Dear All,
I am trying to produce the pairwise combinations of non-muon (pion) tracks in my TTree and select only the combinations yielding zero net charge in ROOT. I have a working PyRoot solution which uses numpy
and itertools
:
pi_idxs=np.where(isMuon!=1) #indices of pion tracks
temp=np.array(list(itertools.combinations(pi_idxs[0], 2))) #combinatorics of indices of hadron tracks, no repetitions, pairwise combinations
neutral_pairs_idxs = temp[np.where(np.sum(Charge[temp], axis=1)==0)]
What I have done is retrieve the indices of non-muon tracks in an array and then proceed with the manipulation of the indices.
In ROOT I am finding this rather tedious, as I am less capable of manipulating indices.
My current TTree have the following structure (from mymacro.h compiled using MakeFile tutorial)
class mymacro {
public :
TTree *fChain; //!pointer to the analyzed TTree or TChain
Int_t fCurrent; //!current Tree number in a TChain
// Fixed size dimensions of array or collections stored in the TTree if any.
// Declaration of leaf types
Int_t run;
Int_t evt;
Int_t bunchid;
Int_t bunchtype;
Int_t trighlt1;
Int_t trigmu;
Int_t l0dim;
Int_t l0m;
Int_t stripphi;
Int_t nlong;
Int_t nvelo;
Int_t down;
Int_t ntk;
Int_t nspd;
Int_t ntotphot;
Int_t nout;
Int_t nphotons;
Float_t etprev1;
Float_t etprev2;
Int_t tt[10]; //[nout]
Float_t tx[10]; //[nout]
Float_t ty[10]; //[nout]
Float_t tz[10]; //[nout]
Float_t px[10]; //[nout]
Float_t py[10]; //[nout]
Float_t pz[10]; //[nout]
Float_t pt[10]; //[nout]
Int_t charge[10]; //[nout]
Int_t muon[10]; //[nout]
Int_t muacc[10]; //[nout]
Float_t pide[10]; //[nout]
Float_t pidk[10]; //[nout]
Float_t pidpi[10]; //[nout]
Float_t pidp[10]; //[nout]
Float_t pidm[10]; //[nout]
Float_t ecal[10]; //[nout]
Float_t hcal[10]; //[nout]
Float_t eoverp[10]; //[nout]
Float_t phx[6]; //[nphotons]
Float_t phy[6]; //[nphotons]
Float_t phz[6]; //[nphotons]
Int_t spd[6]; //[nphotons]
Int_t prs[6]; //[nphotons]
Int_t nl0;
Float_t l0et[3]; //[nl0]
Float_t l0phi[3]; //[nl0]
Float_t l0theta[3]; //[nl0]
Int_t nher;
Int_t herchan[30]; //[nher]
Int_t heradc[30]; //[nher]
// List of branches
TBranch *b_run; //!
TBranch *b_evt; //!
TBranch *b_bunchid; //!
TBranch *b_bunchtype; //!
TBranch *b_trighlt1; //!
TBranch *b_trigmu; //!
TBranch *b_l0dim; //!
TBranch *b_l0m; //!
TBranch *b_stripphi; //!
TBranch *b_nlong; //!
TBranch *b_nvelo; //!
TBranch *b_ndown; //!
TBranch *b_ntk; //!
TBranch *b_nspd; //!
TBranch *b_ntotphot; //!
TBranch *b_nout; //!
TBranch *b_nphotons; //!
TBranch *b_etprev1; //!
TBranch *b_etprev2; //!
TBranch *b_tt; //!
TBranch *b_tx; //!
TBranch *b_ty; //!
TBranch *b_tz; //!
TBranch *b_px; //!
TBranch *b_py; //!
TBranch *b_pz; //!
TBranch *b_pt; //!
TBranch *b_charge; //!
TBranch *b_muon; //!
TBranch *b_muacc; //!
TBranch *b_pide; //!
TBranch *b_pidk; //!
TBranch *b_pidpi; //!
TBranch *b_pidp; //!
TBranch *b_pidm; //!
TBranch *b_ecal; //!
TBranch *b_hcal; //!
TBranch *b_eoverp; //!
TBranch *b_phx; //!
TBranch *b_phy; //!
TBranch *b_phz; //!
TBranch *b_spd; //!
TBranch *b_prs; //!
TBranch *b_nl0; //!
TBranch *b_l0et; //!
TBranch *b_l0phi; //!
TBranch *b_l0theta; //!
TBranch *b_nher; //!
TBranch *b_herchan; //!
TBranch *b_heradc; //!
mymacro(TTree *tree=0);
virtual ~mymacro();
virtual Int_t Cut(Long64_t entry);
virtual Int_t GetEntry(Long64_t entry);
virtual Long64_t LoadTree(Long64_t entry);
virtual void Init(TTree *tree);
virtual void Loop();
virtual Bool_t Notify();
virtual void Show(Long64_t entry = -1);
};
where nout
out is the number of tracks per event, and I am interested in selecting those such that muon != 1
, combining the charges associated with the tracks and selecting only pairwise non-muon like tracks with net charge == 0
.
Hopefully I have explained my query clearly. Thank you.