]>
Commit | Line | Data |
---|---|---|
ec55623f | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
16 | /* $Id$ */ | |
17 | ||
18 | //////////////////////////////////////////////////////////////////////////// | |
19 | // // | |
20 | // This class is a first implementation for the TRD. // | |
21 | // It takes data from HLT and computes the parameters // | |
22 | // and stores both reference data and online calibration // | |
23 | // parameters in the CDB // | |
a5e1169e | 24 | // It alsotakes DCS data, does spline fits // |
25 | // and stores both reference data and spline fits results // | |
26 | // in the CDB // | |
ec55623f | 27 | // // |
fdfee371 | 28 | // Authors: // |
ec55623f | 29 | // R. Bailhache (R.Bailhache@gsi.de) // |
6a0417c1 | 30 | // J. Book (jbook@ikf.uni-frankfurt.de) // |
cd4fc278 | 31 | // W. Monange (w.monange@gsi.de) // |
fdfee371 | 32 | // F. Kramer (kramer@ikf.uni-frankfurt.de) // |
ec55623f | 33 | // // |
34 | //////////////////////////////////////////////////////////////////////////// | |
e5c60cc7 | 35 | |
c893147d | 36 | #include <fstream> |
37 | ||
e5c60cc7 | 38 | #include <TFile.h> |
39 | #include <TProfile2D.h> | |
e5c60cc7 | 40 | #include <TObjString.h> |
41 | #include <TString.h> | |
42 | #include <TList.h> | |
fdfee371 | 43 | #include <TSAXParser.h> |
e5c60cc7 | 44 | |
45 | #include "AliCDBMetaData.h" | |
e5c60cc7 | 46 | #include "AliLog.h" |
47 | ||
c8ab4518 | 48 | #include "AliTRDPreprocessor.h" |
3a0f6479 | 49 | #include "AliTRDSensorArray.h" |
67c25e8d | 50 | #include "AliTRDCalibraFit.h" |
51 | #include "AliTRDCalibraMode.h" | |
3a0f6479 | 52 | #include "AliTRDCalibPadStatus.h" |
fdfee371 | 53 | #include "AliTRDSaxHandler.h" |
c893147d | 54 | #include "AliTRDgeometry.h" |
6a0417c1 | 55 | #include "AliTRDCalibChamberStatus.h" |
5029ad25 | 56 | #include "Cal/AliTRDCalPad.h" |
3a0f6479 | 57 | #include "Cal/AliTRDCalPadStatus.h" |
fdfee371 | 58 | #include "Cal/AliTRDCalDCS.h" |
5029ad25 | 59 | #include "Cal/AliTRDCalSingleChamberStatus.h" |
6a0417c1 | 60 | #include "Cal/AliTRDCalChamberStatus.h" |
5029ad25 | 61 | #include "Cal/AliTRDCalROC.h" |
62 | ||
e5c60cc7 | 63 | ClassImp(AliTRDPreprocessor) |
64 | ||
65 | //______________________________________________________________________________________________ | |
ec55623f | 66 | AliTRDPreprocessor::AliTRDPreprocessor(AliShuttleInterface *shuttle) |
c8ab4518 | 67 | :AliPreprocessor("TRD", shuttle) |
6a0417c1 | 68 | ,fCalDCSObjSOR(0) |
69 | ,fCalDCSObjEOR(0) | |
c8ab4518 | 70 | ,fVdriftHLT(0) |
e5c60cc7 | 71 | { |
72 | // | |
73 | // Constructor | |
74 | // | |
75 | ||
6a0417c1 | 76 | |
f9ed5395 | 77 | AddRunType("PHYSICS"); |
78 | AddRunType("STANDALONE"); | |
79 | AddRunType("PEDESTAL"); | |
80 | AddRunType("DAQ"); | |
81 | ||
6a0417c1 | 82 | |
83 | } | |
84 | //______________________________________________________________________________________________ | |
85 | AliTRDPreprocessor::AliTRDPreprocessor(const AliTRDPreprocessor& ) : | |
86 | AliPreprocessor("TRD",0), | |
87 | fCalDCSObjSOR(0), | |
88 | fCalDCSObjEOR(0), | |
89 | fVdriftHLT(0) | |
90 | { | |
91 | ||
92 | Fatal("AliTRDPreprocessor", "copy constructor not implemented"); | |
93 | ||
e5c60cc7 | 94 | } |
e5c60cc7 | 95 | //______________________________________________________________________________________________ |
96 | AliTRDPreprocessor::~AliTRDPreprocessor() | |
97 | { | |
98 | // | |
99 | // Destructor | |
100 | // | |
101 | ||
6a0417c1 | 102 | if (fCalDCSObjSOR != NULL) { |
103 | delete fCalDCSObjSOR; | |
104 | fCalDCSObjSOR =0; | |
105 | } | |
106 | if (fCalDCSObjEOR != NULL) { | |
107 | delete fCalDCSObjEOR; | |
108 | fCalDCSObjEOR =0; | |
109 | } | |
e5c60cc7 | 110 | |
6a0417c1 | 111 | } |
112 | //______________________________________________________________________________________________ | |
113 | AliTRDPreprocessor& AliTRDPreprocessor::operator = (const AliTRDPreprocessor& ) | |
114 | { | |
115 | Fatal("operator =", "assignment operator not implemented"); | |
116 | return *this; | |
117 | } | |
e5c60cc7 | 118 | //______________________________________________________________________________________________ |
119 | void AliTRDPreprocessor::Initialize(Int_t run, UInt_t startTime, UInt_t endTime) | |
120 | { | |
121 | // | |
122 | // Initialization routine for the TRD preprocessor | |
123 | // | |
124 | ||
125 | AliPreprocessor::Initialize(run,startTime,endTime); | |
6a0417c1 | 126 | |
e5c60cc7 | 127 | } |
128 | ||
129 | //______________________________________________________________________________________________ | |
a5e1169e | 130 | UInt_t AliTRDPreprocessor::Process(TMap* dcsAliasMap) |
e5c60cc7 | 131 | { |
a5e1169e | 132 | // |
133 | // Process DCS and calibration part for HLT | |
134 | // | |
135 | ||
8dd14606 | 136 | TString runType = GetRunType(); |
137 | Log(Form("runtype %s\n",runType.Data())); | |
65ffd646 | 138 | |
fdfee371 | 139 | // always process the configuration data |
3821ce70 | 140 | Int_t DCSConfigReturn = ProcessDCSConfigData(); |
141 | if(DCSConfigReturn) return DCSConfigReturn; | |
6a0417c1 | 142 | |
b70c68da | 143 | if (runType=="PEDESTAL"){ |
8dd14606 | 144 | if(ExtractPedestals()) return 1; |
145 | return 0; | |
146 | } | |
a5e1169e | 147 | |
f9ed5395 | 148 | if ((runType=="PHYSICS") || (runType=="STANDALONE") || (runType=="DAQ")){ |
65ffd646 | 149 | // DCS |
6a0417c1 | 150 | if(ProcessDCS(dcsAliasMap)) return 1; |
f9ed5395 | 151 | if(runType=="PHYSICS"){ |
152 | // HLT if On | |
153 | //TString runPar = GetRunParameter("HLTStatus"); | |
154 | //if(runPar=="1") { | |
155 | if(GetHLTStatus()) { | |
83bc2fc6 | 156 | //if(ExtractHLT()) return 1; // for testing! |
157 | ExtractHLT(); | |
f9ed5395 | 158 | } |
159 | // DAQ if HLT failed | |
160 | if(!fVdriftHLT) { | |
594b418c | 161 | //if(ExtractDriftVelocityDAQ()) return 1; |
162 | ExtractDriftVelocityDAQ(); // for testing! | |
f9ed5395 | 163 | } |
164 | } | |
6a0417c1 | 165 | //if((runType=="PHYSICS") || (runType=="STANDALONE")) { |
166 | // if(ExtractHalfChamberStatusDAQ()) return 1; | |
167 | //} | |
6ace5fe2 | 168 | } |
8dd14606 | 169 | |
170 | return 0; | |
6ace5fe2 | 171 | |
f5bb5557 | 172 | } |
173 | //______________________________________________________________________________ | |
174 | Bool_t AliTRDPreprocessor::ProcessDCS() | |
175 | { | |
c8ab4518 | 176 | // |
177 | // Default process DCS method | |
178 | // | |
f5bb5557 | 179 | |
180 | TString runType = GetRunType(); | |
b70c68da | 181 | if ((runType == "PHYSICS") || (runType == "STANDALONE")) { |
c8ab4518 | 182 | return kTRUE; |
183 | } | |
f5bb5557 | 184 | return kFALSE; |
185 | ||
6ace5fe2 | 186 | } |
187 | ||
6ace5fe2 | 188 | //______________________________________________________________________________ |
c8ab4518 | 189 | Bool_t AliTRDPreprocessor::ProcessDCS(TMap *dcsAliasMap) |
6ace5fe2 | 190 | { |
c8ab4518 | 191 | // |
192 | // Process DCS method | |
193 | // | |
194 | ||
195 | Bool_t error = kFALSE; | |
6ace5fe2 | 196 | |
a5e1169e | 197 | AliCDBMetaData metaData; |
198 | metaData.SetBeamPeriod(0); | |
199 | metaData.SetResponsible("Wilfried Monange/Raphaelle Bailhache"); | |
200 | metaData.SetComment("TRD calib test"); | |
c8ab4518 | 201 | |
202 | Log("****** DCS ******\n"); | |
cd4fc278 | 203 | |
6a0417c1 | 204 | TObjArray * list=AliTRDSensorArray::GetList(); |
cd4fc278 | 205 | |
206 | if (list == 0x0) { | |
6ace5fe2 | 207 | Log ("Error during AliTRDSensorArray::GetList"); |
208 | Log ("DCS will not be processing"); | |
8dd14606 | 209 | return kTRUE; |
6ace5fe2 | 210 | } |
211 | ||
212 | Int_t nEntries = list->GetEntries (); | |
213 | Log (Form ("%d alias loaded", nEntries)); | |
cd4fc278 | 214 | |
6ace5fe2 | 215 | Bool_t * results=new Bool_t [nEntries]; |
216 | Int_t * nGraph=new Int_t [nEntries]; | |
cd4fc278 | 217 | |
6ace5fe2 | 218 | for (Int_t iAlias = 0; iAlias < nEntries; iAlias++) { |
cd4fc278 | 219 | |
6ace5fe2 | 220 | AliTRDSensorArray * oneTRDDCS = (AliTRDSensorArray *)list->At (iAlias); |
cd4fc278 | 221 | |
6ace5fe2 | 222 | oneTRDDCS->SetStartTime (TTimeStamp (fStartTime)); |
223 | oneTRDDCS->SetEndTime (TTimeStamp (fEndTime)); | |
cd4fc278 | 224 | |
c8ab4518 | 225 | Log(Form("Processing DCS : \"%s\"", oneTRDDCS->GetStoreName ().Data ())); |
cd4fc278 | 226 | |
6ace5fe2 | 227 | TMap * map; |
228 | ||
229 | map=oneTRDDCS->ExtractDCS (dcsAliasMap); | |
cd4fc278 | 230 | |
6ace5fe2 | 231 | nGraph [iAlias] = map->GetEntries (); |
cd4fc278 | 232 | |
6ace5fe2 | 233 | if (nGraph [iAlias] == 0) { |
234 | Log("No TGraph for this dcsDatapointAlias : not stored"); | |
235 | results [iAlias] = kFALSE; | |
611a7239 | 236 | //error = kTRUE; |
6ace5fe2 | 237 | continue; |
238 | } | |
cd4fc278 | 239 | |
6ace5fe2 | 240 | oneTRDDCS->SetGraph(map); |
611a7239 | 241 | results[iAlias]=Store("Calib", oneTRDDCS->GetStoreName().Data(), oneTRDDCS, &metaData, 0, kFALSE); |
6ace5fe2 | 242 | delete map; |
243 | ||
244 | //results [iAlias] = StoreReferenceData("Calib", oneTRDDCS->GetStoreName ().Data (), oneTRDDCS, &metaData); | |
245 | ||
6ace5fe2 | 246 | if (!results[iAlias]) { |
8dd14606 | 247 | AliError("Problem during StoreRef DCS"); |
611a7239 | 248 | //error=kTRUE; |
6ace5fe2 | 249 | } |
250 | ||
6ace5fe2 | 251 | //BEGIN TEST (should not be removed ...) |
252 | /* | |
253 | oneTRDDCS->ClearGraph(); | |
254 | oneTRDDCS->ClearFit(); | |
255 | oneTRDDCS->SetDiffCut2 (0.1); | |
256 | map=oneTRDDCS->ExtractDCS (dcsAliasMap); | |
257 | oneTRDDCS->SetGraph (map); | |
258 | Store("Calib", ("cut_"+oneTRDDCS->GetStoreName()).Data(), oneTRDDCS, &metaData, 0, kTRUE); | |
259 | delete map; | |
260 | ||
261 | ||
262 | if(iAlias==1 || iAlias==19) continue; | |
263 | ||
264 | oneTRDDCS->ClearGraph(); | |
265 | oneTRDDCS->ClearFit(); | |
266 | oneTRDDCS->SetDiffCut2(0); | |
267 | map=oneTRDDCS->ExtractDCS(dcsAliasMap); | |
268 | oneTRDDCS->MakeSplineFit(map); | |
269 | Store("Calib", ("fit_"+oneTRDDCS->GetStoreName()).Data() , oneTRDDCS, &metaData, 0, kTRUE); | |
270 | delete map; | |
271 | ||
272 | ||
273 | oneTRDDCS->ClearGraph(); | |
274 | oneTRDDCS->ClearFit(); | |
275 | oneTRDDCS->SetDiffCut2 (0.1); | |
276 | map=oneTRDDCS->ExtractDCS (dcsAliasMap); | |
277 | oneTRDDCS->MakeSplineFit(map); | |
278 | Store("Calib", ("cutfit_"+oneTRDDCS->GetStoreName()).Data() , oneTRDDCS, &metaData, 0, kTRUE); | |
279 | delete map; | |
280 | */ | |
281 | //END TEST | |
282 | ||
6ace5fe2 | 283 | } |
611a7239 | 284 | |
285 | // Check errors | |
286 | Int_t nbCount = 0; | |
287 | for (Int_t iAlias = 0; iAlias < nEntries; iAlias++) { | |
288 | if (results[iAlias]) { | |
289 | nbCount++; | |
290 | } | |
291 | } | |
292 | if(nbCount == 0) error = kTRUE; | |
293 | ||
cd4fc278 | 294 | |
6ace5fe2 | 295 | Log (" Summury of DCS :\n"); |
296 | Log (Form("%30s %10s %10s", "dcsDatapointAlias", "Stored ?", "# graph")); | |
297 | for (Int_t iAlias = 0; iAlias < nEntries; iAlias++) { | |
298 | AliTRDSensorArray * oneTRDDCS = (AliTRDSensorArray *)list->At (iAlias); | |
299 | Log (Form ("%30s %10s %4d", | |
300 | oneTRDDCS->GetStoreName ().Data (), | |
301 | results[iAlias] ? "ok" : "X", | |
302 | nGraph [iAlias])); | |
303 | } | |
304 | Log ("*********** End of DCS **********"); | |
305 | ||
4ce766eb | 306 | delete [] results; |
307 | delete [] nGraph; | |
6ace5fe2 | 308 | |
8dd14606 | 309 | return error; |
c8ab4518 | 310 | |
6ace5fe2 | 311 | } |
6a0417c1 | 312 | //______________________________________________________________________________________________ |
313 | Bool_t AliTRDPreprocessor::ExtractHalfChamberStatusDAQ() | |
314 | { | |
315 | // | |
316 | // Half chamber status algorithm running on DAQ | |
317 | // | |
318 | ||
319 | Bool_t error = kFALSE; | |
320 | ||
321 | AliCDBMetaData metaData; | |
322 | metaData.SetBeamPeriod(0); | |
323 | metaData.SetResponsible("Raphaelle Bailhache"); | |
324 | metaData.SetComment("TRD calib test"); | |
325 | ||
326 | // Take the output of the DA on DAQ | |
327 | TList * listpad = GetFileSources(kDAQ,"HALFCHAMBERSTATUS"); | |
328 | if (!listpad) { | |
329 | Log("No list found for the HalfChamberStatus"); | |
330 | return kTRUE; | |
331 | } | |
332 | ||
333 | AliTRDCalibChamberStatus *calPed = 0x0; | |
334 | ||
335 | // loop through all files (only one normally) | |
336 | UInt_t index = 0; | |
337 | while (listpad->At(index)!=NULL) { | |
338 | TObjString* fileNameEntry = (TObjString*) listpad->At(index); | |
339 | if (fileNameEntry != NULL) | |
340 | { | |
341 | TString fileName = GetFile(kDAQ, "HALFCHAMBERSTATUS", | |
342 | fileNameEntry->GetString().Data()); | |
343 | if(fileName.Length() ==0){ | |
344 | Log(Form("Error by retrieving the file %d for the halfchamberstatus",(Int_t)index)); | |
345 | delete listpad; | |
346 | return kTRUE; | |
347 | } | |
348 | ||
349 | TFile *f = TFile::Open(fileName); | |
350 | f->GetObject("calibchamberstatus",calPed); | |
351 | ||
352 | if(calPed) { | |
353 | ||
354 | // store as reference data | |
355 | TString name("HalfChamberStatus"); | |
356 | if(!StoreReferenceData("DAQData",(const char *)name,(TObject *) calPed,&metaData)){ | |
357 | Log(Form("Error storing AliTRDCalibPadStatus object %d as reference data",(Int_t)index)); | |
358 | error = kTRUE; | |
359 | } | |
360 | } // calPed | |
361 | else Log(Form("Error getting AliTRDCalibChamberStatus onject from file")); | |
362 | ||
363 | } // fileNameEntry | |
364 | ++index; | |
365 | }// while (list) | |
6ace5fe2 | 366 | |
6a0417c1 | 367 | Log(Form("%d elements found in the list for the halfchamberstatus",(Int_t)index)); |
368 | if(index!=1){ | |
369 | delete listpad; | |
370 | return kTRUE; | |
371 | } | |
372 | ||
373 | // | |
374 | // Produce the AliTRDCalChamberStatus name calHalfChamberStatus | |
375 | // | |
376 | AliTRDCalChamberStatus *calHalfChamberStatus = 0x0; | |
377 | if(calPed) { | |
378 | //calPed->AnalyseHisto(); // check number of events, create calHalfChamberStatus (done on DAQ) | |
379 | if(fCalDCSObjEOR) { | |
380 | calPed->CheckEORStatus((AliTRDCalDCS *)fCalDCSObjEOR); | |
381 | } | |
382 | calHalfChamberStatus=(AliTRDCalChamberStatus *)calPed->GetCalChamberStatus(); | |
383 | } | |
384 | ||
385 | // | |
386 | // Store | |
387 | // | |
388 | ||
389 | AliCDBMetaData md3; | |
390 | md3.SetObjectClassName("AliTRDCalChamberStatus"); | |
391 | md3.SetResponsible("Raphaelle Bailhache"); | |
392 | md3.SetBeamPeriod(1); | |
393 | md3.SetComment("TRD calib test"); | |
394 | if(!Store("Calib","ChamberStatus" ,(TObject *)calHalfChamberStatus, &md3, 0, kTRUE)){ | |
395 | Log("Error storing the pedestal"); | |
396 | delete listpad; | |
397 | return kTRUE; | |
398 | } | |
399 | ||
400 | delete listpad; | |
401 | return error; | |
402 | ||
403 | } | |
6ace5fe2 | 404 | //______________________________________________________________________________________________ |
8dd14606 | 405 | Bool_t AliTRDPreprocessor::ExtractPedestals() |
6ace5fe2 | 406 | { |
407 | // | |
408 | // Pedestal running on LDCs at the DAQ | |
409 | // | |
54c85ef7 | 410 | |
411 | // | |
412 | // The reference data are stored in: | |
413 | // PadStatus1 for sm-00-01-02-09-10-11 | |
414 | // PadStatus2 for sm-03-04-05-12-13-14 | |
415 | // PadStatus3 for sm-06-07-08-15-16-17 | |
416 | // PadStatus0 if nothing found..means problems | |
417 | // | |
5029ad25 | 418 | |
8dd14606 | 419 | Bool_t error = kFALSE; |
6ace5fe2 | 420 | |
421 | // Init a AliTRDCalibPadStatus | |
422 | AliTRDCalibPadStatus calPedSum = AliTRDCalibPadStatus(); | |
423 | ||
424 | AliCDBMetaData metaData; | |
425 | metaData.SetBeamPeriod(0); | |
426 | metaData.SetResponsible("Raphaelle Bailhache"); | |
427 | metaData.SetComment("TRD calib test"); | |
428 | ||
429 | // Sum the contributions of the LDCs | |
430 | TList * listpad = GetFileSources(kDAQ,"PADSTATUS"); | |
8dd14606 | 431 | if (!listpad) { |
432 | Log("No list found for the PEDESTRAL Run"); | |
433 | return kTRUE; | |
434 | } | |
435 | ||
c8ab4518 | 436 | // loop through all files from LDCs |
8dd14606 | 437 | UInt_t index = 0; |
438 | while (listpad->At(index)!=NULL) { | |
439 | TObjString* fileNameEntry = (TObjString*) listpad->At(index); | |
440 | if (fileNameEntry != NULL) | |
441 | { | |
6ace5fe2 | 442 | TString fileName = GetFile(kDAQ, "PADSTATUS", |
443 | fileNameEntry->GetString().Data()); | |
8dd14606 | 444 | if(fileName.Length() ==0){ |
6ace5fe2 | 445 | Log(Form("Error by retrieving the file %d for the pedestal",(Int_t)index)); |
8dd14606 | 446 | delete listpad; |
447 | return kTRUE; | |
cd4fc278 | 448 | } |
8dd14606 | 449 | |
450 | TFile *f = TFile::Open(fileName); | |
451 | AliTRDCalibPadStatus *calPed; | |
452 | f->GetObject("calibpadstatus",calPed); | |
453 | ||
454 | if(calPed){ | |
455 | ||
54c85ef7 | 456 | Int_t ldc = 0; |
289cc637 | 457 | |
8dd14606 | 458 | // analyse |
289cc637 | 459 | //calPed->AnalyseHisto(); |
460 | ||
461 | // Add to the calPedSum | |
462 | for (Int_t idet=0; idet<540; idet++) { | |
463 | AliTRDCalROC *rocMean = calPed->GetCalRocMean(idet, kFALSE); | |
464 | if ( rocMean ) { | |
465 | calPedSum.SetCalRocMean(rocMean,idet); | |
54c85ef7 | 466 | ldc = (Int_t) (idet / 30); |
289cc637 | 467 | } |
468 | AliTRDCalROC *rocRMS = calPed->GetCalRocRMS(idet, kFALSE); | |
469 | if ( rocRMS ) { | |
470 | calPedSum.SetCalRocRMS(rocRMS,idet); | |
471 | } | |
e4db522f | 472 | AliTRDCalROC *rocMeand = calPed->GetCalRocMeand(idet, kFALSE); |
473 | if ( rocMeand ) { | |
474 | calPedSum.SetCalRocMeand(rocMeand,idet); | |
475 | } | |
476 | AliTRDCalROC *rocRMSd = calPed->GetCalRocRMSd(idet, kFALSE); | |
477 | if ( rocRMSd ) { | |
478 | calPedSum.SetCalRocRMSd(rocRMSd,idet); | |
479 | } | |
289cc637 | 480 | }// det loop |
481 | ||
1ac4bb35 | 482 | if((ldc==0) || (ldc==1) || (ldc==2)) ldc = 1; |
483 | if((ldc==3) || (ldc==4) || (ldc==5)) ldc = 2; | |
484 | if((ldc==6) || (ldc==7) || (ldc==8)) ldc = 3; | |
485 | if((ldc==9) || (ldc==10) || (ldc==11)) ldc = 4; | |
486 | if((ldc==12) || (ldc==13) || (ldc==14)) ldc = 5; | |
487 | if((ldc==15) || (ldc==16) || (ldc==17)) ldc = 6; | |
54c85ef7 | 488 | |
8dd14606 | 489 | // store as reference data |
490 | TString name("PadStatus"); | |
54c85ef7 | 491 | name += ldc; |
8dd14606 | 492 | if(!StoreReferenceData("DAQData",(const char *)name,(TObject *) calPed,&metaData)){ |
493 | Log(Form("Error storing AliTRDCalibPadStatus object %d as reference data",(Int_t)index)); | |
494 | error = kTRUE; | |
495 | } | |
289cc637 | 496 | |
8dd14606 | 497 | } // calPed |
498 | } // fileNameEntry | |
499 | ++index; | |
500 | }// while (list) | |
c8ab4518 | 501 | |
8dd14606 | 502 | Log(Form("%d elements found in the list for the pedestal",(Int_t)index)); |
503 | if(index==0){ | |
6ace5fe2 | 504 | delete listpad; |
8dd14606 | 505 | return kTRUE; |
6ace5fe2 | 506 | } |
c8ab4518 | 507 | |
8dd14606 | 508 | // |
5029ad25 | 509 | // Create pedestal |
8dd14606 | 510 | // |
c8ab4518 | 511 | |
8dd14606 | 512 | // Create Pad Status |
513 | AliTRDCalPadStatus *calPadStatus = calPedSum.CreateCalPadStatus(); | |
5029ad25 | 514 | // Create Noise |
515 | //Make the AliTRDCalPad | |
516 | AliTRDCalPad *calPad2 = calPedSum.CreateCalPad(); | |
517 | //Make the AliTRDCalDet correspondant | |
518 | AliTRDCalDet *calDet = calPedSum.CreateCalDet(); | |
519 | ||
520 | // | |
521 | // Take the noise and Pad status from the previous OCDB | |
522 | // | |
523 | ||
524 | AliTRDCalPad *calPadPrevious=0; | |
525 | AliCDBEntry* entry = GetFromOCDB("Calib", "PadNoise"); | |
526 | if (entry) calPadPrevious = (AliTRDCalPad*)entry->GetObject(); | |
527 | if ( calPadPrevious==NULL ) { | |
528 | Log("AliTRDPreprocsessor: No previous TRD pad noise entry available.\n"); | |
529 | calPadPrevious = new AliTRDCalPad("PadNoise", "PadNoise"); | |
530 | } | |
531 | ||
532 | AliTRDCalPadStatus *calPadStatusPrevious=0; | |
533 | entry = GetFromOCDB("Calib", "PadStatus"); | |
534 | if (entry) calPadStatusPrevious = (AliTRDCalPadStatus*)entry->GetObject(); | |
535 | if ( calPadStatusPrevious==NULL ) { | |
536 | Log("AliTRDPreprocsessor: No previous TRD pad status entry available.\n"); | |
537 | calPadStatusPrevious = new AliTRDCalPadStatus("padstatus", "padstatus"); | |
538 | for (Int_t idet=0; idet<540; ++idet) | |
539 | { | |
540 | AliTRDCalSingleChamberStatus *calROC = calPadStatusPrevious->GetCalROC(idet); | |
541 | for(Int_t k = 0; k < calROC->GetNchannels(); k++){ | |
542 | calROC->SetStatus(k,AliTRDCalPadStatus::kMasked); | |
543 | } | |
544 | } | |
545 | } | |
546 | ||
547 | ||
548 | // Loop over detectors for check | |
549 | for (Int_t det=0; det<AliTRDgeometry::kNdet; ++det) { | |
550 | ||
551 | // noise | |
552 | AliTRDCalROC *calROCPreviousNoise = calPadPrevious->GetCalROC(det); | |
553 | AliTRDCalROC *calROCNoise = calPad2->GetCalROC(det); | |
554 | ||
555 | // padstatus | |
556 | AliTRDCalSingleChamberStatus *calROCPreviousStatus = calPadStatusPrevious->GetCalROC(det); | |
557 | AliTRDCalSingleChamberStatus *calROCStatus = calPadStatus->GetCalROC(det); | |
558 | ||
559 | ||
560 | // loop over first half and second half chamber | |
561 | for(Int_t half = 0; half < 2; half++){ | |
562 | ||
563 | Bool_t data = AreThereDataPedestal(calROCStatus,(Bool_t)half); | |
37b0cf5e | 564 | //printf("There are data for the detector %d the half %d: %d\n",det,half,data); |
5029ad25 | 565 | if(!data){ |
566 | // look if data in the OCDB | |
567 | Bool_t dataPrevious = AreThereDataPedestal(calROCPreviousStatus,(Bool_t)half); | |
568 | // if no data at all, set to default value | |
569 | if(!dataPrevious){ | |
570 | SetDefaultStatus(*calROCStatus,(Bool_t)half); | |
571 | SetDefaultNoise(*calROCNoise,(Bool_t)half); | |
572 | } | |
573 | else{ | |
574 | // if data, set to previous value | |
575 | SetStatus(*calROCStatus,calROCPreviousStatus,(Bool_t)half); | |
576 | SetNoise(*calROCNoise,calROCPreviousNoise,(Bool_t)half); | |
577 | } | |
578 | } | |
579 | } | |
580 | } | |
581 | ||
582 | // | |
583 | // Store | |
584 | // | |
585 | ||
8dd14606 | 586 | AliCDBMetaData md3; |
587 | md3.SetObjectClassName("AliTRDCalPadStatus"); | |
588 | md3.SetResponsible("Raphaelle Bailhache"); | |
589 | md3.SetBeamPeriod(1); | |
590 | md3.SetComment("TRD calib test"); | |
591 | if(!Store("Calib","PadStatus" ,(TObject *)calPadStatus, &md3, 0, kTRUE)){ | |
592 | Log("Error storing the pedestal"); | |
593 | delete listpad; | |
594 | return kTRUE; | |
a5e1169e | 595 | } |
289cc637 | 596 | |
289cc637 | 597 | AliCDBMetaData md4; |
598 | md4.SetObjectClassName("AliTRDCalPad"); | |
599 | md4.SetResponsible("Raphaelle Bailhache"); | |
600 | md4.SetBeamPeriod(1); | |
601 | md4.SetComment("TRD calib test"); | |
602 | if(!Store("Calib","PadNoise" ,(TObject *)calPad2, &md4, 0, kTRUE)){ | |
603 | Log("Error storing the pedestal"); | |
604 | delete listpad; | |
605 | return kTRUE; | |
606 | } | |
5029ad25 | 607 | |
289cc637 | 608 | AliCDBMetaData md5; |
609 | md5.SetObjectClassName("AliTRDCalDet"); | |
610 | md5.SetResponsible("Raphaelle Bailhache"); | |
611 | md5.SetBeamPeriod(1); | |
612 | md5.SetComment("TRD calib test"); | |
613 | if(!Store("Calib","DetNoise" ,(TObject *)calDet, &md5, 0, kTRUE)){ | |
614 | Log("Error storing the pedestal"); | |
615 | delete listpad; | |
616 | return kTRUE; | |
617 | } | |
618 | ||
8dd14606 | 619 | delete listpad; |
620 | return error; | |
5029ad25 | 621 | |
622 | } | |
c893147d | 623 | |
5029ad25 | 624 | //__________________________________________________________________ |
c893147d | 625 | Bool_t AliTRDPreprocessor::AreThereDataPedestal(AliTRDCalSingleChamberStatus * const calROCStatus |
626 | , Bool_t second) | |
627 | { | |
a5e1169e | 628 | |
5029ad25 | 629 | // |
630 | // Data for this half chamber | |
631 | // | |
632 | ||
633 | Bool_t data = kFALSE; | |
634 | Int_t nCols = calROCStatus->GetNcols(); | |
635 | Int_t nCol0 = 0; | |
636 | Int_t nColE = (Int_t) nCols/2 - 2; | |
637 | if(second) { | |
638 | nCol0 = nColE + 4; | |
639 | nColE = nCols; | |
640 | } | |
f2a468d7 | 641 | |
642 | Int_t totalnumberofpads = 0; | |
643 | Int_t totalnumberofdata = 0; | |
644 | ||
5029ad25 | 645 | for(Int_t col = nCol0; col < nColE; col++){ |
646 | for(Int_t row = 0; row < calROCStatus->GetNrows(); row++){ | |
f2a468d7 | 647 | totalnumberofpads++; |
5029ad25 | 648 | //printf("ismasked %d\n",(Int_t)calROCStatus->IsMasked(col,row)); |
37b0cf5e | 649 | if(!calROCStatus->GetStatus(col,row)) { |
5029ad25 | 650 | data = kTRUE; |
f2a468d7 | 651 | totalnumberofdata++; |
5029ad25 | 652 | } |
653 | } | |
5029ad25 | 654 | } |
f2a468d7 | 655 | if(totalnumberofdata < (Int_t)(totalnumberofpads/2)) data = kFALSE; |
5029ad25 | 656 | |
657 | return data; | |
658 | ||
659 | } | |
660 | //__________________________________________________________________ | |
661 | void AliTRDPreprocessor::SetDefaultStatus(AliTRDCalSingleChamberStatus &calROCStatus, Bool_t second){ | |
662 | ||
663 | // | |
664 | // default status for this half chamber | |
665 | // | |
666 | ||
667 | Int_t nCols = calROCStatus.GetNcols(); | |
668 | Int_t nCol0 = 0; | |
669 | Int_t nColE = (Int_t) nCols/2; | |
670 | if(second) { | |
671 | nCol0 = nColE; | |
672 | nColE = nCols; | |
673 | } | |
674 | for(Int_t col = nCol0; col < nColE; col++){ | |
675 | for(Int_t row = 0; row < calROCStatus.GetNrows(); row++){ | |
676 | calROCStatus.SetStatus(col,row,0); | |
677 | } | |
678 | } | |
679 | } | |
680 | //__________________________________________________________________ | |
681 | void AliTRDPreprocessor::SetStatus(AliTRDCalSingleChamberStatus &calROCStatus, AliTRDCalSingleChamberStatus *calROCStatusPrevious,Bool_t second){ | |
682 | ||
683 | // | |
684 | // previous status for this half chamber | |
685 | // | |
686 | ||
687 | Int_t nCols = calROCStatus.GetNcols(); | |
688 | Int_t nCol0 = 0; | |
689 | Int_t nColE = (Int_t) nCols/2; | |
690 | if(second) { | |
691 | nCol0 = nColE; | |
692 | nColE = nCols; | |
693 | } | |
694 | for(Int_t col = nCol0; col < nColE; col++){ | |
695 | for(Int_t row = 0; row < calROCStatus.GetNrows(); row++){ | |
696 | calROCStatus.SetStatus(col,row,calROCStatusPrevious->GetStatus(col,row)); | |
697 | } | |
698 | } | |
6ace5fe2 | 699 | } |
5029ad25 | 700 | //__________________________________________________________________ |
701 | void AliTRDPreprocessor::SetDefaultNoise(AliTRDCalROC &calROCNoise, Bool_t second){ | |
702 | ||
703 | // | |
704 | // default noise for this half chamber | |
705 | // | |
c8ab4518 | 706 | |
5029ad25 | 707 | Int_t nCols = calROCNoise.GetNcols(); |
708 | Int_t nCol0 = 0; | |
709 | Int_t nColE = (Int_t) nCols/2; | |
710 | if(second) { | |
711 | nCol0 = nColE; | |
712 | nColE = nCols; | |
713 | } | |
714 | for(Int_t col = nCol0; col < nColE; col++){ | |
715 | for(Int_t row = 0; row < calROCNoise.GetNrows(); row++){ | |
716 | calROCNoise.SetValue(col,row,0.12); | |
717 | } | |
718 | } | |
719 | } | |
720 | //__________________________________________________________________ | |
721 | void AliTRDPreprocessor::SetNoise(AliTRDCalROC &calROCNoise, AliTRDCalROC *calROCNoisePrevious, Bool_t second){ | |
722 | ||
723 | // | |
724 | // previous noise for this half chamber | |
725 | // | |
726 | ||
727 | Int_t nCols = calROCNoise.GetNcols(); | |
728 | Int_t nCol0 = 0; | |
729 | Int_t nColE = (Int_t) nCols/2; | |
730 | if(second) { | |
731 | nCol0 = nColE; | |
732 | nColE = nCols; | |
733 | } | |
734 | for(Int_t col = nCol0; col < nColE; col++){ | |
735 | for(Int_t row = 0; row < calROCNoise.GetNrows(); row++){ | |
736 | calROCNoise.SetValue(col,row,calROCNoisePrevious->GetValue(col,row)); | |
737 | } | |
738 | } | |
739 | } | |
6ace5fe2 | 740 | //______________________________________________________________________________________________ |
8dd14606 | 741 | Bool_t AliTRDPreprocessor::ExtractDriftVelocityDAQ() |
6ace5fe2 | 742 | { |
e5c60cc7 | 743 | // |
6ace5fe2 | 744 | // Drift velocity DA running on monitoring servers at the DAQ |
e5c60cc7 | 745 | // |
746 | ||
8dd14606 | 747 | Bool_t error = kFALSE; |
6ace5fe2 | 748 | |
749 | // Objects for HLT and DAQ zusammen | |
3a0f6479 | 750 | AliTRDCalibraFit *calibra = AliTRDCalibraFit::Instance(); |
6ace5fe2 | 751 | AliCDBMetaData metaData; |
752 | metaData.SetBeamPeriod(0); | |
753 | metaData.SetResponsible("Raphaelle Bailhache"); | |
754 | metaData.SetComment("TRD calib test"); | |
3a0f6479 | 755 | // Store the infos for the detector |
6ace5fe2 | 756 | AliCDBMetaData md1; |
757 | md1.SetObjectClassName("AliTRDCalDet"); | |
758 | md1.SetResponsible("Raphaelle Bailhache"); | |
759 | md1.SetBeamPeriod(0); | |
760 | md1.SetComment("TRD calib test"); | |
3a0f6479 | 761 | // Store the infos for the pads |
6ace5fe2 | 762 | AliCDBMetaData md2; |
763 | md2.SetObjectClassName("AliTRDCalPad"); | |
764 | md2.SetResponsible("Raphaelle Bailhache"); | |
765 | md2.SetBeamPeriod(0); | |
766 | md2.SetComment("TRD calib test"); | |
3a0f6479 | 767 | |
6ace5fe2 | 768 | // Take the file from the DAQ file exchange server |
769 | TList *listdaq = GetFileSources(kDAQ,"VDRIFT"); | |
8dd14606 | 770 | if (!listdaq) { |
6ace5fe2 | 771 | Log("No list found for vdrift (DAQ)"); |
8dd14606 | 772 | return kTRUE; |
773 | } | |
774 | ||
775 | if(listdaq->GetSize() !=1){ | |
776 | Log(Form("Problem on the size of the list: %d (DAQ)",listdaq->GetSize())); | |
777 | delete listdaq; | |
778 | return kTRUE; | |
6ace5fe2 | 779 | } |
8dd14606 | 780 | |
781 | TObjString* fileNameEntry = (TObjString*) listdaq->At(0); | |
782 | if(fileNameEntry != NULL){ | |
783 | TString fileName = GetFile(kDAQ, "VDRIFT", | |
784 | fileNameEntry->GetString().Data()); | |
785 | if(fileName.Length() ==0){ | |
786 | Log("Error retrieving the file vdrift (DAQ)"); | |
787 | delete listdaq; | |
788 | return kTRUE; | |
789 | } | |
790 | TFile *filedaq = TFile::Open(fileName); | |
791 | TProfile2D *histodriftvelocity = (TProfile2D *) filedaq->Get("PH2d"); | |
792 | if (histodriftvelocity) { | |
793 | ||
794 | // store as reference data | |
795 | if(!StoreReferenceData("DAQData","VdriftT0",(TObject *) histodriftvelocity,&metaData)){ | |
796 | Log("Error storing 2D Profile for vdrift from the DAQ"); | |
797 | error = kTRUE; | |
798 | } | |
799 | ||
800 | // analyse | |
801 | ||
802 | Log("Take the PH reference data. Now we will try to fit\n"); | |
803 | calibra->SetMinEntries(2000); // If there is less than 2000 | |
804 | calibra->AnalysePH(histodriftvelocity); | |
805 | ||
806 | Int_t nbtg = 6*4*18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb0(1)) | |
807 | + 6* 18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb2(1)); | |
808 | Int_t nbfit = calibra->GetNumberFit(); | |
6aafa7ea | 809 | Int_t nbfitSuccess = calibra->GetNumberFitSuccess(); |
8dd14606 | 810 | Int_t nbE = calibra->GetNumberEnt(); |
811 | ||
812 | // if enough statistics store the results | |
813 | if ((nbtg > 0) && | |
6aafa7ea | 814 | (nbfit >= 0.5*nbE) && (nbE > 30) && (nbfitSuccess > 30)) { |
8dd14606 | 815 | // create the cal objects |
6aafa7ea | 816 | calibra->RemoveOutliers(1,kTRUE); |
64942b85 | 817 | calibra->PutMeanValueOtherVectorFit(1,kTRUE); |
6aafa7ea | 818 | calibra->RemoveOutliers2(kTRUE); |
64942b85 | 819 | calibra->PutMeanValueOtherVectorFit2(1,kTRUE); |
8dd14606 | 820 | TObjArray object = calibra->GetVectorFit(); |
821 | AliTRDCalDet *objdriftvelocitydet = calibra->CreateDetObjectVdrift(&object,kTRUE); | |
6a0417c1 | 822 | // TObject *objdriftvelocitypad = calibra->CreatePadObjectVdrift(); |
8dd14606 | 823 | object = calibra->GetVectorFit2(); |
824 | AliTRDCalDet *objtime0det = calibra->CreateDetObjectT0(&object,kTRUE); | |
6a0417c1 | 825 | // TObject *objtime0pad = calibra->CreatePadObjectT0(); |
8dd14606 | 826 | calibra->ResetVectorFit(); |
827 | // store | |
6a0417c1 | 828 | if(!Store("Calib","ChamberVdrift" ,(TObject *) objdriftvelocitydet,&md1,0,kTRUE)){ |
829 | Log("Error storing the calibration object for the chamber vdrift (DAQ)"); | |
830 | error = kTRUE; | |
831 | } | |
832 | if(!Store("Calib","ChamberT0" ,(TObject *) objtime0det ,&md1,0,kTRUE)){ | |
833 | Log("Error storing the calibration object for the chamber t0 (DAQ)"); | |
834 | error = kTRUE; | |
835 | } | |
836 | // if(!Store("Calib","LocalVdrift" ,(TObject *) objdriftvelocitypad,&md2,0,kTRUE)){ | |
837 | // Log("Error storing the calibration object for the local drift velocity (DAQ)"); | |
838 | // error = kTRUE; | |
839 | // } | |
840 | // if(!Store("Calib","LocalT0" ,(TObject *) objtime0pad ,&md2,0,kTRUE)){ | |
841 | // Log("Error storing the calibration object for the local time0 (DAQ)"); | |
842 | // error = kTRUE; | |
843 | // } | |
8dd14606 | 844 | } |
845 | else{ | |
846 | Log("Not enough statistics for the average pulse height (DAQ)"); | |
847 | } | |
848 | } // histo here | |
849 | }// if fileNameEntry | |
850 | ||
851 | delete listdaq; | |
852 | return error; | |
853 | ||
6ace5fe2 | 854 | } |
c8ab4518 | 855 | |
6ace5fe2 | 856 | //______________________________________________________________________________________________ |
8dd14606 | 857 | Bool_t AliTRDPreprocessor::ExtractHLT() |
6ace5fe2 | 858 | { |
e5c60cc7 | 859 | // |
6ace5fe2 | 860 | // Gain, vdrift and PRF calibration running on HLT |
f5bb5557 | 861 | // return kTRUE if NULL pointer to the list |
e5c60cc7 | 862 | // |
3a0f6479 | 863 | |
8dd14606 | 864 | Bool_t error = kFALSE; |
865 | ||
6ace5fe2 | 866 | // Objects for HLT and DAQ zusammen |
867 | AliTRDCalibraFit *calibra = AliTRDCalibraFit::Instance(); | |
868 | AliCDBMetaData metaData; | |
869 | metaData.SetBeamPeriod(0); | |
870 | metaData.SetResponsible("Raphaelle Bailhache"); | |
871 | metaData.SetComment("TRD calib test"); | |
872 | // Store the infos for the detector | |
873 | AliCDBMetaData md1; | |
874 | md1.SetObjectClassName("AliTRDCalDet"); | |
875 | md1.SetResponsible("Raphaelle Bailhache"); | |
876 | md1.SetBeamPeriod(0); | |
877 | md1.SetComment("TRD calib test"); | |
878 | // Store the infos for the pads | |
879 | AliCDBMetaData md2; | |
880 | md2.SetObjectClassName("AliTRDCalPad"); | |
881 | md2.SetResponsible("Raphaelle Bailhache"); | |
882 | md2.SetBeamPeriod(0); | |
883 | md2.SetComment("TRD calib test"); | |
6ace5fe2 | 884 | |
885 | // Take the file from the HLT file exchange server | |
886 | TList *listhlt = GetFileSources(kHLT,"GAINDRIFTPRF"); | |
8dd14606 | 887 | if (!listhlt) { |
6ace5fe2 | 888 | Log("No list found for the HLT"); |
8dd14606 | 889 | return kTRUE; |
890 | } | |
891 | ||
892 | if(listhlt->GetSize() != 1) { | |
893 | Log(Form("Problem on the size of the list: %d (HLT)",listhlt->GetSize())); | |
894 | delete listhlt; | |
895 | return kTRUE; | |
6ace5fe2 | 896 | } |
3a0f6479 | 897 | |
8dd14606 | 898 | TObjString* fileNameEntry = (TObjString*) listhlt->At(0); |
899 | if(fileNameEntry != NULL){ | |
900 | TString fileName = GetFile(kHLT, "GAINDRIFTPRF", | |
901 | fileNameEntry->GetString().Data()); | |
902 | if(fileName.Length() ==0){ | |
903 | Log("Error retrieving the file (HLT)"); | |
904 | delete listhlt; | |
905 | return kTRUE; | |
906 | } | |
907 | // Take the file | |
908 | TFile *filehlt = TFile::Open(fileName); | |
909 | ||
8dd14606 | 910 | // gain |
911 | TH2I *histogain = (TH2I *) filehlt->Get("CH2d"); | |
8dd14606 | 912 | if (histogain) { |
7172a9fa | 913 | histogain->SetDirectory(0); |
8dd14606 | 914 | // store the reference data |
915 | if(!StoreReferenceData("HLTData","Gain",(TObject *) histogain,&metaData)){ | |
916 | Log("Error storing 2D histos for gain"); | |
917 | error = kTRUE; | |
918 | } | |
919 | // analyse | |
920 | Log("Take the CH reference data. Now we will try to fit\n"); | |
64942b85 | 921 | calibra->SetMinEntries(800); // If there is less than 1000 entries in the histo: no fit |
8dd14606 | 922 | calibra->AnalyseCH(histogain); |
923 | Int_t nbtg = 6*4*18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb0(0)) | |
924 | + 6* 18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb2(0)); | |
925 | Int_t nbfit = calibra->GetNumberFit(); | |
926 | Int_t nbE = calibra->GetNumberEnt(); | |
927 | // enough statistics | |
928 | if ((nbtg > 0) && | |
4da4a4c8 | 929 | (nbfit >= 0.5*nbE) && (nbE > 30)) { |
8dd14606 | 930 | // create the cal objects |
64942b85 | 931 | calibra->PutMeanValueOtherVectorFit(1,kTRUE); |
8dd14606 | 932 | TObjArray object = calibra->GetVectorFit(); |
413153cb | 933 | AliTRDCalDet *objgaindet = calibra->CreateDetObjectGain(&object); |
6a0417c1 | 934 | // TObject *objgainpad = calibra->CreatePadObjectGain(); |
8dd14606 | 935 | // store them |
936 | if(!Store("Calib","ChamberGainFactor",(TObject *) objgaindet ,&md1,0,kTRUE)){ | |
937 | Log("Error storing the calibration object for the chamber gain"); | |
938 | error = kTRUE; | |
939 | } | |
6a0417c1 | 940 | // if(!Store("Calib","LocalGainFactor" ,(TObject *) objgainpad ,&md2,0,kTRUE)){ |
941 | // Log("Error storing the calibration object for the local gain factor"); | |
942 | // error = kTRUE; | |
943 | // } | |
8dd14606 | 944 | } |
945 | calibra->ResetVectorFit(); | |
946 | }// if histogain | |
947 | ||
8dd14606 | 948 | // vdrift |
949 | fVdriftHLT = kFALSE; | |
950 | TProfile2D *histodriftvelocity = (TProfile2D *) filehlt->Get("PH2d"); | |
8dd14606 | 951 | if (histodriftvelocity) { |
7172a9fa | 952 | histodriftvelocity->SetDirectory(0); |
8dd14606 | 953 | // store the reference data |
954 | if(!StoreReferenceData("HLTData","VdriftT0",(TObject *) histodriftvelocity,&metaData)){ | |
955 | Log("Error storing 2D Profile for average pulse height (HLT)"); | |
956 | error = kTRUE; | |
957 | } | |
958 | // analyse | |
959 | Log("Take the PH reference data. Now we will try to fit\n"); | |
64942b85 | 960 | calibra->SetMinEntries(800*20); // If there is less than 20000 |
8dd14606 | 961 | calibra->AnalysePH(histodriftvelocity); |
962 | Int_t nbtg = 6*4*18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb0(1)) | |
963 | + 6* 18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb2(1)); | |
964 | Int_t nbfit = calibra->GetNumberFit(); | |
6aafa7ea | 965 | Int_t nbfitSuccess = calibra->GetNumberFitSuccess(); |
8dd14606 | 966 | Int_t nbE = calibra->GetNumberEnt(); |
967 | // enough statistics | |
968 | if ((nbtg > 0) && | |
6aafa7ea | 969 | (nbfit >= 0.5*nbE) && (nbE > 30) && (nbfitSuccess > 30)) { |
8dd14606 | 970 | // create the cal objects |
6aafa7ea | 971 | calibra->RemoveOutliers(1,kTRUE); |
64942b85 | 972 | calibra->PutMeanValueOtherVectorFit(1,kTRUE); |
6aafa7ea | 973 | calibra->RemoveOutliers2(kTRUE); |
64942b85 | 974 | calibra->PutMeanValueOtherVectorFit2(1,kTRUE); |
8dd14606 | 975 | TObjArray object = calibra->GetVectorFit(); |
976 | AliTRDCalDet *objdriftvelocitydet = calibra->CreateDetObjectVdrift(&object,kTRUE); | |
6a0417c1 | 977 | // TObject *objdriftvelocitypad = calibra->CreatePadObjectVdrift(); |
8dd14606 | 978 | object = calibra->GetVectorFit2(); |
979 | AliTRDCalDet *objtime0det = calibra->CreateDetObjectT0(&object,kTRUE); | |
79b38efd | 980 | //TObject *objtime0pad = calibra->CreatePadObjectT0(); |
8dd14606 | 981 | // store them |
982 | if(!Store("Calib","ChamberVdrift" ,(TObject *) objdriftvelocitydet,&md1,0,kTRUE)){ | |
983 | Log("Error storing the calibration object for the chamber vdrift (HLT)"); | |
984 | error = kTRUE; | |
985 | } | |
986 | if(!Store("Calib","ChamberT0" ,(TObject *) objtime0det ,&md1,0,kTRUE)){ | |
987 | Log("Error storing the calibration object for the chamber t0 (HLT)"); | |
988 | error = kTRUE; | |
989 | } | |
6a0417c1 | 990 | // if(!Store("Calib","LocalVdrift" ,(TObject *) objdriftvelocitypad,&md2,0,kTRUE)){ |
991 | // Log("Error storing the calibration object for the local drift velocity (HLT)"); | |
992 | // error = kTRUE; | |
993 | // } | |
994 | // if(!Store("Calib","LocalT0" ,(TObject *) objtime0pad ,&md2,0,kTRUE)){ | |
995 | // Log("Error storing the calibration object for the local time0 (HLT)"); | |
996 | // error = kTRUE; | |
997 | // } | |
8dd14606 | 998 | fVdriftHLT = kTRUE; |
999 | } | |
1000 | calibra->ResetVectorFit(); | |
1001 | }// if TProfile2D | |
1002 | ||
8dd14606 | 1003 | // prf |
1004 | TProfile2D *histoprf = (TProfile2D *) filehlt->Get("PRF2d"); | |
8dd14606 | 1005 | if (histoprf) { |
7172a9fa | 1006 | histoprf->SetDirectory(0); |
8dd14606 | 1007 | // store reference data |
1008 | if(!StoreReferenceData("HLTData","PRF",(TObject *) histoprf,&metaData)){ | |
1009 | Log("Error storing the 2D Profile for Pad Response Function"); | |
1010 | error = kTRUE; | |
1011 | } | |
1012 | // analyse | |
1013 | Log("Take the PRF reference data. Now we will try to fit\n"); | |
1014 | calibra->SetMinEntries(600); // If there is less than 20000 | |
1015 | calibra->AnalysePRFMarianFit(histoprf); | |
1016 | Int_t nbtg = 6*4*18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb0(2)) | |
1017 | + 6* 18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb2(2)); | |
1018 | Int_t nbfit = calibra->GetNumberFit(); | |
1019 | Int_t nbE = calibra->GetNumberEnt(); | |
1020 | // enough statistics | |
1021 | if ((nbtg > 0) && | |
4da4a4c8 | 1022 | (nbfit >= 0.95*nbE) && (nbE > 30)) { |
8dd14606 | 1023 | // create cal pad objects |
1024 | TObjArray object = calibra->GetVectorFit(); | |
1025 | TObject *objPRFpad = calibra->CreatePadObjectPRF(&object); | |
1026 | // store them | |
1027 | if(!Store("Calib","PRFWidth" ,(TObject *) objPRFpad ,&md2,0,kTRUE)){ | |
1028 | Log("Error storing the calibration object for the Pad Response Function"); | |
1029 | error = kTRUE; | |
1030 | } | |
1031 | } | |
1032 | calibra->ResetVectorFit(); | |
1033 | }// if PRF | |
1034 | }// if fileNameEntry | |
1035 | ||
1036 | delete listhlt; | |
1037 | return error; | |
1038 | ||
e5c60cc7 | 1039 | } |
fdfee371 | 1040 | |
1041 | //_____________________________________________________________________________ | |
1042 | UInt_t AliTRDPreprocessor::ProcessDCSConfigData() | |
1043 | { | |
1044 | // | |
1045 | // process the configuration of FEE, PTR and GTU | |
e74c968f | 1046 | // reteive XML filei(s) from the DCS FXS |
1047 | // parse it/them and store TObjArrays in the CDB | |
1048 | // | |
fdfee371 | 1049 | // return 0 for success, otherwise: |
8b9bf3e9 | 1050 | // 5 : Could not get the (SOR and EOR) or SOR file from the FXS |
8f7e6c0b | 1051 | // 8 : Both files are not valid |
eaceaf51 | 1052 | // 10 : SOR XML is not well-formed |
1053 | // 11 : EOR XML is not well-formed | |
8f7e6c0b | 1054 | // 12 : ERROR in SOR XML SAX validation: something wrong with the content |
1055 | // 12 : ERROR in EOR XML SAX validation: something wrong with the content | |
1056 | // 14 : ERROR while creating SOR calibration objects in the handler | |
1057 | // 15 : ERROR while creating EOR calibration objects in the handler | |
1058 | // 16 : ERROR while storing data in the CDB | |
fdfee371 | 1059 | // |
1060 | ||
eaceaf51 | 1061 | Log("Processing the DCS config summary files."); |
fdfee371 | 1062 | |
e74c968f | 1063 | // get the XML files |
1064 | Log("Requesting the 2 summaryfiles from the FXS.."); | |
8b9bf3e9 | 1065 | TString xmlFileS = GetFile(kDCS,"CONFIGSUMMARYSOR",""); |
1066 | TString xmlFileE = GetFile(kDCS,"CONFIGSUMMARYEOR",""); | |
3821ce70 | 1067 | // Request EOR and SOR files from the fxs, if both are not found exit |
1068 | ||
f4200e67 | 1069 | Bool_t fileExistE = kTRUE, fileExistS = kTRUE; |
3821ce70 | 1070 | |
8f7e6c0b | 1071 | // check if the files are there |
8b9bf3e9 | 1072 | if (xmlFileS.IsNull()) { |
1073 | Log(Form("Warning: SOR file %s not found!", xmlFileS.Data())); | |
f4200e67 | 1074 | fileExistS = kFALSE; |
8b9bf3e9 | 1075 | } else Log(Form("SOR file found: %s", xmlFileS.Data())); |
f4200e67 | 1076 | |
8b9bf3e9 | 1077 | if (xmlFileE.IsNull()) { |
1078 | Log(Form("Warning: EOR file %s not found!", xmlFileE.Data())); | |
f4200e67 | 1079 | fileExistE = kFALSE; |
8b9bf3e9 | 1080 | } else Log(Form("EOR file found: %s", xmlFileE.Data())); |
f4200e67 | 1081 | |
1082 | if (fileExistS==0 && fileExistE==0) { | |
8b9bf3e9 | 1083 | Log(Form("ERROR: SOR and EOR files not found: %s and %s", xmlFileS.Data(), xmlFileE.Data())); |
f4200e67 | 1084 | return 5; |
6b36d985 | 1085 | } |
3821ce70 | 1086 | |
8f7e6c0b | 1087 | // test the files |
3821ce70 | 1088 | if (fileExistS) { |
f4200e67 | 1089 | Log("Checking if SOR file is valid."); |
3821ce70 | 1090 | std::ifstream fileTestS; |
8b9bf3e9 | 1091 | fileTestS.open(xmlFileS.Data(), std::ios_base::binary | std::ios_base::in); |
3821ce70 | 1092 | if (!fileTestS.good() || fileTestS.eof() || !fileTestS.is_open()) { |
8b9bf3e9 | 1093 | Log(Form("Warning: File %s not valid!",xmlFileS.Data())); |
f4200e67 | 1094 | fileExistS = kFALSE; |
8b9bf3e9 | 1095 | return 5; |
3821ce70 | 1096 | } |
f4200e67 | 1097 | Log("Checking if SOR file is not empty."); |
3821ce70 | 1098 | fileTestS.seekg(0, std::ios_base::end); |
1099 | if (static_cast<int>(fileTestS.tellg()) < 2) { | |
8b9bf3e9 | 1100 | Log(Form("Warning: File %s is empty!",xmlFileS.Data())); |
f4200e67 | 1101 | fileExistS = kFALSE; |
8b9bf3e9 | 1102 | return 5; |
3821ce70 | 1103 | } |
1104 | } | |
f4200e67 | 1105 | |
f4200e67 | 1106 | |
3821ce70 | 1107 | if (fileExistE) { |
f4200e67 | 1108 | Log("Checking if EOR file is valid."); |
3821ce70 | 1109 | std::ifstream fileTestE; |
8b9bf3e9 | 1110 | fileTestE.open(xmlFileE.Data(), std::ios_base::binary | std::ios_base::in); |
3821ce70 | 1111 | if (!fileTestE.good() || fileTestE.eof() || !fileTestE.is_open()) { |
8b9bf3e9 | 1112 | Log(Form("Warning: File %s not valid!",xmlFileE.Data())); |
f4200e67 | 1113 | fileExistE = kFALSE; |
3821ce70 | 1114 | } |
f4200e67 | 1115 | Log("Checking if EOR file is not empty."); |
3821ce70 | 1116 | fileTestE.seekg(0, std::ios_base::end); |
1117 | if (static_cast<int>(fileTestE.tellg()) < 2) { | |
8b9bf3e9 | 1118 | Log(Form("Warning: File %s is empty!",xmlFileE.Data())); |
f4200e67 | 1119 | fileExistE = kFALSE; |
3821ce70 | 1120 | } |
1121 | } | |
f4200e67 | 1122 | |
f4200e67 | 1123 | if (fileExistS==0 && fileExistE==0) { |
8f7e6c0b | 1124 | Log("ERROR: Both files (SOR/EOR) are not valid!"); |
1125 | return 8; | |
1126 | } | |
f4200e67 | 1127 | |
8f7e6c0b | 1128 | Log("One or both of the tested files are valid."); |
fdfee371 | 1129 | |
6b36d985 | 1130 | // make a robust XML validation |
1131 | TSAXParser testParser; | |
8b9bf3e9 | 1132 | if (fileExistS && testParser.ParseFile(xmlFileS.Data()) < 0 ) { |
eaceaf51 | 1133 | Log("ERROR: XML content (SOR) is not well-formed."); |
e74c968f | 1134 | return 10; |
8b9bf3e9 | 1135 | } else if (fileExistE && testParser.ParseFile(xmlFileE.Data()) < 0 ) { |
eaceaf51 | 1136 | Log("ERROR: XML content (EOR) is not well-formed."); |
1137 | return 11; | |
6b36d985 | 1138 | } |
eaceaf51 | 1139 | Log("XML contents are well-formed."); |
3821ce70 | 1140 | |
fdfee371 | 1141 | // create parser and parse |
eaceaf51 | 1142 | TSAXParser saxParserS, saxParserE; |
1143 | AliTRDSaxHandler saxHandlerS, saxHandlerE; | |
3821ce70 | 1144 | if (fileExistS) { |
1145 | saxParserS.ConnectToHandler("AliTRDSaxHandler", &saxHandlerS); | |
8b9bf3e9 | 1146 | saxParserS.ParseFile(xmlFileS.Data()); |
3821ce70 | 1147 | } |
1148 | if (fileExistE) { | |
1149 | saxParserE.ConnectToHandler("AliTRDSaxHandler", &saxHandlerE); | |
8b9bf3e9 | 1150 | saxParserE.ParseFile(xmlFileE.Data()); |
3821ce70 | 1151 | } |
8f7e6c0b | 1152 | // report errors of the parser if present |
1153 | if (fileExistS && saxParserS.GetParseCode() != 0) { | |
9258bcf0 | 1154 | Log(Form("ERROR in XML file validation. SOR Parse Code: %d", saxParserS.GetParseCode())); |
e74c968f | 1155 | return 12; |
fdfee371 | 1156 | } |
8f7e6c0b | 1157 | if (fileExistE && saxParserE.GetParseCode() != 0) { |
9258bcf0 | 1158 | Log(Form("ERROR in XML file validation. EOR Parse Code: %d", saxParserE.GetParseCode())); |
8f7e6c0b | 1159 | return 13; |
fdfee371 | 1160 | } |
8f7e6c0b | 1161 | Log("XML file validation OK."); |
1162 | // report errors of the handler if present | |
1163 | if (fileExistS && saxHandlerS.GetHandlerStatus() != 0) { | |
9258bcf0 | 1164 | Log(Form("ERROR while creating calibration objects. SOR Error code: %d", saxHandlerS.GetHandlerStatus())); |
8f7e6c0b | 1165 | return 14; |
1166 | } | |
1167 | if (fileExistE && saxHandlerE.GetHandlerStatus() != 0) { | |
9258bcf0 | 1168 | Log(Form("ERROR while creating calibration objects. EOR Error code: %d", saxHandlerE.GetHandlerStatus())); |
8f7e6c0b | 1169 | return 15; |
1170 | } | |
1171 | Log("SAX handler reports no errors."); | |
fdfee371 | 1172 | |
eaceaf51 | 1173 | // put both objects in one TObjArray to store them |
6a0417c1 | 1174 | TObjArray* calObjArray = new TObjArray(2); |
1175 | calObjArray->SetOwner(); | |
3821ce70 | 1176 | |
1177 | // get the calibration object storing the data from the handler | |
1178 | if (fileExistS) { | |
6a0417c1 | 1179 | if(fCalDCSObjSOR) delete fCalDCSObjSOR; |
1180 | fCalDCSObjSOR = (AliTRDCalDCS *) saxHandlerS.GetCalDCSObj()->Clone(); | |
3821ce70 | 1181 | fCalDCSObjSOR->EvaluateGlobalParameters(); |
8f7e6c0b | 1182 | fCalDCSObjSOR->SetRunType(GetRunType()); |
1183 | fCalDCSObjSOR->SetStartTime(GetStartTimeDCSQuery()); | |
1184 | fCalDCSObjSOR->SetEndTime(GetEndTimeDCSQuery()); | |
6a0417c1 | 1185 | calObjArray->AddAt(fCalDCSObjSOR,0); |
8f7e6c0b | 1186 | Log("TRDCalDCS object for SOR created."); |
3821ce70 | 1187 | } |
1188 | ||
1189 | if (fileExistE) { | |
6a0417c1 | 1190 | if(fCalDCSObjEOR) delete fCalDCSObjEOR; |
1191 | fCalDCSObjEOR = (AliTRDCalDCS *) saxHandlerE.GetCalDCSObj()->Clone(); | |
3821ce70 | 1192 | fCalDCSObjEOR->EvaluateGlobalParameters(); |
8f7e6c0b | 1193 | fCalDCSObjEOR->SetRunType(GetRunType()); |
1194 | fCalDCSObjEOR->SetStartTime(GetStartTimeDCSQuery()); | |
1195 | fCalDCSObjEOR->SetEndTime(GetEndTimeDCSQuery()); | |
6a0417c1 | 1196 | calObjArray->AddAt(fCalDCSObjEOR,1); |
8f7e6c0b | 1197 | Log("TRDCalDCS object for EOR created."); |
6a0417c1 | 1198 | // printf("globalnumberoftimebins %d \n",fCalDCSObjEOR->GetGlobalNumberOfTimeBins()); |
3821ce70 | 1199 | } |
1200 | ||
6a0417c1 | 1201 | |
1202 | ||
fdfee371 | 1203 | // store the DCS calib data in the CDB |
1204 | AliCDBMetaData metaData1; | |
1205 | metaData1.SetBeamPeriod(0); | |
1206 | metaData1.SetResponsible("Frederick Kramer"); | |
eaceaf51 | 1207 | metaData1.SetComment("DCS configuration data in two AliTRDCalDCS objects in one TObjArray (0:SOR, 1:EOR)."); |
6a0417c1 | 1208 | if (!Store("Calib", "DCS", calObjArray, &metaData1, 0, kTRUE)) { |
fdfee371 | 1209 | Log("problems while storing DCS config data object"); |
8f7e6c0b | 1210 | return 16; |
6b36d985 | 1211 | } else { |
1212 | Log("DCS config data object stored."); | |
fdfee371 | 1213 | } |
1214 | ||
6a0417c1 | 1215 | //delete calObjArray; |
6b36d985 | 1216 | |
8f7e6c0b | 1217 | Log("SUCCESS: Processing of the DCS config summary file DONE."); |
fdfee371 | 1218 | return 0; |
75ba22eb | 1219 | } |
1220 | ||
1221 | ||
7172a9fa | 1222 | |
6a0417c1 | 1223 |