CMS 3D CMS Logo

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

#include <CTPPSHector.h>

Public Types

typedef CLHEP::HepLorentzVector LorentzVector
 

Public Member Functions

void add (const HepMC::GenEvent *ev, const edm::EventSetup &es, CLHEP::HepRandomEngine *engine)
 
HepMC::GenEvent * addPartToHepMC (HepMC::GenEvent *event)
 
void ApplyBeamCorrection (LorentzVector &, CLHEP::HepRandomEngine *engine)
 
void clear ()
 
void clearApertureFlags ()
 
 CTPPSHector (const edm::ParameterSet &ps, bool verbosity, bool CTPPSTransport)
 
void filterCTPPS (TRandom3 *)
 
double get_BeamEnergy ()
 
double get_BeamMomentum ()
 
std::vector< LHCTransportLink > & getCorrespondenceMap ()
 
int getDirect (unsigned int part_n) const
 
void LorentzBoost (LorentzVector &p_out, const string &frame)
 
void print () const
 
void set_BeamEnergy (double e)
 
virtual ~CTPPSHector ()
 

Private Attributes

string beam1filename
 
string beam2filename
 
double etacut
 
double fBeamEnergy
 
double fBeamMomentum
 
bool fCrossAngleCorr
 
double fCrossingAngle
 
double fMomentumMin
 
double fVtxMeanX
 
double fVtxMeanY
 
double fVtxMeanZ
 
double lengthctpps
 
float m_b_ctpps_b
 
std::unique_ptr< H_BeamLine > m_beamlineCTPPS1
 
std::unique_ptr< H_BeamLine > m_beamlineCTPPS2
 
std::map< unsigned int, H_BeamParticle * > m_beamPart
 
bool m_CTPPSTransport
 
std::map< unsigned int, int > m_direct
 
std::map< unsigned int, double > m_eAtTrPoint
 
std::map< unsigned int, double > m_eta
 
float m_f_ctpps_f
 
std::map< unsigned int, bool > m_isCharged
 
std::map< unsigned int, bool > m_isStoppedctpps
 
std::map< unsigned int, int > m_pdg
 
std::map< unsigned int, double > m_pz
 
double m_sig_e
 
double m_sigmaSTX
 
double m_sigmaSTY
 
bool m_smearAng
 
bool m_smearE
 
std::map< unsigned int, double > m_TxAtTrPoint
 
std::map< unsigned int, double > m_TyAtTrPoint
 
bool m_verbosity
 
std::map< unsigned int, double > m_xAtTrPoint
 
std::map< unsigned int, double > m_yAtTrPoint
 
int NEvent
 
edm::ESHandle< ParticleDataTablepdt
 
std::vector< LHCTransportLinktheCorrespondenceMap
 

Detailed Description

Definition at line 39 of file CTPPSHector.h.

Member Typedef Documentation

typedef CLHEP::HepLorentzVector CTPPSHector::LorentzVector

Definition at line 46 of file CTPPSHector.h.

Constructor & Destructor Documentation

CTPPSHector::CTPPSHector ( const edm::ParameterSet ps,
bool  verbosity,
bool  CTPPSTransport 
)

Definition at line 20 of file CTPPSHector.cc.

References beam1filename, beam2filename, etacut, fBeamEnergy, fCrossAngleCorr, fCrossingAngle, objects.autophobj::float, fMomentumMin, fVtxMeanX, fVtxMeanY, fVtxMeanZ, edm::ParameterSet::getParameter(), lengthctpps, LogDebug, m_b_ctpps_b, m_beamlineCTPPS1, m_beamlineCTPPS2, m_CTPPSTransport, m_f_ctpps_f, m_sig_e, m_sigmaSTX, m_sigmaSTY, m_smearAng, m_smearE, m_verbosity, and theCorrespondenceMap.

