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 + P. Cerello Feb 2008
24 // M.Siciliano Aug 2008 QA RecPoints
27 // --- ROOT system ---
29 #include <TProfile2D.h>
36 #include <TDirectory.h>
38 // --- Standard library ---
40 // --- AliRoot header files ---
41 #include "AliITSQASDDDataMakerRec.h"
44 #include "AliQAChecker.h"
45 #include "AliRawReader.h"
46 #include "AliITSRawStream.h"
47 #include "AliITSRawStreamSDD.h"
48 #include "AliITSRawStreamSDDCompressed.h"
49 #include "AliITSDetTypeRec.h"
50 #include "AliITSdigit.h"
51 #include "AliITSRecPoint.h"
52 #include "AliITSgeomTGeo.h"
53 #include "AliCDBManager.h"
54 #include "AliCDBStorage.h"
55 #include "AliCDBEntry.h"
56 #include "Riostream.h"
57 #include "AliITSdigitSDD.h"
59 #include "AliRunLoader.h"
60 #include "AliITSLoader.h"
61 #include "AliITSDetTypeRec.h"
65 ClassImp(AliITSQASDDDataMakerRec)
67 //____________________________________________________________________________
68 AliITSQASDDDataMakerRec::AliITSQASDDDataMakerRec(AliITSQADataMakerRec *aliITSQADataMakerRec, Bool_t kMode, Short_t ldc) :
70 fAliITSQADataMakerRec(aliITSQADataMakerRec),
75 fSDDhRecPointsTask(0),
78 fGenRecPointsOffset(0),
83 fGoodAnodesCurrent(0),
86 //ctor used to discriminate OnLine-Offline analysis
87 if(fLDC < 0 || fLDC > 6) {
88 AliError("Error: LDC number out of range; return\n");
90 fGenRawsOffset = new Int_t[AliRecoParam::kNSpecies];
91 fGenRecPointsOffset = new Int_t[AliRecoParam::kNSpecies];
92 fGenDigitsOffset = new Int_t[AliRecoParam::kNSpecies];
93 for(Int_t i=0; i<AliRecoParam::kNSpecies; i++) {
94 fGenRawsOffset[i] = 0;
95 fGenRecPointsOffset[i] = 0;
96 fGenDigitsOffset[i]=0;
100 //____________________________________________________________________________
101 AliITSQASDDDataMakerRec::AliITSQASDDDataMakerRec(const AliITSQASDDDataMakerRec& qadm) :
103 fAliITSQADataMakerRec(qadm.fAliITSQADataMakerRec),
104 fkOnline(qadm.fkOnline),
106 fSDDhRawsTask(qadm.fSDDhRawsTask),
107 fSDDhDigitsTask(qadm.fSDDhDigitsTask),
108 fSDDhRecPointsTask(qadm.fSDDhRecPointsTask),
109 fGenRawsOffset(qadm.fGenRawsOffset),
110 fGenDigitsOffset(qadm.fGenDigitsOffset),
111 fGenRecPointsOffset(qadm.fGenRecPointsOffset),
114 fGoodAnodes(qadm.fGoodAnodes),
115 fBadAnodes(qadm.fBadAnodes),
116 fGoodAnodesCurrent(qadm.fGoodAnodesCurrent),
117 fBadAnodesCurrent(qadm.fBadAnodesCurrent){
119 fAliITSQADataMakerRec->SetName((const char*)qadm.fAliITSQADataMakerRec->GetName()) ;
120 fAliITSQADataMakerRec->SetTitle((const char*)qadm.fAliITSQADataMakerRec->GetTitle());
124 //____________________________________________________________________________
125 AliITSQASDDDataMakerRec::~AliITSQASDDDataMakerRec(){
127 // if(fDDLModuleMap) delete fDDLModuleMap;
129 //__________________________________________________________________
130 AliITSQASDDDataMakerRec& AliITSQASDDDataMakerRec::operator = (const AliITSQASDDDataMakerRec& qac )
133 this->~AliITSQASDDDataMakerRec();
134 new(this) AliITSQASDDDataMakerRec(qac);
138 //____________________________________________________________________________
139 void AliITSQASDDDataMakerRec::StartOfDetectorCycle()
141 //Detector specific actions at start of cycle
142 AliDebug(AliQAv1::GetQADebugLevel(),"AliITSQADM::Start of SDD Cycle\n");
145 //____________________________________________________________________________
146 void AliITSQASDDDataMakerRec::EndOfDetectorCycle(AliQAv1::TASKINDEX_t /*task*/, TObjArray* /*list*/)
149 // launch the QA checking
151 AnalyseBNG(); // Analyse Baseline, Noise, Gain
152 AnalyseINJ(); // Analyse Injectors
155 AliDebug(AliQAv1::GetQADebugLevel(),"AliITSDM instantiates checker with Run(AliQAv1::kITS, task, list)\n");
158 //____________________________________________________________________________
159 Int_t AliITSQASDDDataMakerRec::InitRaws()
161 // Initialization for RAW data - SDD -
162 const Bool_t expert = kTRUE ;
163 const Bool_t saveCorr = kTRUE ;
164 const Bool_t image = kTRUE ;
166 AliCDBEntry *ddlMapSDD = AliCDBManager::Instance()->Get("ITS/Calib/DDLMapSDD");
167 Bool_t cacheStatus = AliCDBManager::Instance()->GetCacheFlag();
170 AliError("Calibration object retrieval failed! SDD will not be processed");
171 fDDLModuleMap = NULL;
174 fDDLModuleMap = (AliITSDDLModuleMapSDD*)ddlMapSDD->GetObject();
175 if(!cacheStatus)ddlMapSDD->SetObject(NULL);
176 ddlMapSDD->SetOwner(kTRUE);
188 AliInfo("Book Online Histograms for SDD\n");
192 AliInfo("Book Offline Histograms for SDD\n ");
194 TH1D *h0 = new TH1D("SDDModPattern","HW Modules pattern",fgknSDDmodules,239.5,499.5); //0
195 h0->GetXaxis()->SetTitle("Module Number");
196 h0->GetYaxis()->SetTitle("Counts");
197 rv = fAliITSQADataMakerRec->Add2RawsList((new TH1D(*h0)),0+fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image, !saveCorr);
201 //zPhi distribution using ladder and modules numbers
202 TH2D *hphil3 = new TH2D("SDDphizL3","SDD #varphiz Layer3 ",6,0.5,6.5,14,0.5,14.5);
203 hphil3->GetXaxis()->SetTitle("z[#Module L3 ]");
204 hphil3->GetYaxis()->SetTitle("#varphi[#Ladder L3]");
205 rv = fAliITSQADataMakerRec->Add2RawsList((new TH2D(*hphil3)),1+fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, image, saveCorr);
209 TH2D *hphil4 = new TH2D("SDDphizL4","SDD #varphiz Layer4 ",8,0.5,8.5,22,0.5,22.5);
210 hphil4->GetXaxis()->SetTitle("z[#Module L4]");
211 hphil4->GetYaxis()->SetTitle("#varphi[#Ladder L4]");
212 rv = fAliITSQADataMakerRec->Add2RawsList((new TH2D(*hphil4)),2+fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, image, saveCorr);
221 TH2D *hddl = new TH2D("SDDDDLPattern","SDD DDL Pattern ",24,-0.5,23.5,24,-0.5,23.5);
222 hddl->GetXaxis()->SetTitle("Channel");
223 hddl->GetYaxis()->SetTitle("#DDL");
224 rv = fAliITSQADataMakerRec->Add2RawsList((new TH2D(*hddl)),3+fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image, !saveCorr);
227 Int_t indexlast1 = 0;
232 indexlast1 = fSDDhRawsTask;
234 for(Int_t i=0; i<3; i++) hname[i]= new char[50];
235 for(Int_t moduleSDD =0; moduleSDD<fgknSDDmodules; moduleSDD++){
236 for(Int_t iside=0;iside<fgknSide;iside++){
237 AliITSgeomTGeo::GetModuleId(moduleSDD+fgkmodoffset, lay, lad, det);
238 sprintf(hname[0],"SDDchargeMapFSE_L%d_%d_%d_%d",lay,lad,det,iside);
239 sprintf(hname[1],"SDDChargeMapForSingleEvent_L%d_%d_%d_%d",lay,lad,det,iside);
240 // sprintf(hname[2],"SDDhmonoDMap_L%d_%d_%d_%d",lay,lad,det,iside);
241 TProfile2D *fModuleChargeMapFSE = new TProfile2D(hname[0],hname[1],256/fTimeBinSize,-0.5,255.5,256,-0.5,255.5);
242 fModuleChargeMapFSE->GetXaxis()->SetTitle("Time Bin");
243 fModuleChargeMapFSE->GetYaxis()->SetTitle("Anode");
244 rv = fAliITSQADataMakerRec->Add2RawsList((new TProfile2D(*fModuleChargeMapFSE)),indexlast1 + index1 + fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image, !saveCorr);
245 delete fModuleChargeMapFSE;
252 for(Int_t moduleSDD =0; moduleSDD<fgknSDDmodules; moduleSDD++){
253 for(Int_t iside=0;iside<fgknSide;iside++){
254 AliITSgeomTGeo::GetModuleId(moduleSDD+fgkmodoffset, lay, lad, det);
255 sprintf(hname[0],"SDDchargeMap_L%d_%d_%d_%d",lay,lad,det,iside);
256 sprintf(hname[1],"SDDChargeMap_L%d_%d_%d_%d",lay,lad,det,iside);
257 TProfile2D *fModuleChargeMap = new TProfile2D(hname[0],hname[1],256/fTimeBinSize,-0.5,255.5,256,-0.5,255.5);
258 fModuleChargeMap->GetXaxis()->SetTitle("Time Bin");
259 fModuleChargeMap->GetYaxis()->SetTitle("Anode");
260 rv = fAliITSQADataMakerRec->Add2RawsList((new TProfile2D(*fModuleChargeMap)),indexlast1 + index1 + fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image, !saveCorr);
261 delete fModuleChargeMap;
271 AliDebug(AliQAv1::GetQADebugLevel(),Form("%d SDD Raws histograms booked\n",fSDDhRawsTask));
276 //____________________________________________________________________________
277 Int_t AliITSQASDDDataMakerRec::MakeRaws(AliRawReader* rawReader)
279 // Fill QA for RAW - SDD -
281 // Check id histograms already created for this Event Specie
284 AliError("SDD DDL module map not available - skipping SDD QA");
287 if(rawReader->GetType() != 7) return rv; // skips non physical triggers
288 AliDebug(AliQAv1::GetQADebugLevel(),"entering MakeRaws\n");
290 AliITSRawStream *stream=AliITSRawStreamSDD::CreateRawStreamSDD(rawReader);
291 stream->SetDDLModuleMap(fDDLModuleMap);
297 for(Int_t moduleSDD =0; moduleSDD<fgknSDDmodules; moduleSDD++){
298 for(Int_t iside=0;iside<fgknSide;iside++) {
299 if(fSDDhRawsTask > 4 + index) fAliITSQADataMakerRec->GetRawsData(4 + index +fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Reset();
300 // 4 because the 2D histos for single events start after the fourth position
310 Int_t coord1, coord2, signal, moduleSDD, activeModule, index1;
312 while(stream->Next()) {
313 ildcID = rawReader->GetLDCId();
314 iddl = rawReader->GetDDLID() - fgkDDLIDshift;
316 isddmod = fDDLModuleMap->GetModuleNumber(iddl,stream->GetCarlosId());
318 AliDebug(AliQAv1::GetQADebugLevel(),Form("Found module with iddl: %d, stream->GetCarlosId: %d \n",iddl,stream->GetCarlosId()));
321 if(stream->IsCompletedModule()) {
322 AliDebug(AliQAv1::GetQADebugLevel(),Form("IsCompletedModule == KTRUE\n"));
325 if(stream->IsCompletedDDL()) {
326 AliDebug(AliQAv1::GetQADebugLevel(),Form("IsCompletedDDL == KTRUE\n"));
330 coord1 = stream->GetCoord1();
331 coord2 = stream->GetCoord2();
332 signal = stream->GetSignal();
334 moduleSDD = isddmod - fgkmodoffset;
336 if(isddmod <fgkmodoffset|| isddmod>fgknSDDmodules+fgkmodoffset-1) {
337 AliDebug(AliQAv1::GetQADebugLevel(),Form( "Module SDD = %d, resetting it to 1 \n",isddmod));
341 AliITSgeomTGeo::GetModuleId(isddmod, lay, lad, det);
342 fAliITSQADataMakerRec->GetRawsData( 0 + fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()] )->Fill(isddmod);
343 if(lay==3) fAliITSQADataMakerRec->GetRawsData(1+fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(det,lad);
345 fAliITSQADataMakerRec->GetRawsData(2+fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(det,lad);}
347 Short_t iside = stream->GetChannel();
354 fAliITSQADataMakerRec->GetRawsData(3+fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(2*(stream->GetCarlosId())+iside,iddl);
356 activeModule = moduleSDD;
357 index1 = activeModule * 2 + iside;
360 AliDebug(AliQAv1::GetQADebugLevel(),Form("Wrong index number %d - patched to 0\n",index1));
363 fAliITSQADataMakerRec->GetRawsData(3+fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(2*(stream->GetCarlosId())+iside,iddl);
364 if(fSDDhRawsTask > 4 + index1) {
365 ((TProfile2D *)(fAliITSQADataMakerRec->GetRawsData(4 + index1 +fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()])))->Fill(coord2, coord1, signal);
366 ((TProfile2D *)(fAliITSQADataMakerRec->GetRawsData(4 + index1 + 260*2 +fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()])))->Fill(coord2, coord1, signal);
370 if(!(cnt%10000)) AliDebug(AliQAv1::GetQADebugLevel(),Form(" %d raw digits read",cnt));
372 AliDebug(AliQAv1::GetQADebugLevel(),Form("Event completed, %d raw digits read",cnt));
377 // AnalyseBNG(); // Analyse Baseline, Noise, Gain
378 // AnalyseINJ(); // Analyse Injectors
385 //____________________________________________________________________________
386 Int_t AliITSQASDDDataMakerRec::InitDigits()
390 // Initialization for DIGIT data - SDD -
391 const Bool_t expert = kTRUE ;
392 const Bool_t image = kTRUE ;
394 // fGenDigitsOffset = (fAliITSQADataMakerRec->fDigitsQAList[AliRecoParam::kDefault])->GetEntries();
395 //fSDDhTask must be incremented by one unit every time a histogram is ADDED to the QA List
396 TH1F* h0=new TH1F("SDD DIGITS Module Pattern","SDD DIGITS Module Pattern",260,239.5,499.5); //hmod
397 h0->GetXaxis()->SetTitle("SDD Module Number");
398 h0->GetYaxis()->SetTitle("# DIGITS");
399 rv = fAliITSQADataMakerRec->Add2DigitsList(h0,fGenDigitsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, image);
401 // printf("Add %s \t the task offset is %i\n",fAliITSQADataMakerRec->GetDigitsData(fGenDigitsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->GetName() , fSDDhDigitsTask );
402 TH1F* h1=new TH1F("SDD Anode Distribution","DIGITS Anode Distribution",512,-0.5,511.5); //hanocc
403 h1->GetXaxis()->SetTitle("Anode Number");
404 h1->GetYaxis()->SetTitle("# DIGITS");
405 rv = fAliITSQADataMakerRec->Add2DigitsList(h1,1+fGenDigitsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, image);
407 //printf("Add %s \t the task offset is %i\n",fAliITSQADataMakerRec->GetDigitsData(1+fGenDigitsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->GetName() , fSDDhDigitsTask );
408 TH1F* h2=new TH1F("SDD Tbin Distribution","DIGITS Tbin Distribution",256,-0.5,255.5); //htbocc
409 h2->GetXaxis()->SetTitle("Tbin Number");
410 h2->GetYaxis()->SetTitle("# DIGITS");
411 rv = fAliITSQADataMakerRec->Add2DigitsList(h2,2+fGenDigitsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, image);
413 //printf("Add %s \t the task offset is %i\n",fAliITSQADataMakerRec->GetDigitsData(2+fGenDigitsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->GetName() , fSDDhDigitsTask );
414 TH1F* h3=new TH1F("SDD ADC Counts Distribution","DIGITS ADC Counts Distribution",200,0.,1024.); //hsig
415 h3->GetXaxis()->SetTitle("ADC Value");
416 h3->GetYaxis()->SetTitle("# DIGITS");
417 rv = fAliITSQADataMakerRec->Add2DigitsList(h3,3+fGenDigitsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, image);
419 //printf("Add %s \t the task offset is %i\n",fAliITSQADataMakerRec->GetDigitsData(3+fGenDigitsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->GetName() , fSDDhDigitsTask );
420 AliDebug(AliQAv1::GetQADebugLevel(),Form("%d SDD Digits histograms booked\n",fSDDhDigitsTask));
424 //____________________________________________________________________________
425 Int_t AliITSQASDDDataMakerRec::MakeDigits(TTree * digits)
428 // Fill QA for DIGIT - SDD -
429 //AliITS *fITS = (AliITS*)gAlice->GetModule("ITS");
430 //fITS->SetTreeAddress();
431 //TClonesArray *iITSdigits = fITS->DigitsAddress(1);
436 TBranch *branchD = digits->GetBranch("ITSDigitsSDD");
439 AliError("can't get the branch with the ITS SDD digits !");
442 // Check id histograms already created for this Event Specie
443 // if ( ! fAliITSQADataMakerRec->GetDigitsData(fGenDigitsOffset) )
444 // rv = InitDigits() ;
446 static TClonesArray statDigits("AliITSdigitSDD");
447 TClonesArray *iITSdigits = &statDigits;
448 branchD->SetAddress(&iITSdigits);
450 for(Int_t i=0; i<260; i++){
452 digits->GetEvent(nmod);
453 Int_t ndigits = iITSdigits->GetEntries();
454 fAliITSQADataMakerRec->GetDigitsData(fGenDigitsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(nmod,ndigits);
456 for (Int_t idig=0; idig<ndigits; idig++) {
457 AliITSdigit *dig=(AliITSdigit*)iITSdigits->UncheckedAt(idig);
458 Int_t iz=dig->GetCoord1(); // cell number z
459 Int_t ix=dig->GetCoord2(); // cell number x
460 Int_t sig=dig->GetSignal();
461 fAliITSQADataMakerRec->GetDigitsData(1+fGenDigitsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(iz);
462 fAliITSQADataMakerRec->GetDigitsData(2+fGenDigitsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(ix);
463 fAliITSQADataMakerRec->GetDigitsData(3+fGenDigitsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(sig);
469 //____________________________________________________________________________
470 Int_t AliITSQASDDDataMakerRec::InitRecPoints()
473 //AliInfo("Initialize SDD recpoints histos\n");
474 // Initialization for RECPOINTS - SDD -
475 const Bool_t expert = kTRUE ;
476 const Bool_t image = kTRUE ;
478 // fGenRecPointsOffset = (fAliITSQADataMakerRec->fRecPointsQAList[AliRecoParam::kDefault])->GetEntries();
492 //AliInfo(Form("fAliITSQADataMakerRec->GetEventSpecie() %d\n",fAliITSQADataMakerRec->GetEventSpecie()));
493 //AliInfo(Form("fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()] %d\n",fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]));
494 TH1F *h0 = new TH1F("SDDLay3TotCh","Layer 3 total charge",1000/nOnline,-0.5, 499.5); //position number 0
495 h0->GetXaxis()->SetTitle("ADC value");
496 h0->GetYaxis()->SetTitle("Entries");
497 rv = fAliITSQADataMakerRec->Add2RecPointsList((new TH1F(*h0)), 0 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, image);
499 fSDDhRecPointsTask++;
501 TH1F *h1 = new TH1F("SDDLay4TotCh","Layer 4 total charge",1000/nOnline,-0.5, 499.5);//position number 1
502 h1->GetXaxis()->SetTitle("ADC value");
503 h1->GetYaxis()->SetTitle("Entries");
504 rv = fAliITSQADataMakerRec->Add2RecPointsList((new TH1F(*h1)), 1 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, image);
506 fSDDhRecPointsTask++;
509 TH2F *h2 = new TH2F("SDDGlobalCoordDistribYX","YX Global Coord Distrib",5600/nOnline2,-28,28,5600/nOnline2,-28,28);//position number 2
510 h2->GetYaxis()->SetTitle("Y[cm]");
511 h2->GetXaxis()->SetTitle("X[cm]");
512 rv = fAliITSQADataMakerRec->Add2RecPointsList((new TH2F(*h2)),2+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, !image);
514 fSDDhRecPointsTask++;
516 TH2F *h3 = new TH2F("SDDGlobalCoordDistribRZ","RZ Global Coord Distrib",6400/nOnline3,-32,32,1400/nOnline4,12,26);//position number 3
517 h3->GetYaxis()->SetTitle("R[cm]");
518 h3->GetXaxis()->SetTitle("Z[cm]");
519 rv = fAliITSQADataMakerRec->Add2RecPointsList((new TH2F(*h3)),3+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, !image);
521 fSDDhRecPointsTask++;
523 TH2F *h4 = new TH2F("SDDGlobalCoordDistribL3PHIZ","#varphi Z Global Coord Distrib L3",6400/nOnline3,-32,32,360/nOnline,-TMath::Pi(),TMath::Pi());//position number 4
524 h4->GetYaxis()->SetTitle("#phi[rad]");
525 h4->GetXaxis()->SetTitle("Z[cm]");
526 rv = fAliITSQADataMakerRec->Add2RecPointsList((new TH2F(*h4)),4+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, image);
528 fSDDhRecPointsTask++;
530 TH2F *h5 = new TH2F("SDDGlobalCoordDistribL4PHIZ","#varphi Z Global Coord Distrib L4",6400/nOnline3,-32,32,360/nOnline,-TMath::Pi(),TMath::Pi());//position number 5
531 h5->GetYaxis()->SetTitle("#phi[rad]");
532 h5->GetXaxis()->SetTitle("Z[cm]");
533 rv = fAliITSQADataMakerRec->Add2RecPointsList((new TH2F(*h5)),5+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, image);
535 fSDDhRecPointsTask++;
537 TH1F *h6 = new TH1F("SDDModPatternRP","Modules pattern RP",fgknSDDmodules,239.5,499.5); //position number 6
538 h6->GetXaxis()->SetTitle("Module number"); //spd offset = 240
539 h6->GetYaxis()->SetTitle("Entries");
540 rv = fAliITSQADataMakerRec->Add2RecPointsList((new TH1F(*h6)),6 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image);
542 fSDDhRecPointsTask++;
543 TH1F *h7 = new TH1F("SDDLadPatternL3RP","Ladder pattern L3 RP",14,0.5,14.5); //position number 7
544 h7->GetXaxis()->SetTitle("Ladder #, Layer 3");
545 h7->GetYaxis()->SetTitle("Entries");
546 rv = fAliITSQADataMakerRec->Add2RecPointsList((new TH1F(*h7)),7 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image);
548 fSDDhRecPointsTask++;
549 TH1F *h8 = new TH1F("SDDLadPatternL4RP","Ladder pattern L4 RP",22,0.5,22.5); //position number 8
550 h8->GetXaxis()->SetTitle("Ladder #, Layer 4");
551 h8->GetYaxis()->SetTitle("Entries");
552 rv = fAliITSQADataMakerRec->Add2RecPointsList((new TH1F(*h8)),8 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image);
554 fSDDhRecPointsTask++;
555 TH2F *h9 = new TH2F("SDDLocalCoordDistrib","Local Coord Distrib",1000/nOnline,-4,4,1000/nOnline,-4,4);//position number 9
556 h9->GetXaxis()->SetTitle("X local coord, drift, cm");
557 h9->GetYaxis()->SetTitle("Z local coord, anode, cm");
558 rv = fAliITSQADataMakerRec->Add2RecPointsList((new TH2F(*h9)),9 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image);
560 fSDDhRecPointsTask++;
562 //AliInfo("Create SDD recpoints histos\n");
564 TH1F *h10 = new TH1F("SDDrdistrib_Layer3" ,"SDD r distribution Layer3" ,100,14.,18.);//position number 10 (L3)
565 h10->GetXaxis()->SetTitle("r[cm]");
566 h10->GetXaxis()->CenterTitle();
567 h10->GetYaxis()->SetTitle("Entries");
568 rv = fAliITSQADataMakerRec->Add2RecPointsList((new TH1F(*h10)),10 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image);
570 fSDDhRecPointsTask++;
572 TH1F *h11 = new TH1F("SDDrdistrib_Layer4" ,"SDD r distribution Layer4" ,100,22.,26.);// and position number 11 (L4)
573 h11->GetXaxis()->SetTitle("r[cm]");
574 h11->GetXaxis()->CenterTitle();
575 h11->GetYaxis()->SetTitle("Entries");
576 rv = fAliITSQADataMakerRec->Add2RecPointsList((new TH1F(*h11)),11 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image);
578 fSDDhRecPointsTask++;
580 for(Int_t iLay=0; iLay<=1; iLay++){
581 sprintf(hisnam,"SDDphidistrib_Layer%d",iLay+3);
582 TH1F *h12 = new TH1F(hisnam,hisnam,180,-TMath::Pi(),TMath::Pi());//position number 12 (L3) and position number 13 (L4)
583 h12->GetXaxis()->SetTitle("#varphi[rad]");
584 h12->GetXaxis()->CenterTitle();
585 h12->GetYaxis()->SetTitle("Entries");
586 rv = fAliITSQADataMakerRec->Add2RecPointsList((new TH1F(*h12)),iLay+12+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image);
588 fSDDhRecPointsTask++;
593 TH2F *h14 = new TH2F("SDDGlobalCoordDistribYXFSE","YX Global Coord Distrib FSE",5600/nOnline2,-28,28,5600/nOnline2,-28,28);//position number 14
594 h14->GetYaxis()->SetTitle("Y[cm]");
595 h14->GetXaxis()->SetTitle("X[cm]");
596 rv = fAliITSQADataMakerRec->Add2RecPointsList((new TH2F(*h14)),14+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image);
598 fSDDhRecPointsTask++;
600 TH2F *h15 = new TH2F("SDDGlobalCoordDistribRZFSE","RZ Global Coord Distrib FSE",Int_t(6400/nOnline3),-32,32,1400/nOnline4,12,26);//position number 15
601 h15->GetYaxis()->SetTitle("R[cm]");
602 h15->GetXaxis()->SetTitle("Z[cm]");
603 rv = fAliITSQADataMakerRec->Add2RecPointsList((new TH2F(*h15)),15+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image);
605 fSDDhRecPointsTask++;
609 AliDebug(AliQAv1::GetQADebugLevel(),Form("%d SDD Recs histograms booked\n",fSDDhRecPointsTask));
614 //____________________________________________________________________________
615 Int_t AliITSQASDDDataMakerRec::MakeRecPoints(TTree * clustersTree)
617 // Fill QA for RecPoints - SDD -
620 //AliInfo(Form("fAliITSQADataMakerRec->GetEventSpecie() %d\n",fAliITSQADataMakerRec->GetEventSpecie()));
621 //AliInfo(Form("fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()] %d\n",fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]));
622 // Check id histograms already created for this Event Specie
623 // if ( ! fAliITSQADataMakerRec->GetRecPointsData(fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]) )
624 // rv = InitRecPoints() ;
626 //AliInfo("get the branch with the ITS clusters !\n");
627 TBranch *branchRecP = clustersTree->GetBranch("ITSRecPoints");
629 AliError("can't get the branch with the ITS clusters !");
633 static TClonesArray statRecpoints("AliITSRecPoint") ;
634 TClonesArray *recpoints = &statRecpoints;
635 branchRecP->SetAddress(&recpoints);
637 Float_t cluglo[3]={0.,0.,0.};
640 for(Int_t i=14;i<16;i++)
642 fAliITSQADataMakerRec->GetRecPointsData(i+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Reset();
645 for(Int_t module=0; module<clustersTree->GetEntries();module++){
646 //AliInfo(Form("Module %d\n",module));
647 branchRecP->GetEvent(module);
648 npoints += recpoints->GetEntries();
649 //AliInfo(Form("modnumb %d, npoints %d, total points %d\n",module, recpoints->GetEntries(),npoints));
650 AliITSgeomTGeo::GetModuleId(module, lay, lad, det);
651 //AliInfo(Form("modnumb %d, lay %d, lad %d, det %d \n",module, lay, lad, det));
652 Bool_t kSDD = kFALSE;
653 if(lay == 3 || lay == 4) kSDD = kTRUE;
655 //AliInfo(Form("modnumb %d, entries %d\n",module, recpoints->GetEntries()));
656 for(Int_t j=0;j<recpoints->GetEntries();j++){
657 //AliInfo(Form("modnumb %d, entry %d \n",module, j));
658 AliITSRecPoint *recp = (AliITSRecPoint*)recpoints->At(j);
659 fAliITSQADataMakerRec->GetRecPointsData(6 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(module);//modpatternrp
660 recp->GetGlobalXYZ(cluglo);
661 Float_t rad=TMath::Sqrt(cluglo[0]*cluglo[0]+cluglo[1]*cluglo[1]);
662 Float_t phi=TMath::ATan2(cluglo[1],cluglo[0]);
663 fAliITSQADataMakerRec->GetRecPointsData(9 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(recp->GetDetLocalX(),recp->GetDetLocalZ());//local distribution
664 fAliITSQADataMakerRec->GetRecPointsData(2 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(cluglo[0],cluglo[1]);//global distribution YX
665 fAliITSQADataMakerRec->GetRecPointsData(3 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(cluglo[2],rad);//global distribution rz
667 fAliITSQADataMakerRec->GetRecPointsData(14 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(cluglo[0],cluglo[1]);//global distribution YX FSE
668 fAliITSQADataMakerRec->GetRecPointsData(15 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(cluglo[2],rad);//global distribution rz FSE
670 if(recp->GetLayer() == 2) {
671 fAliITSQADataMakerRec->GetRecPointsData(0 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(recp->GetQ()) ;//total charge of layer 3
672 fAliITSQADataMakerRec->GetRecPointsData(7 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(lad);//lad pattern layer 3
673 fAliITSQADataMakerRec->GetRecPointsData(10 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(rad);//r distribution layer 3
674 fAliITSQADataMakerRec->GetRecPointsData(12 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(phi);// phi distribution layer 3
675 fAliITSQADataMakerRec->GetRecPointsData(4 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(cluglo[2],phi);// phi distribution layer 3
676 } else if(recp->GetLayer() == 3) {
677 fAliITSQADataMakerRec->GetRecPointsData(1 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(recp->GetQ()) ;//total charge layer 4
678 fAliITSQADataMakerRec->GetRecPointsData(8 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(lad);//ladpatternlayer4
679 fAliITSQADataMakerRec->GetRecPointsData(11 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(rad);//r distribution
680 fAliITSQADataMakerRec->GetRecPointsData(13 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(phi);//phi distribution
681 fAliITSQADataMakerRec->GetRecPointsData(5 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(cluglo[2],phi);// phi distribution layer 4
685 statRecpoints.Clear();
689 //_______________________________________________________________
691 Int_t AliITSQASDDDataMakerRec::GetOffset(AliQAv1::TASKINDEX_t task)
694 if( task == AliQAv1::kRAWS )
696 offset=fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()];
698 else if(task == AliQAv1::kDIGITSR )
700 offset=fGenDigitsOffset[fAliITSQADataMakerRec->GetEventSpecie()];
702 else if( task == AliQAv1::kRECPOINTS )
704 offset=fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()];
709 //_______________________________________________________________
711 void AliITSQASDDDataMakerRec::SetOffset(AliQAv1::TASKINDEX_t task, Int_t offset, Int_t specie) {
712 // Returns offset number according to the specified task
713 if( task == AliQAv1::kRAWS ) {
714 fGenRawsOffset[specie]=offset;
716 else if( task == AliQAv1::kDIGITSR ) {
717 fGenDigitsOffset[specie]=offset;
719 else if( task == AliQAv1::kRECPOINTS ) {
720 fGenRecPointsOffset[specie]=offset;
724 //_______________________________________________________________
726 Int_t AliITSQASDDDataMakerRec::GetTaskHisto(AliQAv1::TASKINDEX_t task)
731 if( task == AliQAv1::kRAWS )
733 histotot=fSDDhRawsTask ;
735 else if(task == AliQAv1::kDIGITSR)
737 histotot=fSDDhDigitsTask;
739 else if( task == AliQAv1::kRECPOINTS )
741 histotot=fSDDhRecPointsTask;
744 AliInfo("No task has been selected. TaskHisto set to zero.\n");
749 //_______________________________________________________________
751 void AliITSQASDDDataMakerRec::AnalyseBNG()
754 // get file time for Previous test
755 AliInfo("AnalyseBNG\n");
756 static Int_t bngtimePrevious[6];
757 FILE *fpinPrevious = fopen( "SDDgainHistos.time", "r" );
759 for(Int_t i=0; i<6; i++) fscanf(fpinPrevious,"%d",&bngtimePrevious[i]);
760 fclose (fpinPrevious);
762 for(Int_t i=0; i<6; i++) bngtimePrevious[i] = 0;
763 Int_t bngtimeCurrent[6] = { 0 };
764 gSystem->Exec("perl -e '@d=localtime ((stat(shift))[9]); printf \"%02d%02d%02d%02d%02d\n\", $d[5]-100,$d[4]+1,$d[3],$d[2],$d[1]' SDDgainHistos1.root > SDDgainHistos.time");
765 gSystem->Exec("perl -e '@d=localtime ((stat(shift))[9]); printf \"%02d%02d%02d%02d%02d\n\", $d[5]-100,$d[4]+1,$d[3],$d[2],$d[1]' SDDgainHistos2.root >> SDDgainHistos.time");
766 gSystem->Exec("perl -e '@d=localtime ((stat(shift))[9]); printf \"%02d%02d%02d%02d%02d\n\", $d[5]-100,$d[4]+1,$d[3],$d[2],$d[1]' SDDgainHistos3.root >> SDDgainHistos.time");
767 gSystem->Exec("perl -e '@d=localtime ((stat(shift))[9]); printf \"%02d%02d%02d%02d%02d\n\", $d[5]-100,$d[4]+1,$d[3],$d[2],$d[1]' SDDgainHistos4.root >> SDDgainHistos.time");
768 gSystem->Exec("perl -e '@d=localtime ((stat(shift))[9]); printf \"%02d%02d%02d%02d%02d\n\", $d[5]-100,$d[4]+1,$d[3],$d[2],$d[1]' SDDgainHistos5.root >> SDDgainHistos.time");
769 gSystem->Exec("perl -e '@d=localtime ((stat(shift))[9]); printf \"%02d%02d%02d%02d%02d\n\", $d[5]-100,$d[4]+1,$d[3],$d[2],$d[1]' SDDgainHistos6.root >> SDDgainHistos.time");
770 FILE *fpin = fopen( "SDDgainHistos.time", "r" );
771 for(Int_t i=0; i<6; i++) {
772 fscanf(fpin,"%d",&bngtimeCurrent[i]);
773 // AliInfo(Form("bngtimeCurrent[%d] %d, bngtimePrevious[%d] %d\n",i,bngtimeCurrent[i],i,bngtimePrevious[i]));
775 Bool_t kAnalyse = kTRUE;
776 for(Int_t i=0; i<6; i++) if(bngtimeCurrent[i] <= bngtimePrevious[i]) kAnalyse = kFALSE;
778 // new bng file found
779 for(Int_t i=0; i<6; i++) bngtimePrevious[i] = bngtimeCurrent[i];
780 Bool_t kFilesExist = kTRUE;
781 char *hname = new char[50];
782 for(Int_t i=0; i<6; i++) {
783 sprintf(hname,"SDDgainHistos%d.root",i+1);
784 TFile gainFile(hname);
785 if(gainFile.IsZombie()) kFilesExist = kFALSE;
789 AnalyseHistos(1); // Baseline
790 AnalyseHistos(2); // Uncorrected Noise
791 AnalyseHistos(3); // Common Mode Noise
792 AnalyseHistos(4); // Corrected Noise
793 AnalyseHistos(5); // Gain
794 gSystem->Exec("cp SDDgainHistos1.root SDDgainHistosPrevious1.root");
795 gSystem->Exec("cp SDDgainHistos2.root SDDgainHistosPrevious2.root");
796 gSystem->Exec("cp SDDgainHistos3.root SDDgainHistosPrevious3.root");
797 gSystem->Exec("cp SDDgainHistos4.root SDDgainHistosPrevious4.root");
798 gSystem->Exec("cp SDDgainHistos5.root SDDgainHistosPrevious5.root");
799 gSystem->Exec("cp SDDgainHistos6.root SDDgainHistosPrevious6.root");
801 AliInfo("file(s) SDDgainHistos .root not found \n");
809 //_______________________________________________________________
811 void AliITSQASDDDataMakerRec::AnalyseINJ()
813 // get file time for last test
815 AliInfo("AnalyseINJ\n");
816 static Int_t injtimePrevious[6];
817 FILE *fpinPrevious = fopen( "SDDinjectHistos.time", "r" );
819 for(Int_t i=0; i<6; i++) fscanf(fpinPrevious,"%d",&injtimePrevious[i]);
820 fclose (fpinPrevious);
822 for(Int_t i=0; i<6; i++) injtimePrevious[i] = 0;
823 Int_t injtimeCurrent[6] = { 0 };
824 gSystem->Exec("perl -e '@d=localtime ((stat(shift))[9]); printf \"%02d%02d%02d%02d%02d\n\", $d[5]-100,$d[4]+1,$d[3],$d[2],$d[1]' SDDinjectHistos1.root > SDDinjectHistos.time");
825 gSystem->Exec("perl -e '@d=localtime ((stat(shift))[9]); printf \"%02d%02d%02d%02d%02d\n\", $d[5]-100,$d[4]+1,$d[3],$d[2],$d[1]' SDDinjectHistos2.root >> SDDinjectHistos.time");
826 gSystem->Exec("perl -e '@d=localtime ((stat(shift))[9]); printf \"%02d%02d%02d%02d%02d\n\", $d[5]-100,$d[4]+1,$d[3],$d[2],$d[1]' SDDinjectHistos3.root >> SDDinjectHistos.time");
827 gSystem->Exec("perl -e '@d=localtime ((stat(shift))[9]); printf \"%02d%02d%02d%02d%02d\n\", $d[5]-100,$d[4]+1,$d[3],$d[2],$d[1]' SDDinjectHistos4.root >> SDDinjectHistos.time");
828 gSystem->Exec("perl -e '@d=localtime ((stat(shift))[9]); printf \"%02d%02d%02d%02d%02d\n\", $d[5]-100,$d[4]+1,$d[3],$d[2],$d[1]' SDDinjectHistos5.root >> SDDinjectHistos.time");
829 gSystem->Exec("perl -e '@d=localtime ((stat(shift))[9]); printf \"%02d%02d%02d%02d%02d\n\", $d[5]-100,$d[4]+1,$d[3],$d[2],$d[1]' SDDinjectHistos6.root >> SDDinjectHistos.time");
830 FILE *fpin = fopen( "SDDinjectHistos.time", "r" );
831 for(Int_t i=0; i<6; i++) {
832 fscanf(fpin,"%d",&injtimeCurrent[i]);
833 // AliInfo(Form("injtimeCurrent[%d] %d, injtimePrevious[%d] %d\n",i,injtimeCurrent[i],i,injtimePrevious[i]));
835 Bool_t kAnalyse = kTRUE;
836 for(Int_t i=0; i<6; i++) if(injtimeCurrent[i] <= injtimePrevious[i]) kAnalyse = kFALSE;
838 // new inj file found
839 for(Int_t i=0; i<6; i++) injtimePrevious[i] = injtimeCurrent[i];
840 Bool_t kFilesExist = kTRUE;
841 char *hname = new char[50];
842 for(Int_t i=0; i<6; i++) {
843 sprintf(hname,"SDDinjectHistos%d.root",i+1);
844 TFile gainFile(hname);
845 if(gainFile.IsZombie()) kFilesExist = kFALSE;
848 AnalyseHistos(6); // Drift Speed
849 gSystem->Exec("cp SDDinjectHistos1.root SDDinjectHistosPrevious1.root");
850 gSystem->Exec("cp SDDinjectHistos2.root SDDinjectHistosPrevious2.root");
851 gSystem->Exec("cp SDDinjectHistos3.root SDDinjectHistosPrevious3.root");
852 gSystem->Exec("cp SDDinjectHistos4.root SDDinjectHistosPrevious4.root");
853 gSystem->Exec("cp SDDinjectHistos5.root SDDinjectHistosPrevious5.root");
854 gSystem->Exec("cp SDDinjectHistos6.root SDDinjectHistosPrevious6.root");
856 AliInfo("file(s) SDDinjectHistos .root not found \n");
861 static Int_t injtimeLast = 0;
862 FILE *fpinlast = fopen( "SDDinjectHistos.time", "r" );
864 fscanf(fpinlast,"%d",&injtimeLast);
868 Int_t injtimeCurrent = 0;
869 gSystem->Exec("perl -e '@d=localtime ((stat(shift))[9]); printf \"%02d%02d%02d%02d%02d\n\", $d[5]-100,$d[4]+1,$d[3],$d[2],$d[1]' SDDinjectHistos.root > SDDinjectHistos.time");
870 FILE *fpin = fopen( "SDDinjectHistos.time", "r" );
871 fscanf(fpin,"%d",&injtimeCurrent);
872 if(injtimeCurrent > injtimeLast) {
873 // new gain file found
874 injtimeLast = injtimeCurrent;
876 TFile injectFile("SDDinjectHistos.root");
877 if(!injectFile.IsZombie()) {
878 AnalyseHistos(6); // Drift Speed
879 gSystem->Exec("cp SDDinjectHistos.root SDDinjectHistosLast.root");
881 AliInfo("file SDDinjectHistos.root not found \n");
890 //_______________________________________________________________
892 void AliITSQASDDDataMakerRec::AnodeStatus()
894 char *hnamePrevious = new char[50];
895 char *fnamePrevious = new char[50];
898 for(Int_t k=0;k<6;k++) {
899 sprintf(fnamePrevious,"SDDgainHistosPrevious%d.root",k+1);
900 TFile gainFilePrevious(fnamePrevious);
901 if(gainFilePrevious.IsZombie()) continue;
902 for(Int_t ddl =0; ddl<fDDLModuleMap->GetNDDLs(); ddl++){
903 for(Int_t crx =0; crx<fDDLModuleMap->GetNModPerDDL(); crx++){
904 for(Int_t iside=0;iside<fgknSide;iside++){
905 Int_t moduleSDD = fDDLModuleMap->GetModuleNumber(ddl,crx);
906 //AliITSgeomTGeo::GetModuleId(moduleSDD+fgkmodoffset, lay, lad, det);
907 sprintf(hnamePrevious,"hgood%02dc%02ds%d",ddl,crx,iside);
908 //AliInfo(Form("get histo %s\n",hnamePrevious));
909 TH1F *hgood = (TH1F *) gainFilePrevious.Get(hnamePrevious);
911 for(Int_t i=0; i<hgood->GetNbinsX();i++) {
912 fAnodeMap[moduleSDD-fgkmodoffset][iside][i] = hgood->GetBinContent(i);
913 if(fAnodeMap[moduleSDD-fgkmodoffset][iside][i]) fGoodAnodes++;
919 gainFilePrevious.Close();
922 fGoodAnodesCurrent = 0;
923 fBadAnodesCurrent = 0;
924 char *hname = new char[50];
925 Int_t nChangedStatus = 0;
926 Bool_t CurrentAnodeMap[fgknSDDmodules][fgknSide][fgknAnode];
927 for(Int_t k=0;k<6;k++) {
928 sprintf(fnamePrevious,"SDDgainHistos%d.root",k+1);
929 TFile gainFile(fnamePrevious);
930 if(gainFile.IsZombie()) continue;
931 for(Int_t ddl =0; ddl<fDDLModuleMap->GetNDDLs(); ddl++){
932 for(Int_t crx =0; crx<fDDLModuleMap->GetNModPerDDL(); crx++){
933 for(Int_t iside=0;iside<fgknSide;iside++){
934 Int_t moduleSDD = fDDLModuleMap->GetModuleNumber(ddl,crx);
935 //AliITSgeomTGeo::GetModuleId(moduleSDD+fgkmodoffset, lay, lad, det);
936 sprintf(hname,"hgood%02dc%02ds%d",ddl,crx,iside);
937 //AliInfo(Form("get histo %s\n",hname));
938 TH1F *hgood = (TH1F *) gainFile.Get(hname);
940 for(Int_t i=0; i<hgood->GetNbinsX();i++) {
941 CurrentAnodeMap[moduleSDD-fgkmodoffset][iside][i] = hgood->GetBinContent(i);
942 if(CurrentAnodeMap[moduleSDD-fgkmodoffset][iside][i]) fGoodAnodesCurrent++;
943 else fBadAnodesCurrent++;
944 if(CurrentAnodeMap[moduleSDD-fgkmodoffset][iside][i] != fAnodeMap[moduleSDD-fgkmodoffset][iside][i]) {
945 fAnodeMap[moduleSDD-fgkmodoffset][iside][i] = CurrentAnodeMap[moduleSDD-fgkmodoffset][iside][i];
947 AliWarning(Form("DDL %d, CRX %d, Side %d, Anode %d changed status to %d \n",ddl,crx,iside,i,fAnodeMap[moduleSDD-fgkmodoffset][iside][i]));
957 AliWarning(Form("Number of good anodes changed from %d to %d, that is %f %%\n",fGoodAnodes,fGoodAnodesCurrent,((Float_t) TMath::Abs(fGoodAnodes-fGoodAnodesCurrent))/(fBadAnodesCurrent+fGoodAnodesCurrent)));
958 if(fGoodAnodesCurrent != fGoodAnodes) {
959 fGoodAnodes = fGoodAnodesCurrent;
961 AliWarning(Form("Number of bad anodes changed from %d to %d, that is %f %%\n",fBadAnodes,fBadAnodesCurrent,((Float_t) TMath::Abs(fBadAnodes-fBadAnodesCurrent))/(fBadAnodesCurrent+fGoodAnodesCurrent)));
962 if(fBadAnodesCurrent != fBadAnodes) {
963 fBadAnodes = fBadAnodesCurrent;
968 //_______________________________________________________________
970 void AliITSQASDDDataMakerRec::AnalyseHistos(Int_t type)
973 if(type < 1 || type > 6) AliWarning(Form("Wrong type (%d), must be between 1 and 6\n",type));
975 Double_t Current[fgknSDDmodules][fgknSide][fgknAnode];
976 char *hnamePrevious = new char[50];
977 char *fnamePrevious = new char[50];
979 for(Int_t k=0; k<6; k++) {
980 if(type < 6) sprintf(fnamePrevious,"SDDgainHistosPrevious%d.root",k+1);
981 else sprintf(fnamePrevious,"SDDinjectHistosPrevious%d.root",k+1);
982 TFile *gainFilePrevious = new TFile(fnamePrevious);
983 if(gainFilePrevious->IsZombie()) continue;
985 for(Int_t ddl =0; ddl<fDDLModuleMap->GetNDDLs(); ddl++){
986 for(Int_t crx =0; crx<fDDLModuleMap->GetNModPerDDL(); crx++){
987 for(Int_t iside=0;iside<fgknSide;iside++){
988 Int_t moduleSDD = fDDLModuleMap->GetModuleNumber(ddl,crx);
989 //AliITSgeomTGeo::GetModuleId(moduleSDD+fgkmodoffset, lay, lad, det);
990 if(type == 1) sprintf(hnamePrevious,"hbase%02dc%02ds%d",ddl,crx,iside);
991 else if(type == 2) sprintf(hnamePrevious,"hnois%02dc%02ds%d",ddl,crx,iside);
992 else if(type == 3) sprintf(hnamePrevious,"hcmn%02dc%02ds%d",ddl,crx,iside);
993 else if(type == 4) sprintf(hnamePrevious,"hcorn%02dc%02ds%d",ddl,crx,iside);
994 else if(type == 5) sprintf(hnamePrevious,"hgain%02dc%02ds%d",ddl,crx,iside);
995 else if(type == 6) sprintf(hnamePrevious,"hdrsp%02dc%02ds%d",ddl,crx,iside);
996 //AliInfo(Form("get histo %s\n",hnamePrevious));
997 TH1F *hhist = (TH1F *) gainFilePrevious->Get(hnamePrevious);
999 for(Int_t i=0; i<hhist->GetNbinsX();i++) {
1000 Current[moduleSDD-fgkmodoffset][iside][i] = hhist->GetBinContent(i);
1006 gainFilePrevious->Close();
1007 delete gainFilePrevious;
1014 TH1F *hDistDiff = 0;
1018 nbins = (Int_t)(xmax-xmin);
1019 hDist = new TH1F("hBaseline","Baseline",nbins,xmin,xmax);
1020 hDistDiff = new TH1F("hBaselineDiff","Baseline Difference",200,-100.,100.);
1021 } else if(type == 2) {
1024 nbins = (Int_t) (100.*(xmax-xmin));
1025 hDist = new TH1F("hNoiseUnc","Noise (before correction)",nbins,xmin,xmax);
1026 hDistDiff = new TH1F("hNoiseUncDiff","Noise (before correction) Difference",200,-10.,10.);
1027 } else if(type == 3) {
1030 nbins = (Int_t)( 100.*(xmax-xmin));
1031 hDist = new TH1F("hNoiseCMN","Noise (common mode)",nbins,xmin,xmax);
1032 hDistDiff = new TH1F("hNoiseCMNDiff","Noise (common mode) Difference",200,-10.,10.);
1033 } else if(type == 4) {
1036 nbins = (Int_t)(100.*(xmax-xmin));
1037 hDist = new TH1F("hNoiseCor","Noise (after correction)",nbins,xmin,xmax);
1038 hDistDiff = new TH1F("hNoiseCorDiff","Noise (after correction) Difference",200,-10.,10.);
1039 } else if(type == 5) {
1042 nbins = (Int_t)(100.*(xmax-xmin));
1043 hDist = new TH1F("hGain","Gain",nbins,xmin,xmax);
1044 hDistDiff = new TH1F("hGainDiff","Gain Difference",200,-10.,10.);
1045 } else if(type == 6) {
1048 nbins = (Int_t)(100.*(xmax-xmin));
1049 hDist = new TH1F("hDriftSpeed","Drift Speed",nbins,xmin,xmax);
1050 hDistDiff = new TH1F("hDriftSpeedDiff","Drift Speed Difference",200,-10.,10.);
1053 Float_t binw = (xmax-xmin)/nbins;
1055 for(Int_t k=0; k<6; k++) {
1056 if(type < 6) sprintf(fnamePrevious,"SDDgainHistos%d.root",k+1);
1057 else sprintf(fnamePrevious,"SDDinjectHistos%d.root",k+1);
1058 TFile *gainFile = new TFile(fnamePrevious);
1059 if(gainFile->IsZombie()) continue;
1061 for(Int_t ddl =0; ddl<fDDLModuleMap->GetNDDLs(); ddl++){
1062 for(Int_t crx =0; crx<fDDLModuleMap->GetNModPerDDL(); crx++){
1063 for(Int_t iside=0;iside<fgknSide;iside++){
1064 Int_t moduleSDD = fDDLModuleMap->GetModuleNumber(ddl,crx);
1065 //AliITSgeomTGeo::GetModuleId(moduleSDD+fgkmodoffset, lay, lad, det);
1066 if(type == 1) sprintf(hnamePrevious,"hbase%02dc%02ds%d",ddl,crx,iside);
1067 else if(type == 2) sprintf(hnamePrevious,"hnois%02dc%02ds%d",ddl,crx,iside);
1068 else if(type == 3) sprintf(hnamePrevious,"hcmn%02dc%02ds%d",ddl,crx,iside);
1069 else if(type == 4) sprintf(hnamePrevious,"hcorn%02dc%02ds%d",ddl,crx,iside);
1070 else if(type == 5) sprintf(hnamePrevious,"hgain%02dc%02ds%d",ddl,crx,iside);
1071 else if(type == 6) sprintf(hnamePrevious,"hdrsp%02dc%02ds%d",ddl,crx,iside);
1072 //AliInfo(Form("get histo %s\n",hname));
1073 TH1F *hhist = (TH1F *) gainFile->Get(hnamePrevious);
1074 if(!hhist) continue;
1075 for(Int_t i=0; i<hhist->GetNbinsX();i++) {
1076 if(!fAnodeMap[moduleSDD-fgkmodoffset][iside][i]) continue;
1077 hDist->Fill(hhist->GetBinContent(i));
1078 hDistDiff->Fill(hhist->GetBinContent(i)-Current[moduleSDD-fgkmodoffset][iside][i]);
1089 TF1 ff("ff", "gaus", xmin+0.1, xmax-0.1);
1090 hDist->Fit("ff","NWR");
1091 // hDist->Fit("gaus","","",xmin+0.1, xmax-0.1);
1092 // Float_t ChiSquared = (Float_t) ff.GetChisquare();
1093 // Int_t NDF = ff.GetNumberFitPoints() - ff.GetNpar();
1094 Float_t average = (Float_t) ff.GetParameter(1);
1095 Float_t sigma = (Float_t) ff.GetParameter(2);
1096 // Float_t mean = hDist->GetMean();
1097 // Float_t rms = hDist->GetRMS();
1099 for(Int_t i=0; i<hDist->GetNbinsX();i++) {
1101 if(TMath::Abs(i*binw-average) > 4.*sigma) badB += (Int_t)hDist->GetBinContent(i);
1103 // if(TMath::Abs(i-mean) > 4*rms) badB += hDist->GetBinContent(i);
1106 AliInfo(Form("Number of anodes with baseline out of 4*sigma from average: %d, %f%%\n",badB,100.*((Float_t) badB)/hDist->GetEntries()));
1107 } else if(type == 2) {
1108 AliInfo(Form("Number of anodes with uncorrected noise out of 4*sigma from average: %d, %f%%\n",badB,100.*((Float_t) badB)/hDist->GetEntries()));
1109 } else if(type == 3) {
1110 AliInfo(Form("Number of anodes with common mode noise out of 4*sigma from average: %d, %f%%\n",badB,100.*((Float_t) badB)/hDist->GetEntries()));
1111 } else if(type == 4) {
1112 AliInfo(Form("Number of anodes with corrected noise out of 4*sigma from average: %d, %f%%\n",badB,100.*((Float_t) badB)/hDist->GetEntries()));
1113 } else if(type == 5) {
1114 AliInfo(Form("Number of anodes with gain out of 4*sigma from average: %d, %f%%\n",badB,100.*((Float_t) badB)/hDist->GetEntries()));
1115 } else if(type == 6) {
1116 Int_t badspeed = (Int_t)hDist->GetBinContent(1);
1117 AliInfo(Form("Number of anodes with drift speed equal to 0: %d\n",badspeed));
1118 AliInfo(Form("Number of anodes with drift speed out of 4*sigma from average: %d, %f%%\n",badB-badspeed,100.*((Float_t) (badB-badspeed))/(hDist->GetEntries()-badspeed)));
1121 TH1F *hDistHistoryCurrent = NULL;
1122 TH1F *hDistHistoryPrevious = NULL;
1124 TFile *gainHistoryFile;
1126 gainHistoryFile = new TFile("SDDgainHistory.root","UPDATE");
1128 gainHistoryFile = new TFile("SDDinjectHistory.root","UPDATE");
1131 //AliInfo("SDDgainHistory.root file opened\n");
1132 if(!gainHistoryFile->IsZombie()) {
1133 if(type == 1) hDistHistoryPrevious = (TH1F *) gainHistoryFile->Get("hBaselineHistory");
1134 else if(type == 2) hDistHistoryPrevious = (TH1F *) gainHistoryFile->Get("hNoiseUncHistory");
1135 else if(type == 3) hDistHistoryPrevious = (TH1F *) gainHistoryFile->Get("hNoiseCMNHistory");
1136 else if(type == 4) hDistHistoryPrevious = (TH1F *) gainHistoryFile->Get("hNoiseCorHistory");
1137 else if(type == 5) hDistHistoryPrevious = (TH1F *) gainHistoryFile->Get("hGainHistory");
1138 else if(type == 6) hDistHistoryPrevious = (TH1F *) gainHistoryFile->Get("hDriftSpeedHistory");
1139 //AliInfo(Form("hDistHistoryPrevious %x\n",hDistHistoryPrevious));
1141 if(!hDistHistoryPrevious) {
1142 if(type == 1) hDistHistoryCurrent = new TH1F("hBaselineHistory","Average Baseline History",1,0,1);
1143 else if(type == 2) hDistHistoryCurrent = new TH1F("hNoiseUncHistory","Average Uncorrected Noise History",1,0,1);
1144 else if(type == 3) hDistHistoryCurrent = new TH1F("hNoiseCMNHistory","Average Common Mode Noise History",1,0,1);
1145 else if(type == 4) hDistHistoryCurrent = new TH1F("hNoiseCorHistory","Average Corrected Noise History",1,0,1);
1146 else if(type == 5) hDistHistoryCurrent = new TH1F("hGainHistory","Average Gain History",1,0,1);
1147 else if(type == 6) hDistHistoryCurrent = new TH1F("hDriftSpeedHistory","Average Drift Speed History",1,0,1);
1148 //AliInfo(Form("hDistHistoryCurrent 1 %x\n",hDistHistoryCurrent));
1150 hDistHistoryCurrent->SetBinContent(1,average);
1151 hDistHistoryCurrent->SetBinError(1,sigma);
1154 hDistHistoryCurrent->SetBinContent(1,mean);
1155 hDistHistoryCurrent->SetBinError(1,rms);
1159 if(type == 1) hDistHistoryCurrent = new TH1F("hBaselineHistory","Average Baseline History",hDistHistoryPrevious->GetNbinsX()+1,0,hDistHistoryPrevious->GetNbinsX()+1);
1160 else if(type == 2) hDistHistoryCurrent = new TH1F("hNoiseUncHistory","Average Uncorrected Noise History",hDistHistoryPrevious->GetNbinsX()+1,0,hDistHistoryPrevious->GetNbinsX()+1);
1161 else if(type == 3) hDistHistoryCurrent = new TH1F("hNoiseCMNHistory","Average Common Mode Noise History",hDistHistoryPrevious->GetNbinsX()+1,0,hDistHistoryPrevious->GetNbinsX()+1);
1162 else if(type == 4) hDistHistoryCurrent = new TH1F("hNoiseCorHistory","Average Corrected Noise History",hDistHistoryPrevious->GetNbinsX()+1,0,hDistHistoryPrevious->GetNbinsX()+1);
1163 else if(type == 5) hDistHistoryCurrent = new TH1F("hGainHistory","Average Gain History",hDistHistoryPrevious->GetNbinsX()+1,0,hDistHistoryPrevious->GetNbinsX()+1);
1164 else if(type == 6) hDistHistoryCurrent = new TH1F("hDriftSpeedHistory","Average Drift Speed History",hDistHistoryPrevious->GetNbinsX()+1,0,hDistHistoryPrevious->GetNbinsX()+1);
1165 //AliInfo(Form("hBaselineHistory 2 %x\n",hDistHistory));
1166 for(Int_t i=0;i<hDistHistoryPrevious->GetNbinsX();i++) {
1167 hDistHistoryCurrent->SetBinContent(i,hDistHistoryPrevious->GetBinContent(i));
1168 hDistHistoryCurrent->SetBinError(i,hDistHistoryPrevious->GetBinError(i));
1170 hDistHistoryCurrent->SetBinContent(hDistHistoryPrevious->GetNbinsX(),average);
1171 hDistHistoryCurrent->SetBinError(hDistHistoryPrevious->GetNbinsX(),sigma);
1174 hDistHistoryCurrent->Write();
1175 gainHistoryFile->Close();
1176 delete gainHistoryFile;
1180 }//_______________________________________________________________