]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - VZERO/AliVZEROPreprocessor.cxx
Protection added in filling DigitTree
[u/mrichter/AliRoot.git] / VZERO / AliVZEROPreprocessor.cxx
index cf67eb370c2cb2c9215da8596d004c75d2888d96..3fab728265356ef07c214fa6d29289d9b1800449 100644 (file)
@@ -1,57 +1,80 @@
 #include "AliVZEROPreprocessor.h"
 #include "AliVZEROCalibData.h"
+#include "AliVZEROTriggerData.h"
 #include "AliCDBMetaData.h"
 #include "AliCDBEntry.h"
 #include "AliDCSValue.h"
 #include "AliLog.h"
+#include "AliShuttleInterface.h"
+#include "AliVZERODataFEE.h"
+#include "AliVZERODataDCS.h"
+
 #include <TFile.h>
 #include <TTimeStamp.h>
 #include <TObjString.h>
 #include <TSystem.h>
-#include <TList.h>
 
+
+class Tlist;
+
+//
+//  This class is  a simple preprocessor for VZERO detector.
 //
-// This class is  a simple preprocessor for V0.
+//  It gets High Voltage values for a given run from DCS and Pedestal values from DAQ 
+//  and writes them as Calibration MetaData into OCDB/VZERO/Calib/Data
+//  It also retrieves FEE parameters from DCS archive   
+//  and writes them as Trigger MetaData into OCDB/VZERO/Trigger/Data 
+//  (to be used for trigger simulation)
 //
 
 ClassImp(AliVZEROPreprocessor)
 
 //______________________________________________________________________________________________
 AliVZEROPreprocessor::AliVZEROPreprocessor(AliShuttleInterface* shuttle) :
-  AliPreprocessor("V00", shuttle),
-  fData(0)
+       AliPreprocessor("V00", shuttle),
+       fData(0),
+       fFEEData(0)
  
 {
-  // constructor
+  // constructor  
+  
+  AddRunType("STANDALONE");
+  AddRunType("PHYSICS");
+    
 }
 
 //______________________________________________________________________________________________
 AliVZEROPreprocessor::~AliVZEROPreprocessor()
 {
   // destructor
+       delete fFEEData;
+       delete fData;
+       
 }
 
 //______________________________________________________________________________________________
 void AliVZEROPreprocessor::Initialize(Int_t run, UInt_t startTime,
        UInt_t endTime)
 {
-  // Creates AliZDCDataDCS object
-
-  AliPreprocessor::Initialize(run, startTime, endTime);
+  // Creates AliVZERODataDCS object
 
-       Log(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run,
+   AliPreprocessor::Initialize(run, startTime, endTime);
+  
+   Log(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run,
                TTimeStamp(startTime).AsString(),
                TTimeStamp(endTime).AsString()));
 
-       fRun = run;
-        fStartTime = startTime;
-        fEndTime = endTime;
+   fRun       = run;
+   // fStartTime = startTime;
+   // fEndTime   = endTime;
+   fStartTime = GetStartTimeDCSQuery ();
+   fEndTime   = GetEndTimeDCSQuery ();
 
-       fData = new AliVZERODataDCS(fRun, fStartTime, fEndTime);
+       fData      = new AliVZERODataDCS(fRun, fStartTime, fEndTime);
+       fFEEData   = new AliVZERODataFEE(fRun, fStartTime, fEndTime);           
+   
 }
 
