All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CrtCalTree.cxx
Go to the documentation of this file.
1 #ifndef CRTCALTREE_CXX
2 #define CRTCALTREE_CXX
3 
5 
6 using namespace icarus::crt;
7 
8 CrtCalTree::CrtCalTree(TTree* tree){
9  fTree = tree;
10  Init();
11 }
12 
14  TFile fin(fname.c_str());//,"READ");
15  fTree = (TTree*)fin.FindObjectAny("calTree");
16  Init();
17 }
18 
20 
22 
23  fTree->SetBranchAddress("mac5", &mac5, &b_mac5);
24  fTree->SetBranchAddress("gain", gain, &b_gain);
25  fTree->SetBranchAddress("ped", ped, &b_ped);
26  fTree->SetBranchAddress("active", active, &b_active);
27  fTree->SetBranchAddress("gainXsqr", gainXsqr, &b_gainXsqr);
28  fTree->SetBranchAddress("gainNdf", gainNdf, &b_gainNdf);
29  fTree->SetBranchAddress("gainErr", gainErr, &b_gainErr);
30  fTree->SetBranchAddress("pedXsqr", pedXsqr, &b_pedXsqr);
31  fTree->SetBranchAddress("pedNdf", pedNdf, &b_pedNdf);
32  fTree->SetBranchAddress("pedErr", pedErr, &b_pedErr);
33  fTree->SetBranchAddress("pedSigma", pedSigma, &b_pedSigma);
34  fTree->SetBranchAddress("pedSigmaErr", pedSigmaErr, &b_pedSigmaErr);
35 
36  const size_t nmac = fTree->GetEntriesFast();
37  std::cout << "retreiving calibration data for " << nmac << " FEBs..." << std::endl;
38 
39  for(size_t imac=0; imac<nmac; imac++){
40  fTree->GetEntry(imac);
41 
42  fMacs.push_back(mac5);
43  fMacToEntry[mac5] = imac;
44  for(size_t chan=0; chan < 32; chan++){
45  fMacChanToGain[std::make_pair(mac5,chan)] = gain[chan];
46  fMacChanToPed[std::make_pair(mac5,chan)] = ped[chan];
47  fMacChanToActive[std::make_pair(mac5,chan)] = active[chan];
48  }
49  }
50 }
51 
52 float CrtCalTree::GetGain(uint8_t mac, uint8_t channel){
53  return fMacChanToGain[std::make_pair(mac,channel)];
54 }
55 
56 float CrtCalTree::GetPed(uint8_t mac, uint8_t channel){
57  return fMacChanToPed[std::make_pair(mac,channel)];
58 }
59 
60 bool CrtCalTree::GetActive(uint8_t mac, uint8_t channel){
61  return fMacChanToActive[std::make_pair(mac,channel)];
62 }
63 
64 std::vector<uint8_t> CrtCalTree::GetMacs() {
65  return fMacs;
66 }
67 
68 float CrtCalTree::GetGainXsqr(uint8_t mac, uint8_t channel){
69  float val = -1.;
70  fTree->GetEntry(fMacToEntry[mac]);
71  val = gainXsqr[channel];
72  return val;
73 }
74 short CrtCalTree::GetGainNdf(uint8_t mac, uint8_t channel){
75  float val = -1.;
76  fTree->GetEntry(fMacToEntry[mac]);
77  val = gainNdf[channel];
78  return val;
79 }
80 float CrtCalTree::GetGainErr(uint8_t mac, uint8_t channel){
81  float val = -1.;
82  fTree->GetEntry(fMacToEntry[mac]);
83  val = gainErr[channel];
84  return val;
85 }
86 float CrtCalTree::GetPedErr(uint8_t mac, uint8_t channel){
87  float val = -1.;
88  fTree->GetEntry(fMacToEntry[mac]);
89  val = pedErr[channel];
90  return val;
91 }
92 float CrtCalTree::GetPedXsqr(uint8_t mac, uint8_t channel){
93  float val = -1.;
94  fTree->GetEntry(fMacToEntry[mac]);
95  val = pedXsqr[channel];
96  return val;
97 }
98 short CrtCalTree::GetPedNdf(uint8_t mac, uint8_t channel){
99  float val = -1.;
100  fTree->GetEntry(fMacToEntry[mac]);
101  val = pedNdf[channel];
102  return val;
103 }
104 float CrtCalTree::GetPedSigma(uint8_t mac, uint8_t channel){
105  float val = -1.;
106  fTree->GetEntry(fMacToEntry[mac]);
107  val = pedSigma[channel];
108  return val;
109 }
110 float CrtCalTree::GetPedSigmaErr(uint8_t mac, uint8_t channel){
111  float val = -1.;
112  fTree->GetEntry(fMacToEntry[mac]);
113  val = pedSigmaErr[channel];
114  return val;
115 }
116 
118  std::cout << "preparing to dump " << fMacChanToGain.size() << " channels." << std::endl;
119 
120  std::cout << "mac5, channel -> gain, ped (active)" << std::endl;
121  for(auto const& mc : fMacChanToGain) {
122  std::cout << " " << (int)mc.first.first << ", "
123  << (int)mc.first.second << "-> " << mc.second
124  << ", " << fMacChanToPed[mc.first] << " ("
125  << fMacChanToActive[mc.first] << ")" << std::endl;
126  }
127 }
128 
129 #endif
bool GetActive(uint8_t mac, uint8_t channel)
Definition: CrtCalTree.cxx:60
float GetPedErr(uint8_t mac, uint8_t channel)
Definition: CrtCalTree.cxx:86
string fname
Definition: demo.py:5
UShort_t pedNdf[32]
Definition: CrtCalTree.h:65
std::map< uint8_t, int > fMacToEntry
Definition: CrtCalTree.h:55
float GetPed(uint8_t mac, uint8_t channel)
Definition: CrtCalTree.cxx:56
float GetPedSigma(uint8_t mac, uint8_t channel)
Definition: CrtCalTree.cxx:104
std::vector< uint8_t > fMacs
Definition: CrtCalTree.h:54
float GetPedSigmaErr(uint8_t mac, uint8_t channel)
Definition: CrtCalTree.cxx:110
std::map< std::pair< uint8_t, uint8_t >, float > fMacChanToPed
Definition: CrtCalTree.h:52
UShort_t gainNdf[32]
Definition: CrtCalTree.h:62
short GetPedNdf(uint8_t mac, uint8_t channel)
Definition: CrtCalTree.cxx:98
vector< uint8_t > GetMacs()
Definition: CrtCalTree.cxx:64
std::map< std::pair< uint8_t, uint8_t >, float > fMacChanToGain
Definition: CrtCalTree.h:51
std::map< std::pair< uint8_t, uint8_t >, bool > fMacChanToActive
Definition: CrtCalTree.h:53
float GetGain(uint8_t mac, uint8_t channel)
Definition: CrtCalTree.cxx:52
CrtCalTree(TTree *tree)
Definition: CrtCalTree.cxx:8
float GetPedXsqr(uint8_t mac, uint8_t channel)
Definition: CrtCalTree.cxx:92
process_name crt
float GetGainXsqr(uint8_t mac, uint8_t channel)
Definition: CrtCalTree.cxx:68
float GetGainErr(uint8_t mac, uint8_t channel)
Definition: CrtCalTree.cxx:80
BEGIN_PROLOG could also be cout
short GetGainNdf(uint8_t mac, uint8_t channel)
Definition: CrtCalTree.cxx:74