1 /**************************************************************************
2 * Copyright(c) 2007-2009, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 // *************************************************************
19 // Checks the quality assurance
20 // by comparing with reference data
22 // -------------------------------------------------------------
23 // W. Ferrarese Gen 2008
26 // --- ROOT system ---
33 // --- Standard library ---
35 // --- AliRoot header files ---
36 #include "AliITSQADataMakerRec.h"
39 #include "AliQAChecker.h"
40 #include "AliRawReader.h"
41 #include "AliITSRawStreamSDD.h"
42 #include "AliITSRecPoint.h"
43 #include "AliITSgeomTGeo.h"
44 #include "AliRawReader.h"
46 #include "AliCDBManager.h"
47 #include "AliCDBStorage.h"
48 #include "AliCDBEntry.h"
51 ClassImp(AliITSQADataMakerRec)
53 //____________________________________________________________________________
54 AliITSQADataMakerRec::AliITSQADataMakerRec() :
55 AliQADataMakerRec(AliQA::GetDetName(AliQA::kITS), "SDD Quality Assurance Data Maker"),
61 // Default constructor
64 //____________________________________________________________________________
65 AliITSQADataMakerRec::AliITSQADataMakerRec(Int_t ldc, AliITSDDLModuleMapSDD *sddDDLModuleMap, Bool_t kMode) :
66 AliQADataMakerRec(AliQA::GetDetName(AliQA::kITS), "SDD Quality Assurance Data Maker"),
70 fSDDDDLModuleMap(sddDDLModuleMap)
72 //ctor no more useful since the SDDModuleMap is taken in the InitRaws
73 //ctor used to discriminate OnLine-Offline analysis
76 //____________________________________________________________________________
77 AliITSQADataMakerRec::AliITSQADataMakerRec(Int_t ldc, Bool_t kMode) :
78 AliQADataMakerRec(AliQA::GetDetName(AliQA::kITS), "SDD Quality Assurance Data Maker"),
84 //ctor used to discriminate OnLine-Offline analysis
87 //____________________________________________________________________________
88 AliITSQADataMakerRec::AliITSQADataMakerRec(const AliITSQADataMakerRec& qadm) :
89 AliQADataMakerRec(qadm),
90 fkOnline(qadm.fkOnline),
92 fnSDDHistos(qadm.fnSDDHistos),
96 SetName((const char*)qadm.GetName()) ;
97 SetTitle((const char*)qadm.GetTitle());
100 //__________________________________________________________________
101 AliITSQADataMakerRec& AliITSQADataMakerRec::operator = (const AliITSQADataMakerRec& qac )
104 this->~AliITSQADataMakerRec();
105 new(this) AliITSQADataMakerRec(qac);
109 //____________________________________________________________________________
110 void AliITSQADataMakerRec::StartOfDetectorCycle() const
112 //Detector specific actions at start of cycle
113 AliDebug(1,"AliITSQADM::Start of ITS Cycle\n");
116 //____________________________________________________________________________
117 void AliITSQADataMakerRec::EndOfDetectorCycle(AliQA::TASKINDEX /*task*/, TObjArray* /*list*/)
119 // launch the QA checking
120 AliDebug(1,"AliITSDM instantiates checker with Run(AliQA::kITS, task, list)\n");
122 //AliQAChecker::Instance()->Run( AliQA::kITS , task, list);
125 //____________________________________________________________________________
126 void AliITSQADataMakerRec::EndOfDetectorCycle(const char * /* fgDataName */)
128 //possibly used for different AliQAChecker::Instance()->Run
131 //____________________________________________________________________________
132 void AliITSQADataMakerRec::InitRaws()
134 // Initialization for RAW data
140 //____________________________________________________________________________
141 void AliITSQADataMakerRec::InitSPDRaws()
143 // Initialization for RAW data - SPD -
146 //____________________________________________________________________________
147 void AliITSQADataMakerRec::InitSDDRaws()
149 // create SDD histo of raw
151 AliCDBEntry *ddlMapSDD = AliCDBManager::Instance()->Get("ITS/Calib/DDLMapSDD");
153 AliFatal("Calibration object retrieval failed! ");
155 AliITSDDLModuleMapSDD *ddlsdd=(AliITSDDLModuleMapSDD*)ddlMapSDD->GetObject();
156 ddlMapSDD->SetOwner(kTRUE);
157 fSDDDDLModuleMap = ddlsdd;
162 AliInfo("Book Online Histograms\n");
165 AliInfo("Book Offline Histograms\n ");
168 TH1F *h0 = new TH1F("ModPattern","Modules pattern",fgknSDDmodules,-0.5,259.5);
171 TH1F *h1 = new TH1F("LadPatternL3","Ladder pattern L3",14,0.5,14.5);
174 TH1F *h2 = new TH1F("LadPatternL4","Ladder pattern L4",22,0.5,22.5);
178 Char_t *hname0[fgkLADDonLAY3] ;
179 TH1D *h3[fgkLADDonLAY3] ;
180 for(Int_t i=1; i<=fgkLADDonLAY3; i++) {
181 hname0[i-1] = new Char_t[20];
182 sprintf(hname0[i-1],"ModPattern_L3_%d",i);
183 h3[i-1] = new TH1D(hname0[i-1],hname0[i-1],6,0.5,6.5);
184 Add2RawsList(h3[i-1],i-1+3);
188 Char_t *hname1[fgkLADDonLAY4] ;
189 TH1D *h4[fgkLADDonLAY4] ;
190 for(Int_t i=1; i<=fgkLADDonLAY4; i++) {
191 hname1[i-1] = new Char_t[20];
192 sprintf(hname1[i-1],"ModPattern_L4_%d",i);
193 h4[i-1] = new TH1D(hname1[i-1],hname1[i-1],8,0.5,8.5);
194 Add2RawsList(h4[i-1],i-1+17);
200 Char_t *hname2[fgknSDDmodules*2] ;
201 TH1D *h5[fgknSDDmodules*2] ;
203 for(Int_t moduleSDD=0; moduleSDD<fgknSDDmodules; moduleSDD++){
204 if((moduleSDD >= 0 && moduleSDD < 36) || (moduleSDD >= 84 && moduleSDD < 180)) {
205 for(Int_t iside=0; iside<fgknSide; iside++){
206 //Int_t index1 = moduleSDD * 2 + iside;
207 hname2[index1] = new Char_t[50];
208 AliITSgeomTGeo::GetModuleId(moduleSDD, lay, lad, det);
209 sprintf(hname2[index1],"ProjYMap_L%d_%d_%d_%d",lay,lad,det,iside);
211 h5[index1] = new TH1D(hname2[index1],hname2[index1],256,-0.5,255.5);
212 Add2RawsList(h5[index1],index1+39);
215 indexlast = index1+39;
220 Char_t *hname3[fgknSDDmodules*8] ;
221 TH1D *h6[fgknSDDmodules*8] ;
223 Int_t indexlast1 = 0;
224 for(Int_t htype=0; htype<4; htype++){
225 for(Int_t moduleSDD=0; moduleSDD<fgknSDDmodules; moduleSDD++){
226 if((moduleSDD >= 0 && moduleSDD < 36) || (moduleSDD >= 84 && moduleSDD < 180)) {
227 for(Int_t iside=0; iside<fgknSide; iside++){
228 //Int_t index1 = moduleSDD*2 + iside;
229 hname3[indextot] = new Char_t[50];
230 AliITSgeomTGeo::GetModuleId(moduleSDD+fgkmodoffset, lay, lad, det);
231 if(htype == 0) sprintf(hname3[indextot],"CountsVSAnode_L%d_%d_%d_%d",lay,lad,det,iside);
232 if(htype == 1) sprintf(hname3[indextot],"ChargeVSAnode_L%d_%d_%d_%d",lay,lad,det,iside);
233 if(htype == 2) sprintf(hname3[indextot],"CountsVSTbin_L%d_%d_%d_%d",lay,lad,det,iside);
234 if(htype == 3) sprintf(hname3[indextot],"ChargeVSTbin_L%d_%d_%d_%d",lay,lad,det,iside);
235 h6[indextot] = new TH1D(hname3[indextot],hname3[indextot],256,-0.5,255.5);
236 Add2RawsList(h6[indextot],indexlast + indextot);
239 indexlast1 = indexlast + indextot;
245 Int_t indexlast2 = 0;
246 Char_t *hname4[fgknSDDmodules*2];
247 TH2D *h7[fgknSDDmodules*2] ;
249 for(Int_t moduleSDD=0; moduleSDD<fgknSDDmodules; moduleSDD++){
250 if((moduleSDD >= 0 && moduleSDD < 36) || (moduleSDD >= 84 && moduleSDD < 180)) {
251 for(Int_t iside=0; iside<fgknSide; iside++){
252 //Int_t index1 = moduleSDD * 2 + iside;
253 AliITSgeomTGeo::GetModuleId(moduleSDD+fgkmodoffset, lay, lad, det);
254 hname4[index1] = new Char_t[50];
255 sprintf(hname4[index1],"Anode_vs_Charge_L%d_%d_%d_%d",lay,lad,det,iside);
256 h7[index1] = new TH2D(hname4[index1],hname4[index1],fgknSDDmodules*2,-0.5,-0.5+fgknSDDmodules*2,256,0.5,256.5);
257 Add2RawsList(h7[index1],indexlast1 + index1);
260 indexlast2 = indexlast1 + index1;
265 Char_t *hname[3][2 * fgknSDDmodules] ;
267 for(Int_t moduleSDD =0; moduleSDD<fgknSDDmodules; moduleSDD++){
268 if((moduleSDD >= 0 && moduleSDD < 36) || (moduleSDD >= 84 && moduleSDD < 180)) {
269 for(Int_t iside=0;iside<fgknSide;iside++){
270 //Int_t index1 = moduleSDD * 2 + iside ;
271 for(Int_t i=0; i<3; i++) hname[i][index1]= new Char_t[50];
272 AliITSgeomTGeo::GetModuleId(moduleSDD+fgkmodoffset, lay, lad, det);
273 sprintf(hname[0][index1],"chargeMap_L%d_%d_%d_%d",lay,lad,det,iside);
274 sprintf(hname[1][index1],"TotalCharge_L%d_%d_%d_%d",lay,lad,det,iside);
275 sprintf(hname[2][index1],"hmonoDMap_L%d_%d_%d_%d",lay,lad,det,iside);
276 fModuleChargeMap[index1] = new TH2D(hname[0][index1],hname[1][index1],256,-0.5,255.5,256,-0.5,255.5);
277 Add2RawsList(fModuleChargeMap[index1],indexlast2 + index1);
279 fmonoD[index1] = new TH1D(hname[2][index1],hname[2][index1],256,-0.5,255.5);
287 AliDebug(1,Form("%d SDD histograms booked\n",fnSDDHistos));
290 //____________________________________________________________________________
291 void AliITSQADataMakerRec::InitSSDRaws()
293 // Initialization for RAW data - SSD -
296 //____________________________________________________________________________
297 void AliITSQADataMakerRec::MakeRaws(AliRawReader* rawReader)
300 MakeSPDRaws(rawReader);
301 MakeSDDRaws(rawReader);
302 MakeSSDRaws(rawReader);
305 //____________________________________________________________________________
306 void AliITSQADataMakerRec::MakeSPDRaws(AliRawReader* /* rawReader */)
308 // Fill QA for RAW - SPD -
311 //____________________________________________________________________________
312 void AliITSQADataMakerRec::MakeSDDRaws(AliRawReader* rawReader)
315 //Fills Raw QA list of histos
316 if(rawReader->GetType() != 7) return; // skips non physical triggers
317 AliDebug(1,"entering MakeRaws\n");
318 rawReader->SelectEquipment(17,fgkeqOffset,fgkeqOffset + fgkDDLidRange);
321 AliITSRawStreamSDD s(rawReader);
322 s.SetDDLModuleMap(fSDDDDLModuleMap);
327 for(Int_t moduleSDD =0; moduleSDD<fgknSDDmodules; moduleSDD++){
328 if((moduleSDD >= 0 && moduleSDD < 36) || (moduleSDD >= 84 && moduleSDD < 180)) {
329 for(Int_t iside=0;iside<fgknSide;iside++) {
330 if(fnSDDHistos > 39+12 * 132 + index) GetRawsData(39+12 *132 + index)->Reset();
338 Int_t iddl = rawReader->GetDDLID() - fgkDDLIDshift;
339 Int_t isddmod = s.GetModuleNumber(iddl,s.GetCarlosId());
341 AliDebug(1,Form("Found module with iddl: %d, s.GetCarlosId: %d \n",iddl,s.GetCarlosId() ));
343 if(s.IsCompletedModule()) {
344 AliDebug(1,Form("IsCompletedModule == KTRUE\n"));
347 Int_t coord1 = s.GetCoord1();
348 Int_t coord2 = s.GetCoord2();
349 Int_t signal = s.GetSignal();
350 Int_t moduleSDD = isddmod - fgkmodoffset;
351 if(moduleSDD < 0 || moduleSDD>fgknSDDmodules+fgkmodoffset) {
352 AliDebug(1,Form( "Module SDD = %d, resetting it to 1 \n",moduleSDD));
355 GetRawsData(0)->Fill(moduleSDD);
357 AliITSgeomTGeo::GetModuleId(isddmod, lay, lad, det);
358 //printf("modnumb %d, lay %d, lad %d, det %d \n",isddmod, lay, lad, det);
365 GetRawsData(iorder)->Fill(lad);
366 GetRawsData(ioffset+lad-1)->Fill(det); //-1 because ladder# starts from 1
368 Short_t iside = s.GetChannel();
370 Int_t activeModule = moduleSDD - fgkmodoffset ;
371 if(moduleSDD > 35) activeModule -= 48;
372 Int_t index1 = activeModule * 2 + iside;
375 AliDebug(1,Form("Wrong index number %d - patched to 0\n",index1));
380 if(fnSDDHistos > 39+12 * 132 + index1) {
381 GetRawsData(39+ 2 * 132 + index1)->Fill(coord1);
382 GetRawsData(39+ 4 * 132 + index1)->Fill(coord1,signal);
383 GetRawsData(39+ 6 * 132 + index1)->Fill(coord2);
384 GetRawsData(39+ 8 * 132 + index1)->Fill(coord2,signal);
385 GetRawsData(39+10 * 132 + index1)->Fill(signal,coord1);
386 ((TH2D *)(GetRawsData(39+12 * 132 + index1)))->Fill(coord2, coord1, signal);
390 if(!(cnt%10000)) AliDebug(1,Form(" %d raw digits read",cnt));
392 AliDebug(1,Form("Event completed, %d raw digits read",cnt));
396 for(Int_t moduleSDD=0; moduleSDD<fgknSDDmodules; moduleSDD++){
397 if((moduleSDD >= 0 && moduleSDD < 36) || (moduleSDD >= 84 && moduleSDD < 180)) {
398 for(Int_t iside=0; iside<fgknSide; iside++){
399 Int_t activeModule = moduleSDD - fgkmodoffset;
400 if(moduleSDD > 35) activeModule -= 48;
401 Int_t index1 = activeModule * 2 + iside;
402 if(fnSDDHistos > 39 + 2 * 132 + index1) {
403 fmonoD[index1] = ((TH2D *) (GetRawsData(39+12 * 132 + index1)))->ProjectionY();
404 for(Int_t bin=0; bin<nBins; bin++) GetRawsData(index1+39)->Fill(bin,fmonoD[index1]->GetBinContent(bin+1) );
409 for(Int_t i=0; i<fnSDDHistos; i++){
410 Int_t entries = static_cast<Int_t>(GetRawsData(i)->GetEntries());
412 AliDebug(1,Form("histo %d, name %s , entries %d ",i,GetRawsData(i)->GetName(),entries));
418 //____________________________________________________________________________
419 void AliITSQADataMakerRec::MakeSSDRaws(AliRawReader* /* rawReader */)
421 // Fill QA for RAW - SSD -
424 //____________________________________________________________________________
425 void AliITSQADataMakerRec::InitRecPoints()
427 // Initialization for RECPOINTS
433 //____________________________________________________________________________
434 void AliITSQADataMakerRec::InitSPDRecPoints()
436 // Initialization for RECPOINTS - SPD -
439 //____________________________________________________________________________
440 void AliITSQADataMakerRec::InitSDDRecPoints()
442 // create SDD histo of RecPoints
444 TH1F * h0 = new TH1F("Lay3TotCh","Layer 3 total charge",1000,-0.5, 499.5);
445 h0->GetXaxis()->SetTitle("ADC Counts");
446 Add2RecPointsList(h0, 0);
448 TH1F * h1 = new TH1F("Lay4TotCh","Layer 4 total charge",1000,-0.5, 499.5);
449 h1->GetXaxis()->SetTitle("ADC Counts");
450 Add2RecPointsList(h1, 1);
455 for(Int_t i=1; i<=3; i++){
456 hisnam[i] = new Char_t[50];
457 sprintf(hisnam[i],"Charge_L3_Strip%d",i);
458 h2[i] = new TH1F(hisnam[i],hisnam[i],1000,-0.5, 499.5);
459 Add2RecPointsList(h2[i],i+1);
464 for(Int_t i=1; i<=4; i++){
465 hisnam2[i] = new Char_t[50];
466 sprintf(hisnam2[i],"Charge_L4_Strip%d",i);
467 h3[i] = new TH1F(hisnam2[i],hisnam2[i],1000,-0.5, 499.5);
468 Add2RecPointsList(h3[i],i+4);
471 TH1F *h4 = new TH1F("ModPatternRP","Modules pattern RP",fgknSDDmodules,-0.5,259.5);
472 h4->GetXaxis()->SetTitle("Module #");
473 Add2RecPointsList(h4,9);
474 TH1F *h5 = new TH1F("ModPatternL3 RP","Ladder pattern L3 RP",14,0.5,14.5);
475 h5->GetXaxis()->SetTitle("Ladder #, Layer 3");
476 Add2RecPointsList(h5,10);
477 TH1F *h6 = new TH1F("ModPatternL4 RP","Ladder pattern L4 RP",22,0.5,22.5);
478 h6->GetXaxis()->SetTitle("Ladder #, Layer 4");
479 Add2RecPointsList(h6,11);
480 TH2F *h7 = new TH2F("Local Coord Distrib","Local Coord Distrib",110,-5.5,5.5,110,-5.5,5.5);
481 h7->GetXaxis()->SetTitle("X local coord, drift, cm");
482 h7->GetYaxis()->SetTitle("Z local coord, anode, cm");
483 Add2RecPointsList(h7,12);
484 TH2F *h8 = new TH2F("Global Coord Distrib","Global Coord Distrib",80,-40,40,80,-40,40);
485 h8->GetYaxis()->SetTitle("Y glob coord, cm");
486 h8->GetXaxis()->SetTitle("X glob coord, cm");
487 Add2RecPointsList(h8,13);
491 for(Int_t iLay=0; iLay<=1; iLay++){
492 name = new Char_t[50];
493 sprintf(name,"hr_Layer%d",iLay+3);
494 h9[iLay] = new TH1F(name,name,100,5.,35.);
495 h9[iLay]->GetXaxis()->SetTitle("r (cm)");
496 h9[iLay]->GetXaxis()->CenterTitle();
497 Add2RecPointsList(h9[iLay],iLay+14);
500 for(Int_t iLay=0; iLay<=1; iLay++){
501 name = new Char_t[50];
502 sprintf(name,"hphi_Layer%d",iLay+3);
503 h10[iLay] = new TH1F(name,name,100,-TMath::Pi(),TMath::Pi());
504 h10[iLay]->GetXaxis()->SetTitle("#varphi (rad)");
505 h10[iLay]->GetXaxis()->CenterTitle();
506 Add2RecPointsList(h10[iLay],iLay+16);
512 //____________________________________________________________________________
513 void AliITSQADataMakerRec::InitSSDRecPoints()
515 // Initialization for RECPOINTS - SSD -
518 //____________________________________________________________________________
519 void AliITSQADataMakerRec::MakeRecPoints(TTree * clustersTree)
521 // Fill QA for recpoints
522 MakeSPDRecPoints(clustersTree);
523 MakeSDDRecPoints(clustersTree);
524 MakeSSDRecPoints(clustersTree);
527 //____________________________________________________________________________
528 void AliITSQADataMakerRec::MakeSPDRecPoints(TTree * /* clustersTree */)
530 // Fill QA for recpoints - SPD -
533 //____________________________________________________________________________
534 void AliITSQADataMakerRec::MakeSDDRecPoints(TTree * clustersTree)
536 // makes data from RecPoints
538 TBranch *branchRecP = clustersTree->GetBranch("ITSRecPoints");
540 AliError("can't get the branch with the ITS clusters !");
543 TClonesArray * recpoints = new TClonesArray("AliITSRecPoint") ;
544 branchRecP->SetAddress(&recpoints);
546 Float_t cluglo[3]={0.,0.,0.};
547 for(Int_t module=240; module<500;module++){
548 branchRecP->GetEvent(module);
549 npoints += recpoints->GetEntries();
550 AliITSgeomTGeo::GetModuleId(module, lay, lad, det);
551 //printf("modnumb %d, lay %d, lad %d, det %d \n",module, lay, lad, det);
553 for(Int_t j=0;j<recpoints->GetEntries();j++){
554 AliITSRecPoint *recp = (AliITSRecPoint*)recpoints->At(j);
555 GetRecPointsData(9)->Fill(module);
556 recp->GetGlobalXYZ(cluglo);
557 Float_t rad=TMath::Sqrt(cluglo[0]*cluglo[0]+cluglo[1]*cluglo[1]);
558 Float_t phi=TMath::ATan2(cluglo[1],cluglo[0]);
559 if(recp->GetLayer() ==2) {
560 GetRecPointsData(0)->Fill( recp->GetQ()) ;
561 GetRecPointsData(10)->Fill(lad);
562 GetRecPointsData(14)->Fill(rad);
563 GetRecPointsData(16)->Fill(phi);
565 else if(recp->GetLayer() ==3) {
566 GetRecPointsData(1)->Fill( recp->GetQ()) ;
567 GetRecPointsData(11)->Fill(lad);
568 GetRecPointsData(15)->Fill(rad);
569 GetRecPointsData(17)->Fill(phi);
571 else AliWarning(Form("Wrong SDD Layer: %d",recp->GetLayer()));
572 GetRecPointsData(12)->Fill(recp->GetDetLocalX(),recp->GetDetLocalZ());
573 GetRecPointsData(13)->Fill(cluglo[0],cluglo[1]);
582 //____________________________________________________________________________
583 void AliITSQADataMakerRec::MakeSSDRecPoints(TTree * /*clustersTree*/)
585 // Fill QA for recpoints - SSD -