CGEM BOSS 6.6.5.h
BESIII Offline Software System
Loading...
Searching...
No Matches
NTupleHelper Class Reference

#include <NTupleHelper.h>

Public Member Functions

 NTupleHelper (NTuple::Tuple *Tree)
 
void fillDouble (string name, double value)
 
void fillLong (string name, long value)
 
void fillArray (string name, string index_name, double *value, int size)
 
void fillArrayLong (string name, string index_name, long *value, int size)
 
void fillArrayInt (string name, string index_name, int *value, int size)
 
void write ()
 

Detailed Description

Definition at line 19 of file NTupleHelper.h.

Constructor & Destructor Documentation

◆ NTupleHelper()

NTupleHelper::NTupleHelper ( NTuple::Tuple * Tree)

Definition at line 9 of file NTupleHelper.cxx.

9 {
10 m_Tree = Tree;
11 m_bookingStage = true;
12
13 if( m_Tree == NULL )
14 cout << "ERROR: null tree pointer -- "
15 << "check for duplicate final states in configuration"
16 << endl;
17 assert( m_Tree != NULL );
18}

Member Function Documentation

◆ fillArray()

void NTupleHelper::fillArray ( string name,
string index_name,
double * value,
int size )

Definition at line 99 of file NTupleHelper.cxx.

99 {
100
101 if (m_bookingStage && !containsEntry(index_name)){
102 m_Tree->addItem(index_name, m_ntupleLongMap[index_name], 0, 100);
103 }
104
105 m_longMap[index_name]=size;
106
107 if (m_bookingStage && !containsEntry(name)){
108 m_Tree->addIndexedItem(name, m_ntupleLongMap[index_name], m_ntupleArrayMap[name]);
109 }
110
111 if (!m_bookingStage && !containsEntry(name)){
112 cout << "NTUPLEHELPER: Variable " << name << " has not been booked." << endl;
113 exit(0);
114 }
115
116 if (!m_bookingStage && !containsEntry(index_name)){
117 cout << "NTUPLEHELPER: Variable " << index_name << " has not been booked." << endl;
118 exit(0);
119 }
120
121 m_arrayMap[name]= new double[100];
122 for(int i=0; i<size; i++){
123 //printf("value %2d = %10f\n", i, *(value+i));
124 m_arrayMap[name][i] = *(value+i);
125 }
126}

◆ fillArrayInt()

void NTupleHelper::fillArrayInt ( string name,
string index_name,
int * value,
int size )

Definition at line 157 of file NTupleHelper.cxx.

157 {
158
159 if (m_bookingStage && !containsEntry(index_name)){
160 m_Tree->addItem(index_name, m_ntupleLongMap[index_name], 0, 100);
161 }
162
163 m_longMap[index_name]=size;
164
165 if (m_bookingStage && !containsEntry(name)){
166 m_Tree->addIndexedItem(name, m_ntupleLongMap[index_name], m_ntupleArrayIntMap[name]);
167 }
168
169 if (!m_bookingStage && !containsEntry(name)){
170 cout << "NTUPLEHELPER: Variable " << name << " has not been booked." << endl;
171 exit(0);
172 }
173
174 if (!m_bookingStage && !containsEntry(index_name)){
175 cout << "NTUPLEHELPER: Variable " << index_name << " has not been booked." << endl;
176 exit(0);
177 }
178
179 m_arrayIntMap[name]= new int[100];
180 for(int i=0; i<size; i++){
181 //printf("value %2d = %10f\n", i, *(value+i));
182 m_arrayIntMap[name][i] = *(value+i);
183 }
184}

◆ fillArrayLong()

void NTupleHelper::fillArrayLong ( string name,
string index_name,
long * value,
int size )

Definition at line 128 of file NTupleHelper.cxx.

