HARPO  5.1.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
HarpoAnalysePedestalShift.cxx
Go to the documentation of this file.
1 //
2 // File HarpoAnalysePedestalShift.cxx
3 //
12 #include "HarpoConfig.h"
13 #include "HarpoDetSet.h"
14 #include "HarpoDebug.h"
15 #include "HarpoDccEvent.h"
16 #include "Pmm2Event.h"
17 #include "HarpoEvent.h"
18 #include "HarpoRecoEvent.h"
19 #include "MakeNiceHisto.h"
20 
21 #include "TFile.h"
22 #include "TStyle.h"
23 #include "TCanvas.h"
24 #include "TLatex.h"
25 #include "TGraph.h"
26 #include "TF1.h"
27 #include "TMath.h"
28 #include "TSystem.h"
29 #include "TRootEmbeddedCanvas.h"
30 #include "TGListBox.h"
31 #include "TGLabel.h"
32 
33 #include <cstdlib>
34 #include <cstring>
35 #include <cassert>
36 #include <fstream>
37 #include <iostream>
38 
40 
42  {
43  unsigned int nd; // number of detectors
45 
46  assert(hdr != NULL);
47  hdr->print();
48 
49  for (nd = 0; nd < gkNDetectors; nd++) {
50  // if (fEvt->isdataExist(nd)) {
51  HarpoDccMap *plane = fEvt->GetDccMap(nd);
52  if (plane != NULL )plane->print();
53  }
54  }
55 
57 {
58  // Bool_t drawEvent = kFALSE;
59  nEvents++;
60 
61  Double_t QchMax[2];
62  QchMax[0] = 0;
63  QchMax[1] = 0;
64  Double_t qtot[2];
65  qtot[0] = 0;
66  qtot[1] = 0;
67  // Process RAW data
68  for(Int_t ndet=0;ndet<2;ndet++) { // Detectors 0 and 1 = X and Y planes
69  if (!gHDetSet->isExist(ndet)) continue;
70  HarpoDccMap* m = fEvt->GetDccMap(ndet);
71  if ( m == NULL ) continue;
72  hMapRaw[ndet]->Reset();
73 
74  for(Int_t j=0;j<NCHAN;j++){ // Channels
75  Double_t qch = 0;
76  for(Int_t i=0;i<NADC;i++){ // Time bins
77  Double_t q = m->GetData(j,i);
78  if(qch>4e4 && q<=0)
79  m->SetData(j,i,-2000);
80  if(q <= 0) continue;
81  qch += q;
82  hMapRaw[ndet]->Fill(i,j,qch);
83  hQraw[ndet]->Fill(q);
84  }
85  qtot[ndet] += qch;
86  hQch[ndet]->Fill(qch);
87  if(qch>QchMax[ndet]) QchMax[ndet] = qch;
88  if(qch>QchMax[ndet]) QchMax[ndet] = qch;
89  Int_t index = 0;
90  for(Int_t i=NADC-1;i>=0;i--){
91  Double_t q = m->GetRawData(j,i);
92  if(q<=0) continue;
93  if(qch>5e4) hQsat[ndet]->Fill(index,q);
94  else hQnosat[ndet]->Fill(index,q);
95  if(index == 0) hQlast[ndet]->Fill(qch,q);
96  index++;
97  }
98  index = 0;
99  for(Int_t i=0;i<NADC;i++){
100  Double_t q = m->GetRawData(j,i);
101  if(q<=0) continue;
102  if(qch>5e4) hQsat1[ndet]->Fill(index,q);
103  else hQnosat1[ndet]->Fill(index,q);
104  if(index == 0) hQfirst[ndet]->Fill(qch,q);
105  index++;
106  }
107  }
108  if(QchMax[ndet]>2e4 && gHarpoDebug>1)
109  Info("process","Map %d saturated",ndet);
110  }
111 
112 
113  //std::cout << QchMax[1] << " " << qtot[1] << " " << QchMax[0] << " " << qtot[0] << std::endl;
114  if(qtot[0]<=0) return;
115  if(qtot[1]<=0) return;
116  // if(QchMax[1]<45e3){
117  hRatioVsQchX->Fill(QchMax[0],qtot[0]/qtot[1]);
118  hRatioVsQchXVsQtotX->Fill(QchMax[0],qtot[0],qtot[0]/qtot[1]);
119  // }
120  // if(QchMax[0]<45e3){
121  hRatioVsQchY->Fill(QchMax[1],qtot[0]/qtot[1]);
122  hRatioVsQchYVsQtotY->Fill(QchMax[1],qtot[1],qtot[0]/qtot[1]);
123  //}
124  //std::cout << QchMax[1] << " " << qtot[1] << " " << QchMax[0] << " " << qtot[0] << " " << qtot[0]/qtot[1] << std::endl;
125 
126 
127 }
128 
130 {
131 
132  // Initialise histograms here
133  hMapRaw[0] = new TH2F("hMapRawX","map;Time;Channel",511,0,511,288,0,288);
134  hMapRaw[1] = new TH2F("hMapRawY","map",511,0,511,288,0,288);
135 
136  hPmm2 = new TH2F("hPmm2","map",16,0,16,1024,0,1024);
137  hAngle = new TH1F("hAngle","map",200,0,TMath::Pi());
138 
139  hQraw[0] = new TH1F("hQrawX",";Q_{raw}",4096,0,4096);
140  hQraw[1] = new TH1F("hQrawY",";Q_{raw}",4096,0,4096);
141 
142 
143  hQsat[0] = new TH2F("hQsatX",";index;Q;",511,0,511,4096,0,4096);
144  hQsat[1] = new TH2F("hQsatY",";index;Q;",511,0,511,4096,0,4096);
145  hQnosat[0] = new TH2F("hQnosatX",";index;Q;",511,0,511,4096,0,4096);
146  hQnosat[1] = new TH2F("hQnosatY",";index;Q;",511,0,511,4096,0,4096);
147 
148  hQsat1[0] = new TH2F("hQsat1X",";index;Q;",511,0,511,4096,0,4096);
149  hQsat1[1] = new TH2F("hQsat1Y",";index;Q;",511,0,511,4096,0,4096);
150  hQnosat1[0] = new TH2F("hQnosat1X",";index;Q;",511,0,511,4096,0,4096);
151  hQnosat1[1] = new TH2F("hQnosat1Y",";index;Q;",511,0,511,4096,0,4096);
152 
153 
154 
155 
156  Int_t fNbins = 2000;
157  Double_t fQmin = 100, fQmax = 1e7;
158 
159  Long64_t Nbins;
160  if( ! gHConfig->Lookup("pedshift.nbins",Nbins ))
161  Info("Constructor","Use default fnbinr %d",fNbins);
162  else
163  fNbins = Nbins;
164 
165  Double_t qmin;
166  if( ! gHConfig->Lookup("pedshift.qmin",qmin ))
167  Info("Constructor","Use default Qmin %.3g",fQmin);
168  else
169  fQmin = qmin;
170 
171  Double_t qmax;
172  if( ! gHConfig->Lookup("pedshift.qmax",qmax ))
173  Info("Constructor","Use default Qmax %.3g",fQmax);
174  else
175  fQmax = qmax;
176 
177 
178 
179  const Int_t nbinsQcl = fNbins;
180  Double_t xminQcl = fQmin;
181  Double_t xmaxQcl = fQmax;
182  Double_t logxminQcl = TMath::Log(xminQcl);
183  Double_t logxmaxQcl = TMath::Log(xmaxQcl);
184  Double_t binwidthQcl = (logxmaxQcl-logxminQcl)/nbinsQcl;
185  Double_t xbinsQcl[nbinsQcl+1];
186  xbinsQcl[0] = xminQcl;
187  for (Int_t i=1;i<=nbinsQcl;i++)
188  xbinsQcl[i] = TMath::Exp(logxminQcl+i*binwidthQcl);
189 
190  const Int_t nbinsQcl2 = 200;
191  Double_t xminQcl2 = 1e2;
192  Double_t xmaxQcl2 = 1e7;
193  Double_t logxminQcl2 = TMath::Log(xminQcl2);
194  Double_t logxmaxQcl2 = TMath::Log(xmaxQcl2);
195  Double_t binwidthQcl2 = (logxmaxQcl2-logxminQcl2)/nbinsQcl2;
196  Double_t xbinsQcl2[nbinsQcl2+1];
197  xbinsQcl2[0] = xminQcl2;
198  for (Int_t i=1;i<=nbinsQcl2;i++)
199  xbinsQcl2[i] = TMath::Exp(logxminQcl2+i*binwidthQcl2);
200 
201  hQcl[0] = new TH1F("hQclX",";Q_{cl}",nbinsQcl,xbinsQcl);
202  hQcl[1] = new TH1F("hQclY",";Q_{cl}",nbinsQcl,xbinsQcl);
203 
204 
205  hQch[0] = new TH1F("hQchX",";Q_{ch}",nbinsQcl,xbinsQcl);
206  hQch[1] = new TH1F("hQchY",";Q_{ch}",nbinsQcl,xbinsQcl);
207 
208  hQfirst[0] = new TH2F("hQfirstX",";Q_{first}",nbinsQcl,xbinsQcl,4096,0,4096);
209  hQfirst[1] = new TH2F("hQfirstY",";Q_{first}",nbinsQcl,xbinsQcl,4096,0,4096);
210  hQlast[0] = new TH2F("hQlastX",";Q_{last}",nbinsQcl,xbinsQcl,4096,0,4096);
211  hQlast[1] = new TH2F("hQlastY",";Q_{last}",nbinsQcl,xbinsQcl,4096,0,4096);
212 
213  hRatioVsQchX = new TH2F("hRatioVsQchX",";Q_{channelX}^{max};Q_{x}/Q_{y}",nbinsQcl,xbinsQcl,500,0,5);
214  hRatioVsQchY = new TH2F("hRatioVsQchY",";Q_{channelY}^{max};Q_{x}/Q_{y}",nbinsQcl,xbinsQcl,500,0,5);
215 
216 
217  const Int_t nbinsRatio = 150;
218  Double_t xminRatio = 0;
219  Double_t xmaxRatio = 3;
220  Double_t xbinsRatio[nbinsRatio+1];
221  for (Int_t i=1;i<=nbinsRatio;i++)
222  xbinsRatio[i] = xminRatio + i*1./nbinsRatio*(xmaxRatio - xminRatio);
223 
224 
225  hRatioVsQchXVsQtotX = new TH3F("hRatioVsQchXVsQtotX",";Q_{channelX}^{max};Q_{X}^{tot};Q_{x}/Q_{y}",nbinsQcl2,xbinsQcl2,nbinsQcl2,xbinsQcl2,nbinsRatio,xbinsRatio);
226  hRatioVsQchYVsQtotY = new TH3F("hRatioVsQchYVsQtotY",";Q_{channelY}^{max};Q_{Y}^{tot};Q_{x}/Q_{y}",nbinsQcl2,xbinsQcl2,nbinsQcl2,xbinsQcl2,nbinsRatio,xbinsRatio);
227  }
228 
229 void HarpoAnalysePedestalShift::Save(char * /* mode */)
230  {
231 
232  /* TFile *hf = */ OpenHistFile("PedestalShift");
233 
234  // Save histograms here
235  hMapRaw[0]->Write();
236  hMapRaw[1]->Write();
237  hQraw[0]->Write();
238  hQraw[1]->Write();
239  hQsat[0]->Write();
240  hQsat[1]->Write();
241  hQnosat[0]->Write();
242  hQnosat[1]->Write();
243  hQsat1[0]->Write();
244  hQsat1[1]->Write();
245  hQnosat1[0]->Write();
246  hQnosat1[1]->Write();
247  hQcl[0]->Write();
248  hQcl[1]->Write();
249  hQch[0]->Write();
250  hQch[1]->Write();
251  hQfirst[0]->Write();
252  hQfirst[1]->Write();
253  hQlast[0]->Write();
254  hQlast[1]->Write();
255  hPmm2->Write();
256  hAngle->Write();
257  hRatioVsQchX->Write();
258  hRatioVsQchY->Write();
259  hRatioVsQchXVsQtotX->Write();
260  hRatioVsQchYVsQtotY->Write();
261 
262  }
263 
264 
265 void HarpoAnalysePedestalShift::DisplayAnalysis(TRootEmbeddedCanvas* ecTab, TGListBox* infobox)
266 {
267  // in hrecomonitorgui: fills the canvas on the "Analysis" tab
268  TCanvas* c = ecTab->GetCanvas();
269  c->GetPad(1)->Delete();
270  c->GetPad(2)->Delete();
271  c->Divide(2);
272 
273  for(Int_t plane = 0; plane<2;plane++){
274  TVirtualPad* cMap = c->GetPad(plane+1);
275  cMap->Divide(1,1);
276  hQch[plane]->SetMinimum(0.5);
277  // MakeNiceHisto(hQch[plane],cMap->GetPad(2),"");
278  // cMap->GetPad(2)->SetLogx();
279  // cMap->GetPad(2)->SetLogy();
280  hMapRaw[plane]->SetMaximum(100000);
281  MakeNiceHisto(hMapRaw[plane],cMap->GetPad(1),"colz");
282  Double_t qmax = 0;
283  infobox->NewEntry(Form("Qchmax = %g",qmax));
284  }
285 
286  c->Update();
287 }
288 
289 
290 void HarpoAnalysePedestalShift::ConfigFrame(TGMainFrame* /* fMain */, Int_t /* id */)
291 {
292  // // in hrecomonitorgui: Creates a popup window for analysis configuration
293  // // You must define SetConfig() properly
294 
295  // UInt_t xsize = 200;
296  // UInt_t ysize2 = 20;
297  // UInt_t ysize = 10*ysize2;
298  // TGTransientFrame* main = new TGTransientFrame(gClient->GetRoot(), fMain, xsize, ysize);
299  // main->Connect("CloseWindow()", "HarpoRecoMonitorGui", main, "CloseWindow()");
300  // main->DontCallClose(); // to avoid double deletions.
301 
302  // // use hierarchical cleaning
303  // main->SetCleanup(kDeepCleanup);
304 
305  // TGVerticalFrame* frame = new TGVerticalFrame(main,xsize,ysize,kVerticalFrame);
306 
307  // // Object layout options
308  // TGLayoutHints* fLayout1 = new TGLayoutHints(kLHintsLeft ,5,5,5,5);
309  // TGLayoutHints* fLayout2 = new TGLayoutHints(kLHintsRight ,5,5,5,5);
310  // TGLayoutHints* fLayout3 = new TGLayoutHints(kLHintsTop | kLHintsExpandX ,5,5,5,5);
311  // TGLayoutHints* fLayout4 = new TGLayoutHints(kLHintsExpandX | kLHintsExpandY,5,5,5,5);
312 
313  // //________ DO NOT MODIFY ABOVE _____________________________
314 
315 
316 
317 
318  // // // Title of the analysis
319  // // TGLabel* fAnalysisLabel = new TGLabel(frame, "Template analysis");
320 
321  // // // Create a line for choosing value of parameter
322  // // TGHorizontalFrame* nBinsFrame = new TGHorizontalFrame(frame,xsize,ysize2,kHorizontalFrame);
323  // // TGLabel* nBinsLabel = new TGLabel(nBinsFrame, "fNbins");
324  // // fChooseNbins = new TGNumberEntry(nBinsFrame);
325  // // fChooseNbins->SetNumber(fNbins);
326 
327  // // main->AddFrame(frame,fLayout4);
328  // // frame->AddFrame(fAnalysisLabel,fLayout3);
329  // // frame->AddFrame(nBinsFrame,fLayout3);
330  // // nBinsFrame->AddFrame(nBinsLabel,fLayout1);
331  // // nBinsFrame->AddFrame(fChooseNbins,fLayout2);
332 
333 
334 
335  // //________ DO NOT MODIFY BELOW _____________________________
336  // // Button to validate configuration
337  // TGTextButton* setConf = new TGTextButton(frame,"Save Config",id);
338  // setConf->Associate(fMain);
339 
340  // frame->AddFrame(setConf,fLayout3);
341 
342  // main->MapSubwindows();
343  // main->MapWindow();
344  // main->Resize();
345  return;
346 }
347 
348 
349 
351 {
352  // Update the configuration according to the values in the popup window
353 
354  // if(!fChooseNbins) return;
355 
356  // fNbins = fChooseNbins->GetNumber();
357 }
Dummy analysis to run as test and example. Give basic histograms of the data.
void DisplayAnalysis(TRootEmbeddedCanvas *ecTab, TGListBox *infobox)
Redefine empty default.
#define NCHAN
Definition: HarpoDccMap.h:16
Double_t GetRawData(Int_t i, Int_t j)
Definition: HarpoDccMap.cxx:75
void print()
Overloaded method which do all job.
Double_t GetData(Int_t i, Int_t j)
Set/Get Data Cell.
Definition: HarpoDccMap.cxx:84
Bool_t isExist(ULong_t det)
Detecror date exist //! Number of Real Detectors.
Definition: HarpoDetSet.h:33
void SetData(Int_t i, Int_t j, Double_t val)
virtual void print()
FullEvent Header not scecific to the detectors The class is ....
virtual void print()
TFile * OpenHistFile(const char *ananame)
unpacked dcc data The class contains the data map for DCC or Feminos The data is stored as a 2D TMatr...
Definition: HarpoDccMap.h:29
TVirtualPad * MakeNiceHisto(TH1 *hist, TVirtualPad *c1, const char *opt, Bool_t copy)
#define NADC
Definition: HarpoDccMap.h:18
Long64_t gHarpoDebug
Definition: HarpoDebug.cxx:9
Bool_t Lookup(const char *path, Bool_t &val)
Lookup function for scalar values.
HarpoEventHeader * GetHeader()
Definition: HarpoEvent.cxx:80
HarpoEvent * fEvt
Definition: HarpoAnalyse.h:70
ULong_t nEvents
Definition: HarpoAnalyse.h:75
void ConfigFrame(TGMainFrame *fMain, Int_t id)
const ULong_t gkNDetectors
Definition: HarpoDet.h:14
HarpoConfig * gHConfig
HarpoDccMap * GetDccMap(Long_t plane=XDCC)
Definition: HarpoEvent.cxx:108
R__EXTERN HarpoDetSet * gHDetSet
Definition: HarpoDetSet.h:71