]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TOF/AliTOFQADataMakerRec.cxx
Removing badly placed code (copy/paste error)
[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 14/06/2010
26   - Updated plots
27   - use LoadRawDataBuffersV2()
28
29   Modified by fbellini on 10/05/2010
30   - Fixed EndOfDetectorCycle() memory corruption bug
31
32   Modified by fbellini on 22/04/2010
33    - Added filter for physics events
34
35    Modified by fbellini on 16/04/2010
36    - Added EnableDqmShifterOpt() 
37    - Modified EndOfDetectorCycle() with options for DQM         
38    - Updated ESDs QA
39
40    Modified by fbellini on 30/03/2010
41    - Changed raws time histos range to 610ns
42    - Added FilterLTMData() and FilterSpare() methods
43    - Added check on enabled channels for raw data               
44    - Updated RecPoints QA
45
46    Modified by fbellini on 02/03/2010
47    - Fixed raw data decoding methods (use AliTOFRawStream::LoadRawDataBuffer())
48    - Added filter for noisy channels and read map from OCDB
49    - Added GetCalibData() method
50    - Added CheckVolumeID() and CheckEquipID() methods  
51    - Updated Raw QA
52 */
53
54 #include <TClonesArray.h>
55 #include <TH1F.h> 
56 #include <TH2F.h> 
57 #include <TLine.h>
58
59 #include "AliCDBManager.h"
60 #include "AliCDBEntry.h"
61 #include "AliESDEvent.h"
62 #include "AliESDtrack.h"
63 #include "AliQAChecker.h"
64 #include "AliRawReader.h"
65 #include "AliTOFRawStream.h"
66 #include "AliTOFcluster.h"
67 #include "AliTOFQADataMakerRec.h"
68 #include "AliTOFrawData.h"
69 #include "AliTOFGeometry.h"
70 #include "AliTOFChannelOnlineStatusArray.h"
71
72
73 ClassImp(AliTOFQADataMakerRec)
74            
75 //____________________________________________________________________________ 
76   AliTOFQADataMakerRec::AliTOFQADataMakerRec() : 
77   AliQADataMakerRec(AliQAv1::GetDetName(AliQAv1::kTOF), "TOF Quality Assurance Data Maker"),
78   fCalibData(0x0),
79   fEnableNoiseFiltering(kFALSE),
80     fEnableDqmShifterOpt(kFALSE),
81     fProcessedRawEventN(0)
82 {
83   //
84   // ctor
85   //
86    
87 }
88
89 //____________________________________________________________________________ 
90 AliTOFQADataMakerRec::AliTOFQADataMakerRec(const AliTOFQADataMakerRec& qadm) :
91   AliQADataMakerRec(),
92   fCalibData(qadm.fCalibData),
93   fEnableNoiseFiltering(qadm.fEnableNoiseFiltering),
94   fEnableDqmShifterOpt(qadm.fEnableDqmShifterOpt),
95   fProcessedRawEventN(qadm.fProcessedRawEventN)
96 {
97   //
98   //copy ctor 
99   //
100   SetName((const char*)qadm.GetName()) ; 
101   SetTitle((const char*)qadm.GetTitle()); 
102   
103  
104 }
105
106 //__________________________________________________________________
107 AliTOFQADataMakerRec& AliTOFQADataMakerRec::operator = (const AliTOFQADataMakerRec& qadm )
108 {
109   //
110   // assignment operator.
111   //
112   this->~AliTOFQADataMakerRec();
113   new(this) AliTOFQADataMakerRec(qadm);
114   return *this;
115 }
116  
117 //----------------------------------------------------------------------------
118 AliTOFChannelOnlineStatusArray* AliTOFQADataMakerRec::GetCalibData() const
119 {
120   //
121   // Retrive TOF calib objects from OCDB
122   //
123     AliCDBManager *man = AliCDBManager::Instance();
124
125     AliCDBEntry *cdbe=0;
126
127     cdbe = man->Get("TOF/Calib/Status",fRun);
128     if(!cdbe){
129         AliWarning("Load of calibration data from default storage failed!");
130         AliWarning("Calibration data will be loaded from local storage ($ALICE_ROOT)");
131         man->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
132         cdbe = man->Get("TOF/Calib/Status",fRun);
133     }
134     // Retrieval of data in directory TOF/Calib/Data:
135     
136     AliTOFChannelOnlineStatusArray * array = 0;
137     if (cdbe) array = (AliTOFChannelOnlineStatusArray *)cdbe->GetObject();
138     if (!array)  AliFatal("No calibration data from calibration database !");
139     
140     return array;
141     
142 }
143
144
145
146 //____________________________________________________________________________ 
147 void AliTOFQADataMakerRec::InitRaws()
148 {
149   //
150   // create Raws histograms in Raws subdir
151   //
152   const Bool_t expert   = kTRUE ; 
153   const Bool_t saveCorr = kTRUE ; 
154   const Bool_t image    = kTRUE ; 
155
156   TH1I * h0 =  new TH1I("hTOFRaws",      "TOF raw hit multiplicity; TOF raw hits number;Counts ",200, 0, 200) ;
157
158   TH1I * h1 =  new TH1I("hTOFRawsIA",    "TOF raw hit multiplicity - I/A side; TOF raw hits number ;Counts ",200, 0, 200) ;
159   TH1I * h2 =  new TH1I("hTOFRawsOA",    "TOF raw hit multiplicity - O/A side; TOF raw hits number ;Counts ",200, 0, 200) ;
160   TH1I * h3 =  new TH1I("hTOFRawsIC",    "TOF raw hit multiplicity - I/C side; TOF raw hits number ;Counts ",200, 0, 200) ;
161   TH1I * h4 =  new TH1I("hTOFRawsOC",    "TOF raw hit multiplicity - O/C side; TOF raw hits number ;Counts ",200, 0, 200) ;
162
163   TH1F * h5  = new TH1F("hTOFRawsTime", "TOF Raws - Hit time (ns);Measured Hit time [ns];Counts", 25000,0. ,610.) ; 
164
165   TH1F * h6  = new TH1F("hTOFRawsTimeIA", "TOF Raws - Hit time (ns) - I/A side;Measured Hit time [ns];Counts", 25000,0. ,610.) ; 
166   TH1F * h7  = new TH1F("hTOFRawsTimeOA", "TOF Raws - Hit time (ns) - O/A side;Measured Hit time [ns];Counts", 25000,0. ,610.) ; 
167   TH1F * h8  = new TH1F("hTOFRawsTimeIC", "TOF Raws - Hit time (ns) - I/C side;Measured Hit time [ns];Counts", 25000,0. ,610.) ; 
168   TH1F * h9  = new TH1F("hTOFRawsTimeOC", "TOF Raws - Hit time (ns) - O/C side;Measured Hit time [ns];Counts", 25000,0. ,610.) ; 
169
170   TH1F * h10  = new TH1F("hTOFRawsToT", "TOF Raws - Hit ToT (ns);Measured Hit ToT (ns);Counts", 1000, 0., 48.8) ; 
171
172   TH1F * h11  = new TH1F("hTOFRawsToTIA", "TOF Raws - Hit ToT (ns) - I/A side;Measured Hit ToT (ns);Counts", 1000, 0., 48.8) ; 
173   TH1F * h12  = new TH1F("hTOFRawsToTOA", "TOF Raws - Hit ToT (ns) - O/A side;Measured Hit ToT (ns);Counts", 1000, 0., 48.8) ; 
174   TH1F * h13  = new TH1F("hTOFRawsToTIC", "TOF Raws - Hit ToT (ns) - I/C side;Measured Hit ToT (ns);Counts", 1000, 0., 48.8) ; 
175   TH1F * h14  = new TH1F("hTOFRawsToTOC", "TOF Raws - Hit ToT (ns) - O/C side;Measured Hit ToT (ns);Counts", 1000, 0., 48.8) ; 
176
177   TH1F * h15 = new TH1F("hTOFRawsLTMHits", "LTMs OR signals; Crate; Counts",  72, 0., 72.);
178   TH1F * h16  = new TH1F("hTOFRawsTRMHits035", "TRM hits  - crates 0 to 35 ;TRM index = SMid(crate*10)+TRM(0-9);Hits",  361, 0., 361.) ;
179   TH1F * h17  = new TH1F("hTOFRawsTRMHits3671","TRM hits  - crates 36 to 71 ;TRM index = SMid(crate*10)+TRM(0-9);Hits", 361, 360., 721.) ;
180   
181   TH1F * h18 = new TH1F("hTOFRawChannelHits","TOF channel hits count; Channel ID; Hits", 158000, 0., 158000);
182   
183   TH1F * h19  = new TH1F("hTOFOrphansTime", "TOF Raws - Orphans time (ns);Measured Hit time [ns];Counts", 25000, 0. ,610.) ; 
184   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., 250, 0., 610.0) ;
185   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., 250, 0., 610.0) ;
186   TH2F * h22 = new TH2F("hTOFRawToTVsTRM035",  "TOF raws - Hit ToT vs TRM - crates 0 to 35; TRM index = DDL*10+TRM(0-9);TOF raw ToT [ns] ", 361, 0., 361., 100, 0., 48.8) ;
187   TH2F * h23 = new TH2F("hTOFRawToTVsTRM3671",  "TOF raws - Hit ToT vs TRM - crates 36 to 72; TRM index = DDL*10+TRM(0-9);TOF raw ToT [ns] ", 361, 360., 721., 100, 0., 48.8) ;
188   TH2F * h24 = new TH2F("hTOFTimeVsStrip","TOF Raws - Hit time vs. strip (theta); Strip index;Raws TOF time (ns) ", 91,0.,91, 250, 0., 610.) ; 
189   
190 // TH2F * h25 = new TH2F("hTOFRawsClusMap","Raws vs TOF eta-phi;eta (2*strip+padz);phi (48*sector+padx)",183, -0.5, 182.5,865,-0.5,864.5) ; 
191
192   h0->Sumw2() ;
193   h1->Sumw2() ;
194   h2->Sumw2() ;
195   h3->Sumw2() ;
196   h4->Sumw2() ;
197   h5->Sumw2() ;
198   h6->Sumw2() ;
199   h7->Sumw2() ;
200   h8->Sumw2() ;
201   h9->Sumw2() ;
202   h10->Sumw2() ;
203   h11->Sumw2() ;
204   h12->Sumw2() ;
205   h13->Sumw2() ;
206   h14->Sumw2() ;
207   h15->Sumw2() ;
208   h16->Sumw2() ;
209   h17->Sumw2() ;
210   h18->Sumw2() ;
211   h19->Sumw2() ;
212   h20->Sumw2() ;
213   h21->Sumw2() ;
214   h22->Sumw2() ;
215   h23->Sumw2() ;
216   h24->Sumw2() ;
217
218   Add2RawsList(h0,   0, !expert,  image, !saveCorr) ;
219   Add2RawsList(h1,   1,  expert, !image, !saveCorr) ;
220   Add2RawsList(h2,   2,  expert, !image, !saveCorr) ;
221   Add2RawsList(h3,   3,  expert, !image, !saveCorr) ;
222   Add2RawsList(h4,   4,  expert, !image, !saveCorr) ;
223   Add2RawsList(h5,   5, !expert,  image, !saveCorr) ;
224   Add2RawsList(h6,   6,  expert, !image, !saveCorr) ;
225   Add2RawsList(h7,   7,  expert, !image, !saveCorr) ;
226   Add2RawsList(h8,   8,  expert, !image, !saveCorr) ;
227   Add2RawsList(h9,   9,  expert, !image, !saveCorr) ;
228   Add2RawsList(h10, 10, !expert,  image, !saveCorr) ;
229   Add2RawsList(h11, 11,  expert, !image, !saveCorr) ;
230   Add2RawsList(h12, 12,  expert, !image, !saveCorr) ;
231   Add2RawsList(h13, 13,  expert, !image, !saveCorr) ;
232   Add2RawsList(h14, 14,  expert, !image, !saveCorr) ;
233   Add2RawsList(h15, 15, !expert,  image, !saveCorr) ;
234   Add2RawsList(h16, 16, !expert,  image, !saveCorr) ;
235   Add2RawsList(h17, 17, !expert,  image, !saveCorr) ;
236   Add2RawsList(h18, 18,  expert, !image, !saveCorr) ;
237   Add2RawsList(h19, 19,  expert, !image, !saveCorr) ;
238   Add2RawsList(h20, 20,  expert, !image, !saveCorr) ;
239   Add2RawsList(h21, 21,  expert, !image, !saveCorr) ;
240   Add2RawsList(h22, 22,  expert, !image, !saveCorr) ;
241   Add2RawsList(h23, 23,  expert, !image, !saveCorr) ;
242   Add2RawsList(h24, 24,  expert, !image, !saveCorr) ;
243
244 }
245
246 //____________________________________________________________________________ 
247 void AliTOFQADataMakerRec::InitRecPoints()
248 {
249   //
250   // create RecPoints histograms in RecPoints subdir
251   //
252
253   const Bool_t expert   = kTRUE ; 
254   const Bool_t image    = kTRUE ; 
255
256   TH1I * h0 = new TH1I("hTOFRecPoints",    "TOF RecPoints multiplicity ; TOF RecPoints number;Counts",200, 0, 200) ;
257
258   TH1F * h1 = new TH1F("hTOFRecPointsTimeIA", "RecPoints Time Spectrum in TOF (ns)- I/A side; Calibrated TOF time [ns];Counts", 25000, 0., 610.) ; 
259   TH1F * h2 = new TH1F("hTOFRecPointsTimeOA", "RecPoints Time Spectrum in TOF (ns)- O/A side; Calibrated TOF time [ns];Counts", 25000, 0., 610.) ;
260   TH1F * h3 = new TH1F("hTOFRecPointsTimeIC", "RecPoints Time Spectrum in TOF (ns)- I/C side; Calibrated TOF time [ns];Counts", 25000, 0., 610.) ;
261   TH1F * h4 = new TH1F("hTOFRecPointsTimeOC", "RecPoints Time Spectrum in TOF (ns)- O/C side; Calibrated TOF time [ns];Counts", 25000, 0., 610.) ;
262   
263   TH1F * h5  = new TH1F("hTOFRecPointsRawTimeIA", "RecPoints raw Time Spectrum in TOF (ns)-I/A side; Measured TOF time [ns];Counts", 25000, 0., 610.) ; 
264   TH1F * h6  = new TH1F("hTOFRecPointsRawTimeOA", "RecPoints raw Time Spectrum in TOF (ns)-O/A side; Measured TOF time [ns];Counts", 25000, 0., 610.) ; 
265   TH1F * h7  = new TH1F("hTOFRecPointsRawTimeIC", "RecPoints raw Time Spectrum in TOF (ns)-I/C side; Measured TOF time [ns];Counts", 25000, 0., 610.) ; 
266   TH1F * h8  = new TH1F("hTOFRecPointsRawTimeOC", "RecPoints raw Time Spectrum in TOF (ns)-O/C side; Measured TOF time [ns];Counts", 25000, 0., 610.) ; 
267  
268   TH1F * h9   = new TH1F("hTOFRecPointsToTIA", "RecPoints ToT Spectrum in TOF (ns)-I/A side; Measured TOT [ns];Counts", 1000, 0., 48.8 ) ; 
269   TH1F * h10  = new TH1F("hTOFRecPointsToTOA", "RecPoints ToT Spectrum in TOF (ns)-O/A side; Measured TOT [ns];Counts", 1000, 0., 48.8 ) ; 
270   TH1F * h11  = new TH1F("hTOFRecPointsToTIC", "RecPoints ToT Spectrum in TOF (ns)-I/C side; Measured TOT [ns];Counts", 1000, 0., 48.8 ) ; 
271   TH1F * h12  = new TH1F("hTOFRecPointsToTOC", "RecPoints ToT Spectrum in TOF (ns)-O/C side; Measured TOT [ns];Counts", 1000, 0., 48.8 ) ; 
272   TH1F * h13 = new TH1F("hTOFRawChannelHits","TOF channel hits count; Channel ID; Hits", 158000, 0., 158000);
273
274   TH2F * h14 = new TH2F("hTOFRecPointsClusMap","RecPoints vs TOF phi-eta; eta (2*strip+padz);phi (48*sector+padx)",183, -0.5, 182.5,865,-0.5,864.5) ; 
275   TH2F * h15 = new TH2F("hTOFRecTimeVsStrip","RecPoints TOF time vs. strip (theta); Strip index; RecPoints TOF time (ns) ",92,-1.,91, 250, 0., 610.) ;
276
277   TH2F * h16 = 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) ;
278   TH2F * h17 = 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) ;
279   TH2F * h18 = new TH2F("hTOFRecPointsToTVsTRM035","TOF RecPoints ToT vs TRM - crates 0 to 35; TRM index = DDL*10+TRM(0-9);TOF ToT [ns] ", 361, 0., 361., 100, 0., 48.8) ;
280   TH2F * h19 = new TH2F("hTOFRecPointsToTVsTRM3671","TOF RecPoints ToT vs TRM - crates 36 to 72; TRM index = DDL*10+TRM(0-9);TOF ToT [ns] ", 361, 360., 721., 100, 0., 48.8) ;
281  
282     h0->Sumw2() ;
283     h1->Sumw2() ;
284     h2->Sumw2() ;
285     h3->Sumw2() ;
286     h4->Sumw2() ;
287     h5->Sumw2() ;
288     h6->Sumw2() ;
289     h7->Sumw2() ;
290     h8->Sumw2() ;
291     h9->Sumw2() ;
292     h10->Sumw2() ;
293     h11->Sumw2() ;
294     h12->Sumw2() ;
295     h13->Sumw2() ;
296     h14->Sumw2() ;
297     h15->Sumw2() ;
298     h16->Sumw2() ;
299     h17->Sumw2() ;
300     h18->Sumw2() ;
301     h19->Sumw2() ;
302
303   Add2RecPointsList(h0, 0,   !expert,  image) ;
304   Add2RecPointsList(h1, 1,   !expert,  image) ;
305   Add2RecPointsList(h2, 2,   !expert,  image) ;
306   Add2RecPointsList(h3, 3,   !expert,  image) ;
307   Add2RecPointsList(h4, 4,   !expert,  image) ;
308   Add2RecPointsList(h5, 5,    expert, !image) ;
309   Add2RecPointsList(h6, 6,    expert, !image) ;
310   Add2RecPointsList(h7, 7,    expert, !image) ;
311   Add2RecPointsList(h8, 8,    expert, !image) ;
312   Add2RecPointsList(h9, 9,   !expert,  image) ;
313   Add2RecPointsList(h10, 10, !expert,  image) ;
314   Add2RecPointsList(h11, 11, !expert,  image) ;
315   Add2RecPointsList(h12, 12, !expert,  image) ;
316   Add2RecPointsList(h13, 13,  expert, !image) ;
317   Add2RecPointsList(h14, 14,  expert, !image) ;
318   Add2RecPointsList(h15, 15,  expert, !image) ;
319   Add2RecPointsList(h16, 16,  expert, !image) ;
320   Add2RecPointsList(h17, 17,  expert, !image) ;
321   Add2RecPointsList(h18, 18,  expert, !image) ;
322   Add2RecPointsList(h19, 19,  expert, !image) ;
323 }
324
325 //____________________________________________________________________________ 
326 void AliTOFQADataMakerRec::InitESDs()
327 {
328   //
329   //create ESDs histograms in ESDs subdir
330   //
331
332   const Bool_t expert   = kTRUE ; 
333   const Bool_t image    = kTRUE ; 
334
335   TH1I * h0  = new TH1I("hTOFESDs", "Number of matched TOF tracks per event;Number of TOF matched ESD tracks;Counts", 200, 0, 200) ;  
336   TH1F * h1  = new TH1F("hTOFESDsTime", "Matched  ESDs tracks: TOF Time spectrum; Calibrated TOF time [ns];Counts", 25000, 0., 610. ) ; 
337   TH1F * h2  = new TH1F("hTOFESDsRawTime", "Matched ESDs tracks: TOF raw Time spectrum;Measured TOF time [ns];Counts", 25000, 0., 610.) ; 
338   TH1F * h3  = new TH1F("hTOFESDsToT", "Matched ESDs tracks: TOF ToT spectrum; ESDs ToT [ns];Counts",1000, 0., 48.8) ; 
339   TH1F * h4  = new TH1F("hTOFESDsPIDoverMatched", "Fraction of TOF identified tracks over matched TOF tracks per event; identified by TOF / matched tracks [%];Counts", 101, -1., 100.) ;  
340   TH1F * h5  = new TH1F("hTOFESDsPID", "Fraction of TOF identified tracks over ESD identified tracks per event;  identified by TOF / ESD identified [%];Counts", 101, -1., 100.) ;  
341   TH1F * h6  = new TH1F("hTOFESDsTPCmatched", "TPC-TOF matched tracks momentum distribution (GeV/c); p (GeV/c);Counts", 50, 0.20, 5.00) ;  
342   TH1F * h7  = new TH1F("hTOFESDsMatchingProb", "TPC-TOF track-matching probability per event;TPC-TOF track-matching probability (%)  ;Counts",101, -1.0, 100) ;  
343   TH1F * h8  = new TH1F("hTOFESDsHitOverTracked", "Fraction of TOF matching tracks over propagated tracks per event; TOF matched / propagated to TOF [%];Counts",101, -1.0, 100.0) ;  
344   TH1F * h9  = new TH1F("hTOFESDsDiffTime", "ESDs t_{TOF}-t_{exp} spectrum in TOF (ps); t_{TOF}-t_{exp} [ps];Counts", 200, -2440., 2440.) ; 
345   TH1F * h10  = new TH1F("hTOFHitsLength", "Matched ESDs tracks: Length Spectrum; Track length [cm];Counts", 800, 0., 800) ; 
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
358   Add2ESDsList(h0, 0, !expert,  image) ;
359   Add2ESDsList(h1, 1, !expert,  image) ;
360   Add2ESDsList(h2, 2,  expert,  image) ;
361   Add2ESDsList(h3, 3, !expert,  image) ;
362   Add2ESDsList(h4, 4,  expert,  image) ;
363   Add2ESDsList(h5, 5,  expert,  image) ;
364   Add2ESDsList(h6, 6,  expert,  image) ; 
365   Add2ESDsList(h7, 7,  expert,  image) ; 
366   Add2ESDsList(h8, 8,  expert,  image) ; 
367   Add2ESDsList(h9, 9, !expert,  image) ;
368   Add2ESDsList(h10, 10, !expert,  image) ;
369 }
370
371
372 //____________________________________________________________________________
373 void AliTOFQADataMakerRec::MakeRaws(AliRawReader* rawReader)
374 {
375   //
376   // makes data from Raws
377   //
378     if (rawReader->GetType()==7) {
379         
380         Double_t tdc2ns=AliTOFGeometry::TdcBinWidth()*1E-3;//in ns
381         Double_t tot2ns=AliTOFGeometry::ToTBinWidth()*1E-3;
382         
383         Int_t ntof[5]; /* 0=tot, 1=IA, 2=OA, 3=IC, 4=OC*/
384         for (Int_t j=0;j<5;j++){ ntof[j]=0;}
385         
386         Int_t equipmentID[5]; //(ddl, trm, chain,tdc,channel)
387         Int_t volumeID[5];   //(sector,plate,strip,padX,padZ)
388         Int_t volumeID2[5];   //(sector,plate,strip,padZ,padX) to use AliTOFGeometry::GetIndex()
389         Int_t out[5]; //   out=(indexZ,indexPhi)   
390         Int_t chIndex=-1;
391         
392         TClonesArray * clonesRawData;
393         AliTOFRawStream tofInput(rawReader);
394         
395         //uncomment if needed to apply DeltaBC correction
396         //tofInput.ApplyBCCorrections(kTRUE);
397         
398         for (Int_t iDDL = 0; iDDL < AliTOFGeometry::NDDL()*AliTOFGeometry::NSectors(); iDDL++){
399             rawReader->Reset();
400             
401             tofInput.LoadRawDataBuffersV2(iDDL);
402             clonesRawData = (TClonesArray*)tofInput.GetRawData();
403             for (Int_t iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) {
404                 AliTOFrawData *tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData);
405                 
406                 if (tofRawDatum->GetTOF()){
407                     
408                     equipmentID[0]=iDDL;
409                     equipmentID[1]=tofRawDatum->GetTRM(); 
410                     equipmentID[2]=tofRawDatum->GetTRMchain();
411                     equipmentID[3]=tofRawDatum->GetTDC();
412                     equipmentID[4]=tofRawDatum->GetTDCchannel();
413                     
414                     if (CheckEquipID(equipmentID)){
415                         tofInput.EquipmentId2VolumeId(iDDL, 
416                                                       tofRawDatum->GetTRM(), 
417                                                       tofRawDatum->GetTRMchain(),
418                                                       tofRawDatum->GetTDC(), 
419                                                       tofRawDatum->GetTDCchannel(), 
420                                                       volumeID);
421                         if (FilterSpare(equipmentID)) continue;
422                         if (FilterLTMData(equipmentID)){ //counts LTM hits
423                             if (tofRawDatum->GetTOT()) GetRawsData(15)->Fill(equipmentID[0]);
424                         } else {
425                             if (CheckVolumeID(volumeID)){  
426                                 
427                                 GetMapIndeces(volumeID,out);
428                                 volumeID2[0]=volumeID[0];
429                                 volumeID2[1]=volumeID[1];
430                                 volumeID2[2]=volumeID[2];
431                                 volumeID2[3]=volumeID[4];
432                                 volumeID2[4]=volumeID[3];
433                                 chIndex=AliTOFGeometry::GetIndex(volumeID2);
434                                 
435                                 if (tofRawDatum->GetTOT()){         
436                                     if (!(fCalibData->GetNoiseStatus(chIndex)==AliTOFChannelOnlineStatusArray::kTOFNoiseBad)
437                                         && (fCalibData->GetHWStatus(chIndex) == AliTOFChannelOnlineStatusArray::kTOFHWOk)) {//noise and enabled filter
438                                         ntof[0]++; //counter for tof hits
439                                         
440                                         //fill global spectra for DQM plots
441                                         GetRawsData(5)->Fill( tofRawDatum->GetTOF()*tdc2ns) ;//in ns
442                                         GetRawsData(10)->Fill( tofRawDatum->GetTOT()*tot2ns) ;//in ns
443                                         
444                                         //fill side-related spectra for experts plots
445                                         if (volumeID2[0]>4 && volumeID2[0]<14){       //I side
446                                             if ((iDDL%4==0)|| (iDDL%4==1)){ //A side
447                                                 ntof[1]++;
448                                                 GetRawsData(6)->Fill( tofRawDatum->GetTOF()*tdc2ns) ;
449                                                 GetRawsData(11)->Fill( tofRawDatum->GetTOT()*tot2ns) ;
450                                             } else {
451                                                 if ((iDDL%4==2)|| (iDDL%4==3)){//C side
452                                                     ntof[3]++;
453                                                     GetRawsData(8)->Fill( tofRawDatum->GetTOF()*tdc2ns) ;
454                                                     GetRawsData(13)->Fill( tofRawDatum->GetTOT()*tot2ns) ;
455                                                 }
456                                             }
457                                         } else {                                    
458                                             if (volumeID2[0]<5 || volumeID2[0]>13){   //O side
459                                                 if ((iDDL%4==0)|| (iDDL%4==1)){ //A side
460                                                     ntof[2]++;
461                                                     GetRawsData(7)->Fill( tofRawDatum->GetTOF()*tdc2ns) ;
462                                                     GetRawsData(12)->Fill( tofRawDatum->GetTOT()*tot2ns) ;
463                                                 } else {
464                                                     if ((iDDL%4==2)|| (iDDL%4==3)){//C side
465                                                         ntof[4]++;
466                                                         GetRawsData(9)->Fill( tofRawDatum->GetTOF()*tdc2ns) ;
467                                                         GetRawsData(14)->Fill( tofRawDatum->GetTOT()*tot2ns) ;
468                                                     }
469                                                 }
470                                             }   
471                                         }
472                                         GetRawsData(18)->Fill(chIndex);
473                                         //compute TRM offset
474                                         Int_t trm= iDDL*10+(equipmentID[1]-3);
475                                         if (iDDL>=0 && iDDL<36) {
476                                             GetRawsData(16)->Fill(trm) ;
477                                             GetRawsData(20)->Fill(trm,tofRawDatum->GetTOF()*tdc2ns);
478                                             GetRawsData(22)->Fill(trm,tofRawDatum->GetTOT()*tot2ns);
479                                         }
480                                         if (iDDL>=36 && iDDL<72) {
481                                             GetRawsData(17)->Fill(trm) ;//in ns 
482                                             GetRawsData(21)->Fill(trm,tofRawDatum->GetTOF()*tdc2ns);
483                                             GetRawsData(23)->Fill(trm,tofRawDatum->GetTOT()*tot2ns);
484                                         }                               
485                                         GetRawsData(24)->Fill(GetStripIndex(volumeID),tofRawDatum->GetTOF()*tdc2ns) ;
486                                         //GetRawsData(25)->Fill( out[0],out[1]) ;//raw map
487                                     }//noise filter
488                                 }//end hit selection
489                                 else { //orphans
490                                     if (!(fCalibData->GetNoiseStatus(chIndex) == AliTOFChannelOnlineStatusArray::kTOFNoiseBad)
491                                         && (fCalibData->GetHWStatus(chIndex) == AliTOFChannelOnlineStatusArray::kTOFHWOk))
492                                         GetRawsData(19)->Fill( tofRawDatum->GetTOF()*tdc2ns) ;//in ns
493                                 }//end orphans
494                             }//end volumeID check
495                         }//end LTM filter
496                     }//end equipID check
497                 }
498             } //while loop
499             clonesRawData->Clear();
500         } // DDL Loop
501         
502         for (Int_t j=0;j<5;j++){
503             GetRawsData(j)->Fill(ntof[j]);
504         }
505         fProcessedRawEventN++;
506         
507     } else {
508         AliDebug(1,Form("Event of type %d found. Skipping non-physics event for QA.\n", rawReader->GetType())); 
509     }
510     EnableDqmShifterOpt(kTRUE);
511 }
512
513 //____________________________________________________________________________
514 void AliTOFQADataMakerRec::MakeRecPoints(TTree * clustersTree)
515 {
516     //
517   // Make data from Clusters
518   //
519  
520   Double_t tdc2ns=AliTOFGeometry::TdcBinWidth()*1E-3;
521   Double_t tot2ns=AliTOFGeometry::ToTBinWidth()*1E-3;
522
523   Int_t volumeID[5];
524   Int_t volumeID2[5];
525   Int_t out[5];
526
527   TBranch *branch=clustersTree->GetBranch("TOF");
528   if (!branch) { 
529     AliError("can't get the branch with the TOF clusters !");
530     return;
531   }
532
533   static TClonesArray dummy("AliTOFcluster",10000);
534   dummy.Clear();
535   TClonesArray *clusters=&dummy;
536   branch->SetAddress(&clusters);
537
538   // Import the tree
539   clustersTree->GetEvent(0);  
540  
541   GetRecPointsData(0)->Fill((Int_t)clusters->GetEntriesFast()) ; 
542   
543   TIter next(clusters) ; 
544   AliTOFcluster * c ; 
545   while ( (c = dynamic_cast<AliTOFcluster *>(next())) ) {
546    
547       volumeID[0] = c->GetDetInd(0);
548       volumeID[1] = c->GetDetInd(1);
549       volumeID[2] = c->GetDetInd(2);
550       volumeID[3] = c->GetDetInd(4); //X and Z indeces inverted in RecPoints
551       volumeID[4] = c->GetDetInd(3); //X and Z indeces inverted in RecPoints
552       
553       for (Int_t i=0;i<5;i++){
554           volumeID2[i]=c->GetDetInd(i); //X and Z indeces inverted in RecPoints
555       }
556       
557       GetMapIndeces(volumeID,out);
558       Int_t chIndex=AliTOFGeometry::GetIndex(volumeID2);
559       Int_t iDDL=AliTOFRawStream::Geant2DDL(volumeID2);
560       Int_t iTRM=AliTOFRawStream::Geant2TRM(volumeID2);
561
562       if (c->GetTDCRAW() && c->GetTDC() && c->GetToT()){
563           if (volumeID2[0]>4 && volumeID2[0]<14){       //I side
564               if ((iDDL%4==0)|| (iDDL%4==1)){ //A side
565                   GetRecPointsData(1)->Fill( c->GetTDC()*tdc2ns) ;//in ns
566                   GetRecPointsData(5)->Fill( c->GetTDCRAW()*tdc2ns) ;//in ns
567                   GetRecPointsData(9)->Fill( c->GetToT()*tot2ns) ;//in ns
568                   
569               } else {
570                   if ((iDDL%4==2)|| (iDDL%4==3)){//C side
571                       GetRecPointsData(3)->Fill( c->GetTDC()*tdc2ns) ;//in ns
572                       GetRecPointsData(7)->Fill( c->GetTDCRAW()*tdc2ns) ;//in ns
573                       GetRecPointsData(11)->Fill( c->GetToT()*tot2ns) ;//in ns
574                   }
575               }
576           } else {
577               if (volumeID2[0]<5 || volumeID2[0]>13){       //O side
578                   if ((iDDL%4==0)|| (iDDL%4==1)){ //A side
579                       GetRecPointsData(2)->Fill( c->GetTDC()*tdc2ns) ;//in ns
580                       GetRecPointsData(6)->Fill( c->GetTDCRAW()*tdc2ns) ;//in ns
581                       GetRecPointsData(10)->Fill( c->GetToT()*tot2ns) ;//in ns
582                   } else {
583                       if ((iDDL%4==2)|| (iDDL%4==3)){//C side
584                           GetRecPointsData(4)->Fill( c->GetTDC()*tdc2ns) ;//in ns
585                           GetRecPointsData(8)->Fill( c->GetTDCRAW()*tdc2ns) ;//in ns
586                           GetRecPointsData(12)->Fill( c->GetToT()*tot2ns) ;//in ns
587                       }
588                   }
589               }
590           }
591           GetRecPointsData(14)->Fill(out[0],out[1]);
592           GetRecPointsData(15)->Fill(GetStripIndex(volumeID), c->GetTDC()*tdc2ns) ;
593           Int_t trm= iDDL*10+(iTRM-3);
594           if (iDDL>=0 && iDDL<36) {
595               GetRecPointsData(16)->Fill(trm,c->GetTDC()*tdc2ns);
596               GetRecPointsData(18)->Fill(trm,c->GetToT()*tot2ns);
597           }
598           if (iDDL>=36 && iDDL<72) {
599               GetRecPointsData(17)->Fill(trm,c->GetTDC()*tdc2ns);
600               GetRecPointsData(19)->Fill(trm,c->GetToT()*tot2ns);
601           }
602           GetRecPointsData(13)->Fill(chIndex) ;//in ns
603       }//hit selection
604   }//end while  
605  
606   EnableDqmShifterOpt(kFALSE);
607 }
608
609 //____________________________________________________________________________
610 void AliTOFQADataMakerRec::MakeESDs(AliESDEvent * esd)
611 {
612   //
613   // make QA data from ESDs
614   //  
615     const Double_t speedOfLight = TMath::C()*1E2*1E-12; // cm/ps
616     const Double_t pionMass = 0.13957018; //GeV/c^2
617
618     Int_t ntrk = esd->GetNumberOfTracks() ; 
619     Int_t ntof=0;
620     Int_t ntofpid=0;
621     Int_t nesdpid=0;
622     Int_t ntpc=0;
623     Int_t ntpctof=0;
624     Int_t ntofout=0;
625     
626     while (ntrk--) {
627         AliESDtrack *track=esd->GetTrack(ntrk);
628         Double_t tofTime=track->GetTOFsignal();//in ps
629         Double_t tofTimeRaw=track->GetTOFsignalRaw();//in ps
630         Double_t tofToT=track->GetTOFsignalToT(); //in ps
631
632         UInt_t status=track->GetStatus();
633         if (track->IsOn(AliESDtrack::kTPCrefit)) {
634             ntpc++;
635             Double_t y=track->Eta();
636             if ((status&AliESDtrack::kTOFout)!=0) {
637                 ntofout++;
638                 if (tofTime>0){
639                     ntof++;
640                     
641                     if (TMath::Abs(y)<0.9) {
642                         GetESDsData(6)->Fill(track->Pt());
643                         ntpctof++;
644                     }
645                     GetESDsData(1)->Fill(tofTime*1E-3);
646                     GetESDsData(2)->Fill(tofTimeRaw*1E-3); 
647                     GetESDsData(3)->Fill(tofToT*1E-3);
648                     //check how many tracks where ESD PID is ok 
649                     if ((status&AliESDtrack::kESDpid)!=0) nesdpid++; 
650                     if (((status&AliESDtrack::kESDpid)&AliESDtrack::kTOFpid)!=0) ntofpid++;
651                     
652                     Double_t length =track->GetIntegratedLength();
653                     Double_t mom2=(track->Pt()*track->Pt())+(track->Pz()*track->Pz());
654                     Double_t eTexp = TMath::Sqrt(1+(pionMass*pionMass/mom2))*length/speedOfLight; //in ps
655                     GetESDsData(9)->Fill(tofTime-eTexp);
656                     GetESDsData(10)->Fill(length);
657                 } //end check on matched tracks
658             }
659         }//end check on TPCrefit
660     }
661     
662     GetESDsData(0)->Fill(ntof) ;
663   
664     
665     if(ntof>0) {
666         Float_t ratio = (Int_t)ntofpid/(Int_t)ntof*100; //identified by TOF over matched
667         GetESDsData(4)->Fill(ratio) ;
668     }
669     
670     if(nesdpid>0) {
671         Float_t ratio = (Float_t)ntofpid/(Float_t)nesdpid *100; //identified by TOF over identified
672         GetESDsData(5)->Fill(ratio) ;
673     }
674     
675     if(ntpc>0){
676         Float_t ratio = (Float_t)ntof/(Float_t)ntpc*100.; //matching probability
677         GetESDsData(7)->Fill(ratio) ;
678     }
679     
680     if(ntofout>0) {
681         Float_t ratio = (Float_t)ntof/(Float_t)ntofout*100; //matched over propagated to TOF outer radius
682         GetESDsData(8)->Fill(ratio) ;
683     }
684     EnableDqmShifterOpt(kFALSE);
685 }
686
687 //____________________________________________________________________________ 
688 void AliTOFQADataMakerRec::StartOfDetectorCycle()
689 {
690   //
691   //Detector specific actions at start of cycle
692  
693   fCalibData = GetCalibData();
694
695 }
696
697 //____________________________________________________________________________ 
698 void AliTOFQADataMakerRec::EndOfDetectorCycle(AliQAv1::TASKINDEX_t task, TObjArray ** list)
699 {
700   //Detector specific actions at end of cycle
701   // do the QA checking
702      for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
703         if ( !AliQAv1::Instance()->IsEventSpecieSet(specie) ) 
704             continue ; 
705         
706         if (fEnableDqmShifterOpt){
707             // Help make the raw qa histogram easier to interpret for the DQM shifter
708             // This is still to be optimized...
709             
710             if (!GetRawsData(0) || !GetRawsData(5) || !GetRawsData(10) 
711                 || !GetRawsData(15) || !GetRawsData(16) || !GetRawsData(17)) {
712                 printf("No histogram for DQM found - Possible memory corruption ???. Please check\n") ; 
713                 continue;
714             }
715             AliInfo(Form("Processed %i physics raw events",fProcessedRawEventN));
716             
717             
718             if (fCalibData){
719                 //normalize TRM hits plots to the number of enabled channels from OCDB object
720                 TH1F * hTrmChannels035 = new TH1F("hTrmchannels035", "Active channels per TRM - crates 0 to 35;TRM index = SMid(crate*10)+TRM(0-9);Active channels",  361, 0., 361.) ;
721                 TH1F * hTrmChannels3671 = new TH1F("hTrmChannels3671","Active channels per TRM - crates 36 to 71 ;TRM index = SMid(crate*10)+TRM(0-9);Active channels", 361, 360., 721.) ;
722                 
723                 for (Int_t ch = 0; ch <  fCalibData->GetSize(); ch++) {
724                     if (!(fCalibData->GetNoiseStatus(ch)==AliTOFChannelOnlineStatusArray::kTOFNoiseBad)
725                         && (fCalibData->GetHWStatus(ch) == AliTOFChannelOnlineStatusArray::kTOFHWOk)){
726                         Int_t geoId[5];
727                         Int_t detId[5];
728                         AliTOFGeometry::GetVolumeIndices(ch,geoId);
729                         AliTOFRawStream::Geant2EquipmentId(geoId,detId); //detID=(ddl,trm,tdc, chain,channel)
730                         if (detId[0]<36) hTrmChannels035->Fill((detId[1]-3)+detId[0]*10);
731                         else hTrmChannels3671->Fill((detId[1]-3)+detId[0]*10);
732                     }
733                 }
734                 GetRawsData(16)->Divide(hTrmChannels035);
735                 GetRawsData(16)->SetTitle("TRMs average hit number per active channel - crates 0-35");
736                 GetRawsData(16)->GetYaxis()->SetTitle("hits/active channels");
737                 GetRawsData(17)->Divide(hTrmChannels3671);
738                 GetRawsData(17)->SetTitle("TRMs average hit number per active channel - crates 36-71");
739                 GetRawsData(17)->GetYaxis()->SetTitle("hits/active channels");
740             }
741             
742             
743             Double_t yTimeMin = GetRawsData(5)->GetMinimum();
744             Double_t yTimeMax = GetRawsData(5)->GetMaximum();
745             Double_t yTotMin = GetRawsData(10)->GetMinimum();
746             Double_t yTotMax = GetRawsData(10)->GetMaximum();
747             
748             TLine* lineExpTimeMin = new TLine(200., yTimeMin, 200., yTimeMax);
749             lineExpTimeMin->SetLineColor(kGreen);
750             lineExpTimeMin->SetLineWidth(2);
751             
752             TLine* lineExpTimeMax = new TLine(250., yTimeMin, 250., yTimeMax);
753             lineExpTimeMax->SetLineColor(kGreen);
754             lineExpTimeMax->SetLineWidth(2);
755             
756             TLine* lineExpTotMin = new TLine( 5., yTotMin, 5., yTotMax);
757             lineExpTotMin->SetLineColor(kGreen);
758             lineExpTotMin->SetLineWidth(2);
759             
760             TLine* lineExpTotMax = new TLine(20., yTotMin, 20., yTotMax);
761             lineExpTotMax->SetLineColor(kGreen);
762             lineExpTotMax->SetLineWidth(2);
763             
764             ((TH1F*)GetRawsData(5))->GetListOfFunctions()->Add(lineExpTimeMin);
765             ((TH1F*)GetRawsData(5))->GetListOfFunctions()->Add(lineExpTimeMax);
766             ((TH1F*)GetRawsData(10))->GetListOfFunctions()->Add(lineExpTotMin);
767             ((TH1F*)GetRawsData(10))->GetListOfFunctions()->Add(lineExpTotMax);
768                             
769             //make up for all bistos 
770             for(Int_t j=0;j<20;j++){
771               if (j<5) {
772                 GetRawsData(j)->SetMarkerColor(kRed);
773                 GetRawsData(j)->SetMarkerStyle(7);
774               } else {
775                 GetRawsData(j)->SetLineColor(kBlue+1);
776                 GetRawsData(j)->SetLineWidth(1);
777                 GetRawsData(j)->SetMarkerColor(kBlue+1);
778               }
779             }
780             Float_t ySMmax035=GetRawsData(16)->GetMaximum();
781             TLine* lineSMid035[10];
782             Float_t ySMmax3671=GetRawsData(17)->GetMaximum();
783             TLine* lineSMid3671[10];
784             
785             for (Int_t sm=0;sm<10;sm++){
786               lineSMid035[sm] = new TLine( 40*sm, 0, 40*sm, ySMmax035);
787               lineSMid035[sm]->SetLineColor(kMagenta);
788               lineSMid035[sm]->SetLineWidth(2);
789               GetRawsData(16)->GetListOfFunctions()->Add(lineSMid035[sm]);
790               
791               lineSMid3671[sm] = new TLine( 40*sm+360, 0, 40*sm+360, ySMmax3671);
792               lineSMid3671[sm]->SetLineColor(kMagenta);
793               lineSMid3671[sm]->SetLineWidth(2);
794               GetRawsData(17)->GetListOfFunctions()->Add(lineSMid3671[sm]);
795             }
796             
797             for (Int_t j=15;j<19;j++){
798               GetRawsData(j)->SetFillColor(kGray+1);
799               GetRawsData(j)->SetOption("bar");
800             }
801             
802         }
803     }
804     AliQAChecker::Instance()->Run(AliQAv1::kTOF, task, list) ;  
805 }
806 //____________________________________________________________________________
807 void AliTOFQADataMakerRec::GetMapIndeces(const Int_t* const in , Int_t* out)
808 {
809   //
810   //return appropriate indeces for the theta-phi map
811   //
812
813   Int_t npadX = AliTOFGeometry::NpadX();
814   Int_t npadZ = AliTOFGeometry::NpadZ();
815   Int_t nStripA = AliTOFGeometry::NStripA();
816   Int_t nStripB = AliTOFGeometry::NStripB();
817   Int_t nStripC = AliTOFGeometry::NStripC();
818
819   Int_t isector = in[0];
820   Int_t iplate = in[1];
821   Int_t istrip = in[2];
822   Int_t ipadX = in[3]; 
823   Int_t ipadZ = in[4]; 
824   
825   Int_t stripOffset = 0;
826   switch (iplate) {
827   case 0:
828     stripOffset = 0;
829       break;
830   case 1:
831     stripOffset = nStripC;
832     break;
833   case 2:
834     stripOffset = nStripC+nStripB;
835     break;
836   case 3:
837     stripOffset = nStripC+nStripB+nStripA;
838     break;
839   case 4:
840     stripOffset = nStripC+nStripB+nStripA+nStripB;
841     break;
842   default:
843     AliDebug(1,Form("Wrong plate number in TOF (%d) !",iplate));
844     break;
845   };
846   Int_t zindex=npadZ*(istrip+stripOffset)+(ipadZ+1);
847   Int_t phiindex=npadX*isector+ipadX+1;
848   out[0]=zindex;  
849   out[1]=phiindex;  
850   
851 }
852
853 //---------------------------------------------------------------
854 Int_t AliTOFQADataMakerRec::GetStripIndex(const Int_t * const in)
855 {
856     /* return tof strip index between 0 and 91 */
857
858   Int_t nStripA = AliTOFGeometry::NStripA();
859   Int_t nStripB = AliTOFGeometry::NStripB();
860   Int_t nStripC = AliTOFGeometry::NStripC();
861
862   // Int_t isector = in[0];
863   Int_t iplate = in[1];
864   Int_t istrip = in[2];
865   //Int_t ipadX = in[3]; 
866   //Int_t ipadZ = in[4]; 
867   
868   Int_t stripOffset = 0;
869   switch (iplate) {
870   case 0:
871     stripOffset = 0;
872       break;
873   case 1:
874     stripOffset = nStripC;
875     break;
876   case 2:
877     stripOffset = nStripC+nStripB;
878     break;
879   case 3:
880     stripOffset = nStripC+nStripB+nStripA;
881     break;
882   case 4:
883     stripOffset = nStripC+nStripB+nStripA+nStripB;
884     break;
885   default:
886       AliDebug(1,Form("Wrong plate number in TOF (%d) !",iplate));
887       stripOffset=-1;
888       break;
889   };
890   
891   if (stripOffset<0 || stripOffset>92) return -1;
892   else 
893       return (stripOffset+istrip);
894   
895 }
896 //---------------------------------------------------------------
897 Bool_t  AliTOFQADataMakerRec::CheckVolumeID(const Int_t * const volumeID)
898 {
899     //
900     //Checks volume ID validity
901     //
902    
903     for (Int_t j=0;j<5;j++){
904         if (volumeID[j]<0) {
905             AliDebug(1,Form("Invalid detector volume index for volumeID[%i]",j));
906             return kFALSE;
907         }
908     }
909     return kTRUE;
910     
911 }
912
913 //---------------------------------------------------------------
914 Bool_t  AliTOFQADataMakerRec::CheckEquipID(const Int_t * const equipmentID)
915 {
916     //
917     //Checks equipment ID validity
918     
919    for (Int_t j=0;j<5;j++){
920         if (equipmentID[j]<0) {
921           AliDebug(1,Form("Invalid equipment volume index for equipmentID[%i]",j));
922           return kFALSE;
923         }
924    }
925    return kTRUE;
926 }
927 //---------------------------------------------------------------
928 Bool_t  AliTOFQADataMakerRec::FilterLTMData(const Int_t * const equipmentID) const
929 {
930   /*It returns kTRUE if data come from LTM.
931     It thus filters trigger-related signals  */
932
933   Int_t ddl, trm, tdc;
934   //if (!CheckEquipID(equipmentID)) return kFALSE;
935   ddl = equipmentID[0];
936   trm = equipmentID[1];
937   tdc = equipmentID[3];
938   
939   if ((ddl%2==1) && (trm==3) && (tdc>11 && tdc<15))
940     return kTRUE;
941   else 
942     return kFALSE;
943  
944 }
945 //---------------------------------------------------------------
946 Bool_t  AliTOFQADataMakerRec::FilterSpare(const Int_t * const equipmentID) const
947 {
948   /*It returns kTRUE if data come from spare 
949     equipment ID. 
950     So far only check on TRM 3 crate left is implemented */
951
952   Int_t ddl, trm, tdc;
953   //if (!CheckEquipID(equipmentID)) return kFALSE;
954   ddl = equipmentID[0];
955   trm = equipmentID[1];
956   tdc = equipmentID[3];
957   
958   if ((ddl%2==1) && (trm==3) && (tdc>2 && tdc<12))
959     return kTRUE;
960   else 
961     return kFALSE;
962  
963 }