17 #include "GaudiKernel/MsgStream.h"
18 #include "GaudiKernel/EventContext.h"
31 ConversionFinder::~ConversionFinder()=
default;
35 ATH_CHECK( m_VertexFinderTool.retrieve() );
37 m_doExtrapolation.value() &= !m_EMExtrapolationTool.name().empty();
38 ATH_CHECK( m_EMExtrapolationTool.retrieve( EnableTool {m_doExtrapolation} ) );
41 ATH_CHECK( m_InDetConversionOutputName.initialize() );
44 return StatusCode::SUCCESS;
51 std::cout<<
"------------------------------------------------------------"<<std::endl;
52 std::cout<<
"Processed: " << m_events_processed<<
" events " <<std::endl;
53 std::cout<<
"Stored : " << m_Gamma_stored<<
" Conversions " <<std::endl;
54 std::cout<<
"------------------------------------------------------------"<<std::endl;
55 std::cout<<
"| Double Conversions Si-Si Si-TRT TRT-TRT |"<<std::endl;
57 std::setw(10)<<m_Double_Conversions<<
58 std::setw(18)<<m_SiSi_Conversions<<
59 std::setw(11)<<m_SiTrt_Conversions<<
60 std::setw(13)<<m_TrtTrt_Conversions<<
" |"<<
62 std::cout<<
"------------------------------------------------------------" <<std::endl;
63 std::cout<<
"| Single Conversions Si TRT |"<<std::endl;
65 std::setw(10)<<m_Single_Conversions<<
66 std::setw(25)<<m_Si_Conversions<<
67 std::setw(19)<<m_Trt_Conversions<<
" |"<<
69 std::cout<<
"------------------------------------------------------------" <<std::endl;
71 return StatusCode::SUCCESS;
74 void ConversionFinder::resetStatistics() {
75 m_events_processed = 0;
77 m_Double_Conversions = 0;
78 m_Single_Conversions = 0;
79 m_SiSi_Conversions = 0;
80 m_SiTrt_Conversions = 0;
81 m_TrtTrt_Conversions = 0;
83 m_Trt_Conversions = 0;
87 class cleanup_pair :
public std::pair<xAOD::VertexContainer*, xAOD::VertexAuxContainer*>
92 : std::pair<xAOD::VertexContainer*, xAOD::VertexAuxContainer*>(a_pair)
114 const EventContext& ctx =Algorithm::getContext();
115 m_events_processed++;
118 if ( !trackParticleCollection.isValid())
120 ATH_MSG_WARNING(
"Could not find xAOD::TrackParticleContainer " << m_tracksName <<
" in StoreGate.");
122 return StatusCode::SUCCESS;
125 cleanup_pair conversions( m_VertexFinderTool->findVertex ( trackParticleCollection.cptr() ) );
127 if (!conversions.first || !conversions.second)
130 return StatusCode::SUCCESS;
132 ATH_MSG_DEBUG(
"New conversion container size: " << conversions.first->size());
134 m_Gamma_stored += conversions.first->size();
139 if(m_doExtrapolation){
140 float etaAtCalo = -9999., phiAtCalo = -9999.;
145 for (
unsigned int i = 0;
i <
vertex->nTrackParticles(); ++
i){
146 momentum += m_EMExtrapolationTool->getMomentumAtVertex(ctx,*
vertex,
i);
154 if (!m_EMExtrapolationTool->getEtaPhiAtCalo(ctx,
vertex, &etaAtCalo, &phiAtCalo)) {
161 acceta(*
vertex) = etaAtCalo;
162 accphi(*
vertex) = phiAtCalo;
166 analyzeResults(conversions.first);
169 if (
output.record( std::unique_ptr<xAOD::VertexContainer>(conversions.releaseFirst()) ,
170 std::unique_ptr<xAOD::VertexAuxContainer>(conversions.releaseSecond())).isFailure()) {
171 ATH_MSG_ERROR(
"Failed to record conversion vertices " << m_InDetConversionOutputName.key());
172 return StatusCode::FAILURE;
175 return StatusCode::SUCCESS;
180 for (
auto fz : *convContainer){
182 int numTracksPerVertex = fz->nTrackParticles();
183 if (numTracksPerVertex == 2) m_Double_Conversions++;
184 else m_Single_Conversions++;
186 bool isTrt1 =
false;
bool isSi1 =
false;
bool isTrt2 =
false;
bool isSi2 =
false;
187 for (
unsigned int i = 0;
i < fz->nTrackParticles() ; ++
i) {
188 const auto *trackParticle = fz->trackParticle(
i );
189 if(!trackParticle)
continue;
198 if(ncl>0) isSi1 =
true;
199 if(ncl==0 && ntrt>0) isTrt1 =
true;
202 if(ncl>0) isSi2 =
true;
203 if(ncl==0 && ntrt>0) isTrt2 =
true;
207 if(numTracksPerVertex==2){
208 if (isSi1 && isSi2) m_SiSi_Conversions++;
209 else if(isTrt1 && isTrt2) m_TrtTrt_Conversions++;
210 else m_SiTrt_Conversions++;
212 if(numTracksPerVertex==1){
213 if(isSi1) m_Si_Conversions++;
214 if(isTrt1) m_Trt_Conversions++;