Transverse mass calculalation from arrays with different lengths

Hello,
I have a very general question regarding the calculation of a transverse mass. I have a MC data .root file from a ttbar->WbWb->lepton,neutrino,2jets decay. Lets say I wanted to calculate the transverse mass of the one W boson decaying to an electron and a neutrino. I now have the float arrays of the transverse momentum of the electron and the neutrino to calculate transverse mass via a given formula.

Now my question: What if the arrays are of different lengths/have different amount of entries? I get a mass for every pair of momentum of the leptons but what if there are more statistics in one than the other? (say 1000 entries for electron transverse momentum and 3000 for neutrino transverse momentum.) This is kind of the code I have so far, I just started using ROOT a week ago. This is in the .C file in the “Process” section corresponding to the .h file created by TSelector().

   for (Float_t elphi : el_phi) {       
      for (Float_t elpt : el_pt){         	    

			TLorentzVector P_elec;
   			TLorentzVector P_neut;            
			// Set TLorentzVector values
            P_elec.SetPtEtaPhiM(elpt, 0, elphi, 0);
            P_neut.SetPtEtaPhiM(*met_met, 0, *met_phi, 0);

            // Calculate transverse mass
	      Double_t W_transverse_mass = (P_elec + P_neut).Mt();
            // Output the transverse mass
            hist->Fill(W_transverse_mass);
      }
    }

el_pt and el_phi are TTreeReaderArray while met_met and met_phi are TTreeReaderValue<Float_t>.
In the code met_met is kind of the transverse momentum of the neutrino and phi the azimutal angle to calculate transverse mass.
Ive been having some trouble so hopefully someone can help me out. Thanks alot!


Dear @helton ,

Sorry for the late reply, this post slipped through.

First off, I see you are using TLorentzVector. If you read the documentation, you will see that this class is highly discouraged. You should use the superior alternative ROOT::Math::LorentzVector.

Second, from your code I understand that what you are trying to do is to compute for multiple instances of elphi and elpt the corresponding transverse mass of the same neutrino observables met_met and met_phi. I am not sure about this use case. More often, the calculations are done per event, so that only observables related to the same event are involved in the computation. Unless what you mean is that within a certain event you have N leptons but only one neutrino.

In any case, I would highly suggest that you try to frame your analysis with the API of RDataFrame. Maybe take a look at the documentation and then I can try to guide you towards writing the analysis once you have specific questions.

Cheers,
Vincenzo

Hi Vincenzo,

yes you are right I indeed wanted to do the calculations per event. Ive learned from there so the question is obsolete now. Thanks!