CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
SiStripTkMaps Class Reference

#include <SiStripTkMaps.h>

Public Member Functions

void bookMap (const std::string mapTitle, const std::string zAxisTitle)
 
void drawMap (TCanvas &canvas, std::string option="")
 
void fill (long rawid, double val)
 
const std::vector< unsigned int > & getTheFilledIds ()
 
const std::vector< double > & getTheFilledValues ()
 
const TH2Poly * getTheMap ()
 
const std::string & getTheMapTitle ()
 
const std::string & getTheZAxisTitle ()
 
void setZAxisRange (double xmin, double xmax)
 
 SiStripTkMaps (const char *option)
 
 ~SiStripTkMaps ()=default
 

Private Member Functions

void adjustCanvasMargins (TVirtualPad *pad, const float top, const float bottom, const float left, const float right)
 
void drawArrows (const float x_X1, const float x_X2, const float x_Y1, const float y_Y2, const char *x_label, const char *y_label)
 
void dressMap (TCanvas &canv)
 
void readVertices (double &minx, double &maxx, double &miny, double &maxy)
 

Private Attributes

double m_axmax
 
double m_axmin
 
std::map< long, std::shared_ptr< TGraph > > m_bins
 
std::vector< unsigned int > m_detIdVector
 
std::string m_mapTitle = ""
 
Option_t * m_option
 
TH2Poly * m_trackerMap {nullptr}
 
TrackerTopology m_trackerTopo
 
std::vector< double > m_values
 
std::string m_zAxisTitle = ""
 

Detailed Description

Definition at line 40 of file SiStripTkMaps.h.

Constructor & Destructor Documentation

◆ SiStripTkMaps()

SiStripTkMaps::SiStripTkMaps ( const char *  option)
inline

Definition at line 42 of file SiStripTkMaps.h.

43  : m_option{option},
45  edm::FileInPath("Geometry/TrackerCommonData/data/PhaseI/trackerParameters.xml").fullPath())} {}

References fileinputsource_cfi::option.

◆ ~SiStripTkMaps()

SiStripTkMaps::~SiStripTkMaps ( )
default

Member Function Documentation

◆ adjustCanvasMargins()

void SiStripTkMaps::adjustCanvasMargins ( TVirtualPad *  pad,
const float  top,
const float  bottom,
const float  left,
const float  right 
)
private

Definition at line 206 of file SiStripTkMaps.cc.

207  {
208  if (top > 0) {
209  pad->SetTopMargin(top);
210  }
211  if (bottom > 0) {
212  pad->SetBottomMargin(bottom);
213  }
214  if (left > 0) {
215  pad->SetLeftMargin(left);
216  }
217  if (right > 0) {
218  pad->SetRightMargin(right);
219  }
220 }

Referenced by drawMap().

◆ bookMap()

void SiStripTkMaps::bookMap ( const std::string  mapTitle,
const std::string  zAxisTitle 
)

Definition at line 35 of file SiStripTkMaps.cc.

35  {
36  double minx = 0xFFFFFF, maxx = -0xFFFFFF, miny = 0xFFFFFF, maxy = -0xFFFFFFF;
37  readVertices(minx, maxx, miny, maxy);
38 
39  // set the titles
40  m_zAxisTitle = zAxisTitle;
41  m_mapTitle = mapTitle;
42 
43  TGaxis::SetMaxDigits(2);
44 
45  // margin of the box
46  static constexpr int margin = 5;
47  m_trackerMap =
48  new TH2Poly("Tracker Map", m_mapTitle.c_str(), minx - margin, maxx + margin, miny - margin, maxy + margin);
49  m_trackerMap->SetFloat();
50  m_trackerMap->SetOption(m_option);
51  m_trackerMap->SetStats(false);
52  m_trackerMap->GetZaxis()->SetLabelSize(0.03);
53  m_trackerMap->GetZaxis()->SetTitleOffset(0.5);
54  m_trackerMap->GetZaxis()->SetTitleSize(0.05);
55  m_trackerMap->GetZaxis()->SetTitle(m_zAxisTitle.c_str());
56  m_trackerMap->GetZaxis()->CenterTitle();
57 
58  for (const auto& pair : m_bins) {
59  m_trackerMap->AddBin(pair.second->Clone());
60  }
61 }

References m_bins, m_mapTitle, m_option, m_trackerMap, m_zAxisTitle, margin, and readVertices().

◆ drawArrows()

