CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
L2TauNarrowConeIsolationProducer.cc
Go to the documentation of this file.
5 
6 using namespace reco;
7 
9  l2CaloJets_(consumes<CaloJetCollection>(iConfig.getParameter<edm::InputTag>("L2TauJetCollection"))),
10  EBRecHits_(consumes<EBRecHitCollection>(iConfig.getParameter<edm::InputTag>("EBRecHits"))),
11  EERecHits_(consumes<EERecHitCollection>(iConfig.getParameter<edm::InputTag>("EERecHits"))),
12  CaloTowers_(consumes<CaloTowerCollection>(iConfig.getParameter<edm::InputTag>("CaloTowers"))),
13  associationRadius_(iConfig.getParameter<double>("associationRadius")),
14  crystalThresholdE_(iConfig.getParameter<double>("crystalThresholdEE")),
15  crystalThresholdB_(iConfig.getParameter<double>("crystalThresholdEB")),
16  towerThreshold_(iConfig.getParameter<double>("towerThreshold"))
17  {
18 
19  //ECAL Isolation
20  edm::ParameterSet ECALIsolParams = iConfig.getParameter<edm::ParameterSet>("ECALIsolation") ;
21  ECALIsolation_innerCone_ = ECALIsolParams.getParameter<double>( "innerCone" );
22  ECALIsolation_outerCone_ = ECALIsolParams.getParameter<double>( "outerCone" );
23  ECALIsolation_run_ = ECALIsolParams.getParameter<bool>( "runAlgorithm" );
24 
25  //ECAL Clustering
26  edm::ParameterSet ECALClusterParams = iConfig.getParameter<edm::ParameterSet>("ECALClustering") ;
27  ECALClustering_run_ = ECALClusterParams.getParameter<bool>( "runAlgorithm" );
28  ECALClustering_clusterRadius_ = ECALClusterParams.getParameter<double>( "clusterRadius" );
29 
30  //Tower Isolation
31  edm::ParameterSet TowerIsolParams = iConfig.getParameter<edm::ParameterSet>("TowerIsolation") ;
32  TowerIsolation_innerCone_ = TowerIsolParams.getParameter<double>( "innerCone" );
33  TowerIsolation_outerCone_ = TowerIsolParams.getParameter<double>( "outerCone" );
34  TowerIsolation_run_ = TowerIsolParams.getParameter<bool>( "runAlgorithm" );
35 
36 
37  //Add the products
38  produces<L2TauInfoAssociation>();
39 
40 }
41 
42 
44 {
45  //Destruction
46 
47 }
48 
49 
50 
51 void
53 {
54 
55 
56  edm::Handle<CaloJetCollection> l2CaloJets; //Handle to the input (L2TauCaloJets);
57  iEvent.getByToken(l2CaloJets_ ,l2CaloJets);//get the handle
58 
59  //Create the Association
60  std::auto_ptr<L2TauInfoAssociation> l2InfoAssoc( new L2TauInfoAssociation);
61 
62  //If the JetCrystalsAssociation exists -> RUN The Producer
63  if(l2CaloJets->size()>0)
64  {
65  CaloJetCollection::const_iterator jcStart = l2CaloJets->begin();
66  //Loop on Jets
67  for(CaloJetCollection::const_iterator jc = jcStart ;jc!=l2CaloJets->end();++jc)
68  {
69  //Create Algorithm Object
71 
72  //Create Info Object
74 
75  //get Hits
76  math::PtEtaPhiELorentzVectorCollection hitsECAL = getECALHits(*jc,iEvent,iSetup);
78 
79 
80 
81  //Run ECALIsolation
83  {
84  info.setEcalIsolEt( alg.isolatedEt(hitsECAL , jc->p4().Vect(), ECALIsolation_innerCone_,ECALIsolation_outerCone_) );
85  if(hitsECAL.size()>0)
86  info.setSeedEcalHitEt(hitsECAL[0].pt());
87  }
88 
89  //Run ECALClustering
91  {
92  //load simple clustering algorithm
94  math::PtEtaPhiELorentzVectorCollection clusters = clustering.clusterize(hitsECAL);
95  info.setEcalClusterShape(alg.clusterShape(clusters,jc->p4().Vect(),0,0.5) );
96  info.setNEcalHits(clusters.size());
97  }
98 
99  //Run CaloTower Isolation
101  {
102  info.setHcalIsolEt( alg.isolatedEt(hitsHCAL , jc->p4().Vect(), TowerIsolation_innerCone_,TowerIsolation_outerCone_) );
103  if(hitsHCAL.size()>0)
104  info.setSeedHcalHitEt(hitsHCAL[0].pt());
105  }
106 
107  //Store the info Class
108  edm::Ref<CaloJetCollection> jcRef(l2CaloJets,jc-jcStart);
109  l2InfoAssoc->insert(jcRef, info);
110  }
111 
112  } //end of if(*jetCrystalsObj)
113 
114  iEvent.put(l2InfoAssoc);
115 }
116 
117 
118 void
120 {
121 }
122 
123 
124 void
126 }
127 
128 
129 
132 {
135 
136  if(iEvent.getByToken(CaloTowers_,towers))
137  for(size_t i=0;i<towers->size();++i)
138  {
139  math::PtEtaPhiELorentzVector tower((*towers)[i].et(),(*towers)[i].eta(),(*towers)[i].phi(),(*towers)[i].energy());
140  if(ROOT::Math::VectorUtil::DeltaR(tower,jet.p4()) <associationRadius_)
141  {
142  if(tower.energy()>towerThreshold_)
143  towers2.push_back(tower);
144 
145  }
146 
147  }
148 
149  std::sort(towers2.begin(),towers2.end(),comparePt);
150 
151  return towers2;
152 }
153 
154 
157 {
158  //Init Geometry
160  iSetup.get<CaloGeometryRecord>().get(geometry);
161 
162  //Create ECAL Geometry
163  const CaloSubdetectorGeometry* EB = geometry->getSubdetectorGeometry(DetId::Ecal,EcalBarrel);
164  const CaloSubdetectorGeometry* EE = geometry->getSubdetectorGeometry(DetId::Ecal,EcalEndcap);
165 
166  //Handle To the ECAL
169 
170  //Create a container for the hits
172 
173  //Loop on the barrel hits
174  if(iEvent.getByToken( EBRecHits_, EBRecHits))
175  for(EBRecHitCollection::const_iterator hit = EBRecHits->begin();hit!=EBRecHits->end();++hit)
176  {
177  //get Detector Geometry
178  const CaloCellGeometry* this_cell = EB->getGeometry(hit->detid());
179  GlobalPoint posi = this_cell->getPosition();
180  double energy = hit->energy();
181  double eta = posi.eta();
182  double phi = posi.phi();
183  double theta = posi.theta();
184  if(theta > M_PI) theta = 2 * M_PI- theta;
185  double et = energy * sin(theta);
186  math::PtEtaPhiELorentzVector p(et, eta, phi, energy);
187  if(ROOT::Math::VectorUtil::DeltaR(p,jet.p4()) <associationRadius_)
188  if(p.energy()>crystalThresholdB_)
189  jetRecHits.push_back(p);
190  }
191 
192  if(iEvent.getByToken( EERecHits_, EERecHits))
193  for(EERecHitCollection::const_iterator hit = EERecHits->begin();hit!=EERecHits->end();++hit)
194  {
195  //get Detector Geometry
196  const CaloCellGeometry* this_cell = EE->getGeometry(hit->detid());
197  GlobalPoint posi = this_cell->getPosition();
198  double energy = hit->energy();
199  double eta = posi.eta();
200  double phi = posi.phi();
201  double theta = posi.theta();
202  if(theta > M_PI) theta = 2 * M_PI- theta;
203  double et = energy * sin(theta);
204  math::PtEtaPhiELorentzVector p(et, eta, phi, energy);
205  if(ROOT::Math::VectorUtil::DeltaR(p,jet.p4()) < associationRadius_)
206  if(p.energy()>crystalThresholdE_)
207  jetRecHits.push_back(p);
208  }
209 
210 
211  std::sort(jetRecHits.begin(),jetRecHits.end(),comparePt);
212 
213  return jetRecHits;
214 }
215 
216 
217 
math::PtEtaPhiELorentzVectorCollection clusterize(const math::PtEtaPhiELorentzVectorCollection &)
void setSeedHcalHitEt(double et)
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
static const TGPicture * info(bool iBackgroundIsBlack)
Jets made from CaloTowers.
Definition: CaloJet.h:29
void setEcalClusterShape(const std::vector< double > &shape)
virtual const LorentzVector & p4() const GCC11_FINAL
four-momentum Lorentz vector
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:446
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
std::vector< EcalRecHit >::const_iterator const_iterator
Geom::Theta< T > theta() const
edm::EDGetTokenT< CaloTowerCollection > CaloTowers_
L2TauNarrowConeIsolationProducer(const edm::ParameterSet &)
T eta() const
math::PtEtaPhiELorentzVectorCollection getHCALHits(const CaloJet &, const edm::Event &)
virtual const CaloCellGeometry * getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
Geom::Theta< T > theta() const
Definition: PV3DBase.h:75
void setSeedEcalHitEt(double et)
int iEvent
Definition: GenABIO.cc:230
double isolatedEt(const math::PtEtaPhiELorentzVectorCollection &, const math::XYZVector &, double innerCone, double outerCone) const
std::vector< PtEtaPhiELorentzVector > PtEtaPhiELorentzVectorCollection
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:113
edm::EDGetTokenT< EBRecHitCollection > EBRecHits_
void hitsHCAL(std::vector< DetId > &vdets, edm::Handle< T > &hits, std::vector< typename T::const_iterator > &hitlist, bool debug=false)
#define M_PI
PtEtaPhiELorentzVectorD PtEtaPhiELorentzVector
Lorentz vector with cartesian internal representation.
Definition: LorentzVector.h:27
math::PtEtaPhiELorentzVectorCollection getECALHits(const CaloJet &, const edm::Event &, const edm::EventSetup &iSetup)
const T & get() const
Definition: EventSetup.h:55
virtual void produce(edm::Event &, const edm::EventSetup &) override
T eta() const
Definition: PV3DBase.h:76
edm::EDGetTokenT< EERecHitCollection > EERecHits_
ESHandle< TrackerGeometry > geometry
std::vector< double > clusterShape(const math::PtEtaPhiELorentzVectorCollection &, const math::XYZVector &, double innerCone, double outerCone) const
const GlobalPoint & getPosition() const
Returns the position of reference for this cell.
edm::EDGetTokenT< reco::CaloJetCollection > l2CaloJets_
Definition: DDAxes.h:10