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");
42 AddRunType("PHYSICS");
46 //______________________________________________________________________________________________
47 AliVZEROPreprocessor::~AliVZEROPreprocessor()
55 //______________________________________________________________________________________________
56 void AliVZEROPreprocessor::Initialize(Int_t run, UInt_t startTime,
59 // Creates AliVZERODataDCS object
61 AliPreprocessor::Initialize(run, startTime, endTime);
63 Log(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run,
64 TTimeStamp(startTime).AsString(),
65 TTimeStamp(endTime).AsString()));
68 // fStartTime = startTime;
69 // fEndTime = endTime;
70 fStartTime = GetStartTimeDCSQuery ();
71 fEndTime = GetEndTimeDCSQuery ();
73 fData = new AliVZERODataDCS(fRun, fStartTime, fEndTime);
74 fFEEData = new AliVZERODataFEE(fRun, fStartTime, fEndTime);
78 //______________________________________________________________________________________________
79 UInt_t AliVZEROPreprocessor::Process(TMap* dcsAliasMap)
81 // Fills data retrieved from DCS and DAQ into a AliVZEROCalibData object and
82 // stores it into CalibrationDB
85 // *** GET RUN TYPE ***
86 TString runType = GetRunType();
89 // *** REFERENCE DATA ***
92 AliVZEROCalibData *calibData = new AliVZEROCalibData();
94 // *************** HV From DCS ******************
95 // Fills data into a AliVZERODataDCS object
96 if(!dcsAliasMap) return 1;
98 // The Processing of the DCS input data is forwarded to AliVZERODataDCS
100 fData->ProcessData(*dcsAliasMap);
101 //fData->Draw(""); // Draws the HV values as a function of time
102 //dcsAliasMap->Print(""); // Prints out the HV values
104 // Writes VZERO PMs HV values into VZERO calibration object
105 calibData->SetMeanHV(fData->GetMeanHV());
106 calibData->SetWidthHV(fData->GetWidthHV());
108 // *************** From DAQ ******************
110 TString sourcesId = "V00da_results";
112 TList* sourceList = GetFileSources(kDAQ, sourcesId.Data());
114 Log(Form("No sources found for id %s", sourcesId.Data()));
116 Log(Form("The following sources produced files with the id %s",sourcesId.Data()));
119 TIter iter(sourceList);
120 TObjString *source = 0;
122 while((source=dynamic_cast<TObjString*> (iter.Next()))){
123 fileName = GetFile(kDAQ, sourcesId.Data(), source->GetName());
124 if (fileName.Length() > 0)
125 Log(Form("Got the file %s, now we can extract some values.", fileName.Data()));
127 if((file = fopen(fileName.Data(),"r")) == NULL){
128 Log(Form("Cannot open file %s",fileName.Data()));
130 Float_t pedMean[128], pedSigma[128], adcMean[128], adcSigma[128] ;
131 for(Int_t j=0; j<128; j++)fscanf(file,"%f %f %f %f",
132 &pedMean[j], &pedSigma[j], &adcMean[j], &adcSigma[j]);
135 calibData->SetPedestal(pedMean);
136 calibData->SetSigma(pedSigma);
137 calibData->SetGain(adcMean);
138 calibData->SetADCsigma(adcSigma);
143 // Check that everything was properly transmitted
145 // for(Int_t j=0; j<128; j++){printf("Pedestal[%d] -> %f \n",j,calibData->GetPedestal(j));}
146 // for(Int_t j=0; j<128; j++){printf("pedSigma[%d] -> %f \n",j,calibData->GetSigma(j));}
147 // for(Int_t j=0; j<128; j++){printf("Gain[%d] -> %f \n",j,calibData->GetGain(j));}
148 // for(Int_t j=0; j<128; j++){printf("adcSigma[%d] -> %f \n",j,calibData->GetADCsigma(j));}
149 // for(Int_t j=0; j<64; j++){printf("MeanHV[%d] -> %f \n",j,calibData->GetMeanHV(j));}
150 // for(Int_t j=0; j<64; j++){printf("WidthHV[%d] -> %f \n",j,calibData->GetWidthHV(j));}
152 // Now we store the VZERO Calibration Object into CalibrationDB
154 Bool_t resECal=kTRUE;
157 // if(sourceList && sourceList->GetEntries()>0)
159 AliCDBMetaData metaData;
160 metaData.SetBeamPeriod(0);
161 metaData.SetResponsible("Brigitte Cheynis");
162 metaData.SetComment("This preprocessor fills an AliVZEROCalibData object");
164 resECal = Store("Calib", "Data", calibData, &metaData, 0, kTRUE);
166 if(resECal==kFALSE ) result = 1;
172 // -----------------------------------------------------------------------
173 // Retrieves Front End Electronics Parameters from DCS archive
174 // -----------------------------------------------------------------------
175 AliVZEROTriggerData *triggerData = new AliVZEROTriggerData();
177 // The processing of the DCS input data is forwarded to AliVZERODataFEE
178 fFEEData->ProcessData(*dcsAliasMap);
180 // Writes VZERO FEE parameters values into VZERO Trigger parametrization object
181 triggerData->FillData(fFEEData);
183 // Stores the VZERO Trigger Object into TriggerDB
188 metaData.SetBeamPeriod(0);
189 metaData.SetResponsible("Brigitte Cheynis");
190 metaData.SetComment("This preprocessor fills an AliVZEROTriggerData object");
192 resECal = Store("Trigger", "Data", triggerData, &metaData, 0, kTRUE);
193 if(resECal==kFALSE ) result = 1;