CMS 3D CMS Logo

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

#include <TrackingMaterialPlotter.h>

Public Types

typedef std::pair< double, double > Range
 

Public Member Functions

void draw (void)
 
void normalize (void)
 
void plotSegmentInLayer (const MaterialAccountingStep &step, int layer)
 
void plotSegmentUnassigned (const MaterialAccountingStep &step)
 
 TrackingMaterialPlotter (float maxZ, float maxR, float resolution)
 

Private Member Functions

void fill_color ()
 
unsigned int fill_gradient (const TColor &first, const TColor &last, unsigned int steps=100, unsigned int index=0)
 
unsigned int fill_gradient (unsigned int first, unsigned int last, unsigned int steps=100, unsigned int index=0)
 

Private Attributes

std::vector< int > m_color
 
std::vector< int > m_gradient
 
XHistogram m_tracker
 

Detailed Description

Definition at line 16 of file TrackingMaterialPlotter.h.

Member Typedef Documentation

◆ Range

typedef std::pair<double, double> TrackingMaterialPlotter::Range

Definition at line 18 of file TrackingMaterialPlotter.h.

Constructor & Destructor Documentation

◆ TrackingMaterialPlotter()

TrackingMaterialPlotter::TrackingMaterialPlotter ( float  maxZ,
float  maxR,
float  resolution 
)

Definition at line 106 of file TrackingMaterialPlotter.cc.

References fill_color(), fill_gradient(), createfilelist::int, m_color, m_tracker, SiStripPI::max, CosmicsPD_Skims::maxZ, and L1TObjectsTimingClient_cff::resolution.

106  {
107  const float rzMinZ = -maxZ;
108  const float rzMaxZ = maxZ;
109  const float rzMinR = 0.;
110  const float rzMaxR = maxR;
111  const int rzBinsZ = (int)(2. * maxZ * resolution);
112  const int rzBinsR = (int)(maxR * resolution);
113 
114  std::vector<double> max;
115  max.push_back(0.08);
116  max.push_back(0.00016);
118  2, rzBinsZ, rzBinsR, std::make_pair(rzMinZ, rzMaxZ), std::make_pair(rzMinR, rzMaxR), m_color.size(), max);
119 
120  TColor::InitializeColors();
121  fill_color();
122  fill_gradient(kWhite, kBlack, 100); // 100-steps gradient from white to black
123 }
unsigned int fill_gradient(const TColor &first, const TColor &last, unsigned int steps=100, unsigned int index=0)

Member Function Documentation

◆ draw()

void TrackingMaterialPlotter::draw ( void  )

Definition at line 147 of file TrackingMaterialPlotter.cc.

References DivergingColor::blue, svgfig::canvas(), XHistogram::colormap(), XHistogram::get(), mps_fire::i, m_color, m_gradient, m_tracker, DivergingColor::red, and pfClustersFromCombinedCaloHF_cfi::scale.

Referenced by TrackingMaterialAnalyser::endJob().

