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:
61 };
62 
63 //
64 // constructors
65 //
66 
67 template <typename T>
69  tokenSoATrack_ = consumes<PixelTrackHeterogeneous>(iConfig.getParameter<edm::InputTag>("pixelTrackSrc"));
70  topFolderName_ = iConfig.getParameter<std::string>("topFolderName"); //"SiPixelHeterogeneous/PixelTrackSoA";
71  useQualityCut_ = iConfig.getParameter<bool>("useQualityCut");
72  minQuality_ = pixelTrack::qualityByName(iConfig.getParameter<std::string>("minQuality"));
73 }
74 
75 //
76 // -- Analyze
77 //
78 template <typename T>
80  const auto& tsoaHandle = iEvent.getHandle(tokenSoATrack_);
81  if (!tsoaHandle.isValid()) {
82  edm::LogWarning("SiPixelMonitorTrackSoA") << "No Track SoA found \n returning!" << std::endl;
83  return;
84  }
85 
86  using helper = TracksUtilities<T>;
87  auto const& tsoa = *tsoaHandle.product();
88  auto maxTracks = tsoa.view().metadata().size();
89  auto const* quality = tsoa.view().quality();
90  int32_t nTracks = 0;
91  int32_t nLooseAndAboveTracks = 0;
92 
93  for (int32_t it = 0; it < maxTracks; ++it) {
94  auto nHits = helper::nHits(tsoa.const_view(), it);
95  auto nLayers = tsoa.view()[it].nLayers();
96  if (nHits == 0)
97  break; // this is a guard
98  float pt = tsoa.view()[it].pt();
99  if (!(pt > 0.))
100  continue;
101 
102  // fill the quality for all tracks
104  hquality->Fill(int(qual));
105  nTracks++;
106 
107  if (useQualityCut_ && quality[it] < minQuality_)
108  continue;
109 
110  // fill parameters only for quality >= loose
111  float chi2 = tsoa.view()[it].chi2();
112  float phi = helper::phi(tsoa.const_view(), it);
113  float zip = helper::zip(tsoa.const_view(), it);
114  float eta = tsoa.view()[it].eta();
115  float tip = helper::tip(tsoa.const_view(), it);
116  auto charge = helper::charge(tsoa.const_view(), it);
117 
118  hchi2->Fill(chi2);
119  hChi2VsPhi->Fill(phi, chi2);
120  hChi2VsEta->Fill(eta, chi2);
121  hnHits->Fill(nHits);
122  hnLayers->Fill(nLayers);
123  hnHitsVsPhi->Fill(phi, nHits);
124  hnHitsVsEta->Fill(eta, nHits);
125  hnLayersVsPhi->Fill(phi, nLayers);
126  hnLayersVsEta->Fill(eta, nLayers);
127  hpt->Fill(pt);
128  hCurvature->Fill(charge / pt);
129  heta->Fill(eta);
130  hphi->Fill(phi);
131  hz->Fill(zip);
132  htip->Fill(tip);
133  nLooseAndAboveTracks++;
134  }
135  hnTracks->Fill(nTracks);
136  hnLooseAndAboveTracks->Fill(nLooseAndAboveTracks);
137 }
138 
139 //
140 // -- Book Histograms
141 //
142 template <typename T>
144  edm::Run const& iRun,
145  edm::EventSetup const& iSetup) {
146  iBook.cd();
147  iBook.setCurrentFolder(topFolderName_);
148 
149  // clang-format off
150  std::string toRep = "Number of tracks";
151  hnTracks = iBook.book1D("nTracks", fmt::sprintf(";%s per event;#events",toRep), 1001, -0.5, 2001.5);
152  hnLooseAndAboveTracks = iBook.book1D("nLooseAndAboveTracks", fmt::sprintf(";%s (quality #geq loose) per event;#events",toRep), 1001, -0.5, 2001.5);
153 
154  toRep = "Number of all RecHits per track (quality #geq loose)";
155  hnHits = iBook.book1D("nRecHits", fmt::sprintf(";%s;#tracks",toRep), 15, -0.5, 14.5);
156  hnHitsVsPhi = iBook.bookProfile("nHitsPerTrackVsPhi", fmt::sprintf("%s vs track #phi;Track #phi;%s",toRep,toRep), 30, -M_PI, M_PI,0., 15.);
157  hnHitsVsEta = iBook.bookProfile("nHitsPerTrackVsEta", fmt::sprintf("%s vs track #eta;Track #eta;%s",toRep,toRep), 30, -3., 3., 0., 15.);
158 
159  toRep = "Number of all layers per track (quality #geq loose)";
160  hnLayers = iBook.book1D("nLayers", fmt::sprintf(";%s;#tracks",toRep), 15, -0.5, 14.5);
161  hnLayersVsPhi = iBook.bookProfile("nLayersPerTrackVsPhi", fmt::sprintf("%s vs track #phi;Track #phi;%s",toRep,toRep), 30, -M_PI, M_PI,0., 15.);
162  hnLayersVsEta = iBook.bookProfile("nLayersPerTrackVsEta", fmt::sprintf("%s vs track #eta;Track #eta;%s",toRep,toRep), 30, -3., 3., 0., 15.);
163 
164  toRep = "Track (quality #geq loose) #chi^{2}/ndof";
165  hchi2 = iBook.book1D("nChi2ndof", fmt::sprintf(";%s;#tracks",toRep), 40, 0., 20.);
166  hChi2VsPhi = iBook.bookProfile("nChi2ndofVsPhi", fmt::sprintf("%s vs track #phi;Track #phi;%s",toRep,toRep), 30, -M_PI, M_PI, 0., 20.);
167  hChi2VsEta = iBook.bookProfile("nChi2ndofVsEta", fmt::sprintf("%s vs track #eta;Track #eta;%s",toRep,toRep), 30, -3., 3., 0., 20.);
168  // clang-format on
169 
170  hpt = iBook.book1D("pt", ";Track (quality #geq loose) p_{T} [GeV];#tracks", 200, 0., 200.);
171  hCurvature = iBook.book1D("curvature", ";Track (quality #geq loose) q/p_{T} [GeV^{-1}];#tracks", 100, -3., 3.);
172  heta = iBook.book1D("eta", ";Track (quality #geq loose) #eta;#tracks", 30, -3., 3.);
173  hphi = iBook.book1D("phi", ";Track (quality #geq loose) #phi;#tracks", 30, -M_PI, M_PI);
174  hz = iBook.book1D("z", ";Track (quality #geq loose) z [cm];#tracks", 30, -30., 30.);
175  htip = iBook.book1D("tip", ";Track (quality #geq loose) TIP [cm];#tracks", 100, -0.5, 0.5);
176  hquality = iBook.book1D("quality", ";Track Quality;#tracks", 7, -0.5, 6.5);
177  uint i = 1;
178  for (const auto& q : pixelTrack::qualityName) {
179  hquality->setBinLabel(i, q, 1);
180  i++;
181  }
182 }
183 
184 template <typename T>
186  // monitorpixelTrackSoA
188  desc.add<edm::InputTag>("pixelTrackSrc", edm::InputTag("pixelTracksSoA"));
189  desc.add<std::string>("topFolderName", "SiPixelHeterogeneous/PixelTrackSoA");
190  desc.add<bool>("useQualityCut", true);
191  desc.add<std::string>("minQuality", "loose");
192  descriptions.addWithDefaultLabel(desc);
193 }
194 
198 
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)
ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE constexpr float zip(ConstView const &tracks, int32_t i)
Definition: TracksSoA.h:90
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:408
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