2 - Contact: - prino@to.infn.it
3 - Link: - http://www.to.infn.it/~prino/alice/RawData/run11161.date
4 - Run Type: - PEDESTAL_RUN
6 - Number of events needed: 100
8 - Output Files: - SDDbase_step1_mod*_sid*.data SDDbase_step2_mod*_sid*.data
13 //////////////////////////////////////////////////////////////////////////////
14 // Detector Algorithm for analysis of SDD baseline runs. //
16 // Produces ASCII and ROOT output files with: //
17 // 1. anode quality bit //
18 // 1. Baseline values //
20 // 3. Common mode coefficients //
21 // 4. Noise corrected for common mode //
22 // Files are stored locally. //
23 // The next DAQ-DA step on Test Pulse run writes files to FXS //
25 // Author: F. Prino (prino@to.infn.it) //
27 //////////////////////////////////////////////////////////////////////////////
46 #include <TPluginManager.h>
49 #include "AliRawReaderDate.h"
50 #include "AliITSOnlineSDDBase.h"
51 #include "AliITSOnlineSDDCMN.h"
52 #include "AliITSRawStreamSDD.h"
54 Arguments: list of DATE raw data files
56 int main(int argc, char **argv) {
60 // line added to solve IO problems
61 gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo",
67 /* log start of process */
68 printf("ITS SDD BASE algorithm program started\n");
71 /* check that we got some arguments = list of files */
73 printf("Wrong number of arguments\n");
80 Int_t maxNEvents=18; // maximum number of events to be analyzed
81 const Int_t nSDDmodules=260; // temp for test raw data
82 AliITSOnlineSDDBase **base=new AliITSOnlineSDDBase*[2*nSDDmodules];
83 AliITSOnlineSDDCMN **corr=new AliITSOnlineSDDCMN*[2*nSDDmodules];
84 TH2F **histo=new TH2F*[2*nSDDmodules];
87 for(Int_t imod=0; imod<nSDDmodules;imod++){
88 for(Int_t isid=0;isid<2;isid++){
89 Int_t index=2*imod+isid;
90 base[index]=new AliITSOnlineSDDBase(imod,isid);
91 corr[index]=new AliITSOnlineSDDCMN(imod,isid);
92 sprintf(hisnam,"his%03ds%d",imod,isid);
93 histo[index]=new TH2F(hisnam,"",256,-0.5,255.5,256,-0.5,255.5);
98 daqDA_progressReport(8);
100 for(Int_t iStep=0;iStep<2;iStep++){
101 printf("Start Analysis Step %d\n",iStep);
104 for(Int_t imod=0; imod<nSDDmodules;imod++){
105 for(Int_t isid=0;isid<2;isid++){
106 Int_t index=2*imod+isid;
107 corr[index]->Reset();
112 /* read the data files */
114 for (n=1;n<argc;n++) {
116 status=monitorSetDataSource( argv[n] );
118 printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
122 /* report progress */
123 /* in this example, indexed on the number of files */
124 // Progress report inside the event loop as well?
125 daqDA_progressReport(10+40*iStep*n/argc);
129 struct eventHeaderStruct *event;
130 eventTypeType eventT;
133 status=monitorGetEventDynamic((void **)&event);
134 if (status==MON_ERR_EOF) break; /* end of monitoring file has been reached */
136 printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
140 /* retry if got no event */
146 if(iev>maxNEvents) break;
148 /* use event - here, just write event id to result file */
149 eventT=event->eventType;
150 switch (event->eventType){
160 // case PHYSICS_EVENT: // comment this line for test raw data
161 // break; // comment this line for test raw data
164 case CALIBRATION_EVENT:
165 break; // uncomment this line for test raw data
166 case PHYSICS_EVENT: // uncomment this line for test raw data
167 printf(" event number = %i \n",iev);
168 AliRawReader *rawReader = new AliRawReaderDate((void*)event);
169 rawReader->SelectEquipment(17,eqOffset+1,eqOffset+DDLrange);
173 while(rawReader->ReadHeader()){
174 const UInt_t *subev = rawReader->GetSubEventAttributes();
175 if(subev[0]==0 && subev[1]==0 && subev[2]==0) evtyp=1;
179 for(Int_t imod=0; imod<nSDDmodules;imod++){
180 for(Int_t isid=0; isid<2;isid++){
181 Int_t index=2*imod+isid;
182 histo[index]->Reset();
185 AliITSRawStreamSDD s(rawReader);
188 Int_t isddmod=s.GetModuleID();//Number(iddl,s.GetCarlosId());
189 isddmod-=240; // to have SDD modules from 0 to 259
190 if(isddmod>0 && isddmod<nSDDmodules && s.IsCompletedModule()==kFALSE){
191 Int_t index=2*isddmod+s.GetChannel();
192 histo[index]->Fill(s.GetCoord2(),s.GetCoord1(),s.GetSignal());
196 for(Int_t imod=0; imod<nSDDmodules;imod++){
197 for(Int_t isid=0; isid<2;isid++){
198 Int_t index=2*imod+isid;
199 if(iStep==0) base[index]->AddEvent(histo[index]);
200 if(iStep==1) corr[index]->AddEvent(histo[index]);
211 for(Int_t imod=0; imod<nSDDmodules;imod++){
212 for(Int_t isid=0; isid<2;isid++){
213 Int_t index=2*imod+isid;
215 base[index]->ValidateAnodes();
216 base[index]->WriteToASCII();
219 corr[index]->ValidateAnodes();
220 corr[index]->WriteToASCII();
227 printf("Run #%s, received %d calibration events\n",getenv("DATE_RUN_NUMBER"),iev);
229 /* report progress */
230 daqDA_progressReport(90);
234 TFile *fh=new TFile("SDDbaseHistos.root","RECREATE");
235 for(Int_t imod=0; imod<nSDDmodules;imod++){
236 for(Int_t isid=0; isid<2;isid++){
237 Int_t index=2*imod+isid;
238 corr[index]->WriteToROOT(fh);
244 /* report progress */
245 daqDA_progressReport(100);