]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/ITSSDDQA.C
Undo previous commit of this file
[u/mrichter/AliRoot.git] / ITS / ITSSDDQA.C
1 void ITSSDDQA(char *iFile, Int_t MaxEvts=1000000, Int_t FirstEvt=0) {
2
3 cout << "SDD Quality Assurance Prototype Macro" << endl; 
4
5 const Int_t nSDDmodules= 260;
6 const Int_t imodoffset = 240;
7 const Int_t modtotSDD  = nSDDmodules*2;
8
9 Float_t xi = 0.5;
10 Float_t xf = xi + nSDDmodules;
11 TH1F *modulePattern = new TH1F("patternModule","Modules pattern",nSDDmodules,xi,xf);
12 xf = xi + modtotSDD;
13 TH1F *moduleSidePattern = new TH1F("patternSide","Modules/Side pattern",modtotSDD,xi,xf);
14
15 TH2F *hismap[modtotSDD];  //260 dx e 260 sx  with A, T, Q
16 TH2F *hispop[modtotSDD];  //260 dx e 260 sx  with A, T, Ncounts
17  
18 Char_t *cindex = new Char_t[5];
19 for(Int_t imod=0; imod<nSDDmodules;imod++){
20   for(Int_t isid=0;isid<2;isid++){
21     Int_t index=2*imod+isid;       //260*2 position
22
23     sprintf(cindex,"%d",index+1); // imod,isid);
24     TString sindex((const char *) cindex);
25
26     TString histnam("chargeMap");
27     TString histit("Total Charge, module number ");
28     histnam.Append(sindex);
29     histit.Append(sindex);
30     hismap[index]=new TH2F(histnam.Data(),histit.Data(),256,-0.5,255.5,256,-0.5,255.5);
31       
32     TString hisnam2("countsMap");
33     TString histit2("Number of Counts, module number ");
34     hisnam2.Append(sindex);
35     histit2.Append(sindex);
36     hispop[index]=new TH2F(hisnam2.Data(),histit2.Data(),256,-0.5,255.5,256,-0.5,255.5);
37   
38     /*
39       sprintf(hisnam,"hisprojX%03ds%d",imod,isid);
40       sprintf(histitle,"layer , ladder, module position, channel, %d, %d", imod, isid);
41       hisprojX[index]=new TH2F(hisnam,histitle,256,-0.5,255.5,256,-0.5,255.5);
42
43       sprintf(hisnam,"hisprojY%03ds%d",imod,isid);
44       sprintf(histitle,"layer , ladder, module position, channel, %d, %d", imod, isid);
45       hisprojY[index]=new TH2F(hisnam,histitle,256,-0.5,255.5,256,-0.5,255.5);
46
47       sprintf(hisnam,"hisprofX%03ds%d",imod,isid);
48       sprintf(histitle,"layer , ladder, module position, channel, %d, %d", imod, isid);
49       hisprofX[index]=new TH2F(hisnam,histitle,256,-0.5,255.5,256,-0.5,255.5);
50
51       sprintf(hisnam,"hisprofY%03ds%d",imod,isid);
52       sprintf(histitle,"layer , ladder, module position, channel, %d, %d", imod, isid);
53       hisprofY[index]=new TH2F(hisnam,histitle,256,-0.5,255.5,256,-0.5,255.5);
54       */
55  
56   }
57 }
58 delete [] cindex;
59
60   AliRawReader *rd = new AliRawReaderDate(iFile,FirstEvt);  // open run
61   Int_t evCounter = 0;
62
63   //AliITS *itsRun = new AliITS();
64   //  TGeoManager::Import("$ALICE_ROOT/EVE/alice-data/alice_fullgeo.root");
65   /*
66     AliITSInitGeometry *initgeom = new AliITSInitGeometry("AliITSvPPRasymmFMD",2);
67     geom = initgeom->CreateAliITSgeom();
68     delete initgeom;
69   */
70
71   Int_t eqOffset = 256;
72   Int_t DDLid_range = 24;
73   do{       // start loop on events
74     if(++evCounter > MaxEvts) { cout << MaxEvts << " events read, stop" << endl; evCounter--; break; }  
75      cout << "Read Event: " << evCounter+FirstEvt-1 << endl;
76
77     rd->RequireHeader(kFALSE);             
78     rd->SelectEvents(7);                   // read only events with the given type. no selection is applied if a value < 0 is used. 
79
80     rd->SelectEquipment(17,eqOffset+1,eqOffset+DDLid_range);
81
82     rd->Reset();    // reset the current position to the beginning of the event
83     AliITSRawStreamSDD s(rd);    //This class provides access to ITS SDD digits in raw data.
84     Int_t iddl;
85     Int_t isddmod;
86     Int_t moduleSDD;
87     while(s.Next()){                       //read the next raw digit; returns kFALSE if there is no digit left
88
89         iddl=rd->GetDDLID();
90         isddmod=s.GetModuleNumber(iddl,s.GetCarlosId());  //this is the FEE Carlos
91         //cout<<"DDLID= "<<iddl <<"; Module number= " <<isddmod  <<endl;
92         modulePattern->Fill(isddmod-imodoffset+1);     // 1 to 260
93         moduleSDD=2*(isddmod-imodoffset)+s.GetChannel();
94         moduleSidePattern->Fill(moduleSDD+1);          // 1 to 520
95         //cout << "anode " << s.GetCoord1() << ", time bin: " << s.GetCoord2() << ", charge: " << s.GetSignal() << endl;
96         hismap[moduleSDD]->Fill(s.GetCoord1(), s.GetCoord2(),s.GetSignal() );
97         hispop[moduleSDD]->Fill(s.GetCoord1(), s.GetCoord2() );  
98     }    
99
100   } while(rd->NextEvent()); // end loop on events
101   delete rd;
102
103   cout << "end after " << evCounter << " events" << endl;
104
105    TString oFileName(iFile);
106    oFileName.Append(".root");
107    TFile *oFile = TFile::Open(oFileName,"recreate");
108    modulePattern->Write();
109    moduleSidePattern->Write();
110    for(Int_t i=0; i<modtotSDD; i++){
111      hismap[i]->Write();
112      hispop[i]->Write();
113    }
114    oFile->Close();
115
116    for(Int_t imod=0; imod<nSDDmodules;imod++){
117      for(Int_t isid=0;isid<2;isid++){
118        Int_t index=2*imod+isid;       //260*2 position
119        delete hismap[index];
120        delete hispop[index];
121      }
122    }
123    delete modulePattern;
124    delete moduleSidePattern;
125
126 }