///////////////////////////////////////////////////////////////////////////////
/// \file scintillation.cc
///
/// \brief Extracts the scintillation photon properties
///
/// \author P G Jones
///
/// REVISION HISTORY:\n
/// 2014-07-22 : P G Jones - Moved to rat-tools validation.\n
/// 2016-10-19 : M Stringer - Changes to how MCTracks are accessed (PR #1508).
// 2018-02-10 : R Lane - change to function arguments necessary for ROOT 6 compatibility
///
/// \details The number, wavelength direction and time of emission are compared
///
///////////////////////////////////////////////////////////////////////////////
#include
#include
#include
#include
#include
#include
#include
void scintillation(std::string event_file, std::string outfile)
{
RAT::DU::DSReader* dsReader = new RAT::DU::DSReader(event_file);
TFile *outtfile = new TFile(outfile.c_str(),"RECREATE");
TH1D* hNum = new TH1D( "Num", "Number of emitted photons", 30, 9000.0, 12000.0 );
hNum->SetXTitle( "Number of photons per event." );
hNum->SetYTitle( "Count per 100 photon bin." );
TH1D* hWave = new TH1D( "Wave", "Wavelength of emitted photons", 80, 100.0, 900.0 );
hWave->SetXTitle( "Wavelength nm." );
hWave->SetYTitle( "Count per 10nm bin." );
TH1D* hDir = new TH1D( "Dir", "Direction of emitted photons relative to initial electron", 10, -1.0, 1.0 );
hDir->SetXTitle( "cos(#theta)." );
hDir->SetYTitle( "Count per 0.1 cos(#theta) bin." );
TH1D* hTime = new TH1D( "Time", "Time of photon emission", 50, 0.0, 500.0 );
hTime->SetXTitle( "Emission time ns." );
hTime->SetYTitle( "Count per 10 ns bin." );
for( size_t iEntry = 0; iEntry < dsReader->GetEntryCount(); iEntry++ )
{
const RAT::DS::Entry& rDS = dsReader->GetEntry( iEntry );
const RAT::DS::MC& rMC = rDS.GetMC();
std::vector mcTrackIDs = rMC.GetMCTrackIDs();
const TVector3 initialDir = rMC.GetMCParticle( 0 ).GetMomentum().Unit();
int numPhotons = 0;
for( size_t iMCTrack = 0; iMCTrack < mcTrackIDs.size(); iMCTrack++ )
{
const RAT::DS::MCTrack& rMCTrack = rMC.GetMCTrack( mcTrackIDs.at(iMCTrack) );
if( rMCTrack.GetPDGCode() != 0 ) // Optical photon is 0
continue; // Only want optical photon tracks
const RAT::DS::MCTrackStep& initialStep = rMCTrack.GetMCTrackStep( 0 );
if( initialStep.GetProcess() != string( "Scintillation" ) )
continue; // Only want Cerenkov photons
numPhotons++;
hWave->Fill( 0.001242375 / initialStep.GetKineticEnergy() ); // MeV to nm
hDir->Fill( initialStep.GetMomentum().Unit().Dot( initialDir ) );
hTime->Fill( initialStep.GetGlobalTime() );
}
hNum->Fill( numPhotons );
}
outtfile->cd();
hNum->Write();
hWave->Write();
hDir->Write();
hTime->Write();
outtfile->Close();
delete outtfile;
delete dsReader;
}