Skip to content
Snippets Groups Projects
Commit fccce220 authored by Adrien Matta's avatar Adrien Matta :skull_crossbones:
Browse files

* Adding new Silicon Scorer based on png images to set the strip number

        - allow arbitrary geometry
        - can be used to simulate interstrip and dead layer
        - Use a base class NPImage to manage the image information
        - switch must2 to new scorers
        - fix must2 limitation to event with less particle than
          telescope (issue #17)
parent ed0c5898
No related branches found
No related tags found
No related merge requests found
Showing
with 926 additions and 565 deletions
...@@ -42,7 +42,7 @@ ETOF->Draw("same"); ...@@ -42,7 +42,7 @@ ETOF->Draw("same");
// Kinematical Line // // Kinematical Line //
c1->cd(3); c1->cd(3);
//chain->Draw("ELab:ThetaLab>>hKine(500,0,45,400,0,40)","MUST2.CsI_E<0 && MUST2.TelescopeNumber<5 && EDE && ETOF","colz"); //chain->Draw("ELab:ThetaLab>>hKine(500,0,45,400,0,40)","MUST2.CsI_E<0 && MUST2.TelescopeNumber<5 && EDE && ETOF","colz");
chain->Draw("ELab:ThetaLab","MUST2.CsI_E<0 && MUST2.TelescopeNumber<5 && EDE && ETOF","colz"); chain->Draw("ELab:ThetaLab>>h(1000,0,90,1000,0,30)","MUST2.CsI_E<0 && MUST2.TelescopeNumber<5 && EDE && ETOF","colz");
NPL::Reaction r("11Li(d,3He)10He@553"); NPL::Reaction r("11Li(d,3He)10He@553");
r.SetExcitationHeavy(1.4); r.SetExcitationHeavy(1.4);
......
...@@ -4,10 +4,10 @@ ...@@ -4,10 +4,10 @@
% Energy are given in MeV , Position in mm % % Energy are given in MeV , Position in mm %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Isotropic Isotropic
EnergyLow= 0 MeV EnergyLow= 30 MeV
EnergyHigh= 850 MeV EnergyHigh= 30 MeV
HalfOpenAngleMin= 0 deg HalfOpenAngleMin= 0 deg
HalfOpenAngleMax= 10 deg HalfOpenAngleMax= 180 deg
x0= 0 mm x0= 0 mm
y0= 0 mm y0= 0 mm
z0= 0 mm z0= 0 mm
......
add_custom_command(OUTPUT TAsciiFileDict.cxx COMMAND ../scripts/build_dict.sh TAsciiFile.h TAsciiFileDict.cxx TAsciiFile.rootmap libNPCore.so) add_custom_command(OUTPUT TAsciiFileDict.cxx COMMAND ../scripts/build_dict.sh TAsciiFile.h TAsciiFileDict.cxx TAsciiFile.rootmap libNPCore.so)
add_custom_command(OUTPUT NPVDetectorDict.cxx COMMAND ../scripts/build_dict.sh NPVDetector.h NPVDetectorDict.cxx NPVDetector.rootmap libNPCore.so NPCoreLinkdef.h) add_custom_command(OUTPUT NPVDetectorDict.cxx COMMAND ../scripts/build_dict.sh NPVDetector.h NPVDetectorDict.cxx NPVDetector.rootmap libNPCore.so NPCoreLinkdef.h)
add_library(NPCore SHARED NPVAnalysis.cxx NPAnalysisFactory.cxx NPCalibrationManager.cxx NPOptionManager.cxx RootOutput.cxx RootInput.cxx TAsciiFile.cxx TAsciiFileDict.cxx NPDetectorManager.cxx NPVDetector.cxx NPVDetectorDict.cxx NPVSpectra.cxx NPDetectorFactory.cxx NPSpectraServer.cxx NPInputParser.cxx) add_library(NPCore SHARED NPVAnalysis.cxx NPAnalysisFactory.cxx NPCalibrationManager.cxx NPOptionManager.cxx RootOutput.cxx RootInput.cxx TAsciiFile.cxx TAsciiFileDict.cxx NPDetectorManager.cxx NPVDetector.cxx NPVDetectorDict.cxx NPVSpectra.cxx NPDetectorFactory.cxx NPSpectraServer.cxx NPInputParser.cxx NPImage.cxx)
target_link_libraries(NPCore ${ROOT_LIBRARIES}) target_link_libraries(NPCore ${ROOT_LIBRARIES})
install(FILES NPVAnalysis.h NPAnalysisFactory.h NPCalibrationManager.h NPOptionManager.h RootInput.h RootOutput.h TAsciiFile.h NPDetectorManager.h NPVDetector.h NPGlobalSystemOfUnits.h NPPhysicalConstants.h NPSystemOfUnits.h NPVSpectra.h NPDetectorFactory.h NPSpectraServer.h NPInputParser.h DESTINATION ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}) install(FILES NPVAnalysis.h NPAnalysisFactory.h NPCalibrationManager.h NPOptionManager.h RootInput.h RootOutput.h TAsciiFile.h NPDetectorManager.h NPVDetector.h NPGlobalSystemOfUnits.h NPPhysicalConstants.h NPSystemOfUnits.h NPVSpectra.h NPDetectorFactory.h NPSpectraServer.h NPInputParser.h NPImage.h DESTINATION ${CMAKE_INCLUDE_OUTPUT_DIRECTORY})
/*****************************************************************************
* 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 : *
* Last update : *
*---------------------------------------------------------------------------*
* Decription: *
* This class is wrapper of root TASImage to manipulate and generate *
* detector pixel map *
* *
*---------------------------------------------------------------------------*
* Comment: *
* *
* *
*****************************************************************************/
//NPTool
#include "NPImage.h"
//STL
#include<iostream>
////////////////////////////////////////////////////////////////////////////////
NPL::Image::Image(){
m_Image = NULL;
m_ARGB = NULL;
}
////////////////////////////////////////////////////////////////////////////////
NPL::Image::Image(std::string filename,double Xscalling,double Yscalling){
m_Image = new TASImage(filename.c_str());
m_ARGB = m_Image->GetArgbArray();
m_Xscaling = Xscalling;
m_Yscaling = Yscalling;
}
////////////////////////////////////////////////////////////////////////////////
NPL::Image::~Image(){
if(m_Image)
delete m_Image;
if(m_ARGB)
delete m_ARGB;
}
////////////////////////////////////////////////////////////////////////////////
void NPL::Image::Open(std::string filename){
if(m_Image)
delete m_Image;
if(m_ARGB)
delete m_ARGB;
m_Image = new TASImage(filename.c_str());
m_ARGB = m_Image->GetArgbArray();
}
////////////////////////////////////////////////////////////////////////////////
void NPL::Image::Print(double scale){
unsigned int yPixel = m_Image->GetHeight();
unsigned int xPixel = m_Image->GetWidth();
m_Image->Scale(scale*xPixel,scale*yPixel);
for(unsigned int i = 0 ; i < m_Image->GetWidth() ; i++){
for(unsigned int j = 0 ; j < m_Image->GetHeight() ; j++){
unsigned int index = i*xPixel+j;
unsigned int b = GetBlueAtPixel(i,j);
unsigned int g = GetGreenAtPixel(i,j);
unsigned int r = GetRedAtPixel(i,j);
unsigned int a = GetAlphaAtPixel(i,j);
if(r||b||g)
std::cout << "x"<< " " ;
else
std::cout << "."<<" " ;
}
std::cout << std::endl;
}
}
////////////////////////////////////////////////////////////////////////////////
void NPL::Image::Save(std::string filename){
m_Image->WriteImage(filename.c_str());
}
////////////////////////////////////////////////////////////////////////////////
void NPL::Image::Draw(){
m_Image->Draw();
}
////////////////////////////////////////////////////////////////////////////////
unsigned int NPL::Image::GetRedAtCoordinate(double x, double y){
unsigned int xp = x/m_Xscaling+m_Image->GetWidth()/2 ;
unsigned int yp = y/m_Yscaling+m_Image->GetHeight()/2 ;
return GetRedAtPixel(xp,yp);
}
////////////////////////////////////////////////////////////////////////////////
unsigned int NPL::Image::GetGreenAtCoordinate(double x, double y){
unsigned int xp = x/m_Xscaling+m_Image->GetWidth()/2 ;
unsigned int yp = y/m_Yscaling+m_Image->GetHeight()/2 ;
return GetRedAtPixel(xp,yp);
}
////////////////////////////////////////////////////////////////////////////////
unsigned int NPL::Image::GetBlueAtCoordinate(double x, double y){
unsigned int xp = x/m_Xscaling+m_Image->GetWidth()/2 ;
unsigned int yp = y/m_Yscaling+m_Image->GetHeight()/2 ;
return GetRedAtPixel(xp,yp);
}
////////////////////////////////////////////////////////////////////////////////
unsigned int NPL::Image::GetAlphaAtCoordinate(double x, double y){
unsigned int xp = x/m_Xscaling+m_Image->GetWidth()/2 ;
unsigned int yp = y/m_Yscaling+m_Image->GetHeight()/2 ;
return GetRedAtPixel(xp,yp);
}
////////////////////////////////////////////////////////////////////////////////
unsigned int NPL::Image::GetPixelAtCoordinate(double x, double y){
unsigned int xp = x/m_Xscaling+m_Image->GetWidth()/2 ;
unsigned int yp = y/m_Yscaling+m_Image->GetHeight()/2 ;
return m_ARGB[PixelToIndex(xp,yp)];
}
////////////////////////////////////////////////////////////////////////////////
unsigned int NPL::Image::PixelToIndex(unsigned int x, unsigned int y){
return x*m_Image->GetWidth()+y;
}
////////////////////////////////////////////////////////////////////////////////
unsigned int NPL::Image::GetRedAtPixel(unsigned int x, unsigned int y){
unsigned int v = m_ARGB[PixelToIndex(x,y)];
v= (v>>16)&0xff;
return v;
}
////////////////////////////////////////////////////////////////////////////////
unsigned int NPL::Image::GetGreenAtPixel(unsigned int x, unsigned int y){
unsigned int v = m_ARGB[PixelToIndex(x,y)];
v= (v>>8)&0xff;
return v;
}
////////////////////////////////////////////////////////////////////////////////
unsigned int NPL::Image::GetBlueAtPixel(unsigned int x, unsigned int y){
unsigned int v = m_ARGB[PixelToIndex(x,y)];
v= v&0xff;
return v;
}
////////////////////////////////////////////////////////////////////////////////
unsigned int NPL::Image::GetAlphaAtPixel(unsigned int x, unsigned int y){
unsigned int v = m_ARGB[PixelToIndex(x,y)];
v= (v>>24)&0xff;
return v;
}
/*****************************************************************************
* 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 : *
* Last update : *
*---------------------------------------------------------------------------*
* Decription: *
* This class is wrapper of root TASImage to manipulate and generate *
* detector pixel map *
* *
*---------------------------------------------------------------------------*
* Comment: *
* *
* *
*****************************************************************************/
// ROOT
#include"TASImage.h"
//STL
#include<string>
namespace NPL{
class Image{
public:
Image();
Image(std::string filename,double Xscalling,double Yscalling);
~Image();
public:
void Open(std::string filename);
void Print(double scale=0); // print mockup in terminal
void Draw(); // draw in a new canvas (interactive only)
void Save(std::string filename); // save the image
public: // Get the value based on coordinate
unsigned int GetRedAtCoordinate(double x, double y);
unsigned int GetGreenAtCoordinate(double x, double y);
unsigned int GetBlueAtCoordinate(double x, double y);
unsigned int GetAlphaAtCoordinate(double x, double y);
unsigned int GetPixelAtCoordinate(double x, double y);
public: // Get the value based on pixel
unsigned int PixelToIndex(unsigned int x, unsigned int y);
unsigned int GetRedAtPixel(unsigned int x, unsigned int y);
unsigned int GetGreenAtPixel(unsigned int x, unsigned int y);
unsigned int GetBlueAtPixel(unsigned int x, unsigned int y);
unsigned int GetAlphaAtPixel(unsigned int x, unsigned int y);
public:
void GenerateStrip(unsigned int Nbr, double x, double y , double interstrip , unsigned int pixel);
private:
TASImage* m_Image; // the image itself
unsigned int* m_ARGB; // the alpha red green blue array of pixel value
double m_Xscaling; // pixel per mm
double m_Yscaling; // pixel per mm
};
}
...@@ -62,14 +62,11 @@ void TChio_digPhysics::ReadConfiguration(NPL::InputParser parser){ ...@@ -62,14 +62,11 @@ void TChio_digPhysics::ReadConfiguration(NPL::InputParser parser){
if(NPOptionManager::getInstance()->GetVerboseLevel()) if(NPOptionManager::getInstance()->GetVerboseLevel())
cout << "//// " << blocks.size() << " detectors found " << endl; cout << "//// " << blocks.size() << " detectors found " << endl;
vector<string> token = {"A","B","C","D"}; vector<string> token = {"POS"};
for(unsigned int i = 0 ; i < blocks.size() ; i++){ for(unsigned int i = 0 ; i < blocks.size() ; i++){
if(blocks[i]->HasTokenList(token)){ if(blocks[i]->HasTokenList(token)){
TVector3 A = blocks[i]->GetTVector3("A","mm"); TVector3 Pos = blocks[i]->GetTVector3("POS","mm");
TVector3 B = blocks[i]->GetTVector3("B","mm");
TVector3 C = blocks[i]->GetTVector3("C","mm");
TVector3 D = blocks[i]->GetTVector3("D","mm");
// AddChio(A,B,C,D); // AddChio(A,B,C,D);
} }
......
void Mask(){
double dimension = 100.42;
double active = 97.30;
double pitch = 97.30/128;
double width = 0.7;
//
// double dimension = 100;
// double active = 97;
// double pitch = 97/97;
// double width = 0.5;
// mm per pixel
double scale = 0.01;
//pitch in pixel
unsigned int spitch = pitch/scale;
unsigned int swidth = width/scale;
unsigned int sinter = (spitch - swidth)/2;
cout << spitch << " " << swidth << " " << sinter << endl;
// image size
unsigned int size = dimension/scale;
cout << "Image size: " << size << "x" << size<< endl ;
double* zargb = new double[size*size];
TASImage* zero = new TASImage("zero",zargb,size,size,0);
zero->WriteImage("mask.png");
TASImage* mask = new TASImage("mask.png");
delete[] zargb;
unsigned int* argb = mask->GetArgbArray();
unsigned int* argb2 = mask->GetArgbArray();
unsigned int index = 0;
double border1 = (dimension-active)/scale;
double border2 = (active)/scale;
for(unsigned int px = 0 ; px < size ; px++){
for(unsigned int py = 0 ; py < size ; py++){
if(px%1000==0)
cout << "\r" << px << "/" << size << flush;
// Compute array index
index = px * size + py;
// Inactive sides
if(px < border1|| py < border1 || px>border2 || py>border2)
argb[index] = 0xffff0000;
else{ // strips
unsigned int coord = px-border1;
unsigned int nbr = coord/spitch;
// cout << coord << " " << nbr*spitch+sinter << " " << spitch << " " << sinter << " " << spitch << " " << sinter << endl;
if(coord<(nbr*spitch+sinter) || coord >(((nbr+1)*spitch-sinter))){// interstrip
argb[index] = 0xffff0000+(((nbr+1))<<8)+nbr;
}
else
argb[index] = 0xff000000 + nbr;
}
}
}
mask->WriteImage("mask.png");
//mask->Draw();
}
NPLib/Detectors/MUST2/ressources/maskBack.png

313 KiB

NPLib/Detectors/MUST2/ressources/maskFront.png

317 KiB

...@@ -36,7 +36,7 @@ endif() ...@@ -36,7 +36,7 @@ endif()
## Collect the different information ## ## Collect the different information ##
# List of Root dependencies # List of Root dependencies
set(ROOT_LIBRARIES dl Gui Core RIO Net Hist Gpad Tree Physics MathCore Thread ) set(ROOT_LIBRARIES dl Gui Core RIO Net Hist Gpad Tree Physics MathCore Thread ASImage)
# Lib directories # Lib directories
exec_program(${NPTOOL_ROOT_CONFIG} ARGS "--libdir" OUTPUT_VARIABLE ROOT_LIBRARY_DIR) exec_program(${NPTOOL_ROOT_CONFIG} ARGS "--libdir" OUTPUT_VARIABLE ROOT_LIBRARY_DIR)
......
This diff is collapsed.
...@@ -47,7 +47,7 @@ namespace MUST2 ...@@ -47,7 +47,7 @@ namespace MUST2
const G4double AluStripThickness = 0.4*micrometer ; const G4double AluStripThickness = 0.4*micrometer ;
const G4double SiliconThickness = 300*micrometer ; const G4double SiliconThickness = 300*micrometer ;
const G4double SiliconFace = 98*mm ; const G4double SiliconFace = 100.42*mm ;
const G4double VacBoxThickness = 3*cm ; const G4double VacBoxThickness = 3*cm ;
const G4double SiLiThickness = 5.1*mm; // Must be checked const G4double SiLiThickness = 5.1*mm; // Must be checked
......
...@@ -126,7 +126,6 @@ G4bool PS_CalorimeterWithInteraction::ProcessHits(G4Step* aStep, G4TouchableHist ...@@ -126,7 +126,6 @@ G4bool PS_CalorimeterWithInteraction::ProcessHits(G4Step* aStep, G4TouchableHist
Infos[5] = m_Position.theta(); Infos[5] = m_Position.theta();
Infos[6] = m_Position.phi(); Infos[6] = m_Position.phi();
for(unsigned int i = 0 ; i < mysize ; i++){ for(unsigned int i = 0 ; i < mysize ; i++){
Infos[i+7] = aStep->GetPreStepPoint()->GetTouchableHandle()->GetCopyNumber(m_NestingLevel[i]); Infos[i+7] = aStep->GetPreStepPoint()->GetTouchableHandle()->GetCopyNumber(m_NestingLevel[i]);
} }
......
...@@ -22,7 +22,159 @@ ...@@ -22,7 +22,159 @@
#include "SiliconScorers.hh" #include "SiliconScorers.hh"
#include "G4UnitsTable.hh" #include "G4UnitsTable.hh"
using namespace SILICONSCORERS ; using namespace SILICONSCORERS ;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
PS_Silicon_Images::PS_Silicon_Images(G4String name, string imageFront,string imageBack,double scalingFront, double scalingBack, double centerOffsetX,double centerOffsetY,unsigned int ignoreValue, G4int depth) :G4VPrimitiveScorer(name, depth),HCID(-1){
m_ImageFront = new NPL::Image(imageFront,scalingFront,scalingFront);
m_ImageBack = new NPL::Image(imageBack,scalingBack,scalingBack);
m_ScalingFront = scalingFront;
m_ScalingBack = scalingBack;
m_CenterOffsetX = centerOffsetX;
m_CenterOffsetY = centerOffsetY;
m_IgnoreValue = ignoreValue;
m_Level = depth;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4bool PS_Silicon_Images::ProcessHits(G4Step* aStep, G4TouchableHistory*){
// contain Energy Time, DetNbr, PixelFront and PixelBack
t_Energy = aStep->GetTotalEnergyDeposit();
t_Time = aStep->GetPreStepPoint()->GetGlobalTime();
t_DetectorNbr = aStep->GetPreStepPoint()->GetTouchableHandle()->GetCopyNumber(m_Level);
t_Position = aStep->GetPreStepPoint()->GetPosition();
// Interaction coordinates (used to fill the InteractionCoordinates branch)
t_X = t_Position.x();
t_Y = t_Position.y();
t_Z = t_Position.z();
t_Theta = t_Position.theta();
t_Phi = t_Position.phi();
t_Position = aStep->GetPreStepPoint()->GetTouchableHandle()->GetHistory()->GetTopTransform().TransformPoint(t_Position);
t_PixelFront = m_ImageFront->GetPixelAtCoordinate(t_Position.x(),t_Position.y());
t_PixelBack = m_ImageBack->GetPixelAtCoordinate(t_Position.x(),t_Position.y());
unsigned int front = (m_ImageFront->GetPixelAtCoordinate(t_Position.x(),t_Position.y()))&0xff;
unsigned int back = (m_ImageBack->GetPixelAtCoordinate(t_Position.x(),t_Position.y()))&0xff;
// If front and back are in inactive part of the wafer,
// nothing is added to the map
if(t_PixelFront == m_IgnoreValue && t_PixelBack == m_IgnoreValue)
return FALSE;
t_Index = aStep->GetTrack()->GetTrackID() + t_DetectorNbr * 1e3 ;
// Check if the particle has interact before, if yes, add up the energies.
map<unsigned int, double>::iterator it;
it= m_Energy.find(t_Index);
if(it!=m_Energy.end()){
double dummy = it->second;
t_Energy+=dummy;
}
m_Energy[t_Index] = t_Energy;
m_Time[t_Index] = t_Time;
m_DetectorNbr[t_Index] = t_DetectorNbr;
m_PixelFront[t_Index] = t_PixelFront;
m_PixelBack[t_Index] = t_PixelBack;
m_X[t_Index] = t_X;
m_Y[t_Index] = t_Y;
m_Z[t_Index] = t_Z;
m_Theta[t_Index] = t_Theta;
m_Phi[t_Index] = t_Phi;
return TRUE;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void PS_Silicon_Images::Initialize(G4HCofThisEvent* HCE){
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void PS_Silicon_Images::EndOfEvent(G4HCofThisEvent*){
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void PS_Silicon_Images::clear(){
m_Energy.clear();
m_Time.clear();
m_DetectorNbr.clear();
m_PixelFront.clear();
m_PixelBack.clear();
m_X.clear();
m_Y.clear();
m_Z.clear();
m_Theta.clear();
m_Phi.clear();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
vector<unsigned int> PS_Silicon_Images::GetIndexes(){
vector<unsigned int > indexes;
map<unsigned int , double>::iterator it;
for(it=m_Energy.begin(); it!=m_Energy.end();it++)
indexes.push_back(it->first);
return indexes;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
unsigned int PS_Silicon_Images::GetPixelFront(unsigned int index){
return m_PixelFront[index];
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
unsigned int PS_Silicon_Images::GetPixelBack(unsigned int index){
return m_PixelBack[index];
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void PS_Silicon_Images::GetARGBFront(unsigned int index,unsigned int& a,unsigned int& r,unsigned int& g,unsigned int& b){
unsigned int Info =m_PixelFront[index];
a = (Info>>24)&0xff;
r = (Info>>16)&0xff;
g = (Info>>8)&0xff;
b = (Info>>0)&0xff;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void PS_Silicon_Images::GetARGBBack(unsigned int index,unsigned int& a,unsigned int& r,unsigned int& g,unsigned int& b){
unsigned int Info =m_PixelBack[index];
a = (Info>>24)&0xff;
r = (Info>>16)&0xff;
g = (Info>>8)&0xff;
b = (Info>>0)&0xff;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
double PS_Silicon_Images::GetEnergy(unsigned int index){
return m_Energy[index];
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
double PS_Silicon_Images::GetTime(unsigned int index){
return m_Time[index];
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
unsigned int PS_Silicon_Images::GetDetectorNbr(unsigned int index){
return m_DetectorNbr[index];
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
double PS_Silicon_Images::GetX(unsigned int index){
return m_X[index];
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
double PS_Silicon_Images::GetY(unsigned int index){
return m_Y[index];
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
double PS_Silicon_Images::GetZ(unsigned int index){
return m_Z[index];
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
double PS_Silicon_Images::GetTheta(unsigned int index){
return m_Theta[index];
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
double PS_Silicon_Images::GetPhi(unsigned int index){
return m_Phi[index];
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
PS_Silicon_Rectangle::PS_Silicon_Rectangle(G4String name,G4int Level, G4double StripPlaneLength, G4double StripPlaneWidth, G4int NumberOfStripLength,G4int NumberOfStripWidth,G4int depth,G4String axis) PS_Silicon_Rectangle::PS_Silicon_Rectangle(G4String name,G4int Level, G4double StripPlaneLength, G4double StripPlaneWidth, G4int NumberOfStripLength,G4int NumberOfStripWidth,G4int depth,G4String axis)
:G4VPrimitiveScorer(name, depth),HCID(-1){ :G4VPrimitiveScorer(name, depth),HCID(-1){
...@@ -192,7 +344,7 @@ G4bool PS_Silicon_Annular::ProcessHits(G4Step* aStep, G4TouchableHistory*){ ...@@ -192,7 +344,7 @@ G4bool PS_Silicon_Annular::ProcessHits(G4Step* aStep, G4TouchableHistory*){
phi+=2*M_PI; phi+=2*M_PI;
m_StripSectorNumber = (int) ((phi - m_PhiStart) / m_StripPitchSector ) + 1 ; m_StripSectorNumber = (int) ((phi - m_PhiStart) / m_StripPitchSector ) + 1 ;
m_StripQuadrantNumber = (int) ((phi - m_PhiStart) /m_StripPitchQuadrant) + 1 ; m_StripQuadrantNumber = (int) ((phi - m_PhiStart) /m_StripPitchQuadrant) + 1 ;
//Rare case where particle is close to edge of silicon plan //Rare case where particle is close to edge of silicon plan
if (m_StripRingNumber > m_NumberOfStripRing) m_StripRingNumber = m_NumberOfStripRing; if (m_StripRingNumber > m_NumberOfStripRing) m_StripRingNumber = m_NumberOfStripRing;
if (m_StripSectorNumber > m_NumberOfStripSector) m_StripSectorNumber = m_NumberOfStripSector; if (m_StripSectorNumber > m_NumberOfStripSector) m_StripSectorNumber = m_NumberOfStripSector;
......
...@@ -26,13 +26,87 @@ ...@@ -26,13 +26,87 @@
*****************************************************************************/ *****************************************************************************/
#include "G4VPrimitiveScorer.hh" #include "G4VPrimitiveScorer.hh"
#include "NPSHitsMap.hh" #include "NPSHitsMap.hh"
#include "NPImage.h"
#include <map> #include <map>
using namespace std; using namespace std;
using namespace CLHEP; using namespace CLHEP;
namespace SILICONSCORERS { namespace SILICONSCORERS {
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
class PS_Silicon_Images : public G4VPrimitiveScorer{
public: // with description
PS_Silicon_Images(G4String name, string imageFront,string imageBack,double scalingFront, double scalingBack, double centerOffsetX,double centerOffsetY,unsigned int ignoreValue, G4int depth=0);
~PS_Silicon_Images(){};
protected: // with description
G4bool ProcessHits(G4Step*, G4TouchableHistory*);
public:
void Initialize(G4HCofThisEvent*);
void EndOfEvent(G4HCofThisEvent*);
void clear();
void DrawAll(){};
void PrintAll(){};
private: // Geometry of the detector
NPL::Image* m_ImageFront;
NPL::Image* m_ImageBack;
double m_ScalingFront;
double m_ScalingBack;
double m_CenterOffsetX;
double m_CenterOffsetY;
unsigned int m_IgnoreValue;
// Level at which to find the copy number linked to the detector number
G4int m_Level;
private: // inherited from G4VPrimitiveScorer
G4int HCID;
map<unsigned int,double> m_Energy;
map<unsigned int,double> m_Time;
map<unsigned int,unsigned int> m_DetectorNbr;
map<unsigned int,unsigned int> m_PixelFront;
map<unsigned int,unsigned int> m_PixelBack;
map<unsigned int,double> m_X;
map<unsigned int,double> m_Y;
map<unsigned int,double> m_Z;
map<unsigned int,double> m_Theta;
map<unsigned int,double> m_Phi;
private: // Needed for intermediate calculation (avoid multiple instantiation in Processing Hit)
G4ThreeVector t_Position;
unsigned int t_Index;
double t_Energy;
double t_Time;
unsigned int t_DetectorNbr;
unsigned int t_PixelFront;
unsigned int t_PixelBack;
double t_X;
double t_Y;
double t_Z;
double t_Theta;
double t_Phi;
public: // information accessor
vector<unsigned int> GetIndexes();
unsigned int GetPixelFront(unsigned int index);
unsigned int GetPixelBack(unsigned int index);
void GetARGBFront(unsigned int index,unsigned int& a,unsigned int& r,unsigned int& g,unsigned int& b);
void GetARGBBack(unsigned int index,unsigned int& a,unsigned int& r,unsigned int& g,unsigned int& b);
double GetEnergy(unsigned int index);
double GetTime(unsigned int index);
unsigned int GetDetectorNbr(unsigned int index);
double GetX(unsigned int index);
double GetY(unsigned int index);
double GetZ(unsigned int index);
double GetTheta(unsigned int index);
double GetPhi(unsigned int index);
};
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
struct RectangularOutput { struct RectangularOutput {
G4double totalEnergy; G4double totalEnergy;
...@@ -48,46 +122,46 @@ namespace SILICONSCORERS { ...@@ -48,46 +122,46 @@ namespace SILICONSCORERS {
}; };
class PS_Silicon_Rectangle : public G4VPrimitiveScorer{ class PS_Silicon_Rectangle : public G4VPrimitiveScorer{
public: // with description public: // with description
PS_Silicon_Rectangle(G4String name, G4int Level, G4double StripPlaneLength, G4double StripPlaneWidth, G4int NumberOfStripLength,G4int NumberOfStripWidth,G4int depth=0,G4String axis="xy"); PS_Silicon_Rectangle(G4String name, G4int Level, G4double StripPlaneLength, G4double StripPlaneWidth, G4int NumberOfStripLength,G4int NumberOfStripWidth,G4int depth=0,G4String axis="xy");
~PS_Silicon_Rectangle(); ~PS_Silicon_Rectangle();
protected: // with description protected: // with description
G4bool ProcessHits(G4Step*, G4TouchableHistory*); G4bool ProcessHits(G4Step*, G4TouchableHistory*);
public: public:
void Initialize(G4HCofThisEvent*); void Initialize(G4HCofThisEvent*);
void EndOfEvent(G4HCofThisEvent*); void EndOfEvent(G4HCofThisEvent*);
void clear(); void clear();
void DrawAll(); void DrawAll();
void PrintAll(); void PrintAll();
private: // Geometry of the detector private: // Geometry of the detector
G4double m_StripPlaneLength; G4double m_StripPlaneLength;
G4double m_StripPlaneWidth; G4double m_StripPlaneWidth;
G4int m_NumberOfStripLength; G4int m_NumberOfStripLength;
G4int m_NumberOfStripWidth; G4int m_NumberOfStripWidth;
G4double m_StripPitchLength; G4double m_StripPitchLength;
G4double m_StripPitchWidth; G4double m_StripPitchWidth;
G4String m_Axis; G4String m_Axis;
// Level at which to find the copy number linked to the detector number // Level at which to find the copy number linked to the detector number
G4int m_Level; G4int m_Level;
private: // inherited from G4VPrimitiveScorer private: // inherited from G4VPrimitiveScorer
G4int HCID; G4int HCID;
NPS::HitsMap<G4double*>* EvtMap; NPS::HitsMap<G4double*>* EvtMap;
private: // Needed for intermediate calculation (avoid multiple instantiation in Processing Hit) private: // Needed for intermediate calculation (avoid multiple instantiation in Processing Hit)
G4ThreeVector m_Position ; G4ThreeVector m_Position ;
G4int m_DetectorNumber ; G4int m_DetectorNumber ;
G4int m_StripLengthNumber ; G4int m_StripLengthNumber ;
G4int m_StripWidthNumber ; G4int m_StripWidthNumber ;
G4int m_Index ; G4int m_Index ;
}; };
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
struct AnnularOutput { struct AnnularOutput {
G4double totalEnergy; G4double totalEnergy;
...@@ -104,51 +178,51 @@ namespace SILICONSCORERS { ...@@ -104,51 +178,51 @@ namespace SILICONSCORERS {
}; };
class PS_Silicon_Annular : public G4VPrimitiveScorer{ class PS_Silicon_Annular : public G4VPrimitiveScorer{
public: // with description public: // with description
PS_Silicon_Annular(G4String name,G4int Level, G4double StripPlaneInnerRadius, G4double StripPlaneOuterRadius, G4double PhiStart,G4double PhiStop, G4int NumberOfStripRing,G4int NumberOfStripSector=1, G4int NumberOfQuadrant=1,G4int depth=0); PS_Silicon_Annular(G4String name,G4int Level, G4double StripPlaneInnerRadius, G4double StripPlaneOuterRadius, G4double PhiStart,G4double PhiStop, G4int NumberOfStripRing,G4int NumberOfStripSector=1, G4int NumberOfQuadrant=1,G4int depth=0);
~PS_Silicon_Annular(); ~PS_Silicon_Annular();
protected: // with description protected: // with description
G4bool ProcessHits(G4Step*, G4TouchableHistory*); G4bool ProcessHits(G4Step*, G4TouchableHistory*);
public: public:
void Initialize(G4HCofThisEvent*); void Initialize(G4HCofThisEvent*);
void EndOfEvent(G4HCofThisEvent*); void EndOfEvent(G4HCofThisEvent*);
void clear(); void clear();
void DrawAll(); void DrawAll();
void PrintAll(); void PrintAll();
private: // Geometry of the detector private: // Geometry of the detector
G4double m_StripPlaneInnerRadius; G4double m_StripPlaneInnerRadius;
G4double m_StripPlaneOuterRadius; G4double m_StripPlaneOuterRadius;
G4double m_PhiStart; G4double m_PhiStart;
G4double m_PhiStop; G4double m_PhiStop;
G4int m_NumberOfStripRing; G4int m_NumberOfStripRing;
G4int m_NumberOfStripSector; G4int m_NumberOfStripSector;
G4int m_NumberOfStripQuadrant; G4int m_NumberOfStripQuadrant;
G4double m_StripPitchRing; G4double m_StripPitchRing;
G4double m_StripPitchSector; G4double m_StripPitchSector;
G4double m_StripPitchQuadrant; G4double m_StripPitchQuadrant;
G4String m_Axis; G4String m_Axis;
// Level at which to find the copy number linked to the detector number // Level at which to find the copy number linked to the detector number
G4int m_Level; G4int m_Level;
private: // inherited from G4VPrimitiveScorer private: // inherited from G4VPrimitiveScorer
G4int HCID; G4int HCID;
NPS::HitsMap<G4double*>* EvtMap; NPS::HitsMap<G4double*>* EvtMap;
private: // Needed for intermediate calculation (avoid multiple instantiation in Processing Hit) private: // Needed for intermediate calculation (avoid multiple instantiation in Processing Hit)
G4ThreeVector m_Position ; G4ThreeVector m_Position ;
G4ThreeVector m_uz ; G4ThreeVector m_uz ;
G4int m_DetectorNumber ; G4int m_DetectorNumber ;
G4int m_StripRingNumber ; G4int m_StripRingNumber ;
G4int m_StripSectorNumber ; G4int m_StripSectorNumber ;
G4int m_StripQuadrantNumber ; G4int m_StripQuadrantNumber ;
G4int m_Index ; G4int m_Index ;
}; };
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
struct ResistiveOutput { struct ResistiveOutput {
G4double upstreamEnergy; G4double upstreamEnergy;
G4double downstreamEnergy; G4double downstreamEnergy;
...@@ -163,42 +237,42 @@ namespace SILICONSCORERS { ...@@ -163,42 +237,42 @@ namespace SILICONSCORERS {
}; };
class PS_Silicon_Resistive : public G4VPrimitiveScorer{ class PS_Silicon_Resistive : public G4VPrimitiveScorer{
public: // with description public: // with description
PS_Silicon_Resistive(G4String name, G4int Level, PS_Silicon_Resistive(G4String name, G4int Level,
G4double StripPlaneLength, G4double StripPlaneWidth, G4double StripPlaneLength, G4double StripPlaneWidth,
G4int NumberOfStripWidth,G4int depth=0); G4int NumberOfStripWidth,G4int depth=0);
~PS_Silicon_Resistive(); ~PS_Silicon_Resistive();
protected: // with description protected: // with description
G4bool ProcessHits(G4Step*, G4TouchableHistory*); G4bool ProcessHits(G4Step*, G4TouchableHistory*);
public: public:
void Initialize(G4HCofThisEvent*); void Initialize(G4HCofThisEvent*);
void EndOfEvent(G4HCofThisEvent*); void EndOfEvent(G4HCofThisEvent*);
void clear(); void clear();
void DrawAll(); void DrawAll();
void PrintAll(); void PrintAll();
private: // Geometry of the detector private: // Geometry of the detector
G4double m_StripPlaneLength; G4double m_StripPlaneLength;
G4double m_StripPlaneWidth; G4double m_StripPlaneWidth;
G4int m_NumberOfStripWidth; G4int m_NumberOfStripWidth;
G4double m_StripPitchWidth; G4double m_StripPitchWidth;
// Level at which to find the copy number linked to the detector number // Level at which to find the copy number linked to the detector number
G4int m_Level; G4int m_Level;
private: // inherited from G4VPrimitiveScorer private: // inherited from G4VPrimitiveScorer
G4int HCID; G4int HCID;
NPS::HitsMap<G4double*>* EvtMap; NPS::HitsMap<G4double*>* EvtMap;
private: // Needed for intermediate calculation (avoid multiple instantiation in Processing Hit) private: // Needed for intermediate calculation (avoid multiple instantiation in Processing Hit)
G4ThreeVector m_Position ; G4ThreeVector m_Position ;
G4int m_DetectorNumber ; G4int m_DetectorNumber ;
G4int m_StripWidthNumber ; G4int m_StripWidthNumber ;
G4int m_Index ; G4int m_Index ;
}; };
} }
......
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