TypeError: LorentzVector object is not iterable

Hi everyone.
I am trying to get the deltaR from a bunch of montecarlo events. I am doing this:

        events = Events (infile)
        handleGen = Handle ("vector<reco::GenParticle>")
        label = "genParticles"

        leptons = [11, 13, 15, -11, -13, -15]
        quarks = [1, 2, 3, 4, 5, 6, -1, -2, -3, -4, -5, -6]

        for event in events:
                print event
                event.getByLabel (label, handleGen)
                gens = handleGen.product()

                for p in gens:
                        if p.status() == 1:                     # for final particles
                                if p.pdgId() in leptons:
                                        lepton = p.p4()
                                        L = lepton
                        elif p.status() == 3:
                                if p.pdgId() in quarks:         # for particles before parton showering
                                        quark = p.p4()
                                        Q = quark
                for i in L:
                        for j in Q:
                                deltaR = Math.VectorUtil.DeltaR(L[i],Q[j])
                                print deltaR

but I got this error message:

TClass::TClass:0: RuntimeWarning: no dictionary for class type_info is available
Traceback (most recent call last):
  File "plothistos.py", line 187, in <module>
    main(sys.argv[1:])
  File "plothistos.py", line 180, in main
    deltaR(infile)
  File "plothistos.py", line 112, in deltaR
    for i in L:
TypeError: 'ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> >' object is not iterable

I am working on it for a while and I don’t know what I am doing wrong. Please help!!! :blush:

Alejandro Gomez

Hi,

the message says that you can not loop over a TLorentzVector, so instead of “for i in L:” do “for i in range(4):” which from the looks of the rest of the code is what you want to do anyway.

Cheers,
Wim