00001 #ifndef MuIsoDeposit_H
00002 #define MuIsoDeposit_H
00003
00016 #ifndef USE_MUISODEPOSIT_REQUIRED
00017 #error THIS FILE IS NOT SUPPOSED TO BE INCLUDED: USE "DataFormats/RecoCandidate/interface/IsoDeposit.h" instead
00018 #error THIS FILE IS HERE FOR BKW COMPATIBILITY ONLY
00019
00020
00021 #else
00022
00023 #include "DataFormats/TrackReco/interface/Track.h"
00024 #include "DataFormats/TrackReco/interface/TrackFwd.h"
00025 #include "DataFormats/MuonReco/interface/Direction.h"
00026 #include "DataFormats/Math/interface/Vector3D.h"
00027 #include <map>
00028 #include <cmath>
00029 #include <string>
00030 #include <vector>
00031
00032
00033 namespace reco {
00034 namespace muisodeposit {
00035 struct AbsVeto {
00036 virtual ~AbsVeto() { }
00038 virtual bool veto(double eta, double phi, float value) const = 0;
00041 virtual void centerOn(double eta, double phi) {
00042 throw cms::Exception("Not Implemented") << "This AbsVeto implementation (" << typeid(this).name() << ") does not support the centerOn(eta,phi) method";
00043 }
00044 };
00045 typedef std::vector<AbsVeto*> AbsVetos;
00046 }
00047 }
00048
00049 namespace reco {
00050
00051 class MuIsoDeposit {
00052 public:
00053
00054 typedef ::muonisolation::Direction Direction;
00055 typedef muisodeposit::AbsVeto AbsVeto;
00056 typedef muisodeposit::AbsVetos AbsVetos;
00057
00058
00059 struct Veto {
00060 Direction vetoDir; float dR;
00061 Veto() {}
00062 Veto(Direction dir, double d):vetoDir(dir), dR(d) {}
00063 };
00064 typedef std::vector<Veto> Vetos;
00065
00067 MuIsoDeposit(const std::string type="", double eta=0, double phi=0);
00068 MuIsoDeposit(const std::string type, const Direction & muonDirection);
00069
00071 virtual ~MuIsoDeposit(){};
00072
00074 const std::string getType() const {return theType;}
00075
00077 const Direction & direction() const { return theDirection; }
00078 double eta() const {return theDirection.eta();}
00079 double phi() const {return theDirection.phi();}
00080
00082 const Veto & veto() const { return theVeto; }
00084 void setVeto(const Veto & aVeto) { theVeto = aVeto; }
00085
00087 void addDeposit(double dr, double deposit);
00088 void addDeposit(const Direction & depDir, double deposit);
00089
00091 double depositWithin(
00092 double coneSize,
00093 const Vetos & vetos = Vetos(),
00094 bool skipDepositVeto = false
00095 ) const;
00096
00098 double depositWithin( Direction dir,
00099 double coneSize,
00100 const Vetos & vetos = Vetos(),
00101 bool skipDepositVeto = false
00102 ) const;
00103
00105 std::pair<double,int> depositAndCountWithin(
00106 double coneSize,
00107 const Vetos & vetos = Vetos(),
00108 double threshold = -1e+36,
00109 bool skipDepositVeto = false
00110 ) const;
00111
00113 std::pair<double,int> depositAndCountWithin(
00114 Direction dir,
00115 double coneSize,
00116 const Vetos & vetos = Vetos(),
00117 double threshold = -1e+36,
00118 bool skipDepositVeto = false
00119 ) const;
00120
00122 double depositWithin(
00123 double coneSize,
00124 const AbsVetos & vetos,
00125 bool skipDepositVeto = false
00126 ) const;
00127
00129 std::pair<double,int> depositAndCountWithin(
00130 double coneSize,
00131 const AbsVetos & vetos,
00132 bool skipDepositVeto = false
00133 ) const;
00134
00135
00137 double muonEnergy() const {return theMuonTag;}
00138
00140 void addMuonEnergy(double et) { theMuonTag += et;}
00141
00142 std::string print() const;
00143
00144
00145
00146
00147
00148
00149 class const_iterator {
00150 public:
00151 const const_iterator & operator++() { ++it_; cacheReady_ = false; return *this; }
00152 const const_iterator * operator->() const { return this; }
00153 float dR() const { return it_->first.deltaR; }
00154 float eta() const { if (!cacheReady_) doDir(); return cache_.eta(); }
00155 float phi() const { if (!cacheReady_) doDir(); return cache_.phi(); }
00156 float value() const { return it_->second; }
00157 bool operator!=(const const_iterator &it2) { return it2.it_ != it_; }
00158 friend class MuIsoDeposit;
00159 private:
00160 void doDir() const { cache_ = parent_->direction() + it_->first; cacheReady_ = true; }
00161 const_iterator(const MuIsoDeposit* parent, std::multimap<muonisolation::Direction::Distance, float>::const_iterator it) :
00162 parent_(parent), it_(it), cache_(), cacheReady_(false) { }
00163 const reco::MuIsoDeposit* parent_;
00164 mutable std::multimap<muonisolation::Direction::Distance, float>::const_iterator it_;
00165 mutable Direction cache_;
00166 mutable bool cacheReady_;
00167 };
00168 const_iterator begin() const { return const_iterator(this, theDeposits.begin()); }
00169 const_iterator end() const { return const_iterator(this, theDeposits.end()); }
00170 private:
00171
00173 std::string theType;
00174
00176 Direction theDirection;
00177
00179 Veto theVeto;
00180
00182 float theMuonTag;
00183
00185 typedef muonisolation::Direction::Distance Distance;
00186 typedef std::multimap<Distance, float> DepositsMultimap;
00187
00188
00189 DepositsMultimap theDeposits;
00190 };
00191
00192 }
00193
00194 #endif //USE_MUISODEPOSIT_REQUIRED
00195 #endif