2 - Contact: - prino@to.infn.it
3 - Link: - alien:///alice/data/2009/LHC09c_SDD/000079098/raw/09000079098024.10.root
6 - Number of events needed: >20
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>
45 #include <TObjArray.h>
46 #include <TObjString.h>
51 #include "AliRawReaderDate.h"
52 #include "AliITSOnlineSDDInjectors.h"
53 #include "AliITSRawStreamSDD.h"
54 #include "AliITSRawStreamSDDCompressed.h"
61 Arguments: list of DATE raw data files
63 int main(int argc, char **argv) {
64 // main - Arguments: list of DATE raw data files
68 // line added to solve IO problems
69 gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo",
75 /* log start of process */
76 printf("ITS SDD INJ algorithm program started\n");
79 /* check that we got some arguments = list of files */
81 printf("Wrong number of arguments\n");
86 Int_t maxNEvents=20; // maximum number of events to be analyzed
87 const Int_t kTotDDL=24;
88 const Int_t kModPerDDL=12;
92 gSystem->Exec("rm -f SDDinj_ddl*.data");
93 gSystem->Exec("rm -f SDDinj_LDC.tar");
97 AliITSOnlineSDDInjectors **injan=new AliITSOnlineSDDInjectors*[kTotDDL*kModPerDDL*kSides];
98 TH2F **histo=new TH2F*[kTotDDL*kModPerDDL*kSides];
99 Int_t nWrittenEv[kTotDDL*kModPerDDL*kSides];
100 Bool_t isFilled[kTotDDL*kModPerDDL*kSides];
101 Bool_t writtenoutput=kFALSE;
104 for(Int_t iddl=0; iddl<kTotDDL;iddl++){
105 for(Int_t imod=0; imod<kModPerDDL;imod++){
106 for(Int_t isid=0;isid<kSides;isid++){
107 Int_t index=kSides*(kModPerDDL*iddl+imod)+isid;
108 injan[index]=new AliITSOnlineSDDInjectors(iddl,imod,isid);
109 sprintf(hisnam,"h%02dc%02ds%d",iddl,imod,isid);
110 histo[index]=new TH2F(hisnam,"",256,-0.5,255.5,256,-0.5,255.5);
117 /* report progress */
118 daqDA_progressReport(10);
123 Int_t nEvToBeSkipped=5;
125 /* read the data files */
127 for (n=1;n<argc;n++) {
129 status=monitorSetDataSource( argv[n] );
131 printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
135 /* report progress */
136 /* in this example, indexed on the number of files */
137 // Progress report inside the event loop as well?
138 daqDA_progressReport(10+80*n/argc);
142 struct eventHeaderStruct *event;
143 eventTypeType eventT;
146 status=monitorGetEventDynamic((void **)&event);
147 if (status==MON_ERR_EOF) break; /* end of monitoring file has been reached */
149 printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
152 /* retry if got no event */
159 /* use event - here, just write event id to result file */
160 eventT=event->eventType;
161 switch (event->eventType){
171 // case PHYSICS_EVENT: // comment this line for test raw data
172 // break; // comment this line for test raw data
174 case CALIBRATION_EVENT:
175 break; // uncomment this line for test raw data
176 case PHYSICS_EVENT: // uncomment this line for test raw data
177 printf(" Event number = %i ",iev);
179 if(ievInj<=nEvToBeSkipped){
180 printf(" -> SKIP\n");
183 printf(" -> Analyze\n");
186 AliRawReader *rawReader = new AliRawReaderDate((void*)event);
187 timeSt=rawReader->GetTimestamp();
189 UChar_t cdhAttr=AliITSRawStreamSDD::ReadBlockAttributes(rawReader);
190 amSamplFreq=AliITSRawStreamSDD::ReadAMSamplFreqFromCDH(cdhAttr);
191 AliITSRawStream* s=AliITSRawStreamSDD::CreateRawStreamSDD(rawReader,cdhAttr);
193 printf("Use %s raw stream, sampling frequency %d MHz\n",s->ClassName(),amSamplFreq);
196 for(Int_t iddl=0; iddl<kTotDDL;iddl++){
197 for(Int_t imod=0; imod<kModPerDDL;imod++){
198 for(Int_t isid=0;isid<kSides;isid++){
199 Int_t index=kSides*(kModPerDDL*iddl+imod)+isid;
200 histo[index]->Reset();
206 Int_t iDDL=rawReader->GetDDLID();
207 Int_t iCarlos=s->GetCarlosId();
208 if(s->IsCompletedModule()) continue;
209 if(s->IsCompletedDDL()) continue;
210 if(iDDL>=0 && iDDL<kTotDDL){
211 Int_t index=kSides*(kModPerDDL*iDDL+iCarlos)+s->GetChannel();
212 histo[index]->Fill(s->GetCoord2(),s->GetCoord1(),s->GetSignal());
219 for(Int_t iddl=0; iddl<kTotDDL;iddl++){
220 for(Int_t imod=0; imod<kModPerDDL;imod++){
221 for(Int_t isid=0;isid<kSides;isid++){
222 Int_t index=kSides*(kModPerDDL*iddl+imod)+isid;
224 if(amSamplFreq==20) injan[index]->Set20MHzConfig();
225 else injan[index]->Set40MHzConfig();
226 injan[index]->AddEvent(histo[index]);
227 // injan[index]->WriteToASCII(iev,timeSt,nWrittenEv[index]);
236 if(ievUsed>=maxNEvents) break;
242 TObjString timeinfo(Form("%02d%02d%02d%02d%02d%02d",time.GetYear()-2000,time.GetMonth(),time.GetDay(),time.GetHour(),time.GetMinute(),time.GetSecond()));
243 printf("Run #%s, received %d calibration events, time %s\n",getenv("DATE_RUN_NUMBER"),ievUsed,timeinfo.GetString().Data());
245 /* report progress */
246 daqDA_progressReport(90);
247 TObjArray* dspHistos=new TObjArray();
250 Char_t filnam[100],command[120];
251 for(Int_t iddl=0; iddl<kTotDDL;iddl++){
252 for(Int_t imod=0; imod<kModPerDDL;imod++){
253 for(Int_t isid=0;isid<kSides;isid++){
254 Int_t index=kSides*(kModPerDDL*iddl+imod)+isid;
255 if(nWrittenEv[index]>0){
256 injan[index]->FitMeanDriftSpeedVsAnode();
257 injan[index]->WriteToASCII(0,timeSt,0);
258 injan[index]->WriteInjectorStatusToASCII();
259 dspHistos->AddLast(injan[index]->GetMeanDriftSpeedVsPadHisto());
260 sprintf(filnam,"SDDinj_ddl%02dc%02d_sid%d.data",iddl,imod,isid);
261 sprintf(command,"tar -rf SDDinj_LDC.tar %s",filnam);
262 gSystem->Exec(command);
267 status=daqDA_FES_storeFile("./SDDinj_LDC.tar","SDD_Injec");
271 amore::da::AmoreDA amoreDA(amore::da::AmoreDA::kSender);
272 Int_t statusamore =0;
273 statusamore += amoreDA.Send("TimeInfoInject",&timeinfo);
274 statusamore += amoreDA.Send("DriftSpeed",dspHistos);
276 printf("Warning: Failed to write Arrays in the AMORE database\n");
278 printf("amoreDA.Send() OK\n");
280 printf("Warning: SDDINJ DA not compiled with AMORE support\n");
283 TFile *fh=new TFile("SDDinjectHistos.root","RECREATE");
288 /* report progress */
289 daqDA_progressReport(100);