76 th_y_cut_apply = ps.
getParameter<
bool>(
"th_y_cut_apply");
77 th_y_cut_value = ps.
getParameter<
double>(
"th_y_cut_value");
83 desc.
add<
bool>(
"x_cut_apply",
false)->setComment(
"whether to apply track-association cut in x");
84 desc.
add<
double>(
"x_cut_value", 800E-6)->setComment(
"threshold of track-association cut in x, mm");
85 desc.
add<
bool>(
"y_cut_apply",
false)->setComment(
"whether to apply track-association cut in y");
86 desc.
add<
double>(
"y_cut_value", 600E-6)->setComment(
"threshold of track-association cut in y, mm");
87 desc.
add<
bool>(
"xi_cut_apply",
true)->setComment(
"whether to apply track-association cut in xi");
88 desc.
add<
double>(
"xi_cut_value", 0.013)->
setComment(
"threshold of track-association cut in xi");
89 desc.
add<
bool>(
"th_y_cut_apply",
true)->setComment(
"whether to apply track-association cut in th_y");
90 desc.
add<
double>(
"th_y_cut_value", 20E-6)->setComment(
"threshold of track-association cut in th_y, rad");
111 verbosity_(iConfig.getUntrackedParameter<unsigned
int>(
"verbosity", 0)),
125 iConfig.getParameter<
bool>(
"fitVtxY"), iConfig.getParameter<
bool>(
"useImprovedInitialEstimate"),
verbosity_),
128 const unsigned int arm = (sector ==
"45") ? 0 : 1;
145 ->setComment(
"specification of the input lite-track collection");
147 desc.
add<
std::string>(
"lhcInfoLabel",
"")->setComment(
"label of the LHCInfo record");
149 desc.
addUntracked<
unsigned int>(
"verbosity", 0)->setComment(
"verbosity level");
151 desc.
add<
bool>(
"doSingleRPReconstruction",
true)
152 ->setComment(
"flag whether to apply single-RP reconstruction strategy");
154 desc.
add<
bool>(
"doMultiRPReconstruction",
true)->setComment(
"flag whether to apply multi-RP reconstruction strategy");
157 ->setComment(
"output label for single-RP reconstruction products");
160 ->setComment(
"output label for multi-RP reconstruction products");
162 desc.
add<
double>(
"localAngleXMin", -0.03)->
setComment(
"minimal accepted value of local horizontal angle (rad)");
163 desc.
add<
double>(
"localAngleXMax", +0.03)->
setComment(
"maximal accepted value of local horizontal angle (rad)");
164 desc.
add<
double>(
"localAngleYMin", -0.04)->
setComment(
"minimal accepted value of local vertical angle (rad)");
165 desc.
add<
double>(
"localAngleYMax", +0.04)->
setComment(
"maximal accepted value of local vertical angle (rad)");
169 ->setComment(
"track-association cuts for sector " + sector);
172 std::vector<edm::ParameterSet>
config;
174 desc.
add<
unsigned int>(
"max_n_timing_tracks", 5)->setComment(
"maximum number of timing tracks per RP");
176 desc.
add<
bool>(
"fitVtxY",
true)
177 ->setComment(
"for multi-RP reconstruction, flag whether y* should be free fit parameter");
179 desc.
add<
bool>(
"useImprovedInitialEstimate",
true)
181 "for multi-RP reconstruction, flag whether a quadratic estimate of the initial point should be used");
183 descriptions.
add(
"ctppsProtons", desc);
199 if (!hTracks->empty()) {
212 if (hOpticalFunctions->empty()) {
213 edm::LogInfo(
"CTPPSProtonProducer") <<
"No optical functions available, reconstruction disabled.";
225 std::ostringstream ssLog;
227 ssLog <<
"* input tracks:" << std::endl;
230 std::map<unsigned int, std::vector<unsigned int>> trackingSelection, timingSelection;
232 for (
unsigned int idx = 0;
idx < hTracks->size(); ++
idx) {
233 const auto &tr = hTracks->at(
idx);
243 <<
"[" <<
idx <<
"] " << tr.rpId() <<
" (" << (rpId.arm() * 100 + rpId.station() * 10 + rpId.rp())
245 <<
"x=" << tr.x() <<
" +- " << tr.xUnc() <<
" mm, " 246 <<
"y=" << tr.y() <<
" +- " << tr.yUnc() <<
" mm" << std::endl;
248 const bool trackerRP =
252 trackingSelection[rpId.arm()].push_back(
idx);
254 timingSelection[rpId.arm()].push_back(
idx);
258 for (
const auto &arm_it : trackingSelection) {
259 const auto &
indices = arm_it.second;
264 std::map<unsigned int, reco::ForwardProton> singleRPResultsIndexed;
268 ssLog << std::endl <<
"* reconstruction from track " <<
idx << std::endl;
270 singleRPResultsIndexed[
idx] =
278 std::set<unsigned int> rpIds;
280 rpIds.insert(hTracks->at(
idx).rpId());
285 std::vector<std::pair<unsigned int, unsigned int>> idx_pairs;
286 std::map<unsigned int, unsigned int> idx_pair_multiplicity;
287 for (
const auto &
i : indices) {
288 for (
const auto &
j : indices) {
292 const auto &tr_i = hTracks->at(
i);
293 const auto &tr_j = hTracks->at(
j);
295 const auto &pr_i = singleRPResultsIndexed[
i];
296 const auto &pr_j = singleRPResultsIndexed[
j];
298 if (tr_i.rpId() == tr_j.rpId())
303 if (ac.x_cut_apply &&
std::abs(tr_i.x() - tr_j.x()) > ac.x_cut_value)
305 if (ac.y_cut_apply &&
std::abs(tr_i.y() - tr_j.y()) > ac.y_cut_value)
307 if (ac.xi_cut_apply &&
std::abs(pr_i.xi() - pr_j.xi()) > ac.xi_cut_value)
309 if (ac.th_y_cut_apply &&
std::abs(pr_i.thetaY() - pr_j.thetaY()) > ac.th_y_cut_value)
315 idx_pairs.emplace_back(
i,
j);
316 idx_pair_multiplicity[
i]++;
317 idx_pair_multiplicity[
j]++;
322 std::map<unsigned int, unsigned int> timing_RP_track_multiplicity;
323 for (
const auto &ti : timingSelection[arm_it.first]) {
324 const auto &tr = hTracks->at(ti);
325 timing_RP_track_multiplicity[tr.rpId()]++;
329 std::map<unsigned int, std::vector<unsigned int>> matched_timing_track_indices;
330 std::map<unsigned int, unsigned int> matched_timing_track_multiplicity;
331 for (
unsigned int pr_idx = 0; pr_idx < idx_pairs.size(); ++pr_idx) {
332 const auto &
i = idx_pairs[pr_idx].first;
333 const auto &
j = idx_pairs[pr_idx].second;
336 if (idx_pair_multiplicity[
i] > 1 || idx_pair_multiplicity[
j] > 1)
339 const auto &tr_i = hTracks->at(
i);
340 const auto &tr_j = hTracks->at(
j);
345 for (
const auto &ti : timingSelection[arm_it.first]) {
346 const auto &tr_ti = hTracks->at(ti);
355 const double f_i = (z_ti - z_j) / (z_i - z_j), f_j = (z_i - z_ti) / (z_i - z_j);
356 const double x_inter = f_i * tr_i.x() + f_j * tr_j.x();
357 const double x_inter_unc_sq =
358 f_i * f_i * tr_i.xUnc() * tr_i.xUnc() + f_j * f_j * tr_j.xUnc() * tr_j.xUnc();
360 const double de_x = tr_ti.x() - x_inter;
361 const double de_x_unc =
sqrt(tr_ti.xUnc() * tr_ti.xUnc() + x_inter_unc_sq);
366 ssLog <<
"ti=" << ti <<
", i=" <<
i <<
", j=" <<
j <<
" | z_ti=" << z_ti <<
", z_i=" << z_i
367 <<
", z_j=" << z_j <<
" | x_ti=" << tr_ti.x() <<
", x_inter=" << x_inter <<
", de_x=" << de_x
368 <<
", de_x_unc=" << de_x_unc <<
", matching=" << matching << std::endl;
373 matched_timing_track_indices[pr_idx].push_back(ti);
374 matched_timing_track_multiplicity[ti]++;
379 for (
unsigned int pr_idx = 0; pr_idx < idx_pairs.size(); ++pr_idx) {
380 const auto &
i = idx_pairs[pr_idx].first;
381 const auto &
j = idx_pairs[pr_idx].second;
384 if (idx_pair_multiplicity[
i] > 1 || idx_pair_multiplicity[
j] > 1)
389 <<
"* reconstruction from tracking-RP tracks: " <<
i <<
", " <<
j <<
" and timing-RP tracks: ";
398 double sw = 0., swt = 0.;
399 for (
const auto &ti : matched_timing_track_indices[pr_idx]) {
401 if (matched_timing_track_multiplicity[ti] > 1)
409 const auto &tr = hTracks->at(ti);
410 const double t_unc = tr.timeUnc();
411 const double w = (t_unc > 0.) ? 1. / t_unc / t_unc : 1.;
413 swt += w * tr.time();
416 float time = 0., time_unc = 0.;
419 time_unc = 1. /
sqrt(sw);
423 ssLog << std::endl <<
" time = " << time <<
" +- " << time_unc << std::endl;
430 pOutMultiRP->emplace_back(proton);
435 for (
const auto &
p : singleRPResultsIndexed)
436 pOutSingleRP->emplace_back(
std::move(
p.second));
T getParameter(std::string const &) const
void setComment(std::string const &value)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
std::string lhcInfoLabel_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
reco::ForwardProton reconstructFromSingleRP(const CTPPSLocalTrackLiteRef &track, const LHCInfo &lhcInfo, std::ostream &os) const
run proton reconstruction using single-RP strategy
bool doMultiRPReconstruction_
void load(const edm::ParameterSet &ps)
~CTPPSProtonProducer() override=default
unsigned int max_n_timing_tracks_
Event setup record containing the real (actual) geometry information.
void init(const LHCInterpolatedOpticalFunctionsSetCollection &opticalFunctions)
#define DEFINE_FWK_MODULE(type)
CLHEP::Hep3Vector rpTranslation(unsigned int id) const
void setTimeError(float time_err)
reco::ForwardProton reconstructFromMultiRP(const CTPPSLocalTrackLiteRefVector &tracks, const LHCInfo &lhcInfo, std::ostream &os) const
run proton reconstruction using multiple-RP strategy
CTPPSProtonProducer(const edm::ParameterSet &)
edm::ESWatcher< CTPPSInterpolatedOpticsRcd > opticsWatcher_
Abs< T >::type abs(const T &t)
edm::Ref< CTPPSLocalTrackLiteCollection > CTPPSLocalTrackLiteRef
Persistent reference to a CTPPSLocalTrackLite.
std::map< unsigned int, AssociationCuts > association_cuts_
static edm::ParameterSetDescription getDefaultParameters()
ParameterDescriptionBase * add(U const &iLabel, T const &value)
std::vector< CTPPSLocalTrackLite > CTPPSLocalTrackLiteCollection
Collection of CTPPSLocalTrackLite objects.
ParameterSet const & getParameterSet(std::string const &) const
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void produce(edm::Event &, const edm::EventSetup &) override
bool check(const edm::EventSetup &iSetup)
Base class for CTPPS detector IDs.
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
ProtonReconstructionAlgorithm algorithm_
void push_back(value_type const &ref)
Add a Ref<C, T> to the RefVector.
std::vector< ForwardProton > ForwardProtonCollection
Collection of ForwardProton objects.
void setContributingLocalTracks(const CTPPSLocalTrackLiteRefVector &v)
store the list of RP tracks that contributed to this global track
std::string singleRPReconstructionLabel_
std::string multiRPReconstructionLabel_
bool doSingleRPReconstruction_
edm::EDGetTokenT< CTPPSLocalTrackLiteCollection > tracksToken_