]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TOF/AliTOFQADataMakerSim.cxx
moving class
[u/mrichter/AliRoot.git] / TOF / AliTOFQADataMakerSim.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 #include <TTree.h>
30 #include <TMath.h>
31
32 #include "AliLog.h"
33
34 #include "AliTOFdigit.h"
35 #include "AliTOFSDigit.h"
36 #include "AliTOFhitT0.h"
37 #include "AliTOFQADataMakerSim.h"
38 #include "AliQAChecker.h"
39 #include "AliTOFGeometry.h"
40
41
42 ClassImp(AliTOFQADataMakerSim)
43            
44 //____________________________________________________________________________ 
45   AliTOFQADataMakerSim::AliTOFQADataMakerSim() : 
46   AliQADataMakerSim(AliQA::GetDetName(AliQA::kTOF), "TOF Quality Assurance Data Maker")
47 {
48   //
49   // ctor
50   //
51 }
52
53 //____________________________________________________________________________ 
54 AliTOFQADataMakerSim::AliTOFQADataMakerSim(const AliTOFQADataMakerSim& qadm) :
55   AliQADataMakerSim()
56 {
57   //
58   //copy ctor 
59   //
60   SetName((const char*)qadm.GetName()) ; 
61   SetTitle((const char*)qadm.GetTitle()); 
62 }
63
64 //__________________________________________________________________
65 AliTOFQADataMakerSim& AliTOFQADataMakerSim::operator = (const AliTOFQADataMakerSim& qadm )
66 {
67   //
68   // assignment operator.
69   //
70   this->~AliTOFQADataMakerSim();
71   new(this) AliTOFQADataMakerSim(qadm);
72   return *this;
73 }
74  
75 //____________________________________________________________________________ 
76 void AliTOFQADataMakerSim::InitHits()
77 {
78   //
79   // create Hits histograms in Hits subdir
80   //
81   TH1F * h0 = new TH1F("hTOFHits",    "Number of TOF Hits ",301, -1.02, 5.) ; 
82   h0->Sumw2() ;
83   Add2HitsList(h0, 0) ;
84
85   TH1F * h1  = new TH1F("hTOFHitsTime", "Hits Time Spectrum in TOF (ns)", 2000, 0., 200) ; 
86   h1->Sumw2() ;
87   Add2HitsList(h1, 1) ;
88
89   TH1F * h2  = new TH1F("hTOFHitsLength", "Length Spectrum in TOF (cm)", 500, 0., 500) ; 
90   h2->Sumw2() ;
91   Add2HitsList(h2, 2) ;
92
93   TH2F * h3  = new TH2F("hTOFHitsClusMap","Hits vs TOF eta-phi",183, -0.5, 182.5,865,-0.5,864.5) ; 
94   h3->Sumw2() ;
95   Add2HitsList(h3, 3) ;
96 }
97
98 //____________________________________________________________________________ 
99 void AliTOFQADataMakerSim::InitDigits()
100 {
101   //
102   // create Digits histograms in Digits subdir
103   //
104   TH1F * h0 = new TH1F("hTOFDigits",    "Number of TOF Digits ",301, -1.02, 5.) ;   h0->Sumw2() ;
105   Add2DigitsList(h0, 0) ;
106
107   TH1F * h1  = new TH1F("hTOFDigitsTime", "Digits Time Spectrum in TOF (ns)", 2000, 0., 200) ; 
108   h1->Sumw2() ;
109   Add2DigitsList(h1, 1) ;
110
111   TH1F * h2  = new TH1F("hTOFDigitsToT", "Digits ToT Spectrum in TOF (ns)", 500, 0., 50) ; 
112   h2->Sumw2() ;
113   Add2DigitsList(h2, 2) ;
114
115   TH2F * h3  = new TH2F("hTOFDigitsClusMap","Digits vs TOF eta-phi",183, -0.5, 182.5,865,-0.5,864.5) ; 
116   h3->Sumw2() ;
117   Add2DigitsList(h3, 3) ;
118
119 }
120
121 //____________________________________________________________________________ 
122 void AliTOFQADataMakerSim::InitSDigits()
123 {
124   //
125   // create SDigits histograms in SDigits subdir
126   //
127   TH1F * h0 = new TH1F("hTOFSDigits",    "Number of TOF SDigits ",301, -1.02, 5.) ;   h0->Sumw2() ;
128   Add2SDigitsList(h0, 0) ;
129
130   TH1F * h1  = new TH1F("hTOFSDigitsTime", "SDigits Time Spectrum in TOF (ns)", 2000, 0., 200) ; 
131   h1->Sumw2() ;
132   Add2SDigitsList(h1, 1) ;
133
134   TH2F * h2  = new TH2F("hTOFSDigitsClusMap","SDigits vs TOF eta-phi",183, -0.5, 182.5,865,-0.5,864.5) ; 
135   h2->Sumw2() ;
136   Add2SDigitsList(h2, 2) ;
137
138 }
139
140 //____________________________________________________________________________
141 void AliTOFQADataMakerSim::MakeHits(TClonesArray * hits)
142 {
143   //
144   //make QA data from Hits
145   //
146
147   Int_t in[5];
148   Int_t out[5];
149
150   Int_t nentries=hits->GetEntriesFast();
151   if(nentries<=0) {
152     GetHitsData(0)->Fill(-1.) ; 
153   } else{
154     GetHitsData(0)->Fill(TMath::Log10(nentries)) ; 
155   }
156   TIter next(hits) ; 
157   AliTOFhitT0 * hit ; 
158   while ( (hit = dynamic_cast<AliTOFhitT0 *>(next())) ) {
159
160     GetHitsData(1)->Fill( hit->GetTof()*1.E9) ;//in ns
161     GetHitsData(2)->Fill( hit->GetLen()) ;//in cm
162   
163     in[0] = hit->GetSector();
164     in[1] = hit->GetPlate();
165     in[2]= hit->GetStrip();
166     in[3]= hit->GetPadx();
167     in[4]= hit->GetPadz();
168     GetMapIndeces(in,out);
169     GetHitsData(3)->Fill( out[0],out[1]) ;//hit map
170   }
171
172 }
173
174
175 //____________________________________________________________________________
176 void AliTOFQADataMakerSim::MakeHits(TTree * hitTree)
177 {
178   //
179   // make QA data from Hit Tree
180   //
181   if(!hitTree){
182     AliError("can't get the tree with TOF hits !");
183     return;
184   }     
185
186   TBranch * branch = hitTree->GetBranch("TOF") ;
187
188   if (!branch ) {
189     AliError("TOF branch in Hit Tree not found") ; 
190     return;
191   }
192
193   static TClonesArray statichits("AliTOFhitT0", 1000);
194   statichits.Clear();
195   TClonesArray *hits = &statichits;
196   static TClonesArray staticdummy("AliTOFhitT0", 1000);
197   staticdummy.Clear();
198   TClonesArray *dummy = &staticdummy;
199   branch->SetAddress(&dummy);
200   Int_t index = 0 ;  
201   for (Int_t ientry = 0 ; ientry < branch->GetEntries() ; ientry++) {
202     branch->GetEntry(ientry) ; 
203     for (Int_t ihit = 0 ; ihit < dummy->GetEntries() ; ihit++) {
204       AliTOFhitT0 * hit = dynamic_cast<AliTOFhitT0 *> (dummy->At(ihit)) ; 
205       new((*hits)[index]) AliTOFhitT0(*hit) ; 
206       index++ ;
207     } 
208   }     
209
210   MakeHits(hits) ; 
211
212 }
213
214 //____________________________________________________________________________
215 void AliTOFQADataMakerSim::MakeDigits(TClonesArray * digits)
216 {
217   //
218   // makes data from Digits
219   //
220   Double_t tdc2ns=AliTOFGeometry::TdcBinWidth()*1E-3;
221   Double_t tot2ns=AliTOFGeometry::ToTBinWidth()*1E-3;
222   Int_t in[5];
223   Int_t out[5];
224
225   Int_t nentries=digits->GetEntriesFast();
226   if(nentries<=0){
227     GetDigitsData(0)->Fill(-1.) ; 
228   }else{
229     GetDigitsData(0)->Fill(TMath::Log10(nentries)) ; 
230   } 
231
232   TIter next(digits) ; 
233   AliTOFdigit * digit ; 
234   while ( (digit = dynamic_cast<AliTOFdigit *>(next())) ) {
235     
236     GetDigitsData(1)->Fill( digit->GetTdc()*tdc2ns) ;//in ns
237     GetDigitsData(2)->Fill( digit->GetToT()*tot2ns) ;//in ns
238
239     in[0] = digit->GetSector();
240     in[1] = digit->GetPlate();
241     in[2] = digit->GetStrip();
242     in[3] = digit->GetPadx();
243     in[4]= digit->GetPadz();
244     GetMapIndeces(in,out);
245     GetDigitsData(3)->Fill( out[0],out[1]) ;//digit map
246   }
247
248 }
249
250
251 //____________________________________________________________________________
252 void AliTOFQADataMakerSim::MakeDigits(TTree * digitTree)
253 {
254   //
255   // makes data from Digit Tree
256   //
257   TClonesArray * digits = new TClonesArray("AliTOFdigit", 1000) ; 
258   
259   TBranch * branch = digitTree->GetBranch("TOF") ;
260   if ( ! branch ) {
261     AliError("TOF branch in Digit Tree not found") ; 
262     return;
263   }
264   branch->SetAddress(&digits) ;
265   branch->GetEntry(0) ; 
266   MakeDigits(digits) ; 
267 }
268
269 //____________________________________________________________________________
270 void AliTOFQADataMakerSim::MakeSDigits(TClonesArray * sdigits)
271 {
272   //
273   // makes data from SDigits
274   //
275
276   Double_t tdc2ns=AliTOFGeometry::TdcBinWidth()*1E-3;
277   Int_t in[5];
278   Int_t out[5];
279
280   Int_t nentries=sdigits->GetEntriesFast();
281   if(nentries<=0){
282     GetSDigitsData(0)->Fill(-1.) ; 
283   }else{
284     GetSDigitsData(0)->Fill(TMath::Log10(nentries)) ; 
285   } 
286
287   TIter next(sdigits) ; 
288   AliTOFSDigit * sdigit ; 
289   while ( (sdigit = dynamic_cast<AliTOFSDigit *>(next())) ) {
290     
291     for(Int_t i=0;i<sdigit->GetNDigits();i++){
292       GetSDigitsData(1)->Fill( sdigit->GetTdc(i)*tdc2ns) ;//in ns
293     }
294
295     in[0] = sdigit->GetSector();
296     in[1] = sdigit->GetPlate();
297     in[2] = sdigit->GetStrip();
298     in[3] = sdigit->GetPadx();
299     in[4]= sdigit->GetPadz();
300     GetMapIndeces(in,out);
301     GetSDigitsData(2)->Fill( out[0],out[1]) ;//sdigit map
302   }
303 }
304
305 //____________________________________________________________________________
306 void AliTOFQADataMakerSim::MakeSDigits(TTree * sdigitTree)
307 {
308   //
309   // makes data from SDigit Tree
310   //
311   TClonesArray * sdigits = new TClonesArray("AliTOFSDigit", 1000) ; 
312   
313   TBranch * branch = sdigitTree->GetBranch("TOF") ;
314   if ( ! branch ) {
315     AliError("TOF branch in SDigit Tree not found") ; 
316     return;
317   }
318   branch->SetAddress(&sdigits) ;
319   branch->GetEntry(0) ; 
320   MakeSDigits(sdigits) ; 
321 }
322
323 //____________________________________________________________________________ 
324 void AliTOFQADataMakerSim::StartOfDetectorCycle()
325 {
326   //
327   //Detector specific actions at start of cycle
328   //to be implemented  
329 }
330
331 //____________________________________________________________________________ 
332 void AliTOFQADataMakerSim::EndOfDetectorCycle(AliQA::TASKINDEX_t task, TObjArray * list)
333 {
334   //Detector specific actions at end of cycle
335   // do the QA checking
336
337   AliQAChecker::Instance()->Run(AliQA::kTOF, task, list) ;  
338 }
339 //____________________________________________________________________________
340 void AliTOFQADataMakerSim::GetMapIndeces(Int_t* in , Int_t* out)
341 {
342   //
343   //return appropriate indeces for the theta-phi map
344   //
345
346   Int_t npadX = AliTOFGeometry::NpadX();
347   Int_t npadZ = AliTOFGeometry::NpadZ();
348   Int_t nStripA = AliTOFGeometry::NStripA();
349   Int_t nStripB = AliTOFGeometry::NStripB();
350   Int_t nStripC = AliTOFGeometry::NStripC();
351
352   Int_t isector = in[0];
353   Int_t iplate = in[1];
354   Int_t istrip = in[2];
355   Int_t ipadX = in[3]; 
356   Int_t ipadZ = in[4]; 
357   
358   Int_t stripOffset = 0;
359   switch (iplate) {
360   case 0:
361     stripOffset = 0;
362       break;
363   case 1:
364     stripOffset = nStripC;
365     break;
366   case 2:
367     stripOffset = nStripC+nStripB;
368     break;
369   case 3:
370     stripOffset = nStripC+nStripB+nStripA;
371     break;
372   case 4:
373     stripOffset = nStripC+nStripB+nStripA+nStripB;
374     break;
375   default:
376     AliError(Form("Wrong plate number in TOF (%d) !",iplate));
377     break;
378   };
379   Int_t zindex=npadZ*(istrip+stripOffset)+(ipadZ+1);
380   Int_t phiindex=npadX*isector+ipadX+1;
381   out[0]=zindex;  
382   out[1]=phiindex;  
383   
384 }