I have a TTree that contains a TClonesArray of TObjString’s, and I’m loading it in the following way (N.B. I have the same problem with ::Scan whether I use a TChain or a TTree).
TChain chain = TChain("Dir/TrackerVtx");
TClonesArray *Vtx = new TClonesArray("TrackerVtx",100);
int NVtx;
chain.AddFile("input.root")
chain.SetBranchAddress("NVtx",&NVtx);
chain.SetBranchAddress("Vtx",&Vtx);
When trying to use the TTree::Scan method, I can only ‘see’ the first instance of the TObjString for a particular row, whereas all other variable types (ints, doubles, floats) I can see the values change for each instance. (N.B. The two variables below are linked; changing G2NeutEvtCode should change EvtCode).
[code]chain.Scan(“Vtx->EvtCode->GetString():Vtx->G2NeutEvtCode”,"",“col=70:”)
- Row * Instance * Vtx->EvtCode->GetString() * Vtx->G2Ne *
-
0 * 0 * nu:14;tgt:1000260560;N:2112;proc:Weak[CC],QES; * 1 *
-
0 * 1 * nu:14;tgt:1000260560;N:2112;proc:Weak[CC],QES; * 1 *
-
0 * 2 * nu:14;tgt:1000260560;N:2112;proc:Weak[CC],QES; * 1 *
-
0 * 3 * nu:14;tgt:1000260560;N:2112;proc:Weak[CC],QES; * 31 *
[/code]
Yet when I run the code below, the TObjString for instance 3 changes to what it should be
[code]chain.GetEntry(0);
TrackerVtx curr_flux;
for(int jvtx=0; jvtx<NVtx; jvtx++){
curr_flux = (TrackerVtx) Vtx->At(jvtx);
cout<<curr_flux->EvtCode->GetString()<<" for vtx: "<<jvtx<< " event: "<<jevt<<endl;
}
nu:14;tgt:1000260560;N:2112;proc:Weak[CC],QES; for vtx: 0 event: 0
nu:14;tgt:1000260560;N:2112;proc:Weak[CC],QES; for vtx: 1 event: 0
nu:14;tgt:1000260580;N:2112;proc:Weak[CC],QES; for vtx: 2 event: 0
nu:14;tgt:1000260560;N:2112;proc:Weak[NC],RES;res:0; for vtx: 3 event: 0
[/code]
How do I get the TTree::Scan method to produce the correct behaviour when using TClonesArray’s of TObjString’s?