CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
aod2patFilterZee.cc
Go to the documentation of this file.
1 #ifndef aod2patFilterZee_H
2 #define aod2patFilterZee_H
3 
4 /******************************************************************************
5  *
6  * Implementation Notes:
7  *
8  * this is a filter that creates pat::Electrons without the need of
9  * running the PAT sequence
10  *
11  * it is meant to be an interface of Wenu and Zee CandidateFilters
12  * for the October 2009 exercise
13  * it does make sense to implement the trigger requirement here
14  * but it will not be implemented in order to keep compatibolity with the
15  * old code
16  *
17  *
18  * contact:
19  * Nikolaos.Rompotis@Cern.ch
20  *
21  * Nikolaos Rompotis
22  * Imperial College London
23  *
24  * 21 Sept 2009
25  *
26  *****************************************************************************/
27 
28 
29 
30 // system include files
31 #include <memory>
32 
33 // user include files
36 
39 
41 //
42 #include <vector>
43 #include <iostream>
51 //
52 #include "TString.h"
53 #include "TMath.h"
55 
56 
58  public:
59  explicit aod2patFilterZee(const edm::ParameterSet&);
61 
62  private:
63  virtual void beginJob() override;
64  virtual bool filter(edm::Event&, const edm::EventSetup&) override;
65  virtual void endJob() override ;
66  //bool isInFiducial(double eta);
67 
68  // ----------member data ---------------------------
69  //double ETCut_;
70  //double METCut_;
71  //double ETCut2ndEle_;
72  //edm::InputTag triggerCollectionTag_;
73  //edm::InputTag triggerEventTag_;
74  //std::string hltpath_;
75  //edm::InputTag hltpathFilter_;
80 
81  //double BarrelMaxEta_;
82  //double EndCapMaxEta_;
83  //double EndCapMinEta_;
84  //bool electronMatched2HLT_;
85  //double electronMatched2HLT_DR_;
86  //bool vetoSecondElectronEvents_;
87 };
88 #endif
89 
90 
92 {
93 
94  electronCollectionTag_=iConfig.getUntrackedParameter<edm::InputTag>("electronCollectionTag");
95  electronCollectionToken_=consumes<reco::GsfElectronCollection>(electronCollectionTag_);
96  metCollectionTag_=iConfig.getUntrackedParameter<edm::InputTag>("metCollectionTag");
97  metCollectionToken_=consumes<reco::CaloMETCollection>(metCollectionTag_);
98 
99 
100  produces< pat::ElectronCollection >
101  ("patElectrons").setBranchAlias("patElectrons");
102 
103  produces< pat::METCollection>("patCaloMets").setBranchAlias("patCaloMets");
104  //produces< pat::METCollection>("patPfMets").setBranchAlias("patPfMets");
105  //produces< pat::METCollection>("patTcMets").setBranchAlias("patTcMets");
106  //produces< pat::METCollection>("patT1cMets").setBranchAlias("patT1cMets");
107 
108 }
109 
111 {
112 
113  // do anything here that needs to be done at desctruction time
114  // (e.g. close files, deallocate resources etc.)
115 
116 }
117 
118 
119 bool
121 {
122  using namespace edm;
123  using namespace std;
124  using namespace pat;
125  // *************************************************************************
126  // ELECTRONS
127  // *************************************************************************
130  if (!gsfElectrons.isValid()) {
131  std::cout <<"aod2patFilterZee: Could not get electron collection with label: "
132  <<electronCollectionTag_ << std::endl;
133  return false;
134  }
135  const reco::GsfElectronCollection *pElecs = gsfElectrons.product();
136  // calculate your electrons
137  auto_ptr<pat::ElectronCollection> patElectrons(new pat::ElectronCollection);
138  for (reco::GsfElectronCollection::const_iterator elec = pElecs->begin();
139  elec != pElecs->end(); ++elec) {
140  reco::GsfElectron mygsfelec = *elec;
141  pat::Electron myElectron(mygsfelec);
142  // now set the isolations from the Gsf electron
143  myElectron.setTrackIso(elec->dr03TkSumPt());
144  myElectron.setEcalIso(elec->dr04EcalRecHitSumEt());
145  myElectron.setHcalIso(elec->dr04HcalTowerSumEt());
146 
147  patElectrons->push_back(myElectron);
148  }
149  // *************************************************************************
150  // METs
151  // *************************************************************************
153  iEvent.getByToken(metCollectionToken_, calomets);
154  if (! calomets.isValid()) {
155  std::cout << "aod2patFilterZee: Could not get met collection with label: "
156  << metCollectionTag_ << std::endl;
157  return false;
158  }
159  const reco::CaloMETCollection *mycalomets = calomets.product();
160  auto_ptr<pat::METCollection> patCaloMets(new pat::METCollection);
161  for (reco::CaloMETCollection::const_iterator met = mycalomets->begin();
162  met != mycalomets->end(); ++ met ) {
163  pat::MET mymet(*met);
164  patCaloMets->push_back(mymet);
165  }
166 
167  //
168  // put everything in the event
169  //
170  iEvent.put( patElectrons, "patElectrons");
171  iEvent.put( patCaloMets, "patCaloMets");
172  //
173 
174  return true;
175 
176 }
177 
178 // ------------ method called once each job just before starting event loop -
179 void
181 }
182 
183 // ------------ method called once each job just after ending the event loop -
184 void
186 }
187 
188 
189 //define this as a plug-in
Analysis-level MET class.
Definition: MET.h:43
T getUntrackedParameter(std::string const &, T const &) const
virtual void beginJob() override
virtual void endJob() override
aod2patFilterZee(const edm::ParameterSet &)
edm::InputTag metCollectionTag_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:464
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
std::vector< MET > METCollection
Definition: MET.h:32
virtual bool filter(edm::Event &, const edm::EventSetup &) override
std::vector< GsfElectron > GsfElectronCollection
collection of GsfElectron objects
int iEvent
Definition: GenABIO.cc:230
std::vector< Electron > ElectronCollection
Definition: Electron.h:37
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:120
edm::InputTag electronCollectionTag_
std::vector< reco::CaloMET > CaloMETCollection
collection of CaloMET objects
Analysis-level electron class.
Definition: Electron.h:52
edm::EDGetTokenT< reco::GsfElectronCollection > electronCollectionToken_
edm::EDGetTokenT< reco::CaloMETCollection > metCollectionToken_
void setTrackIso(float trackIso)
Sets tracker isolation variable.
Definition: Lepton.h:154
tuple cout
Definition: gather_cfg.py:121
void setEcalIso(float caloIso)
Sets ecal isolation variable.
Definition: Lepton.h:156
void setHcalIso(float caloIso)
Sets hcal isolation variable.
Definition: Lepton.h:158