]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Implementation of TOFFEE-DCS FXS file in TOF pp + small bug fixes... (R. Preghenella)
authorzampolli <zampolli@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 14 Mar 2008 15:44:02 +0000 (15:44 +0000)
committerzampolli <zampolli@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 14 Mar 2008 15:44:02 +0000 (15:44 +0000)
TOF/AliTOFPreprocessor.cxx
TOF/AliTOFPreprocessor.h
TOF/TOFPreprocessor.C
TOF/TOFbaseLinkDef.h
TOF/libTOFbase.pkg

index cd4c1dbc5d4541aaaa63ce3f8a18dbcc375d81d1..69c70f6c278d409436cbfd4b3997934ac1f9e283 100644 (file)
@@ -37,6 +37,7 @@
 #include "AliTOFDataDCS.h"
 #include "AliTOFGeometry.h"
 #include "AliTOFPreprocessor.h"
+#include "AliTOFFEEReader.h"
 
 //class TF1;
 //class AliDCSValue;
 // return=12: failed to store Reference Data for Noise
 // return=13: failed to retrieve Noise data 
 // return=14: failed to store Noise map in OCDB
+// return=15: failed to retrieve FEE data from FXS
+// return=16: failed to retrieve FEE data from OCDB
+// return=17: failed to store FEE data in OCDB
+// return=18: failed to store FEE reference data in OCDB
 
 ClassImp(AliTOFPreprocessor)
 
@@ -81,6 +86,7 @@ AliTOFPreprocessor::AliTOFPreprocessor(AliShuttleInterface* shuttle) :
   fh2(0),
   fCal(0),
   fCalStatus(0),
+  fFEEStatus(0),
   fNChannels(0),
   fStoreRefData(kTRUE),
   fFDRFlag(kTRUE)
@@ -111,6 +117,10 @@ AliTOFPreprocessor::~AliTOFPreprocessor()
     delete fCalStatus;
     fCalStatus = 0;
   }
+  if (fFEEStatus){
+    delete fFEEStatus;
+    fFEEStatus = 0;
+  }
 }
 
 //______________________________________________________________________________
@@ -141,6 +151,12 @@ void AliTOFPreprocessor::Initialize(Int_t run, UInt_t startTime,
          AliTOFChannelOnlineStatus * calChOnlineStatus = new AliTOFChannelOnlineStatus();
          fCalStatus->AddAt(calChOnlineStatus,ich);
        }