void SiStripTkMaps::drawArrows ( const float  x_X1,
const float  x_X2,
const float  x_Y1,
const float  y_Y2,
const char *  x_label,
const char *  y_label 
)
private

Definition at line 176 of file SiStripTkMaps.cc.

177  {
178  auto arrow_X = TArrow();
179  arrow_X.SetLineColor(kBlue);
180  arrow_X.SetLineWidth(2);
181  arrow_X.SetOption("|>");
182  arrow_X.SetArrowSize(10);
183  arrow_X.DrawLineNDC(x_X1, x_Y1, x_X2, x_Y1);
184 
185  auto arrow_Y = TArrow();
186  arrow_Y.SetLineColor(kBlue);
187  arrow_Y.SetLineWidth(2);
188  arrow_Y.SetOption("|>");
189  arrow_Y.SetArrowSize(10);
190  arrow_Y.DrawLineNDC(x_X2, x_Y1, x_X2, y_Y2);
191 
192  auto text_X = TLatex();
193  text_X.SetTextSize(0.04);
194  text_X.SetTextAlign(11);
195  text_X.SetTextColor(kBlue);
196  text_X.DrawLatexNDC(x_X1, x_Y1 - 0.03, x_label);
197 
198  auto text_Y = TLatex();
199  text_Y.SetTextSize(0.04);
200  text_Y.SetTextAlign(11);
201  text_Y.SetTextColor(kBlue);
202  text_Y.DrawLatexNDC(x_X2 + 0.005, y_Y2 - 0.01, y_label);
203 }

Referenced by dressMap().

◆ drawMap()

void SiStripTkMaps::drawMap ( TCanvas &  canvas,
std::string  option = "" 
)

Definition at line 70 of file SiStripTkMaps.cc.

70  {
71  // margins
72  static constexpr float tmargin_ = 0.08;
73  static constexpr float bmargin_ = 0.02;
74  static constexpr float lmargin_ = 0.02;
75  static constexpr float rmargin_ = 0.08;
76 
77  // window size
78  static constexpr int wH_ = 3000;
79  static constexpr int hH_ = 850;
80 
81  canvas.cd();
82  adjustCanvasMargins(canvas.cd(), tmargin_, bmargin_, lmargin_, rmargin_);
83  canvas.Update();
84 
85  m_trackerMap->SetTitle("");
86  if (!option.empty()) {
87  m_trackerMap->Draw(option.c_str());
88  } else {
89  m_trackerMap->Draw();
90  }
91 
92  canvas.SetFrameLineColor(0);
93  gPad->Update();
94  TPaletteAxis* palette = (TPaletteAxis*)m_trackerMap->GetListOfFunctions()->FindObject("palette");
95  if (palette != nullptr) {
96  palette->SetLabelSize(0.02);
97  palette->SetX1NDC(1 - rmargin_);
98  palette->SetX2NDC(1 - rmargin_ + lmargin_);
99  }
100 
101  // if not right size, and not drawn in same mode
102  if (canvas.GetWindowHeight() != hH_ && canvas.GetWindowWidth() != wH_ && option.find("same") == std::string::npos) {
103  canvas.SetWindowSize(wH_, hH_);
104  }
105 
106  // call the map dressing
107  dressMap(canvas);
108 }

References adjustCanvasMargins(), svgfig::canvas(), dressMap(), m_trackerMap, and fileinputsource_cfi::option.

◆ dressMap()

void SiStripTkMaps::dressMap ( TCanvas &  canv)
private

Definition at line 111 of file SiStripTkMaps.cc.