128 {
129
130 if (m_bookingStage && !containsEntry(index_name)){
131 m_Tree->addItem(index_name, m_ntupleLongMap[index_name], 0, 100);
132 }
133
134 m_longMap[index_name]=size;
135
136 if (m_bookingStage && !containsEntry(name)){
137 m_Tree->addIndexedItem(name, m_ntupleLongMap[index_name], m_ntupleArrayLongMap[name]);
138 }
139
140 if (!m_bookingStage && !containsEntry(name)){
141 cout << "NTUPLEHELPER: Variable " << name << " has not been booked." << endl;
142 exit(0);
143 }
144
145 if (!m_bookingStage && !containsEntry(index_name)){
146 cout << "NTUPLEHELPER: Variable " << index_name << " has not been booked." << endl;
147 exit(0);
148 }
149
150 m_arrayLongMap[name]= new long[100];
151 for(int i=0; i<size; i++){
152 //printf("value %2d = %10f\n", i, *(value+i));
153 m_arrayLongMap[name][i] = *(value+i);
154 }
155}

◆ fillDouble()

void NTupleHelper::fillDouble ( string name,
double value )

Definition at line 75 of file NTupleHelper.cxx.

75 {
76 if (m_bookingStage && !containsEntry(name)){
77 m_Tree->addItem(name,m_ntupleDoubleMap[name]);
78 }
79 if (!m_bookingStage && !containsEntry(name)){
80 cout << "NTUPLEHELPER: Variable " << name << " has not been booked." << endl;
81 exit(0);
82 }
83 m_doubleMap[name] = value;
84}

◆ fillLong()

void NTupleHelper::fillLong ( string name,
long value )

Definition at line 86 of file NTupleHelper.cxx.

86 {
87 if (m_bookingStage && !containsEntry(name)){
88 m_Tree->addItem(name,m_ntupleLongMap[name]);
89 }
90 if (!m_bookingStage && !containsEntry(name)){
91 cout << "NTUPLEHELPER: Variable " << name << " has not been booked." << endl;
92 exit(0);
93 }
94 m_longMap[name] = value;
95}

◆ write()

void NTupleHelper::write ( )

Definition at line 22 of file NTupleHelper.cxx.

22 {
23
24 for (map<string,double>::iterator mapItr = m_doubleMap.begin();
25 mapItr != m_doubleMap.end(); mapItr++){
26 m_ntupleDoubleMap[mapItr->first] = mapItr->second;
27 }
28
29 for (map<string,long>::iterator mapItr = m_longMap.begin();
30 mapItr != m_longMap.end(); mapItr++){
31 m_ntupleLongMap[mapItr->first] = mapItr->second;
32 }
33
34 for (map<string,double*>::iterator mapItr = m_arrayMap.begin();
35 mapItr != m_arrayMap.end(); mapItr++){
36 for(int i=0; i< 100; i++) {
37 m_ntupleArrayMap[mapItr->first][i] = *(mapItr->second + i);
38 }
39 }
40
41 for (map<string,long*>::iterator mapItr = m_arrayLongMap.begin();
42 mapItr != m_arrayLongMap.end(); mapItr++){
43 for(int i=0; i< 100; i++) {
44 m_ntupleArrayLongMap[mapItr->first][i] = *(mapItr->second + i);
45 }
46 }
47
48 for (map<string,int*>::iterator mapItr = m_arrayIntMap.begin();
49 mapItr != m_arrayIntMap.end(); mapItr++){
50 for(int i=0; i< 100; i++) {
51 m_ntupleArrayIntMap[mapItr->first][i] = *(mapItr->second + i);
52 }
53 }
54
55 m_Tree->write();
56
57 for (map<string,double*>::iterator mapItr = m_arrayMap.begin();
58 mapItr != m_arrayMap.end(); mapItr++){
59 delete mapItr->second;
60 }
61 for (map<string,long*>::iterator mapItr = m_arrayLongMap.begin();
62 mapItr != m_arrayLongMap.end(); mapItr++){
63 delete mapItr->second;
64 }
65 for (map<string,int*>::iterator mapItr = m_arrayIntMap.begin();
66 mapItr != m_arrayIntMap.end(); mapItr++){
67 delete mapItr->second;
68 }
69 m_bookingStage = false;
70 //cout<<mapItr->first<<" "<<sizeof(*(mapItr->second))<<endl;
71 //for(int i=0; i<m_ntupleLongMap["idx_mc"]; i++) {
72}

The documentation for this class was generated from the following files: