1 #ifndef ALIMUONESDINTERFACE_H
2 #define ALIMUONESDINTERFACE_H
4 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
5 * See cxx source for full Copyright notice */
10 /// \class AliMUONESDInterface
11 /// \brief Converter between MUON track/cluster/digit and ESDMuon track/cluster/pad
13 // Author Philippe Pillot
15 #include <AliMpExMap.h>
17 #include <TClonesArray.h>
21 class AliMUONVTrackStore;
22 class AliMUONVCluster;
23 class AliMUONVClusterStore;
25 class AliMUONVDigitStore;
26 class AliMUONTrackParam;
28 class AliESDMuonTrack;
29 class AliESDMuonCluster;
33 class AliMUONESDInterface : public TObject
35 public: // methods to play with internal objects
37 AliMUONESDInterface();
38 virtual ~AliMUONESDInterface();
40 virtual void Clear(Option_t* = "");
42 void LoadEvent(AliESDEvent& esdEvent);
44 /// Return internal track store
45 AliMUONVTrackStore* GetTracks() const {return fTracks;}
46 /// Return internal track store
47 AliMUONVDigitStore* GetDigits() const {return fDigits;}
49 // Return numbers of tracks/clusters/digits
50 Int_t GetNTracks() const;
51 Int_t GetNClusters() const;
52 Int_t GetNClusters(Int_t iTrack) const;
53 Int_t GetNDigits() const;
54 Int_t GetNDigits(Int_t iTrack) const;
55 Int_t GetNDigits(Int_t iTrack, Int_t iCluster) const;
56 Int_t GetNDigitsInCluster(UInt_t clusterId) const;
58 // Return internal MUON objects (faster than finders)
59 // ordering of the MUON objects is the same as in ESD
60 AliMUONTrack* GetTrack(Int_t iTrack) const;
61 AliMUONVCluster* GetCluster(Int_t iTrack, Int_t iCluster) const;
62 AliMUONVDigit* GetDigit(Int_t iTrack, Int_t iCluster, Int_t iDigit) const;
64 // Quickly return internal MUON objects (indices unchecked)
65 // ordering of the MUON objects is the same as in ESD
66 AliMUONTrack* GetTrackFast(Int_t iTrack) const;
67 AliMUONVCluster* GetClusterFast(Int_t iTrack, Int_t iCluster) const;
68 AliMUONVDigit* GetDigitFast(Int_t iTrack, Int_t iCluster, Int_t iDigit) const;
70 // Find internal MUON objects (slower than getters)
71 AliMUONVCluster* FindCluster(UInt_t clusterId) const;
72 AliMUONVDigit* FindDigit(UInt_t digitId) const;
74 // iterate over internal MUON objects
75 TIterator* CreateTrackIterator() const;
76 TIterator* CreateClusterIterator() const;
77 TIterator* CreateClusterIterator(Int_t iTrack) const;
78 TIterator* CreateDigitIterator() const;
79 TIterator* CreateDigitIterator(Int_t iTrack) const;
80 TIterator* CreateDigitIterator(Int_t iTrack, Int_t iCluster) const;
81 TIterator* CreateDigitIteratorInCluster(UInt_t clusterId) const;
84 public: // static methods
86 /// Set the version of track store
87 static void UseTrackStore(TString name) {fgTrackStoreName = name;}
88 /// Set the version of cluster store
89 static void UseClusterStore(TString name) {fgClusterStoreName = name;}
90 /// Set the version of digit store
91 static void UseDigitStore(TString name) {fgDigitStoreName = name;}
93 // Create empty stores (use the version defined in this interface)
94 static AliMUONVTrackStore* NewTrackStore();
95 static AliMUONVClusterStore* NewClusterStore();
96 static AliMUONVDigitStore* NewDigitStore();
98 // ESD track parameters --> MUON track parameters
99 static void GetParamAtVertex(const AliESDMuonTrack& esdTrack, AliMUONTrackParam& trackParam);
100 static void GetParamAtDCA(const AliESDMuonTrack& esdTrack, AliMUONTrackParam& trackParam);
101 static void GetParamAtFirstCluster(const AliESDMuonTrack& esdTrack, AliMUONTrackParam& trackParam);
102 static void GetParamCov(const AliESDMuonTrack& esdTrack, AliMUONTrackParam& trackParam);
104 // MUON track parameters --> ESD track parameters
105 static void SetParamAtVertex(const AliMUONTrackParam& trackParam, AliESDMuonTrack& esdTrack);
106 static void SetParamAtDCA(const AliMUONTrackParam& trackParam, AliESDMuonTrack& esdTrack);
107 static void SetParamAtFirstCluster(const AliMUONTrackParam& trackParam, AliESDMuonTrack& esdTrack);
108 static void SetParamCov(const AliMUONTrackParam& trackParam, AliESDMuonTrack& esdTrack);
110 // ESDMuon objects --> MUON objects conversion
111 static void ESDToMUON(const AliESDMuonTrack& esdTrack, AliMUONTrack& track);
112 static void ESDToMUON(const AliESDMuonCluster& esdCluster, AliMUONVCluster& cluster);
113 static void ESDToMUON(const AliESDMuonPad& esdPad, AliMUONVDigit& digit);
115 // MUON objects --> ESDMuon objects conversion
116 static void MUONToESD(const AliMUONTrack& track, AliESDMuonTrack& esdTrack, const Double_t vertex[3], const AliMUONVDigitStore* digits = 0x0);
117 static void MUONToESD(const AliMUONVCluster& cluster, AliESDMuonCluster& esdCluster, const AliMUONVDigitStore* digits = 0x0);
118 static void MUONToESD(const AliMUONVDigit& digit, AliESDMuonPad& esdPad);
120 // Add ESD object into the corresponding MUON store
121 // return a pointer to the corresponding MUON object into the store
122 static AliMUONTrack* Add(const AliESDMuonTrack& esdTrack, AliMUONVTrackStore& trackStore);
123 static AliMUONVCluster* Add(const AliESDMuonCluster& esdCluster, AliMUONVClusterStore& clusterStore);
124 static AliMUONVDigit* Add(const AliESDMuonPad& esdPad, AliMUONVDigitStore& digitStore);
129 AliMUONESDInterface (const AliMUONESDInterface&); ///< copy constructor
130 AliMUONESDInterface& operator=(const AliMUONESDInterface&); ///< assignment operator
136 AliMUONVCluster* FindClusterInTrack(const AliMUONTrack& track, UInt_t clusterId) const;
141 static TString fgTrackStoreName; ///< class name of the track store to use
142 static TString fgClusterStoreName; ///< class name of the cluster store to use
143 static TString fgDigitStoreName; ///< class name of the digit store to use
146 AliMUONVTrackStore* fTracks; ///< track container
147 AliMUONVDigitStore* fDigits; ///< digit container
149 // maps (to speed up data retrieval)
150 AliMpExMap* fTrackMap; ///< map of tracks
151 AliMpExMap* fClusterMap; ///< map of clusters
152 TClonesArray* fDigitMap; ///< map of digits
155 ClassDef(AliMUONESDInterface,0)
159 //___________________________________________________________________________
160 inline AliMUONTrack* AliMUONESDInterface::GetTrackFast(Int_t iTrack) const
162 /// return MUON track "iTrack" without any check
163 return (AliMUONTrack*) fTrackMap->GetObjectFast(iTrack);
166 //___________________________________________________________________________
167 inline AliMUONVCluster* AliMUONESDInterface::GetClusterFast(Int_t iTrack, Int_t iCluster) const
169 /// return MUON cluster numbered "iCluster" in track "iTrack" without any check
170 return (AliMUONVCluster*) ((AliMpExMap*) fClusterMap->GetObjectFast(iTrack))->GetObjectFast(iCluster);
173 //___________________________________________________________________________
174 inline AliMUONVDigit* AliMUONESDInterface::GetDigitFast(Int_t iTrack, Int_t iCluster, Int_t iDigit) const
176 /// return MUON digit numbered "iDigit" in cluster numbered "iCluster" of track "iTrack" without any check
177 return (AliMUONVDigit*) ((AliMpExMap*) ((AliMpExMap*) fDigitMap->UncheckedAt(iTrack))->GetObjectFast(iCluster))->GetObjectFast(iDigit);