User will overwrite this function. Histogram booking is no longer done in C++. This function is called in execute once the filters are all passed.
141 {
142 using namespace Monitored;
143
144
145 auto genericTrackGroup =
getGroup(
"IDA_Tracks");
146
147
148 int ntrkMax=0;
149 float xv=-999;
150 float yv=-999;
151 float zv=-999;
152 int nTracks=0;
153 int ngTracks=0;
154
155 ATH_MSG_DEBUG (
"IDAlignMonGenericTracksAlg::fillHistograms ** START ** call for track collection: " <<
m_tracksName.key());
156
157
159
160 if (not trks.isValid()) {
162 return StatusCode::RECOVERABLE;
163 }else {
164 ATH_MSG_DEBUG(
"IDAlignMonGenericTracksAlg: Track container " << trks.name() <<
" is found.");
165 }
166
167
169
171
172 if (!handle_vxContainer.isPresent()) {
174 return StatusCode::SUCCESS;
175 }
176 if (!handle_vxContainer.isValid()) {
178 return StatusCode::RECOVERABLE;
179 }
180
181 const auto *vertexContainer = handle_vxContainer.cptr();
182 for(const auto vtx : *vertexContainer) {
183 if ( !vtx ) continue;
184 if ( !vtx->vxTrackAtVertexAvailable() ) continue;
185
186 const std::vector< Trk::VxTrackAtVertex >& theTrackAtVertex = vtx->vxTrackAtVertex();
187 int numTracksPerVertex = theTrackAtVertex.size();
188 ATH_MSG_DEBUG(
"Size of TrackAtVertex: " << numTracksPerVertex);
189 if (numTracksPerVertex>ntrkMax) {
190 ntrkMax=numTracksPerVertex;
191 xv=vtx->position()[0];
192 yv=vtx->position()[1];
193 zv=vtx->position()[2];
194 }
195 }
196
197 if (xv==-999 || yv==-999 || zv==-999) {
199 xv=0;yv=0;zv=0;
200 }
201
202
203 std::map<const xAOD::TrackParticle*, const xAOD::Vertex*> trackVertexMapTP;
205
206 float beamSpotX = 0.;
207 float beamSpotY = 0.;
208 float beamSpotZ = 0.;
209 float beamTiltX = 0.;
210 float beamTiltY = 0.;
211
213 auto beamSpotHandle = SG::ReadCondHandle(
m_beamSpotKey, ctx);
215 beamSpotX = bpos.x();
216 beamSpotY = bpos.y();
217 beamSpotZ = bpos.z();
218 beamTiltX = beamSpotHandle->beamTilt(0);
219 beamTiltY = beamSpotHandle->beamTilt(1);
220 ATH_MSG_DEBUG (
"Beamspot: x0 = " << beamSpotX <<
", y0 = " << beamSpotY <<
", z0 = " << beamSpotZ <<
", tiltX = " << beamTiltX <<
", tiltY = " << beamTiltY);
221 }
222
223
225 auto lb_m = Monitored::Scalar<int>(
"m_lb",
lb );
227 auto run_m = Monitored::Scalar<int>( "m_run", run );
229 auto event_m = Monitored::Scalar<int>( "m_event", event );
231 auto mu_m = Monitored::Scalar<float>("m_mu", mu);
232
234
235 auto beamSpotX_m = Monitored::Scalar<float>( "m_beamSpotX", beamSpotX );
236 auto beamSpotY_m = Monitored::Scalar<float>( "m_beamSpotY", beamSpotY );
237 auto beamSpotZ_m = Monitored::Scalar<float>( "m_beamSpotZ", beamSpotZ );
238 auto beamTiltX_m = Monitored::Scalar<float>( "m_beamTiltX", beamTiltX );
239 auto beamTiltY_m = Monitored::Scalar<float>( "m_beamTiltY", beamTiltY );
240 fill(genericTrackGroup, beamSpotX_m, beamSpotY_m, beamSpotZ_m, lb_m);
241
242
243 fill(genericTrackGroup, mu_m);
244 }
245
248
249 if (!handle_vxContainer.isPresent()) {
251 return StatusCode::SUCCESS;
252 }
253 if (!handle_vxContainer.isValid()) {
255 return StatusCode::FAILURE;
256 }
257
258 const auto *vertexContainer = handle_vxContainer.cptr();
259
262 for (; vxI != vxE; ++vxI) {
263 if ((*vxI)->type() == 1) {
264 pvtx = (*vxI);
265 }
266 }
267 }
268
269
270
271
272
273 ATH_MSG_DEBUG (
"Start loop on tracks. Number of tracks " << trks->size());
274 for (const Trk::Track* trksItr: *trks) {
275
276
277 if ( !trksItr || trksItr->perigeeParameters() == nullptr )
278 {
279 ATH_MSG_DEBUG(
"InDetAlignmentMonitoringRun3: NULL track pointer in collection" );
280 continue;
281 }
282
283
285 continue;
286
287 nTracks++;
288
289 float chisquared = 0.;
290 int DoF = 0;
291 float chi2oDoF = -999;
292 float trkd0 = -999;
293 float Err_d0 = -999;
294 float trkz0 = -999;
295 float Err_z0 = -999;
296 float trkphi = -999;
297 float Err_phi = -999;
298 float trktheta = -999;
299 float Err_theta = -999;
300 float Err_eta = -999;
301 float trketa = -999;
303 float Err_qOverP = -999;
304 float Err_Pt = -999;
305 float trkpt = -999;
306 float trkP = -999;
308 float trkd0c = -999;
309 float beamX = 0;
310 float beamY = 0;
311 float d0bscorr = -999;
312 int layerDisk = 99;
313 int sctSide = 99;
314 int modEta = 9999;
315 int modPhi = 9999;
316
317
318 const Trk::FitQuality* fitQual = trksItr->fitQuality();
319
320 const Trk::Perigee* measPer = trksItr->perigeeParameters();
321 const AmgSymMatrix(5)* covariance = measPer ? measPer->covariance() :
nullptr;
322
323 std::unique_ptr<Trk::ImpactParametersAndSigma> myIPandSigma=nullptr;
324
325
327
328
330 }
331
332 if (covariance == nullptr) {
333 ATH_MSG_WARNING(
"No measured perigee parameters assigned to the track");
334 }
335 else{
336 AmgVector(5) perigeeParams = measPer->parameters();
337 trkd0 = perigeeParams[Trk::d0];
338 trkz0 = perigeeParams[Trk::z0];
339 trkphi = perigeeParams[Trk::phi0];
340 trktheta = perigeeParams[Trk::
theta];
341 trketa = measPer->
eta();
342 qOverP = perigeeParams[Trk::qOverP]*1000.;
343 if(qOverP) trkP = 1/qOverP;
344 trkpt = measPer->pT()/1000.;
345 Err_d0 = Amg::error(*measPer->covariance(), Trk::d0);
346 Err_z0 = Amg::error(*measPer->covariance(), Trk::z0);
347 Err_phi = Amg::error(*measPer->covariance(), Trk::phi0);
348 Err_theta = Amg::error(*measPer->covariance(), Trk::
theta);
349 Err_eta = Err_theta / sin(trktheta);
350 Err_qOverP = Amg::error(*measPer->covariance(), Trk::qOverP) * 1000;
351 Err_Pt = sin(trktheta) * Err_qOverP /
pow(qOverP, 2);
354
355
356
357 trkd0c=trkd0-(yv*cos(trkphi)-xv*sin(trkphi));
359
360
361 beamX = beamSpotX + tan(beamTiltX) * (trkz0-beamSpotZ);
362 beamY = beamSpotY + tan(beamTiltY) * (trkz0-beamSpotZ);
363 d0bscorr = trkd0 - ( -sin(trkphi)*beamX + cos(trkphi)*beamY );
364 }
365
366 if (fitQual==
nullptr) {
368 }
369
370 chisquared = (fitQual) ? fitQual->
chiSquared() : -1.;
371 DoF = (fitQual) ? fitQual->
numberDoF() : -1;
372 if(DoF>0) chi2oDoF = chisquared/(
float)DoF;
373
374 if (trkphi<0) trkphi+=2*
M_PI;
375
376 ngTracks++;
378
379
380 auto lb_track_m = Monitored::Scalar<int>(
"m_lb_track",
lb );
381 fill(genericTrackGroup, lb_track_m);
382
383 int nhpixB=0, nhpixECA=0, nhpixECC=0, nhsctB=0, nhsctECA=0, nhsctECC=0, nhtrtB=0, nhtrtECA=0, nhtrtECC=0;
384
385
386 ATH_MSG_VERBOSE (
" starting to loop over TSOS: " << trksItr->trackStateOnSurfaces()->size());
387 for (const Trk::TrackStateOnSurface* tsos : *trksItr->trackStateOnSurfaces()) {
388
389 if(!(tsos->trackParameters())) {
390 ATH_MSG_DEBUG(
" hit skipped because no associated track parameters");
391 continue;
392 }
393
394 Identifier surfaceID;
395 const Trk::MeasurementBase* mesb=tsos->measurementOnTrack();
396
398
399
400 else continue;
401
403
406 ATH_MSG_DEBUG(
"applying hit quality cuts to Silicon hit...");
407
409 if (hit == nullptr) {
411 continue;
412 } else {
414 }
415 } else {
417 }
418 }
419
420
422 if(
m_pixelID->barrel_ec(surfaceID) == 0){
423 nhpixB++;
424 }
425 else if(
m_pixelID->barrel_ec(surfaceID) == 2) nhpixECA++;
426 else if(
m_pixelID->barrel_ec(surfaceID) == -2) nhpixECC++;
427 }
428
430 if(
m_sctID->barrel_ec(surfaceID) == 0){
431 nhsctB++;
432 }
433 else if(
m_sctID->barrel_ec(surfaceID) == 2) nhsctECA++;
434 else if(
m_sctID->barrel_ec(surfaceID) == -2) nhsctECC++;
435 }
436
438 int barrel_ec =
m_trtID->barrel_ec(surfaceID);
439 if(barrel_ec == 1 || barrel_ec == -1 ) {
440 nhtrtB++;
441 }
442 else if(barrel_ec == 2){
443 nhtrtECA++;
444 }else if(barrel_ec == -2){
445 nhtrtECC++;
446 }
447 }
448
450 layerDisk =
m_pixelID -> layer_disk(surfaceID);
451 modEta =
m_pixelID->eta_module(surfaceID);
452 modPhi =
m_pixelID->phi_module(surfaceID);
453 auto modEta_m = Monitored::Scalar<int>( "m_modEta", modEta );
454 auto modPhi_m = Monitored::Scalar<int>( "m_modPhi", modPhi );
455 auto layerDisk_m = Monitored::Scalar<float>("m_layerDisk", layerDisk);
456
457 if(
m_pixelID->barrel_ec(surfaceID) == 0){
459 }
460 else if(
m_pixelID->barrel_ec(surfaceID) == 2){
462 }
463 else if(
m_sctID->barrel_ec(surfaceID) == -2){
465 }
466 }
468 layerDisk =
m_sctID->layer_disk(surfaceID);
469 modEta =
m_sctID->eta_module(surfaceID);
470 modPhi =
m_sctID->phi_module(surfaceID);
471 sctSide =
m_sctID->side(surfaceID);
472 auto modEta_m = Monitored::Scalar<int>( "m_modEta", modEta );
473 auto modPhi_m = Monitored::Scalar<int>( "m_modPhi", modPhi );
474 auto layerDisk_m = Monitored::Scalar<float>("m_layerDisk", layerDisk);
475
476 if(
m_sctID->barrel_ec(surfaceID) == 0){
477 if (sctSide == 0) {
479 } else {
481 }
482 }
483 else if(
m_sctID->barrel_ec(surfaceID) == 2){
484 if (sctSide == 0) {
486 } else {
488 }
489 }
490 else if(
m_sctID->barrel_ec(surfaceID) == -2){
491 if (sctSide == 0) {
493 } else {
495 }
496 }
497 }
498
499 }
500 }
501
502 int nhpix= nhpixB +nhpixECA + nhpixECC;
503 int nhsct= nhsctB +nhsctECA + nhsctECC;
504 int nhtrt= nhtrtB +nhtrtECA + nhtrtECC;
505 int nhits= nhpix+ nhsct+ nhtrt;
506
507 auto nhits_per_track_m = Monitored::Scalar<float>( "m_nhits_per_track", nhits );
508 fill(genericTrackGroup, nhits_per_track_m);
509
510 auto npixelhits_per_track_m = Monitored::Scalar<float>( "m_npixelhits_per_track", nhpix );
511 auto npixelhits_per_track_barrel_m = Monitored::Scalar<float>( "m_npixelhits_per_track_barrel", nhpixB );
512 fill(genericTrackGroup, npixelhits_per_track_barrel_m);
513 auto npixelhits_per_track_eca_m = Monitored::Scalar<float>( "m_npixelhits_per_track_eca", nhpixECA );
514 fill(genericTrackGroup, npixelhits_per_track_eca_m);
515 auto npixelhits_per_track_ecc_m = Monitored::Scalar<float>( "m_npixelhits_per_track_ecc", nhpixECC );
516 fill(genericTrackGroup, npixelhits_per_track_ecc_m);
517
518 auto nscthits_per_track_m = Monitored::Scalar<float>( "m_nscthits_per_track", nhsct );
519 auto nscthits_per_track_barrel_m = Monitored::Scalar<float>( "m_nscthits_per_track_barrel", nhsctB );
520 fill(genericTrackGroup, nscthits_per_track_barrel_m);
521 auto nscthits_per_track_eca_m = Monitored::Scalar<float>( "m_nscthits_per_track_eca", nhsctECA );
522 fill(genericTrackGroup, nscthits_per_track_eca_m);
523 auto nscthits_per_track_ecc_m = Monitored::Scalar<float>( "m_nscthits_per_track_ecc", nhsctECC );
524 fill(genericTrackGroup, nscthits_per_track_ecc_m);
525
526 auto ntrthits_per_track_m = Monitored::Scalar<float>( "m_ntrthits_per_track", nhtrt );
527 auto ntrthits_per_track_barrel_m = Monitored::Scalar<float>( "m_ntrthits_per_track_barrel", nhtrtB );
528 fill(genericTrackGroup, ntrthits_per_track_barrel_m);
529 auto ntrthits_per_track_eca_m = Monitored::Scalar<float>( "m_ntrthits_per_track_eca", nhtrtECA );
530 fill(genericTrackGroup, ntrthits_per_track_eca_m);
531 auto ntrthits_per_track_ecc_m = Monitored::Scalar<float>( "m_ntrthits_per_track_ecc", nhtrtECC );
532 fill(genericTrackGroup, ntrthits_per_track_ecc_m);
533
534 auto chi2oDoF_m = Monitored::Scalar<float>( "m_chi2oDoF", chi2oDoF );
535 fill(genericTrackGroup, chi2oDoF_m);
536 auto eta_m = Monitored::Scalar<float>( "m_eta", trketa );
537 auto errEta_m = Monitored::Scalar<float>( "m_errEta", Err_eta );
538 fill(genericTrackGroup, errEta_m);
539
540
541 auto isTrkPositive = Monitored::Scalar<float>(
"isTrkPositive",
charge > 0 ? 1 : 0 );
542 auto isTrkNegative = Monitored::Scalar<float>(
"isTrkNegative",
charge > 0 ? 0 : 1 );
543
544
545 auto z0_m = Monitored::Scalar<float>( "m_z0", trkz0 );
546 auto errZ0_m = Monitored::Scalar<float>( "m_errZ0", Err_z0 );
547 auto z0_bscorr_m = Monitored::Scalar<float>( "m_z0_bscorr", trkz0-beamSpotZ );
548 float z0sintheta = trkz0*(
sin(trktheta));
549 auto z0sintheta_m = Monitored::Scalar<float>( "m_z0sintheta", z0sintheta );
550 fill(genericTrackGroup, z0_m, errZ0_m, z0_bscorr_m, z0sintheta_m);
551
552
553 auto d0_m = Monitored::Scalar<float>( "m_d0", trkd0 );
554 fill(genericTrackGroup, d0_m);
555 auto errD0_m = Monitored::Scalar<float>( "m_errD0", Err_d0 );
556 fill(genericTrackGroup, errD0_m);
557 auto d0_bscorr_m = Monitored::Scalar<float>( "m_d0_bscorr", d0bscorr );
558
559
560 auto phi_m = Monitored::Scalar<float>( "m_phi", trkphi );
561 auto errPhi_m = Monitored::Scalar<float>( "m_errPhi", Err_phi );
562
563
564 auto isTrackBarrel = Monitored::Scalar<float>(
"isTrackBarrel", fabs(trketa) <
m_barrelEta ? 1 : 0 );
565 auto isTrackECA = Monitored::Scalar<float>(
"isTrackECA", trketa >
m_barrelEta ? 1 : 0 );
566 auto isTrackECC = Monitored::Scalar<float>(
"isTrackECC", trketa < -
m_barrelEta ? 1 : 0 );
567
568
570 auto pT_m = Monitored::Scalar<float>( "m_pT", pT );
571 auto errPt_m = Monitored::Scalar<float>( "m_errPt", Err_Pt );
572 auto pTRes_m = Monitored::Scalar<float>( "m_pTRes", std::fabs(Err_qOverP / qOverP) );
573
574
575 fill(genericTrackGroup, npixelhits_per_track_m, nscthits_per_track_m, ntrthits_per_track_m, eta_m, isTrkPositive, isTrkNegative, d0_bscorr_m, phi_m, isTrackBarrel, isTrackECA, isTrackECC, errPhi_m, pT_m, errPt_m, pTRes_m);
576
577 auto p_m = Monitored::Scalar<float>( "m_p", trkP );
578 fill(genericTrackGroup, p_m);
579 }
580
581
582
583
584 auto ngTracks_m = Monitored::Scalar<float>( "m_ngTracks", ngTracks );
585 fill(genericTrackGroup, ngTracks_m);
586
587 ATH_MSG_DEBUG(
"Histogram filling completed for #good_tracks: " << ngTracks);
588
589 return StatusCode::SUCCESS;
590}
Scalar eta() const
pseudorapidity method
Scalar theta() const
theta method
#define ATH_MSG_VERBOSE(x)
double charge(const T &p)
#define AmgSymMatrix(dim)
constexpr int pow(int base, int exp) noexcept
const ToolHandle< GenericMonitoringTool > & getGroup(const std::string &name) const
Get a specific monitoring tool from the tool handle array.
SG::ReadHandle< xAOD::EventInfo > GetEventInfo(const EventContext &) const
Return a ReadHandle for an EventInfo object (get run/event numbers, etc.)
ToolHandleArray< GenericMonitoringTool > m_tools
Array of Generic Monitoring Tools.
DataModel_detail::const_iterator< DataVector > const_iterator
std::vector< int > m_measurements_vs_Eta_Phi_sct_ecc_s1
std::vector< int > m_measurements_vs_Eta_Phi_pix_b
SG::ReadHandleKey< xAOD::VertexContainer > m_VxPrimContainerName
ToolHandle< Trk::ITrackToVertexIPEstimator > m_trackToVertexIPEstimator
std::vector< int > m_measurements_vs_Eta_Phi_sct_b_s0
std::vector< int > m_measurements_vs_Eta_Phi_sct_b_s1
std::vector< int > m_measurements_vs_Eta_Phi_sct_eca_s0
SG::ReadHandleKey< TrackCollection > m_tracksName
std::vector< int > m_measurements_vs_Eta_Phi_sct_ecc_s0
std::vector< int > m_measurements_vs_Eta_Phi_sct_eca_s1
bool fillVertexInformation(std::map< const xAOD::TrackParticle *, const xAOD::Vertex * > &trackVertexMapTP, const EventContext &ctx) const
SG::ReadCondHandleKey< InDet::BeamSpotData > m_beamSpotKey
std::vector< int > m_measurements_vs_Eta_Phi_pix_ec
int numberDoF() const
returns the number of degrees of freedom of the overall track or vertex fit as integer
double chiSquared() const
returns the of the overall track fit
virtual const Surface & associatedSurface() const =0
Interface method to get the associated Surface.
const TrkDetElementBase * associatedDetectorElement() const
return associated Detector Element
@ Measurement
This is a measurement, and will at least contain a Trk::MeasurementBase.
virtual Identifier identify() const =0
Identifier.
void fill(const ToolHandle< GenericMonitoringTool > &groupHandle, std::vector< std::reference_wrapper< Monitored::IMonitoredVariable > > &&variables) const
Fills a vector of variables to a group by reference.
virtual float lbAverageInteractionsPerCrossing(const EventContext &ctx=Gaudi::Hive::currentContext()) const
Calculate the average mu, i.e.
Eigen::Matrix< double, 3, 1 > Vector3D
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
ParametersT< TrackParametersDim, Charged, PerigeeSurface > Perigee
Vertex_v1 Vertex
Define the latest version of the vertex class.