#ifndef ALIHLTMUONRECHIT_H #define ALIHLTMUONRECHIT_H /* This file is property of and copyright by the ALICE HLT Project * * ALICE Experiment at CERN, All rights reserved. * * See cxx source for full Copyright notice */ // $Id$ /// /// @file AliHLTMUONRecHit.h /// @author Artur Szostak /// @date 29 Sep 2007 /// @brief Declaration of a reconstructed hit ROOT object to store 3D hit coordinates. /// #include "TObject.h" #include "TClonesArray.h" #include "TVector3.h" #include /** * A 3D hit object used to store hits reconstructed on the tracking chambers by * the dHLT. These objects store information translated into ROOT format from * dHLT raw data. Reconstructed hit values of (0, 0, 0) indicate an invalid or * nil hit. * This class is mainly for testing or as a helper object for dHLT specific analysis, * since it is sometimes easier to store and handle ROOT objects. */ class AliHLTMUONRecHit : public TObject { /** * Stream operator for usage with std::ostream classes. * Allows usage such as: * AliHLTMUONRecHit h; std::cout << h; */ friend std::ostream& operator << (std::ostream& stream, const AliHLTMUONRecHit& hit); public: /** * The AliChannel class stores extra debugging information about the channels * and raw data words that were considered during reconstruction of a hit * by the dHLT hit reconstructor component. */ class AliChannel : public TObject { /** * Stream operator for usage with std::ostream classes. */ friend std::ostream& operator << (std::ostream& stream, const AliChannel& c); public: /** * Constructor. * \param busPatch The bus patch ID of the channel as found in the DDL raw data. * \param manu The MANU ID of the channel as found in the raw data word. * \param channel The MANU channel ID as found in the raw data word. * \param signal The ADC signal value as found in the raw data word. * \param rawDataWord The actual raw data word. */ AliChannel( Short_t busPatch = -1, Short_t manu = -1, Short_t channel = -1, Short_t signal = -1, UInt_t rawDataWord = 0 ) : TObject(), fBusPatch(busPatch), fManu(manu), fAddress(channel), fSignal(signal), fRawDataWord(rawDataWord) {} /** * Default destructor. */ virtual ~AliChannel() {} /** * Returns the bus patch ID of the channel. */ Short_t BusPatch() const { return fBusPatch; } /** * Returns the MANU address. */ Short_t Manu() const { return fManu; } /** * Returns the channel address of the MANU. */ Short_t Address() const { return fAddress; } /** * Returns the ADC signal measured on the channel. */ Short_t Signal() const { return fSignal; } /** * Returns the raw data word as found in the tracking DDL payload. */ UInt_t RawDataWord() const { return fRawDataWord; } /** * Returns true if the channel is for the bending plane. */ Bool_t InBendingPlane() const { return (fRawDataWord & (1<<28)) == 0; } /** * Returns true if the channel is for the non-bending plane. */ Bool_t InNonBendingPlane() const { return (fRawDataWord & (1<<28)) != 0; } virtual void Print(Option_t* option = NULL) const; // Methods inherited from TObject virtual Bool_t IsSortable() const { return kTRUE; } Int_t Compare(const TObject* obj) const; // Implement comparison operators. bool operator == (const AliChannel& c) const { return fManu == c.fManu and fAddress == c.fAddress and fSignal == c.fSignal and fRawDataWord == c.fRawDataWord; } bool operator != (const AliChannel& c) const { return not this->operator == (c); } private: Short_t fBusPatch; ///< The bus patch ID for the channel. Short_t fManu; ///< The MANU address on the electronics. Short_t fAddress; ///< The channel address on the electronics. Short_t fSignal; ///< ADC value of signal. UInt_t fRawDataWord; ///< The raw data word as found in the DDL stream. ClassDef(AliHLTMUONRecHit::AliChannel, 5); // A MANU channel forming part of a cluster that was considered during hit reconstruction in dHLT. }; /** * Construct a new AliHLTMUONRecHit object with coordinate (x, y, z). * @param x X coordinate of hit * @param y Y coordinate of hit * @param z Z coordinate of hit * @param sourceDDL The DDL from which this hit originates. * @param detectorId The ID number for the AliRoot detector element on * which this hit resides. * @param clusterId The cluster ID number assigned to the hit's cluster. * @param nChExpB The expected number of channels in the bending plane that form the cluster. * @param nChExpNB The expected number of channels in the non-bending plane that form the cluster. * @param chargeB The charge of the cluster in the bending plane. * @param chargeNB The charge of the cluster in the non-bending plane. */ AliHLTMUONRecHit( Float_t x = 0, Float_t y = 0, Float_t z = 0, Int_t sourceDDL = -1, Int_t detElemId = -1, Int_t clusterId = -1, UShort_t nChExpB = 0, UShort_t nChExpNB = 0, Float_t chargeB = -1, Float_t chargeNB = -1 ) : TObject(), fCoordinate(x, y, z), fSourceDDL(sourceDDL), fDetElemId(detElemId), fClusterId(clusterId), fNchExpB(nChExpB), fNchExpNB(nChExpNB), fChannels("AliHLTMUONRecHit::AliChannel", 6), fChargeB(chargeB), fChargeNB(chargeNB) {} /** * Default destructor. */ virtual ~AliHLTMUONRecHit() {} /** * Returns the 3D hit coordinate. */ const TVector3& Coordinate() const { return fCoordinate; } /** * Returns the X coordinate of the reconstructed hit in centimetres. */ Double_t X() const { return fCoordinate.X(); } /** * Returns the Y coordinate of the reconstructed hit in centimetres. */ Double_t Y() const { return fCoordinate.Y(); } /** * Returns the Z coordinate of the reconstructed hit in centimetres. */ Double_t Z() const { return fCoordinate.Z(); } /** * Returns the source DDL from which this hit originates. * -1 is returned if this was not set. */ Int_t SourceDDL() const { return fSourceDDL; } /** * Returns the detector element ID on which this reconstructed hit resides. * -1 is returned if this was not set. */ Int_t DetElemId() const { return fDetElemId; } /** * Returns the chamber number of this hit in the range [1..14]. * If -1 is returned then the chamber number is not known because the * detector element ID was not set or is invalid. * @param warn Indicates if any warning should be printed in case of problems. */ Int_t Chamber(bool warn = true) const; /** * Returns the ID number given to the hit's cluster. */ Int_t ClusterId() const { return fClusterId; } /** * Returns the expected total number of channels that are to be added to this hit. * If the number of calls to AddChannel does not correspond to this value * then we lost some debugging information along the way. */ UInt_t ExpectedNchannels() const { return ExpectedNchannelsB() + ExpectedNchannelsNB(); } /** * Returns the expected number of channels in the bending plane that are to * be added to this hit. */ UInt_t ExpectedNchannelsB() const { return fNchExpB; } /** * Returns the expected number of channels in the non-bending plane that * are to be added to this hit. */ UInt_t ExpectedNchannelsNB() const { return fNchExpNB; } /** * Returns the total charge of the cluster. */ Float_t TotalCharge() const { return fChargeB + fChargeNB; } /** * Returns the charge of the cluster in the bending plane. */ Float_t ChargeB() const { return fChargeB; } /** * Returns the charge of the cluster in the non-bending plane. */ Float_t ChargeNB() const { return fChargeNB; } /** * Sets the extra debugging information for this hit. * @param detElemId The detector element ID. * @param clusterId Cluster ID of the hit's cluster. * @param nChExpB Number of expected channels in the bending plane forming the cluster. * @param nChExpNB Number of expected channels in the non-bending plane forming the cluster. * @param chargeB The charge of the cluster in the bending plane. * @param chargeNB The charge of the cluster in the non-bending plane. * @param sourceDDL The source DDL of this hit. */ void SetDebugInfo( Int_t detElemId, Int_t clusterId, UShort_t nChExpB, UShort_t nChExpNB, Float_t chargeB, Float_t chargeNB, Int_t sourceDDL = -1 ); /** * Sets the hit coordinate. */ void SetHit(Float_t x, Float_t y, Float_t z) { fCoordinate.SetXYZ(x, y, z); } /** * Returns the total number of channels associated with this hit. */ Int_t Nchannels() const { return fChannels.GetEntriesFast(); } /** * Returns the i'th channel associated with this hit. * @param i Should be a number in the range [0..n), where n = Nchannels(). */ const AliChannel* GetChannel(Int_t i) const { return static_cast(fChannels[i]); } /** * Adds a new channel to this hit if it is on a tracking chamber. * @param buspatch The bus patch ID of the channel. * @param manu The MANU number * @param channel The MANU channel address. * @param signal The ADC signal value measured on the channel. * @param rawDataWord This is the raw data word as read from the DDL. */ void AddChannel( Short_t buspatch, Short_t manu, Short_t channel, Short_t signal, UInt_t rawDataWord ); /** * Prints the details of the reconstructed hit. * @param option A case sensitive string that can contain one of the * following strings: * "compact" - Prints just the coordinates of the hit in a terse format. * "detail" - Prints the coordinates and detector element ID. * "all" - Prints all known information about this hit including * channel information forming the cluster that was reconstructed. * If the string contains an empty option or NULL then the default is * to print compactly. */ virtual void Print(Option_t* option = NULL) const; // Methods inherited from TObject virtual Bool_t IsSortable() const { return kTRUE; } Int_t Compare(const TObject* obj) const; // Implement comparison operators. bool operator == (const AliHLTMUONRecHit& hit) const { return X() == hit.X() and Y() == hit.Y() and Z() == hit.Z(); } bool operator != (const AliHLTMUONRecHit& hit) const { return not this->operator == (hit); } private: TVector3 fCoordinate; ///< The 3D coordinate of the hit in AliRoot global coordinates (cm). // The following is debugging information and may not be filled if the // dHLT components were not set to produce this information. Int_t fSourceDDL; ///< The DDL from which this hit originates. Int_t fDetElemId; ///< Detector element ID number. Int_t fClusterId; ///< The cluster ID number used to relate all the channels to each other. UShort_t fNchExpB; ///< The number of channels in the bending plane that were supposed to be found. UShort_t fNchExpNB; ///< The number of channels in the non-bending plane that were supposed to be found. TClonesArray fChannels; ///< The channels forming part of the cluster from which this hit was reconstructed. Float_t fChargeB; ///< The charge of the cluster in the bending plane. Float_t fChargeNB; ///< The charge of the cluster in the non-bending plane. ClassDef(AliHLTMUONRecHit, 5); // A reconstructed hit translated from dHLT raw data into ROOT format. }; #endif // ALIHLTMUONRECHIT_H