]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONRejectList.cxx
Merge branch 'master' of https://git.cern.ch/reps/AliRoot
[u/mrichter/AliRoot.git] / MUON / AliMUONRejectList.cxx
index ede8e89c9927cfa4ed9e28b6198914876e89806a..0d29e512b7a75b3eabf09e5b31beb88a216435ee 100644 (file)
@@ -21,7 +21,9 @@
 /// Object to hold the probability to reject elements during reconstruction.
 ///
 /// Those elements are either channels, manus, 
-/// bus patches, detection elements, or all the four.
+/// bus patches, detection elements, pcbs (for slats) and HV channels,
+/// or all of them.
+///
 /// (we do not consider the next level, chamber, because if a full
 /// chamber is missing, we assume we'll remove that run from the
 /// list of usable runs anyway).
 
 #include "AliMUONRejectList.h"
 
+#include "AliLog.h"
+#include "AliMpArea.h"
 #include "AliMpConstants.h"
+#include "AliMpDCSNamer.h"
+#include "AliMpDDLStore.h"
+#include "AliMpDEStore.h"
+#include "AliMpDetElement.h"
+#include "AliMpMotifPosition.h"
+#include "AliMpPCB.h"
+#include "AliMpSegmentation.h"
+#include "AliMpSlat.h"
+#include "AliMpVSegmentation.h"
 #include "AliMUON2DMap.h"
 #include "AliMUONCalibParamNF.h"
 #include "Riostream.h"
 #include "TMath.h"
 
+using std::cout;
+using std::endl;
 /// \cond CLASSIMP
 ClassImp(AliMUONRejectList)
 /// \endcond
@@ -144,16 +159,24 @@ namespace
   {
     /// Copy src into dest
     delete[] dest;
-    dest = new UInt_t[n];
-    memcpy(src,dest,n*sizeof(UInt_t));
+    dest = 0;
+    if ( src && n )
+    {
+      dest = new UInt_t[n];
+      memcpy(dest,src,n*sizeof(UInt_t));
+    }
   }
 
   void Copy(UInt_t n, Float_t* src, Float_t*& dest)
   {
     /// Copy src into dest
     delete[] dest;
-    dest = new Float_t[n];
-    memcpy(src,dest,n*sizeof(Float_t));
+    dest = 0;
+    if ( src && n )
+    {
+      dest = new Float_t[n];
+      memcpy(dest,src,n*sizeof(Float_t));
+    }
   }
   
 }
@@ -209,13 +232,13 @@ fChannels(0x0)
 //_____________________________________________________________________________
 AliMUONRejectList::AliMUONRejectList(const AliMUONRejectList& rl)
 : TObject(rl),
-fIsBinary(kTRUE),
-fMaxNofDEs(),
-fMaxNofBPs(),
-fMaxNofManus(),
-fNofDEs(), 
-fNofBPs(), 
-fNofManus(0), 
+fIsBinary(rl.fIsBinary),
+fMaxNofDEs(rl.fMaxNofDEs),
+fMaxNofBPs(rl.fMaxNofBPs),
+fMaxNofManus(rl.fMaxNofManus),
+fNofDEs(rl.fNofDEs), 
+fNofBPs(rl.fNofBPs), 
+fNofManus(rl.fNofManus), 
 fDEIds(0x0),
 fDEProbas(0x0),
 fBPIds(0x0),
@@ -225,7 +248,18 @@ fManuProbas(0x0),
 fChannels(0x0)
 {
   /// Copy ctor
-  rl.CopyTo(*this);
+  
+  ::Copy(rl.fMaxNofDEs,rl.fDEIds,fDEIds);
+  ::Copy(rl.fMaxNofDEs,rl.fDEProbas,fDEProbas);
+  ::Copy(rl.fMaxNofBPs,rl.fBPIds,fBPIds);
+  ::Copy(rl.fMaxNofBPs,rl.fBPProbas,fBPProbas);
+  ::Copy(rl.fMaxNofManus,rl.fManuIds,fManuIds);
+  ::Copy(rl.fMaxNofManus,rl.fManuProbas,fManuProbas);
+  
+  if ( rl.fChannels ) 
+  {
+    fChannels = static_cast<AliMUONVStore*>(rl.fChannels->Clone());
+  }
 }
 
 //_____________________________________________________________________________
