58 filenameTemplate(
"cut%.root"),
61 pos = filenameTemplate.find(wildcard);
72 JSeparateCuts(
const std::string& templateName,
76 filenameTemplate(templateName),
79 if (filenameTemplate.find(wildcard) == std::string::npos) {
81 "JSeparateCuts::JSeparateCuts(): Given file-name template \"" << filenameTemplate <<
82 "\" does not contain specified wildcard \'" << wildcard <<
"\'.");
85 pos = filenameTemplate.find(wildcard);
111 const JRange_t E(*prev(Ebound), *Ebound);
115 const bool overlap1 =
overlap(E, first .E);
116 const bool overlap2 =
overlap(E, second.
E);
118 if (overlap1 && overlap2) {
121 out.push_back(
cut(*prev(Ebound), *Ebound, *prev(cosTbound), *cosTbound));
124 }
else if (overlap1) {
128 }
else if (overlap2) {
161 const Evt*
event = scanner.
next();
163 if (event != NULL && !event->mc_trks.empty()) {
167 double Nprimaries = 0.0;
184 recorder.
put(*event);
221 const size_t N = JHead::getMaximumNumberOfMatches() - (header0.
spectrum.
match(header1.
spectrum) ? 1 : 2);
223 if (!((header0.*pd).match(header1.*pd)) && header0.
getNumberOfMatches(header1) == N) {
225 vector<cut> cuts = separate(header0.*pd, header1.*pd);
231 const string outputFilename = string(filenameTemplate).replace(pos, 1,
MAKE_CSTRING(
distance(cuts.begin(),
cut)));
237 JHead header2(header0);
239 (header2.*pd).E =
cut->
E;
240 (header2.*pd).cosT =
cut->
cosT;
252 recorder.
put(*in.next());
256 recorder.
put(*in.next());
261 extract(recorder, first, *
cut);
262 extract(recorder, second, *
cut);
281 void setFilenameTemplate(
const std::string& _filenameTemplate)
283 std::size_t p = _filenameTemplate.find(wildcard);
285 if (p != std::string::npos) {
287 this->filenameTemplate = _filenameTemplate;
292 THROW(
JValueOutOfRange,
"JSeparateCuts::setFilenameTemplate(): Given filename template " << filenameTemplate <<
" does not contain wildcard " << wildcard);
302 void setWildcard(
const char wc)
304 std::size_t p = this->filenameTemplate.find(wc);
306 if (p != std::string::npos) {
313 THROW(
JValueOutOfRange,
"JSeparateCuts::setWildcard(): Given wildcard character " << wildcard <<
" is not contained in current filename template " << this->filenameTemplate);
323 const std::string& getFilenameTemplate()
325 return filenameTemplate;
334 const char getWildcard()
344 std::string filenameTemplate;
360 int main(
int argc,
char **argv)
384 catch(
const exception& error) {
385 FATAL(error.what() << endl);
390 if (pos == string::npos) {
391 FATAL(
"Valid wildcard must be specified (<" <<
outputFile <<
"> does not contain \'" << wildcard <<
"\').");
408 if (scanner0->hasNext() && scanner1->hasNext()) {
411 const string name = string(
outputFile).replace(pos, 1, identifier.c_str());
415 const size_t N = (
separator.separate(*scanner0, *scanner1, &JHead::cut_primary) +
416 separator.separate(*scanner0, *scanner1, &JHead::cut_seamuon) +
417 separator.separate(*scanner0, *scanner1, &JHead::cut_in) +
418 separator.separate(*scanner0, *scanner1, &JHead::cut_nu));
420 STATUS(
"\rExtracted " << N <<
" output files with" <<
421 " disjoint cuts for " <<
getFilename(scanner0->getFilename()) <<
426 buffer.insert(scanner0->getFilename());
427 buffer.insert(scanner1->getFilename());
434 if (remove(i->c_str()) != 0) {
435 FATAL(endl <<
"Error removing file " << *i);
437 NOTICE(endl <<
"Removing file " << *i);
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Recording of objects on file according a format that follows from the file name extension.
General purpose messaging.
#define DEBUG(A)
Message macros.
Scanning of objects from multiple files according a format that follows from the extension of each fi...
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
TString replace(const TString &target, const TRegexp ®exp, const T &replacement)
Replace regular expression in input by given replacement.
I/O formatting auxiliaries.
#define MAKE_CSTRING(A)
Make C-string.
#define MAKE_STRING(A)
Make string.
Auxiliary class to define a range between two values.
int main(int argc, char **argv)
ROOT TTree parameter settings of various packages.
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
JAANET::spectrum spectrum
const JHead & getHeader() const
Get header.
size_t getNumberOfMatches(const JHead &header) const
Get number of matching fields.
virtual bool put(const T &object)=0
Object output.
Exception for accessing a value in a collection that is outside of its range.
Utility class to parse command line options.
virtual void open(const char *file_name) override
Open file.
General purpose class for object reading from a list of file names.
virtual void rewind() override
Rewind.
virtual bool hasNext() override
Check availability of next element.
virtual const pointer_type & next() override
Get next element.
void copy(const Head &from, JHead &to)
Copy header from from to to.
std::string getFilename(const std::string &file_name)
Get file name part, i.e. part after last JEEP::PATHNAME_SEPARATOR if any.
T * open(const std::string &file_name)
Open file.
std::ostream & separator(std::ostream &out)
Print separator.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
The Evt class respresent a Monte Carlo (MC) event as well as an offline event.
The Head class reflects the header of Monte-Carlo event files, which consists of keys (also referred ...
Type definition of range.
General purpose class of phase space generation.
JRange_t cosT
Cosine zenith angle range
JRange_t E
Energy range [GeV].
double numberOfEvents
Number of events.
bool match(const spectrum &object) const
Test match.
virtual void close() override
Close device.
virtual bool is_open() const override
Check is device is open.
Auxiliary class for organising Monte Carlo file scanners associated with event weighters.
std::vector< filescanner_type >::iterator iterator
std::string getUniqueIdentifier(const_iterator p) const
Get unique identifier for a file-scanner contained within this set of event-weighter-associated file-...
Template event-weighter-associated file scanner.
Auxiliary base class for list of file names.
static const int TRK_ST_PRIMARYCOSMIC
initial state cosmic ray ('track_primary' tag in evt files from corant).
static const int TRK_ST_PRIMARYNEUTRINO
initial state neutrino ('neutrino' tag in evt files from gseagen and genhen).