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  dropTrackRefs_(iConfig.getParameter<std::string>("dropTrackRefs")),
47  dropSpecific_(iConfig.getParameter<std::string>("dropSpecific")),
48  dropTagInfos_(iConfig.getParameter<std::string>("dropTagInfos"))
49 {
50  produces<std::vector<pat::Jet> >();
51 }
52 
53 void
55  using namespace edm;
56  using namespace std;
57 
59  iEvent.getByToken(jets_, src);
61  iEvent.getByToken(pf2pc_,pf2pc);
62 
63  auto_ptr<vector<pat::Jet> > out(new vector<pat::Jet>());
64  out->reserve(src->size());
65 
66  for (edm::View<pat::Jet>::const_iterator it = src->begin(), ed = src->end(); it != ed; ++it) {
67  out->push_back(*it);
68  pat::Jet & jet = out->back();
69  if(dropTagInfos_(*it)){
70  jet.tagInfos_.clear();
71  jet.tagInfosFwdPtr_.clear();
72  }
73  if (dropJetVars_(*it)) {
74  // jet.setJetArea(0);
75  jet.setNPasses(0);
76  // jet.setPileup(0);
77  }
78  if(dropTrackRefs_(*it))
79  {
81  }
82  if (dropDaughters_(*it)) {
83  jet.clearDaughters();
84  jet.pfCandidatesFwdPtr_.clear();
85  jet.caloTowersFwdPtr_.clear();
86  } else { //rekey
87  //copy old
89  jet.clearDaughters();
90  std::map<unsigned int,reco::CandidatePtr> ptrs;
91  for(unsigned int i=0;i<old.size();i++)
92  {
93  // jet.addDaughter(refToPtr((*pf2pc)[old[i]]));
94  ptrs[((*pf2pc)[old[i]]).key()]=refToPtr((*pf2pc)[old[i]]);
95  }
96  for(std::map<unsigned int,reco::CandidatePtr>::iterator itp=ptrs.begin();itp!=ptrs.end();itp++) //iterate on sorted items
97  {
98  jet.addDaughter(itp->second);
99  }
100 
101 
102  }
103  if (dropSpecific_(*it)) {
104  // FIXME add method in pat::Jet
105  jet.specificCalo_.clear();
106  jet.specificPF_.clear();
107  }
108  // if (dropJetCorrFactors_(*it)) {
109  // // FIXME add method in pat::Jet
110  // jet.jetEnergyCorrections_.clear();
111  // }
112  }
113 
114  iEvent.put(out);
115 }
116 
118 using namespace pat;
int i
Definition: DBlmapReader.cc:9
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:81
CaloTowerFwdPtrVector caloTowersFwdPtr_
Definition: Jet.h:510
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:434
StringCutObjectSelector< pat::Jet > dropTrackRefs_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
TagInfoFwdPtrCollection tagInfosFwdPtr_
Definition: Jet.h:546
std::vector< pat::PackedCandidate > PackedCandidateCollection
edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > pf2pc_
std::vector< PFSpecific > specificPF_
Definition: Jet.h:558
edm::OwnVector< reco::BaseTagInfo > tagInfos_
Definition: Jet.h:545
void setAssociatedTracks(const reco::TrackRefVector &tracks)
method to set the vector of refs to the tracks associated to this jet
Definition: Jet.cc:393
int iEvent
Definition: GenABIO.cc:243
std::vector< CaloSpecific > specificCalo_
Definition: Jet.h:556
edm::EDGetTokenT< edm::View< pat::Jet > > jets_
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
StringCutObjectSelector< pat::Jet > dropSpecific_
void clear()
Definition: OwnVector.h:370
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_
Analysis-level calorimeter jet class.
Definition: Jet.h:73
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:516
list key
Definition: combine.py:13
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_