ROOT logo
#ifndef ALIMUONESDINTERFACE_H
#define ALIMUONESDINTERFACE_H

/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
* See cxx source for full Copyright notice                               */

// $Id$

/// \ingroup rec
/// \class AliMUONESDInterface
/// \brief Converter between MUON track/cluster/digit and ESDMuon track/cluster/pad
/// 
//  Author Philippe Pillot

#include <AliMpExMap.h>
#include <TObject.h>
#include <TString.h>
#include "AliLog.h"

class AliMUONTrack;
class AliMUONVTrackStore;
class AliMUONVCluster;
class AliMUONVClusterStore;
class AliMUONVDigit;
class AliMUONVDigitStore;
class AliMUONLocalTrigger;
class AliMUONTriggerTrack;
class AliMUONVTriggerTrackStore;
class AliMUONVTriggerStore;
class AliMUONTrackParam;
class AliMUONVTrackReconstructor;
class AliESDEvent;
class AliESDMuonTrack;
class AliESDMuonCluster;
class AliESDMuonPad;
class TIterator;
class AliMUONRecoParam;

class AliMUONESDInterface : public TObject
{
public: // methods to play with internal objects
  
  AliMUONESDInterface();
  virtual ~AliMUONESDInterface();
  
  virtual void Clear(Option_t* = "");
  
  void LoadEvent(AliESDEvent& esdEvent,  Bool_t refit = kTRUE);
  
  /// Return internal track store
  AliMUONVTrackStore* GetTracks() const {return fTracks;}
  /// Return internal track store
  AliMUONVDigitStore* GetDigits() const {return fDigits;}
  /// Return internal trigger store
  AliMUONVTriggerStore* GetTriggers() const {return fTriggers;}
  
  // Return numbers of tracks/clusters/digits
  Int_t GetNTracks() const;
  Int_t GetNClusters() const;
  Int_t GetNClusters(UInt_t trackId) const;
  Int_t GetNDigits() const;
  Int_t GetNDigits(UInt_t trackId) const;
  Int_t GetNDigits(UInt_t trackId, UInt_t clusterId) const;
  Int_t GetNDigitsInCluster(UInt_t clusterId) const;
  Int_t GetNTriggers() const;
  
  // Check that all digits have been stored for a given track
  Bool_t DigitsStored(UInt_t trackId) const;
  
  // Find internal MUON objects
  AliMUONTrack*        FindTrack(UInt_t trackId) const;
  AliMUONVCluster*     FindCluster(UInt_t clusterId) const;
  AliMUONVCluster*     FindCluster(UInt_t trackId, UInt_t clusterId) const;
  AliMUONVDigit*       FindDigit(UInt_t digitId) const;
  AliMUONLocalTrigger* FindLocalTrigger(Int_t boardNumber) const;
  
  // iterate over internal MUON objects
  TIterator* CreateTrackIterator() const;
  TIterator* CreateClusterIterator() const;
  TIterator* CreateClusterIterator(UInt_t trackId) const;
  TIterator* CreateDigitIterator() const;
  TIterator* CreateDigitIterator(UInt_t trackId) const;
  TIterator* CreateDigitIterator(UInt_t trackId, UInt_t clusterId) const;
  TIterator* CreateDigitIteratorInCluster(UInt_t clusterId) const;
  TIterator* CreateLocalTriggerIterator() const;
  
  
public: // static methods
  
  // Reset the MUON tracker (using "recoParam" if provided)
  static void ResetTracker(const AliMUONRecoParam* recoParam = 0x0, Bool_t info = kTRUE);
  /// Return pointer to the MUON tracker if any (use first ResetTracker(...) to create it)
  static AliMUONVTrackReconstructor* GetTracker() {return fgTracker;}
  
  /// Set the version of track store
  static void UseTrackStore(TString name) {fgTrackStoreName = name;}
  /// Set the version of cluster store
  static void UseClusterStore(TString name) {fgClusterStoreName = name;}
  /// Set the version of digit store
  static void UseDigitStore(TString name) {fgDigitStoreName = name;}
  /// Set the version of trigger store
  static void UseTriggerStore(TString name) {fgTriggerStoreName = name;}
  
