ATLAS Offline Software
Loading...
Searching...
No Matches
TauJetCnv_p1.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
5//-----------------------------------------------------------------------------
6// file: TauJetCnv_p1.cxx
7// author: Lukasz Janyst
8// date: April 2007
9//-----------------------------------------------------------------------------
10
11#include "tauEvent/TauJet.h"
14
18
25
26static void setBit( unsigned char &field, unsigned num, bool val )
27{
28 if( val )
29 field |= (1 << num);
30 else
31 field &= ~(1 << num);
32}
33
34static bool getBit( unsigned char field, unsigned num )
35{
36 return (field & (1 << num)) ? true : false;
37}
38
39void TauJetCnv_p1 :: persToTrans( const TauJet_p1 *pers,
40 Analysis :: TauJet *trans,
41 MsgStream &msg ) const
42{
43 momCnv.persToTrans( &pers->m_momentum, &trans->momentumBase(), msg );
44 partBaseCnv.persToTrans( &pers->m_particleBase, &trans->particleBase(),
45 msg );
46 clusterCnv.persToTrans( &pers->m_cluster, &trans->clusterLink(), msg );
47 clusterCnv.persToTrans( &pers->m_cellCluster, &trans->cellClusterLink(), msg );
48 jetCnv.persToTrans( &pers->m_jet, &trans->jetLink(), msg );
49 tracksCnv.persToTrans( &pers->m_tracks, &trans->trackLinkVector(), msg );
50 detailsCnv.persToTrans( &pers->m_tauDetails, &trans->tauDetailLinkVector(), msg );
51 trans->setNumberOfTracks (pers->m_numberOfTracks);
52 trans->setROIWord (pers->m_roiWord);
53
54 if( getBit( pers->m_flags, 0 ) )
55 {
56 std::vector<std::pair<TauJetParameters::TauID, double> > params;
57 params.reserve(pers->m_params.size());
58 for (const auto& p : pers->m_params) {
59 params.emplace_back( static_cast<TauJetParameters::TauID>( p.first),
60 p.second);
61 }
62
63 Analysis::TauPID* tauID = new Analysis::TauPID (std::move(params),
64 std::bitset<32>(),
65 pers->m_vetoFlags);
66 trans->setTauID (tauID);
67 }
68 else
69 trans->setTauID( 0 );
70
71 if( getBit( pers->m_flags, 2 ) )
72 trans->setAuthor( TauJetParameters :: tauRec );
73 if( getBit( pers->m_flags, 3 ) )
74 trans->setAuthor( TauJetParameters :: tau1P3P );
75}
76
77void TauJetCnv_p1 :: transToPers( const Analysis :: TauJet *trans,
78 TauJet_p1 *pers,
79 MsgStream &msg ) const
80{
81 pers->m_params.clear();
82 momCnv.transToPers( &trans->momentumBase(), &pers->m_momentum, msg );
83 partBaseCnv.transToPers( &trans->particleBase(), &pers->m_particleBase, msg );
84 const ElementLink<CaloClusterContainer> clusterLink = trans->clusterLink();
85 clusterCnv.transToPers( &clusterLink, &pers->m_cluster, msg );
86 const ElementLink<CaloClusterContainer> cellClusterLink = trans->cellClusterLink();
87 clusterCnv.transToPers( &cellClusterLink, &pers->m_cellCluster, msg );
88 const ElementLink<JetCollection> jetLink = trans->jetLink();
89 jetCnv.transToPers( &jetLink, &pers->m_jet, msg );
90 tracksCnv.transToPers( &trans->trackLinkVector(), &pers->m_tracks, msg );
91 detailsCnv.transToPers( &trans->tauDetailLinkVector(), &pers->m_tauDetails, msg );
92 pers->m_numberOfTracks = trans->numberOfTracks();
93 pers->m_roiWord = trans->ROIWord();
94
95 if( trans->tauID() )
96 {
97 setBit( pers->m_flags, 0, true );
98
99 pers->m_vetoFlags = trans->tauID()->vetoFlags().to_ulong();
100
101 pers->m_params.reserve (trans->tauID()->params().size());
102 for (const auto& p : trans->tauID()->params()) {
103 pers->m_params.emplace_back (static_cast<int>( p.first ), p.second);
104 }
105 }
106 else
107 setBit( pers->m_flags, 0, false );
108
109 if( trans->hasAuthor( TauJetParameters :: tauRec ) )
110 setBit( pers->m_flags, 2, true );
111 if( trans->hasAuthor( TauJetParameters :: tau1P3P ) )
112 setBit( pers->m_flags, 3, true );
113}
This file contains the class definition for the ElementLinkCnv_p1 class.
This file contains the class definition for the ElementLinkVectorCnv_p1 class.
static const P4ImplPxPyPzECnv_p1 momCnv
Definition JetCnv_p1.cxx:30
static const JetCnv_p1 jetCnv
static const ClusterLinkCnv_t clusterCnv
static const ParticleBaseCnv_p1 partBaseCnv
Declaration of tau jet transient class.
static const ElementLinkVectorCnv_p1< ElementLinkVector< Rec::TrackParticleContainer > > tracksCnv
static void setBit(unsigned char &field, unsigned num, bool val)
static bool getBit(unsigned char field, unsigned num)
static const ElementLinkVectorCnv_p1< ElementLinkVector< Analysis::TauDetailsContainer > > detailsCnv
Class containing discriminants produced by identification algorithms.
Definition TauPID.h:32
ParticleBase_p1 m_particleBase
Definition TauJet_p1.h:38
unsigned long m_numberOfTracks
Definition TauJet_p1.h:49
P4EEtaPhiM_p1 m_momentum
Definition TauJet_p1.h:37
unsigned long m_vetoFlags
Definition TauJet_p1.h:48
ElementLinkInt_p1 m_cellCluster
Definition TauJet_p1.h:40
ElementLinkIntVector_p1 m_tracks
Definition TauJet_p1.h:42
ElementLinkInt_p1 m_jet
Definition TauJet_p1.h:41
std ::vector< std ::pair< int, double > > m_params
Definition TauJet_p1.h:51
unsigned int m_roiWord
Definition TauJet_p1.h:50
ElementLinkInt_p1 m_cluster
Definition TauJet_p1.h:39
ElementLinkIntVector_p1 m_tauDetails
Definition TauJet_p1.h:43
unsigned char m_flags
Definition TauJet_p1.h:44
TauID
Enum for discriminants.
MsgStream & msg
Definition testRead.cxx:32