Logo ROOT  
Reference Guide
TEveCaloData.cxx
Go to the documentation of this file.
1 // @(#)root/eve:$Id$
2 // Author: Matevz Tadel 2007
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #include "TEveCaloData.h"
13 #include "TEveCalo.h"
14 
15 #include "TGLSelectRecord.h"
16 
17 #include "TAxis.h"
18 #include "THStack.h"
19 #include "TH2.h"
20 #include "TMath.h"
21 #include "TList.h"
22 
23 #include <cassert>
24 #include <algorithm>
25 #include <set>
26 
27 /** \class TEveCaloData::CellGeom_t
28 \ingroup TEve
29 Cell geometry inner structure.
30 */
31 
32 ////////////////////////////////////////////////////////////////////////////////
33 /// Print member data.
34 
36 {
37  printf("%f, %f %f, %f \n", fEtaMin, fEtaMax, fPhiMin, fPhiMax);
38 }
39 
40 ////////////////////////////////////////////////////////////////////////////////
41 
43 {
44  fEtaMin = etaMin;
45  fEtaMax = etaMax;
46 
47  fPhiMin = phiMin;
48  fPhiMax = phiMax;
49 
50  // Complain if phi is out of [-2*pi, 2*pi] range.
51  if (fPhiMin < - TMath::TwoPi() || fPhiMin > TMath::TwoPi() ||
52  fPhiMax < - TMath::TwoPi() || fPhiMax > TMath::TwoPi())
53  {
54  ::Error("TEveCaloData::CellGeom_t::Configure", "phiMin and phiMax should be between -2*pi and 2*pi (min=%f, max=%f). RhoZ projection will be wrong.",
55  fPhiMin, fPhiMax);
56  }
57 
58  fThetaMin = EtaToTheta(fEtaMax);
59  fThetaMax = EtaToTheta(fEtaMin);
60 }
61 
62 /** \class TEveCaloData::CellData_t
63 \ingroup TEve
64 Cell data inner structure.
65 */
66 
67 ////////////////////////////////////////////////////////////////////////////////
68 /// Return energy value associated with the cell, usually Et.
69 /// If isEt is false it is transformed into energy E.
70 
72 {
73  if (isEt)
74  return fValue;
75  else
76  return TMath::Abs(fValue/TMath::Sin(Theta()));
77 }
78 
79 ////////////////////////////////////////////////////////////////////////////////
80 /// Print member data.
81 
83 {
84  printf("%f, %f %f, %f \n", fEtaMin, fEtaMax, fPhiMin, fPhiMax);
85 }
86 
87 ////////////////////////////////////////////////////////////////////////////////
88 
90 {
91  // printf("get val vec bin %d size %d\n", bin, fBinData.size());
92  if (fBinData[bin] == -1)
93  {
94  fBinData[bin] = fSliceData.size();
95 
96  for (Int_t i=0; i<fNSlices; i++)
97  fSliceData.push_back(0.f);
98  }
99 
100  return &fSliceData[fBinData[bin]];
101 }
102 
103 /** \class TEveCaloData
104 \ingroup TEve
105 A central manager for calorimeter event data. It provides a list of
106 cells within requested phi and eta range.
107 */
108 
110 
111 ////////////////////////////////////////////////////////////////////////////////
112 
113 TEveCaloData::TEveCaloData(const char* n, const char* t):
114  TEveElement(),
115  TNamed(n, t),
116 
117  fEtaAxis(0),
118  fPhiAxis(0),
119 
120  fWrapTwoPi(kTRUE),
121 
122  fMaxValEt(0),
123  fMaxValE(0),
124 
125  fEps(0)
126 {
127  // Constructor.
128 }
129 
130 ////////////////////////////////////////////////////////////////////////////////
131 /// Virtual method TEveElement::UnSelect.
132 /// Clear selected towers when deselected.
133 
135 {
136  fCellsSelected.clear();
137 }
138 
139 ////////////////////////////////////////////////////////////////////////////////
140 /// Virtual method TEveElement::UnHighlighted.
141 
143 {
144  fCellsHighlighted.clear();
145 }
146 
147 ////////////////////////////////////////////////////////////////////////////////
148 
150 {
151  if (fCellsHighlighted.empty()) return "";
152 
153  CellData_t cellData;
154 
155  Bool_t single = fCellsHighlighted.size() == 1;
156  Float_t sum = 0;
157  TString s;
158  for (vCellId_i i = fCellsHighlighted.begin(); i!=fCellsHighlighted.end(); ++i)
159  {
160  GetCellData(*i, cellData);
161 
162  s += TString::Format("%s %.2f (%.3f, %.3f)",
163  fSliceInfos[i->fSlice].fName.Data(), cellData.fValue,
164  cellData.Eta(), cellData.Phi());
165 
166  if (single) return s;
167  s += "\n";
168  sum += cellData.fValue;
169  }
170  s += TString::Format("Sum = %.2f", sum);
171  return s;
172 }
173 
174 ////////////////////////////////////////////////////////////////////////////////
175 /// Populate set impSelSet with derived / dependant elements.
176 ///
177 
179 {
180  for (List_ci i=fChildren.begin(); i!=fChildren.end(); ++i)
181  {
182  impSelSet.insert(*i);
183  }
184 }
185 
186 ////////////////////////////////////////////////////////////////////////////////
187 /// Print selected cells info.
188 
190 {
191  printf("%d Selected selected cells:\n", (Int_t)fCellsSelected.size());
192  CellData_t cellData;
193 
194  for (vCellId_i i = fCellsSelected.begin(); i != fCellsSelected.end(); ++i)
195  {
196  GetCellData(*i, cellData);
197  printf("Tower [%d] Slice [%d] Value [%.2f] ", i->fTower, i->fSlice, cellData.fValue);
198  printf("Eta:(%f, %f) Phi(%f, %f)\n", cellData.fEtaMin, cellData.fEtaMax, cellData.fPhiMin, cellData.fPhiMax);
199  }
200 }
201 
202 ////////////////////////////////////////////////////////////////////////////////
203 /// Process newly selected cells with given select-record.
204 /// Secondary-select status is set.
205 /// CellSelectionChanged() is called if needed.
206 
208 {
209  typedef std::set<CellId_t> sCellId_t;
210  typedef std::set<CellId_t>::iterator sCellId_i;
211 
212  struct helper
213  {
214  static void fill_cell_set(sCellId_t& cset, vCellId_t& cvec)
215  {
216  for (vCellId_i i = cvec.begin(); i != cvec.end(); ++i)
217  cset.insert(*i);
218  }
219  static void fill_cell_vec(vCellId_t& cvec, sCellId_t& cset)
220  {
221  for (sCellId_i i = cset.begin(); i != cset.end(); ++i)
222  cvec.push_back(*i);
223  }
224  };
225 
227 
228  if (cells.empty())
229  {
230  if (!sel_cells.empty())
231  {
232  cells.swap(sel_cells);
234  }
235  }
236  else
237  {
238  if (!sel_cells.empty())
239  {
240  if (rec.GetMultiple())
241  {
242  sCellId_t cs;
243  helper::fill_cell_set(cs, cells);
244  for (vCellId_i i = sel_cells.begin(); i != sel_cells.end(); ++i)
245  {
246  std::set<CellId_t>::iterator csi = cs.find(*i);
247  if (csi == cs.end())
248  cs.insert(*i);
249  else
250  cs.erase(csi);
251  }
252  cells.clear();
253  if (cs.empty())
254  {
256  }
257  else
258  {
259  helper::fill_cell_vec(cells, cs);
261  }
262  }
263  else
264  {
265  Bool_t differ = kFALSE;
266  if (cells.size() == sel_cells.size())
267  {
268  sCellId_t cs;
269  helper::fill_cell_set(cs, cells);
270  for (vCellId_i i = sel_cells.begin(); i != sel_cells.end(); ++i)
271  {
272  if (cs.find(*i) == cs.end())
273  {
274  differ = kTRUE;
275  break;
276  }
277  }
278  }
279  else
280  {
281  differ = kTRUE;
282  }
283  if (differ)
284  {
285  cells.swap(sel_cells);
287  }
288  }
289  }
290  else
291  {
292  if (!rec.GetMultiple())
293  {
294  cells.clear();
296  }
297  }
298  }
299 
301  {
303  }
304 }
305 
306 ////////////////////////////////////////////////////////////////////////////////
307 /// Set threshold for given slice.
308 
310 {
311  fSliceInfos[slice].fThreshold = val;
313 }
314 
315 ////////////////////////////////////////////////////////////////////////////////
316 /// Get threshold for given slice.
317 
319 {
320  return fSliceInfos[slice].fThreshold;
321 }
322 
323 ////////////////////////////////////////////////////////////////////////////////
324 /// Set color for given slice.
325 
327 {
328  fSliceInfos[slice].fColor = col;
329  for (List_ci i=fChildren.begin(); i!=fChildren.end(); ++i)
330  {
331  (*i)->AddStamp(TEveElement::kCBObjProps);
332  }
333 }
334 
335 ////////////////////////////////////////////////////////////////////////////////
336 /// Get color for given slice.
337 
339 {
340  return fSliceInfos[slice].fColor;
341 }
342 
343 ////////////////////////////////////////////////////////////////////////////////
344 /// Set transparency for given slice.
345 
347 {
348  fSliceInfos[slice].fTransparency = t;
349  for (List_ci i=fChildren.begin(); i!=fChildren.end(); ++i)
350  {
351  (*i)->AddStamp(TEveElement::kCBObjProps);
352  }
353 }
354 
355 ////////////////////////////////////////////////////////////////////////////////
356 /// Get transparency for given slice.
357 
359 {
360  return fSliceInfos[slice].fTransparency;
361 }
362 
363 ////////////////////////////////////////////////////////////////////////////////
364 /// Invalidate cell ids cache on back ptr references.
365 
367 {
368  TEveCaloViz* calo;
369  for (List_ci i=fChildren.begin(); i!=fChildren.end(); ++i)
370  {
371  calo = dynamic_cast<TEveCaloViz*>(*i);
372  calo->InvalidateCellIdCache();
373  calo->StampObjProps();
374  }
375 }
376 
377 ////////////////////////////////////////////////////////////////////////////////
378 /// Tell users (TEveCaloViz instances using this data) that data
379 /// has changed and they should update the limits/scales etc.
380 /// This is done by calling TEveCaloViz::DataChanged().
381 
383 {
384  TEveCaloViz* calo;
385  for (List_ci i=fChildren.begin(); i!=fChildren.end(); ++i)
386  {
387  calo = dynamic_cast<TEveCaloViz*>(*i);
388  calo->DataChanged();
389  calo->StampObjProps();
390  }
391 }
392 
393 ////////////////////////////////////////////////////////////////////////////////
394 /// Tell users (TEveCaloViz instances using this data) that cell selection
395 /// has changed and they should update selection cache if necessary.
396 /// This is done by calling TEveCaloViz::CellSelectionChanged().
397 
399 {
400  TEveCaloViz* calo;
401  for (List_ci i=fChildren.begin(); i!=fChildren.end(); ++i)
402  {
403  calo = dynamic_cast<TEveCaloViz*>(*i);
404  calo->CellSelectionChanged();
405  calo->StampColorSelection();
406  }
407 }
408 
409 ////////////////////////////////////////////////////////////////////////////////
410 
412 {
413  using namespace TMath;
414 
415  if (eta < 0)
416  return Pi() - 2*ATan(Exp(- Abs(eta)));
417  else
418  return 2*ATan(Exp(- Abs(eta)));
419 }
420 
421 
422 /** \class TEveCaloDataVec
423 \ingroup TEve
424 Calo data for universal cell geometry.
425 */
426 
428 
429 ////////////////////////////////////////////////////////////////////////////////
430 
432  TEveCaloData(),
433 
434  fTower(0),
435  fEtaMin( 1e3),
436  fEtaMax(-1e3),
437  fPhiMin( 1e3),
438  fPhiMax(-1e3)
439 {
440  // Constructor.
441 
442  fSliceInfos.assign(nslices, SliceInfo_t());
443 
444  fSliceVec.assign(nslices, std::vector<Float_t> ());
445 }
446 
447 ////////////////////////////////////////////////////////////////////////////////
448 /// Destructor.
449 
451 {
452  if (fEtaAxis) delete fEtaAxis;
453  if (fPhiAxis) delete fPhiAxis;
454 }
455 
456 ////////////////////////////////////////////////////////////////////////////////
457 /// Add new slice.
458 
460 {
461  fSliceInfos.push_back(SliceInfo_t());
462  fSliceVec.push_back(std::vector<Float_t> ());
463  fSliceVec.back().resize(fGeomVec.size(), 0.f);
464 
465  return fSliceInfos.size() - 1;
466 }
467 
468 ////////////////////////////////////////////////////////////////////////////////
469 /// Add tower within eta/phi range.
470 
472 {
473  assert (etaMin < etaMax);
474  assert (phiMin < phiMax);
475 
476  fGeomVec.push_back(CellGeom_t(etaMin, etaMax, phiMin, phiMax));
477 
478  for (vvFloat_i it=fSliceVec.begin(); it!=fSliceVec.end(); ++it)
479  (*it).push_back(0);
480 
481  if (etaMin < fEtaMin) fEtaMin = etaMin;
482  if (etaMax > fEtaMax) fEtaMax = etaMax;
483 
484  if (phiMin < fPhiMin) fPhiMin = phiMin;
485  if (phiMax > fPhiMax) fPhiMax = phiMax;
486 
487  fTower = fGeomVec.size() - 1;
488  return fTower;
489 }
490 
491 ////////////////////////////////////////////////////////////////////////////////
492 /// Fill given slice in the current tower.
493 
495 {
496  fSliceVec[slice][fTower] = val;
497 }
498 
499 ////////////////////////////////////////////////////////////////////////////////
500 /// Fill given slice in a given tower.
501 
503 {
504  fSliceVec[slice][tower] = val;
505 }
506 
507 
508 ////////////////////////////////////////////////////////////////////////////////
509 /// Get list of cell-ids for given eta/phi range.
510 
512  Float_t phi, Float_t phiD,
513  TEveCaloData::vCellId_t &out) const
514 {
515  using namespace TMath;
516 
517  Float_t etaMin = eta - etaD*0.5;
518  Float_t etaMax = eta + etaD*0.5;
519 
520  Float_t phiMin = phi - phiD*0.5;
521  Float_t phiMax = phi + phiD*0.5;
522 
523  Int_t nS = fSliceVec.size();
524 
525  Int_t tower = 0;
526  Float_t fracx=0, fracy=0, frac;
527  Float_t minQ, maxQ;
528 
529  for(vCellGeom_ci i=fGeomVec.begin(); i!=fGeomVec.end(); i++)
530  {
531  const CellGeom_t &cg = *i;
532  fracx = TEveUtil::GetFraction(etaMin, etaMax, cg.fEtaMin, cg.fEtaMax);
533  if (fracx > 1e-3)
534  {
535  minQ = cg.fPhiMin;
536  maxQ = cg.fPhiMax;
537 
538  if (fWrapTwoPi)
539  {
540  if (maxQ < phiMin)
541  {
542  minQ += TwoPi(); maxQ += TwoPi();
543  }
544  else if (minQ > phiMax)
545  {
546  minQ -= TwoPi(); maxQ -= TwoPi();
547  }
548  }
549 
550  if (maxQ >= phiMin && minQ <= phiMax)
551  {
552  fracy = TEveUtil::GetFraction(phiMin, phiMax, minQ, maxQ);
553  if (fracy > 1e-3)
554  {
555  frac = fracx*fracy;
556  for (Int_t s=0; s<nS; s++)
557  {
558  if (fSliceVec[s][tower] > fSliceInfos[s].fThreshold)
559  out.push_back(CellId_t(tower, s, frac));
560  }
561  }
562  }
563  }
564  tower++;
565  }
566 }
567 
568 ////////////////////////////////////////////////////////////////////////////////
569 /// Rebin cells.
570 
571 void TEveCaloDataVec::Rebin(TAxis* ax, TAxis* ay, vCellId_t &ids, Bool_t et, RebinData_t& rdata) const
572 {
573  rdata.fNSlices = GetNSlices();
574  rdata.fBinData.assign((ax->GetNbins()+2)*(ay->GetNbins()+2), -1);
575 
576  CellData_t cd;
577  for (vCellId_i it = ids.begin(); it != ids.end(); ++it)
578  {
579  GetCellData(*it, cd);
580  Int_t iMin = ax->FindBin(cd.EtaMin());
581  Int_t iMax = ax->FindBin(cd.EtaMax());
582  Int_t jMin = ay->FindBin(cd.PhiMin());
583  Int_t jMax = ay->FindBin(cd.PhiMax());
584  for (Int_t i = iMin; i <= iMax; ++i)
585  {
586  if (i < 0 || i > ax->GetNbins()) continue;
587  for (Int_t j = jMin; j <= jMax; ++j)
588  {
589  if (j < 0 || j > ay->GetNbins()) continue;
590 
591  Double_t ratio = TEveUtil::GetFraction(ax->GetBinLowEdge(i), ax->GetBinUpEdge(i), cd.EtaMin(), cd.EtaMax())
592  * TEveUtil::GetFraction(ay->GetBinLowEdge(j), ay->GetBinUpEdge(j), cd.PhiMin(), cd.PhiMax());
593 
594  if (ratio > 1e-6f)
595  {
596  Float_t* slices = rdata.GetSliceVals(i + j*(ax->GetNbins()+2));
597  slices[(*it).fSlice] += ratio * cd.Value(et);
598  }
599  }
600  }
601  }
602 }
603 
604 ////////////////////////////////////////////////////////////////////////////////
605 /// Get cell geometry and value from cell ID.
606 
608  TEveCaloData::CellData_t& cellData) const
609 {
610  cellData.CellGeom_t::operator=( fGeomVec[id.fTower] );
611  cellData.fValue = fSliceVec[id.fSlice][id.fTower];
612 }
613 
614 ////////////////////////////////////////////////////////////////////////////////
615 /// Update limits and notify data users.
616 
618 {
619  using namespace TMath;
620 
621  // update max E/Et values
622 
623  fMaxValE = 0;
624  fMaxValEt = 0;
625  Float_t sum=0;
626  // printf("geom vec %d slices %d\n",fGeomVec.size(), fSliceVec.size() );
627 
628  for (UInt_t tw=0; tw<fGeomVec.size(); tw++)
629  {
630  sum=0;
631  for (vvFloat_i it=fSliceVec.begin(); it!=fSliceVec.end(); ++it)
632  sum += (*it)[tw];
633 
634  if (sum > fMaxValEt ) fMaxValEt=sum;
635 
636  sum /= Abs(Sin(EtaToTheta(fGeomVec[tw].Eta())));
637 
638  if (sum > fMaxValE) fMaxValE=sum;
639  }
640 
642 }
643 
644 
645 ////////////////////////////////////////////////////////////////////////////////
646 /// Set XY axis from cells geometry.
647 
649 {
650  std::vector<Double_t> binX;
651  std::vector<Double_t> binY;
652 
653  for(vCellGeom_ci i=fGeomVec.begin(); i!=fGeomVec.end(); i++)
654  {
655  const CellGeom_t &ch = *i;
656 
657  binX.push_back(ch.EtaMin());
658  binX.push_back(ch.EtaMax());
659  binY.push_back(ch.PhiMin());
660  binY.push_back(ch.PhiMax());
661  }
662 
663  std::sort(binX.begin(), binX.end());
664  std::sort(binY.begin(), binY.end());
665 
666  Int_t cnt = 0;
667  Double_t sum = 0;
668  Double_t val;
669 
670  // X axis
671  Double_t dx = binX.back() - binX.front();
672  epsX *= dx;
673  std::vector<Double_t> newX;
674  newX.push_back(binX.front()); // underflow
675  Int_t nX = binX.size()-1;
676  for(Int_t i=0; i<nX; i++)
677  {
678  val = (sum +binX[i])/(cnt+1);
679  if (binX[i+1] -val > epsX)
680  {
681  newX.push_back(val);
682  cnt = 0;
683  sum = 0;
684  }
685  else
686  {
687  sum += binX[i];
688  cnt++;
689  }
690  }
691  newX.push_back(binX.back()); // overflow
692 
693  // Y axis
694  cnt = 0;
695  sum = 0;
696  std::vector<Double_t> newY;
697  Double_t dy = binY.back() - binY.front();
698  epsY *= dy;
699  newY.push_back(binY.front());// underflow
700  Int_t nY = binY.size()-1;
701  for(Int_t i=0 ; i<nY; i++)
702  {
703  val = (sum +binY[i])/(cnt+1);
704  if (binY[i+1] -val > epsY )
705  {
706  newY.push_back(val);
707  cnt = 0;
708  sum = 0;
709  }
710  else
711  {
712  sum += binY[i];
713  cnt++;
714  }
715 
716  }
717  newY.push_back(binY.back()); // overflow
718 
719  if (fEtaAxis) delete fEtaAxis;
720  if (fPhiAxis) delete fPhiAxis;
721 
722  fEtaAxis = new TAxis(newX.size()-1, &newX[0]);
723  fPhiAxis = new TAxis(newY.size()-1, &newY[0]);
724  fEtaAxis->SetNdivisions(510);
725  fPhiAxis->SetNdivisions(510);
726 }
727 
728 /** \class TEveCaloDataHist
729 \ingroup TEve
730 A central manager for calorimeter data of an event written in TH2F.
731 X axis is used for eta and Y axis for phi.
732 */
733 
735 
736 ////////////////////////////////////////////////////////////////////////////////
737 /// Constructor.
738 
740  TEveCaloData(),
741 
742  fHStack(0)
743 {
744  fHStack = new THStack();
745  fEps = 1e-5;
746 }
747 
748 ////////////////////////////////////////////////////////////////////////////////
749 /// Destructor.
750 
752 {
753  delete fHStack;
754 }
755 
756 ////////////////////////////////////////////////////////////////////////////////
757 /// Update limits and notify data users.
758 
760 {
761  using namespace TMath;
762 
763  // update max E/Et values
764  fMaxValE = 0;
765  fMaxValEt = 0;
766 
767  if (GetNSlices() < 1) return;
768 
769  TH2* hist = GetHist(0);
770  fEtaAxis = hist->GetXaxis();
771  fPhiAxis = hist->GetYaxis();
772  for (Int_t ieta = 1; ieta <= fEtaAxis->GetNbins(); ++ieta)
773  {
774  Double_t eta = fEtaAxis->GetBinCenter(ieta); // conversion E/Et
775  for (Int_t iphi = 1; iphi <= fPhiAxis->GetNbins(); ++iphi)
776  {
777  Double_t value = 0;
778  for (Int_t i = 0; i < GetNSlices(); ++i)
779  {
780  hist = GetHist(i);
781  Int_t bin = hist->GetBin(ieta, iphi);
782  value += hist->GetBinContent(bin);
783  }
784 
785  if (value > fMaxValEt ) fMaxValEt = value;
786 
787  value /= Abs(Sin(EtaToTheta(eta)));
788 
789  if (value > fMaxValE) fMaxValE = value;
790  }
791  }
793 }
794 
795 ////////////////////////////////////////////////////////////////////////////////
796 /// Get list of cell IDs in given eta and phi range.
797 
799  Float_t phi, Float_t phiD,
800  TEveCaloData::vCellId_t &out) const
801 {
802  using namespace TMath;
803 
804  Float_t etaMin = eta - etaD*0.5 -fEps;
805  Float_t etaMax = eta + etaD*0.5 +fEps;
806 
807  Float_t phiMin = phi - phiD*0.5 -fEps;
808  Float_t phiMax = phi + phiD*0.5 +fEps;
809 
810  Int_t nEta = fEtaAxis->GetNbins();
811  Int_t nPhi = fPhiAxis->GetNbins();
812  Int_t nSlices = GetNSlices();
813 
814  Int_t bin = 0;
815 
816  Bool_t accept;
817  for (Int_t ieta = 1; ieta <= nEta; ++ieta)
818  {
819  if (fEtaAxis->GetBinLowEdge(ieta) >= etaMin && fEtaAxis->GetBinUpEdge(ieta) <= etaMax)
820  {
821  for (Int_t iphi = 1; iphi <= nPhi; ++iphi)
822  {
823  if (fWrapTwoPi )
824  {
826  (phiMin, phiMax, fPhiAxis->GetBinLowEdge(iphi), fPhiAxis->GetBinUpEdge(iphi));
827  }
828  else
829  {
830  accept = fPhiAxis->GetBinLowEdge(iphi) >= phiMin && fPhiAxis->GetBinUpEdge(iphi) <= phiMax &&
831  fPhiAxis->GetBinLowEdge(iphi) >= phiMin && fPhiAxis->GetBinUpEdge(iphi) <= phiMax;
832  }
833 
834  if (accept)
835  {
836  for (Int_t s = 0; s < nSlices; ++s)
837  {
838  TH2F *hist = GetHist(s);
839  bin = hist->GetBin(ieta, iphi);
840  if (hist->GetBinContent(bin) > fSliceInfos[s].fThreshold)
841  out.push_back(TEveCaloData::CellId_t(bin, s));
842  } // hist slices
843  }
844  } // phi bins
845  }
846  } // eta bins
847 }
848 
849 ////////////////////////////////////////////////////////////////////////////////
850 /// Rebin
851 
853 {
854  rdata.fNSlices = GetNSlices();
855  rdata.fBinData.assign((ax->GetNbins()+2)*(ay->GetNbins()+2), -1);
857  Float_t *val;
858  Int_t i, j, w;
859  Int_t binx, biny;
860  Int_t bin;
861 
862  for (vCellId_i it=ids.begin(); it!=ids.end(); ++it)
863  {
864  GetCellData(*it, cd);
865  GetHist(it->fSlice)->GetBinXYZ((*it).fTower, i, j, w);
866  binx = ax->FindBin(fEtaAxis->GetBinCenter(i));
867  biny = ay->FindBin(fPhiAxis->GetBinCenter(j));
868  bin = biny*(ax->GetNbins()+2)+binx;
869  val = rdata.GetSliceVals(bin);
870  Double_t ratio = TEveUtil::GetFraction(ax->GetBinLowEdge(binx), ax->GetBinUpEdge(binx), cd.EtaMin(), cd.EtaMax())
871  * TEveUtil::GetFraction(ay->GetBinLowEdge(biny), ay->GetBinUpEdge(biny), cd.PhiMin(), cd.PhiMax());
872 
873  val[(*it).fSlice] += cd.Value(et)*ratio;
874  }
875 }
876 
877 ////////////////////////////////////////////////////////////////////////////////
878 /// Get cell geometry and value from cell ID.
879 
881  TEveCaloData::CellData_t& cellData) const
882 {
883  TH2F* hist = GetHist(id.fSlice);
884 
885  Int_t x, y, z;
886  hist->GetBinXYZ(id.fTower, x, y, z);
887 
888  cellData.fValue = hist->GetBinContent(id.fTower);
889  cellData.Configure(hist->GetXaxis()->GetBinLowEdge(x),
890  hist->GetXaxis()->GetBinUpEdge(x),
891  hist->GetYaxis()->GetBinLowEdge(y),
892  hist->GetYaxis()->GetBinUpEdge(y));
893 }
894 
895 ////////////////////////////////////////////////////////////////////////////////
896 /// Add new slice to calo tower. Updates cached variables fMaxValE
897 /// and fMaxValEt
898 /// Return last index in the vector of slice infos.
899 
901 {
902  fHStack->Add(hist);
903  fSliceInfos.push_back(SliceInfo_t());
904  fSliceInfos.back().fName = hist->GetName();
905  fSliceInfos.back().fColor = hist->GetLineColor();
906 
907  DataChanged();
908 
909  return fSliceInfos.size() - 1;
910 }
911 
912 ////////////////////////////////////////////////////////////////////////////////
913 /// Get histogram in given slice.
914 
916 {
917  assert(slice >= 0 && slice < fHStack->GetHists()->GetSize());
918  return (TH2F*) fHStack->GetHists()->At(slice);
919 }
920 
921 ////////////////////////////////////////////////////////////////////////////////
922 /// Get eta limits.
923 
925 {
926  min = fEtaAxis->GetXmin();
927  max = fEtaAxis->GetXmax();
928 }
929 
930 ////////////////////////////////////////////////////////////////////////////////
931 /// Get phi limits.
932 
934 {
935  min = fPhiAxis->GetXmin();
936  max = fPhiAxis->GetXmax();
937 }
TEveCaloDataVec::FillSlice
void FillSlice(Int_t slice, Float_t value)
Fill given slice in the current tower.
Definition: TEveCaloData.cxx:494
TEveCaloData::CellGeom_t::fEtaMax
Float_t fEtaMax
Definition: TEveCaloData.h:79
n
const Int_t n
Definition: legend1.C:16
TEveCaloData::RebinData_t
Definition: TEveCaloData.h:128
TAxis
Class to manage histogram axis.
Definition: TAxis.h:30
TEveCaloData::RebinData_t::GetSliceVals
Float_t * GetSliceVals(Int_t bin)
Definition: TEveCaloData.cxx:89
TEveCaloDataHist::Rebin
virtual void Rebin(TAxis *ax, TAxis *ay, vCellId_t &in, Bool_t et, RebinData_t &out) const
Rebin.
Definition: TEveCaloData.cxx:852
TEveCaloData::CellData_t
Definition: TEveCaloData.h:114
ROOT::Math::etaMax
T etaMax()
Function providing the maximum possible value of pseudorapidity for a non-zero rho,...
Definition: etaMax.h:60
TEveCaloData::CellSelectionChanged
virtual void CellSelectionChanged()
Tell users (TEveCaloViz instances using this data) that cell selection has changed and they should up...
Definition: TEveCaloData.cxx:398
TEveElement
Definition: TEveElement.h:35
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:91
e
#define e(i)
Definition: RSha256.hxx:121
TEveCaloViz::CellSelectionChanged
virtual void CellSelectionChanged()
Definition: TEveCalo.h:83
TAxis::GetBinLowEdge
virtual Double_t GetBinLowEdge(Int_t bin) const
Return low edge of bin.
Definition: TAxis.cxx:518
TEveCaloDataHist::GetCellData
virtual void GetCellData(const TEveCaloData::CellId_t &id, TEveCaloData::CellData_t &data) const
Get cell geometry and value from cell ID.
Definition: TEveCaloData.cxx:880
TEveCaloData::vCellGeom_ci
std::vector< CellGeom_t >::const_iterator vCellGeom_ci
Definition: TEveCaloData.h:151
TGLSelectRecord::GetHighlight
Bool_t GetHighlight() const
Definition: TGLSelectRecord.h:111
f
#define f(i)
Definition: RSha256.hxx:122
TEveCaloDataHist::TEveCaloDataHist
TEveCaloDataHist()
Constructor.
Definition: TEveCaloData.cxx:739
TEveCaloDataVec::SetAxisFromBins
void SetAxisFromBins(Double_t epsX=0.001, Double_t epsY=0.001)
Set XY axis from cells geometry.
Definition: TEveCaloData.cxx:648
TEveCaloDataVec
Definition: TEveCaloData.h:239
TEveCaloData::CellGeom_t::fEtaMin
Float_t fEtaMin
Definition: TEveCaloData.h:78
TEveCaloData::FillImpliedSelectedSet
virtual void FillImpliedSelectedSet(Set_t &impSelSet)
Populate set impSelSet with derived / dependant elements.
Definition: TEveCaloData.cxx:178
TEveCaloData::ProcessSelection
void ProcessSelection(vCellId_t &sel_cells, TGLSelectRecord &rec)
Process newly selected cells with given select-record.
Definition: TEveCaloData.cxx:207
TH2::GetBinContent
virtual Double_t GetBinContent(Int_t bin) const
Return content of bin number bin.
Definition: TH2.h:88
TEveElement::kCBObjProps
@ kCBObjProps
Definition: TEveElement.h:384
TH2F
2-D histogram with a float per channel (see TH1 documentation)}
Definition: TH2.h:251
TEveUtil::GetFraction
static Float_t GetFraction(Float_t minM, Float_t maxM, Float_t minQ, Float_t maxQ)
Get fraction of interval [minQ, maxQ] in [minM, maxM].
Definition: TEveUtil.cxx:382
THStack
Definition: THStack.h:38
ClassImp
#define ClassImp(name)
Definition: Rtypes.h:364
TEveCaloData::RebinData_t::fBinData
std::vector< Int_t > fBinData
Definition: TEveCaloData.h:133
TEveCaloDataHist::DataChanged
virtual void DataChanged()
Update limits and notify data users.
Definition: TEveCaloData.cxx:759
TObject::Error
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:890
TEveCaloData::CellGeom_t::Configure
void Configure(Float_t etaMin, Float_t etaMax, Float_t phiMin, Float_t phiMax)
Definition: TEveCaloData.cxx:42
TEveCaloData::CellGeom_t::PhiMin
Float_t PhiMin() const
Definition: TEveCaloData.h:95
TEveCaloViz::DataChanged
void DataChanged()
Update setting and cache on data changed.
Definition: TEveCalo.cxx:256
TEveCaloData::CellGeom_t
Definition: TEveCaloData.h:72
THStack::Add
virtual void Add(TH1 *h, Option_t *option="")
add a new histogram to the list Only 1-d and 2-d histograms currently supported.
Definition: THStack.cxx:361
TGLSelectRecord::kModifyingInternalSelection
@ kModifyingInternalSelection
Definition: TGLSelectRecord.h:77
TEveCaloDataVec::fPhiMax
Float_t fPhiMax
Definition: TEveCaloData.h:262
Float_t
float Float_t
Definition: RtypesCore.h:57
TMath::Exp
Double_t Exp(Double_t x)
Definition: TMath.h:727
TGeant4Unit::s
static constexpr double s
Definition: TGeant4SystemOfUnits.h:168
TAxis::GetBinCenter
virtual Double_t GetBinCenter(Int_t bin) const
Return center of bin.
Definition: TAxis.cxx:478
TEveCaloData::vCellId_t
std::vector< CellId_t > vCellId_t
Definition: TEveCaloData.h:146
TEveCaloData::CellGeom_t::fPhiMax
Float_t fPhiMax
Definition: TEveCaloData.h:77
TAxis::GetBinUpEdge
virtual Double_t GetBinUpEdge(Int_t bin) const
Return up edge of bin.
Definition: TAxis.cxx:528
TEveCaloDataVec::fPhiMin
Float_t fPhiMin
Definition: TEveCaloData.h:261
TEveCaloDataVec::fEtaMax
Float_t fEtaMax
Definition: TEveCaloData.h:259
TEveCaloData::PrintCellsSelected
void PrintCellsSelected()
Print selected cells info.
Definition: TEveCaloData.cxx:189
TEveUtil::IsU1IntervalContainedByMinMax
static Bool_t IsU1IntervalContainedByMinMax(Float_t minM, Float_t maxM, Float_t minQ, Float_t maxQ)
Return true if interval Q is contained within interval M for U1 variables.
Definition: TEveUtil.cxx:342
TEveCaloDataVec::fGeomVec
vCellGeom_t fGeomVec
Definition: TEveCaloData.h:254
TEveCaloData::GetSliceTransparency
Char_t GetSliceTransparency(Int_t slice) const
Get transparency for given slice.
Definition: TEveCaloData.cxx:358
x
Double_t x[n]
Definition: legend1.C:17
TEveCaloDataVec::vvFloat_i
std::vector< vFloat_t >::iterator vvFloat_i
Definition: TEveCaloData.h:251
TEveCaloData::CellGeom_t::EtaMax
Float_t EtaMax() const
Definition: TEveCaloData.h:91
TList.h
ROOT::Math::Pi
double Pi()
Mathematical constants.
Definition: Math.h:88
TEveCaloData::SetSliceColor
void SetSliceColor(Int_t slice, Color_t col)
Set color for given slice.
Definition: TEveCaloData.cxx:326
TEveElement::fChildren
List_t fChildren
Definition: TEveElement.h:81
TMath::Abs
Short_t Abs(Short_t d)
Definition: TMathBase.h:120
TEveCaloDataVec::fTower
Int_t fTower
Definition: TEveCaloData.h:256
TEveCaloData::CellGeom_t::PhiMax
Float_t PhiMax() const
Definition: TEveCaloData.h:96
TEveCaloData::SliceInfo_t
Definition: TEveCaloData.h:30
TString::Format
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Definition: TString.cxx:2311
TEveCaloData::CellGeom_t::fPhiMin
Float_t fPhiMin
Definition: TEveCaloData.h:76
TEveCaloDataHist::GetPhiLimits
virtual void GetPhiLimits(Double_t &min, Double_t &max) const
Get phi limits.
Definition: TEveCaloData.cxx:933
TString
Definition: TString.h:136
TEveCaloData::fCellsHighlighted
vCellId_t fCellsHighlighted
Definition: TEveCaloData.h:171
Color_t
short Color_t
Definition: RtypesCore.h:83
TEveCaloDataHist
Definition: TEveCaloData.h:297
bool
TEveCaloData::CellData_t::Dump
virtual void Dump() const
Print member data.
Definition: TEveCaloData.cxx:82
TEveCaloDataVec::fSliceVec
vvFloat_t fSliceVec
Definition: TEveCaloData.h:253
TGLSelectRecord::kEnteringSelection
@ kEnteringSelection
Definition: TGLSelectRecord.h:77
TEveCaloDataHist::fHStack
THStack * fHStack
Definition: TEveCaloData.h:304
TEveCaloData::GetHighlightTooltip
virtual TString GetHighlightTooltip()
Definition: TEveCaloData.cxx:149
THStack::GetHists
TList * GetHists() const
Definition: THStack.h:67
TList::At
virtual TObject * At(Int_t idx) const
Returns the object at position idx. Returns 0 if idx is out of range.
Definition: TList.cxx:356
TEveCaloDataVec::Rebin
virtual void Rebin(TAxis *ax, TAxis *ay, vCellId_t &in, Bool_t et, RebinData_t &out) const
Rebin cells.
Definition: TEveCaloData.cxx:571
TEveCaloData::UnHighlighted
virtual void UnHighlighted()
Virtual method TEveElement::UnHighlighted.
Definition: TEveCaloData.cxx:142
TEveCaloData::fMaxValE
Float_t fMaxValE
Definition: TEveCaloData.h:166
TEveCaloData::CellData_t::Value
Float_t Value(Bool_t) const
Return energy value associated with the cell, usually Et.
Definition: TEveCaloData.cxx:71
TEveCaloData::TEveCaloData
TEveCaloData(const TEveCaloData &)
TAxis::GetXmin
Double_t GetXmin() const
Definition: TAxis.h:133
TH1::GetYaxis
TAxis * GetYaxis()
Definition: TH1.h:318
TEveCaloData::GetSliceColor
Color_t GetSliceColor(Int_t slice) const
Get color for given slice.
Definition: TEveCaloData.cxx:338
TEveCaloData::SetSliceThreshold
void SetSliceThreshold(Int_t slice, Float_t threshold)
Set threshold for given slice.
Definition: TEveCaloData.cxx:309
TGLSelectRecord
Definition: TGLSelectRecord.h:74
TEveCaloData::EtaToTheta
static Float_t EtaToTheta(Float_t eta)
Definition: TEveCaloData.cxx:411
TEveCaloData::CellGeom_t::Phi
Float_t Phi() const
Definition: TEveCaloData.h:97
TEveCaloData::UnSelected
virtual void UnSelected()
Virtual method TEveElement::UnSelect.
Definition: TEveCaloData.cxx:134
TNamed
Definition: TNamed.h:29
TEveElement::StampObjProps
void StampObjProps()
Definition: TEveElement.h:399
kFALSE
const Bool_t kFALSE
Definition: RtypesCore.h:92
TEveCaloDataVec::AddSlice
Int_t AddSlice()
Add new slice.
Definition: TEveCaloData.cxx:459
TGLSelectRecord::GetMultiple
Bool_t GetMultiple() const
Definition: TGLSelectRecord.h:110
TEveCaloData::fPhiAxis
TAxis * fPhiAxis
Definition: TEveCaloData.h:161
TGLSelectRecord::SetSecSelResult
void SetSecSelResult(ESecSelResult r)
Definition: TGLSelectRecord.h:124
TEveCaloData::CellGeom_t::Dump
virtual void Dump() const
Print member data.
Definition: TEveCaloData.cxx:35
TEveCaloData::CellData_t::fValue
Float_t fValue
Definition: TEveCaloData.h:118
TEveElement::List_ci
List_t::const_iterator List_ci
Definition: TEveElement.h:73
THStack.h
TH2
Definition: TH2.h:30
TEveCaloData::fCellsSelected
vCellId_t fCellsSelected
Definition: TEveCaloData.h:170
TEveCaloDataHist::GetCellList
virtual void GetCellList(Float_t etaMin, Float_t etaMax, Float_t phi, Float_t phiRng, vCellId_t &out) const
Get list of cell IDs in given eta and phi range.
Definition: TEveCaloData.cxx:798
TMath::Sin
Double_t Sin(Double_t)
Definition: TMath.h:639
TH2::GetBin
virtual Int_t GetBin(Int_t binx, Int_t biny, Int_t binz=0) const
Return Global bin number corresponding to binx,y,z.
Definition: TH2.cxx:967
y
Double_t y[n]
Definition: legend1.C:17
TEveCaloDataVec::~TEveCaloDataVec
virtual ~TEveCaloDataVec()
Destructor.
Definition: TEveCaloData.cxx:450
TEveCaloData::SetSliceTransparency
void SetSliceTransparency(Int_t slice, Char_t t)
Set transparency for given slice.
Definition: TEveCaloData.cxx:346
TEveCaloViz
Definition: TEveCalo.h:27
TEveCaloData::fEtaAxis
TAxis * fEtaAxis
Definition: TEveCaloData.h:160
TEveCaloData::fEps
Float_t fEps
Definition: TEveCaloData.h:168
TH2.h
TEveCaloDataVec::AddTower
Int_t AddTower(Float_t etaMin, Float_t etaMax, Float_t phiMin, Float_t phiMax)
Add tower within eta/phi range.
Definition: TEveCaloData.cxx:471
TEveCaloData
Definition: TEveCaloData.h:26
unsigned int
TMath::TwoPi
constexpr Double_t TwoPi()
Definition: TMath.h:50
TEveCaloData.h
TEveCaloData::fSliceInfos
vSliceInfo_t fSliceInfos
Definition: TEveCaloData.h:158
TEveElement::StampColorSelection
void StampColorSelection()
Definition: TEveElement.h:397
TEveCaloViz::InvalidateCellIdCache
void InvalidateCellIdCache()
Definition: TEveCalo.h:93
sum
static long int sum(long int i)
Definition: Factory.cxx:2272
TEveCaloDataVec::TEveCaloDataVec
TEveCaloDataVec(const TEveCaloDataVec &)
TMath::ATan
Double_t ATan(Double_t)
Definition: TMath.h:675
TEveCaloData::GetNSlices
Int_t GetNSlices() const
Definition: TEveCaloData.h:202
Double_t
double Double_t
Definition: RtypesCore.h:59
TEveCaloDataVec::GetCellData
virtual void GetCellData(const TEveCaloData::CellId_t &id, TEveCaloData::CellData_t &data) const
Get cell geometry and value from cell ID.
Definition: TEveCaloData.cxx:607
TGLSelectRecord::kNone
@ kNone
Definition: TGLSelectRecord.h:77
TAxis.h
TEveCalo.h
TEveCaloData::DataChanged
virtual void DataChanged()
Tell users (TEveCaloViz instances using this data) that data has changed and they should update the l...
Definition: TEveCaloData.cxx:382
TEveCaloDataHist::GetEtaLimits
virtual void GetEtaLimits(Double_t &min, Double_t &max) const
Get eta limits.
Definition: TEveCaloData.cxx:924
TGLSelectRecord.h
TEveCaloDataHist::AddHistogram
Int_t AddHistogram(TH2F *hist)
Add new slice to calo tower.
Definition: TEveCaloData.cxx:900
TEveCaloData::InvalidateUsersCellIdCache
virtual void InvalidateUsersCellIdCache()
Invalidate cell ids cache on back ptr references.
Definition: TEveCaloData.cxx:366
TAxis::FindBin
virtual Int_t FindBin(Double_t x)
Find bin number corresponding to abscissa x.
Definition: TAxis.cxx:293
TEveCaloDataVec::fEtaMin
Float_t fEtaMin
Definition: TEveCaloData.h:258
TAttAxis::SetNdivisions
virtual void SetNdivisions(Int_t n=510, Bool_t optim=kTRUE)
Set the number of divisions for this axis.
Definition: TAttAxis.cxx:228
TGLSelectRecord::kLeavingSelection
@ kLeavingSelection
Definition: TGLSelectRecord.h:77
TEveCaloDataVec::GetCellList
virtual void GetCellList(Float_t etaMin, Float_t etaMax, Float_t phi, Float_t phiRng, vCellId_t &out) const
Get list of cell-ids for given eta/phi range.
Definition: TEveCaloData.cxx:511
xmlio::cnt
const char * cnt
Definition: TXMLSetup.cxx:81
TEveCaloData::GetCellData
virtual void GetCellData(const CellId_t &id, CellData_t &data) const =0
TNamed::GetName
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:53
TH1::GetBinXYZ
virtual void GetBinXYZ(Int_t binglobal, Int_t &binx, Int_t &biny, Int_t &binz) const
Return binx, biny, binz corresponding to the global bin number globalbin see TH1::GetBin function abo...
Definition: TH1.cxx:4821
TEveCaloData::CellGeom_t::EtaMin
Float_t EtaMin() const
Definition: TEveCaloData.h:90
TAxis::GetXmax
Double_t GetXmax() const
Definition: TAxis.h:134
Float_t
TEveCaloData::CellGeom_t::Eta
Float_t Eta() const
Definition: TEveCaloData.h:92
TEveCaloDataHist::~TEveCaloDataHist
virtual ~TEveCaloDataHist()
Destructor.
Definition: TEveCaloData.cxx:751
TH1::GetXaxis
TAxis * GetXaxis()
Get the behaviour adopted by the object about the statoverflows. See EStatOverflows for more informat...
Definition: TH1.h:317
Char_t
char Char_t
Definition: RtypesCore.h:33
TEveCaloData::fMaxValEt
Float_t fMaxValEt
Definition: TEveCaloData.h:165
TEveCaloData::vCellId_i
std::vector< CellId_t >::iterator vCellId_i
Definition: TEveCaloData.h:147
TEveCaloData::RebinData_t::fNSlices
Int_t fNSlices
Definition: TEveCaloData.h:130
TEveCaloData::GetSliceThreshold
Float_t GetSliceThreshold(Int_t slice) const
Get threshold for given slice.
Definition: TEveCaloData.cxx:318
TEveElement::Set_t
std::set< TEveElement * > Set_t
Definition: TEveElement.h:75
TAxis::GetNbins
Int_t GetNbins() const
Definition: TAxis.h:121
TEveCaloData::CellId_t
Definition: TEveCaloData.h:57
TGLSelectRecord::GetSecSelResult
ESecSelResult GetSecSelResult() const
Definition: TGLSelectRecord.h:113
TMath
TMath.
Definition: TMathBase.h:35
TEveCaloData::fWrapTwoPi
Bool_t fWrapTwoPi
Definition: TEveCaloData.h:163
TMath.h
TEveCaloDataVec::DataChanged
virtual void DataChanged()
Update limits and notify data users.
Definition: TEveCaloData.cxx:617
TEveCaloDataHist::GetHist
TH2F * GetHist(Int_t slice) const
Get histogram in given slice.
Definition: TEveCaloData.cxx:915
int