]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/ITSSDDINJda.cxx
Fixes related to the placement of the SPD ladders w.r.t. the half staves (A. Dainese)
[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"
51/* Main routine
52 Arguments: list of DATE raw data files
53*/
54int main(int argc, char **argv) {
55
56 int status = 0;
57
58
00252d8f 59 // line added to solve IO problems
60 gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo",
61 "*",
62 "TStreamerInfo",
63 "RIO",
64 "TStreamerInfo()");
65
4c82df4c 66 /* log start of process */
67 printf("ITS SDD INJ algorithm program started\n");
68
69
70 /* check that we got some arguments = list of files */
71 if (argc<2) {
72 printf("Wrong number of arguments\n");
73 return -1;
74 }
75
76
767934e8 77 Int_t eqOffset = 256;
78 Int_t DDLrange = 24;
4c82df4c 79 Int_t maxNEvents=10; // maximum number of events to be analyzed
979b5a5f 80 const Int_t kTotDDL=24;
81 const Int_t kModPerDDL=12;
82 const Int_t kSides=2;
83 AliITSOnlineSDDInjectors **injan=new AliITSOnlineSDDInjectors*[kTotDDL*kModPerDDL*kSides];
84 TH2F **histo=new TH2F*[kTotDDL*kModPerDDL*kSides];
85 Int_t nWrittenEv[kTotDDL*kModPerDDL*kSides];
86 Bool_t isFilled[kTotDDL*kModPerDDL*kSides];
4c82df4c 87
88 Char_t hisnam[20];
979b5a5f 89 for(Int_t iddl=0; iddl<kTotDDL;iddl++){
90 for(Int_t imod=0; imod<kModPerDDL;imod++){
91 for(Int_t isid=0;isid<kSides;isid++){
92 Int_t index=kSides*(kModPerDDL*iddl+imod)+isid;
93 injan[index]=new AliITSOnlineSDDInjectors(iddl,imod,isid);
94 sprintf(hisnam,"h%02dc%02ds%d",iddl,imod,isid);
95 histo[index]=new TH2F(hisnam,"",256,-0.5,255.5,256,-0.5,255.5);
96 nWrittenEv[index]=0;
97 isFilled[index]=0;
98 }
4c82df4c 99 }
100 }
101
102 /* report progress */
103 daqDA_progressReport(10);
104 Int_t iev=0;
105 /* read the data files */
106 int n;
107 for (n=1;n<argc;n++) {
108
109 status=monitorSetDataSource( argv[n] );
110 if (status!=0) {
111 printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
112 return -1;
113 }
114
115 /* report progress */
116 /* in this example, indexed on the number of files */
117 // Progress report inside the event loop as well?
118 daqDA_progressReport(10+80*n/argc);
119
120 /* read the file */
121 for(;;) {
122 struct eventHeaderStruct *event;
123 eventTypeType eventT;
124
125 /* get next event */
126 status=monitorGetEventDynamic((void **)&event);
127 if (status==MON_ERR_EOF) break; /* end of monitoring file has been reached */
128 if (status!=0) {
129 printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
130 return -1;
131 }
132
133 /* retry if got no event */
134 if (event==NULL) {
135 break;
136 }
137
138 iev++;
139 if(iev>maxNEvents) break;
140
141 /* use event - here, just write event id to result file */
142 eventT=event->eventType;
143 switch (event->eventType){
144
145 /* START OF RUN */
146 case START_OF_RUN:
147 break;
148
149 /* END OF RUN */
150 case END_OF_RUN:
151 break;
152
153 // case PHYSICS_EVENT: // comment this line for test raw data
154 // break; // comment this line for test raw data
155
156 case CALIBRATION_EVENT:
157 break; // uncomment this line for test raw data
158 case PHYSICS_EVENT: // uncomment this line for test raw data
159 printf(" event number = %i \n",iev);
160 AliRawReader *rawReader = new AliRawReaderDate((void*)event);
767934e8 161 rawReader->SelectEquipment(17,eqOffset+1,eqOffset+DDLrange);
4c82df4c 162
cd452b3b 163 UInt_t timeSt=rawReader->GetTimestamp();
164 //UInt_t timeSt=iev*5000+12; // fake timestamp for test
4c82df4c 165 Int_t evtyp=0;
166 while(rawReader->ReadHeader()){
167 const UInt_t *subev = rawReader->GetSubEventAttributes();
168 if(subev[0]==0 && subev[1]==0 && subev[2]==0) evtyp=1;
169 }
170
171 rawReader->Reset();
979b5a5f 172 for(Int_t iddl=0; iddl<kTotDDL;iddl++){
173 for(Int_t imod=0; imod<kModPerDDL;imod++){
174 for(Int_t isid=0;isid<kSides;isid++){
175 Int_t index=kSides*(kModPerDDL*iddl+imod)+isid;
176 histo[index]->Reset();
177 }
4c82df4c 178 }
179 }
180 AliITSRawStreamSDD s(rawReader);
4c82df4c 181
182 while(s.Next()){
979b5a5f 183 Int_t iDDL=rawReader->GetDDLID();
184 Int_t iCarlos=s.GetCarlosId();
185 if(iDDL>=0 && iDDL<kTotDDL && s.IsCompletedModule()==kFALSE){
186 Int_t index=kSides*(kModPerDDL*iDDL+iCarlos)+s.GetChannel();
4c82df4c 187 histo[index]->Fill(s.GetCoord2(),s.GetCoord1(),s.GetSignal());
979b5a5f 188 isFilled[index]=1;
4c82df4c 189 }
190 }
191 delete rawReader;
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 if(isFilled[index]){
197 injan[index]->Reset();
198 injan[index]->AnalyzeEvent(histo[index]);
199 injan[index]->WriteToASCII(iev,timeSt,nWrittenEv[index]);
200 nWrittenEv[index]++;
201 }
202 }
4c82df4c 203 }
204 }
4c82df4c 205 /* free resources */
206 free(event);
207 }
208 }
209
210 }
211
212 Char_t filnam[100],command[120];
979b5a5f 213 for(Int_t iddl=0; iddl<kTotDDL;iddl++){
214 for(Int_t imod=0; imod<kModPerDDL;imod++){
215 for(Int_t isid=0;isid<kSides;isid++){
216 Int_t index=kSides*(kModPerDDL*iddl+imod)+isid;
217 if(nWrittenEv[index]>0){
218 sprintf(filnam,"SDDinj_ddl%02dc%02d_sid%d.data",iddl,imod,isid);
219 sprintf(command,"tar -rf SDDinj_LDC.tar %s",filnam);
220 gSystem->Exec(command);
221 }
222 }
223 }
4c82df4c 224 }
225
226 /* write report */
227 printf("Run #%s, received %d injector events\n",getenv("DATE_RUN_NUMBER"),iev);
228
229 /* report progress */
230 daqDA_progressReport(90);
231
232
233 status=daqDA_FES_storeFile("./SDDinj_LDC1.tar","SDD_Calib");
234
235 /* report progress */
236 daqDA_progressReport(100);
237
238
239
240 return status;
241}