Class Reference for E1039 Core & Analysis Software
AnaSignal.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <iomanip>
3 #include <TFile.h>
4 #include <TTree.h>
5 #include "RoadInfo.h"
6 #include "RoadMap.h"
7 #include "RoadList.h"
8 #include "UtilRoad.h"
9 #include "AnaSignal.h"
10 using namespace std;
11 
12 AnaSignal::AnaSignal(const std::string label)
13  : AnaBase(label)
14  , m_mass_lo(0.0)
15  , m_mass_hi(100.0)
16  , m_sig_data(0)
17 {
22 }
23 
25 {
26  ;
27 }
28 
29 void AnaSignal::SetMassRange(const double mass_lo, const double mass_hi)
30 {
31  m_mass_lo = mass_lo;
32  m_mass_hi = mass_hi;
33 }
34 
36 {
37  ;
38 }
39 
41 {
42  ;
43 }
44 
45 void AnaSignal::ReadEvents(const char* fname)
46 {
47  //gROOT->cd();
48  TFile* file = new TFile(fname);
49  if (! file->IsOpen()) {
50  cout << "Cannot open the file, '" << fname << "'. Abort." << endl;
51  exit(1);
52  }
53  TTree* tree = (TTree*)file->Get(m_tree_name.c_str());
54  if (! tree) {
55  cout << "Cannot get the tree, '" << m_tree_name.c_str() << "'. Abort." << endl;
56  exit(1);
57  }
58 
59  tree->SetBranchAddress(m_branch_name.c_str(), &m_sig_data);
60 
61  for (int i_ent = 0; i_ent < tree->GetEntries(); i_ent++) {
62  tree->GetEntry(i_ent);
64  }
65 
66  file->Close();
67  delete file;
68 }
69 
71 {
72  double weight = m_sig_data->weight;
73  double mass = m_sig_data->mass;
74  int road_pos = m_sig_data->road_pos;
75  int road_neg = m_sig_data->road_neg;
76 
77  if (mass < m_mass_lo || mass > m_mass_hi) return;
78  if (road_pos * road_neg >= 0) return; // Require T+B or B+T
79 
80  RoadMap* map = &(road_pos > 0 ? m_road_map_pos_top : m_road_map_pos_bot);
81  map->Add(road_pos, weight);
82 
83  map = &(road_neg > 0 ? m_road_map_neg_top : m_road_map_neg_bot);
84  map->Add(road_neg, weight);
85 }
86 
88 {
89  cout << "AnaSignal::Analyze():" << endl;
90  cout << " Do nothing for now. Probably it will scale the signal weight by the simulated integrated luminosity." << endl;
91 
92  //m_road_list_pos_top.reserve(m_road_map_pos_top.size());
93  //m_road_list_pos_bot.reserve(m_road_map_pos_bot.size());
94  //m_road_list_neg_top.reserve(m_road_map_neg_top.size());
95  //m_road_list_neg_bot.reserve(m_road_map_neg_bot.size());
96 
97  //UtilRoad::MakeOrderedList(&m_road_map_pos_top, &m_road_list_pos_top);
98  //UtilRoad::MakeOrderedList(&m_road_map_pos_bot, &m_road_list_pos_bot);
99  //UtilRoad::MakeOrderedList(&m_road_map_neg_top, &m_road_list_neg_top);
100  //UtilRoad::MakeOrderedList(&m_road_map_neg_bot, &m_road_list_neg_bot);
101 
102 // m_road_list_pos_top.Add(&m_road_map_pos_top);
103 // m_road_list_pos_bot.Add(&m_road_map_pos_bot);
104 // m_road_list_neg_top.Add(&m_road_map_neg_top);
105 // m_road_list_neg_bot.Add(&m_road_map_neg_bot);
106  //m_road_list_pos_top.SortBySignal();
107  //m_road_list_pos_bot.SortBySignal();
108  //m_road_list_neg_top.SortBySignal();
109  //m_road_list_neg_bot.SortBySignal();
110 
111  //cout << " pos top: " << m_road_list_pos_top.Size() << endl
112  // << " pos bot: " << m_road_list_pos_bot.Size() << endl
113  // << " neg top: " << m_road_list_neg_top.Size() << endl
114  // << " neg bot: " << m_road_list_neg_bot.Size() << endl
115  // << endl;
116 
117  //m_ofs << "Pos Top: First Five\n";
118  //UtilRoad::PrintList(&m_road_list_pos_top, +1, +5, m_ofs);
119  //m_ofs << " Last Five\n";
120  //UtilRoad::PrintList(&m_road_list_pos_top, -5, -1, m_ofs);
121  //m_ofs << "Pos Bot: First Five\n";
122  //UtilRoad::PrintList(&m_road_list_pos_bot, +1, +5, m_ofs);
123  //m_ofs << " Last Five\n";
124  //UtilRoad::PrintList(&m_road_list_pos_bot, -5, -1, m_ofs);
125  //m_ofs << "Neg Top: First Five\n";
126  //UtilRoad::PrintList(&m_road_list_neg_top, +1, +5, m_ofs);
127  //m_ofs << " Last Five\n";
128  //UtilRoad::PrintList(&m_road_list_neg_top, -5, -1, m_ofs);
129  //m_ofs << "Neg Bot: First Five\n";
130  //UtilRoad::PrintList(&m_road_list_neg_bot, +1, +5, m_ofs);
131  //m_ofs << " Last Five\n";
132  //UtilRoad::PrintList(&m_road_list_neg_bot, -5, -1, m_ofs);
133 }
Definition: AnaBase.h:6
std::string m_branch_name
Definition: AnaBase.h:10
std::string m_tree_name
Definition: AnaBase.h:9
virtual void ProcessOneEvent()
Definition: AnaSignal.cc:70
virtual void Init()
Definition: AnaSignal.cc:35
virtual void End()
Definition: AnaSignal.cc:40
double m_mass_lo
Definition: AnaSignal.h:11
double m_mass_hi
Definition: AnaSignal.h:12
AnaSignal(const std::string label="ana_signal")
Definition: AnaSignal.cc:12
virtual ~AnaSignal()
Definition: AnaSignal.cc:24
RoadMap m_road_map_neg_top
Definition: AnaSignal.h:15
virtual void Analyze()
Definition: AnaSignal.cc:87
void SetMassRange(const double mass_lo, const double mass_hi)
Definition: AnaSignal.cc:29
RoadMap m_road_map_neg_bot
Definition: AnaSignal.h:16
virtual void ReadEvents(const char *fname="signal_tree.root")
Definition: AnaSignal.cc:45
SignalData * m_sig_data
Definition: AnaSignal.h:18
RoadMap m_road_map_pos_bot
Definition: AnaSignal.h:14
RoadMap m_road_map_pos_top
Definition: AnaSignal.h:13
void SetPNTB(const int pn, const int tb)
Definition: RoadListBase.h:17
Class to hold a non-ordered set (i.e. map) of roads.
Definition: RoadMap.h:8
void Add(const int road, const double weight, const int count=1)
Definition: RoadMap.cc:43
double weight
Definition: TreeData.h:8
double mass
Definition: TreeData.h:9
int road_pos
Definition: TreeData.h:18
int road_neg
Definition: TreeData.h:19