1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 ////////////////////////////////////////////////////////////////////////////
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 //
24 // It alsotakes DCS data, does spline fits //
25 // and stores both reference data and spline fits results //
29 // R. Bailhache (R.Bailhache@gsi.de) //
30 // J. Book (jbook@ikf.uni-frankfurt.de) //
31 // W. Monange (w.monange@gsi.de) //
32 // F. Kramer (kramer@ikf.uni-frankfurt.de) //
34 ////////////////////////////////////////////////////////////////////////////
39 #include <TProfile2D.h>
40 #include <TObjString.h>
43 #include <TSAXParser.h>
45 #include "AliCDBMetaData.h"
48 #include "AliTRDPreprocessor.h"
49 #include "AliTRDSensorArray.h"
50 #include "AliTRDCalibraFit.h"
51 #include "AliTRDCalibraMode.h"
52 #include "AliTRDCalibPadStatus.h"
53 #include "AliTRDSaxHandler.h"
54 #include "AliTRDgeometry.h"
55 #include "AliTRDCalibChamberStatus.h"
56 #include "Cal/AliTRDCalPad.h"
57 #include "Cal/AliTRDCalPadStatus.h"
58 #include "Cal/AliTRDCalDCSv2.h"
59 #include "Cal/AliTRDCalSingleChamberStatus.h"
60 #include "Cal/AliTRDCalChamberStatus.h"
61 #include "Cal/AliTRDCalROC.h"
63 ClassImp(AliTRDPreprocessor)
65 //______________________________________________________________________________________________
66 AliTRDPreprocessor::AliTRDPreprocessor(AliShuttleInterface *shuttle)
67 :AliPreprocessor("TRD", shuttle)
77 AddRunType("PHYSICS");
78 AddRunType("STANDALONE");
79 AddRunType("PEDESTAL");
84 //______________________________________________________________________________________________
85 AliTRDPreprocessor::AliTRDPreprocessor(const AliTRDPreprocessor& ) :
86 AliPreprocessor("TRD",0),
92 Fatal("AliTRDPreprocessor", "copy constructor not implemented");
95 //______________________________________________________________________________________________
96 AliTRDPreprocessor::~AliTRDPreprocessor()
102 if (fCalDCSObjSOR != NULL) {
103 delete fCalDCSObjSOR;
106 if (fCalDCSObjEOR != NULL) {
107 delete fCalDCSObjEOR;
112 //______________________________________________________________________________________________
113 AliTRDPreprocessor& AliTRDPreprocessor::operator = (const AliTRDPreprocessor& )
115 Fatal("operator =", "assignment operator not implemented");
118 //______________________________________________________________________________________________
119 void AliTRDPreprocessor::Initialize(Int_t run, UInt_t startTime, UInt_t endTime)
122 // Initialization routine for the TRD preprocessor
125 AliPreprocessor::Initialize(run,startTime,endTime);
129 //______________________________________________________________________________________________
130 UInt_t AliTRDPreprocessor::Process(TMap* dcsAliasMap)
133 // Process DCS and calibration part for HLT
136 TString runType = GetRunType();
137 Log(Form("runtype %s\n",runType.Data()));
139 // always process the configuration data
140 Int_t DCSConfigReturn = ProcessDCSConfigData();
141 if(DCSConfigReturn) return DCSConfigReturn;
143 if (runType=="PEDESTAL"){
144 if(ExtractPedestals()) return 1;
148 if ((runType=="PHYSICS") || (runType=="STANDALONE") || (runType=="DAQ")){
150 if(ProcessDCS(dcsAliasMap)) return 1;
151 if(runType=="PHYSICS"){
153 //TString runPar = GetRunParameter("HLTStatus");
156 //if(ExtractHLT()) return 1; // for testing!
161 //if(ExtractDriftVelocityDAQ()) return 1;
162 ExtractDriftVelocityDAQ(); // for testing!
165 //if((runType=="PHYSICS") || (runType=="STANDALONE")) {
166 // if(ExtractHalfChamberStatusDAQ()) return 1;
173 //______________________________________________________________________________
174 Bool_t AliTRDPreprocessor::ProcessDCS()
177 // Default process DCS method
180 TString runType = GetRunType();
181 if ((runType == "PHYSICS") || (runType == "STANDALONE")) {
188 //______________________________________________________________________________
189 Bool_t AliTRDPreprocessor::ProcessDCS(TMap *dcsAliasMap)
192 // Process DCS method
195 Bool_t error = kFALSE;
197 AliCDBMetaData metaData;
198 metaData.SetBeamPeriod(0);
199 metaData.SetResponsible("Wilfried Monange/Raphaelle Bailhache");
200 metaData.SetComment("TRD calib test");
202 Log("****** DCS ******\n");
204 TObjArray * list=AliTRDSensorArray::GetList();
207 Log ("Error during AliTRDSensorArray::GetList");
208 Log ("DCS will not be processing");
212 Int_t nEntries = list->GetEntries ();
213 Log (Form ("%d alias loaded", nEntries));
215 Bool_t * results=new Bool_t [nEntries];
216 Int_t * nGraph=new Int_t [nEntries];
218 for (Int_t iAlias = 0; iAlias < nEntries; iAlias++) {
220 AliTRDSensorArray * oneTRDDCS = (AliTRDSensorArray *)list->At (iAlias);
222 oneTRDDCS->SetStartTime (TTimeStamp (fStartTime));
223 oneTRDDCS->SetEndTime (TTimeStamp (fEndTime));
225 Log(Form("Processing DCS : \"%s\"", oneTRDDCS->GetStoreName ().Data ()));
229 map=oneTRDDCS->ExtractDCS (dcsAliasMap);
231 nGraph [iAlias] = map->GetEntries ();
233 if (nGraph [iAlias] == 0) {
234 Log("No TGraph for this dcsDatapointAlias : not stored");
235 results [iAlias] = kFALSE;
240 oneTRDDCS->SetGraph(map);
241 results[iAlias]=Store("Calib", oneTRDDCS->GetStoreName().Data(), oneTRDDCS, &metaData, 0, kFALSE);
244 //results [iAlias] = StoreReferenceData("Calib", oneTRDDCS->GetStoreName ().Data (), oneTRDDCS, &metaData);
246 if (!results[iAlias]) {
247 AliError("Problem during StoreRef DCS");
251 //BEGIN TEST (should not be removed ...)
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);
262 if(iAlias==1 || iAlias==19) continue;
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);
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);
287 for (Int_t iAlias = 0; iAlias < nEntries; iAlias++) {
288 if (results[iAlias]) {
292 if(nbCount == 0) error = kTRUE;
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",
304 Log ("*********** End of DCS **********");
312 //______________________________________________________________________________________________
313 Bool_t AliTRDPreprocessor::ExtractHalfChamberStatusDAQ()
316 // Half chamber status algorithm running on DAQ
319 Bool_t error = kFALSE;
321 AliCDBMetaData metaData;
322 metaData.SetBeamPeriod(0);
323 metaData.SetResponsible("Raphaelle Bailhache");
324 metaData.SetComment("TRD calib test");
326 // Take the output of the DA on DAQ
327 TList * listpad = GetFileSources(kDAQ,"HALFCHAMBERSTATUS");
329 Log("No list found for the HalfChamberStatus");
333 AliTRDCalibChamberStatus *calPed = 0x0;
335 // loop through all files (only one normally)
337 while (listpad->At(index)!=NULL) {
338 TObjString* fileNameEntry = (TObjString*) listpad->At(index);
339 if (fileNameEntry != NULL)
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));
349 TFile *f = TFile::Open(fileName);
350 f->GetObject("calibchamberstatus",calPed);
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));
361 else Log(Form("Error getting AliTRDCalibChamberStatus onject from file"));
367 Log(Form("%d elements found in the list for the halfchamberstatus",(Int_t)index));
374 // Produce the AliTRDCalChamberStatus name calHalfChamberStatus
376 AliTRDCalChamberStatus *calHalfChamberStatus = 0x0;
378 //calPed->AnalyseHisto(); // check number of events, create calHalfChamberStatus (done on DAQ)
380 calPed->CheckEORStatus((AliTRDCalDCSv2 *)fCalDCSObjEOR);
382 calHalfChamberStatus=(AliTRDCalChamberStatus *)calPed->GetCalChamberStatus();
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");
404 //______________________________________________________________________________________________
405 Bool_t AliTRDPreprocessor::ExtractPedestals()
408 // Pedestal running on LDCs at the DAQ
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
419 Bool_t error = kFALSE;
421 // Init a AliTRDCalibPadStatus
422 AliTRDCalibPadStatus calPedSum = AliTRDCalibPadStatus();
424 AliCDBMetaData metaData;
425 metaData.SetBeamPeriod(0);
426 metaData.SetResponsible("Raphaelle Bailhache");
427 metaData.SetComment("TRD calib test");
429 // Sum the contributions of the LDCs
430 TList * listpad = GetFileSources(kDAQ,"PADSTATUS");
432 Log("No list found for the PEDESTRAL Run");
436 // loop through all files from LDCs
438 while (listpad->At(index)!=NULL) {
439 TObjString* fileNameEntry = (TObjString*) listpad->At(index);
440 if (fileNameEntry != NULL)
442 TString fileName = GetFile(kDAQ, "PADSTATUS",
443 fileNameEntry->GetString().Data());
444 if(fileName.Length() ==0){
445 Log(Form("Error by retrieving the file %d for the pedestal",(Int_t)index));
450 TFile *f = TFile::Open(fileName);
451 AliTRDCalibPadStatus *calPed;
452 f->GetObject("calibpadstatus",calPed);
457 //calPed->AnalyseHisto();
459 // Add to the calPedSum
460 for (Int_t idet=0; idet<540; idet++) {
461 AliTRDCalROC *rocMean = calPed->GetCalRocMean(idet, kFALSE);
463 calPedSum.SetCalRocMean(rocMean,idet);
465 AliTRDCalROC *rocRMS = calPed->GetCalRocRMS(idet, kFALSE);
467 calPedSum.SetCalRocRMS(rocRMS,idet);
469 AliTRDCalROC *rocMeand = calPed->GetCalRocMeand(idet, kFALSE);
471 calPedSum.SetCalRocMeand(rocMeand,idet);
473 AliTRDCalROC *rocRMSd = calPed->GetCalRocRMSd(idet, kFALSE);
475 calPedSum.SetCalRocRMSd(rocRMSd,idet);
479 // store as reference data
480 TString name("PadStatus");
482 if(!StoreReferenceData("DAQData",(const char *)name,(TObject *) calPed,&metaData)){
483 Log(Form("Error storing AliTRDCalibPadStatus object %d as reference data",(Int_t)index));
492 Log(Form("%d elements found in the list for the pedestal",(Int_t)index));
503 AliTRDCalPadStatus *calPadStatus = calPedSum.CreateCalPadStatus();
505 //Make the AliTRDCalPad
506 AliTRDCalPad *calPad2 = calPedSum.CreateCalPad();
507 //Make the AliTRDCalDet correspondant
508 AliTRDCalDet *calDet = calPedSum.CreateCalDet();
511 // Take the noise and Pad status from the previous OCDB
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");
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)
530 AliTRDCalSingleChamberStatus *calROC = calPadStatusPrevious->GetCalROC(idet);
531 for(Int_t k = 0; k < calROC->GetNchannels(); k++){
532 calROC->SetStatus(k,AliTRDCalPadStatus::kMasked);
538 // Loop over detectors for check
539 for (Int_t det=0; det<AliTRDgeometry::kNdet; ++det) {
542 AliTRDCalROC *calROCPreviousNoise = calPadPrevious->GetCalROC(det);
543 AliTRDCalROC *calROCNoise = calPad2->GetCalROC(det);
546 AliTRDCalSingleChamberStatus *calROCPreviousStatus = calPadStatusPrevious->GetCalROC(det);
547 AliTRDCalSingleChamberStatus *calROCStatus = calPadStatus->GetCalROC(det);
550 // loop over first half and second half chamber
551 for(Int_t half = 0; half < 2; half++){
553 Bool_t data = AreThereDataPedestal(calROCStatus,(Bool_t)half);
554 //printf("There are data for the detector %d the half %d: %d\n",det,half,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
560 SetDefaultStatus(*calROCStatus,(Bool_t)half);
561 SetDefaultNoise(*calROCNoise,(Bool_t)half);
564 // if data, set to previous value
565 SetStatus(*calROCStatus,calROCPreviousStatus,(Bool_t)half);
566 SetNoise(*calROCNoise,calROCPreviousNoise,(Bool_t)half);
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");
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");
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");
614 //__________________________________________________________________
615 Bool_t AliTRDPreprocessor::AreThereDataPedestal(AliTRDCalSingleChamberStatus * const calROCStatus
620 // Data for this half chamber
623 Bool_t data = kFALSE;
624 Int_t nCols = calROCStatus->GetNcols();
626 Int_t nColE = (Int_t) nCols/2 - 2;
632 Int_t totalnumberofpads = 0;
633 Int_t totalnumberofdata = 0;
635 for(Int_t col = nCol0; col < nColE; col++){
636 for(Int_t row = 0; row < calROCStatus->GetNrows(); row++){
638 //printf("ismasked %d\n",(Int_t)calROCStatus->IsMasked(col,row));
639 if(!calROCStatus->GetStatus(col,row)) {
645 if(totalnumberofdata < (Int_t)(totalnumberofpads/2)) data = kFALSE;
650 //__________________________________________________________________
651 void AliTRDPreprocessor::SetDefaultStatus(AliTRDCalSingleChamberStatus &calROCStatus, Bool_t second){
654 // default status for this half chamber
657 Int_t nCols = calROCStatus.GetNcols();
659 Int_t nColE = (Int_t) nCols/2;
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);
670 //__________________________________________________________________
671 void AliTRDPreprocessor::SetStatus(AliTRDCalSingleChamberStatus &calROCStatus, AliTRDCalSingleChamberStatus *calROCStatusPrevious,Bool_t second){
674 // previous status for this half chamber
677 Int_t nCols = calROCStatus.GetNcols();
679 Int_t nColE = (Int_t) nCols/2;
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));
690 //__________________________________________________________________
691 void AliTRDPreprocessor::SetDefaultNoise(AliTRDCalROC &calROCNoise, Bool_t second){
694 // default noise for this half chamber
697 Int_t nCols = calROCNoise.GetNcols();
699 Int_t nColE = (Int_t) nCols/2;
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);
710 //__________________________________________________________________
711 void AliTRDPreprocessor::SetNoise(AliTRDCalROC &calROCNoise, AliTRDCalROC *calROCNoisePrevious, Bool_t second){
714 // previous noise for this half chamber
717 Int_t nCols = calROCNoise.GetNcols();
719 Int_t nColE = (Int_t) nCols/2;
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));
730 //______________________________________________________________________________________________
731 Bool_t AliTRDPreprocessor::ExtractDriftVelocityDAQ()
734 // Drift velocity DA running on monitoring servers at the DAQ
737 Bool_t error = kFALSE;
739 // Objects for HLT and DAQ zusammen
740 AliTRDCalibraFit *calibra = AliTRDCalibraFit::Instance();
741 AliCDBMetaData metaData;
742 metaData.SetBeamPeriod(0);
743 metaData.SetResponsible("Raphaelle Bailhache");
744 metaData.SetComment("TRD calib test");
745 // Store the infos for the detector
747 md1.SetObjectClassName("AliTRDCalDet");
748 md1.SetResponsible("Raphaelle Bailhache");
749 md1.SetBeamPeriod(0);
750 md1.SetComment("TRD calib test");
751 // Store the infos for the pads
753 md2.SetObjectClassName("AliTRDCalPad");
754 md2.SetResponsible("Raphaelle Bailhache");
755 md2.SetBeamPeriod(0);
756 md2.SetComment("TRD calib test");
758 // Take the file from the DAQ file exchange server
759 TList *listdaq = GetFileSources(kDAQ,"VDRIFT");
761 Log("No list found for vdrift (DAQ)");
765 if(listdaq->GetSize() !=1){
766 Log(Form("Problem on the size of the list: %d (DAQ)",listdaq->GetSize()));
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)");
780 TFile *filedaq = TFile::Open(fileName);
781 TProfile2D *histodriftvelocity = (TProfile2D *) filedaq->Get("PH2d");
782 if (histodriftvelocity) {
784 // store as reference data
785 if(!StoreReferenceData("DAQData","VdriftT0",(TObject *) histodriftvelocity,&metaData)){
786 Log("Error storing 2D Profile for vdrift from the DAQ");
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);
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();
799 Int_t nbfitSuccess = calibra->GetNumberFitSuccess();
800 Int_t nbE = calibra->GetNumberEnt();
802 // if enough statistics store the results
804 (nbfit >= 0.5*nbE) && (nbE > 30) && (nbfitSuccess > 30)) {
805 // create the cal objects
806 calibra->RemoveOutliers(1,kTRUE);
807 calibra->PutMeanValueOtherVectorFit(1,kTRUE);
808 calibra->RemoveOutliers2(kTRUE);
809 calibra->PutMeanValueOtherVectorFit2(1,kTRUE);
810 TObjArray object = calibra->GetVectorFit();
811 AliTRDCalDet *objdriftvelocitydet = calibra->CreateDetObjectVdrift(&object,kTRUE);
812 // TObject *objdriftvelocitypad = calibra->CreatePadObjectVdrift();
813 object = calibra->GetVectorFit2();
814 AliTRDCalDet *objtime0det = calibra->CreateDetObjectT0(&object,kTRUE);
815 // TObject *objtime0pad = calibra->CreatePadObjectT0();
816 calibra->ResetVectorFit();
818 if(!Store("Calib","ChamberVdrift" ,(TObject *) objdriftvelocitydet,&md1,0,kTRUE)){
819 Log("Error storing the calibration object for the chamber vdrift (DAQ)");
822 if(!Store("Calib","ChamberT0" ,(TObject *) objtime0det ,&md1,0,kTRUE)){
823 Log("Error storing the calibration object for the chamber t0 (DAQ)");
826 // if(!Store("Calib","LocalVdrift" ,(TObject *) objdriftvelocitypad,&md2,0,kTRUE)){
827 // Log("Error storing the calibration object for the local drift velocity (DAQ)");
830 // if(!Store("Calib","LocalT0" ,(TObject *) objtime0pad ,&md2,0,kTRUE)){
831 // Log("Error storing the calibration object for the local time0 (DAQ)");
836 Log("Not enough statistics for the average pulse height (DAQ)");
846 //______________________________________________________________________________________________
847 Bool_t AliTRDPreprocessor::ExtractHLT()
850 // Gain, vdrift and PRF calibration running on HLT
851 // return kTRUE if NULL pointer to the list
854 Bool_t error = kFALSE;
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
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
870 md2.SetObjectClassName("AliTRDCalPad");
871 md2.SetResponsible("Raphaelle Bailhache");
872 md2.SetBeamPeriod(0);
873 md2.SetComment("TRD calib test");
875 // Take the file from the HLT file exchange server
876 TList *listhlt = GetFileSources(kHLT,"GAINDRIFTPRF");
878 Log("No list found for the HLT");
882 if(listhlt->GetSize() != 1) {
883 Log(Form("Problem on the size of the list: %d (HLT)",listhlt->GetSize()));
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)");
898 TFile *filehlt = TFile::Open(fileName);
901 TH2I *histogain = (TH2I *) filehlt->Get("CH2d");
903 histogain->SetDirectory(0);
904 // store the reference data
905 if(!StoreReferenceData("HLTData","Gain",(TObject *) histogain,&metaData)){
906 Log("Error storing 2D histos for gain");
910 Log("Take the CH reference data. Now we will try to fit\n");
911 calibra->SetMinEntries(800); // If there is less than 1000 entries in the histo: no fit
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();
919 (nbfit >= 0.5*nbE) && (nbE > 30)) {
920 // create the cal objects
921 calibra->PutMeanValueOtherVectorFit(1,kTRUE);
922 TObjArray object = calibra->GetVectorFit();
923 AliTRDCalDet *objgaindet = calibra->CreateDetObjectGain(&object);
924 // TObject *objgainpad = calibra->CreatePadObjectGain();
926 if(!Store("Calib","ChamberGainFactor",(TObject *) objgaindet ,&md1,0,kTRUE)){
927 Log("Error storing the calibration object for the chamber gain");
930 // if(!Store("Calib","LocalGainFactor" ,(TObject *) objgainpad ,&md2,0,kTRUE)){
931 // Log("Error storing the calibration object for the local gain factor");
935 calibra->ResetVectorFit();
940 TProfile2D *histodriftvelocity = (TProfile2D *) filehlt->Get("PH2d");
941 if (histodriftvelocity) {
942 histodriftvelocity->SetDirectory(0);
943 // store the reference data
944 if(!StoreReferenceData("HLTData","VdriftT0",(TObject *) histodriftvelocity,&metaData)){
945 Log("Error storing 2D Profile for average pulse height (HLT)");
949 Log("Take the PH reference data. Now we will try to fit\n");
950 calibra->SetMinEntries(800*20); // If there is less than 20000
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();
955 Int_t nbfitSuccess = calibra->GetNumberFitSuccess();
956 Int_t nbE = calibra->GetNumberEnt();
959 (nbfit >= 0.5*nbE) && (nbE > 30) && (nbfitSuccess > 30)) {
960 // create the cal objects
961 calibra->RemoveOutliers(1,kTRUE);
962 calibra->PutMeanValueOtherVectorFit(1,kTRUE);
963 calibra->RemoveOutliers2(kTRUE);
964 calibra->PutMeanValueOtherVectorFit2(1,kTRUE);
965 TObjArray object = calibra->GetVectorFit();
966 AliTRDCalDet *objdriftvelocitydet = calibra->CreateDetObjectVdrift(&object,kTRUE);
967 // TObject *objdriftvelocitypad = calibra->CreatePadObjectVdrift();
968 object = calibra->GetVectorFit2();
969 AliTRDCalDet *objtime0det = calibra->CreateDetObjectT0(&object,kTRUE);
970 //TObject *objtime0pad = calibra->CreatePadObjectT0();
972 if(!Store("Calib","ChamberVdrift" ,(TObject *) objdriftvelocitydet,&md1,0,kTRUE)){
973 Log("Error storing the calibration object for the chamber vdrift (HLT)");
976 if(!Store("Calib","ChamberT0" ,(TObject *) objtime0det ,&md1,0,kTRUE)){
977 Log("Error storing the calibration object for the chamber t0 (HLT)");
980 // if(!Store("Calib","LocalVdrift" ,(TObject *) objdriftvelocitypad,&md2,0,kTRUE)){
981 // Log("Error storing the calibration object for the local drift velocity (HLT)");
984 // if(!Store("Calib","LocalT0" ,(TObject *) objtime0pad ,&md2,0,kTRUE)){
985 // Log("Error storing the calibration object for the local time0 (HLT)");
990 calibra->ResetVectorFit();
995 TProfile2D *histoprf = (TProfile2D *) filehlt->Get("PRF2d");
997 histoprf->SetDirectory(0);
998 // store reference data
999 if(!StoreReferenceData("HLTData","PRF",(TObject *) histoprf,&metaData)){
1000 Log("Error storing the 2D Profile for Pad Response Function");
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
1013 (nbfit >= 0.95*nbE) && (nbE > 30)) {
1014 // create cal pad objects
1015 TObjArray object = calibra->GetVectorFit();
1016 TObject *objPRFpad = calibra->CreatePadObjectPRF(&object);
1018 if(!Store("Calib","PRFWidth" ,(TObject *) objPRFpad ,&md2,0,kTRUE)){
1019 Log("Error storing the calibration object for the Pad Response Function");
1023 calibra->ResetVectorFit();
1026 }// if fileNameEntry
1033 //_____________________________________________________________________________
1034 UInt_t AliTRDPreprocessor::ProcessDCSConfigData()
1037 // process the configuration of FEE, PTR and GTU
1038 // reteive XML filei(s) from the DCS FXS
1039 // parse it/them and store TObjArrays in the CDB
1041 // return 0 for success, otherwise:
1042 // 5 : Could not get the SOR file from the FXS
1043 // 8 : SOR file is not valid
1044 // 10 : SOR XML is not well-formed
1045 // 12 : ERROR in SOR XML SAX validation: something wrong with the content
1046 // 14 : ERROR while creating SOR calibration objects in the handler
1047 // 16 : ERROR while storing data in the CDB
1050 Log("Processing the DCS config summary files.");
1052 // get the XML files
1053 Log("Requesting the two XML files from the FXS..");
1054 TString xmlFileS = GetFile(kDCS,"CONFIGSUMMARYSOR","");
1055 TString xmlFileE = GetFile(kDCS,"CONFIGSUMMARYEOR","");
1056 Bool_t fileExistE = kTRUE;
1059 // check if the files are there
1060 if (xmlFileS.IsNull()) {
1061 Log("ERROR: SOR file not found!");
1064 Log(Form("SOR file found: %s", xmlFileS.Data()));
1066 if (xmlFileE.IsNull()) {
1067 Log("Warning: EOR file not found!");
1068 fileExistE = kFALSE;
1069 } else Log(Form("EOR file found: %s", xmlFileE.Data()));
1073 std::ifstream fileTestS;
1074 fileTestS.open(xmlFileS.Data(), std::ios_base::binary | std::ios_base::in);
1075 if (!fileTestS.good() || fileTestS.eof() || !fileTestS.is_open()) {
1076 Log("ERROR: SOR file not valid!");
1079 fileTestS.seekg(0, std::ios_base::end);
1080 if (static_cast<int>(fileTestS.tellg()) < 2) {
1081 Log("ERROR: SOR file is empty!");
1084 Log("SOR file is valid.");
1087 std::ifstream fileTestE;
1088 fileTestE.open(xmlFileE.Data(), std::ios_base::binary | std::ios_base::in);
1089 if (!fileTestE.good() || fileTestE.eof() || !fileTestE.is_open()) {
1090 Log("Warning: EOR file is not valid!");
1091 fileExistE = kFALSE;
1093 fileTestE.seekg(0, std::ios_base::end);
1094 if (static_cast<int>(fileTestE.tellg()) < 2) {
1095 Log("Warning: EOR file is empty!");
1096 fileExistE = kFALSE;
1100 if (fileExistE) Log("EOR file is valid.");
1103 // make a robust XML validation
1104 TSAXParser testParserS, testParserE;
1105 if (testParserS.ParseFile(xmlFileS.Data()) < 0 ) {
1106 Log("ERROR: SOR XML content is not well-formed!");
1109 Log("SOR XML content is well-formed.");
1112 if (testParserE.ParseFile(xmlFileE.Data()) < 0 ) {
1113 Log("Warning: XML content (EOR) is not well-formed!");
1114 fileExistE = kFALSE;
1117 if (fileExistE) Log("EOR XML content is well-formed.");
1120 // create parser and parse
1121 TSAXParser saxParserS, saxParserE;
1122 AliTRDSaxHandler saxHandlerS, saxHandlerE;
1123 saxParserS.ConnectToHandler("AliTRDSaxHandler", &saxHandlerS);
1124 saxParserS.ParseFile(xmlFileS.Data());
1126 // report errors of the parser if present
1127 if (saxParserS.GetParseCode() != 0) {
1128 Log(Form("ERROR: SOR XML file validation failed! Parse code: %d", saxParserS.GetParseCode()));
1131 Log("SOR XML file validation OK.");
1134 saxParserE.ConnectToHandler("AliTRDSaxHandler", &saxHandlerE);
1135 saxParserE.ParseFile(xmlFileE.Data());
1136 if (saxParserE.GetParseCode() != 0) {
1137 Log(Form("Warning: EOR XML file validation failed! Parse code: %d", saxParserE.GetParseCode()));
1138 fileExistE = kFALSE;
1141 if (fileExistE) Log("EOR XML file validation OK.");
1144 // report errors of the handler if present
1145 if (saxHandlerS.GetHandlerStatus() != 0) {
1146 Log(Form("ERROR: Creating SOR calibration object failed! Error code: %d", saxHandlerS.GetHandlerStatus()));
1149 Log("SOR SAX handler reports no errors.");
1152 if (saxHandlerE.GetHandlerStatus() != 0) {
1153 Log(Form("Warning: Creating EOR calibration object failed! Error code: %d", saxHandlerE.GetHandlerStatus()));
1154 fileExistE = kFALSE;
1157 if (fileExistE) Log("EOR SAX handler reports no errors.");
1160 // put both objects in one TObjArray to store them
1161 TObjArray* calObjArray = new TObjArray(2);
1162 calObjArray->SetOwner();
1164 // get the calibration object storing the data from the handler
1165 if(fCalDCSObjSOR) delete fCalDCSObjSOR;
1166 fCalDCSObjSOR = (AliTRDCalDCSv2 *) saxHandlerS.GetCalDCSObj()->Clone();
1167 fCalDCSObjSOR->EvaluateGlobalParameters();
1168 fCalDCSObjSOR->SetRunType(GetRunType());
1169 fCalDCSObjSOR->SetStartTime(GetStartTimeDCSQuery());
1170 fCalDCSObjSOR->SetEndTime(GetEndTimeDCSQuery());
1171 calObjArray->AddAt(fCalDCSObjSOR,0);
1172 Log("TRDCalDCS object for SOR created.");
1175 if(fCalDCSObjEOR) delete fCalDCSObjEOR;
1176 fCalDCSObjEOR = (AliTRDCalDCSv2 *) saxHandlerE.GetCalDCSObj()->Clone();
1177 fCalDCSObjEOR->EvaluateGlobalParameters();
1178 fCalDCSObjEOR->SetRunType(GetRunType());
1179 fCalDCSObjEOR->SetStartTime(GetStartTimeDCSQuery());
1180 fCalDCSObjEOR->SetEndTime(GetEndTimeDCSQuery());
1181 calObjArray->AddAt(fCalDCSObjEOR,1);
1182 Log("TRDCalDCS object for EOR created.");
1186 // store the DCS calib data in the CDB
1187 AliCDBMetaData metaData1;
1188 metaData1.SetBeamPeriod(0);
1189 metaData1.SetResponsible("Frederick Kramer");
1190 metaData1.SetComment("DCS configuration data in two AliTRDCalDCSv2 objects in one TObjArray (0:SOR, 1:EOR).");
1191 if (!Store("Calib", "DCS", calObjArray, &metaData1, 0, kTRUE)) {
1192 Log("ERROR: Storing DCS config data object failed!");
1198 Log("SUCCESS: Processing of the DCS config summary file DONE.");