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  // Electrons can be stored as objects of types TriggerCluster, TriggerElectron, or TriggerPhoton
76  vector<Ref<reco::RecoEcalCandidateCollection> > clusCands;
77  PrevFilterOutput->getObjects(trigger::TriggerCluster,clusCands);
78 
79  vector<Ref<reco::ElectronCollection> > eleCands;
80  PrevFilterOutput->getObjects(trigger::TriggerElectron,eleCands);
81 
82  trigger::VRphoton photonCands;
83  PrevFilterOutput->getObjects(trigger::TriggerPhoton, photonCands);
84 
85  vector<reco::RecoChargedCandidateRef> muonCands;
86  PrevFilterOutput->getObjects(trigger::TriggerMuon,muonCands);
87 
88  Handle<JetCollection> theJetCollectionHandle;
89  iEvent.getByToken(m_theJetToken, theJetCollectionHandle);
90 
91  const JetCollection & theJetCollection = *theJetCollectionHandle;
92 
93  auto_ptr < JetCollectionVector > allSelections(new JetCollectionVector());
94 
95  if(!clusCands.empty()){ // try trigger clusters
96  for(size_t candNr=0;candNr<clusCands.size();candNr++){
97  JetRefVector refVector;
98  for (unsigned int j = 0; j < theJetCollection.size(); j++) {
99  if (deltaR(clusCands[candNr]->superCluster()->position(),theJetCollection[j]) > minDeltaR_) refVector.push_back(JetRef(theJetCollectionHandle, j));
100  }
101  allSelections->push_back(refVector);
102  }
103  }
104 
105  if(!eleCands.empty()){ // try electrons
106  for(size_t candNr=0;candNr<eleCands.size();candNr++){
107  JetRefVector refVector;
108  for (unsigned int j = 0; j < theJetCollection.size(); j++) {
109  if (deltaR(eleCands[candNr]->superCluster()->position(),theJetCollection[j]) > minDeltaR_) refVector.push_back(JetRef(theJetCollectionHandle, j));
110  }
111  allSelections->push_back(refVector);
112  }
113  }
114 
115  if(!photonCands.empty()){ // try photons
116  for(size_t candNr=0;candNr<photonCands.size();candNr++){
117  JetRefVector refVector;
118  for (unsigned int j = 0; j < theJetCollection.size(); j++) {
119  if (deltaR(photonCands[candNr]->superCluster()->position(),theJetCollection[j]) > minDeltaR_) refVector.push_back(JetRef(theJetCollectionHandle, j));
120  }
121  allSelections->push_back(refVector);
122  }
123  }
124 
125  if(!muonCands.empty()){ // muons
126  for(size_t candNr=0;candNr<muonCands.size();candNr++){
127  JetRefVector refVector;
128  for (unsigned int j = 0; j < theJetCollection.size(); j++) {
129  if (deltaR(muonCands[candNr]->p4(),theJetCollection[j]) > minDeltaR_) refVector.push_back(JetRef(theJetCollectionHandle, j));
130  }
131  allSelections->push_back(refVector);
132  }
133  }
134 
135 
136 
137 
138  iEvent.put(allSelections);
139 
140  return;
141 
142 }
143 
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:230
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 &)
std::vector< reco::RecoEcalCandidateRef > VRphoton