]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/AliTRDQADataMakerSim.cxx
New plots for trending injector efficiencies (Melinda)
[u/mrichter/AliRoot.git] / TRD / AliTRDQADataMakerSim.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 /* $Id$ */
17
18 ////////////////////////////////////////////////////////////////////////////
19 //                                                                        //
20 //  Produces the data needed to calculate the quality assurance.          //
21 //  All data must be mergeable objects.                                   //
22 //                                                                        //
23 //  Author:                                                               //
24 //    Sylwester Radomski (radomski@physi.uni-heidelberg.de)               //
25 //                                                                        //
26 ////////////////////////////////////////////////////////////////////////////
27
28 // --- ROOT system ---
29 #include <TClonesArray.h>
30 #include <TFile.h> 
31 #include <TH1D.h> 
32 #include <TH2D.h>
33 #include <TH3D.h>
34 #include <TProfile.h>
35 #include <TF1.h>
36 #include <TCanvas.h>
37 #include <TTree.h>
38
39 // --- AliRoot header files ---
40 //#include "AliESDEvent.h"
41 #include "AliLog.h"
42 #include "AliTRDdigit.h"
43 #include "AliTRDhit.h"
44 //#include "AliTRDcluster.h"
45 #include "AliTRDQADataMakerSim.h"
46 #include "AliTRDdigitsManager.h"
47 #include "AliTRDgeometry.h"
48 #include "AliTRDarrayADC.h"
49 #include "AliTRDarraySignal.h"
50 //#include "AliTRDrawStream.h"
51
52 #include "AliQAChecker.h"
53
54 ClassImp(AliTRDQADataMakerSim)
55
56 //____________________________________________________________________________ 
57   AliTRDQADataMakerSim::AliTRDQADataMakerSim() : 
58   AliQADataMakerSim(AliQAv1::GetDetName(AliQAv1::kTRD), "TRD Quality Assurance Data Maker"),
59   fTmpHits(NULL) 
60 {
61   //
62   // Default constructor
63 }
64
65 //____________________________________________________________________________ 
66 AliTRDQADataMakerSim::AliTRDQADataMakerSim(const AliTRDQADataMakerSim& qadm) :
67   AliQADataMakerSim(), 
68   fTmpHits(NULL)
69 {
70   //
71   // Copy constructor 
72   //
73
74   SetName((const char*)qadm.GetName()) ; 
75   SetTitle((const char*)qadm.GetTitle()); 
76
77 }
78
79 //__________________________________________________________________
80 AliTRDQADataMakerSim& AliTRDQADataMakerSim::operator=(const AliTRDQADataMakerSim& qadm)
81 {
82   //
83   // Equal operator.
84   //
85
86   this->~AliTRDQADataMakerSim();
87   new(this) AliTRDQADataMakerSim(qadm);
88   return *this;
89
90 }
91
92 //____________________________________________________________________________ 
93 AliTRDQADataMakerSim::~AliTRDQADataMakerSim()
94 {
95   if (fTmpHits) {
96     fTmpHits->Clear() ; 
97     delete fTmpHits ; 
98   }
99 }
100
101 //____________________________________________________________________________ 
102 void AliTRDQADataMakerSim::EndOfDetectorCycle(AliQAv1::TASKINDEX_t task, TObjArray ** list)
103 {
104   //
105   // Detector specific actions at end of cycle
106   //
107
108   //AliDebug(AliQAv1::GetQADebugLevel(), Form("EndOfCycle", "Fitting RecPoints %d", task));
109
110   // call the checker
111   AliQAChecker::Instance()->Run(AliQAv1::kTRD, task, list) ;    
112
113
114 }
115
116 //____________________________________________________________________________ 
117 void AliTRDQADataMakerSim::InitHits()
118 {
119   //
120   // Create Hits histograms in Hits subdir
121   //
122   const Bool_t expert   = kTRUE ; 
123   const Bool_t image    = kTRUE ; 
124   
125   const Int_t kNhist = 4;
126   TH1D *hist[kNhist];
127
128   hist[0] = new TH1D("qaTRD_hits_det", "TRD hits det;Detector Id of the hit;Counts", 540, -0.5, 539.5) ; 
129
130   hist[1] = new TH1D("qaTRD_hist_Qdrift", "TRD hits Qdrift;Charge from tracks;Counts", 100, 0, 100);
131   hist[2] = new TH1D("qaTRD_hist_Qamp", "TRD hits Qamp;Charge from TRD photon;Counts", 100, 0, 100);
132   hist[3] = new TH1D("qaTRD_hist_Qphoton", "TRD hits Qphoton;Charge from TRD photon;Counts", 100, 0, 100);
133
134   for(Int_t i=0; i<kNhist; i++) {
135     //hist[i]->Sumw2();
136     Add2HitsList(hist[i], i, !expert, image);
137   }
138
139 }
140
141 //____________________________________________________________________________ 
142 void AliTRDQADataMakerSim::InitDigits()
143 {
144   //
145   // Create Digits histograms in Digits subdir
146   //
147   const Bool_t expert   = kTRUE ; 
148   const Bool_t image    = kTRUE ; 
149   
150   const Int_t kNhist = 3;
151   TH1D *hist[kNhist];
152
153   hist[0] = new TH1D("qaTRD_digits_det", "TRD digits det;Detector Id of the digit;Counts", 540, -0.5, 539.5);
154   hist[1] = new TH1D("qaTRD_digits_time", "TRDdigits time;Time bin;Counts", 40, -0.5, 39.5);
155   hist[2] = new TH1D("qaTRD_digits_amp", "TRD digits amp;Amplitude;Counts", 100, -5.5, 94.5);
156
157   for(Int_t i=0; i<kNhist; i++) {
158     hist[i]->Sumw2();
159     Add2DigitsList(hist[i], i, !expert, image);
160   }
161
162 }
163
164 //____________________________________________________________________________ 
165 void AliTRDQADataMakerSim::InitSDigits()
166 {
167   //
168   // Create SDigits histograms in SDigits subdir
169   //
170   const Bool_t expert   = kTRUE ; 
171   const Bool_t image    = kTRUE ; 
172   
173   const Int_t kNhist = 3;
174   TH1D *hist[kNhist];
175
176   hist[0] = new TH1D("qaTRD_sdigits_det", "TRD sdigits det;Detector Id of the digit;Counts", 540, -0.5, 539.5);
177   hist[1] = new TH1D("qaTRD_sdigits_time", "TRD sdigits time;Time bin;Counts", 40, -0.5, 39.5);
178   hist[2] = new TH1D("qaTRD_sdigits_amp", "TRD sdigits amp;Amplitude;Counts", 100, 0, 1e7);
179
180   for(Int_t i=0; i<kNhist; i++) {
181     hist[i]->Sumw2();
182     Add2SDigitsList(hist[i], i, !expert, image);
183   }
184
185 }
186
187 //____________________________________________________________________________
188 void AliTRDQADataMakerSim::MakeHits()
189 {
190   //
191   // Make QA data from Hits
192   //
193   
194   TIter next(fHitsArray); 
195   AliTRDhit * hit; 
196
197   while ( (hit = dynamic_cast<AliTRDhit *>(next())) ) {
198     GetHitsData(0)->Fill(hit->GetDetector());
199     Double_t q = TMath::Abs(hit->GetCharge());
200
201     if (hit->FromDrift()) GetHitsData(1)->Fill(q);
202     if (hit->FromAmplification()) GetHitsData(2)->Fill(q);
203     if (hit->FromTRphoton()) GetHitsData(3)->Fill(q);
204   }
205
206 }
207
208 //____________________________________________________________________________
209 void AliTRDQADataMakerSim::MakeHits(TTree * hitTree)
210 {
211   //
212   // Make QA data from Hits
213   //
214
215   if (!CheckPointer(hitTree, "TRD hits tree")) return;
216
217   TBranch *branch = hitTree->GetBranch("TRD");
218   if (!CheckPointer(branch, "TRD hits branch")) return;
219   
220   Int_t nhits = (Int_t)(hitTree->GetTotBytes()/sizeof(AliTRDhit));
221   if (fHitsArray)
222     fHitsArray->Clear() ; 
223   else
224    fHitsArray = new TClonesArray("AliTRDhit", nhits+1000);
225   
226   //Int_t index = 0;
227   Int_t nEntries = (Int_t)branch->GetEntries();
228   for(Int_t i = 0; i < nEntries; i++) {
229     branch->GetEntry(i);
230     MakeHits();
231     fHitsArray->Clear() ; 
232   }
233 }
234
235 //____________________________________________________________________________
236 void AliTRDQADataMakerSim::MakeDigits()
237 {
238   //
239   // Makes data from Digits
240   //
241
242   if (!fDigitsArray)
243     return ; 
244   
245   TIter next(fDigitsArray) ; 
246   AliTRDdigit * digit ; 
247   
248   // Info("Make digits", "From the arrya");
249   
250   while ( (digit = dynamic_cast<AliTRDdigit *>(next())) ) {
251     if (digit->GetAmp() < 1) continue;
252     GetDigitsData(0)->Fill(digit->GetDetector());
253     GetDigitsData(1)->Fill(digit->GetTime());
254     GetDigitsData(2)->Fill(digit->GetAmp());
255   }
256
257 }
258
259 //____________________________________________________________________________
260 void AliTRDQADataMakerSim::MakeDigits(TTree * digits)
261 {
262   //
263   // Makes data from digits tree
264   //
265   // Info("Make digits", "From a tree");
266
267   AliTRDdigitsManager *digitsManager = new AliTRDdigitsManager();
268   digitsManager->CreateArrays();
269   digitsManager->ReadDigits(digits);
270
271   TH1D *histDet = (TH1D*)GetDigitsData(0);
272   TH1D *histTime = (TH1D*)GetDigitsData(1);
273   TH1D *histSignal = (TH1D*)GetDigitsData(2);
274
275   for (Int_t i = 0; i < AliTRDgeometry::kNdet; i++) 
276     {
277       AliTRDarrayADC *digitsIn = (AliTRDarrayADC *) digitsManager->GetDigits(i);      
278
279       // This is to take care of switched off super modules
280       if (digitsIn->GetNtime() == 0) continue;
281       
282       digitsIn->Expand();
283       
284       //AliTRDSignalIndex* indexes = digitsManager->GetIndexes(i);
285       //if (indexes->IsAllocated() == kFALSE) digitsManager->BuildIndexes(i);
286       
287       Int_t nRows = digitsIn->GetNrow();
288       Int_t nCols = digitsIn->GetNcol();
289       Int_t nTbins = digitsIn->GetNtime();
290       
291       for(Int_t row = 0; row < nRows; row++) 
292         for(Int_t col = 0; col < nCols; col++) 
293           for(Int_t time = 0; time < nTbins; time++) 
294             {   
295               Float_t signal = digitsIn->GetData(row,col,time);
296               if (signal < 1) continue;
297               histDet->Fill(i);
298               histTime->Fill(time);
299               histSignal->Fill(signal);
300             }
301       
302       //delete digitsIn;
303     }
304   delete digitsManager;
305 }
306
307 //____________________________________________________________________________
308 void AliTRDQADataMakerSim::MakeSDigits()
309 {
310   //
311   // Makes data from Digits
312   //
313
314   if (!fSDigitsArray)
315     return ; 
316
317   TIter next(fSDigitsArray) ; 
318   AliTRDdigit * digit ; 
319   while ( (digit = dynamic_cast<AliTRDdigit *>(next())) ) {
320     GetDigitsData(0)->Fill(digit->GetDetector());
321     GetDigitsData(1)->Fill(digit->GetTime());
322     GetDigitsData(2)->Fill(digit->GetAmp());
323   }
324
325 }
326
327 //____________________________________________________________________________
328 void AliTRDQADataMakerSim::MakeSDigits(TTree * digits)
329 {
330   //
331   // Makes data from SDigits
332   //
333   // Check id histograms already created for this Event Specie
334   if ( ! GetSDigitsData(0) )
335     InitSDigits() ;
336   
337   AliTRDdigitsManager *digitsManager = new AliTRDdigitsManager();
338   digitsManager->SetSDigits(kTRUE);
339   digitsManager->CreateArrays();
340   digitsManager->ReadDigits(digits);
341
342   TH1D *histDet = (TH1D*)GetSDigitsData(0);
343   TH1D *histTime = (TH1D*)GetSDigitsData(1);
344   TH1D *histSignal = (TH1D*)GetSDigitsData(2);
345
346   for (Int_t i = 0; i < AliTRDgeometry::kNdet; i++) 
347     {
348       AliTRDarraySignal *digitsIn = (AliTRDarraySignal *) digitsManager->GetSDigits(i);
349   
350     // This is to take care of switched off super modules
351       if (digitsIn->GetNtime() == 0) continue;
352       
353     digitsIn->Expand(); 
354       
355       //AliTRDSignalIndex* indexes = digitsManager->GetIndexes(i);
356       //if (indexes->IsAllocated() == kFALSE) digitsManager->BuildIndexes(i);
357       Int_t nRows = digitsIn->GetNrow();
358       Int_t nCols = digitsIn->GetNcol();
359       Int_t nTbins = digitsIn->GetNtime();
360
361       for(Int_t row = 0; row < nRows; row++) 
362         {
363           for(Int_t col = 0; col < nCols; col++) 
364             {
365               for(Int_t time = 0; time < nTbins; time++) 
366                 {           
367                   Float_t signal = digitsIn->GetData(row,col,time);
368                   if (signal < 1) continue;
369                   histDet->Fill(i);
370                   histTime->Fill(time);
371                   histSignal->Fill(signal);
372                 }
373             }
374         }
375       // delete digitsIn;
376     }
377   delete digitsManager;
378 }
379
380 //____________________________________________________________________________ 
381 void AliTRDQADataMakerSim::StartOfDetectorCycle()
382 {
383   //
384   // Detector specific actions at start of cycle
385   //
386
387 }
388
389 //__________________________________________________________________________
390 Int_t AliTRDQADataMakerSim::CheckPointer(TObject *obj, const char *name) 
391 {
392   //
393   // Checks initialization of pointers
394   //
395
396   if (!obj) AliWarning(Form("null pointer: %s", name));
397   return !!obj;
398
399 }