CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

GflashG4Watcher Class Reference

#include <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 BeginOfEvent *)
 This routine will be called when the appropriate signal arrives.
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.

Private Attributes

TH1F * eb_hit_lat
TH1F * eb_hit_lat_sd
TH1F * eb_hit_long
TH1F * eb_hit_long_sd
TH2F * eb_hit_rz
TH2F * eb_hit_rz_sd
TH1F * eb_ssp_rho
TH1F * ee_hit_lat
TH1F * ee_hit_lat_sd
TH1F * ee_hit_long
TH1F * ee_hit_long_sd
TH2F * ee_hit_rz
TH2F * ee_hit_rz_sd
TH1F * ee_ssp_z
TH1F * em_incE
TH1F * em_vtx_rho
TH1F * em_vtx_z
TFile * histFile_
std::string histFileName_
G4ThreeVector inc_direction
G4double inc_energy
G4bool inc_flag
G4ThreeVector inc_position
G4ThreeVector inc_vertex
G4double out_energy
double recoEnergyScaleEB_
double recoEnergyScaleEE_

Detailed Description

Definition at line 22 of file GflashG4Watcher.h.


Constructor & Destructor Documentation

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

Definition at line 21 of file GflashG4Watcher.cc.

References eb_hit_lat, eb_hit_lat_sd, eb_hit_long, eb_hit_long_sd, eb_hit_rz, eb_hit_rz_sd, eb_ssp_rho, ee_hit_lat, ee_hit_lat_sd, ee_hit_long, ee_hit_long_sd, ee_hit_rz, ee_hit_rz_sd, ee_ssp_z, em_incE, em_vtx_rho, em_vtx_z, edm::ParameterSet::getParameter(), histFile_, histFileName_, recoEnergyScaleEB_, and recoEnergyScaleEE_.

                                                         {

  edm::ParameterSet myP = p.getParameter<edm::ParameterSet>("GflashG4Watcher");
  histFileName_ = myP.getParameter<std::string>("histFileName");
  recoEnergyScaleEB_ = myP.getParameter<double>("recoEnergyScaleEB");
  recoEnergyScaleEE_ = myP.getParameter<double>("recoEnergyScaleEE");


  histFile_ = new TFile(histFileName_.c_str(),"RECREATE");

  TH1::AddDirectory(kTRUE);


  em_incE        = new TH1F("em_incE","Incoming energy at Ecal;E (GeV);Number of Events",500,0.0,500.0);
  em_vtx_rho     = new TH1F("em_vtx_rho","vertex position;#rho (cm);Number of Events",100,0.0,10.0);
  em_vtx_z       = new TH1F("em_vtx_z","vertex position;z (cm);Number of Events",100,-10.0,10.0);

  eb_ssp_rho     = new TH1F("eb_ssp_rho","Shower starting position;#rho (cm);Number of Events",200,0.0,200.0);
  eb_hit_long    = new TH1F("eb_hit_long","longitudinal hit position;shower depth (cm);Number of energy weighted hits",400,0.0,200.0);
  eb_hit_lat     = new TH1F("eb_hit_lat","lateral hit position;arm (cm);Number of energy weighted hits",100,0.0,5.0);
  eb_hit_rz      = new TH2F("eb_hit_rz","hit position along the shower direction;shower depth (cm);arm (cm)",400,0.0,200.0,100,0.0,5.0);
  eb_hit_long_sd = new TH1F("eb_hit_long_sd","longitudinal hit position in Sensitive Detector;shower depth (cm);Number of energy weighted hits",400,0.0,200.0);
  eb_hit_lat_sd  = new TH1F("eb_hit_lat_sd","lateral hit position in Sensitive Detector;arm (cm);Number of energy weighted hits",100,0.0,5.0);
  eb_hit_rz_sd   = new TH2F("eb_hit_rz_sd","hit position along the shower direction in Sensitive Detector;shower depth (cm);arm (cm)",400,0.0,200.0,100,0.0,5.0);

  ee_ssp_z       = new TH1F("ee_ssp_z","Shower starting position;z (cm);Number of Events",800,-400.0,400.0);
  ee_hit_long    = new TH1F("ee_hit_long","longitudinal hit position;shower depth (cm);Number of energy weighted hits",800,0.0,400.0);
  ee_hit_lat     = new TH1F("ee_hit_lat","lateral hit position;arm (cm);Number of energy weighted hits",100,0.0,5.0);
  ee_hit_rz      = new TH2F("ee_hit_rz","hit position along the shower direction;shower depth (cm);arm (cm)",800,0.0,400.0,100,0.0,5.0);
  ee_hit_long_sd = new TH1F("ee_hit_long_sd","longitudinal hit position in Sensitive Detector;shower depth (cm);Number of energy weighted hits",800,0.0,400.0);
  ee_hit_lat_sd  = new TH1F("ee_hit_lat_sd","lateral hit position in Sensitive Detector;arm (cm);Number of energy weighted hits",100,0.0,5.0);
  ee_hit_rz_sd   = new TH2F("ee_hit_rz_sd","hit position along the shower direction in Sensitive Detector;shower depth (cm);arm (cm)",800,0.0,400.0,100,0.0,5.0);

}
GflashG4Watcher::~GflashG4Watcher ( )

