CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
25 reco::IsoDeposit EgammaEcalExtractor::deposit(const edm::Event & ev, const edm::EventSetup & evSetup, const reco::Candidate & candidate) const {
26  edm::Handle<reco::SuperClusterCollection> superClusterCollectionH;
27  edm::Handle<reco::BasicClusterCollection> basicClusterCollectionH;
28  ev.getByToken(superClusterToken_, superClusterCollectionH);
29  ev.getByToken(basicClusterToken_, basicClusterCollectionH);
30 
32  math::XYZPoint position = sc->position();
33  // match the photon hybrid supercluster with those with Algo==0 (island)
34  double delta1=1000.;
35  double deltacur=1000.;
36  const reco::SuperCluster *matchedsupercluster=0;
37  bool MATCHEDSC = false;
38 
39  Direction candDir(position.eta(), position.phi());
40  reco::IsoDeposit deposit(candDir );
41  deposit.setVeto( reco::IsoDeposit::Veto(candDir, 0) ); // no veto is needed for this deposit
42  deposit.addCandEnergy(sc->energy()*sin(2*atan(exp(-sc->eta()))));
43 
44  for(reco::SuperClusterCollection::const_iterator scItr = superClusterCollectionH->begin(); scItr != superClusterCollectionH->end(); ++scItr){
45 
46  const reco::SuperCluster *supercluster = &(*scItr);
47 
48  if(supercluster->seed()->algo() == 0){
49  deltacur = ROOT::Math::VectorUtil::DeltaR(supercluster->position(), position);
50  if (deltacur < delta1) {
51  delta1=deltacur;
52  matchedsupercluster = supercluster;
53  MATCHEDSC = true;
54  }
55  }
56  }
57 
58  const reco::BasicCluster *cluster= 0;
59 
60  //loop over basic clusters
61  for(reco::BasicClusterCollection::const_iterator cItr = basicClusterCollectionH->begin(); cItr != basicClusterCollectionH->end(); ++cItr){
62 
63  cluster = &(*cItr);
64 // double ebc_bcchi2 = cluster->chi2();
65  int ebc_bcalgo = cluster->algo();
66  double ebc_bce = cluster->energy();
67  double ebc_bceta = cluster->eta();
68  double ebc_bcet = ebc_bce*sin(2*atan(exp(ebc_bceta)));
69  double newDelta = 0.;
70 
71  if (ebc_bcet > etMin_ && ebc_bcalgo == 0) {
72 // if (ebc_bcchi2 < 30.) {
73 
74  if(MATCHEDSC || !scmatch_ ){ //skip selection if user wants to fill all superclusters
75  bool inSuperCluster = false;
76 
77  if( scmatch_ ){ // only try the matching if needed
78  reco::CaloCluster_iterator theEclust = matchedsupercluster->clustersBegin();
79  // loop over the basic clusters of the matched supercluster
80  for(;theEclust != matchedsupercluster->clustersEnd(); ++theEclust) {
81  if ((**theEclust) == (*cluster) ) inSuperCluster = true;
82  }
83  }
84  if (!inSuperCluster || !scmatch_ ) { //skip selection if user wants to fill all superclusters
85  newDelta=ROOT::Math::VectorUtil::DeltaR(cluster->position(),position);
86  if(newDelta < conesize_) {
87  deposit.addDeposit( Direction(cluster->eta(), cluster->phi()), ebc_bcet);
88  }
89  }
90  }
91 // } // matches ebc_bcchi2
92  } // matches ebc_bcet && ebc_bcalgo
93 
94  }
95 
96  // std::cout << "Will return ecalIsol = " << ecalIsol << std::endl;
97  return deposit;
98 
99 }
const math::XYZPoint & position() const
cluster centroid position
Definition: CaloCluster.h:126
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:449
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
bool ev
virtual reco::IsoDeposit deposit(const edm::Event &ev, const edm::EventSetup &evSetup, const reco::Track &track) const
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
static int position[264][3]
Definition: ReadPGInfo.cc:509
CaloCluster_iterator clustersBegin() const
fist iterator over BasicCluster constituents
Definition: SuperCluster.h:75
T get() const
get a component
Definition: Candidate.h:217
const CaloClusterPtr & seed() const
seed BasicCluster
Definition: SuperCluster.h:66
CaloCluster_iterator clustersEnd() const
last iterator over BasicCluster constituents
Definition: SuperCluster.h:78