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.4.p3 ] [ 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/exoticphysics/phonon/src/XAluminumElectrodeSensitivity.cc (Version 11.3.0) and /examples/extended/exoticphysics/phonon/src/XAluminumElectrodeSensitivity.cc (Version 10.0.p4)


  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 /// \file exoticphysics/phonon/src/XAluminumEl     26 /// \file exoticphysics/phonon/src/XAluminumElectrodeSensitivity.cc
 27 /// \brief Implementation of the XAluminumElec     27 /// \brief Implementation of the XAluminumElectrodeSensitivity class
 28 //                                                 28 //
                                                   >>  29 // $Id: XAluminumElectrodeSensitivity.cc 76246 2013-11-08 11:17:29Z gcosmo $
 29 //                                                 30 //
 30 #include "XAluminumElectrodeSensitivity.hh"        31 #include "XAluminumElectrodeSensitivity.hh"
 31                                                    32 
 32 #include "XAluminumElectrodeHit.hh"                33 #include "XAluminumElectrodeHit.hh"
 33                                                << 
 34 #include "G4AutoLock.hh"                       << 
 35 #include "G4HCofThisEvent.hh"                      34 #include "G4HCofThisEvent.hh"
 36 #include "G4Navigator.hh"                      << 
 37 #include "G4SDManager.hh"                      << 
 38 #include "G4Step.hh"                           << 
 39 #include "G4SystemOfUnits.hh"                  << 
 40 #include "G4Threading.hh"                      << 
 41 #include "G4TouchableHistory.hh"                   35 #include "G4TouchableHistory.hh"
 42 #include "G4Track.hh"                              36 #include "G4Track.hh"
                                                   >>  37 #include "G4Step.hh"
                                                   >>  38 #include "G4SDManager.hh"
                                                   >>  39 #include "G4Navigator.hh"
                                                   >>  40 #include "G4SystemOfUnits.hh"
                                                   >>  41 #include "G4ios.hh"
 43                                                    42 
 44 #include <fstream>                             << 
 45                                                    43 
 46 std::fstream* XAluminumElectrodeSensitivity::f <<  44 using namespace std;
 47 std::fstream* XAluminumElectrodeSensitivity::f << 
 48                                                    45 
 49 G4Mutex theMutex = G4MUTEX_INITIALIZER;  // Ju <<  46 XAluminumElectrodeHitsCollection* 
                                                   >>  47 XAluminumElectrodeSensitivity::fHitsCollection = NULL;
 50                                                    48 
 51 //....oooOO0OOooo........oooOO0OOooo........oo     49 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
 52                                                    50 
 53 XAluminumElectrodeSensitivity::XAluminumElectr <<  51 XAluminumElectrodeSensitivity::XAluminumElectrodeSensitivity(G4String name)
 54   : G4VSensitiveDetector(name)                 <<  52 :G4VSensitiveDetector(name)
 55 {                                                  53 {
 56   collectionName.insert("XAluminumElectrodeHit <<  54   G4String HCname;
                                                   >>  55   collectionName.insert(HCname="XAluminumElectrodeHit");
 57   fHCID = -1;                                      56   fHCID = -1;
                                                   >>  57   fWriter.open("caustic.ssv", fstream::out | fstream::ate);
                                                   >>  58   fWriter2.open("timing.ssv", fstream::out | fstream::ate);
 58                                                    59 
 59   G4AutoLock lockIt(&theMutex);  // Only one t <<  60   if(!fWriter.is_open()){
 60   fWriter = new std::fstream("caustic.ssv", st <<  61     G4cout<<"\nXAluminumElectrodeSensitivity::Constructor:";
 61   if (!fWriter->is_open()) {                   <<  62     G4cout<<"\n\tFailed to open caustic.ssv for appending data.";
 62     G4cerr << "XAluminumElectrodeSensitivity:: <<  63     G4cout<<"\n\tCreating caustic.ssv" << G4endl;
 63            << "\n\tFailed to open caustic.ssv  <<  64     fWriter.open("caustic.ssv");
 64            << "\n\tCreating caustic.ssv" << G4 << 
 65     fWriter->open("caustic.ssv");              << 
 66   }                                                65   }
 67                                                    66 
 68   fWriter2 = new std::fstream("timing.ssv", st <<  67   if(!fWriter2.is_open()){
 69   if (!fWriter2->is_open()) {                  <<  68     G4cout<<"\nXAluminumElectrodeSensitivity::Constructor: ";
 70     G4cerr << "XAluminumElectrodeSensitivity:: <<  69     G4cout<<"\n\tFailed to open timing.ssv for appending data.";
 71            << "\n\tFailed to open timing.ssv f <<  70     G4cout<<"\n\tCreating timing.ssv." << G4endl;
 72            << "\n\tCreating timing.ssv." << G4 <<  71     fWriter2.open("timing.ssv");
 73     fWriter2->open("timing.ssv");              << 
 74   }                                                72   }
 75                                                    73 
 76   if (!(fWriter->is_open() && fWriter2->is_ope <<  74   if(!(fWriter.is_open() && fWriter2.is_open())){
 77     G4cerr << "XAluminumElectrodeSensitivity:: <<  75     G4cout<<"\nXAluminumElectrodeSensitivity::Constructor: "
 78            << "\nERROR: COULD NOT CREATE OUTPU <<  76           <<"\nERROR: COULD NOT CREATE OUTPUT FILES FOR WRITING" << G4endl;
 79   }                                                77   }
 80 }                                                  78 }
 81                                                    79 
 82 //....oooOO0OOooo........oooOO0OOooo........oo     80 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
 83                                                    81 
 84 XAluminumElectrodeSensitivity::~XAluminumElect <<  82 XAluminumElectrodeSensitivity::~XAluminumElectrodeSensitivity(){
 85 {                                              <<  83   fWriter.close();
 86   G4AutoLock lockIt(&theMutex);  // Only one t <<  84   fWriter2.close();
 87                                                << 
 88   if (fWriter) {                               << 
 89     fWriter->close();                          << 
 90     delete fWriter;                            << 
 91     fWriter = 0;                               << 
 92   }                                            << 
 93                                                << 
 94   if (fWriter2) {                              << 
 95     fWriter2->close();                         << 
 96     delete fWriter2;                           << 
 97     fWriter2 = 0;                              << 
 98   }                                            << 
 99 }                                                  85 }
100                                                    86 
101 //....oooOO0OOooo........oooOO0OOooo........oo     87 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
102                                                    88 
103 XAluminumElectrodeHitsCollection* XAluminumEle <<  89 XAluminumElectrodeHitsCollection* 
104 {                                              <<  90 XAluminumElectrodeSensitivity::GetHitsCollection(){
105   return fHitsCollection;                          91   return fHitsCollection;
106 }                                                  92 }
107                                                    93 
108 //....oooOO0OOooo........oooOO0OOooo........oo     94 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
109                                                    95 
110 void XAluminumElectrodeSensitivity::Initialize <<  96 void XAluminumElectrodeSensitivity::Initialize(G4HCofThisEvent*HCE)
111 {                                                  97 {
112   fHitsCollection = new XAluminumElectrodeHits <<  98   fHitsCollection = new XAluminumElectrodeHitsCollection
113   if (fHCID < 0) {                             <<  99                    (SensitiveDetectorName,collectionName[0]);
114     fHCID = G4SDManager::GetSDMpointer()->GetC << 100   if(fHCID<0)
115   }                                            << 101   { fHCID = G4SDManager::GetSDMpointer()->GetCollectionID(fHitsCollection); }
116   HCE->AddHitsCollection(fHCID, fHitsCollectio << 102   HCE->AddHitsCollection(fHCID,fHitsCollection);
117 }                                                 103 }
118                                                   104 
119 //....oooOO0OOooo........oooOO0OOooo........oo    105 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
120                                                   106 
121 G4bool XAluminumElectrodeSensitivity::ProcessH << 107 G4bool XAluminumElectrodeSensitivity::ProcessHits(G4Step* aStep,
                                                   >> 108                                                   G4TouchableHistory* /*ROhist*/)
122 {                                                 109 {
123   // if(aStep->GetTrack()->GetDefinition()!=Ph << 110   //if(aStep->GetTrack()->GetDefinition()!=Phonon::PhononDefinition()) return true;
124   G4double edp = aStep->GetNonIonizingEnergyDe    111   G4double edp = aStep->GetNonIonizingEnergyDeposit();
125   if (edp == 0.) return true;                  << 112   if(edp==0.) return true;
126                                                   113 
127   G4StepPoint* preStepPoint = aStep->GetPreSte    114   G4StepPoint* preStepPoint = aStep->GetPreStepPoint();
128   G4StepPoint* postStepPoint = aStep->GetPostS    115   G4StepPoint* postStepPoint = aStep->GetPostStepPoint();
129   G4TouchableHistory* theTouchable = (G4Toucha << 116   G4TouchableHistory* theTouchable
                                                   >> 117     = (G4TouchableHistory*)(preStepPoint->GetTouchable());
130   G4ThreeVector fWorldPos = postStepPoint->Get    118   G4ThreeVector fWorldPos = postStepPoint->GetPosition();
131   G4ThreeVector fLocalPos = theTouchable->GetH << 119   G4ThreeVector fLocalPos
                                                   >> 120     = theTouchable->GetHistory()->GetTopTransform().TransformPoint(fWorldPos);
132                                                   121 
133   XAluminumElectrodeHit* aHit = new XAluminumE    122   XAluminumElectrodeHit* aHit = new XAluminumElectrodeHit();
134   aHit->fTime = postStepPoint->GetGlobalTime() << 123   aHit->SetTime(postStepPoint->GetGlobalTime());
135   aHit->fEdep = edp;                           << 124   aHit->SetEDep(edp);
136   aHit->fWorldPos = fWorldPos;                 << 125   aHit->SetWorldPos(fWorldPos);
137   aHit->fLocalPos = fLocalPos;                 << 126   aHit->SetLocalPos(fLocalPos);
138                                                   127 
139   fHitsCollection->insert(aHit);                  128   fHitsCollection->insert(aHit);
140                                                   129 
141   return true;                                 << 130   fWriter<<"\n"<<fWorldPos.getX()/mm
142 }                                              << 131          <<","<<fWorldPos.getY()/mm
                                                   >> 132          <<","<<fWorldPos.getZ()/mm;
143                                                   133 
144 //....oooOO0OOooo........oooOO0OOooo........oo << 134   fWriter2<<"\n"<<postStepPoint->GetGlobalTime()/ns<<" "
145                                                << 135           <<aHit->GetEDep()/eV;
146 void XAluminumElectrodeSensitivity::EndOfEvent << 
147 {                                              << 
148   if (!fHitsCollection || fHitsCollection->Get << 
149                                                   136 
150   for (size_t i = 0; i < fHitsCollection->GetS << 137   return true;
151     WriteHitInfo(dynamic_cast<XAluminumElectro << 
152   }                                            << 
153 }                                                 138 }
154                                                   139 
155 //....oooOO0OOooo........oooOO0OOooo........oo    140 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
156                                                   141 
157 void XAluminumElectrodeSensitivity::WriteHitIn << 142 void XAluminumElectrodeSensitivity::EndOfEvent(G4HCofThisEvent* /*HCE*/)
158 {                                              << 143 {;}
159   if (!aHit) return;                           << 
160                                                << 
161   G4AutoLock lockIt(&theMutex);  // Only one e << 
162                                                << 
163   *fWriter << aHit->fWorldPos.getX() / mm << " << 
164            << aHit->fWorldPos.getZ() / mm << " << 
165                                                   144 
166   *fWriter2 << aHit->fTime / ns << " " << aHit << 
167 }                                              << 
168                                                   145