20  :
21  m_smearAng(false),m_sig_e(0.),m_smearE(false),m_sigmaSTX(0.),m_sigmaSTY(0.),
23  fVtxMeanX(0.),fVtxMeanY(0.),fVtxMeanZ(0.),fMomentumMin(0.),
26 
27 {
28  // Create LHC beam line
29  edm::ParameterSet hector_par = param.getParameter<edm::ParameterSet>("CTPPSHector");
30 
31  // User definitons
32  lengthctpps = hector_par.getParameter<double>("BeamLineLengthCTPPS" );
33  m_f_ctpps_f = (float) hector_par.getParameter<double>("CTPPSf");
34  m_b_ctpps_b = (float) hector_par.getParameter<double>("CTPPSb");
35 
36  beam1filename = hector_par.getParameter<string>("Beam1");
37  beam2filename = hector_par.getParameter<string>("Beam2");
38  m_smearAng = hector_par.getParameter<bool>("smearAng");
39  m_sigmaSTX = hector_par.getParameter<double>("sigmaSTX" );
40  m_sigmaSTY = hector_par.getParameter<double>("sigmaSTY" );
41  m_smearE = hector_par.getParameter<bool>("smearEnergy");
42  m_sig_e = hector_par.getParameter<double>("sigmaEnergy");
43  etacut = hector_par.getParameter<double>("EtaCutForHector" );
44  //CTPPS
45  fCrossAngleCorr = hector_par.getParameter<bool>("CrossAngleCorr");
46  fCrossingAngle = hector_par.getParameter<double>("CrossingAngle");
47  fBeamEnergy = hector_par.getParameter<double>("BeamEnergy"); // beam energy in GeV
48  fVtxMeanX = hector_par.getParameter<double>("VtxMeanX");
49  fVtxMeanY = hector_par.getParameter<double>("VtxMeanY");
50  fVtxMeanZ = hector_par.getParameter<double>("VtxMeanZ");
51  fMomentumMin = hector_par.getParameter<double>("MomentumMin");
52 
53  theCorrespondenceMap.clear();
54 
55  if(m_verbosity) {
56  edm::LogInfo("CTPPSHectorSetup") << "===================================================================\n"
57  << " * * * * * * * * * * * * * * * * * * * * * * * * * * * * \n"
58  << " * * \n"
59  << " * --<--<-- A fast simulator --<--<-- * \n"
60  << " * | --<--<-- of particle --<--<-- * \n"
61  << " * ----HECTOR----< * \n"
62  << " * | -->-->-- transport through-->-->-- * \n"
63  << " * -->-->-- generic beamlines -->-->-- * \n"
64  << " * * \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"
68  << " * * \n"
69  << " * Center for Cosmology, Particle Physics and Phenomenology * \n"
70  << " * Universite catholique de Louvain * \n"
71  << " * Louvain-la-Neuve, Belgium * \n"
72  << " * * \n"
73  << " * * * * * * * * * * * * * * * * * * * * * * * * * * * * \n"
74  << " CTPPSHector configuration: \n"
75  << " m_CTPPSTransport = " << m_CTPPSTransport << "\n"
76  << " lengthctpps = " << lengthctpps << "\n"
77  << " m_f_ctpps_f = " << m_f_ctpps_f << "\n"
78  << " m_b_ctpps_b = " << m_b_ctpps_b << "\n"
79  << "===================================================================\n";
80  }
81  edm::FileInPath b1(beam1filename.c_str());
82  edm::FileInPath b2(beam2filename.c_str());
83 
84  // construct beam line for CTPPS (forward 1 backward 2):
85  if(m_CTPPSTransport && lengthctpps>0. ) {
86  m_beamlineCTPPS1 = std::unique_ptr<H_BeamLine>(new H_BeamLine( -1, lengthctpps + 0.1 )); // (direction, length)
87  m_beamlineCTPPS2 = std::unique_ptr<H_BeamLine>(new H_BeamLine( 1, lengthctpps + 0.1 )); //
88  m_beamlineCTPPS1->fill( b2.fullPath(), 1, "IP5" );
89  m_beamlineCTPPS2->fill( b1.fullPath(), 1, "IP5" );
90  m_beamlineCTPPS1->offsetElements( 120, 0.097 );
91  m_beamlineCTPPS2->offsetElements( 120, 0.097 );
92  m_beamlineCTPPS1->calcMatrix();
93  m_beamlineCTPPS2->calcMatrix();
94  } else {
95  if ( m_verbosity ) LogDebug("CTPPSHectorSetup") << "CTPPSHector: WARNING: lengthctpps= " << lengthctpps;
96  }
97 }
#define LogDebug(id)
T getParameter(std::string const &) const
CTPPSTransport
HepMC source to be processed.
double fBeamMomentum
Definition: CTPPSHector.h:94
bool m_verbosity
Definition: CTPPSHector.h:124
double m_sigmaSTY
Definition: CTPPSHector.h:87
bool m_smearAng
Definition: CTPPSHector.h:83
string beam1filename
Definition: CTPPSHector.h:121
bool m_CTPPSTransport
Definition: CTPPSHector.h:125
double etacut
Definition: CTPPSHector.h:82
double fVtxMeanX
Definition: CTPPSHector.h:96
double fVtxMeanY
Definition: CTPPSHector.h:97
double fVtxMeanZ
Definition: CTPPSHector.h:98
double lengthctpps
Definition: CTPPSHector.h:80
float m_f_ctpps_f
Definition: CTPPSHector.h:88
double fMomentumMin
Definition: CTPPSHector.h:99
bool m_smearE
Definition: CTPPSHector.h:85
double fCrossingAngle
Definition: CTPPSHector.h:93
std::vector< LHCTransportLink > theCorrespondenceMap
Definition: CTPPSHector.h:127
float m_b_ctpps_b
Definition: CTPPSHector.h:89
double m_sigmaSTX
Definition: CTPPSHector.h:86
double fBeamEnergy
Definition: CTPPSHector.h:95
std::unique_ptr< H_BeamLine > m_beamlineCTPPS1
Definition: CTPPSHector.h:104
std::unique_ptr< H_BeamLine > m_beamlineCTPPS2
Definition: CTPPSHector.h:105
bool fCrossAngleCorr
Definition: CTPPSHector.h:92
string beam2filename
Definition: CTPPSHector.h:122
double m_sig_e
Definition: CTPPSHector.h:84
CTPPSHector::~CTPPSHector ( )
virtual

Definition at line 99 of file CTPPSHector.cc.

References m_beamPart.

