CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 // ----------------------------------------------------------------
45 // Includes needed for Root ntupling
46 //
47 #include "TROOT.h"
48 #include "TFile.h"
49 #include "TH1.h"
50 #include "TH2.h"
51 #include "TProfile.h"
52 #include "TNtuple.h"
53 #include "TRandom.h"
54 #include "TLorentzVector.h"
55 #include "TUnixSystem.h"
56 #include "TSystem.h"
57 #include "TMath.h"
58 #include "TF1.h"
59 
60 
61 #include <TObjArray.h>
62 #include <TObjString.h>
63 #include <TNamed.h>
64 
65 
66 class BscAnalysisHistManager : public TNamed {
67  public:
68 
69  BscAnalysisHistManager(const TString& managername);
71 
72  TH1F* GetHisto(Int_t Number);
73  TH1F* GetHisto(const TObjString& histname);
74 
75  TH2F* GetHisto2(Int_t Number);
76  TH2F* GetHisto2(const TObjString& histname);
77 
78  void WriteToFile(const TString& fOutputFile,const TString& fRecreateFile);
79 
80  private:
81 
82  void BookHistos();
83  void StoreWeights();
84  void HistInit(const char* name, const char* title, Int_t nbinsx, Axis_t xlow, Axis_t xup);
85  void HistInit(const char* name, const char* title, Int_t nbinsx, Axis_t xlow, Axis_t xup, Int_t nbinsy, Axis_t ylow, Axis_t yup);
86 
87  const char* fTypeTitle;
88  TObjArray* fHistArray;
89  TObjArray* fHistNamesArray;
90 
91 };
92 
93 
94 class BscNumberingScheme;
95 
96 class BeginOfJob;
97 class BeginOfRun;
98 class EndOfRun;
99 class BeginOfEvent;
100 class EndOfEvent;
101 class BeginOfTrack;
102 class EndOfTrack;
103 class G4Step;
104 
105 /*
106 class ObserveBeginOfRun : private Observer<const BeginOfRun *>
107 {
108 public:
109  ObserveBeginOfRun();
110 private:
111  void update(const BeginOfRun * run);
112 };
113 
114 class ObserveEndOfRun : private Observer<const EndOfRun *>
115 {
116 public:
117  ObserveEndOfRun();
118 private:
119  void update(const EndOfRun * run);
120 };
121 
122 class ObserveBeginOfEvent : private Observer<const BeginOfEvent *>
123 {
124 public:
125  ObserveBeginOfEvent();
126 private:
127  void update(const BeginOfEvent * evt);
128 };
129 
130 class ObserveEndOfEvent : private Observer<const EndOfEvent *>
131 {
132 public:
133  ObserveEndOfEvent();
134 private:
135  void update(const EndOfEvent * evt);
136  // std::vector<BscG4Hit> theStripHits;
137 };
138 
139 class ObserveBeginOfTrack : private Observer<const BeginOfTrack *>
140 {
141 public:
142  ObserveBeginOfTrack();
143 private:
144  void update(const BeginOfTrack * trk);
145 };
146 
147 class ObserveEndOfTrack : private Observer<const EndOfTrack *>
148 {
149 public:
150  ObserveEndOfTrack();
151 private:
152  void update(const EndOfTrack * trk);
153 };
154 
155 class ObserveStep : private Observer<const G4Step *>
156 {
157 public:
158  ObserveStep();
159 private:
160  void update(const G4Step * step);
161 };
162 */
163  //class BscTest: public SimProducer,
164 class BscTest : public SimWatcher,
165  public Observer<const BeginOfJob *>,
166  public Observer<const BeginOfRun *>,
167  public Observer<const EndOfRun *>,
168  public Observer<const BeginOfEvent *>,
169  public Observer<const BeginOfTrack *>,
170  public Observer<const G4Step *>,
171  public Observer<const EndOfTrack *>,
172  public Observer<const EndOfEvent *>
173 {
174 public:
175  BscTest(const edm::ParameterSet &p);
176  virtual ~BscTest();
177  //MyActions();
178  //MyActions();
179 private:
180 
181  // observer classes
182  void update(const BeginOfJob * run);
183  void update(const BeginOfRun * run);
184  void update(const EndOfRun * run);
185  void update(const BeginOfEvent * evt);
186  void update(const BeginOfTrack * trk);
187  void update(const G4Step * step);
188  void update(const EndOfTrack * trk);
189  void update(const EndOfEvent * evt);
190 
191 private:
192 
193  //UHB_Analysis* UserNtuples;
195 
196 
197  int iev;
198  int itrk;
199  G4double entot0, tracklength0;
200 
201 private:
202 // Utilities to get detector levels during a step
203 
204  int detLevels(const G4VTouchable*) const;
205  G4String detName(const G4VTouchable*, int, int) const;
206  void detectorLevel(const G4VTouchable*, int&, int*, G4String*) const;
207 
208 
209  double rinCalo, zinCalo;
212 
213  // SumEnerDeposit - all deposited energy on all steps ; SumStepl - length in steel !!!
215  // numofpart - # particles produced along primary track
217  // last point of the primary track
218  G4ThreeVector lastpo;
219 
220 
221  // z:
222  double z1, z2, z3, z4;
223 
224 private:
225 
226  Float_t bsceventarray[1];
227  TNtuple* bsceventntuple;
230 
231  BscAnalysisHistManager* TheHistManager; //Histogram Manager of the analysis
232  std::string fDataLabel; // Data type label
233  std::string fOutputFile; // The output file name
234  std::string fRecreateFile; // Recreate the file flag, default="RECREATE"
235 
236  // // // // // // TObjString fHistType;
237 // TString fDataLabel; // Data type label
238 // TString fOutputFile; // The output file name
239 // TString fRecreateFile; // Recreate the file flag, default="RECREATE"
240 
241 };
242 
243 #endif
244 
245 
246 
247 
248 
249 
250 
251 
252 
int numofpart
Definition: BscTest.h:216
double z2
Definition: BscTest.h:222
G4double SumStepl
Definition: BscTest.h:214
double z1
Definition: BscTest.h:222
TH1F * GetHisto(Int_t Number)
Definition: BscTest.cc:209
int detLevels(const G4VTouchable *) const
Definition: BscTest.cc:558
std::string fOutputFile
Definition: BscTest.h:233
TH2F * GetHisto2(Int_t Number)
Definition: BscTest.cc:228
G4ThreeVector lastpo
Definition: BscTest.h:218
TObjArray * fHistNamesArray
Definition: BscTest.h:89
int iev
Definition: BscTest.h:197
G4String detName(const G4VTouchable *, int, int) const
Definition: BscTest.cc:568
TObjArray * fHistArray
Definition: BscTest.h:88
std::string fRecreateFile
Definition: BscTest.h:234
double rinCalo
Definition: BscTest.h:209
int verbosity
Definition: BscTest.h:211
double z4
Definition: BscTest.h:222
const char * fTypeTitle
Definition: BscTest.h:87
int whichevent
Definition: BscTest.h:229
void WriteToFile(const TString &fOutputFile, const TString &fRecreateFile)
Definition: BscTest.cc:163
std::string fDataLabel
Definition: BscTest.h:232
G4double entot0
Definition: BscTest.h:199
void HistInit(const char *name, const char *title, Int_t nbinsx, Axis_t xlow, Axis_t xup)
Definition: BscTest.cc:179
BscAnalysisHistManager * TheHistManager
Definition: BscTest.h:231
double z3
Definition: BscTest.h:222
G4double SumEnerDeposit
Definition: BscTest.h:214
BscTest(const edm::ParameterSet &p)
Definition: BscTest.cc:58
double zinCalo
Definition: BscTest.h:209
BscNumberingScheme * theBscNumberingScheme
Definition: BscTest.h:194
TNtuple * bsceventntuple
Definition: BscTest.h:227
int lastTrackID
Definition: BscTest.h:210
void detectorLevel(const G4VTouchable *, int &, int *, G4String *) const
Definition: BscTest.cc:580
int itrk
Definition: BscTest.h:198
void update(const BeginOfJob *run)
This routine will be called when the appropriate signal arrives.
Definition: BscTest.cc:276
Float_t bsceventarray[1]
Definition: BscTest.h:226
G4double SumStepc
Definition: BscTest.h:214
TFile bscOutputFile
Definition: BscTest.h:228
BscAnalysisHistManager(const TString &managername)
Definition: BscTest.cc:117
virtual ~BscTest()
Definition: BscTest.cc:86
G4double tracklength0
Definition: BscTest.h:199