CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DJpsiFilter.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: DJpsiFilter
4 // Class: DJpsiFilter
5 //
13 //
14 // Original Author: bian jianguo
15 // Created: Tue Nov 22 20:39:54 CST 2011
16 //
17 //
18 
19 
20 // system include files
21 #include <memory>
22 
23 // user include files
26 
29 
32 
33 #include <iostream>
34 
35 //
36 // class declaration
37 //
38 
39 class DJpsiFilter : public edm::EDFilter {
40  public:
41  explicit DJpsiFilter(const edm::ParameterSet&);
42  ~DJpsiFilter();
43 
44  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
45 
46  private:
47 
48  virtual bool filter(edm::Event&, const edm::EventSetup&) override;
49 
50  // ----------member data ---------------------------
51 
53  double minPt;
54  double maxY;
55  double maxPt;
56  double minY;
57  int status;
59 
60 };
61 
62 //
63 // constants, enums and typedefs
64 //
65 
66 //
67 // static data member definitions
68 //
69 
70 //
71 // constructors and destructor
72 //
74 token_(consumes<edm::HepMCProduct>(edm::InputTag(iConfig.getUntrackedParameter("moduleLabel",std::string("generator")),"unsmeared"))),
75 minPt(iConfig.getUntrackedParameter("MinPt", 0.)),
76 maxY(iConfig.getUntrackedParameter("MaxY", 10.)),
77 maxPt(iConfig.getUntrackedParameter("MaxPt", 1000.)),
78 minY(iConfig.getUntrackedParameter("MinY", 0.)),
79 status(iConfig.getUntrackedParameter("Status", 0)),
80 particleID(iConfig.getUntrackedParameter("ParticleID", 0))
81 {
82  //now do what ever initialization is needed
83 }
84 
85 
87 {
88 
89  // do anything here that needs to be done at desctruction time
90  // (e.g. close files, deallocate resources etc.)
91 
92 }
93 
94 
95 //
96 // member functions
97 //
98 
99 // ------------ method called on each new Event ------------
100 bool
102 {
103  using namespace edm;
104 // DJpsiInput++;
105 // std::cout<<"NumberofInputEvent "<<DJpsiInput<<std::endl;
106 
107  bool accepted = false;
108  int n2jpsi = 0;
109 // int n2hadron = 0;
110  double energy, pz, momentumY;
112  iEvent.getByToken(token_, evt);
113  const HepMC::GenEvent * myGenEvent = evt->GetEvent();
114 
115 
116  for ( HepMC::GenEvent::particle_const_iterator p = myGenEvent->particles_begin(); p != myGenEvent->particles_end(); ++p ) {
117  if ( (*p)->status()!=status ) continue;
118 // if ( abs((*p)->pdg_id()) == particleID )n2hadron++;
119  energy=(*p)->momentum().e();
120  pz=(*p)->momentum().pz();
121  momentumY=0.5*log((energy+pz)/(energy-pz));
122  if ((*p)->momentum().perp() > minPt && fabs(momentumY) < maxY &&
123  (*p)->momentum().perp() < maxPt && fabs(momentumY) > minY) {
124  if ( abs((*p)->pdg_id()) == particleID ) n2jpsi++;
125  }
126  if (n2jpsi >= 2) {
127  accepted = true;
128  break;
129  }
130  }
131 
132 
133  if (accepted) {
134  return true;
135  } else {
136  return false;
137  }
138 
139 
140 }
141 
142 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
143 void
145  //The following says we do not know what parameters are allowed so do no validation
146  // Please change this to state exactly what you do use, even if it is no parameters
148  desc.setUnknown();
149  descriptions.addDefault(desc);
150 }
151 //define this as a plug-in
DJpsiFilter(const edm::ParameterSet &)
Definition: DJpsiFilter.cc:73
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:464
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
double minY
Definition: DJpsiFilter.cc:56
int iEvent
Definition: GenABIO.cc:230
void addDefault(ParameterSetDescription const &psetDescription)
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: DJpsiFilter.cc:144
edm::EDGetToken token_
Definition: DJpsiFilter.cc:52
double maxY
Definition: DJpsiFilter.cc:54
double minPt
Definition: DJpsiFilter.cc:53
virtual bool filter(edm::Event &, const edm::EventSetup &) override
Definition: DJpsiFilter.cc:101
tuple status
Definition: ntuplemaker.py:245
double maxPt
Definition: DJpsiFilter.cc:55
tuple log
Definition: cmsBatch.py:341