]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/readSSDCommonMode.C
Removed debug printout in iterations
[u/mrichter/AliRoot.git] / ITS / readSSDCommonMode.C
CommitLineData
f5a5ae3e 1#if !defined(__CINT__) || defined(__MAKECINT__)
2#include "TString.h"
3#include "TH1.h"
4#include "TH2.h"
5#include "TFile.h"
6#include "TList.h"
7#include "TChain.h"
8#include "TObject.h"
9#include "TCanvas.h"
10#include "TStyle.h"
11#include "TSystem.h"
12#include "Riostream.h"
13
14#include "AliITSgeomTGeo.h"
15#include "AliLog.h"
16#include "AliRawReaderRoot.h"
17#include "AliITSRawStreamSSD.h"
18#include "AliCDBManager.h"
19#include "AliCDBEntry.h"
20#endif
21
22/* $Id: $ */
23
24//============================================================//
af105157 25static const Int_t fgkNumOfChips = 6; //number of SSD chips per module per side
f5a5ae3e 26static const Int_t fgkNumOfLDCs = 8; //number of SSD LDCs
27static const Int_t fgkNumOfDDLs = 16; //number of SSD DDLs
28static const Int_t fgkSSDMODULES = 1698; //total number of SSD modules
29static const Int_t fgkSSDLADDERSLAYER5 = 34; //ladders on layer 5
30static const Int_t fgkSSDLADDERSLAYER6 = 38; //ladders on layer 6
31static const Int_t fgkSSDMODULESPERLADDERLAYER5 = 22; //modules per ladder - layer 5
32static const Int_t fgkSSDMODULESPERLADDERLAYER6 = 25; //modules per ladder - layer 6
33static const Int_t fgkSSDMODULESLAYER5 = 748; //total number of SSD modules - layer5
34static const Int_t fgkSSDMODULESLAYER6 = 950; //total number of SSD modules - layer6
35static const Int_t fgkNumberOfPSideStrips = 768; //number of P-side strips
36//============================================================//
37
38TList *initCM();
39void makeCM(const char* filename, Int_t nEvents, TList *list);
a56fec3e 40void checkCM(const char* filename);
f5a5ae3e 41
42//__________________________________________________________//
43void readSSDCommonMode(const char* filename = "raw.root",
44 Int_t nEvents = -1) {
45 //Reads the CM pseudo-channels and produces the CM map for both layers
46 //and for p and n-side.
47 gStyle->SetPalette(1,0);
48
49 TList *list = initCM();
50 //list->ls();
51 Printf("CM histograms: %d",list->GetEntries());
52 makeCM(filename,nEvents,list);
53}
54
55//__________________________________________________________//
56TList *initCM() {
57 //Initializes the histograms and returns the TList object
58 TList *list = new TList();
59
60 Int_t gLayer = 0,gLadder = 0, gModule = 0;
61 Int_t gHistCounter = 0;
62 TString gTitle;
af105157 63 TH1F *gHistSSDCMModule[2*fgkSSDMODULES][fgkNumOfChips];
f5a5ae3e 64 for(Int_t iModule = 500; iModule < fgkSSDMODULES + 500; iModule++) {
65 AliITSgeomTGeo::GetModuleId(iModule,gLayer,gLadder,gModule);
af105157 66 for(Int_t iChip = 0; iChip < fgkNumOfChips; iChip++) {
67 gTitle = "SSD_CM_PSide_Layer"; gTitle += gLayer;
68 gTitle += "_Ladder"; gTitle += gLadder;
69 gTitle += "_Module"; gTitle += gModule;
70 gTitle += "_Chip"; gTitle += iChip+1;
71 gHistSSDCMModule[gHistCounter][iChip] = new TH1F(gTitle.Data(),
72 gTitle.Data(),
73 100,-50.,50.);
74 gHistSSDCMModule[gHistCounter][iChip]->GetXaxis()->SetTitle("CM");
75 list->Add(gHistSSDCMModule[gHistCounter][iChip]);
76 }
f5a5ae3e 77 gHistCounter += 1;
78 }
79 for(Int_t iModule = 500; iModule < fgkSSDMODULES + 500; iModule++) {
80 AliITSgeomTGeo::GetModuleId(iModule,gLayer,gLadder,gModule);
af105157 81 for(Int_t iChip = 0; iChip < fgkNumOfChips; iChip++) {
82 gTitle = "SSD_CM_NSide_Layer"; gTitle += gLayer;
83 gTitle += "_Ladder"; gTitle += gLadder;
84 gTitle += "_Module"; gTitle += gModule;
85 gTitle += "_Chip"; gTitle += iChip+1;
86 gHistSSDCMModule[gHistCounter][iChip] = new TH1F(gTitle.Data(),
87 gTitle.Data(),
88 100,-50.,50.);
89 gHistSSDCMModule[gHistCounter][iChip]->GetXaxis()->SetTitle("CM");
90 list->Add(gHistSSDCMModule[gHistCounter][iChip]);
91 }
f5a5ae3e 92 gHistCounter += 1;
93 }
94
95 return list;
96}
97
98//__________________________________________________________//
99void makeCM(const char* filename, Int_t nEvents, TList *list) {
100 //Function to read the CM values
101 Int_t gStripNumber = 0;
102 Int_t gLayer = 0,gLadder = 0, gModule = 0;
103
104 //==================================================//
105 AliCDBManager *fCDBManager = AliCDBManager::Instance();
106 fCDBManager->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
107 Int_t runNumber = atoi(gSystem->Getenv("DATE_RUN_NUMBER"));
108 if(!runNumber)
109 Printf("DATE_RUN_NUMBER not defined!!!\n");
110
111 fCDBManager->SetRun(runNumber);
112 AliCDBEntry *geomGRP = fCDBManager->Get("GRP/Geometry/Data");
113 if(!geomGRP) cout<<"GRP geometry not found!!!"<<endl;;
114 //==================================================//
115
116 //==================================================//
af105157 117 TH2F *fHistPSideMeanCMMapLayer5 = new TH2F("fHistPSideMeanCMMapLayer5",
118 "Layer 5 - P side;N_{module};N_{ladder}",
119 22,1,23,
120 34,500,534);
121 fHistPSideMeanCMMapLayer5->GetXaxis()->SetTitleColor(1);
122 fHistPSideMeanCMMapLayer5->GetZaxis()->SetRangeUser(0.,20.);
123 fHistPSideMeanCMMapLayer5->SetStats(kFALSE);
124 fHistPSideMeanCMMapLayer5->GetYaxis()->SetTitleOffset(1.8);
125 fHistPSideMeanCMMapLayer5->GetXaxis()->SetNdivisions(22);
126 fHistPSideMeanCMMapLayer5->GetYaxis()->SetNdivisions(34);
127 fHistPSideMeanCMMapLayer5->GetXaxis()->SetLabelSize(0.03);
128 fHistPSideMeanCMMapLayer5->GetYaxis()->SetLabelSize(0.03);
129 fHistPSideMeanCMMapLayer5->GetZaxis()->SetTitleOffset(1.6);
130 fHistPSideMeanCMMapLayer5->GetZaxis()->SetTitle("RMS(CM) (p-side)");
131
132 TH2F *fHistNSideMeanCMMapLayer5 = new TH2F("fHistNSideMeanCMMapLayer5",
133 "Layer 5 - N side;N_{module};N_{ladder}",
134 22,1,23,
135 34,500,534);
136 fHistNSideMeanCMMapLayer5->GetXaxis()->SetTitleColor(1);
137 fHistNSideMeanCMMapLayer5->GetZaxis()->SetRangeUser(0.,20.);
138 fHistNSideMeanCMMapLayer5->SetStats(kFALSE);
139 fHistNSideMeanCMMapLayer5->GetYaxis()->SetTitleOffset(1.8);
140 fHistNSideMeanCMMapLayer5->GetXaxis()->SetNdivisions(22);
141 fHistNSideMeanCMMapLayer5->GetYaxis()->SetNdivisions(34);
142 fHistNSideMeanCMMapLayer5->GetXaxis()->SetLabelSize(0.03);
143 fHistNSideMeanCMMapLayer5->GetYaxis()->SetLabelSize(0.03);
144 fHistNSideMeanCMMapLayer5->GetZaxis()->SetTitleOffset(1.6);
145 fHistNSideMeanCMMapLayer5->GetZaxis()->SetTitle("RMS(CM) (n-side)");
146
147 TH2F *fHistPSideMeanCMMapLayer6 = new TH2F("fHistPSideMeanCMMapLayer6",
148 "Layer 6 - P side;N_{module};N_{ladder}",
149 25,1,26,
150 38,600,638);
151 fHistPSideMeanCMMapLayer6->GetXaxis()->SetTitleColor(1);
152 fHistPSideMeanCMMapLayer6->GetZaxis()->SetRangeUser(0.,20.);
153 fHistPSideMeanCMMapLayer6->SetStats(kFALSE);
154 fHistPSideMeanCMMapLayer6->GetYaxis()->SetTitleOffset(1.8);
155 fHistPSideMeanCMMapLayer6->GetXaxis()->SetNdivisions(25);
156 fHistPSideMeanCMMapLayer6->GetYaxis()->SetNdivisions(38);
157 fHistPSideMeanCMMapLayer6->GetXaxis()->SetLabelSize(0.03);
158 fHistPSideMeanCMMapLayer6->GetYaxis()->SetLabelSize(0.03);
159 fHistPSideMeanCMMapLayer6->GetZaxis()->SetTitleOffset(1.6);
160 fHistPSideMeanCMMapLayer6->GetZaxis()->SetTitle("RMS(CM) (p-side)");
161
162 TH2F *fHistNSideMeanCMMapLayer6 = new TH2F("fHistNSideMeanCMMapLayer6",
163 "Layer 6 - N side;N_{module};N_{ladder}",
164 25,1,26,
165 38,600,638);
166 fHistNSideMeanCMMapLayer6->GetXaxis()->SetTitleColor(1);
167 fHistNSideMeanCMMapLayer6->GetZaxis()->SetRangeUser(0.,20.);
168 fHistNSideMeanCMMapLayer6->SetStats(kFALSE);
169 fHistNSideMeanCMMapLayer6->GetYaxis()->SetTitleOffset(1.8);
170 fHistNSideMeanCMMapLayer6->GetXaxis()->SetNdivisions(25);
171 fHistNSideMeanCMMapLayer6->GetYaxis()->SetNdivisions(38);
172 fHistNSideMeanCMMapLayer6->GetXaxis()->SetLabelSize(0.03);
173 fHistNSideMeanCMMapLayer6->GetYaxis()->SetLabelSize(0.03);
174 fHistNSideMeanCMMapLayer6->GetZaxis()->SetTitleOffset(1.6);
175 fHistNSideMeanCMMapLayer6->GetZaxis()->SetTitle("RMS(CM) (n-side)");
176
177 //____________________________________________________________//
178 TH2F *fHistPSideRMSCMMapLayer5 = new TH2F("fHistPSideRMSCMMapLayer5",
f5a5ae3e 179 "Layer 5 - P side;N_{module};N_{ladder}",
180 22,1,23,
181 34,500,534);
af105157 182 fHistPSideRMSCMMapLayer5->GetXaxis()->SetTitleColor(1);
183 fHistPSideRMSCMMapLayer5->GetZaxis()->SetRangeUser(0.,20.);
184 fHistPSideRMSCMMapLayer5->SetStats(kFALSE);
185 fHistPSideRMSCMMapLayer5->GetYaxis()->SetTitleOffset(1.8);
186 fHistPSideRMSCMMapLayer5->GetXaxis()->SetNdivisions(22);
187 fHistPSideRMSCMMapLayer5->GetYaxis()->SetNdivisions(34);
188 fHistPSideRMSCMMapLayer5->GetXaxis()->SetLabelSize(0.03);
189 fHistPSideRMSCMMapLayer5->GetYaxis()->SetLabelSize(0.03);
190 fHistPSideRMSCMMapLayer5->GetZaxis()->SetTitleOffset(1.6);
191 fHistPSideRMSCMMapLayer5->GetZaxis()->SetTitle("RMS(CM) (p-side)");
192
193 TH2F *fHistNSideRMSCMMapLayer5 = new TH2F("fHistNSideRMSCMMapLayer5",
f5a5ae3e 194 "Layer 5 - N side;N_{module};N_{ladder}",
195 22,1,23,
196 34,500,534);
af105157 197 fHistNSideRMSCMMapLayer5->GetXaxis()->SetTitleColor(1);
198 fHistNSideRMSCMMapLayer5->GetZaxis()->SetRangeUser(0.,20.);
199 fHistNSideRMSCMMapLayer5->SetStats(kFALSE);
200 fHistNSideRMSCMMapLayer5->GetYaxis()->SetTitleOffset(1.8);
201 fHistNSideRMSCMMapLayer5->GetXaxis()->SetNdivisions(22);
202 fHistNSideRMSCMMapLayer5->GetYaxis()->SetNdivisions(34);
203 fHistNSideRMSCMMapLayer5->GetXaxis()->SetLabelSize(0.03);
204 fHistNSideRMSCMMapLayer5->GetYaxis()->SetLabelSize(0.03);
205 fHistNSideRMSCMMapLayer5->GetZaxis()->SetTitleOffset(1.6);
206 fHistNSideRMSCMMapLayer5->GetZaxis()->SetTitle("RMS(CM) (n-side)");
f5a5ae3e 207
af105157 208 TH2F *fHistPSideRMSCMMapLayer6 = new TH2F("fHistPSideRMSCMMapLayer6",
f5a5ae3e 209 "Layer 6 - P side;N_{module};N_{ladder}",
210 25,1,26,
211 38,600,638);
af105157 212 fHistPSideRMSCMMapLayer6->GetXaxis()->SetTitleColor(1);
213 fHistPSideRMSCMMapLayer6->GetZaxis()->SetRangeUser(0.,20.);
214 fHistPSideRMSCMMapLayer6->SetStats(kFALSE);
215 fHistPSideRMSCMMapLayer6->GetYaxis()->SetTitleOffset(1.8);
216 fHistPSideRMSCMMapLayer6->GetXaxis()->SetNdivisions(25);
217 fHistPSideRMSCMMapLayer6->GetYaxis()->SetNdivisions(38);
218 fHistPSideRMSCMMapLayer6->GetXaxis()->SetLabelSize(0.03);
219 fHistPSideRMSCMMapLayer6->GetYaxis()->SetLabelSize(0.03);
220 fHistPSideRMSCMMapLayer6->GetZaxis()->SetTitleOffset(1.6);
221 fHistPSideRMSCMMapLayer6->GetZaxis()->SetTitle("RMS(CM) (p-side)");
222
223 TH2F *fHistNSideRMSCMMapLayer6 = new TH2F("fHistNSideRMSCMMapLayer6",
f5a5ae3e 224 "Layer 6 - N side;N_{module};N_{ladder}",
225 25,1,26,
226 38,600,638);
af105157 227 fHistNSideRMSCMMapLayer6->GetXaxis()->SetTitleColor(1);
228 fHistNSideRMSCMMapLayer6->GetZaxis()->SetRangeUser(0.,20.);
229 fHistNSideRMSCMMapLayer6->SetStats(kFALSE);
230 fHistNSideRMSCMMapLayer6->GetYaxis()->SetTitleOffset(1.8);
231 fHistNSideRMSCMMapLayer6->GetXaxis()->SetNdivisions(25);
232 fHistNSideRMSCMMapLayer6->GetYaxis()->SetNdivisions(38);
233 fHistNSideRMSCMMapLayer6->GetXaxis()->SetLabelSize(0.03);
234 fHistNSideRMSCMMapLayer6->GetYaxis()->SetLabelSize(0.03);
235 fHistNSideRMSCMMapLayer6->GetZaxis()->SetTitleOffset(1.6);
236 fHistNSideRMSCMMapLayer6->GetZaxis()->SetTitle("RMS(CM) (n-side)");
f5a5ae3e 237 //==================================================//
238
239 TChain *chain = new TChain("RAW");
240 chain->Add(filename);
241 Int_t nTotalEvents = chain->GetEntries();
242 if(nEvents == -1) nEvents = nTotalEvents;
243
244 AliRawReaderRoot *rawReader = new AliRawReaderRoot(filename);
245 Int_t iEvent = 0;
246 Int_t fSSDEvent = 0;
247 for(iEvent = 0; iEvent < nEvents; iEvent++) {
248 cout<<"Event: "<<iEvent+1<<"/"<<nEvents<<endl;
249 rawReader->Select("ITSSSD",-1,-1);
250 rawReader->Reset();
251 rawReader->NextEvent();
252
253 if(rawReader->GetType() != 7) continue;
254
255 fSSDEvent += 1;
256 AliITSRawStreamSSD gSSDStream(rawReader);
257 while (gSSDStream.Next()) {
258 if(gSSDStream.GetModuleID() < 0) continue;
259 AliITSgeomTGeo::GetModuleId(gSSDStream.GetModuleID(),gLayer,gLadder,gModule);
260 //if(gSSDStream.GetModuleID() != 500) continue;
261 //Printf("Module id: %d - Layer: %d - Ladder: %d - Module: %d",gSSDStream.GetModuleID(),gLayer,gLadder,gModule);
262
263 if(gSSDStream.GetStrip() >= 0) continue;
264 gStripNumber = (gSSDStream.GetSideFlag() == 0) ? gSSDStream.GetStrip() : -gSSDStream.GetStrip() + 2*fgkNumberOfPSideStrips;
265 //Printf("Module id: %d - Strip: %d - strip number: %d - Signal: %lf",gSSDStream.GetModuleID(),gSSDStream.GetStrip(),gStripNumber,signal);
266 if(TMath::Abs(gSSDStream.GetStrip()) < 7)
af105157 267 ((TH1*)list->At((gSSDStream.GetModuleID()-500)*fgkNumOfChips+gSSDStream.GetStrip()))->Fill(gSSDStream.GetSignal());
f5a5ae3e 268 if(TMath::Abs(gSSDStream.GetStrip()) > 6)
af105157 269 ((TH1*)list->At(fgkSSDMODULES*fgkNumOfChips+(gSSDStream.GetModuleID()-500)*fgkNumOfChips+gSSDStream.GetStrip()-fgkNumOfChips))->Fill(gSSDStream.GetSignal());
f5a5ae3e 270 }//streamer loop
271 }//event loop
272
273 //compute the rms of the CM values
af105157 274 TH1F *gHistCMDummy = new TH1F("gHistCMDummy","",100,-50.,50.);
275 Double_t meanPsideCM = 0.0, meanNsideCM = 0.0;
f5a5ae3e 276 Double_t rmsPsideCM = 0.0, rmsNsideCM = 0.0;
af105157 277 for(Int_t iModule = 0; iModule < fgkSSDMODULES; iModule++) {
278 meanPsideCM = 0.0; meanNsideCM = 0.0;
f5a5ae3e 279 rmsPsideCM = 0.0; rmsNsideCM = 0.0;
af105157 280 AliITSgeomTGeo::GetModuleId(iModule+500,gLayer,gLadder,gModule);
281
282 gHistCMDummy->Clear();
283 for(Int_t iChip = 0; iChip < fgkNumOfChips; iChip++) {
284 //cout<<"Name: "<<dynamic_cast<TH1*>(list->At(iModule*fgkNumOfChips+iChip))->GetName()<<endl;
285 gHistCMDummy->Add((TH1*)list->At(iModule*fgkNumOfChips+iChip));
286 }
287 meanPsideCM = TMath::Abs(gHistCMDummy->GetMean());
288 rmsPsideCM = gHistCMDummy->GetRMS();
289
290 gHistCMDummy->Clear();
291 for(Int_t iChip = 0; iChip < fgkNumOfChips; iChip++) {
292 //cout<<"Name: "<<dynamic_cast<TH1*>(list->At(fgkSSDMODULES*fgkNumOfChips+iModule*fgkNumOfChips+iChip))->GetName()<<endl;
293 gHistCMDummy->Add((TH1*)list->At(fgkSSDMODULES*fgkNumOfChips+iModule*fgkNumOfChips+iChip));
294 }
295 meanNsideCM = TMath::Abs(gHistCMDummy->GetMean());
296 rmsNsideCM = gHistCMDummy->GetRMS();
297
298 if(meanPsideCM == 0) meanPsideCM = 0.001;
299 if(meanNsideCM == 0) meanNsideCM = 0.001;
f5a5ae3e 300 if(rmsPsideCM == 0) rmsPsideCM = 0.001;
301 if(rmsNsideCM == 0) rmsNsideCM = 0.001;
af105157 302
f5a5ae3e 303 if(gLayer == 5) {
af105157 304 fHistPSideMeanCMMapLayer5->SetBinContent(gModule,gLadder,meanPsideCM);
305 fHistNSideMeanCMMapLayer5->SetBinContent(gModule,gLadder,meanNsideCM);
306 fHistPSideRMSCMMapLayer5->SetBinContent(gModule,gLadder,rmsPsideCM);
307 fHistNSideRMSCMMapLayer5->SetBinContent(gModule,gLadder,rmsNsideCM);
f5a5ae3e 308 }
309 if(gLayer == 6) {
af105157 310 fHistPSideMeanCMMapLayer6->SetBinContent(gModule,gLadder,meanPsideCM);
311 fHistNSideMeanCMMapLayer6->SetBinContent(gModule,gLadder,meanNsideCM);
312 fHistPSideRMSCMMapLayer6->SetBinContent(gModule,gLadder,rmsPsideCM);
313 fHistNSideRMSCMMapLayer6->SetBinContent(gModule,gLadder,rmsNsideCM);
f5a5ae3e 314 }
315 }
316
317 TFile *foutput = TFile::Open("SSD.CM.root","recreate");
318 list->Write();
af105157 319 fHistPSideMeanCMMapLayer5->Write(); fHistNSideMeanCMMapLayer5->Write();
320 fHistPSideMeanCMMapLayer6->Write(); fHistNSideMeanCMMapLayer6->Write();
321 fHistPSideRMSCMMapLayer5->Write(); fHistNSideRMSCMMapLayer5->Write();
322 fHistPSideRMSCMMapLayer6->Write(); fHistNSideRMSCMMapLayer6->Write();
f5a5ae3e 323 foutput->Close();
324}
325
326//__________________________________________________________//
327void drawSSDCM(const char* filename = "SSD.CM.root") {
328 gStyle->SetPalette(1,0);
329
330 TFile *f = TFile::Open(filename);
331
af105157 332 TCanvas *c1 = new TCanvas("c1","Mean of CM values",0,0,700,650);
f5a5ae3e 333 c1->SetFillColor(10); c1->SetHighLightColor(10); c1->Divide(2,2);
334 c1->cd(1);
af105157 335 TH2F *fHistPSideMeanCMMapLayer5 = dynamic_cast<TH2F *>(f->Get("fHistPSideMeanCMMapLayer5"));
336 fHistPSideMeanCMMapLayer5->Draw("colz");
f5a5ae3e 337 c1->cd(2);
af105157 338 TH2F *fHistNSideMeanCMMapLayer5 = dynamic_cast<TH2F *>(f->Get("fHistNSideMeanCMMapLayer5"));
339 fHistNSideMeanCMMapLayer5->Draw("colz");
f5a5ae3e 340 c1->cd(3);
af105157 341 TH2F *fHistPSideMeanCMMapLayer6 = dynamic_cast<TH2F *>(f->Get("fHistPSideMeanCMMapLayer6"));
342 fHistPSideMeanCMMapLayer6->Draw("colz");
f5a5ae3e 343 c1->cd(4);
af105157 344 TH2F *fHistNSideMeanCMMapLayer6 = dynamic_cast<TH2F *>(f->Get("fHistNSideMeanCMMapLayer6"));
345 fHistNSideMeanCMMapLayer6->Draw("colz");
346
347 TCanvas *c2 = new TCanvas("c2","RMS of CM values",100,100,700,650);
348 c2->SetFillColor(10); c2->SetHighLightColor(10); c2->Divide(2,2);
349 c2->cd(1);
350 TH2F *fHistPSideRMSCMMapLayer5 = dynamic_cast<TH2F *>(f->Get("fHistPSideRMSCMMapLayer5"));
351 fHistPSideRMSCMMapLayer5->Draw("colz");
352 c2->cd(2);
353 TH2F *fHistNSideRMSCMMapLayer5 = dynamic_cast<TH2F *>(f->Get("fHistNSideRMSCMMapLayer5"));
354 fHistNSideRMSCMMapLayer5->Draw("colz");
355 c2->cd(3);
356 TH2F *fHistPSideRMSCMMapLayer6 = dynamic_cast<TH2F *>(f->Get("fHistPSideRMSCMMapLayer6"));
357 fHistPSideRMSCMMapLayer6->Draw("colz");
358 c2->cd(4);
359 TH2F *fHistNSideRMSCMMapLayer6 = dynamic_cast<TH2F *>(f->Get("fHistNSideRMSCMMapLayer6"));
360 fHistNSideRMSCMMapLayer6->Draw("colz");
f5a5ae3e 361}
a56fec3e 362
363//__________________________________________________________//
364void checkCM(const char* filename) {
365 //Reads the SSD.CM.root file as an input.
366 //For every chip checks the mean and the rms of the CM distributions.
367 //If the absolute value of the mean is beyond 5 ADC counts or/and the
368 //rms is beyond 10, the corresponding histogram is added to the list
369 //of suspicious chips. This list is written to the output file having
370 //the name: SSD.FaultyChips.root
371
372 //Hardcoded check values
373 const Double_t meanMax = 5.;
374 const Double_t rmsMax = 10.;
375
376 //output list
377 TList *listOfSuspiciousChips = new TList();
378
379 //Input file
380 TFile *fInput = TFile::Open(filename);
381
382 Int_t gLayer = 0,gLadder = 0, gModule = 0;
383 TString gTitle;
384 //Double_t meanValue = 0.0, rmsValue = 0.0;
385 TH1F *gHistSSDCMModule = 0x0;
386 //P-side
387 for(Int_t iModule = 500; iModule < fgkSSDMODULES + 500; iModule++) {
388 AliITSgeomTGeo::GetModuleId(iModule,gLayer,gLadder,gModule);
389 for(Int_t iChip = 0; iChip < fgkNumOfChips; iChip++) {
390 gTitle = "SSD_CM_PSide_Layer"; gTitle += gLayer;
391 gTitle += "_Ladder"; gTitle += gLadder;
392 gTitle += "_Module"; gTitle += gModule;
393 gTitle += "_Chip"; gTitle += iChip+1;
394 gHistSSDCMModule = dynamic_cast<TH1F *>(fInput->Get(gTitle.Data()));
395 if((TMath::Abs(gHistSSDCMModule->GetMean(1)) > meanMax)||
396 (TMath::Abs(gHistSSDCMModule->GetRMS(1)) > rmsMax)) {
397 Printf("Name: %s, Mean: %lf - rms: %lf",
398 gHistSSDCMModule->GetName(),
399 TMath::Abs(gHistSSDCMModule->GetMean(1)),
400 TMath::Abs(gHistSSDCMModule->GetRMS(1)));
401 listOfSuspiciousChips->Add(gHistSSDCMModule);
402 }
403 }//chip loop
404 }//module loop
405
406 //N-side
407 for(Int_t iModule = 500; iModule < fgkSSDMODULES + 500; iModule++) {
408 AliITSgeomTGeo::GetModuleId(iModule,gLayer,gLadder,gModule);
409 for(Int_t iChip = 0; iChip < fgkNumOfChips; iChip++) {
410 gTitle = "SSD_CM_NSide_Layer"; gTitle += gLayer;
411 gTitle += "_Ladder"; gTitle += gLadder;
412 gTitle += "_Module"; gTitle += gModule;
413 gTitle += "_Chip"; gTitle += iChip+1;
414 gHistSSDCMModule = dynamic_cast<TH1F *>(fInput->Get(gTitle.Data()));
415 if((TMath::Abs(gHistSSDCMModule->GetMean(1)) > meanMax)||
416 (TMath::Abs(gHistSSDCMModule->GetRMS(1)) > rmsMax)) {
417 Printf("Name: %s, Mean: %lf - rms: %lf",
418 gHistSSDCMModule->GetName(),
419 TMath::Abs(gHistSSDCMModule->GetMean(1)),
420 TMath::Abs(gHistSSDCMModule->GetRMS(1)));
421 listOfSuspiciousChips->Add(gHistSSDCMModule);
422 }
423 //Printf("Name: %s",gHistSSDCMModule->GetName());
424 }//chip loop
425 }//module loop
426
427 Printf("===============================================");
428 Printf("%d suspicious chips were put in the list",
429 listOfSuspiciousChips->GetEntries());
430 Printf("===============================================");
431 TFile *fOutput = new TFile("SSD.FaultyChips.root","recreate");
432 listOfSuspiciousChips->Write();
433 fOutput->Close();
434
435 fInput->Close();
436}