147  {
148  const double scale = 10.;
149  TCanvas* canvas;
150 
151  XHistogram::Histogram* radlen = m_tracker.get(0);
152  canvas = new TCanvas("radlen_rz", "RadiationLengths - RZ view", (int)(600 * scale * 1.25), (int)(120 * scale * 1.50));
153  gStyle->SetOptStat(0);
154  gStyle->SetPalette(m_gradient.size(), &m_gradient.front());
155  gStyle->SetNumberContours(m_gradient.size());
156  canvas->GetFrame()->SetFillColor(kWhite);
157  radlen->Draw("colz");
158  radlen->Draw("same axis y+");
159  radlen->SaveAs("radlen.root");
160  canvas->SaveAs("radlen.png");
161  // Replicate RainBow palette, with White in the first white_slots
162  // positions
163  int white_slots = 1;
164  int MyPalette[100];
165  double stops[9] = {0.0000, 0.1250, 0.2500, 0.3750, 0.5000, 0.6250, 0.7500, 0.8750, 1.0000};
166  double red[9] = {
167  0. / 255., 5. / 255., 15. / 255., 35. / 255., 102. / 255., 196. / 255., 208. / 255., 199. / 255., 110. / 255.};
168  double green[9] = {
169  0. / 255., 48. / 255., 124. / 255., 192. / 255., 206. / 255., 226. / 255., 97. / 255., 16. / 255., 0. / 255.};
170  double blue[9] = {
171  99. / 255., 142. / 255., 198. / 255., 201. / 255., 90. / 255., 22. / 255., 13. / 255., 8. / 255., 2. / 255.};
172  int palette_index = TColor::CreateGradientColorTable(9, stops, red, green, blue, 100 - white_slots);
173  for (int i = 0; i < white_slots; i++)
174  MyPalette[i] = kWhite;
175  for (int i = 0; i < 100 - white_slots; i++)
176  MyPalette[i + white_slots] = palette_index + i;
177  canvas->Clear();
178  gStyle->SetNumberContours(100);
179  gStyle->SetPalette(100, MyPalette); // ROOT Rainbow color palette
180  radlen->Draw("colz");
181  radlen->Draw("same axis y+");
182  canvas->SaveAs("radlenColor.png");
183 
184  delete canvas;
185 
187  canvas = new TCanvas("dedx_rz", "-dE/dx term - RZ view", (int)(600 * scale * 1.25), (int)(120 * scale * 1.50));
188  canvas->GetFrame()->SetFillColor(kWhite);
189  gStyle->SetOptStat(0);
190  gStyle->SetPalette(m_gradient.size(), &m_gradient.front());
191  gStyle->SetNumberContours(m_gradient.size());
192  dedx->Draw("colz");
193  dedx->Draw("same axis y+");
194  dedx->SaveAs("dedx.root");
195  canvas->SaveAs("dedx.png");
196  canvas->Clear();
197  gStyle->SetNumberContours(100);
198  gStyle->SetPalette(100, MyPalette); // ROOT Rainbow color palette
199  dedx->Draw("colz");
200  dedx->Draw("same axis y+");
201  canvas->SaveAs("dedxColor.png");
202  delete canvas;
203 
205  canvas = new TCanvas("layer_rz", "Layers - RZ view", (int)(600 * scale * 1.25), (int)(120 * scale * 1.50));
206  canvas->GetFrame()->SetFillColor(kWhite);
207  gStyle->SetOptStat(0);
208  gStyle->SetPalette(m_color.size(), &m_color.front());
209  gStyle->SetNumberContours(m_color.size());
210  colormap->SetMinimum(1);
211  colormap->SetMaximum(m_color.size());
212  colormap->Draw("col");
213  colormap->Draw("same axis y+");
214  colormap->SaveAs("layers.root");
215  canvas->SaveAs("layers.png");
216  delete canvas;
217 }
TH2F Histogram
Definition: XHistogram.h:16
ColorMap * colormap(void) const
access the colormap
Definition: XHistogram.h:97
TH2I ColorMap
Definition: XHistogram.h:15
def canvas(sub, attr)
Definition: svgfig.py:482
Histogram * get(size_t h=0) const
access one of the histograms
Definition: XHistogram.h:86

◆ fill_color()

void TrackingMaterialPlotter::fill_color ( void  )
private

Definition at line 14 of file TrackingMaterialPlotter.cc.

References m_color.

Referenced by TrackingMaterialPlotter().

