21 m_containerPosition(0),
25 m_fileStream.open(fileName.c_str(), std::ios::in | std::ios::binary);
46 return STATUS_CODE_FAILURE;
51 return STATUS_CODE_FAILURE;
57 return STATUS_CODE_FAILURE;
59 return STATUS_CODE_SUCCESS;
70 return STATUS_CODE_FAILURE;
72 return STATUS_CODE_SUCCESS;
79 const std::ifstream::pos_type initialPosition(
m_fileStream.tellg());
84 if (STATUS_CODE_SUCCESS != fileHashStatusCode)
105 int nGeometriesRead(0);
109 return STATUS_CODE_FAILURE;
114 while (nGeometriesRead <
static_cast<int>(geometryNumber))
120 return STATUS_CODE_SUCCESS;
131 return STATUS_CODE_FAILURE;
136 while (nEventsRead <
static_cast<int>(eventNumber))
142 return STATUS_CODE_SUCCESS;
152 if (STATUS_CODE_SUCCESS != statusCode)
154 if (STATUS_CODE_NOT_FOUND != statusCode)
157 return STATUS_CODE_NOT_FOUND;
174 return STATUS_CODE_NOT_FOUND;
187 if (STATUS_CODE_SUCCESS != statusCode)
189 if (STATUS_CODE_NOT_FOUND != statusCode)
192 return STATUS_CODE_NOT_FOUND;
207 return STATUS_CODE_NOT_FOUND;
218 return STATUS_CODE_FAILURE;
220 if (checkComponentId)
226 return STATUS_CODE_FAILURE;
235 std::string subDetectorName;
239 float innerRCoordinate(0.f);
241 float innerZCoordinate(0.f);
243 float innerPhiCoordinate(0.f);
245 unsigned int innerSymmetryOrder(0);
247 float outerRCoordinate(0.f);
249 float outerZCoordinate(0.f);
251 float outerPhiCoordinate(0.f);
253 unsigned int outerSymmetryOrder(0);
255 bool isMirroredInZ(
false);
257 unsigned int nLayers(0);
260 pParameters->m_subDetectorName = subDetectorName;
261 pParameters->m_subDetectorType = subDetectorType;
262 pParameters->m_innerRCoordinate = innerRCoordinate;
263 pParameters->m_innerZCoordinate = innerZCoordinate;
264 pParameters->m_innerPhiCoordinate = innerPhiCoordinate;
265 pParameters->m_innerSymmetryOrder = innerSymmetryOrder;
266 pParameters->m_outerRCoordinate = outerRCoordinate;
267 pParameters->m_outerZCoordinate = outerZCoordinate;
268 pParameters->m_outerPhiCoordinate = outerPhiCoordinate;
269 pParameters->m_outerSymmetryOrder = outerSymmetryOrder;
270 pParameters->m_isMirroredInZ = isMirroredInZ;
271 pParameters->m_nLayers = nLayers;
273 for (
unsigned int iLayer = 0; iLayer < nLayers; ++iLayer)
275 float closestDistanceToIp(0.f);
277 float nRadiationLengths(0.f);
279 float nInteractionLengths(0.f);
286 pParameters->m_layerParametersVector.push_back(layerParameters);
298 return STATUS_CODE_SUCCESS;
306 return STATUS_CODE_FAILURE;
308 if (checkComponentId)
314 return STATUS_CODE_FAILURE;
323 unsigned int larTPCVolumeId;
337 float wirePitchU(0.f);
339 float wirePitchV(0.f);
341 float wirePitchW(0.f);
343 float wireAngleU(0.f);
345 float wireAngleV(0.f);
347 float wireAngleW(0.f);
351 bool isDriftInPositiveX(
false);
354 pParameters->m_larTPCVolumeId = larTPCVolumeId;
355 pParameters->m_centerX = centerX;
356 pParameters->m_centerY = centerY;
357 pParameters->m_centerZ = centerZ;
358 pParameters->m_widthX = widthX;
359 pParameters->m_widthY = widthY;
360 pParameters->m_widthZ = widthZ;
361 pParameters->m_wirePitchU = wirePitchU;
362 pParameters->m_wirePitchV = wirePitchV;
363 pParameters->m_wirePitchW = wirePitchW;
364 pParameters->m_wireAngleU = wireAngleU;
365 pParameters->m_wireAngleV = wireAngleV;
366 pParameters->m_wireAngleW = wireAngleW;
367 pParameters->m_sigmaUVW = sigmaUVW;
368 pParameters->m_isDriftInPositiveX = isDriftInPositiveX;
379 return STATUS_CODE_SUCCESS;
387 return STATUS_CODE_FAILURE;
389 if (checkComponentId)
395 return STATUS_CODE_FAILURE;
406 float lineStartX(0.f);
410 float lineStartZ(0.f);
415 pParameters->m_lineGapType = lineGapType;
416 pParameters->m_lineStartX = lineStartX;
417 pParameters->m_lineEndX = lineEndX;
418 pParameters->m_lineStartZ = lineStartZ;
419 pParameters->m_lineEndZ = lineEndZ;
429 return STATUS_CODE_SUCCESS;
437 return STATUS_CODE_FAILURE;
439 if (checkComponentId)
445 return STATUS_CODE_FAILURE;
463 pParameters->m_vertex = vertex;
464 pParameters->m_side1 = side1;
465 pParameters->m_side2 = side2;
466 pParameters->m_side3 = side3;
476 return STATUS_CODE_SUCCESS;
484 return STATUS_CODE_FAILURE;
486 if (checkComponentId)
492 return STATUS_CODE_FAILURE;
501 float minZCoordinate(0.f);
503 float maxZCoordinate(0.f);
505 float innerRCoordinate(0.f);
507 float innerPhiCoordinate(0.f);
509 unsigned int innerSymmetryOrder(0);
511 float outerRCoordinate(0.f);
513 float outerPhiCoordinate(0.f);
515 unsigned int outerSymmetryOrder(0);
518 pParameters->m_minZCoordinate = minZCoordinate;
519 pParameters->m_maxZCoordinate = maxZCoordinate;
520 pParameters->m_innerRCoordinate = innerRCoordinate;
521 pParameters->m_innerPhiCoordinate = innerPhiCoordinate;
522 pParameters->m_innerSymmetryOrder = innerSymmetryOrder;
523 pParameters->m_outerRCoordinate = outerRCoordinate;
524 pParameters->m_outerPhiCoordinate = outerPhiCoordinate;
525 pParameters->m_outerSymmetryOrder = outerSymmetryOrder;
535 return STATUS_CODE_SUCCESS;
543 return STATUS_CODE_FAILURE;
545 if (checkComponentId)
551 return STATUS_CODE_FAILURE;
568 float cellThickness(0.f);
570 float nCellRadiationLengths(0.f);
572 float nCellInteractionLengths(0.f);
576 float inputEnergy(0.f);
578 float mipEquivalentEnergy(0.f);
580 float electromagneticEnergy(0.f);
582 float hadronicEnergy(0.f);
584 bool isDigital(
false);
590 unsigned int layer(0);
592 bool isInOuterSamplingLayer(
false);
594 const void *pParentAddress(
nullptr);
596 float cellSize0(0.f);
598 float cellSize1(0.f);
601 pParameters->m_positionVector = positionVector;
602 pParameters->m_expectedDirection = expectedDirection;
603 pParameters->m_cellNormalVector = cellNormalVector;
604 pParameters->m_cellGeometry = cellGeometry;
605 pParameters->m_cellSize0 = cellSize0;
606 pParameters->m_cellSize1 = cellSize1;
607 pParameters->m_cellThickness = cellThickness;
608 pParameters->m_nCellRadiationLengths = nCellRadiationLengths;
609 pParameters->m_nCellInteractionLengths = nCellInteractionLengths;
610 pParameters->m_time = time;
611 pParameters->m_inputEnergy = inputEnergy;
612 pParameters->m_mipEquivalentEnergy = mipEquivalentEnergy;
613 pParameters->m_electromagneticEnergy = electromagneticEnergy;
614 pParameters->m_hadronicEnergy = hadronicEnergy;
615 pParameters->m_isDigital = isDigital;
616 pParameters->m_hitType = hitType;
617 pParameters->m_hitRegion = hitRegion;
618 pParameters->m_layer = layer;
619 pParameters->m_isInOuterSamplingLayer = isInOuterSamplingLayer;
620 pParameters->m_pParentAddress = pParentAddress;
630 return STATUS_CODE_SUCCESS;
638 return STATUS_CODE_FAILURE;
640 if (checkComponentId)
646 return STATUS_CODE_FAILURE;
667 TrackState trackStateAtStart(0.f, 0.f, 0.f, 0.f, 0.f, 0.f);
669 TrackState trackStateAtEnd(0.f, 0.f, 0.f, 0.f, 0.f, 0.f);
671 TrackState trackStateAtCalorimeter(0.f, 0.f, 0.f, 0.f, 0.f, 0.f);
673 float timeAtCalorimeter(0.f);
675 bool reachesCalorimeter(
false);
677 bool isProjectedToEndCap(
false);
679 bool canFormPfo(
false);
681 bool canFormClusterlessPfo(
false);
683 const void *pParentAddress(
nullptr);
686 pParameters->m_d0 = d0;
687 pParameters->m_z0 = z0;
688 pParameters->m_particleId = particleId;
689 pParameters->m_charge = charge;
690 pParameters->m_mass = mass;
691 pParameters->m_momentumAtDca = momentumAtDca;
692 pParameters->m_trackStateAtStart = trackStateAtStart;
693 pParameters->m_trackStateAtEnd = trackStateAtEnd;
694 pParameters->m_trackStateAtCalorimeter = trackStateAtCalorimeter;
695 pParameters->m_timeAtCalorimeter = timeAtCalorimeter;
696 pParameters->m_reachesCalorimeter = reachesCalorimeter;
697 pParameters->m_isProjectedToEndCap = isProjectedToEndCap;
698 pParameters->m_canFormPfo = canFormPfo;
699 pParameters->m_canFormClusterlessPfo = canFormClusterlessPfo;
700 pParameters->m_pParentAddress = pParentAddress;
710 return STATUS_CODE_SUCCESS;
718 return STATUS_CODE_FAILURE;
720 if (checkComponentId)
726 return STATUS_CODE_FAILURE;
743 int particleId(-std::numeric_limits<int>::max());
747 const void *pParentAddress(
nullptr);
750 pParameters->m_energy = energy;
751 pParameters->m_momentum = momentum;
752 pParameters->m_vertex = vertex;
753 pParameters->m_endpoint = endpoint;
754 pParameters->m_particleId = particleId;
755 pParameters->m_mcParticleType = mcParticleType;
756 pParameters->m_pParentAddress = pParentAddress;
766 return STATUS_CODE_SUCCESS;
774 return STATUS_CODE_FAILURE;
776 if (checkComponentId)
782 return STATUS_CODE_FAILURE;
787 const void *address1(
nullptr);
789 const void *address2(
nullptr);
794 switch (relationshipId)
807 return STATUS_CODE_FAILURE;
810 return STATUS_CODE_SUCCESS;
Header file for the binary file reader class.
Header file for the calo hit class.
Header file for the pandora api class.
#define PANDORA_THROW_RESULT_IF(StatusCode1, Operator, Command)
#define PANDORA_RETURN_RESULT_IF(StatusCode1, Operator, Command)
Header file for the track class.
static pandora::StatusCode SetTrackToMCParticleRelationship(const pandora::Pandora &pandora, const void *const pTrackParentAddress, const void *const pMCParticleParentAddress, const float mcParticleWeight=1)
Set track to mc particle relationship.
static pandora::StatusCode SetMCParentDaughterRelationship(const pandora::Pandora &pandora, const void *const pParentAddress, const void *const pDaughterAddress)
Set parent-daughter mc particle relationship.
static pandora::StatusCode SetCaloHitToMCParticleRelationship(const pandora::Pandora &pandora, const void *const pCaloHitParentAddress, const void *const pMCParticleParentAddress, const float mcParticleWeight=1)
Set calo hit to mc particle relationship.
static pandora::StatusCode SetTrackSiblingRelationship(const pandora::Pandora &pandora, const void *const pFirstSiblingAddress, const void *const pSecondSiblingAddress)
Set sibling track relationship.
static pandora::StatusCode SetTrackParentDaughterRelationship(const pandora::Pandora &pandora, const void *const pParentAddress, const void *const pDaughterAddress)
Set parent-daughter track relationship.
pandora::InputFloat m_closestDistanceToIp
Closest distance of the layer from the interaction point, units mm.
pandora::InputFloat m_nRadiationLengths
Absorber material in front of layer, units radiation lengths.
pandora::InputFloat m_nInteractionLengths
Absorber material in front of layer, units interaction lengths.
static pandora::StatusCode Create(const pandora::Pandora &pandora, const Parameters ¶meters, const pandora::ObjectFactory< Parameters, Object > &factory=pandora::PandoraObjectFactory< Parameters, Object >())
Create a new object from a user factory.
StatusCode ReadTrack(bool checkComponentId=true)
Read a track from the current position in the file, recreating the stored object.
StatusCode ReadCaloHit(bool checkComponentId=true)
Read a calo hit from the current position in the file, recreating the stored object.
std::ifstream::pos_type m_containerSize
Size of the current event/geometry container object in the file.
StatusCode ReadHeader()
Read the container header from the current position in the file, checking for properly written contai...
StatusCode ReadSubDetector(bool checkComponentId=true)
Read a sub detector from the current position in the file.
StatusCode GoToNextContainer()
Skip to next container in the file.
StatusCode ReadLineGap(bool checkComponentId=true)
Read a line gap from the current position in the file.
StatusCode ReadConcentricGap(bool checkComponentId=true)
Read a concentric gap from the current position in the file.
StatusCode ReadVariable(T &t)
Read a variable from the file.
StatusCode GoToGeometry(const unsigned int geometryNumber)
Skip to a specified geometry number in the file.
StatusCode ReadRelationship(bool checkComponentId=true)
Read a relationship from the current position in the file, recreating the stored relationship.
BinaryFileReader(const pandora::Pandora &pandora, const std::string &fileName)
Constructor.
StatusCode ReadLArTPC(bool checkComponentId=true)
Read a lar tpc from the current position in the file.
~BinaryFileReader()
Destructor.
ContainerId GetNextContainerId()
Get the id of the next container in the file without changing the current position in the file.
StatusCode ReadNextEventComponent()
Read the next pandora event component from the current position in the file, recreating the stored co...
StatusCode ReadNextGeometryComponent()
Read the next pandora geometry component from the current position in the file, recreating the stored...
StatusCode ReadBoxGap(bool checkComponentId=true)
Read a box gap from the current position in the file.
std::ifstream m_fileStream
The stream class to read from the file.
std::ifstream::pos_type m_containerPosition
Position of start of the current event/geometry container object in file.
StatusCode ReadMCParticle(bool checkComponentId=true)
Read a mc particle from the current position in the file, recreating the stored object.
StatusCode GoToEvent(const unsigned int eventNumber)
Skip to a specified event number in the file.
StatusCode GoToNextGeometry()
Skip to next geometry container in the file.
StatusCode GoToNextEvent()
Skip to next event container in the file.
virtual Parameters * NewParameters() const =0
Create new parameters instance on the heap (memory-management to be controlled by user)
virtual StatusCode Read(Parameters ¶meters, FileReader &fileReader) const =0
Read any additional (derived class only) object parameters from file using the specified file reader.
ObjectFactory< object_creation::Geometry::BoxGap::Parameters, object_creation::Geometry::BoxGap::Object > * m_pBoxGapFactory
Address of the box gap factory.
ContainerId m_containerId
The type of container currently being written to file.
const Pandora *const m_pPandora
Address of pandora instance to be used alongside the file writer.
ObjectFactory< object_creation::MCParticle::Parameters, object_creation::MCParticle::Object > * m_pMCParticleFactory
Address of the mc particle factory.
ObjectFactory< object_creation::Geometry::LArTPC::Parameters, object_creation::Geometry::LArTPC::Object > * m_pLArTPCFactory
Address of the lar tpc factory.
ObjectFactory< object_creation::Track::Parameters, object_creation::Track::Object > * m_pTrackFactory
Address of the track factory.
ObjectFactory< object_creation::CaloHit::Parameters, object_creation::CaloHit::Object > * m_pCaloHitFactory
Address of the calo hit factory.
ObjectFactory< object_creation::Geometry::LineGap::Parameters, object_creation::Geometry::LineGap::Object > * m_pLineGapFactory
Address of the line gap factory.
ObjectFactory< object_creation::Geometry::ConcentricGap::Parameters, object_creation::Geometry::ConcentricGap::Object > * m_pConcentricGapFactory
Address of the concentric gap factory.
ObjectFactory< object_creation::Geometry::SubDetector::Parameters, object_creation::Geometry::SubDetector::Object > * m_pSubDetectorFactory
Address of the sub detector factory.
FileType m_fileType
The file type.
StatusCodeException class.
StatusCode GetStatusCode() const
Get status code.
HitType
Calorimeter hit type enum.
HitRegion
Calorimeter hit region enum.
ComponentId
The component identification enum.
@ CONCENTRIC_GAP_COMPONENT
RelationshipId
The relationship identification enum.
@ TRACK_TO_MC_RELATIONSHIP
@ CALO_HIT_TO_MC_RELATIONSHIP
@ TRACK_SIBLING_RELATIONSHIP
@ TRACK_PARENT_DAUGHTER_RELATIONSHIP
@ MC_PARENT_DAUGHTER_RELATIONSHIP
CellGeometry
Cell geometry enum.
ContainerId
The container identification enum.
MCParticleType
MC particle type enum.
StatusCode
The StatusCode enum.
SubDetectorType
Subdetector type enum.
const std::string PANDORA_FILE_HASH("pandora")
Look for hash each event to check integrity.
LineGapType
Line gap type.