ATLAS Offline Software
Loading...
Searching...
No Matches
LArCollisionTimeMonAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3*/
4
5// ********************************************************************
6//
7// NAME: LArCollisionTimeMonAlg.cxx
8// PACKAGE: LArMonitoring
9//
10// AUTHOR: Margherita Spalla (migrated from LArCollisionTimeMonTool by Vikas Bansal)
11//
12// Class for monitoring : EC timing from LArCollisionTime Container
13
14//
15// ********************************************************************
16
17
18
22
23/*---------------------------------------------------------*/
24LArCollisionTimeMonAlg::LArCollisionTimeMonAlg( const std::string& name, ISvcLocator* pSvcLocator )
25 : AthMonitorAlgorithm(name,pSvcLocator)
26{}
27
28/*---------------------------------------------------------*/
31
32/*---------------------------------------------------------*/
33StatusCode
35
36 //init handlers
37 ATH_CHECK( m_LArCollisionTimeKey.initialize() );
38 ATH_CHECK( m_bunchCrossingKey.initialize());
39 ATH_CHECK( m_eventInfoDecorKey.initialize() );
41}
42
43/*---------------------------------------------------------*/
44/*
45TO BE MOVED IN PYTHON
46 MonGroup generalGroupShift( this, "/LAr/"+m_histPath+"/", run, ATTRIB_MANAGED);
47 MonGroup generalGroupLB( this, "/LAr/"+m_histPath+"/", run, ATTRIB_X_VS_LB, "", "merge");
48
49*/
50
51/*---------------------------------------------------------*/
52StatusCode
53LArCollisionTimeMonAlg::fillHistograms( const EventContext& ctx ) const
54{
55 using namespace Monitored;
56
57 ATH_MSG_DEBUG( "in fillHists()" );
58
59 //monitored variables
60 auto ecTimeDiff = Monitored::Scalar<float>("ecTimeDiff",0.0);
61 auto ecTimeAvg = Monitored::Scalar<float>("ecTimeAvg",0.0);
62 auto lumi_block = Monitored::Scalar<unsigned int>("lumi_block",0);
63 auto lumi_block_timeWindow = Monitored::Scalar<float>("lumi_block_timeWindow",0);
64 auto lumi_block_singleBeam_timeWindow = Monitored::Scalar<float>("lumi_block_singleBeam_timeWindow",0);
65 auto bunch_crossing_id = Monitored::Scalar<unsigned int>("bunch_crossing_id",0);
66 auto weight = Monitored::Scalar<float>("weight",1.);
67
69 ATH_CHECK(thisEvent.isValid());
70 // bunch crossing ID:
71 bunch_crossing_id = thisEvent->bcid();
72
73 // luminosity block number
74 lumi_block = thisEvent->lumiBlock();
75
77 if (!bcidHdl.isValid()) {
78 ATH_MSG_WARNING( "Unable to retrieve BunchCrossing conditions object" );
79 return StatusCode::SUCCESS;
80 }
81 const BunchCrossingCondData* bcData=*bcidHdl;
82
83 if (!bcData->isFilled(bunch_crossing_id)) {
84 ATH_MSG_INFO("BCID: "<<bunch_crossing_id<<" empty ? not filling the coll. time" );
85 return StatusCode::SUCCESS; // not filling anything in empty bunches
86 }
87
88 const int bcid_distance = bcData->distanceFromFront(bunch_crossing_id, BunchCrossingCondData::BunchCrossings);
89 ATH_MSG_DEBUG("BCID distance: "<<bcid_distance );
90
91 // Retrieve LArCollision Timing information
93 if(! larTime.isValid())
94 {
95 ATH_MSG_WARNING( "Unable to retrieve LArCollisionTime with key " << m_LArCollisionTimeKey );
96 return StatusCode::SUCCESS; // Check if failure shd be returned. VB
97 } else {
98 ATH_MSG_DEBUG( "LArCollisionTime successfully retrieved from event store" );
99 }
100
101 if(!thisEvent->isEventFlagBitSet(xAOD::EventInfo::LAr,LArEventBitInfo::NOISEBURSTVETO)) { // Do not fill histo if noise burst suspected
102
103 // Calculate the time diff between ECC and ECA
104 ecTimeDiff = (larTime->timeC() - larTime->timeA())/m_timeUnit;
105 ecTimeAvg = (larTime->timeC() + larTime->timeA())/(m_timeUnit*2.);
106 if (larTime->ncellA() > m_minCells && larTime->ncellC() > m_minCells && std::fabs(ecTimeDiff) < m_timeCut/m_timeUnit ) { // Only fill histograms if a minimum number of cells were found and time difference was sensible
107
108 ATH_MSG_DEBUG( "filling !" );
109 //set the weight if needed
110 if (m_eWeighted) weight = (larTime->energyA()+larTime->energyC())*1e-3;
111
112 //fill your group
113 ATH_MSG_DEBUG( "time A = " << larTime->timeA() << " time C = " << larTime->timeC() << " diff = " << larTime->timeC() - larTime->timeA() << "saved diff = " << ecTimeDiff );
114 fill(m_MonGroupName,ecTimeDiff,ecTimeAvg,lumi_block,bunch_crossing_id,weight);
115
116 //check timeWindow
117 lumi_block_timeWindow=lumi_block;
118 if ( fabs(ecTimeDiff) < 10*Gaudi::Units::nanosecond/m_timeUnit) fill(m_MonGroupName,lumi_block_timeWindow);
119
120 //check singleBeam-timeWindow
121 lumi_block_singleBeam_timeWindow=lumi_block;
122 if ( fabs(ecTimeDiff) > 20*Gaudi::Units::nanosecond/m_timeUnit && fabs(ecTimeDiff) < 30*Gaudi::Units::nanosecond/m_timeUnit ) fill(m_MonGroupName,lumi_block_singleBeam_timeWindow);
123
124 //check in-train (online only)
125 if(m_IsOnline && bcid_distance > m_distance) { // fill histos inside the train
126
127 ATH_MSG_DEBUG("BCID: "<<bunch_crossing_id<<" distance from Front: "<<bcid_distance<<"Filling in train...");
128 if(m_InTrain_MonGroupName!="") { //group name is empty by default, give it a name when you define it in the python
129
130 //fill the intrain group
131 fill(m_InTrain_MonGroupName,ecTimeDiff,ecTimeAvg,lumi_block,bunch_crossing_id,weight);
132 //check timeWindow
133 if ( fabs(ecTimeDiff) < 10*Gaudi::Units::nanosecond/m_timeUnit ) fill(m_InTrain_MonGroupName,lumi_block_timeWindow,weight);
134
135 //check singleBeam-timeWindow
136 if ( fabs(ecTimeDiff) > 20*Gaudi::Units::nanosecond/m_timeUnit && fabs(ecTimeDiff) < 30*Gaudi::Units::nanosecond/m_timeUnit ) fill(m_InTrain_MonGroupName,lumi_block_singleBeam_timeWindow,weight);
137 }
138 else ATH_MSG_WARNING( "I should be filling the 'inTrain' group now, but it looks undefined. Did you remember to set 'm_InTrain_MonGroupName' in the python?" );
139 }
140 } else {
141 ATH_MSG_DEBUG( "LAr below cuts ncells: " << larTime->ncellA() << " " << larTime->ncellC() << " times: " << larTime->timeA() << " " <<larTime->timeC() << " " << std::fabs(ecTimeDiff) <<", not filling !" );
142 }
143 }
144
145 return StatusCode::SUCCESS;
146}
147
148
149
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
Handle class for reading a decoration on an object.
virtual StatusCode initialize() override
initialize
SG::ReadHandle< xAOD::EventInfo > GetEventInfo(const EventContext &) const
Return a ReadHandle for an EventInfo object (get run/event numbers, etc.)
AthMonitorAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
int distanceFromFront(const bcid_type bcid, const BunchDistanceType type=NanoSec) const
The distance of the specific bunch crossing from the front of the train.
@ BunchCrossings
Distance in units of 25 nanoseconds.
bool isFilled(const bcid_type bcid) const
The simplest query: Is the bunch crossing filled or not?
Gaudi::Property< bool > m_IsOnline
virtual StatusCode fillHistograms(const EventContext &ctx) const override
Called each event.
Gaudi::Property< int > m_distance
SG::ReadHandleKey< LArCollisionTime > m_LArCollisionTimeKey
LArCollisionTimeMonAlg(const std::string &name, ISvcLocator *pSvcLocator)
Gaudi::Property< float > m_timeCut
Gaudi::Property< int > m_minCells
virtual StatusCode initialize() override
Overwrite dummy method from AlgTool.
Gaudi::Property< double > m_timeUnit
Gaudi::Property< std::string > m_InTrain_MonGroupName
Gaudi::Property< std::string > m_MonGroupName
SG::ReadDecorHandleKey< xAOD::EventInfo > m_eventInfoDecorKey
SG::ReadCondHandleKey< BunchCrossingCondData > m_bunchCrossingKey
virtual ~LArCollisionTimeMonAlg()
Default destructor.
Gaudi::Property< bool > m_eWeighted
Declare a monitored scalar variable.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
@ LAr
The LAr calorimeter.
Generic monitoring tool for athena components.
void fill(H5::Group &out_file, size_t iterations)