Definition at line 57 of file GflashG4Watcher.cc.

References histFile_.

                                  {
  histFile_->cd();
  histFile_->Write();
  histFile_->Close();
}

Member Function Documentation

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

This routine will be called when the appropriate signal arrives.

Implements Observer< const BeginOfEvent * >.

Definition at line 64 of file GflashG4Watcher.cc.

References abs, eb_ssp_rho, ee_ssp_z, em_incE, em_vtx_rho, em_vtx_z, inc_direction, inc_energy, inc_flag, inc_position, inc_vertex, and out_energy.

                                                       {

  inc_flag = false;

  const G4Event* evt = (*g4Event)();
  inc_vertex = evt->GetPrimaryVertex(0)->GetPosition();
  inc_position = inc_vertex;
  inc_direction = evt->GetPrimaryVertex(0)->GetPrimary(0)->GetMomentum().unit();
  inc_energy = evt->GetPrimaryVertex(0)->GetPrimary(0)->GetMomentum().mag();
  out_energy = 0;

  em_incE->Fill(inc_energy/GeV);
  em_vtx_rho->Fill(inc_vertex.rho()/cm);
  em_vtx_z->Fill(inc_vertex.z()/cm);

  if(std::abs(inc_direction.eta()) < 1.5) eb_ssp_rho->Fill(inc_position.rho()/cm);
  else ee_ssp_z->Fill(inc_position.z()/cm);

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

This routine will be called when the appropriate signal arrives.

Implements Observer< const G4Step * >.

Definition at line 88 of file GflashG4Watcher.cc.

References abs, angle(), funct::cos(), diffTreeTool::diff, eb_hit_lat, eb_hit_lat_sd, eb_hit_long, eb_hit_long_sd, eb_hit_rz, eb_hit_rz_sd, ee_hit_lat, ee_hit_lat_sd, ee_hit_long, ee_hit_long_sd, ee_hit_rz, ee_hit_rz_sd, inc_direction, inc_position, NULL, out_energy, recoEnergyScaleEB_, recoEnergyScaleEE_, and funct::sin().

                                               {

  if(aStep == NULL) return;

  double hitEnergy = aStep->GetTotalEnergyDeposit();

  if(hitEnergy < 1.0e-6) return;

  bool inEB = std::abs(inc_direction.eta()) < 1.5;

  out_energy += hitEnergy; // to check outgoing energy

  // This is to calculate shower depth and arm of hits from the shower direction
  G4ThreeVector hitPosition = aStep->GetPreStepPoint()->GetPosition();
  G4ThreeVector diff = hitPosition - inc_position;
  double angle = diff.angle(inc_direction);
  double diff_z = std::abs(diff.mag() * std::cos(angle));
  double diff_r = std::abs(diff.mag() * std::sin(angle));

  G4VSensitiveDetector* aSensitive = aStep->GetPreStepPoint()->GetSensitiveDetector();

  if(inEB){ // showers in barrel crystals
    hitEnergy *= recoEnergyScaleEB_;
    eb_hit_long->Fill(diff_z/cm,hitEnergy/GeV);
    eb_hit_lat->Fill(diff_r/cm,hitEnergy/GeV);
    eb_hit_rz->Fill(diff_z/cm,diff_r/cm,hitEnergy/GeV);
    if(aSensitive){
      eb_hit_long_sd->Fill(diff_z/cm,hitEnergy/GeV);
      eb_hit_lat_sd->Fill(diff_r/cm,hitEnergy/GeV);
      eb_hit_rz_sd->Fill(diff_z/cm,diff_r/cm,hitEnergy/GeV);
    }
  }
  else{ // showers in endcap crystals
    hitEnergy *= recoEnergyScaleEE_;
    ee_hit_long->Fill(diff_z/cm,hitEnergy/GeV);
    ee_hit_lat->Fill(diff_r/cm,hitEnergy/GeV);
    ee_hit_rz->Fill(diff_z/cm,diff_r/cm,hitEnergy/GeV);
    if(aSensitive){
      ee_hit_long_sd->Fill(diff_z/cm,hitEnergy/GeV);
      ee_hit_lat_sd->Fill(diff_r/cm,hitEnergy/GeV);
      ee_hit_rz_sd->Fill(diff_z/cm,diff_r/cm,hitEnergy/GeV);
    }
  }


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

This routine will be called when the appropriate signal arrives.

Implements Observer< const EndOfEvent * >.

Definition at line 85 of file GflashG4Watcher.cc.

{ }

Member Data Documentation

TH1F* GflashG4Watcher::eb_hit_lat [private]

Definition at line 58 of file GflashG4Watcher.h.

Referenced by GflashG4Watcher(), and update().

Definition at line 61 of file GflashG4Watcher.h.

Referenced by GflashG4Watcher(), and update().

Definition at line 57 of file GflashG4Watcher.h.

Referenced by GflashG4Watcher(), and update().

Definition at line 60 of file GflashG4Watcher.h.

Referenced by GflashG4Watcher(), and update().

TH2F* GflashG4Watcher::eb_hit_rz [private]

Definition at line 59 of file GflashG4Watcher.h.

Referenced by GflashG4Watcher(), and update().

Definition at line 62 of file GflashG4Watcher.h.

Referenced by GflashG4Watcher(), and update().

TH1F* GflashG4Watcher::eb_ssp_rho [private]

Definition at line 56 of file GflashG4Watcher.h.

Referenced by GflashG4Watcher(), and update().

TH1F* GflashG4Watcher::ee_hit_lat [private]

Definition at line 66 of file GflashG4Watcher.h.

Referenced by GflashG4Watcher(), and update().

Definition at line 69 of file GflashG4Watcher.h.

Referenced by GflashG4Watcher(), and update().

Definition at line 65 of file GflashG4Watcher.h.

Referenced by GflashG4Watcher(), and update().

Definition at line 68 of file GflashG4Watcher.h.

Referenced by GflashG4Watcher(), and update().

TH2F* GflashG4Watcher::ee_hit_rz [private]

Definition at line 67 of file GflashG4Watcher.h.

Referenced by GflashG4Watcher(), and update().

Definition at line 70 of file GflashG4Watcher.h.

Referenced by GflashG4Watcher(), and update().

TH1F* GflashG4Watcher::ee_ssp_z [private]

Definition at line 64 of file GflashG4Watcher.h.

Referenced by GflashG4Watcher(), and update().

TH1F* GflashG4Watcher::em_incE [private]

Definition at line 52 of file GflashG4Watcher.h.

Referenced by GflashG4Watcher(), and update().

TH1F* GflashG4Watcher::em_vtx_rho [private]

Definition at line 53 of file GflashG4Watcher.h.

Referenced by GflashG4Watcher(), and update().

TH1F* GflashG4Watcher::em_vtx_z [private]

Definition at line 54 of file GflashG4Watcher.h.

Referenced by GflashG4Watcher(), and update().

TFile* GflashG4Watcher::histFile_ [private]

Definition at line 50 of file GflashG4Watcher.h.

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

std::string GflashG4Watcher::histFileName_ [private]

Definition at line 46 of file GflashG4Watcher.h.

Referenced by GflashG4Watcher().

G4ThreeVector GflashG4Watcher::inc_direction [private]

Definition at line 37 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 38 of file GflashG4Watcher.h.

Referenced by update().

G4ThreeVector GflashG4Watcher::inc_vertex [private]

Definition at line 36 of file GflashG4Watcher.h.

Referenced by update().

G4double GflashG4Watcher::out_energy [private]

Definition at line 35 of file GflashG4Watcher.h.

Referenced by update().

Definition at line 47 of file GflashG4Watcher.h.

Referenced by GflashG4Watcher(), and update().

Definition at line 48 of file GflashG4Watcher.h.

Referenced by GflashG4Watcher(), and update().