46 inline const char*
const track_t() {
return "track"; }
47 inline const char*
const shower_t() {
return "shower"; }
58 int main(
int argc,
char **argv)
62 using namespace KM3NETDAQ;
95 JParser<> zap(
"Example program to analyse track fit results from Evt formatted data.");
121 catch(
const exception& error) {
122 FATAL(error.what() << endl);
125 if (useWeights && numberOfEvents != JLimit::max()) {
126 FATAL(
"Cannot apply weighting to limited number of events.");
134 if (detectorFile !=
"") {
148 bool (*has_reconstruction)(
const Evt&);
149 const Trk& (*get_best_fit)(
const Evt&);
154 }
else if (recotype == shower_t()) {
158 FATAL(
"Invalid recotype: " << recotype);
164 const Int_t N_Nhits = 400;
165 const Double_t Nhits_min = 0.0 - 0.5;
166 const Double_t Nhits_max = 1000.0 - 0.5;
168 const Int_t N_Noverlays = 40;
169 const Double_t Noverlays_min = 0.0 - 0.5;
170 const Double_t Noverlays_max = 1000.0 - 0.5;
172 const Int_t N_radius = 201;
173 const Double_t radius_min = -700.0 - 0.5;
174 const Double_t radius_max = +700.0 + 0.5;
176 const Int_t N_height = 18;
177 const Double_t height_min = 20.0;
178 const Double_t height_max = 200.0;
180 const Int_t N_ToTfrac = 20;
181 const Double_t ToTfrac_min = 0.0;
182 const Double_t ToTfrac_max = 1.0;
184 const Int_t N_dt = 1500;
185 const Double_t dt_min = -500.0 - 0.5;
186 const Double_t dt_max = 1000.0 - 0.5;
188 const Int_t N_zenith = 21;
189 const Double_t zenith_min = -1.0;
190 const Double_t zenith_max = +1.0;
192 const Int_t N_energy = 60;
193 const Double_t energy_min = -2.0;
194 const Double_t energy_max = 4.0;
196 const Int_t N_quality = 100;
197 const Double_t quality_min = -200.0;
198 const Double_t quality_max = +800.0;
200 const Int_t N_beta0 = 60;
201 const Double_t beta0_min = -2.0;
202 const Double_t beta0_max = +3.5;
207 string ordinateLabel(useWeights ?
"Rate [Hz]" :
"Number of events");
211 TH1D hs (
"hs",
MAKE_CSTRING(
"; #snapshot hits; " << ordinateLabel),
212 N_Nhits, Nhits_min, Nhits_max);
213 TH1D hn (
"hn",
MAKE_CSTRING(
"; #triggered hits; " << ordinateLabel),
214 N_Nhits, Nhits_min, Nhits_max);
215 TH1D ho (
"ho",
MAKE_CSTRING(
"; #overlays; " << ordinateLabel),
216 N_Noverlays, Noverlays_min, Noverlays_max);
218 TH1D hz (
"hz",
MAKE_CSTRING(
"; cos(#theta); " << ordinateLabel),
219 N_zenith, zenith_min, zenith_max);
220 TH1D he (
"he",
MAKE_CSTRING(
"; log_{10}(E_{reco} / 1 GeV); " << ordinateLabel),
221 N_energy, energy_min, energy_max);
222 TH1D ht (
"ht",
MAKE_CSTRING(
"; #Delta t [ns]; " << ordinateLabel),
223 N_dt, dt_min, dt_max);
225 TH1D hZ (
"hZ",
MAKE_CSTRING(
"; longitudinal ToT-barycenter [m]; " << ordinateLabel),
226 N_height, height_min, height_max);
227 TH1D hT0 (
"hT0",
MAKE_CSTRING(
"; ToT-fraction below earliest triggered hit [ns]; " << ordinateLabel),
228 N_ToTfrac, ToTfrac_min, ToTfrac_max);
229 TH1D hT1 (
"hT1",
MAKE_CSTRING(
"; ToT-fraction above earliest triggered hit [ns]; " << ordinateLabel),
230 N_ToTfrac, ToTfrac_min, ToTfrac_max);
232 TH1D hq (
"hq",
MAKE_CSTRING(
"; quality; " << ordinateLabel),
233 N_quality, quality_min, quality_max);
234 TH1D hb0 (
"hb0",
MAKE_CSTRING(
"; #beta_{0}; " << ordinateLabel),
235 N_beta0, beta0_min, beta0_max);
237 TH2D hzo (
"hzo",
MAKE_CSTRING(
"; cos(#theta); #overlays; " << ordinateLabel),
238 N_zenith, zenith_min, zenith_max,
239 N_Noverlays, Noverlays_min, Noverlays_max);
240 TH2D hze (
"hze",
MAKE_CSTRING(
"; cos(#theta); log_{10}(E_{reco} / 1 GeV); " << ordinateLabel),
241 N_zenith, zenith_min, zenith_max,
242 N_energy, energy_min, energy_max);
243 TH2D heo (
"heo",
MAKE_CSTRING(
"; log_{10}(E_{reco} / 1 GeV); #overlays; " << ordinateLabel),
244 N_energy, energy_min, energy_max,
245 N_Noverlays, Noverlays_min, Noverlays_max);
246 TH2D hzt (
"hzt",
MAKE_CSTRING(
"; cos(#theta); #Delta t [ns]; " << ordinateLabel),
247 N_zenith, zenith_min, zenith_max,
248 N_dt, dt_min, dt_max);
249 TH2D het (
"het",
MAKE_CSTRING(
"; log_{10}(E_{reco} / 1 GeV); #Delta t [ns]; " << ordinateLabel),
250 N_energy, energy_min, energy_max,
251 N_dt, dt_min, dt_max);
252 TH2D hot (
"hot",
MAKE_CSTRING(
"; #overlays; #Delta t [ns]; " << ordinateLabel),
253 N_Noverlays, Noverlays_min, Noverlays_max,
254 N_dt, dt_min, dt_max);
256 TH2D hzq (
"hzq",
MAKE_CSTRING(
"; cos(#theta); quality; " << ordinateLabel),
257 N_zenith, zenith_min, zenith_max,
258 N_quality, quality_min, quality_max);
259 TH2D heq (
"heq",
MAKE_CSTRING(
"; log_{10}(E_{reco} / 1 GeV); quality; " << ordinateLabel),
260 N_energy, energy_min, energy_max,
261 N_quality, quality_min, quality_max);
262 TH2D hoq (
"hoq",
MAKE_CSTRING(
"; #overlays; quality; " << ordinateLabel),
263 N_Noverlays, Noverlays_min, Noverlays_max,
264 N_quality, quality_min, quality_max);
266 TH2D hob0(
"hob0",
MAKE_CSTRING(
"; #overlays; log_{10}(#beta_{0}); " << ordinateLabel),
267 N_Noverlays, Noverlays_min, Noverlays_max,
268 N_beta0, beta0_min, beta0_max);
269 TH2D heb0(
"heb0",
MAKE_CSTRING(
"; log_{10}(E_{reco} / 1 GeV); log_{10}(#beta_{0}); " << ordinateLabel),
270 N_energy, energy_min, energy_max,
271 N_beta0, beta0_min, beta0_max);
272 TH2D hzb0(
"hzb0",
MAKE_CSTRING(
"; cos(#theta); log_{10}(#beta_{0}); " << ordinateLabel),
273 N_zenith, zenith_min, zenith_max,
274 N_beta0, beta0_min, beta0_max);
276 TH2D hxy (
"hxy",
MAKE_CSTRING(
"; x [m]; y [m]; " << ordinateLabel),
277 N_radius, radius_min, radius_max,
278 N_radius, radius_min, radius_max);
283 if (!oscProbTable.empty()) {
290 if (scanners.
setFlux(fluxMaps) == 0) {
291 WARNING(
"No flux function set." << endl);
298 scanner->setLimit(numberOfEvents);
300 while (scanner->hasNext()) {
302 const Evt* evt = scanner->next();
304 const double weight = (useWeights ? scanner->getWeight(*evt) : 1.0);
306 const size_t NsnapshotHits = evt->
hits.size();
307 const size_t NtriggeredHits = count_if(evt->
hits.begin(), evt->
hits.end(),
310 if (!triggeredHitsRange(NtriggeredHits)) {
continue; }
312 hs .Fill(NsnapshotHits, weight);
313 hn .Fill(NtriggeredHits, weight);
316 if (!has_reconstruction(*evt)) {
continue; }
318 const Trk& best_trk = (*get_best_fit)(*evt);
323 if (!energyRange (tb.
getE()) ||
324 !coszenithRange(tb.
getDZ()) ||
332 RIGHT (15) << scanner->getCounter() <<
337 hz .Fill(tb.
getDZ(), weight);
338 he .Fill(logE, weight);
339 hq .Fill(best_trk.
lik, weight);
341 hzo.Fill(tb.
getDZ(), evt->overlays, weight);
342 hze.Fill(tb.
getDZ(), logE, weight);
343 heo.Fill(logE, evt->overlays, weight);
345 hoq.Fill(evt->overlays, best_trk.
lik, weight);
346 hzq.Fill(tb.
getDZ(), best_trk.
lik, weight);
347 heq.Fill(logE, best_trk.
lik, weight);
349 hxy.Fill(tb.
getX(), tb.
getY(), weight);
355 hb0 .Fill(logb0, weight);
356 hob0.Fill(evt->overlays, logb0, weight);
357 heb0.Fill(logE, logb0, weight);
358 hzb0.Fill(tb.
getDZ(), logb0, weight);
361 double ToTbelow = 0.0;
362 double ToTabove = 0.0;
363 double ToTtotal = 0.0;
364 double ToTweightedZ = 0.0;
371 if (router.
hasPMT(hit->pmt_id)) {
375 const double t0 = tb.
getT(pmt);
376 const double t1 =
getTime(*hit);
378 ht .Fill(t1 - t0, weight);
379 hot.Fill(evt->overlays, t1 - t0, weight);
380 hzt.Fill(tb.
getDZ(), t1 - t0, weight);
381 het.Fill(
log10(best_trk.
E), t1 - t0, weight);
385 ToTtotal += hit->tot;
386 ToTweightedZ += hit->tot * hit->pos.z;
388 if (hit->pos.z < firstHit->pos.z) {
389 ToTbelow += hit->tot;
390 }
else if (hit->pos.z >= firstHit->pos.z) {
391 ToTabove += hit->tot;
397 hT0.Fill(ToTbelow / ToTtotal, weight);
398 hT1.Fill(ToTabove / ToTtotal, weight);
399 hZ .Fill(ToTweightedZ / ToTtotal, weight);
Router for direct addressing of PMT data in detector data structure.
Utility class to parse command line options.
JPredicate< JResult_t T::*, JComparison::eq > make_predicate(JResult_t T::*member, const JResult_t value)
Helper method to create predicate for data member.
int main(int argc, char *argv[])
ROOT TTree parameter settings of various packages.
JComparator< JResult_t T::*, JComparison::lt > make_comparator(JResult_t T::*member)
Helper method to create comparator between values of data member.
JTrack3E getTrack(const Trk &track)
Get track.
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
#define gmake_property(A)
macros to convert (template) parameter to JPropertiesElement object
Utility class to parse parameter values.
#define MAKE_CSTRING(A)
Make C-string.
bool hasPMT(const JObjectID &id) const
Has PMT.
const JPMT & getPMT(const JPMTAddress &address) const
Get PMT.
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
double getTime(const Hit &hit)
Get true time of hit.
double E
Energy [GeV] (either MC truth or reconstructed)
Data structure for detector geometry and calibration.
Utility class to parse parameter values.
Auxiliary class for defining the range of iterations of objects.
unsigned int overlays
number of overlaying triggered events
double getE() const
Get energy.
const JCylinder3D getMaximumContainmentVolume()
Auxiliary function to retrieve the maximum cylindrical containment volume.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
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.
Data structure for PMT geometry, calibration and status.
std::vector< double > fitinf
place to store additional fit info, see km3net-dataformat/definitions/fitparameters.csv
static const int JGANDALF_BETA0_RAD
KM3NeT Data Definitions v3.2.0-10-g78c1c7a https://git.km3net.de/common/km3net-dataformat.
double getY() const
Get y position.
Direct access to PMT in detector data structure.
const JPosition3D & getPosition() const
Get position.
double getT(const JVector3D &pos) const
Get arrival time of Cherenkov light at given position.
Auxiliary class for parsing multiparticle fluxes.
General purpose messaging.
Scanning of objects from multiple files according a format that follows from the extension of each fi...
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.
const char *const track_t
std::vector< filescanner_type >::iterator iterator
Auxiliary class to define a range between two values.
ULong64_t trig
non-zero if the hit is a trigger hit.
double lik
likelihood or lambda value (for aafit, lambda)
Utility class to parse command line options.
double t
hit time (from tdc+calibration or MC truth)
double getX() const
Get x position.
size_t setFlux(const int type, const JFlux &flux)
Set flux function for all MC-files corresponding to a given PDG code.
Auxiliary class for organising Monte Carlo file scanners associated with event weighters.
std::vector< Hit > hits
list of hits
do set_variable DETECTOR_TXT $WORKDIR detector
Auxiliaries for defining the range of iterations of objects.
The Trk class represents a Monte Carlo (MC) particle as well as a reconstructed track/shower.
Auxiliary data structure for floating point format specification.
double getDZ() const
Get z direction.
Template definition of a multi-dimensional oscillation probability interpolation table.
The Evt class respresent a Monte Carlo (MC) event as well as an offline event.
#define DEBUG(A)
Message macros.