GRSISort "v4.0.0.5"
An extension of the ROOT analysis Framework
Loading...
Searching...
No Matches
TCalList.cxx
Go to the documentation of this file.
1#include "TCalList.h"
2#include "Globals.h"
3
4#include <iostream>
5
10
11TCalList::TCalList(const char* name, const char* title) : TNamed(name, title)
12{
13 Clear();
14}
15
16TCalList::TCalList(const TCalList& copy) : TNamed(copy)
17{
18 copy.Copy(*this);
19}
20
21void TCalList::Copy(TObject& obj) const
22{
23 TNamed::Copy(obj);
24 static_cast<TCalList&>(obj).Clear();
25 for(const auto& it : fCalList) {
26 static_cast<TCalList&>(obj).AddPoint(it.second);
27 }
28}
29
30void TCalList::AddPoint(const TCalPoint& point)
31{
32 AddPoint(std::floor(point.Centroid()), point);
33}
34
35void TCalList::AddPoint(const UInt_t& idx, const TCalPoint& point)
36{
37 fCalList.insert(std::make_pair(idx, point));
38}
39
40bool TCalList::SetPointIndex(const UInt_t& old_idx, const UInt_t& new_idx)
41{
42 auto it = fCalList.find(old_idx);
43 if(it != fCalList.end()) {
44 // This means we found the old index! no go ahead and save the pair
45 TCalPoint sav_pt = it->second;
46 // delete the old pair
47 fCalList.erase(it);
48 // insert the new pair
49 fCalList.insert(std::make_pair(new_idx, sav_pt));
50 return true;
51 }
52 // didn't find it, return false
53 return false;
54}
55
56void TCalList::Print(Option_t*) const
57{
58 int idx = 0;
59 std::cout << GetName() << " " << GetTitle() << std::endl;
60 for(const auto& it : fCalList) {
61 std::cout << idx++ << " " << it.first << std::endl;
62 it.second.Print();
63 }
64}
65
66void TCalList::Clear(Option_t*)
67{
68 fCalList.clear();
69}
70
71void TCalList::FillGraph(TGraph* graph) const
72{
73 graph->Clear();
74 Int_t i = 0;
75 auto* ge = static_cast<TGraphErrors*>(graph);
76
77 for(const auto& it : fCalList) {
78 graph->SetPoint(i, it.second.Centroid(), it.second.Area());
79 if(ge != nullptr) {
80 ge->SetPointError(i++, it.second.CentroidErr(), it.second.AreaErr());
81 }
82 }
83}
void Copy(TObject &obj) const override
Definition TCalList.cxx:21
void FillGraph(TGraph *graph) const
Definition TCalList.cxx:71
void AddPoint(const TCalPoint &point)
Definition TCalList.cxx:30
std::map< UInt_t, TCalPoint > fCalList
Definition TCalList.h:37
void Print(Option_t *opt="") const override
Definition TCalList.cxx:56
bool SetPointIndex(const UInt_t &old_idx, const UInt_t &new_idx)
Definition TCalList.cxx:40
void Clear(Option_t *opt="") override
Definition TCalList.cxx:66
Double_t Centroid() const
Definition TCalPoint.h:32