Print a warning and exit when there are more than 1000 cluster in a ITS layer
[u/mrichter/AliRoot.git] / ITS / AliITSQADataMakerRec.cxx
CommitLineData
04236e67 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 "AliITSQADataMakerRec.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
46ClassImp(AliITSQADataMakerRec)
47
48//____________________________________________________________________________
49AliITSQADataMakerRec::AliITSQADataMakerRec() :
50 AliQADataMakerRec(AliQA::GetDetName(AliQA::kITS), "SDD Quality Assurance Data Maker")
51{
52 fkOnline = kFALSE;
53 fnSDDHistos = 0;
54 // ctor
55}
56
57//____________________________________________________________________________
58AliITSQADataMakerRec::AliITSQADataMakerRec(Int_t ldc, Bool_t kMode) :
59 AliQADataMakerRec(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//____________________________________________________________________________
68AliITSQADataMakerRec::AliITSQADataMakerRec(const AliITSQADataMakerRec& qadm) :
69 AliQADataMakerRec()
70{
71 //copy ctor
72 SetName((const char*)qadm.GetName()) ;
73 SetTitle((const char*)qadm.GetTitle());
74}
75
76//__________________________________________________________________
77AliITSQADataMakerRec& AliITSQADataMakerRec::operator = (const AliITSQADataMakerRec& qac )
78{
79 // Equal operator.
80 this->~AliITSQADataMakerRec();
81 new(this) AliITSQADataMakerRec(qac);
82 return *this;
83}
84
85//____________________________________________________________________________
86void AliITSQADataMakerRec::StartOfDetectorCycle() const
87{
88 //Detector specific actions at start of cycle
89 AliDebug(1,"AliITSQADM::Start of ITS Cycle\n");
90}
91
92//____________________________________________________________________________
93void AliITSQADataMakerRec::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//____________________________________________________________________________
102void AliITSQADataMakerRec::EndOfDetectorCycle(const char * fgDataName)
103{
104 //eventually used for different AliQAChecker::Instance()->Run
105}
106
107//____________________________________________________________________________
108void AliITSQADataMakerRec::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//____________________________________________________________________________
243void AliITSQADataMakerRec::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->SelectEvents(7);
259 rawReader->SelectEquipment(17,fgkeqOffset+1,fgkeqOffset + fgkDDLidRange);
260 rawReader->Reset();
261 AliITSRawStreamSDD s(rawReader);
262 Int_t lay, lad, det;
263
264 Int_t cnt = 0;
265 while(s.Next()) {
266 Int_t iddl = rawReader->GetDDLID() - fgkDDLIDshift;
267 Int_t isddmod = s.GetModuleNumber(iddl,s.GetCarlosId());
268 if(s.IsCompletedModule()) {
269 AliDebug(1,Form("IsCompletedModule == KTRUE\n"));
270 continue;
271 }
272 Int_t coord1 = s.GetCoord1();
273 Int_t coord2 = s.GetCoord2();
274 Int_t signal = s.GetSignal();
275 Int_t moduleSDD = isddmod - fgkmodoffset;
276 if(moduleSDD < 0 || moduleSDD>fgknSDDmodules+fgkmodoffset) {
277 AliDebug(1,Form( "Module SDD = %d, resetting it to 1 \n",moduleSDD));
278 moduleSDD = 1;
279 }
280 GetRawsData(0)->Fill(moduleSDD);
281
282 AliITSgeomTGeo::GetModuleId(isddmod, lay, lad, det);
283 //printf("modnumb %d, lay %d, lad %d, det %d \n",isddmod, lay, lad, det);
284 Int_t ioffset = 3;
285 Int_t iorder = 1;
286 if(lay==4) {
287 ioffset += 14;
288 iorder = 2;
289 }
290 GetRawsData(iorder)->Fill(lad);
291 GetRawsData(ioffset+lad-1)->Fill(det); //-1 because ladder# starts from 1
292
293 Short_t iside = s.GetChannel();
294 Int_t activeModule = moduleSDD;
295 if(moduleSDD > 35) activeModule -= 48;
296 Int_t index1 = activeModule * 2 + iside;
297
298 if(index1<0){
299 AliDebug(1,Form("Wrong index number %d - patched to 0\n",index1));
300 index1 = 0;
301 }
302
303 if(fkOnline) {
304 if(fnSDDHistos > 39+12 * 132 + index1) {
305 GetRawsData(39+ 2 * 132 + index1)->Fill(coord1);
306 GetRawsData(39+ 4 * 132 + index1)->Fill(coord1,signal);
307 GetRawsData(39+ 6 * 132 + index1)->Fill(coord2);
308 GetRawsData(39+ 8 * 132 + index1)->Fill(coord2,signal);
309 GetRawsData(39+10 * 132 + index1)->Fill(signal,coord1);
310 ((TH2D *)(GetRawsData(39+12 * 132 + index1)))->Fill(coord2, coord1, signal);
311 }
312 }
313 cnt++;
314 if(!(cnt%10000)) AliDebug(1,Form(" %d raw digits read",cnt));
315 }
316 AliDebug(1,Form("Event completed, %d raw digits read",cnt));
317
318 if(fkOnline) {
319 Int_t nBins = 256;
320 for(Int_t moduleSDD=0; moduleSDD<fgknSDDmodules; moduleSDD++){
321 if((moduleSDD >= 0 && moduleSDD < 36) || (moduleSDD >= 84 && moduleSDD < 180)) {
322 for(Int_t iside=0; iside<fgknSide; iside++){
323 Int_t activeModule = moduleSDD;
324 if(moduleSDD > 35) activeModule -= 48;
325 Int_t index1 = activeModule * 2 + iside;
326 if(fnSDDHistos > 39 + 2 * 132 + index1) {
327 fmonoD[index1] = ((TH2D *) (GetRawsData(39+12 * 132 + index1)))->ProjectionY();
328 for(Int_t bin=0; bin<nBins; bin++) GetRawsData(index1+39)->Fill(bin,fmonoD[index1]->GetBinContent(bin+1) );
329 }
330 }
331 }
332 }
333 for(Int_t i=0; i<fnSDDHistos; i++){
334 Int_t entries = static_cast<Int_t>(GetRawsData(i)->GetEntries());
335 if(entries != 0)
336 AliDebug(1,Form("histo %d, name %s , entries %d ",i,GetRawsData(i)->GetName(),entries));
337 }
338 }
339}
340
341
342
343//____________________________________________________________________________
344void AliITSQADataMakerRec::InitRecPoints()
345{
346 // create SDD histo of RecPoints
347
348 TH1F * h0 = new TH1F("Lay3TotCh","Layer 3 total charge",1000,-0.5, 499.5);
349 Add2RecPointsList(h0, 0);
350
351 TH1F * h1 = new TH1F("Lay4TotCh","Layer 4 total charge",1000,-0.5, 499.5);
352 Add2RecPointsList(h1, 1);
353
354
355 Char_t *hisnam[3];
356 TH1F *h2[3];
357 for(Int_t i=1; i<=3; i++){
358 hisnam[i] = new Char_t[50];
359 sprintf(hisnam[i],"Charge_L3_Strip%d",i);
360 h2[i] = new TH1F(hisnam[i],hisnam[i],1000,-0.5, 499.5);
361 Add2RecPointsList(h2[i],i+1);
362 }
363
364 Char_t *hisnam2[4] ;
365 TH1F *h3[4];
366 for(Int_t i=1; i<=4; i++){
367 hisnam2[i] = new Char_t[50];
368 sprintf(hisnam2[i],"Charge_L4_Strip%d",i);
369 h3[i] = new TH1F(hisnam2[i],hisnam2[i],1000,-0.5, 499.5);
370 Add2RecPointsList(h3[i],i+4);
371 }
372
373}
374
375
376//____________________________________________________________________________
377void AliITSQADataMakerRec::MakeRecPoints(TTree * clustersTree)
378{
379 // makes data from RecPoints
380 /*
381 TBranch *branchRecP = clustersTree->GetBranch("ITSRecPoints");
382 if (!branchRecP) {
383 AliError("can't get the branch with the ITS clusters !");
384 return;
385 }
386 TObjArray * recpoints = new TObjArray(100) ;
387 branchRecP->SetAddress(&recpoints);
388 branchRecP->GetEntry(0);
389
390 TIter next(recpoints);
391 AliITSRecPoint * rp;
392 while ( rp = dynamic_cast<AliITSRecPoint *>(next()) ) {
393 if(rp->GetLayer() ==3) GetRecPointsData(0)->Fill( rp->GetQ()) ;
394 else if(rp->GetLayer() ==4) GetRecPointsData(1)->Fill( rp->GetQ()) ;
395 }
396 recpoints->Delete();
397 delete recpoints;
398 */
399}
400
401