3 Contact: r.bailhache@gsi.de
8 Number of events needed: 100
9 Input Files: TRD raw files
10 Output Files: trdCalibration.root
11 Trigger types used: PHYSICS_EVENT
15 #define RESULT_FILE "trdPedestal.root"
16 #define FILE_ID "PADSTATUS"
31 #include <TStopwatch.h>
33 #include "TPluginManager.h"
38 #include "AliRawReader.h"
39 #include "AliRawReaderDate.h"
40 #include "AliTRDgeometry.h"
41 #include "AliCDBManager.h"
50 // AliRoot TRD calib classes
52 #include "AliTRDCalibPadStatus.h"
54 //functios, implementation below
55 void SendToAmoreDB(TObject *o, unsigned long32 runNb);
58 Arguments: list of DATE raw data files
60 int main(int argc, char **argv) {
62 /* magic line from Rene */
63 gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo",
72 /* log start of process */
73 printf("TRD DA PEDESTAL started\n");
76 /* check that we got some arguments = list of files */
78 printf("Wrong number of arguments\n");
83 /* copy locally a file from daq detector config db */
84 //status=daqDA_DB_getFile("myconfig","./myconfig.txt");
86 // printf("Failed to get config file : %d\n",status);
89 /* and possibly use it */
92 /* init some counters */
96 //Instance of AliCDBManager: needed by AliTRDRawStream
97 //AliCDBManager *man = AliCDBManager::Instance();
98 //man->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
100 // AliTRDCalibPadStatus object
101 AliTRDCalibPadStatus calipad = AliTRDCalibPadStatus();
102 Bool_t passpadstatus = kTRUE;
103 unsigned long32 runNb=0; //run number
106 //AliTRDrawFastStream::DisableSkipData();
107 AliLog::SetGlobalLogLevel(AliLog::kFatal);
109 /* read the data files */
111 for (n=1;n<argc;n++) {
113 /* define data source : this is argument i */
114 printf("Processing file %s\n",argv[n]);
115 status=monitorSetDataSource( argv[n] );
117 printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
121 /* read the file until EOF */
123 struct eventHeaderStruct *event;
124 eventTypeType eventT;
127 status=monitorGetEventDynamic((void **)&event);
128 if (status==MON_ERR_EOF) {
129 printf("End of File %d detected\n",n);
130 break; /* end of monitoring file has been reached */
133 printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
137 /* retry if got no event */
142 /* use event - here, just write event id to result file */
143 eventT=event->eventType;
145 if((eventT==PHYSICS_EVENT) && (passpadstatus)){
147 AliRawReader *rawReader = new AliRawReaderDate((void*)event);
148 rawReader->Select("TRD");
150 //rawReader->SelectEquipment(-1,1024,1025);
152 Int_t result = calipad.ProcessEvent((AliRawReader *) rawReader);
153 // 0 error, 1 no input, 2 output
154 if(result == 2) nevents++;
155 if(result == 0) passpadstatus = kFALSE;
162 // get the run number
163 runNb = event->eventRunNb;
171 /* report progress */
172 printf("%d events processed and %d used\n",nevents_total,nevents);
174 /* write file in any case to see what happens in case of problems*/
175 TFile *fileTRD = new TFile(RESULT_FILE,"recreate");
176 if(nevents < 30) calipad.Destroy();
177 calipad.AnalyseHisto();
178 calipad.Write("calibpadstatus");
182 SendToAmoreDB(&calipad,runNb);
185 /* store the result file on FES */
186 status=daqDA_FES_storeFile(RESULT_FILE,FILE_ID);
188 printf("Failed to export file : %d\n",status);
196 void SendToAmoreDB(TObject *calipad, unsigned long32 runNb)
198 //cheet a little -- temporary solution (hopefully)
200 //currently amoreDA uses the environment variable AMORE_DA_NAME to create the mysql
201 //table in which the calib objects are stored. This table is dropped each time AmoreDA
202 //is initialised. This of course makes a problem if we would like to store different
203 //calibration entries in the AMORE DB. Therefore in each DA which writes to the AMORE DB
204 //the AMORE_DA_NAME env variable is overwritten.
208 // The reference data are stored in:
209 // PadStatus1 for sm-00-01-02
210 // PadStatus2 for sm-03-04-05
211 // PadStatus3 for sm-06-07-08
212 // PadStatus4 for sm-09-10-11
213 // PadStatus5 for sm-12-13-14
214 // PadStatus6 for sm-15-16-17
215 // PadStatus0 if nothing found..means problems
221 Int_t ldcnumber = -1;
223 for (Int_t idet=0; idet<540; idet++) {
224 AliTRDCalROC *rocMean = ((AliTRDCalibPadStatus *) calipad)->GetCalRocMean(idet, kFALSE);
226 sm = AliTRDgeometry::GetSector(idet);
227 if((sm==0) || (sm==1) || (sm==2)) ldcnumber = 1;
228 if((sm==3) || (sm==4) || (sm==5)) ldcnumber = 2;
229 if((sm==6) || (sm==7) || (sm==8)) ldcnumber = 3;
230 if((sm==9) || (sm==10) || (sm==11)) ldcnumber = 4;
231 if((sm==12) || (sm==13) || (sm==14)) ldcnumber = 5;
232 if((sm==15) || (sm==16) || (sm==17)) ldcnumber = 6;
235 const char *amoreDANameorig=gSystem->Getenv("AMORE_DA_NAME");
237 gSystem->Setenv("AMORE_DA_NAME",Form("TRD-dataQA-%02d-%s",ldcnumber,FILE_ID));
239 /////////////////////
244 TObjString info(Form("Run: %u; Date: %s",runNb,time.AsSQLString()));
246 amore::da::AmoreDA amoreDA(amore::da::AmoreDA::kSender);
248 statusDA+=amoreDA.Send("Pedestals",calipad);
249 statusDA+=amoreDA.Send("Info",&info);
251 printf("Warning: Failed to write one of the calib objects to the AMORE database\n");
253 printf("Warning: No data found!\n");
257 if (amoreDANameorig) gSystem->Setenv("AMORE_DA_NAME",amoreDANameorig);