1 #include "AliVZEROPreprocessor.h"
2 #include "AliVZEROCalibData.h"
3 #include "AliVZEROTriggerData.h"
4 #include "AliCDBMetaData.h"
5 #include "AliCDBEntry.h"
6 #include "AliDCSValue.h"
8 #include "AliShuttleInterface.h"
9 #include "AliVZERODataFEE.h"
10 #include "AliVZERODataDCS.h"
13 #include <TTimeStamp.h>
14 #include <TObjString.h>
21 // This class is a simple preprocessor for VZERO detector.
23 // It gets High Voltage values for a given run from DCS and Pedestal values from DAQ
24 // and writes them as Calibration MetaData into OCDB/VZERO/Calib/Data
25 // It also retrieves FEE parameters from DCS archive
26 // and writes them as Trigger MetaData into OCDB/VZERO/Trigger/Data
27 // (to be used for trigger simulation)
30 ClassImp(AliVZEROPreprocessor)
32 //______________________________________________________________________________________________
33 AliVZEROPreprocessor::AliVZEROPreprocessor(AliShuttleInterface* shuttle) :
34 AliPreprocessor("V00", shuttle),
41 AddRunType("STANDALONE_PULSER");
42 AddRunType("STANDALONE_BC");
43 AddRunType("PHYSICS");
47 //______________________________________________________________________________________________
48 AliVZEROPreprocessor::~AliVZEROPreprocessor()
56 //______________________________________________________________________________________________
57 void AliVZEROPreprocessor::Initialize(Int_t run, UInt_t startTime,
60 // Creates AliVZERODataDCS object
62 AliPreprocessor::Initialize(run, startTime, endTime);
64 Log(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run,
65 TTimeStamp(startTime).AsString(),
66 TTimeStamp(endTime).AsString()));
69 // fStartTime = startTime;
70 // fEndTime = endTime;
71 fStartTime = GetStartTimeDCSQuery ();
72 fEndTime = GetEndTimeDCSQuery ();
73 time_t daqStart = (time_t) (((TString)GetRunParameter("DAQ_time_start")).Atoi());
74 time_t daqEnd = (time_t) (((TString)GetRunParameter("DAQ_time_end")).Atoi());
76 fData = new AliVZERODataDCS(fRun, fStartTime, fEndTime,(UInt_t)daqStart, (UInt_t)daqEnd);
77 fFEEData = new AliVZERODataFEE(fRun, fStartTime, fEndTime);
81 //______________________________________________________________________________________________
82 UInt_t AliVZEROPreprocessor::Process(TMap* dcsAliasMap)
84 // Fills data retrieved from DCS and DAQ into a AliVZEROCalibData object and
85 // stores it into CalibrationDB
88 // *** GET RUN TYPE ***
89 TString runType = GetRunType();
92 // *** REFERENCE DATA ***
95 AliVZEROCalibData *calibData = new AliVZEROCalibData();
97 // *************** HV From DCS ******************
98 // Fills data into a AliVZERODataDCS object
99 if(!dcsAliasMap) return 1;
101 // The Processing of the DCS input data is forwarded to AliVZERODataDCS
102 fData->ProcessData(*dcsAliasMap);
104 // Writes VZERO PMs HV values into VZERO calibration object and Timing resolution parameters
105 calibData->FillDCSData(fData);
107 // *************** From DAQ ******************
109 TString sourcesId = "V00da_results";
111 TList* sourceList = GetFileSources(kDAQ, sourcesId.Data());
113 Log(Form("No sources found for id %s", sourcesId.Data()));
115 Log(Form("The following sources produced files with the id %s",sourcesId.Data()));
118 TIter iter(sourceList);
119 TObjString *source = 0;
121 while((source=dynamic_cast<TObjString*> (iter.Next()))){
122 fileName = GetFile(kDAQ, sourcesId.Data(), source->GetName());
123 if (fileName.Length() > 0)
124 Log(Form("Got the file %s, now we can extract some values.", fileName.Data()));
126 if((file = fopen(fileName.Data(),"r")) == NULL){
127 Log(Form("Cannot open file %s",fileName.Data()));
129 Float_t pedMean[128], pedSigma[128], adcMean[128], adcSigma[128] ;
130 for(Int_t j=0; j<128; j++)fscanf(file,"%f %f %f %f",
131 &pedMean[j], &pedSigma[j], &adcMean[j], &adcSigma[j]);
134 calibData->SetPedestal(pedMean);
135 calibData->SetSigma(pedSigma);
136 calibData->SetADCsigma(adcSigma);
141 // Check that everything was properly transmitted
143 // for(Int_t j=0; j<128; j++){printf("Pedestal[%d] -> %f \n",j,calibData->GetPedestal(j));}
144 // for(Int_t j=0; j<128; j++){printf("pedSigma[%d] -> %f \n",j,calibData->GetSigma(j));}
145 // for(Int_t j=0; j<128; j++){printf("Gain[%d] -> %f \n",j,calibData->GetGain(j));}
146 // for(Int_t j=0; j<128; j++){printf("adcSigma[%d] -> %f \n",j,calibData->GetADCsigma(j));}
147 // for(Int_t j=0; j<64; j++){printf("MeanHV[%d] -> %f \n",j,calibData->GetMeanHV(j));}
148 // for(Int_t j=0; j<64; j++){printf("WidthHV[%d] -> %f \n",j,calibData->GetWidthHV(j));}
150 // Now we store the VZERO Calibration Object into CalibrationDB
152 Bool_t resECal=kTRUE;
155 // if(sourceList && sourceList->GetEntries()>0)
157 AliCDBMetaData metaData;
158 metaData.SetBeamPeriod(0);
159 metaData.SetResponsible("Brigitte Cheynis");
160 metaData.SetComment("This preprocessor fills an AliVZEROCalibData object");
162 resECal = Store("Calib", "Data", calibData, &metaData, 0, kTRUE);
164 if(resECal==kFALSE ) result = 1;
170 // -----------------------------------------------------------------------
171 // Retrieves Front End Electronics Parameters from DCS archive
172 // -----------------------------------------------------------------------
173 AliVZEROTriggerData *triggerData = new AliVZEROTriggerData();
175 // The processing of the DCS input data is forwarded to AliVZERODataFEE
176 fFEEData->ProcessData(*dcsAliasMap);
178 // Writes VZERO FEE parameters values into VZERO Trigger parametrization object
179 triggerData->FillData(fFEEData);
181 // Stores the VZERO Trigger Object into TriggerDB
186 metaData.SetBeamPeriod(0);
187 metaData.SetResponsible("Brigitte Cheynis");
188 metaData.SetComment("This preprocessor fills an AliVZEROTriggerData object");
190 resECal = Store("Trigger", "Data", triggerData, &metaData, 0, kTRUE);
191 if(resECal==kFALSE ) result = 1;