CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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

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

Definition at line 19 of file TrackingMaterialPlotter.h.

Constructor & Destructor Documentation

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

Definition at line 89 of file TrackingMaterialPlotter.cc.

References fill_color(), fill_gradient(), m_color, m_tracker, max(), and CosmicsPD_Skims::maxZ.

90 {
91  const float rzMinZ = -maxZ;
92  const float rzMaxZ = maxZ;
93  const float rzMinR = 0.;
94  const float rzMaxR = maxR;
95  const int rzBinsZ = (int) (2. * maxZ * resolution);
96  const int rzBinsR = (int) ( maxR * resolution);
97 
98  std::vector<double> max;
99  max.push_back( 0.02 );
100  max.push_back( 0.04 );
101  m_tracker = XHistogram( 2, rzBinsZ, rzBinsR, std::make_pair(rzMinZ, rzMaxZ), std::make_pair(rzMinR, rzMaxR), m_color.size(), max);
102 
103  TColor::InitializeColors();
104  fill_color();
105  fill_gradient( kWhite, kBlack, 100); // 100-steps gradient from white to black
106 }
const T & max(const T &a, const T &b)
unsigned int fill_gradient(const TColor &first, const TColor &last, unsigned int steps=100, unsigned int index=0)

Member Function Documentation

void TrackingMaterialPlotter::draw ( void  )

Definition at line 129 of file TrackingMaterialPlotter.cc.

References svgfig::canvas(), XHistogram::colormap(), XHistogram::get(), m_color, m_gradient, m_tracker, and pileupReCalc_HLTpaths::scale.

130 {
131  const double scale = 10.;
132  TCanvas* canvas;
133 
134  XHistogram::Histogram* radlen = m_tracker.get(0);
135  canvas = new TCanvas("radlen_rz", "RadiationLengths - RZ view", (int) (600 * scale * 1.25), (int) (120 * scale * 1.50));
136  gStyle->SetOptStat(0);
137  gStyle->SetPalette( m_gradient.size(), & m_gradient.front() );
138  gStyle->SetNumberContours( m_gradient.size() );
139  canvas->GetFrame()->SetFillColor(kWhite);
140  radlen->Draw("colz");
141  radlen->Draw("same axis y+");
142  canvas->SaveAs("radlen.png");
143  delete canvas;
144 
146  canvas = new TCanvas("dedx_rz", "-dE/dx term - RZ view", (int) (600 * scale * 1.25), (int) (120 * scale * 1.50));
147  canvas->GetFrame()->SetFillColor(kWhite);
148  gStyle->SetOptStat(0);
149  gStyle->SetPalette( m_gradient.size(), & m_gradient.front() );
150  gStyle->SetNumberContours( m_gradient.size() );
151  dedx->Draw("colz");
152  dedx->Draw("same axis y+");
153  canvas->SaveAs("dedx.png");
154  delete canvas;
155 
157  canvas = new TCanvas("layer_rz", "Layers - RZ view", (int) (600 * scale * 1.25), (int) (120 * scale * 1.50));
158  canvas->GetFrame()->SetFillColor(kWhite);
159  gStyle->SetOptStat(0);
160  gStyle->SetPalette( m_color.size(), & m_color.front() );
161  gStyle->SetNumberContours( m_color.size() );
162  colormap->SetMinimum( 1 );
163  colormap->SetMaximum( m_color.size() );
164  colormap->Draw("col");
165  colormap->Draw("same axis y+");
166  canvas->SaveAs("layers.png");
167  delete canvas;
168 }
ColorMap * colormap(void) const
access the colormap
Definition: XHistogram.h:104
TH2F Histogram
Definition: XHistogram.h:17
Histogram * get(size_t h=0) const
access one of the histograms
Definition: XHistogram.h:89
def canvas
Definition: svgfig.py:481
TH2I ColorMap
Definition: XHistogram.h:16
void TrackingMaterialPlotter::fill_color ( void  )
private

Definition at line 14 of file TrackingMaterialPlotter.cc.

References m_color.

Referenced by TrackingMaterialPlotter().

15 {
16  m_color.push_back(kBlack); // unassigned
17  m_color.push_back(kBlue); // PixelBarrel
18  m_color.push_back(kBlue + 100); //
19  m_color.push_back(kBlue); //
20  m_color.push_back(kGreen); // TIB
21  m_color.push_back(kGreen + 100); //
22  m_color.push_back(kGreen); //
23  m_color.push_back(kGreen + 100); //
24  m_color.push_back(kRed); // TOB
25  m_color.push_back(kRed + 100); //
26  m_color.push_back(kRed); //
27  m_color.push_back(kRed + 100); //
28  m_color.push_back(kRed); //
29  m_color.push_back(kRed + 100); //
30  m_color.push_back(kBlue); // PixelEndcap Z-
31  m_color.push_back(kBlue + 100); //
32  m_color.push_back(kGreen); // TID Z-
33  m_color.push_back(kGreen + 100); //
34  m_color.push_back(kGreen); //
35  m_color.push_back(kRed); // TEC Z-
36  m_color.push_back(kRed + 100); //
37  m_color.push_back(kRed); //
38  m_color.push_back(kRed + 100); //
39  m_color.push_back(kRed); //
40  m_color.push_back(kRed + 100); //
41  m_color.push_back(kRed); //
42  m_color.push_back(kRed + 100); //
43  m_color.push_back(kRed); //
44  m_color.push_back(kBlue); // PixelEndcap Z+
45  m_color.push_back(kBlue + 100); //
46  m_color.push_back(kGreen); // TID Z+
47  m_color.push_back(kGreen + 100); //
48  m_color.push_back(kGreen); //
49  m_color.push_back(kRed); // TEC Z+
50  m_color.push_back(kRed + 100); //
51  m_color.push_back(kRed); //
52  m_color.push_back(kRed + 100); //
53  m_color.push_back(kRed); //
54  m_color.push_back(kRed + 100); //
55  m_color.push_back(kRed); //
56  m_color.push_back(kRed + 100); //
57  m_color.push_back(kRed); //
58 }
unsigned int TrackingMaterialPlotter::fill_gradient ( const TColor &  first,
const TColor &  last,
unsigned int  steps = 100,
unsigned int  index = 0 
)
private

