From 70b4a8d69f8f993b33d4407c4336a603bc79afdf Mon Sep 17 00:00:00 2001 From: ivana Date: Fri, 17 Mar 2006 16:58:01 +0000 Subject: [PATCH] Initial version (Laurent) --- MUON/AliMUON1DArray.cxx | 130 ++++++++++++ MUON/AliMUON1DArray.h | 51 +++++ MUON/AliMUONCheck.cxx | 113 +++++++++++ MUON/AliMUONCheck.h | 52 +++++ MUON/AliMUONDataDigitIterator.cxx | 134 ++++++++++++ MUON/AliMUONDataDigitIterator.h | 50 +++++ MUON/AliMUONDataIterator.cxx | 120 +++++++++++ MUON/AliMUONDataIterator.h | 46 +++++ MUON/AliMUONTriggerEfficiencyCells.cxx | 271 +++++++++++++++++++++++++ MUON/AliMUONTriggerEfficiencyCells.h | 52 +++++ MUON/AliMUONV1DStore.cxx | 42 ++++ MUON/AliMUONV1DStore.h | 40 ++++ MUON/AliMUONVDataIterator.cxx | 25 +++ MUON/AliMUONVDataIterator.h | 33 +++ 14 files changed, 1159 insertions(+) create mode 100644 MUON/AliMUON1DArray.cxx create mode 100644 MUON/AliMUON1DArray.h create mode 100644 MUON/AliMUONCheck.cxx create mode 100644 MUON/AliMUONCheck.h create mode 100644 MUON/AliMUONDataDigitIterator.cxx create mode 100644 MUON/AliMUONDataDigitIterator.h create mode 100644 MUON/AliMUONDataIterator.cxx create mode 100644 MUON/AliMUONDataIterator.h create mode 100755 MUON/AliMUONTriggerEfficiencyCells.cxx create mode 100755 MUON/AliMUONTriggerEfficiencyCells.h create mode 100644 MUON/AliMUONV1DStore.cxx create mode 100644 MUON/AliMUONV1DStore.h create mode 100644 MUON/AliMUONVDataIterator.cxx create mode 100644 MUON/AliMUONVDataIterator.h diff --git a/MUON/AliMUON1DArray.cxx b/MUON/AliMUON1DArray.cxx new file mode 100644 index 00000000000..b852543c5c1 --- /dev/null +++ b/MUON/AliMUON1DArray.cxx @@ -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 index 00000000000..e68218b341d --- /dev/null +++ b/MUON/AliMUON1DArray.h @@ -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 index 00000000000..7e106fa166a --- /dev/null +++ b/MUON/AliMUONCheck.cxx @@ -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 index 00000000000..2137c7c5357 --- /dev/null +++ b/MUON/AliMUONCheck.h @@ -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 index 00000000000..7ccb9437887 --- /dev/null +++ b/MUON/AliMUONDataDigitIterator.cxx @@ -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 index 00000000000..e01c4840d5e --- /dev/null +++ b/MUON/AliMUONDataDigitIterator.h @@ -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 index 00000000000..fc2821809b6 --- /dev/null +++ b/MUON/AliMUONDataIterator.cxx @@ -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 index 00000000000..d7f2e275ed4 --- /dev/null +++ b/MUON/AliMUONDataIterator.h @@ -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 index 00000000000..12f29960c04 --- /dev/null +++ b/MUON/AliMUONTriggerEfficiencyCells.cxx @@ -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 +#include +#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=0 & yExpandPathName(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> 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