Skip to content

Commit

Permalink
Merge pull request #174 from soleti/master
Browse files Browse the repository at this point in the history
Intercepting also filenames with Mu2e convention
  • Loading branch information
kutschke authored Apr 16, 2020
2 parents 950d05b + fa520ae commit 09fc225
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 8 deletions.
38 changes: 38 additions & 0 deletions JobConfig/cosmic/cosmic_s1_dsstops_corsika.fcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#include "JobConfig/cosmic/cosmic_s1_dsstops.fcl"

targetParams: {
projectToTargetBox : true
targetBoxXmin: -10000
targetBoxXmax: 3000
targetBoxYmin: -5000
targetBoxYmax: 5000
targetBoxZmin: -5000
targetBoxZmax: 21000
}

source: {
module_type: FromCorsikaBinary
fileNames: ["/pnfs/mu2e/persistent/users/srsoleti/corsika/DAT300001"]
runNumber : 1
showerAreaExtension : 10000
@table::targetParams
resample: false
compact: true
fluxConstant: 1.8e4
lowE: 1.3
highE: 1e6
}


physics.producers.generate.module_type : CORSIKAEventGenerator
physics.producers.generate.corsikaModuleLabel: "FromCorsikaBinary"
physics.producers.generate.refPointChoice: "UNDEFINED"
physics.producers.generate.projectToTargetBox : true
physics.producers.generate.targetBoxYmax : 5000
physics.producers.generate.intDist: -1

physics.producers.generate.inputFile : @erase
physics.producers.generate.stashSize : @erase

services.GeometryService.inputFile : "JobConfig/cosmic/geom_cosmic.txt"
services.GeometryService.simulatedDetector : { tool_type: "Mu2e" }
3 changes: 0 additions & 3 deletions Sources/inc/CosmicCORSIKA.hh
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@ struct Config
using Name = fhicl::Name;
using Comment = fhicl::Comment;
fhicl::Sequence<std::string> showerInputFiles{Name("fileNames"),Comment("List of CORSIKA binary output paths")};
fhicl::Atom<int> firstEventNumber{Name("firstEventNumber"), Comment("First event number"), 0};
fhicl::Atom<int> firstSubRunNumber{Name("firstSubRunNumber"), Comment("First subrun number"), 0};
fhicl::Atom<int> maxEvents{Name("maxEvents"), Comment("Max number of events"), 0};
fhicl::Atom<unsigned int> runNumber{Name("runNumber"), Comment("First run number"), 0};
fhicl::Atom<std::string> module_label{Name("module_label"), Comment("Art module label"), ""};
fhicl::Atom<std::string> module_type{Name("module_type"), Comment("Art module type"), ""};
Expand Down
27 changes: 22 additions & 5 deletions Sources/src/FromCorsikaBinary_source.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <cassert>
#include <set>
#include <string>
#include <regex>

#include "CLHEP/Vector/LorentzVector.h"
#include "CLHEP/Vector/ThreeVector.h"
Expand Down Expand Up @@ -137,13 +138,29 @@ namespace mu2e {

//----------------------------------------------------------------
unsigned CorsikaBinaryDetail::getSubRunNumber(const std::string& filename) const {
const std::string::size_type islash = filename.find("DAT") ;
const std::string basename = (islash == std::string::npos) ? filename : filename.substr(islash + 3);
std::regex re_corsika("^(.*/)?DAT([0-9]+)$");
std::regex re_mu2e("^(.*/)?sim\\.\\w+\\.[\\w-]+\\.[\\w-]+\\.([0-9]+)\\.csk$");

unsigned sr(-1);
std::istringstream is(basename);
if(!(is>>sr)) {
throw cet::exception("BADINPUTS")<<"Expect an unsigned integer at the beginning of input file name, got "<<basename<<"\n";

std::smatch match;
if(std::regex_search(filename, match, re_corsika)) {
// [0]: the whole string
// [1]: dirname or emtpy
// [2]: the run number string
sr = std::stoi(match.str(2));
}
else if(std::regex_search(filename, match, re_mu2e)) {
// [0]: the whole string
// [1]: dirname or emtpy
// [2]: the run number string
sr = std::stoi(match.str(2));
}
else {
throw cet::exception("BADINPUT", " FromCorsikaBinary: ")
<< " Can not parse filename to extract subrun number: "<<filename<<"\n";
}

return sr;
}

Expand Down

0 comments on commit 09fc225

Please sign in to comment.