-////////////////////////////////////////////////////////
-//
-// This class is a first implementation for the TRD.
-// It takes data from HLT and computes the parameters
-// and stores both reference data and online calibration parameters in the CDB
-//
-/////////////////////////////////////////////////////////
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * *
+ * Author: The ALICE Off-line Project. *
+ * Contributors are mentioned in the code where appropriate. *
+ * *
+ * Permission to use, copy, modify and distribute this software and its *
+ * documentation strictly for non-commercial purposes is hereby granted *
+ * without fee, provided that the above copyright notice appears in all *
+ * copies and that both the copyright notice and this permission notice *
+ * appear in the supporting documentation. The authors make no claims *
+ * about the suitability of this software for any purpose. It is *
+ * provided "as is" without express or implied warranty. *
+ **************************************************************************/
+
+/* $Id$ */
+
+////////////////////////////////////////////////////////////////////////////
+// //
+// This class is a first implementation for the TRD. //
+// It takes data from HLT and computes the parameters //
+// and stores both reference data and online calibration //
+// parameters in the CDB //
+// It alsotakes DCS data, does spline fits //
+// and stores both reference data and spline fits results //
+// in the CDB //
+// //
+// Author: //
+// R. Bailhache (R.Bailhache@gsi.de) //
+// W. Monange (w.monange@gsi.de) //
+// //
+////////////////////////////////////////////////////////////////////////////
#include "AliTRDPreprocessor.h"
-#include <TTimeStamp.h>
#include <TFile.h>
#include <TProfile2D.h>
-#include <TH2I.h>
#include <TStopwatch.h>
#include <TObjString.h>
#include <TString.h>
#include <TCollection.h>
#include "AliCDBMetaData.h"
-#include "AliDCSValue.h"
#include "AliLog.h"
-#include "AliTRDCalibra.h"
+#include "AliTRDSensorArray.h"
+#include "AliTRDCalibraFit.h"
+#include "AliTRDCalibraMode.h"
+#include "AliTRDCalibPadStatus.h"
#include "Cal/AliTRDCalDet.h"
-
+#include "Cal/AliTRDCalPadStatus.h"
ClassImp(AliTRDPreprocessor)
//______________________________________________________________________________________________
-AliTRDPreprocessor::AliTRDPreprocessor(const Char_t *detector, AliShuttleInterface *shuttle)
- :AliPreprocessor(detector, shuttle)
+AliTRDPreprocessor::AliTRDPreprocessor(AliShuttleInterface *shuttle)
+ :AliPreprocessor("TRD", shuttle),
+ fVdriftHLT(0)
{
//
// Constructor
}
//______________________________________________________________________________________________
-UInt_t AliTRDPreprocessor::Process(TMap* /*dcsAliasMap*/)
+UInt_t AliTRDPreprocessor::Process(TMap* dcsAliasMap)
{
//
- // Process the calibraion data for the HLT part
+ // Process DCS and calibration part for HLT
//
- // How long does it take for the HLT part?
- TStopwatch timer;
- timer.Start();
-
- // Metadata for the reference data
- AliCDBMetaData metaData;
- metaData.SetBeamPeriod(1);
- metaData.SetResponsible("Raphaelle Bailhache");
- metaData.SetComment("This preprocessor fills reference data.");
+ TString runType = GetRunType();
+ Log(Form("runtype %s\n",runType.Data()));
+
+ if (runType=="PEDESTAL_RUN"){
+ if(ExtractPedestals()) return 1;
+ return 0;
+ }
+ //
+ // DCS
+ //
+
+ if(ProcessDCS(dcsAliasMap)) return 1;
- // Take the file from the HLT file exchange server
- TList *filesources = GetFileSources(kHLT,"GAINDRIFTPRF");
- if (!filesources) {
- AliError(Form("No sources found for GAINDRIFTPRF for run %d !",fRun));
- return 0;
+ //
+ // Process the calibration data for the HLT and DAQ part
+ //
+
+ if (runType=="PHYSICS"){
+ //TString runPar = GetRunParameter("HLTStatus")
+ //if(runPar=="1") {
+ if(ExtractHLT()) return 1;
+ //if (fResult > 0) return fResult;
+ //}
+ if(!fVdriftHLT) {
+ if(ExtractDriftVelocityDAQ()) return 1;
+ }
}
- if (filesources->GetSize() != 1) {
- AliError(Form("More than one source found for GAINDRIFTPRF for run %d!",fRun));
- return 0;
+
+ return 0;
+
+}
+
+//______________________________________________________________________________
+Bool_t AliTRDPreprocessor::ProcessDCS(TMap * dcsAliasMap)
+{
+ Bool_t error=kFALSE;
+
+ AliCDBMetaData metaData;
+ metaData.SetBeamPeriod(0);
+ metaData.SetResponsible("Wilfried Monange/Raphaelle Bailhache");
+ metaData.SetComment("TRD calib test");
+
+
+ Log ("****** DCS ******\n");
+
+ TObjArray * list=AliTRDSensorArray::GetList ();
+
+ if (list == 0x0) {
+ Log ("Error during AliTRDSensorArray::GetList");
+ Log ("DCS will not be processing");
+ return kTRUE;
}
- // Call a AliTRDCalibra instance for fit
- AliTRDCalibra *calibra = AliTRDCalibra::Instance();
-
- // Init some things
- AliTRDCalDet *objgaindet = 0x0; // Object for det average gain factor
- AliTRDCalDet *objdriftvelocitydet = 0x0; // Object for det average drift velocity
- AliTRDCalDet *objtime0det = 0x0; // Object for det average time0
- TObject *objgainpad = 0x0; // Object for pad (relative to the det) gain factor
- TObject *objdriftvelocitypad = 0x0; // Object for pad (relative to the det) drift velocity
- TObject *objtime0pad = 0x0; // Object for pad (relative to the det) time0
- TObject *objPRFpad = 0x0; // Object for pad prf width
- TH2I *histogain = 0x0; // Histogram taken from HLT for gain factor
- TProfile2D *histodriftvelocity = 0x0; // Profile taken from HLT for drift velocity and time0
- TProfile2D *histoprf = 0x0; // Profile taken from HLT for prf
-
- Int_t numberfit[3] = { 0, 0, 0 }; // Number of histos fitted for gain, drift velocity and prf
- Int_t numberEnt[3] = { 0, 0, 0 }; // Number of histos with entries
- Double_t statisticmean[3] = { 0.0, 0.0, 0.0 }; // Mean values of the number of entries in these histos
- Int_t numbertotalgroup[3] = { 0, 0, 0 }; // Total number of groups
-
-
- // Loop over the files taken from the HLT/
- TIter iter(filesources);
- TObjString *source;
- while ((source = dynamic_cast<TObjString *> (iter.Next()))) {
-
- TString filename = GetFile(kHLT,"GAINDRIFTPRF",source->GetName());
- if (!filename.Data()) {
- AliError(Form("Error retrieving file from source %d failed!", source->GetName()));
- delete filesources;
- return 0;
- }
+ Int_t nEntries = list->GetEntries ();
+ Log (Form ("%d alias loaded", nEntries));
+
+ Bool_t * results=new Bool_t [nEntries];
+ Int_t * nGraph=new Int_t [nEntries];
+
+ for (Int_t iAlias = 0; iAlias < nEntries; iAlias++) {
+
+ AliTRDSensorArray * oneTRDDCS = (AliTRDSensorArray *)list->At (iAlias);
+
+ oneTRDDCS->SetStartTime (TTimeStamp (fStartTime));
+ oneTRDDCS->SetEndTime (TTimeStamp (fEndTime));
+
+ Log (Form("Processing DCS : \"%s\"", oneTRDDCS->GetStoreName ().Data ()));
+
+ TMap * map;
- // Take the histos
- TFile *file = TFile::Open(filename);
- histogain = (TH2I *) file->Get("CH2d");
- histogain->SetDirectory(0);
- if (!histogain) {
- AliError("Error retrieving 2D histos for gain failed!");
- }
- histodriftvelocity = (TProfile2D *) file->Get("PH2d");
- histodriftvelocity->SetDirectory(0);
- if (!histodriftvelocity) {
- AliError("Error retrieving 2D Profile for average pulse height failed!");
+ map=oneTRDDCS->ExtractDCS (dcsAliasMap);
+
+ nGraph [iAlias] = map->GetEntries ();
+
+ if (nGraph [iAlias] == 0) {
+ Log("No TGraph for this dcsDatapointAlias : not stored");
+ results [iAlias] = kFALSE;
+ continue;
}
- histoprf = (TProfile2D *) file->Get("PRF2d");
- histoprf->SetDirectory(0);
- if (!histoprf) {
- AliError("Error retrieving 2D Profile for Pad Response Function failed!");
- }
- file->Close();
+
+ oneTRDDCS->SetGraph(map);
+ results[iAlias]=Store("Calib", oneTRDDCS->GetStoreName().Data(), oneTRDDCS, &metaData, 0, kTRUE);
+ delete map;
- // Set the mode of calibration from the TObject, store the reference data and try to fit them
- if (histogain) {
- calibra->SetModeCalibrationFromTObject((TObject *) histogain,0);
- Store("Data","Gain",(TObject *) histogain,&metaData,0,0);
- AliInfo("Take the CH reference data. Now we will try to fit\n");
- calibra->SetMinEntries(100); // If there is less than 100 entries in the histo: no fit
- calibra->FitCHOnline(histogain);
- numbertotalgroup[0] = 6*4*18*((Int_t) calibra->GetDetChamb0(0))
- + 6* 18*((Int_t) calibra->GetDetChamb2(0));
- numberfit[0] = calibra->GetNumberFit();
- statisticmean[0] = calibra->GetStatisticMean();
- numberEnt[0] = calibra->GetNumberEnt();
- objgaindet = calibra->CreateDetObjectTree(calibra->GetGain(),0);
- objgainpad = calibra->CreatePadObjectTree(calibra->GetGain(),0,objgaindet);
- }
-
- if (histodriftvelocity) {
- calibra->SetModeCalibrationFromTObject((TObject *) histodriftvelocity,1);
- Store("Data","VdriftT0",(TObject *) histodriftvelocity,&metaData,0,0);
- AliInfo("Take the PH reference data. Now we will try to fit\n");
- calibra->SetMinEntries(100*20); // If there is less than 2000
- calibra->FitPHOnline(histodriftvelocity);
- numbertotalgroup[1] = 6*4*18*((Int_t) calibra->GetDetChamb0(1))
- + 6* 18*((Int_t) calibra->GetDetChamb2(1));
- numberfit[1] = calibra->GetNumberFit();
- statisticmean[1] = calibra->GetStatisticMean();
- numberEnt[1] = calibra->GetNumberEnt();
- objdriftvelocitydet = calibra->CreateDetObjectTree(calibra->GetVdrift(),1);
- objdriftvelocitypad = calibra->CreatePadObjectTree(calibra->GetVdrift(),1,objdriftvelocitydet);
- objtime0det = calibra->CreateDetObjectTree(calibra->GetT0(),3);
- objtime0pad = calibra->CreatePadObjectTree(calibra->GetT0(),3,objtime0det);
+ //results [iAlias] = StoreReferenceData("Calib", oneTRDDCS->GetStoreName ().Data (), oneTRDDCS, &metaData);
+
+
+ if (!results[iAlias]) {
+ AliError("Problem during StoreRef DCS");
+ error=kTRUE;
}
+
+
+ //BEGIN TEST (should not be removed ...)
+ /*
+ oneTRDDCS->ClearGraph();
+ oneTRDDCS->ClearFit();
+ oneTRDDCS->SetDiffCut2 (0.1);
+ map=oneTRDDCS->ExtractDCS (dcsAliasMap);
+ oneTRDDCS->SetGraph (map);
+ Store("Calib", ("cut_"+oneTRDDCS->GetStoreName()).Data(), oneTRDDCS, &metaData, 0, kTRUE);
+ delete map;
+
+
+ if(iAlias==1 || iAlias==19) continue;
- if (histoprf) {
- calibra->SetModeCalibrationFromTObject((TObject *) histoprf,2);
- Store("Data","PRF",(TObject *) histoprf,&metaData,0,0);
- AliInfo("Take the PRF reference data. Now we will try to fit\n");
- calibra->SetMinEntries(100*20); // If there is less than 2000
- calibra->SetRangeFitPRF(0.5);
- calibra->FitPRFOnline(histoprf);
- numbertotalgroup[2] = 6*4*18*((Int_t) calibra->GetDetChamb0(2))
- + 6* 18*((Int_t) calibra->GetDetChamb2(2));
- numberfit[2] = calibra->GetNumberFit();
- statisticmean[2] = calibra->GetStatisticMean();
- numberEnt[2] = calibra->GetNumberEnt();
- objPRFpad = calibra->CreatePadObjectTree(calibra->GetPRF());
- }
+ oneTRDDCS->ClearGraph();
+ oneTRDDCS->ClearFit();
+ oneTRDDCS->SetDiffCut2(0);
+ map=oneTRDDCS->ExtractDCS(dcsAliasMap);
+ oneTRDDCS->MakeSplineFit(map);
+ Store("Calib", ("fit_"+oneTRDDCS->GetStoreName()).Data() , oneTRDDCS, &metaData, 0, kTRUE);
+ delete map;
+
+
+ oneTRDDCS->ClearGraph();
+ oneTRDDCS->ClearFit();
+ oneTRDDCS->SetDiffCut2 (0.1);
+ map=oneTRDDCS->ExtractDCS (dcsAliasMap);
+ oneTRDDCS->MakeSplineFit(map);
+ Store("Calib", ("cutfit_"+oneTRDDCS->GetStoreName()).Data() , oneTRDDCS, &metaData, 0, kTRUE);
+ delete map;
+ */
+ //END TEST
+
+
}
+
+ Log (" Summury of DCS :\n");
+ Log (Form("%30s %10s %10s", "dcsDatapointAlias", "Stored ?", "# graph"));
+ for (Int_t iAlias = 0; iAlias < nEntries; iAlias++) {
+ AliTRDSensorArray * oneTRDDCS = (AliTRDSensorArray *)list->At (iAlias);
+ Log (Form ("%30s %10s %4d",
+ oneTRDDCS->GetStoreName ().Data (),
+ results[iAlias] ? "ok" : "X",
+ nGraph [iAlias]));
+ }
+ Log ("*********** End of DCS **********");
- // Bilan of the fit statistic
- AliInfo(Form("The mean number of entries required for a fit is: %d"
- ,(Int_t) calibra->GetMinEntries()));
- AliInfo(Form("FOR THE CH: There is a mean statistic of: %f, with %d fits for %d groups and %d histos with entries"
- ,statisticmean[0],numberfit[0],numbertotalgroup[0],numberEnt[0]));
- AliInfo(Form("FOR THE PH: There is a mean statistic of: %f, with %d fits for %d groups and %d histos with entries"
- ,statisticmean[1],numberfit[1],numbertotalgroup[1],numberEnt[1]));
- AliInfo(Form("FOR THE PRF: There is a mean statistic of: %f, with %d fits for %d groups and %d histos with entries"
- ,statisticmean[2],numberfit[2],numbertotalgroup[2],numberEnt[2]));
-
+ delete results;
+ delete nGraph;
+
+ return error;
+}
+//______________________________________________________________________________________________
+Bool_t AliTRDPreprocessor::ExtractPedestals()
+{
//
- // Store the coefficients in the grid OCDB if enough statistics
+ // Pedestal running on LDCs at the DAQ
//
+
+ Bool_t error = kFALSE;
+
+ // Init a AliTRDCalibPadStatus
+ AliTRDCalibPadStatus calPedSum = AliTRDCalibPadStatus();
+
+ AliCDBMetaData metaData;
+ metaData.SetBeamPeriod(0);
+ metaData.SetResponsible("Raphaelle Bailhache");
+ metaData.SetComment("TRD calib test");
- // Store the infos for the detector
- AliCDBMetaData *md1= new AliCDBMetaData();
- md1->SetObjectClassName("AliTRDCalDet");
- md1->SetResponsible("Raphaelle Bailhache");
- md1->SetBeamPeriod(1);
- md1->SetAliRootVersion("01-10-06"); // root version
- md1->SetComment("The dummy values in this calibration file are for testing only");
- if ((numbertotalgroup[0] > 0) &&
- (numberfit[0] >= 0.95*numberEnt[0])) {
- Store("Calib","ChamberGainFactor",(TObject *) objgaindet ,md1,0,kTRUE);
+ // Sum the contributions of the LDCs
+ TList * listpad = GetFileSources(kDAQ,"PADSTATUS");
+ if (!listpad) {
+ Log("No list found for the PEDESTRAL Run");
+ return kTRUE;
}
- if ((numbertotalgroup[1] > 0) &&
- (numberfit[1] >= 0.95*numberEnt[1])) {
- Store("Calib","ChamberVdrift" ,(TObject *) objdriftvelocitydet,md1,0,kTRUE);
- Store("Calib","ChamberT0" ,(TObject *) objtime0det ,md1,0,kTRUE);
+
+ // loop through all files from LDCs
+
+ UInt_t index = 0;
+ while (listpad->At(index)!=NULL) {
+ TObjString* fileNameEntry = (TObjString*) listpad->At(index);
+ if (fileNameEntry != NULL)
+ {
+ TString fileName = GetFile(kDAQ, "PADSTATUS",
+ fileNameEntry->GetString().Data());
+ if(fileName.Length() ==0){
+ Log(Form("Error by retrieving the file %d for the pedestal",(Int_t)index));
+ delete listpad;
+ return kTRUE;
+ }
+
+ TFile *f = TFile::Open(fileName);
+ AliTRDCalibPadStatus *calPed;
+ f->GetObject("calibpadstatus",calPed);
+
+ if(calPed){
+
+ // analyse
+ calPed->AnalyseHisto();
+
+ // store as reference data
+ TString name("PadStatus");
+ name += (Int_t)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;
+ }
+
+
+ // Add to the calPedSum
+ for (Int_t idet=0; idet<540; idet++) {
+ AliTRDCalROC *rocMean = calPed->GetCalRocMean(idet, kFALSE);
+ if ( rocMean ) calPedSum.SetCalRocMean(rocMean,idet);
+ AliTRDCalROC *rocRMS = calPed->GetCalRocRMS(idet, kFALSE);
+ if ( rocRMS ) calPedSum.SetCalRocRMS(rocRMS,idet);
+ }// det loop
+ } // calPed
+ } // fileNameEntry
+ ++index;
+ }// while (list)
+ Log(Form("%d elements found in the list for the pedestal",(Int_t)index));
+ if(index==0){
+ delete listpad;
+ return kTRUE;
}
+ //
+ // Store pedestal entry to OCDB
+ //
- // Store the infos for the pads
- AliCDBMetaData *md2= new AliCDBMetaData();
- md2->SetObjectClassName("AliTRDCalPad");
- md2->SetResponsible("Raphaelle Bailhache");
- md2->SetBeamPeriod(1);
- md2->SetAliRootVersion("01-10-06"); //root version
- md2->SetComment("The dummy values in this calibration file are for testing only");
- if ((numbertotalgroup[0] > 0) &&
- (numberfit[0] >= 0.95*numberEnt[0])) {
- Store("Calib","LocalGainFactor" ,(TObject *) objgainpad ,md2,0,kTRUE);
+
+ // Create Pad Status
+ AliTRDCalPadStatus *calPadStatus = calPedSum.CreateCalPadStatus();
+ AliCDBMetaData md3;
+ md3.SetObjectClassName("AliTRDCalPadStatus");
+ md3.SetResponsible("Raphaelle Bailhache");
+ md3.SetBeamPeriod(1);
+ md3.SetComment("TRD calib test");
+ if(!Store("Calib","PadStatus" ,(TObject *)calPadStatus, &md3, 0, kTRUE)){
+ Log("Error storing the pedestal");
+ delete listpad;
+ return kTRUE;
}
- if ((numbertotalgroup[1] > 0) &&
- (numberfit[1] >= 0.95*numberEnt[1])) {
- Store("Calib","LocalVdrift" ,(TObject *) objdriftvelocitypad,md2,0,kTRUE);
- Store("Calib","LocalT0" ,(TObject *) objtime0pad ,md2,0,kTRUE);
+
+ delete listpad;
+ return error;
+
+}
+//______________________________________________________________________________________________
+Bool_t AliTRDPreprocessor::ExtractDriftVelocityDAQ()
+{
+ //
+ // Drift velocity DA running on monitoring servers at the DAQ
+ //
+
+ Bool_t error = kFALSE;
+
+ // Objects for HLT and DAQ zusammen
+ AliTRDCalibraFit *calibra = AliTRDCalibraFit::Instance();
+ AliCDBMetaData metaData;
+ metaData.SetBeamPeriod(0);
+ metaData.SetResponsible("Raphaelle Bailhache");
+ metaData.SetComment("TRD calib test");
+ // Store the infos for the detector
+ AliCDBMetaData md1;
+ md1.SetObjectClassName("AliTRDCalDet");
+ md1.SetResponsible("Raphaelle Bailhache");
+ md1.SetBeamPeriod(0);
+ md1.SetComment("TRD calib test");
+ // Store the infos for the pads
+ AliCDBMetaData md2;
+ md2.SetObjectClassName("AliTRDCalPad");
+ md2.SetResponsible("Raphaelle Bailhache");
+ md2.SetBeamPeriod(0);
+ md2.SetComment("TRD calib test");
+
+
+
+
+ // Take the file from the DAQ file exchange server
+ TList *listdaq = GetFileSources(kDAQ,"VDRIFT");
+ if (!listdaq) {
+ Log("No list found for vdrift (DAQ)");
+ return kTRUE;
}
- if ((numbertotalgroup[2] > 0) &&
- (numberfit[2] >= 0.95*numberEnt[2])) {
- Store("Calib","PRFWidth" ,(TObject *) objPRFpad ,md2,0,kTRUE);
+
+ if(listdaq->GetSize() !=1){
+ Log(Form("Problem on the size of the list: %d (DAQ)",listdaq->GetSize()));
+ delete listdaq;
+ return kTRUE;
}
- // End
- delete filesources;
- timer.Stop();
- timer.Print();
- return 1;
+ TObjString* fileNameEntry = (TObjString*) listdaq->At(0);
+ if(fileNameEntry != NULL){
+ TString fileName = GetFile(kDAQ, "VDRIFT",
+ fileNameEntry->GetString().Data());
+ if(fileName.Length() ==0){
+ Log("Error retrieving the file vdrift (DAQ)");
+ delete listdaq;
+ return kTRUE;
+ }
+ TFile *filedaq = TFile::Open(fileName);
+ TProfile2D *histodriftvelocity = (TProfile2D *) filedaq->Get("PH2d");
+ if (histodriftvelocity) {
+
+ // store as reference data
+ if(!StoreReferenceData("DAQData","VdriftT0",(TObject *) histodriftvelocity,&metaData)){
+ Log("Error storing 2D Profile for vdrift from the DAQ");
+ error = kTRUE;
+ }
+
+ // analyse
+
+ Log("Take the PH reference data. Now we will try to fit\n");
+ calibra->SetMinEntries(2000); // If there is less than 2000
+ 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 nbE = calibra->GetNumberEnt();
+
+ // if enough statistics store the results
+ if ((nbtg > 0) &&
+ (nbfit >= 0.95*nbE)) {
+ // create the cal objects
+ TObjArray object = calibra->GetVectorFit();
+ AliTRDCalDet *objdriftvelocitydet = calibra->CreateDetObjectVdrift(&object,kTRUE);
+ TObject *objdriftvelocitypad = calibra->CreatePadObjectVdrift();
+ object = calibra->GetVectorFit2();
+ AliTRDCalDet *objtime0det = calibra->CreateDetObjectT0(&object,kTRUE);
+ 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;
+ }
+ }
+ else{
+ Log("Not enough statistics for the average pulse height (DAQ)");
+ }
+ } // histo here
+ }// if fileNameEntry
+
+ delete listdaq;
+ return error;
+
+}
+//______________________________________________________________________________________________
+Bool_t AliTRDPreprocessor::ExtractHLT()
+{
+ //
+ // Gain, vdrift and PRF calibration running on HLT
+ // return kFALSE if NULL pointer to the list
+ //
+
+ Bool_t error = kFALSE;
+
+ // Objects for HLT and DAQ zusammen
+ AliTRDCalibraFit *calibra = AliTRDCalibraFit::Instance();
+ AliCDBMetaData metaData;
+ metaData.SetBeamPeriod(0);
+ metaData.SetResponsible("Raphaelle Bailhache");
+ metaData.SetComment("TRD calib test");
+ // Store the infos for the detector
+ AliCDBMetaData md1;
+ md1.SetObjectClassName("AliTRDCalDet");
+ md1.SetResponsible("Raphaelle Bailhache");
+ md1.SetBeamPeriod(0);
+ md1.SetComment("TRD calib test");
+ // Store the infos for the pads
+ AliCDBMetaData md2;
+ md2.SetObjectClassName("AliTRDCalPad");
+ md2.SetResponsible("Raphaelle Bailhache");
+ md2.SetBeamPeriod(0);
+ md2.SetComment("TRD calib test");
+
+
+ // Take the file from the HLT file exchange server
+ TList *listhlt = GetFileSources(kHLT,"GAINDRIFTPRF");
+ if (!listhlt) {
+ Log("No list found for the HLT");
+ return kTRUE;
+ }
+ if(listhlt->GetSize() != 1) {
+ Log(Form("Problem on the size of the list: %d (HLT)",listhlt->GetSize()));
+ delete listhlt;
+ return kTRUE;
+ }
+
+ TObjString* fileNameEntry = (TObjString*) listhlt->At(0);
+ if(fileNameEntry != NULL){
+ TString fileName = GetFile(kHLT, "GAINDRIFTPRF",
+ fileNameEntry->GetString().Data());
+ if(fileName.Length() ==0){
+ Log("Error retrieving the file (HLT)");
+ delete listhlt;
+ return kTRUE;
+ }
+ // Take the file
+ TFile *filehlt = TFile::Open(fileName);
+
+
+ // gain
+ TH2I *histogain = (TH2I *) filehlt->Get("CH2d");
+ histogain->SetDirectory(0);
+ if (histogain) {
+ // store the reference data
+ if(!StoreReferenceData("HLTData","Gain",(TObject *) histogain,&metaData)){
+ Log("Error storing 2D histos for gain");
+ error = kTRUE;
+ }
+ // 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->AnalyseCH(histogain);
+ Int_t nbtg = 6*4*18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb0(0))
+ + 6* 18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb2(0));
+ Int_t nbfit = calibra->GetNumberFit();
+ Int_t nbE = calibra->GetNumberEnt();
+ // enough statistics
+ if ((nbtg > 0) &&
+ (nbfit >= 0.95*nbE)) {
+ // create the cal objects
+ TObjArray object = calibra->GetVectorFit();
+ AliTRDCalDet *objgaindet = calibra->CreateDetObjectGain(&object,calibra->GetScaleFitFactor(),kTRUE);
+ 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;
+ }
+ }
+ calibra->ResetVectorFit();
+ }// if histogain
+
+
+
+ // vdrift
+ fVdriftHLT = kFALSE;
+ TProfile2D *histodriftvelocity = (TProfile2D *) filehlt->Get("PH2d");
+ histodriftvelocity->SetDirectory(0);
+ if (histodriftvelocity) {
+ // store the reference data
+ if(!StoreReferenceData("HLTData","VdriftT0",(TObject *) histodriftvelocity,&metaData)){
+ Log("Error storing 2D Profile for average pulse height (HLT)");
+ error = kTRUE;
+ }
+ // 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->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 nbE = calibra->GetNumberEnt();
+ // enough statistics
+ if ((nbtg > 0) &&
+ (nbfit >= 0.95*nbE)) {
+ // create the cal objects
+ TObjArray object = calibra->GetVectorFit();
+ AliTRDCalDet *objdriftvelocitydet = calibra->CreateDetObjectVdrift(&object,kTRUE);
+ TObject *objdriftvelocitypad = calibra->CreatePadObjectVdrift();
+ object = calibra->GetVectorFit2();
+ AliTRDCalDet *objtime0det = calibra->CreateDetObjectT0(&object,kTRUE);
+ 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)");
+ error = kTRUE;
+ }
+ if(!Store("Calib","ChamberT0" ,(TObject *) objtime0det ,&md1,0,kTRUE)){
+ 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;
+ }
+ fVdriftHLT = kTRUE;
+ }
+ calibra->ResetVectorFit();
+ }// if TProfile2D
+
+
+ // prf
+ TProfile2D *histoprf = (TProfile2D *) filehlt->Get("PRF2d");
+ histoprf->SetDirectory(0);
+ if (histoprf) {
+ // store reference data
+ if(!StoreReferenceData("HLTData","PRF",(TObject *) histoprf,&metaData)){
+ Log("Error storing the 2D Profile for Pad Response Function");
+ error = kTRUE;
+ }
+ // analyse
+ Log("Take the PRF reference data. Now we will try to fit\n");
+ calibra->SetMinEntries(600); // If there is less than 20000
+ calibra->AnalysePRFMarianFit(histoprf);
+ Int_t nbtg = 6*4*18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb0(2))
+ + 6* 18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb2(2));
+ Int_t nbfit = calibra->GetNumberFit();
+ Int_t nbE = calibra->GetNumberEnt();
+ // enough statistics
+ if ((nbtg > 0) &&
+ (nbfit >= 0.95*nbE)) {
+ // create cal pad objects
+ TObjArray object = calibra->GetVectorFit();
+ TObject *objPRFpad = calibra->CreatePadObjectPRF(&object);
+ // store them
+ if(!Store("Calib","PRFWidth" ,(TObject *) objPRFpad ,&md2,0,kTRUE)){
+ Log("Error storing the calibration object for the Pad Response Function");
+ error = kTRUE;
+ }
+ }
+ calibra->ResetVectorFit();
+ }// if PRF
+ }// if fileNameEntry
+
+ delete listhlt;
+ return error;
+
}