CMS 3D CMS Logo

LHEVpTFilter.cc
Go to the documentation of this file.
2 
3 using namespace edm;
4 using namespace std;
5 
7 vptMin_(iConfig.getParameter<double>("VpTMin")),
8 vptMax_(iConfig.getParameter<double>("VpTMax")),
9 totalEvents_(0), passedEvents_(0)
10 {
11  //here do whatever other initialization is needed
12  src_ = consumes<LHEEventProduct>(iConfig.getParameter<edm::InputTag>("src"));
13 
14 }
15 
17 {
18 
19  // do anything here that needs to be done at destruction time
20  // (e.g. close files, deallocate resources etc.)
21 
22 }
23 
24 
25 // ------------ method called to skim the data ------------
27 {
28  lepCands.clear();
30  iEvent.getByToken( src_ , EvtHandle ) ;
31 
32  totalEvents_++;
33 
34  lheParticles = EvtHandle->hepeup().PUP;
35 
36  for (unsigned int i = 0; i < lheParticles.size(); ++i) {
37  if (EvtHandle->hepeup().ISTUP[i] != 1) { // keep only outgoing particles
38  continue;
39  }
40  unsigned absPdgId = std::abs(EvtHandle->hepeup().IDUP[i]);
41  if(absPdgId >=11 && absPdgId<=16){
42  lepCands.push_back(ROOT::Math::PxPyPzEVector(lheParticles[i][0],lheParticles[i][1],lheParticles[i][2],lheParticles[i][3]));
43  }
44  }
45  double vpt_ = -1;
46  if (lepCands.size()==2){
47  vpt_ = (lepCands[0]+lepCands[1]).pt();
48  }
49  if ( vpt_ <= vptMax_ && vpt_ > vptMin_) {
50  passedEvents_++;
51  return true;
52  } else {
53  return false;
54  }
55 
56 }
57 
58 // ------------ method called once each job just after ending the event loop ------------
60  edm::LogInfo("LHEVpTFilter") << "=== Results of LHEVpTFilter: passed "
61  << passedEvents_ << "/" << totalEvents_ << " events" << std::endl;
62 }
63 
64 //define this as a plug-in
66 
T getParameter(std::string const &) const
double vptMin_
Definition: LHEVpTFilter.h:53
const lhef::HEPEUP & hepeup() const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
int iEvent
Definition: GenABIO.cc:224
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
std::vector< FiveVector > PUP
Definition: LesHouches.h:261
std::vector< ROOT::Math::PxPyPzEVector > lepCands
Definition: LHEVpTFilter.h:51
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::vector< int > ISTUP
Definition: LesHouches.h:243
std::vector< int > IDUP
Definition: LesHouches.h:238
std::vector< lhef::HEPEUP::FiveVector > lheParticles
Definition: LHEVpTFilter.h:50
virtual bool filter(edm::Event &, const edm::EventSetup &)
Definition: LHEVpTFilter.cc:26
HLT enums.
LHEVpTFilter(const edm::ParameterSet &)
Definition: LHEVpTFilter.cc:6
virtual void endJob()
Definition: LHEVpTFilter.cc:59
edm::EDGetTokenT< LHEEventProduct > src_
Definition: LHEVpTFilter.h:49