7 #include "CLHEP/Units/GlobalSystemOfUnits.h" 8 #include "CLHEP/Units/GlobalPhysicalConstants.h" 9 #include "HepMC/SimpleVector.h" 11 #include "CLHEP/Random/RandGauss.h" 16 #include "H_Parameters.h" 21 m_smearAng(
false),m_sig_e(0.),m_smearE(
false),m_sigmaSTX(0.),m_sigmaSTY(0.),
22 fCrossAngleCorr(
false),fCrossingAngle(0.),fBeamMomentum(0),fBeamEnergy(0),
23 fVtxMeanX(0.),fVtxMeanY(0.),fVtxMeanZ(0.),fMomentumMin(0.),
24 m_verbosity(verbosity),
25 m_CTPPSTransport(CTPPSTransport),NEvent(0)
56 edm::LogInfo(
"CTPPSHectorSetup") <<
"===================================================================\n" 57 <<
" * * * * * * * * * * * * * * * * * * * * * * * * * * * * \n" 59 <<
" * --<--<-- A fast simulator --<--<-- * \n" 60 <<
" * | --<--<-- of particle --<--<-- * \n" 61 <<
" * ----HECTOR----< * \n" 62 <<
" * | -->-->-- transport through-->-->-- * \n" 63 <<
" * -->-->-- generic beamlines -->-->-- * \n" 65 <<
" * JINST 2:P09005 (2007) * \n" 66 <<
" * X Rouby, J de Favereau, K Piotrzkowski (CP3) * \n" 67 <<
" * http://www.fynu.ucl.ac.be/hector.html * \n" 69 <<
" * Center for Cosmology, Particle Physics and Phenomenology * \n" 70 <<
" * Universite catholique de Louvain * \n" 71 <<
" * Louvain-la-Neuve, Belgium * \n" 73 <<
" * * * * * * * * * * * * * * * * * * * * * * * * * * * * \n" 74 <<
" CTPPSHector configuration: \n" 76 <<
" lengthctpps = " << lengthctpps <<
"\n" 77 <<
" m_f_ctpps_f = " << m_f_ctpps_f <<
"\n" 79 <<
"===================================================================\n";
86 m_beamlineCTPPS1 = std::unique_ptr<H_BeamLine>(
new H_BeamLine( -1, lengthctpps + 0.1 ));
87 m_beamlineCTPPS2 = std::unique_ptr<H_BeamLine>(
new H_BeamLine( 1, lengthctpps + 0.1 ));
89 m_beamlineCTPPS2->fill( b1.fullPath(), 1,
"IP5" );
91 m_beamlineCTPPS2->offsetElements( 120, 0.097 );
93 m_beamlineCTPPS2->calcMatrix();
101 for (std::map<unsigned int,H_BeamParticle*>::iterator it =
m_beamPart.begin(); it !=
m_beamPart.end(); ++it ) {
112 for ( std::map<unsigned int,H_BeamParticle*>::iterator it =
m_beamPart.begin(); it !=
m_beamPart.end(); ++it ) {
125 H_BeamParticle* h_p =
NULL;
128 for (HepMC::GenEvent::particle_const_iterator eventParticle =evt->particles_begin();
129 eventParticle != evt->particles_end();
131 if ( (*eventParticle)->status() == 1 && (*eventParticle)->pdg_id()==2212 ){
133 line = (*eventParticle)->barcode();
141 charge = part->charge();
144 double mass = (*eventParticle)->generatedMass();
146 h_p =
new H_BeamParticle(mass,charge);
149 double TXforPosition=0.0, TYforPosition=0.0;
151 px = (*eventParticle)->momentum().px();
152 py = (*eventParticle)->momentum().py();
153 pz = (*eventParticle)->momentum().pz();
163 double XforPosition = (*eventParticle)->production_vertex()->position().x()/cm;
164 double YforPosition = (*eventParticle)->production_vertex()->position().y()/cm;
165 double ZforPosition = (*eventParticle)->production_vertex()->position().z()/cm;
171 h_p->set4Momentum( -p_out.px(), p_out.py(), -p_out.pz(), p_out.e() );
177 m_eta[
line] = (*eventParticle)->momentum().eta();
178 m_pdg[
line] = (*eventParticle)->pdg_id();
179 m_pz[
line] = (*eventParticle)->momentum().pz();
182 LogDebug(
"CTPPSHectorEventProcessing") <<
"CTPPSHector:add: barcode = " << line
183 <<
" status = " << g->status()
184 <<
" PDG Id = " << g->pdg_id()
185 <<
" mass = " << mass
187 <<
" charge = " << charge
202 std::map< unsigned int, H_BeamParticle* >::iterator it;
218 direction = (*
m_direct.find( line )).second;
224 if(
m_verbosity)
LogDebug(
"CTPPSHectorEventProcessing") <<
"CTPPSHector:filterCTPPS: barcode = " << line <<
" positive is_stop= "<< is_stop;
231 if(
m_verbosity)
LogDebug(
"CTPPSHectorEventProcessing") <<
"CTPPSHector:filterCTPPS: barcode = " << line <<
" negative is_stop= "<< is_stop;
235 if(
m_verbosity)
LogDebug(
"CTPPSHectorEventProcessing") <<
"CTPPSHector:filterCTPPS: barcode = " << line <<
" 0 is_stop= "<< is_stop;
243 if ( direction == 1 ) part->propagate(
m_f_ctpps_f );
244 if ( direction == -1 ) part->propagate(
m_b_ctpps_b );
245 x1_ctpps = -part->getX()/millimeter;
246 y1_ctpps = part->getY()/millimeter;
247 if(
m_verbosity)
LogDebug(
"CTPPSHectorEventProcessing") <<
"CTPPSHector:filterCTPPS: barcode = " << line <<
" x= "<< x1_ctpps <<
" y= " << y1_ctpps;
268 std::map<unsigned int, int>::const_iterator it =
m_direct.find( part_n );
276 for (std::map<unsigned int,H_BeamParticle*>::const_iterator it =
m_beamPart.begin(); it !=
m_beamPart.end(); ++it ) {
277 (*it).second->printProperties();
284 double microrad = 1.e-6;
285 double theta = p_out.theta();
if (p_out.pz()<0) theta=
CLHEP::pi-theta;
288 double denergy = (double)(
m_smearE)?CLHEP::RandGauss::shoot(engine,0.,
m_sig_e):0.;
290 double p =
sqrt((p_out.px())*(p_out.px())+(p_out.py())*(p_out.py())+(p_out.pz())*(p_out.pz()));
291 double px = p*
sin(theta+dtheta_x*microrad)*
cos(p_out.phi());
292 double py = p*
sin(theta+dtheta_y*microrad)*
sin(p_out.phi());
293 double pz = p*(
cos(theta)+denergy);
295 if (p_out.pz()<0) pz*=-1;
308 double microrad = 1.e-6;
309 TMatrixD tmpboost(4,4);
312 if (p_out.pz()<0) phi_*=-1;
313 tmpboost(0,0) = 1./
cos(phi_);
314 tmpboost(0,1) = -
cos(alpha_)*
sin(phi_);
315 tmpboost(0,2) = -
tan(phi_)*
sin(phi_);
316 tmpboost(0,3) = -
sin(alpha_)*
sin(phi_);
317 tmpboost(1,0) = -
cos(alpha_)*
tan(phi_);
319 tmpboost(1,2) =
cos(alpha_)*
tan(phi_);
322 tmpboost(2,1) = -
cos(alpha_)*
sin(phi_);
323 tmpboost(2,2) =
cos(phi_);
324 tmpboost(2,3) = -
sin(alpha_)*
sin(phi_);
325 tmpboost(3,0) = -
sin(alpha_)*
tan(phi_);
327 tmpboost(3,2) =
sin(alpha_)*
tan(phi_);
330 if(frame==
"LAB") tmpboost.Invert();
334 p4(1,0) = p_out.px();
335 p4(2,0) = p_out.py();
336 p4(3,0) = p_out.pz();
338 p4lab = tmpboost *
p4;
339 p_out.setPx(p4lab(1,0));
340 p_out.setPy(p4lab(2,0));
341 p_out.setPz(p4lab(3,0));
342 p_out.setE(p4lab(0,0));
352 long double tx,ty,
theta,fi,energy,
time = 0;
353 std::map< unsigned int, H_BeamParticle* >::iterator it;
359 LogDebug(
"CTPPSHectorEventProcessing") <<
"CTPPSHector:addPartToHepMC: barcode = " << line <<
"\n" 364 gpart = evt->barcode_to_particle( line );
368 theta =
sqrt((tx*tx) + (ty*ty));
370 long double fi_ = 0.;
372 if( (*
m_direct.find( line )).second >0 ) {
374 fi_ = std::atan2(tx,ty);
376 else if((*
m_direct.find( line )).second <0 ) {
379 fi_ = std::atan2(tx,ty);
384 time = ( ddd*meter - gpart->production_vertex()->position().z()*mm );
388 LogDebug(
"CTPPSHectorEventProcessing") <<
"CTPPSHector:: x= "<< (*(
m_xAtTrPoint.find(line))).second*0.001<<
"\n" 389 <<
"CTPPSHector:: y= "<< (*(
m_yAtTrPoint.find(line))).second*0.001<<
"\n" 390 <<
"CTPPSHector:: z= "<< ddd * (*(
m_direct.find( line ))).second*1000. <<
"\n" 391 <<
"CTPPSHector:: t= "<<
time;
394 HepMC::GenVertex * vert =
new HepMC::GenVertex( HepMC::FourVector( (*(
m_xAtTrPoint.find(line))).second*0.001,
396 ddd * (*(
m_direct.find( line ))).second*1000.,
397 time + .001*
time ) );
399 gpart->set_status( 2 );
400 vert->add_particle_in( gpart );
405 energy ),gpart->pdg_id(), 1, gpart->flow() ) );
406 evt->add_vertex( vert );
408 int ingoing = (*vert->particles_in_const_begin())->barcode();
409 int outgoing = (*vert->particles_out_const_begin())->barcode();
411 if (
m_verbosity)
LogDebug(
"CTPPSHectorEventProcessing") <<
"CTPPSHector:addPartToHepMC: LHCTransportLink " << theLink;
414 if(
m_verbosity)
LogDebug(
"CTPPSHectorEventProcessing") <<
"CTPPSHector::TRANSPORTED pz= " << gpart->momentum().pz()
415 <<
" eta= "<< gpart->momentum().eta() <<
" status= "<< gpart->status();
421 gpart = evt->barcode_to_particle( line );
423 gpart->set_status( 2 );
424 if(
m_verbosity)
LogDebug(
"CTPPSHectorEventProcessing") <<
"CTPPSHector::NON-transp. pz= " << gpart->momentum().pz()
425 <<
" eta= "<< gpart->momentum().eta() <<
" status= "<< gpart->status();
HepMC::GenEvent * addPartToHepMC(HepMC::GenEvent *event)
T getParameter(std::string const &) const
CTPPSTransport
HepMC source to be processed.
void clearApertureFlags()
std::map< unsigned int, double > m_eAtTrPoint
Sin< T >::type sin(const T &t)
std::map< unsigned int, double > m_yAtTrPoint
Geom::Theta< T > theta() const
std::map< unsigned int, int > m_pdg
std::map< unsigned int, double > m_pz
std::map< unsigned int, int > m_direct
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
void getData(T &iHolder) const
std::map< unsigned int, H_BeamParticle * > m_beamPart
U second(std::pair< T, U > const &p)
edm::ESHandle< ParticleDataTable > pdt
std::map< unsigned int, bool > m_isStoppedctpps
void add(const HepMC::GenEvent *ev, const edm::EventSetup &es, CLHEP::HepRandomEngine *engine)
Cos< T >::type cos(const T &t)
Tan< T >::type tan(const T &t)
Abs< T >::type abs(const T &t)
HepPDT::ParticleData ParticleData
const double ProtonMassSQ
std::map< unsigned int, double > m_eta
std::vector< LHCTransportLink > theCorrespondenceMap
std::map< unsigned int, bool > m_isCharged
int getDirect(unsigned int part_n) const
std::map< unsigned int, double > m_TxAtTrPoint
std::map< unsigned int, double > m_xAtTrPoint
std::unique_ptr< H_BeamLine > m_beamlineCTPPS1
std::map< unsigned int, double > m_TyAtTrPoint
CTPPSHector(const edm::ParameterSet &ps, bool verbosity, bool CTPPSTransport)
std::unique_ptr< H_BeamLine > m_beamlineCTPPS2
void filterCTPPS(TRandom3 *)
CLHEP::HepLorentzVector LorentzVector
void LorentzBoost(LorentzVector &p_out, const string &frame)
Power< A, B >::type pow(const A &a, const B &b)
void ApplyBeamCorrection(LorentzVector &, CLHEP::HepRandomEngine *engine)