ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4PSNofSecondary.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4PSNofSecondary.cc
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 // G4PSNofSecondary
29 #include "G4PSNofSecondary.hh"
30 
31 // (Description)
32 // This is a primitive scorer class for scoring number of secondaries
33 // in the Cell.
34 //
35 // Created: 2005-11-14 Tsukasa ASO, Akinori Kimura.
36 // Modify: 2011-09-09 T.Aso modify comment in PrintAll().
37 //
38 
40  :G4VPrimitiveScorer(name,depth),HCID(-1),EvtMap(0),particleDef(0),
41  weighted(true)
42 {;}
43 
45 {;}
46 
48 {
49  //- check for newly produced particle. e.g. first step.
50  if ( aStep->GetTrack()->GetCurrentStepNumber() != 1) return FALSE;
51  //- check for this is not a primary particle. e.g. ParentID > 0 .
52  if ( aStep->GetTrack()->GetParentID() == 0 ) return FALSE;
53  //- check the particle if the partifle definition is given.
54  if ( particleDef && particleDef != aStep->GetTrack()->GetDefinition() )
55  return FALSE;
56  //
57  //- This is a newly produced secondary particle.
58  G4int index = GetIndex(aStep);
59  G4double weight = 1.0;
60  if ( weighted ) weight *= aStep->GetPreStepPoint()->GetWeight();
61  EvtMap->add(index,weight);
62  return TRUE;
63 }
64 
65 void G4PSNofSecondary::SetParticle(const G4String& particleName){
68  if(!pd) {
69  G4String msg = "Particle <";
70  msg += particleName;
71  msg += "> not found.";
72  G4Exception("G4PSNofSecondary::SetParticle",
73  "DetPS0101",FatalException,msg);
74  }
75  particleDef = pd;
76 }
77 
79 {
81  if(HCID < 0) {HCID = GetCollectionID(0);}
83 }
84 
86 {;}
87 
89  EvtMap->clear();
90 }
91 
93 {;}
94 
96 {
97  G4cout << " PrimitiveScorer " << GetName() << G4endl;
98  G4cout << " Number of entries " << EvtMap->entries() << G4endl;
99  std::map<G4int,G4double*>::iterator itr = EvtMap->GetMap()->begin();
100  for(; itr != EvtMap->GetMap()->end(); itr++) {
101  G4cout << " copy no.: " << itr->first
102  << " num of secondaries: " << *(itr->second)/GetUnitValue()
103  << G4endl;
104  }
105 }
106 
108 {
109  if (unit == "" ){
110  unitName = unit;
111  unitValue = 1.0;
112  }else{
113  G4String msg = "Invalid unit ["+unit+"] (Current unit is [" +GetUnit()+"] ) for " + GetName();
114  G4Exception("G4PSNofSecondary::SetUnit","DetPS0010",JustWarning,msg);
115  }
116 }
117