CMS 3D CMS Logo

BeamSpotHistogramMaker.cc
Go to the documentation of this file.
7 #include "TH2F.h"
8 #include "TH1F.h"
9 #include "TProfile.h"
10 
12  : _currdir(nullptr), _histoParameters(), _rhm(iC) {}
13 
15  : _currdir(nullptr),
16  _histoParameters(iConfig.getUntrackedParameter<edm::ParameterSet>("histoParameters", edm::ParameterSet())),
17  _rhm(iC) {}
18 
20 
23  TFileDirectory* currdir;
24 
25  if (!dirname.empty()) {
26  currdir = new TFileDirectory(tfserv->mkdir(dirname));
27  _currdir = currdir;
28  } else {
29  currdir = &(tfserv->tFileDirectory());
30  }
31 
32  edm::LogInfo("HistogramBooking") << "BeamSpot histogram booking in directory " << dirname;
33 
34  _hbsxrun = _rhm.makeTH1F("bsxrun",
35  "BeamSpot X position",
36  _histoParameters.getUntrackedParameter<unsigned int>("nBinX", 200),
37  _histoParameters.getUntrackedParameter<double>("xMin", -1.),
38  _histoParameters.getUntrackedParameter<double>("xMax", 1.));
39 
40  _hbsyrun = _rhm.makeTH1F("bsyrun",
41  "BeamSpot Y position",
42  _histoParameters.getUntrackedParameter<unsigned int>("nBinY", 200),
43  _histoParameters.getUntrackedParameter<double>("yMin", -1.),
44  _histoParameters.getUntrackedParameter<double>("yMax", 1.));
45 
46  _hbszrun = _rhm.makeTH1F("bszrun",
47  "BeamSpot Z position",
48  _histoParameters.getUntrackedParameter<unsigned int>("nBinZ", 200),
49  _histoParameters.getUntrackedParameter<double>("zMin", -1.),
50  _histoParameters.getUntrackedParameter<double>("zMax", 1.));
51 
52  _hbssigmaxrun = _rhm.makeTH1F("bssigmaxrun",
53  "BeamSpot sigmaX",
54  _histoParameters.getUntrackedParameter<unsigned int>("nBinSigmaX", 200),
55  _histoParameters.getUntrackedParameter<double>("sigmaXMin", 0.),
56  _histoParameters.getUntrackedParameter<double>("sigmaXMax", 0.025));
57 
58  _hbssigmayrun = _rhm.makeTH1F("bssigmayrun",
59  "BeamSpot sigmaY",
60  _histoParameters.getUntrackedParameter<unsigned int>("nBinSigmaY", 200),
61  _histoParameters.getUntrackedParameter<double>("sigmaYMin", 0.),
62  _histoParameters.getUntrackedParameter<double>("sigmaYMax", 0.025));
63 
64  _hbssigmazrun = _rhm.makeTH1F("bssigmazrun",
65  "BeamSpot sigmaZ",
66  _histoParameters.getUntrackedParameter<unsigned int>("nBinSigmaZ", 200),
67  _histoParameters.getUntrackedParameter<double>("sigmaZMin", 0.),
68  _histoParameters.getUntrackedParameter<double>("sigmaZMax", 15.));
69 
71  _rhm.makeTProfile("bsxvsorbrun", "BeamSpot X position vs orbit number", 1600, 0.5, 1600. * 16384 + 0.5);
73  _rhm.makeTProfile("bsyvsorbrun", "BeamSpot Y position vs orbit number", 1600, 0.5, 1600. * 16384 + 0.5);
75  _rhm.makeTProfile("bszvsorbrun", "BeamSpot Z position vs orbit number", 1600, 0.5, 1600. * 16384 + 0.5);
77  _rhm.makeTProfile("bssigmaxvsorbrun", "BeamSpot sigmaX vs orbit number", 1600, 0.5, 1600. * 16384 + 0.5);
79  _rhm.makeTProfile("bssigmayvsorbrun", "BeamSpot sigmaY vs orbit number", 1600, 0.5, 1600. * 16384 + 0.5);
81  _rhm.makeTProfile("bssigmazvsorbrun", "BeamSpot sigmaZ vs orbit number", 1600, 0.5, 1600. * 16384 + 0.5);
82 }
83 
84 void BeamSpotHistogramMaker::beginRun(const unsigned int nrun) {
85  char runname[100];
86  sprintf(runname, "run_%d", nrun);
87 
88  TFileDirectory* currdir = _currdir;
89  if (currdir == nullptr) {
91  currdir = &(tfserv->tFileDirectory());
92  }
93 
94  _rhm.beginRun(nrun, *currdir);
95 
96  (*_hbsxrun)->GetXaxis()->SetTitle("X [cm]");
97  (*_hbsxrun)->GetYaxis()->SetTitle("Events");
98  (*_hbsyrun)->GetXaxis()->SetTitle("Y [cm]");
99  (*_hbsyrun)->GetYaxis()->SetTitle("Events");
100  (*_hbszrun)->GetXaxis()->SetTitle("Z [cm]");
101  (*_hbszrun)->GetYaxis()->SetTitle("Events");
102  (*_hbssigmaxrun)->GetXaxis()->SetTitle("sigmaX [cm]");
103  (*_hbssigmaxrun)->GetYaxis()->SetTitle("Events");
104  (*_hbssigmayrun)->GetXaxis()->SetTitle("sigmaY [cm]");
105  (*_hbssigmayrun)->GetYaxis()->SetTitle("Events");
106  (*_hbssigmazrun)->GetXaxis()->SetTitle("sigmaZ [cm]");
107  (*_hbssigmazrun)->GetYaxis()->SetTitle("Events");
108 
109  (*_hbsxvsorbrun)->GetXaxis()->SetTitle("time [orbit#]");
110  (*_hbsxvsorbrun)->GetYaxis()->SetTitle("X [cm]");
111  (*_hbsxvsorbrun)->SetCanExtend(TH1::kAllAxes);
112  (*_hbsyvsorbrun)->GetXaxis()->SetTitle("time [orbit#]");
113  (*_hbsyvsorbrun)->GetYaxis()->SetTitle("Y [cm]");
114  (*_hbsyvsorbrun)->SetCanExtend(TH1::kAllAxes);
115  (*_hbszvsorbrun)->GetXaxis()->SetTitle("time [orbit#]");
116  (*_hbszvsorbrun)->GetYaxis()->SetTitle("Z [cm]");
117  (*_hbszvsorbrun)->SetCanExtend(TH1::kAllAxes);
118  (*_hbssigmaxvsorbrun)->GetXaxis()->SetTitle("time [orbit#]");
119  (*_hbssigmaxvsorbrun)->GetYaxis()->SetTitle("sigmaX [cm]");
120  (*_hbssigmaxvsorbrun)->SetCanExtend(TH1::kAllAxes);
121  (*_hbssigmayvsorbrun)->GetXaxis()->SetTitle("time [orbit#]");
122  (*_hbssigmayvsorbrun)->GetYaxis()->SetTitle("sigmaY [cm]");
123  (*_hbssigmayvsorbrun)->SetCanExtend(TH1::kAllAxes);
124  (*_hbssigmazvsorbrun)->GetXaxis()->SetTitle("time [orbit#]");
125  (*_hbssigmazvsorbrun)->GetYaxis()->SetTitle("sigmaZ [cm]");
126  (*_hbssigmazvsorbrun)->SetCanExtend(TH1::kAllAxes);
127 }
128 
129 void BeamSpotHistogramMaker::fill(const unsigned int orbit, const reco::BeamSpot& bs) {
130  if (_hbsxrun && *_hbsxrun)
131  (*_hbsxrun)->Fill(bs.x0());
133  (*_hbsxvsorbrun)->Fill(orbit, bs.x0());
134 
135  if (_hbsyrun && *_hbsyrun)
136  (*_hbsyrun)->Fill(bs.y0());
138  (*_hbsyvsorbrun)->Fill(orbit, bs.y0());
139 
140  if (_hbszrun && *_hbszrun)
141  (*_hbszrun)->Fill(bs.z0());
143  (*_hbszvsorbrun)->Fill(orbit, bs.z0());
144 
146  (*_hbssigmaxrun)->Fill(bs.BeamWidthX());
148  (*_hbssigmayrun)->Fill(bs.BeamWidthY());
150  (*_hbssigmazrun)->Fill(bs.sigmaZ());
152  (*_hbssigmaxvsorbrun)->Fill(orbit, bs.BeamWidthX());
154  (*_hbssigmayvsorbrun)->Fill(orbit, bs.BeamWidthY());
156  (*_hbssigmazvsorbrun)->Fill(orbit, bs.sigmaZ());
157 }
BeamSpotHistogramMaker::fill
void fill(const unsigned int orbit, const reco::BeamSpot &bs)
Definition: BeamSpotHistogramMaker.cc:129
BeamSpotHistogramMaker::_hbszvsorbrun
TProfile ** _hbszvsorbrun
Definition: BeamSpotHistogramMaker.h:45
MessageLogger.h
edm
HLT enums.
Definition: AlignableModifier.h:19
BeamSpotHistogramMaker::_hbssigmazvsorbrun
TProfile ** _hbssigmazvsorbrun
Definition: BeamSpotHistogramMaker.h:48
TFileService::tFileDirectory
TFileDirectory & tFileDirectory()
Definition: TFileService.h:42
BeamSpotHistogramMaker::_hbssigmazrun
TH1F ** _hbssigmazrun
Definition: BeamSpotHistogramMaker.h:42
BeamSpotHistogramMaker::_hbssigmayrun
TH1F ** _hbssigmayrun
Definition: BeamSpotHistogramMaker.h:41
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
TFileDirectory
Definition: TFileDirectory.h:24
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
BeamSpotHistogramMaker::~BeamSpotHistogramMaker
~BeamSpotHistogramMaker()
Definition: BeamSpotHistogramMaker.cc:19
BeamSpotHistogramMaker::_histoParameters
const edm::ParameterSet _histoParameters
Definition: BeamSpotHistogramMaker.h:34
BTVHLTOfflineSource_cfi.dirname
dirname
Definition: BTVHLTOfflineSource_cfi.py:7
cms::cuda::bs
bs
Definition: HistoContainer.h:127
BeamSpot.h
BeamSpotHistogramMaker::_currdir
TFileDirectory * _currdir
Definition: BeamSpotHistogramMaker.h:33
Service.h
BeamSpotHistogramMaker::_hbsxrun
TH1F ** _hbsxrun
Definition: BeamSpotHistogramMaker.h:37
BeamSpotHistogramMaker::_rhm
RunHistogramManager _rhm
Definition: BeamSpotHistogramMaker.h:36
reco::BeamSpot
Definition: BeamSpot.h:21
BeamSpotHistogramMaker::_hbssigmayvsorbrun
TProfile ** _hbssigmayvsorbrun
Definition: BeamSpotHistogramMaker.h:47
BeamSpotHistogramMaker::book
void book(const std::string dirname="")
Definition: BeamSpotHistogramMaker.cc:21
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
TFileService.h
TFileService::mkdir
TFileDirectory mkdir(const std::string &dir, const std::string &descr="")
create a new subdirectory
Definition: TFileService.h:69
RunHistogramManager::makeTH1F
TH1F ** makeTH1F(const char *name, const char *title, const unsigned int nbinx, const double xmin, const double xmax)
Definition: RunHistogramManager.cc:33
edm::ParameterSet
Definition: ParameterSet.h:47
ParameterSet
Definition: Functions.h:16
BeamSpotHistogramMaker::_hbsyrun
TH1F ** _hbsyrun
Definition: BeamSpotHistogramMaker.h:38
RunHistogramManager::beginRun
void beginRun(const edm::Run &iRun)
Definition: RunHistogramManager.cc:101
edm::Service< TFileService >
BeamSpotHistogramMaker::_hbssigmaxrun
TH1F ** _hbssigmaxrun
Definition: BeamSpotHistogramMaker.h:40
BeamSpotHistogramMaker::BeamSpotHistogramMaker
BeamSpotHistogramMaker(edm::ConsumesCollector &&iC)
Definition: BeamSpotHistogramMaker.cc:11
BeamSpotHistogramMaker::_hbsyvsorbrun
TProfile ** _hbsyvsorbrun
Definition: BeamSpotHistogramMaker.h:44
BeamSpotHistogramMaker::_hbssigmaxvsorbrun
TProfile ** _hbssigmaxvsorbrun
Definition: BeamSpotHistogramMaker.h:46
BeamSpotHistogramMaker::beginRun
void beginRun(const unsigned int nrun)
Definition: BeamSpotHistogramMaker.cc:84
BeamSpotHistogramMaker::_hbszrun
TH1F ** _hbszrun
Definition: BeamSpotHistogramMaker.h:39
BeamSpotHistogramMaker::_hbsxvsorbrun
TProfile ** _hbsxvsorbrun
Definition: BeamSpotHistogramMaker.h:43
ParameterSet.h
edm::ConsumesCollector
Definition: ConsumesCollector.h:45
BeamSpotHistogramMaker.h
RunHistogramManager::makeTProfile
TProfile ** makeTProfile(const char *name, const char *title, const unsigned int nbinx, const double xmin, const double xmax)
Definition: RunHistogramManager.cc:52