  // Create empty stores (use the version defined in this interface)
  static AliMUONVTrackStore* NewTrackStore();
  static AliMUONVClusterStore* NewClusterStore();
  static AliMUONVCluster* NewCluster();
  static AliMUONVDigitStore* NewDigitStore();
  static AliMUONVDigit* NewDigit();
  static AliMUONVTriggerStore* NewTriggerStore();
  static AliMUONVTriggerTrackStore* NewTriggerTrackStore();
  
  // ESD track parameters --> MUON track parameters
  static void GetParamAtVertex(const AliESDMuonTrack& esdTrack, AliMUONTrackParam& trackParam);
  static void GetParamAtDCA(const AliESDMuonTrack& esdTrack, AliMUONTrackParam& trackParam);
  static void GetParamAtFirstCluster(const AliESDMuonTrack& esdTrack, AliMUONTrackParam& trackParam);
  static void GetParamCov(const AliESDMuonTrack& esdTrack, AliMUONTrackParam& trackParam);
  
  // MUON track parameters --> ESD track parameters
  static void SetParamAtVertex(const AliMUONTrackParam& trackParam, AliESDMuonTrack& esdTrack);
  static void SetParamAtDCA(const AliMUONTrackParam& trackParam, AliESDMuonTrack& esdTrack);
  static void SetParamAtFirstCluster(const AliMUONTrackParam& trackParam, AliESDMuonTrack& esdTrack);
  static void SetParamCov(const AliMUONTrackParam& trackParam, AliESDMuonTrack& esdTrack);
  
  // ESDMuon objects --> MUON objects conversion
  static void ESDToMUON(const AliESDMuonTrack& esdTrack, AliMUONTrack& track, Bool_t refit = kTRUE);
  static void ESDToMUON(const AliESDMuonTrack& esdTrack, AliMUONLocalTrigger& locTrg);
  static void ESDToMUON(const AliESDMuonCluster& esdCluster, AliMUONVCluster& cluster);
  static void ESDToMUON(const AliESDMuonPad& esdPad, AliMUONVDigit& digit);
  
  // MUON objects --> ESDMuon objects conversion
  static void MUONToESD(const AliMUONTrack& track, AliESDEvent& esd, const Double_t vertex[3],
			const AliMUONVDigitStore* digits = 0x0, const AliMUONLocalTrigger* locTrg = 0x0);
  static void MUONToESD(const AliMUONTrack& track, AliESDMuonTrack& esdTrack, const Double_t vertex[3],
			const AliMUONLocalTrigger* locTrg = 0x0);
  static void MUONToESD(const AliMUONLocalTrigger& locTrg, AliESDEvent& esd, UInt_t trackId,
			const AliMUONTriggerTrack* triggerTrack = 0x0);
  static void MUONToESD(const AliMUONLocalTrigger& locTrg, AliESDMuonTrack& esdTrack, UInt_t trackId,
			const AliMUONTriggerTrack* triggerTrack = 0x0);
  static void MUONToESD(const AliMUONVCluster& cluster, AliESDEvent& esd, const AliMUONVDigitStore* digits = 0x0);
  static void MUONToESD(const AliMUONVCluster& cluster, AliESDMuonCluster& esdCluster, Bool_t copyPadsId = kFALSE);
  static void MUONToESD(const AliMUONVDigit& digit, AliESDEvent& esd);
  static void MUONToESD(const AliMUONVDigit& digit, AliESDMuonPad& esdPad);
  
  // Add ESD object into the corresponding MUON store
  // return a pointer to the corresponding MUON object into the store
  static AliMUONTrack*    Add(const AliESDMuonTrack& esdTrack, AliMUONVTrackStore& trackStore, Bool_t refit = kTRUE);
  static void             Add(const AliESDMuonTrack& esdTrack, AliMUONVTriggerStore& triggerStore);
  static AliMUONVCluster* Add(const AliESDMuonCluster& esdCluster, AliMUONVClusterStore& clusterStore);
  static AliMUONVDigit*   Add(const AliESDMuonPad& esdPad, AliMUONVDigitStore& digitStore);
  
  
protected:
  
  AliMUONESDInterface (const AliMUONESDInterface&); ///< copy constructor
  AliMUONESDInterface& operator=(const AliMUONESDInterface&); ///< assignment operator
  
  
private:
  
  void Reset();
  
  
private:
  
