diff --git a/Simulation/G4Atlas/G4AtlasTests/src/ALFA_SimHitsTestTool.cxx b/Simulation/G4Atlas/G4AtlasTests/src/ALFA_SimHitsTestTool.cxx index e1484516b96a56115b0d2c4109226c64442f6d9f..af30c8790d40cab073d8d5671b09e75cbf35664e 100644 --- a/Simulation/G4Atlas/G4AtlasTests/src/ALFA_SimHitsTestTool.cxx +++ b/Simulation/G4Atlas/G4AtlasTests/src/ALFA_SimHitsTestTool.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ #include "ALFA_SimHitsTestTool.h" @@ -19,113 +19,105 @@ ALFA_SimHitsTestTool::ALFA_SimHitsTestTool(const std::string& type, const std::string& name, const IInterface* parent) : SimTestToolBase(type, name, parent) -{ - for (int i(0); i<8; ++i) - { - m_E_full_sum_h[i]=0; - m_E_layer_sum_h[i]=0; - m_hit_map_h[i]=0; - } - +{ + for (int i(0); i<8; ++i) { + m_E_full_sum_h[i]=nullptr; + m_E_layer_sum_h[i]=nullptr; + m_hit_map_h[i]=nullptr; + } } StatusCode ALFA_SimHitsTestTool::initialize() { m_path+="ALFA/"; + _TH1D(m_E_gvs,"edep_full_in_gvs", 8, -0.5, 7.5); + _SET_TITLE(m_E_gvs, "Energy deposit in GVS","Station","E (MeV)"); + std::stringstream s; - - for (unsigned int j=0; j<8; j++) - { - s.str(""); - s << j+1; - - _TH1D(m_E_full_sum_h[j],("edep_full_in_det_no."+s.str()).c_str(), 100, 0., 5.); - _SET_TITLE(m_E_full_sum_h[j], "Energy deposit in full detector","E (MeV)","N"); - - _TH2D(m_E_layer_sum_h[j],("edep_per_layer_detector_no."+s.str()).c_str(), 100, 0., 0.5, 22, 0., 21.); - _SET_TITLE(m_E_layer_sum_h[j], "Energy deposit in layers","E (MeV)","layer"); - - _TH2D(m_hit_map_h[j],("hitmap_det_no."+s.str()).c_str(), 22, 0., 21., 66, 0., 65.); - _SET_TITLE(m_hit_map_h[j], "hit map - layer vs fiber","layer","fiber"); - + for (unsigned int j=0; j<8; j++) { + s.str(""); + s << j+1; + + _TH1D(m_E_full_sum_h[j],("edep_full_in_det_no."+s.str()).c_str(), 100, 0., 5.); + _SET_TITLE(m_E_full_sum_h[j], "Energy deposit in full detector","E (MeV)","N"); + + _TH2D(m_E_layer_sum_h[j],("edep_per_layer_detector_no."+s.str()).c_str(), 100, 0., 0.5, 22, 0., 21.); + _SET_TITLE(m_E_layer_sum_h[j], "Energy deposit in layers","E (MeV)","layer"); + + _TH2D(m_hit_map_h[j],("hitmap_det_no."+s.str()).c_str(), 22, 0., 21., 66, 0., 65.); + _SET_TITLE(m_hit_map_h[j], "hit map - layer vs fiber","layer","fiber"); } return StatusCode::SUCCESS; } StatusCode ALFA_SimHitsTestTool::processEvent() { - - int fiber, plate, sign, station; - - double E_fiber_sum[8][10][64][2], E_full_sum[8], E_layer_sum[8][20]; - - // cleaning - - for ( int l = 0; l < 8; l++ ) - { - E_full_sum[l] = 0.; - - for ( int i = 0; i < 10; i++ ) - { - E_layer_sum[l][i] = 0.; - E_layer_sum[l][i+10] = 0.; - - for ( int j = 0; j < 64; j++ ) - { - for ( int k = 0; k < 2; k++ ) - { - E_fiber_sum[l][i][j][k] = 0.; - } - } - } - } - - - ALFA_HitConstIter iter; - const DataHandle<ALFA_HitCollection> coll_handle; - CHECK( evtStore()->retrieve(coll_handle,"ALFA_HitCollection") ); - - - for (iter=(*coll_handle).begin(); iter != (*coll_handle).end(); ++iter) { - - station = (*iter).GetStationNumber(); - plate = (*iter).GetPlateNumber(); - fiber = (*iter).GetFiberNumber(); - sign = (*iter).GetSignFiber(); - - E_fiber_sum[station-1][plate-1][fiber-1][(1-sign)/2] += ((*iter).GetEnergyDeposit()); - } - - for ( int l = 0; l < 8; l++ ) - { - for ( int i = 0; i < 10; i++ ) - { - for ( int j = 0; j < 64; j++ ) - { - for ( int k = 0; k < 2; k++ ) - { - - E_full_sum[l] += E_fiber_sum[l][i][j][k]; - E_layer_sum[l][2*i+k] += E_fiber_sum[l][i][j][k]; - - if (E_fiber_sum[l][i][j][k] > 0.) m_hit_map_h[l]->Fill(2*i+k+1,j+1); - - } - } - } - } - - for ( int l = 0; l < 8; l++ ) - { - m_E_full_sum_h[l]->Fill(E_full_sum[l]); - - for ( int i = 0; i < 20; i++ ) - { - m_E_layer_sum_h[l]->Fill(E_layer_sum[l][i],i+1); - } - } + int fiber, plate, sign, station; + + double E_fiber_sum[8][10][64][2]; + double E_full_sum[8]; + double E_layer_sum[8][20]; + + // cleaning + const int station_max{8}; + const int plate_max{10}; + const int fiber_max{64}; + + for ( int l = 0; l < station_max; l++ ) { + E_full_sum[l] = 0.; + for ( int i = 0; i < plate_max; i++ ) { + E_layer_sum[l][i] = 0.; + E_layer_sum[l][i+plate_max] = 0.; + for ( int j = 0; j < fiber_max; j++ ) { + for ( int k = 0; k < 2; k++ ) { + E_fiber_sum[l][i][j][k] = 0.; + } + } + } + } + + + ALFA_HitConstIter iter; + const DataHandle<ALFA_HitCollection> coll_handle; + CHECK( evtStore()->retrieve(coll_handle,"ALFA_HitCollection") ); + + + for (iter=(*coll_handle).begin(); iter != (*coll_handle).end(); ++iter) { + + station = (*iter).GetStationNumber(); + plate = (*iter).GetPlateNumber(); + fiber = (*iter).GetFiberNumber(); + sign = (*iter).GetSignFiber(); + if (plate==100) { + // Treat hits in GVS separately. + m_E_gvs->Fill(station,((*iter).GetEnergyDeposit())); + continue; + } + E_fiber_sum[station-1][plate-1][fiber-1][(1-sign)/2] += ((*iter).GetEnergyDeposit()); + } + + for ( int l = 0; l < station_max; l++ ) { + for ( int i = 0; i < plate_max; i++ ){ + for ( int j = 0; j < fiber_max; j++ ) { + for ( int k = 0; k < 2; k++ ) { + E_full_sum[l] += E_fiber_sum[l][i][j][k]; + E_layer_sum[l][2*i+k] += E_fiber_sum[l][i][j][k]; + if (E_fiber_sum[l][i][j][k] > 0.) { + m_hit_map_h[l]->Fill(2*i+k+1,j+1); + } + } + } + } + } + + for ( int l = 0; l < station_max; l++ ) { + m_E_full_sum_h[l]->Fill(E_full_sum[l]); + for ( int i = 0; i < 2*plate_max; i++ ) { + m_E_layer_sum_h[l]->Fill(E_layer_sum[l][i],i+1); + } + } return StatusCode::SUCCESS; } diff --git a/Simulation/G4Atlas/G4AtlasTests/src/ALFA_SimHitsTestTool.h b/Simulation/G4Atlas/G4AtlasTests/src/ALFA_SimHitsTestTool.h index c8e6d76a7a0e02cbcc63727189ec872fa443d0ba..ff4fc72bf285d66a7efa7632986d094ba4fd860c 100644 --- a/Simulation/G4Atlas/G4AtlasTests/src/ALFA_SimHitsTestTool.h +++ b/Simulation/G4Atlas/G4AtlasTests/src/ALFA_SimHitsTestTool.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration */ #ifndef G4AT_ALFA_SIMHITSTESTTOOL @@ -21,10 +21,10 @@ class ALFA_SimHitsTestTool : public SimTestToolBase { // ALFA test histograms - TH2 *m_hit_map_h[8], *m_E_layer_sum_h[8]; + TH2 *m_hit_map_h[8]; + TH2 *m_E_layer_sum_h[8]; TH1 *m_E_full_sum_h[8]; - + TH1 *m_E_gvs{}; }; #endif -