40 #include "HepMC/GenEvent.h" 41 #include "HepMC/GenVertex.h" 42 #include "HepMC/GenParticle.h" 52 #include <CLHEP/Vector/LorentzVector.h> 92 produces<edm::PSimHitContainer>(
"CTPPSHits");
118 std::vector<PSimHit> theCTPPSHits;
122 std::vector<math::XYZTLorentzVector> protonCTPPS;
124 for(HepMC::GenEvent::vertex_const_iterator ivtx = Evt->vertices_begin();ivtx!=Evt->vertices_end();ivtx++) {
125 if ((*ivtx)->id()!=0)
continue;
128 for(HepMC::GenVertex::particles_out_const_iterator
i=(*ivtx)->particles_out_const_begin();
i != (*ivtx)->particles_out_const_end();++
i) {
129 int pid = (*i)->pdg_id();
130 if(pid!=2212)
continue;
132 HepMC::GenVertex*
pv = (*i)->production_vertex();
133 HepMC::FourVector vertex = pv->position();
134 const HepMC::FourVector
p((*i)->momentum());
137 LocalPoint initialPosition_tr1, initialPosition_tr2, initialPosition_tof;
139 double t0_tr1 = 0., t0_tr2 = 0., t0_tof = 0.;
145 double x_tr1 = 0. , x_tr2 = 0. , x_tof = 0., y_tr1 = 0. , y_tr2 = 0. , y_tof = 0., z_tr1 = 0.;
151 if(
std::abs(vertex.eta())>8. && (*i)->status() == 1){
152 if (vertex.z()>0) Direction = 1;
153 else if (vertex.z() < 0 ) Direction = -1;
160 initialPosition_tr1 = xyzzy_tr1;
161 t0_tr1 = vertex.t()/c_light_s*
s_to_ns;
163 t0_tr2 = z_tr2*m_to_mm/c_light_s*
s_to_ns;
165 x_tr2 = x_tr1 + (
p.x()/
p.z())*(z_tr2-z_tr1)*
m_to_mm;
166 y_tr2 = y_tr1 + (
p.y()/
p.z())*(z_tr2-z_tr1)*
m_to_mm;
168 initialPosition_tr2 = xyzzy_tr2;
170 t0_tof = z_tof*m_to_mm/c_light_s*
s_to_ns;
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;
175 initialPosition_tof = xyzzy_tof;
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);
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);
206 for ( std::vector<PSimHit>::const_iterator
i = theCTPPSHits.begin();
207 i != theCTPPSHits.end();
i++ ) {
208 pctpps->push_back(*
i);
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
virtual void produce(edm::Event &, const edm::EventSetup &) override
bool getByToken(EDGetToken token, Handle< PROD > &result) const
virtual void beginStream(edm::StreamID) override
#define DEFINE_FWK_MODULE(type)
edm::Handle< edm::HepMCProduct > EvtHandle
virtual void endStream() override
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
edm::EDGetTokenT< edm::HepMCProduct > mcEventToken
Abs< T >::type abs(const T &t)
CLHEP::HepLorentzVector LorentzVector
const HepMC::GenEvent * GetEvent() const
std::vector< PSimHit > PSimHitContainer
CTPPSSimHitProducer(const edm::ParameterSet &)