test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
L2TauModularIsolationProducer.cc
Go to the documentation of this file.
4 
5 
6 using namespace reco;
7 using namespace edm;
8 
9 
11  l2CaloJets_(consumes<CaloJetCollection>(iConfig.getParameter<edm::InputTag>("L2TauJetCollection"))),
12  EBRecHits_(consumes<EBRecHitCollection>(iConfig.getParameter<edm::InputTag>("EBRecHits"))),
13  EERecHits_(consumes<EERecHitCollection>(iConfig.getParameter<edm::InputTag>("EERecHits"))),
14  caloTowers_(consumes<CaloTowerCollection>(iConfig.getParameter<edm::InputTag>("CaloTowers"))),
15  pfClustersECAL_(consumes<PFClusterCollection>(iConfig.getParameter<edm::InputTag>("pfClustersECAL"))),
16  pfClustersHCAL_(consumes<PFClusterCollection>(iConfig.getParameter<edm::InputTag>("pfClustersHCAL"))),
17  ecalIsolationAlg_(iConfig.getParameter<std::string>("ecalIsolationAlgorithm")),
18  hcalIsolationAlg_(iConfig.getParameter<std::string>("hcalIsolationAlgorithm")),
19  ecalClusteringAlg_(iConfig.getParameter<std::string>("ecalClusteringAlgorithm")),
20  hcalClusteringAlg_(iConfig.getParameter<std::string>("hcalClusteringAlgorithm")),
21  associationRadius_(iConfig.getParameter<double>("associationRadius")),
22  simpleClusterRadiusECAL_(iConfig.getParameter<double>("simpleClusterRadiusEcal")),
23  simpleClusterRadiusHCAL_(iConfig.getParameter<double>("simpleClusterRadiusHcal")),
24  innerConeECAL_(iConfig.getParameter<double>("innerConeECAL")),
25  outerConeECAL_(iConfig.getParameter<double>("outerConeECAL")),
26  innerConeHCAL_(iConfig.getParameter<double>("innerConeHCAL")),
27  outerConeHCAL_(iConfig.getParameter<double>("outerConeHCAL")),
28  crystalThresholdE_(iConfig.getParameter<double>("crystalThresholdEE")),
29  crystalThresholdB_(iConfig.getParameter<double>("crystalThresholdEB")),
30  towerThreshold_(iConfig.getParameter<double>("towerThreshold"))
31 
32  {
33 
34  //Add the products
35  produces<L2TauInfoAssociation>();
36 
37 }
38 
39 
41 {
42  //Destruction
43 
44 }
45 
46 
47 
48 void
50 {
51  edm::Handle<CaloJetCollection> l2CaloJets; //Handle to the input (L2TauCaloJets);
52  iEvent.getByToken(l2CaloJets_ ,l2CaloJets);//get the handle
53 
54  //Create the Association
55  std::auto_ptr<L2TauInfoAssociation> l2InfoAssoc( new L2TauInfoAssociation);
56 
57  //If the JetCrystalsAssociation exists -> RUN The Producer
58  if(l2CaloJets->size()>0)
59  {
60  CaloJetCollection::const_iterator jcStart = l2CaloJets->begin();
61  //Loop on Jets
62  for(CaloJetCollection::const_iterator jc = jcStart ;jc!=l2CaloJets->end();++jc)
63  {
64  //Create Algorithm Object
66  //Create Info Object
68 
69  //Define objects to be loaded from file:
74 
75  if(ecalIsolationAlg_=="recHits" || ecalClusteringAlg_=="recHits" || ecalIsolationAlg_ =="simpleClusters" ||ecalClusteringAlg_ =="simpleClusters")
76  hitsECAL =getECALHits(*jc,iEvent,iSetup);
77 
78  if(hcalIsolationAlg_=="recHits" || hcalClusteringAlg_=="recHits" || hcalIsolationAlg_ =="simpleClusters" ||hcalClusteringAlg_ =="simpleClusters")
79  hitsHCAL =getHCALHits(*jc,iEvent);
80 
81  if(ecalIsolationAlg_=="particleFlow" || ecalClusteringAlg_=="particleFlow")
82  pfClustersECAL =getPFClusters(*jc,iEvent,pfClustersECAL_);
83 
84  if(hcalIsolationAlg_=="particleFlow" || hcalClusteringAlg_=="particleFlow")
85  pfClustersHCAL =getPFClusters(*jc,iEvent,pfClustersHCAL_);
86 
87 
88 
89  //Do ECAL Isolation
90 
91  if(ecalIsolationAlg_ == "recHits")
92  {
93  //Use Rechits
94  info.setEcalIsolEt( alg.isolatedEt(hitsECAL , jc->p4().Vect(), innerConeECAL_,outerConeECAL_) );
95  }
96  else if(ecalIsolationAlg_ == "simpleClusters")
97  {
98  //create the simple clusters
100  math::PtEtaPhiELorentzVectorCollection clusters = clustering.clusterize(hitsECAL);
101  info.setEcalIsolEt( alg.isolatedEt(clusters , jc->p4().Vect(), innerConeECAL_,outerConeECAL_) );
102 
103  }
104  else if(ecalIsolationAlg_ == "particleFlow")
105  {
106  //Use ParticleFlow
107  info.setEcalIsolEt( alg.isolatedEt(pfClustersECAL , jc->p4().Vect(), innerConeECAL_,outerConeECAL_) );
108  }
109 
110  //Do ECAL Clustering
111 
112  if(ecalClusteringAlg_ == "recHits")
113  {
114  //Use Rechits
115  info.setEcalClusterShape(alg.clusterShape(hitsECAL,jc->p4().Vect(),0.,outerConeECAL_) );
116  info.setNEcalHits( alg.nClustersAnnulus(hitsECAL , jc->p4().Vect(), innerConeECAL_,outerConeECAL_));
117  if(hitsECAL.size()>0)
118  info.setSeedEcalHitEt(hitsECAL[0].pt());
119 
120  }
121  else if(ecalClusteringAlg_ == "simpleClusters")
122  {
123  //create the simple clusters
125  math::PtEtaPhiELorentzVectorCollection clusters = clustering.clusterize(hitsECAL);
126  info.setEcalClusterShape(alg.clusterShape(clusters,jc->p4().Vect(),0.,outerConeECAL_) );
127  info.setNEcalHits( alg.nClustersAnnulus(clusters, jc->p4().Vect(), innerConeECAL_,outerConeECAL_));
128 
129  if(clusters.size()>0)
130  info.setSeedEcalHitEt(clusters[0].pt());
131  }
132  else if(ecalClusteringAlg_ == "particleFlow")
133  {
134  //Use ParticleFlow
135  info.setEcalClusterShape(alg.clusterShape(pfClustersECAL,jc->p4().Vect(),0.,outerConeECAL_) );
136  info.setNEcalHits( alg.nClustersAnnulus(pfClustersECAL, jc->p4().Vect(), innerConeECAL_,outerConeECAL_));
137  if(pfClustersECAL.size()>0)
138  info.setSeedEcalHitEt(pfClustersECAL[0].pt());
139  }
140 
141 
142  //Do HCAL Isolation
143 
144  if(hcalIsolationAlg_ == "recHits")
145  {
146  //Use Rechits
147  info.setHcalIsolEt( alg.isolatedEt(hitsHCAL , jc->p4().Vect(), innerConeHCAL_,outerConeHCAL_) );
148  }
149  else if(hcalIsolationAlg_ == "simpleClusters")
150  {
151  //create the simple clusters
153  math::PtEtaPhiELorentzVectorCollection clusters = clustering.clusterize(hitsHCAL);
154  info.setHcalIsolEt( alg.isolatedEt(clusters , jc->p4().Vect(), innerConeHCAL_,outerConeHCAL_) );
155 
156  }
157  else if(hcalIsolationAlg_ == "particleFlow")
158  {
159  //Use ParticleFlow
160  info.setHcalIsolEt( alg.isolatedEt(pfClustersHCAL , jc->p4().Vect(), innerConeHCAL_,outerConeHCAL_) );
161  }
162 
163 
164 
165  //Do HCAL Clustering
166 
167  if(hcalClusteringAlg_ == "recHits")
168  {
169  //Use Rechits
170  info.setHcalClusterShape(alg.clusterShape(hitsHCAL,jc->p4().Vect(),0.,outerConeHCAL_) );
171  info.setNHcalHits( alg.nClustersAnnulus(hitsHCAL, jc->p4().Vect(), innerConeHCAL_,outerConeHCAL_));
172  if(hitsHCAL.size()>0)
173  info.setSeedHcalHitEt(hitsHCAL[0].pt());
174  }
175  else if(hcalClusteringAlg_ == "simpleClusters")
176  {
177  //create the simple clusters
179  math::PtEtaPhiELorentzVectorCollection clusters = clustering.clusterize(hitsHCAL);
180  info.setHcalClusterShape(alg.clusterShape(clusters,jc->p4().Vect(),0.,outerConeHCAL_) );
181  info.setNHcalHits( alg.nClustersAnnulus(clusters, jc->p4().Vect(), innerConeHCAL_,outerConeHCAL_));
182  if(clusters.size()>0)
183  info.setSeedHcalHitEt(clusters[0].pt());
184  }
185  else if(hcalClusteringAlg_ == "particleFlow")
186  {
187  //Use ParticleFlow
188  info.setHcalClusterShape(alg.clusterShape(pfClustersHCAL,jc->p4().Vect(),0.,outerConeHCAL_) );
189  info.setNHcalHits( alg.nClustersAnnulus(pfClustersHCAL, jc->p4().Vect(), innerConeHCAL_,outerConeHCAL_));
190  if(pfClustersHCAL.size()>0)
191  info.setSeedHcalHitEt(pfClustersHCAL[0].pt());
192  }
193 
194  //Store the info Class
195  edm::Ref<CaloJetCollection> jcRef(l2CaloJets,jc-jcStart);
196  l2InfoAssoc->insert(jcRef, info);
197  }
198 
199  } //end of if(*jetCrystalsObj)
200 
201  iEvent.put(l2InfoAssoc);
202 }
203 
204 
205 void
207 {
208 }
209 
210 
211 void
213 }
214 
215 
216 
217 
220 {
222 
224 
225  if(iEvent.getByToken(caloTowers_,towers))
226  if(towers->size()>0)
227  for(size_t i=0;i<towers->size();++i)
228  {
229  math::PtEtaPhiELorentzVector tower((*towers)[i].et(),(*towers)[i].eta(),(*towers)[i].phi(),(*towers)[i].energy());
230  if(ROOT::Math::VectorUtil::DeltaR(tower,jet.p4()) <associationRadius_)
231  {
232  if(tower.pt()>towerThreshold_)
233  towers2.push_back(tower);
234  }
235  }
236 
237  if(towers2.size()>0)
238  std::sort(towers2.begin(),towers2.end(),comparePt);
239  return towers2;
240 }
241 
242 
245 {
246  //Init Geometry
248  iSetup.get<CaloGeometryRecord>().get(geometry);
249 
250  //Create ECAL Geometry
251  const CaloSubdetectorGeometry* EB = geometry->getSubdetectorGeometry(DetId::Ecal,EcalBarrel);
252  const CaloSubdetectorGeometry* EE = geometry->getSubdetectorGeometry(DetId::Ecal,EcalEndcap);
253 
254  //Handle To the ECAL
257 
258  //Create a container for the hits
260 
261  //Loop on the barrel hits
262  if(iEvent.getByToken(EBRecHits_, EBRecHits))
263  for(EBRecHitCollection::const_iterator hit = EBRecHits->begin();hit!=EBRecHits->end();++hit)
264  {
265  //get Detector Geometry
266  const CaloCellGeometry* this_cell = EB->getGeometry(hit->detid());
267  GlobalPoint posi = this_cell->getPosition();
268  double energy = hit->energy();
269  double eta = posi.eta();
270  double phi = posi.phi();
271  double theta = posi.theta();
272  if(theta > M_PI) theta = 2 * M_PI- theta;
273  double et = energy * sin(theta);
274  math::PtEtaPhiELorentzVector p(et, eta, phi, energy);
275  if(ROOT::Math::VectorUtil::DeltaR(p,jet.p4()) <associationRadius_)
276  if(p.pt()>crystalThresholdB_)
277  jetRecHits.push_back(p);
278  }
279 
280  if(iEvent.getByToken(EERecHits_, EERecHits))
281  for(EERecHitCollection::const_iterator hit = EERecHits->begin();hit!=EERecHits->end();++hit)
282  {
283  //get Detector Geometry
284  const CaloCellGeometry* this_cell = EE->getGeometry(hit->detid());
285  GlobalPoint posi = this_cell->getPosition();
286  double energy = hit->energy();
287  double eta = posi.eta();
288  double phi = posi.phi();
289  double theta = posi.theta();
290  if(theta > M_PI) theta = 2 * M_PI- theta;
291  double et = energy * sin(theta);
292  math::PtEtaPhiELorentzVector p(et, eta, phi, energy);
293  if(ROOT::Math::VectorUtil::DeltaR(p,jet.p4()) < associationRadius_)
294  if(p.pt()>crystalThresholdE_)
295  jetRecHits.push_back(p);
296  }
297 
298  if(jetRecHits.size()>0)
299  std::sort(jetRecHits.begin(),jetRecHits.end(),comparePt);
300 
301  return jetRecHits;
302 }
303 
304 
305 
308 {
311 
312  //get Clusters near the jet
313  if(iEvent.getByToken(input,clusters))
314  if(clusters->size()>0)
315  for(PFClusterCollection::const_iterator c = clusters->begin();c!=clusters->end();++c)
316  {
317  double energy = c->energy();
318  double eta = c->eta();
319  double phi = c->phi();
320  double theta = c->position().theta();
321  if(theta > M_PI) theta = 2 * M_PI- theta;
322  double et = energy * sin(theta);
323  math::PtEtaPhiELorentzVector p(et, eta, phi, energy);
324 
325  if(ROOT::Math::VectorUtil::DeltaR(p,jet.p4()) < associationRadius_)
326  clusters2.push_back(p);
327  }
328 
329  if(clusters2.size()>0)
330  std::sort(clusters2.begin(),clusters2.end(),comparePt);
331  return clusters2;
332 }
333 
math::PtEtaPhiELorentzVectorCollection clusterize(const math::PtEtaPhiELorentzVectorCollection &)
void setSeedHcalHitEt(double et)
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)
edm::EDGetTokenT< reco::PFClusterCollection > pfClustersECAL_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
virtual void produce(edm::Event &, const edm::EventSetup &) override
math::PtEtaPhiELorentzVectorCollection getPFClusters(const reco::CaloJet &, const edm::Event &, const edm::EDGetTokenT< reco::PFClusterCollection > &)
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
void setHcalClusterShape(const std::vector< double > &shape)
edm::EDGetTokenT< reco::CaloJetCollection > l2CaloJets_
T eta() const
virtual const CaloCellGeometry * getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
static std::string const input
Definition: EdmProvDump.cc:44
Geom::Theta< T > theta() const
Definition: PV3DBase.h:75
math::PtEtaPhiELorentzVectorCollection getECALHits(const reco::CaloJet &, const edm::Event &, const edm::EventSetup &iSetup)
void setSeedEcalHitEt(double et)
int iEvent
Definition: GenABIO.cc:230
double isolatedEt(const math::PtEtaPhiELorentzVectorCollection &, const math::XYZVector &, double innerCone, double outerCone) const
edm::EDGetTokenT< CaloTowerCollection > caloTowers_
std::vector< PtEtaPhiELorentzVector > PtEtaPhiELorentzVectorCollection
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
math::PtEtaPhiELorentzVectorCollection getHCALHits(const reco::CaloJet &, const edm::Event &)
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
const T & get() const
Definition: EventSetup.h:55
T eta() const
Definition: PV3DBase.h:76
ESHandle< TrackerGeometry > geometry
int nClustersAnnulus(const math::PtEtaPhiELorentzVectorCollection &, const math::XYZVector &, double innerCone, double outerCone) const
std::vector< double > clusterShape(const math::PtEtaPhiELorentzVectorCollection &, const math::XYZVector &, double innerCone, double outerCone) const
edm::EDGetTokenT< EERecHitCollection > EERecHits_
L2TauModularIsolationProducer(const edm::ParameterSet &)
edm::EDGetTokenT< EBRecHitCollection > EBRecHits_
std::vector< PFCluster > PFClusterCollection
collection of PFCluster objects
Definition: PFClusterFwd.h:9
edm::EDGetTokenT< reco::PFClusterCollection > pfClustersHCAL_
const GlobalPoint & getPosition() const
Returns the position of reference for this cell.
virtual const LorentzVector & p4() const
four-momentum Lorentz vector
std::vector< CaloJet > CaloJetCollection
collection of CaloJet objects
Definition: DDAxes.h:10