test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
V0Monitor.cc
Go to the documentation of this file.
3 
5 
8 
10 
11 
12 // -----------------------------
13 // constructors and destructor
14 // -----------------------------
15 
17  folderName_( iConfig.getParameter<std::string>("FolderName") )
18  , v0Token_ ( consumes<reco::VertexCompositeCandidateCollection>(iConfig.getParameter<edm::InputTag>("v0") ) )
19  , bsToken_ ( consumes<reco::BeamSpot> (iConfig.getParameter<edm::InputTag>("beamSpot") ) )
20  , pvToken_ ( consumes<reco::VertexCollection> (iConfig.getParameter<edm::InputTag>("primaryVertex") ) )
21  , lumiscalersToken_( consumes<LumiScalersCollection> (iConfig.getParameter<edm::InputTag>("lumiScalers") ) )
22  , pvNDOF_ ( iConfig.getParameter<int> ("pvNDOF") )
23  , genTriggerEventFlag_(new GenericTriggerEventFlag(iConfig.getParameter<edm::ParameterSet>("genericTriggerEventPSet"),consumesCollector(), *this))
24 {
25 
26  v0_N_ = nullptr;
27  v0_mass_ = nullptr;
28  v0_pt_ = nullptr;
29  v0_eta_ = nullptr;
30  v0_phi_ = nullptr;
31  v0_Lxy_ = nullptr;
32  v0_Lxy_wrtBS_ = nullptr;
33  v0_chi2oNDF_ = nullptr;
34  v0_mass_vs_p_ = nullptr;
35  v0_mass_vs_pt_ = nullptr;
36  v0_mass_vs_eta_ = nullptr;
37  v0_deltaMass_ = nullptr;
38  v0_deltaMass_vs_pt_ = nullptr;
39  v0_deltaMass_vs_eta_ = nullptr;
40 
41  v0_Lxy_vs_deltaMass_ = nullptr;
42  v0_Lxy_vs_pt_ = nullptr;
43  v0_Lxy_vs_eta_ = nullptr;
44 
45  v0_N_vs_BX_ = nullptr;
46  v0_mass_vs_BX_ = nullptr;
47  v0_Lxy_vs_BX_ = nullptr;
48  v0_deltaMass_vs_BX_ = nullptr;
49 
50  v0_N_vs_lumi_ = nullptr;
51  v0_mass_vs_lumi_ = nullptr;
52  v0_Lxy_vs_lumi_ = nullptr;
53  v0_deltaMass_vs_lumi_ = nullptr;
54 
55  v0_N_vs_PU_ = nullptr;
56  v0_mass_vs_PU_ = nullptr;
57  v0_Lxy_vs_PU_ = nullptr;
58  v0_deltaMass_vs_PU_ = nullptr;
59 
60 
61  edm::ParameterSet histoPSet = iConfig.getParameter<edm::ParameterSet>("histoPSet");
62  getHistoPSet(histoPSet.getParameter<edm::ParameterSet>("massPSet"), mass_binning_ );
66  getHistoPSet(histoPSet.getParameter<edm::ParameterSet>("chi2oNDFPSet"), chi2oNDF_binning_);
67  getHistoPSet(histoPSet.getParameter<edm::ParameterSet>("lumiPSet"), lumi_binning_ );
69 
70 }
71 
73 {
74  mebinning.nbins = pset.getParameter<int32_t>("nbins");
75  mebinning.xmin = pset.getParameter<double>("xmin");
76  mebinning.xmax = pset.getParameter<double>("xmax");
77 }
78 
80 {
81  std::string title_w_axes = title+";"+xaxis+";"+yaxis;
82  return ibooker.book1D(name, title_w_axes,
83  binning.nbins, binning.xmin, binning.xmax);
84 
85 }
87 {
88  std::string title_w_axes = title+";"+xaxis+";"+yaxis;
89  return ibooker.book2D(name, title_w_axes,
90  xbinning.nbins, xbinning.xmin, xbinning.xmax,
91  ybinning.nbins, ybinning.xmin, ybinning.xmax
92  );
93 }
95 {
96  std::string title_w_axes = title+";"+xaxis+";"+yaxis;
97  return ibooker.bookProfile(name, title_w_axes,
98  xbinning.nbins, xbinning.xmin, xbinning.xmax,
99  ybinning.xmin, ybinning.xmax
100  );
101 }
102 
104  edm::Run const & iRun,
105  edm::EventSetup const & iSetup)
106 {
107 
108  std::string histname, histtitle;
109 
110  std::string currentFolder = folderName_ ;
111  ibooker.setCurrentFolder(currentFolder.c_str());
112 
113  MEbinning N_binning; N_binning.nbins = 15; N_binning.xmin = -0.5; N_binning.xmax = 14.5;
114  v0_N_ = bookHisto1D(ibooker,"v0_N", "# v0", "# v0", "events",N_binning);
115  v0_mass_ = bookHisto1D(ibooker,"v0_mass", "mass", "mass [GeV]", "events",mass_binning_);
116  v0_pt_ = bookHisto1D(ibooker,"v0_pt", "pt", "p_{T} [GeV]", "events",pt_binning_ );
117  v0_eta_ = bookHisto1D(ibooker,"v0_eta", "eta", "#eta", "events",eta_binning_ );
118  MEbinning phi_binning; phi_binning.nbins = 34; phi_binning.xmin = -3.2; phi_binning.xmax = 3.2;
119  v0_phi_ = bookHisto1D(ibooker,"v0_phi", "phi", "#phi [rad]", "events",phi_binning );
120  v0_Lxy_ = bookHisto1D(ibooker,"v0_Lxy", "Lxy", "L_{xy} w.r.t. PV [cm]", "events",Lxy_binning_ );
121  v0_Lxy_wrtBS_ = bookHisto1D(ibooker,"v0_Lxy_wrtBS","Lxy", "L_{xy} w.r.t. BS [cm]", "events",Lxy_binning_ );
122  v0_chi2oNDF_ = bookHisto1D(ibooker,"v0_chi2oNDF", "chi2oNDF", "vertex normalized #chi^{2}","events",chi2oNDF_binning_ );
123 
124  v0_mass_vs_p_ = bookProfile(ibooker,"v0_mass_vs_p", "mass vs p", "p [GeV]","mass [GeV]", pt_binning_, mass_binning_);
125  v0_mass_vs_pt_ = bookProfile(ibooker,"v0_mass_vs_pt", "mass vs pt", "p_{T} [GeV]","mass [GeV]",pt_binning_, mass_binning_);
126  v0_mass_vs_eta_ = bookProfile(ibooker,"v0_mass_vs_eta","mass vs eta","#eta", "mass [GeV]",eta_binning_,mass_binning_);
127 
128  MEbinning delta_binning; delta_binning.nbins = 100; delta_binning.xmin = -1.; delta_binning.xmax = 1.;
129  v0_deltaMass_ = bookHisto1D(ibooker,"v0_deltaMass", "deltaMass", "m-m_{PDG}/m_{DPG}", "events",delta_binning );
130  v0_deltaMass_vs_pt_ = bookProfile(ibooker,"v0_deltaMass_vs_pt", "deltaMass vs pt", "p_{T} [GeV]", "m-m_{PDG}/m_{DPG}", pt_binning_, delta_binning);
131  v0_deltaMass_vs_eta_ = bookProfile(ibooker,"v0_deltaMass_vs_eta", "deltaMass vs eta", "#eta", "m-m_{PDG}/m_{DPG}", eta_binning_, delta_binning);
132 
133  v0_Lxy_vs_deltaMass_ = bookProfile(ibooker,"v0_Lxy_vs_deltaMass","L_{xy} vs deltaMass","m-m_{PDG}/m_{DPG}","L_{xy} [cm]",delta_binning,Lxy_binning_);
134  v0_Lxy_vs_pt_ = bookProfile(ibooker,"v0_Lxy_vs_pt", "L_{xy} vs p_{T}", "p_{T} [GeV]", "L_{xy} [cm]",pt_binning_, Lxy_binning_);
135  v0_Lxy_vs_eta_ = bookProfile(ibooker,"v0_Lxy_vs_eta", "L_{xy} vs #eta", "#eta", "L_{xy} [cm]",eta_binning_, Lxy_binning_);
136 
137  MEbinning bx_binning; bx_binning.nbins = 3564; bx_binning.xmin = 0.5; bx_binning.xmax = 3564.5;
138  v0_N_vs_BX_ = bookProfile(ibooker,"v0_N_vs_BX", "# v0 vs BX", "BX", "# v0", bx_binning, N_binning );
139  v0_mass_vs_BX_ = bookProfile(ibooker,"v0_mass_vs_BX", "mass vs BX", "BX", "mass [GeV]", bx_binning, mass_binning_);
140  v0_Lxy_vs_BX_ = bookProfile(ibooker,"v0_Lxy_vs_BX", "L_{xy} vs BX", "BX", "L_{xy} [cm]", bx_binning, Lxy_binning_ );
141  v0_deltaMass_vs_BX_ = bookProfile(ibooker,"v0_deltaMass_vs_BX","deltaMass vs BX","BX", "m-m_{PDG}/m_{DPG}",bx_binning, delta_binning);
142 
143  v0_N_vs_lumi_ = bookProfile(ibooker,"v0_N_vs_lumi", "# v0 vs lumi", "inst. lumi x10^{30} [Hz cm^{-2}]", "# v0", lumi_binning_, N_binning );
144  v0_mass_vs_lumi_ = bookProfile(ibooker,"v0_mass_vs_lumi", "mass vs lumi", "inst. lumi x10^{30} [Hz cm^{-2}]", "mass [GeV]", lumi_binning_, mass_binning_);
145  v0_Lxy_vs_lumi_ = bookProfile(ibooker,"v0_Lxy_vs_lumi", "L_{xy} vs lumi", "inst. lumi x10^{30} [Hz cm^{-2}]", "L_{xy} [cm]", lumi_binning_, Lxy_binning_ );
146  v0_deltaMass_vs_lumi_ = bookProfile(ibooker,"v0_deltaMass_vs_lumi","deltaMass vs lumi","inst. lumi x10^{30} [Hz cm^{-2}]", "m-m_{PDG}/m_{DPG}",lumi_binning_, delta_binning);
147 
148 
149  v0_N_vs_PU_ = bookProfile(ibooker,"v0_N_vs_PU", "# v0 vs PU", "# good PV", "# v0", pu_binning_, N_binning );
150  v0_mass_vs_PU_ = bookProfile(ibooker,"v0_mass_vs_PU", "mass vs PU", "# good PV", "mass [GeV]", pu_binning_, mass_binning_);
151  v0_Lxy_vs_PU_ = bookProfile(ibooker,"v0_Lxy_vs_PU", "L_{xy} vs PU", "# good PV", "L_{xy} [cm]", pu_binning_, Lxy_binning_ );
152  v0_deltaMass_vs_PU_ = bookProfile(ibooker,"v0_deltaMass_vs_PU","deltaMass vs PU","# good PV", "m-m_{PDG}/m_{DPG}",pu_binning_, delta_binning);
153 
154 
155 }
156 
158 
159  // int ls = iEvent.id().luminosityBlock();
160 
162  iEvent.getByToken(v0Token_, v0Handle);
163  if (!v0Handle.isValid() or v0Handle->size() == 0)
164  return;
165 
166  size_t bx = iEvent.bunchCrossing();
167 
168  float lumi = -1.;
170  iEvent.getByToken(lumiscalersToken_, lumiScalers);
171  if ( lumiScalers.isValid() && lumiScalers->size() ) {
172  LumiScalersCollection::const_iterator scalit = lumiScalers->begin();
173  lumi = scalit->instantLumi();
174  } else
175  lumi = -1.;
176 
177  edm::Handle<reco::BeamSpot> beamspotHandle;
178  iEvent.getByToken(bsToken_,beamspotHandle);
179  reco::BeamSpot const * bs = nullptr;
180  if (beamspotHandle.isValid())
181  bs = &(*beamspotHandle);
182 
183 
185  iEvent.getByToken(pvToken_, pvHandle );
186  reco::Vertex const * pv = nullptr;
187  size_t nPV = 0;
188  if (pvHandle.isValid()) {
189  pv = &pvHandle->front();
190  //--- pv fake (the pv collection should have size==1 and the pv==beam spot)
191  if ( pv->isFake() || pv->tracksSize()==0
192  // definition of goodOfflinePrimaryVertex
193  || pv->ndof() < pvNDOF_ || pv->z() > 24.) pv = nullptr;
194 
195  for (auto v : *pvHandle) {
196  if (v.isFake() ) continue;
197  if (v.ndof() < pvNDOF_) continue;
198  if (v.z() > 24. ) continue;
199  ++nPV;
200  }
201  }
202 
204  size_t n = v0s.size();
205  v0_N_ -> Fill(n);
206  v0_N_vs_BX_ -> Fill(bx, n);
207  v0_N_vs_lumi_ -> Fill(lumi,n);
208  v0_N_vs_PU_ -> Fill(nPV, n);
209  for ( auto v0 : v0s ) {
210  float mass = v0.mass();
211  float pt = v0.pt();
212  float p = v0.p();
213  float eta = v0.eta();
214  float phi = v0.phi();
215  int pdgID = v0.pdgId();
216  float chi2oNDF = v0.vertexNormalizedChi2();
217  GlobalPoint displacementFromPV = ( pv==nullptr ? GlobalPoint(-9.,-9.,0) : GlobalPoint( (pv->x() - v0.vx()),
218  (pv->y() - v0.vy()),
219  0. ) );
220  GlobalPoint displacementFromBS = ( bs==nullptr ? GlobalPoint(-9.-9.,0.) : GlobalPoint( -1*((bs->position().x() - v0.vx()) + (v0.vz() - bs->position().z()) * bs->dxdz()),
221  -1*((bs->position().y() - v0.vy()) + (v0.vz() - bs->position().z()) * bs->dydz()),
222  0 ) );
223  float lxy = ( pv==nullptr ? -9. : displacementFromPV.perp() );
224  float lxyWRTbs = ( bs==nullptr ? -9. : displacementFromBS.perp() );
225 
226  v0_mass_ -> Fill(mass);
227  v0_pt_ -> Fill(pt);
228  v0_eta_ -> Fill(eta);
229  v0_phi_ -> Fill(phi);
230  v0_Lxy_ -> Fill(lxy);
231  v0_Lxy_wrtBS_-> Fill(lxyWRTbs);
232  v0_chi2oNDF_ -> Fill(chi2oNDF);
233 
234  v0_mass_vs_p_ -> Fill(p, mass);
235  v0_mass_vs_pt_ -> Fill(pt, mass);
236  v0_mass_vs_eta_ -> Fill(eta, mass);
237  v0_mass_vs_BX_ -> Fill(bx, mass);
238  v0_mass_vs_lumi_ -> Fill(lumi,mass);
239  v0_mass_vs_PU_ -> Fill(nPV, mass);
240 
241  v0_Lxy_vs_BX_ -> Fill(bx, lxy);
242  v0_Lxy_vs_lumi_ -> Fill(lumi,lxy);
243  v0_Lxy_vs_PU_ -> Fill(nPV, lxy);
244 
245  float PDGmass = -9999.;
246  switch(pdgID) {
247  case 130: // K_s
248  case 310: // K_L
249  PDGmass = 0.497614; // GeV
250  break;
251  case 3122: // Lambda
252  case -3122: // Lambda
253  PDGmass = 1.115683; // GeV
254  break;
255  case 4122: // Lambda_c
256  case -4122: // Lambda_c
257  case 5122: // Lambda_b
258  case -5122: // Lambda_b
259  default:
260  break;
261  }
262  float delta = (PDGmass > 0. ? (mass-PDGmass)/PDGmass : -9.);
263  v0_deltaMass_ -> Fill (delta);
264  v0_deltaMass_vs_pt_ -> Fill (pt, delta);
265  v0_deltaMass_vs_eta_ -> Fill (eta, delta);
266  v0_deltaMass_vs_BX_ -> Fill (bx, delta);
267  v0_deltaMass_vs_lumi_ -> Fill (lumi,delta);
268  v0_deltaMass_vs_PU_ -> Fill (nPV, delta);
269 
270  v0_Lxy_vs_deltaMass_ -> Fill (delta,lxy);
271  v0_Lxy_vs_pt_ -> Fill (pt, lxy);
272  v0_Lxy_vs_eta_ -> Fill (eta, lxy);
273  }
274 
275 }
276 
277 // Define this as a plug-in
MEbinning pu_binning_
Definition: V0Monitor.h:108
MonitorElement * v0_Lxy_vs_pt_
Definition: V0Monitor.h:84
dbl * delta
Definition: mlp_gen.cc:36
T getParameter(std::string const &) const
MonitorElement * v0_deltaMass_vs_PU_
Definition: V0Monitor.h:100
MonitorElement * v0_mass_vs_PU_
Definition: V0Monitor.h:98
MonitorElement * v0_pt_
Definition: V0Monitor.h:70
MonitorElement * v0_Lxy_vs_PU_
Definition: V0Monitor.h:99
MonitorElement * v0_mass_vs_eta_
Definition: V0Monitor.h:78
MonitorElement * v0_mass_vs_lumi_
Definition: V0Monitor.h:93
std::vector< VertexCompositeCandidate > VertexCompositeCandidateCollection
collection of Candidate objects
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Definition: V0Monitor.cc:103
T perp() const
Definition: PV3DBase.h:72
MEbinning Lxy_binning_
Definition: V0Monitor.h:105
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventIDconst &, edm::Timestampconst & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
void getHistoPSet(edm::ParameterSet pset, MEbinning &mebinning)
Definition: V0Monitor.cc:72
MonitorElement * bookProfile(Args &&...args)
Definition: DQMStore.h:157
V0Monitor(const edm::ParameterSet &)
Definition: V0Monitor.cc:16
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
MonitorElement * v0_mass_vs_p_
Definition: V0Monitor.h:76
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
tuple lumi
Definition: fjr2json.py:35
double y() const
y coordinate
Definition: Vertex.h:103
MonitorElement * v0_mass_
Definition: V0Monitor.h:69
MEbinning lumi_binning_
Definition: V0Monitor.h:107
MonitorElement * v0_chi2oNDF_
Definition: V0Monitor.h:75
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
int bunchCrossing() const
Definition: EventBase.h:65
MonitorElement * v0_mass_vs_pt_
Definition: V0Monitor.h:77
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
MonitorElement * v0_deltaMass_
Definition: V0Monitor.h:79
Provides a code based selection for trigger and DCS information in order to have no failing filters i...
MonitorElement * v0_eta_
Definition: V0Monitor.h:71
edm::EDGetTokenT< reco::BeamSpot > bsToken_
Definition: V0Monitor.h:60
double dydz() const
dydz slope
Definition: BeamSpot.h:84
int iEvent
Definition: GenABIO.cc:230
MonitorElement * v0_deltaMass_vs_lumi_
Definition: V0Monitor.h:95
MonitorElement * bookHisto2D(DQMStore::IBooker &ibooker, std::string name, std::string title, std::string xaxis, std::string yaxis, MEbinning xbinning, MEbinning ybinning)
Definition: V0Monitor.cc:86
edm::EDGetTokenT< reco::VertexCompositeCandidateCollection > v0Token_
Definition: V0Monitor.h:59
MonitorElement * v0_Lxy_vs_BX_
Definition: V0Monitor.h:89
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
double xmin
Definition: V0Monitor.h:31
MonitorElement * v0_Lxy_wrtBS_
Definition: V0Monitor.h:74
int pvNDOF_
Definition: V0Monitor.h:64
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:115
std::string folderName_
Definition: V0Monitor.h:57
double z() const
y coordinate
Definition: Vertex.h:105
MonitorElement * v0_Lxy_vs_lumi_
Definition: V0Monitor.h:94
MonitorElement * v0_Lxy_vs_eta_
Definition: V0Monitor.h:85
MonitorElement * bookHisto1D(DQMStore::IBooker &ibooker, std::string name, std::string title, std::string xaxis, std::string yaxis, MEbinning binning)
Definition: V0Monitor.cc:79
MonitorElement * v0_deltaMass_vs_BX_
Definition: V0Monitor.h:90
edm::EDGetTokenT< reco::VertexCollection > pvToken_
Definition: V0Monitor.h:61
bool isValid() const
Definition: HandleBase.h:75
double dxdz() const
dxdz slope
Definition: BeamSpot.h:82
MonitorElement * v0_deltaMass_vs_eta_
Definition: V0Monitor.h:81
double ndof() const
Definition: Vertex.h:95
MEbinning pt_binning_
Definition: V0Monitor.h:103
MEbinning chi2oNDF_binning_
Definition: V0Monitor.h:106
double x() const
x coordinate
Definition: Vertex.h:101
MonitorElement * bookProfile(DQMStore::IBooker &ibooker, std::string name, std::string title, std::string xaxis, std::string yaxis, MEbinning xbinning, MEbinning ybinning)
Definition: V0Monitor.cc:94
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:276
bool isFake() const
Definition: Vertex.h:64
MonitorElement * v0_N_
Definition: V0Monitor.h:68
T const * product() const
Definition: Handle.h:81
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:133
MEbinning mass_binning_
Definition: V0Monitor.h:102
edm::EDGetTokenT< LumiScalersCollection > lumiscalersToken_
Definition: V0Monitor.h:62
MonitorElement * v0_Lxy_vs_deltaMass_
Definition: V0Monitor.h:83
int nbins
Definition: V0Monitor.h:30
void analyze(edm::Event const &iEvent, edm::EventSetup const &iSetup)
Definition: V0Monitor.cc:157
MEbinning eta_binning_
Definition: V0Monitor.h:104
std::vector< LumiScalers > LumiScalersCollection
Definition: LumiScalers.h:160
const Point & position() const
position
Definition: BeamSpot.h:62
MonitorElement * v0_phi_
Definition: V0Monitor.h:72
MonitorElement * v0_N_vs_BX_
Definition: V0Monitor.h:87
MonitorElement * v0_mass_vs_BX_
Definition: V0Monitor.h:88
MonitorElement * v0_N_vs_lumi_
Definition: V0Monitor.h:92
size_t tracksSize() const
number of tracks
Definition: Vertex.cc:34
Definition: Run.h:43
MonitorElement * v0_N_vs_PU_
Definition: V0Monitor.h:97
double xmax
Definition: V0Monitor.h:32
MonitorElement * v0_Lxy_
Definition: V0Monitor.h:73
MonitorElement * v0_deltaMass_vs_pt_
Definition: V0Monitor.h:80