133 std::ostringstream os;
158 unsigned int arm = 2;
160 std::map<unsigned int, unsigned int> recHitsPerRP;
161 bool inAcceptanceNear =
false, inAcceptanceFar =
false, inAcceptance =
false;
164 std::map<int, ParticleInfo> particleInfo;
167 for (
auto it = hepMCEventAfterSmearing->particles_begin(); it != hepMCEventAfterSmearing->particles_end(); ++it) {
168 const auto &
part = *it;
171 if (
part->pdg_id() != 2212)
174 if (
part->status() != 1)
180 const auto &mom =
part->momentum();
187 info.arm = (mom.z() > 0.) ? 0 : 1;
189 const double p_nom = hLHCInfo->
energy();
190 info.xi = (p_nom - mom.rho()) / p_nom;
196 for (
const auto &
pp : *hStripRecHitsPerParticle) {
197 const auto barcode =
pp.first;
199 for (
const auto &ds :
pp.second) {
202 particleInfo[barcode].recHitsPerRP[
rpId] += ds.size();
206 for (
const auto &
pp : *hPixelRecHitsPerParticle) {
207 const auto barcode =
pp.first;
209 for (
const auto &ds :
pp.second) {
212 particleInfo[barcode].recHitsPerRP[
rpId] += ds.size();
216 std::map<unsigned int, bool> isStripRPNear, isStripRPFar;
218 for (
auto &
pp : particleInfo) {
220 os <<
"* barcode=" <<
pp.first <<
", arm=" <<
pp.second.arm <<
", xi=" <<
pp.second.xi << std::endl;
222 for (
const auto &rpp :
pp.second.recHitsPerRP) {
224 unsigned int needed_rec_hits = 1000;
230 unsigned int rpDecId = rpId.arm() * 100 + rpId.station() * 10 + rpId.rp();
234 isStripRPNear[rpId.arm()] =
true;
236 isStripRPFar[rpId.arm()] =
true;
239 if (rpp.second >= needed_rec_hits) {
241 pp.second.inAcceptanceNear =
true;
243 pp.second.inAcceptanceFar =
true;
247 os <<
" RP " << rpDecId <<
": " << rpp.second <<
" hits" << std::endl;
250 pp.second.inAcceptance =
pp.second.inAcceptanceNear &&
pp.second.inAcceptanceFar;
253 os <<
" inAcceptance: near=" <<
pp.second.inAcceptanceNear <<
", far=" <<
pp.second.inAcceptanceFar <<
", global=" <<
pp.second.inAcceptance << std::endl;
258 unsigned int near = 0, far = 0, global = 0;
260 std::map<unsigned int, ArmCounter> nParticlesInAcceptance;
261 for (
auto &
pp : particleInfo) {
262 auto &
counter = nParticlesInAcceptance[
pp.second.arm];
263 if (
pp.second.inAcceptanceNear)
265 if (
pp.second.inAcceptanceFar)
267 if (
pp.second.inAcceptance)
272 std::map<unsigned int, ArmCounter> nReconstructedTracks;
273 for (
const auto &tr : *tracks) {
275 unsigned int rpDecId = rpId.arm() * 100 + rpId.station() * 10 + rpId.rp();
278 nReconstructedTracks[rpId.arm()].near++;
280 nReconstructedTracks[rpId.arm()].far++;
284 std::map<unsigned int, unsigned int> nReconstructedProtons;
285 for (
const auto &
pr : *hRecoProtonsMultiRP) {
289 unsigned int arm = 2;
295 nReconstructedProtons[
arm]++;
299 for (
unsigned int arm = 0; arm < 2; arm++) {
300 const auto &npa = nParticlesInAcceptance[
arm];
301 const auto &nrt = nReconstructedTracks[
arm];
304 os <<
"* arm " << arm <<
": nRecoProtons=" 305 << nReconstructedProtons[
arm] <<
" (tracks near=" << nReconstructedTracks[
arm].near <<
", far=" << nReconstructedTracks[
arm].far
306 <<
"), nAcc=" << npa.global <<
" (near=" << npa.near <<
", far=" << npa.far <<
")" << std::endl;
314 p.h_n_part_acc_nr->Fill(npa.near);
315 p.h_n_part_acc_fr->Fill(npa.far);
318 if (nrt.near != npa.near || nrt.far != npa.far)
321 const double eff = double(nReconstructedProtons[arm]) / npa.global;
324 os <<
" eff=" << eff << std::endl;
326 for (
auto &
pp : particleInfo) {
327 if (
pp.second.arm != arm || !
pp.second.inAcceptance)
330 p.p_eff_vs_xi->Fill(
pp.second.xi, eff);
335 edm::LogInfo(
"CTPPSProtonReconstructionEfficiencyEstimatorMC") << os.str();
edm::EDGetTokenT< CTPPSLocalTrackLiteCollection > tracksToken_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
std::map< unsigned int, std::map< unsigned int, PlotGroup > > plots_
std::map< unsigned int, unsigned int > rpDecId_near_
edm::EDGetTokenT< reco::ForwardProtonCollection > tokenRecoProtonsMultiRP_
edm::EDGetTokenT< std::map< int, edm::DetSetVector< CTPPSPixelRecHit > > > tokenPixelRecHitsPerParticle_
edm::EDGetTokenT< edm::HepMCProduct > tokenHepMCAfterSmearing_
CTPPSDetId getRPId() const
const HepMC::GenEvent * GetEvent() const
Base class for CTPPS detector IDs.
std::map< unsigned int, unsigned int > rpDecId_far_
float const energy() const
std::string lhcInfoLabel_
edm::EDGetTokenT< std::map< int, edm::DetSetVector< TotemRPRecHit > > > tokenStripRecHitsPerParticle_