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) {
159 while (scanner.hasNext()) {
161 const Evt*
event = scanner.next();
163 if (event != NULL && !event->mc_trks.empty()) {
167 double Nprimaries = 0.0;
183 if (cut.
E(E) && cut.
cosT(costh)) {
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;
242 header2.genvol.numberOfEvents += header1.genvol.numberOfEvents;
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());
413 separator.setFilenameTemplate(name);
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);
Utility class to parse command line options.
int main(int argc, char *argv[])
ROOT TTree parameter settings of various packages.
std::string getUniqueIdentifier(const_iterator p) const
Get unique identifier for a file-scanner contained within this set of event-weighter-associated file-...
TString replace(const TString &target, const TRegexp ®exp, const T &replacement)
Replace regular expression in input by given replacement.
then usage $script< input file >[option[primary[working directory]]] nWhere option can be E
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
Recording of objects on file according a format that follows from the file name extension.
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
#define MAKE_CSTRING(A)
Make C-string.
JRange_t E
Energy range [GeV].
General purpose class of phase space generation.
T * open(const std::string &file_name)
Open file.
then echo The file $DIR KM3NeT_00000001_00000000 root already please rename or remove it first
#define MAKE_STRING(A)
Make string.
Type definition of range.
I/O formatting auxiliaries.
std::ostream & separator(std::ostream &out)
Print separator.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
do set_variable OUTPUT_DIRECTORY $WORKDIR T
static const int TRK_ST_PRIMARYNEUTRINO
initial state neutrino ('neutrino' tag in evt files from gseagen and genhen).
static const int TRK_ST_PRIMARYCOSMIC
initial state cosmic ray ('track_primary' tag in evt files from corant).
JRange_t cosT
Cosine zenith angle range.
General purpose messaging.
then fatal The output file must have the wildcard in the name
The Head class reflects the header of Monte-Carlo event files, which consists of keys (also referred ...
Scanning of objects from multiple files according a format that follows from the extension of each fi...
virtual void close()=0
Close device.
Auxiliary base class for list of file names.
then usage $script< input file >[option[primary[working directory]]] nWhere option can be N
std::vector< filescanner_type >::iterator iterator
virtual bool is_open() const =0
Check is device is open.
Auxiliary class to define a range between two values.
General purpose class for object reading from a list of file names.
then fatal The output file must have the wildcard in the e g root fi eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
Utility class to parse command line options.
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.
virtual void open(const char *file_name) override
Open file.
const JHead & getHeader() const
Get header.
Auxiliary class for organising Monte Carlo file scanners associated with event weighters.
Exception for accessing a value in a collection that is outside of its range.
Template event-weighter-associated file scanner.
virtual bool put(const T &object)=0
Object output.
The Evt class respresent a Monte Carlo (MC) event as well as an offline event.
#define DEBUG(A)
Message macros.