]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/ITSSDDINJda.cxx
Adding comment lines to class description needed for Root documentation,
[u/mrichter/AliRoot.git] / ITS / ITSSDDINJda.cxx
CommitLineData
4c82df4c 1//////////////////////////////////////////////////////////////////////////////
2// Detector Algorithm for analysis of SDD injector events. //
3// //
4// Produces ASCII output files with: //
5// 1. event number //
6// 2. event timestamp //
7// 3. Fit parameters of drift vel. vs. anode //
8// Tar Files are written to FXS //
9// //
10// Author: F. Prino (prino@to.infn.it) //
11// //
12//////////////////////////////////////////////////////////////////////////////
13
14
15
16extern "C" {
17#include "daqDA.h"
18}
19
20#include "event.h"
21#include "monitor.h"
22
23#include <stdio.h>
24#include <stdlib.h>
25
26// ROOT includes
27#include <TFile.h>
28#include <TH1F.h>
29#include <TH2F.h>
30#include <TSystem.h>
31
32// AliRoot includes
33#include "AliRawReaderDate.h"
34#include "AliITSOnlineSDDInjectors.h"
35#include "AliITSRawStreamSDD.h"
36/* Main routine
37 Arguments: list of DATE raw data files
38*/
39int main(int argc, char **argv) {
40
41 int status = 0;
42
43
44 /* log start of process */
45 printf("ITS SDD INJ algorithm program started\n");
46
47
48 /* check that we got some arguments = list of files */
49 if (argc<2) {
50 printf("Wrong number of arguments\n");
51 return -1;
52 }
53
54
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];
60
61 Char_t hisnam[20];
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);
68 nWrittenEv[index]=0;
69 }
70 }
71
72 /* report progress */
73 daqDA_progressReport(10);
74 Int_t iev=0;
75 /* read the data files */
76 int n;
77 for (n=1;n<argc;n++) {
78
79 status=monitorSetDataSource( argv[n] );
80 if (status!=0) {
81 printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
82 return -1;
83 }
84
85 /* report progress */
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);
89
90 /* read the file */
91 for(;;) {
92 struct eventHeaderStruct *event;
93 eventTypeType eventT;
94
95 /* get next event */
96 status=monitorGetEventDynamic((void **)&event);
97 if (status==MON_ERR_EOF) break; /* end of monitoring file has been reached */
98 if (status!=0) {
99 printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
100 return -1;
101 }
102
103 /* retry if got no event */
104 if (event==NULL) {
105 break;
106 }
107
108 iev++;
109 if(iev>maxNEvents) break;
110
111 /* use event - here, just write event id to result file */
112 eventT=event->eventType;
113 switch (event->eventType){
114
115 /* START OF RUN */
116 case START_OF_RUN:
117 break;
118
119 /* END OF RUN */
120 case END_OF_RUN:
121 break;
122
123 // case PHYSICS_EVENT: // comment this line for test raw data
124 // break; // comment this line for test raw data
125
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
133
cd452b3b 134 UInt_t timeSt=rawReader->GetTimestamp();
135 //UInt_t timeSt=iev*5000+12; // fake timestamp for test
4c82df4c 136 Int_t evtyp=0;
137 while(rawReader->ReadHeader()){
138 const UInt_t *subev = rawReader->GetSubEventAttributes();
139 if(subev[0]==0 && subev[1]==0 && subev[2]==0) evtyp=1;
140 }
141
142 rawReader->Reset();
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();
147 }
148 }
149 AliITSRawStreamSDD s(rawReader);
150 rawReader->SelectEquipment(17,101,101); // temp for test raw data
151
152 while(s.Next()){
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());
161 }
162 }
163 delete rawReader;
4c82df4c 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]);
170 nWrittenEv[index]++;
171 }
172 }
173
174 /* free resources */
175 free(event);
176 }
177 }
178
179 }
180
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);
187 }
188 }
189
190 /* write report */
191 printf("Run #%s, received %d injector events\n",getenv("DATE_RUN_NUMBER"),iev);
192
193 /* report progress */
194 daqDA_progressReport(90);
195
196
197 status=daqDA_FES_storeFile("./SDDinj_LDC1.tar","SDD_Calib");
198
199 /* report progress */
200 daqDA_progressReport(100);
201
202
203
204 return status;
205}