Jpp 20.0.0-rc.2
the software that should make you happy
Loading...
Searching...
No Matches
JEventShapeVariables.cc File Reference

Auxiliary program to plot event shape variables. More...

#include <iostream>
#include <string>
#include <vector>
#include "km3net-dataformat/offline/Evt.hh"
#include "km3net-dataformat/offline/Trk.hh"
#include "JAAnet/JAAnetToolkit.hh"
#include "JAAnet/JLorentzBoost.hh"
#include "JAAnet/JEvtCategoryMap.hh"
#include "JSirene/JEventShapeVariables.hh"
#include "JDetector/JDetector.hh"
#include "JDetector/JDetectorToolkit.hh"
#include "JSupport/JSupport.hh"
#include "JSupport/JMultipleFileScanner.hh"
#include "JSupport/JEvtWeightFileScannerSet.hh"
#include "JSupport/JMonteCarloFileSupportkit.hh"
#include "Jeep/JeepToolkit.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"
#include "TFile.h"
#include "TH1D.h"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Auxiliary program to plot event shape variables.

Author
bjjung

Definition in file JEventShapeVariables.cc.

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Definition at line 36 of file JEventShapeVariables.cc.

37{
38 using namespace std;
39 using namespace JPP;
40
41 JMultipleFileScanner_t inputFiles;
42 string outputFile;
43 string detectorFile;
44
45 JLimit_t numberOfEvents;
46
47 bool useBoost;
48
49 bool useWeights;
50 JEvtWeightFactorMap weightFactorMap;
51
52 int debug;
53
54 try {
55
56 JParser<> zap("Auxiliary program to test event shape variables.");
57
58 zap['f'] = make_field(inputFiles);
59 zap['o'] = make_field(outputFile);
60 zap['a'] = make_field(detectorFile) = "";
61 zap['n'] = make_field(numberOfEvents) = JLimit::max();
62 zap['B'] = make_field(useBoost);
63 zap['W'] = make_field(useWeights);
64 zap['@'] = make_field(weightFactorMap)
66 zap['d'] = make_field(debug) = 3;
67
68 zap(argc, argv);
69 }
70 catch(const exception &error) {
71 FATAL(error.what() << endl);
72 }
73
74 if (useWeights && numberOfEvents != JLimit::max()) {
75 FATAL("Cannot apply weighting to limited number of events.");
76 }
77
78
79 // Load detector file
80
82
83 if (!detectorFile.empty()) {
84 try {
85 load(detectorFile, detector);
86 }
87 catch(const JException& error) {
88 FATAL(error);
89 }
90 }
91
92 JCylinder3D fiducialVolume;
93
94 if (!detector.empty()) {
95 fiducialVolume.set(detector.begin(), detector.end());
96 }
97
98
99 // Create file scanners
100
101 JEvtWeightFileScannerSet<> scanners(inputFiles);
102
103 if (scanners.setEvtWeightFactor(weightFactorMap) == 0) {
104 WARNING("No flux function set." << endl);
105 }
106
107
108 // Define histograms
109
110 TFile out(outputFile.c_str(), "recreate");
111
112 TH1D hT("hT", "thrust", 50, 0.5, 1.0);
113
114 TH1D hA("hA", "aplanarity", 50, 0.0, 0.5);
115 TH1D hS("hS", "sphericity", 100, 0.0, 1.0);
116 TH1D hc("hc", "circularity", 100, 0.0, 1.0);
117 TH1D hp("hp", "planar flow", 100, 0.0, 1.0);
118
119 TH1D hC("hC", "C-variable", 100, 0.0, 1.0);
120 TH1D hD("hD", "D-variable", 100, 0.0, 1.0);
121
122 TH1D hH10("hH10", "H10", 100, 0.0, 1.0);
123 TH1D hH20("hH20", "H20", 100, 0.0, 1.0);
124 TH1D hH30("hH30", "H30", 100, 0.0, 1.0);
125 TH1D hH40("hH40", "H40", 100, 0.0, 1.0);
126
127 TH1D hq("hq", "Logarithmic eigenvalue ratio hit inertia tensor", 200, -20.0, 0.0);
128
129
130 // Loop over events
131
132 STATUS(RIGHT(15) << "header ID" << RIGHT(15) << "event" << RIGHT(15) << "weight" << endl);
133
134 for (JEvtWeightFileScannerSet<>::iterator scanner = scanners.begin(); scanner != scanners.end(); ++scanner) {
135
136 const JHead& header = scanner->getHeader();
137
138 if (detector.empty()) { // Use can volume if detector file has not been specified
139 fiducialVolume = getCylinder(header);
140 }
141
142 for (JMultipleFileScanner<Evt> in(scanner->getFilelist(), numberOfEvents); in.hasNext(); ) {
143
144 Evt* event = in.next();
145
146 const double weight = (useWeights ? scanner->getWeight(*event) : 1.0);
147
148 STATUS(RIGHT (15) << distance(scanners.begin(), scanner) <<
149 RIGHT (15) << in.getCounter() <<
150 SCIENTIFIC(15, 3) << weight << '\r'); DEBUG(endl);
151
152 if (useBoost) { boostToCOM(*event); }
153
154 const JVertex3D vertex = getVertex(*event);
155
156 const JSphericityTensor S1(*event, 1.0);
157 const JSphericityTensor S2(*event, 2.0);
158
159 const JFoxWolframMoments H(*event, fiducialVolume, 4);
160
161 const JHitInertiaTensor Q(*event, vertex);
162
163 const double thrust = getThrust(*event);
164
165 const double aplanarity = S2.getAplanarity();
166 const double sphericity = S2.getSphericity();
167 const double circularity = S2.getCircularity();
168 const double planarflow = S2.getPlanarFlow();
169
170 const double C = S1.getC();
171 const double D = S1.getD();
172
173 const double q = Q.getEigenvalueRatio();
174
175 hT.Fill(thrust, weight);
176
177 hA.Fill(aplanarity, weight);
178 hS.Fill(sphericity, weight);
179 hc.Fill(circularity, weight);
180 hp.Fill(planarflow, weight);
181
182 hC.Fill(C, weight);
183 hD.Fill(D, weight);
184
185 hH10.Fill(H[1]/H[0], weight);
186 hH20.Fill(H[2]/H[0], weight);
187 hH30.Fill(H[3]/H[0], weight);
188 hH40.Fill(H[4]/H[0], weight);
189
190 hq.Fill(log10(q), weight);
191 }
192 }
193
194 STATUS(endl);
195
196 out.Write();
197 out.Close();
198
199 return 0;
200}
string outputFile
#define DEBUG(A)
Message macros.
Definition JMessage.hh:62
#define STATUS(A)
Definition JMessage.hh:63
#define FATAL(A)
Definition JMessage.hh:67
int debug
debug level
Definition JSirene.cc:72
#define WARNING(A)
Definition JMessage.hh:65
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
Template specialisation for a map between event categories and event-weight factor products.
Monte Carlo run header.
Definition JHead.hh:1236
const JHead & getHeader() const
Get header.
Definition JHead.hh:1270
Detector data structure.
Definition JDetector.hh:96
void set(const JVector2D &p0, const JVector2D &p1)
Set circle.
Definition JCircle2D.hh:157
General exception.
Definition JException.hh:24
Utility class to parse command line options.
Definition JParser.hh:1698
General purpose class for object reading from a list of file names.
virtual bool hasNext() override
Check availability of next element.
#define S1(x)
void boostToCOM(Evt &event)
Boost event to the Center of Mass (COM) frame.
JCylinder3D getCylinder(const JHead &header)
Get cylinder corresponding to the positions of generated tracks (i.e.
JVertex3D getVertex(const Trk &track)
Get vertex.
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
@ RIGHT
Definition JTwosome.hh:18
static const double H
Planck constant [eV s].
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
double getThrust(const std::vector< Trk >::const_iterator __begin, const std::vector< Trk >::const_iterator __end)
Compute thrust for a given range of tracks.
The Evt class respresent a Monte Carlo (MC) event as well as an offline event.
Definition Evt.hh:21
Detector file.
Definition JHead.hh:227
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Definition JParser.hh:68
Class for computing Fox-Wolfram moments.
Class for hit inertia tensor calculations.
Class for sphericity tensor calculations.
Auxiliary class for organising Monte Carlo file scanners associated with event weighters.
Auxiliary class for defining the range of iterations of objects.
Definition JLimit.hh:45
static counter_type max()
Get maximum counter value.
Definition JLimit.hh:128
Auxiliary base class for list of file names.
Auxiliary data structure for alignment of data.
Definition JManip.hh:298
Auxiliary data structure for floating point format specification.
Definition JManip.hh:488