Definition at line 61 of file TrackingMaterialPlotter.cc.

References hitfit::delta_r(), diffTwoXMLs::g1, diffTwoXMLs::g2, i, getHLTprescales::index, m_gradient, diffTwoXMLs::r1, diffTwoXMLs::r2, and relval_steps::steps.

Referenced by fill_gradient(), and TrackingMaterialPlotter().

62 {
63  if (index == 0) {
64  // if no index was given, find the highest used one and start from that plus one
65  index = ((TObjArray*) gROOT->GetListOfColors())->GetLast() + 1;
66  }
67 
68  float r1, g1, b1, r2, g2, b2;
69  first.GetRGB(r1, g1, b1);
70  last.GetRGB(r2, g2, b2);
71  float delta_r = (r2 - r1) / (steps - 1);
72  float delta_g = (g2 - g1) / (steps - 1);
73  float delta_b = (b2 - b1) / (steps - 1);
74 
75  m_gradient.resize(steps);
76  for (unsigned int i = 0; i < steps; ++i) {
77  new TColor(index + i, r1 + delta_r * i, g1 + delta_g * i, b1 + delta_b * i);
78  m_gradient[i] = index + i;
79  }
80 
81  return index;
82 }
int i
Definition: DBlmapReader.cc: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:250
bool first
Definition: L1TdeRCT.cc:94
unsigned int TrackingMaterialPlotter::fill_gradient ( unsigned int  first,
unsigned int  last,
unsigned int  steps = 100,
unsigned int  index = 0 
)
private

Definition at line 84 of file TrackingMaterialPlotter.cc.

References fill_gradient(), getHLTprescales::index, and relval_steps::steps.

85 {
86  return fill_gradient(* (TColor *) gROOT->GetListOfColors()->At(first), * (TColor *) gROOT->GetListOfColors()->At(last), steps, index);
87 }
bool first
Definition: L1TdeRCT.cc:94
unsigned int fill_gradient(const TColor &first, const TColor &last, unsigned int steps=100, unsigned int index=0)
void TrackingMaterialPlotter::normalize ( void  )
inline

Definition at line 25 of file TrackingMaterialPlotter.h.

References m_tracker, and XHistogram::normalize().

25  {
27  }
void normalize(void)
normalize the histograms
Definition: XHistogram.cc:119
void TrackingMaterialPlotter::plotSegmentInLayer ( const MaterialAccountingStep step,
int  layer 
)

Definition at line 118 of file TrackingMaterialPlotter.cc.

References MaterialAccountingStep::energyLoss(), XHistogram::fill(), MaterialAccountingStep::in(), MaterialAccountingStep::length(), m_tracker, MaterialAccountingStep::out(), PV3DBase< T, PVType, FrameType >::perp(), MaterialAccountingStep::radiationLengths(), w(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by TrackingMaterialAnalyser::split().

119 {
120  std::vector<double> w(2);
121  w[0] = step.radiationLengths();
122  w[1] = step.energyLoss();
123  m_tracker.fill( std::make_pair(step.in().z(), step.out().z()),
124  std::make_pair(step.in().perp(), step.out().perp()),
125  w, step.length(), layer+1 ); // layer is 1-based, but plot uses: 0 is empty, 1 is unassigned
126 }
T perp() const
Definition: PV3DBase.h:71
double length(void) const
double radiationLengths(void) const
double energyLoss(void) const
T z() const
Definition: PV3DBase.h:63
const GlobalPoint & out(void) const
void fill(double x, double y, const std::vector< double > &weight, double norm)
fill one point
Definition: XHistogram.cc:71
const GlobalPoint & in(void) const
T w() const
void TrackingMaterialPlotter::plotSegmentUnassigned ( const MaterialAccountingStep step)

Definition at line 108 of file TrackingMaterialPlotter.cc.

References MaterialAccountingStep::energyLoss(), XHistogram::fill(), MaterialAccountingStep::in(), MaterialAccountingStep::length(), m_tracker, MaterialAccountingStep::out(), PV3DBase< T, PVType, FrameType >::perp(), MaterialAccountingStep::radiationLengths(), w(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by TrackingMaterialAnalyser::split().

109 {
110  std::vector<double> w(2);
111  w[0] = step.radiationLengths();
112  w[1] = step.energyLoss();
113  m_tracker.fill( std::make_pair(step.in().z(), step.out().z()),
114  std::make_pair(step.in().perp(), step.out().perp()),
115  w, step.length(), 1 ); // 0 is empty, 1 is unassigned
116 }
T perp() const
Definition: PV3DBase.h:71
double length(void) const
double radiationLengths(void) const
double energyLoss(void) const
T z() const
Definition: PV3DBase.h:63
const GlobalPoint & out(void) const
void fill(double x, double y, const std::vector< double > &weight, double norm)
fill one point
Definition: XHistogram.cc:71
const GlobalPoint & in(void) const
T w() const

Member Data Documentation

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

Definition at line 34 of file TrackingMaterialPlotter.h.

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

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

Definition at line 35 of file TrackingMaterialPlotter.h.

Referenced by draw(), and fill_gradient().

XHistogram TrackingMaterialPlotter::m_tracker
private