Newer
Older
TB_Chris / TbAnalysis / src / .svn / text-base / TbChargeCalib.cpp.svn-base
  1. // Gaudi
  2. #include "GaudiKernel/PhysicalConstants.h"
  3. #include "GaudiUtils/HistoLabels.h"
  4.  
  5. // Tb/TbEvent
  6. #include "Event/TbTrack.h"
  7. #include "Event/TbCluster.h"
  8.  
  9. // Tb/TbKernel
  10. #include "TbKernel/TbConstants.h"
  11. #include "TbKernel/TbModule.h"
  12.  
  13. // Local
  14. #include "TbChargeCalib.h"
  15.  
  16. using namespace Gaudi::Utils::Histos;
  17.  
  18. DECLARE_ALGORITHM_FACTORY(TbChargeCalib)
  19.  
  20. //=============================================================================
  21. // Standard constructor
  22. //=============================================================================
  23. TbChargeCalib::TbChargeCalib(const std::string& name,
  24. ISvcLocator* pSvcLocator)
  25. : TbAlgorithm(name, pSvcLocator) {
  26.  
  27. declareProperty("ClusterLocation",
  28. m_clusterLocation = LHCb::TbClusterLocation::Default);
  29.  
  30. }
  31.  
  32. //=============================================================================
  33. // Initialization
  34. //=============================================================================
  35. StatusCode TbChargeCalib::initialize() {
  36.  
  37. // Initialise the base class.
  38. StatusCode sc = TbAlgorithm::initialize();
  39. if (sc.isFailure()) return sc;
  40. info() << "Booking histograms for Chargecalib ... " << endmsg;
  41. m_ToTHists.reserve(256*256);
  42. for( unsigned int i = 0 ; i < 256*256; ++i){
  43. const std::string name = "c=" + std::to_string( i/256 ) + ", r=" + std::to_string(i%256);
  44. if( i % 256 == 0 ) info() << "Booked histogram for column " << i << endmsg;
  45. m_ToTHists.push_back(book1D(name, name, 0.5, 200.5, 200));
  46. setAxisLabels(m_ToTHists[i], "ToT", "Entries");
  47. }
  48. info() << "Booked 60000 ish hists" << endmsg;
  49. return StatusCode::SUCCESS;
  50. }
  51.  
  52. //=============================================================================
  53. // Main execution
  54. //=============================================================================
  55. StatusCode TbChargeCalib::execute() {
  56.  
  57. LHCb::TbClusters* clusters = getIfExists<LHCb::TbClusters>(m_clusterLocation+std::to_string(0));
  58. if (!clusters) {
  59. error() << "No clusters in " << m_clusterLocation << endmsg;
  60. return StatusCode::FAILURE;
  61. }
  62. for( const LHCb::TbCluster* c : *clusters ){
  63. if( c->size() != 1 ) continue;
  64. unsigned int col = c->hits()[0]->col();
  65. unsigned int row = c->hits()[0]->row();
  66. unsigned int tot = c->hits()[0]->ToT();
  67. //info() << c->hits()[0] << endmsg;
  68. m_ToTHists[ col*256 + row ]->fill( tot );
  69.  
  70. }
  71. return StatusCode::SUCCESS;
  72. }
  73.