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: 100
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>
50 #include "AliRawReaderDate.h"
51 #include "AliITSOnlineSDDBase.h"
52 #include "AliITSOnlineSDDCMN.h"
53 #include "AliITSRawStreamSDD.h"
54 #include "AliITSRawStreamSDDCompressed.h"
56 Arguments: list of DATE raw data files
58 int main(int argc, char **argv) {
62 // line added to solve IO problems
63 gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo",
69 /* log start of process */
70 printf("ITS SDD BASELINE+NOISE algorithm program started\n");
73 /* check that we got some arguments = list of files */
75 printf("Wrong number of arguments\n");
80 Int_t maxNEvents=10; // maximum number of events to be analyzed
81 const Int_t kTotDDL=24;
82 const Int_t kModPerDDL=12;
84 Int_t adcSamplFreq=40;
85 Bool_t readfeeconf=kFALSE;
87 gSystem->Exec("rm -f SDDbase_*.data");
88 gSystem->Exec("rm -f SDDbase_step2_LDC.tar");
89 if(gSystem->Getenv("DAQ_DETDB_LOCAL")!=NULL){
90 const char* dir=gSystem->Getenv("DAQ_DETDB_LOCAL");
91 TString filnam=Form("%s/fee.conf",dir);
92 FILE* feefil=fopen(filnam.Data(),"r");
94 fscanf(feefil,"%d \n",&adcSamplFreq);
95 fscanf(feefil,"%d \n",&dataformat);
98 printf("ADC sampling frequency = %d MHz dataformat code =%d \n",adcSamplFreq,dataformat);
101 if(!readfeeconf) printf("File fee.conf not found, sampling frequency set to 40 MHz and data format to 1\n");
103 AliITSOnlineSDDBase **base=new AliITSOnlineSDDBase*[kTotDDL*kModPerDDL*kSides];
104 AliITSOnlineSDDCMN **corr=new AliITSOnlineSDDCMN*[kTotDDL*kModPerDDL*kSides];
105 TH2F **histo=new TH2F*[kTotDDL*kModPerDDL*kSides];
106 Bool_t isFilled[kTotDDL*kModPerDDL*kSides];
109 for(Int_t iddl=0; iddl<kTotDDL;iddl++){
110 for(Int_t imod=0; imod<kModPerDDL;imod++){
111 for(Int_t isid=0;isid<kSides;isid++){
112 Int_t index=kSides*(kModPerDDL*iddl+imod)+isid;
113 base[index]=new AliITSOnlineSDDBase(iddl,imod,isid);
114 if(adcSamplFreq==20) base[index]->SetLastGoodTB(126);
115 else base[index]->SetLastGoodTB(254);
116 sprintf(hisnam,"h%02dc%02ds%d",iddl,imod,isid);
117 histo[index]=new TH2F(hisnam,"",256,-0.5,255.5,256,-0.5,255.5);
123 /* report progress */
124 daqDA_progressReport(8);
127 for(Int_t iStep=0;iStep<2;iStep++){
128 printf("Start Analysis Step %d\n",iStep);
132 for(Int_t iddl=0; iddl<kTotDDL;iddl++){
133 for(Int_t imod=0; imod<kModPerDDL;imod++){
134 for(Int_t isid=0;isid<kSides;isid++){
135 Int_t index=kSides*(kModPerDDL*iddl+imod)+isid;
136 corr[index]=new AliITSOnlineSDDCMN(iddl,imod,isid);
137 if(adcSamplFreq==20) corr[index]->SetLastGoodTB(126);
138 else corr[index]->SetLastGoodTB(254);
145 /* read the data files */
147 for (n=1;n<argc;n++) {
149 status=monitorSetDataSource( argv[n] );
151 printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
155 /* report progress */
156 /* in this example, indexed on the number of files */
157 // Progress report inside the event loop as well?
158 daqDA_progressReport(10+40*iStep*n/argc);
162 struct eventHeaderStruct *event;
163 eventTypeType eventT;
166 status=monitorGetEventDynamic((void **)&event);
167 if (status==MON_ERR_EOF) break; /* end of monitoring file has been reached */
169 printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
173 /* retry if got no event */
180 /* use event - here, just write event id to result file */
181 eventT=event->eventType;
182 switch (event->eventType){
192 // case PHYSICS_EVENT: // comment this line for test raw data
193 // break; // comment this line for test raw data
196 case CALIBRATION_EVENT:
197 break; // uncomment this line for test raw data
198 case PHYSICS_EVENT: // uncomment this line for test raw data
199 printf(" event number = %i \n",iev);
201 AliRawReader *rawReader = new AliRawReaderDate((void*)event);
205 while(rawReader->ReadHeader()){
206 const UInt_t *subev = rawReader->GetSubEventAttributes();
207 if(subev[0]==0 && subev[1]==0 && subev[2]==0) evtyp=1;
211 for(Int_t iddl=0; iddl<kTotDDL;iddl++){
212 for(Int_t imod=0; imod<kModPerDDL;imod++){
213 for(Int_t isid=0;isid<kSides;isid++){
214 Int_t index=kSides*(kModPerDDL*iddl+imod)+isid;
215 histo[index]->Reset();
221 s=new AliITSRawStreamSDD(rawReader);
223 s=new AliITSRawStreamSDDCompressed(rawReader);
224 if(dataformat==1) s->SetADCEncoded(kTRUE);
228 Int_t iDDL=rawReader->GetDDLID();
229 Int_t iCarlos=s->GetCarlosId();
230 if(s->IsCompletedModule()) continue;
231 if(s->IsCompletedDDL()) continue;
232 if(iDDL>=0 && iDDL<kTotDDL){
233 Int_t index=kSides*(kModPerDDL*iDDL+iCarlos)+s->GetChannel();
234 histo[index]->Fill(s->GetCoord2(),s->GetCoord1(),s->GetSignal());
240 for(Int_t iddl=0; iddl<kTotDDL;iddl++){
241 for(Int_t imod=0; imod<kModPerDDL;imod++){
242 for(Int_t isid=0;isid<kSides;isid++){
243 Int_t index=kSides*(kModPerDDL*iddl+imod)+isid;
244 if(iStep==0) base[index]->AddEvent(histo[index]);
245 if(iStep==1) corr[index]->AddEvent(histo[index]);
253 if(ievPed>=maxNEvents) break;
258 for(Int_t iddl=0; iddl<kTotDDL;iddl++){
259 for(Int_t imod=0; imod<kModPerDDL;imod++){
260 for(Int_t isid=0;isid<kSides;isid++){
261 Int_t index=kSides*(kModPerDDL*iddl+imod)+isid;
262 base[index]->ValidateAnodes();
263 base[index]->WriteToASCII();
271 printf("Run #%s, received %d calibration events\n",getenv("DATE_RUN_NUMBER"),ievPed);
273 /* report progress */
274 daqDA_progressReport(90);
278 Char_t filnam[100],command[150];
279 TFile *fh=new TFile("SDDbaseHistos.root","RECREATE");
280 for(Int_t iddl=0; iddl<kTotDDL;iddl++){
281 for(Int_t imod=0; imod<kModPerDDL;imod++){
282 for(Int_t isid=0;isid<kSides;isid++){
283 Int_t index=kSides*(kModPerDDL*iddl+imod)+isid;
284 corr[index]->ValidateAnodes();
285 corr[index]->WriteToASCII();
287 corr[index]->WriteToROOT(fh);
288 sprintf(filnam,"SDDbase_step2_ddl%02dc%02d_sid%d.data",iddl,imod,isid);
289 sprintf(command,"tar -rf SDDbase_step2_LDC.tar %s",filnam);
290 gSystem->Exec(command);
298 /* report progress */
299 daqDA_progressReport(100);