CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
CTPPSSimHitProducer Class Reference

#include <FastSimulation/CTPPSSimHitProducer/plugins/CTPPSSimHitProducer.cc>

Inheritance diagram for CTPPSSimHitProducer:
edm::stream::EDProducer<>

Public Member Functions

 CTPPSSimHitProducer (const edm::ParameterSet &)
 
 ~CTPPSSimHitProducer () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 

Private Member Functions

void beginStream (edm::StreamID) override
 
void endStream () override
 
void produce (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

edm::Handle< edm::HepMCProductEvtHandle
 
double fz_timing
 
double fz_tracker1
 
double fz_tracker2
 
edm::EDGetTokenT< edm::HepMCProductmcEventToken
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Detailed Description

Description: [one line class summary]

Implementation: [Notes on implementation]

Definition at line 57 of file CTPPSSimHitProducer.cc.

Constructor & Destructor Documentation

CTPPSSimHitProducer::CTPPSSimHitProducer ( const edm::ParameterSet iConfig)
explicit

Definition at line 87 of file CTPPSSimHitProducer.cc.

References fz_timing, fz_tracker1, fz_tracker2, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), mcEventToken, and AlCaHLTBitMon_QueryRunRegistry::string.

88 {
89 
90  produces<edm::PSimHitContainer>("CTPPSHits");
91  // consumes
92  mcEventToken = mayConsume<edm::HepMCProduct>(iConfig.getUntrackedParameter<edm::InputTag>("MCEvent",std::string("")));
93 
94  // Read the position of the trackers and timing detectors
95  fz_tracker1 = iConfig.getParameter<double>("Z_Tracker1");
96  fz_tracker2 = iConfig.getParameter<double>("Z_Tracker2");
97  fz_timing = iConfig.getParameter<double>("Z_Timing");
98 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
edm::EDGetTokenT< edm::HepMCProduct > mcEventToken
CTPPSSimHitProducer::~CTPPSSimHitProducer ( )
override

Definition at line 100 of file CTPPSSimHitProducer.cc.

101 {
102 
103 }

Member Function Documentation

void CTPPSSimHitProducer::beginStream ( edm::StreamID  )
overrideprivate

Definition at line 216 of file CTPPSSimHitProducer.cc.

217 {
218 }
void CTPPSSimHitProducer::endStream ( )
overrideprivate

Definition at line 222 of file CTPPSSimHitProducer.cc.

References DEFINE_FWK_MODULE.

222  {
223 }
void CTPPSSimHitProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 112 of file CTPPSSimHitProducer.cc.

References funct::abs(), c_light_s, EvtHandle, fz_timing, fz_tracker2, edm::Event::getByToken(), edm::HepMCProduct::GetEvent(), mps_fire::i, m_to_mm, mcEventToken, mm_to_m, eostools::move(), gen::n, AlCaHLTBitMon_ParallelJobs::p, sysUtil::pid, edm::Event::put(), MetAnalyzer::pv(), and s_to_ns.

Referenced by JSONExport.JsonExport::export(), HTMLExport.HTMLExport::export(), and HTMLExport.HTMLExportStatic::export().

113 {
114  using namespace edm;
115 
116  std::vector<PSimHit> theCTPPSHits;
117  iEvent.getByToken( mcEventToken , EvtHandle );
118 
119  const HepMC::GenEvent* Evt = EvtHandle->GetEvent() ;
120  std::vector<math::XYZTLorentzVector> protonCTPPS;
121  protonCTPPS.clear();
122  for(HepMC::GenEvent::vertex_const_iterator ivtx = Evt->vertices_begin();ivtx!=Evt->vertices_end();ivtx++) {
123  if ((*ivtx)->id()!=0) continue;
124  double prim_vtxZ=(*ivtx)->position().z()*mm_to_m; //in meters
125  // Get the vertices at the entrance of CTPPS and get the protons coming out of them (propagated by Hector)
126  for(HepMC::GenVertex::particles_out_const_iterator i=(*ivtx)->particles_out_const_begin(); i != (*ivtx)->particles_out_const_end();++i) {
127  int pid = (*i)->pdg_id();
128  if(pid!=2212) continue;
129 
130  HepMC::GenVertex* pv = (*i)->production_vertex();
131  const HepMC::FourVector& vertex = pv->position();
132  const HepMC::FourVector p((*i)->momentum());
133  protonCTPPS.push_back(math::XYZTLorentzVector(p.x(),p.y(),p.z(),p.t()));
134 
135  LocalPoint initialPosition_tr1, initialPosition_tr2, initialPosition_tof;
136 
137  double t0_tr1 = 0., t0_tr2 = 0., t0_tof = 0.;
138  // t0_* has dimensions of mm
139  // Convert to ns for internal calculations.
140  const double c_light_s = 2.99792458e+11;// mm/s;
141  const double s_to_ns = 1.e9;
142  const double m_to_mm = 1.e3;
143  double x_tr1 = 0. , x_tr2 = 0. , x_tof = 0., y_tr1 = 0. , y_tr2 = 0. , y_tof = 0., z_tr1 = 0.;
144  double z_tr2 = fz_tracker2; //m
145  double z_tof = fz_timing; //m
146  int Direction =0;
147 
148  // Read the vertex made by SimTransport at the entrance of det1
149  if(std::abs(vertex.eta())>8. && (*i)->status() == 1){
150  if (vertex.z()>0) Direction = 1;
151  else if (vertex.z() < 0 ) Direction = -1;
152 
153  //Get the global coordinates at Tracker1, equal to those of the vertex at CTPPS
154  x_tr1 = vertex.x();
155  y_tr1 = vertex.y();
156  z_tr1 = vertex.z()*mm_to_m;//move z from mm to meters
157  Local3DPoint xyzzy_tr1(x_tr1, y_tr1, z_tr1);
158  initialPosition_tr1 = xyzzy_tr1;
159  t0_tr1 = vertex.t()/c_light_s*s_to_ns;
160  //Get the global coordinates at Tracker2 by propagating as a straight line from Tracker1
161  t0_tr2 = z_tr2*m_to_mm/c_light_s*s_to_ns;//discuss latter if needs to be corrected with vertex position
162  t0_tr2 = t0_tr1+(z_tr2-z_tr1)*m_to_mm/c_light_s*s_to_ns;//corrected with vertex position
163  z_tr2 *= Direction;
164  x_tr2 = x_tr1 + (p.x()/p.z())*(z_tr2-z_tr1)*m_to_mm;
165  y_tr2 = y_tr1 + (p.y()/p.z())*(z_tr2-z_tr1)*m_to_mm;
166  Local3DPoint xyzzy_tr2(x_tr2, y_tr2, z_tr2);
167  initialPosition_tr2 = xyzzy_tr2;
168  //Propagate as a straight line from Tracker1
169  t0_tof = z_tof*m_to_mm/c_light_s*s_to_ns;//discuss latter if needs to be corrected with vertex position
170  t0_tof = (z_tof-prim_vtxZ)*m_to_mm/c_light_s*s_to_ns;//corrected with vertex position
171  z_tof *= Direction;
172  x_tof = x_tr1 + (p.x()/p.z())*(z_tof-z_tr1)*m_to_mm;
173  y_tof = y_tr1 + (p.y()/p.z())*(z_tof-z_tr1)*m_to_mm;
174  Local3DPoint xyzzy_tof(x_tof, y_tof, z_tof);
175  initialPosition_tof = xyzzy_tof;
176 
177  // DetId codification for PSimHit from CTPPSPixel- It will be replaced by CTPPSDetId
178  // 2014314496 -> Tracker1 zPositive
179  // 2014838784 -> Tracker2 zPositive
180  // 2046820352 -> Timing zPositive
181  // 2031091712 -> Tracker1 zNegative
182  // 2031616000 -> Tracker2 zNegative
183  // 2063597568 -> Timing zNegative
184 
185  if(Direction > 0.) {
186  PSimHit hit_tr1(xyzzy_tr1,xyzzy_tr1,0.,t0_tr1,0.,pid,2014314496,0,0.,0.,2);
187  PSimHit hit_tr2(xyzzy_tr2,xyzzy_tr2,0.,t0_tr2,0.,pid,2014838784,0,0.,0.,2);
188  PSimHit hit_tof(xyzzy_tof,xyzzy_tof,0.,t0_tof,0.,pid,2046820352,0,0.,0.,2);
189  theCTPPSHits.push_back(hit_tr1);
190  theCTPPSHits.push_back(hit_tr2);
191  theCTPPSHits.push_back(hit_tof);
192  }
193  if(Direction < 0.) {
194  PSimHit hit_tr1(xyzzy_tr1,xyzzy_tr1,0.,t0_tr1,0.,pid,2031091712,0,0.,0.,2);
195  PSimHit hit_tr2(xyzzy_tr2,xyzzy_tr2,0.,t0_tr2,0.,pid,2031616000,0,0.,0.,2);
196  PSimHit hit_tof(xyzzy_tof,xyzzy_tof,0.,t0_tof,0.,pid,2063597568,0,0.,0.,2);
197  theCTPPSHits.push_back(hit_tr1);
198  theCTPPSHits.push_back(hit_tr2);
199  theCTPPSHits.push_back(hit_tof);
200  }
201  }
202  }
203  }
204  std::unique_ptr<edm::PSimHitContainer> pctpps(new edm::PSimHitContainer);
205  int n = 0;
206  for ( std::vector<PSimHit>::const_iterator i = theCTPPSHits.begin();
207  i != theCTPPSHits.end(); i++ ) {
208  pctpps->push_back(*i);
209  n += 1;
210  }
211  iEvent.put(std::move(pctpps),"CTPPSHits");
212 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
static const double c_light_s
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
edm::Handle< edm::HepMCProduct > EvtHandle
static const double s_to_ns
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
edm::EDGetTokenT< edm::HepMCProduct > mcEventToken
def pv(vc)
Definition: MetAnalyzer.py:7
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const HepMC::GenEvent * GetEvent() const
Definition: HepMCProduct.h:38
static const double m_to_mm
HLT enums.
static const double mm_to_m
std::vector< PSimHit > PSimHitContainer
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

edm::Handle< edm::HepMCProduct > CTPPSSimHitProducer::EvtHandle
private

Definition at line 68 of file CTPPSSimHitProducer.cc.

Referenced by produce().

double CTPPSSimHitProducer::fz_timing
private

Definition at line 70 of file CTPPSSimHitProducer.cc.

Referenced by CTPPSSimHitProducer(), and produce().

double CTPPSSimHitProducer::fz_tracker1
private

Definition at line 70 of file CTPPSSimHitProducer.cc.

Referenced by CTPPSSimHitProducer().

double CTPPSSimHitProducer::fz_tracker2
private

Definition at line 70 of file CTPPSSimHitProducer.cc.

Referenced by CTPPSSimHitProducer(), and produce().

edm::EDGetTokenT< edm::HepMCProduct > CTPPSSimHitProducer::mcEventToken
private

Definition at line 67 of file CTPPSSimHitProducer.cc.

Referenced by CTPPSSimHitProducer(), and produce().