38 #include <unordered_map> 60 std::vector<CTPPSLocalTrackLite> &out_tracks,
65 static bool isPixelHit(
float xLocalCoordinate,
float yLocalCoordinate,
bool is3x2 =
true)
67 float tmpXlocalCoordinate = xLocalCoordinate + (79*0.1 + 0.2);
68 float tmpYlocalCoordinate = yLocalCoordinate + (0.15*51 + 0.3*2 + 0.15*25);
70 if(tmpXlocalCoordinate<0)
return false;
71 if(tmpYlocalCoordinate<0)
return false;
72 int xModuleSize = 0.1*79 + 0.2*2 + 0.1*79;
74 if (is3x2) yModuleSize = 0.15*51 + 0.3*2 + 0.15*50 + 0.3*2 + 0.15*51;
75 else yModuleSize = 0.15*51 + 0.3*2 + 0.15*51;
76 if(tmpXlocalCoordinate>xModuleSize)
return false;
77 if(tmpYlocalCoordinate>yModuleSize)
return false;
133 pitchStrips_( iConfig.getParameter<double>(
"pitchStrips" ) ),
139 verbosity_( iConfig.getUntrackedParameter<unsigned
int>(
"verbosity", 0 ) )
142 produces<std::vector<CTPPSLocalTrackLite>>();
146 produces<edm::DetSetVector<TotemRPRecHit>>();
147 produces<edm::DetSetVector<CTPPSDiamondRecHit>>();
148 produces<edm::DetSetVector<CTPPSPixelRecHit>>();
178 std::unique_ptr<std::vector<CTPPSLocalTrackLite>> pTracks(
new std::vector<CTPPSLocalTrackLite>());
182 for (
auto it_vtx = evt->vertices_begin(); it_vtx != evt->vertices_end(); ++it_vtx )
184 auto vtx = *( it_vtx );
187 for (
auto it_part =
vtx->particles_out_const_begin(); it_part !=
vtx->particles_out_const_end(); ++it_part )
189 auto part = *( it_part );
192 if (
part->pdg_id() != 2212 )
195 if (
part->status() != 1 &&
part->status() < 83 )
198 processProton(
vtx,
part, *geometry, *hBeamParameters, *hOpticalFunctions, *pTracks, *pStripRecHits, *pPixelRecHits, *pDiamondRecHits);
224 std::stringstream ssLog;
227 const HepMC::FourVector& vtx_cms = in_vtx->position();
228 const HepMC::FourVector& mom_cms = in_trk->momentum();
231 HepMC::FourVector vtx_lhc(-vtx_cms.x(), vtx_cms.y(), -vtx_cms.z(), vtx_cms.t());
232 HepMC::FourVector mom_lhc(-mom_cms.x(), mom_cms.y(), -mom_cms.z(), mom_cms.t());
235 unsigned int arm = 3;
237 double beamMomentum = 0.;
239 double empiricalAperture_xi0, empiricalAperture_a;
259 const double p = mom_lhc.rho();
260 const double xi = 1. - p / beamMomentum;
261 const double th_x_phys = mom_lhc.x() /
p;
262 const double th_y_phys = mom_lhc.y() /
p;
263 const double vtx_lhc_eff_x = vtx_lhc.x() - vtx_lhc.z() * (mom_lhc.x() / mom_lhc.z() + xangle);
264 const double vtx_lhc_eff_y = vtx_lhc.y() - vtx_lhc.z() * (mom_lhc.y() / mom_lhc.z());
268 ssLog <<
"simu: xi = " << xi <<
", th_x_phys = " << th_x_phys <<
", th_y_phys = " << th_y_phys
269 <<
", vtx_lhc_eff_x = " << vtx_lhc_eff_x <<
", vtx_lhc_eff_y = " << vtx_lhc_eff_y << std::endl;
275 const double xi_th = empiricalAperture_xi0 + th_x_phys * empiricalAperture_a;
280 ssLog <<
"stop because of empirical appertures";
281 edm::LogInfo(
"CTPPSDirectProtonSimulation") << ssLog.str();
289 for (
const auto &ofp : opticalFunctions)
292 const unsigned int rpDecId = rpId.
arm()*100 + rpId.
station()*10 + rpId.
rp();
295 if (rpId.
arm() != arm)
299 ssLog <<
" RP " << rpDecId << std::endl;
304 ofp.second.transport(k_in, k_out,
true);
306 double b_x = k_out.
x * 1E1, b_y = k_out.
y * 1E1;
307 double a_x = k_out.
th_x, a_y = k_out.
th_y;
315 ofp.second.transport(k_be_in, k_be_out,
true);
317 a_x -= k_be_out.
th_x; a_y -= k_be_out.
th_y;
318 b_x -= k_be_out.
x * 1E1; b_y -= k_be_out.
y * 1E1;
321 const double z_scoringPlane = ofp.second.getScoringPlaneZ() * 1E1;
325 ssLog <<
" proton transported: a_x = " << a_x <<
" rad, a_y = " << a_y <<
" rad, b_x = " << b_x <<
326 " mm, b_y = " << b_y <<
" mm, z = " << z_scoringPlane <<
" mm" << std::endl;
331 out_tracks.emplace_back(rpId.
rawId(), b_x, 0., b_y, 0., 0., 0., 0., 0., 0.,
CTPPSpixelLocalTrackReconstructionInfo::invalid, 0, 0., 0.);
344 CLHEP::Hep3Vector gl_o = geometry.
localToGlobal(detId, CLHEP::Hep3Vector(0, 0, 0));
345 CLHEP::Hep3Vector gl_a1 = geometry.
localToGlobal(detId, CLHEP::Hep3Vector(1, 0, 0)) - gl_o;
346 CLHEP::Hep3Vector gl_a2 = geometry.
localToGlobal(detId, CLHEP::Hep3Vector(0, 1, 0)) - gl_o;
350 A(0, 0) = a_x;
A(0, 1) = -gl_a1.x();
A(0, 2) = -gl_a2.x();
B(0) = gl_o.x() - b_x;
351 A(1, 0) = a_y;
A(1, 1) = -gl_a1.y();
A(1, 2) = -gl_a2.y();
B(1) = gl_o.y() - b_y;
352 A(2, 0) = z_sign;
A(2, 1) = -gl_a1.z();
A(2, 2) = -gl_a2.z();
B(2) = gl_o.z() - z_scoringPlane;
359 CLHEP::Hep3Vector h_glo(a_x * ze + b_x, a_y * ze + b_y, z_sign*ze + z_scoringPlane);
362 CLHEP::Hep3Vector h_loc = geometry.
globalToLocal(detId, h_glo);
367 <<
" de z = " <<
P(0) <<
" mm, p1 = " <<
P(1) <<
" mm, p2 = " <<
P(2) <<
" mm" << std::endl
368 <<
" h_glo: x = " << h_glo.x() <<
" mm, y = " << h_glo.y() <<
" mm, z = " << h_glo.z() <<
" mm" << std::endl
369 <<
" h_loc: c1 = " << h_loc.x() <<
" mm, c2 = " << h_loc.y() <<
" mm, c3 = " << h_loc.z() <<
" mm" << std::endl;
375 double u = h_loc.x();
376 double v = h_loc.y();
379 ssLog <<
" u=" << u <<
", v=" <<
v;
385 ssLog <<
" | no hit" << std::endl;
398 ssLog <<
" | strip=" <<
strip;
404 ssLog <<
" | m=" << v <<
", sigma=" << sigma << std::endl;
413 throw cms::Exception(
"CTPPSDirectProtonSimulation") <<
"Diamonds are not yet supported.";
422 ssLog <<
" pixel plane " << pixelDetId.
plane() <<
": local hit x = " << h_loc.x()
423 <<
" mm, y = " << h_loc.y() <<
" mm, z = " << h_loc.z() <<
" mm" << std::endl;
436 ssLog <<
" hit accepted: m1 = " << h_loc.x() <<
" mm, m2 = " << h_loc.y() <<
" mm" << std::endl;
441 const LocalPoint lp(h_loc.x(), h_loc.y(), h_loc.z());
451 edm::LogInfo(
"CTPPSDirectProtonSimulation") << ssLog.str();
461 desc.
add<
bool>(
"produceScoringPlaneHits",
true);
462 desc.
add<
bool>(
"produceRecHits",
true);
463 desc.
add<
bool>(
"useEmpiricalApertures",
false);
464 desc.
add<
double>(
"empiricalAperture45_xi0", 0.);
465 desc.
add<
double>(
"empiricalAperture45_a", 0.);
466 desc.
add<
double>(
"empiricalAperture56_xi0", 0.);
467 desc.
add<
double>(
"empiricalAperture56_a", 0.);
468 desc.
add<
bool>(
"produceHitsRelativeToBeam",
false);
469 desc.
add<
bool>(
"roundToPitch",
true);
470 desc.
add<
bool>(
"checkIsHit",
true);
471 desc.
add<
double>(
"pitchStrips", 66.e-3);
472 desc.
add<
double>(
"insensitiveMarginStrips", 34.e-3);
473 desc.
add<
double>(
"pitchPixelsHor", 100.e-3)->setComment(
"x in local coordinates, in mm");
474 desc.
add<
double>(
"pitchPixelsVer", 150.e-3)->setComment(
"y in local coordinates, in mm");
476 descriptions.
add(
"ctppsDirectProtonSimulation", desc);
double pitchStrips_
strip pitch in mm
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
void push_back(const T &t)
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
double empiricalAperture56_xi0_
double empiricalAperture56_a_
bool produceScoringPlaneHits_
flags what output to be produced
constexpr uint32_t rawId() const
get the raw id
static bool IsHit(double u, double v, double insensitiveMargin=0)
static const unsigned short no_of_strips_
void produce(edm::Event &, const edm::EventSetup &) override
static bool isPixelHit(float xLocalCoordinate, float yLocalCoordinate, bool is3x2=true)
reference find_or_insert(det_id_type id)
edm::EDGetTokenT< edm::HepMCProduct > hepMCToken_
input tag
static const double y_width_
double empiricalAperture45_a_
#define DEFINE_FWK_MODULE(type)
~CTPPSDirectProtonSimulation() override
bool produceHitsRelativeToBeam_
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
Reconstructed hit in TOTEM RP.
double getBeamMom56() const
double insensitiveMarginStrips_
size of insensitive margin at sensor's edge facing the beam, in mm
double getHalfXangleX56() const
static const std::string B
CLHEP::Hep3Vector localToGlobal(const DetGeomDesc *, const CLHEP::Hep3Vector &) const
ParameterDescriptionBase * add(U const &iLabel, T const &value)
proton kinematics description
bool useEmpiricalApertures_
bool checkApertures_
simulation parameters
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
The manager class for TOTEM RP geometry.
static const double last_strip_to_border_dist_
const HepMC::GenEvent * GetEvent() const
void add(std::string const &label, ParameterSetDescription const &psetDescription)
std::pair< OmniClusterRef, TrackingParticleRef > P
Base class for CTPPS detector IDs.
double stripZeroPosition_
internal variable: v position of strip 0, in mm
double empiricalAperture45_xi0_
ESHandle< TrackerGeometry > geometry
Event setup record containing the misaligned geometry information. It is used for alignment studies o...
static const double pitch_
double getBeamMom45() const
void processProton(const HepMC::GenVertex *in_vtx, const HepMC::GenParticle *in_trk, const CTPPSGeometry &geometry, const CTPPSBeamParameters &beamParameters, const LHCInterpolatedOpticalFunctionsSetCollection &opticalFunctions, std::vector< CTPPSLocalTrackLite > &out_tracks, edm::DetSetVector< TotemRPRecHit > &out_strip_hits, edm::DetSetVector< CTPPSPixelRecHit > &out_pixel_hits, edm::DetSetVector< CTPPSDiamondRecHit > &out_diamond_hits) const
const std::set< unsigned int > & getSensorsInRP(unsigned int) const
after checks returns set of sensor ids corresponding to the given RP id
double getHalfXangleX45() const
CLHEP::Hep3Vector globalToLocal(const DetGeomDesc *, const CLHEP::Hep3Vector &) const
CTPPSDirectProtonSimulation(const edm::ParameterSet &)