Initial version
authorivana <ivana@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 17 Mar 2006 16:58:01 +0000 (16:58 +0000)
committerivana <ivana@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 17 Mar 2006 16:58:01 +0000 (16:58 +0000)
(Laurent)

14 files changed:
MUON/AliMUON1DArray.cxx [new file with mode: 0644]
MUON/AliMUON1DArray.h [new file with mode: 0644]
MUON/AliMUONCheck.cxx [new file with mode: 0644]
MUON/AliMUONCheck.h [new file with mode: 0644]
MUON/AliMUONDataDigitIterator.cxx [new file with mode: 0644]
MUON/AliMUONDataDigitIterator.h [new file with mode: 0644]
MUON/AliMUONDataIterator.cxx [new file with mode: 0644]
MUON/AliMUONDataIterator.h [new file with mode: 0644]
MUON/AliMUONTriggerEfficiencyCells.cxx [new file with mode: 0755]
MUON/AliMUONTriggerEfficiencyCells.h [new file with mode: 0755]
MUON/AliMUONV1DStore.cxx [new file with mode: 0644]
MUON/AliMUONV1DStore.h [new file with mode: 0644]
MUON/AliMUONVDataIterator.cxx [new file with mode: 0644]
MUON/AliMUONVDataIterator.h [new file with mode: 0644]

