Skip to content
Snippets Groups Projects
Commit 7226bfd7 authored by Paul Seyfert's avatar Paul Seyfert
Browse files

draft for juggle TISTOS with added interfaces of DTT

parent 9180a1b3
No related branches found
No related tags found
No related merge requests found
......@@ -172,6 +172,15 @@ private:
bool m_revertToPositiveID ;
std::vector<Decays::OnePart*> m_parts;
public:
std::vector<std::string> partsNames() {
std::vector<std::string> ret(m_parts.size(),"");
for (size_t k = 0 ; k < m_parts.size() ; ++k) {
ret[k] = m_parts[k]->headName();
}
return ret;
}
private:
std::vector< IMCParticleTupleTool* > m_mcTools;
std::vector< IEventTupleTool* > m_eTools;
......
......@@ -61,6 +61,30 @@ StatusCode fillTuple( Tuples::Tuple& tuple
return test;
}
public:
void create_row( const LHCb::MCParticle* head
, std::vector<const LHCb::MCParticle*>& row) const
{
const typename Decays::iTree_<const LHCb::MCParticle*>& decaytree = mcDecayTree();
row.clear();
if ( decaytree(head) && decaytree.marked() ) {
decaytree.collect(row);
}
row.insert( row.begin(), head ); // must insert the head as it cant be flagged.
}
void create_row( const LHCb::Particle* head
, std::vector<const LHCb::Particle*>& row) const
{
const typename Decays::iTree_<const LHCb::Particle*>& decaytree = decayTree();
row.clear();
if ( decaytree(head) && decaytree.marked() ) {
decaytree.collect(row);
}
row.insert( row.begin(), head ); // must insert the head as it cant be flagged.
}
protected:
template<class PARTICLE,class COLLECTION>
StatusCode fillTuple( typename Tuple::Tuple& tuple
, COLLECTION heads
......@@ -72,11 +96,7 @@ StatusCode fillTuple( typename Tuple::Tuple& tuple
for ( typename COLLECTION::const_iterator pIt = heads.begin(); pIt != heads.end(); ++pIt ) {
if (msgLevel(MSG::DEBUG)) debug() << "######################################## New head" << endmsg ;
test = StatusCode::FAILURE;
row.clear();
if ( decaytree(*pIt) && decaytree.marked() ) {
decaytree.collect(row);
}
row.insert( row.begin(), *pIt ); // must insert the head as it cant be flagged.
create_row(*pIt, row);
if( fillParticles( tuple, row ) ) {
tuple->column( "nCandidate", nCandidates ).ignore();
......
// Include files
// from Gaudi
#include "GaudiKernel/ToolFactory.h"
#include <Kernel/GetIDVAlgorithm.h>
#include <Kernel/IDVAlgorithm.h>
// local
#include "TupleToolJuggleTisTos.h"
using namespace LHCb;
//-----------------------------------------------------------------------------
// Implementation file for class : TupleToolJuggleTisTos
// @author Paul Seyfert
// @date 2016-11-30
//-----------------------------------------------------------------------------
DECLARE_TOOL_FACTORY( TupleToolJuggleTisTos )
/**
* @brief constructor
*
* Inherit from TupleToolTISTOS and call its constructor.
* declare the property Locations
*/
TupleToolJuggleTisTos::TupleToolJuggleTisTos( const std::string& type,
const std::string& name,
const IInterface* parent )
: TupleToolTISTOS ( type, name , parent ),
m_dva(nullptr)
{
declareInterface<IParticleTupleTool>(this);
declareProperty("Locations", m_locations,
"decay descriptors of the particle combination which should be TISTOSed");
}
///**
// * @brief clean up memory
// *
// * @return always SUCCESS
// * @todo FIXME tried unique pointers, computer said no.
// */
//StatusCode TupleToolJuggleTisTos::finalize() {
// return StatusCode::SUCCESS;
//}
/**
* @brief initialize algorithm
*
* * instantiate LoKi::Child::Selectors (which parse the decay descriptor to
* obtain descentants from the decay chain)
*
* @return SUCCESS unless there are initialization errors or if the DecayDescriptor is invalid.
*/
StatusCode TupleToolJuggleTisTos::initialize()
{
/// mostly copy&paste from TupleToolGeometry
m_dva = (DecayTreeTupleBase*) Gaudi::Utils::getIDVAlgorithm ( contextSvc(), this )->gaudiAlg() ;
if ( !m_dva ) return Error("Couldn't get parent DVAlgorithm",
StatusCode::FAILURE);
StatusCode sc = TupleToolTISTOS::initialize();
if ( sc.isFailure() ) return sc;
return sc;
}
/**
* @brief
*
* @param t top of the decay chain
* @param P particle in decay chain - ignored to be able to access particle juggeling from top DTT
* @param head part of the branch name determination (forwarded to TupleToolTISTOS)
* @param tuple the ntuple to which columns will get added (forwarded to TupleToolTISTOS)
*
* @return if tuple filling was successful
*/
StatusCode TupleToolJuggleTisTos::fill( const Particle* t
, const Particle*
, const std::string& head
, Tuples::Tuple& tuple )
{
std::vector<const LHCb::Particle*> row;
row.clear();
m_dva->create_row(t,row);
std::vector<std::string> m_parts = m_dva->partsNames();
if (m_parts.size() != row.size() ) {
return Error("OOOOOOOOOOOO",StatusCode::FAILURE);
}
std::vector<const Particle*> components;
const std::string prefix = fullName(head) + "_KEY_";
for (size_t i = 0 ; i < m_locations.size() ; ++i) {
auto loc = m_locations[i];
for (size_t k = 0 ; k < m_parts.size() ; ++k) {
if (loc == m_parts[k]) {
auto daughter = row[k];
components.push_back(daughter);
if (daughter->proto()&&daughter->proto()->track()) {
tuple->column(prefix + Form("%zu",i),daughter->proto()->track()->key()).ignore();
} else {
tuple->column(prefix + Form("%zu",i),daughter->key()).ignore();
}
}
}
}
if (m_locations.size() != components.size() ) {
return Error("Big problem",StatusCode::FAILURE);
}
// forward a completely empty particle in case a child wasn't found
LHCb::Particle cand;
for (const LHCb::Particle* p : components) {
cand.addToDaughters(p);
}
return TupleToolTriggerBase::fill(t,&cand,head,tuple);
}
#ifndef TupleToolJuggleTisTos_H
#define TupleToolJuggleTisTos_H
#include "Kernel/IParticleTupleTool.h"
#include "TupleToolTISTOS.h"
#include "DecayTreeTupleBase/DecayTreeTupleBase.h"
class IDVAlgorithm;
namespace LHCb {
class Particle;
}
/** @class TupleToolJuggleTisTos TupleToolJuggleTisTos.h
*
* @brief DecayTreeTupleTool to make TISTOS branches for specific decay components
*
* Advice to users: Make sure to use the `ExtraName` property!
*
* Main use case is to determine which combination of final state particles in an N body
* decay triggered a M body trigger line (with N>M).
*
* @code
* Bu2JpsiKTuple.Decay = '[B- -> ^(J/psi(1S)-> ^mu+ ^mu-) ^(D- -> ^K+ ^pi- ^pi-) ]CC'
* Bu2JpsiKTuple.addBranches( {
* "Jpsi" : '[B- -> ^(J/psi(1S)-> mu+ mu-) (D- -> K+ pi- pi-) ]CC'
* ,"D_m" : '[B- -> (J/psi(1S)-> mu+ mu-) ^(D- -> K+ pi- pi-) ]CC'
* ,"muon_m" : '[B- -> (J/psi(1S)-> mu+ ^mu-) (D- -> K+ pi- pi-) ]CC'
* ,"muon_p" : '[B- -> (J/psi(1S)-> ^mu+ mu-) (D- -> K+ pi- pi-) ]CC'
* ,"kaon_p" : '[B- -> (J/psi(1S)-> mu+ mu-) (D- -> ^K+ pi- pi-) ]CC'
* ,"pion_1" : '[B- -> (J/psi(1S)-> mu+ mu-) (D- -> K+ ^pi- pi-) ]CC'
* ,"pion_2" : '[B- -> (J/psi(1S)-> mu+ mu-) (D- -> K+ pi- ^pi-) ]CC'
* ,"Bu" : '[B- -> (J/psi(1S)-> mu+ mu-) (D- -> K+ pi- pi-) ]CC'
* } )
*
* example1 = Bu2JpsiKTuple.Bu.addTupleTool('TupleToolJuggleTisTos')
* example1.ExtraName = "KmuOS"
* example1.Locations = [ 'kaon_p'
* ,'muon_m' ]
* example1.TriggerList=["L0MuonDecision",
* "L0DiMuonDecision",
* "Hlt2TopoMu2BodyBBDTDecision",
* "Hlt2SingleMuonDecision",
* "Hlt2SingleMuonLowPTDecision"
* "L0HadronDecision",
* "Hlt2SingleMuonHighPTDecision",
* "Hlt2Topo2BodySimpleDecision",
* "Hlt2Topo2BodyBBDTDecision"
* ]
* example1.VerboseL0 = True
* example1.VerboseHlt1 = True
* example1.VerboseHlt2 = True
* example1.TUS = True
* example1.TPS = True
*
* @author Paul Seyfert
* @date 2016-11-30
*/
class TupleToolJuggleTisTos : public TupleToolTISTOS,
virtual public IParticleTupleTool
{
public:
/// Standard constructor
TupleToolJuggleTisTos( const std::string& type,
const std::string& name,
const IInterface* parent);
virtual ~TupleToolJuggleTisTos( ){}; ///< Destructor
virtual StatusCode initialize();
//virtual StatusCode finalize();
StatusCode fill( const LHCb::Particle*
, const LHCb::Particle*
, const std::string&
, Tuples::Tuple& );
virtual StatusCode fill(Tuples::Tuple& t) {
return TupleToolTriggerBase::fill(t);
}
private:
std::vector<std::string> m_locations;
DecayTreeTupleBase* m_dva;
};
#endif // TupleToolJuggleTisTos_H
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment