]> git.uio.no Git - u/mrichter/AliRoot.git/blob - VZERO/AliVZEROPreprocessor.cxx
Use standard cuts.
[u/mrichter/AliRoot.git] / VZERO / AliVZEROPreprocessor.cxx
1 #include "AliVZEROPreprocessor.h"
2 #include "AliVZEROCalibData.h"
3 #include "AliVZEROTriggerData.h"
4 #include "AliCDBMetaData.h"
5 #include "AliCDBEntry.h"
6 #include "AliDCSValue.h"
7 #include "AliLog.h"
8 #include "AliShuttleInterface.h"
9 #include "AliVZERODataFEE.h"
10 #include "AliVZERODataDCS.h"
11
12 #include <TFile.h>
13 #include <TTimeStamp.h>
14 #include <TObjString.h>
15 #include <TSystem.h>
16
17
18 class Tlist;
19
20 //
21 //  This class is  a simple preprocessor for VZERO detector.
22 //
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)
28 //
29
30 ClassImp(AliVZEROPreprocessor)
31
32 //______________________________________________________________________________________________
33 AliVZEROPreprocessor::AliVZEROPreprocessor(AliShuttleInterface* shuttle) :
34         AliPreprocessor("V00", shuttle),
35         fData(0),
36         fFEEData(0)
37  
38 {
39   // constructor  
40   
41   AddRunType("STANDALONE");
42   AddRunType("PHYSICS");
43     
44 }
45
46 //______________________________________________________________________________________________
47 AliVZEROPreprocessor::~AliVZEROPreprocessor()
48 {
49   // destructor
50         delete fFEEData;
51         delete fData;
52         
53 }
54
55 //______________________________________________________________________________________________
56 void AliVZEROPreprocessor::Initialize(Int_t run, UInt_t startTime,
57         UInt_t endTime)
58 {
59   // Creates AliVZERODataDCS object
60
61    AliPreprocessor::Initialize(run, startTime, endTime);
62   
63    Log(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run,
64                 TTimeStamp(startTime).AsString(),
65                 TTimeStamp(endTime).AsString()));
66
67    fRun       = run;
68    // fStartTime = startTime;
69    // fEndTime   = endTime;
70    fStartTime = GetStartTimeDCSQuery ();
71    fEndTime   = GetEndTimeDCSQuery ();
72
73         fData      = new AliVZERODataDCS(fRun, fStartTime, fEndTime);
74         fFEEData   = new AliVZERODataFEE(fRun, fStartTime, fEndTime);           
75    
76 }
77
78 //______________________________________________________________________________________________
79 UInt_t AliVZEROPreprocessor::Process(TMap* dcsAliasMap)
80 {
81   // Fills data retrieved from DCS and DAQ into a AliVZEROCalibData object and 
82   // stores it into CalibrationDB
83
84
85   // *** GET RUN TYPE ***
86   TString runType = GetRunType();
87
88
89   // *** REFERENCE DATA *** 
90   
91   TString fileName; 
92   AliVZEROCalibData *calibData = new AliVZEROCalibData();
93   
94   // *************** HV From DCS ******************
95   // Fills data into a AliVZERODataDCS object
96   if(!dcsAliasMap) return 1;
97
98         // The Processing of the DCS input data is forwarded to AliVZERODataDCS
99
100         fData->ProcessData(*dcsAliasMap);
101         //fData->Draw("");              // Draws the HV values as a function of time
102         //dcsAliasMap->Print("");       // Prints out the HV values
103
104         // Writes VZERO PMs HV values into VZERO calibration object
105         calibData->SetMeanHV(fData->GetMeanHV());
106         calibData->SetWidthHV(fData->GetWidthHV());
107     
108    // *************** From DAQ ******************
109    
110         TString sourcesId = "V00da_results";
111
112         TList* sourceList = GetFileSources(kDAQ, sourcesId.Data());
113         if (!sourceList)  {
114                 Log(Form("No sources found for id %s", sourcesId.Data()));                      
115                 return 1; }
116         Log(Form("The following sources produced files with the id %s",sourcesId.Data()));
117         sourceList->Print();    
118
119         TIter iter(sourceList);
120         TObjString *source = 0;
121                 
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()));
126                 FILE *file;
127                 if((file = fopen(fileName.Data(),"r")) == NULL){
128                                    Log(Form("Cannot open file %s",fileName.Data()));
129                                    return 1;}
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]);
133                 fclose(file);
134                 
135                 calibData->SetPedestal(pedMean);
136                 calibData->SetSigma(pedSigma);                  
137                 calibData->SetGain(adcMean); 
138                 calibData->SetADCsigma(adcSigma);
139                 }                               
140
141         delete source;      
142   
143   // Check that everything was properly transmitted
144
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));}
151   
152   // Now we store the VZERO Calibration Object into CalibrationDB
153
154   Bool_t resECal=kTRUE;
155   
156   Bool_t result = 0;
157 //  if(sourceList && sourceList->GetEntries()>0)
158 //  {
159   AliCDBMetaData metaData;
160   metaData.SetBeamPeriod(0);
161   metaData.SetResponsible("Brigitte Cheynis");
162   metaData.SetComment("This preprocessor fills an AliVZEROCalibData object");
163
164   resECal = Store("Calib", "Data", calibData, &metaData, 0, kTRUE);
165 //  }
166   if(resECal==kFALSE ) result = 1;
167   
168
169   delete calibData;
170   delete sourceList; 
171
172  // -----------------------------------------------------------------------
173  // Retrieves Front End Electronics Parameters from  DCS archive
174  // -----------------------------------------------------------------------
175         AliVZEROTriggerData *triggerData = new AliVZEROTriggerData();
176
177         // The processing of the DCS input data is forwarded to AliVZERODataFEE
178         fFEEData->ProcessData(*dcsAliasMap);
179
180         // Writes VZERO FEE parameters values into VZERO  Trigger parametrization object
181         triggerData->FillData(fFEEData);
182
183         // Stores the VZERO Trigger Object into TriggerDB
184         
185         resECal=kTRUE;
186         
187         result = 0;
188         metaData.SetBeamPeriod(0);
189         metaData.SetResponsible("Brigitte Cheynis");
190         metaData.SetComment("This preprocessor fills an AliVZEROTriggerData object");
191         
192         resECal = Store("Trigger", "Data", triggerData, &metaData, 0, kTRUE);
193         if(resECal==kFALSE ) result = 1;
194         
195         
196   return result;
197 }
198