LCOV - code coverage report
Current view: top level - TOF/TOFbase - AliTOFPreprocessorFDR.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 143 0.7 %
Date: 2016-06-14 17:26:59 Functions: 1 9 11.1 %

          Line data    Source code
       1             : /**************************************************************************
       2             :  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
       3             :  *                                                                        *
       4             :  * Author: The ALICE Off-line Project.                                    *
       5             :  * Contributors are mentioned in the code where appropriate.              *
       6             :  *                                                                        *
       7             :  * Permission to use, copy, modify and distribute this software and its   *
       8             :  * documentation strictly for non-commercial purposes is hereby granted   *
       9             :  * without fee, provided that the above copyright notice appears in all   *
      10             :  * copies and that both the copyright notice and this permission notice   *
      11             :  * appear in the supporting documentation. The authors make no claims     *
      12             :  * about the suitability of this software for any purpose. It is          *
      13             :  * provided "as is" without express or implied warranty.                  *
      14             :  **************************************************************************/
      15             : 
      16             : /* 
      17             : $Log$
      18             : Revision 1.4  2007/12/05 13:55:18  zampolli
      19             : Initialization bug fixed.
      20             : 
      21             : Revision 1.3  2007/11/27 13:12:30  zampolli
      22             : CDB object run range upper limit extended to AliCDBRunRange::Infinity()
      23             : 
      24             : Revision 1.2  2007/11/27 07:24:41  zampolli
      25             : Log used, fData member removed
      26             : 
      27             : Revision 1.1  2007/11/24 18:36:27  zampolli
      28             : TOF Preprocessor for FDR
      29             : 
      30             : */
      31             : 
      32             : //#include <Riostream.h>
      33             : //#include <stdio.h>
      34             : //#include <stdlib.h>
      35             : 
      36             : //#include <TFile.h>
      37             : #include <TH1.h>
      38             : #include <TMath.h>
      39             : #include <TObjArray.h>
      40             : //#include <TObjString.h>
      41             : #include <TTimeStamp.h>
      42             : 
      43             : #include "AliCDBMetaData.h"
      44             : #include "AliLog.h"
      45             : 
      46             : //#include "AliTOFDataDCS.h"
      47             : //#include "AliTOFGeometry.h"
      48             : #include "AliTOFPreprocessorFDR.h"
      49             : #include "AliTOFFormatDCS.h"
      50             : #include "AliDCSValue.h"
      51             : 
      52             : // TOF preprocessor class.
      53             : // It takes data from DCS and passes them to the class AliTOFDataDCS, which
      54             : // processes them. The result is then written to the CDB.
      55             : // analogously, it takes data form DAQ (both at Run level and inclusive - 
      56             : // of all the runs - level, processes them, and stores both Reference Data
      57             : // and Online Calibration files in the CDB. 
      58             : 
      59             : 
      60          26 : ClassImp(AliTOFPreprocessorFDR)
      61             : 
      62             : //_____________________________________________________________________________
      63             : 
      64             : AliTOFPreprocessorFDR::AliTOFPreprocessorFDR(AliShuttleInterface* shuttle) :
      65           0 :   AliPreprocessor("TOF", shuttle),
      66           0 :   fStoreRefData(kTRUE)
      67           0 : {
      68             :   // constructor
      69           0 :   AddRunType("PHYSICS");
      70             : 
      71           0 : }
      72             : 
      73             : //_____________________________________________________________________________
      74             : 
      75             : AliTOFPreprocessorFDR::~AliTOFPreprocessorFDR()
      76           0 : {
      77             :   // destructor
      78           0 : }
      79             : 
      80             : //______________________________________________________________________________
      81             : void AliTOFPreprocessorFDR::Initialize(Int_t run, UInt_t startTime,
      82             :         UInt_t endTime)
      83             : {
      84             :   // Creates AliTOFDataDCS object
      85             : 
      86           0 :   AliPreprocessor::Initialize(run, startTime, endTime);
      87             : 
      88           0 :         Log(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run,
      89           0 :                 TTimeStamp(startTime).AsString(),
      90           0 :                 TTimeStamp(endTime).AsString()));
      91             : 
      92           0 : }
      93             : 
      94             : //_____________________________________________________________________________
      95             : 
      96             : UInt_t AliTOFPreprocessorFDR::ProcessDCSDataPoints(TMap* aliasMap)
      97             : {
      98             :   // Fills data into a AliTOFDataDCS object
      99             :   // return codes:
     100             :   // return=0 : all ok
     101             :   // return=1 : no DCS input data Map
     102             :   // return=2 : no DCS processed data was stored in Ref Data
     103             :   // return=3 : no DCS processed data was stored in OCDB
     104             : 
     105           0 :   if (!aliasMap){
     106           0 :     Log("No DCS map found: TOF exiting from Shuttle");
     107           0 :     return 1;// return error Code for DCS input data not found 
     108             :   }
     109             : 
     110             :   else {
     111             : 
     112             :     AliDCSValue* aValue;
     113             :     AliDCSValue* aValue1;
     114           0 :     Float_t timeMin = (Float_t)fStartTime;
     115           0 :     Float_t timeMax = (Float_t)fEndTime;
     116             :     Float_t val=0;
     117             :     Float_t val1=0;
     118             :     Float_t time=0; 
     119           0 :     Float_t delta[2];
     120           0 :     Float_t timedelta[2];
     121             : 
     122           0 :     TH1::AddDirectory(0);
     123             :     
     124             :     Bool_t resultDCSMap=kFALSE;
     125             :     Bool_t resultDCSStore=kFALSE;
     126             :     
     127           0 :     TString aliasDP[4]={"tof_lv_i48_02","tof_lv_v48_02","tof_lv_i33_02","tof_lv_v33_02"};
     128             :     
     129           0 :     TObjArray *array = new TObjArray(4);
     130           0 :     array->SetOwner();
     131             : 
     132           0 :     AliTOFFormatDCS *lvI4802 = new AliTOFFormatDCS();
     133           0 :     AliTOFFormatDCS *lvV4802 = new AliTOFFormatDCS();
     134           0 :     AliTOFFormatDCS *lvI3302 = new AliTOFFormatDCS();
     135           0 :     AliTOFFormatDCS *lvV3302 = new AliTOFFormatDCS();
     136             :     
     137           0 :     array->AddAt(lvI4802,0);
     138           0 :     array->AddAt(lvV4802,1);
     139           0 :     array->AddAt(lvI3302,2);
     140           0 :     array->AddAt(lvV3302,3);
     141             : 
     142             :     // processing DCS
     143             :     
     144           0 :     for (Int_t i=0;i<4;i++){
     145           0 :       for (Int_t idelta =0;idelta<2;idelta++){
     146           0 :         delta[idelta]=0;
     147           0 :         timedelta[idelta]=0;
     148             :       }
     149           0 :       TObjArray *aliasArr = (TObjArray*) aliasMap->GetValue(aliasDP[i].Data());
     150             :       
     151           0 :       if(!aliasArr){
     152           0 :         Log(Form("Alias %s not found!", aliasDP[i].Data()));
     153           0 :         return kFALSE;
     154             :       }
     155             :       
     156           0 :       if(aliasArr->GetEntries()<3){
     157           0 :         Log(Form("Alias %s has just %d entries!",
     158           0 :                       aliasDP[i].Data(),aliasArr->GetEntries()));
     159           0 :         continue;
     160             :       }
     161             :       
     162           0 :       TIter iterarray(aliasArr);
     163             :       
     164           0 :       Int_t nentries = aliasArr->GetEntries();
     165           0 :       Int_t deltaTimeStamp = (Int_t) nentries/3;
     166           0 :       Int_t deltaTimeStamp1 = (Int_t) nentries/2;
     167             :       
     168             :       // filling aliases with 10 floats+1 Usign
     169             :       Int_t index = 0;
     170           0 :       for (Int_t k=0;k<3;k++){
     171           0 :         index = deltaTimeStamp*k;
     172           0 :         if (k==0) {
     173             :           index=0;
     174           0 :         }
     175           0 :         else if (k==1) {
     176             :           index=deltaTimeStamp1;
     177           0 :         } 
     178           0 :         else if (k==2) {
     179           0 :           index=nentries-1; 
     180           0 :         }
     181           0 :         aValue = (AliDCSValue*) aliasArr->At(index);
     182           0 :         val = aValue->GetFloat();
     183           0 :         time = (Float_t) (aValue->GetTimeStamp());
     184           0 :         if (i==0){
     185           0 :           AliDebug(1,Form("tof_lv_i48_02: setting value %i to %f at %f",k,val,time));
     186           0 :           lvI4802->SetFloat(k,val);
     187           0 :           lvI4802->SetTimeStampFloat(k,time);
     188           0 :         }
     189           0 :         else if (i==1){
     190           0 :           AliDebug(1,Form("tof_lv_v48_02: setting value %i to %f at %f",k,val,time));
     191           0 :           lvV4802->SetFloat(k,val);
     192           0 :           lvV4802->SetTimeStampFloat(k,time);
     193           0 :         }
     194           0 :         else if (i==2){
     195           0 :           AliDebug(1,Form("tof_lv_i33_02: setting value %i to %f at %f",k,val,time));
     196           0 :           lvI3302->SetFloat(k,val);
     197           0 :           lvI3302->SetTimeStampFloat(k,time);
     198           0 :         }
     199           0 :         else if (i==3){
     200           0 :           AliDebug(1,Form("tof_lv_v33_02: setting value %i to %f at %f",k,val,time));
     201           0 :           lvV3302->SetFloat(k,val);
     202           0 :           lvV3302->SetTimeStampFloat(k,time);
     203           0 :         }
     204             :       }
     205             :   
     206             :       // computing the most significant variations
     207             :       
     208           0 :       Int_t deltamin = (Int_t)(60/(timeMax-timeMin)*nentries);
     209           0 :       Int_t klast = nentries-deltamin;
     210             :       
     211           0 :       for (Int_t k=0;k<klast;k++){
     212           0 :         aValue = (AliDCSValue*) aliasArr->At(k);
     213           0 :         aValue1 = (AliDCSValue*) aliasArr->At(k+deltamin);
     214           0 :         val = aValue->GetFloat();
     215           0 :         val1 = aValue1->GetFloat();
     216           0 :         if (delta[0]<=TMath::Abs(val1-val)) {
     217           0 :           delta[0]=TMath::Abs(val1-val);
     218           0 :           timedelta[0] = (Float_t)k;
     219           0 :         }
     220           0 :         if (delta[1]<=delta[0]) {
     221             :           Float_t temp = delta[1];
     222           0 :           Float_t timetemp = timedelta[1];
     223           0 :           delta[1]=delta[0];
     224           0 :           delta[0]=temp;
     225           0 :           timedelta[1]=timedelta[0];
     226           0 :           timedelta[0]=timetemp;
     227           0 :         }
     228             :       }
     229             :       
     230           0 :       for (Int_t kk=0;kk<2;kk++){
     231           0 :         if (i==0){
     232           0 :           AliDebug(1,Form("tof_lv_i48: setting variation %i to %f at %f",kk,delta[kk],timedelta[kk]));
     233           0 :           lvI4802->SetDelta(kk,delta[kk]);
     234           0 :           lvI4802->SetTimeStampDelta(kk,(Float_t)timedelta[kk]);
     235           0 :         }
     236           0 :         else if (i==1){
     237           0 :           AliDebug(1,Form("tof_lv_v48: setting variation %i to %f at %f",kk,delta[kk],timedelta[kk]));
     238           0 :           lvV4802->SetDelta(kk,delta[kk]);
     239           0 :           lvV4802->SetTimeStampDelta(kk,(Float_t)timedelta[kk]);
     240           0 :         }
     241           0 :         else if (i==2){
     242           0 :           AliDebug(1,Form("tof_lv_i33: setting variation %i to %f at %f",kk,delta[kk],timedelta[kk]));
     243           0 :           lvI3302->SetDelta(kk,delta[kk]);
     244           0 :           lvI3302->SetTimeStampDelta(kk,(Float_t)timedelta[kk]);
     245           0 :         }
     246           0 :         else if (i==3){
     247           0 :           AliDebug(1,Form("tof_lv_v33: setting variation %i to %f at %f",kk,delta[kk],timedelta[kk]));
     248           0 :           lvV3302->SetDelta(kk,delta[kk]);
     249           0 :           lvV3302->SetTimeStampDelta(kk,(Float_t)timedelta[kk]);
     250           0 :         }
     251             :       }
     252           0 :     }
     253             : 
     254           0 :     AliCDBMetaData metaDataDCS;
     255           0 :     metaDataDCS.SetBeamPeriod(0);
     256           0 :     metaDataDCS.SetResponsible("Chiara Zampolli");
     257           0 :     metaDataDCS.SetComment("This preprocessor fills an AliTOFDataDCS object.");
     258           0 :     Log("Storing DCS Data");
     259           0 :     resultDCSStore = StoreReferenceData("Calib","DCSData",array, &metaDataDCS);
     260           0 :     if (!resultDCSStore){
     261           0 :       Log("Some problems occurred while storing DCS data results in Reference Data, TOF exiting from Shuttle");
     262           0 :       return 2;// return error Code for processed DCS data not stored 
     263             :       // in reference data
     264             :     }
     265             :     
     266           0 :     Log("Storing DCS Data in OCDB");
     267           0 :     resultDCSMap = Store("Calib","DCSData",array, &metaDataDCS,0,kTRUE);
     268           0 :     if (!resultDCSMap){
     269           0 :       Log("Some problems occurred while storing DCS data results in OCDB, TOF exiting from Shuttle");
     270           0 :       return 3;// return error Code for processed DCS data not stored 
     271             :       // in reference data
     272             :     }
     273             :     
     274           0 :     delete array;
     275           0 :     return 0;
     276             : 
     277           0 :   }
     278             : 
     279           0 : }
     280             : //_____________________________________________________________________________
     281             : 
     282             : UInt_t AliTOFPreprocessorFDR::Process(TMap* dcsAliasMap)
     283             : {
     284             :   // Fills data into a AliTOFDataDCS object
     285             :   // return codes:
     286             :   // return=0  : all ok
     287             :   // return=1  : no DCS input data Map
     288             :   // return=2  : no DCS processed data was stored in Ref Data
     289             :   // return=3  : no DCS processed data was stored in OCDB
     290             : 
     291           0 :   TH1::AddDirectory(0);
     292             : 
     293             :   // processing 
     294             : 
     295           0 :   Int_t iresultDCS = ProcessDCSDataPoints(dcsAliasMap);
     296           0 :   if ((iresultDCS == 1) || (iresultDCS == 2) || (iresultDCS == 3)) return iresultDCS; 
     297             :   
     298           0 :   return 0;
     299           0 : }
     300             : 
     301             : 

Generated by: LCOV version 1.11