Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-31 09:21:54

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 /*
0027  * ============================================================================
0028  *
0029  *       Filename:  CexmcTrackPointsDigitizer.cc
0030  *
0031  *    Description:  track points collector
0032  *
0033  *        Version:  1.0
0034  *        Created:  24.11.2009 16:34:43
0035  *       Revision:  none
0036  *       Compiler:  gcc
0037  *
0038  *         Author:  Alexey Radkov (), 
0039  *        Company:  PNPI
0040  *
0041  * ============================================================================
0042  */
0043 
0044 #include <G4DigiManager.hh>
0045 #include <G4RunManager.hh>
0046 #include <G4String.hh>
0047 #include "CexmcTrackPointsDigitizer.hh"
0048 #include "CexmcTrackPoints.hh"
0049 #include "CexmcTrackPointsInLeftRightSet.hh"
0050 #include "CexmcTrackPointsInCalorimeter.hh"
0051 #include "CexmcSensitiveDetectorsAttributes.hh"
0052 #include "CexmcCommon.hh"
0053 
0054 
0055 CexmcTrackPointsDigitizer::CexmcTrackPointsDigitizer( const G4String &  name ) :
0056     G4VDigitizerModule( name ), hasTriggered( false )
0057 {
0058     G4RunManager *      runManager( G4RunManager::GetRunManager() );
0059     const CexmcSetup *  setup( static_cast< const CexmcSetup * >(
0060                                 runManager->GetUserDetectorConstruction() ) );
0061     calorimeterGeometry = setup->GetCalorimeterGeometry();
0062 }
0063 
0064 
0065 void  CexmcTrackPointsDigitizer::InitializeData( void )
0066 {
0067     monitorTP.trackId = CexmcInvalidTrackId;
0068     targetTPBeamParticle.trackId = CexmcInvalidTrackId;
0069     targetTPOutputParticle.trackId = CexmcInvalidTrackId;
0070     targetTPNucleusParticle.trackId = CexmcInvalidTrackId;
0071     targetTPOutputParticleDecayProductParticle[ 0 ].trackId =
0072                                                         CexmcInvalidTrackId;
0073     targetTPOutputParticleDecayProductParticle[ 1 ].trackId =
0074                                                         CexmcInvalidTrackId;
0075     vetoCounterTPLeft.trackId = CexmcInvalidTrackId;
0076     vetoCounterTPRight.trackId = CexmcInvalidTrackId;
0077     calorimeterTPLeft.trackId = CexmcInvalidTrackId;
0078     calorimeterTPRight.trackId = CexmcInvalidTrackId;
0079     hasTriggered = false;
0080 }
0081 
0082 
0083 void  CexmcTrackPointsDigitizer::Digitize( void )
0084 {
0085     InitializeData();
0086 
0087     G4int     nCrystalsInColumn( calorimeterGeometry.nCrystalsInColumn );
0088     G4int     nCrystalsInRow( calorimeterGeometry.nCrystalsInRow );
0089     G4double  crystalWidth( calorimeterGeometry.crystalWidth );
0090     G4double  crystalHeight( calorimeterGeometry.crystalHeight );
0091 
0092     G4DigiManager *  digiManager( G4DigiManager::GetDMpointer() );
0093     G4int    hcId( digiManager->GetHitsCollectionID(
0094                     CexmcDetectorRoleName[ CexmcMonitorDetectorRole ] +
0095                     "/" + CexmcDetectorTypeName[ CexmcTPDetector ] ) );
0096     const CexmcTrackPointsCollection *
0097              hitsCollection( static_cast< const CexmcTrackPointsCollection * >(
0098                                     digiManager->GetHitsCollection( hcId ) ) );
0099 
0100     if ( hitsCollection )
0101     {
0102         for ( CexmcTrackPointsCollectionData::iterator
0103                   k( hitsCollection->GetMap()->begin() );
0104                       k != hitsCollection->GetMap()->end(); ++k )
0105         {
0106             monitorTP = *k->second;
0107             break;
0108         }
0109     }
0110 
0111     hcId = digiManager->GetHitsCollectionID(
0112                     CexmcDetectorRoleName[ CexmcTargetDetectorRole ] +
0113                     "/" + CexmcDetectorTypeName[ CexmcTPDetector ] );
0114     hitsCollection = static_cast< const CexmcTrackPointsCollection * >(
0115                                     digiManager->GetHitsCollection( hcId ) );
0116 
0117     if ( hitsCollection )
0118     {
0119         for ( CexmcTrackPointsCollectionData::iterator
0120                   k( hitsCollection->GetMap()->begin() );
0121                       k != hitsCollection->GetMap()->end(); ++k )
0122         {
0123             do
0124             {
0125                 if ( k->second->trackType == CexmcBeamParticleTrack )
0126                 {
0127                     targetTPBeamParticle = *k->second;
0128                     break;
0129                 }
0130                 if ( k->second->trackType == CexmcOutputParticleTrack )
0131                 {
0132                     targetTPOutputParticle = *k->second;
0133                     hasTriggered = targetTPOutputParticle.IsValid();
0134                     break;
0135                 }
0136                 if ( k->second->trackType == CexmcNucleusParticleTrack )
0137                 {
0138                     targetTPNucleusParticle = *k->second;
0139                     break;
0140                 }
0141                 if ( k->second->trackType ==
0142                                         CexmcOutputParticleDecayProductTrack )
0143                 {
0144                     /* NB: if there are more than 2 output particle's decay
0145                      * products then the chosen particles may differ from those
0146                      * which entered calorimeters; however this is not a
0147                      * critical issue as far as information about decay products
0148                      * is not necessary in reconstruction and only used in some
0149                      * histograming */
0150                     G4int  index(
0151                             targetTPOutputParticleDecayProductParticle[ 0 ].
0152                                                           trackId > 0 ? 1 : 0 );
0153                     targetTPOutputParticleDecayProductParticle[ index ] =
0154                             *k->second;
0155                     break;
0156                 }
0157             } while ( false );
0158         }
0159     }
0160 
0161     hcId = digiManager->GetHitsCollectionID(
0162                     CexmcDetectorRoleName[ CexmcVetoCounterDetectorRole ] +
0163                     "/" + CexmcDetectorTypeName[ CexmcTPDetector ] );
0164     hitsCollection = static_cast< const CexmcTrackPointsCollection * >(
0165                                     digiManager->GetHitsCollection( hcId ) );
0166 
0167     if ( hitsCollection )
0168     {
0169         for ( CexmcTrackPointsCollectionData::iterator
0170                   k( hitsCollection->GetMap()->begin() );
0171                       k != hitsCollection->GetMap()->end(); ++k )
0172         {
0173             if ( k->second->trackType != CexmcOutputParticleDecayProductTrack )
0174                 continue;
0175 
0176             G4int  index( k->first );
0177             CexmcSide  side( CexmcTrackPointsInLeftRightSet::GetSide(
0178                                                                    index ) );
0179             switch ( side )
0180             {
0181             case CexmcLeft :
0182                 vetoCounterTPLeft = *k->second;
0183                 break;
0184             case CexmcRight :
0185                 vetoCounterTPRight = *k->second;
0186                 break;
0187             default :
0188                 break;
0189             }
0190         }
0191     }
0192 
0193     hcId = digiManager->GetHitsCollectionID(
0194                     CexmcDetectorRoleName[ CexmcCalorimeterDetectorRole ] +
0195                     "/" + CexmcDetectorTypeName[ CexmcTPDetector ] );
0196     hitsCollection = static_cast< const CexmcTrackPointsCollection * >(
0197                                     digiManager->GetHitsCollection( hcId ) );
0198 
0199     if ( hitsCollection )
0200     {
0201         for ( CexmcTrackPointsCollectionData::iterator
0202                   k( hitsCollection->GetMap()->begin() );
0203                       k != hitsCollection->GetMap()->end(); ++k )
0204         {
0205             if ( k->second->trackType != CexmcOutputParticleDecayProductTrack )
0206                 continue;
0207 
0208             G4int  index( k->first );
0209             CexmcSide  side( CexmcTrackPointsInLeftRightSet::GetSide(
0210                                                                    index ) );
0211             G4int      row( CexmcTrackPointsInCalorimeter::GetRow( index ) );
0212             G4int      column( CexmcTrackPointsInCalorimeter::GetColumn(
0213                                                                    index ) );
0214             G4double   xInCalorimeterOffset(
0215                     ( G4double( column ) - G4double( nCrystalsInRow ) / 2 ) *
0216                                         crystalWidth + crystalWidth / 2 );
0217             G4double   yInCalorimeterOffset(
0218                     ( G4double( row ) - G4double( nCrystalsInColumn ) / 2 ) *
0219                                         crystalHeight + crystalHeight / 2 );
0220             switch ( side )
0221             {
0222             case CexmcLeft :
0223                 calorimeterTPLeft = *k->second;
0224                 calorimeterTPLeft.positionLocal.setX( xInCalorimeterOffset +
0225                                         calorimeterTPLeft.positionLocal.x() );
0226                 calorimeterTPLeft.positionLocal.setY( yInCalorimeterOffset +
0227                                         calorimeterTPLeft.positionLocal.y() );
0228                 break;
0229             case CexmcRight :
0230                 calorimeterTPRight = *k->second;
0231                 calorimeterTPRight.positionLocal.setX( xInCalorimeterOffset +
0232                                         calorimeterTPRight.positionLocal.x() );
0233                 calorimeterTPRight.positionLocal.setY( yInCalorimeterOffset +
0234                                         calorimeterTPRight.positionLocal.y() );
0235                 break;
0236             default :
0237                 break;
0238             }
0239         }
0240     }
0241 }
0242