CMS 3D CMS Logo

EgammaEcalExtractor.cc
Go to the documentation of this file.
1 //*****************************************************************************
2 // File: EgammaEcalExtractor.cc
3 // ----------------------------------------------------------------------------
4 // OrigAuth: Gilles De Lentdecker
5 // Institute: IIHE-ULB
6 //=============================================================================
7 //*****************************************************************************
8 
9 //C++ includes
10 #include <vector>
11 #include <functional>
12 
13 //ROOT includes
14 #include <Math/VectorUtil.h>
15 
16 //CMSSW includes
19 
20 using namespace egammaisolation;
21 using namespace reco::isodeposit;
22 
24 
26  const edm::EventSetup &evSetup,
27  const reco::Candidate &candidate) const {
28  edm::Handle<reco::SuperClusterCollection> superClusterCollectionH;
29  edm::Handle<reco::BasicClusterCollection> basicClusterCollectionH;
30  ev.getByToken(superClusterToken_, superClusterCollectionH);
31  ev.getByToken(basicClusterToken_, basicClusterCollectionH);
32 
34  math::XYZPoint position = sc->position();
35  // match the photon hybrid supercluster with those with Algo==0 (island)
36  double delta1 = 1000.;
37  double deltacur = 1000.;
38  const reco::SuperCluster *matchedsupercluster = nullptr;
39  bool MATCHEDSC = false;
40 
41  Direction candDir(position.eta(), position.phi());
42  reco::IsoDeposit deposit(candDir);
43  deposit.setVeto(reco::IsoDeposit::Veto(candDir, 0)); // no veto is needed for this deposit
44  deposit.addCandEnergy(sc->energy() * sin(2 * atan(exp(-sc->eta()))));
45 
46  for (reco::SuperClusterCollection::const_iterator scItr = superClusterCollectionH->begin();
47  scItr != superClusterCollectionH->end();
48  ++scItr) {
49  const reco::SuperCluster *supercluster = &(*scItr);
50 
51  if (supercluster->seed()->algo() == 0) {
52  deltacur = ROOT::Math::VectorUtil::DeltaR(supercluster->position(), position);
53  if (deltacur < delta1) {
54  delta1 = deltacur;
55  matchedsupercluster = supercluster;
56  MATCHEDSC = true;
57  }
58  }
59  }
60 
61  const reco::BasicCluster *cluster = nullptr;
62 
63  //loop over basic clusters
64  for (reco::BasicClusterCollection::const_iterator cItr = basicClusterCollectionH->begin();
65  cItr != basicClusterCollectionH->end();
66  ++cItr) {
67  cluster = &(*cItr);
68  // double ebc_bcchi2 = cluster->chi2();
69  int ebc_bcalgo = cluster->algo();
70  double ebc_bce = cluster->energy();
71  double ebc_bceta = cluster->eta();
72  double ebc_bcet = ebc_bce * sin(2 * atan(exp(ebc_bceta)));
73  double newDelta = 0.;
74 
75  if (ebc_bcet > etMin_ && ebc_bcalgo == 0) {
76  // if (ebc_bcchi2 < 30.) {
77 
78  if (MATCHEDSC || !scmatch_) { //skip selection if user wants to fill all superclusters
79  bool inSuperCluster = false;
80 
81  if (scmatch_) { // only try the matching if needed
82  reco::CaloCluster_iterator theEclust = matchedsupercluster->clustersBegin();
83  // loop over the basic clusters of the matched supercluster
84  for (; theEclust != matchedsupercluster->clustersEnd(); ++theEclust) {
85  if ((**theEclust) == (*cluster))
86  inSuperCluster = true;
87  }
88  }
89  if (!inSuperCluster || !scmatch_) { //skip selection if user wants to fill all superclusters
90  newDelta = ROOT::Math::VectorUtil::DeltaR(cluster->position(), position);
91  if (newDelta < conesize_) {
92  deposit.addDeposit(Direction(cluster->eta(), cluster->phi()), ebc_bcet);
93  }
94  }
95  }
96  // } // matches ebc_bcchi2
97  } // matches ebc_bcet && ebc_bcalgo
98  }
99 
100  // std::cout << "Will return ecalIsol = " << ecalIsol << std::endl;
101  return deposit;
102 }
const math::XYZPoint & position() const
cluster centroid position
Definition: CaloCluster.h:153
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
bool ev
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
static int position[264][3]
Definition: ReadPGInfo.cc:289
CaloCluster_iterator clustersBegin() const
fist iterator over BasicCluster constituents
Definition: SuperCluster.h:86
T get() const
get a component
Definition: Candidate.h:222
const CaloClusterPtr & seed() const
seed BasicCluster
Definition: SuperCluster.h:77
reco::IsoDeposit deposit(const edm::Event &ev, const edm::EventSetup &evSetup, const reco::Track &track) const override
CaloCluster_iterator clustersEnd() const
last iterator over BasicCluster constituents
Definition: SuperCluster.h:89