CMS 3D CMS Logo

SiPixelMonitorTrackSoA.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 // Package: SiPixelMonitorTrackSoA
3 // Class: SiPixelMonitorTrackSoA
4 //
7 //
8 // Author: Suvankar Roy Chowdhury
9 //
19 // DQM Histograming
25 // for string manipulations
26 #include <fmt/printf.h>
27 
28 template <typename T>
30 public:
33  ~SiPixelMonitorTrackSoA() override = default;
34  void bookHistograms(DQMStore::IBooker& ibooker, edm::Run const& iRun, edm::EventSetup const& iSetup) override;
35  void analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) override;
36  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
37 
38 private:
60 };
61 
62 //
63 // constructors
64 //
65 
66 template <typename T>
68  tokenSoATrack_ = consumes<PixelTrackHeterogeneous>(iConfig.getParameter<edm::InputTag>("pixelTrackSrc"));
69  topFolderName_ = iConfig.getParameter<std::string>("topFolderName"); //"SiPixelHeterogeneous/PixelTrackSoA";
70  useQualityCut_ = iConfig.getParameter<bool>("useQualityCut");
71  minQuality_ = pixelTrack::qualityByName(iConfig.getParameter<std::string>("minQuality"));
72 }
73 
74 //
75 // -- Analyze
76 //
77 template <typename T>
79  const auto& tsoaHandle = iEvent.getHandle(tokenSoATrack_);
80  if (!tsoaHandle.isValid()) {
81  edm::LogWarning("SiPixelMonitorTrackSoA") << "No Track SoA found \n returning!" << std::endl;
82  return;
83  }
84 
85  using helper = TracksUtilities<T>;
86  auto const& tsoa = *tsoaHandle.product();
87  auto maxTracks = tsoa.view().metadata().size();
88  auto const* quality = tsoa.view().quality();
89  int32_t nTracks = 0;
90  int32_t nLooseAndAboveTracks = 0;
91 
92  for (int32_t it = 0; it < maxTracks; ++it) {
93  auto nHits = helper::nHits(tsoa.const_view(), it);
94  auto nLayers = tsoa.view()[it].nLayers();
95  if (nHits == 0)
96  break; // this is a guard
97  float pt = tsoa.view()[it].pt();
98  if (!(pt > 0.))
99  continue;
100 
101  // fill the quality for all tracks
102  pixelTrack::Quality qual = quality[it];
103  hquality->Fill(int(qual));
104  nTracks++;
105 
106  if (useQualityCut_ && quality[it] < minQuality_)
107  continue;
108 
109  // fill parameters only for quality >= loose
110  float chi2 = tsoa.view()[it].chi2();
111  float phi = helper::phi(tsoa.const_view(), it);
112  float zip = helper::zip(tsoa.const_view(), it);
113  float eta = tsoa.view()[it].eta();
114  float tip = helper::tip(tsoa.const_view(), it);
115 
116  hchi2->Fill(chi2);
117  hChi2VsPhi->Fill(phi, chi2);
118  hChi2VsEta->Fill(eta, chi2);
119  hnHits->Fill(nHits);
120  hnLayers->Fill(nLayers);
121  hnHitsVsPhi->Fill(phi, nHits);
122  hnHitsVsEta->Fill(eta, nHits);
123  hnLayersVsPhi->Fill(phi, nLayers);
124  hnLayersVsEta->Fill(eta, nLayers);
125  hpt->Fill(pt);
126  heta->Fill(eta);
127  hphi->Fill(phi);
128  hz->Fill(zip);
129  htip->Fill(tip);
130  nLooseAndAboveTracks++;
131  }
132  hnTracks->Fill(nTracks);
133  hnLooseAndAboveTracks->Fill(nLooseAndAboveTracks);
134 }
135 
136 //
137 // -- Book Histograms
138 //
139 template <typename T>
141  edm::Run const& iRun,
142  edm::EventSetup const& iSetup) {
143  iBook.cd();
144  iBook.setCurrentFolder(topFolderName_);
145 
146  // clang-format off
147  std::string toRep = "Number of tracks";
148  hnTracks = iBook.book1D("nTracks", fmt::sprintf(";%s per event;#events",toRep), 1001, -0.5, 1000.5);
149  hnLooseAndAboveTracks = iBook.book1D("nLooseAndAboveTracks", fmt::sprintf(";%s (quality #geq loose) per event;#events",toRep), 1001, -0.5, 1000.5);
150 
151  toRep = "Number of all RecHits per track (quality #geq loose)";
152  hnHits = iBook.book1D("nRecHits", fmt::sprintf(";%s;#tracks",toRep), 15, -0.5, 14.5);
153  hnHitsVsPhi = iBook.bookProfile("nHitsPerTrackVsPhi", fmt::sprintf("%s vs track #phi;Track #phi;%s",toRep,toRep), 30, -M_PI, M_PI,0., 15.);
154  hnHitsVsEta = iBook.bookProfile("nHitsPerTrackVsEta", fmt::sprintf("%s vs track #eta;Track #eta;%s",toRep,toRep), 30, -3., 3., 0., 15.);
155 
156  toRep = "Number of all layers per track (quality #geq loose)";
157  hnLayers = iBook.book1D("nLayers", fmt::sprintf(";%s;#tracks",toRep), 15, -0.5, 14.5);
158  hnLayersVsPhi = iBook.bookProfile("nLayersPerTrackVsPhi", fmt::sprintf("%s vs track #phi;Track #phi;%s",toRep,toRep), 30, -M_PI, M_PI,0., 15.);
159  hnLayersVsEta = iBook.bookProfile("nLayersPerTrackVsEta", fmt::sprintf("%s vs track #eta;Track #eta;%s",toRep,toRep), 30, -3., 3., 0., 15.);
160 
161  toRep = "Track (quality #geq loose) #chi^{2}/ndof";
162  hchi2 = iBook.book1D("nChi2ndof", fmt::sprintf(";%s;#tracks",toRep), 40, 0., 20.);
163  hChi2VsPhi = iBook.bookProfile("nChi2ndofVsPhi", fmt::sprintf("%s vs track #phi;Track #phi;%s",toRep,toRep), 30, -M_PI, M_PI, 0., 20.);
164  hChi2VsEta = iBook.bookProfile("nChi2ndofVsEta", fmt::sprintf("%s vs track #eta;Track #eta;%s",toRep,toRep), 30, -3., 3., 0., 20.);
165  // clang-format on
166 
167  hpt = iBook.book1D("pt", ";Track (quality #geq loose) p_{T} [GeV];#tracks", 200, 0., 200.);
168  heta = iBook.book1D("eta", ";Track (quality #geq loose) #eta;#tracks", 30, -3., 3.);
169  hphi = iBook.book1D("phi", ";Track (quality #geq loose) #phi;#tracks", 30, -M_PI, M_PI);
170  hz = iBook.book1D("z", ";Track (quality #geq loose) z [cm];#tracks", 30, -30., 30.);
171  htip = iBook.book1D("tip", ";Track (quality #geq loose) TIP [cm];#tracks", 100, -0.5, 0.5);
172  hquality = iBook.book1D("quality", ";Track Quality;#tracks", 7, -0.5, 6.5);
173  uint i = 1;
174  for (const auto& q : pixelTrack::qualityName) {
175  hquality->setBinLabel(i, q, 1);
176  i++;
177  }
178 }
179 
180 template <typename T>
182  // monitorpixelTrackSoA
184  desc.add<edm::InputTag>("pixelTrackSrc", edm::InputTag("pixelTracksSoA"));
185  desc.add<std::string>("topFolderName", "SiPixelHeterogeneous/PixelTrackSoA");
186  desc.add<bool>("useQualityCut", true);
187  desc.add<std::string>("minQuality", "loose");
188  descriptions.addWithDefaultLabel(desc);
189 }
190 
193 
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
Definition: helper.py:1
pixelTrack::Quality minQuality_
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:36
Quality qualityByName(std::string const &name)
const std::string qualityName[qualitySize]
edm::EDGetTokenT< PixelTrackHeterogeneous > tokenSoATrack_
void bookHistograms(DQMStore::IBooker &ibooker, edm::Run const &iRun, edm::EventSetup const &iSetup) override
string quality
int iEvent
Definition: GenABIO.cc:224
MonitorElement * bookProfile(TString const &name, TString const &title, int nchX, double lowX, double highX, int, double lowY, double highY, char const *option="s", FUNC onbooking=NOOP())
Definition: DQMStore.h:399
OutputIterator zip(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
SiPixelMonitorTrackSoA(const edm::ParameterSet &)
#define M_PI
void analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup) override
maxTracks
Definition: DMR_cfg.py:158
MonitorElement * hnLooseAndAboveTracks
Log< level::Warning, false > LogWarning
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
TupleMultiplicity< TrackerTraits > const *__restrict__ uint32_t nHits
~SiPixelMonitorTrackSoA() override=default
Definition: Run.h:45