55 using namespace KM3NETDAQ;
79 JParser<> zap(
"Example program to analyse track fit results from Evt formatted data.");
82 zap[
'n'] =
make_field(numberOfEvents) = JLimit::max();
87 JEvtWeightOption::unweighted(),
88 JEvtWeightOption::standard(),
89 JEvtWeightOption::rescaled();
94 catch(
const exception& error) {
95 FATAL(error.what() << endl);
98 if (weightOption != JEvtWeightOption::unweighted() &&
99 numberOfEvents != JLimit::max()) {
100 FATAL(
"Cannot apply weighting to limited number of events.");
106 if (detectorFile !=
"") {
120 const Int_t N_Nhits = 400;
121 const Double_t Nhits_min = 0.0 - 0.5;
122 const Double_t Nhits_max = 1000.0 - 0.5;
124 const Int_t N_Noverlays = 40;
125 const Double_t Noverlays_min = 0.0 - 0.5;
126 const Double_t Noverlays_max = 1000.0 - 0.5;
128 const Int_t N_radius = 201;
129 const Double_t radius_min = -700.0 - 0.5;
130 const Double_t radius_max = +700.0 + 0.5;
132 const Int_t N_height = 18;
133 const Double_t height_min = 20.0;
134 const Double_t height_max = 200.0;
136 const Int_t N_ToTfrac = 20;
137 const Double_t ToTfrac_min = 0.0;
138 const Double_t ToTfrac_max = 1.0;
140 const Int_t N_dt = 1500;
141 const Double_t dt_min = -500.0 - 0.5;
142 const Double_t dt_max = 1000.0 - 0.5;
144 const Int_t N_zenith = 21;
145 const Double_t zenith_min = -1.0;
146 const Double_t zenith_max = +1.0;
148 const Int_t N_energy = 60;
149 const Double_t energy_min = -2.0;
150 const Double_t energy_max = 4.0;
152 const Int_t N_quality = 100;
153 const Double_t quality_min = -200.0;
154 const Double_t quality_max = +800.0;
156 const Int_t N_beta0 = 60;
157 const Double_t beta0_min = -2.0;
158 const Double_t beta0_max = +3.5;
163 string ordinateLabel(weightOption == JEvtWeightOption::unweighted() ?
164 "Number of events" :
"Rate [Hz]");
168 TH1D hs (
"hs",
MAKE_CSTRING(
"; #snapshot hits; " << ordinateLabel),
169 N_Nhits, Nhits_min, Nhits_max);
170 TH1D hn (
"hn",
MAKE_CSTRING(
"; #triggered hits; " << ordinateLabel),
171 N_Nhits, Nhits_min, Nhits_max);
172 TH1D ho (
"ho",
MAKE_CSTRING(
"; #overlays; " << ordinateLabel),
173 N_Noverlays, Noverlays_min, Noverlays_max);
175 TH1D hz (
"hz",
MAKE_CSTRING(
"; cos(#theta); " << ordinateLabel),
176 N_zenith, zenith_min, zenith_max);
177 TH1D he (
"he",
MAKE_CSTRING(
"; log_{10}(E_{reco} / 1 GeV); " << ordinateLabel),
178 N_energy, energy_min, energy_max);
179 TH1D ht (
"ht",
MAKE_CSTRING(
"; #Delta t [ns]; " << ordinateLabel),
180 N_dt, dt_min, dt_max);
182 TH1D hZ (
"hZ",
MAKE_CSTRING(
"; longitudinal ToT-barycenter [m]; " << ordinateLabel),
183 N_height, height_min, height_max);
184 TH1D hT0 (
"hT0",
MAKE_CSTRING(
"; ToT-fraction below earliest triggered hit [ns]; " << ordinateLabel),
185 N_ToTfrac, ToTfrac_min, ToTfrac_max);
186 TH1D hT1 (
"hT1",
MAKE_CSTRING(
"; ToT-fraction above earliest triggered hit [ns]; " << ordinateLabel),
187 N_ToTfrac, ToTfrac_min, ToTfrac_max);
189 TH1D hq (
"hq",
MAKE_CSTRING(
"; quality; " << ordinateLabel),
190 N_quality, quality_min, quality_max);
191 TH1D hb0 (
"hb0",
MAKE_CSTRING(
"; #beta_{0}; " << ordinateLabel),
192 N_beta0, beta0_min, beta0_max);
194 TH2D hzo (
"hzo",
MAKE_CSTRING(
"; cos(#theta); #overlays; " << ordinateLabel),
195 N_zenith, zenith_min, zenith_max,
196 N_Noverlays, Noverlays_min, Noverlays_max);
197 TH2D hze (
"hze",
MAKE_CSTRING(
"; cos(#theta); log_{10}(E_{reco} / 1 GeV); " << ordinateLabel),
198 N_zenith, zenith_min, zenith_max,
199 N_energy, energy_min, energy_max);
200 TH2D heo (
"heo",
MAKE_CSTRING(
"; log_{10}(E_{reco} / 1 GeV); #overlays; " << ordinateLabel),
201 N_energy, energy_min, energy_max,
202 N_Noverlays, Noverlays_min, Noverlays_max);
203 TH2D hzt (
"hzt",
MAKE_CSTRING(
"; cos(#theta); #Delta t [ns]; " << ordinateLabel),
204 N_zenith, zenith_min, zenith_max,
205 N_dt, dt_min, dt_max);
206 TH2D het (
"het",
MAKE_CSTRING(
"; log_{10}(E_{reco} / 1 GeV); #Delta t [ns]; " << ordinateLabel),
207 N_energy, energy_min, energy_max,
208 N_dt, dt_min, dt_max);
209 TH2D hot (
"hot",
MAKE_CSTRING(
"; #overlays; #Delta t [ns]; " << ordinateLabel),
210 N_Noverlays, Noverlays_min, Noverlays_max,
211 N_dt, dt_min, dt_max);
213 TH2D hzq (
"hzq",
MAKE_CSTRING(
"; cos(#theta); quality; " << ordinateLabel),
214 N_zenith, zenith_min, zenith_max,
215 N_quality, quality_min, quality_max);
216 TH2D heq (
"heq",
MAKE_CSTRING(
"; log_{10}(E_{reco} / 1 GeV); quality; " << ordinateLabel),
217 N_energy, energy_min, energy_max,
218 N_quality, quality_min, quality_max);
219 TH2D hoq (
"hoq",
MAKE_CSTRING(
"; #overlays; quality; " << ordinateLabel),
220 N_Noverlays, Noverlays_min, Noverlays_max,
221 N_quality, quality_min, quality_max);
223 TH2D hob0(
"hob0",
MAKE_CSTRING(
"; #overlays; log_{10}(#beta_{0}); " << ordinateLabel),
224 N_Noverlays, Noverlays_min, Noverlays_max,
225 N_beta0, beta0_min, beta0_max);
226 TH2D heb0(
"heb0",
MAKE_CSTRING(
"; log_{10}(E_{reco} / 1 GeV); log_{10}(#beta_{0}); " << ordinateLabel),
227 N_energy, energy_min, energy_max,
228 N_beta0, beta0_min, beta0_max);
229 TH2D hzb0(
"hzb0",
MAKE_CSTRING(
"; cos(#theta); log_{10}(#beta_{0}); " << ordinateLabel),
230 N_zenith, zenith_min, zenith_max,
231 N_beta0, beta0_min, beta0_max);
233 TH2D hxy (
"hxy",
MAKE_CSTRING(
"; x [m]; y [m]; " << ordinateLabel),
234 N_radius, radius_min, radius_max,
235 N_radius, radius_min, radius_max);
244 scanner->setLimit(numberOfEvents);
246 while (scanner->hasNext()) {
248 const Evt* evt = scanner->next();
258 const size_t NsnapshotHits = evt->
hits.size();
259 const size_t NtriggeredHits = count_if(evt->
hits.begin(), evt->
hits.end(),
262 if (triggeredHitsRange(NtriggeredHits) &&
263 coszenithRange (tb.
getDZ()) &&
264 energyRange (tb.
getE())) {
270 if (weightOption == JEvtWeightOption::unweighted()) {
272 }
else if (weightOption == JEvtWeightOption::standard()) {
273 weight = scanner->getWeight(*evt);
274 }
else if (weightOption == JEvtWeightOption::rescaled()) {
279 RIGHT (15) << scanner->getCounter() <<
284 hs .Fill(NsnapshotHits, weight);
285 hn .Fill(NtriggeredHits, weight);
289 he .Fill(logE, weight);
290 hq .Fill(best_trk.
lik, weight);
294 heo.Fill(logE, evt->
overlays, weight);
298 heq.Fill(logE, best_trk.
lik, weight);
306 hb0 .Fill(logb0, weight);
307 hob0.Fill(evt->
overlays, logb0, weight);
308 heb0.Fill(logE, logb0, weight);
312 double ToTbelow = 0.0;
313 double ToTabove = 0.0;
314 double ToTtotal = 0.0;
315 double ToTweightedZ = 0.0;
322 if (router.hasPMT(hit->pmt_id)) {
324 const JPMT& pmt = router.getPMT(hit->pmt_id);
326 const double t0 = tb.
getT(pmt);
327 const double t1 =
getTime(*hit);
329 ht .Fill(t1 - t0, weight);
330 hot.Fill(evt->
overlays, t1 - t0, weight);
332 het.Fill(
log10(best_trk.
E), t1 - t0, weight);
336 ToTtotal += hit->tot;
337 ToTweightedZ += hit->tot * hit->pos.z;
339 if (hit->pos.z < firstHit->pos.z) {
340 ToTbelow += hit->tot;
341 }
else if (hit->pos.z >= firstHit->pos.z) {
342 ToTabove += hit->tot;
348 hT0.Fill(ToTbelow / ToTtotal, weight);
349 hT1.Fill(ToTabove / ToTtotal, weight);
350 hZ .Fill(ToTweightedZ / ToTtotal, weight);
Router for direct addressing of PMT data in detector data structure.
static const int RESCALED_WEIGHT_INDEX
Index of rescaled weight.
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.
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)
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.
std::vector< double > w
MC: Weights w[0]=w1, w[1]=w2, w[2]]=w3 (see e.g. Tag list)
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)
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, for jgandalf, see JFitParameters.hh
static const int JGANDALF_BETA0_RAD
KM3NeT Data Definitions v2.2.0 https://git.km3net.de/common/km3net-dataformat.
double getY() const
Get y position.
double getT(const JVector3D &pos) const
Get arrival time of Cherenkov light at given position.
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
ULong64_t trig
non-zero if the hit is a trigger hit.
double lik
likelihood or lambda value (for aafit, lambda)
double t
hit time (from tdc+calibration or MC truth)
then usage $script< input_file >< detector_file > fi set_variable OUTPUT_DIR set_variable SELECTOR JDAQTimesliceL1 set_variable DEBUG case set_variable DEBUG
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
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