Skip to content
Snippets Groups Projects
Commit 067234ee authored by LEMAIR Louis's avatar LEMAIR Louis
Browse files

* Adding new scorers for Nebula plastic bars

  - For now only a copy of CalorimeterScorers
  - Adapted CMakeLists.txt
parent 5fad7c31
No related branches found
No related tags found
No related merge requests found
add_library(NPSScorers SHARED CylinderTPCScorers.cc DriftChamberScorers.cc NPSHitsMap.hh CalorimeterScorers.cc InteractionScorers.cc DSSDScorers.cc SiliconScorers.cc PhotoDiodeScorers.cc ObsoleteGeneralScorers.cc DriftElectronScorers.cc TPCScorers.cc MDMScorer.cc NeutronDetectorScorers.cc ProcessScorers.cc)
add_library(NPSScorers SHARED CylinderTPCScorers.cc DriftChamberScorers.cc NPSHitsMap.hh CalorimeterScorers.cc InteractionScorers.cc DSSDScorers.cc SiliconScorers.cc PhotoDiodeScorers.cc ObsoleteGeneralScorers.cc DriftElectronScorers.cc TPCScorers.cc MDMScorer.cc NeutronDetectorScorers.cc ProcessScorers.cc PlasticBar.cc)
target_link_libraries(NPSScorers ${ROOT_LIBRARIES} ${Geant4_LIBRARIES} ${NPLib_LIBRARIES} -lNPInitialConditions -lNPInteractionCoordinates)
/*****************************************************************************
* Copyright (C) 2009-2016 this file is part of the NPTool Project *
* *
* For the licensing terms see $NPTOOL/Licence/NPTool_Licence *
* For the list of contributors see $NPTOOL/Licence/Contributors *
*****************************************************************************/
/*****************************************************************************
* Original Author: Adrien MATTA contact address: matta@lpccaen.in2p3.fr *
* *
* Creation Date : February 2013 *
* Last update : *
*---------------------------------------------------------------------------*
* Decription: *
* File old the scorer specific to the Sharc Detector *
* *
*---------------------------------------------------------------------------*
* Comment: *
* This new type of scorer is aim to become the standard for DSSD,SSSD and *
* PAD detector (any Silicon Detector) *
*****************************************************************************/
#include "PlasticBar.hh"
#include "G4UnitsTable.hh"
using namespace PlasticBar;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
unsigned int
PlasticBarData::CalculateIndex(const vector<unsigned int>& level) {
unsigned int size = level.size();
unsigned int result = 0;
unsigned int multiplier = 1;
for (unsigned int i = 0; i < size; i++) {
result += level[i] * multiplier;
multiplier *= 1000;
}
return result;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
vector<PlasticBarData>::iterator
PlasticBarDataVector::find(const unsigned int& index) {
for (vector<PlasticBarData>::iterator it = m_Data.begin();
it != m_Data.end(); it++) {
if ((*it).GetIndex() == index)
return it;
}
return m_Data.end();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
PS_PlasticBar::PS_PlasticBar(G4String name, vector<G4int> NestingLevel,
G4int depth)
: G4VPrimitiveScorer(name, depth) {
m_NestingLevel = NestingLevel;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
PS_PlasticBar::~PS_PlasticBar() {}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4bool PS_PlasticBar::ProcessHits(G4Step* aStep, G4TouchableHistory*) {
G4String particlename
= aStep->GetTrack()->GetParticleDefinition()->GetParticleName();
cout << particlename << " has left ";
// Contain Energy, Time + as many copy number as nested volume
unsigned int mysize = m_NestingLevel.size();
t_Energy = aStep->GetTotalEnergyDeposit();
cout << t_Energy << " MeV";
t_Time = aStep->GetPreStepPoint()->GetGlobalTime();
cout << " after " << t_Time << " ms" << endl;
t_Level.clear();
for (unsigned int i = 0; i < mysize; i++) {
t_Level.push_back(
aStep->GetPreStepPoint()->GetTouchableHandle()->GetCopyNumber(
m_NestingLevel[i]));
}
// Check if the particle has interact before, if yes, add up the energies.
vector<PlasticBarData>::iterator it;
it = m_Data.find(PlasticBarData::CalculateIndex(t_Level));
if (it != m_Data.end()) {
it->Add(t_Energy);
} else {
m_Data.Set(t_Energy, t_Time, t_Level);
}
return TRUE;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void PS_PlasticBar::Initialize(G4HCofThisEvent*) { clear(); }
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void PS_PlasticBar::EndOfEvent(G4HCofThisEvent*) {}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void PS_PlasticBar::clear() {
m_Data.clear();
t_Level.clear();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void PS_PlasticBar::DrawAll() {}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void PS_PlasticBar::PrintAll() {}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#ifndef PlasticBar_h
#define PlasticBar_h 1
/*****************************************************************************
* Copyright (C) 2009-2016 this file is part of the NPTool Project *
* *
* For the licensing terms see $NPTOOL/Licence/NPTool_Licence *
* For the list of contributors see $NPTOOL/Licence/Contributors *
*****************************************************************************/
/*****************************************************************************
* Original Author: Adrien MATTA contact address: matta@lpccaen.in2p3.fr *
* *
* Creation Date : February 2013 *
* Last update : *
*---------------------------------------------------------------------------*
* Decription: *
* File old the scorer specific to the Silicon Detector *
* *
*---------------------------------------------------------------------------*
* Comment: *
* This new style of scorer is aim to become the standard way of doing scorer*
* in NPTool. *
*The index is build using the TrackID, Detector Number and Strip Number. *
*The scorer Hold Energy and time together *
*Only one scorer is needed for a detector *
*****************************************************************************/
#include "G4VPrimitiveScorer.hh"
#include "NPSHitsMap.hh"
//#include "NPSecondaries.hh"
#include <map>
using namespace std;
using namespace CLHEP;
namespace PlasticBar {
// Hold One hit info
class PlasticBarData{
public:
PlasticBarData(const double& Energy,const double& Time,const vector<unsigned int>& Nesting){
m_Index=CalculateIndex(Nesting);
m_Level=Nesting;
m_Energy=Energy;
m_Time=Time;
};
~PlasticBarData(){};
private:
unsigned int m_Index;
vector<unsigned int> m_Level;
double m_Energy;
double m_Time;
public:
static unsigned int CalculateIndex(const vector<unsigned int>& Nesting);
public:
inline unsigned int GetIndex() const {return m_Index;}
inline vector<unsigned int> GetLevel() const {return m_Level;};
inline double GetEnergy() const {return m_Energy;};
inline double GetTime() const {return m_Time;};
public:
void Add(const double& Energy) {m_Energy+=Energy;};
};
// Manage a vector of DSSD hit
class PlasticBarDataVector{
public:
PlasticBarDataVector(){};
~PlasticBarDataVector(){};
private:
vector<PlasticBarData> m_Data;
public:
vector<PlasticBarData>::iterator find(const unsigned int& index) ;
inline void clear(){m_Data.clear();} ;
inline vector<PlasticBarData>::iterator end() {return m_Data.end();};
inline vector<PlasticBarData>::iterator begin() {return m_Data.begin();};
inline unsigned int size() {return m_Data.size();};
inline void Add(const unsigned int& index,const double& Energy) {find(index)->Add(Energy);};
inline void Set(const double& Energy, const double& Time, const vector<unsigned int>& Nesting) {m_Data.push_back(PlasticBarData(Energy,Time,Nesting));};
PlasticBarData* operator[](const unsigned int& i){return &m_Data[i];};
};
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
class PS_PlasticBar : public G4VPrimitiveScorer{
public: // with description
PS_PlasticBar(G4String name, vector<G4int> NestingLevel,G4int depth=0);
~PS_PlasticBar();
protected: // with description
G4bool ProcessHits(G4Step*, G4TouchableHistory*);
public:
void Initialize(G4HCofThisEvent*);
void EndOfEvent(G4HCofThisEvent*);
void clear();
void DrawAll();
void PrintAll();
private: // How much level of volume nesting should be considered
// Give the list of the nesting level at which the copy number should be return.
// 0 is the lowest level possible (the actual volume copy number in which the interaction happen)
vector<G4int> m_NestingLevel;
private:
PlasticBarDataVector m_Data;
double t_Energy;
double t_Time;
vector<unsigned int> t_Level;
double t_ParticleMultiplicity;
public:
inline unsigned int GetMult() {return m_Data.size();};
inline double GetEnergy(const unsigned int& i) {return m_Data[i]->GetEnergy();};
inline double GetTime(const unsigned int& i) {return m_Data[i]->GetTime();};
inline vector<unsigned int> GetLevel(const unsigned int& i) {return m_Data[i]->GetLevel();};
};
}
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment