1 //////////////////////////////////////////////////////////////////////////////
2 // Detector Algorithm for analysis of SDD injector events. //
4 // Produces ASCII output files with: //
6 // 2. event timestamp //
7 // 3. Fit parameters of drift vel. vs. anode //
8 // Tar Files are written to FXS //
10 // Author: F. Prino (prino@to.infn.it) //
12 //////////////////////////////////////////////////////////////////////////////
33 #include "AliRawReaderDate.h"
34 #include "AliITSOnlineSDDInjectors.h"
35 #include "AliITSRawStreamSDD.h"
37 Arguments: list of DATE raw data files
39 int main(int argc, char **argv) {
44 /* log start of process */
45 printf("ITS SDD INJ algorithm program started\n");
48 /* check that we got some arguments = list of files */
50 printf("Wrong number of arguments\n");
57 Int_t maxNEvents=10; // maximum number of events to be analyzed
58 const Int_t nSDDmodules=12; // temp for test raw data
59 AliITSOnlineSDDInjectors **injan=new AliITSOnlineSDDInjectors*[2*nSDDmodules];
60 TH2F **histo=new TH2F*[2*nSDDmodules];
61 Int_t nWrittenEv[2*nSDDmodules];
64 for(Int_t imod=0; imod<nSDDmodules;imod++){
65 for(Int_t isid=0;isid<2;isid++){
66 Int_t index=2*imod+isid;
67 injan[index]=new AliITSOnlineSDDInjectors(imod,isid);
68 sprintf(hisnam,"his%03ds%d",imod,isid);
69 histo[index]=new TH2F(hisnam,"",256,-0.5,255.5,256,-0.5,255.5);
75 daqDA_progressReport(10);
77 /* read the data files */
79 for (n=1;n<argc;n++) {
81 status=monitorSetDataSource( argv[n] );
83 printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
88 /* in this example, indexed on the number of files */
89 // Progress report inside the event loop as well?
90 daqDA_progressReport(10+80*n/argc);
94 struct eventHeaderStruct *event;
98 status=monitorGetEventDynamic((void **)&event);
99 if (status==MON_ERR_EOF) break; /* end of monitoring file has been reached */
101 printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
105 /* retry if got no event */
111 if(iev>maxNEvents) break;
113 /* use event - here, just write event id to result file */
114 eventT=event->eventType;
115 switch (event->eventType){
125 // case PHYSICS_EVENT: // comment this line for test raw data
126 // break; // comment this line for test raw data
128 case CALIBRATION_EVENT:
129 break; // uncomment this line for test raw data
130 case PHYSICS_EVENT: // uncomment this line for test raw data
131 printf(" event number = %i \n",iev);
132 AliRawReader *rawReader = new AliRawReaderDate((void*)event);
133 rawReader->RequireHeader(kFALSE);
134 rawReader->SelectEquipment(17,eqOffset+1,eqOffset+DDLrange);
136 UInt_t timeSt=rawReader->GetTimestamp();
137 //UInt_t timeSt=iev*5000+12; // fake timestamp for test
139 while(rawReader->ReadHeader()){
140 const UInt_t *subev = rawReader->GetSubEventAttributes();
141 if(subev[0]==0 && subev[1]==0 && subev[2]==0) evtyp=1;
145 for(Int_t imod=0; imod<nSDDmodules;imod++){
146 for(Int_t isid=0; isid<2;isid++){
147 Int_t index=2*imod+isid;
148 histo[index]->Reset();
151 AliITSRawStreamSDD s(rawReader);
154 Int_t iddl=rawReader->GetDDLID();
155 iddl=0; // temporary for test raw data
156 Int_t isddmod=s.GetModuleNumber(iddl,s.GetCarlosId());
157 isddmod-=240; // to have SDD modules from 0 to 259
158 isddmod=s.GetCarlosId(); // temporary for test raw data
159 if(isddmod<nSDDmodules&&s.IsCompletedModule()==kFALSE){
160 Int_t index=2*isddmod+s.GetChannel();
161 histo[index]->Fill(s.GetCoord2(),s.GetCoord1(),s.GetSignal());
165 for(Int_t imod=0; imod<nSDDmodules;imod++){
166 for(Int_t isid=0; isid<2;isid++){
167 Int_t index=2*imod+isid;
168 injan[index]->Reset();
169 injan[index]->AnalyzeEvent(histo[index]);
170 injan[index]->WriteToASCII(iev,timeSt,nWrittenEv[index]);
182 Char_t filnam[100],command[120];
183 for(Int_t imod=0; imod<nSDDmodules;imod++){
184 for(Int_t isid=0; isid<2;isid++){
185 sprintf(filnam,"SDDinj_mod%03d_sid%d.data",imod,isid);
186 sprintf(command,"tar -rf SDDinj_LDC1.tar %s",filnam);
187 gSystem->Exec(command);
192 printf("Run #%s, received %d injector events\n",getenv("DATE_RUN_NUMBER"),iev);
194 /* report progress */
195 daqDA_progressReport(90);
198 status=daqDA_FES_storeFile("./SDDinj_LDC1.tar","SDD_Calib");
200 /* report progress */
201 daqDA_progressReport(100);