CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HLTJetCollectionsForElePlusJets.cc
Go to the documentation of this file.
2 
4 
7 
9 
11 
13 #include "TVector3.h"
14 
15 #include <string>
16 #include <vector>
17 #include <typeinfo>
18 
19 template<typename T>
21  hltElectronTag(iConfig.getParameter< edm::InputTag > ("HltElectronTag")),
22  sourceJetTag(iConfig.getParameter< edm::InputTag > ("SourceJetTag")),
23  //minJetPt_(iConfig.getParameter<double> ("MinJetPt")),
24  //maxAbsJetEta_(iConfig.getParameter<double> ("MaxAbsJetEta")),
25  //minNJets_(iConfig.getParameter<unsigned int> ("MinNJets")),
26  minDeltaR_(iConfig.getParameter< double > ("minDeltaR"))
27  //Only for VBF
28  //minSoftJetPt_(iConfig.getParameter< double > ("MinSoftJetPt")),
29  //minDeltaEta_(iConfig.getParameter< double > ("MinDeltaEta"))
30 {
31  typedef std::vector<edm::RefVector<std::vector<T>,T,edm::refhelper::FindUsingAdvance<std::vector<T>,T> > > TCollectionVector;
32  m_theElectronToken = consumes<trigger::TriggerFilterObjectWithRefs>(hltElectronTag);
33  m_theJetToken = consumes<std::vector<T>>(sourceJetTag);
34  produces<TCollectionVector> ();
35 }
36 
37 
38 template<typename T>
40 {
41  // do anything here that needs to be done at desctruction time
42  // (e.g. close files, deallocate resources etc.)
43 
44 }
45 
46 template<typename T>
49  desc.add<edm::InputTag> ("HltElectronTag", edm::InputTag("triggerFilterObjectWithRefs"));
50  desc.add<edm::InputTag> ("SourceJetTag", edm::InputTag("jetCollection"));
51  // desc.add<double> ("MinJetPt", 30.);
52  // desc.add<double> ("MaxAbsJetEta", 2.6);
53  // desc.add<unsigned int> ("MinNJets", 1);
54  desc.add<double> ("minDeltaR", 0.5);
55  //Only for VBF
56  // desc.add<double> ("MinSoftJetPt", 25.);
57  //desc.add<double> ("MinDeltaEta", -1.);
58  descriptions.add(std::string("hlt")+std::string(typeid(HLTJetCollectionsForElePlusJets<T>).name()),desc);
59 }
60 
61 //
62 // member functions
63 //
64 
65 
66 // ------------ method called to produce the data ------------
67 template <typename T>
68 void
70 {
71  using namespace edm;
72  using namespace std;
73 
74  typedef vector<T> TCollection;
75  typedef Ref<TCollection> TRef;
76 
77  typedef edm::RefVector<TCollection> TRefVector;
78 
79  typedef std::vector<edm::RefVector<std::vector<T>,T,edm::refhelper::FindUsingAdvance<std::vector<T>,T> > > TCollectionVector;
80 
82  iEvent.getByToken(m_theElectronToken,PrevFilterOutput);
83 
84  //its easier on the if statement flow if I try everything at once, shouldnt add to timing
85  std::vector<edm::Ref<reco::RecoEcalCandidateCollection> > clusCands;
86  PrevFilterOutput->getObjects(trigger::TriggerCluster,clusCands);
87 
88  std::vector<edm::Ref<reco::ElectronCollection> > eleCands;
89  PrevFilterOutput->getObjects(trigger::TriggerElectron,eleCands);
90 
91  //prepare the collection of 3-D vector for electron momenta
92  std::vector<TVector3> ElePs;
93 
94  if(!clusCands.empty()){ //try trigger cluster
95  for(size_t candNr=0;candNr<clusCands.size();candNr++){
96  TVector3 positionVector(
97  clusCands[candNr]->superCluster()->position().x(),
98  clusCands[candNr]->superCluster()->position().y(),
99  clusCands[candNr]->superCluster()->position().z());
100  ElePs.push_back(positionVector);
101  }
102  }else if(!eleCands.empty()){ // try trigger electrons
103  for(size_t candNr=0;candNr<eleCands.size();candNr++){
104  TVector3 positionVector(
105  eleCands[candNr]->superCluster()->position().x(),
106  eleCands[candNr]->superCluster()->position().y(),
107  eleCands[candNr]->superCluster()->position().z());
108  ElePs.push_back(positionVector);
109  }
110  }
111 
112  edm::Handle<TCollection> theJetCollectionHandle;
113  iEvent.getByToken(m_theJetToken, theJetCollectionHandle);
114 
115  const TCollection & theJetCollection = *theJetCollectionHandle;
116 
117  //std::auto_ptr< TCollection > theFilteredJetCollection(new TCollection);
118 
119  std::auto_ptr < TCollectionVector > allSelections(new TCollectionVector());
120 
121  //bool foundSolution(false);
122 
123  for (unsigned int i = 0; i < ElePs.size(); i++) {
124 
125  // bool VBFJetPair = false;
126  //std::vector<int> store_jet;
127  TRefVector refVector;
128 
129  for (unsigned int j = 0; j < theJetCollection.size(); j++) {
130  TVector3 JetP(theJetCollection[j].px(), theJetCollection[j].py(), theJetCollection[j].pz());
131  double DR = ElePs[i].DeltaR(JetP);
132 
133  if (DR > minDeltaR_)
134  refVector.push_back(TRef(theJetCollectionHandle, j));
135  }
136  allSelections->push_back(refVector);
137  }
138 
139  //iEvent.put(theFilteredJetCollection);
140  iEvent.put(allSelections);
141 
142  return;
143 
144 }
edm::EDGetTokenT< std::vector< T > > m_theJetToken
int i
Definition: DBlmapReader.cc:9
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
float float float z
static int position[TOTALCHAMBERS][3]
Definition: ReadPGInfo.cc:509
HLTJetCollectionsForElePlusJets(const edm::ParameterSet &)
int iEvent
Definition: GenABIO.cc:243
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
int j
Definition: DBlmapReader.cc:9
ParameterDescriptionBase * add(U const &iLabel, T const &value)
edm::EDGetTokenT< trigger::TriggerFilterObjectWithRefs > m_theElectronToken
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: DDAxes.h:10
long double T
virtual void produce(edm::Event &, const edm::EventSetup &)