-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTigCut.cxx
More file actions
131 lines (111 loc) · 2.65 KB
/
Copy pathTigCut.cxx
File metadata and controls
131 lines (111 loc) · 2.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
// part of TigSortGUI
// author: Ulrike Hager
#include <iostream>
#include <sstream>
#include <TROOT.h>
#include "TigCut.h"
using std::string;
TigCut::TigCut()
:mCut(NULL)
{
ObjType = "Formula" ;
}
TigCut::~TigCut()
{
if (mCut) delete mCut;
}
bool
TigCut::Evaluate()
{
// std::cout << "[TigCut::Evaluate] " << mName << std::endl;
*IsUpdated = false;
for (int i = 0; i<InputData.size(); i++ ) {
if ( *(InputUpdated.at(i)) == false ) return false;
if ((InputData.at(i))->first != 1) return false;
}
int passed = 0;
switch (mWhatToDo){
case TCUTG:{
if (mCut->IsInside((InputData.at(0))->second[0],(InputData.at(1))->second[0] ) ){
passed = 1;
}break;
case RANGECUT: {
if ( ( (InputData.at(0))->second[0] >= mMinRange ) && ( (InputData.at(0))->second[0] <= mMaxRange ) ) passed = 1;
}break;
}
}
this->Update(1,&passed);
return true;
}
//---- Initialize
bool
TigCut::Initialize()
{
// std::cout << "[TigCut::Initialize] " << mName << std::endl;
bool check = this->TigDataObject::Initialize();
switch (mWhatToDo){
case TCUTG:{
if (mNeeded.size() != 2){
std::cout << "[TigCut::Initialize] TCutG " << mName <<" needs 2 inputs, found " << mNeeded.size() << std::endl;
return false;
}
string processLine = ".x " + mFile;
gROOT->ProcessLine(processLine.c_str());
mCut = (TCutG*)gROOT->FindObjectAny(mCutName.c_str());
if (!mCut) {
std::cout << "[TigCut::Initialize] no cut " << mCutName << std::endl;
return false;
}
}break;
case RANGECUT:{
if (mNeeded.size() != 1){
std::cout << "[TigCut::Initialize] " << mName << " cut needs 1 inputs" << std::endl;
return false;
}
if (mMaxRange < mMinRange){
std::cout << "[TigCut::Initialize] " << mName << " maximum range smaller than minimum" << std::endl;
return false;
}
} break;
}
this->SetNumData(1);
this->SetDataLength(1);
return true;
}
bool
TigCut::ParseInput(string line)
{
bool result = false;
string token;
std::istringstream stream(line.c_str());
stream >> token;
if (token.compare("tcutg") ==0){
string file, object;
stream >> file >> object;
this->SetCutName(file,object);
result = true;
}
else if (token.compare("range") ==0){
double min, max;
stream >> min >> max;
this->SetRange(min,max);
result = true;
}
else result = this->TigDataObject::ParseInput(line);
return result;
}
//---- SetCutName
void
TigCut::SetCutName(string pFile, string pObject)
{
mFile = pFile;
mCutName = pObject;
mWhatToDo = TCUTG;
}
void
TigCut::SetRange(double min, double max)
{
mMinRange = min;
mMaxRange = max;
mWhatToDo = RANGECUT;
}