]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TOF/AliTOFQADataMakerRec.cxx
Fixes for bug #49914: Compilation breaks in trunk, and bug #48629: Trunk cannot read...
[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 #include <TClonesArray.h>
25 //#include <TFile.h> 
26 //#include <TH1I.h> 
27 #include <TH1F.h> 
28 #include <TH2F.h> 
29
30 #include "AliLog.h"
31 #include "AliESDEvent.h"
32 #include "AliESDtrack.h"
33 #include "AliQAChecker.h"
34 #include "AliRawReader.h"
35
36 #include "AliTOFcluster.h"
37 #include "AliTOFQADataMakerRec.h"
38 #include "AliTOFRawStream.h"
39 #include "AliTOFrawData.h"
40 #include "AliTOFGeometry.h"
41
42 ClassImp(AliTOFQADataMakerRec)
43            
44 //____________________________________________________________________________ 
45   AliTOFQADataMakerRec::AliTOFQADataMakerRec() : 
46   AliQADataMakerRec(AliQAv1::GetDetName(AliQAv1::kTOF), "TOF Quality Assurance Data Maker")
47 {
48   //
49   // ctor
50   //
51 }
52
53 //____________________________________________________________________________ 
54 AliTOFQADataMakerRec::AliTOFQADataMakerRec(const AliTOFQADataMakerRec& qadm) :
55   AliQADataMakerRec()
56 {
57   //
58   //copy ctor 
59   //
60   SetName((const char*)qadm.GetName()) ; 
61   SetTitle((const char*)qadm.GetTitle()); 
62 }
63
64 //__________________________________________________________________
65 AliTOFQADataMakerRec& AliTOFQADataMakerRec::operator = (const AliTOFQADataMakerRec& qadm )
66 {
67   //
68   // assignment operator.
69   //
70   this->~AliTOFQADataMakerRec();
71   new(this) AliTOFQADataMakerRec(qadm);
72   return *this;
73 }
74  
75 //____________________________________________________________________________ 
76 void AliTOFQADataMakerRec::InitRaws()
77 {
78   //
79   // create Raws histograms in Raws subdir
80   //
81
82   Bool_t expert = kFALSE;
83
84   TH1F * h0 = new TH1F("hTOFRaws",    "Number of TOF Raws ",301, -1.02, 5.) ;   h0->Sumw2() ;
85   Add2RawsList(h0, 0, expert) ;
86
87   TH1F * h1  = new TH1F("hTOFRawsTime", "Raws Time Spectrum in TOF (ns)", 2000, 0., 200) ; 
88   h1->Sumw2() ;
89   Add2RawsList(h1, 1, expert) ;
90
91   TH1F * h2  = new TH1F("hTOFRawsToT", "Raws ToT Spectrum in TOF (ns)", 500, 0., 50) ; 
92   h2->Sumw2() ;
93   Add2RawsList(h2, 2, expert) ;
94
95   TH2F * h3  = new TH2F("hTOFRawsClusMap","Raws vs TOF eta-phi",183, -0.5, 182.5,865,-0.5,864.5) ; 
96   h3->Sumw2() ;
97   Add2RawsList(h3, 3, expert) ;
98
99 }
100
101 //____________________________________________________________________________ 
102 void AliTOFQADataMakerRec::InitRecPoints()
103 {
104   //
105   // create RecPoints histograms in RecPoints subdir
106   //
107
108   Bool_t expert = kFALSE;
109
110   TH1F * h0 = new TH1F("hTOFRecPoints",    "Number of TOF RecPoints ",301, -1.02, 5.) ;   h0->Sumw2() ;
111   Add2RecPointsList(h0, 0, expert) ;
112
113   TH1F * h1  = new TH1F("hTOFRecPointsTime", "RecPoints Time Spectrum in TOF (ns)", 2000, 0., 200) ; 
114   h1->Sumw2() ;
115   Add2RecPointsList(h1, 1, expert) ;
116
117   TH1F * h2  = new TH1F("hTOFRecPointsRawTime", "RecPoints raw Time Spectrum in TOF (ns)", 2000, 0., 200) ; 
118   h2->Sumw2() ;
119   Add2RecPointsList(h2, 2, expert) ;
120
121   TH1F * h3  = new TH1F("hTOFRecPointsToT", "RecPoints ToT Spectrum in TOF (ns)", 500, 0., 50) ; 
122   h3->Sumw2() ;
123   Add2RecPointsList(h3, 3, expert) ;
124
125   TH2F * h4  = new TH2F("hTOFRecPointsClusMap","RecPoints vs TOF phi-eta",183, -0.5, 182.5,865,-0.5,864.5) ; 
126   h4->Sumw2() ;
127   h4->GetXaxis()->SetTitle("2*strip+padz (eta)");
128   h4->GetYaxis()->SetTitle("48*sector+padx (phi)");
129
130   Add2RecPointsList(h4, 4, expert) ;
131
132 }
133
134 //____________________________________________________________________________ 
135 void AliTOFQADataMakerRec::InitESDs()
136 {
137   //
138   //create ESDs histograms in ESDs subdir
139   //
140
141   Bool_t expert = kFALSE;
142
143   TH1F * h0 = new TH1F("hTOFESDs",    "Number of matched TOF tracks over ESDs",       250, -1., 4.) ;  
144   h0->Sumw2() ; 
145   Add2ESDsList(h0, 0, expert) ;
146
147   TH1F * h1  = new TH1F("hTOFESDsTime", "Time Spectrum in TOF (ns)", 2000, 0., 200) ; 
148   h1->Sumw2() ;
149   Add2ESDsList(h1, 1, expert) ;
150
151   TH1F * h2  = new TH1F("hTOFESDsRawTime", "raw Time Spectrum in TOF (ns)", 2000, 0., 200) ; 
152   h2->Sumw2() ;
153   Add2ESDsList(h2, 2, expert) ;
154
155   TH1F * h3  = new TH1F("hTOFESDsToT", "ToT Spectrum in TOF (ns)", 500, 0., 50) ; 
156   h3->Sumw2() ;
157   Add2ESDsList(h3, 3, expert) ;
158
159   TH1F * h4 = new TH1F("hTOFESDsPID",    "Fraction of matched TOF tracks with good PID flag (%)", 101, 0., 101.) ;  
160   h4->Sumw2() ; 
161   Add2ESDsList(h4, 4, expert) ;
162 }
163
164 //____________________________________________________________________________
165 void AliTOFQADataMakerRec::MakeRaws(AliRawReader* rawReader)
166 {
167   //
168   // makes data from Raws
169   //
170
171   Double_t tdc2ns=AliTOFGeometry::TdcBinWidth()*1E-3;
172   Double_t tot2ns=AliTOFGeometry::ToTBinWidth()*1E-3;
173
174
175   Int_t ntof = 0 ; 
176   Int_t in[5];
177   Int_t out[5];
178
179   TClonesArray * clonesRawData;
180   AliTOFRawStream tofInput(rawReader);
181   for (Int_t iDDL = 0; iDDL < AliTOFGeometry::NDDL()*AliTOFGeometry::NSectors(); iDDL++){
182     rawReader->Reset();
183     tofInput.LoadRawData(iDDL);
184     clonesRawData = (TClonesArray*)tofInput.GetRawData();
185     for (Int_t iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) {
186       AliTOFrawData *tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData);
187       if (!tofRawDatum->GetTOT() || !tofRawDatum->GetTOF()) continue;
188       ntof++;
189       GetRawsData(1)->Fill( tofRawDatum->GetTOF()*tdc2ns) ;//in ns
190       GetRawsData(2)->Fill( tofRawDatum->GetTOT()*tot2ns) ;//in ns
191
192       tofInput.EquipmentId2VolumeId(iDDL, 
193                                     tofRawDatum->GetTRM(), 
194                                     tofRawDatum->GetTRMchain(),
195                                     tofRawDatum->GetTDC(), 
196                                     tofRawDatum->GetTDCchannel(), 
197                                     in);
198     
199       GetMapIndeces(in,out);
200       GetRawsData(3)->Fill( out[0],out[1]) ;//raw map
201       
202     } // while loop
203     
204     clonesRawData->Clear();
205     
206   } // DDL Loop
207   
208   Int_t nentries=ntof;
209   if(nentries<=0){
210     GetRawsData(0)->Fill(-1.) ; 
211   }else{
212     GetRawsData(0)->Fill(TMath::Log10(nentries)) ; 
213   }
214 }
215
216 //____________________________________________________________________________
217 void AliTOFQADataMakerRec::MakeRecPoints(TTree * clustersTree)
218 {
219   //
220   // Make data from Clusters
221   //
222
223   Double_t tdc2ns=AliTOFGeometry::TdcBinWidth()*1E-3;
224   Double_t tot2ns=AliTOFGeometry::ToTBinWidth()*1E-3;
225
226   Int_t in[5];
227   Int_t out[5];
228
229   TBranch *branch=clustersTree->GetBranch("TOF");
230   if (!branch) { 
231     AliError("can't get the branch with the TOF clusters !");
232     return;
233   }
234
235   static TClonesArray dummy("AliTOFcluster",10000);
236   dummy.Clear();
237   TClonesArray *clusters=&dummy;
238   branch->SetAddress(&clusters);
239
240   // Import the tree
241   clustersTree->GetEvent(0);  
242   
243   Int_t nentries=clusters->GetEntriesFast();
244   if(nentries<=0){
245     GetRecPointsData(0)->Fill(-1.) ; 
246   }else{
247     GetRecPointsData(0)->Fill(TMath::Log10(nentries)) ; 
248   } 
249  
250   TIter next(clusters) ; 
251   AliTOFcluster * c ; 
252   while ( (c = dynamic_cast<AliTOFcluster *>(next())) ) {
253     GetRecPointsData(1)->Fill(c->GetTDC()*tdc2ns);
254     GetRecPointsData(2)->Fill(c->GetTDCRAW()*tdc2ns);
255     GetRecPointsData(3)->Fill(c->GetToT()*tot2ns);
256     
257     in[0] = c->GetDetInd(0);
258     in[1] = c->GetDetInd(1);
259     in[2] = c->GetDetInd(2);
260     in[3] = c->GetDetInd(4); //X and Z indeces inverted in RecPoints
261     in[4] = c->GetDetInd(3); //X and Z indeces inverted in RecPoints
262     
263     GetMapIndeces(in,out);
264     GetRecPointsData(4)->Fill(out[0],out[1]);
265     
266   }
267 }
268
269 //____________________________________________________________________________
270 void AliTOFQADataMakerRec::MakeESDs(AliESDEvent * esd)
271 {
272   //
273   // make QA data from ESDs
274   //  
275   Int_t ntrk = esd->GetNumberOfTracks() ; 
276   Int_t ntof=0;
277   Int_t ntofpid=0;
278   while (ntrk--) {
279     AliESDtrack *track=esd->GetTrack(ntrk);
280     Double_t tofTime=track->GetTOFsignal()*1E-3;//in ns
281     Double_t tofTimeRaw=track->GetTOFsignalRaw()*1E-3;//in ns
282     Double_t tofToT=track->GetTOFsignalToT(); //in ns
283     if(!(tofTime>0))continue;
284     ntof++;
285     GetESDsData(1)->Fill(tofTime);
286     GetESDsData(2)->Fill(tofTimeRaw); 
287     GetESDsData(3)->Fill(tofToT);
288     //check how many tracks where ESD PID is ok 
289     UInt_t status=track->GetStatus();
290     if (((status&AliESDtrack::kESDpid)==0) || 
291         ((status&AliESDtrack::kTOFpid)==0)) continue;
292     ntofpid++;
293   }
294   
295   Int_t nentries=ntof;
296   if(nentries<=0){
297     GetESDsData(0)->Fill(-1.) ;
298   }else{
299     GetESDsData(0)->Fill(TMath::Log10(nentries)) ;
300   }
301
302   Float_t ratio = (Float_t)ntofpid/(Float_t)ntof*100.;
303   if(ntof>0)GetESDsData(4)->Fill(ratio) ;
304
305 }
306
307 //____________________________________________________________________________ 
308 void AliTOFQADataMakerRec::StartOfDetectorCycle()
309 {
310   //
311   //Detector specific actions at start of cycle
312   //to be implemented  
313 }
314
315 //____________________________________________________________________________ 
316 void AliTOFQADataMakerRec::EndOfDetectorCycle(AliQAv1::TASKINDEX_t task, TObjArray ** list)
317 {
318   //Detector specific actions at end of cycle
319   // do the QA checking
320
321   AliQAChecker::Instance()->Run(AliQAv1::kTOF, task, list) ;  
322 }
323 //____________________________________________________________________________
324 void AliTOFQADataMakerRec::GetMapIndeces(Int_t* in , Int_t* out)
325 {
326   //
327   //return appropriate indeces for the theta-phi map
328   //
329
330   Int_t npadX = AliTOFGeometry::NpadX();
331   Int_t npadZ = AliTOFGeometry::NpadZ();
332   Int_t nStripA = AliTOFGeometry::NStripA();
333   Int_t nStripB = AliTOFGeometry::NStripB();
334   Int_t nStripC = AliTOFGeometry::NStripC();
335
336   Int_t isector = in[0];
337   Int_t iplate = in[1];
338   Int_t istrip = in[2];
339   Int_t ipadX = in[3]; 
340   Int_t ipadZ = in[4]; 
341   
342   Int_t stripOffset = 0;
343   switch (iplate) {
344   case 0:
345     stripOffset = 0;
346       break;
347   case 1:
348     stripOffset = nStripC;
349     break;
350   case 2:
351     stripOffset = nStripC+nStripB;
352     break;
353   case 3:
354     stripOffset = nStripC+nStripB+nStripA;
355     break;
356   case 4:
357     stripOffset = nStripC+nStripB+nStripA+nStripB;
358     break;
359   default:
360     AliError(Form("Wrong plate number in TOF (%d) !",iplate));
361     break;
362   };
363   Int_t zindex=npadZ*(istrip+stripOffset)+(ipadZ+1);
364   Int_t phiindex=npadX*isector+ipadX+1;
365   out[0]=zindex;  
366   out[1]=phiindex;  
367   
368 }