Counting Particle flux and energy flux

Hello dear experts,
In my simulation heavy ions collide with metallic cylinder. Lots of particles produce. In all of that particles I am interested in neutrons. I want to calculate there flux throw this cylinder and beyond. As I found there is MultifunctionalDetector class. But from user guide I am not sure I understood how it works. For example I have my cylinder that is one solid object. But I want count flux in every 1cm3. So this class will just count number of particles in whole cylinder or I can somehow tell him how to split my cylinder, and how can I count flux outside? And second question. Now I want to see want energy passed through this cubes. I mean energy that neutrons carry, not deposited.
Maybe there is a way to do it with SteppingAction not SensetiveDetector?

you can use g4scoringmanager class. you should define cylindrical mesh and use g4flatsurfeceflux for counting neutron flux and energy spectrum(particle and energy should be filter in mesh file).

I tried to attach scoringmanager class. And i get some strange error after ending my vis session. This error comes from ROOT. Break segmentation violation. If in my main() i dont create scoring manage i dont have this error. And i dont get it while i am in batch mode. And this error doesnt affect anything.
By mesh file you mean .mac files? So i can make everything only using those macro files? And also what is the difference between flux and current? Cell and FlatSurface? I havent found anything about getting energy of the partilce. So i guess i should implment it myself? Sorry for too many questions

Update: This error i get after SessionStart() function. So when i close my vis session my programm crushes for some reason because of ROOT

Update: It has nothing to do with ROOT but with some other libs. I am working on CLion and recently updated Ubuntu to 20 verison

you should add #include “G4ScoringManager.hh” andG4ScoringManager::GetScoringManager(); in main() .
for conting neutrons in cylinder, you act like this:
score/create/boxMesh energyspec
/score/mesh/cylinderSize 10 10 cm #define cylinder withradiuse=10 cm and half lenght=10 cm
/score/mesh/translate/xyz 0 0 0 nm # position of mesh
/score/mesh/nBin 10 10 10 #number of mesh in three direction
/score/quantity/cellFlux flux100 # calculate particle flux in mesh cells
/score/filter/particleWithKineticEnergy f100 0.49 0.69 MeV neutron #calculate neutron fluence in this range
/score/quantity/cellFlux flux101
/score/filter/particleWithKineticEnergy f101 0.69 0.89 MeV neutron
/score/quantity/cellFlux flux102
/score/filter/particleWithKineticEnergy f102 0.89 1.09 MeV neutron
you can read geant4 manual (page=159) for additional information .

Can i create those spectrum filters with loop?

in mesh scoring you can not use that

i have a question for you, when you get your results how can you plot them in the graph.