ATLAS Offline Software
TauJetCnv_p5.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
18 
19 
20 #include "tauEvent/TauJet.h"
23 
27 
29 
30 //Pre-allocate converters
31 static const HepLorentzVectorCnv_p1 hepLorentzVectorCnv;
32 static const P4ImplEEtaPhiMCnv_p2 momCnv;
33 static const ParticleBaseCnv_p2 partBaseCnv;
41 
42 static void setBit( unsigned char &field, unsigned num, bool val )
43 {
44  if ( val )
45  field |= (1 << num);
46  else
47  field &= ~(1 << num);
48 }
49 
50 static bool getBit( unsigned char field, unsigned num )
51 {
52  return (field & (1 << num)) ? true : false;
53 }
54 
56  Analysis::TauJet *trans,
57  MsgStream &msg ) const
58 {
59  momCnv.persToTrans( &pers->m_momentum, &trans->momentumBase(), msg );
60  partBaseCnv.persToTrans( &pers->m_particleBase, &trans->particleBase(), msg );
61  clusterCnv.persToTrans( &pers->m_cluster, &trans->clusterLink(), msg );
62  clusterCnv.persToTrans( &pers->m_cellCluster, &trans->cellClusterLink(), msg );
63  jetCnv.persToTrans( &pers->m_jet, &trans->jetLink(), msg );
64  tracksCnv.persToTrans( &pers->m_tracks, &trans->trackLinkVector(), msg );
65  detailsCnv.persToTrans( &pers->m_tauDetails, &trans->tauDetailLinkVector(), msg );
66  trans->setNumberOfTracks (pers->m_numberOfTracks);
67  trans->setROIWord (pers->m_roiWord);
68 
69  if( getBit( pers->m_flags, 0 ) ) {
70  std::vector<std::pair<TauJetParameters::TauID, double> > params;
71  params.reserve(pers->m_params.size());
72  for (const auto& p : pers->m_params) {
73  params.emplace_back( static_cast<TauJetParameters::TauID>( p.first),
74  p.second);
75 
76  }
77 
78  Analysis::TauPID* tauID = new Analysis::TauPID (std::move(params),
79  pers->m_isTauFlags,
80  pers->m_vetoFlags);
81  trans->setTauID (tauID);
82  } else {
83  trans->setTauID( 0 );
84  }
85 
86  if( getBit( pers->m_flags, 2 ) )
88  if( getBit( pers->m_flags, 3 ) )
90  conversionTracksCnv.persToTrans(
91  &pers->m_conversionTracks,
92  &trans->conversionTrackLinkVector(), msg );
93  seedCalo_tracksCnv.persToTrans(
94  &pers->m_seedCalo_tracks,
95  &trans->seedCalo_trackLinkVector(), msg );
96  seedTrk_tracksCnv.persToTrans(
97  &pers->m_seedTrk_tracks,
98  &trans->seedTrk_trackLinkVector(), msg );
99 
100 // STILL NEED CONDITIONALS
101  /*
102  std::vector<std::pair<int, HepLorentzVector_p1> >::const_iterator it;
103  trans->m_tauHLVStorage.clear();
104  trans->m_tauHLVStorage.reserve(pers->m_tauHLVStorage.size());
105  for( it = pers->m_tauHLVStorage.begin();
106  it != pers->m_tauHLVStorage.end(); ++it )
107  {
108  CLHEP::HepLorentzVector dummy;
109  hepLorentzVectorCnv.persToTrans(&((*it).second), &dummy,msg);
110  std::pair<TauJetParameters::TauCalibType, CLHEP::HepLorentzVector> store;
111  store.first = static_cast<TauJetParameters::TauCalibType>( (*it).first );
112  store.second = dummy;
113  trans->m_tauHLVStorage.push_back( store );
114  }
115  */
116  trans->clearHLV();
117  CLHEP::HepLorentzVector hlv;
118  hepLorentzVectorCnv.persToTrans( &pers->m_tauHLV_jetseed, &hlv,msg);
119  trans->storeHLV ( TauJetParameters::JetSeed,hlv);
120  hepLorentzVectorCnv.persToTrans( &pers->m_tauHLV_detaxis, &hlv,msg);
122  hepLorentzVectorCnv.persToTrans( &pers->m_tauHLV_intaxis, &hlv,msg);
124  hepLorentzVectorCnv.persToTrans( &pers->m_tauHLV_tesaxis, &hlv,msg);
126  hepLorentzVectorCnv.persToTrans( &pers->m_tauHLV_etaaxis, &hlv,msg);
128 }
129 
131  TauJet_p5 *pers,
132  MsgStream &msg ) const
133 {
134  momCnv.transToPers( &trans->momentumBase(), &pers->m_momentum, msg );
135  partBaseCnv.transToPers( &trans->particleBase(), &pers->m_particleBase, msg );
136  const ElementLink<CaloClusterContainer> clusterLink = trans->clusterLink();
137  clusterCnv.transToPers( &clusterLink, &pers->m_cluster, msg );
138  const ElementLink<CaloClusterContainer> cellClusterLink = trans->cellClusterLink();
139  clusterCnv.transToPers( &cellClusterLink, &pers->m_cellCluster, msg );
140  const ElementLink<JetCollection> jetLink = trans->jetLink();
141  jetCnv.transToPers( &jetLink, &pers->m_jet, msg );
142  tracksCnv.transToPers( &trans->trackLinkVector(), &pers->m_tracks, msg );
143  detailsCnv.transToPers( &trans->tauDetailLinkVector(), &pers->m_tauDetails, msg );
144  pers->m_numberOfTracks = trans->numberOfTracks();
145  pers->m_roiWord = trans->ROIWord();
146  pers->m_params.clear();
147 
148  if( trans->tauID() ) {
149  setBit( pers->m_flags, 0, true );
150 
151  pers->m_vetoFlags = trans->tauID()->vetoFlags().to_ulong();
152  pers->m_isTauFlags = trans->tauID()->isTauFlags().to_ulong();
153 
154  pers->m_params.reserve (trans->tauID()->params().size());
155  for (const auto& p : trans->tauID()->params()) {
156  pers->m_params.emplace_back (static_cast<int>( p.first ), p.second);
157  }
158  } else {
159  setBit( pers->m_flags, 0, false );
160  }
161  if( trans->hasAuthor( TauJetParameters::tauRec ) )
162  setBit( pers->m_flags, 2, true );
163  if( trans->hasAuthor( TauJetParameters::tau1P3P ) )
164  setBit( pers->m_flags, 3, true );
165  conversionTracksCnv.transToPers(
166  &trans->conversionTrackLinkVector(),
167  &pers->m_conversionTracks, msg );
168  seedCalo_tracksCnv.transToPers(
169  &trans->seedCalo_trackLinkVector(),
170  &pers->m_seedCalo_tracks, msg );
171  seedTrk_tracksCnv.transToPers(
172  &trans->seedTrk_trackLinkVector(),
173  &pers->m_seedTrk_tracks, msg );
174 
175 
176 // STILL NEED CONDITIONALS
177  /*
178  pers->m_tauHLVStorage.clear();
179  pers->m_tauHLVStorage.reserve (trans->m_tauHLVStorage.size());
180  std::vector<std::pair<TauJetParameters::TauCalibType, CLHEP::HepLorentzVector> >::const_iterator it;
181  for( it = trans->m_tauHLVStorage.begin(); it != trans->m_tauHLVStorage.end(); ++it ) {
182  HepLorentzVector_p1 dummy;
183  hepLorentzVectorCnv.transToPers( &((*it).second), &dummy, msg);
184 
185  std::pair<int, HepLorentzVector_p1 > store;
186  store.first = static_cast<int>( (*it).first );
187  store.second = dummy;
188  pers->m_tauHLVStorage.push_back( store );
189  }
190  */
191 
192  CLHEP::HepLorentzVector hlv = trans->getHLV(TauJetParameters::JetSeed);
193  hepLorentzVectorCnv.transToPers( &hlv, &pers->m_tauHLV_jetseed, msg);
195  hepLorentzVectorCnv.transToPers( &hlv, &pers->m_tauHLV_detaxis, msg);
197  hepLorentzVectorCnv.transToPers( &hlv, &pers->m_tauHLV_intaxis, msg);
199  hepLorentzVectorCnv.transToPers( &hlv, &pers->m_tauHLV_tesaxis, msg);
201  hepLorentzVectorCnv.transToPers( &hlv, &pers->m_tauHLV_etaaxis, msg);
202 }
TauJet_p5::m_isTauFlags
unsigned long m_isTauFlags
Definition: TauJet_p5.h:71
Analysis::TauJet::seedCalo_trackLinkVector
const ElementLinkVector< Rec::TrackParticleContainer > & seedCalo_trackLinkVector() const
Get seed calo track link vector.
ElementLinkCnv_p3
Definition: ElementLinkCnv_p3.h:27
Analysis::TauJet::setROIWord
void setROIWord(unsigned int RoiWord)
Set ROI Word (trigger purposes)
P4ImplEEtaPhiMCnv_p2
Definition: P4ImplEEtaPhiMCnv_p2.h:35
Analysis::TauJet::setTauID
void setTauID(TauPID *tauID)
Set TauPID object that contains discriminant values.
Analysis::TauPID
Class containing discriminants produced by identification algorithms.
Definition: TauPID.h:32
ElementLinkCnv_p3.h
This file contains the class definition for the ElementLinkCnv_p3 class.
ElementLinkCnv_p3::persToTrans
void persToTrans(const PersLink_t &pers, Link_t &trans, MsgStream &log) const
TauJet_p5::m_flags
unsigned char m_flags
Definition: TauJet_p5.h:66
TauJet_p5::m_vetoFlags
unsigned long m_vetoFlags
Definition: TauJet_p5.h:70
TauJetParameters::tau1P3P
@ tau1P3P
Definition: TauJetParameters.h:36
TauJet_p5
Definition: TauJet_p5.h:35
Analysis::TauJet::getHLV
CLHEP::HepLorentzVector getHLV(TauJetParameters ::TauCalibType type) const
P4ImplEEtaPhiMCnv_p2.h
ParticleBaseCnv_p2::persToTrans
virtual void persToTrans(const ParticleBase_p2 *persObj, ParticleBase *transObj, MsgStream &msg) const final
Method creating the transient representation of ParticleBase from its persistent representation Parti...
Definition: ParticleBaseCnv_p2.cxx:42
ElementLinkVectorCnv_p1
Definition: ElementLinkVectorCnv_p1.h:28
TauJet_p5::m_tauHLV_tesaxis
HepLorentzVector_p1 m_tauHLV_tesaxis
Definition: TauJet_p5.h:82
Analysis::TauJet::hasAuthor
bool hasAuthor(const TauJetParameters ::Author &author) const
check if this object has Author author (can be more than one)
TauJet_p5::m_tauHLV_intaxis
HepLorentzVector_p1 m_tauHLV_intaxis
Definition: TauJet_p5.h:81
Analysis::TauJet::storeHLV
void storeHLV(TauJetParameters ::TauCalibType type, CLHEP ::HepLorentzVector hlv)
Analysis::TauJet::numberOfTracks
unsigned int numberOfTracks() const
Get number of tracks.
ElementLinkVectorCnv_p1.h
This file contains the class definition for the ElementLinkVectorCnv_p1 class. NOTE: it should be inc...
TauJet_p5::m_seedCalo_tracks
ElementLinkIntVector_p1 m_seedCalo_tracks
Definition: TauJet_p5.h:76
ElementLinkVectorCnv_p1::persToTrans
void persToTrans(const PersLinkVect_t &pers, LinkVect_t &trans, MsgStream &log) const
ReadOfcFromCool.field
field
Definition: ReadOfcFromCool.py:48
Analysis::TauJet::jetLink
const ElementLink< JetCollection > jetLink() const
ElementLink to seed Jet, might be invalid if not seeded from a Jet
TauJet_p5::m_tracks
ElementLinkIntVector_p1 m_tracks
Definition: TauJet_p5.h:64
HepLorentzVectorCnv_p1.h
TauJet_p5::m_roiWord
unsigned int m_roiWord
Definition: TauJet_p5.h:73
TauJetParameters::IntermediateAxis
@ IntermediateAxis
Definition: TauJetParameters.h:193
Analysis::TauPID::isTauFlags
const std::bitset< 32 > & isTauFlags() const
Definition: TauPID.cxx:90
Analysis::TauJet::tauID
const TauPID * tauID() const
Get TauPID object containing discriminant values.
ParticleBaseCnv_p2::transToPers
virtual void transToPers(const ParticleBase *transObj, ParticleBase_p2 *persObj, MsgStream &msg) const final
Method creating the persistent representation ParticleBase_p2 from its transient representation Parti...
Definition: ParticleBaseCnv_p2.cxx:73
TauJetCnv_p5::persToTrans
void persToTrans(const TauJet_p5 *pers, Analysis::TauJet *trans, MsgStream &msg) const
Fills a transient object from a persistent object.
Definition: TauJetCnv_p5.cxx:55
TauJet_p5::m_momentum
P4EEtaPhiMFloat_p2 m_momentum
Definition: TauJet_p5.h:59
TauJet_p5::m_conversionTracks
ElementLinkIntVector_p1 m_conversionTracks
Definition: TauJet_p5.h:75
ElementLinkCnv_p3::transToPers
void transToPers(const Link_t &trans, PersLink_t &pers, const SG::ThinningCache *cache, MsgStream &log) const
TauJet_p5::m_particleBase
ParticleBase_p2 m_particleBase
Definition: TauJet_p5.h:60
TauJetParameters::tauRec
@ tauRec
Definition: TauJetParameters.h:35
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
ParticleBaseCnv_p2.h
TauJetCnv_p5::transToPers
void transToPers(const Analysis::TauJet *trans, TauJet_p5 *pers, MsgStream &msg) const
Fills a persistent object from a transient object
Definition: TauJetCnv_p5.cxx:130
TauJet_p5::m_tauHLV_jetseed
HepLorentzVector_p1 m_tauHLV_jetseed
Definition: TauJet_p5.h:79
Analysis::TauJet
Object for taus common for ESD and AOD.
Definition: Reconstruction/tauEvent/tauEvent/TauJet.h:61
Analysis::TauJet::seedTrk_trackLinkVector
const ElementLinkVector< Rec::TrackParticleContainer > & seedTrk_trackLinkVector() const
Get seed trk track link vector.
Analysis::TauJet::conversionTrackLinkVector
const ElementLinkVector< Rec::TrackParticleContainer > & conversionTrackLinkVector() const
Get conversion track element link vector (const)
Analysis::TauPID::vetoFlags
const std::bitset< 32 > & vetoFlags() const
Definition: TauPID.cxx:94
HepLorentzVectorCnv_p1::transToPers
virtual void transToPers(const CLHEP::HepLorentzVector *transObj, HepLorentzVector_p1 *persObj, MsgStream &log) const override
Method creating the persistent representation HepLorentzVector_p1 from its transient representation H...
Definition: HepLorentzVectorCnv_p1.cxx:35
TauJetParameters::JetSeed
@ JetSeed
Definition: TauJetParameters.h:191
TauJet_p5::m_cellCluster
ElementLinkInt_p3 m_cellCluster
Definition: TauJet_p5.h:62
TauJetCnv_p5.h
Analysis::TauJet::clusterLink
const ElementLink< CaloClusterContainer > clusterLink() const
ElementLink to seed CaloCluster, DEPRECATED as of release 13
ParticleImpl::momentumBase
const momentum_type & momentumBase() const
access to underlying base type (I4Momentum-like)
Definition: ParticleImpl.h:393
Analysis::TauJet::ROIWord
unsigned int ROIWord() const
Retrieve ROI Word (trigger purposes)
trigbs_pickEvents.num
num
Definition: trigbs_pickEvents.py:76
TauJetParameters::TauID
TauID
Enum for discriminants.
Definition: TauJetParameters.h:44
P4ImplEEtaPhiMCnv_p2::transToPers
virtual void transToPers(const P4ImplEEtaPhiM *transObj, P4EEtaPhiMFloat_p2 *persObj, MsgStream &log) const override
Method creating the persistent representation P4EEtaPhiMFloat_p2 from its transient representation P4...
Definition: P4ImplEEtaPhiMCnv_p2.cxx:38
TauJetParameters::DetectorAxis
@ DetectorAxis
Definition: TauJetParameters.h:192
ParticleImpl::particleBase
const particle_type & particleBase() const
access to underlying base type (IParticle-like)
Definition: ParticleImpl.h:403
Analysis::TauJet::clearHLV
void clearHLV()
Definition: TauJet.cxx:590
TauJet_p5::m_tauHLV_etaaxis
HepLorentzVector_p1 m_tauHLV_etaaxis
Definition: TauJet_p5.h:83
HepLorentzVectorCnv_p1::persToTrans
virtual void persToTrans(const HepLorentzVector_p1 *persObj, CLHEP::HepLorentzVector *transObj, MsgStream &log) const override
Method creating the transient representation of HepLorentzVector from its persistent representation H...
Definition: HepLorentzVectorCnv_p1.cxx:26
P4ImplEEtaPhiMCnv_p2::persToTrans
virtual void persToTrans(const P4EEtaPhiMFloat_p2 *persObj, P4ImplEEtaPhiM *transObj, MsgStream &log) const override
Method creating the transient representation of P4ImplEEtaPhiM from its persistent representation P4E...
Definition: P4ImplEEtaPhiMCnv_p2.cxx:26
TauJet_p5::m_tauHLV_detaxis
HepLorentzVector_p1 m_tauHLV_detaxis
Definition: TauJet_p5.h:80
TauJetParameters::TauEtaCalib
@ TauEtaCalib
Definition: TauJetParameters.h:195
TauJet_p5::m_seedTrk_tracks
ElementLinkIntVector_p1 m_seedTrk_tracks
Definition: TauJet_p5.h:77
TauJet_p5::m_jet
ElementLinkInt_p3 m_jet
Definition: TauJet_p5.h:63
Pythia8_RapidityOrderMPI.val
val
Definition: Pythia8_RapidityOrderMPI.py:14
TauJet_p5::m_params
std ::vector< std ::pair< int, float > > m_params
Definition: TauJet_p5.h:74
Analysis::TauJet::trackLinkVector
const ElementLinkVector< Rec::TrackParticleContainer > & trackLinkVector() const
Get track link vector.
ElementLinkVectorCnv_p1::transToPers
void transToPers(const LinkVect_t &trans, PersLinkVect_t &pers, const SG::ThinningCache *cache, MsgStream &log) const
Analysis::TauJet::setNumberOfTracks
void setNumberOfTracks(unsigned int numberOfTracks)
Set number of tracks @ param numberOfTracks Number of tracks.
TauJet_p5::m_cluster
ElementLinkInt_p3 m_cluster
Definition: TauJet_p5.h:61
PowhegControl_ttFCNC_NLO.params
params
Definition: PowhegControl_ttFCNC_NLO.py:226
TauJet_p5::m_numberOfTracks
unsigned long m_numberOfTracks
Definition: TauJet_p5.h:72
Analysis::TauJet::cellClusterLink
const ElementLink< CaloClusterContainer > cellClusterLink() const
ElementLink to cell CaloCluster, might be invalid the ID variables are calculated from this cluster i...
HepLorentzVectorCnv_p1
Definition: HepLorentzVectorCnv_p1.h:34
TauJetParameters::TauEnergyScale
@ TauEnergyScale
Definition: TauJetParameters.h:194
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
TauJet.h
ParticleBaseCnv_p2
Definition: ParticleBaseCnv_p2.h:30
Analysis::TauJet::setAuthor
void setAuthor(const TauJetParameters ::Author &author)
set the author flag to true
TauJet_p5::m_tauDetails
ElementLinkIntVector_p1 m_tauDetails
Definition: TauJet_p5.h:65
Analysis::TauPID::params
const std::vector< std::pair< TauJetParameters::TauID, double > > & params() const
Definition: TauPID.cxx:86
Analysis::TauJet::tauDetailLinkVector
ElementLinkVector< TauDetailsContainer > & tauDetailLinkVector()