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");
55 Int_t maxNEvents=10; // maximum number of events to be analyzed
56 const Int_t nSDDmodules=12; // temp for test raw data
57 AliITSOnlineSDDInjectors **injan=new AliITSOnlineSDDInjectors*[2*nSDDmodules];
58 TH2F **histo=new TH2F*[2*nSDDmodules];
59 Int_t nWrittenEv[2*nSDDmodules];
62 for(Int_t imod=0; imod<nSDDmodules;imod++){
63 for(Int_t isid=0;isid<2;isid++){
64 Int_t index=2*imod+isid;
65 injan[index]=new AliITSOnlineSDDInjectors(imod,isid);
66 sprintf(hisnam,"his%03ds%d",imod,isid);
67 histo[index]=new TH2F(hisnam,"",256,-0.5,255.5,256,-0.5,255.5);
73 daqDA_progressReport(10);
75 /* read the data files */
77 for (n=1;n<argc;n++) {
79 status=monitorSetDataSource( argv[n] );
81 printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
86 /* in this example, indexed on the number of files */
87 // Progress report inside the event loop as well?
88 daqDA_progressReport(10+80*n/argc);
92 struct eventHeaderStruct *event;
96 status=monitorGetEventDynamic((void **)&event);
97 if (status==MON_ERR_EOF) break; /* end of monitoring file has been reached */
99 printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
103 /* retry if got no event */
109 if(iev>maxNEvents) break;
111 /* use event - here, just write event id to result file */
112 eventT=event->eventType;
113 switch (event->eventType){
123 // case PHYSICS_EVENT: // comment this line for test raw data
124 // break; // comment this line for test raw data
126 case CALIBRATION_EVENT:
127 break; // uncomment this line for test raw data
128 case PHYSICS_EVENT: // uncomment this line for test raw data
129 printf(" event number = %i \n",iev);
130 AliRawReader *rawReader = new AliRawReaderDate((void*)event);
131 rawReader->RequireHeader(kFALSE);
132 rawReader->SelectEquipment(17,101,101); // temp for test raw data
134 UInt_t timeSt=rawReader->GetTimestamp();
135 //UInt_t timeSt=iev*5000+12; // fake timestamp for test
137 while(rawReader->ReadHeader()){
138 const UInt_t *subev = rawReader->GetSubEventAttributes();
139 if(subev[0]==0 && subev[1]==0 && subev[2]==0) evtyp=1;
143 for(Int_t imod=0; imod<nSDDmodules;imod++){
144 for(Int_t isid=0; isid<2;isid++){
145 Int_t index=2*imod+isid;
146 histo[index]->Reset();
149 AliITSRawStreamSDD s(rawReader);
150 rawReader->SelectEquipment(17,101,101); // temp for test raw data
153 Int_t iddl=rawReader->GetDDLID();
154 iddl=0; // temporary for test raw data
155 Int_t isddmod=s.GetModuleNumber(iddl,s.GetCarlosId());
156 isddmod-=240; // to have SDD modules from 0 to 259
157 isddmod=s.GetCarlosId(); // temporary for test raw data
158 if(isddmod<nSDDmodules){
159 Int_t index=2*isddmod+s.GetChannel();
160 histo[index]->Fill(s.GetCoord2(),s.GetCoord1(),s.GetSignal());
164 for(Int_t imod=0; imod<nSDDmodules;imod++){
165 for(Int_t isid=0; isid<2;isid++){
166 Int_t index=2*imod+isid;
167 injan[index]->Reset();
168 injan[index]->AnalyzeEvent(histo[index]);
169 injan[index]->WriteToASCII(iev,timeSt,nWrittenEv[index]);
181 Char_t filnam[100],command[120];
182 for(Int_t imod=0; imod<nSDDmodules;imod++){
183 for(Int_t isid=0; isid<2;isid++){
184 sprintf(filnam,"SDDinj_mod%03d_sid%d.data",imod,isid);
185 sprintf(command,"tar -rf SDDinj_LDC1.tar %s",filnam);
186 gSystem->Exec(command);
191 printf("Run #%s, received %d injector events\n",getenv("DATE_RUN_NUMBER"),iev);
193 /* report progress */
194 daqDA_progressReport(90);
197 status=daqDA_FES_storeFile("./SDDinj_LDC1.tar","SDD_Calib");
199 /* report progress */
200 daqDA_progressReport(100);