CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
JetCollectionForEleHT.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: JetCollectionForEleHT
4 // Class: JetCollectionForEleHT
5 //
13 //
14 // Original Author: Massimiliano Chiorboli,40 4-A01,+41227671535,
15 // Created: Mon Oct 4 11:57:35 CEST 2010
16 // $Id: JetCollectionForEleHT.cc,v 1.4 2011/03/03 14:20:14 gruen Exp $
17 //
18 //
19 
20 
21 // system include files
22 #include <memory>
23 
24 // user include files
27 
30 
33 
37 
41 
43 
45 
47 
49  hltElectronTag(iConfig.getParameter< edm::InputTag > ("HltElectronTag")),
50  sourceJetTag(iConfig.getParameter< edm::InputTag > ("SourceJetTag")),
51  minDeltaR_(iConfig.getParameter< double > ("minDeltaR"))
52 {
53  produces<reco::CaloJetCollection>();
54 }
55 
56 
57 
59 {
60 
61  // do anything here that needs to be done at desctruction time
62  // (e.g. close files, deallocate resources etc.)
63 
64 }
65 
66 
67 //
68 // member functions
69 //
70 
71 
72 // ------------ method called to produce the data ------------
73 // template <typename T>
74 void
76 {
77  using namespace edm;
78 
80  iEvent.getByLabel(hltElectronTag,PrevFilterOutput);
81 
82  //its easier on the if statement flow if I try everything at once, shouldnt add to timing
83  std::vector<edm::Ref<reco::RecoEcalCandidateCollection> > clusCands;
84  PrevFilterOutput->getObjects(trigger::TriggerCluster,clusCands);
85  std::vector<edm::Ref<reco::ElectronCollection> > eleCands;
86  PrevFilterOutput->getObjects(trigger::TriggerElectron,eleCands);
87 
88  //prepare the collection of 3-D vector for electron momenta
89  std::vector<TVector3> ElePs;
90 
91  if(!clusCands.empty()){ //try trigger cluster
92  for(size_t candNr=0;candNr<clusCands.size();candNr++){
93  TVector3 positionVector(
94  clusCands[candNr]->superCluster()->position().x(),
95  clusCands[candNr]->superCluster()->position().y(),
96  clusCands[candNr]->superCluster()->position().z());
97  ElePs.push_back(positionVector);
98  }
99  }else if(!eleCands.empty()){ // try trigger electrons
100  for(size_t candNr=0;candNr<eleCands.size();candNr++){
101  TVector3 positionVector(
102  eleCands[candNr]->superCluster()->position().x(),
103  eleCands[candNr]->superCluster()->position().y(),
104  eleCands[candNr]->superCluster()->position().z());
105  ElePs.push_back(positionVector);
106  }
107  }
108 
109  edm::Handle<reco::CaloJetCollection> theCaloJetCollectionHandle;
110  iEvent.getByLabel(sourceJetTag, theCaloJetCollectionHandle);
111  const reco::CaloJetCollection* theCaloJetCollection = theCaloJetCollectionHandle.product();
112 
113  std::auto_ptr< reco::CaloJetCollection > theFilteredCaloJetCollection(new reco::CaloJetCollection);
114 
115  bool isOverlapping;
116 
117  for(unsigned int j=0; j<theCaloJetCollection->size(); j++) {
118 
119  isOverlapping = false;
120  for(unsigned int i=0; i<ElePs.size(); i++) {
121 
122  TVector3 JetP((*theCaloJetCollection)[j].px(), (*theCaloJetCollection)[j].py(), (*theCaloJetCollection)[j].pz());
123  double DR = ElePs[i].DeltaR(JetP);
124 
125  if(DR<minDeltaR_) {
126  isOverlapping = true;
127  break;
128  }
129  }
130 
131  if(!isOverlapping) theFilteredCaloJetCollection->push_back((*theCaloJetCollection)[j]);
132  }
133 
134  //do the filtering
135 
136  iEvent.put(theFilteredCaloJetCollection);
137 
138  return;
139 
140 }
141 
142 // ------------ method called once each job just before starting event loop ------------
143 void
145 {
146 }
147 
148 // ------------ method called once each job just after ending the event loop ------------
149 void
151 }
152 
153 //define this as a plug-in
155 
int i
Definition: DBlmapReader.cc:9
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
JetCollectionForEleHT(const edm::ParameterSet &)
static int position[TOTALCHAMBERS][3]
Definition: ReadPGInfo.cc:509
int iEvent
Definition: GenABIO.cc:243
Definition: DDAxes.h:10
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:84
int j
Definition: DBlmapReader.cc:9
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:359
virtual void produce(edm::Event &, const edm::EventSetup &)
std::vector< CaloJet > CaloJetCollection
collection of CaloJet objects