99  {
100 
101  for (std::map<unsigned int,H_BeamParticle*>::iterator it = m_beamPart.begin(); it != m_beamPart.end(); ++it ) {
102  delete (*it).second;
103  }
104 
105 }
std::map< unsigned int, H_BeamParticle * > m_beamPart
Definition: CTPPSHector.h:107

Member Function Documentation

void CTPPSHector::add ( const HepMC::GenEvent *  ev,
const edm::EventSetup es,
CLHEP::HepRandomEngine *  engine 
)

Adds the stable protons from the event ev to a beamline

Definition at line 123 of file CTPPSHector.cc.

References funct::abs(), ApplyBeamCorrection(), ALCARECOTkAlJpsiMuMu_cff::charge, cm_to_m, cm_to_um, MillePedeFileConverter_cfg::e, etacut, fCrossAngleCorr, fMomentumMin, fVtxMeanX, fVtxMeanY, fVtxMeanZ, g, GenParticle::GenParticle, edm::EventSetup::getData(), geometryCSVtoXML::line, LogDebug, LorentzBoost(), m_beamPart, m_direct, m_eta, m_isCharged, m_pdg, m_pz, m_verbosity, ResonanceBuilder::mass, pdt, funct::pow(), and mathSSE::sqrt().

Referenced by CTPPSHectorProducer::produce(), and counter.Counter::register().

123  {
124 
125  H_BeamParticle* h_p = nullptr;
126  unsigned int line;
127 
128  for (HepMC::GenEvent::particle_const_iterator eventParticle =evt->particles_begin();
129  eventParticle != evt->particles_end();
130  ++eventParticle ) {
131  if ( (*eventParticle)->status() == 1 && (*eventParticle)->pdg_id()==2212 ){
132  if ( abs( (*eventParticle)->momentum().eta())>etacut && abs( (*eventParticle)->momentum().pz())>fMomentumMin){
133  line = (*eventParticle)->barcode();
134  if ( m_beamPart.find(line) == m_beamPart.end() ) {
135  double charge=1.;
136  m_isCharged[line] = false;// neutrals
137  HepMC::GenParticle * g = (*eventParticle);
138  iSetup.getData( pdt );
139  const ParticleData * part = pdt->particle( g->pdg_id() );
140  if (part){
141  charge = part->charge();
142  }
143  if(charge !=0) m_isCharged[line] = true;//charged
144  double mass = (*eventParticle)->generatedMass();
145 
146  h_p = new H_BeamParticle(mass,charge);
147 
148  double px,py,pz,e;
149  double TXforPosition=0.0, TYforPosition=0.0;//urad
150 
151  px = (*eventParticle)->momentum().px();
152  py = (*eventParticle)->momentum().py();
153  pz = (*eventParticle)->momentum().pz();
154 
155  e = sqrt(pow(mass,2)+pow(px,2)+pow(py,2)+pow(pz,2));
156 
157  // Apply Beam and Crossing Angle Corrections
158  LorentzVector p_out(px,py,pz,e);
159  ApplyBeamCorrection(p_out, engine);
160  if (fCrossAngleCorr) LorentzBoost(const_cast<LorentzVector&>(p_out),"LAB");
161 
162  // from mm to cm
163  double XforPosition = (*eventParticle)->production_vertex()->position().x()/cm;//cm
164  double YforPosition = (*eventParticle)->production_vertex()->position().y()/cm;//cm
165  double ZforPosition = (*eventParticle)->production_vertex()->position().z()/cm;//cm
166 
167  if(m_verbosity) LogDebug("CTPPSHectorEventProcessing") << " fVtxMeanX: " << fVtxMeanX << " fVtxMeanY: " << fVtxMeanY << " fVtxMeanZ: " << fVtxMeanZ ;
168  // It is important to set the Position before the 4Momentum otherwise HECTOR resets variables
169  h_p->setPosition(-(XforPosition-fVtxMeanX)*cm_to_um,(YforPosition-fVtxMeanY)*cm_to_um,TXforPosition,TYforPosition,-(ZforPosition)*cm_to_m);
170 
171  h_p->set4Momentum( -p_out.px(), p_out.py(), -p_out.pz(), p_out.e() );
172 
173  m_beamPart[line] = h_p;
174  m_direct[line] = 0;
175  m_direct[line] = ( pz > 0 ) ? 1 : -1;
176 
177  m_eta[line] = (*eventParticle)->momentum().eta();
178  m_pdg[line] = (*eventParticle)->pdg_id();
179  m_pz[line] = (*eventParticle)->momentum().pz();
180 
181  if(m_verbosity) {
182  LogDebug("CTPPSHectorEventProcessing") << "CTPPSHector:add: barcode = " << line
183  << " status = " << g->status()
184  << " PDG Id = " << g->pdg_id()
185  << " mass = " << mass
186  << " pz = " << pz
187  << " charge = " << charge
188  << " m_isCharged[line] = " << m_isCharged[line];
189  }
190  }// if find line
191  }// if eta > 8.2
192  }// if status
193  }// for loop
194 
195 }
#define LogDebug(id)
bool m_verbosity
Definition: CTPPSHector.h:124
std::map< unsigned int, int > m_pdg
Definition: CTPPSHector.h:117
std::map< unsigned int, double > m_pz
Definition: CTPPSHector.h:118
std::map< unsigned int, int > m_direct
Definition: CTPPSHector.h:108
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
Definition: Activities.doc:4
std::map< unsigned int, H_BeamParticle * > m_beamPart
Definition: CTPPSHector.h:107
double etacut
Definition: CTPPSHector.h:82
edm::ESHandle< ParticleDataTable > pdt
Definition: CTPPSHector.h:101
double fVtxMeanX
Definition: CTPPSHector.h:96
T sqrt(T t)
Definition: SSEVec.h:18
double fVtxMeanY
Definition: CTPPSHector.h:97
double fVtxMeanZ
Definition: CTPPSHector.h:98
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
math::XYZTLorentzVector LorentzVector
double fMomentumMin
Definition: CTPPSHector.h:99
HepPDT::ParticleData ParticleData
std::map< unsigned int, double > m_eta
Definition: CTPPSHector.h:116
const double cm_to_m
std::map< unsigned int, bool > m_isCharged
Definition: CTPPSHector.h:119
part
Definition: HCALResponse.h:20
const double cm_to_um
bool fCrossAngleCorr
Definition: CTPPSHector.h:92
void LorentzBoost(LorentzVector &p_out, const string &frame)
Definition: CTPPSHector.cc:305
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
void ApplyBeamCorrection(LorentzVector &, CLHEP::HepRandomEngine *engine)
Definition: CTPPSHector.cc:281
HepMC::GenEvent * CTPPSHector::addPartToHepMC ( HepMC::GenEvent *  event)

