CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PATJetSlimmer.cc
Go to the documentation of this file.
1 //
2 // $Id: PATJetSlimmer.cc,v 1.1 2011/03/24 18:45:45 mwlebour Exp $
3 //
4 
20 
23 
24 namespace pat {
25 
27  public:
28  explicit PATJetSlimmer(const edm::ParameterSet & iConfig);
29  virtual ~PATJetSlimmer() { }
30 
31  virtual void produce(edm::Event & iEvent, const edm::EventSetup & iSetup);
32  virtual void beginLuminosityBlock(const edm::LuminosityBlock&, const edm::EventSetup&) override final;
33 
34  private:
35  const edm::EDGetTokenT<edm::Association<pat::PackedCandidateCollection>> pf2pc_;
36  const edm::EDGetTokenT<edm::View<pat::Jet> > jets_;
39  std::unique_ptr<pat::ObjectModifier<pat::Jet> > jetModifier_;
40  };
41 
42 } // namespace
43 
44 
46  pf2pc_(consumes<edm::Association<pat::PackedCandidateCollection> >(iConfig.getParameter<edm::InputTag>("packedPFCandidates"))),
47  jets_(consumes<edm::View<pat::Jet> >(iConfig.getParameter<edm::InputTag>("src"))),
48  dropJetVars_(iConfig.getParameter<std::string>("dropJetVars")),
49  dropDaughters_(iConfig.getParameter<std::string>("dropDaughters")),
50  rekeyDaughters_(iConfig.getParameter<std::string>("rekeyDaughters")),
51  dropTrackRefs_(iConfig.getParameter<std::string>("dropTrackRefs")),
52  dropSpecific_(iConfig.getParameter<std::string>("dropSpecific")),
53  dropTagInfos_(iConfig.getParameter<std::string>("dropTagInfos")),
54  modifyJet_(iConfig.getParameter<bool>("modifyJets"))
55 {
57  if( modifyJet_ ) {
58  const edm::ParameterSet& mod_config = iConfig.getParameter<edm::ParameterSet>("modifierConfig");
59  jetModifier_.reset(new pat::ObjectModifier<pat::Jet>(mod_config) );
60  jetModifier_->setConsumes(sumes);
61  } else {
62  jetModifier_.reset(nullptr);
63  }
64  produces<std::vector<pat::Jet> >();
65 }
66 
67 void
69  if( modifyJet_ ) jetModifier_->setEventContent(iSetup);
70 }
71 
72 void
74  using namespace edm;
75  using namespace std;
76 
78  iEvent.getByToken(jets_, src);
80  iEvent.getByToken(pf2pc_,pf2pc);
81 
82  auto_ptr<vector<pat::Jet> > out(new vector<pat::Jet>());
83  out->reserve(src->size());
84 
85  if( modifyJet_ ) { jetModifier_->setEvent(iEvent); }
86 
87  for (edm::View<pat::Jet>::const_iterator it = src->begin(), ed = src->end(); it != ed; ++it) {
88  out->push_back(*it);
89  pat::Jet & jet = out->back();
90 
91  if( modifyJet_ ) { jetModifier_->modify(jet); }
92 
93  if(dropTagInfos_(*it)){
94  jet.tagInfos_.clear();
95  jet.tagInfosFwdPtr_.clear();
96  }
97  if (dropJetVars_(*it)) {
98  // jet.setJetArea(0);
99  jet.setNPasses(0);
100  // jet.setPileup(0);
101  }
102  if(dropTrackRefs_(*it))
103  {
105  }
106  if (dropDaughters_(*it)) {
107  jet.clearDaughters();
108  jet.pfCandidatesFwdPtr_.clear();
109  jet.caloTowersFwdPtr_.clear();
110  } else if (rekeyDaughters_(*it)) { //rekey
111  //copy old
113  jet.clearDaughters();
114  std::map<unsigned int,reco::CandidatePtr> ptrs;
115  for(unsigned int i=0;i<old.size();i++)
116  {
117  // jet.addDaughter(refToPtr((*pf2pc)[old[i]]));
118  ptrs[((*pf2pc)[old[i]]).key()]=refToPtr((*pf2pc)[old[i]]);
119  }
120  for(std::map<unsigned int,reco::CandidatePtr>::iterator itp=ptrs.begin();itp!=ptrs.end();itp++) //iterate on sorted items
121  {
122  jet.addDaughter(itp->second);
123  }
124 
125 
126  }
127  if (dropSpecific_(*it)) {
128  // FIXME add method in pat::Jet
129  jet.specificCalo_.clear();
130  jet.specificPF_.clear();
131  }
132  // if (dropJetCorrFactors_(*it)) {
133  // // FIXME add method in pat::Jet
134  // jet.jetEnergyCorrections_.clear();
135  // }
136  }
137 
138  iEvent.put(out);
139 }
140 
142 using namespace pat;
std::unique_ptr< pat::ObjectModifier< pat::Jet > > jetModifier_
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
const StringCutObjectSelector< pat::Jet > dropDaughters_
CaloTowerFwdPtrVector caloTowersFwdPtr_
Definition: Jet.h:520
Ptr< typename C::value_type > refToPtr(Ref< C, typename C::value_type, refhelper::FindUsingAdvance< C, typename C::value_type > > const &ref)
Definition: RefToPtr.h:18
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:464
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
TagInfoFwdPtrCollection tagInfosFwdPtr_
Definition: Jet.h:560
std::vector< pat::PackedCandidate > PackedCandidateCollection
const StringCutObjectSelector< pat::Jet > dropTrackRefs_
virtual void beginLuminosityBlock(const edm::LuminosityBlock &, const edm::EventSetup &) overridefinal
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
std::vector< PFSpecific > specificPF_
Definition: Jet.h:572
const bool modifyJet_
edm::OwnVector< reco::BaseTagInfo > tagInfos_
Definition: Jet.h:559
int iEvent
Definition: GenABIO.cc:230
std::vector< CaloSpecific > specificCalo_
Definition: Jet.h:570
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:120
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
void clear()
Definition: OwnVector.h:377
const StringCutObjectSelector< pat::Jet > dropSpecific_
const StringCutObjectSelector< pat::Jet > dropTagInfos_
#define private
Definition: FWEveView.cc:22
virtual void produce(edm::Event &iEvent, const edm::EventSetup &iSetup)
string key
FastSim: produces sample of signal events, overlayed with premixed minbias events.
tuple out
Definition: dbtoconf.py:99
std::vector< CandidatePtr > daughters
collection of references to daughters
const StringCutObjectSelector< pat::Jet > rekeyDaughters_
void setAssociatedTracks(const reco::TrackRefVector &tracks)
method to set the vector of refs to the tracks associated to this jet
string const
Definition: compareJSON.py:14
Analysis-level calorimeter jet class.
Definition: Jet.h:77
const edm::EDGetTokenT< edm::View< pat::Jet > > jets_
PATJetSlimmer(const edm::ParameterSet &iConfig)
void clearDaughters()
clear daughter references
const StringCutObjectSelector< pat::Jet > dropJetVars_
virtual void setNPasses(int fPasses)
Set number of passes taken by algorithm.
Definition: Jet.h:113
reco::PFCandidateFwdPtrVector pfCandidatesFwdPtr_
Definition: Jet.h:526
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:85
const edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > pf2pc_
const daughters & daughterPtrVector() const
references to daughtes
void addDaughter(const CandidatePtr &)
add a daughter via a reference
Matcher of reconstructed objects to L1 Muons.
virtual ~PATJetSlimmer()