CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_0/src/SimG4CMS/Forward/interface/BscTest.h

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