1 #include "AliVZEROPreprocessor.h"
2 #include "AliVZEROCalibData.h"
3 #include "AliCDBMetaData.h"
4 #include "AliCDBEntry.h"
5 #include "AliDCSValue.h"
8 #include <TTimeStamp.h>
9 #include <TObjString.h>
14 // This class is a simple preprocessor for V0.
17 ClassImp(AliVZEROPreprocessor)
19 //______________________________________________________________________________________________
20 AliVZEROPreprocessor::AliVZEROPreprocessor(AliShuttleInterface* shuttle) :
21 AliPreprocessor("V00", shuttle),
27 AddRunType("STANDALONE");
28 AddRunType("PHYSICS");
32 //______________________________________________________________________________________________
33 AliVZEROPreprocessor::~AliVZEROPreprocessor()
40 //______________________________________________________________________________________________
41 void AliVZEROPreprocessor::Initialize(Int_t run, UInt_t startTime,
44 // Creates AliZDCDataDCS object
46 AliPreprocessor::Initialize(run, startTime, endTime);
48 Log(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run,
49 TTimeStamp(startTime).AsString(),
50 TTimeStamp(endTime).AsString()));
53 // fStartTime = startTime;
54 // fEndTime = endTime;
55 fStartTime = GetStartTimeDCSQuery ();
56 fEndTime = GetEndTimeDCSQuery ();
58 fData = new AliVZERODataDCS(fRun, fStartTime, fEndTime);
62 //______________________________________________________________________________________________
63 UInt_t AliVZEROPreprocessor::Process(TMap* dcsAliasMap)
65 // Fills data retrieved from DCS and DAQ into a AliVZEROCalibData object and
66 // stores it into CalibrationDB
69 // *** GET RUN TYPE ***
70 TString runType = GetRunType();
73 // *** REFERENCE DATA ***
76 AliVZEROCalibData *calibData = new AliVZEROCalibData();
78 // *************** From DCS ******************
79 // Fills data into a AliVZERODataDCS object
80 if(!dcsAliasMap) return 1;
82 // The processing of the DCS input data is forwarded to AliVZERODataDCS
84 fData->ProcessData(*dcsAliasMap);
85 //fData->Draw(""); // Draws the HV values as a function of time
86 //dcsAliasMap->Print(""); // Prints out the HV values
88 // Writes VZERO PMs HV values into VZERO calibration object
89 calibData->SetMeanHV(fData->GetMeanHV());
90 calibData->SetWidthHV(fData->GetWidthHV());
92 // *************** From DAQ ******************
94 TString SourcesId = "V00da_results";
96 TList* sourceList = GetFileSources(kDAQ, SourcesId.Data());
98 Log(Form("No sources found for id %s", SourcesId.Data()));
100 Log(Form("The following sources produced files with the id %s",SourcesId.Data()));
103 TIter iter(sourceList);
104 TObjString *source = 0;
106 while((source=dynamic_cast<TObjString*> (iter.Next()))){
107 fileName = GetFile(kDAQ, SourcesId.Data(), source->GetName());
108 if (fileName.Length() > 0)
109 Log(Form("Got the file %s, now we can extract some values.", fileName.Data()));
111 if((file = fopen(fileName.Data(),"r")) == NULL){
112 Log(Form("Cannot open file %s",fileName.Data()));
114 Float_t PEDmean[128], PEDsigma[128], ADCmean[128], ADCsigma[128] ;
115 for(Int_t j=0; j<128; j++)fscanf(file,"%f %f %f %f",
116 &PEDmean[j], &PEDsigma[j], &ADCmean[j], &ADCsigma[j]);
119 calibData->SetPedestal(PEDmean);
120 calibData->SetSigma(PEDsigma);
121 calibData->SetGain(ADCmean);
122 calibData->SetADCsigma(ADCsigma);
127 // Check that everything was properly transmitted
129 // for(Int_t j=0; j<128; j++){printf("Pedestal[%d] -> %f \n",j,calibData->GetPedestal(j));}
130 // for(Int_t j=0; j<128; j++){printf("PedSigma[%d] -> %f \n",j,calibData->GetSigma(j));}
131 // for(Int_t j=0; j<128; j++){printf("Gain[%d] -> %f \n",j,calibData->GetGain(j));}
132 // for(Int_t j=0; j<128; j++){printf("ADCsigma[%d] -> %f \n",j,calibData->GetADCsigma(j));}
133 // for(Int_t j=0; j<64; j++){printf("MeanHV[%d] -> %f \n",j,calibData->GetMeanHV(j));}
134 // for(Int_t j=0; j<64; j++){printf("WidthHV[%d] -> %f \n",j,calibData->GetWidthHV(j));}
136 // Now we store the VZERO Calibration Object into CalibrationDB
138 Bool_t resECal=kTRUE;
141 // if(sourceList && sourceList->GetEntries()>0)
143 AliCDBMetaData metaData;
144 metaData.SetBeamPeriod(0);
145 metaData.SetResponsible("Brigitte Cheynis");
146 metaData.SetComment("This preprocessor fills an AliVZEROCalibData object");
148 resECal = Store("Calib", "Data", calibData, &metaData, 0, kTRUE);
150 if(resECal==kFALSE ) result = 1;