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