53 produces<edm::ValueMap<int>>(
"arm");
54 produces<nanoaod::FlatTable>(
"ppsTrackTable");
56 produces<edm::ValueMap<int>>(
"protonRPId");
74 std::vector<int> multiRP_arm;
77 std::vector<float> trackX, trackY, trackTime, trackTimeUnc;
78 std::vector<int> multiRPProtonIdx,
decRPId, rpType;
79 std::vector<int> singleRPProtonIdx, singleRP_protonRPId;
84 const auto &num_proton = hRecoProtonsSingleRP->size();
85 singleRP_protonRPId.reserve(num_proton);
87 for (
const auto &proton : *hRecoProtonsSingleRP) {
88 CTPPSDetId rpId((*proton.contributingLocalTracks().begin())->rpId());
89 unsigned int rpDecId = rpId.
arm() * 100 + rpId.station() * 10 + rpId.rp();
90 singleRP_protonRPId.push_back(rpDecId);
96 const auto &num_proton = hRecoProtonsMultiRP->size();
97 multiRP_arm.reserve(num_proton);
99 for (
const auto &proton : *hRecoProtonsMultiRP) {
100 multiRP_arm.push_back((proton.pz() < 0.) ? 1 : 0);
105 for (
unsigned int tr_idx = 0; tr_idx < ppsTracksLite->size(); ++tr_idx) {
106 const auto &tr = ppsTracksLite->at(tr_idx);
111 unsigned int rpDecId = rpId.
arm() * 100 + rpId.station() * 10 + rpId.rp();
113 signed int singleRP_idx = -1;
114 for (
unsigned int p_idx = 0; p_idx < hRecoProtonsSingleRP->size(); ++p_idx) {
115 const auto &proton = hRecoProtonsSingleRP->at(p_idx);
117 for (
const auto &ref : proton.contributingLocalTracks()) {
118 if (ref.key() == tr_idx) {
119 singleRP_idx = p_idx;
125 signed int multiRP_idx = -1;
126 for (
unsigned int p_idx = 0; p_idx < hRecoProtonsMultiRP->size(); ++p_idx) {
127 const auto &proton = hRecoProtonsMultiRP->at(p_idx);
129 for (
const auto &ref : proton.contributingLocalTracks()) {
130 if (ref.key() == tr_idx) {
138 singleRPProtonIdx.push_back(singleRP_idx);
139 multiRPProtonIdx.push_back(multiRP_idx);
141 rpType.push_back(rpId.subdetId());
142 trackX.push_back(tr.x());
143 trackY.push_back(tr.y());
144 trackTime.push_back(tr.time());
145 trackTimeUnc.push_back(tr.timeUnc());
151 for (
unsigned int p_idx = 0; p_idx < hRecoProtonsMultiRP->size(); ++p_idx) {
152 const auto &proton = hRecoProtonsMultiRP->at(p_idx);
153 multiRP_arm.push_back((proton.pz() < 0.) ? 1 : 0);
155 for (
const auto &ref : proton.contributingLocalTracks()) {
156 multiRPProtonIdx.push_back(p_idx);
158 unsigned int rpDecId = rpId.
arm() * 100 + rpId.station() * 10 + rpId.rp();
160 rpType.push_back(rpId.subdetId());
161 trackX.push_back(ref->x());
162 trackY.push_back(ref->y());
163 trackTime.push_back(ref->time());
164 trackTimeUnc.push_back(ref->timeUnc());
172 fillermultiArm.
insert(hRecoProtonsMultiRP, multiRP_arm.begin(), multiRP_arm.end());
173 fillermultiArm.
fill();
178 fillerID.
insert(hRecoProtonsSingleRP, singleRP_protonRPId.begin(), singleRP_protonRPId.end());
183 auto ppsTab = std::make_unique<nanoaod::FlatTable>(trackX.size(),
"PPSLocalTrack",
false);
184 ppsTab->addColumn<
int>(
"multiRPProtonIdx", multiRPProtonIdx,
"local track - proton correspondence");
186 ppsTab->addColumn<
int>(
"singleRPProtonIdx", singleRPProtonIdx,
"local track - proton correspondence");
187 ppsTab->addColumn<
float>(
"x", trackX,
"local track x", 16);
188 ppsTab->addColumn<
float>(
"y", trackY,
"local track y", 13);
189 ppsTab->addColumn<
float>(
"time", trackTime,
"local track time", 16);
190 ppsTab->addColumn<
float>(
"timeUnc", trackTimeUnc,
"local track time uncertainty", 13);
191 ppsTab->addColumn<
int>(
"decRPId",
decRPId,
"local track detector dec id");
192 ppsTab->addColumn<
int>(
"rpType", rpType,
"strip=3, pixel=4, diamond=5, timing=6");
193 ppsTab->setDoc(
"ppsLocalTrack variables");
205 desc.add<
edm::InputTag>(
"tagRecoProtonsMulti")->setComment(
"multiRP proton collection");
206 desc.add<
edm::InputTag>(
"tagRecoProtonsSingle")->setComment(
"singleRP proton collection");
207 desc.add<
edm::InputTag>(
"tagTrackLite")->setComment(
"pps local tracks lite collection");
208 desc.add<
bool>(
"storeSingleRPProtons")->setComment(
"flag to store singleRP protons and associated tracks");
209 descriptions.
add(
"ProtonProducer",
desc);
const edm::EDGetTokenT< reco::ForwardProtonCollection > tokenRecoProtonsMultiRP_
Local (=single RP) track with essential information only.
~ProtonProducer() override
#define DEFINE_FWK_MODULE(type)
void insert(const H &h, I begin, I end)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
const edm::EDGetTokenT< reco::ForwardProtonCollection > tokenRecoProtonsSingleRP_
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Base class for CTPPS detector IDs.
ProtonProducer(edm::ParameterSet const &ps)
const edm::EDGetTokenT< std::vector< CTPPSLocalTrackLite > > tokenTracksLite_
std::vector< ForwardProton > ForwardProtonCollection
Collection of ForwardProton objects.
EDGetTokenT< ProductType > mayConsume(edm::InputTag const &tag)
const bool storeSingleRPProtons_
void produce(edm::StreamID id, edm::Event &iEvent, const edm::EventSetup &iSetup) const override