40 int main(
int argc,
char **argv)
44 using namespace KM3NETDAQ;
68 JParser<> zap(
"Example program to analyse track fit results from Evt formatted data.");
71 zap[
'n'] =
make_field(numberOfEvents) = JLimit::max();
75 zap[
'W'] =
make_field(weightIndex) = -1, 2, 3, 4;
80 catch(
const exception& error) {
81 FATAL(error.what() << endl);
84 if (weightIndex > 0 && numberOfEvents != JLimit::max()) {
85 FATAL(
"Cannot apply weighting to limited number of events.");
91 if (detectorFile !=
"") {
105 const Int_t N_Nhits = 400;
106 const Double_t Nhits_min = 0.0 - 0.5;
107 const Double_t Nhits_max = 1000.0 - 0.5;
109 const Int_t N_Noverlays = 40;
110 const Double_t Noverlays_min = 0.0 - 0.5;
111 const Double_t Noverlays_max = 1000.0 - 0.5;
113 const Int_t N_radius = 201;
114 const Double_t radius_min = -700.0 - 0.5;
115 const Double_t radius_max = +700.0 + 0.5;
117 const Int_t N_height = 18;
118 const Double_t height_min = 20.0;
119 const Double_t height_max = 200.0;
121 const Int_t N_ToTfrac = 20;
122 const Double_t ToTfrac_min = 0.0;
123 const Double_t ToTfrac_max = 1.0;
125 const Int_t N_dt = 1500;
126 const Double_t dt_min = -500.0 - 0.5;
127 const Double_t dt_max = 1000.0 - 0.5;
129 const Int_t N_zenith = 21;
130 const Double_t zenith_min = -1.0;
131 const Double_t zenith_max = +1.0;
133 const Int_t N_energy = 60;
134 const Double_t energy_min = -2.0;
135 const Double_t energy_max = 4.0;
137 const Int_t N_quality = 100;
138 const Double_t quality_min = -200.0;
139 const Double_t quality_max = +800.0;
141 const Int_t N_beta0 = 60;
142 const Double_t beta0_min = -2.0;
143 const Double_t beta0_max = +3.5;
150 TH1D hs (
"hs",
"; #snapshot hits",
151 N_Nhits, Nhits_min, Nhits_max);
152 TH1D hn (
"hn",
"; #triggered hits",
153 N_Nhits, Nhits_min, Nhits_max);
154 TH1D ho (
"ho",
"; #overlays",
155 N_Noverlays, Noverlays_min, Noverlays_max);
157 TH1D hz (
"hz",
"; cos(#theta)",
158 N_zenith, zenith_min, zenith_max);
159 TH1D he (
"he",
"; log_{10}(E_{reco} / 1 GeV)",
160 N_energy, energy_min, energy_max);
161 TH1D ht (
"ht",
"; #Delta t [ns]",
162 N_dt, dt_min, dt_max);
164 TH1D hZ (
"hZ",
"; longitudinal ToT-barycenter [m]",
165 N_height, height_min, height_max);
166 TH1D hT0 (
"hT0",
"; ToT-fraction below earliest triggered hit [ns]",
167 N_ToTfrac, ToTfrac_min, ToTfrac_max);
168 TH1D hT1 (
"hT1",
"; ToT-fraction above earliest triggered hit [ns]",
169 N_ToTfrac, ToTfrac_min, ToTfrac_max);
171 TH1D hq (
"hq",
"; quality",
172 N_quality, quality_min, quality_max);
173 TH1D hb0 (
"hb0",
"; #beta_{0}",
174 N_beta0, beta0_min, beta0_max);
176 TH2D hzo (
"hzo",
"; cos(#theta); #overlays",
177 N_zenith, zenith_min, zenith_max,
178 N_Noverlays, Noverlays_min, Noverlays_max);
179 TH2D hze (
"hze",
"; cos(#theta); log_{10}(E_{reco} / 1 GeV)",
180 N_zenith, zenith_min, zenith_max,
181 N_energy, energy_min, energy_max);
182 TH2D heo (
"heo",
"; log_{10}(E_{reco} / 1 GeV); #overlays",
183 N_energy, energy_min, energy_max,
184 N_Noverlays, Noverlays_min, Noverlays_max);
185 TH2D hzt (
"hzt",
"; cos(#theta); #Delta t [ns]",
186 N_zenith, zenith_min, zenith_max,
187 N_dt, dt_min, dt_max);
188 TH2D het (
"het",
"; log_{10}(E_{reco} / 1 GeV); #Delta t [ns]",
189 N_energy, energy_min, energy_max,
190 N_dt, dt_min, dt_max);
191 TH2D hot (
"hot",
"; #overlays; #Delta t [ns]",
192 N_Noverlays, Noverlays_min, Noverlays_max,
193 N_dt, dt_min, dt_max);
195 TH2D hzq (
"hzq",
"; cos(#theta); quality",
196 N_zenith, zenith_min, zenith_max,
197 N_quality, quality_min, quality_max);
198 TH2D heq (
"heq",
"; log_{10}(E_{reco} / 1 GeV); quality",
199 N_energy, energy_min, energy_max,
200 N_quality, quality_min, quality_max);
201 TH2D hoq (
"hoq",
"; #overlays; quality",
202 N_Noverlays, Noverlays_min, Noverlays_max,
203 N_quality, quality_min, quality_max);
205 TH2D hob0(
"hob0",
"; #overlays; log_{10}(#beta_{0})",
206 N_Noverlays, Noverlays_min, Noverlays_max,
207 N_beta0, beta0_min, beta0_max);
208 TH2D heb0(
"heb0",
"; log_{10}(E_{reco} / 1 GeV); log_{10}(#beta_{0})",
209 N_energy, energy_min, energy_max,
210 N_beta0, beta0_min, beta0_max);
211 TH2D hzb0(
"hzb0",
"; cos(#theta); log_{10}(#beta_{0})",
212 N_zenith, zenith_min, zenith_max,
213 N_beta0, beta0_min, beta0_max);
215 TH2D hxy (
"hxy",
"; x [m]; y [m]",
216 N_radius, radius_min, radius_max,
217 N_radius, radius_min, radius_max);
226 scanner->setLimit(numberOfEvents);
228 while (scanner->hasNext()) {
230 const Evt* evt = scanner->next();
239 const double logE = log10(tb.
getE());
240 const size_t NsnapshotHits = evt->
hits.size();
241 const size_t NtriggeredHits = count_if(evt->
hits.begin(), evt->
hits.end(),
244 if (triggeredHitsRange(NtriggeredHits) &&
245 coszenithRange (tb.
getDZ()) &&
246 energyRange (tb.
getE())) {
252 if (weightIndex < 2) {
256 }
else if (weightIndex < 3) {
258 weight = scanner->getWeight(*evt);
260 }
else if (weightIndex <= (
int) evt->
w.size()) {
262 weight = evt->
w.at(weightIndex - 1);
266 WARNING(
'w' << weightIndex <<
"-weight does not exist for event #" << scanner->getCounter() <<
"; skip." << endl);
271 RIGHT (15) << scanner->getCounter() <<
276 hs .Fill(NsnapshotHits, weight);
277 hn .Fill(NtriggeredHits, weight);
281 he .Fill(logE, weight);
282 hq .Fill(best_trk.
lik, weight);
286 heo.Fill(logE, evt->
overlays, weight);
290 heq.Fill(logE, best_trk.
lik, weight);
298 hb0 .Fill(logb0, weight);
299 hob0.Fill(evt->
overlays, logb0, weight);
300 heb0.Fill(logE, logb0, weight);
304 double ToTbelow = 0.0;
305 double ToTabove = 0.0;
306 double ToTtotal = 0.0;
307 double ToTweightedZ = 0.0;
314 if (router.
hasPMT(hit->pmt_id)) {
318 const double t0 = tb.
getT(pmt);
319 const double t1 =
getTime(*hit);
321 ht .Fill(t1 - t0, weight);
322 hot.Fill(evt->
overlays, t1 - t0, weight);
324 het.Fill(log10(best_trk.
E), t1 - t0, weight);
328 ToTtotal += hit->tot;
329 ToTweightedZ += hit->tot * hit->pos.z;
331 if (hit->pos.z < firstHit->pos.z) {
332 ToTbelow += hit->tot;
333 }
else if (hit->pos.z >= firstHit->pos.z) {
334 ToTabove += hit->tot;
340 hT0.Fill(ToTbelow / ToTtotal, weight);
341 hT1.Fill(ToTabove / ToTtotal, weight);
342 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)
macro to convert (template) parameter to JPropertiesElement object
std::string comment
use as you like
Utility class to parse parameter values.
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)
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.
std::vector< value_type >::iterator iterator
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
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.1.0-7-g97845ea 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.
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)
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
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