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
4 files
+ 225
379
Compare changes
  • Side-by-side
  • Inline
Files
4
+ 0
257
/*****************************************************************************\
* (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/VPFullCluster.h"
#include "Kernel/VPConstants.h"
#include "VPDet/DeVP.h"
#include "DetDesc/GenericConditionAccessorHolder.h"
#include "VPDet/DeVPSensor.h"
#include "GaudiAlg/GaudiHistoAlg.h"
#include "GaudiUtils/Aida2ROOT.h"
#include "LHCbAlgs/Consumer.h"
#include <AIDA/IHistogram1D.h>
#include <AIDA/IHistogram2D.h>
#include <string>
#include <vector>
namespace {
constexpr auto NAsics = VP::NSensorsPerModule * VP::NChipsPerSensor;
// Transform sensor number to range [0,3] for plotting purposes
constexpr uint get_sensorNr( uint sensor ) { return sensor % VP::NSensorsPerModule; }
// Get asic in range [0, 623]
constexpr uint get_asic( uint sensor, uint chipNr ) { return 3 * sensor + chipNr; }
// Transform ASIC number to range [0,11] for plotting purposes
constexpr uint get_asicNr( uint sensorNr, uint chipNr ) { return 3 * sensorNr + chipNr; }
// Sensors from DeVP
class zSensors {
public:
// Constructor
zSensors( const DeVP& det ) {
auto totSensors = det.numberSensors();
m_z.reserve( totSensors );
for ( uint sensorNum = 0; sensorNum != totSensors; ++sensorNum ) {
auto& DetSensor = det.sensor( LHCb::Detector::VPChannelID::SensorID( sensorNum ) );
m_z.push_back( DetSensor.z() );
} // will have to sort vector if sensor numbers not in ascending
}
// useless and unused, but nevertheless needed by stupid DD4hep
zSensors() = default;
// Get z-coordinate of sensor
double z( uint nr ) const { return m_z.at( nr ); }
private:
std::vector<double> m_z{};
}; // class zSensors
} // anonymous namespace
using namespace Gaudi::Utils; // Aida2ROOT::aida2root
namespace LHCb {
/**
* * Class for plotting:
* - Number of VP clusters
* - VP cluster size
*
* * How to use:
* from Configurables import VPClusFull, VPClusterMonitors
* gaudi_seqeuence = GaudiSequencer("VPClusterMonitorsSequencer")
* gaudi_seqeuence.Members += [VPClusFull(), VPClusterMonitors()]
*
* * Notes:
* - No. of clusters per superpixel per ASIC currently plotted stacking all modules rather than
* individually for all 624 ASICs
*
* @author T.H.McGrath
* @date 2020-01-30
*/
class VPClusterMonitors : public Algorithm::Consumer<void( const std::vector<VPFullCluster>&, const zSensors& ),
DetDesc::usesBaseAndConditions<GaudiHistoAlg, zSensors>> {
public:
// Constructor
VPClusterMonitors( const std::string& name, ISvcLocator* pSvcLocator );
// Initialize
StatusCode initialize() override;
// Functional operator
void operator()( const std::vector<VPFullCluster>&, const zSensors& ) const override;
private:
// Histogram objects
AIDA::IHistogram1D* m_ncl = nullptr; // Number of clusters per event i.e. size of the vpClusters vector per event
AIDA::IHistogram1D* m_mnr = nullptr; // Number of clusters per module
AIDA::IHistogram1D* m_mz = nullptr; // Number of clusters per z-location of module
AIDA::IHistogram1D* m_ch = nullptr; // Number of clusters per chip
AIDA::IHistogram1D* m_se = nullptr; // Number of clusters per sensor
AIDA::IHistogram1D* m_senr = nullptr; // Number of clusters per sensor number
AIDA::IHistogram1D* m_as = nullptr; // Number of clusters per ASIC
AIDA::IHistogram1D* m_asnr = nullptr; // Number of clusters per ASIC number
// std::vector<AIDA::IHistogram2D*> m_ao; // Number of clusters per 8x8 pixels on ASIC
std::vector<AIDA::IHistogram2D*> m_sp; // Number of clusters per superpixel on ASIC
AIDA::IHistogram1D* m_pcl = nullptr; // Number of pixels per cluster (cluster size)
AIDA::IHistogram2D* m_pmnr = nullptr; // Number of cluster sizes per module
AIDA::IHistogram2D* m_pmz = nullptr; // Number of cluster sizes per z-location of module
AIDA::IHistogram2D* m_pse = nullptr; // Number of cluster sizes per sensor
AIDA::IHistogram2D* m_psenr = nullptr; // Number of cluster sizes per sensor number
AIDA::IHistogram2D* m_pas = nullptr; // Number of cluster sizes per ASIC
AIDA::IHistogram2D* m_pasnr = nullptr; // Number of cluster sizes per ASIC number
}; // class VPClusterMonitors
// Declaration of the Algorithm Factory
DECLARE_COMPONENT_WITH_ID( VPClusterMonitors, "VPClusterMonitors" )
} // namespace LHCb
LHCb::VPClusterMonitors::VPClusterMonitors( const std::string& name, ISvcLocator* pSvcLocator )
: Consumer( name, pSvcLocator,
{KeyValue{"ClusterLocation", VPFullClusterLocation::Default},
KeyValue{"zSensorLocation", "VPClusterMonitor-" + name + "-Sensors"}} ) {}
StatusCode LHCb::VPClusterMonitors::initialize() {
return Consumer::initialize().andThen( [&] {
// Register derived condition for DeVP
addConditionDerivation<zSensors( DeVP const& )>( {DeVPLocation::Default}, inputLocation<zSensors>() );
// Histogram booking base
auto bookHisto = [this]( std::string name, std::string title, uint nBins, double min, double max ) {
AIDA::IHistogram1D* h = book1D( name, title, min, max, nBins );
declareInfo( name, h, title );
return h;
};
auto bookHisto2D = [this]( std::string name, std::string title, uint nBinsX, double minX, double maxX, uint nBinsY,
double minY, double maxY ) {
AIDA::IHistogram2D* h2 = book2D( name, title, minX, maxX, nBinsX, minY, maxY, nBinsY );
declareInfo( name, h2, title );
return h2;
};
m_ncl = bookHisto( "VPClustersPerEvent",
"Frequency of # of VP clusters per event (Frequency vs Clusters); Clusters/event; ", 100, 0.,
10000. );
m_mnr = bookHisto( "VPClustersPerModule", "VP clusters per module (Clusters vs Module); Module; Clusters",
VP::NModules, -0.5, VP::NModules - 0.5 );
m_mz = bookHisto( "VPClustersPerZ", "VP clusters per z-coordinate of sensor (Clusters vs z (mm)); z (mm); Clusters",
105, -294, 756 );
m_ch = bookHisto( "VPClustersPerChip", "VP clusters per chip # (Clusters vs Chip #); Chip Number; Clusters",
VP::NChipsPerSensor + 2, -1.5, VP::NChipsPerSensor + 0.5 );
m_se = bookHisto( "VPClustersPerSensor", "VP clusters per sensor (Clusters vs Sensor); Sensor; Clusters",
VP::NSensors, -0.5, VP::NSensors - 0.5 );
m_senr =
bookHisto( "VPClustersPerSensorNr", "VP clusters per sensor # (Clusters vs Sensor #); Sensor Number; Clusters",
VP::NSensorsPerModule + 2, -1.5, VP::NSensorsPerModule + 0.5 );
m_as = bookHisto( "VPClustersPerASIC", "VP clusters per ASIC (Clusters vs ASIC); ASIC; Clusters",
NAsics * VP::NModules, 0, NAsics * VP::NModules );
m_asnr = bookHisto( "VPClustersPerASICNr", "VP clusters per ASIC # (Clusters vs ASIC #); ASIC Number; Clusters",
NAsics, 0, NAsics );
m_pcl = bookHisto( "VPClusterSize", "Number of pixels per VP cluster (Frequency vs Cluster Size); Cluster Size; ",
50, 0, 50 );
m_pmnr = bookHisto2D( "VPClusterSizeVSModule",
"Number of pixels per VP cluster per module (Cluster Size vs Module); Module; Cluster Size",
VP::NModules, -0.5, VP::NModules - 0.5, 10, 0.5, 10.5 );
m_pmz = bookHisto2D(
"VPClusterSizeVSZ",
"Number of pixels per VP cluster per z-coordinate of sensor (Cluster Size vs z (mm)); z (mm); Cluster Size",
105, -294, 756, 10, 0.5, 10.5 );
m_pse = bookHisto2D( "VPClusterSizeVSSensor",
"Number of pixels per VP cluster per sensor (Cluster Size vs Sensor); Sensor; Cluster Size",
VP::NSensors, -0.5, VP::NSensors - 0.5, 10, 0.5, 10.5 );
m_psenr = bookHisto2D(
"VPClusterSizeVSSensorNr",
"Number of pixels per VP cluster per sensor # (Cluster Size vs Sensor #); Sensor Number; Cluster Size",
VP::NSensorsPerModule + 2, -1.5, VP::NSensorsPerModule + 0.5, 10, 0.5, 10.5 );
m_pas = bookHisto2D( "VPClusterSizeVSASIC",
"Number of pixels per VP cluster per ASIC (Cluster Size vs ASIC); ASIC; Cluster Size",
NAsics * VP::NModules, 0, NAsics * VP::NModules, 10, 0.5, 10.5 );
m_pasnr =
bookHisto2D( "VPClusterSizeVSASICNr",
"Number of pixels per VP cluster per ASIC # (Cluster Size vs ASIC #); ASIC Number; Cluster Size",
NAsics, 0, NAsics, 10, 0.5, 10.5 );
// Book vector of histograms for ASICs
m_sp.resize( NAsics, nullptr );
for ( uint asicNr = 0; asicNr < NAsics; ++asicNr ) {
// Numbering of VP
uint sensorNr = asicNr / 3;
uint nr = asicNr % 3;
// Clusters per superpixel per ASIC superposed for all modules
m_sp[asicNr] = bookHisto2D( "VPClustersPerSuperPixelOnASIC" + std::to_string( asicNr ),
"VP cluster position per Super Pixel on VP" + std::to_string( sensorNr ) +
std::to_string( nr ) + " for all Modules (Row vs Column); SP Column; SP Row",
128, 0, VP::NColumns / 2, 64, 0, VP::NColumns / 4 );
}
return StatusCode::SUCCESS;
} );
}
void LHCb::VPClusterMonitors::operator()( const std::vector<LHCb::VPFullCluster>& vpClusters,
const zSensors& zSensors ) const {
// Fill total number of clusters
m_ncl->fill( vpClusters.size() ); // size of flat_map
// Loop over clusters vector
for ( const auto& vpCluster : vpClusters ) {
// Get VP Channel IDs of pixels in cluster
const Detector::VPChannelID vpID = vpCluster.channelID();
const auto vpIDs = vpCluster.pixels();
// Get cluster size
uint nPixels = vpIDs.size();
// Get cluster locations
const auto mod = vpID.module();
const auto chipNr = to_unsigned( vpID.chip() );
const auto sen = to_unsigned( vpID.sensor() );
const auto senNr = get_sensorNr( sen );
const auto asic = get_asic( sen, chipNr );
const auto asicNr = get_asicNr( senNr, chipNr );
// Fill objects
m_mnr->fill( mod );
m_mz->fill( zSensors.z( sen ) );
m_ch->fill( chipNr );
m_se->fill( sen );
m_senr->fill( senNr );
m_as->fill( asic );
m_asnr->fill( asicNr );
// Fill 2D ASIC in bins of superpixel for all Modules
m_sp[asicNr]->fill( to_unsigned( vpID.col() ) / 2, to_unsigned( vpID.row() ) / 4 );
// Fill cluster size histograms
m_pcl->fill( nPixels );
m_pmnr->fill( mod, nPixels );
m_pmz->fill( zSensors.z( sen ), nPixels );
m_pse->fill( sen, nPixels );
m_psenr->fill( senNr, nPixels );
m_pas->fill( asic, nPixels );
m_pasnr->fill( asicNr, nPixels );
} // Loop over clusters per event
}
Loading