CMS 3D CMS Logo

GflashG4Watcher Class Reference

#include <SimG4Core/GFlash/interface/GflashG4Watcher.h>

Inheritance diagram for GflashG4Watcher:

SimWatcher Observer< const BeginOfEvent * > Observer< const EndOfEvent * > Observer< const G4Step * >

List of all members.

Public Member Functions

 GflashG4Watcher (const edm::ParameterSet &p)
 ~GflashG4Watcher ()

Private Member Functions

void update (const G4Step *)
 This routine will be called when the appropriate signal arrives.
void update (const EndOfEvent *)
 This routine will be called when the appropriate signal arrives.
void update (const BeginOfEvent *)
 This routine will be called when the appropriate signal arrives.

Private Attributes

GflashObjectgflashObject_
TFile * histFile_
std::string histFileName_
TH1F * hitEnergy_
G4ThreeVector inc_direction
G4double inc_energy
G4bool inc_flag
G4ThreeVector inc_position
TH1F * incEnergy_
TH1F * lateral_r_
TH1F * longitudinal_
TH1F * nHits_
TH1F * outEnergy_
TH2F * rzHits_
TH1F * showerStartingPosition_
TTree * watcherTree_


Detailed Description

Definition at line 22 of file GflashG4Watcher.h.


Constructor & Destructor Documentation

GflashG4Watcher::GflashG4Watcher ( const edm::ParameterSet p  ) 

Definition at line 22 of file GflashG4Watcher.cc.

References edm::ParameterSet::getParameter(), gflashObject_, histFile_, histFileName_, hitEnergy_, incEnergy_, lateral_r_, longitudinal_, nHits_, outEnergy_, rzHits_, showerStartingPosition_, and watcherTree_.

00022                                                          {
00023 
00024   edm::ParameterSet myP = p.getParameter<edm::ParameterSet>("GflashG4Watcher");
00025   histFileName_ = myP.getParameter<std::string>("histFileName");
00026   histFile_ = new TFile(histFileName_.c_str(),"RECREATE");
00027 
00028   TH1::AddDirectory(kTRUE);
00029 
00030   gflashObject_ = new GflashObject;
00031   watcherTree_ = new TTree("watcherTree","Watcher Tree Variable");
00032   watcherTree_->Branch("gflashObject","GflashObject",&gflashObject_,6400,99);
00033   watcherTree_->SetAutoSave();
00034 
00035   longitudinal_ = new TH1F("longitudinal","Logitudinal profile;X_{0};Energy",100,0.0,50.0);
00036   lateral_r_ = new TH1F("lateral_r","Lateral profile;r_{M};Number of hits",300,0.0,3.0);
00037   showerStartingPosition_ = new TH1F("showerStartingPosition","Shower starting position;r(cm);Number of hits",100,120.0,170.0);
00038   nHits_ = new TH1F("nHits","Number of hits;N_{hit};Events",30,4000.0,7000.0);
00039   hitEnergy_ = new TH1F("hitEnergy","Energy of hits;Energy (MeV);Number of hits",100,0.0,10.0);
00040   rzHits_ = new TH2F("rzHits","r vs. z of hits;z (X_{0});r_{M}",100,0.0,50.0,300,0.0,3.0);
00041   incEnergy_ = new TH1F("incEnergy","Incoming energy;energy (GeV);Events",100,0.0,100.0);
00042   outEnergy_ = new TH1F("outEnergy","Outgoing energy;energy (GeV);Events",100,0.0,100.0);
00043 
00044 }

GflashG4Watcher::~GflashG4Watcher (  ) 

Definition at line 47 of file GflashG4Watcher.cc.

References histFile_.

00047                                   {
00048   histFile_->cd();
00049   histFile_->Write();
00050   histFile_->Close();
00051 }


Member Function Documentation

void GflashG4Watcher::update ( const G4Step *   )  [private, virtual]

This routine will be called when the appropriate signal arrives.

Implements Observer< const G4Step * >.

