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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/advanced/gammaray_telescope/src/GammaRayTelEventAction.cc (Version 11.3.0) and /examples/advanced/gammaray_telescope/src/GammaRayTelEventAction.cc (Version 10.6)


  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 //                                                 26 //
 27 // -------------------------------------------     27 // ------------------------------------------------------------
 28 //      GEANT 4 class implementation file          28 //      GEANT 4 class implementation file
 29 //      CERN Geneva Switzerland                    29 //      CERN Geneva Switzerland
 30 //                                                 30 //
 31 //                                                 31 //
 32 //      ------------ GammaRayTelEventAction  -     32 //      ------------ GammaRayTelEventAction  ------
 33 //           by  R.Giannitrapani, F.Longo & G.     33 //           by  R.Giannitrapani, F.Longo & G.Santin (13 nov 2000)
 34 //                                                 34 //
 35 // - inclusion of Digits by F.Longo & R.Gianni     35 // - inclusion of Digits by F.Longo & R.Giannitrapani (24 oct 2001)
 36 //                                                 36 // 
 37 // - Modification of analysis management by G.     37 // - Modification of analysis management by G.Santin (18 Nov 2001)
 38 //                                                 38 // 
 39 // *******************************************     39 // ************************************************************
 40                                                    40 
 41 #include "GammaRayTelEventAction.hh"               41 #include "GammaRayTelEventAction.hh"
 42 #include "GammaRayTelTrackerHit.hh"                42 #include "GammaRayTelTrackerHit.hh"
 43 #include "GammaRayTelAnticoincidenceHit.hh"        43 #include "GammaRayTelAnticoincidenceHit.hh"
 44 #include "GammaRayTelCalorimeterHit.hh"            44 #include "GammaRayTelCalorimeterHit.hh"
                                                   >>  45 
 45 #include "GammaRayTelAnalysis.hh"                  46 #include "GammaRayTelAnalysis.hh"
 46 #include "GammaRayTelDigi.hh"                  << 
 47 #include "GammaRayTelDigitizer.hh"             << 
 48                                                    47 
 49 #include "G4DigiManager.hh"                    <<  48 #include "G4SystemOfUnits.hh"
 50 #include "G4Event.hh"                              49 #include "G4Event.hh"
 51 #include "G4EventManager.hh"                       50 #include "G4EventManager.hh"
 52 #include "G4HCofThisEvent.hh"                      51 #include "G4HCofThisEvent.hh"
 53 #include "G4ios.hh"                            <<  52 #include "G4VHitsCollection.hh"
 54 #include "G4SDManager.hh"                          53 #include "G4SDManager.hh"
 55 #include "G4SystemOfUnits.hh"                  << 
 56 #include "G4UImanager.hh"                          54 #include "G4UImanager.hh"
                                                   >>  55 #include "G4ios.hh"
 57 #include "G4UnitsTable.hh"                         56 #include "G4UnitsTable.hh"
 58 #include "G4VHitsCollection.hh"                << 
 59 #include "Randomize.hh"                            57 #include "Randomize.hh"
 60                                                    58 
 61 //....oooOO0OOooo........oooOO0OOooo........oo <<  59 #include "GammaRayTelDigi.hh"
                                                   >>  60 #include "GammaRayTelDigitizer.hh"
                                                   >>  61 #include "G4DigiManager.hh"
 62                                                    62 
 63 // This file is a global variable in which we      63 // This file is a global variable in which we store energy deposition per hit
 64 // and other relevant information                  64 // and other relevant information
 65                                                    65 
 66 GammaRayTelEventAction::GammaRayTelEventAction << 
 67     auto *digitizer = new GammaRayTelDigitizer << 
 68     G4DigiManager::GetDMpointer()->AddNewModul << 
 69 }                                              << 
 70                                                << 
 71 //....oooOO0OOooo........oooOO0OOooo........oo     66 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
 72                                                    67 
 73 GammaRayTelEventAction::~GammaRayTelEventActio <<  68 GammaRayTelEventAction::GammaRayTelEventAction(GammaRayTelRunAction* runAction)
                                                   >>  69   :trackerCollID(-1),calorimeterCollID(-1),                
                                                   >>  70    anticoincidenceCollID(-1), drawFlag("all"),
                                                   >>  71    theRunAction(runAction)
                                                   >>  72 { 
                                                   >>  73   GammaRayTelDigitizer * myDM = new GammaRayTelDigitizer( "GammaRayTelDigitizer" );
                                                   >>  74   G4DigiManager::GetDMpointer()->AddNewModule(myDM);
 74 }                                                  75 }
 75                                                    76 
 76 //....oooOO0OOooo........oooOO0OOooo........oo     77 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
 77                                                    78 
 78 void GammaRayTelEventAction::BeginOfEventActio <<  79 GammaRayTelEventAction::~GammaRayTelEventAction()
 79     G4int eventIdentifer = event->GetEventID() <<  80 {;}
 80     G4cout << "Event: " << eventIdentifer << G << 
 81     auto *sensitiveDetectorManager = G4SDManag << 
 82                                                    81 
 83     if (trackerCollectionID == -1) {           <<  82 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
 84         trackerCollectionID = sensitiveDetecto <<  83 
 85     }                                          <<  84 void GammaRayTelEventAction::BeginOfEventAction(const G4Event* evt)
 86     if (anticoincidenceCollectionID == -1) {   <<  85 {
 87         anticoincidenceCollectionID = sensitiv <<  86   G4int evtNb = evt->GetEventID();
 88     }                                          <<  87   G4cout << "Event: " << evtNb << G4endl;
 89     if (calorimeterCollectionID == -1) {       <<  88   G4SDManager * SDman = G4SDManager::GetSDMpointer();  
 90         calorimeterCollectionID = sensitiveDet <<  89 
 91     }                                          <<  90   if (trackerCollID==-1) {
                                                   >>  91     trackerCollID = SDman->GetCollectionID("TrackerCollection");
                                                   >>  92   }
                                                   >>  93   if(anticoincidenceCollID==-1) {
                                                   >>  94     anticoincidenceCollID =
                                                   >>  95       SDman->GetCollectionID("AnticoincidenceCollection");
                                                   >>  96   }
                                                   >>  97   if(calorimeterCollID==-1) {
                                                   >>  98     calorimeterCollID =
                                                   >>  99       SDman->GetCollectionID("CalorimeterCollection");
                                                   >> 100   }
 92 }                                                 101 }
 93                                                   102 
 94 //....oooOO0OOooo........oooOO0OOooo........oo    103 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
 95                                                   104 
 96 void GammaRayTelEventAction::EndOfEventAction( << 105 void GammaRayTelEventAction::EndOfEventAction(const G4Event* evt)
 97     G4int eventIdentifier = event->GetEventID( << 106 {
                                                   >> 107   G4int event_id = evt->GetEventID();
 98                                                   108 
 99     if (theRunAction == nullptr) {             << 
100         G4Exception("GammaRayTelEventAction::B << 
101     }                                          << 
102                                                   109 
                                                   >> 110   if (!theRunAction)
                                                   >> 111     {
                                                   >> 112       G4Exception("GammaRayTelEventAction::BeginOfEventAction()",
                                                   >> 113       "GTR0001",FatalException,"Null pointer to Run Action: this should not be");
                                                   >> 114     }
103 #ifdef G4STORE_DATA                               115 #ifdef G4STORE_DATA
104     auto *outputFile = theRunAction->GetOutput << 116   std::ofstream* outFile = theRunAction->GetOutputFile();
105 #endif                                            117 #endif
106                                                   118 
107     auto *collection = event->GetHCofThisEvent << 119   G4HCofThisEvent* HCE = evt->GetHCofThisEvent();
108     GammaRayTelTrackerHitsCollection *trackerC << 120   GammaRayTelTrackerHitsCollection* THC = 0;
109     // GammaRayTelCalorimeterHitsCollection* c << 
110     // GammaRayTelAnticoincidenceHitsCollectio << 
111                                                << 
112     auto *fDM = G4DigiManager::GetDMpointer(); << 
113     GammaRayTelAnalysis *analysis = GammaRayTe << 
114                                                << 
115     if (collection != nullptr) {               << 
116         trackerCollection = (GammaRayTelTracke << 
117         // calorimeterCollection = (GammaRayTe << 
118         // anticoincidenceCollection = (GammaR << 
119                                                << 
120         if (trackerCollection != nullptr) {    << 
121             G4int numberOfHits = trackerCollec << 
122             G4cout << "Number of tracker hits  << 
123                                                << 
124             G4double depositedEnergy{0};       << 
125             G4int stripNumber;                 << 
126             G4int planeNumber;                 << 
127             G4int isXPlane;                    << 
128                                                << 
129             // This is a cycle on all the trac << 
130                                                << 
131             for (auto i = 0; i < numberOfHits; << 
132                 // Here we put the hit data in << 
133                 depositedEnergy = (*trackerCol << 
134                 stripNumber = (*trackerCollect << 
135                 planeNumber = (*trackerCollect << 
136                 isXPlane = (*trackerCollection << 
137                                                   121 
138 #ifdef G4STORE_DATA                            << 122   //  GammaRayTelCalorimeterHitsCollection* CHC = 0;
139                 (*outputFile) << std::setw(7)  << 123   //  GammaRayTelAnticoincidenceHitsCollection* AHC = 0;
140                     << " " << depositedEnergy/ << 
141                     << " " << stripNumber      << 
142                     << " " << planeNumber      << 
143                     << " " << isXPlane         << 
144                     << " " << (*trackerCollect << 
145                     << " " << (*trackerCollect << 
146                     << " " << (*trackerCollect << 
147                     << " " << G4endl;          << 
148 #else                                          << 
149                 G4cout << std::setw(7) << even << 
150                     << " " << depositedEnergy  << 
151                     << " " << stripNumber      << 
152                     << " " << planeNumber      << 
153                     << " " << isXPlane         << 
154                     << " " << (*trackerCollect << 
155                     << " " << (*trackerCollect << 
156                     << " " << (*trackerCollect << 
157                     << " " << G4endl;          << 
158 #endif                                         << 
159                                                   124 
160                 // Here we fill the histograms << 
161                 if (isXPlane != 0) {           << 
162                     if (analysis->GetHisto2DMo << 
163                         analysis->InsertPositi << 
164                     } else {                   << 
165                         analysis->InsertPositi << 
166                     }                          << 
167                                                << 
168                     if (planeNumber == 0) {    << 
169                         analysis->InsertEnergy << 
170                     }                          << 
171                     analysis->InsertHits(plane << 
172                 } else {                       << 
173                     if (analysis->GetHisto2DMo << 
174                         analysis->InsertPositi << 
175                     } else {                   << 
176                         analysis->InsertPositi << 
177                     }                          << 
178                     if (planeNumber == 0) {    << 
179                         analysis->InsertEnergy << 
180                     }                          << 
181                     analysis->InsertHits(plane << 
182                 }                              << 
183                 analysis->setNtuple(depositedE << 
184                     (*trackerCollection)[i]->G << 
185                     (*trackerCollection)[i]->G << 
186                     (*trackerCollection)[i]->G << 
187                 );                             << 
188             }                                  << 
189             analysis->EndOfEvent(numberOfHits) << 
190         }                                      << 
191                                                   125 
192         auto *myDM = (GammaRayTelDigitizer*) f << 126   G4DigiManager * fDM = G4DigiManager::GetDMpointer();
193         myDM->Digitize();                      << 127   GammaRayTelAnalysis* analysis = GammaRayTelAnalysis::getInstance();
                                                   >> 128 
                                                   >> 129   if (HCE)
                                                   >> 130     {
                                                   >> 131       THC = (GammaRayTelTrackerHitsCollection*)(HCE->GetHC(trackerCollID));
                                                   >> 132       //      CHC = (GammaRayTelCalorimeterHitsCollection*)
                                                   >> 133       //  (HCE->GetHC(calorimeterCollID));
                                                   >> 134       //      AHC = (GammaRayTelAnticoincidenceHitsCollection*)
                                                   >> 135       //  (HCE->GetHC(anticoincidenceCollID));
                                                   >> 136       
                                                   >> 137       if (THC)
                                                   >> 138   {
                                                   >> 139     int n_hit = THC->entries();
                                                   >> 140     G4cout << "Number of tracker hits in this event =  " << n_hit << G4endl;
                                                   >> 141     G4double ESil=0;
                                                   >> 142     G4int NStrip, NPlane, IsX;
                                                   >> 143     
                                                   >> 144     // This is a cycle on all the tracker hits of this event
                                                   >> 145     
                                                   >> 146     for (int i=0;i<n_hit;i++) 
                                                   >> 147       {
                                                   >> 148         // Here we put the hit data in a an ASCII file for 
                                                   >> 149         // later analysis 
                                                   >> 150         ESil = (*THC)[i]->GetEdepSil();
                                                   >> 151         NStrip = (*THC)[i]->GetNStrip();
                                                   >> 152         NPlane = (*THC)[i]->GetNSilPlane();
                                                   >> 153         IsX = (*THC)[i]->GetPlaneType();
                                                   >> 154         
                                                   >> 155 #ifdef G4STORE_DATA
                                                   >> 156        
194                                                   157 
                                                   >> 158         (*outFile) << std::setw(7) << event_id << " " << 
                                                   >> 159     ESil/keV << " " << NStrip << 
                                                   >> 160     " " << NPlane << " " << IsX << " " <<
                                                   >> 161     (*THC)[i]->GetPos().x()/mm <<" "<<
                                                   >> 162     (*THC)[i]->GetPos().y()/mm <<" "<<
                                                   >> 163     (*THC)[i]->GetPos().z()/mm <<" "<<
                                                   >> 164     G4endl;
                                                   >> 165 #else     
                                                   >> 166         G4cout << std::setw(7) << event_id << " " << 
                                                   >> 167     ESil/keV << " " << NStrip << 
                                                   >> 168     " " << NPlane << " " << IsX << " " <<
                                                   >> 169     (*THC)[i]->GetPos().x()/mm <<" "<<
                                                   >> 170     (*THC)[i]->GetPos().y()/mm <<" "<<
                                                   >> 171     (*THC)[i]->GetPos().z()/mm <<" "<<
                                                   >> 172     G4endl;
                                                   >> 173 #endif
                                                   >> 174         
                                                   >> 175         
                                                   >> 176         // Here we fill the histograms of the Analysis manager
                                                   >> 177         if(IsX) 
                                                   >> 178     {
                                                   >> 179       if (analysis->GetHisto2DMode()=="position")
                                                   >> 180         analysis->InsertPositionXZ((*THC)[i]->GetPos().x()/mm,(*THC)[i]->GetPos().z()/mm);
                                                   >> 181       else
                                                   >> 182         analysis->InsertPositionXZ(NStrip, NPlane);         
                                                   >> 183       if (NPlane == 0) analysis->InsertEnergy(ESil/keV);
                                                   >> 184       analysis->InsertHits(NPlane);
                                                   >> 185     } 
                                                   >> 186         else 
                                                   >> 187     {
                                                   >> 188       if (analysis->GetHisto2DMode()=="position")
                                                   >> 189         analysis->InsertPositionYZ((*THC)[i]->GetPos().y()/mm,(*THC)[i]->GetPos().z()/mm);  
                                                   >> 190       else 
                                                   >> 191         analysis->InsertPositionYZ(NStrip, NPlane);         
                                                   >> 192       if (NPlane == 0) analysis->InsertEnergy(ESil/keV);
                                                   >> 193       analysis->InsertHits(NPlane);
                                                   >> 194     }
                                                   >> 195         
                                                   >> 196         analysis->setNtuple( ESil/keV, NPlane, (*THC)[i]->GetPos().x()/mm,
                                                   >> 197            (*THC)[i]->GetPos().y()/mm,
                                                   >> 198            (*THC)[i]->GetPos().z()/mm);
                                                   >> 199     
                                                   >> 200       }   
                                                   >> 201     analysis->EndOfEvent(n_hit);    
                                                   >> 202   }
                                                   >> 203       
                                                   >> 204       GammaRayTelDigitizer * myDM = 
                                                   >> 205   (GammaRayTelDigitizer*)fDM->FindDigitizerModule( "GammaRayTelDigitizer" );
                                                   >> 206       myDM->Digitize();
                                                   >> 207       
195 #ifdef G4STORE_DATA                               208 #ifdef G4STORE_DATA
196         // The whole block is needed only when << 209       // the whole block is needed only when outfile is active; protect block to avoid
197         // protect block to avoid compilations << 210       //     compilations warnings from gcc4.6, Gunter Folger
198                                                   211 
199     auto digitsCollectionIdentifier = fDM->Get << 212       G4int myDigiCollID = fDM->GetDigiCollectionID("DigitsCollection");
200         // G4cout << "Digits collection: " <<  << 
201                                                   213       
202     auto *digitsCollection = (GammaRayTelDigit << 214       // G4cout << "digi collecion" << myDigiCollID << G4endl;
203                                                   215       
204         if (digitsCollection != nullptr) {     << 216       GammaRayTelDigitsCollection * DC = (GammaRayTelDigitsCollection*)fDM->GetDigiCollection( myDigiCollID );
205             auto numberOfDigits = digitsCollec << 217       
206             // G4cout << "Total number of digi << 218       if(DC) {
207                                                << 219   //    G4cout << "Total Digits " << DC->entries() << G4endl;
208             G4int stripNumber;                 << 220   G4int n_digi =  DC->entries();
209             G4int planeNumber;                 << 221   G4int NStrip, NPlane, IsX;
210             G4int isXPlane;                    << 222   for (G4int i=0;i<n_digi;i++) {
211                                                << 223     // Here we put the digi data in a an ASCII file for 
212             for (auto i = 0; i < numberOfDigit << 224     // later analysis
213                 // Here we put the digi data i << 225     NStrip = (*DC)[i]->GetStripNumber();
214                 stripNumber = (*digitsCollecti << 226     NPlane = (*DC)[i]->GetPlaneNumber();
215                 planeNumber = (*digitsCollecti << 227     IsX = (*DC)[i]->GetPlaneType();
216                 isXPlane = (*digitsCollection) << 228     
217                                                << 229     (*outFile) << std::setw(7) << event_id << " " << NStrip << 
218                 (*outputFile) << std::setw(7)  << 230       " " << NPlane << " " << IsX << " " << G4endl; 
219                     << eventIdentifier         << 231   }
220                     << " " << stripNumber      << 232       }
221                     << " " << planeNumber      << 
222                     << " " << isXPlane         << 
223                     << " " << G4endl;          << 
224             }                                  << 
225         }                                      << 
226 #endif                                            233 #endif      
227     }                                             234     }
228 }                                                 235 }
                                                   >> 236 
                                                   >> 237 
                                                   >> 238 
                                                   >> 239 
                                                   >> 240 
                                                   >> 241 
                                                   >> 242 
                                                   >> 243 
                                                   >> 244 
                                                   >> 245 
                                                   >> 246 
                                                   >> 247 
                                                   >> 248 
229                                                   249