1 #if !defined(__CINT__) || defined(__MAKECINT__)
12 #include "Riostream.h"
14 #include "AliITSgeomTGeo.h"
16 #include "AliRawReaderRoot.h"
17 #include "AliITSRawStreamSSD.h"
18 #include "AliCDBManager.h"
19 #include "AliCDBEntry.h"
24 //============================================================//
25 static const Int_t fgkNumOfChips = 6; //number of SSD chips per module per side
26 static const Int_t fgkNumOfLDCs = 8; //number of SSD LDCs
27 static const Int_t fgkNumOfDDLs = 16; //number of SSD DDLs
28 static const Int_t fgkSSDMODULES = 1698; //total number of SSD modules
29 static const Int_t fgkSSDLADDERSLAYER5 = 34; //ladders on layer 5
30 static const Int_t fgkSSDLADDERSLAYER6 = 38; //ladders on layer 6
31 static const Int_t fgkSSDMODULESPERLADDERLAYER5 = 22; //modules per ladder - layer 5
32 static const Int_t fgkSSDMODULESPERLADDERLAYER6 = 25; //modules per ladder - layer 6
33 static const Int_t fgkSSDMODULESLAYER5 = 748; //total number of SSD modules - layer5
34 static const Int_t fgkSSDMODULESLAYER6 = 950; //total number of SSD modules - layer6
35 static const Int_t fgkNumberOfPSideStrips = 768; //number of P-side strips
36 //============================================================//
39 void makeCM(const char* filename, Int_t nEvents, TList *list);
40 void checkCM(const char* filename);
41 void compareChipLists(TString inputFile1,
45 //__________________________________________________________//
46 void readSSDCommonMode(const char* filename = "raw.root",
48 //Reads the CM pseudo-channels and produces the CM map for both layers
49 //and for p and n-side.
50 gStyle->SetPalette(1,0);
52 TList *list = initCM();
54 Printf("CM histograms: %d",list->GetEntries());
55 makeCM(filename,nEvents,list);
58 //__________________________________________________________//
60 //Initializes the histograms and returns the TList object
61 TList *list = new TList();
63 Int_t gLayer = 0,gLadder = 0, gModule = 0;
64 Int_t gHistCounter = 0;
66 TH1F *gHistSSDCMModule[2*fgkSSDMODULES][fgkNumOfChips];
67 for(Int_t iModule = 500; iModule < fgkSSDMODULES + 500; iModule++) {
68 AliITSgeomTGeo::GetModuleId(iModule,gLayer,gLadder,gModule);
69 for(Int_t iChip = 0; iChip < fgkNumOfChips; iChip++) {
70 gTitle = "SSD_CM_PSide_Layer"; gTitle += gLayer;
71 gTitle += "_Ladder"; gTitle += gLadder;
72 gTitle += "_Module"; gTitle += gModule;
73 gTitle += "_Chip"; gTitle += iChip+1;
74 gHistSSDCMModule[gHistCounter][iChip] = new TH1F(gTitle.Data(),
77 gHistSSDCMModule[gHistCounter][iChip]->GetXaxis()->SetTitle("CM");
78 list->Add(gHistSSDCMModule[gHistCounter][iChip]);
82 for(Int_t iModule = 500; iModule < fgkSSDMODULES + 500; iModule++) {
83 AliITSgeomTGeo::GetModuleId(iModule,gLayer,gLadder,gModule);
84 for(Int_t iChip = 0; iChip < fgkNumOfChips; iChip++) {
85 gTitle = "SSD_CM_NSide_Layer"; gTitle += gLayer;
86 gTitle += "_Ladder"; gTitle += gLadder;
87 gTitle += "_Module"; gTitle += gModule;
88 gTitle += "_Chip"; gTitle += iChip+1;
89 gHistSSDCMModule[gHistCounter][iChip] = new TH1F(gTitle.Data(),
92 gHistSSDCMModule[gHistCounter][iChip]->GetXaxis()->SetTitle("CM");
93 list->Add(gHistSSDCMModule[gHistCounter][iChip]);
101 //__________________________________________________________//
102 void makeCM(const char* filename, Int_t nEvents, TList *list) {
103 //Function to read the CM values
104 Int_t gStripNumber = 0;
105 Int_t gLayer = 0,gLadder = 0, gModule = 0;
107 //==================================================//
108 AliCDBManager *fCDBManager = AliCDBManager::Instance();
109 fCDBManager->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
110 Int_t runNumber = atoi(gSystem->Getenv("DATE_RUN_NUMBER"));
112 Printf("DATE_RUN_NUMBER not defined!!!\n");
114 fCDBManager->SetRun(runNumber);
115 AliCDBEntry *geomGRP = fCDBManager->Get("GRP/Geometry/Data");
116 if(!geomGRP) cout<<"GRP geometry not found!!!"<<endl;;
117 //==================================================//
119 //==================================================//
120 TH2F *fHistPSideMeanCMMapLayer5 = new TH2F("fHistPSideMeanCMMapLayer5",
121 "Layer 5 - P side;N_{module};N_{ladder}",
124 fHistPSideMeanCMMapLayer5->GetXaxis()->SetTitleColor(1);
125 fHistPSideMeanCMMapLayer5->GetZaxis()->SetRangeUser(0.,20.);
126 fHistPSideMeanCMMapLayer5->SetStats(kFALSE);
127 fHistPSideMeanCMMapLayer5->GetYaxis()->SetTitleOffset(1.8);
128 fHistPSideMeanCMMapLayer5->GetXaxis()->SetNdivisions(22);
129 fHistPSideMeanCMMapLayer5->GetYaxis()->SetNdivisions(34);
130 fHistPSideMeanCMMapLayer5->GetXaxis()->SetLabelSize(0.03);
131 fHistPSideMeanCMMapLayer5->GetYaxis()->SetLabelSize(0.03);
132 fHistPSideMeanCMMapLayer5->GetZaxis()->SetTitleOffset(1.6);
133 fHistPSideMeanCMMapLayer5->GetZaxis()->SetTitle("RMS(CM) (p-side)");
135 TH2F *fHistNSideMeanCMMapLayer5 = new TH2F("fHistNSideMeanCMMapLayer5",
136 "Layer 5 - N side;N_{module};N_{ladder}",
139 fHistNSideMeanCMMapLayer5->GetXaxis()->SetTitleColor(1);
140 fHistNSideMeanCMMapLayer5->GetZaxis()->SetRangeUser(0.,20.);
141 fHistNSideMeanCMMapLayer5->SetStats(kFALSE);
142 fHistNSideMeanCMMapLayer5->GetYaxis()->SetTitleOffset(1.8);
143 fHistNSideMeanCMMapLayer5->GetXaxis()->SetNdivisions(22);
144 fHistNSideMeanCMMapLayer5->GetYaxis()->SetNdivisions(34);
145 fHistNSideMeanCMMapLayer5->GetXaxis()->SetLabelSize(0.03);
146 fHistNSideMeanCMMapLayer5->GetYaxis()->SetLabelSize(0.03);
147 fHistNSideMeanCMMapLayer5->GetZaxis()->SetTitleOffset(1.6);
148 fHistNSideMeanCMMapLayer5->GetZaxis()->SetTitle("RMS(CM) (n-side)");
150 TH2F *fHistPSideMeanCMMapLayer6 = new TH2F("fHistPSideMeanCMMapLayer6",
151 "Layer 6 - P side;N_{module};N_{ladder}",
154 fHistPSideMeanCMMapLayer6->GetXaxis()->SetTitleColor(1);
155 fHistPSideMeanCMMapLayer6->GetZaxis()->SetRangeUser(0.,20.);
156 fHistPSideMeanCMMapLayer6->SetStats(kFALSE);
157 fHistPSideMeanCMMapLayer6->GetYaxis()->SetTitleOffset(1.8);
158 fHistPSideMeanCMMapLayer6->GetXaxis()->SetNdivisions(25);
159 fHistPSideMeanCMMapLayer6->GetYaxis()->SetNdivisions(38);
160 fHistPSideMeanCMMapLayer6->GetXaxis()->SetLabelSize(0.03);
161 fHistPSideMeanCMMapLayer6->GetYaxis()->SetLabelSize(0.03);
162 fHistPSideMeanCMMapLayer6->GetZaxis()->SetTitleOffset(1.6);
163 fHistPSideMeanCMMapLayer6->GetZaxis()->SetTitle("RMS(CM) (p-side)");
165 TH2F *fHistNSideMeanCMMapLayer6 = new TH2F("fHistNSideMeanCMMapLayer6",
166 "Layer 6 - N side;N_{module};N_{ladder}",
169 fHistNSideMeanCMMapLayer6->GetXaxis()->SetTitleColor(1);
170 fHistNSideMeanCMMapLayer6->GetZaxis()->SetRangeUser(0.,20.);
171 fHistNSideMeanCMMapLayer6->SetStats(kFALSE);
172 fHistNSideMeanCMMapLayer6->GetYaxis()->SetTitleOffset(1.8);
173 fHistNSideMeanCMMapLayer6->GetXaxis()->SetNdivisions(25);
174 fHistNSideMeanCMMapLayer6->GetYaxis()->SetNdivisions(38);
175 fHistNSideMeanCMMapLayer6->GetXaxis()->SetLabelSize(0.03);
176 fHistNSideMeanCMMapLayer6->GetYaxis()->SetLabelSize(0.03);
177 fHistNSideMeanCMMapLayer6->GetZaxis()->SetTitleOffset(1.6);
178 fHistNSideMeanCMMapLayer6->GetZaxis()->SetTitle("RMS(CM) (n-side)");
180 //____________________________________________________________//
181 TH2F *fHistPSideRMSCMMapLayer5 = new TH2F("fHistPSideRMSCMMapLayer5",
182 "Layer 5 - P side;N_{module};N_{ladder}",
185 fHistPSideRMSCMMapLayer5->GetXaxis()->SetTitleColor(1);
186 fHistPSideRMSCMMapLayer5->GetZaxis()->SetRangeUser(0.,20.);
187 fHistPSideRMSCMMapLayer5->SetStats(kFALSE);
188 fHistPSideRMSCMMapLayer5->GetYaxis()->SetTitleOffset(1.8);
189 fHistPSideRMSCMMapLayer5->GetXaxis()->SetNdivisions(22);
190 fHistPSideRMSCMMapLayer5->GetYaxis()->SetNdivisions(34);
191 fHistPSideRMSCMMapLayer5->GetXaxis()->SetLabelSize(0.03);
192 fHistPSideRMSCMMapLayer5->GetYaxis()->SetLabelSize(0.03);
193 fHistPSideRMSCMMapLayer5->GetZaxis()->SetTitleOffset(1.6);
194 fHistPSideRMSCMMapLayer5->GetZaxis()->SetTitle("RMS(CM) (p-side)");
196 TH2F *fHistNSideRMSCMMapLayer5 = new TH2F("fHistNSideRMSCMMapLayer5",
197 "Layer 5 - N side;N_{module};N_{ladder}",
200 fHistNSideRMSCMMapLayer5->GetXaxis()->SetTitleColor(1);
201 fHistNSideRMSCMMapLayer5->GetZaxis()->SetRangeUser(0.,20.);
202 fHistNSideRMSCMMapLayer5->SetStats(kFALSE);
203 fHistNSideRMSCMMapLayer5->GetYaxis()->SetTitleOffset(1.8);
204 fHistNSideRMSCMMapLayer5->GetXaxis()->SetNdivisions(22);
205 fHistNSideRMSCMMapLayer5->GetYaxis()->SetNdivisions(34);
206 fHistNSideRMSCMMapLayer5->GetXaxis()->SetLabelSize(0.03);
207 fHistNSideRMSCMMapLayer5->GetYaxis()->SetLabelSize(0.03);
208 fHistNSideRMSCMMapLayer5->GetZaxis()->SetTitleOffset(1.6);
209 fHistNSideRMSCMMapLayer5->GetZaxis()->SetTitle("RMS(CM) (n-side)");
211 TH2F *fHistPSideRMSCMMapLayer6 = new TH2F("fHistPSideRMSCMMapLayer6",
212 "Layer 6 - P side;N_{module};N_{ladder}",
215 fHistPSideRMSCMMapLayer6->GetXaxis()->SetTitleColor(1);
216 fHistPSideRMSCMMapLayer6->GetZaxis()->SetRangeUser(0.,20.);
217 fHistPSideRMSCMMapLayer6->SetStats(kFALSE);
218 fHistPSideRMSCMMapLayer6->GetYaxis()->SetTitleOffset(1.8);
219 fHistPSideRMSCMMapLayer6->GetXaxis()->SetNdivisions(25);
220 fHistPSideRMSCMMapLayer6->GetYaxis()->SetNdivisions(38);
221 fHistPSideRMSCMMapLayer6->GetXaxis()->SetLabelSize(0.03);
222 fHistPSideRMSCMMapLayer6->GetYaxis()->SetLabelSize(0.03);
223 fHistPSideRMSCMMapLayer6->GetZaxis()->SetTitleOffset(1.6);
224 fHistPSideRMSCMMapLayer6->GetZaxis()->SetTitle("RMS(CM) (p-side)");
226 TH2F *fHistNSideRMSCMMapLayer6 = new TH2F("fHistNSideRMSCMMapLayer6",
227 "Layer 6 - N side;N_{module};N_{ladder}",
230 fHistNSideRMSCMMapLayer6->GetXaxis()->SetTitleColor(1);
231 fHistNSideRMSCMMapLayer6->GetZaxis()->SetRangeUser(0.,20.);
232 fHistNSideRMSCMMapLayer6->SetStats(kFALSE);
233 fHistNSideRMSCMMapLayer6->GetYaxis()->SetTitleOffset(1.8);
234 fHistNSideRMSCMMapLayer6->GetXaxis()->SetNdivisions(25);
235 fHistNSideRMSCMMapLayer6->GetYaxis()->SetNdivisions(38);
236 fHistNSideRMSCMMapLayer6->GetXaxis()->SetLabelSize(0.03);
237 fHistNSideRMSCMMapLayer6->GetYaxis()->SetLabelSize(0.03);
238 fHistNSideRMSCMMapLayer6->GetZaxis()->SetTitleOffset(1.6);
239 fHistNSideRMSCMMapLayer6->GetZaxis()->SetTitle("RMS(CM) (n-side)");
240 //==================================================//
242 TChain *chain = new TChain("RAW");
243 chain->Add(filename);
244 Int_t nTotalEvents = chain->GetEntries();
245 if(nEvents == -1) nEvents = nTotalEvents;
247 AliRawReaderRoot *rawReader = new AliRawReaderRoot(filename);
250 for(iEvent = 0; iEvent < nEvents; iEvent++) {
251 cout<<"Event: "<<iEvent+1<<"/"<<nEvents<<endl;
252 rawReader->Select("ITSSSD",-1,-1);
254 rawReader->NextEvent();
256 if(rawReader->GetType() != 7) continue;
259 AliITSRawStreamSSD gSSDStream(rawReader);
260 while (gSSDStream.Next()) {
261 if(gSSDStream.GetModuleID() < 0) continue;
262 AliITSgeomTGeo::GetModuleId(gSSDStream.GetModuleID(),gLayer,gLadder,gModule);
263 //if(gSSDStream.GetModuleID() != 500) continue;
264 //Printf("Module id: %d - Layer: %d - Ladder: %d - Module: %d",gSSDStream.GetModuleID(),gLayer,gLadder,gModule);
266 if(gSSDStream.GetStrip() >= 0) continue;
267 gStripNumber = (gSSDStream.GetSideFlag() == 0) ? gSSDStream.GetStrip() : -gSSDStream.GetStrip() + 2*fgkNumberOfPSideStrips;
268 //Printf("Module id: %d - Strip: %d - strip number: %d - Signal: %lf",gSSDStream.GetModuleID(),gSSDStream.GetStrip(),gStripNumber,signal);
269 if(TMath::Abs(gSSDStream.GetStrip()) < 7)
270 ((TH1*)list->At((gSSDStream.GetModuleID()-500)*fgkNumOfChips+gSSDStream.GetStrip()))->Fill(gSSDStream.GetSignal());
271 if(TMath::Abs(gSSDStream.GetStrip()) > 6)
272 ((TH1*)list->At(fgkSSDMODULES*fgkNumOfChips+(gSSDStream.GetModuleID()-500)*fgkNumOfChips+gSSDStream.GetStrip()))->Fill(gSSDStream.GetSignal());
276 //compute the rms of the CM values
277 TH1F *gHistCMDummy = new TH1F("gHistCMDummy","",100,-50.,50.);
278 Double_t meanPsideCM = 0.0, meanNsideCM = 0.0;
279 Double_t rmsPsideCM = 0.0, rmsNsideCM = 0.0;
280 for(Int_t iModule = 0; iModule < fgkSSDMODULES; iModule++) {
281 meanPsideCM = 0.0; meanNsideCM = 0.0;
282 rmsPsideCM = 0.0; rmsNsideCM = 0.0;
283 AliITSgeomTGeo::GetModuleId(iModule+500,gLayer,gLadder,gModule);
285 gHistCMDummy->Clear();
286 for(Int_t iChip = 0; iChip < fgkNumOfChips; iChip++) {
287 //cout<<"Name: "<<dynamic_cast<TH1*>(list->At(iModule*fgkNumOfChips+iChip))->GetName()<<endl;
288 gHistCMDummy->Add((TH1*)list->At(iModule*fgkNumOfChips+iChip));
290 meanPsideCM = TMath::Abs(gHistCMDummy->GetMean());
291 rmsPsideCM = gHistCMDummy->GetRMS();
293 gHistCMDummy->Clear();
294 for(Int_t iChip = 0; iChip < fgkNumOfChips; iChip++) {
295 //cout<<"Name: "<<dynamic_cast<TH1*>(list->At(fgkSSDMODULES*fgkNumOfChips+iModule*fgkNumOfChips+iChip))->GetName()<<endl;
296 gHistCMDummy->Add((TH1*)list->At(fgkSSDMODULES*fgkNumOfChips+iModule*fgkNumOfChips+iChip));
298 meanNsideCM = TMath::Abs(gHistCMDummy->GetMean());
299 rmsNsideCM = gHistCMDummy->GetRMS();
301 if(meanPsideCM == 0) meanPsideCM = 0.001;
302 if(meanNsideCM == 0) meanNsideCM = 0.001;
303 if(rmsPsideCM == 0) rmsPsideCM = 0.001;
304 if(rmsNsideCM == 0) rmsNsideCM = 0.001;
307 fHistPSideMeanCMMapLayer5->SetBinContent(gModule,gLadder,meanPsideCM);
308 fHistNSideMeanCMMapLayer5->SetBinContent(gModule,gLadder,meanNsideCM);
309 fHistPSideRMSCMMapLayer5->SetBinContent(gModule,gLadder,rmsPsideCM);
310 fHistNSideRMSCMMapLayer5->SetBinContent(gModule,gLadder,rmsNsideCM);
313 fHistPSideMeanCMMapLayer6->SetBinContent(gModule,gLadder,meanPsideCM);
314 fHistNSideMeanCMMapLayer6->SetBinContent(gModule,gLadder,meanNsideCM);
315 fHistPSideRMSCMMapLayer6->SetBinContent(gModule,gLadder,rmsPsideCM);
316 fHistNSideRMSCMMapLayer6->SetBinContent(gModule,gLadder,rmsNsideCM);
320 TFile *foutput = TFile::Open("SSD.CM.root","recreate");
322 fHistPSideMeanCMMapLayer5->Write(); fHistNSideMeanCMMapLayer5->Write();
323 fHistPSideMeanCMMapLayer6->Write(); fHistNSideMeanCMMapLayer6->Write();
324 fHistPSideRMSCMMapLayer5->Write(); fHistNSideRMSCMMapLayer5->Write();
325 fHistPSideRMSCMMapLayer6->Write(); fHistNSideRMSCMMapLayer6->Write();
329 //__________________________________________________________//
330 void drawSSDCM(const char* filename = "SSD.CM.root") {
331 gStyle->SetPalette(1,0);
333 TFile *f = TFile::Open(filename);
335 TCanvas *c1 = new TCanvas("c1","Mean of CM values",0,0,700,650);
336 c1->SetFillColor(10); c1->SetHighLightColor(10); c1->Divide(2,2);
338 TH2F *fHistPSideMeanCMMapLayer5 = dynamic_cast<TH2F *>(f->Get("fHistPSideMeanCMMapLayer5"));
339 fHistPSideMeanCMMapLayer5->Draw("colz");
341 TH2F *fHistNSideMeanCMMapLayer5 = dynamic_cast<TH2F *>(f->Get("fHistNSideMeanCMMapLayer5"));
342 fHistNSideMeanCMMapLayer5->Draw("colz");
344 TH2F *fHistPSideMeanCMMapLayer6 = dynamic_cast<TH2F *>(f->Get("fHistPSideMeanCMMapLayer6"));
345 fHistPSideMeanCMMapLayer6->Draw("colz");
347 TH2F *fHistNSideMeanCMMapLayer6 = dynamic_cast<TH2F *>(f->Get("fHistNSideMeanCMMapLayer6"));
348 fHistNSideMeanCMMapLayer6->Draw("colz");
350 TCanvas *c2 = new TCanvas("c2","RMS of CM values",100,100,700,650);
351 c2->SetFillColor(10); c2->SetHighLightColor(10); c2->Divide(2,2);
353 TH2F *fHistPSideRMSCMMapLayer5 = dynamic_cast<TH2F *>(f->Get("fHistPSideRMSCMMapLayer5"));
354 fHistPSideRMSCMMapLayer5->Draw("colz");
356 TH2F *fHistNSideRMSCMMapLayer5 = dynamic_cast<TH2F *>(f->Get("fHistNSideRMSCMMapLayer5"));
357 fHistNSideRMSCMMapLayer5->Draw("colz");
359 TH2F *fHistPSideRMSCMMapLayer6 = dynamic_cast<TH2F *>(f->Get("fHistPSideRMSCMMapLayer6"));
360 fHistPSideRMSCMMapLayer6->Draw("colz");
362 TH2F *fHistNSideRMSCMMapLayer6 = dynamic_cast<TH2F *>(f->Get("fHistNSideRMSCMMapLayer6"));
363 fHistNSideRMSCMMapLayer6->Draw("colz");
366 //__________________________________________________________//
367 void checkCM(const char* filename) {
368 //Reads the SSD.CM.root file as an input.
369 //For every chip checks the mean and the rms of the CM distributions.
370 //If the absolute value of the mean is beyond 5 ADC counts or/and the
371 //rms is beyond 10, the corresponding histogram is added to the list
372 //of suspicious chips. This list is written to the output file having
373 //the name: SSD.FaultyChips.root
375 //Hardcoded check values
376 const Double_t meanMax = 5.;
377 const Double_t rmsMax = 10.;
380 TList *listOfSuspiciousChips = new TList();
383 TFile *fInput = TFile::Open(filename);
385 Int_t gLayer = 0,gLadder = 0, gModule = 0;
387 //Double_t meanValue = 0.0, rmsValue = 0.0;
388 TH1F *gHistSSDCMModule = 0x0;
390 for(Int_t iModule = 500; iModule < fgkSSDMODULES + 500; iModule++) {
391 AliITSgeomTGeo::GetModuleId(iModule,gLayer,gLadder,gModule);
392 for(Int_t iChip = 0; iChip < fgkNumOfChips; iChip++) {
393 gTitle = "SSD_CM_PSide_Layer"; gTitle += gLayer;
394 gTitle += "_Ladder"; gTitle += gLadder;
395 gTitle += "_Module"; gTitle += gModule;
396 gTitle += "_Chip"; gTitle += iChip+1;
397 gHistSSDCMModule = dynamic_cast<TH1F *>(fInput->Get(gTitle.Data()));
398 if((TMath::Abs(gHistSSDCMModule->GetMean(1)) > meanMax)||
399 (TMath::Abs(gHistSSDCMModule->GetRMS(1)) > rmsMax)) {
400 Printf("Name: %s, Mean: %lf - rms: %lf",
401 gHistSSDCMModule->GetName(),
402 TMath::Abs(gHistSSDCMModule->GetMean(1)),
403 TMath::Abs(gHistSSDCMModule->GetRMS(1)));
404 listOfSuspiciousChips->Add(gHistSSDCMModule);
410 for(Int_t iModule = 500; iModule < fgkSSDMODULES + 500; iModule++) {
411 AliITSgeomTGeo::GetModuleId(iModule,gLayer,gLadder,gModule);
412 for(Int_t iChip = 0; iChip < fgkNumOfChips; iChip++) {
413 gTitle = "SSD_CM_NSide_Layer"; gTitle += gLayer;
414 gTitle += "_Ladder"; gTitle += gLadder;
415 gTitle += "_Module"; gTitle += gModule;
416 gTitle += "_Chip"; gTitle += iChip+1;
417 gHistSSDCMModule = dynamic_cast<TH1F *>(fInput->Get(gTitle.Data()));
418 if((TMath::Abs(gHistSSDCMModule->GetMean(1)) > meanMax)||
419 (TMath::Abs(gHistSSDCMModule->GetRMS(1)) > rmsMax)) {
420 Printf("Name: %s, Mean: %lf - rms: %lf",
421 gHistSSDCMModule->GetName(),
422 TMath::Abs(gHistSSDCMModule->GetMean(1)),
423 TMath::Abs(gHistSSDCMModule->GetRMS(1)));
424 listOfSuspiciousChips->Add(gHistSSDCMModule);
426 //Printf("Name: %s",gHistSSDCMModule->GetName());
430 Printf("===============================================");
431 Printf("%d suspicious chips were put in the list",
432 listOfSuspiciousChips->GetEntries());
433 Printf("===============================================");
434 TFile *fOutput = new TFile("SSD.FaultyChips.root","recreate");
435 listOfSuspiciousChips->Write();
441 //__________________________________________________________//
442 void compareChipLists(TString inputFile1,
445 //Compare two different lists of chips and put those present in both files
448 TFile *fInput1 = TFile::Open(inputFile1.Data());
449 TList *listOfSuspiciousChips1 = new TList();
450 listOfSuspiciousChips1=fInput1->GetListOfKeys();
451 TFile *fInput2 = TFile::Open(inputFile2.Data());
452 TList *listOfSuspiciousChips2 = new TList();
453 listOfSuspiciousChips2=fInput2->GetListOfKeys();
455 Int_t Nentries1 = 0, Nentries2 = 0, k = 0;
456 Nentries1 = listOfSuspiciousChips1->GetEntries();
457 Nentries2 = listOfSuspiciousChips2->GetEntries();
460 TList *listOfRecurrentChips = new TList();
463 for(Int_t i=0; i<Nentries1; i++){
464 TH1F *h1 = dynamic_cast <TH1F*>(fInput1->Get(listOfSuspiciousChips1->At(i)->GetName()));
465 for(Int_t j=0; j<Nentries2; j++){
466 TH1F *h2 = dynamic_cast <TH1F*>(fInput2->Get(listOfSuspiciousChips2->At(j)->GetName()));
468 if (!Name1.CompareTo(h2->GetName())) {
469 cout << Name1.CompareTo(h2->GetName()) <<
470 " " << h2->GetName() << endl;
472 listOfRecurrentChips->Add(h1);
477 Printf("%i Faulty chips in the first file", Nentries1);
478 Printf("%i Faulty chips in the second file", Nentries2);
479 Printf("%i Recurrent Faulty chips", k+1);
481 TString outputFile = "SSD.RecurrentFaultyChips."; outputFile += outputTxt;
482 outputFile += ".root";
484 TFile *fOutput = new TFile(outputFile.Data(),"recreate");
485 listOfRecurrentChips->Write();
492 //__________________________________________________________//
493 void makeCM2D(const char* filename, Int_t nEvents) {
494 //Function to read the CM values
495 gStyle->SetPalette(1,0);
496 Int_t gStripNumber = 0;
497 Int_t gLayer = 0,gLadder = 0, gModule = 0;
499 //==================================================//
500 AliCDBManager *fCDBManager = AliCDBManager::Instance();
501 fCDBManager->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
502 Int_t runNumber = atoi(gSystem->Getenv("DATE_RUN_NUMBER"));
504 Printf("DATE_RUN_NUMBER not defined!!!\n");
506 fCDBManager->SetRun(runNumber);
507 AliCDBEntry *geomGRP = fCDBManager->Get("GRP/Geometry/Data");
508 if(!geomGRP) cout<<"GRP geometry not found!!!"<<endl;;
509 //==================================================//
511 //==================================================//
512 TList *list = new TList();
513 TH2F *gHistCM2D[fgkSSDMODULES];
514 TString gHistoTitle, gArrayTitle;
515 Int_t gHistCounter = 0;
516 for(Int_t iModule = 500; iModule < fgkSSDMODULES + 500; iModule++) {
517 AliITSgeomTGeo::GetModuleId(iModule,gLayer,gLadder,gModule);
518 gHistoTitle = "SSD_CM_Layer"; gHistoTitle += gLayer;
519 gHistoTitle += "_Ladder"; gHistoTitle += gLadder;
520 gHistoTitle += "_Module"; gHistoTitle += gModule;
521 //Printf("Title: %s",gHistoTitle.Data());
522 gHistCM2D[gHistCounter] = new TH2F(gHistoTitle.Data(),
526 gHistCM2D[gHistCounter]->SetStats(kFALSE);
527 gHistCM2D[gHistCounter]->GetXaxis()->SetTitleColor(1);
528 gHistCM2D[gHistCounter]->GetZaxis()->SetTitle("Entries");
529 gHistCM2D[gHistCounter]->GetYaxis()->SetTitle("CM");
530 gHistCM2D[gHistCounter]->GetXaxis()->SetTitle("Chip number");
531 gHistCM2D[gHistCounter]->GetXaxis()->SetNdivisions(12);
532 list->Add(gHistCM2D[gHistCounter]);
535 //Printf("List entries: %d",list->GetEntries());
536 //==================================================//
538 TChain *chain = new TChain("RAW");
539 chain->Add(filename);
540 Int_t nTotalEvents = chain->GetEntries();
541 if(nEvents == -1) nEvents = nTotalEvents;
543 AliRawReaderRoot *rawReader = new AliRawReaderRoot(filename);
546 for(iEvent = 0; iEvent < nEvents; iEvent++) {
547 cout<<"Event: "<<iEvent+1<<"/"<<nEvents<<endl;
548 rawReader->Select("ITSSSD",-1,-1);
550 rawReader->NextEvent();
552 if(rawReader->GetType() != 7) continue;
555 AliITSRawStreamSSD gSSDStream(rawReader);
556 while (gSSDStream.Next()) {
557 if(gSSDStream.GetModuleID() < 0) continue;
558 AliITSgeomTGeo::GetModuleId(gSSDStream.GetModuleID(),gLayer,gLadder,gModule);
559 //if(gSSDStream.GetModuleID() != 500) continue;
560 //Printf("Module id: %d - Layer: %d - Ladder: %d - Module: %d",gSSDStream.GetModuleID(),gLayer,gLadder,gModule);
562 if(gSSDStream.GetStrip() >= 0) continue;
563 gStripNumber = (gSSDStream.GetSideFlag() == 0) ? gSSDStream.GetStrip() : -gSSDStream.GetStrip() + 2*fgkNumberOfPSideStrips;
564 //Printf("Module id: %d - Strip: %d - strip number: %d - Signal: %lf",gSSDStream.GetModuleID(),gSSDStream.GetStrip(),gStripNumber,gSSDStream.GetSignal());
565 gHistCM2D[gSSDStream.GetModuleID()-500]->Fill(TMath::Abs(gSSDStream.GetStrip()),gSSDStream.GetSignal());
569 TCanvas *cLayer5[34];
570 TCanvas *cLayer6[38];
572 for(Int_t iLadder = 1; iLadder < 35; iLadder++) {
573 canvasTitle = "SSD_CM_Layer5_Ladder"; canvasTitle += iLadder;
574 cLayer5[iLadder-1] = new TCanvas(canvasTitle.Data(),
576 cLayer5[iLadder-1]->Divide(5,5);
577 for(Int_t iModule = 1; iModule < 23; iModule++) {
578 cLayer5[iLadder-1]->cd(iModule);
579 gHistCM2D[(iLadder-1)*fgkSSDMODULESPERLADDERLAYER5 + iModule - 1]->Draw("colz");
581 if(iLadder == 1) cLayer5[iLadder-1]->Print("CommonModePlotsLayer5.ps(");
582 if(iLadder == 34) cLayer5[iLadder-1]->Print("CommonModePlotsLayer5.ps)");
583 else cLayer5[iLadder-1]->Print("CommonModePlotsLayer5.ps");
584 //Printf("Ladder %d finished...",499+iLadder);
587 for(Int_t iLadder = 1; iLadder < 39; iLadder++) {
588 canvasTitle = "SSD_CM_Layer6_Ladder"; canvasTitle += iLadder;
589 cLayer6[iLadder-1] = new TCanvas(canvasTitle.Data(),
591 cLayer6[iLadder-1]->Divide(5,5);
592 for(Int_t iModule = 1; iModule < 26; iModule++) {
593 cLayer6[iLadder-1]->cd(iModule);
594 gHistCM2D[fgkSSDMODULESLAYER5 + (iLadder-1)*fgkSSDMODULESPERLADDERLAYER6 + iModule - 1]->Draw("colz");
596 if(iLadder == 1) cLayer6[iLadder-1]->Print("CommonModePlotsLayer6.ps(");
597 if(iLadder == 38) cLayer6[iLadder-1]->Print("CommonModePlotsLayer6.ps)");
598 else cLayer6[iLadder-1]->Print("CommonModePlotsLayer6.ps");
599 //Printf("Ladder %d finished...",599+iLadder);
603 TFile *foutput = TFile::Open("SSD.CM2D.root","recreate");