1 void ITSSDDQAMaker(char *iFile, Int_t MaxEvts=1000000, Int_t FirstEvt=0) {
3 //To have Baseline Histos uncomment parts with " // BL!!! " comment
5 cout << "SDD Quality Assurance Prototype Macro" << endl;
7 const Int_t nSDDmodules= 260;
8 const Int_t imodoffset = 240;
9 const Int_t modtotSDD = nSDDmodules*2;
10 const Int_t anode = 256;
13 Float_t xf = xi + nSDDmodules;
14 TH1F *hModulePattern = new TH1F("hModulePattern","Modules pattern",nSDDmodules,xi,xf);
16 TH1F *hModuleSidePattern = new TH1F("hModuleSidePattern","Modules/Side pattern",modtotSDD,xi,xf);
18 TH2F *hModuleChargeMap[modtotSDD]; //260 dx e 260 sx with A, T, Q
19 TH2F *hModuleCountsMap[modtotSDD]; //260 dx e 260 sx with A, T, Ncounts
20 TH2I *hModuleCarlos = new TH2I("hModuleCarlos","hModuleCarlos",modtotSDD,xi,xf,101,-0.5,100.5);
22 TH1F *hModuleSideBL[modtotSDD][anode]; // BL!!!
26 //-------histograms definition
27 Char_t *hisnam = new Char_t[50];
28 Char_t *histit = new Char_t[50];
29 Char_t *hisnam2 = new Char_t[50];
30 Char_t *histit2 = new Char_t[50];
31 Char_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
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);
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);
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.);
53 TString strFile = iFile;
54 strFile += "?EventType=7";
55 AliRawReader *rd = new AliRawReaderDate(strFile.Data(),FirstEvt); // open run
58 Int_t DDLid_range = 24;
59 do{ // start loop on events
60 if(++evCounter > MaxEvts) { cout << MaxEvts << " events read, stop" << endl; evCounter--; break; }
61 cout << "Read Event: " << evCounter+FirstEvt-1 << endl;
63 rd->RequireHeader(kFALSE);
64 rd->SelectEquipment(17,eqOffset+1,eqOffset+DDLid_range); //17 states for "DRorc acquisition"
65 rd->Reset(); // reset the current position to the beginning of the event
67 Int_t nSkip = 0; // number of skipped signals
68 AliITSRawStreamSDD s(rd); //This class provides access to ITS SDD digits in raw data.
72 gStyle->SetPalette(1);
73 while(s.Next()){ //read the next raw digit; returns kFALSE if there is no digit left
74 if(s.IsCompletedModule()) continue;
75 iddl=rd->GetDDLID()-2; // -2 is temporary for test raw data
77 isddmod=s.GetModuleNumber(iddl,s.GetCarlosId()); //this is the FEE Carlos
78 //cout<<"DDLID= "<<iddl <<"; Module number= " <<isddmod <<endl;
79 if(isddmod >= imodoffset) {
80 hModulePattern->Fill(isddmod-imodoffset); // 0 to 259 so 240 to 499
81 moduleSDD=2*(isddmod-imodoffset)+s.GetChannel();
82 hModuleSidePattern->Fill(moduleSDD); // 0 to 519
83 hModuleCarlos->Fill(isddmod-imodoffset,s.GetCarlosId());
84 //cout << "anode " << s.GetCoord1() << ", time bin: " << s.GetCoord2() << ", charge: " << s.GetSignal() << endl;
85 Int_t coord1 = s.GetCoord1();
86 Int_t coord2 = s.GetCoord2();
87 Int_t signal = s.GetSignal();
88 hModuleChargeMap[moduleSDD]->Fill(coord2, coord1,signal);
89 hModuleCountsMap[moduleSDD]->Fill(coord2, coord1 );
90 //hModuleSideBL[moduleSDD][coord1]->Fill(signal); // BL !!!
95 cout << "End of Event " << evCounter+FirstEvt-1 << ", " << nSkip << " wrong module numbers" << endl;
96 } while(rd->NextEvent()); // end loop on events
99 cout << "end after " << evCounter << " events" << endl;
101 TNtuple *Baseline = new TNtuple("Baseline","Baseline","HalfModule:Anode:Mean:RMS"); // BL!!!
105 for(Int_t i=0; i<modtotSDD; i++){
106 if(hModuleSidePattern->GetBinContent(i+1)){ //check if they're not empty
107 hModuleChargeMap[i]->GetXaxis()->SetTitle("Time Bin");
108 hModuleChargeMap[i]->GetYaxis()->SetTitle("Anode");
109 hModuleCountsMap[i]->GetXaxis()->SetTitle("Time Bin");
110 hModuleCountsMap[i]->GetYaxis()->SetTitle("Anode");
112 for(Int_t ianode=0; ianode<anode; ianode++ ){ // BL!!!
113 hModuleSideBL[i][ianode]->GetXaxis()->SetTitle("ADC counts");
114 hModuleSideBL[i][ianode]->GetYaxis()->SetTitle("#");
115 meanBL = hModuleSideBL[i][ianode]->GetMean();
116 rmsBL = hModuleSideBL[i][ianode]->GetRMS();
117 gaussfitBL = hModuleSideBL[i][ianode]->Fit("gaus");
118 Baseline->Fill(i,ianode,meanBL,rmsBL);
124 hModuleSidePattern->GetXaxis()->SetTitle("2*(Module Number-1)+Side");
125 hModuleSidePattern->GetYaxis()->SetTitle("Counts");
126 hModulePattern->GetXaxis()->SetTitle("Module Number");
127 hModulePattern->GetYaxis()->SetTitle("Counts");
130 //-------store Histograms
131 cout << "Store Histograms" << endl;
132 TString oFileName(iFile);
133 oFileName.Append(".root");
134 TFile *oFile = TFile::Open(oFileName,"recreate");
135 hModulePattern->Write();
136 hModuleSidePattern->Write();
137 hModuleCarlos->Write();
138 for(Int_t i=0; i<modtotSDD; i++){
139 if(hModuleSidePattern->GetBinContent(i+1)){ //check if they're not empty
140 hModuleChargeMap[i]->Write();
141 hModuleCountsMap[i]->Write();
143 for(Int_t ianode=0; ianode<anode; ianode++ ){ // BL!!!
144 hModuleSideBL[i][ianode]->Write();
152 cout << "Clear memory" << endl;
153 for(Int_t imod=0; imod<nSDDmodules;imod++){
154 for(Int_t isid=0;isid<2;isid++){
155 Int_t index=2*imod+isid; //260*2 position
156 delete hModuleChargeMap[index];
157 delete hModuleCountsMap[index];
159 for(Int_t ianode=0; ianode<anode; ianode++ ){ // BL!!!
160 delete hModuleSideBL[index][ianode];
166 delete hModulePattern;
167 delete hModuleSidePattern;
168 delete hModuleCarlos;