Execute on an entire collection of clusters.
75{
78 {
80 {
82 return StatusCode::FAILURE;
83 }
84 } else {
86 return StatusCode::FAILURE;
87 }
88
89
90 std::vector<unsigned int> numTracksPerVertex(primcontainer->size()-1, 0);
91 std::vector<float> trkParticlePt_atOrigin;
92 std::vector<float> trkParticleEta_atCaloEntrance;
93 std::vector<float> trkParticlePhi_atCaloEntrance;
94
95 for (
unsigned int v = 0 ;
v < primcontainer->size()-1; ++
v)
96 {
97 const std::vector<Trk::VxTrackAtVertex*>* vxTrackAtVertex = primcontainer->at(v)->vxTrackAtVertex();
98 for (std::vector<Trk::VxTrackAtVertex*>::const_iterator vxTrkItr = vxTrackAtVertex->begin(); vxTrkItr != vxTrackAtVertex->end(); ++vxTrkItr)
99 {
101 Trk::ITrackLink* trklink = (*vxTrkItr)->trackOrParticleLink();
102 Trk::LinkToTrackParticleBase* linkToTrackParticle = dynamic_cast<Trk::LinkToTrackParticleBase*>(trklink);
103 if (linkToTrackParticle !=
nullptr && linkToTrackParticle->
isValid()) {
104 const Rec::TrackParticle* theTrackParticle =
dynamic_cast<const Rec::TrackParticle*
>(linkToTrackParticle->
cachedElement());
105 if (theTrackParticle != nullptr)
106 {
108 numTracksPerVertex.at(v)++;
109 trkParticlePt_atOrigin.push_back (theTrackParticle->
pt()/1.e3);
110
112 const std::vector< const Trk::TrackParameters * >& trackParametersVector = theTrackParticle->
trackParameters();
113 if (trackParametersVector.size() > 1) lastTrackParametersInID = trackParametersVector.at(trackParametersVector.size()-2);
114 else lastTrackParametersInID = trackParametersVector.at(0);
115
116
117 if (theTrackParticle->
eta() >
118 1.35)
119
120 {
121 trackParameters_atCaloEntrance =
123 ctx,
124 *lastTrackParametersInID,
127 true,
129 }
else if (theTrackParticle->
eta() <
130 -1.35)
131
132 {
133 trackParameters_atCaloEntrance =
135 ctx,
136 *lastTrackParametersInID,
139 true,
141 } else
142 {
143 trackParameters_atCaloEntrance =
146 *lastTrackParametersInID,
149 true,
151 }
152 if (trackParameters_atCaloEntrance != nullptr) {
153 trkParticleEta_atCaloEntrance.push_back(trackParameters_atCaloEntrance->position().eta());
154 trkParticlePhi_atCaloEntrance.push_back(trackParameters_atCaloEntrance->position().phi());
155 ATH_MSG_DEBUG(
"At calo entrance R(1150mm) " << *trackParameters_atCaloEntrance );
156 ATH_MSG_DEBUG(
"TrkParticle eta/phi/pt[GeV] at calo " << trackParameters_atCaloEntrance->position().eta() <<
"\t"
157 << trackParameters_atCaloEntrance->position().phi() << "\t"
158 << trackParameters_atCaloEntrance->position().perp()/1.e3 );
159 delete trackParameters_atCaloEntrance;
160 } else {
161 trkParticleEta_atCaloEntrance.push_back(999.);
162 trkParticlePhi_atCaloEntrance.push_back(999.);
163 }
164 }
165 }
166 }
167 }
168
169 double fabs_Dphi(9999.);
170 double fabs_Deta(9999.);
171 double dR2(9999.);
172 std::vector<float> sumPtOfMatchedTracksPerVertex(numTracksPerVertex.size(), 0.);
173
175 {
177
178
179 if (std::fabs(theCluster->
eta()) < 2.5)
180 {
181
182 std::vector<unsigned int>::iterator numTrksPerVertexItr = numTracksPerVertex.begin();
183 std::vector<unsigned int>::iterator numTrksPerVertexItrE = numTracksPerVertex.end();
184 unsigned int vertexCounter(0);
185 unsigned int totalTrackCounter(0);
186 for ( ; numTrksPerVertexItr != numTrksPerVertexItrE ; ++numTrksPerVertexItr, vertexCounter++)
187 {
188 sumPtOfMatchedTracksPerVertex.at(vertexCounter) = 0.;
189 for (
unsigned int track = 0;
track < (*numTrksPerVertexItr); ++
track, totalTrackCounter++)
190 {
191 if (trkParticleEta_atCaloEntrance.at(totalTrackCounter) < 900.)
192 {
193 fabs_Dphi =
calculateDPhi(trkParticlePhi_atCaloEntrance.at(totalTrackCounter), theCluster->
phi());
194 fabs_Deta = fabs(trkParticleEta_atCaloEntrance.at(totalTrackCounter) - theCluster->
eta());
195 dR2 = fabs_Deta * fabs_Deta + fabs_Dphi * fabs_Dphi;
197 sumPtOfMatchedTracksPerVertex.at(vertexCounter) += trkParticlePt_atOrigin.at(totalTrackCounter);
198 }
199 }
200 }
201 }
202 double totalSumPtOfMatchedTracksWhichWereAlsoUsedInAVertex(0.);
203 for (unsigned int mTpV = 0; mTpV < sumPtOfMatchedTracksPerVertex.size(); ++mTpV) {
204 totalSumPtOfMatchedTracksWhichWereAlsoUsedInAVertex += sumPtOfMatchedTracksPerVertex.at(mTpV);
205
206 }
207
208 double cvf(-1.);
209 double ncvf(-1.);
210 if (totalSumPtOfMatchedTracksWhichWereAlsoUsedInAVertex > 0.)
211 {
212 double sumPtInPrimary = sumPtOfMatchedTracksPerVertex.at(0);
213 cvf = sumPtOfMatchedTracksPerVertex.at(0)/totalSumPtOfMatchedTracksWhichWereAlsoUsedInAVertex;
214 std::sort(sumPtOfMatchedTracksPerVertex.begin(), sumPtOfMatchedTracksPerVertex.end());
215 double highestSumPt = sumPtOfMatchedTracksPerVertex.at(sumPtOfMatchedTracksPerVertex.size()-1);
216 if (highestSumPt > 0) ncvf = sumPtInPrimary/highestSumPt;
217 }
218
221 } else {
224 }
225 }
226
227 return StatusCode::SUCCESS;
228}
#define ATH_MSG_WARNING(x)
Athena::TPCnvVers::Old VxContainer
ServiceHandle< StoreGateSvc > & evtStore()
std::unique_ptr< Trk::Surface > m_discSurface_atCaloEntrance_positiveZ
std::unique_ptr< Trk::Surface > m_cylinderSurface_atCaloEntrance
std::unique_ptr< Trk::Surface > m_discSurface_atCaloEntrance_negativeZ
static double calculateDPhi(double phi1, double phi2)
DataModel_detail::iterator< DataVector > iterator
bool isValid() const
Test to see if the link can be dereferenced.
ElementType cachedElement() const
Return the cached element, if any.
virtual double pt() const =0
transverse momentum
virtual double eta() const =0
pseudo rapidity
const std::vector< const TrackParameters * > & trackParameters() const
Returns the track parameters.
virtual double eta() const
The pseudorapidity ( ) of the particle.
void insertMoment(MomentType type, double value)
virtual double phi() const
The azimuthal angle ( ) of the particle.
@ VERTEX_FRACTION
Vertex fraction of this cluster wrt.
@ NVERTEX_FRACTION
slightly updated vertex fraction more pile up independent (similar to nJVF)
static std::string release
bool contains(const std::string &s, const std::string ®x)
does a string contain the substring
ParametersT< TrackParametersDim, Charged, DiscSurface > AtaDisc
ParametersBase< TrackParametersDim, Charged > TrackParameters
ParametersT< TrackParametersDim, Charged, CylinderSurface > AtaCylinder
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.