]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSQADataMaker.cxx
TList replaced by TObjArray as QA data container. Introducing OCDB for the reference...
[u/mrichter/AliRoot.git] / ITS / AliITSQADataMaker.cxx
1 /**************************************************************************
2  * Copyright(c) 2007-2009, 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 //  Checks the quality assurance 
20 //  by comparing with reference data
21 //  contained in a DB
22 //  -------------------------------------------------------------
23 //  W. Ferrarese Nov 2007
24 //  INFN Torino
25
26 // --- ROOT system ---
27 #include <TH2D.h>
28 #include <TBranch.h>
29 #include <TTree.h>
30 #include <TGaxis.h>
31
32 // --- Standard library ---
33
34 // --- AliRoot header files ---
35 #include "AliITSQADataMaker.h"
36 #include "AliLog.h"
37 #include "AliQA.h"
38 #include "AliQAChecker.h"
39 #include "AliRawReader.h"
40 #include "AliITSRawStreamSDD.h"
41 #include "AliITSRecPoint.h"
42 #include "AliITSgeomTGeo.h"
43 #include "AliRawReader.h"
44
45
46 ClassImp(AliITSQADataMaker)
47
48 //____________________________________________________________________________ 
49 AliITSQADataMaker::AliITSQADataMaker() : 
50   AliQADataMaker(AliQA::GetDetName(AliQA::kITS), "SDD Quality Assurance Data Maker")
51
52   fkOnline = kFALSE;
53   fnSDDHistos = 0;
54   // ctor 
55 }
56
57 //____________________________________________________________________________ 
58 AliITSQADataMaker::AliITSQADataMaker(Int_t ldc, Bool_t kMode) :
59   AliQADataMaker(AliQA::GetDetName(AliQA::kITS), "SDD Quality Assurance Data Maker")
60 {
61   //ctor used to discriminate OnLine-Offline analysis
62   fkOnline = kMode;
63   fLDC = ldc; 
64   fnSDDHistos = 0;
65 }
66
67 //____________________________________________________________________________ 
68 AliITSQADataMaker::AliITSQADataMaker(const AliITSQADataMaker& qadm) :
69   AliQADataMaker()
70 {
71   //copy ctor 
72   SetName((const char*)qadm.GetName()) ; 
73   SetTitle((const char*)qadm.GetTitle()); 
74 }
75
76 //__________________________________________________________________
77 AliITSQADataMaker& AliITSQADataMaker::operator = (const AliITSQADataMaker& qac )
78 {
79   // Equal operator.
80   this->~AliITSQADataMaker();
81   new(this) AliITSQADataMaker(qac);
82   return *this;
83 }
84
85 //____________________________________________________________________________ 
86 void AliITSQADataMaker::StartOfDetectorCycle() const
87 {
88   //Detector specific actions at start of cycle
89   AliDebug(1,"AliITSQADM::Start of ITS Cycle\n");
90 }
91
92 //____________________________________________________________________________ 
93 void AliITSQADataMaker::EndOfDetectorCycle(AliQA::TASKINDEX task, TObjArray *list)
94 {
95   // launch the QA checking
96   AliDebug(1,"AliITSDM instantiates checker with Run(AliQA::kITS, task, list)\n"); 
97   
98   AliQAChecker::Instance()->Run( AliQA::kITS , task, list);
99 }
100
101 //____________________________________________________________________________ 
102 void AliITSQADataMaker::EndOfDetectorCycle(const char * fgDataName)
103 {
104   //eventually used for different  AliQAChecker::Instance()->Run
105 }
106
107 //____________________________________________________________________________ 
108 void AliITSQADataMaker::InitRaws()
109 {  
110   // create SDD histo of raw
111   
112   Int_t lay, lad, det;
113   
114   if(fkOnline) {
115     AliInfo("Book Online Histograms\n");
116   }
117   else {
118     AliInfo("Book Offline Histograms\n ");
119   }
120
121   TH1F *h0 = new TH1F("ModPattern","Modules pattern",fgknSDDmodules,-0.5,259.5); 
122   Add2RawsList(h0,0);
123   fnSDDHistos++;
124   TH1F *h1 = new TH1F("ModPatternL3","Modules pattern L3",14,0.5,14.5);  
125   Add2RawsList(h1,1);
126   fnSDDHistos++;
127   TH1F *h2 = new TH1F("ModPatternL4","Modules pattern L4",22,0.5,22.5);  
128   Add2RawsList(h2,2);
129   fnSDDHistos++;
130
131   Char_t *hname0[fgkLADDonLAY3] ; 
132   TH1D *h3[fgkLADDonLAY3] ; 
133   for(Int_t i=1; i<=fgkLADDonLAY3; i++) {
134     hname0[i-1] = new Char_t[20];
135     sprintf(hname0[i-1],"ModPattern_L3_%d",i);
136     h3[i-1] = new TH1D(hname0[i-1],hname0[i-1],6,0.5,6.5);
137     Add2RawsList(h3[i-1],i-1+3);
138     fnSDDHistos++;
139   }
140
141   Char_t *hname1[fgkLADDonLAY4] ;
142   TH1D *h4[fgkLADDonLAY4] ; 
143   for(Int_t i=1; i<=fgkLADDonLAY4; i++) {
144     hname1[i-1] = new Char_t[20];
145     sprintf(hname1[i-1],"ModPattern_L4_%d",i);
146     h4[i-1] = new TH1D(hname1[i-1],hname1[i-1],8,0.5,8.5);
147     Add2RawsList(h4[i-1],i-1+17);  
148     fnSDDHistos++;
149   }
150
151   if(fkOnline) {
152         Int_t indexlast = 0;
153     Char_t *hname2[fgknSDDmodules*2] ;
154     TH1D *h5[fgknSDDmodules*2] ; 
155     Int_t index1 = 0;
156     for(Int_t moduleSDD=0; moduleSDD<fgknSDDmodules; moduleSDD++){
157           if((moduleSDD >= 0 && moduleSDD < 36) || (moduleSDD >= 84 && moduleSDD < 180)) {
158                 for(Int_t iside=0; iside<fgknSide; iside++){
159                         //Int_t index1 = moduleSDD * 2 + iside;
160                         hname2[index1] = new Char_t[50];
161                         AliITSgeomTGeo::GetModuleId(moduleSDD+fgkmodoffset, lay, lad, det);
162                         sprintf(hname2[index1],"ProjYMap_L%d_%d_%d_%d",lay,lad,det,iside);
163
164                         h5[index1] = new TH1D(hname2[index1],hname2[index1],256,-0.5,255.5);
165                         Add2RawsList(h5[index1],index1+39);
166                         fnSDDHistos++;
167                         index1++;
168                         indexlast = index1+39;
169                 }
170           }
171     }
172     
173     Char_t *hname3[fgknSDDmodules*8] ;
174     TH1D *h6[fgknSDDmodules*8] ; 
175         Int_t indextot = 0;
176         Int_t indexlast1 = 0;
177         for(Int_t htype=0; htype<4; htype++){
178       for(Int_t moduleSDD=0; moduleSDD<fgknSDDmodules; moduleSDD++){
179                 if((moduleSDD >= 0 && moduleSDD < 36) || (moduleSDD >= 84 && moduleSDD < 180)) {
180                   for(Int_t iside=0; iside<fgknSide; iside++){
181                         //Int_t index1 = moduleSDD*2 + iside;
182                         hname3[indextot] = new Char_t[50]; 
183                         AliITSgeomTGeo::GetModuleId(moduleSDD+fgkmodoffset, lay, lad, det);
184                         if(htype == 0) sprintf(hname3[indextot],"CountsVSAnode_L%d_%d_%d_%d",lay,lad,det,iside);
185                         if(htype == 1) sprintf(hname3[indextot],"ChargeVSAnode_L%d_%d_%d_%d",lay,lad,det,iside);
186                         if(htype == 2) sprintf(hname3[indextot],"CountsVSTbin_L%d_%d_%d_%d",lay,lad,det,iside);
187                         if(htype == 3) sprintf(hname3[indextot],"ChargeVSTbin_L%d_%d_%d_%d",lay,lad,det,iside);
188                         h6[indextot] = new TH1D(hname3[indextot],hname3[indextot],256,-0.5,255.5);
189                         Add2RawsList(h6[indextot],indexlast + indextot);
190                         fnSDDHistos++;
191                         indextot++;
192                         indexlast1 = indexlast + indextot;
193                   }
194                 }
195       }
196     }
197     
198         Int_t indexlast2 = 0;
199     Char_t *hname4[fgknSDDmodules*2];
200     TH2D *h7[fgknSDDmodules*2] ;
201         index1 = 0;
202     for(Int_t moduleSDD=0; moduleSDD<fgknSDDmodules; moduleSDD++){
203                 if((moduleSDD >= 0 && moduleSDD < 36) || (moduleSDD >= 84 && moduleSDD < 180)) {
204                   for(Int_t iside=0; iside<fgknSide; iside++){
205                         //Int_t index1 = moduleSDD * 2 + iside;
206                         AliITSgeomTGeo::GetModuleId(moduleSDD+fgkmodoffset, lay, lad, det);
207                         hname4[index1] = new Char_t[50]; 
208                         sprintf(hname4[index1],"Anode_vs_Charge_L%d_%d_%d_%d",lay,lad,det,iside);
209                         h7[index1] = new TH2D(hname4[index1],hname4[index1],fgknSDDmodules*2,-0.5,-0.5+fgknSDDmodules*2,256,0.5,256.5);
210                         Add2RawsList(h7[index1],indexlast1 + index1);
211                         fnSDDHistos++;
212                         index1++;
213                         indexlast2 = indexlast1 + index1;
214                   }
215                 }
216         }
217
218     Char_t *hname[3][2 * fgknSDDmodules] ;
219     index1 = 0;
220     for(Int_t moduleSDD =0; moduleSDD<fgknSDDmodules; moduleSDD++){
221           if((moduleSDD >= 0 && moduleSDD < 36) || (moduleSDD >= 84 && moduleSDD < 180)) {
222                 for(Int_t iside=0;iside<fgknSide;iside++){
223                         //Int_t index1 = moduleSDD * 2 + iside ;
224                         for(Int_t i=0; i<3; i++) hname[i][index1]= new Char_t[50];
225                         AliITSgeomTGeo::GetModuleId(moduleSDD+fgkmodoffset, lay, lad, det);
226                         sprintf(hname[0][index1],"chargeMap_L%d_%d_%d_%d",lay,lad,det,iside);
227                         sprintf(hname[1][index1],"TotalCharge_L%d_%d_%d_%d",lay,lad,det,iside);
228                         sprintf(hname[2][index1],"hmonoDMap_L%d_%d_%d_%d",lay,lad,det,iside);
229                         fModuleChargeMap[index1] = new TH2D(hname[0][index1],hname[1][index1],256,-0.5,255.5,256,-0.5,255.5);
230                         Add2RawsList(fModuleChargeMap[index1],indexlast2 + index1);
231                         fnSDDHistos++;
232                         fmonoD[index1] = new TH1D(hname[2][index1],hname[2][index1],256,-0.5,255.5);
233                         index1++;
234                 }
235           }
236         }
237   }
238   
239   AliDebug(1,Form("%d SDD histograms booked\n",fnSDDHistos));
240 }
241
242 //____________________________________________________________________________
243 void AliITSQADataMaker::MakeRaws(AliRawReader* rawReader)
244
245   //Fills Raw QA list of histos
246     Int_t index=0;
247     if(fkOnline) {
248         for(Int_t moduleSDD =0; moduleSDD<fgknSDDmodules; moduleSDD++){
249           if((moduleSDD >= 0 && moduleSDD < 36) || (moduleSDD >= 84 && moduleSDD < 180)) {
250                 for(Int_t iside=0;iside<fgknSide;iside++) {
251                         if(fnSDDHistos > 39+12 * 132 + index) GetRawsData(39+12 * 132 + index)->Reset();
252                         index++;
253                 }
254           }             
255         }
256     }
257   AliDebug(1,"entering MakeRaws\n");
258   rawReader->RequireHeader(kFALSE);               
259   rawReader->SelectEvents(7);                    
260   rawReader->SelectEquipment(17,fgkeqOffset+1,fgkeqOffset + fgkDDLidRange); 
261   rawReader->Reset();                         
262   AliITSRawStreamSDD s(rawReader); 
263   Int_t lay, lad, det; 
264
265   Int_t cnt = 0;
266   while(s.Next()) {
267     Int_t iddl = rawReader->GetDDLID() - fgkDDLIDshift;
268     Int_t isddmod = s.GetModuleNumber(iddl,s.GetCarlosId());
269     if(s.IsCompletedModule()) {
270       AliDebug(1,Form("IsCompletedModule == KTRUE\n"));
271       continue;
272     } 
273     Int_t coord1 = s.GetCoord1();
274     Int_t coord2 = s.GetCoord2();
275     Int_t signal = s.GetSignal();
276     Int_t moduleSDD = isddmod - fgkmodoffset;
277     if(moduleSDD < 0 || moduleSDD>fgknSDDmodules+fgkmodoffset) {
278       AliDebug(1,Form( "Module SDD = %d, resetting it to 1 \n",moduleSDD));
279       moduleSDD = 1;
280     }
281     GetRawsData(0)->Fill(moduleSDD); 
282     
283     AliITSgeomTGeo::GetModuleId(isddmod, lay, lad, det);
284     //printf("modnumb %d, lay %d, lad %d, det %d \n",isddmod, lay, lad, det);
285     Int_t ioffset = 3;
286     Int_t iorder = 1;
287     if(lay==4) { 
288       ioffset += 14;
289       iorder = 2;   
290     } 
291     GetRawsData(iorder)->Fill(lad);
292     GetRawsData(ioffset+lad-1)->Fill(det); //-1 because ladder# starts from 1    
293     
294     Short_t iside = s.GetChannel();
295         Int_t activeModule = moduleSDD;
296         if(moduleSDD > 35) activeModule -= 48;
297     Int_t index1 = activeModule * 2 + iside;
298     
299     if(index1<0){
300       AliDebug(1,Form("Wrong index number %d - patched to 0\n",index1));
301       index1 = 0;
302     }
303     
304     if(fkOnline) {
305       if(fnSDDHistos > 39+12 * 132 + index1) {
306         GetRawsData(39+ 2 * 132 + index1)->Fill(coord1); 
307         GetRawsData(39+ 4 * 132 + index1)->Fill(coord1,signal); 
308         GetRawsData(39+ 6 * 132 + index1)->Fill(coord2);        
309         GetRawsData(39+ 8 * 132 + index1)->Fill(coord2,signal); 
310         GetRawsData(39+10 * 132 + index1)->Fill(signal,coord1);
311         ((TH2D *)(GetRawsData(39+12 * 132 + index1)))->Fill(coord2, coord1, signal);
312       }
313     }
314     cnt++;
315     if(!(cnt%10000)) AliDebug(1,Form(" %d raw digits read",cnt));
316   }
317   AliDebug(1,Form("Event completed, %d raw digits read",cnt));
318   
319   if(fkOnline) {
320     Int_t nBins = 256;
321     for(Int_t moduleSDD=0; moduleSDD<fgknSDDmodules; moduleSDD++){
322                 if((moduleSDD >= 0 && moduleSDD < 36) || (moduleSDD >= 84 && moduleSDD < 180)) {
323                   for(Int_t iside=0; iside<fgknSide; iside++){
324                         Int_t activeModule = moduleSDD;
325                         if(moduleSDD > 35) activeModule -= 48;
326                         Int_t index1 = activeModule * 2 + iside;
327                         if(fnSDDHistos > 39 + 2 * 132 + index1) {
328                           fmonoD[index1] = ((TH2D *) (GetRawsData(39+12 * 132 + index1)))->ProjectionY();
329                           for(Int_t bin=0; bin<nBins; bin++) GetRawsData(index1+39)->Fill(bin,fmonoD[index1]->GetBinContent(bin+1) );
330                         }  
331                   }
332                 }
333     }
334     for(Int_t i=0; i<fnSDDHistos; i++){
335       Int_t entries = static_cast<Int_t>(GetRawsData(i)->GetEntries());
336       if(entries != 0)
337         AliDebug(1,Form("histo %d, name %s , entries %d ",i,GetRawsData(i)->GetName(),entries));
338     }
339     rawReader->RequireHeader(kTRUE); 
340   }
341 }
342
343
344
345 //____________________________________________________________________________ 
346 void AliITSQADataMaker::InitRecPoints()
347 {
348   // create SDD histo of RecPoints
349   
350   TH1F * h0 = new TH1F("Lay3TotCh","Layer 3 total charge",1000,-0.5, 499.5);
351   Add2RecPointsList(h0, 0);
352  
353   TH1F * h1 = new TH1F("Lay4TotCh","Layer 4 total charge",1000,-0.5, 499.5);
354   Add2RecPointsList(h1, 1);
355
356     
357   Char_t *hisnam[3];
358   TH1F *h2[3]; 
359   for(Int_t i=1; i<=3; i++){
360     hisnam[i] = new Char_t[50];
361     sprintf(hisnam[i],"Charge_L3_Strip%d",i);
362     h2[i] = new TH1F(hisnam[i],hisnam[i],1000,-0.5, 499.5);
363     Add2RecPointsList(h2[i],i+1);
364   }
365   
366   Char_t *hisnam2[4] ;
367   TH1F *h3[4]; 
368   for(Int_t i=1; i<=4; i++){
369     hisnam2[i] = new Char_t[50];
370     sprintf(hisnam2[i],"Charge_L4_Strip%d",i);
371     h3[i] = new TH1F(hisnam2[i],hisnam2[i],1000,-0.5, 499.5);
372     Add2RecPointsList(h3[i],i+4);
373   }
374   
375 }
376
377
378 //____________________________________________________________________________ 
379 void AliITSQADataMaker::MakeRecPoints(TTree * clustersTree)
380 {
381   // makes data from RecPoints
382   /*  
383   TBranch *branchRecP = clustersTree->GetBranch("ITSRecPoints");
384   if (!branchRecP) { 
385     AliError("can't get the branch with the ITS clusters !");
386     return;
387   }
388   TObjArray * recpoints = new TObjArray(100) ;
389   branchRecP->SetAddress(&recpoints);
390   branchRecP->GetEntry(0);
391   
392   TIter next(recpoints);
393   AliITSRecPoint * rp;
394   while ( rp = dynamic_cast<AliITSRecPoint *>(next())  ) {
395     if(rp->GetLayer() ==3) GetRecPointsData(0)->Fill( rp->GetQ()) ;
396     else if(rp->GetLayer() ==4) GetRecPointsData(1)->Fill( rp->GetQ()) ;
397   }
398   recpoints->Delete();
399   delete recpoints;
400   */
401 }
402
403