111  {
112  std::array<std::string, 12> barrelNames = {
113  {"TIB L2", "TIB L1", "TIB L4", "TIB L3", "TOB L2", "TOB L1", "TOB L4", " TOB L3", "TOB L6", "TOB L5"}};
114  std::array<std::string, 4> endcapNames = {{"TID", "TEC", "TID", "TEC"}};
115  std::array<std::string, 24> disknumbering = {{"+1", "+2", "+3", "+1", "+2", "+3", "+4", "+5",
116  "+6", "+7", "+8", "+9", "-1", "-2", "-3", "-1",
117  "-2", "-3", "-4", "-5", "-6", "-7", "-8", "-9"}};
118 
119  static constexpr std::array<float, 12> b_coordx = {
120  {0.1, 0.1, 0.26, 0.26, 0.41, 0.41, 0.56, 0.56, 0.725, 0.725, 0.05, 0.17}};
121  static constexpr std::array<float, 12> b_coordy = {
122  {0.70, 0.45, 0.70, 0.45, 0.70, 0.46, 0.70, 0.46, 0.70, 0.46, 0.85, 0.85}};
123 
124  static constexpr std::array<float, 4> e_coordx = {{0.01, 0.21, 0.01, 0.21}};
125  static constexpr std::array<float, 4> e_coordy = {{0.89, 0.89, 0.17, 0.17}};
126 
127  static constexpr std::array<float, 24> n_coordx = {{0.01, 0.087, 0.165, 0.227, 0.305, 0.383, 0.461, 0.539,
128  0.616, 0.694, 0.772, 0.850, 0.01, 0.087, 0.165, 0.227,
129  0.305, 0.383, 0.461, 0.539, 0.617, 0.695, 0.773, 0.851}};
130 
131  static constexpr std::array<float, 24> n_coordy = {{0.85, 0.85, 0.85, 0.85, 0.85, 0.85, 0.85, 0.85,
132  0.85, 0.85, 0.85, 0.85, 0.13, 0.13, 0.13, 0.13,
133  0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13}};
134 
135  canv.cd();
136  for (const auto& name : barrelNames | boost::adaptors::indexed(0)) {
137  auto ltx = TLatex();
138  ltx.SetTextFont(62);
139  ltx.SetTextSize(0.035);
140  ltx.SetTextAlign(11);
141  ltx.DrawLatexNDC(b_coordx[name.index()], b_coordy[name.index()], name.value().c_str());
142  }
143 
144  for (const auto& name : endcapNames | boost::adaptors::indexed(0)) {
145  auto ltx = TLatex();
146  ltx.SetTextFont(62);
147  ltx.SetTextSize(0.05);
148  ltx.SetTextAlign(11);
149  ltx.DrawLatexNDC(e_coordx[name.index()], e_coordy[name.index()], name.value().c_str());
150  }
151 
152  for (const auto& name : disknumbering | boost::adaptors::indexed(0)) {
153  auto ltx = TLatex();
154  ltx.SetTextFont(62);
155  ltx.SetTextSize(0.035);
156  ltx.SetTextAlign(11);
157  ltx.DrawLatexNDC(n_coordx[name.index()], n_coordy[name.index()], name.value().c_str());
158  }
159 
160  auto ltx = TLatex();
161  ltx.SetTextFont(62);
162  ltx.SetTextSize(0.045);
163  ltx.SetTextAlign(11);
164  ltx.DrawLatexNDC(gPad->GetLeftMargin(), 1 - gPad->GetTopMargin() + 0.03, m_mapTitle.c_str());
165 
166  // barrel axes
167  drawArrows(0.09, 0.23, 0.24, 0.45, "#phi", "z");
168  // endcap axes
169  drawArrows(0.85, 0.89, 0.83, 0.95, "x", "y");
170 
171  canv.Modified();
172  canv.Update(); // make sure it's really (re)drawn
173 }

References drawArrows(), m_mapTitle, and Skims_PA_cff::name.

Referenced by drawMap().

◆ fill()

void SiStripTkMaps::fill ( long  rawid,
double  val 
)

Definition at line 64 of file SiStripTkMaps.cc.

64  {
65  m_trackerMap->Fill(TString::Format("%ld", rawid), val);
66  m_values.push_back(val);
67 }

References m_trackerMap, m_values, and heppy_batch::val.

◆ getTheFilledIds()

const std::vector<unsigned int>& SiStripTkMaps::getTheFilledIds ( )
inline

Definition at line 63 of file SiStripTkMaps.h.

63 { return m_detIdVector; }

References m_detIdVector.

◆ getTheFilledValues()

const std::vector<double>& SiStripTkMaps::getTheFilledValues ( )
inline

Definition at line 66 of file SiStripTkMaps.h.

66 { return m_values; }

References m_values.

◆ getTheMap()

const TH2Poly* SiStripTkMaps::getTheMap ( )
inline

Definition at line 54 of file SiStripTkMaps.h.

54 { return m_trackerMap; }

References m_trackerMap.

◆ getTheMapTitle()

const std::string& SiStripTkMaps::getTheMapTitle ( )
inline

Definition at line 57 of file SiStripTkMaps.h.

57 { return m_mapTitle; }

References m_mapTitle.

◆ getTheZAxisTitle()

const std::string& SiStripTkMaps::getTheZAxisTitle ( )
inline

