I am creating a root file using Geant4 (10.04) and ROOT 6.14. The histograms of volume name (name of the shape of the detector model) and ptype (particle type, e.g., electron, neutron, etc.) show weird Special Characters (instead of the real volume name provided in geant4). The volume name looks fine on terminal window when the code executes, it is just the generated root file that displays weird special characters.
Other histogram which have numeric characters instead of alphabets are fine in the root file. These codes worked fine when I was using Mac but I see the special characters in Ubuntu. I would appreciate any suggestions as I am just a beginner.
Thanks,
Manish
ROOT Version: 6.14 Platform: Ubuntu 18.04 Compiler: Not Provided
Thanks for your reply. Here is what I have set in Geant4:
“G4Tubs* scint_shape = new G4Tubs("NaI_Scint", 0*cm,radius*cm, radius*cm, 0.0*deg, 360.*deg);”
Where “NaI_Scint” is volume name, which is displayed correctly on terminal window with notification: “Checking overlaps for volume NaI_Scint … OK!”
However, it s shown as x^3 in the simulated root file (attached, see volname). Of course I tried changing NaI_Scint to just NaI, but the name was displayed wrong here as well. These codes were working fine on Mac, just giving me hard time on Ubuntu!
You need to inspect how you define the “MC_out” tree, in particular its “ptype” and “volumeName” branches.
Try to run “MC_out->MakeClass();” and then see the “MC_out.h” file. You will find "Char_t ptype[5]; and Char_t volumeName[5];, which means that your names can be 4 characters long at most (plus the null character which ends the string, of course, hence at most 5 characters in total).
Moreover, you should also inspect the place where you fill these branches as it seems to me that they use uninitialized variables.
Note also that the “NaI_Scint” in the “G4Tubs” call is actually converted into a “G4String” which is basically a “std:string” (NOT a “char *”).
So, I inspected the way volumeName is filled in my code:
// ================
G4String VolName=aStep->GetPreStepPoint()->GetTouchableHandle()
->GetVolume()->GetName();
One of the things I noticed, however, is the way volumeName branch is different from the other branches. The data is visible in data() under volumeName.
My goal now is to analyze this root file and determine which events were in that volume (NaI). For example, in my earlier analysis code that worked on MAC OS, I was setting:
#include "string"
Char_t volumeName[15];
TBranch *b_volumeName;
fChain->SetBranchAddress("volumeName", volumeName, &b_volumeName);
if(volumeName[3]== 'I'){ // desired events happening in NaI
// then execute this loop...
} // if loop ends
I now tried updating Char_t volumeName[15] to string *volumeName; volumeName=0; and fChain->SetBranchAddress("volumeName", &volumeName, &b_volumeName); based on what I have seen in MC_out.h but what I should be using to execute something like the if loop above.
Thanks. I tried analyzing my root file and I am able to analyze other branches. For example:
if(pdgNum == 22){
… // Do this
}
The above works fine. However I am not able to access the data of volumeName. In theory I want to implement:
if(volumeName[3] == ‘I’ ){ // Events happening in NaI only
… // Do this
}
When I have two volumes (e.g., NaI, and EJ230), I am interested in events happenign in NaI only by using something like the above if loop.build.root (9.1 KB)