]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/ITSSDDQAMaker.C
Adding the new histograms filled for each mirror
[u/mrichter/AliRoot.git] / ITS / ITSSDDQAMaker.C
CommitLineData
27639c72 1void ITSSDDQAMaker(char *iFile, Int_t MaxEvts=1000000, Int_t FirstEvt=0) {
2
3 //To have Baseline Histos uncomment parts with " // BL!!! " comment
4
5cout << "SDD Quality Assurance Prototype Macro" << endl;
6
7const Int_t nSDDmodules= 260;
8const Int_t imodoffset = 240;
9const Int_t modtotSDD = nSDDmodules*2;
10const Int_t anode = 256;
11
12Float_t xi = -0.5;
13Float_t xf = xi + nSDDmodules;
14TH1F *hModulePattern = new TH1F("hModulePattern","Modules pattern",nSDDmodules,xi,xf);
15xf = xi + modtotSDD;
16TH1F *hModuleSidePattern = new TH1F("hModuleSidePattern","Modules/Side pattern",modtotSDD,xi,xf);
17
18TH2F *hModuleChargeMap[modtotSDD]; //260 dx e 260 sx with A, T, Q
19TH2F *hModuleCountsMap[modtotSDD]; //260 dx e 260 sx with A, T, Ncounts
20TH2I *hModuleCarlos = new TH2I("hModuleCarlos","hModuleCarlos",modtotSDD,xi,xf,101,-0.5,100.5);
21/*
22 TH1F *hModuleSideBL[modtotSDD][anode]; // BL!!!
23*/
24
25
26//-------histograms definition
27Char_t *hisnam = new Char_t[50];
28Char_t *histit = new Char_t[50];
29Char_t *hisnam2 = new Char_t[50];
30Char_t *histit2 = new Char_t[50];
31Char_t *hisnam3 = new Char_t[50];
32 for(Int_t imod=0; imod<nSDDmodules;imod++){
33 for(Int_t isid=0;isid<2;isid++){
34 Int_t index=2*imod+isid; //260*2 position
35
36 sprintf(hisnam,"chargeMap%d",index);
37 sprintf(histit,"Total Charge, module number %d",index);
38 hModuleChargeMap[index]=new TH2F(hisnam,histit,256,-0.5,255.5,256,-0.5,255.5);
39
40 sprintf(hisnam2,"countsMap%d",index);
41 sprintf(histit2,"Number of Counts, module number %d",index);
42 hModuleCountsMap[index] = new TH2F(hisnam2,histit2,256,-0.5,255.5,256,-0.5,255.5);
43 /*
44 for(Int_t ianode=0; ianode<anode; ianode++){ // BL!!!
45 sprintf(hisnam3,"BL_module_%d_%d",index,ianode);
46 //cout<<hisnam3 <<endl;
47 hModuleSideBL[index][ianode] = new TH1F(hisnam3,hisnam3,256,0.,1024.);
48 }
49 */
50 }
51 }
52
3f7450e0 53 TString strFile = iFile;
54 strFile += "?EventType=7";
55 AliRawReader *rd = new AliRawReaderDate(strFile.Data(),FirstEvt); // open run
27639c72 56 Int_t evCounter = 0;
27639c72 57 do{ // start loop on events
58 if(++evCounter > MaxEvts) { cout << MaxEvts << " events read, stop" << endl; evCounter--; break; }
59 cout << "Read Event: " << evCounter+FirstEvt-1 << endl;
60
61 rd->RequireHeader(kFALSE);
27639c72 62 rd->Reset(); // reset the current position to the beginning of the event
63
64 Int_t nSkip = 0; // number of skipped signals
65 AliITSRawStreamSDD s(rd); //This class provides access to ITS SDD digits in raw data.
66 Int_t iddl;
67 Int_t isddmod;
68 Int_t moduleSDD;
69 gStyle->SetPalette(1);
70 while(s.Next()){ //read the next raw digit; returns kFALSE if there is no digit left
5dfa68c5 71 if(s.IsCompletedModule()) continue;
72 iddl=rd->GetDDLID()-2; // -2 is temporary for test raw data
27639c72 73
5dfa68c5 74 isddmod=s.GetModuleNumber(iddl,s.GetCarlosId()); //this is the FEE Carlos
27639c72 75 //cout<<"DDLID= "<<iddl <<"; Module number= " <<isddmod <<endl;
76 if(isddmod >= imodoffset) {
77 hModulePattern->Fill(isddmod-imodoffset); // 0 to 259 so 240 to 499
78 moduleSDD=2*(isddmod-imodoffset)+s.GetChannel();
79 hModuleSidePattern->Fill(moduleSDD); // 0 to 519
80 hModuleCarlos->Fill(isddmod-imodoffset,s.GetCarlosId());
81 //cout << "anode " << s.GetCoord1() << ", time bin: " << s.GetCoord2() << ", charge: " << s.GetSignal() << endl;
82 Int_t coord1 = s.GetCoord1();
83 Int_t coord2 = s.GetCoord2();
84 Int_t signal = s.GetSignal();
85 hModuleChargeMap[moduleSDD]->Fill(coord2, coord1,signal);
86 hModuleCountsMap[moduleSDD]->Fill(coord2, coord1 );
87 //hModuleSideBL[moduleSDD][coord1]->Fill(signal); // BL !!!
88 } else {
89 nSkip++;
90 }
91 }
92 cout << "End of Event " << evCounter+FirstEvt-1 << ", " << nSkip << " wrong module numbers" << endl;
93 } while(rd->NextEvent()); // end loop on events
94 delete rd;
95
96 cout << "end after " << evCounter << " events" << endl;
97 /*
98 TNtuple *Baseline = new TNtuple("Baseline","Baseline","HalfModule:Anode:Mean:RMS"); // BL!!!
99 Float_t meanBL;
100 Float_t rmsBL;
101 */
102 for(Int_t i=0; i<modtotSDD; i++){
103 if(hModuleSidePattern->GetBinContent(i+1)){ //check if they're not empty
104 hModuleChargeMap[i]->GetXaxis()->SetTitle("Time Bin");
105 hModuleChargeMap[i]->GetYaxis()->SetTitle("Anode");
106 hModuleCountsMap[i]->GetXaxis()->SetTitle("Time Bin");
107 hModuleCountsMap[i]->GetYaxis()->SetTitle("Anode");
108 /*
109 for(Int_t ianode=0; ianode<anode; ianode++ ){ // BL!!!
110 hModuleSideBL[i][ianode]->GetXaxis()->SetTitle("ADC counts");
111 hModuleSideBL[i][ianode]->GetYaxis()->SetTitle("#");
112 meanBL = hModuleSideBL[i][ianode]->GetMean();
113 rmsBL = hModuleSideBL[i][ianode]->GetRMS();
114 gaussfitBL = hModuleSideBL[i][ianode]->Fit("gaus");
115 Baseline->Fill(i,ianode,meanBL,rmsBL);
116 }
117 */
118 }
119 }
120
121 hModuleSidePattern->GetXaxis()->SetTitle("2*(Module Number-1)+Side");
122 hModuleSidePattern->GetYaxis()->SetTitle("Counts");
123 hModulePattern->GetXaxis()->SetTitle("Module Number");
124 hModulePattern->GetYaxis()->SetTitle("Counts");
125
126
127 //-------store Histograms
128 cout << "Store Histograms" << endl;
129 TString oFileName(iFile);
130 oFileName.Append(".root");
131 TFile *oFile = TFile::Open(oFileName,"recreate");
132 hModulePattern->Write();
133 hModuleSidePattern->Write();
134 hModuleCarlos->Write();
135 for(Int_t i=0; i<modtotSDD; i++){
136 if(hModuleSidePattern->GetBinContent(i+1)){ //check if they're not empty
137 hModuleChargeMap[i]->Write();
138 hModuleCountsMap[i]->Write();
139 /*
140 for(Int_t ianode=0; ianode<anode; ianode++ ){ // BL!!!
141 hModuleSideBL[i][ianode]->Write();
142 Baseline->Write();
143 }
144 */
145 }
146 }
147
148 oFile->Close();
149 cout << "Clear memory" << endl;
150 for(Int_t imod=0; imod<nSDDmodules;imod++){
151 for(Int_t isid=0;isid<2;isid++){
152 Int_t index=2*imod+isid; //260*2 position
153 delete hModuleChargeMap[index];
154 delete hModuleCountsMap[index];
155 /*
156 for(Int_t ianode=0; ianode<anode; ianode++ ){ // BL!!!
157 delete hModuleSideBL[index][ianode];
158 delete Baseline;
159 }
160 */
161 }
162 }
163 delete hModulePattern;
164 delete hModuleSidePattern;
165 delete hModuleCarlos;
166
167}