]>
Commit | Line | Data |
---|---|---|
00252d8f | 1 | /* |
2 | - Contact: - prino@to.infn.it | |
1ccdd571 | 3 | - Link: - http://www.to.infn.it/~prino/alice/RawData/run11173.date |
4 | - Run Type: - PULSER_RUN | |
00252d8f | 5 | - DA Type: - LDC |
6 | - Number of events needed: 100 | |
979b5a5f | 7 | - Input Files: - SDDbase_step1_ddl*c*_sid*.data |
8 | - Output Files: - SDDbase_ddl*c*_sid*.data | |
00252d8f | 9 | - Trigger types used: |
10 | */ | |
11 | ||
3083967f | 12 | ////////////////////////////////////////////////////////////////////////////// |
13 | // Detector Algorithm for analysis of SDD test pulse runs. // | |
14 | // // | |
15 | // Produces ASCII and ROOT output files with: // | |
16 | // 1. anode quality bit // | |
17 | // 1. Baseline values // | |
18 | // 2. Raw noise // | |
19 | // 3. Common mode coefficients // | |
20 | // 4. Noise corrected for common mode // | |
21 | // 5. Gain // | |
22 | // Files are written to FXS // | |
23 | // // | |
24 | // Author: F. Prino (prino@to.infn.it) // | |
25 | // // | |
26 | ////////////////////////////////////////////////////////////////////////////// | |
27 | ||
28 | ||
29 | ||
30 | extern "C" { | |
31 | #include "daqDA.h" | |
32 | } | |
33 | ||
34 | #include "event.h" | |
35 | #include "monitor.h" | |
36 | ||
37 | #include <stdio.h> | |
38 | #include <stdlib.h> | |
39 | ||
40 | // ROOT includes | |
41 | #include <TFile.h> | |
42 | #include <TH1F.h> | |
43 | #include <TH2F.h> | |
44 | #include <TSystem.h> | |
00252d8f | 45 | #include <TROOT.h> |
46 | #include <TPluginManager.h> | |
3083967f | 47 | |
48 | // AliRoot includes | |
49 | #include "AliRawReaderDate.h" | |
50 | #include "AliITSOnlineSDDTP.h" | |
51 | #include "AliITSRawStreamSDD.h" | |
52 | /* Main routine | |
53 | Arguments: list of DATE raw data files | |
54 | */ | |
55 | int main(int argc, char **argv) { | |
56 | ||
57 | int status = 0; | |
58 | ||
00252d8f | 59 | // line added to solve IO problems |
60 | gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo", | |
61 | "*", | |
62 | "TStreamerInfo", | |
63 | "RIO", | |
64 | "TStreamerInfo()"); | |
3083967f | 65 | |
66 | /* log start of process */ | |
979b5a5f | 67 | printf("ITS SDD TEST-PULSE algorithm program started\n"); |
3083967f | 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 | ||
1ccdd571 | 77 | Int_t maxNEvents=15; // maximum number of events to be analyzed |
979b5a5f | 78 | const Int_t kTotDDL=24; |
79 | const Int_t kModPerDDL=12; | |
80 | const Int_t kSides=2; | |
81 | ||
82 | AliITSOnlineSDDTP **tpan=new AliITSOnlineSDDTP*[kTotDDL*kModPerDDL*kSides]; | |
83 | TH2F **histo=new TH2F*[kTotDDL*kModPerDDL*kSides]; | |
84 | Bool_t isFilled[kTotDDL*kModPerDDL*kSides]; | |
3083967f | 85 | Char_t hisnam[20]; |
979b5a5f | 86 | for(Int_t iddl=0; iddl<kTotDDL;iddl++){ |
87 | for(Int_t imod=0; imod<kModPerDDL;imod++){ | |
88 | for(Int_t isid=0;isid<kSides;isid++){ | |
89 | Int_t index=kSides*(kModPerDDL*iddl+imod)+isid; | |
90 | tpan[index]=new AliITSOnlineSDDTP(iddl,imod,isid,100.); | |
91 | sprintf(hisnam,"h%02dc%02ds%d",iddl,imod,isid); | |
92 | histo[index]=new TH2F(hisnam,"",256,-0.5,255.5,256,-0.5,255.5); | |
93 | isFilled[index]=0; | |
94 | } | |
3083967f | 95 | } |
96 | } | |
97 | ||
98 | /* report progress */ | |
99 | daqDA_progressReport(10); | |
1ccdd571 | 100 | Int_t iev=0,iAnalyzedEv=0; |
3083967f | 101 | /* read the data files */ |
102 | int n; | |
103 | for (n=1;n<argc;n++) { | |
104 | ||
105 | status=monitorSetDataSource( argv[n] ); | |
106 | if (status!=0) { | |
107 | printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status)); | |
108 | return -1; | |
109 | } | |
110 | ||
111 | /* report progress */ | |
112 | /* in this example, indexed on the number of files */ | |
113 | // Progress report inside the event loop as well? | |
114 | daqDA_progressReport(10+80*n/argc); | |
115 | ||
116 | /* read the file */ | |
117 | for(;;) { | |
118 | struct eventHeaderStruct *event; | |
119 | eventTypeType eventT; | |
120 | ||
121 | /* get next event */ | |
122 | status=monitorGetEventDynamic((void **)&event); | |
123 | if (status==MON_ERR_EOF) break; /* end of monitoring file has been reached */ | |
124 | if (status!=0) { | |
125 | printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status)); | |
126 | return -1; | |
127 | } | |
128 | ||
129 | /* retry if got no event */ | |
130 | if (event==NULL) { | |
131 | break; | |
132 | } | |
133 | ||
1ccdd571 | 134 | if(iAnalyzedEv>=maxNEvents) break; |
3083967f | 135 | iev++; |
3083967f | 136 | |
137 | /* use event - here, just write event id to result file */ | |
138 | eventT=event->eventType; | |
139 | switch (event->eventType){ | |
140 | ||
141 | /* START OF RUN */ | |
142 | case START_OF_RUN: | |
143 | break; | |
144 | ||
145 | /* END OF RUN */ | |
146 | case END_OF_RUN: | |
147 | break; | |
148 | ||
149 | // case PHYSICS_EVENT: // comment this line for test raw data | |
150 | // break; // comment this line for test raw data | |
151 | ||
152 | case CALIBRATION_EVENT: | |
153 | break; // uncomment this line for test raw data | |
154 | case PHYSICS_EVENT: // uncomment this line for test raw data | |
155 | printf(" event number = %i \n",iev); | |
156 | AliRawReader *rawReader = new AliRawReaderDate((void*)event); | |
3083967f | 157 | |
158 | Int_t evtyp=0; | |
159 | while(rawReader->ReadHeader()){ | |
160 | const UInt_t *subev = rawReader->GetSubEventAttributes(); | |
161 | if(subev[0]==0 && subev[1]==0 && subev[2]==0) evtyp=1; | |
162 | } | |
163 | ||
164 | rawReader->Reset(); | |
979b5a5f | 165 | for(Int_t iddl=0; iddl<kTotDDL;iddl++){ |
166 | for(Int_t imod=0; imod<kModPerDDL;imod++){ | |
167 | for(Int_t isid=0;isid<kSides;isid++){ | |
168 | Int_t index=kSides*(kModPerDDL*iddl+imod)+isid; | |
169 | histo[index]->Reset(); | |
170 | } | |
3083967f | 171 | } |
172 | } | |
173 | AliITSRawStreamSDD s(rawReader); | |
3083967f | 174 | |
175 | while(s.Next()){ | |
979b5a5f | 176 | Int_t iDDL=rawReader->GetDDLID(); |
177 | Int_t iCarlos=s.GetCarlosId(); | |
de075dae | 178 | if(s.IsCompletedModule()) continue; |
179 | if(s.IsCompletedDDL()) continue; | |
180 | if(iDDL>=0 && iDDL<kTotDDL){ | |
979b5a5f | 181 | Int_t index=kSides*(kModPerDDL*iDDL+iCarlos)+s.GetChannel(); |
3083967f | 182 | histo[index]->Fill(s.GetCoord2(),s.GetCoord1(),s.GetSignal()); |
1ccdd571 | 183 | isFilled[index]=1; |
3083967f | 184 | } |
185 | } | |
186 | delete rawReader; | |
979b5a5f | 187 | for(Int_t iddl=0; iddl<kTotDDL;iddl++){ |
188 | for(Int_t imod=0; imod<kModPerDDL;imod++){ | |
189 | for(Int_t isid=0;isid<kSides;isid++){ | |
190 | Int_t index=kSides*(kModPerDDL*iddl+imod)+isid; | |
191 | if(isFilled[index]) tpan[index]->AddEvent(histo[index]); | |
192 | } | |
3083967f | 193 | } |
194 | } | |
195 | ||
196 | /* free resources */ | |
1ccdd571 | 197 | iAnalyzedEv++; |
3083967f | 198 | free(event); |
199 | } | |
200 | } | |
201 | ||
202 | } | |
203 | ||
204 | TFile *fh=new TFile("SDDgainHistos.root","RECREATE"); | |
205 | Char_t filnam[100],command[120]; | |
979b5a5f | 206 | for(Int_t iddl=0; iddl<kTotDDL;iddl++){ |
207 | for(Int_t imod=0; imod<kModPerDDL;imod++){ | |
208 | for(Int_t isid=0;isid<kSides;isid++){ | |
209 | Int_t index=kSides*(kModPerDDL*iddl+imod)+isid; | |
210 | if(isFilled[index]){ | |
211 | tpan[index]->ValidateAnodes(); | |
212 | tpan[index]->WriteToASCII(); | |
213 | tpan[index]->WriteToROOT(fh); | |
214 | sprintf(filnam,"SDDbase_ddl%02dc%02d_sid%d.data",iddl,imod,isid); | |
215 | sprintf(command,"tar -rf SDDbase_LDC.tar %s",filnam); | |
216 | gSystem->Exec(command); | |
217 | } | |
1ccdd571 | 218 | } |
3083967f | 219 | } |
220 | } | |
221 | fh->Close(); | |
222 | ||
223 | /* write report */ | |
1ccdd571 | 224 | printf("Run #%s, received %d calibration events\n",getenv("DATE_RUN_NUMBER"),iAnalyzedEv); |
3083967f | 225 | |
226 | /* report progress */ | |
227 | daqDA_progressReport(90); | |
228 | ||
229 | ||
230 | ||
231 | fh->Close(); | |
232 | ||
233 | ||
234 | ||
1ccdd571 | 235 | status=daqDA_FES_storeFile("./SDDbase_LDC.tar","SDD_Calib"); |
3083967f | 236 | |
237 | /* report progress */ | |
238 | daqDA_progressReport(100); | |
239 | ||
240 | ||
241 | ||
242 | return status; | |
243 | } |