# No member named 'PT'

**URL:** <https://root-forum.cern.ch/t/no-member-named-pt/42156>\
**Category:** Newbie\
**Created:** [November 7, 2020, 7:17am UTC](https://root-forum.cern.ch/t/no-member-named-pt/42156 "2020-11-07T07:17:41Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![odylalalaaa](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/odylalalaaa/32/16600_2.png) [@odylalalaaa](https://root-forum.cern.ch/u/odylalalaaa)\
**Post date:** [November 7, 2020, 7:17am UTC](https://root-forum.cern.ch/t/no-member-named-pt/42156/1 "2020-11-07T07:17:42Z")

</div>

hi im very new to root & delphes. im trying to modify the tutorial [https://cp3.irmp.ucl.ac.be/projects/delphes/wiki/WorkBook/TutorialBologna](https://cp3.irmp.ucl.ac.be/projects/delphes/wiki/WorkBook/TutorialBologna)  
im trying to sort the PT after the cuts with

```auto
std::sort(electrons->PT.begin(), electrons->PT.end(), std::greater<int>());

```

but ending up with error

```auto
error: no member named 'PT' in 'std::__1::vector<const Electron *,
std:: __1::allocator<const Electron *> >'___

```

here is some part of my code

````auto
// Create object of class ExRootTreeReader
  ExRootTreeReader *treeReader = new ExRootTreeReader(&chain);
  Long64_t numberOfEntries = treeReader->GetEntries();
  
  // Get pointers to branches used in this analysis
  TClonesArray *branchParticle = treeReader->UseBranch("Particle");
  TClonesArray *branchElectron = treeReader->UseBranch("Electron");
  TClonesArray *branchMuon = treeReader->UseBranch("Muon");
  
//Declare variable
    
    const Electron *elec1, *elec2, *elec3, *elec4;
    const Muon *muon1, *muon2, *muon3, *muon4;
   
    
    vector<const Electron*> *electrons = new vector<const Electron*>();;
    vector<const Muon*> *muons = new vector<const Muon*>();;
   // Loop over all events begins
    for(Int_t entry = 0; entry < numberOfEntries; ++entry)
    {
      // print event number in the file
      if(entry%100==0) cout << "Reading Event " << entry << endl;
      
      // Load selected branches with data from specified event
      treeReader->ReadEntry(entry);
    
       electrons -> clear();
       muons -> clear();

       // Select leptons e||mu with pT > 5 || 7 GeV and |eta| < 2.5 || 2.4
       CollectionFilter(*branchElectron, *electrons , 5.0 , 2.5);
       CollectionFilter(*branchMuon , *muons , 7.0 , 2.4);
   
    //sort the PT from highest to lowest
        std::sort(electrons->PT.begin(), electrons->PT.end(), std::greater<int>());

   // sort Muon PT, High to low
        std::sort(muons->PT.begin(), muons->PT.end(), std::greater<int>());
    ```
i think i am declaring the vectors wrongly, any suggestions on how i can fix this? thanks

_Please read [tips for efficient and successful posting](https://root-forum.cern.ch/t/tips-for-efficient-and-successful-posting/28292) and [posting code](https://root-forum.cern.ch/t/posting-code-read-this-first/28293)_

_ROOT Version:6.22
_Platform:mac osx catalina 15.15.7
_Compiler:Apple clang version 11.0.3 (clang-1103.0.32.29)
````

---

<div class="post-metadata">

**Author:** ![RENATO\_QUAGLIANI](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/renato_quagliani/32/19496_2.png) [@RENATO\_QUAGLIANI](https://root-forum.cern.ch/u/RENATO_QUAGLIANI)\
**Post date:** [November 8, 2020, 5:15pm UTC](https://root-forum.cern.ch/t/no-member-named-pt/42156/2 "2020-11-08T17:15:23Z")

</div>

Hi,  
I wonder if you actually need a  
std::sort(electrons.begin(),elecrrons.end(),[]( const & electron1, const & electron2) { return electron1. Pt() \< electron2. Pt()} ;  
It all depends on the signatures of your containers i think.

---

<div class="post-metadata">

**Author:** ![odylalalaaa](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/odylalalaaa/32/16600_2.png) [@odylalalaaa](https://root-forum.cern.ch/u/odylalalaaa)\
**Post date:** [November 9, 2020, 7:25am UTC](https://root-forum.cern.ch/t/no-member-named-pt/42156/3 "2020-11-09T07:25:51Z")

</div>

hi,  
i wanted to sort my PT in decending order, though i see the example skipping this part

Also i wanted to add the P px py pz to the muons which is in another branch ‘particle’ im not very sure how to do this either, im getting error  
no member named ‘P’ in ‘Muon’ when i execute muon.P()  
below is the example; does leading & subleading means that it is already sorted?

```auto
gSystem->Load("libDelphes");

  // Create chain of root trees
  TChain chain("Delphes");
  chain.Add(inputFile);

  // Create object of class ExRootTreeReader
  ExRootTreeReader *treeReader = new ExRootTreeReader(&chain);
  Long64_t numberOfEntries = treeReader->GetEntries();

  // Get pointers to branches used in this analysis
  TClonesArray *branchParticle = treeReader->UseBranch("Particle");
  TClonesArray *branchElectron = treeReader->UseBranch("Electron");
  TClonesArray *branchMuon = treeReader->UseBranch("Muon");

  // Book histograms
  TH1F *histMinMass = new TH1F("mass_min", "", 50, 00.0, 140.0);
  TH1F *histMaxMass = new TH1F("mass_max", "", 50, 00.0, 140.0);
  TH1F *histMass = new TH1F("mass", "", 50, 100, 150);

  TH1F *histMinMassGen = new TH1F("mass_min_gen", "", 50, 0.0, 140.0);
  TH1F *histMaxMassGen = new TH1F("mass_max_gen", "", 50, 00.0, 140.0);
  TH1F *histMassGen = new TH1F("mass_gen", "", 50, 100, 150);

  // Define variables
  const Electron *elec1, *elec2;
  const Muon *muon1, *muon2;

  const GenParticle *gen_elec1, *gen_elec2;
  const GenParticle *gen_muon1, *gen_muon2;

  vector<const Electron*> *electrons = new vector<const Electron*>();;
  vector<const Muon*> *muons = new vector<const Muon*>();;

  Double_t massMin, massMax, mass, massEE, massMM;
  Double_t gen_massMin, gen_massMax, gen_mass, gen_massEE, gen_massMM;

  // Loop over all events
  for(Int_t entry = 0; entry < numberOfEntries; ++entry)
  {
    // Load selected branches with data from specified event
    treeReader->ReadEntry(entry);

    electrons -> clear();
    muons -> clear();

    // Select leptons with pT > 10 GeV and |eta| < 2.5
    CollectionFilter(*branchElectron, *electrons , 10.0 , 2.5);
    CollectionFilter(*branchMuon , *muons , 10.0 , 2.5);

    // Select event with at least 2 electrons and 2 muons
    if(electrons->size() < 2) continue;
    if(muons->size() < 2) continue;

    // Define leading and subleading leptons
    elec1 = electrons->at(0);
    elec2 = electrons->at(1);
    muon1 = muons->at(0);
    muon2 = muons->at(1); 

```

---

<div class="post-metadata">

**Author:** ![Axel](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/axel/32/11084_2.png) [@Axel](https://root-forum.cern.ch/u/Axel)\
**Post date:** [November 9, 2020, 10:53am UTC](https://root-forum.cern.ch/t/no-member-named-pt/42156/4 "2020-11-09T10:53:40Z")

</div>

Hi,

> does leading & subleading means that it is already sorted?

Likely, but should be easy to test, right? And for sorting, Renato is certainly right!

Cheers, Axel.