14  {
15  m_color.push_back(kBlack); // unassigned
16  m_color.push_back(kAzure); // PixelBarrel
17  m_color.push_back(kAzure + 1); //
18  m_color.push_back(kAzure + 1); //
19  m_color.push_back(kAzure + 3); //
20  m_color.push_back(kAzure + 3); //
21  m_color.push_back(kGreen); // TIB
22  m_color.push_back(kGreen); //
23  m_color.push_back(kGreen + 2); //
24  m_color.push_back(kGreen + 2); //
25  m_color.push_back(kGreen - 3); //
26  m_color.push_back(kGreen - 3); //
27  m_color.push_back(kGreen - 1); //
28  m_color.push_back(kGreen - 1); //
29  m_color.push_back(kRed); // TOB
30  m_color.push_back(kRed); //
31  m_color.push_back(kRed); //
32  m_color.push_back(kRed + 3); //
33  m_color.push_back(kRed + 3); //
34  m_color.push_back(kRed + 3); //
35  m_color.push_back(kRed - 3); //
36  m_color.push_back(kRed - 3); //
37  m_color.push_back(kRed - 3); //
38  m_color.push_back(kOrange + 9); //
39  m_color.push_back(kOrange + 9); //
40  m_color.push_back(kOrange + 9); //
41  m_color.push_back(kOrange + 7); //
42  m_color.push_back(kOrange + 7); //
43  m_color.push_back(kOrange + 7); //
44  m_color.push_back(kOrange + 5); //
45  m_color.push_back(kOrange + 5); //
46  m_color.push_back(kOrange + 5); //
47  m_color.push_back(kOrange + 8); // PixelEndcap Z-
48  m_color.push_back(kOrange + 10); //
49  m_color.push_back(kOrange - 3); //
50  m_color.push_back(kOrange - 1); // PixelEndcap Z+
51  m_color.push_back(kOrange - 8); //
52  m_color.push_back(kYellow); // TID Z-
53  m_color.push_back(kYellow); //
54  m_color.push_back(kYellow + 2); //
55  m_color.push_back(kYellow + 2); //
56  m_color.push_back(kYellow + 2); //
57  m_color.push_back(kYellow + 3); //
58  m_color.push_back(kMagenta); //
59  m_color.push_back(kMagenta); //
60  m_color.push_back(kMagenta); //
61  m_color.push_back(kMagenta); //
62  m_color.push_back(kMagenta); //
63  m_color.push_back(kMagenta + 1); //
64  m_color.push_back(kMagenta + 2); //
65  m_color.push_back(kMagenta + 3); //
66  m_color.push_back(kMagenta + 4); //
67  m_color.push_back(kMagenta + 5); //
68  m_color.push_back(kMagenta + 6); //
69  m_color.push_back(kMagenta + 7); //
70  m_color.push_back(kMagenta + 8); //
71 }

◆ fill_gradient() [1/2]

unsigned int TrackingMaterialPlotter::fill_gradient ( const TColor &  first,
const TColor &  last,
unsigned int  steps = 100,
unsigned int  index = 0 
)
private

Definition at line 73 of file TrackingMaterialPlotter.cc.

References b1, b2, hitfit::delta_r(), dqmdumpme::first, diffTwoXMLs::g1, diffTwoXMLs::g2, mps_fire::i, dqmdumpme::last, m_gradient, diffTwoXMLs::r1, diffTwoXMLs::r2, and customisers::steps.

Referenced by fill_gradient(), and TrackingMaterialPlotter().

76  {
77  if (index == 0) {
78  // if no index was given, find the highest used one and start from that plus one
79  index = ((TObjArray*)gROOT->GetListOfColors())->GetLast() + 1;
80  }
81 
82  float r1, g1, b1, r2, g2, b2;
83  first.GetRGB(r1, g1, b1);
84  last.GetRGB(r2, g2, b2);
85  float delta_r = (r2 - r1) / (steps - 1);
86  float delta_g = (g2 - g1) / (steps - 1);
87  float delta_b = (b2 - b1) / (steps - 1);
88 
89  m_gradient.resize(steps);
90  for (unsigned int i = 0; i < steps; ++i) {
91  new TColor(static_cast<Int_t>(index + i), r1 + delta_r * i, g1 + delta_g * i, b1 + delta_b * i);
92  m_gradient[i] = index + i;
93  }
94 
95  return index;
96 }
weight_default_t b1[25]
Definition: b1.h:9
double delta_r(const Fourvec &a, const Fourvec &b)
Find the distance between two four-vectors in the two-dimensional space .
Definition: fourvec.cc:238
weight_default_t b2[10]
Definition: b2.h:9

