LCOV - code coverage report
Current view: top level - VZERO/VZERObase - AliVZEROPreprocessor.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 116 0.9 %
Date: 2016-06-14 17:26:59 Functions: 1 8 12.5 %

          Line data    Source code
       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             : #include <TH1F.h>
      17             : 
      18             : 
      19             : class Tlist;
      20             : 
      21             : //
      22             : //  This class is  a simple preprocessor for VZERO detector.
      23             : //
      24             : //  It gets High Voltage values for a given run from DCS and Pedestal values from DAQ 
      25             : //  and writes them as Calibration MetaData into OCDB/VZERO/Calib/Data
      26             : //  It also retrieves FEE parameters from DCS archive   
      27             : //  and writes them as Trigger MetaData into OCDB/VZERO/Trigger/Data 
      28             : //  (to be used for trigger simulation)
      29             : //
      30             : 
      31          44 : ClassImp(AliVZEROPreprocessor)
      32             : 
      33             : //______________________________________________________________________________________________
      34             : AliVZEROPreprocessor::AliVZEROPreprocessor(AliShuttleInterface* shuttle) :
      35           0 :         AliPreprocessor("V00", shuttle),
      36           0 :         fData(0),
      37           0 :         fFEEData(0)
      38             :  
      39           0 : {
      40             :   // constructor  
      41             :   
      42           0 :   AddRunType("STANDALONE_PULSER");
      43           0 :   AddRunType("STANDALONE_BC");
      44           0 :   AddRunType("PHYSICS");
      45             :     
      46           0 : }
      47             : 
      48             : //______________________________________________________________________________________________
      49             : AliVZEROPreprocessor::~AliVZEROPreprocessor()
      50           0 : {
      51             :   // destructor
      52           0 :         delete fFEEData;
      53           0 :         delete fData;
      54             :         
      55           0 : }
      56             : 
      57             : //______________________________________________________________________________________________
      58             : void AliVZEROPreprocessor::Initialize(Int_t run, UInt_t startTime,
      59             :         UInt_t endTime)
      60             : {
      61             :   // Creates AliVZERODataDCS object
      62             : 
      63           0 :    AliPreprocessor::Initialize(run, startTime, endTime);
      64             :   
      65           0 :    Log(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run,
      66           0 :                 TTimeStamp(startTime).AsString(),
      67           0 :                 TTimeStamp(endTime).AsString()));
      68             : 
      69           0 :    fRun       = run;
      70             :    // fStartTime = startTime;
      71             :    // fEndTime   = endTime;
      72           0 :    fStartTime = GetStartTimeDCSQuery ();
      73           0 :    fEndTime   = GetEndTimeDCSQuery ();
      74           0 :    time_t daqStart = (time_t) (((TString)GetRunParameter("DAQ_time_start")).Atoi());
      75           0 :    time_t daqEnd   = (time_t) (((TString)GetRunParameter("DAQ_time_end")).Atoi());
      76           0 :    time_t ctpStart = (time_t) (((TString)GetRunParameter("TRGTimeStart")).Atoi());
      77           0 :    time_t ctpEnd   = (time_t) (((TString)GetRunParameter("TRGTimeEnd")).Atoi());
      78             :    
      79           0 :         fData      = new AliVZERODataDCS(fRun, fStartTime, fEndTime,(UInt_t)daqStart, (UInt_t)daqEnd,(UInt_t)ctpStart, (UInt_t)ctpEnd);
      80           0 :         fFEEData   = new AliVZERODataFEE(fRun, fStartTime, fEndTime);           
      81             :    
      82           0 : }
      83             : 
      84             : //______________________________________________________________________________________________
      85             : UInt_t AliVZEROPreprocessor::Process(TMap* dcsAliasMap)
      86             : {
      87             :   // Fills data retrieved from DCS and DAQ into a AliVZEROCalibData object and 
      88             :   // stores it into CalibrationDB
      89             : 
      90             : 
      91             :   // *** GET RUN TYPE ***
      92           0 :   TString runType = GetRunType();
      93             : 
      94             : 
      95             :   // *** REFERENCE DATA *** 
      96             :   
      97           0 :   TString fileName; 
      98           0 :   AliVZEROCalibData *calibData = new AliVZEROCalibData();
      99             :   
     100             :   // *************** HV From DCS ******************
     101             :   // Fills data into a AliVZERODataDCS object
     102           0 :   if(!dcsAliasMap) return 1;
     103             : 
     104             :         // The Processing of the DCS input data is forwarded to AliVZERODataDCS
     105           0 :   if (!fData->ProcessData(*dcsAliasMap)) return 1;
     106             : 
     107             :         // Writes VZERO PMs HV values into VZERO calibration object and Timing resolution parameters
     108           0 :         calibData->FillDCSData(fData);
     109             :            
     110             :    // *************** From DAQ ******************
     111             :    
     112           0 :         TString sourcesId = "V00da_results";
     113             : 
     114           0 :         TList* sourceList = GetFileSources(kDAQ, sourcesId.Data());
     115           0 :         if (!sourceList)  {
     116           0 :                 Log(Form("No sources found for id %s", sourcesId.Data()));                    
     117           0 :                 return 1; }
     118           0 :         Log(Form("The following sources produced files with the id %s",sourcesId.Data()));
     119           0 :         sourceList->Print();    
     120             : 
     121           0 :         TIter iter(sourceList);
     122             :         TObjString *source;
     123             :                 
     124           0 :         while((source=dynamic_cast<TObjString*> (iter.Next()))){
     125           0 :                 fileName = GetFile(kDAQ, sourcesId.Data(), source->GetName());
     126           0 :                 if (fileName.Length() > 0)
     127           0 :                 Log(Form("Got the file %s, now we can extract some values.", fileName.Data()));
     128             :                 FILE *file;
     129           0 :                 if((file = fopen(fileName.Data(),"r")) == NULL){
     130           0 :                                    Log(Form("Cannot open file %s",fileName.Data()));
     131           0 :                                    return 1;}
     132           0 :                 Float_t pedMean[128], pedSigma[128], adcMean[128], adcSigma[128] ;
     133           0 :                 for(Int_t j=0; j<128; j++) {
     134           0 :                   Int_t resScan = fscanf(file,"%f %f %f %f",
     135           0 :                                          &pedMean[j], &pedSigma[j], &adcMean[j], &adcSigma[j]);
     136           0 :                   if (resScan != 4) Log(Form("Bad data in file %s !",fileName.Data()));
     137             :                 }
     138           0 :                 fclose(file);
     139             :                 
     140           0 :                 calibData->SetPedestal(pedMean);
     141           0 :                 calibData->SetSigma(pedSigma);                       
     142           0 :                 calibData->SetADCsigma(adcSigma);
     143           0 :                 }                               
     144             : 
     145           0 :         delete source;      
     146             :   
     147             :   // Check that everything was properly transmitted
     148             : 
     149             : //   for(Int_t j=0; j<128; j++){printf("Pedestal[%d] -> %f \n",j,calibData->GetPedestal(j));}
     150             : //   for(Int_t j=0; j<128; j++){printf("pedSigma[%d] -> %f \n",j,calibData->GetSigma(j));}
     151             : //   for(Int_t j=0; j<128; j++){printf("Gain[%d] -> %f \n",j,calibData->GetGain(j));}
     152             : //   for(Int_t j=0; j<128; j++){printf("adcSigma[%d] -> %f \n",j,calibData->GetADCsigma(j));}
     153             : //   for(Int_t j=0; j<64; j++){printf("MeanHV[%d] -> %f \n",j,calibData->GetMeanHV(j));}
     154             : //   for(Int_t j=0; j<64; j++){printf("WidthHV[%d] -> %f \n",j,calibData->GetWidthHV(j));}
     155             :   
     156             :   // Now we store the VZERO Calibration Object into CalibrationDB
     157             : 
     158             :   Bool_t resECal=kTRUE;
     159             :   
     160             :   Bool_t result = 0;
     161             : //  if(sourceList && sourceList->GetEntries()>0)
     162             : //  {
     163           0 :   AliCDBMetaData metaData;
     164           0 :   metaData.SetBeamPeriod(0);
     165           0 :   metaData.SetResponsible("Brigitte Cheynis");
     166           0 :   metaData.SetComment("This preprocessor fills an AliVZEROCalibData object");
     167             : 
     168           0 :   resECal = Store("Calib", "Data", calibData, &metaData, 0, kTRUE);
     169             : //  }
     170           0 :   if(resECal==kFALSE ) result = 1;
     171             :   
     172             : 
     173           0 :   delete calibData;
     174           0 :   delete sourceList; 
     175             : 
     176             :  // -----------------------------------------------------------------------
     177             :  // Retrieves Front End Electronics Parameters from  DCS archive
     178             :  // -----------------------------------------------------------------------
     179           0 :         AliVZEROTriggerData *triggerData = new AliVZEROTriggerData();
     180             : 
     181             :         // The processing of the DCS input data is forwarded to AliVZERODataFEE
     182           0 :         fFEEData->ProcessData(*dcsAliasMap);
     183             : 
     184             :         // Writes VZERO FEE parameters values into VZERO  Trigger parametrization object
     185           0 :         triggerData->FillData(fFEEData);
     186             : 
     187             :         // Stores the VZERO Trigger Object into TriggerDB
     188             :         
     189             :         resECal=kTRUE;
     190             :         
     191           0 :         metaData.SetBeamPeriod(0);
     192           0 :         metaData.SetResponsible("Brigitte Cheynis");
     193           0 :         metaData.SetComment("This preprocessor fills an AliVZEROTriggerData object");
     194             :         
     195           0 :         resECal = Store("Trigger", "Data", triggerData, &metaData, 0, kTRUE);
     196           0 :         if(resECal==kFALSE ) result = 1;
     197             :         
     198             : 
     199             :    // *************** From DAQ DA - Equalization factors ******************
     200             :   
     201           0 :   TH1F *eqFactors = new TH1F("VZEROEqualizationFactors","VZERO Equalization Factors for Pb-Pb",64,-0.5,63.5);
     202           0 :   sourcesId = "V00DAEqualFactors";
     203             : 
     204           0 :   TList* sourceList2 = GetFileSources(kDAQ, sourcesId.Data());
     205           0 :   if (!sourceList2)  {
     206           0 :     Log(Form("No sources found for id %s", sourcesId.Data()));                
     207           0 :     return 1; }
     208           0 :   Log(Form("The following sources produced files with the id %s",sourcesId.Data()));
     209           0 :   sourceList2->Print();
     210             : 
     211           0 :   TIter iter2(sourceList2);
     212             :   TObjString *source2;
     213             :                 
     214           0 :   while((source2=dynamic_cast<TObjString*> (iter2.Next()))){
     215           0 :     fileName = GetFile(kDAQ, sourcesId.Data(), source2->GetName());
     216           0 :     if (fileName.Length() > 0)
     217           0 :       Log(Form("Got the file %s, now we can extract some values.", fileName.Data()));
     218             :     FILE *file2;
     219           0 :     if((file2 = fopen(fileName.Data(),"r")) == NULL){
     220           0 :       Log(Form("Cannot open file %s",fileName.Data()));
     221           0 :       return 1;}
     222             : 
     223           0 :     Double_t alpha[66];
     224           0 :     alpha[0] = alpha[65] = 0;
     225           0 :     Int_t tempCh;
     226           0 :     Float_t tempAlpha;
     227           0 :     for(Int_t j=0; j<64; ++j) {
     228           0 :       Int_t resScan = fscanf(file2,"%d %f", &tempCh, &tempAlpha);
     229           0 :       if (resScan != 2) Log(Form("Bad data in file %s !",fileName.Data()));
     230           0 :       alpha[tempCh+1] = tempAlpha;
     231             :     }
     232           0 :     fclose(file2);
     233             : 
     234             :     // Check that everything was properly transmitted
     235           0 :     printf("Equalization factors (0->64): ");
     236           0 :     for(Int_t j=0; j<64; ++j) printf("%.5f ",alpha[j+1]);
     237           0 :     printf("\n");
     238             : 
     239           0 :     eqFactors->SetContent(alpha);
     240           0 :   }
     241             : 
     242           0 :   delete source2;      
     243             :   
     244             :   // Now we store the VZERO Equalization Factors Object into OCDB
     245             : 
     246             :   resECal=kTRUE;
     247             :   
     248           0 :   AliCDBMetaData metaData2;
     249           0 :   metaData2.SetBeamPeriod(0);
     250           0 :   metaData2.SetResponsible("Brigitte Cheynis");
     251           0 :   metaData2.SetComment("VZERO Equalization Factors object filled by VZERO preprocessor");
     252             : 
     253           0 :   resECal = Store("Calib", "EqualizationFactors", eqFactors, &metaData2, 0, kTRUE);
     254             : 
     255           0 :   if(resECal==kFALSE ) result = 1;
     256             : 
     257           0 :   delete eqFactors;
     258           0 :   delete sourceList2; 
     259             : 
     260             :         
     261           0 :   return result;
     262           0 : }
     263             : 

Generated by: LCOV version 1.11