-
-
 //______________________________________________________________________________________________
 UInt_t AliVZEROPreprocessor::Process(TMap* dcsAliasMap)
 {
@@ -68,88 +91,108 @@ UInt_t AliVZEROPreprocessor::Process(TMap* dcsAliasMap)
   TString fileName; 
   AliVZEROCalibData *calibData = new AliVZEROCalibData();
   
-  // *************** From DCS ******************
+  // *************** HV From DCS ******************
   // Fills data into a AliVZERODataDCS object
   if(!dcsAliasMap) return 1;
 
-       // The processing of the DCS input data is forwarded to AliVZERODataDCS
+       // The Processing of the DCS input data is forwarded to AliVZERODataDCS
 
        fData->ProcessData(*dcsAliasMap);
-       //fData->Draw("");              // Draw the HV values as a function of time
-       //dcsAliasMap->Print("");       // Print out the HV values
+       //fData->Draw("");              // Draws the HV values as a function of time
+       //dcsAliasMap->Print("");       // Prints out the HV values
 
-       // Writing VZERO PMs HV values into calibration object
+       // Writes VZERO PMs HV values into VZERO calibration object
        calibData->SetMeanHV(fData->GetMeanHV());
        calibData->SetWidthHV(fData->GetWidthHV());
-  
-  
+    
    // *************** From DAQ ******************
-       TString SourcesId[3];
-       SourcesId[0] = "PEDESTALS";
-       SourcesId[1] = "GAINS";
-       SourcesId[2] = "SIGMAS";
-
-       for(int iSource=0;iSource<3;iSource++){
-               TList* sourceList = GetFileSources(kDAQ, SourcesId[iSource].Data());
-               if (!sourceList){
-                       AliError(Form("No sources found for id %s", SourcesId[iSource].Data()));                
-               return 1;   
-               }
-               AliInfo(Form("The following sources produced files with the id %s",SourcesId[iSource].Data()));
-               sourceList->Print();    
-
-               TIter iter(sourceList);
-               TObjString *source = 0;
+   
+       TString sourcesId = "V00da_results";
+
+       TList* sourceList = GetFileSources(kDAQ, sourcesId.Data());
+       if (!sourceList)  {
+               Log(Form("No sources found for id %s", sourcesId.Data()));                      
+               return 1; }
+       Log(Form("The following sources produced files with the id %s",sourcesId.Data()));
+       sourceList->Print();    
+
+       TIter iter(sourceList);
+       TObjString *source = 0;
                
-               while((source=dynamic_cast<TObjString*> (iter.Next()))){
-                       fileName = GetFile(kDAQ, SourcesId[iSource].Data(), source->GetName());
-                       if (fileName.Length() > 0)
-                       AliInfo(Form("Got the file %s, now we can extract some values.", fileName.Data()));
-                       FILE *file;
-                       if((file = fopen(fileName.Data(),"r")) == NULL){
-               AliError(Form("Cannot open file %s",fileName.Data()));
-                       return 1;
-                       }
-                       Float_t Values[128];
-                       for(Int_t j=0; j<128; j++)fscanf(file,"%f",&Values[j]);
-                       fclose(file);
-               switch(iSource){
-                               case 0:
-                                       calibData->SetPedestal(Values);
-                                       break;
-                               case 1:
-                                       calibData->SetGain(Values);
-                                       break;
-                               case 2:
-                                       calibData->SetSigma(Values);
-                                       break;
-                               }
-               }
-               delete sourceList;
-
-       }
-      
+       while((source=dynamic_cast<TObjString*> (iter.Next()))){
+               fileName = GetFile(kDAQ, sourcesId.Data(), source->GetName());
+               if (fileName.Length() > 0)
+               Log(Form("Got the file %s, now we can extract some values.", fileName.Data()));
+               FILE *file;
+               if((file = fopen(fileName.Data(),"r")) == NULL){
+                                  Log(Form("Cannot open file %s",fileName.Data()));
+                                  return 1;}
+               Float_t pedMean[128], pedSigma[128], adcMean[128], adcSigma[128] ;
+               for(Int_t j=0; j<128; j++)fscanf(file,"%f %f %f %f",
+                                         &pedMean[j], &pedSigma[j], &adcMean[j], &adcSigma[j]);
+               fclose(file);
+               
+               calibData->SetPedestal(pedMean);
+               calibData->SetSigma(pedSigma);                  
+               calibData->SetGain(adcMean); 
+               calibData->SetADCsigma(adcSigma);
+               }                               
+
+       delete source;      
   
   // Check that everything was properly transmitted
 
-//   for(Int_t j=0; j<128; j++){printf("ADCPedestal[%d] -> %f \n",j,calibData->GetPedestal(j));}
-//   for(Int_t j=0; j<128; j++){printf("ADCGain[%d] -> %f \n",j,calibData->GetGain(j));}
-//   for(Int_t j=0; j<128; j++){printf("ADCSigma[%d] -> %f \n",j,calibData->GetSigma(j));}
+//   for(Int_t j=0; j<128; j++){printf("Pedestal[%d] -> %f \n",j,calibData->GetPedestal(j));}
+//   for(Int_t j=0; j<128; j++){printf("pedSigma[%d] -> %f \n",j,calibData->GetSigma(j));}
+//   for(Int_t j=0; j<128; j++){printf("Gain[%d] -> %f \n",j,calibData->GetGain(j));}
+//   for(Int_t j=0; j<128; j++){printf("adcSigma[%d] -> %f \n",j,calibData->GetADCsigma(j));}
 //   for(Int_t j=0; j<64; j++){printf("MeanHV[%d] -> %f \n",j,calibData->GetMeanHV(j));}
 //   for(Int_t j=0; j<64; j++){printf("WidthHV[%d] -> %f \n",j,calibData->GetWidthHV(j));}
-//   
-  // Now we  store the VZERO Calibration Object into CalibrationDB
   
+  // Now we store the VZERO Calibration Object into CalibrationDB
+
+  Bool_t resECal=kTRUE;
+  
+  Bool_t result = 0;
+//  if(sourceList && sourceList->GetEntries()>0)
+//  {
   AliCDBMetaData metaData;
   metaData.SetBeamPeriod(0);
   metaData.SetResponsible("Brigitte Cheynis");
   metaData.SetComment("This preprocessor fills an AliVZEROCalibData object");
 
-  Bool_t result = Store("Calib", "Data", calibData, &metaData, 0, kTRUE);
+  resECal = Store("Calib", "Data", calibData, &metaData, 0, kTRUE);
+//  }
+  if(resECal==kFALSE ) result = 1;
+  
 
   delete calibData;
-
-  if (!result) return 1;   
-  return 0;
+  delete sourceList; 
+
+ // -----------------------------------------------------------------------
+ // Retrieves Front End Electronics Parameters from  DCS archive
+ // -----------------------------------------------------------------------
+       AliVZEROTriggerData *triggerData = new AliVZEROTriggerData();
+
+       // The processing of the DCS input data is forwarded to AliVZERODataFEE
+       fFEEData->ProcessData(*dcsAliasMap);
+
+       // Writes VZERO FEE parameters values into VZERO  Trigger parametrization object
+       triggerData->FillData(fFEEData);
+
+       // Stores the VZERO Trigger Object into TriggerDB
+       
+       resECal=kTRUE;
+       
+       result = 0;
+       metaData.SetBeamPeriod(0);
+       metaData.SetResponsible("Brigitte Cheynis");
+       metaData.SetComment("This preprocessor fills an AliVZEROTriggerData object");
+       
+       resECal = Store("Trigger", "Data", triggerData, &metaData, 0, kTRUE);
+       if(resECal==kFALSE ) result = 1;
+       
+       
+  return result;
 }