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)