LCOV - code coverage report
Current view: top level - AD/ADbase - AliADPreprocessor.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 120 0.8 %
Date: 2016-06-14 17:26:59 Functions: 1 10 10.0 %

          Line data    Source code
       1             : #include "AliADPreprocessor.h"
       2             : #include "AliADCalibData.h"
       3             : #include "AliCDBMetaData.h"
       4             : #include "AliCDBEntry.h"
       5             : #include "AliDCSValue.h"
       6             : #include "AliLog.h"
       7             : #include "AliShuttleInterface.h"
       8             : #include "AliADDataDCS.h"
       9             : 
      10             : #include <TFile.h>
      11             : #include <TTimeStamp.h>
      12             : #include <TObjString.h>
      13             : #include <TSystem.h>
      14             : #include <TH1F.h>
      15             : 
      16             : 
      17             : class Tlist;
      18             : 
      19             : //
      20             : //  This class is  a simple preprocessor for AD detector.
      21             : //
      22             : //  It gets High Voltage values for a given run from DCS and Pedestal values from DAQ 
      23             : //  and writes them as Calibration MetaData into OCDB/AD/Calib/Data
      24             : //  It also retrieves FEE parameters from DCS archive   
      25             : //  and writes them as Trigger MetaData into OCDB/AD/Trigger/Data 
      26             : //  (to be used for trigger simulation)
      27             : //
      28             : 
      29          16 : ClassImp(AliADPreprocessor)
      30             : 
      31             : //______________________________________________________________________________________________
      32             : AliADPreprocessor::AliADPreprocessor(AliShuttleInterface* shuttle) :
      33           0 :         AliPreprocessor("AD0", shuttle),
      34           0 :         fDCSData(0)
      35             :  
      36           0 : {
      37             :   // constructor  
      38             :   
      39           0 :   AddRunType("STANDALONE_PULSER");
      40           0 :   AddRunType("STANDALONE_BC");
      41           0 :   AddRunType("PHYSICS");
      42           0 :   AddRunType("PEDESTAL");
      43             :     
      44           0 : }
      45             : 
      46             : //______________________________________________________________________________________________
      47             : AliADPreprocessor::~AliADPreprocessor()
      48           0 : {
      49             :   // destructor
      50           0 :         delete fDCSData;
      51             :         
      52           0 : }
      53             : 
      54             : //______________________________________________________________________________________________
      55             : void AliADPreprocessor::Initialize(Int_t run, UInt_t startTime,
      56             :         UInt_t endTime)
      57             : {
      58             :   // Creates AliADDataDCS object
      59             : 
      60           0 :    AliPreprocessor::Initialize(run, startTime, endTime);
      61             :   
      62           0 :    Log(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run,
      63           0 :                 TTimeStamp(startTime).AsString(),
      64           0 :                 TTimeStamp(endTime).AsString()));
      65             : 
      66           0 :    fRun       = run;
      67             :    // fStartTime = startTime;
      68             :    // fEndTime   = endTime;
      69           0 :    fStartTime = GetStartTimeDCSQuery ();
      70           0 :    fEndTime   = GetEndTimeDCSQuery ();
      71           0 :    time_t daqStart = (time_t) (((TString)GetRunParameter("DAQ_time_start")).Atoi());
      72           0 :    time_t daqEnd   = (time_t) (((TString)GetRunParameter("DAQ_time_end")).Atoi());
      73           0 :    time_t ctpStart = (time_t) (((TString)GetRunParameter("TRGTimeStart")).Atoi());
      74           0 :    time_t ctpEnd   = (time_t) (((TString)GetRunParameter("TRGTimeEnd")).Atoi());
      75             :    
      76           0 :         fDCSData      = new AliADDataDCS(fRun, fStartTime, fEndTime,(UInt_t)daqStart, (UInt_t)daqEnd,(UInt_t)ctpStart, (UInt_t)ctpEnd); 
      77             :    
      78           0 : }
      79             : 
      80             : //______________________________________________________________________________________________
      81             : UInt_t AliADPreprocessor::Process(TMap* dcsAliasMap)
      82             : {
      83             :   // Fills data retrieved from DCS and DAQ into a AliADCalibData object and 
      84             :   // stores it into CalibrationDB
      85             : 
      86             : 
      87             :   // *** GET RUN TYPE ***
      88           0 :   TString runType = GetRunType();
      89           0 :   TString beamMode = GetRunParameter("LHCBeamMode");
      90           0 :   Log(Form("Run type: %s, Beam mode: %s",runType.Data(), beamMode.Data()));
      91             : 
      92             : 
      93             :   // *** REFERENCE DATA *** 
      94             :   
      95           0 :   TString fileName; 
      96           0 :   AliADCalibData *calibData = new AliADCalibData();
      97             :   
      98             :   // *************** HV From DCS ******************
      99             :   // Fills data into a AliADDataDCS object
     100           0 :   if(!dcsAliasMap) return 1;
     101             : 
     102             :         // The Processing of the DCS input data is forwarded to AliADDataDCS
     103           0 :   if (!fDCSData->ProcessData(*dcsAliasMap)) return 1;
     104             : 
     105             :         // Writes AD PMs HV values into AD calibration object and Timing resolution parameters
     106           0 :         calibData->FillDCSData(fDCSData);
     107             :         
     108           0 :         if(runType == "PHYSICS") ProcessTrendings();
     109             :            
     110             :    // *************** From DAQ ******************
     111             :    
     112           0 :         TString sourcesId = "AD0da_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[32], pedSigma[32], adcMean[32], adcSigma[32] ;
     133           0 :                 for(Int_t j=0; j<32; 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->SetADCmean(adcMean);                      
     143           0 :                 calibData->SetADCsigma(adcSigma);
     144           0 :                 }                               
     145             : 
     146           0 :         delete source;      
     147             :   
     148             :   // Now we store the AD Calibration Object into CalibrationDB
     149             : 
     150             :   Bool_t resECal=kFALSE;
     151             :   
     152             :   Bool_t result = 0;
     153           0 :   if(sourceList && sourceList->GetEntries()>0)
     154             :   {
     155           0 :   AliCDBMetaData metaData;
     156           0 :   metaData.SetBeamPeriod(0);
     157           0 :   metaData.SetResponsible("Michal Broz");
     158           0 :   metaData.SetComment("This preprocessor fills an AliADCalibData object");
     159             : 
     160           0 :   resECal = Store("Calib", "Data", calibData, &metaData, 0, kTRUE);
     161             :   
     162           0 :   }
     163           0 :   if(resECal==kFALSE ) result = 1;
     164             :     
     165           0 :   if(runType == "PHYSICS" && beamMode != "NO BEAM") ProcessTimeSlewing();
     166             :   
     167           0 :   if(sourceList && sourceList->GetEntries()>0) calibData->PrintConfigShuttle();
     168             :   
     169           0 :   delete calibData;
     170           0 :   delete sourceList; 
     171             :         
     172           0 :   return result;
     173           0 : }
     174             : 
     175             : //______________________________________________________________________________________________
     176             : UInt_t AliADPreprocessor::ProcessTimeSlewing()
     177             : {
     178             : 
     179             :   // *************** From DAQ ******************
     180             :   TList *fListSplines = 0x0;
     181           0 :   TString fileName; 
     182           0 :   TString sourcesId = "AD0da_slewing";
     183             : 
     184           0 :   TList* sourceList = GetFileSources(kDAQ, sourcesId.Data());
     185           0 :   if (!sourceList)  {
     186           0 :           Log(Form("No sources found for id %s", sourcesId.Data()));                    
     187           0 :           return 1; }
     188           0 :   Log(Form("The following sources produced files with the id %s",sourcesId.Data()));
     189           0 :   sourceList->Print();    
     190             : 
     191           0 :   TIter iter(sourceList);
     192             :   TObjString *source;
     193             :           
     194           0 :   while((source=dynamic_cast<TObjString*> (iter.Next()))){
     195           0 :           fileName = GetFile(kDAQ, sourcesId.Data(), source->GetName());
     196           0 :           if (fileName.Length() > 0)
     197           0 :           Log(Form("Got the file %s, now we can extract some values.", fileName.Data()));
     198           0 :           TFile *f = TFile::Open(fileName);
     199           0 :           if(!f){
     200           0 :                 Log(Form("Cannot open file %s",fileName.Data()));
     201           0 :                 return 1;}
     202             :                 
     203           0 :           fListSplines = (TList*)f->Get("fListSplines");
     204           0 :           if ( !fListSplines ) {
     205           0 :                Log("No Spline List in file");
     206           0 :                return 1;}
     207           0 :           f->Close();
     208           0 :           }                               
     209             : 
     210             :   Bool_t result = 0;
     211             :   Bool_t resECal=kFALSE;
     212             :  
     213           0 :   if(sourceList && sourceList->GetEntries()>0)
     214             :   {
     215           0 :   AliCDBMetaData metaData;
     216           0 :   metaData.SetBeamPeriod(0);
     217           0 :   metaData.SetResponsible("Michal Broz");
     218           0 :   metaData.SetComment("This preprocessor fills an time slewing splines object");
     219             : 
     220           0 :   resECal = Store("Calib", "TimeSlewing", fListSplines, &metaData, 0, kTRUE);
     221           0 :   }
     222           0 :   if(resECal==kFALSE ) result = 1;
     223             :   
     224           0 :   delete sourceList;
     225             :    
     226           0 :   return result;
     227             : 
     228           0 : }
     229             : //______________________________________________________________________________________________
     230             : UInt_t AliADPreprocessor::ProcessTrendings()
     231             : {
     232             : 
     233             :   // *************** HV From DCS ******************
     234             :   TClonesArray *fGraphs = 0x0;
     235           0 :   fGraphs = fDCSData->GetGraphs();
     236             :   
     237             :   Bool_t result = 0;
     238             :   Bool_t resECal=kFALSE;
     239             :  
     240           0 :   if(fGraphs != 0x0){
     241           0 :   AliCDBMetaData metaData;
     242           0 :   metaData.SetBeamPeriod(0);
     243           0 :   metaData.SetResponsible("Michal Broz");
     244           0 :   metaData.SetComment("This preprocessor fills an object with PM V and I trends");
     245             : 
     246           0 :   resECal = Store("Calib", "PMTrends", fGraphs, &metaData, 0, kFALSE);
     247           0 :   }
     248           0 :   if(resECal==kFALSE ) result = 1;
     249             :      
     250           0 :   return result;
     251             : 
     252           0 : }

Generated by: LCOV version 1.11