/
upsilon_finder.cpp
194 lines (163 loc) · 4.66 KB
/
upsilon_finder.cpp
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
/*
* upsilon_finder.cpp
*
* Created on: Aug 21, 2012
* Author: magania
*/
#include <getopt.h>
#include <AA.hpp>
#include <Ana.hpp>
#include <AA.hpp>
#include <Trg.hpp>
#include <Muo.hpp>
#include <Ptl.hpp>
#include <DST.hpp>
#include <Field.hpp>
#include <Spot.hpp>
#include <select.hpp>
#include <Monitor.hpp>
#include <V0Finder.hpp>
#include <TTree.h>
#include <TFile.h>
#include "EvtSaver.h"
#include "UpsilonFinder.h"
void params() {
//Parameters for Real Data and MC
AA::debugLevel = 0;
// AA::firstEventIn = 6539424; // Optional first event to be processed
AA::monitor.set("AA_ElmBox_Maps", 2, 2);
AA::monitor.set("AA_State5_Chi2", 10, 2);
// AA::monitor.set("AA_DST_Field",100,1);
AA::xBeamDefault = -0.030;
AA::yBeamDefault = +0.030;
AA::nTrkMinVrt = 5; //It defines the minimal number of tracks in the primary vertex.
AA::correctMomentum = false;
//parameters for jet finding (see PYTHIA description)
AA::mstu[46] = 5;
AA::paru[44] = 15.;
//definition of input blocks
AA::blocksIn.clear();
//definition of output blocks
AA::blocksOut.clear();
AA::tuneImpact = false;
// :)
AA::findPVFlag = true;
AA::findSVFlag = true;
AA::findV0Flag = false;
AA::findCascadeFlag = false;
AA::findJetsFlag = false;
AA::findJPsiFlag = false;
}
bool nextEvent() {
AA::newEvent();
AA::newAnaEvent();
AA::newSelectEvent();
return AA::dst.getEvent();
}
void usage(void) {
printf("\n");
printf("\033[1mUsage: up_finder [options].\033[m \n");
printf("options:\n");
printf("\t \033[1m-i\033[m input_file \t Set the file to process.\n\n");
printf("\t \033[1m--mc\033[m \t Process MC events.\n");
printf("\t \033[1m--elist\033[m \t Understand input_file as an elist.\n\n");
printf("Report bugs to <magania@fnal.gov>.\n");
exit(EXIT_FAILURE);
}
int main(int argc, char** argv) {
static int mc = false;
static int elist = false;
const char *input_file = 0;
int c;
while (1) {
static struct option long_options[] ={
/* These options set a flag. */
{"mc" , no_argument, &mc , 1},
{"elist" , no_argument, &elist , 1},
{0, 0, 0, 0}
};
/* getopt_long stores the option index here. */
int option_index = 0;
c = getopt_long(argc, argv, "i:",
long_options, &option_index);
/* Detect the end of the options. */
if (c == -1)
break;
switch (c) {
case 0:
/* If this option set a flag, do nothing else now. */
if (long_options[option_index].flag != 0)
break;
case 'i':
input_file = optarg;
break;
case '?':
usage();
default:
usage();
}
}
if (!input_file){
std::cout << argv[0] << " II: Missing input_file " << std::endl;
usage();
}
AA::newJob();
AA::newAnaJob();
AA::newSelectJob();
params();
AA::displayParameters();
bool ok = false;
if (elist){
std::cout << argv[0] << " II: Doing event lists " << std::endl;
ok = AA::dst.eventLst(input_file);
} else {
std::cout << argv[0] << " II: Doing sequential mode" << std::endl;
ok = AA::dst.fileLst(input_file);
}
if (!ok) {
std::cout << argv[0] << " EE: Input stream is not valid or is empty." << std::endl;
exit(EXIT_FAILURE);
}
/* ================================ MAIN ===================================*/
/* -- We will save all in this tree --*/
TFile root_file("upsilon.root", "RECREATE");
TTree tree("tree", "all info.");
TTree *treeMC=0;
if (mc)
treeMC = new TTree("treeMC", "all mc info.");
EvtSaver evt_saver(tree);
UpsilonFinder upsilon_finder(tree);
/* -- Initilization of geometry, field and beam spot.
* Should be done after the fileLst or eventLst initilization -- */
AA::det.input();
AA::field.input();
AA::spot.input();
AA::newEvent();
AA::newAnaEvent();
AA::newSelectEvent();
unsigned long p_events = 0;
while (nextEvent()) {
p_events++;
AA::setField(); //define beam-spot and field value
AA::spot.set();
AA::analyse();
AA::select(AA::TAG);
//std::cout << "Run:" << AA::runNumber << " Evt: " << AA::evtNumber << std::endl;
if (!upsilon_finder.find())
continue;
while (upsilon_finder.next()){
// std::cout << xyg_finder.getMass() << ' ' << std::endl;
upsilon_finder.fill();
evt_saver.fill();
tree.Fill();
}
AA::dst.outEventLst("upsilon_elist");
}//End while next event.
tree.Write();
if (mc)
treeMC->Write();
root_file.Write();
root_file.Close();
std::cout << argv[0] << " II: upsilon_finder ended. " << p_events << " events seen."<< std::endl;
std::exit(EXIT_SUCCESS);
}