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