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