| Summary: | Cannot Create Analysis Histograms by specifying edges vector | ||
|---|---|---|---|
| Product: | Geant4 | Reporter: | Sebastian Preuss <s.preuss> |
| Component: | analysis | Assignee: | Ivana Hrivnacova <ivana> |
| Status: | RESOLVED FIXED | ||
| Severity: | normal | CC: | s.preuss |
| Priority: | P4 | ||
| Version: | 11.1 | ||
| Hardware: | All | ||
| OS: | All | ||
| Attachments: | Minimum working example included above as a .cc file | ||
Hello, Thank you for reporting this problem; the option with user defined histogram edges was not included in our regular testing, that's why we did not see it with the last refactoring of the analysis code. The fix is in now available in the development version (including a test) and it is also scheduled for the next patch for 11.1. With best regards, Ivana Hrivnacova |
Created attachment 811 [details] Minimum working example included above as a .cc file When using the G4AnalysisManager::CreateH1("name", "title", std::vector<G4double> edges) Constructor, the histogram is not created and the warning 'Illegal value of x (min >= max)' is given. Same goes for H2 and H3. A minimum working example showcasing this bug is given at the end. The problem is in geant4-v11.1.1/source/analysis/management/include/G4HnInformation.hh, where in lines 56-61, the fMinValue and fMaxValue of G4HnDimension are both set to zero; afterwards in geant4-v11.1.1/source/analysis/management/src/G4HnInformation.cc, in lines 174-178, these zeroes are compared to each other and the check obviously fails. This problem would not occur, if the CheckMinMax(G4double, G4double)-function in G4HnInformation.cc, line 137-147 were to be used, but this would in turn eliminate the information about which dimension's values are off. MWE: #include "G4RunManagerFactory.hh" #include "G4UImanager.hh" #include "FTFP_BERT.hh" #include "G4AnalysisManager.hh" #include "G4VUserDetectorConstruction.hh" #include "G4VUserActionInitialization.hh" #include "G4VPhysicalVolume.hh" #include <vector> class DetectorConstruction : public G4VUserDetectorConstruction { public: DetectorConstruction() {} ~DetectorConstruction() override {} G4VPhysicalVolume *Construct() override { return nullptr; }; }; class ActionInitialization : public G4VUserActionInitialization { public: ActionInitialization() {} ~ActionInitialization() override {} void Build() const override {} }; int main(int argc, char **argv) { auto *runManager = G4RunManagerFactory::CreateRunManager(G4RunManagerType::Default); auto *analysisManager = G4AnalysisManager::Instance(); std::vector<G4double> edges = {1., 2., 3., 4.}; int id = analysisManager->CreateH1("name", "title", edges); if (id == G4Analysis::kInvalidId) { //this prints, in addition to a G4 warning message G4cout << "ID is invalid" << G4endl; } // Set mandatory initialization classes // // Detector construction runManager->SetUserInitialization(new DetectorConstruction()); // Physics list runManager->SetUserInitialization(new FTFP_BERT); // User action initialization runManager->SetUserInitialization(new ActionInitialization()); runManager->BeamOn(1); delete runManager; }