Skip to content

Commit

Permalink
Renamed list_of_particles_from_decay into get_list_of_particles_from_…
Browse files Browse the repository at this point in the history
…decay, idem for list_of_stable_particles.

For backward compatibility, kept a function list_of_particles_from_decay, that calls get_list_of_particles_from_decay
and prints a message that this function has been renamed.
  • Loading branch information
EmanuelPerez committed Jul 14, 2021
1 parent ca80410 commit 0681e5d
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 10 deletions.
36 changes: 28 additions & 8 deletions analyzers/dataframe/MCParticle.cc
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ edm4hep::MCParticleData MCParticle::sel_byIndex( int idx, ROOT::VecOps::RVec<edm

// ----------------------------------------------------------------------------------------------------------------------------------

std::vector<int> MCParticle::list_of_stable_particles_from_decay( int i, ROOT::VecOps::RVec<edm4hep::MCParticleData> in, ROOT::VecOps::RVec<int> ind) {
std::vector<int> MCParticle::get_list_of_stable_particles_from_decay( int i, ROOT::VecOps::RVec<edm4hep::MCParticleData> in, ROOT::VecOps::RVec<int> ind) {

std::vector<int> res;
// i = index of a MC particle in the Particle block
Expand All @@ -461,9 +461,9 @@ std::vector<int> MCParticle::list_of_stable_particles_from_decay( int i, ROOT::V
//int d1 = ind[db] ;
//int d2 = ind[de-1];
//for (int idaughter = d1; idaughter <= d2; idaughter++) {
for (int id = db; id <= de-1; id++) {
for (int id = db; id < de; id++) {
int idaughter = ind[ id ];
std::vector<int> rr = list_of_stable_particles_from_decay( idaughter, in, ind) ;
std::vector<int> rr = get_list_of_stable_particles_from_decay( idaughter, in, ind) ;
res.insert( res.end(), rr.begin(), rr.end() );
}
}
Expand All @@ -476,7 +476,7 @@ std::vector<int> MCParticle::list_of_stable_particles_from_decay( int i, ROOT::V

// ----------------------------------------------------------------------------------------------------------------------------------

std::vector<int> MCParticle::list_of_particles_from_decay(int i, ROOT::VecOps::RVec<edm4hep::MCParticleData> in, ROOT::VecOps::RVec<int> ind) {
std::vector<int> MCParticle::get_list_of_particles_from_decay(int i, ROOT::VecOps::RVec<edm4hep::MCParticleData> in, ROOT::VecOps::RVec<int> ind) {

std::vector<int> res;

Expand All @@ -493,12 +493,32 @@ std::vector<int> MCParticle::list_of_particles_from_decay(int i, ROOT::VecOps::R
//int d2 = ind[de-1];
//for (int idaughter = d1; idaughter <= d2; idaughter++) {
//res.push_back( idaughter);
for (int id = db; id <= de-1; id++) {
for (int id = db; id < de; id++) {
res.push_back( ind[id] ) ;
}
return res;
}


// ----------------------------------------------------------------------------------------------------------------------------------

// obsolete: keep for the while, for backward compatibility

std::vector<int> MCParticle::list_of_stable_particles_from_decay( int i, ROOT::VecOps::RVec<edm4hep::MCParticleData> in, ROOT::VecOps::RVec<int> ind) {
std::cout << " -------- OBSOLETE ----- call to get_list_of_stable_particles_from_decay , please update your code ----- " << std::endl;
return get_list_of_stable_particles_from_decay( i, in, ind );
}

std::vector<int> MCParticle::list_of_particles_from_decay(int i, ROOT::VecOps::RVec<edm4hep::MCParticleData> in, ROOT::VecOps::RVec<int> ind) {
std::cout << " -------- OBSOLETE ----- call to get_list_of_particles_from_decay , please update your code ----- " << std::endl;
return get_list_of_particles_from_decay( i, in, ind );
}






// ----------------------------------------------------------------------------------------------------------------------------------

ROOT::VecOps::RVec<int> MCParticle::get_indices_ExclusiveDecay_MotherByIndex ( int imother,
Expand Down Expand Up @@ -528,18 +548,18 @@ ROOT::VecOps::RVec<int> MCParticle::get_indices_ExclusiveDecay_MotherByIndex (


if (debug) {
std::vector<int> unstable_products = list_of_particles_from_decay( imother, in, ind ) ;
std::vector<int> unstable_products = get_list_of_particles_from_decay( imother, in, ind ) ;
for ( auto & k: unstable_products) {
std::cout << " ......... unstable daughter PDG = " << in[k].PDG << std::endl;
}
}

std::vector<int> products ;
if ( m_stableDaughters ) {
products = list_of_stable_particles_from_decay( imother, in, ind ) ;
products = get_list_of_stable_particles_from_decay( imother, in, ind ) ;
}
else {
products = list_of_particles_from_decay( imother, in, ind ) ;
products = get_list_of_particles_from_decay( imother, in, ind ) ;
}

if (debug) {
Expand Down
13 changes: 11 additions & 2 deletions analyzers/dataframe/MCParticle.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,16 +183,25 @@ namespace MCParticle{
ROOT::VecOps::RVec<float> AngleBetweenTwoMCParticles( ROOT::VecOps::RVec<edm4hep::MCParticleData> p1, ROOT::VecOps::RVec<edm4hep::MCParticleData> p2 );

/// return the list of stable particles from the decay of a mother particle, looking at the full decay chain recursively. i is the mother index in the Particle block
std::vector<int> list_of_stable_particles_from_decay( int i, ROOT::VecOps::RVec<edm4hep::MCParticleData> in, ROOT::VecOps::RVec<int> ind) ;
std::vector<int> get_list_of_stable_particles_from_decay( int i, ROOT::VecOps::RVec<edm4hep::MCParticleData> in, ROOT::VecOps::RVec<int> ind) ;

/// return the list of particles from the decay of a mother particle. i is the mother index in the Particle block.
std::vector<int> list_of_particles_from_decay( int i,
std::vector<int> get_list_of_particles_from_decay( int i,
ROOT::VecOps::RVec<edm4hep::MCParticleData> in,
ROOT::VecOps::RVec<int> ind) ;

/// returns one MCParticle selected by its index in the particle block
edm4hep::MCParticleData sel_byIndex( int idx, ROOT::VecOps::RVec<edm4hep::MCParticleData> in) ;

/// obsolete: should use get_list_of_stable_particles_from_decay instead
std::vector<int> list_of_stable_particles_from_decay( int i, ROOT::VecOps::RVec<edm4hep::MCParticleData> in, ROOT::VecOps::RVec<int> ind) ;
/// obsolete: should use get_list_of_particles_from_decay instead
std::vector<int> list_of_particles_from_decay( int i,
ROOT::VecOps::RVec<edm4hep::MCParticleData> in,
ROOT::VecOps::RVec<int> ind) ;




}
#endif

0 comments on commit 0681e5d

Please sign in to comment.