CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
MCLongLivedParticles.cc
Go to the documentation of this file.
1 
3 
5 #include <iostream>
6 
7 using namespace edm;
8 using namespace std;
9 
10 
12 {
13  //here do whatever other initialization is needed
14  theCut = iConfig.getUntrackedParameter<double>("LengCut",10.);
15 }
16 
17 
19 {
20 
21  // do anything here that needs to be done at desctruction time
22  // (e.g. close files, deallocate resources etc.)
23 
24 }
25 
26 
27 // ------------ method called to skim the data ------------
29 {
30 
31  using namespace edm;
32 
34 
35  iEvent.getByType(evt);
36 
37  bool pass = false;
38 
39  const HepMC::GenEvent * generated_event = evt->GetEvent();
40  HepMC::GenEvent::particle_const_iterator p;
41 
42  for (p = generated_event->particles_begin(); p != generated_event->particles_end(); p++)
43  {
44 
45  if((*p)->production_vertex()!=0&&(*p)->end_vertex()!=0)
46  {
47  float dist = sqrt((((*p)->production_vertex())->position().x()-((*p)->end_vertex())->position().x())*(((*p)->production_vertex())->position().x()-((*p)->end_vertex())->position().x())+
48  (((*p)->production_vertex())->position().y()-((*p)->end_vertex())->position().y())*(((*p)->production_vertex())->position().y()-((*p)->end_vertex())->position().y()));
49  if(dist>theCut)
50  pass=true;
51  }
52 
53  if((*p)->production_vertex()==0&&!(*p)->end_vertex()!=0)
54  {
55  if(((*p)->end_vertex())->position().perp()>theCut)
56  pass=true;
57  }
58 
59  if(pass)
60  return pass;
61  }
62 
63  return pass;
64 }
65 
T getUntrackedParameter(std::string const &, T const &) const
virtual bool filter(edm::Event &, const edm::EventSetup &)
bool getByType(Handle< PROD > &result) const
Definition: Event.h:398
MCLongLivedParticles(const edm::ParameterSet &)
int iEvent
Definition: GenABIO.cc:243
T sqrt(T t)
Definition: SSEVec.h:46
static int position[264][3]
Definition: ReadPGInfo.cc:509