CMS 3D CMS Logo

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

Generated on Tue Jun 9 17:46:54 2009 for CMSSW by  doxygen 1.5.4