Definition at line 60 of file SiStripTkMaps.h.

60 { return m_zAxisTitle; }

References m_zAxisTitle.

◆ readVertices()

void SiStripTkMaps::readVertices ( double &  minx,
double &  maxx,
double &  miny,
double &  maxy 
)
private

Definition at line 223 of file SiStripTkMaps.cc.

223  {
224  std::ifstream in;
225 
226  // TPolyline vertices stored at https://github.com/cms-data/DQM-SiStripMonitorClient
227  in.open(edm::FileInPath("DQM/SiStripMonitorClient/data/Geometry/tracker_map_bare").fullPath().c_str());
228 
229  if (!in.good()) {
230  throw cms::Exception("FileError") << "SiStripTkMaps: problem opening vertices file!!" << std::endl;
231  return;
232  }
233 
234  while (in.good()) {
235  long detid = 0;
236  double x[5], y[5];
237 
239  std::getline(in, line);
240  typedef boost::tokenizer<boost::char_separator<char>> tokenizer;
241  boost::char_separator<char> sep{" "};
242  tokenizer tok{line, sep};
243 
244  int ix{0}, iy{0};
245  bool isPixel{false};
246  for (const auto& t : tok | boost::adaptors::indexed(0)) {
247  int i = t.index();
248  if (i == 0) {
249  detid = atoll((t.value()).c_str());
250 
251  // Drop Pixel Data
252  DetId detId(detid);
253  if (detId.subdetId() == PixelSubdetector::PixelBarrel || detId.subdetId() == PixelSubdetector::PixelEndcap) {
254  isPixel = true;
255  break;
256  }
257  } else {
258  if (i % 2 == 0) {
259  x[ix] = atof((t.value()).c_str());
260  if (x[ix] < minx) {
261  minx = x[ix];
262  }
263  if (x[ix] > maxx) {
264  maxx = x[ix];
265  }
266  ++ix;
267  } else {
268  y[iy] = atof((t.value()).c_str());
269  if (y[iy] < miny) {
270  miny = y[iy];
271  }
272  if (y[iy] > maxy) {
273  maxy = y[iy];
274  }
275  ++iy;
276  } // else
277  } // else
278  } // loop on entries
279 
280  if (isPixel) {
281  continue;
282  }
283 
284  m_bins[detid] = std::make_shared<TGraph>(ix, x, y);
285  m_bins[detid]->SetName(TString::Format("%ld", detid));
286  m_bins[detid]->SetTitle(TString::Format("Module ID=%ld", detid));
287  m_detIdVector.push_back(detid);
288  }
289 }

References Exception, contentValuesFiles::fullPath, mps_fire::i, recoMuon::in, fastTrackerRecHitType::isPixel(), mps_splice::line, m_bins, m_detIdVector, PixelSubdetector::PixelBarrel, PixelSubdetector::PixelEndcap, AlCaHLTBitMon_QueryRunRegistry::string, submitPVValidationJobs::t, x, and y.

Referenced by bookMap().

◆ setZAxisRange()

void SiStripTkMaps::setZAxisRange ( double  xmin,
double  xmax 
)
inline

Definition at line 69 of file SiStripTkMaps.h.

69 { m_trackerMap->GetZaxis()->SetRangeUser(xmin, xmax); }

References m_trackerMap, TrackerOfflineValidation_Dqm_cff::xmax, and TrackerOfflineValidation_Dqm_cff::xmin.

Member Data Documentation

◆ m_axmax

double SiStripTkMaps::m_axmax
private

Definition at line 76 of file SiStripTkMaps.h.

◆ m_axmin

double SiStripTkMaps::m_axmin
private

Definition at line 76 of file SiStripTkMaps.h.

◆ m_bins

std::map<long, std::shared_ptr<TGraph> > SiStripTkMaps::m_bins
private

Definition at line 77 of file SiStripTkMaps.h.

Referenced by bookMap(), and readVertices().

◆ m_detIdVector

std::vector<unsigned int> SiStripTkMaps::m_detIdVector
private

Definition at line 78 of file SiStripTkMaps.h.

Referenced by getTheFilledIds(), and readVertices().

◆ m_mapTitle

std::string SiStripTkMaps::m_mapTitle = ""
private

Definition at line 74 of file SiStripTkMaps.h.

Referenced by bookMap(), dressMap(), and getTheMapTitle().

◆ m_option

