]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TOF/AliTOFQADataMakerRec.cxx
Adding ability to use multiple test functions
[u/mrichter/AliRoot.git] / TOF / AliTOFQADataMakerRec.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 ///////////////////////////////////////////////////////////////////////
17 //                                                                   //
18 //  Produces the data needed to calculate the TOF quality assurance. //
19 //  QA objects are 1 & 2 Dimensional histograms.                     //
20 //  author: S.Arcelli                                                //
21 //                                                                   //
22 ///////////////////////////////////////////////////////////////////////
23
24 /*
25 Modified by fbellini on 01/11/2011
26 - removed TLines as functions
27 - changed shifters plots for 2012 DQM
28
29 Modified by fbellini on 01/11/2011
30 - added histograms for LTM monitoring
31 - fix for coverity
32
33 Modified by fbellini on 17/10/2011
34 - fix for memory leak in constructor
35 - added methods to read histos ranges from config file in DQM
36 - added CTTM maps + relative methods to retrieve CTTM numbering
37 - removed obslete comments
38
39 Modified by fbellini & rshanoian on 06/07/2011
40 - changes for trigger classes implementation
41 - fRunNumber added as private member
42 - added time vs BCID plot
43
44 Modified by fbellini on 18/01/2011
45 - reduced histo binning to reduce size 
46 - added decoding errors plot
47 - added channel maps and options for DQM shifters
48 - new list of recPoints and ESDs plots
49 - removed hTrmChannels035 and hTrmChannels3671
50
51  Modified by bvonhall on 03/11/2010
52    - modified declaration of hTrmChannels035 and hTrmChannels3671 in EndOfDetectorCycle()
53      to prevent memory corruption
54    
55  Modified by adecaro on 18/10/2010
56    - fTOFRawStream object set as private member
57  
58 Modified by fbellini on 13/09/2010
59   - Set TLines as private members
60   - Set image flag for expert histos
61
62 Modified by fbellini on 14/06/2010
63   - Updated plots
64   - use LoadRawDataBuffersV2()
65
66   Modified by fbellini on 10/05/2010
67   - Fixed EndOfDetectorCycle() memory corruption bug
68
69   Modified by fbellini on 22/04/2010
70    - Added filter for physics events
71
72    Modified by fbellini on 16/04/2010
73    - Added EnableDqmShifterOpt() 
74    - Modified EndOfDetectorCycle() with options for DQM         
75    - Updated ESDs QA
76
77    Modified by fbellini on 30/03/2010
78    - Changed raws time histos range to 610ns
79    - Added FilterLTMData() and FilterSpare() methods
80    - Added check on enabled channels for raw data               
81    - Updated RecPoints QA
82
83    Modified by fbellini on 02/03/2010
84    - Fixed raw data decoding methods (use AliTOFRawStream::LoadRawDataBuffer())
85    - Added filter for noisy channels and read map from OCDB
86    - Added GetCalibData() method
87    - Added CheckVolumeID() and CheckEquipID() methods  
88    - Updated Raw QA
89 */
90 #include <iostream>
91 #include <fstream>
92
93 #include <TClonesArray.h>
94 #include <TH1F.h> 
95 #include <TH2F.h> 
96 #include <TLine.h>
97 #include <TPaveText.h>
98
99 #include "AliCDBManager.h"
100 #include "AliCDBEntry.h"
101 #include "AliESDEvent.h"
102 #include "AliESDtrack.h"
103 #include "AliQAChecker.h"
104 #include "AliRawReader.h"
105 #include "AliTOFRawStream.h"
106 #include "AliTOFcluster.h"
107 #include "AliTOFQADataMakerRec.h"
108 #include "AliTOFrawData.h"
109 #include "AliTOFGeometry.h"
110 #include "AliTOFChannelOnlineStatusArray.h"
111 #include "AliTOFDecoderSummaryData.h"
112 #include "AliTOFDecoderV2.h"
113
114 ClassImp(AliTOFQADataMakerRec)
115
116 Int_t AliTOFQADataMakerRec::fgNbinsMultiplicity=200; //number of bins in multiplicity plot
117 Int_t AliTOFQADataMakerRec::fgRangeMinMultiplicity=0;//min range in multiplicity plot
118 Int_t AliTOFQADataMakerRec::fgRangeMaxMultiplicity=200;//max range in multiplicity plot
119 Int_t AliTOFQADataMakerRec::fgNbinsTime=250;//number of bins in time plot
120 const Float_t AliTOFQADataMakerRec::fgkNbinsWidthTime=2.44;//width of bins in time plot
121 Float_t AliTOFQADataMakerRec::fgRangeMinTime=0.0;//range min in time plot
122 Float_t AliTOFQADataMakerRec::fgRangeMaxTime=620.0; //range max in time plot
123 Int_t AliTOFQADataMakerRec::fgCutNmaxFiredMacropad=50;//cut on number of max fired macropad
124 const Int_t AliTOFQADataMakerRec::fgkFiredMacropadLimit=50;//cut on number of max fired macropad
125
126
127 //____________________________________________________________________________ 
128   AliTOFQADataMakerRec::AliTOFQADataMakerRec() : 
129   AliQADataMakerRec(AliQAv1::GetDetName(AliQAv1::kTOF), "TOF Quality Assurance Data Maker"),
130   fCalibData(0x0),
131   fEnableNoiseFiltering(kFALSE),
132   fEnableDqmShifterOpt(kFALSE),
133   fIsSOC(kFALSE),
134   fLineExpTimeMin(0x0),
135   fLineExpTimeMax(0x0),
136   fLineExpTotMin(0x0),
137   fLineExpTotMax(0x0),
138   fTOFRawStream(AliTOFRawStream()),
139   fDecoderSummary(0),
140   fRunNumber(-1),
141   fCalib(AliTOFcalib())
142 {
143   //
144   // ctor
145   //   
146   // fLineExpTimeMin = new TLine(200., 0., 200., 0.);
147   // fLineExpTimeMax = new TLine(250., 0., 250., 0.);
148   // fLineExpTotMin = new TLine(5., 0., 5., 0.);
149   // fLineExpTotMax = new TLine(20., 0., 20., 0.);
150   /*
151     for (Int_t sm=0;sm<17;sm++){
152     fLineSMid[sm] = new TLine( sm+1, 0., sm+1, 91.);
153   }
154
155   for (Int_t sm=0;sm<71;sm++){
156     fLineLTMid[sm] = new TLine( sm+1, 0., sm+1, 23.);
157   }
158
159   for (Int_t sm=0;sm<22;sm++){
160     fLineLTMbitId[sm] = new TLine( 0., sm+1, 72. ,sm+1);
161   }
162   */
163 }
164
165 //____________________________________________________________________________ 
166 AliTOFQADataMakerRec::AliTOFQADataMakerRec(const AliTOFQADataMakerRec& qadm) :
167   AliQADataMakerRec(),
168   fCalibData(qadm.fCalibData),
169   fEnableNoiseFiltering(qadm.fEnableNoiseFiltering),
170   fEnableDqmShifterOpt(qadm.fEnableDqmShifterOpt),
171   fIsSOC(qadm.fIsSOC),
172   fLineExpTimeMin(qadm.fLineExpTimeMin),
173   fLineExpTimeMax(qadm.fLineExpTimeMax),
174   fLineExpTotMin(qadm.fLineExpTotMin),
175   fLineExpTotMax(qadm.fLineExpTotMax),
176   fTOFRawStream(qadm.fTOFRawStream),
177   fDecoderSummary(qadm.fDecoderSummary),
178   fRunNumber(qadm.fRunNumber),
179   fCalib(qadm.fCalib)
180 {
181   //
182   //copy ctor 
183   //
184   SetName((const char*)qadm.GetName()) ; 
185   SetTitle((const char*)qadm.GetTitle()); 
186   /*
187   for (Int_t sm=0;sm<17;sm++){
188     fLineSMid[sm]=qadm.fLineSMid[sm];
189   }
190
191  for (Int_t sm=0;sm<71;sm++){
192     fLineLTMid[sm] = qadm.fLineLTMid[sm];
193   }
194
195   for (Int_t sm=0;sm<22;sm++){
196     fLineLTMbitId[sm] = qadm.fLineLTMbitId[sm];
197   }
198   */
199 }
200
201 //__________________________________________________________________
202 AliTOFQADataMakerRec& AliTOFQADataMakerRec::operator = (const AliTOFQADataMakerRec& qadm )
203 {
204   //
205   // assignment operator.
206   //
207   this->~AliTOFQADataMakerRec();
208   new(this) AliTOFQADataMakerRec(qadm);
209   return *this;
210 }
211  
212 //----------------------------------------------------------------------------
213 AliTOFQADataMakerRec::~AliTOFQADataMakerRec()
214 {
215   //destructor
216   fTOFRawStream.Clear();
217   fCalib.Clear();
218   if (fLineExpTimeMin)
219     delete fLineExpTimeMin;
220   if (fLineExpTimeMax)
221     delete fLineExpTimeMax;
222   if (fLineExpTotMin)
223     delete fLineExpTotMin;
224   if (fLineExpTotMax)
225     delete fLineExpTotMax;
226   /*
227     for (Int_t sm=0;sm<17;sm++){
228     if (fLineSMid[sm])
229       delete fLineSMid[sm];
230   }
231   for (Int_t sm=0;sm<71;sm++){
232     if (fLineLTMid[sm])
233       delete fLineLTMid[sm];
234   }
235 for (Int_t sm=0;sm<22;sm++){
236     if (fLineLTMbitId[sm])
237       delete fLineLTMbitId[sm];
238   }
239   */
240 }
241 //----------------------------------------------------------------------------
242 AliTOFChannelOnlineStatusArray* AliTOFQADataMakerRec::GetCalibData() 
243 {
244   //
245   // Retrive TOF calib objects from OCDB
246   //
247   AliCDBManager *man = AliCDBManager::Instance();
248   AliCDBEntry *cdbe=0;
249  
250   if (fRun<=0) fRunNumber=145288; //reference run from LHC11a
251   else fRunNumber=fRun;
252   
253   if (man->GetRun()!=fRunNumber){
254     fRunNumber=man->GetRun();
255     AliWarning(Form("Run number mismatch found: setting it to value from current AliCDBManager instance = %i", fRunNumber));
256   }
257   cdbe = man->Get("TOF/Calib/Status",fRunNumber);
258   
259   if(!cdbe){
260     // for DQM online
261     AliWarning("Load of calibration data from default (alien://) storage failed!");
262     printf("Calibration data will be loaded from local storage - ok if on DQM station!");
263     man->SetDefaultStorage("local:///local/cdb/");
264     cdbe = man->Get("TOF/Calib/Status",fRun);
265     
266     if(!cdbe){
267       AliWarning("Load of calibration data from local DQM machine storage failed!");
268       AliWarning("Calibration data will be loaded from local ($ALICE_ROOT) storage ");
269       man->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
270       cdbe = man->Get("TOF/Calib/Status",fRunNumber);
271     }
272   }
273   // Retrieval of data in directory TOF/Calib/Data:
274   AliTOFChannelOnlineStatusArray * array = 0;
275   if (cdbe) {
276     printf("======= OCDB object for TOF retrieved from run %i in %s\n",fRunNumber,cdbe->GetName());
277     array = (AliTOFChannelOnlineStatusArray *)cdbe->GetObject();
278   }
279   if (!array)  AliFatal("No calibration data from calibration database !");
280   
281   fCalib.Init(fRunNumber);
282   return array;
283 }
284
285 //____________________________________________________________________________ 
286 void AliTOFQADataMakerRec::InitRaws()
287 {
288   //
289   // create Raws histograms in Raws subdir
290   //
291   ReadHistogramRangeFromFile(gSystem->Getenv("TOFDQMHISTO_CONFIGFILE"));
292   
293   const Bool_t expert   = kTRUE ; 
294   const Bool_t saveCorr = kTRUE ; 
295   const Bool_t image    = kTRUE ; 
296
297   TH1I * h0 =  new TH1I("hTOFRaws","TOF raw hit multiplicity; TOF raw hits number; Events ",fgNbinsMultiplicity, fgRangeMinMultiplicity, fgRangeMaxMultiplicity);
298   TH1I * h1 =  new TH1I("hTOFRawsIA","TOF raw hit multiplicity - I/A side; TOF raw hits number;Events ",fgNbinsMultiplicity, fgRangeMinMultiplicity, fgRangeMaxMultiplicity);
299   TH1I * h2 =  new TH1I("hTOFRawsOA","TOF raw hit multiplicity - O/A side; TOF raw hits number;Events ",fgNbinsMultiplicity, fgRangeMinMultiplicity, fgRangeMaxMultiplicity);
300   TH1I * h3 =  new TH1I("hTOFRawsIC","TOF raw hit multiplicity - I/C side; TOF raw hits number;Events ",fgNbinsMultiplicity, fgRangeMinMultiplicity, fgRangeMaxMultiplicity);
301   TH1I * h4 =  new TH1I("hTOFRawsOC","TOF raw hit multiplicity - O/C side; TOF raw hits number;Events ",fgNbinsMultiplicity, fgRangeMinMultiplicity, fgRangeMaxMultiplicity);
302
303   TH1F * h5  = new TH1F("hTOFRawsTime", "TOF Raws - Hit time (ns);Measured Hit time [ns];Hits", fgNbinsTime,fgRangeMinTime,fgRangeMaxTime); 
304   TH1F * h6  = new TH1F("hTOFRawsTimeIA", "TOF Raws - Hit time (ns) - I/A side;Measured Hit time [ns];Hits", fgNbinsTime,fgRangeMinTime,fgRangeMaxTime); 
305   TH1F * h7  = new TH1F("hTOFRawsTimeOA", "TOF Raws - Hit time (ns) - O/A side;Measured Hit time [ns];Hits", fgNbinsTime,fgRangeMinTime,fgRangeMaxTime); 
306   TH1F * h8  = new TH1F("hTOFRawsTimeIC", "TOF Raws - Hit time (ns) - I/C side;Measured Hit time [ns];Hits", fgNbinsTime,fgRangeMinTime,fgRangeMaxTime); 
307   TH1F * h9  = new TH1F("hTOFRawsTimeOC", "TOF Raws - Hit time (ns) - O/C side;Measured Hit time [ns];Hits", fgNbinsTime,fgRangeMinTime,fgRangeMaxTime); 
308   
309   TH1F * h10  = new TH1F("hTOFRawsToT", "TOF Raws - Hit ToT (ns);Measured Hit ToT (ns);Hits", 100, 0., 48.8); 
310   
311   TH1F * h11  = new TH1F("hTOFRawsToTIA", "TOF Raws - Hit ToT (ns) - I/A side;Measured Hit ToT (ns);Hits", 100, 0., 48.8); 
312   TH1F * h12  = new TH1F("hTOFRawsToTOA", "TOF Raws - Hit ToT (ns) - O/A side;Measured Hit ToT (ns);Hits", 100, 0., 48.8); 
313   TH1F * h13  = new TH1F("hTOFRawsToTIC", "TOF Raws - Hit ToT (ns) - I/C side;Measured Hit ToT (ns);Hits", 100, 0., 48.8); 
314   TH1F * h14  = new TH1F("hTOFRawsToTOC", "TOF Raws - Hit ToT (ns) - O/C side;Measured Hit ToT (ns);Hits", 100, 0., 48.8); 
315   
316   TH1F * h15 = new TH1F("hTOFRawsLTMHits", "LTMs OR signals; Crate; Counts",  72, 0., 72.);
317   TH2F * h16  = new TH2F("hTOFrefMap", "TOF enabled channel reference map;sector;strip",  72, 0., 18., 91, 0., 91.);
318   TH2F * h17  = new TH2F("hTOFRawHitMap","TOF raw hit map;sector;strip", 72, 0., 18., 91, 0., 91.);
319   TH2I * h18 = new TH2I("hTOFDecodingErrors","Decoding error monitoring; DDL; Error ", 72, 0, 72, 13,1,14);
320   
321   h18->GetYaxis()->SetBinLabel(1,"DRM ");
322   h18->GetYaxis()->SetBinLabel(2,"LTM ");
323   h18->GetYaxis()->SetBinLabel(3,"TRM 3 ");
324   h18->GetYaxis()->SetBinLabel(4,"TRM 4");
325   h18->GetYaxis()->SetBinLabel(5,"TRM 5");
326   h18->GetYaxis()->SetBinLabel(6,"TRM 6");
327   h18->GetYaxis()->SetBinLabel(7,"TRM 7");
328   h18->GetYaxis()->SetBinLabel(8,"TRM 8");
329   h18->GetYaxis()->SetBinLabel(9,"TRM 9");
330   h18->GetYaxis()->SetBinLabel(10,"TRM 10");
331   h18->GetYaxis()->SetBinLabel(11,"TRM 11");
332   h18->GetYaxis()->SetBinLabel(12,"TRM 12");
333   h18->GetYaxis()->SetBinLabel(13,"recovered");
334   
335   TH1F * h19  = new TH1F("hTOFOrphansTime", "TOF Raws - Orphans time (ns);Measured Hit time [ns];Hits",fgNbinsTime,fgRangeMinTime,fgRangeMaxTime); 
336   TH2F * h20 = new TH2F("hTOFRawTimeVsTRM035", "TOF raws - Hit time vs TRM - crates 0 to 35; TRM index = DDL*10+TRM(0-9);TOF raw time [ns]", 361, 0., 361.,fgNbinsTime,fgRangeMinTime,fgRangeMaxTime);
337   TH2F * h21 = new TH2F("hTOFRawTimeVsTRM3671", "TOF raws - Hit time vs TRM - crates 36 to 72; TRM index = DDL**10+TRM(0-9);TOF raw time [ns]", 361, 360., 721.,fgNbinsTime, fgRangeMinTime,fgRangeMaxTime);
338   TH2F * h22 = new TH2F("hTOFTimeVsStrip","TOF raw hit time vs. MRPC (along z axis); MRPC index along z axis; Raws TOF time (ns) ", 91,0.,91,fgNbinsTime,fgRangeMinTime,fgRangeMaxTime); 
339   TH2F * h23 = new TH2F("hTOFtimeVsBCID","TOF time vs BCID; BCID; time (ns) ", 3564, 0., 3564.,fgNbinsTime,fgRangeMinTime,fgRangeMaxTime);
340   TH2F * h24 = new TH2F("hTOFchannelEfficiencyMap","TOF channels (HWok && efficient && !noisy && !problematic);sector;strip",  72, 0., 18., 91, 0., 91.);
341   TH2F * h25 = new TH2F("hTOFhitsCTTM","Map of hit pads according to CTTM numbering;LTM index;bit index",  72, 0., 72., 23, 0., 23.);
342   TH2F * h26 = new TH2F("hTOFmacropadCTTM","Map of hit macropads according to CTTM numbering;LTM index; bit index",  72, 0., 72., 23, 0., 23.);
343   TH2F * h27 = new TH2F("hTOFmacropadDeltaPhiTime","#Deltat vs #Delta#Phi of hit macropads;#Delta#Phi (degrees);#DeltaBX",  18, 0., 180., 20, 0., 20.0);
344   TH2I *h28 = new TH2I("hBXVsCttmBit","BX ID in TOF matching window vs trg channel; trg channel; BX", 1728, 0, 1728, 24, 0, 24); 
345   TH2F *h29 = new TH2F("hTimeVsCttmBit","TOF raw time vs trg channel; trg channel; raw time (ns)", 1728, 0., 1728., fgNbinsTime, fgRangeMinTime, fgRangeMaxTime); 
346
347   h25->GetYaxis()->SetTickLength(-0.02);
348   h26->GetYaxis()->SetTickLength(-0.02);
349   h25->GetYaxis()->SetNdivisions(210);
350   h26->GetYaxis()->SetNdivisions(210);
351   h25->GetXaxis()->SetTickLength(-0.02);
352   h26->GetXaxis()->SetTickLength(-0.02);
353   h25->GetXaxis()->SetLabelOffset(0.015);
354   h26->GetXaxis()->SetLabelOffset(0.015);
355   h25->GetXaxis()->SetNdivisions(515);
356   h26->GetXaxis()->SetNdivisions(515);
357   
358   h0->Sumw2() ;
359   h1->Sumw2() ;
360   h2->Sumw2() ;
361   h3->Sumw2() ;
362   h4->Sumw2() ;
363   //  h5->Sumw2() ;
364   h6->Sumw2() ;
365   h7->Sumw2() ;
366   h8->Sumw2() ;
367   h9->Sumw2() ;
368   // h10->Sumw2() ;
369   h11->Sumw2() ;
370   h12->Sumw2() ;
371   h13->Sumw2() ;
372   h14->Sumw2() ;
373   h15->Sumw2() ;
374   h16->Sumw2() ;
375   h17->Sumw2() ;
376   h18->Sumw2() ;
377   h19->Sumw2() ;
378   h20->Sumw2() ;
379   h21->Sumw2() ;
380   h22->Sumw2() ;
381   h23->Sumw2() ;
382   h24->Sumw2() ;
383   h25->Sumw2() ;
384   h26->Sumw2() ;
385   h27->Sumw2() ;
386   h28->Sumw2() ;
387   h29->Sumw2() ;
388
389   //add lines for DQM shifter
390   fLineExpTimeMin = new TLine(200., 0., 200., 0.);
391   fLineExpTimeMax = new TLine(300., 0., 300., 0.);
392   fLineExpTotMin = new TLine(10., 0., 10., 0.);
393   fLineExpTotMax = new TLine(15., 0., 15., 0.);
394
395   fLineExpTimeMin->SetLineColor(kGreen);
396   fLineExpTimeMin->SetLineWidth(2);
397   
398   fLineExpTimeMax->SetLineColor(kGreen);
399   fLineExpTimeMax->SetLineWidth(2);
400   
401   fLineExpTotMin->SetLineColor(kGreen);
402   fLineExpTotMin->SetLineWidth(2);
403   
404   fLineExpTotMax->SetLineColor(kGreen);
405   fLineExpTotMax->SetLineWidth(2);
406   
407   /*
408     for (Int_t sm=0;sm<17;sm++){
409     fLineSMid[sm]->SetLineColor(kMagenta);
410     fLineSMid[sm]->SetLineWidth(2);
411   }
412   */
413   h5->GetListOfFunctions()->Add(fLineExpTimeMin);
414   h5->GetListOfFunctions()->Add(fLineExpTimeMax);
415   h10->GetListOfFunctions()->Add(fLineExpTotMin);
416   h10->GetListOfFunctions()->Add(fLineExpTotMax);
417   /*
418   for (Int_t sm=0;sm<17;sm++){
419     h16->GetListOfFunctions()->Add(fLineSMid[sm]);
420     h17->GetListOfFunctions()->Add(fLineSMid[sm]);
421   }
422   for (Int_t sm=0;sm<71;sm++){
423     fLineLTMid[sm]->SetLineColor(kBlack);
424     fLineLTMid[sm]->SetLineWidth(1);
425     h26->GetListOfFunctions()->Add(fLineLTMid[sm]);
426     h25->GetListOfFunctions()->Add(fLineLTMid[sm]);
427   }
428   for (Int_t sm=0;sm<22;sm++){
429     fLineLTMbitId[sm]->SetLineColor(kBlack);
430     fLineLTMbitId[sm]->SetLineWidth(1);
431     h26->GetListOfFunctions()->Add(fLineLTMbitId[sm]);
432     h25->GetListOfFunctions()->Add(fLineLTMbitId[sm]);
433   }
434   */
435   TPaveText *phosHoleBox=new TPaveText(13,38,16,53,"b");        
436   phosHoleBox->SetFillStyle(0);
437   phosHoleBox->SetFillColor(kWhite);
438   phosHoleBox->SetLineColor(kMagenta);
439   phosHoleBox->SetLineWidth(2);
440   phosHoleBox->AddText("PHOS"); 
441   h16->GetListOfFunctions()->Add(phosHoleBox);
442   h17->GetListOfFunctions()->Add(phosHoleBox);
443
444   // h0->SetDrawOption("logy");
445   // h5->SetDrawOption("logy");
446   // h10->SetDrawOption("logy");
447
448   Add2RawsList(h0,   0, !expert,  image, !saveCorr) ;
449   Add2RawsList(h1,   1,  expert, !image, !saveCorr) ;
450   Add2RawsList(h2,   2,  expert, !image, !saveCorr) ;
451   Add2RawsList(h3,   3,  expert, !image, !saveCorr) ;
452   Add2RawsList(h4,   4,  expert, !image, !saveCorr) ;
453   Add2RawsList(h5,   5, !expert,  image, !saveCorr) ;
454   Add2RawsList(h6,   6,  expert, !image, !saveCorr) ;
455   Add2RawsList(h7,   7,  expert, !image, !saveCorr) ;
456   Add2RawsList(h8,   8,  expert, !image, !saveCorr) ;
457   Add2RawsList(h9,   9,  expert, !image, !saveCorr) ;
458   Add2RawsList(h10, 10, !expert,  image, !saveCorr) ;
459   Add2RawsList(h11, 11,  expert, !image, !saveCorr) ;
460   Add2RawsList(h12, 12,  expert, !image, !saveCorr) ;
461   Add2RawsList(h13, 13,  expert, !image, !saveCorr) ;
462   Add2RawsList(h14, 14,  expert, !image, !saveCorr) ;
463   Add2RawsList(h15, 15,  expert, !image, !saveCorr) ;
464   Add2RawsList(h16, 16, !expert,  image, !saveCorr) ;
465   Add2RawsList(h17, 17, !expert,  image, !saveCorr) ;
466   Add2RawsList(h18, 18,  expert, !image, !saveCorr) ;
467   Add2RawsList(h19, 19,  expert, !image, !saveCorr) ;
468   Add2RawsList(h20, 20,  expert, !image, !saveCorr) ;
469   Add2RawsList(h21, 21,  expert, !image, !saveCorr) ;
470   Add2RawsList(h22, 22,  expert, !image, !saveCorr) ;
471   Add2RawsList(h23, 23,  expert, !image, !saveCorr) ;
472   Add2RawsList(h24, 24,  expert, !image, !saveCorr) ;
473   Add2RawsList(h25, 25,  expert, !image, !saveCorr) ;
474   Add2RawsList(h26, 26,  expert,  image, !saveCorr) ;
475   Add2RawsList(h27, 27,  expert, !image, !saveCorr) ;
476   Add2RawsList(h28, 28,  expert, !image, !saveCorr) ;
477   Add2RawsList(h29, 29,  expert, !image, !saveCorr) ;
478   
479 //
480   ClonePerTrigClass(AliQAv1::kRAWS); // this should be the last line
481 }
482
483 //____________________________________________________________________________ 
484 void AliTOFQADataMakerRec::InitRecPoints()
485 {
486   //
487   // create RecPoints histograms in RecPoints subdir
488   //
489   
490   const Bool_t expert   = kTRUE ; 
491   const Bool_t image    = kTRUE ; 
492
493   TH1I * h0 = new TH1I("hTOFRecPoints",    "TOF RecPoints multiplicity ; TOF RecPoints number;Events",200, 0, 200) ;
494
495   TH1F * h1 = new TH1F("hTOFRecPointsTimeIA", "RecPoints Time Spectrum in TOF (ns)- I/A side; Calibrated TOF time [ns];Events", 250, 0., 610.) ; 
496   TH1F * h2 = new TH1F("hTOFRecPointsTimeOA", "RecPoints Time Spectrum in TOF (ns)- O/A side; Calibrated TOF time [ns];Events", 250, 0., 610.) ;
497   TH1F * h3 = new TH1F("hTOFRecPointsTimeIC", "RecPoints Time Spectrum in TOF (ns)- I/C side; Calibrated TOF time [ns];Events", 250, 0., 610.) ;
498   TH1F * h4 = new TH1F("hTOFRecPointsTimeOC", "RecPoints Time Spectrum in TOF (ns)- O/C side; Calibrated TOF time [ns];Events", 250, 0., 610.) ;
499   
500   TH1F * h5  = new TH1F("hTOFRecPointsRawTimeIA", "RecPoints raw Time Spectrum in TOF (ns)-I/A side; Measured TOF time [ns];Hits", 250, 0., 610.) ; 
501   TH1F * h6  = new TH1F("hTOFRecPointsRawTimeOA", "RecPoints raw Time Spectrum in TOF (ns)-O/A side; Measured TOF time [ns];Hits", 250, 0., 610.) ; 
502   TH1F * h7  = new TH1F("hTOFRecPointsRawTimeIC", "RecPoints raw Time Spectrum in TOF (ns)-I/C side; Measured TOF time [ns];Hits", 250, 0., 610.) ; 
503   TH1F * h8  = new TH1F("hTOFRecPointsRawTimeOC", "RecPoints raw Time Spectrum in TOF (ns)-O/C side; Measured TOF time [ns];Hits", 250, 0., 610.) ; 
504  
505   TH1F * h9   = new TH1F("hTOFRecPointsToTIA", "RecPoints ToT Spectrum in TOF (ns)-I/A side; Measured TOT [ns];Hits", 100, 0., 48.8 ) ; 
506   TH1F * h10  = new TH1F("hTOFRecPointsToTOA", "RecPoints ToT Spectrum in TOF (ns)-O/A side; Measured TOT [ns];Hits", 100, 0., 48.8 ) ; 
507   TH1F * h11  = new TH1F("hTOFRecPointsToTIC", "RecPoints ToT Spectrum in TOF (ns)-I/C side; Measured TOT [ns];Hits", 100, 0., 48.8 ) ; 
508   TH1F * h12  = new TH1F("hTOFRecPointsToTOC", "RecPoints ToT Spectrum in TOF (ns)-O/C side; Measured TOT [ns];Hits", 100, 0., 48.8 ) ; 
509   
510   TH2F * h13 = new TH2F("hTOFRecPointsClusMap","RecPoints map; sector ;strip", 72, 0., 18., 91, 0., 91.) ; 
511   TH2F * h14 = new TH2F("hTOFRecPointsTimeVsStrip","RecPoints TOF time vs. strip (theta); Strip index; RecPoints TOF time (ns) ",91, 0., 91., 250, 0., 610.) ;
512   TH2F * h15 = new TH2F("hTOFRecPointsTimeVsTRM035","TOF RecPoints time vs TRM - crates 0 to 35; TRM index = DDL*10+TRM(0-9);TOF time [ns]", 361, 0., 361., 250, 0., 610.0) ;
513   TH2F * h16 = new TH2F("hTOFRecPointsTimeVsTRM3671","TOF RecPoints time vs TRM - crates 36 to 72; TRM index = DDL**10+TRM(0-9);TOF time [ns]", 361, 360., 721., 250, 0., 610.0) ;
514
515   h0->Sumw2() ;
516   h1->Sumw2() ;
517   h2->Sumw2() ;
518   h3->Sumw2() ;
519   h4->Sumw2() ;
520   h5->Sumw2() ;
521   h6->Sumw2() ;
522   h7->Sumw2() ;
523   h8->Sumw2() ;
524   h9->Sumw2() ;
525   h10->Sumw2() ;
526   h11->Sumw2() ;
527   h12->Sumw2() ;
528   h13->Sumw2() ;
529   h14->Sumw2() ;
530   h15->Sumw2() ;
531   h16->Sumw2() ;
532    
533   Add2RecPointsList(h0, 0,   !expert,  image) ;
534   Add2RecPointsList(h1, 1,   !expert,  image) ;
535   Add2RecPointsList(h2, 2,   !expert,  image) ;
536   Add2RecPointsList(h3, 3,   !expert,  image) ;
537   Add2RecPointsList(h4, 4,   !expert,  image) ;
538   Add2RecPointsList(h5, 5,    expert,  !image) ;
539   Add2RecPointsList(h6, 6,    expert, !image) ;
540   Add2RecPointsList(h7, 7,    expert, !image) ;
541   Add2RecPointsList(h8, 8,    expert, !image) ;
542   Add2RecPointsList(h9, 9,   !expert, !image) ;
543   Add2RecPointsList(h10, 10, !expert, !image) ;
544   Add2RecPointsList(h11, 11, !expert, !image) ;
545   Add2RecPointsList(h12, 12, !expert, !image) ;
546   Add2RecPointsList(h13, 13,  expert, !image) ;
547   Add2RecPointsList(h14, 14,  expert, image) ;
548   Add2RecPointsList(h15, 15,  expert, !image) ;
549   Add2RecPointsList(h16, 16,  expert, !image) ;
550   //
551   ClonePerTrigClass(AliQAv1::kRECPOINTS); // this should be the last line
552 }
553
554 //____________________________________________________________________________ 
555 void AliTOFQADataMakerRec::InitESDs()
556 {
557   //
558   //create ESDs histograms in ESDs subdir
559   //
560
561   const Bool_t expert   = kTRUE ; 
562   const Bool_t image    = kTRUE ; 
563
564   TH1I * h0  = new TH1I("hTOFESDs", "Number of matched TOF tracks per event;Number of TOF matched ESD tracks;Counts", 200, 0, 200) ;  
565   TH1F * h1  = new TH1F("hTOFESDsTime", "Matched  ESDs tracks: TOF Time spectrum; Calibrated TOF time [ns];Counts", 250, 0., 610. ) ; 
566   TH1F * h2  = new TH1F("hTOFESDsRawTime", "Matched ESDs tracks: TOF raw Time spectrum;Measured TOF time [ns];Counts", 250, 0., 610.) ; 
567   TH1F * h3  = new TH1F("hTOFESDsToT", "Matched ESDs tracks: TOF ToT spectrum; ESDs ToT [ns];Counts",100, 0., 48.8) ; 
568   TH1F * h4  = new TH1F("hTOFESDskTOFOUT", "p_{T}  distribution of tracks with kTOFout; p_{T} (GeV/c);Counts", 50, 0.20, 5.00) ;  
569   TH1F * h5  = new TH1F("hTOFESDskTIME", "p_{T}  distribution of tracks with kTOFout && kTIME; p_{T} (GeV/c);Counts", 50, 0.20, 5.00) ;  
570   TH1F * h6  = new TH1F("hTOFESDsMatched", "p_{T} distribution of tracks with kTOFout && TOFtime>0; p_{T} (GeV/c);Counts", 50, 0.20, 5.00) ;  
571   TH1F * h7  = new TH1F("hTOFESDsMatchingProb", "TPC-TOF track-matching probability;TOF matching probability (%)  ;Counts",101, -1.0, 100) ;  
572   TH1F * h8  = new TH1F("hTOFESDsDiffTime", "ESDs t_{TOF}-t_{exp,pi} spectrum in TOF (ps); t_{TOF}-t_{exp,pi} [ps];Counts", 200, -2440., 2440.) ; 
573   TH1F * h9  = new TH1F("hTOFHitsLength", "Matched ESDs tracks: Length Spectrum; Track length [cm];Counts", 800, 0., 800) ; 
574
575   h0->Sumw2() ;
576   h1->Sumw2() ;
577   h2->Sumw2() ;
578   h3->Sumw2() ;
579   h4->Sumw2() ;
580   h5->Sumw2() ;
581   h6->Sumw2() ;
582   h7->Sumw2() ;
583   h8->Sumw2() ;
584   h9->Sumw2() ;
585
586   Add2ESDsList(h0, 0, !expert,  image) ;
587   Add2ESDsList(h1, 1, !expert,  image) ;
588   Add2ESDsList(h2, 2,  expert,  !image) ;
589   Add2ESDsList(h3, 3, !expert,  !image) ;
590   Add2ESDsList(h4, 4,  expert,  image) ;
591   Add2ESDsList(h5, 5,  expert,  image) ;
592   Add2ESDsList(h6, 6,  expert,  image) ; 
593   Add2ESDsList(h7, 7,  expert,  image) ; 
594   Add2ESDsList(h8, 8,  expert,  !image) ; 
595   Add2ESDsList(h9, 9, !expert,  !image) ;
596   //
597   ClonePerTrigClass(AliQAv1::kESDS); // this should be the last line 
598 }
599
600
601 //____________________________________________________________________________
602 void AliTOFQADataMakerRec::MakeRaws(AliRawReader* rawReader)
603 {
604   //
605   // makes data from Raws
606   //
607   if (rawReader->GetType()==7) {
608    
609     Double_t tdc2ns=AliTOFGeometry::TdcBinWidth()*1E-3;//in ns
610     Double_t tot2ns=AliTOFGeometry::ToTBinWidth()*1E-3;
611     Int_t ntof[5]; /* 0=tot, 1=IA, 2=OA, 3=IC, 4=OC*/
612     for (Int_t j=0;j<5;j++){ ntof[j]=0;}
613     Int_t equipmentID[5]; //(ddl, trm, chain,tdc,channel)
614     Int_t volumeID[5];   //(sector,plate,strip,padX,padZ)
615     Int_t volumeID2[5];   //(sector,plate,strip,padZ,padX) to use AliTOFGeometry::GetIndex()
616     Int_t chIndex=-1;
617     Int_t indexCTTM[2]={-1,-1};     
618     Int_t indexGeo2CTTM[2]={-1,-1};
619     Float_t macropadPhiTimeUPC[fgkFiredMacropadLimit][2];
620     for (Int_t ii=0;ii<2;ii++){
621       for (Int_t jj=0;jj<fgkFiredMacropadLimit;jj++){   
622         macropadPhiTimeUPC[jj][ii]=-999.0; 
623       }
624     }
625
626     TClonesArray * clonesRawData;
627     fTOFRawStream.SetRawReader(rawReader);
628     Int_t BCID=rawReader->GetBCID();
629     
630     Int_t nFiredMacropad=0,
631       iFiredMacropad=-1;
632     nFiredMacropad=GetNumberOfFiredMacropad(rawReader);
633     
634     //uncomment if needed to apply DeltaBC correction
635     //fTOFRawStream.ApplyBCCorrections(kTRUE);
636     
637     if (fDecoderSummary){
638       fDecoderSummary->Reset();
639     }
640     for (Int_t iDDL = 0; iDDL < AliTOFGeometry::NDDL()*AliTOFGeometry::NSectors(); iDDL++){
641       rawReader->Reset();
642       fTOFRawStream.LoadRawDataBuffersV2(iDDL);
643       
644       //* get decoding error counters
645       fDecoderSummary = ( (AliTOFDecoderV2*) fTOFRawStream.GetDecoderV2() )->GetDecoderSummaryData();
646       if ( (fDecoderSummary) && (fDecoderSummary ->GetErrorDetected()) ) {
647         Int_t errorSlotID=(Int_t) fDecoderSummary->GetErrorSlotID();
648         FillRawsData(18,iDDL,errorSlotID);
649         if (fDecoderSummary -> GetRecoverError() )              
650           FillRawsData(18,iDDL,13);
651       }     
652       
653       clonesRawData = (TClonesArray*)fTOFRawStream.GetRawData();
654       for (Int_t iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) {
655         AliTOFrawData *tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData);
656         Float_t tofRawTime=tofRawDatum->GetTOF()*tdc2ns;
657         
658         if (tofRawDatum->GetTOF()){
659           equipmentID[0]=iDDL;
660           equipmentID[1]=tofRawDatum->GetTRM(); 
661           equipmentID[2]=tofRawDatum->GetTRMchain();
662           equipmentID[3]=tofRawDatum->GetTDC();
663           equipmentID[4]=tofRawDatum->GetTDCchannel();
664           
665           if (CheckEquipID(equipmentID)){
666             fTOFRawStream.EquipmentId2VolumeId(iDDL, 
667                                                tofRawDatum->GetTRM(), 
668                                                tofRawDatum->GetTRMchain(),
669                                                tofRawDatum->GetTDC(), 
670                                                tofRawDatum->GetTDCchannel(), 
671                                                volumeID);
672             //LTM data
673             if (FilterLTMData(equipmentID)) { //counts LTM hits
674               if (equipmentID[2]==1)  //crate left, A-side or C-side
675                 FillRawsData(15,equipmentID[0]);
676               else 
677                 FillRawsData(15,equipmentID[0]-1); 
678               
679               //retrieve CTTM index (Ltm, bit)
680               GetCTTMIndex(equipmentID, indexCTTM);
681               
682               //get BX index within TOF-matching window
683               Int_t indexBC=-1;
684               indexBC= TMath::Nint(tofRawTime/24.4);
685
686               Int_t indexCttmChannel=indexCTTM[0]*24+indexCTTM[1];
687               FillRawsData(28,indexCttmChannel,indexBC);
688               FillRawsData(29,indexCttmChannel,tofRawTime);
689               
690               //fired macropad map (from LTM hits) - only for low multi evts (UPC)
691               if ((nFiredMacropad<=fgCutNmaxFiredMacropad)){    
692                 iFiredMacropad++;
693                 AliInfo(Form("Event found with %i fired macropads in BCID = %i!",nFiredMacropad,BCID));
694                 FillRawsData(26,indexCTTM[0],indexCTTM[1]);
695                 Float_t halfSMphi=-999.0;
696                 if (indexCTTM[0]<36)
697                   halfSMphi=indexCTTM[0]*10.+5.;
698                 else  halfSMphi=(indexCTTM[0]-36)*10.+5.;
699                 macropadPhiTimeUPC[iFiredMacropad][0]=halfSMphi;
700                 macropadPhiTimeUPC[iFiredMacropad][1]=indexBC;
701               }
702             }
703             
704             //TRM data
705             if (CheckVolumeID(volumeID)){  
706               volumeID2[0]=volumeID[0];
707               volumeID2[1]=volumeID[1];
708               volumeID2[2]=volumeID[2];
709               volumeID2[3]=volumeID[4];
710               volumeID2[4]=volumeID[3];
711               chIndex=AliTOFGeometry::GetIndex(volumeID2);
712               
713               //fill hit map according to CTTM numbering
714               GetGeo2CTTMIndex(volumeID2, indexGeo2CTTM);
715               if ((nFiredMacropad<=fgCutNmaxFiredMacropad)){    
716                 FillRawsData(25,indexGeo2CTTM[0],indexGeo2CTTM[1]);
717               }
718               //hits selection
719               if (tofRawDatum->GetTOT()){           
720                 if (!(fCalibData->GetNoiseStatus(chIndex)==AliTOFChannelOnlineStatusArray::kTOFNoiseBad)
721                     && (fCalibData->GetHWStatus(chIndex) == AliTOFChannelOnlineStatusArray::kTOFHWOk)) {//noise and enabled filter
722                   ntof[0]++; //counter for tof hits
723                   
724                   //fill global spectra for DQM plots
725                   FillRawsData(5, tofRawTime) ;//in ns
726                   FillRawsData(10, tofRawDatum->GetTOT()*tot2ns) ;//in ns
727                   FillRawsData(23, BCID, tofRawTime) ;//in ns
728                   
729                   //fill side-related spectra for experts plots
730                   Int_t ddlACside=iDDL/36; // 0 or 1
731                   Int_t ddlPerSm=iDDL%4;
732                   
733                   if (volumeID2[0]>4 && volumeID2[0]<14){       //O side
734                     if (ddlPerSm<2){ //A side
735                       ntof[1]++;
736                       FillRawsData(6, tofRawTime) ;
737                       FillRawsData(11, tofRawDatum->GetTOT()*tot2ns) ;
738                     } else {  //C side
739                       ntof[3]++;
740                       FillRawsData(8, tofRawTime) ;
741                       FillRawsData(13, tofRawDatum->GetTOT()*tot2ns) ;
742                     }
743                   } else {                                    
744                     if (volumeID2[0]<5 || volumeID2[0]>13){   //I side
745                       if (ddlPerSm<2){ //A side
746                         ntof[2]++;
747                         FillRawsData(7, tofRawTime) ;
748                         FillRawsData(12, tofRawDatum->GetTOT()*tot2ns) ;
749                       } else {//C side
750                         ntof[4]++;
751                         FillRawsData(9, tofRawTime) ;
752                         FillRawsData(14, tofRawDatum->GetTOT()*tot2ns) ;
753                       }
754                     }   
755                   }
756                   
757                   //compute TRM offset
758                   Int_t trm= iDDL*10+(equipmentID[1]-3);
759                   FillRawsData(20+ddlACside,trm,tofRawTime);
760                   FillRawsData(22,GetStripIndex(volumeID),tofRawTime) ;
761                   Short_t fea = volumeID2[4]/12;
762                   Float_t hitmapx = volumeID2[0] + ((Double_t)(3 - fea) + 0.5) *0.25;
763                   FillRawsData(17,hitmapx,GetStripIndex(volumeID2));
764                   if (fCalib.IsChannelEnabled(chIndex,kTRUE,kTRUE))//checks also if efficient and if problematic
765                     FillRawsData(24,hitmapx,GetStripIndex(volumeID2));
766                 }//noise filter
767               }//end hit selection
768               else { //orphans
769                 if (!(fCalibData->GetNoiseStatus(chIndex) == AliTOFChannelOnlineStatusArray::kTOFNoiseBad)
770                     && (fCalibData->GetHWStatus(chIndex) == AliTOFChannelOnlineStatusArray::kTOFHWOk))
771                   FillRawsData(19, tofRawTime) ;//in ns
772               }//end orphans
773             }//end volumeID check
774           }//end equipID check
775         }//end tof check
776       }//loop on raw data
777       clonesRawData->Clear();
778     } // DDL Loop
779     
780     for (Int_t j=0;j<5;j++) FillRawsData(j,ntof[j]);
781     fTOFRawStream.Clear();
782   
783     if ((nFiredMacropad<=fgCutNmaxFiredMacropad)){
784       Float_t deltaPhiMacropad=-999.;
785       Float_t deltaTimeMacropad=-999.;
786       for (Int_t j=0;j<fgCutNmaxFiredMacropad+1; j++){
787         for (Int_t k=j+1;k<fgCutNmaxFiredMacropad+1; k++){
788           if ((macropadPhiTimeUPC[j][0]>0.0)&&(macropadPhiTimeUPC[k][0]>0.0)){
789             deltaPhiMacropad=TMath::Abs(macropadPhiTimeUPC[j][0]-macropadPhiTimeUPC[k][0]);
790             deltaTimeMacropad=TMath::Abs(macropadPhiTimeUPC[j][1]-macropadPhiTimeUPC[k][1]);
791             if (deltaPhiMacropad<=180.)
792               FillRawsData(27, deltaPhiMacropad,deltaTimeMacropad);
793             else
794               FillRawsData(27, TMath::Abs(360.0-deltaPhiMacropad),deltaTimeMacropad);
795           }
796         } 
797       }    
798     }//end cut on number of fired macropad
799   } else {
800     AliDebug(1,Form("Event of type %d found. Skipping non-physics event for QA.\n", rawReader->GetType())); 
801   }
802   
803   //fill reference map for DQM shifter only once in a detector cycle 
804   if (fIsSOC) {
805     Int_t geoId[5]={-1,-1,-1,-1,-1};// pgeoId=(sm, mod, strip, padZ, padX)
806     Int_t detId[5]={-1,-1,-1,-1,-1};//detID=(ddl,trm,tdc, chain,channel)
807     Int_t trmIndex=-1;
808     for (Int_t ch = 0; ch <  fCalibData->GetSize(); ch++) {
809       AliTOFGeometry::GetVolumeIndices(ch,geoId);
810       AliTOFRawStream::Geant2EquipmentId(geoId,detId); 
811       if ((detId[1]<0)||(detId[0]<0)) continue;
812       trmIndex=(detId[1]-3)+detId[0]*10;
813
814       if ( (!(fCalibData->GetNoiseStatus(ch)==AliTOFChannelOnlineStatusArray::kTOFNoiseBad))
815            && (fCalibData->GetHWStatus(ch) == AliTOFChannelOnlineStatusArray::kTOFHWOk) ){
816         //fill reference map with info from OCDB
817         Short_t fea = geoId[4]/12;
818         Float_t hitmapx = geoId[0] + ((Double_t)(3 - fea) + 0.5)*0.25;
819         FillRawsData(16,hitmapx, GetStripIndex(geoId));
820       }
821     }
822     fIsSOC=kFALSE;
823   }
824   
825   //enable options for DQM shifter
826   EnableDqmShifterOpt(kTRUE);
827   //
828   IncEvCountCycleRaws();
829   IncEvCountTotalRaws();
830   //
831 }
832
833 //____________________________________________________________________________
834 void AliTOFQADataMakerRec::MakeRecPoints(TTree * clustersTree)
835 {
836     //
837   // Make data from Clusters
838   //
839  
840   Double_t tdc2ns=AliTOFGeometry::TdcBinWidth()*1E-3;
841   Double_t tot2ns=AliTOFGeometry::ToTBinWidth()*1E-3;
842   
843   Int_t volumeID2[5];//(sm, plate,strip, padZ,padX)
844   //Int_t volumeID[5];//(sm, plate,strip, padX,padZ) 
845     
846   TBranch *branch=clustersTree->GetBranch("TOF");
847   if (!branch) { 
848     AliError("can't get the branch with the TOF clusters !");
849     return;
850   }
851
852   static TClonesArray dummy("AliTOFcluster",10000);
853   dummy.Clear();
854   TClonesArray *clusters=&dummy;
855   branch->SetAddress(&clusters);
856   
857   // Import the tree
858   clustersTree->GetEvent(0);  
859  
860   FillRecPointsData(0,(Int_t)clusters->GetEntriesFast()) ; 
861   
862   TIter next(clusters) ; 
863   AliTOFcluster * c ; 
864   while ( (c = dynamic_cast<AliTOFcluster *>(next())) ) {
865    
866       // volumeID2[0] = c->GetDetInd(0);
867       // volumeID2[1] = c->GetDetInd(1);
868       // volumeID2[2] = c->GetDetInd(2);
869       // volumeID2[3] = c->GetDetInd(4); //padX
870       // volumeID2[4] = c->GetDetInd(3); //padZ 
871       
872       for (Int_t i=0;i<5;i++){
873         volumeID2[i]=c->GetDetInd(i); //X and Z indeces inverted in RecPoints
874       }
875       //Int_t chIndex=AliTOFGeometry::GetIndex(volumeID2);
876       Int_t iDDL=AliTOFRawStream::Geant2DDL(volumeID2);
877       Int_t iTRM=AliTOFRawStream::Geant2TRM(volumeID2);
878       Short_t fea = volumeID2[4]/12;
879       Float_t hitmapx = volumeID2[0] + ((Double_t)(3 - fea) + 0.5) *0.25;
880       Int_t ddlACside=iDDL/36; // 0 or 1
881       Int_t ddlPerSm=iDDL%4;
882       
883       if ((c->GetTDCRAW()) && (c->GetTDC()) && (c->GetToT())){
884         if (volumeID2[0]>4 && volumeID2[0]<14){       //I side
885           if (ddlPerSm<2){ //A side
886             FillRecPointsData(1, c->GetTDC()*tdc2ns) ;//in ns
887             FillRecPointsData(5, c->GetTDCRAW()*tdc2ns) ;//in ns
888             FillRecPointsData(9, c->GetToT()*tot2ns) ;//in ns
889           } else {//C side
890             FillRecPointsData(3, c->GetTDC()*tdc2ns) ;//in ns
891             FillRecPointsData(7, c->GetTDCRAW()*tdc2ns) ;//in ns
892             FillRecPointsData(11, c->GetToT()*tot2ns) ;//in ns
893           }
894         } else {
895           if (volumeID2[0]<5 || volumeID2[0]>13){       //O side
896             if (ddlPerSm<2){ //A side
897               FillRecPointsData(2, c->GetTDC()*tdc2ns) ;//in ns
898               FillRecPointsData(6, c->GetTDCRAW()*tdc2ns) ;//in ns
899               FillRecPointsData(10, c->GetToT()*tot2ns) ;//in ns
900             } else { //C side
901               FillRecPointsData(4, c->GetTDC()*tdc2ns) ;//in ns
902               FillRecPointsData(8, c->GetTDCRAW()*tdc2ns) ;//in ns
903               FillRecPointsData(12, c->GetToT()*tot2ns) ;//in ns
904             }
905           }
906         }
907         FillRecPointsData(13,hitmapx,GetStripIndex(volumeID2));
908         FillRecPointsData(14,GetStripIndex(volumeID2), c->GetTDC()*tdc2ns) ;
909         Int_t trm= iDDL*10+(iTRM-3);
910         if (ddlACside==0) { //A side
911           FillRecPointsData(15,trm,c->GetTDC()*tdc2ns);
912         } else {//C side
913           FillRecPointsData(16,trm,c->GetTDC()*tdc2ns);
914         }
915       }//hit selection
916   }//end while   
917   EnableDqmShifterOpt(kFALSE);
918   //
919   IncEvCountCycleRecPoints();
920   IncEvCountTotalRecPoints();
921   //
922 }
923
924 //____________________________________________________________________________
925 void AliTOFQADataMakerRec::MakeESDs(AliESDEvent * esd)
926 {
927   //
928   // make QA data from ESDs
929   //  
930   const Double_t speedOfLight = TMath::C()*1E2*1E-12; // cm/ps
931   const Double_t pionMass = 0.13957018; //GeV/c^2
932
933   Int_t ntrk = esd->GetNumberOfTracks() ; 
934   Int_t ntpc=0;
935   Int_t ntofout=0;
936   
937     while (ntrk--) {
938       AliESDtrack *track=esd->GetTrack(ntrk);
939       Double_t tofTime=track->GetTOFsignal();//in ps
940       Double_t tofTimeRaw=track->GetTOFsignalRaw();//in ps
941       Double_t tofToT=track->GetTOFsignalToT(); //in ps
942       
943       UInt_t status=track->GetStatus();
944       if (track->IsOn(AliESDtrack::kTPCrefit)) {
945         ntpc++;
946         Double_t y=track->Eta();
947         if (TMath::Abs(y)<0.9) { //select TOF acceptance
948           if ((status&AliESDtrack::kTOFout)!=0)  { //define matching
949             ntofout++;
950             FillESDsData(1,tofTime*1E-3);
951             FillESDsData(2,tofTimeRaw*1E-3); 
952             FillESDsData(3,tofToT*1E-3);
953             FillESDsData(4,track->Pt());
954             
955             Double_t length =track->GetIntegratedLength();
956             Double_t mom2=(track->Pt()*track->Pt())+(track->Pz()*track->Pz());
957             Double_t piTexp = TMath::Sqrt(1+(pionMass*pionMass/mom2))*length/speedOfLight; //in ps
958             FillESDsData(8,tofTime-piTexp);
959             FillESDsData(9,length);
960             
961             if ((status&AliESDtrack::kTIME)!=0) 
962               FillESDsData(5,track->Pt());
963             
964             if (tofTime>0)
965               FillESDsData(6,track->Pt());
966           } //end check on matched tracks
967         } 
968       }//end check on TPCrefit
969     }
970     
971     FillESDsData(0,ntofout) ;
972     if(ntpc>0){
973       Float_t ratio = (Float_t)ntofout/(Float_t)ntpc*100.; //matching probability
974       FillESDsData(7,ratio) ;
975     }
976     
977     if(ntofout>0) {
978         Float_t ratio = (Float_t)ntofout/(Float_t)ntpc*100; //matched over propagated to TOF outer radius
979         FillESDsData(8,ratio) ;
980     }
981     EnableDqmShifterOpt(kFALSE);
982     //
983     IncEvCountCycleESDs();
984     IncEvCountTotalESDs();
985     //
986 }
987
988 //____________________________________________________________________________ 
989 void AliTOFQADataMakerRec::StartOfDetectorCycle()
990 {
991   //
992   //Detector specific actions at start of cycle
993   fCalibData = GetCalibData();
994   fIsSOC=kTRUE;
995   return;
996 }  
997
998 //____________________________________________________________________________ 
999 void AliTOFQADataMakerRec::EndOfDetectorCycle(AliQAv1::TASKINDEX_t task, TObjArray ** list)
1000 {
1001   //Detector specific actions at end of cycle
1002   // do the QA checking
1003   ResetEventTrigClasses();
1004   //
1005   for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
1006     if ( !AliQAv1::Instance()->IsEventSpecieSet(specie) ) continue ;     
1007     SetEventSpecie(AliRecoParam::ConvertIndex(specie));  
1008
1009     for (int itc=-1;itc<GetNTrigClasses();itc++) { // RS: loop over eventual clones per trigger class
1010
1011       if (fEnableDqmShifterOpt) {
1012         // RS: fetch the histograms for given trigger class
1013         TObjArray& arrRW = *GetRawsDataOfTrigClass(itc);
1014         
1015         // Help make the raw qa histogram easier to interpret for the DQM shifter
1016         if (!arrRW[ 0] || !arrRW[ 5] || !arrRW[10] || !arrRW[15] || !arrRW[16] || !arrRW[17]) continue;
1017         
1018         printf("=========>Processed %i physics raw of specie %s with TrigGlass %d\n",
1019                GetEvCountCycleRaws(itc),AliRecoParam::GetEventSpecieName(specie), itc);
1020         
1021         //Double_t monitorPeriodLength=fProcessedRawEventN*600*1E-9;//in s
1022       
1023         if (fCalibData){
1024           //set minima and maxima to allow log scale
1025           Double_t yTimeMax = ((TH1*)arrRW[5])->GetMaximum()*1.05;
1026           Double_t yTotMax = ((TH1*)arrRW[10])->GetMaximum()*1.05;
1027           fLineExpTimeMin->SetY2(yTimeMax);
1028           fLineExpTimeMax->SetY2(yTimeMax);
1029           fLineExpTotMin->SetY2(yTotMax);
1030           fLineExpTotMax->SetY2(yTotMax);
1031           //
1032           for (Int_t j=0;j<18;j++){
1033             if ((j==0)||(j==5)||(j==10)||(j==15)||(j==16)||(j==17)) {
1034               TH1* htmp = (TH1*)arrRW[j];
1035               htmp->GetXaxis()->SetLabelOffset(0.005);
1036               htmp->GetXaxis()->SetLabelSize(0.05);
1037               htmp->GetXaxis()->SetTitleOffset(0.8);
1038               htmp->GetXaxis()->SetTitleSize(0.05);
1039               htmp->GetYaxis()->SetLabelOffset(0.005);
1040               htmp->GetYaxis()->SetLabelSize(0.06);
1041               htmp->GetYaxis()->SetTitleOffset(0.8);
1042               htmp->GetYaxis()->SetTitleSize(0.06);       
1043             }
1044           }
1045           //make up for all histos 
1046           for(Int_t j=0;j<5;j++) {
1047             TH1* htmp = (TH1*)arrRW[j];  
1048             if (!htmp) continue;
1049             htmp->SetMarkerColor(kBlue);
1050             htmp->SetMarkerStyle(8);
1051             htmp->SetMarkerSize(0.7);
1052           }
1053           for(Int_t j=5;j<15;j++) {
1054             TH1* htmp = (TH1*)arrRW[j];
1055             if (!htmp) continue;
1056             htmp->SetLineColor(kBlue);
1057             htmp->SetLineWidth(1);
1058             htmp->SetMarkerColor(kBlue);
1059           }
1060           
1061           TH1* htmp =  (TH1*)arrRW[15];  
1062           htmp->SetLineColor(kBlue);
1063           htmp->SetLineWidth(1);
1064           htmp->SetMarkerStyle(8);
1065           htmp->SetMarkerSize(0.7);
1066           htmp->SetMarkerColor(kBlue);//Option("bar");
1067           //
1068           TString title25 = Form("Map of hit pads according to CTTM numbering (Max Fired Macropad = %i)",fgCutNmaxFiredMacropad);
1069           TString title26 = Form("Map of hit macropads according to CTTM numbering (Max Fired Macropad = %i)",fgCutNmaxFiredMacropad);
1070           TString title27 = Form("#Deltat vs #Delta#Phi of hit macropads (Max Fired Macropad = %i)",fgCutNmaxFiredMacropad);
1071           
1072           if ( (htmp=(TH1*)arrRW[16]) ) htmp->SetOption("colz");
1073           if ( (htmp=(TH1*)arrRW[17]) ) htmp->SetOption("colz");
1074           if ( (htmp=(TH1*)arrRW[18]) ) htmp->SetOption("colz"); 
1075           if ( (htmp=(TH1*)arrRW[22]) ) htmp->SetOption("colz"); 
1076           if ( (htmp=(TH1*)arrRW[23]) ) htmp->SetOption("colz"); 
1077           if ( (htmp=(TH1*)arrRW[24]) ) htmp->SetOption("colz"); 
1078           if ( (htmp=(TH1*)arrRW[28]) ) htmp->SetOption("colz"); 
1079           if ( (htmp=(TH1*)arrRW[29]) ) htmp->SetOption("colz"); 
1080
1081           if ( (htmp=(TH1*)arrRW[25]) ) {
1082             htmp->SetOption("colz"); 
1083             htmp->SetTitle(title25.Data());
1084           }
1085           if ( (htmp=(TH1*)arrRW[26]) ) {
1086             htmp->SetOption("colz"); 
1087             htmp->SetTitle(title26.Data());
1088           }
1089           if ( (htmp=(TH1*)arrRW[27]) ){
1090             htmp->SetOption("colz"); 
1091             htmp->SetTitle(title27.Data());
1092           }
1093         }
1094       }//END ENABLE DQM SHIFTER OPT
1095     } // RS: loop over trigger classes
1096   } //end for
1097   //
1098   AliQAChecker::Instance()->Run(AliQAv1::kTOF, task, list) ;  
1099   //
1100 }
1101 //____________________________________________________________________________
1102 void AliTOFQADataMakerRec::GetMapIndeces(const Int_t* const in , Int_t* out)
1103 {
1104   //
1105   //return appropriate indeces for the theta-phi map
1106   //
1107
1108   Int_t npadX = AliTOFGeometry::NpadX();
1109   Int_t npadZ = AliTOFGeometry::NpadZ();
1110   Int_t nStripA = AliTOFGeometry::NStripA();
1111   Int_t nStripB = AliTOFGeometry::NStripB();
1112   Int_t nStripC = AliTOFGeometry::NStripC();
1113
1114   Int_t isector = in[0];
1115   Int_t iplate = in[1];
1116   Int_t istrip = in[2];
1117   Int_t ipadX = in[3]; 
1118   Int_t ipadZ = in[4]; 
1119   
1120   Int_t stripOffset = 0;
1121   switch (iplate) {
1122   case 0:
1123     stripOffset = 0;
1124       break;
1125   case 1:
1126     stripOffset = nStripC;
1127     break;
1128   case 2:
1129     stripOffset = nStripC+nStripB;
1130     break;
1131   case 3:
1132     stripOffset = nStripC+nStripB+nStripA;
1133     break;
1134   case 4:
1135     stripOffset = nStripC+nStripB+nStripA+nStripB;
1136     break;
1137   default:
1138     AliDebug(1,Form("Wrong plate number in TOF (%d) !",iplate));
1139     break;
1140   };
1141   Int_t zindex=npadZ*(istrip+stripOffset)+(ipadZ+1);
1142   Int_t phiindex=npadX*isector+ipadX+1;
1143   out[0]=zindex;  
1144   out[1]=phiindex;  
1145   
1146 }
1147
1148 //---------------------------------------------------------------
1149 Int_t AliTOFQADataMakerRec::GetStripIndex(const Int_t * const in)
1150 {
1151     /* return tof strip index between 0 and 91 */
1152
1153   Int_t nStripA = AliTOFGeometry::NStripA();
1154   Int_t nStripB = AliTOFGeometry::NStripB();
1155   Int_t nStripC = AliTOFGeometry::NStripC();
1156
1157   // Int_t isector = in[0];
1158   Int_t iplate = in[1];
1159   Int_t istrip = in[2];
1160   //Int_t ipadX = in[3]; 
1161   //Int_t ipadZ = in[4]; 
1162   
1163   Int_t stripOffset = 0;
1164   switch (iplate) {
1165   case 0:
1166     stripOffset = 0;
1167       break;
1168   case 1:
1169     stripOffset = nStripC;
1170     break;
1171   case 2:
1172     stripOffset = nStripC+nStripB;
1173     break;
1174   case 3:
1175     stripOffset = nStripC+nStripB+nStripA;
1176     break;
1177   case 4:
1178     stripOffset = nStripC+nStripB+nStripA+nStripB;
1179     break;
1180   default:
1181       AliDebug(1,Form("Wrong plate number in TOF (%d) !",iplate));
1182       stripOffset=-1;
1183       break;
1184   };
1185   
1186   if (stripOffset<0 || stripOffset>92) return -1;
1187   else 
1188       return (stripOffset+istrip);
1189   
1190 }
1191 //---------------------------------------------------------------
1192 Bool_t  AliTOFQADataMakerRec::CheckVolumeID(const Int_t * const volumeID)
1193 {
1194     //
1195     //Checks volume ID validity
1196     //   
1197     for (Int_t j=0;j<5;j++){
1198         if (volumeID[j]<0) {
1199             AliDebug(1,Form("Invalid detector volume index for volumeID[%i]",j));
1200             return kFALSE;
1201         }
1202     }
1203     return kTRUE; 
1204 }
1205
1206 //---------------------------------------------------------------
1207 Bool_t  AliTOFQADataMakerRec::CheckEquipID(const Int_t * const equipmentID)
1208 {
1209     //
1210     //Checks equipment ID validity    
1211    for (Int_t j=0;j<5;j++){
1212         if (equipmentID[j]<0) {
1213           AliDebug(1,Form("Invalid equipment volume index for equipmentID[%i]",j));
1214           return kFALSE;
1215         }
1216    }
1217    return kTRUE;
1218 }
1219 //---------------------------------------------------------------
1220 Bool_t  AliTOFQADataMakerRec::FilterLTMData(const Int_t * const equipmentID) const
1221 {
1222   /*It returns kTRUE if data come from LTM.
1223     It thus filters trigger-related signals  */
1224
1225   Int_t ddl, trm, tdc;
1226   //if (!CheckEquipID(equipmentID)) return kFALSE;
1227   ddl = equipmentID[0];
1228   trm = equipmentID[1];
1229   tdc = equipmentID[3];
1230   
1231   if ((ddl%2==1) && (trm==3) && (tdc>11 && tdc<15))
1232     return kTRUE;
1233   else 
1234     return kFALSE;
1235  
1236 }
1237 //---------------------------------------------------------------
1238 Bool_t  AliTOFQADataMakerRec::FilterSpare(const Int_t * const equipmentID) const
1239 {
1240   /*It returns kTRUE if data come from spare 
1241     equipment ID. 
1242     So far only check on TRM 3 crate left is implemented */
1243
1244   Int_t ddl, trm, tdc;
1245   //if (!CheckEquipID(equipmentID)) return kFALSE;
1246   ddl = equipmentID[0];
1247   trm = equipmentID[1];
1248   tdc = equipmentID[3];
1249   
1250   if ((ddl%2==1) && (trm==3) && (tdc>2 && tdc<12))
1251     return kTRUE;
1252   else 
1253     return kFALSE;
1254 }
1255
1256 //-----------------------------------------------------------------------------
1257 void AliTOFQADataMakerRec::GetGeo2LTMIndex(const Int_t * const detind, Int_t *indexLTM) {
1258   //
1259   // getting LTMmatrix indexes for current digit
1260   //
1261   Int_t stripId=GetStripIndex(detind);
1262
1263   if (detind[1]==0 || detind[1]==1 || (detind[1]==2 && detind[2]<=7)) { //A side
1264     if (detind[4]<24){ //R
1265       indexLTM[0] = detind[0]*2;
1266     } else { //L
1267       indexLTM[0] = detind[0]*2+1;
1268     }  
1269     indexLTM[1]=stripId;
1270
1271   } else { //C side
1272     if (detind[4]<24){
1273       indexLTM[0] = detind[0]*2+36;
1274     } else {
1275       indexLTM[0] = (detind[0]*2+1)+36;
1276     }
1277     indexLTM[1]=90-stripId; 
1278   }
1279   
1280   // if (indexLTM[0]<36) { //A side
1281   //   if (detind[1] ==0){
1282   //     indexLTM[1] = detind[2];
1283   //   }
1284   //   else if (detind[1] ==1){
1285   //     indexLTM[1] = detind[2]+nStripB;
1286   //   }
1287   //   else if (detind[1] ==2){
1288   //     indexLTM[1] = detind[2]+19*2;
1289   //   }
1290   //   else{
1291   //     AliError("Smth Wrong!!!");
1292   //   }
1293   // }
1294   // else { //C side
1295   //   if (detind[1]==2){
1296   //     if (detind[4]<24)
1297   //    indexLTM[1] = (nStripAL-detind[2])+nStripC+nStripB;
1298   //     else 
1299   //    indexLTM[1] = (nStripAR-detind[2])+nStripC+nStripB;
1300   //   }
1301   //   else if (detind[1] ==3){
1302   //     indexLTM[1] = (nStripB-detind[2])+nStripC;
1303   //   }
1304   //   else if (detind[1] ==4){
1305   //     indexLTM[1] = nStripC-detind[2];
1306   //   }
1307   //   else{
1308   //     AliError("Smth Wrong!!!");
1309   //   }
1310   // }  
1311 }
1312
1313 //-----------------------------------------------------------------------------
1314 void AliTOFQADataMakerRec::GetGeo2CTTMIndex(Int_t *detind, Int_t *indexCTTM) {
1315   //
1316   // Returns CTTM index corresponding to the detector element detind
1317   //
1318   GetGeo2LTMIndex(detind,indexCTTM);
1319   indexCTTM[1]/=2;
1320   return;
1321 }
1322
1323 //-------------------------------------------------------------------------
1324 Int_t AliTOFQADataMakerRec::GetNumberOfFiredMacropad(AliRawReader * rawReader){
1325   
1326   Int_t nFired=0;
1327   TClonesArray * clonesRawData;  
1328   if (!rawReader) return 0;  
1329   for (Int_t iDDL = 0; iDDL < AliTOFGeometry::NDDL()*AliTOFGeometry::NSectors(); iDDL++){
1330     rawReader->Reset();
1331     fTOFRawStream.LoadRawDataBuffersV2(iDDL); 
1332     clonesRawData = (TClonesArray*)fTOFRawStream.GetRawData();
1333     for (Int_t iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) {
1334       AliTOFrawData *tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData);    
1335       if (tofRawDatum->GetTOF()){       
1336         if ( (tofRawDatum->GetTRM()==3)&&
1337              (tofRawDatum->GetTDC()>11)&&
1338              (tofRawDatum->GetTDC()<15)) {        
1339           nFired+=1;  
1340         }
1341       }
1342     }    
1343   }//loop over DDLs
1344   return nFired; 
1345 }
1346
1347 //----------------------------------------------------------------
1348 void AliTOFQADataMakerRec::GetCTTMIndex(Int_t *equipid, Int_t *indexCTTM) {
1349   //
1350   // Returns CTTM index corresponding to the equipment id equipid, only for LTM hits
1351   // equipid = (crate, trm, chain, tdc, channel)
1352
1353   if ( (equipid[1]!=3)||(equipid[3]<12) ){
1354     indexCTTM[0]=-1;
1355     indexCTTM[1]=-1;
1356     return;
1357   }  
1358   Int_t modStrip2LTM[3][8]={ { 0, 1, 2, 3, 4, 5, 6, 7},
1359                              { 8, 9, 10, 11, 12, 13, 14, 15},
1360                              {16, 17, 18, 19, 20, 21, 22, 23}
1361                             }; 
1362
1363   Int_t DDL2LTMmatrix[72]={0,1,37,36,2,3,39,38,4,5,41,40,6,7,43,42,8,9,45,44,10,11,47,46,12,13,49,48,14,15,51,50,16,17,53,52,18,19,
1364                            55,54,20,21,57,56,22,23,59,58,24,25,61,60,26,27,63,62,28,29,65,64,30,31,67,66,32,33,69,68,34,35,71,70};
1365
1366   Int_t itdc=equipid[3]%12;
1367   Int_t crate=-1;
1368   if (equipid[2]==0)
1369    crate=equipid[0]-1;
1370   else crate=equipid[0];
1371   
1372   indexCTTM[0]=DDL2LTMmatrix[crate];
1373   indexCTTM[1]=modStrip2LTM[itdc][equipid[4]];      
1374   return;
1375 }
1376
1377 //_____________________________________________________________________________
1378 void AliTOFQADataMakerRec::ReadHistogramRangeFromFile(const Char_t * filename)
1379 {
1380   //
1381   // read histogram ranges from configuration file
1382   //
1383   if (!filename) {
1384     AliInfo("Config file with histograms ranges not found or invalid -> use default values.");
1385     SetDefaultHistogramRange();
1386     SetDefaultCutNmaxFiredMacropad();
1387     return;
1388   }
1389   
1390   std::fstream configFile;
1391   configFile.open(filename, std::fstream::in);
1392   if (!configFile.is_open()){
1393     AliInfo("Cannot open config file with histograms ranges -> use default values.");
1394     SetDefaultHistogramRange();
1395     return;
1396   }
1397   
1398   //check file size
1399   Int_t begin = configFile.tellg();
1400   configFile.seekg(0, std::fstream::end); /* end */
1401   Int_t end = configFile.tellg();
1402   Int_t size = end - begin;
1403   configFile.seekg(0, std::fstream::beg); /* rewind file */
1404   if (size <= 0){
1405     AliInfo(Form("Unexpected EOF of config file with histograms ranges. File size: %d -> use default values", size));
1406     SetDefaultHistogramRange();
1407     return;
1408   }
1409   
1410   Int_t minMulti=9999, maxMulti=-9999;
1411   Int_t nbinsMulti=0,nbinsTime=0;
1412   Float_t minTime=9999.0, maxTime=-9999.0;
1413   Int_t cutFiredMacropad=0;
1414   TString endoflist;
1415   while (!configFile.eof()) {
1416     configFile >> cutFiredMacropad >> minMulti >> maxMulti >> minTime >> maxTime;
1417     configFile >> endoflist;
1418     if (endoflist.Contains("end")) break;
1419   }
1420
1421   //set multiplicity histo ranges
1422   if (minMulti>maxMulti){
1423     AliInfo("Invalid range for multiplicity histogram set. Changing to default values.");
1424     SetDefaultMultiHistogramRange();
1425   } else {
1426     nbinsMulti = maxMulti-minMulti;
1427     SetNbinsMultiplicityHisto(nbinsMulti);
1428     SetMultiplicityHistoRange(minMulti,maxMulti);
1429     //AliInfo(Form("Setting multiplicity histogram ranges to: multMin = %i - multMax = %i - nMultBins = %i", fgRangeMinMultiplicity, fgRangeMaxMultiplicity, fgNbinsMultiplicity));
1430   }
1431
1432   //set time histo ranges
1433   if (minTime>maxTime){
1434     AliInfo("Invalid range for time histogram set. Changing to default values.");
1435     SetDefaultTimeHistogramRange();
1436   } else {
1437     nbinsTime = TMath::Nint((maxTime - minTime)/fgkNbinsWidthTime);//ns
1438     maxTime=minTime+nbinsTime*fgkNbinsWidthTime;//ns
1439     SetNbinsTimeHisto(nbinsTime);
1440     SetTimeHistoRange(minTime,maxTime);
1441     //AliInfo(Form("Setting time histogram ranges to: timeMin = %5.2f ns - timeMax = %5.2f ns - nTimeBins = %i", fgRangeMinTime, fgRangeMaxTime,fgNbinsTime));
1442   } 
1443  
1444   if ((cutFiredMacropad>0)&&(cutFiredMacropad<fgkFiredMacropadLimit)){
1445     AliInfo("Invalid value for cut on fired macropad. Changing to default values.");
1446     SetDefaultCutNmaxFiredMacropad();
1447   } else {
1448     SetCutNmaxFiredMacropad(cutFiredMacropad);
1449     //AliInfo(Form("Setting cut on fired macropad to:  = %i",cutFiredMacropad));
1450   } 
1451   AliInfo(Form("Setting: multMin = %i - multMax = %i - nMultBins = %i, timeMin = %5.2f ns - timeMax = %5.2f ns - nTimeBins = %i, cutMaxFiredMacropad = %i", 
1452                fgRangeMinMultiplicity, fgRangeMaxMultiplicity, fgNbinsMultiplicity, fgRangeMinTime, fgRangeMaxTime,fgNbinsTime, cutFiredMacropad));
1453   configFile.close();
1454   return;
1455 }
1456
1457 //_____________________________________________________________________________
1458 void AliTOFQADataMakerRec::SetDefaultHistogramRange()
1459 {
1460   //
1461   // set default histogram ranges (tuned on 2011 pp collisions)
1462   // 
1463   AliInfo("Setting all histogram ranges to default values.");
1464   SetDefaultMultiHistogramRange();
1465   SetDefaultTimeHistogramRange();
1466   SetDefaultCutNmaxFiredMacropad();
1467   return;
1468 }
1469
1470 //_____________________________________________________________________________
1471 void AliTOFQADataMakerRec::SetDefaultMultiHistogramRange()
1472 {
1473   //
1474   // set default histogram ranges (tuned on 2011 pp collisions)
1475   // 
1476   SetMultiplicityHistoRange (0, 200);
1477   SetNbinsMultiplicityHisto(200);
1478   AliInfo("Setting Multiplicity histogram ranges to default values.");
1479   AliInfo(Form("multMin = %i - multMax = %i - nMultBins = %i",
1480                fgRangeMinMultiplicity, fgRangeMaxMultiplicity, fgNbinsMultiplicity));
1481   return;
1482 }
1483
1484 //_____________________________________________________________________________
1485 void AliTOFQADataMakerRec::SetDefaultTimeHistogramRange()
1486 {
1487   //
1488   // set default histogram ranges (tuned on 2011 pp collisions)
1489   // 
1490   SetNbinsTimeHisto(250);
1491   SetTimeHistoRange (0.0,610.);   
1492   
1493   AliInfo("Setting Time histogram ranges to default values:");
1494   AliInfo(Form("timeMin = %5.2f ns - timeMax = %5.2f ns - nTimeBins = %i",
1495                fgRangeMinTime, fgRangeMaxTime,fgNbinsTime));
1496   return;
1497 }
1498
1499 //------------------------------------------------------------------
1500 void AliTOFQADataMakerRec::SetDefaultCutNmaxFiredMacropad()
1501 {
1502   //
1503   // set default cut on fired macropad 
1504   // 
1505   SetCutNmaxFiredMacropad(50); 
1506   AliInfo(Form("Setting cut on fired macropad to default values: NfiredMacropad = %i", fgCutNmaxFiredMacropad));
1507   return;
1508 }