Fork me on GitHub

Changeset 367 in svn for trunk


Ignore:
Timestamp:
May 10, 2009, 8:08:45 PM (15 years ago)
Author:
Xavier Rouby
Message:

bug fix if no mother written in the input data. small code-cleaning

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/HepMCConverter.cc

    r362 r367  
    2727**                      Copyright (C) 2008-2009,                      **
    2828**                        All rights reserved.                        ** 
    29   //
    3029**                                                                    **
    3130***********************************************************************/
     
    115114      if ( index_to_particle[j]->production_vertex() )
    116115        {
    117             //HepLorentzVector p = index_to_particle[j]->production_vertex()->position();
    118      
    119116          int num_mothers = index_to_particle[j]->production_vertex()->particles_in_size();
    120           int first_mother = find_in_map( particle_to_index,*(index_to_particle[j]->production_vertex()->particles_in_const_begin()));
    121           int last_mother = first_mother + num_mothers - 1;
    122           if ( first_mother == 0 ) last_mother = 0;
    123           mo1=first_mother;
    124           mo2=last_mother;
     117          if (num_mothers ==0) {
     118            mo1 = 0;
     119            mo2 = 0;
     120          }
     121          else {
     122            int first_mother = find_in_map( particle_to_index,*(index_to_particle[j]->production_vertex()->particles_in_const_begin()));
     123            int last_mother = first_mother + num_mothers - 1;
     124            if ( first_mother == 0 ) last_mother = 0;
     125            mo1=first_mother;
     126            mo2=last_mother;
     127          } // if num_mothers !=0
    125128        }
    126       else
     129      else // no data on production_vertex
    127130        {
    128131          mo1 =0;
     
    173176//---------------------------------------------------------------------------
    174177
    175 void HepMCConverter::AnalyseParticles(ExRootTreeBranch *branch,HepMC::GenEvent& evt)
     178void HepMCConverter::AnalyseParticles(ExRootTreeBranch *branch, const HepMC::GenEvent& evt)
    176179{
    177180  TRootC::GenParticle *element;
     
    203206      float PT = sqrt(pow(element->Px,2)+pow(element->Py,2));
    204207      element->PT = PT;
     208
    205209      momentum.SetPxPyPzE(element->Px, element->Py, element->Pz, element->E);
    206210      signPz = (element->Pz >= 0.0) ? 1.0 : -1.0;
    207       element->Eta = element->PT == 0.0 ? signPz*999.9 : momentum.Eta();
     211      //element->Eta = element->PT == 0.0 ? signPz*999.9 : momentum.Eta(); to avoid a warning from ROOT, replace the "==0" by "< 1e-6"
     212      element->Eta = element->PT < 1e-6 ? signPz*999.9 : momentum.Eta();
    208213      element->Phi = index_to_particle[n]->momentum().phi();
    209214 
Note: See TracChangeset for help on using the changeset viewer.