CMS 3D CMS Logo

CTPPSLHCInfoPlotter.cc
Go to the documentation of this file.
1 /****************************************************************************
2  * Authors:
3  * Jan Kašpar
4  ****************************************************************************/
5 
10 
13 
15 
16 #include "TFile.h"
17 #include "TH1D.h"
18 #include "TH2D.h"
19 
20 //----------------------------------------------------------------------------------------------------
21 
23 public:
24  explicit CTPPSLHCInfoPlotter(const edm::ParameterSet &);
25 
26  static void fillDescriptions(edm::ConfigurationDescriptions &descriptions);
27 
28 private:
29  void analyze(const edm::Event &, const edm::EventSetup &) override;
30  void endJob() override;
31 
35  const bool useNewLHCInfo_;
36 
38 
40  TH1D *h_xangle_;
41  TH1D *h_betaStar_;
43 
44  TH1D *h_fill_;
45  TH1D *h_run_;
46 };
47 
48 //----------------------------------------------------------------------------------------------------
49 
50 using namespace std;
51 using namespace edm;
52 
53 //----------------------------------------------------------------------------------------------------
54 
56  : lhcInfoToken_(esConsumes(ESInputTag("", iConfig.getParameter<std::string>("lhcInfoLabel")))),
57  lhcInfoPerLSToken_(esConsumes(ESInputTag("", iConfig.getParameter<std::string>("lhcInfoPerLSLabel")))),
58  lhcInfoPerFillToken_(esConsumes(ESInputTag("", iConfig.getParameter<std::string>("lhcInfoPerFillLabel")))),
59  useNewLHCInfo_(iConfig.getParameter<bool>("useNewLHCInfo")),
60  outputFile_(iConfig.getParameter<string>("outputFile")),
61 
62  h_beamEnergy_(new TH1D("h_beamEnergy", ";beam energy (GeV)", 81, -50., 8050.)),
63  h_xangle_(new TH1D("h_xangle", ";(half) crossing angle (#murad)", 201, -0.5, 200.5)),
64  h_betaStar_(new TH1D("h_betaStar", ";#beta^{*} (m)", 101, -0.005, 1.005)),
65  h2_betaStar_vs_xangle_(new TH2D("h2_betaStar_vs_xangle",
66  ";(half) crossing angle (#murad);#beta^{*} (m)",
67  201,
68  -0.5,
69  200.5,
70  101,
71  -0.005,
72  1.005)),
73 
74  h_fill_(new TH1D("h_fill", ";fill", 6001, 3999.5, 10000.5)),
75  h_run_(new TH1D("h_run", ";run", 6000, 270E3, 430E3)) {}
76 
77 //----------------------------------------------------------------------------------------------------
78 
81 
82  desc.add<std::string>("lhcInfoLabel", "")->setComment("label of the LHCInfo record");
83  desc.add<std::string>("lhcInfoPerLSLabel", "")->setComment("label of the LHCInfoPerLS record");
84  desc.add<std::string>("lhcInfoPerFillLabel", "")->setComment("label of the LHCInfoPerFill record");
85  desc.add<bool>("useNewLHCInfo", false)->setComment("flag whether to use new LHCInfoPer* records or old LHCInfo");
86 
87  desc.add<std::string>("outputFile", "")->setComment("output file");
88 
89  descriptions.add("ctppsLHCInfoPlotterDefault", desc);
90 }
91 
92 //----------------------------------------------------------------------------------------------------
93 
96 
97  h_beamEnergy_->Fill(lhcInfoCombined.energy);
98  h_xangle_->Fill(lhcInfoCombined.crossingAngle());
99  h_betaStar_->Fill(lhcInfoCombined.betaStarX); //adjust accordingly to run period
100  // h_betaStar_->Fill(lhcInfoCombined.betaStarY);
101  h2_betaStar_vs_xangle_->Fill(lhcInfoCombined.crossingAngle(),
102  lhcInfoCombined.betaStarX); //adjust accordingly to run period
103  // h2_betaStar_vs_xangle_->Fill(lhcInfoCombined.crossingAngle(), lhcInfoCombined.betaStarY);
104 
105  h_fill_->Fill(lhcInfoCombined.fillNumber);
106  h_run_->Fill(iEvent.id().run());
107 }
108 
109 //----------------------------------------------------------------------------------------------------
110 
112  auto f_out = std::make_unique<TFile>(outputFile_.c_str(), "recreate");
113 
114  h_beamEnergy_->Write();
115  h_xangle_->Write();
116  h_betaStar_->Write();
117  h2_betaStar_vs_xangle_->Write();
118 
119  h_fill_->Write();
120  h_run_->Write();
121 }
122 
123 //----------------------------------------------------------------------------------------------------
124 
void analyze(const edm::Event &, const edm::EventSetup &) override
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
float crossingAngle() const
int iEvent
Definition: GenABIO.cc:224
CTPPSLHCInfoPlotter(const edm::ParameterSet &)
const edm::ESGetToken< LHCInfoPerLS, LHCInfoPerLSRcd > lhcInfoPerLSToken_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
const edm::ESGetToken< LHCInfo, LHCInfoRcd > lhcInfoToken_
void add(std::string const &label, ParameterSetDescription const &psetDescription)
const edm::ESGetToken< LHCInfoPerFill, LHCInfoPerFillRcd > lhcInfoPerFillToken_
HLT enums.
unsigned short fillNumber