2 - Contact: - prino@to.infn.it
6 - Number of events needed:
8 - Output Files: - SDDinj_ddl*c*_sid*.data
13 //////////////////////////////////////////////////////////////////////////////
14 // Detector Algorithm for analysis of SDD injector events. //
16 // Produces ASCII output files with: //
18 // 2. event timestamp //
19 // 3. Fit parameters of drift vel. vs. anode //
20 // Tar Files are written to FXS //
22 // Author: F. Prino (prino@to.infn.it) //
24 //////////////////////////////////////////////////////////////////////////////
44 #include <TPluginManager.h>
48 #include "AliRawReaderDate.h"
49 #include "AliITSOnlineSDDInjectors.h"
50 #include "AliITSRawStreamSDD.h"
52 Arguments: list of DATE raw data files
54 int main(int argc, char **argv) {
59 // line added to solve IO problems
60 gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo",
66 /* log start of process */
67 printf("ITS SDD INJ algorithm program started\n");
70 /* check that we got some arguments = list of files */
72 printf("Wrong number of arguments\n");
77 Int_t maxNEvents=10; // maximum number of events to be analyzed
78 const Int_t kTotDDL=24;
79 const Int_t kModPerDDL=12;
81 Int_t adcSamplFreq=40;
82 if(gSystem->Getenv("DAQ_DETDB_LOCAL")!=NULL){
83 const char* dir=gSystem->Getenv("DAQ_DETDB_LOCAL");
84 TString filnam=Form("%s/fee.conf",dir);
85 FILE* feefil=fopen(filnam.Data(),"r");
86 fscanf(feefil,"%d \n",&adcSamplFreq);
91 AliITSOnlineSDDInjectors **injan=new AliITSOnlineSDDInjectors*[kTotDDL*kModPerDDL*kSides];
92 TH2F **histo=new TH2F*[kTotDDL*kModPerDDL*kSides];
93 Int_t nWrittenEv[kTotDDL*kModPerDDL*kSides];
94 Bool_t isFilled[kTotDDL*kModPerDDL*kSides];
97 for(Int_t iddl=0; iddl<kTotDDL;iddl++){
98 for(Int_t imod=0; imod<kModPerDDL;imod++){
99 for(Int_t isid=0;isid<kSides;isid++){
100 Int_t index=kSides*(kModPerDDL*iddl+imod)+isid;
101 injan[index]=new AliITSOnlineSDDInjectors(iddl,imod,isid);
102 if(adcSamplFreq==20) injan[index]->Set20MHzConfig();
103 else injan[index]->Set40MHzConfig();
104 sprintf(hisnam,"h%02dc%02ds%d",iddl,imod,isid);
105 histo[index]=new TH2F(hisnam,"",256,-0.5,255.5,256,-0.5,255.5);
112 /* report progress */
113 daqDA_progressReport(10);
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+80*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
166 case CALIBRATION_EVENT:
167 break; // uncomment this line for test raw data
168 case PHYSICS_EVENT: // uncomment this line for test raw data
169 printf(" event number = %i \n",iev);
170 AliRawReader *rawReader = new AliRawReaderDate((void*)event);
172 UInt_t timeSt=rawReader->GetTimestamp();
173 //UInt_t timeSt=iev*5000+12; // fake timestamp for test
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(s.IsCompletedModule()) continue;
195 if(s.IsCompletedDDL()) continue;
196 if(iDDL>=0 && iDDL<kTotDDL){
197 Int_t index=kSides*(kModPerDDL*iDDL+iCarlos)+s.GetChannel();
198 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;
208 injan[index]->Reset();
209 injan[index]->AnalyzeEvent(histo[index]);
210 injan[index]->WriteToASCII(iev,timeSt,nWrittenEv[index]);
223 Char_t filnam[100],command[120];
224 for(Int_t iddl=0; iddl<kTotDDL;iddl++){
225 for(Int_t imod=0; imod<kModPerDDL;imod++){
226 for(Int_t isid=0;isid<kSides;isid++){
227 Int_t index=kSides*(kModPerDDL*iddl+imod)+isid;
228 if(nWrittenEv[index]>0){
229 sprintf(filnam,"SDDinj_ddl%02dc%02d_sid%d.data",iddl,imod,isid);
230 sprintf(command,"tar -rf SDDinj_LDC.tar %s",filnam);
231 gSystem->Exec(command);
238 printf("Run #%s, received %d injector events\n",getenv("DATE_RUN_NUMBER"),iev);
240 /* report progress */
241 daqDA_progressReport(90);
244 status=daqDA_FES_storeFile("./SDDinj_LDC.tar","SDD_Injec");
246 /* report progress */
247 daqDA_progressReport(100);