2 - Contact: - prino@to.infn.it
3 - Link: - http://www.to.infn.it/~prino/alice/RawData/run11161.date
4 - Run Type: - PEDESTAL_RUN
6 - Number of events needed: > 10
8 - Output Files: - SDDbase_step1_ddl*c*_sid*.data SDDbase_step2_ddl*c*_sid*.data
13 //////////////////////////////////////////////////////////////////////////////
14 // Detector Algorithm for analysis of SDD baseline runs. //
16 // Produces ASCII and ROOT output files with: //
17 // 1. anode quality bit //
18 // 1. Baseline values //
20 // 3. Common mode coefficients //
21 // 4. Noise corrected for common mode //
22 // Files are stored locally. //
23 // The next DAQ-DA step on Test Pulse run writes files to FXS //
25 // Author: F. Prino (prino@to.infn.it) //
27 //////////////////////////////////////////////////////////////////////////////
47 #include <TPluginManager.h>
48 #include <TObjArray.h>
49 #include <TObjString.h>
53 #include "AliRawReaderDate.h"
54 #include "AliITSOnlineSDDBase.h"
55 #include "AliITSOnlineSDDCMN.h"
56 #include "AliITSRawStreamSDD.h"
57 #include "AliITSRawStreamSDDCompressed.h"
64 Arguments: list of DATE raw data files
66 int main(int argc, char **argv) {
70 // line added to solve IO problems
71 gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo",
77 /* log start of process */
78 printf("ITS SDD BASELINE+NOISE algorithm program started\n");
81 /* check that we got some arguments = list of files */
83 printf("Wrong number of arguments\n");
88 Int_t maxNEvents=10; // maximum number of events to be analyzed
89 const Int_t kTotDDL=24;
90 const Int_t kModPerDDL=12;
92 UInt_t amSamplFreq=40;
94 gSystem->Exec("rm -f SDDbase_*.data");
95 gSystem->Exec("rm -f SDDbase_step2_LDC.tar");
97 AliITSOnlineSDDBase **base=new AliITSOnlineSDDBase*[kTotDDL*kModPerDDL*kSides];
98 AliITSOnlineSDDCMN **corr=new AliITSOnlineSDDCMN*[kTotDDL*kModPerDDL*kSides];
99 TH2F **histo=new TH2F*[kTotDDL*kModPerDDL*kSides];
100 Bool_t isFilled[kTotDDL*kModPerDDL*kSides];
101 Bool_t writtenoutput=kFALSE;
104 for(Int_t iddl=0; iddl<kTotDDL;iddl++){
105 for(Int_t imod=0; imod<kModPerDDL;imod++){
106 for(Int_t isid=0;isid<kSides;isid++){
107 Int_t index=kSides*(kModPerDDL*iddl+imod)+isid;
108 base[index]=new AliITSOnlineSDDBase(iddl,imod,isid);
109 sprintf(hisnam,"h%02dc%02ds%d",iddl,imod,isid);
110 histo[index]=new TH2F(hisnam,"",256,-0.5,255.5,256,-0.5,255.5);
116 /* report progress */
117 daqDA_progressReport(8);
120 for(Int_t iStep=0;iStep<2;iStep++){
121 printf("Start Analysis Step %d\n",iStep);
125 for(Int_t iddl=0; iddl<kTotDDL;iddl++){
126 for(Int_t imod=0; imod<kModPerDDL;imod++){
127 for(Int_t isid=0;isid<kSides;isid++){
128 Int_t index=kSides*(kModPerDDL*iddl+imod)+isid;
129 corr[index]=new AliITSOnlineSDDCMN(iddl,imod,isid);
136 /* read the data files */
138 for (n=1;n<argc;n++) {
140 status=monitorSetDataSource( argv[n] );
142 printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
146 /* report progress */
147 /* in this example, indexed on the number of files */
148 // Progress report inside the event loop as well?
149 daqDA_progressReport(10+40*iStep*n/argc);
153 struct eventHeaderStruct *event;
154 eventTypeType eventT;
157 status=monitorGetEventDynamic((void **)&event);
158 if (status==MON_ERR_EOF) break; /* end of monitoring file has been reached */
160 printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
164 /* retry if got no event */
171 /* use event - here, just write event id to result file */
172 eventT=event->eventType;
173 switch (event->eventType){
183 // case PHYSICS_EVENT: // comment this line for test raw data
184 // break; // comment this line for test raw data
187 case CALIBRATION_EVENT:
188 break; // uncomment this line for test raw data
189 case PHYSICS_EVENT: // uncomment this line for test raw data
190 printf(" event number = %i \n",iev);
192 AliRawReader *rawReader = new AliRawReaderDate((void*)event);
194 UChar_t cdhAttr=AliITSRawStreamSDD::ReadBlockAttributes(rawReader);
195 amSamplFreq=AliITSRawStreamSDD::ReadAMSamplFreqFromCDH(cdhAttr);
196 AliITSRawStream* s=AliITSRawStreamSDD::CreateRawStreamSDD(rawReader,cdhAttr);
198 printf("Use %s raw stream, sampling frequency %d MHz\n",s->ClassName(),amSamplFreq);
203 for(Int_t iddl=0; iddl<kTotDDL;iddl++){
204 for(Int_t imod=0; imod<kModPerDDL;imod++){
205 for(Int_t isid=0;isid<kSides;isid++){
206 Int_t index=kSides*(kModPerDDL*iddl+imod)+isid;
207 histo[index]->Reset();
213 Int_t iDDL=rawReader->GetDDLID();
214 Int_t iCarlos=s->GetCarlosId();
215 if(s->IsCompletedModule()) continue;
216 if(s->IsCompletedDDL()) continue;
217 if(iDDL>=0 && iDDL<kTotDDL){
218 Int_t index=kSides*(kModPerDDL*iDDL+iCarlos)+s->GetChannel();
219 histo[index]->Fill(s->GetCoord2(),s->GetCoord1(),s->GetSignal());
225 for(Int_t iddl=0; iddl<kTotDDL;iddl++){
226 for(Int_t imod=0; imod<kModPerDDL;imod++){
227 for(Int_t isid=0;isid<kSides;isid++){
228 Int_t index=kSides*(kModPerDDL*iddl+imod)+isid;
230 if(amSamplFreq==20) base[index]->SetLastGoodTB(126);
231 else base[index]->SetLastGoodTB(254);
232 base[index]->AddEvent(histo[index]);
235 if(amSamplFreq==20) corr[index]->SetLastGoodTB(126);
236 else corr[index]->SetLastGoodTB(254);
237 corr[index]->AddEvent(histo[index]);
246 if(ievPed>=maxNEvents) break;
251 for(Int_t iddl=0; iddl<kTotDDL;iddl++){
252 for(Int_t imod=0; imod<kModPerDDL;imod++){
253 for(Int_t isid=0;isid<kSides;isid++){
254 Int_t index=kSides*(kModPerDDL*iddl+imod)+isid;
255 base[index]->ValidateAnodes();
256 base[index]->WriteToASCII();
265 TObjString timeinfo(Form("%02d%02d%02d%02d%02d%02d",time.GetYear()-2000,time.GetMonth(),time.GetDay(),time.GetHour(),time.GetMinute(),time.GetSecond()));
266 printf("Run #%s, received %d calibration events, time %s\n",getenv("DATE_RUN_NUMBER"),ievPed,timeinfo.GetString().Data());
268 /* report progress */
269 daqDA_progressReport(90);
271 TObjArray* basHistos=new TObjArray();
272 TObjArray* noiseHistos=new TObjArray();
273 TObjArray* cmnHistos=new TObjArray();
274 TObjArray* corrnHistos=new TObjArray();
275 TObjArray* statusHistos=new TObjArray();
278 Char_t filnam[100],command[150];
279 for(Int_t iddl=0; iddl<kTotDDL;iddl++){
280 for(Int_t imod=0; imod<kModPerDDL;imod++){
281 for(Int_t isid=0;isid<kSides;isid++){
282 Int_t index=kSides*(kModPerDDL*iddl+imod)+isid;
283 corr[index]->ValidateAnodes();
284 corr[index]->WriteToASCII();
286 basHistos->AddLast(corr[index]->GetBaselineAnodeHisto());
287 noiseHistos->AddLast(corr[index]->GetRawNoiseAnodeHisto());
288 cmnHistos->AddLast(corr[index]->GetCMNCoefAnodeHisto());
289 corrnHistos->AddLast(corr[index]->GetCorrNoiseAnodeHisto());
290 statusHistos->AddLast(corr[index]->GetStatusAnodeHisto());
291 sprintf(filnam,"SDDbase_step2_ddl%02dc%02d_sid%d.data",iddl,imod,isid);
292 sprintf(command,"tar -rf SDDbase_step2_LDC.tar %s",filnam);
293 gSystem->Exec(command);
300 amore::da::AmoreDA amoreDA(amore::da::AmoreDA::kSender);
301 Int_t statusamore =0;
302 statusamore += amoreDA.Send("TimeInfoPedestal",&timeinfo);
303 statusamore += amoreDA.Send("Baselines",basHistos);
304 statusamore += amoreDA.Send("RawNoise",noiseHistos);
305 statusamore += amoreDA.Send("CommonMode",cmnHistos);
306 statusamore += amoreDA.Send("CorrectedNoise",corrnHistos);
307 statusamore += amoreDA.Send("NoisyChannels",statusHistos);
309 printf("Warning: Failed to write Arrays in the AMORE database\n");
311 printf("amoreDA.Send() OK\n");
313 printf("Warning: SDDBAS DA not compiled with AMORE support\n");
317 TFile *fh=new TFile("SDDbaseHistos.root","RECREATE");
319 noiseHistos->Write();
321 corrnHistos->Write();
322 statusHistos->Write();
325 /* report progress */
326 daqDA_progressReport(100);