]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONTrackerConditionDataMaker.cxx
Fix coverity defect
[u/mrichter/AliRoot.git] / MUON / AliMUONTrackerConditionDataMaker.cxx
index b63731baa7871086c28fd94ca224d15c1d4fb925..4379f55757c42303bbf691d3435febff74f2288f 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,35 @@ 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);
+    }
+    // we do not delete the store, as it's supposedly part of the OCDB cache...
+  }
   
   AliCDBManager::Instance()->SetDefaultStorage(storage);
 }
@@ -85,7 +117,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 +152,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 +175,7 @@ fSource(Form("direct-%s",type))
 AliMUONTrackerConditionDataMaker::~AliMUONTrackerConditionDataMaker()
 {
   /// dtor
-  delete fData;
+  if ( fIsOwnerOfData ) delete fData;
 }
 
 
@@ -235,13 +270,13 @@ AliMUONTrackerConditionDataMaker::CreateHVStore(TMap& m)
     
     Int_t hvIndex = hvNamer.DCSIndexFromDCSAlias(name.Data());
 
-    if ( hvIndex >= 0 )
+    Int_t detElemId = hvNamer.DetElemIdFromDCSAlias(name.Data());
+    
+    if ( hvIndex >= 0 && detElemId < 0 )
     {
       // skip switches
       continue;      
     }
-
-    Int_t detElemId = hvNamer.DetElemIdFromDCSAlias(name.Data());
     
     if ( !AliMpDEManager::IsValidDetElemId(detElemId) )
     {
@@ -249,13 +284,14 @@ AliMUONTrackerConditionDataMaker::CreateHVStore(TMap& m)
                          detElemId,name.Data()));
       continue;
     }
-    
+
     Int_t nPCBs = hvNamer.NumberOfPCBs(detElemId);
-    Int_t nindex = nPCBs ? nPCBs : 1;
+    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);
       
@@ -279,14 +315,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());
       
@@ -407,8 +452,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 ) 
     {
@@ -437,6 +481,7 @@ AliMUONTrackerConditionDataMaker::CreateStore(Int_t runNumber,
     if ( ocdb ) 
     {
       store = AliMUONCalibrationData::CreateOccupancyMap(runNumber,&startOfValidity);
+      if (store) store = static_cast<AliMUONVStore*>(store->Clone());
     }
     else
     {