CMS 3D CMS Logo

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