-
Notifications
You must be signed in to change notification settings - Fork 27
Muon DIS with Pythia6 run through Geant4 #280
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 1 commit
a6fec0b
3d32a53
f128a66
877e6bd
36b336c
52c44a1
2c9636c
590ce52
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| #include "MuonDISProcessInjector.h" | ||
| #include "G4MuonMinus.hh" | ||
| #include "G4MuonPlus.hh" | ||
| #include "G4ProcessManager.hh" | ||
| #include "G4MuonDISProcess.hh" | ||
| #include "FairLogger.h" | ||
| #include "TFile.h" | ||
| #include "TGraph.h" | ||
| #include <exception> | ||
| #include <vector> | ||
|
|
||
| using std::vector; | ||
|
|
||
| // Convert ROOT's TGraph to G4PhysicsFreeVector | ||
| G4PhysicsFreeVector* GraphToFreeVector(TGraph* graph) { | ||
| auto xsec_data = new G4PhysicsFreeVector(); | ||
| for (int i = 0; i < graph->GetN(); ++i) { | ||
| double x, y; | ||
| graph->GetPoint(i, x, y); | ||
| xsec_data->InsertValues(x, y); | ||
| } | ||
| return xsec_data; | ||
| } | ||
|
|
||
| MuonDISProcessInjector::MuonDISProcessInjector(char *nucleon, vector<float> x_range, vector<float> y_range, | ||
| vector<float> z_range, char *volume, char *xsec_filename) | ||
| : FairTask("MuonDISProcessInjector") | ||
| { | ||
| fNucleon = nucleon; | ||
| fVolumeName = volume; | ||
| fXRange = x_range; | ||
| fYRange = y_range; | ||
| fZRange = z_range; | ||
|
|
||
| TFile* xsec_file = new TFile(xsec_filename); | ||
| if(!xsec_file || xsec_file->IsZombie()){ | ||
| LOG(FATAL) << "DIS cross section file not found"; | ||
| exit(0); | ||
| } | ||
| TGraph* crsec_muminus = static_cast<TGraph*> (xsec_file->Get(Form("g_13_%s", fNucleon))); | ||
| TGraph* crsec_muplus = static_cast<TGraph*> (xsec_file->Get(Form("g_-13_%s", fNucleon))); | ||
| if (!crsec_muminus || !crsec_muplus){ | ||
| LOG(FATAL) << "DIS cross section graphs per " << fNucleon <<" are missing in "<< xsec_filename; | ||
| exit(0); | ||
| } | ||
|
|
||
| fXsecTables = std::make_shared<std::map<int, G4PhysicsFreeVector*>>(); | ||
| fXsecTables->insert({13, GraphToFreeVector(crsec_muminus)}); | ||
| fXsecTables->insert({-13, GraphToFreeVector(crsec_muplus)}); | ||
|
|
||
| LOG(WARNING) << "MuonDISProcessInjector: Setting xyz ranges[cm] for muon DIS\nx: " | ||
| << fXRange[0] << ", " << fXRange[1] << "\ny: " << fYRange[0] << ", " << fYRange[1] << "\nz: " | ||
| << fZRange[0] << ", " << fZRange[1] << "\nand volume name '" << fVolumeName | ||
| << "' and nucleon type " << fNucleon; | ||
| } | ||
|
|
||
| InitStatus MuonDISProcessInjector::Init() | ||
| { | ||
| muMinus = G4MuonMinus::Definition(); | ||
| muPlus = G4MuonPlus::Definition(); | ||
|
|
||
| DISProcess = new G4MuonDISProcess(); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does the process-manager free this? Since the process is added to two different ones, probably not? |
||
|
|
||
| // Set the nucleon type | ||
| DISProcess->SetNucleonType(fNucleon); | ||
| // Set DIS xsec lookup tables per set nucleon type | ||
| DISProcess->SetCrossSectionTables(fXsecTables); | ||
| // Set the z range of the DIS interaction | ||
| DISProcess->SetRange(&fXRange, &fYRange, &fZRange); | ||
| // Set the name of the geo volume for the DIS interaction | ||
| DISProcess->SetVolume(fVolumeName); | ||
|
|
||
| auto process_man_muminus = muMinus->GetProcessManager(); | ||
| if (process_man_muminus) { | ||
| G4int id_muminus = process_man_muminus->AddDiscreteProcess(DISProcess); | ||
| } | ||
| auto process_man_muplus = muPlus->GetProcessManager(); | ||
| if (process_man_muplus) { | ||
| G4int id_muplus = process_man_muplus->AddDiscreteProcess(DISProcess); | ||
| } | ||
|
|
||
| LOG(WARNING) << "Adding the external generation for muon DIS using Pythia6"; | ||
| return kSUCCESS; | ||
| } | ||
|
|
||
| ClassImp(MuonDISProcessInjector) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This isn't needed. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| #ifndef MUONDISPROCESSINJECTOR_H | ||
| #define MUONDISPROCESSINJECTOR_H | ||
|
|
||
| #include "FairTask.h" | ||
| #include "G4ParticleDefinition.hh" | ||
| #include "G4MuonDISProcess.hh" | ||
| #include <vector> | ||
| #include <map> | ||
|
|
||
| class G4PhysicsFreeVector; | ||
|
|
||
| class MuonDISProcessInjector : public FairTask { | ||
| public: | ||
| MuonDISProcessInjector(char *nucleon, std::vector<float> x_range, std::vector<float> y_range, | ||
| std::vector<float> z_range, char *volume, char *xsec_filename); | ||
| virtual ~MuonDISProcessInjector() {} | ||
|
|
||
| virtual InitStatus Init(); | ||
|
|
||
| char *fNucleon; //! nucleon type | ||
| char *fVolumeName; //! geometry volume name to place the DIS | ||
|
Comment on lines
+20
to
+21
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd prefer using std::string here (and if necessary accessing the C-string when needed). |
||
| std::vector<float> fXRange; /// x range to place the DIS | ||
| std::vector<float> fYRange; /// y range to place the DIS | ||
| std::vector<float> fZRange; /// z range to place the DIS | ||
| std::shared_ptr<std::map<int, G4PhysicsFreeVector*>> fXsecTables; /// DIS cross section lookup tables | ||
| const G4ParticleDefinition *muPlus; | ||
| const G4ParticleDefinition *muMinus; | ||
|
Comment on lines
+26
to
+27
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are these const? They are updated in Init, I'm surprised this compiles. |
||
| G4MuonDISProcess *DISProcess; | ||
|
|
||
| ClassDef(MuonDISProcessInjector, 1); | ||
| }; | ||
|
|
||
| #endif | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TFile::Open is more robust, checks for Zombie and can open remote files automatically.