78 JLimit_t& numberOfEvents = inputFile.getLimit();
80 JCalibration_t calibrationFile;
89 JParser<> zap(
"Auxiliary program to convert fit results to Evt format.\
90 \nThe option -L corresponds to the name of a shared library \
91 \nand function so to rearrange the order of fit results.");
95 zap[
'n'] =
make_field(numberOfEvents) = JLimit::max();
106 catch(
const exception& error) {
107 FATAL(error.what() << endl);
110 if (detectorFile ==
"" && !calibrationFile.empty()) {
111 FATAL(
"Missing detector file." << endl);
115 typedef JParallelFileScanner_t::multi_pointer_type multi_pointer_type;
119 if (detectorFile !=
"") {
128 unique_ptr<JDynamics> dynamics;
130 if (!calibrationFile.empty()) {
136 dynamics->load(calibrationFile);
138 catch(
const exception& error) {
154 }
catch(
const exception& error) {}
162 buffer.DAQ.livetime_s =
getLivetime(inputFile.begin(), inputFile.end());
165 copy(buffer, header);
168 if (detectorFile !=
"") {
170 buffer.calibration.buffer = (dynamics ? calibration::dynamical() :
calibration::statical());
173 copy(buffer, header);
189 STATUS(
"Processing: " << *i << endl);
191 JParallelFileScanner_t in(*i);
194 in.setLimit(inputFile.getLimit());
205 mc_run_id = head.start_run.run_id;
207 }
catch(
const exception& error) {}
210 while (in.hasNext()) {
212 STATUS(
"event: " << setw(10) << in.getCounter() <<
'\r');
DEBUG(endl);
214 multi_pointer_type ps = in.next();
220 dynamics->update(*tev);
223 JFIT::JEvt::iterator __end = evt->end();
225 if (numberOfFits > 0) {
226 advance(__end = evt->begin(), min(numberOfFits, evt->size()));
230 partial_sort(evt->begin(), __end, evt->end(),
qualitySorter);
235 if (mc.getEntries() != 0) {
255 if (!pmt_router->empty()) {
259 if (pmt_router.hasPMT(i->pmt_id)) {
261 const JPMTAddress address = pmt_router.getAddress(i->pmt_id);
263 const JPMT& pmt = pmt_router.getPMT(address);
265 i->dom_id =
id.
getID();
266 i->channel_id =
id.getPMTAddress();
272 miss_pmt[i->pmt_id] += 1;
277 if (!mod_router->empty()) {
281 if (mod_router.hasModule(i->dom_id)) {
288 const JPMT& pmt = mod_router.getPMT(
id);
294 i->pmt_id = pmt.
getID();
298 i->tot = hit.getToT();
299 i->a = cpu.getNPE(i->tot);
303 miss_mod[i->dom_id] += 1;
310 inline int get_index(
const JUUID& element)
const
312 const_iterator i = this->find(element);
314 if (i != this->end())
321 for (JFIT::JEvt::const_iterator fit = evt->begin(); fit != __end; ++fit) {
322 uuid.insert(fit->getUUID());
325 for (JFIT::JEvt::const_iterator fit = evt->begin(); fit != __end; ++fit) {
329 trk.
id = uuid.get_index(fit->getUUID());
330 trk.
pos =
Vec(fit->getX(), fit->getY(), fit->getZ());
331 trk.
dir =
Vec(fit->getDX(), fit->getDY(), fit->getDZ());
334 trk.
lik = fit->getQ();
338 if (fit->hasParentUUID()) {
339 trk.
mother_id = uuid.get_index(fit->getParentUUID());
342 for (JHistory::const_iterator i = fit->getHistory().begin(); i != fit->getHistory().end(); ++i) {
346 for (
int i = 0; i != fit->getN(); ++i) {
347 trk.
fitinf.push_back(fit->getW(i));
352 out.
trks.push_back(trk);
355 out.
id = ++number_of_events;
363 for (
const auto& i : miss_pmt) {
ERROR(
"Misses PMT " << setw(8) << i.first <<
' ' << setw(8) << i.second << endl); }
364 for (
const auto& i : miss_mod) {
ERROR(
"Misses module " << setw(8) << i.first <<
' ' << setw(8) << i.second << endl); }
#define DEBUG(A)
Message macros.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
JAANET::calibration calibration
const JCalibration & getCalibration() const
Get calibration.
Router for direct addressing of module data in detector data structure.
Address of PMT in detector data structure.
Auxiliary class for map of PMT parameters.
const JPMTParameters & getPMTParameters(const JPMTIdentifier &id) const
Get PMT parameters.
Data structure for PMT parameters.
bool slewing
time slewing of analogue signal
Router for direct addressing of PMT data in detector data structure.
Data structure for PMT geometry, calibration and status.
Data structure for set of track fit results.
int getID() const
Get identifier.
Utility class to parse command line options.
General purpose class for object reading from a list of file names.
General purpose class for parallel reading of objects from a single file or multiple files.
static void setSlewing(const bool slewing)
Set slewing option.
JTriggerCounter_t getCounter() const
Get trigger counter.
static const int JPP_RECONSTRUCTION_TYPE
KM3NeT Data Definitions v3.4.0-8-ge14cb17 https://git.km3net.de/common/km3net-dataformat.
JDirection3D getDirection(const Vec &dir)
Get direction.
double getTime(const Hit &hit)
Get true time of hit.
void copy(const Head &from, JHead &to)
Copy header from from to to.
JPosition3D getPosition(const Vec &pos)
Get position.
Vec getOffset(const JHead &header)
Get offset.
std::istream & read(std::istream &in, JTestSummary &summary, const char delimiter=' ')
Read test summary.
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
bool qualitySorter(const JFit &first, const JFit &second)
Comparison of fit results.
counter_type advance(counter_type &counter, const counter_type value, const counter_type limit=std::numeric_limits< counter_type >::max())
Advance counter.
Long64_t counter_type
Type definition for counter.
double getLivetime(const std::string &file_name)
Get data taking live time.
Head getHeader(const JMultipleFileScanner_t &file_list)
Get Monte Carlo header.
KM3NeT DAQ data structures and auxiliaries.
The Evt class respresent a Monte Carlo (MC) event as well as an offline event.
std::vector< Hit > hits
list of hits
int mc_run_id
MC run identifier.
std::vector< Hit > mc_hits
MC: list of MC truth hits.
std::vector< Trk > mc_trks
MC: list of MC truth tracks.
int id
offline event identifier
std::vector< Trk > trks
list of reconstructed tracks (can be several because of prefits,showers, etc).
The Head class reflects the header of Monte-Carlo event files, which consists of keys (also referred ...
PMT analogue signal processor.
Dynamic detector calibration.
Auxiliary class for recursive type list generation.
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
General purpose sorter of fit results.
Auxiliary class for defining the range of iterations of objects.
The Trk class represents a Monte Carlo (MC) particle as well as a reconstructed track/shower.
int status
MC status code, see km3net-dataformat/definitions/trkmembers.csv for values.
std::vector< double > error_matrix
(NxN) error covariance matrix for fit parameters (stored as linear vector)
std::vector< double > fitinf
place to store additional fit info, see km3net-dataformat/definitions/fitparameters....
std::vector< int > rec_stages
list of identifyers of succesfull fitting stages resulting in this track
double E
Energy [GeV] (either MC truth or reconstructed)
double t
track time [ns] (when the particle is at pos )
int rec_type
identifier of the fitting algorithm/chain/strategy, see km3net-dataformat/definitions/reconstruction....
int mother_id
MC id of the parent particle.
double lik
likelihood or lambda value (for aafit, lambda)
Vec pos
postion [m] of the track at time t
The Vec class is a straightforward 3-d vector, which also works in pyroot.
static const int TRK_ST_FINALSTATE
for MC: the particle must be processed by detector simulation ('track_in' tag in evt files)....
static const int TRK_ST_UNDEFINED
status was not defined for this MC track (all reco tracks have this value)