37 #include <unordered_map> 60 std::vector<CTPPSLocalTrackLite>& out_tracks,
65 static bool isPixelHit(
float xLocalCoordinate,
float yLocalCoordinate,
bool is3x2 =
true) {
66 float tmpXlocalCoordinate = xLocalCoordinate + (79 * 0.1 + 0.2);
67 float tmpYlocalCoordinate = yLocalCoordinate + (0.15 * 51 + 0.3 * 2 + 0.15 * 25);
69 if (tmpXlocalCoordinate < 0)
71 if (tmpYlocalCoordinate < 0)
73 int xModuleSize = 0.1 * 79 + 0.2 * 2 + 0.1 * 79;
76 yModuleSize = 0.15 * 51 + 0.3 * 2 + 0.15 * 50 + 0.3 * 2 + 0.15 * 51;
78 yModuleSize = 0.15 * 51 + 0.3 * 2 + 0.15 * 51;
79 if (tmpXlocalCoordinate > xModuleSize)
81 if (tmpYlocalCoordinate > yModuleSize)
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>>();
181 std::unique_ptr<std::vector<CTPPSLocalTrackLite>> pTracks(
new std::vector<CTPPSLocalTrackLite>());
185 for (
auto it_vtx = evt->vertices_begin(); it_vtx != evt->vertices_end(); ++it_vtx) {
186 auto vtx = *(it_vtx);
189 for (
auto it_part =
vtx->particles_out_const_begin(); it_part !=
vtx->particles_out_const_end(); ++it_part) {
190 auto part = *(it_part);
193 if (
part->pdg_id() != 2212)
196 if (
part->status() != 1 &&
part->status() < 83)
228 std::vector<CTPPSLocalTrackLite>& out_tracks,
235 std::stringstream ssLog;
238 const HepMC::FourVector& vtx_cms = in_vtx->position();
239 const HepMC::FourVector& mom_cms = in_trk->momentum();
242 HepMC::FourVector vtx_lhc(-vtx_cms.x(), vtx_cms.y(), -vtx_cms.z(), vtx_cms.t());
243 HepMC::FourVector mom_lhc(-mom_cms.x(), mom_cms.y(), -mom_cms.z(), mom_cms.t());
246 unsigned int arm = 3;
248 double beamMomentum = 0.;
250 double empiricalAperture_xi0, empiricalAperture_a;
270 const double p = mom_lhc.rho();
271 const double xi = 1. - p / beamMomentum;
272 const double th_x_phys = mom_lhc.x() /
p;
273 const double th_y_phys = mom_lhc.y() /
p;
274 const double vtx_lhc_eff_x = vtx_lhc.x() - vtx_lhc.z() * (mom_lhc.x() / mom_lhc.z() + xangle);
275 const double vtx_lhc_eff_y = vtx_lhc.y() - vtx_lhc.z() * (mom_lhc.y() / mom_lhc.z());
278 ssLog <<
"simu: xi = " << xi <<
", th_x_phys = " << th_x_phys <<
", th_y_phys = " << th_y_phys
279 <<
", vtx_lhc_eff_x = " << vtx_lhc_eff_x <<
", vtx_lhc_eff_y = " << vtx_lhc_eff_y << std::endl;
284 const double xi_th = empiricalAperture_xi0 + th_x_phys * empiricalAperture_a;
287 ssLog <<
"stop because of empirical appertures";
288 edm::LogInfo(
"CTPPSDirectProtonSimulation") << ssLog.str();
296 for (
const auto& ofp : opticalFunctions) {
298 const unsigned int rpDecId = rpId.
arm() * 100 + rpId.
station() * 10 + rpId.
rp();
301 if (rpId.
arm() != arm)
305 ssLog <<
" RP " << rpDecId << std::endl;
309 vtx_lhc_eff_x * 1E-1, th_x_phys, vtx_lhc_eff_y * 1E-1, th_y_phys, xi};
311 ofp.second.transport(k_in, k_out,
true);
313 double b_x = k_out.
x * 1E1, b_y = k_out.
y * 1E1;
314 double a_x = k_out.
th_x, a_y = k_out.
th_y;
321 ofp.second.transport(k_be_in, k_be_out,
true);
323 a_x -= k_be_out.
th_x;
324 a_y -= k_be_out.
th_y;
325 b_x -= k_be_out.
x * 1E1;
326 b_y -= k_be_out.
y * 1E1;
329 const double z_scoringPlane = ofp.second.getScoringPlaneZ() * 1E1;
332 ssLog <<
" proton transported: a_x = " << a_x <<
" rad, a_y = " << a_y <<
" rad, b_x = " << b_x
333 <<
" mm, b_y = " << b_y <<
" mm, z = " << z_scoringPlane <<
" mm" << std::endl;
338 out_tracks.emplace_back(
339 rpId.
rawId(), b_x, 0., b_y, 0., 0., 0., 0., 0., 0.,
CTPPSpixelLocalTrackReconstructionInfo::invalid, 0, 0., 0.);
346 for (
const auto& detIdInt : geometry.
sensorsInRP(rpId)) {
351 CLHEP::Hep3Vector gl_o = geometry.
localToGlobal(detId, CLHEP::Hep3Vector(0, 0, 0));
352 CLHEP::Hep3Vector gl_a1 = geometry.
localToGlobal(detId, CLHEP::Hep3Vector(1, 0, 0)) - gl_o;
353 CLHEP::Hep3Vector gl_a2 = geometry.
localToGlobal(detId, CLHEP::Hep3Vector(0, 1, 0)) - gl_o;
358 A(0, 1) = -gl_a1.x();
359 A(0, 2) = -gl_a2.x();
360 B(0) = gl_o.x() - b_x;
362 A(1, 1) = -gl_a1.y();
363 A(1, 2) = -gl_a2.y();
364 B(1) = gl_o.y() - b_y;
366 A(2, 1) = -gl_a1.z();
367 A(2, 2) = -gl_a2.z();
368 B(2) = gl_o.z() - z_scoringPlane;
375 CLHEP::Hep3Vector h_glo(a_x * ze + b_x, a_y * ze + b_y, z_sign * ze + z_scoringPlane);
378 CLHEP::Hep3Vector h_loc = geometry.
globalToLocal(detId, h_glo);
382 <<
" de z = " <<
P(0) <<
" mm, p1 = " <<
P(1) <<
" mm, p2 = " <<
P(2) <<
" mm" << std::endl
383 <<
" h_glo: x = " << h_glo.x() <<
" mm, y = " << h_glo.y() <<
" mm, z = " << h_glo.z() <<
" mm" 385 <<
" h_loc: c1 = " << h_loc.x() <<
" mm, c2 = " << h_loc.y() <<
" mm, c3 = " << h_loc.z() <<
" mm" 391 double u = h_loc.x();
392 double v = h_loc.y();
395 ssLog <<
" u=" << u <<
", v=" <<
v;
400 ssLog <<
" | no hit" << std::endl;
412 ssLog <<
" | strip=" <<
strip;
418 ssLog <<
" | m=" << v <<
", sigma=" << sigma << std::endl;
426 throw cms::Exception(
"CTPPSDirectProtonSimulation") <<
"Diamonds are not yet supported.";
433 ssLog <<
" pixel plane " << pixelDetId.
plane() <<
": local hit x = " << h_loc.x()
434 <<
" mm, y = " << h_loc.y() <<
" mm, z = " << h_loc.z() <<
" mm" << std::endl;
446 ssLog <<
" hit accepted: m1 = " << h_loc.x() <<
" mm, m2 = " << h_loc.y() <<
" mm" << std::endl;
451 const LocalPoint lp(h_loc.x(), h_loc.y(), h_loc.z());
461 edm::LogInfo(
"CTPPSDirectProtonSimulation") << ssLog.str();
470 desc.
add<
bool>(
"produceScoringPlaneHits",
true);
471 desc.
add<
bool>(
"produceRecHits",
true);
472 desc.
add<
bool>(
"useEmpiricalApertures",
false);
473 desc.
add<
double>(
"empiricalAperture45_xi0", 0.);
474 desc.
add<
double>(
"empiricalAperture45_a", 0.);
475 desc.
add<
double>(
"empiricalAperture56_xi0", 0.);
476 desc.
add<
double>(
"empiricalAperture56_a", 0.);
477 desc.
add<
bool>(
"produceHitsRelativeToBeam",
false);
478 desc.
add<
bool>(
"roundToPitch",
true);
479 desc.
add<
bool>(
"checkIsHit",
true);
480 desc.
add<
double>(
"pitchStrips", 66.e-3);
481 desc.
add<
double>(
"insensitiveMarginStrips", 34.e-3);
482 desc.
add<
double>(
"pitchPixelsHor", 100.e-3)->setComment(
"x in local coordinates, in mm");
483 desc.
add<
double>(
"pitchPixelsVer", 150.e-3)->setComment(
"y in local coordinates, in mm");
485 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 std::set< unsigned int > & sensorsInRP(unsigned int) const
after checks returns set of sensor ids corresponding to the given RP id
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
double getHalfXangleX45() const
CLHEP::Hep3Vector globalToLocal(const DetGeomDesc *, const CLHEP::Hep3Vector &) const
CTPPSDirectProtonSimulation(const edm::ParameterSet &)