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
31StatusCode BunchCrossingCondTest::execute(const EventContext& ctx) {
32
33 // Retrieve the object holding the BCID of the current event:
34
35
36 std::ostream& out = m_fileOut.good() ? m_fileOut : std::cout;
37
39 const BunchCrossingCondData* bccd=*readHdl;
40
41 out << "\nTimestamp:" << ctx.eventID().time_stamp() << " ns:" << ctx.eventID().time_stamp_ns_offset() << std::endl;
42 out << "numberOfBunchTrains=" << bccd->numberOfBunchTrains() << std::endl;
43 out << "numberOfUnpairedBunches= " << bccd->numberOfUnpairedBunches() << std::endl;
44
45 for (unsigned bcid=0;bcid<3564;++bcid) {
46 if (m_compact) {
47 printCompactInfo(bccd,bcid,out);
48 }
49 else {
50 printInfo(bccd,bcid,out);
51 }
52 }
53 return StatusCode::SUCCESS;
54}
55
56
57void BunchCrossingCondTest::printInfo(const BunchCrossingCondData* bccd, unsigned int bcid, std::ostream& out ) {
58
59 out << "BCID " << bcid;
60 out << " Filled=" << bccd->isFilled(bcid) << ", isInTrain=" << bccd->isInTrain(bcid)
61 << ", isUnPaired=" << bccd->isUnpaired(bcid)
62 << ", isBeam1="<< bccd->isBeam1(bcid) << ", isBeam2=" <<bccd->isBeam2(bcid);
63 out << ", distFront=" << bccd->distanceFromFront(bcid)
64 << ", distTail= " << bccd->distanceFromTail(bcid);
65
66 out << ", gapBefore=" << bccd->gapBeforeTrain(bcid)
67 << ", gapAfter=" << bccd->gapAfterTrain(bcid);
68
69 out << std::endl;
70
71}
72
73void BunchCrossingCondTest::printCompactInfo(const BunchCrossingCondData* bccd, unsigned int bcid, std::ostream& out ) {
74
75 if (bccd->isBeam1(bcid) || bccd->isBeam2(bcid)) {
76 out << bcid << " ";
77 out << (bccd->isFilled(bcid) ? "F" : " ");
78 out << (bccd->isInTrain(bcid) ? "T" : " ");
79 out << (bccd->isUnpaired(bcid) ? "U" : " ");
80 out << (bccd->isBeam1(bcid) ? "1" : " ");
81 out << (bccd->isBeam2(bcid) ? "2" : " ");
82 int df=bccd->distanceFromFront(bcid);
83 if (df>=0) {
84 out << "/" << df;
85 }
86 int dt=bccd->distanceFromTail(bcid);
87 if (dt>=0) {
88 out << "/" << dt;
89 }
90 out << std::endl;
91 }
92}
#define endmsg
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)
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.
Gaudi::Property< bool > m_compact
virtual StatusCode execute(const EventContext &ctx)
Function called once per event.