Definition at line 345 of file CTPPSHector.cc.

References funct::cos(), GenParticle::GenParticle, geometryCSVtoXML::line, LogDebug, m_b_ctpps_b, m_beamPart, m_CTPPSTransport, m_direct, m_eAtTrPoint, m_f_ctpps_f, m_isStoppedctpps, m_TxAtTrPoint, m_TyAtTrPoint, m_verbosity, m_xAtTrPoint, m_yAtTrPoint, NEvent, pi, ProtonMassSQ, edm::second(), funct::sin(), mathSSE::sqrt(), theCorrespondenceMap, theta(), and ntuplemaker::time.

Referenced by get_BeamMomentum(), and CTPPSHectorProducer::produce().

345  {
346  NEvent++;
347  theCorrespondenceMap.clear();
348 
349  unsigned int line;
350 
351  HepMC::GenParticle * gpart;
352  long double tx,ty,theta,fi,energy,time = 0;
353  std::map< unsigned int, H_BeamParticle* >::iterator it;
354 
355  for (it = m_beamPart.begin(); it != m_beamPart.end(); ++it ) {
356  line = (*it).first;
358  if(m_verbosity) {
359  LogDebug("CTPPSHectorEventProcessing") << "CTPPSHector:addPartToHepMC: barcode = " << line << "\n"
360  << "CTPPSHector:addPartToHepMC: isStoppedctpps=" << (*m_isStoppedctpps.find(line)).second;
361  }
362  if (!((*m_isStoppedctpps.find(line)).second)){
363 
364  gpart = evt->barcode_to_particle( line );
365  if ( gpart ) {
366  tx = (*m_TxAtTrPoint.find(line)).second / 1000000.;
367  ty = (*m_TyAtTrPoint.find(line)).second / 1000000.;
368  theta = sqrt((tx*tx) + (ty*ty));
369  double ddd = 0.;
370  long double fi_ = 0.;
371  if ( !((*m_isStoppedctpps.find(line)).second)) {
372  if( (*m_direct.find( line )).second >0 ) {
373  ddd = m_f_ctpps_f;
374  fi_ = std::atan2(tx,ty); // tx, ty never == 0?
375  }
376  else if((*m_direct.find( line )).second <0 ) {
377  ddd = m_b_ctpps_b;
378  theta= CLHEP::pi-theta;
379  fi_ = std::atan2(tx,ty); // tx, ty never == 0?
380  }
381  }
382  fi = fi_;
383  energy = (*m_eAtTrPoint.find(line)).second;
384  time = ( ddd*meter - gpart->production_vertex()->position().z()*mm ); // mm
385 
386  if(ddd != 0.) {
387  if(m_verbosity) {
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;
392  }
393 
394  HepMC::GenVertex * vert = new HepMC::GenVertex( HepMC::FourVector( (*(m_xAtTrPoint.find(line))).second*0.001,
395  (*(m_yAtTrPoint.find(line))).second*0.001,
396  ddd * (*(m_direct.find( line ))).second*1000.,
397  time + .001*time ) );
398 
399  gpart->set_status( 2 );
400  vert->add_particle_in( gpart );
401  double Pmom = sqrt(energy*energy - ProtonMassSQ);
402  vert->add_particle_out( new HepMC::GenParticle( HepMC::FourVector(Pmom*std::sin(theta)*std::sin(fi),
403  Pmom*std::sin(theta)*std::cos(fi),
404  Pmom*std::cos(theta),
405  energy ),gpart->pdg_id(), 1, gpart->flow() ) );
406  evt->add_vertex( vert );
407 
408  int ingoing = (*vert->particles_in_const_begin())->barcode();
409  int outgoing = (*vert->particles_out_const_begin())->barcode();
410  LHCTransportLink theLink(ingoing,outgoing);
411  if (m_verbosity) LogDebug("CTPPSHectorEventProcessing") << "CTPPSHector:addPartToHepMC: LHCTransportLink " << theLink;
412  theCorrespondenceMap.push_back(theLink);
413 
414  if(m_verbosity) LogDebug("CTPPSHectorEventProcessing") << "CTPPSHector::TRANSPORTED pz= " << gpart->momentum().pz()
415  << " eta= "<< gpart->momentum().eta() << " status= "<< gpart->status();
416  }// ddd
417  }// if gpart
418  }// if !isStopped
419 
420  else {
421  gpart = evt->barcode_to_particle( line );
422  if ( gpart ) {
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();
426  }
427  }
428  }//for
429 
430  return evt;
431 }
#define LogDebug(id)
bool m_verbosity
Definition: CTPPSHector.h:124
std::map< unsigned int, double > m_eAtTrPoint
Definition: CTPPSHector.h:114
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
std::map< unsigned int, double > m_yAtTrPoint
Definition: CTPPSHector.h:111
Geom::Theta< T > theta() const
std::map< unsigned int, int > m_direct
Definition: CTPPSHector.h:108
const Double_t pi
std::map< unsigned int, H_BeamParticle * > m_beamPart
Definition: CTPPSHector.h:107
U second(std::pair< T, U > const &p)
bool m_CTPPSTransport
Definition: CTPPSHector.h:125
std::map< unsigned int, bool > m_isStoppedctpps
Definition: CTPPSHector.h:109
T sqrt(T t)
Definition: SSEVec.h:18
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
float m_f_ctpps_f
Definition: CTPPSHector.h:88
const double ProtonMassSQ
std::vector< LHCTransportLink > theCorrespondenceMap
Definition: CTPPSHector.h:127
float m_b_ctpps_b
Definition: CTPPSHector.h:89
std::map< unsigned int, double > m_TxAtTrPoint
Definition: CTPPSHector.h:112
std::map< unsigned int, double > m_xAtTrPoint
Definition: CTPPSHector.h:110
std::map< unsigned int, double > m_TyAtTrPoint
Definition: CTPPSHector.h:113
void CTPPSHector::ApplyBeamCorrection ( LorentzVector p_out,
CLHEP::HepRandomEngine *  engine 
)

