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 }
reco::CaloCluster::phi
double phi() const
azimuthal angle of cluster centroid
Definition: CaloCluster.h:184
egammaisolation
Definition: EgammaTrackSelector.h:11
reco::SuperCluster
Definition: SuperCluster.h:18
egammaisolation::EgammaEcalExtractor::deposit
reco::IsoDeposit deposit(const edm::Event &ev, const edm::EventSetup &evSetup, const reco::Track &track) const override
Definition: EgammaEcalExtractor.h:55
edm::PtrVectorItr
Definition: PtrVector.h:51
reco::Candidate::get
T get() const
get a component
Definition: Candidate.h:221
reco::IsoDeposit::Veto
Definition: IsoDeposit.h:59
edm::Handle
Definition: AssociativeIterator.h:50
RecoCandidate.h
EgammaEcalExtractor.h
edm::Ref< SuperClusterCollection >
funct::sin
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
reco::isodeposit
Definition: IsoDeposit.h:31
reco::CaloCluster
Definition: CaloCluster.h:31
math::XYZPoint
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
reco::SuperCluster::seed
const CaloClusterPtr & seed() const
seed BasicCluster
Definition: SuperCluster.h:77
reco::CaloCluster::eta
double eta() const
pseudorapidity of cluster centroid
Definition: CaloCluster.h:181
position
static int position[264][3]
Definition: ReadPGInfo.cc:289
egammaisolation::EgammaEcalExtractor::~EgammaEcalExtractor
~EgammaEcalExtractor() override
Definition: EgammaEcalExtractor.cc:23
reco::SuperCluster::clustersBegin
CaloCluster_iterator clustersBegin() const
fist iterator over BasicCluster constituents
Definition: SuperCluster.h:86
edm::EventSetup
Definition: EventSetup.h:57
electronAnalyzer_cfi.DeltaR
DeltaR
Definition: electronAnalyzer_cfi.py:33
reco::CaloCluster::position
const math::XYZPoint & position() const
cluster centroid position
Definition: CaloCluster.h:154
reco::Candidate
Definition: Candidate.h:27
reco::CaloCluster::algo
AlgoId algo() const
algorithm identifier
Definition: CaloCluster.h:190
reco::isodeposit::Direction
Definition: IsoDepositDirection.h:19
ev
bool ev
Definition: Hydjet2Hadronizer.cc:95
reco::IsoDeposit
Definition: IsoDeposit.h:49
reco::SuperCluster::clustersEnd
CaloCluster_iterator clustersEnd() const
last iterator over BasicCluster constituents
Definition: SuperCluster.h:89
JetChargeProducer_cfi.exp
exp
Definition: JetChargeProducer_cfi.py:6
edm::Event
Definition: Event.h:73
reco::CaloCluster::energy
double energy() const
cluster energy
Definition: CaloCluster.h:149