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 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /examples/extended/parameterisations/Par04/src/Par04Hit.cc (Version 11.3.0) and /examples/extended/parameterisations/Par04/src/Par04Hit.cc (Version 11.2.1)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
 26 #include "Par04Hit.hh"                             26 #include "Par04Hit.hh"
 27                                                <<  27 #include <CLHEP/Units/SystemOfUnits.h>     // for mm, pi, MeV, cm, rad
 28 #include "G4AttDef.hh"  // for G4AttDef        <<  28 #include <CLHEP/Vector/ThreeVector.h>      // for operator/, operator<<, Hep...
 29 #include "G4AttDefStore.hh"  // for GetInstanc <<  29 #include <G4RotationMatrix.hh>             // for G4RotationMatrix
 30 #include "G4AttValue.hh"  // for G4AttValue    <<  30 #include <G4String.hh>                     // for G4String
 31 #include "G4Colour.hh"  // for G4Colour        <<  31 #include <G4ThreeVector.hh>                // for G4ThreeVector
 32 #include "G4SystemOfUnits.hh"  // for mm, MeV, <<  32 #include <G4Transform3D.hh>                // for G4Transform3D
 33 #include "G4Tubs.hh"  // for G4Tubs            <<  33 #include <G4VHit.hh>                       // for G4VHit
 34 #include "G4UnitsTable.hh"  // for G4BestUnit  <<  34 #include <algorithm>                       // for max
 35 #include "G4VVisManager.hh"  // for G4VVisMana <<  35 #include <iostream>                        // for operator<<, basic_ostream:...
 36 #include "G4VisAttributes.hh"  // for G4VisAtt <<  36 #include <string>                          // for operator<
 37                                                <<  37 #include "G4AttDef.hh"                     // for G4AttDef
 38 #include <CLHEP/Units/SystemOfUnits.h>  // for <<  38 #include "G4AttDefStore.hh"                // for GetInstance
 39 #include <CLHEP/Vector/ThreeVector.h>  // for  <<  39 #include "G4AttValue.hh"                   // for G4AttValue
 40 #include <G4RotationMatrix.hh>  // for G4Rotat <<  40 #include "G4Colour.hh"                     // for G4Colour
 41 #include <G4String.hh>  // for G4String        <<  41 #include "G4SystemOfUnits.hh"              // for mm, MeV, cm, rad
 42 #include <G4ThreeVector.hh>  // for G4ThreeVec <<  42 #include "G4Tubs.hh"                       // for G4Tubs
 43 #include <G4Transform3D.hh>  // for G4Transfor <<  43 #include "G4UnitsTable.hh"                 // for G4BestUnit
 44 #include <G4VHit.hh>  // for G4VHit            <<  44 #include "G4VVisManager.hh"                // for G4VVisManager
 45 #include <algorithm>  // for max               <<  45 #include "G4VisAttributes.hh"              // for G4VisAttributes
 46 #include <cmath>  // for log10                 <<  46 #include <cmath>                           // for log10
 47 #include <iostream>  // for operator<<, basic_ <<  47 template <class Type> class G4Allocator;
 48 #include <string>  // for operator<            << 
 49 template<class Type>                           << 
 50 class G4Allocator;                             << 
 51                                                    48 
 52 G4ThreadLocal G4Allocator<Par04Hit>* Par04HitA     49 G4ThreadLocal G4Allocator<Par04Hit>* Par04HitAllocator;
 53                                                    50 
 54 //....oooOO0OOooo........oooOO0OOooo........oo     51 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 55                                                    52 
 56 Par04Hit::Par04Hit() : G4VHit() {}             <<  53 Par04Hit::Par04Hit()
                                                   >>  54   : G4VHit()
                                                   >>  55 {}
 57                                                    56 
 58 //....oooOO0OOooo........oooOO0OOooo........oo     57 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 59                                                    58 
 60 Par04Hit::~Par04Hit() = default;                   59 Par04Hit::~Par04Hit() = default;
 61                                                    60 
 62 //....oooOO0OOooo........oooOO0OOooo........oo     61 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 63                                                    62 
 64 Par04Hit::Par04Hit(const Par04Hit& aRight) : G <<  63 Par04Hit::Par04Hit(const Par04Hit& aRight)
                                                   >>  64   : G4VHit()
 65 {                                                  65 {
 66   fEdep = aRight.fEdep;                        <<  66   fEdep   = aRight.fEdep;
 67   fNdep = aRight.fNdep;                        <<  67   fNdep   = aRight.fNdep;
 68   fZId = aRight.fZId;                          <<  68   fZId    = aRight.fZId;
 69   fRhoId = aRight.fRhoId;                      <<  69   fRhoId  = aRight.fRhoId;
 70   fPhiId = aRight.fPhiId;                      <<  70   fPhiId  = aRight.fPhiId;
 71   fTime = aRight.fTime;                        <<  71   fTime   = aRight.fTime;
 72   fPos = aRight.fPos;                          <<  72   fPos    = aRight.fPos;
 73   fRot = aRight.fRot;                          <<  73   fRot    = aRight.fRot;
 74   fType = aRight.fType;                        <<  74   fType   = aRight.fType;
 75   fLogVol = aRight.fLogVol;                        75   fLogVol = aRight.fLogVol;
 76 }                                                  76 }
 77                                                    77 
 78 //....oooOO0OOooo........oooOO0OOooo........oo     78 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 79                                                    79 
 80 const Par04Hit& Par04Hit::operator=(const Par0     80 const Par04Hit& Par04Hit::operator=(const Par04Hit& aRight)
 81 {                                                  81 {
 82   fEdep = aRight.fEdep;                        <<  82   fEdep   = aRight.fEdep;
 83   fNdep = aRight.fNdep;                        <<  83   fNdep   = aRight.fNdep;
 84   fZId = aRight.fZId;                          <<  84   fZId    = aRight.fZId;
 85   fRhoId = aRight.fRhoId;                      <<  85   fRhoId  = aRight.fRhoId;
 86   fPhiId = aRight.fPhiId;                      <<  86   fPhiId  = aRight.fPhiId;
 87   fTime = aRight.fTime;                        <<  87   fTime   = aRight.fTime;
 88   fPos = aRight.fPos;                          <<  88   fPos    = aRight.fPos;
 89   fRot = aRight.fRot;                          <<  89   fRot    = aRight.fRot;
 90   fType = aRight.fType;                        <<  90   fType   = aRight.fType;
 91   fLogVol = aRight.fLogVol;                        91   fLogVol = aRight.fLogVol;
 92   return *this;                                    92   return *this;
 93 }                                                  93 }
 94                                                    94 
 95 //....oooOO0OOooo........oooOO0OOooo........oo     95 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 96                                                    96 
 97 int Par04Hit::operator==(const Par04Hit& aRigh     97 int Par04Hit::operator==(const Par04Hit& aRight) const
 98 {                                                  98 {
 99   return (fRhoId == aRight.fRhoId && fPhiId ==     99   return (fRhoId == aRight.fRhoId && fPhiId == aRight.fPhiId && fZId == aRight.fZId);
100 }                                                 100 }
101                                                   101 
102 //....oooOO0OOooo........oooOO0OOooo........oo    102 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
103                                                   103 
104 void Par04Hit::Draw()                             104 void Par04Hit::Draw()
105 {                                                 105 {
106   /// Arbitrary size corresponds to the exampl    106   /// Arbitrary size corresponds to the example macros
107   G4ThreeVector meshSize(2.325 * mm, 2 * CLHEP    107   G4ThreeVector meshSize(2.325 * mm, 2 * CLHEP::pi / 50. * CLHEP::rad, 3.4 * mm);
108   G4int numPhiCells = CLHEP::pi * 2. / meshSiz << 108   G4int numPhiCells           = CLHEP::pi * 2. / meshSize.y();
109   G4VVisManager* pVVisManager = G4VVisManager:    109   G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance();
110   // Hits can be filtered out in visualisation    110   // Hits can be filtered out in visualisation
111   if (!pVVisManager->FilterHit(*this)) return; << 111   if(!pVVisManager->FilterHit(*this))
                                                   >> 112     return;
112   // Do not plot hits from parallel world         113   // Do not plot hits from parallel world
113   if (fType >= 2) return;                      << 114   if(fType >= 2)
                                                   >> 115     return;
114   // Do not draw empty hits                       116   // Do not draw empty hits
115   if (fEdep <= 0) return;                      << 117   if(fEdep <= 0)
                                                   >> 118     return;
116   // Do not plot if default values were not ch    119   // Do not plot if default values were not changed
117   if (fRhoId == -1 && fZId == -1 && fPhiId ==  << 120   if(fRhoId == -1 && fZId == -1 && fPhiId == -1)
118   if (pVVisManager) {                          << 121     return;
                                                   >> 122   if(pVVisManager)
                                                   >> 123   {
119     G4Transform3D trans(fRot, fPos);              124     G4Transform3D trans(fRot, fPos);
120     G4VisAttributes attribs;                      125     G4VisAttributes attribs;
121     G4Tubs solid("draw", fRhoId * meshSize.x()    126     G4Tubs solid("draw", fRhoId * meshSize.x(), (fRhoId + 1) * meshSize.x(), meshSize.z() / 2.,
122                  (-numPhiCells / 2. + fPhiId)     127                  (-numPhiCells / 2. + fPhiId) * meshSize.y(), meshSize.y());
123     // Set colours depending on type of hit (f    128     // Set colours depending on type of hit (full/fast sim)
124     G4double colR = fType == 0 ? 0 : 1;           129     G4double colR = fType == 0 ? 0 : 1;
125     G4double colG = fType == 0 ? 1 : 0;           130     G4double colG = fType == 0 ? 1 : 0;
126     G4double colB = 0;                            131     G4double colB = 0;
127     // Set transparency depending on the energ    132     // Set transparency depending on the energy
128     // Arbitrary formula                          133     // Arbitrary formula
129     G4double alpha = 2 * std::log10(fEdep + 1)    134     G4double alpha = 2 * std::log10(fEdep + 1);
130     G4Colour colour(colR, colG, colB, alpha);     135     G4Colour colour(colR, colG, colB, alpha);
131     attribs.SetColour(colour);                    136     attribs.SetColour(colour);
132     attribs.SetForceSolid(true);                  137     attribs.SetForceSolid(true);
133     pVVisManager->Draw(solid, attribs, trans);    138     pVVisManager->Draw(solid, attribs, trans);
134   }                                               139   }
135 }                                                 140 }
136                                                   141 
137 //....oooOO0OOooo........oooOO0OOooo........oo    142 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
138                                                   143 
139 const std::map<G4String, G4AttDef>* Par04Hit::    144 const std::map<G4String, G4AttDef>* Par04Hit::GetAttDefs() const
140 {                                                 145 {
141   G4bool isNew;                                   146   G4bool isNew;
142   std::map<G4String, G4AttDef>* store = G4AttD    147   std::map<G4String, G4AttDef>* store = G4AttDefStore::GetInstance("Par04Hit", isNew);
143   if (isNew) {                                 << 148   if(isNew)
                                                   >> 149   {
144     (*store)["HitType"] = G4AttDef("HitType",     150     (*store)["HitType"] = G4AttDef("HitType", "Hit Type", "Physics", "", "G4String");
145     (*store)["Energy"] =                          151     (*store)["Energy"] =
146       G4AttDef("Energy", "Energy Deposited", "    152       G4AttDef("Energy", "Energy Deposited", "Physics", "G4BestUnit", "G4double");
147     (*store)["Time"] = G4AttDef("Time", "Time"    153     (*store)["Time"] = G4AttDef("Time", "Time", "Physics", "G4BestUnit", "G4double");
148     (*store)["Pos"] = G4AttDef("Pos", "Positio << 154     (*store)["Pos"]  = G4AttDef("Pos", "Position", "Physics", "G4BestUnit", "G4ThreeVector");
149   }                                               155   }
150   return store;                                   156   return store;
151 }                                                 157 }
152                                                   158 
153 //....oooOO0OOooo........oooOO0OOooo........oo    159 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
154                                                   160 
155 std::vector<G4AttValue>* Par04Hit::CreateAttVa    161 std::vector<G4AttValue>* Par04Hit::CreateAttValues() const
156 {                                                 162 {
157   std::vector<G4AttValue>* values = new std::v    163   std::vector<G4AttValue>* values = new std::vector<G4AttValue>;
158   values->push_back(G4AttValue("HitType", "Had    164   values->push_back(G4AttValue("HitType", "HadPar04Hit", ""));
159   values->push_back(G4AttValue("Energy", G4Bes    165   values->push_back(G4AttValue("Energy", G4BestUnit(fEdep, "Energy"), ""));
160   values->push_back(G4AttValue("Time", G4BestU    166   values->push_back(G4AttValue("Time", G4BestUnit(fTime, "Time"), ""));
161   values->push_back(G4AttValue("Pos", G4BestUn    167   values->push_back(G4AttValue("Pos", G4BestUnit(fPos, "Length"), ""));
162   return values;                                  168   return values;
163 }                                                 169 }
164                                                   170 
165 //....oooOO0OOooo........oooOO0OOooo........oo    171 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
166                                                   172 
167 void Par04Hit::Print()                            173 void Par04Hit::Print()
168 {                                                 174 {
169   std::cout << "\tHit " << fEdep / MeV << " Me    175   std::cout << "\tHit " << fEdep / MeV << " MeV from " << fNdep << " deposits at " << fPos / cm
170             << " cm rotation " << fRot << " (R << 176             << " cm rotation " << fRot << " (R,phi,z)= (" << fRhoId << ", " << fPhiId
171             << fZId << "), " << fTime << " ns" << 177             << ", " << fZId << "), " << fTime << " ns" << std::endl;
172 }                                                 178 }
173                                                   179