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_ddl*c*_sid*.data SDDbase_step2_ddl*c*_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 BASELINE+NOISE algorithm program started\n");
71 /* check that we got some arguments = list of files */
73 printf("Wrong number of arguments\n");
78 Int_t maxNEvents=18; // maximum number of events to be analyzed
79 const Int_t kTotDDL=24;
80 const Int_t kModPerDDL=12;
82 AliITSOnlineSDDBase **base=new AliITSOnlineSDDBase*[kTotDDL*kModPerDDL*kSides];
83 AliITSOnlineSDDCMN **corr=new AliITSOnlineSDDCMN*[kTotDDL*kModPerDDL*kSides];
84 TH2F **histo=new TH2F*[kTotDDL*kModPerDDL*kSides];
87 for(Int_t iddl=0; iddl<kTotDDL;iddl++){
88 for(Int_t imod=0; imod<kModPerDDL;imod++){
89 for(Int_t isid=0;isid<kSides;isid++){
90 Int_t index=kSides*(kModPerDDL*iddl+imod)+isid;
91 base[index]=new AliITSOnlineSDDBase(iddl,imod,isid);
92 sprintf(hisnam,"h%02dc%02ds%d",iddl,imod,isid);
93 histo[index]=new TH2F(hisnam,"",256,-0.5,255.5,256,-0.5,255.5);
99 daqDA_progressReport(8);
101 for(Int_t iStep=0;iStep<2;iStep++){
102 printf("Start Analysis Step %d\n",iStep);
105 for(Int_t iddl=0; iddl<kTotDDL;iddl++){
106 for(Int_t imod=0; imod<kModPerDDL;imod++){
107 for(Int_t isid=0;isid<kSides;isid++){
108 Int_t index=kSides*(kModPerDDL*iddl+imod)+isid;
109 corr[index]=new AliITSOnlineSDDCMN(iddl,imod,isid);
115 /* read the data files */
117 for (n=1;n<argc;n++) {
119 status=monitorSetDataSource( argv[n] );
121 printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
125 /* report progress */
126 /* in this example, indexed on the number of files */
127 // Progress report inside the event loop as well?
128 daqDA_progressReport(10+40*iStep*n/argc);
132 struct eventHeaderStruct *event;
133 eventTypeType eventT;
136 status=monitorGetEventDynamic((void **)&event);
137 if (status==MON_ERR_EOF) break; /* end of monitoring file has been reached */
139 printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
143 /* retry if got no event */
149 if(iev>maxNEvents) break;
151 /* use event - here, just write event id to result file */
152 eventT=event->eventType;
153 switch (event->eventType){
163 // case PHYSICS_EVENT: // comment this line for test raw data
164 // break; // comment this line for test raw data
167 case CALIBRATION_EVENT:
168 break; // uncomment this line for test raw data
169 case PHYSICS_EVENT: // uncomment this line for test raw data
170 printf(" event number = %i \n",iev);
171 AliRawReader *rawReader = new AliRawReaderDate((void*)event);
175 while(rawReader->ReadHeader()){
176 const UInt_t *subev = rawReader->GetSubEventAttributes();
177 if(subev[0]==0 && subev[1]==0 && subev[2]==0) evtyp=1;
181 for(Int_t iddl=0; iddl<kTotDDL;iddl++){
182 for(Int_t imod=0; imod<kModPerDDL;imod++){
183 for(Int_t isid=0;isid<kSides;isid++){
184 Int_t index=kSides*(kModPerDDL*iddl+imod)+isid;
185 histo[index]->Reset();
189 AliITSRawStreamSDD s(rawReader);
192 Int_t iDDL=rawReader->GetDDLID();
193 Int_t iCarlos=s.GetCarlosId();
194 if(iDDL>=0 && iDDL<kTotDDL && s.IsCompletedModule()==kFALSE){
195 Int_t index=kSides*(kModPerDDL*iDDL+iCarlos)+s.GetChannel();
196 histo[index]->Fill(s.GetCoord2(),s.GetCoord1(),s.GetSignal());
200 for(Int_t iddl=0; iddl<kTotDDL;iddl++){
201 for(Int_t imod=0; imod<kModPerDDL;imod++){
202 for(Int_t isid=0;isid<kSides;isid++){
203 Int_t index=kSides*(kModPerDDL*iddl+imod)+isid;
204 if(iStep==0) base[index]->AddEvent(histo[index]);
205 if(iStep==1) corr[index]->AddEvent(histo[index]);
217 for(Int_t iddl=0; iddl<kTotDDL;iddl++){
218 for(Int_t imod=0; imod<kModPerDDL;imod++){
219 for(Int_t isid=0;isid<kSides;isid++){
220 Int_t index=kSides*(kModPerDDL*iddl+imod)+isid;
221 base[index]->ValidateAnodes();
222 base[index]->WriteToASCII();
230 printf("Run #%s, received %d calibration events\n",getenv("DATE_RUN_NUMBER"),iev);
232 /* report progress */
233 daqDA_progressReport(90);
237 TFile *fh=new TFile("SDDbaseHistos.root","RECREATE");
238 for(Int_t iddl=0; iddl<kTotDDL;iddl++){
239 for(Int_t imod=0; imod<kModPerDDL;imod++){
240 for(Int_t isid=0;isid<kSides;isid++){
241 Int_t index=kSides*(kModPerDDL*iddl+imod)+isid;
242 corr[index]->ValidateAnodes();
243 corr[index]->WriteToASCII();
244 corr[index]->WriteToROOT(fh);
251 /* report progress */
252 daqDA_progressReport(100);