CMS 3D CMS Logo

BscTest.h
Go to the documentation of this file.
1 #ifndef BscTest_H
2 #define BscTest_H
3 
4 // system include files
5 #include <vector>
6 #include <iostream>
7 #include <memory>
8 #include <string>
9 //
10 // user include files
14 
15 // necessary objects:
17 
18 //
19 //
29 //#include "SimG4Core/Watcher/interface/SimProducer.h"
30 //#include "SimG4Core/Watcher/interface/SimWatcherMaker.h"
32 
34 
35 #include "G4VTouchable.hh"
36 #include <map>
37 #include <cmath>
38 #include <CLHEP/Vector/ThreeVector.h>
39 #include <CLHEP/Vector/LorentzVector.h>
40 #include <CLHEP/Random/Randomize.h>
41 // #include <fstream>
42 
43 // ----------------------------------------------------------------
44 // Includes needed for Root ntupling
45 //
46 #include "TROOT.h"
47 #include "TFile.h"
48 #include "TH1.h"
49 #include "TH2.h"
50 #include "TProfile.h"
51 #include "TNtuple.h"
52 #include "TRandom.h"
53 #include "TLorentzVector.h"
54 #include "TUnixSystem.h"
55 #include "TSystem.h"
56 #include "TMath.h"
57 #include "TF1.h"
58 
59 #include <TObjArray.h>
60 #include <TObjString.h>
61 #include <TNamed.h>
62 
63 class BscAnalysisHistManager : public TNamed {
64 public:
65  BscAnalysisHistManager(const TString& managername);
66  ~BscAnalysisHistManager() override;
67 
68  TH1F* GetHisto(Int_t Number);
69  TH1F* GetHisto(const TObjString& histname);
70 
71  TH2F* GetHisto2(Int_t Number);
72  TH2F* GetHisto2(const TObjString& histname);
73 
74  void WriteToFile(const TString& fOutputFile, const TString& fRecreateFile);
75 
76 private:
77  void BookHistos();
78  void StoreWeights();
79  void HistInit(const char* name, const char* title, Int_t nbinsx, Axis_t xlow, Axis_t xup);
80  void HistInit(
81  const char* name, const char* title, Int_t nbinsx, Axis_t xlow, Axis_t xup, Int_t nbinsy, Axis_t ylow, Axis_t yup);
82 
83  const char* fTypeTitle;
84  TObjArray* fHistArray;
85  TObjArray* fHistNamesArray;
86 };
87 
88 class BscNumberingScheme;
89 
90 class BeginOfJob;
91 class BeginOfRun;
92 class EndOfRun;
93 class BeginOfEvent;
94 class EndOfEvent;
95 class BeginOfTrack;
96 class EndOfTrack;
97 class G4Step;
98 
99 /*
100 class ObserveBeginOfRun : private Observer<const BeginOfRun *>
101 {
102 public:
103  ObserveBeginOfRun();
104 private:
105  void update(const BeginOfRun * run);
106 };
107 
108 class ObserveEndOfRun : private Observer<const EndOfRun *>
109 {
110 public:
111  ObserveEndOfRun();
112 private:
113  void update(const EndOfRun * run);
114 };
115 
116 class ObserveBeginOfEvent : private Observer<const BeginOfEvent *>
117 {
118 public:
119  ObserveBeginOfEvent();
120 private:
121  void update(const BeginOfEvent * evt);
122 };
123 
124 class ObserveEndOfEvent : private Observer<const EndOfEvent *>
125 {
126 public:
127  ObserveEndOfEvent();
128 private:
129  void update(const EndOfEvent * evt);
130  // std::vector<BscG4Hit> theStripHits;
131 };
132 
133 class ObserveBeginOfTrack : private Observer<const BeginOfTrack *>
134 {
135 public:
136  ObserveBeginOfTrack();
137 private:
138  void update(const BeginOfTrack * trk);
139 };
140 
141 class ObserveEndOfTrack : private Observer<const EndOfTrack *>
142 {
143 public:
144  ObserveEndOfTrack();
145 private:
146  void update(const EndOfTrack * trk);
147 };
148 
149 class ObserveStep : private Observer<const G4Step *>
150 {
151 public:
152  ObserveStep();
153 private:
154  void update(const G4Step * step);
155 };
156 */
157 //class BscTest: public SimProducer,
158 class BscTest : public SimWatcher,
159  public Observer<const BeginOfJob*>,
160  public Observer<const BeginOfRun*>,
161  public Observer<const EndOfRun*>,
162  public Observer<const BeginOfEvent*>,
163  public Observer<const BeginOfTrack*>,
164  public Observer<const G4Step*>,
165  public Observer<const EndOfTrack*>,
166  public Observer<const EndOfEvent*> {
167 public:
168  BscTest(const edm::ParameterSet& p);
169  ~BscTest() override;
170  //MyActions();
171  //MyActions();
172 private:
173  // observer classes
174  void update(const BeginOfJob* run) override;
175  void update(const BeginOfRun* run) override;
176  void update(const EndOfRun* run) override;
177  void update(const BeginOfEvent* evt) override;
178  void update(const BeginOfTrack* trk) override;
179  void update(const G4Step* step) override;
180  void update(const EndOfTrack* trk) override;
181  void update(const EndOfEvent* evt) override;
182 
183 private:
184  //UHB_Analysis* UserNtuples;
186 
187  int iev;
188  int itrk;
189  G4double entot0, tracklength0;
190 
191 private:
192  // Utilities to get detector levels during a step
193 
194  int detLevels(const G4VTouchable*) const;
195  G4String detName(const G4VTouchable*, int, int) const;
196  void detectorLevel(const G4VTouchable*, int&, int*, G4String*) const;
197 
198  double rinCalo, zinCalo;
201 
202  // SumEnerDeposit - all deposited energy on all steps ; SumStepl - length in steel !!!
203  G4double SumEnerDeposit, SumStepl, SumStepc;
204  // numofpart - # particles produced along primary track
206  // last point of the primary track
207  G4ThreeVector lastpo;
208 
209  // z:
210  double z1, z2, z3, z4;
211 
212 private:
213  Float_t bsceventarray[1];
214  TNtuple* bsceventntuple;
217 
218  BscAnalysisHistManager* TheHistManager; //Histogram Manager of the analysis
219  std::string fDataLabel; // Data type label
220  std::string fOutputFile; // The output file name
221  std::string fRecreateFile; // Recreate the file flag, default="RECREATE"
222 
223  // // // // // // TObjString fHistType;
224  // TString fDataLabel; // Data type label
225  // TString fOutputFile; // The output file name
226  // TString fRecreateFile; // Recreate the file flag, default="RECREATE"
227 };
228 
229 #endif
int numofpart
Definition: BscTest.h:205
G4double SumStepl
Definition: BscTest.h:203
TH1F * GetHisto(Int_t Number)
Definition: BscTest.cc:184
std::string fOutputFile
Definition: BscTest.h:220
TH2F * GetHisto2(Int_t Number)
Definition: BscTest.cc:200
G4ThreeVector lastpo
Definition: BscTest.h:207
TObjArray * fHistNamesArray
Definition: BscTest.h:85
int iev
Definition: BscTest.h:187
TObjArray * fHistArray
Definition: BscTest.h:84
std::string fRecreateFile
Definition: BscTest.h:221
int verbosity
Definition: BscTest.h:200
double z4
Definition: BscTest.h:210
const char * fTypeTitle
Definition: BscTest.h:83
int whichevent
Definition: BscTest.h:216
void WriteToFile(const TString &fOutputFile, const TString &fRecreateFile)
Definition: BscTest.cc:143
std::string fDataLabel
Definition: BscTest.h:219
void HistInit(const char *name, const char *title, Int_t nbinsx, Axis_t xlow, Axis_t xup)
Definition: BscTest.cc:157
BscAnalysisHistManager * TheHistManager
Definition: BscTest.h:218
double zinCalo
Definition: BscTest.h:198
BscNumberingScheme * theBscNumberingScheme
Definition: BscTest.h:185
TNtuple * bsceventntuple
Definition: BscTest.h:214
int lastTrackID
Definition: BscTest.h:199
#define update(a, b)
int itrk
Definition: BscTest.h:188
step
Definition: StallMonitor.cc:94
TFile bscOutputFile
Definition: BscTest.h:215
BscAnalysisHistManager(const TString &managername)
Definition: BscTest.cc:103
G4double tracklength0
Definition: BscTest.h:189
~BscAnalysisHistManager() override
Definition: BscTest.cc:117