]>
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" | |
a8cd2ab2 | 52 | #include "AliITSRawStreamSDDCompressed.h" |
3083967f | 53 | /* Main routine |
54 | Arguments: list of DATE raw data files | |
55 | */ | |
56 | int main(int argc, char **argv) { | |
57 | ||
58 | int status = 0; | |
59 | ||
00252d8f | 60 | // line added to solve IO problems |
61 | gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo", | |
62 | "*", | |
63 | "TStreamerInfo", | |
64 | "RIO", | |
65 | "TStreamerInfo()"); | |
3083967f | 66 | |
67 | /* log start of process */ | |
979b5a5f | 68 | printf("ITS SDD TEST-PULSE algorithm program started\n"); |
3083967f | 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 | ||
1ccdd571 | 78 | Int_t maxNEvents=15; // 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; | |
040d0012 | 82 | UInt_t amSamplFreq=40; |
83 | UChar_t cdhAttr=0; | |
84 | ||
5065707f | 85 | gSystem->Exec("rm -f SDDbase_LDC.tar"); |
979b5a5f | 86 | |
87 | AliITSOnlineSDDTP **tpan=new AliITSOnlineSDDTP*[kTotDDL*kModPerDDL*kSides]; | |
88 | TH2F **histo=new TH2F*[kTotDDL*kModPerDDL*kSides]; | |
89 | Bool_t isFilled[kTotDDL*kModPerDDL*kSides]; | |
040d0012 | 90 | Bool_t writtenoutput=kFALSE; |
3083967f | 91 | Char_t hisnam[20]; |
979b5a5f | 92 | for(Int_t iddl=0; iddl<kTotDDL;iddl++){ |
93 | for(Int_t imod=0; imod<kModPerDDL;imod++){ | |
94 | for(Int_t isid=0;isid<kSides;isid++){ | |
95 | Int_t index=kSides*(kModPerDDL*iddl+imod)+isid; | |
96 | tpan[index]=new AliITSOnlineSDDTP(iddl,imod,isid,100.); | |
97 | sprintf(hisnam,"h%02dc%02ds%d",iddl,imod,isid); | |
98 | histo[index]=new TH2F(hisnam,"",256,-0.5,255.5,256,-0.5,255.5); | |
99 | isFilled[index]=0; | |
100 | } | |
3083967f | 101 | } |
102 | } | |
103 | ||
104 | /* report progress */ | |
105 | daqDA_progressReport(10); | |
1ccdd571 | 106 | Int_t iev=0,iAnalyzedEv=0; |
3083967f | 107 | /* read the data files */ |
108 | int n; | |
109 | for (n=1;n<argc;n++) { | |
110 | ||
111 | status=monitorSetDataSource( argv[n] ); | |
112 | if (status!=0) { | |
113 | printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status)); | |
114 | return -1; | |
115 | } | |
116 | ||
117 | /* report progress */ | |
118 | /* in this example, indexed on the number of files */ | |
119 | // Progress report inside the event loop as well? | |
120 | daqDA_progressReport(10+80*n/argc); | |
121 | ||
122 | /* read the file */ | |
123 | for(;;) { | |
124 | struct eventHeaderStruct *event; | |
125 | eventTypeType eventT; | |
126 | ||
127 | /* get next event */ | |
128 | status=monitorGetEventDynamic((void **)&event); | |
129 | if (status==MON_ERR_EOF) break; /* end of monitoring file has been reached */ | |
130 | if (status!=0) { | |
131 | printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status)); | |
132 | return -1; | |
133 | } | |
134 | ||
135 | /* retry if got no event */ | |
136 | if (event==NULL) { | |
137 | break; | |
138 | } | |
139 | ||
1ccdd571 | 140 | if(iAnalyzedEv>=maxNEvents) break; |
3083967f | 141 | iev++; |
3083967f | 142 | |
143 | /* use event - here, just write event id to result file */ | |
144 | eventT=event->eventType; | |
145 | switch (event->eventType){ | |
146 | ||
147 | /* START OF RUN */ | |
148 | case START_OF_RUN: | |
149 | break; | |
150 | ||
151 | /* END OF RUN */ | |
152 | case END_OF_RUN: | |
153 | break; | |
154 | ||
155 | // case PHYSICS_EVENT: // comment this line for test raw data | |
156 | // break; // comment this line for test raw data | |
157 | ||
158 | case CALIBRATION_EVENT: | |
159 | break; // uncomment this line for test raw data | |
160 | case PHYSICS_EVENT: // uncomment this line for test raw data | |
161 | printf(" event number = %i \n",iev); | |
162 | AliRawReader *rawReader = new AliRawReaderDate((void*)event); | |
040d0012 | 163 | rawReader->Reset(); |
164 | cdhAttr=AliITSRawStreamSDD::ReadBlockAttributes(rawReader); | |
165 | amSamplFreq=AliITSRawStreamSDD::ReadAMSamplFreqFromCDH(cdhAttr); | |
166 | AliITSRawStream* s=AliITSRawStreamSDD::CreateRawStreamSDD(rawReader,cdhAttr); | |
167 | if(!writtenoutput){ | |
168 | printf("Use %s raw stream, sampling frequency %d MHz\n",s->ClassName(),amSamplFreq); | |
169 | writtenoutput=kTRUE; | |
3083967f | 170 | } |
171 | ||
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 | } | |
3083967f | 178 | } |
179 | } | |
040d0012 | 180 | |
a8cd2ab2 | 181 | while(s->Next()){ |
979b5a5f | 182 | Int_t iDDL=rawReader->GetDDLID(); |
a8cd2ab2 | 183 | Int_t iCarlos=s->GetCarlosId(); |
184 | if(s->IsCompletedModule()) continue; | |
185 | if(s->IsCompletedDDL()) continue; | |
de075dae | 186 | if(iDDL>=0 && iDDL<kTotDDL){ |
a8cd2ab2 | 187 | Int_t index=kSides*(kModPerDDL*iDDL+iCarlos)+s->GetChannel(); |
188 | histo[index]->Fill(s->GetCoord2(),s->GetCoord1(),s->GetSignal()); | |
1ccdd571 | 189 | isFilled[index]=1; |
3083967f | 190 | } |
191 | } | |
040d0012 | 192 | delete s; |
3083967f | 193 | delete rawReader; |
979b5a5f | 194 | for(Int_t iddl=0; iddl<kTotDDL;iddl++){ |
195 | for(Int_t imod=0; imod<kModPerDDL;imod++){ | |
196 | for(Int_t isid=0;isid<kSides;isid++){ | |
197 | Int_t index=kSides*(kModPerDDL*iddl+imod)+isid; | |
040d0012 | 198 | if(amSamplFreq==20) tpan[index]->SetLastGoodTB(126); |
199 | else tpan[index]->SetLastGoodTB(254); | |
979b5a5f | 200 | if(isFilled[index]) tpan[index]->AddEvent(histo[index]); |
201 | } | |
3083967f | 202 | } |
203 | } | |
204 | ||
205 | /* free resources */ | |
1ccdd571 | 206 | iAnalyzedEv++; |
3083967f | 207 | free(event); |
208 | } | |
209 | } | |
210 | ||
211 | } | |
212 | ||
213 | TFile *fh=new TFile("SDDgainHistos.root","RECREATE"); | |
214 | Char_t filnam[100],command[120]; | |
979b5a5f | 215 | for(Int_t iddl=0; iddl<kTotDDL;iddl++){ |
216 | for(Int_t imod=0; imod<kModPerDDL;imod++){ | |
217 | for(Int_t isid=0;isid<kSides;isid++){ | |
218 | Int_t index=kSides*(kModPerDDL*iddl+imod)+isid; | |
219 | if(isFilled[index]){ | |
220 | tpan[index]->ValidateAnodes(); | |
221 | tpan[index]->WriteToASCII(); | |
222 | tpan[index]->WriteToROOT(fh); | |
223 | sprintf(filnam,"SDDbase_ddl%02dc%02d_sid%d.data",iddl,imod,isid); | |
224 | sprintf(command,"tar -rf SDDbase_LDC.tar %s",filnam); | |
225 | gSystem->Exec(command); | |
226 | } | |
1ccdd571 | 227 | } |
3083967f | 228 | } |
229 | } | |
230 | fh->Close(); | |
231 | ||
040d0012 | 232 | FILE *conffil=fopen("fee.conf","w"); |
233 | fprintf(conffil,"%d\n",amSamplFreq); | |
234 | fprintf(conffil,"%02X\n",cdhAttr); | |
235 | fclose(conffil); | |
236 | gSystem->Exec("tar -rf SDDbase_LDC.tar fee.conf"); | |
237 | ||
238 | ||
3083967f | 239 | /* write report */ |
1ccdd571 | 240 | printf("Run #%s, received %d calibration events\n",getenv("DATE_RUN_NUMBER"),iAnalyzedEv); |
3083967f | 241 | |
242 | /* report progress */ | |
243 | daqDA_progressReport(90); | |
244 | ||
245 | ||
246 | ||
247 | fh->Close(); | |
248 | ||
249 | ||
250 | ||
1ccdd571 | 251 | status=daqDA_FES_storeFile("./SDDbase_LDC.tar","SDD_Calib"); |
3083967f | 252 | |
253 | /* report progress */ | |
254 | daqDA_progressReport(100); | |
255 | ||
256 | ||
257 | ||
258 | return status; | |
259 | } |