[807] | 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 | // Rich advanced example for Geant4 |
---|
| 27 | // RichTbIOData.cc for Rich of LHCb |
---|
| 28 | // History: |
---|
| 29 | // Created: Sajan Easo (Sajan.Easo@cern.ch) |
---|
| 30 | // Revision and changes: Patricia Mendez (Patricia.Mendez@cern.ch) |
---|
| 31 | ///////////////////////////////////////////////////////////////////////////// |
---|
| 32 | #include "RichTbIOData.hh" |
---|
| 33 | #include "G4HCofThisEvent.hh" |
---|
| 34 | #include "G4VHitsCollection.hh" |
---|
| 35 | #include "G4SDManager.hh" |
---|
| 36 | #include "G4ios.hh" |
---|
| 37 | #include "G4ThreeVector.hh" |
---|
| 38 | #include "RichTbHit.hh" |
---|
| 39 | #include <fstream> |
---|
| 40 | |
---|
| 41 | RichTbIOData::RichTbIOData(RichTbRunConfig* RConfig ) |
---|
| 42 | :OutputDataFS((RConfig -> getOutputFileName()).c_str()) |
---|
| 43 | { |
---|
| 44 | |
---|
| 45 | aOutFileString=RConfig -> getOutputFileName(); |
---|
| 46 | |
---|
| 47 | |
---|
| 48 | } |
---|
| 49 | RichTbIOData::~RichTbIOData() { } |
---|
| 50 | |
---|
| 51 | void RichTbIOData::WriteOutEventHeaderData( const G4Event* ) { } |
---|
| 52 | |
---|
| 53 | void RichTbIOData::WriteOutHitData( const G4Event* evt ) { |
---|
| 54 | |
---|
| 55 | G4SDManager * SDman = G4SDManager::GetSDMpointer(); |
---|
| 56 | G4String colNam; |
---|
| 57 | G4int RichTbCID = SDman->GetCollectionID(colNam="RichTbHitsCollection"); |
---|
| 58 | if(RichTbCID<0) return; |
---|
| 59 | G4HCofThisEvent * HCE = evt->GetHCofThisEvent(); |
---|
| 60 | RichTbHitsCollection* RHC = NULL; |
---|
| 61 | if(HCE) |
---|
| 62 | { |
---|
| 63 | RHC = (RichTbHitsCollection*)(HCE->GetHC(RichTbCID)); |
---|
| 64 | } |
---|
| 65 | if(RHC) |
---|
| 66 | { |
---|
| 67 | G4int n_hit = RHC->entries(); |
---|
| 68 | G4cout << " " << n_hit << "Hits being written out "<<G4endl; |
---|
| 69 | // OutputDataFS<<n_hit<<G4endl; |
---|
| 70 | for (G4int ih=0; ih<n_hit; ih++ ) { |
---|
| 71 | RichTbHit* aHit = (*RHC)[ih]; |
---|
| 72 | G4int aHitHpdNum = aHit -> GetCurHpdNum(); |
---|
| 73 | G4int aHitSectNum = aHit -> GetCurSectNum(); |
---|
| 74 | G4int aHitPixelNum = aHit -> GetCurPixNum(); |
---|
| 75 | G4ThreeVector aHitPosPC = aHit -> GetPosPC(); |
---|
| 76 | |
---|
| 77 | OutputDataFS<<" "<< aHitHpdNum<<" "<< aHitSectNum |
---|
| 78 | <<" "<<aHitPixelNum |
---|
| 79 | <<" "<< aHitPosPC.x()<<" "<< aHitPosPC.y() |
---|
| 80 | <<" "<< aHitPosPC.z()<<G4endl; |
---|
| 81 | |
---|
| 82 | |
---|
| 83 | } |
---|
| 84 | } |
---|
| 85 | |
---|
| 86 | |
---|
| 87 | } |
---|
| 88 | |
---|