Flexible pt range for the efficiency histogramming
[u/mrichter/AliRoot.git] / MUON / AliMUONTrackerConditionDataMaker.cxx
index 3f4ba6c..64ccdb0 100644 (file)
@@ -40,6 +40,7 @@ ClassImp(AliMUONTrackerConditionDataMaker)
 #include "AliMUONDigitCalibrator.h"
 #include "AliMUONPadStatusMaker.h"
 #include "AliMUONPadStatusMapMaker.h"
+#include "AliMUONRejectList.h"
 #include "AliMUONTrackerData.h"
 #include "AliMUONTrackerIO.h"
 #include "AliMpArrayI.h"
@@ -54,12 +55,24 @@ ClassImp(AliMUONTrackerConditionDataMaker)
 #include "Riostream.h"
 #include "TString.h"
 #include <sstream>
+#include "TSystem.h"
+
+//_____________________________________________________________________________
+AliMUONTrackerConditionDataMaker::AliMUONTrackerConditionDataMaker():
+AliMUONVTrackerDataMaker(),
+fData(0x0),
+fSource(""),
+fIsOwnerOfData(kTRUE)
+{
+  /// default ctor to be able to stream
+}
 
 //_____________________________________________________________________________
 AliMUONTrackerConditionDataMaker::AliMUONTrackerConditionDataMaker(Int_t runNumber, const char* ocdbPath, const char* type):
 AliMUONVTrackerDataMaker(),
 fData(0x0),
-fSource(Form("%s-%010d-%s",ocdbPath,runNumber,type))
+fSource(Form("%s-%010d-%s",ocdbPath,runNumber,type)),
+fIsOwnerOfData(kTRUE)
 {
   /// ctor from OCDB
 
@@ -67,16 +80,44 @@ fSource(Form("%s-%010d-%s",ocdbPath,runNumber,type))
        
        AliCDBManager::Instance()->SetDefaultStorage(ocdbPath);
 
-  Int_t startOfValidity;
-  AliMUONVStore* store = CreateStore(runNumber,ocdbPath,type,startOfValidity);
-  AliInfo(Form("runNumber=%d ocdbPath=%s type=%s startOfValidity=%d store=%p",
-               runNumber,ocdbPath,type,startOfValidity,store));
-  if ( store )
+  TString stype(type);
+  stype.ToUpper();
+  
+  if ( stype == "REJECTLIST" ) 
   {
-    fData = CreateData(type,*store,startOfValidity);
-  }  
+    
+    Int_t startOfValidity(0);
+    
+    AliMUONRejectList* rl = AliMUONCalibrationData::CreateRejectList(runNumber,&startOfValidity);    
 
-  delete store;
+    if (rl)
+    {
+      fData = new AliMUONTrackerData(Form("RL%d",startOfValidity),"RejectList",*rl);
+    }
+    
+    delete rl;
+  }
+  else
+  {
+    Int_t startOfValidity;
+    AliMUONVStore* store = CreateStore(runNumber,ocdbPath,type,startOfValidity);
+    AliDebug(1,Form("runNumber=%d ocdbPath=%s type=%s startOfValidity=%d store=%p",
+                    runNumber,ocdbPath,type,startOfValidity,store));
+    if ( store )
+    {
+      fData = CreateData(type,*store,startOfValidity);
+    }
+    delete store;
+  }
+
+  if ( fData )
+  {
+    TString name(fData->GetName());
+    name += "(";
+    name += ocdbPath;
+    name += ")";
+    fData->SetName(name);
+  }
   
   AliCDBManager::Instance()->SetDefaultStorage(storage);
 }
@@ -85,7 +126,8 @@ fSource(Form("%s-%010d-%s",ocdbPath,runNumber,type))
 AliMUONTrackerConditionDataMaker::AliMUONTrackerConditionDataMaker(const char* filename, const char* type):
 AliMUONVTrackerDataMaker(),
 fData(0x0),
