39 struct JEvtWeightOption {
41 static const char*
const unweighted() {
return "unweighted"; }
42 static const char*
const standard() {
return "standardFlux"; }
43 static const char*
const rescaled() {
return "rescaledFlux"; }
54 int main(
int argc,
char **argv)
58 using namespace KM3NETDAQ;
82 JParser<> zap(
"Example program to analyse track fit results from Evt formatted data.");
85 zap[
'n'] =
make_field(numberOfEvents) = JLimit::max();
90 JEvtWeightOption::unweighted(),
91 JEvtWeightOption::standard(),
92 JEvtWeightOption::rescaled();
97 catch(
const exception& error) {
98 FATAL(error.what() << endl);
101 if (weightOption != JEvtWeightOption::unweighted() &&
102 numberOfEvents != JLimit::max()) {
103 FATAL(
"Cannot apply weighting to limited number of events.");
109 if (detectorFile !=
"") {
123 const Int_t N_Nhits = 400;
124 const Double_t Nhits_min = 0.0 - 0.5;
125 const Double_t Nhits_max = 1000.0 - 0.5;
127 const Int_t N_Noverlays = 40;
128 const Double_t Noverlays_min = 0.0 - 0.5;
129 const Double_t Noverlays_max = 1000.0 - 0.5;
131 const Int_t N_radius = 201;
132 const Double_t radius_min = -700.0 - 0.5;
133 const Double_t radius_max = +700.0 + 0.5;
135 const Int_t N_height = 18;
136 const Double_t height_min = 20.0;
137 const Double_t height_max = 200.0;
139 const Int_t N_ToTfrac = 20;
140 const Double_t ToTfrac_min = 0.0;
141 const Double_t ToTfrac_max = 1.0;
143 const Int_t N_dt = 1500;
144 const Double_t dt_min = -500.0 - 0.5;
145 const Double_t dt_max = 1000.0 - 0.5;
147 const Int_t N_zenith = 21;
148 const Double_t zenith_min = -1.0;
149 const Double_t zenith_max = +1.0;
151 const Int_t N_energy = 60;
152 const Double_t energy_min = -2.0;
153 const Double_t energy_max = 4.0;
155 const Int_t N_quality = 100;
156 const Double_t quality_min = -200.0;
157 const Double_t quality_max = +800.0;
159 const Int_t N_beta0 = 60;
160 const Double_t beta0_min = -2.0;
161 const Double_t beta0_max = +3.5;
166 string ordinateLabel(weightOption == JEvtWeightOption::unweighted() ?
167 "Number of events" :
"Rate [Hz]");
171 TH1D hs (
"hs",
MAKE_CSTRING(
"; #snapshot hits; " << ordinateLabel),
172 N_Nhits, Nhits_min, Nhits_max);
173 TH1D hn (
"hn",
MAKE_CSTRING(
"; #triggered hits; " << ordinateLabel),
174 N_Nhits, Nhits_min, Nhits_max);
175 TH1D ho (
"ho",
MAKE_CSTRING(
"; #overlays; " << ordinateLabel),
176 N_Noverlays, Noverlays_min, Noverlays_max);
178 TH1D hz (
"hz",
MAKE_CSTRING(
"; cos(#theta); " << ordinateLabel),
179 N_zenith, zenith_min, zenith_max);
180 TH1D he (
"he",
MAKE_CSTRING(
"; log_{10}(E_{reco} / 1 GeV); " << ordinateLabel),
181 N_energy, energy_min, energy_max);
182 TH1D ht (
"ht",
MAKE_CSTRING(
"; #Delta t [ns]; " << ordinateLabel),
183 N_dt, dt_min, dt_max);
185 TH1D hZ (
"hZ",
MAKE_CSTRING(
"; longitudinal ToT-barycenter [m]; " << ordinateLabel),
186 N_height, height_min, height_max);
187 TH1D hT0 (
"hT0",
MAKE_CSTRING(
"; ToT-fraction below earliest triggered hit [ns]; " << ordinateLabel),
188 N_ToTfrac, ToTfrac_min, ToTfrac_max);
189 TH1D hT1 (
"hT1",
MAKE_CSTRING(
"; ToT-fraction above earliest triggered hit [ns]; " << ordinateLabel),
190 N_ToTfrac, ToTfrac_min, ToTfrac_max);
192 TH1D hq (
"hq",
MAKE_CSTRING(
"; quality; " << ordinateLabel),
193 N_quality, quality_min, quality_max);
194 TH1D hb0 (
"hb0",
MAKE_CSTRING(
"; #beta_{0}; " << ordinateLabel),
195 N_beta0, beta0_min, beta0_max);
197 TH2D hzo (
"hzo",
MAKE_CSTRING(
"; cos(#theta); #overlays; " << ordinateLabel),
198 N_zenith, zenith_min, zenith_max,
199 N_Noverlays, Noverlays_min, Noverlays_max);
200 TH2D hze (
"hze",
MAKE_CSTRING(
"; cos(#theta); log_{10}(E_{reco} / 1 GeV); " << ordinateLabel),
201 N_zenith, zenith_min, zenith_max,
202 N_energy, energy_min, energy_max);
203 TH2D heo (
"heo",
MAKE_CSTRING(
"; log_{10}(E_{reco} / 1 GeV); #overlays; " << ordinateLabel),
204 N_energy, energy_min, energy_max,
205 N_Noverlays, Noverlays_min, Noverlays_max);
206 TH2D hzt (
"hzt",
MAKE_CSTRING(
"; cos(#theta); #Delta t [ns]; " << ordinateLabel),
207 N_zenith, zenith_min, zenith_max,
208 N_dt, dt_min, dt_max);
209 TH2D het (
"het",
MAKE_CSTRING(
"; log_{10}(E_{reco} / 1 GeV); #Delta t [ns]; " << ordinateLabel),
210 N_energy, energy_min, energy_max,
211 N_dt, dt_min, dt_max);
212 TH2D hot (
"hot",
MAKE_CSTRING(
"; #overlays; #Delta t [ns]; " << ordinateLabel),
213 N_Noverlays, Noverlays_min, Noverlays_max,
214 N_dt, dt_min, dt_max);
216 TH2D hzq (
"hzq",
MAKE_CSTRING(
"; cos(#theta); quality; " << ordinateLabel),
217 N_zenith, zenith_min, zenith_max,
218 N_quality, quality_min, quality_max);
219 TH2D heq (
"heq",
MAKE_CSTRING(
"; log_{10}(E_{reco} / 1 GeV); quality; " << ordinateLabel),
220 N_energy, energy_min, energy_max,
221 N_quality, quality_min, quality_max);
222 TH2D hoq (
"hoq",
MAKE_CSTRING(
"; #overlays; quality; " << ordinateLabel),
223 N_Noverlays, Noverlays_min, Noverlays_max,
224 N_quality, quality_min, quality_max);
226 TH2D hob0(
"hob0",
MAKE_CSTRING(
"; #overlays; log_{10}(#beta_{0}); " << ordinateLabel),
227 N_Noverlays, Noverlays_min, Noverlays_max,
228 N_beta0, beta0_min, beta0_max);
229 TH2D heb0(
"heb0",
MAKE_CSTRING(
"; log_{10}(E_{reco} / 1 GeV); log_{10}(#beta_{0}); " << ordinateLabel),
230 N_energy, energy_min, energy_max,
231 N_beta0, beta0_min, beta0_max);
232 TH2D hzb0(
"hzb0",
MAKE_CSTRING(
"; cos(#theta); log_{10}(#beta_{0}); " << ordinateLabel),
233 N_zenith, zenith_min, zenith_max,
234 N_beta0, beta0_min, beta0_max);
236 TH2D hxy (
"hxy",
MAKE_CSTRING(
"; x [m]; y [m]; " << ordinateLabel),
237 N_radius, radius_min, radius_max,
238 N_radius, radius_min, radius_max);
247 scanner->setLimit(numberOfEvents);
249 while (scanner->hasNext()) {
251 const Evt* evt = scanner->next();
261 const size_t NsnapshotHits = evt->
hits.size();
262 const size_t NtriggeredHits = count_if(evt->
hits.begin(), evt->
hits.end(),
265 if (triggeredHitsRange(NtriggeredHits) &&
266 coszenithRange (tb.
getDZ()) &&
267 energyRange (tb.
getE())) {
273 if (weightOption == JEvtWeightOption::unweighted()) {
275 }
else if (weightOption == JEvtWeightOption::standard()) {
276 weight = scanner->getWeight(*evt);
277 }
else if (weightOption == JEvtWeightOption::rescaled()) {
282 RIGHT (15) << scanner->getCounter() <<
287 hs .Fill(NsnapshotHits, weight);
288 hn .Fill(NtriggeredHits, weight);
292 he .Fill(logE, weight);
293 hq .Fill(best_trk.
lik, weight);
297 heo.Fill(logE, evt->
overlays, weight);
301 heq.Fill(logE, best_trk.
lik, weight);
309 hb0 .Fill(logb0, weight);
310 hob0.Fill(evt->
overlays, logb0, weight);
311 heb0.Fill(logE, logb0, weight);
315 double ToTbelow = 0.0;
316 double ToTabove = 0.0;
317 double ToTtotal = 0.0;
318 double ToTweightedZ = 0.0;
325 if (router.
hasPMT(hit->pmt_id)) {
329 const double t0 = tb.
getT(pmt);
330 const double t1 =
getTime(*hit);
332 ht .Fill(t1 - t0, weight);
333 hot.Fill(evt->
overlays, t1 - t0, weight);
335 het.Fill(
log10(best_trk.
E), t1 - t0, weight);
339 ToTtotal += hit->tot;
340 ToTweightedZ += hit->tot * hit->pos.z;
342 if (hit->pos.z < firstHit->pos.z) {
343 ToTbelow += hit->tot;
344 }
else if (hit->pos.z >= firstHit->pos.z) {
345 ToTabove += hit->tot;
351 hT0.Fill(ToTbelow / ToTtotal, weight);
352 hT1.Fill(ToTabove / ToTtotal, weight);
353 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.
static const int WEIGHTLIST_RESCALED_EVENT_RATE
Rescaled event rate [s-1].
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)
macro to convert (template) parameter to JPropertiesElement object
std::string comment
use as you like
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.
std::vector< double > w
MC: Weights w[0]=w1, w[1]=w2, w[2]=w3 (see e.g. Tag list or km3net-dataformat/definitions) ...
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.
Auxiliary class for defining the range of iterations of objects.
unsigned int overlays
number of overlaying triggered events
double getE() const
Get energy.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
set_variable E_E log10(E_{fit}/E_{#mu})"
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.0.0-1-gb6f251e https://git.km3net.de/common/km3net-dataformat.
double getY() const
Get y position.
Direct access to PMT in detector data structure.
double getT(const JVector3D &pos) const
Get arrival time of Cherenkov light at given position.
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.
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
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.
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.
The Evt class respresent a Monte Carlo (MC) event as well as an offline event.
std::vector< double > weight
#define DEBUG(A)
Message macros.