CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HLTJetCollectionsForLeptonPlusJets.cc
Go to the documentation of this file.
2 
4 
9 
11 
13 
16 
17 
18 
19 
20 template <typename jetType>
22  hltLeptonTag(iConfig.getParameter< edm::InputTag > ("HltLeptonTag")),
23  sourceJetTag(iConfig.getParameter< edm::InputTag > ("SourceJetTag")),
24  minDeltaR_(iConfig.getParameter< double > ("minDeltaR"))
25 {
26  using namespace edm;
27  using namespace std;
28  typedef vector<RefVector<vector<jetType>,jetType,refhelper::FindUsingAdvance<vector<jetType>,jetType> > > JetCollectionVector;
29  m_theLeptonToken = consumes<trigger::TriggerFilterObjectWithRefs>(hltLeptonTag);
30  m_theJetToken = consumes<std::vector<jetType>>(sourceJetTag);
31  produces<JetCollectionVector> ();
32 }
33 
34 template <typename jetType>
36 {
37  // do anything here that needs to be done at desctruction time
38  // (e.g. close files, deallocate resources etc.)
39 
40 }
41 
42 template <typename jetType>
43 void
46  desc.add<edm::InputTag> ("HltLeptonTag", edm::InputTag("triggerFilterObjectWithRefs"));
47  desc.add<edm::InputTag> ("SourceJetTag", edm::InputTag("caloJetCollection"));
48  desc.add<double> ("minDeltaR", 0.5);
49  descriptions.add(std::string("hlt")+std::string(typeid(HLTJetCollectionsForLeptonPlusJets<jetType>).name()),desc);
50 }
51 
52 //
53 // member functions
54 //
55 
56 
57 // ------------ method called to produce the data ------------
58 // template <typename T>
59 template <typename jetType>
60 void
62 {
63  using namespace edm;
64  using namespace std;
65 
66  typedef vector<RefVector<vector<jetType>,jetType,refhelper::FindUsingAdvance<vector<jetType>,jetType> > > JetCollectionVector;
67  typedef vector<jetType> JetCollection;
70 
72  iEvent.getByToken(m_theLeptonToken,PrevFilterOutput);
73 
74  //its easier on the if statement flow if I try everything at once, shouldnt add to timing
75  vector<Ref<reco::RecoEcalCandidateCollection> > clusCands;
76  PrevFilterOutput->getObjects(trigger::TriggerCluster,clusCands);
77 
78  vector<Ref<reco::ElectronCollection> > eleCands;
79  PrevFilterOutput->getObjects(trigger::TriggerElectron,eleCands);
80 
81  vector<reco::RecoChargedCandidateRef> muonCands;
82  PrevFilterOutput->getObjects(trigger::TriggerMuon,muonCands);
83 
84  Handle<JetCollection> theJetCollectionHandle;
85  iEvent.getByToken(m_theJetToken, theJetCollectionHandle);
86 
87  const JetCollection & theJetCollection = *theJetCollectionHandle;
88 
89  auto_ptr < JetCollectionVector > allSelections(new JetCollectionVector());
90 
91  if(!clusCands.empty()){ //try trigger cluster
92  for(size_t candNr=0;candNr<clusCands.size();candNr++){
93  JetRefVector refVector;
94  for (unsigned int j = 0; j < theJetCollection.size(); j++) {
95  if (deltaR(clusCands[candNr]->superCluster()->position(),theJetCollection[j]) > minDeltaR_) refVector.push_back(JetRef(theJetCollectionHandle, j));
96  }
97  allSelections->push_back(refVector);
98  }
99  }
100 
101  if(!eleCands.empty()){ //try trigger cluster
102  for(size_t candNr=0;candNr<eleCands.size();candNr++){
103  JetRefVector refVector;
104  for (unsigned int j = 0; j < theJetCollection.size(); j++) {
105  if (deltaR(eleCands[candNr]->superCluster()->position(),theJetCollection[j]) > minDeltaR_) refVector.push_back(JetRef(theJetCollectionHandle, j));
106  }
107  allSelections->push_back(refVector);
108  }
109  }
110 
111  if(!muonCands.empty()){ //try trigger cluster
112  for(size_t candNr=0;candNr<muonCands.size();candNr++){
113  JetRefVector refVector;
114  for (unsigned int j = 0; j < theJetCollection.size(); j++) {
115  if (deltaR(muonCands[candNr]->p4(),theJetCollection[j]) > minDeltaR_) refVector.push_back(JetRef(theJetCollectionHandle, j));
116  }
117  allSelections->push_back(refVector);
118  }
119  }
120 
121 
122 
123 
124  iEvent.put(allSelections);
125 
126  return;
127 
128 }
129 
std::vector< Jet > JetCollection
Definition: Jet.h:49
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
edm::EDGetTokenT< trigger::TriggerFilterObjectWithRefs > m_theLeptonToken
edm::Ref< JetCollection > JetRef
Definition: Jet.h:51
static int position[TOTALCHAMBERS][3]
Definition: ReadPGInfo.cc:509
edm::RefVector< JetCollection > JetRefVector
Definition: Jet.h:52
int iEvent
Definition: GenABIO.cc:243
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
double p4[4]
Definition: TauolaWrapper.h:92
int j
Definition: DBlmapReader.cc:9
ParameterDescriptionBase * add(U const &iLabel, T const &value)
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
void add(std::string const &label, ParameterSetDescription const &psetDescription)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
edm::EDGetTokenT< std::vector< jetType > > m_theJetToken
virtual void produce(edm::Event &, const edm::EventSetup &)