@@ -234,31 +268,35 @@ AliMUONRejectList& AliMUONRejectList::operator=(const AliMUONRejectList& rl)
   /// assignement operator
   if ( this != &rl ) 
   {
-    rl.CopyTo(*this);
+    static_cast<TObject&>(*this)=rl;
+    
+    fIsBinary = rl.fIsBinary;
+    fMaxNofDEs = rl.fMaxNofDEs;
+    fMaxNofBPs = rl.fMaxNofBPs;
+    fMaxNofManus = rl.fMaxNofManus;
+    fNofDEs = rl.fNofDEs;
+    fNofBPs = rl.fNofBPs;
+    fNofManus = rl.fNofManus;
+    
+    ::Copy(rl.fMaxNofDEs,rl.fDEIds,fDEIds);
+    ::Copy(rl.fMaxNofDEs,rl.fDEProbas,fDEProbas);
+    ::Copy(rl.fMaxNofBPs,rl.fBPIds,fBPIds);
+    ::Copy(rl.fMaxNofBPs,rl.fBPProbas,fBPProbas);
+    ::Copy(rl.fMaxNofManus,rl.fManuIds,fManuIds);
+    ::Copy(rl.fMaxNofManus,rl.fManuProbas,fManuProbas);
+    
+    delete fChannels;
+    fChannels = 0x0;
+    
+    if ( rl.fChannels ) 
+    {
+      fChannels = static_cast<AliMUONVStore*>(rl.fChannels->Clone());
+    }
+    
   }  
   return *this;
 }
 
-//_____________________________________________________________________________
-void 
-AliMUONRejectList::CopyTo(AliMUONRejectList& rl) const
-{
-  /// Copy this to rl
-  TObject::Copy(rl);
-
-  rl.fIsBinary = fIsBinary;
-
-  ::Copy(rl.fMaxNofDEs,fDEIds,rl.fDEIds);
-  ::Copy(rl.fMaxNofDEs,fDEProbas,rl.fDEProbas);
-  ::Copy(rl.fMaxNofBPs,fBPIds,rl.fBPIds);
-  ::Copy(rl.fMaxNofBPs,fBPProbas,rl.fBPProbas);
-  ::Copy(rl.fMaxNofManus,fManuIds,rl.fManuIds);
-  ::Copy(rl.fMaxNofManus,fManuProbas,rl.fManuProbas);
-  
-  delete rl.fChannels;  
-  rl.fChannels = static_cast<AliMUONVStore*>(fChannels->Clone());
-}
-
 //_____________________________________________________________________________
 AliMUONRejectList::~AliMUONRejectList()
 {
@@ -359,6 +397,60 @@ void AliMUONRejectList::SetChannelProbability(Int_t detElemId, Int_t manuId, Int
   ZeroOrOne(proba);
 }
 
+//_____________________________________________________________________________
+void AliMUONRejectList::SetPCBProbability(Int_t detElemId, Int_t pcbNumber, Float_t proba)
+{
+  /// Set the probability to reject all the manus of a given (slat) PCB
+  AliMpSegmentation* seg = AliMpSegmentation::Instance();
+  AliMp::CathodType ct[] = { AliMp::kCath0, AliMp::kCath1 };
+  
+  for ( Int_t i = 0; i < 2; ++i )
+  {
+    const AliMpVSegmentation* vseg = seg->GetMpSegmentation(detElemId,ct[i]);
+    if (!vseg)
+    {
+      AliError(Form("Could not get segmentation of DE %d",detElemId));
+      continue;
+    }
+    const AliMpSlat* slat = seg->GetSlat(vseg);
+    if (!slat)
+    {
+      AliError(Form("Could not get slat from DE %d",detElemId));
+      continue;      
+    }
+    AliMpPCB* pcb = slat->GetPCB(pcbNumber);
+    for ( Int_t j = 0; j < pcb->GetSize(); ++j )
+    {
+      AliMpMotifPosition* mp = pcb->GetMotifPosition(j);
+      SetManuProbability(detElemId,mp->GetID(),proba);
+    }
+  }
+}
+
+//_____________________________________________________________________________
+void AliMUONRejectList::SetHVProbability(const char* dcsName, Float_t proba)
+{
+  /// Set the probability to reject all the manus of a given HV part
+  /// Caution : the dcs string is a dcs NAME, _not_ an alias
+  
+  AliMpDCSNamer hv("TRACKER");
+
+  TString alias = hv.DCSAliasFromName(dcsName);
+
+  Int_t detElemId = hv.DetElemIdFromDCSAlias(alias.Data());
+  Int_t index = hv.DCSIndexFromDCSAlias(alias.Data());
+
+  AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(detElemId);
+
+  const AliMpArrayI* manus = de->ManusForHV(index);
+
+  for ( Int_t i = 0; i < manus->GetSize(); ++ i )
+  {
+    Int_t manuId = manus->GetValue(i);
+    SetManuProbability(detElemId,manuId,proba);
+  }
+}
+
 //_____________________________________________________________________________
 void 
 AliMUONRejectList::Print(Option_t* opt) const