CMS 3D CMS Logo

EgammaEcalExtractor.cc
Go to the documentation of this file.
1 //*****************************************************************************
2 // File: EgammaEcalExtractor.cc
3 // ----------------------------------------------------------------------------
4 // Type: Class implementation header
5 // Package: EgammaIsolationAlgos/EgammaIsolationAlgos
6 // Class: EgammaEcalExtractor
7 // Language: Standard C++
8 // Project: CMS
9 // OrigAuth: Gilles De Lentdecker
10 // Institute: IIHE-ULB
11 //=============================================================================
12 //*****************************************************************************
13 
29 
30 #include <Math/VectorUtil.h>
31 
32 #include <functional>
33 #include <vector>
34 
35 namespace egammaisolation {
36 
38  public:
41  : etMin_(par.getParameter<double>("etMin")),
42  conesize_(par.getParameter<double>("extRadius")),
43  scmatch_(par.getParameter<bool>("superClusterMatch")),
45  iC.consumes<reco::BasicClusterCollection>(par.getParameter<edm::InputTag>("basicClusters"))),
47  iC.consumes<reco::SuperClusterCollection>(par.getParameter<edm::InputTag>("superClusters"))) {}
48 
49  ~EgammaEcalExtractor() override;
50 
51  void fillVetos(const edm::Event& ev, const edm::EventSetup& evSetup, const reco::TrackCollection& tracks) override {
52  }
54  const edm::EventSetup& evSetup,
55  const reco::Track& track) const override {
56  throw cms::Exception("Configuration Error")
57  << "This extractor " << (typeid(this).name()) << " is not made for tracks";
58  }
60  const edm::EventSetup& evSetup,
61  const reco::Candidate& c) const override;
62 
63  private:
64  // ---------- member data --------------------------------
65 
66  // Parameters of isolation cone geometry.
67  // Photon case
68  double etMin_;
69  double conesize_;
70  bool scmatch_; // true-> reject basic clusters matched to the superclsuter
71  // false-> fill all basic clusters
74  };
75 
76 } // namespace egammaisolation
77 
81 
82 using namespace egammaisolation;
83 using namespace reco::isodeposit;
84 
86 
88  const edm::EventSetup& evSetup,
89  const reco::Candidate& candidate) const {
91  math::XYZPoint position = sc->position();
92  // match the photon hybrid supercluster with those with Algo==0 (island)
93  double delta1 = 1000.;
94  double deltacur = 1000.;
95  const reco::SuperCluster* matchedsupercluster = nullptr;
96  bool MATCHEDSC = false;
97 
98  Direction candDir(position.eta(), position.phi());
99  reco::IsoDeposit deposit(candDir);
100  deposit.setVeto(reco::IsoDeposit::Veto(candDir, 0)); // no veto is needed for this deposit
101  deposit.addCandEnergy(sc->energy() * sin(2 * atan(exp(-sc->eta()))));
102 
103  for (auto const& scItr : ev.get(superClusterToken_)) {
104  const reco::SuperCluster* supercluster = &scItr;
105 
106  if (supercluster->seed()->algo() == 0) {
107  deltacur = ROOT::Math::VectorUtil::DeltaR(supercluster->position(), position);
108  if (deltacur < delta1) {
109  delta1 = deltacur;
110  matchedsupercluster = supercluster;
111  MATCHEDSC = true;
112  }
113  }
114  }
115 
116  const reco::BasicCluster* cluster = nullptr;
117 
118  //loop over basic clusters
119  for (auto const& cItr : ev.get(basicClusterToken_)) {
120  cluster = &cItr;
121  // double ebc_bcchi2 = cluster->chi2();
122  int ebc_bcalgo = cluster->algo();
123  double ebc_bce = cluster->energy();
124  double ebc_bceta = cluster->eta();
125  double ebc_bcet = ebc_bce * sin(2 * atan(exp(ebc_bceta)));
126  double newDelta = 0.;
127 
128  if (ebc_bcet > etMin_ && ebc_bcalgo == 0) {
129  // if (ebc_bcchi2 < 30.) {
130 
131  if (MATCHEDSC || !scmatch_) { //skip selection if user wants to fill all superclusters
132  bool inSuperCluster = false;
133 
134  if (scmatch_) { // only try the matching if needed
135  reco::CaloCluster_iterator theEclust = matchedsupercluster->clustersBegin();
136  // loop over the basic clusters of the matched supercluster
137  for (; theEclust != matchedsupercluster->clustersEnd(); ++theEclust) {
138  if ((**theEclust) == (*cluster))
139  inSuperCluster = true;
140  }
141  }
142  if (!inSuperCluster || !scmatch_) { //skip selection if user wants to fill all superclusters
143  newDelta = ROOT::Math::VectorUtil::DeltaR(cluster->position(), position);
144  if (newDelta < conesize_) {
145  deposit.addDeposit(Direction(cluster->eta(), cluster->phi()), ebc_bcet);
146  }
147  }
148  }
149  // } // matches ebc_bcchi2
150  } // matches ebc_bcet && ebc_bcalgo
151  }
152 
153  // std::cout << "Will return ecalIsol = " << ecalIsol << std::endl;
154  return deposit;
155 }
const math::XYZPoint & position() const
cluster centroid position
Definition: CaloCluster.h:154
reco::IsoDeposit deposit(const edm::Event &ev, const edm::EventSetup &evSetup, const reco::Track &track) const override
EgammaEcalExtractor(const edm::ParameterSet &par, edm::ConsumesCollector &&iC)
AlgoId algo() const
algorithm identifier
Definition: CaloCluster.h:190
T get() const
get a component
Definition: Candidate.h:221
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
CaloCluster_iterator clustersBegin() const
fist iterator over BasicCluster constituents
Definition: SuperCluster.h:86
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
double phi() const
azimuthal angle of cluster centroid
Definition: CaloCluster.h:184
CaloCluster_iterator clustersEnd() const
last iterator over BasicCluster constituents
Definition: SuperCluster.h:89
edm::EDGetTokenT< reco::BasicClusterCollection > basicClusterToken_
std::vector< SuperCluster > SuperClusterCollection
collection of SuperCluser objectr
void fillVetos(const edm::Event &ev, const edm::EventSetup &evSetup, const reco::TrackCollection &tracks) override
edm::EDGetTokenT< reco::SuperClusterCollection > superClusterToken_
double energy() const
cluster energy
Definition: CaloCluster.h:149
auto const & tracks
cannot be loose
EgammaEcalExtractor(const edm::ParameterSet &par, edm::ConsumesCollector &iC)
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
std::vector< BasicCluster > BasicClusterCollection
collection of BasicCluster objects
const CaloClusterPtr & seed() const
seed BasicCluster
Definition: SuperCluster.h:77
fixed size matrix
HLT enums.
static int position[264][3]
Definition: ReadPGInfo.cc:289
#define DEFINE_EDM_PLUGIN(factory, type, name)
double eta() const
pseudorapidity of cluster centroid
Definition: CaloCluster.h:181