+       fFEEStatus = new TObjArray(fNChannels);
+       fFEEStatus->SetOwner();
+       for (Int_t ich = 0; ich<fNChannels; ich ++){
+         AliTOFChannelOnlineStatus * calChOnlineStatus = new AliTOFChannelOnlineStatus();
+         fFEEStatus->AddAt(calChOnlineStatus,ich);
+       }
 }
 //_____________________________________________________________________________
 Bool_t AliTOFPreprocessor::ProcessDCS(){
@@ -441,6 +457,13 @@ UInt_t AliTOFPreprocessor::ProcessPulserData()
          Int_t nread=0;
          Int_t nreadNotEmpty=0;
          for (Int_t ientry=1;ientry<=h1->GetNbinsX();ientry++){
+
+           /* check whether channel has been read out during current run.
+            * if the status is bad it means it has not been read out.
+            * in this case skip channel in order to not affect the mean */ 
+           if (((AliTOFChannelOnlineStatus *)fFEEStatus->At(ientry-1))->GetStatus() == AliTOFChannelOnlineStatus::kTOFHWBad)
+             continue;
+
            if (h1->GetBinContent(ientry)==-1) continue;
            else {
              if (h1->GetBinContent(ientry)>0) {
@@ -458,6 +481,14 @@ UInt_t AliTOFPreprocessor::ProcessPulserData()
            if (h1->GetBinContent(ich+1)==-1) continue;
            AliDebug(1,Form(" channel %i ",ich));
            AliDebug(1,Form(" channel status before pulser = %i",(Int_t)chSt->GetStatus()));
+
+           /* check whether channel has been read out during current run.
+            * if the status is bad it means it has not been read out.
+            * in this case skip channel in order to leave its status 
+            * unchanged */
+           if (((AliTOFChannelOnlineStatus *)fFEEStatus->At(ich))->GetStatus() == AliTOFChannelOnlineStatus::kTOFHWBad)
+             continue;
+           
            if (h1->GetBinContent(ich+1)<0.05*mean){
              chSt->SetStatus(chSt->GetStatus()|AliTOFChannelOnlineStatus::kTOFPulserBad);  // bad status for pulser
              AliDebug(1,Form(" channel status after pulser = %i",(Int_t)chSt->GetStatus()));
@@ -494,7 +525,7 @@ UInt_t AliTOFPreprocessor::ProcessPulserData()
   metaData.SetResponsible("Chiara Zampolli");
   metaData.SetComment("This preprocessor fills a TObjArray object for Pulser data.");
   AliInfo("Storing Calibration Data from Pulser Run");
-  resultPulser = Store("Calib","PulserData",fCalStatus, &metaData,0,kTRUE);
+  resultPulser = Store("Calib","Pulser",fCalStatus, &metaData,0,kTRUE);
   if(!resultPulser){
     Log("Some problems occurred while storing online object resulting from Pulser data processing");
     return 11;//return error code for problems in storing Pulser data 
@@ -509,7 +540,7 @@ UInt_t AliTOFPreprocessor::ProcessPulserData()
     sprintf(comment,"This preprocessor stores the result of the pulser run");
     metaDataHisto.SetComment(comment);
     AliInfo("Storing Reference Data");
-    resultPulserRef = StoreReferenceData("Calib","Pulser",htofPulser, &metaDataHisto);
+    resultPulserRef = StoreReferenceData("Calib","PulserData",htofPulser, &metaDataHisto);
     if (!resultPulserRef){
       Log("some problems occurred::No Reference Data for pulser stored, TOF exiting from Shuttle");
       return 9;//return error code for failure in storing Ref Data 
@@ -588,6 +619,14 @@ UInt_t AliTOFPreprocessor::ProcessNoiseData()
            if (h1->GetBinContent(ich+1)==-1) continue;
            AliDebug(1,Form( " channel %i",ich));
            AliDebug(1,Form( " channel status before noise = %i",(Int_t)chSt->GetStatus()));
+
+           /* check whether channel has been read out during current run.
+            * if the status is bad it means it has not been read out.
+            * in this case skip channel in order to leave its status 
+            * unchanged */
+           if (((AliTOFChannelOnlineStatus *)fFEEStatus->At(ich))->GetStatus() == AliTOFChannelOnlineStatus::kTOFHWBad)
+             continue;
+
            if (h1->GetBinContent(ich+1)>=1){  // setting limit for noise to 1 kHz
              chSt->SetStatus(chSt->GetStatus()|AliTOFChannelOnlineStatus::kTOFNoiseBad);  // bad status for noise
              AliDebug(1,Form( " channel status after noise = %i",(Int_t)chSt->GetStatus()));
@@ -626,7 +665,7 @@ UInt_t AliTOFPreprocessor::ProcessNoiseData()
   metaData.SetResponsible("Chiara Zampolli");
   metaData.SetComment("This preprocessor fills a TObjArray object for Noise data.");
   AliInfo("Storing Calibration Data from Noise Run");
-  resultNoise = Store("Calib","NoiseData",fCalStatus, &metaData,0,kTRUE);
+  resultNoise = Store("Calib","Noise",fCalStatus, &metaData,0,kTRUE);
   if(!resultNoise){
     Log("Some problems occurred while storing online object resulting from Noise data processing");
     return 14;//return error code for problems in storing Noise data 
@@ -641,7 +680,7 @@ UInt_t AliTOFPreprocessor::ProcessNoiseData()
     sprintf(comment,"This preprocessor stores the result of the noise run, TOF exiting from Shuttle ");
     metaDataHisto.SetComment(comment);
     AliInfo("Storing Reference Data");
-    resultNoiseRef = StoreReferenceData("Calib","Noise",htofNoise, &metaDataHisto);
+    resultNoiseRef = StoreReferenceData("Calib","NoiseData",htofNoise, &metaDataHisto);
     if (!resultNoiseRef){
       Log("some problems occurred::No Reference Data for noise stored");
       return 12;//return error code for failure in storing Ref Data 
@@ -652,12 +691,111 @@ UInt_t AliTOFPreprocessor::ProcessNoiseData()
 }
 //_____________________________________________________________________________
 
-UInt_t AliTOFPreprocessor::ProcessHWData()
+UInt_t AliTOFPreprocessor::ProcessFEEData()
 {
   // Processing Pulser Run data for TOF channel status
   // dummy for the time being
 
-  Log("Processing HW");
+  Log("Processing FEE");
+
+  Bool_t updateOCDB = kFALSE;
+  AliTOFFEEReader feeReader;
+  AliTOFChannelOnlineStatus *currentChannel = NULL, *storedChannel = NULL;
+  TObjArray *currentFEE = fFEEStatus;
+  
+  TH1C hCurrentFEE("hCurrentFEE","histo with current FEE channel status", fNChannels, 0, fNChannels);
+  
+  /* load current TOF FEE config from DCS FXS, parse, 
+   * fill current FEE histogram and set FEE status */
+  
+  const char * nameFile = GetFile(kDCS,"TofFeeMap",""); 
+  AliInfo(Form("nameFile = %s",nameFile));
+  if (nameFile == NULL) {
+         return 15;
+  } 
+  feeReader.LoadFEEConfig(nameFile);
+  feeReader.ParseFEEConfig();
+  /* loop over channels */
+  for (Int_t iChannel = 0; iChannel < fNChannels; iChannel++) {
+    currentChannel = (AliTOFChannelOnlineStatus *)currentFEE->At(iChannel);
+    if (!currentChannel)
+      continue;
+    /* channel enabled. set FEE channel status ok */
+    if (feeReader.IsChannelEnabled(iChannel)) {
+      currentChannel->SetStatus(AliTOFChannelOnlineStatus::kTOFHWOk);
+      hCurrentFEE.SetBinContent(iChannel + 1, 1);
+    }
+    /* channel disabled. set FEE channel status bad */
+    else {
+      currentChannel->SetStatus(AliTOFChannelOnlineStatus::kTOFHWBad);
+    }
+  }
+  
+  /* load stored TOF FEE from OCDB and compare it with current FEE.
+   * if stored FEE is different from current FEE set update flag.
+   * if there is no stored FEE in OCDB set update flag */
+  
+  AliCDBEntry *cdbEntry = GetFromOCDB("Calib","FEE");
+  /* no CDB entry found. set update flag */
+  if (cdbEntry == NULL) {
+    updateOCDB = kTRUE;
+  }
+  /* CDB entry OK. loop over channels */
+  else {
+    TObjArray *storedFEE = (TObjArray *)cdbEntry->GetObject();
+    for (Int_t iChannel = 0; iChannel < fNChannels; iChannel++){
+      currentChannel = (AliTOFChannelOnlineStatus *)currentFEE->At(iChannel);
+      storedChannel = (AliTOFChannelOnlineStatus *)storedFEE->At(iChannel);
+      /* compare current FEE channel status with stored one 
+       * if different set update flag and break loop */
+      if (currentChannel->GetStatus() != storedChannel->GetStatus()) {
+       updateOCDB = kTRUE;
+       break;
+      }
+    }
+  }
+
+  /* check whether we don't have to store reference data.
+   * in this case we return without errors. */
+  if (fStoreRefData) {
+         /* store reference data */
+         AliCDBMetaData metaDataHisto;
+         metaDataHisto.SetBeamPeriod(0);
+         metaDataHisto.SetResponsible("Roberto Preghenella");
+         metaDataHisto.SetComment("This preprocessor stores the FEE referece data of the current run.");
+         AliInfo("Storing FEE reference data");
+         /* store FEE reference data */
+         if (!StoreReferenceData("Calib", "FEEData", &hCurrentFEE, &metaDataHisto)) {
+                 /* failed */
+                 Log("problems while storing FEE reference data");
+                 return 18; /* error return code for problems while storing FEE reference data */
+         }
+  }
+
+  /* check whether we don't need to update OCDB.
+   * in this case we can return without errors and
+   * the current FEE is stored in the fFEEStatus TObjArray. */
+  if (!updateOCDB) {
+    AliInfo("TOF FEE config has not changed. Do not overwrite stored file.");
+    return 0; /* return ok */
+  }
+
+  /* update the OCDB with the current FEE since even 
+   * a little difference has been detected. */
+
+  AliCDBMetaData metaData;
+  metaData.SetBeamPeriod(0);
+  metaData.SetResponsible("Roberto Preghenella");
+  metaData.SetComment("This preprocessor fills a TObjArray object for FEE data.");
+  AliInfo("Storing FEE data from current run");
+  /* store FEE data */
+  if (!Store("Calib", "FEE", fFEEStatus, &metaData, 0, kTRUE)) {
+    /* failed */
+    Log("problems while storing FEE data object");
+    return 17; /* return error code for problems  while storing FEE data */
+  }
+
+  /* everything fine. return */
 
   return 0;
 
@@ -678,6 +816,11 @@ UInt_t AliTOFPreprocessor::Process(TMap* dcsAliasMap)
 
   // processing 
 
+  /* always process FEE data */
+  Int_t iresultFEE = ProcessFEEData();
+  if (iresultFEE != 0)
+    return iresultFEE;
+
   if (runType == "PULSER") {
     Int_t iresultPulser = ProcessPulserData();
     return iresultPulser; 
index 6a57fa2f1c713b0dc81555071c241ef8eb65d038..9052ee65bc7446ca68ffd1ab16644ed7ca4c0d2b 100644 (file)
@@ -38,7 +38,7 @@ class AliTOFPreprocessor : public AliPreprocessor
     UInt_t ProcessOnlineDelays();
     UInt_t ProcessPulserData();
     UInt_t ProcessNoiseData();
-    UInt_t ProcessHWData(); // dummy, for the time being
+    UInt_t ProcessFEEData(); // dummy, for the time being
 
     static const Int_t fgkBinRangeAve;    // number of bins where to 
                                           // calculate the mean
@@ -51,6 +51,7 @@ class AliTOFPreprocessor : public AliPreprocessor
                                           // for delays  
     TObjArray *fCal;                      // TOF Calibration object
     TObjArray *fCalStatus;                // TOF Calibration object from pulser/noise
+    TObjArray *fFEEStatus;                // TOF Calibration object from FEE
     Int_t fNChannels;                     // number of TOF channels
     Bool_t fStoreRefData;                 // Flag to decide storage of Ref Data
     Bool_t fFDRFlag;                      // Flag for FDR runs 
index 0974e2c74e46f9613e3e0fe84f2cf0beb4a377c8..ab6fe7541d6f5b3c5072aec669ebc7165c73b661 100644 (file)
@@ -13,7 +13,7 @@ $Id$
 extern TBenchmark *gBenchmark;
 void TOFPreprocessor(Char_t * RunType="PHYSICS")
 {
-  gSystem->Load("$ALICE/SHUTTLE/TestShuttle/libTestShuttle.so");
+  gSystem->Load("$ALICE_ROOT/SHUTTLE/TestShuttle/libTestShuttle.so");
 
   //AliLog::SetClassDebugLevel("AliTOFPreprocessor",1);
   // initialize location of CDB
@@ -34,6 +34,7 @@ void TOFPreprocessor(Char_t * RunType="PHYSICS")
   // processing files. for the time being, the files are local.
   shuttle->AddInputFile(AliTestShuttle::kDAQ, "TOF", "DELAYS", "MON", "$ALICE_ROOT/TOF/ShuttleInput/Total.root");
   shuttle->AddInputFile(AliTestShuttle::kDAQ, "TOF", "RUNLevel", "MON", "$ALICE_ROOT/TOF/ShuttleInput/Partial.root");
+  shuttle->AddInputFile(AliTestShuttle::kDCS, "TOF", "TofFeeMap", "", "$ALICE_ROOT/TOF/ShuttleInput/TOFFEE.20080310.164003.4001");
   char filename[100];
   char LDCname[5];
 
@@ -283,6 +284,7 @@ TMap* CreateDCSAliasMap()
     */
     // gauss generation of values 
     for (int timeStamp=0;timeStamp<1000;timeStamp+=10){
+    //for (int timeStamp=0;timeStamp<1;timeStamp++){
       Float_t gaussvalue = (Float_t) (random.Gaus(tent,sigma));
       if (TMath::Abs(gaussvalue-tent)>sigma){
        AliDCSValue* dcsVal = new AliDCSValue(gaussvalue, timeStamp);
index 99ead08d1f0fb84a74a62272bc346f8a9a800cdc..3b26845ce3178b4d7d93afeadde760def58c0f5a 100644 (file)
@@ -25,5 +25,7 @@
 #pragma link C++ class  AliTOFPreprocessorFDR+;
 #pragma link C++ class  AliTOFDataDCS+;
 #pragma link C++ class  AliTOFFormatDCS+;
+#pragma link C++ class  AliTOFFEEReader+;
+
 
 #endif
index d9b92dbe40385052dedbff241c5039135412513f..87cf542ecd2bd47832c160206ea6840158b18a00 100644 (file)
@@ -17,7 +17,8 @@ SRCS  = AliTOFGeometry.cxx  \
        AliTOFPreprocessor.cxx \
         AliTOFDataDCS.cxx \
         AliTOFFormatDCS.cxx \
-       AliTOFPreprocessorFDR.cxx
+       AliTOFPreprocessorFDR.cxx \
+       AliTOFFEEReader.cxx
 
 
 HDRS:= $(SRCS:.cxx=.h)