]>
Commit | Line | Data |
---|---|---|
6ace5fe2 | 1 | /* |
2 | ||
c5348551 | 3 | Contact: r.bailhache@gsi.de |
27b46d95 | 4 | Link: |
5 | Reference run: 12170 | |
25781e34 | 6 | Run Type: PEDESTAL |
c5348551 | 7 | DA Type: LDC |
8 | Number of events needed: 100 | |
27b46d95 | 9 | Input Files: TRD raw files |
10 | Output Files: trdCalibration.root | |
f2a468d7 | 11 | Trigger types used: PHYSICS_EVENT |
6ace5fe2 | 12 | |
13 | */ | |
14 | ||
5f518e55 | 15 | #define RESULT_FILE "trdPedestal.root" |
16 | #define FILE_ID "PADSTATUS" | |
6ace5fe2 | 17 | |
18 | extern "C" { | |
19 | #include <daqDA.h> | |
20 | } | |
21 | ||
22 | #include "event.h" | |
23 | #include "monitor.h" | |
24 | #include <stdio.h> | |
25 | #include <stdlib.h> | |
26 | ||
27 | // | |
28 | // Root includes | |
29 | // | |
30 | #include <TFile.h> | |
31 | #include <TStopwatch.h> | |
25781e34 | 32 | #include "TROOT.h" |
33 | #include "TPluginManager.h" | |
2c61d953 | 34 | #include "TSystem.h" |
6ace5fe2 | 35 | // |
36 | // AliRoot includes | |
37 | // | |
38 | #include "AliRawReader.h" | |
39 | #include "AliRawReaderDate.h" | |
fd50bb14 | 40 | //#include "AliTRDrawFastStream.h" |
41 | //#include "AliTRDrawStreamBase.h" | |
2c61d953 | 42 | #include "AliTRDgeometry.h" |
6ace5fe2 | 43 | #include "AliCDBManager.h" |
fd50bb14 | 44 | #include "AliLog.h" |
1785640c | 45 | |
46 | // | |
47 | //AMORE | |
48 | // | |
49 | #include <AmoreDA.h> | |
50 | ||
6ace5fe2 | 51 | // |
52 | // AliRoot TRD calib classes | |
53 | // | |
54 | #include "AliTRDCalibPadStatus.h" | |
55 | ||
1785640c | 56 | //functios, implementation below |
2c61d953 | 57 | void SendToAmoreDB(TObject *o, unsigned long32 runNb); |
6ace5fe2 | 58 | |
59 | /* Main routine | |
60 | Arguments: list of DATE raw data files | |
61 | */ | |
62 | int main(int argc, char **argv) { | |
63 | ||
25781e34 | 64 | /* magic line from Rene */ |
65 | gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo", | |
66 | "*", | |
67 | "TStreamerInfo", | |
68 | "RIO", | |
69 | "TStreamerInfo()"); | |
70 | ||
6ace5fe2 | 71 | int status; |
72 | ||
73 | ||
74 | /* log start of process */ | |
75 | printf("TRD DA PEDESTAL started\n"); | |
76 | ||
77 | ||
78 | /* check that we got some arguments = list of files */ | |
79 | if (argc<2) { | |
80 | printf("Wrong number of arguments\n"); | |
81 | return -1; | |
82 | } | |
83 | ||
84 | ||
85 | /* copy locally a file from daq detector config db */ | |
86 | //status=daqDA_DB_getFile("myconfig","./myconfig.txt"); | |
87 | //if (status) { | |
88 | // printf("Failed to get config file : %d\n",status); | |
89 | // return -1; | |
90 | //} | |
91 | /* and possibly use it */ | |
92 | ||
93 | ||
94 | /* init some counters */ | |
1785640c | 95 | int nevents_total=0; |
6ace5fe2 | 96 | int nevents =0; |
97 | ||
98 | //Instance of AliCDBManager: needed by AliTRDRawStream | |
162a3e73 | 99 | //AliCDBManager *man = AliCDBManager::Instance(); |
162637e4 | 100 | //man->SetDefaultStorage("local://$ALICE_ROOT/OCDB"); |
162a3e73 | 101 | //man->SetRun(0); |
6ace5fe2 | 102 | // AliTRDCalibPadStatus object |
103 | AliTRDCalibPadStatus calipad = AliTRDCalibPadStatus(); | |
104 | Bool_t passpadstatus = kTRUE; | |
2c61d953 | 105 | unsigned long32 runNb=0; //run number |
6ace5fe2 | 106 | |
162a3e73 | 107 | // setting |
fd50bb14 | 108 | //AliTRDrawFastStream::DisableSkipData(); |
109 | AliLog::SetGlobalLogLevel(AliLog::kFatal); | |
6ace5fe2 | 110 | |
111 | /* read the data files */ | |
112 | int n; | |
113 | for (n=1;n<argc;n++) { | |
114 | ||
115 | /* define data source : this is argument i */ | |
116 | printf("Processing file %s\n",argv[n]); | |
117 | status=monitorSetDataSource( argv[n] ); | |
118 | if (status!=0) { | |
119 | printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status)); | |
120 | return -1; | |
121 | } | |
122 | ||
123 | /* read the file until EOF */ | |
124 | for(;;) { | |
125 | struct eventHeaderStruct *event; | |
f2a468d7 | 126 | eventTypeType eventT; |
6ace5fe2 | 127 | |
128 | /* get next event */ | |
129 | status=monitorGetEventDynamic((void **)&event); | |
130 | if (status==MON_ERR_EOF) { | |
131 | printf("End of File %d detected\n",n); | |
132 | break; /* end of monitoring file has been reached */ | |
133 | } | |
134 | if (status!=0) { | |
135 | printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status)); | |
136 | break; | |
137 | } | |
138 | ||
139 | /* retry if got no event */ | |
140 | if (event==NULL) { | |
141 | break; | |
142 | } | |
143 | ||
f2a468d7 | 144 | /* use event - here, just write event id to result file */ |
145 | eventT=event->eventType; | |
146 | ||
147 | if((eventT==PHYSICS_EVENT) && (passpadstatus)){ | |
6ace5fe2 | 148 | |
149 | AliRawReader *rawReader = new AliRawReaderDate((void*)event); | |
f222df8d | 150 | rawReader->Select("TRD"); |
2c61d953 | 151 | // for debug |
152 | //rawReader->SelectEquipment(-1,1024,1025); | |
1785640c | 153 | |
fd50bb14 | 154 | Int_t result = calipad.ProcessEvent3((AliRawReader *) rawReader); |
8799e123 | 155 | // 0 error, 1 no input, 2 output |
156 | if(result == 2) nevents++; | |
157 | if(result == 0) passpadstatus = kFALSE; | |
6ace5fe2 | 158 | delete rawReader; |
8799e123 | 159 | |
6ace5fe2 | 160 | } |
161 | ||
1785640c | 162 | nevents_total++; |
163 | ||
164 | // get the run number | |
2c61d953 | 165 | runNb = event->eventRunNb; |
6ace5fe2 | 166 | |
167 | /* free resources */ | |
168 | free(event); | |
169 | } | |
170 | } | |
171 | ||
172 | ||
173 | /* report progress */ | |
1785640c | 174 | printf("%d events processed and %d used\n",nevents_total,nevents); |
6ace5fe2 | 175 | |
6ace5fe2 | 176 | /* write file in any case to see what happens in case of problems*/ |
177 | TFile *fileTRD = new TFile(RESULT_FILE,"recreate"); | |
8799e123 | 178 | if(nevents < 30) calipad.Destroy(); |
289cc637 | 179 | calipad.AnalyseHisto(); |
6ace5fe2 | 180 | calipad.Write("calibpadstatus"); |
181 | fileTRD->Close(); | |
2c61d953 | 182 | |
183 | /* Send to amore */ | |
184 | SendToAmoreDB(&calipad,runNb); | |
185 | ||
25781e34 | 186 | |
6ace5fe2 | 187 | /* store the result file on FES */ |
5f518e55 | 188 | status=daqDA_FES_storeFile(RESULT_FILE,FILE_ID); |
6ace5fe2 | 189 | if (status) { |
190 | printf("Failed to export file : %d\n",status); | |
191 | return -1; | |
192 | } | |
6ace5fe2 | 193 | |
194 | ||
195 | return status; | |
1785640c | 196 | |
2c61d953 | 197 | } |
198 | void SendToAmoreDB(TObject *calipad, unsigned long32 runNb) | |
199 | { | |
1785640c | 200 | //cheet a little -- temporary solution (hopefully) |
201 | // | |
202 | //currently amoreDA uses the environment variable AMORE_DA_NAME to create the mysql | |
203 | //table in which the calib objects are stored. This table is dropped each time AmoreDA | |
204 | //is initialised. This of course makes a problem if we would like to store different | |
205 | //calibration entries in the AMORE DB. Therefore in each DA which writes to the AMORE DB | |
206 | //the AMORE_DA_NAME env variable is overwritten. | |
207 | ||
208 | ||
209 | // | |
210 | // The reference data are stored in: | |
211 | // PadStatus1 for sm-00-01-02 | |
212 | // PadStatus2 for sm-03-04-05 | |
213 | // PadStatus3 for sm-06-07-08 | |
214 | // PadStatus4 for sm-09-10-11 | |
215 | // PadStatus5 for sm-12-13-14 | |
216 | // PadStatus6 for sm-15-16-17 | |
217 | // PadStatus0 if nothing found..means problems | |
218 | // | |
2c61d953 | 219 | |
1785640c | 220 | /////////////////// |
221 | // Find wich LDC | |
222 | /////////////////// | |
223 | Int_t ldcnumber = -1; | |
224 | Int_t sm = -1; | |
225 | for (Int_t idet=0; idet<540; idet++) { | |
2c61d953 | 226 | AliTRDCalROC *rocMean = ((AliTRDCalibPadStatus *) calipad)->GetCalRocMean(idet, kFALSE); |
1785640c | 227 | if ( rocMean ) { |
228 | sm = AliTRDgeometry::GetSector(idet); | |
229 | if((sm==0) || (sm==1) || (sm==2)) ldcnumber = 1; | |
230 | if((sm==3) || (sm==4) || (sm==5)) ldcnumber = 2; | |
231 | if((sm==6) || (sm==7) || (sm==8)) ldcnumber = 3; | |
2c61d953 | 232 | if((sm==9) || (sm==10) || (sm==11)) ldcnumber = 4; |
233 | if((sm==12) || (sm==13) || (sm==14)) ldcnumber = 5; | |
234 | if((sm==15) || (sm==16) || (sm==17)) ldcnumber = 6; | |
1785640c | 235 | } |
236 | } | |
237 | const char *amoreDANameorig=gSystem->Getenv("AMORE_DA_NAME"); | |
238 | ||
239 | gSystem->Setenv("AMORE_DA_NAME",Form("TRD-dataQA-%02d-%s",ldcnumber,FILE_ID)); | |
240 | ||
241 | ///////////////////// | |
242 | // Send the stuff | |
243 | //////////////////// | |
244 | if (ldcnumber>-1){ | |
2c61d953 | 245 | TDatime time; |
246 | TObjString info(Form("Run: %u; Date: %s",runNb,time.AsSQLString())); | |
247 | ||
248 | amore::da::AmoreDA amoreDA(amore::da::AmoreDA::kSender); | |
249 | Int_t statusDA=0; | |
250 | statusDA+=amoreDA.Send("Pedestals",calipad); | |
251 | statusDA+=amoreDA.Send("Info",&info); | |
252 | if ( statusDA ) | |
fd50bb14 | 253 | printf("Warning: Failed to write one of the calib objects to the AMORE database\n"); |
1785640c | 254 | } else { |
fd50bb14 | 255 | printf("Warning: No data found!\n"); |
1785640c | 256 | } |
257 | ||
258 | // reset env var | |
259 | if (amoreDANameorig) gSystem->Setenv("AMORE_DA_NAME",amoreDANameorig); | |
260 | ||
2c61d953 | 261 | } |
1785640c | 262 | |
1785640c | 263 | |
264 |