Jpp  18.3.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JEventShapeVariables.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <string>
3 #include <vector>
4 
7 
11 
14 
16 
17 #include "JDetector/JDetector.hh"
19 
20 #include "JSupport/JSupport.hh"
24 
25 #include "Jeep/JeepToolkit.hh"
26 #include "Jeep/JParser.hh"
27 #include "Jeep/JMessage.hh"
28 
29 #include "TFile.h"
30 #include "TH1D.h"
31 
32 
33 /**
34  * \file
35  *
36  * Auxiliary program to plot event shape variables.
37  * \author bjjung
38  */
39 int main(int argc, char **argv)
40 {
41  using namespace std;
42  using namespace JPP;
43 
44  JMultipleFileScanner_t inputFiles;
45  string outputFile;
46  string detectorFile;
47 
48  JLimit_t numberOfEvents;
49 
50  bool useBoost;
51 
52  bool useWeights;
53  JFluxMap fluxMaps;
54 
55  string oscProbTable;
56  JOscParameters<> oscParameters;
57 
58  int debug;
59 
60  try {
61 
62  JParser<> zap("Auxiliary program to test event shape variables.");
63 
64  zap['f'] = make_field(inputFiles);
65  zap['o'] = make_field(outputFile);
66  zap['a'] = make_field(detectorFile) = "";
67  zap['n'] = make_field(numberOfEvents) = JLimit::max();
68  zap['B'] = make_field(useBoost);
69  zap['W'] = make_field(useWeights);
70  zap['@'] = make_field(fluxMaps)
72  zap['P'] = make_field(oscProbTable)
74  zap['#'] = make_field(oscParameters)
76  zap['d'] = make_field(debug) = 3;
77 
78  zap(argc, argv);
79  }
80  catch(const exception &error) {
81  FATAL(error.what() << endl);
82  }
83 
84  if (useWeights && numberOfEvents != JLimit::max()) {
85  FATAL("Cannot apply weighting to limited number of events.");
86  }
87 
88 
89  // Load detector file
90 
92 
93  if (!detectorFile.empty()) {
94  try {
95  load(detectorFile, detector);
96  }
97  catch(const JException& error) {
98  FATAL(error);
99  }
100  }
101 
102  JCylinder3D fiducialVolume;
103 
104  if (!detector.empty()) {
105  fiducialVolume.set(detector.begin(), detector.end());
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  // Create file scanners
131 
132  JEvtWeightFileScannerSet<> scanners(inputFiles);
133 
134  if (!oscProbTable.empty()) {
135 
136  JOscProbInterpolator<> interpolator(oscProbTable.c_str(), oscParameters);
137 
138  fluxMaps.configure(make_oscProbFunction(interpolator));
139  }
140 
141  if (scanners.setFlux(fluxMaps) == 0) {
142  WARNING("No flux function set." << endl);
143  }
144 
145  STATUS(RIGHT(15) << "header ID" << RIGHT(15) << "event" << RIGHT(15) << "weight" << endl);
146 
147  // Loop over events
148 
149  for (JEvtWeightFileScannerSet<>::iterator scanner = scanners.begin(); scanner != scanners.end(); ++scanner) {
150 
151  scanner->setLimit(numberOfEvents);
152 
153  const JHead& header = scanner->getHeader();
154 
155  if (detector.empty()) { // Use can volume if detector file has not been specified
156  fiducialVolume = get<JCylinder3D>(header);
157  }
158 
159  while (scanner->hasNext()) {
160 
161  Evt* event = scanner->next();
162 
163  const double weight = (useWeights ? scanner->getWeight(*event) : 1.0);
164 
165  STATUS(RIGHT (15) << distance(scanners.begin(), scanner) <<
166  RIGHT (15) << scanner->getCounter() <<
167  SCIENTIFIC(15, 3) << weight << '\r'); DEBUG(endl);
168 
169  if (useBoost) { boostToCOM(*event); }
170 
171  const JVertex3D vertex = getVertex(*event);
172 
173  const JSphericityTensor S1(*event, 1.0);
174  const JSphericityTensor S2(*event, 2.0);
175 
176  const JFoxWolframMoments H(*event, fiducialVolume, 4);
177 
178  const JHitInertiaTensor Q(*event, vertex);
179 
180  const double thrust = getThrust(*event);
181 
182  const double aplanarity = S2.getAplanarity();
183  const double sphericity = S2.getSphericity();
184  const double circularity = S2.getCircularity();
185  const double planarflow = S2.getPlanarFlow();
186 
187  const double C = S1.getC();
188  const double D = S1.getD();
189 
190  const double q = Q.getEigenvalueRatio();
191 
192  hT.Fill(thrust, weight);
193 
194  hA.Fill(aplanarity, weight);
195  hS.Fill(sphericity, weight);
196  hc.Fill(circularity, weight);
197  hp.Fill(planarflow, weight);
198 
199  hC.Fill(C, weight);
200  hD.Fill(D, weight);
201 
202  hH10.Fill(H[1]/H[0], weight);
203  hH20.Fill(H[2]/H[0], weight);
204  hH30.Fill(H[3]/H[0], weight);
205  hH40.Fill(H[4]/H[0], weight);
206 
207  hq.Fill(log10(q), weight);
208  }
209  }
210 
211  STATUS(endl);
212 
213  out.Write();
214  out.Close();
215 
216  return 0;
217 }
JVertex3D getVertex(const Trk &track)
Get vertex.
Utility class to parse command line options.
Definition: JParser.hh:1514
General exception.
Definition: JException.hh:24
#define WARNING(A)
Definition: JMessage.hh:65
Class for hit inertia tensor calculations.
Q(UTCMax_s-UTCMin_s)-livetime_s
int main(int argc, char *argv[])
Definition: Main.cc:15
ROOT TTree parameter settings of various packages.
void boostToCOM(Evt &event)
Boost event to the Center of Mass (COM) frame.
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
#define STATUS(A)
Definition: JMessage.hh:63
Detector data structure.
Definition: JDetector.hh:89
Class for computing Fox-Wolfram moments.
static const double H
Planck constant [eV s].
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Definition: JParser.hh:83
string outputFile
Data structure for detector geometry and calibration.
Event shape variables.
static const double C
Physics constants.
double getD() const
Get D-variable.
Auxiliary class for defining the range of iterations of objects.
Definition: JLimit.hh:41
Cylinder object.
Definition: JCylinder3D.hh:39
Detector file.
Definition: JHead.hh:226
Class for sphericity tensor calculations.
#define S1(x)
Monte Carlo run header.
Definition: JHead.hh:1234
double getC() const
Get C-variable.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1989
set_variable E_E log10(E_{fit}/E_{#mu})"
JOscProbFunction< JFunction_t > make_oscProbFunction(const JFunction_t &function)
Auxiliary method for creating an interface to an oscillation probability function.
Auxiliary methods for handling file names, type names and environment.
Auxiliary methods for calculating Lorentz boosts.
Definition of hit and track types and auxiliary methods for handling Monte Carlo data.
double getAplanarity() const
Get aplanarity.
Auxiliary class for parsing multiparticle fluxes.
General purpose messaging.
#define FATAL(A)
Definition: JMessage.hh:67
Scanning of objects from multiple files according a format that follows from the extension of each fi...
double getSphericity() const
Get sphericity.
Auxiliary base class for list of file names.
Data structure for single set of oscillation parameters.
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
std::vector< filescanner_type >::iterator iterator
double getCircularity() const
Get circularity.
Utility class to parse command line options.
size_t setFlux(const int type, const JFlux &flux)
Set flux function for all MC-files corresponding to a given PDG code.
const JHead & getHeader() const
Get header.
Definition: JHead.hh:1270
Auxiliary class for organising Monte Carlo file scanners associated with event weighters.
void set(const JVector2D &p0, const JVector2D &p1)
Set circle.
Definition: JCircle2D.hh:157
double getEigenvalueRatio() const
Get eigenvalue ratio.
do set_variable DETECTOR_TXT $WORKDIR detector
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:486
do echo Generating $dir eval D
Definition: JDrawLED.sh:53
double getPlanarFlow() const
Get planar flow.
Template definition of a multi-dimensional oscillation probability interpolation table.
int debug
debug level
The Evt class respresent a Monte Carlo (MC) event as well as an offline event.
Definition: Evt.hh:20
double getThrust(const std::vector< Trk >::const_iterator __begin, const std::vector< Trk >::const_iterator __end)
Compute thrust for a given range of tracks.
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62