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 // $Id: DJpsiFilter.cc,v 1.1 2012/03/16 14:37:32 lenzip Exp $
17 //
18 //
19 
20 
21 // system include files
22 #include <memory>
23 
24 // user include files
27 
30 
33 
34 #include <iostream>
35 
36 //
37 // class declaration
38 //
39 
40 class DJpsiFilter : public edm::EDFilter {
41  public:
42  explicit DJpsiFilter(const edm::ParameterSet&);
43  ~DJpsiFilter();
44 
45  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
46 
47  private:
48  virtual void beginJob() ;
49  virtual bool filter(edm::Event&, const edm::EventSetup&);
50  virtual void endJob() ;
51 
52  virtual bool beginRun(edm::Run&, edm::EventSetup const&);
53  virtual bool endRun(edm::Run&, edm::EventSetup const&);
56 
57  // ----------member data ---------------------------
58 
59  std::string label_;
60  double minPt;
61  double maxY;
62  double maxPt;
63  double minY;
64  int status;
66 
67 };
68 
69 //
70 // constants, enums and typedefs
71 //
72 
73 //
74 // static data member definitions
75 //
76 
77 //
78 // constructors and destructor
79 //
81 label_(iConfig.getUntrackedParameter("moduleLabel",std::string("generator"))),
82 minPt(iConfig.getUntrackedParameter("MinPt", 0.)),
83 maxY(iConfig.getUntrackedParameter("MaxY", 10.)),
84 maxPt(iConfig.getUntrackedParameter("MaxPt", 1000.)),
85 minY(iConfig.getUntrackedParameter("MinY", 0.)),
86 status(iConfig.getUntrackedParameter("Status", 0)),
87 particleID(iConfig.getUntrackedParameter("ParticleID", 0))
88 {
89  //now do what ever initialization is needed
90 }
91 
92 
94 {
95 
96  // do anything here that needs to be done at desctruction time
97  // (e.g. close files, deallocate resources etc.)
98 
99 }
100 
101 
102 //
103 // member functions
104 //
105 
106 // ------------ method called on each new Event ------------
107 bool
109 {
110  using namespace edm;
111 // DJpsiInput++;
112 // std::cout<<"NumberofInputEvent "<<DJpsiInput<<std::endl;
113 
114  bool accepted = false;
115  int n2jpsi = 0;
116 // int n2hadron = 0;
117  double energy, pz, momentumY;
119  iEvent.getByLabel(label_, evt);
120  const HepMC::GenEvent * myGenEvent = evt->GetEvent();
121 
122 
123  for ( HepMC::GenEvent::particle_const_iterator p = myGenEvent->particles_begin(); p != myGenEvent->particles_end(); ++p ) {
124  if ( (*p)->status()!=status ) continue;
125 // if ( abs((*p)->pdg_id()) == particleID )n2hadron++;
126  energy=(*p)->momentum().e();
127  pz=(*p)->momentum().pz();
128  momentumY=0.5*log((energy+pz)/(energy-pz));
129  if ((*p)->momentum().perp() > minPt && fabs(momentumY) < maxY &&
130  (*p)->momentum().perp() < maxPt && fabs(momentumY) > minY) {
131  if ( abs((*p)->pdg_id()) == particleID ) n2jpsi++;
132  }
133  if (n2jpsi >= 2) {
134  accepted = true;
135  break;
136  }
137  }
138 
139 
140  if (accepted) {
141  return true;
142  } else {
143  return false;
144  }
145 
146 
147 }
148 
149 // ------------ method called once each job just before starting event loop ------------
150 void
152 {
153 }
154 
155 // ------------ method called once each job just after ending the event loop ------------
156 void
158 }
159 
160 // ------------ method called when starting to processes a run ------------
161 bool
163 {
164  return true;
165 }
166 
167 // ------------ method called when ending the processing of a run ------------
168 bool
170 {
171  return true;
172 }
173 
174 // ------------ method called when starting to processes a luminosity block ------------
175 bool
177 {
178  return true;
179 }
180 
181 // ------------ method called when ending the processing of a luminosity block ------------
182 bool
184 {
185  return true;
186 }
187 
188 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
189 void
191  //The following says we do not know what parameters are allowed so do no validation
192  // Please change this to state exactly what you do use, even if it is no parameters
194  desc.setUnknown();
195  descriptions.addDefault(desc);
196 }
197 //define this as a plug-in
virtual bool endRun(edm::Run &, edm::EventSetup const &)
Definition: DJpsiFilter.cc:169
DJpsiFilter(const edm::ParameterSet &)
Definition: DJpsiFilter.cc:80
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
double minY
Definition: DJpsiFilter.cc:63
#define abs(x)
Definition: mlp_lapack.h:159
virtual void beginJob()
Definition: DJpsiFilter.cc:151
virtual bool beginRun(edm::Run &, edm::EventSetup const &)
Definition: DJpsiFilter.cc:162
int iEvent
Definition: GenABIO.cc:243
void addDefault(ParameterSetDescription const &psetDescription)
virtual bool endLuminosityBlock(edm::LuminosityBlock &, edm::EventSetup const &)
Definition: DJpsiFilter.cc:183
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: DJpsiFilter.cc:190
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
virtual bool beginLuminosityBlock(edm::LuminosityBlock &, edm::EventSetup const &)
Definition: DJpsiFilter.cc:176
double maxY
Definition: DJpsiFilter.cc:61
double minPt
Definition: DJpsiFilter.cc:60
tuple status
Definition: ntuplemaker.py:245
virtual bool filter(edm::Event &, const edm::EventSetup &)
Definition: DJpsiFilter.cc:108
std::string label_
Definition: DJpsiFilter.cc:59
Definition: Run.h:33
double maxPt
Definition: DJpsiFilter.cc:62
virtual void endJob()
Definition: DJpsiFilter.cc:157