CMS 3D CMS Logo

ListGroups.cc
Go to the documentation of this file.
1 #include <string>
2 #include <vector>
3 #include <map>
4 #include <iostream>
5 #include <iomanip>
6 
7 #include "boost/format.hpp"
8 
17 
24 
25 // ROOT
26 #include <TROOT.h>
27 #include <TProfile2D.h>
28 #include <TColor.h>
29 #include <TStyle.h>
30 #include <TCanvas.h>
31 #include <TFrame.h>
32 #include <TText.h>
33 #include <TLegend.h>
34 #include <TLegendEntry.h>
35 #include <TLine.h>
36 
39 
40 static
42  std::vector<const DDsvalues_type *> result;
43  view.specificsV(result);
44  for (std::vector<const DDsvalues_type *>::iterator it = result.begin(); it != result.end(); ++it) {
45  DDValue parameter(name);
46  if (DDfetch(*it, parameter)) {
47  if (parameter.strings().size() == 1) {
48  value = parameter.strings().front();
49  return true;
50  } else {
51  throw cms::Exception("Configuration")<< " ERROR: multiple " << name << " tags encountered";
52  return false;
53  }
54  }
55  }
56  return false;
57 }
58 
59 /*
60 static inline
61 double dddGetDouble(const std::string & s, DDFilteredView const & view) {
62  std::string value;
63  if (dddGetStringRaw(view, s, value))
64  return double(::atof(value.c_str()));
65  else
66  return NAN;
67 }
68 */
69 
70 static inline
73  if (dddGetStringRaw(view, s, value))
74  return value;
75  else
76  return std::string();
77 }
78 
79 static inline
80 std::ostream & operator<<(std::ostream & out, const math::XYZVector & v) {
81  out << std::fixed << std::setprecision(3);
82  return out << "(" << v.rho() << ", " << v.z() << ", " << v.phi() << ")";
83 }
84 
86 {
87 public:
89  ~ListGroups() override;
90 
91 private:
92  void analyze(const edm::Event &, const edm::EventSetup &) override;
93  void beginJob() override {}
94  void endJob() override;
95  void fillColor();
97  void fillGradient();
98  std::vector<std::pair<std::shared_ptr<TLine>, std::shared_ptr<TText> > > overlayEtaReferences();
101  std::vector<TH2F *> m_plots;
102  std::set<std::string> m_group_names;
103  std::vector<MaterialAccountingGroup *> m_groups;
104  std::vector<unsigned int> m_color;
105  std::vector<int> m_gradient;
106 
107  // The following maps are automatically filled by the script
108  // dumpFullXML, when run with -c,--compare flag, and are injected in
109  // this code via the header ListGroupsMaterialDifference.h, which is
110  // included below. The first value of the pair in m_diff represents
111  // the relative difference ((new - old)/old * 100, in %) of
112  // radiation length, while the second referes to the energy loss (in
113  // GeV/cm) changes. The values in m_values are ordered in the very
114  // same way, ie. they contain the new values for radiation length
115  // and energy loss, respectively.
116  std::map<std::string, std::pair<float, float> > m_diff;
117  std::map<std::string, std::pair<float, float> > m_values;
118 };
119 
121  m_saveSummaryPlot = iPSet.getUntrackedParameter<bool>("SaveSummaryPlot");
122  m_plots.clear();
123  m_groups.clear();
124  TColor::InitializeColors();
125  fillColor();
127  fillGradient();
128 }
129 
131  for (auto plot : m_plots)
132  delete plot;
133 
134  if (!m_groups.empty())
135  for (auto g : m_groups)
136  delete g;
137 }
138 
140  m_diff["TrackerRecMaterialTIBLayer0_Z20"] = std::make_pair<float, float>(0.000000, 0.000000);
141  m_diff["TrackerRecMaterialTECDisk0_R60"] = std::make_pair<float, float>(0.000000, 0.000000);
142  m_diff["TrackerRecMaterialTOBLayer1_Z80"] = std::make_pair<float, float>(0.000000, 0.000000);
143  m_diff["TrackerRecMaterialTOBLayer4_Z0"] = std::make_pair<float, float>(0.000000, 0.000000);
144  m_diff["TrackerRecMaterialTOBLayer2_Z0"] = std::make_pair<float, float>(0.000000, 0.000000);
145  m_diff["TrackerRecMaterialTOBLayer0_Z70"] = std::make_pair<float, float>(0.000000, 0.000000);
146  m_diff["TrackerRecMaterialTECDisk0_R20"] = std::make_pair<float, float>(0.000000, 0.000000);
147  m_diff["TrackerRecMaterialTOBLayer5_Z80"] = std::make_pair<float, float>(338.028085, 425.909863);
148  m_diff["TrackerRecMaterialPixelEndcapDisk1Fw_Outer"] = std::make_pair<float, float>(0.000000, 0.000000);
149  m_diff["TrackerRecMaterialTECDisk1_R20"] = std::make_pair<float, float>(19.426752, 17.294518);
150  m_diff["TrackerRecMaterialTOBLayer5_Z0"] = std::make_pair<float, float>(510.125226, 651.305054);
151  m_diff["TrackerRecMaterialTECDisk8"] = std::make_pair<float, float>(1098.073793, 778.542517);
152  m_diff["TrackerRecMaterialTIDDisk3_R24"] = std::make_pair<float, float>(0.000000, 0.000000);
153  m_diff["TrackerRecMaterialTECDisk4_R33"] = std::make_pair<float, float>(51.925713, 42.900250);
154  m_diff["TrackerRecMaterialTIBLayer1_Z0"] = std::make_pair<float, float>(0.000000, 0.000000);
155  m_diff["TrackerRecMaterialPixelEndcapDisk1Bw_Outer"] = std::make_pair<float, float>(0.000000, 0.000000);
156  m_diff["TrackerRecMaterialTIDDisk2_R25"] = std::make_pair<float, float>(0.000000, 0.000000);
157  m_diff["TrackerRecMaterialTIBLayer0_Z0"] = std::make_pair<float, float>(0.000000, 0.000000);
158  m_diff["TrackerRecMaterialTOBLayer3_Z25"] = std::make_pair<float, float>(0.000000, 0.000000);
159  m_diff["TrackerRecMaterialTIBLayer1_Z30"] = std::make_pair<float, float>(0.000000, 0.000000);
160  m_diff["TrackerRecMaterialTIDDisk2_R40"] = std::make_pair<float, float>(0.000000, 0.000000);
161  m_diff["TrackerRecMaterialTIBLayer2_Z40"] = std::make_pair<float, float>(0.000000, 0.000000);
162  m_diff["TrackerRecMaterialTOBLayer1_Z20"] = std::make_pair<float, float>(0.000000, 0.000000);
163  m_diff["TrackerRecMaterialPixelEndcapDisk2Bw_Inner"] = std::make_pair<float, float>(0.000000, 0.000000);
164  m_diff["TrackerRecMaterialTOBLayer0_Z0"] = std::make_pair<float, float>(0.000000, 0.000000);
165  m_diff["TrackerRecMaterialPixelBarrelLayer0"] = std::make_pair<float, float>(0.000000, 0.000000);
166  m_diff["TrackerRecMaterialPixelBarrelLayer3"] = std::make_pair<float, float>(0.000000, 0.000000);
167  m_diff["TrackerRecMaterialTIBLayer3_Z0"] = std::make_pair<float, float>(0.000000, 0.000000);
168  m_diff["TrackerRecMaterialTOBLayer3_Z80"] = std::make_pair<float, float>(118.048766, 116.983451);
169  m_diff["TrackerRecMaterialTOBLayer4_Z80"] = std::make_pair<float, float>(210.657923, 218.401623);
170  m_diff["TrackerRecMaterialTECDisk5_R33"] = std::make_pair<float, float>(69.556218, 54.695749);
171  m_diff["TrackerRecMaterialTOBLayer0_Z20"] = std::make_pair<float, float>(0.000000, 0.000000);
172  m_diff["TrackerRecMaterialTIBLayer2_Z0"] = std::make_pair<float, float>(0.000000, 0.000000);
173  m_diff["TrackerRecMaterialTECDisk2_R20"] = std::make_pair<float, float>(43.042551, 39.124220);
174  m_diff["TrackerRecMaterialPixelEndcapDisk1Bw_Inner"] = std::make_pair<float, float>(0.000000, 0.000000);
175  m_diff["TrackerRecMaterialTIDDisk1_R30"] = std::make_pair<float, float>(0.000000, 0.000000);
176  m_diff["TrackerRecMaterialTECDisk0_R50"] = std::make_pair<float, float>(0.000000, 0.000000);
177  m_diff["TrackerRecMaterialTOBLayer5_Z25"] = std::make_pair<float, float>(308.073141, 389.306637);
178  m_diff["TrackerRecMaterialPixelEndcapDisk2Bw_Outer"] = std::make_pair<float, float>(0.000000, 0.000000);
179  m_diff["TrackerRecMaterialTIBLayer3_Z50"] = std::make_pair<float, float>(0.000000, 0.000000);
180  m_diff["TrackerRecMaterialTECDisk3"] = std::make_pair<float, float>(40.109901, 34.382246);
181  m_diff["TrackerRecMaterialPixelBarrelLayer1"] = std::make_pair<float, float>(0.000000, 0.000000);
182  m_diff["TrackerRecMaterialPixelBarrelLayer2_External"] = std::make_pair<float, float>(0.000000, 0.000000);
183  m_diff["TrackerRecMaterialPixelEndcapDisk2Fw_Inner"] = std::make_pair<float, float>(0.000000, 0.000000);
184  m_diff["TrackerRecMaterialTECDisk7_R40"] = std::make_pair<float, float>(219.144902, 162.590326);
185  m_diff["TrackerRecMaterialPixelEndcapDisk3Bw_Inner"] = std::make_pair<float, float>(594.908414, 558.979032);
186  m_diff["TrackerRecMaterialPixelEndcapDisk2Fw_Outer"] = std::make_pair<float, float>(0.000000, 0.000000);
187  m_diff["TrackerRecMaterialPixelEndcapDisk3Fw_Outer"] = std::make_pair<float, float>(0.000000, 0.000000);
188  m_diff["TrackerRecMaterialTECDisk6"] = std::make_pair<float, float>(85.692825, 67.990698);
189  m_diff["TrackerRecMaterialTOBLayer3_Z0"] = std::make_pair<float, float>(0.000000, 0.000000);
190  m_diff["TrackerRecMaterialPixelBarrelLayer2"] = std::make_pair<float, float>(0.000000, 0.000000);
191  m_diff["TrackerRecMaterialPixelBarrelLayer3_External"] = std::make_pair<float, float>(0.000000, 0.000000);
192  m_diff["TrackerRecMaterialPixelEndcapDisk3Fw_Inner"] = std::make_pair<float, float>(607.142137, 570.407286);
193  m_diff["TrackerRecMaterialTOBLayer2_Z25"] = std::make_pair<float, float>(0.000000, 0.000000);
194  m_diff["TrackerRecMaterialPixelEndcapDisk3Bw_Outer"] = std::make_pair<float, float>(0.000000, 0.000000);
195  m_diff["TrackerRecMaterialPixelBarrelLayer0_External"] = std::make_pair<float, float>(0.000000, 0.000000);
196  m_diff["TrackerRecMaterialTECDisk0_R90"] = std::make_pair<float, float>(59.694180, 74.636115);
197  m_diff["TrackerRecMaterialTOBLayer1_Z0"] = std::make_pair<float, float>(0.000000, 0.000000);
198  m_diff["TrackerRecMaterialTIDDisk1_R0"] = std::make_pair<float, float>(0.000000, 0.000000);
199  m_diff["TrackerRecMaterialPixelBarrelLayer1_External"] = std::make_pair<float, float>(0.000000, 0.000000);
200  m_diff["TrackerRecMaterialTOBLayer4_Z25"] = std::make_pair<float, float>(0.000000, 0.000000);
201  m_diff["TrackerRecMaterialTOBLayer2_Z80"] = std::make_pair<float, float>(2.291492, 2.290657);
202  m_diff["TrackerRecMaterialPixelEndcapDisk1Fw_Inner"] = std::make_pair<float, float>(0.000000, 0.000000);
203  m_diff["TrackerRecMaterialTECDisk0_R40"] = std::make_pair<float, float>(0.000000, 0.000000);
204  m_diff["TrackerRecMaterialTIDDisk2_R30"] = std::make_pair<float, float>(0.000000, 0.000000);
205  m_values["TrackerRecMaterialTIBLayer0_Z20"] = std::make_pair<float, float>(0.076264, 0.000162);
206  m_values["TrackerRecMaterialTECDisk0_R60"] = std::make_pair<float, float>(0.199482, 0.000368);
207  m_values["TrackerRecMaterialTOBLayer1_Z80"] = std::make_pair<float, float>(0.075550, 0.000145);
208  m_values["TrackerRecMaterialTOBLayer4_Z0"] = std::make_pair<float, float>(0.014804, 0.000033);
209  m_values["TrackerRecMaterialTOBLayer2_Z0"] = std::make_pair<float, float>(0.014947, 0.000033);
210  m_values["TrackerRecMaterialTOBLayer0_Z70"] = std::make_pair<float, float>(0.104496, 0.000208);
211  m_values["TrackerRecMaterialTECDisk0_R20"] = std::make_pair<float, float>(0.177496, 0.000419);
212  m_values["TrackerRecMaterialTOBLayer5_Z80"] = std::make_pair<float, float>(0.095700, 0.000224);
213  m_values["TrackerRecMaterialPixelEndcapDisk1Fw_Outer"] = std::make_pair<float, float>(0.063054, 0.000139);
214  m_values["TrackerRecMaterialTECDisk1_R20"] = std::make_pair<float, float>(0.086704, 0.000189);
215  m_values["TrackerRecMaterialTOBLayer5_Z0"] = std::make_pair<float, float>(0.060576, 0.000155);
216  m_values["TrackerRecMaterialTECDisk8"] = std::make_pair<float, float>(0.329777, 0.000532);
217  m_values["TrackerRecMaterialTIDDisk3_R24"] = std::make_pair<float, float>(0.154447, 0.000366);
218  m_values["TrackerRecMaterialTECDisk4_R33"] = std::make_pair<float, float>(0.072594, 0.000158);
219  m_values["TrackerRecMaterialTIBLayer1_Z0"] = std::make_pair<float, float>(0.049604, 0.000102);
220  m_values["TrackerRecMaterialPixelEndcapDisk1Bw_Outer"] = std::make_pair<float, float>(0.065873, 0.000145);
221  m_values["TrackerRecMaterialTIDDisk2_R25"] = std::make_pair<float, float>(0.067206, 0.000166);
222  m_values["TrackerRecMaterialTIBLayer0_Z0"] = std::make_pair<float, float>(0.056395, 0.000125);
223  m_values["TrackerRecMaterialTOBLayer3_Z25"] = std::make_pair<float, float>(0.035290, 0.000071);
224  m_values["TrackerRecMaterialTIBLayer1_Z30"] = std::make_pair<float, float>(0.068299, 0.000137);
225  m_values["TrackerRecMaterialTIDDisk2_R40"] = std::make_pair<float, float>(0.143121, 0.000310);
226  m_values["TrackerRecMaterialTIBLayer2_Z40"] = std::make_pair<float, float>(0.077840, 0.000155);
227  m_values["TrackerRecMaterialTOBLayer1_Z20"] = std::make_pair<float, float>(0.051913, 0.000103);
228  m_values["TrackerRecMaterialPixelEndcapDisk2Bw_Inner"] = std::make_pair<float, float>(0.039093, 0.000090);
229  m_values["TrackerRecMaterialTOBLayer0_Z0"] = std::make_pair<float, float>(0.029002, 0.000069);
230  m_values["TrackerRecMaterialPixelBarrelLayer0"] = std::make_pair<float, float>(0.018043, 0.000038);
231  m_values["TrackerRecMaterialPixelBarrelLayer3"] = std::make_pair<float, float>(0.020661, 0.000042);
232  m_values["TrackerRecMaterialTIBLayer3_Z0"] = std::make_pair<float, float>(0.048101, 0.000110);
233  m_values["TrackerRecMaterialTOBLayer3_Z80"] = std::make_pair<float, float>(0.093979, 0.000181);
234  m_values["TrackerRecMaterialTOBLayer4_Z80"] = std::make_pair<float, float>(0.101240, 0.000203);
235  m_values["TrackerRecMaterialTECDisk5_R33"] = std::make_pair<float, float>(0.092564, 0.000201);
236  m_values["TrackerRecMaterialTOBLayer0_Z20"] = std::make_pair<float, float>(0.063558, 0.000138);
237  m_values["TrackerRecMaterialTIBLayer2_Z0"] = std::make_pair<float, float>(0.036854, 0.000078);
238  m_values["TrackerRecMaterialTECDisk2_R20"] = std::make_pair<float, float>(0.107900, 0.000237);
239  m_values["TrackerRecMaterialPixelEndcapDisk1Bw_Inner"] = std::make_pair<float, float>(0.039143, 0.000086);
240  m_values["TrackerRecMaterialTIDDisk1_R30"] = std::make_pair<float, float>(0.167774, 0.000321);
241  m_values["TrackerRecMaterialTECDisk0_R50"] = std::make_pair<float, float>(0.108277, 0.000255);
242  m_values["TrackerRecMaterialTOBLayer5_Z25"] = std::make_pair<float, float>(0.086612, 0.000209);
243  m_values["TrackerRecMaterialPixelEndcapDisk2Bw_Outer"] = std::make_pair<float, float>(0.070143, 0.000165);
244  m_values["TrackerRecMaterialTIBLayer3_Z50"] = std::make_pair<float, float>(0.063872, 0.000138);
245  m_values["TrackerRecMaterialTECDisk3"] = std::make_pair<float, float>(0.064126, 0.000139);
246  m_values["TrackerRecMaterialPixelBarrelLayer1"] = std::make_pair<float, float>(0.016379, 0.000028);
247  m_values["TrackerRecMaterialPixelBarrelLayer2_External"] = std::make_pair<float, float>(0.026687, 0.000046);
248  m_values["TrackerRecMaterialPixelEndcapDisk2Fw_Inner"] = std::make_pair<float, float>(0.039737, 0.000091);
249  m_values["TrackerRecMaterialTECDisk7_R40"] = std::make_pair<float, float>(0.126225, 0.000235);
250  m_values["TrackerRecMaterialPixelEndcapDisk3Bw_Inner"] = std::make_pair<float, float>(0.674984, 0.001356);
251  m_values["TrackerRecMaterialPixelEndcapDisk2Fw_Outer"] = std::make_pair<float, float>(0.065935, 0.000151);
252  m_values["TrackerRecMaterialPixelEndcapDisk3Fw_Outer"] = std::make_pair<float, float>(0.100139, 0.000205);
253  m_values["TrackerRecMaterialTECDisk6"] = std::make_pair<float, float>(0.078988, 0.000163);
254  m_values["TrackerRecMaterialTOBLayer3_Z0"] = std::make_pair<float, float>(0.015009, 0.000033);
255  m_values["TrackerRecMaterialPixelBarrelLayer2"] = std::make_pair<float, float>(0.017219, 0.000030);
256  m_values["TrackerRecMaterialPixelBarrelLayer3_External"] = std::make_pair<float, float>(0.036152, 0.000066);
257  m_values["TrackerRecMaterialPixelEndcapDisk3Fw_Inner"] = std::make_pair<float, float>(0.673782, 0.001357);
258  m_values["TrackerRecMaterialTOBLayer2_Z25"] = std::make_pair<float, float>(0.034917, 0.000069);
259  m_values["TrackerRecMaterialPixelEndcapDisk3Bw_Outer"] = std::make_pair<float, float>(0.100143, 0.000204);
260  m_values["TrackerRecMaterialPixelBarrelLayer0_External"] = std::make_pair<float, float>(0.031128, 0.000062);
261  m_values["TrackerRecMaterialTECDisk0_R90"] = std::make_pair<float, float>(0.309342, 0.000539);
262  m_values["TrackerRecMaterialTOBLayer1_Z0"] = std::make_pair<float, float>(0.023489, 0.000050);
263  m_values["TrackerRecMaterialTIDDisk1_R0"] = std::make_pair<float, float>(0.175180, 0.000349);
264  m_values["TrackerRecMaterialPixelBarrelLayer1_External"] = std::make_pair<float, float>(0.022508, 0.000036);
265  m_values["TrackerRecMaterialTOBLayer4_Z25"] = std::make_pair<float, float>(0.036056, 0.000073);
266  m_values["TrackerRecMaterialTOBLayer2_Z80"] = std::make_pair<float, float>(0.062072, 0.000117);
267  m_values["TrackerRecMaterialPixelEndcapDisk1Fw_Inner"] = std::make_pair<float, float>(0.039127, 0.000086);
268  m_values["TrackerRecMaterialTECDisk0_R40"] = std::make_pair<float, float>(0.084231, 0.000209);
269  m_values["TrackerRecMaterialTIDDisk2_R30"] = std::make_pair<float, float>(0.065109, 0.000143);
270 
271 }
272 
274 {
275  m_gradient.reserve(200);
276  unsigned int steps = 100;
277  // if no index was given, find the highest used one and start from that plus one
278  unsigned int index = ((TObjArray*) gROOT->GetListOfColors())->GetLast() + 1;
279 
280  float r1, g1, b1, r2, g2, b2;
281  static_cast<TColor *>(gROOT->GetListOfColors()->At(kBlue + 1))->GetRGB(r1, g1, b1);
282  static_cast<TColor *>(gROOT->GetListOfColors()->At(kAzure + 10))->GetRGB(r2, g2, b2);
283  float delta_r = (r2 - r1) / (steps - 1);
284  float delta_g = (g2 - g1) / (steps - 1);
285  float delta_b = (b2 - b1) / (steps - 1);
286 
287  m_gradient.push_back(kBlue + 4); // Underflow lowest bin
288  unsigned int ii = 0;
289  for (unsigned int i = 0; i < steps; ++i, ++ii) {
290  new TColor(static_cast<Int_t>(index + ii), r1 + delta_r * i, g1 + delta_g * i, b1 + delta_b * i);
291  m_gradient.push_back(index + ii);
292  }
293 
294  m_gradient.push_back(kWhite); // 0 level perfectly white
295 
296  static_cast<TColor *>(gROOT->GetListOfColors()->At(kOrange))->GetRGB(r1, g1, b1);
297  static_cast<TColor *>(gROOT->GetListOfColors()->At(kOrange + 7))->GetRGB(r2, g2, b2);
298  delta_r = (r2 - r1) / (steps - 1);
299  delta_g = (g2 - g1) / (steps - 1);
300  delta_b = (b2 - b1) / (steps - 1);
301  for (unsigned int i = 0; i < steps; ++i, ++ii) {
302  new TColor(static_cast<Int_t>(index + ii), r1 + delta_r * i, g1 + delta_g * i, b1 + delta_b * i);
303  m_gradient.push_back(index + ii);
304  }
305  m_gradient.push_back(kRed); // Overflow highest bin
306 }
307 
309  // With the introduction of the support for PhaseI and PhaseII detectors it
310  // became quite difficult to maintain a list of colors that is in sync with
311  // the real number of grouping used in the different scenarios. We therefore
312  // define some reasonable set and loop over it in case the number of grouping
313  // is larger than the number of colors.
314 
315  m_color.push_back(kBlack); // unassigned
316 
317  m_color.push_back(kAzure); // PixelBarrelLayer0_Z0
318  m_color.push_back(kAzure - 1); // PixelBarrelLayer0_Z20
319  m_color.push_back(kAzure + 1) ; // Layer1_Z0
320  m_color.push_back(kAzure + 2) ; // Layer1_Z20
321 
322  m_color.push_back(kGreen); // EndCapDisk1_R0
323  m_color.push_back(kGreen + 2); // EndcapDisk1_R11
324  m_color.push_back(kGreen + 4); // EndcapDisk1_R7
325  m_color.push_back(kSpring + 9); // EndcapDisk2_R0
326  m_color.push_back(kSpring + 4); // EndcapDisk2_R7
327  m_color.push_back(kSpring ); // EndcapDisk2_R7
328 
329  m_color.push_back(kRed); // TECDisk0_R20
330  m_color.push_back(kRed + 2); // TECDisk0_R40
331  m_color.push_back(kRed - 7); // TECDisk0_R50
332  m_color.push_back(kRed - 5); // TECDisk0_R60
333  m_color.push_back(kRed - 10); // TECDisk0_R90
334  m_color.push_back(kRed - 1); // TECDisk1_Inner
335  m_color.push_back(kRed - 2); // TECDisk1_Outer
336  m_color.push_back(kRed - 3); // TECDisk1_R20
337  m_color.push_back(kPink - 2); // TECDisk2_Inner
338  m_color.push_back(kPink - 3); // TECDisk2_Outer
339  m_color.push_back(kPink - 4); // TECDisk2_R20
340  m_color.push_back(kPink + 9); // TECDisk3_Inner
341  m_color.push_back(kPink + 8); // TECDisk3_Outer
342  m_color.push_back(kPink + 7); // TECDisk3
343  m_color.push_back(kMagenta - 2); // TECDisk4_Inner
344  m_color.push_back(kMagenta - 3); // TECDisk4_Outer
345  m_color.push_back(kMagenta - 4); // TECDisk4_R33
346  m_color.push_back(kMagenta - 5); // TECDisk5_Inner
347  m_color.push_back(kMagenta - 6); // TECDisk5_Outer
348  m_color.push_back(kMagenta - 7); // TECDisk5_R33
349  m_color.push_back(kRed); // TECDisk6
350  m_color.push_back(kMagenta - 9); // TECDisk7_R40
351  m_color.push_back(kViolet); // TECDisk8
352 
353  m_color.push_back(kOrange + 9); // TIBLayer0_Z0
354  m_color.push_back(kOrange + 7); // TIBLayer0_Z20
355  m_color.push_back(kOrange + 5); // TIBLayer0_Z40
356  m_color.push_back(kOrange - 2); // TIBLayer1_Z0
357  m_color.push_back(kOrange - 3); // TIBLayer1_Z30
358  m_color.push_back(kOrange - 6); // TIBLayer1_Z60
359  m_color.push_back(kOrange + 4); // TIBLayer2_Z0
360  m_color.push_back(kOrange - 7); // TIBLayer2_Z40
361  m_color.push_back(kOrange); // TIBLayer3_Z0
362  m_color.push_back(kOrange + 10); // TIBLayer3_Z50
363 
364  m_color.push_back(kViolet + 10); // TIDDisk1_R0
365  m_color.push_back(kViolet + 6); // TIDDisk1_R30
366  m_color.push_back(kViolet + 3); // TIDDisk1_R40
367  m_color.push_back(kViolet - 7); // TIDDisk2_R25
368  m_color.push_back(kViolet - 1); // TIDDisk2_R30
369  m_color.push_back(kViolet + 9); // TIDDisk2_R40
370  m_color.push_back(kViolet - 5); // TIDDisk3_R24
371  m_color.push_back(kViolet - 3); // TIDDisk3_R30
372  m_color.push_back(kViolet); // TIDDisk3_R40
373 
374  m_color.push_back(kAzure ); // TOBLayer0_Z0
375  m_color.push_back(kAzure + 8); // TOBLayer0_Z20
376  m_color.push_back(kAzure + 2); // TOBLayer0_Z70
377  m_color.push_back(kAzure + 4); // TOBLayer0_Z80
378  m_color.push_back(kCyan + 1); // TOBLayer1_Z0
379  m_color.push_back(kCyan - 9); // TOBLayer1_Z20
380  m_color.push_back(kCyan + 3); // TOBLayer1_Z80
381  m_color.push_back(kCyan + 4); // TOBLayer1_Z90
382  m_color.push_back(kAzure ); // TOBLayer2_Z0
383  m_color.push_back(kAzure + 8); // TOBLayer2_Z25
384  m_color.push_back(kAzure + 2); // TOBLayer2_Z80
385  m_color.push_back(kAzure + 5); // TOBLayer2_Z90
386  m_color.push_back(kCyan + 1); // TOBLayer3_Z0
387  m_color.push_back(kCyan - 9); // TOBLayer3_Z25
388  m_color.push_back(kCyan + 3); // TOBLayer3_Z80
389  m_color.push_back(kCyan + 4); // TOBLayer3_Z90
390  m_color.push_back(kAzure ); // TOBLayer4_Z0
391  m_color.push_back(kAzure + 8); // TOBLayer4_Z25
392  m_color.push_back(kAzure + 2); // TOBLayer4_Z80
393  m_color.push_back(kAzure + 5); // TOBLayer4_Z90
394  m_color.push_back(kCyan + 1); // TOBLayer5_Z0
395  m_color.push_back(kCyan - 9); // TOBLayer5_Z25
396  m_color.push_back(kCyan + 3); // TOBLayer5_Z80
397  m_color.push_back(kCyan + 4); // TOBLayer5_Z90
398 }
399 
400 std::vector<std::pair<std::shared_ptr<TLine>, std::shared_ptr<TText> > >
402  std::vector<std::pair<std::shared_ptr<TLine>, std::shared_ptr<TText> > > lines;
403 
404  lines.reserve(40);
405  std::pair<float, float> deltaZ(293, 298);
406  std::pair<float, float> deltaR(115, 118);
407  float text_size = 0.033;
408 
409  for (float eta = 0.; eta <= 3.8; eta += 0.2) {
410  float theta = 2. * atan (exp(-eta));
411  if (eta >= 1.8) {
412  lines.push_back(
413  std::make_pair<std::shared_ptr<TLine>, std::shared_ptr<TText> > (
414  std::make_shared<TLine>(
415  deltaZ.first, deltaZ.first * tan(theta), deltaZ.second, deltaZ.second * tan(theta)),
416  std::make_shared<TText>(
417  deltaZ.first, deltaZ.first * tan(theta), str(boost::format("%2.1f") % eta).c_str())));
418  lines.back().second->SetTextFont(42);
419  lines.back().second->SetTextSize(text_size);
420  lines.back().second->SetTextAlign(33);
421  lines.push_back(
422  std::make_pair<std::shared_ptr<TLine>, std::shared_ptr<TText> > (
423  std::make_shared<TLine>(
424  -deltaZ.first, deltaZ.first * tan(theta), -deltaZ.second, deltaZ.second * tan(theta)),
425  std::make_shared<TText>(
426  -deltaZ.first, deltaZ.first * tan(theta), str(boost::format("-%2.1f") % eta).c_str())));
427  lines.back().second->SetTextFont(42);
428  lines.back().second->SetTextSize(text_size);
429  lines.back().second->SetTextAlign(13);
430  } else {
431  lines.push_back(
432  std::make_pair<std::shared_ptr<TLine>, std::shared_ptr<TText> > (
433  std::make_shared<TLine>(
434  deltaR.first / tan(theta), deltaR.first, deltaR.second / tan(theta), deltaR.second),
435  std::make_shared<TText>(
436  deltaR.first / tan(theta), deltaR.first, str(boost::format("%2.1f") % eta).c_str())));
437  lines.back().second->SetTextFont(42);
438  lines.back().second->SetTextSize(text_size);
439  lines.back().second->SetTextAlign(23);
440  if (eta != 0) {
441  lines.push_back(
442  std::make_pair<std::shared_ptr<TLine>, std::shared_ptr<TText> > (
443  std::make_shared<TLine>(
444  - deltaR.first / tan(theta), deltaR.first, - deltaR.second / tan(theta), deltaR.second),
445  std::make_shared<TText>(
446  - deltaR.first / tan(theta), deltaR.first, str(boost::format("-%2.1f") % eta).c_str())));
447  lines.back().second->SetTextFont(42);
448  lines.back().second->SetTextSize(text_size);
449  lines.back().second->SetTextAlign(23);
450  }
451  }
452  }
453  return lines;
454 }
455 
456 
458  const double scale = 10.;
459  std::vector<TText *> nukem_text;
460  static int markerStyles[10] = {kFullCircle, kFullSquare, kFullTriangleUp, kFullTriangleDown, kOpenCircle, kOpenSquare, kOpenTriangleUp, kOpenDiamond, kOpenCross, kFullStar};
461 
463  setup.get<IdealGeometryRecord>().get( hDdd );
464 
465  for (auto n : m_group_names) {
466  m_groups.push_back( new MaterialAccountingGroup(n, *hDdd) );
467  };
468 
469  std::unique_ptr<TCanvas> canvas(
470  new TCanvas("Grouping_rz", "Grouping - RZ view",
471  (int) (600 * scale * 1.25), (int) (120 * scale * 1.50)));
472  canvas->GetFrame()->SetFillColor(kWhite);
473  gStyle->SetOptStat(0);
474 
475  unsigned int color_index = 1;
476  // Setup the legend
477  std::unique_ptr<TLegend> leg(new TLegend(0.1,0.1,0.23,0.34));
478  leg->SetHeader("Tracker Material Grouping");
479  leg->SetTextFont(42);
480  leg->SetTextSize(0.008);
481  leg->SetNColumns(3);
482  std::unique_ptr<TProfile2D> radlen(
483  new TProfile2D( "OverallRadLen", "OverallRadLen",
484  600., -300., 300, 120., 0., 120.));
485  std::unique_ptr<TProfile2D> eneloss(
486  new TProfile2D( "OverallEnergyLoss", "OverallEnergyLoss",
487  600., -300., 300, 120., 0., 120.));
488  std::unique_ptr<TProfile2D> radlen_diff(
489  new TProfile2D( "OverallDifferencesRadLen", "OverallDifferencesRadLen",
490  600., -300., 300, 120., 0., 120.));
491  std::unique_ptr<TProfile2D> eneloss_diff(
492  new TProfile2D( "OverallDifferencesEnergyLoss", "OverallDifferencesEnergyLoss",
493  600., -300., 300, 120., 0., 120.));
494 
495  for (auto g : m_groups) {
496  m_plots.push_back(
497  new TH2F( g->name().c_str(), g->name().c_str(),
498  6000., -300., 300, 1200., 0., 120.)); // 10x10 points per cm2
499  TH2F &current = *m_plots.back();
500  current.SetMarkerColor(m_color[color_index]);
501  current.SetMarkerStyle(markerStyles[color_index%10]);
502  current.SetMarkerSize(0.8);
503  current.SetLineWidth(1);
504  for (auto element : g->elements()) {
505  current.Fill(element.z(), element.perp());
506  radlen->Fill(element.z(), element.perp(), m_values[g->name()].first);
507  eneloss->Fill(element.z(), element.perp(), m_values[g->name()].second);
508  radlen_diff->Fill(element.z(), element.perp(), m_diff[g->name()].first);
509  eneloss_diff->Fill(element.z(), element.perp(), m_diff[g->name()].second);
510  }
511 
512  if (color_index == 1)
513  current.Draw();
514  else
515  current.Draw("SAME");
516 
517  leg->AddEntry(&current , g->name().c_str(), "lp")->SetTextColor(m_color[color_index]);
518  color_index++;
519 
520  // Loop over the same chromatic scale in case the number of
521  // allocated colors is not big enough.
522  color_index = color_index%m_color.size();
523  }
524  leg->Draw();
525  canvas->SaveAs("Grouping.png");
526 
527  std::vector<std::pair<std::shared_ptr<TLine>, std::shared_ptr<TText> > > lines = overlayEtaReferences();
528 
529  canvas->Clear();
530  radlen->SetMinimum(0);
531  radlen->SetMaximum(0.25);
532  radlen->Draw("COLZ");
533  for (auto line : lines) {
534  line.first->SetLineWidth(5);
535  line.first->Draw();
536  line.second->Draw();
537  }
538  canvas->SaveAs("RadLenValues.png");
539 
540  canvas->Clear();
541  eneloss->SetMinimum(0.00001);
542  eneloss->SetMaximum(0.0005);
543  eneloss->Draw("COLZ");
544  for (auto line : lines) {
545  line.first->SetLineWidth(5);
546  line.first->Draw();
547  line.second->Draw();
548  }
549  canvas->SaveAs("EnergyLossValues.png");
550 
551  canvas->Clear();
552  gStyle->SetPalette( m_gradient.size(), & m_gradient.front() );
553  gStyle->SetNumberContours( m_gradient.size() );
554  radlen_diff->SetMinimum(-100);
555  radlen_diff->SetMaximum(100);
556  radlen_diff->Draw("COLZ");
557  for (auto line : lines) {
558  line.first->SetLineWidth(5);
559  line.first->Draw();
560  line.second->Draw();
561  }
562  canvas->SaveAs("RadLenChanges.png");
563 
564  canvas->Clear();
565  eneloss_diff->SetMinimum(-100);
566  eneloss_diff->SetMaximum(100);
567  eneloss_diff->Draw("COLZ");
568  for (auto line : lines) {
569  line.first->SetLineWidth(5);
570  line.first->Draw();
571  line.second->Draw();
572  }
573  canvas->SaveAs("EnergyLossChanges.png");
574 
575  for (auto g : nukem_text)
576  delete g;
577 
578 }
579 
580 
581 void
584  setup.get<IdealGeometryRecord>().get( hDdd );
585 
586  DDSpecificsHasNamedValueFilter filter{"TrackingMaterialGroup"};
587  DDFilteredView fv(*hDdd,filter);
588 
589  while (fv.next()) {
590  // print the group name and full hierarchy of all items
591  std::cout << dddGetString("TrackingMaterialGroup", fv) << '\t';
592  m_group_names.insert(dddGetString("TrackingMaterialGroup", fv));
593 
594  // start from 2 to skip the leading /OCMS[0]/CMSE[1] part
595  const DDGeoHistory & history = fv.geoHistory();
596  std::cout << '/';
597  for (unsigned int h = 2; h < history.size(); ++h)
598  std::cout << '/' << history[h].logicalPart().name().name() << '[' << history[h].copyno() << ']';
599 
600  // DD3Vector and DDTranslation are the same type as math::XYZVector
601  math::XYZVector position = fv.translation() / 10.; // mm -> cm
602  std::cout << "\t(" << position.x()
603  << ", " << position.y()
604  << ", " << position.z() << ") "
605  << "[rho] " << position.Rho() << std::endl;
606  };
607  std::cout << std::endl;
608 
609  if (m_saveSummaryPlot)
611 }
612 
613 void
615 }
616 
617 //-------------------------------------------------------------------------
618 // define as a plugin
T getUntrackedParameter(std::string const &, T const &) const
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
void endJob() override
Definition: ListGroups.cc:614
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
void fillColor()
Definition: ListGroups.cc:308
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: ListGroups.cc:582
Geom::Theta< T > theta() const
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:1
const DDGeoHistory & geoHistory() const
The list of ancestors up to the root-node of the current node.
std::vector< TH2F * > m_plots
Definition: ListGroups.cc:101
bool DDfetch(const DDsvalues_type *, DDValue &)
helper for retrieving DDValues from DDsvalues_type *.
Definition: DDsvalues.cc:81
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
Definition: Activities.doc:4
void beginJob() override
Definition: ListGroups.cc:93
std::vector< unsigned int > m_color
Definition: ListGroups.cc:104
std::vector< std::pair< std::shared_ptr< TLine >, std::shared_ptr< TText > > > overlayEtaReferences()
Definition: ListGroups.cc:401
void produceAndSaveSummaryPlot(const edm::EventSetup &)
Definition: ListGroups.cc:457
static std::ostream & operator<<(std::ostream &out, const math::XYZVector &v)
Definition: ListGroups.cc:80
bool next()
set current node to the next node in the filtered tree
void fillMaterialDifferences()
Definition: ListGroups.cc:139
double delta_r(const Fourvec &a, const Fourvec &b)
Find the distance between two four-vectors in the two-dimensional space .
Definition: fourvec.cc:249
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
format
Some error handling for the usage.
Definition: value.py:1
ii
Definition: cuy.py:589
const std::vector< std::string > & strings() const
a reference to the std::string-valued values stored in the given instance of DDValue ...
Definition: DDValue.h:61
std::map< std::string, std::pair< float, float > > m_diff
Definition: ListGroups.cc:116
std::vector< DDExpandedNode > DDGeoHistory
Geometrical &#39;path&#39; of the current node up to the root-node.
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
bool m_saveSummaryPlot
Definition: ListGroups.cc:100
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:30
void fillGradient()
Definition: ListGroups.cc:273
std::set< std::string > m_group_names
Definition: ListGroups.cc:102
std::vector< MaterialAccountingGroup * > m_groups
Definition: ListGroups.cc:103
static int position[264][3]
Definition: ReadPGInfo.cc:509
ListGroups(const edm::ParameterSet &)
Definition: ListGroups.cc:120
T get() const
Definition: EventSetup.h:63
def canvas(sub, attr)
Definition: svgfig.py:481
std::vector< int > m_gradient
Definition: ListGroups.cc:105
void specificsV(std::vector< const DDsvalues_type * > &result) const
User specific data attached to the current node.
static bool dddGetStringRaw(const DDFilteredView &view, const std::string &name, std::string &value)
Definition: ListGroups.cc:41
const DDTranslation & translation() const
The absolute translation of the current node.
#define str(s)
~ListGroups() override
Definition: ListGroups.cc:130
std::map< std::string, std::pair< float, float > > m_values
Definition: ListGroups.cc:117
static std::string dddGetString(const std::string &s, DDFilteredView const &view)
Definition: ListGroups.cc:71