Jpp test-rotations-old
the software that should make you happy
Loading...
Searching...
No Matches
JTriggeredEventsOnly.cc
Go to the documentation of this file.
1
2#include <string>
3#include <iostream>
4#include <iomanip>
5#include <sstream>
6#include <set>
7
11
13#include "JDAQ/JDAQEventIO.hh"
15
17
24#include "JSupport/JMeta.hh"
25#include "JSupport/JSupport.hh"
26
27#include "Jeep/JParser.hh"
28#include "Jeep/JMessage.hh"
29
30namespace mc_keys {
31
32 const char* const primarylepton_t = "primarylepton:";
33}
34
35/**
36 * \file
37 * Auxiliary program to select number of DAQ events.
38 *
39 * \author mdejong
40 */
41int main(int argc, char **argv)
42{
43 using namespace std;
44 using namespace JPP;
45
46 string inputFile;
48 JLimit_t numberOfEvents;
49 int debug;
50
51 try {
52
53 JParser<> zap("Auxiliary program to select number of DAQ events.");
54
55 zap['f'] = make_field(inputFile);
56 zap['o'] = make_field(outputFile);
57 zap['n'] = make_field(numberOfEvents) = JLimit::max();
58 zap['d'] = make_field(debug) = 1;
59
60 zap(argc, argv);
61 }
62 catch(const exception& error) {
63 FATAL(error.what() << endl);
64 }
65
66
67 outputFile.open();
68
69 outputFile.put(JMeta(argc,argv));
70
71 try { outputFile.put(getHeader(inputFile)); } catch(const exception&) {}
72 try { outputFile.put(getMultiHeader(inputFile)); } catch(const exception&) {}
73 try { outputFile.put(getTriggerParameters(inputFile)); } catch(const exception&) {}
74
75 JTreeScanner<Evt> mc (inputFile);
76 JSummaryFileRouter summary(inputFile);
77
78 int trigger_counter = 0;
79
80 set<int> frame_index;
81
82 for (JSingleFileScanner<JDAQEvent> in(inputFile, numberOfEvents); in.hasNext(); ) {
83
84 STATUS("event: " << setw(10) << in.getCounter() << '\r'); DEBUG(endl);
85
86 JDAQEvent* tev = in.next();
87 Evt* event = mc.getEntry(tev->getCounter());
88
89 summary.update(*tev);
90
91 if (tev->getFrameIndex() != summary.getSummaryslice()->getFrameIndex()) {
92 WARNING("Frame index " << tev->getFrameIndex() << " != " << summary.getSummaryslice()->getFrameIndex() << endl);
93 }
94
95 if (Evt::ROOT_IO_VERSION < 16) {
96
97 for (vector<Trk>::iterator i = event->mc_trks.begin(); i != event->mc_trks.end(); ++i) {
98
99 const std::string& tag = i->comment;
100
101 if (tag == mc_keys::track_in_t) {
102
103 i->status = TRK_ST_FINALSTATE;
104
105 } else if (tag == mc_keys::track_t) {
106
107 } else if (tag == mc_keys::neutrino_t) {
108
109 i->status = TRK_ST_PRIMARYNEUTRINO;
110
111 } else if (tag == mc_keys::track_primary_t) {
112
113 i->status = TRK_ST_PRIMARYCOSMIC;
114
115 } else if (tag == mc_keys::track_bundle_t) {
116
117 i->type = PDG_MUONBUNDLE;
118 i->status = TRK_ST_MUONBUNDLE;
119
120 } else if (tag == mc_keys::primarylepton_t) {
121
122 i->status = TRK_ST_FINALSTATE;
123 }
124 }
125 }
126
127 tev->setCounter(trigger_counter);
128
129 outputFile.put(*tev);
130 outputFile.put(*event);
131
132 if (frame_index.insert(summary.getSummaryslice()->getFrameIndex()).second) {
133 outputFile.put(*summary.getSummaryslice());
134 }
135
136 ++trigger_counter;
137 }
138 STATUS(endl);
139
140 outputFile.close();
141}
string outputFile
Recording of objects on file according a format that follows from the file name extension.
General purpose messaging.
#define DEBUG(A)
Message macros.
Definition JMessage.hh:62
#define STATUS(A)
Definition JMessage.hh:63
#define FATAL(A)
Definition JMessage.hh:67
int debug
debug level
Definition JSirene.cc:72
#define WARNING(A)
Definition JMessage.hh:65
ROOT I/O of application specific meta data.
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
Scanning of objects from a single file according a format that follows from the extension of each fil...
ROOT TTree parameter settings of various packages.
int main(int argc, char **argv)
Utility class to parse command line options.
Definition JParser.hh:1698
Object writing to file.
Object reading from a list of files.
virtual bool hasNext() override
Check availability of next element.
File router for fast addressing of summary data.
void update(const JDAQHeader &header)
Update router.
const JDAQSummaryslice * getSummaryslice() const
Get summary slice.
Template definition for direct access of elements in ROOT TChain.
int getFrameIndex() const
Get frame index.
JTriggerCounter_t getCounter() const
Get trigger counter.
JTriggerCounter_t next()
Increment trigger counter.
void setCounter(const JTriggerCounter_t counter)
Set trigger counter.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
JTriggerParameters getTriggerParameters(const JMultipleFileScanner_t &file_list)
Get trigger parameters.
JMultiHead getMultiHeader(const JMultipleFileScanner_t &file_list)
Get multi-header corresponding to a given file list.
Head getHeader(const JMultipleFileScanner_t &file_list)
Get Monte Carlo header.
const char *const neutrino_t
Definition io_ascii.hh:29
const char *const track_in_t
Definition io_ascii.hh:26
const char *const track_t
Definition io_ascii.hh:27
const char *const primarylepton_t
const char *const track_bundle_t
Definition io_ascii.hh:31
const char *const track_primary_t
Definition io_ascii.hh:30
The Evt class respresent a Monte Carlo (MC) event as well as an offline event.
Definition Evt.hh:21
static int ROOT_IO_VERSION
Streamer version as obtained from ROOT file.
Definition Evt.hh:274
Auxiliary class for defining the range of iterations of objects.
Definition JLimit.hh:45
static counter_type max()
Get maximum counter value.
Definition JLimit.hh:128
Auxiliary class for ROOT I/O of application specific meta data.
Definition JMeta.hh:72
static const int PDG_MUONBUNDLE
muon bundle reached the can level (mupage)
Definition trkmembers.hh:38
static const int TRK_ST_FINALSTATE
for MC: the particle must be processed by detector simulation ('track_in' tag in evt files)....
Definition trkmembers.hh:15
static const int TRK_ST_MUONBUNDLE
initial state muon bundle (mupage)
Definition trkmembers.hh:18
static const int TRK_ST_PRIMARYCOSMIC
initial state cosmic ray ('track_primary' tag in evt files from corant).
Definition trkmembers.hh:17
static const int TRK_ST_PRIMARYNEUTRINO
initial state neutrino ('neutrino' tag in evt files from gseagen and genhen).
Definition trkmembers.hh:16