diff --git a/NPLib/Tiara/TTiaraBarrelPhysics.cxx b/NPLib/Tiara/TTiaraBarrelPhysics.cxx index ab0b8125c956f2f66b27711a3744a48d01363625..8888e7a50341543b69adfa90ff0e0635bc71c600 100644 --- a/NPLib/Tiara/TTiaraBarrelPhysics.cxx +++ b/NPLib/Tiara/TTiaraBarrelPhysics.cxx @@ -69,9 +69,10 @@ void TTiaraBarrelPhysics::BuildSimplePhysicalEvent(){ void TTiaraBarrelPhysics::BuildPhysicalEvent(){ PreTreat(); - unsigned int sizeU = m_PreTreatedData->GetFrontUpstreamEMult(); - unsigned int sizeD = m_PreTreatedData->GetFrontDownstreamEMult(); - unsigned int sizeB = m_PreTreatedData->GetBackEMult(); + unsigned int sizeU = m_PreTreatedData->GetFrontUpstreamEMult(); + unsigned int sizeD = m_PreTreatedData->GetFrontDownstreamEMult(); + unsigned int sizeB = m_PreTreatedData->GetBackEMult(); + for(unsigned int k = 0 ; k < sizeB ; k++){ for(unsigned int i = 0 ; i < sizeU ; i++){ if(m_PreTreatedData->GetFrontUpstreamEDetectorNbr(i) == m_PreTreatedData->GetBackEDetectorNbr(k)) diff --git a/NPSimulation/Sharc/Sharc.cc b/NPSimulation/Sharc/Sharc.cc index 80e98e5397dca7570925fdf568c7195134a74db5..0746f33365d6b2609e02319ad14c1d6dd6aef9ca 100644 --- a/NPSimulation/Sharc/Sharc.cc +++ b/NPSimulation/Sharc/Sharc.cc @@ -796,7 +796,6 @@ void Sharc::InitializeScorers(){ //////////////////////////////////////////////////////////////// void Sharc::InitializeMaterial(){ m_MaterialSilicon = MaterialManager::getInstance()->GetMaterialFromLibrary("Si"); - m_MaterialAl = MaterialManager::getInstance()->GetMaterialFromLibrary("Al"); m_MaterialPCB = MaterialManager::getInstance()->GetMaterialFromLibrary("PCB"); m_MaterialVacuum = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); diff --git a/NPSimulation/Sharc/Sharc.hh b/NPSimulation/Sharc/Sharc.hh index a8ad6ce80d66a47702734b1118fbe6ef11924885..acb889a657e3dc293a06bb6d8b45058eba2cc74e 100644 --- a/NPSimulation/Sharc/Sharc.hh +++ b/NPSimulation/Sharc/Sharc.hh @@ -210,7 +210,6 @@ private: // List of material G4Material* m_MaterialSilicon ; - G4Material* m_MaterialAl ; G4Material* m_MaterialVacuum ; G4Material* m_MaterialPCB ; diff --git a/NPSimulation/Tiara/Tiara.cc b/NPSimulation/Tiara/Tiara.cc index 05463ab62dfea285b6211dae64cf3952e5eeeb55..ff2acf13119c301ddba6a3904c08cdae76f41d90 100644 --- a/NPSimulation/Tiara/Tiara.cc +++ b/NPSimulation/Tiara/Tiara.cc @@ -44,10 +44,11 @@ // NPS #include "Tiara.hh" #include "MaterialManager.hh" +#include "ResistiveStripScorers.hh" +#include "SiliconScorers.hh" + // NPL #include "NPOptionManager.h" - -//#include "TiaraScorers.hh" #include "RootOutput.h" using namespace TIARA; @@ -146,15 +147,99 @@ void Tiara::ConstructDetector(G4LogicalVolume* world){ // Read sensitive part and fill the Root tree. // Called at in the EventAction::EndOfEventAvtion void Tiara::ReadSensitive(const G4Event* event){ + m_EventBarrel->Clear(); + m_EventHyball->Clear(); + + // InnerBarrel // + G4THitsMap<G4double*>* InnerBarrelHitMap; + std::map<G4int, G4double**>::iterator InnerBarrel_itr; + G4int InnerBarrelCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("Tiara_InnerBarrelScorer/InnerBarrel"); + InnerBarrelHitMap = (G4THitsMap<G4double*>*)(event->GetHCofThisEvent()->GetHC(InnerBarrelCollectionID)); + + // Loop on the InnerBarrel map + for (InnerBarrel_itr = InnerBarrelHitMap->GetMap()->begin() ; InnerBarrel_itr != InnerBarrelHitMap->GetMap()->end() ; InnerBarrel_itr++){ + G4double* Info = *(InnerBarrel_itr->second); + + cout << Info[0] << " " << Info[1] << " " << Info[2] << " " << Info[3] << " " << Info[4] << endl ; + + // Upstream Energy + double EU = RandGauss::shoot(Info[0],ResoEnergy); + if(EU>EnergyThreshold){ + m_EventBarrel->SetFrontUpstreamE(Info[3],Info[4],EU); + m_EventBarrel->SetFrontUpstreamT(Info[3],Info[4],Info[2]); + } + + // Downstream Energy + double ED = RandGauss::shoot(Info[1],ResoEnergy); + if(ED>EnergyThreshold){ + m_EventBarrel->SetFrontDownstreamE(Info[3],Info[4],ED); + m_EventBarrel->SetFrontDownstreamT(Info[3],Info[4],Info[2]); + } + + // Back Energy + double EB = RandGauss::shoot(Info[1]+Info[0],ResoEnergy); + if(ED>EnergyThreshold){ + m_EventBarrel->SetBackE(Info[3],EB); + m_EventBarrel->SetBackT(Info[3],Info[2]); + } + } + // Clear Map for next event + InnerBarrelHitMap->clear(); + + // OuterBarrel // + G4THitsMap<G4double*>* OuterBarrelHitMap; + std::map<G4int, G4double**>::iterator OuterBarrel_itr; + G4int OuterBarrelCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("Tiara_OuterBarrelScorer/OuterBarrel"); + OuterBarrelHitMap = (G4THitsMap<G4double*>*)(event->GetHCofThisEvent()->GetHC(OuterBarrelCollectionID)); + + // Loop on the OuterBarrel map + for (OuterBarrel_itr = OuterBarrelHitMap->GetMap()->begin() ; OuterBarrel_itr != OuterBarrelHitMap->GetMap()->end() ; OuterBarrel_itr++){ + G4double* Info = *(OuterBarrel_itr->second); + + double E = RandGauss::shoot(Info[0],ResoEnergy); + if(E>EnergyThreshold){ + m_EventBarrel->SetOuterE(Info[7],Info[9],E); + m_EventBarrel->SetOuterT(Info[7],Info[9],Info[1]); + } + } + // Clear Map for next event + OuterBarrelHitMap->clear(); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... void Tiara::InitializeScorers(){ + + m_InnerBarrelScorer = new G4MultiFunctionalDetector("Tiara_InnerBarrelScorer"); + m_OuterBarrelScorer = new G4MultiFunctionalDetector("Tiara_OuterBarrelScorer"); + + G4VPrimitiveScorer* InnerBarrel = new SILICONSCORERS::PS_Silicon_Resistive("InnerBarrel", + INNERBARREL_ActiveWafer_Length, + INNERBARREL_ActiveWafer_Width, + INNERBARREL_NumberOfStrip); + + m_InnerBarrelScorer->RegisterPrimitive(InnerBarrel); + + G4VPrimitiveScorer* OuterBarrel = new SILICONSCORERS::PS_Silicon_Rectangle("OuterBarrel", + INNERBARREL_ActiveWafer_Length, + INNERBARREL_ActiveWafer_Width, + 1, + OUTERBARREL_NumberOfStrip); + + m_OuterBarrelScorer->RegisterPrimitive(OuterBarrel); + + + // Add All Scorer to the Global Scorer Manager + G4SDManager::GetSDMpointer()->AddNewDetector(m_InnerBarrelScorer) ; + G4SDManager::GetSDMpointer()->AddNewDetector(m_OuterBarrelScorer) ; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... void Tiara::InitializeRootOutput(){ +RootOutput *pAnalysis = RootOutput::getInstance(); +TTree *pTree = pAnalysis->GetTree(); +pTree->Branch("TiaraBarrel", "TTiaraBarrelData", &m_EventBarrel) ; +pTree->Branch("TiaraHyball", "TTiaraHyballData", &m_EventHyball) ; } @@ -256,12 +341,16 @@ void Tiara::ConstructInnerBarrel(G4LogicalVolume* world){ G4LogicalVolume* logicActiveWafer = new G4LogicalVolume(ActiveWafer,m_MaterialSilicon,"logicActiveWafer", 0, 0, 0); logicActiveWafer->SetVisAttributes(SiliconVisAtt); + + // Set the sensitive volume + logicActiveWafer->SetSensitiveDetector(m_InnerBarrelScorer); // The Distance from target is given by half the lenght of a detector // plus the length of a detector inclined by 45 deg. G4double DistanceFromTarget = INNERBARREL_PCB_Width*(0.5+sin(45*deg)) ; for( unsigned int i = 0; i < 8; i ++){ + cout << i << endl; // Place the sub volumes in the master volume // Last argument is the detector number, used in the scorer to get the // revelant information @@ -300,7 +389,6 @@ void Tiara::ConstructInnerBarrel(G4LogicalVolume* world){ logicBarrelDetector,"Tiara_Barrel_Detector", world,false,i+1); } - } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... void Tiara::ConstructOuterBarrel(G4LogicalVolume* world){ @@ -397,7 +485,10 @@ void Tiara::ConstructOuterBarrel(G4LogicalVolume* world){ G4LogicalVolume* logicActiveWafer = new G4LogicalVolume(ActiveWafer,m_MaterialSilicon,"logicActiveWafer", 0, 0, 0); logicActiveWafer->SetVisAttributes(SiliconVisAtt); - + + // Set the sensitive detector + logicActiveWafer->SetSensitiveDetector(m_OuterBarrelScorer); + // The Distance from target is given by half the lenght of a detector // plus the length of a detector inclined by 45 deg. G4double DistanceFromTarget = OUTERBARREL_PCB_Width*(0.5+sin(45*deg)) ; diff --git a/NPSimulation/Tiara/Tiara.hh b/NPSimulation/Tiara/Tiara.hh index d6d8735babd5c1aa24219f268f40529281867a19..0aa543f728f674094d3ea62ae567b48adb375ed6 100644 --- a/NPSimulation/Tiara/Tiara.hh +++ b/NPSimulation/Tiara/Tiara.hh @@ -49,9 +49,8 @@ namespace TIARA { // Energy and time Resolution const G4double ResoTime = 0 ; - //const G4double ResoEnergy = 0.035*MeV ;// = zzkeV of Resolution // Unit is MeV/2.35 const G4double ResoEnergy = 0.042*MeV ;// = zzkeV of Resolution // Unit is MeV/2.35 - + const G4double EnergyThreshold = 200*keV; // Geometric Information // // Chanber // @@ -85,6 +84,7 @@ namespace TIARA const G4double INNERBARREL_ActiveWafer_Thickness =400*um; const G4double INNERBARREL_InertWafer_Length = 97.00*mm; const G4double INNERBARREL_InertWafer_Width = 24.80*mm; + const G4int INNERBARREL_NumberOfStrip = 4; // Outer Barrel // const G4double OUTERBARREL_PCB_Length = 98.00*mm; @@ -102,7 +102,7 @@ namespace TIARA const G4double OUTERBARREL_ActiveWafer_Thickness =700*um; const G4double OUTERBARREL_InertWafer_Length = 97.00*mm; const G4double OUTERBARREL_InertWafer_Width = 30.2*mm; - + const G4int OUTERBARREL_NumberOfStrip = 4; } @@ -180,8 +180,8 @@ private: void InitializeScorers() ; // Scorer Associate with the Silicon -// G4MultiFunctionalDetector* m_InnerBarrelScorer ; -// G4MultiFunctionalDetector* m_OuterBarrelScorer ; + G4MultiFunctionalDetector* m_InnerBarrelScorer ; + G4MultiFunctionalDetector* m_OuterBarrelScorer ; // G4MultiFunctionalDetector* m_HyballScorer ; //////////////////////////////////////////////////// diff --git a/NPSimulation/Tigress/Tigress.cc b/NPSimulation/Tigress/Tigress.cc index 80057e802a56564f00b519b733350bdceb03542f..8b79492129d25cb1580e39358122216c55fede2f 100644 --- a/NPSimulation/Tigress/Tigress.cc +++ b/NPSimulation/Tigress/Tigress.cc @@ -505,7 +505,7 @@ void Tigress::ConstructClover(string){ new G4LogicalVolume(CrystalB,m_MaterialVacuum,"LogicCrystalW", 0, 0, 0); G4RotationMatrix* CrystalRotation = new G4RotationMatrix(0,0,0); - CrystalPosition = G4ThreeVector(CrystalOffset,CrystalOffset,0); + CrystalPosition = G4ThreeVector(CrystalOffset,CrystalOffset,-0.5*CapsuleWidth); new G4PVPlacement(G4Transform3D(*CrystalRotation, CrystalPosition), logicCrystalB,"LogicCrystalB",m_LogicClover,false,m_CloverId[0]); logicCrystalB->SetVisAttributes(BlueVisAtt); diff --git a/NPSimulation/include/ResistiveStripScorers.hh b/NPSimulation/include/ResistiveStripScorers.hh index dcb2ee59b5ab186a0053b943dac266ab87fa2750..dc05e1882f8a556366c3232de866d036541620d6 100644 --- a/NPSimulation/include/ResistiveStripScorers.hh +++ b/NPSimulation/include/ResistiveStripScorers.hh @@ -29,49 +29,49 @@ #include <map> using namespace std; - using namespace CLHEP; +using namespace CLHEP; //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +namespace SILICONSCORERS{ + class PS_Silicon_Resistive : public G4VPrimitiveScorer{ -class PS_Silicon_Resistive : public G4VPrimitiveScorer{ + public: // with description + PS_Silicon_Resistive(G4String name, + G4double StripPlaneLength, G4double StripPlaneWidth, + G4int NumberOfStripWidth,G4int depth=0); - public: // with description - PS_Silicon_Resistive(G4String name, - G4double StripPlaneLength, G4double StripPlaneWidth, - G4int NumberOfStripWidth,G4int depth=0); + ~PS_Silicon_Resistive(); - ~PS_Silicon_Resistive(); + protected: // with description + G4bool ProcessHits(G4Step*, G4TouchableHistory*); - protected: // with description - G4bool ProcessHits(G4Step*, G4TouchableHistory*); + public: + void Initialize(G4HCofThisEvent*); + void EndOfEvent(G4HCofThisEvent*); + void clear(); + void DrawAll(); + void PrintAll(); - public: - void Initialize(G4HCofThisEvent*); - void EndOfEvent(G4HCofThisEvent*); - void clear(); - void DrawAll(); - void PrintAll(); + private: // Threshold + G4double m_TriggerThreshold; - private: // Threshold - G4double m_TriggerThreshold; + private: // Geometry of the detector + G4double m_StripPlaneLength; + G4double m_StripPlaneWidth; + G4int m_NumberOfStripWidth; + G4double m_StripPitchWidth; - private: // Geometry of the detector - G4double m_StripPlaneLength; - G4double m_StripPlaneWidth; - G4int m_NumberOfStripWidth; - G4double m_StripPitchWidth; + private: // inherited from G4VPrimitiveScorer + G4int HCID; + G4THitsMap<G4double*>* EvtMap; - private: // inherited from G4VPrimitiveScorer - G4int HCID; - G4THitsMap<G4double*>* EvtMap; - - private: // Needed for intermediate calculation (avoid multiple instantiation in Processing Hit) - G4ThreeVector m_Position ; - G4int m_DetectorNumber ; - G4int m_StripWidthNumber ; - G4int m_Index ; - -}; + private: // Needed for intermediate calculation (avoid multiple instantiation in Processing Hit) + G4ThreeVector m_Position ; + G4int m_DetectorNumber ; + G4int m_StripWidthNumber ; + G4int m_Index ; + }; +} #endif diff --git a/NPSimulation/src/ResistiveStripScorers.cc b/NPSimulation/src/ResistiveStripScorers.cc index d7b1078b9e242f70b9a3a61480e8966e1a205403..66ef34d7ef8786cff90d3d38f50b775bd0544a2e 100644 --- a/NPSimulation/src/ResistiveStripScorers.cc +++ b/NPSimulation/src/ResistiveStripScorers.cc @@ -21,7 +21,7 @@ *****************************************************************************/ #include "ResistiveStripScorers.hh" #include "G4UnitsTable.hh" - +using namespace SILICONSCORERS; //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... PS_Silicon_Resistive::PS_Silicon_Resistive(G4String name, G4double StripPlaneLength, G4double StripPlaneWidth, G4int NumberOfStripWidth,G4int depth) :G4VPrimitiveScorer(name, depth),HCID(-1){ @@ -46,11 +46,10 @@ G4bool PS_Silicon_Resistive::ProcessHits(G4Step* aStep, G4TouchableHistory*){ // contain Energy Total, E1, E2, Time, DetNbr, and StripWidth G4double* EnergyAndTime = new G4double[10]; - EnergyAndTime[0] = aStep->GetTotalEnergyDeposit(); - - EnergyAndTime[1] = aStep->GetPreStepPoint()->GetGlobalTime(); + + EnergyAndTime[2] = aStep->GetPreStepPoint()->GetGlobalTime(); - m_DetectorNumber = aStep->GetPreStepPoint()->GetTouchableHandle()->GetCopyNumber(0); + m_DetectorNumber = aStep->GetPreStepPoint()->GetTouchableHandle()->GetCopyNumber(1); m_Position = aStep->GetPreStepPoint()->GetPosition(); // Interaction coordinates (used to fill the InteractionCoordinates branch) @@ -64,8 +63,18 @@ G4bool PS_Silicon_Resistive::ProcessHits(G4Step* aStep, G4TouchableHistory*){ m_StripWidthNumber = (int)((m_Position.y() + m_StripPlaneWidth / 2.) / m_StripPitchWidth ) + 1 ; m_StripWidthNumber = m_NumberOfStripWidth - m_StripWidthNumber + 1 ; + + // The energy is divided in two depending on the position + // position along the resistive strip + double P = (m_Position.x())/(0.5*m_StripPlaneLength); + + // Upstream Energy + EnergyAndTime[0] = aStep->GetTotalEnergyDeposit()*(1+P)*0.5; - EnergyAndTime[2] = m_DetectorNumber; + // Downstream Energy + EnergyAndTime[1] = aStep->GetTotalEnergyDeposit()-EnergyAndTime[0]; + + EnergyAndTime[3] = m_DetectorNumber; EnergyAndTime[4] = m_StripWidthNumber; //Rare case where particle is close to edge of silicon plan diff --git a/NPSimulation/src/SiliconScorers.cc b/NPSimulation/src/SiliconScorers.cc index 73971df944993b119a5d16654621c1ff98e1457b..60edc4907352b0ed1b1b0364383b875586704103 100644 --- a/NPSimulation/src/SiliconScorers.cc +++ b/NPSimulation/src/SiliconScorers.cc @@ -53,7 +53,7 @@ G4bool PS_Silicon_Rectangle::ProcessHits(G4Step* aStep, G4TouchableHistory*){ Infos[0] = aStep->GetTotalEnergyDeposit(); Infos[1] = aStep->GetPreStepPoint()->GetGlobalTime(); - m_DetectorNumber = aStep->GetPreStepPoint()->GetTouchableHandle()->GetCopyNumber(0); + m_DetectorNumber = aStep->GetPreStepPoint()->GetTouchableHandle()->GetCopyNumber(1); m_Position = aStep->GetPreStepPoint()->GetPosition(); // Interaction coordinates (used to fill the InteractionCoordinates branch)