diff --git a/NPAnalysis/Example1/Analysis.cxx b/NPAnalysis/Example1/Analysis.cxx index b2b354ec690ef5c062d6cbbb96cd16300fc46e4d..e8f94ad11d07ed3a979c8111b93c045575ab62b2 100644 --- a/NPAnalysis/Example1/Analysis.cxx +++ b/NPAnalysis/Example1/Analysis.cxx @@ -38,6 +38,7 @@ Analysis::~Analysis(){ void Analysis::Init(){ M2= (TMust2Physics*) m_DetectorManager->GetDetector("MUST2Array"); SSSD= (TSSSDPhysics*) m_DetectorManager->GetDetector("SSSD"); + Initial=new TInitialConditions(); InitOutputBranch(); InitInputBranch(); Rand = TRandom3(); @@ -58,114 +59,115 @@ void Analysis::Init(){ Si_Y_M2 = 0; ZTarget = 0; TargetThickness = m_DetectorManager->GetTargetThickness(); + // Energy loss table: the G4Table are generated by the simulation + He3CD2 = EnergyLoss("He3_CD2.G4table","G4Table",100 ); + He3Al = EnergyLoss("He3_Al.G4table","G4Table",10); + He3Si = EnergyLoss("He3_Si.G4table","G4Table",10); + Li11CD2 = EnergyLoss("Li11[0.0]_CD2.G4table","G4Table",100); } //////////////////////////////////////////////////////////////////////////////// void Analysis::TreatEvent(){ - // Reinitiate calculated variable - ReInitValue(); - - // Get the Init information on beam position and energy - // and apply by hand the experimental resolution - // This is because the beam diagnosis are not simulated - - // PPAC position resolution on target is assumed to be 1mm - double XTarget = Rand.Gaus(Initial->GetIncidentPositionX(),1); - double YTarget = Rand.Gaus(Initial->GetIncidentPositionY(),1); - TVector3 BeamDirection = Initial->GetBeamDirection(); - - // Beam energy is measured using F3 and F2 plastic TOF - double BeamEnergy = Rand.Gaus(Initial->GetIncidentInitialKineticEnergy(),4.5); - BeamEnergy = Li11CD2.Slow(BeamEnergy,TargetThickness/2.,0); - He10Reaction->SetBeamEnergy(BeamEnergy); - - //////////////////////////// LOOP on MUST2 + SSSD Hit ////////////////// - for(unsigned int countSSSD = 0 ; countSSSD < SSSD->Energy.size() ; countSSSD++){ - for(unsigned int countMust2 = 0 ; countMust2 < M2->Si_E.size() ; countMust2++){ + // Reinitiate calculated variable + ReInitValue(); + // Get the Init information on beam position and energy + // and apply by hand the experimental resolution + // This is because the beam diagnosis are not simulated + // PPAC position resolution on target is assumed to be 1mm + double XTarget = Rand.Gaus(Initial->GetIncidentPositionX(),1); + double YTarget = Rand.Gaus(Initial->GetIncidentPositionY(),1); + TVector3 BeamDirection = Initial->GetBeamDirection(); + // Beam energy is measured using F3 and F2 plastic TOF + double BeamEnergy = Rand.Gaus(Initial->GetIncidentInitialKineticEnergy(),4.5); + BeamEnergy = Li11CD2.Slow(BeamEnergy,TargetThickness/2.,0); + He10Reaction->SetBeamEnergy(BeamEnergy); + //////////////////////////// LOOP on MUST2 + SSSD Hit ////////////////// + for(unsigned int countSSSD = 0 ; countSSSD < SSSD->Energy.size() ; countSSSD++){ + for(unsigned int countMust2 = 0 ; countMust2 < M2->Si_E.size() ; countMust2++){ + /************************************************/ + //Part 0 : Get the usefull Data + // MUST2 + int X = M2->Si_X[countMust2]; + int Y = M2->Si_Y[countMust2]; + int TelescopeNumber = M2->TelescopeNumber[countMust2]; + Si_X_M2 = X ; + Si_Y_M2 = Y ; + //SSSD + int SiNumber = SSSD->DetectorNumber[countSSSD]; + + /************************************************/ + // Matching between Thin Si and MUST2, and Forward Telescope Only + if(TelescopeNumber==SiNumber && TelescopeNumber<5){ + DetectorNumber = TelescopeNumber ; + /************************************************/ + // Part 1 : Impact Angle + ThetaM2Surface = 0; + ThetaNormalTarget = 0; + if(XTarget>-1000 && YTarget>-1000){ + TVector3 BeamImpact(XTarget,YTarget,0); + TVector3 HitDirection = M2 -> GetPositionOfInteraction(countMust2) - BeamImpact ; + ThetaLab = HitDirection.Angle( BeamDirection ); + + ThetaM2Surface = HitDirection.Angle(- M2 -> GetTelescopeNormal(countMust2) ); + ThetaNormalTarget = HitDirection.Angle( TVector3(0,0,1) ) ; + X_M2 = M2 -> GetPositionOfInteraction(countMust2).X() ; + Y_M2 = M2 -> GetPositionOfInteraction(countMust2).Y() ; + Z_M2 = M2 -> GetPositionOfInteraction(countMust2).Z() ; + } + + else{ + BeamDirection = TVector3(-1000,-1000,-1000); + ThetaM2Surface = -1000 ; + ThetaNormalTarget = -1000 ; + } + /************************************************/ - //Part 0 : Get the usefull Data - // MUST2 - int X = M2->Si_X[countMust2]; - int Y = M2->Si_Y[countMust2]; - int TelescopeNumber = M2->TelescopeNumber[countMust2]; - Si_X_M2 = X ; - Si_Y_M2 = Y ; - //SSSD - int SiNumber = SSSD->DetectorNumber[countSSSD]; /************************************************/ - // Matching between Thin Si and MUST2, and Forward Telescope Only - if(TelescopeNumber==SiNumber && TelescopeNumber<5){ - DetectorNumber = TelescopeNumber ; - /************************************************/ - // Part 1 : Impact Angle - ThetaM2Surface = 0; - ThetaNormalTarget = 0; - if(XTarget>-1000 && YTarget>-1000){ - TVector3 BeamImpact(XTarget,YTarget,0); - TVector3 HitDirection = M2 -> GetPositionOfInteraction(countMust2) - BeamImpact ; - ThetaLab = HitDirection.Angle( BeamDirection ); - - ThetaM2Surface = HitDirection.Angle(- M2 -> GetTelescopeNormal(countMust2) ); - ThetaNormalTarget = HitDirection.Angle( TVector3(0,0,1) ) ; - X_M2 = M2 -> GetPositionOfInteraction(countMust2).X() ; - Y_M2 = M2 -> GetPositionOfInteraction(countMust2).Y() ; - Z_M2 = M2 -> GetPositionOfInteraction(countMust2).Z() ; - } - - else{ - BeamDirection = TVector3(-1000,-1000,-1000); - ThetaM2Surface = -1000 ; - ThetaNormalTarget = -1000 ; - } - - /************************************************/ - - /************************************************/ - - // Part 2 : Impact Energy - Energy = ELab = 0; - Si_E_M2 = M2->Si_E[countMust2]; - CsI_E_M2= M2->CsI_E[countMust2]; - E_SSSD = SSSD->Energy[countSSSD]; - - // if CsI - if(CsI_E_M2>0 ){ - // The energy in CsI is calculate form dE/dx Table because - // 20um resolution is poor - Energy = - He3Si.EvaluateEnergyFromDeltaE(Si_E_M2,300*micrometer, - ThetaM2Surface, 0.01*MeV, - 450.*MeV,0.001*MeV ,1000); - E_M2=CsI_E_M2; - } - - else - Energy = Si_E_M2; - - E_M2 += Si_E_M2; - - // Evaluate energy using the thickness - ELab = He3Al.EvaluateInitialEnergy( Energy ,2*0.4*micrometer , ThetaM2Surface); - ELab = He3Si.EvaluateInitialEnergy( ELab ,20*micrometer , ThetaM2Surface); - ELab = He3Al.EvaluateInitialEnergy( ELab ,0.4*micrometer , ThetaM2Surface); - // Target Correction - ELab = He3CD2.EvaluateInitialEnergy( ELab ,TargetThickness/2., ThetaNormalTarget); - /************************************************/ - - /***********888888888888888888888****************/ - // Part 3 : Excitation Energy Calculation - Ex = He10Reaction -> ReconstructRelativistic( ELab , ThetaLab ); - ThetaLab=ThetaLab/deg; - /************************************************/ - - /************************************************/ - // Part 4 : Theta CM Calculation - ThetaCM = He10Reaction -> EnergyLabToThetaCM( ELab , 0)/deg; - /************************************************/ + + // Part 2 : Impact Energy + Energy = ELab = 0; + Si_E_M2 = M2->Si_E[countMust2]; + CsI_E_M2= M2->CsI_E[countMust2]; + E_SSSD = SSSD->Energy[countSSSD]; + + // if CsI + if(CsI_E_M2>0 ){ + // The energy in CsI is calculate form dE/dx Table because + // 20um resolution is poor + Energy = + He3Si.EvaluateEnergyFromDeltaE(Si_E_M2,300*micrometer, + ThetaM2Surface, 0.01*MeV, + 450.*MeV,0.001*MeV ,1000); + E_M2=CsI_E_M2; } - } //end loop SSSD - }//end loop MUST2 + + else + Energy = Si_E_M2; + + E_M2 += Si_E_M2; + + // Evaluate energy using the thickness + ELab = He3Al.EvaluateInitialEnergy( Energy ,2*0.4*micrometer , ThetaM2Surface); + ELab = He3Si.EvaluateInitialEnergy( ELab ,20*micrometer , ThetaM2Surface); + ELab = He3Al.EvaluateInitialEnergy( ELab ,0.4*micrometer , ThetaM2Surface); + // Target Correction + ELab = He3CD2.EvaluateInitialEnergy( ELab ,TargetThickness/2., ThetaNormalTarget); + /************************************************/ + + /************************************************/ + // Part 3 : Excitation Energy Calculation + Ex = He10Reaction -> ReconstructRelativistic( ELab , ThetaLab ); + ThetaLab=ThetaLab/deg; + /************************************************/ + + /************************************************/ + // Part 4 : Theta CM Calculation + ThetaCM = He10Reaction -> EnergyLabToThetaCM( ELab , 0)/deg; + /************************************************/ + } + } //end loop SSSD + }//end loop MUST2 } //////////////////////////////////////////////////////////////////////////////// @@ -182,9 +184,9 @@ void Analysis::InitOutputBranch() { //////////////////////////////////////////////////////////////////////////////// void Analysis::InitInputBranch(){ - RootInput:: getInstance()->GetChain()->SetBranchAddress("InitialConditions",&Initial); RootInput:: getInstance()->GetChain()->SetBranchStatus("InitialConditions",true ); RootInput:: getInstance()->GetChain()->SetBranchStatus("fIC_*",true ); + RootInput:: getInstance()->GetChain()->SetBranchAddress("InitialConditions",&Initial); } //////////////////////////////////////////////////////////////////////////////// diff --git a/NPAnalysis/Example1/CMakeLists.txt b/NPAnalysis/Example1/CMakeLists.txt index dc3f3a57e6c3bae6a4be926ca41e3237809dfa6e..ceb5ebea2e999f49b4aae22dc7bcef23eeb6bb2d 100644 --- a/NPAnalysis/Example1/CMakeLists.txt +++ b/NPAnalysis/Example1/CMakeLists.txt @@ -9,6 +9,8 @@ include("${NPLIB}/FindROOT.cmake") project (NPAnalysis) set(CMAKE_BUILD_TYPE Release) + + # Add root to the link and include directories include_directories( ${ROOT_INCLUDE_DIR}) link_directories( ${ROOT_LIBRARY_DIR}) diff --git a/NPLib/Core/NPCalibrationManager.cxx b/NPLib/Core/NPCalibrationManager.cxx index 641da2bc3dc484f3de1d95b2a70cec5bad9d3b2d..c9d40759a9b28b1ea6f7870de16b409cbbb7d7f6 100644 --- a/NPLib/Core/NPCalibrationManager.cxx +++ b/NPLib/Core/NPCalibrationManager.cxx @@ -20,6 +20,7 @@ * * *****************************************************************************/ #include "NPCalibrationManager.h" +#include "NPOptionManager.h" #include "TAsciiFile.h" #include "RootOutput.h" @@ -32,8 +33,7 @@ ////////////////////////////////////////////////////////////////// CalibrationManager* CalibrationManager::instance = 0; -CalibrationManager* CalibrationManager::getInstance(string configFileName) -{ +CalibrationManager* CalibrationManager::getInstance(string configFileName){ // A new instance of CalibrationManager is created if it does not exist: if (instance == 0) { instance = new CalibrationManager(configFileName); @@ -44,8 +44,7 @@ CalibrationManager* CalibrationManager::getInstance(string configFileName) } ////////////////////////////////////////////////////////////////// -CalibrationManager::CalibrationManager(string configFileName) -{ +CalibrationManager::CalibrationManager(string configFileName){ // Read configuration file Buffer string lineBuffer, dataBuffer; @@ -53,12 +52,15 @@ CalibrationManager::CalibrationManager(string configFileName) ifstream inputConfigFile; inputConfigFile.open(configFileName.c_str()); - cout << endl; - cout << "/////////// Calibration Information ///////////" << endl; - cout << "Getting list of Calibration File" << endl; - + if(!NPOptionManager::getInstance()->IsDefault("Calibration")){ + cout << endl; + cout << "/////////// Calibration Information ///////////" << endl; + cout << "Getting list of Calibration File" << endl; + } + if (!inputConfigFile) { - cout << "Calibration Path file :" << configFileName << " not found " << endl; + if(!NPOptionManager::getInstance()->IsDefault("Calibration")) + cout << "Calibration Path file :" << configFileName << " not found " << endl; return; } diff --git a/NPLib/Core/NPDetectorManager.cxx b/NPLib/Core/NPDetectorManager.cxx index 189487405b47649eaa9d5171e9f21e2c87729313..ea9ac4ddce699de79c17dccc4641f2ce77239bf1 100644 --- a/NPLib/Core/NPDetectorManager.cxx +++ b/NPLib/Core/NPDetectorManager.cxx @@ -77,8 +77,9 @@ void NPA::DetectorManager::ReadConfigurationFile(string Path) { ifstream ConfigFile; ConfigFile.open(Path.c_str()); - string LineBuffer; + string LineBuffer,DataBuffer; set<string> check; + bool cGeneralTarget=false; if (ConfigFile.is_open()) { cout << endl << "/////////// Detector geometry ///////////" << endl; @@ -90,6 +91,104 @@ void NPA::DetectorManager::ReadConfigurationFile(string Path) { getline(ConfigFile, LineBuffer); //Search for comment Symbol: % if (LineBuffer.compare(0, 1, "%") == 0) { ;} + //////////////////////////////////////////// + //////////// Search for Target ///////////// + //////////////////////////////////////////// + + else if (LineBuffer.compare(0, 13, "GeneralTarget") == 0 && cGeneralTarget == false) { + cGeneralTarget = true ; + cout << "////////// Target ///////////" << endl; + + // jump one line + getline(ConfigFile, LineBuffer); + getline(ConfigFile, LineBuffer); + + bool check_Thickness = false; + // bool check_Angle = false; + bool check_Radius = false; + bool check_Material = false; + bool check_X = false; + bool check_Y = false; + bool check_Z = false; + + bool ReadingStatusTarget = true; + while (ReadingStatusTarget) { + ConfigFile >> DataBuffer; + + // Search for comment Symbol % + if (DataBuffer.compare(0, 1, "%") == 0) {ConfigFile.ignore ( std::numeric_limits<std::streamsize>::max(), '\n' );getline(ConfigFile, LineBuffer);} + + else if (DataBuffer.compare(0, 10, "THICKNESS=") == 0) { + check_Thickness = true ; + ConfigFile >> DataBuffer; + // m_TargetThickness = atof(DataBuffer.c_str()) * micrometer; + m_TargetThickness = atof(DataBuffer.c_str()); + cout << "Target Thickness: " << m_TargetThickness << endl; + } + + else if (DataBuffer.compare(0, 6, "ANGLE=") == 0) { + // check_Angle = true ; + ConfigFile >> DataBuffer; + // m_TargetAngle = atof(DataBuffer.c_str()) * deg; + m_TargetAngle = atof(DataBuffer.c_str()); + cout << "Target Angle: " << m_TargetAngle << endl; + } + + else if (DataBuffer.compare(0, 7, "RADIUS=") == 0) { + check_Radius = true ; + ConfigFile >> DataBuffer; + // m_TargetRadius = atof(DataBuffer.c_str()) * mm; + m_TargetRadius = atof(DataBuffer.c_str()); + cout << "Target Radius: " << m_TargetRadius << endl; + } + + else if (DataBuffer.compare(0, 9, "MATERIAL=") == 0) { + check_Material = true ; + ConfigFile >> DataBuffer; + m_TargetMaterial = DataBuffer; + cout << "Target Material: " << m_TargetMaterial << endl; + } + + else if (DataBuffer.compare(0, 2, "X=") == 0) { + check_X = true ; + ConfigFile >> DataBuffer; + // m_TargetX = atoi(DataBuffer.c_str()) * mm; + m_TargetX = atoi(DataBuffer.c_str()); + cout << "Target Coordinates (mm): ( " << m_TargetX << " ; "; + } + + else if (DataBuffer.compare(0, 2, "Y=") == 0) { + check_Y = true ; + ConfigFile >> DataBuffer; + // m_TargetY = atoi(DataBuffer.c_str()) * mm; + m_TargetY = atoi(DataBuffer.c_str()); + cout << m_TargetY << " ; "; + } + + else if (DataBuffer.compare(0, 2, "Z=") == 0) { + check_Z = true ; + ConfigFile >> DataBuffer; + // m_TargetZ = atoi(DataBuffer.c_str()) * mm; + m_TargetZ = atoi(DataBuffer.c_str()); + cout << m_TargetZ << " )" << endl; + } + + /////////////////////////////////////////////////// + // If no Target Token and no comments, toggle out + else { + ReadingStatusTarget = false; + cout << "WARNING : Wrong Token Sequence: Getting out " << endl; + } + + /////////////////////////////////////////////////// + // If all Token found toggle out + if (check_Thickness && check_Radius && check_Material && check_X && check_Y && check_Z) + ReadingStatusTarget = false; + + } + }/////////////////////////////////////////// + /////////// Search for Detectors /////////// + //////////////////////////////////////////// else{ istringstream oss(LineBuffer); string token; diff --git a/NPLib/Core/RootInput.cxx b/NPLib/Core/RootInput.cxx index dc6f7c38cfdc6a8306eff2e43711ef51475adc89..3e2de07837a8000cdf8c3d6a5c399526f28ea484 100644 --- a/NPLib/Core/RootInput.cxx +++ b/NPLib/Core/RootInput.cxx @@ -30,7 +30,6 @@ #include "RootInput.h" #include "TAsciiFile.h" #include "NPOptionManager.h" -#include "TEnv.h" RootInput* RootInput::instance = 0; //////////////////////////////////////////////////////////////////////////////// RootInput* RootInput::getInstance(string configFileName){ @@ -58,11 +57,6 @@ RootInput::RootInput(string configFileName){ configFileName = lastfile; } - // Setting Root Parameter - gEnv->SetValue("TFile.AsyncPrefetching", 1); - gEnv->SetValue("TTreeCache.Size",300000000); - gEnv->SetValue("TTreeCache.Prefill",1); - NumberOfFriend = 0; bool CheckTreeName = false; bool CheckRootFileName = false; @@ -111,9 +105,13 @@ RootInput::RootInput(string configFileName){ std::string SHARED_LIB_EXTENSION = ".dylib"; #endif + string path = getenv("NPTOOL"); + path+="/NPLib/lib/"; string libName="libNPInteractionCoordinates"+SHARED_LIB_EXTENSION; + libName=path+libName; dlopen(libName.c_str(),RTLD_NOW); libName="libNPInitialConditions"+SHARED_LIB_EXTENSION; + libName=path+libName; dlopen(libName.c_str(),RTLD_NOW); } } diff --git a/NPLib/SSSD/TSSSDPhysics.cxx b/NPLib/SSSD/TSSSDPhysics.cxx index 29544aa6b5e30b0ac487cf94af8496b9ce7fea9a..e7ee9a916906b830ac920280fb1d8fe1fa567705 100644 --- a/NPLib/SSSD/TSSSDPhysics.cxx +++ b/NPLib/SSSD/TSSSDPhysics.cxx @@ -46,8 +46,7 @@ string itoa(int value) ClassImp(TSSSDPhysics) /////////////////////////////////////////////////////////////////////////// -TSSSDPhysics::TSSSDPhysics() - { +TSSSDPhysics::TSSSDPhysics(){ NumberOfDetector = 0; EventData = new TSSSDData; PreTreatedData = new TSSSDData; @@ -59,16 +58,14 @@ TSSSDPhysics::TSSSDPhysics() TSSSDPhysics::~TSSSDPhysics() {} /////////////////////////////////////////////////////////////////////////// -void TSSSDPhysics::Clear() - { +void TSSSDPhysics::Clear(){ DetectorNumber .clear() ; StripNumber .clear() ; Energy .clear() ; Time .clear() ; } /////////////////////////////////////////////////////////////////////////// -void TSSSDPhysics::ReadConfiguration(string Path) - { +void TSSSDPhysics::ReadConfiguration(string Path) { ifstream ConfigFile ; ConfigFile.open(Path.c_str()) ; string LineBuffer ; @@ -87,14 +84,10 @@ void TSSSDPhysics::ReadConfiguration(string Path) bool check_beta = false ; bool ReadingStatus = false ; - while (!ConfigFile.eof()) - { - + while (!ConfigFile.eof()) { getline(ConfigFile, LineBuffer); - // If line is a Start Up SSSD bloc, Reading toggle to true - if (LineBuffer.compare(0, 4, "SSSD") == 0 &&LineBuffer.compare(0, 5, "SSSDA") != 0) - { + if (LineBuffer.compare(0, 4, "SSSD") == 0 &&LineBuffer.compare(0, 5, "SSSDA") != 0) { cout << "SSSD found: " << endl ; ReadingStatus = true ; } @@ -103,8 +96,7 @@ void TSSSDPhysics::ReadConfiguration(string Path) else ReadingStatus = false ; // Reading Block - while(ReadingStatus) - { + while(ReadingStatus){ // Pickup Next Word ConfigFile >> DataBuffer ; @@ -207,8 +199,7 @@ void TSSSDPhysics::ReadConfiguration(string Path) ///////////////////////////////////////////////// // If All necessary information there, toggle out - if ( (check_A && check_B && check_C && check_D) || (check_Theta && check_Phi && check_R && check_beta) ) - { + if ( (check_A && check_B && check_C && check_D) || (check_Theta && check_Phi && check_R && check_beta) ) { ReadingStatus = false; ///Add The previously define telescope @@ -236,7 +227,6 @@ void TSSSDPhysics::ReadConfiguration(string Path) ReadingStatus = false ; } - } } @@ -246,33 +236,27 @@ void TSSSDPhysics::ReadConfiguration(string Path) /////////////////////////////////////////////////////////////////////////// -void TSSSDPhysics::AddParameterToCalibrationManager() - { +void TSSSDPhysics::AddParameterToCalibrationManager(){ CalibrationManager* Cal = CalibrationManager::getInstance(); - for(int i = 0 ; i < NumberOfDetector ; ++i) - { + for(int i = 0 ; i < NumberOfDetector ; ++i){ - for( int j = 0 ; j < 16 ; ++j) - { + for( int j = 0 ; j < 16 ; ++j){ Cal->AddParameter("SSSD", "Detector"+ NPA::itoa(i+1)+"_Strip"+ NPA::itoa(j+1)+"_E","SSSD_DETECTOR_"+ NPA::itoa(i+1)+"_STRIP_"+ NPA::itoa(j+1)+"_E") ; Cal->AddParameter("SSSD", "Detector"+ NPA::itoa(i+1)+"_Strip"+ NPA::itoa(j+1)+"_T","SSSD_DETECTOR_"+ NPA::itoa(i+1)+"_STRIP_"+ NPA::itoa(j+1)+"_T") ; } - } } - + /////////////////////////////////////////////////////////////////////////// -void TSSSDPhysics::InitializeRootInputRaw() - { +void TSSSDPhysics::InitializeRootInputRaw(){ TChain* inputChain = RootInput::getInstance()->GetChain(); inputChain->SetBranchStatus ( "SSSD" , true ); inputChain->SetBranchStatus ( "fSSSD_*" , true ); inputChain->SetBranchAddress( "SSSD" , &EventData ); } /////////////////////////////////////////////////////////////////////////// -void TSSSDPhysics::InitializeRootInputPhysics() - { +void TSSSDPhysics::InitializeRootInputPhysics(){ TChain* inputChain = RootInput::getInstance()->GetChain(); inputChain->SetBranchStatus ( "SSSD" , true ); inputChain->SetBranchStatus ( "DetectorNumber", true ); @@ -283,32 +267,25 @@ void TSSSDPhysics::InitializeRootInputPhysics() } /////////////////////////////////////////////////////////////////////////// -void TSSSDPhysics::InitializeRootOutput() - { +void TSSSDPhysics::InitializeRootOutput(){ TTree* outputTree = RootOutput::getInstance()->GetTree() ; outputTree->Branch( "SSSD" , "TSSSDPhysics" , &EventPhysics ) ; } /////////////////////////////////////////////////////////////////////////// -void TSSSDPhysics::BuildPhysicalEvent() - { +void TSSSDPhysics::BuildPhysicalEvent(){ BuildSimplePhysicalEvent() ; } /////////////////////////////////////////////////////////////////////////// -void TSSSDPhysics::BuildSimplePhysicalEvent() - { +void TSSSDPhysics::BuildSimplePhysicalEvent(){ PreTreat(); - - for(unsigned int i = 0 ; i < PreTreatedData->GetEnergyMult() ; ++i) - { - + for(unsigned int i = 0 ; i < PreTreatedData->GetEnergyMult() ; ++i){ DetectorNumber .push_back( PreTreatedData->GetEnergyDetectorNbr(i) ) ; StripNumber .push_back( PreTreatedData->GetEnergyStripNbr(i) ) ; Energy .push_back( PreTreatedData->GetEnergy(i) ) ; // Look For associate Time - for(unsigned int j = 0 ; j < PreTreatedData->GetTimeMult() ; ++j ) - { + for(unsigned int j = 0 ; j < PreTreatedData->GetTimeMult() ; ++j ){ if(PreTreatedData->GetEnergyDetectorNbr(i) == PreTreatedData->GetTimeDetectorNbr(j) && PreTreatedData->GetEnergyStripNbr(i)==PreTreatedData->GetTimeStripNbr(j)) Time.push_back(PreTreatedData->GetTime(j)); } @@ -317,30 +294,23 @@ void TSSSDPhysics::BuildSimplePhysicalEvent() } /////////////////////////////////////////////////////////////////////////// -void TSSSDPhysics::PreTreat() - { - ClearPreTreatedData(); - - // E - for(int i = 0 ; i < EventData->GetEnergyMult() ; ++i) - { - if(EventData->GetEnergy(i) > m_Pedestal_Threshold && ChannelStatus[EventData->GetEnergyDetectorNbr(i)-1][EventData->GetEnergyStripNbr(i)-1]) - { +void TSSSDPhysics::PreTreat(){ + ClearPreTreatedData(); + + // E + for(int i = 0 ; i < EventData->GetEnergyMult() ; ++i){ + if(EventData->GetEnergy(i) > m_Pedestal_Threshold && ChannelStatus[EventData->GetEnergyDetectorNbr(i)-1][EventData->GetEnergyStripNbr(i)-1]){ double E = fSi_E(EventData , i); - if( E > m_E_Threshold ) - { + if( E > m_E_Threshold ){ PreTreatedData->SetEnergyDetectorNbr( EventData->GetEnergyDetectorNbr(i) ) ; PreTreatedData->SetEnergyStripNbr( EventData->GetEnergyStripNbr(i) ) ; PreTreatedData->SetEnergy( E ) ; } } } - // T - for(int i = 0 ; i < EventData->GetTimeMult() ; ++i) - { - if(ChannelStatus[EventData->GetEnergyDetectorNbr(i)-1][EventData->GetEnergyStripNbr(i)-1]) - { + for(int i = 0 ; i < EventData->GetTimeMult() ; ++i){ + if(ChannelStatus[EventData->GetTimeDetectorNbr(i)-1][EventData->GetTimeStripNbr(i)-1]){ PreTreatedData->SetTimeDetectorNbr( EventData->GetTimeDetectorNbr(i) ) ; PreTreatedData->SetTimeStripNbr( EventData->GetTimeStripNbr(i) ) ; PreTreatedData->SetTime( fSi_T(EventData , i) ) ; @@ -349,8 +319,7 @@ void TSSSDPhysics::PreTreat() } /////////////////////////////////////////////////////////////////////////// -void TSSSDPhysics::InitializeStandardParameter() - { +void TSSSDPhysics::InitializeStandardParameter(){ // Enable all channel vector<bool> TempChannelStatus; ChannelStatus.clear(); @@ -359,8 +328,7 @@ void TSSSDPhysics::InitializeStandardParameter() ChannelStatus[i] = TempChannelStatus; } /////////////////////////////////////////////////////////////////////////// -void TSSSDPhysics::ReadAnalysisConfig() -{ +void TSSSDPhysics::ReadAnalysisConfig(){ bool ReadingStatus = false; // path to file diff --git a/NPSimulation/SSSD/CMakeLists.txt b/NPSimulation/SSSD/CMakeLists.txt index f874cde2faca3de3f6e49b0a880c63e93aa63249..ca38832e559aeb1b151aa7e67f7ca1b9d6944ac9 100644 --- a/NPSimulation/SSSD/CMakeLists.txt +++ b/NPSimulation/SSSD/CMakeLists.txt @@ -1,2 +1,2 @@ -add_library(NPSSSSD SHARED ThinSi.cc ThinSiScorers.cc) +add_library(NPSSSSD SHARED SSSD.cc) target_link_libraries(NPSSSSD NPSCore ${ROOT_LIBRARIES} ${Geant4_LIBRARIES} ${NPLib_LIBRARIES} -lNPSSSD) diff --git a/NPSimulation/SSSD/ThinSi.cc b/NPSimulation/SSSD/SSSD.cc similarity index 72% rename from NPSimulation/SSSD/ThinSi.cc rename to NPSimulation/SSSD/SSSD.cc index 7265b209cc10245bf9b4e0d662fe20e047a43a85..1493b085bfb57e303285d772449731c164d86a03 100644 --- a/NPSimulation/SSSD/ThinSi.cc +++ b/NPSimulation/SSSD/SSSD.cc @@ -42,13 +42,12 @@ #include "G4SubtractionSolid.hh" // NPTool header -#include "ThinSi.hh" +#include "SSSD.hh" #include "MaterialManager.hh" #include "NPSDetectorFactory.hh" -#include "ObsoleteGeneralScorers.hh" -#include "ThinSiScorers.hh" +#include "SiliconScorers.hh" #include "RootOutput.h" -using namespace THINSI; +using namespace SSSD_LOCAL; // CLHEP header #include "CLHEP/Random/RandGauss.h" @@ -59,17 +58,18 @@ using namespace CLHEP; //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -// ThinSi Specific Method -ThinSi::ThinSi(){ +// SSSD Specific Method +SSSD::SSSD(){ InitializeMaterial(); m_Event = new TSSSDData(); m_StripScorer=0; } -ThinSi::~ThinSi(){ +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +SSSD::~SSSD(){ } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void ThinSi::AddTelescope( G4ThreeVector TL, +void SSSD::AddTelescope( G4ThreeVector TL, G4ThreeVector BL, G4ThreeVector BR, G4ThreeVector TR) @@ -88,8 +88,8 @@ void ThinSi::AddTelescope( G4ThreeVector TL, m_beta_v.push_back(0); m_beta_w.push_back(0); } - -void ThinSi::AddTelescope( G4double R, +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +void SSSD::AddTelescope( G4double R, G4double Theta, G4double Phi, G4double beta_u, @@ -115,7 +115,7 @@ void ThinSi::AddTelescope( G4double R, } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void ThinSi::VolumeMaker( G4int DetNumber , +void SSSD::VolumeMaker( G4int DetNumber , G4ThreeVector Det_pos , G4RotationMatrix* Det_rot , G4LogicalVolume* world ) @@ -130,21 +130,21 @@ void ThinSi::VolumeMaker( G4int DetNumber , /////////General Geometry Parameter Definition ///////////////// //////////////////////////////////////////////////////////////// /////// Starting Volume Definition /////// - G4String Name = "ThinSi" + DetectorNumber; + G4String Name = "SSSD" + DetectorNumber; - G4Box* solidThinSi = new G4Box(Name+"Solid", 0.5*DetectorSize, 0.5*DetectorSize, 0.5*FrameThickness); + G4Box* solidSSSD = new G4Box(Name+"Solid", 0.5*DetectorSize, 0.5*DetectorSize, 0.5*FrameThickness); - G4LogicalVolume* logicThinSi = - new G4LogicalVolume(solidThinSi, m_MaterialVacuum, Name+"_logic", 0, 0); + G4LogicalVolume* logicSSSD = + new G4LogicalVolume(solidSSSD, m_MaterialVacuum, Name+"_logic", 0, 0); new G4PVPlacement( G4Transform3D(*Det_rot, Det_pos) , - logicThinSi , + logicSSSD , Name , world , false , - 0); + DetNumber); - logicThinSi->SetVisAttributes(G4VisAttributes::Invisible); + logicSSSD->SetVisAttributes(G4VisAttributes::Invisible); // Frame is made of 4 thick box (2 Horizontal and 2 Vertical) G4Box* solidFrameHorizontal = new G4Box(Name + "_Frame", 0.5*SiliconSize, 0.5*(DetectorSize - SiliconSize) / 2, 0.5*FrameThickness*mm) ; G4Box* solidFrameVertical = new G4Box(Name + "_Frame", 0.5*(DetectorSize - SiliconSize) / 2, 0.5*DetectorSize, 0.5*FrameThickness*mm) ; @@ -156,7 +156,7 @@ void ThinSi::VolumeMaker( G4int DetNumber , G4LogicalVolume* logicFrameVertical = new G4LogicalVolume(solidFrameVertical, m_MaterialAl, Name, 0, 0); logicFrameVertical->SetVisAttributes(VisAtt1); - + G4ThreeVector FrameTopPosition = G4ThreeVector(0 , 0.5 * SiliconSize + 0.5 * (DetectorSize - SiliconSize) / 2 , 0) ; G4ThreeVector FrameBottomPosition = G4ThreeVector(0 , -0.5 * SiliconSize - 0.5 * (DetectorSize - SiliconSize) / 2 , 0) ; G4ThreeVector FrameLeftPosition = G4ThreeVector(0.5 * SiliconSize + 0.5 * (DetectorSize - SiliconSize) / 2 , 0 , 0) ; @@ -167,33 +167,33 @@ void ThinSi::VolumeMaker( G4int DetNumber , FrameTopPosition, logicFrameHorizontal, Name + "_Frame", - logicThinSi, + logicSSSD, false, - 0); + DetNumber); new G4PVPlacement( 0, FrameBottomPosition, logicFrameHorizontal, Name + "_Frame", - logicThinSi, + logicSSSD, false, - 0); + DetNumber); new G4PVPlacement( 0, FrameLeftPosition, logicFrameVertical, Name + "_Frame", - logicThinSi, + logicSSSD, false, - 0); + DetNumber); new G4PVPlacement( 0, FrameRightPosition, logicFrameVertical, Name + "_Frame", - logicThinSi, + logicSSSD, false, - 0); + DetNumber); G4ThreeVector posAluFront = G4ThreeVector(0 , 0 , AluStripFront_PosZ) ; @@ -201,25 +201,25 @@ void ThinSi::VolumeMaker( G4int DetNumber , G4ThreeVector posAluBack = G4ThreeVector(0 , 0 , AluStripBack_PosZ ) ; G4Box* solidAlu = - new G4Box("ThinSiAlu", 0.5*SiliconSize, 0.5*SiliconSize, 0.5*AluThickness) ; + new G4Box("SSSDAlu", 0.5*SiliconSize, 0.5*SiliconSize, 0.5*AluThickness) ; G4LogicalVolume* logicAlu = new G4LogicalVolume(solidAlu, m_MaterialAl, "logicAlu", 0, 0, 0) ; - - new G4PVPlacement(0 , posAluFront , logicAlu , Name + "_AluFront" , logicThinSi , true, 0) ; - new G4PVPlacement(0 , posAluBack , logicAlu , Name + "_AluBack" , logicThinSi , true, 0) ; + new G4PVPlacement(0 , posAluFront , logicAlu , Name + "_AluFront" , logicSSSD , true, DetNumber) ; + + new G4PVPlacement(0 , posAluBack , logicAlu , Name + "_AluBack" , logicSSSD , true, DetNumber) ; G4Box* solidSi = - new G4Box("ThinSi", 0.5*SiliconSize, 0.5*SiliconSize, 0.5*SiliconThickness); + new G4Box("SSSD", 0.5*SiliconSize, 0.5*SiliconSize, 0.5*SiliconThickness); G4LogicalVolume* logicSi = new G4LogicalVolume(solidSi, m_MaterialSilicon, "logicSi", 0, 0, 0); logicAlu->SetVisAttributes(G4VisAttributes::Invisible); - new G4PVPlacement(0, posSi, logicSi, Name + "_Si", logicThinSi, true, 0); + new G4PVPlacement(0, posSi, logicSi, Name + "_Si", logicSSSD, true, DetNumber); //attach it to the Silicon plate logicSi ->SetSensitiveDetector(m_StripScorer); @@ -230,10 +230,10 @@ void ThinSi::VolumeMaker( G4int DetNumber , //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Virtual Method of NPS::VDetector class - +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Read stream at Configfile to pick-up parameters of detector (Position,...) // Called in DetecorConstruction::ReadDetextorConfiguration Method -void ThinSi::ReadConfiguration(string Path){ +void SSSD::ReadConfiguration(string Path){ ifstream ConfigFile ; ConfigFile.open(Path.c_str()) ; string LineBuffer ; @@ -258,7 +258,7 @@ void ThinSi::ReadConfiguration(string Path){ getline(ConfigFile, LineBuffer); - // If line is a Start Up ThinSi bloc, Reading toggle to true + // If line is a Start Up SSSD bloc, Reading toggle to true if (LineBuffer.compare(0, 4, "SSSD") == 0 && LineBuffer.compare(0, 5, "SSSDA") != 0) { G4cout << "///" << G4endl ; @@ -441,10 +441,10 @@ void ThinSi::ReadConfiguration(string Path){ } } - +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Construct detector and inialise sensitive part. // Called After DetecorConstruction::AddDetector Method -void ThinSi::ConstructDetector(G4LogicalVolume* world){ +void SSSD::ConstructDetector(G4LogicalVolume* world){ G4RotationMatrix* Det_rot = NULL; G4ThreeVector Det_pos = G4ThreeVector(0, 0, 0); @@ -519,183 +519,111 @@ void ThinSi::ConstructDetector(G4LogicalVolume* world){ Det_pos = Det_w + CT ; } - - VolumeMaker(i + 1 , Det_pos , Det_rot , world); } delete Det_rot ; } - +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Add Detector branch to the EventTree. // Called After DetecorConstruction::AddDetector Method -void ThinSi::InitializeRootOutput(){ +void SSSD::InitializeRootOutput(){ RootOutput *pAnalysis = RootOutput::getInstance(); TTree *pTree = pAnalysis->GetTree(); pTree->Branch("SSSD", "TSSSDData", &m_Event) ; pTree->SetBranchAddress("SSSD", &m_Event) ; } - +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Read sensitive part and fill the Root tree. // Called at in the EventAction::EndOfEventAvtion -void ThinSi::ReadSensitive(const G4Event* event){ +void SSSD::ReadSensitive(const G4Event* event){ m_Event->Clear(); - ////////////////////////////////////////////////////////////////////////////////////// - //////////////////////// Used to Read Event Map of detector ////////////////////////// - ////////////////////////////////////////////////////////////////////////////////////// - - // Si - G4THitsMap<G4int>* DetNbrHitMap; - G4THitsMap<G4int>* StripNbrHitMap; - G4THitsMap<G4double>* EnergyHitMap; - G4THitsMap<G4double>* TimeHitMap; - - std::map<G4int, G4int*>::iterator DetNbr_itr ; - std::map<G4int, G4int*>::iterator StripNbr_itr ; - std::map<G4int, G4double*>::iterator Energy_itr ; - std::map<G4int, G4double*>::iterator Time_itr ; - ////////////////////////////////////////////////////////////////////////////////////// - ////////////////////////////////////////////////////////////////////////////////////// - // Read the Scorer associate to the Silicon Strip - - //DetectorNumber - G4int DetNbrCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("ThinSi_StripScorer/DetectorNumber"); - DetNbrHitMap = (G4THitsMap<G4int>*)(event->GetHCofThisEvent()->GetHC(DetNbrCollectionID)); - DetNbr_itr = DetNbrHitMap->GetMap()->begin(); - - //StripNumber - G4int StripNbrCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("ThinSi_StripScorer/StripNumber"); - StripNbrHitMap = (G4THitsMap<G4int>*)(event->GetHCofThisEvent()->GetHC(StripNbrCollectionID)); - - //Energy - G4int StripEnergyCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("ThinSi_StripScorer/StripEnergy"); - EnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripEnergyCollectionID)); - - //Time - G4int StripTimeCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("ThinSi_StripScorer/StripTime"); - TimeHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripTimeCollectionID)); - - G4int sizeN = DetNbrHitMap ->entries(); - G4int sizeS = StripNbrHitMap ->entries(); - G4int sizeE = EnergyHitMap ->entries(); - G4int sizeT = TimeHitMap ->entries(); - - // Loop on Det Number - for (G4int l = 0 ; l < sizeN ; l++) - { - G4int N = *(DetNbr_itr->second); - G4int NTrackID = DetNbr_itr->first - N; - - if (N > 0) - { - m_Event->SetEnergyDetectorNbr(N); - m_Event->SetTimeDetectorNbr(N); - - // Strip Number - StripNbr_itr = StripNbrHitMap->GetMap()->begin(); - for (G4int h = 0 ; h < sizeS ; h++) { - G4int STrackID = StripNbr_itr->first - N ; - G4int S = *(StripNbr_itr->second); - - if (STrackID == NTrackID) { - m_Event->SetEnergyStripNbr(S); - m_Event->SetTimeStripNbr(S); - } - - StripNbr_itr++; - } - - // Energy - Energy_itr = EnergyHitMap->GetMap()->begin(); - for (G4int h = 0 ; h < sizeE ; h++) { - G4int ETrackID = Energy_itr->first - N; - G4double E = *(Energy_itr->second); - - if (ETrackID == NTrackID) { - m_Event->SetEnergy( RandGauss::shoot(E, ResoEnergy ) ); - } - - Energy_itr++; - } - - - // Time - Time_itr = TimeHitMap->GetMap()->begin(); - for (G4int h = 0 ; h < sizeT ; h++) { - G4int TTrackID = Time_itr->first - N ; - G4double T = *(Time_itr->second); - - if (TTrackID == NTrackID) { - m_Event->SetTime( RandGauss::shoot(T, ResoTime ) ); - } - - Time_itr++; - } + /////////// + G4THitsMap<G4double*>* StripHitMap; + std::map<G4int, G4double**>::iterator Strip_itr; + + G4int StripCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("SSSD_Scorer/StripScorer"); + StripHitMap = (G4THitsMap<G4double*>*)(event->GetHCofThisEvent()->GetHC(StripCollectionID)); + + // Loop on the Strip map + for (Strip_itr = StripHitMap->GetMap()->begin() ; Strip_itr != StripHitMap->GetMap()->end() ; Strip_itr++){ + + G4double* Info = *(Strip_itr->second); + + double Energy = Info[0]; + + if(Energy>EnergyThreshold){ + double Time = Info[1]; + int DetNbr = (int) Info[7]; + int StripFront = (int) Info[8]; + + m_Event->SetEnergyDetectorNbr(DetNbr); + m_Event->SetEnergyStripNbr(StripFront); + m_Event->SetEnergy(RandGauss::shoot(Energy, ResoEnergy)); + + m_Event->SetTimeDetectorNbr(DetNbr); + m_Event->SetTimeStripNbr(StripFront); + m_Event->SetTime(RandGauss::shoot(Time, ResoTime)); + } - - DetNbr_itr++; } - // clear map for next event + StripHitMap->clear(); + - DetNbrHitMap ->clear(); - StripNbrHitMap ->clear(); - EnergyHitMap ->clear(); - TimeHitMap ->clear(); } - -void ThinSi::InitializeScorers(){ +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +void SSSD::InitializeScorers(){ bool already_exist = false; // Silicon Associate Scorer - m_StripScorer = CheckScorer("ThinSi_StripScorer",already_exist); + m_StripScorer = CheckScorer("SSSD_Scorer",already_exist); if(already_exist) return; - G4VPrimitiveScorer* DetNbr = new OBSOLETEGENERALSCORERS::PSDetectorNumber("DetectorNumber","ThinSi_", 0); - G4VPrimitiveScorer* StripNbr = new PSStripNumber("StripNumber",0,SiliconSize, NumberOfStrip); - G4VPrimitiveScorer* Energy = new OBSOLETEGENERALSCORERS::PSEnergy("StripEnergy","ThinSi_", 0); - G4VPrimitiveScorer* TOF = new OBSOLETEGENERALSCORERS::PSTOF("StripTime","ThinSi_", 0); - - - //and register it to the multifunctionnal detector - m_StripScorer->RegisterPrimitive(DetNbr); - m_StripScorer->RegisterPrimitive(StripNbr); - m_StripScorer->RegisterPrimitive(Energy); - m_StripScorer->RegisterPrimitive(TOF); + G4VPrimitiveScorer* StripScorer = + new SILICONSCORERS::PS_Silicon_Rectangle("StripScorer",0, + DetectorSize, + DetectorSize, + NumberOfStrip, + 1); - // Add All Scorer to the Global Scorer Manager - G4SDManager::GetSDMpointer()->AddNewDetector(m_StripScorer) ; + m_StripScorer->RegisterPrimitive(StripScorer); + G4SDManager::GetSDMpointer()->AddNewDetector(m_StripScorer); } +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //////////////////////////////////////////////////////////////// /////////////////Material Definition /////////////////////////// //////////////////////////////////////////////////////////////// -void ThinSi::InitializeMaterial(){ +void SSSD::InitializeMaterial(){ m_MaterialSilicon = MaterialManager::getInstance()->GetMaterialFromLibrary("Si"); m_MaterialAl = MaterialManager::getInstance()->GetMaterialFromLibrary("Al"); m_MaterialVacuum = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); } +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... - //////////////////////////////////////////////////////////////////////////////// - // Construct Method to be pass to the DetectorFactory // - //////////////////////////////////////////////////////////////////////////////// - NPS::VDetector* ThinSi::Construct(){ - return (NPS::VDetector*) new ThinSi(); - } - - //////////////////////////////////////////////////////////////////////////////// - // Registering the construct method to the factory // - //////////////////////////////////////////////////////////////////////////////// - extern"C" { - class proxy{ - public: - proxy(){ - NPS::DetectorFactory::getInstance()->AddToken("ThinSi","ThinSi"); - NPS::DetectorFactory::getInstance()->AddDetector("ThinSi",ThinSi::Construct); - } -}; +//////////////////////////////////////////////////////////////////////////////// +// Construct Method to be pass to the DetectorFactory // +//////////////////////////////////////////////////////////////////////////////// +NPS::VDetector* SSSD::Construct(){ + return (NPS::VDetector*) new SSSD(); +} - proxy p; - } +//////////////////////////////////////////////////////////////////////////////// +// Registering the construct method to the factory // +//////////////////////////////////////////////////////////////////////////////// +extern"C" { + class proxy{ + public: + proxy(){ + NPS::DetectorFactory::getInstance()->AddToken("SSSD","SSSD"); + NPS::DetectorFactory::getInstance()->AddDetector("SSSD",SSSD::Construct); + } + }; + + proxy p; +} diff --git a/NPSimulation/SSSD/ThinSi.hh b/NPSimulation/SSSD/SSSD.hh similarity index 97% rename from NPSimulation/SSSD/ThinSi.hh rename to NPSimulation/SSSD/SSSD.hh index d47e79d3f43c678d2d423b85573123e2b609b59e..3e3021ddf40ace8d5e98c9fc485a834c4efc5c7a 100644 --- a/NPSimulation/SSSD/ThinSi.hh +++ b/NPSimulation/SSSD/SSSD.hh @@ -1,5 +1,5 @@ -#ifndef ThinSi_h -#define ThinSi_h 1 +#ifndef SSSD_h +#define SSSD_h 1 /***************************************************************************** * Copyright (C) 2009-2013 this file is part of the NPTool Project * * * @@ -38,15 +38,14 @@ // NPLib #include "TSSSDData.h" using namespace std; - using namespace CLHEP; +using namespace CLHEP; //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -namespace THINSI -{ +namespace SSSD_LOCAL{ // Energy and time Resolution const G4double ResoTime = 0 ; const G4double ResoEnergy = 0.064 ;// = 150keV of Resolution // Unit is MeV/2.35 - + const G4double EnergyThreshold = 100*keV; // Geometry const G4double DetectorSize = 68*mm ; const G4double SiliconThickness = 20*micrometer ; @@ -58,19 +57,15 @@ namespace THINSI const G4double AluStripFront_PosZ = -0.5*SiliconThickness - 0.5*AluThickness ; const G4double Si_PosZ = 0 ; const G4double AluStripBack_PosZ = 0.5*SiliconThickness + 0.5*AluThickness ; - } -using namespace THINSI ; - -class ThinSi : public NPS::VDetector -{ +class SSSD : public NPS::VDetector{ //////////////////////////////////////////////////// /////// Default Constructor and Destructor ///////// //////////////////////////////////////////////////// public: - ThinSi() ; - virtual ~ThinSi() ; + SSSD() ; + ~SSSD() ; //////////////////////////////////////////////////// //////// Specific Function of this Class /////////// diff --git a/NPSimulation/SSSD/ThinSiScorers.cc b/NPSimulation/SSSD/ThinSiScorers.cc index ba2ba9889d8b2ec9a27cf4f9dc4187b99561934f..367e2d1c2f166650354d62ea35c7f7f6f7b64c07 100644 --- a/NPSimulation/SSSD/ThinSiScorers.cc +++ b/NPSimulation/SSSD/ThinSiScorers.cc @@ -56,6 +56,7 @@ G4bool PSStripNumber::ProcessHits(G4Step* aStep, G4TouchableHistory*) G4double X = int(temp) + 1 ; //Rare case where particle is close to edge of silicon plan if (X == m_NumberOfStrip+1) X = m_NumberOfStrip; + if (X ==0 ) X =1 ; G4double edep = aStep->GetTotalEnergyDeposit(); if (edep < TriggerThreshold) return FALSE; G4int index = aStep->GetTrack()->GetTrackID(); diff --git a/NPSimulation/Sharc/Sharc.cc b/NPSimulation/Sharc/Sharc.cc index 2aacfdc7d3cb2581c37c89c6d72e4ac23c1042b9..62659186fde9875c9375f84202a2476d74934b32 100644 --- a/NPSimulation/Sharc/Sharc.cc +++ b/NPSimulation/Sharc/Sharc.cc @@ -48,7 +48,6 @@ // NPL #include "NPOptionManager.h" -//#include "SharcScorers.hh" #include "RootOutput.h" using namespace SHARC;