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 ) delete fCalDCSObjSOR;
103 if (fCalDCSObjEOR ) delete fCalDCSObjEOR;
106 //______________________________________________________________________________________________
107 AliTRDPreprocessor& AliTRDPreprocessor::operator = (const AliTRDPreprocessor& )
109 Fatal("operator =", "assignment operator not implemented");
112 //______________________________________________________________________________________________
113 void AliTRDPreprocessor::Initialize(Int_t run, UInt_t startTime, UInt_t endTime)
116 // Initialization routine for the TRD preprocessor
119 AliPreprocessor::Initialize(run,startTime,endTime);
123 //______________________________________________________________________________________________
124 UInt_t AliTRDPreprocessor::Process(TMap* dcsAliasMap)
127 // Process DCS and calibration part for HLT
130 TString runType = GetRunType();
131 Log(Form("runtype %s\n",runType.Data()));
133 // always process the configuration data
134 Int_t dCSConfigReturn = ProcessDCSConfigData();
135 if(dCSConfigReturn) return dCSConfigReturn;
137 if (runType=="PEDESTAL"){
138 if(ExtractPedestals()) return 1;
142 if ((runType=="PHYSICS") || (runType=="STANDALONE") || (runType=="DAQ")){
144 if(ProcessDCS(dcsAliasMap)) return 1;
146 if(runType=="PHYSICS"){
148 //TString runPar = GetRunParameter("HLTStatus");
151 //if(ExtractHLT()) return 1; // for testing!
156 //if(ExtractDriftVelocityDAQ()) return 1;
157 ExtractDriftVelocityDAQ(); // for testing!
167 //______________________________________________________________________________
168 Bool_t AliTRDPreprocessor::ProcessDCS()
171 // Default process DCS method
174 TString runType = GetRunType();
175 if ((runType == "PHYSICS") || (runType == "STANDALONE")) {
182 //______________________________________________________________________________
183 Bool_t AliTRDPreprocessor::ProcessDCS(TMap *dcsAliasMap)
186 // Process DCS method
189 Bool_t error = kFALSE;
191 AliCDBMetaData metaData;
192 metaData.SetBeamPeriod(0);
193 metaData.SetResponsible("Wilfried Monange/Raphaelle Bailhache");
194 metaData.SetComment("TRD calib test");
196 Log("****** DCS ******\n");
198 TObjArray * list=AliTRDSensorArray::GetList();
201 Log ("Error during AliTRDSensorArray::GetList");
202 Log ("DCS will not be processing");
206 Int_t nEntries = list->GetEntries ();
207 Log (Form ("%d alias loaded", nEntries));
209 Bool_t * results=new Bool_t [nEntries];
210 Int_t * nGraph=new Int_t [nEntries];
212 for (Int_t iAlias = 0; iAlias < nEntries; iAlias++) {
214 AliTRDSensorArray * oneTRDDCS = (AliTRDSensorArray *)list->At (iAlias);
216 oneTRDDCS->SetStartTime (TTimeStamp (fStartTime));
217 oneTRDDCS->SetEndTime (TTimeStamp (fEndTime));
219 Log(Form("Processing DCS : \"%s\"", oneTRDDCS->GetStoreName ().Data ()));
223 map=oneTRDDCS->ExtractDCS (dcsAliasMap);
225 nGraph [iAlias] = map->GetEntries ();
227 if (nGraph [iAlias] == 0) {
228 Log("No TGraph for this dcsDatapointAlias : not stored");
229 results [iAlias] = kFALSE;
234 oneTRDDCS->SetGraph(map);
235 results[iAlias]=Store("Calib", oneTRDDCS->GetStoreName().Data(), oneTRDDCS, &metaData, 0, kFALSE);
238 //results [iAlias] = StoreReferenceData("Calib", oneTRDDCS->GetStoreName ().Data (), oneTRDDCS, &metaData);
240 if (!results[iAlias]) {
241 AliError("Problem during StoreRef DCS");
245 //BEGIN TEST (should not be removed ...)
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);
256 if(iAlias==1 || iAlias==19) continue;
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);
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);
281 for (Int_t iAlias = 0; iAlias < nEntries; iAlias++) {
282 if (results[iAlias]) {
286 if(nbCount == 0) error = kTRUE;
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",
298 Log ("*********** End of DCS **********");
306 //______________________________________________________________________________________________
307 Bool_t AliTRDPreprocessor::ExtractHalfChamberStatusDAQ()
310 // Half chamber status algorithm running on DAQ
313 Bool_t error = kFALSE;
315 AliCDBMetaData metaData;
316 metaData.SetBeamPeriod(0);
317 metaData.SetResponsible("Raphaelle Bailhache");
318 metaData.SetComment("TRD calib test");
320 // Take the output of the DA on DAQ
321 TList * listpad = GetFileSources(kDAQ,"HALFCHAMBERSTATUS");
323 Log("No list found for the HalfChamberStatus");
327 AliTRDCalibChamberStatus *calPed = 0x0;
329 // loop through all files (only one normally)
331 while (listpad->At(index)!=NULL) {
332 TObjString* fileNameEntry = (TObjString*) listpad->At(index);
333 if (fileNameEntry != NULL)
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));
343 TFile *f = TFile::Open(fileName);
344 f->GetObject("calibchamberstatus",calPed);
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));
355 else Log(Form("Error getting AliTRDCalibChamberStatus onject from file"));
361 Log(Form("%d elements found in the list for the halfchamberstatus",(Int_t)index));
368 // Produce the AliTRDCalChamberStatus name calHalfChamberStatus
370 AliTRDCalChamberStatus *calHalfChamberStatus = 0x0;
372 //calPed->AnalyseHisto(); // check number of events, create calHalfChamberStatus (done on DAQ)
374 calPed->CheckEORStatus((AliTRDCalDCSv2 *)fCalDCSObjEOR);
376 calHalfChamberStatus=(AliTRDCalChamberStatus *)calPed->GetCalChamberStatus();
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");
398 //______________________________________________________________________________________________
399 Bool_t AliTRDPreprocessor::ExtractPedestals()
402 // Pedestal running on LDCs at the DAQ
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
413 Bool_t error = kFALSE;
415 // Init a AliTRDCalibPadStatus
416 AliTRDCalibPadStatus calPedSum = AliTRDCalibPadStatus();
418 AliCDBMetaData metaData;
419 metaData.SetBeamPeriod(0);
420 metaData.SetResponsible("Raphaelle Bailhache");
421 metaData.SetComment("TRD calib test");
423 // Sum the contributions of the LDCs
424 TList * listpad = GetFileSources(kDAQ,"PADSTATUS");
426 Log("No list found for the PEDESTRAL Run");
430 // loop through all files from LDCs
432 while (listpad->At(index)!=NULL) {
433 TObjString* fileNameEntry = (TObjString*) listpad->At(index);
434 if (fileNameEntry != NULL)
436 TString fileName = GetFile(kDAQ, "PADSTATUS",
437 fileNameEntry->GetString().Data());
438 if(fileName.Length() ==0){
439 Log(Form("Error by retrieving the file %d for the pedestal",(Int_t)index));
444 TFile *f = TFile::Open(fileName);
445 AliTRDCalibPadStatus *calPed;
446 f->GetObject("calibpadstatus",calPed);
451 //calPed->AnalyseHisto();
453 // Add to the calPedSum
454 for (Int_t idet=0; idet<540; idet++) {
455 AliTRDCalROC *rocMean = calPed->GetCalRocMean(idet, kFALSE);
457 calPedSum.SetCalRocMean(rocMean,idet);
459 AliTRDCalROC *rocRMS = calPed->GetCalRocRMS(idet, kFALSE);
461 calPedSum.SetCalRocRMS(rocRMS,idet);
463 AliTRDCalROC *rocMeand = calPed->GetCalRocMeand(idet, kFALSE);
465 calPedSum.SetCalRocMeand(rocMeand,idet);
467 AliTRDCalROC *rocRMSd = calPed->GetCalRocRMSd(idet, kFALSE);
469 calPedSum.SetCalRocRMSd(rocRMSd,idet);
473 // store as reference data
474 TString name("PadStatus");
476 if(!StoreReferenceData("DAQData",(const char *)name,(TObject *) calPed,&metaData)){
477 Log(Form("Error storing AliTRDCalibPadStatus object %d as reference data",(Int_t)index));
486 Log(Form("%d elements found in the list for the pedestal",(Int_t)index));
497 AliTRDCalPadStatus *calPadStatus = calPedSum.CreateCalPadStatus();
499 //Make the AliTRDCalPad
500 AliTRDCalPad *calPad2 = calPedSum.CreateCalPad();
501 //Make the AliTRDCalDet correspondant
502 AliTRDCalDet *calDet = calPedSum.CreateCalDet();
505 // Take the noise and Pad status from the previous OCDB
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");
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)
524 AliTRDCalSingleChamberStatus *calROC = calPadStatusPrevious->GetCalROC(idet);
525 for(Int_t k = 0; k < calROC->GetNchannels(); k++){
526 calROC->SetStatus(k,AliTRDCalPadStatus::kMasked);
532 // Loop over detectors for check
533 for (Int_t det=0; det<AliTRDgeometry::kNdet; ++det) {
536 AliTRDCalROC *calROCPreviousNoise = calPadPrevious->GetCalROC(det);
537 AliTRDCalROC *calROCNoise = calPad2->GetCalROC(det);
540 AliTRDCalSingleChamberStatus *calROCPreviousStatus = calPadStatusPrevious->GetCalROC(det);
541 AliTRDCalSingleChamberStatus *calROCStatus = calPadStatus->GetCalROC(det);
544 // loop over first half and second half chamber
545 for(Int_t half = 0; half < 2; half++){
547 Bool_t data = AreThereDataPedestal(calROCStatus,(Bool_t)half);
548 //printf("There are data for the detector %d the half %d: %d\n",det,half,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
554 SetDefaultStatus(*calROCStatus,(Bool_t)half);
555 SetDefaultNoise(*calROCNoise,(Bool_t)half);
558 // if data, set to previous value
559 SetStatus(*calROCStatus,calROCPreviousStatus,(Bool_t)half);
560 SetNoise(*calROCNoise,calROCPreviousNoise,(Bool_t)half);
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");
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");
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");
608 //__________________________________________________________________
609 Bool_t AliTRDPreprocessor::AreThereDataPedestal(const AliTRDCalSingleChamberStatus * const calROCStatus
614 // Data for this half chamber
617 Bool_t data = kFALSE;
618 Int_t nCols = calROCStatus->GetNcols();
620 Int_t nColE = (Int_t) nCols/2 - 2;
626 Int_t totalnumberofpads = 0;
627 Int_t totalnumberofdata = 0;
629 for(Int_t col = nCol0; col < nColE; col++){
630 for(Int_t row = 0; row < calROCStatus->GetNrows(); row++){
632 //printf("ismasked %d\n",(Int_t)calROCStatus->IsMasked(col,row));
633 if(!calROCStatus->GetStatus(col,row)) {
639 if(totalnumberofdata < (Int_t)(totalnumberofpads/2)) data = kFALSE;
644 //__________________________________________________________________
645 void AliTRDPreprocessor::SetDefaultStatus(AliTRDCalSingleChamberStatus &calROCStatus, Bool_t second){
648 // default status for this half chamber
651 Int_t nCols = calROCStatus.GetNcols();
653 Int_t nColE = (Int_t) nCols/2;
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);
664 //__________________________________________________________________
665 void AliTRDPreprocessor::SetStatus(AliTRDCalSingleChamberStatus &calROCStatus, AliTRDCalSingleChamberStatus *calROCStatusPrevious,Bool_t second){
668 // previous status for this half chamber
671 Int_t nCols = calROCStatus.GetNcols();
673 Int_t nColE = (Int_t) nCols/2;
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));
684 //__________________________________________________________________
685 void AliTRDPreprocessor::SetDefaultNoise(AliTRDCalROC &calROCNoise, Bool_t second){
688 // default noise for this half chamber
691 Int_t nCols = calROCNoise.GetNcols();
693 Int_t nColE = (Int_t) nCols/2;
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);
704 //__________________________________________________________________
705 void AliTRDPreprocessor::SetNoise(AliTRDCalROC &calROCNoise, AliTRDCalROC *calROCNoisePrevious, Bool_t second){
708 // previous noise for this half chamber
711 Int_t nCols = calROCNoise.GetNcols();
713 Int_t nColE = (Int_t) nCols/2;
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));
724 //______________________________________________________________________________________________
725 Bool_t AliTRDPreprocessor::ExtractDriftVelocityDAQ()
728 // Drift velocity DA running on monitoring servers at the DAQ
731 Bool_t error = kFALSE;
733 // Objects for HLT and DAQ zusammen
734 AliTRDCalibraFit *calibra = AliTRDCalibraFit::Instance();
735 AliCDBMetaData metaData;
736 metaData.SetBeamPeriod(0);
737 metaData.SetResponsible("Raphaelle Bailhache");
738 metaData.SetComment("TRD calib test");
739 // Store the infos for the detector
741 md1.SetObjectClassName("AliTRDCalDet");
742 md1.SetResponsible("Raphaelle Bailhache");
743 md1.SetBeamPeriod(0);
744 md1.SetComment("TRD calib test");
745 // Store the infos for the pads
747 md2.SetObjectClassName("AliTRDCalPad");
748 md2.SetResponsible("Raphaelle Bailhache");
749 md2.SetBeamPeriod(0);
750 md2.SetComment("TRD calib test");
752 // Take the file from the DAQ file exchange server
753 TList *listdaq = GetFileSources(kDAQ,"VDRIFT");
755 Log("No list found for vdrift (DAQ)");
759 if(listdaq->GetSize() !=1){
760 Log(Form("Problem on the size of the list: %d (DAQ)",listdaq->GetSize()));
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)");
774 TFile *filedaq = TFile::Open(fileName);
775 TProfile2D *histodriftvelocity = (TProfile2D *) filedaq->Get("PH2d");
776 if (histodriftvelocity) {
778 // store as reference data
779 if(!StoreReferenceData("DAQData","VdriftT0",(TObject *) histodriftvelocity,&metaData)){
780 Log("Error storing 2D Profile for vdrift from the DAQ");
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);
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();
793 Int_t nbfitSuccess = calibra->GetNumberFitSuccess();
794 Int_t nbE = calibra->GetNumberEnt();
796 // if enough statistics store the results
798 (nbfit >= 0.5*nbE) && (nbE > 30) && (nbfitSuccess > 30)) {
799 // create the cal objects
800 calibra->RemoveOutliers(1,kTRUE);
801 calibra->PutMeanValueOtherVectorFit(1,kTRUE);
802 calibra->RemoveOutliers2(kTRUE);
803 calibra->PutMeanValueOtherVectorFit2(1,kTRUE);
804 TObjArray object = calibra->GetVectorFit();
805 AliTRDCalDet *objdriftvelocitydet = calibra->CreateDetObjectVdrift(&object,kTRUE);
806 // TObject *objdriftvelocitypad = calibra->CreatePadObjectVdrift();
807 object = calibra->GetVectorFit2();
808 AliTRDCalDet *objtime0det = calibra->CreateDetObjectT0(&object,kTRUE);
809 // TObject *objtime0pad = calibra->CreatePadObjectT0();
810 calibra->ResetVectorFit();
812 if(!Store("Calib","ChamberVdrift" ,(TObject *) objdriftvelocitydet,&md1,0,kTRUE)){
813 Log("Error storing the calibration object for the chamber vdrift (DAQ)");
816 if(!Store("Calib","ChamberT0" ,(TObject *) objtime0det ,&md1,0,kTRUE)){
817 Log("Error storing the calibration object for the chamber t0 (DAQ)");
820 // if(!Store("Calib","LocalVdrift" ,(TObject *) objdriftvelocitypad,&md2,0,kTRUE)){
821 // Log("Error storing the calibration object for the local drift velocity (DAQ)");
824 // if(!Store("Calib","LocalT0" ,(TObject *) objtime0pad ,&md2,0,kTRUE)){
825 // Log("Error storing the calibration object for the local time0 (DAQ)");
830 Log("Not enough statistics for the average pulse height (DAQ)");
840 //______________________________________________________________________________________________
841 Bool_t AliTRDPreprocessor::ExtractHLT()
844 // Gain, vdrift and PRF calibration running on HLT
845 // return kTRUE if NULL pointer to the list
848 Bool_t error = kFALSE;
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
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
864 md2.SetObjectClassName("AliTRDCalPad");
865 md2.SetResponsible("Raphaelle Bailhache");
866 md2.SetBeamPeriod(0);
867 md2.SetComment("TRD calib test");
869 // Take the file from the HLT file exchange server
870 TList *listhlt = GetFileSources(kHLT,"GAINDRIFTPRF");
872 Log("No list found for the HLT");
876 if(listhlt->GetSize() != 1) {
877 Log(Form("Problem on the size of the list: %d (HLT)",listhlt->GetSize()));
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)");
892 TFile *filehlt = TFile::Open(fileName);
895 TH2I *histogain = (TH2I *) filehlt->Get("CH2d");
897 histogain->SetDirectory(0);
898 // store the reference data
899 if(!StoreReferenceData("HLTData","Gain",(TObject *) histogain,&metaData)){
900 Log("Error storing 2D histos for gain");
904 Log("Take the CH reference data. Now we will try to fit\n");
905 calibra->SetMinEntries(800); // If there is less than 1000 entries in the histo: no fit
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();
913 (nbfit >= 0.5*nbE) && (nbE > 30)) {
914 // create the cal objects
915 calibra->PutMeanValueOtherVectorFit(1,kTRUE);
916 TObjArray object = calibra->GetVectorFit();
917 AliTRDCalDet *objgaindet = calibra->CreateDetObjectGain(&object);
918 // TObject *objgainpad = calibra->CreatePadObjectGain();
920 if(!Store("Calib","ChamberGainFactor",(TObject *) objgaindet ,&md1,0,kTRUE)){
921 Log("Error storing the calibration object for the chamber gain");
924 // if(!Store("Calib","LocalGainFactor" ,(TObject *) objgainpad ,&md2,0,kTRUE)){
925 // Log("Error storing the calibration object for the local gain factor");
929 calibra->ResetVectorFit();
934 TProfile2D *histodriftvelocity = (TProfile2D *) filehlt->Get("PH2d");
935 if (histodriftvelocity) {
936 histodriftvelocity->SetDirectory(0);
937 // store the reference data
938 if(!StoreReferenceData("HLTData","VdriftT0",(TObject *) histodriftvelocity,&metaData)){
939 Log("Error storing 2D Profile for average pulse height (HLT)");
943 Log("Take the PH reference data. Now we will try to fit\n");
944 calibra->SetMinEntries(800*20); // If there is less than 20000
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();
949 Int_t nbfitSuccess = calibra->GetNumberFitSuccess();
950 Int_t nbE = calibra->GetNumberEnt();
953 (nbfit >= 0.5*nbE) && (nbE > 30) && (nbfitSuccess > 30)) {
954 // create the cal objects
955 calibra->RemoveOutliers(1,kTRUE);
956 calibra->PutMeanValueOtherVectorFit(1,kTRUE);
957 calibra->RemoveOutliers2(kTRUE);
958 calibra->PutMeanValueOtherVectorFit2(1,kTRUE);
959 TObjArray object = calibra->GetVectorFit();
960 AliTRDCalDet *objdriftvelocitydet = calibra->CreateDetObjectVdrift(&object,kTRUE);
961 // TObject *objdriftvelocitypad = calibra->CreatePadObjectVdrift();
962 object = calibra->GetVectorFit2();
963 AliTRDCalDet *objtime0det = calibra->CreateDetObjectT0(&object,kTRUE);
964 //TObject *objtime0pad = calibra->CreatePadObjectT0();
966 if(!Store("Calib","ChamberVdrift" ,(TObject *) objdriftvelocitydet,&md1,0,kTRUE)){
967 Log("Error storing the calibration object for the chamber vdrift (HLT)");
970 if(!Store("Calib","ChamberT0" ,(TObject *) objtime0det ,&md1,0,kTRUE)){
971 Log("Error storing the calibration object for the chamber t0 (HLT)");
974 // if(!Store("Calib","LocalVdrift" ,(TObject *) objdriftvelocitypad,&md2,0,kTRUE)){
975 // Log("Error storing the calibration object for the local drift velocity (HLT)");
978 // if(!Store("Calib","LocalT0" ,(TObject *) objtime0pad ,&md2,0,kTRUE)){
979 // Log("Error storing the calibration object for the local time0 (HLT)");
984 calibra->ResetVectorFit();
989 TProfile2D *histoprf = (TProfile2D *) filehlt->Get("PRF2d");
991 histoprf->SetDirectory(0);
992 // store reference data
993 if(!StoreReferenceData("HLTData","PRF",(TObject *) histoprf,&metaData)){
994 Log("Error storing the 2D Profile for Pad Response Function");
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
1007 (nbfit >= 0.95*nbE) && (nbE > 30)) {
1008 // create cal pad objects
1009 TObjArray object = calibra->GetVectorFit();
1010 TObject *objPRFpad = calibra->CreatePadObjectPRF(&object);
1012 if(!Store("Calib","PRFWidth" ,(TObject *) objPRFpad ,&md2,0,kTRUE)){
1013 Log("Error storing the calibration object for the Pad Response Function");
1017 calibra->ResetVectorFit();
1020 }// if fileNameEntry
1027 //_____________________________________________________________________________
1028 UInt_t AliTRDPreprocessor::ProcessDCSConfigData()
1030 // process the configuration of FEE, PTR and GTU
1031 // reteive XML filei(s) from the DCS FXS
1032 // parse it/them and store TObjArrays in the CDB
1034 Log("Processing the DCS config summary files.");
1036 if(fCalDCSObjSOR) delete fCalDCSObjSOR;
1037 if(fCalDCSObjEOR) delete fCalDCSObjEOR;
1040 TString esor[2] = {"SOR", "EOR"};
1041 // get the XML files
1042 xmlFile[0] = GetFile(kDCS,"CONFIGSUMMARYSOR","");
1043 xmlFile[1] = GetFile(kDCS,"CONFIGSUMMARYEOR","");
1047 for (Int_t iFile=0; iFile<2; iFile++) {
1049 // check if the file are there
1050 if (xmlFile[iFile].IsNull()) {
1051 Log(Form("Warning: %s file not found!", esor[iFile].Data()));
1054 Log(Form("%s file found: %s", esor[iFile].Data(), xmlFile[iFile].Data()));
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()));
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()));
1069 Log(Form("%s file is valid.", esor[iFile].Data()));
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()));
1077 Log(Form("%s XML content is well-formed.", esor[iFile].Data()));
1079 // create parser and parse
1080 TSAXParser saxParser;
1081 AliTRDSaxHandler saxHandler;
1082 saxParser.ConnectToHandler("AliTRDSaxHandler", &saxHandler);
1083 saxParser.ParseFile(xmlFile[iFile].Data());
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()));
1090 Log(Form("%s XML validation OK.", esor[iFile].Data()));
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()));
1097 Log(Form("%s SAX handler reports no errors.", esor[iFile].Data()));
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;
1109 if (!fCalDCSObjSOR && !fCalDCSObjEOR) { Log("ERROR: Failed reading both files!"); return 1; }
1111 // put both objects in one TObjArray to store them
1112 TObjArray* calObjArray = new TObjArray(2);
1113 calObjArray->SetOwner();
1115 if (fCalDCSObjSOR) {
1116 calObjArray->AddAt(fCalDCSObjSOR,0);
1117 Log("TRDCalDCS object for SOR created.");
1119 if (fCalDCSObjEOR) {
1120 calObjArray->AddAt(fCalDCSObjEOR,1);
1121 Log("TRDCalDCS object for EOR created.");
1124 // store the DCS calib data in the CDB
1125 AliCDBMetaData metaData1;
1126 metaData1.SetBeamPeriod(0);
1127 metaData1.SetResponsible("Frederick Kramer");
1128 metaData1.SetComment("DCS configuration data in two AliTRDCalDCSv2 objects in one TObjArray (0:SOR, 1:EOR).");
1129 if (!Store("Calib", "DCS", calObjArray, &metaData1, 0, kTRUE)) { Log("ERROR: Storing DCS config data object failed!"); return 1; }
1133 Log("SUCCESS: Processing of the DCS config summary file DONE.");