Definition at line 281 of file CTPPSHector.cc.

References funct::cos(), MillePedeFileConverter_cfg::e, m_sig_e, m_sigmaSTX, m_sigmaSTY, m_smearAng, m_smearE, AlCaHLTBitMon_ParallelJobs::p, pi, ProtonMassSQ, funct::sin(), mathSSE::sqrt(), and theta().

Referenced by add(), and get_BeamMomentum().

282 {
283 
284  double microrad = 1.e-6;
285  double theta = p_out.theta(); if (p_out.pz()<0) theta=CLHEP::pi-theta;
286  double dtheta_x = (double)(m_smearAng)?CLHEP::RandGauss::shoot(engine,0.,m_sigmaSTX):0;
287  double dtheta_y = (double)(m_smearAng)?CLHEP::RandGauss::shoot(engine,0.,m_sigmaSTY):0;
288  double denergy = (double)(m_smearE)?CLHEP::RandGauss::shoot(engine,0.,m_sig_e):0.;
289 
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);
294 
295  if (p_out.pz()<0) pz*=-1;
296 
297  double e = sqrt(px*px+py*py+pz*pz+ProtonMassSQ);
298  p_out.setPx(px);
299  p_out.setPy(py);
300  p_out.setPz(pz);
301  p_out.setE(e);
302 
303 }
double m_sigmaSTY
Definition: CTPPSHector.h:87
bool m_smearAng
Definition: CTPPSHector.h:83
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Geom::Theta< T > theta() const
const Double_t pi
T sqrt(T t)
Definition: SSEVec.h:18
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
bool m_smearE
Definition: CTPPSHector.h:85
const double ProtonMassSQ
double m_sigmaSTX
Definition: CTPPSHector.h:86
double m_sig_e
Definition: CTPPSHector.h:84
void CTPPSHector::clear ( void  )

Clears BeamParticle, prepares CTPPSHector for a next Aperture check or/and a next event

Definition at line 111 of file CTPPSHector.cc.

References m_beamPart, m_direct, m_eta, m_isCharged, m_pdg, and m_pz.

Referenced by CTPPSHectorProducer::produce().

111  {
112  for ( std::map<unsigned int,H_BeamParticle*>::iterator it = m_beamPart.begin(); it != m_beamPart.end(); ++it ) {
113  delete (*it).second;
114  };
115  m_beamPart.clear();
116  m_direct.clear();
117  m_eta.clear();
118  m_pdg.clear();
119  m_pz.clear();
120  m_isCharged.clear();
121 }
std::map< unsigned int, int > m_pdg
Definition: CTPPSHector.h:117
std::map< unsigned int, double > m_pz
Definition: CTPPSHector.h:118
std::map< unsigned int, int > m_direct
Definition: CTPPSHector.h:108
std::map< unsigned int, H_BeamParticle * > m_beamPart
Definition: CTPPSHector.h:107
std::map< unsigned int, double > m_eta
Definition: CTPPSHector.h:116
std::map< unsigned int, bool > m_isCharged
Definition: CTPPSHector.h:119
void CTPPSHector::clearApertureFlags ( )