-fSource(Form("%s-%s",filename,type))
+fSource(Form("%s-%s",filename,type)),
+fIsOwnerOfData(kTRUE)
 {
   /// ctor from an ASCII file
   
@@ -119,7 +161,9 @@ fSource(Form("%s-%s",filename,type))
 AliMUONTrackerConditionDataMaker::AliMUONTrackerConditionDataMaker(const char* data, const char* type, Bool_t) :
 AliMUONVTrackerDataMaker(),
 fData(0x0),
-fSource(Form("direct-%s",type))
+fSource(Form("direct-%s",type)),
+fIsOwnerOfData(kTRUE)
+
 {
   /// ctor from a string containing the ASCII data
   /// the last parameter is there just to distinguish this ctor from the previous one
@@ -140,7 +184,7 @@ fSource(Form("direct-%s",type))
 AliMUONTrackerConditionDataMaker::~AliMUONTrackerConditionDataMaker()
 {
   /// dtor
-  delete fData;
+  if ( fIsOwnerOfData ) delete fData;
 }
 
 
@@ -250,24 +294,19 @@ AliMUONTrackerConditionDataMaker::CreateHVStore(TMap& m)
       continue;
     }
 
-    if ( hvIndex > 1 && AliMpDEManager::GetStationType(detElemId) == AliMp::kStation12 )
-    {
-      // skip all but first sector (as we'll loop on the 3 sectors below
-      continue;      
-    }
-    
     Int_t nPCBs = hvNamer.NumberOfPCBs(detElemId);
-    Int_t nindex = nPCBs ? nPCBs : 3;
+    Int_t indexMin = nPCBs ? 0 : hvIndex;
+    Int_t indexMax = nPCBs ? nPCBs : hvIndex+1;
     
     AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(detElemId);
     
-    for ( int i = 0 ; i < nindex; ++i )
+    for ( int i = indexMin ; i < indexMax; ++i )
     {
       Float_t switchValue(1.0);
       
       if ( nPCBs ) 
       {
-        TString switchName(hvNamer.DCSSwitchName(detElemId,i));
+        TString switchName(hvNamer.DCSSwitchAliasName(detElemId,i));
 
         TPair* p = static_cast<TPair*>(m.FindObject(switchName.Data()));
         TObjArray* a = static_cast<TObjArray*>(p->Value());
@@ -285,14 +324,23 @@ AliMUONTrackerConditionDataMaker::CreateHVStore(TMap& m)
       AliDCSValue* v;
       Float_t hvValue(0);
       Int_t n(0);
+      Int_t noff(0);
+      
       while ( ( v = static_cast<AliDCSValue*>(n2()) ) )
       {
         hvValue += v->GetFloat();
+        if ( v->GetFloat() < AliMpDCSNamer::TrackerHVOFF() ) ++noff;
         ++n;
       }
       hvValue *= switchValue;  
       
       if ( n ) hvValue /= n;
+
+      if (noff>0 && noff<n) 
+      {
+        // that's a trip
+        hvValue = -1.0;        
+      }
       
       Int_t nofChannels(AliMpConstants::ManuNofChannels());
       
@@ -413,8 +461,7 @@ AliMUONTrackerConditionDataMaker::CreateStore(Int_t runNumber,
     else
     {
       tmp = new AliMUON2DMap(kTRUE);
-      Bool_t changed(kFALSE);
-      AliMUONTrackerIO::DecodeConfig(source,*tmp,changed);
+      AliMUONTrackerIO::DecodeConfig(source,*tmp);
     }
     if ( tmp ) 
     {
@@ -443,6 +490,7 @@ AliMUONTrackerConditionDataMaker::CreateStore(Int_t runNumber,
     if ( ocdb ) 
     {
       store = AliMUONCalibrationData::CreateOccupancyMap(runNumber,&startOfValidity);
+      if (store) store = static_cast<AliMUONVStore*>(store->Clone());
     }
     else
     {