CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_2_9_HLT1_bphpatch4/src/SimG4CMS/FP420/interface/FP420Test.h

Go to the documentation of this file.
00001 #ifndef FP420Test_H
00002 #define FP420Test_H
00003 
00004 // system include files
00005 #include<vector>
00006 #include <iostream>
00007 #include <memory>
00008 #include <string>
00009 //
00010 // user include files
00011 #include "FWCore/Framework/interface/Frameworkfwd.h"
00012 #include "FWCore/Framework/interface/EDAnalyzer.h"
00013 #include "FWCore/Framework/interface/MakerMacros.h"
00014 
00015 // necessary objects:
00016 #include "FWCore/Framework/interface/ESHandle.h"
00017 
00018 //
00019 //
00020 #include "SimG4Core/Notification/interface/Observer.h"
00021 #include "SimG4Core/Notification/interface/BeginOfJob.h"
00022 #include "SimG4Core/Notification/interface/BeginOfRun.h"
00023 #include "SimG4Core/Notification/interface/EndOfRun.h"
00024 #include "SimG4Core/Notification/interface/BeginOfEvent.h"
00025 #include "SimG4Core/Notification/interface/EndOfEvent.h"
00026 #include "SimG4Core/Notification/interface/BeginOfTrack.h"
00027 #include "SimG4Core/Notification/interface/EndOfTrack.h"
00028 #include "SimG4Core/Watcher/interface/SimWatcher.h"
00029 //#include "SimG4Core/Watcher/interface/SimProducer.h"
00030 //#include "SimG4Core/Watcher/interface/SimWatcherMaker.h"
00031 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00032 
00033 #include "SimG4CMS/FP420/interface/FP420G4Hit.h"
00034 
00035 #include "G4VTouchable.hh"
00036 #include <map>
00037 #include <cmath>
00038 #include <CLHEP/Random/Randomize.h> 
00039 // #include <fstream>
00040 
00041 
00042 // ----------------------------------------------------------------
00043 // Includes needed for Root ntupling
00044 //
00045 #include "TROOT.h"
00046 #include "TFile.h"
00047 #include "TH1.h"
00048 #include "TH2.h"
00049 #include "TProfile.h"
00050 #include "TNtuple.h"
00051 #include "TRandom.h"
00052 #include "TLorentzVector.h"
00053 #include "TUnixSystem.h"
00054 #include "TSystem.h"
00055 #include "TMath.h"
00056 #include "TF1.h"
00057 
00058 
00059 #include <TObjArray.h>
00060 #include <TObjString.h>
00061 #include <TNamed.h>
00062 
00063 
00064 class Fp420AnalysisHistManager : public TNamed {
00065         public:
00066 
00067                 Fp420AnalysisHistManager(TString managername);
00068                 ~Fp420AnalysisHistManager();
00069 
00070                 TH1F* GetHisto(Int_t Number);
00071                 TH1F* GetHisto(const TObjString histname);
00072 
00073                 TH2F* GetHisto2(Int_t Number);
00074                 TH2F* GetHisto2(const TObjString histname);
00075 
00076                 void WriteToFile(TString fOutputFile,TString fRecreateFile);
00077 
00078         private:
00079 
00080                 void BookHistos();
00081                 void StoreWeights();
00082                 void HistInit(const char* name, const char* title, Int_t nbinsx, Axis_t xlow, Axis_t xup);
00083                 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);
00084 
00085                 const char* fTypeTitle;
00086                 TObjArray* fHistArray;
00087                 TObjArray* fHistNamesArray;
00088 
00089 };
00090 
00091 
00092 class FP420NumberingScheme;
00093 
00094 class BeginOfJob;
00095 class BeginOfRun;
00096 class EndOfRun;
00097 class BeginOfEvent;
00098 class EndOfEvent;
00099 class BeginOfTrack;
00100 class EndOfTrack;
00101 class G4Step;
00102 
00103 /*
00104 class ObserveBeginOfRun : private Observer<const BeginOfRun *> 
00105 {
00106 public:
00107     ObserveBeginOfRun();
00108 private:
00109     void update(const BeginOfRun * run);
00110 };
00111 
00112 class ObserveEndOfRun : private Observer<const EndOfRun *> 
00113 {
00114 public:
00115     ObserveEndOfRun();
00116 private:
00117     void update(const EndOfRun * run);
00118 };
00119 
00120 class ObserveBeginOfEvent : private Observer<const BeginOfEvent *> 
00121 {
00122 public:
00123     ObserveBeginOfEvent();
00124 private:
00125     void update(const BeginOfEvent * evt);
00126 };
00127 
00128 class ObserveEndOfEvent : private Observer<const EndOfEvent *> 
00129 {
00130 public:
00131     ObserveEndOfEvent();
00132 private:
00133     void update(const EndOfEvent * evt);
00134     //    std::vector<FP420G4Hit> theStripHits;
00135 };
00136 
00137 class ObserveBeginOfTrack : private Observer<const BeginOfTrack *> 
00138 {
00139 public:
00140     ObserveBeginOfTrack();
00141 private:
00142     void update(const BeginOfTrack * trk);
00143 };
00144 
00145 class ObserveEndOfTrack : private Observer<const EndOfTrack *> 
00146 {
00147 public:
00148     ObserveEndOfTrack();
00149 private:
00150     void update(const EndOfTrack * trk);
00151 };
00152 
00153 class ObserveStep : private Observer<const G4Step *> 
00154 {
00155 public:
00156     ObserveStep();
00157 private:
00158     void update(const G4Step * step);
00159 };
00160 */
00161                     //class FP420Test: public SimProducer,
00162 class FP420Test : public SimWatcher,
00163   public Observer<const BeginOfJob *>, 
00164   public Observer<const BeginOfRun *>,
00165   public Observer<const EndOfRun *>,
00166   public Observer<const BeginOfEvent *>,
00167   public Observer<const BeginOfTrack *>,
00168   public Observer<const G4Step *>,
00169   public Observer<const EndOfTrack *>,
00170   public Observer<const EndOfEvent *>
00171 {
00172 public:
00173   FP420Test(const edm::ParameterSet &p);
00174   virtual ~FP420Test();
00175   //MyActions();
00176   //MyActions();
00177 private:
00178 
00179   // observer classes
00180   void update(const BeginOfJob * run);
00181   void update(const BeginOfRun * run);
00182   void update(const EndOfRun * run);
00183   void update(const BeginOfEvent * evt);
00184   void update(const BeginOfTrack * trk);
00185   void update(const G4Step * step);
00186   void update(const EndOfTrack * trk);
00187   void update(const EndOfEvent * evt);
00188 
00189 private:
00190 
00191   //UHB_Analysis* UserNtuples;
00192   FP420NumberingScheme * theFP420NumberingScheme;
00193 
00194 
00195   int iev;
00196   int itrk;
00197   G4double entot0, tracklength0;
00198 
00199 private:
00200 // Utilities to get detector levels during a step
00201 
00202   int      detLevels(const G4VTouchable*) const;
00203   G4String  detName(const G4VTouchable*, int, int) const;
00204   void     detectorLevel(const G4VTouchable*, int&, int*, G4String*) const;
00205 
00206 
00207  double rinCalo, zinCalo;
00208  int    lastTrackID;
00209  int verbosity;
00210 
00211  // SumEnerDeposit - all deposited energy on all steps ;  SumStepl - length in steel !!!
00212  G4double      SumEnerDeposit, SumStepl, SumStepc;
00213  // numofpart - # particles produced along primary track
00214  int          numofpart;
00215  // last point of the primary track
00216  G4ThreeVector  lastpo;
00217 
00218 
00219  // z:
00220  double z1, z2, z3, z4, zD2, zD3; 
00221  int sn0, dn0, pn0, rn0;
00222  int rn00;
00223  double ZSiDet, z420;
00224  double ZGapLDet, ZBoundDet, ZSiStep, ZSiPlane, zinibeg;
00225  double  zBlade, gapBlade;
00226 
00227 private:
00228 
00229   Float_t fp420eventarray[1];
00230   TNtuple* fp420eventntuple;
00231   TFile fp420OutputFile;
00232   int whichevent;
00233 
00234   Fp420AnalysisHistManager* TheHistManager;  //Histogram Manager of the analysis
00235   std::string fDataLabel;             // Data type label
00236   std::string fOutputFile;            // The output file name
00237   std::string fRecreateFile;          // Recreate the file flag, default="RECREATE"
00238 
00239   //  //  //  //  //  //  TObjString fHistType;
00240 //   TString fDataLabel;             // Data type label
00241 //   TString fOutputFile;            // The output file name
00242 //   TString fRecreateFile;          // Recreate the file flag, default="RECREATE"
00243 
00244 };
00245 
00246 #endif
00247 
00248 
00249 
00250 
00251 
00252 
00253 
00254 
00255