46 SingleArmPlots() : h_xi_all(new TH1D(
"",
";#xi", 100, 0., 0.25)), h_xi_acc(new TH1D(
"",
";#xi", 100, 0., 0.25)) {}
55 h_xi_all->Write(
"h_xi_all");
56 h_xi_acc->Write(
"h_xi_acc");
58 auto h_xi_rat = std::make_unique<TH1D>(*h_xi_acc);
59 h_xi_rat->Divide(h_xi_all.get());
60 h_xi_rat->Write(
"h_xi_rat");
73 : h_m_all(new TH1D(
"",
";m (GeV)", 100, 0., 2500.)),
74 h_m_acc(new TH1D(
"",
";m (GeV)", 100, 0., 2500.)),
75 h2_xi_45_vs_xi_56_all(new TH2D(
"",
";xi_56;xi_45", 25, 0., 0.25, 25, 0., 0.25)),
76 h2_xi_45_vs_xi_56_acc(new TH2D(
"",
";xi_56;xi_45", 25, 0., 0.25, 25, 0., 0.25)),
77 h2_y_vs_m_all(new TH2D(
"",
";m (GeV);y", 25, 0., 2500., 25, -1.5, +1.5)),
78 h2_y_vs_m_acc(new TH2D(
"",
";m (GeV);y", 25, 0., 2500., 25, -1.5, +1.5)) {}
80 void fill(
double xi_45,
double xi_56,
bool acc) {
81 const double p_nom = 6500.;
82 const double m = 2. * p_nom *
sqrt(xi_45 * xi_56);
83 const double y =
log(xi_45 / xi_56) / 2.;
86 h2_xi_45_vs_xi_56_all->Fill(xi_56, xi_45);
87 h2_y_vs_m_all->Fill(m, y);
91 h2_xi_45_vs_xi_56_acc->Fill(xi_56, xi_45);
92 h2_y_vs_m_acc->Fill(m, y);
97 h_m_all->Write(
"h_m_all");
98 h_m_acc->Write(
"h_m_acc");
100 auto h_m_rat = std::make_unique<TH1D>(*h_m_acc);
101 h_m_rat->Divide(h_m_all.get());
102 h_m_rat->Write(
"h_m_rat");
104 h2_xi_45_vs_xi_56_all->Write(
"h2_xi_45_vs_xi_56_all");
105 h2_xi_45_vs_xi_56_acc->Write(
"h2_xi_45_vs_xi_56_acc");
107 auto h2_xi_45_vs_xi_56_rat = std::make_unique<TH2D>(*h2_xi_45_vs_xi_56_acc);
108 h2_xi_45_vs_xi_56_rat->Divide(h2_xi_45_vs_xi_56_all.get());
109 h2_xi_45_vs_xi_56_rat->Write(
"h2_xi_45_vs_xi_56_rat");
111 h2_y_vs_m_all->Write(
"h2_y_vs_m_all");
112 h2_y_vs_m_acc->Write(
"h2_y_vs_m_acc");
114 auto h2_y_vs_m_rat = std::make_unique<TH2D>(*h2_y_vs_m_acc);
115 h2_y_vs_m_rat->Divide(h2_y_vs_m_all.get());
116 h2_y_vs_m_rat->Write(
"h2_y_vs_m_rat");
128 using namespace HepMC;
168 bool proton_45_set =
false;
169 bool proton_56_set =
false;
170 FourVector mom_45, mom_56;
172 for (
auto it = hepMCEvent->particles_begin(); it != hepMCEvent->particles_end(); ++it) {
173 const auto &
part = *it;
176 if (
part->pdg_id() != 2212)
179 if (
part->status() != 1)
185 const auto &mom =
part->momentum();
193 LogError(
"CTPPSAcceptancePlotter") <<
"Multiple protons found in sector 45.";
197 proton_45_set =
true;
202 LogError(
"CTPPSAcceptancePlotter") <<
"Multiple protons found in sector 56.";
206 proton_56_set =
true;
212 if (!proton_45_set || !proton_56_set)
216 const double p_nom = 6500.;
217 const double xi_45 = (p_nom - mom_45.e()) / p_nom;
218 const double xi_56 = (p_nom - mom_56.e()) / p_nom;
221 map<unsigned int, bool> trackPresent;
222 for (
const auto &trk : *hTracks) {
224 unsigned int rpDecId = rpId.
arm() * 100 + rpId.station() * 10 + rpId.rp();
225 trackPresent[rpDecId] =
true;
232 for (
const auto rpId : rpIds) {
233 acc &= trackPresent[rpId];
240 const double xi = (arm == 0) ? xi_45 : xi_56;
247 for (
const auto rpId : rpIds)
248 acc &= trackPresent[rpId];
257 auto f_out = std::make_unique<TFile>(
outputFile_.c_str(),
"recreate");
261 for (
const auto &rpId :
p.first) {
262 if (!dirName.empty())
264 dirName += Form(
"%u", rpId);
267 gDirectory = f_out->mkdir(dirName.c_str());
273 for (
const auto &rpId :
p.first) {
274 if (!dirName.empty())
276 dirName += Form(
"%u", rpId);
279 gDirectory = f_out->mkdir(dirName.c_str());
std::unique_ptr< TH1D > h_xi_acc
bool getByToken(EDGetToken token, Handle< PROD > &result) const
CTPPSAcceptancePlotter(const edm::ParameterSet &)
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
#define DEFINE_FWK_MODULE(type)
std::unique_ptr< TH1D > h_xi_all
std::unique_ptr< TH1D > h_m_all
std::unique_ptr< TH2D > h2_y_vs_m_all
std::map< std::set< unsigned int >, SingleArmPlots > singleArmPlots
edm::EDGetTokenT< edm::HepMCProduct > tokenHepMC_
std::vector< std::set< unsigned int > > singleArmConfigurations
std::map< std::set< unsigned int >, DoubleArmPlots > doubleArmPlots
edm::EDGetTokenT< CTPPSLocalTrackLiteCollection > tokenTracks_
void fill(double xi_45, double xi_56, bool acc)
std::unique_ptr< TH2D > h2_xi_45_vs_xi_56_all
const HepMC::GenEvent * GetEvent() const
std::vector< CTPPSLocalTrackLite > CTPPSLocalTrackLiteCollection
Collection of CTPPSLocalTrackLite objects.
Base class for CTPPS detector IDs.
void fill(double xi, bool acc)
void analyze(const edm::Event &, const edm::EventSetup &) override
std::vector< std::set< unsigned int > > doubleArmConfigurations