X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=TRD%2FAliTRDPreprocessor.cxx;h=d8e81736d539470234c70e0ba16fa7d4af84445f;hb=c36ddf5246319665c2fc9a3274eedc0a0437cd45;hp=9df5084073602d51b82ae7aca2c5cf9aae692b23;hpb=197b835efb17e6733fb256a8231f444f8c91d68e;p=u%2Fmrichter%2FAliRoot.git diff --git a/TRD/AliTRDPreprocessor.cxx b/TRD/AliTRDPreprocessor.cxx index 9df50840736..d8e81736d53 100644 --- a/TRD/AliTRDPreprocessor.cxx +++ b/TRD/AliTRDPreprocessor.cxx @@ -25,20 +25,22 @@ // and stores both reference data and spline fits results // // in the CDB // // // -// Author: // +// Authors: // // R. Bailhache (R.Bailhache@gsi.de) // +// J. Book (jbook@ikf.uni-frankfurt.de) // // W. Monange (w.monange@gsi.de) // +// F. Kramer (kramer@ikf.uni-frankfurt.de) // // // //////////////////////////////////////////////////////////////////////////// +#include + #include #include -#include #include #include #include -#include -#include "TSAXParser.h" +#include #include "AliCDBMetaData.h" #include "AliLog.h" @@ -49,27 +51,47 @@ #include "AliTRDCalibraMode.h" #include "AliTRDCalibPadStatus.h" #include "AliTRDSaxHandler.h" -#include "Cal/AliTRDCalDet.h" +#include "AliTRDgeometry.h" +#include "AliTRDCalibChamberStatus.h" +#include "Cal/AliTRDCalPad.h" #include "Cal/AliTRDCalPadStatus.h" -#include "Cal/AliTRDCalDCS.h" +#include "Cal/AliTRDCalDCSv2.h" +#include "Cal/AliTRDCalSingleChamberStatus.h" +#include "Cal/AliTRDCalChamberStatus.h" +#include "Cal/AliTRDCalROC.h" ClassImp(AliTRDPreprocessor) //______________________________________________________________________________________________ AliTRDPreprocessor::AliTRDPreprocessor(AliShuttleInterface *shuttle) :AliPreprocessor("TRD", shuttle) + ,fCalDCSObjSOR(0) + ,fCalDCSObjEOR(0) ,fVdriftHLT(0) { // // Constructor // - AddRunType("PHYSICS"); - AddRunType("STANDALONE"); - AddRunType("PEDESTAL"); + AddRunType("PHYSICS"); + AddRunType("STANDALONE"); + AddRunType("PEDESTAL"); + AddRunType("DAQ"); + + +} +//______________________________________________________________________________________________ + AliTRDPreprocessor::AliTRDPreprocessor(const AliTRDPreprocessor& ) : + AliPreprocessor("TRD",0), + fCalDCSObjSOR(0), + fCalDCSObjEOR(0), + fVdriftHLT(0) +{ + + Fatal("AliTRDPreprocessor", "copy constructor not implemented"); + } - //______________________________________________________________________________________________ AliTRDPreprocessor::~AliTRDPreprocessor() { @@ -77,8 +99,16 @@ AliTRDPreprocessor::~AliTRDPreprocessor() // Destructor // -} + if (fCalDCSObjSOR ) delete fCalDCSObjSOR; + if (fCalDCSObjEOR ) delete fCalDCSObjEOR; +} +//______________________________________________________________________________________________ +AliTRDPreprocessor& AliTRDPreprocessor::operator = (const AliTRDPreprocessor& ) +{ + Fatal("operator =", "assignment operator not implemented"); + return *this; +} //______________________________________________________________________________________________ void AliTRDPreprocessor::Initialize(Int_t run, UInt_t startTime, UInt_t endTime) { @@ -87,7 +117,7 @@ void AliTRDPreprocessor::Initialize(Int_t run, UInt_t startTime, UInt_t endTime) // AliPreprocessor::Initialize(run,startTime,endTime); - + } //______________________________________________________________________________________________ @@ -99,36 +129,41 @@ UInt_t AliTRDPreprocessor::Process(TMap* dcsAliasMap) TString runType = GetRunType(); Log(Form("runtype %s\n",runType.Data())); - + // always process the configuration data - Int_t resultDCSC = ProcessDCSConfigData(); - // if there was an error, return with its code - if (resultDCSC != 0) return resultDCSC; + Int_t dCSConfigReturn = ProcessDCSConfigData(); + if(dCSConfigReturn) return dCSConfigReturn; if (runType=="PEDESTAL"){ if(ExtractPedestals()) return 1; return 0; } - if ((runType=="PHYSICS") || (runType=="STANDALONE")){ + if ((runType=="PHYSICS") || (runType=="STANDALONE") || (runType=="DAQ")){ // DCS if(ProcessDCS(dcsAliasMap)) return 1; - // HLT if On - //TString runPar = GetRunParameter("HLTStatus"); - //if(runPar=="1") { - if(GetHLTStatus()) { - if(ExtractHLT()) return 1; - } - // DAQ if HLT failed - if(!fVdriftHLT) { - if(ExtractDriftVelocityDAQ()) return 1; + if(runType=="PHYSICS"){ + // HLT if On + //TString runPar = GetRunParameter("HLTStatus"); + //if(runPar=="1") { + if(GetHLTStatus()) { + //if(ExtractHLT()) return 1; // for testing! + ExtractHLT(); + } + // DAQ if HLT failed + if(!fVdriftHLT) { + //if(ExtractDriftVelocityDAQ()) return 1; + ExtractDriftVelocityDAQ(); // for testing! + } } + //if((runType=="PHYSICS") || (runType=="STANDALONE")) { + // if(ExtractHalfChamberStatusDAQ()) return 1; + //} } return 0; } - //______________________________________________________________________________ Bool_t AliTRDPreprocessor::ProcessDCS() { @@ -160,7 +195,7 @@ Bool_t AliTRDPreprocessor::ProcessDCS(TMap *dcsAliasMap) Log("****** DCS ******\n"); - TObjArray * list=AliTRDSensorArray::GetList (); + TObjArray * list=AliTRDSensorArray::GetList(); if (list == 0x0) { Log ("Error during AliTRDSensorArray::GetList"); @@ -192,19 +227,19 @@ Bool_t AliTRDPreprocessor::ProcessDCS(TMap *dcsAliasMap) if (nGraph [iAlias] == 0) { Log("No TGraph for this dcsDatapointAlias : not stored"); results [iAlias] = kFALSE; - error = kTRUE; + //error = kTRUE; continue; } oneTRDDCS->SetGraph(map); - results[iAlias]=Store("Calib", oneTRDDCS->GetStoreName().Data(), oneTRDDCS, &metaData, 0, kTRUE); + results[iAlias]=Store("Calib", oneTRDDCS->GetStoreName().Data(), oneTRDDCS, &metaData, 0, kFALSE); delete map; //results [iAlias] = StoreReferenceData("Calib", oneTRDDCS->GetStoreName ().Data (), oneTRDDCS, &metaData); if (!results[iAlias]) { AliError("Problem during StoreRef DCS"); - error=kTRUE; + //error=kTRUE; } //BEGIN TEST (should not be removed ...) @@ -240,6 +275,16 @@ Bool_t AliTRDPreprocessor::ProcessDCS(TMap *dcsAliasMap) //END TEST } + + // Check errors + Int_t nbCount = 0; + for (Int_t iAlias = 0; iAlias < nEntries; iAlias++) { + if (results[iAlias]) { + nbCount++; + } + } + if(nbCount == 0) error = kTRUE; + Log (" Summury of DCS :\n"); Log (Form("%30s %10s %10s", "dcsDatapointAlias", "Stored ?", "# graph")); @@ -252,20 +297,119 @@ Bool_t AliTRDPreprocessor::ProcessDCS(TMap *dcsAliasMap) } Log ("*********** End of DCS **********"); - delete results; - delete nGraph; + delete [] results; + delete [] nGraph; return error; } +//______________________________________________________________________________________________ +Bool_t AliTRDPreprocessor::ExtractHalfChamberStatusDAQ() +{ + // + // Half chamber status algorithm running on DAQ + // + + Bool_t error = kFALSE; + + AliCDBMetaData metaData; + metaData.SetBeamPeriod(0); + metaData.SetResponsible("Raphaelle Bailhache"); + metaData.SetComment("TRD calib test"); + + // Take the output of the DA on DAQ + TList * listpad = GetFileSources(kDAQ,"HALFCHAMBERSTATUS"); + if (!listpad) { + Log("No list found for the HalfChamberStatus"); + return kTRUE; + } + + AliTRDCalibChamberStatus *calPed = 0x0; + + // loop through all files (only one normally) + UInt_t index = 0; + while (listpad->At(index)!=NULL) { + TObjString* fileNameEntry = (TObjString*) listpad->At(index); + if (fileNameEntry != NULL) + { + TString fileName = GetFile(kDAQ, "HALFCHAMBERSTATUS", + fileNameEntry->GetString().Data()); + if(fileName.Length() ==0){ + Log(Form("Error by retrieving the file %d for the halfchamberstatus",(Int_t)index)); + delete listpad; + return kTRUE; + } + + TFile *f = TFile::Open(fileName); + f->GetObject("calibchamberstatus",calPed); + + if(calPed) { + + // store as reference data + TString name("HalfChamberStatus"); + if(!StoreReferenceData("DAQData",(const char *)name,(TObject *) calPed,&metaData)){ + Log(Form("Error storing AliTRDCalibPadStatus object %d as reference data",(Int_t)index)); + error = kTRUE; + } + } // calPed + else Log(Form("Error getting AliTRDCalibChamberStatus onject from file")); + + } // fileNameEntry + ++index; + }// while (list) + + Log(Form("%d elements found in the list for the halfchamberstatus",(Int_t)index)); + if(index!=1){ + delete listpad; + return kTRUE; + } + + // + // Produce the AliTRDCalChamberStatus name calHalfChamberStatus + // + AliTRDCalChamberStatus *calHalfChamberStatus = 0x0; + if(calPed) { + //calPed->AnalyseHisto(); // check number of events, create calHalfChamberStatus (done on DAQ) + if(fCalDCSObjEOR) { + calPed->CheckEORStatus((AliTRDCalDCSv2 *)fCalDCSObjEOR); + } + calHalfChamberStatus=(AliTRDCalChamberStatus *)calPed->GetCalChamberStatus(); + } + + // + // Store + // + AliCDBMetaData md3; + md3.SetObjectClassName("AliTRDCalChamberStatus"); + md3.SetResponsible("Raphaelle Bailhache"); + md3.SetBeamPeriod(1); + md3.SetComment("TRD calib test"); + if(!Store("Calib","ChamberStatus" ,(TObject *)calHalfChamberStatus, &md3, 0, kTRUE)){ + Log("Error storing the pedestal"); + delete listpad; + return kTRUE; + } + + delete listpad; + return error; + +} //______________________________________________________________________________________________ Bool_t AliTRDPreprocessor::ExtractPedestals() { // // Pedestal running on LDCs at the DAQ // - + + // + // The reference data are stored in: + // PadStatus1 for sm-00-01-02-09-10-11 + // PadStatus2 for sm-03-04-05-12-13-14 + // PadStatus3 for sm-06-07-08-15-16-17 + // PadStatus0 if nothing found..means problems + // + Bool_t error = kFALSE; // Init a AliTRDCalibPadStatus @@ -303,8 +447,6 @@ Bool_t AliTRDPreprocessor::ExtractPedestals() if(calPed){ - Int_t sm = -1; - // analyse //calPed->AnalyseHisto(); @@ -313,7 +455,6 @@ Bool_t AliTRDPreprocessor::ExtractPedestals() AliTRDCalROC *rocMean = calPed->GetCalRocMean(idet, kFALSE); if ( rocMean ) { calPedSum.SetCalRocMean(rocMean,idet); - sm = (Int_t) (idet / 30); } AliTRDCalROC *rocRMS = calPed->GetCalRocRMS(idet, kFALSE); if ( rocRMS ) { @@ -331,7 +472,7 @@ Bool_t AliTRDPreprocessor::ExtractPedestals() // store as reference data TString name("PadStatus"); - name += sm; + name += index; if(!StoreReferenceData("DAQData",(const char *)name,(TObject *) calPed,&metaData)){ Log(Form("Error storing AliTRDCalibPadStatus object %d as reference data",(Int_t)index)); error = kTRUE; @@ -349,11 +490,83 @@ Bool_t AliTRDPreprocessor::ExtractPedestals() } // - // Store pedestal entry to OCDB + // Create pedestal // // Create Pad Status AliTRDCalPadStatus *calPadStatus = calPedSum.CreateCalPadStatus(); + // Create Noise + //Make the AliTRDCalPad + AliTRDCalPad *calPad2 = calPedSum.CreateCalPad(); + //Make the AliTRDCalDet correspondant + AliTRDCalDet *calDet = calPedSum.CreateCalDet(); + + // + // Take the noise and Pad status from the previous OCDB + // + + AliTRDCalPad *calPadPrevious=0; + AliCDBEntry* entry = GetFromOCDB("Calib", "PadNoise"); + if (entry) calPadPrevious = (AliTRDCalPad*)entry->GetObject(); + if ( calPadPrevious==NULL ) { + Log("AliTRDPreprocsessor: No previous TRD pad noise entry available.\n"); + calPadPrevious = new AliTRDCalPad("PadNoise", "PadNoise"); + } + + AliTRDCalPadStatus *calPadStatusPrevious=0; + entry = GetFromOCDB("Calib", "PadStatus"); + if (entry) calPadStatusPrevious = (AliTRDCalPadStatus*)entry->GetObject(); + if ( calPadStatusPrevious==NULL ) { + Log("AliTRDPreprocsessor: No previous TRD pad status entry available.\n"); + calPadStatusPrevious = new AliTRDCalPadStatus("padstatus", "padstatus"); + for (Int_t idet=0; idet<540; ++idet) + { + AliTRDCalSingleChamberStatus *calROC = calPadStatusPrevious->GetCalROC(idet); + for(Int_t k = 0; k < calROC->GetNchannels(); k++){ + calROC->SetStatus(k,AliTRDCalPadStatus::kMasked); + } + } + } + + + // Loop over detectors for check + for (Int_t det=0; detGetCalROC(det); + AliTRDCalROC *calROCNoise = calPad2->GetCalROC(det); + + // padstatus + AliTRDCalSingleChamberStatus *calROCPreviousStatus = calPadStatusPrevious->GetCalROC(det); + AliTRDCalSingleChamberStatus *calROCStatus = calPadStatus->GetCalROC(det); + + + // loop over first half and second half chamber + for(Int_t half = 0; half < 2; half++){ + + Bool_t data = AreThereDataPedestal(calROCStatus,(Bool_t)half); + //printf("There are data for the detector %d the half %d: %d\n",det,half,data); + if(!data){ + // look if data in the OCDB + Bool_t dataPrevious = AreThereDataPedestal(calROCPreviousStatus,(Bool_t)half); + // if no data at all, set to default value + if(!dataPrevious){ + SetDefaultStatus(*calROCStatus,(Bool_t)half); + SetDefaultNoise(*calROCNoise,(Bool_t)half); + } + else{ + // if data, set to previous value + SetStatus(*calROCStatus,calROCPreviousStatus,(Bool_t)half); + SetNoise(*calROCNoise,calROCPreviousNoise,(Bool_t)half); + } + } + } + } + + // + // Store + // + AliCDBMetaData md3; md3.SetObjectClassName("AliTRDCalPadStatus"); md3.SetResponsible("Raphaelle Bailhache"); @@ -365,9 +578,6 @@ Bool_t AliTRDPreprocessor::ExtractPedestals() return kTRUE; } - // Create Noise - //Make the AliTRDCalPad - AliTRDCalPad *calPad2 = calPedSum.CreateCalPad(); AliCDBMetaData md4; md4.SetObjectClassName("AliTRDCalPad"); md4.SetResponsible("Raphaelle Bailhache"); @@ -378,8 +588,7 @@ Bool_t AliTRDPreprocessor::ExtractPedestals() delete listpad; return kTRUE; } - //Make the AliTRDCalDet correspondant - AliTRDCalDet *calDet = calPedSum.CreateCalDet(); + AliCDBMetaData md5; md5.SetObjectClassName("AliTRDCalDet"); md5.SetResponsible("Raphaelle Bailhache"); @@ -393,9 +602,125 @@ Bool_t AliTRDPreprocessor::ExtractPedestals() delete listpad; return error; + +} + +//__________________________________________________________________ +Bool_t AliTRDPreprocessor::AreThereDataPedestal(const AliTRDCalSingleChamberStatus * const calROCStatus + , Bool_t second) +{ + + // + // Data for this half chamber + // + + Bool_t data = kFALSE; + Int_t nCols = calROCStatus->GetNcols(); + Int_t nCol0 = 0; + Int_t nColE = (Int_t) nCols/2 - 2; + if(second) { + nCol0 = nColE + 4; + nColE = nCols; + } + + Int_t totalnumberofpads = 0; + Int_t totalnumberofdata = 0; + + for(Int_t col = nCol0; col < nColE; col++){ + for(Int_t row = 0; row < calROCStatus->GetNrows(); row++){ + totalnumberofpads++; + //printf("ismasked %d\n",(Int_t)calROCStatus->IsMasked(col,row)); + if(!calROCStatus->GetStatus(col,row)) { + data = kTRUE; + totalnumberofdata++; + } + } + } + if(totalnumberofdata < (Int_t)(totalnumberofpads/2)) data = kFALSE; + + return data; + +} +//__________________________________________________________________ +void AliTRDPreprocessor::SetDefaultStatus(AliTRDCalSingleChamberStatus &calROCStatus, Bool_t second){ + + // + // default status for this half chamber + // + + Int_t nCols = calROCStatus.GetNcols(); + Int_t nCol0 = 0; + Int_t nColE = (Int_t) nCols/2; + if(second) { + nCol0 = nColE; + nColE = nCols; + } + for(Int_t col = nCol0; col < nColE; col++){ + for(Int_t row = 0; row < calROCStatus.GetNrows(); row++){ + calROCStatus.SetStatus(col,row,0); + } + } +} +//__________________________________________________________________ +void AliTRDPreprocessor::SetStatus(AliTRDCalSingleChamberStatus &calROCStatus, AliTRDCalSingleChamberStatus *calROCStatusPrevious,Bool_t second){ + + // + // previous status for this half chamber + // + + Int_t nCols = calROCStatus.GetNcols(); + Int_t nCol0 = 0; + Int_t nColE = (Int_t) nCols/2; + if(second) { + nCol0 = nColE; + nColE = nCols; + } + for(Int_t col = nCol0; col < nColE; col++){ + for(Int_t row = 0; row < calROCStatus.GetNrows(); row++){ + calROCStatus.SetStatus(col,row,calROCStatusPrevious->GetStatus(col,row)); + } + } +} +//__________________________________________________________________ +void AliTRDPreprocessor::SetDefaultNoise(AliTRDCalROC &calROCNoise, Bool_t second){ + + // + // default noise for this half chamber + // + Int_t nCols = calROCNoise.GetNcols(); + Int_t nCol0 = 0; + Int_t nColE = (Int_t) nCols/2; + if(second) { + nCol0 = nColE; + nColE = nCols; + } + for(Int_t col = nCol0; col < nColE; col++){ + for(Int_t row = 0; row < calROCNoise.GetNrows(); row++){ + calROCNoise.SetValue(col,row,0.12); + } + } } +//__________________________________________________________________ +void AliTRDPreprocessor::SetNoise(AliTRDCalROC &calROCNoise, AliTRDCalROC *calROCNoisePrevious, Bool_t second){ + + // + // previous noise for this half chamber + // + Int_t nCols = calROCNoise.GetNcols(); + Int_t nCol0 = 0; + Int_t nColE = (Int_t) nCols/2; + if(second) { + nCol0 = nColE; + nColE = nCols; + } + for(Int_t col = nCol0; col < nColE; col++){ + for(Int_t row = 0; row < calROCNoise.GetNrows(); row++){ + calROCNoise.SetValue(col,row,calROCNoisePrevious->GetValue(col,row)); + } + } +} //______________________________________________________________________________________________ Bool_t AliTRDPreprocessor::ExtractDriftVelocityDAQ() { @@ -465,36 +790,41 @@ Bool_t AliTRDPreprocessor::ExtractDriftVelocityDAQ() Int_t nbtg = 6*4*18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb0(1)) + 6* 18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb2(1)); Int_t nbfit = calibra->GetNumberFit(); + Int_t nbfitSuccess = calibra->GetNumberFitSuccess(); Int_t nbE = calibra->GetNumberEnt(); // if enough statistics store the results if ((nbtg > 0) && - (nbfit >= 0.95*nbE)) { + (nbfit >= 0.5*nbE) && (nbE > 30) && (nbfitSuccess > 30)) { // create the cal objects + calibra->RemoveOutliers(1,kTRUE); + calibra->PutMeanValueOtherVectorFit(1,kTRUE); + calibra->RemoveOutliers2(kTRUE); + calibra->PutMeanValueOtherVectorFit2(1,kTRUE); TObjArray object = calibra->GetVectorFit(); AliTRDCalDet *objdriftvelocitydet = calibra->CreateDetObjectVdrift(&object,kTRUE); - TObject *objdriftvelocitypad = calibra->CreatePadObjectVdrift(); + // TObject *objdriftvelocitypad = calibra->CreatePadObjectVdrift(); object = calibra->GetVectorFit2(); AliTRDCalDet *objtime0det = calibra->CreateDetObjectT0(&object,kTRUE); - TObject *objtime0pad = calibra->CreatePadObjectT0(); + // TObject *objtime0pad = calibra->CreatePadObjectT0(); calibra->ResetVectorFit(); // store - if(!Store("Calib","ChamberVdrift" ,(TObject *) objdriftvelocitydet,&md1,0,kTRUE)){ - Log("Error storing the calibration object for the chamber vdrift (DAQ)"); - error = kTRUE; - } - if(!Store("Calib","ChamberT0" ,(TObject *) objtime0det ,&md1,0,kTRUE)){ - Log("Error storing the calibration object for the chamber t0 (DAQ)"); - error = kTRUE; - } - if(!Store("Calib","LocalVdrift" ,(TObject *) objdriftvelocitypad,&md2,0,kTRUE)){ - Log("Error storing the calibration object for the local drift velocity (DAQ)"); - error = kTRUE; - } - if(!Store("Calib","LocalT0" ,(TObject *) objtime0pad ,&md2,0,kTRUE)){ - Log("Error storing the calibration object for the local time0 (DAQ)"); - error = kTRUE; - } + if(!Store("Calib","ChamberVdrift" ,(TObject *) objdriftvelocitydet,&md1,0,kTRUE)){ + Log("Error storing the calibration object for the chamber vdrift (DAQ)"); + error = kTRUE; + } + if(!Store("Calib","ChamberT0" ,(TObject *) objtime0det ,&md1,0,kTRUE)){ + Log("Error storing the calibration object for the chamber t0 (DAQ)"); + error = kTRUE; + } + // if(!Store("Calib","LocalVdrift" ,(TObject *) objdriftvelocitypad,&md2,0,kTRUE)){ + // Log("Error storing the calibration object for the local drift velocity (DAQ)"); + // error = kTRUE; + // } + // if(!Store("Calib","LocalT0" ,(TObject *) objtime0pad ,&md2,0,kTRUE)){ + // Log("Error storing the calibration object for the local time0 (DAQ)"); + // error = kTRUE; + // } } else{ Log("Not enough statistics for the average pulse height (DAQ)"); @@ -563,8 +893,8 @@ Bool_t AliTRDPreprocessor::ExtractHLT() // gain TH2I *histogain = (TH2I *) filehlt->Get("CH2d"); - histogain->SetDirectory(0); if (histogain) { + histogain->SetDirectory(0); // store the reference data if(!StoreReferenceData("HLTData","Gain",(TObject *) histogain,&metaData)){ Log("Error storing 2D histos for gain"); @@ -572,7 +902,7 @@ Bool_t AliTRDPreprocessor::ExtractHLT() } // analyse Log("Take the CH reference data. Now we will try to fit\n"); - calibra->SetMinEntries(1000); // If there is less than 1000 entries in the histo: no fit + calibra->SetMinEntries(800); // If there is less than 1000 entries in the histo: no fit calibra->AnalyseCH(histogain); Int_t nbtg = 6*4*18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb0(0)) + 6* 18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb2(0)); @@ -580,20 +910,21 @@ Bool_t AliTRDPreprocessor::ExtractHLT() Int_t nbE = calibra->GetNumberEnt(); // enough statistics if ((nbtg > 0) && - (nbfit >= 0.95*nbE)) { + (nbfit >= 0.5*nbE) && (nbE > 30)) { // create the cal objects + calibra->PutMeanValueOtherVectorFit(1,kTRUE); TObjArray object = calibra->GetVectorFit(); AliTRDCalDet *objgaindet = calibra->CreateDetObjectGain(&object); - TObject *objgainpad = calibra->CreatePadObjectGain(); + // TObject *objgainpad = calibra->CreatePadObjectGain(); // store them if(!Store("Calib","ChamberGainFactor",(TObject *) objgaindet ,&md1,0,kTRUE)){ Log("Error storing the calibration object for the chamber gain"); error = kTRUE; } - if(!Store("Calib","LocalGainFactor" ,(TObject *) objgainpad ,&md2,0,kTRUE)){ - Log("Error storing the calibration object for the local gain factor"); - error = kTRUE; - } + // if(!Store("Calib","LocalGainFactor" ,(TObject *) objgainpad ,&md2,0,kTRUE)){ + // Log("Error storing the calibration object for the local gain factor"); + // error = kTRUE; + // } } calibra->ResetVectorFit(); }// if histogain @@ -601,8 +932,8 @@ Bool_t AliTRDPreprocessor::ExtractHLT() // vdrift fVdriftHLT = kFALSE; TProfile2D *histodriftvelocity = (TProfile2D *) filehlt->Get("PH2d"); - histodriftvelocity->SetDirectory(0); if (histodriftvelocity) { + histodriftvelocity->SetDirectory(0); // store the reference data if(!StoreReferenceData("HLTData","VdriftT0",(TObject *) histodriftvelocity,&metaData)){ Log("Error storing 2D Profile for average pulse height (HLT)"); @@ -610,22 +941,27 @@ Bool_t AliTRDPreprocessor::ExtractHLT() } // analyse Log("Take the PH reference data. Now we will try to fit\n"); - calibra->SetMinEntries(1000*20); // If there is less than 20000 + calibra->SetMinEntries(800*20); // If there is less than 20000 calibra->AnalysePH(histodriftvelocity); Int_t nbtg = 6*4*18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb0(1)) + 6* 18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb2(1)); Int_t nbfit = calibra->GetNumberFit(); + Int_t nbfitSuccess = calibra->GetNumberFitSuccess(); Int_t nbE = calibra->GetNumberEnt(); // enough statistics if ((nbtg > 0) && - (nbfit >= 0.95*nbE)) { + (nbfit >= 0.5*nbE) && (nbE > 30) && (nbfitSuccess > 30)) { // create the cal objects + calibra->RemoveOutliers(1,kTRUE); + calibra->PutMeanValueOtherVectorFit(1,kTRUE); + calibra->RemoveOutliers2(kTRUE); + calibra->PutMeanValueOtherVectorFit2(1,kTRUE); TObjArray object = calibra->GetVectorFit(); AliTRDCalDet *objdriftvelocitydet = calibra->CreateDetObjectVdrift(&object,kTRUE); - TObject *objdriftvelocitypad = calibra->CreatePadObjectVdrift(); + // TObject *objdriftvelocitypad = calibra->CreatePadObjectVdrift(); object = calibra->GetVectorFit2(); AliTRDCalDet *objtime0det = calibra->CreateDetObjectT0(&object,kTRUE); - TObject *objtime0pad = calibra->CreatePadObjectT0(); + //TObject *objtime0pad = calibra->CreatePadObjectT0(); // store them if(!Store("Calib","ChamberVdrift" ,(TObject *) objdriftvelocitydet,&md1,0,kTRUE)){ Log("Error storing the calibration object for the chamber vdrift (HLT)"); @@ -635,23 +971,24 @@ Bool_t AliTRDPreprocessor::ExtractHLT() Log("Error storing the calibration object for the chamber t0 (HLT)"); error = kTRUE; } - if(!Store("Calib","LocalVdrift" ,(TObject *) objdriftvelocitypad,&md2,0,kTRUE)){ - Log("Error storing the calibration object for the local drift velocity (HLT)"); - error = kTRUE; - } - if(!Store("Calib","LocalT0" ,(TObject *) objtime0pad ,&md2,0,kTRUE)){ - Log("Error storing the calibration object for the local time0 (HLT)"); - error = kTRUE; - } + // if(!Store("Calib","LocalVdrift" ,(TObject *) objdriftvelocitypad,&md2,0,kTRUE)){ + // Log("Error storing the calibration object for the local drift velocity (HLT)"); + // error = kTRUE; + // } + // if(!Store("Calib","LocalT0" ,(TObject *) objtime0pad ,&md2,0,kTRUE)){ + // Log("Error storing the calibration object for the local time0 (HLT)"); + // error = kTRUE; + // } fVdriftHLT = kTRUE; } calibra->ResetVectorFit(); }// if TProfile2D // prf + /* TProfile2D *histoprf = (TProfile2D *) filehlt->Get("PRF2d"); - histoprf->SetDirectory(0); if (histoprf) { + histoprf->SetDirectory(0); // store reference data if(!StoreReferenceData("HLTData","PRF",(TObject *) histoprf,&metaData)){ Log("Error storing the 2D Profile for Pad Response Function"); @@ -667,7 +1004,7 @@ Bool_t AliTRDPreprocessor::ExtractHLT() Int_t nbE = calibra->GetNumberEnt(); // enough statistics if ((nbtg > 0) && - (nbfit >= 0.95*nbE)) { + (nbfit >= 0.95*nbE) && (nbE > 30)) { // create cal pad objects TObjArray object = calibra->GetVectorFit(); TObject *objPRFpad = calibra->CreatePadObjectPRF(&object); @@ -679,6 +1016,7 @@ Bool_t AliTRDPreprocessor::ExtractHLT() } calibra->ResetVectorFit(); }// if PRF + */ }// if fileNameEntry delete listhlt; @@ -689,57 +1027,110 @@ Bool_t AliTRDPreprocessor::ExtractHLT() //_____________________________________________________________________________ UInt_t AliTRDPreprocessor::ProcessDCSConfigData() { - // // process the configuration of FEE, PTR and GTU - // reteive XML file from the DCS FXS - // parse it and store TObjArrays in the CDB - // return 0 for success, otherwise: - // 5: could not get the file from the FXS - // 6: ERROR in XML validation: something wrong with the file - // 7: ERROR while creating calibration objects in the handler - // 8: error while storing data in the CDB - // + // reteive XML filei(s) from the DCS FXS + // parse it/them and store TObjArrays in the CDB + + Log("Processing the DCS config summary files."); + + if(fCalDCSObjSOR) delete fCalDCSObjSOR; + if(fCalDCSObjEOR) delete fCalDCSObjEOR; + + TString xmlFile[2]; + TString esor[2] = {"SOR", "EOR"}; + // get the XML files + xmlFile[0] = GetFile(kDCS,"CONFIGSUMMARYSOR",""); + xmlFile[1] = GetFile(kDCS,"CONFIGSUMMARYEOR",""); + + + // check both files + for (Int_t iFile=0; iFile<2; iFile++) { - Log("Processing the DCS config summary file."); + // check if the file are there + if (xmlFile[iFile].IsNull()) { + Log(Form("Warning: %s file not found!", esor[iFile].Data())); + continue; + } + Log(Form("%s file found: %s", esor[iFile].Data(), xmlFile[iFile].Data())); + + // test the file + std::ifstream fileTest; + fileTest.open(xmlFile[iFile].Data(), std::ios_base::binary | std::ios_base::in); + if (!fileTest.good() || fileTest.eof() || !fileTest.is_open()) { + Log(Form("Warning: %s file not valid!", esor[iFile].Data())); + continue; + } + // check if the file is empty + fileTest.seekg(0, std::ios_base::end); + if (static_cast(fileTest.tellg()) < 2) { + Log(Form("Warning: %s file empty!", esor[iFile].Data())); + continue; + } + Log(Form("%s file is valid.", esor[iFile].Data())); - // get the XML file - const char * nameFile = GetFile(kDCS,"CONFIGSUMMARY",""); - if (nameFile == NULL) { - return 5; - Log(Form("File %s not found!",nameFile)); + // make a robust XML validation + TSAXParser testParser; + if (testParser.ParseFile(xmlFile[iFile].Data()) < 0 ) { + Log(Form("Warning: %s XML content is not well-formed!", esor[iFile].Data())); + continue; + } + Log(Form("%s XML content is well-formed.", esor[iFile].Data())); + + // create parser and parse + TSAXParser saxParser; + AliTRDSaxHandler saxHandler; + saxParser.ConnectToHandler("AliTRDSaxHandler", &saxHandler); + saxParser.ParseFile(xmlFile[iFile].Data()); + + // report errors of the parser if present + if (saxParser.GetParseCode() != 0) { + Log(Form("Warning: %s XML file validation failed! Parse code: %d", esor[iFile].Data(), saxParser.GetParseCode())); + continue; + } + Log(Form("%s XML validation OK.", esor[iFile].Data())); + + // report errors of the handler if present + if (saxHandler.GetHandlerStatus() != 0) { + Log(Form("Warning: Creating %s calibration object failed! Error code: %d", esor[iFile].Data(), saxHandler.GetHandlerStatus())); + continue; + } + Log(Form("%s SAX handler reports no errors.", esor[iFile].Data())); + + // get the calibration object storing the data from the handler + AliTRDCalDCSv2 *calDCSObj = (AliTRDCalDCSv2*)saxHandler.GetCalDCSObj()->Clone(); + calDCSObj->EvaluateGlobalParameters(); + calDCSObj->SetRunType(GetRunType()); + calDCSObj->SetStartTime(GetStartTimeDCSQuery()); + calDCSObj->SetEndTime(GetEndTimeDCSQuery()); + if (iFile == 0) fCalDCSObjSOR = calDCSObj; + if (iFile == 1) fCalDCSObjEOR = calDCSObj; } - // create parser and parse - TSAXParser saxParser; - AliTRDSaxHandler saxHandler; - saxParser.ConnectToHandler("AliTRDSaxHandler", &saxHandler); - saxParser.ParseFile(nameFile); + if (!fCalDCSObjSOR && !fCalDCSObjEOR) { Log("ERROR: Failed reading both files!"); return 1; } + + // put both objects in one TObjArray to store them + TObjArray* calObjArray = new TObjArray(2); + calObjArray->SetOwner(); - // report errors if present - if (saxParser.GetParseCode() == 0) { - Log("XML file validation OK"); - } else { - Log(Form("ERROR in XML file validation. Parsecode: %s", saxParser.GetParseCode())); - return 6; + if (fCalDCSObjSOR) { + calObjArray->AddAt(fCalDCSObjSOR,0); + Log("TRDCalDCS object for SOR created."); } - if (saxHandler.GetHandlerStatus() != 0) { - Log(Form("ERROR while creating calibration objects. Error code: %s", saxHandler.GetHandlerStatus())); - return 7; + if (fCalDCSObjEOR) { + calObjArray->AddAt(fCalDCSObjEOR,1); + Log("TRDCalDCS object for EOR created."); } - // get the calibration object storing the data from the handler - AliTRDCalDCS* fCalDCSObj = saxHandler.GetCalDCSObj(); - // store the DCS calib data in the CDB AliCDBMetaData metaData1; metaData1.SetBeamPeriod(0); metaData1.SetResponsible("Frederick Kramer"); - metaData1.SetComment("DCS configuration data in one AliTRDCalDCS object."); - if (!Store("Calib", "DCSCONFIG", fCalDCSObj, &metaData1, 0, kTRUE)) { - Log("problems while storing DCS config data object"); - return 8; - } + metaData1.SetComment("DCS configuration data in two AliTRDCalDCSv2 objects in one TObjArray (0:SOR, 1:EOR)."); + if (!Store("Calib", "DCS", calObjArray, &metaData1, 0, kTRUE)) { Log("ERROR: Storing DCS config data object failed!"); return 1; } + + delete calObjArray; + Log("SUCCESS: Processing of the DCS config summary file DONE."); return 0; }