CMS 3D CMS Logo

CTPPSLHCInfoPlotter.cc
Go to the documentation of this file.
1 /****************************************************************************
2  * Authors:
3  * Jan Kašpar
4  ****************************************************************************/
5 
10 
13 
16 
17 #include "TFile.h"
18 #include "TH1D.h"
19 #include "TH2D.h"
20 
21 //----------------------------------------------------------------------------------------------------
22 
24 public:
25  explicit CTPPSLHCInfoPlotter(const edm::ParameterSet &);
26 
27  static void fillDescriptions(edm::ConfigurationDescriptions &descriptions);
28 
29 private:
30  void analyze(const edm::Event &, const edm::EventSetup &) override;
31  void endJob() override;
32 
34 
36 
38  TH1D *h_xangle_;
39  TH1D *h_betaStar_;
41 
42  TH1D *h_fill_;
43  TH1D *h_run_;
44 };
45 
46 //----------------------------------------------------------------------------------------------------
47 
48 using namespace std;
49 using namespace edm;
50 
51 //----------------------------------------------------------------------------------------------------
52 
54  : lhcInfoESToken_(esConsumes(ESInputTag("", iConfig.getParameter<std::string>("lhcInfoLabel")))),
55  outputFile_(iConfig.getParameter<string>("outputFile")),
56 
57  h_beamEnergy_(new TH1D("h_beamEnergy", ";beam energy (GeV)", 81, -50., 8050.)),
58  h_xangle_(new TH1D("h_xangle", ";(half) crossing angle (#murad)", 201, -0.5, 200.5)),
59  h_betaStar_(new TH1D("h_betaStar", ";#beta^{*} (m)", 101, -0.005, 1.005)),
60  h2_betaStar_vs_xangle_(new TH2D("h2_betaStar_vs_xangle",
61  ";(half) crossing angle (#murad);#beta^{*} (m)",
62  201,
63  -0.5,
64  200.5,
65  101,
66  -0.005,
67  1.005)),
68 
69  h_fill_(new TH1D("h_fill", ";fill", 4001, 3999.5, 8000.5)),
70  h_run_(new TH1D("h_run", ";run", 6000, 270E3, 330E3)) {}
71 
72 //----------------------------------------------------------------------------------------------------
73 
76 
77  desc.add<std::string>("lhcInfoLabel", "")->setComment("label of the LHCInfo record");
78  desc.add<std::string>("outputFile", "")->setComment("output file");
79 
80  descriptions.add("ctppsLHCInfoPlotter", desc);
81 }
82 
83 //----------------------------------------------------------------------------------------------------
84 
86  const auto &lhcInfo = iSetup.getData(lhcInfoESToken_);
87 
88  h_beamEnergy_->Fill(lhcInfo.energy());
89  h_xangle_->Fill(lhcInfo.crossingAngle());
90  h_betaStar_->Fill(lhcInfo.betaStar());
91  h2_betaStar_vs_xangle_->Fill(lhcInfo.crossingAngle(), lhcInfo.betaStar());
92 
93  h_fill_->Fill(lhcInfo.fillNumber());
94  h_run_->Fill(iEvent.id().run());
95 }
96 
97 //----------------------------------------------------------------------------------------------------
98 
100  auto f_out = std::make_unique<TFile>(outputFile_.c_str(), "recreate");
101 
102  h_beamEnergy_->Write();
103  h_xangle_->Write();
104  h_betaStar_->Write();
105  h2_betaStar_vs_xangle_->Write();
106 
107  h_fill_->Write();
108  h_run_->Write();
109 }
110 
111 //----------------------------------------------------------------------------------------------------
112 
void analyze(const edm::Event &, const edm::EventSetup &) override
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
int iEvent
Definition: GenABIO.cc:224
CTPPSLHCInfoPlotter(const edm::ParameterSet &)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
bool getData(T &iHolder) const
Definition: EventSetup.h:122
edm::ESGetToken< LHCInfo, LHCInfoRcd > lhcInfoESToken_
void add(std::string const &label, ParameterSetDescription const &psetDescription)
HLT enums.