2 - Contact: - prino@to.infn.it
3 - Link: - http://www.to.infn.it/~prino/alice/RawData/run11173.date
4 - Run Type: - PULSER_RUN
6 - Number of events needed: 100
7 - Input Files: - SDDbase_step1_ddl*c*_sid*.data
8 - Output Files: - SDDbase_ddl*c*_sid*.data
12 //////////////////////////////////////////////////////////////////////////////
13 // Detector Algorithm for analysis of SDD test pulse runs. //
15 // Produces ASCII and ROOT output files with: //
16 // 1. anode quality bit //
17 // 1. Baseline values //
19 // 3. Common mode coefficients //
20 // 4. Noise corrected for common mode //
22 // Files are written to FXS //
24 // Author: F. Prino (prino@to.infn.it) //
26 //////////////////////////////////////////////////////////////////////////////
46 #include <TPluginManager.h>
49 #include "AliRawReaderDate.h"
50 #include "AliITSOnlineSDDTP.h"
51 #include "AliITSRawStreamSDD.h"
52 #include "AliITSRawStreamSDDCompressed.h"
54 Arguments: list of DATE raw data files
56 int main(int argc, char **argv) {
60 // line added to solve IO problems
61 gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo",
67 /* log start of process */
68 printf("ITS SDD TEST-PULSE algorithm program started\n");
71 /* check that we got some arguments = list of files */
73 printf("Wrong number of arguments\n");
78 Int_t maxNEvents=15; // maximum number of events to be analyzed
79 const Int_t kTotDDL=24;
80 const Int_t kModPerDDL=12;
82 Int_t adcSamplFreq=40;
83 Bool_t readfeeconf=kFALSE;
85 gSystem->Exec("rm -f SDDbase_LDC.tar");
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);
92 fscanf(feefil,"%d \n",&dataformat);
94 TString shcomm=Form("tar -rf SDDbase_LDC.tar -C %s fee.conf",dir);
95 gSystem->Exec(shcomm.Data());
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 AliITSOnlineSDDTP **tpan=new AliITSOnlineSDDTP*[kTotDDL*kModPerDDL*kSides];
103 TH2F **histo=new TH2F*[kTotDDL*kModPerDDL*kSides];
104 Bool_t isFilled[kTotDDL*kModPerDDL*kSides];
106 for(Int_t iddl=0; iddl<kTotDDL;iddl++){
107 for(Int_t imod=0; imod<kModPerDDL;imod++){
108 for(Int_t isid=0;isid<kSides;isid++){
109 Int_t index=kSides*(kModPerDDL*iddl+imod)+isid;
110 tpan[index]=new AliITSOnlineSDDTP(iddl,imod,isid,100.);
111 if(adcSamplFreq==20) tpan[index]->SetLastGoodTB(126);
112 else tpan[index]->SetLastGoodTB(254);
113 sprintf(hisnam,"h%02dc%02ds%d",iddl,imod,isid);
114 histo[index]=new TH2F(hisnam,"",256,-0.5,255.5,256,-0.5,255.5);
120 /* report progress */
121 daqDA_progressReport(10);
122 Int_t iev=0,iAnalyzedEv=0;
123 /* read the data files */
125 for (n=1;n<argc;n++) {
127 status=monitorSetDataSource( argv[n] );
129 printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
133 /* report progress */
134 /* in this example, indexed on the number of files */
135 // Progress report inside the event loop as well?
136 daqDA_progressReport(10+80*n/argc);
140 struct eventHeaderStruct *event;
141 eventTypeType eventT;
144 status=monitorGetEventDynamic((void **)&event);
145 if (status==MON_ERR_EOF) break; /* end of monitoring file has been reached */
147 printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
151 /* retry if got no event */
156 if(iAnalyzedEv>=maxNEvents) break;
159 /* use event - here, just write event id to result file */
160 eventT=event->eventType;
161 switch (event->eventType){
171 // case PHYSICS_EVENT: // comment this line for test raw data
172 // break; // comment this line for test raw data
174 case CALIBRATION_EVENT:
175 break; // uncomment this line for test raw data
176 case PHYSICS_EVENT: // uncomment this line for test raw data
177 printf(" event number = %i \n",iev);
178 AliRawReader *rawReader = new AliRawReaderDate((void*)event);
181 while(rawReader->ReadHeader()){
182 const UInt_t *subev = rawReader->GetSubEventAttributes();
183 if(subev[0]==0 && subev[1]==0 && subev[2]==0) evtyp=1;
187 for(Int_t iddl=0; iddl<kTotDDL;iddl++){
188 for(Int_t imod=0; imod<kModPerDDL;imod++){
189 for(Int_t isid=0;isid<kSides;isid++){
190 Int_t index=kSides*(kModPerDDL*iddl+imod)+isid;
191 histo[index]->Reset();
197 s=new AliITSRawStreamSDD(rawReader);
199 s=new AliITSRawStreamSDDCompressed(rawReader);
200 if(dataformat==1) s->SetADCEncoded(kTRUE);
204 Int_t iDDL=rawReader->GetDDLID();
205 Int_t iCarlos=s->GetCarlosId();
206 if(s->IsCompletedModule()) continue;
207 if(s->IsCompletedDDL()) continue;
208 if(iDDL>=0 && iDDL<kTotDDL){
209 Int_t index=kSides*(kModPerDDL*iDDL+iCarlos)+s->GetChannel();
210 histo[index]->Fill(s->GetCoord2(),s->GetCoord1(),s->GetSignal());
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]) tpan[index]->AddEvent(histo[index]);
232 TFile *fh=new TFile("SDDgainHistos.root","RECREATE");
233 Char_t filnam[100],command[120];
234 for(Int_t iddl=0; iddl<kTotDDL;iddl++){
235 for(Int_t imod=0; imod<kModPerDDL;imod++){
236 for(Int_t isid=0;isid<kSides;isid++){
237 Int_t index=kSides*(kModPerDDL*iddl+imod)+isid;
239 tpan[index]->ValidateAnodes();
240 tpan[index]->WriteToASCII();
241 tpan[index]->WriteToROOT(fh);
242 sprintf(filnam,"SDDbase_ddl%02dc%02d_sid%d.data",iddl,imod,isid);
243 sprintf(command,"tar -rf SDDbase_LDC.tar %s",filnam);
244 gSystem->Exec(command);
252 printf("Run #%s, received %d calibration events\n",getenv("DATE_RUN_NUMBER"),iAnalyzedEv);
254 /* report progress */
255 daqDA_progressReport(90);
263 status=daqDA_FES_storeFile("./SDDbase_LDC.tar","SDD_Calib");
265 /* report progress */
266 daqDA_progressReport(100);