Definition at line 108 of file GflashG4Watcher.cc.

References GflashHit::energy, gflashObject_, GflashObject::hits, inc_direction, inc_energy, inc_flag, inc_position, lv, NULL, and GflashHit::position.

00108                                                {
00109 
00110   if(aStep == NULL) return;
00111 
00112   if(inc_flag){
00113     if(aStep->GetTotalEnergyDeposit() > 1.0e-6){
00114       G4ThreeVector hitPosition = aStep->GetPreStepPoint()->GetPosition();
00115       GflashHit gHit;
00116       gHit.energy = aStep->GetTotalEnergyDeposit();
00117       gHit.position.SetXYZ(hitPosition.x(),hitPosition.y(),hitPosition.z());
00118       gflashObject_->hits.push_back(gHit);
00119     }
00120   }
00121   else {
00122     G4bool trigger = aStep->GetPreStepPoint()->GetKineticEnergy() > 1.0*GeV;
00123     trigger = trigger && (aStep->GetTrack()->GetDefinition() == G4Electron::ElectronDefinition() || 
00124                           aStep->GetTrack()->GetDefinition() == G4Positron::PositronDefinition());
00125 
00126     G4LogicalVolume* lv = aStep->GetPreStepPoint()->GetPhysicalVolume()->GetLogicalVolume();
00127     trigger = trigger && (lv->GetRegion()->GetName() == "GflashRegion");
00128 
00129     std::size_t pos1 = lv->GetName().find("EBRY");
00130     std::size_t pos2 = lv->GetName().find("EFRY");
00131     trigger = trigger && (pos1 != std::string::npos || pos2 != std::string::npos);
00132 
00133     if(trigger){
00134       inc_energy = aStep->GetPreStepPoint()->GetKineticEnergy();
00135       inc_direction = aStep->GetPreStepPoint()->GetMomentumDirection();
00136       inc_position = aStep->GetPreStepPoint()->GetPosition();
00137       inc_flag = true;
00138     }
00139   }
00140 
00141 }

void GflashG4Watcher::update ( const EndOfEvent  )  [private, virtual]

This routine will be called when the appropriate signal arrives.

Implements Observer< const EndOfEvent * >.

Definition at line 62 of file GflashG4Watcher.cc.

References funct::abs(), angle(), funct::cos(), diff, GflashObject::direction, GflashObject::energy, gflashObject_, hitEnergy_, GflashObject::hits, inc_direction, inc_energy, inc_flag, inc_position, incEnergy_, it, lateral_r_, longitudinal_, nHits_, outEnergy_, GflashObject::position, radLength, rMoliere, rzHits_, showerStartingPosition_, funct::sin(), funct::sqrt(), muonGeometry::TVector3(), and watcherTree_.

00062                                                      {
00063 
00064   if(!inc_flag) return;
00065 
00066   const G4Event* evt = (*g4Event)();
00067   double primP = evt->GetPrimaryVertex(0)->GetPrimary(0)->GetMomentum().mag();
00068   double primM = evt->GetPrimaryVertex(0)->GetPrimary(0)->GetMass();
00069   double primE = std::sqrt(primP*primP + primM+primM);
00070 
00071   incEnergy_->Fill(inc_energy/GeV);
00072 
00073   if(inc_energy < 0.95*primE) return;
00074 
00075 
00076   // Now fill GflashObject
00077 
00078   gflashObject_->energy = inc_energy;
00079   gflashObject_->direction.SetXYZ(inc_direction.x(),inc_direction.y(),inc_direction.z());
00080   gflashObject_->position.SetXYZ(inc_position.x(),inc_position.y(),inc_position.z());
00081   showerStartingPosition_->Fill(inc_position.rho()/cm);
00082 
00083 
00084   double outEnergy = 0.0;
00085 
00086   for(std::vector<GflashHit>::iterator it = gflashObject_->hits.begin();
00087       it != gflashObject_->hits.end(); it++){
00088     TVector3 diff = it->position - gflashObject_->position;
00089     double angle = diff.Angle(gflashObject_->direction);
00090     double diff_z = std::abs(diff.Mag()*std::cos(angle));
00091     double diff_r = std::abs(diff.Mag()*std::sin(angle));
00092 
00093     lateral_r_->Fill(diff_r/rMoliere,it->energy);
00094     rzHits_->Fill(diff_z/radLength,diff_r/rMoliere,it->energy);
00095     hitEnergy_->Fill(it->energy);
00096     longitudinal_->Fill(diff_z/radLength,it->energy);
00097 
00098     outEnergy += it->energy;
00099   }
00100 
00101   nHits_->Fill(gflashObject_->hits.size());
00102   outEnergy_->Fill(outEnergy/GeV);
00103 
00104   watcherTree_->Fill();
00105 
00106 }

