132 std::ostringstream os;
157 unsigned int arm = 2;
159 std::map<unsigned int, unsigned int> recHitsPerRP;
160 bool inAcceptanceNear =
false, inAcceptanceFar =
false, inAcceptance =
false;
163 std::map<int, ParticleInfo> particleInfo;
166 for (
auto it = hepMCEventAfterSmearing->particles_begin(); it != hepMCEventAfterSmearing->particles_end(); ++it) {
167 const auto &
part = *it;
170 if (
part->pdg_id() != 2212)
173 if (
part->status() != 1)
179 const auto &mom =
part->momentum();
186 info.arm = (mom.z() > 0.) ? 0 : 1;
188 const double p_nom = hLHCInfo->
energy();
189 info.xi = (p_nom - mom.rho()) / p_nom;
195 for (
const auto &
pp : *hStripRecHitsPerParticle) {
196 const auto barcode =
pp.first;
198 for (
const auto &ds :
pp.second) {
201 particleInfo[barcode].recHitsPerRP[
rpId] += ds.size();
205 for (
const auto &
pp : *hPixelRecHitsPerParticle) {
206 const auto barcode =
pp.first;
208 for (
const auto &ds :
pp.second) {
211 particleInfo[barcode].recHitsPerRP[
rpId] += ds.size();
215 std::map<unsigned int, bool> isStripRPNear, isStripRPFar;
217 for (
auto &
pp : particleInfo) {
219 os <<
"* barcode=" <<
pp.first <<
", arm=" <<
pp.second.arm <<
", xi=" <<
pp.second.xi << std::endl;
221 for (
const auto &rpp :
pp.second.recHitsPerRP) {
223 unsigned int needed_rec_hits = 1000;
229 unsigned int rpDecId =
rpId.arm() * 100 +
rpId.station() * 10 +
rpId.rp();
233 isStripRPNear[
rpId.arm()] =
true;
235 isStripRPFar[
rpId.arm()] =
true;
238 if (rpp.second >= needed_rec_hits) {
240 pp.second.inAcceptanceNear =
true;
242 pp.second.inAcceptanceFar =
true;
246 os <<
" RP " << rpDecId <<
": " << rpp.second <<
" hits" << std::endl;
249 pp.second.inAcceptance =
pp.second.inAcceptanceNear &&
pp.second.inAcceptanceFar;
252 os <<
" inAcceptance: near=" <<
pp.second.inAcceptanceNear <<
", far=" <<
pp.second.inAcceptanceFar
253 <<
", 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=" << nReconstructedProtons[arm]
305 <<
" (tracks near=" << nReconstructedTracks[arm].near <<
", far=" << nReconstructedTracks[arm].far
306 <<
"), nAcc=" << npa.global <<
" (near=" << npa.near <<
", far=" << npa.far <<
")" << std::endl;
312 const auto &
p =
plots_[arm][npa.global];
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();