]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/ITSSDDINJda.cxx
dq/dt and dq/dl reference plots
[u/mrichter/AliRoot.git] / ITS / ITSSDDINJda.cxx
CommitLineData
00252d8f 1/*
2- Contact: - prino@to.infn.it
3- Link: -
4- Run Type: - PHYSICS
5- DA Type: - LDC
6- Number of events needed:
7- Input Files: -
979b5a5f 8- Output Files: - SDDinj_ddl*c*_sid*.data
00252d8f 9- Trigger types used:
10*/
11
12
4c82df4c 13//////////////////////////////////////////////////////////////////////////////
14// Detector Algorithm for analysis of SDD injector events. //
15// //
16// Produces ASCII output files with: //
17// 1. event number //
18// 2. event timestamp //
19// 3. Fit parameters of drift vel. vs. anode //
20// Tar Files are written to FXS //
21// //
22// Author: F. Prino (prino@to.infn.it) //
23// //
24//////////////////////////////////////////////////////////////////////////////
25
26
27
28extern "C" {
29#include "daqDA.h"
30}
31
32#include "event.h"
33#include "monitor.h"
34
35#include <stdio.h>
36#include <stdlib.h>
37
38// ROOT includes
39#include <TFile.h>
40#include <TH1F.h>
41#include <TH2F.h>
42#include <TSystem.h>
00252d8f 43#include <TROOT.h>
44#include <TPluginManager.h>
45
4c82df4c 46
47// AliRoot includes
48#include "AliRawReaderDate.h"
49#include "AliITSOnlineSDDInjectors.h"
50#include "AliITSRawStreamSDD.h"
a8cd2ab2 51#include "AliITSRawStreamSDDCompressed.h"
4c82df4c 52/* Main routine
53 Arguments: list of DATE raw data files
54*/
55int main(int argc, char **argv) {
56
57 int status = 0;
58
59
00252d8f 60 // line added to solve IO problems
61 gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo",
62 "*",
63 "TStreamerInfo",
64 "RIO",
65 "TStreamerInfo()");
66
4c82df4c 67 /* log start of process */
68 printf("ITS SDD INJ algorithm program started\n");
69
70
71 /* check that we got some arguments = list of files */
72 if (argc<2) {
73 printf("Wrong number of arguments\n");
74 return -1;
75 }
76
77
78 Int_t maxNEvents=10; // maximum number of events to be analyzed
979b5a5f 79 const Int_t kTotDDL=24;
80 const Int_t kModPerDDL=12;
81 const Int_t kSides=2;
42e868a7 82 Int_t adcSamplFreq=40;
5065707f 83 Bool_t readfeeconf=kFALSE;
a8cd2ab2 84 Int_t dataformat=1;
5065707f 85 gSystem->Exec("rm -f SDDinj_ddl*.data");
42e868a7 86 if(gSystem->Getenv("DAQ_DETDB_LOCAL")!=NULL){
87 const char* dir=gSystem->Getenv("DAQ_DETDB_LOCAL");
5065707f 88 TString filnam=Form("%s/fee.conf",dir);
42e868a7 89 FILE* feefil=fopen(filnam.Data(),"r");
5065707f 90 if(feefil){
91 fscanf(feefil,"%d \n",&adcSamplFreq);
a8cd2ab2 92 fscanf(feefil,"%d \n",&dataformat);
5065707f 93 fclose(feefil);
94 readfeeconf=kTRUE;
a8cd2ab2 95 printf("ADC sampling frequency = %d MHz dataformat code =%d \n",adcSamplFreq,dataformat);
5065707f 96 }
42e868a7 97 }
a8cd2ab2 98 if(!readfeeconf) printf("File fee.conf not found, sampling frequency set to 40 MHz and data format to 1\n");
5065707f 99
42e868a7 100
101
979b5a5f 102 AliITSOnlineSDDInjectors **injan=new AliITSOnlineSDDInjectors*[kTotDDL*kModPerDDL*kSides];
103 TH2F **histo=new TH2F*[kTotDDL*kModPerDDL*kSides];
104 Int_t nWrittenEv[kTotDDL*kModPerDDL*kSides];
105 Bool_t isFilled[kTotDDL*kModPerDDL*kSides];
4c82df4c 106
107 Char_t hisnam[20];
979b5a5f 108 for(Int_t iddl=0; iddl<kTotDDL;iddl++){
109 for(Int_t imod=0; imod<kModPerDDL;imod++){
110 for(Int_t isid=0;isid<kSides;isid++){
111 Int_t index=kSides*(kModPerDDL*iddl+imod)+isid;
112 injan[index]=new AliITSOnlineSDDInjectors(iddl,imod,isid);
42e868a7 113 if(adcSamplFreq==20) injan[index]->Set20MHzConfig();
114 else injan[index]->Set40MHzConfig();
979b5a5f 115 sprintf(hisnam,"h%02dc%02ds%d",iddl,imod,isid);
116 histo[index]=new TH2F(hisnam,"",256,-0.5,255.5,256,-0.5,255.5);
117 nWrittenEv[index]=0;
118 isFilled[index]=0;
119 }
4c82df4c 120 }
121 }
122
123 /* report progress */
124 daqDA_progressReport(10);
125 Int_t iev=0;
5065707f 126 Int_t ievInj=0;
4c82df4c 127 /* read the data files */
128 int n;
129 for (n=1;n<argc;n++) {
130
131 status=monitorSetDataSource( argv[n] );
132 if (status!=0) {
133 printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
134 return -1;
135 }
136
137 /* report progress */
138 /* in this example, indexed on the number of files */
139 // Progress report inside the event loop as well?
140 daqDA_progressReport(10+80*n/argc);
141
142 /* read the file */
143 for(;;) {
144 struct eventHeaderStruct *event;
145 eventTypeType eventT;
146
147 /* get next event */
148 status=monitorGetEventDynamic((void **)&event);
149 if (status==MON_ERR_EOF) break; /* end of monitoring file has been reached */
150 if (status!=0) {
151 printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
152 return -1;
153 }
4c82df4c 154 /* retry if got no event */
155 if (event==NULL) {
156 break;
157 }
5065707f 158 iev++;
4c82df4c 159
4c82df4c 160
161 /* use event - here, just write event id to result file */
162 eventT=event->eventType;
163 switch (event->eventType){
164
165 /* START OF RUN */
166 case START_OF_RUN:
167 break;
168
169 /* END OF RUN */
170 case END_OF_RUN:
171 break;
172
173 // case PHYSICS_EVENT: // comment this line for test raw data
174 // break; // comment this line for test raw data
175
176 case CALIBRATION_EVENT:
177 break; // uncomment this line for test raw data
178 case PHYSICS_EVENT: // uncomment this line for test raw data
179 printf(" event number = %i \n",iev);
5065707f 180 ievInj++;
4c82df4c 181 AliRawReader *rawReader = new AliRawReaderDate((void*)event);
4c82df4c 182
cd452b3b 183 UInt_t timeSt=rawReader->GetTimestamp();
5065707f 184
4c82df4c 185 Int_t evtyp=0;
186 while(rawReader->ReadHeader()){
187 const UInt_t *subev = rawReader->GetSubEventAttributes();
188 if(subev[0]==0 && subev[1]==0 && subev[2]==0) evtyp=1;
189 }
190
191 rawReader->Reset();
979b5a5f 192 for(Int_t iddl=0; iddl<kTotDDL;iddl++){
193 for(Int_t imod=0; imod<kModPerDDL;imod++){
194 for(Int_t isid=0;isid<kSides;isid++){
195 Int_t index=kSides*(kModPerDDL*iddl+imod)+isid;
196 histo[index]->Reset();
197 }
4c82df4c 198 }
199 }
a8cd2ab2 200 AliITSRawStream* s;
201 if(dataformat==0){
202 s=new AliITSRawStreamSDD(rawReader);
203 }else{
204 s=new AliITSRawStreamSDDCompressed(rawReader);
205 if(dataformat==1) s->SetADCEncoded(kTRUE);
206 }
4c82df4c 207
a8cd2ab2 208 while(s->Next()){
979b5a5f 209 Int_t iDDL=rawReader->GetDDLID();
a8cd2ab2 210 Int_t iCarlos=s->GetCarlosId();
211 if(s->IsCompletedModule()) continue;
212 if(s->IsCompletedDDL()) continue;
de075dae 213 if(iDDL>=0 && iDDL<kTotDDL){
a8cd2ab2 214 Int_t index=kSides*(kModPerDDL*iDDL+iCarlos)+s->GetChannel();
215 histo[index]->Fill(s->GetCoord2(),s->GetCoord1(),s->GetSignal());
979b5a5f 216 isFilled[index]=1;
4c82df4c 217 }
218 }
219 delete rawReader;
979b5a5f 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 if(isFilled[index]){
225 injan[index]->Reset();
226 injan[index]->AnalyzeEvent(histo[index]);
227 injan[index]->WriteToASCII(iev,timeSt,nWrittenEv[index]);
228 nWrittenEv[index]++;
229 }
230 }
4c82df4c 231 }
232 }
4c82df4c 233 /* free resources */
234 free(event);
235 }
5065707f 236 if(ievInj>=maxNEvents) break;
4c82df4c 237 }
4c82df4c 238 }
5065707f 239 /* write report */
240 printf("Run #%s, received %d injector events\n",getenv("DATE_RUN_NUMBER"),ievInj);
241
242 gSystem->Exec("rm -f SDDinj_LDC.tar");
4c82df4c 243 Char_t filnam[100],command[120];
979b5a5f 244 for(Int_t iddl=0; iddl<kTotDDL;iddl++){
245 for(Int_t imod=0; imod<kModPerDDL;imod++){
246 for(Int_t isid=0;isid<kSides;isid++){
247 Int_t index=kSides*(kModPerDDL*iddl+imod)+isid;
248 if(nWrittenEv[index]>0){
249 sprintf(filnam,"SDDinj_ddl%02dc%02d_sid%d.data",iddl,imod,isid);
250 sprintf(command,"tar -rf SDDinj_LDC.tar %s",filnam);
251 gSystem->Exec(command);
252 }
253 }
254 }
4c82df4c 255 }
256
4c82df4c 257
258 /* report progress */
259 daqDA_progressReport(90);
260
261
2b066e71 262 status=daqDA_FES_storeFile("./SDDinj_LDC.tar","SDD_Injec");
4c82df4c 263
264 /* report progress */
265 daqDA_progressReport(100);
266
267
268
269 return status;
270}