Option_t* SiStripTkMaps::m_option
private

Definition at line 73 of file SiStripTkMaps.h.

Referenced by bookMap().

◆ m_trackerMap

TH2Poly* SiStripTkMaps::m_trackerMap {nullptr}
private

Definition at line 81 of file SiStripTkMaps.h.

Referenced by bookMap(), drawMap(), fill(), getTheMap(), and setZAxisRange().

◆ m_trackerTopo

TrackerTopology SiStripTkMaps::m_trackerTopo
private

Definition at line 80 of file SiStripTkMaps.h.

◆ m_values

std::vector<double> SiStripTkMaps::m_values
private

Definition at line 79 of file SiStripTkMaps.h.

Referenced by fill(), and getTheFilledValues().

◆ m_zAxisTitle

std::string SiStripTkMaps::m_zAxisTitle = ""
private

Definition at line 75 of file SiStripTkMaps.h.

Referenced by bookMap(), and getTheZAxisTitle().

svgfig.canvas
def canvas(*sub, **attr)
Definition: svgfig.py:482
DDAxes::y
mps_fire.i
i
Definition: mps_fire.py:428
SiStripTkMaps::m_mapTitle
std::string m_mapTitle
Definition: SiStripTkMaps.h:74
PixelSubdetector::PixelEndcap
Definition: PixelSubdetector.h:11
PixelSubdetector::PixelBarrel
Definition: PixelSubdetector.h:11
SiStripTkMaps::adjustCanvasMargins
void adjustCanvasMargins(TVirtualPad *pad, const float top, const float bottom, const float left, const float right)
Definition: SiStripTkMaps.cc:206
contentValuesFiles.fullPath
fullPath
Definition: contentValuesFiles.py:64
DDAxes::x
fileinputsource_cfi.option
option
Definition: fileinputsource_cfi.py:94
SiStripTkMaps::m_option
Option_t * m_option
Definition: SiStripTkMaps.h:73
DetId
Definition: DetId.h:17
edm::FileInPath
Definition: FileInPath.h:61
SiStripTkMaps::m_values
std::vector< double > m_values
Definition: SiStripTkMaps.h:79
SiStripTkMaps::m_bins
std::map< long, std::shared_ptr< TGraph > > m_bins
Definition: SiStripTkMaps.h:77
fastTrackerRecHitType::isPixel
bool isPixel(HitType hitType)
Definition: FastTrackerRecHit.h:37
SiStripTkMaps::m_trackerTopo
TrackerTopology m_trackerTopo
Definition: SiStripTkMaps.h:80
SiStripTkMaps::m_zAxisTitle
std::string m_zAxisTitle
Definition: SiStripTkMaps.h:75
recoMuon::in
Definition: RecoMuonEnumerators.h:6
SiStripTkMaps::m_detIdVector
std::vector< unsigned int > m_detIdVector
Definition: SiStripTkMaps.h:78
SiStripTkMaps::dressMap
void dressMap(TCanvas &canv)
Definition: SiStripTkMaps.cc:111
SiStripTkMaps::drawArrows
void drawArrows(const float x_X1, const float x_X2, const float x_Y1, const float y_Y2, const char *x_label, const char *y_label)
Definition: SiStripTkMaps.cc:176
SiStripTkMaps::m_trackerMap
TH2Poly * m_trackerMap
Definition: SiStripTkMaps.h:81
SiStripPI::palette
palette
Definition: SiStripPayloadInspectorHelper.h:782
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
heppy_batch.val
val
Definition: heppy_batch.py:351
TrackerOfflineValidation_Dqm_cff.xmax
xmax
Definition: TrackerOfflineValidation_Dqm_cff.py:11
Exception
Definition: hltDiff.cc:245
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
TrackerOfflineValidation_Dqm_cff.xmin
xmin
Definition: TrackerOfflineValidation_Dqm_cff.py:10
mps_splice.line
line
Definition: mps_splice.py:76
submitPVValidationJobs.t
string t
Definition: submitPVValidationJobs.py:644
SiStripTkMaps::readVertices
void readVertices(double &minx, double &maxx, double &miny, double &maxy)
Definition: SiStripTkMaps.cc:223
StandaloneTrackerTopology::fromTrackerParametersXMLFile
TrackerTopology fromTrackerParametersXMLFile(const std::string &xmlFileName)
Definition: StandaloneTrackerTopology.cc:168
margin
Double_t margin
Definition: trackSplitPlot.h:45