CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HLTTauRefProducer.cc
Go to the documentation of this file.
2 #include "TLorentzVector.h"
3 // TAU includes
8 // ELECTRON includes
17 // MUON includes
20 #include "TLorentzVector.h"
22 //CaloTower includes
26 #include "Math/GenVector/VectorUtil.h"
27 
28 
29 using namespace edm;
30 using namespace reco;
31 using namespace std;
32 
34 {
35 
36 
37  //One Parameter Set per Collection
38 
39  ParameterSet pfTau = iConfig.getUntrackedParameter<edm::ParameterSet>("PFTaus");
40  PFTaus_ = pfTau.getUntrackedParameter<InputTag>("PFTauProducer");
41  PFTauDis_ = pfTau.getUntrackedParameter<std::vector<InputTag> >("PFTauDiscriminators");
42  doPFTaus_ = pfTau.getUntrackedParameter<bool>("doPFTaus",false);
43  ptMinPFTau_= pfTau.getUntrackedParameter<double>("ptMin",15.);
44 
46  Electrons_ = electrons.getUntrackedParameter<InputTag>("ElectronCollection");
47  doElectrons_ = electrons.getUntrackedParameter<bool>("doElectrons",false);
48  e_idAssocProd_ = electrons.getUntrackedParameter<InputTag>("IdCollection");
49  e_ctfTrackCollection_= electrons.getUntrackedParameter<InputTag>("TrackCollection");
50  ptMinElectron_= electrons.getUntrackedParameter<double>("ptMin",15.);
51  e_doID_ = electrons.getUntrackedParameter<bool>("doID",false);
52  e_doTrackIso_ = electrons.getUntrackedParameter<bool>("doTrackIso",false);
53  e_trackMinPt_= electrons.getUntrackedParameter<double>("ptMinTrack",1.5);
54  e_lipCut_= electrons.getUntrackedParameter<double>("lipMinTrack",1.5);
55  e_minIsoDR_= electrons.getUntrackedParameter<double>("InnerConeDR",0.02);
56  e_maxIsoDR_= electrons.getUntrackedParameter<double>("OuterConeDR",0.6);
57  e_isoMaxSumPt_= electrons.getUntrackedParameter<double>("MaxIsoVar",0.02);
58 
60  Muons_ = muons.getUntrackedParameter<InputTag>("MuonCollection");
61  doMuons_ = muons.getUntrackedParameter<bool>("doMuons",false);
62  ptMinMuon_= muons.getUntrackedParameter<double>("ptMin",15.);
63 
65  Jets_ = jets.getUntrackedParameter<InputTag>("JetCollection");
66  doJets_ = jets.getUntrackedParameter<bool>("doJets");
67  ptMinJet_= jets.getUntrackedParameter<double>("etMin");
68 
69  ParameterSet towers = iConfig.getUntrackedParameter<edm::ParameterSet>("Towers");
70  Towers_ = towers.getUntrackedParameter<InputTag>("TowerCollection");
71  doTowers_ = towers.getUntrackedParameter<bool>("doTowers");
72  ptMinTower_= towers.getUntrackedParameter<double>("etMin");
73  towerIsol_= towers.getUntrackedParameter<double>("towerIsolation");
74 
76  Photons_ = photons.getUntrackedParameter<InputTag>("PhotonCollection");
77  doPhotons_ = photons.getUntrackedParameter<bool>("doPhotons");
78  ptMinPhoton_= photons.getUntrackedParameter<double>("etMin");
79  photonEcalIso_= photons.getUntrackedParameter<double>("ECALIso");
80 
81 
82  etaMax = iConfig.getUntrackedParameter<double>("EtaMax",2.5);
83 
84 
85  //recoCollections
86  produces<LorentzVectorCollection>("PFTaus");
87  produces<LorentzVectorCollection>("Electrons");
88  produces<LorentzVectorCollection>("Muons");
89  produces<LorentzVectorCollection>("Jets");
90  produces<LorentzVectorCollection>("Photons");
91  produces<LorentzVectorCollection>("Towers");
92 
93 }
94 
96 
98 {
99  if(doPFTaus_)
100  doPFTaus(iEvent,iES);
101  if(doElectrons_)
102  doElectrons(iEvent,iES);
103  if(doMuons_)
104  doMuons(iEvent,iES);
105  if(doJets_)
106  doJets(iEvent,iES);
107  if(doPhotons_)
108  doPhotons(iEvent,iES);
109  if(doTowers_)
110  doTowers(iEvent,iES);
111 
112 }
113 
114 void
116 {
117  auto_ptr<LorentzVectorCollection> product_PFTaus(new LorentzVectorCollection);
118  //Retrieve the collection
120  if(iEvent.getByLabel(PFTaus_,pftaus))
121  {
122  for(unsigned int i=0;i<pftaus->size();++i)
123  if((*pftaus)[i].pt()>ptMinPFTau_&&fabs((*pftaus)[i].eta())<etaMax)
124  {
125  reco::PFTauRef thePFTau(pftaus,i);
126  for(unsigned int j=0;j<PFTauDis_.size();++j)
127  {
129  if(iEvent.getByLabel(PFTauDis_[j],pftaudis))
130  {
131  if((*pftaudis)[thePFTau]>0.5)
132  {
133  LorentzVector vec((*pftaus)[i].px(),(*pftaus)[i].py(),(*pftaus)[i].pz(),(*pftaus)[i].energy());
134  product_PFTaus->push_back(vec);
135  }
136  }
137  }
138  }
139  }
140 
141  iEvent.put(product_PFTaus,"PFTaus");
142 
143 }
144 
145 
146 void
148 {
149  auto_ptr<LorentzVectorCollection> product_Electrons(new LorentzVectorCollection);
150  //Retrieve the collections
151 
153  if(e_doID_){//UGLY HACK UNTIL GET ELETRON ID WORKING IN 210
154 
155  iEvent.getByLabel(e_idAssocProd_,pEleID);
156 
157  if (!pEleID.isValid()){
158  edm::LogInfo("")<< "Error! Can't get electronIDAssocProducer by label. ";
159  e_doID_ = false;
160  }
161  }
163  iEvent.getByLabel(e_ctfTrackCollection_, pCtfTracks);
164  if (!pCtfTracks.isValid()) {
165  edm::LogInfo("")<< "Error! Can't get " << e_ctfTrackCollection_.label() << " by label. ";
166  iEvent.put(product_Electrons,"Electrons");
167  return;
168  }
169  const reco::TrackCollection * ctfTracks = pCtfTracks.product();
171  if(iEvent.getByLabel(Electrons_,electrons))
172  for(size_t i=0;i<electrons->size();++i)
173  {
174  edm::Ref<reco::GsfElectronCollection> electronRef(electrons,i);
175  bool idDec=false;
176  if(e_doID_){
178  tagIDAssocItr = pEleID->find(electronRef);
179  const reco::ElectronIDRef& id_tag = tagIDAssocItr->val;
180  idDec=id_tag->cutBasedDecision();
181  }else idDec=true;
182  if((*electrons)[i].pt()>ptMinElectron_&&fabs((*electrons)[i].eta())<etaMax&&idDec)
183  {
184  if(e_doTrackIso_){
185  reco::TrackCollection::const_iterator tr = ctfTracks->begin();
186  double sum_of_pt_ele=0;
187  for(;tr != ctfTracks->end();++tr)
188  {
189  double lip = (*electrons)[i].gsfTrack()->dz() - tr->dz();
190  if(tr->pt() > e_trackMinPt_ && fabs(lip) < e_lipCut_){
191  double dphi=fabs(tr->phi()-(*electrons)[i].trackMomentumAtVtx().phi());
192  if(dphi>acos(-1.))dphi=2*acos(-1.)-dphi;
193  double deta=fabs(tr->eta()-(*electrons)[i].trackMomentumAtVtx().eta());
194  double dr_ctf_ele = sqrt(deta*deta+dphi*dphi);
195  if((dr_ctf_ele>e_minIsoDR_) && (dr_ctf_ele<e_maxIsoDR_)){
196  double cft_pt_2 = (tr->pt())*(tr->pt());
197  sum_of_pt_ele += cft_pt_2;
198  }
199  }
200  }
201  double isolation_value_ele = sum_of_pt_ele/((*electrons)[i].trackMomentumAtVtx().Rho()*(*electrons)[i].trackMomentumAtVtx().Rho());
202  if(isolation_value_ele<e_isoMaxSumPt_){
203  LorentzVector vec((*electrons)[i].px(),(*electrons)[i].py(),(*electrons)[i].pz(),(*electrons)[i].energy());
204  product_Electrons->push_back(vec);
205  }
206 
207  }
208  else{
209  LorentzVector vec((*electrons)[i].px(),(*electrons)[i].py(),(*electrons)[i].pz(),(*electrons)[i].energy());
210  product_Electrons->push_back(vec);
211  }
212  }
213  }
214 
215  iEvent.put(product_Electrons,"Electrons");
216 }
217 
218 void
220 {
221  auto_ptr<LorentzVectorCollection> product_Muons(new LorentzVectorCollection);
222  //Retrieve the collection
224  if(iEvent.getByLabel(Muons_,muons))
225 
226  for(size_t i = 0 ;i<muons->size();++i)
227  {
228 
229  if((*muons)[i].pt()>ptMinMuon_&&fabs((*muons)[i].eta())<etaMax)
230  {
231  LorentzVector vec((*muons)[i].px(),(*muons)[i].py(),(*muons)[i].pz(),(*muons)[i].energy());
232  product_Muons->push_back(vec);
233  }
234  }
235 
236 
237  iEvent.put(product_Muons,"Muons");
238 
239 }
240 
241 
242 void
244 {
245  auto_ptr<LorentzVectorCollection> product_Jets(new LorentzVectorCollection);
246  //Retrieve the collection
248  if(iEvent.getByLabel(Jets_,jets))
249  for(size_t i = 0 ;i<jets->size();++i)
250  {
251  if((*jets)[i].et()>ptMinJet_&&fabs((*jets)[i].eta())<etaMax)
252  {
253  LorentzVector vec((*jets)[i].px(),(*jets)[i].py(),(*jets)[i].pz(),(*jets)[i].energy());
254  product_Jets->push_back(vec);
255  }
256  }
257  iEvent.put(product_Jets,"Jets");
258 }
259 
260 void
262 {
263  auto_ptr<LorentzVectorCollection> product_Towers(new LorentzVectorCollection);
264  //Retrieve the collection
266  if(iEvent.getByLabel(Towers_,towers))
267  for(size_t i = 0 ;i<towers->size();++i)
268  {
269  if((*towers)[i].pt()>ptMinTower_&&fabs((*towers)[i].eta())<etaMax)
270  {
271  //calculate isolation
272  double isolET=0;
273  for(unsigned int j=0;j<towers->size();++j)
274  {
275  if(ROOT::Math::VectorUtil::DeltaR((*towers)[i].p4(),(*towers)[j].p4())<0.5)
276  isolET+=(*towers)[j].pt();
277  }
278  isolET-=(*towers)[i].pt();
279  if(isolET<towerIsol_)
280  {
281  LorentzVector vec((*towers)[i].px(),(*towers)[i].py(),(*towers)[i].pz(),(*towers)[i].energy());
282  product_Towers->push_back(vec);
283  }
284  }
285  }
286  iEvent.put(product_Towers,"Towers");
287 }
288 
289 
290 void
292 {
293  auto_ptr<LorentzVectorCollection> product_Gammas(new LorentzVectorCollection);
294  //Retrieve the collection
296  if(iEvent.getByLabel(Photons_,photons))
297  for(size_t i = 0 ;i<photons->size();++i)
298  if((*photons)[i].ecalRecHitSumEtConeDR04()<photonEcalIso_)
299  {
300  if((*photons)[i].et()>ptMinPhoton_&&fabs((*photons)[i].eta())<etaMax)
301  {
302  LorentzVector vec((*photons)[i].px(),(*photons)[i].py(),(*photons)[i].pz(),(*photons)[i].energy());
303  product_Gammas->push_back(vec);
304  }
305  }
306  iEvent.put(product_Gammas,"Photons");
307 }
308 
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
void doPFTaus(edm::Event &, const edm::EventSetup &)
virtual void produce(edm::Event &, const edm::EventSetup &)
const std::string id_tag("id")
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:10
HLTTauRefProducer(const edm::ParameterSet &)
T eta() const
void doTowers(edm::Event &, const edm::EventSetup &)
void doJets(edm::Event &, const edm::EventSetup &)
math::XYZTLorentzVectorD LorentzVector
int iEvent
Definition: GenABIO.cc:243
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
T sqrt(T t)
Definition: SSEVec.h:46
double p4[4]
Definition: TauolaWrapper.h:92
vector< PseudoJet > jets
int j
Definition: DBlmapReader.cc:9
bool isValid() const
Definition: HandleBase.h:76
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
void doMuons(edm::Event &, const edm::EventSetup &)
std::vector< LorentzVector > LorentzVectorCollection
T const * product() const
Definition: Handle.h:74
void doPhotons(edm::Event &, const edm::EventSetup &)
tuple muons
Definition: patZpeak.py:38
void doElectrons(edm::Event &, const edm::EventSetup &)