File indexing completed on 2025-01-30 09:19:32
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050 #include "TFile.h"
0051 #include "TSystem.h"
0052 #include "TTree.h"
0053 #include "TH1.h"
0054
0055 #include "Event.hh"
0056 #include "DRCalorimeterHit.hh"
0057
0058 int main(int argc, char** argv)
0059 {
0060
0061 TSystem ts;
0062 gSystem->Load("libCaTSClassesDict");
0063 if(argc < 4)
0064 {
0065 G4cout << "Program requires 3 arguments: name of input file, name of "
0066 "output file, Volume that sensitive detector is attached to"
0067 << G4endl;
0068 exit(1);
0069 }
0070 TFile* outfile = new TFile(argv[2], "RECREATE");
0071 outfile->cd();
0072 TFile fo(argv[1]);
0073 fo.GetListOfKeys()->Print();
0074 Event* event = new Event();
0075 TTree* Tevt = (TTree*) fo.Get("Events");
0076 Tevt->SetBranchAddress("event.", &event);
0077 TBranch* fevtbranch = Tevt->GetBranch("event.");
0078 Int_t nevent = fevtbranch->GetEntries();
0079 G4cout << " Nr. of Events: " << nevent << G4endl;
0080 double max = 0.;
0081 double min = 1000000;
0082 double nmax = 0.;
0083 double nmin = 1000000000;
0084 std::string CollectionName = argv[3];
0085 CollectionName = CollectionName + "_DRCalorimeter_HC";
0086 for(Int_t i = 0; i < nevent; i++)
0087 {
0088 fevtbranch->GetEntry(i);
0089 auto* hcmap = event->GetHCMap();
0090 for(const auto& ele : *hcmap)
0091 {
0092 if(ele.first.compare(CollectionName) == 0)
0093 {
0094 auto hits = ele.second;
0095 G4int NbHits = hits.size();
0096 for(G4int ii = 0; ii < NbHits; ii++)
0097 {
0098 DRCalorimeterHit* drcaloHit =
0099 dynamic_cast<DRCalorimeterHit*>(hits.at(ii));
0100 const double ed = drcaloHit->GetEdep();
0101 if(ed > max)
0102 max = ed;
0103 if(ed < min)
0104 min = ed;
0105 const unsigned int nceren = drcaloHit->GetNceren();
0106 if(nceren > nmax)
0107 nmax = nceren;
0108 if(nceren < nmin)
0109 nmin = nceren;
0110 }
0111 }
0112 }
0113 }
0114 outfile->cd();
0115 TH1F* hedep = new TH1F("energy", "edep", 100, min, max);
0116 TH1F* hnceren = new TH1F("nceren", "nceren", 100, nmin, nmax);
0117 for(Int_t i = 0; i < nevent; i++)
0118 {
0119 fevtbranch->GetEntry(i);
0120 auto* hcmap = event->GetHCMap();
0121 for(const auto& ele : *hcmap)
0122 {
0123 if(ele.first.compare(CollectionName) == 0)
0124 {
0125 auto hits = ele.second;
0126 G4int NbHits = hits.size();
0127 for(G4int ii = 0; ii < NbHits; ii++)
0128 {
0129 DRCalorimeterHit* drcaloHit =
0130 dynamic_cast<DRCalorimeterHit*>(hits.at(ii));
0131 hedep->Fill(drcaloHit->GetEdep());
0132 hnceren->Fill(drcaloHit->GetNceren());
0133 }
0134 }
0135 }
0136 }
0137
0138
0139 outfile->Write();
0140 }