Clears ApertureFlags, prepares CTPPSHector for a next event

Definition at line 107 of file CTPPSHector.cc.

References m_isStoppedctpps.

Referenced by CTPPSHectorProducer::produce().

107  {
108  m_isStoppedctpps.clear();
109 }
std::map< unsigned int, bool > m_isStoppedctpps
Definition: CTPPSHector.h:109
void CTPPSHector::filterCTPPS ( TRandom3 *  rootEngine)

propagate the particles through a beamline to CTPPS

Definition at line 197 of file CTPPSHector.cc.

References lengthctpps, geometryCSVtoXML::line, LogDebug, m_b_ctpps_b, m_beamlineCTPPS1, m_beamlineCTPPS2, m_beamPart, m_direct, m_eAtTrPoint, m_f_ctpps_f, m_isCharged, m_isStoppedctpps, m_TxAtTrPoint, m_TyAtTrPoint, m_verbosity, m_xAtTrPoint, m_yAtTrPoint, and edm::second().

Referenced by CTPPSHectorProducer::produce().

197  {
198 
199  unsigned int line;
200  H_BeamParticle * part = nullptr;
201 
202  std::map< unsigned int, H_BeamParticle* >::iterator it;
203 
204  bool is_stop;
205  int direction;
206 
207  float x1_ctpps;
208  float y1_ctpps;
209 
210  if ( !m_beamPart.empty() && lengthctpps>0. ) {
211 
212  for (it = m_beamPart.begin(); it != m_beamPart.end(); ++it ) {
213  line = (*it).first;
214  part = (*it).second;
215 
216  if(m_verbosity) LogDebug("CTPPSHectorEventProcessing") << "CTPPSHector:filterCTPPS: barcode = " << line;
217  if ( (*m_isCharged.find( line )).second ) {
218  direction = (*m_direct.find( line )).second;
219  if ( direction == 1 && m_beamlineCTPPS1 != nullptr ) {
220 
221  part->computePath(&*m_beamlineCTPPS1);
222 
223  is_stop = part->stopped(&* m_beamlineCTPPS1 );
224  if(m_verbosity) LogDebug("CTPPSHectorEventProcessing") << "CTPPSHector:filterCTPPS: barcode = " << line << " positive is_stop= "<< is_stop;
225  }
226  else if ( direction == -1 && m_beamlineCTPPS2 != nullptr ){
227 
228  part->computePath(&*m_beamlineCTPPS2 );
229 
230  is_stop = part->stopped(&*m_beamlineCTPPS2 );
231  if(m_verbosity) LogDebug("CTPPSHectorEventProcessing") << "CTPPSHector:filterCTPPS: barcode = " << line << " negative is_stop= "<< is_stop;
232  }
233  else {
234  is_stop = true;
235  if(m_verbosity) LogDebug("CTPPSHectorEventProcessing") << "CTPPSHector:filterCTPPS: barcode = " << line << " 0 is_stop= "<< is_stop;
236  }
237 
238  //propagating
239  m_isStoppedctpps[line] = is_stop;
240  if(m_verbosity) LogDebug("CTPPSHectorEventProcessing") << "CTPPSHector:filterCTPPS: barcode = " << line << " isStopped=" << (*m_isStoppedctpps.find(line)).second;
241 
242  if (!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;
248 
249  m_xAtTrPoint[line] = x1_ctpps;
250  m_yAtTrPoint[line] = y1_ctpps;
251  m_TxAtTrPoint[line] = -part->getTX();
252  m_TyAtTrPoint[line] = part->getTY();
253  m_eAtTrPoint[line] = part->getE();
254 
255  }
256  }// if isCharged
257  else {
258  m_isStoppedctpps[line] = true;// imply that neutral particles stopped to reach 420m
259  if(m_verbosity) LogDebug("CTPPSHectorEventProcessing") << "CTPPSHector:filterCTPPS: barcode = " << line << " isStopped=" << (*m_isStoppedctpps.find(line)).second;
260  }
261 
262  } // for (it = m_beamPart.begin(); it != m_beamPart.end(); it++ )
263  } // if ( m_beamPart.size() )
264 
265 }//
#define LogDebug(id)
bool m_verbosity
Definition: CTPPSHector.h:124
std::map< unsigned int, double > m_eAtTrPoint
Definition: CTPPSHector.h:114
std::map< unsigned int, double > m_yAtTrPoint
Definition: CTPPSHector.h:111
std::map< unsigned int, int > m_direct
Definition: CTPPSHector.h:108
std::map< unsigned int, H_BeamParticle * > m_beamPart
Definition: CTPPSHector.h:107
U second(std::pair< T, U > const &p)
std::map< unsigned int, bool > m_isStoppedctpps
Definition: CTPPSHector.h:109
double lengthctpps
Definition: CTPPSHector.h:80
float m_f_ctpps_f
Definition: CTPPSHector.h:88
std::map< unsigned int, bool > m_isCharged
Definition: CTPPSHector.h:119
float m_b_ctpps_b
Definition: CTPPSHector.h:89
part
Definition: HCALResponse.h:20
std::map< unsigned int, double > m_TxAtTrPoint
Definition: CTPPSHector.h:112
std::map< unsigned int, double > m_xAtTrPoint
Definition: CTPPSHector.h:110
std::unique_ptr< H_BeamLine > m_beamlineCTPPS1
Definition: CTPPSHector.h:104
std::map< unsigned int, double > m_TyAtTrPoint
Definition: CTPPSHector.h:113
std::unique_ptr< H_BeamLine > m_beamlineCTPPS2
Definition: CTPPSHector.h:105
double CTPPSHector::get_BeamEnergy ( )
inline

