1 #include "AliVZEROPreprocessor.h"
2 #include "AliVZEROCalibData.h"
3 #include "AliVZEROTriggerData.h"
4 #include "AliCDBMetaData.h"
5 #include "AliCDBEntry.h"
6 #include "AliDCSValue.h"
9 #include <TTimeStamp.h>
10 #include <TObjString.h>
15 // This class is a simple preprocessor for V0.
18 ClassImp(AliVZEROPreprocessor)
20 //______________________________________________________________________________________________
21 AliVZEROPreprocessor::AliVZEROPreprocessor(AliShuttleInterface* shuttle) :
22 AliPreprocessor("V00", shuttle),
29 AddRunType("STANDALONE");
30 AddRunType("PHYSICS");
34 //______________________________________________________________________________________________
35 AliVZEROPreprocessor::~AliVZEROPreprocessor()
43 //______________________________________________________________________________________________
44 void AliVZEROPreprocessor::Initialize(Int_t run, UInt_t startTime,
47 // Creates AliVZERODataDCS object
49 AliPreprocessor::Initialize(run, startTime, endTime);
51 Log(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run,
52 TTimeStamp(startTime).AsString(),
53 TTimeStamp(endTime).AsString()));
56 // fStartTime = startTime;
57 // fEndTime = endTime;
58 fStartTime = GetStartTimeDCSQuery ();
59 fEndTime = GetEndTimeDCSQuery ();
61 fData = new AliVZERODataDCS(fRun, fStartTime, fEndTime);
62 fFEEData = new AliVZERODataFEE(fRun, fStartTime, fEndTime);
66 //______________________________________________________________________________________________
67 UInt_t AliVZEROPreprocessor::Process(TMap* dcsAliasMap)
69 // Fills data retrieved from DCS and DAQ into a AliVZEROCalibData object and
70 // stores it into CalibrationDB
73 // *** GET RUN TYPE ***
74 TString runType = GetRunType();
77 // *** REFERENCE DATA ***
80 AliVZEROCalibData *calibData = new AliVZEROCalibData();
82 // *************** HV From DCS ******************
83 // Fills data into a AliVZERODataDCS object
84 if(!dcsAliasMap) return 1;
86 // The Processing of the DCS input data is forwarded to AliVZERODataDCS
88 fData->ProcessData(*dcsAliasMap);
89 //fData->Draw(""); // Draws the HV values as a function of time
90 //dcsAliasMap->Print(""); // Prints out the HV values
92 // Writes VZERO PMs HV values into VZERO calibration object
93 calibData->SetMeanHV(fData->GetMeanHV());
94 calibData->SetWidthHV(fData->GetWidthHV());
96 // *************** From DAQ ******************
98 TString SourcesId = "V00da_results";
100 TList* sourceList = GetFileSources(kDAQ, SourcesId.Data());
102 Log(Form("No sources found for id %s", SourcesId.Data()));
104 Log(Form("The following sources produced files with the id %s",SourcesId.Data()));
107 TIter iter(sourceList);
108 TObjString *source = 0;
110 while((source=dynamic_cast<TObjString*> (iter.Next()))){
111 fileName = GetFile(kDAQ, SourcesId.Data(), source->GetName());
112 if (fileName.Length() > 0)
113 Log(Form("Got the file %s, now we can extract some values.", fileName.Data()));
115 if((file = fopen(fileName.Data(),"r")) == NULL){
116 Log(Form("Cannot open file %s",fileName.Data()));
118 Float_t PEDmean[128], PEDsigma[128], ADCmean[128], ADCsigma[128] ;
119 for(Int_t j=0; j<128; j++)fscanf(file,"%f %f %f %f",
120 &PEDmean[j], &PEDsigma[j], &ADCmean[j], &ADCsigma[j]);
123 calibData->SetPedestal(PEDmean);
124 calibData->SetSigma(PEDsigma);
125 calibData->SetGain(ADCmean);
126 calibData->SetADCsigma(ADCsigma);
131 // Check that everything was properly transmitted
133 // for(Int_t j=0; j<128; j++){printf("Pedestal[%d] -> %f \n",j,calibData->GetPedestal(j));}
134 // for(Int_t j=0; j<128; j++){printf("PedSigma[%d] -> %f \n",j,calibData->GetSigma(j));}
135 // for(Int_t j=0; j<128; j++){printf("Gain[%d] -> %f \n",j,calibData->GetGain(j));}
136 // for(Int_t j=0; j<128; j++){printf("ADCsigma[%d] -> %f \n",j,calibData->GetADCsigma(j));}
137 // for(Int_t j=0; j<64; j++){printf("MeanHV[%d] -> %f \n",j,calibData->GetMeanHV(j));}
138 // for(Int_t j=0; j<64; j++){printf("WidthHV[%d] -> %f \n",j,calibData->GetWidthHV(j));}
140 // Now we store the VZERO Calibration Object into CalibrationDB
142 Bool_t resECal=kTRUE;
145 // if(sourceList && sourceList->GetEntries()>0)
147 AliCDBMetaData metaData;
148 metaData.SetBeamPeriod(0);
149 metaData.SetResponsible("Brigitte Cheynis");
150 metaData.SetComment("This preprocessor fills an AliVZEROCalibData object");
152 resECal = Store("Calib", "Data", calibData, &metaData, 0, kTRUE);
154 if(resECal==kFALSE ) result = 1;
160 // -----------------------------------------------------------------------
161 // Retrieve Front End Electronics Parameters from the DCS
162 // -----------------------------------------------------------------------
163 AliVZEROTriggerData *triggerData = new AliVZEROTriggerData();
165 // The processing of the DCS input data is forwarded to AliVZERODataFEE
166 fFEEData->ProcessData(*dcsAliasMap);
168 // Writes VZERO FEE parameters values into VZERO Trigger parametrization object
169 triggerData->FillData(fFEEData);
171 // Stores the VZERO Trigger Object into CalibrationDB
176 metaData.SetBeamPeriod(0);
177 metaData.SetResponsible("Brigitte Cheynis");
178 metaData.SetComment("This preprocessor fills an AliVZEROTriggerData object");
180 resECal = Store("Trigger", "Data", triggerData, &metaData, 0, kTRUE);
181 if(resECal==kFALSE ) result = 1;