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");
80 Int_t maxNEvents=18; // maximum number of events to be analyzed
81 const Int_t kTotDDL=24;
82 const Int_t kModPerDDL=12;
84 AliITSOnlineSDDBase **base=new AliITSOnlineSDDBase*[kTotDDL*kModPerDDL*kSides];
85 AliITSOnlineSDDCMN **corr=new AliITSOnlineSDDCMN*[kTotDDL*kModPerDDL*kSides];
86 TH2F **histo=new TH2F*[kTotDDL*kModPerDDL*kSides];
89 for(Int_t iddl=0; iddl<kTotDDL;iddl++){
90 for(Int_t imod=0; imod<kModPerDDL;imod++){
91 for(Int_t isid=0;isid<kSides;isid++){
92 Int_t index=kSides*(kModPerDDL*iddl+imod)+isid;
93 base[index]=new AliITSOnlineSDDBase(iddl,imod,isid);
94 sprintf(hisnam,"h%02dc%02ds%d",iddl,imod,isid);
95 histo[index]=new TH2F(hisnam,"",256,-0.5,255.5,256,-0.5,255.5);
100 /* report progress */
101 daqDA_progressReport(8);
103 for(Int_t iStep=0;iStep<2;iStep++){
104 printf("Start Analysis Step %d\n",iStep);
107 for(Int_t iddl=0; iddl<kTotDDL;iddl++){
108 for(Int_t imod=0; imod<kModPerDDL;imod++){
109 for(Int_t isid=0;isid<kSides;isid++){
110 Int_t index=kSides*(kModPerDDL*iddl+imod)+isid;
111 corr[index]=new AliITSOnlineSDDCMN(iddl,imod,isid);
117 /* read the data files */
119 for (n=1;n<argc;n++) {
121 status=monitorSetDataSource( argv[n] );
123 printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
127 /* report progress */
128 /* in this example, indexed on the number of files */
129 // Progress report inside the event loop as well?
130 daqDA_progressReport(10+40*iStep*n/argc);
134 struct eventHeaderStruct *event;
135 eventTypeType eventT;
138 status=monitorGetEventDynamic((void **)&event);
139 if (status==MON_ERR_EOF) break; /* end of monitoring file has been reached */
141 printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
145 /* retry if got no event */
151 if(iev>maxNEvents) break;
153 /* use event - here, just write event id to result file */
154 eventT=event->eventType;
155 switch (event->eventType){
165 // case PHYSICS_EVENT: // comment this line for test raw data
166 // break; // comment this line for test raw data
169 case CALIBRATION_EVENT:
170 break; // uncomment this line for test raw data
171 case PHYSICS_EVENT: // uncomment this line for test raw data
172 printf(" event number = %i \n",iev);
173 AliRawReader *rawReader = new AliRawReaderDate((void*)event);
174 rawReader->SelectEquipment(17,eqOffset+1,eqOffset+DDLrange);
178 while(rawReader->ReadHeader()){
179 const UInt_t *subev = rawReader->GetSubEventAttributes();
180 if(subev[0]==0 && subev[1]==0 && subev[2]==0) evtyp=1;
184 for(Int_t iddl=0; iddl<kTotDDL;iddl++){
185 for(Int_t imod=0; imod<kModPerDDL;imod++){
186 for(Int_t isid=0;isid<kSides;isid++){
187 Int_t index=kSides*(kModPerDDL*iddl+imod)+isid;
188 histo[index]->Reset();
192 AliITSRawStreamSDD s(rawReader);
195 Int_t iDDL=rawReader->GetDDLID();
196 Int_t iCarlos=s.GetCarlosId();
197 if(iDDL>=0 && iDDL<kTotDDL && s.IsCompletedModule()==kFALSE){
198 Int_t index=kSides*(kModPerDDL*iDDL+iCarlos)+s.GetChannel();
199 histo[index]->Fill(s.GetCoord2(),s.GetCoord1(),s.GetSignal());
203 for(Int_t iddl=0; iddl<kTotDDL;iddl++){
204 for(Int_t imod=0; imod<kModPerDDL;imod++){
205 for(Int_t isid=0;isid<kSides;isid++){
206 Int_t index=kSides*(kModPerDDL*iddl+imod)+isid;
207 if(iStep==0) base[index]->AddEvent(histo[index]);
208 if(iStep==1) corr[index]->AddEvent(histo[index]);
220 for(Int_t iddl=0; iddl<kTotDDL;iddl++){
221 for(Int_t imod=0; imod<kModPerDDL;imod++){
222 for(Int_t isid=0;isid<kSides;isid++){
223 Int_t index=kSides*(kModPerDDL*iddl+imod)+isid;
224 base[index]->ValidateAnodes();
225 base[index]->WriteToASCII();
233 printf("Run #%s, received %d calibration events\n",getenv("DATE_RUN_NUMBER"),iev);
235 /* report progress */
236 daqDA_progressReport(90);
240 TFile *fh=new TFile("SDDbaseHistos.root","RECREATE");
241 for(Int_t iddl=0; iddl<kTotDDL;iddl++){
242 for(Int_t imod=0; imod<kModPerDDL;imod++){
243 for(Int_t isid=0;isid<kSides;isid++){
244 Int_t index=kSides*(kModPerDDL*iddl+imod)+isid;
245 corr[index]->ValidateAnodes();
246 corr[index]->WriteToASCII();
247 corr[index]->WriteToROOT(fh);
254 /* report progress */
255 daqDA_progressReport(100);