1 //////////////////////////////////////////////////////////////////////////////
2 // Detector Algorithm for analysis of SDD test pulse runs. //
4 // Produces ASCII and ROOT output files with: //
5 // 1. anode quality bit //
6 // 1. Baseline values //
8 // 3. Common mode coefficients //
9 // 4. Noise corrected for common mode //
11 // Files are written to FXS //
13 // Author: F. Prino (prino@to.infn.it) //
15 //////////////////////////////////////////////////////////////////////////////
36 #include "AliRawReaderDate.h"
37 #include "AliITSOnlineSDDTP.h"
38 #include "AliITSRawStreamSDD.h"
40 Arguments: list of DATE raw data files
42 int main(int argc, char **argv) {
47 /* log start of process */
48 printf("ITS SDD TP algorithm program started\n");
51 /* check that we got some arguments = list of files */
53 printf("Wrong number of arguments\n");
58 Int_t maxNEvents=10; // maximum number of events to be analyzed
59 const Int_t nSDDmodules=12; // temp for test raw data
60 AliITSOnlineSDDTP **tpan=new AliITSOnlineSDDTP*[2*nSDDmodules];
61 TH2F **histo=new TH2F*[2*nSDDmodules];
64 for(Int_t imod=0; imod<nSDDmodules;imod++){
65 for(Int_t isid=0;isid<2;isid++){
66 Int_t index=2*imod+isid;
67 tpan[index]=new AliITSOnlineSDDTP(imod,isid,411.);
68 sprintf(hisnam,"his%03ds%d",imod,isid);
69 histo[index]=new TH2F(hisnam,"",256,-0.5,255.5,256,-0.5,255.5);
74 daqDA_progressReport(10);
76 /* read the data files */
78 for (n=1;n<argc;n++) {
80 status=monitorSetDataSource( argv[n] );
82 printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
87 /* in this example, indexed on the number of files */
88 // Progress report inside the event loop as well?
89 daqDA_progressReport(10+80*n/argc);
93 struct eventHeaderStruct *event;
97 status=monitorGetEventDynamic((void **)&event);
98 if (status==MON_ERR_EOF) break; /* end of monitoring file has been reached */
100 printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
104 /* retry if got no event */
110 if(iev>maxNEvents) break;
112 /* use event - here, just write event id to result file */
113 eventT=event->eventType;
114 switch (event->eventType){
124 // case PHYSICS_EVENT: // comment this line for test raw data
125 // break; // comment this line for test raw data
127 case CALIBRATION_EVENT:
128 break; // uncomment this line for test raw data
129 case PHYSICS_EVENT: // uncomment this line for test raw data
130 printf(" event number = %i \n",iev);
131 AliRawReader *rawReader = new AliRawReaderDate((void*)event);
132 rawReader->RequireHeader(kFALSE);
133 rawReader->SelectEquipment(17,101,101); // temp for test raw data
136 while(rawReader->ReadHeader()){
137 const UInt_t *subev = rawReader->GetSubEventAttributes();
138 if(subev[0]==0 && subev[1]==0 && subev[2]==0) evtyp=1;
142 for(Int_t imod=0; imod<nSDDmodules;imod++){
143 for(Int_t isid=0; isid<2;isid++){
144 Int_t index=2*imod+isid;
145 histo[index]->Reset();
148 AliITSRawStreamSDD s(rawReader);
149 rawReader->SelectEquipment(17,101,101); // temp for test raw data
152 Int_t iddl=rawReader->GetDDLID();
153 iddl=0; // temporary for test raw data
154 Int_t isddmod=s.GetModuleNumber(iddl,s.GetCarlosId());
155 isddmod-=240; // to have SDD modules from 0 to 259
156 isddmod=s.GetCarlosId(); // temporary for test raw data
157 if(isddmod<nSDDmodules){
158 Int_t index=2*isddmod+s.GetChannel();
159 histo[index]->Fill(s.GetCoord2(),s.GetCoord1(),s.GetSignal());
163 for(Int_t imod=0; imod<nSDDmodules;imod++){
164 for(Int_t isid=0; isid<2;isid++){
165 Int_t index=2*imod+isid;
166 tpan[index]->AddEvent(histo[index]);
177 TFile *fh=new TFile("SDDgainHistos.root","RECREATE");
178 Char_t filnam[100],command[120];
179 for(Int_t imod=0; imod<nSDDmodules;imod++){
180 for(Int_t isid=0; isid<2;isid++){
181 Int_t index=2*imod+isid;
182 tpan[index]->ValidateAnodes();
183 tpan[index]->WriteToASCII();
184 tpan[index]->WriteToROOT(fh);
185 sprintf(filnam,"SDDbase_mod%03d_sid%d.data",imod,isid);
186 sprintf(command,"tar -rf SDDbase_LDC1.tar %s",filnam);
187 gSystem->Exec(command);
193 printf("Run #%s, received %d calibration events\n",getenv("DATE_RUN_NUMBER"),iev);
195 /* report progress */
196 daqDA_progressReport(90);
204 status=daqDA_FES_storeFile("./SDDbase_LDC1.tar","SDD_Calib");
206 /* report progress */
207 daqDA_progressReport(100);