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 if(gSystem->Getenv("DAQ_DETDB_LOCAL")!=NULL){
89 const char* dir=gSystem->Getenv("DAQ_DETDB_LOCAL");
90 TString filnam=Form("%s/fee.conf",dir);
91 FILE* feefil=fopen(filnam.Data(),"r");
93 fscanf(feefil,"%d \n",&adcSamplFreq);
94 fscanf(feefil,"%d \n",&dataformat);
97 printf("ADC sampling frequency = %d MHz dataformat code =%d \n",adcSamplFreq,dataformat);
100 if(!readfeeconf) printf("File fee.conf not found, sampling frequency set to 40 MHz and data format to 1\n");
102 AliITSOnlineSDDBase **base=new AliITSOnlineSDDBase*[kTotDDL*kModPerDDL*kSides];
103 AliITSOnlineSDDCMN **corr=new AliITSOnlineSDDCMN*[kTotDDL*kModPerDDL*kSides];
104 TH2F **histo=new TH2F*[kTotDDL*kModPerDDL*kSides];
107 for(Int_t iddl=0; iddl<kTotDDL;iddl++){
108 for(Int_t imod=0; imod<kModPerDDL;imod++){
109 for(Int_t isid=0;isid<kSides;isid++){
110 Int_t index=kSides*(kModPerDDL*iddl+imod)+isid;
111 base[index]=new AliITSOnlineSDDBase(iddl,imod,isid);
112 if(adcSamplFreq==20) base[index]->SetLastGoodTB(126);
113 else base[index]->SetLastGoodTB(254);
114 sprintf(hisnam,"h%02dc%02ds%d",iddl,imod,isid);
115 histo[index]=new TH2F(hisnam,"",256,-0.5,255.5,256,-0.5,255.5);
120 /* report progress */
121 daqDA_progressReport(8);
124 for(Int_t iStep=0;iStep<2;iStep++){
125 printf("Start Analysis Step %d\n",iStep);
129 for(Int_t iddl=0; iddl<kTotDDL;iddl++){
130 for(Int_t imod=0; imod<kModPerDDL;imod++){
131 for(Int_t isid=0;isid<kSides;isid++){
132 Int_t index=kSides*(kModPerDDL*iddl+imod)+isid;
133 corr[index]=new AliITSOnlineSDDCMN(iddl,imod,isid);
134 if(adcSamplFreq==20) corr[index]->SetLastGoodTB(126);
135 else corr[index]->SetLastGoodTB(254);
141 /* read the data files */
143 for (n=1;n<argc;n++) {
145 status=monitorSetDataSource( argv[n] );
147 printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
151 /* report progress */
152 /* in this example, indexed on the number of files */
153 // Progress report inside the event loop as well?
154 daqDA_progressReport(10+40*iStep*n/argc);
158 struct eventHeaderStruct *event;
159 eventTypeType eventT;
162 status=monitorGetEventDynamic((void **)&event);
163 if (status==MON_ERR_EOF) break; /* end of monitoring file has been reached */
165 printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
169 /* retry if got no event */
176 /* use event - here, just write event id to result file */
177 eventT=event->eventType;
178 switch (event->eventType){
188 // case PHYSICS_EVENT: // comment this line for test raw data
189 // break; // comment this line for test raw data
192 case CALIBRATION_EVENT:
193 break; // uncomment this line for test raw data
194 case PHYSICS_EVENT: // uncomment this line for test raw data
195 printf(" event number = %i \n",iev);
197 AliRawReader *rawReader = new AliRawReaderDate((void*)event);
201 while(rawReader->ReadHeader()){
202 const UInt_t *subev = rawReader->GetSubEventAttributes();
203 if(subev[0]==0 && subev[1]==0 && subev[2]==0) evtyp=1;
207 for(Int_t iddl=0; iddl<kTotDDL;iddl++){
208 for(Int_t imod=0; imod<kModPerDDL;imod++){
209 for(Int_t isid=0;isid<kSides;isid++){
210 Int_t index=kSides*(kModPerDDL*iddl+imod)+isid;
211 histo[index]->Reset();
217 s=new AliITSRawStreamSDD(rawReader);
219 s=new AliITSRawStreamSDDCompressed(rawReader);
220 if(dataformat==1) s->SetADCEncoded(kTRUE);
224 Int_t iDDL=rawReader->GetDDLID();
225 Int_t iCarlos=s->GetCarlosId();
226 if(s->IsCompletedModule()) continue;
227 if(s->IsCompletedDDL()) continue;
228 if(iDDL>=0 && iDDL<kTotDDL){
229 Int_t index=kSides*(kModPerDDL*iDDL+iCarlos)+s->GetChannel();
230 histo[index]->Fill(s->GetCoord2(),s->GetCoord1(),s->GetSignal());
235 for(Int_t iddl=0; iddl<kTotDDL;iddl++){
236 for(Int_t imod=0; imod<kModPerDDL;imod++){
237 for(Int_t isid=0;isid<kSides;isid++){
238 Int_t index=kSides*(kModPerDDL*iddl+imod)+isid;
239 if(iStep==0) base[index]->AddEvent(histo[index]);
240 if(iStep==1) corr[index]->AddEvent(histo[index]);
248 if(ievPed>=maxNEvents) break;
253 for(Int_t iddl=0; iddl<kTotDDL;iddl++){
254 for(Int_t imod=0; imod<kModPerDDL;imod++){
255 for(Int_t isid=0;isid<kSides;isid++){
256 Int_t index=kSides*(kModPerDDL*iddl+imod)+isid;
257 base[index]->ValidateAnodes();
258 base[index]->WriteToASCII();
266 printf("Run #%s, received %d calibration events\n",getenv("DATE_RUN_NUMBER"),ievPed);
268 /* report progress */
269 daqDA_progressReport(90);
273 TFile *fh=new TFile("SDDbaseHistos.root","RECREATE");
274 for(Int_t iddl=0; iddl<kTotDDL;iddl++){
275 for(Int_t imod=0; imod<kModPerDDL;imod++){
276 for(Int_t isid=0;isid<kSides;isid++){
277 Int_t index=kSides*(kModPerDDL*iddl+imod)+isid;
278 corr[index]->ValidateAnodes();
279 corr[index]->WriteToASCII();
280 corr[index]->WriteToROOT(fh);
287 /* report progress */
288 daqDA_progressReport(100);