ATLAS Offline Software
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 
13 
14  if (m_fileName.size()>0) {
15  m_fileOut.open(m_fileName);
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) {
49  }
50  else {
51  printInfo(bccd,bcid,out);
52  }
53  }
54  return StatusCode::SUCCESS;
55 }
56 
57 
58 void 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 
74 void 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 }
BunchCrossingCondData::distanceFromTail
int distanceFromTail(const bcid_type bcid, const BunchDistanceType type=NanoSec) const
The distance of the specific bunch crossing from the tail of the train.
Definition: BunchCrossingCondData.cxx:60
BunchCrossingCondData
Definition: BunchCrossingCondData.h:23
BunchCrossingCondData::isUnpaired
bool isUnpaired(const bcid_type bcid) const
Function deciding if a given bunch crossing has an unpaired bunch.
Definition: BunchCrossingCondData.h:358
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
BunchCrossingCondData::gapAfterTrain
int gapAfterTrain(bcid_type bcid=0, BunchDistanceType type=NanoSec) const
Gap after the train this BCID is in.
Definition: BunchCrossingCondData.cxx:164
BunchCrossingCondTest::m_compact
Gaudi::Property< bool > m_compact
Definition: BunchCrossingCondTest.h:39
BunchCrossingCondData::numberOfBunchTrains
unsigned int numberOfBunchTrains() const
Get the number of the bunch trains in the current configuration.
Definition: BunchCrossingCondData.h:371
BunchCrossingCondTest::m_fileOut
std::ofstream m_fileOut
Definition: BunchCrossingCondTest.h:41
BunchCrossingCondTest::printCompactInfo
static void printCompactInfo(const BunchCrossingCondData *bccd, unsigned int bcid, std::ostream &out)
Definition: BunchCrossingCondTest.cxx:74
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:71
BunchCrossingCondData::gapBeforeTrain
int gapBeforeTrain(bcid_type bcid=0, BunchDistanceType type=NanoSec) const
Gap before the train this BCID is in.
Definition: BunchCrossingCondData.cxx:127
BunchCrossingCondTest::m_inputKey
SG::ReadCondHandleKey< BunchCrossingCondData > m_inputKey
Definition: BunchCrossingCondTest.h:35
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
CaloNoise_fillDB.dt
dt
Definition: CaloNoise_fillDB.py:58
BunchCrossingCondTest.h
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
BunchCrossingCondTest::m_fileName
Gaudi::Property< std::string > m_fileName
Definition: BunchCrossingCondTest.h:37
BunchCrossingCondData::numberOfUnpairedBunches
unsigned int numberOfUnpairedBunches() const
Get the number of unpaired bunches in the current configuration.
Definition: BunchCrossingCondData.cxx:85
BunchCrossingCondData::isBeam2
bool isBeam2(const bcid_type bcid) const
Function deciding if there was a bunch from "beam 2" in this bunch crossing.
Definition: BunchCrossingCondData.h:351
BunchCrossingCondData::distanceFromFront
int distanceFromFront(const bcid_type bcid, const BunchDistanceType type=NanoSec) const
The distance of the specific bunch crossing from the front of the train.
Definition: BunchCrossingCondData.cxx:35
BunchCrossingCondTest::printInfo
static void printInfo(const BunchCrossingCondData *bccd, unsigned int bcid, std::ostream &out)
Function for printing detailed info about a given bunch crossing.
Definition: BunchCrossingCondTest.cxx:58
BunchCrossingCondData::isBeam1
bool isBeam1(const bcid_type bcid) const
Function deciding if there was a bunch from "beam 1" in this bunch crossing.
Definition: BunchCrossingCondData.h:345
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
xAOD::bcid
setEventNumber setTimeStamp bcid
Definition: EventInfo_v1.cxx:133
BunchCrossingCondData::isInTrain
bool isInTrain(const bcid_type bcid) const
Function deciding if a given bunch crossing is in a filled train.
Definition: BunchCrossingCondData.h:376
AthCommonMsg< Algorithm >::msg
MsgStream & msg() const
Definition: AthCommonMsg.h:24
python.TriggerAPI.TriggerAPISession.df
df
Definition: TriggerAPISession.py:432
BunchCrossingCondTest::execute
virtual StatusCode execute()
Function called once per event.
Definition: BunchCrossingCondTest.cxx:31
BunchCrossingCondTest::initialize
virtual StatusCode initialize()
Initialization run before the event loop.
Definition: BunchCrossingCondTest.cxx:9
BunchCrossingCondData::isFilled
bool isFilled(const bcid_type bcid) const
The simplest query: Is the bunch crossing filled or not?
Definition: BunchCrossingCondData.h:339