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 
22 
23 namespace pat {
24 
25  class PATJetSlimmer : public edm::EDProducer {
26  public:
27  explicit PATJetSlimmer(const edm::ParameterSet & iConfig);
28  virtual ~PATJetSlimmer() { }
29 
30  virtual void produce(edm::Event & iEvent, const edm::EventSetup & iSetup);
31 
32  private:
36  };
37 
38 } // namespace
39 
40 
42  pf2pc_(consumes<edm::Association<pat::PackedCandidateCollection> >(iConfig.getParameter<edm::InputTag>("packedPFCandidates"))),
43  jets_(consumes<edm::View<pat::Jet> >(iConfig.getParameter<edm::InputTag>("src"))),
44  dropJetVars_(iConfig.getParameter<std::string>("dropJetVars")),
45  dropDaughters_(iConfig.getParameter<std::string>("dropDaughters")),
46  rekeyDaughters_(iConfig.getParameter<std::string>("rekeyDaughters")),
47  dropTrackRefs_(iConfig.getParameter<std::string>("dropTrackRefs")),
48  dropSpecific_(iConfig.getParameter<std::string>("dropSpecific")),
49  dropTagInfos_(iConfig.getParameter<std::string>("dropTagInfos"))
50 {
51  produces<std::vector<pat::Jet> >();
52 }
53 
54 void
56  using namespace edm;
57  using namespace std;
58 
60  iEvent.getByToken(jets_, src);
62  iEvent.getByToken(pf2pc_,pf2pc);
63 
64  auto_ptr<vector<pat::Jet> > out(new vector<pat::Jet>());
65  out->reserve(src->size());
66 
67  for (edm::View<pat::Jet>::const_iterator it = src->begin(), ed = src->end(); it != ed; ++it) {
68  out->push_back(*it);
69  pat::Jet & jet = out->back();
70  if(dropTagInfos_(*it)){
71  jet.tagInfos_.clear();
72  jet.tagInfosFwdPtr_.clear();
73  }
74  if (dropJetVars_(*it)) {
75  // jet.setJetArea(0);
76  jet.setNPasses(0);
77  // jet.setPileup(0);
78  }
79  if(dropTrackRefs_(*it))
80  {
82  }
83  if (dropDaughters_(*it)) {
84  jet.clearDaughters();
85  jet.pfCandidatesFwdPtr_.clear();
86  jet.caloTowersFwdPtr_.clear();
87  } else if (rekeyDaughters_(*it)) { //rekey
88  //copy old
90  jet.clearDaughters();
91  std::map<unsigned int,reco::CandidatePtr> ptrs;
92  for(unsigned int i=0;i<old.size();i++)
93  {
94  // jet.addDaughter(refToPtr((*pf2pc)[old[i]]));
95  ptrs[((*pf2pc)[old[i]]).key()]=refToPtr((*pf2pc)[old[i]]);
96  }
97  for(std::map<unsigned int,reco::CandidatePtr>::iterator itp=ptrs.begin();itp!=ptrs.end();itp++) //iterate on sorted items
98  {
99  jet.addDaughter(itp->second);
100  }
101 
102 
103  }
104  if (dropSpecific_(*it)) {
105  // FIXME add method in pat::Jet
106  jet.specificCalo_.clear();
107  jet.specificPF_.clear();
108  }
109  // if (dropJetCorrFactors_(*it)) {
110  // // FIXME add method in pat::Jet
111  // jet.jetEnergyCorrections_.clear();
112  // }
113  }
114 
115  iEvent.put(out);
116 }
117 
119 using namespace pat;
int i
Definition: DBlmapReader.cc:9
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:449
StringCutObjectSelector< pat::Jet > dropTrackRefs_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
TagInfoFwdPtrCollection tagInfosFwdPtr_
Definition: Jet.h:560
std::vector< pat::PackedCandidate > PackedCandidateCollection
edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > pf2pc_
StringCutObjectSelector< pat::Jet > rekeyDaughters_
std::vector< PFSpecific > specificPF_
Definition: Jet.h:572
edm::OwnVector< reco::BaseTagInfo > tagInfos_
Definition: Jet.h:559
int iEvent
Definition: GenABIO.cc:230
std::vector< CaloSpecific > specificCalo_
Definition: Jet.h:570
edm::EDGetTokenT< edm::View< pat::Jet > > jets_
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:113
StringCutObjectSelector< pat::Jet > dropSpecific_
void clear()
Definition: OwnVector.h:377
virtual void produce(edm::Event &iEvent, const edm::EventSetup &iSetup)
StringCutObjectSelector< pat::Jet > dropJetVars_
tuple out
Definition: dbtoconf.py:99
std::vector< CandidatePtr > daughters
collection of references to daughters
StringCutObjectSelector< pat::Jet > dropTagInfos_
void setAssociatedTracks(const reco::TrackRefVector &tracks)
method to set the vector of refs to the tracks associated to this jet
Analysis-level calorimeter jet class.
Definition: Jet.h:77
PATJetSlimmer(const edm::ParameterSet &iConfig)
void clearDaughters()
clear daughter references
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:81
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()
StringCutObjectSelector< pat::Jet > dropDaughters_