32 #include "TGraphErrors.h" 71 : p_eff_vs_xi(new TProfile(
"",
";#xi_{simu};efficiency", 19, 0.015, 0.205)),
72 h_n_part_acc_nr(new TH1D(
"",
";n particles in acceptance", 6, -0.5, +5.5)),
73 h_n_part_acc_fr(new TH1D(
"",
";n particles in acceptance", 6, -0.5, +5.5)) {}
76 p_eff_vs_xi->Write(
"p_eff_vs_xi");
77 h_n_part_acc_nr->Write(
"h_n_part_acc_nr");
78 h_n_part_acc_fr->Write(
"h_n_part_acc_fr");
82 std::map<unsigned int, std::map<unsigned int, PlotGroup>>
plots_;
89 using namespace HepMC;
98 iConfig.getParameter<
edm::
InputTag>(
"tagStripRecHitsPerParticle"))),
100 iConfig.getParameter<
edm::
InputTag>(
"tagPixelRecHitsPerParticle"))),
119 for (
unsigned int arm = 0; arm < 2; ++arm) {
120 for (
unsigned int np = 1;
np <= 5; ++
np)
135 printf(
"--------------------------------------------------\n");
136 printf(
"event %llu\n",
eid);
162 unsigned int arm = 2;
164 std::map<unsigned int, unsigned int> recHitsPerRP;
165 bool inAcceptanceNear =
false, inAcceptanceFar =
false, inAcceptance =
false;
168 std::map<int, ParticleInfo> particleInfo;
171 for (
auto it = hepMCEventAfterSmearing->particles_begin(); it != hepMCEventAfterSmearing->particles_end(); ++it) {
172 const auto &
part = *it;
175 if (
part->pdg_id() != 2212)
178 if (
part->status() != 1)
184 const auto &mom =
part->momentum();
191 info.arm = (mom.z() > 0.) ? 0 : 1;
193 const double p_nom = hLHCInfo->
energy();
194 info.xi = (p_nom - mom.rho()) / p_nom;
200 for (
const auto &
pp : *hStripRecHitsPerParticle) {
201 const auto barcode =
pp.first;
203 for (
const auto &ds :
pp.second) {
206 particleInfo[barcode].recHitsPerRP[
rpId] += ds.size();
210 for (
const auto &
pp : *hPixelRecHitsPerParticle) {
211 const auto barcode =
pp.first;
213 for (
const auto &ds :
pp.second) {
216 particleInfo[barcode].recHitsPerRP[
rpId] += ds.size();
220 std::map<unsigned int, bool> isStripRPNear, isStripRPFar;
222 for (
auto &
pp : particleInfo) {
224 printf(
"* barcode=%i, arm=%u, xi=%.3f\n",
pp.first,
pp.second.arm,
pp.second.xi);
226 for (
const auto &rpp :
pp.second.recHitsPerRP) {
228 unsigned int needed_rec_hits = 1000;
234 unsigned int rpDecId = rpId.
arm() * 100 + rpId.
station() * 10 + rpId.
rp();
238 isStripRPNear[rpId.
arm()] =
true;
240 isStripRPFar[rpId.
arm()] =
true;
243 if (rpp.second >= needed_rec_hits) {
245 pp.second.inAcceptanceNear =
true;
247 pp.second.inAcceptanceFar =
true;
251 printf(
" RP %u: %u hits\n", rpDecId, rpp.second);
254 pp.second.inAcceptance =
pp.second.inAcceptanceNear &&
pp.second.inAcceptanceFar;
257 printf(
" inAcceptance: near=%u, far=%u, global=%u\n",
258 pp.second.inAcceptanceNear,
259 pp.second.inAcceptanceFar,
260 pp.second.inAcceptance);
266 unsigned int near = 0, far = 0, global = 0;
268 std::map<unsigned int, ArmCounter> nParticlesInAcceptance;
269 for (
auto &
pp : particleInfo) {
270 auto &
counter = nParticlesInAcceptance[
pp.second.arm];
271 if (
pp.second.inAcceptanceNear)
273 if (
pp.second.inAcceptanceFar)
275 if (
pp.second.inAcceptance)
280 std::map<unsigned int, ArmCounter> nReconstructedTracks;
281 for (
const auto &tr : *tracks) {
283 unsigned int rpDecId =
rpId.arm() * 100 +
rpId.station() * 10 +
rpId.rp();
286 nReconstructedTracks[
rpId.arm()].near++;
288 nReconstructedTracks[
rpId.arm()].far++;
292 std::map<unsigned int, unsigned int> nReconstructedProtons;
293 for (
const auto &
pr : *hRecoProtonsMultiRP) {
297 unsigned int arm = 2;
303 nReconstructedProtons[arm]++;
307 for (
unsigned int arm = 0; arm < 2; arm++) {
308 const auto &npa = nParticlesInAcceptance[arm];
309 const auto &nrt = nReconstructedTracks[arm];
312 printf(
"* arm %u: nRecoProtons=%u (tracks near=%u, far=%u), nAcc=%u (near=%u, far=%u)\n",
314 nReconstructedProtons[arm],
315 nReconstructedTracks[arm].near,
316 nReconstructedTracks[arm].far,
326 const auto &
p =
plots_[arm][npa.global];
328 p.h_n_part_acc_nr->Fill(npa.near);
329 p.h_n_part_acc_fr->Fill(npa.far);
332 if (nrt.near != npa.near || nrt.far != npa.far)
335 const double eff = double(nReconstructedProtons[arm]) / npa.global;
338 printf(
" eff=%.3f\n", eff);
340 for (
auto &
pp : particleInfo) {
341 if (
pp.second.arm != arm || !
pp.second.inAcceptance)
344 p.p_eff_vs_xi->Fill(
pp.second.xi, eff);
352 auto f_out = std::make_unique<TFile>(
outputFile_.c_str(),
"recreate");
354 for (
const auto &ait :
plots_) {
356 sprintf(buf,
"arm%u", ait.first);
357 TDirectory *d_arm = f_out->mkdir(buf);
359 for (
const auto &npit : ait.second) {
360 sprintf(buf,
"%u", npit.first);
361 TDirectory *d_np = d_arm->mkdir(buf);
EventNumber_t event() const
std::unique_ptr< TH1D > h_n_part_acc_nr
bool getByToken(EDGetToken token, Handle< PROD > &result) const
edm::EDGetTokenT< std::map< int, edm::DetSetVector< TotemRPRecHit > > > tokenStripRecHitsPerParticle_
std::string lhcInfoLabel_
edm::EDGetTokenT< reco::ForwardProtonCollection > tokenRecoProtonsMultiRP_
edm::EDGetTokenT< std::map< int, edm::DetSetVector< CTPPSPixelRecHit > > > tokenPixelRecHitsPerParticle_
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
std::unique_ptr< TProfile > p_eff_vs_xi
#define DEFINE_FWK_MODULE(type)
std::map< unsigned int, unsigned int > rpDecId_near_
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
std::map< unsigned int, unsigned int > rpDecId_far_
Reconstructed hit in TOTEM RP.
edm::EDGetTokenT< CTPPSLocalTrackLiteCollection > tracksToken_
std::map< unsigned int, std::map< unsigned int, PlotGroup > > plots_
const HepMC::GenEvent * GetEvent() const
std::vector< CTPPSLocalTrackLite > CTPPSLocalTrackLiteCollection
Collection of CTPPSLocalTrackLite objects.
edm::EDGetTokenT< edm::HepMCProduct > tokenHepMCAfterSmearing_
std::unique_ptr< TH1D > h_n_part_acc_fr
Base class for CTPPS detector IDs.
CTPPSProtonReconstructionEfficiencyEstimator(const edm::ParameterSet &)
float const energy() const
std::vector< ForwardProton > ForwardProtonCollection
Collection of ForwardProton objects.
void analyze(const edm::Event &, const edm::EventSetup &) override