]>
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 | ||
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) { | |
d6a1ec13 | 380 | calPed->CheckEORStatus((AliTRDCalDCSv2 *)fCalDCSObjEOR); |
6a0417c1 | 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 | ||
456 | // analyse | |
289cc637 | 457 | //calPed->AnalyseHisto(); |
458 | ||
459 | // Add to the calPedSum | |
460 | for (Int_t idet=0; idet<540; idet++) { | |
461 | AliTRDCalROC *rocMean = calPed->GetCalRocMean(idet, kFALSE); | |
462 | if ( rocMean ) { | |
463 | calPedSum.SetCalRocMean(rocMean,idet); | |
289cc637 | 464 | } |
465 | AliTRDCalROC *rocRMS = calPed->GetCalRocRMS(idet, kFALSE); | |
466 | if ( rocRMS ) { | |
467 | calPedSum.SetCalRocRMS(rocRMS,idet); | |
468 | } | |
e4db522f | 469 | AliTRDCalROC *rocMeand = calPed->GetCalRocMeand(idet, kFALSE); |
470 | if ( rocMeand ) { | |
471 | calPedSum.SetCalRocMeand(rocMeand,idet); | |
472 | } | |
473 | AliTRDCalROC *rocRMSd = calPed->GetCalRocRMSd(idet, kFALSE); | |
474 | if ( rocRMSd ) { | |
475 | calPedSum.SetCalRocRMSd(rocRMSd,idet); | |
476 | } | |
289cc637 | 477 | }// det loop |
478 | ||
8dd14606 | 479 | // store as reference data |
480 | TString name("PadStatus"); | |
373e138c | 481 | name += index; |
8dd14606 | 482 | if(!StoreReferenceData("DAQData",(const char *)name,(TObject *) calPed,&metaData)){ |
483 | Log(Form("Error storing AliTRDCalibPadStatus object %d as reference data",(Int_t)index)); | |
484 | error = kTRUE; | |
485 | } | |
289cc637 | 486 | |
8dd14606 | 487 | } // calPed |
488 | } // fileNameEntry | |
489 | ++index; | |
490 | }// while (list) | |
c8ab4518 | 491 | |
8dd14606 | 492 | Log(Form("%d elements found in the list for the pedestal",(Int_t)index)); |
493 | if(index==0){ | |
6ace5fe2 | 494 | delete listpad; |
8dd14606 | 495 | return kTRUE; |
6ace5fe2 | 496 | } |
c8ab4518 | 497 | |
8dd14606 | 498 | // |
5029ad25 | 499 | // Create pedestal |
8dd14606 | 500 | // |
c8ab4518 | 501 | |
8dd14606 | 502 | // Create Pad Status |
503 | AliTRDCalPadStatus *calPadStatus = calPedSum.CreateCalPadStatus(); | |
5029ad25 | 504 | // Create Noise |
505 | //Make the AliTRDCalPad | |
506 | AliTRDCalPad *calPad2 = calPedSum.CreateCalPad(); | |
507 | //Make the AliTRDCalDet correspondant | |
508 | AliTRDCalDet *calDet = calPedSum.CreateCalDet(); | |
509 | ||
510 | // | |
511 | // Take the noise and Pad status from the previous OCDB | |
512 | // | |
513 | ||
514 | AliTRDCalPad *calPadPrevious=0; | |
515 | AliCDBEntry* entry = GetFromOCDB("Calib", "PadNoise"); | |
516 | if (entry) calPadPrevious = (AliTRDCalPad*)entry->GetObject(); | |
517 | if ( calPadPrevious==NULL ) { | |
518 | Log("AliTRDPreprocsessor: No previous TRD pad noise entry available.\n"); | |
519 | calPadPrevious = new AliTRDCalPad("PadNoise", "PadNoise"); | |
520 | } | |
521 | ||
522 | AliTRDCalPadStatus *calPadStatusPrevious=0; | |
523 | entry = GetFromOCDB("Calib", "PadStatus"); | |
524 | if (entry) calPadStatusPrevious = (AliTRDCalPadStatus*)entry->GetObject(); | |
525 | if ( calPadStatusPrevious==NULL ) { | |
526 | Log("AliTRDPreprocsessor: No previous TRD pad status entry available.\n"); | |
527 | calPadStatusPrevious = new AliTRDCalPadStatus("padstatus", "padstatus"); | |
528 | for (Int_t idet=0; idet<540; ++idet) | |
529 | { | |
530 | AliTRDCalSingleChamberStatus *calROC = calPadStatusPrevious->GetCalROC(idet); | |
531 | for(Int_t k = 0; k < calROC->GetNchannels(); k++){ | |
532 | calROC->SetStatus(k,AliTRDCalPadStatus::kMasked); | |
533 | } | |
534 | } | |
535 | } | |
536 | ||
537 | ||
538 | // Loop over detectors for check | |
539 | for (Int_t det=0; det<AliTRDgeometry::kNdet; ++det) { | |
540 | ||
541 | // noise | |
542 | AliTRDCalROC *calROCPreviousNoise = calPadPrevious->GetCalROC(det); | |
543 | AliTRDCalROC *calROCNoise = calPad2->GetCalROC(det); | |
544 | ||
545 | // padstatus | |
546 | AliTRDCalSingleChamberStatus *calROCPreviousStatus = calPadStatusPrevious->GetCalROC(det); | |
547 | AliTRDCalSingleChamberStatus *calROCStatus = calPadStatus->GetCalROC(det); | |
548 | ||
549 | ||
550 | // loop over first half and second half chamber | |
551 | for(Int_t half = 0; half < 2; half++){ | |
552 | ||
553 | Bool_t data = AreThereDataPedestal(calROCStatus,(Bool_t)half); | |
37b0cf5e | 554 | //printf("There are data for the detector %d the half %d: %d\n",det,half,data); |
5029ad25 | 555 | if(!data){ |
556 | // look if data in the OCDB | |
557 | Bool_t dataPrevious = AreThereDataPedestal(calROCPreviousStatus,(Bool_t)half); | |
558 | // if no data at all, set to default value | |
559 | if(!dataPrevious){ | |
560 | SetDefaultStatus(*calROCStatus,(Bool_t)half); | |
561 | SetDefaultNoise(*calROCNoise,(Bool_t)half); | |
562 | } | |
563 | else{ | |
564 | // if data, set to previous value | |
565 | SetStatus(*calROCStatus,calROCPreviousStatus,(Bool_t)half); | |
566 | SetNoise(*calROCNoise,calROCPreviousNoise,(Bool_t)half); | |
567 | } | |
568 | } | |
569 | } | |
570 | } | |
571 | ||
572 | // | |
573 | // Store | |
574 | // | |
575 | ||
8dd14606 | 576 | AliCDBMetaData md3; |
577 | md3.SetObjectClassName("AliTRDCalPadStatus"); | |
578 | md3.SetResponsible("Raphaelle Bailhache"); | |
579 | md3.SetBeamPeriod(1); | |
580 | md3.SetComment("TRD calib test"); | |
581 | if(!Store("Calib","PadStatus" ,(TObject *)calPadStatus, &md3, 0, kTRUE)){ | |
582 | Log("Error storing the pedestal"); | |
583 | delete listpad; | |
584 | return kTRUE; | |
a5e1169e | 585 | } |
289cc637 | 586 | |
289cc637 | 587 | AliCDBMetaData md4; |
588 | md4.SetObjectClassName("AliTRDCalPad"); | |
589 | md4.SetResponsible("Raphaelle Bailhache"); | |
590 | md4.SetBeamPeriod(1); | |
591 | md4.SetComment("TRD calib test"); | |
592 | if(!Store("Calib","PadNoise" ,(TObject *)calPad2, &md4, 0, kTRUE)){ | |
593 | Log("Error storing the pedestal"); | |
594 | delete listpad; | |
595 | return kTRUE; | |
596 | } | |
5029ad25 | 597 | |
289cc637 | 598 | AliCDBMetaData md5; |
599 | md5.SetObjectClassName("AliTRDCalDet"); | |
600 | md5.SetResponsible("Raphaelle Bailhache"); | |
601 | md5.SetBeamPeriod(1); | |
602 | md5.SetComment("TRD calib test"); | |
603 | if(!Store("Calib","DetNoise" ,(TObject *)calDet, &md5, 0, kTRUE)){ | |
604 | Log("Error storing the pedestal"); | |
605 | delete listpad; | |
606 | return kTRUE; | |
607 | } | |
608 | ||
8dd14606 | 609 | delete listpad; |
610 | return error; | |
5029ad25 | 611 | |
612 | } | |
c893147d | 613 | |
5029ad25 | 614 | //__________________________________________________________________ |
c893147d | 615 | Bool_t AliTRDPreprocessor::AreThereDataPedestal(AliTRDCalSingleChamberStatus * const calROCStatus |
616 | , Bool_t second) | |
617 | { | |
a5e1169e | 618 | |
5029ad25 | 619 | // |
620 | // Data for this half chamber | |
621 | // | |
622 | ||
623 | Bool_t data = kFALSE; | |
624 | Int_t nCols = calROCStatus->GetNcols(); | |
625 | Int_t nCol0 = 0; | |
626 | Int_t nColE = (Int_t) nCols/2 - 2; | |
627 | if(second) { | |
628 | nCol0 = nColE + 4; | |
629 | nColE = nCols; | |
630 | } | |
f2a468d7 | 631 | |
632 | Int_t totalnumberofpads = 0; | |
633 | Int_t totalnumberofdata = 0; | |
634 | ||
5029ad25 | 635 | for(Int_t col = nCol0; col < nColE; col++){ |
636 | for(Int_t row = 0; row < calROCStatus->GetNrows(); row++){ | |
f2a468d7 | 637 | totalnumberofpads++; |
5029ad25 | 638 | //printf("ismasked %d\n",(Int_t)calROCStatus->IsMasked(col,row)); |
37b0cf5e | 639 | if(!calROCStatus->GetStatus(col,row)) { |
5029ad25 | 640 | data = kTRUE; |
f2a468d7 | 641 | totalnumberofdata++; |
5029ad25 | 642 | } |
643 | } | |
5029ad25 | 644 | } |
f2a468d7 | 645 | if(totalnumberofdata < (Int_t)(totalnumberofpads/2)) data = kFALSE; |
5029ad25 | 646 | |
647 | return data; | |
648 | ||
649 | } | |
650 | //__________________________________________________________________ | |
651 | void AliTRDPreprocessor::SetDefaultStatus(AliTRDCalSingleChamberStatus &calROCStatus, Bool_t second){ | |
652 | ||
653 | // | |
654 | // default status for this half chamber | |
655 | // | |
656 | ||
657 | Int_t nCols = calROCStatus.GetNcols(); | |
658 | Int_t nCol0 = 0; | |
659 | Int_t nColE = (Int_t) nCols/2; | |
660 | if(second) { | |
661 | nCol0 = nColE; | |
662 | nColE = nCols; | |
663 | } | |
664 | for(Int_t col = nCol0; col < nColE; col++){ | |
665 | for(Int_t row = 0; row < calROCStatus.GetNrows(); row++){ | |
666 | calROCStatus.SetStatus(col,row,0); | |
667 | } | |
668 | } | |
669 | } | |
670 | //__________________________________________________________________ | |
671 | void AliTRDPreprocessor::SetStatus(AliTRDCalSingleChamberStatus &calROCStatus, AliTRDCalSingleChamberStatus *calROCStatusPrevious,Bool_t second){ | |
672 | ||
673 | // | |
674 | // previous status for this half chamber | |
675 | // | |
676 | ||
677 | Int_t nCols = calROCStatus.GetNcols(); | |
678 | Int_t nCol0 = 0; | |
679 | Int_t nColE = (Int_t) nCols/2; | |
680 | if(second) { | |
681 | nCol0 = nColE; | |
682 | nColE = nCols; | |
683 | } | |
684 | for(Int_t col = nCol0; col < nColE; col++){ | |
685 | for(Int_t row = 0; row < calROCStatus.GetNrows(); row++){ | |
686 | calROCStatus.SetStatus(col,row,calROCStatusPrevious->GetStatus(col,row)); | |
687 | } | |
688 | } | |
6ace5fe2 | 689 | } |
5029ad25 | 690 | //__________________________________________________________________ |
691 | void AliTRDPreprocessor::SetDefaultNoise(AliTRDCalROC &calROCNoise, Bool_t second){ | |
692 | ||
693 | // | |
694 | // default noise for this half chamber | |
695 | // | |
c8ab4518 | 696 | |
5029ad25 | 697 | Int_t nCols = calROCNoise.GetNcols(); |
698 | Int_t nCol0 = 0; | |
699 | Int_t nColE = (Int_t) nCols/2; | |
700 | if(second) { | |
701 | nCol0 = nColE; | |
702 | nColE = nCols; | |
703 | } | |
704 | for(Int_t col = nCol0; col < nColE; col++){ | |
705 | for(Int_t row = 0; row < calROCNoise.GetNrows(); row++){ | |
706 | calROCNoise.SetValue(col,row,0.12); | |
707 | } | |
708 | } | |
709 | } | |
710 | //__________________________________________________________________ | |
711 | void AliTRDPreprocessor::SetNoise(AliTRDCalROC &calROCNoise, AliTRDCalROC *calROCNoisePrevious, Bool_t second){ | |
712 | ||
713 | // | |
714 | // previous noise for this half chamber | |
715 | // | |
716 | ||
717 | Int_t nCols = calROCNoise.GetNcols(); | |
718 | Int_t nCol0 = 0; | |
719 | Int_t nColE = (Int_t) nCols/2; | |
720 | if(second) { | |
721 | nCol0 = nColE; | |
722 | nColE = nCols; | |
723 | } | |
724 | for(Int_t col = nCol0; col < nColE; col++){ | |
725 | for(Int_t row = 0; row < calROCNoise.GetNrows(); row++){ | |
726 | calROCNoise.SetValue(col,row,calROCNoisePrevious->GetValue(col,row)); | |
727 | } | |
728 | } | |
729 | } | |
6ace5fe2 | 730 | //______________________________________________________________________________________________ |
8dd14606 | 731 | Bool_t AliTRDPreprocessor::ExtractDriftVelocityDAQ() |
6ace5fe2 | 732 | { |
e5c60cc7 | 733 | // |
6ace5fe2 | 734 | // Drift velocity DA running on monitoring servers at the DAQ |
e5c60cc7 | 735 | // |
736 | ||
8dd14606 | 737 | Bool_t error = kFALSE; |
6ace5fe2 | 738 | |
739 | // Objects for HLT and DAQ zusammen | |
3a0f6479 | 740 | AliTRDCalibraFit *calibra = AliTRDCalibraFit::Instance(); |
6ace5fe2 | 741 | AliCDBMetaData metaData; |
742 | metaData.SetBeamPeriod(0); | |
743 | metaData.SetResponsible("Raphaelle Bailhache"); | |
744 | metaData.SetComment("TRD calib test"); | |
3a0f6479 | 745 | // Store the infos for the detector |
6ace5fe2 | 746 | AliCDBMetaData md1; |
747 | md1.SetObjectClassName("AliTRDCalDet"); | |
748 | md1.SetResponsible("Raphaelle Bailhache"); | |
749 | md1.SetBeamPeriod(0); | |
750 | md1.SetComment("TRD calib test"); | |
3a0f6479 | 751 | // Store the infos for the pads |
6ace5fe2 | 752 | AliCDBMetaData md2; |
753 | md2.SetObjectClassName("AliTRDCalPad"); | |
754 | md2.SetResponsible("Raphaelle Bailhache"); | |
755 | md2.SetBeamPeriod(0); | |
756 | md2.SetComment("TRD calib test"); | |
3a0f6479 | 757 | |
6ace5fe2 | 758 | // Take the file from the DAQ file exchange server |
759 | TList *listdaq = GetFileSources(kDAQ,"VDRIFT"); | |
8dd14606 | 760 | if (!listdaq) { |
6ace5fe2 | 761 | Log("No list found for vdrift (DAQ)"); |
8dd14606 | 762 | return kTRUE; |
763 | } | |
764 | ||
765 | if(listdaq->GetSize() !=1){ | |
766 | Log(Form("Problem on the size of the list: %d (DAQ)",listdaq->GetSize())); | |
767 | delete listdaq; | |
768 | return kTRUE; | |
6ace5fe2 | 769 | } |
8dd14606 | 770 | |
771 | TObjString* fileNameEntry = (TObjString*) listdaq->At(0); | |
772 | if(fileNameEntry != NULL){ | |
773 | TString fileName = GetFile(kDAQ, "VDRIFT", | |
774 | fileNameEntry->GetString().Data()); | |
775 | if(fileName.Length() ==0){ | |
776 | Log("Error retrieving the file vdrift (DAQ)"); | |
777 | delete listdaq; | |
778 | return kTRUE; | |
779 | } | |
780 | TFile *filedaq = TFile::Open(fileName); | |
781 | TProfile2D *histodriftvelocity = (TProfile2D *) filedaq->Get("PH2d"); | |
782 | if (histodriftvelocity) { | |
783 | ||
784 | // store as reference data | |
785 | if(!StoreReferenceData("DAQData","VdriftT0",(TObject *) histodriftvelocity,&metaData)){ | |
786 | Log("Error storing 2D Profile for vdrift from the DAQ"); | |
787 | error = kTRUE; | |
788 | } | |
789 | ||
790 | // analyse | |
791 | ||
792 | Log("Take the PH reference data. Now we will try to fit\n"); | |
793 | calibra->SetMinEntries(2000); // If there is less than 2000 | |
794 | calibra->AnalysePH(histodriftvelocity); | |
795 | ||
796 | Int_t nbtg = 6*4*18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb0(1)) | |
797 | + 6* 18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb2(1)); | |
798 | Int_t nbfit = calibra->GetNumberFit(); | |
6aafa7ea | 799 | Int_t nbfitSuccess = calibra->GetNumberFitSuccess(); |
8dd14606 | 800 | Int_t nbE = calibra->GetNumberEnt(); |
801 | ||
802 | // if enough statistics store the results | |
803 | if ((nbtg > 0) && | |
6aafa7ea | 804 | (nbfit >= 0.5*nbE) && (nbE > 30) && (nbfitSuccess > 30)) { |
8dd14606 | 805 | // create the cal objects |
6aafa7ea | 806 | calibra->RemoveOutliers(1,kTRUE); |
64942b85 | 807 | calibra->PutMeanValueOtherVectorFit(1,kTRUE); |
6aafa7ea | 808 | calibra->RemoveOutliers2(kTRUE); |
64942b85 | 809 | calibra->PutMeanValueOtherVectorFit2(1,kTRUE); |
8dd14606 | 810 | TObjArray object = calibra->GetVectorFit(); |
811 | AliTRDCalDet *objdriftvelocitydet = calibra->CreateDetObjectVdrift(&object,kTRUE); | |
6a0417c1 | 812 | // TObject *objdriftvelocitypad = calibra->CreatePadObjectVdrift(); |
8dd14606 | 813 | object = calibra->GetVectorFit2(); |
814 | AliTRDCalDet *objtime0det = calibra->CreateDetObjectT0(&object,kTRUE); | |
6a0417c1 | 815 | // TObject *objtime0pad = calibra->CreatePadObjectT0(); |
8dd14606 | 816 | calibra->ResetVectorFit(); |
817 | // store | |
6a0417c1 | 818 | if(!Store("Calib","ChamberVdrift" ,(TObject *) objdriftvelocitydet,&md1,0,kTRUE)){ |
819 | Log("Error storing the calibration object for the chamber vdrift (DAQ)"); | |
820 | error = kTRUE; | |
821 | } | |
822 | if(!Store("Calib","ChamberT0" ,(TObject *) objtime0det ,&md1,0,kTRUE)){ | |
823 | Log("Error storing the calibration object for the chamber t0 (DAQ)"); | |
824 | error = kTRUE; | |
825 | } | |
826 | // if(!Store("Calib","LocalVdrift" ,(TObject *) objdriftvelocitypad,&md2,0,kTRUE)){ | |
827 | // Log("Error storing the calibration object for the local drift velocity (DAQ)"); | |
828 | // error = kTRUE; | |
829 | // } | |
830 | // if(!Store("Calib","LocalT0" ,(TObject *) objtime0pad ,&md2,0,kTRUE)){ | |
831 | // Log("Error storing the calibration object for the local time0 (DAQ)"); | |
832 | // error = kTRUE; | |
833 | // } | |
8dd14606 | 834 | } |
835 | else{ | |
836 | Log("Not enough statistics for the average pulse height (DAQ)"); | |
837 | } | |
838 | } // histo here | |
839 | }// if fileNameEntry | |
840 | ||
841 | delete listdaq; | |
842 | return error; | |
843 | ||
6ace5fe2 | 844 | } |
c8ab4518 | 845 | |
6ace5fe2 | 846 | //______________________________________________________________________________________________ |
8dd14606 | 847 | Bool_t AliTRDPreprocessor::ExtractHLT() |
6ace5fe2 | 848 | { |
e5c60cc7 | 849 | // |
6ace5fe2 | 850 | // Gain, vdrift and PRF calibration running on HLT |
f5bb5557 | 851 | // return kTRUE if NULL pointer to the list |
e5c60cc7 | 852 | // |
3a0f6479 | 853 | |
8dd14606 | 854 | Bool_t error = kFALSE; |
855 | ||
6ace5fe2 | 856 | // Objects for HLT and DAQ zusammen |
857 | AliTRDCalibraFit *calibra = AliTRDCalibraFit::Instance(); | |
858 | AliCDBMetaData metaData; | |
859 | metaData.SetBeamPeriod(0); | |
860 | metaData.SetResponsible("Raphaelle Bailhache"); | |
861 | metaData.SetComment("TRD calib test"); | |
862 | // Store the infos for the detector | |
863 | AliCDBMetaData md1; | |
864 | md1.SetObjectClassName("AliTRDCalDet"); | |
865 | md1.SetResponsible("Raphaelle Bailhache"); | |
866 | md1.SetBeamPeriod(0); | |
867 | md1.SetComment("TRD calib test"); | |
868 | // Store the infos for the pads | |
869 | AliCDBMetaData md2; | |
870 | md2.SetObjectClassName("AliTRDCalPad"); | |
871 | md2.SetResponsible("Raphaelle Bailhache"); | |
872 | md2.SetBeamPeriod(0); | |
873 | md2.SetComment("TRD calib test"); | |
6ace5fe2 | 874 | |
875 | // Take the file from the HLT file exchange server | |
876 | TList *listhlt = GetFileSources(kHLT,"GAINDRIFTPRF"); | |
8dd14606 | 877 | if (!listhlt) { |
6ace5fe2 | 878 | Log("No list found for the HLT"); |
8dd14606 | 879 | return kTRUE; |
880 | } | |
881 | ||
882 | if(listhlt->GetSize() != 1) { | |
883 | Log(Form("Problem on the size of the list: %d (HLT)",listhlt->GetSize())); | |
884 | delete listhlt; | |
885 | return kTRUE; | |
6ace5fe2 | 886 | } |
3a0f6479 | 887 | |
8dd14606 | 888 | TObjString* fileNameEntry = (TObjString*) listhlt->At(0); |
889 | if(fileNameEntry != NULL){ | |
890 | TString fileName = GetFile(kHLT, "GAINDRIFTPRF", | |
891 | fileNameEntry->GetString().Data()); | |
892 | if(fileName.Length() ==0){ | |
893 | Log("Error retrieving the file (HLT)"); | |
894 | delete listhlt; | |
895 | return kTRUE; | |
896 | } | |
897 | // Take the file | |
898 | TFile *filehlt = TFile::Open(fileName); | |
899 | ||
8dd14606 | 900 | // gain |
901 | TH2I *histogain = (TH2I *) filehlt->Get("CH2d"); | |
8dd14606 | 902 | if (histogain) { |
7172a9fa | 903 | histogain->SetDirectory(0); |
8dd14606 | 904 | // store the reference data |
905 | if(!StoreReferenceData("HLTData","Gain",(TObject *) histogain,&metaData)){ | |
906 | Log("Error storing 2D histos for gain"); | |
907 | error = kTRUE; | |
908 | } | |
909 | // analyse | |
910 | Log("Take the CH reference data. Now we will try to fit\n"); | |
64942b85 | 911 | calibra->SetMinEntries(800); // If there is less than 1000 entries in the histo: no fit |
8dd14606 | 912 | calibra->AnalyseCH(histogain); |
913 | Int_t nbtg = 6*4*18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb0(0)) | |
914 | + 6* 18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb2(0)); | |
915 | Int_t nbfit = calibra->GetNumberFit(); | |
916 | Int_t nbE = calibra->GetNumberEnt(); | |
917 | // enough statistics | |
918 | if ((nbtg > 0) && | |
4da4a4c8 | 919 | (nbfit >= 0.5*nbE) && (nbE > 30)) { |
8dd14606 | 920 | // create the cal objects |
64942b85 | 921 | calibra->PutMeanValueOtherVectorFit(1,kTRUE); |
8dd14606 | 922 | TObjArray object = calibra->GetVectorFit(); |
413153cb | 923 | AliTRDCalDet *objgaindet = calibra->CreateDetObjectGain(&object); |
6a0417c1 | 924 | // TObject *objgainpad = calibra->CreatePadObjectGain(); |
8dd14606 | 925 | // store them |
926 | if(!Store("Calib","ChamberGainFactor",(TObject *) objgaindet ,&md1,0,kTRUE)){ | |
927 | Log("Error storing the calibration object for the chamber gain"); | |
928 | error = kTRUE; | |
929 | } | |
6a0417c1 | 930 | // if(!Store("Calib","LocalGainFactor" ,(TObject *) objgainpad ,&md2,0,kTRUE)){ |
931 | // Log("Error storing the calibration object for the local gain factor"); | |
932 | // error = kTRUE; | |
933 | // } | |
8dd14606 | 934 | } |
935 | calibra->ResetVectorFit(); | |
936 | }// if histogain | |
937 | ||
8dd14606 | 938 | // vdrift |
939 | fVdriftHLT = kFALSE; | |
940 | TProfile2D *histodriftvelocity = (TProfile2D *) filehlt->Get("PH2d"); | |
8dd14606 | 941 | if (histodriftvelocity) { |
7172a9fa | 942 | histodriftvelocity->SetDirectory(0); |
8dd14606 | 943 | // store the reference data |
944 | if(!StoreReferenceData("HLTData","VdriftT0",(TObject *) histodriftvelocity,&metaData)){ | |
945 | Log("Error storing 2D Profile for average pulse height (HLT)"); | |
946 | error = kTRUE; | |
947 | } | |
948 | // analyse | |
949 | Log("Take the PH reference data. Now we will try to fit\n"); | |
64942b85 | 950 | calibra->SetMinEntries(800*20); // If there is less than 20000 |
8dd14606 | 951 | calibra->AnalysePH(histodriftvelocity); |
952 | Int_t nbtg = 6*4*18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb0(1)) | |
953 | + 6* 18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb2(1)); | |
954 | Int_t nbfit = calibra->GetNumberFit(); | |
6aafa7ea | 955 | Int_t nbfitSuccess = calibra->GetNumberFitSuccess(); |
8dd14606 | 956 | Int_t nbE = calibra->GetNumberEnt(); |
957 | // enough statistics | |
958 | if ((nbtg > 0) && | |
6aafa7ea | 959 | (nbfit >= 0.5*nbE) && (nbE > 30) && (nbfitSuccess > 30)) { |
8dd14606 | 960 | // create the cal objects |
6aafa7ea | 961 | calibra->RemoveOutliers(1,kTRUE); |
64942b85 | 962 | calibra->PutMeanValueOtherVectorFit(1,kTRUE); |
6aafa7ea | 963 | calibra->RemoveOutliers2(kTRUE); |
64942b85 | 964 | calibra->PutMeanValueOtherVectorFit2(1,kTRUE); |
8dd14606 | 965 | TObjArray object = calibra->GetVectorFit(); |
966 | AliTRDCalDet *objdriftvelocitydet = calibra->CreateDetObjectVdrift(&object,kTRUE); | |
6a0417c1 | 967 | // TObject *objdriftvelocitypad = calibra->CreatePadObjectVdrift(); |
8dd14606 | 968 | object = calibra->GetVectorFit2(); |
969 | AliTRDCalDet *objtime0det = calibra->CreateDetObjectT0(&object,kTRUE); | |
79b38efd | 970 | //TObject *objtime0pad = calibra->CreatePadObjectT0(); |
8dd14606 | 971 | // store them |
972 | if(!Store("Calib","ChamberVdrift" ,(TObject *) objdriftvelocitydet,&md1,0,kTRUE)){ | |
973 | Log("Error storing the calibration object for the chamber vdrift (HLT)"); | |
974 | error = kTRUE; | |
975 | } | |
976 | if(!Store("Calib","ChamberT0" ,(TObject *) objtime0det ,&md1,0,kTRUE)){ | |
977 | Log("Error storing the calibration object for the chamber t0 (HLT)"); | |
978 | error = kTRUE; | |
979 | } | |
6a0417c1 | 980 | // if(!Store("Calib","LocalVdrift" ,(TObject *) objdriftvelocitypad,&md2,0,kTRUE)){ |
981 | // Log("Error storing the calibration object for the local drift velocity (HLT)"); | |
982 | // error = kTRUE; | |
983 | // } | |
984 | // if(!Store("Calib","LocalT0" ,(TObject *) objtime0pad ,&md2,0,kTRUE)){ | |
985 | // Log("Error storing the calibration object for the local time0 (HLT)"); | |
986 | // error = kTRUE; | |
987 | // } | |
8dd14606 | 988 | fVdriftHLT = kTRUE; |
989 | } | |
990 | calibra->ResetVectorFit(); | |
991 | }// if TProfile2D | |
992 | ||
8dd14606 | 993 | // prf |
c1105918 | 994 | /* |
8dd14606 | 995 | TProfile2D *histoprf = (TProfile2D *) filehlt->Get("PRF2d"); |
8dd14606 | 996 | if (histoprf) { |
7172a9fa | 997 | histoprf->SetDirectory(0); |
8dd14606 | 998 | // store reference data |
999 | if(!StoreReferenceData("HLTData","PRF",(TObject *) histoprf,&metaData)){ | |
1000 | Log("Error storing the 2D Profile for Pad Response Function"); | |
1001 | error = kTRUE; | |
1002 | } | |
1003 | // analyse | |
1004 | Log("Take the PRF reference data. Now we will try to fit\n"); | |
1005 | calibra->SetMinEntries(600); // If there is less than 20000 | |
1006 | calibra->AnalysePRFMarianFit(histoprf); | |
1007 | Int_t nbtg = 6*4*18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb0(2)) | |
1008 | + 6* 18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb2(2)); | |
1009 | Int_t nbfit = calibra->GetNumberFit(); | |
1010 | Int_t nbE = calibra->GetNumberEnt(); | |
1011 | // enough statistics | |
1012 | if ((nbtg > 0) && | |
4da4a4c8 | 1013 | (nbfit >= 0.95*nbE) && (nbE > 30)) { |
8dd14606 | 1014 | // create cal pad objects |
1015 | TObjArray object = calibra->GetVectorFit(); | |
1016 | TObject *objPRFpad = calibra->CreatePadObjectPRF(&object); | |
1017 | // store them | |
1018 | if(!Store("Calib","PRFWidth" ,(TObject *) objPRFpad ,&md2,0,kTRUE)){ | |
1019 | Log("Error storing the calibration object for the Pad Response Function"); | |
1020 | error = kTRUE; | |
1021 | } | |
1022 | } | |
1023 | calibra->ResetVectorFit(); | |
1024 | }// if PRF | |
c1105918 | 1025 | */ |
8dd14606 | 1026 | }// if fileNameEntry |
1027 | ||
1028 | delete listhlt; | |
1029 | return error; | |
1030 | ||
e5c60cc7 | 1031 | } |
fdfee371 | 1032 | |
1033 | //_____________________________________________________________________________ | |
1034 | UInt_t AliTRDPreprocessor::ProcessDCSConfigData() | |
1035 | { | |
fdfee371 | 1036 | // process the configuration of FEE, PTR and GTU |
e74c968f | 1037 | // reteive XML filei(s) from the DCS FXS |
1038 | // parse it/them and store TObjArrays in the CDB | |
fdfee371 | 1039 | |
eaceaf51 | 1040 | Log("Processing the DCS config summary files."); |
fdfee371 | 1041 | |
650ccfcf | 1042 | if(fCalDCSObjSOR) delete fCalDCSObjSOR; |
1043 | if(fCalDCSObjEOR) delete fCalDCSObjEOR; | |
3821ce70 | 1044 | |
650ccfcf | 1045 | TString xmlFile[2]; |
1046 | TString esor[2] = {"SOR", "EOR"}; | |
1047 | // get the XML files | |
1048 | xmlFile[0] = GetFile(kDCS,"CONFIGSUMMARYSOR",""); | |
1049 | xmlFile[1] = GetFile(kDCS,"CONFIGSUMMARYEOR",""); | |
f4200e67 | 1050 | |
f4200e67 | 1051 | |
650ccfcf | 1052 | // check both files |
1053 | for (Int_t iFile=0; iFile<2; iFile++) { | |
3821ce70 | 1054 | |
650ccfcf | 1055 | // check if the file are there |
1056 | if (xmlFile[iFile].IsNull()) { | |
1057 | Log(Form("Warning: %s file not found!", esor[iFile].Data())); | |
1058 | continue; | |
3821ce70 | 1059 | } |
650ccfcf | 1060 | Log(Form("%s file found: %s", esor[iFile].Data(), xmlFile[iFile].Data())); |
0712ac67 | 1061 | |
650ccfcf | 1062 | // test the file |
1063 | std::ifstream fileTest; | |
1064 | fileTest.open(xmlFile[iFile].Data(), std::ios_base::binary | std::ios_base::in); | |
1065 | if (!fileTest.good() || fileTest.eof() || !fileTest.is_open()) { | |
1066 | Log(Form("Warning: %s file not valid!", esor[iFile].Data())); | |
1067 | continue; | |
1068 | } | |
1069 | // check if the file is empty | |
1070 | fileTest.seekg(0, std::ios_base::end); | |
1071 | if (static_cast<int>(fileTest.tellg()) < 2) { | |
1072 | Log(Form("Warning: %s file empty!", esor[iFile].Data())); | |
1073 | continue; | |
0712ac67 | 1074 | } |
650ccfcf | 1075 | Log(Form("%s file is valid.", esor[iFile].Data())); |
3821ce70 | 1076 | |
650ccfcf | 1077 | // make a robust XML validation |
1078 | TSAXParser testParser; | |
1079 | if (testParser.ParseFile(xmlFile[iFile].Data()) < 0 ) { | |
1080 | Log(Form("Warning: %s XML content is not well-formed!", esor[iFile].Data())); | |
1081 | continue; | |
0712ac67 | 1082 | } |
650ccfcf | 1083 | Log(Form("%s XML content is well-formed.", esor[iFile].Data())); |
0712ac67 | 1084 | |
650ccfcf | 1085 | // create parser and parse |
1086 | TSAXParser saxParser; | |
1087 | AliTRDSaxHandler saxHandler; | |
1088 | saxParser.ConnectToHandler("AliTRDSaxHandler", &saxHandler); | |
1089 | saxParser.ParseFile(xmlFile[iFile].Data()); | |
0712ac67 | 1090 | |
650ccfcf | 1091 | // report errors of the parser if present |
1092 | if (saxParser.GetParseCode() != 0) { | |
1093 | Log(Form("Warning: %s XML file validation failed! Parse code: %d", esor[iFile].Data(), saxParser.GetParseCode())); | |
1094 | continue; | |
1095 | } | |
1096 | Log(Form("%s XML validation OK.", esor[iFile].Data())); | |
0712ac67 | 1097 | |
650ccfcf | 1098 | // report errors of the handler if present |
1099 | if (saxHandler.GetHandlerStatus() != 0) { | |
1100 | Log(Form("Warning: Creating %s calibration object failed! Error code: %d", esor[iFile].Data(), saxHandler.GetHandlerStatus())); | |
1101 | continue; | |
0712ac67 | 1102 | } |
650ccfcf | 1103 | Log(Form("%s SAX handler reports no errors.", esor[iFile].Data())); |
1104 | ||
1105 | // get the calibration object storing the data from the handler | |
1106 | AliTRDCalDCSv2 *calDCSObj = (AliTRDCalDCSv2*)saxHandler.GetCalDCSObj()->Clone(); | |
1107 | calDCSObj->EvaluateGlobalParameters(); | |
1108 | calDCSObj->SetRunType(GetRunType()); | |
1109 | calDCSObj->SetStartTime(GetStartTimeDCSQuery()); | |
1110 | calDCSObj->SetEndTime(GetEndTimeDCSQuery()); | |
1111 | if (iFile == 0) fCalDCSObjSOR = calDCSObj; | |
1112 | if (iFile == 1) fCalDCSObjEOR = calDCSObj; | |
8f7e6c0b | 1113 | } |
0712ac67 | 1114 | |
650ccfcf | 1115 | if (!fCalDCSObjSOR && !fCalDCSObjEOR) { Log("ERROR: Failed reading both files!"); return 1; } |
fdfee371 | 1116 | |
eaceaf51 | 1117 | // put both objects in one TObjArray to store them |
6a0417c1 | 1118 | TObjArray* calObjArray = new TObjArray(2); |
1119 | calObjArray->SetOwner(); | |
3821ce70 | 1120 | |
650ccfcf | 1121 | if (fCalDCSObjSOR) { |
1122 | calObjArray->AddAt(fCalDCSObjSOR,0); | |
1123 | Log("TRDCalDCS object for SOR created."); | |
1124 | } | |
1125 | if (fCalDCSObjEOR) { | |
6a0417c1 | 1126 | calObjArray->AddAt(fCalDCSObjEOR,1); |
8f7e6c0b | 1127 | Log("TRDCalDCS object for EOR created."); |
3821ce70 | 1128 | } |
1129 | ||
fdfee371 | 1130 | // store the DCS calib data in the CDB |
1131 | AliCDBMetaData metaData1; | |
1132 | metaData1.SetBeamPeriod(0); | |
1133 | metaData1.SetResponsible("Frederick Kramer"); | |
d6a1ec13 | 1134 | metaData1.SetComment("DCS configuration data in two AliTRDCalDCSv2 objects in one TObjArray (0:SOR, 1:EOR)."); |
650ccfcf | 1135 | if (!Store("Calib", "DCS", calObjArray, &metaData1, 0, kTRUE)) { Log("ERROR: Storing DCS config data object failed!"); return 1; } |
fdfee371 | 1136 | |
0712ac67 | 1137 | delete calObjArray; |
6b36d985 | 1138 | |
8f7e6c0b | 1139 | Log("SUCCESS: Processing of the DCS config summary file DONE."); |
fdfee371 | 1140 | return 0; |
75ba22eb | 1141 | } |
1142 |