Definition at line 63 of file CTPPSHector.h.

References fBeamEnergy.

63 {return fBeamEnergy;};
double fBeamEnergy
Definition: CTPPSHector.h:95
double CTPPSHector::get_BeamMomentum ( )
inline

Definition at line 65 of file CTPPSHector.h.

References addPartToHepMC(), ApplyBeamCorrection(), fBeamMomentum, getDirect(), and print().

65 {return fBeamMomentum;};
double fBeamMomentum
Definition: CTPPSHector.h:94
std::vector<LHCTransportLink>& CTPPSHector::getCorrespondenceMap ( )
inline

Definition at line 76 of file CTPPSHector.h.

References theCorrespondenceMap.

Referenced by CTPPSHectorProducer::produce().

76 { return theCorrespondenceMap; }
std::vector< LHCTransportLink > theCorrespondenceMap
Definition: CTPPSHector.h:127
int CTPPSHector::getDirect ( unsigned int  part_n) const

Definition at line 267 of file CTPPSHector.cc.

References m_direct.

Referenced by get_BeamMomentum().

267  {
268  std::map<unsigned int, int>::const_iterator it = m_direct.find( part_n );
269  if ( it != m_direct.end() ){
270  return (*it).second;
271  }
272  return 0;
273 }
std::map< unsigned int, int > m_direct
Definition: CTPPSHector.h:108
void CTPPSHector::LorentzBoost ( LorentzVector p_out,
const string &  frame 
)

Definition at line 305 of file CTPPSHector.cc.

References funct::cos(), fCrossingAngle, p4, funct::sin(), and funct::tan().

Referenced by add().

306 {
307  // Use a matrix
308  double microrad = 1.e-6;
309  TMatrixD tmpboost(4,4);
310  double alpha_ = 0.;
311  double phi_ = fCrossingAngle*microrad;
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_);
318  tmpboost(1,1) = 1.;
319  tmpboost(1,2) = cos(alpha_)*tan(phi_);
320  tmpboost(1,3) = 0.;
321  tmpboost(2,0) = 0.;
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_);
326  tmpboost(3,1) = 0.;
327  tmpboost(3,2) = sin(alpha_)*tan(phi_);
328  tmpboost(3,3) = 1.;
329 
330  if(frame=="LAB") tmpboost.Invert();
331 
332  TMatrixD p4(4,1);
333  p4(0,0) = p_out.e();
334  p4(1,0) = p_out.px();
335  p4(2,0) = p_out.py();
336  p4(3,0) = p_out.pz();
337  TMatrixD p4lab(4,1);
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));
343 }
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
double p4[4]
Definition: TauolaWrapper.h:92
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
double fCrossingAngle
Definition: CTPPSHector.h:93
void CTPPSHector::print ( void  ) const

Prints properties of all particles in a beamline

Definition at line 275 of file CTPPSHector.cc.

References m_beamPart.

Referenced by get_BeamMomentum().

275  {
276  for (std::map<unsigned int,H_BeamParticle*>::const_iterator it = m_beamPart.begin(); it != m_beamPart.end(); ++it ) {
277  (*it).second->printProperties();
278  };
279 }
std::map< unsigned int, H_BeamParticle * > m_beamPart
Definition: CTPPSHector.h:107
void CTPPSHector::set_BeamEnergy ( double  e)
inline

Member Data Documentation

string CTPPSHector::beam1filename
private

Definition at line 121 of file CTPPSHector.h.

Referenced by CTPPSHector().

string CTPPSHector::beam2filename
private

Definition at line 122 of file CTPPSHector.h.

Referenced by CTPPSHector().

double CTPPSHector::etacut
private

Definition at line 82 of file CTPPSHector.h.

Referenced by add(), and CTPPSHector().

double CTPPSHector::fBeamEnergy
private

Definition at line 95 of file CTPPSHector.h.

Referenced by CTPPSHector(), get_BeamEnergy(), and set_BeamEnergy().

double CTPPSHector::fBeamMomentum
private

Definition at line 94 of file CTPPSHector.h.

Referenced by get_BeamMomentum(), and set_BeamEnergy().

bool CTPPSHector::fCrossAngleCorr
private

Definition at line 92 of file CTPPSHector.h.

Referenced by add(), and CTPPSHector().

double CTPPSHector::fCrossingAngle
private

Definition at line 93 of file CTPPSHector.h.

Referenced by CTPPSHector(), and LorentzBoost().

double CTPPSHector::fMomentumMin
private

Definition at line 99 of file CTPPSHector.h.

Referenced by add(), and CTPPSHector().

double CTPPSHector::fVtxMeanX
private

Definition at line 96 of file CTPPSHector.h.

Referenced by add(), and CTPPSHector().

double CTPPSHector::fVtxMeanY
private

Definition at line 97 of file CTPPSHector.h.

