CMS 3D CMS Logo

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