Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 28 additions & 36 deletions RecoPPS/ProtonReconstruction/plugins/PPSFilteredProtonProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -62,31 +62,31 @@ class PPSFilteredProtonProducer : public edm::stream::EDProducer<> {
//----------------------------------------------------------------------------------------------------

PPSFilteredProtonProducer::PPSFilteredProtonProducer(const edm::ParameterSet &iConfig)
: verbosity_(iConfig.getUntrackedParameter<bool>("verbosity", 0)),
n_protons_single_rp_all(0),
n_protons_single_rp_kept(0),
n_protons_multi_rp_all(0),
n_protons_multi_rp_kept(0) {
: verbosity_(iConfig.getUntrackedParameter<bool>("verbosity")),
n_protons_single_rp_all(0),
n_protons_single_rp_kept(0),
n_protons_multi_rp_all(0),
n_protons_multi_rp_kept(0) {
const auto &tracks_all = iConfig.getParameterSet("tracks_all");
tracks_all_local_angle_x_max_ = tracks_all.getParameter<double>("local_angle_x_max");
tracks_all_local_angle_y_max_ = tracks_all.getParameter<double>("local_angle_y_max");

const auto &tracks_pixel = iConfig.getParameterSet("tracks_pixel");
tracks_pixel_forbidden_RecoInfo_values_ =
tracks_pixel.getParameter<std::vector<unsigned int>>("forbidden_RecoInfo_values");
tracks_pixel.getParameter<std::vector<unsigned int>>("forbidden_RecoInfo_values");
tracks_pixel_number_of_hits_min_ = tracks_pixel.getParameter<unsigned int>("number_of_hits_min");
tracks_pixel_normalised_chi_sq_max_ = tracks_pixel.getParameter<double>("normalised_chi_sq_max");

const auto &protons_single_rp = iConfig.getParameterSet("protons_single_rp");
protons_single_rp_include_ = protons_single_rp.getParameter<bool>("include");
protons_single_rp_input_token_ =
consumes<reco::ForwardProtonCollection>(protons_single_rp.getParameter<edm::InputTag>("input_tag"));
consumes<reco::ForwardProtonCollection>(protons_single_rp.getParameter<edm::InputTag>("input_tag"));
protons_single_rp_output_label_ = protons_single_rp.getParameter<std::string>("output_label");

const auto &protons_multi_rp = iConfig.getParameterSet("protons_multi_rp");
protons_multi_rp_include_ = protons_multi_rp.getParameter<bool>("include");
protons_multi_rp_input_token_ =
consumes<reco::ForwardProtonCollection>(protons_multi_rp.getParameter<edm::InputTag>("input_tag"));
consumes<reco::ForwardProtonCollection>(protons_multi_rp.getParameter<edm::InputTag>("input_tag"));
protons_multi_rp_output_label_ = protons_multi_rp.getParameter<std::string>("output_label");
protons_multi_rp_check_valid_fit_ = protons_multi_rp.getParameter<bool>("check_valid_fit");
protons_multi_rp_chi_sq_max_ = protons_multi_rp.getParameter<double>("chi_sq_max");
Expand All @@ -104,25 +104,25 @@ PPSFilteredProtonProducer::PPSFilteredProtonProducer(const edm::ParameterSet &iC
void PPSFilteredProtonProducer::fillDescriptions(edm::ConfigurationDescriptions &descriptions) {
edm::ParameterSetDescription desc;

desc.addUntracked<bool>("verbosity", 0)->setComment("verbosity level");
desc.addUntracked<bool>("verbosity", false)->setComment("verbosity");

edm::ParameterSetDescription tracks_all;
tracks_all.add<double>("local_angle_x_max", 0.020)
->setComment("maximum absolute value of local horizontal angle, in rad");
->setComment("maximum absolute value of local horizontal angle, in rad");
tracks_all.add<double>("local_angle_y_max", 0.020)
->setComment("maximum absolute value of local horizontal angle, in rad");
->setComment("maximum absolute value of local horizontal angle, in rad");
desc.add<edm::ParameterSetDescription>("tracks_all", tracks_all)->setComment("settings for all tracks");

edm::ParameterSetDescription tracks_pixel;
const std::vector<unsigned int> def_for_RecoInfo_vals = {
(unsigned int)CTPPSpixelLocalTrackReconstructionInfo::allShiftedPlanes,
(unsigned int)CTPPSpixelLocalTrackReconstructionInfo::mixedPlanes};
(unsigned int)CTPPSpixelLocalTrackReconstructionInfo::allShiftedPlanes,
(unsigned int)CTPPSpixelLocalTrackReconstructionInfo::mixedPlanes};
tracks_pixel.add<std::vector<unsigned int>>("forbidden_RecoInfo_values", def_for_RecoInfo_vals)
->setComment("list of forbidden RecoInfo values");
->setComment("list of forbidden RecoInfo values");
tracks_pixel.add<unsigned int>("number_of_hits_min", 0)->setComment("minimum required number of hits");
tracks_pixel.add<double>("normalised_chi_sq_max", 1E100)->setComment("maximum tolerated chi square / ndof");
desc.add<edm::ParameterSetDescription>("tracks_pixel", tracks_pixel)
->setComment("specific settings for pixel-RP tracks");
->setComment("specific settings for pixel-RP tracks");

edm::ParameterSetDescription protons_single_rp;
protons_single_rp.add<bool>("include", true)->setComment("flag whether single-RP protons should be processed");
Expand Down Expand Up @@ -177,14 +177,10 @@ void PPSFilteredProtonProducer::produce(edm::Event &iEvent, const edm::EventSetu

// process single-RP protons
if (protons_single_rp_include_) {
edm::Handle<reco::ForwardProtonCollection> hInputProtons;
iEvent.getByToken(protons_single_rp_input_token_, hInputProtons);

reco::ForwardProtonCollection const &hInputProtons = iEvent.get(protons_single_rp_input_token_);
std::unique_ptr<reco::ForwardProtonCollection> pOutputProtons(new reco::ForwardProtonCollection);

for (unsigned int pr_idx = 0; pr_idx < hInputProtons->size(); ++pr_idx) {
const auto &proton = hInputProtons->at(pr_idx);

for (const auto &proton : hInputProtons) {
bool keep = true;

// no specific checks for single-RP protons
Expand All @@ -204,7 +200,7 @@ void PPSFilteredProtonProducer::produce(edm::Event &iEvent, const edm::EventSetu
pOutputProtons->push_back(proton);
} else {
if (verbosity_)
ssLog << "single-RP proton idx=" << pr_idx << " excluded." << std::endl;
ssLog << "single-RP proton idx=" << n_protons_single_rp_all - 1 << " excluded." << std::endl;
}
}

Expand All @@ -213,14 +209,10 @@ void PPSFilteredProtonProducer::produce(edm::Event &iEvent, const edm::EventSetu

// process multi-RP protons
if (protons_multi_rp_include_) {
edm::Handle<reco::ForwardProtonCollection> hInputProtons;
iEvent.getByToken(protons_multi_rp_input_token_, hInputProtons);

reco::ForwardProtonCollection const &hInputProtons = iEvent.get(protons_multi_rp_input_token_);
std::unique_ptr<reco::ForwardProtonCollection> pOutputProtons(new reco::ForwardProtonCollection);

for (unsigned int pr_idx = 0; pr_idx < hInputProtons->size(); ++pr_idx) {
const auto &proton = hInputProtons->at(pr_idx);

for (const auto &proton : hInputProtons) {
bool keep = true;

// multi-RP proton checks
Expand All @@ -247,7 +239,7 @@ void PPSFilteredProtonProducer::produce(edm::Event &iEvent, const edm::EventSetu
pOutputProtons->push_back(proton);
} else {
if (verbosity_)
ssLog << "multi-RP proton idx=" << pr_idx << " excluded." << std::endl;
ssLog << "multi-RP proton idx=" << n_protons_multi_rp_all - 1 << " excluded." << std::endl;
}
}

Expand All @@ -262,13 +254,13 @@ void PPSFilteredProtonProducer::produce(edm::Event &iEvent, const edm::EventSetu

void PPSFilteredProtonProducer::endStream() {
edm::LogInfo("PPS")
<< "single-RP protons: total=" << n_protons_single_rp_all << ", kept=" << n_protons_single_rp_kept
<< " --> keep rate="
<< ((n_protons_single_rp_all > 0) ? double(n_protons_single_rp_kept) / n_protons_single_rp_all * 100. : 0.)
<< "%\n"
<< "multi-RP protons: total=" << n_protons_multi_rp_all << ", kept=" << n_protons_multi_rp_kept
<< " --> keep rate="
<< ((n_protons_multi_rp_all > 0) ? double(n_protons_multi_rp_kept) / n_protons_multi_rp_all * 100. : 0.) << "%";
<< "single-RP protons: total=" << n_protons_single_rp_all << ", kept=" << n_protons_single_rp_kept
<< " --> keep rate="
<< ((n_protons_single_rp_all > 0) ? double(n_protons_single_rp_kept) / n_protons_single_rp_all * 100. : 0.)
<< "%\n"
<< "multi-RP protons: total=" << n_protons_multi_rp_all << ", kept=" << n_protons_multi_rp_kept
<< " --> keep rate="
<< ((n_protons_multi_rp_all > 0) ? double(n_protons_multi_rp_kept) / n_protons_multi_rp_all * 100. : 0.) << "%";
}

//----------------------------------------------------------------------------------------------------
Expand Down