Skip to content

Commit

Permalink
fix: Don't special case EOS paths
Browse files Browse the repository at this point in the history
Fixes #566
  • Loading branch information
olantwin committed Feb 12, 2025
1 parent b725a71 commit 2dc3a8a
Show file tree
Hide file tree
Showing 10 changed files with 163 additions and 217 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ it in future.

### Changed

* Don't special case EOS paths (fix #566)

### Removed

## 25.01
Expand Down
14 changes: 2 additions & 12 deletions macro/ShipAna.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,27 +28,17 @@
parser.add_argument("--Debug", dest="Debug", help="Switch on debugging", required=False, action="store_true")
options = parser.parse_args()

eosship = ROOT.gSystem.Getenv("EOSSHIP")
if not options.inputFile.find(',')<0 :
sTree = ROOT.TChain("cbmsim")
for x in options.inputFile.split(','):
if x[0:4] == "/eos":
sTree.AddFile(eosship+x)
else: sTree.AddFile(x)
elif options.inputFile[0:4] == "/eos":
eospath = eosship+options.inputFile
f = ROOT.TFile.Open(eospath)
sTree = f.cbmsim
sTree.AddFile(x)
else:
f = ROOT.TFile(options.inputFile)
sTree = f.cbmsim

# try to figure out which ecal geo to load
if not options.geoFile:
options.geoFile = options.inputFile.replace('ship.','geofile_full.').replace('_rec.','.')
if options.geoFile[0:4] == "/eos":
eospath = eosship+options.geoFile
fgeo = ROOT.TFile.Open(eospath)
else:
fgeo = ROOT.TFile(options.geoFile)

Expand Down Expand Up @@ -878,7 +868,7 @@ def HNLKinematics():
makePlots()
# output histograms
hfile = options.inputFile.split(',')[0].replace('_rec','_ana')
if hfile[0:4] == "/eos" or not options.inputFile.find(',')<0:
if "/eos" in hfile or not options.inputFile.find(',')<0:
# do not write to eos, write to local directory
tmp = hfile.split('/')
hfile = tmp[len(tmp)-1]
Expand Down
4 changes: 0 additions & 4 deletions macro/eventDisplay.py
Original file line number Diff line number Diff line change
Expand Up @@ -1290,12 +1290,8 @@ def debugStraw(n):
# ----- Reconstruction run -------------------------------------------
fRun = ROOT.FairRunAna()
if options.geoFile:
if options.geoFile[0:4] == "/eos":
options.geoFile = ROOT.gSystem.Getenv("EOSSHIP") + options.geoFile
fRun.SetGeomFile(options.geoFile)

if options.InputFile[0:4] == "/eos":
options.InputFile = ROOT.gSystem.Getenv("EOSSHIP") + options.InputFile
inFile = ROOT.FairFileSource(options.InputFile)
fRun.SetSource(inFile)
if options.OutputFile is None:
Expand Down
2 changes: 0 additions & 2 deletions macro/getGeoInformation.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,6 @@ def print_info(path, node, level, currentlevel, print_sub_det_info=False):