Referenced by add(), and CTPPSHector().

double CTPPSHector::fVtxMeanZ
private

Definition at line 98 of file CTPPSHector.h.

Referenced by add(), and CTPPSHector().

double CTPPSHector::lengthctpps
private

Definition at line 80 of file CTPPSHector.h.

Referenced by CTPPSHector(), and filterCTPPS().

float CTPPSHector::m_b_ctpps_b
private

Definition at line 89 of file CTPPSHector.h.

Referenced by addPartToHepMC(), CTPPSHector(), and filterCTPPS().

std::unique_ptr<H_BeamLine> CTPPSHector::m_beamlineCTPPS1
private

Definition at line 104 of file CTPPSHector.h.

Referenced by CTPPSHector(), and filterCTPPS().

std::unique_ptr<H_BeamLine> CTPPSHector::m_beamlineCTPPS2
private

Definition at line 105 of file CTPPSHector.h.

Referenced by CTPPSHector(), and filterCTPPS().

std::map<unsigned int, H_BeamParticle*> CTPPSHector::m_beamPart
private

Definition at line 107 of file CTPPSHector.h.

Referenced by add(), addPartToHepMC(), clear(), filterCTPPS(), print(), and ~CTPPSHector().

bool CTPPSHector::m_CTPPSTransport
private

Definition at line 125 of file CTPPSHector.h.

Referenced by addPartToHepMC(), and CTPPSHector().

std::map<unsigned int, int> CTPPSHector::m_direct
private

Definition at line 108 of file CTPPSHector.h.

Referenced by add(), addPartToHepMC(), clear(), filterCTPPS(), and getDirect().

std::map<unsigned int, double> CTPPSHector::m_eAtTrPoint
private

Definition at line 114 of file CTPPSHector.h.

Referenced by addPartToHepMC(), and filterCTPPS().

std::map<unsigned int, double> CTPPSHector::m_eta
private

Definition at line 116 of file CTPPSHector.h.

Referenced by add(), and clear().

float CTPPSHector::m_f_ctpps_f
private

Definition at line 88 of file CTPPSHector.h.

Referenced by addPartToHepMC(), CTPPSHector(), and filterCTPPS().

std::map<unsigned int, bool> CTPPSHector::m_isCharged
private

Definition at line 119 of file CTPPSHector.h.

Referenced by add(), clear(), and filterCTPPS().

std::map<unsigned int, bool> CTPPSHector::m_isStoppedctpps
private

Definition at line 109 of file CTPPSHector.h.

Referenced by addPartToHepMC(), clearApertureFlags(), and filterCTPPS().

std::map<unsigned int, int> CTPPSHector::m_pdg
private

Definition at line 117 of file CTPPSHector.h.

Referenced by add(), and clear().

std::map<unsigned int, double> CTPPSHector::m_pz
private

Definition at line 118 of file CTPPSHector.h.

Referenced by add(), and clear().

double CTPPSHector::m_sig_e
private

Definition at line 84 of file CTPPSHector.h.

Referenced by ApplyBeamCorrection(), and CTPPSHector().

double CTPPSHector::m_sigmaSTX
private

Definition at line 86 of file CTPPSHector.h.

Referenced by ApplyBeamCorrection(), and CTPPSHector().

double CTPPSHector::m_sigmaSTY
private

Definition at line 87 of file CTPPSHector.h.

Referenced by ApplyBeamCorrection(), and CTPPSHector().

bool CTPPSHector::m_smearAng
private

Definition at line 83 of file CTPPSHector.h.

Referenced by ApplyBeamCorrection(), and CTPPSHector().

bool CTPPSHector::m_smearE
private

Definition at line 85 of file CTPPSHector.h.

Referenced by ApplyBeamCorrection(), and CTPPSHector().

std::map<unsigned int, double> CTPPSHector::m_TxAtTrPoint
private

Definition at line 112 of file CTPPSHector.h.

Referenced by addPartToHepMC(), and filterCTPPS().

std::map<unsigned int, double> CTPPSHector::m_TyAtTrPoint
private

Definition at line 113 of file CTPPSHector.h.

Referenced by addPartToHepMC(), and filterCTPPS().

bool CTPPSHector::m_verbosity
private

Definition at line 124 of file CTPPSHector.h.

Referenced by add(), addPartToHepMC(), CTPPSHector(), and filterCTPPS().

std::map<unsigned int, double> CTPPSHector::m_xAtTrPoint
private

Definition at line 110 of file CTPPSHector.h.

Referenced by addPartToHepMC(), and filterCTPPS().

std::map<unsigned int, double> CTPPSHector::m_yAtTrPoint
private

Definition at line 111 of file CTPPSHector.h.

Referenced by addPartToHepMC(), and filterCTPPS().

int CTPPSHector::NEvent
private

Definition at line 128 of file CTPPSHector.h.

Referenced by addPartToHepMC().

edm::ESHandle< ParticleDataTable > CTPPSHector::pdt
private

Definition at line 101 of file CTPPSHector.h.

Referenced by add().

std::vector<LHCTransportLink> CTPPSHector::theCorrespondenceMap
private

Definition at line 127 of file CTPPSHector.h.

Referenced by addPartToHepMC(), CTPPSHector(), and getCorrespondenceMap().