Skip to content
Snippets Groups Projects

New merge to master for VELO monitoring (rebased from velomon_rhel9, TAEmonitor only now)

Merged Lanxing Li requested to merge lali_velomon_rebase_TAE_only into master
Compare and
2 files
+ 227
2
Compare changes
  • Side-by-side
  • Inline
Files
2
+ 222
0
/*****************************************************************************\
* (c) Copyright 2020 CERN for the benefit of the LHCb Collaboration *
* *
* This software is distributed under the terms of the GNU General Public *
* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". *
* *
* In applying this licence, CERN does not waive the privileges and immunities *
* granted to it by virtue of its status as an Intergovernmental Organization *
* or submit itself to any jurisdiction. *
\*****************************************************************************/
#include "Event/RecVertex.h"
#include "Event/ODIN.h"
#include "Event/VPFullCluster.h"
#include "Kernel/VPConstants.h"
#include "VPDet/DeVP.h"
#include "DetDesc/GenericConditionAccessorHolder.h"
#include "VPDet/DeVPSensor.h"
#include "GaudiAlg/Consumer.h"
#include "GaudiAlg/GaudiTupleAlg.h"
#include "GaudiUtils/Aida2ROOT.h"
#include <GaudiAlg/GaudiHistoAlg.h>
#include <GaudiKernel/IHistogramSvc.h>
#include <GaudiUtils/HistoLabels.h>
#include <unistd.h>
#include "Gaudi/Accumulators/Histogram.h"
#include <string>
#include <vector>
/* @class VPTAEMonitors.cpp VPTAEMonitors.cpp
*
* * Class for plotting:
* - used for TAE plots (True/Fake)
*
*
* * Notes:
* - Currently use Odin features to obtain the FillingScheme
* @author Lanxing Li
* @date 2023-10-04
*/
namespace {
// Adjust bxid when it is shifted for some operation, so that it is always 1-3564
// This only works if the operation shifts the bxid by at most 3564
constexpr uint adjust_bxid( int checkedBxID ) {
int adjustedBxID{checkedBxID};
if ( checkedBxID < 1 ) {
adjustedBxID += 3564;
} else if ( checkedBxID > 3564 ) {
adjustedBxID -= 3564;
}
return static_cast<uint>( adjustedBxID );
}
} // anonymous namespace
using namespace Gaudi::Functional; // Consumer
using namespace Gaudi::Utils; // Aida2ROOT::aida2root
// Enumerators
enum struct OutputMode { Histograms, Tuples };
template <OutputMode outmode>
class VPTAEMonitors : public Consumer<void( const LHCb::ODIN&, const std::vector<LHCb::VPFullCluster>& ),
LHCb::DetDesc::usesBaseAndConditions<GaudiTupleAlg>> {
public:
// Constructor
VPTAEMonitors( const std::string& name, ISvcLocator* pSvcLocator );
// Initialize
StatusCode initialize() override;
// Functional operator
void operator()( const LHCb::ODIN&, const std::vector<LHCb::VPFullCluster>& ) const override;
bool is_trueTAE = false;
const int m_maxTaeIndex = 10;
private:
// Histogram objects
struct Histograms {
mutable Gaudi::Accumulators::Histogram<2> m_fakeTAE; // Number of clusters per event for prespill -2, -1, 0, BBs,
// spillover +0, +1 +2 (EE)
// mutable Gaudi::Accumulators::Histogram<2> m_fakeTAE_split; // Number of clusters per event for prespill -2, -1,
// 0,
// BB in lead, BBs in middle, BB at tail. spillover +0, +1 +2 (EE) temporarily removed (no need)
mutable Gaudi::Accumulators::Histogram<2> m_fakeTAE_lead; // Number of clusters per event for prespill -2, -1, 0, BB
// in lead,
mutable Gaudi::Accumulators::Histogram<2> m_fakeTAE_trail; // Number of clusters per event for BB at tail, spillver
// 0, -1, -2 (EE)
mutable Gaudi::Accumulators::Histogram<2> m_fakeTAE_lead_trail; // Number of clusters per event for prespill -2, -1,
// 0, BB at lead, BB at tail, spillver 0, -1, -2
// (EE)
mutable Gaudi::Accumulators::Histogram<2> m_trueTAE; // Number of clusters per event for prespill -2, -1, 0, BBs,
// spillover +0, +1 +2 (EE)
mutable Gaudi::Accumulators::Histogram<2> m_TAE_all; // Number of clusters per event for prespill -2, -1, 0, BBs
// (isolated + lead + trail), spillover +0, +1 +2 (EE)
// Book all plots
Histograms( const VPTAEMonitors<outmode>* owner )
: m_fakeTAE{owner,
"VPClustersPerEventFakeTAEAny",
"EE -> EE -> EE -> Beam-Beams -> EE -> EE -> EE ; ; Clusters/event",
{9, -0.5, 8.5},
{5001, -1, 10001}}
,
m_fakeTAE_lead{owner,
"VPClustersPerEventFakeTAE_lead",
"EE -> EE -> EE -> Beam-Beams(lead); ; Clusters/event",
{9, -0.5, 8.5},
{5001, -1, 10001}}
, m_fakeTAE_trail{owner,
"VPClustersPerEventFakeTAE_trail",
"Beam-Beams(trail) -> EE -> EE -> EE ; ; Clusters/event",
{9, -0.5, 8.5},
{5001, -1, 10001}}
, m_fakeTAE_lead_trail{owner,
"VPClustersPerEventFakeTAE_lead_trail",
"EE -> EE -> EE -> Beam-Beams(lead) -> Beam-Beams(trail) -> EE -> EE -> EE ; ; "
"Clusters/event",
{9, -0.5, 8.5},
{5001, -1, 10001}}
, m_trueTAE{owner,
"VPClustersPerEventTrueTAE",
"EE -> EE -> EE -> iso Beam-Beam -> EE -> EE -> EE ; ; Clusters/event",
{9, -0.5, 8.5},
{5001, -1, 10001}}
, m_TAE_all{owner,
"VPClustersPerEvent_TAE_all",
"EE -> EE -> EE -> Beam-Beams -> EE -> EE -> EE ; ; Clusters/event",
{9, -0.5, 8.5},
{5001, -1, 10001}} {}
};
std::unique_ptr<Histograms> m_histos;
};
// Declaration of the Algorithm Factory
using VPTAEMonitorsHistograms = VPTAEMonitors<OutputMode::Histograms>;
using VPTAEMonitorsTuples = VPTAEMonitors<OutputMode::Tuples>;
DECLARE_COMPONENT_WITH_ID( VPTAEMonitorsHistograms, "VPTAEMonitors" )
DECLARE_COMPONENT_WITH_ID( VPTAEMonitorsTuples, "VPTAEMonitorsNT" )
// ===============================================================
// Constructor
// ===============================================================
template <OutputMode outmode>
VPTAEMonitors<outmode>::VPTAEMonitors( const std::string& name, ISvcLocator* pSvcLocator )
: Consumer( name, pSvcLocator,
{
KeyValue{"ODINLocation", LHCb::ODINLocation::Default},
KeyValue{"ClusterLocation", LHCb::VPFullClusterLocation::Default},
} ) {}
// ===============================================================
// Initialize
// ===============================================================
template <OutputMode outmode>
StatusCode VPTAEMonitors<outmode>::initialize() {
StatusCode sc = Consumer::initialize();
if ( sc.isFailure() ) return sc;
// return sc;
return sc.andThen( [&]() { m_histos = std::make_unique<Histograms>( this ); } );
};
// ===============================================================
// Main
// ===============================================================
template <OutputMode outmode>
void VPTAEMonitors<outmode>::operator()( const LHCb::ODIN& odin,
const std::vector<LHCb::VPFullCluster>& vpClusters ) const {
// Get event information from ODIN
auto bxid{odin.bunchId()};
auto trigger_type{odin.triggerType()};
auto event_type{odin.eventType()};
// auto TAE_index = m_maxTaeIndex - odin.timeAlignmentEventIndex();
auto TAE_index = m_maxTaeIndex - odin.timeAlignmentEventIndex() - 2;
// auto TAE_index = odin.timeAlignmentEventIndex();
const auto bxtype{odin.bunchCrossingType()};
if ( outmode == OutputMode::Histograms ) {
int nclPerEvent = vpClusters.size();
if ( TAE_index < m_maxTaeIndex && odin.timeAlignmentEventIndex() != 0 ) {
if ( ( event_type & static_cast<std::uint16_t>( 1 << 8 ) ) ||
( event_type & static_cast<std::uint16_t>( 1 << 11 ) ) ||
( event_type & static_cast<std::uint16_t>( 1 << 12 ) ) ) {
++( *m_histos ).m_trueTAE[{TAE_index, nclPerEvent}];
++( *m_histos ).m_TAE_all[{TAE_index, nclPerEvent}];
}
if ( ( event_type & static_cast<std::uint16_t>( 1 << 9 ) ) ||
( event_type & static_cast<std::uint16_t>( 1 << 13 ) ) ) {
++( *m_histos ).m_fakeTAE[{TAE_index, nclPerEvent}];
++( *m_histos ).m_fakeTAE_lead[{TAE_index, nclPerEvent}];
++( *m_histos ).m_fakeTAE_lead_trail[{TAE_index, nclPerEvent}];
++( *m_histos ).m_TAE_all[{TAE_index, nclPerEvent}];
}
if ( ( event_type & static_cast<std::uint16_t>( 1 << 10 ) ) ||
( event_type & static_cast<std::uint16_t>( 1 << 14 ) ) ) {
++( *m_histos ).m_fakeTAE[{TAE_index, nclPerEvent}];
++( *m_histos ).m_fakeTAE_trail[{TAE_index, nclPerEvent}];
++( *m_histos ).m_fakeTAE_lead_trail[{TAE_index, nclPerEvent}];
++( *m_histos ).m_TAE_all[{TAE_index, nclPerEvent}];
}
}
}
} // operator()
Loading