diff --git a/MUON/AliMUON1DArray.cxx b/MUON/AliMUON1DArray.cxx
new file mode 100644 (file)
index 0000000..b852543
--- /dev/null
@@ -0,0 +1,130 @@
+/**************************************************************************
+* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+*                                                                        *
+* Author: The ALICE Off-line Project.                                    *
+* Contributors are mentioned in the code where appropriate.              *
+*                                                                        *
+* Permission to use, copy, modify and distribute this software and its   *
+* documentation strictly for non-commercial purposes is hereby granted   *
+* without fee, provided that the above copyright notice appears in all   *
+* copies and that both the copyright notice and this permission notice   *
+* appear in the supporting documentation. The authors make no claims     *
+* about the suitability of this software for any purpose. It is          *
+* provided "as is" without express or implied warranty.                  *
+**************************************************************************/
+
+// $Id$
+
+#include "AliMUON1DArray.h"
+
+#include "AliLog.h"
+#include "TObjArray.h"
+
+///
+/// This class is simply a wrapper to a TObjArray, offering in addition a
+/// control over the replacement policy when you add
+/// something to it.
+///
+
+ClassImp(AliMUON1DArray)
+
+//_____________________________________________________________________________
+AliMUON1DArray::AliMUON1DArray(Int_t theSize)
+: AliMUONV1DStore(),
+  fArray(0x0)
+{
+  // 
+  // Default ctor
+  //
+  if ( theSize ) 
+  {
+    fArray = new TObjArray(theSize);
+  }
+}
+
+//_____________________________________________________________________________
+AliMUON1DArray::AliMUON1DArray(const AliMUON1DArray& other)
+: AliMUONV1DStore(),
+  fArray(0x0)
+{
+  other.CopyTo(*this);
+}
+
+//_____________________________________________________________________________
+AliMUON1DArray&
+AliMUON1DArray::operator=(const AliMUON1DArray& other)
+{
+  other.CopyTo(*this);
+  return *this;
+}
+
+//_____________________________________________________________________________
+AliMUON1DArray::~AliMUON1DArray()
+{
+  //
+  // dtor, we're the owner of our internal array.
+  //
+  delete fArray;
+}
+
+//_____________________________________________________________________________
+void
+AliMUON1DArray::CopyTo(AliMUON1DArray& dest) const
+{
+  //
+  // Make a deep copy
+  //
+  delete dest.fArray;
+  dest.fArray = new TObjArray;
+  dest.fArray->SetOwner(kTRUE);
+  for ( Int_t i = 0; i < fArray->GetLast(); ++i )
+  {
+    dest.fArray->AddAt(fArray->At(i)->Clone(),i);
+  }
+}
+
+//_____________________________________________________________________________
+TObject* 
+AliMUON1DArray::Get(Int_t i) const
+{
+  //
+  // Get the object located at index i, if it exists, and if i is correct.
+  //
+  if ( i >= 0 && i < fArray->GetSize() )
+  {
+    return fArray->At(i);
+  }
+  AliError(Form("Index %d out of bounds (max %d)",i,fArray->GetSize()));
+  return 0x0;
+}
+
+//_____________________________________________________________________________
+Bool_t 
+AliMUON1DArray::Set(Int_t i, TObject* object, Bool_t replace)
+{
+  //
+  // Set the object located at i
+  // If replace=kFALSE and there's already an object at location i,
+  // this method fails and returns kFALSE, otherwise it returns kTRUE
+  //
+  if ( i >= 0 && i < fArray->GetSize() )
+  {
+    TObject* o = Get(i);
+    if ( o && !replace )
+    {
+      AliError(Form("Object %p is already there for i=%d",o,i));
+      return kFALSE;
+    }
+    if ( replace ) 
+    {
+      delete o;
+    }
+    fArray->AddAt(object,i);
+    return kTRUE;
+  }
+  AliError(Form("Index %d out of bounds (max %d)",i,fArray->GetSize()));
+  return kFALSE;
+}
+
+
+
diff --git a/MUON/AliMUON1DArray.h b/MUON/AliMUON1DArray.h
new file mode 100644 (file)
index 0000000..e68218b
--- /dev/null
@@ -0,0 +1,51 @@
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+* See cxx source for full Copyright notice                               */
+
+// $Id$
+
+/// \ingroup base
+/// \class AliMUON1DStore
+/// \brief Implementation of AliMUONV1DStore
+/// 
+/// \author Laurent Aphecetche
+
+#ifndef ALIMUON1DARRAY_H
+#define ALIMUON1DARRAY_H
+
+#ifndef ALIMUONV1DSTORE_H
+#  include "AliMUONV1DStore.h"
+#endif
+
+class TObjArray;
+
+class AliMUON1DArray : public AliMUONV1DStore
+{
+public:
+  AliMUON1DArray(Int_t theSize=0);
+  AliMUON1DArray(const AliMUON1DArray& other);
+  AliMUON1DArray& operator=(const AliMUON1DArray& other);
+  
+  virtual ~AliMUON1DArray();
+  
+  /// Return the object stored at i.
+  virtual TObject* Get(Int_t i) const;
+  
+  /** Set the object stored at i.
+    if replace=false and there's already an object there, returns kFALSE
+    */
+  virtual Bool_t Set(Int_t i, TObject* object, Bool_t replace);
+  
+  /// Whether or not this container is the owner of its contents.
+  virtual Bool_t IsOwner() const { return kTRUE; }
+  
+private:
+   void CopyTo(AliMUON1DArray& to) const;
+  
+private:  
+    
+    TObjArray* fArray; // Internal array
+  
+    ClassDef(AliMUON1DArray,1) // Implementation of AliMUONV1DStore
+};
+
+#endif
diff --git a/MUON/AliMUONCheck.cxx b/MUON/AliMUONCheck.cxx
new file mode 100644 (file)
index 0000000..7e106fa
--- /dev/null
@@ -0,0 +1,113 @@
+/**************************************************************************
+* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+*                                                                        *
+* Author: The ALICE Off-line Project.                                    *
+* Contributors are mentioned in the code where appropriate.              *
+*                                                                        *
+* Permission to use, copy, modify and distribute this software and its   *
+* documentation strictly for non-commercial purposes is hereby granted   *
+* without fee, provided that the above copyright notice appears in all   *
+* copies and that both the copyright notice and this permission notice   *
+* appear in the supporting documentation. The authors make no claims     *
+* about the suitability of this software for any purpose. It is          *
+* provided "as is" without express or implied warranty.                  *
+**************************************************************************/
+
+// $Id$
+
+#include "AliMUONCheck.h"
+
+#include "AliLoader.h"
+#include "AliLog.h"
+#include "AliRunLoader.h"
+#include "AliMUONData.h"
+#include "AliMUONDataIterator.h"
+#include "AliMUONDigit.h"
+
+/// A helper class to dump data from AliRoot-generated root files.
+/// 
+/// Only implemented for digits so far, it is meant as a replacement
+/// of the MUONCheck.C macro, or to be used by this macro to simplify it.
+///
+
+ClassImp(AliMUONCheck)
+
+//_____________________________________________________________________________
+AliMUONCheck::AliMUONCheck(const char* galiceFile, 
+                           Int_t firstEvent, Int_t lastEvent) 
+: TObject(),
+fFileName(galiceFile),
+fFirstEvent(firstEvent),
+fLastEvent(lastEvent),
+fRunLoader(0x0),
+fData(0x0)
+{
+  // ctor
+  
+  fRunLoader = AliRunLoader::Open(fFileName.Data(),"MUONFolder","READ");
+  if (!fRunLoader) 
+  {
+    AliError(Form("Error opening %s file \n",fFileName.Data()));
+  }  
+  else
+  {
+    AliLoader* loader = fRunLoader->GetLoader("MUONLoader");
+    if ( loader )
+    {
+      fData = new AliMUONData(loader,"MUON","MUON");
+    }
+    else
+    {
+      AliError(Form("Could get MUONLoader"));
+    }
+  }
+}
+
+//_____________________________________________________________________________
+AliMUONCheck::AliMUONCheck(const AliMUONCheck& rhs) : TObject(rhs)
+{
+  // copy ctor
+  AliFatal("Implement me if needed");
+}
+
+//_____________________________________________________________________________
+AliMUONCheck& 
+AliMUONCheck::operator=(const AliMUONCheck&)
+{
+  // assignement operator
+  AliFatal("Implement me if needed")
+  return *this;
+}
+
+//_____________________________________________________________________________
+AliMUONCheck::~AliMUONCheck()
+{
+  // dtor
+  delete fData;
+}
+
+//_____________________________________________________________________________
+void
+AliMUONCheck::DumpDigits(Option_t* opt) const
+{
+  // Dump the digits to screen
+  if ( !IsValid() ) return;
+  
+  Int_t nevents = fRunLoader->GetNumberOfEvents();
+  Int_t endOfLoop = fLastEvent+1;
+  
+  if ( fLastEvent == -1 ) endOfLoop = nevents;
+  
+  for ( Int_t ievent = fFirstEvent; ievent < endOfLoop; ++ievent ) 
+  {
+    fRunLoader->GetEvent(ievent);
+
+    AliMUONDataIterator it(fData,"digit",AliMUONDataIterator::kTrackingChambers);
+    AliMUONDigit* digit;
+     while ( ( digit = (AliMUONDigit*)it.Next() ) )
+     {
+       digit->Print(opt);
+     }
+  } 
+}
diff --git a/MUON/AliMUONCheck.h b/MUON/AliMUONCheck.h
new file mode 100644 (file)
index 0000000..2137c7c
--- /dev/null
@@ -0,0 +1,52 @@
+#ifndef ALIMUONCHECK_H
+#define ALIMUONCHECK_H
+
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+* See cxx source for full Copyright notice                               */
+
+// $Id$
+
+/// \ingroup base
+/// \class AliMUONCheck
+/// \brief A helper class to dump data from AliRoot-generated root files.
+/// 
+/// Only implemented for digits so far, it is meant as a replacement
+/// of the MUONCheck.C macro, or to be used by this macro to simplify it.
+///
+/// \author Laurent Aphecetche
+
+#ifndef ROOT_TObject
+#  include "TObject.h"
+#endif
+#ifndef ROOT_TString
+#  include "TString.h"
+#endif
+
+class AliMUONData;
+class AliRunLoader;
+
+class AliMUONCheck : public TObject
+{
+public:
+  AliMUONCheck(const char* galiceFile, Int_t firstEvent=0, Int_t lastEvent=-1);
+  virtual ~AliMUONCheck();
+  
+  Bool_t IsValid() const { return (fData!=0); }
+  
+  void DumpDigits(Option_t* opt="") const;
+  
+private:
+  AliMUONCheck(const AliMUONCheck& rhs);
+  AliMUONCheck& operator=(const AliMUONCheck& rhs);
+  
+private:
+  TString fFileName; //! File (galice.root) to read from
+  Int_t fFirstEvent; //! First event to consider
+  Int_t fLastEvent; //! Last event to consider
+  AliRunLoader* fRunLoader; //! AliRunLoader pointer
+  AliMUONData* fData; //! AliMUONData pointer (to access containers)
+
+  ClassDef(AliMUONCheck,0) // Dumper of MUON related data
+};
+
+#endif
diff --git a/MUON/AliMUONDataDigitIterator.cxx b/MUON/AliMUONDataDigitIterator.cxx
new file mode 100644 (file)
index 0000000..7ccb943
--- /dev/null
@@ -0,0 +1,134 @@
+/**************************************************************************
+* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+*                                                                        *
+* Author: The ALICE Off-line Project.                                    *
+* Contributors are mentioned in the code where appropriate.              *
+*                                                                        *
+* Permission to use, copy, modify and distribute this software and its   *
+* documentation strictly for non-commercial purposes is hereby granted   *
+* without fee, provided that the above copyright notice appears in all   *
+* copies and that both the copyright notice and this permission notice   *
+* appear in the supporting documentation. The authors make no claims     *
+* about the suitability of this software for any purpose. It is          *
+* provided "as is" without express or implied warranty.                  *
+**************************************************************************/
+
+// $Id$
+
+#include "AliMUONDataDigitIterator.h"
+
+#include "AliMUONData.h"
+#include "AliMUONDigit.h"
+#include "TClonesArray.h"
+
+///
+/// An iterator to access digits (stored into AliMUONData).
+///
+/// Iteration can occur on tracking chambers only, trigger chambers only,
+/// or both.
+///
+
+//_____________________________________________________________________________
+AliMUONDataDigitIterator::AliMUONDataDigitIterator(const AliMUONData* data,
+                                                   Int_t firstChamber, 
+                                                   Int_t lastChamber)
+: 
+AliMUONVDataIterator(),
+fData(data),
+fFirstChamber(firstChamber),
+fLastChamber(lastChamber)
+{
+  // 
+  // Ctor
+  // 
+  Reset();
+}
+
+//_____________________________________________________________________________
+AliMUONDataDigitIterator::AliMUONDataDigitIterator(const AliMUONDataDigitIterator& rhs)
+: 
+AliMUONVDataIterator()
+{
+  rhs.CopyTo(*this);
+}
+
+//_____________________________________________________________________________
+AliMUONDataDigitIterator&
+AliMUONDataDigitIterator::operator=(const AliMUONDataDigitIterator& rhs)
+{
+  rhs.CopyTo(*this);
+  return *this;
+}
+
+//_____________________________________________________________________________
+void
+AliMUONDataDigitIterator::CopyTo(AliMUONDataDigitIterator& destination) const
+{
+  destination.fData=fData;
+  destination.fFirstChamber=fFirstChamber;
+  destination.fLastChamber=fLastChamber;
+  destination.fCurrentDigit=fCurrentDigit;
+  destination.fCurrentChamber=fCurrentChamber;
+  destination.fDigits=fDigits;
+}
+
+//_____________________________________________________________________________
+TObject*
+AliMUONDataDigitIterator::Next()
+{
+  // Return current element and self-position to the next one.
+  
+  TObject* rv(0x0);
+  
+  if ( fDigits ) 
+  {
+    // get the pointer to be returned
+    rv = fDigits->At(fCurrentDigit);
+    // prepare for the next position, if it exists
+    if ( fCurrentDigit < fDigits->GetLast() ) 
+    {
+      ++fCurrentDigit;
+    }
+    else
+    {
+      fCurrentDigit = 0;
+      ++fCurrentChamber;
+      if ( fCurrentChamber <= fLastChamber )
+      {
+        fDigits = fData->Digits(fCurrentChamber);
+      }
+      else
+      {
+        fDigits = 0x0;
+      }
+    }
+  }
+  
+  return rv;
+}
+
+//_____________________________________________________________________________
+Bool_t
+AliMUONDataDigitIterator::Remove()
+{
+  // Remove current element.
+  
+  if ( fDigits ) 
+  {
+    fDigits->RemoveAt(fCurrentDigit);
+    fDigits->Compress();
+    return kTRUE;
+  }
+  
+  return kFALSE;
+}
+
+//_____________________________________________________________________________
+void
+AliMUONDataDigitIterator::Reset()
+{
+  fData->GetDigits();
+  fCurrentDigit = 0;
+  fCurrentChamber = fFirstChamber;
+  fDigits = fData->Digits(fCurrentChamber);
+}
diff --git a/MUON/AliMUONDataDigitIterator.h b/MUON/AliMUONDataDigitIterator.h
new file mode 100644 (file)
index 0000000..e01c484
--- /dev/null
@@ -0,0 +1,50 @@
+#ifndef ALIMUONDATADIGITITERATOR_H
+#define ALIMUONDATADIGITITERATOR_H
+
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+* See cxx source for full Copyright notice                               */
+
+// $Id$
+
+/// \ingroup base
+/// \class AliMUONDataDigitIterator
+/// \brief Iterator on digits (handled by AliMUONData).
+/// 
+/// \author Laurent Aphecetche
+
+#ifndef ALIMUONVDATAITERATOR_H
+#  include "AliMUONVDataIterator.h"
+#endif
+
+class AliMUONData;
+class TClonesArray;
+
+class AliMUONDataDigitIterator : public AliMUONVDataIterator
+{
+public:
+  AliMUONDataDigitIterator(const AliMUONData* data, Int_t firstChamber, Int_t lastChamber);
+  AliMUONDataDigitIterator(const AliMUONDataDigitIterator& rhs);
+  AliMUONDataDigitIterator& operator=(const AliMUONDataDigitIterator& rhs);
+  virtual ~AliMUONDataDigitIterator() {}
+    
+  TObject* Next();
+  
+  void Reset(); 
+  
+  Bool_t Remove();
+  
+private:
+    void CopyTo(AliMUONDataDigitIterator& destination) const;
+  
+private:
+    const AliMUONData* fData; //! Pointer to data accessor
+  Int_t fFirstChamber; //! First chamber to iterate on
+  Int_t fLastChamber; //! Last chamber to iterate on      
+  TClonesArray* fDigits; //! Digits of the current chamber
+  Int_t fCurrentDigit; //! Current position within fDigits array
+  Int_t fCurrentChamber; //! Current chamber
+  
+  ClassDef(AliMUONDataDigitIterator,0)
+};      
+
+#endif
diff --git a/MUON/AliMUONDataIterator.cxx b/MUON/AliMUONDataIterator.cxx
new file mode 100644 (file)
index 0000000..fc28218
--- /dev/null
@@ -0,0 +1,120 @@
+/**************************************************************************
+* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+*                                                                        *
+* Author: The ALICE Off-line Project.                                    *
+* Contributors are mentioned in the code where appropriate.              *
+*                                                                        *
+* Permission to use, copy, modify and distribute this software and its   *
+* documentation strictly for non-commercial purposes is hereby granted   *
+* without fee, provided that the above copyright notice appears in all   *
+* copies and that both the copyright notice and this permission notice   *
+* appear in the supporting documentation. The authors make no claims     *
+* about the suitability of this software for any purpose. It is          *
+* provided "as is" without express or implied warranty.                  *
+**************************************************************************/
+
+// $Id$
+
+#include "AliMUONDataIterator.h"
+
+#include "AliMUONConstants.h"
+#include "AliMUONData.h"
+#include "AliMUONDataDigitIterator.h"
+#include "TString.h"
+
+//
+// A wrapper to various iterators used to loop over
+// objects handled by AliMUONData, like sdigits, digits, rawclusters, 
+// and so on.
+//
+// Currently only implemented for digits, as a proof-of-principle.
+//
+
+namespace
+{
+  void GetChamberNumbers(AliMUONDataIterator::EIterationStyle type, 
+                         Int_t& firstChamber, Int_t& lastChamber)
+{
+    switch ( type )
+    {
+      case AliMUONDataIterator::kAllChambers:
+        firstChamber=0;
+        lastChamber=AliMUONConstants::NCh()-1;
+        break;
+      case AliMUONDataIterator::kTrackingChambers:
+        firstChamber=0;
+        lastChamber=AliMUONConstants::NCh()-1;
+        break;
+      case AliMUONDataIterator::kTriggerChambers:
+        firstChamber=AliMUONConstants::NTrackingCh();
+        lastChamber=AliMUONConstants::NCh()-1;
+        break;
+      default:
+        firstChamber=lastChamber=-1;
+        break;
+    }
+}
+}
+
+ClassImp(AliMUONDataIterator)
+
+//_____________________________________________________________________________
+AliMUONDataIterator::AliMUONDataIterator() 
+: 
+TObject(),
+fIterator(0x0)
+{
+}
+
+//_____________________________________________________________________________
+AliMUONDataIterator::AliMUONDataIterator(AliMUONData* data,
+                                         const char* onWhatToIterate,
+                                         EIterationStyle howToIterate) 
+: 
+TObject(),
+fIterator(0x0)
+{
+  TString opt(onWhatToIterate);
+  opt.ToLower();
+  if ( opt.Contains("digit") || opt.Contains("d") )
+  {
+      Int_t firstChamber;
+      Int_t lastChamber;
+      GetChamberNumbers(howToIterate,firstChamber,lastChamber); 
+      if ( firstChamber >= 0 && lastChamber >= 0 )
+      {
+        data->GetLoader()->LoadDigits("READ");
+        data->SetTreeAddress("D,GLT");
+        fIterator = new AliMUONDataDigitIterator(data,firstChamber,lastChamber);
+      }
+  }
+}
+
+//_____________________________________________________________________________
+AliMUONDataIterator::~AliMUONDataIterator()
+{
+  delete fIterator;
+}
+
+//_____________________________________________________________________________
+TObject* 
+AliMUONDataIterator::Next() 
+{ 
+  if (!fIterator) return fIterator->Next(); 
+  return 0x0;
+}
+
+//_____________________________________________________________________________
+Bool_t 
+AliMUONDataIterator::Remove() 
+{ 
+  if (!fIterator) return fIterator->Remove(); 
+  return kFALSE;
+}
+
+//_____________________________________________________________________________
+void 
+AliMUONDataIterator::Reset() 
+{ 
+  if (!fIterator) fIterator->Reset(); 
+}
diff --git a/MUON/AliMUONDataIterator.h b/MUON/AliMUONDataIterator.h
new file mode 100644 (file)
index 0000000..d7f2e27
--- /dev/null
@@ -0,0 +1,46 @@
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+* See cxx source for full Copyright notice                               */
+
+// $Id$
+
+/// \ingroup
+/// \class AliMUONDataIterator
+/// \brief
+/// 
+/// \author Laurent Aphecetche
+
+#ifndef ALIMUONDATAITERATOR_H
+#define ALIMUONDATAITERATOR_H
+
+#ifndef ROOT_TObject
+#  include "TObject.h"
+#endif
+
+class AliMUONData;
+class AliMUONVDataIterator;
+
+class AliMUONDataIterator : public TObject
+{
+public:
+
+  enum EIterationStyle { kAllChambers, kTrackingChambers, kTriggerChambers };
+  
+  AliMUONDataIterator();
+  AliMUONDataIterator(AliMUONData* data, const char* onWhatToIterate,
+                      EIterationStyle howToIterate);
+  
+  virtual ~AliMUONDataIterator();
+    
+  TObject* Next();
+  
+  Bool_t Remove();
+  
+  void Reset();
+  
+private:
+  AliMUONVDataIterator* fIterator;   
+  
+  ClassDef(AliMUONDataIterator,0) // 
+};
+
+#endif
diff --git a/MUON/AliMUONTriggerEfficiencyCells.cxx b/MUON/AliMUONTriggerEfficiencyCells.cxx
new file mode 100755 (executable)
index 0000000..12f2996
--- /dev/null
@@ -0,0 +1,271 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+
+#include <fstream>
+#include <TRandom.h>
+#include "Riostream.h"
+
+#include "AliMUONTriggerEfficiencyCells.h"
+#include "AliMUONConstants.h"
+#include "AliRun.h"
+#include "AliMpPad.h"
+#include "AliMUON.h"
+#include "AliMpVSegmentation.h"
+#include "AliMpTriggerSegmentation.h"
+#include "AliMpTrigger.h"
+#include "AliLog.h"
+
+//
+// A class to store and give access to the trigger chamber efficiency.
+//
+// Efficiency is stored per cathode, on "cells" of a given size.
+//
+// The main method of this class is IsTriggered().
+//
+// $ALICE_ROOT/MUON/data/TriggerChamberefficiencyCells.dat contains efficiency 
+// for each chamber (i.e. DetElement). 
+// The efficiency cells goes from right to left and 
+// from bottom to top of the chamber, namely, the efficiencies tabulated in the 
+// file refers to the following reference frame:
+//
+//x
+//<----------------------------------|
+//                                   |
+//   ---------------------------     |
+//  | 0.97 | 0.97 | 0.97 | 0.97 |    |
+//   ---------------------------     |
+//  | 0.97 | 0.97 | 0.97 | 0.97 |    |
+//   ---------------------------     |
+//  | 0.97 | 0.97 | 0.97 | 0.97 |    |
+//   ---------------------------     |
+//                                   |
+//                                  \/ y
+//
+//  The file can be edited in order to change efficiency in a chosen region
+//  of the chamber.
+//
+// But please note that this object is also available from the CDB 
+// (generated using the MUONCDB.C macro)
+//
+
+ClassImp(AliMUONTriggerEfficiencyCells)
+
+//__________________________________________________________________________
+AliMUONTriggerEfficiencyCells::AliMUONTriggerEfficiencyCells()
+:
+TObject()
+{
+  // Default ctor.
+  Reset();
+}
+
+//__________________________________________________________________________
+AliMUONTriggerEfficiencyCells::AliMUONTriggerEfficiencyCells(const char* filename)
+:
+TObject()
+{
+  // Ctor using an ASCII file.
+  Reset();
+  ReadFile(filename);
+}
+
+
+//__________________________________________________________________________
+AliMUONTriggerEfficiencyCells::~AliMUONTriggerEfficiencyCells()
+{
+  // dtor. Does nothing ;-)
+}
+    
+//__________________________________________________________________________
+Float_t AliMUONTriggerEfficiencyCells::GetCellEfficiency(Int_t detElemId, Int_t cathode, Float_t x, Float_t y)
+{
+  // Get the efficiency at a given position (x,y) for a given cathode
+  
+  Int_t chamber = FindChamberIndex(detElemId);
+  Int_t slat = FindSlatIndex(detElemId);
+  TArrayI cell = CellByCoord(detElemId,x,y);
+  Float_t efficiency = 0.0;
+  if (cell.At(0)>=0 && cell.At(1)>=0)
+  {
+    efficiency = fCellContent[chamber][slat][cathode][cell.At(0)][cell.At(1)];
+  }
+  return efficiency;
+}
+
+
+//__________________________________________________________________________
+void AliMUONTriggerEfficiencyCells::GetCellEfficiency(Int_t detElemId, Float_t x, Float_t y, Float_t &eff1, Float_t &eff2)
+{
+  // Get the efficiencies of the 2 cathode at a given location (x,y)
+  Int_t chamber = FindChamberIndex(detElemId);
+  Int_t slat = FindSlatIndex(detElemId);
+  TArrayI cell = CellByCoord(detElemId,x,y);
+  eff1 = 0.0;
+  eff2 = 0.0;
+  if(cell.At(0)>=0 && cell.At(1)>=0)
+  {
+    eff1 = fCellContent[chamber][slat][0][cell.At(0)][cell.At(1)];
+    eff2 = fCellContent[chamber][slat][1][cell.At(0)][cell.At(1)];
+  }
+}
+
+
+//__________________________________________________________________________
+Bool_t 
+AliMUONTriggerEfficiencyCells::IsTriggered(Int_t detElemId, Int_t cathode, Float_t x, Float_t y)
+{
+  // Random decision of whether a given "location" (x,y) trigs or not.
+  Float_t efficiency = GetCellEfficiency(detElemId, cathode, x, y);
+  Bool_t trigger = kTRUE;
+  if(gRandom->Rndm()>efficiency)
+  {
+    trigger = kFALSE;
+  }
+  return trigger;
+}
+
+
+//__________________________________________________________________________
+void 
+AliMUONTriggerEfficiencyCells::IsTriggered(Int_t detElemId, Float_t x, Float_t y, Bool_t &trig1, Bool_t &trig2)
+{
+  // Whether or not a given location (x,y) has a chance to trig, on each cathode.
+  Float_t eff1 = 0.0;
+  Float_t eff2 = 0.0;
+  GetCellEfficiency(detElemId, x, y, eff1, eff2);
+  trig1 = kTRUE; 
+  trig2 = kTRUE;
+  if(gRandom->Rndm()>eff1)trig1 = kFALSE;
+  if(gRandom->Rndm()>eff2)trig2 = kFALSE;
+}
+
+
+//__________________________________________________________________________
+TArrayI AliMUONTriggerEfficiencyCells::CellByCoord(Int_t detElemId, Float_t x, Float_t y)
+{
+  // Get the efficiencies at a given location.
+  Int_t chamber = FindChamberIndex(detElemId);
+  Int_t slat = FindSlatIndex(detElemId);
+  Int_t cell[2]={-1,-1};
+  Float_t maxX = fCellSize[chamber][slat][0]*((Float_t)fCellNumber[chamber][slat][0]);
+  Float_t maxY = fCellSize[chamber][slat][1]*((Float_t)fCellNumber[chamber][slat][1]);
+  if(x>=0 & x<maxX & y>=0 & y<maxY)
+  {
+    cell[0] = (Int_t)(x/fCellSize[chamber][slat][0]);
+    cell[1] = (Int_t)(y/fCellSize[chamber][slat][1]);
+  }
+  return TArrayI(2,cell);
+}
+
+//__________________________________________________________________________
+void AliMUONTriggerEfficiencyCells::ReadFile(const char* filename)
+{
+  // Reads a file containing the efficiency map.
+  TString fileName = gSystem->ExpandPathName(filename);
+  ifstream file(fileName.Data());
+  Int_t datInt=0, detEl=0, chamber=0, rpc=0;
+  Float_t datFloat=0.0;
+  char dat[50];
+  if (file.good()){
+    while (file >> dat) {
+           file >> detEl;
+           chamber = FindChamberIndex(detEl);
+           rpc = FindSlatIndex(detEl);
+           file >> dat;
+           for(Int_t i=0; i<2; i++){
+        file >> datInt;
+        fCellNumber[chamber][rpc][i] = datInt;
+        file >> dat;
+           }
+           for(Int_t i=0; i<2; i++){
+        file >> datFloat;
+        fCellSize[chamber][rpc][i] = datFloat;
+        if(i==0)file >> dat;
+           }
+           for(Int_t cath=0; cath<2; cath++){
+        file >> dat;
+        file >> datInt;
+        for(Int_t iy=0; iy<fCellNumber[chamber][rpc][1]; iy++){
+          for(Int_t ix=0; ix<fCellNumber[chamber][rpc][0]; ix++){
+            file >> datFloat;
+            fCellContent[chamber][rpc][cath][ix][iy] = datFloat;
+          }
+        }
+           }
+    }
+    file.close();
+  } else {
+    AliWarning(Form("Can't read file %s",fileName.Data()));
+  }
+}
+
+
+//__________________________________________________________________________
+Int_t AliMUONTriggerEfficiencyCells::FindChamberIndex(Int_t detElemId)
+{
+  // From detElemId to chamber number
+  Int_t offset = 100*(AliMUONConstants::NTrackingCh()+1);
+  Int_t chamber = (detElemId-offset)/100;
+  return chamber;
+}
+
+
+//__________________________________________________________________________
+Int_t AliMUONTriggerEfficiencyCells::FindSlatIndex(Int_t detElemId)
+{
+  // From detElemId to slat index.
+  Int_t offset = 100*(AliMUONConstants::NTrackingCh()+1);
+  Int_t chamber = FindChamberIndex(detElemId);
+  Int_t slat = detElemId-offset-(chamber*100);
+  return slat;
+}
+
+
+//__________________________________________________________________________
+TVector2 AliMUONTriggerEfficiencyCells::ChangeReferenceFrame(Float_t x, Float_t y, Float_t x0, Float_t y0)
+{
+    //(x0,y0) position of the local reference frame (center of the chamber)
+    Float_t x1 = x0-x;//reflection of axis
+    Float_t y1 = y+y0;
+    return TVector2(x1,y1);
+}
+
+//__________________________________________________________________________
+void
+AliMUONTriggerEfficiencyCells::Reset()
+{
+  //
+  // Sets our internal array contents to zero.
+  //
+  for(Int_t chamber=0; chamber<4; chamber++)
+  {
+    for(Int_t slat=0; slat<18; slat++)
+    {
+           for(Int_t cath=0; cath<2; cath++)
+      {
+        fCellSize[chamber][slat][cath]=0.0;
+        fCellNumber[chamber][slat][cath]=0;
+        for(Int_t ix=0; ix<fgkNofCells; ix++)
+        {
+          for(Int_t iy=0; iy<fgkNofCells; iy++)
+          {
+            fCellContent[chamber][slat][cath][ix][iy]=0.0;
+          }
+        }
+           }
+    }
+  }
+}
+
diff --git a/MUON/AliMUONTriggerEfficiencyCells.h b/MUON/AliMUONTriggerEfficiencyCells.h
new file mode 100755 (executable)
index 0000000..e3c0045
--- /dev/null
@@ -0,0 +1,52 @@
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+/// \ingroup sim
+/// \class AliMUONTriggerEfficiencyCells
+/// \brief Store and give access to the trigger chamber efficiency.
+///
+/// \author: Diego Stocco; INFN Torino
+
+#ifndef ALIMUONTRIGGEREFFICIENCYCELLS_H
+#define ALIMUONTRIGGEREFFICIENCYCELLS_H
+
+#include "TObject.h"
+#include "TArrayI.h"
+#include "TVector2.h"
+#include "TString.h"
+
+class AliMUONTriggerEfficiencyCells : public TObject
+{
+public:
+  AliMUONTriggerEfficiencyCells();
+  AliMUONTriggerEfficiencyCells(const char* filename);
+
+  virtual ~AliMUONTriggerEfficiencyCells();
+
+  Float_t GetCellEfficiency(Int_t detElemId, Int_t cathode, Float_t x, Float_t y);
+  void GetCellEfficiency(Int_t detElemId, Float_t x, Float_t y, Float_t &eff1, Float_t &eff2);
+    
+  Bool_t IsTriggered(Int_t detElemId, Int_t cathode, Float_t x, Float_t y);
+  void IsTriggered(Int_t detElemId, Float_t x, Float_t y, Bool_t &trig1, Bool_t &trig2);
+
+  TVector2 ChangeReferenceFrame(Float_t x, Float_t y, Float_t x0, Float_t y0);
+
+  void Reset();
+    
+protected:
+    TArrayI CellByCoord(Int_t detElemId, Float_t x, Float_t y);
+    void ReadFile(const char* filename="$ALICE_ROOT/MUON/data/efficiencyCells.dat");
+
+private:
+    Int_t FindChamberIndex(Int_t detElemId);
+    Int_t FindSlatIndex(Int_t detElemId);
+    
+    static const Int_t fgkNofCells=80; // number of cells
+    
+    Float_t fCellContent[4][18][2][fgkNofCells][fgkNofCells]; //[trig. chambers][RPCs][cathode][cellsX][cellsY]
+    Float_t fCellSize[4][18][2]; //the size of the cells
+    Int_t fCellNumber[4][18][2]; //id of the cells
+    
+    ClassDef(AliMUONTriggerEfficiencyCells,1) // Trigger efficiency store
+};
+#endif
diff --git a/MUON/AliMUONV1DStore.cxx b/MUON/AliMUONV1DStore.cxx
new file mode 100644 (file)
index 0000000..3b9f042
--- /dev/null
@@ -0,0 +1,42 @@
+/**************************************************************************
+* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+*                                                                        *
+* Author: The ALICE Off-line Project.                                    *
+* Contributors are mentioned in the code where appropriate.              *
+*                                                                        *
+* Permission to use, copy, modify and distribute this software and its   *
+* documentation strictly for non-commercial purposes is hereby granted   *
+* without fee, provided that the above copyright notice appears in all   *
+* copies and that both the copyright notice and this permission notice   *
+* appear in the supporting documentation. The authors make no claims     *
+* about the suitability of this software for any purpose. It is          *
+* provided "as is" without express or implied warranty.                  *
+**************************************************************************/
+
+// $Id$
+
+#include "AliMUONV1DStore.h"
+
+///
+/// Defines an interface equivalent to a list of TObject, indexed
+/// by integer (somehow a vector, except that indices are not necessarily
+/// sequential).
+/// 
+/// It's extremely simple and hopefully allow many implementations.
+/// It also makes the object ownership self-evident.
+///
+
+ClassImp(AliMUONV1DStore)
+
+//_____________________________________________________________________________
+AliMUONV1DStore::AliMUONV1DStore()
+{
+}
+
+//_____________________________________________________________________________
+AliMUONV1DStore::~AliMUONV1DStore()
+{
+}
+
+
+
diff --git a/MUON/AliMUONV1DStore.h b/MUON/AliMUONV1DStore.h
new file mode 100644 (file)
index 0000000..57cc6d8
--- /dev/null
@@ -0,0 +1,40 @@
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+* See cxx source for full Copyright notice                               */
+
+// $Id$
+
+/// \ingroup base
+/// \class AliMUON1DStore
+/// \brief Generic container indexed by a single integer.
+/// 
+/// \author Laurent Aphecetche
+
+#ifndef AliMUONV1DSTORE_H
+#define AliMUONV1DSTORE_H
+
+#ifndef ROOT_TObject
+#  include "TObject.h"
+#endif
+
+class AliMUONV1DStore : public TObject
+{
+public:
+  AliMUONV1DStore();
+  virtual ~AliMUONV1DStore();
+  
+  /// Return the object stored at i.
+  virtual TObject* Get(Int_t i) const = 0;
+  
+  /** Set the object stored at i.
+    if replace=false and there's already an object there, returns kFALSE
+    */
+  virtual Bool_t Set(Int_t i, TObject*, Bool_t replace) = 0;
+  
+  /// Whether or not this container is the owner of its contents.
+  virtual Bool_t IsOwner() const = 0;
+  
+private:  
+  ClassDef(AliMUONV1DStore,0) // Generic container indexed by a single integer
+};
+
+#endif
diff --git a/MUON/AliMUONVDataIterator.cxx b/MUON/AliMUONVDataIterator.cxx
new file mode 100644 (file)
index 0000000..eae0fd3
--- /dev/null
@@ -0,0 +1,25 @@
+/**************************************************************************
+* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+*                                                                        *
+* Author: The ALICE Off-line Project.                                    *
+* Contributors are mentioned in the code where appropriate.              *
+*                                                                        *
+* Permission to use, copy, modify and distribute this software and its   *
+* documentation strictly for non-commercial purposes is hereby granted   *
+* without fee, provided that the above copyright notice appears in all   *
+* copies and that both the copyright notice and this permission notice   *
+* appear in the supporting documentation. The authors make no claims     *
+* about the suitability of this software for any purpose. It is          *
+* provided "as is" without express or implied warranty.                  *
+**************************************************************************/
+
+// $Id$
+
+#include "AliMUONVDataIterator.h"
+
+ClassImp(AliMUONVDataIterator)
+
+//_____________________________________________________________________________
+AliMUONVDataIterator::~AliMUONVDataIterator()
+{
+}
diff --git a/MUON/AliMUONVDataIterator.h b/MUON/AliMUONVDataIterator.h
new file mode 100644 (file)
index 0000000..44310c6
--- /dev/null
@@ -0,0 +1,33 @@
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+* See cxx source for full Copyright notice                               */
+
+// $Id$
+
+/// \ingroup
+/// \class AliMUONVDataIterator
+/// \brief
+/// 
+/// \author Laurent Aphecetche
+
+#ifndef ALIMUONVDATAITERATOR_H
+#define ALIMUONVDATAITERATOR_H
+
+#ifndef ROOT_TObject
+#  include "TObject.h"
+#endif
+
+class AliMUONVDataIterator : public TObject
+{
+public:
+  virtual ~AliMUONVDataIterator();
+  
+  virtual TObject* Next() = 0;
+  
+  virtual void Reset() = 0; 
+  
+  virtual Bool_t Remove() = 0;
+  
+  ClassDef(AliMUONVDataIterator,0) // Interface for an iterator on AliMUONData.
+};
+
+#endif