]>
Commit | Line | Data |
---|---|---|
2955f67c | 1 | /** |
2 | * @file SummaryDrawer.C | |
3 | * @author Christian Holm Christensen <cholm@master.hehi.nbi.dk> | |
4 | * @date Sun Nov 25 11:36:41 2012 | |
5 | * | |
6 | * @brief Base class for classes to draw summaries | |
7 | * | |
8 | * | |
9 | */ | |
10 | #ifndef SUMMARYDRAWER_C | |
11 | # define SUMMARYDRAWER_C | |
12 | # ifndef __CINT__ | |
13 | # include <THStack.h> | |
14 | # include <TH1.h> | |
15 | # include <TH2.h> | |
8449e3e0 | 16 | # include <TH3.h> |
2955f67c | 17 | # include <TParameter.h> |
18 | # include <TCanvas.h> | |
19 | # include <TList.h> | |
20 | # include <TFile.h> | |
21 | # include <TError.h> | |
22 | # include <TLatex.h> | |
23 | # include <TLegend.h> | |
24 | # include <TLegendEntry.h> | |
25 | # include <TMath.h> | |
26 | # include <TString.h> | |
27 | # include <TStyle.h> | |
28 | # include <TSystem.h> | |
29 | # include <TProfile.h> | |
30 | # include <TGaxis.h> | |
31 | # include <TPad.h> | |
8449e3e0 | 32 | # include <TRegexp.h> |
77f97e3f | 33 | # include <TGraph.h> |
a19faec0 | 34 | # include <sstream> |
35 | # include <iomanip> | |
bfab35d9 | 36 | # else |
37 | # ifdef __ACLIC__ | |
2955f67c | 38 | class THStack; |
39 | class TH1; | |
40 | class TH2; | |
8449e3e0 | 41 | class TH3; |
2955f67c | 42 | class TCollection; |
43 | class TCanvas; | |
44 | class TVirtualPad; | |
45 | class TPad; | |
46 | class TLatex; | |
47 | class TAxis; | |
bfab35d9 | 48 | # endif |
2955f67c | 49 | # endif |
50 | ||
8449e3e0 | 51 | /** |
52 | * Base class for summary drawers | |
53 | * | |
54 | */ | |
2955f67c | 55 | class SummaryDrawer |
56 | { | |
57 | public: | |
bfab35d9 | 58 | enum { |
59 | kLogx = 0x1, | |
60 | kLogy = 0x2, | |
61 | kLogz = 0x4, | |
62 | kLegend = 0x10, | |
63 | kGridx = 0x100, | |
64 | kGridy = 0x200, | |
b767da2c | 65 | kGridz = 0x400, |
70849dc0 | 66 | kSilent = 0x800, |
67 | kNorth = 0x1000, | |
68 | kMiddle = 0x2000, | |
69 | kSouth = 0x3000, | |
70 | kEast = 0x10000, | |
71 | kCenter = 0x20000, | |
72 | kWest = 0x30000 | |
bfab35d9 | 73 | }; |
fba5d22d | 74 | enum { |
75 | kLandscape = 0x100, | |
76 | kPause = 0x200 | |
77 | }; | |
2955f67c | 78 | SummaryDrawer() |
79 | : fCanvas(0), | |
80 | fTop(0), | |
81 | fBody(0), | |
82 | fHeader(0), | |
83 | fParName(0), | |
84 | fParVal(0), | |
85 | fPause(false), | |
86 | fLandscape(false), | |
8449e3e0 | 87 | fRingMap(0), |
77f97e3f CHC |
88 | fPDF(true), |
89 | fLastTitle("") | |
2955f67c | 90 | { |
91 | fRingMap = new TVirtualPad*[6]; | |
92 | fRingMap[0] = 0; | |
93 | fRingMap[1] = 0; | |
94 | fRingMap[2] = 0; | |
95 | fRingMap[3] = 0; | |
96 | fRingMap[4] = 0; | |
97 | fRingMap[5] = 0; | |
98 | } | |
bfab35d9 | 99 | virtual ~SummaryDrawer() {} |
2955f67c | 100 | |
101 | protected: | |
70849dc0 | 102 | //____________________________________________________________________ |
7095962e CHC |
103 | /** |
104 | * Get null terminated array of ring names | |
105 | * | |
106 | * @param lower If true, return in the form FMD[1-3][io], otherwise | |
107 | * in the form FMD[1-3][IO] | |
108 | * | |
109 | * @return Null terminated array of ring names | |
110 | */ | |
111 | static const Char_t** GetRingNames(Bool_t lower=false) | |
112 | { | |
113 | static const Char_t* lN[]={ "FMD1i", "FMD2i", "FMD2o", "FMD3o", "FMD3i", 0}; | |
114 | static const Char_t* uN[]={ "FMD1I", "FMD2I", "FMD2O", "FMD3O", "FMD3I", 0}; | |
115 | return (lower ? lN : uN); | |
116 | } | |
70849dc0 | 117 | //____________________________________________________________________ |
bfab35d9 | 118 | /** |
119 | * Get the standard color for a ring | |
120 | * | |
121 | * @param d Detector | |
122 | * @param r Ring | |
123 | * | |
124 | * @return | |
125 | */ | |
126 | static Color_t RingColor(UShort_t d, Char_t r) | |
127 | { | |
128 | return ((d == 1 ? kRed : (d == 2 ? kGreen : kBlue)) | |
129 | + ((r == 'I' || r == 'i') ? 2 : -3)); | |
130 | } | |
70849dc0 | 131 | //____________________________________________________________________ |
132 | TLegend* DrawRingLegend(TVirtualPad* p, UInt_t flags) | |
133 | { | |
134 | TLegend* l = MakeLegend(p, flags, false); | |
135 | ||
136 | for (UShort_t i = 0; i < 5; i++) { | |
137 | UShort_t d = (i+1)/2+1; | |
a19faec0 | 138 | Char_t r = (i/2 == 1) ? 'o' : 'i'; |
70849dc0 | 139 | TLegendEntry* e = l->AddEntry("dummy", Form("FMD%d%c", d, r), "f"); |
140 | e->SetFillColor(RingColor(d, r)); | |
141 | e->SetFillStyle(1001); | |
142 | e->SetLineColor(kBlack); | |
143 | } | |
144 | ||
145 | l->Draw(); | |
146 | return l; | |
147 | } | |
148 | //____________________________________________________________________ | |
fba5d22d | 149 | static void SysString(UShort_t sys, TString& str) |
150 | { | |
151 | str = "?"; | |
152 | switch (sys) { | |
153 | case 1: str = "pp"; break; | |
154 | case 2: str = "PbPb"; break; | |
155 | case 3: str = "pPb"; break; | |
156 | } | |
157 | } | |
70849dc0 | 158 | //____________________________________________________________________ |
fba5d22d | 159 | static void SNNString(UShort_t sNN, TString& str) |
160 | { | |
161 | str = "?"; | |
162 | if (sNN < 1000) str = Form("%dGeV", sNN); | |
163 | else if (sNN < 3000) str = Form("%4.2fTeV", 0.001*sNN); | |
164 | else str = Form("%dTeV", sNN/1000); | |
165 | } | |
70849dc0 | 166 | //____________________________________________________________________ |
2955f67c | 167 | /** |
fba5d22d | 168 | * Append an & to a string and the next term. |
2955f67c | 169 | * |
fba5d22d | 170 | * @param trg Output string |
171 | * @param what Term | |
2955f67c | 172 | */ |
fba5d22d | 173 | static void AppendAnd(TString& trg, const TString& what) |
2955f67c | 174 | { |
fba5d22d | 175 | if (!trg.IsNull()) trg.Append(" & "); |
176 | trg.Append(what); | |
177 | } | |
70849dc0 | 178 | //____________________________________________________________________ |
fba5d22d | 179 | static void TriggerString(ULong_t trigger, TString& str) |
180 | { | |
181 | str = ""; | |
182 | /** | |
183 | * Bits of the trigger pattern | |
184 | */ | |
185 | enum { | |
186 | /** In-elastic collision */ | |
187 | kInel = 0x0001, | |
188 | /** In-elastic collision with at least one SPD tracklet */ | |
189 | kInelGt0 = 0x0002, | |
190 | /** Non-single diffractive collision */ | |
191 | kNSD = 0x0004, | |
192 | /** Empty bunch crossing */ | |
193 | kEmpty = 0x0008, | |
194 | /** A-side trigger */ | |
195 | kA = 0x0010, | |
196 | /** B(arrel) trigger */ | |
197 | kB = 0x0020, | |
198 | /** C-side trigger */ | |
199 | kC = 0x0080, | |
200 | /** Empty trigger */ | |
201 | kE = 0x0100, | |
202 | /** pileup from SPD */ | |
203 | kPileUp = 0x0200, | |
204 | /** true NSD from MC */ | |
205 | kMCNSD = 0x0400, | |
206 | /** Offline MB triggered */ | |
207 | kOffline = 0x0800, | |
208 | /** At least one SPD cluster */ | |
209 | kNClusterGt0 = 0x1000, | |
210 | /** V0-AND trigger */ | |
211 | kV0AND = 0x2000, | |
212 | /** Satellite event */ | |
213 | kSatellite = 0x4000 | |
214 | }; | |
215 | if ((trigger & kInel) != 0x0) AppendAnd(str, "INEL"); | |
216 | if ((trigger & kInelGt0) != 0x0) AppendAnd(str, "INEL>0"); | |
217 | if ((trigger & kNSD) != 0x0) AppendAnd(str, "NSD"); | |
218 | if ((trigger & kV0AND) != 0x0) AppendAnd(str, "V0AND"); | |
219 | if ((trigger & kA) != 0x0) AppendAnd(str, "A"); | |
220 | if ((trigger & kB) != 0x0) AppendAnd(str, "B"); | |
221 | if ((trigger & kC) != 0x0) AppendAnd(str, "C"); | |
222 | if ((trigger & kE) != 0x0) AppendAnd(str, "E"); | |
223 | if ((trigger & kMCNSD) != 0x0) AppendAnd(str, "MCNSD"); | |
224 | if ((trigger & kNClusterGt0) != 0x0) AppendAnd(str, "NCluster>0"); | |
225 | if ((trigger & kSatellite) != 0x0) AppendAnd(str, "Satellite"); | |
2955f67c | 226 | } |
fba5d22d | 227 | |
2955f67c | 228 | //__________________________________________________________________ |
229 | /** | |
fba5d22d | 230 | * Find an object in a collection |
2955f67c | 231 | * |
232 | * @param parent Parent directory | |
233 | * @param name Name of object | |
33438b4c | 234 | * @param verb Be verbose |
2955f67c | 235 | * |
236 | * @return Pointer to object or null | |
237 | */ | |
fba5d22d | 238 | static TObject* GetObject(const TObject* parent, |
2955f67c | 239 | const TString& name, |
240 | Bool_t verb=true) | |
241 | { | |
242 | if (!parent) { | |
fba5d22d | 243 | if (verb) Warning("GetObject", "No parent given"); |
2955f67c | 244 | return 0; |
245 | } | |
246 | if (name.IsNull()) { | |
247 | if (verb) Warning("GetObject", "No name specified"); | |
248 | return 0; | |
249 | } | |
fba5d22d | 250 | TObject* o = 0; |
251 | if (parent->IsA()->InheritsFrom(TCollection::Class())) { | |
252 | const TCollection* p = static_cast<const TCollection*>(parent); | |
253 | o = p->FindObject(name); | |
254 | } | |
255 | else if (parent->IsA()->InheritsFrom(TDirectory::Class())) { | |
256 | const TDirectory* d = static_cast<const TDirectory*>(parent); | |
257 | o = const_cast<TDirectory*>(d)->Get(name); | |
258 | } | |
259 | else | |
260 | Warning("GetObject", "Do not know how to find an object (%s) in " | |
261 | "%s (of class %s)", name.Data(), | |
262 | parent ? parent->GetName() : "?", | |
263 | parent ? parent->ClassName() : "?"); | |
2955f67c | 264 | if (!o) { |
265 | if (verb) Warning("GetObject", "Object \"%s\" not found in parent \"%s\"", | |
266 | name.Data(), parent->GetName()); | |
267 | return 0; | |
268 | } | |
fba5d22d | 269 | return o; |
2955f67c | 270 | } |
271 | //____________________________________________________________________ | |
272 | /** | |
273 | * Check the type of a found object | |
274 | * | |
275 | * @param o Object | |
276 | * @param cl Class | |
277 | * @param src Source of object | |
278 | * | |
279 | * @return true on success, false otherwise | |
280 | */ | |
281 | static Bool_t CheckType(const TObject* o, | |
282 | const TClass* cl, | |
283 | const TString& src) | |
284 | { | |
285 | if (!o->IsA()->InheritsFrom(cl)) { | |
286 | Warning("CheckType", "Object \"%s\" retrieved from \"%s\" is not a " | |
287 | "%s but a %s", o->GetName(), src.Data(), cl->GetName(), | |
288 | o->ClassName()); | |
289 | return false; | |
290 | } | |
291 | return true; | |
292 | } | |
fba5d22d | 293 | //__________________________________________________________________ |
294 | /** | |
295 | * Check a possibly returned object. | |
296 | * | |
297 | * @param o Object found - if any | |
298 | * @param p Parent of object | |
299 | * | |
300 | * @return A pointer to the object cast to the right type | |
301 | */ | |
302 | template <typename T> | |
303 | static T* DoGetObject(TObject* o, const TObject* p) | |
304 | { | |
305 | if (!o) return 0; | |
306 | if (!CheckType(o, T::Class(), p->GetName())) return 0; | |
307 | return static_cast<T*>(o); | |
308 | } | |
309 | //__________________________________________________________________ | |
310 | /** | |
311 | * Check a returned parameter from a parent | |
312 | * | |
313 | * @param o Possibly found object | |
314 | * @param p Parent object | |
315 | * @param value Value | |
316 | * | |
317 | * @return true on success, false otherwise | |
318 | */ | |
4fdca35c | 319 | template <typename T> |
320 | static Bool_t DoGetParameter(TObject* o, const TObject* p, T& value) | |
321 | { | |
fba5d22d | 322 | TParameter<T>* r = DoGetObject<TParameter<T> >(o, p); |
323 | if (!r) return false; | |
324 | // if (r->TestBit(TParameter<T>::kFirst)) value = r->GetVal(); | |
325 | // else value = r->GetUniqueID(); | |
326 | value = r->GetVal(); | |
327 | if (!r->TestBit(BIT(19))) { | |
328 | TObject* oc = GetObject(p, "count", false); | |
329 | if (oc) { | |
330 | TParameter<int>* pc = static_cast<TParameter<int>*>(oc); | |
331 | int cnt = pc->GetVal(); | |
332 | value /= cnt; | |
333 | } | |
334 | else | |
335 | value = r->GetUniqueID(); | |
336 | } | |
337 | // value = r->GetUniqueID(); | |
4fdca35c | 338 | return true; |
339 | } | |
340 | ||
a19faec0 | 341 | //___________________________________________________________________ |
342 | /** | |
343 | * Get a Short_t parameter value | |
344 | * | |
345 | * @param c Parent collection | |
346 | * @param name Name of parameter | |
347 | * @param value On return the value | |
348 | * @param verb If true, complain if not found | |
349 | */ | |
350 | static Bool_t GetParameter(const TObject* c, | |
351 | const TString& name, | |
352 | Short_t& value, | |
353 | Bool_t verb=true) | |
354 | { | |
355 | int v; | |
356 | Bool_t r = DoGetParameter(GetObject(c, name, verb), c, v); | |
357 | value = v; | |
358 | return r; | |
359 | } | |
2955f67c | 360 | //___________________________________________________________________ |
361 | /** | |
362 | * Get a UShort_t parameter value | |
363 | * | |
364 | * @param c Parent collection | |
365 | * @param name Name of parameter | |
366 | * @param value On return the value | |
367 | * @param verb If true, complain if not found | |
368 | */ | |
fba5d22d | 369 | static Bool_t GetParameter(const TObject* c, |
370 | const TString& name, | |
371 | UShort_t& value, | |
372 | Bool_t verb=true) | |
2955f67c | 373 | { |
4fdca35c | 374 | int v; |
375 | Bool_t r = DoGetParameter(GetObject(c, name, verb), c, v); | |
376 | value = v; | |
377 | return r; | |
378 | } | |
fba5d22d | 379 | //___________________________________________________________________ |
380 | /** | |
a19faec0 | 381 | * Get a ULong_t parameter value |
fba5d22d | 382 | * |
383 | * @param c Parent collection | |
384 | * @param name Name of parameter | |
385 | * @param value On return the value | |
386 | * @param verb If true, complain if not found | |
387 | */ | |
388 | static Bool_t GetParameter(const TObject* c, | |
389 | const TString& name, | |
390 | ULong_t& value, | |
391 | Bool_t verb=true) | |
4fdca35c | 392 | { |
fba5d22d | 393 | Long_t v; |
394 | Bool_t r = DoGetParameter(GetObject(c, name, verb), c, v); | |
4fdca35c | 395 | value = v; |
396 | return r; | |
2955f67c | 397 | } |
398 | //_____________________________________________________________________ | |
399 | /** | |
400 | * Get a Int_t parameter value | |
401 | * | |
402 | * @param c Parent collection | |
403 | * @param name Name of parameter | |
404 | * @param value On return the value | |
405 | * @param verb If true, complain if not found | |
406 | */ | |
fba5d22d | 407 | static Bool_t GetParameter(const TObject* c, |
408 | const TString& name, | |
409 | Int_t& value, | |
410 | Bool_t verb=true) | |
4fdca35c | 411 | { |
412 | return DoGetParameter(GetObject(c, name, verb), c, value); | |
2955f67c | 413 | } |
414 | //_____________________________________________________________________ | |
415 | /** | |
416 | * Get a Double_t parameter value | |
417 | * | |
418 | * @param c Parent collection | |
419 | * @param name Name of parameter | |
420 | * @param value On return the value | |
421 | * @param verb If true, complain if not found | |
422 | */ | |
fba5d22d | 423 | static Bool_t GetParameter(const TObject* c, |
4fdca35c | 424 | const TString& name, |
425 | Double_t& value, | |
426 | Bool_t verb=true); | |
2955f67c | 427 | //_____________________________________________________________________ |
428 | /** | |
429 | * Get a Bool_t parameter value | |
430 | * | |
431 | * @param c Parent collection | |
432 | * @param name Name of parameter | |
433 | * @param value On return the value | |
434 | * @param verb If true, complain if not found | |
435 | */ | |
fba5d22d | 436 | static Bool_t GetParameter(const TObject* c, |
4fdca35c | 437 | const TString& name, |
438 | Bool_t& value, | |
439 | Bool_t verb=true) | |
440 | { | |
441 | return DoGetParameter(GetObject(c, name, verb), c, value); | |
2955f67c | 442 | } |
443 | //____________________________________________________________________ | |
444 | /** | |
445 | * Find a collection in another collection | |
446 | * | |
447 | * @param parent Parent collection | |
448 | * @param name Name of the collection | |
449 | * @param verb If true and not found, complain | |
450 | * | |
451 | * @return pointer to collection on success, otherwise null | |
452 | */ | |
fba5d22d | 453 | static TCollection* GetCollection(const TObject* parent, |
2955f67c | 454 | const TString& name, |
455 | Bool_t verb=true) | |
456 | { | |
fba5d22d | 457 | return DoGetObject<TCollection>(GetObject(parent, name, verb), parent); |
2955f67c | 458 | } |
459 | //____________________________________________________________________ | |
460 | /** | |
fba5d22d | 461 | * Check a 1D histogram object from a parent |
2955f67c | 462 | * |
c8b1a7db | 463 | * @param parent Parent collection |
464 | * @param name Name of histogram | |
465 | * @param verb Possibly be verbose | |
2955f67c | 466 | * |
467 | * @return pointer or null | |
468 | */ | |
fba5d22d | 469 | static TH1* GetH1(const TObject* parent, |
2955f67c | 470 | const TString& name, |
471 | Bool_t verb=true) | |
472 | { | |
fba5d22d | 473 | return DoGetObject<TH1>(GetObject(parent, name, verb), parent); |
2955f67c | 474 | } |
475 | //____________________________________________________________________ | |
476 | /** | |
477 | * Get a 2D histogram from a collection | |
478 | * | |
479 | * @param parent Parent collection | |
480 | * @param name Name of histogram | |
481 | * @param verb If true and not found, complain | |
482 | * | |
483 | * @return pointer or null | |
484 | */ | |
fba5d22d | 485 | static TH2* GetH2(const TObject* parent, |
4fdca35c | 486 | const TString& name, |
487 | Bool_t verb=true) | |
488 | { | |
fba5d22d | 489 | return DoGetObject<TH2>(GetObject(parent, name, verb), parent); |
2955f67c | 490 | } |
8449e3e0 | 491 | //____________________________________________________________________ |
492 | /** | |
493 | * Get a 2D histogram from a collection | |
494 | * | |
495 | * @param parent Parent collection | |
496 | * @param name Name of histogram | |
497 | * @param verb If true and not found, complain | |
498 | * | |
499 | * @return pointer or null | |
500 | */ | |
501 | static TH3* GetH3(const TCollection* parent, | |
502 | const TString& name, | |
503 | Bool_t verb=true) | |
504 | { | |
505 | // Info("GetH2", "Getting 2D histogram of %s from %p", name.Data(), c); | |
506 | // --- Find the object ------------------------------------------- | |
fba5d22d | 507 | return DoGetObject<TH3>(GetObject(parent, name, verb), parent); |
8449e3e0 | 508 | } |
2955f67c | 509 | //__________________________________________________________________ |
510 | /** | |
511 | * Get a histogram stack from a collection | |
512 | * | |
513 | * @param parent Parent collection | |
514 | * @param name Name of histogram | |
fba5d22d | 515 | * @param sub If set, fill from sub-component |
2955f67c | 516 | * @param verb If true and not found, complain |
517 | * | |
518 | * @return pointer or null | |
519 | */ | |
fba5d22d | 520 | static THStack* GetStack(const TObject* parent, |
521 | const TString& name, | |
522 | const char* sub=0, | |
523 | Bool_t verb=true) | |
4fdca35c | 524 | { |
fba5d22d | 525 | THStack* stack = DoGetObject<THStack>(GetObject(parent,name,verb),parent); |
526 | if (!stack) return 0; | |
2955f67c | 527 | if (sub == 0) return stack; |
528 | ||
529 | if (stack->GetHists()->GetEntries() <= 0 ||stack->GetMaximum() < 1) { | |
530 | // Info("GetStack", "No entries in %s", name.Data()); | |
531 | stack->GetHists()->Delete(); | |
7095962e | 532 | const char** ptr = GetRingNames(false); |
2955f67c | 533 | while (*ptr) { |
534 | TCollection* sc = GetCollection(parent, *ptr, true); | |
535 | if (!sc) { ptr++; continue; } | |
536 | ||
537 | TObject* obj = GetObject(sc, sub); | |
538 | if (!obj) { | |
539 | continue; | |
540 | ptr++; | |
541 | } | |
542 | ||
543 | if (obj->IsA()->InheritsFrom(TH2::Class())) { | |
544 | TH2* h = static_cast<TH2*>(obj); | |
545 | TH1* p = h->ProjectionX(*ptr, 1, h->GetNbinsY(), "e"); | |
546 | p->Scale(1., "width"); | |
547 | p->SetTitle(*ptr); | |
548 | p->SetDirectory(0); | |
549 | stack->Add(p); | |
550 | } | |
551 | else if (obj->IsA()->InheritsFrom(TH1::Class())) { | |
552 | TH1* hh = static_cast<TH1*>(obj); | |
553 | hh->SetTitle(*ptr); | |
554 | stack->Add(hh); | |
555 | } | |
556 | ptr++; | |
557 | } | |
558 | } | |
559 | // --- Return the collection ------------------------------------- | |
560 | return stack; | |
561 | } | |
562 | //____________________________________________________________________ | |
563 | /** | |
564 | * Clear canvas | |
565 | * | |
566 | */ | |
567 | void ClearCanvas() | |
568 | { | |
06963733 | 569 | if (fTop) { |
570 | fTop->Clear(); | |
571 | fTop->SetNumber(1); | |
572 | fTop->SetFillColor(kBlue-5); | |
573 | fTop->SetBorderSize(0); | |
574 | fTop->SetBorderMode(0); | |
575 | } | |
2955f67c | 576 | |
577 | fBody->Clear(); | |
578 | fBody->SetNumber(2); | |
579 | fBody->SetFillColor(0); | |
580 | fBody->SetFillStyle(0); | |
581 | fBody->SetBorderSize(0); | |
582 | fBody->SetBorderMode(0); | |
583 | fBody->SetTopMargin(0.01); | |
584 | fBody->SetLeftMargin(0.10); | |
585 | fBody->SetRightMargin(0.01); | |
586 | fBody->SetBottomMargin(0.10); | |
587 | ||
588 | fRingMap[0] = 0; | |
589 | fRingMap[1] = 0; | |
590 | fRingMap[2] = 0; | |
591 | fRingMap[3] = 0; | |
592 | fRingMap[4] = 0; | |
593 | fRingMap[5] = 0; | |
594 | ||
595 | fCanvas->cd(); | |
596 | } | |
597 | //____________________________________________________________________ | |
598 | /** | |
599 | * Create a canvas | |
600 | * | |
c8b1a7db | 601 | * @param pname Name of PDF file to make |
602 | * @param landscape If true, print in landscape | |
603 | * @param pdf Make PDF | |
33438b4c | 604 | * |
2955f67c | 605 | * @return Created canvas |
606 | */ | |
8449e3e0 | 607 | void CreateCanvas(const TString& pname, |
608 | Bool_t landscape=false, | |
06963733 | 609 | Bool_t pdf=true, |
610 | Bool_t useTop=true) | |
2955f67c | 611 | { |
612 | // Info("CreateCanvas", "Creating canvas"); | |
613 | fLandscape = landscape; | |
8449e3e0 | 614 | fPDF = pdf; |
2955f67c | 615 | Int_t height = 1000; |
616 | Int_t width = height / TMath::Sqrt(2); | |
617 | if (fLandscape) { | |
618 | Int_t tmp = height; | |
619 | height = width; | |
620 | width = tmp; | |
621 | } | |
622 | fCanvas = new TCanvas("c", pname.Data(), width, height); | |
623 | fCanvas->SetFillColor(0); | |
624 | fCanvas->SetBorderSize(0); | |
625 | fCanvas->SetBorderMode(0); | |
8449e3e0 | 626 | if (fPDF) |
627 | fCanvas->Print(Form("%s[", pname.Data()), | |
628 | Form("pdf %s", fLandscape ? "Landscape" : "")); | |
2955f67c | 629 | fCanvas->SetLeftMargin(.1); |
630 | fCanvas->SetRightMargin(.05); | |
631 | fCanvas->SetBottomMargin(.1); | |
632 | fCanvas->SetTopMargin(.05); | |
633 | ||
634 | gStyle->SetOptStat(0); | |
635 | gStyle->SetTitleColor(0); | |
636 | gStyle->SetTitleStyle(0); | |
637 | gStyle->SetTitleBorderSize(0); | |
638 | gStyle->SetTitleX(.5); | |
639 | gStyle->SetTitleY(1); | |
640 | gStyle->SetTitleW(.8); | |
641 | gStyle->SetTitleH(.09); | |
642 | gStyle->SetFrameFillColor(kWhite); | |
643 | gStyle->SetFrameBorderSize(1); | |
644 | gStyle->SetFrameBorderMode(1); | |
645 | gStyle->SetPalette(1); | |
646 | ||
06963733 | 647 | Float_t dy = useTop ? .05 : 0; |
648 | if (useTop) { | |
649 | fTop = new TPad("top", "Top", 0, 1-dy, 1, 1, 0, 0); | |
650 | fTop->SetNumber(1); | |
651 | fTop->SetFillColor(kBlue-5); | |
652 | fTop->SetBorderSize(0); | |
653 | fTop->SetBorderMode(0); | |
654 | fCanvas->cd(); | |
655 | fTop->Draw(); | |
656 | } | |
657 | ||
2955f67c | 658 | fBody = new TPad("body", "Body", 0, 0, 1, 1-dy, 0, 0); |
659 | fBody->SetNumber(2); | |
660 | fBody->SetFillColor(0); | |
661 | fBody->SetFillStyle(0); | |
662 | fBody->SetBorderSize(0); | |
663 | fBody->SetBorderMode(0); | |
664 | fCanvas->cd(); | |
665 | fBody->Draw(); | |
666 | ||
667 | fHeader = new TLatex(.5, .5, "Title"); | |
668 | fHeader->SetNDC(); | |
669 | fHeader->SetTextAlign(22); | |
670 | fHeader->SetTextSize(.7); | |
671 | fHeader->SetTextColor(kWhite); | |
672 | fHeader->SetTextFont(62); | |
673 | ||
674 | Double_t x1 = .1; | |
675 | Double_t x2 = .6; | |
676 | Double_t y = .8; | |
677 | Double_t s = fLandscape ? 0.08 : 0.05; | |
678 | fParName = new TLatex(x1, y, ""); | |
679 | fParName->SetTextAlign(13); | |
680 | fParName->SetNDC(); | |
681 | fParName->SetTextSize(s); | |
bfab35d9 | 682 | fParName->SetTextFont(62); |
2955f67c | 683 | |
684 | fParVal = new TLatex(x2, y, ""); | |
685 | fParVal->SetTextAlign(13); | |
686 | fParVal->SetNDC(); | |
687 | fParVal->SetTextSize(s); | |
bfab35d9 | 688 | fParVal->SetTextFont(42); |
2955f67c | 689 | |
690 | fCanvas->cd(); | |
691 | } | |
692 | ||
693 | //____________________________________________________________________ | |
694 | /** | |
695 | * Close the PDF | |
696 | * | |
2955f67c | 697 | */ |
698 | void CloseCanvas() | |
699 | { | |
700 | // Info("CloseCanvas", "Closing canvas"); | |
701 | // ClearCanvas(); | |
77f97e3f CHC |
702 | if (fPDF && fCanvas) { |
703 | // Printf("Closing canvas with last title %s", fLastTitle.Data()); | |
8449e3e0 | 704 | fCanvas->Print(Form("%s]", fCanvas->GetTitle()), |
77f97e3f CHC |
705 | Form("pdf %s Title:%s", |
706 | fLandscape ? "Landscape" : "", | |
707 | fLastTitle.Data())); | |
708 | } | |
8449e3e0 | 709 | if (fCanvas) |
710 | fCanvas->Close(); | |
711 | fCanvas = 0; | |
2955f67c | 712 | } |
713 | ||
714 | //__________________________________________________________________ | |
715 | /** | |
716 | * Print the canvas | |
717 | * | |
718 | * @param title Title | |
719 | * @param size Size of text | |
720 | */ | |
721 | void PrintCanvas(const TString& title, Float_t size=.7) | |
722 | { | |
06963733 | 723 | if (fTop) { |
724 | fTop->cd(); | |
725 | fHeader->SetTextSize(size); | |
726 | fHeader->DrawLatex(.5,.5,title); | |
727 | } | |
2955f67c | 728 | |
729 | fCanvas->Modified(); | |
730 | fCanvas->Update(); | |
731 | fCanvas->cd(); | |
732 | ||
8449e3e0 | 733 | if (fPDF) { |
70849dc0 | 734 | TString tit; |
735 | tit.Form("pdf %s Title:%s", fLandscape ? "Landscape" : "", | |
736 | title.Data()); | |
737 | ||
738 | #ifdef DEBUG | |
739 | Info("PrintCanvas", "Printing to %s (%s)", | |
740 | fCanvas->GetTitle(), tit.Data()); | |
741 | #else | |
8449e3e0 | 742 | gSystem->RedirectOutput("/dev/null"); |
70849dc0 | 743 | #endif |
8449e3e0 | 744 | fCanvas->Print(fCanvas->GetTitle(), tit); |
70849dc0 | 745 | #ifndef DEBUG |
8449e3e0 | 746 | gSystem->RedirectOutput(0); |
70849dc0 | 747 | #endif |
77f97e3f | 748 | fLastTitle = title; |
8449e3e0 | 749 | Pause(); |
70849dc0 | 750 | |
8449e3e0 | 751 | ClearCanvas(); |
752 | } | |
2955f67c | 753 | } |
754 | //__________________________________________________________________ | |
755 | /** | |
756 | * Make a chapter page | |
757 | * | |
758 | * @param title Title | |
759 | */ | |
760 | void MakeChapter(const TString& title) | |
761 | { | |
762 | fBody->cd(); | |
763 | ||
764 | TLatex* ltx = new TLatex(.5, .5, title); | |
765 | ltx->SetNDC(); | |
766 | ltx->SetTextAlign(22); | |
767 | ltx->Draw(); | |
768 | ||
769 | PrintCanvas(title); | |
770 | } | |
771 | //__________________________________________________________________ | |
772 | /** | |
773 | * Draw an object in pad | |
774 | * | |
775 | * @param c PArent pad | |
776 | * @param padNo Sub-pad number (0 is self) | |
777 | * @param h Object to draw | |
778 | * @param opts Options | |
779 | * @param flags Flags | |
c8b1a7db | 780 | * @param title Title on plot |
a19faec0 | 781 | * |
782 | * @return Drawn object - if any | |
2955f67c | 783 | */ |
a19faec0 | 784 | TObject* DrawInPad(TVirtualPad* c, |
785 | Int_t padNo, | |
786 | TObject* h, | |
787 | Option_t* opts="", | |
788 | UInt_t flags=0x0, | |
789 | const char* title="") | |
2955f67c | 790 | { |
791 | TVirtualPad* p = c->GetPad(padNo); | |
792 | if (!p) { | |
793 | Warning("DrawInPad", "Pad # %d not found in %s", padNo, c->GetName()); | |
a19faec0 | 794 | return 0; |
2955f67c | 795 | } |
a19faec0 | 796 | return DrawInPad(p, h, opts, flags, title); |
2955f67c | 797 | } |
c8b1a7db | 798 | /** |
799 | * Draw a clone of an object | |
800 | * | |
801 | * @param o Object | |
802 | * @param options Draw options | |
803 | * @param title Title of object | |
a19faec0 | 804 | * |
805 | * @return Drawn object - if any | |
c8b1a7db | 806 | */ |
a19faec0 | 807 | virtual TObject* DrawObjClone(TObject* o, Option_t* options, |
808 | const char* title) | |
079fd669 | 809 | { |
810 | if (o->IsA()->InheritsFrom(TH1::Class())) | |
a19faec0 | 811 | return DrawObjClone(static_cast<TH1*>(o), options, title); |
079fd669 | 812 | else if (o->IsA()->InheritsFrom(THStack::Class())) |
a19faec0 | 813 | return DrawObjClone(static_cast<THStack*>(o), options, title); |
77f97e3f | 814 | else if (o->IsA()->InheritsFrom(TGraph::Class())) |
a19faec0 | 815 | return o->DrawClone(options); |
079fd669 | 816 | else |
817 | o->Draw(options); | |
a19faec0 | 818 | return o; |
079fd669 | 819 | } |
c8b1a7db | 820 | /** |
821 | * Draw an object clone | |
822 | * | |
823 | * @param o Stack object | |
824 | * @param options Draw options | |
825 | * @param title Title on plot | |
a19faec0 | 826 | * |
827 | * @return Drawn object - if any | |
c8b1a7db | 828 | */ |
a19faec0 | 829 | virtual TObject* DrawObjClone(THStack* o, Option_t* options, |
830 | const char* title) | |
079fd669 | 831 | { |
832 | // THStack* tmp = static_cast<THStack*>(o->Clone()); | |
833 | o->Draw(options); | |
834 | if (title && title[0] != '\0') o->GetHistogram()->SetTitle(title); | |
b767da2c | 835 | TAxis* xAxis = o->GetXaxis(); |
77f97e3f CHC |
836 | if (!xAxis) { |
837 | Warning("DrawObjClone", "No X-axis for drawn stack %s", o->GetName()); | |
a19faec0 | 838 | return o; |
77f97e3f | 839 | } |
b767da2c | 840 | TH1* h = 0; |
841 | Int_t nBins = xAxis->GetNbins(); | |
842 | Double_t xMin = xAxis->GetXmin(); | |
843 | Double_t xMax = xAxis->GetXmax(); | |
844 | TIter next(o->GetHists()); | |
845 | while ((h = static_cast<TH1*>(next()))) { | |
846 | TAxis* a = h->GetXaxis(); | |
847 | nBins = TMath::Max(nBins, a->GetNbins()); | |
848 | xMin = TMath::Min(xMin, a->GetXmin()); | |
849 | xMax = TMath::Max(xMax, a->GetXmax()); | |
850 | } | |
851 | if (nBins != xAxis->GetNbins() || | |
852 | xMin != xAxis->GetXmin() || | |
853 | xMax != xAxis->GetXmax()) { | |
854 | xAxis->Set(nBins, xMin, xMax); | |
855 | o->GetHistogram()->Rebuild(); | |
856 | } | |
a19faec0 | 857 | return o; |
079fd669 | 858 | } |
c8b1a7db | 859 | /** |
860 | * Draw an object clone | |
861 | * | |
862 | * @param o Histogram | |
863 | * @param options Draw options | |
864 | * @param title Title on plot | |
a19faec0 | 865 | * |
866 | * @return Drawn object - if any | |
c8b1a7db | 867 | */ |
a19faec0 | 868 | virtual TObject* DrawObjClone(TH1* o, Option_t* options, const char* title) |
079fd669 | 869 | { |
870 | TH1* tmp = o->DrawCopy(options); | |
871 | if (title && title[0] != '\0') tmp->SetTitle(title); | |
a19faec0 | 872 | return tmp; |
079fd669 | 873 | } |
2955f67c | 874 | //__________________________________________________________________ |
70849dc0 | 875 | static void GetLegendPosition(UInt_t flags, TVirtualPad* p, |
876 | Double_t& x1, Double_t& y1, | |
877 | Double_t& x2, Double_t& y2) | |
878 | { | |
879 | UInt_t horiz = (flags & 0xF0000); | |
880 | UInt_t verti = (flags & 0xF000); | |
881 | Double_t eps = .01; | |
882 | Double_t dY = .4; | |
883 | Double_t dX = .4; | |
884 | Double_t yB = p->GetBottomMargin()+eps; | |
885 | Double_t yT = 1-p->GetTopMargin()-eps; | |
886 | Double_t xL = p->GetLeftMargin()+eps; | |
887 | Double_t xR = 1-p->GetRightMargin()-eps; | |
888 | switch (verti) { | |
889 | case kNorth: y1 = yT-dY; break; | |
890 | case kSouth: y1 = yB; break; | |
891 | case kMiddle: y1 = (yB+yT-dY)/2; break; | |
892 | } | |
893 | y2 = TMath::Min(y1 + dY, yT); | |
894 | ||
895 | switch (horiz) { | |
896 | case kEast: x1 = xL; break; | |
897 | case kWest: x1 = xR-dX; break; | |
898 | case kCenter: x1 = (xL+xR-dX)/2; break; | |
899 | } | |
900 | x2 = TMath::Min(x1 + dX, xR); | |
901 | } | |
95563506 | 902 | //__________________________________________________________________ |
903 | /** | |
904 | * Make a legend | |
905 | * | |
906 | * @param p | |
907 | * @param flags | |
908 | * @param autoFill | |
909 | * | |
910 | * @return | |
911 | */ | |
70849dc0 | 912 | TLegend* MakeLegend(TVirtualPad* p, UInt_t flags, Bool_t autoFill) |
913 | { | |
914 | Double_t x1 = fParVal->GetX(); | |
915 | Double_t y1 = fParVal->GetY(); | |
916 | Double_t x2 = 0; | |
917 | Double_t y2 = 0; | |
918 | GetLegendPosition(flags, p, x1, y1, x2, y2); | |
919 | ||
920 | //Printf("Legend at (%f,%f)x(%f,%f)", x1, y1, x2, y2); | |
921 | TLegend* l = 0; | |
922 | if (autoFill) l = p->BuildLegend(x1, y1, x2, y2); | |
923 | else l = new TLegend(x1, y1, x2, y2); | |
924 | l->SetFillColor(0); | |
925 | l->SetFillStyle(0); | |
926 | l->SetBorderSize(0); | |
927 | ||
928 | return l; | |
929 | } | |
930 | //__________________________________________________________________ | |
2955f67c | 931 | /** |
932 | * Draw an object in pad | |
933 | * | |
33438b4c | 934 | * @param p Pad |
2955f67c | 935 | * @param h Object to draw |
936 | * @param opts Options | |
937 | * @param flags Flags | |
c8b1a7db | 938 | * @param title Title on plot |
a19faec0 | 939 | * |
940 | * @return Drawn object - if any | |
2955f67c | 941 | */ |
a19faec0 | 942 | TObject* DrawInPad(TVirtualPad* p, |
943 | TObject* h, | |
944 | Option_t* opts="", | |
945 | UInt_t flags=0x0, | |
946 | const char* title="") | |
2955f67c | 947 | { |
948 | if (!p) { | |
949 | Warning("DrawInPad", "No pad specified"); | |
a19faec0 | 950 | return 0; |
2955f67c | 951 | } |
952 | p->cd(); | |
953 | // Info("DrawInPad", "Drawing in pad %p", p); | |
954 | // fBody->ls(); | |
bfab35d9 | 955 | if (flags & kLogx) p->SetLogx(); |
956 | if (flags & kLogy) p->SetLogy(); | |
957 | if (flags & kLogz) p->SetLogz(); | |
958 | if (flags & kGridx) p->SetGridx(); | |
959 | if (flags & kGridy) p->SetGridy(); | |
960 | // if (flags & kGridz) p->SetGridz(); | |
2955f67c | 961 | p->SetFillColor(0); |
962 | TString o(opts); | |
963 | if (o.Contains("colz", TString::kIgnoreCase)) | |
964 | p->SetRightMargin(0.15); | |
8449e3e0 | 965 | if (!h) { |
b767da2c | 966 | if (!(flags & kSilent)) |
967 | Warning("DrawInPad", "Nothing to draw in pad # %s", p->GetName()); | |
a19faec0 | 968 | return 0; |
8449e3e0 | 969 | } |
2955f67c | 970 | if (o.Contains("text", TString::kIgnoreCase)) { |
971 | TH1* hh = static_cast<TH1*>(h); | |
972 | hh->SetMaximum(1.1*hh->GetMaximum()); | |
973 | hh->SetMarkerSize(2); | |
974 | o.Append("30"); | |
975 | } | |
a19faec0 | 976 | TObject* ret = DrawObjClone(h, o, title); |
2955f67c | 977 | |
70849dc0 | 978 | if (flags & kLegend) { |
979 | MakeLegend(p, flags, true); | |
2955f67c | 980 | } |
981 | p->Modified(); | |
982 | p->Update(); | |
983 | p->cd(); | |
a19faec0 | 984 | |
985 | return ret; | |
2955f67c | 986 | } |
987 | //__________________________________________________________________ | |
988 | /** | |
989 | * Draw two graphs in the same frame, but with separate y-axis | |
990 | * | |
991 | * @param c Mother pad | |
992 | * @param padNo Sub-pad number (0 is self) | |
993 | * @param h1 First histogram | |
994 | * @param h2 Second histogram | |
995 | * @param opts Options | |
996 | * @param flags Flags | |
997 | */ | |
998 | void DrawTwoInPad(TVirtualPad* c, Int_t padNo, TH1* h1, TH1* h2, | |
999 | Option_t* opts="", UShort_t flags=0x0) | |
1000 | { | |
1001 | TVirtualPad* p = c->cd(padNo); | |
1002 | if (!p) { | |
1003 | Warning("DrawInPad", "Pad # %d not found in %s", padNo, c->GetName()); | |
1004 | return; | |
1005 | } | |
bfab35d9 | 1006 | if (flags & kLogx) p->SetLogx(); |
1007 | if (flags & kLogy) p->SetLogy(); | |
1008 | if (flags & kLogz) p->SetLogz(); | |
1009 | if (flags & kGridx) p->SetGridx(); | |
1010 | if (flags & kGridy) p->SetGridy(); | |
1011 | // if (flags & kGridz) p->SetGridz(); | |
2955f67c | 1012 | p->SetFillColor(0); |
1013 | ||
1014 | TString o(opts); | |
1015 | o.ToLower(); | |
1016 | TString fopts(o); | |
1017 | Bool_t e3 = o.Contains("e3"); | |
1018 | if (e3) { | |
1019 | fopts.ReplaceAll("e3", " same"); | |
1020 | } | |
1021 | ||
1022 | h1->GetYaxis()->SetLabelSize(0); | |
1023 | h1->GetYaxis()->SetTicks(""); | |
1024 | h1->GetYaxis()->SetNdivisions(0); | |
1025 | h1->DrawCopy(o); // First draw with opts | |
1026 | if (e3) h1->DrawCopy(fopts); | |
1027 | p->Update(); | |
1028 | ||
1029 | Double_t m1 = 1.05 * h1->GetMaximum(); | |
bfab35d9 | 1030 | if (m1 > 0) { |
1031 | TGaxis* a1 = new TGaxis(p->GetUxmin(), p->GetUymin(), | |
1032 | p->GetUxmin(), p->GetUymax(), | |
1033 | 0, m1, 510); | |
1034 | a1->SetLineColor(h1->GetLineColor()); | |
1035 | a1->Draw(); | |
1036 | } | |
1037 | ||
2955f67c | 1038 | o.Append(" same"); |
1039 | Double_t m2 = 1.1 * h2->GetMaximum(); | |
bfab35d9 | 1040 | Double_t scale = m2 > 0 ? m1 / m2 : 1; |
2955f67c | 1041 | h2->Scale(scale); |
1042 | h2->DrawCopy(o); | |
1043 | if (e3) h2->DrawCopy(fopts); | |
bfab35d9 | 1044 | |
1045 | if (m2 > 0) { | |
1046 | TGaxis* a2 = new TGaxis(p->GetUxmax(), p->GetUymin(), | |
1047 | p->GetUxmax(), p->GetUymax(), | |
1048 | 0, m2, 510, "+L"); | |
1049 | a2->SetLineColor(h2->GetLineColor()); | |
1050 | a2->Draw(); | |
1051 | } | |
1052 | if (flags& kLegend) { | |
70849dc0 | 1053 | MakeLegend(p, flags, true); |
2955f67c | 1054 | } |
1055 | p->Modified(); | |
1056 | p->Update(); | |
1057 | p->cd(); | |
1058 | } | |
1059 | ||
1060 | //____________________________________________________________________ | |
1061 | /** | |
1062 | * Draw a parameter. | |
1063 | * | |
1064 | * @param y Current y position. On return new y position | |
1065 | * @param name Parameter name | |
1066 | * @param value Parameter value | |
1067 | * @param size Optional text size | |
1068 | */ | |
1069 | void DrawParameter(Double_t& y, | |
1070 | const TString& name, | |
1071 | const TString& value, | |
1072 | Double_t size=0) | |
1073 | { | |
1074 | Double_t s = fParName->GetTextSize(); | |
1075 | Double_t t = fParVal->GetTextSize(); | |
1076 | if (name.IsNull() && value.IsNull()) return; | |
1077 | if (size > 0) { | |
1078 | fParName->SetTextSize(size); | |
1079 | fParVal->SetTextSize(size); | |
1080 | } | |
1081 | if (!name.IsNull()) | |
1082 | fParName->DrawLatex(fParName->GetX(), y, Form("%s:", name.Data())); | |
1083 | if (!value.IsNull()) | |
1084 | fParVal->DrawLatex(fParVal->GetX(), y, value.Data()); | |
1085 | if (!name.IsNull()) | |
1086 | y -= 1.2 * fParName->GetTextSize(); | |
1087 | else if (!value.IsNull()) | |
1088 | y -= 1.2 * fParVal->GetTextSize(); | |
1089 | ||
1090 | fParName->SetTextSize(s); | |
1091 | fParVal->SetTextSize(t); | |
1092 | } | |
a19faec0 | 1093 | template <typename T> |
1094 | void DrawTParameter(Double_t& y, | |
1095 | TList* list, | |
1096 | const TString& name) { | |
1097 | T value; | |
1098 | if (!GetParameter(list, name, value)) | |
1099 | return; | |
1100 | std::stringstream s; | |
1101 | s << std::boolalpha << value; | |
1102 | DrawParameter(y, name, s.str().c_str(), 0); | |
1103 | } | |
1104 | ||
1105 | //__________________________________________________________________ | |
1106 | /** | |
1107 | * Structure to hold a dived pad | |
1108 | */ | |
1109 | struct DividedPad { | |
1110 | TVirtualPad* fParent; | |
1111 | TVirtualPad** fSubs; | |
1112 | Bool_t fLandscape; | |
1113 | Int_t fNCol; | |
1114 | Int_t fNRow; | |
1115 | ||
1116 | DividedPad(TVirtualPad* p, Bool_t landscape, Int_t nCol, Int_t nRow) | |
1117 | : fParent(p), | |
1118 | fSubs(0), | |
1119 | fLandscape(landscape), | |
1120 | fNCol(landscape ? nRow : nCol), | |
1121 | fNRow(landscape ? nCol : nRow) | |
1122 | { | |
1123 | Int_t nPad = fNCol * fNRow; | |
1124 | fSubs = new TVirtualPad*[nPad]; | |
1125 | } | |
1126 | void Divide(Bool_t commonX, Bool_t commonY) { | |
1127 | if ((!commonX && !commonY) || (commonX && commonY)) { | |
1128 | // In case we have no common axis or do have both to be common, | |
1129 | // we directly use the TVirtualPad::Divide member function | |
1130 | fParent->Divide(fNCol, fNRow, commonX ? 0 : 0.01, commonY ? 0 : 0.01); | |
1131 | for (Int_t iPad = 1; iPad <= fNRow*fNCol; iPad++) | |
1132 | fSubs[iPad-1] = fParent->GetPad(iPad); | |
1133 | } | |
1134 | else if (commonX && !commonY) { | |
1135 | // We need to have common X axis, but not common Y axis. We first | |
1136 | // divide the pad in fNCol columns, and then each in to fNRow rows | |
1137 | fParent->Divide(fNCol, 1); | |
1138 | for (Int_t iCol = 1; iCol <= fNCol; iCol++) { | |
1139 | TVirtualPad* q = fParent->GetPad(iCol); | |
1140 | ||
1141 | if (fNRow == 1) { | |
1142 | fSubs[GetIdx(iCol,0)] = q; | |
1143 | continue; | |
1144 | } | |
1145 | ||
1146 | q->Divide(1,fNRow,0,0); | |
1147 | for (Int_t iRow = 1; iRow <= fNRow; iRow++) | |
1148 | fSubs[GetIdx(iCol, iRow)] = q->GetPad(iRow); | |
1149 | } | |
1150 | } | |
1151 | else if (!commonX && commonY) { | |
1152 | // We need to have common Y axis, but not common X axis. We first | |
1153 | // divide the pad in fNRow rows, and then each in to fNCol columns | |
1154 | fParent->Divide(1, fNRow); | |
1155 | for (Int_t iRow = 1; iRow <= fNRow; iRow++) { | |
1156 | TVirtualPad* q = fParent->GetPad(iRow); | |
1157 | ||
1158 | if (fNCol == 1) { | |
1159 | fSubs[GetIdx(0,iRow)] = q; | |
1160 | continue; | |
1161 | } | |
1162 | ||
1163 | q->Divide(fNCol,1,0,0); | |
1164 | for (Int_t iCol = 1; iCol <= fNCol; iCol++) | |
1165 | fSubs[GetIdx(iCol, iRow)] = q->GetPad(iCol); | |
1166 | } | |
1167 | } | |
1168 | } | |
1169 | virtual ~DividedPad() { if (fSubs) delete [] fSubs; } | |
1170 | /** | |
1171 | * Get a sub-pad | |
1172 | * | |
1173 | * @param idx Index (0 based) | |
1174 | * | |
1175 | * @return Pad or null | |
1176 | */ | |
1177 | TVirtualPad* GetPad(Int_t idx) { | |
1178 | if (!fSubs) { | |
1179 | ::Warning("GetPad","No sub-pads"); | |
1180 | return 0; | |
1181 | } | |
1182 | if (idx < 0 || idx >= (fNRow*fNCol)) { | |
1183 | ::Warning("GetPad", "Inded %d out of bounds [%d,%d]", | |
1184 | idx, 0, fNRow*fNCol); | |
1185 | return 0; | |
1186 | } | |
1187 | return fSubs[idx]; | |
1188 | } | |
1189 | Int_t GetIdx(Int_t iCol, Int_t iRow) const | |
1190 | { | |
1191 | return (iRow-1) * fNCol + iCol; | |
1192 | } | |
1193 | /** | |
1194 | * Get a sub-pad | |
1195 | * | |
1196 | * @param iRow Row number (1-based) | |
1197 | * @param iCol Column number (1-based) | |
1198 | * | |
1199 | * @return Pad or null | |
1200 | */ | |
1201 | TVirtualPad* GetPad(Int_t iCol, Int_t iRow) { | |
1202 | if (iRow < 0 || iRow > fNRow) return 0; | |
1203 | if (iCol < 0 || iRow > fNCol) return 0; | |
1204 | return GetPad(GetIdx(iCol, iRow)); | |
1205 | } | |
1206 | }; | |
1207 | ||
2955f67c | 1208 | //__________________________________________________________________ |
1209 | void DivideForRings(Bool_t commonX, Bool_t commonY) | |
1210 | { | |
1211 | // | |
1212 | // Divide canvas for rings | |
1213 | // | |
1214 | if ((!commonX && !commonY) || | |
1215 | (commonX && commonY)) { | |
1216 | // Portrait: | |
1217 | // +----------+----------+ | |
1218 | // | 1: FMD1i | 2: Free | | |
1219 | // +----------+----------+ | |
1220 | // | 3: FMD2i | 4: FMD2o | | |
1221 | // +----------+----------+ | |
1222 | // | 5: FMD3i | 6: FMD3o | | |
1223 | // +----------+----------+ | |
1224 | // | |
1225 | // Landscape: | |
1226 | // +----------+----------+----------+ | |
1227 | // | 1: FMD1i | 2: FMD2i | 3: FMD3i | | |
1228 | // +----------+----------+----------+ | |
1229 | // | 4: Free | 5: FMD2o | 6: FMD3o | | |
1230 | // +----------+----------+----------+ | |
1231 | // | |
1232 | fBody->Divide(fLandscape ? 3 : 2, fLandscape ? 2 : 3, | |
1233 | commonX ? 0 : 0.01, commonY ? 0 : 0.01); | |
1234 | fRingMap[0] = fBody->GetPad(1); // FMD1i; | |
1235 | fRingMap[1] = fBody->GetPad(fLandscape ? 2 : 3); // FMD2i; | |
1236 | fRingMap[2] = fBody->GetPad(fLandscape ? 5 : 4); // FMD2o; | |
1237 | fRingMap[3] = fBody->GetPad(fLandscape ? 3 : 5); // FMD3i; | |
1238 | fRingMap[4] = fBody->GetPad(6); // FMD3o; | |
1239 | fRingMap[5] = fBody->GetPad(fLandscape ? 4 : 2); // Free | |
1240 | } | |
1241 | else if (commonX && !commonY) { | |
1242 | // Divide into two - left/right | |
1243 | // Portrait: | |
1244 | // +----------++----------+ | |
1245 | // | 1: FMD1i || 1: Free | | |
1246 | // +----------++----------+ | |
1247 | // | 2: FMD2i || 2: FMD2o | | |
1248 | // +----------++----------+ | |
1249 | // | 3: FMD3i || 3: FMD3o | | |
1250 | // +----------++----------+ | |
1251 | // | |
1252 | // Landscape: | |
1253 | // +----------++----------++----------+ | |
1254 | // | 1: FMD1i || 1: FMD2i || 1: FMD3i | | |
1255 | // +----------++----------++----------+ | |
1256 | // | 2: Free || 2: FMD2o || 2: FMD3o | | |
1257 | // +----------++----------++----------+ | |
1258 | // | |
1259 | fBody->Divide(fLandscape ? 3 : 2, 1); | |
1260 | TVirtualPad* left = fBody->cd(1); | |
1261 | left->Divide(fLandscape ? 2 : 3); | |
1262 | TVirtualPad* middle = fBody->cd(2); | |
1263 | middle->Divide(fLandscape ? 2 : 3); | |
1264 | ||
1265 | Info("left","%p",left); left->ls(); | |
1266 | Info("middle","%p",middle); middle->ls(); | |
1267 | ||
1268 | fRingMap[0] = left->GetPad(1); // FMD1i; | |
1269 | if (!fLandscape) { | |
1270 | fRingMap[1] = left->GetPad(2); // FMD2i | |
1271 | fRingMap[2] = middle->GetPad(2); // FMD2o | |
1272 | fRingMap[3] = left->GetPad(3); // FMD3i | |
1273 | fRingMap[4] = middle->GetPad(3); // FMD3o | |
1274 | fRingMap[5] = middle->GetPad(1); // Free | |
1275 | } | |
1276 | else { | |
1277 | TVirtualPad* right = fBody->cd(3); | |
1278 | right->Divide(fLandscape ? 2 : 3); | |
1279 | fRingMap[1] = middle->GetPad(1); // FMD2i | |
1280 | fRingMap[2] = middle->GetPad(2); // FMD2o | |
1281 | fRingMap[3] = right->GetPad(1); // FMD3i | |
1282 | fRingMap[4] = right->GetPad(2); // FMD3o | |
1283 | fRingMap[5] = left->GetPad(2); // Free | |
1284 | } | |
1285 | } | |
1286 | else { | |
1287 | // Divide into two - left/right | |
1288 | // Portrait: | |
1289 | // +----------+----------+ | |
1290 | // | 1: FMD1i | 2: Free | | |
1291 | // +----------+----------+ | |
1292 | // +----------+----------+ | |
1293 | // | 1: FMD2i | 2: FMD2o | | |
1294 | // +----------+----------+ | |
1295 | // +----------+----------+ | |
1296 | // | 1: FMD3i | 2: FMD3o | | |
1297 | // +----------+----------+ | |
1298 | // | |
1299 | // Landscape: | |
1300 | // +----------+----------+----------+ | |
1301 | // | 1: FMD1i | 2: FMD2i | 3: FMD3i | | |
1302 | // +----------+----------+----------+ | |
1303 | // +----------+----------+----------+ | |
1304 | // | 1: Free | 2: FMD2o | 3: FMD3o | | |
1305 | // +----------+----------+----------+ | |
1306 | // | |
1307 | fBody->Divide(1, fLandscape ? 2 : 3); | |
1308 | TVirtualPad* top = fBody->cd(1); | |
1309 | top->Divide(fLandscape ? 3 : 2); | |
1310 | TVirtualPad* middle = fBody->cd(2); | |
1311 | middle->Divide(fLandscape ? 3 : 2); | |
1312 | ||
1313 | fRingMap[0] = top->GetPad(1); // FMD1i; | |
1314 | if (!fLandscape) { | |
1315 | TVirtualPad* bottom = fBody->cd(2); | |
1316 | bottom->Divide(2); | |
1317 | ||
1318 | fRingMap[1] = middle->GetPad(1); // FMD2i | |
1319 | fRingMap[2] = middle->GetPad(2); // FMD2o | |
1320 | fRingMap[3] = bottom->GetPad(1); // FMD3i | |
1321 | fRingMap[4] = bottom->GetPad(2); // FMD3o | |
1322 | fRingMap[5] = top->GetPad(2); // Free | |
1323 | } | |
1324 | else { | |
1325 | fRingMap[1] = top->GetPad(2); // FMD2i | |
1326 | fRingMap[2] = middle->GetPad(2); // FMD2o | |
1327 | fRingMap[3] = top->GetPad(3); // FMD3i | |
1328 | fRingMap[4] = middle->GetPad(3); // FMD3o | |
1329 | fRingMap[5] = middle->GetPad(1); // Free | |
1330 | } | |
1331 | } | |
1332 | if (fRingMap[0]) fRingMap[0]->SetTitle("FMD1i"); | |
1333 | if (fRingMap[1]) fRingMap[1]->SetTitle("FMD2i"); | |
1334 | if (fRingMap[2]) fRingMap[2]->SetTitle("FMD2o"); | |
1335 | if (fRingMap[3]) fRingMap[3]->SetTitle("FMD3i"); | |
1336 | if (fRingMap[4]) fRingMap[4]->SetTitle("FMD3o"); | |
1337 | if (fRingMap[5]) fRingMap[5]->SetTitle("Other"); | |
1338 | } | |
1339 | //__________________________________________________________________ | |
1340 | TVirtualPad* RingPad(UShort_t d, Char_t r) const | |
1341 | { | |
1342 | Int_t idx = 0; | |
1343 | switch (d) { | |
1344 | case 0: idx = 5; break; | |
1345 | case 1: idx = 0; break; | |
1346 | case 2: idx = 1 + ((r == 'I' || r == 'i') ? 0 : 1); break; | |
1347 | case 3: idx = 3 + ((r == 'I' || r == 'i') ? 0 : 1); break; | |
1348 | default: return 0; | |
1349 | } | |
1350 | return fRingMap[idx]; | |
1351 | // return fBody->GetPad(no); | |
1352 | } | |
1353 | //__________________________________________________________________ | |
7095962e CHC |
1354 | TVirtualPad* RingPad(const char* name) const |
1355 | { | |
1356 | TString n(name); | |
1357 | Int_t idx = n.Index("FMD"); | |
1358 | if (n == kNPOS) return 0; | |
1359 | n.Remove(0, idx+3); | |
1360 | Int_t det = n.Atoi(); | |
1361 | n.Remove(0,1); | |
1362 | Char_t rng = n[0]; | |
1363 | return RingPad(det, rng); | |
1364 | } | |
1365 | //__________________________________________________________________ | |
2955f67c | 1366 | /** |
1367 | * Draw an object in pad | |
1368 | * | |
33438b4c | 1369 | * @param d Detector |
1370 | * @param r Ring | |
2955f67c | 1371 | * @param h Object to draw |
1372 | * @param opts Options | |
1373 | * @param flags Flags | |
c8b1a7db | 1374 | * @param title Title on plot |
2955f67c | 1375 | */ |
079fd669 | 1376 | void DrawInRingPad(UShort_t d, |
1377 | Char_t r, | |
1378 | TObject* h, | |
1379 | Option_t* opts="", | |
1380 | UShort_t flags=0x0, | |
1381 | const char* title="") | |
2955f67c | 1382 | { |
1383 | TVirtualPad* p = RingPad(d, r); | |
1384 | if (!p) { | |
1385 | Warning("DrawInRingPad", "No pad found for FMD%d%c", d, r); | |
1386 | return; | |
1387 | } | |
079fd669 | 1388 | DrawInPad(p, h, opts, flags, title); |
2955f67c | 1389 | } |
7095962e CHC |
1390 | /** |
1391 | * Draw object in a ring pad | |
1392 | * | |
1393 | * @param name Name of ring | |
1394 | * @param h Object to draw | |
1395 | * @param opts Options | |
1396 | * @param flags Flags | |
1397 | * @param title Possible new title | |
1398 | */ | |
1399 | void DrawInRingPad(const char* name, | |
1400 | TObject* h, | |
1401 | Option_t* opts="", | |
1402 | UShort_t flags=0x0, | |
1403 | const char* title="") | |
1404 | { | |
1405 | TVirtualPad* p = RingPad(name); | |
1406 | if (!p) { | |
1407 | Warning("DrawInRingPad", "No pad found for \"%s\"", name); | |
1408 | return; | |
1409 | } | |
1410 | DrawInPad(p, h, opts, flags, title); | |
1411 | } | |
1412 | /** | |
1413 | * Draw object in a ring pad. Which pad to draw in depends on the | |
1414 | * name or title of the drawn object (must contain the ring name as | |
1415 | * a sub-string). | |
1416 | * | |
1417 | * @param h Object to draw | |
1418 | * @param opts Options | |
1419 | * @param flags Flags | |
1420 | * @param title Possible new title | |
1421 | */ | |
1422 | void DrawInRingPad(TObject* h, | |
1423 | Option_t* opts="", | |
1424 | UShort_t flags=0x0, | |
1425 | const char* title="") | |
1426 | { | |
1427 | if (!h) return; | |
1428 | TVirtualPad* p = RingPad(h->GetName()); | |
1429 | if (!p) { | |
1430 | p = RingPad(h->GetTitle()); | |
1431 | if (!p) { | |
1432 | Warning("DrawInRingPad", "No pad found for %s/%s", | |
1433 | h->GetName(), h->GetTitle()); | |
1434 | return; | |
1435 | } | |
1436 | } | |
1437 | DrawInPad(p, h, opts, flags, title); | |
1438 | } | |
2955f67c | 1439 | |
1440 | ||
1441 | //__________________________________________________________________ | |
1442 | /** | |
1443 | * Pause after each plot | |
1444 | * | |
1445 | */ | |
1446 | void Pause() | |
1447 | { | |
1448 | if (!fPause) return; | |
1449 | printf("Press enter to continue"); | |
1450 | std::cin.get(); | |
1451 | } | |
a19faec0 | 1452 | static void CompileScript(const TString& name, |
1453 | const TString& sub, | |
1454 | const TString& check, | |
1455 | Bool_t force) | |
1456 | { | |
1457 | if (!check.IsNull() && gROOT->GetClass(check)) return; | |
2955f67c | 1458 | |
a19faec0 | 1459 | TString fwd =gSystem->ExpandPathName("$ALICE_ROOT/PWGLF/FORWARD/analysis2"); |
1460 | TString macPath(gROOT->GetMacroPath()); | |
1461 | TString incPath(gSystem->GetIncludePath()); | |
1462 | if (!macPath.Contains(fwd)) macPath.Append(Form(":%s", fwd.Data())); | |
1463 | if (!incPath.Contains(fwd)) gSystem->AddIncludePath(Form("-I%s", | |
1464 | fwd.Data())); | |
1465 | if (!sub.IsNull()) { | |
1466 | TObjArray* subs = sub.Tokenize(": "); | |
1467 | TObject* pSub = 0; | |
1468 | TIter iSub(subs); | |
1469 | while ((pSub = iSub())) { | |
1470 | TString subDir = gSystem->ConcatFileName(fwd, pSub->GetName()); | |
1471 | if (!macPath.Contains(subDir)) | |
1472 | macPath.Append(Form(":%s", subDir.Data())); | |
1473 | if (!incPath.Contains(subDir)) | |
1474 | gSystem->AddIncludePath(Form("-I%s", subDir.Data())); | |
1475 | } | |
1476 | } | |
d6cea8ac | 1477 | gROOT->SetMacroPath(macPath); |
a19faec0 | 1478 | gROOT->LoadMacro(Form("%s%s", name.Data(), (force ? "++g" : "+"))); |
a19faec0 | 1479 | } |
bfab35d9 | 1480 | //____________________________________________________________________ |
1481 | virtual void DrawEventInspector(TCollection* parent) | |
1482 | { | |
1483 | Info("DrawEventInspector", "Drawing event inspector"); | |
1484 | TCollection* c = GetCollection(parent, "fmdEventInspector"); | |
1485 | if (!c) return; | |
1486 | ||
fba5d22d | 1487 | UShort_t sys=0, sNN=0; |
1488 | Int_t field=0; | |
1489 | ULong_t runNo=0; | |
24338c03 | 1490 | Int_t lowFlux=0, nPileUp=0, ipMethod=0; |
1491 | ULong_t aliRev=0, aliBra=0; | |
1492 | Bool_t v0and=false; | |
bfab35d9 | 1493 | Double_t dPileUp=0.; |
1494 | Double_t y = .8; | |
1495 | ||
1496 | fBody->cd(); | |
1497 | ||
1498 | Double_t save = fParName->GetTextSize(); | |
1499 | fParName->SetTextSize(0.03); | |
1500 | fParVal->SetTextSize(0.03); | |
fba5d22d | 1501 | |
1502 | GetParameter(c, "sys", sys); | |
1503 | GetParameter(c, "sNN", sNN); | |
1504 | GetParameter(c, "field", field); | |
1505 | GetParameter(c, "runNo", runNo); | |
1506 | GetParameter(c, "lowFlux", lowFlux); | |
7c844559 | 1507 | GetParameter(c, "ipMethod", ipMethod, false); |
fba5d22d | 1508 | GetParameter(c, "v0and", v0and); |
1509 | GetParameter(c, "nPileUp", nPileUp); | |
1510 | GetParameter(c, "dPileup", dPileUp); | |
1511 | GetParameter(c, "alirootRev", aliRev); | |
1512 | GetParameter(c, "alirootBranch", aliBra); | |
1513 | ||
1514 | TString tS; SysString(sys, tS); DrawParameter(y, "System", tS); | |
1515 | TString tE; SNNString(sNN, tE); DrawParameter(y, "#sqrt{s_{NN}}", tE); | |
1516 | DrawParameter(y, "L3 B field", Form("%+2dkG", field)); | |
1517 | DrawParameter(y, "Run #", Form("%lu", runNo)); | |
1518 | DrawParameter(y, "Low flux cut", Form("%d", lowFlux)); | |
24338c03 | 1519 | TString sIpMeth("unknown"); |
1520 | switch(ipMethod) { | |
1521 | case 0: sIpMeth = "Normal"; break; | |
1522 | case 1: sIpMeth = "pA in 2012"; break; | |
1523 | case 2: sIpMeth = "pA in 2013"; break; | |
1524 | case 3: sIpMeth = "PWG-UD"; break; | |
1525 | case 4: sIpMeth = "Satellite"; break; | |
1526 | } | |
1527 | DrawParameter(y, "Use PWG-UD vertex", sIpMeth); | |
fba5d22d | 1528 | DrawParameter(y, "Use V0AND for NSD", (v0and ? "yes" : "no")); |
1529 | DrawParameter(y, "Least # of pile-up vertex", Form("%d", nPileUp)); | |
1530 | DrawParameter(y, "Least distance of pile-up vertex", | |
1531 | Form("%fcm", dPileUp)); | |
1532 | DrawParameter(y, "AliROOT", Form("%lu/0x%08lx", ULong_t(aliRev), | |
1533 | ULong_t(aliBra))); | |
bfab35d9 | 1534 | |
1535 | TH1* triggers = GetH1(c, "triggers"); | |
1536 | TH1* vertex = GetH1(c, "vertex", false); | |
1537 | Bool_t mc = (vertex != 0); | |
1538 | if (mc) { | |
1539 | Int_t nInelMC = vertex->GetEntries(); | |
1540 | Int_t nInel = triggers->GetBinContent(1); | |
1541 | Int_t nNSDMC = triggers->GetBinContent(11); | |
1542 | Int_t nNSD = triggers->GetBinContent(4); | |
1543 | DrawParameter(y, | |
1544 | Form("#varepsilon_{INEL} = #bf{%d/%d}", nInel, nInelMC), | |
1545 | Form("%5.3f", float(nInel)/nInelMC)); | |
1546 | DrawParameter(y, | |
1547 | Form("#varepsilon_{NSD} = #bf{%d/%d}", nNSD, nNSDMC), | |
1548 | Form("%5.3f", float(nNSD)/nNSDMC)); | |
1549 | } | |
1550 | ||
1551 | PrintCanvas("Event Inspector"); | |
1552 | fParName->SetTextSize(save); | |
1553 | fParVal->SetTextSize(save); | |
1554 | ||
77f97e3f CHC |
1555 | if (fLandscape) fBody->Divide(4,2); |
1556 | else fBody->Divide(2,4); | |
bfab35d9 | 1557 | |
1558 | TH1* nEventsTr = GetH1(c, "nEventsTr"); | |
1559 | TH1* nEventsTrVtx = GetH1(c, "nEventsTrVtx"); | |
1560 | TH1* nEventsAcc = GetH1(c, "nEventsAccepted"); | |
1561 | if (nEventsTr) nEventsTr->Rebin(2); | |
1562 | if (nEventsTrVtx) nEventsTrVtx->Rebin(2); | |
1563 | if (vertex) { | |
1564 | // vertex->Rebin(2); | |
1565 | vertex->SetFillColor(kMagenta+2); | |
1566 | } | |
fba5d22d | 1567 | DrawInPad(fBody, 1, nEventsTr, "", kLogy, |
079fd669 | 1568 | "Events w/trigger, trigger+vertex, accepted"); |
bfab35d9 | 1569 | if (vertex) DrawInPad(fBody, 1, vertex, "same"); |
1570 | DrawInPad(fBody, 1, nEventsTrVtx, "same"); | |
fba5d22d | 1571 | DrawInPad(fBody, 1, nEventsAcc, "same", kLegend); |
bfab35d9 | 1572 | |
1573 | ||
fba5d22d | 1574 | DrawInPad(fBody, 2, GetH2(c, "nEventsAcceptedXY"), "colz", kLogz); |
bfab35d9 | 1575 | DrawInPad(fBody, 3, triggers, "hist text"); |
1576 | if (GetH1(c, "trgStatus")) | |
1577 | DrawInPad(fBody, 4, GetH1(c, "trgStatus"), "hist text"); | |
1578 | else // Old one | |
fba5d22d | 1579 | DrawInPad(fBody, 4, GetH2(c, "triggerCorr"), "colz", kLogz); |
bfab35d9 | 1580 | DrawInPad(fBody, 5, GetH1(c, "status"), "hist text"); |
1581 | if (GetH1(c, "vtxStatus")) | |
1582 | DrawInPad(fBody, 6, GetH1(c, "vtxStatus"), "hist text"); | |
1583 | else // old | |
1584 | DrawInPad(fBody, 6, GetH1(c, "type"), "hist text"); | |
1585 | ||
1586 | TH1* cent = GetH1(c, "cent"); | |
f0c2bb64 | 1587 | if (cent) { |
bfab35d9 | 1588 | cent->Scale(1, "width"); |
77f97e3f | 1589 | DrawInPad(fBody, 7, cent, "", kLogy); |
f0c2bb64 | 1590 | } |
1591 | ||
7c844559 | 1592 | TH1* pileupStatus = GetH1(c, "pileupStatus", false); |
1593 | if (pileupStatus) DrawInPad(fBody, 8, pileupStatus, "hist text30"); | |
1594 | else { | |
1595 | TH2* centQual = GetH2(c, "centVsQuality"); | |
1596 | if (centQual) { | |
1597 | centQual->Scale(1, "width"); | |
1598 | DrawInPad(fBody, 8, centQual, "colz", kLogz); | |
1599 | } | |
bfab35d9 | 1600 | } |
1601 | ||
1602 | PrintCanvas("EventInspector - Histograms"); | |
1603 | ||
1604 | if (!mc) return; // not MC | |
1605 | ||
1606 | TH1* phiR = GetH1(c, "phiR"); | |
1607 | TH1* b = GetH1(c, "b"); | |
1608 | TH2* bVsNpart = GetH2(c, "bVsParticipants"); | |
1609 | TH2* bVsNbin = GetH2(c, "bVsBinary"); | |
1610 | TH2* bVsCent = GetH2(c, "bVsCentrality"); | |
1611 | TH2* vzComparison = GetH2(c, "vzComparison"); | |
1612 | TH2* centVsNpart = GetH2(c, "centralityVsParticipans");// Spelling! | |
1613 | TH2* centVsNbin = GetH2(c, "centralityVsBinary"); | |
1614 | ||
1615 | fBody->Divide(2,3); | |
1616 | ||
1617 | DrawInPad(fBody, 1, phiR); | |
fba5d22d | 1618 | DrawInPad(fBody, 2, vzComparison, "colz", kLogz); |
bfab35d9 | 1619 | DrawInPad(fBody, 3, b); |
1620 | ||
1621 | TProfile* nPartB = bVsNpart->ProfileX("nPartB",1,-1,"s"); | |
1622 | TProfile* nBinB = bVsNbin->ProfileX("nBinB",1,-1,"s"); | |
1623 | nPartB->SetMarkerColor(kBlue+2); | |
1624 | nPartB->SetMarkerStyle(20); | |
1625 | nPartB->SetLineColor(kBlue+2); | |
1626 | nPartB->SetFillColor(kBlue-10); | |
1627 | nPartB->SetFillStyle(1001); | |
1628 | nPartB->SetMarkerSize(0.7); | |
1629 | nBinB->SetMarkerColor(kRed+2); | |
1630 | nBinB->SetMarkerStyle(21); | |
1631 | nBinB->SetLineColor(kRed+2); | |
1632 | nBinB->SetFillColor(kRed-10); | |
1633 | nBinB->SetMarkerSize(0.7); | |
1634 | nBinB->SetFillStyle(1001); | |
1635 | ||
fba5d22d | 1636 | DrawTwoInPad(fBody, 4, nPartB, nBinB, "e3 p", kLegend); |
bfab35d9 | 1637 | |
fba5d22d | 1638 | DrawInPad(fBody, 5, bVsCent, "colz", kLogz); |
bfab35d9 | 1639 | |
1640 | TProfile* nPartC = centVsNpart->ProfileY("nPartC",1,-1,"s"); | |
1641 | TProfile* nBinC = centVsNbin->ProfileY("nBinC",1,-1,"s"); | |
1642 | nPartC->SetMarkerColor(kBlue+2); | |
1643 | nPartC->SetMarkerStyle(20); | |
1644 | nPartC->SetLineColor(kBlue+2); | |
1645 | nPartC->SetFillColor(kBlue-10); | |
1646 | nPartC->SetFillStyle(1001); | |
1647 | nPartC->SetMarkerSize(0.7); | |
1648 | nBinC->SetMarkerColor(kRed+2); | |
1649 | nBinC->SetMarkerStyle(21); | |
1650 | nBinC->SetLineColor(kRed+2); | |
1651 | nBinC->SetFillColor(kRed-10); | |
1652 | nBinC->SetMarkerSize(0.7); | |
1653 | nBinC->SetFillStyle(1001); | |
1654 | ||
fba5d22d | 1655 | DrawTwoInPad(fBody, 6, nPartC, nBinC, "e3 p", kLegend); |
bfab35d9 | 1656 | |
1657 | PrintCanvas("EventInspector - Monte-Carlo"); | |
1658 | } | |
1659 | //____________________________________________________________________ | |
24338c03 | 1660 | virtual void DrawESDFixer(TCollection* parent) |
1661 | { | |
1662 | Info("DrawESDFixer", "Drawing ESD fixer"); | |
1663 | TCollection* c = GetCollection(parent, "fmdESDFixer"); | |
1664 | if (!c) return; | |
1665 | ||
1666 | Int_t recoFactor = 0; | |
1667 | Bool_t recalcEta = false; | |
1668 | Bool_t invalidIsEmpty = false; | |
1669 | ||
1670 | fBody->cd(); | |
1671 | ||
1672 | Double_t save = fParName->GetTextSize(); | |
1673 | fParName->SetTextSize(0.05); | |
1674 | fParVal->SetTextSize(0.05); | |
1675 | ||
1676 | fBody->Divide(2,2); | |
1677 | fBody->cd(1); | |
1678 | ||
1679 | Double_t y = .8; | |
1680 | if (GetParameter(c, "recoFactor", recoFactor)) | |
1681 | DrawParameter(y, "Noise factor used in reco", | |
1682 | Form("%d (assumed)", recoFactor)); | |
1683 | if (GetParameter(c, "recalcEta", recalcEta)) | |
1684 | DrawParameter(y, "Recalculate #eta", | |
1685 | Form("%s", (recalcEta ? "yes" : "no"))); | |
1686 | if (GetParameter(c, "invalidIsEmpty", invalidIsEmpty)) | |
1687 | DrawParameter(y, "Assume invalid strips are empty", | |
1688 | Form("%s", (invalidIsEmpty ? "yes" : "no"))); | |
1689 | ||
1690 | TCollection* xd = GetCollection(c, "extraDead"); | |
1691 | if (xd) | |
1692 | DrawParameter(y, "# extra dead strips", | |
1693 | Form("%d", xd->GetEntries())); | |
1694 | ||
1695 | DrawInPad(fBody, 2, GetH1(c, "noiseChange"), "", kLogy); | |
1696 | DrawInPad(fBody, 3, GetH1(c, "etaChange"), "", kLogy); | |
1697 | DrawInPad(fBody, 4, GetH1(c, "deadChange"), "", kLogy); | |
1698 | ||
1699 | PrintCanvas("ESD Fixer"); | |
1700 | fParName->SetTextSize(save); | |
1701 | fParVal->SetTextSize(save); | |
1702 | } | |
1703 | //____________________________________________________________________ | |
eeb4f8c1 | 1704 | void DrawTrackDensity(TCollection* parent, |
1705 | const char* folderName="mcTrackDensity") | |
bfab35d9 | 1706 | { |
1707 | Info("DrawTrackDensity", "Drawing track density"); | |
1708 | ||
1709 | // --- MC -------------------------------------------------------- | |
eeb4f8c1 | 1710 | TCollection* mc = GetCollection(parent, folderName, false); |
bfab35d9 | 1711 | if (!mc) return; // Not MC |
1712 | ||
1713 | fBody->Divide(2,3); | |
fba5d22d | 1714 | DrawInPad(fBody, 1, GetH2(mc, "binFlow"), "colz", kLogz); |
1715 | DrawInPad(fBody, 2, GetH2(mc, "binFlowEta"), "colz", kLogz); | |
1716 | DrawInPad(fBody, 3, GetH2(mc, "binFlowPhi"), "colz", kLogz); | |
1717 | DrawInPad(fBody, 4, GetH1(mc, "nRefs"), "", kLogy, | |
81775aba | 1718 | "# of references"); |
1719 | DrawInPad(fBody, 4, GetH1(mc, "clusterRefs", false), "same"); | |
1720 | DrawInPad(fBody, 4, GetH1(mc, "clusterSize", false), "same"); | |
fba5d22d | 1721 | DrawInPad(fBody, 4, GetH1(mc, "nClusters", false), "same", kLegend); |
1722 | DrawInPad(fBody, 5, GetH2(mc, "clusterVsRefs", false),"colz", kLogz); | |
bfab35d9 | 1723 | |
1724 | PrintCanvas("Track density"); | |
1725 | } | |
2955f67c | 1726 | //__________________________________________________________________ |
1727 | TCanvas* fCanvas; // Our canvas | |
1728 | TPad* fTop; // Top part | |
1729 | TPad* fBody; // Body part | |
1730 | TLatex* fHeader; // Header text | |
1731 | TLatex* fParName; // Parameter name | |
1732 | TLatex* fParVal; // Parameter value | |
1733 | Bool_t fPause; // Whether to pause after drawing a canvas | |
1734 | Bool_t fLandscape; // Landscape or Portrait orientation | |
1735 | TVirtualPad** fRingMap; | |
8449e3e0 | 1736 | Bool_t fPDF; |
77f97e3f | 1737 | TString fLastTitle; |
2955f67c | 1738 | }; |
fba5d22d | 1739 | #if 0 |
1740 | template <> | |
4fdca35c | 1741 | inline Bool_t |
fba5d22d | 1742 | SummaryDrawer::DoGetParameter<Double_t>(TObject* o, const TObject* p, |
1743 | Double_t& value) | |
4fdca35c | 1744 | { |
fba5d22d | 1745 | TParameter<Double_t>* r = DoGetObject<TParameter<Double_t>(o, p); |
1746 | UInt_t i = o->GetUniqueID(); | |
1747 | Float_t v = *reinterpret_cast<Float_t*>(&i); | |
1748 | value = v; | |
1749 | return true; | |
4fdca35c | 1750 | } |
fba5d22d | 1751 | #endif |
4fdca35c | 1752 | inline Bool_t |
fba5d22d | 1753 | SummaryDrawer::GetParameter(const TObject* c, |
1754 | const TString& name, | |
1755 | Double_t& value, | |
1756 | Bool_t verb) | |
4fdca35c | 1757 | |
1758 | { | |
1759 | return DoGetParameter(GetObject(c, name, verb), c, value); | |
1760 | } | |
1761 | ||
2955f67c | 1762 | #endif |
fba5d22d | 1763 | // |
1764 | // EOF | |
1765 | // | |
2955f67c | 1766 |