options = parser.parse_args()
fname = options.geometry
if fname.startswith('/eos/'):
fname = os.environ['EOSSHIP'] + fname
fgeom = ROOT.TFile.Open(fname)
fGeo = fgeom.FAIRGeom
top = fGeo.GetTopVolume()
Expand Down
4 changes: 1 addition & 3 deletions macro/run_simScript.py
Original file line number Diff line number Diff line change
Expand Up @@ -473,9 +473,7 @@
MuonBackgen.Init(inputFile,options.firstEvent,options.phiRandom)
MuonBackgen.SetSmearBeam(5 * u.cm) # radius of ring, thickness 8mm
if DownScaleDiMuon:
if inputFile[0:4] == "/eos": test = os.environ["EOSSHIP"]+inputFile
else: test = inputFile
testf = ROOT.TFile.Open(test)
testf = ROOT.TFile.Open(inputFile)
if not testf.FileHeader.GetTitle().find('diMu100.0')<0:
MuonBackgen.SetDownScaleDiMuon() # avoid interference with boosted channels
print("MuonBackgenerator: set downscale for dimuon on")
Expand Down
18 changes: 6 additions & 12 deletions shipgen/GenieGenerator.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,13 @@ Bool_t GenieGenerator::Init(const char* fileName) {
// ----- Default constructor -------------------------------------------
Bool_t GenieGenerator::Init(const char* fileName, const int firstEvent) {
fNuOnly = false;
if (0 == strncmp("/eos",fileName,4) ) {
TString tmp = gSystem->Getenv("EOSSHIP");
tmp+=fileName;
fInputFile = TFile::Open(tmp);
LOGF(info, "Opening input file on eos %s", tmp.Data());
}else{
fInputFile = new TFile(fileName);
LOGF(info, "Opening input file %s", fileName);
fInputFile = TFile::Open(fileName);
LOG(INFO) << "Opening input file " << fileName;
if (!fInputFile) {
LOG(FATAL) << "Error opening input file.";
return kFALSE;
}
if (fInputFile->IsZombie() or !fInputFile) {
LOG(FATAL) << "Error opening input file";
return kFALSE; }
fTree = (TTree *)fInputFile->Get("gst");
fTree = dynamic_cast<TTree*>(fInputFile->Get("gst"));
fNevents = fTree->GetEntries();
fn = firstEvent;
fTree->SetBranchAddress("Ev",&Ev); // incoming neutrino energy
Expand Down
71 changes: 30 additions & 41 deletions shipgen/HNLPythia8Generator.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -36,52 +36,41 @@ Bool_t HNLPythia8Generator::Init()
fPythia->setRndmEnginePtr(fRandomEngine);
fn = 0;
if (fextFile && *fextFile) {
if (0 == strncmp("/eos",fextFile,4) ) {
TString tmp = gSystem->Getenv("EOSSHIP");
tmp+=fextFile;
fInputFile = TFile::Open(tmp);
LOGF(info, "Open external file with charm or beauty hadrons on eos: %s", tmp.Data());
if (!fInputFile) {
LOG(FATAL) << "Error opening input file. You may have forgotten to provide a krb5 token. Try kinit username@lxplus.cern.ch";
return kFALSE; }
}else{
LOGF(info, "Open external file with charm or beauty hadrons: %s", fextFile);
fInputFile = new TFile(fextFile);
fInputFile = TFile::Open(fextFile);
LOG(info) << "Open external file with charm or beauty hadrons: " << fextFile;
if (!fInputFile) {
LOG(FATAL) << "Error opening input file";
return kFALSE; }
}
if (fInputFile->IsZombie()) {
LOG(FATAL) << "File is corrupted";
return kFALSE; }
fTree = (TTree *)fInputFile->Get("pythia6");
fNevents = fTree->GetEntries();
fn = firstEvent;
fTree->SetBranchAddress("id",&hid); // particle id
fTree->SetBranchAddress("px",&hpx); // momentum
fTree->SetBranchAddress("py",&hpy);
fTree->SetBranchAddress("pz",&hpz);
fTree->SetBranchAddress("E",&hE);
fTree->SetBranchAddress("M",&hM);
fTree->SetBranchAddress("mid",&mid); // mother
fTree->SetBranchAddress("mpx",&mpx); // momentum
fTree->SetBranchAddress("mpy",&mpy);
fTree->SetBranchAddress("mpz",&mpz);
fTree->SetBranchAddress("mE",&mE);
LOG(FATAL) << "Error opening input file.";
return kFALSE;
}

fTree = fInputFile->Get<TTree>("pythia6");
fNevents = fTree->GetEntries();
fn = firstEvent;
fTree->SetBranchAddress("id", &hid); // particle id
fTree->SetBranchAddress("px", &hpx); // momentum
fTree->SetBranchAddress("py", &hpy);
fTree->SetBranchAddress("pz", &hpz);
fTree->SetBranchAddress("E", &hE);
fTree->SetBranchAddress("M", &hM);
fTree->SetBranchAddress("mid", &mid); // mother
fTree->SetBranchAddress("mpx", &mpx); // momentum
fTree->SetBranchAddress("mpy", &mpy);
fTree->SetBranchAddress("mpz", &mpz);
fTree->SetBranchAddress("mE", &mE);
}else{
if ( debug ){std::cout<<"Beam Momentum "<<fMom<<std::endl;}
fPythia->settings.mode("Beams:idA", fId);
fPythia->settings.mode("Beams:idB", 2212);
fPythia->settings.mode("Beams:frameType", 2);
fPythia->settings.parm("Beams:eA",fMom);
fPythia->settings.parm("Beams:eB",0.);
LOG(debug) << "Beam Momentum " << fMom;
fPythia->settings.mode("Beams:idA", fId);
fPythia->settings.mode("Beams:idB", 2212);
fPythia->settings.mode("Beams:frameType", 2);
fPythia->settings.parm("Beams:eA", fMom);
fPythia->settings.parm("Beams:eB", 0.);
}
TDatabasePDG* pdgBase = TDatabasePDG::Instance();
Double_t root_ctau = pdgBase->GetParticle(fHNL)->Lifetime();
fctau = fPythia->particleData.tau0(fHNL); //* 3.3333e-12
if ( debug ){
std::cout<<"tau root "<<root_ctau<< "[s] ctau root = " << root_ctau*3e10 << "[cm]"<<std::endl;
std::cout<<"ctau pythia "<<fctau<<"[mm]"<<std::endl;
LOG(debug) << "tau root " << root_ctau << "[s] ctau root = " << root_ctau * 3e10 << "[cm]";
LOG(debug) << "ctau pythia " << fctau << "[mm]";
if (debug) {
List(9900015);
}
fPythia->init();
Expand Down Expand Up @@ -257,7 +246,7 @@ void HNLPythia8Generator::SetParameters(char* par)
{
// Set Parameters
fPythia->readString(par);
if ( debug ){std::cout<<"fPythia->readString(\""<<par<<"\")"<<std::endl;}
LOG(debug) << "fPythia->readString(\"" << par << "\")";
}

// -------------------------------------------------------------------------
22 changes: 7 additions & 15 deletions shipgen/MuDISGenerator.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,16 @@ Bool_t MuDISGenerator::Init(const char* fileName, const int firstEvent) {

iMuon = 0;
dPart = 0;
if (0 == strncmp("/eos",fileName,4) ) {
TString tmp = gSystem->Getenv("EOSSHIP");
tmp+=fileName;
fInputFile = TFile::Open(tmp);
LOGF(info, "Open external file on eos: %s", tmp.Data());
}else{
fInputFile = new TFile(fileName);
fInputFile = TFile::Open(fileName);
if (!fInputFile) {
LOG(FATAL) << "Error opening input file";
return kFALSE;
}
if (fInputFile->IsZombie() or !fInputFile) {
LOG(FATAL) << "Error opening input file";
return kFALSE; }
fTree = (TTree *)fInputFile->Get("DIS");
fTree = fInputFile->Get<TTree>("DIS");
fNevents = fTree->GetEntries();
fn = firstEvent;
fTree->SetBranchAddress("InMuon",&iMuon); // incoming muon
fTree->SetBranchAddress("Particles",&dPart);
// cout << "muon DIS Generator number of events "<< fNevents << endl;
fTree->SetBranchAddress("Particles", &dPart);
return kTRUE;
}
Double_t MuDISGenerator::MeanMaterialBudget(const Double_t *start, const Double_t *end, Double_t *mparam)
Expand Down Expand Up @@ -87,8 +80,7 @@ Double_t MuDISGenerator::MeanMaterialBudget(const Double_t *start, const Double_
for (Int_t i=0;i<6;i++) bparam[i]=0;

if (!gGeoManager) {
//AliFatalClass("No TGeo\n");
return 0.;
return 0.;
}
//
Double_t length;
Expand Down
Loading

0 comments on commit 2dc3a8a

Please sign in to comment.