Geant4  10.00.p01
CexmcTrackPointsDigitizer.cc
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 /*
27  * ============================================================================
28  *
29  * Filename: CexmcTrackPointsDigitizer.cc
30  *
31  * Description: track points collector
32  *
33  * Version: 1.0
34  * Created: 24.11.2009 16:34:43
35  * Revision: none
36  * Compiler: gcc
37  *
38  * Author: Alexey Radkov (),
39  * Company: PNPI
40  *
41  * ============================================================================
42  */
43 
44 #include <G4DigiManager.hh>
45 #include <G4RunManager.hh>
46 #include <G4String.hh>
48 #include "CexmcTrackPoints.hh"
52 #include "CexmcCommon.hh"
53 
54 
56  G4VDigitizerModule( name ), hasTriggered( false )
57 {
58  G4RunManager * runManager( G4RunManager::GetRunManager() );
59  const CexmcSetup * setup( static_cast< const CexmcSetup * >(
60  runManager->GetUserDetectorConstruction() ) );
62 }
63 
64 
66 {
79  hasTriggered = false;
80 }
81 
82 
84 {
86 
87  G4int nCrystalsInColumn( calorimeterGeometry.nCrystalsInColumn );
88  G4int nCrystalsInRow( calorimeterGeometry.nCrystalsInRow );
91 
92  G4DigiManager * digiManager( G4DigiManager::GetDMpointer() );
93  G4int hcId( digiManager->GetHitsCollectionID(
97  hitsCollection( static_cast< const CexmcTrackPointsCollection * >(
98  digiManager->GetHitsCollection( hcId ) ) );
99 
100  if ( hitsCollection )
101  {
102  for ( CexmcTrackPointsCollectionData::iterator
103  k( hitsCollection->GetMap()->begin() );
104  k != hitsCollection->GetMap()->end(); ++k )
105  {
106  monitorTP = *k->second;
107  break;
108  }
109  }
110 
111  hcId = digiManager->GetHitsCollectionID(
113  "/" + CexmcDetectorTypeName[ CexmcTPDetector ] );
114  hitsCollection = static_cast< const CexmcTrackPointsCollection * >(
115  digiManager->GetHitsCollection( hcId ) );
116 
117  if ( hitsCollection )
118  {
119  for ( CexmcTrackPointsCollectionData::iterator
120  k( hitsCollection->GetMap()->begin() );
121  k != hitsCollection->GetMap()->end(); ++k )
122  {
123  do
124  {
125  if ( k->second->trackType == CexmcBeamParticleTrack )
126  {
127  targetTPBeamParticle = *k->second;
128  break;
129  }
130  if ( k->second->trackType == CexmcOutputParticleTrack )
131  {
132  targetTPOutputParticle = *k->second;
134  break;
135  }
136  if ( k->second->trackType == CexmcNucleusParticleTrack )
137  {
138  targetTPNucleusParticle = *k->second;
139  break;
140  }
141  if ( k->second->trackType ==
143  {
144  /* NB: if there are more than 2 output particle's decay
145  * products then the chosen particles may differ from those
146  * which entered calorimeters; however this is not a
147  * critical issue as far as information about decay products
148  * is not necessary in reconstruction and only used in some
149  * histograming */
150  G4int index(
152  trackId > 0 ? 1 : 0 );
154  *k->second;
155  break;
156  }
157  } while ( false );
158  }
159  }
160 
161  hcId = digiManager->GetHitsCollectionID(
163  "/" + CexmcDetectorTypeName[ CexmcTPDetector ] );
164  hitsCollection = static_cast< const CexmcTrackPointsCollection * >(
165  digiManager->GetHitsCollection( hcId ) );
166 
167  if ( hitsCollection )
168  {
169  for ( CexmcTrackPointsCollectionData::iterator
170  k( hitsCollection->GetMap()->begin() );
171  k != hitsCollection->GetMap()->end(); ++k )
172  {
173  if ( k->second->trackType != CexmcOutputParticleDecayProductTrack )
174  continue;
175 
176  G4int index( k->first );
178  index ) );
179  switch ( side )
180  {
181  case CexmcLeft :
182  vetoCounterTPLeft = *k->second;
183  break;
184  case CexmcRight :
185  vetoCounterTPRight = *k->second;
186  break;
187  default :
188  break;
189  }
190  }
191  }
192 
193  hcId = digiManager->GetHitsCollectionID(
195  "/" + CexmcDetectorTypeName[ CexmcTPDetector ] );
196  hitsCollection = static_cast< const CexmcTrackPointsCollection * >(
197  digiManager->GetHitsCollection( hcId ) );
198 
199  if ( hitsCollection )
200  {
201  for ( CexmcTrackPointsCollectionData::iterator
202  k( hitsCollection->GetMap()->begin() );
203  k != hitsCollection->GetMap()->end(); ++k )
204  {
205  if ( k->second->trackType != CexmcOutputParticleDecayProductTrack )
206  continue;
207 
208  G4int index( k->first );
210  index ) );
213  index ) );
214  G4double xInCalorimeterOffset(
215  ( G4double( column ) - G4double( nCrystalsInRow ) / 2 ) *
216  crystalWidth + crystalWidth / 2 );
217  G4double yInCalorimeterOffset(
218  ( G4double( row ) - G4double( nCrystalsInColumn ) / 2 ) *
219  crystalHeight + crystalHeight / 2 );
220  switch ( side )
221  {
222  case CexmcLeft :
223  calorimeterTPLeft = *k->second;
224  calorimeterTPLeft.positionLocal.setX( xInCalorimeterOffset +
226  calorimeterTPLeft.positionLocal.setY( yInCalorimeterOffset +
228  break;
229  case CexmcRight :
230  calorimeterTPRight = *k->second;
231  calorimeterTPRight.positionLocal.setX( xInCalorimeterOffset +
233  calorimeterTPRight.positionLocal.setY( yInCalorimeterOffset +
235  break;
236  default :
237  break;
238  }
239  }
240  }
241 }
242 
CexmcTrackPointsDigitizer(const G4String &name)
const G4VUserDetectorConstruction * GetUserDetectorConstruction() const
G4String name
Definition: TRTMaterials.hh:40
const G4int CexmcInvalidTrackId(-1)
const G4String CexmcDetectorTypeName[CexmcNumberOfDetectorTypes]
static G4DigiManager * GetDMpointer()
CexmcTrackPointInfo targetTPNucleusParticle
const G4VHitsCollection * GetHitsCollection(G4int HCID, G4int eventID=0)
int G4int
Definition: G4Types.hh:78
CexmcSetup::CalorimeterGeometryData calorimeterGeometry
G4int GetHitsCollectionID(G4String HCname)
const G4String CexmcDetectorRoleName[CexmcNumberOfDetectorRoles]
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:74
CexmcSide
Definition: CexmcCommon.hh:132
CexmcTrackPointInfo targetTPOutputParticle
const CalorimeterGeometryData & GetCalorimeterGeometry(void) const
Definition: CexmcSetup.hh:182
G4bool IsValid(void) const
double G4double
Definition: G4Types.hh:76
CexmcTrackPointInfo targetTPBeamParticle
CexmcTrackPointInfo targetTPOutputParticleDecayProductParticle[2]