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"
55 Arguments: list of DATE raw data files
57 int main(int argc, char **argv) {
61 // line added to solve IO problems
62 gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo",
68 /* log start of process */
69 printf("ITS SDD BASELINE+NOISE algorithm program started\n");
72 /* check that we got some arguments = list of files */
74 printf("Wrong number of arguments\n");
79 Int_t maxNEvents=10; // maximum number of events to be analyzed
80 const Int_t kTotDDL=24;
81 const Int_t kModPerDDL=12;
83 Int_t adcSamplFreq=40;
84 Bool_t readfeeconf=kFALSE;
85 gSystem->Exec("rm -f SDDbase_*.data");
86 if(gSystem->Getenv("DAQ_DETDB_LOCAL")!=NULL){
87 const char* dir=gSystem->Getenv("DAQ_DETDB_LOCAL");
88 TString filnam=Form("%s/fee.conf",dir);
89 FILE* feefil=fopen(filnam.Data(),"r");
91 fscanf(feefil,"%d \n",&adcSamplFreq);
94 printf("ADC sampling frequency = %d MHz\n",adcSamplFreq);
97 if(!readfeeconf) printf("File fee.conf not found, sampling frequency set to 40 MHz\n");
99 AliITSOnlineSDDBase **base=new AliITSOnlineSDDBase*[kTotDDL*kModPerDDL*kSides];
100 AliITSOnlineSDDCMN **corr=new AliITSOnlineSDDCMN*[kTotDDL*kModPerDDL*kSides];
101 TH2F **histo=new TH2F*[kTotDDL*kModPerDDL*kSides];
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 if(adcSamplFreq==20) base[index]->SetLastGoodTB(126);
110 else base[index]->SetLastGoodTB(254);
111 sprintf(hisnam,"h%02dc%02ds%d",iddl,imod,isid);
112 histo[index]=new TH2F(hisnam,"",256,-0.5,255.5,256,-0.5,255.5);
117 /* report progress */
118 daqDA_progressReport(8);
121 for(Int_t iStep=0;iStep<2;iStep++){
122 printf("Start Analysis Step %d\n",iStep);
126 for(Int_t iddl=0; iddl<kTotDDL;iddl++){
127 for(Int_t imod=0; imod<kModPerDDL;imod++){
128 for(Int_t isid=0;isid<kSides;isid++){
129 Int_t index=kSides*(kModPerDDL*iddl+imod)+isid;
130 corr[index]=new AliITSOnlineSDDCMN(iddl,imod,isid);
131 if(adcSamplFreq==20) corr[index]->SetLastGoodTB(126);
132 else corr[index]->SetLastGoodTB(254);
138 /* read the data files */
140 for (n=1;n<argc;n++) {
142 status=monitorSetDataSource( argv[n] );
144 printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
148 /* report progress */
149 /* in this example, indexed on the number of files */
150 // Progress report inside the event loop as well?
151 daqDA_progressReport(10+40*iStep*n/argc);
155 struct eventHeaderStruct *event;
156 eventTypeType eventT;
159 status=monitorGetEventDynamic((void **)&event);
160 if (status==MON_ERR_EOF) break; /* end of monitoring file has been reached */
162 printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
166 /* retry if got no event */
173 /* use event - here, just write event id to result file */
174 eventT=event->eventType;
175 switch (event->eventType){
185 // case PHYSICS_EVENT: // comment this line for test raw data
186 // break; // comment this line for test raw data
189 case CALIBRATION_EVENT:
190 break; // uncomment this line for test raw data
191 case PHYSICS_EVENT: // uncomment this line for test raw data
192 printf(" event number = %i \n",iev);
194 AliRawReader *rawReader = new AliRawReaderDate((void*)event);
198 while(rawReader->ReadHeader()){
199 const UInt_t *subev = rawReader->GetSubEventAttributes();
200 if(subev[0]==0 && subev[1]==0 && subev[2]==0) evtyp=1;
204 for(Int_t iddl=0; iddl<kTotDDL;iddl++){
205 for(Int_t imod=0; imod<kModPerDDL;imod++){
206 for(Int_t isid=0;isid<kSides;isid++){
207 Int_t index=kSides*(kModPerDDL*iddl+imod)+isid;
208 histo[index]->Reset();
212 AliITSRawStreamSDD s(rawReader);
215 Int_t iDDL=rawReader->GetDDLID();
216 Int_t iCarlos=s.GetCarlosId();
217 if(s.IsCompletedModule()) continue;
218 if(s.IsCompletedDDL()) continue;
219 if(iDDL>=0 && iDDL<kTotDDL){
220 Int_t index=kSides*(kModPerDDL*iDDL+iCarlos)+s.GetChannel();
221 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;
229 if(iStep==0) base[index]->AddEvent(histo[index]);
230 if(iStep==1) corr[index]->AddEvent(histo[index]);
238 if(ievPed>=maxNEvents) break;
243 for(Int_t iddl=0; iddl<kTotDDL;iddl++){
244 for(Int_t imod=0; imod<kModPerDDL;imod++){
245 for(Int_t isid=0;isid<kSides;isid++){
246 Int_t index=kSides*(kModPerDDL*iddl+imod)+isid;
247 base[index]->ValidateAnodes();
248 base[index]->WriteToASCII();
256 printf("Run #%s, received %d calibration events\n",getenv("DATE_RUN_NUMBER"),ievPed);
258 /* report progress */
259 daqDA_progressReport(90);
263 TFile *fh=new TFile("SDDbaseHistos.root","RECREATE");
264 for(Int_t iddl=0; iddl<kTotDDL;iddl++){
265 for(Int_t imod=0; imod<kModPerDDL;imod++){
266 for(Int_t isid=0;isid<kSides;isid++){
267 Int_t index=kSides*(kModPerDDL*iddl+imod)+isid;
268 corr[index]->ValidateAnodes();
269 corr[index]->WriteToASCII();
270 corr[index]->WriteToROOT(fh);
277 /* report progress */
278 daqDA_progressReport(100);