10#include "Identifier/Identifier.h"
33#include <system_error>
77 ATH_MSG_DEBUG(
"initialize() successful in " << name() <<
", retrieved: ..., locR_cut = " <<
m_locR_cut <<
" mm." );
78 return StatusCode::SUCCESS;
88 return StatusCode::SUCCESS;
96 StatusCode
sc = StatusCode::SUCCESS;
99 return StatusCode::FAILURE;
101 int runNumber = (int) eventInfo->runNumber();
106 int lumiBlock0 =eventInfo->lumiBlock();
109 if (not rdoContainer.
isValid()) {
111 return StatusCode::FAILURE;
114 if (not trkCollection.
isValid()) {
116 return StatusCode::FAILURE;
123 ATH_MSG_DEBUG (
"Couldn't retrieve VertexContainer with key: PrimaryVertices");
124 return StatusCode::SUCCESS;
127 int countVertices(0);
130 if ( vx-> nTrackParticles() >= 3) countVertices++;
133 if (countVertices < 1) {
134 ATH_MSG_INFO(
"no vertices with at least 3 tracks found" );
135 return StatusCode::SUCCESS;
139 int countRDOhitsInEvent(0);
142 if (not TRTCollection)
continue;
144 countRDOhitsInEvent++;
147 if (countRDOhitsInEvent>100000) {
148 ATH_MSG_INFO(
"N RDO hits in event greater than 100000: " << countRDOhitsInEvent <<
", exiting" );
152 if (trkCollection->size() > 10) {
153 ATH_MSG_INFO(
"N tracks greater than 10: " << trkCollection->size() <<
", exiting" );
162 std::vector<Identifier> holeIdentifiers;
163 std::vector<Identifier> holeIdentifiersWithHits;
167 const Trk::Perigee* perigee = (*trackIt)->perigeeParameters();
168 if ( not perigee ) {
ATH_MSG_ERROR(
"Trk::Perigee missing" );
continue; }
169 if ( std::abs(perigee->
pT())/CLHEP::GeV < 1. )
continue;
172 if ( not trackStates ) {
ATH_MSG_ERROR(
"Trk::TrackStateOnSurface empty" );
continue; }
174 int n_pixel_hits(0), n_sct_hits(0), n_trt_hits(0);
176 if ( *trackStatesIt ==
nullptr ) {
ATH_MSG_ERROR(
"*trackStatesIt == 0" );
continue; }
184 if (n_pixel_hits<2 || n_sct_hits < 6 || n_trt_hits<15)
continue;
192 if ( *trackStatesIt ==
nullptr ) {
ATH_MSG_ERROR(
"*trackStatesIt == 0" );
continue; }
197 if ( not driftCircleOnTrack )
continue;
205 double unbiased_locR = unbiased_track_parameters->parameters()[
Trk::locR];
206 if ( std::abs(unbiased_locR) >
m_locR_cut )
continue;
209 if ( driftCircle ==
nullptr ) {
ATH_MSG_ERROR(
"driftCircle == 0" );
continue; }
214 if (driftCircle->highLevel()) (*m_accumulateHits)[(
index[0]>0)?0:1][
index[2]][
index[5]][3]++;
221 if (
holes==
nullptr )
continue;
227 if (!track_parameters) {
ATH_MSG_WARNING(
"m_trt_hole_finder track_parameters missing" );
continue; }
230 if ( !(
m_TRTHelper->is_trt(
id)) ) {
ATH_MSG_ERROR(
"m_trt_hole_finder returned something that is not a TRT hole" );
continue; }
235 holeIdentifiers.push_back(
id );
246 if (TRTCollection==
nullptr)
continue;
251 if ((*trtIt)->highLevel()) (*m_accumulateHits)[(
index[0]>0)?0:1][
index[2]][
index[5]][2]++;
253 if (std::find(holeIdentifiers.begin(), holeIdentifiers.end(),
id) != holeIdentifiers.end())
254 holeIdentifiersWithHits.push_back(
id );
262 for (
unsigned int i=0; i<holeIdentifiers.size(); i++) {
270 if (std::find(holeIdentifiersWithHits.begin(), holeIdentifiersWithHits.end(),
id) != holeIdentifiersWithHits.end())
294 FILE *f = fopen(fileName,
"w");
296 ATH_MSG_ERROR(
"InDet::TRT_StrawStatus::reportResults: Cannot open " << fileName <<
" for write" );
297 return StatusCode::FAILURE;
299 fprintf(f,
"%d %d %d %d %d %d %d %d %d \n", 0, 0, 0, 0, 0, 0, 0, 0,
m_nEvents);
300 for (
size_t i=0; i<2; i++)
for (
size_t j=0; j<32; j++)
for (
size_t k=0; k<
nAllStraws; k++) {
301 int side = (i>0)?-1:1;
302 if (k>=1642) side *= 2;
303 fprintf(f,
"%d %zu %zu", side, j, k);
308 return StatusCode::SUCCESS;
313 ATH_MSG_INFO(
"InDet::TRT_StrawStatus::printDetailedInformation()");
314 const std::string fileName =
315 std::format(
"{}.{}{}_printDetailedInformation.txt",
317 std::string(7 - std::min<std::size_t>(7, std::to_string(
m_runNumber).size()),
'0'),
319 std::ofstream out(fileName, std::ios::out | std::ios::trunc);
321 ATH_MSG_ERROR(std::format(
"Failed to open '{}' for writing", fileName));
328 const int maxStraw =
m_TRTHelper->straw_max(layerId);
330 for (
int i = 0; i <= maxStraw; ++i) {
332 std::array<int, 6>
index{};
339 ATH_MSG_INFO(
"if the code crashes on the next line, there is a problem with "
340 "m_TRTStrawStatusSummarySvc not being loaded ");
341 ATH_MSG_INFO(
"in that case, running with reco turned on normally solves the problem, "
342 "know of no better solution at the moment");
343 ATH_MSG_INFO(
"if you do not need the detailed print information, you can also just set "
344 "printDetailedInformation to 0 to avoid this crash");
347 const auto& ctx = Gaudi::Hive::currentContext();
352 for (
int j = 0; j < 6; ++j) out <<
index[j] <<
' ';
353 out << chip <<
' ' << HVpad <<
' ' << status <<
' '
354 << statusTemporary <<
' ' << statusPermanent <<
'\n';
363 int strawLayerNumber =
m_TRTHelper->straw_layer(
id);
367 const int numberOfStraws[74] = { 0, 15, 31, 47, 63, 79, 96, 113, 130, 147, 164, 182, 200, 218, 236, 254, 273, 292, 311, 329,
368 348, 368, 388, 408, 428, 448, 469, 490, 511, 532, 553, 575, 597, 619, 641, 663, 686, 709, 732, 755, 778, 802, 826, 849,
369 872, 896, 920, 944, 968, 993, 1018, 1043, 1068, 1093, 1119, 1145, 1171, 1197, 1223, 1250, 1277, 1304, 1331, 1358, 1386, 1414, 1442, 1470, 1498, 1527, 1556, 1585, 1614, 1642 };
372 if (layerNumber==1) strawLayerNumber+= 19;
373 else if (layerNumber==2) strawLayerNumber+= 43;
374 straw = ( numberOfStraws[strawLayerNumber+1] - strawNumber -1 );
376 int board = layerNumber;
377 if (board<6) { board *= 2;
if (strawLayerNumber>7) board++; }
379 straw = board * 192 + strawNumber * 8 + strawLayerNumber % 8 ;
383 index[1] = layerNumber;
385 index[3] = strawLayerNumber;
386 index[4] = strawNumber;
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
An STL vector of pointers that by default owns its pointed-to elements.
Handle class for reading from StoreGate.
This is an Identifier helper class for the TRT subdetector.
const size_t nEndcapStraws
const size_t nBarrelStraws
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
const ServiceHandle< StoreGateSvc > & detStore() const
bool msgLvl(const MSG::Level lvl) const
DataModel_detail::const_iterator< DataVector > const_iterator
Standard const_iterator.
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
Specific class to represent the pixel measurements.
Specific class to represent the SCT measurements.
Represents 'corrected' measurements from the TRT (for example, corrected for wire sag).
virtual const TRT_DriftCircle * prepRawData() const override final
returns the PrepRawData - is a TRT_DriftCircle in this scope
std::unique_ptr< ACCHITS_t > m_accumulateHits
SG::ReadHandleKey< xAOD::VertexContainer > m_vxContainerKey
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
StatusCode finalize()
standard Athena-Algorithm method
ToolHandle< Trk::ITrackHoleSearchTool > m_trt_hole_finder
StatusCode reportResults()
Gaudi::Property< int > m_printDetailedInformation
ServiceHandle< ITRT_DCS_ConditionsSvc > m_DCSSvc
void myStrawIndex(Identifier id, int *index)
function that returns straw index (in range 0-5481; 0-1641 for barrel, the rest for endcap) same conv...
TRT_StrawStatus(const std::string &name, ISvcLocator *pSvcLocator)
Standard Athena-Algorithm Constructor.
StatusCode initialize()
standard Athena-Algorithm method
ServiceHandle< ITRT_HWMappingSvc > m_mapSvc
const TRT_ID * m_TRTHelper
ToolHandle< ITRT_StrawStatusSummaryTool > m_TRTStrawStatusSummaryTool
Gaudi::Property< double > m_locR_cut
std::atomic< int > m_printStatusCount
void printDetailedInformation()
int m_nEvents
returns index of hardware units: board, chip, pad private fix for now, will call TRTStrawNeighbourSvc...
SG::ReadHandleKey< DataVector< Trk::Track > > m_tracksName
~TRT_StrawStatus()
Default Destructor.
PublicToolHandle< Trk::IUpdator > m_updator
Gaudi::Property< int > m_skipBusyEvents
Gaudi::Property< std::string > m_fileName
ServiceHandle< ITRT_StrawNeighbourSvc > m_TRTStrawNeighbourSvc
StatusCode execute()
standard Athena-Algorithm method
SG::ReadHandleKey< TRT_RDO_Container > m_rdoContainerKey
virtual bool isValid() override final
Can the handle be successfully dereferenced?
const_pointer_type cptr()
Dereference the pointer.
const LocalParameters & localParameters() const
Interface method to get the LocalParameters.
const Amg::MatrixX & localCovariance() const
Interface method to get the localError.
virtual const Surface & associatedSurface() const override=0
Access to the Surface associated to the Parameters.
double pT() const
Access method for transverse momentum.
Identifier associatedDetectorElementIdentifier() const
return Identifier of the associated Detector Element
represents the track state (measurement, material, fit parameters and quality) at a surface.
const MeasurementBase * measurementOnTrack() const
returns MeasurementBase const overload
const TrackParameters * trackParameters() const
return ptr to trackparameters const overload
@ Measurement
This is a measurement, and will at least contain a Trk::MeasurementBase.
@ Hole
A hole on the track - this is defined in the following way.
ParametersT< TrackParametersDim, Charged, PerigeeSurface > Perigee
ParametersBase< TrackParametersDim, Charged > TrackParameters
Vertex_v1 Vertex
Define the latest version of the vertex class.