CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
L2TauIsolationProducer.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  crystalThreshold_(iConfig.getParameter<double>("crystalThreshold")),
13  towerThreshold_(iConfig.getParameter<double>("towerThreshold"))
14  {
15 
16  //ECAL Isolation
17  edm::ParameterSet ECALIsolParams = iConfig.getParameter<edm::ParameterSet>("ECALIsolation") ;
18 
19  ECALIsolation_innerCone_ = ECALIsolParams.getParameter<double>( "innerCone" );
20  ECALIsolation_outerCone_ = ECALIsolParams.getParameter<double>( "outerCone" );
21  ECALIsolation_run_ = ECALIsolParams.getParameter<bool>( "runAlgorithm" );
22 
23 
24  //ECAL Clustering
25  edm::ParameterSet ECALClusterParams = iConfig.getParameter<edm::ParameterSet>("ECALClustering") ;
26 
27  ECALClustering_run_ = ECALClusterParams.getParameter<bool>( "runAlgorithm" );
28  ECALClustering_clusterRadius_ = ECALClusterParams.getParameter<double>( "clusterRadius" );
29 
30 
31  //Tower Isolation
32  edm::ParameterSet TowerIsolParams = iConfig.getParameter<edm::ParameterSet>("TowerIsolation") ;
33  TowerIsolation_innerCone_ = TowerIsolParams.getParameter<double>( "innerCone" );
34  TowerIsolation_outerCone_ = TowerIsolParams.getParameter<double>( "outerCone" );
35  TowerIsolation_run_ = TowerIsolParams.getParameter<bool>( "runAlgorithm" );
36 
37 
38  //Add the products
39  produces<L2TauInfoAssociation>();
40 
41 }
42 
43 
45 {
46  //Destruction
47 
48 }
49 
50 
51 
52 void
54 {
55 
56 
57  edm::Handle<CaloJetCollection> l2CaloJets; //Handle to the input (L2TauCaloJets);
58  iEvent.getByToken(l2CaloJets_ ,l2CaloJets);//get the handle
59 
60  //Create the Association
61  std::auto_ptr<L2TauInfoAssociation> l2InfoAssoc( new L2TauInfoAssociation);
62 
63  //If the JetCrystalsAssociation exists -> RUN The Producer
64  if(l2CaloJets->size()>0)
65  {
66  CaloJetCollection::const_iterator jcStart = l2CaloJets->begin();
67 
68  //Loop on Jets
69  for(CaloJetCollection::const_iterator jc = jcStart ;jc!=l2CaloJets->end();++jc)
70  {
71 
72  //Create Algorithm Object
74 
75  //Create Info Object
77 
78  //get Hits
79  math::PtEtaPhiELorentzVectorCollection hitsECAL = getECALHits(*jc,iEvent,iSetup);
81 
82 
83  //Run ECALIsolation
85  {
86  info.setEcalIsolEt( alg.isolatedEt(hitsECAL , jc->p4().Vect(), ECALIsolation_innerCone_,ECALIsolation_outerCone_) );
87  if(hitsECAL.size()>0)
88  info.setSeedEcalHitEt(hitsECAL[0].pt());
89  }
90 
91  //Run ECALClustering
93  {
94  //load simple clustering algorithm
97  info.setEcalClusterShape(alg.clusterShape(clusters,jc->p4().Vect(),0,0.5) );
98  info.setNEcalHits(clusters.size());
99  }
100 
101  //Run CaloTower Isolation
103  {
104  info.setHcalIsolEt( alg.isolatedEt(hitsHCAL , jc->p4().Vect(), TowerIsolation_innerCone_,TowerIsolation_outerCone_) );
105  if(hitsHCAL.size()>0)
106  info.setSeedHcalHitEt(hitsHCAL[0].pt());
107  }
108 
109  //Store the info Class
110  edm::Ref<CaloJetCollection> jcRef(l2CaloJets,jc-jcStart);
111  l2InfoAssoc->insert(jcRef, info);
112  }
113 
114 
115  } //end of if(*jetCrystalsObj)
116 
117  iEvent.put(l2InfoAssoc);
118 }
119 
120 
121 void
123 {
124 }
125 
126 
127 void
129 }
130 
131 
132 
135 {
136 
137 
138  std::vector<CaloTowerPtr> towers = jet.getCaloConstituents();
139 
141 
142  for(size_t i=0;i<towers.size();++i)
143  if(towers[i]->energy()>towerThreshold_)
144  towers2.push_back(math::PtEtaPhiELorentzVector(towers[i]->et(),towers[i]->eta(),towers[i]->phi(),towers[i]->energy()));
145 
146  return towers2;
147 }
148 
149 
150 
151 
152 
155 {
156 
157  //Init Geometry
159  iSetup.get<CaloGeometryRecord>().get(geometry);
160 
161  //Create ECAL Geometry
162  const CaloSubdetectorGeometry* EB = geometry->getSubdetectorGeometry(DetId::Ecal,EcalBarrel);
163  const CaloSubdetectorGeometry* EE = geometry->getSubdetectorGeometry(DetId::Ecal,EcalEndcap);
164 
165  //Handle To the ECAL
168 
169  //Read From File
170 
171  iEvent.getByToken( EBRecHits_, EBRecHits );
172  iEvent.getByToken( EERecHits_, EERecHits );
173 
174 
175 
176  //Create a container for the hits
178 
179 
180  //Create the Machinery to put the highest et crystal at the begining
181  double ref_pt = 0.;//max et
182  int ref_id=0; //id of the max element
183  int count=0; //counter
184 
185  //Code Copied from JetCrystalsAssociator
186  const std::vector<CaloTowerPtr> myTowers=jet.getCaloConstituents();
187  for (unsigned int iTower = 0; iTower < myTowers.size(); iTower++)
188  {
189  CaloTowerPtr theTower = myTowers[iTower];
190  size_t numRecHits = theTower->constituentsSize();
191  // access CaloRecHits
192  for (size_t j = 0; j < numRecHits; j++) {
193  DetId RecHitDetID=theTower->constituent(j);
194  DetId::Detector DetNum=RecHitDetID.det();
195  if( DetNum == DetId::Ecal ){
196  int EcalNum = RecHitDetID.subdetId();
197  if( EcalNum == 1 ){
198  EBDetId EcalID = RecHitDetID;
199  EBRecHitCollection::const_iterator theRecHit=EBRecHits->find(EcalID);
200  if(theRecHit != EBRecHits->end()){
201  DetId id = theRecHit->detid();
202  const CaloCellGeometry* this_cell = EB->getGeometry(id);
203  if (this_cell) {
204  GlobalPoint posi = this_cell->getPosition();
205  double energy = theRecHit->energy();
206  double eta = posi.eta();
207  double phi = posi.phi();
208  double theta = posi.theta();
209  if(theta > M_PI) theta = 2 * M_PI- theta;
210  double et = energy * sin(theta);
211  //Apply Thresholds Here
212  math::PtEtaPhiELorentzVector p(et, eta, phi, energy);
213  if(p.pt()>crystalThreshold_)
214  {
215  if(p.pt()>ref_pt)
216  {
217  ref_id=count;
218  ref_pt = p.pt();
219  }
220  jetRecHits.push_back(p);
221  count++;
222  }
223 
224  }
225  }
226  } else if ( EcalNum == 2 ) {
227  EEDetId EcalID = RecHitDetID;
228  EERecHitCollection::const_iterator theRecHit=EERecHits->find(EcalID);
229  if(theRecHit != EBRecHits->end()){
230  DetId id = theRecHit->detid();
231  const CaloCellGeometry* this_cell = EE->getGeometry(id);
232  if (this_cell) {
233  GlobalPoint posi = this_cell->getPosition();
234  double energy = theRecHit->energy();
235  double eta = posi.eta();
236  double phi = posi.phi();
237  double theta = posi.theta();
238  if (theta > M_PI) theta = 2 * M_PI - theta;
239  double et = energy * sin(theta);
240  // std::cout <<"Et "<<et<<std::endl;
241  math::PtEtaPhiELorentzVector p(et, eta, phi, energy);
242  if(p.pt()>crystalThreshold_)
243  {
244  if(p.pt()>ref_pt)
245  {
246  ref_id=count;
247  ref_pt = p.pt();
248  }
249  jetRecHits.push_back(p);
250  count++;
251  }
252  }
253  }
254  }
255  }
256  }
257  }
258 
259  //bring it to the front
260  if(jetRecHits.size()>0)
261  std::swap(jetRecHits[ref_id],jetRecHits[0]);
262 
263  return jetRecHits;
264 }
265 
266 
267 
268 
math::PtEtaPhiELorentzVectorCollection clusterize(const math::PtEtaPhiELorentzVectorCollection &)
void setSeedHcalHitEt(double et)
T getParameter(std::string const &) const
edm::EDGetTokenT< EBRecHitCollection > EBRecHits_
int i
Definition: DBlmapReader.cc:9
math::PtEtaPhiELorentzVectorCollection getHCALHits(const reco::CaloJet &)
static const TGPicture * info(bool iBackgroundIsBlack)
Jets made from CaloTowers.
Definition: CaloJet.h:29
void setEcalClusterShape(const std::vector< double > &shape)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:449
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
T eta() const
virtual std::vector< CaloTowerPtr > getCaloConstituents() const
get all constituents
Definition: CaloJet.cc:93
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
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
int j
Definition: DBlmapReader.cc:9
void hitsHCAL(std::vector< DetId > &vdets, edm::Handle< T > &hits, std::vector< typename T::const_iterator > &hitlist, bool debug=false)
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
#define M_PI
Definition: DetId.h:18
edm::EDGetTokenT< reco::CaloJetCollection > l2CaloJets_
PtEtaPhiELorentzVectorD PtEtaPhiELorentzVector
Lorentz vector with cartesian internal representation.
Definition: LorentzVector.h:27
Detector
Definition: DetId.h:24
const T & get() const
Definition: EventSetup.h:55
T eta() const
Definition: PV3DBase.h:76
ESHandle< TrackerGeometry > geometry
std::vector< double > clusterShape(const math::PtEtaPhiELorentzVectorCollection &, const math::XYZVector &, double innerCone, double outerCone) const
edm::EDGetTokenT< EERecHitCollection > EERecHits_
virtual void produce(edm::Event &, const edm::EventSetup &) override
L2TauIsolationProducer(const edm::ParameterSet &)
Detector det() const
get the detector field from this detid
Definition: DetId.h:35
const GlobalPoint & getPosition() const
Returns the position of reference for this cell.
math::PtEtaPhiELorentzVectorCollection getECALHits(const reco::CaloJet &, const edm::Event &, const edm::EventSetup &iSetup)
std::vector< CaloJet > CaloJetCollection
collection of CaloJet objects
Definition: DDAxes.h:10