void GflashG4Watcher::update ( const BeginOfEvent  )  [private, virtual]

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfEvent * >.

Definition at line 54 of file GflashG4Watcher.cc.

References gflashObject_, inc_direction, inc_energy, inc_flag, inc_position, and GflashObject::Init().

00054                                                        {
00055   inc_flag = false;
00056   inc_energy = 0;
00057   inc_direction *= 0;
00058   inc_position *= 0;
00059   gflashObject_->Init();
00060 }


Member Data Documentation

GflashObject* GflashG4Watcher::gflashObject_ [private]

Definition at line 47 of file GflashG4Watcher.h.

Referenced by GflashG4Watcher(), and update().

TFile* GflashG4Watcher::histFile_ [private]

Definition at line 45 of file GflashG4Watcher.h.

Referenced by GflashG4Watcher(), and ~GflashG4Watcher().

std::string GflashG4Watcher::histFileName_ [private]

Definition at line 44 of file GflashG4Watcher.h.

Referenced by GflashG4Watcher().

TH1F* GflashG4Watcher::hitEnergy_ [private]

Definition at line 53 of file GflashG4Watcher.h.

Referenced by GflashG4Watcher(), and update().

G4ThreeVector GflashG4Watcher::inc_direction [private]

Definition at line 35 of file GflashG4Watcher.h.

Referenced by update().

G4double GflashG4Watcher::inc_energy [private]

Definition at line 34 of file GflashG4Watcher.h.

Referenced by update().

G4bool GflashG4Watcher::inc_flag [private]

Definition at line 33 of file GflashG4Watcher.h.

Referenced by update().

G4ThreeVector GflashG4Watcher::inc_position [private]

Definition at line 36 of file GflashG4Watcher.h.

Referenced by update().

TH1F* GflashG4Watcher::incEnergy_ [private]

Definition at line 55 of file GflashG4Watcher.h.

Referenced by GflashG4Watcher(), and update().

TH1F* GflashG4Watcher::lateral_r_ [private]

Definition at line 50 of file GflashG4Watcher.h.

Referenced by GflashG4Watcher(), and update().

TH1F* GflashG4Watcher::longitudinal_ [private]

Definition at line 49 of file GflashG4Watcher.h.

Referenced by GflashG4Watcher(), and update().

TH1F* GflashG4Watcher::nHits_ [private]

Definition at line 52 of file GflashG4Watcher.h.

Referenced by GflashG4Watcher(), and update().

TH1F* GflashG4Watcher::outEnergy_ [private]

Definition at line 56 of file GflashG4Watcher.h.

Referenced by GflashG4Watcher(), and update().

TH2F* GflashG4Watcher::rzHits_ [private]

Definition at line 54 of file GflashG4Watcher.h.

Referenced by GflashG4Watcher(), and update().

TH1F* GflashG4Watcher::showerStartingPosition_ [private]

Definition at line 51 of file GflashG4Watcher.h.

Referenced by GflashG4Watcher(), and update().

TTree* GflashG4Watcher::watcherTree_ [private]

Definition at line 48 of file GflashG4Watcher.h.

Referenced by GflashG4Watcher(), and update().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:21:24 2009 for CMSSW by  doxygen 1.5.4