29 #include "CLHEP/GenericFunctions/CumulativeChiSquare.hh"
51 m_trackSelection(
"InDet::InDetTrackSelectionTool/TrackSelectionTool", this),
98 ATH_MSG_DEBUG(
"No hit quality tool configured - not hit quality cuts will be imposed");
104 ATH_MSG_DEBUG(
"Hit quality tool setup - hit quality cuts will be applied to Si hits");
145 auto genericTrackGroup =
getGroup(
"IDA_Tracks");
155 ATH_MSG_DEBUG (
"IDAlignMonGenericTracksAlg::fillHistograms ** START ** call for track collection: " <<
m_tracksName.key());
160 if (not trks.isValid()) {
162 return StatusCode::RECOVERABLE;
164 ATH_MSG_DEBUG(
"IDAlignMonGenericTracksAlg: Track container " << trks.name() <<
" is found.");
172 if (!handle_vxContainer.isPresent()) {
174 return StatusCode::SUCCESS;
176 if (!handle_vxContainer.isValid()) {
178 return StatusCode::RECOVERABLE;
181 const auto *vertexContainer = handle_vxContainer.cptr();
182 for(
const auto vtx : *vertexContainer) {
183 if ( !vtx )
continue;
184 if ( !vtx->vxTrackAtVertexAvailable() )
continue;
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];
197 if (xv==-999 || yv==-999 || zv==-999) {
203 std::map<const xAOD::TrackParticle*, const xAOD::Vertex*> trackVertexMapTP;
206 float beamSpotX = 0.;
207 float beamSpotY = 0.;
208 float beamSpotZ = 0.;
209 float beamTiltX = 0.;
210 float beamTiltY = 0.;
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);
240 fill(genericTrackGroup, beamSpotX_m, beamSpotY_m, beamSpotZ_m, lb_m);
243 fill(genericTrackGroup, mu_m);
249 if (!handle_vxContainer.isPresent()) {
251 return StatusCode::SUCCESS;
253 if (!handle_vxContainer.isValid()) {
255 return StatusCode::FAILURE;
258 const auto *vertexContainer = handle_vxContainer.cptr();
262 for (; vxI != vxE; ++vxI) {
263 if ((*vxI)->type() == 1) {
273 ATH_MSG_DEBUG (
"Start loop on tracks. Number of tracks " << trks->size());
277 if ( !trksItr || trksItr->perigeeParameters() ==
nullptr )
279 ATH_MSG_DEBUG(
"InDetAlignmentMonitoringRun3: NULL track pointer in collection" );
289 float chisquared = 0.;
291 float chi2oDoF = -999;
297 float Err_phi = -999;
298 float trktheta = -999;
299 float Err_theta = -999;
300 float Err_eta = -999;
303 float Err_qOverP = -999;
311 float d0bscorr = -999;
320 const Trk::Perigee* measPer = trksItr->perigeeParameters();
321 const AmgSymMatrix(5)* covariance = measPer ? measPer->covariance() :
nullptr;
323 std::unique_ptr<Trk::ImpactParametersAndSigma> myIPandSigma=
nullptr;
332 if (covariance ==
nullptr) {
333 ATH_MSG_WARNING(
"No measured perigee parameters assigned to the track");
336 AmgVector(5) perigeeParams = measPer->parameters();
337 trkd0 = perigeeParams[
Trk::d0];
338 trkz0 = perigeeParams[
Trk::z0];
341 trketa = measPer->eta();
344 trkpt = measPer->pT()/1000.;
349 Err_eta = Err_theta /
sin(trktheta);
357 trkd0c=trkd0-(yv*
cos(trkphi)-xv*
sin(trkphi));
361 beamX = beamSpotX +
tan(beamTiltX) * (trkz0-beamSpotZ);
362 beamY = beamSpotY +
tan(beamTiltY) * (trkz0-beamSpotZ);
363 d0bscorr = trkd0 - ( -
sin(trkphi)*beamX +
cos(trkphi)*beamY );
366 if (fitQual==
nullptr) {
370 chisquared = (fitQual) ? fitQual->
chiSquared() : -1.;
371 DoF = (fitQual) ? fitQual->
numberDoF() : -1;
372 if(DoF>0) chi2oDoF = chisquared/(
float)DoF;
374 if (trkphi<0) trkphi+=2*
M_PI;
381 fill(genericTrackGroup, lb_track_m);
383 int nhpixB=0, nhpixECA=0, nhpixECC=0, nhsctB=0, nhsctECA=0, nhsctECC=0, nhtrtB=0, nhtrtECA=0, nhtrtECC=0;
386 ATH_MSG_VERBOSE (
" starting to loop over TSOS: " << trksItr->trackStateOnSurfaces()->size());
389 if(!(tsos->trackParameters())) {
390 ATH_MSG_DEBUG(
" hit skipped because no associated track parameters");
406 ATH_MSG_DEBUG(
"applying hit quality cuts to Silicon hit...");
409 if (hit ==
nullptr) {
439 if(barrel_ec == 1 || barrel_ec == -1 ) {
442 else if(barrel_ec == 2){
444 }
else if(barrel_ec == -2){
450 layerDisk =
m_pixelID -> layer_disk(surfaceID);
502 int nhpix= nhpixB +nhpixECA + nhpixECC;
503 int nhsct= nhsctB +nhsctECA + nhsctECC;
504 int nhtrt= nhtrtB +nhtrtECA + nhtrtECC;
505 int nhits= nhpix+ nhsct+ nhtrt;
508 fill(genericTrackGroup, nhits_per_track_m);
512 fill(genericTrackGroup, npixelhits_per_track_barrel_m);
514 fill(genericTrackGroup, npixelhits_per_track_eca_m);
516 fill(genericTrackGroup, npixelhits_per_track_ecc_m);
520 fill(genericTrackGroup, nscthits_per_track_barrel_m);
522 fill(genericTrackGroup, nscthits_per_track_eca_m);
524 fill(genericTrackGroup, nscthits_per_track_ecc_m);
528 fill(genericTrackGroup, ntrthits_per_track_barrel_m);
530 fill(genericTrackGroup, ntrthits_per_track_eca_m);
532 fill(genericTrackGroup, ntrthits_per_track_ecc_m);
535 fill(genericTrackGroup, chi2oDoF_m);
538 fill(genericTrackGroup, errEta_m);
548 float z0sintheta = trkz0*(
sin(trktheta));
550 fill(genericTrackGroup, z0_m, errZ0_m, z0_bscorr_m, z0sintheta_m);
554 fill(genericTrackGroup, d0_m);
556 fill(genericTrackGroup, errD0_m);
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);
578 fill(genericTrackGroup, p_m);
585 fill(genericTrackGroup, ngTracks_m);
587 ATH_MSG_DEBUG(
"Histogram filling completed for #good_tracks: " << ngTracks);
589 return StatusCode::SUCCESS;
595 std::map<const xAOD::TrackParticle*, const xAOD::Vertex* >::const_iterator tpVx = trackVertexMapTP.find(
track);
597 if (tpVx == trackVertexMapTP.end() ){
601 return (*tpVx).second;
612 if(
nullptr!= trkLink){
614 if(
nullptr!= linktrkPB){
634 ATH_MSG_DEBUG(
"Generic Tracks: fillVertexInformation(): Checking ");
635 trackVertexMapTP.clear();
640 if (!handle_vxContainer.isPresent()) {
644 if (!handle_vxContainer.isValid()) {
649 const auto *vertexContainer = handle_vxContainer.cptr();
651 for(
const auto vtx : *vertexContainer) {
652 auto tpLinks = vtx->trackParticleLinks();
655 if (tpLinks.size() > 4 ) {
656 for(
const auto& link: tpLinks) {
659 trackVertexMapTP.insert( std::make_pair( TP, vtx ) );