CMS 3D CMS Logo

HGCalTBCheckGunPosition.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: HGCalTestBeam/HGCalTBCheckGunPostion
4 // Class: HGCalTBCheckGunPostion
5 //
14 //
15 // Original Author: Shilpi Jain
16 // Created: Wed, 31 Aug 2016 17:47:22 GMT
17 //
18 //
19 
20 // system include files
21 #include <memory>
22 
23 // user include files
29 
32 
33 #include <iostream>
35 
36 //#define EDM_ML_DEBUG
37 
38 //
39 // class declaration
40 //
41 
43 public:
45  ~HGCalTBCheckGunPostion() override;
46 
47  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
48 
49 private:
50  void beginStream(edm::StreamID) override {}
51  bool filter(edm::Event&, const edm::EventSetup&) override;
52  void endStream() override {}
53 
54  void beginRun(edm::Run const&, edm::EventSetup const&) override {}
55  void endRun(edm::Run const&, edm::EventSetup const&) override {}
57  void endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) override {}
58 
59  // ----------member data ---------------------------
60 
64 };
65 
66 //
67 // constants, enums and typedefs
68 //
69 
70 //
71 // static data member definitions
72 //
73 
74 //
75 // constructors and destructor
76 //
78  // now do what ever initialization is needed
79  edm::InputTag tmp0 = iConfig.getParameter<edm::InputTag>("HepMCProductLabel");
80  verbosity_ = iConfig.getUntrackedParameter<bool>("Verbosity", false);
81  method2_ = iConfig.getUntrackedParameter<bool>("Method2", false);
82  hepMCproductLabel_ = consumes<edm::HepMCProduct>(tmp0);
83 
84  // hexside = 7; //cm - check it
85  tan30deg_ = 0.5773502693;
86  hexwidth_ = 6.185;
87  hexside_ = 2.0 * hexwidth_ * tan30deg_;
88 }
89 
91 
92 //
93 // member functions
94 //
95 
96 // ------------ method called on each new Event ------------
99  iEvent.getByToken(hepMCproductLabel_, hepmc);
100 #ifdef DebugLog
101  if (verbosity_)
102  edm::LogVerbatim("HGCSim") << "isHandle valid: " << isHandle valid;
103 #endif
104  double x(0), y(0);
105 
106  if (hepmc.isValid()) {
107  const HepMC::GenEvent* Evt = hepmc->GetEvent();
108 
109 #ifdef DebugLog
110  if (verbosity_)
111  edm::LogVerbatim("HGCSim") << "vertex " << Evt->vertices_size();
112 #endif
113  for (HepMC::GenEvent::vertex_const_iterator p = Evt->vertices_begin(); p != Evt->vertices_end(); ++p) {
114  x = (*p)->position().x() / 10.; // in cm
115  y = (*p)->position().y() / 10.; // in cm
116 #ifdef DebugLog
117  z = (*p)->position().z() / 10.; // in cm
118  if (verbosity_)
119  edm::LogVerbatim("HGCSim") << " x: " << (*p)->position().x() << ":" << x << " y: " << (*p)->position().y()
120  << ":" << y << " z: " << (*p)->position().z() << ":" << z;
121 #endif
122  }
123  } // if (genEventInfoHandle.isValid())
124 
125  bool flag(false);
126  if (method2_) {
127  bool cond1 = y == 0 && x >= (-hexside_ * sqrt(3) / 2.);
128  bool cond2 = ((y + hexside_) >= -x / sqrt(3)) && (y < 0 && x < 0);
129  bool cond3 = (y * sqrt(3) >= (x - hexside_ * sqrt(3))) && (y < 0 && x > 0);
130  bool cond4 = y == 0 && x <= (hexside_ * sqrt(3) / 2.);
131  bool cond5 = (-y * sqrt(3) >= (x - hexside_ * sqrt(3))) && (y > 0 && x > 0);
132  bool cond6 = ((y - hexside_) <= x / sqrt(3)) && (y > 0 && x < 0);
133  flag = cond1 || cond2 || cond3 || cond4 || cond5 || cond6;
134  } else {
135  double absx = std::abs(x);
136  double absy = std::abs(y);
137  if (absx <= hexwidth_ && absy <= hexside_) {
138  if (absy <= hexwidth_ * tan30deg_ || absx <= (2. * hexwidth_ - absy / tan30deg_))
139  flag = true;
140  }
141  }
142 
143 #ifdef DebugLog
144  if (verbosity_)
145  edm::LogVerbatim("HGCSim") << "Selection Flag " << flag;
146 #endif
147  return flag;
148 }
149 
150 // ------------ method fills 'descriptions' with the allowed parameters for the
151 // module ------------
153  // The following says we do not know what parameters are allowed so do no
154  // validation
155  // Please change this to state exactly what you do use, even if it is no
156  // parameters
158  desc.setUnknown();
159  descriptions.addDefault(desc);
160 }
161 
162 // define this as a plug-in
edm::StreamID
Definition: StreamID.h:30
DDAxes::y
HGCalTBCheckGunPostion::beginRun
void beginRun(edm::Run const &, edm::EventSetup const &) override
Definition: HGCalTBCheckGunPosition.cc:54
HGCalTBCheckGunPostion::endRun
void endRun(edm::Run const &, edm::EventSetup const &) override
Definition: HGCalTBCheckGunPosition.cc:55
MessageLogger.h
HGCalTBCheckGunPostion::hepMCproductLabel_
edm::EDGetTokenT< edm::HepMCProduct > hepMCproductLabel_
Definition: HGCalTBCheckGunPosition.cc:61
edm::LuminosityBlock
Definition: LuminosityBlock.h:50
edm::Run
Definition: Run.h:45
edm::EDGetTokenT< edm::HepMCProduct >
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
HGCalTBCheckGunPostion::tan30deg_
double tan30deg_
Definition: HGCalTBCheckGunPosition.cc:63
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
DDAxes::x
edm::Handle< edm::HepMCProduct >
HGCalTBCheckGunPostion::endStream
void endStream() override
Definition: HGCalTBCheckGunPosition.cc:52
HGCalTBCheckGunPostion::endLuminosityBlock
void endLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &) override
Definition: HGCalTBCheckGunPosition.cc:57
HepMC::GenEvent
Definition: hepmc_rootio.cc:9
HGCalTBCheckGunPostion::method2_
bool method2_
Definition: HGCalTBCheckGunPosition.cc:62
MakerMacros.h
HGCalTBCheckGunPostion::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: HGCalTBCheckGunPosition.cc:152
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
DDAxes::z
HGCalTBCheckGunPostion::filter
bool filter(edm::Event &, const edm::EventSetup &) override
Definition: HGCalTBCheckGunPosition.cc:97
HGCalTBCheckGunPostion::hexwidth_
double hexwidth_
Definition: HGCalTBCheckGunPosition.cc:63
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
HGCalTBCheckGunPostion::hexside_
double hexside_
Definition: HGCalTBCheckGunPosition.cc:63
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
HGCalTBCheckGunPostion::beginLuminosityBlock
void beginLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &) override
Definition: HGCalTBCheckGunPosition.cc:56
iEvent
int iEvent
Definition: GenABIO.cc:224
HGCalTBCheckGunPostion
Definition: HGCalTBCheckGunPosition.cc:42
edm::EventSetup
Definition: EventSetup.h:58
edm::HepMCProduct::GetEvent
const HepMC::GenEvent * GetEvent() const
Definition: HepMCProduct.h:37
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
Frameworkfwd.h
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
HGCalTBCheckGunPostion::verbosity_
bool verbosity_
Definition: HGCalTBCheckGunPosition.cc:62
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
EDFilter.h
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
RunInfoPI::valid
Definition: RunInfoPayloadInspectoHelper.h:16
ParameterSet.h
HGCalTBCheckGunPostion::HGCalTBCheckGunPostion
HGCalTBCheckGunPostion(const edm::ParameterSet &)
Definition: HGCalTBCheckGunPosition.cc:77
HepMCProduct.h
HGCalTBCheckGunPostion::~HGCalTBCheckGunPostion
~HGCalTBCheckGunPostion() override
Definition: HGCalTBCheckGunPosition.cc:90
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
edm::stream::EDFilter
Definition: EDFilter.h:38
edm::Event
Definition: Event.h:73
edm::ConfigurationDescriptions::addDefault
void addDefault(ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:99
StreamID.h
edm::InputTag
Definition: InputTag.h:15
HGCalTBCheckGunPostion::beginStream
void beginStream(edm::StreamID) override
Definition: HGCalTBCheckGunPosition.cc:50
RemoveAddSevLevel.flag
flag
Definition: RemoveAddSevLevel.py:116