  static AliMUONRecoParam*           fgRecoParam; ///< reconstruction parameters for refitting
  static AliMUONVTrackReconstructor* fgTracker;   ///< track reconstructor for refitting
    
  static TString fgTrackStoreName;   ///< class name of the track store to use
  static TString fgClusterStoreName; ///< class name of the cluster store to use
  static TString fgDigitStoreName;   ///< class name of the digit store to use
  static TString fgTriggerStoreName; ///< class name of the trigger store to use
  static TString fgTriggerTrackStoreName; ///< class name of the trigger track store to use
  
  // data containers
  AliMUONVTrackStore*   fTracks;   ///< track container
  AliMUONVDigitStore*   fDigits;   ///< digit container
  AliMUONVTriggerStore* fTriggers; ///< trigger container
  
  // maps (to speed up data retrieval)
  AliMpExMap* fClusterMap; ///< map of clusters
  AliMpExMap* fDigitMap;   ///< map of digits
  
  
  ClassDef(AliMUONESDInterface,0)
};

#endif

 AliMUONESDInterface.h:1
 AliMUONESDInterface.h:2
 AliMUONESDInterface.h:3
 AliMUONESDInterface.h:4
 AliMUONESDInterface.h:5
 AliMUONESDInterface.h:6
 AliMUONESDInterface.h:7
 AliMUONESDInterface.h:8
 AliMUONESDInterface.h:9
 AliMUONESDInterface.h:10
 AliMUONESDInterface.h:11
 AliMUONESDInterface.h:12
 AliMUONESDInterface.h:13
 AliMUONESDInterface.h:14
 AliMUONESDInterface.h:15
 AliMUONESDInterface.h:16
 AliMUONESDInterface.h:17
 AliMUONESDInterface.h:18
 AliMUONESDInterface.h:19
 AliMUONESDInterface.h:20
 AliMUONESDInterface.h:21
 AliMUONESDInterface.h:22
 AliMUONESDInterface.h:23
 AliMUONESDInterface.h:24
 AliMUONESDInterface.h:25
 AliMUONESDInterface.h:26
 AliMUONESDInterface.h:27
 AliMUONESDInterface.h:28
 AliMUONESDInterface.h:29
 AliMUONESDInterface.h:30
 AliMUONESDInterface.h:31
 AliMUONESDInterface.h:32
 AliMUONESDInterface.h:33
 AliMUONESDInterface.h:34
 AliMUONESDInterface.h:35
 AliMUONESDInterface.h:36
 AliMUONESDInterface.h:37
 AliMUONESDInterface.h:38
 AliMUONESDInterface.h:39
 AliMUONESDInterface.h:40
 AliMUONESDInterface.h:41
 AliMUONESDInterface.h:42
 AliMUONESDInterface.h:43
 AliMUONESDInterface.h:44
 AliMUONESDInterface.h:45
 AliMUONESDInterface.h:46
 AliMUONESDInterface.h:47
 AliMUONESDInterface.h:48
 AliMUONESDInterface.h:49
 AliMUONESDInterface.h:50
 AliMUONESDInterface.h:51
 AliMUONESDInterface.h:52
 AliMUONESDInterface.h:53
 AliMUONESDInterface.h:54
 AliMUONESDInterface.h:55
 AliMUONESDInterface.h:56
 AliMUONESDInterface.h:57
 AliMUONESDInterface.h:58
 AliMUONESDInterface.h:59
 AliMUONESDInterface.h:60
 AliMUONESDInterface.h:61
 AliMUONESDInterface.h:62
 AliMUONESDInterface.h:63
 AliMUONESDInterface.h:64
 AliMUONESDInterface.h:65
 AliMUONESDInterface.h:66
 AliMUONESDInterface.h:67
 AliMUONESDInterface.h:68
 AliMUONESDInterface.h:69
 AliMUONESDInterface.h:70
 AliMUONESDInterface.h:71
 AliMUONESDInterface.h:72
 AliMUONESDInterface.h:73
 AliMUONESDInterface.h:74
 AliMUONESDInterface.h:75
 AliMUONESDInterface.h:76
 AliMUONESDInterface.h:77
 AliMUONESDInterface.h:78
 AliMUONESDInterface.h:79
 AliMUONESDInterface.h:80
 AliMUONESDInterface.h:81
 AliMUONESDInterface.h:82
 AliMUONESDInterface.h:83
 AliMUONESDInterface.h:84
 AliMUONESDInterface.h:85
 AliMUONESDInterface.h:86
 AliMUONESDInterface.h:87
 AliMUONESDInterface.h:88
 AliMUONESDInterface.h:89
 AliMUONESDInterface.h:90
 AliMUONESDInterface.h:91
 AliMUONESDInterface.h:92
 AliMUONESDInterface.h:93
 AliMUONESDInterface.h:94
 AliMUONESDInterface.h:95
 AliMUONESDInterface.h:96
 AliMUONESDInterface.h:97
 AliMUONESDInterface.h:98
 AliMUONESDInterface.h:99
 AliMUONESDInterface.h:100
 AliMUONESDInterface.h:101
 AliMUONESDInterface.h:102
 AliMUONESDInterface.h:103
 AliMUONESDInterface.h:104
 AliMUONESDInterface.h:105
 AliMUONESDInterface.h:106
 AliMUONESDInterface.h:107
 AliMUONESDInterface.h:108
 AliMUONESDInterface.h:109
 AliMUONESDInterface.h:110
 AliMUONESDInterface.h:111
 AliMUONESDInterface.h:112
 AliMUONESDInterface.h:113
 AliMUONESDInterface.h:114
 AliMUONESDInterface.h:115
 AliMUONESDInterface.h:116
 AliMUONESDInterface.h:117
 AliMUONESDInterface.h:118
 AliMUONESDInterface.h:119
 AliMUONESDInterface.h:120
 AliMUONESDInterface.h:121
 AliMUONESDInterface.h:122
 AliMUONESDInterface.h:123
 AliMUONESDInterface.h:124
 AliMUONESDInterface.h:125
 AliMUONESDInterface.h:126
 AliMUONESDInterface.h:127
 AliMUONESDInterface.h:128
 AliMUONESDInterface.h:129
 AliMUONESDInterface.h:130
 AliMUONESDInterface.h:131
 AliMUONESDInterface.h:132
 AliMUONESDInterface.h:133
 AliMUONESDInterface.h:134
 AliMUONESDInterface.h:135
 AliMUONESDInterface.h:136
 AliMUONESDInterface.h:137
 AliMUONESDInterface.h:138
 AliMUONESDInterface.h:139
 AliMUONESDInterface.h:140
 AliMUONESDInterface.h:141
 AliMUONESDInterface.h:142
 AliMUONESDInterface.h:143
 AliMUONESDInterface.h:144
 AliMUONESDInterface.h:145
 AliMUONESDInterface.h:146
 AliMUONESDInterface.h:147
 AliMUONESDInterface.h:148
 AliMUONESDInterface.h:149
 AliMUONESDInterface.h:150
 AliMUONESDInterface.h:151
 AliMUONESDInterface.h:152
 AliMUONESDInterface.h:153
 AliMUONESDInterface.h:154
 AliMUONESDInterface.h:155
 AliMUONESDInterface.h:156
 AliMUONESDInterface.h:157
 AliMUONESDInterface.h:158
 AliMUONESDInterface.h:159
 AliMUONESDInterface.h:160
 AliMUONESDInterface.h:161
 AliMUONESDInterface.h:162
 AliMUONESDInterface.h:163
 AliMUONESDInterface.h:164
 AliMUONESDInterface.h:165
 AliMUONESDInterface.h:166
 AliMUONESDInterface.h:167
 AliMUONESDInterface.h:168
 AliMUONESDInterface.h:169
 AliMUONESDInterface.h:170
 AliMUONESDInterface.h:171
 AliMUONESDInterface.h:172
 AliMUONESDInterface.h:173
 AliMUONESDInterface.h:174
 AliMUONESDInterface.h:175
 AliMUONESDInterface.h:176
 AliMUONESDInterface.h:177
 AliMUONESDInterface.h:178
 AliMUONESDInterface.h:179
 AliMUONESDInterface.h:180
 AliMUONESDInterface.h:181
 AliMUONESDInterface.h:182
 AliMUONESDInterface.h:183
 AliMUONESDInterface.h:184
 AliMUONESDInterface.h:185
 AliMUONESDInterface.h:186
 AliMUONESDInterface.h:187
 AliMUONESDInterface.h:188
 AliMUONESDInterface.h:189