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