21 #include <fmt/format.h> 22 #include <fmt/printf.h> 110 : m_clusterInfo(consumesCollector()),
111 mismatchedBField_{
false},
112 mismatchedLatency_{
false},
114 saveHistosMods_(iConfig.getParameter<
bool>(
"saveHistoMods")),
116 m_association_token(consumes<TrajTrackAssociationCollection>(iConfig.getParameter<
edm::InputTag>(
"Tracks"))),
117 m_tkGeomToken{esConsumes<>()},
118 m_latencyTokenBR{esConsumes<edm::Transition::BeginRun>()},
119 m_topoEsTokenBR{esConsumes<edm::Transition::BeginRun>()},
120 m_tkGeomTokenBR{esConsumes<edm::Transition::BeginRun>()},
121 m_magFieldTokenBR{esConsumes<edm::Transition::BeginRun>()},
122 m_lorentzAngleTokenBR{esConsumes<edm::Transition::BeginRun>()} {}
134 const auto& theMagField = 1.f / (magField.inverseBzAtOriginInGeV() *
teslaToInverseGeV_);
153 std::vector<uint32_t> c_rawid;
154 std::vector<float> c_globalZofunitlocalY, c_localB, c_BdotY, c_driftx, c_drifty, c_driftz, c_lorentzAngle;
156 auto dets = tkGeom.detsTIB();
158 dets.insert(dets.end(), tkGeom.detsTOB().begin(), tkGeom.detsTOB().end());
161 for (
auto det : dets) {
162 auto detid = det->geographicalId().rawId();
165 c_rawid.push_back(detid);
169 c_localB.push_back(locB.mag());
172 c_driftx.push_back(
drift.
x());
173 c_drifty.push_back(
drift.
y());
174 c_driftz.push_back(
drift.
z());
175 c_lorentzAngle.push_back(lorentzAngle.getLorentzAngle(detid));
182 std::sort(c_rawid.begin(), c_rawid.end());
205 unsigned int layer = 0;
242 std::vector<OnTrackCluster>
clusters{};
245 for (
const auto&
assoc : *trajTrackAssociations) {
246 const auto traj =
assoc.key.get();
254 const auto normChi2 =
track->ndof() > 0 ?
track->chi2() /
track->ndof() : -1.;
255 iHists_.
h1_[
"track_chi2ndof"]->Fill(normChi2);
256 iHists_.
h2_[
"track_chi2xhits"]->Fill(normChi2,
track->numberOfValidHits());
264 <<
" track pT()" <<
track->pt() <<
" track eta()" <<
track->eta() << std::endl;
266 for (
const auto& meas : traj->measurements()) {
267 const auto& trajState = meas.updatedState();
268 if (!trajState.isValid())
272 const auto trechit = meas.recHit()->hit();
280 clusters.emplace_back(simple->geographicalId().rawId(), simple->cluster().get(), traj,
track, meas);
281 }
else if (simple1d) {
282 clusters.emplace_back(simple1d->geographicalId().rawId(), simple1d->cluster().get(), traj,
track, meas);
288 uint32_t c_nstrips = clus.cluster->amplitudes().size();
291 const auto& trajState = clus.measurement.updatedState();
292 const auto trackDir = trajState.localDirection();
293 float c_localdirx = trackDir.x();
294 float c_localdiry = trackDir.y();
295 float c_localdirz = trackDir.z();
296 const auto hit = clus.measurement.recHit()->hit();
308 const uint32_t
mod =
hit->geographicalId().rawId();
311 if (locationtype.empty())
322 TVector3 localdir(c_localdirx, c_localdiry, c_localdirz);
324 float tantheta = TMath::Tan(localdir.Theta());
325 float cosphi = TMath::Cos(localdir.Phi());
326 float theta = localdir.Theta();
328 iHists_.
h1_[Form(
"%s_nstrips", locationtype.c_str())]->
Fill(c_nstrips);
330 iHists_.
h1_[Form(
"%s_cosphitrk", locationtype.c_str())]->
Fill(cosphi);
333 iHists_.
h2_[Form(
"%s_tanthcosphtrk_nstrip", locationtype.c_str())]->
Fill(
sign * cosphi * tantheta, c_nstrips);
343 if (c_nstrips == 2) {
344 iHists_.
h1_[Form(
"%s_variance_w2", locationtype.c_str())]->
Fill(c_variance);
345 iHists_.
h2_[Form(
"%s_tanthcosphtrk_var2", locationtype.c_str())]->
Fill(
sign * cosphi * tantheta, c_variance);
351 iHists_.
h1_[Form(
"%s_%d_variance_w2", locationtype.c_str(),
mod)]->
Fill(c_variance);
357 if (c_nstrips == 3) {
358 iHists_.
h1_[Form(
"%s_variance_w3", locationtype.c_str())]->
Fill(c_variance);
359 iHists_.
h2_[Form(
"%s_tanthcosphtrk_var3", locationtype.c_str())]->
Fill(
sign * cosphi * tantheta, c_variance);
364 iHists_.
h1_[Form(
"%s_%d_variance_w3", locationtype.c_str(),
mod)]->
Fill(c_variance);
389 iHists_.
h1_[
"track_pt"] = ibook.
book1D(
"track_pt",
"track p_{T};track p_{T} [GeV];n. tracks", 2000, 0, 1000);
390 iHists_.
h1_[
"track_eta"] = ibook.
book1D(
"track_eta",
"track #eta;track #eta;n. tracks", 100, -4, 4);
391 iHists_.
h1_[
"track_phi"] = ibook.
book1D(
"track_phi",
"track #phi;track #phi;n. tracks", 80, -3.2, 3.2);
393 ibook.
book1D(
"track_validhits",
"track n. valid hits;track n. valid hits;n. tracks", 50, 0, 50);
395 ibook.
book1D(
"track_chi2ndof",
"track #chi^{2}/ndf;track #chi^{2}/ndf;n. tracks", 100, 0, 5);
397 ibook.
book2D(
"track_chi2xhits_2d",
398 "track track n. hits vs track #chi^{2}/ndf;track #chi^{2};track n. valid hits;tracks",
399 100, 0, 5, 50, 0, 50);
401 "track_ptxhits_2d",
"track n. hits vs p_{T};track p_{T} [GeV];track n. valid hits;tracks", 200, 0, 100, 50, 0, 50);
403 "track_etaxhits_2d",
"track n. hits vs track #eta;track #eta;track n. valid hits;tracks", 60, -3, 3, 50, 0, 50);
405 ibook.
book2D(
"track_ptxchi2_2d",
406 "track #chi^{2}/ndf vs track p_{T};track p_{T} [GeV]; track #chi^{2}/ndf;tracks",
407 200, 0, 100, 100, 0, 5);
409 "track_ptxeta_2d",
"track #eta vs track p_{T};track p_{T} [GeV];track #eta;tracks", 200, 0, 100, 60, -3, 3);
411 "track_etaxchi2_2d",
"track #chi^{2}/ndf vs track #eta;track #eta;track #chi^{2};tracks", 60, -3, 3, 100, 0, 5);
415 iHists_.
h1_[
"occupancyPerIndex"] = ibook.
book1D(
"ClusterOccupancyPerHashedIndex",
416 "cluster occupancy;hashed index;# clusters per module",
431 for (
int l = 1;
l <=
layers.second; ++
l) {
435 if (
l > 2 &&
t ==
"s")
437 std::string locType = Form(
"%s_L%d%s", subdet.c_str(),
l,
t.c_str());
440 const char*
titles = Form(
"n.strips in %s;n.strips;n. clusters", locType.c_str());
441 iHists_.
h1_[Form(
"%s_nstrips", locType.c_str())] = ibook.
book1D(Form(
"%s_nstrips", locType.c_str()),
titles, 20, 0, 20);
443 titles = Form(
"tan(#theta_{trk}) in %s;tan(#theta_{trk});n. clusters", locType.c_str());
444 iHists_.
h1_[Form(
"%s_tanthetatrk", locType.c_str())] = ibook.
book1D(Form(
"%s_tanthetatrk", locType.c_str()),
titles, 300, -1.5, 1.5);
446 titles = Form(
"cos(#phi_{trk}) in %s;cos(#phi_{trk});n. clusters", locType.c_str());
447 iHists_.
h1_[Form(
"%s_cosphitrk", locType.c_str())] = ibook.
book1D(Form(
"%s_cosphitrk", locType.c_str()),
titles, 40, -1, 1);
449 titles = Form(
"Cluster variance (w=2) in %s;cluster variance (w=2);n. clusters", locType.c_str());
450 iHists_.
h1_[Form(
"%s_variance_w2", locType.c_str())] = ibook.
book1D(Form(
"%s_variance_w2", locType.c_str()),
titles, 100, 0, 1);
452 titles = Form(
"Cluster variance (w=3) in %s;cluster variance (w=3);n. clusters", locType.c_str());
453 iHists_.
h1_[Form(
"%s_variance_w3", locType.c_str())] = ibook.
book1D(Form(
"%s_variance_w3", locType.c_str()),
titles, 100, 0, 1);
455 titles = Form(
"n. strips in %s vs tan(#theta_{trk})cos(#phi_{trk});tan(#theta_{trk})cos(#phi_{trk});n. strips;n. clusters", locType.c_str());
456 iHists_.
h2_[Form(
"%s_tanthcosphtrk_nstrip", locType.c_str())] = ibook.
book2D(Form(
"%s_tanthcosphtrk_nstrip", locType.c_str()),
titles, 360, -0.9, 0.9, 20, 0, 20);
458 titles = Form(
"n. strips in %s vs #theta_{trk};#theta_{trk} [rad];n. strips;n. clusters", locType.c_str());
459 iHists_.
h2_[Form(
"%s_thetatrk_nstrip", locType.c_str())] = ibook.
book2D(Form(
"%s_thetatrk_nstrip", locType.c_str()),
titles, 360, -0.9, 0.9, 20, 0, 20);
461 titles = Form(
"cluster variance (w=2) in %s vs tan(#theta_{trk})cos(#phi_{trk});tan(#theta_{trk})cos(#phi_{trk});cluster variance (w=2);n. clusters", locType.c_str());
462 iHists_.
h2_[Form(
"%s_tanthcosphtrk_var2", locType.c_str())] = ibook.
book2D(Form(
"%s_tanthcosphtrk_var2", locType.c_str()),
titles, 360, -0.9, 0.9, 50, 0, 1);
464 titles = Form(
"cluster variance (w=3) in %s vs tan(#theta_{trk})cos(#phi_{trk});tan(#theta_{trk})cos(#phi_{trk});cluster variance (w=3);n. clusters", locType.c_str());
465 iHists_.
h2_[Form(
"%s_tanthcosphtrk_var3", locType.c_str())] = ibook.
book2D(Form(
"%s_tanthcosphtrk_var3", locType.c_str()),
titles, 360, -0.9, 0.9, 50, 0, 1);
467 titles = Form(
"cluster variance (w=2) in %s vs #theta_{trk}cos(#phi_{trk});#theta_{trk}cos(#phi_{trk});cluster variance (w=2);n. clusters", locType.c_str());
468 iHists_.
h2_[Form(
"%s_thcosphtrk_var2", locType.c_str())] = ibook.
book2D(Form(
"%s_thcosphtrk_var2", locType.c_str()),
titles, 360, -0.9, 0.9, 50, 0, 1);
470 titles = Form(
"cluster variance (w=3) in %s vs #theta_{trk}cos(#phi_{trk});#theta_{trk}cos(#phi_{trk});cluster variance (w=3);n. clusters", locType.c_str());
471 iHists_.
h2_[Form(
"%s_thcosphtrk_var3", locType.c_str())] = ibook.
book2D(Form(
"%s_thcosphtrk_var3", locType.c_str()),
titles, 360, -0.9, 0.9, 50, 0, 1);
481 ibook.
setCurrentFolder(folderToBook +
"/modules" + Form(
"/%s", locationType.c_str()));
483 iHists_.
h1_[Form(
"%s_%d_nstrips", locationType.c_str(),
mod)] =
484 ibook.
book1D(Form(
"%s_%d_nstrips", locationType.c_str(),
mod),
"", 10, 0, 10);
485 iHists_.
h1_[Form(
"%s_%d_tanthetatrk", locationType.c_str(),
mod)] =
486 ibook.
book1D(Form(
"%s_%d_tanthetatrk", locationType.c_str(),
mod),
"", 40, -1., 1.);
487 iHists_.
h1_[Form(
"%s_%d_cosphitrk", locationType.c_str(),
mod)] =
488 ibook.
book1D(Form(
"%s_%d_cosphitrk", locationType.c_str(),
mod),
"", 40, -1, 1);
489 iHists_.
h1_[Form(
"%s_%d_variance_w2", locationType.c_str(),
mod)] =
490 ibook.
book1D(Form(
"%s_%d_variance_w2", locationType.c_str(),
mod),
"", 20, 0, 1);
491 iHists_.
h1_[Form(
"%s_%d_variance_w3", locationType.c_str(),
mod)] =
492 ibook.
book1D(Form(
"%s_%d_variance_w3", locationType.c_str(),
mod),
"", 20, 0, 1);
498 LogDebug(
"SiStripLorentzAnglePCLMonitor")
501 ibook.
setCurrentFolder(folderToBook +
"/modules" + Form(
"/%s", locationType.c_str()));
503 ibook.
book2D(Form(
"ct_w_m_%s_%d", locationType.c_str(), *iter),
"", 90, -0.9, 0.9, 10, 0, 10));
505 ibook.
book2D(Form(
"t_w_m_%s_%d", locationType.c_str(), *iter),
"", 90, -0.9, 0.9, 10, 0, 10));
507 ibook.
book2D(Form(
"ct_var2_m_%s_%d", locationType.c_str(), *iter),
"", 90, -0.9, 0.9, 20, 0, 1));
509 ibook.
book2D(Form(
"ct_var3_m_%s_%d", locationType.c_str(), *iter),
"", 90, -0.9, 0.9, 20, 0, 1));
511 ibook.
book2D(Form(
"t_var2_m_%s_%d", locationType.c_str(), *iter),
"", 90, -0.9, 0.9, 20, 0, 1));
513 ibook.
book2D(Form(
"t_var3_m_%s_%d", locationType.c_str(), *iter),
"", 90, -0.9, 0.9, 20, 0, 1));
517 << __PRETTY_FUNCTION__ <<
" Booked " <<
counter <<
" module level histograms!";
524 desc.add<
std::string>(
"folder",
"AlCaReco/SiStripLorentzAngle")->setComment(
"DQM folder to write into");
525 desc.add<
bool>(
"saveHistoMods",
false)->setComment(
"save module level hisotgrams. Warning! takes a lot of space!");
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
static const std::array< std::string, 5 > titles
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
std::vector< std::string > modtypes_
const edm::ESGetToken< SiStripLorentzAngle, SiStripLorentzAngleDepRcd > m_lorentzAngleTokenBR
Local3DVector LocalVector
std::vector< uint32_t >::const_iterator const_iterator
std::string moduleLocationType(const uint32_t &mod, const TrackerTopology *tTopo)
void setCluster(const SiStripCluster &cluster, int detId)
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
virtual void setCurrentFolder(std::string const &fullpath)
std::vector< dqm::reco::MonitorElement * > h2_ct_var3_m_
std::vector< dqm::reco::MonitorElement * > h2_t_w_m_
std::vector< dqm::reco::MonitorElement * > h2_t_var3_m_
LocalVector drift(const StripGeomDetUnit *, const MagneticField &, const SiStripLorentzAngle &)
std::map< std::string, int > nlayers_
SubDetector subDetector() const
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > m_tkGeomTokenBR
const TrajectoryMeasurement & measurement
const bool saveHistosMods_
LocalPoint toLocal(const GlobalPoint &gp) const
uint32_t hashedIndex(uint32_t det_id)
unsigned int layer(const DetId &id) const
Provides dense hash map in place of DetId.
std::vector< dqm::reco::MonitorElement * > h2_ct_w_m_
SiStripLorentzAngleCalibrationHistograms iHists_
int hashedIndex(int ieta, int iphi)
const edm::EDGetTokenT< TrajTrackAssociationCollection > m_association_token
const size_t size() const
std::map< std::string, dqm::reco::MonitorElement * > h2_
std::map< uint32_t, std::string > moduleLocationType_
const reco::Track * track
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > m_tkGeomToken
SiStripClusterInfo m_clusterInfo
const std::string fieldAsString(const float &inputField)
std::vector< dqm::reco::MonitorElement * > h2_t_var2_m_
OnTrackCluster(uint32_t detId, const SiStripCluster *stripCluster, const Trajectory *trajectory, const reco::Track *track_, const TrajectoryMeasurement &measurement_)
#define DEFINE_FWK_MODULE(type)
SiStripLorentzAnglePCLMonitor(const edm::ParameterSet &)
const SiStripCluster * cluster
const std::string apvModeAsString(const SiStripLatency *latency)
const edm::ESGetToken< SiStripLatency, SiStripLatencyRcd > m_latencyTokenBR
static constexpr auto TOB
Log< level::Warning, true > LogPrint
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Log< level::Info, false > LogInfo
Detector identifier class for the strip tracker.
std::vector< dqm::reco::MonitorElement * > h2_ct_var2_m_
std::map< uint32_t, int > orientation_
std::map< std::string, dqm::reco::MonitorElement * > h1_
void analyze(const edm::Event &, const edm::EventSetup &) override
const Plane & surface() const
The nominal surface of the GeomDet.
const PositionType & position() const
std::map< uint32_t, float > la_db_
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
void dqmBeginRun(edm::Run const &, edm::EventSetup const &) override
static constexpr auto TIB
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > m_topoEsTokenBR
const edm::EDGetTokenT< edm::View< reco::Track > > m_tracks_token
~SiStripLorentzAnglePCLMonitor() override=default
static constexpr float teslaToInverseGeV_
const_iterator end() const
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
const std::string folder_
T mod(const T &a, const T &b)
Geom::Theta< T > theta() const
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > m_magFieldTokenBR
const_iterator begin() const