41 #include <unordered_map> 65 std::vector<CTPPSLocalTrackLite> &out_tracks,
138 pitchStrips_(iConfig.getParameter<double>(
"pitchStrips")),
144 verbosity_(iConfig.getUntrackedParameter<unsigned
int>(
"verbosity", 0)) {
146 produces<std::vector<CTPPSLocalTrackLite>>();
149 produces<edm::DetSetVector<TotemRPRecHit>>();
150 produces<edm::DetSetVector<CTPPSDiamondRecHit>>();
151 produces<edm::DetSetVector<CTPPSPixelRecHit>>();
153 produces<std::map<int, edm::DetSetVector<TotemRPRecHit>>>();
154 produces<std::map<int, edm::DetSetVector<CTPPSDiamondRecHit>>>();
155 produces<std::map<int, edm::DetSetVector<CTPPSPixelRecHit>>>();
188 auto pStripRecHitsPerParticle = std::make_unique<std::map<int, edm::DetSetVector<TotemRPRecHit>>>();
189 auto pDiamondRecHitsPerParticle = std::make_unique<std::map<int, edm::DetSetVector<CTPPSDiamondRecHit>>>();
190 auto pPixelRecHitsPerParticle = std::make_unique<std::map<int, edm::DetSetVector<CTPPSPixelRecHit>>>();
192 std::unique_ptr<std::vector<CTPPSLocalTrackLite>> pTracks(
new std::vector<CTPPSLocalTrackLite>());
196 for (
auto it_vtx = evt->vertices_begin(); it_vtx != evt->vertices_end(); ++it_vtx) {
197 auto vtx = *(it_vtx);
200 for (
auto it_part =
vtx->particles_out_const_begin(); it_part !=
vtx->particles_out_const_end(); ++it_part) {
201 auto part = *(it_part);
204 if (
part->pdg_id() != 2212)
207 if (
part->status() != 1 &&
part->status() < 83)
220 *pStripRecHitsPerParticle,
221 *pPixelRecHitsPerParticle,
222 *pDiamondRecHitsPerParticle);
243 const HepMC::GenVertex *in_vtx,
249 std::vector<CTPPSLocalTrackLite> &out_tracks,
259 std::stringstream ssLog;
262 const HepMC::FourVector &vtx_cms = in_vtx->position();
263 const HepMC::FourVector &mom_cms = in_trk->momentum();
266 HepMC::FourVector vtx_lhc(-vtx_cms.x(), vtx_cms.y(), -vtx_cms.z(), vtx_cms.t());
267 HepMC::FourVector mom_lhc(-mom_cms.x(), mom_cms.y(), -mom_cms.z(), mom_cms.t());
270 unsigned int arm = 3;
272 double beamMomentum = 0.;
274 double empiricalAperture_xi0_int, empiricalAperture_xi0_slp;
275 double empiricalAperture_a_int, empiricalAperture_a_slp;
299 const double p = mom_lhc.rho();
300 const double xi = 1. - p / beamMomentum;
301 const double th_x_phys = mom_lhc.x() /
p;
302 const double th_y_phys = mom_lhc.y() /
p;
303 const double vtx_lhc_eff_x = vtx_lhc.x() - vtx_lhc.z() * (mom_lhc.x() / mom_lhc.z() +
xangle);
304 const double vtx_lhc_eff_y = vtx_lhc.y() - vtx_lhc.z() * (mom_lhc.y() / mom_lhc.z());
307 ssLog <<
"simu: xi = " << xi <<
", th_x_phys = " << th_x_phys <<
", th_y_phys = " << th_y_phys
308 <<
", vtx_lhc_eff_x = " << vtx_lhc_eff_x <<
", vtx_lhc_eff_y = " << vtx_lhc_eff_y << std::endl;
314 const double xi_th = (empiricalAperture_xi0_int + xangle * empiricalAperture_xi0_slp) +
315 (empiricalAperture_a_int + xangle * empiricalAperture_a_slp) * th_x_phys;
319 ssLog <<
"stop because of empirical appertures";
320 edm::LogInfo(
"CTPPSDirectProtonSimulation") << ssLog.str();
328 for (
const auto &ofp : opticalFunctions) {
330 const unsigned int rpDecId = rpId.
arm() * 100 + rpId.
station() * 10 + rpId.
rp();
333 if (rpId.
arm() != arm)
337 ssLog <<
" RP " << rpDecId << std::endl;
341 vtx_lhc_eff_x * 1E-1, th_x_phys, vtx_lhc_eff_y * 1E-1, th_y_phys, xi};
343 ofp.second.transport(k_in, k_out,
true);
345 double b_x = k_out.
x * 1E1, b_y = k_out.
y * 1E1;
346 double a_x = k_out.
th_x, a_y = k_out.
th_y;
353 ofp.second.transport(k_be_in, k_be_out,
true);
355 a_x -= k_be_out.
th_x;
356 a_y -= k_be_out.
th_y;
357 b_x -= k_be_out.
x * 1E1;
358 b_y -= k_be_out.
y * 1E1;
361 const double z_scoringPlane = ofp.second.getScoringPlaneZ() * 1E1;
364 ssLog <<
" proton transported: a_x = " << a_x <<
" rad, a_y = " << a_y <<
" rad, b_x = " << b_x
365 <<
" mm, b_y = " << b_y <<
" mm, z = " << z_scoringPlane <<
" mm" << std::endl;
370 out_tracks.emplace_back(
371 rpId.
rawId(), b_x, 0., b_y, 0., 0., 0., 0., 0., 0.,
CTPPSpixelLocalTrackReconstructionInfo::invalid, 0, 0., 0.);
383 CLHEP::Hep3Vector gl_o = geometry.
localToGlobal(detId, CLHEP::Hep3Vector(0, 0, 0));
384 CLHEP::Hep3Vector gl_a1 = geometry.
localToGlobal(detId, CLHEP::Hep3Vector(1, 0, 0)) - gl_o;
385 CLHEP::Hep3Vector gl_a2 = geometry.
localToGlobal(detId, CLHEP::Hep3Vector(0, 1, 0)) - gl_o;
390 A(0, 1) = -gl_a1.x();
391 A(0, 2) = -gl_a2.x();
392 B(0) = gl_o.x() - b_x;
394 A(1, 1) = -gl_a1.y();
395 A(1, 2) = -gl_a2.y();
396 B(1) = gl_o.y() - b_y;
398 A(2, 1) = -gl_a1.z();
399 A(2, 2) = -gl_a2.z();
400 B(2) = gl_o.z() - z_scoringPlane;
407 CLHEP::Hep3Vector h_glo(a_x * ze + b_x, a_y * ze + b_y, z_sign * ze + z_scoringPlane);
410 CLHEP::Hep3Vector h_loc = geometry.
globalToLocal(detId, h_glo);
414 <<
" de z = " <<
P(0) <<
" mm, p1 = " <<
P(1) <<
" mm, p2 = " <<
P(2) <<
" mm" << std::endl
415 <<
" h_glo: x = " << h_glo.x() <<
" mm, y = " << h_glo.y() <<
" mm, z = " << h_glo.z() <<
" mm" 417 <<
" h_loc: c1 = " << h_loc.x() <<
" mm, c2 = " << h_loc.y() <<
" mm, c3 = " << h_loc.z() <<
" mm" 423 double u = h_loc.x();
424 double v = h_loc.y();
427 ssLog <<
" u=" << u <<
", v=" <<
v;
432 ssLog <<
" | no hit" << std::endl;
444 ssLog <<
" | strip=" <<
strip;
450 ssLog <<
" | m=" << v <<
", sigma=" << sigma << std::endl;
456 out_strip_hits_per_particle[in_trk->barcode()].find_or_insert(detId);
462 throw cms::Exception(
"CTPPSDirectProtonSimulation") <<
"Diamonds are not yet supported.";
469 ssLog <<
" pixel plane " << pixelDetId.
plane() <<
": local hit x = " << h_loc.x()
470 <<
" mm, y = " << h_loc.y() <<
" mm, z = " << h_loc.z() <<
" mm" << std::endl;
483 ssLog <<
" hit accepted: m1 = " << h_loc.x() <<
" mm, m2 = " << h_loc.y() <<
" mm" << std::endl;
488 const LocalPoint lp(h_loc.x(), h_loc.y(), h_loc.z());
495 out_pixel_hits_per_particle[in_trk->barcode()].find_or_insert(detId);
502 edm::LogInfo(
"CTPPSDirectProtonSimulation") << ssLog.str();
511 desc.
add<
std::string>(
"lhcInfoLabel",
"")->setComment(
"label of the LHCInfo record");
512 desc.
add<
std::string>(
"opticsLabel",
"")->setComment(
"label of the optics records");
515 desc.
add<
bool>(
"produceScoringPlaneHits",
true);
516 desc.
add<
bool>(
"produceRecHits",
true);
518 desc.
add<
bool>(
"useEmpiricalApertures",
false);
519 desc.
add<
double>(
"empiricalAperture45_xi0_int", 0.);
520 desc.
add<
double>(
"empiricalAperture45_xi0_slp", 0.);
521 desc.
add<
double>(
"empiricalAperture45_a_int", 0.);
522 desc.
add<
double>(
"empiricalAperture45_a_slp", 0.);
523 desc.
add<
double>(
"empiricalAperture56_xi0_int", 0.);
524 desc.
add<
double>(
"empiricalAperture56_xi0_slp", 0.);
525 desc.
add<
double>(
"empiricalAperture56_a_int", 0.);
526 desc.
add<
double>(
"empiricalAperture56_a_slp", 0.);
528 desc.
add<
bool>(
"produceHitsRelativeToBeam",
false);
529 desc.
add<
bool>(
"roundToPitch",
true);
530 desc.
add<
bool>(
"checkIsHit",
true);
531 desc.
add<
double>(
"pitchStrips", 66.e-3);
532 desc.
add<
double>(
"insensitiveMarginStrips", 34.e-3);
534 desc.
add<
double>(
"pitchPixelsHor", 100.e-3)->setComment(
"x in local coordinates, in mm");
535 desc.
add<
double>(
"pitchPixelsVer", 150.e-3)->setComment(
"y in local coordinates, in mm");
537 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)
const std::string & sensorType() const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
bool produceScoringPlaneHits_
flags what output to be produced
constexpr uint32_t rawId() const
get the raw id
static bool isPixelHit(float xLocalCoordinate, float yLocalCoordinate, bool is3x2=true)
double empiricalAperture45_xi0_int_
double empiricalAperture56_xi0_slp_
static bool IsHit(double u, double v, double insensitiveMargin=0)
static const unsigned short no_of_strips_
double empiricalAperture56_a_int_
void produce(edm::Event &, const edm::EventSetup &) override
const std::string DDD_CTPPS_PIXELS_SENSOR_TYPE_2x2
reference find_or_insert(det_id_type id)
edm::EDGetTokenT< edm::HepMCProduct > hepMCToken_
float const crossingAngle() const
static const double y_width_
const DetGeomDesc * getSensor(unsigned int id) const
returns geometry of a detector performs necessary checks, returns NULL if fails
#define DEFINE_FWK_MODULE(type)
~CTPPSDirectProtonSimulation() override
bool produceHitsRelativeToBeam_
void processProton(const HepMC::GenVertex *in_vtx, const HepMC::GenParticle *in_trk, const CTPPSGeometry &geometry, const LHCInfo &lhcInfo, 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, std::map< int, edm::DetSetVector< TotemRPRecHit >> &out_strip_hits_per_particle, std::map< int, edm::DetSetVector< CTPPSPixelRecHit >> &out_pixel_hits_per_particle, std::map< int, edm::DetSetVector< CTPPSDiamondRecHit >> &out_diamond_hits_per_particle) const
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 empiricalAperture45_a_int_
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
double empiricalAperture45_xi0_slp_
double empiricalAperture56_a_slp_
bool useEmpiricalApertures_
bool checkApertures_
simulation parameters
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
The manager class for TOTEM RP geometry.
std::string lhcInfoLabel_
input
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
double empiricalAperture45_a_slp_
Base class for CTPPS detector IDs.
double stripZeroPosition_
internal variable: v position of strip 0, in mm
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
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
double empiricalAperture56_xi0_int_
CTPPSDirectProtonSimulation(const edm::ParameterSet &)