ATLAS Offline Software
Loading...
Searching...
No Matches
BunchCrossingCondTest.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3*/
4
5// Local include(s):
7
8
10 ATH_MSG_INFO( "Initializing..." );
11
12 ATH_CHECK( m_inputKey.initialize() );
13
14 if (m_fileName.size()>0) {
16 if (m_fileOut.is_open()) {
17 ATH_MSG_INFO("Writing to file " << m_fileName);
18 }
19 else {
20 msg(MSG::ERROR) << "Failed to open file " << m_fileName << endmsg;
21 return StatusCode::FAILURE;
22 }
23 }
24 else
25 ATH_MSG_INFO("Writing to stdout");
26
27 return StatusCode::SUCCESS;
28}
29
30
32
33 // Retrieve the object holding the BCID of the current event:
34 const EventContext& ctx = Gaudi::Hive::currentContext();
35
36
37 std::ostream& out = m_fileOut.good() ? m_fileOut : std::cout;
38
40 const BunchCrossingCondData* bccd=*readHdl;
41
42 out << "\nTimestamp:" << ctx.eventID().time_stamp() << " ns:" << ctx.eventID().time_stamp_ns_offset() << std::endl;
43 out << "numberOfBunchTrains=" << bccd->numberOfBunchTrains() << std::endl;
44 out << "numberOfUnpairedBunches= " << bccd->numberOfUnpairedBunches() << std::endl;
45
46 for (unsigned bcid=0;bcid<3564;++bcid) {
47 if (m_compact) {
48 printCompactInfo(bccd,bcid,out);
49 }
50 else {
51 printInfo(bccd,bcid,out);
52 }
53 }
54 return StatusCode::SUCCESS;
55}
56
57
58void BunchCrossingCondTest::printInfo(const BunchCrossingCondData* bccd, unsigned int bcid, std::ostream& out ) {
59
60 out << "BCID " << bcid;
61 out << " Filled=" << bccd->isFilled(bcid) << ", isInTrain=" << bccd->isInTrain(bcid)
62 << ", isUnPaired=" << bccd->isUnpaired(bcid)
63 << ", isBeam1="<< bccd->isBeam1(bcid) << ", isBeam2=" <<bccd->isBeam2(bcid);
64 out << ", distFront=" << bccd->distanceFromFront(bcid)
65 << ", distTail= " << bccd->distanceFromTail(bcid);
66
67 out << ", gapBefore=" << bccd->gapBeforeTrain(bcid)
68 << ", gapAfter=" << bccd->gapAfterTrain(bcid);
69
70 out << std::endl;
71
72}
73
74void BunchCrossingCondTest::printCompactInfo(const BunchCrossingCondData* bccd, unsigned int bcid, std::ostream& out ) {
75
76 if (bccd->isBeam1(bcid) || bccd->isBeam2(bcid)) {
77 out << bcid << " ";
78 out << (bccd->isFilled(bcid) ? "F" : " ");
79 out << (bccd->isInTrain(bcid) ? "T" : " ");
80 out << (bccd->isUnpaired(bcid) ? "U" : " ");
81 out << (bccd->isBeam1(bcid) ? "1" : " ");
82 out << (bccd->isBeam2(bcid) ? "2" : " ");
83 int df=bccd->distanceFromFront(bcid);
84 if (df>=0) {
85 out << "/" << df;
86 }
87 int dt=bccd->distanceFromTail(bcid);
88 if (dt>=0) {
89 out << "/" << dt;
90 }
91 out << std::endl;
92 }
93}
#define endmsg
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)
MsgStream & msg() const
int distanceFromFront(const bcid_type bcid, const BunchDistanceType type=NanoSec) const
The distance of the specific bunch crossing from the front of the train.
bool isBeam1(const bcid_type bcid) const
Function deciding if there was a bunch from "beam 1" in this bunch crossing.
unsigned int numberOfUnpairedBunches() const
Get the number of unpaired bunches in the current configuration.
bool isBeam2(const bcid_type bcid) const
Function deciding if there was a bunch from "beam 2" in this bunch crossing.
bool isInTrain(const bcid_type bcid) const
Function deciding if a given bunch crossing is in a filled train.
int distanceFromTail(const bcid_type bcid, const BunchDistanceType type=NanoSec) const
The distance of the specific bunch crossing from the tail of the train.
bool isFilled(const bcid_type bcid) const
The simplest query: Is the bunch crossing filled or not?
unsigned int numberOfBunchTrains() const
Get the number of the bunch trains in the current configuration.
bool isUnpaired(const bcid_type bcid) const
Function deciding if a given bunch crossing has an unpaired bunch.
int gapBeforeTrain(bcid_type bcid=0, BunchDistanceType type=NanoSec) const
Gap before the train this BCID is in.
int gapAfterTrain(bcid_type bcid=0, BunchDistanceType type=NanoSec) const
Gap after the train this BCID is in.
static void printInfo(const BunchCrossingCondData *bccd, unsigned int bcid, std::ostream &out)
Function for printing detailed info about a given bunch crossing.
Gaudi::Property< std::string > m_fileName
static void printCompactInfo(const BunchCrossingCondData *bccd, unsigned int bcid, std::ostream &out)
SG::ReadCondHandleKey< BunchCrossingCondData > m_inputKey
virtual StatusCode initialize()
Initialization run before the event loop.
virtual StatusCode execute()
Function called once per event.
Gaudi::Property< bool > m_compact