◆ fill_gradient() [2/2]

unsigned int TrackingMaterialPlotter::fill_gradient ( unsigned int  first,
unsigned int  last,
unsigned int  steps = 100,
unsigned int  index = 0 
)
private

Definition at line 98 of file TrackingMaterialPlotter.cc.

References fill_gradient(), dqmdumpme::first, dqmdumpme::last, and customisers::steps.

101  {
102  return fill_gradient(
103  *(TColor*)gROOT->GetListOfColors()->At(first), *(TColor*)gROOT->GetListOfColors()->At(last), steps, index);
104 }
unsigned int fill_gradient(const TColor &first, const TColor &last, unsigned int steps=100, unsigned int index=0)

◆ normalize()

void TrackingMaterialPlotter::normalize ( void  )
inline

Definition at line 24 of file TrackingMaterialPlotter.h.

References m_tracker, and XHistogram::normalize().

Referenced by TrackingMaterialAnalyser::endJob().

24 { m_tracker.normalize(); }
void normalize(void)
normalize the histograms
Definition: XHistogram.cc:115

◆ plotSegmentInLayer()

void TrackingMaterialPlotter::plotSegmentInLayer ( const MaterialAccountingStep step,
int  layer 
)

Definition at line 136 of file TrackingMaterialPlotter.cc.

References XHistogram::fill(), nano_mu_digi_cff::layer, m_tracker, and w().

Referenced by TrackingMaterialAnalyser::split().

136  {
137  std::vector<double> w(2);
138  w[0] = step.radiationLengths();
139  w[1] = step.energyLoss();
140  m_tracker.fill(std::make_pair(step.in().z(), step.out().z()),
141  std::make_pair(step.in().perp(), step.out().perp()),
142  w,
143  step.length(),
144  layer + 1); // layer is 1-based, but plot uses: 0 is empty, 1 is unassigned
145 }
T w() const
void fill(double x, double y, const std::vector< double > &weight, double norm)
fill one point
Definition: XHistogram.cc:70
step
Definition: StallMonitor.cc:98

◆ plotSegmentUnassigned()

void TrackingMaterialPlotter::plotSegmentUnassigned ( const MaterialAccountingStep step)

Definition at line 125 of file TrackingMaterialPlotter.cc.

References XHistogram::fill(), m_tracker, and w().

Referenced by TrackingMaterialAnalyser::split().

125  {
126  std::vector<double> w(2);
127  w[0] = step.radiationLengths();
128  w[1] = step.energyLoss();
129  m_tracker.fill(std::make_pair(step.in().z(), step.out().z()),
130  std::make_pair(step.in().perp(), step.out().perp()),
131  w,
132  step.length(),
133  1); // 0 is empty, 1 is unassigned
134 }
T w() const
void fill(double x, double y, const std::vector< double > &weight, double norm)
fill one point
Definition: XHistogram.cc:70
step
Definition: StallMonitor.cc:98

Member Data Documentation

◆ m_color

std::vector<int> TrackingMaterialPlotter::m_color
private

Definition at line 31 of file TrackingMaterialPlotter.h.

Referenced by draw(), fill_color(), and TrackingMaterialPlotter().

◆ m_gradient

std::vector<int> TrackingMaterialPlotter::m_gradient
private

Definition at line 32 of file TrackingMaterialPlotter.h.

Referenced by draw(), and fill_gradient().

◆ m_tracker

XHistogram TrackingMaterialPlotter::m_tracker
private