diff --git a/Examples/Example1/Analysis.cxx b/Examples/Example1/Analysis.cxx index 0a60fe37dc998bf3977f6574983f3a109b90a94f..02e68e4a8d11aa275662400516e1f406697004cc 100644 --- a/Examples/Example1/Analysis.cxx +++ b/Examples/Example1/Analysis.cxx @@ -61,10 +61,10 @@ void Analysis::Init(){ Si_Y_M2 = 0; TargetThickness = m_DetectorManager->GetTargetThickness(); // Energy loss table: the G4Table are generated by the simulation - He3CD2 = EnergyLoss("Example/He3_CD2.G4table","G4Table",100 ); - He3Al = EnergyLoss("Example/He3_Al.G4table","G4Table",10); - He3Si = EnergyLoss("Example/He3_Si.G4table","G4Table",10); - Li11CD2 = EnergyLoss("Example/Li11_CD2.G4table","G4Table",100); + He3CD2 = EnergyLoss("energy_loss/He3_CD2.G4table","G4Table",100 ); + He3Al = EnergyLoss("energy_loss/He3_Al.G4table","G4Table",10); + He3Si = EnergyLoss("energy_loss/He3_Si.G4table","G4Table",10); + Li11CD2 = EnergyLoss("energy_loss/Li11_CD2.G4table","G4Table",100); } //////////////////////////////////////////////////////////////////////////////// diff --git a/Examples/Example1/ShowResults.C b/Examples/Example1/ShowResults.C index e398a21e2ce991aaae28b74d4fd7907a4755cffa..6d7c2ed410b92cf005913800d9d94f8a5d95abd2 100644 --- a/Examples/Example1/ShowResults.C +++ b/Examples/Example1/ShowResults.C @@ -16,7 +16,7 @@ void LoadCuts(){ //////////////////////////////////////////////////////////////////////////////// void LoadChain(){ chain = new TChain("PhysicsTree"); - chain->Add("../../Outputs/Analysis/Example1.root"); + chain->Add("root/analysis/Example1.root"); } //////////////////////////////////////////////////////////////////////////////// diff --git a/Inputs/DetectorConfiguration/plastic.detector b/Inputs/DetectorConfiguration/plastic.detector index 5237bfa314e15942a59b8037f31ac98df03163e1..ed3bedfdd744cbd06426541ecca182c09ccecb08 100644 --- a/Inputs/DetectorConfiguration/plastic.detector +++ b/Inputs/DetectorConfiguration/plastic.detector @@ -11,12 +11,12 @@ Target Plastic X= 0 mm Y= 0 mm - Z= 10 mm - Thickness= 1.0 cm - Shape= Square - Height= 22 mm - Width= 22 mm - Radius= 0 mm + Z= 100 mm + Thickness= 50 mm + Shape= cylind + Height= 50 mm + Width= 0 mm + Radius= 25 mm Scintillator= Cu LeadThickness= 0 mm diff --git a/Inputs/EventGenerator/alpha.source b/Inputs/EventGenerator/alpha.source index e374754a730c56c6642ab67769c01c126d0ba3e1..c84b2c8ead64ed5414f23c69828118feb1d5618b 100644 --- a/Inputs/EventGenerator/alpha.source +++ b/Inputs/EventGenerator/alpha.source @@ -4,13 +4,13 @@ % Energy are given in MeV , Position in mm % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Isotropic - EnergyLow= 0.5 MeV - EnergyHigh= 0.5 MeV - HalfOpenAngleMin= 25 deg - HalfOpenAngleMax= 65 deg + EnergyLow= 5 MeV + EnergyHigh= 5 MeV + HalfOpenAngleMin= 0 deg + HalfOpenAngleMax= 180 deg x0= 0 mm y0= 0 mm - z0= 0 mm + z0= -150 mm Particle= alpha ExcitationEnergy= 0 MeV diff --git a/Inputs/EventGenerator/gamma.source b/Inputs/EventGenerator/gamma.source index f1ea250953a430703a077137a25e3b855cad91db..82a2d2a9ccba6cab8920598f037d8f1a2e56373e 100644 --- a/Inputs/EventGenerator/gamma.source +++ b/Inputs/EventGenerator/gamma.source @@ -4,10 +4,10 @@ % Energy are given in MeV , Position in mm % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Isotropic - EnergyLow= 10 MeV - EnergyHigh= 10 MeV + EnergyLow= 12 MeV + EnergyHigh= 12 MeV HalfOpenAngleMin= 0 deg - HalfOpenAngleMax= 180 deg + HalfOpenAngleMax= 5 deg x0= 0 mm y0= 0 mm z0= 0 mm diff --git a/Inputs/EventGenerator/neutron.source b/Inputs/EventGenerator/neutron.source index d861370b140a651c5a39492ad40855b5f97ec94b..8b5c5562961f2912f8481078f0f5fc252735f429 100644 --- a/Inputs/EventGenerator/neutron.source +++ b/Inputs/EventGenerator/neutron.source @@ -4,22 +4,21 @@ % Energy are given in MeV , Position in mm % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Isotropic - EnergyLow= 0 - EnergyHigh= 20 + EnergyLow= 4 + EnergyHigh= 15 %EnergyDistribution= flat - EnergyDistribution= 0.38*sqrt(x)*exp(-x/0.847212) + EnergyDistribution= Watt + %EnergyDistribution= 0.38*sqrt(x)*exp(-x/0.847212) %EnergyDistribution= -0.00372440431*pow(x,6)+0.387617479*pow(x,5)-14.3752948*pow(x,4)+225.888082*pow(x,3)-1555.60583*pow(x,2)+7983.24902*pow(x,1)+9069.96435 %EnergyDistribution= 0.619676*TMath::SinH(sqrt(1.07777*x))*exp(-0.847212*x) - %EnergyDistribution= 1.90903*TMath::SinH(sqrt(1.04982*x))*exp(-0.845506*x) - %EnergyDistribution= 22.8043*TMath::SinH(sqrt(0.0144658*x))*exp(-0.729612*x) - %EnergyDistribution= 13.0603*TMath::SinH(sqrt(0.0547835*x))*exp(-0.691795*x) + %EnergyDistribution= 1.5*TMath::SinH(sqrt(1.3*x))*exp(-0.89*x) HalfOpenAngleMin= 0 HalfOpenAngleMax= 0 x0= 0 y0= 0 - z0= -1000 mm - SigmaX= 5 mm - SigmaY= 5 mm + z0= 0 mm + SigmaX= 1 mm + SigmaY= 1 mm Multiplicity= 1 Particle= neutron %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/Inputs/EventGenerator/np.source b/Inputs/EventGenerator/np.source index 59867b6eadb2a3fa2d8bfd963a4f4d308a9420fb..79d252791d92bbd8dfb14cc1f80e7ad3a2aa0d3e 100644 --- a/Inputs/EventGenerator/np.source +++ b/Inputs/EventGenerator/np.source @@ -11,7 +11,7 @@ Isotropic x0= 0 mm y0= 0 mm z0= 0 mm - Multiplicity= 1 1 - Particle= neutron proton + Multiplicity= 1 1 1 + Particle= neutron proton 8He %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Supported particle type: proton, neutron, deuton, triton, He3 , alpha diff --git a/Inputs/EventGenerator/sofia_238U.reaction b/Inputs/EventGenerator/sofia_238U.reaction new file mode 100644 index 0000000000000000000000000000000000000000..64f4b000bb0238548425facbe3c602e982f2cbcb --- /dev/null +++ b/Inputs/EventGenerator/sofia_238U.reaction @@ -0,0 +1,36 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%% Reaction file for 238U transfer reaction %%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%Beam energy given in MeV ; Excitation in MeV ; emmitance in rad +Beam + Particle= 238U + Energy= 135660 + ExcitationEnergy= 15 MeV + SigmaEnergy= 2 + SigmaX= 6 mm + SigmaY= 5 mm + SigmaThetaX= 0 + SigmaPhiY= 0 + MeanThetaX= 0 + MeanPhiY= 0.1 deg + MeanX= -20.0 mm + MeanY= -2.8 mm +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%TwoBodyReaction + Beam= 238U + Target= 208Pb + Light= 208Pb + Heavy= 238U + ExcitationEnergyLight= 15.0 + ExcitationEnergyHeavy= 0.0 + CrossSectionPath= sofia.txt CS + ShootLight= 1 + ShootHeavy= 1 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +FissionDecay + CompoundNucleus= 238U + FissionModel= GEF + VamosChargeStates= 0 + Shoot_FF= 1 + Shoot_neutron= 0 + Shoot_gamma= 0 diff --git a/NPLib/Core/NPVDetector.h b/NPLib/Core/NPVDetector.h index 415950273338a0e5287bb25ec139a3a1b5ca38f3..a023fc3173f81fa9911626c25dda416c1f5b6565 100644 --- a/NPLib/Core/NPVDetector.h +++ b/NPLib/Core/NPVDetector.h @@ -22,99 +22,107 @@ *---------------------------------------------------------------------------* * Comment: * * See MUST2 array for exemple of VDetector derived class * - * * + * * * Adding Fill Spectra Method to fill control Histogramm * *****************************************************************************/ // ROOT -#include "TH1.h" #include "TCanvas.h" -// STL +#include "TH1.h" +// STL +#include <map> #include <string> #include <vector> -#include <map> // NPL -#include "NPInputParser.h" #include "NPCore.h" +#include "NPInputParser.h" namespace NPL { - class VDetector{ - public: - - // Default Constructor and destructor - VDetector() ; - virtual ~VDetector() ; - - // Read stream at ConfigFile to pick-up parameters of detector (Position,...) using Token - virtual void ReadConfiguration(NPL::InputParser) {} ; - - // Add Parameter to the CalibrationManger - virtual void AddParameterToCalibrationManager() {} ; - - // Activated associated Branches and link it to the private member DetectorData address - // In this method mother Branches (Detector) AND daughter leaf (fDetector_parameter) have to be activated - virtual void InitializeRootInputRaw() {} ; - - // Activated associated Branches and link it to the private member DetectorPhysics address - // In this method mother Branches (Detector) AND daughter leaf (parameter) have to be activated - virtual void InitializeRootInputPhysics() {} ; - - // Create associated branches and associated private member DetectorPhysics address - virtual void InitializeRootOutput() {} ; - - // This method is called at each event read from the Input Tree. Aime is to build treat Raw dat in order to extract physical parameter. - virtual void BuildPhysicalEvent() {} ; - - // Same as above, but only the simplest event and/or simple method are used (low multiplicity, faster algorythm but less efficient ...). - // This method aimed to be used for analysis performed during experiment, when speed is requiered. - // NB: This method can eventually be the same as BuildPhysicalEvent. - virtual void BuildSimplePhysicalEvent() {} ; - - // Those two method all to clear the Event Physics or Data - virtual void ClearEventPhysics() {} ; - virtual void ClearEventData() {} ; - - // Method related to the TSpectra classes, aimed at providing a framework for online applications - // Instantiate the Spectra class and the histogramm throught it - virtual void InitSpectra() {}; - // Fill the spectra hold by the spectra class - virtual void FillSpectra() {}; - // Write the spectra to a file - virtual void WriteSpectra() {}; - // Used for Online mainly, perform check on the histo and for example change their color if issues are found - virtual void CheckSpectra() {}; - // Used for Online only, clear all the spectra hold by the Spectra class - virtual void ClearSpectra() {}; - // Used for Online only, get all the spectra hold by the Spectra class - virtual std::map< std::string , TH1*> GetSpectra() {std::map< std::string, TH1* > x; return x;}; - // Used for Online only, get all the canvases - virtual std::vector<TCanvas*> GetCanvas(){std::vector<TCanvas*> x ; return x;}; - // Used for interoperability with other framework - virtual void SetRawDataPointer(void*) {}; - - private: // The list below is here to help you building your own detector - /* - // GRU and Simulated Tree output are made of Data Object wich contain all the RAW parameter output by Detectors during an experiment. - // You need to add a pointer to those kind of object in order to received data from the Tree at each getEntry call. Just replace Detector - // by your Detector name, like Must2Data for Must2 - - DetectorData* EventData ; - - // Position of detector: An array which held geometric information of detector, such as Strip position,... - // Dimension must be suited for your need - - vector< vector <double > > DetectorPosition ; - - // Calibration are passed to the EventPhysics Object, so you don't need to store them here - - nothing noCalibration ; - -*/ - ClassDef(VDetector,1) + class VDetector { + public: + // Default Constructor and destructor + VDetector(); + virtual ~VDetector(); + + // Read stream at ConfigFile to pick-up parameters of detector (Position,...) using Token + virtual void ReadConfiguration(NPL::InputParser){}; + + // Add Parameter to the CalibrationManger + virtual void AddParameterToCalibrationManager(){}; + + // Activated associated Branches and link it to the private member DetectorData address + // In this method mother Branches (Detector) AND daughter leaf (fDetector_parameter) have to be activated + virtual void InitializeRootInputRaw(){}; + + // Activated associated Branches and link it to the private member DetectorPhysics address + // In this method mother Branches (Detector) AND daughter leaf (parameter) have to be activated + virtual void InitializeRootInputPhysics(){}; + + // Create associated branches and associated private member DetectorPhysics address + virtual void InitializeRootOutput(){}; + + // This method is called at each event read from the Input Tree. Aime is to build treat Raw dat in order to extract + // physical parameter. + virtual void BuildPhysicalEvent(){}; + + // Same as above, but only the simplest event and/or simple method are used (low multiplicity, faster algorythm but + // less efficient ...). This method aimed to be used for analysis performed during experiment, when speed is + // requiered. NB: This method can eventually be the same as BuildPhysicalEvent. + virtual void BuildSimplePhysicalEvent(){}; + + // Those two method all to clear the Event Physics or Data + virtual void ClearEventPhysics(){}; + virtual void ClearEventData(){}; + + // Method related to the TSpectra classes, aimed at providing a framework for online applications + // Instantiate the Spectra class and the histogramm throught it + virtual void InitSpectra(){}; + // Fill the spectra hold by the spectra class + virtual void FillSpectra(){}; + // Write the spectra to a file + virtual void WriteSpectra(){}; + // Used for Online mainly, perform check on the histo and for example change their color if issues are found + virtual void CheckSpectra(){}; + // Used for Online only, clear all the spectra hold by the Spectra class + virtual void ClearSpectra(){}; + // Used for Online only, get all the spectra hold by the Spectra class + virtual std::map<std::string, TH1*> GetSpectra() { + std::map<std::string, TH1*> x; + return x; + }; + // Used for Online only, get all the canvases + virtual std::vector<TCanvas*> GetCanvas() { + std::vector<TCanvas*> x; + return x; + }; + // Used for interoperability with other framework + virtual void SetRawDataPointer(void*){}; + + private: // The list below is here to help you building your own detector + /* + // GRU and Simulated Tree output are made of Data Object wich contain all the RAW parameter output by Detectors + during an experiment. + // You need to add a pointer to those kind of object in order to received data from the Tree at each getEntry + call. Just replace Detector + // by your Detector name, like Must2Data for Must2 + + DetectorData* EventData ; + + // Position of detector: An array which held geometric information of detector, such as Strip position,... + // Dimension must be suited for your need + + vector< vector <double > > DetectorPosition ; + + // Calibration are passed to the EventPhysics Object, so you don't need to store them here + + nothing noCalibration ; + + */ + ClassDef(VDetector, 1) }; -} +} // namespace NPL #endif diff --git a/NPLib/Core/RootInput.cxx b/NPLib/Core/RootInput.cxx index b92a4f76682c5d827a7de9080f7f45505ec230df..a10a49cce7d7fd4505cc279be146ecd984eed0b7 100644 --- a/NPLib/Core/RootInput.cxx +++ b/NPLib/Core/RootInput.cxx @@ -19,22 +19,22 @@ * * *****************************************************************************/ -#include <iostream> -#include <sstream> +#include <dlfcn.h> #include <fstream> +#include <iostream> #include <limits> -#include <sys/stat.h> +#include <sstream> #include <stdlib.h> -#include <dlfcn.h> +#include <sys/stat.h> +#include "NPOptionManager.h" #include "RootInput.h" #include "TAsciiFile.h" -#include "NPOptionManager.h" using namespace std; RootInput* RootInput::instance = 0; //////////////////////////////////////////////////////////////////////////////// -RootInput* RootInput::getInstance(std::string configFileName){ +RootInput* RootInput::getInstance(std::string configFileName) { // A new instance of RootInput is created if it does not exist: if (instance == 0) { instance = new RootInput(configFileName); @@ -45,7 +45,7 @@ RootInput* RootInput::getInstance(std::string configFileName){ } //////////////////////////////////////////////////////////////////////////////// -void RootInput::Destroy(){ +void RootInput::Destroy() { if (instance != 0) { delete instance; instance = 0; @@ -53,64 +53,64 @@ void RootInput::Destroy(){ } //////////////////////////////////////////////////////////////////////////////// -void RootInput::ReadOldStyleInputFile(NPL::InputParser& parser){ - vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithToken("TTreeName"); - pTreeName = blocks[0]->GetLines()[0]; - vector<NPL::InputBlock*> files = parser.GetAllBlocksWithToken("RootFileName"); - if(files.size()>0){ - vector<string> lines=files[0]->GetLines(); - unsigned int size = lines.size(); - for(unsigned int i = 0 ; i < size ; i++){ - pTreePath.push_back(lines[i]); - } +void RootInput::ReadOldStyleInputFile(NPL::InputParser& parser) { + vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithToken("TTreeName"); + pTreeName = blocks[0]->GetLines()[0]; + vector<NPL::InputBlock*> files = parser.GetAllBlocksWithToken("RootFileName"); + if (files.size() > 0) { + vector<string> lines = files[0]->GetLines(); + unsigned int size = lines.size(); + for (unsigned int i = 0; i < size; i++) { + pTreePath.push_back(lines[i]); } + } } //////////////////////////////////////////////////////////////////////////////// -void RootInput::ReadInputFile(NPL::InputParser& parser){ - vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithToken("Tree"); - pTreeName = blocks[0]->GetMainValue(); - std::vector<std::string> lines=blocks[0]->GetLines(); - unsigned int size = lines.size(); - for(unsigned int i = 0 ; i < size ; i++){ - if(lines[i].find(".root")!=string::npos) - pTreePath.push_back(lines[i]); - else if(lines[i].find(".tree")!=string::npos) - ReadTreeFile(lines[i]); - } +void RootInput::ReadInputFile(NPL::InputParser& parser) { + vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithToken("Tree"); + pTreeName = blocks[0]->GetMainValue(); + std::vector<std::string> lines = blocks[0]->GetLines(); + unsigned int size = lines.size(); + for (unsigned int i = 0; i < size; i++) { + if (lines[i].find(".root") != string::npos) + pTreePath.push_back(lines[i]); + else if (lines[i].find(".tree") != string::npos) + ReadTreeFile(lines[i]); + } - vector<NPL::InputBlock*> friends = parser.GetAllBlocksWithToken("Friend"); - unsigned int sizeF = friends.size(); - for(unsigned int i = 0 ; i < sizeF ; i++){ - pFriendsPath.insert(pair< string,vector<string> > (friends[i]->GetMainValue(),friends[i]->GetLines())); - } + vector<NPL::InputBlock*> friends = parser.GetAllBlocksWithToken("Friend"); + unsigned int sizeF = friends.size(); + for (unsigned int i = 0; i < sizeF; i++) { + pFriendsPath.insert(pair<string, vector<string>>(friends[i]->GetMainValue(), friends[i]->GetLines())); + } } //////////////////////////////////////////////////////////////////////////////// -void RootInput::ReadTreeFile(std::string path){ +void RootInput::ReadTreeFile(std::string path) { ifstream tree(path.c_str()); - path=path.substr(0,path.rfind("/")+1); + path = path.substr(0, path.rfind("/") + 1); std::string buffer; - bool first=true; - unsigned int count = 0 ; - while(tree>>buffer){ - if(first){ - pTreePath.push_back(path+buffer); + bool first = true; + unsigned int count = 0; + while (tree >> buffer) { + if (first) { + pTreePath.push_back(path + buffer); count++; - first=false; + first = false; } - else{ - pFriendsTreePath[count++].push_back(path+buffer); + else { + pFriendsTreePath[count++].push_back(path + buffer); } } } //////////////////////////////////////////////////////////////////////////////// -RootInput::RootInput(std::string configFileName){ +RootInput::RootInput(std::string configFileName) { NumberOfFriend = 0; - pRootFile = NULL; - std::string lastfile= NPOptionManager::getInstance()->GetLastFile(); - if(lastfile!="VOID"){ + pRootFile = NULL; + std::string lastfile = NPOptionManager::getInstance()->GetLastFile(); + if (lastfile != "VOID") { configFileName = lastfile; } @@ -120,25 +120,25 @@ RootInput::RootInput(std::string configFileName){ // Old style file vector<NPL::InputBlock*> old_blocks = parser.GetAllBlocksWithToken("TTreeName"); - if(old_blocks.size()==1){ + if (old_blocks.size() == 1) { ReadOldStyleInputFile(parser); } // New style file vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithToken("Tree"); - if(blocks.size()==1){ + if (blocks.size() == 1) { ReadInputFile(parser); } // If the tree come from a simulation, the InteractionCoordinates // and InitialConditions lib are loaded - if(pTreeName=="SimulatedTree"){ - std::string path = getenv("NPTOOL"); - path+="/NPLib/lib/"; - std::string libName="libNPInteractionCoordinates"+NPOptionManager::getInstance()->GetSharedLibExtension(); - libName=path+libName; - dlopen(libName.c_str(),RTLD_NOW); - libName="libNPInitialConditions"+NPOptionManager::getInstance()->GetSharedLibExtension(); - libName=path+libName; - dlopen(libName.c_str(),RTLD_NOW); + if (pTreeName == "SimulatedTree") { + std::string path = getenv("NPTOOL"); + path += "/NPLib/lib/"; + std::string libName = "libNPInteractionCoordinates" + NPOptionManager::getInstance()->GetSharedLibExtension(); + libName = path + libName; + dlopen(libName.c_str(), RTLD_NOW); + libName = "libNPInitialConditions" + NPOptionManager::getInstance()->GetSharedLibExtension(); + libName = path + libName; + dlopen(libName.c_str(), RTLD_NOW); } // Initialise the chain @@ -147,106 +147,111 @@ RootInput::RootInput(std::string configFileName){ // Add all the files unsigned int size = pTreePath.size(); std::string firstfile; - for(unsigned int i = 0 ; i < size ; i++){ + for (unsigned int i = 0; i < size; i++) { cout << " - Adding file : " << pTreePath[i].c_str() << endl; pRootChain->Add(pTreePath[i].c_str()); // Test if the file is a regex or a single file double counts; std::string command = "ls " + pTreePath[i] + " > .ls_return"; - counts= system(command.c_str()); + counts = system(command.c_str()); std::ifstream return_ls(".ls_return"); std::string files; - while(return_ls >> files){ - if(counts == 0) + while (return_ls >> files) { + if (counts == 0) firstfile = files; counts++; } } - + // Case of user made Friends - for(auto it = pFriendsPath.begin(); it!=pFriendsPath.end() ; it++){ + for (auto it = pFriendsPath.begin(); it != pFriendsPath.end(); it++) { TChain* chain = new TChain(it->first.c_str()); cout << " - Adding friend : " << endl; - for(auto itp = it->second.begin() ; itp!=it->second.end() ; itp++){ - cout << " - " << (*itp).c_str() << endl; - chain->Add((*itp).c_str()); + for (auto itp = it->second.begin(); itp != it->second.end(); itp++) { + cout << " - " << (*itp).c_str() << endl; + chain->Add((*itp).c_str()); } pRootChain->AddFriend(chain); } // Case of tree file - for(auto it = pFriendsTreePath.begin(); it!=pFriendsTreePath.end() ; it++){ + for (auto it = pFriendsTreePath.begin(); it != pFriendsTreePath.end(); it++) { TChain* chain = new TChain(pTreeName.c_str()); cout << " - Adding friend : " << endl; - for(auto itp = it->second.begin() ; itp!=it->second.end() ; itp++){ + for (auto itp = it->second.begin(); itp != it->second.end(); itp++) { cout << " - " << (*itp).c_str() << endl; chain->Add((*itp).c_str()); - } + } pRootChain->AddFriend(chain); } - - if (!pRootFile) + + if (!pRootFile) pRootFile = new TFile(firstfile.c_str()); - if( pRootChain->GetEntries() ==0){ - std::cout << "\033[1;31m**** ERROR: No entries to analyse ****\033[0m" << std::endl; + if (pRootChain->GetEntries() == 0) { + std::cout << "\033[1;31m**** ERROR: No entries to analyse ****\033[0m" << std::endl; exit(1); } - else - std::cout << "\033[1;32mROOTInput: " << pRootChain->GetEntries() << " entries loaded in the input chain\033[0m" << std::endl ; + else + std::cout << "\033[1;32mROOTInput: " << pRootChain->GetEntries() << " entries loaded in the input chain\033[0m" + << std::endl; } //////////////////////////////////////////////////////////////////////////////// -std::string RootInput::DumpAsciiFile(const char* type, const char* folder){ - std::string name="fail"; +std::string RootInput::DumpAsciiFile(const char* type, const char* folder) { + std::string name = "fail"; std::string sfolder = folder; // create folder if not existing // first test if folder exist struct stat dirInfo; int res = stat(folder, &dirInfo); - if (res != 0) { // if folder does not exist, create it + if (res != 0) { // if folder does not exist, create it std::string cmd = "mkdir " + sfolder; - if (system(cmd.c_str()) != 0) std::cout << "RootInput::DumpAsciiFile() problem creating directory" << std::endl; + if (system(cmd.c_str()) != 0) + std::cout << "RootInput::DumpAsciiFile() problem creating directory" << std::endl; } std::string stype = type; if (stype == "EventGenerator") { - TAsciiFile *aFile = (TAsciiFile*)pRootFile->Get(stype.c_str()); + TAsciiFile* aFile = (TAsciiFile*)pRootFile->Get(stype.c_str()); - if(aFile) - { + if (aFile) { // build file name std::string title = aFile->GetTitle(); size_t pos = title.rfind("/"); - if (pos != std::string::npos) name = sfolder + title.substr(pos); - else name = sfolder + "/" + title; + if (pos != std::string::npos) + name = sfolder + title.substr(pos); + else + name = sfolder + "/" + title; aFile->WriteToFile(name.c_str()); } } else if (stype == "DetectorConfiguration") { - TAsciiFile *aFile = (TAsciiFile*)pRootFile->Get(stype.c_str()); - if(aFile) - { + TAsciiFile* aFile = (TAsciiFile*)pRootFile->Get(stype.c_str()); + if (aFile) { // build file name std::string title = aFile->GetTitle(); size_t pos = title.rfind("/"); - if (pos != std::string::npos) name = sfolder + title.substr(pos); - else name = sfolder + "/" + title; + if (pos != std::string::npos) + name = sfolder + title.substr(pos); + else + name = sfolder + "/" + title; aFile->WriteToFile(name.c_str()); } } else if (stype == "Calibration") { - TAsciiFile *aFile = (TAsciiFile*)pRootFile->Get(stype.c_str()); - if(aFile) - { + TAsciiFile* aFile = (TAsciiFile*)pRootFile->Get(stype.c_str()); + if (aFile) { // build file name std::string title = aFile->GetTitle(); size_t pos = title.rfind("/"); - if (pos != std::string::npos) name = sfolder + title.substr(pos); - else name = sfolder + "/" + title; + if (pos != std::string::npos) + name = sfolder + title.substr(pos); + else + name = sfolder + "/" + title; aFile->WriteToFile(name.c_str()); } } @@ -261,12 +266,13 @@ std::string RootInput::DumpAsciiFile(const char* type, const char* folder){ } //////////////////////////////////////////////////////////////////////////////// -RootInput::~RootInput(){ +RootInput::~RootInput() { // delete default directory ./.tmp struct stat dirInfo; int res = stat("./.tmp", &dirInfo); - if (res == 0) { // if does exist, delete it - if (system("rm -rf ./.tmp") != 0) std::cout << "RootInput::~RootInput() problem deleting ./.tmp directory" << std::endl; + if (res == 0) { // if does exist, delete it + if (system("rm -rf ./.tmp") != 0) + std::cout << "RootInput::~RootInput() problem deleting ./.tmp directory" << std::endl; } std::cout << std::endl << "Root Input summary" << std::endl; std::cout << " - Number of bites read: " << pRootFile->GetBytesRead() << std::endl; diff --git a/NPLib/Detectors/Iss/CMakeLists.txt b/NPLib/Detectors/Iss/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..e9b1d0e235bf141d31e51665fa9ba4e8c4b8f236 --- /dev/null +++ b/NPLib/Detectors/Iss/CMakeLists.txt @@ -0,0 +1,5 @@ +add_custom_command(OUTPUT TIssPhysicsDict.cxx COMMAND ../../scripts/build_dict.sh TIssPhysics.h TIssPhysicsDict.cxx TIssPhysics.rootmap libNPIss.dylib DEPENDS TIssPhysics.h) +add_custom_command(OUTPUT TIssDataDict.cxx COMMAND ../../scripts/build_dict.sh TIssData.h TIssDataDict.cxx TIssData.rootmap libNPIss.dylib DEPENDS TIssData.h) +add_library(NPIss SHARED TIssData.cxx TIssPhysics.cxx TIssDataDict.cxx TIssPhysicsDict.cxx TIssSpectra.cxx) +target_link_libraries(NPIss ${ROOT_LIBRARIES} NPCore) +install(FILES TIssData.h TIssPhysics.h TIssSpectra.h DESTINATION ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}) diff --git a/NPLib/Detectors/Iss/TIssData.cxx b/NPLib/Detectors/Iss/TIssData.cxx new file mode 100644 index 0000000000000000000000000000000000000000..95ee271560e2299026fbe29d70b36e8100fa9b00 --- /dev/null +++ b/NPLib/Detectors/Iss/TIssData.cxx @@ -0,0 +1,162 @@ +/***************************************************************************** + * Copyright (C) 2009-2019 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: a.matta@surrey.ac.uk * + * Author: M. Labiche address: marc.labiche@stfc.ac.uk * +* * + * Creation Date : July 2019 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class hold Iss Raw data * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ +#include <iostream> +#include <fstream> +#include <sstream> +#include <string> +using namespace std; + +#include "TIssData.h" + +ClassImp(TIssData) + +TIssData::TIssData() +{ + // Default constructor + + // DSSD + fIss_StripFront_DetectorNbr.clear(); + fIss_StripFront_StripNbr.clear(); + fIss_StripFront_Energy.clear(); + fIss_StripFront_TimeCFD.clear(); + fIss_StripFront_TimeLED.clear(); + fIss_StripFront_Time.clear(); + + fIss_StripBack_DetectorNbr.clear(); + fIss_StripBack_StripNbr.clear(); + fIss_StripBack_Energy.clear(); + fIss_StripBack_TimeCFD.clear(); + fIss_StripBack_TimeLED.clear(); + fIss_StripBack_Time.clear(); + +/* + + + // (X,E) + fMM_StripXE_DetectorNbr.clear(); + fMM_StripXE_StripNbr.clear(); + fMM_StripXE_Energy.clear(); + // (X,T) + fMM_StripXT_DetectorNbr.clear(); + fMM_StripXT_StripNbr.clear(); + fMM_StripXT_Time.clear(); + // (Y,E) + fMM_StripYE_DetectorNbr.clear(); + fMM_StripYE_StripNbr.clear(); + fMM_StripYE_Energy.clear(); + // (Y,T) + fMM_StripYT_DetectorNbr.clear(); + fMM_StripYT_StripNbr.clear(); + fMM_StripYT_Time.clear(); +*/ +} + +TIssData::~TIssData() +{} + +void TIssData::Clear() +{ + // DSSD + + fIss_StripFront_DetectorNbr.clear(); + fIss_StripFront_StripNbr.clear(); + fIss_StripFront_Energy.clear(); + fIss_StripFront_TimeCFD.clear(); + fIss_StripFront_TimeLED.clear(); + fIss_StripFront_Time.clear(); + + fIss_StripBack_DetectorNbr.clear(); + fIss_StripBack_StripNbr.clear(); + fIss_StripBack_Energy.clear(); + fIss_StripBack_TimeCFD.clear(); + fIss_StripBack_TimeLED.clear(); + fIss_StripBack_Time.clear(); + +/* + // (X,E) + fMM_StripXE_DetectorNbr.clear(); + fMM_StripXE_StripNbr.clear(); + fMM_StripXE_Energy.clear(); + // (X,T) + fMM_StripXT_DetectorNbr.clear(); + fMM_StripXT_StripNbr.clear(); + fMM_StripXT_Time.clear(); + // (Y,E) + fMM_StripYE_DetectorNbr.clear(); + fMM_StripYE_StripNbr.clear(); + fMM_StripYE_Energy.clear(); + // (Y,T) + fMM_StripYT_DetectorNbr.clear(); + fMM_StripYT_StripNbr.clear(); + fMM_StripYT_Time.clear(); +*/ +} + + + +void TIssData::Dump() const +{ + cout << "XXXXXXXXXXXXXXXXXXXXXXXX New Event XXXXXXXXXXXXXXXXX" << endl; + + // DSSD + // Front + cout << "Iss Strip Front Mult = " << fIss_StripFront_DetectorNbr.size() << endl; + for (UShort_t i = 0; i < fIss_StripFront_DetectorNbr.size(); i++){ + cout << "DetNbr (Front): " << fIss_StripFront_DetectorNbr[i] + << " Strip: " << fIss_StripFront_StripNbr[i] + << " Energy: " << fIss_StripFront_Energy[i] + << " Time CFD: " << fIss_StripFront_TimeCFD[i] + << " Time LED: " << fIss_StripFront_TimeLED[i] << endl; + } + + // Back + cout << "Iss Strip Back Mult = " << fIss_StripBack_DetectorNbr.size() << endl; + for (UShort_t i = 0; i < fIss_StripBack_DetectorNbr.size(); i++){ + cout << "DetNbr (Back): " << fIss_StripBack_DetectorNbr[i] + << " Strip: " << fIss_StripBack_StripNbr[i] + << " Energy: " << fIss_StripBack_Energy[i] + << " Time CFD: " << fIss_StripBack_TimeCFD[i] + << " Time LED: " << fIss_StripBack_TimeLED[i] << endl; + } + + +/* + // (X,E) + cout << "MM_StripXE_Mult = " << fMM_StripXE_DetectorNbr.size() << endl; + for (UShort_t i = 0; i < fMM_StripXE_DetectorNbr.size(); i++) + cout << "DetNbr: " << fMM_StripXE_DetectorNbr[i] << " Strip: " << fMM_StripXE_StripNbr[i] << " Energy: " << fMM_StripXE_Energy[i] << endl; + // (X,T) + cout << "MM_StripXT_Mult = " << fMM_StripXT_DetectorNbr.size() << endl; + for (UShort_t i = 0; i < fMM_StripXT_DetectorNbr.size(); i++) + cout << "DetNbr: " << fMM_StripXT_DetectorNbr[i] << " Strip: " << fMM_StripXT_StripNbr[i] << " Time: " << fMM_StripXT_Time[i] << endl; + // (Y,E) + cout << "MM_StripYE_Mult = " << fMM_StripYE_DetectorNbr.size() << endl; + for (UShort_t i = 0; i < fMM_StripYE_DetectorNbr.size(); i++) + cout << "DetNbr: " << fMM_StripYE_DetectorNbr[i] << " Strip: " << fMM_StripYE_StripNbr[i] << " Energy: " << fMM_StripYE_Energy[i] << endl; + // (Y,T) + cout << "MM_StripYT_Mult = " << fMM_StripYT_DetectorNbr.size() << endl; + for (UShort_t i = 0; i < fMM_StripYT_DetectorNbr.size(); i++) + cout << "DetNbr: " << fMM_StripYT_DetectorNbr[i] << " Strip: " << fMM_StripYT_StripNbr[i] << " Time: " << fMM_StripYT_Time[i] << endl; +*/ + +} diff --git a/NPLib/Detectors/Iss/TIssData.h b/NPLib/Detectors/Iss/TIssData.h new file mode 100644 index 0000000000000000000000000000000000000000..47a40fcf488b6462a912c68a8df7a2d20b144fd8 --- /dev/null +++ b/NPLib/Detectors/Iss/TIssData.h @@ -0,0 +1,205 @@ +#ifndef __ISSDATA__ +#define __ISSDATA__ +/***************************************************************************** + * Copyright (C) 2009-2019 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: a.matta@surrey.ac.uk * +* Author: M. Labiche address: marc.labiche@stfc.ac.uk * + * * + * Creation Date : Jul 2019 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class hold Iss Raw data * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ + + +#include <stdlib.h> +#include <vector> +#include <map> +using namespace std ; + +// ROOT +//#include "TNamed.h" +#include "TObject.h" + +class TIssData : public TObject { +//class TIssData : public TNamed { + private: + // DSSD + + vector<UShort_t> fIss_StripFront_DetectorNbr; + vector<UShort_t> fIss_StripFront_StripNbr; + vector<Double_t> fIss_StripFront_Energy; + vector<Double_t> fIss_StripFront_TimeCFD; + vector<Double_t> fIss_StripFront_TimeLED; + vector<Double_t> fIss_StripFront_Time; + + vector<UShort_t> fIss_StripBack_DetectorNbr; + vector<UShort_t> fIss_StripBack_StripNbr; + vector<Double_t> fIss_StripBack_Energy; + vector<Double_t> fIss_StripBack_TimeCFD; + vector<Double_t> fIss_StripBack_TimeLED; + vector<Double_t> fIss_StripBack_Time; + + + +/* + + // X strips + // Energy + vector<UShort_t> fMM_StripXE_DetectorNbr; + vector<UShort_t> fMM_StripXE_StripNbr; + vector<Double_t> fMM_StripXE_Energy; + // Time + vector<UShort_t> fMM_StripXT_DetectorNbr; + vector<UShort_t> fMM_StripXT_StripNbr; + vector<Double_t> fMM_StripXT_Time; + // Y strips + // Energy + vector<UShort_t> fMM_StripYE_DetectorNbr; + vector<UShort_t> fMM_StripYE_StripNbr; + vector<Double_t> fMM_StripYE_Energy; + // Time + vector<UShort_t> fMM_StripYT_DetectorNbr; + vector<UShort_t> fMM_StripYT_StripNbr; + vector<Double_t> fMM_StripYT_Time; +*/ + + public: + TIssData(); + virtual ~TIssData(); + + void Clear(); + void Clear(const Option_t*) {}; + void Dump() const; + + ///////////////////// SETTERS //////////////////////// + // DSSD + + inline void SetFront_DetectorNbr(const UShort_t& DetNbr) {fIss_StripFront_DetectorNbr.push_back(DetNbr);} + inline void SetFront_StripNbr(const UShort_t& StripNbr) {fIss_StripFront_StripNbr.push_back(StripNbr);} + inline void SetFront_Energy(const Double_t& Energy) {fIss_StripFront_Energy.push_back(Energy);} + inline void SetFront_TimeCFD(const Double_t& TimeCFD) {fIss_StripFront_TimeCFD.push_back(TimeCFD);} + inline void SetFront_TimeLED(const Double_t& TimeLED) {fIss_StripFront_TimeLED.push_back(TimeLED);} + inline void SetFront_Time(const Double_t& Time) {fIss_StripFront_Time.push_back(Time);} + + inline void SetBack_DetectorNbr(const UShort_t& DetNbr) {fIss_StripBack_DetectorNbr.push_back(DetNbr);} + inline void SetBack_StripNbr(const UShort_t& StripNbr) {fIss_StripBack_StripNbr.push_back(StripNbr);} + inline void SetBack_Energy(const Double_t& Energy) {fIss_StripBack_Energy.push_back(Energy);} + inline void SetBack_TimeCFD(const Double_t& TimeCFD) {fIss_StripBack_TimeCFD.push_back(TimeCFD);} + inline void SetBack_TimeLED(const Double_t& TimeLED) {fIss_StripBack_TimeLED.push_back(TimeLED);} + inline void SetBack_Time(const Double_t& Time) {fIss_StripBack_Time.push_back(Time);} + + inline void SetFront(const UShort_t& DetNbr,const UShort_t& StripNbr,const Double_t& Energy,const Double_t& TimeCFD,const Double_t& TimeLED,const Double_t& Time = 0) { + SetFront_DetectorNbr(DetNbr); + SetFront_StripNbr(StripNbr); + SetFront_Energy(Energy); + SetFront_TimeCFD(TimeCFD); + SetFront_TimeLED(TimeLED); + SetFront_Time(Time); + }; + inline void SetBack(const UShort_t &DetNbr,const UShort_t &StripNbr,const Double_t &Energy,const Double_t &TimeCFD,const Double_t &TimeLED,const Double_t &Time = 0) { + SetBack_DetectorNbr(DetNbr); + SetBack_StripNbr(StripNbr); + SetBack_Energy(Energy); + SetBack_TimeCFD(TimeCFD); + SetBack_TimeLED(TimeLED); + SetBack_Time(Time); + }; + +/* + // (X,E) + inline void SetStripXE(const UShort_t& DetNbr, const UShort_t& StripNbr, const Double_t& Energy){ + fMM_StripXE_DetectorNbr.push_back(DetNbr); + fMM_StripXE_StripNbr.push_back(StripNbr); + fMM_StripXE_Energy.push_back(Energy); + } + + // (X,T) + inline void SetStripXT(const UShort_t& DetNbr, const UShort_t& StripNbr, const Double_t& Time){ + fMM_StripXT_DetectorNbr.push_back(DetNbr); + fMM_StripXT_StripNbr.push_back(StripNbr); + fMM_StripXT_Time.push_back(Time); + } + // (Y,E) + inline void SetStripYE(const UShort_t& DetNbr, const UShort_t& StripNbr, const Double_t& Energy){ + fMM_StripYE_DetectorNbr.push_back(DetNbr); + fMM_StripYE_StripNbr.push_back(StripNbr); + fMM_StripYE_Energy.push_back(Energy); + } + + // (Y,T) + inline void SetStripYT(const UShort_t& DetNbr, const UShort_t& StripNbr, const Double_t& Time){ + fMM_StripYT_DetectorNbr.push_back(DetNbr); + fMM_StripYT_StripNbr.push_back(StripNbr); + fMM_StripYT_Time.push_back(Time); + } + + */ + + ///////////////////// GETTERS //////////////////////// + // DSSD + + inline UShort_t GetFront_DetectorNbr(const unsigned int &i) const {return fIss_StripFront_DetectorNbr[i];}//! + inline UShort_t GetFront_StripNbr(const unsigned int &i) const {return fIss_StripFront_StripNbr[i];}//! + inline Double_t GetFront_Energy(const unsigned int &i) const {return fIss_StripFront_Energy[i];}//! + inline Double_t GetFront_TimeCFD(const unsigned int &i) const {return fIss_StripFront_TimeCFD[i];}//! + inline Double_t GetFront_TimeLED(const unsigned int &i) const {return fIss_StripFront_TimeLED[i];}//! + inline Double_t GetFront_Time(const unsigned int &i) const {return fIss_StripFront_Time[i];}//! + + + inline UShort_t GetBack_DetectorNbr(const unsigned int &i) const {return fIss_StripBack_DetectorNbr[i];}//! + inline UShort_t GetBack_StripNbr(const unsigned int &i) const {return fIss_StripBack_StripNbr[i];}//! + inline Double_t GetBack_Energy(const unsigned int &i) const {return fIss_StripBack_Energy[i];}//! + inline Double_t GetBack_TimeCFD(const unsigned int &i) const {return fIss_StripBack_TimeCFD[i];}//! + inline Double_t GetBack_TimeLED(const unsigned int &i) const {return fIss_StripBack_TimeLED[i];}//! + inline Double_t GetBack_Time(const unsigned int &i) const {return fIss_StripBack_Time[i];}//! + + + + inline unsigned int GetMultiplicityFront() const {return fIss_StripFront_DetectorNbr.size();}//! + inline unsigned int GetMultiplicityBack() const {return fIss_StripBack_DetectorNbr.size();}//! + + + + +/* + + // (X,E) + UShort_t GetMMStripXEMult() const {return fMM_StripXE_DetectorNbr.size();} + UShort_t GetMMStripXEDetectorNbr(const Int_t& i) const {return fMM_StripXE_DetectorNbr[i];} + UShort_t GetMMStripXEStripNbr(const Int_t& i) const {return fMM_StripXE_StripNbr[i];} + Double_t GetMMStripXEEnergy(const Int_t& i) const {return fMM_StripXE_Energy[i];} + // (X,T) + UShort_t GetMMStripXTMult() const {return fMM_StripXT_DetectorNbr.size();} + UShort_t GetMMStripXTDetectorNbr(const Int_t& i) const {return fMM_StripXT_DetectorNbr[i];} + UShort_t GetMMStripXTStripNbr(const Int_t& i) const {return fMM_StripXT_StripNbr[i];} + Double_t GetMMStripXTTime(const Int_t& i) const {return fMM_StripXT_Time[i];} + // (Y,E) + UShort_t GetMMStripYEMult() const {return fMM_StripYE_DetectorNbr.size();} + UShort_t GetMMStripYEDetectorNbr(const Int_t& i) const {return fMM_StripYE_DetectorNbr[i];} + UShort_t GetMMStripYEStripNbr(const Int_t& i) const {return fMM_StripYE_StripNbr[i];} + Double_t GetMMStripYEEnergy(const Int_t& i) const {return fMM_StripYE_Energy[i];} + // (Y,T) + UShort_t GetMMStripYTMult() const {return fMM_StripYT_DetectorNbr.size();} + UShort_t GetMMStripYTDetectorNbr(const Int_t& i) const {return fMM_StripYT_DetectorNbr[i];} + UShort_t GetMMStripYTStripNbr(const Int_t& i) const {return fMM_StripYT_StripNbr[i];} + Double_t GetMMStripYTTime(const Int_t& i) const {return fMM_StripYT_Time[i];} + +*/ + + ClassDef(TIssData,1) // IssData structure +}; + +#endif diff --git a/NPLib/Detectors/Iss/TIssPhysics.cxx b/NPLib/Detectors/Iss/TIssPhysics.cxx new file mode 100644 index 0000000000000000000000000000000000000000..119907387f1f9a11535cddd7bc3a1aef7de573af --- /dev/null +++ b/NPLib/Detectors/Iss/TIssPhysics.cxx @@ -0,0 +1,1985 @@ +/***************************************************************************** + * Copyright (C) 2009-2019 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: a.matta@surrey.ac.uk * + * Author: M. Labiche address: marc.labiche@stfc.ac.uk * + * * + * Creation Date : Jul 2019 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class hold Iss treated data * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + *****************************************************************************/ +#include "TIssPhysics.h" +using namespace ISS_LOCAL; + +// STL +#include <cmath> +#include <iostream> +#include <limits> +#include <sstream> +#include <stdlib.h> + +// NPL +#include "NPDetectorFactory.h" +#include "NPInputParser.h" +#include "NPOptionManager.h" +#include "NPSystemOfUnits.h" +#include "RootInput.h" +#include "RootOutput.h" +#include "TAsciiFile.h" + +using namespace NPUNITS; +// ROOT +#include "TChain.h" +/////////////////////////////////////////////////////////////////////////// + +ClassImp(TIssPhysics) + +/////////////////////////////////////////////////////////////////////////// +TIssPhysics::TIssPhysics() { + EventMultiplicity = 0; + m_EventData = new TIssData; + m_PreTreatedData = new TIssData; + m_EventPhysics = this; + m_Spectra = NULL; + // m_NumberOfTelescope = 0; + m_NumberOfDetector = 0; + + m_MaximumStripMultiplicityAllowed = 10; + m_StripEnergyMatchingSigma = 0.020; + m_StripEnergyMatchingNumberOfSigma = 3; + + // Threshold + m_StripFront_E_RAW_Threshold = 0 ; + m_StripFront_E_Threshold = 0 ; + + m_StripBack_E_RAW_Threshold = 0 ; + m_StripBack_E_Threshold = 0 ; + + m_Take_E_Front=true; + m_Take_T_Back=true; + + m_NominalField = 0; + + + /* from Must2 + // Raw Threshold + m_Si_X_E_RAW_Threshold = 8200; + m_Si_Y_E_RAW_Threshold = 8200; + // Calibrated Threshold + m_Si_X_E_Threshold = 0; + m_Si_Y_E_Threshold = 0; + + + m_Take_E_Y = false; + m_Take_T_Y = true; + */ + ////////////////// + +} + +/////////////////////////////////////////////////////////////////////////// +TIssPhysics::~TIssPhysics() {} + + + +/////////////////////////////////////////////////////////////////////////// + +void TIssPhysics::BuildPhysicalEvent() { + + PreTreat(); + + vector< TVector2 > couple = Match_Front_Back() ; + EventMultiplicity = couple.size(); + + + /* + for(unsigned int i = 0 ; i < EventMultiplicity ; ++i){ + cout << " iX= " << couple[i].X() << " iY=" << couple[i].Y() << endl; + } + //CHECK + */ + + unsigned int size = couple.size(); + for(unsigned int i = 0 ; i < size ; ++i){ + + int N = m_PreTreatedData->GetFront_DetectorNbr(couple[i].X()) ; + + int Front = m_PreTreatedData->GetFront_StripNbr(couple[i].X()) ; + int Back = m_PreTreatedData->GetBack_StripNbr(couple[i].Y()) ; + + double Front_E = m_PreTreatedData->GetFront_Energy( couple[i].X() ) ; + double Back_E = m_PreTreatedData->GetBack_Energy( couple[i].Y() ) ; + + double Front_T = m_PreTreatedData->GetFront_TimeCFD( couple[i].X() ) ; + double Back_T = m_PreTreatedData->GetBack_TimeCFD ( couple[i].Y() ) ; + + DetectorNumber.push_back(N); + StripFront_E.push_back(Front_E); + StripFront_T.push_back(Front_T) ; + StripBack_E.push_back(Back_E) ; + StripBack_T.push_back(Back_T) ; + Strip_Front.push_back(Front) ; + Strip_Back.push_back(Back) ; + + // Try to obtain Pixel Calibration + static CalibrationManager* Cal = CalibrationManager::getInstance(); + static string name; + //Store for calibration purposes + Strip_Front_RawE.push_back(StripFront_OriginalE[couple[i].X()]); + Strip_Back_RawE.push_back(StripBack_OriginalE[couple[i].Y()]); + + //Proceed for Pixel Calibration + name = "ISS/D"+ NPL::itoa(N)+"_STRIP_FRONT"+ NPL::itoa(Front)+"_BACK"+ NPL::itoa(Back)+"_E"; + double Pixel_E = Cal->ApplyCalibration(name,StripFront_OriginalE[couple[i].X()] ); + if(Pixel_E != StripFront_OriginalE[couple[i].X()]){ + Strip_E.push_back(Pixel_E); + name = "ISS/D"+ NPL::itoa(N)+"_STRIP_FRONT"+ NPL::itoa(Front)+"_BACK"+ NPL::itoa(Back)+"_DEADLAYER"; + DeadLayer.push_back(Cal->GetValue(name,0)); + } + // Fall Back option, take the Strip Calibration + else if(m_Take_E_Front){ + Strip_E.push_back(Front_E) ; + name = "ISS/D"+ NPL::itoa(N)+"_STRIP_FRONT"+ NPL::itoa(Front)+"_DEADLAYER"; + DeadLayer.push_back(Cal->GetValue(name,0)); + } + else{ + Strip_E.push_back(Back_E) ; + name = "ISS/D"+ NPL::itoa(N)+"_STRIP_BACK"+ NPL::itoa(Back)+"_DEADLAYER"; + DeadLayer.push_back(Cal->GetValue(name,0)); + } + + if(m_Take_T_Back) + Strip_T.push_back(Back_T) ; + else + Strip_T.push_back(Front_T) ; + + + } + + if(DetectorNumber.size()==1) + return; + +} +/////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////// +void TIssPhysics::BuildSimplePhysicalEvent(){ + + + BuildPhysicalEvent(); + +} + + + +/////////////////////////////////////////////////////////////////////////// +void TIssPhysics::PreTreat() { + + + ClearPreTreatedData(); + + + // Front + unsigned int sizeFront = m_EventData->GetMultiplicityFront(); + for(unsigned int i = 0 ; i < sizeFront ; i++){ + if( m_EventData->GetFront_Energy(i)>m_StripFront_E_RAW_Threshold && IsValidChannel("Front", m_EventData->GetFront_DetectorNbr(i), m_EventData->GetFront_StripNbr(i)) ){ + double Front_E = fStrip_Front_E(m_EventData , i); + if( Front_E > m_StripFront_E_Threshold ){ + m_PreTreatedData->SetFront( m_EventData->GetFront_DetectorNbr(i), + m_EventData->GetFront_StripNbr(i), + Front_E, + m_EventData->GetFront_TimeCFD(i), + m_EventData->GetFront_TimeLED(i)); + + StripFront_OriginalE.push_back( m_EventData->GetFront_Energy(i)); + } + } + } + + // Back + unsigned int sizeBack = m_EventData->GetMultiplicityBack() ; + for(unsigned int i = 0 ; i < sizeBack ; i++){ + if( m_EventData->GetBack_Energy(i)>m_StripBack_E_RAW_Threshold && IsValidChannel("Back", m_EventData->GetBack_DetectorNbr(i), m_EventData->GetBack_StripNbr(i)) ){ + double Back_E = fStrip_Back_E(m_EventData , i); + if( Back_E > m_StripBack_E_Threshold ){ + m_PreTreatedData->SetBack( m_EventData->GetBack_DetectorNbr(i), + m_EventData->GetBack_StripNbr(i), + Back_E, + m_EventData->GetBack_TimeCFD(i), + m_EventData->GetBack_TimeLED(i)); + + StripBack_OriginalE.push_back( m_EventData->GetBack_Energy(i)); + } + } + } + + + + return; +} + + +/////////////////////////////////////////////////////////////////////////// + + +/////////////////////////////////////////////////////////////////////////// +int TIssPhysics :: CheckEvent(){ + return 1 ; // Regular Event +} + +/////////////////////////////////////////////////////////////////////////// + + + +vector < TVector2 > TIssPhysics :: Match_Front_Back(){ + vector < TVector2 > ArrayOfGoodCouple ; + // Prevent code from treating very high multiplicity Event + // Those event are not physical anyway and that improve speed. + if( m_PreTreatedData->GetMultiplicityFront() > m_MaximumStripMultiplicityAllowed || m_PreTreatedData->GetMultiplicityBack() > m_MaximumStripMultiplicityAllowed ) + return ArrayOfGoodCouple; + + ArrayOfGoodCouple.clear(); + unsigned int mysizeF = m_PreTreatedData->GetMultiplicityFront(); + unsigned int mysizeB = m_PreTreatedData->GetMultiplicityBack(); + //cout << " mysizeF/B = " << mysizeF << " " << mysizeB << endl; //CHECK + + for(unsigned int i = 0 ; i < mysizeF ; i++) { + for(unsigned int j = 0 ; j < mysizeB ; j++){ + //cout << "Det Number F/B = " << m_PreTreatedData->GetFront_DetectorNbr(i) << " =? " << m_PreTreatedData->GetBack_DetectorNbr(j) << endl; + // if same detector check energy + if ( m_PreTreatedData->GetFront_DetectorNbr(i) == m_PreTreatedData->GetBack_DetectorNbr(j) ){ + //cout << "Energy F= " << m_PreTreatedData->GetFront_Energy(i) << endl; + //cout << "Energy B= " << m_PreTreatedData->GetBack_Energy(j) << endl; + //cout << "abs(F-B)= " << abs( (m_PreTreatedData->GetFront_Energy(i)-m_PreTreatedData->GetBack_Energy(j))/2. ) << endl; + //cout << "Allowed difference = " << m_StripEnergyMatchingNumberOfSigma*m_StripEnergyMatchingSigma << endl; + + // Look if energy match + if( abs( (m_PreTreatedData->GetFront_Energy(i)-m_PreTreatedData->GetBack_Energy(j))/2. ) < m_StripEnergyMatchingNumberOfSigma*m_StripEnergyMatchingSigma ){ + //cout << " Good Couple!! " << endl; + ArrayOfGoodCouple.push_back ( TVector2(i,j) ) ; + } + + } + } + } + + //cout << " Good couples = " << ArrayOfGoodCouple.size() << " must.be.less.then " << m_PreTreatedData->GetMultiplicityFront() << endl; + + // Prevent to treat event with ambiguous matching beetween Front and Back + if( ArrayOfGoodCouple.size() > m_PreTreatedData->GetMultiplicityFront() ) + ArrayOfGoodCouple.clear() ; + + //cout << " final size = " << ArrayOfGoodCouple.size() << endl; + + return ArrayOfGoodCouple; + + + + + + /* from MUST2 + vector<TVector2> TIssPhysics::Match_X_Y() { + vector<TVector2> ArrayOfGoodCouple; + ArrayOfGoodCouple.clear(); + + m_StripXEMult = m_PreTreatedData->GetMMStripXEMult(); + m_StripYEMult = m_PreTreatedData->GetMMStripYEMult(); + + double matchSigma = m_StripEnergyMatchingSigma; + double NmatchSigma = m_StripEnergyMatchingNumberOfSigma; + + // Prevent code from treating very high multiplicity Event + // Those event are not physical anyway and that improve speed. + if (m_StripXEMult > m_MaximumStripMultiplicityAllowed + || m_StripYEMult > m_MaximumStripMultiplicityAllowed) { + return ArrayOfGoodCouple; + } + + // Get Detector multiplicity + for (unsigned int i = 0; i < m_StripXEMult; i++) { + int N = m_PreTreatedData->GetMMStripXEDetectorNbr(i); + m_StripXMultDet[N] += 1; + } + + for (unsigned int j = 0; j < m_StripYEMult; j++) { + int N = m_PreTreatedData->GetMMStripYEDetectorNbr(j); + m_StripYMultDet[N] += 1; + } + + for (unsigned int i = 0; i < m_StripXEMult; i++) { + for (unsigned int j = 0; j < m_StripYEMult; j++) { + + // Declaration of variable for clarity + int StripXDetNbr = m_PreTreatedData->GetMMStripXEDetectorNbr(i); + int StripYDetNbr = m_PreTreatedData->GetMMStripYEDetectorNbr(j); + + // if same detector check energy + if (StripXDetNbr == StripYDetNbr) { + + int DetNbr = StripXDetNbr; + + // Declaration of variable for clarity + double StripXEnergy = m_PreTreatedData->GetMMStripXEEnergy(i); + double StripXNbr = m_PreTreatedData->GetMMStripXEStripNbr(i); + + double StripYEnergy = m_PreTreatedData->GetMMStripYEEnergy(j); + double StripYNbr = m_PreTreatedData->GetMMStripYEStripNbr(j); + + // Look if energy match + // FIXME Should be proportional to the energy loss in the DSSDs + // if (abs(StripXEnergy - StripYEnergy) + // < 0.09 * (std::max(StripXEnergy, StripYEnergy))) { + // negligible correction according to Adrien + /* + if (abs((StripXEnergy - StripYEnergy) / 2.) + < NmatchSigma * matchSigma) { + + // Special Option, if the event is between two CsI + // cristal, it is rejected. + if (m_Ignore_not_matching_CsI) { + bool check_validity = false; + for (unsigned int hh = 0; hh < 16; ++hh) { + if (Match_Si_CsI(StripXNbr, StripYNbr, hh + 1)) { + check_validity = true; + } + } + if (check_validity) { + ArrayOfGoodCouple.push_back(TVector2(i, j)); + } + } + + // Special Option, if the event is between two SiLi pad , + // it is rejected. + else if (m_Ignore_not_matching_SiLi) { + bool check_validity = false; + for (unsigned int hh = 0; hh < 16; ++hh) { + if (Match_Si_SiLi(StripXNbr, StripYNbr, hh + 1)) + check_validity = true; + } + if (check_validity) + ArrayOfGoodCouple.push_back(TVector2(i, j)); + } + // Regular case, keep the event + else { + ArrayOfGoodCouple.push_back(TVector2(i, j)); + m_NMatchDet[DetNbr] += 1; + } + } + } // if same detector + } // loop on StripY Mult + } // loop on StripX Mult + + unsigned int couple_size = ArrayOfGoodCouple.size(); + + for (unsigned int i = 0; i < couple_size; ++i) { + int N = m_PreTreatedData->GetMMStripXEDetectorNbr(ArrayOfGoodCouple[i].X()); + m_match_type.push_back(CheckEvent(N)); + } + return ArrayOfGoodCouple; + */ + +} + + + +//////////////////////////////////////////////////////////////////////////// +bool TIssPhysics :: IsValidChannel(const string& DetectorType, const int& telescope , const int& channel){ + + if(DetectorType == "Front") + return *(m_FrontChannelStatus[telescope-1].begin()+channel-1); + + else if(DetectorType == "Back") + return *(m_BackChannelStatus[telescope-1].begin()+channel-1); + + else return false; +} + +/////////////////////////////////////////////////////////////////////////// +void TIssPhysics::ReadAnalysisConfig(){ + bool ReadingStatus = false; + + // path to file + string FileName = "./configs/ConfigIss.dat"; + + // open analysis config file + ifstream AnalysisConfigFile; + AnalysisConfigFile.open(FileName.c_str()); + + if (!AnalysisConfigFile.is_open()) { + cout << " No ConfigIss.dat found: Default parameter loaded for Analysis " << FileName << endl; + return; + } + cout << " Loading user parameter for Analysis from ConfigIss.dat " << endl; + + // Save it in a TAsciiFile + TAsciiFile* asciiConfig = RootOutput::getInstance()->GetAsciiFileAnalysisConfig(); + asciiConfig->AppendLine("%%% ConfigIss.dat %%%"); + asciiConfig->Append(FileName.c_str()); + asciiConfig->AppendLine(""); + // read analysis config file + string LineBuffer,DataBuffer,whatToDo; + while (!AnalysisConfigFile.eof()) { + // Pick-up next line + getline(AnalysisConfigFile, LineBuffer); + + // search for "header" + if (LineBuffer.compare(0, 11, "ConfigIss") == 0) ReadingStatus = true; + + // loop on tokens and data + while (ReadingStatus ) { + + whatToDo=""; + AnalysisConfigFile >> whatToDo; + + // Search for comment symbol (%) + if (whatToDo.compare(0, 1, "%") == 0) { + AnalysisConfigFile.ignore(numeric_limits<streamsize>::max(), '\n' ); + } + + else if (whatToDo=="MAX_STRIP_MULTIPLICITY") { + AnalysisConfigFile >> DataBuffer; + m_MaximumStripMultiplicityAllowed = atoi(DataBuffer.c_str() ); + cout << "MAXIMUN STRIP MULTIPLICITY " << m_MaximumStripMultiplicityAllowed << endl; + } + + else if (whatToDo=="STRIP_ENERGY_MATCHING_SIGMA") { + AnalysisConfigFile >> DataBuffer; + m_StripEnergyMatchingSigma = atof(DataBuffer.c_str() ); + cout << "STRIP ENERGY MATCHING SIGMA " << m_StripEnergyMatchingSigma <<endl; + } + + else if (whatToDo=="STRIP_ENERGY_MATCHING_NUMBER_OF_SIGMA") { + AnalysisConfigFile >> DataBuffer; + m_StripEnergyMatchingNumberOfSigma = atoi(DataBuffer.c_str() ); + cout << "STRIP ENERGY MATCHING NUMBER OF SIGMA " << m_StripEnergyMatchingNumberOfSigma << endl; + } + + else if (whatToDo== "DISABLE_ALL") { + AnalysisConfigFile >> DataBuffer; + cout << whatToDo << " " << DataBuffer << endl; + int Detector = atoi(DataBuffer.substr(2,2).c_str()); + vector< bool > ChannelStatus; + ChannelStatus.resize(128,false); + //ChannelStatus.resize(24,false); + m_FrontChannelStatus[Detector-1] = ChannelStatus; + ChannelStatus.resize(11,false); + //ChannelStatus.resize(22,false); + //ChannelStatus.resize(48,false); + m_BackChannelStatus[Detector-1] = ChannelStatus; + + } + + else if (whatToDo == "DISABLE_CHANNEL") { + AnalysisConfigFile >> DataBuffer; + int Detector = atoi(DataBuffer.substr(2,2).c_str()); + int channel = -1; + if (DataBuffer.find("STRF") != string::npos) { + channel = atoi(DataBuffer.substr(8).c_str()); + *(m_FrontChannelStatus[Detector-1].begin()+channel-1) = false; + cout << "DISABLE DETECTOR " << Detector << " STRIP FRONT " << channel << endl; + } + + else if (DataBuffer.find("STRB")!=string::npos) { + channel = atoi(DataBuffer.substr(8).c_str()); + *(m_BackChannelStatus[Detector-1].begin()+channel-1) = false; + cout << "DISABLE DETECTOR " << Detector << " STRIP BACK " << channel << endl; + + } + + + else cout << "Warning: detector type for Iss unknown!" << endl; + + } + + else if (whatToDo=="TAKE_E_FRONT") { + m_Take_E_Front = true; + cout << whatToDo << endl; + } + + else if (whatToDo=="TAKE_E_BACK") { + m_Take_E_Front = false; + cout << whatToDo << endl; + } + + else if (whatToDo=="TAKE_T_FRONT") { + m_Take_T_Back = false; + cout << whatToDo << endl; + } + + else if (whatToDo=="TAKE_T_BACK") { + m_Take_T_Back = true; + cout << whatToDo << endl; + } + + else if (whatToDo=="STRIP_FRONT_E_RAW_THRESHOLD") { + AnalysisConfigFile >> DataBuffer; + m_StripFront_E_RAW_Threshold = atof(DataBuffer.c_str()); + cout << whatToDo << " " << m_StripFront_E_RAW_Threshold << endl; + } + + else if (whatToDo=="STRIP_BACK_E_RAW_THRESHOLD") { + AnalysisConfigFile >> DataBuffer; + m_StripBack_E_RAW_Threshold = atof(DataBuffer.c_str()); + cout << whatToDo << " " << m_StripBack_E_RAW_Threshold << endl; + } + + else if (whatToDo=="STRIP_FRONT_E_THRESHOLD") { + AnalysisConfigFile >> DataBuffer; + m_StripFront_E_Threshold = atof(DataBuffer.c_str()); + cout << whatToDo << " " << m_StripFront_E_Threshold << endl; + } + + else if (whatToDo=="STRIP_BACK_E_THRESHOLD") { + AnalysisConfigFile >> DataBuffer; + m_StripBack_E_Threshold = atof(DataBuffer.c_str()); + cout << whatToDo << " " << m_StripBack_E_Threshold << endl; + } + + + else { + ReadingStatus = false; + } + + } + } + +} + + +/////////////////////////////////////////////////////////////////////////// +void TIssPhysics::Clear(){ + EventMultiplicity = 0; + + // Provide a Classification of Event + EventType.clear() ; + + // Detector + DetectorNumber.clear() ; + + // DSSD + Strip_E.clear() ; + Strip_T.clear() ; + StripFront_E.clear() ; + StripFront_T.clear(); + StripBack_E.clear() ; + StripBack_T.clear() ; + Strip_Front.clear() ; + Strip_Back.clear() ; + StripFront_OriginalE.clear(); + StripBack_OriginalE.clear(); + DeadLayer.clear(); + Strip_Front_RawE.clear(); + Strip_Back_RawE.clear(); +} +/////////////////////////////////////////////////////////////////////////// + +//// Innherited from VDetector Class //// + +/////////////////////////////////////////////////////////////////////////// +void TIssPhysics::ReadConfiguration(NPL::InputParser parser){ + vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithToken("ISSDet"); + if(NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks.size() << " detectors found " << endl; + + // Cartesian Case + vector<string> cart + = {"X1_Y1", "X1_Y128", "X128_Y1", "X128_Y128", "SI"}; + vector<string> cart1 + = {"MField", "X1_Y1", "X1_Y128", "X128_Y1", "X128_Y128", "SI"}; + + // Spherical Case + vector<string> sphe = {"R", "THETA", "PHI", "BETA", "SI"}; + + for (unsigned int i = 0; i < blocks.size(); i++) { + + if (blocks[i]->HasTokenList(cart1)) { + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// Iss Telescope " << i + 1 << endl; + m_NominalField= blocks[i]->GetDouble("MField", "tesla"); + TVector3 A = blocks[i]->GetTVector3("X1_Y1", "mm"); + TVector3 B = blocks[i]->GetTVector3("X128_Y1", "mm"); + TVector3 C = blocks[i]->GetTVector3("X1_Y128", "mm"); + TVector3 D = blocks[i]->GetTVector3("X128_Y128", "mm"); + AddTelescope(A, B, C, D); + } + + else if (blocks[i]->HasTokenList(cart)) { + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// Iss Telescope " << i + 1 << endl; + TVector3 A = blocks[i]->GetTVector3("X1_Y1", "mm"); + TVector3 B = blocks[i]->GetTVector3("X128_Y1", "mm"); + TVector3 C = blocks[i]->GetTVector3("X1_Y128", "mm"); + TVector3 D = blocks[i]->GetTVector3("X128_Y128", "mm"); + AddTelescope(A, B, C, D); + + } + + else if (blocks[i]->HasTokenList(sphe)) { + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// Iss Telescope " << i + 1 << endl; + + double Theta = blocks[i]->GetDouble("THETA", "deg"); + double Phi = blocks[i]->GetDouble("PHI", "deg"); + double R = blocks[i]->GetDouble("R", "mm"); + vector<double> beta = blocks[i]->GetVectorDouble("BETA", "deg"); + //AddTelescope(Theta, Phi, R, beta[0], beta[1], beta[2]); + + } + + else { + cout << "ERROR: Missing token for M2Telescope blocks, check your " + "input " + "file" + << endl; + exit(1); + } + } + + + /* + vector<string> tokenBOX = {"Z","ThicknessDetector1","ThicknessDetector2","ThicknessDetector3","ThicknessDetector4","ThicknessPAD1","ThicknessPAD2","ThicknessPAD3","ThicknessPAD4"}; + + for(unsigned int i = 0 ; i < blocks.size() ; i++){ + + if(blocks[i]->GetMainValue()=="BOX" && blocks[i]->HasTokenList(tokenBOX)){ + if(NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// Iss Box " << i+1 << endl; + double Z = blocks[i]->GetDouble("Z","mm"); + double Thickness1= blocks[i]->GetDouble("ThicknessDetector1","micrometer"); + double Thickness2= blocks[i]->GetDouble("ThicknessDetector2","micrometer"); + double Thickness3= blocks[i]->GetDouble("ThicknessDetector3","micrometer"); + double Thickness4= blocks[i]->GetDouble("ThicknessDetector4","micrometer"); + double ThicknessPAD1 = blocks[i]->GetDouble("ThicknessPAD1","micrometer"); + double ThicknessPAD2 = blocks[i]->GetDouble("ThicknessPAD2","micrometer"); + double ThicknessPAD3 = blocks[i]->GetDouble("ThicknessPAD3","micrometer"); + double ThicknessPAD4 = blocks[i]->GetDouble("ThicknessPAD4","micrometer"); + AddBoxDetector(Z); + } + + else{ + cout << "Warning: check your input file formatting " << endl; + } + } + */ + + InitializeStandardParameter(); + ReadAnalysisConfig(); +} +/////////////////////////////////////////////////////////////////////////// +void TIssPhysics::InitSpectra(){ + m_Spectra = new TIssSpectra(m_NumberOfDetector); +} + +/////////////////////////////////////////////////////////////////////////// +void TIssPhysics::FillSpectra(){ + m_Spectra -> FillRawSpectra(m_EventData); + m_Spectra -> FillPreTreatedSpectra(m_PreTreatedData); + m_Spectra -> FillPhysicsSpectra(m_EventPhysics); +} +/////////////////////////////////////////////////////////////////////////// +void TIssPhysics::CheckSpectra(){ + m_Spectra->CheckSpectra(); +} +/////////////////////////////////////////////////////////////////////////// +void TIssPhysics::ClearSpectra(){ + // To be done +} +/////////////////////////////////////////////////////////////////////////// +map< string , TH1*> TIssPhysics::GetSpectra() { + if(m_Spectra) + return m_Spectra->GetMapHisto(); + else{ + map< string , TH1*> empty; + return empty; + } +} + +/////////////////////////////////////////////////////////////////////////// +void TIssPhysics::WriteSpectra(){ + m_Spectra->WriteSpectra(); +} +/////////////////////////////////////////////////////////////////////////// +void TIssPhysics::AddParameterToCalibrationManager(){ + CalibrationManager* Cal = CalibrationManager::getInstance(); + + for(int i = 0 ; i < m_NumberOfDetector ; ++i){ + + for( int j = 0 ; j < 128 ; ++j){ + // Front Strip Calibration + Cal->AddParameter("ISS", "D"+ NPL::itoa(i+1)+"_STRIP_FRONT"+ NPL::itoa(j+1)+"_E","ISS_D"+ NPL::itoa(i+1)+"_STRIP_FRONT"+ NPL::itoa(j+1)+"_E") ; + Cal->AddParameter("ISS", "D"+ NPL::itoa(i+1)+"_STRIP_FRONT"+ NPL::itoa(j+1)+"_DEADLAYER", + "ISS_D"+ NPL::itoa(i+1)+"_STRIP_FRONT"+ NPL::itoa(j+1)+"_DEADLAYER") ; + Cal->AddParameter("ISS", "D"+ NPL::itoa(i+1)+"_STRIP_FRONT"+ NPL::itoa(j+1)+"_T","ISS_D"+ NPL::itoa(i+1)+"_STRIP_FRONT"+ NPL::itoa(j+1)+"_T") ; + + // Pixel Calibration + //for( int k = 0 ; k < 22 ; ++k){ + for( int k = 0 ; k < 11 ; ++k){ + + Cal->AddParameter("ISS", "D"+ NPL::itoa(i+1)+"_STRIP_FRONT"+ NPL::itoa(j+1)+"_BACK"+ NPL::itoa(k+1)+"_E","ISS_D"+ NPL::itoa(i+1)+"_STRIP_FRONT"+ NPL::itoa(j+1)+"_BACK"+ NPL::itoa(k+1)+"_E") ; + Cal->AddParameter("ISS", "D"+ NPL::itoa(i+1)+"_STRIP_FRONT"+ NPL::itoa(j+1)+"_BACK"+ NPL::itoa(k+1)+"_DEADLAYER", + "ISS_D"+ NPL::itoa(i+1)+"_STRIP_FRONT"+ NPL::itoa(j+1)+"_BACK"+ NPL::itoa(k+1)+"_DEADLAYER") ; + + } + } + + //for( int j = 0 ; j < 22 ; ++j){ + for( int j = 0 ; j < 11 ; ++j){ + + // Back strip Calibration + Cal->AddParameter("ISS", "D"+ NPL::itoa(i+1)+"_STRIP_BACK"+ NPL::itoa(j+1)+"_E","ISS_D"+ NPL::itoa(i+1)+"_STRIP_BACK"+ NPL::itoa(j+1)+"_E") ; + Cal->AddParameter("ISS", "D"+ NPL::itoa(i+1)+"_STRIP_BACK"+ NPL::itoa(j+1)+"_DEADLAYER", + "ISS_D"+ NPL::itoa(i+1)+"_STRIP_BACK"+ NPL::itoa(j+1)+"_DEADLAYER") ; + + Cal->AddParameter("ISS", "D"+ NPL::itoa(i+1)+"_STRIP_BACK"+ NPL::itoa(j+1)+"_T","ISS_D"+ NPL::itoa(i+1)+"_STRIP_BACK"+ NPL::itoa(j+1)+"_T") ; + } + + for( int j = 0 ; j < 1 ; ++j){ + // Pad Calibration + Cal->AddParameter("ISS", "D"+ NPL::itoa(i+1)+"_PAD_E","ISS_D"+ NPL::itoa(i+1)+"_PAD_E") ; + Cal->AddParameter("ISS", "D"+ NPL::itoa(i+1)+"_PAD_T","ISS_D"+ NPL::itoa(i+1)+"_PAD_T") ; + } + } + + return; + +} + +/////////////////////////////////////////////////////////////////////////// +void TIssPhysics::InitializeRootInputRaw(){ + TChain* inputChain = RootInput::getInstance()->GetChain() ; + inputChain->SetBranchStatus( "ISS" , true ); + // The following line is necessary only for system were the tree is splitted + // (older root version). The found argument silenced the Branches not found + // warning for non splitted tree. + if(inputChain->FindBranch("fIss_*")) + inputChain->SetBranchStatus( "fIss_*",true); + inputChain->SetBranchAddress( "ISS" , &m_EventData ); + +} + +/////////////////////////////////////////////////////////////////////////// +void TIssPhysics::InitializeRootInputPhysics(){ + TChain* inputChain = RootInput::getInstance()->GetChain(); + inputChain->SetBranchStatus( "EventMultiplicity" , true ); + inputChain->SetBranchStatus( "EventType" , true ); + inputChain->SetBranchStatus( "DetectorNumber" , true ); + inputChain->SetBranchStatus( "Strip_E" , true ); + inputChain->SetBranchStatus( "Strip_T" , true ); + inputChain->SetBranchStatus( "StripFront_E" , true ); + inputChain->SetBranchStatus( "StripFront_T" , true ); + inputChain->SetBranchStatus( "StripBack_E" , true ); + inputChain->SetBranchStatus( "StripBack_T" , true ); + inputChain->SetBranchStatus( "Strip_Front" , true ); + inputChain->SetBranchStatus( "Strip_Back" , true ); + inputChain->SetBranchAddress( "ISS" , &m_EventPhysics ) ; +} + +/////////////////////////////////////////////////////////////////////////// +void TIssPhysics::InitializeRootOutput(){ + TTree* outputTree = RootOutput::getInstance()->GetTree(); + outputTree->Branch( "ISS" , "TIssPhysics" , &m_EventPhysics ); +} + +//////////////////////////////////////////////////////////////////////////////// +///// Specific to IssArray //// + +// telescope +void TIssPhysics::AddTelescope(TVector3 C_X1_Y1, TVector3 C_X128_Y1, + TVector3 C_X1_Y128, TVector3 C_X128_Y128) { + // To avoid warning + C_X128_Y128 *= 1; + + //m_NumberOfTelescope++; + m_NumberOfDetector++; + + // Vector U on Telescope Face (paralelle to Y Strip) (NB: remember that + // Y strip are allong X axis) + TVector3 U = C_X128_Y1 - C_X1_Y1; + //double Ushift = (U.Mag() - 98) / 2.; // square Si + //double Ushift = (U.Mag() - 22) / 2.; + U = U.Unit(); + // Vector V on Telescope Face (parallele to X Strip) + TVector3 V = C_X1_Y128 - C_X1_Y1; + // double Vshift = (V.Mag() - 98) / 2.; // square Si + //double Vshift = (V.Mag() - 125) / 2.; + V = V.Unit(); + + // Position Vector of Strip Center + TVector3 StripCenter = TVector3(0, 0, 0); + // Position Vector of X=1 Y=1 Strip + TVector3 Strip_1_1; + + // Geometry Parameter + //double Face = 98; // mm + //double NumberOfStrip = 128; + //double StripPitch = Face / NumberOfStrip; // mm + + double FaceL = 22; // mm + double NumberOfLStrip = 11; + double StripLPitch = FaceL / NumberOfLStrip; // mm + + double FaceT = 125; // mm + double NumberOfTStrip = 128; + double StripTPitch = FaceT / NumberOfTStrip; // mm + + + // Buffer object to fill Position Array + vector<double> lineX; + vector<double> lineY; + vector<double> lineZ; + + vector<vector<double>> OneTelescopeStripPositionX; + vector<vector<double>> OneTelescopeStripPositionY; + vector<vector<double>> OneTelescopeStripPositionZ; + + // Moving StripCenter to 1.1 corner: + //Strip_1_1 = C_X1_Y1 + (U + V) * (StripPitch / 2.); + //Strip_1_1 += U * Ushift + V * Vshift; + + Strip_1_1 = C_X1_Y1 + (U*(StripLPitch/2.)) + (V*(StripTPitch/2.)); // or: C_X1_Y1 + (U * (StripTPitch/2.) + (V* (StripLPitch/2.) !!! To be checked !!! + + cout << "Strip_1_1 x=" << Strip_1_1[0] << endl; + cout << "Strip_1_1 y=" << Strip_1_1[1] << endl; + cout << "Strip_1_1 z=" << Strip_1_1[2] << endl; + + //Strip_1_1 += U * Ushift + V * Vshift; // + + //cout << "Shifted Strip_1_1 x=" << Strip_1_1[0] << endl; + //cout << "Shifted Strip_1_1 y=" << Strip_1_1[1] << endl; + //cout << "Shifted Strip_1_1 z=" << Strip_1_1[2] << endl; + + + //for (int i = 0; i < 128; ++i) { + for (int i = 0; i < NumberOfTStrip; ++i) { // front strip are the transversal one + lineX.clear(); + lineY.clear(); + lineZ.clear(); + + //for (int j = 0; j < 128; ++j) { + for (int j = 0; j < NumberOfLStrip; ++j) { // back strip are the longitudinal one + //StripCenter = Strip_1_1 + StripPitch * (i * U + j * V); + StripCenter = Strip_1_1 + StripLPitch*( j*U ) + StripTPitch*( i*V ); // or: Strip_1_1 + StripTPitch*( j*U ) + StripLPitch*( i*V ) !!! To be checked as above!!! + //StripCenter = Strip_1_1 + StripTPitch*( j*U ) + StripLPitch*( i*V ); // !!! To be checked as above!!! + + lineX.push_back(StripCenter.X()); + lineY.push_back(StripCenter.Y()); + lineZ.push_back(StripCenter.Z()); + } + + OneTelescopeStripPositionX.push_back(lineX); + OneTelescopeStripPositionY.push_back(lineY); + OneTelescopeStripPositionZ.push_back(lineZ); + } + m_StripPositionX.push_back(OneTelescopeStripPositionX); + m_StripPositionY.push_back(OneTelescopeStripPositionY); + m_StripPositionZ.push_back(OneTelescopeStripPositionZ); +} + + +void TIssPhysics::AddTelescope(double theta, double phi, double distance, + double beta_u, double beta_v, double beta_w) { + /* + // m_NumberOfTelescope++; + m_NumberOfDetector++; + + double Pi = 3.141592654; + + // convert from degree to radian: + theta = theta * Pi / 180.; + phi = phi * Pi / 180.; + + // Vector U on Telescope Face (paralelle to Y Strip) (NB: remember that Y + // strip are allong X axis) + TVector3 U; + // Vector V on Telescope Face (parallele to X Strip) + TVector3 V; + // Vector W normal to Telescope Face (pointing CsI) + TVector3 W; + // Vector position of Telescope Face center + TVector3 C; + + C = TVector3(distance * sin(theta) * cos(phi), + distance * sin(theta) * sin(phi), distance * cos(theta)); + + TVector3 P + = TVector3(cos(theta) * cos(phi), cos(theta) * sin(phi), -sin(theta)); + + W = C.Unit(); + U = W.Cross(P); + V = W.Cross(U); + + U = U.Unit(); + V = V.Unit(); + + U.Rotate(beta_u * Pi / 180., U); + V.Rotate(beta_u * Pi / 180., U); + + U.Rotate(beta_v * Pi / 180., V); + V.Rotate(beta_v * Pi / 180., V); + + U.Rotate(beta_w * Pi / 180., W); + V.Rotate(beta_w * Pi / 180., W); + + double Face = 98; // mm + double NumberOfStrip = 128; + double StripPitch = Face / NumberOfStrip; // mm + + vector<double> lineX; + vector<double> lineY; + vector<double> lineZ; + + vector<vector<double>> OneTelescopeStripPositionX; + vector<vector<double>> OneTelescopeStripPositionY; + vector<vector<double>> OneTelescopeStripPositionZ; + + double X, Y, Z; + + // Moving C to the 1.1 corner: + C.SetX(C.X() - (Face / 2 - StripPitch / 2) * (V.X() + U.X())); + C.SetY(C.Y() - (Face / 2 - StripPitch / 2) * (V.Y() + U.Y())); + C.SetZ(C.Z() - (Face / 2 - StripPitch / 2) * (V.Z() + U.Z())); + + for (int i = 0; i < 128; ++i) { + + lineX.clear(); + lineY.clear(); + lineZ.clear(); + + for (int j = 0; j < 128; ++j) { + X = C.X() + StripPitch * (U.X() * i + V.X() * j); + Y = C.Y() + StripPitch * (U.Y() * i + V.Y() * j); + Z = C.Z() + StripPitch * (U.Z() * i + V.Z() * j); + + lineX.push_back(X); + lineY.push_back(Y); + lineZ.push_back(Z); + } + + OneTelescopeStripPositionX.push_back(lineX); + OneTelescopeStripPositionY.push_back(lineY); + OneTelescopeStripPositionZ.push_back(lineZ); + } + m_StripPositionX.push_back(OneTelescopeStripPositionX); + m_StripPositionY.push_back(OneTelescopeStripPositionY); + m_StripPositionZ.push_back(OneTelescopeStripPositionZ); + */ + +} +/* + TVector3 TIssPhysics::GetPositionOfInteraction(const int i) const { + TVector3 Position + = TVector3(GetStripPositionX(TelescopeNumber[i], Si_X[i], Si_Y[i]), + GetStripPositionY(TelescopeNumber[i], Si_X[i], Si_Y[i]), + GetStripPositionZ(TelescopeNumber[i], Si_X[i], Si_Y[i])); + + return (Position); + } + + TVector3 TIssPhysics::GetTelescopeNormal(const int i) const { + TVector3 U = TVector3(GetStripPositionX(TelescopeNumber[i], 128, 1), + GetStripPositionY(TelescopeNumber[i], 128, 1), + GetStripPositionZ(TelescopeNumber[i], 128, 1)) + + - TVector3(GetStripPositionX(TelescopeNumber[i], 1, 1), + GetStripPositionY(TelescopeNumber[i], 1, 1), + GetStripPositionZ(TelescopeNumber[i], 1, 1)); + + TVector3 V = TVector3(GetStripPositionX(TelescopeNumber[i], 128, 128), + GetStripPositionY(TelescopeNumber[i], 128, 128), + GetStripPositionZ(TelescopeNumber[i], 128, 128)) + + - TVector3(GetStripPositionX(TelescopeNumber[i], 128, 1), + GetStripPositionY(TelescopeNumber[i], 128, 1), + GetStripPositionZ(TelescopeNumber[i], 128, 1)); + + TVector3 Normal = U.Cross(V); + + return (Normal.Unit()); + } + + */ + + + + + + +// Box +void TIssPhysics::AddBoxDetector(double Z){ + // BOX // + double BOX_PCB_Width = 26; //61.10; + double BOX_PCB_Length = 129; //104.00; + double BOX_PCB_Thickness = 1;// 3.4; + double BOX_PCB_Border_LongSide = 1; + double BOX_PCB_Border_ShortSide = 2; + + // Single stage box case (DSSD only) + double BOX_PCB_Slot_Width1 = BOX_PCB_Thickness; + double BOX_PCB_Slot_Border1 = 4; + double BOX_PCB_Slot_Deepness1 = BOX_PCB_Border_ShortSide; + + // BOX Wafer + double BOX_ActiveWafer_Width = 22; //48; + double BOX_ActiveWafer_Length = 125;//72; + double BOX_Wafer_Width = 23; // 52.20; + double BOX_Wafer_Length = 126; //76.20; + + int BOX_Wafer_Front_NumberOfStrip = 128; //24 ; + int BOX_Wafer_Back_NumberOfStrip = 11; //22; //48 ; + + // Compute + double BOX_LeftOver1 = BOX_PCB_Length - BOX_PCB_Border_ShortSide - BOX_Wafer_Length - BOX_PCB_Slot_Border1 - BOX_PCB_Slot_Width1 ; + double BOX_Exposed_Length1 = BOX_Wafer_Length + BOX_PCB_Slot_Border1 ; + + double BOX_CenterOffset1 = - 0.5 * BOX_PCB_Length+BOX_PCB_Border_ShortSide+0.5*BOX_Exposed_Length1; + double BOX_DetectorSpacing1 = 0.5*BOX_Exposed_Length1+0.5*BOX_PCB_Slot_Width1; + + double BOX_Wafer_Width_Offset1 = -0.5*BOX_PCB_Width + BOX_PCB_Border_LongSide + 0.5*BOX_Wafer_Width; + double BOX_Wafer_Length_Offset1 = -0.5*BOX_PCB_Length + BOX_PCB_Border_ShortSide + 0.5*BOX_Wafer_Length; + + double BOX_PCB_Slot_Position1 = 0.5*BOX_PCB_Length-BOX_LeftOver1 - 0.5*BOX_PCB_Slot_Width1; + + double StripPitchFront = BOX_ActiveWafer_Length/BOX_Wafer_Front_NumberOfStrip ; //mm + double StripPitchBack = BOX_ActiveWafer_Width/BOX_Wafer_Back_NumberOfStrip ; //mm + m_BoxPitchBack = StripPitchBack; + m_BoxPitchFront = StripPitchFront; + + // Double stage box case (DSSD+PAD) (the wafer is the same but the slot is different to accomodate the additional PAD) + double PAD_PCB_Thickness = 3.4; + + double BOX_PCB_Slot_Width2 = BOX_PCB_Thickness + PAD_PCB_Thickness ; + double BOX_PCB_Slot_Border2 = 2.7; + double BOX_PCB_Slot_Deepness2 = BOX_PCB_Border_ShortSide; + + double BOX_LeftOver2 = BOX_PCB_Length - BOX_PCB_Border_ShortSide - BOX_Wafer_Length - BOX_PCB_Slot_Border2 - BOX_PCB_Slot_Width2; + double BOX_Exposed_Length2 = BOX_Wafer_Length + BOX_PCB_Slot_Border2 ; + + double BOX_CenterOffset2 = - 0.5*BOX_PCB_Length+BOX_PCB_Border_ShortSide + 0.5*BOX_Exposed_Length2; + double BOX_DetectorSpacing2 = 0.5*BOX_Exposed_Length2 + 0.5*BOX_PCB_Thickness; + + double BOX_Wafer_Width_Offset2 = - 0.5*BOX_PCB_Width + BOX_PCB_Border_LongSide + 0.5*BOX_Wafer_Width; + double BOX_Wafer_Length_Offset2 = - 0.5*BOX_PCB_Length + BOX_PCB_Border_ShortSide + 0.5*BOX_Wafer_Length; + + double BOX_PCB_Slot_Position2 = 0.5*BOX_PCB_Length-BOX_LeftOver2 - 0.5*BOX_PCB_Slot_Width2; + + + double A1 = BOX_Exposed_Length1*0.5 -BOX_PCB_Slot_Border1- 0.5*StripPitchFront ; + double B1 = BOX_DetectorSpacing1 - 0.5*BOX_PCB_Thickness; + double Z1 = Z - BOX_Wafer_Width*0.5 + StripPitchBack*0.5 ; + + double A2 = BOX_Exposed_Length2*0.5 -BOX_PCB_Slot_Border2- 0.5*StripPitchFront ; + double B2 = BOX_DetectorSpacing2 - 0.5*BOX_PCB_Thickness; + double Z2 = Z + BOX_Wafer_Width*0.5 - StripPitchBack*0.5 ; + + TVector3 U; TVector3 V;TVector3 Strip_1_1; + + + + //cout << "cava" << endl; + + + // To do : adapted for 24 detecteor rather than 4 and for 6 sides/orientation along z rather than 4 + for(int i = 0 ; i < 4 ; i++){ + m_NumberOfDetector++; + if(Z<0){// Up Stream + if(i==0) {U=TVector3(1,0,0);V=TVector3(0,0,1); Strip_1_1=TVector3( -A1 , B1 ,Z1); m_DetectorNormal.push_back(TVector3(0,-1,0));} + else if(i==1) {U=TVector3(0,1,0);V=TVector3(0,0,1); Strip_1_1=TVector3( -B1 , -A1 ,Z1); m_DetectorNormal.push_back(TVector3(1,0,0)) ;} + else if(i==2) {U=TVector3(-1,0,0);V=TVector3(0,0,1); Strip_1_1=TVector3( A1 , -B1 ,Z1); m_DetectorNormal.push_back(TVector3(0,1,0)) ;} + else if(i==3) {U=TVector3(0,-1,0);V=TVector3(0,0,1); Strip_1_1=TVector3( B1 , A1 ,Z1); m_DetectorNormal.push_back(TVector3(-1,0,0));} + } + + else if(Z>0){//Down Stream + if(i==0) {U=TVector3(-1,0,0);V=TVector3(0,0,-1); Strip_1_1=TVector3( A2 ,B2 ,Z2); m_DetectorNormal.push_back(TVector3(0,-1,0));} + else if(i==1) {U=TVector3(0,-1,0);V=TVector3(0,0,-1); Strip_1_1=TVector3( -B2 ,A2 ,Z2); m_DetectorNormal.push_back(TVector3(1,0,0)) ;} + else if(i==2) {U=TVector3(1,0,0);V=TVector3(0,0,-1); Strip_1_1=TVector3( -A2 ,-B2 ,Z2); m_DetectorNormal.push_back(TVector3(0,1,0)) ;} + else if(i==3) {U=TVector3(0,1,0);V=TVector3(0,0,-1); Strip_1_1=TVector3( B2 ,-A2 ,Z2); m_DetectorNormal.push_back(TVector3(-1,0,0));} + } + + m_U.push_back(U); + m_V.push_back(V); + + //cout << "cava" << endl; + + + // Buffer object to fill Position Array + vector<double> lineX ; vector<double> lineY ; vector<double> lineZ ; + + vector< vector< double > > OneBoxStripPositionX ; + vector< vector< double > > OneBoxStripPositionY ; + vector< vector< double > > OneBoxStripPositionZ ; + + TVector3 StripCenter = Strip_1_1; + for(int f = 0 ; f < BOX_Wafer_Front_NumberOfStrip ; f++){ + lineX.clear() ; + lineY.clear() ; + lineZ.clear() ; + + for(int b = 0 ; b < BOX_Wafer_Back_NumberOfStrip ; b++){ + StripCenter = Strip_1_1 + ( StripPitchFront*f*U + StripPitchBack*b*V ); + + lineX.push_back( StripCenter.X() ); + lineY.push_back( StripCenter.Y() ); + lineZ.push_back( StripCenter.Z() ); + } + + OneBoxStripPositionX.push_back(lineX); + OneBoxStripPositionY.push_back(lineY); + OneBoxStripPositionZ.push_back(lineZ); + } + m_StripPositionX.push_back( OneBoxStripPositionX ) ; + m_StripPositionY.push_back( OneBoxStripPositionY ) ; + m_StripPositionZ.push_back( OneBoxStripPositionZ ) ; + } +} + + +//////////////////////////////////////////////////////////////////////////////// +TVector3 TIssPhysics::GetDetectorNormal( const int& i) const{ + return (m_DetectorNormal[DetectorNumber[i]-1]); + +} +//////////////////////////////////////////////////////////////////////////////// +TVector3 TIssPhysics::GetPositionOfInteraction(const int& i,bool random) const{ + static TVector3 Position ; + + //cout << "cava Pos" << endl; + + + Position = TVector3 ( GetStripPositionX( DetectorNumber[i], Strip_Front[i], Strip_Back[i] ), + GetStripPositionY( DetectorNumber[i] , Strip_Front[i], Strip_Back[i] ), + GetStripPositionZ( DetectorNumber[i] , Strip_Front[i], Strip_Back[i] )) ; + + + if(random){ + // Box Detector + + //cout << "DetNum: " << DetectorNumber[i] << endl; + if(m_U[ DetectorNumber[i]-1].Mag()!=0){ + Position += m_V[ DetectorNumber[i]-1]*m_Rand->Uniform(-1,1)*m_BoxPitchBack*0.5; + Position += m_U[ DetectorNumber[i]-1]*m_Rand->Uniform(-1,1)*m_BoxPitchFront*0.5; + } + + } + + return Position ; + +} +//////////////////////////////////////////////////////////////////////////////// +double TIssPhysics::GetDeadLayer(const int& i ) const{ + return DeadLayer[i]; +} +//////////////////////////////////////////////////////////////////////////////// +void TIssPhysics::InitializeStandardParameter() +{ + // Enable all channel + vector< bool > ChannelStatus; + m_FrontChannelStatus.clear() ; + m_BackChannelStatus.clear() ; + + + ChannelStatus.resize(128,true); + for(int i = 0 ; i < m_NumberOfDetector ; i++){ + m_FrontChannelStatus[i] = ChannelStatus; + } + + ChannelStatus.resize(11,true); + for(int i = 0 ; i < m_NumberOfDetector ; i++){ + m_BackChannelStatus[i] = ChannelStatus; + } + + + m_MaximumStripMultiplicityAllowed = m_NumberOfDetector ; + + return; +} + + +/////////////////////////////////////////////////////////////////////////// +namespace ISS_LOCAL{ +// DSSD +// Front +double fStrip_Front_E(const TIssData* m_EventData , const int& i){ + static CalibrationManager* Cal = CalibrationManager::getInstance(); + static string name ; + name = "ISS/D" + NPL::itoa( m_EventData->GetFront_DetectorNbr(i) ) + "_STRIP_FRONT" + NPL::itoa( m_EventData->GetFront_StripNbr(i) ) + "_E"; + return Cal->ApplyCalibration(name,m_EventData->GetFront_Energy(i) ); +} + +double fStrip_Front_T(const TIssData* m_EventData , const int& i){ + static CalibrationManager* Cal = CalibrationManager::getInstance(); + static string name ; + name ="ISS/D" + NPL::itoa( m_EventData->GetFront_DetectorNbr(i) ) + "_STRIP_FRONT" + NPL::itoa( m_EventData->GetFront_StripNbr(i) ) +"_T"; + + return Cal->ApplyCalibration(name, m_EventData->GetFront_TimeCFD(i) ); +} + +// Back +double fStrip_Back_E(const TIssData* m_EventData , const int& i){ + static CalibrationManager* Cal = CalibrationManager::getInstance(); + static string name ; + name = "ISS/D" + NPL::itoa( m_EventData->GetBack_DetectorNbr(i) ) + "_STRIP_BACK" + NPL::itoa( m_EventData->GetBack_StripNbr(i)) +"_E"; + + return Cal->ApplyCalibration(name, m_EventData->GetBack_Energy(i) ); +} + +double fStrip_Back_T(const TIssData* m_EventData , const int& i){ + static CalibrationManager* Cal = CalibrationManager::getInstance(); + static string name ; + name = "ISS/D" + NPL::itoa( m_EventData->GetBack_DetectorNbr(i) ) + "_STRIP_BACK" + NPL::itoa( m_EventData->GetBack_StripNbr(i) ) +"_T"; + + return Cal->ApplyCalibration(name, m_EventData->GetFront_TimeCFD(i)); +} + + +} + +//////////////////////////////////////////////////////////////////////////////// +// Construct Method to be pass to the DetectorFactory // +//////////////////////////////////////////////////////////////////////////////// +NPL::VDetector* TIssPhysics::Construct(){ + return (NPL::VDetector*) new TIssPhysics(); +} + +//////////////////////////////////////////////////////////////////////////////// +// Registering the construct method to the factory // +//////////////////////////////////////////////////////////////////////////////// +extern "C"{ +class proxy_iss{ +public: + proxy_iss(){ + NPL::DetectorFactory::getInstance()->AddToken("ISSDet","Iss"); + NPL::DetectorFactory::getInstance()->AddDetector("ISSDet",TIssPhysics::Construct); + } +}; + +proxy_iss p_iss; +} + + + + +/* from MUST2: + //////////////////////////////////////////////////////////////////////////// + int TIssPhysics::CheckEvent(int N) { + // Bad event + if (m_NMatchDet[N] > m_StripXMultDet[N] + || m_NMatchDet[N] > m_StripYMultDet[N]) { + return 2; + } + // Good event + else { + return 1; + } + } + + //////////////////////////////////////////////////////////////////////////// + bool TIssPhysics::IsValidChannel(const int& DetectorType, + const int& telescope, const int& channel) { + if (DetectorType == 0) + return *(m_XChannelStatus[telescope - 1].begin() + channel - 1); + + else if (DetectorType == 1) + return *(m_YChannelStatus[telescope - 1].begin() + channel - 1); + + else if (DetectorType == 2) + return *(m_SiLiChannelStatus[telescope - 1].begin() + channel - 1); + + else if (DetectorType == 3) + return *(m_CsIChannelStatus[telescope - 1].begin() + channel - 1); + + else + return false; + } + + /////////////////////////////////////////////////////////////////////////// + void TIssPhysics::ReadAnalysisConfig() { + bool ReadingStatus = false; + + // path to file + string FileName = "./configs/ConfigIss.dat"; + + // open analysis config file + ifstream AnalysisConfigFile; + AnalysisConfigFile.open(FileName.c_str()); + + if (!AnalysisConfigFile.is_open()) { + cout << " No ConfigIss.dat found: Default parameters loaded for " + "Analysis " + << FileName << endl; + return; + } + cout << " Loading user parameters for Analysis from ConfigIss.dat " << endl; + + // Save it in a TAsciiFile + TAsciiFile* asciiConfig + = RootOutput::getInstance()->GetAsciiFileAnalysisConfig(); + asciiConfig->AppendLine("%%% ConfigIss.dat %%%"); + asciiConfig->Append(FileName.c_str()); + asciiConfig->AppendLine(""); + // read analysis config file + string LineBuffer, DataBuffer, whatToDo; + while (!AnalysisConfigFile.eof()) { + // Pick-up next line + getline(AnalysisConfigFile, LineBuffer); + + // search for "header" + if (LineBuffer.compare(0, 11, "ConfigIss") == 0) + ReadingStatus = true; + + // loop on tokens and data + while (ReadingStatus) { + + whatToDo = ""; + AnalysisConfigFile >> whatToDo; + + // Search for comment symbol (%) + if (whatToDo.compare(0, 1, "%") == 0) { + AnalysisConfigFile.ignore(numeric_limits<streamsize>::max(), '\n'); + } + + else if (whatToDo == "MAX_STRIP_MULTIPLICITY") { + AnalysisConfigFile >> DataBuffer; + m_MaximumStripMultiplicityAllowed = atoi(DataBuffer.c_str()); + cout << "MAXIMUN STRIP MULTIPLICITY " + << m_MaximumStripMultiplicityAllowed << endl; + } + + else if (whatToDo == "STRIP_ENERGY_MATCHING_SIGMA") { + AnalysisConfigFile >> DataBuffer; + m_StripEnergyMatchingSigma = atof(DataBuffer.c_str()); + cout << "STRIP ENERGY MATCHING SIGMA " << m_StripEnergyMatchingSigma + << endl; + } + + else if (whatToDo == "STRIP_ENERGY_MATCHING_NUMBER_OF_SIGMA") { + AnalysisConfigFile >> DataBuffer; + m_StripEnergyMatchingNumberOfSigma = atoi(DataBuffer.c_str()); + cout << "STRIP ENERGY MATCHING NUMBER OF SIGMA " + << m_StripEnergyMatchingNumberOfSigma << endl; + } + + else if (whatToDo == "DISABLE_ALL") { + AnalysisConfigFile >> DataBuffer; + cout << whatToDo << " " << DataBuffer << endl; + int telescope = atoi(DataBuffer.substr(2, 1).c_str()); + vector<bool> ChannelStatus; + ChannelStatus.resize(128, false); + m_XChannelStatus[telescope - 1] = ChannelStatus; + m_YChannelStatus[telescope - 1] = ChannelStatus; + ChannelStatus.resize(16, false); + m_SiLiChannelStatus[telescope - 1] = ChannelStatus; + m_CsIChannelStatus[telescope - 1] = ChannelStatus; + } + + else if (whatToDo == "DISABLE_CHANNEL") { + AnalysisConfigFile >> DataBuffer; + cout << whatToDo << " " << DataBuffer << endl; + int telescope = atoi(DataBuffer.substr(2, 1).c_str()); + int channel = -1; + if (DataBuffer.compare(3, 4, "STRX") == 0) { + channel = atoi(DataBuffer.substr(7).c_str()); + *(m_XChannelStatus[telescope - 1].begin() + channel - 1) = false; + } + + else if (DataBuffer.compare(3, 4, "STRY") == 0) { + channel = atoi(DataBuffer.substr(7).c_str()); + *(m_YChannelStatus[telescope - 1].begin() + channel - 1) = false; + } + + + else + cout << "Warning: detector type for Iss unknown!" << endl; + + } + + else if (whatToDo == "TAKE_E_Y") { + m_Take_E_Y = true; + cout << whatToDo << endl; + } + + else if (whatToDo == "TAKE_T_Y") { + m_Take_T_Y = true; + cout << whatToDo << endl; + } + + else if (whatToDo == "TAKE_E_X") { + m_Take_E_Y = false; + cout << whatToDo << endl; + } + + else if (whatToDo == "TAKE_T_X") { + m_Take_T_Y = false; + cout << whatToDo << endl; + } + + else if (whatToDo == "IGNORE_NOT_MATCHING_CSI") { + m_Ignore_not_matching_CsI = true; + cout << whatToDo << endl; + } + + + else if (whatToDo == "SI_X_E_RAW_THRESHOLD") { + AnalysisConfigFile >> DataBuffer; + m_Si_X_E_RAW_Threshold = atof(DataBuffer.c_str()); + cout << whatToDo << " " << m_Si_X_E_RAW_Threshold << endl; + } + + else if (whatToDo == "SI_Y_E_RAW_THRESHOLD") { + AnalysisConfigFile >> DataBuffer; + m_Si_Y_E_RAW_Threshold = atof(DataBuffer.c_str()); + cout << whatToDo << " " << m_Si_Y_E_RAW_Threshold << endl; + } + + + else if (whatToDo == "SI_X_E_THRESHOLD") { + AnalysisConfigFile >> DataBuffer; + m_Si_X_E_Threshold = atof(DataBuffer.c_str()); + cout << whatToDo << " " << m_Si_X_E_Threshold << endl; + } + + else if (whatToDo == "SI_Y_E_THRESHOLD") { + AnalysisConfigFile >> DataBuffer; + m_Si_Y_E_Threshold = atof(DataBuffer.c_str()); + cout << whatToDo << " " << m_Si_Y_E_Threshold << endl; + } + + + else { + ReadingStatus = false; + } + } + } + } + + /////////////////////////////////////////////////////////////////////////// + bool TIssPhysics::Match_Si_SiLi(int X, int Y, int PadNbr) { + + // remove the central part and surrounding + if (X < 8 || X > 120 || (Y < 68 && Y > 60)) + return false; + + if (abs(m_SiLi_MatchingX[PadNbr - 1] - X) < m_SiLi_Size / 2. + && abs(m_SiLi_MatchingY[PadNbr - 1] - Y) < m_SiLi_Size / 2.) + return true; + + else + return false; + } + + /////////////////////////////////////////////////////////////////////////// + bool TIssPhysics::Match_Si_CsI(int X, int Y, int CristalNbr) { + + if (abs(m_CsI_MatchingX[CristalNbr - 1] - X) < (double)m_CsI_Size / 2. + && abs(m_CsI_MatchingY[CristalNbr - 1] - Y) < (double)m_CsI_Size / 2.) { + return true; + } + + else + return false; + } + + /////////////////////////////////////////////////////////////////////////// + void TIssPhysics::Clear() { + EventMultiplicity = 0; + + m_match_type.clear(); + + m_StripXMultDet.clear(); + m_StripYMultDet.clear(); + m_NMatchDet.clear(); + + TelescopeNumber.clear(); + EventType.clear(); + TotalEnergy.clear(); + + // Si X + Si_E.clear(); + Si_T.clear(); + Si_X.clear(); + Si_Y.clear(); + + + Si_EX.clear(); + Si_TX.clear(); + Si_EY.clear(); + Si_TY.clear(); + TelescopeNumber_X.clear(); + TelescopeNumber_Y.clear(); + } + /////////////////////////////////////////////////////////////////////////// + + void TIssPhysics::ReadCalibrationRun() { + m_StripXEMult = m_EventData->GetMMStripXEMult(); + m_StripYEMult = m_EventData->GetMMStripYEMult(); + m_StripXTMult = m_EventData->GetMMStripXTMult(); + m_StripYTMult = m_EventData->GetMMStripYTMult(); + + + // X + // E + for (unsigned int i = 0; i < m_StripXEMult; ++i) { + TelescopeNumber_X.push_back(m_EventData->GetMMStripXEDetectorNbr(i)); + Si_EX.push_back(fSi_X_E(m_EventData, i)); + Si_X.push_back(m_EventData->GetMMStripXEStripNbr(i)); + } + // T + for (unsigned int i = 0; i < m_StripXTMult; ++i) { + TelescopeNumber_X.push_back(m_EventData->GetMMStripXTDetectorNbr(i)); + Si_TX.push_back(fSi_X_T(m_EventData, i)); + Si_X.push_back(m_EventData->GetMMStripXTStripNbr(i)); + } + + // Y + // E + for (unsigned int i = 0; i < m_StripYEMult; ++i) { + TelescopeNumber_Y.push_back(m_EventData->GetMMStripYEDetectorNbr(i)); + Si_EY.push_back(fSi_Y_E(m_EventData, i)); + Si_Y.push_back(m_EventData->GetMMStripYEStripNbr(i)); + } + + // T + for (unsigned int i = 0; i < m_StripYTMult; ++i) { + TelescopeNumber_Y.push_back(m_EventData->GetMMStripYTDetectorNbr(i)); + Si_TY.push_back(fSi_Y_T(m_EventData, i)); + Si_Y.push_back(m_EventData->GetMMStripYTStripNbr(i)); + } + } + + + //// Innherited from VDetector Class //// + + /////////////////////////////////////////////////////////////////////////// + void TIssPhysics::ReadConfiguration(NPL::InputParser parser) { + vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithToken("ISSDet"); + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks.size() << " Detector found " << endl; + + // Cartesian Case + vector<string> cart + = {"X1_Y1", "X1_Y128", "X128_Y1", "X128_Y128", "SI"}; + // Spherical Case + vector<string> sphe = {"R", "THETA", "PHI", "BETA", "SI"}; + + for (unsigned int i = 0; i < blocks.size(); i++) { + if (blocks[i]->HasTokenList(cart)) { + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// Iss Telescope " << i + 1 << endl; + TVector3 A = blocks[i]->GetTVector3("X1_Y1", "mm"); + TVector3 B = blocks[i]->GetTVector3("X128_Y1", "mm"); + TVector3 C = blocks[i]->GetTVector3("X1_Y128", "mm"); + TVector3 D = blocks[i]->GetTVector3("X128_Y128", "mm"); + AddTelescope(A, B, C, D); + } + + else if (blocks[i]->HasTokenList(sphe)) { + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// Iss Telescope " << i + 1 << endl; + + double Theta = blocks[i]->GetDouble("THETA", "deg"); + double Phi = blocks[i]->GetDouble("PHI", "deg"); + double R = blocks[i]->GetDouble("R", "mm"); + vector<double> beta = blocks[i]->GetVectorDouble("BETA", "deg"); + AddTelescope(Theta, Phi, R, beta[0], beta[1], beta[2]); + + } + + else { + cout << "ERROR: Missing token for M2Telescope blocks, check your " + "input " + "file" + << endl; + exit(1); + } + } + + // m_MultEvt = new TIssMultTelescope[m_NumberOfTelescope]; + + InitializeStandardParameter(); + ReadAnalysisConfig(); + } + ////////////////////////////////////////////////////////////////////////// + void TIssPhysics::InitSpectra() { + m_Spectra = new TIssSpectra(m_NumberOfTelescope); + } + + /////////////////////////////////////////////////////////////////////////// + void TIssPhysics::FillSpectra() { + m_Spectra->FillRawSpectra(m_EventData); + m_Spectra->FillPreTreatedSpectra(m_PreTreatedData); + m_Spectra->FillPhysicsSpectra(m_EventPhysics); + } + /////////////////////////////////////////////////////////////////////////// + void TIssPhysics::CheckSpectra() { m_Spectra->CheckSpectra(); } + /////////////////////////////////////////////////////////////////////////// + void TIssPhysics::ClearSpectra() { + // To be done + } + + /////////////////////////////////////////////////////////////////////////// + void TIssPhysics::WriteSpectra() { + if (m_Spectra) + m_Spectra->WriteSpectra(); + } + + /////////////////////////////////////////////////////////////////////////// + map<string, TH1*> TIssPhysics::GetSpectra() { + if (m_Spectra) + return m_Spectra->GetMapHisto(); + else { + map<string, TH1*> empty; + return empty; + } + } + + /////////////////////////////////////////////////////////////////////////// + void TIssPhysics::AddParameterToCalibrationManager() { + CalibrationManager* Cal = CalibrationManager::getInstance(); + // Good for simulation, close to typical values + vector<double> standardX = {-63, 63. / 8192.}; + vector<double> standardY = {63, -63. / 8192.}; + vector<double> standardT = {-1000, 1000. / 8192.}; + + for (int i = 0; i < m_NumberOfTelescope; ++i) { + + for (int j = 0; j < 128; ++j) { + Cal->AddParameter( + "Iss", "T" + NPL::itoa(i + 1) + "_Si_X" + NPL::itoa(j + 1) + "_E", + "Iss_T" + NPL::itoa(i + 1) + "_Si_X" + NPL::itoa(j + 1) + "_E", + standardX); + Cal->AddParameter( + "Iss", "T" + NPL::itoa(i + 1) + "_Si_Y" + NPL::itoa(j + 1) + "_E", + "Iss_T" + NPL::itoa(i + 1) + "_Si_Y" + NPL::itoa(j + 1) + "_E", + standardY); + Cal->AddParameter( + "Iss", "T" + NPL::itoa(i + 1) + "_Si_X" + NPL::itoa(j + 1) + "_T", + "Iss_T" + NPL::itoa(i + 1) + "_Si_X" + NPL::itoa(j + 1) + "_T", + standardT); + Cal->AddParameter( + "Iss", "T" + NPL::itoa(i + 1) + "_Si_Y" + NPL::itoa(j + 1) + "_T", + "Iss_T" + NPL::itoa(i + 1) + "_Si_Y" + NPL::itoa(j + 1) + "_T", + standardT); + } + + } + + return; + } + + /////////////////////////////////////////////////////////////////////////// + void TIssPhysics::InitializeRootInputRaw() { + TChain* inputChain = RootInput::getInstance()->GetChain(); + inputChain->SetBranchStatus("ISS", true); + inputChain->SetBranchStatus("fMM_*", true); + inputChain->SetBranchAddress("ISS", &m_EventData); + } + + /////////////////////////////////////////////////////////////////////////// + void TIssPhysics::InitializeRootInputPhysics() { + TChain* inputChain = RootInput::getInstance()->GetChain(); + inputChain->SetBranchStatus("ISS", true); + inputChain->SetBranchStatus("EventMultiplicity", true); + inputChain->SetBranchStatus("EventType", true); + inputChain->SetBranchStatus("DetNumber", true); + inputChain->SetBranchStatus("Si_E", true); + inputChain->SetBranchStatus("Si_T", true); + inputChain->SetBranchStatus("Si_X", true); + inputChain->SetBranchStatus("Si_Y", true); + inputChain->SetBranchStatus("Si_EX", true); + inputChain->SetBranchStatus("Si_TX", true); + inputChain->SetBranchStatus("Si_EY", true); + inputChain->SetBranchStatus("Si_TY", true); + inputChain->SetBranchStatus("DetNumber_X", true); + inputChain->SetBranchStatus("DetNumber_Y", true); + inputChain->SetBranchStatus("TotalEnergy", true); + inputChain->SetBranchAddress("ISS", &m_EventPhysics); + } + + /////////////////////////////////////////////////////////////////////////// + void TIssPhysics::InitializeRootOutput() { + TTree* outputTree = RootOutput::getInstance()->GetTree(); + outputTree->Branch("ISS", "TIssPhysics", &m_EventPhysics); + } + + ///// Specific to IssArray //// + + void TIssPhysics::AddTelescope(TVector3 C_X1_Y1, TVector3 C_X128_Y1, + TVector3 C_X1_Y128, TVector3 C_X128_Y128) { + // To avoid warning + C_X128_Y128 *= 1; + + m_NumberOfTelescope++; + + // Vector U on Telescope Face (paralelle to Y Strip) (NB: remember that + // Y strip are allong X axis) + TVector3 U = C_X128_Y1 - C_X1_Y1; + double Ushift = (U.Mag() - 98) / 2.; + U = U.Unit(); + // Vector V on Telescope Face (parallele to X Strip) + TVector3 V = C_X1_Y128 - C_X1_Y1; + double Vshift = (V.Mag() - 98) / 2.; + V = V.Unit(); + + // Position Vector of Strip Center + TVector3 StripCenter = TVector3(0, 0, 0); + // Position Vector of X=1 Y=1 Strip + TVector3 Strip_1_1; + + // Geometry Parameter + double Face = 98; // mm + double NumberOfStrip = 128; + double StripPitch = Face / NumberOfStrip; // mm + // Buffer object to fill Position Array + vector<double> lineX; + vector<double> lineY; + vector<double> lineZ; + + vector<vector<double>> OneTelescopeStripPositionX; + vector<vector<double>> OneTelescopeStripPositionY; + vector<vector<double>> OneTelescopeStripPositionZ; + + // Moving StripCenter to 1.1 corner: + Strip_1_1 = C_X1_Y1 + (U + V) * (StripPitch / 2.); + Strip_1_1 += U * Ushift + V * Vshift; + + for (int i = 0; i < 128; ++i) { + lineX.clear(); + lineY.clear(); + lineZ.clear(); + + for (int j = 0; j < 128; ++j) { + StripCenter = Strip_1_1 + StripPitch * (i * U + j * V); + lineX.push_back(StripCenter.X()); + lineY.push_back(StripCenter.Y()); + lineZ.push_back(StripCenter.Z()); + } + + OneTelescopeStripPositionX.push_back(lineX); + OneTelescopeStripPositionY.push_back(lineY); + OneTelescopeStripPositionZ.push_back(lineZ); + } + m_StripPositionX.push_back(OneTelescopeStripPositionX); + m_StripPositionY.push_back(OneTelescopeStripPositionY); + m_StripPositionZ.push_back(OneTelescopeStripPositionZ); + } + + void TIssPhysics::InitializeStandardParameter() { + // Enable all channel + vector<bool> ChannelStatus; + m_XChannelStatus.clear(); + m_YChannelStatus.clear(); + + + ChannelStatus.resize(128, true); + for (int i = 0; i < m_NumberOfTelescope; ++i) { + m_XChannelStatus[i] = ChannelStatus; + m_YChannelStatus[i] = ChannelStatus; + } + + + m_MaximumStripMultiplicityAllowed = m_NumberOfTelescope; + + return; + } + + void TIssPhysics::AddTelescope(double theta, double phi, double distance, + double beta_u, double beta_v, double beta_w) { + + m_NumberOfTelescope++; + + double Pi = 3.141592654; + + // convert from degree to radian: + theta = theta * Pi / 180.; + phi = phi * Pi / 180.; + + // Vector U on Telescope Face (paralelle to Y Strip) (NB: remember that Y + // strip are allong X axis) + TVector3 U; + // Vector V on Telescope Face (parallele to X Strip) + TVector3 V; + // Vector W normal to Telescope Face (pointing CsI) + TVector3 W; + // Vector position of Telescope Face center + TVector3 C; + + C = TVector3(distance * sin(theta) * cos(phi), + distance * sin(theta) * sin(phi), distance * cos(theta)); + + TVector3 P + = TVector3(cos(theta) * cos(phi), cos(theta) * sin(phi), -sin(theta)); + + W = C.Unit(); + U = W.Cross(P); + V = W.Cross(U); + + U = U.Unit(); + V = V.Unit(); + + U.Rotate(beta_u * Pi / 180., U); + V.Rotate(beta_u * Pi / 180., U); + + U.Rotate(beta_v * Pi / 180., V); + V.Rotate(beta_v * Pi / 180., V); + + U.Rotate(beta_w * Pi / 180., W); + V.Rotate(beta_w * Pi / 180., W); + + double Face = 98; // mm + double NumberOfStrip = 128; + double StripPitch = Face / NumberOfStrip; // mm + + vector<double> lineX; + vector<double> lineY; + vector<double> lineZ; + + vector<vector<double>> OneTelescopeStripPositionX; + vector<vector<double>> OneTelescopeStripPositionY; + vector<vector<double>> OneTelescopeStripPositionZ; + + double X, Y, Z; + + // Moving C to the 1.1 corner: + C.SetX(C.X() - (Face / 2 - StripPitch / 2) * (V.X() + U.X())); + C.SetY(C.Y() - (Face / 2 - StripPitch / 2) * (V.Y() + U.Y())); + C.SetZ(C.Z() - (Face / 2 - StripPitch / 2) * (V.Z() + U.Z())); + + for (int i = 0; i < 128; ++i) { + + lineX.clear(); + lineY.clear(); + lineZ.clear(); + + for (int j = 0; j < 128; ++j) { + X = C.X() + StripPitch * (U.X() * i + V.X() * j); + Y = C.Y() + StripPitch * (U.Y() * i + V.Y() * j); + Z = C.Z() + StripPitch * (U.Z() * i + V.Z() * j); + + lineX.push_back(X); + lineY.push_back(Y); + lineZ.push_back(Z); + } + + OneTelescopeStripPositionX.push_back(lineX); + OneTelescopeStripPositionY.push_back(lineY); + OneTelescopeStripPositionZ.push_back(lineZ); + } + m_StripPositionX.push_back(OneTelescopeStripPositionX); + m_StripPositionY.push_back(OneTelescopeStripPositionY); + m_StripPositionZ.push_back(OneTelescopeStripPositionZ); + } + + TVector3 TIssPhysics::GetPositionOfInteraction(const int i) const { + TVector3 Position + = TVector3(GetStripPositionX(TelescopeNumber[i], Si_X[i], Si_Y[i]), + GetStripPositionY(TelescopeNumber[i], Si_X[i], Si_Y[i]), + GetStripPositionZ(TelescopeNumber[i], Si_X[i], Si_Y[i])); + + return (Position); + } + + TVector3 TIssPhysics::GetTelescopeNormal(const int i) const { + TVector3 U = TVector3(GetStripPositionX(TelescopeNumber[i], 128, 1), + GetStripPositionY(TelescopeNumber[i], 128, 1), + GetStripPositionZ(TelescopeNumber[i], 128, 1)) + + - TVector3(GetStripPositionX(TelescopeNumber[i], 1, 1), + GetStripPositionY(TelescopeNumber[i], 1, 1), + GetStripPositionZ(TelescopeNumber[i], 1, 1)); + + TVector3 V = TVector3(GetStripPositionX(TelescopeNumber[i], 128, 128), + GetStripPositionY(TelescopeNumber[i], 128, 128), + GetStripPositionZ(TelescopeNumber[i], 128, 128)) + + - TVector3(GetStripPositionX(TelescopeNumber[i], 128, 1), + GetStripPositionY(TelescopeNumber[i], 128, 1), + GetStripPositionZ(TelescopeNumber[i], 128, 1)); + + TVector3 Normal = U.Cross(V); + + return (Normal.Unit()); + } + + /////////////////////////////////////////////////////////////////////////// + namespace ISS_LOCAL { + // DSSD + // X + double fSi_X_E(const TIssData* m_EventData, const int& i) { + static string name; + name = "ISS/T"; + name += NPL::itoa(m_EventData->GetMMStripXEDetectorNbr(i)); + name += "_Si_X"; + name += NPL::itoa(m_EventData->GetMMStripXEStripNbr(i)); + name += "_E"; + return CalibrationManager::getInstance()->ApplyCalibration( + name, m_EventData->GetMMStripXEEnergy(i)); + } + + double fSi_X_T(const TIssData* m_EventData, const int& i) { + static string name; + name = "ISS/T"; + name += NPL::itoa(m_EventData->GetMMStripXTDetectorNbr(i)); + name += "_Si_X"; + name += NPL::itoa(m_EventData->GetMMStripXTStripNbr(i)); + name += "_T"; + return CalibrationManager::getInstance()->ApplyCalibration( + name, m_EventData->GetMMStripXTTime(i)); + } + + // Y + double fSi_Y_E(const TIssData* m_EventData, const int& i) { + static string name; + name = "ISS/T"; + name += NPL::itoa(m_EventData->GetMMStripYEDetectorNbr(i)); + name += "_Si_Y"; + name += NPL::itoa(m_EventData->GetMMStripYEStripNbr(i)); + name += "_E"; + return CalibrationManager::getInstance()->ApplyCalibration( + name, m_EventData->GetMMStripYEEnergy(i)); + } + + double fSi_Y_T(const TIssData* m_EventData, const int& i) { + static string name; + name = "ISS/T"; + name += NPL::itoa(m_EventData->GetMMStripYTDetectorNbr(i)); + name += "_Si_Y"; + name += NPL::itoa(m_EventData->GetMMStripYTStripNbr(i)); + name += "_T"; + return CalibrationManager::getInstance()->ApplyCalibration( + name, m_EventData->GetMMStripYTTime(i)); + } + + } // namespace ISS_LOCAL + + //////////////////////////////////////////////////////////////////////////////// + // Construct Method to be pass to the DetectorFactory // + //////////////////////////////////////////////////////////////////////////////// + NPL::VDetector* TIssPhysics::Construct() { + return (NPL::VDetector*)new TIssPhysics(); + } + + //////////////////////////////////////////////////////////////////////////////// + // Registering the construct method to the factory // + //////////////////////////////////////////////////////////////////////////////// + extern "C" { + class proxy_iss { + public: + proxy_iss() { + NPL::DetectorFactory::getInstance()->AddToken("ISSDet", "ISS"); + NPL::DetectorFactory::getInstance()->AddDetector("ISSDet", + TIssPhysics::Construct); + } + }; + + proxy_iss p_iss; + } + */ diff --git a/NPLib/Detectors/Iss/TIssPhysics.h b/NPLib/Detectors/Iss/TIssPhysics.h new file mode 100644 index 0000000000000000000000000000000000000000..0b055b5ede2fe4603fbb993a921ed5ff9d55f6ad --- /dev/null +++ b/NPLib/Detectors/Iss/TIssPhysics.h @@ -0,0 +1,533 @@ +#ifndef TISSPHYSICS_H +#define TISSPHYSICS_H +/***************************************************************************** + * Copyright (C) 2009-2019 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: a.matta@surrey.ac.uk * + * Author: M. Labiche address: marc.labiche@stfc.ac.uk * + * * + * Creation Date : july 2019 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class hold Iss treated data * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + * * + *****************************************************************************/ +// STL +#include <map> +#include <vector> +// NPL +#include "NPCalibrationManager.h" +#include "NPInputParser.h" +#include "NPVDetector.h" +#include "TIssData.h" +#include "TIssSpectra.h" + +// ROOT +#include "TH1.h" +#include "TObject.h" +#include "TVector2.h" +#include "TVector3.h" +#include "TRandom3.h" + +using namespace std; + +// Forward Declaration +class TIssSpectra; + +class TIssPhysics : public TObject, public NPL::VDetector { +public: + TIssPhysics(); + ~TIssPhysics(); + +public: + void Clear(); + void Clear(const Option_t*){}; + +public: + vector < TVector2 > Match_Front_Back() ; + int CheckEvent(); + +/* from MUST2 + vector<TVector2> Match_X_Y(); + int CheckEvent(int N); + bool Match_Si_CsI(int X, int Y, int CristalNbr); + bool Match_Si_SiLi(int X, int Y, int PadNbr); + bool ResolvePseudoEvent(); +*/ +public: + // Provide Physical Multiplicity + // Int_t EventMultiplicity; + int EventMultiplicity; + + // Provide a Classification of Event + vector<int> EventType; + + // Detector + vector<int> DetectorNumber ; + + // DSSD + vector<double> Strip_E ; + vector<double> Strip_T ; + vector<double> StripFront_E ; + vector<double> StripFront_T ; + vector<double> StripBack_E ; + vector<double> StripBack_T ; + vector<int> Strip_Front ; + vector<int> Strip_Back ; + + // Used to apply Pixel Cal + vector<double> StripFront_OriginalE; //! + vector<double> StripBack_OriginalE; //! + vector<double> DeadLayer; //! + // Used for Calibration + vector<double> Strip_Front_RawE; + vector<double> Strip_Back_RawE; + + +/* from MUST2 + // Telescope + vector<int> TelescopeNumber; + + // Si + vector<double> Si_E; + vector<double> Si_T; + vector<int> Si_X; + vector<int> Si_Y; + + // Use for checking purpose + vector<double> Si_EX; + vector<double> Si_TX; + vector<double> Si_EY; + vector<double> Si_TY; + vector<int> TelescopeNumber_X; + vector<int> TelescopeNumber_Y; + + + // Physical Value + vector<double> TotalEnergy; +*/ + + +public: // Innherited from VDetector Class + + // Read stream at ConfigFile to pick-up parameters of detector (Position,...) using Token + void ReadConfiguration(NPL::InputParser) ; + + + // Add Parameter to the CalibrationManger + void AddParameterToCalibrationManager() ; + + // Activated associated Branches and link it to the private member DetectorData address + // In this method mother Branches (Detector) AND daughter leaf (fDetector_parameter) have to be activated + void InitializeRootInputRaw() ; + + // Activated associated Branches and link it to the private member DetectorPhysics address + // In this method mother Branches (Detector) AND daughter leaf (parameter) have to be activated + void InitializeRootInputPhysics() ; + + // Create associated branches and associated private member DetectorPhysics address + void InitializeRootOutput() ; + + // This method is called at each event read from the Input Tree. Aime is to build treat Raw dat in order to extract physical parameter. + void BuildPhysicalEvent() ; + + // Same as above, but only the simplest event and/or simple method are used (low multiplicity, faster algorythm but less efficient ...). + // This method aimed to be used for analysis performed during experiment, when speed is requiered. + // NB: This method can eventually be the same as BuildPhysicalEvent. + void BuildSimplePhysicalEvent() ; + + // Same as above but for online analysis + void BuildOnlinePhysicalEvent() {BuildPhysicalEvent();} + + // Those two method all to clear the Event Physics or Data + void ClearEventPhysics() {Clear();} + void ClearEventData() {m_EventData->Clear();} + + // Method related to the TSpectra classes, aimed at providing a framework for online applications + // Instantiate the Spectra class and the histogramm throught it + void InitSpectra(); + // Fill the spectra hold by the spectra class + void FillSpectra(); + // Used for Online mainly, perform check on the histo and for example change their color if issues are found + void CheckSpectra(); + // Used for Online only, clear all the spectra hold by the Spectra class + void ClearSpectra(); + // Write Spectra to file + void WriteSpectra(); + + + +/* from MUST2 + + // Read stream at ConfigFile to pick-up parameters of detector + // (Position,...) using Token + void ReadConfiguration(NPL::InputParser parser); + + // Add Parameter to the CalibrationManger + void AddParameterToCalibrationManager(); + + // Activated associated Branches and link it to the private member + // DetectorData address + // In this method mother Branches (Detector) AND daughter leaf + // (fDetector_parameter) have to be activated + void InitializeRootInputRaw(); + + // Activated associated Branches and link it to the private member + // DetectorPhysics address + // In this method mother Branches (Detector) AND daughter leaf (parameter) + // have to be activated + void InitializeRootInputPhysics(); + + // Create associated branches and associated private member DetectorPhysics + // address + void InitializeRootOutput(); + + // This method is called at each event read from the Input Tree. Aime is to + // build treat Raw dat in order to extract physical parameter. + void BuildPhysicalEvent(); + + // Same as above, but only the simplest event and/or simple method are used + // (low multiplicity, faster algorythm but less efficient ...). + // This method aimed to be used for analysis performed during experiment, + // when speed is requiered. + // NB: This method can eventually be the same as BuildPhysicalEvent. + void BuildSimplePhysicalEvent(); + + // Same as above but for online analysis + void BuildOnlinePhysicalEvent() { BuildPhysicalEvent(); }; + + // Those two method all to clear the Event Physics or Data + void ClearEventPhysics() { Clear(); } + void ClearEventData() { m_EventData->Clear(); } + + // Method related to the TSpectra classes, aimed at providing a framework for + // online applications + // Instantiate the Spectra class and the histogramm throught it + void InitSpectra(); + // Fill the spectra hold by the spectra class + void FillSpectra(); + // Used for Online mainly, perform check on the histo and for example change + // their color if issues are found + void CheckSpectra(); + // Used for Online only, clear all the spectra hold by the Spectra class + void ClearSpectra(); +*/ + + +public: // Specific to Iss Array + + // Clear The PreTeated object + void ClearPreTreatedData() {m_PreTreatedData->Clear();} + + // Remove bad channel, calibrate the data and apply threshold + void PreTreat(); + + // Return false if the channel is disabled by user + // Frist argument is either "X","Y","SiLi","CsI" + bool IsValidChannel(const string& DetectorType, const int& telescope , const int& channel); + + // Initialize the standard parameter for analysis + // ie: all channel enable, maximum multiplicity for strip = number of telescope + void InitializeStandardParameter(); + + // Read the user configuration file; if no file found, load standard one + void ReadAnalysisConfig(); + + + // Add a Detector + void AddBoxDetector( double Z); +// void AddQQQDetector( double R,double Phi,double Z); + // Add a Telescope using Corner Coordinate information + void AddTelescope(TVector3 C_X1_Y1, TVector3 C_X128_Y1, TVector3 C_X1_Y128, TVector3 C_X128_Y128); + + // Add a Telescope using R Theta Phi of Si center information + void AddTelescope(double theta, double phi, double distance, double beta_u, double beta_v, double beta_w); + + double GetNominalMField() { return m_NominalField; } + + + // Give and external TMustData object to TSharcPhysics. Needed for online analysis for example. + void SetRawDataPointer(TIssData* rawDataPointer) {m_EventData = rawDataPointer;} + // Retrieve raw and pre-treated data + TIssData* GetRawData() const {return m_EventData;} + TIssData* GetPreTreatedData() const {return m_PreTreatedData;} + + // Use to access the strip position + inline double GetStripPositionX( const int& N , const int& Front , const int& Back ) const{ return m_StripPositionX[N-1][Front-1][Back-1] ; } ; + inline double GetStripPositionY( const int& N , const int& Front , const int& Back ) const{ return m_StripPositionY[N-1][Front-1][Back-1] ; } ; + inline double GetStripPositionZ( const int& N , const int& Front , const int& Back ) const{ return m_StripPositionZ[N-1][Front-1][Back-1] ; } ; + + inline double GetNumberOfDetector() const { return m_NumberOfDetector; }; + + // To be called after a build Physical Event + inline int GetEventMultiplicity() const { return EventMultiplicity; }; + + TVector3 GetPositionOfInteraction(const int& i, bool random=false) const; + TVector3 GetDetectorNormal(const int& i) const; + double GetDeadLayer(const int& i) const; + + + +/*from MUST2 + + // Clear The PreTeated object + void ClearPreTreatedData() { m_PreTreatedData->Clear(); } + + // Remove bad channel, calibrate the data and apply threshold + void PreTreat(); + + // Return false if the channel is disabled by user + // Frist argument is either 0 for X,1 Y,2 SiLi, 3 CsI + bool IsValidChannel(const int& DetectorType, const int& telescope, + const int& channel); + + // Initialize the standard parameter for analysis + // ie: all channel enable, maximum multiplicity for strip = number of + // telescope + void InitializeStandardParameter(); + + // Read the user configuration file; if no file found, load standard one + void ReadAnalysisConfig(); + + // Add a Telescope using Corner Coordinate information + void AddTelescope(TVector3 C_X1_Y1, TVector3 C_X128_Y1, TVector3 C_X1_Y128, + TVector3 C_X128_Y128); + + // Add a Telescope using R Theta Phi of Si center information + void AddTelescope(double theta, double phi, double distance, double beta_u, + double beta_v, double beta_w); + + // Use for reading Calibration Run, very simple methods; only apply + // calibration, no condition + void ReadCalibrationRun(); + + // Give and external TMustData object to TIssPhysics. Needed for online + // analysis for example. + void SetRawDataPointer(void* rawDataPointer) { + m_EventData = (TIssData*)rawDataPointer; + } + // Retrieve raw and pre-treated data + TIssData* GetRawData() const { return m_EventData; } + TIssData* GetPreTreatedData() const { return m_PreTreatedData; } + + // Use to access the strip position + double GetStripPositionX(const int N, const int X, const int Y) const { + return m_StripPositionX[N - 1][X - 1][Y - 1]; + }; + double GetStripPositionY(const int N, const int X, const int Y) const { + return m_StripPositionY[N - 1][X - 1][Y - 1]; + }; + double GetStripPositionZ(const int N, const int X, const int Y) const { + return m_StripPositionZ[N - 1][X - 1][Y - 1]; + }; + + double GetNumberOfTelescope() const { return m_NumberOfTelescope; }; + + // To be called after a build Physical Event + int GetEventMultiplicity() const { return EventMultiplicity; }; + + double GetEnergyDeposit(const int i) const { return TotalEnergy[i]; }; + + TVector3 GetPositionOfInteraction(const int i) const; + TVector3 GetTelescopeNormal(const int i) const; + + +*/ + + +private: // Parameter used in the analysis + + // By default take EX and TY. + bool m_Take_E_Front;//! + bool m_Take_T_Back;//! + + // Event over this value after pre-treatment are not treated / avoid long treatment time on spurious event + unsigned int m_MaximumStripMultiplicityAllowed ;//! + // Give the allowance in percent of the difference in energy between X and Y + double m_StripEnergyMatchingSigma ; //! + double m_StripEnergyMatchingNumberOfSigma ; //! + + // Threshold + double m_StripFront_E_RAW_Threshold ;//! + double m_StripFront_E_Threshold ;//! + double m_StripBack_E_RAW_Threshold ;//! + double m_StripBack_E_Threshold ;//! + + + + +/*from MUST2 + + // By default take EX and TY. + bool m_Take_E_Y; //! + bool m_Take_T_Y; //! + + // Size Container to be used in the different loop of the analysis (value must + // be given locally) + unsigned int m_StripXEMult; //! + unsigned int m_StripYEMult; //! + unsigned int m_StripXTMult; //! + unsigned int m_StripYTMult; //! + unsigned int m_SiLiEMult; //! + unsigned int m_SiLiTMult; //! + unsigned int m_CsIEMult; //! + unsigned int m_CsITMult; //! + + // Event over this value after pre-treatment are not treated / avoid long + // treatment time on spurious event + unsigned int m_MaximumStripMultiplicityAllowed; //! + // Give the allowance in percent of the difference in energy between X and Y + double m_StripEnergyMatchingSigma; //! + double m_StripEnergyMatchingNumberOfSigma; //! + + // Raw Threshold + int m_Si_X_E_RAW_Threshold; //! + int m_Si_Y_E_RAW_Threshold; //! + int m_SiLi_E_RAW_Threshold; //! + int m_CsI_E_RAW_Threshold; //! + + // Calibrated Threshold + double m_Si_X_E_Threshold; //! + double m_Si_Y_E_Threshold; //! + double m_SiLi_E_Threshold; //! + double m_CsI_E_Threshold; //! + + // Geometric Matching + // size in strip of a pad + int m_SiLi_Size; //! + // center position of the pad on X + vector<int> m_SiLi_MatchingX; //! + // center position of the pad on Y + vector<int> m_SiLi_MatchingY; //! + // size in strip of a cristal + int m_CsI_Size; //! + // center position of the cristal on X + vector<int> m_CsI_MatchingX; //! + // center position of the cristal on X + vector<int> m_CsI_MatchingY; //! + + // If set to true, all event that do not come in front of a cristal will be + // ignore all time (crossing or not), + // Warning, this option reduce statistic, however it help eliminating + // unrealevent event that cross the DSSD + // And go between pad or cristal. + bool m_Ignore_not_matching_SiLi; //! + bool m_Ignore_not_matching_CsI; //! + +*/ + + +private: // Root Input and Output tree classes + TIssData* m_EventData; //! + TIssData* m_PreTreatedData; //! + TIssPhysics* m_EventPhysics; //! + +private: // Map of activated channel + + map< int, vector<bool> > m_FrontChannelStatus;//! + map< int, vector<bool> > m_BackChannelStatus;//! + + +/* from MUST2 + map<int, vector<bool>> m_XChannelStatus; //! + map<int, vector<bool>> m_YChannelStatus; //! + map<int, vector<bool>> m_SiLiChannelStatus; //! + map<int, vector<bool>> m_CsIChannelStatus; //! +*/ + + + private: // Spatial Position of Strip Calculated on bases of detector position + + int m_NumberOfDetector;//! + vector< vector < vector < double > > > m_StripPositionX;//! + vector< vector < vector < double > > > m_StripPositionY;//! + vector< vector < vector < double > > > m_StripPositionZ;//! + vector< TVector3 > m_DetectorNormal;//! + vector< TVector3 > m_U;//! + vector< TVector3 > m_V;//! + TRandom3* m_Rand;//! + double m_BoxPitchBack ;//! + double m_BoxPitchFront;//! + + double m_NominalField; + + + +/* from MUST2 +private: + int m_NumberOfTelescope; //! + + vector<vector<vector<double>>> m_StripPositionX; //! + vector<vector<vector<double>>> m_StripPositionY; //! + vector<vector<vector<double>>> m_StripPositionZ; //! + + +public: + // Prevent to treat event with ambiguous matching beetween X and Y + bool m_multimatch; //! + vector<int> m_match_type; //! + map<int, int> m_NMatchDet; //! + map<int, int> m_StripXMultDet; //! + map<int, int> m_StripYMultDet; //! + +private: + map<int, bool> m_CsIPresent; //! + map<int, bool> m_SiLiPresent; //! +*/ + + +private: // Spectra Class + TIssSpectra* m_Spectra; //! + + +public: // Spectra Getter + map<string, TH1*> GetSpectra(); + +public: // Static constructor to be passed to the Detector Factory + static NPL::VDetector* Construct(); + ClassDef(TIssPhysics, 1) // IssPhysics structure +}; + +namespace ISS_LOCAL { +// DSSD + + // Front + double fStrip_Front_E(const TIssData* Data, const int& i); + double fStrip_Front_T(const TIssData* Data, const int& i); + + // Back + double fStrip_Back_E(const TIssData* Data, const int& i); + double fStrip_Back_T(const TIssData* Data, const int& i); + + +/* from MUST2 +// X +double fSi_X_E(const TIssData* Data, const int& i); +double fSi_X_T(const TIssData* Data, const int& i); + +// Y +double fSi_Y_E(const TIssData* Data, const int& i); +double fSi_Y_T(const TIssData* Data, const int& i); + +// SiLi +double fSiLi_E(const TIssData* Data, const int& i); +double fSiLi_T(const TIssData* Data, const int& i); + +// CsI +double fCsI_E(const TIssData* Data, const int& i); +double fCsI_T(const TIssData* Data, const int& i); +*/ +} // namespace ISS_LOCAL + +#endif diff --git a/NPLib/Detectors/Iss/TIssSpectra.cxx b/NPLib/Detectors/Iss/TIssSpectra.cxx new file mode 100644 index 0000000000000000000000000000000000000000..7815c207a29509f70c4b64cb2a0874b9ca890133 --- /dev/null +++ b/NPLib/Detectors/Iss/TIssSpectra.cxx @@ -0,0 +1,368 @@ +/***************************************************************************** + * Copyright (C) 2009-2019 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: a.matta@surrey.ac.uk * + * Author: M. Labiche address: marc.labiche@stfc.ac.uk * + * * + * Creation Date : July 2019 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class holds all the online spectra needed for Iss * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + *****************************************************************************/ + +// NPL +#include "TIssSpectra.h" +#include "NPOptionManager.h" +#include "NPGlobalSystemOfUnits.h" +#include "NPPhysicalConstants.h" +#ifdef NP_SYSTEM_OF_UNITS_H +using namespace NPUNITS; +#endif + +// STL +#include <stdexcept> +#include <iostream> +#include <cstdlib> +#include <string> +using namespace std; + + +//////////////////////////////////////////////////////////////////////////////// +TIssSpectra::TIssSpectra(){ + SetName("ISS"); + fNumberOfDetector = 0; + fStripFront=128; + fStripBack=22; +} + +//////////////////////////////////////////////////////////////////////////////// +TIssSpectra::TIssSpectra(unsigned int NumberOfDetector){ + if(NPOptionManager::getInstance()->GetVerboseLevel()>0) + cout << "************************************************" << endl + << "TIssSpectra : Initalising control spectra for " + << NumberOfDetector << " Detectors" << endl + << "************************************************" << endl ; + SetName("ISS"); + fNumberOfDetector = NumberOfDetector; + fStripFront=128; + fStripBack=22; + + InitRawSpectra(); + InitPreTreatedSpectra(); + InitPhysicsSpectra(); +} + +//////////////////////////////////////////////////////////////////////////////// +TIssSpectra::~TIssSpectra(){ +} + +//////////////////////////////////////////////////////////////////////////////// +void TIssSpectra::InitRawSpectra(){ + + static string name; + for (unsigned int i = 0; i < fNumberOfDetector; i++) { // loop on number of detectors + name = "ISSRaw"+NPL::itoa(i+1); + // STR_FRONT_E_RAW + name = "ISS"+NPL::itoa(i+1)+"_STR_FRONT_E_RAW"; + AddHisto2D(name, name, fStripFront, 1, fStripFront+1, 5000, 0, 1.5e6, "ISS/RAW/STR_FRONT_E")->Draw("colz"); + + // STR_BACK_E_RAW + name = "ISS"+NPL::itoa(i+1)+"_STR_BACK_E_RAW"; + AddHisto2D(name, name, fStripBack, 1, fStripBack+1, 5000, 0, 1.5e6, "ISS/RAW/STR_BACK_E")->Draw("colz"); + + // STR_FRONT_EMAX_RAW + name = "ISS"+NPL::itoa(i+1)+"_STR_FRONT_EMAX_RAW"; + AddHisto2D(name, name, fStripFront, 1, fStripFront+1, 5000, 0, 1.5e6, "ISS/RAW/STR_FRONT_EMAX"); + + // STR_BACK_EMAX_Raw + name = "ISS"+NPL::itoa(i+1)+"_STR_BACK_EMAX_RAW"; + AddHisto2D(name, name, fStripBack, 1, fStripBack+1, 5000, 0, 1.5e6, "ISS/RAW/STR_BACK_EMAX"); + + // PAD_E_RAW + name = "ISS"+NPL::itoa(i+1)+"_PAD_E_RAW"; + AddHisto1D(name, name, 500, 0, 2500, "ISS/RAW/PAD_E")->Draw(""); + + // STR_FRONT_RAW_MULT + name = "ISS"+NPL::itoa(i+1)+"_STR_FRONT_RAW_MULT"; + AddHisto1D(name, name, fStripFront, 1, fStripFront+1, "ISS/RAW/MULT")->Draw(""); + gPad->SetLogy(); + + // STR_BACK_RAW_MULT + name = "ISS"+NPL::itoa(i+1)+"_STR_BACK_RAW_MULT"; + AddHisto1D(name, name, fStripFront, 1, fStripFront+1, "ISS/RAW/MULT")->Draw(""); + gPad->SetLogy(); + + // PAD_RAW_MULT + name = "ISS"+NPL::itoa(i+1)+"_PAD_RAW_MULT"; + AddHisto1D(name, name, fNumberOfDetector, 1, fNumberOfDetector+1, "ISS/RAW/MULT")->Draw(""); + gPad->SetLogy(); + + } // end loop on number of detectors + + // STR_PAD_DetN_MAP : useful for mapping issue + name = "ISS_STR_PAD_DetN_RAW"; + AddHisto2D(name, name, fNumberOfDetector, 1, fNumberOfDetector+1, fNumberOfDetector, 1, fNumberOfDetector+1, "ISS/RAW/MAP")->Draw("colz"); + +} + +//////////////////////////////////////////////////////////////////////////////// +void TIssSpectra::InitPreTreatedSpectra(){ + static string name; + for (unsigned int i = 0; i < fNumberOfDetector; i++) { // loop on number of detectors + // STR_FRONT_E_CAL + name = "ISS"+NPL::itoa(i+1)+"_STR_FRONT_E_CAL"; + AddHisto2D(name, name, fStripFront, 1, fStripFront+1, 500, 0, 25, "ISS/CAL/STR_FRONT_E"); + + // STR_BACK_E_CAL + name = "ISS"+NPL::itoa(i+1)+"_STR_BACK_E_CAL"; + AddHisto2D(name, name, fStripBack, 1, fStripBack+1, 500, 0, 25, "ISS/CAL/STR_BACK_E"); + + // PAD_E_CAL + name = "ISS"+NPL::itoa(i+1)+"_PAD_E_CAL"; + AddHisto1D(name, name, 100, 0, 50, "ISS/CAL/PAD_E"); + + // STR_FRONT_CAL_MULT + name = "ISS"+NPL::itoa(i+1)+"_STR_FRONT_CAL_MULT"; + AddHisto1D(name, name, fStripFront, 1, fStripFront+1, "ISS/CAL/MULT"); + + // STR_BACK_CAL_MULT + name = "ISS"+NPL::itoa(i+1)+"_STR_BACK_CAL_MULT"; + AddHisto1D(name, name, fStripFront, 1, fStripFront+1, "ISS/CAL/MULT"); + + // PAD_CAL_MULT + name = "ISS"+NPL::itoa(i+1)+"_PAD_CAL_MULT"; + AddHisto1D(name, name, fNumberOfDetector, 1, fNumberOfDetector+1, "ISS/CAL/MULT"); + + // PAD_CAL_ID + name = "ISS"+NPL::itoa(i+1)+"_PAD_CAL_ID"; + AddHisto2D(name, name,100,0,50,500,0,50, "ISS/CAL/ID"); + + // Front-Back Energy Correlation + name = "ISS"+NPL::itoa(i+1)+"_FB_COR"; + AddHisto2D(name, name,500,0,25,500,0,25, "ISS/CAL/FB"); + + } // end loop on number of detectors + + // STR_PAD_DetN_MAP : useful for mapping issue + name = "ISS_STR_PAD_DetN_CAL"; + AddHisto2D(name, name, fNumberOfDetector, 1, fNumberOfDetector+1, fNumberOfDetector, 1, fNumberOfDetector+1, "ISS/CAL/MAP")->Draw("colz"); + +} + +//////////////////////////////////////////////////////////////////////////////// +void TIssSpectra::InitPhysicsSpectra(){ + static string name; + // Kinematic Plot + name = "ISS_THETA_E"; + AddHisto2D(name, name,360,0,180,500,0,50,"ISS/PHY"); + + // ID Plot + // PAD-DE: + name = "ISS_PAD_E_E"; + AddHisto1D(name, name,500,0,25,"ISS/PHY"); + + for (unsigned int i = 0; i < fNumberOfDetector; i++) { // loop on number of detectors + // PAD-DE: + name = "ISS"+NPL::itoa(i+1)+"_PAD_E_E"; + AddHisto2D(name, name,100,0,100,500,0,25,"ISS/PHY"); + } +} + + + +//////////////////////////////////////////////////////////////////////////////// +void TIssSpectra::FillRawSpectra(TIssData* RawData){ + static string index; + static string name; + + // STR_FRONT_E + unsigned int mysize = RawData->GetMultiplicityFront(); + double EFMAX = 0 ; + int SFMAX = 0; + int DFMAX = 0 ; + for (unsigned int i = 0; i < mysize; i++) { + index = "ISS/RAW/STR_FRONT_E/ISS"+NPL::itoa(RawData->GetFront_DetectorNbr(i))+"_STR_FRONT_E_RAW"; + if(RawData->GetFront_Energy(i) > EFMAX){ + EFMAX = RawData->GetFront_Energy(i); + SFMAX = RawData->GetFront_StripNbr(i); + DFMAX = RawData->GetFront_DetectorNbr(i); + } + + FillSpectra(index + ,RawData->GetFront_StripNbr(i), + RawData->GetFront_Energy(i)); + } + + if(DFMAX!=0){ + index = "ISS/RAW/STR_FRONT_EMAX/ISS"+NPL::itoa(DFMAX)+"_STR_FRONT_EMAX_RAW"; + FillSpectra(index,SFMAX, EFMAX); + } + + // STR_BACK_E + mysize = RawData->GetMultiplicityBack(); + double EBMAX = 0 ; + int SBMAX = 0; + int DBMAX = 0 ; + + for (unsigned int i = 0; i < mysize; i++) { + index = "ISS/RAW/STR_BACK_E/ISS"+NPL::itoa( RawData->GetBack_DetectorNbr(i) )+"_STR_BACK_E_RAW"; + if(RawData->GetBack_Energy(i) > EBMAX){ + EBMAX = RawData->GetBack_Energy(i); + SBMAX = RawData->GetBack_StripNbr(i); + DBMAX = RawData->GetBack_DetectorNbr(i); + } + + FillSpectra(index + ,RawData->GetBack_StripNbr(i), + RawData->GetBack_Energy(i)); + } + + if(DBMAX!=0){ + index = "ISS/RAW/STR_BACK_EMAX/ISS"+NPL::itoa(DBMAX)+"_STR_BACK_EMAX_RAW"; + FillSpectra(index,SBMAX, EBMAX); + } + + + // STR_FRONT MULT + int myMULT[fNumberOfDetector]; + for( unsigned int i = 0; i < fNumberOfDetector; i++) + myMULT[i] = 0 ; + + for(unsigned int i = 0 ; i < RawData->GetMultiplicityFront();i++){ + myMULT[RawData->GetFront_DetectorNbr(i)-1] += 1; + } + + for( unsigned int i = 0; i < fNumberOfDetector; i++){ + index = "ISS/RAW/MULT/ISS"+NPL::itoa(i+1)+"_STR_FRONT_RAW_MULT"; + FillSpectra(index + ,myMULT[i]); + } + + // STR_BACK MULT + for( unsigned int i = 0; i < fNumberOfDetector; i++) + myMULT[i] = 0 ; + + mysize = RawData->GetMultiplicityBack(); + for(unsigned int i = 0 ; i < mysize;i++){ + myMULT[RawData->GetBack_DetectorNbr(i)-1] += 1; + } + + for( unsigned int i = 0; i < fNumberOfDetector; i++){ + index= "ISS/RAW/MULT/ISS"+NPL::itoa(i+1)+"_STR_BACK_RAW_MULT"; + + FillSpectra(index + ,myMULT[i]); + } + + + +} + +//////////////////////////////////////////////////////////////////////////////// +void TIssSpectra::FillPreTreatedSpectra(TIssData* PreTreatedData){ + static string index; + static string name; + + // Front-Back + unsigned int mysizeF = PreTreatedData->GetMultiplicityFront(); + unsigned int mysizeB = PreTreatedData->GetMultiplicityBack(); +// unsigned int mysizePAD = PreTreatedData->GetMultiplicityPAD(); + + for (unsigned int i = 0; i < mysizeF; i++) { + for (unsigned int j = 0; j < mysizeB; j++) { + if(PreTreatedData->GetFront_DetectorNbr(i)==PreTreatedData->GetBack_DetectorNbr(j)){ + index="ISS/CAL/FB/"; + name="ISS"+NPL::itoa(PreTreatedData->GetFront_DetectorNbr(i))+"_FB_COR"; + + FillSpectra(index, name + ,PreTreatedData->GetFront_Energy(i), + PreTreatedData->GetBack_Energy(j) ); + } + } + } + + // STR_FRONT_E + unsigned int mysize = PreTreatedData->GetMultiplicityFront(); + for (unsigned int i = 0; i < mysize; i++) { + index = "ISS/CAL/STR_FRONT_E"; + name="ISS"+NPL::itoa(PreTreatedData->GetFront_DetectorNbr(i))+"_STR_FRONT_E_CAL"; + + FillSpectra(index,name + ,PreTreatedData->GetFront_StripNbr(i), + PreTreatedData->GetFront_Energy(i)); + } + // STR_BACK_E + mysize = PreTreatedData->GetMultiplicityBack(); + for (unsigned int i = 0; i < mysize; i++) { + index = "ISS/CAL/STR_BACK_E"; + string name = "ISS"+NPL::itoa( PreTreatedData->GetBack_DetectorNbr(i))+"_STR_BACK_E_CAL"; + + FillSpectra(index,name + ,PreTreatedData->GetBack_StripNbr(i), + PreTreatedData->GetBack_Energy(i)); + } + + + // STR_FRONT MULT + int myMULT[fNumberOfDetector]; + for( unsigned int i = 0; i < fNumberOfDetector; i++) + myMULT[i] = 0 ; + + mysize = PreTreatedData->GetMultiplicityFront(); + for(unsigned int i = 0 ; i < mysize ;i++){ + myMULT[PreTreatedData->GetFront_DetectorNbr(i)-1] += 1; + } + + for( unsigned int i = 0; i < fNumberOfDetector; i++){ + index= "ISS/CAL/MULT"; + name= "ISS"+NPL::itoa(i+1)+"_STR_FRONT_CAL_MULT"; + FillSpectra(index,name,myMULT[i]); + } + + // STR_BACK MULT + for( unsigned int i = 0; i < fNumberOfDetector; i++) + myMULT[i] = 0 ; + + mysize = PreTreatedData->GetMultiplicityBack(); + for(unsigned int i = 0 ; i < mysize ;i++){ + myMULT[PreTreatedData->GetBack_DetectorNbr(i)-1] += 1; + } + + for( unsigned int i = 0; i < fNumberOfDetector; i++){ + index= "ISS/CAL/MULT"; + name = "ISS"+NPL::itoa(i+1)+"_STR_BACK_CAL_MULT"; + FillSpectra(index,name + ,myMULT[i]); + } + + + + +} + +//////////////////////////////////////////////////////////////////////////////// +void TIssSpectra::FillPhysicsSpectra(TIssPhysics* Physics){ + static string index="ISS/PHY"; + static string name; + // Kine plot + unsigned int mysize = Physics->Strip_E.size(); + for(unsigned int i = 0 ; i < mysize ; i++){ + double Theta = Physics->GetPositionOfInteraction(i).Angle(TVector3(0,0,1)); + Theta = Theta/deg; + double Etot=Physics->Strip_E[i]; + + name = "ISS_THETA_E"; + FillSpectra(index,name,Theta,Etot); + } +} + diff --git a/NPLib/Detectors/Iss/TIssSpectra.h b/NPLib/Detectors/Iss/TIssSpectra.h new file mode 100644 index 0000000000000000000000000000000000000000..d2bf0bc4b1d453e4b6fc90db4d92a009129b5d78 --- /dev/null +++ b/NPLib/Detectors/Iss/TIssSpectra.h @@ -0,0 +1,59 @@ +#ifndef TISSSPECTRA_H +#define TISSSPECTRA_H +/***************************************************************************** + * Copyright (C) 2009-2019 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: a.matta@surrey.ac.uk * + * Author: M. Labiche address: marc.labiche@stfc.ac.uk * + * * + * Creation Date : July 2019 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class holds all the online spectra needed for Iss * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + *****************************************************************************/ + +// NPLib headers +#include "NPVSpectra.h" +#include "TIssData.h" +#include "TIssPhysics.h" + +// ForwardDeclaration +class TIssPhysics ; + +class TIssSpectra:public VSpectra { + public: + // constructor and destructor + TIssSpectra(); + TIssSpectra(unsigned int NumberOfDetector); + ~TIssSpectra(); + + private: + // Initialization methods + void InitRawSpectra(); + void InitPreTreatedSpectra(); + void InitPhysicsSpectra(); + + public: + // Filling methods + void FillRawSpectra(TIssData*); + void FillPreTreatedSpectra(TIssData*); + void FillPhysicsSpectra(TIssPhysics*); + + private: // Information on Iss + unsigned int fNumberOfDetector; + unsigned int fStripFront; + unsigned int fStripBack; +// unsigned int fPad; +}; + +#endif diff --git a/NPLib/Detectors/Iss/ressources/Mask.cxx b/NPLib/Detectors/Iss/ressources/Mask.cxx new file mode 100644 index 0000000000000000000000000000000000000000..0a5e035e04bae975658cf53f6a173a9e3d26493f --- /dev/null +++ b/NPLib/Detectors/Iss/ressources/Mask.cxx @@ -0,0 +1,74 @@ +void Mask(){ + + unsigned int strips = 128 ; + double dimension = 127.; + double active = 125.; + double pitch = active/strips; + double width = 0.9; +// +// double dimension = 100; +// double active = 97; +// double pitch = 97/97; +// double width = 0.5; + + + // mm per pixel + double scale = 125./12800; + //pitch in pixel + unsigned int spitch = pitch/scale; + unsigned int swidth = width/scale; + unsigned int sinter = (pitch - width)/(scale); + cout << spitch << " " << swidth << " " << sinter << endl; + + + + // image size + unsigned int size = dimension/scale; + +/* tried by me: + double dimensionL = 128.42; + double activeL= 127.9; + double scaleL = 127.9/12800; + unsigned int size2 = dimensionL/scaleL; +*/ + + cout << "Image size: " << size << "x" << size << endl ; + double* zargb = new double[size*size]; + + TASImage* mask = new TASImage("mask",zargb,size,size,0); + unsigned int* argb = mask->GetArgbArray(); + unsigned int* argb2 = mask->GetArgbArray(); + unsigned int index = 0; + double border1 = 0.5*(dimension-active); + double border2 =(border1+strips*pitch); //(active)/scale+border1; + unsigned int sborder1=border1/scale; + unsigned int sborder2=border2/scale; // border2/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 < sborder1|| py < sborder1 || px > sborder2 || py > sborder2) + 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)) + // interstrip + argb[index] = 0xffff0000+(((nbr-1))<<8)+nbr-2; + else if (nbr-1 < strips+1) + argb[index] = 0xff000000 + nbr-1; + else + argb[index] = 0xffff0000; + } + } + } + mask->WriteImage("mask.png"); + delete[] zargb; + //mask->Draw(); + +} diff --git a/NPLib/Detectors/Iss/ressources/MaskIssFrontcxx b/NPLib/Detectors/Iss/ressources/MaskIssFrontcxx new file mode 100644 index 0000000000000000000000000000000000000000..10207ff2fa487e458abbea0b899fe68dfab2011b --- /dev/null +++ b/NPLib/Detectors/Iss/ressources/MaskIssFrontcxx @@ -0,0 +1,61 @@ +void Mask(){ + + unsigned int strips = 128 ; + double dimension = 128.42; + double active = 127.9; + double pitch = active/strips; + double width = 0.8; +// +// double dimension = 100; +// double active = 97; +// double pitch = 97/97; +// double width = 0.5; + + // mm per pixel + double scale = 127.9/12800; + //pitch in pixel + unsigned int spitch = pitch/scale; + unsigned int swidth = width/scale; + unsigned int sinter = (pitch - width)/(scale); + 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* mask = new TASImage("mask",zargb,size,size,0); + unsigned int* argb = mask->GetArgbArray(); + unsigned int* argb2 = mask->GetArgbArray(); + unsigned int index = 0; + double border1 = 0.5*(dimension-active); + double border2 = (border1+strips*pitch); //(active)/scale+border1; + unsigned int sborder1=border1/scale; + unsigned int sborder2=border2/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 < sborder1|| py < sborder1 || px > sborder2 || py > sborder2) + 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)) + // interstrip + argb[index] = 0xffff0000+(((nbr-1))<<8)+nbr-2; + else if (nbr-1 < strips+1) + argb[index] = 0xff000000 + nbr-1; + else + argb[index] = 0xffff0000; + } + } + } + mask->WriteImage("mask.png"); + delete[] zargb; + //mask->Draw(); + +} diff --git a/NPLib/Detectors/Iss/ressources/ReadMe b/NPLib/Detectors/Iss/ressources/ReadMe new file mode 100644 index 0000000000000000000000000000000000000000..eb49db39a0947913d2a6f6b024d9528efbaf0897 --- /dev/null +++ b/NPLib/Detectors/Iss/ressources/ReadMe @@ -0,0 +1,31 @@ + +NOTE: to be used only id the PS_Image scorer function defined in the DSSSDScorer file (see /NPSimulation/Scorer/DSSSDScorer.cc) is used in the detector definition file. + + +Edit Mask.cxx and adjust the parameters for one side of the DSSSD. + +Then run: +root -l Mask.cxx + +This creates mask.png file that you can save with a different name (e.g: maskFront.png) + +Repeat the same operation for the other side of the DSSS to create the corresponding mask (e.g:maskBack.png) + + +Parameters used for ISS front: + + unsigned int strips = 128 ; + double dimension = 129.; + double active = 127.9; + double width = 0.9; + // mm per pixel + double scale = 127/12800; + + +Parameters used for ISS back: + unsigned int strips = 11 ; + double dimension = 23.5; + double active = 19.9; + double width = 1.78; + // mm per pixel + double scale = 19.9/1100; diff --git a/NPLib/Detectors/MDM/CMakeLists.txt b/NPLib/Detectors/MDM/CMakeLists.txt index a3ad822b2392fdab604fa53fb2b5101a933106cf..6d3113af06ba5bc9ad5acdc7461da7f930d4f43f 100644 --- a/NPLib/Detectors/MDM/CMakeLists.txt +++ b/NPLib/Detectors/MDM/CMakeLists.txt @@ -6,7 +6,7 @@ add_custom_command(OUTPUT TMDMDataDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/b ## ## Check if MINUIT2 is installed along with ROOT -find_library(libMinuit2_FOUND NAMES Minuit2 HINTS "${ROOTSYS}/lib") +find_library(libMinuit2_FOUND NAMES Minuit2 HINTS "${ROOTSYS}/lib" "/usr/lib64/root") if(libMinuit2_FOUND) message(STATUS "Minuit2 support enabled for MDM.") add_definitions(-DHAVE_MINUIT2) diff --git a/NPLib/Detectors/Minos/CMakeLists.txt b/NPLib/Detectors/Minos/CMakeLists.txt index d81fe157ddb3e5889ccad921cba15e0b759390f2..6f6affcaa8ead07ec97b5a322e81cc3d5d951cb7 100644 --- a/NPLib/Detectors/Minos/CMakeLists.txt +++ b/NPLib/Detectors/Minos/CMakeLists.txt @@ -10,7 +10,7 @@ add_custom_command(OUTPUT TMinosClustDict.cxx COMMAND ../../scripts/build_dict.s add_custom_command(OUTPUT TMinosResultDict.cxx COMMAND ../../scripts/build_dict.sh TMinosResult.h TMinosResultDict.cxx TMinosResult.rootmap libNPMinos.dylib DEPENDS TMinosResult.h) ## Check if MINUIT is installed along with ROOT -find_library(libMinuit_FOUND NAMES Minuit2 HINTS "$ENV{ROOTSYS}/lib") +find_library(libMinuit_FOUND NAMES Minuit2 HINTS "$ENV{ROOTSYS}/lib" "/usr/lib64/root") if(libMinuit_FOUND) message(STATUS "Minuit support enabled for Minos.") add_definitions(-DHAVE_MINUIT) diff --git a/NPLib/Detectors/Minos/TMinosPhysics.cxx b/NPLib/Detectors/Minos/TMinosPhysics.cxx index ad776262fc3e9653aa0c8550597c5bbe1c8c3fd1..04ccd7800a1aceb1e21662b9586040bf2f712bbd 100644 --- a/NPLib/Detectors/Minos/TMinosPhysics.cxx +++ b/NPLib/Detectors/Minos/TMinosPhysics.cxx @@ -10,33 +10,33 @@ * * * Creation Date : 2014/11/24 * * Last update : 2019/09 implemeted in NPTool by Cyril Lenain * - * lenain@lpccaen.in2p3.fr * + * lenain@lpccaen.in2p3.fr * *---------------------------------------------------------------------------* * Decription: * * This class hold Minos Treated data * * * *---------------------------------------------------------------------------* * Comment: * - * * + * * * * *****************************************************************************/ #include "TMinosPhysics.h" // STL -#include <sstream> -#include <iostream> #include <cmath> -#include <stdlib.h> +#include <iostream> #include <limits> +#include <sstream> +#include <stdlib.h> using namespace std; // NPL -#include "RootInput.h" -#include "RootOutput.h" #include "NPDetectorFactory.h" #include "NPOptionManager.h" #include "NPSystemOfUnits.h" +#include "RootInput.h" +#include "RootOutput.h" // ROOT #include "TChain.h" @@ -44,104 +44,94 @@ using namespace std; TMinosPhysics* current_phy = 0; /////////////////////////////////////////////////////////////////////////// -TMinosPhysics::TMinosPhysics(){ - m_EventData=new TMinosData; - m_EventPhysics=this; - m_E_RAW_Threshold=0; // adc channels - m_E_Threshold=0; // MeV - m_ransac.SetParameters(100,// max 100 iteration - 5, // a point belong to a track if it is within 5 mm - 40, // max distance allowed between a pair of point to consider a track - 10);// minimum point to form a valid cluster +TMinosPhysics::TMinosPhysics() { + m_EventData = new TMinosData; + m_EventPhysics = this; + m_E_RAW_Threshold = 0; // adc channels + m_E_Threshold = 0; // MeV + m_ransac.SetParameters(100, // max 100 iteration + 5, // a point belong to a track if it is within 5 mm + 40, // max distance allowed between a pair of point to consider a track + 10); // minimum point to form a valid cluster } /////////////////////////////////////////////////////////////////////////// -void TMinosPhysics::BuildSimplePhysicalEvent() { - BuildPhysicalEvent(); -} +void TMinosPhysics::BuildSimplePhysicalEvent() { BuildPhysicalEvent(); } /////////////////////////////////////////////////////////////////////////// void TMinosPhysics::BuildPhysicalEvent() { PreTreat(); - vector<NPL::LinearCluster3D> clusters = m_ransac.TreatEvent(X_Pad,Y_Pad,Z_Pad); + vector<NPL::LinearCluster3D> clusters = m_ransac.TreatEvent(X_Pad, Y_Pad, Z_Pad); unsigned int sizeC = clusters.size(); - for(unsigned int i = 0 ; i < sizeC ; i++){ - // Extract the Direction of the track + for (unsigned int i = 0; i < sizeC; i++) { + // Extract the Direction of the track clusters[i].LinearFit(); Tracks_P0.push_back(clusters[i].GetP0()); Tracks_Dir.push_back(clusters[i].GetDir()); } - if(sizeC==2){ - static TVector3 Vertex,delta; - Delta_Vertex = - MinimumDistanceTwoLines(Tracks_P0[0],Tracks_P0[0]+Tracks_Dir[0], - Tracks_P0[1],Tracks_P0[1]+Tracks_Dir[1], - Vertex, delta); - X_Vertex= Vertex.X(); - Y_Vertex= Vertex.Y(); - Z_Vertex= Vertex.Z(); - Theta_12=180.*Tracks_Dir[0].Angle(Tracks_Dir[1])/(M_PI); + if (sizeC == 2) { + static TVector3 Vertex, delta; + Delta_Vertex = MinimumDistanceTwoLines(Tracks_P0[0], Tracks_P0[0] + Tracks_Dir[0], Tracks_P0[1], + Tracks_P0[1] + Tracks_Dir[1], Vertex, delta); + X_Vertex = Vertex.X(); + Y_Vertex = Vertex.Y(); + Z_Vertex = Vertex.Z(); + Theta_12 = 180. * Tracks_Dir[0].Angle(Tracks_Dir[1]) / (M_PI); } } /////////////////////////////////////////////////////////////////////////// void TMinosPhysics::PreTreat() { // apply thresholds and calibration - static unsigned int sizePad,sizeQ ; + static unsigned int sizePad, sizeQ; static unsigned short PadNumber; - static double Q,T; - static auto cal= CalibrationManager::getInstance(); + static double Q, T; + static auto cal = CalibrationManager::getInstance(); static string cal_v, cal_o; sizePad = m_EventData->GetPadMult(); - if(sizePad>20){ - for(unsigned int i = 0 ; i < sizePad ; i++){ + if (sizePad > 20) { + for (unsigned int i = 0; i < sizePad; i++) { vector<unsigned short>* Charge = m_EventData->GetChargePtr(i); - if(Charge->size()>40 ){ - vector<unsigned short>* Time = m_EventData->GetTimePtr(i); - m_utility.Calibrate(Time,Charge,i,T,Q); + if (Charge->size() > 40) { + vector<unsigned short>* Time = m_EventData->GetTimePtr(i); + m_utility.Calibrate(Time, Charge, i, T, Q); - if(T>0){ + if (T > 0 && Q < 77000) { PadNumber = m_EventData->GetPadNumber(i); double x_mm = m_X[PadNumber]; double y_mm = m_Y[PadNumber]; - unsigned int ring = round((sqrt(x_mm*x_mm + y_mm*y_mm)-44.15)/2.1); - cal_v="Minos/R"+NPL::itoa(ring)+"_VDRIFT"; - cal_o="Minos/R"+NPL::itoa(ring)+"_OFFSET"; - double calV= cal->GetValue(cal_v,0); - double calO=cal->GetValue(cal_o,0); - - // regular case - //double z_mm = (T*m_TimeBin+cal->GetValue(cal_o,0))*cal->GetValue(cal_v,0); - - // testing dependency: - //calV+=-calV*30./100.;// -5% - //calO+=+calO*60./100; - double z_mm = (T*m_TimeBin+calO)*calV; - TVector3 Pos=TVector3(x_mm+m_Position.X(),y_mm+m_Position.Y(),z_mm+m_Position.Z()); - Pos.RotateZ(m_ZRotation); + unsigned int ring = round((sqrt(x_mm * x_mm + y_mm * y_mm) - 44.15) / 2.1); + cal_v = "Minos/R" + NPL::itoa(ring) + "_VDRIFT"; + cal_o = "Minos/R" + NPL::itoa(ring) + "_OFFSET"; + double calV = cal->GetValue(cal_v, 0); + double calO = cal->GetValue(cal_o, 0); + + double z_mm = (T * m_TimeBin + calO /*-0.7-0.04*ring*/) * calV; + // cout << T*m_TimeBin+calO << endl; + TVector3 Pos = TVector3(x_mm + m_Position.X(), y_mm + m_Position.Y(), z_mm + m_Position.Z()); + Pos.RotateZ(m_ZRotation); // Calibrate the Pad: + X_Pad.push_back(Pos.X()); Y_Pad.push_back(Pos.Y()); - Z_Pad.push_back(Pos.Z()); + Z_Pad.push_back(Pos.Z()); Ring_Pad.push_back(ring); - Q_Pad.push_back(Q); - T_Pad.push_back(T); + Q_Pad.push_back(Q); + T_Pad.push_back(T); } } - else{ + else { /* X_Pad.push_back(-1); Y_Pad.push_back(-1); Z_Pad.push_back((-1); Ring_Pad.push_back(-1); - Z_Pad.push_back(-1); - Q_Pad.push_back(-1); - T_Pad.push_back(-1);*/ + Z_Pad.push_back(-1); + Q_Pad.push_back(-1); + T_Pad.push_back(-1);*/ } - } - } } /////////////////////////////////////////////////////////////////////////// @@ -166,33 +156,33 @@ void TMinosPhysics::ReadAnalysisConfig() { asciiConfig->Append(FileName.c_str()); asciiConfig->AppendLine(""); // read analysis config file - string LineBuffer,DataBuffer,whatToDo; + string LineBuffer, DataBuffer, whatToDo; while (!AnalysisConfigFile.eof()) { // Pick-up next line getline(AnalysisConfigFile, LineBuffer); // search for "header" string name = "ConfigMinos"; - if (LineBuffer.compare(0, name.length(), name) == 0) + if (LineBuffer.compare(0, name.length(), name) == 0) ReadingStatus = true; // loop on tokens and data - while (ReadingStatus ) { - whatToDo=""; + while (ReadingStatus) { + whatToDo = ""; AnalysisConfigFile >> whatToDo; // Search for comment symbol (%) if (whatToDo.compare(0, 1, "%") == 0) { - AnalysisConfigFile.ignore(numeric_limits<streamsize>::max(), '\n' ); + AnalysisConfigFile.ignore(numeric_limits<streamsize>::max(), '\n'); } - else if (whatToDo=="E_RAW_THRESHOLD") { + else if (whatToDo == "E_RAW_THRESHOLD") { AnalysisConfigFile >> DataBuffer; m_E_RAW_Threshold = atof(DataBuffer.c_str()); cout << whatToDo << " " << m_E_RAW_Threshold << endl; } - else if (whatToDo=="E_THRESHOLD") { + else if (whatToDo == "E_THRESHOLD") { AnalysisConfigFile >> DataBuffer; m_E_Threshold = atof(DataBuffer.c_str()); cout << whatToDo << " " << m_E_Threshold << endl; @@ -203,14 +193,13 @@ void TMinosPhysics::ReadAnalysisConfig() { } } } - } /////////////////////////////////////////////////////////////////////////// void TMinosPhysics::Clear() { - Ring_Pad.clear(); - X_Pad.clear(); - Y_Pad.clear(); + Ring_Pad.clear(); + X_Pad.clear(); + Y_Pad.clear(); Z_Pad.clear(); Q_Pad.clear(); T_Pad.clear(); @@ -220,91 +209,86 @@ void TMinosPhysics::Clear() { Tracks_Dir.clear(); // Vertex information - X_Vertex=-1000; - Y_Vertex=-1000; - Z_Vertex=-1000; - Theta_12=-1000; - Delta_Vertex=-1000; + X_Vertex = -1000; + Y_Vertex = -1000; + Z_Vertex = -1000; + Theta_12 = -1000; + Delta_Vertex = -1000; } /////////////////////////////////////////////////////////////////////////// void TMinosPhysics::ReadConfiguration(NPL::InputParser parser) { vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithToken("Minos"); - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << "//// " << blocks.size() << " detector(s) found " << endl; + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks.size() << " detector(s) found " << endl; - vector<string> token= {"XML","TimeBin","ShapingTime","Baseline","Sampling","Position","ZRotation"}; + vector<string> token = {"XML", "TimeBin", "ShapingTime", "Baseline", "Sampling", "Position", "ZRotation"}; + + for (unsigned int i = 0; i < blocks.size(); i++) { - for(unsigned int i = 0 ; i < blocks.size() ; i++){ - if (blocks[i]->HasTokenList(token)) { - cout << endl << "//// MINOS (" << i+1 << ")" << endl; - m_ShapingTime = blocks[i]->GetDouble("ShapingTime","ns")/NPUNITS::ns; - m_TimeBin = blocks[i]->GetDouble("TimeBin","ns")/NPUNITS::ns; - m_Sampling= blocks[i]->GetInt("Sampling"); - m_Baseline= blocks[i]->GetInt("BaseLine"); - m_utility.SetParameters(m_TimeBin,m_ShapingTime,m_Baseline,m_Sampling); - m_Position = blocks[i]->GetTVector3("Position","mm"); - m_ZRotation= blocks[i]->GetDouble("ZRotation","deg"); + cout << endl << "//// MINOS (" << i + 1 << ")" << endl; + m_ShapingTime = blocks[i]->GetDouble("ShapingTime", "ns") / NPUNITS::ns; + m_TimeBin = blocks[i]->GetDouble("TimeBin", "ns") / NPUNITS::ns; + m_Sampling = blocks[i]->GetInt("Sampling"); + m_Baseline = blocks[i]->GetInt("BaseLine"); + m_utility.SetParameters(m_TimeBin, m_ShapingTime, m_Baseline, m_Sampling); + m_Position = blocks[i]->GetTVector3("Position", "mm"); + m_ZRotation = blocks[i]->GetDouble("ZRotation", "deg"); string xmlpath = blocks[i]->GetString("XML"); NPL::XmlParser xml; xml.LoadFile(xmlpath); ReadXML(xml); - } else { - cout << "ERROR: Missing token for Minos, check your input file"<< endl; - cout << "Required token: "; - for(unsigned int i = 0 ; i < token.size() ; i++) - cout << token[i] << " " ; + cout << "ERROR: Missing token for Minos, check your input file" << endl; + cout << "Required token: "; + for (unsigned int i = 0; i < token.size(); i++) + cout << token[i] << " "; cout << endl; exit(1); } - } } /////////////////////////////////////////////////////////////////////////// -void TMinosPhysics::ReadXML(NPL::XmlParser& xml){ - std::vector<NPL::XML::block*> b = xml.GetAllBlocksWithName("MINOS"); +void TMinosPhysics::ReadXML(NPL::XmlParser& xml) { + std::vector<NPL::XML::block*> b = xml.GetAllBlocksWithName("MINOS"); unsigned int size = b.size(); - unsigned int valid_pad=0; - for(unsigned int i = 0 ; i < size ; i++){ + unsigned int valid_pad = 0; + for (unsigned int i = 0; i < size; i++) { - unsigned short ID = b[i]->AsInt("ID"); - m_X[ID] = b[i]->AsDouble("X"); - m_Y[ID] = b[i]->AsDouble("Y"); + unsigned short ID = b[i]->AsInt("ID"); + m_X[ID] = b[i]->AsDouble("X"); + m_Y[ID] = b[i]->AsDouble("Y"); valid_pad++; - if((m_X[ID]==0&&m_Y[ID]==0)||(m_X[ID]==-1&&m_Y[ID]==-1)) + if ((m_X[ID] == 0 && m_Y[ID] == 0) || (m_X[ID] == -1 && m_Y[ID] == -1)) valid_pad--; - m_Period[ID] = b[i]->AsDouble("TPERIOD"); - m_Offset[ID] = b[i]->AsDouble("TOFFSET"); - m_Gain[ID] = b[i]->AsDouble("GAIN"); + m_Period[ID] = b[i]->AsDouble("TPERIOD"); + m_Offset[ID] = b[i]->AsDouble("TOFFSET"); + m_Gain[ID] = b[i]->AsDouble("GAIN"); } - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << "//// " << m_X.size() << " pads found with " << valid_pad << " valid pads" << endl; - + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << m_X.size() << " pads found with " << valid_pad << " valid pads" << endl; } - - /////////////////////////////////////////////////////////////////////////// void TMinosPhysics::AddParameterToCalibrationManager() { CalibrationManager* Cal = CalibrationManager::getInstance(); unsigned int NbrRing = 18; - vector<double> standardV={0.03475}; - vector<double> standardO={0}; - for(unsigned int i = 0 ; i < NbrRing ; i++){ - Cal->AddParameter("Minos", "R"+NPL::itoa(i+1)+"_VDRIFT","Minos_R"+NPL::itoa(i+1)+"_VDRIFT",standardV); - Cal->AddParameter("Minos", "R"+NPL::itoa(i+1)+"_OFFSET","Minos_R"+NPL::itoa(i+1)+"_OFFSET",standardO); + vector<double> standardV = {0.03475}; + vector<double> standardO = {0}; + for (unsigned int i = 0; i < NbrRing; i++) { + Cal->AddParameter("Minos", "R" + NPL::itoa(i + 1) + "_VDRIFT", "Minos_R" + NPL::itoa(i + 1) + "_VDRIFT", standardV); + Cal->AddParameter("Minos", "R" + NPL::itoa(i + 1) + "_OFFSET", "Minos_R" + NPL::itoa(i + 1) + "_OFFSET", standardO); } } /////////////////////////////////////////////////////////////////////////// void TMinosPhysics::InitializeRootInputRaw() { TChain* inputChain = RootInput::getInstance()->GetChain(); - inputChain->SetBranchStatus("Minos", true ); - inputChain->SetBranchAddress("Minos", &m_EventData ); + inputChain->SetBranchStatus("Minos", true); + inputChain->SetBranchAddress("Minos", &m_EventData); } /////////////////////////////////////////////////////////////////////////// @@ -322,21 +306,19 @@ void TMinosPhysics::InitializeRootOutput() { //////////////////////////////////////////////////////////////////////////////// // Construct Method to be pass to the DetectorFactory // //////////////////////////////////////////////////////////////////////////////// -NPL::VDetector* TMinosPhysics::Construct() { - return (NPL::VDetector*) new TMinosPhysics(); -} +NPL::VDetector* TMinosPhysics::Construct() { return (NPL::VDetector*)new TMinosPhysics(); } //////////////////////////////////////////////////////////////////////////////// // Registering the construct method to the factory // //////////////////////////////////////////////////////////////////////////////// -extern "C"{ - class proxy_Minos{ - public: - proxy_Minos(){ - NPL::DetectorFactory::getInstance()->AddToken("Minos","Minos"); - NPL::DetectorFactory::getInstance()->AddDetector("Minos",TMinosPhysics::Construct); - } - }; +extern "C" { +class proxy_Minos { + public: + proxy_Minos() { + NPL::DetectorFactory::getInstance()->AddToken("Minos", "Minos"); + NPL::DetectorFactory::getInstance()->AddDetector("Minos", TMinosPhysics::Construct); + } +}; - proxy_Minos p_Minos; +proxy_Minos p_Minos; } diff --git a/NPLib/Detectors/Mugast/TMugastData.cxx b/NPLib/Detectors/Mugast/TMugastData.cxx index 341b8ae05536444bb5efbd84c4194535458c83ed..dd0530b267b963e4ecd934ecfc6e3273c2d3aed2 100644 --- a/NPLib/Detectors/Mugast/TMugastData.cxx +++ b/NPLib/Detectors/Mugast/TMugastData.cxx @@ -22,26 +22,25 @@ #include <iostream> using namespace std; -#include "TMugastData.h" #include "MugastMap.h" +#include "TMugastData.h" ClassImp(TMugastData) -//////////////////////////////////////////////////////////////////////////////// -TMugastData::TMugastData(){ + //////////////////////////////////////////////////////////////////////////////// + TMugastData::TMugastData() { // Init the correspondace table - for(unsigned int i = 0 ; i < 128 ; i++){ - fMG_MapTrapezeX[i+1] = MUGAST_MAP::TrapezeX[i]; - fMG_MapTrapezeY[i+1] = MUGAST_MAP::TrapezeY[i]; - fMG_MapSquareX[i+1] = MUGAST_MAP::SquareX[i]; - fMG_MapSquareY[i+1] = MUGAST_MAP::SquareY[i]; - fMG_MapAnnularX[i+1] = MUGAST_MAP::AnnularX[i]; - fMG_MapAnnularY[i+1] = MUGAST_MAP::AnnularY[i]; - + for (unsigned int i = 0; i < 128; i++) { + fMG_MapTrapezeX[i + 1] = MUGAST_MAP::TrapezeX[i]; + fMG_MapTrapezeY[i + 1] = MUGAST_MAP::TrapezeY[i]; + fMG_MapSquareX[i + 1] = MUGAST_MAP::SquareX[i]; + fMG_MapSquareY[i + 1] = MUGAST_MAP::SquareY[i]; + fMG_MapAnnularX[i + 1] = MUGAST_MAP::AnnularX[i]; + fMG_MapAnnularY[i + 1] = MUGAST_MAP::AnnularY[i]; } } //////////////////////////////////////////////////////////////////////////////// -TMugastData::~TMugastData(){} +TMugastData::~TMugastData() {} //////////////////////////////////////////////////////////////////////////////// -void TMugastData::Clear(){ +void TMugastData::Clear() { fMG_DSSDXE_DetectorNbr.clear(); fMG_DSSDXE_StripNbr.clear(); fMG_DSSDXE_Energy.clear(); @@ -62,37 +61,41 @@ void TMugastData::Clear(){ fMG_SecondLayerT_Time.clear(); } //////////////////////////////////////////////////////////////////////////////// -void TMugastData::Dump() const -{ +void TMugastData::Dump() const { cout << "XXXXXXXXXXXXXXXXXXXXXXXX Mugast Event XXXXXXXXXXXXXXXXX" << endl; cout << "// First Layer " << endl; // (X,E) cout << " DSSDXE_Mult = " << fMG_DSSDXE_DetectorNbr.size() << endl; for (UShort_t i = 0; i < fMG_DSSDXE_DetectorNbr.size(); i++) - cout << " DetNbr: " << fMG_DSSDXE_DetectorNbr[i] << " DSSD: " << fMG_DSSDXE_StripNbr[i] << " Energy: " << fMG_DSSDXE_Energy[i] << endl; + cout << " DetNbr: " << fMG_DSSDXE_DetectorNbr[i] << " DSSD: " << fMG_DSSDXE_StripNbr[i] + << " Energy: " << fMG_DSSDXE_Energy[i] << endl; // (X,T) cout << " DSSDXT_Mult = " << fMG_DSSDXT_DetectorNbr.size() << endl; for (UShort_t i = 0; i < fMG_DSSDXT_DetectorNbr.size(); i++) - cout << " DetNbr: " << fMG_DSSDXT_DetectorNbr[i] << " DSSD: " << fMG_DSSDXT_StripNbr[i] << " Time: " << fMG_DSSDXT_Time[i] << endl; + cout << " DetNbr: " << fMG_DSSDXT_DetectorNbr[i] << " DSSD: " << fMG_DSSDXT_StripNbr[i] + << " Time: " << fMG_DSSDXT_Time[i] << endl; // (Y,E) cout << " DSSDYE_Mult = " << fMG_DSSDYE_DetectorNbr.size() << endl; for (UShort_t i = 0; i < fMG_DSSDYE_DetectorNbr.size(); i++) - cout << " DetNbr: " << fMG_DSSDYE_DetectorNbr[i] << " DSSD: " << fMG_DSSDYE_StripNbr[i] << " Energy: " << fMG_DSSDYE_Energy[i] << endl; + cout << " DetNbr: " << fMG_DSSDYE_DetectorNbr[i] << " DSSD: " << fMG_DSSDYE_StripNbr[i] + << " Energy: " << fMG_DSSDYE_Energy[i] << endl; // (Y,T) cout << " DSSDYT_Mult = " << fMG_DSSDYT_DetectorNbr.size() << endl; for (UShort_t i = 0; i < fMG_DSSDYT_DetectorNbr.size(); i++) - cout << " DetNbr: " << fMG_DSSDYT_DetectorNbr[i] << " DSSD: " << fMG_DSSDYT_StripNbr[i] << " Time: " << fMG_DSSDYT_Time[i] << endl; + cout << " DetNbr: " << fMG_DSSDYT_DetectorNbr[i] << " DSSD: " << fMG_DSSDYT_StripNbr[i] + << " Time: " << fMG_DSSDYT_Time[i] << endl; // SecondLayer // Energy cout << "// Second Layer " << endl; cout << " SecondLayerE_Mult = " << fMG_SecondLayerE_DetectorNbr.size() << endl; for (UShort_t i = 0; i < fMG_SecondLayerE_DetectorNbr.size(); i++) - cout << " Det: " << fMG_SecondLayerE_DetectorNbr[i] << " DSSD: " << fMG_SecondLayerE_StripNbr[i] << " Energy: " << fMG_SecondLayerE_Energy[i] << endl; + cout << " Det: " << fMG_SecondLayerE_DetectorNbr[i] << " DSSD: " << fMG_SecondLayerE_StripNbr[i] + << " Energy: " << fMG_SecondLayerE_Energy[i] << endl; // Time cout << " SecondLayerT_Mult = " << fMG_SecondLayerT_DetectorNbr.size() << endl; for (UShort_t i = 0; i < fMG_SecondLayerT_DetectorNbr.size(); i++) - cout << " Det: " << fMG_SecondLayerT_DetectorNbr[i] << " DSSD: " << fMG_SecondLayerT_StripNbr[i] << " Time: " << fMG_SecondLayerT_Time[i] << endl; - + cout << " Det: " << fMG_SecondLayerT_DetectorNbr[i] << " DSSD: " << fMG_SecondLayerT_StripNbr[i] + << " Time: " << fMG_SecondLayerT_Time[i] << endl; } diff --git a/NPLib/Detectors/Sofia/CMakeLists.txt b/NPLib/Detectors/Sofia/CMakeLists.txt index 65c96df0144859d82f0ae17a03d7f688b108d71c..b30076cb7ce1f390a31e1967ef264d3cf7ebb149 100644 --- a/NPLib/Detectors/Sofia/CMakeLists.txt +++ b/NPLib/Detectors/Sofia/CMakeLists.txt @@ -20,9 +20,11 @@ add_custom_command(OUTPUT TSofBeamIDDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts add_custom_command(OUTPUT TSofFissionFragmentDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TSofFissionFragment.h TSofFissionFragmentDict.cxx TSofFissionFragment.rootmap libNPSofia.dylib DEPENDS TSofFissionFragment.h) -add_library(NPSofia SHARED TSofSciData.cxx TSofSciDataDict.cxx TSofSciPhysics.cxx TSofSciPhysicsDict.cxx TSofMwpcData.cxx TSofMwpcDataDict.cxx TSofMwpcPhysics.cxx TSofMwpcPhysicsDict.cxx TSofAtData.cxx TSofAtDataDict.cxx TSofAtPhysics.cxx TSofAtPhysicsDict.cxx TSofTrimData.cxx TSofTrimDataDict.cxx TSofTrimPhysics.cxx TSofTrimPhysicsDict.cxx TSofTwimData.cxx TSofTwimDataDict.cxx TSofTwimPhysics.cxx TSofTwimPhysicsDict.cxx TSofTofWData.cxx TSofTofWDataDict.cxx TSofTofWPhysics.cxx TSofTofWPhysicsDict.cxx TSofBeamID.cxx TSofBeamIDDict.cxx TSofFissionFragment.cxx TSofFissionFragmentDict.cxx) +add_custom_command(OUTPUT GladFieldMapDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh GladFieldMap.h GladFieldMapDict.cxx GladFieldMap.rootmap libNPSofia.dylib DEPENDS GladFieldMap.h) + +add_library(NPSofia SHARED TSofSciData.cxx TSofSciDataDict.cxx TSofSciPhysics.cxx TSofSciPhysicsDict.cxx TSofMwpcData.cxx TSofMwpcDataDict.cxx TSofMwpcPhysics.cxx TSofMwpcPhysicsDict.cxx TSofAtData.cxx TSofAtDataDict.cxx TSofAtPhysics.cxx TSofAtPhysicsDict.cxx TSofTrimData.cxx TSofTrimDataDict.cxx TSofTrimPhysics.cxx TSofTrimPhysicsDict.cxx TSofTwimData.cxx TSofTwimDataDict.cxx TSofTwimPhysics.cxx TSofTwimPhysicsDict.cxx TSofTofWData.cxx TSofTofWDataDict.cxx TSofTofWPhysics.cxx TSofTofWPhysicsDict.cxx TSofBeamID.cxx TSofBeamIDDict.cxx TSofFissionFragment.cxx TSofFissionFragmentDict.cxx GladFieldMap.cxx GladFieldMapDict.cxx) target_link_libraries(NPSofia ${ROOT_LIBRARIES} NPCore NPPhysics) -install(FILES TSofSciData.h TSofSciPhysics.h TSofMwpcData.h TSofMwpcPhysics.h TSofAtData.h TSofAtPhysics.h TSofTrimData.h TSofTrimPhysics.h TSofTwimData.h TSofTwimPhysics.h TSofTofWData.h TSofTofWPhysics.h TSofBeamID.h TSofFissionFragment.h DESTINATION ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}) +install(FILES TSofSciData.h TSofSciPhysics.h TSofMwpcData.h TSofMwpcPhysics.h TSofAtData.h TSofAtPhysics.h TSofTrimData.h TSofTrimPhysics.h TSofTwimData.h TSofTwimPhysics.h TSofTofWData.h TSofTofWPhysics.h TSofBeamID.h TSofFissionFragment.h GladFieldMap.h DESTINATION ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}) diff --git a/NPLib/Detectors/Sofia/GladFieldMap.cxx b/NPLib/Detectors/Sofia/GladFieldMap.cxx new file mode 100644 index 0000000000000000000000000000000000000000..3277b93e94d5dbdcd12aae9567884eda24d496cb --- /dev/null +++ b/NPLib/Detectors/Sofia/GladFieldMap.cxx @@ -0,0 +1,246 @@ +/***************************************************************************** + * Copyright (C) 2009-2020 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: Pierre Morfouace contact address: pierre.morfouace@ceafr * + * Creation Date : May 2022 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class hold basic field map and brho reconstruction * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ +#include "GladFieldMap.h" +#include "NPPhysicalConstants.h" +#include "Math/Factory.h" +using namespace NPUNITS; + +#include <cmath> +#include <iostream> +#include <fstream> +#include <sstream> +#include <string> +using namespace std; + +ClassImp(GladFieldMap) + + +////////////////////////////////////////////////////////////////////// +GladFieldMap::GladFieldMap() { + + m_BrhoScan=NULL; + m_min = ROOT::Math::Factory::CreateMinimizer("Minuit2","Migrad"); + m_func = ROOT::Math::Functor(this,&GladFieldMap::Delta,1); + m_min->SetFunction(m_func); + m_min->SetPrintLevel(-1); + m_Bfield = TVector3(0,1.5/1000,0); + m_Z_Glad = 4.434*m; + m_Leff = 2.*m; + m_Tilt = 14.*deg; + + m_Zmax = 9.*m; + m_Limit = 1000; + m_dt = 0.1*nanosecond; + + m_CentralTheta = 20.*deg; + m_X_MWPC3 = -1436.; + m_Z_MWPC3 = 8380.; + + m_InitPos = TVector3(0,0,0); + m_InitDir = TVector3(0,0,1); +} + + + +////////////////////////////////////////////////////////////////////// +GladFieldMap::~GladFieldMap() { +} + +////////////////////////////////////////////////////////////////////// +double GladFieldMap::Delta(const double* parameter){ + static double diff; + static vector<TVector3> vPos; + + vPos = Propagate(parameter[0], m_InitPos, m_InitDir); + TVector3 M_inter = CalculateIntersectionPoint(vPos); + + diff = abs(M_inter.X() - m_FinalPos.X()); + return diff; +} + +////////////////////////////////////////////////////////////////////// +double GladFieldMap::FindBrho(TVector3 Pos_init, TVector3 Dir_init, TVector3 Pos_final){ + m_InitPos = Pos_init; + m_InitDir = Dir_init; + m_FinalPos = Pos_final; + + if(m_FinalPos.X()>-2000){ + m_InitDir = m_InitDir.Unit(); + + if(!m_BrhoScan) + BrhoScan(4.,14.,0.2); + + double param[1]; + param[0] = m_BrhoScan->Eval(m_FinalPos.X()); + + m_min->Clear(); + m_min->SetPrecision(1e-6); + m_min->SetMaxFunctionCalls(1000); + m_min->SetLimitedVariable(0,"B",param[0],0.1,4,14); + m_min->Minimize(); + //cout << "************" << endl; + //cout << m_min->MinValue() << endl; + //cout << param[0] << " / " << m_min->X()[0] << endl; + return m_min->X()[0]; + } + + else + return -1; +} + +////////////////////////////////////////////////////////////////////// +TGraph* GladFieldMap::BrhoScan(double Brho_min, double Brho_max, double Brho_step){ + if(m_BrhoScan) + delete m_BrhoScan; + + m_BrhoScan = new TGraph(); + int i=0; + for(double Brho=Brho_min; Brho<Brho_max; Brho+=Brho_step){ + TVector3 pos = TVector3(0,0,0); + TVector3 dir = TVector3(0,0,1); + //vector<TVector3> vPos = Propagate(Brho, m_InitPos, m_InitDir); + vector<TVector3> vPos = Propagate(Brho, pos, dir); + + TVector3 M_inter = CalculateIntersectionPoint(vPos); + + m_BrhoScan->SetPoint(i,M_inter.X(),Brho); + //cout << Brho << " / " << M_inter.X() << endl; + i++; + } + + return m_BrhoScan; +} + +////////////////////////////////////////////////////////////////////// +vector<TVector3> GladFieldMap::Propagate(double Brho, TVector3 Pos, TVector3 Dir){ + vector<TVector3> vPos; + + TVector3 xk1, xk2, xk3, xk4; + TVector3 pk1, pk2, pk3, pk4; + + static NPL::Particle N("90Zr"); + N.SetBrho(Brho); + double T = N.GetEnergy(); + double M = N.Mass(); + double E = T + M; + double P = sqrt(T*T + 2*M*T)/c_light; + + Dir = Dir.Unit(); + + double px = P*Dir.X(); + double py = P*Dir.Y(); + double pz = P*Dir.Z(); + TVector3 Imp = TVector3(px,py,pz); + + int count=0; + while(Pos.Z()<m_Zmax && count<m_Limit){ + func(N, Pos, Imp, xk1, pk1); + func(N, Pos + (m_dt/2)*xk1, Imp + (m_dt/2)*pk1, xk2, pk2); + func(N, Pos + (m_dt/2)*xk2, Imp + (m_dt/2)*pk2, xk3, pk3); + func(N, Pos + m_dt*xk3, Imp + m_dt*pk3, xk4, pk4); + + Pos += (m_dt/6)*(xk1 + 2*xk2 + 2*xk3 + xk4); + Imp += (m_dt/6)*(pk1 + 2*pk2 + 2*pk3 + pk4); + + vPos.push_back(Pos); + count++; + } + + return vPos; + +} + +////////////////////////////////////////////////////////////////////// +void GladFieldMap::func(NPL::Particle& N, TVector3 Pos, TVector3 Imp, TVector3& xk, TVector3& pk){ + double px, py, pz; + px = Imp.X(); + py = Imp.Y(); + pz = Imp.Z(); + + double M = N.Mass(); + double T = N.GetEnergy(); + double E = T + M; + + double vx, vy, vz; + vx = px*pow(c_light,2)/E; + vy = py*pow(c_light,2)/E; + vz = pz*pow(c_light,2)/E; + xk.SetX(vx); + xk.SetY(vy); + xk.SetZ(vz); + + TVector3 B = LoadMap(Pos); + double Bx, By, Bz; + Bx = B.X(); + By = B.Y(); + Bz = B.Z(); + double q = N.GetZ()*eplus; + pk.SetX(q*(vy*Bz - vz*By)); + pk.SetY(q*(vz*Bx - vx*Bz)); + pk.SetZ(q*(vx*By - vy*Bx)); + + return; +} + +////////////////////////////////////////////////////////////////////// +TVector3 GladFieldMap::CalculateIntersectionPoint(vector<TVector3> vPos){ + + unsigned int size = vPos.size(); + + // Track equation Z = a0*X + b0 + double a0, b0; + a0 = (vPos[size-1].Z() - vPos[size-100].Z()) / (vPos[size-1].X() - vPos[size-100].X()); + b0 = vPos[size-1].Z() - a0*vPos[size-1].X(); + + // MWPC3 equation Z_MWPC = a1*X_MWPC + b1 + double a1, b1; + a1 = tan(m_CentralTheta); + b1 = m_Z_MWPC3 - m_X_MWPC3*tan(m_CentralTheta); + + double Mx, My, Mz; + Mx = (b0 - b1) / (a1 -a0); + My = 0; + Mz = a0*Mx + b0; + + TVector3 M = TVector3(Mx,My,Mz); + return M; +} + +////////////////////////////////////////////////////////////////////// +TVector3 GladFieldMap::LoadMap(TVector3 Pos) { + + double Bx = 0; + double By = 0; + double Bz = 0; + + double Zinf = m_Z_Glad + Pos.X()*tan(m_Tilt) - m_Leff/2; + double Zsup = m_Z_Glad + Pos.X()*tan(m_Tilt) + m_Leff/2; + + if(Pos.Z()>Zinf && Pos.Z()<Zsup){ + Bx = m_Bfield.X(); + By = m_Bfield.Y(); + Bz = m_Bfield.Z(); + } + + TVector3 B = TVector3(Bx,By,Bz); + return B; +} + diff --git a/NPLib/Detectors/Sofia/GladFieldMap.h b/NPLib/Detectors/Sofia/GladFieldMap.h new file mode 100644 index 0000000000000000000000000000000000000000..d303692eee92b428e6a3a638715e1f1782a07d60 --- /dev/null +++ b/NPLib/Detectors/Sofia/GladFieldMap.h @@ -0,0 +1,99 @@ +#ifndef GladFieldMap_h +#define GladFieldMap_h +/***************************************************************************** + * Copyright (C) 2009-2020 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: Pierre Morfouace contact address: pierre.morfouace@cea.fr * + * * + * Creation Date : May 2022 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class hold a basic field map and is used for Brho reconstruction * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ + +// STL +#include <vector> +using namespace std; + +// ROOT +#include "TObject.h" +#include "TGraph.h" +#include "TVector3.h" +#include "Math/Minimizer.h" +#include "Math/Functor.h" + +#include "NPParticle.h" + +class GladFieldMap{ + public: + GladFieldMap(); + ~GladFieldMap(); + + private: + // GLAD parameters + TVector3 m_Bfield; + double m_Z_Glad; + double m_Leff; + double m_Tilt; + // MWPC3 paramters + double m_CentralTheta; + double m_X_MWPC3; + double m_Z_MWPC3; + // Runge-Kunta 4 paramaters + double m_dt; + int m_Limit; + double m_Zmax; + + TVector3 m_InitPos; + TVector3 m_InitDir; + TVector3 m_FinalPos; + + + public: + void SetBfield(TVector3 vec) {m_Bfield = vec;} + void SetZGlad(double val) {m_Z_Glad = val;} + void SetLeff(double val) {m_Leff = val;} + void SetGladTiltAngle(double val) {m_Tilt = val;} + + void SetCentralTheta(double val) {m_CentralTheta = val;} + void SetX_MWPC3(double val) {m_X_MWPC3 = val;} + void SetZ_MWPC3(double val) {m_Z_MWPC3 = val;} + + void SetPropagationTimeInterval(double val) {m_dt = val;} + void SetLimit(int val) {m_Limit = val;} + void SetPropagationMaxZ(double val) {m_Zmax = val;} + + void SetInitPos(TVector3 Pos) {m_InitPos = Pos;} + void SetInitDir(TVector3 Dir) {m_InitPos = Dir;} + + public: + TVector3 LoadMap(TVector3 pos); + TGraph* BrhoScan(double Brho_min, double Brho_max, double Brho_step); + TVector3 CalculateIntersectionPoint(vector<TVector3> vPos); + vector<TVector3> Propagate(double Brho, TVector3 Pos, TVector3 Dir); + void func(NPL::Particle& N, TVector3 Pos, TVector3 Imp, TVector3& xk, TVector3& pk); + double FindBrho(TVector3 Pos_init, TVector3 Dir_init, TVector3 Pos_final); + + private: + TGraph* m_BrhoScan; + ROOT::Math::Minimizer* m_min; + ROOT::Math::Functor m_func; + double Delta(const double* parameter); + + private: + + ClassDef(GladFieldMap,1) +}; + +#endif diff --git a/NPLib/Detectors/Sofia/TSofFissionFragment.cxx b/NPLib/Detectors/Sofia/TSofFissionFragment.cxx index 53be42bac83cd1d2b1727beddc71a5ac6b8f5c96..6e3c3b22e1aa5227a4e1bbfbe8faef0274444c8a 100644 --- a/NPLib/Detectors/Sofia/TSofFissionFragment.cxx +++ b/NPLib/Detectors/Sofia/TSofFissionFragment.cxx @@ -45,6 +45,7 @@ TSofFissionFragment::~TSofFissionFragment() { void TSofFissionFragment::Clear() { fFF_Z.clear(); fFF_iZ.clear(); + fFF_Plastic.clear(); fFF_AoQ.clear(); fFF_A.clear(); fFF_Beta.clear(); @@ -52,7 +53,9 @@ void TSofFissionFragment::Clear() { fFF_Gamma.clear(); fFF_Brho.clear(); fFF_DT.clear(); + fFF_Section.clear(); fFF_ThetaIn.clear(); + fFF_ThetaOut.clear(); fFF_TofPosX.clear(); fFF_TofPosY.clear(); fFF_PosX1.clear(); @@ -63,7 +66,7 @@ void TSofFissionFragment::Clear() { fFF_PosY3.clear(); fFF_Zsum = -1; - fFF_IntZsum = -1; + fFF_iZsum = -1; } diff --git a/NPLib/Detectors/Sofia/TSofFissionFragment.h b/NPLib/Detectors/Sofia/TSofFissionFragment.h index c265a6ccaf4da076973a8a0fb059595cdb9ced02..0ee84c937522866d2795ce1dc6cb47891902e85e 100644 --- a/NPLib/Detectors/Sofia/TSofFissionFragment.h +++ b/NPLib/Detectors/Sofia/TSofFissionFragment.h @@ -36,6 +36,7 @@ class TSofFissionFragment : public TObject { private: vector<double> fFF_Z; vector<int> fFF_iZ; + vector<int> fFF_Plastic; vector<double> fFF_AoQ; vector<double> fFF_A; vector<double> fFF_Beta; @@ -43,7 +44,9 @@ class TSofFissionFragment : public TObject { vector<double> fFF_Gamma; vector<double> fFF_Brho; vector<double> fFF_DT; + vector<int> fFF_Section; vector<double> fFF_ThetaIn; + vector<double> fFF_ThetaOut; vector<double> fFF_TofPosX; vector<double> fFF_TofPosY; vector<double> fFF_PosX1; @@ -53,7 +56,7 @@ class TSofFissionFragment : public TObject { vector<double> fFF_PosY2; vector<double> fFF_PosY3; double fFF_Zsum; - int fFF_IntZsum; + int fFF_iZsum; ////////////////////////////////////////////////////////////// // Constructor and destructor @@ -78,7 +81,8 @@ class TSofFissionFragment : public TObject { public: ////////////////////// SETTERS //////////////////////// inline void SetZsum(double val){fFF_Zsum = val;};//! - inline void SetIntZsum(int val){fFF_IntZsum = val;};//! + inline void SetiZsum(int val){fFF_iZsum = val;};//! + inline void SetPlastic(int val){fFF_Plastic.push_back(val);};//! inline void SetZ(double val){fFF_Z.push_back(val);};//! inline void SetiZ(int val){fFF_iZ.push_back(val);};//! inline void SetAoQ(double val){fFF_AoQ.push_back(val);};//! @@ -88,7 +92,9 @@ class TSofFissionFragment : public TObject { inline void SetGamma(double val){fFF_Gamma.push_back(val);};//! inline void SetBrho(double val){fFF_Brho.push_back(val);};//! inline void SetDT(double val){fFF_DT.push_back(val);};//! + inline void SetSection(int val){fFF_Section.push_back(val);};//! inline void SetThetaIn(double val){fFF_ThetaIn.push_back(val);};//! + inline void SetThetaOut(double val){fFF_ThetaOut.push_back(val);};//! inline void SetTofPosX(double val){fFF_TofPosX.push_back(val);};//! inline void SetTofPosY(double val){fFF_TofPosY.push_back(val);};//! inline void SetPosX1(double val){fFF_PosX1.push_back(val);};//! @@ -106,7 +112,8 @@ class TSofFissionFragment : public TObject { int GetMultMwpc2() {return fFF_PosY2.size();}//! int GetMultMwpc3() {return fFF_PosY3.size();}//! inline double GetZsum() const {return fFF_Zsum;}//! - inline int GetIntZsum() const {return fFF_IntZsum;}//! + inline int GetiZsum() const {return fFF_iZsum;}//! + inline int GetPlastic(int i) const {return fFF_Plastic[i];}//! inline double GetZ(int i) const {return fFF_Z[i];}//! inline int GetiZ(int i) const {return fFF_iZ[i];}//! inline double GetAoQ(int i) const {return fFF_AoQ[i];}//! @@ -116,7 +123,9 @@ class TSofFissionFragment : public TObject { inline double GetGamma(int i) const {return fFF_Gamma[i];}//! inline double GetBrho(int i) const {return fFF_Brho[i];}//! inline double GetDT(int i) const {return fFF_DT[i];}//! + inline double GetSection(int i) const {return fFF_Section[i];}//! inline double GetThetaIn(int i) const {return fFF_ThetaIn[i];}//! + inline double GetThetaOut(int i) const {return fFF_ThetaOut[i];}//! inline double GetTofPosX(int i) const {return fFF_TofPosX[i];}//! inline double GetTofPosY(int i) const {return fFF_TofPosY[i];}//! inline double GetPosX1(int i) const {return fFF_PosX1[i];}//! diff --git a/NPLib/Detectors/Sofia/TSofMwpcPhysics.cxx b/NPLib/Detectors/Sofia/TSofMwpcPhysics.cxx index a7351c1f4706fe5cd7254ed080b3a246d21400ea..2bf422432ae545051d531c7c1b1765b8d05d6eff 100644 --- a/NPLib/Detectors/Sofia/TSofMwpcPhysics.cxx +++ b/NPLib/Detectors/Sofia/TSofMwpcPhysics.cxx @@ -209,40 +209,52 @@ void TSofMwpcPhysics::BuildPhysicalEvent() { } - if(fClusterX.size()==fClusterY.size()){ - int size = fClusterX.size(); - vector<double> Xpos; - vector<double> Ypos; - for(unsigned int i=0; i<size; i++){ - // *** strip X *** // - vector<pair<int,int>> hitX; - hitX = fClusterX[i]; - double x = -1000; - int qleft = hitX[0].second; - int qmax = hitX[1].second; - int qright = hitX[2].second; - int padmax = hitX[2].first; - if(padmax>0 && padmax+1<288 && qmax>0 && qleft>0 && qright>0){ - x = GetPositionX(det_num, qmax, padmax, qleft, qright); - Xpos.push_back(x); - } - - // *** strip Y *** // - vector<pair<int,int>> hitY; - hitY = fClusterY[i]; - double y = -1000; - int qdown = hitY[0].second; - qmax = hitY[1].second; - int qup = hitY[2].second; - padmax = hitY[2].first; - if(padmax>0 && padmax+1<120 && qmax>0 && qdown>0 && qup>0){ - y = GetPositionY(det_num, qmax, padmax, qdown, qup); - Ypos.push_back(y); - } + // *** strip X *** // + int sizeX = fClusterX.size(); + vector<double> Xpos; + for(unsigned int i=0; i<sizeX; i++){ + vector<pair<int,int>> hitX; + hitX = fClusterX[i]; + double x = -1000; + int qleft = hitX[0].second; + int qmax = hitX[1].second; + int qright = hitX[2].second; + int padmax = hitX[2].first; + if(padmax>0 && padmax+1<288 && qmax>0 && qleft>0 && qright>0){ + x = GetPositionX(det_num, qmax, padmax, qleft, qright); + Xpos.push_back(x); + } + } + + // *** strip Y *** // + int sizeY = fClusterY.size(); + vector<double> Ypos; + for(unsigned int i=0; i<sizeY; i++){ + vector<pair<int,int>> hitY; + hitY = fClusterY[i]; + double y = -1000; + int qdown = hitY[0].second; + int qmax = hitY[1].second; + int qup = hitY[2].second; + int padmax = hitY[2].first; + if(padmax>0 && padmax+1<120 && qmax>0 && qdown>0 && qup>0){ + y = GetPositionY(det_num, qmax, padmax, qdown, qup); + Ypos.push_back(y); + } + } + + for(unsigned int i=0; i<Xpos.size(); i++){ + if(Xpos.size()==Ypos.size()){ + DetectorNbr.push_back(det_num); + PositionX1.push_back(Xpos[i]); + PositionX2.push_back(-1000); + PositionY.push_back(Ypos[i]); + } + else{ DetectorNbr.push_back(det_num); - PositionX1.push_back(x); + PositionX1.push_back(Xpos[i]); PositionX2.push_back(-1000); - PositionY.push_back(y); + PositionY.push_back(-1000); } } } diff --git a/NPLib/Detectors/Sofia/TSofTwimPhysics.cxx b/NPLib/Detectors/Sofia/TSofTwimPhysics.cxx index 8904b0635ef71c468ed1f29411e63e92fc09c7d4..449d8db1f165ded371fd73b46dea93f2bf874751 100644 --- a/NPLib/Detectors/Sofia/TSofTwimPhysics.cxx +++ b/NPLib/Detectors/Sofia/TSofTwimPhysics.cxx @@ -93,10 +93,15 @@ void TSofTwimPhysics::BuildPhysicalEvent() { double Esec2=0; double Esec3=0; double Esec4=0; + double Theta1=-10; + double Theta2=-10; + double Theta3=-10; + double Theta4=-10; double DTsec1=-1e6; double DTsec2=-1e6; double DTsec3=-1e6; double DTsec4=-1e6; + double AnodeDriftTime[4][16]; unsigned int mysizeE = m_PreTreatedData->GetMultiplicity(); for (UShort_t e = 0; e < mysizeE ; e++) { @@ -112,6 +117,8 @@ void TSofTwimPhysics::BuildPhysicalEvent() { AnodeEnergy.push_back(Energy); AnodeDT.push_back(DT); + AnodeDriftTime[SectionNbr-1][AnodeNumber-1] = DT; + if(SectionNbr==1){ anode_energy_sec1.push_back(Energy); if(AnodeNumber==8) @@ -166,24 +173,36 @@ void TSofTwimPhysics::BuildPhysicalEvent() { EnergySection.push_back(Esec1); DriftTime.push_back(DTsec1); SectionNbr.push_back(1); + + Theta1 = atan((AnodeDriftTime[0][11]-AnodeDriftTime[0][3])/(7*31.)); + Theta.push_back(-Theta1); } if(Esec2>0){ Esec2 = Cal->ApplyCalibration("SofTwim/SEC2_ALIGN",Esec2); EnergySection.push_back(Esec2); DriftTime.push_back(DTsec2); SectionNbr.push_back(2); + + Theta2 = atan((AnodeDriftTime[1][11]-AnodeDriftTime[1][3])/(7*31.)); + Theta.push_back(-Theta2); } if(Esec3>0){ Esec3 = Cal->ApplyCalibration("SofTwim/SEC3_ALIGN",Esec3); EnergySection.push_back(Esec3); DriftTime.push_back(DTsec3); SectionNbr.push_back(3); + + Theta3 = atan((AnodeDriftTime[2][11]-AnodeDriftTime[2][3])/(7*31.)); + Theta.push_back(-Theta3); } if(Esec4>0){ Esec4 = Cal->ApplyCalibration("SofTwim/SEC4_ALIGN",Esec4); EnergySection.push_back(Esec4); DriftTime.push_back(DTsec4); SectionNbr.push_back(4); + + Theta4 = atan((AnodeDriftTime[3][11]-AnodeDriftTime[3][3])/(7*31.)); + Theta.push_back(-Theta4); } m_Beta = -1; @@ -310,6 +329,7 @@ void TSofTwimPhysics::Clear() { AnodeSecNbr.clear(); AnodeEnergy.clear(); AnodeDT.clear(); + Theta.clear(); mult1 = 0; mult2 = 0; diff --git a/NPLib/Detectors/Sofia/TSofTwimPhysics.h b/NPLib/Detectors/Sofia/TSofTwimPhysics.h index 865d2f761de938098ac2790560c9d8ee82f8d4c8..ac10c26c971c73e9ef29cf39fc15f9339c4708e6 100644 --- a/NPLib/Detectors/Sofia/TSofTwimPhysics.h +++ b/NPLib/Detectors/Sofia/TSofTwimPhysics.h @@ -63,6 +63,7 @@ class TSofTwimPhysics : public TObject, public NPL::VDetector { vector<int> SectionNbr; vector<double> EnergySection; vector<double> DriftTime; + vector<double> Theta; vector<int> AnodeNbr; vector<int> AnodeSecNbr; vector<double> AnodeEnergy; diff --git a/NPLib/Detectors/SuperX3/CMakeLists.txt b/NPLib/Detectors/SuperX3/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..9615752a24b8fa9397ccb6a3806a5eab0ca0835a --- /dev/null +++ b/NPLib/Detectors/SuperX3/CMakeLists.txt @@ -0,0 +1,6 @@ +add_custom_command(OUTPUT TSuperX3PhysicsDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TSuperX3Physics.h TSuperX3PhysicsDict.cxx TSuperX3Physics.rootmap libNPSuperX3.dylib DEPENDS TSuperX3Physics.h) +add_custom_command(OUTPUT TSuperX3DataDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TSuperX3Data.h TSuperX3DataDict.cxx TSuperX3Data.rootmap libNPSuperX3.dylib DEPENDS TSuperX3Data.h) +add_library(NPSuperX3 SHARED TSuperX3Spectra.cxx TSuperX3Data.cxx TSuperX3Physics.cxx TSuperX3DataDict.cxx TSuperX3PhysicsDict.cxx ) +target_link_libraries(NPSuperX3 ${ROOT_LIBRARIES} NPCore) +install(FILES TSuperX3Data.h TSuperX3Physics.h TSuperX3Spectra.h DESTINATION ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}) + diff --git a/NPLib/Detectors/SuperX3/TSuperX3Data.cxx b/NPLib/Detectors/SuperX3/TSuperX3Data.cxx new file mode 100644 index 0000000000000000000000000000000000000000..24a63b65312bb8fbe7cd585ed40755414ca14b9a --- /dev/null +++ b/NPLib/Detectors/SuperX3/TSuperX3Data.cxx @@ -0,0 +1,64 @@ +/***************************************************************************** + * 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: N. de Sereville contact address: deserevi@ipno.in2p3.fr * + * * + * Creation Date : january 2011 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class holds the raw data storage for the SuperX3 detector from Micron * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ +#include "TSuperX3Data.h" + +#include <iostream> +using namespace std; + +ClassImp(TSuperX3Data) + + TSuperX3Data::TSuperX3Data() { + // Default constructor + Clear(); +} + +TSuperX3Data::~TSuperX3Data() {} + +void TSuperX3Data::Clear() { + // (Up, E) + fSuperX3_UpE_DetectorNbr.clear(); + fSuperX3_UpE_StripNbr.clear(); + fSuperX3_UpE_Energy.clear(); + // (Up, T) + fSuperX3_UpT_DetectorNbr.clear(); + fSuperX3_UpT_StripNbr.clear(); + fSuperX3_UpT_Time.clear(); + // (Down, E) + fSuperX3_DownE_DetectorNbr.clear(); + fSuperX3_DownE_StripNbr.clear(); + fSuperX3_DownE_Energy.clear(); + // (Down, T) + fSuperX3_DownT_DetectorNbr.clear(); + fSuperX3_DownT_StripNbr.clear(); + fSuperX3_DownT_Time.clear(); + + // (Back, E) + fSuperX3_BackE_DetectorNbr.clear(); + fSuperX3_BackE_StripNbr.clear(); + fSuperX3_BackE_Energy.clear(); + // (Back, T) + fSuperX3_BackT_DetectorNbr.clear(); + fSuperX3_BackT_StripNbr.clear(); + fSuperX3_BackT_Time.clear(); +} + +void TSuperX3Data::Dump() const {} diff --git a/NPLib/Detectors/SuperX3/TSuperX3Data.h b/NPLib/Detectors/SuperX3/TSuperX3Data.h new file mode 100644 index 0000000000000000000000000000000000000000..37683329a606b91adc28d6a4891508e7a82d33f8 --- /dev/null +++ b/NPLib/Detectors/SuperX3/TSuperX3Data.h @@ -0,0 +1,144 @@ +#ifndef __SuperX3DATA__ +#define __SuperX3DATA__ +/***************************************************************************** + * 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: N. de Sereville contact address: deserevi@ipno.in2p3.fr * + * * + * Creation Date : january 2011 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class holds the raw data storage for the SuperX3 detector from Micron * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ +// C++ headers +#include <vector> +using namespace std; + +// ROOT headers +#include "TObject.h" + +class TSuperX3Data : public TObject { + private: + // Front + // Up + // Energy + vector<UShort_t> fSuperX3_UpE_DetectorNbr; + vector<UShort_t> fSuperX3_UpE_StripNbr; + vector<Double_t> fSuperX3_UpE_Energy; + // Time + vector<UShort_t> fSuperX3_UpT_DetectorNbr; + vector<UShort_t> fSuperX3_UpT_StripNbr; + vector<Double_t> fSuperX3_UpT_Time; + // Energy + vector<UShort_t> fSuperX3_DownE_DetectorNbr; + vector<UShort_t> fSuperX3_DownE_StripNbr; + vector<Double_t> fSuperX3_DownE_Energy; + // Time + vector<UShort_t> fSuperX3_DownT_DetectorNbr; + vector<UShort_t> fSuperX3_DownT_StripNbr; + vector<Double_t> fSuperX3_DownT_Time; + + // Back + // Energy + vector<Double_t> fSuperX3_BackE_Energy; + vector<UShort_t> fSuperX3_BackE_StripNbr; + vector<UShort_t> fSuperX3_BackE_DetectorNbr; + // Time + vector<Double_t> fSuperX3_BackT_Time; + vector<UShort_t> fSuperX3_BackT_StripNbr; + vector<UShort_t> fSuperX3_BackT_DetectorNbr; + + public: + TSuperX3Data(); + virtual ~TSuperX3Data(); + + void Clear(); + void Clear(const Option_t*){}; + void Dump() const; + + ///////////////////// SETTERS //////////////////////// + // up + void SetUpE(UShort_t DetNbr, UShort_t StripNbr, Double_t Energy) { + fSuperX3_UpE_DetectorNbr.push_back(DetNbr); + fSuperX3_UpE_StripNbr.push_back(StripNbr); + fSuperX3_UpE_Energy.push_back(Energy); + } + void SetUpT(UShort_t DetNbr, UShort_t StripNbr, Double_t Time) { + fSuperX3_UpT_DetectorNbr.push_back(DetNbr); + fSuperX3_UpT_StripNbr.push_back(StripNbr); + fSuperX3_UpT_Time.push_back(Time); + } + // down + void SetDownE(UShort_t DetNbr, UShort_t StripNbr, Double_t Energy) { + fSuperX3_DownE_DetectorNbr.push_back(DetNbr); + fSuperX3_DownE_StripNbr.push_back(StripNbr); + fSuperX3_DownE_Energy.push_back(Energy); + } + void SetDownT(UShort_t DetNbr, UShort_t StripNbr, Double_t Time) { + fSuperX3_DownT_DetectorNbr.push_back(DetNbr); + fSuperX3_DownT_StripNbr.push_back(StripNbr); + fSuperX3_DownT_Time.push_back(Time); + } + + // Back E + void SetBackE(UShort_t DetNbr, UShort_t StripNbr, Double_t Energy) { + fSuperX3_BackE_DetectorNbr.push_back(DetNbr); + fSuperX3_BackE_StripNbr.push_back(StripNbr); + fSuperX3_BackE_Energy.push_back(Energy); + } + // Back T + void SetBackT(UShort_t DetNbr, UShort_t StripNbr, Double_t Time) { + fSuperX3_BackT_DetectorNbr.push_back(DetNbr); + fSuperX3_BackT_StripNbr.push_back(StripNbr); + fSuperX3_BackT_Time.push_back(Time); + } + + ///////////////////// GETTERS //////////////////////// + // DSSD + // (Up, E) + UShort_t GetUpEMult() const { return fSuperX3_UpE_DetectorNbr.size(); } + UShort_t GetUpEDetectorNbr(Int_t i) const { return fSuperX3_UpE_DetectorNbr[i]; } + UShort_t GetUpEStripNbr(Int_t i) const { return fSuperX3_UpE_StripNbr[i]; } + Double_t GetUpEEnergy(Int_t i) const { return fSuperX3_UpE_Energy[i]; } + // (Up, T) + UShort_t GetUpTMult() const { return fSuperX3_UpT_DetectorNbr.size(); } + UShort_t GetUpTDetectorNbr(Int_t i) const { return fSuperX3_UpT_DetectorNbr[i]; } + UShort_t GetUpTStripNbr(Int_t i) const { return fSuperX3_UpT_StripNbr[i]; } + Double_t GetUpTTime(Int_t i) const { return fSuperX3_UpT_Time[i]; } + // (Down, E) + UShort_t GetDownEMult() const { return fSuperX3_DownE_DetectorNbr.size(); } + UShort_t GetDownEDetectorNbr(Int_t i) const { return fSuperX3_DownE_DetectorNbr[i]; } + UShort_t GetDownEStripNbr(Int_t i) const { return fSuperX3_DownE_StripNbr[i]; } + Double_t GetDownEEnergy(Int_t i) const { return fSuperX3_DownE_Energy[i]; } + // (Down, T) + UShort_t GetDownTMult() const { return fSuperX3_DownT_DetectorNbr.size(); } + UShort_t GetDownTDetectorNbr(Int_t i) const { return fSuperX3_DownT_DetectorNbr[i]; } + UShort_t GetDownTStripNbr(Int_t i) const { return fSuperX3_DownT_StripNbr[i]; } + Double_t GetDownTTime(Int_t i) const { return fSuperX3_DownT_Time[i]; } + + // (Back, E) + UShort_t GetBackEMult() const { return fSuperX3_BackE_DetectorNbr.size(); } + UShort_t GetBackEDetectorNbr(Int_t i) const { return fSuperX3_BackE_DetectorNbr[i]; } + UShort_t GetBackEStripNbr(Int_t i) const { return fSuperX3_BackE_StripNbr[i]; } + Double_t GetBackEEnergy(Int_t i) const { return fSuperX3_BackE_Energy[i]; } + // (Back, T) + UShort_t GetBackTMult() const { return fSuperX3_BackT_DetectorNbr.size(); } + UShort_t GetBackTDetectorNbr(Int_t i) const { return fSuperX3_BackT_DetectorNbr[i]; } + UShort_t GetBackTStripNbr(Int_t i) const { return fSuperX3_BackT_StripNbr[i]; } + Double_t GetBackTTime(Int_t i) const { return fSuperX3_BackT_Time[i]; } + + ClassDef(TSuperX3Data, 1) // TSuperX3Data raw data +}; + +#endif diff --git a/NPLib/Detectors/SuperX3/TSuperX3Physics.cxx b/NPLib/Detectors/SuperX3/TSuperX3Physics.cxx new file mode 100644 index 0000000000000000000000000000000000000000..0d21f4073abf7a158a93b8d19066a3b39716af0b --- /dev/null +++ b/NPLib/Detectors/SuperX3/TSuperX3Physics.cxx @@ -0,0 +1,698 @@ +/***************************************************************************** + * 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 : november 2009 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class hold SuperX3 Physics * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ +// NPL +#include "TSuperX3Physics.h" +using namespace SuperX3_LOCAL; + +// STL +#include <cmath> +#include <fstream> +#include <iostream> +#include <limits> +#include <sstream> +#include <stdlib.h> +using namespace std; + +// NPTOOL +#include "NPDetectorFactory.h" +#include "NPOptionManager.h" +#include "RootInput.h" +#include "RootOutput.h" + +// ROOT +#include "TChain.h" + +ClassImp(TSuperX3Physics) + + /////////////////////////////////////////////////////////////////////////// + TSuperX3Physics::TSuperX3Physics() + : m_EventData(new TSuperX3Data), m_PreTreatedData(new TSuperX3Data), m_EventPhysics(this), m_Spectra(0), + m_nCounter(10), m_MaximumStripMultiplicityAllowed(1), // multiplidity 1 + m_StripEnergyMatchingSigma(0.060), // MeV + m_StripEnergyMatchingNumberOfSigma(5), // MeV + m_FrontE_Raw_Threshold(0), // adc channels + m_BackE_Raw_Threshold(0), // adc channels + m_FrontE_Calib_Threshold(0), // MeV + m_BackE_Calib_Threshold(0), // MeV + m_NumberOfDetectors(0), m_SiliconFace(49.6), // mm + m_NumberOfStrips(16) { + m_StripPitch = m_SiliconFace / (double)m_NumberOfStrips; + + for (Int_t i = 0; i < m_nCounter; ++i) { // loop on counters + m_Counter[i] = 0; + } // end loop on counters +} + +/////////////////////////////////////////////////////////////////////////// +// TSuperX3Physics::~TSuperX3Physics() +//{ +// delete m_EventData; +// delete m_PreTreatedData; +//} + +/////////////////////////////////////////////////////////////////////////// +void TSuperX3Physics::Clear() { + fEventType.clear(); + fDetectorNumber.clear(); + fFrontEnergy.clear(); + fBackEnergy.clear(); + fHalfEnergy.clear(); + fFrontTime.clear(); + fBackTime.clear(); + fFrontStrip.clear(); + fBackStrip.clear(); + + for (Int_t i = 0; i < m_nCounter; ++i) { // loop on counters + m_Counter[i] = 0; + } // end loop on counters +} + +/////////////////////////////////////////////////////////////////////////// +void TSuperX3Physics::ReadConfiguration(NPL::InputParser parser) { + vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithToken("SuperX3"); + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks.size() << " detectors found " << endl; + for (unsigned int i = 0; i < blocks.size(); i++) { + // Cartesian Case + vector<string> cart = {"X1_Y1", "X1_Y16", "X16_Y1", "X16_Y16"}; + // Spherical Case + vector<string> sphe = {"R", "THETA", "PHI", "BETA"}; + + if (blocks[i]->HasTokenList(cart)) { + cout << endl << "//// SuperX3 " << i + 1 << endl; + TVector3 A = blocks[i]->GetTVector3("X1_Y1", "mm"); + TVector3 B = blocks[i]->GetTVector3("X16_Y1", "mm"); + TVector3 C = blocks[i]->GetTVector3("X1_Y16", "mm"); + TVector3 D = blocks[i]->GetTVector3("X16_Y16", "mm"); + AddDetector(A, B, C, D); + } + + else if (blocks[i]->HasTokenList(sphe)) { + double Theta = blocks[i]->GetDouble("THETA", "deg"); + double Phi = blocks[i]->GetDouble("PHI", "deg"); + double R = blocks[i]->GetDouble("R", "mm"); + vector<double> beta = blocks[i]->GetVectorDouble("BETA", "deg"); + AddDetector(Theta, Phi, R, beta[0], beta[1], beta[2]); + } + + else { + cout << "ERROR: Missing token for SuperX3 blocks, check your input file" << endl; + exit(1); + } + } + + InitializeStandardParameters(); + ReadAnalysisConfig(); +} + +/////////////////////////////////////////////////////////////////////////// +void TSuperX3Physics::AddParameterToCalibrationManager() { + CalibrationManager* Cal = CalibrationManager::getInstance(); + + for (Int_t i = 0; i < m_NumberOfDetectors; i++) { + for (Int_t j = 0; j < m_NumberOfStrips; j++) { + // Energy + Cal->AddParameter("SuperX3", "D" + NPL::itoa(i + 1) + "_Front" + NPL::itoa(j) + "_E", + "SuperX3_D" + NPL::itoa(i + 1) + "_FRONT" + NPL::itoa(j) + "_E"); + Cal->AddParameter("SuperX3", "D" + NPL::itoa(i + 1) + "_Back" + NPL::itoa(j) + "_E", + "SuperX3_D" + NPL::itoa(i + 1) + "_BACK" + NPL::itoa(j) + "_E"); + // Time + Cal->AddParameter("SuperX3", "D" + NPL::itoa(i + 1) + "_Front" + NPL::itoa(j) + "_T", + "SuperX3_D" + NPL::itoa(i + 1) + "_FRONT" + NPL::itoa(j) + "_T"); + Cal->AddParameter("SuperX3", "D" + NPL::itoa(i + 1) + "_Back" + NPL::itoa(j) + "_T", + "SuperX3_D" + NPL::itoa(i + 1) + "_BACK" + NPL::itoa(j) + "_T"); + } + } +} + +/////////////////////////////////////////////////////////////////////////// +void TSuperX3Physics::InitializeRootInputRaw() { + TChain* inputChain = RootInput::getInstance()->GetChain(); + inputChain->SetBranchStatus("SuperX3", true); + inputChain->SetBranchStatus("fSuperX3_*", true); + inputChain->SetBranchAddress("SuperX3", &m_EventData); +} + +/////////////////////////////////////////////////////////////////////////// +void TSuperX3Physics::InitializeRootInputPhysics() { + TChain* inputChain = RootInput::getInstance()->GetChain(); + inputChain->SetBranchStatus("SuperX3", true); + inputChain->SetBranchStatus("fEventType", true); + inputChain->SetBranchStatus("fDetectorNumber", true); + inputChain->SetBranchStatus("fEnergy", true); + inputChain->SetBranchStatus("fTime", true); + inputChain->SetBranchStatus("fFrontStrip", true); + inputChain->SetBranchStatus("fBackStrip", true); + inputChain->SetBranchAddress("SuperX3", &m_EventPhysics); +} + +/////////////////////////////////////////////////////////////////////////// +void TSuperX3Physics::InitializeRootOutput() { + TTree* outputTree = RootOutput::getInstance()->GetTree(); + outputTree->Branch("SuperX3", "TSuperX3Physics", &m_EventPhysics); +} + +void TSuperX3Physics::AddDetector(TVector3 C_X1_Y1, TVector3 C_X16_Y1, TVector3 C_X1_Y16, TVector3 C_X16_Y16) { + m_NumberOfDetectors++; + + // remove warning using C_X16_Y16 + C_X16_Y16.Unit(); + + // Vector U on Module Face (paralelle to Y Strip) (NB: remember that Y strip are allong X axis) + TVector3 U = C_X16_Y1 - C_X1_Y1; + U = U.Unit(); + + // Vector V on Module Face (parallele to X Strip) + TVector3 V = C_X1_Y16 - C_X1_Y1; + V = V.Unit(); + + // Position Vector of Strip Center + TVector3 StripCenter = TVector3(0, 0, 0); + // Position Vector of X=1 Y=1 Strip + TVector3 Strip_1_1; + + // Buffer object to fill Position Array + vector<double> lineX; + vector<double> lineY; + vector<double> lineZ; + + vector<vector<double>> OneModuleStripPositionX; + vector<vector<double>> OneModuleStripPositionY; + vector<vector<double>> OneModuleStripPositionZ; + + // Moving StripCenter to 1.1 corner: + Strip_1_1 = C_X1_Y1 + (U + V) * (m_StripPitch / 2.); + + for (int i = 0; i < m_NumberOfStrips; i++) { + lineX.clear(); + lineY.clear(); + lineZ.clear(); + + for (int j = 0; j < m_NumberOfStrips; j++) { + StripCenter = Strip_1_1 + m_StripPitch * (i * U + j * V); + + lineX.push_back(StripCenter.X()); + lineY.push_back(StripCenter.Y()); + lineZ.push_back(StripCenter.Z()); + } + + OneModuleStripPositionX.push_back(lineX); + OneModuleStripPositionY.push_back(lineY); + OneModuleStripPositionZ.push_back(lineZ); + } + + m_StripPositionX.push_back(OneModuleStripPositionX); + m_StripPositionY.push_back(OneModuleStripPositionY); + m_StripPositionZ.push_back(OneModuleStripPositionZ); +} + +void TSuperX3Physics::AddDetector(double theta, double phi, double distance, double beta_u, double beta_v, + double beta_w) { + m_NumberOfDetectors++; + + // convert from degree to radian: + theta *= M_PI / 180; + phi *= M_PI / 180; + + // Vector U on Module Face (paralelle to Y Strip) (NB: remember that Y strip are allong X axis) + TVector3 U; + // Vector V on Module Face (parallele to X Strip) + TVector3 V; + // Vector W normal to Module Face (pointing CsI) + TVector3 W; + // Vector position of Module Face center + TVector3 C; + + C = TVector3(distance * sin(theta) * cos(phi), distance * sin(theta) * sin(phi), distance * cos(theta)); + + TVector3 YperpW = TVector3(cos(theta) * cos(phi), cos(theta) * sin(phi), -sin(theta)); + + W = C.Unit(); + U = W.Cross(YperpW); + V = W.Cross(U); + + U = U.Unit(); + V = V.Unit(); + + U.Rotate(beta_u * M_PI / 180, U); + V.Rotate(beta_u * M_PI / 180, U); + + U.Rotate(beta_v * M_PI / 180, V); + V.Rotate(beta_v * M_PI / 180, V); + + U.Rotate(beta_w * M_PI / 180, W); + V.Rotate(beta_w * M_PI / 180, W); + + // Position Vector of Strip Center + TVector3 StripCenter = TVector3(0, 0, 0); + // Position Vector of X=1 Y=1 Strip + TVector3 Strip_1_1; + + vector<double> lineX; + vector<double> lineY; + vector<double> lineZ; + + vector<vector<double>> OneModuleStripPositionX; + vector<vector<double>> OneModuleStripPositionY; + vector<vector<double>> OneModuleStripPositionZ; + + // Moving C to the 1.1 corner: + Strip_1_1 = C - 0.5 * (m_SiliconFace - m_StripPitch) * (U + V); + + for (int i = 0; i < m_NumberOfStrips; i++) { + lineX.clear(); + lineY.clear(); + lineZ.clear(); + + for (int j = 0; j < m_NumberOfStrips; j++) { + StripCenter = Strip_1_1 + m_StripPitch * (i * U + j * V); + + lineX.push_back(StripCenter.X()); + lineY.push_back(StripCenter.Y()); + lineZ.push_back(StripCenter.Z()); + } + + OneModuleStripPositionX.push_back(lineX); + OneModuleStripPositionY.push_back(lineY); + OneModuleStripPositionZ.push_back(lineZ); + } + + m_StripPositionX.push_back(OneModuleStripPositionX); + m_StripPositionY.push_back(OneModuleStripPositionY); + m_StripPositionZ.push_back(OneModuleStripPositionZ); +} + +TVector3 TSuperX3Physics::GetPositionOfInteraction(int i) { + TVector3 Position = TVector3(GetStripPositionX(fDetectorNumber[i], fFrontStrip[i], fBackStrip[i]), + GetStripPositionY(fDetectorNumber[i], fFrontStrip[i], fBackStrip[i]), + GetStripPositionZ(fDetectorNumber[i], fFrontStrip[i], fBackStrip[i])); + + return Position; +} + +TVector3 TSuperX3Physics::GetDetectorNormal(int i) { + TVector3 U = TVector3(GetStripPositionX(fDetectorNumber[i], m_NumberOfStrips, 1), + GetStripPositionY(fDetectorNumber[i], m_NumberOfStrips, 1), + GetStripPositionZ(fDetectorNumber[i], m_NumberOfStrips, 1)) + + - TVector3(GetStripPositionX(fDetectorNumber[i], 1, 1), GetStripPositionY(fDetectorNumber[i], 1, 1), + GetStripPositionZ(fDetectorNumber[i], 1, 1)); + + TVector3 V = TVector3(GetStripPositionX(fDetectorNumber[i], m_NumberOfStrips, m_NumberOfStrips), + GetStripPositionY(fDetectorNumber[i], m_NumberOfStrips, m_NumberOfStrips), + GetStripPositionZ(fDetectorNumber[i], m_NumberOfStrips, m_NumberOfStrips)) + + - TVector3(GetStripPositionX(fDetectorNumber[i], m_NumberOfStrips, 1), + GetStripPositionY(fDetectorNumber[i], m_NumberOfStrips, 1), + GetStripPositionZ(fDetectorNumber[i], m_NumberOfStrips, 1)); + + TVector3 Normal = U.Cross(V); + + return Normal.Unit(); +} + +void TSuperX3Physics::DumpStrippingScheme(Int_t detecNumber) { + cout << endl << "TSuperX3Physics::DumpStrippingScheme()" << endl; + cout << "Detector number " << detecNumber << endl; + + for (int i = 1; i < m_NumberOfStrips + 1; i++) { // front part + for (int j = 1; j < m_NumberOfStrips + 1; j++) { // back part + cout << "strips Front, Back: " << i << " " << j + << "\t--->\t (X,Y,Z) mm: " << GetStripPositionX(detecNumber, i, j) << "\t" + << GetStripPositionY(detecNumber, i, j) << "\t" << GetStripPositionZ(detecNumber, i, j) << endl; + } + } +} + +/////////////////////////////////////////////////////////////////////////// +void TSuperX3Physics::BuildPhysicalEvent() { BuildSimplePhysicalEvent(); } + +/////////////////////////////////////////////////////////////////////////// +void TSuperX3Physics::BuildSimplePhysicalEvent() { + // Select active channels and apply thresholds + PreTreat(); + /* m_Counter[0] = 1; + + // Begin treatement + Int_t evtType = EventType(); + + if (evtType == 1) { // case where multiplicity front = multiplicity back + m_Counter[1] = 1; + vector<TVector2> couple = Match_Front_Back(); + + for (UShort_t i = 0; i < couple.size(); i++) { // loop on selected events + Int_t DetecNbr = m_PreTreatedData->GetFrontEDetectorNbr(couple[i].X()); + Int_t StripFront = m_PreTreatedData->GetFrontEStripNbr(couple[i].X()); + Int_t StripBack = m_PreTreatedData->GetBackEStripNbr(couple[i].Y()); + Double_t EnergyFront = m_PreTreatedData->GetFrontEEnergy(couple[i].X()); + Double_t EnergyBack = m_PreTreatedData->GetBackEEnergy(couple[i].Y()); + + // Search for associate time + // Front + Double_t TimeFront = -1000; + for (UShort_t t = 0; t < m_PreTreatedData->GetFrontTMult(); t++) { + if (m_PreTreatedData->GetFrontTStripNbr(couple[i].X()) == m_PreTreatedData->GetFrontTStripNbr(t) && + m_PreTreatedData->GetFrontTDetectorNbr(couple[i].X()) == m_PreTreatedData->GetFrontTDetectorNbr(t)) { + TimeFront = m_PreTreatedData->GetFrontTTime(t); + m_Counter[4] = 1; + } + } + // Back + Double_t TimeBack = -1000; + for (UShort_t t = 0; t < m_PreTreatedData->GetBackTMult(); t++) { + if (m_PreTreatedData->GetBackTStripNbr(couple[i].Y()) == m_PreTreatedData->GetBackTStripNbr(t) && + m_PreTreatedData->GetBackTDetectorNbr(couple[i].Y()) == m_PreTreatedData->GetBackTDetectorNbr(t)) + TimeBack = m_PreTreatedData->GetBackTTime(t); + } + + // Fill TSuperX3Physics private members + fEventType.push_back(evtType); + fDetectorNumber.push_back(DetecNbr); + fFrontEnergy.push_back(EnergyFront); + fBackEnergy.push_back(EnergyBack); + fHalfEnergy.push_back((EnergyFront + EnergyBack) / 2); + fFrontTime.push_back(TimeFront); + fBackTime.push_back(TimeBack); + fFrontStrip.push_back(StripFront); + fBackStrip.push_back(StripBack); + } + }*/ +} + +/////////////////////////////////////////////////////////////////////////// +void TSuperX3Physics::PreTreat() { + // Clear pre treated object + ClearPreTreatedData(); + /* + // (Front, E) + for (UShort_t i = 0; i < m_EventData->GetFrontEMult(); i++) { + if (IsValidChannel("Front", m_EventData->GetFrontEDetectorNbr(i), m_EventData->GetFrontEStripNbr(i)) && + m_EventData->GetFrontEEnergy(i) > m_FrontE_Raw_Threshold) { + Double_t E = fSuperX3_Front_E(m_EventData, i); + if (E > m_FrontE_Calib_Threshold) { + m_PreTreatedData->SetFrontEDetectorNbr(m_EventData->GetFrontEDetectorNbr(i)); + m_PreTreatedData->SetFrontEStripNbr(m_EventData->GetFrontEStripNbr(i)); + m_PreTreatedData->SetFrontEEnergy(E); + } + } + } + // (Front, T) + for (UShort_t i = 0; i < m_EventData->GetFrontTMult(); i++) { + if (IsValidChannel("Front", m_EventData->GetFrontTDetectorNbr(i), m_EventData->GetFrontTStripNbr(i))) { + Double_t T = fSuperX3_Front_T(m_EventData, i); + m_PreTreatedData->SetFrontTDetectorNbr(m_EventData->GetFrontTDetectorNbr(i)); + m_PreTreatedData->SetFrontTStripNbr(m_EventData->GetFrontTStripNbr(i)); + m_PreTreatedData->SetFrontTTime(T); + } + } + + // (Back, E) + for (UShort_t i = 0; i < m_EventData->GetBackEMult(); i++) { + if (IsValidChannel("Back", m_EventData->GetBackEDetectorNbr(i), m_EventData->GetBackEStripNbr(i)) && + m_EventData->GetBackEEnergy(i) > m_BackE_Raw_Threshold) { + Double_t E = fSuperX3_Back_E(m_EventData, i); + if (E > m_BackE_Calib_Threshold) { + m_PreTreatedData->SetBackEDetectorNbr(m_EventData->GetBackEDetectorNbr(i)); + m_PreTreatedData->SetBackEStripNbr(m_EventData->GetBackEStripNbr(i)); + m_PreTreatedData->SetBackEEnergy(E); + } + } + } + // (Back, T) + for (UShort_t i = 0; i < m_EventData->GetBackTMult(); i++) { + if (IsValidChannel("Back", m_EventData->GetBackTDetectorNbr(i), m_EventData->GetBackTStripNbr(i))) { + Double_t T = fSuperX3_Back_T(m_EventData, i); + m_PreTreatedData->SetBackTDetectorNbr(m_EventData->GetBackTDetectorNbr(i)); + m_PreTreatedData->SetBackTStripNbr(m_EventData->GetBackTStripNbr(i)); + m_PreTreatedData->SetBackTTime(T); + } + }*/ +} + +/////////////////////////////////////////////////////////////////////////// +Int_t TSuperX3Physics::EventType() { + /* // Same multiplicity on front and back side + if (m_PreTreatedData->GetFrontEMult() == m_PreTreatedData->GetBackEMult()) { + return 1; + } + // Possibly interstrip + else if (m_PreTreatedData->GetFrontEMult() == m_PreTreatedData->GetBackEMult() + 1 || + m_PreTreatedData->GetFrontEMult() == m_PreTreatedData->GetBackEMult() - 1) { + return 2; + } + // Rejected event + else { + return -1; + }*/ + return 0; +} + +/////////////////////////////////////////////////////////////////////////// +vector<TVector2> TSuperX3Physics::Match_Front_Back() { + vector<TVector2> ArrayOfGoodCouple; + /* + // Select allowed multiplicity events. If multiplicity is too + // high, then return "empty" vector + if (m_PreTreatedData->GetFrontEMult() > m_MaximumStripMultiplicityAllowed || + m_PreTreatedData->GetBackEMult() > m_MaximumStripMultiplicityAllowed) + return ArrayOfGoodCouple; + + // Loop on front multiplicity + for (UShort_t i = 0; i < m_PreTreatedData->GetFrontEMult(); i++) { + // Loop on back multiplicity + for (UShort_t j = 0; j < m_PreTreatedData->GetBackEMult(); j++) { + // if same detector check energy + if (m_PreTreatedData->GetFrontEDetectorNbr(i) == m_PreTreatedData->GetBackEDetectorNbr(j)) { + m_Counter[2] = 1; + // Equal energy + if (abs((m_PreTreatedData->GetFrontEEnergy(i) - m_PreTreatedData->GetBackEEnergy(j)) / 2.) < + m_StripEnergyMatchingNumberOfSigma * m_StripEnergyMatchingSigma) { + ArrayOfGoodCouple.push_back(TVector2(i, j)); + m_Counter[3] = 1; + } // end test energy + } // end test same detector + } // end loop back multiplicity + } // end loop front multiplicity + + // Prevent treating event with ambiguous matchin beetween X and Y + if (ArrayOfGoodCouple.size() > m_PreTreatedData->GetFrontEMult()) + ArrayOfGoodCouple.clear(); + */ + return ArrayOfGoodCouple; +} + +/////////////////////////////////////////////////////////////////////////// +bool TSuperX3Physics::IsValidChannel(string Type, int detector, int channel) { + if (Type == "Front") { + return *(m_FrontChannelStatus[detector - 1].begin() + channel); + } + else if (Type == "Back") + return *(m_BackChannelStatus[detector - 1].begin() + channel); + + else + return false; +} + +/////////////////////////////////////////////////////////////////////////// +void TSuperX3Physics::InitializeStandardParameters() { + // Enable all channels + vector<bool> ChannelStatus; + m_FrontChannelStatus.clear(); + m_BackChannelStatus.clear(); + + ChannelStatus.resize(m_NumberOfStrips, true); + for (Int_t i = 0; i < m_NumberOfDetectors; i++) { + m_FrontChannelStatus[i] = ChannelStatus; + m_BackChannelStatus[i] = ChannelStatus; + } +} + +/////////////////////////////////////////////////////////////////////////// +void TSuperX3Physics::ReadAnalysisConfig() { + bool ReadingStatus = false; + + cout << "\t/////////// Reading ConfigSuperX3.dat file ///////////" << endl; + + // path to file + string FileName = "./configs/ConfigSuperX3.dat"; + + // open analysis config file + ifstream AnalysisConfigFile; + AnalysisConfigFile.open(FileName.c_str()); + + if (!AnalysisConfigFile.is_open()) { + cout << "\tNo ConfigSuperX3.dat found: default parameters loaded for Analysis " << FileName << endl; + return; + } + cout << "\tLoading user parameters from ConfigSuperX3.dat " << endl; + + // storing config file in the ROOT output file + TAsciiFile* asciiFile = RootOutput::getInstance()->GetAsciiFileAnalysisConfig(); + asciiFile->AppendLine("%% ConfigSuperX3.dat %%"); + asciiFile->Append(FileName.c_str()); + asciiFile->AppendLine(""); + + // read analysis config file + string LineBuffer, DataBuffer, whatToDo; + while (!AnalysisConfigFile.eof()) { + // Pick-up next line + getline(AnalysisConfigFile, LineBuffer); + + // search for "header" + if (LineBuffer.compare(0, 8, "ConfigSuperX3") == 0) + ReadingStatus = true; + + // loop on tokens and data + while (ReadingStatus) { + whatToDo = ""; + AnalysisConfigFile >> whatToDo; + + // Search for comment symbol (%) + if (whatToDo.compare(0, 1, "%") == 0) { + AnalysisConfigFile.ignore(numeric_limits<streamsize>::max(), '\n'); + } + + else if (whatToDo == "MAX_STRIP_MULTIPLICITY") { + AnalysisConfigFile >> DataBuffer; + m_MaximumStripMultiplicityAllowed = atoi(DataBuffer.c_str()); + cout << "\t" << whatToDo << "\t" << m_MaximumStripMultiplicityAllowed << endl; + } + + else if (whatToDo == "FRONT_BACK_ENERGY_MATCHING_SIGMA") { + AnalysisConfigFile >> DataBuffer; + m_StripEnergyMatchingSigma = atof(DataBuffer.c_str()); + cout << "\t" << whatToDo << "\t" << m_StripEnergyMatchingSigma << endl; + } + + else if (whatToDo == "FRONT_BACK_ENERGY_MATCHING_NUMBER_OF_SIGMA") { + AnalysisConfigFile >> DataBuffer; + m_StripEnergyMatchingNumberOfSigma = atoi(DataBuffer.c_str()); + cout << "\t" << whatToDo << "\t" << m_StripEnergyMatchingNumberOfSigma << endl; + } + + else if (whatToDo == "FRONT_E_RAW_THRESHOLD") { + AnalysisConfigFile >> DataBuffer; + m_FrontE_Raw_Threshold = atoi(DataBuffer.c_str()); + cout << "\t" << whatToDo << "\t" << m_FrontE_Raw_Threshold << endl; + } + + else if (whatToDo == "BACK_E_RAW_THRESHOLD") { + AnalysisConfigFile >> DataBuffer; + m_BackE_Raw_Threshold = atoi(DataBuffer.c_str()); + cout << "\t" << whatToDo << "\t" << m_BackE_Raw_Threshold << endl; + } + + else if (whatToDo == "FRONT_E_CAL_THRESHOLD") { + AnalysisConfigFile >> DataBuffer; + m_FrontE_Calib_Threshold = atoi(DataBuffer.c_str()); + cout << "\t" << whatToDo << "\t" << m_FrontE_Calib_Threshold << endl; + } + + else if (whatToDo == "BACK_E_CAL_THRESHOLD") { + AnalysisConfigFile >> DataBuffer; + m_BackE_Calib_Threshold = atoi(DataBuffer.c_str()); + cout << "\t" << whatToDo << "\t" << m_BackE_Calib_Threshold << endl; + } + + else if (whatToDo == "DISABLE_ALL") { + AnalysisConfigFile >> DataBuffer; + cout << "\t" << whatToDo << "\t" << DataBuffer << endl; + Int_t Detector = atoi(DataBuffer.substr(4, 1).c_str()); + vector<bool> ChannelStatus; + ChannelStatus.resize(m_NumberOfStrips, false); + m_FrontChannelStatus[Detector - 1] = ChannelStatus; + m_BackChannelStatus[Detector - 1] = ChannelStatus; + } + + else if (whatToDo == "DISABLE_CHANNEL") { + AnalysisConfigFile >> DataBuffer; + cout << "\t" << whatToDo << "\t" << DataBuffer << endl; + int detector = atoi(DataBuffer.substr(4, 1).c_str()); + int channel = -1; + if (DataBuffer.compare(6, 5, "FRONT") == 0) { + channel = atoi(DataBuffer.substr(12).c_str()); + *(m_FrontChannelStatus[detector - 1].begin() + channel) = false; + } + else if (DataBuffer.compare(6, 4, "BACK") == 0) { + channel = atoi(DataBuffer.substr(11).c_str()); + *(m_BackChannelStatus[detector - 1].begin() + channel) = false; + } + } + else { + ReadingStatus = false; + } + } + } + cout << "\t/////////////////////////////////////////////////" << endl; +} + +/////////////////////////////////////////////////////////////////////////// +void TSuperX3Physics::InitSpectra() { m_Spectra = new TSuperX3Spectra(m_NumberOfDetectors); } + +/////////////////////////////////////////////////////////////////////////// +void TSuperX3Physics::FillSpectra() { + m_Spectra->FillRawSpectra(m_EventData); + m_Spectra->FillPreTreatedSpectra(m_PreTreatedData); + m_Spectra->FillPhysicsSpectra(m_EventPhysics); +} + +/////////////////////////////////////////////////////////////////////////// +void TSuperX3Physics::CheckSpectra() { m_Spectra->CheckSpectra(); } + +/////////////////////////////////////////////////////////////////////////// +void TSuperX3Physics::ClearSpectra() { + // To be done +} + +/////////////////////////////////////////////////////////////////////////// +void TSuperX3Physics::WriteSpectra() { m_Spectra->WriteSpectra(); } + +/////////////////////////////////////////////////////////////////////////// +map<string, TH1*> TSuperX3Physics::GetSpectra() { + if (m_Spectra) + return m_Spectra->GetMapHisto(); + else { + map<string, TH1*> empty; + return empty; + } +} + +//////////////////////////////////////////////////////////////////////////////// +// Construct Method to be pass to the DetectorFactory // +//////////////////////////////////////////////////////////////////////////////// +NPL::VDetector* TSuperX3Physics::Construct() { return (NPL::VDetector*)new TSuperX3Physics(); } + +//////////////////////////////////////////////////////////////////////////////// +// Registering the construct method to the factory // +//////////////////////////////////////////////////////////////////////////////// +extern "C" { +class proxy_w1 { + public: + proxy_w1() { + NPL::DetectorFactory::getInstance()->AddToken("SuperX3", "SuperX3"); + NPL::DetectorFactory::getInstance()->AddDetector("SuperX3", TSuperX3Physics::Construct); + } +}; + +proxy_w1 p; +} + diff --git a/NPLib/Detectors/SuperX3/TSuperX3Physics.h b/NPLib/Detectors/SuperX3/TSuperX3Physics.h new file mode 100644 index 0000000000000000000000000000000000000000..f419d6f0c8b7fa2abecc51c74da787bc730d7ae4 --- /dev/null +++ b/NPLib/Detectors/SuperX3/TSuperX3Physics.h @@ -0,0 +1,241 @@ +#ifndef __SuperX3Physics__ +#define __SuperX3Physics__ +/***************************************************************************** + * 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: N. de Sereville contact address: deserevi@ipno.in2p3.fr * + * * + * Creation Date : january 2011 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class holds the physics class for the SuperX3 detector from Micron * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ +// C++ headers +#include <map> +#include <vector> +using namespace std; + +// ROOT headers +#include "TCanvas.h" +#include "TH1.h" +#include "TObject.h" +#include "TVector2.h" +#include "TVector3.h" + +// NPTool headers +#include "NPCalibrationManager.h" +#include "NPInputParser.h" +#include "NPVDetector.h" +#include "TSuperX3Data.h" +#include "TSuperX3Spectra.h" + +// forward declaration +class TSuperX3Spectra; + +class TSuperX3Physics : public TObject, public NPL::VDetector { + public: // Constructor and Destructor + TSuperX3Physics(); + ~TSuperX3Physics(){}; + + public: + void Clear(); + void Clear(const Option_t*){}; + + private: // data obtained after BuildPhysicalEvent() and stored in ROOT output file + vector<Int_t> fEventType; + vector<Int_t> fDetectorNumber; + vector<Double_t> fFrontEnergy; + vector<Double_t> fBackEnergy; + vector<Double_t> fHalfEnergy; + vector<Double_t> fFrontTime; + vector<Double_t> fBackTime; + vector<Int_t> fFrontStrip; + vector<Int_t> fBackStrip; + + public: + // setters + void SetEventType(Int_t evtType) { fEventType.push_back(evtType); } + void SetDetectorNumber(Int_t moduleNbr) { fDetectorNumber.push_back(moduleNbr); } + void SetFrontEnergy(Double_t ener) { fFrontEnergy.push_back(ener); } + void SetBackEnergy(Double_t ener) { fBackEnergy.push_back(ener); } + void SethalfEnergy(Double_t ener) { fHalfEnergy.push_back(ener); } + void SetFrontTime(Double_t time) { fFrontTime.push_back(time); } + void SetBackTime(Double_t time) { fBackTime.push_back(time); } + void SetFrontStrip(Int_t x) { fFrontStrip.push_back(x); } + void SetBackStrip(Int_t y) { fBackStrip.push_back(y); } + + // getters + Int_t GetEventMultiplicity() { return fFrontEnergy.size(); } + Int_t GetEventType(Int_t i) { return fEventType[i]; } + Int_t GetDetectorNumber(Int_t i) { return fDetectorNumber[i]; } + Double_t GetFrontEnergy(Int_t i) { return fFrontEnergy[i]; } + Double_t GetBackEnergy(Int_t i) { return fBackEnergy[i]; } + Double_t GetHalfEnergy(Int_t i) { return fHalfEnergy[i]; } + Double_t GetFrontTime(Int_t i) { return fFrontTime[i]; } + Double_t GetBackTime(Int_t i) { return fBackTime[i]; } + Int_t GetFrontStrip(Int_t i) { return fFrontStrip[i]; } + Int_t GetBackStrip(Int_t i) { return fBackStrip[i]; } + + public: + Int_t m_nCounter; //! + Bool_t m_Counter[10]; //! + + public: // inherited from VDetector + // Read stream at ConfigFile to pick-up parameters of detector (Position,...) using Token + void ReadConfiguration(NPL::InputParser); + + // Add parameters to the CalibrationManger + void AddParameterToCalibrationManager(); + + // Activate associated branches and link them to the private member object m_EventData + void InitializeRootInputRaw(); + + // Activate associated branches and link them to the private member m_EventPhysics + void InitializeRootInputPhysics(); + + // Create associated branches and associated private member m_EventPhysics + void InitializeRootOutput(); + + // This method is called at each event read from the Input Tree. Aime is to build treat Raw dat in order to extract + // physical parameter. + void BuildPhysicalEvent(); + + // Same as above, but only the simplest event and/or simple method are used (low multiplicity, faster algorythm but + // less efficient ...). This method aimed to be used for analysis performed during experiment, when speed is + // requiered. NB: This method can eventually be the same as BuildPhysicalEvent. + void BuildSimplePhysicalEvent(); + + // Same as above but for online analysis + void BuildOnlinePhysicalEvent() { BuildPhysicalEvent(); }; + + // Clear raw and physics data + void ClearEventPhysics() { Clear(); } + void ClearEventData() { m_EventData->Clear(); } + + // Methods related to the TSuperX3Spectra classes + // Instantiate the TSuperX3Spectra class and the histograms + void InitSpectra(); + // Fill the spectra defined in TSuperX3Spectra + void FillSpectra(); + // Used for Online mainly, perform check on the histo and for example change their color if issues are found + void CheckSpectra(); + // Used for Online only, clear all the spectra hold by the Spectra class + void ClearSpectra(); + // Write Spectra to file + void WriteSpectra(); + + public: // Specific to SuperX3 + // Remove bad channel, calibrate the data and apply thresholds + void PreTreat(); + + // Clear the pre treated object + void ClearPreTreatedData() { m_PreTreatedData->Clear(); } + + // Return false if the channel is disabled by user + // Frist argument is either "Front" or "Back" + bool IsValidChannel(string Type, int detector, int channel); + + // Initialize the standard parameters for analysis, i.e.: all channel enable, + // maximum multiplicity for strip = number of telescope + void InitializeStandardParameters(); + + // Read the user configuration file; if no file found, load standard one + void ReadAnalysisConfig(); + + // Add detector using cartesian coordinates + void AddDetector(TVector3 C_X1_Y1, TVector3 C_X16_Y1, TVector3 C_X1_Y16, TVector3 C_X16_Y16); + + // Add detector using spherical coordinates + void AddDetector(double theta, double phi, double distance, double beta_u, double beta_v, double beta_w); + + // Give an external TSuperX3Data object to TSuperX3Physics. Needed for online analysis for example. + void SetRawDataPointer(TSuperX3Data* rawDataPointer) { m_EventData = rawDataPointer; } + + // Use for reading Calibration Run, very simple methods; only apply calibration, no condition + void ReadCalibrationRun(){}; + + public: // Methods used for event treatement + Int_t EventType(); + vector<TVector2> Match_Front_Back(); + + private: // Data not written in the tree + TSuperX3Data* m_EventData; //! + TSuperX3Data* m_PreTreatedData; //! + TSuperX3Physics* m_EventPhysics; //! + + public: + TSuperX3Data* GetRawData() const { return m_EventData; } + TSuperX3Data* GetPreTreatedData() const { return m_PreTreatedData; } + + private: // Map of activated Channel + map<int, vector<bool>> m_FrontChannelStatus; //! + map<int, vector<bool>> m_BackChannelStatus; //! + + private: // Parameters used in the analysis + // If multiplicity is greater than m_MaximumStripMultiplicityAllowed + // after PreTreat(), event is not treated + int m_MaximumStripMultiplicityAllowed; //! + + // Tolerance for front / back energy match + double m_StripEnergyMatchingSigma; //! + double m_StripEnergyMatchingNumberOfSigma; //! + + // Energy thresholds + // Raw Threshold + int m_FrontE_Raw_Threshold; //! + int m_BackE_Raw_Threshold; //! + // Calibrated Threshold + double m_FrontE_Calib_Threshold; //! + double m_BackE_Calib_Threshold; //! + + private: // Spatial Position of Strip Calculated on bases of detector position + int m_NumberOfDetectors; //! + vector<vector<vector<double>>> m_StripPositionX; //! + vector<vector<vector<double>>> m_StripPositionY; //! + vector<vector<vector<double>>> m_StripPositionZ; //! + + public: + double GetNumberOfDetectors() { return m_NumberOfDetectors; }; + double GetStripPositionX(int N, int Front, int Back) { return m_StripPositionX[N - 1][Front - 1][Back - 1]; }; + double GetStripPositionY(int N, int Front, int Back) { return m_StripPositionY[N - 1][Front - 1][Back - 1]; }; + double GetStripPositionZ(int N, int Front, int Back) { return m_StripPositionZ[N - 1][Front - 1][Back - 1]; }; + TVector3 GetPositionOfInteraction(int i); + TVector3 GetDetectorNormal(int i); + void DumpStrippingScheme(Int_t detecNumber); + + private: // Geometry and strip number + double m_SiliconFace; //! // mm + int m_NumberOfStrips; //! + double m_StripPitch; //! + + private: // Spectra Class + TSuperX3Spectra* m_Spectra; // ! + + public: // Spectra Getter + map<string, TH1*> GetSpectra(); + + public: // Static constructor to be passed to the Detector Factory + static NPL::VDetector* Construct(); + + ClassDef(TSuperX3Physics, 1) // TSuperX3Physics +}; + +namespace SuperX3_LOCAL { + Double_t fSuperX3_Front_E(TSuperX3Data* EventData, Int_t i); + Double_t fSuperX3_Front_T(TSuperX3Data* EventData, Int_t i); + Double_t fSuperX3_Back_E(TSuperX3Data* EventData, Int_t i); + Double_t fSuperX3_Back_T(TSuperX3Data* EventData, Int_t i); +} // namespace SuperX3_LOCAL + +#endif diff --git a/NPLib/Detectors/SuperX3/TSuperX3Spectra.cxx b/NPLib/Detectors/SuperX3/TSuperX3Spectra.cxx new file mode 100644 index 0000000000000000000000000000000000000000..fe76f01a2b8e8c59e6aee0711733a426f06bca62 --- /dev/null +++ b/NPLib/Detectors/SuperX3/TSuperX3Spectra.cxx @@ -0,0 +1,66 @@ +/***************************************************************************** + * 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: N. de Sereville address: deserevi@ipno.in2p3.fr * + * * + * Creation Date : November 2015 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class holds all the online spectra needed for SuperX3 * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + *****************************************************************************/ + +// class header +#include "TSuperX3Spectra.h" + +// C++ headers +#include <iostream> +#include <string> +using namespace std; + +// NPTool headers +#include "NPOptionManager.h" + +//////////////////////////////////////////////////////////////////////////////// +TSuperX3Spectra::TSuperX3Spectra() + : fNumberOfDetectors(0), fNumberOfStripsFront(16), fNumberOfStripsBack(16), fNumberOfCounters(10) { + SetName("SuperX3"); +} + +//////////////////////////////////////////////////////////////////////////////// +TSuperX3Spectra::TSuperX3Spectra(unsigned int NumberOfDetectors) { + InitRawSpectra(); + InitPreTreatedSpectra(); + InitPhysicsSpectra(); +} + +//////////////////////////////////////////////////////////////////////////////// +TSuperX3Spectra::~TSuperX3Spectra() {} + +//////////////////////////////////////////////////////////////////////////////// +void TSuperX3Spectra::InitRawSpectra() {} + +//////////////////////////////////////////////////////////////////////////////// +void TSuperX3Spectra::InitPreTreatedSpectra() {} + +//////////////////////////////////////////////////////////////////////////////// +void TSuperX3Spectra::InitPhysicsSpectra() {} + +//////////////////////////////////////////////////////////////////////////////// +void TSuperX3Spectra::FillRawSpectra(TSuperX3Data* RawData) {} + +//////////////////////////////////////////////////////////////////////////////// +void TSuperX3Spectra::FillPreTreatedSpectra(TSuperX3Data* PreTreatedData) {} + +//////////////////////////////////////////////////////////////////////////////// +void TSuperX3Spectra::FillPhysicsSpectra(TSuperX3Physics* Physics) {} + diff --git a/NPLib/Detectors/SuperX3/TSuperX3Spectra.h b/NPLib/Detectors/SuperX3/TSuperX3Spectra.h new file mode 100644 index 0000000000000000000000000000000000000000..0e9ce648ef584b352e950d30e3882faff7d20557 --- /dev/null +++ b/NPLib/Detectors/SuperX3/TSuperX3Spectra.h @@ -0,0 +1,58 @@ +#ifndef TSuperX3SPECTRA_H +#define TSuperX3SPECTRA_H +/***************************************************************************** + * 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: n. de Sereville address: deserevi@ipno.in2p3.fr * + * * + * Creation Date : November 2015 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This class holds all the online spectra needed for SuperX3 * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + *****************************************************************************/ + +// NPLib headers +#include "NPVSpectra.h" +#include "TSuperX3Data.h" +#include "TSuperX3Physics.h" + +// ForwardDeclaration +class TSuperX3Physics; + +class TSuperX3Spectra : public VSpectra { + public: + // constructor and destructor + TSuperX3Spectra(); + TSuperX3Spectra(unsigned int NumberOfDetectors); + ~TSuperX3Spectra(); + + private: + // Initialization methods + void InitRawSpectra(); + void InitPreTreatedSpectra(); + void InitPhysicsSpectra(); + + public: + // Filling methods + void FillRawSpectra(TSuperX3Data*); + void FillPreTreatedSpectra(TSuperX3Data*); + void FillPhysicsSpectra(TSuperX3Physics*); + + private: // Information on SuperX3 + unsigned int fNumberOfDetectors; + unsigned int fNumberOfStripsFront; + unsigned int fNumberOfStripsBack; + Int_t fNumberOfCounters; +}; + +#endif diff --git a/NPLib/TrackReconstruction/CMakeLists.txt b/NPLib/TrackReconstruction/CMakeLists.txt index 341a03e345feb5010c5bc4220dab7d4df0449fe3..f87460b714ed6f34e3c79f695bfb55b12b81fae2 100644 --- a/NPLib/TrackReconstruction/CMakeLists.txt +++ b/NPLib/TrackReconstruction/CMakeLists.txt @@ -7,7 +7,7 @@ add_custom_command(OUTPUT NPClusterDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/ add_custom_command(OUTPUT TrackingDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh Tracking.h TrackingDict.cxx Tracking.rootmap libNPTrackReconstruction.so NPTrackReconstructionLinkDef.h DEPENDS Tracking.h) ## Check if MINUIT2 is installed along with ROOT -find_library(libMinuit2_FOUND NAMES Minuit2 HINTS "${ROOTSYS}/lib") +find_library(libMinuit2_FOUND NAMES Minuit2 HINTS "${ROOTSYS}/lib" "/usr/lib64/root") if(libMinuit2_FOUND) message(STATUS "Minuit2 support enabled for TrackReconstruction.") add_definitions(-DHAVE_MINUIT2) diff --git a/NPLib/TrackReconstruction/NPLinearRansac3D.cxx b/NPLib/TrackReconstruction/NPLinearRansac3D.cxx index 767e43ce05bb8cb956268f6560952dfaaf24fd69..8ef0839a43c82fd5b263a9b10b5351f813b596d1 100644 --- a/NPLib/TrackReconstruction/NPLinearRansac3D.cxx +++ b/NPLib/TrackReconstruction/NPLinearRansac3D.cxx @@ -16,139 +16,143 @@ * Find linear tracks using the ransac method * *****************************************************************************/ -#include"NPLinearRansac3D.h" +#include "NPLinearRansac3D.h" using namespace std; using namespace NPL; //////////////////////////////////////////////////////////////////////////////// -void LinearCluster3D::LinearFit(){ +void LinearCluster3D::LinearFit() { - unsigned int sizeI = m_index.size(); + unsigned int sizeI = m_index.size(); double min_distance = 1e20; - unsigned int min_i = 0 ; unsigned int min_j = 0; - - double meanDX=0; - double meanDY=0; - double meanDZ=0; - double totalW=0; - double meanX=0; - double meanY=0; - double meanZ=0; + unsigned int min_i = 0; + unsigned int min_j = 0; + + double meanDX = 0; + double meanDY = 0; + double meanDZ = 0; + double totalW = 0; + double meanX = 0; + double meanY = 0; + double meanZ = 0; double w; - for(unsigned int i = 0 ; i < sizeI ; i++){ - TVector3 Pi((*m_X)[m_index[i]],(*m_Y)[m_index[i]],(*m_Z)[m_index[i]]); - for(unsigned int j = i+1 ; j < sizeI ; j++){ - double dij=0; - TVector3 Pj((*m_X)[m_index[j]],(*m_Y)[m_index[j]],(*m_Z)[m_index[j]]); + for (unsigned int i = 0; i < sizeI; i++) { + TVector3 Pi((*m_X)[m_index[i]], (*m_Y)[m_index[i]], (*m_Z)[m_index[i]]); + for (unsigned int j = i + 1; j < sizeI; j++) { + double dij = 0; + TVector3 Pj((*m_X)[m_index[j]], (*m_Y)[m_index[j]], (*m_Z)[m_index[j]]); // compute the average distance of all point to this line - for(unsigned int p = 0 ; p < sizeI ; p++){ - TVector3 Pp((*m_X)[m_index[p]],(*m_Y)[m_index[p]],(*m_Z)[m_index[p]]); - dij+=MinimumDistancePointLine(Pi,Pj,Pp); + for (unsigned int p = 0; p < sizeI; p++) { + TVector3 Pp((*m_X)[m_index[p]], (*m_Y)[m_index[p]], (*m_Z)[m_index[p]]); + dij += MinimumDistancePointLine(Pi, Pj, Pp); } - - w = 1./dij; - totalW+=w; - - meanX+=w*((*m_X)[m_index[i]]); - meanY+=w*((*m_Y)[m_index[i]]); - meanZ+=w*((*m_Z)[m_index[i]]); - - meanDX+=w*((*m_X)[m_index[i]]-(*m_X)[m_index[j]]); - meanDY+=w*((*m_Y)[m_index[i]]-(*m_Y)[m_index[j]]); - meanDZ+=w*((*m_Z)[m_index[i]]-(*m_Z)[m_index[j]]); - } - } - meanDX/=totalW; - meanDY/=totalW; - meanDZ/=totalW; - meanX/=totalW; - meanY/=totalW; - meanZ/=totalW; + w = 1. / dij; + totalW += w; - m_P0 = TVector3(meanX,meanY,meanZ); - m_Dir = (TVector3(meanDX,meanDY,meanDZ)).Unit(); + meanX += w * ((*m_X)[m_index[i]]); + meanY += w * ((*m_Y)[m_index[i]]); + meanZ += w * ((*m_Z)[m_index[i]]); + meanDX += w * ((*m_X)[m_index[i]] - (*m_X)[m_index[j]]); + meanDY += w * ((*m_Y)[m_index[i]] - (*m_Y)[m_index[j]]); + meanDZ += w * ((*m_Z)[m_index[i]] - (*m_Z)[m_index[j]]); + } + } + + meanDX /= totalW; + meanDY /= totalW; + meanDZ /= totalW; + meanX /= totalW; + meanY /= totalW; + meanZ /= totalW; + + m_P0 = TVector3(meanX, meanY, meanZ); + m_Dir = (TVector3(meanDX, meanDY, meanDZ)).Unit(); + // Cluster dir is arbitrary. we choose to always have positive Z dir + if (m_Dir.Z() < 0) + m_Dir = -m_Dir; }; //////////////////////////////////////////////////////////////////////////////// - vector<LinearCluster3D> LinearRansac3D::TreatEvent(vector<double>& X, vector<double>&Y, vector<double>&Z){ - cluster_id.clear(); - clusters.clear(); - unsigned int sizeX = X.size(); - cluster_id.resize(sizeX,0); - m_cluster.clear(); - m_assigned.clear(); - - if(sizeX<m_min_count) - return clusters; - - unsigned int p1,p2; - double d; - TVector3 Vp1,Vp2,D,P; - m_iteration_d=0; - m_iteration=0; - - while(m_iteration++ < m_max_iteration && m_assigned.size()<sizeX){ - LinearCluster3D cluster(&X,&Y,&Z); - // take 2 distant point randomly that has not been match before - d=0 ; m_iteration_d=0; - while(d<3*m_match_distance && m_iteration_d++<m_max_iteration ){ - p1 = rand.Integer(sizeX); - p2 = rand.Integer(sizeX); - - Vp1.SetXYZ(X[p1],Y[p1],Z[p1]); - Vp2.SetXYZ(X[p2],Y[p2],Z[p2]); - D=Vp1-Vp2; - d = D.Mag(); - if(d>m_max_distance) - d=0; - } +vector<LinearCluster3D> LinearRansac3D::TreatEvent(vector<double>& X, vector<double>& Y, vector<double>& Z) { + cluster_id.clear(); + clusters.clear(); + unsigned int sizeX = X.size(); + cluster_id.resize(sizeX, 0); + m_cluster.clear(); + m_assigned.clear(); + + if (sizeX < m_min_count) + return clusters; + + unsigned int p1, p2; + double d; + TVector3 Vp1, Vp2, D, P; + m_iteration_d = 0; + m_iteration = 0; + + while (m_iteration++ < m_max_iteration && m_assigned.size() < sizeX) { + LinearCluster3D cluster(&X, &Y, &Z); + // take 2 distant point randomly that has not been match before + d = 0; + m_iteration_d = 0; + while (d < 3 * m_match_distance && m_iteration_d++ < m_max_iteration) { + p1 = rand.Integer(sizeX); + p2 = rand.Integer(sizeX); + + Vp1.SetXYZ(X[p1], Y[p1], Z[p1]); + Vp2.SetXYZ(X[p2], Y[p2], Z[p2]); + D = Vp1 - Vp2; + d = D.Mag(); + if (d > m_max_distance) + d = 0; + } - // loop over all points - for(unsigned int i = 0 ; i < sizeX ; i++){ - P.SetXYZ(X[i],Y[i],Z[i]); - if(MinimumDistancePointLine(Vp1,Vp2,P) < m_match_distance){ - cluster.AddIndex(i); - m_assigned.insert(i); - } - } - // insert the newly formed cluster - if(cluster.size()>m_min_count){ - m_cluster.insert(cluster); - } + // loop over all points + for (unsigned int i = 0; i < sizeX; i++) { + P.SetXYZ(X[i], Y[i], Z[i]); + if (MinimumDistancePointLine(Vp1, Vp2, P) < m_match_distance) { + cluster.AddIndex(i); + m_assigned.insert(i); + } + } + // insert the newly formed cluster + if (cluster.size() > m_min_count) { + m_cluster.insert(cluster); + } - }//while - - // loop over the cluster starting with the biggest - unsigned int current_cluster=0; - unsigned int index; - for(auto it = m_cluster.begin() ; it!=m_cluster.end() ; ++it){ - current_cluster++; - // cout << current_cluster << endl; - unsigned int sizeC = (*it).size(); - unsigned int cluster_size = 0; - for(unsigned int i = 0 ; i < sizeC ; i++){ - // Assigned cluster id to identified points - unsigned int index = (*it).GetIndex(i); - if(!cluster_id[index]){ - cluster_id[index]=current_cluster; - cluster_size++; - } - } - if(cluster_size<m_min_count){ - for(unsigned int i = 0 ; i < sizeC ; i++){ - unsigned int index = (*it).GetIndex(i); - // remove the assigned point - if(cluster_id[index]==current_cluster){ - cluster_id[index]=0; - } - } - } - else{ - clusters.push_back(*it); + } // while + + // loop over the cluster starting with the biggest + unsigned int current_cluster = 0; + unsigned int index; + for (auto it = m_cluster.begin(); it != m_cluster.end(); ++it) { + current_cluster++; + // cout << current_cluster << endl; + unsigned int sizeC = (*it).size(); + unsigned int cluster_size = 0; + for (unsigned int i = 0; i < sizeC; i++) { + // Assigned cluster id to identified points + unsigned int index = (*it).GetIndex(i); + if (!cluster_id[index]) { + cluster_id[index] = current_cluster; + cluster_size++; + } + } + if (cluster_size < m_min_count) { + for (unsigned int i = 0; i < sizeC; i++) { + unsigned int index = (*it).GetIndex(i); + // remove the assigned point + if (cluster_id[index] == current_cluster) { + cluster_id[index] = 0; } } - return clusters; } + else { + clusters.push_back(*it); + } + } + return clusters; +} diff --git a/NPSimulation/Core/Chamber.cc b/NPSimulation/Core/Chamber.cc index 8f1d79f1334b2e742c113fa44db7d492edbc8c30..3473e11df5d7fabf8836d8fc5f405562638c8a5b 100644 --- a/NPSimulation/Core/Chamber.cc +++ b/NPSimulation/Core/Chamber.cc @@ -30,382 +30,369 @@ #endif // G4 geometry header -#include "G4Tubs.hh" -#include "G4Sphere.hh" #include "G4Box.hh" -#include "G4Trap.hh" #include "G4Polycone.hh" +#include "G4Sphere.hh" #include "G4SubtractionSolid.hh" +#include "G4Trap.hh" +#include "G4Tubs.hh" -//G4 various headers +// G4 various headers #include "G4Colour.hh" -#include "G4NistManager.hh" // NIST database of material -#include "G4Material.hh" -#include "G4MaterialTable.hh" #include "G4Element.hh" #include "G4ElementTable.hh" -#include "G4RotationMatrix.hh" -#include "G4PVPlacement.hh" -#include "G4VPhysicalVolume.hh" -#include "G4PVPlacement.hh" -#include "G4VisAttributes.hh" -#include "G4Colour.hh" #include "G4EmCalculator.hh" +#include "G4Material.hh" +#include "G4MaterialTable.hh" +#include "G4NistManager.hh" // NIST database of material +#include "G4PVPlacement.hh" #include "G4ParticleDefinition.hh" #include "G4ParticleTable.hh" +#include "G4RotationMatrix.hh" +#include "G4VPhysicalVolume.hh" +#include "G4VisAttributes.hh" #include "Randomize.hh" -using namespace CLHEP ; +using namespace CLHEP; // NPTool header -#include"Chamber.hh" -#include"MaterialManager.hh" +#include "Chamber.hh" +#include "MaterialManager.hh" #include "NPOptionManager.h" using namespace std; - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Specific Method of this class -Chamber::Chamber(): nStripsX(60),nStripsY(40) -{ - - - //m_ChamberType = true; - m_ChamberType = 0 ; // normal - m_ChamberRmin = 0 ; - m_ChamberRmax = 0 ; - m_ChamberPhiMin = 0 ; - m_ChamberPhiMax = 0 ; - m_ChamberThetaMin = 0 ; - m_ChamberThetaMax = 0 ; - - DefineMaterials(); - - //----------------------------- - //defaults for Planar - fPlanarGuard = 5.0*mm; - fPlanarGe_W = 120.0*mm; - fPlanarGe_H = 60.0*mm; - fPlanarGe_T = 15.0*mm; - - fEndCapThickness = 2.7*mm; //Notes state a 2.2 mm thick rib supporting a 0.5 mm Be window - fAlWindowThickness = 1.1*mm; - fBeWindowThickness = 0.5*mm; - - fPlanarGeGapFront = 14.0*mm; //Front face Al -> Front face Ge - fPlanarGeGapBack = 9.0*mm; //Back face Al -> Back face Ge - fPlanarGeGapFront = 16.0*mm; //Front face Al -> Front face Ge - fPlanarGeGapBack = 7.0*mm; //Back face Al -> Back face Ge - - fPlanarTotalL = 2.*fEndCapThickness + fPlanarGeGapFront + fPlanarGeGapBack + fPlanarGe_T; - - //--------------------------------------- - // I measured 39.5 mm for fPlanarTotalL - // => put end cap thickness 2.75 mm - // => add 1 mm to one of the gaps (most likely the retards put fPlanarGeGapFront = 15 mm !) - fPlanarTotalL = fEndCapThickness + fPlanarGeGapFront + fPlanarGeGapBack + fPlanarGe_T + fAlWindowThickness; - - fdeltaZ_Support = 0.0*mm; //looks like there is a little gap between the cooling block and the planar cut-out - fGap_PCB_2_Planar = 6.0*mm; //the gap between the downstrean part of the PCB and the upstream face of planar - fGap_PCB_2_Planar += fdeltaZ_Support; - fLengthOfPlanarCut = 55.0*mm; //the Z dimension of the cut out used to remove the planar - //-------------------------------------------------------------- - // Cooling block dimensions - fCoolingBlockL = 79.0*mm; - fCoolingBlockH = 152.0*mm; - fCoolingBlockW = 176.7*mm; - fCoolingBlockT = 6.0*mm; //excellent idea for low energy transparency ! - - // Size of cut-out for the tunnel (and DSSD) - fCoolingBlockCutOutH = 74.4*mm; - fCoolingBlockCutOutW = fCoolingBlockW - 2.*fCoolingBlockT; - fCoolingBlockDSSDCentre = fCoolingBlockH - fCoolingBlockT - fCoolingBlockCutOutH/2.; - fDSSD_BoardL = 2.0*mm; //thickness of Si implantation detector support board - - fCoolingBlockZ = fLengthOfPlanarCut + fDSSD_BoardL + fdeltaZ_Support; //distance between chamber inner wall and downstream side of detector support - - G4cout << "fCoolingBlockZ " << fCoolingBlockZ << G4endl; - - - //----------------------------- - //default DSSD - fDSSD_H = 40.0*mm; //active - fDSSD_W = 60.0*mm; //active - fDSSD_T = 0.3*mm; - fDSSD_Guard = 1.0*mm; - - - //----------------------------------------------------- - // Put these defaults here so I can easily compare them - //----------------------------------------------------- - //some default PhaseII detector parameters - fTotalGeL_PhaseII = 70.0 * mm; //was 70 - fCrystalR_PhaseII = 24.0 * mm; //was 25 - fEndCap2Ge_PhaseII = 20.0 * mm; //Distance from Al outer face to Ge - //added to fudge PTG's efficiency measurements for close-geometry STUK config. - fFudge = 8.0*mm; - fEndCap2Ge_PhaseII += fFudge; - - //modify it to make it 5 mm - //fEndCap2Ge_PhaseII -= 23*mm; - - fGapBetweenLeaves_PhaseII = 0.8*mm; - - fHoleR_PhaseII = 5.0 * mm; //was 5.0 - //fPassiveThick_PhaseII = 0.5 * mm; - fContactThick_PhaseII = 0.5 * mm; - - //make the PhaseII solids - CreateCloverIISolids(); - //----------------------------------------------------- - - - //----------------------------------------------------- - //some default GREAT Clover parameters - fTotalGeL_GREAT = 105.0 * mm; - fTaperGeL_GREAT = 30.0 * mm; - fCrystalR_GREAT = 35.0 * mm; - - fFrontFaceSquare_GREAT = 54.00 * mm; - fBackFaceSquare_GREAT = 61.50 * mm; - fEndCap2Ge_GREAT = 10.00 * mm; //Distance from Al outer face to Ge - - fGapBetweenLeaves_GREAT = 0.8*mm; - - fHoleR_GREAT = 5.0 * mm; //was 5.0 - //fPassiveThick_GREAT = 0.5 * mm; - fContactThick_GREAT = 0.5 * mm; - //gap between GREAT clover and chamber in "TOP" position - fGeTopGap = 1.5 * mm; - - //make the GREAT Clover solids - CreateGREATCloverSolids(); - - //----------------------------------------------------- - //Default position of Ges relative to DSSD - geTopPosition = 0. * mm; //-1.5 mm puts the downstream endcap of the GREAT detector level with chamber - geSidePosition = 0. * mm; - //----------------------------------------------------- - - - - //Centre of Si Implantation detector [UPSTREAM] - fDSSD_BoardZ = -fDSSD_BoardL/2.; - fDSSD_BoardZ = 0.0 * mm; - G4cout << "Default SiSuport Z " << fDSSD_BoardZ - fDSSD_BoardL/2. << G4endl; - - - +Chamber::Chamber() : nStripsX(60), nStripsY(40) { + + // m_ChamberType = true; + m_ChamberType = 0; // normal + m_ChamberRmin = 0; + m_ChamberRmax = 0; + m_ChamberPhiMin = 0; + m_ChamberPhiMax = 0; + m_ChamberThetaMin = 0; + m_ChamberThetaMax = 0; + + DefineMaterials(); + + //----------------------------- + // defaults for Planar + fPlanarGuard = 5.0 * mm; + fPlanarGe_W = 120.0 * mm; + fPlanarGe_H = 60.0 * mm; + fPlanarGe_T = 15.0 * mm; + + fEndCapThickness = 2.7 * mm; // Notes state a 2.2 mm thick rib supporting a 0.5 mm Be window + fAlWindowThickness = 1.1 * mm; + fBeWindowThickness = 0.5 * mm; + + fPlanarGeGapFront = 14.0 * mm; // Front face Al -> Front face Ge + fPlanarGeGapBack = 9.0 * mm; // Back face Al -> Back face Ge + fPlanarGeGapFront = 16.0 * mm; // Front face Al -> Front face Ge + fPlanarGeGapBack = 7.0 * mm; // Back face Al -> Back face Ge + + fPlanarTotalL = 2. * fEndCapThickness + fPlanarGeGapFront + fPlanarGeGapBack + fPlanarGe_T; + + //--------------------------------------- + // I measured 39.5 mm for fPlanarTotalL + // => put end cap thickness 2.75 mm + // => add 1 mm to one of the gaps (most likely the retards put fPlanarGeGapFront = 15 mm !) + fPlanarTotalL = fEndCapThickness + fPlanarGeGapFront + fPlanarGeGapBack + fPlanarGe_T + fAlWindowThickness; + + fdeltaZ_Support = 0.0 * mm; // looks like there is a little gap between the cooling block and the planar cut-out + fGap_PCB_2_Planar = 6.0 * mm; // the gap between the downstrean part of the PCB and the upstream face of planar + fGap_PCB_2_Planar += fdeltaZ_Support; + fLengthOfPlanarCut = 55.0 * mm; // the Z dimension of the cut out used to remove the planar + //-------------------------------------------------------------- + // Cooling block dimensions + fCoolingBlockL = 79.0 * mm; + fCoolingBlockH = 152.0 * mm; + fCoolingBlockW = 176.7 * mm; + fCoolingBlockT = 6.0 * mm; // excellent idea for low energy transparency ! + + // Size of cut-out for the tunnel (and DSSD) + fCoolingBlockCutOutH = 74.4 * mm; + fCoolingBlockCutOutW = fCoolingBlockW - 2. * fCoolingBlockT; + fCoolingBlockDSSDCentre = fCoolingBlockH - fCoolingBlockT - fCoolingBlockCutOutH / 2.; + fDSSD_BoardL = 2.0 * mm; // thickness of Si implantation detector support board + + fCoolingBlockZ = fLengthOfPlanarCut + fDSSD_BoardL + + fdeltaZ_Support; // distance between chamber inner wall and downstream side of detector support + + G4cout << "fCoolingBlockZ " << fCoolingBlockZ << G4endl; + + //----------------------------- + // default DSSD + fDSSD_H = 40.0 * mm; // active + fDSSD_W = 60.0 * mm; // active + fDSSD_T = 0.3 * mm; + fDSSD_Guard = 1.0 * mm; + + //----------------------------------------------------- + // Put these defaults here so I can easily compare them + //----------------------------------------------------- + // some default PhaseII detector parameters + fTotalGeL_PhaseII = 70.0 * mm; // was 70 + fCrystalR_PhaseII = 24.0 * mm; // was 25 + fEndCap2Ge_PhaseII = 20.0 * mm; // Distance from Al outer face to Ge + // added to fudge PTG's efficiency measurements for close-geometry STUK config. + fFudge = 8.0 * mm; + fEndCap2Ge_PhaseII += fFudge; + + // modify it to make it 5 mm + // fEndCap2Ge_PhaseII -= 23*mm; + + fGapBetweenLeaves_PhaseII = 0.8 * mm; + + fHoleR_PhaseII = 5.0 * mm; // was 5.0 + // fPassiveThick_PhaseII = 0.5 * mm; + fContactThick_PhaseII = 0.5 * mm; + + // make the PhaseII solids + CreateCloverIISolids(); + //----------------------------------------------------- + + //----------------------------------------------------- + // some default GREAT Clover parameters + fTotalGeL_GREAT = 105.0 * mm; + fTaperGeL_GREAT = 30.0 * mm; + fCrystalR_GREAT = 35.0 * mm; + + fFrontFaceSquare_GREAT = 54.00 * mm; + fBackFaceSquare_GREAT = 61.50 * mm; + fEndCap2Ge_GREAT = 10.00 * mm; // Distance from Al outer face to Ge + + fGapBetweenLeaves_GREAT = 0.8 * mm; + + fHoleR_GREAT = 5.0 * mm; // was 5.0 + // fPassiveThick_GREAT = 0.5 * mm; + fContactThick_GREAT = 0.5 * mm; + // gap between GREAT clover and chamber in "TOP" position + fGeTopGap = 1.5 * mm; + + // make the GREAT Clover solids + CreateGREATCloverSolids(); + + //----------------------------------------------------- + // Default position of Ges relative to DSSD + geTopPosition = 0. * mm; //-1.5 mm puts the downstream endcap of the GREAT detector level with chamber + geSidePosition = 0. * mm; + //----------------------------------------------------- + + // Centre of Si Implantation detector [UPSTREAM] + fDSSD_BoardZ = -fDSSD_BoardL / 2.; + fDSSD_BoardZ = 0.0 * mm; + G4cout << "Default SiSuport Z " << fDSSD_BoardZ - fDSSD_BoardL / 2. << G4endl; } -G4Material* Chamber::GetMaterialFromLibrary(G4String MaterialName){ +G4Material* Chamber::GetMaterialFromLibrary(G4String MaterialName) { - if (MaterialName == "Alu") { - G4Material* myMaterial = new G4Material("Alu", 13, 26.98*g/mole, 2.7*g/cm3); - //G4Material* myMaterial = man->FindOrBuildMaterial("G4_Al"); - return myMaterial; - - } - if (MaterialName == "Cu") { - - G4Material* myMaterial = new G4Material("Cu", 29, 63.546*g/mole, 8.96*g/cm3); - // G4Material* myMaterial = man->FindOrBuildMaterial("G4_Cu"); - return myMaterial; - } - if (MaterialName == "12C") { - - G4Material* myMaterial = new G4Material("12C", 6, 12.011*g/mole, 2.62*g/cm3); - //G4Material* myMaterial = man->FindOrBuildMaterial("G4_C"); - - return myMaterial; - } + if (MaterialName == "Alu") { + G4Material* myMaterial = new G4Material("Alu", 13, 26.98 * g / mole, 2.7 * g / cm3); + // G4Material* myMaterial = man->FindOrBuildMaterial("G4_Al"); + return myMaterial; + } + if (MaterialName == "Cu") { - else { - G4cout << "No Matching Material in the Chamber Library Default is Vacuum" << G4endl; - G4Element* N = new G4Element("Nitrogen", "N", 7., 14.01*g / mole); - G4Element* O = new G4Element("Oxygen" , "O", 8., 16.00*g / mole); - G4Material* myMaterial = new G4Material("Vacuum", 0.000000001*mg / cm3, 2); - myMaterial->AddElement(N, .7); - myMaterial->AddElement(O, .3); + G4Material* myMaterial = new G4Material("Cu", 29, 63.546 * g / mole, 8.96 * g / cm3); + // G4Material* myMaterial = man->FindOrBuildMaterial("G4_Cu"); + return myMaterial; + } + if (MaterialName == "12C") { - //G4Material* myMaterial = man->FindOrBuildMaterial("G4_Galactic"); - //G4Element* N = man->FindOrBuildElement("G4_N"); - //G4Element* O = man->FindOrBuildElement("G4_O"); - //const std::vector<G4int> Zvac; - //const std::vector<G4double> Wvac; - //G4Material* myMaterial = man->FindOrBuildMaterial("Vacuum"); - //myMaterial = man->ConstructNewMaterial("Vacuum", Zvac,Wvac,0.000000001*mg / cm3); + G4Material* myMaterial = new G4Material("12C", 6, 12.011 * g / mole, 2.62 * g / cm3); + // G4Material* myMaterial = man->FindOrBuildMaterial("G4_C"); + return myMaterial; + } - return(myMaterial); - } + else { + G4cout << "No Matching Material in the Chamber Library Default is Vacuum" << G4endl; + G4Element* N = new G4Element("Nitrogen", "N", 7., 14.01 * g / mole); + G4Element* O = new G4Element("Oxygen", "O", 8., 16.00 * g / mole); + G4Material* myMaterial = new G4Material("Vacuum", 0.000000001 * mg / cm3, 2); + myMaterial->AddElement(N, .7); + myMaterial->AddElement(O, .3); + + // G4Material* myMaterial = man->FindOrBuildMaterial("G4_Galactic"); + // G4Element* N = man->FindOrBuildElement("G4_N"); + // G4Element* O = man->FindOrBuildElement("G4_O"); + // const std::vector<G4int> Zvac; + // const std::vector<G4double> Wvac; + // G4Material* myMaterial = man->FindOrBuildMaterial("Vacuum"); + // myMaterial = man->ConstructNewMaterial("Vacuum", Zvac,Wvac,0.000000001*mg / cm3); + + return (myMaterial); + } } - - //------------------------------------------------------------------ -//Materials Definitions -void Chamber::DefineMaterials() -{ - G4double a; // atomic mass - G4double z; // atomic number +// Materials Definitions +void Chamber::DefineMaterials() { + G4double a; // atomic mass + G4double z; // atomic number G4double density; G4String name, symbol; - G4int ncomponents, natoms; + G4int ncomponents, natoms; G4double fractionmass; - + //--------------------------------- - //some elements - a = 1.0078*g/mole; - G4Element* elH = new G4Element(name="Hydrogen", symbol="H", z=1., a); - - a = 12.00*g/mole; - G4Element* elC = new G4Element(name="Carbon", symbol="C", z=6., a); - - a = 14.01*g/mole; - G4Element* elN = new G4Element(name="Nitrogen", symbol="N", z=7., a); - - a = 16.00*g/mole; - G4Element* elO = new G4Element(name="Oxygen", symbol="O", z=8., a); - - a = 24.305*g/mole; - G4Element* elMg = new G4Element(name="Magnesium", symbol="Mg", z=12., a); - - a = 26.98*g/mole; - G4Element* elAl = new G4Element(name="Aluminium", symbol="Al", z=13., a); - - a = 35.45*g/mole; - G4Element* elCl = new G4Element(name="Chlorine", symbol="Cl", z=17., a); - - a = 51.9961*g/mole; - G4Element* elCr = new G4Element(name="Chromium", symbol="Cr", z=24., a); - - a = 54.938*g/mole; - G4Element* elMn = new G4Element(name="Manganse", symbol="Mn", z=25., a); - - a = 55.845*g/mole; - G4Element* elFe = new G4Element(name="Iron", symbol="Fe", z=26., a); - - a = 58.6934*g/mole; - G4Element* elNi = new G4Element(name="Nickel", symbol="Ni", z=28., a); - - a = 63.54*g/mole; - G4Element* elCu = new G4Element(name="Copper", symbol="Cu", z=29., a); - - a = 65.39*g/mole; - G4Element* elZn = new G4Element(name="Zinc", symbol="Zn", z=30., a); - - a = 72.61*g/mole; - G4Element* elGe = new G4Element(name="Germanium", symbol="Ge", z=32., a); - - a =208.98*g/mole; - G4Element* elBi = new G4Element(name="Bismuth", symbol="Bi", z=83., a); - - //elements for physics.... - a =251.00*g/mole; - G4Element* elEs = new G4Element(name="Einsteinium",symbol="Es", z=99., a); + // some elements + a = 1.0078 * g / mole; + G4Element* elH = new G4Element(name = "Hydrogen", symbol = "H", z = 1., a); + + a = 12.00 * g / mole; + G4Element* elC = new G4Element(name = "Carbon", symbol = "C", z = 6., a); + + a = 14.01 * g / mole; + G4Element* elN = new G4Element(name = "Nitrogen", symbol = "N", z = 7., a); + + a = 16.00 * g / mole; + G4Element* elO = new G4Element(name = "Oxygen", symbol = "O", z = 8., a); + + a = 24.305 * g / mole; + G4Element* elMg = new G4Element(name = "Magnesium", symbol = "Mg", z = 12., a); + + a = 26.98 * g / mole; + G4Element* elAl = new G4Element(name = "Aluminium", symbol = "Al", z = 13., a); + + a = 35.45 * g / mole; + G4Element* elCl = new G4Element(name = "Chlorine", symbol = "Cl", z = 17., a); + + a = 51.9961 * g / mole; + G4Element* elCr = new G4Element(name = "Chromium", symbol = "Cr", z = 24., a); + + a = 54.938 * g / mole; + G4Element* elMn = new G4Element(name = "Manganse", symbol = "Mn", z = 25., a); + + a = 55.845 * g / mole; + G4Element* elFe = new G4Element(name = "Iron", symbol = "Fe", z = 26., a); + + a = 58.6934 * g / mole; + G4Element* elNi = new G4Element(name = "Nickel", symbol = "Ni", z = 28., a); + + a = 63.54 * g / mole; + G4Element* elCu = new G4Element(name = "Copper", symbol = "Cu", z = 29., a); + + a = 65.39 * g / mole; + G4Element* elZn = new G4Element(name = "Zinc", symbol = "Zn", z = 30., a); + + a = 72.61 * g / mole; + G4Element* elGe = new G4Element(name = "Germanium", symbol = "Ge", z = 32., a); + + a = 208.98 * g / mole; + G4Element* elBi = new G4Element(name = "Bismuth", symbol = "Bi", z = 83., a); + + // elements for physics.... + a = 251.00 * g / mole; + G4Element* elEs = new G4Element(name = "Einsteinium", symbol = "Es", z = 99., a); einsteinium = elEs; - a =251.00*g/mole; - G4Element* elFm = new G4Element(name="Fermium", symbol="Fm", z=100., a); + a = 251.00 * g / mole; + G4Element* elFm = new G4Element(name = "Fermium", symbol = "Fm", z = 100., a); fermium = elFm; - + //--------------------------------- - //Define required materials - a=6.941*g/mole; density=0.534*g/cm3; - G4Material* Li=new G4Material(name="Lithium", z=3., a, density); - - a=9.0122*g/mole; density=1.85*g/cm3; - G4Material* Be=new G4Material(name="Berilium", z=4., a, density); - - a=28.0855*g/mole; density=2.33*g/cm3; - G4Material* Si=new G4Material(name="Silicon", z=14., a, density); - - a=72.61*g/mole; density=5.32*g/cm3; - G4Material* Ge=new G4Material(name="Germanium", z=32., a, density); - - a=26.98*g/mole; density=2.7*g/cm3; - //G4Material* Al=new G4Material(name="Aluminium", z=13., a, density); - - a=63.54*g/mole; density=8.96*g/cm3; - //G4Material* Cu=new G4Material(name="Copper", z=29., a, density); - - a=183.84*g/mole; density=19.3*g/cm3; - //G4Material* W=new G4Material(name="Tungsten", z=74., a, density); - + // Define required materials + a = 6.941 * g / mole; + density = 0.534 * g / cm3; + G4Material* Li = new G4Material(name = "Lithium", z = 3., a, density); + + a = 9.0122 * g / mole; + density = 1.85 * g / cm3; + G4Material* Be = new G4Material(name = "Berilium", z = 4., a, density); + + a = 28.0855 * g / mole; + density = 2.33 * g / cm3; + G4Material* Si = new G4Material(name = "Silicon", z = 14., a, density); + + a = 72.61 * g / mole; + density = 5.32 * g / cm3; + G4Material* Ge = new G4Material(name = "Germanium", z = 32., a, density); + + a = 26.98 * g / mole; + density = 2.7 * g / cm3; + // G4Material* Al=new G4Material(name="Aluminium", z=13., a, density); + + a = 63.54 * g / mole; + density = 8.96 * g / cm3; + // G4Material* Cu=new G4Material(name="Copper", z=29., a, density); + + a = 183.84 * g / mole; + density = 19.3 * g / cm3; + // G4Material* W=new G4Material(name="Tungsten", z=74., a, density); + //--------------------------------- // AIR - density = 1.290*mg/cm3; - G4Material* Air = new G4Material(name="Air", density, ncomponents=2); - Air->AddElement(elN, fractionmass=70*perCent); - Air->AddElement(elO, fractionmass=30*perCent); - - density = 1.e-5*g/cm3; //taken from ExN03 - G4double pressure = 2.e-7*bar; + density = 1.290 * mg / cm3; + G4Material* Air = new G4Material(name = "Air", density, ncomponents = 2); + Air->AddElement(elN, fractionmass = 70 * perCent); + Air->AddElement(elO, fractionmass = 30 * perCent); + + density = 1.e-5 * g / cm3; // taken from ExN03 + G4double pressure = 2.e-7 * bar; G4double temperature = STP_Temperature; - G4Material* Vacuum=new G4Material(name="Vacuum", density, ncomponents=1, - kStateGas, temperature, pressure); - Vacuum->AddMaterial(Air, fractionmass=1.); + G4Material* Vacuum = new G4Material(name = "Vacuum", density, ncomponents = 1, kStateGas, temperature, pressure); + Vacuum->AddMaterial(Air, fractionmass = 1.); //--------------------------------- // Pentane - density = 0.620*g/cm3; //liquid ! - density = 5.9e-6*g/cm3; //gas - pressure = 1.5/760.0*atmosphere; - temperature = 310*kelvin; - G4Material* Pentane=new G4Material(name="Pentane", density, ncomponents=2, - kStateGas, temperature, pressure); - Pentane->AddElement(elH, natoms=12); - Pentane->AddElement(elC, natoms=5); + density = 0.620 * g / cm3; // liquid ! + density = 5.9e-6 * g / cm3; // gas + pressure = 1.5 / 760.0 * atmosphere; + temperature = 310 * kelvin; + G4Material* Pentane = new G4Material(name = "Pentane", density, ncomponents = 2, kStateGas, temperature, pressure); + Pentane->AddElement(elH, natoms = 12); + Pentane->AddElement(elC, natoms = 5); //------------------------------------------------------------------ - //18-8 (stainless) steel - density = 8.00*g/cm3; - G4Material* Steel = new G4Material(name="Steel", density, ncomponents=3); - Steel->AddElement(elCr, natoms= 8); - Steel->AddElement(elNi, natoms=18); - Steel->AddElement(elFe, natoms=74); - + // 18-8 (stainless) steel + density = 8.00 * g / cm3; + G4Material* Steel = new G4Material(name = "Steel", density, ncomponents = 3); + Steel->AddElement(elCr, natoms = 8); + Steel->AddElement(elNi, natoms = 18); + Steel->AddElement(elFe, natoms = 74); + //------------------------------------------------------------------ - //Brass (there are many compositions) - density = 8.87*g/cm3; - G4Material* Brass = new G4Material(name="Brass", density, ncomponents=3); - Brass->AddElement(elCu, fractionmass=70.0*perCent); - Brass->AddElement(elZn, fractionmass=28.8*perCent); - Brass->AddElement(elMn, fractionmass= 1.2*perCent); + // Brass (there are many compositions) + density = 8.87 * g / cm3; + G4Material* Brass = new G4Material(name = "Brass", density, ncomponents = 3); + Brass->AddElement(elCu, fractionmass = 70.0 * perCent); + Brass->AddElement(elZn, fractionmass = 28.8 * perCent); + Brass->AddElement(elMn, fractionmass = 1.2 * perCent); //------------------------------------------------------------------ - //DurAl [3-4% Cu, 0.5% Mg, 0.25-1%Mn, remainder Al] : use average val - density = 2.8*g/cm3; - G4Material* DurAl = new G4Material(name="DurAluminium", - density, ncomponents=4); - DurAl->AddElement(elCu, fractionmass= 3.5*perCent); - DurAl->AddElement(elMg, fractionmass= 0.5*perCent); - DurAl->AddElement(elMn, fractionmass= 0.6*perCent); - DurAl->AddElement(elAl, fractionmass=95.4*perCent); + // DurAl [3-4% Cu, 0.5% Mg, 0.25-1%Mn, remainder Al] : use average val + density = 2.8 * g / cm3; + G4Material* DurAl = new G4Material(name = "DurAluminium", density, ncomponents = 4); + DurAl->AddElement(elCu, fractionmass = 3.5 * perCent); + DurAl->AddElement(elMg, fractionmass = 0.5 * perCent); + DurAl->AddElement(elMn, fractionmass = 0.6 * perCent); + DurAl->AddElement(elAl, fractionmass = 95.4 * perCent); //------------------------------------------------------------------ - //Epoxy for Si detector support - density = 1.18*g/cm3;//cast - density = 1.85*g/cm3;//molded - G4Material* Epoxy = new G4Material(name="Epoxy", density, ncomponents=3); - Epoxy->AddElement(elH, natoms=19); - Epoxy->AddElement(elC, natoms=18); - Epoxy->AddElement(elO, natoms= 3); + // Epoxy for Si detector support + density = 1.18 * g / cm3; // cast + density = 1.85 * g / cm3; // molded + G4Material* Epoxy = new G4Material(name = "Epoxy", density, ncomponents = 3); + Epoxy->AddElement(elH, natoms = 19); + Epoxy->AddElement(elC, natoms = 18); + Epoxy->AddElement(elO, natoms = 3); //------------------------------------------------------------------ - //Plastic support for the Si detector support - density = 1.68*g/cm3;//PVC - G4Material* Pvc = new G4Material(name="PVC", density, ncomponents=3); - Pvc->AddElement(elH, natoms=3); - Pvc->AddElement(elC, natoms=2); - Pvc->AddElement(elCl, natoms=1); + // Plastic support for the Si detector support + density = 1.68 * g / cm3; // PVC + G4Material* Pvc = new G4Material(name = "PVC", density, ncomponents = 3); + Pvc->AddElement(elH, natoms = 3); + Pvc->AddElement(elC, natoms = 2); + Pvc->AddElement(elCl, natoms = 1); //------------------------------------------------------------------ - //BGO - density = 7.13*g/cm3;//cast - G4Material* BGO = new G4Material(name="BGO", density, ncomponents=3); - BGO->AddElement(elBi, natoms= 4); - BGO->AddElement(elGe, natoms= 3); - BGO->AddElement(elO, natoms=12); + // BGO + density = 7.13 * g / cm3; // cast + G4Material* BGO = new G4Material(name = "BGO", density, ncomponents = 3); + BGO->AddElement(elBi, natoms = 4); + BGO->AddElement(elGe, natoms = 3); + BGO->AddElement(elO, natoms = 12); //--------------------------------- //--------------------------------- @@ -414,27 +401,24 @@ void Chamber::DefineMaterials() G4cout << *(G4Material::GetMaterialTable()) << G4endl; //--------------------------------- - //Default materials - WorldMaterial = Air; - chamberMaterial = DurAl; - //backplateMaterial = DurAl; - defaultMaterial = Ge; - eDetMat = Si; - boardMaterial = Epoxy; - supportMaterial = Steel; - metalbarMaterial = Steel; - geMaterial = Ge; - endCapMaterial = DurAl; - contactMaterial = Li; - //vacuumInVacChamMat = Pentane; - vacuumMaterial = Vacuum; - beMaterial = Be; - //coolMaterial = Cu; + // Default materials + WorldMaterial = Air; + chamberMaterial = DurAl; + // backplateMaterial = DurAl; + defaultMaterial = Ge; + eDetMat = Si; + boardMaterial = Epoxy; + supportMaterial = Steel; + metalbarMaterial = Steel; + geMaterial = Ge; + endCapMaterial = DurAl; + contactMaterial = Li; + // vacuumInVacChamMat = Pentane; + vacuumMaterial = Vacuum; + beMaterial = Be; + // coolMaterial = Cu; } - - - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... @@ -442,143 +426,137 @@ void Chamber::DefineMaterials() // Read stream at Configfile to pick-up parameters of detector (Position,...) // Called in DetecorConstruction::ReadDetextorConfiguration Method -//void Chamber::ReadConfiguration(string Path) +// void Chamber::ReadConfiguration(string Path) //{ -void Chamber::ReadConfiguration(NPL::InputParser parser){ - vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithTokenAndValue("Chamber","Great-Karl"); - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << "//// " << blocks.size() << " GREAT Chmaber found " << endl; - - vector<string> token = {"Heightmin","Heightmax","Widthmin","Widthmax","Depthmin","Depthmax","Material"}; - - for(unsigned int i = 0 ; i < blocks.size() ; i++){ - - if(blocks[i]->HasTokenList(token)){ - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << endl << "//// Great chamber as defined by Karl " << i+1 << endl; - m_ChamberType = 3 ; - m_ChamberHmin = blocks[i]->GetDouble("Heightmin","mm"); - m_ChamberHmax = blocks[i]->GetDouble("Heightmax","mm"); - m_ChamberWmin = blocks[i]->GetDouble("Widthmin","mm"); - m_ChamberWmax = blocks[i]->GetDouble("Widthmax","mm"); - m_ChamberDmin = blocks[i]->GetDouble("Depthmin","mm"); - m_ChamberDmax = blocks[i]->GetDouble("Depthmax","mm"); - m_ChamberMaterial=GetMaterialFromLibrary(blocks[i]->GetString("Material")); +void Chamber::ReadConfiguration(NPL::InputParser parser) { + vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithTokenAndValue("Chamber", "Great-Karl"); + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks.size() << " GREAT Chmaber found " << endl; + + vector<string> token = {"Heightmin", "Heightmax", "Widthmin", "Widthmax", "Depthmin", "Depthmax", "Material"}; + + for (unsigned int i = 0; i < blocks.size(); i++) { + + if (blocks[i]->HasTokenList(token)) { + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// Great chamber as defined by Karl " << i + 1 << endl; + m_ChamberType = 3; + m_ChamberHmin = blocks[i]->GetDouble("Heightmin", "mm"); + m_ChamberHmax = blocks[i]->GetDouble("Heightmax", "mm"); + m_ChamberWmin = blocks[i]->GetDouble("Widthmin", "mm"); + m_ChamberWmax = blocks[i]->GetDouble("Widthmax", "mm"); + m_ChamberDmin = blocks[i]->GetDouble("Depthmin", "mm"); + m_ChamberDmax = blocks[i]->GetDouble("Depthmax", "mm"); + m_ChamberMaterial = GetMaterialFromLibrary(blocks[i]->GetString("Material")); } - else{ + else { cout << "Warning: check your input file formatting " << endl; } } blocks.clear(); - blocks = parser.GetAllBlocksWithTokenAndValue("Chamber","Great"); - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << "//// " << blocks.size() << " Great Chamber found " << endl; - - - for(unsigned int i = 0 ; i < blocks.size() ; i++){ - if(blocks[i]->HasTokenList(token)){ - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << endl << "//// Great standard chamber " << i+1 << endl; - m_ChamberType = 2 ; - m_ChamberHmin = blocks[i]->GetDouble("Heightmin","mm"); - m_ChamberHmax = blocks[i]->GetDouble("Heightmax","mm"); - m_ChamberWmin = blocks[i]->GetDouble("Widthmin","mm"); - m_ChamberWmax = blocks[i]->GetDouble("Widthmax","mm"); - m_ChamberDmin = blocks[i]->GetDouble("Depthmin","mm"); - m_ChamberDmax = blocks[i]->GetDouble("Depthmax","mm"); - m_ChamberMaterial=GetMaterialFromLibrary(blocks[i]->GetString("Material")); + blocks = parser.GetAllBlocksWithTokenAndValue("Chamber", "Great"); + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks.size() << " Great Chamber found " << endl; + + for (unsigned int i = 0; i < blocks.size(); i++) { + if (blocks[i]->HasTokenList(token)) { + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// Great standard chamber " << i + 1 << endl; + m_ChamberType = 2; + m_ChamberHmin = blocks[i]->GetDouble("Heightmin", "mm"); + m_ChamberHmax = blocks[i]->GetDouble("Heightmax", "mm"); + m_ChamberWmin = blocks[i]->GetDouble("Widthmin", "mm"); + m_ChamberWmax = blocks[i]->GetDouble("Widthmax", "mm"); + m_ChamberDmin = blocks[i]->GetDouble("Depthmin", "mm"); + m_ChamberDmax = blocks[i]->GetDouble("Depthmax", "mm"); + m_ChamberMaterial = GetMaterialFromLibrary(blocks[i]->GetString("Material")); } - else{ + else { cout << "Warning: check your input file formatting " << endl; } } blocks.clear(); - blocks = parser.GetAllBlocksWithTokenAndValue("Chamber",""); - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << "//// " << blocks.size() << " Chamber found " << endl; - - token = {"Rmin","Rmax","PhiMin","PhiMax","ThetaMin","ThetaMax","Material"}; - - for(unsigned int i = 0 ; i < blocks.size() ; i++){ - if(blocks[i]->HasTokenList(token)){ - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << endl << "//// Generic Chamber " << i+1 << endl; - m_ChamberType = 0 ; - m_ChamberRmin = blocks[i]->GetDouble("Rmin","mm"); - m_ChamberRmax = blocks[i]->GetDouble("Rmax","mm"); - m_ChamberPhiMin = blocks[i]->GetDouble("PhiMin","deg"); - m_ChamberPhiMax = blocks[i]->GetDouble("PhiMax","deg"); - m_ChamberThetaMin = blocks[i]->GetDouble("ThetaMin","deg"); - m_ChamberThetaMax = blocks[i]->GetDouble("ThetaMax","deg"); - m_ChamberMaterial=GetMaterialFromLibrary(blocks[i]->GetString("Material")); + blocks = parser.GetAllBlocksWithTokenAndValue("Chamber", ""); + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks.size() << " Chamber found " << endl; + + token = {"Rmin", "Rmax", "PhiMin", "PhiMax", "ThetaMin", "ThetaMax", "Material"}; + + for (unsigned int i = 0; i < blocks.size(); i++) { + if (blocks[i]->HasTokenList(token)) { + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// Generic Chamber " << i + 1 << endl; + m_ChamberType = 0; + m_ChamberRmin = blocks[i]->GetDouble("Rmin", "mm"); + m_ChamberRmax = blocks[i]->GetDouble("Rmax", "mm"); + m_ChamberPhiMin = blocks[i]->GetDouble("PhiMin", "deg"); + m_ChamberPhiMax = blocks[i]->GetDouble("PhiMax", "deg"); + m_ChamberThetaMin = blocks[i]->GetDouble("ThetaMin", "deg"); + m_ChamberThetaMax = blocks[i]->GetDouble("ThetaMax", "deg"); + m_ChamberMaterial = GetMaterialFromLibrary(blocks[i]->GetString("Material")); } - else{ + else { cout << "Warning: check your input file formatting " << endl; } } - blocks.clear(); - blocks = parser.GetAllBlocksWithTokenAndValue("Chamber","MARA"); - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << "//// " << blocks.size() << " MARA chamber found " << endl; + blocks = parser.GetAllBlocksWithTokenAndValue("Chamber", "MARA"); + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks.size() << " MARA chamber found " << endl; - token = {"GDMLFilePath","GDMLFileName","GDMLWorldName"}; + token = {"GDMLFilePath", "GDMLFileName", "GDMLWorldName"}; - - for(unsigned int i = 0 ; i < blocks.size() ; i++){ - if(blocks[i]->HasTokenList(token)){ - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << endl << "//// Great standard chamber " << i+1 << endl; - m_ChamberType = 4 ; + for (unsigned int i = 0; i < blocks.size(); i++) { + if (blocks[i]->HasTokenList(token)) { + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// Great standard chamber " << i + 1 << endl; + m_ChamberType = 4; m_GDMLPath = blocks[i]->GetString("GDMLFilePath"); m_GDMLName = blocks[i]->GetString("GDMLFileName"); m_GDMLWorld = blocks[i]->GetString("GDMLWorldName"); } - else{ + else { cout << "Warning: check your input file formatting " << endl; } } blocks.clear(); - blocks = parser.GetAllBlocksWithTokenAndValue("Chamber","MUGAST"); - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << "//// " << blocks.size() << " MuGasT chamber found " << endl; - - token = {"GDMLFilePath","GDMLFileName","GDMLWorldName"}; + blocks = parser.GetAllBlocksWithTokenAndValue("Chamber", "MUGAST"); + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks.size() << " MuGasT chamber found " << endl; + token = {"GDMLFilePath", "GDMLFileName", "GDMLWorldName"}; - for(unsigned int i = 0 ; i < blocks.size() ; i++){ - if(blocks[i]->HasTokenList(token)){ - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << endl << "//// standard chamber " << i+1 << endl; - m_ChamberType = 5 ; + for (unsigned int i = 0; i < blocks.size(); i++) { + if (blocks[i]->HasTokenList(token)) { + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// standard chamber " << i + 1 << endl; + m_ChamberType = 5; m_GDMLPath = blocks[i]->GetString("GDMLFilePath"); m_GDMLName = blocks[i]->GetString("GDMLFileName"); m_GDMLWorld = blocks[i]->GetString("GDMLWorldName"); } - else{ + else { cout << "Warning: check your input file formatting " << endl; } } - } - /* ifstream ConfigFile; ConfigFile.open(Path.c_str()); string LineBuffer; string DataBuffer; - + bool ReadingStatusChamber = false ; bool ReadingStatusGREATChamber = false ; bool ReadingStatusMARAChamber = false ; @@ -598,7 +576,7 @@ void Chamber::ReadConfiguration(NPL::InputParser parser){ bool check_Wmax = false ; bool check_Dmin = false ; bool check_Dmax = false ; - + bool check_GDMLPath = false ; bool check_GDMLName = false ; bool check_GDMLWorld = false ; @@ -617,7 +595,7 @@ void Chamber::ReadConfiguration(NPL::InputParser parser){ // m_ChamberType = false ; // ReadingStatusCryoChamber = true ; //} - + else if (LineBuffer.compare(0, 12, "GREATChamber") == 0) { cout << "GREAT Chamber Found" << endl; m_ChamberType = 2 ; @@ -633,182 +611,186 @@ void Chamber::ReadConfiguration(NPL::InputParser parser){ m_ChamberType = 4 ; ReadingStatusMARAChamber = true ; } - + while (ReadingStatusChamber) { ConfigFile >> DataBuffer; - - //Search for comment Symbol % - if (DataBuffer.compare(0, 1, "%") == 0) { ConfigFile.ignore ( std::numeric_limits<std::streamsize>::max(), '\n' );} - - else if (DataBuffer.compare(0, 5, "Rmin=") == 0) { - check_Rmin = true ; - ConfigFile >> DataBuffer; - m_ChamberRmin = atof(DataBuffer.c_str()) * mm; - cout << "Chamber inner radius: " << m_ChamberRmin << endl ; - } - - else if (DataBuffer.compare(0, 5, "Rmax=") == 0) { - check_Rmax = true ; - ConfigFile >> DataBuffer; - m_ChamberRmax = atof(DataBuffer.c_str()) * mm; - cout << "Chamber outer radius: " << m_ChamberRmax << endl ; - } - - else if (DataBuffer.compare(0, 7, "PhiMin=") == 0) { - check_PhiMin = true ; - ConfigFile >> DataBuffer; - m_ChamberPhiMin = atof(DataBuffer.c_str()) * rad; - cout << "Chamber PhiMin: " << m_ChamberPhiMin << endl ; - } - else if (DataBuffer.compare(0, 7, "PhiMax=") == 0) { - check_PhiMax = true ; - ConfigFile >> DataBuffer; - m_ChamberPhiMax = atof(DataBuffer.c_str()) * rad; - cout << "Chamber PhiMax: " << m_ChamberPhiMax << endl ; - } - else if (DataBuffer.compare(0, 9, "ThetaMin=") == 0) { - check_ThetaMin = true ; - ConfigFile >> DataBuffer; - m_ChamberThetaMin = atof(DataBuffer.c_str()) * rad; - cout << "Chamber ThetaMin: " << m_ChamberThetaMin << endl ; - } - else if (DataBuffer.compare(0, 9, "ThetaMax=") == 0) { - check_ThetaMax = true ; - ConfigFile >> DataBuffer; - m_ChamberThetaMax = atof(DataBuffer.c_str()) * rad; - cout << "Chamber ThetaMax: " << m_ChamberThetaMax << endl ; - } - - else if (DataBuffer.compare(0, 9, "MATERIAL=") == 0) { - check_Material = true ; - ConfigFile >> DataBuffer; - m_ChamberMaterial = GetMaterialFromLibrary(DataBuffer); - cout << "Chamber Material: " << m_ChamberMaterial << endl ; - } - - /////////////////////////////////////////////////// - // If no Beam Token and no comment, toggle out - else - {ReadingStatusChamber = false; G4cout << "WARNING : Wrong Token Sequence: Getting out " << G4endl ;} - - /////////////////////////////////////////////////// - // If all Token found toggle out - if( check_Rmin && check_Rmax && check_Material && check_PhiMin && check_PhiMax && check_ThetaMin && check_ThetaMax ) - ReadingStatusChamber = false ; - - } - + + //Search for comment Symbol % + if (DataBuffer.compare(0, 1, "%") == 0) { ConfigFile.ignore ( std::numeric_limits<std::streamsize>::max(), +'\n' );} + + else if (DataBuffer.compare(0, 5, "Rmin=") == 0) { + check_Rmin = true ; + ConfigFile >> DataBuffer; + m_ChamberRmin = atof(DataBuffer.c_str()) * mm; + cout << "Chamber inner radius: " << m_ChamberRmin << endl ; + } + + else if (DataBuffer.compare(0, 5, "Rmax=") == 0) { + check_Rmax = true ; + ConfigFile >> DataBuffer; + m_ChamberRmax = atof(DataBuffer.c_str()) * mm; + cout << "Chamber outer radius: " << m_ChamberRmax << endl ; + } + + else if (DataBuffer.compare(0, 7, "PhiMin=") == 0) { + check_PhiMin = true ; + ConfigFile >> DataBuffer; + m_ChamberPhiMin = atof(DataBuffer.c_str()) * rad; + cout << "Chamber PhiMin: " << m_ChamberPhiMin << endl ; + } + else if (DataBuffer.compare(0, 7, "PhiMax=") == 0) { + check_PhiMax = true ; + ConfigFile >> DataBuffer; + m_ChamberPhiMax = atof(DataBuffer.c_str()) * rad; + cout << "Chamber PhiMax: " << m_ChamberPhiMax << endl ; + } + else if (DataBuffer.compare(0, 9, "ThetaMin=") == 0) { + check_ThetaMin = true ; + ConfigFile >> DataBuffer; + m_ChamberThetaMin = atof(DataBuffer.c_str()) * rad; + cout << "Chamber ThetaMin: " << m_ChamberThetaMin << endl ; + } + else if (DataBuffer.compare(0, 9, "ThetaMax=") == 0) { + check_ThetaMax = true ; + ConfigFile >> DataBuffer; + m_ChamberThetaMax = atof(DataBuffer.c_str()) * rad; + cout << "Chamber ThetaMax: " << m_ChamberThetaMax << endl ; + } + + else if (DataBuffer.compare(0, 9, "MATERIAL=") == 0) { + check_Material = true ; + ConfigFile >> DataBuffer; + m_ChamberMaterial = GetMaterialFromLibrary(DataBuffer); + cout << "Chamber Material: " << m_ChamberMaterial << endl ; + } + + /////////////////////////////////////////////////// + // If no Beam Token and no comment, toggle out + else + {ReadingStatusChamber = false; G4cout << "WARNING : Wrong Token Sequence: Getting out " << G4endl ;} + + /////////////////////////////////////////////////// + // If all Token found toggle out + if( check_Rmin && check_Rmax && check_Material && check_PhiMin && check_PhiMax && check_ThetaMin && +check_ThetaMax ) ReadingStatusChamber = false ; + + } + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //// For MARA Chamber while (ReadingStatusMARAChamber) { ConfigFile >> DataBuffer; - - //Search for comment Symbol % - if (DataBuffer.compare(0, 1, "%") == 0) { ConfigFile.ignore ( std::numeric_limits<std::streamsize>::max(), '\n' );} - - else if (DataBuffer.compare(0, 13, "GDMLFilePath=") == 0) { - check_GDMLPath = true ; - ConfigFile >> DataBuffer; - m_GDMLPath = DataBuffer.c_str(); - cout << "Path: " << m_GDMLPath << endl ; - } - else if (DataBuffer.compare(0, 13, "GDMLFileName=") == 0) { - check_GDMLName = true ; - ConfigFile >> DataBuffer; - m_GDMLName = DataBuffer.c_str(); - cout << "Name: " << m_GDMLName << endl ; - } - else if (DataBuffer.compare(0, 14, "GDMLWorldName=") == 0) { - check_GDMLWorld = true ; - ConfigFile >> DataBuffer; - m_GDMLWorld = DataBuffer.c_str(); - cout << "World Name: " << m_GDMLWorld << endl ; - } - /////////////////////////////////////////////////// - // If no Beam Token and no comment, toggle out - else - {ReadingStatusMARAChamber = false; G4cout << "WARNING : Wrong Token Sequence for MARA: Getting out " << G4endl ;} - // If all Token found toggle out - if( check_GDMLPath && check_GDMLName && check_GDMLWorld ) - ReadingStatusMARAChamber = false ; - - - } - - - + + //Search for comment Symbol % + if (DataBuffer.compare(0, 1, "%") == 0) { ConfigFile.ignore ( std::numeric_limits<std::streamsize>::max(), +'\n' );} + + else if (DataBuffer.compare(0, 13, "GDMLFilePath=") == 0) { + check_GDMLPath = true ; + ConfigFile >> DataBuffer; + m_GDMLPath = DataBuffer.c_str(); + cout << "Path: " << m_GDMLPath << endl ; + } + else if (DataBuffer.compare(0, 13, "GDMLFileName=") == 0) { + check_GDMLName = true ; + ConfigFile >> DataBuffer; + m_GDMLName = DataBuffer.c_str(); + cout << "Name: " << m_GDMLName << endl ; + } + else if (DataBuffer.compare(0, 14, "GDMLWorldName=") == 0) { + check_GDMLWorld = true ; + ConfigFile >> DataBuffer; + m_GDMLWorld = DataBuffer.c_str(); + cout << "World Name: " << m_GDMLWorld << endl ; + } + /////////////////////////////////////////////////// + // If no Beam Token and no comment, toggle out + else + {ReadingStatusMARAChamber = false; G4cout << "WARNING : Wrong Token Sequence for MARA: Getting out " << +G4endl ;} + // If all Token found toggle out + if( check_GDMLPath && check_GDMLName && check_GDMLWorld ) + ReadingStatusMARAChamber = false ; + + + } + + + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //// For GREAT Chamber while (ReadingStatusGREATChamber) { ConfigFile >> DataBuffer; - - //Search for comment Symbol % - if (DataBuffer.compare(0, 1, "%") == 0) { ConfigFile.ignore ( std::numeric_limits<std::streamsize>::max(), '\n' );} - - else if (DataBuffer.compare(0, 10, "Heightmin=") == 0) { - check_Hmin = true ; - ConfigFile >> DataBuffer; - m_ChamberHmin = atof(DataBuffer.c_str()) * mm; - cout << "Chamber inner radius: " << m_ChamberHmin << endl ; - } - - else if (DataBuffer.compare(0, 10, "Heightmax=") == 0) { - check_Hmax = true ; - ConfigFile >> DataBuffer; - m_ChamberHmax = atof(DataBuffer.c_str()) * mm; - cout << "Chamber outer radius: " << m_ChamberHmax << endl ; - } - else if (DataBuffer.compare(0, 9, "Widthmin=") == 0) { - check_Wmin = true ; - ConfigFile >> DataBuffer; - m_ChamberWmin = atof(DataBuffer.c_str()) * mm; - cout << "Chamber inner radius: " << m_ChamberWmin << endl ; - } - - else if (DataBuffer.compare(0, 9, "Widthmax=") == 0) { - check_Wmax = true ; - ConfigFile >> DataBuffer; - m_ChamberWmax = atof(DataBuffer.c_str()) * mm; - cout << "Chamber outer radius: " << m_ChamberWmax << endl ; - } - else if (DataBuffer.compare(0, 9, "Depthmin=") == 0) { - check_Dmin = true ; - ConfigFile >> DataBuffer; - m_ChamberDmin = atof(DataBuffer.c_str()) * mm; - cout << "Chamber inner radius: " << m_ChamberDmin << endl ; - } - - else if (DataBuffer.compare(0, 9, "Depthmax=") == 0) { - check_Dmax = true ; - ConfigFile >> DataBuffer; - m_ChamberDmax = atof(DataBuffer.c_str()) * mm; - cout << "Chamber outer radius: " << m_ChamberDmax << endl ; - } - - - else if (DataBuffer.compare(0, 9, "MATERIAL=") == 0) { - check_Material = true ; - ConfigFile >> DataBuffer; - m_ChamberMaterial = GetMaterialFromLibrary(DataBuffer); - cout << "Chamber Material: " << m_ChamberMaterial << endl ; - } - - /////////////////////////////////////////////////// - // If no Beam Token and no comment, toggle out - else - {ReadingStatusGREATChamber = false; G4cout << "WARNING : Wrong Token Sequence: Getting out " << G4endl ;} - - /////////////////////////////////////////////////// - // If all Token found toggle out - if( check_Hmin && check_Hmax && check_Material && check_Wmin && check_Wmax && check_Dmin && check_Dmax ) - ReadingStatusGREATChamber = false ; - - } - - - + + //Search for comment Symbol % + if (DataBuffer.compare(0, 1, "%") == 0) { ConfigFile.ignore ( std::numeric_limits<std::streamsize>::max(), +'\n' );} + + else if (DataBuffer.compare(0, 10, "Heightmin=") == 0) { + check_Hmin = true ; + ConfigFile >> DataBuffer; + m_ChamberHmin = atof(DataBuffer.c_str()) * mm; + cout << "Chamber inner radius: " << m_ChamberHmin << endl ; + } + + else if (DataBuffer.compare(0, 10, "Heightmax=") == 0) { + check_Hmax = true ; + ConfigFile >> DataBuffer; + m_ChamberHmax = atof(DataBuffer.c_str()) * mm; + cout << "Chamber outer radius: " << m_ChamberHmax << endl ; + } + else if (DataBuffer.compare(0, 9, "Widthmin=") == 0) { + check_Wmin = true ; + ConfigFile >> DataBuffer; + m_ChamberWmin = atof(DataBuffer.c_str()) * mm; + cout << "Chamber inner radius: " << m_ChamberWmin << endl ; + } + + else if (DataBuffer.compare(0, 9, "Widthmax=") == 0) { + check_Wmax = true ; + ConfigFile >> DataBuffer; + m_ChamberWmax = atof(DataBuffer.c_str()) * mm; + cout << "Chamber outer radius: " << m_ChamberWmax << endl ; + } + else if (DataBuffer.compare(0, 9, "Depthmin=") == 0) { + check_Dmin = true ; + ConfigFile >> DataBuffer; + m_ChamberDmin = atof(DataBuffer.c_str()) * mm; + cout << "Chamber inner radius: " << m_ChamberDmin << endl ; + } + + else if (DataBuffer.compare(0, 9, "Depthmax=") == 0) { + check_Dmax = true ; + ConfigFile >> DataBuffer; + m_ChamberDmax = atof(DataBuffer.c_str()) * mm; + cout << "Chamber outer radius: " << m_ChamberDmax << endl ; + } + + + else if (DataBuffer.compare(0, 9, "MATERIAL=") == 0) { + check_Material = true ; + ConfigFile >> DataBuffer; + m_ChamberMaterial = GetMaterialFromLibrary(DataBuffer); + cout << "Chamber Material: " << m_ChamberMaterial << endl ; + } + + /////////////////////////////////////////////////// + // If no Beam Token and no comment, toggle out + else + {ReadingStatusGREATChamber = false; G4cout << "WARNING : Wrong Token Sequence: Getting out " << G4endl ;} + + /////////////////////////////////////////////////// + // If all Token found toggle out + if( check_Hmin && check_Hmax && check_Material && check_Wmin && check_Wmax && check_Dmin && check_Dmax ) + ReadingStatusGREATChamber = false ; + + } + + + } @@ -817,1499 +799,1429 @@ void Chamber::ReadConfiguration(NPL::InputParser parser){ // Little trick to avoid warning in compilation: Use a PVPlacement "buffer". // If don't you will have a Warning unused variable 'myPVP' - G4VPhysicalVolume* PVPBuffer ; - +G4VPhysicalVolume* PVPBuffer; // Construct detector and inialise sensitive part. // Called After DetecorConstruction::AddDetector Method -void Chamber::ConstructDetector(G4LogicalVolume* world) -{ - - if (m_ChamberType==0) { // case of standard Chamber +void Chamber::ConstructDetector(G4LogicalVolume* world) { - G4Sphere* solidChamber - = new G4Sphere("solidChamber", m_ChamberRmin, m_ChamberRmax, m_ChamberPhiMin, m_ChamberPhiMax, m_ChamberThetaMin, m_ChamberThetaMax ); + if (m_ChamberType == 0) { // case of standard Chamber - G4LogicalVolume* logicChamber = new G4LogicalVolume(solidChamber, m_ChamberMaterial, "logicChamber"); + G4Sphere* solidChamber = new G4Sphere("solidChamber", m_ChamberRmin, m_ChamberRmax, m_ChamberPhiMin, + m_ChamberPhiMax, m_ChamberThetaMin, m_ChamberThetaMax); - // rotation of target - //G4RotationMatrix *rotation = new G4RotationMatrix(); - //rotation->rotateY(m_ChamberAngle); + G4LogicalVolume* logicChamber = new G4LogicalVolume(solidChamber, m_ChamberMaterial, "logicChamber"); - PVPBuffer = - new G4PVPlacement(0, G4ThreeVector(0., 0., 0.), logicChamber, "Chamber", world, false, 0); + // rotation of target + // G4RotationMatrix *rotation = new G4RotationMatrix(); + // rotation->rotateY(m_ChamberAngle); - G4VisAttributes* ChamberVisAtt = new G4VisAttributes(G4Colour(0., 1., 1.)); - logicChamber->SetVisAttributes(ChamberVisAtt); - // } - } - - else if(m_ChamberType==1){ // case of cryogenic target + PVPBuffer = new G4PVPlacement(0, G4ThreeVector(0., 0., 0.), logicChamber, "Chamber", world, false, 0); + G4VisAttributes* ChamberVisAtt = new G4VisAttributes(G4Colour(0., 1., 1.)); + logicChamber->SetVisAttributes(ChamberVisAtt); + // } + } - } + else if (m_ChamberType == 1) { // case of cryogenic target + } #ifdef NPS_GDML - else if(m_ChamberType==4){ // MARA chamber - G4GDMLParser m_gdmlparser; - //m_gdmlparser.Read("/mnt/hgfs/Echanges/gdml/honeycomb/HoneyComb.gdml"); - m_gdmlparser.Read(m_GDMLPath+m_GDMLName); - //m_LogicalGDML= m_gdmlparser.GetVolume("MARA_world"); - m_LogicalGDML= m_gdmlparser.GetVolume(m_GDMLWorld); + else if (m_ChamberType == 4) { // MARA chamber + G4GDMLParser m_gdmlparser; + // m_gdmlparser.Read("/mnt/hgfs/Echanges/gdml/honeycomb/HoneyComb.gdml"); + m_gdmlparser.Read(m_GDMLPath + m_GDMLName); + // m_LogicalGDML= m_gdmlparser.GetVolume("MARA_world"); + m_LogicalGDML = m_gdmlparser.GetVolume(m_GDMLWorld); - //G4RotationMatrix* rm= new G4RotationMatrix(); - //G4RotationMatrix rmY, rmZ; - //rmZ.rotateZ(0.*deg); - //rmY.rotateY(0.*deg); - - //*rm=rmY*rmZ; + // G4RotationMatrix* rm= new G4RotationMatrix(); + // G4RotationMatrix rmY, rmZ; + // rmZ.rotateZ(0.*deg); + // rmY.rotateY(0.*deg); - //G4Transform3D TF(rm, rm*G4ThreeVector(0., 0., 0.)); + //*rm=rmY*rmZ; - // gdml World box - m_LogicalGDML->SetVisAttributes(G4VisAttributes::Invisible); - - PVPBuffer = - new G4PVPlacement(0, G4ThreeVector(0., 0., -0.15*cm), m_LogicalGDML, "MARA", world, false, 0 ); + // G4Transform3D TF(rm, rm*G4ThreeVector(0., 0., 0.)); + // gdml World box + m_LogicalGDML->SetVisAttributes(G4VisAttributes::GetInvisible()); - } - - else if(m_ChamberType==5){ // MuGast chamber - G4GDMLParser m_gdmlparser; - m_gdmlparser.Read(m_GDMLPath+m_GDMLName); - m_LogicalGDML= m_gdmlparser.GetVolume(m_GDMLWorld); + PVPBuffer = new G4PVPlacement(0, G4ThreeVector(0., 0., -0.15 * cm), m_LogicalGDML, "MARA", world, false, 0); + } - //G4RotationMatrix* rm= new G4RotationMatrix(); - //G4RotationMatrix rmY, rmZ; - //rmZ.rotateZ(0.*deg); - //rmY.rotateY(0.*deg); - - //*rm=rmY*rmZ; + else if (m_ChamberType == 5) { // MuGast chamber + G4GDMLParser m_gdmlparser; + m_gdmlparser.Read(m_GDMLPath + m_GDMLName); + m_LogicalGDML = m_gdmlparser.GetVolume(m_GDMLWorld); - //G4Transform3D TF(rm, rm*G4ThreeVector(0., 0., 0.)); + // G4RotationMatrix* rm= new G4RotationMatrix(); + // G4RotationMatrix rmY, rmZ; + // rmZ.rotateZ(0.*deg); + // rmY.rotateY(0.*deg); - // gdml World box - m_LogicalGDML->SetVisAttributes(G4VisAttributes::Invisible); - - PVPBuffer = - new G4PVPlacement(0, G4ThreeVector(0., 0., 0.*cm), m_LogicalGDML, "MuGasTChamber", world, false, 0 ); + //*rm=rmY*rmZ; + // G4Transform3D TF(rm, rm*G4ThreeVector(0., 0., 0.)); - } + // gdml World box + m_LogicalGDML->SetVisAttributes(G4VisAttributes::GetInvisible()); + + PVPBuffer = new G4PVPlacement(0, G4ThreeVector(0., 0., 0. * cm), m_LogicalGDML, "MuGasTChamber", world, false, 0); + } #endif - - else if(m_ChamberType==2){ // case of GREAT chamber - G4Box* solidExtChamber - = new G4Box("solidExtChamber", m_ChamberWmax/2, m_ChamberHmax/2, m_ChamberDmax/2 ); - G4Box* solidIntChamber - = new G4Box("solidIntChamber", m_ChamberWmin/2, m_ChamberHmin/2, m_ChamberDmin/2 ); + else if (m_ChamberType == 2) { // case of GREAT chamber - G4SubtractionSolid* solidChamber=new G4SubtractionSolid("SolidChamber",solidExtChamber, solidIntChamber, 0, G4ThreeVector(0.,0.,-0.5*cm)); + G4Box* solidExtChamber = new G4Box("solidExtChamber", m_ChamberWmax / 2, m_ChamberHmax / 2, m_ChamberDmax / 2); + G4Box* solidIntChamber = new G4Box("solidIntChamber", m_ChamberWmin / 2, m_ChamberHmin / 2, m_ChamberDmin / 2); + G4SubtractionSolid* solidChamber = + new G4SubtractionSolid("SolidChamber", solidExtChamber, solidIntChamber, 0, G4ThreeVector(0., 0., -0.5 * cm)); - G4LogicalVolume* logicChamber = new G4LogicalVolume(solidChamber, m_ChamberMaterial, "logicChamber"); + G4LogicalVolume* logicChamber = new G4LogicalVolume(solidChamber, m_ChamberMaterial, "logicChamber"); - // rotation of target - //G4RotationMatrix *rotation = new G4RotationMatrix(); - //rotation->rotateY(m_ChamberAngle); + // rotation of target + // G4RotationMatrix *rotation = new G4RotationMatrix(); + // rotation->rotateY(m_ChamberAngle); - PVPBuffer = - new G4PVPlacement(0, G4ThreeVector(0., -2.92325*cm/2, 0.), logicChamber, "Chamber", world, false, 0); + PVPBuffer = + new G4PVPlacement(0, G4ThreeVector(0., -2.92325 * cm / 2, 0.), logicChamber, "Chamber", world, false, 0); - G4VisAttributes* ChamberVisAtt = new G4VisAttributes(G4Colour(0., 1., 1.)); - logicChamber->SetVisAttributes(ChamberVisAtt); + G4VisAttributes* ChamberVisAtt = new G4VisAttributes(G4Colour(0., 1., 1.)); + logicChamber->SetVisAttributes(ChamberVisAtt); + /* Eleanor's additions: */ + /* - /* Eleanor's additions: *//* +// for the DSSSD (considered as passive here !!): - // for the DSSSD (considered as passive here !!): +G4Material* m_DSSSDMaterial = new G4Material("Si", 14, 28.0855*g/mole, 2.33*g/cm3); - G4Material* m_DSSSDMaterial = new G4Material("Si", 14, 28.0855*g/mole, 2.33*g/cm3); - - G4Box* solidDSSSD - = new G4Box("solidDSSSD", 6.*cm/2, 4.*cm/2, 0.03*cm/2 ); // +G4Box* solidDSSSD += new G4Box("solidDSSSD", 6.*cm/2, 4.*cm/2, 0.03*cm/2 ); // - G4LogicalVolume* logicDSSSD = new G4LogicalVolume(solidDSSSD, m_DSSSDMaterial, "logicDSSSD"); +G4LogicalVolume* logicDSSSD = new G4LogicalVolume(solidDSSSD, m_DSSSDMaterial, "logicDSSSD"); - PVPBuffer = - new G4PVPlacement(0, G4ThreeVector(-3.2*cm, 0., 0.), logicDSSSD, "DSSSD", world, false, 0); - //new G4PVPlacement(0, G4ThreeVector(-3.2*cm, 2.92325*cm/2, 0.), logicDSSSD, "DSSSD", logicChamber, false, 0); - PVPBuffer = - new G4PVPlacement(0, G4ThreeVector( 3.2*cm, 0., 0.), logicDSSSD, "DSSSD", world, false, 1); - //new G4PVPlacement(0, G4ThreeVector( 3.2*cm, 2.92325*cm/2, 0.), logicDSSSD, "DSSSD", logicChamber, false, 1); +PVPBuffer = +new G4PVPlacement(0, G4ThreeVector(-3.2*cm, 0., 0.), logicDSSSD, "DSSSD", world, false, 0); +//new G4PVPlacement(0, G4ThreeVector(-3.2*cm, 2.92325*cm/2, 0.), logicDSSSD, "DSSSD", logicChamber, false, 0); +PVPBuffer = +new G4PVPlacement(0, G4ThreeVector( 3.2*cm, 0., 0.), logicDSSSD, "DSSSD", world, false, 1); +//new G4PVPlacement(0, G4ThreeVector( 3.2*cm, 2.92325*cm/2, 0.), logicDSSSD, "DSSSD", logicChamber, false, 1); - G4VisAttributes* DSSSDVisAtt = new G4VisAttributes(G4Colour(0., 0., 1.)); - logicDSSSD->SetVisAttributes(DSSSDVisAtt); +G4VisAttributes* DSSSDVisAtt = new G4VisAttributes(G4Colour(0., 0., 1.)); +logicDSSSD->SetVisAttributes(DSSSDVisAtt); - // for the solid aluminium support : - - G4Box* solid_alu_support_ext - = new G4Box("solid_alu_support_ext", (18.32-0.65)*cm/2, (12.343-0.65)*cm/2, 8.5*cm/2 ); // - - G4Box* solid_alu_support_int - = new G4Box("solid_alu_support_int",16.27*cm/2, 10.295*cm/2, 8.6*cm/2 ); // - G4SubtractionSolid* solidsupport=new G4SubtractionSolid("Solidsupport",solid_alu_support_ext, solid_alu_support_int, 0, G4ThreeVector(0.,0.,0)); - G4LogicalVolume* logicALU = new G4LogicalVolume(solidsupport, m_ChamberMaterial, "logicALU"); +// for the solid aluminium support : - PVPBuffer = - new G4PVPlacement(0, G4ThreeVector(0., -2.92325*cm/2,-4.265*cm), logicALU, "Aluminium", world, false, 0); +G4Box* solid_alu_support_ext += new G4Box("solid_alu_support_ext", (18.32-0.65)*cm/2, (12.343-0.65)*cm/2, 8.5*cm/2 ); // - G4VisAttributes* alusupportVisAtt = new G4VisAttributes(G4Colour(0.5, 0., 0.3)); - logicALU->SetVisAttributes(alusupportVisAtt); +G4Box* solid_alu_support_int += new G4Box("solid_alu_support_int",16.27*cm/2, 10.295*cm/2, 8.6*cm/2 ); // +G4SubtractionSolid* solidsupport=new G4SubtractionSolid("Solidsupport",solid_alu_support_ext, solid_alu_support_int, 0, +G4ThreeVector(0.,0.,0)); G4LogicalVolume* logicALU = new G4LogicalVolume(solidsupport, m_ChamberMaterial, "logicALU"); +PVPBuffer = +new G4PVPlacement(0, G4ThreeVector(0., -2.92325*cm/2,-4.265*cm), logicALU, "Aluminium", world, false, 0); - G4Box* solid_alu_support_int1 - = new G4Box("solid_alu_support_int1",16.27*cm/2, 0.55*cm/2, 8.6*cm/2 ); // - - G4LogicalVolume* logicALUint1 = new G4LogicalVolume(solid_alu_support_int1, m_ChamberMaterial, "logicALUint1"); +G4VisAttributes* alusupportVisAtt = new G4VisAttributes(G4Colour(0.5, 0., 0.3)); +logicALU->SetVisAttributes(alusupportVisAtt); - PVPBuffer = - new G4PVPlacement(0, G4ThreeVector(0, -2.5215*cm-2.92325*cm/2, -4.265*cm), logicALUint1, "Aluminium", world, false, 0); - - G4VisAttributes* solid_alu_support_int1VisAtt = new G4VisAttributes(G4Colour(0.9, 0., 0.)); - logicALUint1->SetVisAttributes(solid_alu_support_int1VisAtt); +G4Box* solid_alu_support_int1 += new G4Box("solid_alu_support_int1",16.27*cm/2, 0.55*cm/2, 8.6*cm/2 ); // - G4Box* solid_alu_support_int2 - = new G4Box("solid_alu_support_int2",1.4*cm/2, 2.35*cm/2, 8.6*cm/2 ); // +G4LogicalVolume* logicALUint1 = new G4LogicalVolume(solid_alu_support_int1, m_ChamberMaterial, "logicALUint1"); - G4LogicalVolume* logicALUint2 = new G4LogicalVolume(solid_alu_support_int2, m_ChamberMaterial, "logicALUint2"); +PVPBuffer = +new G4PVPlacement(0, G4ThreeVector(0, -2.5215*cm-2.92325*cm/2, -4.265*cm), logicALUint1, "Aluminium", world, false, 0); - PVPBuffer = - new G4PVPlacement(0, G4ThreeVector(0, -3.9715*cm-2.92325*cm/2, -4.265*cm), logicALUint2, "Aluminium", world, false, 0); +G4VisAttributes* solid_alu_support_int1VisAtt = new G4VisAttributes(G4Colour(0.9, 0., 0.)); +logicALUint1->SetVisAttributes(solid_alu_support_int1VisAtt); - - G4VisAttributes* solid_alu_support_int2VisAtt = new G4VisAttributes(G4Colour(0.9, 0., 0.)); - logicALUint2->SetVisAttributes(solid_alu_support_int2VisAtt); +G4Box* solid_alu_support_int2 += new G4Box("solid_alu_support_int2",1.4*cm/2, 2.35*cm/2, 8.6*cm/2 ); // - G4Box* solid_DSSSD_coating1 - = new G4Box("solid_DSSSD_coating1",16.27*cm/2, 0.1*cm/2, 8.6*cm/2 ); // +G4LogicalVolume* logicALUint2 = new G4LogicalVolume(solid_alu_support_int2, m_ChamberMaterial, "logicALUint2"); - G4LogicalVolume* logicSiliconCoating1 = new G4LogicalVolume(solid_DSSSD_coating1, m_DSSSDMaterial, "logicSiliconCoating1"); - PVPBuffer = - new G4PVPlacement(0, G4ThreeVector(0, -2.5215*cm-2.92325*cm/2+0.05*cm+0.55*cm/2, -4.265*cm), logicSiliconCoating1, "PinDiode1", world, false, 0); +PVPBuffer = +new G4PVPlacement(0, G4ThreeVector(0, -3.9715*cm-2.92325*cm/2, -4.265*cm), logicALUint2, "Aluminium", world, false, 0); - G4VisAttributes* solid_DSSSD_coating1VisAtt = new G4VisAttributes(G4Colour(0., 0.2, 0.8)); - logicSiliconCoating1->SetVisAttributes(solid_DSSSD_coating1VisAtt); +G4VisAttributes* solid_alu_support_int2VisAtt = new G4VisAttributes(G4Colour(0.9, 0., 0.)); +logicALUint2->SetVisAttributes(solid_alu_support_int2VisAtt); - G4Box* solid_DSSSD_coating2 - = new G4Box("solid_DSSSD_coating2",16.27*cm/2, 0.1*cm/2, 8.6*cm/2 ); // - G4LogicalVolume* logicSiliconCoating2 = new G4LogicalVolume(solid_DSSSD_coating2, m_DSSSDMaterial, "logicSiliconCoating2"); - PVPBuffer = - new G4PVPlacement(0, G4ThreeVector(0, 5.1055*cm-2.92325*cm/2-0.05*cm, -4.265*cm), logicSiliconCoating2, "PinDiode2", world, false, 0); +G4Box* solid_DSSSD_coating1 += new G4Box("solid_DSSSD_coating1",16.27*cm/2, 0.1*cm/2, 8.6*cm/2 ); // - G4VisAttributes* solid_DSSSD_coating2VisAtt = new G4VisAttributes(G4Colour(0., 0.2, 0.8)); - logicSiliconCoating2->SetVisAttributes(solid_DSSSD_coating2VisAtt); +G4LogicalVolume* logicSiliconCoating1 = new G4LogicalVolume(solid_DSSSD_coating1, m_DSSSDMaterial, +"logicSiliconCoating1"); PVPBuffer = new G4PVPlacement(0, G4ThreeVector(0, -2.5215*cm-2.92325*cm/2+0.05*cm+0.55*cm/2, +-4.265*cm), logicSiliconCoating1, "PinDiode1", world, false, 0); +G4VisAttributes* solid_DSSSD_coating1VisAtt = new G4VisAttributes(G4Colour(0., 0.2, 0.8)); +logicSiliconCoating1->SetVisAttributes(solid_DSSSD_coating1VisAtt); - G4Box* solid_DSSSD_coating3 - = new G4Box("solid_DSSSD_coating3",0.1*cm/2, 7.393*cm/2, 8.6*cm/2 ); // - G4LogicalVolume* logicSiliconCoating3 = new G4LogicalVolume(solid_DSSSD_coating3, m_DSSSDMaterial, "logicSiliconCoating3"); - PVPBuffer = - new G4PVPlacement(0, G4ThreeVector(8.085*cm, 1.4375*cm-2.92325*cm/2, -4.265*cm), logicSiliconCoating3, "PinDiode3", world, false, 0); - PVPBuffer = - new G4PVPlacement(0, G4ThreeVector(-8.085*cm, 1.4375*cm-2.92325*cm/2, -4.265*cm), logicSiliconCoating3, "PinDiode4", world, false, 1); - - G4VisAttributes* solid_DSSSD_coating3VisAtt = new G4VisAttributes(G4Colour(0., 0.2, 0.8)); - logicSiliconCoating3->SetVisAttributes(solid_DSSSD_coating3VisAtt); +G4Box* solid_DSSSD_coating2 += new G4Box("solid_DSSSD_coating2",16.27*cm/2, 0.1*cm/2, 8.6*cm/2 ); // +G4LogicalVolume* logicSiliconCoating2 = new G4LogicalVolume(solid_DSSSD_coating2, m_DSSSDMaterial, +"logicSiliconCoating2"); PVPBuffer = new G4PVPlacement(0, G4ThreeVector(0, 5.1055*cm-2.92325*cm/2-0.05*cm, -4.265*cm), +logicSiliconCoating2, "PinDiode2", world, false, 0); +G4VisAttributes* solid_DSSSD_coating2VisAtt = new G4VisAttributes(G4Colour(0., 0.2, 0.8)); +logicSiliconCoating2->SetVisAttributes(solid_DSSSD_coating2VisAtt); - // Preamps and connectors board - // PCB - +G4Box* solid_DSSSD_coating3 += new G4Box("solid_DSSSD_coating3",0.1*cm/2, 7.393*cm/2, 8.6*cm/2 ); // - G4Element* Si = new G4Element("Silicon" , "Si" , 14 , 28.0855 * g / mole); - G4Element* C = new G4Element("Carbon" , "C" , 6 , 12.011 * g / mole); - G4Element* H = new G4Element("Hydrogen" , "H" , 1 , 1.0079 * g / mole); - G4Element* Br = new G4Element("Bromine" , "Br" , 35 , 79.904 * g / mole); - G4Element* O = new G4Element("Oxigen" , "O" , 8 , 16.00 * g / mole); +G4LogicalVolume* logicSiliconCoating3 = new G4LogicalVolume(solid_DSSSD_coating3, m_DSSSDMaterial, +"logicSiliconCoating3"); PVPBuffer = new G4PVPlacement(0, G4ThreeVector(8.085*cm, 1.4375*cm-2.92325*cm/2, -4.265*cm), +logicSiliconCoating3, "PinDiode3", world, false, 0); PVPBuffer = new G4PVPlacement(0, +G4ThreeVector(-8.085*cm, 1.4375*cm-2.92325*cm/2, -4.265*cm), logicSiliconCoating3, "PinDiode4", world, false, 1); - G4double density = 1.7 * g / cm3; - G4int ncomponents; - G4Material* PCB = new G4Material("PCB", density, ncomponents = 5); - PCB->AddElement(Si, .181); - PCB->AddElement(O, .406); - PCB->AddElement(C, .278); - PCB->AddElement(H, .068); - PCB->AddElement(Br, .067); +G4VisAttributes* solid_DSSSD_coating3VisAtt = new G4VisAttributes(G4Colour(0., 0.2, 0.8)); +logicSiliconCoating3->SetVisAttributes(solid_DSSSD_coating3VisAtt); - G4Box* pre_amp_board1 - = new G4Box("pre_amp_board1",6.756*cm/2, 1.675*cm/2, 7.976*cm/2 ); // +// Preamps and connectors board - G4LogicalVolume* logicpre_amp1 = new G4LogicalVolume(pre_amp_board1, PCB, "logicpre_amp1"); - PVPBuffer = - new G4PVPlacement(0, G4ThreeVector(4.0675*cm, 5.267875*cm, -4.265*cm), logicpre_amp1, "pre_amp_board1", world, false, 0); - PVPBuffer = - new G4PVPlacement(0, G4ThreeVector(-4.0675*cm, 5.267875*cm, -4.265*cm), logicpre_amp1, "pre_amp_board1", world, false, 1); - +// PCB - G4VisAttributes* pre_amp_board1VisAtt = new G4VisAttributes(G4Colour(0., 0.7, 0.)); - logicpre_amp1->SetVisAttributes(pre_amp_board1VisAtt); - G4Box* pre_amp_board2 - = new G4Box("pre_amp_board2",1.675*cm/2, 6.756*cm/2, 7.976*cm/2 ); // +G4Element* Si = new G4Element("Silicon" , "Si" , 14 , 28.0855 * g / mole); +G4Element* C = new G4Element("Carbon" , "C" , 6 , 12.011 * g / mole); +G4Element* H = new G4Element("Hydrogen" , "H" , 1 , 1.0079 * g / mole); +G4Element* Br = new G4Element("Bromine" , "Br" , 35 , 79.904 * g / mole); +G4Element* O = new G4Element("Oxigen" , "O" , 8 , 16.00 * g / mole); - G4LogicalVolume* logicpre_amp2 = new G4LogicalVolume(pre_amp_board2, PCB, "logicpre_amp2"); - PVPBuffer = - new G4PVPlacement(0, G4ThreeVector(9.6625*cm, 2.413375*cm, -4.265*cm), logicpre_amp2, "pre_amp_board2", world, false, 0); - PVPBuffer = - new G4PVPlacement(0, G4ThreeVector(9.6625*cm, -5.336625*cm, -4.265*cm), logicpre_amp2, "pre_amp_board2", world, false, 1); - +G4double density = 1.7 * g / cm3; +G4int ncomponents; +G4Material* PCB = new G4Material("PCB", density, ncomponents = 5); +PCB->AddElement(Si, .181); +PCB->AddElement(O, .406); +PCB->AddElement(C, .278); +PCB->AddElement(H, .068); +PCB->AddElement(Br, .067); - G4VisAttributes* pre_amp_board2VisAtt = new G4VisAttributes(G4Colour(0., 0.7, 0.)); - logicpre_amp2->SetVisAttributes(pre_amp_board2VisAtt); - - G4Box* pre_amp_board3 - = new G4Box("pre_amp_board3",1.675*cm/2, 6.756*cm/2, 7.976*cm/2 ); // - G4LogicalVolume* logicpre_amp3 = new G4LogicalVolume(pre_amp_board3, PCB, "logicpre_amp3"); - PVPBuffer = - new G4PVPlacement(0, G4ThreeVector(-9.6725*cm, 2.413375*cm, -4.265*cm), logicpre_amp3, "pre_amp_board3", world, false, 0); - PVPBuffer = - new G4PVPlacement(0, G4ThreeVector(-9.6725*cm, -5.336625*cm, -4.265*cm), logicpre_amp3, "pre_amp_board3", world, false, 1); - +G4Box* pre_amp_board1 += new G4Box("pre_amp_board1",6.756*cm/2, 1.675*cm/2, 7.976*cm/2 ); // - G4VisAttributes* pre_amp_board3VisAtt = new G4VisAttributes(G4Colour(0., 0.7, 0.)); - logicpre_amp3->SetVisAttributes(pre_amp_board3VisAtt); +G4LogicalVolume* logicpre_amp1 = new G4LogicalVolume(pre_amp_board1, PCB, "logicpre_amp1"); +PVPBuffer = +new G4PVPlacement(0, G4ThreeVector(4.0675*cm, 5.267875*cm, -4.265*cm), logicpre_amp1, "pre_amp_board1", world, false, +0); PVPBuffer = new G4PVPlacement(0, G4ThreeVector(-4.0675*cm, 5.267875*cm, -4.265*cm), logicpre_amp1, "pre_amp_board1", +world, false, 1); - */ /* end of Eleanor's additions */ +G4VisAttributes* pre_amp_board1VisAtt = new G4VisAttributes(G4Colour(0., 0.7, 0.)); +logicpre_amp1->SetVisAttributes(pre_amp_board1VisAtt); +G4Box* pre_amp_board2 += new G4Box("pre_amp_board2",1.675*cm/2, 6.756*cm/2, 7.976*cm/2 ); // +G4LogicalVolume* logicpre_amp2 = new G4LogicalVolume(pre_amp_board2, PCB, "logicpre_amp2"); +PVPBuffer = +new G4PVPlacement(0, G4ThreeVector(9.6625*cm, 2.413375*cm, -4.265*cm), logicpre_amp2, "pre_amp_board2", world, false, +0); PVPBuffer = new G4PVPlacement(0, G4ThreeVector(9.6625*cm, -5.336625*cm, -4.265*cm), logicpre_amp2, "pre_amp_board2", +world, false, 1); - } +G4VisAttributes* pre_amp_board2VisAtt = new G4VisAttributes(G4Colour(0., 0.7, 0.)); +logicpre_amp2->SetVisAttributes(pre_amp_board2VisAtt); - else if(m_ChamberType==3){ // case of GREAT chamber as defined by Karl - - fChamberH = m_ChamberHmax; - fChamberW = m_ChamberWmax; - //fChamberL = m_ChamberDmax; - fChamberThickness= m_ChamberHmax-m_ChamberHmin; - - fVacuumH = fChamberH - fChamberThickness; - - G4cout << "fChamberH=" << fChamberH << G4endl; - G4cout << "fChamberW=" << fChamberW << G4endl; - G4cout << "fChamberThickness=" << fChamberThickness << G4endl; - - //----------------------------- - // more dimesions for chamber - fChamberL = fCoolingBlockL + fLengthOfPlanarCut + fDSSD_BoardL + fdeltaZ_Support + 2.*fChamberThickness + 10.0*mm; - - - //--------------------------------------------------------------------------------- - // This shift in the position of the chamber is to put the DSSD centred at y = 0 - fShiftChamberY = fCoolingBlockH - fCoolingBlockT - fCoolingBlockCutOutH/2.; //height of centre wrt cooling block base - fShiftChamberY -= fChamberH/2.; - - //Define the downstream face of the DSSD to be at 0 (ie the centre of the DSSD PCB board) - fShiftChamberZ = fCoolingBlockZ + fChamberThickness - fDSSD_BoardL/2.; //a discrepency of 1 mm somewhere - - //the centre of the DSSD wrt the vacuum chamber - fCentreOfDSSD_Y = -fVacuumH/2. + fCoolingBlockH - fCoolingBlockT - fCoolingBlockCutOutH/2.; //+ fChamberThickness - cout << G4endl << " DSSD_Y at 0 mm , but wrt vacuum DSSD_Y @ " << fCentreOfDSSD_Y << G4endl; - - - - - - //-------------------------------------------- - //[partial] Vacuum Chamber (Walls+Vacuum) and end BackPlate - //Set the Upstream side of the Chamber @ Z=0mm - - - //G4Box* solidChamber = new G4Box("chamber",fChamberW/2., fChamberH/2., fChamberL/2.); - // replaced by achamber with a substraction of the Planar area: - G4Box* solidChamberEnv = new G4Box("chamberEnv",fChamberW/2., fChamberH/2., fChamberL/2.); - G4double PlanarCap_W = fPlanarGe_W + 2.*fPlanarGuard + 80.*mm; //A GUESS - G4double PlanarCap_H = 150.*mm; - PlanarCap_H = fPlanarGe_H + 70*mm; - G4double PlanarCap_T = fPlanarTotalL; - G4cout << G4endl << "Planar end-cap thickness " << PlanarCap_T << " cf 41. mm" << G4endl; - fShiftPlanar = fChamberL/2. - fChamberThickness + PlanarCap_T/2. - fLengthOfPlanarCut + fGap_PCB_2_Planar; - G4double Planar_z = fShiftPlanar; - G4Box* solidPlanarCapEnv = new G4Box("planar-cap-Env", PlanarCap_W/2., PlanarCap_H/2., PlanarCap_T/2.); - G4SubtractionSolid* solidChamber = - new G4SubtractionSolid("chamber", solidChamberEnv, solidPlanarCapEnv, 0, G4ThreeVector(0.0*mm, fCentreOfDSSD_Y, Planar_z)); - - // end of replacement - - G4LogicalVolume* logicChamber = new G4LogicalVolume(solidChamber, //it's solid - m_ChamberMaterial,//it's material - //chamberMaterial,//it's material - //vacuumMaterial,//it's material - "Chamber", //it's name - 0, 0, 0); // field manager, sensitive det, user limits - - PVPBuffer = new G4PVPlacement(0, //rotation - G4ThreeVector(0.0*mm,-fShiftChamberY,-fChamberL/2.+fShiftChamberZ), - logicChamber, //its logical volume - "Chamber", //its name - world, //its mother - false, //no boolean operat - 0, //copy number - true); //overlap check - - //viewing the chamber - G4VisAttributes* visAttChamber = new G4VisAttributes(G4Colour(1.0,1.0,1.0) ); - visAttChamber->SetVisibility(true); - visAttChamber->SetForceWireframe(true); - logicChamber->SetVisAttributes(visAttChamber); - //logicChamber->SetVisAttributes(G4VisAttributes::Invisible); - - - - //Vacuum within above partial chamber - - G4double vacH = fChamberH - fChamberThickness; - G4double vacW = fChamberW - 2.*fChamberThickness; - G4double vacL = fChamberL - 2.*fChamberThickness; - - //G4Box* solidChamVac = new G4Box("chamVac",vacW/2., vacH/2., vacL/2.); - //Replaced by - G4Box* solidChamVacEnv = new G4Box("chamVacEnV",vacW/2., vacH/2., vacL/2.); - //G4Box* solidPlanarCapEnv = new G4Box("planar-cap-Env", PlanarCap_W/2., PlanarCap_H/2., PlanarCap_T/2.); - G4SubtractionSolid* solidChamVac = - new G4SubtractionSolid("chamVac", solidChamVacEnv, solidPlanarCapEnv, 0, G4ThreeVector(0.0*mm, fCentreOfDSSD_Y+fChamberThickness/2., Planar_z)); - - - G4LogicalVolume* logicChamVac = new G4LogicalVolume(solidChamVac, //it's solid - vacuumMaterial, //it's material - "chamVac", //it's name - 0, 0, 0); // field manager, sensitive det, user limits - - PVPBuffer = new G4PVPlacement(0, //rotation - G4ThreeVector(0.0*cm, -fChamberThickness/2., 0.0*cm), - logicChamVac, //its logical volume - "ChamVac", //its name - logicChamber, //its mother - false, //no boolean operat - 0, //copy number - true); //overlap check - - //logicChamVac->SetVisAttributes(G4VisAttributes::Invisible); - logicChamVac->SetVisAttributes(visAttChamber); - - - - /* Uncomment if you want the planar in the geometry and you are not using GRTPlan */ - /* - //---------------------------------------------------------------------- - // The Planar - //---------------------------------------------------------------------- - G4double PlanarCap_W = fPlanarGe_W + 2.*fPlanarGuard + 80.*mm; //A GUESS - G4double PlanarCap_H = 150.*mm; - PlanarCap_H = fPlanarGe_H + 70*mm; - G4double PlanarCap_T = fPlanarTotalL; - G4cout << G4endl << "Planar end-cap thickness " << PlanarCap_T << " cf 41. mm" << G4endl; - - // - editted 07/11/2011 - fShiftPlanar = fChamberL/2. - fChamberThickness + PlanarCap_T/2. - fLengthOfPlanarCut + fGap_PCB_2_Planar; - G4double Planar_z = fShiftPlanar; - fPlanar_PosZ = Planar_z; - - //starting endCap sold - G4Box* solidPlanarCap = new G4Box("planar-cap", PlanarCap_W/2., PlanarCap_H/2., PlanarCap_T/2.); - - //cut outs for Be window : planar end-cap is deliberately symmetric to make positioning more simple - //3 mm wide support rib that is 2.2 mm thick. Add the Be thickness => endCap thickness - G4Box* solidBeCutOut = new G4Box("be-cut-out", fPlanarGe_W/4.-1.5*mm, fPlanarGe_H/2., fEndCapThickness/2.);//is it total 120 mm or 120+gap ? - G4ThreeVector beCutOutTrans1(-fPlanarGe_W/4.-1.5*mm, 0.0*mm, -PlanarCap_T/2.+fEndCapThickness/2.); - G4ThreeVector beCutOutTrans2(+fPlanarGe_W/4.+1.5*mm, 0.0*mm, -PlanarCap_T/2.+fEndCapThickness/2.); - - - G4SubtractionSolid* solidPlanarCap_tmp1 = - new G4SubtractionSolid("planar-capo-1", solidPlanarCap, solidBeCutOut, 0, beCutOutTrans1); - - G4SubtractionSolid* solidPlanarCap_tmp2 = - new G4SubtractionSolid("planar-capo-2", solidPlanarCap_tmp1, solidBeCutOut, 0, beCutOutTrans2); - - - //cut outs for Al window at rear - G4Box* solidAlCutOut = new G4Box("Al-cut-out", fPlanarGe_W/2., fPlanarGe_H/2., fAlWindowThickness/2.); - G4ThreeVector alCutOutTrans(0.0*mm, 0.0*mm, PlanarCap_T/2.-fAlWindowThickness/2.); //ends up being 0.9 mm instead of 1.1 mm thick: CORRECT IT - - G4SubtractionSolid* solidPlanarCap_tmp3 = - new G4SubtractionSolid("planar-capo-3", solidPlanarCap_tmp2, solidAlCutOut, 0, alCutOutTrans); - - - G4LogicalVolume* logicPlanarCap = new G4LogicalVolume(solidPlanarCap_tmp3, // it's solid - //logicPlanarCap = new G4LogicalVolume(solidPlanarCap, // it's solid - endCapMaterial, // it's material - "planar-cap", // it's name - 0, 0, 0); // field manager, sensitive det, user limits - - PVPBuffer = new G4PVPlacement(0, //rotation - G4ThreeVector(0.0*mm, fCentreOfDSSD_Y, Planar_z), - logicPlanarCap, //its logical volume - "PlanarCap", //its name - logicChamVac, //its mother - false, //no boolean operat - 0, //copy number - true); //overlap check - - - - - G4VisAttributes* visAttPlanarCapo = new G4VisAttributes(G4Colour(1.0,0.8,1.0) ); - visAttPlanarCapo->SetVisibility(true); - //visAttPlanarCapo->SetVisibility(false); - visAttPlanarCapo->SetForceWireframe(true); - logicPlanarCap->SetVisAttributes(visAttPlanarCapo); - - - //----------------------------------------------------------------------------------------------- - //add the Be window - G4double PlanarBeWindow_z = -PlanarCap_T/2. + fBeWindowThickness/2.; - - G4Box* solidPlanarBeWindow = new G4Box("planar-be", fPlanarGe_W/2., fPlanarGe_H/2., fBeWindowThickness/2.); - - G4LogicalVolume* logicPlanarBeWindow = new G4LogicalVolume(solidPlanarBeWindow,// it's solid - beMaterial, // it's material - "planar-be", // it's name - 0, 0, 0); // field manager, sensitive det, user limits - - PVPBuffer = new G4PVPlacement(0, //rotation - G4ThreeVector(0.0*mm, 0.0*mm, PlanarBeWindow_z), - logicPlanarBeWindow, //its logical volume - "Planar-Be", //its name - logicPlanarCap, //its mother - false, //no boolean operat - 0, //copy number - true); //overlap check - - G4VisAttributes* visAttBeWindow = new G4VisAttributes(G4Colour(0.9,1.0,0.9) ); - visAttBeWindow->SetVisibility(true); - //visAttBeWindow->SetVisibility(false); - visAttBeWindow->SetForceWireframe(true); - logicPlanarBeWindow->SetVisAttributes(visAttBeWindow); - //----------------------------------------------------------------------------------------------- - //special cut out for Vacuum.... - //fAlWindowThickness - //fEndCapThickness - //PlanarCap_T - 2*fEndCapThickness - - - - //cut outs for windows and vacuum - G4Box* solidPlanarVac = new G4Box("planar-vac", PlanarCap_W/2.-fEndCapThickness, PlanarCap_H/2.-fEndCapThickness, PlanarCap_T/2.-fEndCapThickness); - - G4LogicalVolume* logicPlanarVac = new G4LogicalVolume(solidPlanarVac,// it's solid - vacuumMaterial, // it's material - "planar-vac", // it's name - 0, 0, 0); // field manager, sensitive det, user limits - - PVPBuffer = new G4PVPlacement(0, //rotation - G4ThreeVector(0.0*mm, 0.0*mm, 0.0*mm), - logicPlanarVac, //its logical volume - "Planar-Vac", //its name - logicPlanarCap, //its mother - false, //no boolean operat - 0, //copy number - true); //overlap check - - G4cout << "Got Here" << G4endl; - - //visual attributes of the planar end-cap - //G4VisAttributes* visAttPlanarCapo = new G4VisAttributes(G4Colour(1.0,0.8,1.0) ); - //visAttPlanarCapo->SetVisibility(true); - //visAttPlanarCapo->SetVisibility(false); - //visAttPlanarCapo->SetForceWireframe(true); - //logicPlanarCap->SetVisAttributes(visAttPlanarCapo); - logicPlanarVac->SetVisAttributes(visAttPlanarCapo); - - - - - // the planar Ge - G4double PlanarGe_z = -PlanarCap_T/2. + fPlanarGe_T/2. + fPlanarGeGapFront; - - //add in a slab of Ge to accomodate the guard-rail - //and into this slab add the pixels - G4Box* solidPlanarOuterGe = new G4Box("planar-outer-ge", fPlanarGe_W/2.+fPlanarGuard, fPlanarGe_H/2.+fPlanarGuard, fPlanarGe_T/2.); - G4LogicalVolume* logicPlanarOuterGe = new G4LogicalVolume(solidPlanarOuterGe, // it's solid - geMaterial, // it's material - "planar-outer-ge", // it's name - 0, 0, 0); // field manager, sensitive det, user limits - - //G4PVPlacement* physiPlanarOuterGe = new G4PVPlacement(0, //rotation - PVPBuffer = new G4PVPlacement(0, //rotation - G4ThreeVector(0.*mm, 0.0*mm, PlanarGe_z), - logicPlanarOuterGe, //its logical volume - "Planar-Outer-Ge", //its name - logicPlanarVac, //its mother - false, //no boolean operat - 0, true); //copy number - - G4VisAttributes* visAttPlanarOuterGe = new G4VisAttributes(G4Colour(0.9,0.9,1.0) ); - visAttPlanarOuterGe->SetVisibility(true); - //visAttPlanarOuterGe->SetVisibility(false); - visAttPlanarOuterGe->SetForceWireframe(true); - logicPlanarOuterGe->SetVisAttributes(visAttPlanarOuterGe); - - - - //segment the detector - G4int nSegsH = 12; //(y) - G4int nSegsW = 24; //(x) - - //nSegsH = 1; - //nSegsW = 1; - - //common planar "pixel" shape - G4double planarPixel_H = fPlanarGe_H/(G4double) nSegsH; - G4double planarPixel_W = fPlanarGe_W/(G4double) nSegsW; - - G4Box* solidPlanarGe = new G4Box("planar-ge", planarPixel_W/2., planarPixel_H/2., fPlanarGe_T/2.); - - G4VisAttributes* visAttPlanarGe = new G4VisAttributes(G4Colour(1.0,1.0,1.0) ); - visAttPlanarGe->SetVisibility(true); - //visAttPlanarGe->SetVisibility(false); - visAttPlanarGe->SetForceWireframe(true); - logicPlanarOuterGe->SetVisAttributes(visAttPlanarGe); - - //starting y-position for lowest row - G4double thisY = -fPlanarGe_H/2. + planarPixel_H/2.;// + fDSSD_PosY; - - for(G4int ny = 0; ny < nSegsH; ny++) { - //starting x-position - G4double thisX = -fPlanarGe_W/2. + planarPixel_W/2.; - //G4double posY = (2*ny-1)*planarPixel_H/2.; - - for(G4int nx = 0; nx < nSegsW; nx++) { - //G4double posX = -fPlanarGe_W/2. + planarPixel_W/2. + nx*planarPixel_W; - //G4int copyNo = ny*nSegsW+nx; - //G4cout << "Check Planar CopyNo " << copyNo << " @ " << posX << " " << posY << G4endl; - G4int copyNo = ny*100+nx; - G4cout << "Check Planar CopyNo " << copyNo << " @ " << thisX << " " << thisY << G4endl; - - //logicPlanarGe[copyNo] = new G4LogicalVolume(solidPlanarGe,// it's solid - logicPlanarGe[ny][nx] = new G4LogicalVolume(solidPlanarGe,// it's solid - geMaterial, // it's material - "planar-ge", // it's name - 0, 0, 0); // field manager, sensitive det, user limits - - - //physiPlanarGe[copyNo] = new G4PVPlacement(0, //rotation - //G4ThreeVector(posX, posY, 0.0*mm), - //physiPlanarGe[ny][nx] = new G4PVPlacement(0, //rotation - PVPBuffer = new G4PVPlacement(0, //rotation - G4ThreeVector(thisX, thisY, 0.0*mm), - //logicPlanarGe[copyNo], //its logical volume - logicPlanarGe[ny][nx], //its logical volume - "Planar-Ge", //its name - logicPlanarOuterGe, //its mother - false, //no boolean operat - copyNo); //copy number - - //set attributes - logicPlanarGe[ny][nx]->SetVisAttributes(visAttPlanarGe); - - //move along.... - thisX += planarPixel_W; - } - thisY += planarPixel_H; - } - - */ - - //---------------------------------------------------------- - // Cooling Frame: Tunnel and DSSD Detector Support - //---------------------------------------------------------- - G4VisAttributes* visAttCoolingBlock = new G4VisAttributes(G4Colour(0.8,0.8,0.8)); - visAttCoolingBlock->SetVisibility(true); - //visAttCoolingBlock->SetVisibility(false); - visAttCoolingBlock->SetForceWireframe(true); - - G4Box* OuterBox = new G4Box("OuterBox",fCoolingBlockW/2., fCoolingBlockH/2., fCoolingBlockL/2.); - - //place the support on the bottom of the chamber - G4double DSSD_SupPos_y = -fChamberH/2. + fCoolingBlockH/2. + fChamberThickness/2.; - - //position wrt BackPlate/VacChamber - G4double DSSD_SupPos_z = fChamberL/2. - fChamberThickness - fCoolingBlockL/2. - fCoolingBlockZ; - - //now cut a hole out for the DSSD's - G4double Hole4DSSD_W = fCoolingBlockCutOutW; - G4double Hole4DSSD_H = fCoolingBlockCutOutH; - - //from the above can determine the centre of the DSSD wrt centre of Cooling block - fCoolingBlockCutOut_PosY = fCoolingBlockH/2. - fCoolingBlockT - fCoolingBlockCutOutH/2.; //save this frequently used position - G4cout << "fCoolingBlockCutOut_PosY " << fCoolingBlockCutOut_PosY << " cf " << fCoolingBlockDSSDCentre << G4endl; - - G4Box* hole1 = new G4Box("Hole #1",Hole4DSSD_W/2., Hole4DSSD_H/2., fCoolingBlockL/2.); - - G4double dy = fCoolingBlockH/2. - fCoolingBlockT - Hole4DSSD_H/2.; - G4double dx = 0.0*mm; - G4double dz = 0.0*mm; - G4ThreeVector hole1trans(dx, dy, dz); - - G4SubtractionSolid* solid_CB_Temp1 = - new G4SubtractionSolid("fCoolingBlockTemp1", OuterBox, hole1, 0, hole1trans); - - //now cut a hole out for preamps - G4Box* holePreAmp = new G4Box("Hole PreAmp",34.5/2.*mm, 22./2.*mm, fCoolingBlockL/2.); - dx = -fCoolingBlockW/2.+fCoolingBlockT+34.5/2.*mm; - dy = fCoolingBlockH/2. - fCoolingBlockT - Hole4DSSD_H - fCoolingBlockT - 22./2.*mm; - G4ThreeVector holePreAmpTrans1(dx, dy, dz); - dx += (34.5*mm + fCoolingBlockT); - G4ThreeVector holePreAmpTrans2(dx, dy, dz); - dx += (34.5*mm + 14.7*mm); - G4ThreeVector holePreAmpTrans3(dx, dy, dz); - dx += (34.5*mm + fCoolingBlockT); - G4ThreeVector holePreAmpTrans4(dx, dy, dz); - - G4SubtractionSolid* solid_CB_Temp2 = - new G4SubtractionSolid("fCoolingBlockTemp2", solid_CB_Temp1, holePreAmp, 0, holePreAmpTrans1); - - G4SubtractionSolid* solid_CB_Temp3 = - new G4SubtractionSolid("fCoolingBlockTemp3", solid_CB_Temp2, holePreAmp, 0, holePreAmpTrans2); - - G4SubtractionSolid* solid_CB_Temp4 = - new G4SubtractionSolid("fCoolingBlockTemp4", solid_CB_Temp3, holePreAmp, 0, holePreAmpTrans3); - - G4SubtractionSolid* solid_CB_Temp5 = - new G4SubtractionSolid("fCoolingBlockTemp5", solid_CB_Temp4, holePreAmp, 0, holePreAmpTrans4); - - G4LogicalVolume* logicDSSD_Sup = new G4LogicalVolume(solid_CB_Temp5, - supportMaterial, "Cylinder-Box", 0, 0, 0); - //vacuumMaterial, "Cylinder-Box", 0, 0, 0); - - logicDSSD_Sup->SetVisAttributes(visAttCoolingBlock); - - - PVPBuffer = new G4PVPlacement(0,//rotation - G4ThreeVector(0.0*cm, DSSD_SupPos_y, DSSD_SupPos_z), - logicDSSD_Sup, //its logical volume - "fCoolingBlock", //its name - logicChamVac, //its mother - false, //no boolean operat - 1, //copy number - true); //overlap check - - - - - - //------------------------------------------------------------------------------------------- - // DSSD detector Epoxy board....for some reason 2 cut outs are not working => make 2 PCB wafers - G4double DSSD_BrdW = 106.0 * mm * 2.; //Put the 2 boards in one plate - G4double DSSD_BrdH = 157.0 * mm; //SupportH; - G4double DSSD_BrdL = fDSSD_BoardL; //Thickness - - //recess to house DSSD's - G4double siImpBrdCutOutL = fDSSD_BoardL/2.; - // making 2 boards => - G4double DSSD_BrdL1 = DSSD_BrdL - siImpBrdCutOutL; - G4double DSSD_BrdL2 = siImpBrdCutOutL; - - G4double CutOut_dY = 44.0*mm; // distance from top of PCB to top of the first cut-out in the PCB - G4double CutOut1_H = 43.5*mm; // vertical dimension of the cut-out to half thickness - G4double CutOut2_H = 41.0*mm; // vertical dimension of total-thickness cut-ou ie a mounting lip of 1.25 mm - - G4double CutOut1_W = 63.5*mm; //fDSSD_H-2.0*boardLipDSSD; - G4double CutOut2_W = 61.0*mm; //fDSSD_H; - - G4double dssdLip = (CutOut1_W-CutOut2_W)/2.; - G4double central_bar = 1.25*mm; //each side - - G4double DSSD_PCB_Pos_y = -fVacuumH/2. - DSSD_BrdH/2.; //puts top of circuit board at bottom of chamber - DSSD_PCB_Pos_y += (fCoolingBlockDSSDCentre + CutOut_dY + CutOut1_H/2.); - - G4double gapBetweenDSSD = 3.0 * mm; //Gap between the two DSSD's - - //gapBetweenDSSD = 0.01*mm; - - //position wrt centre of vacuum in chamber - G4double DSSD_BrdPos_z = fChamberL/2 - fChamberThickness - fCoolingBlockZ + DSSD_BrdL1/2 + DSSD_BrdL2; - - G4Box* solidDSSD_Board1_tmp1 = - new G4Box("siImpBrd1_tmp", DSSD_BrdW/2., DSSD_BrdH/2., DSSD_BrdL1/2.); - - G4Box* cutOut1a = new G4Box("Box R #1a",CutOut1_W/2., CutOut1_H/2., DSSD_BrdL1/2.); - G4ThreeVector cutOut1aTrans(CutOut1_W/2., DSSD_BrdH/2.-CutOut1_H/2.-CutOut_dY, 0.0*mm); - - G4Box* cutOut1b = new G4Box("Box R #1b",CutOut1_W/2.,CutOut1_H/2.,DSSD_BrdL1/2.); - G4ThreeVector cutOut1bTrans(-CutOut1_W/2., DSSD_BrdH/2.-CutOut1_H/2.-CutOut_dY, 0.0*mm); - - - G4SubtractionSolid* solidDSSD_Board1_a = - new G4SubtractionSolid("siImpBrd1_a", solidDSSD_Board1_tmp1, cutOut1a, 0, cutOut1aTrans); - - G4SubtractionSolid* solidDSSD_Board1 = - new G4SubtractionSolid("siImpBrd1", solidDSSD_Board1_a, cutOut1b, 0, cutOut1bTrans); - - G4LogicalVolume* logicDSSD_Board1 = new G4LogicalVolume(solidDSSD_Board1,// it's solid : with cut-out - boardMaterial, // it's material - //vacuumMaterial, - "DSSD_Brd1", // it's name - 0, 0, 0); // field manager, sensitive det, user limits - - PVPBuffer = new G4PVPlacement(0, //rotation - G4ThreeVector(0.0*mm,DSSD_PCB_Pos_y,DSSD_BrdPos_z), - logicDSSD_Board1, //its logical volume - "DSSD_Brd1", //its name - logicChamVac, //its mother - false, //no boolean operat - 0, //copy number - true); //overlap check - - - DSSD_BrdPos_z -= DSSD_BrdL1/2; - DSSD_BrdPos_z -= DSSD_BrdL2/2; - - G4Box* solidDSSD_Board2_tmp1 = - new G4Box("siImpBrd2_tmp", DSSD_BrdW/2., DSSD_BrdH/2., DSSD_BrdL2/2.); - - G4Box* cutOut2a = new G4Box("Box R #2a",CutOut2_W/2.,CutOut2_H/2.,DSSD_BrdL2/2.); - G4ThreeVector cutOut2aTrans(CutOut2_W/2.+central_bar, DSSD_BrdH/2.-CutOut2_H/2.-CutOut_dY-dssdLip, 0.0*mm); - - G4Box* cutOut2b = new G4Box("Box R #2b",CutOut2_W/2.,CutOut2_H/2.,DSSD_BrdL2/2.); - G4ThreeVector cutOut2bTrans(-CutOut2_W/2.-central_bar, DSSD_BrdH/2.-CutOut2_H/2.-CutOut_dY-dssdLip, 0.0*mm); - - G4SubtractionSolid* solidDSSD_Board2_a = - new G4SubtractionSolid("siImpBrd2_a", solidDSSD_Board2_tmp1, cutOut2a, 0, cutOut2aTrans); - - G4SubtractionSolid* solidDSSD_Board2 = - new G4SubtractionSolid("siImpBrd2", solidDSSD_Board2_a, cutOut2b, 0, cutOut2bTrans); - - G4LogicalVolume* logicDSSD_Board2 = new G4LogicalVolume(solidDSSD_Board2,// it's solid : with cut-out - boardMaterial, // it's material - //vacuumMaterial, - "DSSD_Brd2", // it's name - 0, 0, 0); // field manager, sensitive det, user limits - - PVPBuffer = new G4PVPlacement(0, //rotation - G4ThreeVector(0.0*mm,DSSD_PCB_Pos_y,DSSD_BrdPos_z), - logicDSSD_Board2, //its logical volume - "DSSD_Brd2", //its name - logicChamVac, //its mother - false, //no boolean operat - 0, //copy number - true); //overlap check - - - - //-------------------------------------------- - // Implantation detectors - //first make two Si boards -> gauard ring... - G4VisAttributes* visAttDSSD_1 = new G4VisAttributes(G4Colour(0.6,0.4,0.4) ); - visAttDSSD_1->SetVisibility(true); - //visAttDSSD_1->SetVisibility(false); - visAttDSSD_1->SetForceWireframe(true); - - G4double DSSD_z = DSSD_BrdPos_z - DSSD_BrdL/2. - 3.*fDSSD_T/2. + (DSSD_BrdL-siImpBrdCutOutL); - DSSD_z = fChamberL/2 - fChamberThickness - fCoolingBlockZ + DSSD_BrdL2 - fDSSD_T/2.; - G4cout << "DSSD Z wrt ChamberVac " << DSSD_z << G4endl; - - G4double totalDSSD_H = fDSSD_H+2.*fDSSD_Guard; - G4double totalDSSD_W = fDSSD_W+2.*fDSSD_Guard; - G4Box* solidSi1 = new G4Box("Si1", totalDSSD_W/2., totalDSSD_H/2., fDSSD_T/2.); //Si: 62x42 - G4LogicalVolume* logicSi1 = new G4LogicalVolume(solidSi1, // it's solid - eDetMat, // it's material //vacuumMaterial, - "dssd1", // it's name - 0, 0, 0); // field manager, sensitive det, user limits - - logicSi1->SetVisAttributes(visAttDSSD_1); - - PVPBuffer = new G4PVPlacement(0, //rotation - G4ThreeVector(totalDSSD_W/2.+0.75*mm,fCentreOfDSSD_Y,DSSD_z), - //G4ThreeVector(0.0*mm,fCentreOfDSSD_Y,DSSD_z), - logicSi1, //its logical volume - "dssd1", //its name - logicChamVac, //its mother - false, //no boolean operat - 1); //, //copy number - - G4LogicalVolume* logicSi2 = new G4LogicalVolume(solidSi1, // it's solid - eDetMat, // it's material //vacuumMaterial, - "dssd2", // it's name - 0, 0, 0); // field manager, sensitive det, user limits - - logicSi2->SetVisAttributes(visAttDSSD_1); - - PVPBuffer = new G4PVPlacement(0, //rotation - G4ThreeVector(-totalDSSD_W/2.-0.75*mm,fCentreOfDSSD_Y,DSSD_z), - //G4ThreeVector(0.0*mm,fCentreOfDSSD_Y,DSSD_z), - logicSi2, //its logical volume - "dssd2", //its name - logicChamVac, //its mother - false, //no boolean operat - 2); //, //copy number - - - // The ChamberVac is located wrt centre of Chamber => z0 = -fChamberL/2. - fDSSD_PosZ = DSSD_z - fChamberL/2. - fDSSD_T/2.; - G4cout << "Upstream DSSD face @ Z = " << fDSSD_PosZ << G4endl; - - - //common dssd "pixel" shape - G4VisAttributes* visAttDSSD = new G4VisAttributes(G4Colour(0.8,0.3,0.3) ); - visAttDSSD->SetVisibility(true); - //visAttDSSD->SetVisibility(false); - visAttDSSD->SetForceWireframe(true); - - - - - G4double fDSSD_Pixel_Lx = fDSSD_W/(1.0*nStripsX); - G4double fDSSD_Pixel_Ly = fDSSD_H/(1.0*nStripsY); - - G4Box* solidDSSD = new G4Box("dssd", fDSSD_Pixel_Lx/2., fDSSD_Pixel_Ly/2., fDSSD_T/2.); - - - //starting y-position for lowest row - G4double thisy = -nStripsY/2.*fDSSD_Pixel_Ly + fDSSD_Pixel_Ly/2. + fCoolingBlockCutOut_PosY; - thisy = -nStripsY/2.*fDSSD_Pixel_Ly + fDSSD_Pixel_Ly/2. + fCentreOfDSSD_Y; - - G4double thisy2 = -fDSSD_H/2. + fDSSD_Pixel_Ly/2.; - - for(G4int iy = 0; iy < nStripsY; iy++) { - //starting x-position - G4double thisx = -nStripsX*fDSSD_Pixel_Lx + fDSSD_Pixel_Lx/2. - gapBetweenDSSD/2.; - G4double thisx2 = -fDSSD_W/2. + fDSSD_Pixel_Lx/2.; - for(G4int ix = 0; ix < nStripsX; ix++) { - - //DSSD_A - logicDSSD_A[iy][ix] = new G4LogicalVolume(solidDSSD, // it's solid - eDetMat, // it's material - //vacuumMaterial, - "dssd-pixel",// it's name - 0, 0, 0); // field manager, sensitive det, user limits - - PVPBuffer = new G4PVPlacement(0, //rotation - //G4ThreeVector(thisx,thisy,DSSD_z), - G4ThreeVector(thisx2,thisy2,0.0*mm), - logicDSSD_A[iy][ix],//its logical volume - "DSSD_A", //its name - logicSi2, //its mother - false, //no boolean operat - iy*100+ix);//, //copy number - - - //DSSD_B - logicDSSD_B[iy][ix] = new G4LogicalVolume(solidDSSD, // it's solid - eDetMat, // it's material - //vacuumMaterial, - "dssd-pixel",// it's name - 0, 0, 0); // field manager, sensitive det, user limits - - PVPBuffer = new G4PVPlacement(0, //rotation - //G4ThreeVector(thisx+fDSSD_W+gapBetweenDSSD,thisy,DSSD_z), - G4ThreeVector(thisx2,thisy2,0.0*mm), - logicDSSD_B[iy][ix],//its logical volume - "DSSD_B", //its name - logicSi1, //its mother - false, //no boolean operat - iy*100+ix);//, //copy number - - - //visu - logicDSSD_A[iy][ix]->SetVisAttributes(visAttDSSD); - logicDSSD_B[iy][ix]->SetVisAttributes(visAttDSSD); - - //move along please - //thisN++; - thisx += fDSSD_Pixel_Lx; - thisx2 += fDSSD_Pixel_Lx; - } - thisy += fDSSD_Pixel_Ly; - thisy2 += fDSSD_Pixel_Ly; - } +G4Box* pre_amp_board3 += new G4Box("pre_amp_board3",1.675*cm/2, 6.756*cm/2, 7.976*cm/2 ); // + +G4LogicalVolume* logicpre_amp3 = new G4LogicalVolume(pre_amp_board3, PCB, "logicpre_amp3"); +PVPBuffer = +new G4PVPlacement(0, G4ThreeVector(-9.6725*cm, 2.413375*cm, -4.265*cm), logicpre_amp3, "pre_amp_board3", world, false, +0); PVPBuffer = new G4PVPlacement(0, G4ThreeVector(-9.6725*cm, -5.336625*cm, -4.265*cm), logicpre_amp3, +"pre_amp_board3", world, false, 1); - //-------------------------------------------- - // The PINS - //-------------------------------------------- - G4double PinL = 30.0 * mm; //PinLxPinL - G4double PinT = 1.0 * mm; //0.5 * mm; //Thickness - G4double PinGuard = 1.0 * mm; //Guardrail - G4double PinGap = 1.0 * mm; //between PINS - G4double PinToEdge = 3.0 * mm; //gap from the end - G4double PinEpoxyT = 1.6 * mm; //thickness of pcb board -// G4double PinSupportLip = PinT+PinEpoxyT; //thickness of pcb board - - //horizontal-side dimensions [approxiamted as a single board] - G4double PinBoard_H_W = PinL*5.; - G4double PinBoard_H_H = PinEpoxyT; - G4double PinBoard_H_L = PinToEdge + PinL + PinGap + PinL + 13.0*mm; - - //vertical-side dimensions [approximated as a single board] - G4double PinBoard_V_H = PinL*2.; - G4double PinBoard_V_W = PinEpoxyT; - G4double PinBoard_V_L = PinToEdge + PinL + PinGap + PinL + 13.0*mm; - - //the PCB board for the PINS sits on top of another board [oh yeah transparency !] - G4double PinBoardSupport_T = 4.75*mm; //nominally 4.75*mm; - - //positions wrt cahmaber vacuum : put it at downstream side of the support block - G4double PinBoard_z = DSSD_SupPos_z + fCoolingBlockL/2 - PinBoard_H_L/2.; - PinBoard_z -= 1.5*mm; //move back due to support - - G4double PinBoard_H_x = 0.0 * mm; - G4double PinBoard_H_dy = Hole4DSSD_H/2. - PinEpoxyT/2. - PinBoardSupport_T; - G4double PinBoard_V_x = Hole4DSSD_W/2. - PinEpoxyT/2. - PinBoardSupport_T; - fDSSD_PosY = fCentreOfDSSD_Y; - G4double PinBoard_V_y = fDSSD_PosY; - - //The epoxy board for the pins - G4VisAttributes* visAttPIN_Board = new G4VisAttributes( G4Colour(0.3,0.9,0.3) ); - visAttPIN_Board->SetVisibility(true); - //visAttPIN_Board->SetVisibility(false); - visAttPIN_Board->SetForceWireframe(true); - - //Pin PCB/Epoxy boards - G4Box* solidPinBoard_H = new G4Box("pin-pcb", PinBoard_H_W/2., PinBoard_H_H/2., PinBoard_H_L/2.); - G4Box* solidPinBoard_V = new G4Box("pin-pcb", PinBoard_V_W/2., PinBoard_V_H/2., PinBoard_V_L/2.); - - - G4LogicalVolume* logicPinBoard_H = new G4LogicalVolume(solidPinBoard_H, // it's solid - boardMaterial, // it's material - "pin-pcb", // it's name - 0,0,0); // field manager etc - - G4LogicalVolume* logicPinBoard_V = new G4LogicalVolume(solidPinBoard_V, // it's solid - boardMaterial, // it's material - "pin-pcb", // it's name - 0,0,0); // field manager etc - - logicPinBoard_H->SetVisAttributes(visAttPIN_Board); - logicPinBoard_V->SetVisAttributes(visAttPIN_Board); - - - //G4PVPlacement* physiPinBoard_H[2]; - //G4PVPlacement* physiPinBoard_V[2]; - - for(G4int i = 0; i < 2; i++) { - - G4double dyPos = (2*i-1)*PinBoard_H_dy; - - PVPBuffer = new G4PVPlacement(0, //rotation - G4ThreeVector(PinBoard_H_x, fCentreOfDSSD_Y + dyPos, PinBoard_z), - logicPinBoard_H, //its logical volume - "PinPCB_H", //its name - logicChamVac, //its mother - false, //no boolean operat - i+1); //copy number - - PVPBuffer = new G4PVPlacement(0, //rotation - G4ThreeVector( PinBoard_V_x*(2*i-1), PinBoard_V_y, PinBoard_z), - logicPinBoard_V, //its logical volume - "PinPCB_V", //its name - logicChamVac, //its mother - false, //no boolean operat - i+1); //copy number - +G4VisAttributes* pre_amp_board3VisAtt = new G4VisAttributes(G4Colour(0., 0.7, 0.)); +logicpre_amp3->SetVisAttributes(pre_amp_board3VisAtt); + +*/ /* end of Eleanor's additions */ } + else if (m_ChamberType == 3) { // case of GREAT chamber as defined by Karl + + fChamberH = m_ChamberHmax; + fChamberW = m_ChamberWmax; + // fChamberL = m_ChamberDmax; + fChamberThickness = m_ChamberHmax - m_ChamberHmin; + + fVacuumH = fChamberH - fChamberThickness; + + G4cout << "fChamberH=" << fChamberH << G4endl; + G4cout << "fChamberW=" << fChamberW << G4endl; + G4cout << "fChamberThickness=" << fChamberThickness << G4endl; + + //----------------------------- + // more dimesions for chamber + fChamberL = + fCoolingBlockL + fLengthOfPlanarCut + fDSSD_BoardL + fdeltaZ_Support + 2. * fChamberThickness + 10.0 * mm; + + //--------------------------------------------------------------------------------- + // This shift in the position of the chamber is to put the DSSD centred at y = 0 + fShiftChamberY = + fCoolingBlockH - fCoolingBlockT - fCoolingBlockCutOutH / 2.; // height of centre wrt cooling block base + fShiftChamberY -= fChamberH / 2.; + + // Define the downstream face of the DSSD to be at 0 (ie the centre of the DSSD PCB board) + fShiftChamberZ = fCoolingBlockZ + fChamberThickness - fDSSD_BoardL / 2.; // a discrepency of 1 mm somewhere + + // the centre of the DSSD wrt the vacuum chamber + fCentreOfDSSD_Y = + -fVacuumH / 2. + fCoolingBlockH - fCoolingBlockT - fCoolingBlockCutOutH / 2.; //+ fChamberThickness + cout << G4endl << " DSSD_Y at 0 mm , but wrt vacuum DSSD_Y @ " << fCentreOfDSSD_Y << G4endl; + + //-------------------------------------------- + //[partial] Vacuum Chamber (Walls+Vacuum) and end BackPlate + // Set the Upstream side of the Chamber @ Z=0mm + + // G4Box* solidChamber = new G4Box("chamber",fChamberW/2., fChamberH/2., fChamberL/2.); + // replaced by achamber with a substraction of the Planar area: + G4Box* solidChamberEnv = new G4Box("chamberEnv", fChamberW / 2., fChamberH / 2., fChamberL / 2.); + G4double PlanarCap_W = fPlanarGe_W + 2. * fPlanarGuard + 80. * mm; // A GUESS + G4double PlanarCap_H = 150. * mm; + PlanarCap_H = fPlanarGe_H + 70 * mm; + G4double PlanarCap_T = fPlanarTotalL; + G4cout << G4endl << "Planar end-cap thickness " << PlanarCap_T << " cf 41. mm" << G4endl; + fShiftPlanar = fChamberL / 2. - fChamberThickness + PlanarCap_T / 2. - fLengthOfPlanarCut + fGap_PCB_2_Planar; + G4double Planar_z = fShiftPlanar; + G4Box* solidPlanarCapEnv = new G4Box("planar-cap-Env", PlanarCap_W / 2., PlanarCap_H / 2., PlanarCap_T / 2.); + G4SubtractionSolid* solidChamber = new G4SubtractionSolid("chamber", solidChamberEnv, solidPlanarCapEnv, 0, + G4ThreeVector(0.0 * mm, fCentreOfDSSD_Y, Planar_z)); + + // end of replacement + + G4LogicalVolume* logicChamber = new G4LogicalVolume(solidChamber, // it's solid + m_ChamberMaterial, // it's material + // chamberMaterial,//it's material + // vacuumMaterial,//it's material + "Chamber", // it's name + 0, 0, 0); // field manager, sensitive det, user limits + + PVPBuffer = new G4PVPlacement(0, // rotation + G4ThreeVector(0.0 * mm, -fShiftChamberY, -fChamberL / 2. + fShiftChamberZ), + logicChamber, // its logical volume + "Chamber", // its name + world, // its mother + false, // no boolean operat + 0, // copy number + true); // overlap check + + // viewing the chamber + G4VisAttributes* visAttChamber = new G4VisAttributes(G4Colour(1.0, 1.0, 1.0)); + visAttChamber->SetVisibility(true); + visAttChamber->SetForceWireframe(true); + logicChamber->SetVisAttributes(visAttChamber); + // logicChamber->SetVisAttributes(G4VisAttributes::GetInvisible()); + + // Vacuum within above partial chamber + + G4double vacH = fChamberH - fChamberThickness; + G4double vacW = fChamberW - 2. * fChamberThickness; + G4double vacL = fChamberL - 2. * fChamberThickness; + + // G4Box* solidChamVac = new G4Box("chamVac",vacW/2., vacH/2., vacL/2.); + // Replaced by + G4Box* solidChamVacEnv = new G4Box("chamVacEnV", vacW / 2., vacH / 2., vacL / 2.); + // G4Box* solidPlanarCapEnv = new G4Box("planar-cap-Env", PlanarCap_W/2., PlanarCap_H/2., PlanarCap_T/2.); + G4SubtractionSolid* solidChamVac = + new G4SubtractionSolid("chamVac", solidChamVacEnv, solidPlanarCapEnv, 0, + G4ThreeVector(0.0 * mm, fCentreOfDSSD_Y + fChamberThickness / 2., Planar_z)); + + G4LogicalVolume* logicChamVac = new G4LogicalVolume(solidChamVac, // it's solid + vacuumMaterial, // it's material + "chamVac", // it's name + 0, 0, 0); // field manager, sensitive det, user limits + + PVPBuffer = new G4PVPlacement(0, // rotation + G4ThreeVector(0.0 * cm, -fChamberThickness / 2., 0.0 * cm), + logicChamVac, // its logical volume + "ChamVac", // its name + logicChamber, // its mother + false, // no boolean operat + 0, // copy number + true); // overlap check + + // logicChamVac->SetVisAttributes(G4VisAttributes::GetInvisible()); + logicChamVac->SetVisAttributes(visAttChamber); + + /* Uncomment if you want the planar in the geometry and you are not using GRTPlan */ + /* + //---------------------------------------------------------------------- + // The Planar + //---------------------------------------------------------------------- + G4double PlanarCap_W = fPlanarGe_W + 2.*fPlanarGuard + 80.*mm; //A GUESS + G4double PlanarCap_H = 150.*mm; + PlanarCap_H = fPlanarGe_H + 70*mm; + G4double PlanarCap_T = fPlanarTotalL; + G4cout << G4endl << "Planar end-cap thickness " << PlanarCap_T << " cf 41. mm" << G4endl; + + // - editted 07/11/2011 + fShiftPlanar = fChamberL/2. - fChamberThickness + PlanarCap_T/2. - fLengthOfPlanarCut + fGap_PCB_2_Planar; + G4double Planar_z = fShiftPlanar; + fPlanar_PosZ = Planar_z; + + //starting endCap sold + G4Box* solidPlanarCap = new G4Box("planar-cap", PlanarCap_W/2., PlanarCap_H/2., PlanarCap_T/2.); + + //cut outs for Be window : planar end-cap is deliberately symmetric to make positioning more simple + //3 mm wide support rib that is 2.2 mm thick. Add the Be thickness => endCap thickness + G4Box* solidBeCutOut = new G4Box("be-cut-out", fPlanarGe_W/4.-1.5*mm, fPlanarGe_H/2., fEndCapThickness/2.);//is it + total 120 mm or 120+gap ? G4ThreeVector beCutOutTrans1(-fPlanarGe_W/4.-1.5*mm, 0.0*mm, + -PlanarCap_T/2.+fEndCapThickness/2.); G4ThreeVector beCutOutTrans2(+fPlanarGe_W/4.+1.5*mm, 0.0*mm, + -PlanarCap_T/2.+fEndCapThickness/2.); + + + G4SubtractionSolid* solidPlanarCap_tmp1 = + new G4SubtractionSolid("planar-capo-1", solidPlanarCap, solidBeCutOut, 0, beCutOutTrans1); + + G4SubtractionSolid* solidPlanarCap_tmp2 = + new G4SubtractionSolid("planar-capo-2", solidPlanarCap_tmp1, solidBeCutOut, 0, beCutOutTrans2); + + + //cut outs for Al window at rear + G4Box* solidAlCutOut = new G4Box("Al-cut-out", fPlanarGe_W/2., fPlanarGe_H/2., fAlWindowThickness/2.); + G4ThreeVector alCutOutTrans(0.0*mm, 0.0*mm, PlanarCap_T/2.-fAlWindowThickness/2.); //ends up being 0.9 mm instead + of 1.1 mm thick: CORRECT IT + + G4SubtractionSolid* solidPlanarCap_tmp3 = + new G4SubtractionSolid("planar-capo-3", solidPlanarCap_tmp2, solidAlCutOut, 0, alCutOutTrans); + + + G4LogicalVolume* logicPlanarCap = new G4LogicalVolume(solidPlanarCap_tmp3, // it's solid + //logicPlanarCap = new G4LogicalVolume(solidPlanarCap, // it's solid + endCapMaterial, // it's material + "planar-cap", // it's name + 0, 0, 0); // field manager, sensitive det, user limits + + PVPBuffer = new G4PVPlacement(0, //rotation + G4ThreeVector(0.0*mm, fCentreOfDSSD_Y, Planar_z), + logicPlanarCap, //its logical volume + "PlanarCap", //its name + logicChamVac, //its mother + false, //no boolean operat + 0, //copy number + true); //overlap check + + + + + G4VisAttributes* visAttPlanarCapo = new G4VisAttributes(G4Colour(1.0,0.8,1.0) ); + visAttPlanarCapo->SetVisibility(true); + //visAttPlanarCapo->SetVisibility(false); + visAttPlanarCapo->SetForceWireframe(true); + logicPlanarCap->SetVisAttributes(visAttPlanarCapo); + + + //----------------------------------------------------------------------------------------------- + //add the Be window + G4double PlanarBeWindow_z = -PlanarCap_T/2. + fBeWindowThickness/2.; + + G4Box* solidPlanarBeWindow = new G4Box("planar-be", fPlanarGe_W/2., fPlanarGe_H/2., fBeWindowThickness/2.); + + G4LogicalVolume* logicPlanarBeWindow = new G4LogicalVolume(solidPlanarBeWindow,// it's solid + beMaterial, // it's material + "planar-be", // it's name + 0, 0, 0); // field manager, sensitive det, user limits + + PVPBuffer = new G4PVPlacement(0, //rotation + G4ThreeVector(0.0*mm, 0.0*mm, PlanarBeWindow_z), + logicPlanarBeWindow, //its logical volume + "Planar-Be", //its name + logicPlanarCap, //its mother + false, //no boolean operat + 0, //copy number + true); //overlap check + + G4VisAttributes* visAttBeWindow = new G4VisAttributes(G4Colour(0.9,1.0,0.9) ); + visAttBeWindow->SetVisibility(true); + //visAttBeWindow->SetVisibility(false); + visAttBeWindow->SetForceWireframe(true); + logicPlanarBeWindow->SetVisAttributes(visAttBeWindow); + //----------------------------------------------------------------------------------------------- + //special cut out for Vacuum.... + //fAlWindowThickness + //fEndCapThickness + //PlanarCap_T - 2*fEndCapThickness + + + + //cut outs for windows and vacuum + G4Box* solidPlanarVac = new G4Box("planar-vac", PlanarCap_W/2.-fEndCapThickness, PlanarCap_H/2.-fEndCapThickness, + PlanarCap_T/2.-fEndCapThickness); + + G4LogicalVolume* logicPlanarVac = new G4LogicalVolume(solidPlanarVac,// it's solid + vacuumMaterial, // it's material + "planar-vac", // it's name + 0, 0, 0); // field manager, sensitive det, user limits + + PVPBuffer = new G4PVPlacement(0, //rotation + G4ThreeVector(0.0*mm, 0.0*mm, 0.0*mm), + logicPlanarVac, //its logical volume + "Planar-Vac", //its name + logicPlanarCap, //its mother + false, //no boolean operat + 0, //copy number + true); //overlap check + + G4cout << "Got Here" << G4endl; + + //visual attributes of the planar end-cap + //G4VisAttributes* visAttPlanarCapo = new G4VisAttributes(G4Colour(1.0,0.8,1.0) ); + //visAttPlanarCapo->SetVisibility(true); + //visAttPlanarCapo->SetVisibility(false); + //visAttPlanarCapo->SetForceWireframe(true); + //logicPlanarCap->SetVisAttributes(visAttPlanarCapo); + logicPlanarVac->SetVisAttributes(visAttPlanarCapo); + + + + + // the planar Ge + G4double PlanarGe_z = -PlanarCap_T/2. + fPlanarGe_T/2. + fPlanarGeGapFront; + + //add in a slab of Ge to accomodate the guard-rail + //and into this slab add the pixels + G4Box* solidPlanarOuterGe = new G4Box("planar-outer-ge", fPlanarGe_W/2.+fPlanarGuard, fPlanarGe_H/2.+fPlanarGuard, + fPlanarGe_T/2.); G4LogicalVolume* logicPlanarOuterGe = new G4LogicalVolume(solidPlanarOuterGe, // it's solid + geMaterial, // it's material + "planar-outer-ge", // it's name + 0, 0, 0); // field manager, sensitive det, user limits + + //G4PVPlacement* physiPlanarOuterGe = new G4PVPlacement(0, //rotation + PVPBuffer = new G4PVPlacement(0, //rotation + G4ThreeVector(0.*mm, 0.0*mm, PlanarGe_z), + logicPlanarOuterGe, //its logical volume + "Planar-Outer-Ge", //its name + logicPlanarVac, //its mother + false, //no boolean operat + 0, true); //copy number + + G4VisAttributes* visAttPlanarOuterGe = new G4VisAttributes(G4Colour(0.9,0.9,1.0) ); + visAttPlanarOuterGe->SetVisibility(true); + //visAttPlanarOuterGe->SetVisibility(false); + visAttPlanarOuterGe->SetForceWireframe(true); + logicPlanarOuterGe->SetVisAttributes(visAttPlanarOuterGe); + + + + //segment the detector + G4int nSegsH = 12; //(y) + G4int nSegsW = 24; //(x) + + //nSegsH = 1; + //nSegsW = 1; + + //common planar "pixel" shape + G4double planarPixel_H = fPlanarGe_H/(G4double) nSegsH; + G4double planarPixel_W = fPlanarGe_W/(G4double) nSegsW; + + G4Box* solidPlanarGe = new G4Box("planar-ge", planarPixel_W/2., planarPixel_H/2., fPlanarGe_T/2.); + + G4VisAttributes* visAttPlanarGe = new G4VisAttributes(G4Colour(1.0,1.0,1.0) ); + visAttPlanarGe->SetVisibility(true); + //visAttPlanarGe->SetVisibility(false); + visAttPlanarGe->SetForceWireframe(true); + logicPlanarOuterGe->SetVisAttributes(visAttPlanarGe); + + //starting y-position for lowest row + G4double thisY = -fPlanarGe_H/2. + planarPixel_H/2.;// + fDSSD_PosY; + + for(G4int ny = 0; ny < nSegsH; ny++) { + //starting x-position + G4double thisX = -fPlanarGe_W/2. + planarPixel_W/2.; + //G4double posY = (2*ny-1)*planarPixel_H/2.; + + for(G4int nx = 0; nx < nSegsW; nx++) { + //G4double posX = -fPlanarGe_W/2. + planarPixel_W/2. + nx*planarPixel_W; + //G4int copyNo = ny*nSegsW+nx; + //G4cout << "Check Planar CopyNo " << copyNo << " @ " << posX << " " << posY << G4endl; + G4int copyNo = ny*100+nx; + G4cout << "Check Planar CopyNo " << copyNo << " @ " << thisX << " " << thisY << G4endl; + + //logicPlanarGe[copyNo] = new G4LogicalVolume(solidPlanarGe,// it's solid + logicPlanarGe[ny][nx] = new G4LogicalVolume(solidPlanarGe,// it's solid + geMaterial, // it's material + "planar-ge", // it's name + 0, 0, 0); // field manager, sensitive det, user limits + + + //physiPlanarGe[copyNo] = new G4PVPlacement(0, //rotation + //G4ThreeVector(posX, posY, 0.0*mm), + //physiPlanarGe[ny][nx] = new G4PVPlacement(0, //rotation + PVPBuffer = new G4PVPlacement(0, //rotation + G4ThreeVector(thisX, thisY, 0.0*mm), + //logicPlanarGe[copyNo], //its logical volume + logicPlanarGe[ny][nx], //its logical volume + "Planar-Ge", //its name + logicPlanarOuterGe, //its mother + false, //no boolean operat + copyNo); //copy number + + //set attributes + logicPlanarGe[ny][nx]->SetVisAttributes(visAttPlanarGe); + + //move along.... + thisX += planarPixel_W; + } + thisY += planarPixel_H; + } + */ - //----------------------------------------- - //Horiz Support for Pin Epoxy : the PCB board for the PINS sits on top of another board [oh yeah transparency !] - G4VisAttributes* visAttPIN_BoardSup = new G4VisAttributes( G4Colour(0.9,0.9,0.9) ); - visAttPIN_BoardSup->SetVisibility(true); - //visAttPIN_BoardSup->SetVisibility(false); - visAttPIN_BoardSup->SetForceWireframe(true); - - G4double PinBoardSupport_H_W = fCoolingBlockCutOutW; - G4double PinBoardSupport_H_H = 3.75*mm; - G4double PinBoardSupport_H_L = 80.*mm; + //---------------------------------------------------------- + // Cooling Frame: Tunnel and DSSD Detector Support + //---------------------------------------------------------- + G4VisAttributes* visAttCoolingBlock = new G4VisAttributes(G4Colour(0.8, 0.8, 0.8)); + visAttCoolingBlock->SetVisibility(true); + // visAttCoolingBlock->SetVisibility(false); + visAttCoolingBlock->SetForceWireframe(true); + G4Box* OuterBox = new G4Box("OuterBox", fCoolingBlockW / 2., fCoolingBlockH / 2., fCoolingBlockL / 2.); - G4Box* solidPinSupportBoard_H_temp = new G4Box("pin-pcb-support", PinBoardSupport_H_W/2., PinBoardSupport_H_H/2., PinBoardSupport_H_L/2.); - - G4double cutOutPinBoard_H_x = 28.6*mm; - G4Box* cutOutPinBoard_H = new G4Box("Box Pin Board #1",cutOutPinBoard_H_x/2.,PinBoardSupport_H_H/2.,70.*mm/2.); - - G4ThreeVector cutOutPinBoard_H_centre(0.0*mm, 0.0*mm, 5.0*mm); - G4ThreeVector cutOutPinBoard_H_p1( PinL, 0.0*mm, 5.0*mm); - G4ThreeVector cutOutPinBoard_H_m1(-PinL, 0.0*mm, 5.0*mm); - G4ThreeVector cutOutPinBoard_H_p2( 2*PinL, 0.0*mm, 5.0*mm); - G4ThreeVector cutOutPinBoard_H_m2(-2*PinL, 0.0*mm, 5.0*mm); - - G4SubtractionSolid* solidPinSupportBoard_H0 = - new G4SubtractionSolid("pin-pcb-support_0", solidPinSupportBoard_H_temp, cutOutPinBoard_H, 0, cutOutPinBoard_H_centre); - - G4SubtractionSolid* solidPinSupportBoard_HA = - new G4SubtractionSolid("pin-pcb-support_a", solidPinSupportBoard_H0, cutOutPinBoard_H, 0, cutOutPinBoard_H_p1); - - G4SubtractionSolid* solidPinSupportBoard_HB = - new G4SubtractionSolid("pin-pcb-support_b", solidPinSupportBoard_HA, cutOutPinBoard_H, 0, cutOutPinBoard_H_m1); - - G4SubtractionSolid* solidPinSupportBoard_HC = - new G4SubtractionSolid("pin-pcb-support_b", solidPinSupportBoard_HB, cutOutPinBoard_H, 0, cutOutPinBoard_H_p2); - - G4SubtractionSolid* solidPinSupportBoard_H = - new G4SubtractionSolid("pin-pcb-support_b", solidPinSupportBoard_HC, cutOutPinBoard_H, 0, cutOutPinBoard_H_m2); - - - - G4LogicalVolume* logicPinSupportBoard_H = new G4LogicalVolume(solidPinSupportBoard_H, // it's solid - m_ChamberMaterial, // it's material - "pin-pcb-support", // it's name - 0,0,0); // field manager etc - logicPinSupportBoard_H->SetVisAttributes(visAttPIN_BoardSup); - - G4double PinBoardSupport_Z = DSSD_SupPos_z + fCoolingBlockL/2. - PinBoardSupport_H_L/2. - 1.0*mm; - - - - PVPBuffer = new G4PVPlacement(0, //rotation - G4ThreeVector(PinBoard_H_x, fDSSD_PosY + fCoolingBlockCutOutH/2. - PinBoardSupport_H_H/2., PinBoardSupport_Z), - logicPinSupportBoard_H, //its logical volume - "PinPCB_Support", //its name - logicChamVac, //its mother - false, //no boolean operat - 1); //copy number - - PVPBuffer = new G4PVPlacement(0, //rotation - G4ThreeVector(PinBoard_H_x, fDSSD_PosY - fCoolingBlockCutOutH/2. + PinBoardSupport_H_H/2., PinBoardSupport_Z), - logicPinSupportBoard_H, //its logical volume - "PinPCB_Support", //its name - logicChamVac, //its mother - false, //no boolean operat - 2); //copy number - - - - G4double PinBoardSupport_W_W = 3.75*mm; - G4double PinBoardSupport_W_H = fCoolingBlockCutOutH - 2.*PinBoardSupport_H_H; - G4double PinBoardSupport_W_L = 80.*mm; - - //Vertical Support Pin Epoxy - G4Box* solidPinSupportBoard_V_temp = new G4Box("pin-pcb-support", PinBoardSupport_W_W/2., PinBoardSupport_W_H/2., PinBoardSupport_W_L/2.); - - G4Box* cutOutPinBoard_V = new G4Box("Box Pin Board #1",PinBoardSupport_W_W/2.,cutOutPinBoard_H_x/2.,70.*mm/2.); - G4double cutOutSpine_x = (PinL + PinGap - cutOutPinBoard_H_x)/2.; - - G4ThreeVector cutOutPinBoard_V_p1( 0.0*mm, (cutOutSpine_x+cutOutPinBoard_H_x)/2., 5.0*mm); - G4ThreeVector cutOutPinBoard_V_m1( 0.0*mm, -(cutOutSpine_x+cutOutPinBoard_H_x)/2., 5.0*mm); - - G4SubtractionSolid* solidPinSupportBoard_V0 = - new G4SubtractionSolid("pin-pcb-support_0", solidPinSupportBoard_V_temp, cutOutPinBoard_V, 0, cutOutPinBoard_V_p1); - - G4SubtractionSolid* solidPinSupportBoard_V = - new G4SubtractionSolid("pin-pcb-support_b", solidPinSupportBoard_V0, cutOutPinBoard_V, 0, cutOutPinBoard_V_m1); - - - - G4LogicalVolume* logicPinSupportBoard_V = new G4LogicalVolume(solidPinSupportBoard_V, // it's solid - m_ChamberMaterial, // it's material - "pin-pcb-support", // it's name - 0,0,0); // field manager etc - - logicPinSupportBoard_V->SetVisAttributes(visAttPIN_BoardSup); - - PVPBuffer = new G4PVPlacement(0, //rotation - G4ThreeVector( fCoolingBlockCutOutW/2. - PinBoardSupport_W_W/2., fDSSD_PosY, PinBoardSupport_Z), - logicPinSupportBoard_V, //its logical volume - "PinPCBSupport", //its name - logicChamVac, //its mother - false, //no boolean operat - 1); //copy number - - PVPBuffer= new G4PVPlacement(0, //rotation - G4ThreeVector(-fCoolingBlockCutOutW/2. + PinBoardSupport_W_W/2., fDSSD_PosY, PinBoardSupport_Z), - logicPinSupportBoard_V, //its logical volume - "PinPCBSupport", //its name - logicChamVac, //its mother - false, //no boolean operat - 2); //copy number - - - //add the fucking ridiculous flange.... - G4double PinFlange_Z = DSSD_SupPos_z + fCoolingBlockL/2. - 0.5*mm; - G4Box* PinFlange_outer = new G4Box("Box Pin Flange #1",fCoolingBlockCutOutW/2.,fCoolingBlockCutOutH/2.,1.0*mm/2.); //probably even thicker just to make sure no low E gammas are seen ! - G4Box* PinFlange_hole = new G4Box("Box Pin Flange #2",fCoolingBlockCutOutW/2.-4.0*mm,fCoolingBlockCutOutH/2.-4.0*mm,1.0*mm/2.); - - G4SubtractionSolid* solidPinFlange = - new G4SubtractionSolid("pin-flange", PinFlange_outer, PinFlange_hole, 0, G4ThreeVector(0.*mm, 0.*mm, 0.*mm)); - - - G4LogicalVolume* logicPinFlange = new G4LogicalVolume(solidPinFlange, // it's solid - m_ChamberMaterial, // it's material - "pin-flange", // it's name - 0,0,0); // field manager etc - - logicPinFlange->SetVisAttributes(visAttPIN_BoardSup); - - PVPBuffer = new G4PVPlacement(0, //rotation - G4ThreeVector(0.0*mm, fDSSD_PosY, PinFlange_Z), - logicPinFlange, //its logical volume - "PinFlange", //its name - logicChamVac, //its mother - false, //no boolean operat - 1); //copy number - - //now the PINS..... - G4VisAttributes* visAttPIN = new G4VisAttributes( G4Colour(0.9,0.9,0.3) ); - visAttPIN->SetVisibility(true); - //visAttPIN->SetVisibility(false); - visAttPIN->SetForceWireframe(true); - - G4double Pin_z1 = PinBoard_z + PinBoard_V_L/2. - PinToEdge - PinL/2; - //G4double Pin_z2 = Pin_z1 - PinGap - PinL; - - //total Si area - G4Box* solidPINS_H = new G4Box("pins-passive", PinL/2., PinT/2., PinL/2); //horizontal - new G4Box("pins-passive", PinT/2., PinL/2., PinL/2); //vertical - - //active Si - G4Box* solidPINS_Active_H = new G4Box("pins", PinL/2.-PinGuard, PinT/2., PinL/2-PinGuard); //horizontal - new G4Box("pins", PinT/2., PinL/2.-PinGuard, PinL/2-PinGuard); //vertical - - - //horizontal rows could put an index[i] = copyNo to match position in real array !! - for(G4int nH = 0; nH < 2; nH++) { //up/down - G4double posY = fDSSD_PosY + (2*nH - 1)*(PinBoard_H_dy - PinBoard_H_H/2. - PinT/2.); - - for(G4int i = 1; i <= 5; i++) { //across in x - G4double posX = -PinBoard_H_W/2. + PinL/2. + (i-1)*PinL; - - for(G4int r = 1; r <= 2; r++) { //2 rows (in z) - G4double posZ = Pin_z1 - (r%2)*(PinGap + PinL); - G4int copyNo = nH*10+2*(i-1)+r; - G4cout << "Checking PIN copyNo " << copyNo << G4endl; - - logicPINS[copyNo-1] = new G4LogicalVolume(solidPINS_H, // it's solid - eDetMat, // it's material - "pin-pass-h", // it's name - 0,0,0); // field manager etc - - logicPINS[copyNo-1]->SetVisAttributes(visAttPIN); - - - PVPBuffer = new G4PVPlacement(0, //rotation - G4ThreeVector(posX, posY, posZ), - logicPINS[copyNo-1], //its logical volume - "PinPass", //its name - logicChamVac, //its mother - false, //no boolean operat - copyNo, //copy number - true); //check for overlaps - - - logicPINS_Active[copyNo-1] = new G4LogicalVolume(solidPINS_Active_H, // it's solid - eDetMat, // it's material - "pin-h", // it's name - 0,0,0); // field manager etc - - logicPINS_Active[copyNo-1]->SetVisAttributes(visAttPIN); - - - PVPBuffer = new G4PVPlacement(0, //rotation - G4ThreeVector(0.*mm,0.*mm,0.*mm), - logicPINS_Active[copyNo-1], //its logical volume - "Pin", //its name - logicPINS[copyNo-1], //its mother - false, //no boolean operat - copyNo); //copy number - - } - } - } + // place the support on the bottom of the chamber + G4double DSSD_SupPos_y = -fChamberH / 2. + fCoolingBlockH / 2. + fChamberThickness / 2.; + // position wrt BackPlate/VacChamber + G4double DSSD_SupPos_z = fChamberL / 2. - fChamberThickness - fCoolingBlockL / 2. - fCoolingBlockZ; + // now cut a hole out for the DSSD's + G4double Hole4DSSD_W = fCoolingBlockCutOutW; + G4double Hole4DSSD_H = fCoolingBlockCutOutH; - //-------------------------------------------- - // The DSSD pre-amp boards - //-------------------------------------------- - //dimensions of the main support board - G4double PA_SupportBoard_T = 3.0*mm; - G4double PA_SupportBoard_W = 67.0*mm; - G4double PA_SupportBoard_L = fCoolingBlockL; //along z + // from the above can determine the centre of the DSSD wrt centre of Cooling block + fCoolingBlockCutOut_PosY = + fCoolingBlockH / 2. - fCoolingBlockT - fCoolingBlockCutOutH / 2.; // save this frequently used position + G4cout << "fCoolingBlockCutOut_PosY " << fCoolingBlockCutOut_PosY << " cf " << fCoolingBlockDSSDCentre << G4endl; - //dimensions of the individual pcb boards - G4double PA_Board_T = 0.8*mm; - G4double PA_Board_W = 14.0*mm; - G4double PA_Board_L = 33.0*mm; - - //fudge a capacitor in there.... - G4double PA_Capacitor_T = 2.0*mm; - G4double PA_Capacitor_R = 4.0*mm; + G4Box* hole1 = new G4Box("Hole #1", Hole4DSSD_W / 2., Hole4DSSD_H / 2., fCoolingBlockL / 2.); - //and the connectors... - G4double connectorW = 26.0*mm; - G4double connectorL = 14.0*mm; - G4double connectorT = 5.0*mm; + G4double dy = fCoolingBlockH / 2. - fCoolingBlockT - Hole4DSSD_H / 2.; + G4double dx = 0.0 * mm; + G4double dz = 0.0 * mm; + G4ThreeVector hole1trans(dx, dy, dz); - - //delta-pos for each pre-amp - const G4int nPA = 20; //per support board - G4double PA_dPos = PA_SupportBoard_W / ((G4double) (nPA+1)); + G4SubtractionSolid* solid_CB_Temp1 = new G4SubtractionSolid("fCoolingBlockTemp1", OuterBox, hole1, 0, hole1trans); - //positions wrt chamaber vacuum : put it at downstream side of the support block - G4double PA_SupportBoard_z = DSSD_SupPos_z + fCoolingBlockL/2. - PA_SupportBoard_L/2.; + // now cut a hole out for preamps + G4Box* holePreAmp = new G4Box("Hole PreAmp", 34.5 / 2. * mm, 22. / 2. * mm, fCoolingBlockL / 2.); + dx = -fCoolingBlockW / 2. + fCoolingBlockT + 34.5 / 2. * mm; + dy = fCoolingBlockH / 2. - fCoolingBlockT - Hole4DSSD_H - fCoolingBlockT - 22. / 2. * mm; + G4ThreeVector holePreAmpTrans1(dx, dy, dz); + dx += (34.5 * mm + fCoolingBlockT); + G4ThreeVector holePreAmpTrans2(dx, dy, dz); + dx += (34.5 * mm + 14.7 * mm); + G4ThreeVector holePreAmpTrans3(dx, dy, dz); + dx += (34.5 * mm + fCoolingBlockT); + G4ThreeVector holePreAmpTrans4(dx, dy, dz); - G4Box* solidPA_SupportBoard = new G4Box("dssd-pa-support-pcb", PA_SupportBoard_T/2., PA_SupportBoard_W/2., PA_SupportBoard_L/2.); - G4Box* solidPA_Board = new G4Box("dssd-pa-pcb", PA_Board_W/2., PA_Board_T/2., PA_Board_L/2.); - G4Tubs* solidPA_Capacitor = new G4Tubs("dssd-pa-cap", 0.0*mm, PA_Capacitor_R, PA_Capacitor_T/2., 0.*degree, 360.*degree); - G4Box* solidDSSD_Connector = new G4Box("dssd-connector", connectorW/2., connectorT/2., connectorL/2.); + G4SubtractionSolid* solid_CB_Temp2 = + new G4SubtractionSolid("fCoolingBlockTemp2", solid_CB_Temp1, holePreAmp, 0, holePreAmpTrans1); + G4SubtractionSolid* solid_CB_Temp3 = + new G4SubtractionSolid("fCoolingBlockTemp3", solid_CB_Temp2, holePreAmp, 0, holePreAmpTrans2); - G4VisAttributes* visAtt_PA_SupportBoard = new G4VisAttributes(G4Colour(0.2,0.9,0.2) ); - visAtt_PA_SupportBoard->SetVisibility(true); - // visAtt_PA_SupportBoard->SetVisibility(false); - visAtt_PA_SupportBoard->SetForceWireframe(true); + G4SubtractionSolid* solid_CB_Temp4 = + new G4SubtractionSolid("fCoolingBlockTemp4", solid_CB_Temp3, holePreAmp, 0, holePreAmpTrans3); - G4VisAttributes* visAtt_PA_Board = new G4VisAttributes(G4Colour(0.1,0.9,0.1) ); - visAtt_PA_Board->SetVisibility(true); - // visAtt_PA_Board->SetVisibility(false); - visAtt_PA_Board->SetForceWireframe(true); + G4SubtractionSolid* solid_CB_Temp5 = + new G4SubtractionSolid("fCoolingBlockTemp5", solid_CB_Temp4, holePreAmp, 0, holePreAmpTrans4); - //visualise the capacitors - G4VisAttributes* visCapacitor = new G4VisAttributes(G4Colour(0.3,0.1,0.9) ); - visCapacitor->SetVisibility(true); - //visCapacitor->SetVisibility(false); - visCapacitor->SetForceWireframe(true); + G4LogicalVolume* logicDSSD_Sup = new G4LogicalVolume(solid_CB_Temp5, supportMaterial, "Cylinder-Box", 0, 0, 0); + // vacuumMaterial, "Cylinder-Box", 0, 0, 0); + logicDSSD_Sup->SetVisAttributes(visAttCoolingBlock); - G4LogicalVolume* logicPA_SupportBoard = new G4LogicalVolume(solidPA_SupportBoard, // it's solid - boardMaterial, // it's material - "dssd-pa-support-pcb", // it's name - 0,0,0); // field manager etc + PVPBuffer = new G4PVPlacement(0, // rotation + G4ThreeVector(0.0 * cm, DSSD_SupPos_y, DSSD_SupPos_z), + logicDSSD_Sup, // its logical volume + "fCoolingBlock", // its name + logicChamVac, // its mother + false, // no boolean operat + 1, // copy number + true); // overlap check + //------------------------------------------------------------------------------------------- + // DSSD detector Epoxy board....for some reason 2 cut outs are not working => make 2 PCB wafers + G4double DSSD_BrdW = 106.0 * mm * 2.; // Put the 2 boards in one plate + G4double DSSD_BrdH = 157.0 * mm; // SupportH; + G4double DSSD_BrdL = fDSSD_BoardL; // Thickness + + // recess to house DSSD's + G4double siImpBrdCutOutL = fDSSD_BoardL / 2.; + // making 2 boards => + G4double DSSD_BrdL1 = DSSD_BrdL - siImpBrdCutOutL; + G4double DSSD_BrdL2 = siImpBrdCutOutL; + + G4double CutOut_dY = 44.0 * mm; // distance from top of PCB to top of the first cut-out in the PCB + G4double CutOut1_H = 43.5 * mm; // vertical dimension of the cut-out to half thickness + G4double CutOut2_H = 41.0 * mm; // vertical dimension of total-thickness cut-ou ie a mounting lip of 1.25 mm + + G4double CutOut1_W = 63.5 * mm; // fDSSD_H-2.0*boardLipDSSD; + G4double CutOut2_W = 61.0 * mm; // fDSSD_H; + + G4double dssdLip = (CutOut1_W - CutOut2_W) / 2.; + G4double central_bar = 1.25 * mm; // each side + + G4double DSSD_PCB_Pos_y = -fVacuumH / 2. - DSSD_BrdH / 2.; // puts top of circuit board at bottom of chamber + DSSD_PCB_Pos_y += (fCoolingBlockDSSDCentre + CutOut_dY + CutOut1_H / 2.); + + G4double gapBetweenDSSD = 3.0 * mm; // Gap between the two DSSD's + + // gapBetweenDSSD = 0.01*mm; + + // position wrt centre of vacuum in chamber + G4double DSSD_BrdPos_z = fChamberL / 2 - fChamberThickness - fCoolingBlockZ + DSSD_BrdL1 / 2 + DSSD_BrdL2; + + G4Box* solidDSSD_Board1_tmp1 = new G4Box("siImpBrd1_tmp", DSSD_BrdW / 2., DSSD_BrdH / 2., DSSD_BrdL1 / 2.); + + G4Box* cutOut1a = new G4Box("Box R #1a", CutOut1_W / 2., CutOut1_H / 2., DSSD_BrdL1 / 2.); + G4ThreeVector cutOut1aTrans(CutOut1_W / 2., DSSD_BrdH / 2. - CutOut1_H / 2. - CutOut_dY, 0.0 * mm); + + G4Box* cutOut1b = new G4Box("Box R #1b", CutOut1_W / 2., CutOut1_H / 2., DSSD_BrdL1 / 2.); + G4ThreeVector cutOut1bTrans(-CutOut1_W / 2., DSSD_BrdH / 2. - CutOut1_H / 2. - CutOut_dY, 0.0 * mm); + + G4SubtractionSolid* solidDSSD_Board1_a = + new G4SubtractionSolid("siImpBrd1_a", solidDSSD_Board1_tmp1, cutOut1a, 0, cutOut1aTrans); + + G4SubtractionSolid* solidDSSD_Board1 = + new G4SubtractionSolid("siImpBrd1", solidDSSD_Board1_a, cutOut1b, 0, cutOut1bTrans); + + G4LogicalVolume* logicDSSD_Board1 = new G4LogicalVolume(solidDSSD_Board1, // it's solid : with cut-out + boardMaterial, // it's material + // vacuumMaterial, + "DSSD_Brd1", // it's name + 0, 0, 0); // field manager, sensitive det, user limits + + PVPBuffer = new G4PVPlacement(0, // rotation + G4ThreeVector(0.0 * mm, DSSD_PCB_Pos_y, DSSD_BrdPos_z), + logicDSSD_Board1, // its logical volume + "DSSD_Brd1", // its name + logicChamVac, // its mother + false, // no boolean operat + 0, // copy number + true); // overlap check + + DSSD_BrdPos_z -= DSSD_BrdL1 / 2; + DSSD_BrdPos_z -= DSSD_BrdL2 / 2; + + G4Box* solidDSSD_Board2_tmp1 = new G4Box("siImpBrd2_tmp", DSSD_BrdW / 2., DSSD_BrdH / 2., DSSD_BrdL2 / 2.); + + G4Box* cutOut2a = new G4Box("Box R #2a", CutOut2_W / 2., CutOut2_H / 2., DSSD_BrdL2 / 2.); + G4ThreeVector cutOut2aTrans(CutOut2_W / 2. + central_bar, DSSD_BrdH / 2. - CutOut2_H / 2. - CutOut_dY - dssdLip, + 0.0 * mm); + + G4Box* cutOut2b = new G4Box("Box R #2b", CutOut2_W / 2., CutOut2_H / 2., DSSD_BrdL2 / 2.); + G4ThreeVector cutOut2bTrans(-CutOut2_W / 2. - central_bar, DSSD_BrdH / 2. - CutOut2_H / 2. - CutOut_dY - dssdLip, + 0.0 * mm); + + G4SubtractionSolid* solidDSSD_Board2_a = + new G4SubtractionSolid("siImpBrd2_a", solidDSSD_Board2_tmp1, cutOut2a, 0, cutOut2aTrans); + + G4SubtractionSolid* solidDSSD_Board2 = + new G4SubtractionSolid("siImpBrd2", solidDSSD_Board2_a, cutOut2b, 0, cutOut2bTrans); + + G4LogicalVolume* logicDSSD_Board2 = new G4LogicalVolume(solidDSSD_Board2, // it's solid : with cut-out + boardMaterial, // it's material + // vacuumMaterial, + "DSSD_Brd2", // it's name + 0, 0, 0); // field manager, sensitive det, user limits + + PVPBuffer = new G4PVPlacement(0, // rotation + G4ThreeVector(0.0 * mm, DSSD_PCB_Pos_y, DSSD_BrdPos_z), + logicDSSD_Board2, // its logical volume + "DSSD_Brd2", // its name + logicChamVac, // its mother + false, // no boolean operat + 0, // copy number + true); // overlap check + + //-------------------------------------------- + // Implantation detectors + // first make two Si boards -> gauard ring... + G4VisAttributes* visAttDSSD_1 = new G4VisAttributes(G4Colour(0.6, 0.4, 0.4)); + visAttDSSD_1->SetVisibility(true); + // visAttDSSD_1->SetVisibility(false); + visAttDSSD_1->SetForceWireframe(true); + + G4double DSSD_z = DSSD_BrdPos_z - DSSD_BrdL / 2. - 3. * fDSSD_T / 2. + (DSSD_BrdL - siImpBrdCutOutL); + DSSD_z = fChamberL / 2 - fChamberThickness - fCoolingBlockZ + DSSD_BrdL2 - fDSSD_T / 2.; + G4cout << "DSSD Z wrt ChamberVac " << DSSD_z << G4endl; + + G4double totalDSSD_H = fDSSD_H + 2. * fDSSD_Guard; + G4double totalDSSD_W = fDSSD_W + 2. * fDSSD_Guard; + G4Box* solidSi1 = new G4Box("Si1", totalDSSD_W / 2., totalDSSD_H / 2., fDSSD_T / 2.); // Si: 62x42 + G4LogicalVolume* logicSi1 = new G4LogicalVolume(solidSi1, // it's solid + eDetMat, // it's material //vacuumMaterial, + "dssd1", // it's name + 0, 0, 0); // field manager, sensitive det, user limits + + logicSi1->SetVisAttributes(visAttDSSD_1); + + PVPBuffer = new G4PVPlacement(0, // rotation + G4ThreeVector(totalDSSD_W / 2. + 0.75 * mm, fCentreOfDSSD_Y, DSSD_z), + // G4ThreeVector(0.0*mm,fCentreOfDSSD_Y,DSSD_z), + logicSi1, // its logical volume + "dssd1", // its name + logicChamVac, // its mother + false, // no boolean operat + 1); //, //copy number + + G4LogicalVolume* logicSi2 = new G4LogicalVolume(solidSi1, // it's solid + eDetMat, // it's material //vacuumMaterial, + "dssd2", // it's name + 0, 0, 0); // field manager, sensitive det, user limits + + logicSi2->SetVisAttributes(visAttDSSD_1); + + PVPBuffer = new G4PVPlacement(0, // rotation + G4ThreeVector(-totalDSSD_W / 2. - 0.75 * mm, fCentreOfDSSD_Y, DSSD_z), + // G4ThreeVector(0.0*mm,fCentreOfDSSD_Y,DSSD_z), + logicSi2, // its logical volume + "dssd2", // its name + logicChamVac, // its mother + false, // no boolean operat + 2); //, //copy number + + // The ChamberVac is located wrt centre of Chamber => z0 = -fChamberL/2. + fDSSD_PosZ = DSSD_z - fChamberL / 2. - fDSSD_T / 2.; + G4cout << "Upstream DSSD face @ Z = " << fDSSD_PosZ << G4endl; + + // common dssd "pixel" shape + G4VisAttributes* visAttDSSD = new G4VisAttributes(G4Colour(0.8, 0.3, 0.3)); + visAttDSSD->SetVisibility(true); + // visAttDSSD->SetVisibility(false); + visAttDSSD->SetForceWireframe(true); + + G4double fDSSD_Pixel_Lx = fDSSD_W / (1.0 * nStripsX); + G4double fDSSD_Pixel_Ly = fDSSD_H / (1.0 * nStripsY); + + G4Box* solidDSSD = new G4Box("dssd", fDSSD_Pixel_Lx / 2., fDSSD_Pixel_Ly / 2., fDSSD_T / 2.); + + // starting y-position for lowest row + G4double thisy = -nStripsY / 2. * fDSSD_Pixel_Ly + fDSSD_Pixel_Ly / 2. + fCoolingBlockCutOut_PosY; + thisy = -nStripsY / 2. * fDSSD_Pixel_Ly + fDSSD_Pixel_Ly / 2. + fCentreOfDSSD_Y; + + G4double thisy2 = -fDSSD_H / 2. + fDSSD_Pixel_Ly / 2.; + + for (G4int iy = 0; iy < nStripsY; iy++) { + // starting x-position + G4double thisx = -nStripsX * fDSSD_Pixel_Lx + fDSSD_Pixel_Lx / 2. - gapBetweenDSSD / 2.; + G4double thisx2 = -fDSSD_W / 2. + fDSSD_Pixel_Lx / 2.; + for (G4int ix = 0; ix < nStripsX; ix++) { + + // DSSD_A + logicDSSD_A[iy][ix] = new G4LogicalVolume(solidDSSD, // it's solid + eDetMat, // it's material + // vacuumMaterial, + "dssd-pixel", // it's name + 0, 0, 0); // field manager, sensitive det, user limits + + PVPBuffer = new G4PVPlacement(0, // rotation + // G4ThreeVector(thisx,thisy,DSSD_z), + G4ThreeVector(thisx2, thisy2, 0.0 * mm), + logicDSSD_A[iy][ix], // its logical volume + "DSSD_A", // its name + logicSi2, // its mother + false, // no boolean operat + iy * 100 + ix); //, //copy number + + // DSSD_B + logicDSSD_B[iy][ix] = new G4LogicalVolume(solidDSSD, // it's solid + eDetMat, // it's material + // vacuumMaterial, + "dssd-pixel", // it's name + 0, 0, 0); // field manager, sensitive det, user limits + + PVPBuffer = new G4PVPlacement(0, // rotation + // G4ThreeVector(thisx+fDSSD_W+gapBetweenDSSD,thisy,DSSD_z), + G4ThreeVector(thisx2, thisy2, 0.0 * mm), + logicDSSD_B[iy][ix], // its logical volume + "DSSD_B", // its name + logicSi1, // its mother + false, // no boolean operat + iy * 100 + ix); //, //copy number + + // visu + logicDSSD_A[iy][ix]->SetVisAttributes(visAttDSSD); + logicDSSD_B[iy][ix]->SetVisAttributes(visAttDSSD); + + // move along please + // thisN++; + thisx += fDSSD_Pixel_Lx; + thisx2 += fDSSD_Pixel_Lx; + } + thisy += fDSSD_Pixel_Ly; + thisy2 += fDSSD_Pixel_Ly; + } - G4LogicalVolume* logicDSSD_Connector = new G4LogicalVolume(solidDSSD_Connector, // it's solid - boardMaterial, // it's material - "dssd-connector", // it's name - 0,0,0); // field manager etc + //-------------------------------------------- + // The PINS + //-------------------------------------------- + G4double PinL = 30.0 * mm; // PinLxPinL + G4double PinT = 1.0 * mm; // 0.5 * mm; //Thickness + G4double PinGuard = 1.0 * mm; // Guardrail + G4double PinGap = 1.0 * mm; // between PINS + G4double PinToEdge = 3.0 * mm; // gap from the end + G4double PinEpoxyT = 1.6 * mm; // thickness of pcb board + // G4double PinSupportLip = PinT+PinEpoxyT; //thickness of pcb board + + // horizontal-side dimensions [approxiamted as a single board] + G4double PinBoard_H_W = PinL * 5.; + G4double PinBoard_H_H = PinEpoxyT; + G4double PinBoard_H_L = PinToEdge + PinL + PinGap + PinL + 13.0 * mm; + + // vertical-side dimensions [approximated as a single board] + G4double PinBoard_V_H = PinL * 2.; + G4double PinBoard_V_W = PinEpoxyT; + G4double PinBoard_V_L = PinToEdge + PinL + PinGap + PinL + 13.0 * mm; + + // the PCB board for the PINS sits on top of another board [oh yeah transparency !] + G4double PinBoardSupport_T = 4.75 * mm; // nominally 4.75*mm; + + // positions wrt cahmaber vacuum : put it at downstream side of the support block + G4double PinBoard_z = DSSD_SupPos_z + fCoolingBlockL / 2 - PinBoard_H_L / 2.; + PinBoard_z -= 1.5 * mm; // move back due to support + + G4double PinBoard_H_x = 0.0 * mm; + G4double PinBoard_H_dy = Hole4DSSD_H / 2. - PinEpoxyT / 2. - PinBoardSupport_T; + G4double PinBoard_V_x = Hole4DSSD_W / 2. - PinEpoxyT / 2. - PinBoardSupport_T; + fDSSD_PosY = fCentreOfDSSD_Y; + G4double PinBoard_V_y = fDSSD_PosY; + + // The epoxy board for the pins + G4VisAttributes* visAttPIN_Board = new G4VisAttributes(G4Colour(0.3, 0.9, 0.3)); + visAttPIN_Board->SetVisibility(true); + // visAttPIN_Board->SetVisibility(false); + visAttPIN_Board->SetForceWireframe(true); + + // Pin PCB/Epoxy boards + G4Box* solidPinBoard_H = new G4Box("pin-pcb", PinBoard_H_W / 2., PinBoard_H_H / 2., PinBoard_H_L / 2.); + G4Box* solidPinBoard_V = new G4Box("pin-pcb", PinBoard_V_W / 2., PinBoard_V_H / 2., PinBoard_V_L / 2.); + + G4LogicalVolume* logicPinBoard_H = new G4LogicalVolume(solidPinBoard_H, // it's solid + boardMaterial, // it's material + "pin-pcb", // it's name + 0, 0, 0); // field manager etc + + G4LogicalVolume* logicPinBoard_V = new G4LogicalVolume(solidPinBoard_V, // it's solid + boardMaterial, // it's material + "pin-pcb", // it's name + 0, 0, 0); // field manager etc + + logicPinBoard_H->SetVisAttributes(visAttPIN_Board); + logicPinBoard_V->SetVisAttributes(visAttPIN_Board); + + // G4PVPlacement* physiPinBoard_H[2]; + // G4PVPlacement* physiPinBoard_V[2]; + + for (G4int i = 0; i < 2; i++) { + + G4double dyPos = (2 * i - 1) * PinBoard_H_dy; + + PVPBuffer = new G4PVPlacement(0, // rotation + G4ThreeVector(PinBoard_H_x, fCentreOfDSSD_Y + dyPos, PinBoard_z), + logicPinBoard_H, // its logical volume + "PinPCB_H", // its name + logicChamVac, // its mother + false, // no boolean operat + i + 1); // copy number + + PVPBuffer = new G4PVPlacement(0, // rotation + G4ThreeVector(PinBoard_V_x * (2 * i - 1), PinBoard_V_y, PinBoard_z), + logicPinBoard_V, // its logical volume + "PinPCB_V", // its name + logicChamVac, // its mother + false, // no boolean operat + i + 1); // copy number + } + //----------------------------------------- + // Horiz Support for Pin Epoxy : the PCB board for the PINS sits on top of another board [oh yeah transparency !] + G4VisAttributes* visAttPIN_BoardSup = new G4VisAttributes(G4Colour(0.9, 0.9, 0.9)); + visAttPIN_BoardSup->SetVisibility(true); + // visAttPIN_BoardSup->SetVisibility(false); + visAttPIN_BoardSup->SetForceWireframe(true); - G4LogicalVolume* logicPA_Board = new G4LogicalVolume(solidPA_Board, // it's solid - boardMaterial, // it's material - "dssd-pa-pcb", // it's name - 0,0,0); // field manager etc - + G4double PinBoardSupport_H_W = fCoolingBlockCutOutW; + G4double PinBoardSupport_H_H = 3.75 * mm; + G4double PinBoardSupport_H_L = 80. * mm; - G4LogicalVolume* logicPA_Capacitor = new G4LogicalVolume(solidPA_Capacitor, // it's solid - boardMaterial, // it's material - "dssd-pa-cap", // it's name - 0,0,0); // field manager etc + G4Box* solidPinSupportBoard_H_temp = + new G4Box("pin-pcb-support", PinBoardSupport_H_W / 2., PinBoardSupport_H_H / 2., PinBoardSupport_H_L / 2.); - logicPA_SupportBoard->SetVisAttributes(visAtt_PA_SupportBoard); - logicDSSD_Connector->SetVisAttributes(visAtt_PA_SupportBoard); - logicPA_Board->SetVisAttributes(visAtt_PA_Board); - logicPA_Capacitor->SetVisAttributes(visCapacitor); + G4double cutOutPinBoard_H_x = 28.6 * mm; + G4Box* cutOutPinBoard_H = + new G4Box("Box Pin Board #1", cutOutPinBoard_H_x / 2., PinBoardSupport_H_H / 2., 70. * mm / 2.); + G4ThreeVector cutOutPinBoard_H_centre(0.0 * mm, 0.0 * mm, 5.0 * mm); + G4ThreeVector cutOutPinBoard_H_p1(PinL, 0.0 * mm, 5.0 * mm); + G4ThreeVector cutOutPinBoard_H_m1(-PinL, 0.0 * mm, 5.0 * mm); + G4ThreeVector cutOutPinBoard_H_p2(2 * PinL, 0.0 * mm, 5.0 * mm); + G4ThreeVector cutOutPinBoard_H_m2(-2 * PinL, 0.0 * mm, 5.0 * mm); - //G4PVPlacement* physiPA_SupportBoard[6]; - //G4PVPlacement* physiDSSD_Connector[12]; + G4SubtractionSolid* solidPinSupportBoard_H0 = new G4SubtractionSolid( + "pin-pcb-support_0", solidPinSupportBoard_H_temp, cutOutPinBoard_H, 0, cutOutPinBoard_H_centre); - G4double top_of_DSSD_Brd = DSSD_PCB_Pos_y + DSSD_BrdH/2.; - G4double gapConnector_2_DSSD_Board_V = 15.0*mm; //Gap between the top of the top connector and top of DSSD board = 15.0 mm - G4double gapConnector_2_DSSD_Board_H = 15.0*mm; //Gap between the end of the centre connector to the centre of the DSSD board = 15.0 mm - G4double gapConnector_PA_Board = 4.0*mm; + G4SubtractionSolid* solidPinSupportBoard_HA = + new G4SubtractionSolid("pin-pcb-support_a", solidPinSupportBoard_H0, cutOutPinBoard_H, 0, cutOutPinBoard_H_p1); + G4SubtractionSolid* solidPinSupportBoard_HB = + new G4SubtractionSolid("pin-pcb-support_b", solidPinSupportBoard_HA, cutOutPinBoard_H, 0, cutOutPinBoard_H_m1); - G4RotationMatrix* rmCap = new G4RotationMatrix; - rmCap->set(0,0,0); - rmCap->rotateX(90.*degree); + G4SubtractionSolid* solidPinSupportBoard_HC = + new G4SubtractionSolid("pin-pcb-support_b", solidPinSupportBoard_HB, cutOutPinBoard_H, 0, cutOutPinBoard_H_p2); - G4RotationMatrix* rot_90_Z = new G4RotationMatrix; - rot_90_Z->set(0,0,0); - rot_90_Z->rotateZ(90.*degree); - - G4RotationMatrix* rot_90_Y = new G4RotationMatrix; - rot_90_Y->set(0,0,0); - rot_90_Y->rotateY(90.*degree); - - //vertical boards.... - //G4PVPlacement* physiPA_Board[6][nPA]; - //G4PVPlacement* physiPA_Capacitor[6][nPA]; - - for(G4int i = 0; i < 4; i++) { - - G4double xPos = fCoolingBlockW/2. + PA_SupportBoard_T/2. + 3.0*mm; - G4double yPos = top_of_DSSD_Brd - PA_SupportBoard_W/2. - gapConnector_2_DSSD_Board_V + gapConnector_PA_Board; - - if(i >= 2) xPos *= -1.; - if(i%2 != 0) yPos -= (PA_SupportBoard_W + 7.0*mm); + G4SubtractionSolid* solidPinSupportBoard_H = + new G4SubtractionSolid("pin-pcb-support_b", solidPinSupportBoard_HC, cutOutPinBoard_H, 0, cutOutPinBoard_H_m2); - PVPBuffer = - new G4PVPlacement(0, //rotation - G4ThreeVector(xPos, yPos, PA_SupportBoard_z), - logicPA_SupportBoard, //its logical volume - "dssd-pa-support-pcb", //its name - logicChamVac, //its mother - false, //no boolean operat - i+1); //copy number - - - xPos = DSSD_BrdW/2. - 9.0*mm; - yPos = top_of_DSSD_Brd - gapConnector_2_DSSD_Board_V - connectorW/2.; - - switch (i) { - case 0 : - break; - case 1 : yPos -= (7.0*mm + connectorW); - break; - case 2 : yPos -= (15.0*mm + connectorW); - break; - case 3 : yPos -= (7.0*mm + connectorW); - break; - } + G4LogicalVolume* logicPinSupportBoard_H = new G4LogicalVolume(solidPinSupportBoard_H, // it's solid + m_ChamberMaterial, // it's material + "pin-pcb-support", // it's name + 0, 0, 0); // field manager etc + logicPinSupportBoard_H->SetVisAttributes(visAttPIN_BoardSup); - - PVPBuffer = - new G4PVPlacement(rot_90_Z, //rotation - G4ThreeVector(xPos, yPos, PA_SupportBoard_z+PA_SupportBoard_L/2.-connectorL/2.), - logicDSSD_Connector, //its logical volume - "dssd-pa-support-pcb", //its name - logicChamVac, //its mother - false, //no boolean operat - i+1); //copy number + G4double PinBoardSupport_Z = DSSD_SupPos_z + fCoolingBlockL / 2. - PinBoardSupport_H_L / 2. - 1.0 * mm; PVPBuffer = - new G4PVPlacement(rot_90_Z, //rotation - G4ThreeVector(-xPos, yPos, PA_SupportBoard_z+PA_SupportBoard_L/2.-connectorL/2.), - logicDSSD_Connector, //its logical volume - "dssd-pa-support-pcb", //its name - logicChamVac, //its mother - false, //no boolean operat - i+1+4); //copy number - - //place the preamp boards and capacitors - G4double PA_PosY = top_of_DSSD_Brd - gapConnector_2_DSSD_Board_V + gapConnector_PA_Board; - G4double PA_PosX = fCoolingBlockW/2.+PA_SupportBoard_T+3.0*mm+PA_Board_W/2.; - - if(i >= 2) PA_PosX *= -1.; - if(i%2 != 0) PA_PosY -= (PA_SupportBoard_W + 7.0*mm); - - for(G4int j = 0; j < nPA; j++) { - G4double thisY = PA_PosY - PA_dPos*(j+1); - PVPBuffer = - new G4PVPlacement(0, //rotation - G4ThreeVector(PA_PosX, thisY, PA_SupportBoard_z-10*mm), - logicPA_Board, //its logical volume - "dssd-pa-pcb", //its name - logicChamVac, //its mother - false, //no boolean operat - j+1); //copy number + new G4PVPlacement(0, // rotation + G4ThreeVector(PinBoard_H_x, fDSSD_PosY + fCoolingBlockCutOutH / 2. - PinBoardSupport_H_H / 2., + PinBoardSupport_Z), + logicPinSupportBoard_H, // its logical volume + "PinPCB_Support", // its name + logicChamVac, // its mother + false, // no boolean operat + 1); // copy number - PVPBuffer = - new G4PVPlacement(rmCap, //rotation - G4ThreeVector(PA_PosX, thisY, PA_SupportBoard_z+20.*mm), - logicPA_Capacitor, //its logical volume - "dssd-pa-cap", //its name - logicChamVac, //its mother - false, //no boolean operat - j+1); //copy number - - } - } - - - //horizontal... - for(G4int i = 4; i < 6; i++) { - - G4double xPos = PA_SupportBoard_W/2.+gapConnector_2_DSSD_Board_H-gapConnector_PA_Board; - G4double yPos = top_of_DSSD_Brd-13.*mm-connectorT-PA_SupportBoard_T/2.+ 1.0*mm; - - if(i == 5) xPos *= -1.; - - PVPBuffer= - new G4PVPlacement(rot_90_Z, //rotation - G4ThreeVector(xPos, yPos, PA_SupportBoard_z), - logicPA_SupportBoard, //its logical volume - "dssd-pa-support-pcb", //its name - logicChamVac, //its mother - false, //no boolean operat - i+1); //copy number - - for(G4int j = 0; j < 2; j++) { - PVPBuffer = - new G4PVPlacement(0, //rotation - G4ThreeVector(xPos+((2*j-1)*(connectorW/2.+3.5*mm)), yPos+PA_SupportBoard_T/2.+connectorT/2., PA_SupportBoard_z+PA_SupportBoard_L/2.-connectorL/2.), - logicDSSD_Connector, //its logical volume - "dssd-pa-support-pcb", //its name - logicChamVac, //its mother - false, //no boolean operat - 1+4+2*i+j); //copy number + PVPBuffer = + new G4PVPlacement(0, // rotation + G4ThreeVector(PinBoard_H_x, fDSSD_PosY - fCoolingBlockCutOutH / 2. + PinBoardSupport_H_H / 2., + PinBoardSupport_Z), + logicPinSupportBoard_H, // its logical volume + "PinPCB_Support", // its name + logicChamVac, // its mother + false, // no boolean operat + 2); // copy number + + G4double PinBoardSupport_W_W = 3.75 * mm; + G4double PinBoardSupport_W_H = fCoolingBlockCutOutH - 2. * PinBoardSupport_H_H; + G4double PinBoardSupport_W_L = 80. * mm; + + // Vertical Support Pin Epoxy + G4Box* solidPinSupportBoard_V_temp = + new G4Box("pin-pcb-support", PinBoardSupport_W_W / 2., PinBoardSupport_W_H / 2., PinBoardSupport_W_L / 2.); + + G4Box* cutOutPinBoard_V = + new G4Box("Box Pin Board #1", PinBoardSupport_W_W / 2., cutOutPinBoard_H_x / 2., 70. * mm / 2.); + G4double cutOutSpine_x = (PinL + PinGap - cutOutPinBoard_H_x) / 2.; + + G4ThreeVector cutOutPinBoard_V_p1(0.0 * mm, (cutOutSpine_x + cutOutPinBoard_H_x) / 2., 5.0 * mm); + G4ThreeVector cutOutPinBoard_V_m1(0.0 * mm, -(cutOutSpine_x + cutOutPinBoard_H_x) / 2., 5.0 * mm); + + G4SubtractionSolid* solidPinSupportBoard_V0 = new G4SubtractionSolid( + "pin-pcb-support_0", solidPinSupportBoard_V_temp, cutOutPinBoard_V, 0, cutOutPinBoard_V_p1); + + G4SubtractionSolid* solidPinSupportBoard_V = + new G4SubtractionSolid("pin-pcb-support_b", solidPinSupportBoard_V0, cutOutPinBoard_V, 0, cutOutPinBoard_V_m1); + + G4LogicalVolume* logicPinSupportBoard_V = new G4LogicalVolume(solidPinSupportBoard_V, // it's solid + m_ChamberMaterial, // it's material + "pin-pcb-support", // it's name + 0, 0, 0); // field manager etc + + logicPinSupportBoard_V->SetVisAttributes(visAttPIN_BoardSup); + + PVPBuffer = new G4PVPlacement( + 0, // rotation + G4ThreeVector(fCoolingBlockCutOutW / 2. - PinBoardSupport_W_W / 2., fDSSD_PosY, PinBoardSupport_Z), + logicPinSupportBoard_V, // its logical volume + "PinPCBSupport", // its name + logicChamVac, // its mother + false, // no boolean operat + 1); // copy number + + PVPBuffer = new G4PVPlacement( + 0, // rotation + G4ThreeVector(-fCoolingBlockCutOutW / 2. + PinBoardSupport_W_W / 2., fDSSD_PosY, PinBoardSupport_Z), + logicPinSupportBoard_V, // its logical volume + "PinPCBSupport", // its name + logicChamVac, // its mother + false, // no boolean operat + 2); // copy number + + // add the fucking ridiculous flange.... + G4double PinFlange_Z = DSSD_SupPos_z + fCoolingBlockL / 2. - 0.5 * mm; + G4Box* PinFlange_outer = + new G4Box("Box Pin Flange #1", fCoolingBlockCutOutW / 2., fCoolingBlockCutOutH / 2., + 1.0 * mm / 2.); // probably even thicker just to make sure no low E gammas are seen ! + G4Box* PinFlange_hole = new G4Box("Box Pin Flange #2", fCoolingBlockCutOutW / 2. - 4.0 * mm, + fCoolingBlockCutOutH / 2. - 4.0 * mm, 1.0 * mm / 2.); + + G4SubtractionSolid* solidPinFlange = new G4SubtractionSolid("pin-flange", PinFlange_outer, PinFlange_hole, 0, + G4ThreeVector(0. * mm, 0. * mm, 0. * mm)); + + G4LogicalVolume* logicPinFlange = new G4LogicalVolume(solidPinFlange, // it's solid + m_ChamberMaterial, // it's material + "pin-flange", // it's name + 0, 0, 0); // field manager etc + + logicPinFlange->SetVisAttributes(visAttPIN_BoardSup); + + PVPBuffer = new G4PVPlacement(0, // rotation + G4ThreeVector(0.0 * mm, fDSSD_PosY, PinFlange_Z), + logicPinFlange, // its logical volume + "PinFlange", // its name + logicChamVac, // its mother + false, // no boolean operat + 1); // copy number + + // now the PINS..... + G4VisAttributes* visAttPIN = new G4VisAttributes(G4Colour(0.9, 0.9, 0.3)); + visAttPIN->SetVisibility(true); + // visAttPIN->SetVisibility(false); + visAttPIN->SetForceWireframe(true); + + G4double Pin_z1 = PinBoard_z + PinBoard_V_L / 2. - PinToEdge - PinL / 2; + // G4double Pin_z2 = Pin_z1 - PinGap - PinL; + + // total Si area + G4Box* solidPINS_H = new G4Box("pins-passive", PinL / 2., PinT / 2., PinL / 2); // horizontal + new G4Box("pins-passive", PinT / 2., PinL / 2., PinL / 2); // vertical + + // active Si + G4Box* solidPINS_Active_H = new G4Box("pins", PinL / 2. - PinGuard, PinT / 2., PinL / 2 - PinGuard); // horizontal + new G4Box("pins", PinT / 2., PinL / 2. - PinGuard, PinL / 2 - PinGuard); // vertical + + // horizontal rows could put an index[i] = copyNo to match position in real array !! + for (G4int nH = 0; nH < 2; nH++) { // up/down + G4double posY = fDSSD_PosY + (2 * nH - 1) * (PinBoard_H_dy - PinBoard_H_H / 2. - PinT / 2.); + + for (G4int i = 1; i <= 5; i++) { // across in x + G4double posX = -PinBoard_H_W / 2. + PinL / 2. + (i - 1) * PinL; + + for (G4int r = 1; r <= 2; r++) { // 2 rows (in z) + G4double posZ = Pin_z1 - (r % 2) * (PinGap + PinL); + G4int copyNo = nH * 10 + 2 * (i - 1) + r; + G4cout << "Checking PIN copyNo " << copyNo << G4endl; + + logicPINS[copyNo - 1] = new G4LogicalVolume(solidPINS_H, // it's solid + eDetMat, // it's material + "pin-pass-h", // it's name + 0, 0, 0); // field manager etc + + logicPINS[copyNo - 1]->SetVisAttributes(visAttPIN); + + PVPBuffer = new G4PVPlacement(0, // rotation + G4ThreeVector(posX, posY, posZ), + logicPINS[copyNo - 1], // its logical volume + "PinPass", // its name + logicChamVac, // its mother + false, // no boolean operat + copyNo, // copy number + true); // check for overlaps + + logicPINS_Active[copyNo - 1] = new G4LogicalVolume(solidPINS_Active_H, // it's solid + eDetMat, // it's material + "pin-h", // it's name + 0, 0, 0); // field manager etc + + logicPINS_Active[copyNo - 1]->SetVisAttributes(visAttPIN); + + PVPBuffer = new G4PVPlacement(0, // rotation + G4ThreeVector(0. * mm, 0. * mm, 0. * mm), + logicPINS_Active[copyNo - 1], // its logical volume + "Pin", // its name + logicPINS[copyNo - 1], // its mother + false, // no boolean operat + copyNo); // copy number + } + } } - - //place the preamp boards and capacitors - G4double PA_PosY = yPos + PA_Board_W/2. + PA_SupportBoard_T/2.; - G4double PA_PosX = xPos + PA_SupportBoard_W/2.; - - - //if(i >= 2) PA_PosX *= -1.; - //if(i%2 != 0) PA_PosY -= (PA_SupportBoard_W + 7.0*mm); - - for(G4int j = 0; j < nPA; j++) { - G4double thisX = PA_PosX - PA_dPos*(j+1); + + //-------------------------------------------- + // The DSSD pre-amp boards + //-------------------------------------------- + // dimensions of the main support board + G4double PA_SupportBoard_T = 3.0 * mm; + G4double PA_SupportBoard_W = 67.0 * mm; + G4double PA_SupportBoard_L = fCoolingBlockL; // along z + + // dimensions of the individual pcb boards + G4double PA_Board_T = 0.8 * mm; + G4double PA_Board_W = 14.0 * mm; + G4double PA_Board_L = 33.0 * mm; + + // fudge a capacitor in there.... + G4double PA_Capacitor_T = 2.0 * mm; + G4double PA_Capacitor_R = 4.0 * mm; + + // and the connectors... + G4double connectorW = 26.0 * mm; + G4double connectorL = 14.0 * mm; + G4double connectorT = 5.0 * mm; + + // delta-pos for each pre-amp + const G4int nPA = 20; // per support board + G4double PA_dPos = PA_SupportBoard_W / ((G4double)(nPA + 1)); + + // positions wrt chamaber vacuum : put it at downstream side of the support block + G4double PA_SupportBoard_z = DSSD_SupPos_z + fCoolingBlockL / 2. - PA_SupportBoard_L / 2.; + + G4Box* solidPA_SupportBoard = + new G4Box("dssd-pa-support-pcb", PA_SupportBoard_T / 2., PA_SupportBoard_W / 2., PA_SupportBoard_L / 2.); + G4Box* solidPA_Board = new G4Box("dssd-pa-pcb", PA_Board_W / 2., PA_Board_T / 2., PA_Board_L / 2.); + G4Tubs* solidPA_Capacitor = + new G4Tubs("dssd-pa-cap", 0.0 * mm, PA_Capacitor_R, PA_Capacitor_T / 2., 0. * degree, 360. * degree); + G4Box* solidDSSD_Connector = new G4Box("dssd-connector", connectorW / 2., connectorT / 2., connectorL / 2.); + + G4VisAttributes* visAtt_PA_SupportBoard = new G4VisAttributes(G4Colour(0.2, 0.9, 0.2)); + visAtt_PA_SupportBoard->SetVisibility(true); + // visAtt_PA_SupportBoard->SetVisibility(false); + visAtt_PA_SupportBoard->SetForceWireframe(true); + + G4VisAttributes* visAtt_PA_Board = new G4VisAttributes(G4Colour(0.1, 0.9, 0.1)); + visAtt_PA_Board->SetVisibility(true); + // visAtt_PA_Board->SetVisibility(false); + visAtt_PA_Board->SetForceWireframe(true); + + // visualise the capacitors + G4VisAttributes* visCapacitor = new G4VisAttributes(G4Colour(0.3, 0.1, 0.9)); + visCapacitor->SetVisibility(true); + // visCapacitor->SetVisibility(false); + visCapacitor->SetForceWireframe(true); + + G4LogicalVolume* logicPA_SupportBoard = new G4LogicalVolume(solidPA_SupportBoard, // it's solid + boardMaterial, // it's material + "dssd-pa-support-pcb", // it's name + 0, 0, 0); // field manager etc + + G4LogicalVolume* logicDSSD_Connector = new G4LogicalVolume(solidDSSD_Connector, // it's solid + boardMaterial, // it's material + "dssd-connector", // it's name + 0, 0, 0); // field manager etc + + G4LogicalVolume* logicPA_Board = new G4LogicalVolume(solidPA_Board, // it's solid + boardMaterial, // it's material + "dssd-pa-pcb", // it's name + 0, 0, 0); // field manager etc + + G4LogicalVolume* logicPA_Capacitor = new G4LogicalVolume(solidPA_Capacitor, // it's solid + boardMaterial, // it's material + "dssd-pa-cap", // it's name + 0, 0, 0); // field manager etc + + logicPA_SupportBoard->SetVisAttributes(visAtt_PA_SupportBoard); + logicDSSD_Connector->SetVisAttributes(visAtt_PA_SupportBoard); + logicPA_Board->SetVisAttributes(visAtt_PA_Board); + logicPA_Capacitor->SetVisAttributes(visCapacitor); + + // G4PVPlacement* physiPA_SupportBoard[6]; + // G4PVPlacement* physiDSSD_Connector[12]; + + G4double top_of_DSSD_Brd = DSSD_PCB_Pos_y + DSSD_BrdH / 2.; + G4double gapConnector_2_DSSD_Board_V = + 15.0 * mm; // Gap between the top of the top connector and top of DSSD board = 15.0 mm + G4double gapConnector_2_DSSD_Board_H = + 15.0 * mm; // Gap between the end of the centre connector to the centre of the DSSD board = 15.0 mm + G4double gapConnector_PA_Board = 4.0 * mm; + + G4RotationMatrix* rmCap = new G4RotationMatrix; + rmCap->set(0, 0, 0); + rmCap->rotateX(90. * degree); + + G4RotationMatrix* rot_90_Z = new G4RotationMatrix; + rot_90_Z->set(0, 0, 0); + rot_90_Z->rotateZ(90. * degree); + + G4RotationMatrix* rot_90_Y = new G4RotationMatrix; + rot_90_Y->set(0, 0, 0); + rot_90_Y->rotateY(90. * degree); + + // vertical boards.... + // G4PVPlacement* physiPA_Board[6][nPA]; + // G4PVPlacement* physiPA_Capacitor[6][nPA]; + + for (G4int i = 0; i < 4; i++) { + + G4double xPos = fCoolingBlockW / 2. + PA_SupportBoard_T / 2. + 3.0 * mm; + G4double yPos = top_of_DSSD_Brd - PA_SupportBoard_W / 2. - gapConnector_2_DSSD_Board_V + gapConnector_PA_Board; + + if (i >= 2) + xPos *= -1.; + if (i % 2 != 0) + yPos -= (PA_SupportBoard_W + 7.0 * mm); + + PVPBuffer = new G4PVPlacement(0, // rotation + G4ThreeVector(xPos, yPos, PA_SupportBoard_z), + logicPA_SupportBoard, // its logical volume + "dssd-pa-support-pcb", // its name + logicChamVac, // its mother + false, // no boolean operat + i + 1); // copy number + + xPos = DSSD_BrdW / 2. - 9.0 * mm; + yPos = top_of_DSSD_Brd - gapConnector_2_DSSD_Board_V - connectorW / 2.; + + switch (i) { + case 0: + break; + case 1: + yPos -= (7.0 * mm + connectorW); + break; + case 2: + yPos -= (15.0 * mm + connectorW); + break; + case 3: + yPos -= (7.0 * mm + connectorW); + break; + } + PVPBuffer = - new G4PVPlacement(rot_90_Z, //rotation - G4ThreeVector(thisX, PA_PosY, PA_SupportBoard_z-10*mm), - logicPA_Board, //its logical volume - "dssd-pa-pcb", //its name - logicChamVac, //its mother - false, //no boolean operat - j+1); //copy number - + new G4PVPlacement(rot_90_Z, // rotation + G4ThreeVector(xPos, yPos, PA_SupportBoard_z + PA_SupportBoard_L / 2. - connectorL / 2.), + logicDSSD_Connector, // its logical volume + "dssd-pa-support-pcb", // its name + logicChamVac, // its mother + false, // no boolean operat + i + 1); // copy number + PVPBuffer = - new G4PVPlacement(rot_90_Y, //rotation - G4ThreeVector(thisX, PA_PosY, PA_SupportBoard_z+20.*mm), - logicPA_Capacitor, //its logical volume - "dssd-pa-cap", //its name - logicChamVac, //its mother - false, //no boolean operat - j+1); //copy number - + new G4PVPlacement(rot_90_Z, // rotation + G4ThreeVector(-xPos, yPos, PA_SupportBoard_z + PA_SupportBoard_L / 2. - connectorL / 2.), + logicDSSD_Connector, // its logical volume + "dssd-pa-support-pcb", // its name + logicChamVac, // its mother + false, // no boolean operat + i + 1 + 4); // copy number + + // place the preamp boards and capacitors + G4double PA_PosY = top_of_DSSD_Brd - gapConnector_2_DSSD_Board_V + gapConnector_PA_Board; + G4double PA_PosX = fCoolingBlockW / 2. + PA_SupportBoard_T + 3.0 * mm + PA_Board_W / 2.; + + if (i >= 2) + PA_PosX *= -1.; + if (i % 2 != 0) + PA_PosY -= (PA_SupportBoard_W + 7.0 * mm); + + for (G4int j = 0; j < nPA; j++) { + G4double thisY = PA_PosY - PA_dPos * (j + 1); + PVPBuffer = new G4PVPlacement(0, // rotation + G4ThreeVector(PA_PosX, thisY, PA_SupportBoard_z - 10 * mm), + logicPA_Board, // its logical volume + "dssd-pa-pcb", // its name + logicChamVac, // its mother + false, // no boolean operat + j + 1); // copy number + + PVPBuffer = new G4PVPlacement(rmCap, // rotation + G4ThreeVector(PA_PosX, thisY, PA_SupportBoard_z + 20. * mm), + logicPA_Capacitor, // its logical volume + "dssd-pa-cap", // its name + logicChamVac, // its mother + false, // no boolean operat + j + 1); // copy number + } } - } - - //================================================ - G4cout << "Placing the clovers......." << G4endl; + // horizontal... + for (G4int i = 4; i < 6; i++) { + + G4double xPos = PA_SupportBoard_W / 2. + gapConnector_2_DSSD_Board_H - gapConnector_PA_Board; + G4double yPos = top_of_DSSD_Brd - 13. * mm - connectorT - PA_SupportBoard_T / 2. + 1.0 * mm; + + if (i == 5) + xPos *= -1.; + + PVPBuffer = new G4PVPlacement(rot_90_Z, // rotation + G4ThreeVector(xPos, yPos, PA_SupportBoard_z), + logicPA_SupportBoard, // its logical volume + "dssd-pa-support-pcb", // its name + logicChamVac, // its mother + false, // no boolean operat + i + 1); // copy number + + for (G4int j = 0; j < 2; j++) { + PVPBuffer = new G4PVPlacement(0, // rotation + G4ThreeVector(xPos + ((2 * j - 1) * (connectorW / 2. + 3.5 * mm)), + yPos + PA_SupportBoard_T / 2. + connectorT / 2., + PA_SupportBoard_z + PA_SupportBoard_L / 2. - connectorL / 2.), + logicDSSD_Connector, // its logical volume + "dssd-pa-support-pcb", // its name + logicChamVac, // its mother + false, // no boolean operat + 1 + 4 + 2 * i + j); // copy number + } - //by default place 2 PhaseII clovers on either side of the chamber + // place the preamp boards and capacitors + G4double PA_PosY = yPos + PA_Board_W / 2. + PA_SupportBoard_T / 2.; + G4double PA_PosX = xPos + PA_SupportBoard_W / 2.; + + // if(i >= 2) PA_PosX *= -1.; + // if(i%2 != 0) PA_PosY -= (PA_SupportBoard_W + 7.0*mm); + + for (G4int j = 0; j < nPA; j++) { + G4double thisX = PA_PosX - PA_dPos * (j + 1); + PVPBuffer = new G4PVPlacement(rot_90_Z, // rotation + G4ThreeVector(thisX, PA_PosY, PA_SupportBoard_z - 10 * mm), + logicPA_Board, // its logical volume + "dssd-pa-pcb", // its name + logicChamVac, // its mother + false, // no boolean operat + j + 1); // copy number + + PVPBuffer = new G4PVPlacement(rot_90_Y, // rotation + G4ThreeVector(thisX, PA_PosY, PA_SupportBoard_z + 20. * mm), + logicPA_Capacitor, // its logical volume + "dssd-pa-cap", // its name + logicChamVac, // its mother + false, // no boolean operat + j + 1); // copy number + } + } - // uncomment this to put clovers on the sides !! - //Place_PhaseIIs_Left_and_Right(world); //usual + //================================================ + G4cout << "Placing the clovers......." << G4endl; - //Place_GREAT_On_the_Top(world); //usual // Now you can use GRTClov detector instead + // by default place 2 PhaseII clovers on either side of the chamber - //Place_GREAT_Left_and_Right(); //compare - //Place_PhaseII_LookingUpstream(); //usual + // uncomment this to put clovers on the sides !! + // Place_PhaseIIs_Left_and_Right(world); //usual - G4cout << ".....placed" << G4endl; - + // Place_GREAT_On_the_Top(world); //usual // Now you can use GRTClov detector instead + // Place_GREAT_Left_and_Right(); //compare + // Place_PhaseII_LookingUpstream(); //usual - } + G4cout << ".....placed" << G4endl; + } } // Add Detector branch to the EventTree. // Called After DetecorConstruction::AddDetector Method -void Chamber::InitializeRootOutput() -{} +void Chamber::InitializeRootOutput() {} // Read sensitive part and fill the Root tree. // Called at in the EventAction::EndOfEventAction -void Chamber::ReadSensitive(const G4Event*) -{} - - +void Chamber::ReadSensitive(const G4Event*) {} //################################################################################################################################################# - - //------------------------------------------------------------------ // Should add a ResetNumberOfCloversHere //------------------------------------------------------------------ @@ -2318,179 +2230,170 @@ void Chamber::ReadSensitive(const G4Event*) // Should add a delta-Z so I can check effect of sliding the detectors up and down //------------------------------------------------------------------ -// Clover numbering scheme : +// Clover numbering scheme : // Left = 0 => Crystals 0, 1, 2, 3 // Right = 4 => Crystals 4, 5, 6, 7 // Top = 8 => Crystals 8, 9,10,11 // Upstream = 12 => Crystals 12,13,14,15 //------------------------------------------------------------------ //------------------------------------------------------------------ -void Chamber::Place_PhaseIIs_Left_and_Right(G4LogicalVolume* world) -{ +void Chamber::Place_PhaseIIs_Left_and_Right(G4LogicalVolume* world) { //================================================================================= - //Do not know why, but the positioning seems to be with respect to the Taper-part : - //setting the z-position as endCapTaperL/2 puts the front face at z = 0 mm + // Do not know why, but the positioning seems to be with respect to the Taper-part : + // setting the z-position as endCapTaperL/2 puts the front face at z = 0 mm //================================================================================= G4cout << "\t placing two Phase-II's" << G4endl; - G4double endCap_PosX; + G4double endCap_PosX; G4double vacuum_PosZ; G4double geLeaf_PosZ; - //position is with respect to centre of tapered part (UnionSolid) - endCap_PosX = fChamberW/2. + fEndCapTaperL_PhaseII/2. + 2.0*mm; + // position is with respect to centre of tapered part (UnionSolid) + endCap_PosX = fChamberW / 2. + fEndCapTaperL_PhaseII / 2. + 2.0 * mm; vacuum_PosZ = fVacuumPosZ_PhaseII; geLeaf_PosZ = fGeLeafPosZ_PhaseII; - - G4RotationMatrix rm ; + G4RotationMatrix rm; G4double theta = 90. * deg; - G4double phi = 0. * deg; - - - //for(G4int det = prevNumber; det < numberOfClovers; det++) { - for(G4int det = 0; det < 2; det++) { - logicEndCap_CloverLR[det] = new G4LogicalVolume(solidEndCap_PhaseII, endCapMaterial, "clover_EC", 0, 0, 0); - logicVacuum_CloverLR[det] = new G4LogicalVolume(solidVacuum_PhaseII, vacuumMaterial, "clover_Vac", 0, 0, 0); - - for(G4int l = 0; l < 4; l++) { - logicGeLeaf_CloverLR[det][l] = new G4LogicalVolume(solidGeLeaf_PhaseII, geMaterial, "clover_Leaf", 0, 0, 0); - logicPassivated_CloverLR[det][l] = new G4LogicalVolume(solidPassivated_PhaseII, geMaterial, "passivatedGe", 0, 0, 0); //should be Ge - logicContact_CloverLR[det][l] = new G4LogicalVolume(solidContact_PhaseII, contactMaterial, "inner_contact", 0, 0, 0); //should be Li - logicBoreHole_CloverLR[det][l] = new G4LogicalVolume(solidBoreHole_PhaseII, vacuumMaterial, "bore-hole", 0, 0, 0); + G4double phi = 0. * deg; + + // for(G4int det = prevNumber; det < numberOfClovers; det++) { + for (G4int det = 0; det < 2; det++) { + logicEndCap_CloverLR[det] = new G4LogicalVolume(solidEndCap_PhaseII, endCapMaterial, "clover_EC", 0, 0, 0); + logicVacuum_CloverLR[det] = new G4LogicalVolume(solidVacuum_PhaseII, vacuumMaterial, "clover_Vac", 0, 0, 0); + + for (G4int l = 0; l < 4; l++) { + logicGeLeaf_CloverLR[det][l] = new G4LogicalVolume(solidGeLeaf_PhaseII, geMaterial, "clover_Leaf", 0, 0, 0); + logicPassivated_CloverLR[det][l] = + new G4LogicalVolume(solidPassivated_PhaseII, geMaterial, "passivatedGe", 0, 0, 0); // should be Ge + logicContact_CloverLR[det][l] = + new G4LogicalVolume(solidContact_PhaseII, contactMaterial, "inner_contact", 0, 0, 0); // should be Li + logicBoreHole_CloverLR[det][l] = new G4LogicalVolume(solidBoreHole_PhaseII, vacuumMaterial, "bore-hole", 0, 0, 0); } - - //rotation for each clover..... - rm.set(0,0,0); + // rotation for each clover..... + rm.set(0, 0, 0); phi = 180.0 * deg * det; rm.rotateY(theta); rm.rotateX(phi); rm.invert(); - - //traslate position: the centre of the DSSD has been placed @ Y = 0.0*mm - G4ThreeVector translation(-endCap_PosX*sin(theta)*cos(phi), - endCap_PosX*sin(theta)*sin(phi) + 0.0*mm, //fDSSD_PosY, - geSidePosition); - - G4cout << "Clover " << det << " x " << -endCap_PosX*sin(theta)*cos(phi) << G4endl; - - //Physical placement of these solids...... + + // traslate position: the centre of the DSSD has been placed @ Y = 0.0*mm + G4ThreeVector translation(-endCap_PosX * sin(theta) * cos(phi), + endCap_PosX * sin(theta) * sin(phi) + 0.0 * mm, // fDSSD_PosY, + geSidePosition); + + G4cout << "Clover " << det << " x " << -endCap_PosX * sin(theta) * cos(phi) << G4endl; + + // Physical placement of these solids...... PVPBuffer = new G4PVPlacement(G4Transform3D(rm, translation), - logicEndCap_CloverLR[det],//its logical volume - "Clover_EC", //its name - world, //its mother - true, //no boolean operat - det*4, //copy number - true); //overlap check - - PVPBuffer = new G4PVPlacement(0, //rotation - G4ThreeVector(0.*mm,0.*mm,vacuum_PosZ), - logicVacuum_CloverLR[det], //its logical volume - "Clover_Vac", //its name - logicEndCap_CloverLR[det], //its mother - true, //no boolean operat - det*4, //copy number - true); //overlap check + logicEndCap_CloverLR[det], // its logical volume + "Clover_EC", // its name + world, // its mother + true, // no boolean operat + det * 4, // copy number + true); // overlap check + + PVPBuffer = new G4PVPlacement(0, // rotation + G4ThreeVector(0. * mm, 0. * mm, vacuum_PosZ), + logicVacuum_CloverLR[det], // its logical volume + "Clover_Vac", // its name + logicEndCap_CloverLR[det], // its mother + true, // no boolean operat + det * 4, // copy number + true); // overlap check } - - //Now for the placement of the leaves in each clover...... + + // Now for the placement of the leaves in each clover...... G4RotationMatrix* rmC; G4double leafX; G4double leafY; - - - for(G4int l = 0; l < 4; l++) { - //the rotation + + for (G4int l = 0; l < 4; l++) { + // the rotation rmC = new G4RotationMatrix; - rmC->set(0,0,0); - rmC->rotateZ(90.*degree*(4-l)); + rmC->set(0, 0, 0); + rmC->rotateZ(90. * degree * (4 - l)); rmC->invert(); - //the x-translation - if(l < 2) { - leafX = 22.15*mm; - } else { - leafX = -22.15*mm; + // the x-translation + if (l < 2) { + leafX = 22.15 * mm; } - //the y-translation - if(l == 0 || l == 3 ) { - leafY = 22.15*mm; - } else { - leafY = -22.15*mm; + else { + leafX = -22.15 * mm; } - - - //for(G4int det = prevNumber; det < numberOfClovers; det++) { - for(G4int det = 0; det < 2; det++) { - //physiGeLeaf_CloverLR[det][l] = new G4PVPlacement(rmC, //rotation - PVPBuffer = new G4PVPlacement(rmC, //rotation - G4ThreeVector(leafX,leafY,geLeaf_PosZ), - logicGeLeaf_CloverLR[det][l], //its logical volume - "Clover",//detName[det].data(), //its name - logicVacuum_CloverLR[det], //its mother - true, //no boolean operat - det*4+l, //copy number - true); //overlap check - - //physiPassivated_CloverLR[det][l] = new G4PVPlacement(0, //rotation - PVPBuffer = new G4PVPlacement(0, //rotation - G4ThreeVector(-fHole_dX_PhaseII, -fHole_dY_PhaseII, fContact_dZ_PhaseII), - logicPassivated_CloverLR[det][l], - "GePassivated", - logicGeLeaf_CloverLR[det][l], - false,det*4+l,true); - - //physiContact_CloverLR[det][l] = new G4PVPlacement(0, //rotation - PVPBuffer = new G4PVPlacement(0, //rotation - G4ThreeVector(0.*mm,0.*mm, 0.0*mm),//-fContact_dZ_PhaseII), - logicContact_CloverLR[det][l], - "LiContact", - logicPassivated_CloverLR[det][l], - false,det*4+l,true); - - //physiBoreHole_CloverLR[det][l] = new G4PVPlacement(0, //rotation - PVPBuffer = new G4PVPlacement(0, //rotation - G4ThreeVector(0.*mm,0.*mm, 0.0*mm),//-fContact_dZ_PhaseII), - logicBoreHole_CloverLR[det][l], - "BoreHole", - logicContact_CloverLR[det][l], - false,det*4+l,true); - + // the y-translation + if (l == 0 || l == 3) { + leafY = 22.15 * mm; + } + else { + leafY = -22.15 * mm; + } + + // for(G4int det = prevNumber; det < numberOfClovers; det++) { + for (G4int det = 0; det < 2; det++) { + // physiGeLeaf_CloverLR[det][l] = new G4PVPlacement(rmC, //rotation + PVPBuffer = new G4PVPlacement(rmC, // rotation + G4ThreeVector(leafX, leafY, geLeaf_PosZ), + logicGeLeaf_CloverLR[det][l], // its logical volume + "Clover", // detName[det].data(), //its name + logicVacuum_CloverLR[det], // its mother + true, // no boolean operat + det * 4 + l, // copy number + true); // overlap check + + // physiPassivated_CloverLR[det][l] = new G4PVPlacement(0, //rotation + PVPBuffer = new G4PVPlacement(0, // rotation + G4ThreeVector(-fHole_dX_PhaseII, -fHole_dY_PhaseII, fContact_dZ_PhaseII), + logicPassivated_CloverLR[det][l], "GePassivated", logicGeLeaf_CloverLR[det][l], + false, det * 4 + l, true); + + // physiContact_CloverLR[det][l] = new G4PVPlacement(0, //rotation + PVPBuffer = new G4PVPlacement(0, // rotation + G4ThreeVector(0. * mm, 0. * mm, 0.0 * mm), //-fContact_dZ_PhaseII), + logicContact_CloverLR[det][l], "LiContact", logicPassivated_CloverLR[det][l], false, + det * 4 + l, true); + + // physiBoreHole_CloverLR[det][l] = new G4PVPlacement(0, //rotation + PVPBuffer = new G4PVPlacement(0, // rotation + G4ThreeVector(0. * mm, 0. * mm, 0.0 * mm), //-fContact_dZ_PhaseII), + logicBoreHole_CloverLR[det][l], "BoreHole", logicContact_CloverLR[det][l], false, + det * 4 + l, true); } } - //define the visual attributes - G4VisAttributes* visAttAlCap = new G4VisAttributes( G4Colour(0.9,0.9,0.9) ); + // define the visual attributes + G4VisAttributes* visAttAlCap = new G4VisAttributes(G4Colour(0.9, 0.9, 0.9)); visAttAlCap->SetForceWireframe(true); visAttAlCap->SetVisibility(true); - //visAttAlCap->SetVisibility(false); - - G4VisAttributes* visAttGeVac = new G4VisAttributes( G4Colour(0.9,1.0,0.9) ); + // visAttAlCap->SetVisibility(false); + + G4VisAttributes* visAttGeVac = new G4VisAttributes(G4Colour(0.9, 1.0, 0.9)); visAttGeVac->SetForceWireframe(true); visAttGeVac->SetVisibility(true); - //visAttGeVac->SetVisibility(false); - - G4VisAttributes* visAttActive = new G4VisAttributes( G4Colour(1.0,1.0,0.0) ); + // visAttGeVac->SetVisibility(false); + + G4VisAttributes* visAttActive = new G4VisAttributes(G4Colour(1.0, 1.0, 0.0)); visAttActive->SetForceWireframe(true); visAttActive->SetVisibility(true); - //visAttActive->SetVisibility(false); - - G4VisAttributes* visAttPassive = new G4VisAttributes(G4Colour(0.0,1.0,1.0) ); + // visAttActive->SetVisibility(false); + + G4VisAttributes* visAttPassive = new G4VisAttributes(G4Colour(0.0, 1.0, 1.0)); visAttPassive->SetForceWireframe(true); visAttPassive->SetVisibility(true); - //visAttPassive->SetVisibility(false); - - G4VisAttributes* visAttLiContact = new G4VisAttributes(G4Colour(1.0,0.0,1.0) ); + // visAttPassive->SetVisibility(false); + + G4VisAttributes* visAttLiContact = new G4VisAttributes(G4Colour(1.0, 0.0, 1.0)); visAttLiContact->SetVisibility(true); - //visAttLiContact->SetVisibility(false); - - G4VisAttributes* visAttHole = new G4VisAttributes( G4Colour(0.0,0.0,1.0) ); + // visAttLiContact->SetVisibility(false); + + G4VisAttributes* visAttHole = new G4VisAttributes(G4Colour(0.0, 0.0, 1.0)); visAttHole->SetVisibility(true); - //visAttHole->SetVisibility(false); - - for(G4int det = 0; det < 2; det++) { + // visAttHole->SetVisibility(false); + + for (G4int det = 0; det < 2; det++) { logicEndCap_CloverLR[det]->SetVisAttributes(visAttAlCap); logicVacuum_CloverLR[det]->SetVisAttributes(visAttGeVac); - for(G4int l = 0; l < 4; l++) { + for (G4int l = 0; l < 4; l++) { logicGeLeaf_CloverLR[det][l]->SetVisAttributes(visAttActive); logicPassivated_CloverLR[det][l]->SetVisAttributes(visAttPassive); logicContact_CloverLR[det][l]->SetVisAttributes(visAttLiContact); @@ -2499,161 +2402,150 @@ void Chamber::Place_PhaseIIs_Left_and_Right(G4LogicalVolume* world) } } - //------------------------------------------------------------------ -void Chamber::Place_PhaseII_On_the_Top(G4LogicalVolume* world) -{ +void Chamber::Place_PhaseII_On_the_Top(G4LogicalVolume* world) { //================================================================================= - //Do not know why, but the positioning seems to be with respect to the Taper-part : - //setting the z-position as endCapTaperL/2 puts the front face at z = 0 mm + // Do not know why, but the positioning seems to be with respect to the Taper-part : + // setting the z-position as endCapTaperL/2 puts the front face at z = 0 mm //================================================================================= - G4double endCap_PosX; + G4double endCap_PosX; G4double vacuum_PosZ; G4double geLeaf_PosZ; - //reset scale - endCap_PosX = fChamberH/2. + fEndCapTaperL_PhaseII/2. + fGeTopGap; + // reset scale + endCap_PosX = fChamberH / 2. + fEndCapTaperL_PhaseII / 2. + fGeTopGap; vacuum_PosZ = fVacuumPosZ_PhaseII; geLeaf_PosZ = fGeLeafPosZ_PhaseII; - - - G4RotationMatrix rm ; + + G4RotationMatrix rm; G4double theta = 90. * deg; - G4double phi = 0. * deg; - - - logicEndCap_CloverT = new G4LogicalVolume(solidEndCap_PhaseII, endCapMaterial, "clover_EC", 0, 0, 0); - logicVacuum_CloverT = new G4LogicalVolume(solidVacuum_PhaseII, vacuumMaterial, "clover_Vac", 0, 0, 0); - - for(G4int l = 0; l < 4; l++) { - logicGeLeaf_CloverT[l] = new G4LogicalVolume(solidGeLeaf_PhaseII, geMaterial, "clover_Leaf", 0, 0, 0); - logicPassivated_CloverT[l] = new G4LogicalVolume(solidPassivated_PhaseII, geMaterial, "passivatedGe", 0, 0, 0); //should be Ge - logicContact_CloverT[l] = new G4LogicalVolume(solidContact_PhaseII, contactMaterial, "inner_contact", 0, 0, 0); //should be Li - logicBoreHole_CloverT[l] = new G4LogicalVolume(solidBoreHole_PhaseII, vacuumMaterial, "bore-hole", 0, 0, 0); + G4double phi = 0. * deg; + + logicEndCap_CloverT = new G4LogicalVolume(solidEndCap_PhaseII, endCapMaterial, "clover_EC", 0, 0, 0); + logicVacuum_CloverT = new G4LogicalVolume(solidVacuum_PhaseII, vacuumMaterial, "clover_Vac", 0, 0, 0); + + for (G4int l = 0; l < 4; l++) { + logicGeLeaf_CloverT[l] = new G4LogicalVolume(solidGeLeaf_PhaseII, geMaterial, "clover_Leaf", 0, 0, 0); + logicPassivated_CloverT[l] = + new G4LogicalVolume(solidPassivated_PhaseII, geMaterial, "passivatedGe", 0, 0, 0); // should be Ge + logicContact_CloverT[l] = + new G4LogicalVolume(solidContact_PhaseII, contactMaterial, "inner_contact", 0, 0, 0); // should be Li + logicBoreHole_CloverT[l] = new G4LogicalVolume(solidBoreHole_PhaseII, vacuumMaterial, "bore-hole", 0, 0, 0); } - //rotate - rm.set(0,0,0); + // rotate + rm.set(0, 0, 0); phi = 90.0 * deg; rm.rotateY(theta); rm.rotateX(phi); rm.invert(); - - //traslate position - G4ThreeVector translation(-endCap_PosX*sin(theta)*cos(phi), - endCap_PosX*sin(theta)*sin(phi), - geTopPosition); - - G4cout << "Top Clover " << " x " << -endCap_PosX*sin(theta)*cos(phi) << G4endl; - - //Physical placement of these solids...... - //physiEndCap_CloverT = new G4PVPlacement(G4Transform3D(rm, translation), + + // traslate position + G4ThreeVector translation(-endCap_PosX * sin(theta) * cos(phi), endCap_PosX * sin(theta) * sin(phi), geTopPosition); + + G4cout << "Top Clover " + << " x " << -endCap_PosX * sin(theta) * cos(phi) << G4endl; + + // Physical placement of these solids...... + // physiEndCap_CloverT = new G4PVPlacement(G4Transform3D(rm, translation), PVPBuffer = new G4PVPlacement(G4Transform3D(rm, translation), - logicEndCap_CloverT,//its logical volume - "Clover_EC", //its name - world, //its mother - true, //no boolean operat - 8, //copy number - true); //overlap check - - //physiVacuum_CloverT = new G4PVPlacement(0, //rotation - PVPBuffer = new G4PVPlacement(0, //rotation - G4ThreeVector(0.*mm,0.*mm,vacuum_PosZ), - logicVacuum_CloverT, //its logical volume - "Clover_Vac", //its name - logicEndCap_CloverT, //its mother - true, //no boolean operat - 8, //copy number - true); //overlap check - - //Now for the placement of the leaves in each clover...... + logicEndCap_CloverT, // its logical volume + "Clover_EC", // its name + world, // its mother + true, // no boolean operat + 8, // copy number + true); // overlap check + + // physiVacuum_CloverT = new G4PVPlacement(0, //rotation + PVPBuffer = new G4PVPlacement(0, // rotation + G4ThreeVector(0. * mm, 0. * mm, vacuum_PosZ), + logicVacuum_CloverT, // its logical volume + "Clover_Vac", // its name + logicEndCap_CloverT, // its mother + true, // no boolean operat + 8, // copy number + true); // overlap check + + // Now for the placement of the leaves in each clover...... G4RotationMatrix* rmC; G4double leafX; G4double leafY; - - for(G4int l = 0; l < 4; l++) { - //the rotation + + for (G4int l = 0; l < 4; l++) { + // the rotation rmC = new G4RotationMatrix; - rmC->set(0,0,0); - rmC->rotateZ(90.*degree*(4-l)); + rmC->set(0, 0, 0); + rmC->rotateZ(90. * degree * (4 - l)); rmC->invert(); - //the x-translation - if(l < 2) { - leafX = 22.15*mm; - } else { - leafX = -22.15*mm; + // the x-translation + if (l < 2) { + leafX = 22.15 * mm; + } + else { + leafX = -22.15 * mm; + } + // the y-translation + if (l == 0 || l == 3) { + leafY = 22.15 * mm; } - //the y-translation - if(l == 0 || l == 3 ) { - leafY = 22.15*mm; - } else { - leafY = -22.15*mm; + else { + leafY = -22.15 * mm; } - //the z-translation - - - //physiGeLeaf_CloverT[l] = new G4PVPlacement(rmC, //rotation - PVPBuffer = new G4PVPlacement(rmC, //rotation - G4ThreeVector(leafX,leafY,geLeaf_PosZ), - logicGeLeaf_CloverT[l], //its logical volume - "Clover", //its name - logicVacuum_CloverT, //its mother - true, //no boolean operat - 8+l, //copy number - true); //overlap check - - //physiPassivated_CloverT[l] = new G4PVPlacement(0, //rotation - PVPBuffer = new G4PVPlacement(0, //rotation - G4ThreeVector(-fHole_dX_PhaseII, -fHole_dY_PhaseII, fContact_dZ_PhaseII), - logicPassivated_CloverT[l], - "GePassivated", - logicGeLeaf_CloverT[l], - false,8+l,true); - - //physiContact_CloverT[l] = new G4PVPlacement(0, //rotation - PVPBuffer = new G4PVPlacement(0, //rotation - G4ThreeVector(0.*mm,0.*mm, 0.0*mm),//-fContact_dZ_PhaseII), - logicContact_CloverT[l], - "LiContact", - logicPassivated_CloverT[l], - false,8+l,true); - - //physiBoreHole_CloverT[l] = new G4PVPlacement(0, //rotation - PVPBuffer = new G4PVPlacement(0, //rotation - G4ThreeVector(0.*mm,0.*mm, 0.0*mm),//-fContact_dZ_PhaseII), - logicBoreHole_CloverT[l], - "BoreHole", - logicContact_CloverT[l], - false,8+l,true); - + // the z-translation + + // physiGeLeaf_CloverT[l] = new G4PVPlacement(rmC, //rotation + PVPBuffer = new G4PVPlacement(rmC, // rotation + G4ThreeVector(leafX, leafY, geLeaf_PosZ), + logicGeLeaf_CloverT[l], // its logical volume + "Clover", // its name + logicVacuum_CloverT, // its mother + true, // no boolean operat + 8 + l, // copy number + true); // overlap check + + // physiPassivated_CloverT[l] = new G4PVPlacement(0, //rotation + PVPBuffer = + new G4PVPlacement(0, // rotation + G4ThreeVector(-fHole_dX_PhaseII, -fHole_dY_PhaseII, fContact_dZ_PhaseII), + logicPassivated_CloverT[l], "GePassivated", logicGeLeaf_CloverT[l], false, 8 + l, true); + + // physiContact_CloverT[l] = new G4PVPlacement(0, //rotation + PVPBuffer = new G4PVPlacement(0, // rotation + G4ThreeVector(0. * mm, 0. * mm, 0.0 * mm), //-fContact_dZ_PhaseII), + logicContact_CloverT[l], "LiContact", logicPassivated_CloverT[l], false, 8 + l, true); + + // physiBoreHole_CloverT[l] = new G4PVPlacement(0, //rotation + PVPBuffer = new G4PVPlacement(0, // rotation + G4ThreeVector(0. * mm, 0. * mm, 0.0 * mm), //-fContact_dZ_PhaseII), + logicBoreHole_CloverT[l], "BoreHole", logicContact_CloverT[l], false, 8 + l, true); } - //define the visual attributes - G4VisAttributes* visAttAlCap = new G4VisAttributes( G4Colour(0.9,0.9,0.9) ); + // define the visual attributes + G4VisAttributes* visAttAlCap = new G4VisAttributes(G4Colour(0.9, 0.9, 0.9)); visAttAlCap->SetVisibility(true); visAttAlCap->SetForceWireframe(true); - - G4VisAttributes* visAttGeVac = new G4VisAttributes( G4Colour(0.9,1.0,0.9) ); + + G4VisAttributes* visAttGeVac = new G4VisAttributes(G4Colour(0.9, 1.0, 0.9)); visAttGeVac->SetForceWireframe(true); visAttGeVac->SetVisibility(true); - - G4VisAttributes* visAttActive = new G4VisAttributes( G4Colour(1.0,1.0,0.0) ); + + G4VisAttributes* visAttActive = new G4VisAttributes(G4Colour(1.0, 1.0, 0.0)); visAttActive->SetForceWireframe(true); visAttActive->SetVisibility(true); - - G4VisAttributes* visAttPassive = new G4VisAttributes(G4Colour(0.0,1.0,1.0) ); + + G4VisAttributes* visAttPassive = new G4VisAttributes(G4Colour(0.0, 1.0, 1.0)); visAttPassive->SetForceWireframe(true); visAttPassive->SetVisibility(true); - - G4VisAttributes* visAttLiContact = new G4VisAttributes(G4Colour(1.0,0.0,1.0) ); + + G4VisAttributes* visAttLiContact = new G4VisAttributes(G4Colour(1.0, 0.0, 1.0)); visAttLiContact->SetVisibility(true); - - G4VisAttributes* visAttHole = new G4VisAttributes( G4Colour(0.0,0.0,1.0) ); + + G4VisAttributes* visAttHole = new G4VisAttributes(G4Colour(0.0, 0.0, 1.0)); visAttHole->SetVisibility(true); - + logicEndCap_CloverT->SetVisAttributes(visAttAlCap); logicVacuum_CloverT->SetVisAttributes(visAttGeVac); - for(G4int l = 0; l < 4; l++) { + for (G4int l = 0; l < 4; l++) { logicGeLeaf_CloverT[l]->SetVisAttributes(visAttActive); logicPassivated_CloverT[l]->SetVisAttributes(visAttPassive); logicContact_CloverT[l]->SetVisAttributes(visAttLiContact); @@ -2661,165 +2553,153 @@ void Chamber::Place_PhaseII_On_the_Top(G4LogicalVolume* world) } } - //------------------------------------------------------------------ -void Chamber::Place_GREAT_On_the_Top(G4LogicalVolume* world) -{ +void Chamber::Place_GREAT_On_the_Top(G4LogicalVolume* world) { //================================================================================= // The positioning for boolean solids is odd : for this det it is with respect to the Taper-part : - //setting the z-position as endCapTaperL/2 puts the front face at z = 0 mm + // setting the z-position as endCapTaperL/2 puts the front face at z = 0 mm //================================================================================= - G4double endCap_PosX = fChamberH/2. - fShiftChamberY + fEndCapTaperL_GREAT/2. + fGeTopGap; + G4double endCap_PosX = fChamberH / 2. - fShiftChamberY + fEndCapTaperL_GREAT / 2. + fGeTopGap; G4double vacuum_PosZ = fVacuumPosZ_GREAT; G4double geLeaf_PosZ = fGeLeafPosZ_GREAT; - - - G4RotationMatrix rm ; + + G4RotationMatrix rm; G4double theta = 90. * deg; - G4double phi = 0. * deg; - - - logicEndCap_CloverT = new G4LogicalVolume(solidEndCap_GREAT, endCapMaterial, "clover_EC", 0, 0, 0); - logicVacuum_CloverT = new G4LogicalVolume(solidVacuum_GREAT, vacuumMaterial, "clover_Vac", 0, 0, 0); - - for(G4int l = 0; l < 4; l++) { - logicGeLeaf_CloverT[l] = new G4LogicalVolume(solidGeLeaf_GREAT, geMaterial, "clover_Leaf", 0, 0, 0); - logicPassivated_CloverT[l] = new G4LogicalVolume(solidPassivated_GREAT, geMaterial, "passivatedGe", 0, 0, 0); - logicContact_CloverT[l] = new G4LogicalVolume(solidContact_GREAT, contactMaterial, "inner_contact", 0, 0, 0); - logicBoreHole_CloverT[l] = new G4LogicalVolume(solidBoreHole_GREAT, vacuumMaterial, "bore_hole", 0, 0, 0); + G4double phi = 0. * deg; + + logicEndCap_CloverT = new G4LogicalVolume(solidEndCap_GREAT, endCapMaterial, "clover_EC", 0, 0, 0); + logicVacuum_CloverT = new G4LogicalVolume(solidVacuum_GREAT, vacuumMaterial, "clover_Vac", 0, 0, 0); + + for (G4int l = 0; l < 4; l++) { + logicGeLeaf_CloverT[l] = new G4LogicalVolume(solidGeLeaf_GREAT, geMaterial, "clover_Leaf", 0, 0, 0); + logicPassivated_CloverT[l] = new G4LogicalVolume(solidPassivated_GREAT, geMaterial, "passivatedGe", 0, 0, 0); + logicContact_CloverT[l] = new G4LogicalVolume(solidContact_GREAT, contactMaterial, "inner_contact", 0, 0, 0); + logicBoreHole_CloverT[l] = new G4LogicalVolume(solidBoreHole_GREAT, vacuumMaterial, "bore_hole", 0, 0, 0); } - //rotate - rm.set(0,0,0); + // rotate + rm.set(0, 0, 0); phi = 90.0 * deg; rm.rotateY(theta); rm.rotateX(phi); rm.invert(); - - //traslate position - G4ThreeVector translation(-endCap_PosX*sin(theta)*cos(phi), - endCap_PosX*sin(theta)*sin(phi), - geTopPosition +fCorrection); - - G4cout << "Top Clover " << " x " << -endCap_PosX*sin(theta)*cos(phi) << G4endl; - - //Physical placement of these solids...... - //physiEndCap_CloverT = new G4PVPlacement(G4Transform3D(rm, translation), + + // traslate position + G4ThreeVector translation(-endCap_PosX * sin(theta) * cos(phi), endCap_PosX * sin(theta) * sin(phi), + geTopPosition + fCorrection); + + G4cout << "Top Clover " + << " x " << -endCap_PosX * sin(theta) * cos(phi) << G4endl; + + // Physical placement of these solids...... + // physiEndCap_CloverT = new G4PVPlacement(G4Transform3D(rm, translation), PVPBuffer = new G4PVPlacement(G4Transform3D(rm, translation), - logicEndCap_CloverT,//its logical volume - "Clover_EC", //its name - world, //its mother - true, //no boolean operat - 8, //copy number - true); //overlap check - - //physiVacuum_CloverT = new G4PVPlacement(0, //rotation - PVPBuffer = new G4PVPlacement(0, //rotation - G4ThreeVector(0.*mm,0.*mm,vacuum_PosZ), - logicVacuum_CloverT, //its logical volume - "Clover_Vac", //its name - logicEndCap_CloverT, //its mother - true, //no boolean operat - 8, //copy number - true); //overlap check - - //Now for the placement of the leaves in each clover...... + logicEndCap_CloverT, // its logical volume + "Clover_EC", // its name + world, // its mother + true, // no boolean operat + 8, // copy number + true); // overlap check + + // physiVacuum_CloverT = new G4PVPlacement(0, //rotation + PVPBuffer = new G4PVPlacement(0, // rotation + G4ThreeVector(0. * mm, 0. * mm, vacuum_PosZ), + logicVacuum_CloverT, // its logical volume + "Clover_Vac", // its name + logicEndCap_CloverT, // its mother + true, // no boolean operat + 8, // copy number + true); // overlap check + + // Now for the placement of the leaves in each clover...... G4RotationMatrix* rmC; - G4double dPos = fGeLeaf_dX_GREAT + fGapBetweenLeaves_GREAT/2.; + G4double dPos = fGeLeaf_dX_GREAT + fGapBetweenLeaves_GREAT / 2.; G4double leafX; G4double leafY; G4double leafZ; - - for(G4int l = 0; l < 4; l++) { - //the rotation + + for (G4int l = 0; l < 4; l++) { + // the rotation rmC = new G4RotationMatrix; - rmC->set(0,0,0); - rmC->rotateZ(90.*degree*(4-l)); + rmC->set(0, 0, 0); + rmC->rotateZ(90. * degree * (4 - l)); rmC->invert(); - //the x-translation - if(l < 2) { + // the x-translation + if (l < 2) { leafX = dPos; - } else { + } + else { leafX = -dPos; } - //the y-translation - if(l == 0 || l == 3 ) { + // the y-translation + if (l == 0 || l == 3) { leafY = dPos; - } else { + } + else { leafY = -dPos; } - //the z-translation + // the z-translation leafZ = geLeaf_PosZ; - - - //physiGeLeaf_CloverT[l] = new G4PVPlacement(rmC, //rotation - PVPBuffer = new G4PVPlacement(rmC, //rotation - G4ThreeVector(leafX, leafY, leafZ), - logicGeLeaf_CloverT[l], //its logical volume - "Clover", //its name - logicVacuum_CloverT, //its mother - true, //no boolean operat - 8+l, //copy number - true); //overlap check - - //physiPassivated_CloverT[l] = new G4PVPlacement(0, //rotation - PVPBuffer = new G4PVPlacement(0, //rotation - G4ThreeVector(fHole_dX_GREAT, fHole_dY_GREAT, fContact_dZ_GREAT), - logicPassivated_CloverT[l], - "GePassivated", - logicGeLeaf_CloverT[l], - false,8+l,true); - - //physiContact_CloverT[l] = new G4PVPlacement(0, //rotation - PVPBuffer = new G4PVPlacement(0, //rotation - G4ThreeVector(0.*mm,0.*mm, 0.0*mm),//-fContact_dZ_GREAT), - logicContact_CloverT[l], - "LiContact", - logicPassivated_CloverT[l], - false,8+l,true); - - //physiBoreHole_CloverT[l] = new G4PVPlacement(0, //rotation - PVPBuffer = new G4PVPlacement(0, //rotation - G4ThreeVector(0.*mm,0.*mm, 0.0*mm), - logicBoreHole_CloverT[l], - "BoreHole", - logicContact_CloverT[l], - false,8+l,true); - + + // physiGeLeaf_CloverT[l] = new G4PVPlacement(rmC, //rotation + PVPBuffer = new G4PVPlacement(rmC, // rotation + G4ThreeVector(leafX, leafY, leafZ), + logicGeLeaf_CloverT[l], // its logical volume + "Clover", // its name + logicVacuum_CloverT, // its mother + true, // no boolean operat + 8 + l, // copy number + true); // overlap check + + // physiPassivated_CloverT[l] = new G4PVPlacement(0, //rotation + PVPBuffer = + new G4PVPlacement(0, // rotation + G4ThreeVector(fHole_dX_GREAT, fHole_dY_GREAT, fContact_dZ_GREAT), logicPassivated_CloverT[l], + "GePassivated", logicGeLeaf_CloverT[l], false, 8 + l, true); + + // physiContact_CloverT[l] = new G4PVPlacement(0, //rotation + PVPBuffer = new G4PVPlacement(0, // rotation + G4ThreeVector(0. * mm, 0. * mm, 0.0 * mm), //-fContact_dZ_GREAT), + logicContact_CloverT[l], "LiContact", logicPassivated_CloverT[l], false, 8 + l, true); + + // physiBoreHole_CloverT[l] = new G4PVPlacement(0, //rotation + PVPBuffer = new G4PVPlacement(0, // rotation + G4ThreeVector(0. * mm, 0. * mm, 0.0 * mm), logicBoreHole_CloverT[l], "BoreHole", + logicContact_CloverT[l], false, 8 + l, true); } - //define the visual attributes - G4VisAttributes* visAttAlCap = new G4VisAttributes( G4Colour(0.9,0.9,0.9) ); + // define the visual attributes + G4VisAttributes* visAttAlCap = new G4VisAttributes(G4Colour(0.9, 0.9, 0.9)); visAttAlCap->SetVisibility(true); - //visAttAlCap->SetVisibility(false); + // visAttAlCap->SetVisibility(false); visAttAlCap->SetForceWireframe(true); - - G4VisAttributes* visAttGeVac = new G4VisAttributes( G4Colour(0.9,1.0,0.9) ); + + G4VisAttributes* visAttGeVac = new G4VisAttributes(G4Colour(0.9, 1.0, 0.9)); visAttGeVac->SetVisibility(true); - //visAttGeVac->SetVisibility(false); + // visAttGeVac->SetVisibility(false); visAttGeVac->SetForceWireframe(true); - - G4VisAttributes* visAttActive = new G4VisAttributes( G4Colour(1.0,1.0,0.0) ); + + G4VisAttributes* visAttActive = new G4VisAttributes(G4Colour(1.0, 1.0, 0.0)); visAttActive->SetVisibility(true); - //visAttActive->SetVisibility(false); + // visAttActive->SetVisibility(false); visAttActive->SetForceWireframe(true); - - G4VisAttributes* visAttPassive = new G4VisAttributes(G4Colour(0.0,1.0,1.0) ); + + G4VisAttributes* visAttPassive = new G4VisAttributes(G4Colour(0.0, 1.0, 1.0)); visAttPassive->SetVisibility(true); - //visAttPassive->SetVisibility(false); + // visAttPassive->SetVisibility(false); visAttPassive->SetForceWireframe(true); - - G4VisAttributes* visAttLiContact = new G4VisAttributes(G4Colour(1.0,0.0,1.0) ); + + G4VisAttributes* visAttLiContact = new G4VisAttributes(G4Colour(1.0, 0.0, 1.0)); visAttLiContact->SetVisibility(true); - //visAttLiContact->SetVisibility(false); - - G4VisAttributes* visAttHole = new G4VisAttributes( G4Colour(0.0,0.0,1.0) ); + // visAttLiContact->SetVisibility(false); + + G4VisAttributes* visAttHole = new G4VisAttributes(G4Colour(0.0, 0.0, 1.0)); visAttHole->SetVisibility(true); - //visAttHole->SetVisibility(false); - + // visAttHole->SetVisibility(false); + logicEndCap_CloverT->SetVisAttributes(visAttAlCap); logicVacuum_CloverT->SetVisAttributes(visAttGeVac); - for(G4int l = 0; l < 4; l++) { + for (G4int l = 0; l < 4; l++) { logicGeLeaf_CloverT[l]->SetVisAttributes(visAttActive); logicPassivated_CloverT[l]->SetVisAttributes(visAttPassive); logicContact_CloverT[l]->SetVisAttributes(visAttLiContact); @@ -2828,169 +2708,161 @@ void Chamber::Place_GREAT_On_the_Top(G4LogicalVolume* world) } //------------------------------------------------------------------ -// Clover numbering scheme : +// Clover numbering scheme : // Left = 0 => Crystals 0, 1, 2, 3 // Right = 4 => Crystals 4, 5, 6, 7 // Top = 8 => Crystals 8, 9,10,11 // Upstream = 12 => Crystals 12,13,14,15 //------------------------------------------------------------------ //------------------------------------------------------------------ -void Chamber::Place_GREAT_Left_and_Right(G4LogicalVolume* world) -{ +void Chamber::Place_GREAT_Left_and_Right(G4LogicalVolume* world) { //================================================================================= // The positioning for boolean solids is odd : for this det it is with respect to the Taper-part : - //setting the z-position as endCapTaperL/2 puts the front face at z = 0 mm + // setting the z-position as endCapTaperL/2 puts the front face at z = 0 mm //================================================================================= - G4double endCap_PosX = fChamberW/2. + fEndCapTaperL_GREAT/2. + 3.0*mm; + G4double endCap_PosX = fChamberW / 2. + fEndCapTaperL_GREAT / 2. + 3.0 * mm; G4double vacuum_PosZ = fVacuumPosZ_GREAT; G4double geLeaf_PosZ = fGeLeafPosZ_GREAT; - - - G4RotationMatrix rm ; + + G4RotationMatrix rm; G4double theta = 90. * deg; - G4double phi = 0. * deg; - - - //for(G4int det = prevNumber; det < numberOfClovers; det++) { - for(G4int det = 0; det < 2; det++) { - logicEndCap_CloverLR[det] = new G4LogicalVolume(solidEndCap_GREAT, endCapMaterial, "clover_EC", 0, 0, 0); - logicVacuum_CloverLR[det] = new G4LogicalVolume(solidVacuum_GREAT, vacuumMaterial, "clover_Vac", 0, 0, 0); - - for(G4int l = 0; l < 4; l++) { - logicGeLeaf_CloverLR[det][l] = new G4LogicalVolume(solidGeLeaf_GREAT, geMaterial, "clover_Leaf", 0, 0, 0); - logicPassivated_CloverLR[det][l] = new G4LogicalVolume(solidPassivated_GREAT, geMaterial, "passivatedGe", 0, 0, 0); //should be Ge - logicContact_CloverLR[det][l] = new G4LogicalVolume(solidContact_GREAT, contactMaterial, "inner_contact", 0, 0, 0); //should be Li - logicBoreHole_CloverLR[det][l] = new G4LogicalVolume(solidBoreHole_GREAT, vacuumMaterial, "bore-hole", 0, 0, 0); + G4double phi = 0. * deg; + + // for(G4int det = prevNumber; det < numberOfClovers; det++) { + for (G4int det = 0; det < 2; det++) { + logicEndCap_CloverLR[det] = new G4LogicalVolume(solidEndCap_GREAT, endCapMaterial, "clover_EC", 0, 0, 0); + logicVacuum_CloverLR[det] = new G4LogicalVolume(solidVacuum_GREAT, vacuumMaterial, "clover_Vac", 0, 0, 0); + + for (G4int l = 0; l < 4; l++) { + logicGeLeaf_CloverLR[det][l] = new G4LogicalVolume(solidGeLeaf_GREAT, geMaterial, "clover_Leaf", 0, 0, 0); + logicPassivated_CloverLR[det][l] = + new G4LogicalVolume(solidPassivated_GREAT, geMaterial, "passivatedGe", 0, 0, 0); // should be Ge + logicContact_CloverLR[det][l] = + new G4LogicalVolume(solidContact_GREAT, contactMaterial, "inner_contact", 0, 0, 0); // should be Li + logicBoreHole_CloverLR[det][l] = new G4LogicalVolume(solidBoreHole_GREAT, vacuumMaterial, "bore-hole", 0, 0, 0); } - - //rotation for each clover..... - rm.set(0,0,0); + // rotation for each clover..... + rm.set(0, 0, 0); phi = 180.0 * deg * det; rm.rotateY(theta); rm.rotateX(phi); rm.invert(); - - //traslate position: the centre of the DSSD has been placed @ Y = 0.0*mm - G4ThreeVector translation(-endCap_PosX*sin(theta)*cos(phi), - endCap_PosX*sin(theta)*sin(phi) + 0.0*mm, //fDSSD_PosY, - 0.0*mm); - - G4cout << "Clover " << det << " x " << -endCap_PosX*sin(theta)*cos(phi) << G4endl; - - //Physical placement of these solids...... - //physiEndCap_CloverLR[det] = new G4PVPlacement(G4Transform3D(rm, translation), + + // traslate position: the centre of the DSSD has been placed @ Y = 0.0*mm + G4ThreeVector translation(-endCap_PosX * sin(theta) * cos(phi), + endCap_PosX * sin(theta) * sin(phi) + 0.0 * mm, // fDSSD_PosY, + 0.0 * mm); + + G4cout << "Clover " << det << " x " << -endCap_PosX * sin(theta) * cos(phi) << G4endl; + + // Physical placement of these solids...... + // physiEndCap_CloverLR[det] = new G4PVPlacement(G4Transform3D(rm, translation), PVPBuffer = new G4PVPlacement(G4Transform3D(rm, translation), - logicEndCap_CloverLR[det],//its logical volume - "Clover_EC", //its name - world, //its mother - true, //no boolean operat - det*4, //copy number - true); //overlap check - - //physiVacuum_CloverLR[det] = new G4PVPlacement(0, //rotation - PVPBuffer = new G4PVPlacement(0, //rotation - G4ThreeVector(0.*mm,0.*mm,vacuum_PosZ), - logicVacuum_CloverLR[det], //its logical volume - "Clover_Vac", //its name - logicEndCap_CloverLR[det], //its mother - true, //no boolean operat - det*4, //copy number - true); //overlap check + logicEndCap_CloverLR[det], // its logical volume + "Clover_EC", // its name + world, // its mother + true, // no boolean operat + det * 4, // copy number + true); // overlap check + + // physiVacuum_CloverLR[det] = new G4PVPlacement(0, //rotation + PVPBuffer = new G4PVPlacement(0, // rotation + G4ThreeVector(0. * mm, 0. * mm, vacuum_PosZ), + logicVacuum_CloverLR[det], // its logical volume + "Clover_Vac", // its name + logicEndCap_CloverLR[det], // its mother + true, // no boolean operat + det * 4, // copy number + true); // overlap check } - - //Now for the placement of the leaves in each clover...... + + // Now for the placement of the leaves in each clover...... G4RotationMatrix* rmC; - G4double dPos = fGeLeaf_dX_GREAT + fGapBetweenLeaves_GREAT/2.; + G4double dPos = fGeLeaf_dX_GREAT + fGapBetweenLeaves_GREAT / 2.; G4double leafX; G4double leafY; - - for(G4int l = 0; l < 4; l++) { - //the rotation + + for (G4int l = 0; l < 4; l++) { + // the rotation rmC = new G4RotationMatrix; - rmC->set(0,0,0); - rmC->rotateZ(90.*degree*(4-l)); + rmC->set(0, 0, 0); + rmC->rotateZ(90. * degree * (4 - l)); rmC->invert(); - //the x-translation - if(l < 2) { + // the x-translation + if (l < 2) { leafX = dPos; - } else { + } + else { leafX = -dPos; } - //the y-translation - if(l == 0 || l == 3 ) { + // the y-translation + if (l == 0 || l == 3) { leafY = dPos; - } else { + } + else { leafY = -dPos; } - - - //for(G4int det = prevNumber; det < numberOfClovers; det++) { - for(G4int det = 0; det < 2; det++) { - //physiGeLeaf_CloverLR[det][l] = new G4PVPlacement(rmC, //rotation - PVPBuffer = new G4PVPlacement(rmC, //rotation - G4ThreeVector(leafX,leafY,geLeaf_PosZ), - logicGeLeaf_CloverLR[det][l], //its logical volume - "Clover",//detName[det].data(), //its name - logicVacuum_CloverLR[det], //its mother - true, //no boolean operat - det*4+l, //copy number - true); //overlap check - - //physiPassivated_CloverLR[det][l] = new G4PVPlacement(0, //rotation - PVPBuffer = new G4PVPlacement(0, //rotation - G4ThreeVector(-fHole_dX_PhaseII, -fHole_dY_PhaseII, fContact_dZ_GREAT), - logicPassivated_CloverLR[det][l], - "GePassivated", - logicGeLeaf_CloverLR[det][l], - false,det*4+l,true); - - //physiContact_CloverLR[det][l] = new G4PVPlacement(0, //rotation - PVPBuffer = new G4PVPlacement(0, //rotation - G4ThreeVector(0.*mm,0.*mm, 0.0*mm),//-fContact_dZ_GREAT), - logicContact_CloverLR[det][l], - "LiContact", - logicPassivated_CloverLR[det][l], - false,det*4+l,true); - - //physiBoreHole_CloverLR[det][l] = new G4PVPlacement(0, //rotation - PVPBuffer = new G4PVPlacement(0, //rotation - G4ThreeVector(0.*mm,0.*mm, 0.0*mm),//-fContact_dZ_GREAT), - logicBoreHole_CloverLR[det][l], - "BoreHole", - logicContact_CloverLR[det][l], - false,det*4+l,true); - + + // for(G4int det = prevNumber; det < numberOfClovers; det++) { + for (G4int det = 0; det < 2; det++) { + // physiGeLeaf_CloverLR[det][l] = new G4PVPlacement(rmC, //rotation + PVPBuffer = new G4PVPlacement(rmC, // rotation + G4ThreeVector(leafX, leafY, geLeaf_PosZ), + logicGeLeaf_CloverLR[det][l], // its logical volume + "Clover", // detName[det].data(), //its name + logicVacuum_CloverLR[det], // its mother + true, // no boolean operat + det * 4 + l, // copy number + true); // overlap check + + // physiPassivated_CloverLR[det][l] = new G4PVPlacement(0, //rotation + PVPBuffer = new G4PVPlacement(0, // rotation + G4ThreeVector(-fHole_dX_PhaseII, -fHole_dY_PhaseII, fContact_dZ_GREAT), + logicPassivated_CloverLR[det][l], "GePassivated", logicGeLeaf_CloverLR[det][l], + false, det * 4 + l, true); + + // physiContact_CloverLR[det][l] = new G4PVPlacement(0, //rotation + PVPBuffer = new G4PVPlacement(0, // rotation + G4ThreeVector(0. * mm, 0. * mm, 0.0 * mm), //-fContact_dZ_GREAT), + logicContact_CloverLR[det][l], "LiContact", logicPassivated_CloverLR[det][l], false, + det * 4 + l, true); + + // physiBoreHole_CloverLR[det][l] = new G4PVPlacement(0, //rotation + PVPBuffer = new G4PVPlacement(0, // rotation + G4ThreeVector(0. * mm, 0. * mm, 0.0 * mm), //-fContact_dZ_GREAT), + logicBoreHole_CloverLR[det][l], "BoreHole", logicContact_CloverLR[det][l], false, + det * 4 + l, true); } } - //define the visual attributes - G4VisAttributes* visAttAlCap = new G4VisAttributes( G4Colour(0.9,0.9,0.9) ); + // define the visual attributes + G4VisAttributes* visAttAlCap = new G4VisAttributes(G4Colour(0.9, 0.9, 0.9)); visAttAlCap->SetVisibility(true); visAttAlCap->SetForceWireframe(true); - - G4VisAttributes* visAttGeVac = new G4VisAttributes( G4Colour(0.9,1.0,0.9) ); + + G4VisAttributes* visAttGeVac = new G4VisAttributes(G4Colour(0.9, 1.0, 0.9)); visAttGeVac->SetForceWireframe(true); visAttGeVac->SetVisibility(true); - - G4VisAttributes* visAttActive = new G4VisAttributes( G4Colour(1.0,1.0,0.0) ); + + G4VisAttributes* visAttActive = new G4VisAttributes(G4Colour(1.0, 1.0, 0.0)); visAttActive->SetForceWireframe(true); visAttActive->SetVisibility(true); - - G4VisAttributes* visAttPassive = new G4VisAttributes(G4Colour(0.0,1.0,1.0) ); + + G4VisAttributes* visAttPassive = new G4VisAttributes(G4Colour(0.0, 1.0, 1.0)); visAttPassive->SetForceWireframe(true); visAttPassive->SetVisibility(true); - - G4VisAttributes* visAttLiContact = new G4VisAttributes(G4Colour(1.0,0.0,1.0) ); + + G4VisAttributes* visAttLiContact = new G4VisAttributes(G4Colour(1.0, 0.0, 1.0)); visAttLiContact->SetVisibility(true); - - G4VisAttributes* visAttHole = new G4VisAttributes( G4Colour(0.0,0.0,1.0) ); + + G4VisAttributes* visAttHole = new G4VisAttributes(G4Colour(0.0, 0.0, 1.0)); visAttHole->SetVisibility(true); - - for(G4int det = 0; det < 2; det++) { + + for (G4int det = 0; det < 2; det++) { logicEndCap_CloverLR[det]->SetVisAttributes(visAttAlCap); logicVacuum_CloverLR[det]->SetVisAttributes(visAttGeVac); - for(G4int l = 0; l < 4; l++) { + for (G4int l = 0; l < 4; l++) { logicGeLeaf_CloverLR[det][l]->SetVisAttributes(visAttActive); logicPassivated_CloverLR[det][l]->SetVisAttributes(visAttPassive); logicContact_CloverLR[det][l]->SetVisAttributes(visAttLiContact); @@ -2999,142 +2871,132 @@ void Chamber::Place_GREAT_Left_and_Right(G4LogicalVolume* world) } } - - //------------------------------------------------------------------ -void Chamber::Place_PhaseII_LookingUpstream(G4LogicalVolume* world) -{ +void Chamber::Place_PhaseII_LookingUpstream(G4LogicalVolume* world) { //================================================================================= // The positioning for boolean solids is odd : for this det it is with respect to the Taper-part : - //setting the z-position as endCapTaperL/2 puts the front face at z = 0 mm + // setting the z-position as endCapTaperL/2 puts the front face at z = 0 mm //================================================================================= - G4double endCap_PosZ = fEndCapTaperL_PhaseII/2. + 3.0*mm; + G4double endCap_PosZ = fEndCapTaperL_PhaseII / 2. + 3.0 * mm; G4double vacuum_PosZ = fVacuumPosZ_PhaseII; G4double geLeaf_PosZ = fGeLeafPosZ_PhaseII; - - logicEndCap_CloverU = new G4LogicalVolume(solidEndCap_PhaseII, endCapMaterial, "clover_EC", 0, 0, 0); - logicVacuum_CloverU = new G4LogicalVolume(solidVacuum_PhaseII, vacuumMaterial, "clover_Vac", 0, 0, 0); - - for(G4int l = 0; l < 4; l++) { - logicGeLeaf_CloverU[l] = new G4LogicalVolume(solidGeLeaf_PhaseII, geMaterial, "clover_Leaf", 0, 0, 0); - logicPassivated_CloverU[l] = new G4LogicalVolume(solidPassivated_PhaseII, geMaterial, "passivatedGe", 0, 0, 0); - logicContact_CloverU[l] = new G4LogicalVolume(solidContact_PhaseII, contactMaterial, "inner_contact", 0, 0, 0); - logicBoreHole_CloverU[l] = new G4LogicalVolume(solidBoreHole_PhaseII, vacuumMaterial, "bore_hole", 0, 0, 0); + + logicEndCap_CloverU = new G4LogicalVolume(solidEndCap_PhaseII, endCapMaterial, "clover_EC", 0, 0, 0); + logicVacuum_CloverU = new G4LogicalVolume(solidVacuum_PhaseII, vacuumMaterial, "clover_Vac", 0, 0, 0); + + for (G4int l = 0; l < 4; l++) { + logicGeLeaf_CloverU[l] = new G4LogicalVolume(solidGeLeaf_PhaseII, geMaterial, "clover_Leaf", 0, 0, 0); + logicPassivated_CloverU[l] = new G4LogicalVolume(solidPassivated_PhaseII, geMaterial, "passivatedGe", 0, 0, 0); + logicContact_CloverU[l] = new G4LogicalVolume(solidContact_PhaseII, contactMaterial, "inner_contact", 0, 0, 0); + logicBoreHole_CloverU[l] = new G4LogicalVolume(solidBoreHole_PhaseII, vacuumMaterial, "bore_hole", 0, 0, 0); } - //Physical placement of these solids...... - //traslate position: the centre of the DSSD has been placed @ Y = 0.0*mm - //physiEndCap_CloverU = new G4PVPlacement(0, //no rotation - PVPBuffer = new G4PVPlacement(0, //no rotation - G4ThreeVector(0.*mm, 0.0*mm, endCap_PosZ), - logicEndCap_CloverU,//its logical volume - "Clover_EC", //its name - world, //its mother - true, //no boolean operat - 12, //copy number - true); //overlap check - - //physiVacuum_CloverU = new G4PVPlacement(0, //rotation - PVPBuffer = new G4PVPlacement(0, //rotation - G4ThreeVector(0.*mm,0.*mm,vacuum_PosZ), - logicVacuum_CloverU, //its logical volume - "Clover_Vac", //its name - logicEndCap_CloverU, //its mother - true, //no boolean operat - 12, //copy number - true); //overlap check - - //Now for the placement of the leaves in each clover...... + // Physical placement of these solids...... + // traslate position: the centre of the DSSD has been placed @ Y = 0.0*mm + // physiEndCap_CloverU = new G4PVPlacement(0, //no rotation + PVPBuffer = new G4PVPlacement(0, // no rotation + G4ThreeVector(0. * mm, 0.0 * mm, endCap_PosZ), + logicEndCap_CloverU, // its logical volume + "Clover_EC", // its name + world, // its mother + true, // no boolean operat + 12, // copy number + true); // overlap check + + // physiVacuum_CloverU = new G4PVPlacement(0, //rotation + PVPBuffer = new G4PVPlacement(0, // rotation + G4ThreeVector(0. * mm, 0. * mm, vacuum_PosZ), + logicVacuum_CloverU, // its logical volume + "Clover_Vac", // its name + logicEndCap_CloverU, // its mother + true, // no boolean operat + 12, // copy number + true); // overlap check + + // Now for the placement of the leaves in each clover...... G4RotationMatrix* rmC; - G4double dPos = fGeLeaf_dX_PhaseII + fGapBetweenLeaves_PhaseII/2.; + G4double dPos = fGeLeaf_dX_PhaseII + fGapBetweenLeaves_PhaseII / 2.; G4double leafX; G4double leafY; G4double leafZ; - - for(G4int l = 0; l < 4; l++) { - //the rotation + + for (G4int l = 0; l < 4; l++) { + // the rotation rmC = new G4RotationMatrix; - rmC->set(0,0,0); - rmC->rotateZ(90.*degree*(4-l)); + rmC->set(0, 0, 0); + rmC->rotateZ(90. * degree * (4 - l)); rmC->invert(); - //the x-translation - if(l < 2) { + // the x-translation + if (l < 2) { leafX = dPos; - } else { + } + else { leafX = -dPos; } - //the y-translation - if(l == 0 || l == 3 ) { + // the y-translation + if (l == 0 || l == 3) { leafY = dPos; - } else { + } + else { leafY = -dPos; } - //the z-translation + // the z-translation leafZ = geLeaf_PosZ; - - - //physiGeLeaf_CloverU[l] = new G4PVPlacement(rmC, //rotation - PVPBuffer = new G4PVPlacement(rmC, //rotation - G4ThreeVector(leafX, leafY, leafZ), - logicGeLeaf_CloverU[l], //its logical volume - "Clover", //its name - logicVacuum_CloverU, //its mother - true, //no boolean operat - 12+l, //copy number - true); //overlap check - - //physiPassivated_CloverU[l] = new G4PVPlacement(0, //rotation - PVPBuffer = new G4PVPlacement(0, //rotation - G4ThreeVector(-fHole_dX_PhaseII, -fHole_dY_PhaseII, fContact_dZ_PhaseII), - logicPassivated_CloverU[l], - "GePassivated", - logicGeLeaf_CloverU[l], - false,12+l,true); - - //physiContact_CloverU[l] = new G4PVPlacement(0, //rotation - PVPBuffer = new G4PVPlacement(0, //rotation - G4ThreeVector(0.*mm,0.*mm, 0.0*mm),//-fContact_dZ_GREAT), - logicContact_CloverU[l], - "LiContact", - logicPassivated_CloverU[l], - false,12+l,true); - - //physiBoreHole_CloverU[l] = new G4PVPlacement(0, //rotation - PVPBuffer = new G4PVPlacement(0, //rotation - G4ThreeVector(0.*mm,0.*mm, 0.0*mm), - logicBoreHole_CloverU[l], - "BoreHole", - logicContact_CloverU[l], - false,12+l,true); - + + // physiGeLeaf_CloverU[l] = new G4PVPlacement(rmC, //rotation + PVPBuffer = new G4PVPlacement(rmC, // rotation + G4ThreeVector(leafX, leafY, leafZ), + logicGeLeaf_CloverU[l], // its logical volume + "Clover", // its name + logicVacuum_CloverU, // its mother + true, // no boolean operat + 12 + l, // copy number + true); // overlap check + + // physiPassivated_CloverU[l] = new G4PVPlacement(0, //rotation + PVPBuffer = + new G4PVPlacement(0, // rotation + G4ThreeVector(-fHole_dX_PhaseII, -fHole_dY_PhaseII, fContact_dZ_PhaseII), + logicPassivated_CloverU[l], "GePassivated", logicGeLeaf_CloverU[l], false, 12 + l, true); + + // physiContact_CloverU[l] = new G4PVPlacement(0, //rotation + PVPBuffer = + new G4PVPlacement(0, // rotation + G4ThreeVector(0. * mm, 0. * mm, 0.0 * mm), //-fContact_dZ_GREAT), + logicContact_CloverU[l], "LiContact", logicPassivated_CloverU[l], false, 12 + l, true); + + // physiBoreHole_CloverU[l] = new G4PVPlacement(0, //rotation + PVPBuffer = new G4PVPlacement(0, // rotation + G4ThreeVector(0. * mm, 0. * mm, 0.0 * mm), logicBoreHole_CloverU[l], "BoreHole", + logicContact_CloverU[l], false, 12 + l, true); } - //define the visual attributes - G4VisAttributes* visAttAlCap = new G4VisAttributes( G4Colour(0.9,0.9,0.9) ); + // define the visual attributes + G4VisAttributes* visAttAlCap = new G4VisAttributes(G4Colour(0.9, 0.9, 0.9)); visAttAlCap->SetVisibility(true); visAttAlCap->SetForceWireframe(true); - - G4VisAttributes* visAttGeVac = new G4VisAttributes( G4Colour(0.9,1.0,0.9) ); + + G4VisAttributes* visAttGeVac = new G4VisAttributes(G4Colour(0.9, 1.0, 0.9)); visAttGeVac->SetForceWireframe(true); visAttGeVac->SetVisibility(true); - - G4VisAttributes* visAttActive = new G4VisAttributes( G4Colour(1.0,1.0,0.0) ); + + G4VisAttributes* visAttActive = new G4VisAttributes(G4Colour(1.0, 1.0, 0.0)); visAttActive->SetForceWireframe(true); visAttActive->SetVisibility(true); - - G4VisAttributes* visAttPassive = new G4VisAttributes(G4Colour(0.0,1.0,1.0) ); + + G4VisAttributes* visAttPassive = new G4VisAttributes(G4Colour(0.0, 1.0, 1.0)); visAttPassive->SetForceWireframe(true); visAttPassive->SetVisibility(true); - - G4VisAttributes* visAttLiContact = new G4VisAttributes(G4Colour(1.0,0.0,1.0) ); + + G4VisAttributes* visAttLiContact = new G4VisAttributes(G4Colour(1.0, 0.0, 1.0)); visAttLiContact->SetVisibility(true); - - G4VisAttributes* visAttHole = new G4VisAttributes( G4Colour(0.0,0.0,1.0) ); + + G4VisAttributes* visAttHole = new G4VisAttributes(G4Colour(0.0, 0.0, 1.0)); visAttHole->SetVisibility(true); - + logicEndCap_CloverU->SetVisAttributes(visAttAlCap); logicVacuum_CloverU->SetVisAttributes(visAttGeVac); - for(G4int l = 0; l < 4; l++) { + for (G4int l = 0; l < 4; l++) { logicGeLeaf_CloverU[l]->SetVisAttributes(visAttActive); logicPassivated_CloverU[l]->SetVisAttributes(visAttPassive); logicContact_CloverU[l]->SetVisAttributes(visAttLiContact); @@ -3145,139 +3007,131 @@ void Chamber::Place_PhaseII_LookingUpstream(G4LogicalVolume* world) //------------------------------------------------------------------ // This is just as a comparison with the current position //------------------------------------------------------------------ -void Chamber::Place_GREAT_LookingUpstream(G4LogicalVolume* world) -{ +void Chamber::Place_GREAT_LookingUpstream(G4LogicalVolume* world) { //================================================================================= // The positioning for boolean solids is odd : for this det it is with respect to the Taper-part : - //setting the z-position as endCapTaperL/2 puts the front face at z = 0 mm + // setting the z-position as endCapTaperL/2 puts the front face at z = 0 mm //================================================================================= - G4double endCap_PosZ = fEndCapTaperL_GREAT/2. + 3.0*mm; + G4double endCap_PosZ = fEndCapTaperL_GREAT / 2. + 3.0 * mm; G4double vacuum_PosZ = fVacuumPosZ_GREAT; G4double geLeaf_PosZ = fGeLeafPosZ_GREAT; - - logicEndCap_CloverU = new G4LogicalVolume(solidEndCap_GREAT, endCapMaterial, "clover_EC", 0, 0, 0); - logicVacuum_CloverU = new G4LogicalVolume(solidVacuum_GREAT, vacuumMaterial, "clover_Vac", 0, 0, 0); - - for(G4int l = 0; l < 4; l++) { - logicGeLeaf_CloverU[l] = new G4LogicalVolume(solidGeLeaf_GREAT, geMaterial, "clover_Leaf", 0, 0, 0); - logicPassivated_CloverU[l] = new G4LogicalVolume(solidPassivated_GREAT, geMaterial, "passivatedGe", 0, 0, 0); - logicContact_CloverU[l] = new G4LogicalVolume(solidContact_GREAT, contactMaterial, "inner_contact", 0, 0, 0); - logicBoreHole_CloverU[l] = new G4LogicalVolume(solidBoreHole_GREAT, vacuumMaterial, "bore_hole", 0, 0, 0); + + logicEndCap_CloverU = new G4LogicalVolume(solidEndCap_GREAT, endCapMaterial, "clover_EC", 0, 0, 0); + logicVacuum_CloverU = new G4LogicalVolume(solidVacuum_GREAT, vacuumMaterial, "clover_Vac", 0, 0, 0); + + for (G4int l = 0; l < 4; l++) { + logicGeLeaf_CloverU[l] = new G4LogicalVolume(solidGeLeaf_GREAT, geMaterial, "clover_Leaf", 0, 0, 0); + logicPassivated_CloverU[l] = new G4LogicalVolume(solidPassivated_GREAT, geMaterial, "passivatedGe", 0, 0, 0); + logicContact_CloverU[l] = new G4LogicalVolume(solidContact_GREAT, contactMaterial, "inner_contact", 0, 0, 0); + logicBoreHole_CloverU[l] = new G4LogicalVolume(solidBoreHole_GREAT, vacuumMaterial, "bore_hole", 0, 0, 0); } - //Physical placement of these solids...... - //traslate position: the centre of the DSSD has been placed @ Y = 0.0*mm - //physiEndCap_CloverU = new G4PVPlacement(0, //no rotation - PVPBuffer = new G4PVPlacement(0, //no rotation - G4ThreeVector(0.*mm, 0.0*mm, endCap_PosZ), - logicEndCap_CloverU,//its logical volume - "Clover_EC", //its name - world, //its mother - true, //no boolean operat - 12, //copy number - true); //overlap check - - //physiVacuum_CloverU = new G4PVPlacement(0, //rotation - PVPBuffer = new G4PVPlacement(0, //rotation - G4ThreeVector(0.*mm,0.*mm,vacuum_PosZ), - logicVacuum_CloverU, //its logical volume - "Clover_Vac", //its name - logicEndCap_CloverU, //its mother - true, //no boolean operat - 12, //copy number - true); //overlap check - - //Now for the placement of the leaves in each clover...... + // Physical placement of these solids...... + // traslate position: the centre of the DSSD has been placed @ Y = 0.0*mm + // physiEndCap_CloverU = new G4PVPlacement(0, //no rotation + PVPBuffer = new G4PVPlacement(0, // no rotation + G4ThreeVector(0. * mm, 0.0 * mm, endCap_PosZ), + logicEndCap_CloverU, // its logical volume + "Clover_EC", // its name + world, // its mother + true, // no boolean operat + 12, // copy number + true); // overlap check + + // physiVacuum_CloverU = new G4PVPlacement(0, //rotation + PVPBuffer = new G4PVPlacement(0, // rotation + G4ThreeVector(0. * mm, 0. * mm, vacuum_PosZ), + logicVacuum_CloverU, // its logical volume + "Clover_Vac", // its name + logicEndCap_CloverU, // its mother + true, // no boolean operat + 12, // copy number + true); // overlap check + + // Now for the placement of the leaves in each clover...... G4RotationMatrix* rmC; - G4double dPos = fGeLeaf_dX_GREAT + fGapBetweenLeaves_GREAT/2.; + G4double dPos = fGeLeaf_dX_GREAT + fGapBetweenLeaves_GREAT / 2.; G4double leafX; G4double leafY; G4double leafZ; - - for(G4int l = 0; l < 4; l++) { - //the rotation + + for (G4int l = 0; l < 4; l++) { + // the rotation rmC = new G4RotationMatrix; - rmC->set(0,0,0); - rmC->rotateZ(90.*degree*(4-l)); + rmC->set(0, 0, 0); + rmC->rotateZ(90. * degree * (4 - l)); rmC->invert(); - //the x-translation - if(l < 2) { + // the x-translation + if (l < 2) { leafX = dPos; - } else { + } + else { leafX = -dPos; } - //the y-translation - if(l == 0 || l == 3 ) { + // the y-translation + if (l == 0 || l == 3) { leafY = dPos; - } else { + } + else { leafY = -dPos; } - //the z-translation + // the z-translation leafZ = geLeaf_PosZ; - - - //physiGeLeaf_CloverU[l] = new G4PVPlacement(rmC, //rotation - PVPBuffer = new G4PVPlacement(rmC, //rotation - G4ThreeVector(leafX, leafY, leafZ), - logicGeLeaf_CloverU[l], //its logical volume - "Clover", //its name - logicVacuum_CloverU, //its mother - true, //no boolean operat - 12+l, //copy number - true); //overlap check - - //physiPassivated_CloverU[l] = new G4PVPlacement(0, //rotation - PVPBuffer = new G4PVPlacement(0, //rotation - G4ThreeVector(fHole_dX_GREAT, fHole_dY_GREAT, fContact_dZ_GREAT), - logicPassivated_CloverU[l], - "GePassivated", - logicGeLeaf_CloverU[l], - false,12+l,true); - - //physiContact_CloverU[l] = new G4PVPlacement(0, //rotation - PVPBuffer = new G4PVPlacement(0, //rotation - G4ThreeVector(0.*mm,0.*mm, 0.0*mm),//-fContact_dZ_GREAT), - logicContact_CloverU[l], - "LiContact", - logicPassivated_CloverU[l], - false,12+l,true); - - //physiBoreHole_CloverU[l] = new G4PVPlacement(0, //rotation - PVPBuffer = new G4PVPlacement(0, //rotation - G4ThreeVector(0.*mm,0.*mm, 0.0*mm), - logicBoreHole_CloverU[l], - "BoreHole", - logicContact_CloverU[l], - false,12+l,true); - + + // physiGeLeaf_CloverU[l] = new G4PVPlacement(rmC, //rotation + PVPBuffer = new G4PVPlacement(rmC, // rotation + G4ThreeVector(leafX, leafY, leafZ), + logicGeLeaf_CloverU[l], // its logical volume + "Clover", // its name + logicVacuum_CloverU, // its mother + true, // no boolean operat + 12 + l, // copy number + true); // overlap check + + // physiPassivated_CloverU[l] = new G4PVPlacement(0, //rotation + PVPBuffer = + new G4PVPlacement(0, // rotation + G4ThreeVector(fHole_dX_GREAT, fHole_dY_GREAT, fContact_dZ_GREAT), logicPassivated_CloverU[l], + "GePassivated", logicGeLeaf_CloverU[l], false, 12 + l, true); + + // physiContact_CloverU[l] = new G4PVPlacement(0, //rotation + PVPBuffer = + new G4PVPlacement(0, // rotation + G4ThreeVector(0. * mm, 0. * mm, 0.0 * mm), //-fContact_dZ_GREAT), + logicContact_CloverU[l], "LiContact", logicPassivated_CloverU[l], false, 12 + l, true); + + // physiBoreHole_CloverU[l] = new G4PVPlacement(0, //rotation + PVPBuffer = new G4PVPlacement(0, // rotation + G4ThreeVector(0. * mm, 0. * mm, 0.0 * mm), logicBoreHole_CloverU[l], "BoreHole", + logicContact_CloverU[l], false, 12 + l, true); } - //define the visual attributes - G4VisAttributes* visAttAlCap = new G4VisAttributes( G4Colour(0.9,0.9,0.9) ); + // define the visual attributes + G4VisAttributes* visAttAlCap = new G4VisAttributes(G4Colour(0.9, 0.9, 0.9)); visAttAlCap->SetVisibility(true); visAttAlCap->SetForceWireframe(true); - - G4VisAttributes* visAttGeVac = new G4VisAttributes( G4Colour(0.9,1.0,0.9) ); + + G4VisAttributes* visAttGeVac = new G4VisAttributes(G4Colour(0.9, 1.0, 0.9)); visAttGeVac->SetForceWireframe(true); visAttGeVac->SetVisibility(true); - - G4VisAttributes* visAttActive = new G4VisAttributes( G4Colour(1.0,1.0,0.0) ); + + G4VisAttributes* visAttActive = new G4VisAttributes(G4Colour(1.0, 1.0, 0.0)); visAttActive->SetForceWireframe(true); visAttActive->SetVisibility(true); - - G4VisAttributes* visAttPassive = new G4VisAttributes(G4Colour(0.0,1.0,1.0) ); + + G4VisAttributes* visAttPassive = new G4VisAttributes(G4Colour(0.0, 1.0, 1.0)); visAttPassive->SetForceWireframe(true); visAttPassive->SetVisibility(true); - - G4VisAttributes* visAttLiContact = new G4VisAttributes(G4Colour(1.0,0.0,1.0) ); + + G4VisAttributes* visAttLiContact = new G4VisAttributes(G4Colour(1.0, 0.0, 1.0)); visAttLiContact->SetVisibility(true); - - G4VisAttributes* visAttHole = new G4VisAttributes( G4Colour(0.0,0.0,1.0) ); + + G4VisAttributes* visAttHole = new G4VisAttributes(G4Colour(0.0, 0.0, 1.0)); visAttHole->SetVisibility(true); - + logicEndCap_CloverU->SetVisAttributes(visAttAlCap); logicVacuum_CloverU->SetVisAttributes(visAttGeVac); - for(G4int l = 0; l < 4; l++) { + for (G4int l = 0; l < 4; l++) { logicGeLeaf_CloverU[l]->SetVisAttributes(visAttActive); logicPassivated_CloverU[l]->SetVisAttributes(visAttPassive); logicContact_CloverU[l]->SetVisAttributes(visAttLiContact); @@ -3288,325 +3142,318 @@ void Chamber::Place_GREAT_LookingUpstream(G4LogicalVolume* world) //--------------------------------------------------------------------- // Create the solids defining Phase-II Clovers //--------------------------------------------------------------------- -void Chamber::CreateCloverIISolids() -{ - //An approximate CloverII +void Chamber::CreateCloverIISolids() { + // An approximate CloverII G4cout << G4endl << "Constructing archetypal PhaseII Clover" << G4endl; - + //--------------------------------------------------------- - //end-cap - G4double endCapFrontThickness = 1.2*mm; //was 1.5 - G4double endCapTaperThickness = 1.5*mm; - G4double endCapSideThickness = 1.5*mm; - - G4double GeGap = fEndCap2Ge_PhaseII; - G4double taperAngle = 7.0*degree; - - G4double endCapTotalL = fTotalGeL_PhaseII + GeGap + endCapFrontThickness + 5.*mm; //+ Gap at rear end - G4double endCapFrontD = 43.5*mm; - G4double endCapBackD = 50.5*mm; - G4double endCapTaperL = 55.0*mm; - - G4double endCapBoxL = endCapTotalL - endCapTaperL; - - //the tapered part - G4Trap* solidTaperedCloverEC - = new G4Trap("taperedCloverEC", - endCapTaperL/2., //Half z-length [pDz] - 0.00*degree, //Polar angle of line joining centres of the faces @ -/+pDz - 14.0*degree, //aequivalent zimuthal angle - endCapFrontD, //pDy1 half y length at -pDz - endCapFrontD, //pDx1 half x length at -pDz, -pDy1 - endCapFrontD, //pDx2 half x length at -pDz, +pDy1 - 0.00*degree,//pAlpha1 wrt y-axis from the centre of the side (lower endcap) - endCapBackD, //pDy2 half y length at +pDz - endCapBackD, //pDx3 half x length at +pDz, -pDy2 - endCapBackD, //pDx4 half x length at +pDz, +pDy2 - 0.00*degree); //pAlpha2 wrt y-axis from the centre of the side (upper endcap) - - //the rectangular part..... - G4Box* endCapBox = new G4Box("endCapBox",endCapBackD,endCapBackD,endCapBoxL/2.); - G4ThreeVector transECBox( 0.*mm, 0.*mm, endCapTaperL/2.+endCapBoxL/2.); - - //add the two together - solidEndCap_PhaseII = new G4UnionSolid("Box+Taper",solidTaperedCloverEC,endCapBox,0,transECBox); - //need the taperL for placement + // end-cap + G4double endCapFrontThickness = 1.2 * mm; // was 1.5 + G4double endCapTaperThickness = 1.5 * mm; + G4double endCapSideThickness = 1.5 * mm; + + G4double GeGap = fEndCap2Ge_PhaseII; + G4double taperAngle = 7.0 * degree; + + G4double endCapTotalL = fTotalGeL_PhaseII + GeGap + endCapFrontThickness + 5. * mm; //+ Gap at rear end + G4double endCapFrontD = 43.5 * mm; + G4double endCapBackD = 50.5 * mm; + G4double endCapTaperL = 55.0 * mm; + + G4double endCapBoxL = endCapTotalL - endCapTaperL; + + // the tapered part + G4Trap* solidTaperedCloverEC = + new G4Trap("taperedCloverEC", + endCapTaperL / 2., // Half z-length [pDz] + 0.00 * degree, // Polar angle of line joining centres of the faces @ -/+pDz + 14.0 * degree, // aequivalent zimuthal angle + endCapFrontD, // pDy1 half y length at -pDz + endCapFrontD, // pDx1 half x length at -pDz, -pDy1 + endCapFrontD, // pDx2 half x length at -pDz, +pDy1 + 0.00 * degree, // pAlpha1 wrt y-axis from the centre of the side (lower endcap) + endCapBackD, // pDy2 half y length at +pDz + endCapBackD, // pDx3 half x length at +pDz, -pDy2 + endCapBackD, // pDx4 half x length at +pDz, +pDy2 + 0.00 * degree); // pAlpha2 wrt y-axis from the centre of the side (upper endcap) + + // the rectangular part..... + G4Box* endCapBox = new G4Box("endCapBox", endCapBackD, endCapBackD, endCapBoxL / 2.); + G4ThreeVector transECBox(0. * mm, 0. * mm, endCapTaperL / 2. + endCapBoxL / 2.); + + // add the two together + solidEndCap_PhaseII = new G4UnionSolid("Box+Taper", solidTaperedCloverEC, endCapBox, 0, transECBox); + // need the taperL for placement fEndCapTaperL_PhaseII = endCapTaperL; - - + //--------------------------------------------------------- - //end-cap inner vacuum - G4double endCapDelta_1 = endCapTaperThickness/cos(taperAngle) - endCapFrontThickness*tan(taperAngle); - G4double endCapDelta_2 = ( endCapSideThickness - (endCapTaperThickness*sin(taperAngle)*tan(taperAngle) + - endCapTaperThickness*cos(taperAngle) ) )/tan(taperAngle); - + // end-cap inner vacuum + G4double endCapDelta_1 = endCapTaperThickness / cos(taperAngle) - endCapFrontThickness * tan(taperAngle); + G4double endCapDelta_2 = (endCapSideThickness - (endCapTaperThickness * sin(taperAngle) * tan(taperAngle) + + endCapTaperThickness * cos(taperAngle))) / + tan(taperAngle); + G4cout << endCapDelta_1 << " " << endCapDelta_2 << endl; - - G4double endCapVacTaperL = endCapTaperL - endCapFrontThickness;// - endCapDelta_2; - G4double endCapVacBoxL = endCapBoxL - endCapFrontThickness; + + G4double endCapVacTaperL = endCapTaperL - endCapFrontThickness; // - endCapDelta_2; + G4double endCapVacBoxL = endCapBoxL - endCapFrontThickness; G4double endCapVacTotalL = endCapVacBoxL + endCapVacTaperL; G4double endCapVacFrontD = endCapFrontD - endCapDelta_1; - G4double endCapVacBackD = endCapBackD - endCapSideThickness; - - //position of vacuum wrt end-cap - fVacuumPosZ_PhaseII = (-endCapTotalL + endCapVacTotalL )/2. + 1.5*endCapFrontThickness; - - //tapered part... - G4Trap* solidTaperVac - = new G4Trap("cloverTaperVac", - endCapVacTaperL/2., //Half z-length [pDz] - 0.00*degree, //Polar angle of line joining centres of the faces @ -/+pDz - 14.0*degree, //aequivalent zimuthal angle - endCapVacFrontD, //pDy1 half y length at -pDz - endCapVacFrontD, //pDx1 half x length at -pDz, -pDy1 - endCapVacFrontD, //pDx2 half x length at -pDz, +pDy1 - 0.00*degree,//pAlpha1 wrt y-axis from the centre of the side (lower endcap) - endCapVacBackD, //pDy2 half y length at +pDz - endCapVacBackD, //pDx3 half x length at +pDz, -pDy2 - endCapVacBackD, //pDx4 half x length at +pDz, +pDy2 - 0.00*degree); //pAlpha2 wrt y-axis from the centre of the side (upper endcap) - + G4double endCapVacBackD = endCapBackD - endCapSideThickness; + + // position of vacuum wrt end-cap + fVacuumPosZ_PhaseII = (-endCapTotalL + endCapVacTotalL) / 2. + 1.5 * endCapFrontThickness; + + // tapered part... + G4Trap* solidTaperVac = new G4Trap("cloverTaperVac", + endCapVacTaperL / 2., // Half z-length [pDz] + 0.00 * degree, // Polar angle of line joining centres of the faces @ -/+pDz + 14.0 * degree, // aequivalent zimuthal angle + endCapVacFrontD, // pDy1 half y length at -pDz + endCapVacFrontD, // pDx1 half x length at -pDz, -pDy1 + endCapVacFrontD, // pDx2 half x length at -pDz, +pDy1 + 0.00 * degree, // pAlpha1 wrt y-axis from the centre of the side (lower endcap) + endCapVacBackD, // pDy2 half y length at +pDz + endCapVacBackD, // pDx3 half x length at +pDz, -pDy2 + endCapVacBackD, // pDx4 half x length at +pDz, +pDy2 + 0.00 * degree); // pAlpha2 wrt y-axis from the centre of the side (upper endcap) + G4cout << endCapTotalL << " " << endCapVacTotalL << endl; - - //rectangular part - G4Box* endCapVacBox = new G4Box("endCapBox",endCapVacBackD,endCapVacBackD,endCapVacBoxL/2.); - G4ThreeVector transVacBox( 0.*mm, 0.*mm, (endCapVacTaperL/2.+endCapVacBoxL/2.-0.0001*mm)); - - //add them together - solidVacuum_PhaseII = new G4UnionSolid("Vac_Box+Taper",solidTaperVac,endCapVacBox,0,transVacBox); - + + // rectangular part + G4Box* endCapVacBox = new G4Box("endCapBox", endCapVacBackD, endCapVacBackD, endCapVacBoxL / 2.); + G4ThreeVector transVacBox(0. * mm, 0. * mm, (endCapVacTaperL / 2. + endCapVacBoxL / 2. - 0.0001 * mm)); + + // add them together + solidVacuum_PhaseII = new G4UnionSolid("Vac_Box+Taper", solidTaperVac, endCapVacBox, 0, transVacBox); //--------------------------------------------------------- - //The Ge crystal... - G4double GeTaperL = 36.0*mm; - G4double GeTotalL = fTotalGeL_PhaseII; //70.0 * mm; - G4double smallSquare = 41.0*mm; - G4double largeSquare = 45.5*mm; - - G4double transX = (largeSquare-smallSquare)/2.; - G4double transY = (largeSquare-smallSquare)/2.; - fHole_dX_PhaseII = transX; //transX /= 2.; - fHole_dY_PhaseII = transY; //transY /= 2.; - - //tapered part...... - G4Trap* solidTaper - = new G4Trap("cloverTaper", - GeTaperL/2., //Half ? z-length [pDz] - 5.05*degree, //Polar angle of line joining centres of the faces @ -/+pDz - 45.*degree, //equivalent azimuthal angle //DOES NOT MAKE SENSE !! - smallSquare/2., //pDy1 half y length at -pDz - smallSquare/2., //pDx1 half x length at -pDz, -pDy1 - smallSquare/2., //pDx2 half x length at -pDz, +pDy1 - 0.00*degree,//pAlpha1 wrt y-axis from the centre of the side (lower endcap) - largeSquare/2., //pDy2 half y length at +pDz - largeSquare/2., //pDx3 half x length at +pDz, -pDy2 - largeSquare/2., //pDx4 half x length at +pDz, +pDy2 - 0.0*degree); //pAlpha2 wrt y-axis from the centre of the side (upper endcap) - - //HERE !! - const G4int numZPlanesGe=4; // no. polycone planes + // The Ge crystal... + G4double GeTaperL = 36.0 * mm; + G4double GeTotalL = fTotalGeL_PhaseII; // 70.0 * mm; + G4double smallSquare = 41.0 * mm; + G4double largeSquare = 45.5 * mm; + + G4double transX = (largeSquare - smallSquare) / 2.; + G4double transY = (largeSquare - smallSquare) / 2.; + fHole_dX_PhaseII = transX; // transX /= 2.; + fHole_dY_PhaseII = transY; // transY /= 2.; + + // tapered part...... + G4Trap* solidTaper = new G4Trap("cloverTaper", + GeTaperL / 2., // Half ? z-length [pDz] + 5.05 * degree, // Polar angle of line joining centres of the faces @ -/+pDz + 45. * degree, // equivalent azimuthal angle //DOES NOT MAKE SENSE !! + smallSquare / 2., // pDy1 half y length at -pDz + smallSquare / 2., // pDx1 half x length at -pDz, -pDy1 + smallSquare / 2., // pDx2 half x length at -pDz, +pDy1 + 0.00 * degree, // pAlpha1 wrt y-axis from the centre of the side (lower endcap) + largeSquare / 2., // pDy2 half y length at +pDz + largeSquare / 2., // pDx3 half x length at +pDz, -pDy2 + largeSquare / 2., // pDx4 half x length at +pDz, +pDy2 + 0.0 * degree); // pAlpha2 wrt y-axis from the centre of the side (upper endcap) + + // HERE !! + const G4int numZPlanesGe = 4; // no. polycone planes G4double zPlaneGe[numZPlanesGe]; // positions of planes - zPlaneGe[0] = 0.00*mm; - zPlaneGe[1] = 2.06*mm; - zPlaneGe[2] = 5.00*mm; + zPlaneGe[0] = 0.00 * mm; + zPlaneGe[1] = 2.06 * mm; + zPlaneGe[2] = 5.00 * mm; zPlaneGe[3] = GeTaperL; G4double rInnerGe[numZPlanesGe]; // interior radii - rInnerGe[0] = rInnerGe[1] = rInnerGe[2] = rInnerGe[3] = 0.0*mm; + rInnerGe[0] = rInnerGe[1] = rInnerGe[2] = rInnerGe[3] = 0.0 * mm; G4double rOuterGe[numZPlanesGe]; // exterior radii - rOuterGe[0] = 20.5*mm; rOuterGe[1] = 23.54*mm; + rOuterGe[0] = 20.5 * mm; + rOuterGe[1] = 23.54 * mm; rOuterGe[2] = rOuterGe[3] = fCrystalR_PhaseII; - - - G4Polycone* solidCone = new G4Polycone("cloverCone", 0.0*degree, 360.0*degree, - numZPlanesGe, - zPlaneGe, - rInnerGe, - rOuterGe); - - G4ThreeVector transGeCone( -transX/2., -transY/2., -GeTaperL/2.); - G4IntersectionSolid* taperedCone = new G4IntersectionSolid("Taper+Cone",solidTaper,solidCone,0,transGeCone); - - //back part.... + + G4Polycone* solidCone = + new G4Polycone("cloverCone", 0.0 * degree, 360.0 * degree, numZPlanesGe, zPlaneGe, rInnerGe, rOuterGe); + + G4ThreeVector transGeCone(-transX / 2., -transY / 2., -GeTaperL / 2.); + G4IntersectionSolid* taperedCone = new G4IntersectionSolid("Taper+Cone", solidTaper, solidCone, 0, transGeCone); + + // back part.... G4double geBoxL = fTotalGeL_PhaseII - GeTaperL; - G4Box* GeBox = new G4Box("GeBox",largeSquare/2.,largeSquare/2.,geBoxL/2.); - G4Tubs* GeCyl = new G4Tubs("GeCyl",0.0*mm,fCrystalR_PhaseII,geBoxL/2.,0.*degree,360.*degree); - - G4ThreeVector transGeBox( transX, transY, 0.0*mm); - G4IntersectionSolid* backPart = new G4IntersectionSolid("Box+Cyl",GeCyl,GeBox,0,transGeBox); + G4Box* GeBox = new G4Box("GeBox", largeSquare / 2., largeSquare / 2., geBoxL / 2.); + G4Tubs* GeCyl = new G4Tubs("GeCyl", 0.0 * mm, fCrystalR_PhaseII, geBoxL / 2., 0. * degree, 360. * degree); - //add front and back - G4ThreeVector transBack( -transX/2., -transY/2., (GeTaperL/2.+geBoxL/2.)); - solidGeLeaf_PhaseII = new G4UnionSolid("germanium",taperedCone,backPart,0,transBack); + G4ThreeVector transGeBox(transX, transY, 0.0 * mm); + G4IntersectionSolid* backPart = new G4IntersectionSolid("Box+Cyl", GeCyl, GeBox, 0, transGeBox); - //z-position of Ge-leaf wrt vacuum - fGeLeafPosZ_PhaseII = -endCapVacTaperL/2. + GeTaperL/2. + GeGap - endCapFrontThickness; + // add front and back + G4ThreeVector transBack(-transX / 2., -transY / 2., (GeTaperL / 2. + geBoxL / 2.)); + solidGeLeaf_PhaseII = new G4UnionSolid("germanium", taperedCone, backPart, 0, transBack); - G4cout << "end-cap : box/2 " << endCapBoxL/2. << " taper/2 " << endCapTaperL/2. << " total/2 " << endCapTotalL << G4endl; - G4cout << "vacuum : box/2 " << endCapVacBoxL/2. << " taper/2 " << endCapVacTaperL/2. << " total/2 " << endCapVacTotalL << G4endl; - G4cout << "ge : box/2 " << geBoxL/2. << " taper/2 " << GeTaperL/2. << " total/2 " << GeTotalL << G4endl; + // z-position of Ge-leaf wrt vacuum + fGeLeafPosZ_PhaseII = -endCapVacTaperL / 2. + GeTaperL / 2. + GeGap - endCapFrontThickness; + G4cout << "end-cap : box/2 " << endCapBoxL / 2. << " taper/2 " << endCapTaperL / 2. << " total/2 " << endCapTotalL + << G4endl; + G4cout << "vacuum : box/2 " << endCapVacBoxL / 2. << " taper/2 " << endCapVacTaperL / 2. << " total/2 " + << endCapVacTotalL << G4endl; + G4cout << "ge : box/2 " << geBoxL / 2. << " taper/2 " << GeTaperL / 2. << " total/2 " << GeTotalL << G4endl; //------------------------------------------------------------------ // Inner bore hole + lithium contact + passivated Ge - G4double GeDepth = 15.00 * mm; //Hole dirilled to this far from face - G4double passiveThick = 0.5 * mm; //fPassiveThick_PhaseII; //passivated Ge - G4double contactThick = fContactThick_PhaseII; //Li contact - - G4double holeR = fHoleR_PhaseII; - G4double contactR = holeR + contactThick; - G4double passiveR = contactR + passiveThick; - G4double holeL = fTotalGeL_PhaseII - GeDepth; - G4double tubeL = holeL - holeR; - - //the same translation works for all the following rounded tubes - G4ThreeVector transSphere(0.01*mm, 0.01*mm, -tubeL/2.-0.1*mm); //if offsets are 0. it does not display !! - - //now add a passivated layer - G4Sphere* passivatedSphere = new G4Sphere("passSphere", 0.0*mm, passiveR, 0.*degree, 360.*degree, 0.*degree, 180.*degree); - G4Tubs* passivatedTube = new G4Tubs( "passTube", 0.0*mm, passiveR, tubeL/2., 0.*degree, 360.*degree); - solidPassivated_PhaseII = new G4UnionSolid("passivatedGe",passivatedTube,passivatedSphere,0,transSphere); - - //and the Li contact - G4Sphere* contactSphere = new G4Sphere("sphere1", 0.0*mm, contactR, 0.*deg, 360.*deg, 0.*deg, 180.*deg); - G4Tubs* contactTube = new G4Tubs( "tube1", 0.0*mm, contactR, tubeL/2., 0.*deg, 360.*deg); - solidContact_PhaseII = new G4UnionSolid("liContact",contactTube,contactSphere,0,transSphere); - - //bore out a hole - G4Sphere* boreSphere = new G4Sphere( "boreSphere", 0.0*mm, holeR, 0.*degree, 360.*degree, 0.*degree, 180.*degree); - G4Tubs* boreTube = new G4Tubs( "boreTube", 0.0*mm, holeR, tubeL/2., 0.*degree, 360.*degree); - solidBoreHole_PhaseII = new G4UnionSolid("boreHole",boreTube,boreSphere,0,transSphere); - - //save these for placements.... - fContact_dZ_PhaseII = holeL/2. - contactThick;// - passiveThick; - - //put corners @ (0,0) - fGeLeaf_dX_PhaseII = largeSquare/2. - transX/2.; + G4double GeDepth = 15.00 * mm; // Hole dirilled to this far from face + G4double passiveThick = 0.5 * mm; // fPassiveThick_PhaseII; //passivated Ge + G4double contactThick = fContactThick_PhaseII; // Li contact + + G4double holeR = fHoleR_PhaseII; + G4double contactR = holeR + contactThick; + G4double passiveR = contactR + passiveThick; + G4double holeL = fTotalGeL_PhaseII - GeDepth; + G4double tubeL = holeL - holeR; + + // the same translation works for all the following rounded tubes + G4ThreeVector transSphere(0.01 * mm, 0.01 * mm, -tubeL / 2. - 0.1 * mm); // if offsets are 0. it does not display !! + + // now add a passivated layer + G4Sphere* passivatedSphere = + new G4Sphere("passSphere", 0.0 * mm, passiveR, 0. * degree, 360. * degree, 0. * degree, 180. * degree); + G4Tubs* passivatedTube = new G4Tubs("passTube", 0.0 * mm, passiveR, tubeL / 2., 0. * degree, 360. * degree); + solidPassivated_PhaseII = new G4UnionSolid("passivatedGe", passivatedTube, passivatedSphere, 0, transSphere); + + // and the Li contact + G4Sphere* contactSphere = new G4Sphere("sphere1", 0.0 * mm, contactR, 0. * deg, 360. * deg, 0. * deg, 180. * deg); + G4Tubs* contactTube = new G4Tubs("tube1", 0.0 * mm, contactR, tubeL / 2., 0. * deg, 360. * deg); + solidContact_PhaseII = new G4UnionSolid("liContact", contactTube, contactSphere, 0, transSphere); + + // bore out a hole + G4Sphere* boreSphere = + new G4Sphere("boreSphere", 0.0 * mm, holeR, 0. * degree, 360. * degree, 0. * degree, 180. * degree); + G4Tubs* boreTube = new G4Tubs("boreTube", 0.0 * mm, holeR, tubeL / 2., 0. * degree, 360. * degree); + solidBoreHole_PhaseII = new G4UnionSolid("boreHole", boreTube, boreSphere, 0, transSphere); + + // save these for placements.... + fContact_dZ_PhaseII = holeL / 2. - contactThick; // - passiveThick; + + // put corners @ (0,0) + fGeLeaf_dX_PhaseII = largeSquare / 2. - transX / 2.; } - - - //--------------------------------------------------------------------- // Create the solids defining Phase-II Clovers //--------------------------------------------------------------------- -void Chamber::CreateGREATCloverSolids() -{ - //An approximate CloverII +void Chamber::CreateGREATCloverSolids() { + // An approximate CloverII G4cout << G4endl << "Constructing archetypal GREAT Clover" << G4endl; //--------------------------------------------------------- - //end-cap - G4double endCapFrontThickness = 2.0*mm; - G4double endCapTaperThickness = 2.0*mm; - G4double endCapSideThickness = 2.0*mm; - - G4double GeGap = fEndCap2Ge_GREAT - endCapFrontThickness; - G4double taperAngle = 15.*degree; - - G4double endCapTotalL = fTotalGeL_GREAT + GeGap + 2.*endCapFrontThickness + 5.*mm; //+ Gap at rear end - G4double endCapFrontD = 60.09*mm; - G4double endCapBackD = 70.00*mm; - G4double endCapTaperL = 37.00*mm; - - G4double endCapBoxL = endCapTotalL - endCapTaperL; - - //the tapered part.... - G4Trap* solidTaperedCloverEC = new G4Trap("taperedCloverEC", - endCapTaperL/2., //Half z-length [pDz] - 0.00*degree, //Polar angle of line joining centres of the faces @ -/+pDz - 45.0*degree, //aequivalent zimuthal angle //Does not make sense ! - endCapFrontD, //pDy1 half y length at -pDz - endCapFrontD, //pDx1 half x length at -pDz, -pDy1 - endCapFrontD, //pDx2 half x length at -pDz, +pDy1 - 0.00*degree,//pAlpha1 wrt y-axis from the centre of the side (lower endcap) - endCapBackD, //pDy2 half y length at +pDz - endCapBackD, //pDx3 half x length at +pDz, -pDy2 - endCapBackD, //pDx4 half x length at +pDz, +pDy2 - 0.00*degree); //pAlpha2 wrt y-axis from the centre of the side (upper endcap) - - //the rectangular part..... - G4Box* endCapBox = new G4Box("endCapBox",endCapBackD,endCapBackD,endCapBoxL/2.); - G4ThreeVector transECBox( 0.*mm, 0.*mm, endCapTaperL/2.+endCapBoxL/2.); - - //add the two together - solidEndCap_GREAT = new G4UnionSolid("Box+Taper",solidTaperedCloverEC,endCapBox,0,transECBox); - //need the taperL for placement + // end-cap + G4double endCapFrontThickness = 2.0 * mm; + G4double endCapTaperThickness = 2.0 * mm; + G4double endCapSideThickness = 2.0 * mm; + + G4double GeGap = fEndCap2Ge_GREAT - endCapFrontThickness; + G4double taperAngle = 15. * degree; + + G4double endCapTotalL = fTotalGeL_GREAT + GeGap + 2. * endCapFrontThickness + 5. * mm; //+ Gap at rear end + G4double endCapFrontD = 60.09 * mm; + G4double endCapBackD = 70.00 * mm; + G4double endCapTaperL = 37.00 * mm; + + G4double endCapBoxL = endCapTotalL - endCapTaperL; + + // the tapered part.... + G4Trap* solidTaperedCloverEC = + new G4Trap("taperedCloverEC", + endCapTaperL / 2., // Half z-length [pDz] + 0.00 * degree, // Polar angle of line joining centres of the faces @ -/+pDz + 45.0 * degree, // aequivalent zimuthal angle //Does not make sense ! + endCapFrontD, // pDy1 half y length at -pDz + endCapFrontD, // pDx1 half x length at -pDz, -pDy1 + endCapFrontD, // pDx2 half x length at -pDz, +pDy1 + 0.00 * degree, // pAlpha1 wrt y-axis from the centre of the side (lower endcap) + endCapBackD, // pDy2 half y length at +pDz + endCapBackD, // pDx3 half x length at +pDz, -pDy2 + endCapBackD, // pDx4 half x length at +pDz, +pDy2 + 0.00 * degree); // pAlpha2 wrt y-axis from the centre of the side (upper endcap) + + // the rectangular part..... + G4Box* endCapBox = new G4Box("endCapBox", endCapBackD, endCapBackD, endCapBoxL / 2.); + G4ThreeVector transECBox(0. * mm, 0. * mm, endCapTaperL / 2. + endCapBoxL / 2.); + + // add the two together + solidEndCap_GREAT = new G4UnionSolid("Box+Taper", solidTaperedCloverEC, endCapBox, 0, transECBox); + // need the taperL for placement fEndCapTaperL_GREAT = endCapTaperL; - - + //--------------------------------------------------------- - //end-cap inner vacuum - G4double endCapDelta_1 = endCapTaperThickness/cos(taperAngle) - endCapFrontThickness*tan(taperAngle); - G4double endCapDelta_2 = ( endCapSideThickness - (endCapTaperThickness*sin(taperAngle)*tan(taperAngle) + - endCapTaperThickness*cos(taperAngle) ) )/tan(taperAngle); - + // end-cap inner vacuum + G4double endCapDelta_1 = endCapTaperThickness / cos(taperAngle) - endCapFrontThickness * tan(taperAngle); + G4double endCapDelta_2 = (endCapSideThickness - (endCapTaperThickness * sin(taperAngle) * tan(taperAngle) + + endCapTaperThickness * cos(taperAngle))) / + tan(taperAngle); + G4cout << endCapDelta_1 << " " << endCapDelta_2 << endl; - + G4double endCapVacTaperL = endCapTaperL - endCapFrontThickness - endCapDelta_2; - G4double endCapVacBoxL = endCapBoxL + endCapDelta_2; + G4double endCapVacBoxL = endCapBoxL + endCapDelta_2; G4double endCapVacTotalL = endCapVacBoxL + endCapVacTaperL; G4double endCapVacFrontD = endCapFrontD - endCapDelta_1; - G4double endCapVacBackD = endCapBackD - endCapSideThickness; - - //position of vacuum wrt end-cap - fVacuumPosZ_GREAT = (-endCapTotalL + endCapVacTotalL - endCapDelta_2)/2. + endCapFrontThickness; - - //tapered part... - G4Trap* solidTaperVac = new G4Trap("cloverTaperVac", - endCapVacTaperL/2., //Half z-length [pDz] - 0.00*degree, //Polar angle of line joining centres of the faces @ -/+pDz - 45.0*degree, //aequivalent zimuthal angle - endCapVacFrontD, //pDy1 half y length at -pDz - endCapVacFrontD, //pDx1 half x length at -pDz, -pDy1 - endCapVacFrontD, //pDx2 half x length at -pDz, +pDy1 - 0.00*degree,//pAlpha1 wrt y-axis from the centre of the side (lower endcap) - endCapVacBackD, //pDy2 half y length at +pDz - endCapVacBackD, //pDx3 half x length at +pDz, -pDy2 - endCapVacBackD, //pDx4 half x length at +pDz, +pDy2 - 0.00*degree); //pAlpha2 wrt y-axis from the centre of the side (upper endcap) - + G4double endCapVacBackD = endCapBackD - endCapSideThickness; + + // position of vacuum wrt end-cap + fVacuumPosZ_GREAT = (-endCapTotalL + endCapVacTotalL - endCapDelta_2) / 2. + endCapFrontThickness; + + // tapered part... + G4Trap* solidTaperVac = new G4Trap("cloverTaperVac", + endCapVacTaperL / 2., // Half z-length [pDz] + 0.00 * degree, // Polar angle of line joining centres of the faces @ -/+pDz + 45.0 * degree, // aequivalent zimuthal angle + endCapVacFrontD, // pDy1 half y length at -pDz + endCapVacFrontD, // pDx1 half x length at -pDz, -pDy1 + endCapVacFrontD, // pDx2 half x length at -pDz, +pDy1 + 0.00 * degree, // pAlpha1 wrt y-axis from the centre of the side (lower endcap) + endCapVacBackD, // pDy2 half y length at +pDz + endCapVacBackD, // pDx3 half x length at +pDz, -pDy2 + endCapVacBackD, // pDx4 half x length at +pDz, +pDy2 + 0.00 * degree); // pAlpha2 wrt y-axis from the centre of the side (upper endcap) + G4cout << endCapTotalL << " " << endCapVacTotalL << endl; - - //rectangular part - G4Box* endCapVacBox = new G4Box("endCapBox",endCapVacBackD,endCapVacBackD,endCapVacBoxL/2.); - G4ThreeVector transVacBox( 0.*mm, 0.*mm, endCapVacTaperL/2.+endCapVacBoxL/2.); - - //add them together - solidVacuum_GREAT = new G4UnionSolid("Vac_Box+Taper",solidTaperVac,endCapVacBox,0,transVacBox); - + + // rectangular part + G4Box* endCapVacBox = new G4Box("endCapBox", endCapVacBackD, endCapVacBackD, endCapVacBoxL / 2.); + G4ThreeVector transVacBox(0. * mm, 0. * mm, endCapVacTaperL / 2. + endCapVacBoxL / 2.); + + // add them together + solidVacuum_GREAT = new G4UnionSolid("Vac_Box+Taper", solidTaperVac, endCapVacBox, 0, transVacBox); //--------------------------------------------------------- - //The Ge crystal... - G4double GeTaperL = fTaperGeL_GREAT; //30.0*mm; - G4double GeTotalL = fTotalGeL_GREAT; //105 ? 140.0 * mm; - + // The Ge crystal... + G4double GeTaperL = fTaperGeL_GREAT; // 30.0*mm; + G4double GeTotalL = fTotalGeL_GREAT; // 105 ? 140.0 * mm; + G4double smallSquare = fFrontFaceSquare_GREAT; G4double largeSquare = fBackFaceSquare_GREAT; - G4double transX = (largeSquare-smallSquare)/2.; - G4double transY = (largeSquare-smallSquare)/2.; + G4double transX = (largeSquare - smallSquare) / 2.; + G4double transY = (largeSquare - smallSquare) / 2.; transX /= 2.; transY /= 2.; - + G4cout << "Got to the point of creating the clover leaf" << G4endl; - //don't understand this G4Trap : expect an angle of 12.15 degrees ! + // don't understand this G4Trap : expect an angle of 12.15 degrees ! G4Trap* solidTaper = new G4Trap("cloverTaper", - GeTaperL/2., //Half z-length [pDz] - 9.63*degree, //This is a fudge angle and is diff from debug //Polar angle of line joining centres of the faces @ -/+pDz - 45.0*degree, //equivalent zimuthal angle - smallSquare/2., //pDy1 half y length at -pDz - smallSquare/2., //pDx1 half x length at -pDz, -pDy1 - smallSquare/2., //pDx2 half x length at -pDz, +pDy1 - 0.00*degree,//pAlpha1 wrt y-axis from the centre of the side (lower endcap) - largeSquare/2., //pDy2 half y length at +pDz - largeSquare/2., //pDx3 half x length at +pDz, -pDy2 - largeSquare/2., //pDx4 half x length at +pDz, +pDy2 - 0.0*degree); //pAlpha2 wrt y-axis from the centre of the side (upper endcap) - + GeTaperL / 2., // Half z-length [pDz] + 9.63 * degree, // This is a fudge angle and is diff from debug //Polar angle of line + // joining centres of the faces @ -/+pDz + 45.0 * degree, // equivalent zimuthal angle + smallSquare / 2., // pDy1 half y length at -pDz + smallSquare / 2., // pDx1 half x length at -pDz, -pDy1 + smallSquare / 2., // pDx2 half x length at -pDz, +pDy1 + 0.00 * degree, // pAlpha1 wrt y-axis from the centre of the side (lower endcap) + largeSquare / 2., // pDy2 half y length at +pDz + largeSquare / 2., // pDx3 half x length at +pDz, -pDy2 + largeSquare / 2., // pDx4 half x length at +pDz, +pDy2 + 0.0 * degree); // pAlpha2 wrt y-axis from the centre of the side (upper endcap) + /* This was used for a phaseII to make rounded edges const G4int numZPlanesGe=4; // no. polycone planes @@ -3621,81 +3468,83 @@ void Chamber::CreateGREATCloverSolids() G4double rOuterGe[numZPlanesGe]; // exterior radii rOuterGe[0] = 20.5*mm; rOuterGe[1] = 23.04*mm; //23.54*mm;//exagerate it more rOuterGe[2] = rOuterGe[3] = fCrystalR_PhaseII; - - G4Polycone* solidCone = new G4Polycone("cloverCone", 0.0*degree, 360.0*degree,numZPlanesGe, zPlaneGe, rInnerGe, rOuterGe); - G4ThreeVector transGeCone( -transX/2., -transY/2., -GeTaperL/2.); - G4IntersectionSolid* taperedCone = new G4IntersectionSolid("Taper+Cone",solidTaper,solidCone,0,transGeCone); + + G4Polycone* solidCone = new G4Polycone("cloverCone", 0.0*degree, 360.0*degree,numZPlanesGe, zPlaneGe, rInnerGe, + rOuterGe); G4ThreeVector transGeCone( -transX/2., -transY/2., -GeTaperL/2.); G4IntersectionSolid* taperedCone = new + G4IntersectionSolid("Taper+Cone",solidTaper,solidCone,0,transGeCone); */ - //back part.... + // back part.... G4double geBoxL = GeTotalL - GeTaperL; - G4Box* GeBox = new G4Box("GeBox", largeSquare/2., largeSquare/2., geBoxL/2.); - - //add back box and front tapered parts - G4ThreeVector transGeBox( transX, transX, GeTaperL/2.+geBoxL/2.); - G4UnionSolid* newTaper = new G4UnionSolid("Box+Taper",solidTaper,GeBox,0,transGeBox); - - - //now make a cylinder 90x60 which needs to be displaced before intersection - //the centres of the cylinders should be 56 mm apart, but the gap between leaves - // is 0.8 mm => centre of cylinder should be at (27.6,27.6) wrt inner corner - G4double dx1 = 27.60*mm; - G4double dx2 = largeSquare/2.; + G4Box* GeBox = new G4Box("GeBox", largeSquare / 2., largeSquare / 2., geBoxL / 2.); + + // add back box and front tapered parts + G4ThreeVector transGeBox(transX, transX, GeTaperL / 2. + geBoxL / 2.); + G4UnionSolid* newTaper = new G4UnionSolid("Box+Taper", solidTaper, GeBox, 0, transGeBox); + + // now make a cylinder 90x60 which needs to be displaced before intersection + // the centres of the cylinders should be 56 mm apart, but the gap between leaves + // is 0.8 mm => centre of cylinder should be at (27.6,27.6) wrt inner corner + G4double dx1 = 27.60 * mm; + G4double dx2 = largeSquare / 2.; G4cout << "transX " << transX << " dx2 " << dx2 << ".....hole_dX " << fHole_dX_GREAT << G4endl; - fHole_dX_GREAT = transX + dx1 - dx2; //save the displacements for the bore-hole placements + fHole_dX_GREAT = transX + dx1 - dx2; // save the displacements for the bore-hole placements fHole_dY_GREAT = transY + dx1 - dx2; - - G4Tubs* GeCyl = new G4Tubs("GeCyl",0.0*mm, 35*mm, GeTotalL/2.,0.*degree,360.*degree); - G4ThreeVector transGeCyl( fHole_dX_GREAT, fHole_dY_GREAT, (GeTotalL-GeTaperL)/2.); - //add all of this together for the Ge.... - solidGeLeaf_GREAT = new G4IntersectionSolid("Box+Taper+Cyl",newTaper,GeCyl,0,transGeCyl); - + G4Tubs* GeCyl = new G4Tubs("GeCyl", 0.0 * mm, 35 * mm, GeTotalL / 2., 0. * degree, 360. * degree); + G4ThreeVector transGeCyl(fHole_dX_GREAT, fHole_dY_GREAT, (GeTotalL - GeTaperL) / 2.); + + // add all of this together for the Ge.... + solidGeLeaf_GREAT = new G4IntersectionSolid("Box+Taper+Cyl", newTaper, GeCyl, 0, transGeCyl); - //put corners @ (0,0) - fGeLeaf_dX_GREAT = largeSquare/2. - transX; - //fGeLeaf_dY_GREAT = largeSquare/2. - transY; + // put corners @ (0,0) + fGeLeaf_dX_GREAT = largeSquare / 2. - transX; + // fGeLeaf_dY_GREAT = largeSquare/2. - transY; G4cout << "shift leaves " << fGeLeaf_dX_GREAT << "....." << fHole_dX_GREAT << G4endl; - //z-position of Ge-leaf wrt vacuum - fGeLeafPosZ_GREAT = -endCapVacTaperL/2. + GeTaperL/2. + GeGap; //wrt clover Vacuum + // z-position of Ge-leaf wrt vacuum + fGeLeafPosZ_GREAT = -endCapVacTaperL / 2. + GeTaperL / 2. + GeGap; // wrt clover Vacuum - //1.875 28.875.....-1.575 27.6 + // 1.875 28.875.....-1.575 27.6 //------------------------------------------------------- // Inner bore hole + lithium contact + passivated Ge - G4double GeDepth = 15.00 * mm; - G4double holeL = GeTotalL - GeDepth; //length of bore hole - G4double passiveThick = 0.30 * mm; //passivated Ge - G4double contactThick = 0.50 * mm; //Li contact - - G4double holeR = 5.00 * mm; //fHoleR_PhaseII; - G4double contactR = holeR + contactThick; - G4double passiveR = contactR + passiveThick; - G4double tubeL = holeL - holeR; - - //the same translation works for all the following rounded tubes - G4ThreeVector transSphere(0.001*mm, 0.001*mm, -tubeL/2.-0.001*mm); //if offsets are 0. it does not display !! - - //now add a passivated layer - G4Sphere* passivatedSphere = new G4Sphere("passSphere", 0.0*mm, passiveR, 0.*degree, 360.*degree, 0.*degree, 180.*degree); - G4Tubs* passivatedTube = new G4Tubs( "passTube", 0.0*mm, passiveR, tubeL/2., 0.*degree, 360.*degree); - solidPassivated_GREAT = new G4UnionSolid("passivatedGe",passivatedTube,passivatedSphere,0,transSphere); - - //and the Li contact - G4Sphere* contactSphere = new G4Sphere("sphere1", 0.0*mm, contactR, 0.*deg, 360.*deg, 0.*deg, 180.*deg); - G4Tubs* contactTube = new G4Tubs( "tube1", 0.0*mm, contactR, tubeL/2., 0.*deg, 360.*deg); - solidContact_GREAT = new G4UnionSolid("liContact",contactTube,contactSphere,0,transSphere); - - //bore out a hole - G4Sphere* boreSphere = new G4Sphere( "boreSphere", 0.0*mm, holeR, 0.*degree, 360.*degree, 0.*degree, 180.*degree); - G4Tubs* boreTube = new G4Tubs( "boreTube", 0.0*mm, holeR, tubeL/2., 0.*degree, 360.*degree); - solidBoreHole_GREAT = new G4UnionSolid("boreHole",boreTube,boreSphere,0,transSphere); - - //save this for placement - fContact_dZ_GREAT = -GeTaperL/2 + tubeL/2 + holeR + GeDepth; + G4double GeDepth = 15.00 * mm; + G4double holeL = GeTotalL - GeDepth; // length of bore hole + G4double passiveThick = 0.30 * mm; // passivated Ge + G4double contactThick = 0.50 * mm; // Li contact + + G4double holeR = 5.00 * mm; // fHoleR_PhaseII; + G4double contactR = holeR + contactThick; + G4double passiveR = contactR + passiveThick; + G4double tubeL = holeL - holeR; + + // the same translation works for all the following rounded tubes + G4ThreeVector transSphere(0.001 * mm, 0.001 * mm, + -tubeL / 2. - 0.001 * mm); // if offsets are 0. it does not display !! + + // now add a passivated layer + G4Sphere* passivatedSphere = + new G4Sphere("passSphere", 0.0 * mm, passiveR, 0. * degree, 360. * degree, 0. * degree, 180. * degree); + G4Tubs* passivatedTube = new G4Tubs("passTube", 0.0 * mm, passiveR, tubeL / 2., 0. * degree, 360. * degree); + solidPassivated_GREAT = new G4UnionSolid("passivatedGe", passivatedTube, passivatedSphere, 0, transSphere); + + // and the Li contact + G4Sphere* contactSphere = new G4Sphere("sphere1", 0.0 * mm, contactR, 0. * deg, 360. * deg, 0. * deg, 180. * deg); + G4Tubs* contactTube = new G4Tubs("tube1", 0.0 * mm, contactR, tubeL / 2., 0. * deg, 360. * deg); + solidContact_GREAT = new G4UnionSolid("liContact", contactTube, contactSphere, 0, transSphere); + + // bore out a hole + G4Sphere* boreSphere = + new G4Sphere("boreSphere", 0.0 * mm, holeR, 0. * degree, 360. * degree, 0. * degree, 180. * degree); + G4Tubs* boreTube = new G4Tubs("boreTube", 0.0 * mm, holeR, tubeL / 2., 0. * degree, 360. * degree); + solidBoreHole_GREAT = new G4UnionSolid("boreHole", boreTube, boreSphere, 0, transSphere); + + // save this for placement + fContact_dZ_GREAT = -GeTaperL / 2 + tubeL / 2 + holeR + GeDepth; G4cout << "fContact_dZ_GREAT " << fContact_dZ_GREAT << G4endl; - G4cout << "totalL/2 " << GeTotalL/2 << " taperL/2 " << GeTaperL/2 << " tubeL/2 " << tubeL/2 << " : GeDepth " << GeDepth << G4endl; + G4cout << "totalL/2 " << GeTotalL / 2 << " taperL/2 " << GeTaperL / 2 << " tubeL/2 " << tubeL / 2 << " : GeDepth " + << GeDepth << G4endl; } diff --git a/NPSimulation/Core/DetectorConstruction.cc b/NPSimulation/Core/DetectorConstruction.cc index b002ce96284cbeb19978faea147301a419111339..92a5cca55094b55095f9a37babe0fcc6fad709d2 100644 --- a/NPSimulation/Core/DetectorConstruction.cc +++ b/NPSimulation/Core/DetectorConstruction.cc @@ -25,62 +25,59 @@ #include "DetectorConstruction.hh" // G4 -#include "G4Material.hh" #include "G4Box.hh" +#include "G4GeometryManager.hh" #include "G4LogicalVolume.hh" -#include "G4ThreeVector.hh" +#include "G4LogicalVolumeStore.hh" +#include "G4Material.hh" #include "G4PVPlacement.hh" -#include "G4VisAttributes.hh" -#include "G4GeometryManager.hh" #include "G4PhysicalVolumeStore.hh" -#include "G4LogicalVolumeStore.hh" -#include "G4VPhysicalVolume.hh" -#include "G4SolidStore.hh" +#include "G4RegionStore.hh" #include "G4RunManager.hh" #include "G4SDManager.hh" -#include "G4RegionStore.hh" +#include "G4SolidStore.hh" +#include "G4ThreeVector.hh" #include "G4TransportationManager.hh" +#include "G4VPhysicalVolume.hh" +#include "G4VisAttributes.hh" #ifdef NPS_GDML -#include"G4GDMLParser.hh" +#include "G4GDMLParser.hh" #endif // STL -#include<cstdlib> -#include<fstream> -#include<string> -#include<set> +#include <cstdlib> +#include <fstream> +#include <set> +#include <string> // NPL -#include "RootOutput.h" -#include "NPOptionManager.h" #include "NPInputParser.h" +#include "NPOptionManager.h" +#include "RootOutput.h" // NPS -#include "NPSDetectorFactory.hh" -#include "MaterialManager.hh" #include "DetectorMessenger.hh" +#include "MaterialManager.hh" +#include "NPSDetectorFactory.hh" //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -DetectorConstruction::DetectorConstruction(){ - world_log = NULL; - world_phys = NULL; - world_box = NULL; - m_Target = NULL; - m_Chamber = NULL ; - m_Messenger = new DetectorMessenger(this); +DetectorConstruction::DetectorConstruction() { + world_log = NULL; + world_phys = NULL; + world_box = NULL; + m_Target = NULL; + m_Chamber = NULL; + m_Messenger = new DetectorMessenger(this); m_ReadSensitivePtr = &NPS::VDetector::ReadSensitive; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -DetectorConstruction::~DetectorConstruction(){ -} +DetectorConstruction::~DetectorConstruction() {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -G4VPhysicalVolume* DetectorConstruction::Construct(){ - return ReadConfigurationFile(); -} +G4VPhysicalVolume* DetectorConstruction::Construct() { return ReadConfigurationFile(); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void DetectorConstruction::AddDetector(NPS::VDetector* NewDetector){ +void DetectorConstruction::AddDetector(NPS::VDetector* NewDetector) { // Add new detector to vector m_Detectors.push_back(NewDetector); @@ -94,9 +91,8 @@ void DetectorConstruction::AddDetector(NPS::VDetector* NewDetector){ NewDetector->InitializeRootOutput(); } - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -G4VPhysicalVolume* DetectorConstruction::ReadConfigurationFile(){ +G4VPhysicalVolume* DetectorConstruction::ReadConfigurationFile() { // Construct the World volume G4Material* Vacuum = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); @@ -105,19 +101,17 @@ G4VPhysicalVolume* DetectorConstruction::ReadConfigurationFile(){ G4double world_y = 100.0 * m; G4double world_z = 100.0 * m; - if(!world_box) + if (!world_box) world_box = new G4Box("world_box", world_x, world_y, world_z); - if(!world_log) + if (!world_log) world_log = new G4LogicalVolume(world_box, Vacuum, "world_log", 0, 0, 0); - - if(!world_phys) - world_phys = new G4PVPlacement(0, G4ThreeVector(), world_log, "world", 0, false, 0); - - G4VisAttributes* VisAtt = new G4VisAttributes(G4VisAttributes::Invisible); - world_log->SetVisAttributes(VisAtt); + if (!world_phys) + world_phys = new G4PVPlacement(0, G4ThreeVector(), world_log, "world", 0, false, 0); + G4VisAttributes* VisAtt = new G4VisAttributes(G4VisAttributes::GetInvisible()); + world_log->SetVisAttributes(VisAtt); //------------------------------------------------------------------ @@ -128,22 +122,21 @@ G4VPhysicalVolume* DetectorConstruction::ReadConfigurationFile(){ ////////General Reading needs//////// std::string LineBuffer; std::string DataBuffer; - static bool already=false; + static bool already = false; std::set<std::string> check; - int VerboseLevel = 0 ; - if(!already){ + int VerboseLevel = 0; + if (!already) { VerboseLevel = NPOptionManager::getInstance()->GetVerboseLevel(); already = 1; } else VerboseLevel = 0; - if(VerboseLevel) - cout << endl << "\033[1;36m//// Reading detector file "<< Path << endl<<endl; - - if(already) - cout << endl << "\033[1;36m//// Changing detector file to "<< Path << endl<<endl; + if (VerboseLevel) + cout << endl << "\033[1;36m//// Reading detector file " << Path << endl << endl; + if (already) + cout << endl << "\033[1;36m//// Changing detector file to " << Path << endl << endl; // Access the DetectorFactory and ask it to load the Class List std::string classlist = getenv("NPTOOL"); @@ -156,19 +149,19 @@ G4VPhysicalVolume* DetectorConstruction::ReadConfigurationFile(){ /////////// Search for Target ///////////// //////////////////////////////////////////// std::vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithToken("Target"); - if(blocks.size()==1){ + if (blocks.size() == 1) { m_Target = new Target(); m_Target->ReadConfiguration(parser); AddDetector(m_Target); } - else{ + else { blocks = parser.GetAllBlocksWithToken("CryogenicTarget"); - if(blocks.size()==1){ + if (blocks.size() == 1) { m_Target = new Target(); m_Target->ReadConfiguration(parser); AddDetector(m_Target); } - else{ + else { cout << "WARNING: No target found in detector input file! Use with caution" << endl; } } @@ -177,33 +170,33 @@ G4VPhysicalVolume* DetectorConstruction::ReadConfigurationFile(){ //////////////////////////////////////////// blocks.clear(); blocks = parser.GetAllBlocksWithToken("Chamber"); - if(blocks.size()==1){ + if (blocks.size() == 1) { m_Chamber = new Chamber(); m_Chamber->ReadConfiguration(parser); AddDetector(m_Chamber); - } + } //////////////////////////////////////////// /////////// Search for Detectors /////////// //////////////////////////////////////////// // Get the list of main token std::vector<std::string> token = parser.GetAllBlocksToken(); // Look for detectors among them - for(unsigned int i = 0 ; i < token.size() ; i++){ + for (unsigned int i = 0; i < token.size(); i++) { NPS::VDetector* detector = theFactory->Construct(token[i]); - if(detector!=NULL && check.find(token[i])==check.end()){ + if (detector != NULL && check.find(token[i]) == check.end()) { cout << "/////////////////////////////////////////" << endl; - cout << "//// Adding Detector " << token[i] << endl; + cout << "//// Adding Detector " << token[i] << endl; detector->ReadConfiguration(parser); cout << "/////////////////////////////////////////" << endl; // Add array to the VDetector Vector AddDetector(detector); check.insert(token[i]); } - else if(detector!=NULL) + else if (detector != NULL) delete detector; } - cout << "\033[0m" ; + cout << "\033[0m"; // Create the Material sample for DEDX tables MaterialManager::getInstance()->CreateSampleVolumes(world_log); @@ -211,29 +204,27 @@ G4VPhysicalVolume* DetectorConstruction::ReadConfigurationFile(){ } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void DetectorConstruction::ReadAllSensitive(const G4Event* event){ - unsigned int mysize = m_Detectors.size(); - for (unsigned short i = 0 ; i < mysize ; i++) { - (m_Detectors[i]->*m_ReadSensitivePtr)(event); +void DetectorConstruction::ReadAllSensitive(const G4Event* event) { + unsigned int mysize = m_Detectors.size(); + for (unsigned short i = 0; i < mysize; i++) { + (m_Detectors[i]->*m_ReadSensitivePtr)(event); } } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -G4LogicalVolume* DetectorConstruction::GetWorldLogic(){ - return world_log; -} +G4LogicalVolume* DetectorConstruction::GetWorldLogic() { return world_log; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void DetectorConstruction::ClearGeometry(){ +void DetectorConstruction::ClearGeometry() { unsigned int mySize = m_Detectors.size(); - for (unsigned short i = 0 ; i < mySize ; i++) { + for (unsigned short i = 0; i < mySize; i++) { delete m_Detectors[i]; } m_Detectors.clear(); - // Delete previous Sensitive Detector (Scorer) + // Delete previous Sensitive Detector (Scorer) delete G4SDManager::GetSDMpointer(); G4GeometryManager::GetInstance()->OpenGeometry(); @@ -241,56 +232,55 @@ void DetectorConstruction::ClearGeometry(){ // Cleaning stores by hand (everything but the world) // Cleaning the PVP G4PhysicalVolumeStore* PVP = G4PhysicalVolumeStore::GetInstance(); - while(PVP->size()>1){ - delete PVP->at(PVP->size()-1); + while (PVP->size() > 1) { + delete PVP->at(PVP->size() - 1); PVP->pop_back(); } // Cleaning the Logical Volume G4LogicalVolumeStore* LV = G4LogicalVolumeStore::GetInstance(); - while(LV->size()>1) { - delete LV->at(LV->size()-1); + while (LV->size() > 1) { + delete LV->at(LV->size() - 1); LV->pop_back(); } // Cleaning the Solid store G4SolidStore* SL = G4SolidStore::GetInstance(); - while(SL->size()>1) { - delete SL->at(SL->size()-1); + while (SL->size() > 1) { + delete SL->at(SL->size() - 1); SL->pop_back(); } - - G4Region* reg = G4RegionStore::GetInstance()->GetRegion("NPSimulationProcess",false); - if(reg) + + G4Region* reg = G4RegionStore::GetInstance()->GetRegion("NPSimulationProcess", false); + if (reg) G4RegionStore::GetInstance()->DeRegister(reg); - + delete reg; - m_Target = 0; - m_Chamber = 0; + m_Target = 0; + m_Chamber = 0; world_log->ClearDaughters(); } - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void DetectorConstruction::RedefineGeometry(std::string file){ - ClearGeometry() ; +void DetectorConstruction::RedefineGeometry(std::string file) { + ClearGeometry(); - if(file!="") + if (file != "") NPOptionManager::getInstance()->SetDetectorFile(file); Construct(); - - if(m_Target) + + if (m_Target) m_Target->SetReactionRegion(); G4RunManager::GetRunManager()->GeometryHasBeenModified(); - G4RunManager::GetRunManager()->PhysicsHasBeenModified() ; + G4RunManager::GetRunManager()->PhysicsHasBeenModified(); G4RunManager::GetRunManager()->Initialize(); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void DetectorConstruction::ExportGeometry(string file){ +void DetectorConstruction::ExportGeometry(string file) { #ifdef NPS_GDML - G4GDMLParser parser ; - parser.Write(file.c_str(),world_log); + G4GDMLParser parser; + parser.Write(file.c_str(), world_log); #else // To silenced the compiler file = ""; diff --git a/NPSimulation/Core/MaterialManager.cc b/NPSimulation/Core/MaterialManager.cc index c39bff2e69a2b2d210ec1a2683e216d083a356d3..1786d161463a485ee629f39993c1211b4d9ba712 100644 --- a/NPSimulation/Core/MaterialManager.cc +++ b/NPSimulation/Core/MaterialManager.cc @@ -20,7 +20,7 @@ * Comment: * * * *****************************************************************************/ -//NPL +// NPL #include "NPOptionManager.h" // NPS @@ -56,8 +56,8 @@ MaterialManager::~MaterialManager() {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... MaterialManager::MaterialManager() { - m_D = NULL; - m_T = NULL; + m_D = NULL; + m_T = NULL; m_He3 = NULL; } @@ -75,14 +75,13 @@ void MaterialManager::ClearMaterialLibrary() { // we can forget about them but not delete it // as they can be deleted by the kernel e.g. when Cleaning the PVPStore m_Material.clear(); - m_D = NULL; - m_T = NULL; + m_D = NULL; + m_T = NULL; m_He3 = NULL; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -G4Material* MaterialManager::GetMaterialFromLibrary(string Name, - double density) { +G4Material* MaterialManager::GetMaterialFromLibrary(string Name, double density) { // Search if the material is already instantiate map<string, G4Material*>::iterator it; it = m_Material.find(Name); @@ -91,8 +90,7 @@ G4Material* MaterialManager::GetMaterialFromLibrary(string Name, if (it == m_Material.end()) { // Usual compound - if (Name == "Vacuum" || Name == "Vaccum" || Name == "Vaccuum" - || Name == "Vacum") { + if (Name == "Vacuum" || Name == "Vaccum" || Name == "Vaccuum" || Name == "Vacum") { if (!density) density = 0.000000001 * mg / cm3; G4Material* material = new G4Material("NPS_" + Name, density, 2); @@ -148,7 +146,6 @@ G4Material* MaterialManager::GetMaterialFromLibrary(string Name, return material; } - else if (Name == "Rogers4003C") { if (!density) density = 1.79 * g / cm3; @@ -224,9 +221,8 @@ G4Material* MaterialManager::GetMaterialFromLibrary(string Name, else if (Name == "N2_liquid") { if (!density) density = 0.808 * g / cm3; - G4Material* material = new G4Material("NPS_" + Name, 7, 14.01 * g / mole, - density, kStateLiquid, 77 * kelvin); - m_Material[Name] = material; + G4Material* material = new G4Material("NPS_" + Name, 7, 14.01 * g / mole, density, kStateLiquid, 77 * kelvin); + m_Material[Name] = material; return material; } @@ -264,11 +260,9 @@ G4Material* MaterialManager::GetMaterialFromLibrary(string Name, else if (Name == "EJ200") { if (!density) density = 1.023 * g / cm3; - G4Material* material = new G4Material("NPS_" + Name, density, 2, - kStateSolid, 293 * kelvin); - G4Element* C = new G4Element("C", "C", 6, 12 * g / mole); - G4Element* H - = new G4Element("TS_H_of_Polyethylene", "H", 1., 1.0079 * g / mole); + G4Material* material = new G4Material("NPS_" + Name, density, 2, kStateSolid, 293 * kelvin); + G4Element* C = new G4Element("C", "C", 6, 12 * g / mole); + G4Element* H = new G4Element("TS_H_of_Polyethylene", "H", 1., 1.0079 * g / mole); material->AddElement(C, 5); material->AddElement(H, 4); // material->AddElement(GetElementFromLibrary("C"), 5); @@ -299,7 +293,6 @@ G4Material* MaterialManager::GetMaterialFromLibrary(string Name, return material; } - else if (Name == "Cu") { if (!density) density = 8.96 * g / cm3; @@ -326,8 +319,7 @@ G4Material* MaterialManager::GetMaterialFromLibrary(string Name, G4Isotope* isotope = new G4Isotope("235U", 92, 235); U235->AddIsotope(isotope, 1); - G4Material* material = new G4Material("NPS_" + Name, density, 1, - kStateSolid, 293.15 * kelvin); + G4Material* material = new G4Material("NPS_" + Name, density, 1, kStateSolid, 293.15 * kelvin); material->AddElement(U235, 1); m_Material[Name] = material; return material; @@ -341,8 +333,7 @@ G4Material* MaterialManager::GetMaterialFromLibrary(string Name, G4Isotope* isotope = new G4Isotope("238U", 92, 238); U238->AddIsotope(isotope, 1); - G4Material* material = new G4Material("NPS_" + Name, density, 1, - kStateSolid, 293.15 * kelvin); + G4Material* material = new G4Material("NPS_" + Name, density, 1, kStateSolid, 293.15 * kelvin); material->AddElement(U238, 1); m_Material[Name] = material; return material; @@ -372,8 +363,7 @@ G4Material* MaterialManager::GetMaterialFromLibrary(string Name, isotope = new G4Isotope("160Gd", 64, 160); Gd->AddIsotope(isotope, 0.2186); - G4Material* material = new G4Material("NPS_" + Name, density, 1, - kStateSolid, 293.15 * kelvin); + G4Material* material = new G4Material("NPS_" + Name, density, 1, kStateSolid, 293.15 * kelvin); material->AddElement(Gd, 1); m_Material[Name] = material; return material; @@ -423,28 +413,32 @@ G4Material* MaterialManager::GetMaterialFromLibrary(string Name, material->AddElement(GetElementFromLibrary("H"), 2); m_Material[Name] = material; return material; - } else if (Name == "H2_gas") { + } + else if (Name == "H2_gas") { if (!density) density = 3.34e-11 * g / cm3; G4Material* material = new G4Material("NPS_" + Name, density, 1); material->AddElement(GetElementFromLibrary("H"), 2); m_Material[Name] = material; return material; - } else if (Name == "He_gas") { + } + else if (Name == "He_gas") { if (!density) density = 0.0001665 * g / cm3; // room temp, 1 atm G4Material* material = new G4Material("NPS_" + Name, density, 1); material->AddElement(GetElementFromLibrary("He"), 1); m_Material[Name] = material; return material; - } else if (Name == "O2_gas") { + } + else if (Name == "O2_gas") { if (!density) density = 0.001331 * g / cm3; // room temp, 1 atm G4Material* material = new G4Material("NPS_" + Name, density, 1); material->AddElement(GetElementFromLibrary("O"), 2); m_Material[Name] = material; return material; - } else if (Name == "Ti") { + } + else if (Name == "Ti") { if (!density) density = 4.5189 * g / cm3; G4Material* material = new G4Material("NPS_" + Name, density, 1); @@ -461,7 +455,7 @@ G4Material* MaterialManager::GetMaterialFromLibrary(string Name, material->AddElement(GetElementFromLibrary("O"), 1); m_Material[Name] = material; return material; - } + } else if (Name == "mixMINOS") { // cyril if (!density) density = 0.0019836 * g / cm3; @@ -471,7 +465,7 @@ G4Material* MaterialManager::GetMaterialFromLibrary(string Name, material->AddElement(GetElementFromLibrary("Ar"), .82); m_Material[Name] = material; return material; - } + } else if (Name == "mumetal") { // cyril if (!density) density = 8.7 * g / cm3; @@ -481,14 +475,16 @@ G4Material* MaterialManager::GetMaterialFromLibrary(string Name, material->AddElement(GetElementFromLibrary("Mo"), .05); m_Material[Name] = material; return material; - } else if (Name == "LH2") { // cyril + } + else if (Name == "LH2") { // cyril if (!density) density = 0.07293 * g / cm3; G4Material* material = new G4Material("NPS_" + Name, density, 1); material->AddElement(GetElementFromLibrary("H"), 2); m_Material[Name] = material; return material; - } else if (Name == "Rohacell") { // cyril + } + else if (Name == "Rohacell") { // cyril if (!density) density = 0.075 * g / cm3; G4Material* material = new G4Material("NPS_" + Name, density, 4); @@ -508,15 +504,15 @@ G4Material* MaterialManager::GetMaterialFromLibrary(string Name, material->AddElement(GetElementFromLibrary("Si"), 1); // Adding Optical property: - double* energy_r = new double[2]; - double* rindex = new double[2]; + double* energy_r = new double[2]; + double* rindex = new double[2]; double* absorption = new double[2]; energy_r[0] = 1 * eV; energy_r[1] = 1 * MeV; - rindex[0] = 1; - rindex[1] = 1; + rindex[0] = 1; + rindex[1] = 1; absorption[0] = 1 * um; absorption[1] = 1 * um; @@ -596,23 +592,23 @@ G4Material* MaterialManager::GetMaterialFromLibrary(string Name, else if (Name == "para-Terphenyl_Scintillator") { if (!density) - density = 1.23 * g / cm3; // good + density = 1.23 * g / cm3; // good G4Material* material = new G4Material("NPS_" + Name, density, 2); // check - material->AddElement(GetElementFromLibrary("H"), 14); // good - material->AddElement(GetElementFromLibrary("C"), 18); // good + material->AddElement(GetElementFromLibrary("H"), 14); // good + material->AddElement(GetElementFromLibrary("C"), 18); // good // Adding Scintillation property: - int NumberOfPoints = 10; // check - double wlmin = 0.25 * um; // check - double wlmax = 67 * um; // check - double step = (wlmax - wlmin) / NumberOfPoints; - double* energy_r = new double[NumberOfPoints]; - double* rindex = new double[NumberOfPoints]; - double* absorption = new double[NumberOfPoints]; + int NumberOfPoints = 10; // check + double wlmin = 0.25 * um; // check + double wlmax = 67 * um; // check + double step = (wlmax - wlmin) / NumberOfPoints; + double* energy_r = new double[NumberOfPoints]; + double* rindex = new double[NumberOfPoints]; + double* absorption = new double[NumberOfPoints]; double* energy_e = new double[5]; - double* fast = new double[5]; - double* slow = new double[5]; - double* scint = new double[5]; + double* fast = new double[5]; + double* slow = new double[5]; + double* scint = new double[5]; // check block below energy_e[0] = h_Planck * c_light / (450 * nm); @@ -624,7 +620,7 @@ G4Material* MaterialManager::GetMaterialFromLibrary(string Name, for (int i = 0; i < 5; i++) { // fast[0] = 1 ; fast[1]=1; // slow[0] = 1 ; slow[1]=1; - fast[i] = 2.1; // good + fast[i] = 2.1; // good slow[i] = 22.6; // check } // check below block @@ -640,14 +636,10 @@ G4Material* MaterialManager::GetMaterialFromLibrary(string Name, for (int i = 0; i < NumberOfPoints; i++) { wl = wlmin + i * step; // Formula from www.refractiveindex.info - rindex[i] = sqrt(1 + 0.27587 + 0.68689 / (1 - pow(0.130 / wl, 2)) - + 0.26090 / (1 - pow(0.147 / wl, 2)) - + 0.06256 / (1 - pow(0.163 / wl, 2)) - + 0.06527 / (1 - pow(0.177 / wl, 2)) - + 0.14991 / (1 - pow(0.185 / wl, 2)) - + 0.51818 / (1 - pow(0.206 / wl, 2)) - + 0.01918 / (1 - pow(0.218 / wl, 2)) - + 3.38229 / (1 - pow(161.29 / wl, 2))); + rindex[i] = sqrt(1 + 0.27587 + 0.68689 / (1 - pow(0.130 / wl, 2)) + 0.26090 / (1 - pow(0.147 / wl, 2)) + + 0.06256 / (1 - pow(0.163 / wl, 2)) + 0.06527 / (1 - pow(0.177 / wl, 2)) + + 0.14991 / (1 - pow(0.185 / wl, 2)) + 0.51818 / (1 - pow(0.206 / wl, 2)) + + 0.01918 / (1 - pow(0.218 / wl, 2)) + 3.38229 / (1 - pow(161.29 / wl, 2))); // check below block energy_r[i] = h_Planck * c_light / wl; // To be defined properly @@ -657,19 +649,19 @@ G4Material* MaterialManager::GetMaterialFromLibrary(string Name, G4MaterialPropertiesTable* MPT = new G4MaterialPropertiesTable(); // From St Gobain - MPT->AddConstProperty("SCINTILLATIONYIELD", 27000000 / keV); // good - MPT->AddProperty("SCINTILLATION", energy_e, scint, 5); // check + MPT->AddConstProperty("SCINTILLATIONYIELD", 27000000 / keV); // good + MPT->AddProperty("SCINTILLATION", energy_e, scint, 5); // check MPT->AddProperty("RINDEX", energy_r, rindex, NumberOfPoints); // check MPT->AddProperty("ABSLENGTH", energy_r, absorption, - NumberOfPoints); // check + NumberOfPoints); // check MPT->AddProperty("FASTCOMPONENT", energy_e, fast, 5); // good MPT->AddProperty("SLOWCOMPONENT", energy_e, slow, 5); // good - MPT->AddConstProperty("RESOLUTIONSCALE", 1.0); // check + MPT->AddConstProperty("RESOLUTIONSCALE", 1.0); // check MPT->AddConstProperty("FASTTIMECONSTANT", 1000 * ns); // check MPT->AddConstProperty("SLOWTIMECONSTANT", 1000 * ns); // check - MPT->AddConstProperty("YIELDRATIO", 1.0); // check - material->SetMaterialPropertiesTable(MPT); // good - m_Material[Name] = material; // good + MPT->AddConstProperty("YIELDRATIO", 1.0); // check + material->SetMaterialPropertiesTable(MPT); // good + m_Material[Name] = material; // good return material; } @@ -742,18 +734,18 @@ G4Material* MaterialManager::GetMaterialFromLibrary(string Name, material->AddElement(GetElementFromLibrary("Cs"), 1); material->AddElement(GetElementFromLibrary("I"), 1); // Adding Scintillation property: - int NumberOfPoints = 10; - double wlmin = 0.25 * um; - double wlmax = 67 * um; - double step = (wlmax - wlmin) / NumberOfPoints; - double* energy_r = new double[NumberOfPoints]; - double* rindex = new double[NumberOfPoints]; - double* absorption = new double[NumberOfPoints]; + int NumberOfPoints = 10; + double wlmin = 0.25 * um; + double wlmax = 67 * um; + double step = (wlmax - wlmin) / NumberOfPoints; + double* energy_r = new double[NumberOfPoints]; + double* rindex = new double[NumberOfPoints]; + double* absorption = new double[NumberOfPoints]; double* energy_e = new double[5]; - double* fast = new double[5]; - double* slow = new double[5]; - double* scint = new double[5]; + double* fast = new double[5]; + double* slow = new double[5]; + double* scint = new double[5]; energy_e[0] = h_Planck * c_light / (450 * nm); energy_e[1] = h_Planck * c_light / (500 * nm); @@ -778,14 +770,10 @@ G4Material* MaterialManager::GetMaterialFromLibrary(string Name, for (int i = 0; i < NumberOfPoints; i++) { wl = wlmin + i * step; // Formula from www.refractiveindex.info - rindex[i] = sqrt(1 + 0.27587 + 0.68689 / (1 - pow(0.130 / wl, 2)) - + 0.26090 / (1 - pow(0.147 / wl, 2)) - + 0.06256 / (1 - pow(0.163 / wl, 2)) - + 0.06527 / (1 - pow(0.177 / wl, 2)) - + 0.14991 / (1 - pow(0.185 / wl, 2)) - + 0.51818 / (1 - pow(0.206 / wl, 2)) - + 0.01918 / (1 - pow(0.218 / wl, 2)) - + 3.38229 / (1 - pow(161.29 / wl, 2))); + rindex[i] = sqrt(1 + 0.27587 + 0.68689 / (1 - pow(0.130 / wl, 2)) + 0.26090 / (1 - pow(0.147 / wl, 2)) + + 0.06256 / (1 - pow(0.163 / wl, 2)) + 0.06527 / (1 - pow(0.177 / wl, 2)) + + 0.14991 / (1 - pow(0.185 / wl, 2)) + 0.51818 / (1 - pow(0.206 / wl, 2)) + + 0.01918 / (1 - pow(0.218 / wl, 2)) + 3.38229 / (1 - pow(161.29 / wl, 2))); energy_r[i] = h_Planck * c_light / wl; // To be defined properly @@ -823,7 +811,7 @@ G4Material* MaterialManager::GetMaterialFromLibrary(string Name, else if (Name == "LaBr3_Ce") { if (!density) density = 5.29 * g / cm3; - G4Material* base = GetMaterialFromLibrary("LaBr3"); + G4Material* base = GetMaterialFromLibrary("LaBr3"); G4Material* material = new G4Material("NPS_" + Name, density, 2); material->AddMaterial(base, 95 * perCent); material->AddElement(GetElementFromLibrary("Ce"), 5 * perCent); @@ -832,6 +820,30 @@ G4Material* MaterialManager::GetMaterialFromLibrary(string Name, return material; } + else if (Name == "Lyso" || Name == "LYSO") { + if (!density) + density = 7.1 * g / cm3; + G4Material* material = new G4Material("NPS_" + Name, density, 5); + material->AddElement(GetElementFromLibrary("Lu"), 2); + material->AddElement(GetElementFromLibrary("Y"), 2); + material->AddElement(GetElementFromLibrary("Si"), 1); + material->AddElement(GetElementFromLibrary("O"), 5); + material->AddElement(GetElementFromLibrary("Ce"), 1); + m_Material[Name] = material; + return material; + } + + else if (Name == "BGO") { + if (!density) + density = 7.13 * g / cm3; + G4Material* material = new G4Material("NPS_" + Name, density, 3); + material->AddElement(GetElementFromLibrary("Bi"), 4); + material->AddElement(GetElementFromLibrary("Ge"), 3); + material->AddElement(GetElementFromLibrary("O"), 12); + m_Material[Name] = material; + return material; + } + else if (Name == "BaF2") { if (!density) density = 4.89 * g / cm3; @@ -891,8 +903,7 @@ G4Material* MaterialManager::GetMaterialFromLibrary(string Name, else if (Name == "P10_1atm") { if (!density) density = 1.74 * mg / cm3; - G4Material* material - = new G4Material("NPS_" + Name, density, 3); //@ 0K, 1 atm + G4Material* material = new G4Material("NPS_" + Name, density, 3); //@ 0K, 1 atm material->AddElement(GetElementFromLibrary("Ar"), 0.9222); material->AddElement(GetElementFromLibrary("C"), 0.0623); material->AddElement(GetElementFromLibrary("H"), 0.0155); @@ -903,8 +914,7 @@ G4Material* MaterialManager::GetMaterialFromLibrary(string Name, else if (Name == "P10") { if (!density) density = 0.57 * mg / cm3; - G4Material* material - = new G4Material("NPS_" + Name, density, 3); //@ 0K, 1/3 atm + G4Material* material = new G4Material("NPS_" + Name, density, 3); //@ 0K, 1/3 atm material->AddElement(GetElementFromLibrary("Ar"), 0.9222); material->AddElement(GetElementFromLibrary("C"), 0.0623); material->AddElement(GetElementFromLibrary("H"), 0.0155); @@ -923,7 +933,7 @@ G4Material* MaterialManager::GetMaterialFromLibrary(string Name, } else if (Name == "iC4H10" || Name == "Isobutane" || Name == "isobutane") { - density = 0.002506 * g / cm3; + density = 0.002506 * g / cm3; G4Material* material = new G4Material("NPS_" + Name, density, 2); material->AddElement(GetElementFromLibrary("C"), 4); material->AddElement(GetElementFromLibrary("H"), 10); @@ -934,8 +944,7 @@ G4Material* MaterialManager::GetMaterialFromLibrary(string Name, else if (Name == "CF4") { // 52 torr if (!density) density = 3.78 * mg / cm3; - G4Material* material = new G4Material("NPS_" + Name, density, 2, - kStateGas, 300, 0.0693276 * bar); + G4Material* material = new G4Material("NPS_" + Name, density, 2, kStateGas, 300, 0.0693276 * bar); material->AddElement(GetElementFromLibrary("C"), 1); material->AddElement(GetElementFromLibrary("F"), 4); material->GetIonisation()->SetMeanExcitationEnergy(20.0 * eV); @@ -991,17 +1000,13 @@ G4Material* MaterialManager::GetMaterialFromLibrary(string Name, //--------------------- PMMA optical Properties ---------------------// const G4int NUMENTRIES = 15; - G4double PMMA_PP[NUMENTRIES] - = {10 * eV, 3.25 * eV, 3.099 * eV, 2.88 * eV, 2.695 * eV, - 2.53 * eV, 2.38 * eV, 2.254 * eV, 2.138 * eV, 2.033 * eV, - 1.937 * eV, 1.859 * eV, 1.771 * eV, 1.6 * eV, 0 * eV}; - G4double PMMA_RIND[NUMENTRIES] - = {1.47, 1.47, 1.47, 1.47, 1.47, 1.47, 1.47, 1.47, - 1.47, 1.47, 1.47, 1.47, 1.47, 1.47, 1.47}; - G4double PMMA_ABSL[NUMENTRIES] - = {35. * cm, 35. * cm, 35. * cm, 35. * cm, 35. * cm, - 35. * cm, 35. * cm, 35. * cm, 35. * cm, 35. * cm, - 35. * cm, 35. * cm, 35. * cm, 35. * cm, 35. * cm}; + G4double PMMA_PP[NUMENTRIES] = {10 * eV, 3.25 * eV, 3.099 * eV, 2.88 * eV, 2.695 * eV, + 2.53 * eV, 2.38 * eV, 2.254 * eV, 2.138 * eV, 2.033 * eV, + 1.937 * eV, 1.859 * eV, 1.771 * eV, 1.6 * eV, 0 * eV}; + G4double PMMA_RIND[NUMENTRIES] = {1.47, 1.47, 1.47, 1.47, 1.47, 1.47, 1.47, 1.47, + 1.47, 1.47, 1.47, 1.47, 1.47, 1.47, 1.47}; + G4double PMMA_ABSL[NUMENTRIES] = {35. * cm, 35. * cm, 35. * cm, 35. * cm, 35. * cm, 35. * cm, 35. * cm, 35. * cm, + 35. * cm, 35. * cm, 35. * cm, 35. * cm, 35. * cm, 35. * cm, 35. * cm}; G4MaterialPropertiesTable* myMPT2 = new G4MaterialPropertiesTable(); myMPT2->AddProperty("RINDEX", PMMA_PP, PMMA_RIND, NUMENTRIES); @@ -1017,9 +1022,9 @@ G4Material* MaterialManager::GetMaterialFromLibrary(string Name, if (!density) density = 2.71 * g / cm3; G4Material* material = new G4Material("NPS_" + Name, density, 2); - material->AddElement(GetElementFromLibrary("Al"), 99.5/100.); + material->AddElement(GetElementFromLibrary("Al"), 99.5 / 100.); // To get to 100% - material->AddElement(GetElementFromLibrary("Fe"), 0.5/100.); + material->AddElement(GetElementFromLibrary("Fe"), 0.5 / 100.); // Not 100% from wiki... // material->AddElement(GetElementFromLibrary("Cu"), 0.05/100.); // material->AddElement(GetElementFromLibrary("Fe"), 0.4/100.); @@ -1037,9 +1042,9 @@ G4Material* MaterialManager::GetMaterialFromLibrary(string Name, if (!density) density = 2.67 * g / cm3; G4Material* material = new G4Material("NPS_" + Name, density, 2); - //Realistic - material->AddElement(GetElementFromLibrary("Al"), 97/100.); - material->AddElement(GetElementFromLibrary("Mg"), 3/100.); + // Realistic + material->AddElement(GetElementFromLibrary("Al"), 97 / 100.); + material->AddElement(GetElementFromLibrary("Mg"), 3 / 100.); // Not 100% from Wiki... // material->AddElement(GetElementFromLibrary("Al"), 97.4/100.); // material->AddElement(GetElementFromLibrary("Cr"), 0.3/100.); @@ -1054,7 +1059,6 @@ G4Material* MaterialManager::GetMaterialFromLibrary(string Name, return material; } - else if (Name == "NE213") { if (!density) density = 0.874 * g / cm3; @@ -1075,22 +1079,16 @@ G4Material* MaterialManager::GetMaterialFromLibrary(string Name, //--------------------- Optical Properties ---------------------// const G4int NUMENTRIES = 15; - G4double CsI_PP[NUMENTRIES] - = {10 * eV, 3.5 * eV, 3.25 * eV, 3.2 * eV, 3.15 * eV, - 3.099 * eV, 3.0 * eV, 2.95 * eV, 2.88 * eV, 2.75 * eV, - 2.695 * eV, 2.53 * eV, 2.38 * eV, 2.30 * eV, 0 * eV}; - - G4double CsI_SCINT[NUMENTRIES] - = {0.0, 0.0, 0.1, 0.2, 0.4, 0.65, 0.8, 0.95, - 0.82, 0.7, 0.5, 0.21, 0.05, 0, 0}; - - G4double CsI_RIND[NUMENTRIES] - = {1.505, 1.505, 1.505, 1.505, 1.505, 1.505, 1.505, 1.505, - 1.505, 1.505, 1.505, 1.505, 1.505, 1.505, 1.505}; - G4double CsI_ABSL[NUMENTRIES] - = {1.5 * m, 1.5 * m, 1.5 * m, 1.5 * m, 1.5 * m, - 1.5 * m, 1.5 * m, 1.5 * m, 1.5 * m, 1.5 * m, - 1.5 * m, 1.5 * m, 1.5 * m, 1.5 * m, 1.5 * m}; + G4double CsI_PP[NUMENTRIES] = {10 * eV, 3.5 * eV, 3.25 * eV, 3.2 * eV, 3.15 * eV, + 3.099 * eV, 3.0 * eV, 2.95 * eV, 2.88 * eV, 2.75 * eV, + 2.695 * eV, 2.53 * eV, 2.38 * eV, 2.30 * eV, 0 * eV}; + + G4double CsI_SCINT[NUMENTRIES] = {0.0, 0.0, 0.1, 0.2, 0.4, 0.65, 0.8, 0.95, 0.82, 0.7, 0.5, 0.21, 0.05, 0, 0}; + + G4double CsI_RIND[NUMENTRIES] = {1.505, 1.505, 1.505, 1.505, 1.505, 1.505, 1.505, 1.505, + 1.505, 1.505, 1.505, 1.505, 1.505, 1.505, 1.505}; + G4double CsI_ABSL[NUMENTRIES] = {1.5 * m, 1.5 * m, 1.5 * m, 1.5 * m, 1.5 * m, 1.5 * m, 1.5 * m, 1.5 * m, + 1.5 * m, 1.5 * m, 1.5 * m, 1.5 * m, 1.5 * m, 1.5 * m, 1.5 * m}; G4MaterialPropertiesTable* myMPT1 = new G4MaterialPropertiesTable(); myMPT1->AddProperty("RINDEX", CsI_PP, CsI_RIND, NUMENTRIES); /// Constant? @@ -1115,13 +1113,12 @@ G4Material* MaterialManager::GetMaterialFromLibrary(string Name, else { cout << "INFO: trying to get " << Name << " material from NIST" << endl; - G4NistManager* man = G4NistManager::Instance(); - G4Material* material = man->FindOrBuildMaterial(Name.c_str()); - m_Material[Name] = material; + G4NistManager* man = G4NistManager::Instance(); + G4Material* material = man->FindOrBuildMaterial(Name.c_str()); + m_Material[Name] = material; material->SetName("NPS_" + material->GetName()); if (!material) { - cout << "ERROR: Material requested \"" << Name - << "\" is not available in the nptool material library or NIST" + cout << "ERROR: Material requested \"" << Name << "\" is not available in the nptool material library or NIST" << endl; exit(1); } @@ -1136,17 +1133,14 @@ G4Material* MaterialManager::GetMaterialFromLibrary(string Name, } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void MaterialManager::AddMaterialToLibrary(G4Material* material) { - m_Material[material->GetName()] = material; -} +void MaterialManager::AddMaterialToLibrary(G4Material* material) { m_Material[material->GetName()] = material; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... G4Element* MaterialManager::GetElementFromLibrary(string Name) { if (Name == "D" || Name == "d") { if (!m_D) { m_D = new G4Element(Name.c_str(), Name.c_str(), 1); - G4Isotope* isotope - = new G4Isotope(Name.c_str(), 1, 2, 2.01410178 * g / mole); + G4Isotope* isotope = new G4Isotope(Name.c_str(), 1, 2, 2.01410178 * g / mole); m_D->AddIsotope(isotope, 1); } return m_D; @@ -1155,8 +1149,7 @@ G4Element* MaterialManager::GetElementFromLibrary(string Name) { else if (Name == "T" || Name == "t") { if (!m_T) { m_T = new G4Element(Name.c_str(), Name.c_str(), 1); - G4Isotope* isotope - = new G4Isotope(Name.c_str(), 1, 3, 3.0160492 * g / mole); + G4Isotope* isotope = new G4Isotope(Name.c_str(), 1, 3, 3.0160492 * g / mole); m_T->AddIsotope(isotope, 1); } return m_T; @@ -1165,8 +1158,7 @@ G4Element* MaterialManager::GetElementFromLibrary(string Name) { else if (Name == "He3" || Name == "3He") { if (!m_He3) { m_He3 = new G4Element(Name.c_str(), Name.c_str(), 1); - G4Isotope* isotope - = new G4Isotope(Name.c_str(), 2, 1, 3.0160293 * g / mole); + G4Isotope* isotope = new G4Isotope(Name.c_str(), 2, 1, 3.0160293 * g / mole); m_He3->AddIsotope(isotope, 1); } return m_He3; @@ -1178,11 +1170,10 @@ G4Element* MaterialManager::GetElementFromLibrary(string Name) { //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // -G4Material* MaterialManager::GetGasFromLibrary(string Name, double Pressure, - double Temperature) { +G4Material* MaterialManager::GetGasFromLibrary(string Name, double Pressure, double Temperature) { ostringstream oss; oss << Name << "_" << Pressure << "_" << Temperature; - string newName = oss.str(); + string newName = oss.str(); map<string, G4Material*>::iterator it; it = m_Material.find(Name); @@ -1193,12 +1184,11 @@ G4Material* MaterialManager::GetGasFromLibrary(string Name, double Pressure, // The element is not found if (it == m_Material.end()) { if (Name == "CF4") { // 52 torr - density = 3.72 * kg / m3; + density = 3.72 * kg / m3; double refTemp = (273.15 + 15) * kelvin; double refPres = 1.01325 * bar; - density = density * (refTemp / Temperature) / (refPres / Pressure); - G4Material* material = new G4Material("NPS_" + newName, density, 2, - kStateGas, Temperature, Pressure); + density = density * (refTemp / Temperature) / (refPres / Pressure); + G4Material* material = new G4Material("NPS_" + newName, density, 2, kStateGas, Temperature, Pressure); material->AddElement(GetElementFromLibrary("C"), 1); material->AddElement(GetElementFromLibrary("F"), 4); m_Material[newName] = material; @@ -1206,18 +1196,16 @@ G4Material* MaterialManager::GetGasFromLibrary(string Name, double Pressure, } if (Name == "He") { - density = (4.0026 / Vm) * mg / cm3; - G4Material* material = new G4Material("NPS_" + newName, density, 1, - kStateGas, Temperature, Pressure); + density = (4.0026 / Vm) * mg / cm3; + G4Material* material = new G4Material("NPS_" + newName, density, 1, kStateGas, Temperature, Pressure); material->AddElement(GetElementFromLibrary("He"), 1); m_Material[newName] = material; return material; } if (Name == "iC4H10" || Name == "Isobutane" || Name == "isobutane") { - density = ((4 * 12.0107 + 10 * 1.00794) / Vm) * mg / cm3; - G4Material* material = new G4Material("NPS_" + newName, density, 2, - kStateGas, Temperature, Pressure); + density = ((4 * 12.0107 + 10 * 1.00794) / Vm) * mg / cm3; + G4Material* material = new G4Material("NPS_" + newName, density, 2, kStateGas, Temperature, Pressure); material->AddElement(GetElementFromLibrary("C"), 4); material->AddElement(GetElementFromLibrary("H"), 10); m_Material[newName] = material; @@ -1225,9 +1213,8 @@ G4Material* MaterialManager::GetGasFromLibrary(string Name, double Pressure, } if (Name == "CH4") { - density = ((12.0107 + 4 * 1.00794) / Vm) * mg / cm3; - G4Material* material = new G4Material("NPS_" + newName, density, 2, - kStateGas, Temperature, Pressure); + density = ((12.0107 + 4 * 1.00794) / Vm) * mg / cm3; + G4Material* material = new G4Material("NPS_" + newName, density, 2, kStateGas, Temperature, Pressure); material->AddElement(GetElementFromLibrary("C"), 1); material->AddElement(GetElementFromLibrary("H"), 4); m_Material[newName] = material; @@ -1235,9 +1222,8 @@ G4Material* MaterialManager::GetGasFromLibrary(string Name, double Pressure, } if (Name == "P80") { - density = ((0.2*36 + 0.8*(12.0107 + 4 * 1.00794) )/ Vm) * mg / cm3; - G4Material* material = new G4Material("NPS_" + newName, density, 3, - kStateGas, Temperature, Pressure); + density = ((0.2 * 36 + 0.8 * (12.0107 + 4 * 1.00794)) / Vm) * mg / cm3; + G4Material* material = new G4Material("NPS_" + newName, density, 3, kStateGas, Temperature, Pressure); material->AddElement(GetElementFromLibrary("Ar"), 0.2); material->AddElement(GetElementFromLibrary("C"), 0.64); material->AddElement(GetElementFromLibrary("H"), 0.16); @@ -1245,11 +1231,9 @@ G4Material* MaterialManager::GetGasFromLibrary(string Name, double Pressure, return material; } - if (Name == "CO2") { - density = ((12.0107 + 2 * 16) / Vm) * mg / cm3; - G4Material* material = new G4Material("NPS_" + newName, density, 2, - kStateGas, Temperature, Pressure); + density = ((12.0107 + 2 * 16) / Vm) * mg / cm3; + G4Material* material = new G4Material("NPS_" + newName, density, 2, kStateGas, Temperature, Pressure); material->AddElement(GetElementFromLibrary("C"), 1); material->AddElement(GetElementFromLibrary("O"), 2); m_Material[newName] = material; @@ -1257,9 +1241,8 @@ G4Material* MaterialManager::GetGasFromLibrary(string Name, double Pressure, } if (Name == "H2") { - density = (2 * 1.00794 / Vm) * mg / cm3; - G4Material* material = new G4Material("NPS_" + newName, density, 1, - kStateGas, Temperature, Pressure); + density = (2 * 1.00794 / Vm) * mg / cm3; + G4Material* material = new G4Material("NPS_" + newName, density, 1, kStateGas, Temperature, Pressure); material->AddElement(GetElementFromLibrary("H"), 2); // material->AddElement(GetElementFromLibrary("H"), 1); m_Material[newName] = material; @@ -1267,27 +1250,25 @@ G4Material* MaterialManager::GetGasFromLibrary(string Name, double Pressure, } if (Name == "D2") { - density = (2 * 2.0140 / Vm) * mg / cm3; - G4Material* material = new G4Material("NPS_" + newName, density, 1, - kStateGas, Temperature, Pressure); + density = (2 * 2.0140 / Vm) * mg / cm3; + G4Material* material = new G4Material("NPS_" + newName, density, 1, kStateGas, Temperature, Pressure); material->AddElement(GetElementFromLibrary("D"), 2); // material->AddElement(GetElementFromLibrary("D"), 1); m_Material[newName] = material; return material; } - if (Name == "MixTwinMusic") { - density = ((0.01*(12.0107 + 2*16.) + 0.2*36 + 0.79*(12.0107 + 4 * 1.00794) )/ Vm) * mg / cm3; - G4Material* material = new G4Material("NPS_" + newName, density, 3, - kStateGas, Temperature, Pressure); - - material->AddMaterial(GetGasFromLibrary("CH4",Pressure,Temperature),0.79); - material->AddMaterial(GetGasFromLibrary("CO2",Pressure,Temperature),0.01); + if (Name == "MixTwinMusic") { + density = ((0.01 * (12.0107 + 2 * 16.) + 0.2 * 36 + 0.79 * (12.0107 + 4 * 1.00794)) / Vm) * mg / cm3; + G4Material* material = new G4Material("NPS_" + newName, density, 3, kStateGas, Temperature, Pressure); + + material->AddMaterial(GetGasFromLibrary("CH4", Pressure, Temperature), 0.79); + material->AddMaterial(GetGasFromLibrary("CO2", Pressure, Temperature), 0.01); material->AddElement(GetElementFromLibrary("Ar"), .20); m_Material[Name] = material; return material; - } - + } + else { exit(1); } @@ -1297,19 +1278,18 @@ G4Material* MaterialManager::GetGasFromLibrary(string Name, double Pressure, //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Generate a DEDX file table using the material used in the geometry -void MaterialManager::WriteDEDXTable(G4ParticleDefinition* Particle, - G4double Emin, G4double Emax) { +void MaterialManager::WriteDEDXTable(G4ParticleDefinition* Particle, G4double Emin, G4double Emax) { map<string, G4Material*>::iterator it; if (Particle->GetPDGCharge() == 0) return; for (it = m_Material.begin(); it != m_Material.end(); it++) { // Opening hte output file - G4String GlobalPath =NPOptionManager::getInstance()->GetEnergyLossPath(); - G4String Name = it->second->GetName(); + G4String GlobalPath = NPOptionManager::getInstance()->GetEnergyLossPath(); + G4String Name = it->second->GetName(); // Remove NPS name Name.erase(0, 4); - G4String Path = GlobalPath +"/"+ Particle->GetParticleName() + "_" + Name + ".G4table"; + G4String Path = GlobalPath + "/" + Particle->GetParticleName() + "_" + Name + ".G4table"; ofstream File; File.open(Path); @@ -1318,22 +1298,20 @@ void MaterialManager::WriteDEDXTable(G4ParticleDefinition* Particle, return; File << "Table from Geant4 generate using NPSimulation \t" - << "Particle: " << Particle->GetParticleName() - << "\tMaterial: " << it->second->GetName() << G4endl; + << "Particle: " << Particle->GetParticleName() << "\tMaterial: " << it->second->GetName() << G4endl; // G4cout << Particle->GetParticleName() << "\tMaterial: " << // it->second->GetName() <<endl; G4EmCalculator emCalculator; - G4double dedx; + G4double dedx; // Tipical Range needed, if Emax is larger, then adapted if (Emax < 1 * TeV) Emax = 1 * TeV; - double step = 1 * keV; + double step = 1 * keV; double before = 0; for (G4double E = Emin; E < Emax; E += step) { - dedx = emCalculator.ComputeTotalDEDX(E, Particle, it->second) - / (MeV / micrometer); + dedx = emCalculator.ComputeTotalDEDX(E, Particle, it->second) / (MeV / micrometer); if (before) { if (abs(before - dedx) / abs(before) < 0.01) step *= 2; @@ -1348,20 +1326,17 @@ void MaterialManager::WriteDEDXTable(G4ParticleDefinition* Particle, } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Generate a DEDX file table using the material used in the geometry -void MaterialManager::WriteDEDXTable(std::set<string> Particle, G4double Emin, - G4double Emax) { +void MaterialManager::WriteDEDXTable(std::set<string> Particle, G4double Emin, G4double Emax) { std::set<string>::iterator it; for (it = Particle.begin(); it != Particle.end(); it++) { - G4ParticleDefinition* p - = G4ParticleTable::GetParticleTable()->FindParticle((*it)); + G4ParticleDefinition* p = G4ParticleTable::GetParticleTable()->FindParticle((*it)); WriteDEDXTable(p, Emin, Emax); } } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Generate Cross Section table using the material used in the geomtry -void MaterialManager::WriteCrossSectionTable(G4ParticleDefinition* Particle, - G4double Emin, G4double Emax) { +void MaterialManager::WriteCrossSectionTable(G4ParticleDefinition* Particle, G4double Emin, G4double Emax) { G4HadronicProcessStore* store = G4HadronicProcessStore::Instance(); map<string, G4Material*>::iterator it; @@ -1378,16 +1353,12 @@ void MaterialManager::WriteCrossSectionTable(G4ParticleDefinition* Particle, G4String path4; G4String ParticleName = Particle->GetParticleName(); G4String MaterialName = it->second->GetName(); - G4String ElementName = it->second->GetElement(i)->GetName(); + G4String ElementName = it->second->GetElement(i)->GetName(); - path1 = GlobalPath + "/Inputs/CrossSection/" + "G4XS_elastic_" - + ParticleName + "_" + ElementName + ".dat"; - path2 = GlobalPath + "/Inputs/CrossSection/" + "G4XS_inelastic_" - + ParticleName + "_" + ElementName + ".dat"; - path3 = GlobalPath + "/Inputs/CrossSection/" + "G4XS_capture_" - + ParticleName + "_" + ElementName + ".dat"; - path4 = GlobalPath + "/Inputs/CrossSection/" + "G4XS_fission_" - + ParticleName + "_" + ElementName + ".dat"; + path1 = GlobalPath + "/Inputs/CrossSection/" + "G4XS_elastic_" + ParticleName + "_" + ElementName + ".dat"; + path2 = GlobalPath + "/Inputs/CrossSection/" + "G4XS_inelastic_" + ParticleName + "_" + ElementName + ".dat"; + path3 = GlobalPath + "/Inputs/CrossSection/" + "G4XS_capture_" + ParticleName + "_" + ElementName + ".dat"; + path4 = GlobalPath + "/Inputs/CrossSection/" + "G4XS_fission_" + ParticleName + "_" + ElementName + ".dat"; ofstream ofile_elastic; ofstream ofile_inelastic; @@ -1400,7 +1371,7 @@ void MaterialManager::WriteCrossSectionTable(G4ParticleDefinition* Particle, // std::cout << path << std::endl; double xs; double step_keV = 1 * keV; - double step_eV = 1 * eV; + double step_eV = 1 * eV; double step_meV = 50e-3 * eV; // for(G4double E=Emin+step; E<Emax; E+=step){ double E = Emin; @@ -1415,23 +1386,19 @@ void MaterialManager::WriteCrossSectionTable(G4ParticleDefinition* Particle, E += step_keV; if (E > 1 * keV) { // Elastic Cross Section - xs = store->GetElasticCrossSectionPerAtom( - Particle, E, it->second->GetElement(i), it->second); + xs = store->GetElasticCrossSectionPerAtom(Particle, E, it->second->GetElement(i), it->second); ofile_elastic << E / MeV << " " << xs / barn << G4endl; // Inelastic Cross Section - xs = store->GetInelasticCrossSectionPerAtom( - Particle, E, it->second->GetElement(i), it->second); + xs = store->GetInelasticCrossSectionPerAtom(Particle, E, it->second->GetElement(i), it->second); ofile_inelastic << E / MeV << " " << xs / barn << G4endl; } // Capture Cross Section - xs = store->GetCaptureCrossSectionPerAtom( - Particle, E, it->second->GetElement(i), it->second); + xs = store->GetCaptureCrossSectionPerAtom(Particle, E, it->second->GetElement(i), it->second); ofile_capture << E / MeV << " " << xs / barn << G4endl; // Fission Cross Section - xs = store->GetFissionCrossSectionPerAtom( - Particle, E, it->second->GetElement(i), it->second); + xs = store->GetFissionCrossSectionPerAtom(Particle, E, it->second->GetElement(i), it->second); ofile_fission << E / MeV << " " << xs / barn << G4endl; } @@ -1445,12 +1412,10 @@ void MaterialManager::WriteCrossSectionTable(G4ParticleDefinition* Particle, //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Generate Cross Section table using the material used in the geomtry -void MaterialManager::WriteCrossSectionTable(std::set<string> Particle, - G4double Emin, G4double Emax) { +void MaterialManager::WriteCrossSectionTable(std::set<string> Particle, G4double Emin, G4double Emax) { std::set<string>::iterator it; for (it = Particle.begin(); it != Particle.end(); it++) { - G4ParticleDefinition* p - = G4ParticleTable::GetParticleTable()->FindParticle((*it)); + G4ParticleDefinition* p = G4ParticleTable::GetParticleTable()->FindParticle((*it)); if (p->GetParticleName() == "neutron") { WriteCrossSectionTable(p, Emin, Emax); } @@ -1463,20 +1428,17 @@ void MaterialManager::CreateSampleVolumes(G4LogicalVolume* world_log) { // Create a micrometer size cube for each material G4double SampleSize = 1 * um; - G4double WorldSize = 10.0 * m; - G4Box* sample_box - = new G4Box("sample_box", SampleSize, SampleSize, SampleSize); - G4int i = 1; - G4double Coord1 = WorldSize - SampleSize; - G4double Coord2 = 0; + G4double WorldSize = 10.0 * m; + G4Box* sample_box = new G4Box("sample_box", SampleSize, SampleSize, SampleSize); + G4int i = 1; + G4double Coord1 = WorldSize - SampleSize; + G4double Coord2 = 0; map<string, G4Material*>::iterator it; for (it = m_Material.begin(); it != m_Material.end(); it++) { - G4LogicalVolume* sample_log - = new G4LogicalVolume(sample_box, it->second, "sample_log", 0, 0, 0); - sample_log->SetVisAttributes(G4VisAttributes::Invisible); + G4LogicalVolume* sample_log = new G4LogicalVolume(sample_box, it->second, "sample_log", 0, 0, 0); + sample_log->SetVisAttributes(G4VisAttributes::GetInvisible()); Coord2 = WorldSize - i * 2 * SampleSize; i++; - new G4PVPlacement(0, G4ThreeVector(Coord1, Coord2, -Coord1), sample_log, - "sample", world_log, false, 0); + new G4PVPlacement(0, G4ThreeVector(Coord1, Coord2, -Coord1), sample_log, "sample", world_log, false, 0); } } diff --git a/NPSimulation/Core/RunAction.cc b/NPSimulation/Core/RunAction.cc index a3a503e00f645f7c1815f708a40a676ee75553b1..81e04c55b92595ee85c9fa3a24998171f72127bc 100644 --- a/NPSimulation/Core/RunAction.cc +++ b/NPSimulation/Core/RunAction.cc @@ -74,7 +74,7 @@ void RunAction::EndOfRunAction(const G4Run* aRun){ Particles.insert( (*traj)[i]->GetParticleName()); } MaterialManager::getInstance()->WriteDEDXTable(Particles,0,10*GeV); - MaterialManager::getInstance()->WriteCrossSectionTable(Particles,0,20*MeV); + MaterialManager::getInstance()->WriteCrossSectionTable(Particles,0,19.9*MeV); } diff --git a/NPSimulation/Detectors/AnnularS1/AnnularS1.cc b/NPSimulation/Detectors/AnnularS1/AnnularS1.cc index fbad5cdbefd6463ae400508b5f716b6c4ccc799b..78d2bc4b57e638d6706c95c5cd6317ebfa9a3640 100644 --- a/NPSimulation/Detectors/AnnularS1/AnnularS1.cc +++ b/NPSimulation/Detectors/AnnularS1/AnnularS1.cc @@ -21,34 +21,34 @@ *****************************************************************************/ // C++ headers +#include <cmath> #include <sstream> #include <string> -#include <cmath> -// Geant4 +// Geant4 #include "G4Box.hh" -#include "G4Tubs.hh" -#include "G4Material.hh" -#include "G4VisAttributes.hh" #include "G4Colour.hh" -#include "G4RotationMatrix.hh" -#include "G4Transform3D.hh" -#include "G4PVPlacement.hh" -#include "G4PVDivision.hh" #include "G4ExtrudedSolid.hh" -#include "G4SubtractionSolid.hh" -#include "G4SDManager.hh" +#include "G4Material.hh" #include "G4MultiFunctionalDetector.hh" +#include "G4PVDivision.hh" +#include "G4PVPlacement.hh" +#include "G4RotationMatrix.hh" +#include "G4SDManager.hh" +#include "G4SubtractionSolid.hh" +#include "G4Transform3D.hh" +#include "G4Tubs.hh" +#include "G4VisAttributes.hh" // NPTool headers -#include "MaterialManager.hh" -#include "NPSDetectorFactory.hh" #include "AnnularS1.hh" #include "DSSDScorers.hh" #include "InteractionScorers.hh" -#include "TS1Data.h" -#include "RootOutput.h" +#include "MaterialManager.hh" #include "NPOptionManager.h" +#include "NPSDetectorFactory.hh" +#include "RootOutput.h" +#include "TS1Data.h" // CLHEP #include "CLHEP/Random/RandGauss.h" @@ -57,24 +57,21 @@ using namespace CLHEP; using namespace ANNULARS1; //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -AnnularS1::AnnularS1(){ +AnnularS1::AnnularS1() { m_Event = new TS1Data(); - m_LogicalDetector = 0 ; + m_LogicalDetector = 0; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -AnnularS1::~AnnularS1(){ -} +AnnularS1::~AnnularS1() {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void AnnularS1::AddModule(G4double PosZ){ - m_PosZ.push_back(PosZ); -} +void AnnularS1::AddModule(G4double PosZ) { m_PosZ.push_back(PosZ); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -G4LogicalVolume* AnnularS1::ConstructVolume(){ +G4LogicalVolume* AnnularS1::ConstructVolume() { - if(!m_LogicalDetector){ + if (!m_LogicalDetector) { G4Material* Silicon = MaterialManager::getInstance()->GetMaterialFromLibrary("Si"); G4Material* Vacuum = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); //////////////////////////////////////////////////////////////// @@ -86,139 +83,93 @@ G4LogicalVolume* AnnularS1::ConstructVolume(){ // Building the PCB // The PCB is a simple extruded volume from 8reference point vector<G4TwoVector> polygon; - for(unsigned int i = 0 ; i < 8 ; i++){ - G4TwoVector Point(PCBPointsX[i],PCBPointsY[i]); + for (unsigned int i = 0; i < 8; i++) { + G4TwoVector Point(PCBPointsX[i], PCBPointsY[i]); polygon.push_back(Point); } // Mast volume containing all the detector - G4ExtrudedSolid* solidAnnularS1 = new G4ExtrudedSolid(Name, - polygon, - PCBThickness*0.5, - G4TwoVector(0,0),1, - G4TwoVector(0,0),1); + G4ExtrudedSolid* solidAnnularS1 = + new G4ExtrudedSolid(Name, polygon, PCBThickness * 0.5, G4TwoVector(0, 0), 1, G4TwoVector(0, 0), 1); // Definition of the volume containing the sensitive detector m_LogicalDetector = new G4LogicalVolume(solidAnnularS1, Vacuum, Name, 0, 0, 0); - m_LogicalDetector->SetVisAttributes(G4VisAttributes::Invisible); + m_LogicalDetector->SetVisAttributes(G4VisAttributes::GetInvisible()); // PCB Base - G4ExtrudedSolid* solidPCBBase = new G4ExtrudedSolid("PCBBase", - polygon, - PCBThickness*0.5, - G4TwoVector(0,0),1, - G4TwoVector(0,0),1); + G4ExtrudedSolid* solidPCBBase = + new G4ExtrudedSolid("PCBBase", polygon, PCBThickness * 0.5, G4TwoVector(0, 0), 1, G4TwoVector(0, 0), 1); // Wafer Shape to be substracted to the PCB - G4Tubs* solidWaferShapeBase = new G4Tubs("WaferShape", - 0, - WaferOutterRadius, - PCBThickness, - 0*deg, - 360*deg); + G4Tubs* solidWaferShapeBase = new G4Tubs("WaferShape", 0, WaferOutterRadius, PCBThickness, 0 * deg, 360 * deg); // A no rotation matrix is always handy ;) - G4RotationMatrix* norotation = new G4RotationMatrix(); - // Rotation of the box that make the Si cut - G4RotationMatrix* cutrotation = new G4RotationMatrix(G4ThreeVector(0,0,1),45*deg); - G4ThreeVector cutposition1(80*mm+WaferRCut,0,0); cutposition1.setPhi(45*deg); - G4Transform3D transform1(*cutrotation,cutposition1); - - G4Box* solidCutout = new G4Box("cuttout",80*mm,80*mm,80*mm); + G4RotationMatrix* norotation = new G4RotationMatrix(); + // Rotation of the box that make the Si cut + G4RotationMatrix* cutrotation = new G4RotationMatrix(G4ThreeVector(0, 0, 1), 45 * deg); + G4ThreeVector cutposition1(80 * mm + WaferRCut, 0, 0); + cutposition1.setPhi(45 * deg); + G4Transform3D transform1(*cutrotation, cutposition1); - G4SubtractionSolid* solidWaferShape1 = new G4SubtractionSolid("WaferShape1", - solidWaferShapeBase, - solidCutout, - transform1); + G4Box* solidCutout = new G4Box("cuttout", 80 * mm, 80 * mm, 80 * mm); + G4SubtractionSolid* solidWaferShape1 = + new G4SubtractionSolid("WaferShape1", solidWaferShapeBase, solidCutout, transform1); - G4ThreeVector cutposition2(-80*mm-WaferRCut,0,0); cutposition2.setPhi(-135*deg); - G4Transform3D transform2(*cutrotation,cutposition2); - G4SubtractionSolid* solidWaferShape = new G4SubtractionSolid("WaferShape", - solidWaferShape1, - solidCutout, - transform2); - + G4ThreeVector cutposition2(-80 * mm - WaferRCut, 0, 0); + cutposition2.setPhi(-135 * deg); + G4Transform3D transform2(*cutrotation, cutposition2); + G4SubtractionSolid* solidWaferShape = + new G4SubtractionSolid("WaferShape", solidWaferShape1, solidCutout, transform2); // PCB final - G4SubtractionSolid* solidPCB = new G4SubtractionSolid("AnnularS1_PCB1", - solidPCBBase, - solidWaferShape); + G4SubtractionSolid* solidPCB = new G4SubtractionSolid("AnnularS1_PCB1", solidPCBBase, solidWaferShape); G4LogicalVolume* logicPCB = new G4LogicalVolume(solidPCB, Vacuum, "AnnularS1_PCB", 0, 0, 0); - new G4PVPlacement(G4Transform3D(*norotation, G4ThreeVector()), - logicPCB, - "AnnularS1_PCB", - m_LogicalDetector, - false, - 0); + new G4PVPlacement(G4Transform3D(*norotation, G4ThreeVector()), logicPCB, "AnnularS1_PCB", m_LogicalDetector, false, + 0); - G4VisAttributes* PCBVisAtt = new G4VisAttributes(G4Colour(0.2, 0.5, 0.2)) ; + G4VisAttributes* PCBVisAtt = new G4VisAttributes(G4Colour(0.2, 0.5, 0.2)); logicPCB->SetVisAttributes(PCBVisAtt); - // Wafer itself - G4Tubs* solidWaferBase = new G4Tubs("Wafer", - WaferInnerRadius, - WaferOutterRadius, - 0.5*WaferThickness, - 0*deg, - 360*deg); - - G4SubtractionSolid* solidWafer1 = new G4SubtractionSolid("Wafer1", - solidWaferBase, - solidCutout, - transform1); - - G4SubtractionSolid* solidWafer = new G4SubtractionSolid("Wafer", - solidWafer1, - solidCutout, - transform2); + G4Tubs* solidWaferBase = + new G4Tubs("Wafer", WaferInnerRadius, WaferOutterRadius, 0.5 * WaferThickness, 0 * deg, 360 * deg); + + G4SubtractionSolid* solidWafer1 = new G4SubtractionSolid("Wafer1", solidWaferBase, solidCutout, transform1); + + G4SubtractionSolid* solidWafer = new G4SubtractionSolid("Wafer", solidWafer1, solidCutout, transform2); G4LogicalVolume* logicWafer = new G4LogicalVolume(solidWafer, Silicon, "AnnularS1_Wafer", 0, 0, 0); - new G4PVPlacement(G4Transform3D(*norotation, G4ThreeVector()), - logicWafer, - "AnnularS1_Wafer", - m_LogicalDetector, - false, - 0); + new G4PVPlacement(G4Transform3D(*norotation, G4ThreeVector()), logicWafer, "AnnularS1_Wafer", m_LogicalDetector, + false, 0); - G4VisAttributes* SiVisAtt = new G4VisAttributes(G4Colour(0.3, 0.3, 0.3)) ; - logicWafer->SetVisAttributes(SiVisAtt); + G4VisAttributes* SiVisAtt = new G4VisAttributes(G4Colour(0.3, 0.3, 0.3)); + logicWafer->SetVisAttributes(SiVisAtt); // Active Wafer - G4Tubs* solidActiveWaferBase = new G4Tubs("ActiveWafer", - ActiveWaferInnerRadius, - ActiveWaferOutterRadius, - 0.5*WaferThickness, - 0*deg, - 360*deg); - - - G4ThreeVector activecutposition1(80*mm+ActiveWaferRCut,0,0); activecutposition1.setPhi(45*deg); - G4Transform3D activetransform1(*cutrotation,activecutposition1); - - G4SubtractionSolid* solidActiveWafer1 = new G4SubtractionSolid("ActiveWafer1", - solidActiveWaferBase, - solidCutout, - activetransform1); - - G4ThreeVector activecutposition2(-80*mm-ActiveWaferRCut,0,0); activecutposition2.setPhi(-135*deg); - G4Transform3D activetransform2(*cutrotation,activecutposition2); - - G4SubtractionSolid* solidActiveWafer = new G4SubtractionSolid("ActiveWafer", - solidActiveWafer1, - solidCutout, - activetransform2); - - G4LogicalVolume* logicActiveWafer = new G4LogicalVolume(solidActiveWafer, Silicon, "AnnularS1_ActiveWafer", 0, 0, 0); - new G4PVPlacement(G4Transform3D(*norotation, G4ThreeVector()), - logicActiveWafer, - "AnnularS1_ActiveWafer", - logicWafer, - false, - 0); + G4Tubs* solidActiveWaferBase = new G4Tubs("ActiveWafer", ActiveWaferInnerRadius, ActiveWaferOutterRadius, + 0.5 * WaferThickness, 0 * deg, 360 * deg); + + G4ThreeVector activecutposition1(80 * mm + ActiveWaferRCut, 0, 0); + activecutposition1.setPhi(45 * deg); + G4Transform3D activetransform1(*cutrotation, activecutposition1); + + G4SubtractionSolid* solidActiveWafer1 = + new G4SubtractionSolid("ActiveWafer1", solidActiveWaferBase, solidCutout, activetransform1); + + G4ThreeVector activecutposition2(-80 * mm - ActiveWaferRCut, 0, 0); + activecutposition2.setPhi(-135 * deg); + G4Transform3D activetransform2(*cutrotation, activecutposition2); + + G4SubtractionSolid* solidActiveWafer = + new G4SubtractionSolid("ActiveWafer", solidActiveWafer1, solidCutout, activetransform2); + + G4LogicalVolume* logicActiveWafer = + new G4LogicalVolume(solidActiveWafer, Silicon, "AnnularS1_ActiveWafer", 0, 0, 0); + new G4PVPlacement(G4Transform3D(*norotation, G4ThreeVector()), logicActiveWafer, "AnnularS1_ActiveWafer", + logicWafer, false, 0); logicActiveWafer->SetVisAttributes(SiVisAtt); @@ -226,7 +177,6 @@ G4LogicalVolume* AnnularS1::ConstructVolume(){ logicActiveWafer->SetSensitiveDetector(m_Scorer); } return m_LogicalDetector; - } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... @@ -237,19 +187,19 @@ G4LogicalVolume* AnnularS1::ConstructVolume(){ //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Read stream at Configfile to pick-up parameters of detector (Position,...) // Called in DetecorConstruction::ReadDetextorConfiguration Method -void AnnularS1::ReadConfiguration(NPL::InputParser parser){ - vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithToken("AnnularS1"); - cout << "//// " << blocks.size() << " detectors found " << endl; +void AnnularS1::ReadConfiguration(NPL::InputParser parser) { + vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithToken("AnnularS1"); + cout << "//// " << blocks.size() << " detectors found " << endl; vector<string> token = {"Z"}; - for(unsigned int i = 0 ; i < blocks.size() ; i++){ - if(blocks[i]->HasTokenList(token)){ - double Z = blocks[i]->GetDouble("Z","mm"); + for (unsigned int i = 0; i < blocks.size(); i++) { + if (blocks[i]->HasTokenList(token)) { + double Z = blocks[i]->GetDouble("Z", "mm"); AddModule(Z); } - else{ + else { cout << "ERROR: check your input file formatting " << endl; exit(1); } @@ -259,11 +209,11 @@ void AnnularS1::ReadConfiguration(NPL::InputParser parser){ //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Construct detector and inialise sensitive part. // Called After DetecorConstruction::AddDetector Method -void AnnularS1::ConstructDetector(G4LogicalVolume* world){ +void AnnularS1::ConstructDetector(G4LogicalVolume* world) { G4RotationMatrix* rotation = NULL; - G4ThreeVector position = G4ThreeVector(0, 0, 0); + G4ThreeVector position = G4ThreeVector(0, 0, 0); - G4int NumberOfModule = m_PosZ.size() ; + G4int NumberOfModule = m_PosZ.size(); for (G4int i = 0; i < NumberOfModule; i++) { // translation to position the module @@ -272,85 +222,80 @@ void AnnularS1::ConstructDetector(G4LogicalVolume* world){ // Passage Matrix from Lab Referential to Module Referential // Identity matrix by default rotation = new G4RotationMatrix(); - if (position.z() < 0) rotation->rotateX(180*deg); - - new G4PVPlacement(G4Transform3D(*rotation, position), - ConstructVolume(), - "AnnularS1", - world, - false, - i+1); + if (position.z() < 0) + rotation->rotateX(180 * deg); + + new G4PVPlacement(G4Transform3D(*rotation, position), ConstructVolume(), "AnnularS1", world, false, i + 1); } - delete rotation ; + delete rotation; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Connect the GaspardTrackingData class to the output TTree // of the simulation -void AnnularS1::InitializeRootOutput(){ - RootOutput *pAnalysis = RootOutput::getInstance(); - TTree *pTree = pAnalysis->GetTree(); - if(!pTree->FindBranch("AnnularS1")){ +void AnnularS1::InitializeRootOutput() { + RootOutput* pAnalysis = RootOutput::getInstance(); + TTree* pTree = pAnalysis->GetTree(); + if (!pTree->FindBranch("AnnularS1")) { pTree->Branch("AnnularS1", "TS1Data", &m_Event); } - pTree->SetBranchAddress("AnnularS1",&m_Event); + pTree->SetBranchAddress("AnnularS1", &m_Event); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Read sensitive part and fill the Root tree. // Called at in the EventAction::EndOfEventAvtion -void AnnularS1::ReadSensitive(const G4Event*){ +void AnnularS1::ReadSensitive(const G4Event*) { // Clear ROOT objects m_Event->Clear(); - DSSDScorers::PS_Annular* Scorer= (DSSDScorers::PS_Annular*) m_Scorer->GetPrimitive(0); - + DSSDScorers::PS_Annular* Scorer = (DSSDScorers::PS_Annular*)m_Scorer->GetPrimitive(0); + // Loop on Silicon Ring Hit unsigned int sizeRing = Scorer->GetRingMult(); - for(unsigned int i = 0 ; i < sizeRing ; i++){ + for (unsigned int i = 0; i < sizeRing; i++) { double Energy = Scorer->GetEnergyRing(i); - if(Energy>EnergyThreshold){ - double Time = Scorer->GetTimeRing(i); - unsigned int DetNbr = Scorer->GetDetectorRing(i);; - unsigned int StripTheta = Scorer->GetStripRing(i); - - + if (Energy > EnergyThreshold) { + double Time = Scorer->GetTimeRing(i); + unsigned int DetNbr = Scorer->GetDetectorRing(i); + ; + unsigned int StripTheta = Scorer->GetStripRing(i); + // Check for associated Quadrant strip int StripQuadrant = 0; unsigned int sizeQ = Scorer->GetQuadrantMult(); - for(unsigned int q = 0 ; q < sizeQ ; q++){ - if(Scorer->GetDetectorQuadrant(q)==DetNbr){ - StripQuadrant = Scorer->GetStripQuadrant(q)-1; + for (unsigned int q = 0; q < sizeQ; q++) { + if (Scorer->GetDetectorQuadrant(q) == DetNbr) { + StripQuadrant = Scorer->GetStripQuadrant(q) - 1; break; - } + } } m_Event->SetS1ThetaEDetectorNbr(DetNbr); - m_Event->SetS1ThetaEStripNbr(StripTheta+StripQuadrant*NbrRingStrips); + m_Event->SetS1ThetaEStripNbr(StripTheta + StripQuadrant * NbrRingStrips); m_Event->SetS1ThetaEEnergy(RandGauss::shoot(Energy, ResoEnergy)); m_Event->SetS1ThetaTDetectorNbr(DetNbr); - m_Event->SetS1ThetaTStripNbr(StripTheta+StripQuadrant*NbrRingStrips); + m_Event->SetS1ThetaTStripNbr(StripTheta + StripQuadrant * NbrRingStrips); m_Event->SetS1ThetaTTime(RandGauss::shoot(Time, ResoTime)); - - } - + } } - - // Loop on Silicon Sector Hit - unsigned int sizeSector = Scorer->GetSectorMult(); - for(unsigned int i = 0 ; i < sizeSector ; i++){ + + // Loop on Silicon Sector Hit + unsigned int sizeSector = Scorer->GetSectorMult(); + for (unsigned int i = 0; i < sizeSector; i++) { double Energy = Scorer->GetEnergyRing(i); - if(Energy>EnergyThreshold){ - double Time = Scorer->GetTimeRing(i); - unsigned int DetNbr = Scorer->GetDetectorRing(i);; - unsigned int StripPhi = Scorer->GetStripSector(i); - + if (Energy > EnergyThreshold) { + double Time = Scorer->GetTimeRing(i); + unsigned int DetNbr = Scorer->GetDetectorRing(i); + ; + unsigned int StripPhi = Scorer->GetStripSector(i); + m_Event->SetS1PhiEDetectorNbr(DetNbr); - m_Event->SetS1PhiEStripNbr(StripPhi); + m_Event->SetS1PhiEStripNbr(StripPhi); m_Event->SetS1PhiEEnergy(RandGauss::shoot(Energy, ResoEnergy)); m_Event->SetS1PhiTDetectorNbr(DetNbr); @@ -361,26 +306,21 @@ void AnnularS1::ReadSensitive(const G4Event*){ } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -// Initilize the Scorer use to read out the sensitive volume -void AnnularS1::InitializeScorers(){ - bool already_exist = false; +// Initilize the Scorer use to read out the sensitive volume +void AnnularS1::InitializeScorers() { + bool already_exist = false; // Associate Scorer - m_Scorer = CheckScorer("AnnularS1_Scorer",already_exist); - if(already_exist) return; + m_Scorer = CheckScorer("AnnularS1_Scorer", already_exist); + if (already_exist) + return; G4VPrimitiveScorer* AnnularScorer = - new DSSDScorers::PS_Annular("AnnularS1_Scorer", - 2, - ActiveWaferInnerRadius, - ActiveWaferOutterRadius, - -8*22.5*deg, //MUST2 campaign 2009, See: Phd Sandra Giron - +8*22.5*deg, - NbrRingStrips, - NbrSectorStrips, - NbQuadrant); + new DSSDScorers::PS_Annular("AnnularS1_Scorer", 2, ActiveWaferInnerRadius, ActiveWaferOutterRadius, + -8 * 22.5 * deg, // MUST2 campaign 2009, See: Phd Sandra Giron + +8 * 22.5 * deg, NbrRingStrips, NbrSectorStrips, NbQuadrant); m_Scorer->RegisterPrimitive(AnnularScorer); - G4VPrimitiveScorer* InteractionScorer = new InteractionScorers::PS_Interactions("InteractionS1",ms_InterCoord,2); + G4VPrimitiveScorer* InteractionScorer = new InteractionScorers::PS_Interactions("InteractionS1", ms_InterCoord, 2); m_Scorer->RegisterPrimitive(InteractionScorer); // Add All Scorer to the Global Scorer Manager G4SDManager::GetSDMpointer()->AddNewDetector(m_Scorer); @@ -388,23 +328,20 @@ void AnnularS1::InitializeScorers(){ //////////////////////////////////////////////////////////////////////////////// // Construct Method to be pass to the DetectorFactory // //////////////////////////////////////////////////////////////////////////////// -NPS::VDetector* AnnularS1::Construct(){ - return (NPS::VDetector*) new AnnularS1(); -} +NPS::VDetector* AnnularS1::Construct() { return (NPS::VDetector*)new AnnularS1(); } //////////////////////////////////////////////////////////////////////////////// // Registering the construct method to the factory // //////////////////////////////////////////////////////////////////////////////// -extern "C"{ -class proxy_nps_annulars1{ - public: - proxy_nps_annulars1(){ - NPS::DetectorFactory::getInstance()->AddToken("AnnularS1","AnnularS1"); - NPS::DetectorFactory::getInstance()->AddDetector("AnnularS1",AnnularS1::Construct); - } +extern "C" { +class proxy_nps_annulars1 { + public: + proxy_nps_annulars1() { + NPS::DetectorFactory::getInstance()->AddToken("AnnularS1", "AnnularS1"); + NPS::DetectorFactory::getInstance()->AddDetector("AnnularS1", AnnularS1::Construct); + } }; proxy_nps_annulars1 p_nps_annulars1; } - diff --git a/NPSimulation/Detectors/Catana/Catana.cc b/NPSimulation/Detectors/Catana/Catana.cc index bc634efbeb90c3938d68840dd5fd4defa0cf2455..9ff6023b7cc0509b21b8c9c2095f7e426e5ffe9a 100644 --- a/NPSimulation/Detectors/Catana/Catana.cc +++ b/NPSimulation/Detectors/Catana/Catana.cc @@ -24,58 +24,57 @@ *****************************************************************************/ // C++ headers -#include <sstream> -#include <fstream> #include <cmath> +#include <fstream> #include <limits> -//G4 Geometry object -#include "G4Tubs.hh" +#include <sstream> +// G4 Geometry object #include "G4Box.hh" -#include "G4Trap.hh" #include "G4SubtractionSolid.hh" +#include "G4Trap.hh" +#include "G4Tubs.hh" -//G4 sensitive -#include "G4SDManager.hh" +// G4 sensitive #include "G4MultiFunctionalDetector.hh" +#include "G4SDManager.hh" -//G4 various object +// G4 various object +#include "G4Colour.hh" #include "G4Material.hh" -#include "G4Transform3D.hh" #include "G4PVPlacement.hh" +#include "G4Transform3D.hh" #include "G4VisAttributes.hh" -#include "G4Colour.hh" // NPTool header -#include "Catana.hh" #include "CalorimeterScorers.hh" +#include "Catana.hh" #include "InteractionScorers.hh" -#include "RootOutput.h" #include "MaterialManager.hh" -#include "NPSDetectorFactory.hh" #include "NPOptionManager.h" +#include "NPSDetectorFactory.hh" #include "NPSHitsMap.hh" +#include "RootOutput.h" // CLHEP header #include "CLHEP/Random/RandGauss.h" using namespace std; using namespace CLHEP; - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -namespace Catana_NS{ +namespace Catana_NS { // Energy and time Resolution - const double EnergyThreshold = 0.1*MeV; - const double ResoTime = 4.5*ns ; - const double ResoEnergy = 0.08*MeV ; - double Length = 600*mm ; + const double EnergyThreshold = 0.1 * MeV; + const double ResoTime = 4.5 * ns; + const double ResoEnergy = 0.08 * MeV; + double Length = 600 * mm; string Material = "CsI"; -} +} // namespace Catana_NS //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Catana Specific Method -Catana::Catana(){ - m_Event = new TCatanaData() ; +Catana::Catana() { + m_Event = new TCatanaData(); m_CatanaScorer = 0; m_DetectorType1 = 0; m_DetectorType2 = 0; @@ -84,21 +83,19 @@ Catana::Catana(){ m_DetectorType5 = 0; // RGB Color + Transparency - m_VisCrystal1 = new G4VisAttributes(G4Colour(0.8, 0.3, 0.3, 1)); - m_VisCrystal2 = new G4VisAttributes(G4Colour(0.3, 0.8, 0.3, 1)); - m_VisCrystal3 = new G4VisAttributes(G4Colour(0.3, 0.3, 0.8, 1)); - m_VisCrystal4 = new G4VisAttributes(G4Colour(0.3, 0.8, 0.8, 1)); - m_VisCrystal5 = new G4VisAttributes(G4Colour(0.8, 0.3, 0.8, 1)); - m_VisHousing = new G4VisAttributes(G4Colour(0.3, 0.3, 0.3, 0.2)); - m_VisReflector = new G4VisAttributes(G4Colour(1, 1, 1, 0.1)); - + m_VisCrystal1 = new G4VisAttributes(G4Colour(0.8, 0.3, 0.3, 1)); + m_VisCrystal2 = new G4VisAttributes(G4Colour(0.3, 0.8, 0.3, 1)); + m_VisCrystal3 = new G4VisAttributes(G4Colour(0.3, 0.3, 0.8, 1)); + m_VisCrystal4 = new G4VisAttributes(G4Colour(0.3, 0.8, 0.8, 1)); + m_VisCrystal5 = new G4VisAttributes(G4Colour(0.8, 0.3, 0.8, 1)); + m_VisHousing = new G4VisAttributes(G4Colour(0.3, 0.3, 0.3, 0.2)); + m_VisReflector = new G4VisAttributes(G4Colour(1, 1, 1, 0.1)); } -Catana::~Catana(){ -} +Catana::~Catana() {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Catana::AddDetector(double X,double Y, double Z, double Theta, double Phi, int ID, int Type,double Rshift){ +void Catana::AddDetector(double X, double Y, double Z, double Theta, double Phi, int ID, int Type, double Rshift) { m_X.push_back(X); m_Y.push_back(Y); m_Z.push_back(Z); @@ -110,274 +107,260 @@ void Catana::AddDetector(double X,double Y, double Z, double Theta, double Phi, } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Catana::ReadCSV(string path,double Rshift){ - std::ifstream csv(path); - if(!csv.is_open()){ +void Catana::ReadCSV(string path, double Rshift) { + std::ifstream csv(path); + if (!csv.is_open()) { std::ostringstream message; message << "Catana csv file " << path << " not found " << std::endl; } - - int ID, type,layer; - double X,Y,Z,Theta,Phi; + int ID, type, layer; + double X, Y, Z, Theta, Phi; string buffer; // ignore first line - getline(csv,buffer); - while(csv >> ID >> buffer >> type >> buffer >> layer >> buffer >> X >> buffer >> Y >> buffer >> Z >> buffer >> Theta >> buffer >> Phi){ - if(type<6) - AddDetector(X,Y,Z,Theta*deg,Phi*deg,ID,type,Rshift); - else{ - // ignore other type for which I don't have the geometry - } + getline(csv, buffer); + while (csv >> ID >> buffer >> type >> buffer >> layer >> buffer >> X >> buffer >> Y >> buffer >> Z >> buffer >> + Theta >> buffer >> Phi) { + if (type < 6) + AddDetector(X, Y, Z, Theta * deg, Phi * deg, ID, type, Rshift); + else { + // ignore other type for which I don't have the geometry + } } return; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -G4LogicalVolume* Catana::BuildDetector(int Type){ +G4LogicalVolume* Catana::BuildDetector(int Type) { // Check if the requested detector already exist - if(Type==1 && m_DetectorType1) - return m_DetectorType1; - - else if(Type==2 && m_DetectorType2) - return m_DetectorType2; - - else if(Type==3 && m_DetectorType3) - return m_DetectorType3; + if (Type == 1 && m_DetectorType1) + return m_DetectorType1; + + else if (Type == 2 && m_DetectorType2) + return m_DetectorType2; - else if(Type==4 && m_DetectorType4) - return m_DetectorType4; + else if (Type == 3 && m_DetectorType3) + return m_DetectorType3; - else if(Type==5 && m_DetectorType5) - return m_DetectorType5; + else if (Type == 4 && m_DetectorType4) + return m_DetectorType4; + else if (Type == 5 && m_DetectorType5) + return m_DetectorType5; // Define the requested geometry - double x1,x2,x3,x4,y1,y2,z,crystalz; - //int pmttype; // 1: H7195, 2:H11934 - double seal_dt = 12*mm, housing_dt = 0.5*mm, reflector_dt = 0.5*mm; + double x1, x2, x3, x4, y1, y2, z, crystalz; + // int pmttype; // 1: H7195, 2:H11934 + double seal_dt = 12 * mm, housing_dt = 0.5 * mm, reflector_dt = 0.5 * mm; + + if (Type == 1) { // crystal type 1 + x1 = 62.3 * mm; + x2 = 62.3 * mm; + x3 = 95.7 * mm; + y1 = 36.6 * mm; + y2 = 56.3 * mm; + z = 107 * mm; + crystalz = 93. * mm; // pmttype = 1; + } + if (Type == 2) { // crystal type 2 + x1 = 57.1 * mm; + x2 = 63.6 * mm; + x3 = 84.5 * mm; + y1 = 34.9 * mm; + y2 = 55.4 * mm; + z = 117 * mm; + crystalz = 103. * mm; // pmttype = 1; + } + if (Type == 3) { // crystal type 3 + x1 = 49.7 * mm; + x2 = 58.5 * mm; + x3 = 74.9 * mm; + y1 = 38.3 * mm; + y2 = 64.7 * mm; + z = 137 * mm; + crystalz = 123. * mm; // pmttype = 1; + } + if (Type == 4) { // crystal type 4 + x1 = 40.0 * mm; + x2 = 50.2 * mm; + x3 = 60.3 * mm; + y1 = 38.3 * mm; + y2 = 66.4 * mm; + z = 152 * mm; + crystalz = 138.5 * mm; // pmttype = 1; + } + if (Type == 5) { // crystal type 5 + x1 = 28.4 * mm; + x2 = 39.7 * mm; + x3 = 41.5 * mm; + y1 = 38.3 * mm; + y2 = 69.9 * mm; + z = 162 * mm; + crystalz = 148.5 * mm; // pmttype = 2; + } + x4 = x3 + (y2 / y1) * (x2 - x1); // planarity condition + Double_t beta1 = 90 * deg + std::atan((x2 - x1) / (y1 * 2)); // should be + Double_t beta2 = 90 * deg + std::atan((x4 - x3) / (y2 * 2)); // beta1 = beta2 + if (std::abs(beta1 - beta2) > 1e-4) { + std::cout << "Housing type " << Type << " is not planar" << std::endl; + } - if(Type == 1){ // crystal type 1 - x1 = 62.3*mm; x2 = 62.3*mm; x3 = 95.7*mm; y1 = 36.6*mm; y2 = 56.3*mm; - z = 107*mm; crystalz = 93.*mm; //pmttype = 1; - } - if(Type == 2){ // crystal type 2 - x1 = 57.1*mm; x2 = 63.6*mm; x3 = 84.5*mm; y1 = 34.9*mm; y2 = 55.4*mm; - z = 117*mm; crystalz = 103.*mm; //pmttype = 1; - } - if(Type == 3){ // crystal type 3 - x1 = 49.7*mm; x2 = 58.5*mm; x3 = 74.9*mm; y1 = 38.3*mm; y2 = 64.7*mm; - z = 137*mm; crystalz = 123.*mm; //pmttype = 1; - } - if(Type == 4){ // crystal type 4 - x1 = 40.0*mm; x2 = 50.2*mm; x3 = 60.3*mm; y1 = 38.3*mm; y2 = 66.4*mm; - z = 152*mm; crystalz = 138.5*mm; //pmttype = 1; - } - if(Type == 5){ // crystal type 5 - x1 = 28.4*mm; x2 = 39.7*mm; x3 = 41.5*mm; y1 = 38.3*mm; y2 = 69.9*mm; - z = 162*mm; crystalz = 148.5*mm; //pmttype = 2; - } - x4 = x3 + (y2/y1)*(x2-x1); // planarity condition - Double_t beta1 = 90*deg + std::atan((x2-x1)/(y1*2));// should be - Double_t beta2 = 90*deg + std::atan((x4-x3)/(y2*2));// beta1 = beta2 - if(std::abs(beta1-beta2)>1e-4){ - std::cout << "Housing type " << Type << " is not planar" << std::endl; - } + // Define Material + G4Material* CsI = MaterialManager::getInstance()->GetMaterialFromLibrary("CsI"); + G4Material* Al = MaterialManager::getInstance()->GetMaterialFromLibrary("Al"); + G4Material* Vacuum = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); + G4Material* Teflon = MaterialManager::getInstance()->GetMaterialFromLibrary("G4_TEFLON"); + G4RotationMatrix* Rot = new G4RotationMatrix(); + + // Parameters for G4Trap + double pDz, pDy1, pDy2, pDx1, pDx2, pDx3, pDx4; + double pTheta = 0. * deg, pPhi = 0. * deg, pAlp1 = 0. * deg, pAlp2 = 0 * deg; + + // housing outside + pDz = z * 0.5; + pDy1 = y1 * 0.5; + pDy2 = y2 * 0.5; + pDx1 = x1 * 0.5; + pDx2 = x2 * 0.5; + pDx3 = x3 * 0.5; + pDx4 = x4 * 0.5; + + G4Trap* solidHousingOUT = + new G4Trap("solidHousingOut", pDz, pTheta, pPhi, pDy1, pDx1, pDx2, pAlp1, pDy2, pDx3, pDx4, pAlp2); + + G4LogicalVolume* result = 0; + if (Type == 1) { + m_DetectorType1 = new G4LogicalVolume(solidHousingOUT, Vacuum, "logicDetectorType1", 0, 0, 0); + result = m_DetectorType1; + } + else if (Type == 2) { + m_DetectorType2 = new G4LogicalVolume(solidHousingOUT, Vacuum, "logicDetectorType2", 0, 0, 0); + result = m_DetectorType2; + } - // Define Material - G4Material* CsI = MaterialManager::getInstance()->GetMaterialFromLibrary("CsI"); - G4Material* Al = MaterialManager::getInstance()->GetMaterialFromLibrary("Al"); - G4Material* Vacuum= MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); - G4Material* Teflon= MaterialManager::getInstance()->GetMaterialFromLibrary("G4_TEFLON"); - G4RotationMatrix* Rot= new G4RotationMatrix(); - - - // Parameters for G4Trap - double pDz, pDy1, pDy2, pDx1, pDx2, pDx3, pDx4; - double pTheta=0.*deg, pPhi=0.*deg, pAlp1=0.*deg, pAlp2=0*deg; - - // housing outside - pDz = z*0.5; - pDy1 = y1*0.5; - pDy2 = y2*0.5; - pDx1 = x1*0.5; - pDx2 = x2*0.5; - pDx3 = x3*0.5; - pDx4 = x4*0.5; - - G4Trap *solidHousingOUT = new G4Trap("solidHousingOut", pDz, pTheta, pPhi, - pDy1, pDx1, pDx2, pAlp1, pDy2, pDx3, - pDx4, pAlp2); - - G4LogicalVolume* result = 0; - if(Type==1){ - m_DetectorType1 = new G4LogicalVolume(solidHousingOUT, - Vacuum, - "logicDetectorType1", - 0,0,0); - result = m_DetectorType1; - } - else if(Type==2){ - m_DetectorType2 = new G4LogicalVolume(solidHousingOUT, - Vacuum, - "logicDetectorType2", - 0,0,0); - result = m_DetectorType2; - } - - - else if(Type==3){ - m_DetectorType3 = new G4LogicalVolume(solidHousingOUT, - Vacuum, - "logicDetectorType3", - 0,0,0); - result = m_DetectorType3; - } - - - else if(Type==4){ - m_DetectorType4 = new G4LogicalVolume(solidHousingOUT, - Vacuum, - "logicDetectorType4", - 0,0,0); - result = m_DetectorType4; - } - - else if(Type==5){ - m_DetectorType5 = new G4LogicalVolume(solidHousingOUT, - Vacuum, - "logicDetectorType5", - 0,0,0); - result = m_DetectorType5; - } - - - result->SetVisAttributes(G4VisAttributes::Invisible); - - - // -- Al housing inside - double length = z; - double ax1 = pDx1; - double bx1 = pDx3; - double ax2 = pDx2; - double bx2 = pDx4; - double ay1 = pDy1; - double by1 = pDy2; - - pDz = (length - seal_dt - housing_dt)/2.; - pDy1 = (by1-ay1)/length * housing_dt + ay1 - housing_dt; - pDx1 = (bx1-ax1)/length * housing_dt + ax1 - housing_dt; - pDx2 = (bx2-ax2)/length * housing_dt + ax2 - housing_dt; - pDy2 = (by1-ay1)/length * (length - seal_dt) + ay1 - housing_dt; - pDx3 = (bx1-ax1)/length * (length - seal_dt) + ax1 - housing_dt; - //pDx4 = (bx2-ax2)/length * (length - seal_dt) + ax2 - housing_dt; - pDx4 = pDx3 + (pDy2 / pDy1)*(pDx2 - pDx1); // planarity condition - - G4Trap* solidHousingIN = new G4Trap("solidHousingIN", pDz, pTheta, pPhi, - pDy1, pDx1, pDx2, pAlp1, pDy2, pDx3, - pDx4, pAlp2); - - - double offset = -(length*0.5 - pDz - housing_dt); - G4SubtractionSolid* solidHousing = - new G4SubtractionSolid("solidHousing", solidHousingOUT,// mother - solidHousingIN, Rot, - G4ThreeVector(0.,0.,offset)); - - G4LogicalVolume* LogicHousing = new G4LogicalVolume(solidHousing, Al,"logicHousing",0,0,0); - LogicHousing->SetVisAttributes(m_VisHousing); - - // -- Crystal -- - double space = 2.*mm; // space btw. crystal and housing - length = pDz * 2.; // housing inner z length - ax1 = pDx1; - bx1 = pDx3; - ax2 = pDx2; - bx2 = pDx4; - ay1 = pDy1; - by1 = pDy2; - - pDz = crystalz*0.5; - pDy1 = (by1-ay1)/length * reflector_dt + ay1 - space; - pDx1 = (bx1-ax1)/length * reflector_dt + ax1 - space; - pDx2 = (bx2-ax2)/length * reflector_dt + ax2 - space; - pDy2 = (by1-ay1)/length * (reflector_dt + crystalz) + ay1 - space; - pDx3 = (bx1-ax1)/length * (reflector_dt + crystalz) + ax1 - space; - //pDx4 = (bx2-ax2)/length * (reflector_dt + crystalz) + ax2 - space; - pDx4 = pDx3 + (pDy2 / pDy1)*(pDx2 - pDx1); // planarity condition - - G4Trap* solidCrystal = new G4Trap("solidCrystal", pDz, pTheta, pPhi, - pDy1, pDx1, pDx2, pAlp1, pDy2, pDx3, - pDx4, pAlp2); - - G4LogicalVolume* LogicCrystal = new G4LogicalVolume(solidCrystal,// solid - CsI, - "SolidCrystal", - 0,0,0); - if(Type==1) - LogicCrystal->SetVisAttributes(m_VisCrystal1); - - else if(Type==2) - LogicCrystal->SetVisAttributes(m_VisCrystal2); - - else if(Type==3) - LogicCrystal->SetVisAttributes(m_VisCrystal3); - - else if(Type==4) - LogicCrystal->SetVisAttributes(m_VisCrystal4); - - else if(Type==5) - LogicCrystal->SetVisAttributes(m_VisCrystal5); - - - LogicCrystal->SetSensitiveDetector(m_CatanaScorer); - - // -- Teflon reflector - length = crystalz; - ax1 = pDx1; - bx1 = pDx3; - ax2 = pDx2; - bx2 = pDx4; - ay1 = pDy1; - by1 = pDy2; - - pDz = crystalz*0.5 + reflector_dt; - pDy1 = (by1-ay1)/length * -reflector_dt + ay1 + reflector_dt; - pDx1 = (bx1-ax1)/length * -reflector_dt + ax1 + reflector_dt; - pDx2 = (bx2-ax2)/length * -reflector_dt + ax2 + reflector_dt; - pDy2 = (by1-ay1)/length * (reflector_dt + crystalz) + ay1 + reflector_dt; - pDx3 = (bx1-ax1)/length * (reflector_dt + crystalz) + ax1 + reflector_dt; - //pDx4 = (bx2-ax2)/length * (reflector_dt + crystalz) + ax2 + reflector_dt; - pDx4 = pDx3 + (pDy2 / pDy1)*(pDx2 - pDx1); // planarity condition - - G4Trap* solidReflector = new G4Trap("solidReflector",pDz, pTheta, - pPhi, pDy1, pDx1, pDx2, pAlp1, - pDy2, pDx3, pDx4, pAlp2); - - G4LogicalVolume* LogicReflector = new G4LogicalVolume(solidReflector, Teflon, - "logicReflector", - 0,0,0); - - LogicReflector->SetVisAttributes(m_VisReflector); - - // Place volume in each other: - new G4PVPlacement(G4Transform3D(*Rot,G4ThreeVector(0,0,0)), - LogicHousing, - "CatanaHousing",result,false,0); - - - m_Zoffset[Type] = (z - crystalz)*0.5 - housing_dt - reflector_dt; - - new G4PVPlacement(G4Transform3D(*Rot,G4ThreeVector(0,0,-m_Zoffset[Type])), - LogicReflector, - "CatanaReflector",result,false,0); - - new G4PVPlacement(G4Transform3D(*Rot,G4ThreeVector(0,0,0)), - LogicCrystal, - "CatanaCrystal",LogicReflector,false,0); - - return result; + else if (Type == 3) { + m_DetectorType3 = new G4LogicalVolume(solidHousingOUT, Vacuum, "logicDetectorType3", 0, 0, 0); + result = m_DetectorType3; + } + + else if (Type == 4) { + m_DetectorType4 = new G4LogicalVolume(solidHousingOUT, Vacuum, "logicDetectorType4", 0, 0, 0); + result = m_DetectorType4; + } + else if (Type == 5) { + m_DetectorType5 = new G4LogicalVolume(solidHousingOUT, Vacuum, "logicDetectorType5", 0, 0, 0); + result = m_DetectorType5; + } + + result->SetVisAttributes(G4VisAttributes::GetInvisible()); + + // -- Al housing inside + double length = z; + double ax1 = pDx1; + double bx1 = pDx3; + double ax2 = pDx2; + double bx2 = pDx4; + double ay1 = pDy1; + double by1 = pDy2; + + pDz = (length - seal_dt - housing_dt) / 2.; + pDy1 = (by1 - ay1) / length * housing_dt + ay1 - housing_dt; + pDx1 = (bx1 - ax1) / length * housing_dt + ax1 - housing_dt; + pDx2 = (bx2 - ax2) / length * housing_dt + ax2 - housing_dt; + pDy2 = (by1 - ay1) / length * (length - seal_dt) + ay1 - housing_dt; + pDx3 = (bx1 - ax1) / length * (length - seal_dt) + ax1 - housing_dt; + // pDx4 = (bx2-ax2)/length * (length - seal_dt) + ax2 - housing_dt; + pDx4 = pDx3 + (pDy2 / pDy1) * (pDx2 - pDx1); // planarity condition + + G4Trap* solidHousingIN = + new G4Trap("solidHousingIN", pDz, pTheta, pPhi, pDy1, pDx1, pDx2, pAlp1, pDy2, pDx3, pDx4, pAlp2); + + double offset = -(length * 0.5 - pDz - housing_dt); + G4SubtractionSolid* solidHousing = new G4SubtractionSolid("solidHousing", solidHousingOUT, // mother + solidHousingIN, Rot, G4ThreeVector(0., 0., offset)); + + G4LogicalVolume* LogicHousing = new G4LogicalVolume(solidHousing, Al, "logicHousing", 0, 0, 0); + LogicHousing->SetVisAttributes(m_VisHousing); + + // -- Crystal -- + double space = 2. * mm; // space btw. crystal and housing + length = pDz * 2.; // housing inner z length + ax1 = pDx1; + bx1 = pDx3; + ax2 = pDx2; + bx2 = pDx4; + ay1 = pDy1; + by1 = pDy2; + + pDz = crystalz * 0.5; + pDy1 = (by1 - ay1) / length * reflector_dt + ay1 - space; + pDx1 = (bx1 - ax1) / length * reflector_dt + ax1 - space; + pDx2 = (bx2 - ax2) / length * reflector_dt + ax2 - space; + pDy2 = (by1 - ay1) / length * (reflector_dt + crystalz) + ay1 - space; + pDx3 = (bx1 - ax1) / length * (reflector_dt + crystalz) + ax1 - space; + // pDx4 = (bx2-ax2)/length * (reflector_dt + crystalz) + ax2 - space; + pDx4 = pDx3 + (pDy2 / pDy1) * (pDx2 - pDx1); // planarity condition + + G4Trap* solidCrystal = + new G4Trap("solidCrystal", pDz, pTheta, pPhi, pDy1, pDx1, pDx2, pAlp1, pDy2, pDx3, pDx4, pAlp2); + + G4LogicalVolume* LogicCrystal = new G4LogicalVolume(solidCrystal, // solid + CsI, "SolidCrystal", 0, 0, 0); + if (Type == 1) + LogicCrystal->SetVisAttributes(m_VisCrystal1); + + else if (Type == 2) + LogicCrystal->SetVisAttributes(m_VisCrystal2); + + else if (Type == 3) + LogicCrystal->SetVisAttributes(m_VisCrystal3); + + else if (Type == 4) + LogicCrystal->SetVisAttributes(m_VisCrystal4); + + else if (Type == 5) + LogicCrystal->SetVisAttributes(m_VisCrystal5); + + LogicCrystal->SetSensitiveDetector(m_CatanaScorer); + + // -- Teflon reflector + length = crystalz; + ax1 = pDx1; + bx1 = pDx3; + ax2 = pDx2; + bx2 = pDx4; + ay1 = pDy1; + by1 = pDy2; + + pDz = crystalz * 0.5 + reflector_dt; + pDy1 = (by1 - ay1) / length * -reflector_dt + ay1 + reflector_dt; + pDx1 = (bx1 - ax1) / length * -reflector_dt + ax1 + reflector_dt; + pDx2 = (bx2 - ax2) / length * -reflector_dt + ax2 + reflector_dt; + pDy2 = (by1 - ay1) / length * (reflector_dt + crystalz) + ay1 + reflector_dt; + pDx3 = (bx1 - ax1) / length * (reflector_dt + crystalz) + ax1 + reflector_dt; + // pDx4 = (bx2-ax2)/length * (reflector_dt + crystalz) + ax2 + reflector_dt; + pDx4 = pDx3 + (pDy2 / pDy1) * (pDx2 - pDx1); // planarity condition + + G4Trap* solidReflector = + new G4Trap("solidReflector", pDz, pTheta, pPhi, pDy1, pDx1, pDx2, pAlp1, pDy2, pDx3, pDx4, pAlp2); + + G4LogicalVolume* LogicReflector = new G4LogicalVolume(solidReflector, Teflon, "logicReflector", 0, 0, 0); + + LogicReflector->SetVisAttributes(m_VisReflector); + + // Place volume in each other: + new G4PVPlacement(G4Transform3D(*Rot, G4ThreeVector(0, 0, 0)), LogicHousing, "CatanaHousing", result, false, 0); + + m_Zoffset[Type] = (z - crystalz) * 0.5 - housing_dt - reflector_dt; + + new G4PVPlacement(G4Transform3D(*Rot, G4ThreeVector(0, 0, -m_Zoffset[Type])), LogicReflector, "CatanaReflector", + result, false, 0); + + new G4PVPlacement(G4Transform3D(*Rot, G4ThreeVector(0, 0, 0)), LogicCrystal, "CatanaCrystal", LogicReflector, false, + 0); + + return result; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... @@ -387,138 +370,135 @@ G4LogicalVolume* Catana::BuildDetector(int Type){ // Read stream at Configfile to pick-up parameters of detector (Position,...) // Called in DetecorConstruction::ReadDetextorConfiguration Method -void Catana::ReadConfiguration(NPL::InputParser parser){ +void Catana::ReadConfiguration(NPL::InputParser parser) { // CSV config - vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithTokenAndValue("Catana","CSV"); - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << "//// " << blocks.size() << " CSV block found " << endl; + vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithTokenAndValue("Catana", "CSV"); + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks.size() << " CSV block found " << endl; - vector<string> token = {"Path","Pos","Rshift"}; + vector<string> token = {"Path", "Pos", "Rshift"}; - for(unsigned int i = 0 ; i < blocks.size() ; i++){ - if(blocks[i]->HasTokenList(token)){ - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << endl << "//// Catana " << i+1 << endl; + for (unsigned int i = 0; i < blocks.size(); i++) { + if (blocks[i]->HasTokenList(token)) { + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// Catana " << i + 1 << endl; string path = blocks[i]->GetString("Path"); - double Rshift = blocks[i]->GetDouble("Rshift","micrometer"); + double Rshift = blocks[i]->GetDouble("Rshift", "micrometer"); // Reference position of the whole array - m_Ref = NPS::ConvertVector(blocks[i]->GetTVector3("Pos","mm")); - ReadCSV(path,Rshift); + m_Ref = NPS::ConvertVector(blocks[i]->GetTVector3("Pos", "mm")); + ReadCSV(path, Rshift); } - else{ + else { cout << "ERROR: check your input file formatting " << endl; exit(1); } } - + // Type 1 - blocks = parser.GetAllBlocksWithTokenAndValue("Catana","Detector"); - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << "//// " << blocks.size() << " detectors found " << endl; - - token = {"X","Y","Z","Theta","Phi","ID","Type"}; - - for(unsigned int i = 0 ; i < blocks.size() ; i++){ - if(blocks[i]->HasTokenList(token)){ - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << endl << "//// Catana " << i+1 << endl; - double X = blocks[i]->GetDouble("X","mm"); - double Y = blocks[i]->GetDouble("Y","mm"); - double Z = blocks[i]->GetDouble("Z","mm"); - double Theta = blocks[i]->GetDouble("Theta","deg"); - double Phi = blocks[i]->GetDouble("Phi","deg"); - int ID = blocks[i]->GetInt("ID"); - int Type = blocks[i]->GetInt("Type"); - AddDetector(X,Y,Z,Theta,Phi,ID,Type); + blocks = parser.GetAllBlocksWithTokenAndValue("Catana", "Detector"); + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks.size() << " detectors found " << endl; + + token = {"X", "Y", "Z", "Theta", "Phi", "ID", "Type"}; + + for (unsigned int i = 0; i < blocks.size(); i++) { + if (blocks[i]->HasTokenList(token)) { + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// Catana " << i + 1 << endl; + double X = blocks[i]->GetDouble("X", "mm"); + double Y = blocks[i]->GetDouble("Y", "mm"); + double Z = blocks[i]->GetDouble("Z", "mm"); + double Theta = blocks[i]->GetDouble("Theta", "deg"); + double Phi = blocks[i]->GetDouble("Phi", "deg"); + int ID = blocks[i]->GetInt("ID"); + int Type = blocks[i]->GetInt("Type"); + AddDetector(X, Y, Z, Theta, Phi, ID, Type); } - else{ + else { cout << "ERROR: check your input file formatting " << endl; exit(1); } } - } - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Construct detector and inialise sensitive part. // Called After DetecorConstruction::AddDetector Method -void Catana::ConstructDetector(G4LogicalVolume* world){ - for (unsigned short i = 0 ; i < m_X.size() ; i++) { - if(m_Type[i]>5) +void Catana::ConstructDetector(G4LogicalVolume* world) { + for (unsigned short i = 0; i < m_X.size(); i++) { + if (m_Type[i] > 5) exit(1); BuildDetector(m_Type[i]); // Reference coordinate given for center of crystal - G4ThreeVector Det_pos = G4ThreeVector(m_X[i],m_Y[i],m_Z[i]) ; - // But placed volume is casing which is shifted w/respect to crystal + G4ThreeVector Det_pos = G4ThreeVector(m_X[i], m_Y[i], m_Z[i]); + // But placed volume is casing which is shifted w/respect to crystal G4ThreeVector Det_dir = Det_pos; Det_dir.unit(); // had to add a 70micron in radius to avoid overlap when using official // csv simulation file - Det_dir.setMag(m_Zoffset[m_Type[i]]+m_Rshift[i]); - Det_pos+=Det_dir+m_Ref; + Det_dir.setMag(m_Zoffset[m_Type[i]] + m_Rshift[i]); + Det_pos += Det_dir + m_Ref; G4RotationMatrix* Rot = new G4RotationMatrix(); Rot->rotateX(-m_Theta[i]); Rot->rotateZ(m_Phi[i]); - new G4PVPlacement(G4Transform3D(*Rot,Det_pos), - BuildDetector(m_Type[i]), - "Catana",world,false,m_ID[i]); + new G4PVPlacement(G4Transform3D(*Rot, Det_pos), BuildDetector(m_Type[i]), "Catana", world, false, m_ID[i]); } } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Add Detector branch to the EventTree. // Called After DetecorConstruction::AddDetector Method -void Catana::InitializeRootOutput(){ - RootOutput *pAnalysis = RootOutput::getInstance(); - TTree *pTree = pAnalysis->GetTree(); - if(!pTree->FindBranch("Catana")){ - pTree->Branch("Catana", "TCatanaData", &m_Event) ; +void Catana::InitializeRootOutput() { + RootOutput* pAnalysis = RootOutput::getInstance(); + TTree* pTree = pAnalysis->GetTree(); + if (!pTree->FindBranch("Catana")) { + pTree->Branch("Catana", "TCatanaData", &m_Event); } - pTree->SetBranchAddress("Catana", &m_Event) ; + pTree->SetBranchAddress("Catana", &m_Event); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Read sensitive part and fill the Root tree. // Called at in the EventAction::EndOfEventAvtion -void Catana::ReadSensitive(const G4Event* ){ +void Catana::ReadSensitive(const G4Event*) { m_Event->Clear(); /////////// // Calorimeter scorer - CalorimeterScorers::PS_Calorimeter* Scorer= (CalorimeterScorers::PS_Calorimeter*) m_CatanaScorer->GetPrimitive(0); - - unsigned int size = Scorer->GetMult(); - for(unsigned int i = 0 ; i < size ; i++){ - vector<unsigned int> level = Scorer->GetLevel(i); - double Energy = RandGauss::shoot(Scorer->GetEnergy(i),Catana_NS::ResoEnergy); - if(Energy>Catana_NS::EnergyThreshold){ - double Time = RandGauss::shoot(Scorer->GetTime(i),Catana_NS::ResoTime); + CalorimeterScorers::PS_Calorimeter* Scorer = (CalorimeterScorers::PS_Calorimeter*)m_CatanaScorer->GetPrimitive(0); + + unsigned int size = Scorer->GetMult(); + for (unsigned int i = 0; i < size; i++) { + vector<unsigned int> level = Scorer->GetLevel(i); + double Energy = RandGauss::shoot(Scorer->GetEnergy(i), Catana_NS::ResoEnergy); + if (Energy > Catana_NS::EnergyThreshold) { + double Time = RandGauss::shoot(Scorer->GetTime(i), Catana_NS::ResoTime); int DetectorNbr = level[0]; - m_Event->SetEnergy(DetectorNbr,Energy); - m_Event->SetTime(DetectorNbr,Time); + m_Event->SetEnergy(DetectorNbr, Energy); + m_Event->SetTime(DetectorNbr, Time); } } } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -//////////////////////////////////////////////////////////////// -void Catana::InitializeScorers() { +//////////////////////////////////////////////////////////////// +void Catana::InitializeScorers() { // This check is necessary in case the geometry is reloaded - bool already_exist = false; - m_CatanaScorer = CheckScorer("CatanaScorer",already_exist) ; + bool already_exist = false; + m_CatanaScorer = CheckScorer("CatanaScorer", already_exist); - if(already_exist) - return ; + if (already_exist) + return; // Otherwise the scorer is initialised - vector<int> level; level.push_back(2); - G4VPrimitiveScorer* Calorimeter= new CalorimeterScorers::PS_Calorimeter("Calorimeter",level, 0) ; - G4VPrimitiveScorer* Interaction= new InteractionScorers::PS_Interactions("Interaction",ms_InterCoord, 0) ; - //and register it to the multifunctionnal detector + vector<int> level; + level.push_back(2); + G4VPrimitiveScorer* Calorimeter = new CalorimeterScorers::PS_Calorimeter("Calorimeter", level, 0); + G4VPrimitiveScorer* Interaction = new InteractionScorers::PS_Interactions("Interaction", ms_InterCoord, 0); + // and register it to the multifunctionnal detector m_CatanaScorer->RegisterPrimitive(Calorimeter); m_CatanaScorer->RegisterPrimitive(Interaction); - G4SDManager::GetSDMpointer()->AddNewDetector(m_CatanaScorer) ; + G4SDManager::GetSDMpointer()->AddNewDetector(m_CatanaScorer); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... @@ -527,22 +507,20 @@ void Catana::InitializeScorers() { //////////////////////////////////////////////////////////////////////////////// // Construct Method to be pass to the DetectorFactory // //////////////////////////////////////////////////////////////////////////////// -NPS::VDetector* Catana::Construct(){ - return (NPS::VDetector*) new Catana(); -} +NPS::VDetector* Catana::Construct() { return (NPS::VDetector*)new Catana(); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //////////////////////////////////////////////////////////////////////////////// // Registering the construct method to the factory // //////////////////////////////////////////////////////////////////////////////// -extern"C" { - class proxy_nps_Catana{ - public: - proxy_nps_Catana(){ - NPS::DetectorFactory::getInstance()->AddToken("Catana","Catana"); - NPS::DetectorFactory::getInstance()->AddDetector("Catana",Catana::Construct); - } - }; - - proxy_nps_Catana p_nps_Catana; +extern "C" { +class proxy_nps_Catana { + public: + proxy_nps_Catana() { + NPS::DetectorFactory::getInstance()->AddToken("Catana", "Catana"); + NPS::DetectorFactory::getInstance()->AddDetector("Catana", Catana::Construct); + } +}; + +proxy_nps_Catana p_nps_Catana; } diff --git a/NPSimulation/Detectors/ChiNu/ChiNu.cc b/NPSimulation/Detectors/ChiNu/ChiNu.cc index f8a2b108afc5759a27428894be0eacdb898d7afe..1382ccf01d1459e847c75e6715c49f927fd5af4e 100644 --- a/NPSimulation/Detectors/ChiNu/ChiNu.cc +++ b/NPSimulation/Detectors/ChiNu/ChiNu.cc @@ -62,7 +62,7 @@ using namespace CLHEP; namespace ChiNu_NS{ // EJ309 Scintillator - Energy and time Resolution const double EnergyThreshold = 0.*MeV; - const double ResoTime = 0.5*ns ; + const double ResoTime = 0.686*ns ; const double ResoEnergy = 0.1*MeV ; const double Radius = 8.90*cm ; const double Thickness = 5.08*cm ; @@ -242,8 +242,8 @@ void ChiNu::ReadConfiguration(NPL::InputParser parser){ // Called After DetecorConstruction::AddDetector Method void ChiNu::ConstructDetector(G4LogicalVolume* world){ - G4Material* Air = MaterialManager::getInstance()->GetMaterialFromLibrary("Air"); - world->SetMaterial(Air); + //G4Material* Air = MaterialManager::getInstance()->GetMaterialFromLibrary("Air"); + //world->SetMaterial(Air); for (unsigned short i = 0 ; i < m_R.size() ; i++) { diff --git a/NPSimulation/Detectors/ComptonTelescope/ComptonTelescope.cc b/NPSimulation/Detectors/ComptonTelescope/ComptonTelescope.cc index cb8e38a15c4949793163623fb5ce2be0e1f61214..1c3b38595c0e0ac341dbb926cc742feb30b67f14 100644 --- a/NPSimulation/Detectors/ComptonTelescope/ComptonTelescope.cc +++ b/NPSimulation/Detectors/ComptonTelescope/ComptonTelescope.cc @@ -25,35 +25,35 @@ *****************************************************************************/ // C++ headers +#include <cmath> #include <sstream> #include <string> -#include <cmath> // ROOT headers #include "TString.h" // G4 Geometry headers -#include "G4Trd.hh" #include "G4Box.hh" #include "G4Trap.hh" +#include "G4Trd.hh" // G4 various headers -#include "G4Material.hh" -#include "G4VisAttributes.hh" #include "G4Colour.hh" +#include "G4Material.hh" +#include "G4PVDivision.hh" +#include "G4PVPlacement.hh" #include "G4RotationMatrix.hh" #include "G4Transform3D.hh" -#include "G4PVPlacement.hh" -#include "G4PVDivision.hh" +#include "G4VisAttributes.hh" // NPTool headers #include "ComptonTelescope.hh" #include "ComptonTelescopeScorers.hh" -#include "ObsoleteGeneralScorers.hh" #include "MaterialManager.hh" +#include "NPOptionManager.h" #include "NPSDetectorFactory.hh" +#include "ObsoleteGeneralScorers.hh" #include "RootOutput.h" -#include "NPOptionManager.h" // CLHEP #include "CLHEP/Random/RandGauss.h" @@ -62,188 +62,154 @@ using namespace CLHEP; using namespace COMPTONTELESCOPE; - - - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -ComptonTelescope::ComptonTelescope() - : m_Event(new TComptonTelescopeData()), - m_ProcessEvent(new TComptonTelescopeProcessData()), - m_NumberOfDSSSD(1), - m_SizeOfDSSSD(100), - m_NumberOfStrips(50), - m_ThicknessOfDSSSD(2), - m_DistanceInterDSSSD(7), - m_ThicknessOfCalorimeter(50), - m_DistanceTrackerCalorimeter(7) +ComptonTelescope::ComptonTelescope() + : m_Event(new TComptonTelescopeData()), m_ProcessEvent(new TComptonTelescopeProcessData()), m_NumberOfDSSSD(1), + m_SizeOfDSSSD(100), m_NumberOfStrips(50), m_ThicknessOfDSSSD(2), m_DistanceInterDSSSD(7), + m_ThicknessOfCalorimeter(50), m_DistanceTrackerCalorimeter(7) { - // calculate tower height - m_TowerHeight = (m_NumberOfDSSSD-1) * m_DistanceInterDSSSD + m_ThicknessOfDSSSD - + m_DistanceTrackerCalorimeter + m_ThicknessOfCalorimeter; - - // initialize materials - InitializeMaterial(); -} - + // calculate tower height + m_TowerHeight = (m_NumberOfDSSSD - 1) * m_DistanceInterDSSSD + m_ThicknessOfDSSSD + m_DistanceTrackerCalorimeter + + m_ThicknessOfCalorimeter; + // initialize materials + InitializeMaterial(); +} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -ComptonTelescope::~ComptonTelescope() -{ - // Materials - delete m_MaterialSilicon; - delete m_MaterialAluminium; - delete m_MaterialLaBr3; - delete m_MaterialVacuum; - - // Data - delete m_Event; - - // Scorers - delete m_TrackerScorer; - delete m_CalorimeterScorer; +ComptonTelescope::~ComptonTelescope() { + // Materials + delete m_MaterialSilicon; + delete m_MaterialAluminium; + delete m_MaterialLaBr3; + delete m_MaterialVacuum; + + // Data + delete m_Event; + + // Scorers + delete m_TrackerScorer; + delete m_CalorimeterScorer; } - - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void ComptonTelescope::AddModule(G4ThreeVector X1_Y1 , - G4ThreeVector X128_Y1 , - G4ThreeVector X1_Y128 , - G4ThreeVector X128_Y128 , - bool wTracker , - bool wCalorimeter) -{ - m_DefinitionType.push_back(true) ; - - m_X1_Y1.push_back(X1_Y1) ; - m_X128_Y1.push_back(X128_Y1) ; - m_X1_Y128.push_back(X1_Y128) ; - m_X128_Y128.push_back(X128_Y128) ; - m_wTracker.push_back(wTracker) ; - m_wCalorimeter.push_back(wCalorimeter) ; - - m_R.push_back(0) ; - m_Theta.push_back(0) ; - m_Phi.push_back(0) ; - m_beta_u.push_back(0) ; - m_beta_v.push_back(0) ; - m_beta_w.push_back(0) ; +void ComptonTelescope::AddModule(G4ThreeVector X1_Y1, G4ThreeVector X128_Y1, G4ThreeVector X1_Y128, + G4ThreeVector X128_Y128, bool wTracker, bool wCalorimeter) { + m_DefinitionType.push_back(true); + + m_X1_Y1.push_back(X1_Y1); + m_X128_Y1.push_back(X128_Y1); + m_X1_Y128.push_back(X1_Y128); + m_X128_Y128.push_back(X128_Y128); + m_wTracker.push_back(wTracker); + m_wCalorimeter.push_back(wCalorimeter); + + m_R.push_back(0); + m_Theta.push_back(0); + m_Phi.push_back(0); + m_beta_u.push_back(0); + m_beta_v.push_back(0); + m_beta_w.push_back(0); } - - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void ComptonTelescope::AddModule(G4double R , - G4double Theta , - G4double Phi , - G4double beta_u , - G4double beta_v , - G4double beta_w , - bool wTracker , - bool wCalorimeter) -{ - G4ThreeVector empty = G4ThreeVector(0, 0, 0); - - m_DefinitionType.push_back(false); - - m_R.push_back(R) ; - m_Theta.push_back(Theta) ; - m_Phi.push_back(Phi) ; - m_beta_u.push_back(beta_u) ; - m_beta_v.push_back(beta_v) ; - m_beta_w.push_back(beta_w) ; - m_wTracker.push_back(wTracker) ; - m_wCalorimeter.push_back(wCalorimeter) ; - - m_X1_Y1.push_back(empty) ; - m_X128_Y1.push_back(empty) ; - m_X1_Y128.push_back(empty) ; - m_X128_Y128.push_back(empty) ; +void ComptonTelescope::AddModule(G4double R, G4double Theta, G4double Phi, G4double beta_u, G4double beta_v, + G4double beta_w, bool wTracker, bool wCalorimeter) { + G4ThreeVector empty = G4ThreeVector(0, 0, 0); + + m_DefinitionType.push_back(false); + + m_R.push_back(R); + m_Theta.push_back(Theta); + m_Phi.push_back(Phi); + m_beta_u.push_back(beta_u); + m_beta_v.push_back(beta_v); + m_beta_w.push_back(beta_w); + m_wTracker.push_back(wTracker); + m_wCalorimeter.push_back(wCalorimeter); + + m_X1_Y1.push_back(empty); + m_X128_Y1.push_back(empty); + m_X1_Y128.push_back(empty); + m_X128_Y128.push_back(empty); } - - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void ComptonTelescope::VolumeMaker(G4int TelescopeNumber, - G4ThreeVector CTpos, - G4RotationMatrix* CTrot, - bool wTracker, - bool wCalorimeter, - G4LogicalVolume* world) -{ - G4double NbrTelescopes = TelescopeNumber ; - G4String DetectorNumber ; - ostringstream Number ; - Number << NbrTelescopes ; - DetectorNumber = Number.str() ; - - //////////////////////////////////////////////////////////////// - ////////////// Starting Volume Definition ////////////////////// - //////////////////////////////////////////////////////////////// - G4String Name = "ComptonTelescopeTower" + DetectorNumber; - - // calculate tower height - m_TowerHeight = (m_NumberOfDSSSD-1) * m_DistanceInterDSSSD + m_ThicknessOfDSSSD - + m_DistanceTrackerCalorimeter + m_ThicknessOfCalorimeter; - - G4Box* solidComptonTelescope = new G4Box(Name, 0.5*m_SizeOfDSSSD, 0.5*m_SizeOfDSSSD, 0.5*m_TowerHeight); - G4LogicalVolume* logicComptonTelescope = new G4LogicalVolume(solidComptonTelescope, m_MaterialVacuum, Name, 0, 0, 0); - - new G4PVPlacement(G4Transform3D(*CTrot, CTpos), logicComptonTelescope, Name, world, false, 0); - - logicComptonTelescope->SetVisAttributes(G4VisAttributes::Invisible); - if (m_non_sensitive_part_visiualisation) logicComptonTelescope->SetVisAttributes(G4VisAttributes(G4Colour(0.90, 0.90, 0.90))); - - - //////////////////////////////////////////////////////////// - //////////////// Tracker Construction ////////////////////// - //////////////////////////////////////////////////////////// - if (wTracker) { - // tracker detector itself - G4Box* solidTracker = new G4Box("solidTracker", 0.5*m_SizeOfDSSSD, 0.5*m_SizeOfDSSSD, 0.5*m_ThicknessOfDSSSD); - G4LogicalVolume* logicTracker = new G4LogicalVolume(solidTracker, m_MaterialSilicon, "logicTracker", 0, 0, 0); - - G4ThreeVector positionTracker; - for (G4int i = 0; i < m_NumberOfDSSSD; ++i) { // loop on number of DSSSDs - G4double position = -m_TowerHeight/2 + m_ThicknessOfDSSSD/2 + i*m_DistanceInterDSSSD; - positionTracker = G4ThreeVector(0, 0, position); - G4String nameTracker = Name + "_Tracker"; - ostringstream index; - index << i; - nameTracker = nameTracker + index.str(); - new G4PVPlacement(0, positionTracker, logicTracker, nameTracker, logicComptonTelescope, false, i); - } // end loop on number of DSSSDs - - // set tracker sensible - logicTracker->SetSensitiveDetector(m_TrackerScorer); - - // visualisation of tracker - G4VisAttributes* TrackerVisAtt = new G4VisAttributes(G4Colour(0.0, 0.0, 0.9)); // blue - logicTracker->SetVisAttributes(TrackerVisAtt); - } - - - //////////////////////////////////////////////////////////////// - ///////////////// Calorimeter Construction ///////////////////// - //////////////////////////////////////////////////////////////// - if (wCalorimeter) { - // calorimeter detector - G4Box* solidCalorimeter = new G4Box("solidCalorimeter", 0.5*m_SizeOfDSSSD, 0.5*m_SizeOfDSSSD, 0.5*m_ThicknessOfCalorimeter); - G4LogicalVolume* logicCalorimeter = new G4LogicalVolume(solidCalorimeter, m_MaterialSilicon, "logicCalorimeter", 0, 0, 0); - - G4double position = m_TowerHeight/2 - m_ThicknessOfCalorimeter/2; - G4ThreeVector positionCalorimeter = G4ThreeVector(0, 0, position); - new G4PVPlacement(0, positionCalorimeter, logicCalorimeter, Name + "_Calorimeter", logicComptonTelescope, false, 0); - - // Set Third Stage sensible - logicCalorimeter->SetSensitiveDetector(m_CalorimeterScorer); - - ///Visualisation of Third Stage - G4VisAttributes* CalorimeterVisAtt = new G4VisAttributes(G4Colour(0.0, 0.9, 0.0)); // green - logicCalorimeter->SetVisAttributes(CalorimeterVisAtt); - } +void ComptonTelescope::VolumeMaker(G4int TelescopeNumber, G4ThreeVector CTpos, G4RotationMatrix* CTrot, bool wTracker, + bool wCalorimeter, G4LogicalVolume* world) { + G4double NbrTelescopes = TelescopeNumber; + G4String DetectorNumber; + ostringstream Number; + Number << NbrTelescopes; + DetectorNumber = Number.str(); + + //////////////////////////////////////////////////////////////// + ////////////// Starting Volume Definition ////////////////////// + //////////////////////////////////////////////////////////////// + G4String Name = "ComptonTelescopeTower" + DetectorNumber; + + // calculate tower height + m_TowerHeight = (m_NumberOfDSSSD - 1) * m_DistanceInterDSSSD + m_ThicknessOfDSSSD + m_DistanceTrackerCalorimeter + + m_ThicknessOfCalorimeter; + + G4Box* solidComptonTelescope = new G4Box(Name, 0.5 * m_SizeOfDSSSD, 0.5 * m_SizeOfDSSSD, 0.5 * m_TowerHeight); + G4LogicalVolume* logicComptonTelescope = new G4LogicalVolume(solidComptonTelescope, m_MaterialVacuum, Name, 0, 0, 0); + + new G4PVPlacement(G4Transform3D(*CTrot, CTpos), logicComptonTelescope, Name, world, false, 0); + + logicComptonTelescope->SetVisAttributes(G4VisAttributes::GetInvisible()); + if (m_non_sensitive_part_visiualisation) + logicComptonTelescope->SetVisAttributes(G4VisAttributes(G4Colour(0.90, 0.90, 0.90))); + + //////////////////////////////////////////////////////////// + //////////////// Tracker Construction ////////////////////// + //////////////////////////////////////////////////////////// + if (wTracker) { + // tracker detector itself + G4Box* solidTracker = new G4Box("solidTracker", 0.5 * m_SizeOfDSSSD, 0.5 * m_SizeOfDSSSD, 0.5 * m_ThicknessOfDSSSD); + G4LogicalVolume* logicTracker = new G4LogicalVolume(solidTracker, m_MaterialSilicon, "logicTracker", 0, 0, 0); + + G4ThreeVector positionTracker; + for (G4int i = 0; i < m_NumberOfDSSSD; ++i) { // loop on number of DSSSDs + G4double position = -m_TowerHeight / 2 + m_ThicknessOfDSSSD / 2 + i * m_DistanceInterDSSSD; + positionTracker = G4ThreeVector(0, 0, position); + G4String nameTracker = Name + "_Tracker"; + ostringstream index; + index << i; + nameTracker = nameTracker + index.str(); + new G4PVPlacement(0, positionTracker, logicTracker, nameTracker, logicComptonTelescope, false, i); + } // end loop on number of DSSSDs + + // set tracker sensible + logicTracker->SetSensitiveDetector(m_TrackerScorer); + + // visualisation of tracker + G4VisAttributes* TrackerVisAtt = new G4VisAttributes(G4Colour(0.0, 0.0, 0.9)); // blue + logicTracker->SetVisAttributes(TrackerVisAtt); + } + + //////////////////////////////////////////////////////////////// + ///////////////// Calorimeter Construction ///////////////////// + //////////////////////////////////////////////////////////////// + if (wCalorimeter) { + // calorimeter detector + G4Box* solidCalorimeter = + new G4Box("solidCalorimeter", 0.5 * m_SizeOfDSSSD, 0.5 * m_SizeOfDSSSD, 0.5 * m_ThicknessOfCalorimeter); + G4LogicalVolume* logicCalorimeter = + new G4LogicalVolume(solidCalorimeter, m_MaterialSilicon, "logicCalorimeter", 0, 0, 0); + + G4double position = m_TowerHeight / 2 - m_ThicknessOfCalorimeter / 2; + G4ThreeVector positionCalorimeter = G4ThreeVector(0, 0, position); + new G4PVPlacement(0, positionCalorimeter, logicCalorimeter, Name + "_Calorimeter", logicComptonTelescope, false, 0); + + // Set Third Stage sensible + logicCalorimeter->SetSensitiveDetector(m_CalorimeterScorer); + + /// Visualisation of Third Stage + G4VisAttributes* CalorimeterVisAtt = new G4VisAttributes(G4Colour(0.0, 0.9, 0.0)); // green + logicCalorimeter->SetVisAttributes(CalorimeterVisAtt); + } } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... @@ -253,34 +219,47 @@ void ComptonTelescope::VolumeMaker(G4int TelescopeNumber, // Read stream at Configfile to pick-up parameters of detector (Position,...) // Called in DetecorConstruction::ReadDetextorConfiguration Method -void ComptonTelescope::ReadConfiguration(NPL::InputParser parser ){ +void ComptonTelescope::ReadConfiguration(NPL::InputParser parser) { vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithToken("ComptonTelescope"); - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << "//// " << blocks.size() << " detectors found " << endl; - - vector<string> token = {"R","THETA","PHI","BETA","SIZE_DSSSD","NUMBER_DSSSD","DISTANCE_INTER_DSSSD","THICKNESS_DSSSD","NUMBER_STRIPS","DISTANCE_TRACKER_CALORIMETER","THICKNESS_CALORIMETER","TRACKER","CALORIMETER","VIS"}; - - for(unsigned int i = 0 ; i < blocks.size() ; i++){ - if(blocks[i]->HasTokenList(token)){ - double R = blocks[i]->GetDouble("R","mm"); - double Theta = blocks[i]->GetDouble("THETA","deg"); - double Phi = blocks[i]->GetDouble("PHI","deg"); - vector<double> beta = blocks[i]->GetVectorDouble("BETA","deg"); - m_SizeOfDSSSD = blocks[i]->GetDouble("SIZE_DSSSD","mm"); + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks.size() << " detectors found " << endl; + + vector<string> token = {"R", + "THETA", + "PHI", + "BETA", + "SIZE_DSSSD", + "NUMBER_DSSSD", + "DISTANCE_INTER_DSSSD", + "THICKNESS_DSSSD", + "NUMBER_STRIPS", + "DISTANCE_TRACKER_CALORIMETER", + "THICKNESS_CALORIMETER", + "TRACKER", + "CALORIMETER", + "VIS"}; + + for (unsigned int i = 0; i < blocks.size(); i++) { + if (blocks[i]->HasTokenList(token)) { + double R = blocks[i]->GetDouble("R", "mm"); + double Theta = blocks[i]->GetDouble("THETA", "deg"); + double Phi = blocks[i]->GetDouble("PHI", "deg"); + vector<double> beta = blocks[i]->GetVectorDouble("BETA", "deg"); + m_SizeOfDSSSD = blocks[i]->GetDouble("SIZE_DSSSD", "mm"); m_NumberOfDSSSD = blocks[i]->GetInt("NUMBER_DSSSD"); - m_DistanceInterDSSSD = blocks[i]->GetDouble("DISTANCE_INTER_DSSSD","mm"); - m_ThicknessOfDSSSD= blocks[i]->GetDouble("THICKNESS_DSSSD","mm"); + m_DistanceInterDSSSD = blocks[i]->GetDouble("DISTANCE_INTER_DSSSD", "mm"); + m_ThicknessOfDSSSD = blocks[i]->GetDouble("THICKNESS_DSSSD", "mm"); m_NumberOfStrips = blocks[i]->GetInt("NUMBER_STRIPS"); - m_DistanceTrackerCalorimeter = blocks[i]->GetDouble("DISTANCE_TRACKER_CALORIMETER","mm"); - m_ThicknessOfCalorimeter = blocks[i]->GetDouble("THICKNESS_CALORIMETER","mm"); - int tracker = blocks[i]->GetInt("TRACKER"); - int calorimeter = blocks[i]->GetInt("CALORIMETER"); + m_DistanceTrackerCalorimeter = blocks[i]->GetDouble("DISTANCE_TRACKER_CALORIMETER", "mm"); + m_ThicknessOfCalorimeter = blocks[i]->GetDouble("THICKNESS_CALORIMETER", "mm"); + int tracker = blocks[i]->GetInt("TRACKER"); + int calorimeter = blocks[i]->GetInt("CALORIMETER"); m_non_sensitive_part_visiualisation = blocks[i]->GetInt("VIS"); - AddModule(R,Theta,Phi,beta[0],beta[1],beta[2],tracker== 1 ,calorimeter== 1); + AddModule(R, Theta, Phi, beta[0], beta[1], beta[2], tracker == 1, calorimeter == 1); } - else{ + else { cout << "ERROR: check your input file formatting " << endl; exit(1); } @@ -289,533 +268,537 @@ void ComptonTelescope::ReadConfiguration(NPL::InputParser parser ){ // Construct detector and inialise sensitive part. // Called After DetecorConstruction::AddDetector Method -void ComptonTelescope::ConstructDetector(G4LogicalVolume* world) -{ - G4RotationMatrix* CTrot = NULL ; - G4ThreeVector CTpos = G4ThreeVector(0, 0, 0) ; - G4ThreeVector CTu = G4ThreeVector(0, 0, 0) ; - G4ThreeVector CTv = G4ThreeVector(0, 0, 0) ; - G4ThreeVector CTw = G4ThreeVector(0, 0, 0) ; - G4ThreeVector CTCenter = G4ThreeVector(0, 0, 0) ; - bool FirstStage = true; - bool SecondStage = true; - - G4int NumberOfTelescope = m_DefinitionType.size() ; - - for (G4int i = 0; i < NumberOfTelescope; i++) { - // By Point - if (m_DefinitionType[i]) { - // (u,v,w) unitary vector associated to telescope referencial - // (u,v) // to silicon plan - // w perpendicular to (u,v) plan and pointing ThirdStage - CTu = m_X128_Y1[i] - m_X1_Y1[i]; - CTu = CTu.unit(); - - CTv = m_X1_Y128[i] - m_X1_Y1[i]; - CTv = CTv.unit(); - - CTw = CTu.cross(CTv); - CTw = CTw.unit(); - - CTCenter = (m_X1_Y1[i] + m_X1_Y128[i] + m_X128_Y1[i] + m_X128_Y128[i]) / 4; - - // Passage Matrix from Lab Referential to Telescope Referential - CTrot = new G4RotationMatrix(CTu, CTv, CTw); - // translation to place Telescope - CTpos = CTw * m_TowerHeight * 0.5 + CTCenter; - } +void ComptonTelescope::ConstructDetector(G4LogicalVolume* world) { + G4RotationMatrix* CTrot = NULL; + G4ThreeVector CTpos = G4ThreeVector(0, 0, 0); + G4ThreeVector CTu = G4ThreeVector(0, 0, 0); + G4ThreeVector CTv = G4ThreeVector(0, 0, 0); + G4ThreeVector CTw = G4ThreeVector(0, 0, 0); + G4ThreeVector CTCenter = G4ThreeVector(0, 0, 0); + bool FirstStage = true; + bool SecondStage = true; + + G4int NumberOfTelescope = m_DefinitionType.size(); + + for (G4int i = 0; i < NumberOfTelescope; i++) { + // By Point + if (m_DefinitionType[i]) { + // (u,v,w) unitary vector associated to telescope referencial + // (u,v) // to silicon plan + // w perpendicular to (u,v) plan and pointing ThirdStage + CTu = m_X128_Y1[i] - m_X1_Y1[i]; + CTu = CTu.unit(); + + CTv = m_X1_Y128[i] - m_X1_Y1[i]; + CTv = CTv.unit(); + + CTw = CTu.cross(CTv); + CTw = CTw.unit(); + + CTCenter = (m_X1_Y1[i] + m_X1_Y128[i] + m_X128_Y1[i] + m_X128_Y128[i]) / 4; + + // Passage Matrix from Lab Referential to Telescope Referential + CTrot = new G4RotationMatrix(CTu, CTv, CTw); + // translation to place Telescope + CTpos = CTw * m_TowerHeight * 0.5 + CTCenter; + } - // By Angle - else { - G4double Theta = m_Theta[i] ; - G4double Phi = m_Phi[i] ; - - // (u,v,w) unitary vector associated to telescope referencial - // (u,v) // to silicon plan - // w perpendicular to (u,v) plan and pointing ThirdStage - // Phi is angle between X axis and projection in (X,Y) plan - // Theta is angle between position vector and z axis - G4double wX = m_R[i] * sin(Theta / rad) * cos(Phi / rad); - G4double wY = m_R[i] * sin(Theta / rad) * sin(Phi / rad); - G4double wZ = m_R[i] * cos(Theta / rad); - CTw = G4ThreeVector(wX, wY, wZ); - - // vector corresponding to the center of the module - CTCenter = CTw; - - // vector parallel to one axis of silicon plane - G4double ii = cos(Theta / rad) * cos(Phi / rad); - G4double jj = cos(Theta / rad) * sin(Phi / rad); - G4double kk = -sin(Theta / rad); - G4ThreeVector Y = G4ThreeVector(ii, jj, kk); - - CTw = CTw.unit(); - CTu = CTw.cross(Y); - CTv = CTw.cross(CTu); - CTv = CTv.unit(); - CTu = CTu.unit(); - - // Passage Matrix from Lab Referential to Telescope Referential - // MUST2 - CTrot = new G4RotationMatrix(CTu, CTv, CTw); - // Telescope is rotate of Beta angle around CTv axis. - CTrot->rotate(m_beta_u[i], CTu); - CTrot->rotate(m_beta_v[i], CTv); - CTrot->rotate(m_beta_w[i], CTw); - // translation to place Telescope - CTpos = CTw * m_TowerHeight * 0.5 + CTCenter; - } + // By Angle + else { + G4double Theta = m_Theta[i]; + G4double Phi = m_Phi[i]; + + // (u,v,w) unitary vector associated to telescope referencial + // (u,v) // to silicon plan + // w perpendicular to (u,v) plan and pointing ThirdStage + // Phi is angle between X axis and projection in (X,Y) plan + // Theta is angle between position vector and z axis + G4double wX = m_R[i] * sin(Theta / rad) * cos(Phi / rad); + G4double wY = m_R[i] * sin(Theta / rad) * sin(Phi / rad); + G4double wZ = m_R[i] * cos(Theta / rad); + CTw = G4ThreeVector(wX, wY, wZ); + + // vector corresponding to the center of the module + CTCenter = CTw; + + // vector parallel to one axis of silicon plane + G4double ii = cos(Theta / rad) * cos(Phi / rad); + G4double jj = cos(Theta / rad) * sin(Phi / rad); + G4double kk = -sin(Theta / rad); + G4ThreeVector Y = G4ThreeVector(ii, jj, kk); + + CTw = CTw.unit(); + CTu = CTw.cross(Y); + CTv = CTw.cross(CTu); + CTv = CTv.unit(); + CTu = CTu.unit(); + + // Passage Matrix from Lab Referential to Telescope Referential + // MUST2 + CTrot = new G4RotationMatrix(CTu, CTv, CTw); + // Telescope is rotate of Beta angle around CTv axis. + CTrot->rotate(m_beta_u[i], CTu); + CTrot->rotate(m_beta_v[i], CTv); + CTrot->rotate(m_beta_w[i], CTw); + // translation to place Telescope + CTpos = CTw * m_TowerHeight * 0.5 + CTCenter; + } - FirstStage = m_wTracker[i] ; - SecondStage = m_wCalorimeter[i] ; + FirstStage = m_wTracker[i]; + SecondStage = m_wCalorimeter[i]; - VolumeMaker(i + 1, CTpos, CTrot, FirstStage, SecondStage, world); - } + VolumeMaker(i + 1, CTpos, CTrot, FirstStage, SecondStage, world); + } - delete CTrot ; + delete CTrot; } - - // Connect the GaspardTrackingData class to the output TTree // of the simulation -void ComptonTelescope::InitializeRootOutput() -{ - RootOutput *pAnalysis = RootOutput::getInstance(); - TTree *pTree = pAnalysis->GetTree(); - if(!pTree->FindBranch("ComptonTelescope")){ - pTree->Branch("ComptonTelescope", "TComptonTelescopeData", &m_Event); - } - if(!pTree->FindBranch("ComptonTelescopeProcess")){ +void ComptonTelescope::InitializeRootOutput() { + RootOutput* pAnalysis = RootOutput::getInstance(); + TTree* pTree = pAnalysis->GetTree(); + if (!pTree->FindBranch("ComptonTelescope")) { + pTree->Branch("ComptonTelescope", "TComptonTelescopeData", &m_Event); + } + if (!pTree->FindBranch("ComptonTelescopeProcess")) { pTree->Branch("ComptonTelescopeProcess", "TComptonTelescopeProcessData", &m_ProcessEvent); - } - pTree->SetBranchAddress("ComptonTelescope", &m_Event); - pTree->SetBranchAddress("ComptonTelescopeProcess", &m_ProcessEvent); - + } + pTree->SetBranchAddress("ComptonTelescope", &m_Event); + pTree->SetBranchAddress("ComptonTelescopeProcess", &m_ProcessEvent); } - - // Read sensitive part and fill the Root tree. // Called at in the EventAction::EndOfEventAvtion -void ComptonTelescope::ReadSensitive(const G4Event* event) -{ - m_Event->Clear(); - - ////////////////////////////////////////////////////////////////////////////////////// - //////////////////////// Used to Read Event Map of detector ////////////////////////// - ////////////////////////////////////////////////////////////////////////////////////// - // Tracker - std::map<G4int, G4int*>::iterator TowerNumber_itr; - std::map<G4int, G4int*>::iterator DSSSDNumber_itr; - std::map<G4int, G4double*>::iterator Energy_itr; - std::map<G4int, G4double*>::iterator Time_itr; -/* std::map<G4int, G4int*>::iterator X_itr; - std::map<G4int, G4int*>::iterator Y_itr; - std::map<G4int, G4double*>::iterator Pos_X_itr; - std::map<G4int, G4double*>::iterator Pos_Y_itr; - std::map<G4int, G4double*>::iterator Pos_Z_itr; - std::map<G4int, G4double*>::iterator Ang_Theta_itr; - std::map<G4int, G4double*>::iterator Ang_Phi_itr; -*/ - NPS::HitsMap<G4int>* TowerNumberHitMap; - NPS::HitsMap<G4int>* DSSSDNumberHitMap; - NPS::HitsMap<G4double>* EnergyHitMap; - NPS::HitsMap<G4double>* TimeHitMap; -/* NPS::HitsMap<G4int>* XHitMap; - NPS::HitsMap<G4int>* YHitMap; - NPS::HitsMap<G4double>* PosXHitMap; - NPS::HitsMap<G4double>* PosYHitMap; - NPS::HitsMap<G4double>* PosZHitMap; - NPS::HitsMap<G4double>* AngThetaHitMap; - NPS::HitsMap<G4double>* AngPhiHitMap; -*/ - // Calorimeter - std::map<G4int, G4int*>::iterator CalorimeterTowerNumber_itr; - std::map<G4int, G4int*>::iterator CalorimeterDetectorNumber_itr; - std::map<G4int, G4double*>::iterator CalorimeterEnergy_itr; -// std::map<G4int, G4double*>::iterator CalorimeterTime_itr; - NPS::HitsMap<G4int>* CalorimeterTowerNumberHitMap; - NPS::HitsMap<G4int>* CalorimeterDetectorNumberHitMap; - NPS::HitsMap<G4double>* CalorimeterEnergyHitMap; -// NPS::HitsMap<G4double>* CalorimeterTimeHitMap; - - - // Read scorers associated to the tracker part - // tower number - G4int TrackTowCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("TrackerScorerComptonTelescope/TowerNumber"); - TowerNumberHitMap = (NPS::HitsMap<G4int>*)(event->GetHCofThisEvent()->GetHC(TrackTowCollectionID)); - TowerNumber_itr = TowerNumberHitMap->GetMap()->begin(); - - // detector number - G4int TrackDetCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("TrackerScorerComptonTelescope/DSSSDNumber"); - DSSSDNumberHitMap = (NPS::HitsMap<G4int>*)(event->GetHCofThisEvent()->GetHC(TrackDetCollectionID)); - DSSSDNumber_itr = DSSSDNumberHitMap->GetMap()->begin(); - - // energy - G4int TrackEnergyCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("TrackerScorerComptonTelescope/Energy"); - EnergyHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(TrackEnergyCollectionID)) ; - Energy_itr = EnergyHitMap->GetMap()->begin(); - - // time of flight - G4int TrackTimeCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("TrackerScorerComptonTelescope/Time"); - TimeHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(TrackTimeCollectionID)); - Time_itr = TimeHitMap->GetMap()->begin(); -/* - //Track Number X - G4int TrackXCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("TrackerScorerComptonTelescope/NumberX"); - XHitMap = (NPS::HitsMap<G4int>*)(event->GetHCofThisEvent()->GetHC(TrackXCollectionID)); - X_itr = XHitMap->GetMap()->begin(); - - //Track Number Y - G4int TrackYCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("TrackerScorerComptonTelescope/TrackNumberY") ; - YHitMap = (NPS::HitsMap<G4int>*)(event->GetHCofThisEvent()->GetHC(TrackYCollectionID)); - Y_itr = YHitMap->GetMap()->begin(); - - //Interaction Coordinate X - G4int InterCoordXCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("TrackerScorerComptonTelescope/InterCoordX") ; - PosXHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordXCollectionID)) ; - Pos_X_itr = PosXHitMap->GetMap()->begin() ; - - //Interaction Coordinate Y - G4int InterCoordYCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("TrackerScorerComptonTelescope/InterCoordY") ; - PosYHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordYCollectionID)) ; - Pos_Y_itr = PosYHitMap->GetMap()->begin() ; - - //Interaction Coordinate Z - G4int InterCoordZCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("TrackerScorerComptonTelescope/InterCoordZ") ; - PosZHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordZCollectionID)) ; - Pos_Z_itr = PosXHitMap->GetMap()->begin() ; - - //Interaction Coordinate Angle Theta - G4int InterCoordAngThetaCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("TrackerScorerComptonTelescope/InterCoordAngTheta") ; - AngThetaHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordAngThetaCollectionID)) ; - Ang_Theta_itr = AngThetaHitMap->GetMap()->begin() ; - - //Interaction Coordinate Angle Phi - G4int InterCoordAngPhiCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("TrackerScorerComptonTelescope/InterCoordAngPhi") ; - AngPhiHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordAngPhiCollectionID)) ; - Ang_Phi_itr = AngPhiHitMap->GetMap()->begin() ; -*/ - - // read the scorers associated to the calorimeter - // tower number - G4int CaloTowCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("CalorimeterScorerComptonTelescope/TowerNumber"); - CalorimeterTowerNumberHitMap = (NPS::HitsMap<G4int>*)(event->GetHCofThisEvent()->GetHC(CaloTowCollectionID)); - CalorimeterTowerNumber_itr = CalorimeterTowerNumberHitMap->GetMap()->begin(); - - // detector number - G4int CaloDetCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("CalorimeterScorerComptonTelescope/DetectorNumber"); - CalorimeterDetectorNumberHitMap = (NPS::HitsMap<G4int>*)(event->GetHCofThisEvent()->GetHC(CaloDetCollectionID)); - CalorimeterDetectorNumber_itr = CalorimeterDetectorNumberHitMap->GetMap()->begin(); - - // energy - G4int CaloEnergyCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("CalorimeterScorerComptonTelescope/Energy"); - CalorimeterEnergyHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(CaloEnergyCollectionID)) ; - CalorimeterEnergy_itr = CalorimeterEnergyHitMap->GetMap()->begin(); -/* - // time of flight - G4int CaloTimeCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("CalorimeterScorerComptonTelescope/Time"); - CalorimeterTimeHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(CaloTimeCollectionID)); - CalorimeterTime_itr = CalorimeterTimeHitMap->GetMap()->begin(); -*/ - - // Calorimeter -// G4int sizeCaloTower = ->entries(); - - // Check the size of different map - G4int sizeTrackerNtower = TowerNumberHitMap->entries(); - G4int sizeTrackerNdsssd = DSSSDNumberHitMap->entries(); sizeTrackerNdsssd *= 1; - G4int sizeTrackerE = EnergyHitMap->entries(); - G4int sizeTrackerT = TimeHitMap->entries(); -// G4cout << sizeTrackerNtower << "\t" << sizeTrackerNdsssd << "\t" << sizeTrackerE << "\t" << sizeTrackerT << G4endl; -// G4int sizeTrackerX = XHitMap->entries(); -// G4int sizeTrackerY = YHitMap->entries(); - -// if (sizeE != sizeT || sizeT != sizeX || sizeX != sizeY) { - if (sizeTrackerE != sizeTrackerT) { - G4cout << "No match size Si Event Map: sE:" << sizeTrackerE << " sT:" << sizeTrackerT << G4endl ; - return; - } - - G4double Etot = 0; - - // Loop on FirstStage number - for (G4int l = 0; l < sizeTrackerNtower; l++) { - G4double N = *(TowerNumber_itr->second); - G4int NTrackID = TowerNumber_itr->first - N; -// G4cout << N << "\t" << NTrackID << G4endl; - - if (N > 0) { - // Fill tower number - m_Event->SetCTTrackerFrontETowerNbr(N); - m_Event->SetCTTrackerFrontTTowerNbr(N); - m_Event->SetCTTrackerBackEDetectorNbr(N); - m_Event->SetCTTrackerBackTDetectorNbr(N); - - // Energy - Energy_itr = EnergyHitMap->GetMap()->begin(); - for (G4int ll = 0 ; ll < sizeTrackerE ; ll++) { - G4int ETrackID = Energy_itr->first - N; - G4double E = *(Energy_itr->second); - if (ETrackID == NTrackID) { - Etot += E; - m_Event->SetCTTrackerFrontEEnergy(RandGauss::shoot(E, EnergyResolutionTracker)); -// m_Event->SetCTTrackerBackEEnergy(RandGauss::shoot(E, EnergyResolutionTracker)); - } - Energy_itr++; - } - - // Time - Time_itr = TimeHitMap->GetMap()->begin(); - for (G4int h = 0 ; h < sizeTrackerT ; h++) { - G4int TTrackID = Time_itr->first - N; - G4double T = *(Time_itr->second); - if (TTrackID == NTrackID) { - m_Event->SetCTTrackerFrontTTime(RandGauss::shoot(T, TimeResolutionTracker)); - m_Event->SetCTTrackerBackTTime(RandGauss::shoot(T, TimeResolutionTracker)); - } - Time_itr++; - } -/* - // X - X_itr = XHitMap->GetMap()->begin(); - for (G4int h = 0 ; h < sizeTrackerX ; h++) { - G4int XTrackID = X_itr->first - N; - G4int X = *(X_itr->second); - if (XTrackID == NTrackID) { - m_Event->SetCTFrontEStripNbr(X); - m_Event->SetCTFrontTStripNbr(X); - } - - X_itr++; - } - - // Y - Y_itr = YHitMap->GetMap()->begin() ; - for (G4int h = 0 ; h < sizeTrackerY ; h++) { - G4int YTrackID = Y_itr->first - N; - G4int Y = *(Y_itr->second); - if (YTrackID == NTrackID) { - m_Event->SetCTBackEStripNbr(Y); - m_Event->SetCTBackTStripNbr(Y); - } - - Y_itr++; - } - - // Pos X - Pos_X_itr = PosXHitMap->GetMap()->begin(); - for (G4int h = 0; h < PosXHitMap->entries(); h++) { - G4int PosXTrackID = Pos_X_itr->first - N ; - G4double PosX = *(Pos_X_itr->second) ; - if (PosXTrackID == NTrackID) { - ms_InterCoord->SetDetectedPositionX(PosX) ; - } - Pos_X_itr++; - } - - // Pos Y - Pos_Y_itr = PosYHitMap->GetMap()->begin(); - for (G4int h = 0; h < PosYHitMap->entries(); h++) { - G4int PosYTrackID = Pos_Y_itr->first - N ; - G4double PosY = *(Pos_Y_itr->second) ; - if (PosYTrackID == NTrackID) { - ms_InterCoord->SetDetectedPositionY(PosY) ; - } - Pos_Y_itr++; - } - - // Pos Z - Pos_Z_itr = PosZHitMap->GetMap()->begin(); - for (G4int h = 0; h < PosZHitMap->entries(); h++) { - G4int PosZTrackID = Pos_Z_itr->first - N ; - G4double PosZ = *(Pos_Z_itr->second) ; - if (PosZTrackID == NTrackID) { - ms_InterCoord->SetDetectedPositionZ(PosZ) ; - } - Pos_Z_itr++; - } - - // Angle Theta - Ang_Theta_itr = AngThetaHitMap->GetMap()->begin(); - for (G4int h = 0; h < AngThetaHitMap->entries(); h++) { - G4int AngThetaTrackID = Ang_Theta_itr->first - N ; - G4double AngTheta = *(Ang_Theta_itr->second) ; - if (AngThetaTrackID == NTrackID) { - ms_InterCoord->SetDetectedAngleTheta(AngTheta) ; - } - Ang_Theta_itr++; - } - - // Angle Phi - Ang_Phi_itr = AngPhiHitMap->GetMap()->begin(); - for (G4int h = 0; h < AngPhiHitMap->entries(); h++) { - G4int AngPhiTrackID = Ang_Phi_itr->first - N ; - G4double AngPhi = *(Ang_Phi_itr->second) ; - if (AngPhiTrackID == NTrackID) { - ms_InterCoord->SetDetectedAnglePhi(AngPhi) ; - } - Ang_Phi_itr++; - } -*/ -/* - // Third Stage - ThirdStageEnergy_itr = ThirdStageEnergyHitMap->GetMap()->begin() ; - for (G4int h = 0 ; h < ThirdStageEnergyHitMap->entries() ; h++) { - G4int ThirdStageEnergyTrackID = ThirdStageEnergy_itr->first - N; - G4double ThirdStageEnergy = *(ThirdStageEnergy_itr->second) ; - - if (ThirdStageEnergyTrackID == NTrackID) { - m_Event->SetGPDTrkThirdStageEEnergy(RandGauss::shoot(ThirdStageEnergy, ResoThirdStage)); - m_Event->SetGPDTrkThirdStageEPadNbr(1); - m_Event->SetGPDTrkThirdStageTPadNbr(1); - m_Event->SetGPDTrkThirdStageTTime(1); - m_Event->SetGPDTrkThirdStageTDetectorNbr(m_index["Square"] + N); - m_Event->SetGPDTrkThirdStageEDetectorNbr(m_index["Square"] + N); - } - - ThirdStageEnergy_itr++; - } -*/ - } - TowerNumber_itr++; - - } - - // Fill total energy here - if (Etot > 0) m_Event->SetCTTrackerBackEEnergy(RandGauss::shoot(Etot, EnergyResolutionTracker)); - - // clear map for next event - TowerNumberHitMap -> clear(); - DSSSDNumberHitMap -> clear(); - EnergyHitMap -> clear(); - TimeHitMap -> clear(); -/* XHitMap ->clear() ; - YHitMap ->clear() ; - PosXHitMap ->clear(); - PosYHitMap ->clear(); - PosZHitMap ->clear(); - AngThetaHitMap ->clear(); - AngPhiHitMap ->clear();*/ -// ThirdStageEnergyHitMap ->clear(); - - /////////////////////////////////////////////////// - // counting processes (compton, .....) // - /////////////////////////////////////////////////// - // clear root object - m_ProcessEvent->Clear(); - - // scorers for processes.... - std::map<G4int, G4double*>::iterator TrkProcC_itr; - NPS::HitsMap<G4double>* TrkProcCHitMap; - G4int TrkProcCCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("TrackerScorerComptonTelescope/Process"); - TrkProcCHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(TrkProcCCollectionID)) ; - TrkProcC_itr = TrkProcCHitMap->GetMap()->begin(); - - for (G4int l = 0; l < TrkProcCHitMap->entries(); l++) { - // get electron energy - G4double ElectronKineticEnergy = *(TrkProcC_itr->second); - // get tower, dssd number & trackID - G4int index = TrkProcC_itr->first; -// G4cout << "Read Sensitive : " << l << "\t" << index << G4endl; - G4int towerID = index / (G4int)pow(100.,2.); - index -= towerID * (G4int)pow(100.,2.); - G4int dsssdID = index / (G4int)pow(100.,1.); - G4int trackID = index - dsssdID * (G4int)pow(100.,1.); - trackID *= 1; -// G4cout << "IDs : " << towerID << "\t" << dsssdID << "\t" << trackID << G4endl; -// G4cout << "Energy : " << ElectronKineticEnergy << G4endl; - // fill process data class - m_ProcessEvent->SetCTTrackerComptonTowerNbr(towerID); - m_ProcessEvent->SetCTTrackerComptonDetectorNbr(dsssdID); - m_ProcessEvent->SetCTTrackerComptonEnergy(ElectronKineticEnergy); - - TrkProcC_itr++; - } - TrkProcCHitMap->clear(); +void ComptonTelescope::ReadSensitive(const G4Event* event) { + m_Event->Clear(); + + ////////////////////////////////////////////////////////////////////////////////////// + //////////////////////// Used to Read Event Map of detector ////////////////////////// + ////////////////////////////////////////////////////////////////////////////////////// + // Tracker + std::map<G4int, G4int*>::iterator TowerNumber_itr; + std::map<G4int, G4int*>::iterator DSSSDNumber_itr; + std::map<G4int, G4double*>::iterator Energy_itr; + std::map<G4int, G4double*>::iterator Time_itr; + /* std::map<G4int, G4int*>::iterator X_itr; + std::map<G4int, G4int*>::iterator Y_itr; + std::map<G4int, G4double*>::iterator Pos_X_itr; + std::map<G4int, G4double*>::iterator Pos_Y_itr; + std::map<G4int, G4double*>::iterator Pos_Z_itr; + std::map<G4int, G4double*>::iterator Ang_Theta_itr; + std::map<G4int, G4double*>::iterator Ang_Phi_itr; + */ + NPS::HitsMap<G4int>* TowerNumberHitMap; + NPS::HitsMap<G4int>* DSSSDNumberHitMap; + NPS::HitsMap<G4double>* EnergyHitMap; + NPS::HitsMap<G4double>* TimeHitMap; + /* NPS::HitsMap<G4int>* XHitMap; + NPS::HitsMap<G4int>* YHitMap; + NPS::HitsMap<G4double>* PosXHitMap; + NPS::HitsMap<G4double>* PosYHitMap; + NPS::HitsMap<G4double>* PosZHitMap; + NPS::HitsMap<G4double>* AngThetaHitMap; + NPS::HitsMap<G4double>* AngPhiHitMap; + */ + // Calorimeter + std::map<G4int, G4int*>::iterator CalorimeterTowerNumber_itr; + std::map<G4int, G4int*>::iterator CalorimeterDetectorNumber_itr; + std::map<G4int, G4double*>::iterator CalorimeterEnergy_itr; + // std::map<G4int, G4double*>::iterator CalorimeterTime_itr; + NPS::HitsMap<G4int>* CalorimeterTowerNumberHitMap; + NPS::HitsMap<G4int>* CalorimeterDetectorNumberHitMap; + NPS::HitsMap<G4double>* CalorimeterEnergyHitMap; + // NPS::HitsMap<G4double>* CalorimeterTimeHitMap; + + // Read scorers associated to the tracker part + // tower number + G4int TrackTowCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("TrackerScorerComptonTelescope/TowerNumber"); + TowerNumberHitMap = (NPS::HitsMap<G4int>*)(event->GetHCofThisEvent()->GetHC(TrackTowCollectionID)); + TowerNumber_itr = TowerNumberHitMap->GetMap()->begin(); + + // detector number + G4int TrackDetCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("TrackerScorerComptonTelescope/DSSSDNumber"); + DSSSDNumberHitMap = (NPS::HitsMap<G4int>*)(event->GetHCofThisEvent()->GetHC(TrackDetCollectionID)); + DSSSDNumber_itr = DSSSDNumberHitMap->GetMap()->begin(); + + // energy + G4int TrackEnergyCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("TrackerScorerComptonTelescope/Energy"); + EnergyHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(TrackEnergyCollectionID)); + Energy_itr = EnergyHitMap->GetMap()->begin(); + + // time of flight + G4int TrackTimeCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("TrackerScorerComptonTelescope/Time"); + TimeHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(TrackTimeCollectionID)); + Time_itr = TimeHitMap->GetMap()->begin(); + /* + //Track Number X + G4int TrackXCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("TrackerScorerComptonTelescope/NumberX"); + XHitMap = (NPS::HitsMap<G4int>*)(event->GetHCofThisEvent()->GetHC(TrackXCollectionID)); + X_itr = XHitMap->GetMap()->begin(); + + //Track Number Y + G4int TrackYCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("TrackerScorerComptonTelescope/TrackNumberY") ; YHitMap = + (NPS::HitsMap<G4int>*)(event->GetHCofThisEvent()->GetHC(TrackYCollectionID)); Y_itr = YHitMap->GetMap()->begin(); + + //Interaction Coordinate X + G4int InterCoordXCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("TrackerScorerComptonTelescope/InterCoordX") ; PosXHitMap = + (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordXCollectionID)) ; + Pos_X_itr = PosXHitMap->GetMap()->begin() ; + + //Interaction Coordinate Y + G4int InterCoordYCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("TrackerScorerComptonTelescope/InterCoordY") ; PosYHitMap = + (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordYCollectionID)) ; + Pos_Y_itr = PosYHitMap->GetMap()->begin() ; + + //Interaction Coordinate Z + G4int InterCoordZCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("TrackerScorerComptonTelescope/InterCoordZ") ; PosZHitMap = + (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordZCollectionID)) ; + Pos_Z_itr = PosXHitMap->GetMap()->begin() ; + + //Interaction Coordinate Angle Theta + G4int InterCoordAngThetaCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("TrackerScorerComptonTelescope/InterCoordAngTheta") ; + AngThetaHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordAngThetaCollectionID)) ; + Ang_Theta_itr = AngThetaHitMap->GetMap()->begin() ; + + //Interaction Coordinate Angle Phi + G4int InterCoordAngPhiCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("TrackerScorerComptonTelescope/InterCoordAngPhi") ; AngPhiHitMap = + (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordAngPhiCollectionID)) ; Ang_Phi_itr = + AngPhiHitMap->GetMap()->begin() ; + */ + + // read the scorers associated to the calorimeter + // tower number + G4int CaloTowCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("CalorimeterScorerComptonTelescope/TowerNumber"); + CalorimeterTowerNumberHitMap = (NPS::HitsMap<G4int>*)(event->GetHCofThisEvent()->GetHC(CaloTowCollectionID)); + CalorimeterTowerNumber_itr = CalorimeterTowerNumberHitMap->GetMap()->begin(); + + // detector number + G4int CaloDetCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("CalorimeterScorerComptonTelescope/DetectorNumber"); + CalorimeterDetectorNumberHitMap = (NPS::HitsMap<G4int>*)(event->GetHCofThisEvent()->GetHC(CaloDetCollectionID)); + CalorimeterDetectorNumber_itr = CalorimeterDetectorNumberHitMap->GetMap()->begin(); + + // energy + G4int CaloEnergyCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("CalorimeterScorerComptonTelescope/Energy"); + CalorimeterEnergyHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(CaloEnergyCollectionID)); + CalorimeterEnergy_itr = CalorimeterEnergyHitMap->GetMap()->begin(); + /* + // time of flight + G4int CaloTimeCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("CalorimeterScorerComptonTelescope/Time"); CalorimeterTimeHitMap = + (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(CaloTimeCollectionID)); CalorimeterTime_itr = + CalorimeterTimeHitMap->GetMap()->begin(); + */ + + // Calorimeter + // G4int sizeCaloTower = ->entries(); + + // Check the size of different map + G4int sizeTrackerNtower = TowerNumberHitMap->entries(); + G4int sizeTrackerNdsssd = DSSSDNumberHitMap->entries(); + sizeTrackerNdsssd *= 1; + G4int sizeTrackerE = EnergyHitMap->entries(); + G4int sizeTrackerT = TimeHitMap->entries(); + // G4cout << sizeTrackerNtower << "\t" << sizeTrackerNdsssd << "\t" << sizeTrackerE << "\t" << sizeTrackerT << + // G4endl; G4int sizeTrackerX = XHitMap->entries(); G4int sizeTrackerY = YHitMap->entries(); + + // if (sizeE != sizeT || sizeT != sizeX || sizeX != sizeY) { + if (sizeTrackerE != sizeTrackerT) { + G4cout << "No match size Si Event Map: sE:" << sizeTrackerE << " sT:" << sizeTrackerT << G4endl; + return; + } -} + G4double Etot = 0; + + // Loop on FirstStage number + for (G4int l = 0; l < sizeTrackerNtower; l++) { + G4double N = *(TowerNumber_itr->second); + G4int NTrackID = TowerNumber_itr->first - N; + // G4cout << N << "\t" << NTrackID << G4endl; + + if (N > 0) { + // Fill tower number + m_Event->SetCTTrackerFrontETowerNbr(N); + m_Event->SetCTTrackerFrontTTowerNbr(N); + m_Event->SetCTTrackerBackEDetectorNbr(N); + m_Event->SetCTTrackerBackTDetectorNbr(N); + + // Energy + Energy_itr = EnergyHitMap->GetMap()->begin(); + for (G4int ll = 0; ll < sizeTrackerE; ll++) { + G4int ETrackID = Energy_itr->first - N; + G4double E = *(Energy_itr->second); + if (ETrackID == NTrackID) { + Etot += E; + m_Event->SetCTTrackerFrontEEnergy(RandGauss::shoot(E, EnergyResolutionTracker)); + // m_Event->SetCTTrackerBackEEnergy(RandGauss::shoot(E, EnergyResolutionTracker)); + } + Energy_itr++; + } + // Time + Time_itr = TimeHitMap->GetMap()->begin(); + for (G4int h = 0; h < sizeTrackerT; h++) { + G4int TTrackID = Time_itr->first - N; + G4double T = *(Time_itr->second); + if (TTrackID == NTrackID) { + m_Event->SetCTTrackerFrontTTime(RandGauss::shoot(T, TimeResolutionTracker)); + m_Event->SetCTTrackerBackTTime(RandGauss::shoot(T, TimeResolutionTracker)); + } + Time_itr++; + } + /* + // X + X_itr = XHitMap->GetMap()->begin(); + for (G4int h = 0 ; h < sizeTrackerX ; h++) { + G4int XTrackID = X_itr->first - N; + G4int X = *(X_itr->second); + if (XTrackID == NTrackID) { + m_Event->SetCTFrontEStripNbr(X); + m_Event->SetCTFrontTStripNbr(X); + } + + X_itr++; + } + + // Y + Y_itr = YHitMap->GetMap()->begin() ; + for (G4int h = 0 ; h < sizeTrackerY ; h++) { + G4int YTrackID = Y_itr->first - N; + G4int Y = *(Y_itr->second); + if (YTrackID == NTrackID) { + m_Event->SetCTBackEStripNbr(Y); + m_Event->SetCTBackTStripNbr(Y); + } + + Y_itr++; + } + + // Pos X + Pos_X_itr = PosXHitMap->GetMap()->begin(); + for (G4int h = 0; h < PosXHitMap->entries(); h++) { + G4int PosXTrackID = Pos_X_itr->first - N ; + G4double PosX = *(Pos_X_itr->second) ; + if (PosXTrackID == NTrackID) { + ms_InterCoord->SetDetectedPositionX(PosX) ; + } + Pos_X_itr++; + } + + // Pos Y + Pos_Y_itr = PosYHitMap->GetMap()->begin(); + for (G4int h = 0; h < PosYHitMap->entries(); h++) { + G4int PosYTrackID = Pos_Y_itr->first - N ; + G4double PosY = *(Pos_Y_itr->second) ; + if (PosYTrackID == NTrackID) { + ms_InterCoord->SetDetectedPositionY(PosY) ; + } + Pos_Y_itr++; + } + + // Pos Z + Pos_Z_itr = PosZHitMap->GetMap()->begin(); + for (G4int h = 0; h < PosZHitMap->entries(); h++) { + G4int PosZTrackID = Pos_Z_itr->first - N ; + G4double PosZ = *(Pos_Z_itr->second) ; + if (PosZTrackID == NTrackID) { + ms_InterCoord->SetDetectedPositionZ(PosZ) ; + } + Pos_Z_itr++; + } + + // Angle Theta + Ang_Theta_itr = AngThetaHitMap->GetMap()->begin(); + for (G4int h = 0; h < AngThetaHitMap->entries(); h++) { + G4int AngThetaTrackID = Ang_Theta_itr->first - N ; + G4double AngTheta = *(Ang_Theta_itr->second) ; + if (AngThetaTrackID == NTrackID) { + ms_InterCoord->SetDetectedAngleTheta(AngTheta) ; + } + Ang_Theta_itr++; + } + + // Angle Phi + Ang_Phi_itr = AngPhiHitMap->GetMap()->begin(); + for (G4int h = 0; h < AngPhiHitMap->entries(); h++) { + G4int AngPhiTrackID = Ang_Phi_itr->first - N ; + G4double AngPhi = *(Ang_Phi_itr->second) ; + if (AngPhiTrackID == NTrackID) { + ms_InterCoord->SetDetectedAnglePhi(AngPhi) ; + } + Ang_Phi_itr++; + } + */ + /* + // Third Stage + ThirdStageEnergy_itr = ThirdStageEnergyHitMap->GetMap()->begin() ; + for (G4int h = 0 ; h < ThirdStageEnergyHitMap->entries() ; h++) { + G4int ThirdStageEnergyTrackID = ThirdStageEnergy_itr->first - N; + G4double ThirdStageEnergy = *(ThirdStageEnergy_itr->second) ; + + if (ThirdStageEnergyTrackID == NTrackID) { + m_Event->SetGPDTrkThirdStageEEnergy(RandGauss::shoot(ThirdStageEnergy, ResoThirdStage)); + m_Event->SetGPDTrkThirdStageEPadNbr(1); + m_Event->SetGPDTrkThirdStageTPadNbr(1); + m_Event->SetGPDTrkThirdStageTTime(1); + m_Event->SetGPDTrkThirdStageTDetectorNbr(m_index["Square"] + N); + m_Event->SetGPDTrkThirdStageEDetectorNbr(m_index["Square"] + N); + } + + ThirdStageEnergy_itr++; + } + */ + } + TowerNumber_itr++; + } -void ComptonTelescope::InitializeMaterial() -{ - m_MaterialSilicon = MaterialManager::getInstance()->GetMaterialFromLibrary("Si"); - m_MaterialAluminium = MaterialManager::getInstance()->GetMaterialFromLibrary("Al"); - m_MaterialLaBr3 = MaterialManager::getInstance()->GetMaterialFromLibrary("LaBr3"); - m_MaterialVacuum = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); + // Fill total energy here + if (Etot > 0) + m_Event->SetCTTrackerBackEEnergy(RandGauss::shoot(Etot, EnergyResolutionTracker)); + + // clear map for next event + TowerNumberHitMap->clear(); + DSSSDNumberHitMap->clear(); + EnergyHitMap->clear(); + TimeHitMap->clear(); + /* XHitMap ->clear() ; + YHitMap ->clear() ; + PosXHitMap ->clear(); + PosYHitMap ->clear(); + PosZHitMap ->clear(); + AngThetaHitMap ->clear(); + AngPhiHitMap ->clear();*/ + // ThirdStageEnergyHitMap ->clear(); + + /////////////////////////////////////////////////// + // counting processes (compton, .....) // + /////////////////////////////////////////////////// + // clear root object + m_ProcessEvent->Clear(); + + // scorers for processes.... + std::map<G4int, G4double*>::iterator TrkProcC_itr; + NPS::HitsMap<G4double>* TrkProcCHitMap; + G4int TrkProcCCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("TrackerScorerComptonTelescope/Process"); + TrkProcCHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(TrkProcCCollectionID)); + TrkProcC_itr = TrkProcCHitMap->GetMap()->begin(); + + for (G4int l = 0; l < TrkProcCHitMap->entries(); l++) { + // get electron energy + G4double ElectronKineticEnergy = *(TrkProcC_itr->second); + // get tower, dssd number & trackID + G4int index = TrkProcC_itr->first; + // G4cout << "Read Sensitive : " << l << "\t" << index << G4endl; + G4int towerID = index / (G4int)pow(100., 2.); + index -= towerID * (G4int)pow(100., 2.); + G4int dsssdID = index / (G4int)pow(100., 1.); + G4int trackID = index - dsssdID * (G4int)pow(100., 1.); + trackID *= 1; + // G4cout << "IDs : " << towerID << "\t" << dsssdID << "\t" << trackID << G4endl; + // G4cout << "Energy : " << ElectronKineticEnergy << G4endl; + // fill process data class + m_ProcessEvent->SetCTTrackerComptonTowerNbr(towerID); + m_ProcessEvent->SetCTTrackerComptonDetectorNbr(dsssdID); + m_ProcessEvent->SetCTTrackerComptonEnergy(ElectronKineticEnergy); + + TrkProcC_itr++; + } + TrkProcCHitMap->clear(); } +void ComptonTelescope::InitializeMaterial() { + m_MaterialSilicon = MaterialManager::getInstance()->GetMaterialFromLibrary("Si"); + m_MaterialAluminium = MaterialManager::getInstance()->GetMaterialFromLibrary("Al"); + m_MaterialLaBr3 = MaterialManager::getInstance()->GetMaterialFromLibrary("LaBr3"); + m_MaterialVacuum = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); +} - -void ComptonTelescope::InitializeScorers() -{ - - bool already_exist = false; - // First stage Associate Scorer - m_TrackerScorer = CheckScorer("TrackerScorerComptonTelescope",already_exist); - if(already_exist) return; - - G4VPrimitiveScorer* TowerNbr = new ComptonTelescopeScorerTrackerTowerNumber("TowerNumber", "ComptonTelescopeTower", 0); - G4VPrimitiveScorer* DSSSDNbr = new ComptonTelescopeScorerTrackerDSSSDNumber("DSSSDNumber", "ComptonTelescopeTower", 0); - G4VPrimitiveScorer* Energy = new ComptonTelescopeScorerTrackerEnergy("Energy", "ComptonTelescopeTower", 0); - G4VPrimitiveScorer* TOF = new ComptonTelescopeScorerTrackerTOF("Time", "ComptonTelescopeTower", 0); - G4VPrimitiveScorer* ProcessTypeCompt = new ComptonTelescopeScorerProcess("Process", "ComptonTelescopeTower", "compt", 0); -/* G4VPrimitiveScorer* StripPositionX = new GPDScorerFirstStageFrontStripSquare("StripNumberX", 0, m_NumberOfStrips); - G4VPrimitiveScorer* StripPositionY = new GPDScorerFirstStageBackStripSquare("StripNumberY", 0, m_NumberOfStrips); - G4VPrimitiveScorer* InteractionCoordinatesX = new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesX("InterCoordX","", 0); - G4VPrimitiveScorer* InteractionCoordinatesY = new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesY("InterCoordY","", 0); - G4VPrimitiveScorer* InteractionCoordinatesZ = new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesZ("InterCoordZ","", 0); - G4VPrimitiveScorer* InteractionCoordinatesAngleTheta = new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesAngleTheta("InterCoordAngTheta","", 0); - G4VPrimitiveScorer* InteractionCoordinatesAnglePhi = new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesAnglePhi("InterCoordAngPhi","", 0); -*/ - //and register it to the multifunctionnal detector - m_TrackerScorer->RegisterPrimitive(TowerNbr); - m_TrackerScorer->RegisterPrimitive(DSSSDNbr); - m_TrackerScorer->RegisterPrimitive(Energy); - m_TrackerScorer->RegisterPrimitive(TOF); - m_TrackerScorer->RegisterPrimitive(ProcessTypeCompt); -/* m_TrackerScorer->RegisterPrimitive(StripPositionX); - m_TrackerScorer->RegisterPrimitive(StripPositionY); - m_TrackerScorer->RegisterPrimitive(InteractionCoordinatesX); - m_TrackerScorer->RegisterPrimitive(InteractionCoordinatesY); - m_TrackerScorer->RegisterPrimitive(InteractionCoordinatesZ); - m_TrackerScorer->RegisterPrimitive(InteractionCoordinatesAngleTheta); - m_TrackerScorer->RegisterPrimitive(InteractionCoordinatesAnglePhi); -*/ - // Third stage Associate Scorer - m_CalorimeterScorer = new G4MultiFunctionalDetector("CalorimeterScorerComptonTelescope"); - G4VPrimitiveScorer* CaloTower = new ComptonTelescopeScorerCalorimeterTowerNumber("TowerNumber", "ComptonTelescopeTower", 0); - G4VPrimitiveScorer* CaloDetector = new ComptonTelescopeScorerCalorimeterDetectorNumber("DetectorNumber", "ComptonTelescopeTower", 0); - G4VPrimitiveScorer* CaloEnergy = new ComptonTelescopeScorerCalorimeterEnergy("Energy", "ComptonTelescopeTower", 0); -// G4VPrimitiveScorer* CaloTime = new ComptonTelescopeScorerCalorimeterTOF("Time", "ComptonTelescopeTower", 0); - m_CalorimeterScorer->RegisterPrimitive(CaloTower); - m_CalorimeterScorer->RegisterPrimitive(CaloDetector); - m_CalorimeterScorer->RegisterPrimitive(CaloEnergy); -// m_CalorimeterScorer->RegisterPrimitive(CaloTime); - - // Add All Scorer to the Global Scorer Manager - G4SDManager::GetSDMpointer()->AddNewDetector(m_TrackerScorer); - G4SDManager::GetSDMpointer()->AddNewDetector(m_CalorimeterScorer); +void ComptonTelescope::InitializeScorers() { + + bool already_exist = false; + // First stage Associate Scorer + m_TrackerScorer = CheckScorer("TrackerScorerComptonTelescope", already_exist); + if (already_exist) + return; + + G4VPrimitiveScorer* TowerNbr = + new ComptonTelescopeScorerTrackerTowerNumber("TowerNumber", "ComptonTelescopeTower", 0); + G4VPrimitiveScorer* DSSSDNbr = + new ComptonTelescopeScorerTrackerDSSSDNumber("DSSSDNumber", "ComptonTelescopeTower", 0); + G4VPrimitiveScorer* Energy = new ComptonTelescopeScorerTrackerEnergy("Energy", "ComptonTelescopeTower", 0); + G4VPrimitiveScorer* TOF = new ComptonTelescopeScorerTrackerTOF("Time", "ComptonTelescopeTower", 0); + G4VPrimitiveScorer* ProcessTypeCompt = + new ComptonTelescopeScorerProcess("Process", "ComptonTelescopeTower", "compt", 0); + /* G4VPrimitiveScorer* StripPositionX = new GPDScorerFirstStageFrontStripSquare("StripNumberX", 0, + m_NumberOfStrips); G4VPrimitiveScorer* StripPositionY = new + GPDScorerFirstStageBackStripSquare("StripNumberY", 0, m_NumberOfStrips); G4VPrimitiveScorer* + InteractionCoordinatesX = new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesX("InterCoordX","", 0); + G4VPrimitiveScorer* InteractionCoordinatesY = new + OBSOLETEGENERALSCORERS::PSInteractionCoordinatesY("InterCoordY","", 0); G4VPrimitiveScorer* InteractionCoordinatesZ + = new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesZ("InterCoordZ","", 0); G4VPrimitiveScorer* + InteractionCoordinatesAngleTheta = new + OBSOLETEGENERALSCORERS::PSInteractionCoordinatesAngleTheta("InterCoordAngTheta","", 0); G4VPrimitiveScorer* + InteractionCoordinatesAnglePhi = new + OBSOLETEGENERALSCORERS::PSInteractionCoordinatesAnglePhi("InterCoordAngPhi","", 0); + */ + // and register it to the multifunctionnal detector + m_TrackerScorer->RegisterPrimitive(TowerNbr); + m_TrackerScorer->RegisterPrimitive(DSSSDNbr); + m_TrackerScorer->RegisterPrimitive(Energy); + m_TrackerScorer->RegisterPrimitive(TOF); + m_TrackerScorer->RegisterPrimitive(ProcessTypeCompt); + /* m_TrackerScorer->RegisterPrimitive(StripPositionX); + m_TrackerScorer->RegisterPrimitive(StripPositionY); + m_TrackerScorer->RegisterPrimitive(InteractionCoordinatesX); + m_TrackerScorer->RegisterPrimitive(InteractionCoordinatesY); + m_TrackerScorer->RegisterPrimitive(InteractionCoordinatesZ); + m_TrackerScorer->RegisterPrimitive(InteractionCoordinatesAngleTheta); + m_TrackerScorer->RegisterPrimitive(InteractionCoordinatesAnglePhi); + */ + // Third stage Associate Scorer + m_CalorimeterScorer = new G4MultiFunctionalDetector("CalorimeterScorerComptonTelescope"); + G4VPrimitiveScorer* CaloTower = + new ComptonTelescopeScorerCalorimeterTowerNumber("TowerNumber", "ComptonTelescopeTower", 0); + G4VPrimitiveScorer* CaloDetector = + new ComptonTelescopeScorerCalorimeterDetectorNumber("DetectorNumber", "ComptonTelescopeTower", 0); + G4VPrimitiveScorer* CaloEnergy = new ComptonTelescopeScorerCalorimeterEnergy("Energy", "ComptonTelescopeTower", 0); + // G4VPrimitiveScorer* CaloTime = new ComptonTelescopeScorerCalorimeterTOF("Time", "ComptonTelescopeTower", 0); + m_CalorimeterScorer->RegisterPrimitive(CaloTower); + m_CalorimeterScorer->RegisterPrimitive(CaloDetector); + m_CalorimeterScorer->RegisterPrimitive(CaloEnergy); + // m_CalorimeterScorer->RegisterPrimitive(CaloTime); + + // Add All Scorer to the Global Scorer Manager + G4SDManager::GetSDMpointer()->AddNewDetector(m_TrackerScorer); + G4SDManager::GetSDMpointer()->AddNewDetector(m_CalorimeterScorer); } - //////////////////////////////////////////////////////////////////////////////// - // Construct Method to be pass to the DetectorFactory // - //////////////////////////////////////////////////////////////////////////////// - NPS::VDetector* ComptonTelescope::Construct(){ - return (NPS::VDetector*) new ComptonTelescope(); - } - - //////////////////////////////////////////////////////////////////////////////// - // Registering the construct method to the factory // - //////////////////////////////////////////////////////////////////////////////// -extern"C" { - class proxy_nps_comptontelescope{ - public: - proxy_nps_comptontelescope(){ - NPS::DetectorFactory::getInstance()->AddToken("ComptonTelescope","ComptonTelescope"); - NPS::DetectorFactory::getInstance()->AddDetector("ComptonTelescope",ComptonTelescope::Construct); - } +//////////////////////////////////////////////////////////////////////////////// +// Construct Method to be pass to the DetectorFactory // +//////////////////////////////////////////////////////////////////////////////// +NPS::VDetector* ComptonTelescope::Construct() { return (NPS::VDetector*)new ComptonTelescope(); } + +//////////////////////////////////////////////////////////////////////////////// +// Registering the construct method to the factory // +//////////////////////////////////////////////////////////////////////////////// +extern "C" { +class proxy_nps_comptontelescope { + public: + proxy_nps_comptontelescope() { + NPS::DetectorFactory::getInstance()->AddToken("ComptonTelescope", "ComptonTelescope"); + NPS::DetectorFactory::getInstance()->AddDetector("ComptonTelescope", ComptonTelescope::Construct); + } }; - proxy_nps_comptontelescope p_nps_comptontelescope; - } +proxy_nps_comptontelescope p_nps_comptontelescope; +} diff --git a/NPSimulation/Detectors/CsI/CsI.cc b/NPSimulation/Detectors/CsI/CsI.cc index 6a7775264a8c41281e4fdf93ca75eeafe8c9d440..48d0d3c79e72a2847700a99b6dce0ea79675c376 100644 --- a/NPSimulation/Detectors/CsI/CsI.cc +++ b/NPSimulation/Detectors/CsI/CsI.cc @@ -22,526 +22,462 @@ *****************************************************************************/ // C++ headers -#include <sstream> #include <cmath> #include <limits> -//G4 Geometry object -#include "G4Tubs.hh" +#include <sstream> +// G4 Geometry object #include "G4Box.hh" #include "G4Trd.hh" +#include "G4Tubs.hh" -//G4 sensitive -#include "G4SDManager.hh" +// G4 sensitive #include "G4MultiFunctionalDetector.hh" +#include "G4SDManager.hh" -//G4 various object +// G4 various object +#include "G4Colour.hh" #include "G4Material.hh" -#include "G4Transform3D.hh" #include "G4PVPlacement.hh" +#include "G4Transform3D.hh" #include "G4VisAttributes.hh" -#include "G4Colour.hh" - // NPTool header +#include "CalorimeterScorers.hh" #include "CsI.hh" -#include "ObsoleteGeneralScorers.hh" -#include "RootOutput.h" -#include "MaterialManager.hh" #include "InteractionScorers.hh" -#include "PhotoDiodeScorers.hh" -#include "CalorimeterScorers.hh" -#include "NPSDetectorFactory.hh" +#include "MaterialManager.hh" #include "NPOptionManager.h" -//using namespace OBSOLETEGENERALSCORERS ; -// CLHEP header +#include "NPSDetectorFactory.hh" +#include "ObsoleteGeneralScorers.hh" +#include "PhotoDiodeScorers.hh" +#include "RootOutput.h" +// using namespace OBSOLETEGENERALSCORERS ; +// CLHEP header #include "CLHEP/Random/RandGauss.h" using namespace std; using namespace CLHEP; - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // CsI Specific Method -CsI::CsI(){ - m_Event = new TCsIData() ; - m_CsIScorer = 0; - ResoCsI = 2.5/2.35;// 2.5% FWHM - PhotoDiodeFace = 18.;//mm - PhotoDiodeThickness = 3.;//mm +CsI::CsI() { + m_Event = new TCsIData(); + m_CsIScorer = 0; + ResoCsI = 2.5 / 2.35; // 2.5% FWHM + PhotoDiodeFace = 18.; // mm + PhotoDiodeThickness = 3.; // mm } -CsI::~CsI(){ -} +CsI::~CsI() {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void CsI::AddCsI( G4double R , - G4double Theta , - G4double Phi , - G4double CsIThickness , - G4double CsIRadius , - G4String Scintillator , - G4double LeadThickness ) -{ - - m_R.push_back(R) ; - m_Theta.push_back(Theta) ; - m_Phi.push_back(Phi) ; - m_CsIThickness.push_back(CsIThickness) ; - m_LeadThickness.push_back(LeadThickness) ; - m_Scintillator.push_back(Scintillator) ; - m_CsIRadius.push_back(CsIRadius) ; // cylindrical shape - m_CsIFaceFront.push_back(-1) ; // Trapezoidal shape - m_CsIFaceBack.push_back(-1) ; // Trapezoidal shape +void CsI::AddCsI(G4double R, G4double Theta, G4double Phi, G4double CsIThickness, G4double CsIRadius, + G4String Scintillator, G4double LeadThickness) { + + m_R.push_back(R); + m_Theta.push_back(Theta); + m_Phi.push_back(Phi); + m_CsIThickness.push_back(CsIThickness); + m_LeadThickness.push_back(LeadThickness); + m_Scintillator.push_back(Scintillator); + m_CsIRadius.push_back(CsIRadius); // cylindrical shape + m_CsIFaceFront.push_back(-1); // Trapezoidal shape + m_CsIFaceBack.push_back(-1); // Trapezoidal shape } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void CsI::AddCsI( G4double R , - G4double Theta , - G4double Phi , - G4double FaceFront , - G4double FaceBack , - G4double CsIThickness , - G4String Scintillator , - G4double LeadThickness ) -{ - m_R.push_back(R) ; - m_Theta.push_back(Theta) ; - m_Phi.push_back(Phi) ; - m_CsIThickness.push_back(CsIThickness) ; - m_LeadThickness.push_back(LeadThickness) ; - m_Scintillator.push_back(Scintillator) ; - m_CsIRadius.push_back(-1) ; // cylindrical shape - m_CsIFaceFront.push_back(FaceFront) ; // Trapezoidal shape - m_CsIFaceBack.push_back(FaceBack) ; // Trapezoidal shape - +void CsI::AddCsI(G4double R, G4double Theta, G4double Phi, G4double FaceFront, G4double FaceBack, G4double CsIThickness, + G4String Scintillator, G4double LeadThickness) { + m_R.push_back(R); + m_Theta.push_back(Theta); + m_Phi.push_back(Phi); + m_CsIThickness.push_back(CsIThickness); + m_LeadThickness.push_back(LeadThickness); + m_Scintillator.push_back(Scintillator); + m_CsIRadius.push_back(-1); // cylindrical shape + m_CsIFaceFront.push_back(FaceFront); // Trapezoidal shape + m_CsIFaceBack.push_back(FaceBack); // Trapezoidal shape } - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Virtual Method of VDetector class - // Read stream at Configfile to pick-up parameters of detector (Position,...) // Called in DetecorConstruction::ReadDetextorConfiguration Method -void CsI::ReadConfiguration(NPL::InputParser parser ){ - vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithToken("CsI"); - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << "//// " << blocks.size() << " detectors found " << endl; - - vector<string> cart = {"X","Y","Z"}; - vector<string> sphe = {"R","Theta","Phi"}; - vector<string> trapez= {"Shape","FaceFront","FaceBack","Thickness","Scintillator","LeadThickness"}; - vector<string> cylind= {"Shape","Radius","Thickness","Scintillator","LeadThickness"}; - - for(unsigned int i = 0 ; i < blocks.size() ; i++){ - if(blocks[i]->HasTokenList(cart)){ - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << endl << "//// Plastic " << i+1 << endl; - double X = blocks[i]->GetDouble("X","mm"); - double Y = blocks[i]->GetDouble("Y","mm"); - double Z = blocks[i]->GetDouble("Z","mm"); - double R = sqrt (X*X+Y*Y+Z*Z); - double Theta = acos(Z / (R) ); - double Phi = atan2(Y,X); - - if(blocks[i]->HasTokenList(trapez)){ - string Shape = blocks[i]->GetString("Shape"); - double FaceFront = blocks[i]->GetDouble("FaceFront","mm"); - double FaceBack = blocks[i]->GetDouble("FaceBack","mm"); - double Thickness = blocks[i]->GetDouble("Thickness","mm"); - string Scintillator= blocks[i]->GetString("Scintillator"); - double LeadThickness = blocks[i]->GetDouble("LeadThickness","mm"); - AddCsI(R,Theta,Phi,FaceFront,FaceBack,Thickness,Scintillator,LeadThickness); - } - - else if(blocks[i]->HasTokenList(cylind)){ - string Shape = blocks[i]->GetString("Shape"); - double Radius = blocks[i]->GetDouble("Radius","mm"); - double Thickness = blocks[i]->GetDouble("Thickness","mm"); - string Scintillator= blocks[i]->GetString("Scintillator"); - double LeadThickness = blocks[i]->GetDouble("LeadThickness","mm"); - AddCsI(R,Theta,Phi,Thickness,Radius,Scintillator,LeadThickness); - } - - } - else if(blocks[i]->HasTokenList(sphe)){ - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << endl << "//// Plastic " << i+1 << endl; - double R = blocks[i]->GetDouble("R","mm"); - double Theta = blocks[i]->GetDouble("Theta","deg"); - double Phi = blocks[i]->GetDouble("Phi","deg"); - - if(blocks[i]->HasTokenList(trapez)){ - string Shape = blocks[i]->GetString("Shape"); - double FaceFront = blocks[i]->GetDouble("FaceFront","mm"); - double FaceBack = blocks[i]->GetDouble("FaceBack","mm"); - double Thickness = blocks[i]->GetDouble("Thickness","mm"); - string Scintillator = blocks[i]->GetString("Scintillator"); - double LeadThickness = blocks[i]->GetDouble("LeadThickness","mm"); - AddCsI(R,Theta,Phi,FaceFront,FaceBack,Thickness,Scintillator,LeadThickness); - } - - else if(blocks[i]->HasTokenList(cylind)){ - string Shape = blocks[i]->GetString("Shape"); - double Radius = blocks[i]->GetDouble("Radius","mm"); - double Thickness = blocks[i]->GetDouble("Thickness","mm"); - string Scintillator = blocks[i]->GetString("Scintillator"); - double LeadThickness = blocks[i]->GetDouble("LeadThickness","mm"); - AddCsI(R,Theta,Phi,Thickness,Radius,Scintillator,LeadThickness); - } - - } - - - else{ - cout << "ERROR: check your input file formatting " << endl; - exit(1); - } +void CsI::ReadConfiguration(NPL::InputParser parser) { + vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithToken("CsI"); + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks.size() << " detectors found " << endl; + + vector<string> cart = {"X", "Y", "Z"}; + vector<string> sphe = {"R", "Theta", "Phi"}; + vector<string> trapez = {"Shape", "FaceFront", "FaceBack", "Thickness", "Scintillator", "LeadThickness"}; + vector<string> cylind = {"Shape", "Radius", "Thickness", "Scintillator", "LeadThickness"}; + + for (unsigned int i = 0; i < blocks.size(); i++) { + if (blocks[i]->HasTokenList(cart)) { + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// Plastic " << i + 1 << endl; + double X = blocks[i]->GetDouble("X", "mm"); + double Y = blocks[i]->GetDouble("Y", "mm"); + double Z = blocks[i]->GetDouble("Z", "mm"); + double R = sqrt(X * X + Y * Y + Z * Z); + double Theta = acos(Z / (R)); + double Phi = atan2(Y, X); + + if (blocks[i]->HasTokenList(trapez)) { + string Shape = blocks[i]->GetString("Shape"); + double FaceFront = blocks[i]->GetDouble("FaceFront", "mm"); + double FaceBack = blocks[i]->GetDouble("FaceBack", "mm"); + double Thickness = blocks[i]->GetDouble("Thickness", "mm"); + string Scintillator = blocks[i]->GetString("Scintillator"); + double LeadThickness = blocks[i]->GetDouble("LeadThickness", "mm"); + AddCsI(R, Theta, Phi, FaceFront, FaceBack, Thickness, Scintillator, LeadThickness); + } + + else if (blocks[i]->HasTokenList(cylind)) { + string Shape = blocks[i]->GetString("Shape"); + double Radius = blocks[i]->GetDouble("Radius", "mm"); + double Thickness = blocks[i]->GetDouble("Thickness", "mm"); + string Scintillator = blocks[i]->GetString("Scintillator"); + double LeadThickness = blocks[i]->GetDouble("LeadThickness", "mm"); + AddCsI(R, Theta, Phi, Thickness, Radius, Scintillator, LeadThickness); + } } + else if (blocks[i]->HasTokenList(sphe)) { + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// Plastic " << i + 1 << endl; + double R = blocks[i]->GetDouble("R", "mm"); + double Theta = blocks[i]->GetDouble("Theta", "deg"); + double Phi = blocks[i]->GetDouble("Phi", "deg"); + + if (blocks[i]->HasTokenList(trapez)) { + string Shape = blocks[i]->GetString("Shape"); + double FaceFront = blocks[i]->GetDouble("FaceFront", "mm"); + double FaceBack = blocks[i]->GetDouble("FaceBack", "mm"); + double Thickness = blocks[i]->GetDouble("Thickness", "mm"); + string Scintillator = blocks[i]->GetString("Scintillator"); + double LeadThickness = blocks[i]->GetDouble("LeadThickness", "mm"); + AddCsI(R, Theta, Phi, FaceFront, FaceBack, Thickness, Scintillator, LeadThickness); + } + + else if (blocks[i]->HasTokenList(cylind)) { + string Shape = blocks[i]->GetString("Shape"); + double Radius = blocks[i]->GetDouble("Radius", "mm"); + double Thickness = blocks[i]->GetDouble("Thickness", "mm"); + string Scintillator = blocks[i]->GetString("Scintillator"); + double LeadThickness = blocks[i]->GetDouble("LeadThickness", "mm"); + AddCsI(R, Theta, Phi, Thickness, Radius, Scintillator, LeadThickness); + } + } + + else { + cout << "ERROR: check your input file formatting " << endl; + exit(1); + } + } } // Construct detector and inialise sensitive part. // Called After DetecorConstruction::AddDetector Method -void CsI::ConstructDetector(G4LogicalVolume* world){ - G4ThreeVector Det_pos = G4ThreeVector(0, 0, 0) ; - - for (unsigned short i = 0 ; i < m_R.size() ; i++) { - G4double wX = m_R[i] * sin(m_Theta[i] ) * cos(m_Phi[i] ) ; - G4double wY = m_R[i] * sin(m_Theta[i] ) * sin(m_Phi[i] ) ; - G4double wZ = m_R[i] * cos(m_Theta[i] ) ; - Det_pos = G4ThreeVector(wX, wY, wZ) ; - VolumeMaker(Det_pos , i+1, world) ; - } - +void CsI::ConstructDetector(G4LogicalVolume* world) { + G4ThreeVector Det_pos = G4ThreeVector(0, 0, 0); + + for (unsigned short i = 0; i < m_R.size(); i++) { + G4double wX = m_R[i] * sin(m_Theta[i]) * cos(m_Phi[i]); + G4double wY = m_R[i] * sin(m_Theta[i]) * sin(m_Phi[i]); + G4double wZ = m_R[i] * cos(m_Theta[i]); + Det_pos = G4ThreeVector(wX, wY, wZ); + VolumeMaker(Det_pos, i + 1, world); + } } -void CsI::VolumeMaker(G4ThreeVector Det_pos, int DetNumber, G4LogicalVolume* world){ - //////////////////////////////////////////////////////////////// - ////////////// Starting Volume Definition ////////////////////// - //////////////////////////////////////////////////////////////// - // Name of the module - std::ostringstream DetectorNumber ; - DetectorNumber << DetNumber ; - G4String Name = "CsI" + DetectorNumber.str() ; - - int i = DetNumber-1; - - G4Material* CsIMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary(m_Scintillator[i]) ; - G4Material* Vacuum = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum") ; - - //Create experimental hall - G4double expHall_x = 1.*m; - G4double expHall_y = 1.*m; - G4double expHall_z = 1.*m; - - G4Box* fExperimentalHall_box = new G4Box("expHall_box",expHall_x,expHall_y,expHall_z); - G4LogicalVolume* fExperimentalHall_log = new G4LogicalVolume(fExperimentalHall_box, - Vacuum,"expHall_log",0,0,0); - G4VPhysicalVolume* fExperimentalHall_phys = new G4PVPlacement(0,G4ThreeVector(), - fExperimentalHall_log,"expHall",0,false,0); - - fExperimentalHall_log->SetVisAttributes(G4VisAttributes::Invisible); - - - // Definition of the volume containing the sensitive detector - - // Cylindrical Case - if(m_CsIRadius[i]!=-1){ - if(m_CsIThickness[i]>0 && m_CsIRadius[i]>0){ - - // CsI crystal - G4Tubs* solidCsI = new G4Tubs( Name , - 0 , - m_CsIRadius[i] , - m_CsIThickness[i]/2 , - 0*deg , - 360*deg); - - G4LogicalVolume* logicCsI = new G4LogicalVolume(solidCsI, CsIMaterial, Name+ "_Scintillator", 0, 0, 0); - logicCsI->SetSensitiveDetector(m_CsIScorer); - - G4VisAttributes* CsIVisAtt = new G4VisAttributes(G4Colour(1.0, 0.5, 0.0,0.25)) ; - logicCsI->SetVisAttributes(CsIVisAtt) ; - - G4VPhysicalVolume* physCsI = new G4PVPlacement(0 , - Det_pos , - logicCsI , - Name + "_Scintillator" , - world , - false , - 0 ); - - G4OpticalSurface* OpticalCrysralSurface = new G4OpticalSurface("CrystalSurface"); - OpticalCrysralSurface->SetType(dielectric_metal); - //polished: smooth perfectly polished surcface - //ground: rough surface - OpticalCrysralSurface->SetFinish(polished); - //unified - //glisur - OpticalCrysralSurface->SetModel(glisur); - - G4double pp[] = {0.1*eV, 10*eV}; - const G4int num = sizeof(pp)/sizeof(G4double); - G4double reflectivity[] = {0., 0.}; - assert(sizeof(reflectivity) == sizeof(pp)); - G4double efficiency[] = {1., 1.}; - assert(sizeof(efficiency) == sizeof(pp)); - - G4MaterialPropertiesTable* OpticalCrysralSurfaceProperty = new G4MaterialPropertiesTable(); - - OpticalCrysralSurfaceProperty->AddProperty("REFLECTIVITY",pp,reflectivity,num); - OpticalCrysralSurfaceProperty->AddProperty("EFFICIENCY",pp,efficiency,num); - OpticalCrysralSurface->SetMaterialPropertiesTable(OpticalCrysralSurfaceProperty); - - new G4LogicalBorderSurface("CrystalSurface", physCsI, fExperimentalHall_phys, OpticalCrysralSurface); - //new G4LogicalSkinSurface("OpticalCrysralSurface",logicCsI,OpticalCrysralSurface); - - // Photodiode - G4String NamePD = Name+"PhotoDiode"; - - G4Material* PDMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary("Si"); - - G4Box* solidPhotoDiode = new G4Box(NamePD,0.5*PhotoDiodeFace,0.5*PhotoDiodeFace,0.5*PhotoDiodeThickness); - - G4LogicalVolume* logicPD = new G4LogicalVolume(solidPhotoDiode, PDMaterial, NamePD,0,0,0); - logicPD->SetSensitiveDetector(m_PDScorer); - - G4VisAttributes* PDVisAtt = new G4VisAttributes(G4Colour(0.1, 0.2, 0.3)) ; - logicPD->SetVisAttributes(PDVisAtt); - - new G4PVPlacement(0 , - Det_pos+(m_CsIThickness[i]*0.5+PhotoDiodeThickness*0.5)*Det_pos.unit() , - logicPD , - NamePD , - world , - false , - 0 ); - } - - if(m_LeadThickness[i]>0&& m_CsIRadius[i]>0){ - G4Tubs* solidLead = new G4Tubs(Name+"_Lead", - 0, - m_CsIRadius[i], - m_LeadThickness[i]/2, - 0*deg, - 360*deg); - - G4Material* MaterialLead = MaterialManager::getInstance()->GetMaterialFromLibrary("Pb"); - G4LogicalVolume* logicLead = new G4LogicalVolume(solidLead, MaterialLead, Name+"_Lead", 0, 0, 0);//AC changed lead to Al - G4VisAttributes* LeadVisAtt = new G4VisAttributes(G4Colour(0.1, 0.1, 0.1)) ; - logicLead->SetVisAttributes(LeadVisAtt) ; - - G4PVPlacement( 0, - Det_pos+(m_CsIThickness[i]/2+m_LeadThickness[i]/2)*Det_pos.unit(), - logicLead, - Name+"_Lead", - world, - false, - 0); - } +void CsI::VolumeMaker(G4ThreeVector Det_pos, int DetNumber, G4LogicalVolume* world) { + //////////////////////////////////////////////////////////////// + ////////////// Starting Volume Definition ////////////////////// + //////////////////////////////////////////////////////////////// + // Name of the module + std::ostringstream DetectorNumber; + DetectorNumber << DetNumber; + G4String Name = "CsI" + DetectorNumber.str(); + + int i = DetNumber - 1; + + G4Material* CsIMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary(m_Scintillator[i]); + G4Material* Vacuum = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); + + // Create experimental hall + G4double expHall_x = 1. * m; + G4double expHall_y = 1. * m; + G4double expHall_z = 1. * m; + + G4Box* fExperimentalHall_box = new G4Box("expHall_box", expHall_x, expHall_y, expHall_z); + G4LogicalVolume* fExperimentalHall_log = new G4LogicalVolume(fExperimentalHall_box, Vacuum, "expHall_log", 0, 0, 0); + G4VPhysicalVolume* fExperimentalHall_phys = + new G4PVPlacement(0, G4ThreeVector(), fExperimentalHall_log, "expHall", 0, false, 0); + + fExperimentalHall_log->SetVisAttributes(G4VisAttributes::GetInvisible()); + + // Definition of the volume containing the sensitive detector + + // Cylindrical Case + if (m_CsIRadius[i] != -1) { + if (m_CsIThickness[i] > 0 && m_CsIRadius[i] > 0) { + + // CsI crystal + G4Tubs* solidCsI = new G4Tubs(Name, 0, m_CsIRadius[i], m_CsIThickness[i] / 2, 0 * deg, 360 * deg); + + G4LogicalVolume* logicCsI = new G4LogicalVolume(solidCsI, CsIMaterial, Name + "_Scintillator", 0, 0, 0); + logicCsI->SetSensitiveDetector(m_CsIScorer); + + G4VisAttributes* CsIVisAtt = new G4VisAttributes(G4Colour(1.0, 0.5, 0.0, 0.25)); + logicCsI->SetVisAttributes(CsIVisAtt); + + G4VPhysicalVolume* physCsI = new G4PVPlacement(0, Det_pos, logicCsI, Name + "_Scintillator", world, false, 0); + + G4OpticalSurface* OpticalCrysralSurface = new G4OpticalSurface("CrystalSurface"); + OpticalCrysralSurface->SetType(dielectric_metal); + // polished: smooth perfectly polished surcface + // ground: rough surface + OpticalCrysralSurface->SetFinish(polished); + // unified + // glisur + OpticalCrysralSurface->SetModel(glisur); + + G4double pp[] = {0.1 * eV, 10 * eV}; + const G4int num = sizeof(pp) / sizeof(G4double); + G4double reflectivity[] = {0., 0.}; + assert(sizeof(reflectivity) == sizeof(pp)); + G4double efficiency[] = {1., 1.}; + assert(sizeof(efficiency) == sizeof(pp)); + + G4MaterialPropertiesTable* OpticalCrysralSurfaceProperty = new G4MaterialPropertiesTable(); + + OpticalCrysralSurfaceProperty->AddProperty("REFLECTIVITY", pp, reflectivity, num); + OpticalCrysralSurfaceProperty->AddProperty("EFFICIENCY", pp, efficiency, num); + OpticalCrysralSurface->SetMaterialPropertiesTable(OpticalCrysralSurfaceProperty); + + new G4LogicalBorderSurface("CrystalSurface", physCsI, fExperimentalHall_phys, OpticalCrysralSurface); + // new G4LogicalSkinSurface("OpticalCrysralSurface",logicCsI,OpticalCrysralSurface); + + // Photodiode + G4String NamePD = Name + "PhotoDiode"; + + G4Material* PDMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary("Si"); + + G4Box* solidPhotoDiode = new G4Box(NamePD, 0.5 * PhotoDiodeFace, 0.5 * PhotoDiodeFace, 0.5 * PhotoDiodeThickness); + + G4LogicalVolume* logicPD = new G4LogicalVolume(solidPhotoDiode, PDMaterial, NamePD, 0, 0, 0); + logicPD->SetSensitiveDetector(m_PDScorer); + + G4VisAttributes* PDVisAtt = new G4VisAttributes(G4Colour(0.1, 0.2, 0.3)); + logicPD->SetVisAttributes(PDVisAtt); + + new G4PVPlacement(0, Det_pos + (m_CsIThickness[i] * 0.5 + PhotoDiodeThickness * 0.5) * Det_pos.unit(), logicPD, + NamePD, world, false, 0); + } + + if (m_LeadThickness[i] > 0 && m_CsIRadius[i] > 0) { + G4Tubs* solidLead = new G4Tubs(Name + "_Lead", 0, m_CsIRadius[i], m_LeadThickness[i] / 2, 0 * deg, 360 * deg); + + G4Material* MaterialLead = MaterialManager::getInstance()->GetMaterialFromLibrary("Pb"); + G4LogicalVolume* logicLead = + new G4LogicalVolume(solidLead, MaterialLead, Name + "_Lead", 0, 0, 0); // AC changed lead to Al + G4VisAttributes* LeadVisAtt = new G4VisAttributes(G4Colour(0.1, 0.1, 0.1)); + logicLead->SetVisAttributes(LeadVisAtt); + + G4PVPlacement(0, Det_pos + (m_CsIThickness[i] / 2 + m_LeadThickness[i] / 2) * Det_pos.unit(), logicLead, + Name + "_Lead", world, false, 0); + } + } + + // Trapezoidal case + if (m_CsIFaceFront[i] != -1) { + if (m_CsIThickness[i] > 0 && m_CsIFaceFront[i] > 0 && m_CsIFaceBack[i] > 0) { + + G4Trd* solidCsI = new G4Trd("solidCsICrystal", 0.5 * m_CsIFaceFront[i], 0.5 * m_CsIFaceBack[i], + 0.5 * m_CsIFaceFront[i], 0.5 * m_CsIFaceBack[i], 0.5 * m_CsIThickness[i]); + + // G4Box* solidCsI = new G4Box(Name, 0.5*m_CsIFaceBack[i], 0.5*m_CsIFaceFront[i], 0.5*m_CsIThickness[i]); + G4LogicalVolume* logicCsI = new G4LogicalVolume(solidCsI, CsIMaterial, Name + "_Scintillator", 0, 0, 0); + logicCsI->SetSensitiveDetector(m_CsIScorer); + + G4VisAttributes* PlastVisAtt = new G4VisAttributes(G4Colour(1.0, 0.5, 0.0)); + logicCsI->SetVisAttributes(PlastVisAtt); + + G4RotationMatrix Rot3D; + Rot3D.set(0, 0, 0); + + G4VPhysicalVolume* physCsI = + new G4PVPlacement(G4Transform3D(Rot3D, Det_pos), logicCsI, Name + "_Scintillator", world, false, 0); + + G4OpticalSurface* OpticalCrysralSurface = new G4OpticalSurface("CrystalSurface"); + OpticalCrysralSurface->SetType(dielectric_metal); + // polished: smooth perfectly polished surcface + // ground: rough surface + OpticalCrysralSurface->SetFinish(polished); + // unified + // glisur + OpticalCrysralSurface->SetModel(glisur); + + G4double pp[] = {0.1 * eV, 10 * eV}; + const G4int num = sizeof(pp) / sizeof(G4double); + G4double reflectivity[] = {0., 0.}; + assert(sizeof(reflectivity) == sizeof(pp)); + G4double efficiency[] = {1., 1.}; + assert(sizeof(efficiency) == sizeof(pp)); + + G4MaterialPropertiesTable* OpticalCrysralSurfaceProperty = new G4MaterialPropertiesTable(); + + OpticalCrysralSurfaceProperty->AddProperty("REFLECTIVITY", pp, reflectivity, num); + OpticalCrysralSurfaceProperty->AddProperty("EFFICIENCY", pp, efficiency, num); + OpticalCrysralSurface->SetMaterialPropertiesTable(OpticalCrysralSurfaceProperty); + + new G4LogicalBorderSurface("CrystalSurface", physCsI, fExperimentalHall_phys, OpticalCrysralSurface); + // new G4LogicalSkinSurface("OpticalCrysralSurface",logicCsI,OpticalCrysralSurface); + + // Photodiode + /*G4String NamePD = Name+"PhotoDiode"; + + G4Material* PDMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary("Si"); + + G4Box* solidPhotoDiode = new G4Box(NamePD,0.5*PhotoDiodeFace,0.5*PhotoDiodeFace,0.5*PhotoDiodeThickness); + + G4LogicalVolume* logicPD = new G4LogicalVolume(solidPhotoDiode, PDMaterial, NamePD,0,0,0); + logicPD->SetSensitiveDetector(m_PDScorer); + + G4VisAttributes* PDVisAtt = new G4VisAttributes(G4Colour(0.1, 0.2, 0.3)) ; + logicPD->SetVisAttributes(PDVisAtt); + + new G4PVPlacement(0 , + Det_pos+(m_CsIThickness[i]*0.5+PhotoDiodeThickness*0.5)*Det_pos.unit() , + logicPD , + NamePD , + world , + false , + 0 );*/ } - - // Trapezoidal case - if(m_CsIFaceFront[i]!=-1){ - if(m_CsIThickness[i]>0 && m_CsIFaceFront[i]>0 && m_CsIFaceBack[i]>0){ - - G4Trd* solidCsI = new G4Trd("solidCsICrystal",0.5*m_CsIFaceFront[i],0.5*m_CsIFaceBack[i],0.5*m_CsIFaceFront[i],0.5*m_CsIFaceBack[i],0.5*m_CsIThickness[i]); - - //G4Box* solidCsI = new G4Box(Name, 0.5*m_CsIFaceBack[i], 0.5*m_CsIFaceFront[i], 0.5*m_CsIThickness[i]); - G4LogicalVolume* logicCsI = new G4LogicalVolume(solidCsI, CsIMaterial, Name+ "_Scintillator", 0, 0, 0); - logicCsI->SetSensitiveDetector(m_CsIScorer); - - G4VisAttributes* PlastVisAtt = new G4VisAttributes(G4Colour(1.0, 0.5, 0.0)) ; - logicCsI->SetVisAttributes(PlastVisAtt) ; - - G4RotationMatrix Rot3D; - Rot3D.set(0, 0, 0); - - G4VPhysicalVolume* physCsI = new G4PVPlacement( G4Transform3D(Rot3D,Det_pos), - logicCsI, - Name + "_Scintillator" , - world, - false, - 0); - - G4OpticalSurface* OpticalCrysralSurface = new G4OpticalSurface("CrystalSurface"); - OpticalCrysralSurface->SetType(dielectric_metal); - //polished: smooth perfectly polished surcface - //ground: rough surface - OpticalCrysralSurface->SetFinish(polished); - //unified - //glisur - OpticalCrysralSurface->SetModel(glisur); - - G4double pp[] = {0.1*eV, 10*eV}; - const G4int num = sizeof(pp)/sizeof(G4double); - G4double reflectivity[] = {0., 0.}; - assert(sizeof(reflectivity) == sizeof(pp)); - G4double efficiency[] = {1., 1.}; - assert(sizeof(efficiency) == sizeof(pp)); - - G4MaterialPropertiesTable* OpticalCrysralSurfaceProperty = new G4MaterialPropertiesTable(); - - OpticalCrysralSurfaceProperty->AddProperty("REFLECTIVITY",pp,reflectivity,num); - OpticalCrysralSurfaceProperty->AddProperty("EFFICIENCY",pp,efficiency,num); - OpticalCrysralSurface->SetMaterialPropertiesTable(OpticalCrysralSurfaceProperty); - - new G4LogicalBorderSurface("CrystalSurface", physCsI, fExperimentalHall_phys, OpticalCrysralSurface); - //new G4LogicalSkinSurface("OpticalCrysralSurface",logicCsI,OpticalCrysralSurface); - - // Photodiode - /*G4String NamePD = Name+"PhotoDiode"; - - G4Material* PDMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary("Si"); - - G4Box* solidPhotoDiode = new G4Box(NamePD,0.5*PhotoDiodeFace,0.5*PhotoDiodeFace,0.5*PhotoDiodeThickness); - - G4LogicalVolume* logicPD = new G4LogicalVolume(solidPhotoDiode, PDMaterial, NamePD,0,0,0); - logicPD->SetSensitiveDetector(m_PDScorer); - - G4VisAttributes* PDVisAtt = new G4VisAttributes(G4Colour(0.1, 0.2, 0.3)) ; - logicPD->SetVisAttributes(PDVisAtt); - - new G4PVPlacement(0 , - Det_pos+(m_CsIThickness[i]*0.5+PhotoDiodeThickness*0.5)*Det_pos.unit() , - logicPD , - NamePD , - world , - false , - 0 );*/ - - } - - if(m_LeadThickness[i]>0&& m_CsIFaceFront[i]>0 && m_CsIFaceBack[i]>0){ - G4Box* solidLead = new G4Box(Name+"_Lead", 0.5*m_CsIFaceBack[i], 0.5*m_CsIFaceFront[i], 0.5*m_LeadThickness[i]); - - G4Material* MaterialLead = MaterialManager::getInstance()->GetMaterialFromLibrary("Pb"); - G4LogicalVolume* logicLead = new G4LogicalVolume(solidLead, MaterialLead, Name+"_Lead", 0, 0, 0); - G4VisAttributes* LeadVisAtt = new G4VisAttributes(G4Colour(0.1, 0.1, 0.1)) ; - logicLead->SetVisAttributes(LeadVisAtt) ; - - new G4PVPlacement(0, - Det_pos+(m_CsIThickness[i]/2+m_LeadThickness[i]/2)*Det_pos.unit() +G4ThreeVector(0,0,-10*cm) , - logicLead, - Name+"_Lead", - world, - false, - 0); - } + + if (m_LeadThickness[i] > 0 && m_CsIFaceFront[i] > 0 && m_CsIFaceBack[i] > 0) { + G4Box* solidLead = + new G4Box(Name + "_Lead", 0.5 * m_CsIFaceBack[i], 0.5 * m_CsIFaceFront[i], 0.5 * m_LeadThickness[i]); + + G4Material* MaterialLead = MaterialManager::getInstance()->GetMaterialFromLibrary("Pb"); + G4LogicalVolume* logicLead = new G4LogicalVolume(solidLead, MaterialLead, Name + "_Lead", 0, 0, 0); + G4VisAttributes* LeadVisAtt = new G4VisAttributes(G4Colour(0.1, 0.1, 0.1)); + logicLead->SetVisAttributes(LeadVisAtt); + + new G4PVPlacement(0, + Det_pos + (m_CsIThickness[i] / 2 + m_LeadThickness[i] / 2) * Det_pos.unit() + + G4ThreeVector(0, 0, -10 * cm), + logicLead, Name + "_Lead", world, false, 0); } + } } // Add Detector branch to the EventTree. // Called After DetecorConstruction::AddDetector Method -void CsI::InitializeRootOutput(){ - RootOutput *pAnalysis = RootOutput::getInstance(); - TTree *pTree = pAnalysis->GetTree(); - if(!pTree->FindBranch("CsI")){ - pTree->Branch("CsI", "TCsIData", &m_Event) ; - } - pTree->SetBranchAddress("CsI", &m_Event) ; +void CsI::InitializeRootOutput() { + RootOutput* pAnalysis = RootOutput::getInstance(); + TTree* pTree = pAnalysis->GetTree(); + if (!pTree->FindBranch("CsI")) { + pTree->Branch("CsI", "TCsIData", &m_Event); + } + pTree->SetBranchAddress("CsI", &m_Event); } // Read sensitive part and fill the Root tree. // Called at in the EventAction::EndOfEventAvtion -void CsI::ReadSensitive(const G4Event* event){ - //G4String DetectorNumber; - m_Event->Clear(); - - // CsI // - CalorimeterScorers::PS_Calorimeter* Scorer= (CalorimeterScorers::PS_Calorimeter*) m_CsIScorer->GetPrimitive(0); - - unsigned int size = Scorer->GetMult(); - for(unsigned int i = 0 ; i < size ; i++){ - vector<unsigned int> level = Scorer->GetLevel(i); - double E_CsI = RandGauss::shoot(Scorer->GetEnergy(i),Scorer->GetEnergy(i)*ResoCsI/100); - m_Event->SetCsIEEnergy(E_CsI); - m_Event->SetENumber(level[i]); - } - - // PhotoDiode // - NPS::HitsMap<G4double*>* PhotoDiodeHitMap; - std::map<G4int, G4double**>::iterator PhotoDiode_itr; - - G4int PhotoDiodeCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("PDScorer/PhotoDiode"); - PhotoDiodeHitMap = (NPS::HitsMap<G4double*>*)(event->GetHCofThisEvent()->GetHC(PhotoDiodeCollectionID)); - - // Loop on the PhotoDiode map - vector<double> NumberOfOpticalPhoton; - NumberOfOpticalPhoton.clear(); - for (PhotoDiode_itr = PhotoDiodeHitMap->GetMap()->begin() ; PhotoDiode_itr != PhotoDiodeHitMap->GetMap()->end() ; PhotoDiode_itr++){ - G4double* Info = *(PhotoDiode_itr->second); - - m_Event->SetPhotoDiodeEnergy(Info[0]); - m_Event->SetPhotoDiodeEDetectorNbr(Info[7]); - - m_Event->SetPhotoDiodeTime(Info[1]); - m_Event->SetPhotoDiodeTDetectorNbr(Info[7]); - NumberOfOpticalPhoton.push_back(Info[8]); - //cout << "CsI class Info[8] = " << Info[8] << endl;; - //m_Event->SetNumberOfOpticalPhoton(Info[8]); - } - //cout << "CsI class total optical photon = " << NumberOfOpticalPhoton.size() << endl; - m_Event->SetNumberOfOpticalPhoton(NumberOfOpticalPhoton.size()); - PhotoDiodeHitMap->clear(); - -} +void CsI::ReadSensitive(const G4Event* event) { + // G4String DetectorNumber; + m_Event->Clear(); + + // CsI // + CalorimeterScorers::PS_Calorimeter* Scorer = (CalorimeterScorers::PS_Calorimeter*)m_CsIScorer->GetPrimitive(0); + unsigned int size = Scorer->GetMult(); + for (unsigned int i = 0; i < size; i++) { + vector<unsigned int> level = Scorer->GetLevel(i); + double E_CsI = RandGauss::shoot(Scorer->GetEnergy(i), Scorer->GetEnergy(i) * ResoCsI / 100); + m_Event->SetCsIEEnergy(E_CsI); + m_Event->SetENumber(level[i]); + } + + // PhotoDiode // + NPS::HitsMap<G4double*>* PhotoDiodeHitMap; + std::map<G4int, G4double**>::iterator PhotoDiode_itr; + + G4int PhotoDiodeCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("PDScorer/PhotoDiode"); + PhotoDiodeHitMap = (NPS::HitsMap<G4double*>*)(event->GetHCofThisEvent()->GetHC(PhotoDiodeCollectionID)); + + // Loop on the PhotoDiode map + vector<double> NumberOfOpticalPhoton; + NumberOfOpticalPhoton.clear(); + for (PhotoDiode_itr = PhotoDiodeHitMap->GetMap()->begin(); PhotoDiode_itr != PhotoDiodeHitMap->GetMap()->end(); + PhotoDiode_itr++) { + G4double* Info = *(PhotoDiode_itr->second); + + m_Event->SetPhotoDiodeEnergy(Info[0]); + m_Event->SetPhotoDiodeEDetectorNbr(Info[7]); + + m_Event->SetPhotoDiodeTime(Info[1]); + m_Event->SetPhotoDiodeTDetectorNbr(Info[7]); + NumberOfOpticalPhoton.push_back(Info[8]); + // cout << "CsI class Info[8] = " << Info[8] << endl;; + // m_Event->SetNumberOfOpticalPhoton(Info[8]); + } + // cout << "CsI class total optical photon = " << NumberOfOpticalPhoton.size() << endl; + m_Event->SetNumberOfOpticalPhoton(NumberOfOpticalPhoton.size()); + PhotoDiodeHitMap->clear(); +} //////////////////////////////////////////////////////////////// void CsI::InitializeScorers() { - bool already_exist = false; - vector<G4int> NestingLevel; - NestingLevel.push_back(0); - NestingLevel.push_back(1); - m_CsIScorer = CheckScorer("CsIScorer",already_exist) ; - m_PDScorer = CheckScorer("PDScorer",already_exist) ; - - if(already_exist) return ; - - G4VPrimitiveScorer* CsIScorer= new CalorimeterScorers::PS_Calorimeter("CsI",NestingLevel); - m_CsIScorer->RegisterPrimitive(CsIScorer); - - - G4VPrimitiveScorer* Interaction= new InteractionScorers::PS_Interactions("InteractionCsI",ms_InterCoord,1); - m_CsIScorer->RegisterPrimitive(Interaction); - - - G4VPrimitiveScorer* PDScorer = new PHOTODIODESCORERS::PS_PhotoDiode_Rectangle("PhotoDiode",0, - PhotoDiodeFace, - PhotoDiodeFace, - 1, - 1); - m_PDScorer->RegisterPrimitive(PDScorer); - - G4SDManager::GetSDMpointer()->AddNewDetector(m_PDScorer) ; - G4SDManager::GetSDMpointer()->AddNewDetector(m_CsIScorer) ; - + bool already_exist = false; + vector<G4int> NestingLevel; + NestingLevel.push_back(0); + NestingLevel.push_back(1); + m_CsIScorer = CheckScorer("CsIScorer", already_exist); + m_PDScorer = CheckScorer("PDScorer", already_exist); + + if (already_exist) + return; + + G4VPrimitiveScorer* CsIScorer = new CalorimeterScorers::PS_Calorimeter("CsI", NestingLevel); + m_CsIScorer->RegisterPrimitive(CsIScorer); + + G4VPrimitiveScorer* Interaction = new InteractionScorers::PS_Interactions("InteractionCsI", ms_InterCoord, 1); + m_CsIScorer->RegisterPrimitive(Interaction); + + G4VPrimitiveScorer* PDScorer = + new PHOTODIODESCORERS::PS_PhotoDiode_Rectangle("PhotoDiode", 0, PhotoDiodeFace, PhotoDiodeFace, 1, 1); + m_PDScorer->RegisterPrimitive(PDScorer); + + G4SDManager::GetSDMpointer()->AddNewDetector(m_PDScorer); + G4SDManager::GetSDMpointer()->AddNewDetector(m_CsIScorer); } //////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// // Construct Method to be pass to the DetectorFactory // //////////////////////////////////////////////////////////////////////////////// -NPS::VDetector* CsI::Construct(){ - return (NPS::VDetector*) new CsI(); -} +NPS::VDetector* CsI::Construct() { return (NPS::VDetector*)new CsI(); } //////////////////////////////////////////////////////////////////////////////// // Registering the construct method to the factory // //////////////////////////////////////////////////////////////////////////////// -extern"C" { - class proxy_nps_csi{ - public: - proxy_nps_csi(){ - NPS::DetectorFactory::getInstance()->AddToken("CsI","CsI"); - NPS::DetectorFactory::getInstance()->AddDetector("CsI",CsI::Construct); - } - }; - - proxy_nps_csi p_nps_csi; +extern "C" { +class proxy_nps_csi { + public: + proxy_nps_csi() { + NPS::DetectorFactory::getInstance()->AddToken("CsI", "CsI"); + NPS::DetectorFactory::getInstance()->AddDetector("CsI", CsI::Construct); + } +}; + +proxy_nps_csi p_nps_csi; } diff --git a/NPSimulation/Detectors/Eurogam/Eurogam.cc b/NPSimulation/Detectors/Eurogam/Eurogam.cc index f11a1fe0930d86297c829639318e8ea204efe99f..dd6950e1a40caeadb83176e75217259b991162fb 100755 --- a/NPSimulation/Detectors/Eurogam/Eurogam.cc +++ b/NPSimulation/Detectors/Eurogam/Eurogam.cc @@ -20,36 +20,36 @@ *****************************************************************************/ // C++ headers -#include <sstream> #include <cmath> #include <limits> +#include <sstream> -//G4 Geometry object +// G4 Geometry object #include "G4Box.hh" -#include "G4Tubs.hh" #include "G4Cons.hh" -#include "G4UnionSolid.hh" -#include "G4SubtractionSolid.hh" #include "G4IntersectionSolid.hh" +#include "G4SubtractionSolid.hh" +#include "G4Tubs.hh" +#include "G4UnionSolid.hh" -//G4 sensitive -#include "G4SDManager.hh" +// G4 sensitive #include "G4MultiFunctionalDetector.hh" +#include "G4SDManager.hh" -//G4 various object +// G4 various object +#include "G4Colour.hh" #include "G4Material.hh" -#include "G4Transform3D.hh" #include "G4PVPlacement.hh" +#include "G4Transform3D.hh" #include "G4VisAttributes.hh" -#include "G4Colour.hh" // NPTool header #include "Eurogam.hh" -#include "ObsoleteGeneralScorers.hh" #include "MaterialManager.hh" +#include "NPOptionManager.h" #include "NPSDetectorFactory.hh" +#include "ObsoleteGeneralScorers.hh" #include "RootOutput.h" -#include "NPOptionManager.h" using namespace OBSOLETEGENERALSCORERS; // CLHEP header @@ -59,66 +59,55 @@ using namespace std; using namespace CLHEP; using namespace EUROGAMDETECTOR; - - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Eurogam Specific Method -Eurogam::Eurogam() -{ - InitializeMaterial(); - m_Event = new TEurogamData(); +Eurogam::Eurogam() { + InitializeMaterial(); + m_Event = new TEurogamData(); } +Eurogam::~Eurogam() { + // Materials + delete m_Material_Vacuum; + delete m_Material_Aluminium; + delete m_Material_Silicon; + delete m_Material_Germanium; - -Eurogam::~Eurogam() -{ - // Materials - delete m_Material_Vacuum; - delete m_Material_Aluminium; - delete m_Material_Silicon; - delete m_Material_Germanium; - - delete m_Event; - delete m_EurogamScorer; + delete m_Event; + delete m_EurogamScorer; } - - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Eurogam::AddEurogamModule(G4double R, G4double Theta, G4double Phi, - G4double beta_u, G4double beta_v, G4double beta_w) -{ - m_R.push_back(R); - m_Theta.push_back(Theta); - m_Phi.push_back(Phi); - m_beta_u.push_back(beta_u); - m_beta_v.push_back(beta_v); - m_beta_w.push_back(beta_w); +void Eurogam::AddEurogamModule(G4double R, G4double Theta, G4double Phi, G4double beta_u, G4double beta_v, + G4double beta_w) { + m_R.push_back(R); + m_Theta.push_back(Theta); + m_Phi.push_back(Phi); + m_beta_u.push_back(beta_u); + m_beta_v.push_back(beta_v); + m_beta_w.push_back(beta_w); } - - // Read stream at Configfile to pick-up parameters of detector (Position,...) // Called in DetecorConstruction::ReadDetextorConfiguration Method -void Eurogam::ReadConfiguration(NPL::InputParser parser){ +void Eurogam::ReadConfiguration(NPL::InputParser parser) { vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithToken("Eurogam"); - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << "//// " << blocks.size() << " detectors found " << endl; + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks.size() << " detectors found " << endl; - vector<string> token = {"R","Theta","Phi"}; + vector<string> token = {"R", "Theta", "Phi"}; - for(unsigned int i = 0 ; i < blocks.size() ; i++){ - if(blocks[i]->HasTokenList(token)){ - double R = blocks[i]->GetDouble("R","mm"); - double Theta = blocks[i]->GetDouble("Theta","deg"); - double Phi = blocks[i]->GetDouble("Phi","deg"); - vector<double> beta = blocks[i]->GetVectorDouble("BETA","deg"); + for (unsigned int i = 0; i < blocks.size(); i++) { + if (blocks[i]->HasTokenList(token)) { + double R = blocks[i]->GetDouble("R", "mm"); + double Theta = blocks[i]->GetDouble("Theta", "deg"); + double Phi = blocks[i]->GetDouble("Phi", "deg"); + vector<double> beta = blocks[i]->GetVectorDouble("BETA", "deg"); AddEurogamModule(R, Theta, Phi, beta[0], beta[1], beta[2]); } - else{ + else { cout << "ERROR: check your input file formatting " << endl; exit(1); } @@ -127,484 +116,470 @@ void Eurogam::ReadConfiguration(NPL::InputParser parser){ // Construct detector and inialise sensitive part. // Called After DetecorConstruction::AddDetector Method -void Eurogam::ConstructDetector(G4LogicalVolume* world) -{ - G4ThreeVector Det_pos = G4ThreeVector(0, 0, 0); - G4RotationMatrix* Det_rot = new G4RotationMatrix(); - - for (unsigned short i = 0; i < m_R.size(); i++) { - G4double Theta = m_Theta[i]; - G4double Phi = m_Phi[i]; - - // (u,v,w) unitary vector associated to the detector referencial - // (u,v) // to detector front - // w perpendicular to (u,v) plan and pointing to the detector back - // Phi is angle between X axis and projection in (X,Y) plan - // Theta is angle between position vector and z axis - G4double wX = m_R[i] * sin(Theta / rad) * cos(Phi / rad); - G4double wY = m_R[i] * sin(Theta / rad) * sin(Phi / rad); - G4double wZ = m_R[i] * cos(Theta / rad); - G4ThreeVector dirw = G4ThreeVector(wX, wY, wZ); - - // vector corresponding to the center of the module - Det_pos = dirw; - dirw = dirw.unit(); - - // vector parallel to one axis of silicon plane - G4double ii = cos(Theta / rad) * cos(Phi / rad); - G4double jj = cos(Theta / rad) * sin(Phi / rad); - G4double kk = -sin(Theta / rad); - G4ThreeVector Y = G4ThreeVector(ii, jj, kk); - - // build rotation matrix to go from the lab referential - // to the telescope referential - G4ThreeVector diru = dirw.cross(Y); - G4ThreeVector dirv = dirw.cross(diru); - dirv = dirv.unit(); - diru = diru.unit(); - Det_rot = new G4RotationMatrix(diru, dirv, dirw); - - // Detector is rotated by Beta angles around the v axis. - Det_rot->rotate(m_beta_u[i], diru); - Det_rot->rotate(m_beta_v[i], dirv); - Det_rot->rotate(m_beta_w[i], dirw); - - // translation to place the detector - Det_pos += dirw * EurogamDepth * 0.5; - - // Build geometry - VolumeMaker(i + 1, Det_pos, Det_rot, world); - } +void Eurogam::ConstructDetector(G4LogicalVolume* world) { + G4ThreeVector Det_pos = G4ThreeVector(0, 0, 0); + G4RotationMatrix* Det_rot = new G4RotationMatrix(); + + for (unsigned short i = 0; i < m_R.size(); i++) { + G4double Theta = m_Theta[i]; + G4double Phi = m_Phi[i]; + + // (u,v,w) unitary vector associated to the detector referencial + // (u,v) // to detector front + // w perpendicular to (u,v) plan and pointing to the detector back + // Phi is angle between X axis and projection in (X,Y) plan + // Theta is angle between position vector and z axis + G4double wX = m_R[i] * sin(Theta / rad) * cos(Phi / rad); + G4double wY = m_R[i] * sin(Theta / rad) * sin(Phi / rad); + G4double wZ = m_R[i] * cos(Theta / rad); + G4ThreeVector dirw = G4ThreeVector(wX, wY, wZ); + + // vector corresponding to the center of the module + Det_pos = dirw; + dirw = dirw.unit(); + + // vector parallel to one axis of silicon plane + G4double ii = cos(Theta / rad) * cos(Phi / rad); + G4double jj = cos(Theta / rad) * sin(Phi / rad); + G4double kk = -sin(Theta / rad); + G4ThreeVector Y = G4ThreeVector(ii, jj, kk); + + // build rotation matrix to go from the lab referential + // to the telescope referential + G4ThreeVector diru = dirw.cross(Y); + G4ThreeVector dirv = dirw.cross(diru); + dirv = dirv.unit(); + diru = diru.unit(); + Det_rot = new G4RotationMatrix(diru, dirv, dirw); + + // Detector is rotated by Beta angles around the v axis. + Det_rot->rotate(m_beta_u[i], diru); + Det_rot->rotate(m_beta_v[i], dirv); + Det_rot->rotate(m_beta_w[i], dirw); + + // translation to place the detector + Det_pos += dirw * EurogamDepth * 0.5; + + // Build geometry + VolumeMaker(i + 1, Det_pos, Det_rot, world); + } } - - -void Eurogam::VolumeMaker(G4int DetNumber, - G4ThreeVector DetPos, - G4RotationMatrix* DetRot, - G4LogicalVolume* world) -{ - - //////////////////////////////////////////////////////////////// - ////////////// Starting Volume Definition ////////////////////// - //////////////////////////////////////////////////////////////// - // Name of the module - std::ostringstream DetectorNumber; - DetectorNumber << DetNumber; - G4String Name = "Eurogam" + DetectorNumber.str(); - - // EUROGAM box - G4Box* solidEurogam = new G4Box(Name, EurogamSize/2, EurogamSize/2, EurogamDepth/2); - - G4LogicalVolume* logicEurogam = new G4LogicalVolume(solidEurogam, m_Material_Vacuum, Name, 0, 0, 0); - - new G4PVPlacement(G4Transform3D(*DetRot, DetPos), logicEurogam, Name, world, false, 0); - - logicEurogam->SetVisAttributes(G4VisAttributes::Invisible); - - // Germanium detector itself - // Capot en Aluminium - // Epaisseur du capot - G4double AluThickness = 1*mm; - // Fermeture du capot par 2 disques pleins - G4double RMinFront = 0, RMaxFront = 66.2/2*mm, DzFront = AluThickness; - G4double RMinBack = 0, RMaxBack = 86.2/2*mm, DzBack = AluThickness; - // Composante conique du capot - G4double RMin1Cone = RMaxFront - DzFront, RMax1Cone = RMaxFront; - G4double RMin2Cone = RMaxBack - DzBack, RMax2Cone = RMaxBack; - G4double DzCone = 101.5*mm; - // Composante cylindrique du capot - G4double RMinCylin = RMaxBack - DzBack, RMaxCylin = RMaxBack; - G4double DzCylin = 163.1*mm; - - // Capot avant - G4VSolid* solidCapotFront = new G4Tubs("solidCapotFront", RMinFront, RMaxFront, DzFront/2, 0*degree, 360*degree); - - G4LogicalVolume* logicCapotFront = new G4LogicalVolume(solidCapotFront, // its solid - m_Material_Aluminium, // its material - "logicCapotFront"); // its name - - G4double OffsetZCapotFront = -(EurogamDepth - DzFront)/2; - G4ThreeVector ZposCapotFront = G4ThreeVector(0, 0, OffsetZCapotFront); - new G4PVPlacement(0, // no rotation - ZposCapotFront, // at (0,0,Dz) - logicCapotFront, // its logical name - Name + "_CapotFront", // its name - logicEurogam, // its mother name - false, // no boolean operation - 0); // copy number - - // Partie conique - G4VSolid* solidCapotCone = new G4Cons("solidCapotCone", RMin1Cone, RMax1Cone, RMin2Cone, RMax2Cone, DzCone/2, 0*degree, 360*degree); - - G4LogicalVolume* logicCapotCone = new G4LogicalVolume(solidCapotCone, //its solid - m_Material_Aluminium, //its material - "logicCapotCone"); //its name - - G4double OffsetZCapotCone = -(EurogamDepth/2 - DzFront - DzCone/2); - G4ThreeVector ZposCapotCone = G4ThreeVector(0, 0, OffsetZCapotCone); - new G4PVPlacement(0, // no rotation - ZposCapotCone, // at (0,0,Dz) - logicCapotCone, // its logical name - Name + "_CapotCone", // its name - logicEurogam, // its mother name - false, // no boolean operation - 0); // copy number - - // Partie cylindrique - G4VSolid* solidCapotCylin = new G4Tubs("solidCapotCylin", RMinCylin, RMaxCylin, DzCylin/2, 0*degree, 360*degree); - - G4LogicalVolume* logicCapotCylin = new G4LogicalVolume(solidCapotCylin, //its solid - m_Material_Aluminium, //its material - "logicCapotCylin"); //its name - - G4double OffsetZCapotCylin = -(EurogamDepth/2 - DzFront - DzCone - DzCylin/2); - G4ThreeVector ZposCapotCylin = G4ThreeVector(0, 0, OffsetZCapotCylin); - new G4PVPlacement(0, // no rotation - ZposCapotCylin, // at (0,0,Dz) - logicCapotCylin, // its logical name - Name + "_CapotCylin", // its name - logicEurogam, // its mother name - false, // no boolean operation - 0); // copy number +void Eurogam::VolumeMaker(G4int DetNumber, G4ThreeVector DetPos, G4RotationMatrix* DetRot, G4LogicalVolume* world) { + + //////////////////////////////////////////////////////////////// + ////////////// Starting Volume Definition ////////////////////// + //////////////////////////////////////////////////////////////// + // Name of the module + std::ostringstream DetectorNumber; + DetectorNumber << DetNumber; + G4String Name = "Eurogam" + DetectorNumber.str(); + + // EUROGAM box + G4Box* solidEurogam = new G4Box(Name, EurogamSize / 2, EurogamSize / 2, EurogamDepth / 2); + + G4LogicalVolume* logicEurogam = new G4LogicalVolume(solidEurogam, m_Material_Vacuum, Name, 0, 0, 0); + + new G4PVPlacement(G4Transform3D(*DetRot, DetPos), logicEurogam, Name, world, false, 0); + + logicEurogam->SetVisAttributes(G4VisAttributes::GetInvisible()); + + // Germanium detector itself + // Capot en Aluminium + // Epaisseur du capot + G4double AluThickness = 1 * mm; + // Fermeture du capot par 2 disques pleins + G4double RMinFront = 0, RMaxFront = 66.2 / 2 * mm, DzFront = AluThickness; + G4double RMinBack = 0, RMaxBack = 86.2 / 2 * mm, DzBack = AluThickness; + // Composante conique du capot + G4double RMin1Cone = RMaxFront - DzFront, RMax1Cone = RMaxFront; + G4double RMin2Cone = RMaxBack - DzBack, RMax2Cone = RMaxBack; + G4double DzCone = 101.5 * mm; + // Composante cylindrique du capot + G4double RMinCylin = RMaxBack - DzBack, RMaxCylin = RMaxBack; + G4double DzCylin = 163.1 * mm; + + // Capot avant + G4VSolid* solidCapotFront = + new G4Tubs("solidCapotFront", RMinFront, RMaxFront, DzFront / 2, 0 * degree, 360 * degree); + + G4LogicalVolume* logicCapotFront = new G4LogicalVolume(solidCapotFront, // its solid + m_Material_Aluminium, // its material + "logicCapotFront"); // its name + + G4double OffsetZCapotFront = -(EurogamDepth - DzFront) / 2; + G4ThreeVector ZposCapotFront = G4ThreeVector(0, 0, OffsetZCapotFront); + new G4PVPlacement(0, // no rotation + ZposCapotFront, // at (0,0,Dz) + logicCapotFront, // its logical name + Name + "_CapotFront", // its name + logicEurogam, // its mother name + false, // no boolean operation + 0); // copy number + + // Partie conique + G4VSolid* solidCapotCone = + new G4Cons("solidCapotCone", RMin1Cone, RMax1Cone, RMin2Cone, RMax2Cone, DzCone / 2, 0 * degree, 360 * degree); + + G4LogicalVolume* logicCapotCone = new G4LogicalVolume(solidCapotCone, // its solid + m_Material_Aluminium, // its material + "logicCapotCone"); // its name + + G4double OffsetZCapotCone = -(EurogamDepth / 2 - DzFront - DzCone / 2); + G4ThreeVector ZposCapotCone = G4ThreeVector(0, 0, OffsetZCapotCone); + new G4PVPlacement(0, // no rotation + ZposCapotCone, // at (0,0,Dz) + logicCapotCone, // its logical name + Name + "_CapotCone", // its name + logicEurogam, // its mother name + false, // no boolean operation + 0); // copy number + + // Partie cylindrique + G4VSolid* solidCapotCylin = + new G4Tubs("solidCapotCylin", RMinCylin, RMaxCylin, DzCylin / 2, 0 * degree, 360 * degree); + + G4LogicalVolume* logicCapotCylin = new G4LogicalVolume(solidCapotCylin, // its solid + m_Material_Aluminium, // its material + "logicCapotCylin"); // its name + + G4double OffsetZCapotCylin = -(EurogamDepth / 2 - DzFront - DzCone - DzCylin / 2); + G4ThreeVector ZposCapotCylin = G4ThreeVector(0, 0, OffsetZCapotCylin); + new G4PVPlacement(0, // no rotation + ZposCapotCylin, // at (0,0,Dz) + logicCapotCylin, // its logical name + Name + "_CapotCylin", // its name + logicEurogam, // its mother name + false, // no boolean operation + 0); // copy number // Capot arriere - G4VSolid* solidCapotBack = new G4Tubs("solidCapotBack", RMinBack, RMaxBack, DzBack/2, 0*degree, 360*degree); - - G4LogicalVolume* logicCapotBack = new G4LogicalVolume(solidCapotBack, //its solid - m_Material_Aluminium, //its material - "logicCapotBack"); //its name - - G4double OffsetZCapotBack = -(EurogamDepth/2 - DzFront - DzCone - DzCylin - DzBack/2); - G4ThreeVector ZposCapotBack = G4ThreeVector(0, 0, OffsetZCapotBack); - new G4PVPlacement(0, // no rotation - ZposCapotBack, // at (0,0,Dz) - logicCapotBack, // its logical name - Name + "_CapotBack", // its name - logicEurogam, // its mother name - false, // no boolean operation - 0); // copy number - - // cristal de Ge et doigt froid - G4double RMinGe = 0, RMaxGe = 63.1/2*mm, DzGe = 78.5*mm; - G4double SPhiGe = 0, DPhiGe = 360*degree; - G4double distCapotGe = 20*mm; - G4double RMinDoigt = 0, RMaxDoigt = 11.2/2*mm, DzDoigt = 70*mm; - G4double SPhiDoigt = 0*degree, DPhiDoigt = 360*degree; - - G4VSolid* solidDetec = new G4Tubs("solidGermanium", //its name - RMinGe, RMaxGe, DzGe/2, //its size - SPhiGe, DPhiGe); //its size - - G4VSolid* solidDoigt = new G4Tubs("solidDoigt", - RMinDoigt, RMaxDoigt, DzDoigt/2, - SPhiDoigt, DPhiDoigt); - - // !!! pour soustraire le doigt froid du cristal initial de Germainum - // cela se fait dans le repere du cristal de Germanium - // *************** changer signe - en signe + ??????????? - G4double OffsetZDoigt = - (DzGe/2 - DzDoigt/2); - G4ThreeVector ZposDoigt = G4ThreeVector(0, 0, OffsetZDoigt); - G4VSolid* solidSubtrac = new G4SubtractionSolid("solidCristalGe", solidDetec, solidDoigt, 0, ZposDoigt); - - G4LogicalVolume* logicDetec= new G4LogicalVolume(solidSubtrac, //its solid -// m_Material_Germanium, //its material - m_Material_Silicon, //its material - "logicCristalGe"); //its name - -// G4LogicalVolume* logicDetec= new G4LogicalVolume(solidDetec, //its solid -// m_Material_Germanium, //its material -// "logicCristalGe"); //its name - - - G4double OffsetZGe = -(EurogamDepth/2 - distCapotGe - DzGe/2); - G4ThreeVector ZposGe = G4ThreeVector(0, 0, OffsetZGe); - new G4PVPlacement(0, //no rotation - ZposGe, //at (0,0,0) - logicDetec, //its logical volume - Name + "_CristalGe", //its name - logicEurogam, //its mother volume - false, //no boolean operation - 0); //copy number - - // Set Ge detector sensible - logicDetec->SetSensitiveDetector(m_EurogamScorer); - - // Visualisation of FirstStage Strip - G4VisAttributes* DetectorVisAtt = new G4VisAttributes(G4Colour(0.0, 0.0, 0.9)); // blue - logicDetec->SetVisAttributes(DetectorVisAtt); + G4VSolid* solidCapotBack = new G4Tubs("solidCapotBack", RMinBack, RMaxBack, DzBack / 2, 0 * degree, 360 * degree); + + G4LogicalVolume* logicCapotBack = new G4LogicalVolume(solidCapotBack, // its solid + m_Material_Aluminium, // its material + "logicCapotBack"); // its name + + G4double OffsetZCapotBack = -(EurogamDepth / 2 - DzFront - DzCone - DzCylin - DzBack / 2); + G4ThreeVector ZposCapotBack = G4ThreeVector(0, 0, OffsetZCapotBack); + new G4PVPlacement(0, // no rotation + ZposCapotBack, // at (0,0,Dz) + logicCapotBack, // its logical name + Name + "_CapotBack", // its name + logicEurogam, // its mother name + false, // no boolean operation + 0); // copy number + + // cristal de Ge et doigt froid + G4double RMinGe = 0, RMaxGe = 63.1 / 2 * mm, DzGe = 78.5 * mm; + G4double SPhiGe = 0, DPhiGe = 360 * degree; + G4double distCapotGe = 20 * mm; + G4double RMinDoigt = 0, RMaxDoigt = 11.2 / 2 * mm, DzDoigt = 70 * mm; + G4double SPhiDoigt = 0 * degree, DPhiDoigt = 360 * degree; + + G4VSolid* solidDetec = new G4Tubs("solidGermanium", // its name + RMinGe, RMaxGe, DzGe / 2, // its size + SPhiGe, DPhiGe); // its size + + G4VSolid* solidDoigt = new G4Tubs("solidDoigt", RMinDoigt, RMaxDoigt, DzDoigt / 2, SPhiDoigt, DPhiDoigt); + + // !!! pour soustraire le doigt froid du cristal initial de Germainum + // cela se fait dans le repere du cristal de Germanium + // *************** changer signe - en signe + ??????????? + G4double OffsetZDoigt = -(DzGe / 2 - DzDoigt / 2); + G4ThreeVector ZposDoigt = G4ThreeVector(0, 0, OffsetZDoigt); + G4VSolid* solidSubtrac = new G4SubtractionSolid("solidCristalGe", solidDetec, solidDoigt, 0, ZposDoigt); + + G4LogicalVolume* logicDetec = + new G4LogicalVolume(solidSubtrac, // its solid + // m_Material_Germanium, //its material + m_Material_Silicon, // its material + "logicCristalGe"); // its name + + // G4LogicalVolume* logicDetec= new G4LogicalVolume(solidDetec, //its solid + // m_Material_Germanium, //its material + // "logicCristalGe"); //its name + + G4double OffsetZGe = -(EurogamDepth / 2 - distCapotGe - DzGe / 2); + G4ThreeVector ZposGe = G4ThreeVector(0, 0, OffsetZGe); + new G4PVPlacement(0, // no rotation + ZposGe, // at (0,0,0) + logicDetec, // its logical volume + Name + "_CristalGe", // its name + logicEurogam, // its mother volume + false, // no boolean operation + 0); // copy number + + // Set Ge detector sensible + logicDetec->SetSensitiveDetector(m_EurogamScorer); + + // Visualisation of FirstStage Strip + G4VisAttributes* DetectorVisAtt = new G4VisAttributes(G4Colour(0.0, 0.0, 0.9)); // blue + logicDetec->SetVisAttributes(DetectorVisAtt); } - - // Add Detector branch to the EventTree. // Called After DetecorConstruction::AddDetector Method -void Eurogam::InitializeRootOutput() -{ - RootOutput *pAnalysis = RootOutput::getInstance(); - TTree *pTree = pAnalysis->GetTree(); - if(!pTree->FindBranch("Eurogam")){ - pTree->Branch("Eurogam", "TEurogamData", &m_Event) ; - } - pTree->SetBranchAddress("Eurogam", &m_Event) ; - +void Eurogam::InitializeRootOutput() { + RootOutput* pAnalysis = RootOutput::getInstance(); + TTree* pTree = pAnalysis->GetTree(); + if (!pTree->FindBranch("Eurogam")) { + pTree->Branch("Eurogam", "TEurogamData", &m_Event); + } + pTree->SetBranchAddress("Eurogam", &m_Event); } - - // Read sensitive part and fill the Root tree. // Called at in the EventAction::EndOfEventAvtion -void Eurogam::ReadSensitive(const G4Event* event) -{ - // Clear the data of the TEurogamData object - m_Event->Clear(); - - ////////////////////////////////////////////////////////////////////////////////////// - //////////////////////// Used to Read Event Map of detector ////////////////////////// - ////////////////////////////////////////////////////////////////////////////////////// - std::map<G4int, G4int*>::iterator DetectorNumber_itr; - std::map<G4int, G4double*>::iterator Energy_itr; - std::map<G4int, G4double*>::iterator Time_itr; - std::map<G4int, G4double*>::iterator Pos_X_itr; - std::map<G4int, G4double*>::iterator Pos_Y_itr; - std::map<G4int, G4double*>::iterator Pos_Z_itr; - std::map<G4int, G4double*>::iterator Ang_Theta_itr; - std::map<G4int, G4double*>::iterator Ang_Phi_itr; - - NPS::HitsMap<G4int>* DetectorNumberHitMap; - NPS::HitsMap<G4double>* EnergyHitMap; - NPS::HitsMap<G4double>* TimeHitMap; - NPS::HitsMap<G4double>* PosXHitMap; - NPS::HitsMap<G4double>* PosYHitMap; - NPS::HitsMap<G4double>* PosZHitMap; - NPS::HitsMap<G4double>* AngThetaHitMap; - NPS::HitsMap<G4double>* AngPhiHitMap; - - // Read the Scorer associate to the Silicon Strip - //Detector Number - G4int DetCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("EurogamScorer/DetectorNumber"); - DetectorNumberHitMap = (NPS::HitsMap<G4int>*)(event->GetHCofThisEvent()->GetHC(DetCollectionID)); - DetectorNumber_itr = DetectorNumberHitMap->GetMap()->begin(); - - // Energy - G4int EnergyCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("EurogamScorer/Energy"); - EnergyHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(EnergyCollectionID)); - Energy_itr = EnergyHitMap->GetMap()->begin(); - - //Time of Flight - G4int TimeCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("EurogamScorer/Time"); - TimeHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(TimeCollectionID)); - Time_itr = TimeHitMap->GetMap()->begin(); - - //Interaction Coordinate X - G4int InterCoordXCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("EurogamScorer/InterCoordX"); - PosXHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordXCollectionID)); - Pos_X_itr = PosXHitMap->GetMap()->begin(); - - //Interaction Coordinate Y - G4int InterCoordYCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("EurogamScorer/InterCoordY"); - PosYHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordYCollectionID)); - Pos_Y_itr = PosYHitMap->GetMap()->begin(); - - //Interaction Coordinate Z - G4int InterCoordZCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("EurogamScorer/InterCoordZ"); - PosZHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordZCollectionID)); - Pos_Z_itr = PosXHitMap->GetMap()->begin(); - - //Interaction Coordinate Angle Theta - G4int InterCoordAngThetaCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("EurogamScorer/InterCoordAngTheta"); - AngThetaHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordAngThetaCollectionID)); - Ang_Theta_itr = AngThetaHitMap->GetMap()->begin(); - - //Interaction Coordinate Angle Phi - G4int InterCoordAngPhiCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("EurogamScorer/InterCoordAngPhi"); - AngPhiHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordAngPhiCollectionID)); - Ang_Phi_itr = AngPhiHitMap->GetMap()->begin(); - - // Check the size of different map - G4int sizeN = DetectorNumberHitMap->entries(); - G4int sizeE = EnergyHitMap->entries(); - G4int sizeT = TimeHitMap->entries(); - G4int sizeX = PosXHitMap->entries(); - -/* if (sizeN != sizeE || sizeE != sizeT) { - G4cout << "No match size Eurogam Event Map: sE:" << sizeE << " sT:" << sizeT << G4endl; - return; - }*/ - G4cout << "*******SIZE********: " << sizeN << " " << sizeE << " " << sizeT << " " << sizeX << G4endl; - - G4double Etot = 0; - - // Loop on detector number - for (G4int l = 0; l < sizeN; l++) { - G4double N = *(DetectorNumber_itr->second); - G4int NTrackID = DetectorNumber_itr->first - N; - G4cout << "NTrackID: " << NTrackID << " " << N << G4endl; - - if (N > 0) { - // Fill detector number - m_Event->SetEurogamDetectorNumber(N); - - // Energy - Energy_itr = EnergyHitMap->GetMap()->begin(); - for (G4int ll = 0; ll < sizeE; ll++) { - G4int ETrackID = Energy_itr->first - N; - G4double E = *(Energy_itr->second); - G4cout << "ETrackID, E: " << ETrackID << " " << E << G4endl; - if (ETrackID == NTrackID) { - Etot += E; -// m_Event->SetEurogamEnergy(RandGauss::shoot(E, 1)); - // Fill energy loss for each step -// m_Event->SetEurogamEnergy(E*1e3); - } - 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->SetEurogamTime(RandGauss::shoot(T, 1)); - } - Time_itr++; - } - - // Pos X - Pos_X_itr = PosXHitMap->GetMap()->begin(); - for (G4int h = 0; h < PosXHitMap->entries(); h++) { - G4int PosXTrackID = Pos_X_itr->first - N; - G4double PosX = *(Pos_X_itr->second); - if (PosXTrackID == NTrackID) { - ms_InterCoord->SetDetectedPositionX(PosX); - } - Pos_X_itr++; - } - - // Pos Y - Pos_Y_itr = PosYHitMap->GetMap()->begin(); - for (G4int h = 0; h < PosYHitMap->entries(); h++) { - G4int PosYTrackID = Pos_Y_itr->first - N; - G4double PosY = *(Pos_Y_itr->second); - if (PosYTrackID == NTrackID) { - ms_InterCoord->SetDetectedPositionY(PosY); - } - Pos_Y_itr++; - } - - // Pos Z - Pos_Z_itr = PosZHitMap->GetMap()->begin(); - for (G4int h = 0; h < PosZHitMap->entries(); h++) { - G4int PosZTrackID = Pos_Z_itr->first - N; - G4double PosZ = *(Pos_Z_itr->second); - if (PosZTrackID == NTrackID) { - ms_InterCoord->SetDetectedPositionZ(PosZ); - } - Pos_Z_itr++; - } - - // Angle Theta - Ang_Theta_itr = AngThetaHitMap->GetMap()->begin(); - for (G4int h = 0; h < AngThetaHitMap->entries(); h++) { - G4int AngThetaTrackID = Ang_Theta_itr->first - N; - G4double AngTheta = *(Ang_Theta_itr->second); - if (AngThetaTrackID == NTrackID) { - ms_InterCoord->SetDetectedAngleTheta(AngTheta); - } - Ang_Theta_itr++; - } - - // Angle Phi - Ang_Phi_itr = AngPhiHitMap->GetMap()->begin(); - for (G4int h = 0; h < AngPhiHitMap->entries(); h++) { - G4int AngPhiTrackID = Ang_Phi_itr->first - N; - G4double AngPhi = *(Ang_Phi_itr->second); - if (AngPhiTrackID == NTrackID) { - ms_InterCoord->SetDetectedAnglePhi(AngPhi); - } - Ang_Phi_itr++; - } +void Eurogam::ReadSensitive(const G4Event* event) { + // Clear the data of the TEurogamData object + m_Event->Clear(); + + ////////////////////////////////////////////////////////////////////////////////////// + //////////////////////// Used to Read Event Map of detector ////////////////////////// + ////////////////////////////////////////////////////////////////////////////////////// + std::map<G4int, G4int*>::iterator DetectorNumber_itr; + std::map<G4int, G4double*>::iterator Energy_itr; + std::map<G4int, G4double*>::iterator Time_itr; + std::map<G4int, G4double*>::iterator Pos_X_itr; + std::map<G4int, G4double*>::iterator Pos_Y_itr; + std::map<G4int, G4double*>::iterator Pos_Z_itr; + std::map<G4int, G4double*>::iterator Ang_Theta_itr; + std::map<G4int, G4double*>::iterator Ang_Phi_itr; + + NPS::HitsMap<G4int>* DetectorNumberHitMap; + NPS::HitsMap<G4double>* EnergyHitMap; + NPS::HitsMap<G4double>* TimeHitMap; + NPS::HitsMap<G4double>* PosXHitMap; + NPS::HitsMap<G4double>* PosYHitMap; + NPS::HitsMap<G4double>* PosZHitMap; + NPS::HitsMap<G4double>* AngThetaHitMap; + NPS::HitsMap<G4double>* AngPhiHitMap; + + // Read the Scorer associate to the Silicon Strip + // Detector Number + G4int DetCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("EurogamScorer/DetectorNumber"); + DetectorNumberHitMap = (NPS::HitsMap<G4int>*)(event->GetHCofThisEvent()->GetHC(DetCollectionID)); + DetectorNumber_itr = DetectorNumberHitMap->GetMap()->begin(); + + // Energy + G4int EnergyCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("EurogamScorer/Energy"); + EnergyHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(EnergyCollectionID)); + Energy_itr = EnergyHitMap->GetMap()->begin(); + + // Time of Flight + G4int TimeCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("EurogamScorer/Time"); + TimeHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(TimeCollectionID)); + Time_itr = TimeHitMap->GetMap()->begin(); + + // Interaction Coordinate X + G4int InterCoordXCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("EurogamScorer/InterCoordX"); + PosXHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordXCollectionID)); + Pos_X_itr = PosXHitMap->GetMap()->begin(); + + // Interaction Coordinate Y + G4int InterCoordYCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("EurogamScorer/InterCoordY"); + PosYHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordYCollectionID)); + Pos_Y_itr = PosYHitMap->GetMap()->begin(); + + // Interaction Coordinate Z + G4int InterCoordZCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("EurogamScorer/InterCoordZ"); + PosZHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordZCollectionID)); + Pos_Z_itr = PosXHitMap->GetMap()->begin(); + + // Interaction Coordinate Angle Theta + G4int InterCoordAngThetaCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("EurogamScorer/InterCoordAngTheta"); + AngThetaHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordAngThetaCollectionID)); + Ang_Theta_itr = AngThetaHitMap->GetMap()->begin(); + + // Interaction Coordinate Angle Phi + G4int InterCoordAngPhiCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("EurogamScorer/InterCoordAngPhi"); + AngPhiHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordAngPhiCollectionID)); + Ang_Phi_itr = AngPhiHitMap->GetMap()->begin(); + + // Check the size of different map + G4int sizeN = DetectorNumberHitMap->entries(); + G4int sizeE = EnergyHitMap->entries(); + G4int sizeT = TimeHitMap->entries(); + G4int sizeX = PosXHitMap->entries(); + + /* if (sizeN != sizeE || sizeE != sizeT) { + G4cout << "No match size Eurogam Event Map: sE:" << sizeE << " sT:" << sizeT << G4endl; + return; + }*/ + G4cout << "*******SIZE********: " << sizeN << " " << sizeE << " " << sizeT << " " << sizeX << G4endl; + + G4double Etot = 0; + + // Loop on detector number + for (G4int l = 0; l < sizeN; l++) { + G4double N = *(DetectorNumber_itr->second); + G4int NTrackID = DetectorNumber_itr->first - N; + G4cout << "NTrackID: " << NTrackID << " " << N << G4endl; + + if (N > 0) { + // Fill detector number + m_Event->SetEurogamDetectorNumber(N); + + // Energy + Energy_itr = EnergyHitMap->GetMap()->begin(); + for (G4int ll = 0; ll < sizeE; ll++) { + G4int ETrackID = Energy_itr->first - N; + G4double E = *(Energy_itr->second); + G4cout << "ETrackID, E: " << ETrackID << " " << E << G4endl; + if (ETrackID == NTrackID) { + Etot += E; + // m_Event->SetEurogamEnergy(RandGauss::shoot(E, 1)); + // Fill energy loss for each step + // m_Event->SetEurogamEnergy(E*1e3); + } + 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->SetEurogamTime(RandGauss::shoot(T, 1)); + } + Time_itr++; } - DetectorNumber_itr++; - } - - // Fill total energy here - if (Etot > 0) m_Event->SetEurogamEnergy(RandGauss::shoot(Etot*1e3, 1)); - - // clear map for next event - DetectorNumberHitMap -> clear(); - EnergyHitMap -> clear(); - TimeHitMap -> clear(); - PosXHitMap -> clear(); - PosYHitMap -> clear(); - PosZHitMap -> clear(); - AngThetaHitMap -> clear(); - AngPhiHitMap -> clear(); -} + // Pos X + Pos_X_itr = PosXHitMap->GetMap()->begin(); + for (G4int h = 0; h < PosXHitMap->entries(); h++) { + G4int PosXTrackID = Pos_X_itr->first - N; + G4double PosX = *(Pos_X_itr->second); + if (PosXTrackID == NTrackID) { + ms_InterCoord->SetDetectedPositionX(PosX); + } + Pos_X_itr++; + } + // Pos Y + Pos_Y_itr = PosYHitMap->GetMap()->begin(); + for (G4int h = 0; h < PosYHitMap->entries(); h++) { + G4int PosYTrackID = Pos_Y_itr->first - N; + G4double PosY = *(Pos_Y_itr->second); + if (PosYTrackID == NTrackID) { + ms_InterCoord->SetDetectedPositionY(PosY); + } + Pos_Y_itr++; + } -//////////////////////////////////////////////////////////////// -void Eurogam::InitializeMaterial() -{ - m_Material_Vacuum = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); - m_Material_Aluminium = MaterialManager::getInstance()->GetMaterialFromLibrary("Al"); - m_Material_Silicon = MaterialManager::getInstance()->GetMaterialFromLibrary("Si"); - m_Material_Germanium = MaterialManager::getInstance()->GetMaterialFromLibrary("Ge"); -} + // Pos Z + Pos_Z_itr = PosZHitMap->GetMap()->begin(); + for (G4int h = 0; h < PosZHitMap->entries(); h++) { + G4int PosZTrackID = Pos_Z_itr->first - N; + G4double PosZ = *(Pos_Z_itr->second); + if (PosZTrackID == NTrackID) { + ms_InterCoord->SetDetectedPositionZ(PosZ); + } + Pos_Z_itr++; + } + // Angle Theta + Ang_Theta_itr = AngThetaHitMap->GetMap()->begin(); + for (G4int h = 0; h < AngThetaHitMap->entries(); h++) { + G4int AngThetaTrackID = Ang_Theta_itr->first - N; + G4double AngTheta = *(Ang_Theta_itr->second); + if (AngThetaTrackID == NTrackID) { + ms_InterCoord->SetDetectedAngleTheta(AngTheta); + } + Ang_Theta_itr++; + } + // Angle Phi + Ang_Phi_itr = AngPhiHitMap->GetMap()->begin(); + for (G4int h = 0; h < AngPhiHitMap->entries(); h++) { + G4int AngPhiTrackID = Ang_Phi_itr->first - N; + G4double AngPhi = *(Ang_Phi_itr->second); + if (AngPhiTrackID == NTrackID) { + ms_InterCoord->SetDetectedAnglePhi(AngPhi); + } + Ang_Phi_itr++; + } + } + DetectorNumber_itr++; + } -//////////////////////////////////////////////////////////////// -void Eurogam::InitializeScorers() -{ - bool already_exist = false; - // Eurogam associated scorer - m_EurogamScorer = CheckScorer("EurogamScorer",already_exist); - if(already_exist) return; - - G4VPrimitiveScorer* DetNbr = new OBSOLETEGENERALSCORERS::PSDetectorNumber("DetectorNumber", "Eurogam", 0); - G4VPrimitiveScorer* Energy = new OBSOLETEGENERALSCORERS::PSEnergy("Energy","Eurogam", 0); - G4VPrimitiveScorer* TOF = new OBSOLETEGENERALSCORERS::PSTOF("Time", "Eurogam", 0); - G4VPrimitiveScorer* InteractionCoordinatesX = new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesX("InterCoordX", "Eurogam", 0); - G4VPrimitiveScorer* InteractionCoordinatesY = new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesY("InterCoordY", "Eurogam", 0); - G4VPrimitiveScorer* InteractionCoordinatesZ = new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesZ("InterCoordZ", "Eurogam", 0); - G4VPrimitiveScorer* InteractionCoordinatesAngleTheta = new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesAngleTheta("InterCoordAngTheta", "Eurogam", 0); - G4VPrimitiveScorer* InteractionCoordinatesAnglePhi = new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesAnglePhi("InterCoordAngPhi", "Eurogam", 0); - - //and register it to the multifunctionnal detector - m_EurogamScorer->RegisterPrimitive(DetNbr); - m_EurogamScorer->RegisterPrimitive(Energy); - m_EurogamScorer->RegisterPrimitive(TOF); - m_EurogamScorer->RegisterPrimitive(InteractionCoordinatesX); - m_EurogamScorer->RegisterPrimitive(InteractionCoordinatesY); - m_EurogamScorer->RegisterPrimitive(InteractionCoordinatesZ); - m_EurogamScorer->RegisterPrimitive(InteractionCoordinatesAngleTheta); - m_EurogamScorer->RegisterPrimitive(InteractionCoordinatesAnglePhi); - - // Add All Scorer to the Global Scorer Manager - G4SDManager::GetSDMpointer()->AddNewDetector(m_EurogamScorer); + // Fill total energy here + if (Etot > 0) + m_Event->SetEurogamEnergy(RandGauss::shoot(Etot * 1e3, 1)); + + // clear map for next event + DetectorNumberHitMap->clear(); + EnergyHitMap->clear(); + TimeHitMap->clear(); + PosXHitMap->clear(); + PosYHitMap->clear(); + PosZHitMap->clear(); + AngThetaHitMap->clear(); + AngPhiHitMap->clear(); } - //////////////////////////////////////////////////////////////////////////////// - // Construct Method to be pass to the DetectorFactory // - //////////////////////////////////////////////////////////////////////////////// - NPS::VDetector* Eurogam::Construct(){ - return (NPS::VDetector*) new Eurogam(); - } - - //////////////////////////////////////////////////////////////////////////////// - // Registering the construct method to the factory // - //////////////////////////////////////////////////////////////////////////////// - extern"C" { - class proxy_nps_eurogam{ - public: - proxy_nps_eurogam(){ - NPS::DetectorFactory::getInstance()->AddToken("Eurogam","Eurogam"); - NPS::DetectorFactory::getInstance()->AddDetector("Eurogam",Eurogam::Construct); - } + +//////////////////////////////////////////////////////////////// +void Eurogam::InitializeMaterial() { + m_Material_Vacuum = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); + m_Material_Aluminium = MaterialManager::getInstance()->GetMaterialFromLibrary("Al"); + m_Material_Silicon = MaterialManager::getInstance()->GetMaterialFromLibrary("Si"); + m_Material_Germanium = MaterialManager::getInstance()->GetMaterialFromLibrary("Ge"); +} + +//////////////////////////////////////////////////////////////// +void Eurogam::InitializeScorers() { + bool already_exist = false; + // Eurogam associated scorer + m_EurogamScorer = CheckScorer("EurogamScorer", already_exist); + if (already_exist) + return; + + G4VPrimitiveScorer* DetNbr = new OBSOLETEGENERALSCORERS::PSDetectorNumber("DetectorNumber", "Eurogam", 0); + G4VPrimitiveScorer* Energy = new OBSOLETEGENERALSCORERS::PSEnergy("Energy", "Eurogam", 0); + G4VPrimitiveScorer* TOF = new OBSOLETEGENERALSCORERS::PSTOF("Time", "Eurogam", 0); + G4VPrimitiveScorer* InteractionCoordinatesX = + new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesX("InterCoordX", "Eurogam", 0); + G4VPrimitiveScorer* InteractionCoordinatesY = + new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesY("InterCoordY", "Eurogam", 0); + G4VPrimitiveScorer* InteractionCoordinatesZ = + new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesZ("InterCoordZ", "Eurogam", 0); + G4VPrimitiveScorer* InteractionCoordinatesAngleTheta = + new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesAngleTheta("InterCoordAngTheta", "Eurogam", 0); + G4VPrimitiveScorer* InteractionCoordinatesAnglePhi = + new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesAnglePhi("InterCoordAngPhi", "Eurogam", 0); + + // and register it to the multifunctionnal detector + m_EurogamScorer->RegisterPrimitive(DetNbr); + m_EurogamScorer->RegisterPrimitive(Energy); + m_EurogamScorer->RegisterPrimitive(TOF); + m_EurogamScorer->RegisterPrimitive(InteractionCoordinatesX); + m_EurogamScorer->RegisterPrimitive(InteractionCoordinatesY); + m_EurogamScorer->RegisterPrimitive(InteractionCoordinatesZ); + m_EurogamScorer->RegisterPrimitive(InteractionCoordinatesAngleTheta); + m_EurogamScorer->RegisterPrimitive(InteractionCoordinatesAnglePhi); + + // Add All Scorer to the Global Scorer Manager + G4SDManager::GetSDMpointer()->AddNewDetector(m_EurogamScorer); +} +//////////////////////////////////////////////////////////////////////////////// +// Construct Method to be pass to the DetectorFactory // +//////////////////////////////////////////////////////////////////////////////// +NPS::VDetector* Eurogam::Construct() { return (NPS::VDetector*)new Eurogam(); } + +//////////////////////////////////////////////////////////////////////////////// +// Registering the construct method to the factory // +//////////////////////////////////////////////////////////////////////////////// +extern "C" { +class proxy_nps_eurogam { + public: + proxy_nps_eurogam() { + NPS::DetectorFactory::getInstance()->AddToken("Eurogam", "Eurogam"); + NPS::DetectorFactory::getInstance()->AddDetector("Eurogam", Eurogam::Construct); + } }; - proxy_nps_eurogam p_nps_eurogam; - } +proxy_nps_eurogam p_nps_eurogam; +} diff --git a/NPSimulation/Detectors/Exogam/Exogam.cc b/NPSimulation/Detectors/Exogam/Exogam.cc index 698523717185af5b9b422784cf7dd5bd96af0a06..666fdab2dc4efe97ead4e47d18b0e36c47599e6d 100644 --- a/NPSimulation/Detectors/Exogam/Exogam.cc +++ b/NPSimulation/Detectors/Exogam/Exogam.cc @@ -20,96 +20,93 @@ *****************************************************************************/ // C++ headers -#include <sstream> #include <cmath> #include <limits> -//G4 Geometry object -#include "G4Tubs.hh" +#include <sstream> +// G4 Geometry object #include "G4Box.hh" #include "G4Cons.hh" -#include "G4Trap.hh" -#include "G4Trd.hh" -#include "G4Para.hh" -#include "G4Polyhedra.hh" -#include "G4Polycone.hh" #include "G4LogicalVolume.hh" -#include "G4ThreeVector.hh" #include "G4PVPlacement.hh" +#include "G4Para.hh" +#include "G4Polycone.hh" +#include "G4Polyhedra.hh" #include "G4RotationMatrix.hh" +#include "G4ThreeVector.hh" #include "G4Transform3D.hh" +#include "G4Trap.hh" +#include "G4Trd.hh" +#include "G4Tubs.hh" #include "G4PVReplica.hh" #include "G4SubtractionSolid.hh" #include "G4UnionSolid.hh" -//G4 sensitive -#include "G4SDManager.hh" +// G4 sensitive #include "G4MultiFunctionalDetector.hh" +#include "G4SDManager.hh" -//G4 various object +// G4 various object +#include "G4Colour.hh" #include "G4Material.hh" -#include "G4Transform3D.hh" #include "G4PVPlacement.hh" +#include "G4Transform3D.hh" #include "G4VisAttributes.hh" -#include "G4Colour.hh" // NPTool header -#include "Exogam.hh" #include "CalorimeterScorers.hh" -#include "RootOutput.h" +#include "Exogam.hh" #include "MaterialManager.hh" -#include "NPSDetectorFactory.hh" #include "NPOptionManager.h" +#include "NPSDetectorFactory.hh" #include "NPSHitsMap.hh" +#include "RootOutput.h" // CLHEP header #include "CLHEP/Random/RandGauss.h" using namespace std; using namespace CLHEP; - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -namespace Exogam_NS{ +namespace Exogam_NS { // Energy and time Resolution - const double EnergyThreshold = 10*keV; - //const double ResoTime = 4.5*ns ; //not used - const double ResoEnergy = 2.*keV ; -} + const double EnergyThreshold = 10 * keV; + // const double ResoTime = 4.5*ns ; //not used + const double ResoEnergy = 2. * keV; +} // namespace Exogam_NS //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Exogam Specific Method -Exogam::Exogam(){ - m_Event = new TExogamData() ; +Exogam::Exogam() { + m_Event = new TExogamData(); m_ExogamScorer = 0; - + InitializeMaterials(); - HalfLengthCan = 7.35*cm; - TaperLengthCan = 4.325*cm; - distCollimatorToBGOSShield = 2.95*cm; + HalfLengthCan = 7.35 * cm; + TaperLengthCan = 4.325 * cm; + distCollimatorToBGOSShield = 2.95 * cm; - rm90.rotateZ(90.*deg); - rm90m.rotateZ(-90.*deg); - rm180.rotateZ(180.*deg); - rm270.rotateZ(270.*deg); + rm90.rotateZ(90. * deg); + rm90m.rotateZ(-90. * deg); + rm180.rotateZ(180. * deg); + rm270.rotateZ(270. * deg); } -Exogam::~Exogam(){ -} +Exogam::~Exogam() {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -G4int Exogam::InitializeMaterials() -{ +G4int Exogam::InitializeMaterials() { m_Vacuum = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); m_Aluminum = MaterialManager::getInstance()->GetMaterialFromLibrary("Al"); m_Copper = MaterialManager::getInstance()->GetMaterialFromLibrary("Cu"); m_Germanium = MaterialManager::getInstance()->GetMaterialFromLibrary("Ge"); - m_BGO = new G4Material("BGO", 7.13*g/cm3, 3, kStateSolid); //BGO does not exist in nptool !! - m_BGO->AddElement(MaterialManager::getInstance()->GetElementFromLibrary("Bi"),4); - m_BGO->AddElement(MaterialManager::getInstance()->GetElementFromLibrary("Ge"),3); - m_BGO->AddElement(MaterialManager::getInstance()->GetElementFromLibrary("O"),12); + m_BGO = new G4Material("BGO", 7.13 * g / cm3, 3, kStateSolid); // BGO does not exist in nptool !! + m_BGO->AddElement(MaterialManager::getInstance()->GetElementFromLibrary("Bi"), 4); + m_BGO->AddElement(MaterialManager::getInstance()->GetElementFromLibrary("Ge"), 3); + m_BGO->AddElement(MaterialManager::getInstance()->GetElementFromLibrary("O"), 12); m_CsI = MaterialManager::getInstance()->GetMaterialFromLibrary("CsI"); @@ -117,34 +114,32 @@ G4int Exogam::InitializeMaterials() } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Exogam::BuildClover(int i_clo, G4LogicalVolume* world) -{ - // enveloppe of the whole Clover (i.e. suppressed Clover) called 'SupClover' including: +void Exogam::BuildClover(int i_clo, G4LogicalVolume* world) { + // enveloppe of the whole Clover (i.e. suppressed Clover) called 'SupClover' including: // the cryostat, dewar, side shield, back catcher, collimator - G4double dzEnv = 40.472*cm; - G4double dx1Env = 3.17*cm; - G4double dy1Env = 3.17*cm; - G4double dx2Env = 2.*dzEnv*tan(22.5*deg)+dx1Env; - G4double dy2Env = 2.*dzEnv*tan(22.5*deg)+dy1Env; + G4double dzEnv = 40.472 * cm; + G4double dx1Env = 3.17 * cm; + G4double dy1Env = 3.17 * cm; + G4double dx2Env = 2. * dzEnv * tan(22.5 * deg) + dx1Env; + G4double dy2Env = 2. * dzEnv * tan(22.5 * deg) + dy1Env; - G4Trd* solidSupClover = new G4Trd("SupClover",dx1Env,dx2Env,dy1Env,dy2Env,dzEnv); - G4LogicalVolume * logicSupClover = new G4LogicalVolume(solidSupClover,m_Vacuum,"SupClover"); + G4Trd* solidSupClover = new G4Trd("SupClover", dx1Env, dx2Env, dy1Env, dy2Env, dzEnv); + G4LogicalVolume* logicSupClover = new G4LogicalVolume(solidSupClover, m_Vacuum, "SupClover"); - Offset=dzEnv;//-distCollimatorToGeCan; + Offset = dzEnv; //-distCollimatorToGeCan; G4RotationMatrix rm; - rm.rotateX(m_ThetaX[i_clo]/rad).rotateY(m_ThetaY[i_clo]/rad).rotateZ(m_ThetaZ[i_clo]/rad); + rm.rotateX(m_ThetaX[i_clo] / rad).rotateY(m_ThetaY[i_clo] / rad).rotateZ(m_ThetaZ[i_clo] / rad); - new G4PVPlacement(G4Transform3D(rm, - G4ThreeVector(m_X[i_clo]*mm, m_Y[i_clo]*mm, m_Z[i_clo]*mm+Offset)), - logicSupClover,"Clover",world,false,i_clo+1,false); //this void overlaps the whole setup + new G4PVPlacement(G4Transform3D(rm, G4ThreeVector(m_X[i_clo] * mm, m_Y[i_clo] * mm, m_Z[i_clo] * mm + Offset)), + logicSupClover, "Clover", world, false, i_clo + 1, false); // this void overlaps the whole setup // The Cryostat //////////////// // The Aluminum Clover can ( "CloverCan" )... // - G4double PhiStartCan = 45.*deg; - G4double PhiTotCan = 360.*deg; + G4double PhiStartCan = 45. * deg; + G4double PhiTotCan = 360. * deg; G4double zPlaneCan[3]; G4double rInnerCan[3]; @@ -154,395 +149,381 @@ void Exogam::BuildClover(int i_clo, G4LogicalVolume* world) G4double rOuterVac[3]; zPlaneCan[0] = -HalfLengthCan; - zPlaneCan[1] = -HalfLengthCan+TaperLengthCan; - zPlaneCan[2] = HalfLengthCan; + zPlaneCan[1] = -HalfLengthCan + TaperLengthCan; + zPlaneCan[2] = HalfLengthCan; - G4double rOuterCan[3]; // used to build the shield - rOuterCan[0] = 4.4085*cm; - rOuterCan[1] = 6.2*cm; - rOuterCan[2] = 6.2*cm; + G4double rOuterCan[3]; // used to build the shield + rOuterCan[0] = 4.4085 * cm; + rOuterCan[1] = 6.2 * cm; + rOuterCan[2] = 6.2 * cm; - rInnerCan[0] = rInnerCan[1] = rInnerCan[2] = 0.*cm; + rInnerCan[0] = rInnerCan[1] = rInnerCan[2] = 0. * cm; - G4Polyhedra* solidCloverCan = new G4Polyhedra("CloverCan",PhiStartCan,PhiTotCan,4,3, - zPlaneCan,rInnerCan,rOuterCan); + G4Polyhedra* solidCloverCan = + new G4Polyhedra("CloverCan", PhiStartCan, PhiTotCan, 4, 3, zPlaneCan, rInnerCan, rOuterCan); - G4LogicalVolume* logicCloverCan = new G4LogicalVolume(solidCloverCan,m_Aluminum,"CloverCan"); + G4LogicalVolume* logicCloverCan = new G4LogicalVolume(solidCloverCan, m_Aluminum, "CloverCan"); // The position of the Clover can in the SupClover: -G4ThreeVector posClover(0.*cm,0.*cm,-Offset+HalfLengthCan+0.001*mm); //+0.001mm to avoid roundoff errors - -new G4PVPlacement(0,posClover, logicCloverCan,"CloverCan",logicSupClover,false,i_clo+1,true); //There is an overlap with vacuum SupClover + G4ThreeVector posClover(0. * cm, 0. * cm, -Offset + HalfLengthCan + 0.001 * mm); //+0.001mm to avoid roundoff errors -// The vacuum clover ( "Vac" ) ... -// -G4double HalfLengthVac = 7.175*cm; -G4double TaperLengthVac = 4.0842*cm; + new G4PVPlacement(0, posClover, logicCloverCan, "CloverCan", logicSupClover, false, i_clo + 1, + true); // There is an overlap with vacuum SupClover -zPlaneVac[0] = -HalfLengthVac; -zPlaneVac[1] = -HalfLengthVac+TaperLengthVac; -zPlaneVac[2] = HalfLengthVac; -rOuterVac[0] = 4.3083*cm; -rOuterVac[1] = 6.0*cm; -rOuterVac[2] = 6.0*cm; + // The vacuum clover ( "Vac" ) ... + // + G4double HalfLengthVac = 7.175 * cm; + G4double TaperLengthVac = 4.0842 * cm; -rInnerVac[0] = rInnerVac[1] = rInnerVac[2] = 0.*cm; + zPlaneVac[0] = -HalfLengthVac; + zPlaneVac[1] = -HalfLengthVac + TaperLengthVac; + zPlaneVac[2] = HalfLengthVac; + rOuterVac[0] = 4.3083 * cm; + rOuterVac[1] = 6.0 * cm; + rOuterVac[2] = 6.0 * cm; -G4Polyhedra* solidVac = new G4Polyhedra("Vac",PhiStartCan,PhiTotCan,4,3, - zPlaneVac,rInnerVac,rOuterVac); -G4LogicalVolume * logicVac = new G4LogicalVolume(solidVac,m_Vacuum,"Vac"); + rInnerVac[0] = rInnerVac[1] = rInnerVac[2] = 0. * cm; -G4ThreeVector positionVac = G4ThreeVector(0.*cm,0.*cm,-0.25*mm); -new G4PVPlacement(0,positionVac, logicVac,"Vac",logicCloverCan,false,i_clo+1,true); + G4Polyhedra* solidVac = new G4Polyhedra("Vac", PhiStartCan, PhiTotCan, 4, 3, zPlaneVac, rInnerVac, rOuterVac); + G4LogicalVolume* logicVac = new G4LogicalVolume(solidVac, m_Vacuum, "Vac"); + G4ThreeVector positionVac = G4ThreeVector(0. * cm, 0. * cm, -0.25 * mm); + new G4PVPlacement(0, positionVac, logicVac, "Vac", logicCloverCan, false, i_clo + 1, true); -// -// The enveloppe of the cold finger from the back side of the can to the Dewar -// + // + // The enveloppe of the cold finger from the back side of the can to the Dewar + // -G4double zPlaneEnvColdFinger[6]; -G4double rInnerEnvColdFinger[6]; -G4double rOuterEnvColdFinger[6]; + G4double zPlaneEnvColdFinger[6]; + G4double rInnerEnvColdFinger[6]; + G4double rOuterEnvColdFinger[6]; -G4double PhiStart = 0.*deg; -G4double PhiTot = 360.*deg; -G4double EnvColdFingerHalfLength = 7.24*cm; + G4double PhiStart = 0. * deg; + G4double PhiTot = 360. * deg; + G4double EnvColdFingerHalfLength = 7.24 * cm; -zPlaneEnvColdFinger[0] = -EnvColdFingerHalfLength; -zPlaneEnvColdFinger[1] = -EnvColdFingerHalfLength+4.1*cm; -zPlaneEnvColdFinger[2] = -EnvColdFingerHalfLength+4.1*cm; -zPlaneEnvColdFinger[3] = -EnvColdFingerHalfLength+4.9*cm; -zPlaneEnvColdFinger[4] = -EnvColdFingerHalfLength+4.9*cm; -zPlaneEnvColdFinger[5] = EnvColdFingerHalfLength; + zPlaneEnvColdFinger[0] = -EnvColdFingerHalfLength; + zPlaneEnvColdFinger[1] = -EnvColdFingerHalfLength + 4.1 * cm; + zPlaneEnvColdFinger[2] = -EnvColdFingerHalfLength + 4.1 * cm; + zPlaneEnvColdFinger[3] = -EnvColdFingerHalfLength + 4.9 * cm; + zPlaneEnvColdFinger[4] = -EnvColdFingerHalfLength + 4.9 * cm; + zPlaneEnvColdFinger[5] = EnvColdFingerHalfLength; -rInnerEnvColdFinger[0]=rInnerEnvColdFinger[1]=rInnerEnvColdFinger[2]=0.*cm; -rInnerEnvColdFinger[3]=rInnerEnvColdFinger[4]=rInnerEnvColdFinger[5]=0.*cm; + rInnerEnvColdFinger[0] = rInnerEnvColdFinger[1] = rInnerEnvColdFinger[2] = 0. * cm; + rInnerEnvColdFinger[3] = rInnerEnvColdFinger[4] = rInnerEnvColdFinger[5] = 0. * cm; -rOuterEnvColdFinger[0]=2.225*cm; -rOuterEnvColdFinger[1]=2.225*cm; -rOuterEnvColdFinger[2]=3.1*cm; -rOuterEnvColdFinger[3]=3.1*cm; -rOuterEnvColdFinger[4]=2.225*cm; -rOuterEnvColdFinger[5]=2.225*cm; + rOuterEnvColdFinger[0] = 2.225 * cm; + rOuterEnvColdFinger[1] = 2.225 * cm; + rOuterEnvColdFinger[2] = 3.1 * cm; + rOuterEnvColdFinger[3] = 3.1 * cm; + rOuterEnvColdFinger[4] = 2.225 * cm; + rOuterEnvColdFinger[5] = 2.225 * cm; -G4Polycone* solidEnvColdFinger = new G4Polycone("EnvColdFinger",PhiStart,PhiTot,6, - zPlaneEnvColdFinger,rInnerEnvColdFinger,rOuterEnvColdFinger); + G4Polycone* solidEnvColdFinger = new G4Polycone("EnvColdFinger", PhiStart, PhiTot, 6, zPlaneEnvColdFinger, + rInnerEnvColdFinger, rOuterEnvColdFinger); -G4LogicalVolume* logicEnvColdFinger = new G4LogicalVolume(solidEnvColdFinger,m_Aluminum,"EnvColdFinger"); + G4LogicalVolume* logicEnvColdFinger = new G4LogicalVolume(solidEnvColdFinger, m_Aluminum, "EnvColdFinger"); -G4ThreeVector posEnvColdFinger = - G4ThreeVector(0.*cm,0.*cm,-Offset+2.*HalfLengthCan+EnvColdFingerHalfLength+0.005*mm); + G4ThreeVector posEnvColdFinger = + G4ThreeVector(0. * cm, 0. * cm, -Offset + 2. * HalfLengthCan + EnvColdFingerHalfLength + 0.005 * mm); - new G4PVPlacement(0,posEnvColdFinger,logicEnvColdFinger,"EnvColdFinger",logicSupClover,false,i_clo+1,true); + new G4PVPlacement(0, posEnvColdFinger, logicEnvColdFinger, "EnvColdFinger", logicSupClover, false, i_clo + 1, true); // Its internal vacuum... - G4double minRadiusIntEnvColdFinger = 0.*cm; - G4double maxRadiusIntEnvColdFinger = 2.025*cm; - G4double HalfLengthIntEnvColdFinger = 7.24*cm; - G4double startPhiIntEnvColdFinger = 0.*deg; - G4double deltaPhiIntEnvColdFinger = 360.*deg; + G4double minRadiusIntEnvColdFinger = 0. * cm; + G4double maxRadiusIntEnvColdFinger = 2.025 * cm; + G4double HalfLengthIntEnvColdFinger = 7.24 * cm; + G4double startPhiIntEnvColdFinger = 0. * deg; + G4double deltaPhiIntEnvColdFinger = 360. * deg; - G4Tubs* solidIntEnvColdFinger = new G4Tubs("IntDewar",minRadiusIntEnvColdFinger,maxRadiusIntEnvColdFinger, - HalfLengthIntEnvColdFinger,startPhiIntEnvColdFinger,deltaPhiIntEnvColdFinger); + G4Tubs* solidIntEnvColdFinger = + new G4Tubs("IntDewar", minRadiusIntEnvColdFinger, maxRadiusIntEnvColdFinger, HalfLengthIntEnvColdFinger, + startPhiIntEnvColdFinger, deltaPhiIntEnvColdFinger); - G4LogicalVolume* logicIntEnvColdFinger = new G4LogicalVolume(solidIntEnvColdFinger,m_Vacuum,"IntEnvColdFinger"); + G4LogicalVolume* logicIntEnvColdFinger = new G4LogicalVolume(solidIntEnvColdFinger, m_Vacuum, "IntEnvColdFinger"); // and its position in the cold finger enveloppe. - new G4PVPlacement(0,G4ThreeVector(0.,0.,0.),logicIntEnvColdFinger,"IntEnvColdFinger",logicEnvColdFinger,false,i_clo+1,true); + new G4PVPlacement(0, G4ThreeVector(0., 0., 0.), logicIntEnvColdFinger, "IntEnvColdFinger", logicEnvColdFinger, false, + i_clo + 1, true); - // The cold finger and the associated plate // - G4double xHalfLengthCFPlate = 5.04*cm; - G4double yHalfLengthCFPlate = 5.04*cm; - G4double zHalfLengthCFPlate = 1.*mm; + G4double xHalfLengthCFPlate = 5.04 * cm; + G4double yHalfLengthCFPlate = 5.04 * cm; + G4double zHalfLengthCFPlate = 1. * mm; - G4Box* solidCFPlate = new G4Box("CFPlate",xHalfLengthCFPlate,yHalfLengthCFPlate, - zHalfLengthCFPlate); + G4Box* solidCFPlate = new G4Box("CFPlate", xHalfLengthCFPlate, yHalfLengthCFPlate, zHalfLengthCFPlate); - G4LogicalVolume* logicCFPlate = new G4LogicalVolume(solidCFPlate,m_Copper,"CFPlate"); + G4LogicalVolume* logicCFPlate = new G4LogicalVolume(solidCFPlate, m_Copper, "CFPlate"); - G4ThreeVector posCFPlate(0.*cm,0.*cm,-HalfLengthVac+9.65*cm); // 0.55(d(IntCan-Ge) - // +9.(Ge length)+0.1(half length plate) - new G4PVPlacement(0,posCFPlate,logicCFPlate,"CFPlate",logicVac,false,i_clo+1,true); + G4ThreeVector posCFPlate(0. * cm, 0. * cm, -HalfLengthVac + 9.65 * cm); // 0.55(d(IntCan-Ge) + // +9.(Ge length)+0.1(half length plate) + new G4PVPlacement(0, posCFPlate, logicCFPlate, "CFPlate", logicVac, false, i_clo + 1, true); // The cold finger (internal part) // - G4double minRadiusIntCF = 0.*cm; - G4double maxRadiusIntCF = 1.5*cm; - G4double HalfLengthIntCF = 2.30*cm; - G4double startPhiIntCF = 0.*deg; - G4double deltaPhiIntCF = 360.*deg; + G4double minRadiusIntCF = 0. * cm; + G4double maxRadiusIntCF = 1.5 * cm; + G4double HalfLengthIntCF = 2.30 * cm; + G4double startPhiIntCF = 0. * deg; + G4double deltaPhiIntCF = 360. * deg; - G4Tubs* solidIntCF = new G4Tubs("IntCF",minRadiusIntCF,maxRadiusIntCF, - HalfLengthIntCF,startPhiIntCF,deltaPhiIntCF); + G4Tubs* solidIntCF = + new G4Tubs("IntCF", minRadiusIntCF, maxRadiusIntCF, HalfLengthIntCF, startPhiIntCF, deltaPhiIntCF); - G4LogicalVolume* logicIntCF = - new G4LogicalVolume(solidIntCF,m_Copper,"IntCF"); + G4LogicalVolume* logicIntCF = new G4LogicalVolume(solidIntCF, m_Copper, "IntCF"); // its position vs CloverCan... - G4ThreeVector posIntCF(0.*cm,0.*cm,4.875*cm); // -7.175 (halflengthcan internal) - // +0.55 (ext Can - Ge) - // +9.0 (Ge length) - // +0.2 (CF plate) - // +2.3 (IntCF length) + G4ThreeVector posIntCF(0. * cm, 0. * cm, 4.875 * cm); // -7.175 (halflengthcan internal) + // +0.55 (ext Can - Ge) + // +9.0 (Ge length) + // +0.2 (CF plate) + // +2.3 (IntCF length) - new G4PVPlacement(0,posIntCF,logicIntCF,"IntCF",logicVac,false,i_clo+1,true); + new G4PVPlacement(0, posIntCF, logicIntCF, "IntCF", logicVac, false, i_clo + 1, true); // The cold finger (external part) // - G4double minRadiusExtCF = 0.*cm; - G4double maxRadiusExtCF = 2.0*cm; - G4double HalfLengthExtCF = 7.2*cm; - G4double startPhiExtCF = 0.*deg; - G4double deltaPhiExtCF = 360.*deg; + G4double minRadiusExtCF = 0. * cm; + G4double maxRadiusExtCF = 2.0 * cm; + G4double HalfLengthExtCF = 7.2 * cm; + G4double startPhiExtCF = 0. * deg; + G4double deltaPhiExtCF = 360. * deg; - G4Tubs* solidExtCF = new G4Tubs("IntCF",minRadiusExtCF,maxRadiusExtCF, - HalfLengthExtCF,startPhiExtCF,deltaPhiExtCF); + G4Tubs* solidExtCF = + new G4Tubs("IntCF", minRadiusExtCF, maxRadiusExtCF, HalfLengthExtCF, startPhiExtCF, deltaPhiExtCF); - G4LogicalVolume* logicExtCF = - new G4LogicalVolume(solidExtCF,m_Copper,"ExtCF"); + G4LogicalVolume* logicExtCF = new G4LogicalVolume(solidExtCF, m_Copper, "ExtCF"); // its position vs EnvColdFinger... - G4ThreeVector posExtCF(0.*cm,0.*cm,0.*cm); - new G4PVPlacement(0,posExtCF,logicExtCF,"ExtCF",logicIntEnvColdFinger,false,i_clo+1,true); + G4ThreeVector posExtCF(0. * cm, 0. * cm, 0. * cm); + new G4PVPlacement(0, posExtCF, logicExtCF, "ExtCF", logicIntEnvColdFinger, false, i_clo + 1, true); // The Dewar // - G4double minRadiusDewar = 0.*cm; - G4double maxRadiusDewar = 10.9*cm; - G4double HalfLengthDewar = 15.2*cm; - G4double startPhiDewar = 0.*deg; - G4double deltaPhiDewar = 360.*deg; + G4double minRadiusDewar = 0. * cm; + G4double maxRadiusDewar = 10.9 * cm; + G4double HalfLengthDewar = 15.2 * cm; + G4double startPhiDewar = 0. * deg; + G4double deltaPhiDewar = 360. * deg; - G4Tubs* solidDewar = new G4Tubs("Dewar",minRadiusDewar,maxRadiusDewar, - HalfLengthDewar,startPhiDewar,deltaPhiDewar); + G4Tubs* solidDewar = + new G4Tubs("Dewar", minRadiusDewar, maxRadiusDewar, HalfLengthDewar, startPhiDewar, deltaPhiDewar); - G4LogicalVolume* logicDewar = new G4LogicalVolume(solidDewar,m_Aluminum,"Dewar"); + G4LogicalVolume* logicDewar = new G4LogicalVolume(solidDewar, m_Aluminum, "Dewar"); - G4double distFrontToMidDewar = - -Offset+2.*(HalfLengthCan+EnvColdFingerHalfLength)+HalfLengthDewar+0.01*mm; + G4double distFrontToMidDewar = -Offset + 2. * (HalfLengthCan + EnvColdFingerHalfLength) + HalfLengthDewar + 0.01 * mm; //+0.01mm to avoid roundoff errors - G4ThreeVector posDewar = G4ThreeVector(0.*cm,0.*cm,distFrontToMidDewar); - new G4PVPlacement(0,posDewar,logicDewar,"Dewar",logicSupClover,false,i_clo+1,true); + G4ThreeVector posDewar = G4ThreeVector(0. * cm, 0. * cm, distFrontToMidDewar); + new G4PVPlacement(0, posDewar, logicDewar, "Dewar", logicSupClover, false, i_clo + 1, true); ///////////////////////////////////////// // Construction of the active Ge volume: ///////////////////////////////////////// // A: Ge diode built from cuts subtracted from a cylinder (the "GeDiode") // - G4double minRadiusGeDiode = 0.*cm; - G4double maxRadiusGeDiode = 3.0*cm; - G4double HalfLengthGeDiode = 4.5*cm; - G4double startPhiGeDiode = 0.*deg; - G4double deltaPhiGeDiode = 360.*deg; - - G4Tubs* solidGeDiode = new G4Tubs("GeDiode",minRadiusGeDiode,maxRadiusGeDiode, - HalfLengthGeDiode,startPhiGeDiode,deltaPhiGeDiode); + G4double minRadiusGeDiode = 0. * cm; + G4double maxRadiusGeDiode = 3.0 * cm; + G4double HalfLengthGeDiode = 4.5 * cm; + G4double startPhiGeDiode = 0. * deg; + G4double deltaPhiGeDiode = 360. * deg; + + G4Tubs* solidGeDiode = + new G4Tubs("GeDiode", minRadiusGeDiode, maxRadiusGeDiode, HalfLengthGeDiode, startPhiGeDiode, deltaPhiGeDiode); // // External Tapered volume all along the diode ( "Cut1&2" ) // // // Cut 1 : // - G4double dummy = acos(2.9/3.0); - G4double xHalfLengthCut1 = 0.5*mm; - G4double yHalfLengthCut1 = 2.9*tan(dummy)*cm; - G4double zHalfLengthCut1 = 4.55*cm; + G4double dummy = acos(2.9 / 3.0); + G4double xHalfLengthCut1 = 0.5 * mm; + G4double yHalfLengthCut1 = 2.9 * tan(dummy) * cm; + G4double zHalfLengthCut1 = 4.55 * cm; - G4Box* solidCut1 = new G4Box("Cut1",xHalfLengthCut1,yHalfLengthCut1, - zHalfLengthCut1); + G4Box* solidCut1 = new G4Box("Cut1", xHalfLengthCut1, yHalfLengthCut1, zHalfLengthCut1); // //... and its position vs GeDiode // - G4ThreeVector transCut1(2.95*cm,0.*cm,0.*cm); - G4SubtractionSolid* solidGeMinusCut1 = - new G4SubtractionSolid("GeMinusCut1",solidGeDiode,solidCut1,0,transCut1); + G4ThreeVector transCut1(2.95 * cm, 0. * cm, 0. * cm); + G4SubtractionSolid* solidGeMinusCut1 = new G4SubtractionSolid("GeMinusCut1", solidGeDiode, solidCut1, 0, transCut1); - G4ThreeVector transCut2(0.,2.95*cm,0.); - G4Transform3D positionCut2(rm90,transCut2); + G4ThreeVector transCut2(0., 2.95 * cm, 0.); + G4Transform3D positionCut2(rm90, transCut2); - G4SubtractionSolid* solidGeMinusCut12 = - new G4SubtractionSolid("GeMinusCut12",solidGeMinusCut1,solidCut1,positionCut2); + G4SubtractionSolid* solidGeMinusCut12 = + new G4SubtractionSolid("GeMinusCut12", solidGeMinusCut1, solidCut1, positionCut2); // // External Tapered volume at the front face ( "Cut3&4" ) - G4double cosTap = cos(22.5*deg); - G4double sinTap = sin(22.5*deg); - G4double tanTap = tan(22.5*deg); + G4double cosTap = cos(22.5 * deg); + G4double sinTap = sin(22.5 * deg); + G4double tanTap = tan(22.5 * deg); - G4double xHalfLengthCut3 = 3.0*cm; - G4double yHalfLengthCut3 = 1.5*cm*sinTap; - G4double zHalfLengthCut3 = 1.5*cm/cosTap; + G4double xHalfLengthCut3 = 3.0 * cm; + G4double yHalfLengthCut3 = 1.5 * cm * sinTap; + G4double zHalfLengthCut3 = 1.5 * cm / cosTap; - G4Box* solidCut3 = new G4Box("Cut3",xHalfLengthCut3,yHalfLengthCut3, - zHalfLengthCut3+0.5*cm); - - G4double yCut3 = 2.9*cm-1.5*cm*tanTap+yHalfLengthCut3*cosTap; + G4Box* solidCut3 = new G4Box("Cut3", xHalfLengthCut3, yHalfLengthCut3, zHalfLengthCut3 + 0.5 * cm); - G4double temp = zHalfLengthCut3*cosTap-yHalfLengthCut3*sinTap; - G4double zCut3 = -HalfLengthGeDiode+temp; + G4double yCut3 = 2.9 * cm - 1.5 * cm * tanTap + yHalfLengthCut3 * cosTap; + + G4double temp = zHalfLengthCut3 * cosTap - yHalfLengthCut3 * sinTap; + G4double zCut3 = -HalfLengthGeDiode + temp; G4RotationMatrix rmCut3; - rmCut3.rotateX(-22.5*deg); + rmCut3.rotateX(-22.5 * deg); - G4ThreeVector transCut3(0.,yCut3,zCut3); - G4Transform3D positionCut3(rmCut3,transCut3); + G4ThreeVector transCut3(0., yCut3, zCut3); + G4Transform3D positionCut3(rmCut3, transCut3); - G4SubtractionSolid* solidGeMinusCut123 = - new G4SubtractionSolid("GeMinusCut123",solidGeMinusCut12,solidCut3,positionCut3); + G4SubtractionSolid* solidGeMinusCut123 = + new G4SubtractionSolid("GeMinusCut123", solidGeMinusCut12, solidCut3, positionCut3); - G4Box* solidCut4 = new G4Box("Cut4",yHalfLengthCut3,xHalfLengthCut3, - zHalfLengthCut3); + G4Box* solidCut4 = new G4Box("Cut4", yHalfLengthCut3, xHalfLengthCut3, zHalfLengthCut3); G4RotationMatrix rmCut4; - rmCut4.rotateY(22.5*deg); + rmCut4.rotateY(22.5 * deg); - G4ThreeVector transCut4(yCut3,0.,zCut3); - G4Transform3D positionCut4(rmCut4,transCut4); + G4ThreeVector transCut4(yCut3, 0., zCut3); + G4Transform3D positionCut4(rmCut4, transCut4); - G4SubtractionSolid* solidGeMinusCut1234 = - new G4SubtractionSolid("GeMinusCut1234",solidGeMinusCut123,solidCut4,positionCut4); + G4SubtractionSolid* solidGeMinusCut1234 = + new G4SubtractionSolid("GeMinusCut1234", solidGeMinusCut123, solidCut4, positionCut4); - dummy = acos(2.45/3.0); - G4double xHalfLengthCut5 = 5.5*mm; - G4double yHalfLengthCut5 = 2.45*tan(dummy)*cm; - G4double zHalfLengthCut5 = 4.55*cm; + dummy = acos(2.45 / 3.0); + G4double xHalfLengthCut5 = 5.5 * mm; + G4double yHalfLengthCut5 = 2.45 * tan(dummy) * cm; + G4double zHalfLengthCut5 = 4.55 * cm; - G4Box* solidCut5 = new G4Box("Cut5",xHalfLengthCut5,yHalfLengthCut5, - zHalfLengthCut5); + G4Box* solidCut5 = new G4Box("Cut5", xHalfLengthCut5, yHalfLengthCut5, zHalfLengthCut5); - G4ThreeVector transCut5(-3.0*cm,0.*cm,0.*cm); + G4ThreeVector transCut5(-3.0 * cm, 0. * cm, 0. * cm); - G4SubtractionSolid* solidGeMinusCut12345 = - new G4SubtractionSolid("GeMinusCut12345",solidGeMinusCut1234,solidCut5,0,transCut5); + G4SubtractionSolid* solidGeMinusCut12345 = + new G4SubtractionSolid("GeMinusCut12345", solidGeMinusCut1234, solidCut5, 0, transCut5); - G4ThreeVector transCut6(0.,-3.0*cm,0.); - G4Transform3D positionCut6(rm90,transCut6); + G4ThreeVector transCut6(0., -3.0 * cm, 0.); + G4Transform3D positionCut6(rm90, transCut6); - G4SubtractionSolid* solidGe = - new G4SubtractionSolid("Ge",solidGeMinusCut12345,solidCut5,positionCut6); + G4SubtractionSolid* solidGe = new G4SubtractionSolid("Ge", solidGeMinusCut12345, solidCut5, positionCut6); // Now the individual diode is built; create logical volumes for each of // the four individual diodes A, B, C and D: - G4LogicalVolume * logicGeA = new G4LogicalVolume(solidGe,m_Germanium,"GeA"); - G4LogicalVolume * logicGeB = new G4LogicalVolume(solidGe,m_Germanium,"GeB"); - G4LogicalVolume * logicGeC = new G4LogicalVolume(solidGe,m_Germanium,"GeC"); - G4LogicalVolume * logicGeD = new G4LogicalVolume(solidGe,m_Germanium,"GeD"); + G4LogicalVolume* logicGeA = new G4LogicalVolume(solidGe, m_Germanium, "GeA"); + G4LogicalVolume* logicGeB = new G4LogicalVolume(solidGe, m_Germanium, "GeB"); + G4LogicalVolume* logicGeC = new G4LogicalVolume(solidGe, m_Germanium, "GeC"); + G4LogicalVolume* logicGeD = new G4LogicalVolume(solidGe, m_Germanium, "GeD"); - logicGeA -> SetSensitiveDetector(m_ExogamScorer); - logicGeB -> SetSensitiveDetector(m_ExogamScorer); - logicGeC -> SetSensitiveDetector(m_ExogamScorer); - logicGeD -> SetSensitiveDetector(m_ExogamScorer); + logicGeA->SetSensitiveDetector(m_ExogamScorer); + logicGeB->SetSensitiveDetector(m_ExogamScorer); + logicGeC->SetSensitiveDetector(m_ExogamScorer); + logicGeD->SetSensitiveDetector(m_ExogamScorer); // positioning the tapered partial diodes (A to D) // into the real vacuum of the can - G4double HalfDistanceBetweenDiodes = 0.5*mm; + G4double HalfDistanceBetweenDiodes = 0.5 * mm; - G4double xDumVac = 2.45*cm+HalfDistanceBetweenDiodes; - G4double yDumVac = 2.45*cm+HalfDistanceBetweenDiodes; - G4double zDumVac = -HalfLengthVac+5.05*cm; // 5.05 = 0.55 d(int can to Ge) +4.5(half length Ge) + G4double xDumVac = 2.45 * cm + HalfDistanceBetweenDiodes; + G4double yDumVac = 2.45 * cm + HalfDistanceBetweenDiodes; + G4double zDumVac = -HalfLengthVac + 5.05 * cm; // 5.05 = 0.55 d(int can to Ge) +4.5(half length Ge) - G4ThreeVector positionVacA(xDumVac,yDumVac,zDumVac); + G4ThreeVector positionVacA(xDumVac, yDumVac, zDumVac); - G4ThreeVector posDumVacB(xDumVac,-yDumVac,zDumVac); - G4Transform3D positionVacB(rm270,posDumVacB); + G4ThreeVector posDumVacB(xDumVac, -yDumVac, zDumVac); + G4Transform3D positionVacB(rm270, posDumVacB); - G4ThreeVector posDumVacC(-xDumVac,-yDumVac,zDumVac); - G4Transform3D positionVacC(rm180,posDumVacC); + G4ThreeVector posDumVacC(-xDumVac, -yDumVac, zDumVac); + G4Transform3D positionVacC(rm180, posDumVacC); - G4ThreeVector posDumVacD(-xDumVac,yDumVac,zDumVac); - G4Transform3D positionVacD(rm90,posDumVacD); + G4ThreeVector posDumVacD(-xDumVac, yDumVac, zDumVac); + G4Transform3D positionVacD(rm90, posDumVacD); - new G4PVPlacement(0,positionVacA,logicGeA,"GeA",logicVac,false,1,true); //There is an overlap with vacumm Vac - new G4PVPlacement(positionVacB,logicGeB,"GeB",logicVac,false,2,true); - new G4PVPlacement(positionVacC,logicGeC,"GeC",logicVac,false,3,true); - new G4PVPlacement(positionVacD,logicGeD,"GeD",logicVac, false,4, true); + new G4PVPlacement(0, positionVacA, logicGeA, "GeA", logicVac, false, 1, true); // There is an overlap with vacumm Vac + new G4PVPlacement(positionVacB, logicGeB, "GeB", logicVac, false, 2, true); + new G4PVPlacement(positionVacC, logicGeC, "GeC", logicVac, false, 3, true); + new G4PVPlacement(positionVacD, logicGeD, "GeD", logicVac, false, 4, true); // // some material between the diodes to reproduce the experimental addback factor ... // - G4double xAbsorb1 = 4.16*cm; - G4double yAbsorb1 = 200.*um; // max = HalfDistanceBetweenDiodes = 0.5*mm; - G4double zAbsorb1 = 4.5*cm; + G4double xAbsorb1 = 4.16 * cm; + G4double yAbsorb1 = 200. * um; // max = HalfDistanceBetweenDiodes = 0.5*mm; + G4double zAbsorb1 = 4.5 * cm; - G4Box* solidAbsorb1 = new G4Box("Absorb1",xAbsorb1,yAbsorb1,zAbsorb1); + G4Box* solidAbsorb1 = new G4Box("Absorb1", xAbsorb1, yAbsorb1, zAbsorb1); - G4double xAbsorb2 = 200*um; // max = HalfDistanceBetweenDiodes = 0.5*mm; - G4double yAbsorb2 = 4.16*cm; - G4double zAbsorb2 = 4.5*cm; + G4double xAbsorb2 = 200 * um; // max = HalfDistanceBetweenDiodes = 0.5*mm; + G4double yAbsorb2 = 4.16 * cm; + G4double zAbsorb2 = 4.5 * cm; - G4Box* solidAbsorb2 = new G4Box("Absorb2",xAbsorb2,yAbsorb2,zAbsorb2); + G4Box* solidAbsorb2 = new G4Box("Absorb2", xAbsorb2, yAbsorb2, zAbsorb2); - //G4UnionSolid* solidAbsorb = - //new G4UnionSolid("Absorb",solidAbsorb1,solidAbsorb2,0,0); - G4UnionSolid* solidAbsorb = - new G4UnionSolid("Absorb",solidAbsorb1,solidAbsorb2); + // G4UnionSolid* solidAbsorb = + // new G4UnionSolid("Absorb",solidAbsorb1,solidAbsorb2,0,0); + G4UnionSolid* solidAbsorb = new G4UnionSolid("Absorb", solidAbsorb1, solidAbsorb2); - G4LogicalVolume* logicAbsorb = new G4LogicalVolume(solidAbsorb,m_Copper,"Absorb"); + G4LogicalVolume* logicAbsorb = new G4LogicalVolume(solidAbsorb, m_Copper, "Absorb"); - G4ThreeVector positionAbsorb(0.,0.,zDumVac); + G4ThreeVector positionAbsorb(0., 0., zDumVac); - new G4PVPlacement(0,positionAbsorb,logicAbsorb,"Absorb",logicVac,false,i_clo+1,true); + new G4PVPlacement(0, positionAbsorb, logicAbsorb, "Absorb", logicVac, false, i_clo + 1, true); // // Now: takes care of the holes and amorphous Ge in each diode: - // Central hole with amorphous Ge for each diode. + // Central hole with amorphous Ge for each diode. // - G4double minRadiusAGe1 = 0.*cm; - G4double maxRadiusAGe1 = 0.52*cm; - G4double HalfLengthAGe1 = 3.75*cm; - G4double startPhiAGe1 = 0.*deg; - G4double deltaPhiAGe1 = 360.*deg; + G4double minRadiusAGe1 = 0. * cm; + G4double maxRadiusAGe1 = 0.52 * cm; + G4double HalfLengthAGe1 = 3.75 * cm; + G4double startPhiAGe1 = 0. * deg; + G4double deltaPhiAGe1 = 360. * deg; + + // G4Tubs* solidAGe1 = new G4Tubs("AGe1",minRadiusAGe1,maxRadiusAGe1, + // HalfLengthAGe1,startPhiAGe1,deltaPhiAGe1); - //G4Tubs* solidAGe1 = new G4Tubs("AGe1",minRadiusAGe1,maxRadiusAGe1, - // HalfLengthAGe1,startPhiAGe1,deltaPhiAGe1); + // G4LogicalVolume* logicAGe1 = new G4LogicalVolume(solidAGe1,m_Germanium,"AGe1"); - //G4LogicalVolume* logicAGe1 = new G4LogicalVolume(solidAGe1,m_Germanium,"AGe1"); - // ... and second the hole in it: - G4Tubs* solidHole1 = new G4Tubs("Hole1",minRadiusAGe1,maxRadiusAGe1-2.*mm, - HalfLengthAGe1,startPhiAGe1,deltaPhiAGe1); + G4Tubs* solidHole1 = + new G4Tubs("Hole1", minRadiusAGe1, maxRadiusAGe1 - 2. * mm, HalfLengthAGe1, startPhiAGe1, deltaPhiAGe1); - G4LogicalVolume* logicHole1 = new G4LogicalVolume(solidHole1,m_Vacuum,"Hole1"); + G4LogicalVolume* logicHole1 = new G4LogicalVolume(solidHole1, m_Vacuum, "Hole1"); // Visu - G4VisAttributes* CanVisAtt= new G4VisAttributes(G4Colour(0.5,0.5,0.5, 0.7)); // Grey - G4VisAttributes* DewarVisAtt= new G4VisAttributes(G4Colour(0.5,0.5,0.5)); // Grey - - logicCloverCan ->SetVisAttributes(CanVisAtt); - logicEnvColdFinger ->SetVisAttributes(CanVisAtt); - logicDewar ->SetVisAttributes(DewarVisAtt); - logicSupClover->SetVisAttributes (G4VisAttributes::Invisible); - - G4VisAttributes* HoleVisAtt= new G4VisAttributes(G4Colour(0.0,0.0,0.0)); // Black - G4VisAttributes* AbsorbVisAtt= new G4VisAttributes(G4Colour(0.5,0.0,0.5,1)); // purple - G4VisAttributes* GeAVisAtt= new G4VisAttributes(G4Colour(1.0,0.0,0.0, 0.6)); //Red - G4VisAttributes* GeBVisAtt= new G4VisAttributes(G4Colour(0.0,1.0,0.0, 0.6)); //Green - G4VisAttributes* GeCVisAtt= new G4VisAttributes(G4Colour(0.0,0.0,1.0, 0.6)); //Blue - G4VisAttributes* GeDVisAtt= new G4VisAttributes(G4Colour(1.0,1.0,1.0, 0.6)); //White - - logicHole1 ->SetVisAttributes(HoleVisAtt); - logicAbsorb ->SetVisAttributes(AbsorbVisAtt); - logicGeA ->SetVisAttributes(GeAVisAtt); - logicGeB ->SetVisAttributes(GeBVisAtt); - logicGeC ->SetVisAttributes(GeCVisAtt); - logicGeD ->SetVisAttributes(GeDVisAtt); - logicVac->SetVisAttributes (G4VisAttributes::Invisible); - + G4VisAttributes* CanVisAtt = new G4VisAttributes(G4Colour(0.5, 0.5, 0.5, 0.7)); // Grey + G4VisAttributes* DewarVisAtt = new G4VisAttributes(G4Colour(0.5, 0.5, 0.5)); // Grey + + logicCloverCan->SetVisAttributes(CanVisAtt); + logicEnvColdFinger->SetVisAttributes(CanVisAtt); + logicDewar->SetVisAttributes(DewarVisAtt); + logicSupClover->SetVisAttributes(G4VisAttributes::GetInvisible()); + + G4VisAttributes* HoleVisAtt = new G4VisAttributes(G4Colour(0.0, 0.0, 0.0)); // Black + G4VisAttributes* AbsorbVisAtt = new G4VisAttributes(G4Colour(0.5, 0.0, 0.5, 1)); // purple + G4VisAttributes* GeAVisAtt = new G4VisAttributes(G4Colour(1.0, 0.0, 0.0, 0.6)); // Red + G4VisAttributes* GeBVisAtt = new G4VisAttributes(G4Colour(0.0, 1.0, 0.0, 0.6)); // Green + G4VisAttributes* GeCVisAtt = new G4VisAttributes(G4Colour(0.0, 0.0, 1.0, 0.6)); // Blue + G4VisAttributes* GeDVisAtt = new G4VisAttributes(G4Colour(1.0, 1.0, 1.0, 0.6)); // White + + logicHole1->SetVisAttributes(HoleVisAtt); + logicAbsorb->SetVisAttributes(AbsorbVisAtt); + logicGeA->SetVisAttributes(GeAVisAtt); + logicGeB->SetVisAttributes(GeBVisAtt); + logicGeC->SetVisAttributes(GeCVisAtt); + logicGeD->SetVisAttributes(GeDVisAtt); + logicVac->SetVisAttributes(G4VisAttributes::GetInvisible()); } - - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Exogam::AddDetector(double X, double Y, double Z, double ThetaX, double ThetaY, double ThetaZ){ +void Exogam::AddDetector(double X, double Y, double Z, double ThetaX, double ThetaY, double ThetaZ) { m_X.push_back(X); m_Y.push_back(Y); m_Z.push_back(Z); @@ -551,7 +532,6 @@ void Exogam::AddDetector(double X, double Y, double Z, double ThetaX, double T m_ThetaZ.push_back(ThetaZ); } - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... @@ -559,86 +539,82 @@ void Exogam::AddDetector(double X, double Y, double Z, double ThetaX, double T // Read stream at Configfile to pick-up parameters of detector (Position,...) // Called in DetecorConstruction::ReadDetextorConfiguration Method -void Exogam::ReadConfiguration(NPL::InputParser parser){ +void Exogam::ReadConfiguration(NPL::InputParser parser) { vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithToken("Exogam"); - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << "//// " << blocks.size() << " detectors found " << endl; - - vector<string> coord = {"X", "Y", "Z","ThetaX","ThetaY","ThetaZ"}; - - for(unsigned int i = 0 ; i < blocks.size() ; i++){ - if(blocks[i]->HasTokenList(coord)){ - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << endl << "//// Exogam " << i+1 << endl; - double X = blocks[i]->GetDouble("X","mm"); - double Y = blocks[i]->GetDouble("Y","mm"); - double Z = blocks[i]->GetDouble("Z","mm"); - double ThetaX = blocks[i]->GetDouble("ThetaX","deg"); - double ThetaY = blocks[i]->GetDouble("ThetaY","deg"); - double ThetaZ = blocks[i]->GetDouble("ThetaZ","deg"); - AddDetector(X,Y,Z,ThetaX, ThetaY, ThetaZ); + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks.size() << " detectors found " << endl; + + vector<string> coord = {"X", "Y", "Z", "ThetaX", "ThetaY", "ThetaZ"}; + + for (unsigned int i = 0; i < blocks.size(); i++) { + if (blocks[i]->HasTokenList(coord)) { + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// Exogam " << i + 1 << endl; + double X = blocks[i]->GetDouble("X", "mm"); + double Y = blocks[i]->GetDouble("Y", "mm"); + double Z = blocks[i]->GetDouble("Z", "mm"); + double ThetaX = blocks[i]->GetDouble("ThetaX", "deg"); + double ThetaY = blocks[i]->GetDouble("ThetaY", "deg"); + double ThetaZ = blocks[i]->GetDouble("ThetaZ", "deg"); + AddDetector(X, Y, Z, ThetaX, ThetaY, ThetaZ); } - else{ + else { cout << "ERROR: check your input file formatting " << endl; exit(1); } } } - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Construct detector and inialise sensitive part. // Called After DetecorConstruction::AddDetector Method -void Exogam::ConstructDetector(G4LogicalVolume* world){ - //G4double distBGOSShieldToGeCan = 3.2*cm; // distance from the front face of the - // BGO Side Shield to the front face of the - // Ge can (theory: 3.2*cm) - //G4double distCollimatorToGeCan=6.15*cm; // distance from front face of the collimator - // to the front face of the Ge can - - for ( unsigned i = 0; i < m_X.size(); ++i ) - { +void Exogam::ConstructDetector(G4LogicalVolume* world) { + // G4double distBGOSShieldToGeCan = 3.2*cm; // distance from the front face of the + // BGO Side Shield to the front face of the + // Ge can (theory: 3.2*cm) + // G4double distCollimatorToGeCan=6.15*cm; // distance from front face of the collimator + // to the front face of the Ge can + + for (unsigned i = 0; i < m_X.size(); ++i) { // Build and place Clover and its enveloppe BuildClover(i, world); - - //BuildSideCatcher(); - //BuildBackCatcher(); - //BuildSideShield(); - //BuildCollimator(); + // BuildSideCatcher(); + // BuildBackCatcher(); + + // BuildSideShield(); + // BuildCollimator(); } } - - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Add Detector branch to the EventTree. // Called After DetecorConstruction::AddDetector Method -void Exogam::InitializeRootOutput(){ - RootOutput *pAnalysis = RootOutput::getInstance(); - TTree *pTree = pAnalysis->GetTree(); - if(!pTree->FindBranch("Exogam")){ - pTree->Branch("Exogam", "TExogamData", &m_Event) ; +void Exogam::InitializeRootOutput() { + RootOutput* pAnalysis = RootOutput::getInstance(); + TTree* pTree = pAnalysis->GetTree(); + if (!pTree->FindBranch("Exogam")) { + pTree->Branch("Exogam", "TExogamData", &m_Event); } - pTree->SetBranchAddress("Exogam", &m_Event) ; + pTree->SetBranchAddress("Exogam", &m_Event); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Read sensitive part and fill the Root tree. // Called at in the EventAction::EndOfEventAvtion -void Exogam::ReadSensitive(const G4Event*){ +void Exogam::ReadSensitive(const G4Event*) { m_Event->Clear(); /////////// // Calorimeter scorer - CalorimeterScorers::PS_Calorimeter* Scorer= (CalorimeterScorers::PS_Calorimeter*) m_ExogamScorer->GetPrimitive(0); + CalorimeterScorers::PS_Calorimeter* Scorer = (CalorimeterScorers::PS_Calorimeter*)m_ExogamScorer->GetPrimitive(0); - unsigned int size = Scorer->GetMult(); - for(unsigned int i = 0 ; i < size ; i++){ - double Energy = RandGauss::shoot(Scorer->GetEnergy(i),Exogam_NS::ResoEnergy); - if(Energy>Exogam_NS::EnergyThreshold){ + unsigned int size = Scorer->GetMult(); + for (unsigned int i = 0; i < size; i++) { + double Energy = RandGauss::shoot(Scorer->GetEnergy(i), Exogam_NS::ResoEnergy); + if (Energy > Exogam_NS::EnergyThreshold) { double Time = Scorer->GetTime(i); int CristalNbr = Scorer->GetLevel(i)[0]; int CloverNbr = Scorer->GetLevel(i)[1]; @@ -648,24 +624,22 @@ void Exogam::ReadSensitive(const G4Event*){ m_Event->SetTime(Time); } } - } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -//////////////////////////////////////////////////////////////// -void Exogam::InitializeScorers() { - bool already_exist = false; - m_ExogamScorer = CheckScorer("ExogamScorer",already_exist) ; +//////////////////////////////////////////////////////////////// +void Exogam::InitializeScorers() { + bool already_exist = false; + m_ExogamScorer = CheckScorer("ExogamScorer", already_exist); - if(already_exist) - return ; + if (already_exist) + return; // Otherwise the scorer is initialised - vector<int> level({0, 1}); - - m_ExogamScorer->RegisterPrimitive( - new CalorimeterScorers::PS_Calorimeter("Cristal",level, 0)); - G4SDManager::GetSDMpointer()->AddNewDetector(m_ExogamScorer) ; + vector<int> level({0, 1}); + + m_ExogamScorer->RegisterPrimitive(new CalorimeterScorers::PS_Calorimeter("Cristal", level, 0)); + G4SDManager::GetSDMpointer()->AddNewDetector(m_ExogamScorer); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... @@ -674,22 +648,20 @@ void Exogam::InitializeScorers() { //////////////////////////////////////////////////////////////////////////////// // Construct Method to be pass to the DetectorFactory // //////////////////////////////////////////////////////////////////////////////// -NPS::VDetector* Exogam::Construct(){ - return (NPS::VDetector*) new Exogam(); -} +NPS::VDetector* Exogam::Construct() { return (NPS::VDetector*)new Exogam(); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //////////////////////////////////////////////////////////////////////////////// // Registering the construct method to the factory // //////////////////////////////////////////////////////////////////////////////// -extern"C" { - class proxy_nps_Exogam{ - public: - proxy_nps_Exogam(){ - NPS::DetectorFactory::getInstance()->AddToken("Exogam","Exogam"); - NPS::DetectorFactory::getInstance()->AddDetector("Exogam",Exogam::Construct); - } - }; - - proxy_nps_Exogam p_nps_Exogam; +extern "C" { +class proxy_nps_Exogam { + public: + proxy_nps_Exogam() { + NPS::DetectorFactory::getInstance()->AddToken("Exogam", "Exogam"); + NPS::DetectorFactory::getInstance()->AddDetector("Exogam", Exogam::Construct); + } +}; + +proxy_nps_Exogam p_nps_Exogam; } diff --git a/NPSimulation/Detectors/Fatima/Fatima.cc b/NPSimulation/Detectors/Fatima/Fatima.cc index dffd966af2018feb25db7020dafee25ec6f97ef4..5f8f79504a71edf963b2d9e9ed9c7543aa6ff303 100644 --- a/NPSimulation/Detectors/Fatima/Fatima.cc +++ b/NPSimulation/Detectors/Fatima/Fatima.cc @@ -20,21 +20,21 @@ *****************************************************************************/ // C++ headers -#include <sstream> #include <cmath> #include <limits> +#include <sstream> using namespace std; -//Geant4 -#include "G4VSolid.hh" +// Geant4 #include "G4Box.hh" -#include "G4Tubs.hh" -#include "G4UnionSolid.hh" -#include "G4SubtractionSolid.hh" +#include "G4Colour.hh" +#include "G4PVPlacement.hh" #include "G4SDManager.hh" +#include "G4SubtractionSolid.hh" #include "G4Transform3D.hh" -#include "G4PVPlacement.hh" -#include "G4Colour.hh" +#include "G4Tubs.hh" +#include "G4UnionSolid.hh" +#include "G4VSolid.hh" // NPS #include "Fatima.hh" @@ -53,7 +53,7 @@ using namespace CLHEP; //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Fatima Specific Method -Fatima::Fatima(){ +Fatima::Fatima() { m_Event = new TFatimaData(); // Blue @@ -63,31 +63,31 @@ Fatima::Fatima(){ m_PMTVisAtt = new G4VisAttributes(G4Colour(0.1, 0.1, 0.1)); // Grey wireframe - m_DetectorCasingVisAtt = new G4VisAttributes(G4Colour(0.5, 0.5, 0.5,0.2)); + m_DetectorCasingVisAtt = new G4VisAttributes(G4Colour(0.5, 0.5, 0.5, 0.2)); m_LogicalDetector = 0; - m_LaBr3Scorer = 0 ; + m_LaBr3Scorer = 0; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -Fatima::~Fatima(){ -} +Fatima::~Fatima() {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Fatima::AddDetector(G4ThreeVector Pos1, G4ThreeVector Pos2, G4ThreeVector Pos3, G4ThreeVector Pos4){ - G4ThreeVector Pos=(Pos1+Pos2+Pos3+Pos4)/4.; - G4ThreeVector u = Pos1-Pos2; - G4ThreeVector v = Pos1-Pos4; - u = u.unit(); v = v.unit(); +void Fatima::AddDetector(G4ThreeVector Pos1, G4ThreeVector Pos2, G4ThreeVector Pos3, G4ThreeVector Pos4) { + G4ThreeVector Pos = (Pos1 + Pos2 + Pos3 + Pos4) / 4.; + G4ThreeVector u = Pos1 - Pos2; + G4ThreeVector v = Pos1 - Pos4; + u = u.unit(); + v = v.unit(); G4ThreeVector w = Pos.unit(); - Pos = Pos + w*Length*0.5; + Pos = Pos + w * Length * 0.5; m_Pos.push_back(Pos); - m_Rot.push_back(new G4RotationMatrix(u,v,w)); + m_Rot.push_back(new G4RotationMatrix(u, v, w)); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Fatima::AddDetector(G4ThreeVector Pos, double beta_u, double beta_v, double beta_w){ +void Fatima::AddDetector(G4ThreeVector Pos, double beta_u, double beta_v, double beta_w) { double Theta = Pos.theta(); double Phi = Pos.phi(); @@ -103,10 +103,10 @@ void Fatima::AddDetector(G4ThreeVector Pos, double beta_u, double beta_v, double v = v.unit(); u = u.unit(); - G4RotationMatrix* r = new G4RotationMatrix(u,v,w); - r->rotate(beta_u,u); - r->rotate(beta_v,v); - r->rotate(beta_w,w); + G4RotationMatrix* r = new G4RotationMatrix(u, v, w); + r->rotate(beta_u, u); + r->rotate(beta_v, v); + r->rotate(beta_w, w); m_Pos.push_back(Pos); m_Rot.push_back(r); @@ -116,38 +116,38 @@ void Fatima::AddDetector(G4ThreeVector Pos, double beta_u, double beta_v, double // Virtual Method of NPS::VDetector class // Read stream at Configfile to pick-up parameters of detector (Position,...) // Called in DetecorConstruction::ReadDetextorConfiguration Method -void Fatima::ReadConfiguration(NPL::InputParser parser){ +void Fatima::ReadConfiguration(NPL::InputParser parser) { vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithToken("Fatima"); - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << "//// " << blocks.size() << " detectors found " << endl; - for(unsigned int i = 0 ; i < blocks.size() ; i++){ + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks.size() << " detectors found " << endl; + for (unsigned int i = 0; i < blocks.size(); i++) { // Cartesian Case - vector<string> cart = {"A","B","C","D"}; + vector<string> cart = {"A", "B", "C", "D"}; // Spherical Case - vector<string> sphe= {"R","THETA","PHI","BETA"}; - - if(blocks[i]->HasTokenList(cart)){ - cout << endl << "//// Fatima " << i+1 << endl; - G4ThreeVector A = NPS::ConvertVector(blocks[i]->GetTVector3("A","mm")); - G4ThreeVector B = NPS::ConvertVector(blocks[i]->GetTVector3("B","mm")); - G4ThreeVector C = NPS::ConvertVector(blocks[i]->GetTVector3("C","mm")); - G4ThreeVector D = NPS::ConvertVector(blocks[i]->GetTVector3("D","mm")); - AddDetector(A,B,C,D) ; + vector<string> sphe = {"R", "THETA", "PHI", "BETA"}; + + if (blocks[i]->HasTokenList(cart)) { + cout << endl << "//// Fatima " << i + 1 << endl; + G4ThreeVector A = NPS::ConvertVector(blocks[i]->GetTVector3("A", "mm")); + G4ThreeVector B = NPS::ConvertVector(blocks[i]->GetTVector3("B", "mm")); + G4ThreeVector C = NPS::ConvertVector(blocks[i]->GetTVector3("C", "mm")); + G4ThreeVector D = NPS::ConvertVector(blocks[i]->GetTVector3("D", "mm")); + AddDetector(A, B, C, D); } - else if(blocks[i]->HasTokenList(sphe)){ - cout << endl << "//// Fatima " << i+1 << endl; - double Theta = blocks[i]->GetDouble("THETA","deg"); - double Phi= blocks[i]->GetDouble("PHI","deg"); - double R = blocks[i]->GetDouble("R","mm"); - vector<double> beta = blocks[i]->GetVectorDouble("BETA","deg"); - R = R + 0.5*Length; - G4ThreeVector Pos(R*sin(Theta)*cos(Phi),R*sin(Theta)*sin(Phi),R*cos(Theta)); - AddDetector(Pos,beta[0],beta[1],beta[2]); + else if (blocks[i]->HasTokenList(sphe)) { + cout << endl << "//// Fatima " << i + 1 << endl; + double Theta = blocks[i]->GetDouble("THETA", "deg"); + double Phi = blocks[i]->GetDouble("PHI", "deg"); + double R = blocks[i]->GetDouble("R", "mm"); + vector<double> beta = blocks[i]->GetVectorDouble("BETA", "deg"); + R = R + 0.5 * Length; + G4ThreeVector Pos(R * sin(Theta) * cos(Phi), R * sin(Theta) * sin(Phi), R * cos(Theta)); + AddDetector(Pos, beta[0], beta[1], beta[2]); } - else{ + else { cout << "ERROR: Missing token for Fatima blocks, check your input file" << endl; exit(1); } @@ -157,16 +157,16 @@ void Fatima::ReadConfiguration(NPL::InputParser parser){ //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Construct detector and inialise sensitive part. // Called After DetecorConstruction::AddDetector Method -void Fatima::ConstructDetector(G4LogicalVolume* world){ +void Fatima::ConstructDetector(G4LogicalVolume* world) { unsigned int mysize = m_Pos.size(); - for(unsigned int i = 0 ; i < mysize ; i++){ - new G4PVPlacement(G4Transform3D(*m_Rot[i], m_Pos[i]), ConstructDetector(), "FatimaDetector", world, false, i+1); + for (unsigned int i = 0; i < mysize; i++) { + new G4PVPlacement(G4Transform3D(*m_Rot[i], m_Pos[i]), ConstructDetector(), "FatimaDetector", world, false, i + 1); } } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -G4LogicalVolume* Fatima::ConstructDetector(){ - if(!m_LogicalDetector){ +G4LogicalVolume* Fatima::ConstructDetector() { + if (!m_LogicalDetector) { G4Material* Vacuum = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); G4Material* Alu = MaterialManager::getInstance()->GetMaterialFromLibrary("Al"); @@ -174,27 +174,19 @@ G4LogicalVolume* Fatima::ConstructDetector(){ G4Material* LaBr3 = MaterialManager::getInstance()->GetMaterialFromLibrary("LaBr3"); // Mother Volume - G4Tubs* solidFatimaDetector = - new G4Tubs("Fatima",0, 0.5*FaceFront, 0.5*Length, 0.*deg, 360.*deg); - m_LogicalDetector = - new G4LogicalVolume(solidFatimaDetector, Vacuum, "Fatima", 0, 0, 0); + G4Tubs* solidFatimaDetector = new G4Tubs("Fatima", 0, 0.5 * FaceFront, 0.5 * Length, 0. * deg, 360. * deg); + m_LogicalDetector = new G4LogicalVolume(solidFatimaDetector, Vacuum, "Fatima", 0, 0, 0); - m_LogicalDetector->SetVisAttributes(G4VisAttributes::Invisible); + m_LogicalDetector->SetVisAttributes(G4VisAttributes::GetInvisible()); // Detector construction // LaBr3 - G4ThreeVector positionLaBr3 = G4ThreeVector(0, 0, LaBr3_PosZ); + G4ThreeVector positionLaBr3 = G4ThreeVector(0, 0, LaBr3_PosZ); - G4Tubs* solidLaBr3 = new G4Tubs("solidLaBr3", 0., 0.5*LaBr3Face, 0.5*LaBr3Thickness, 0.*deg, 360.*deg); + G4Tubs* solidLaBr3 = new G4Tubs("solidLaBr3", 0., 0.5 * LaBr3Face, 0.5 * LaBr3Thickness, 0. * deg, 360. * deg); G4LogicalVolume* logicLaBr3 = new G4LogicalVolume(solidLaBr3, LaBr3, "logicLaBr3", 0, 0, 0); - new G4PVPlacement(0, - positionLaBr3, - logicLaBr3, - "Fatima_LaBr3", - m_LogicalDetector, - false, - 0); + new G4PVPlacement(0, positionLaBr3, logicLaBr3, "Fatima_LaBr3", m_LogicalDetector, false, 0); // Set LaBr3 sensible logicLaBr3->SetSensitiveDetector(m_LaBr3Scorer); @@ -204,87 +196,63 @@ G4LogicalVolume* Fatima::ConstructDetector(){ // Aluminium can around LaBr3 // LaBr3 Can - G4ThreeVector positionLaBr3Can = G4ThreeVector(0, 0, LaBr3Can_PosZ); + G4ThreeVector positionLaBr3Can = G4ThreeVector(0, 0, LaBr3Can_PosZ); - G4Tubs* solidLaBr3Can = new G4Tubs("solidLaBr3Can", 0.5*CanInnerDiameter, 0.5*CanOuterDiameter, 0.5*CanLength, 0.*deg, 360.*deg); + G4Tubs* solidLaBr3Can = new G4Tubs("solidLaBr3Can", 0.5 * CanInnerDiameter, 0.5 * CanOuterDiameter, 0.5 * CanLength, + 0. * deg, 360. * deg); G4LogicalVolume* logicLaBr3Can = new G4LogicalVolume(solidLaBr3Can, Alu, "logicLaBr3Can", 0, 0, 0); - new G4PVPlacement(0, - positionLaBr3Can, - logicLaBr3Can, - "Fatima_LaBr3Can", - m_LogicalDetector, - false, - 0); + new G4PVPlacement(0, positionLaBr3Can, logicLaBr3Can, "Fatima_LaBr3Can", m_LogicalDetector, false, 0); // Visualisation of LaBr3Can logicLaBr3Can->SetVisAttributes(m_DetectorCasingVisAtt); // Aluminium window in front of LaBr3 // LaBr3 Window - G4ThreeVector positionLaBr3Win = G4ThreeVector(0, 0, LaBr3Win_PosZ); + G4ThreeVector positionLaBr3Win = G4ThreeVector(0, 0, LaBr3Win_PosZ); - G4Tubs* solidLaBr3Win = new G4Tubs("solidLaBr3Win", 0.5*WinInnerDiameter, 0.5*WinOuterDiameter, 0.5*WinLength, 0.*deg, 360.*deg); + G4Tubs* solidLaBr3Win = new G4Tubs("solidLaBr3Win", 0.5 * WinInnerDiameter, 0.5 * WinOuterDiameter, 0.5 * WinLength, + 0. * deg, 360. * deg); G4LogicalVolume* logicLaBr3Win = new G4LogicalVolume(solidLaBr3Win, Alu, "logicLaBr3Win", 0, 0, 0); - new G4PVPlacement(0, - positionLaBr3Win, - logicLaBr3Win, - "Fatima_LaBr3Win", - m_LogicalDetector, - false, - 0); + new G4PVPlacement(0, positionLaBr3Win, logicLaBr3Win, "Fatima_LaBr3Win", m_LogicalDetector, false, 0); // Visualisation of LaBr3Win logicLaBr3Win->SetVisAttributes(m_DetectorCasingVisAtt); // PMT - G4ThreeVector positionPMT = G4ThreeVector(0, 0, PMT_PosZ); + G4ThreeVector positionPMT = G4ThreeVector(0, 0, PMT_PosZ); - G4Tubs* solidPMout = new G4Tubs("solidPMOut", 0.5*LaBr3Face, 0.5*PMTFace, 0.5*PMTThickness, 0.*deg, 360.*deg); - G4Tubs* solidPMin = new G4Tubs("solidPMIn", 0.5*LaBr3Face-0.1*cm, 0.5*PMTFace-0.5*cm, 0.5*(PMTThickness-2.*cm)-0.1*cm, 0.*deg, 360.*deg); - G4RotationMatrix* RotMat=NULL; - const G4ThreeVector &Trans= G4ThreeVector(0.,0.,1.*cm); - G4SubtractionSolid* solidPMT = new G4SubtractionSolid("solidPMT", solidPMout,solidPMin, RotMat, Trans); + G4Tubs* solidPMout = + new G4Tubs("solidPMOut", 0.5 * LaBr3Face, 0.5 * PMTFace, 0.5 * PMTThickness, 0. * deg, 360. * deg); + G4Tubs* solidPMin = new G4Tubs("solidPMIn", 0.5 * LaBr3Face - 0.1 * cm, 0.5 * PMTFace - 0.5 * cm, + 0.5 * (PMTThickness - 2. * cm) - 0.1 * cm, 0. * deg, 360. * deg); + G4RotationMatrix* RotMat = NULL; + const G4ThreeVector& Trans = G4ThreeVector(0., 0., 1. * cm); + G4SubtractionSolid* solidPMT = new G4SubtractionSolid("solidPMT", solidPMout, solidPMin, RotMat, Trans); G4LogicalVolume* logicPMT = new G4LogicalVolume(solidPMT, Alu, "logicPMT", 0, 0, 0); - new G4PVPlacement(0, - positionPMT, - logicPMT, - "Fatima_PMT", - m_LogicalDetector, - false, - 0); + new G4PVPlacement(0, positionPMT, logicPMT, "Fatima_PMT", m_LogicalDetector, false, 0); // Visualisation of PMT Strip logicPMT->SetVisAttributes(m_PMTVisAtt); // Lead shielding // A - G4ThreeVector positionLeadAShield = G4ThreeVector(0, 0, LeadAShield_PosZ); - G4Tubs* solidLeadA = new G4Tubs("solidLead", 0.5*LeadAMinR, 0.5*LeadAMaxR, 0.5*LeadALength, 0.*deg, 360.*deg); + G4ThreeVector positionLeadAShield = G4ThreeVector(0, 0, LeadAShield_PosZ); + G4Tubs* solidLeadA = + new G4Tubs("solidLead", 0.5 * LeadAMinR, 0.5 * LeadAMaxR, 0.5 * LeadALength, 0. * deg, 360. * deg); G4LogicalVolume* logicLeadAShield = new G4LogicalVolume(solidLeadA, Lead, "logicLeadAShield", 0, 0, 0); - new G4PVPlacement(0, - positionLeadAShield, - logicLeadAShield, - "Fatima_LeadAShield", - m_LogicalDetector, - false, - 0); + new G4PVPlacement(0, positionLeadAShield, logicLeadAShield, "Fatima_LeadAShield", m_LogicalDetector, false, 0); // B - G4ThreeVector positionLeadBShield = G4ThreeVector(0, 0, LeadBShield_PosZ); - G4Tubs* solidLeadB = new G4Tubs("solidLead", 0.5*LeadBMinR, 0.5*LeadBMaxR, 0.5*LeadBLength, 0.*deg, 360.*deg); + G4ThreeVector positionLeadBShield = G4ThreeVector(0, 0, LeadBShield_PosZ); + G4Tubs* solidLeadB = + new G4Tubs("solidLead", 0.5 * LeadBMinR, 0.5 * LeadBMaxR, 0.5 * LeadBLength, 0. * deg, 360. * deg); G4LogicalVolume* logicLeadBShield = new G4LogicalVolume(solidLeadB, Lead, "logicLeadBShield", 0, 0, 0); - new G4PVPlacement(0, - positionLeadBShield, - logicLeadBShield, - "Fatima_LeadBShield", - m_LogicalDetector, - false, - 0); + new G4PVPlacement(0, positionLeadBShield, logicLeadBShield, "Fatima_LeadBShield", m_LogicalDetector, false, 0); // Visualisation of PMT Strip G4VisAttributes* LeadVisAtt = new G4VisAttributes(G4Colour(1., 1., 0.)); @@ -298,79 +266,76 @@ G4LogicalVolume* Fatima::ConstructDetector(){ //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Add Detector branch to the EventTree. // Called After DetecorConstruction::AddDetector Method -void Fatima::InitializeRootOutput(){ - RootOutput *pAnalysis = RootOutput::getInstance(); - TTree *pTree = pAnalysis->GetTree(); - if(!pTree->FindBranch("Fatima")){ - pTree->Branch("Fatima", "TFatimaData", &m_Event) ; - } - pTree->SetBranchAddress("Fatima", &m_Event) ; +void Fatima::InitializeRootOutput() { + RootOutput* pAnalysis = RootOutput::getInstance(); + TTree* pTree = pAnalysis->GetTree(); + if (!pTree->FindBranch("Fatima")) { + pTree->Branch("Fatima", "TFatimaData", &m_Event); + } + pTree->SetBranchAddress("Fatima", &m_Event); } - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Read sensitive part and fill the Root tree. // Called at in the EventAction::EndOfEventAvtion -void Fatima::ReadSensitive(const G4Event* ){ +void Fatima::ReadSensitive(const G4Event*) { m_Event->Clear(); /////////// // LaBr3 - CalorimeterScorers::PS_Calorimeter* Scorer= (CalorimeterScorers::PS_Calorimeter*) m_LaBr3Scorer->GetPrimitive(0); - unsigned int size = Scorer->GetMult(); - for(unsigned int i = 0 ; i < size ; i++){ - vector<unsigned int> level = Scorer->GetLevel(i); + CalorimeterScorers::PS_Calorimeter* Scorer = (CalorimeterScorers::PS_Calorimeter*)m_LaBr3Scorer->GetPrimitive(0); + unsigned int size = Scorer->GetMult(); + for (unsigned int i = 0; i < size; i++) { + vector<unsigned int> level = Scorer->GetLevel(i); double Energy = RandGauss::shoot(Scorer->GetEnergy(i), EnergyResolution); - if(Energy>EnergyThreshold){ + if (Energy > EnergyThreshold) { double Time = Scorer->GetTime(i); int DetectorNbr = level[0]; - m_Event->SetFatimaLaBr3E(DetectorNbr,Energy); - m_Event->SetFatimaLaBr3T(DetectorNbr,Time); + m_Event->SetFatimaLaBr3E(DetectorNbr, Energy); + m_Event->SetFatimaLaBr3T(DetectorNbr, Time); } } } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Fatima::InitializeScorers(){ +void Fatima::InitializeScorers() { vector<G4int> NestingLevel; NestingLevel.push_back(1); // LaBr3 Associate Scorer bool already_exist = false; - m_LaBr3Scorer = CheckScorer("Fatima_LaBr3Scorer",already_exist); + m_LaBr3Scorer = CheckScorer("Fatima_LaBr3Scorer", already_exist); // if the scorer were created previously nothing else need to be made - if(already_exist) return; + if (already_exist) + return; - G4VPrimitiveScorer* LaBr3Scorer = - new CalorimeterScorers::PS_Calorimeter("FatimaLaBr3",NestingLevel); - //and register it to the multifunctionnal detector + G4VPrimitiveScorer* LaBr3Scorer = new CalorimeterScorers::PS_Calorimeter("FatimaLaBr3", NestingLevel); + // and register it to the multifunctionnal detector m_LaBr3Scorer->RegisterPrimitive(LaBr3Scorer); // Add All Scorer to the Global Scorer Manager - G4SDManager::GetSDMpointer()->AddNewDetector(m_LaBr3Scorer) ; + G4SDManager::GetSDMpointer()->AddNewDetector(m_LaBr3Scorer); } //////////////////////////////////////////////////////////////////////////////// // Construct Method to be pass to the DetectorFactory // //////////////////////////////////////////////////////////////////////////////// -NPS::VDetector* Fatima::Construct(){ - return (NPS::VDetector*) new Fatima(); -} +NPS::VDetector* Fatima::Construct() { return (NPS::VDetector*)new Fatima(); } //////////////////////////////////////////////////////////////////////////////// // Registering the construct method to the factory // //////////////////////////////////////////////////////////////////////////////// -extern"C" { - class proxy_nps_fatima{ - public: - proxy_nps_fatima(){ - NPS::DetectorFactory::getInstance()->AddToken("Fatima","Fatima"); - NPS::DetectorFactory::getInstance()->AddDetector("Fatima",Fatima::Construct); - } - }; - - proxy_nps_fatima p_nps_fatima; +extern "C" { +class proxy_nps_fatima { + public: + proxy_nps_fatima() { + NPS::DetectorFactory::getInstance()->AddToken("Fatima", "Fatima"); + NPS::DetectorFactory::getInstance()->AddDetector("Fatima", Fatima::Construct); + } +}; + +proxy_nps_fatima p_nps_fatima; } diff --git a/NPSimulation/Detectors/GASPARD/GaspardScorers.hh b/NPSimulation/Detectors/GASPARD/GaspardScorers.hh index 79b24b244334facb0573bf1c927f2c307cd1f935..bc56d4dc19365ae069d18a090562a87db06a7b35 100644 --- a/NPSimulation/Detectors/GASPARD/GaspardScorers.hh +++ b/NPSimulation/Detectors/GASPARD/GaspardScorers.hh @@ -21,279 +21,248 @@ * * *****************************************************************************/ -#include "G4VPrimitiveScorer.hh" #include "G4THitsMap.hh" - -namespace GPDSCORERS -{ - // This Threshold is used in all scorers - // Any energy deposit under this threshold will not create an entry - const double TriggerThreshold = 0.1 * keV; - -class GPDScorerFirstStageEnergy : public G4VPrimitiveScorer -{ -public: // with description - GPDScorerFirstStageEnergy(G4String name, G4String volumeName, G4int depth = 0); - virtual ~GPDScorerFirstStageEnergy(); - -protected: // with description - virtual G4bool ProcessHits(G4Step*, G4TouchableHistory*); - -public: - virtual void Initialize(G4HCofThisEvent*); - virtual void EndOfEvent(G4HCofThisEvent*); - virtual void clear(); - virtual void DrawAll(); - virtual void PrintAll(); - -private: - G4String m_VolumeName; - G4int HCID; - G4THitsMap<G4double>* EvtMap; -}; - - - -class GPDScorerSecondStageEnergy : public G4VPrimitiveScorer -{ -public: // with description - GPDScorerSecondStageEnergy(G4String name, G4String volumeName, G4int depth = 0); - virtual ~GPDScorerSecondStageEnergy(); - -protected: // with description - virtual G4bool ProcessHits(G4Step*, G4TouchableHistory*); - -public: - virtual void Initialize(G4HCofThisEvent*); - virtual void EndOfEvent(G4HCofThisEvent*); - virtual void clear(); - virtual void DrawAll(); - virtual void PrintAll(); - -private: - G4String m_VolumeName; - G4int HCID; - G4THitsMap<G4double>* EvtMap; -}; - - - -class GPDScorerThirdStageEnergy : public G4VPrimitiveScorer -{ -public: // with description - GPDScorerThirdStageEnergy(G4String name, G4String volumeName, G4int depth = 0); - virtual ~GPDScorerThirdStageEnergy(); - -protected: // with description - virtual G4bool ProcessHits(G4Step*, G4TouchableHistory*); - -public: - virtual void Initialize(G4HCofThisEvent*); - virtual void EndOfEvent(G4HCofThisEvent*); - virtual void clear(); - virtual void DrawAll(); - virtual void PrintAll(); - -private: - G4String m_VolumeName; - G4int HCID; - G4THitsMap<G4double>* EvtMap; -}; - - - - -class GPDScorerFirstStageFrontStripDummyShape : public G4VPrimitiveScorer -{ -public: // with description - GPDScorerFirstStageFrontStripDummyShape(G4String name, G4int depth = 0, G4int NumberOfStrip = 128); - virtual ~GPDScorerFirstStageFrontStripDummyShape(); - -protected: // with description - virtual G4bool ProcessHits(G4Step*, G4TouchableHistory*); - -public: - virtual void Initialize(G4HCofThisEvent*); - virtual void EndOfEvent(G4HCofThisEvent*); - virtual void clear(); - virtual void DrawAll(); - virtual void PrintAll(); - -private: - G4int m_NumberOfStrip ; - G4int HCID; - G4THitsMap<G4int>* EvtMap; -}; - - - -class GPDScorerFirstStageBackStripDummyShape : public G4VPrimitiveScorer -{ -public: // with description - GPDScorerFirstStageBackStripDummyShape(G4String name, G4int depth = 0, G4int NumberOfStrip = 128); - virtual ~GPDScorerFirstStageBackStripDummyShape(); - -protected: // with description - virtual G4bool ProcessHits(G4Step*, G4TouchableHistory*); - -public: - virtual void Initialize(G4HCofThisEvent*); - virtual void EndOfEvent(G4HCofThisEvent*); - virtual void clear(); - virtual void DrawAll(); - virtual void PrintAll(); - -private: - G4int m_NumberOfStrip ; - G4int HCID; - G4THitsMap<G4int>* EvtMap; -}; - - - -class GPDScorerFirstStageFrontStripSquare : public G4VPrimitiveScorer -{ -public: // with description - GPDScorerFirstStageFrontStripSquare(G4String name, G4int depth = 0, G4int NumberOfStrip = 128); - virtual ~GPDScorerFirstStageFrontStripSquare(); - -protected: // with description - virtual G4bool ProcessHits(G4Step*, G4TouchableHistory*); - -public: - virtual void Initialize(G4HCofThisEvent*); - virtual void EndOfEvent(G4HCofThisEvent*); - virtual void clear(); - virtual void DrawAll(); - virtual void PrintAll(); - -private: - G4int m_NumberOfStrip ; - G4int HCID; - G4THitsMap<G4int>* EvtMap; -}; - - - -class GPDScorerFirstStageBackStripSquare : public G4VPrimitiveScorer -{ -public: // with description - GPDScorerFirstStageBackStripSquare(G4String name, G4int depth = 0, G4int NumberOfStrip = 128); - virtual ~GPDScorerFirstStageBackStripSquare(); - -protected: // with description - virtual G4bool ProcessHits(G4Step*, G4TouchableHistory*); - -public: - virtual void Initialize(G4HCofThisEvent*); - virtual void EndOfEvent(G4HCofThisEvent*); - virtual void clear(); - virtual void DrawAll(); - virtual void PrintAll(); - -private: - G4int m_NumberOfStrip ; - G4int HCID; - G4THitsMap<G4int>* EvtMap; -}; - - - -class GPDScorerFirstStageFrontStripTrapezoid : public G4VPrimitiveScorer -{ -public: // with description - GPDScorerFirstStageFrontStripTrapezoid(G4String name, G4int depth = 0, G4int NumberOfStrip = 128); - virtual ~GPDScorerFirstStageFrontStripTrapezoid(); - -protected: // with description - virtual G4bool ProcessHits(G4Step*, G4TouchableHistory*); - -public: - virtual void Initialize(G4HCofThisEvent*); - virtual void EndOfEvent(G4HCofThisEvent*); - virtual void clear(); - virtual void DrawAll(); - virtual void PrintAll(); - -private: - G4int m_NumberOfStrip ; - G4int HCID; - G4THitsMap<G4int>* EvtMap; -}; - - - -class GPDScorerFirstStageBackStripTrapezoid : public G4VPrimitiveScorer -{ -public: // with description - GPDScorerFirstStageBackStripTrapezoid(G4String name, G4int depth = 0, G4int NumberOfStrip = 128); - virtual ~GPDScorerFirstStageBackStripTrapezoid(); - -protected: // with description - virtual G4bool ProcessHits(G4Step*, G4TouchableHistory*); - -public: - virtual void Initialize(G4HCofThisEvent*); - virtual void EndOfEvent(G4HCofThisEvent*); - virtual void clear(); - virtual void DrawAll(); - virtual void PrintAll(); - -private: - G4int m_NumberOfStrip ; - G4int HCID; - G4THitsMap<G4int>* EvtMap; -}; - - - -class GPDScorerFirstStageFrontStripAnnular : public G4VPrimitiveScorer -{ -public: // with description - GPDScorerFirstStageFrontStripAnnular(G4String name, G4int depth = 0, G4double StripPlaneSize = 98, G4int NumberOfStrip = 128); - virtual ~GPDScorerFirstStageFrontStripAnnular(); - -protected: // with description - virtual G4bool ProcessHits(G4Step*, G4TouchableHistory*); - -public: - virtual void Initialize(G4HCofThisEvent*); - virtual void EndOfEvent(G4HCofThisEvent*); - virtual void clear(); - virtual void DrawAll(); - virtual void PrintAll(); - -private: - G4double m_StripPlaneSize; - G4int m_NumberOfStrip ; - G4int HCID; - G4THitsMap<G4int>* EvtMap; -}; - - - -class GPDScorerFirstStageBackStripAnnular : public G4VPrimitiveScorer -{ -public: // with description - GPDScorerFirstStageBackStripAnnular(G4String name, G4int depth = 0, G4double StripPlaneSize = 98, G4int NumberOfStrip = 128); - virtual ~GPDScorerFirstStageBackStripAnnular(); - -protected: // with description - virtual G4bool ProcessHits(G4Step*, G4TouchableHistory*); - -public: - virtual void Initialize(G4HCofThisEvent*); - virtual void EndOfEvent(G4HCofThisEvent*); - virtual void clear(); - virtual void DrawAll(); - virtual void PrintAll(); - -private: - G4double m_StripPlaneSize; - G4int m_NumberOfStrip ; - G4int HCID; - G4THitsMap<G4int>* EvtMap; -}; - -} +#include "G4VPrimitiveScorer.hh" +using namespace CLHEP; +namespace GPDSCORERS { + // This Threshold is used in all scorers + // Any energy deposit under this threshold will not create an entry + const double TriggerThreshold = 0.1 * keV; + + class GPDScorerFirstStageEnergy : public G4VPrimitiveScorer { + public: // with description + GPDScorerFirstStageEnergy(G4String name, G4String volumeName, G4int depth = 0); + virtual ~GPDScorerFirstStageEnergy(); + + protected: // with description + virtual G4bool ProcessHits(G4Step*, G4TouchableHistory*); + + public: + virtual void Initialize(G4HCofThisEvent*); + virtual void EndOfEvent(G4HCofThisEvent*); + virtual void clear(); + virtual void DrawAll(); + virtual void PrintAll(); + + private: + G4String m_VolumeName; + G4int HCID; + G4THitsMap<G4double>* EvtMap; + }; + + class GPDScorerSecondStageEnergy : public G4VPrimitiveScorer { + public: // with description + GPDScorerSecondStageEnergy(G4String name, G4String volumeName, G4int depth = 0); + virtual ~GPDScorerSecondStageEnergy(); + + protected: // with description + virtual G4bool ProcessHits(G4Step*, G4TouchableHistory*); + + public: + virtual void Initialize(G4HCofThisEvent*); + virtual void EndOfEvent(G4HCofThisEvent*); + virtual void clear(); + virtual void DrawAll(); + virtual void PrintAll(); + + private: + G4String m_VolumeName; + G4int HCID; + G4THitsMap<G4double>* EvtMap; + }; + + class GPDScorerThirdStageEnergy : public G4VPrimitiveScorer { + public: // with description + GPDScorerThirdStageEnergy(G4String name, G4String volumeName, G4int depth = 0); + virtual ~GPDScorerThirdStageEnergy(); + + protected: // with description + virtual G4bool ProcessHits(G4Step*, G4TouchableHistory*); + + public: + virtual void Initialize(G4HCofThisEvent*); + virtual void EndOfEvent(G4HCofThisEvent*); + virtual void clear(); + virtual void DrawAll(); + virtual void PrintAll(); + + private: + G4String m_VolumeName; + G4int HCID; + G4THitsMap<G4double>* EvtMap; + }; + + class GPDScorerFirstStageFrontStripDummyShape : public G4VPrimitiveScorer { + public: // with description + GPDScorerFirstStageFrontStripDummyShape(G4String name, G4int depth = 0, G4int NumberOfStrip = 128); + virtual ~GPDScorerFirstStageFrontStripDummyShape(); + + protected: // with description + virtual G4bool ProcessHits(G4Step*, G4TouchableHistory*); + + public: + virtual void Initialize(G4HCofThisEvent*); + virtual void EndOfEvent(G4HCofThisEvent*); + virtual void clear(); + virtual void DrawAll(); + virtual void PrintAll(); + + private: + G4int m_NumberOfStrip; + G4int HCID; + G4THitsMap<G4int>* EvtMap; + }; + + class GPDScorerFirstStageBackStripDummyShape : public G4VPrimitiveScorer { + public: // with description + GPDScorerFirstStageBackStripDummyShape(G4String name, G4int depth = 0, G4int NumberOfStrip = 128); + virtual ~GPDScorerFirstStageBackStripDummyShape(); + + protected: // with description + virtual G4bool ProcessHits(G4Step*, G4TouchableHistory*); + + public: + virtual void Initialize(G4HCofThisEvent*); + virtual void EndOfEvent(G4HCofThisEvent*); + virtual void clear(); + virtual void DrawAll(); + virtual void PrintAll(); + + private: + G4int m_NumberOfStrip; + G4int HCID; + G4THitsMap<G4int>* EvtMap; + }; + + class GPDScorerFirstStageFrontStripSquare : public G4VPrimitiveScorer { + public: // with description + GPDScorerFirstStageFrontStripSquare(G4String name, G4int depth = 0, G4int NumberOfStrip = 128); + virtual ~GPDScorerFirstStageFrontStripSquare(); + + protected: // with description + virtual G4bool ProcessHits(G4Step*, G4TouchableHistory*); + + public: + virtual void Initialize(G4HCofThisEvent*); + virtual void EndOfEvent(G4HCofThisEvent*); + virtual void clear(); + virtual void DrawAll(); + virtual void PrintAll(); + + private: + G4int m_NumberOfStrip; + G4int HCID; + G4THitsMap<G4int>* EvtMap; + }; + + class GPDScorerFirstStageBackStripSquare : public G4VPrimitiveScorer { + public: // with description + GPDScorerFirstStageBackStripSquare(G4String name, G4int depth = 0, G4int NumberOfStrip = 128); + virtual ~GPDScorerFirstStageBackStripSquare(); + + protected: // with description + virtual G4bool ProcessHits(G4Step*, G4TouchableHistory*); + + public: + virtual void Initialize(G4HCofThisEvent*); + virtual void EndOfEvent(G4HCofThisEvent*); + virtual void clear(); + virtual void DrawAll(); + virtual void PrintAll(); + + private: + G4int m_NumberOfStrip; + G4int HCID; + G4THitsMap<G4int>* EvtMap; + }; + + class GPDScorerFirstStageFrontStripTrapezoid : public G4VPrimitiveScorer { + public: // with description + GPDScorerFirstStageFrontStripTrapezoid(G4String name, G4int depth = 0, G4int NumberOfStrip = 128); + virtual ~GPDScorerFirstStageFrontStripTrapezoid(); + + protected: // with description + virtual G4bool ProcessHits(G4Step*, G4TouchableHistory*); + + public: + virtual void Initialize(G4HCofThisEvent*); + virtual void EndOfEvent(G4HCofThisEvent*); + virtual void clear(); + virtual void DrawAll(); + virtual void PrintAll(); + + private: + G4int m_NumberOfStrip; + G4int HCID; + G4THitsMap<G4int>* EvtMap; + }; + + class GPDScorerFirstStageBackStripTrapezoid : public G4VPrimitiveScorer { + public: // with description + GPDScorerFirstStageBackStripTrapezoid(G4String name, G4int depth = 0, G4int NumberOfStrip = 128); + virtual ~GPDScorerFirstStageBackStripTrapezoid(); + + protected: // with description + virtual G4bool ProcessHits(G4Step*, G4TouchableHistory*); + + public: + virtual void Initialize(G4HCofThisEvent*); + virtual void EndOfEvent(G4HCofThisEvent*); + virtual void clear(); + virtual void DrawAll(); + virtual void PrintAll(); + + private: + G4int m_NumberOfStrip; + G4int HCID; + G4THitsMap<G4int>* EvtMap; + }; + + class GPDScorerFirstStageFrontStripAnnular : public G4VPrimitiveScorer { + public: // with description + GPDScorerFirstStageFrontStripAnnular(G4String name, G4int depth = 0, G4double StripPlaneSize = 98, + G4int NumberOfStrip = 128); + virtual ~GPDScorerFirstStageFrontStripAnnular(); + + protected: // with description + virtual G4bool ProcessHits(G4Step*, G4TouchableHistory*); + + public: + virtual void Initialize(G4HCofThisEvent*); + virtual void EndOfEvent(G4HCofThisEvent*); + virtual void clear(); + virtual void DrawAll(); + virtual void PrintAll(); + + private: + G4double m_StripPlaneSize; + G4int m_NumberOfStrip; + G4int HCID; + G4THitsMap<G4int>* EvtMap; + }; + + class GPDScorerFirstStageBackStripAnnular : public G4VPrimitiveScorer { + public: // with description + GPDScorerFirstStageBackStripAnnular(G4String name, G4int depth = 0, G4double StripPlaneSize = 98, + G4int NumberOfStrip = 128); + virtual ~GPDScorerFirstStageBackStripAnnular(); + + protected: // with description + virtual G4bool ProcessHits(G4Step*, G4TouchableHistory*); + + public: + virtual void Initialize(G4HCofThisEvent*); + virtual void EndOfEvent(G4HCofThisEvent*); + virtual void clear(); + virtual void DrawAll(); + virtual void PrintAll(); + + private: + G4double m_StripPlaneSize; + G4int m_NumberOfStrip; + G4int HCID; + G4THitsMap<G4int>* EvtMap; + }; + +} // namespace GPDSCORERS #endif diff --git a/NPSimulation/Detectors/GASPARD/GaspardTrackerAnnular.cc b/NPSimulation/Detectors/GASPARD/GaspardTrackerAnnular.cc index b519cf882d114564af34a3b6d7b93de6004490aa..0ecf72d2708a07892638c3eccce9314ba2abd131 100644 --- a/NPSimulation/Detectors/GASPARD/GaspardTrackerAnnular.cc +++ b/NPSimulation/Detectors/GASPARD/GaspardTrackerAnnular.cc @@ -23,37 +23,37 @@ *****************************************************************************/ // C++ headers +#include <cmath> #include <sstream> #include <string> -#include <cmath> // G4 Geometry headers #include "G4Box.hh" #include "G4Tubs.hh" // G4 various headers -#include "G4MaterialTable.hh" +#include "G4Colour.hh" #include "G4Element.hh" #include "G4ElementTable.hh" -#include "G4VisAttributes.hh" -#include "G4Colour.hh" +#include "G4MaterialTable.hh" +#include "G4PVDivision.hh" +#include "G4PVPlacement.hh" #include "G4RotationMatrix.hh" #include "G4Transform3D.hh" -#include "G4PVPlacement.hh" -#include "G4PVDivision.hh" +#include "G4VisAttributes.hh" // G4 sensitive -#include "G4SDManager.hh" #include "G4MultiFunctionalDetector.hh" +#include "G4SDManager.hh" // NPTool headers #include "GaspardTrackerAnnular.hh" #include "ObsoleteGeneralScorers.hh" //#include "GaspardScorers.hh" +#include "NPSVDetector.hh" +#include "RootOutput.h" #include "SiliconScorers.hh" #include "TGaspardTrackerData.h" -#include "RootOutput.h" -#include "NPSVDetector.hh" // CLHEP #include "CLHEP/Random/RandGauss.h" @@ -61,511 +61,437 @@ using namespace std; using namespace CLHEP; using namespace GPDANNULAR; -//using namespace GPDSCORERS; +// using namespace GPDSCORERS; //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -GaspardTrackerAnnular::GaspardTrackerAnnular() -{ - ms_InterCoord = 0; -} - - +GaspardTrackerAnnular::GaspardTrackerAnnular() { ms_InterCoord = 0; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -GaspardTrackerAnnular::~GaspardTrackerAnnular() -{ -} - - +GaspardTrackerAnnular::~GaspardTrackerAnnular() {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void GaspardTrackerAnnular::AddModule(G4double PosZ, - G4double Rmin, - G4double Rmax, - bool wFirstStage, - bool wSecondStage, - bool wThirdStage) -{ - m_FirstStagePosZ.push_back(PosZ); - m_FirstStageRmin.push_back(Rmin); - m_FirstStageRmax.push_back(Rmax); - - m_wFirstStage.push_back(wFirstStage) ; - m_wSecondStage.push_back(wSecondStage) ; - m_wThirdStage.push_back(wThirdStage) ; +void GaspardTrackerAnnular::AddModule(G4double PosZ, G4double Rmin, G4double Rmax, bool wFirstStage, bool wSecondStage, + bool wThirdStage) { + m_FirstStagePosZ.push_back(PosZ); + m_FirstStageRmin.push_back(Rmin); + m_FirstStageRmax.push_back(Rmax); + + m_wFirstStage.push_back(wFirstStage); + m_wSecondStage.push_back(wSecondStage); + m_wThirdStage.push_back(wThirdStage); } +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +void GaspardTrackerAnnular::VolumeMaker(G4int DetectorNumber, G4ThreeVector MMpos, G4RotationMatrix* MMrot, + bool wFirstStage, bool wSecondStage, bool wThirdStage, G4LogicalVolume* world) { + G4double TelNbr = DetectorNumber; + G4String DetNumber; + ostringstream Number; + Number << TelNbr; + DetNumber = Number.str(); + cout << "FF DetectorNumber: " << DetectorNumber << endl; + cout << "FF m_FSRmin[DetecNbr-1]: " << m_FirstStageRmin[DetectorNumber - 1] << endl; + cout << "FF m_FSRmax[DetecNbr-1]: " << m_FirstStageRmax[DetectorNumber - 1] << endl; + + //////////////////////////////////////////////////////////////// + ////////////// Starting Volume Definition ////////////////////// + //////////////////////////////////////////////////////////////// + // Name of the module + G4String Name = "GPDAnnular" + DetNumber; -//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void GaspardTrackerAnnular::VolumeMaker(G4int DetectorNumber, - G4ThreeVector MMpos, - G4RotationMatrix* MMrot, - bool wFirstStage, - bool wSecondStage, - bool wThirdStage, - G4LogicalVolume* world) -{ - G4double TelNbr = DetectorNumber ; - G4String DetNumber ; - ostringstream Number ; - Number << TelNbr ; - DetNumber = Number.str() ; - - cout<<"FF DetectorNumber: "<<DetectorNumber<<endl; - cout<<"FF m_FSRmin[DetecNbr-1]: "<<m_FirstStageRmin[DetectorNumber-1]<<endl; - cout<<"FF m_FSRmax[DetecNbr-1]: "<<m_FirstStageRmax[DetectorNumber-1]<<endl; - - //////////////////////////////////////////////////////////////// - ////////////// Starting Volume Definition ////////////////////// - //////////////////////////////////////////////////////////////// - // Name of the module - G4String Name = "GPDAnnular" + DetNumber; - - // Definition of the volume containing the sensitive detector - G4Tubs* solidMM = new G4Tubs(Name, - LogicRmin, - LogicRmax, - LogicLength/2, - 0*deg, - 360*deg); - - G4LogicalVolume* logicMM = new G4LogicalVolume(solidMM, m_MaterialVacuum, Name, 0, 0, 0); - - new G4PVPlacement(G4Transform3D(*MMrot, MMpos), logicMM, Name, world, false, DetectorNumber); - - logicMM->SetVisAttributes(G4VisAttributes::Invisible); - if (m_non_sensitive_part_visiualisation){ - G4VisAttributes VisAtt(G4Colour(0.90, 0.90, 0.90)); - VisAtt.SetForceWireframe(true); - logicMM->SetVisAttributes(VisAtt); - } - // Definition of a vaccuum volume - G4ThreeVector positionVacBox = G4ThreeVector(0, 0, VacBox_PosZ); - - G4Tubs* solidVacBox = new G4Tubs("solidVacBox", - m_FirstStageRmin[DetectorNumber-1], - m_FirstStageRmax[DetectorNumber-1], - VacBoxThickness/2, - 0*deg, - 360*deg); - - G4LogicalVolume* logicVacBox = new G4LogicalVolume(solidVacBox, m_MaterialVacuum, "logicVacBox", 0, 0, 0); - - G4PVPlacement(0, positionVacBox, logicVacBox, "G" + DetNumber + "VacBox", logicMM, false, DetectorNumber); - - logicVacBox->SetVisAttributes(G4VisAttributes::Invisible); - - //////////////////////////////////////////////////////////////// - /////////////////// First Stage Construction//////////////////// - //////////////////////////////////////////////////////////////// - if (wFirstStage) { - // Aluminium dead layers - G4ThreeVector positionAluStripFront = G4ThreeVector(0, 0, AluStripFront_PosZ); - G4ThreeVector positionAluStripBack = G4ThreeVector(0, 0, AluStripBack_PosZ); - - G4Tubs* solidAluStrip = new G4Tubs("AluBox", - m_FirstStageRmin[DetectorNumber-1], - m_FirstStageRmax[DetectorNumber-1], - AluStripThickness/2, - 0*deg, - 360*deg); - -// G4LogicalVolume* logicAluStrip = new G4LogicalVolume(solidAluStrip, Aluminium, "logicAluStrip", 0, 0, 0); - G4LogicalVolume* logicAluStrip = new G4LogicalVolume(solidAluStrip, m_MaterialVacuum, "logicAluStrip", 0, 0, 0); - - new G4PVPlacement(0, positionAluStripFront, logicAluStrip, "G" + DetNumber + "AluStripFront", logicMM, false, DetectorNumber); - new G4PVPlacement(0, positionAluStripBack, logicAluStrip, "G" + DetNumber + "AluStripBack", logicMM, false, DetectorNumber); - - logicAluStrip->SetVisAttributes(G4VisAttributes::Invisible); - - // Silicon detector itself - G4ThreeVector positionSilicon = G4ThreeVector(0, 0, Silicon_PosZ); - - G4Tubs* solidSilicon = new G4Tubs("solidSilicon", - m_FirstStageRmin[DetectorNumber-1], - m_FirstStageRmax[DetectorNumber-1], - FirstStageThickness/2, - 0*deg, - 360*deg); - G4LogicalVolume* logicSilicon = new G4LogicalVolume(solidSilicon, m_MaterialSilicon, "logicSilicon", 0, 0, 0); - - new G4PVPlacement(0, positionSilicon, logicSilicon, Name + "_Silicon", logicMM, false, DetectorNumber); - - // Set First Stage sensible - logicSilicon->SetSensitiveDetector(m_FirstStageScorer); - - ///Visualisation of Silicon Strip - G4VisAttributes* SiliconVisAtt = new G4VisAttributes(G4Colour(0.0, 0.0, 0.9)) ; // blue - logicSilicon->SetVisAttributes(SiliconVisAtt) ; - } - - //////////////////////////////////////////////////////////////// - //////////////// Second Stage Construction //////////////////// - //////////////////////////////////////////////////////////////// - if (wSecondStage) { - // Second stage silicon detector - G4ThreeVector positionSecondStage = G4ThreeVector(0, 0, SecondStage_PosZ); - - G4Tubs* solidSecondStage = new G4Tubs("solidSecondStage", - m_FirstStageRmin[DetectorNumber-1], - m_FirstStageRmax[DetectorNumber-1], - SecondStageThickness/2, - 0*deg, - 360*deg); - - G4LogicalVolume* logicSecondStage = new G4LogicalVolume(solidSecondStage, m_MaterialSilicon, "logicSecondStage", 0, 0, 0); - - new G4PVPlacement(0, positionSecondStage, logicSecondStage, Name + "_SecondStage", logicMM, false, 0); - - ///Visualisation of Second Stage - G4VisAttributes* SecondStageVisAtt = new G4VisAttributes(G4Colour(0.9, 0, 0)); // red - logicSecondStage->SetVisAttributes(SecondStageVisAtt); - - // Set Second Stage sensible - logicSecondStage->SetSensitiveDetector(m_SecondStageScorer); - } - - //////////////////////////////////////////////////////////////// - ///////////////// Third Stage Construction ///////////////////// - //////////////////////////////////////////////////////////////// - if (wThirdStage) { - // Third stage silicon detector - G4ThreeVector positionThirdStage = G4ThreeVector(0, 0, ThirdStage_PosZ); - - G4Tubs* solidThirdStage = new G4Tubs("solidThirdStage", - m_FirstStageRmin[DetectorNumber-1], - m_FirstStageRmax[DetectorNumber-1], - ThirdStageThickness/2, - 0*deg, - 360*deg); - - G4LogicalVolume* logicThirdStage = new G4LogicalVolume(solidThirdStage, m_MaterialSilicon, "logicThirdStage", 0, 0, 0); - - new G4PVPlacement(0, positionThirdStage, logicThirdStage, Name + "_ThirdStage", logicMM, false, 0); - - ///Visualisation of Third Stage - G4VisAttributes* ThirdStageVisAtt = new G4VisAttributes(G4Colour(0.0, 0.9, 0.)) ; // green - logicThirdStage->SetVisAttributes(ThirdStageVisAtt) ; - - // Set Third Stage sensible - logicThirdStage->SetSensitiveDetector(m_ThirdStageScorer); - } -} + // Definition of the volume containing the sensitive detector + G4Tubs* solidMM = new G4Tubs(Name, LogicRmin, LogicRmax, LogicLength / 2, 0 * deg, 360 * deg); -//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -// Virtual Method of NPS::VDetector class + G4LogicalVolume* logicMM = new G4LogicalVolume(solidMM, m_MaterialVacuum, Name, 0, 0, 0); -// Read stream at Configfile to pick-up parameters of detector (Position,...) -// Called in DetecorConstruction::ReadDetextorConfiguration Method -void GaspardTrackerAnnular::ReadConfiguration(NPL::InputParser parser){ - vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithToken("GaspardTracker"); - vector<string> tokenp= {"Z","RMIN","RMAX"}; + new G4PVPlacement(G4Transform3D(*MMrot, MMpos), logicMM, Name, world, false, DetectorNumber); - vector<string> token={"FIRSTSTAGE","SECONDSTAGE","THIRDSTAGE"}; + logicMM->SetVisAttributes(G4VisAttributes::GetInvisible()); + if (m_non_sensitive_part_visiualisation) { + G4VisAttributes VisAtt(G4Colour(0.90, 0.90, 0.90)); + VisAtt.SetForceWireframe(true); + logicMM->SetVisAttributes(VisAtt); + } + // Definition of a vaccuum volume + G4ThreeVector positionVacBox = G4ThreeVector(0, 0, VacBox_PosZ); - for(unsigned int i = 0 ; i < blocks.size() ; i++){ - if(blocks[i]->GetMainValue() == "Annular" && blocks[i]->HasTokenList(token) ){ - cout << "Gaspard Annular " << i+1 << ":" << endl; + G4Tubs* solidVacBox = new G4Tubs("solidVacBox", m_FirstStageRmin[DetectorNumber - 1], + m_FirstStageRmax[DetectorNumber - 1], VacBoxThickness / 2, 0 * deg, 360 * deg); - bool first = blocks[i]->GetInt("FIRSTSTAGE"); - bool second = blocks[i]->GetInt("SECONDSTAGE"); - bool third = blocks[i]->GetInt("THIRDSTAGE"); - m_non_sensitive_part_visiualisation = blocks[i]->GetInt("VIS"); - if(blocks[i]->HasTokenList(tokenp)){ - // Add module - double Z = blocks[i]->GetDouble("Z","mm"); - double Rmin = blocks[i]->GetDouble("Rmin","mm"); - double Rmax = blocks[i]->GetDouble("Rmax","mm"); - AddModule(Z,Rmin,Rmax,first,second,third); - } - else{ - cout << "ERROR: Check input formatting for Gaspard" << endl; - exit(1); - } - } - } -} + G4LogicalVolume* logicVacBox = new G4LogicalVolume(solidVacBox, m_MaterialVacuum, "logicVacBox", 0, 0, 0); -// Construct detector and inialise sensitive part. -// Called After DetecorConstruction::AddDetector Method -void GaspardTrackerAnnular::ConstructDetector(G4LogicalVolume* world) -{ - G4RotationMatrix* MMrot = NULL ; - G4ThreeVector MMpos = G4ThreeVector(0, 0, 0) ; - - bool FirstStage = true ; - bool SecondStage = true ; - bool ThirdStage = true ; - - G4int NumberOfModule = m_FirstStagePosZ.size() ; - - for (G4int i = 0; i < NumberOfModule; i++) { - // translation to position the module - // test if module is in the forward or backward hemisphere - (m_FirstStagePosZ[i] < 0) ? m_FirstStagePosZ[i] -= 0.5*LogicLength : m_FirstStagePosZ[i] += 0.5*LogicLength; - MMpos = G4ThreeVector(0, 0, m_FirstStagePosZ[i]); - - // Passage Matrix from Lab Referential to Module Referential - // Identity matrix by default - MMrot = new G4RotationMatrix(); - if (MMpos.z() < 0) MMrot->rotateX(180*deg); - - // Presence of 1st, 2nd and 3rd stage - FirstStage = m_wFirstStage[i] ; - SecondStage = m_wSecondStage[i] ; - ThirdStage = m_wThirdStage[i] ; - - // Build geometry and declare scorers - VolumeMaker(i + 1, MMpos, MMrot, FirstStage, SecondStage, ThirdStage , world); - } - - delete MMrot ; -} + G4PVPlacement(0, positionVacBox, logicVacBox, "G" + DetNumber + "VacBox", logicMM, false, DetectorNumber); + logicVacBox->SetVisAttributes(G4VisAttributes::GetInvisible()); + //////////////////////////////////////////////////////////////// + /////////////////// First Stage Construction//////////////////// + //////////////////////////////////////////////////////////////// + if (wFirstStage) { + // Aluminium dead layers + G4ThreeVector positionAluStripFront = G4ThreeVector(0, 0, AluStripFront_PosZ); + G4ThreeVector positionAluStripBack = G4ThreeVector(0, 0, AluStripBack_PosZ); -// Connect the GaspardTrackingData class to the output TTree -// of the simulation -void GaspardTrackerAnnular::InitializeRootOutput() -{ -} + G4Tubs* solidAluStrip = new G4Tubs("AluBox", m_FirstStageRmin[DetectorNumber - 1], + m_FirstStageRmax[DetectorNumber - 1], AluStripThickness / 2, 0 * deg, 360 * deg); + // G4LogicalVolume* logicAluStrip = new G4LogicalVolume(solidAluStrip, Aluminium, "logicAluStrip", 0, 0, 0); + G4LogicalVolume* logicAluStrip = new G4LogicalVolume(solidAluStrip, m_MaterialVacuum, "logicAluStrip", 0, 0, 0); + new G4PVPlacement(0, positionAluStripFront, logicAluStrip, "G" + DetNumber + "AluStripFront", logicMM, false, + DetectorNumber); + new G4PVPlacement(0, positionAluStripBack, logicAluStrip, "G" + DetNumber + "AluStripBack", logicMM, false, + DetectorNumber); -// Set the TinteractionCoordinates object from NPS::VDetector to the present class -void GaspardTrackerAnnular::SetInterCoordPointer(TInteractionCoordinates* interCoord) -{ - ms_InterCoord = interCoord; -} + logicAluStrip->SetVisAttributes(G4VisAttributes::GetInvisible()); + // Silicon detector itself + G4ThreeVector positionSilicon = G4ThreeVector(0, 0, Silicon_PosZ); + G4Tubs* solidSilicon = + new G4Tubs("solidSilicon", m_FirstStageRmin[DetectorNumber - 1], m_FirstStageRmax[DetectorNumber - 1], + FirstStageThickness / 2, 0 * deg, 360 * deg); + G4LogicalVolume* logicSilicon = new G4LogicalVolume(solidSilicon, m_MaterialSilicon, "logicSilicon", 0, 0, 0); -// Read sensitive part and fill the Root tree. -// Called at in the EventAction::EndOfEventAvtion -void GaspardTrackerAnnular::ReadSensitive(const G4Event* event) -{ - ////////////// - // First stage - NPS::HitsMap<G4double*>* GPD1HitMap; - std::map<G4int, G4double**>::iterator GPD1_itr; - - G4int GPD1CollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerGPDAnnular/GPDAnnularFirstStage"); - GPD1HitMap = (NPS::HitsMap<G4double*>*)(event->GetHCofThisEvent()->GetHC(GPD1CollectionID)); - - // Loop on the GPD map - for (GPD1_itr = GPD1HitMap->GetMap()->begin(); GPD1_itr != GPD1HitMap->GetMap()->end(); GPD1_itr++) { - G4double* Info = *(GPD1_itr->second); - - double Energy = Info[0]; - if (Energy > EnergyThreshold) { - double Time = Info[1]; - int DetNbr = (int) Info[7]; - int StripFront = (int) Info[8]; - int StripBack = (int) Info[9]; - - // detector number - ms_Event->SetGPDTrkFirstStageFrontEDetectorNbr(m_index["Annular"] + DetNbr); - ms_Event->SetGPDTrkFirstStageFrontTDetectorNbr(m_index["Annular"] + DetNbr); - ms_Event->SetGPDTrkFirstStageBackEDetectorNbr(m_index["Annular"] + DetNbr); - ms_Event->SetGPDTrkFirstStageBackTDetectorNbr(m_index["Annular"] + DetNbr); - - // energy - ms_Event->SetGPDTrkFirstStageFrontEEnergy(RandGauss::shoot(Energy, ResoFirstStage)); - ms_Event->SetGPDTrkFirstStageBackEEnergy(RandGauss::shoot(Energy, ResoFirstStage)); - - // time - Time = RandGauss::shoot(Time, ResoTimePPAC); - ms_Event->SetGPDTrkFirstStageFrontTTime(RandGauss::shoot(Time, ResoTimeGpd)); - ms_Event->SetGPDTrkFirstStageBackTTime(RandGauss::shoot(Time, ResoTimeGpd)); - - // strips X and Y - ms_Event->SetGPDTrkFirstStageFrontEStripNbr(StripFront); - ms_Event->SetGPDTrkFirstStageFrontTStripNbr(StripFront); - ms_Event->SetGPDTrkFirstStageBackEStripNbr(StripBack); - ms_Event->SetGPDTrkFirstStageBackTStripNbr(StripBack); - - // Interaction Coordinates - ms_InterCoord->SetDetectedPositionX(Info[2]); - ms_InterCoord->SetDetectedPositionY(Info[3]); - ms_InterCoord->SetDetectedPositionZ(Info[4]); - ms_InterCoord->SetDetectedAngleTheta(Info[5]/deg); - ms_InterCoord->SetDetectedAnglePhi(Info[6]/deg); + new G4PVPlacement(0, positionSilicon, logicSilicon, Name + "_Silicon", logicMM, false, DetectorNumber); - } - } - // clear map for next event - GPD1HitMap->clear(); + // Set First Stage sensible + logicSilicon->SetSensitiveDetector(m_FirstStageScorer); + /// Visualisation of Silicon Strip + G4VisAttributes* SiliconVisAtt = new G4VisAttributes(G4Colour(0.0, 0.0, 0.9)); // blue + logicSilicon->SetVisAttributes(SiliconVisAtt); + } - ////////////// - // Second stage - NPS::HitsMap<G4double*>* GPD2HitMap; - std::map<G4int, G4double**>::iterator GPD2_itr; + //////////////////////////////////////////////////////////////// + //////////////// Second Stage Construction //////////////////// + //////////////////////////////////////////////////////////////// + if (wSecondStage) { + // Second stage silicon detector + G4ThreeVector positionSecondStage = G4ThreeVector(0, 0, SecondStage_PosZ); - G4int GPD2CollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("SecondStageScorerGPDAnnular/GPDAnnularSecondStage"); - GPD2HitMap = (NPS::HitsMap<G4double*>*)(event->GetHCofThisEvent()->GetHC(GPD2CollectionID)); + G4Tubs* solidSecondStage = + new G4Tubs("solidSecondStage", m_FirstStageRmin[DetectorNumber - 1], m_FirstStageRmax[DetectorNumber - 1], + SecondStageThickness / 2, 0 * deg, 360 * deg); - // Loop on the GPD map - for (GPD2_itr = GPD2HitMap->GetMap()->begin(); GPD2_itr != GPD2HitMap->GetMap()->end(); GPD2_itr++) { - G4double* Info = *(GPD2_itr->second); + G4LogicalVolume* logicSecondStage = + new G4LogicalVolume(solidSecondStage, m_MaterialSilicon, "logicSecondStage", 0, 0, 0); - double Energy = Info[0]; - if (Energy > EnergyThreshold) { - double Time = Info[1]; - int DetNbr = (int) Info[7]; - int StripFront = (int) Info[8]; + new G4PVPlacement(0, positionSecondStage, logicSecondStage, Name + "_SecondStage", logicMM, false, 0); - // detector number - ms_Event->SetGPDTrkSecondStageEDetectorNbr(m_index["Annular"] + DetNbr); - ms_Event->SetGPDTrkSecondStageTDetectorNbr(m_index["Annular"] + DetNbr); + /// Visualisation of Second Stage + G4VisAttributes* SecondStageVisAtt = new G4VisAttributes(G4Colour(0.9, 0, 0)); // red + logicSecondStage->SetVisAttributes(SecondStageVisAtt); - // energy - ms_Event->SetGPDTrkSecondStageEEnergy(RandGauss::shoot(Energy, ResoSecondStage)); + // Set Second Stage sensible + logicSecondStage->SetSensitiveDetector(m_SecondStageScorer); + } - // time - Time = RandGauss::shoot(Time, ResoTimePPAC); - ms_Event->SetGPDTrkSecondStageTTime(RandGauss::shoot(Time, ResoTimeGpd)); + //////////////////////////////////////////////////////////////// + ///////////////// Third Stage Construction ///////////////////// + //////////////////////////////////////////////////////////////// + if (wThirdStage) { + // Third stage silicon detector + G4ThreeVector positionThirdStage = G4ThreeVector(0, 0, ThirdStage_PosZ); - // strips X and Y - ms_Event->SetGPDTrkSecondStageEPadNbr(StripFront); - ms_Event->SetGPDTrkSecondStageTPadNbr(StripFront); - } - } - // clear map for next event - GPD2HitMap->clear(); + G4Tubs* solidThirdStage = + new G4Tubs("solidThirdStage", m_FirstStageRmin[DetectorNumber - 1], m_FirstStageRmax[DetectorNumber - 1], + ThirdStageThickness / 2, 0 * deg, 360 * deg); + G4LogicalVolume* logicThirdStage = + new G4LogicalVolume(solidThirdStage, m_MaterialSilicon, "logicThirdStage", 0, 0, 0); - ////////////// - // Third stage - NPS::HitsMap<G4double*>* GPD3HitMap; - std::map<G4int, G4double**>::iterator GPD3_itr; + new G4PVPlacement(0, positionThirdStage, logicThirdStage, Name + "_ThirdStage", logicMM, false, 0); - G4int GPD3CollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("ThirdStageScorerGPDAnnular/GPDAnnularThirdStage"); - GPD3HitMap = (NPS::HitsMap<G4double*>*)(event->GetHCofThisEvent()->GetHC(GPD3CollectionID)); + /// Visualisation of Third Stage + G4VisAttributes* ThirdStageVisAtt = new G4VisAttributes(G4Colour(0.0, 0.9, 0.)); // green + logicThirdStage->SetVisAttributes(ThirdStageVisAtt); - // Loop on the GPD map - for (GPD3_itr = GPD3HitMap->GetMap()->begin(); GPD3_itr != GPD3HitMap->GetMap()->end(); GPD3_itr++) { - G4double* Info = *(GPD3_itr->second); + // Set Third Stage sensible + logicThirdStage->SetSensitiveDetector(m_ThirdStageScorer); + } +} - double Energy = Info[0]; - if (Energy > EnergyThreshold) { - double Time = Info[1]; - int DetNbr = (int) Info[7]; - int StripFront = (int) Info[8]; +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +// Virtual Method of NPS::VDetector class - // detector number - ms_Event->SetGPDTrkThirdStageEDetectorNbr(m_index["Annular"] + DetNbr); - ms_Event->SetGPDTrkThirdStageTDetectorNbr(m_index["Annular"] + DetNbr); +// Read stream at Configfile to pick-up parameters of detector (Position,...) +// Called in DetecorConstruction::ReadDetextorConfiguration Method +void GaspardTrackerAnnular::ReadConfiguration(NPL::InputParser parser) { + vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithToken("GaspardTracker"); + vector<string> tokenp = {"Z", "RMIN", "RMAX"}; - // energy - ms_Event->SetGPDTrkThirdStageEEnergy(RandGauss::shoot(Energy, ResoThirdStage)); + vector<string> token = {"FIRSTSTAGE", "SECONDSTAGE", "THIRDSTAGE"}; - // time - Time = RandGauss::shoot(Time, ResoTimePPAC); - ms_Event->SetGPDTrkThirdStageTTime(RandGauss::shoot(Time, ResoTimeGpd)); + for (unsigned int i = 0; i < blocks.size(); i++) { + if (blocks[i]->GetMainValue() == "Annular" && blocks[i]->HasTokenList(token)) { + cout << "Gaspard Annular " << i + 1 << ":" << endl; - // strips X and Y - ms_Event->SetGPDTrkThirdStageEPadNbr(StripFront); - ms_Event->SetGPDTrkThirdStageTPadNbr(StripFront); + bool first = blocks[i]->GetInt("FIRSTSTAGE"); + bool second = blocks[i]->GetInt("SECONDSTAGE"); + bool third = blocks[i]->GetInt("THIRDSTAGE"); + m_non_sensitive_part_visiualisation = blocks[i]->GetInt("VIS"); + if (blocks[i]->HasTokenList(tokenp)) { + // Add module + double Z = blocks[i]->GetDouble("Z", "mm"); + double Rmin = blocks[i]->GetDouble("Rmin", "mm"); + double Rmax = blocks[i]->GetDouble("Rmax", "mm"); + AddModule(Z, Rmin, Rmax, first, second, third); + } + else { + cout << "ERROR: Check input formatting for Gaspard" << endl; + exit(1); } - } - // clear map for next event - GPD3HitMap->clear(); + } + } +} + +// Construct detector and inialise sensitive part. +// Called After DetecorConstruction::AddDetector Method +void GaspardTrackerAnnular::ConstructDetector(G4LogicalVolume* world) { + G4RotationMatrix* MMrot = NULL; + G4ThreeVector MMpos = G4ThreeVector(0, 0, 0); + + bool FirstStage = true; + bool SecondStage = true; + bool ThirdStage = true; + + G4int NumberOfModule = m_FirstStagePosZ.size(); + + for (G4int i = 0; i < NumberOfModule; i++) { + // translation to position the module + // test if module is in the forward or backward hemisphere + (m_FirstStagePosZ[i] < 0) ? m_FirstStagePosZ[i] -= 0.5 * LogicLength : m_FirstStagePosZ[i] += 0.5 * LogicLength; + MMpos = G4ThreeVector(0, 0, m_FirstStagePosZ[i]); + + // Passage Matrix from Lab Referential to Module Referential + // Identity matrix by default + MMrot = new G4RotationMatrix(); + if (MMpos.z() < 0) + MMrot->rotateX(180 * deg); + + // Presence of 1st, 2nd and 3rd stage + FirstStage = m_wFirstStage[i]; + SecondStage = m_wSecondStage[i]; + ThirdStage = m_wThirdStage[i]; + + // Build geometry and declare scorers + VolumeMaker(i + 1, MMpos, MMrot, FirstStage, SecondStage, ThirdStage, world); + } + + delete MMrot; } +// Connect the GaspardTrackingData class to the output TTree +// of the simulation +void GaspardTrackerAnnular::InitializeRootOutput() {} +// Set the TinteractionCoordinates object from NPS::VDetector to the present class +void GaspardTrackerAnnular::SetInterCoordPointer(TInteractionCoordinates* interCoord) { ms_InterCoord = interCoord; } + +// Read sensitive part and fill the Root tree. +// Called at in the EventAction::EndOfEventAvtion +void GaspardTrackerAnnular::ReadSensitive(const G4Event* event) { + ////////////// + // First stage + NPS::HitsMap<G4double*>* GPD1HitMap; + std::map<G4int, G4double**>::iterator GPD1_itr; + + G4int GPD1CollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerGPDAnnular/GPDAnnularFirstStage"); + GPD1HitMap = (NPS::HitsMap<G4double*>*)(event->GetHCofThisEvent()->GetHC(GPD1CollectionID)); + + // Loop on the GPD map + for (GPD1_itr = GPD1HitMap->GetMap()->begin(); GPD1_itr != GPD1HitMap->GetMap()->end(); GPD1_itr++) { + G4double* Info = *(GPD1_itr->second); + + double Energy = Info[0]; + if (Energy > EnergyThreshold) { + double Time = Info[1]; + int DetNbr = (int)Info[7]; + int StripFront = (int)Info[8]; + int StripBack = (int)Info[9]; + + // detector number + ms_Event->SetGPDTrkFirstStageFrontEDetectorNbr(m_index["Annular"] + DetNbr); + ms_Event->SetGPDTrkFirstStageFrontTDetectorNbr(m_index["Annular"] + DetNbr); + ms_Event->SetGPDTrkFirstStageBackEDetectorNbr(m_index["Annular"] + DetNbr); + ms_Event->SetGPDTrkFirstStageBackTDetectorNbr(m_index["Annular"] + DetNbr); + + // energy + ms_Event->SetGPDTrkFirstStageFrontEEnergy(RandGauss::shoot(Energy, ResoFirstStage)); + ms_Event->SetGPDTrkFirstStageBackEEnergy(RandGauss::shoot(Energy, ResoFirstStage)); + + // time + Time = RandGauss::shoot(Time, ResoTimePPAC); + ms_Event->SetGPDTrkFirstStageFrontTTime(RandGauss::shoot(Time, ResoTimeGpd)); + ms_Event->SetGPDTrkFirstStageBackTTime(RandGauss::shoot(Time, ResoTimeGpd)); + + // strips X and Y + ms_Event->SetGPDTrkFirstStageFrontEStripNbr(StripFront); + ms_Event->SetGPDTrkFirstStageFrontTStripNbr(StripFront); + ms_Event->SetGPDTrkFirstStageBackEStripNbr(StripBack); + ms_Event->SetGPDTrkFirstStageBackTStripNbr(StripBack); + + // Interaction Coordinates + ms_InterCoord->SetDetectedPositionX(Info[2]); + ms_InterCoord->SetDetectedPositionY(Info[3]); + ms_InterCoord->SetDetectedPositionZ(Info[4]); + ms_InterCoord->SetDetectedAngleTheta(Info[5] / deg); + ms_InterCoord->SetDetectedAnglePhi(Info[6] / deg); + } + } + // clear map for next event + GPD1HitMap->clear(); + + ////////////// + // Second stage + NPS::HitsMap<G4double*>* GPD2HitMap; + std::map<G4int, G4double**>::iterator GPD2_itr; + + G4int GPD2CollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("SecondStageScorerGPDAnnular/GPDAnnularSecondStage"); + GPD2HitMap = (NPS::HitsMap<G4double*>*)(event->GetHCofThisEvent()->GetHC(GPD2CollectionID)); + + // Loop on the GPD map + for (GPD2_itr = GPD2HitMap->GetMap()->begin(); GPD2_itr != GPD2HitMap->GetMap()->end(); GPD2_itr++) { + G4double* Info = *(GPD2_itr->second); + + double Energy = Info[0]; + if (Energy > EnergyThreshold) { + double Time = Info[1]; + int DetNbr = (int)Info[7]; + int StripFront = (int)Info[8]; + + // detector number + ms_Event->SetGPDTrkSecondStageEDetectorNbr(m_index["Annular"] + DetNbr); + ms_Event->SetGPDTrkSecondStageTDetectorNbr(m_index["Annular"] + DetNbr); + + // energy + ms_Event->SetGPDTrkSecondStageEEnergy(RandGauss::shoot(Energy, ResoSecondStage)); + + // time + Time = RandGauss::shoot(Time, ResoTimePPAC); + ms_Event->SetGPDTrkSecondStageTTime(RandGauss::shoot(Time, ResoTimeGpd)); + + // strips X and Y + ms_Event->SetGPDTrkSecondStageEPadNbr(StripFront); + ms_Event->SetGPDTrkSecondStageTPadNbr(StripFront); + } + } + // clear map for next event + GPD2HitMap->clear(); + + ////////////// + // Third stage + NPS::HitsMap<G4double*>* GPD3HitMap; + std::map<G4int, G4double**>::iterator GPD3_itr; + + G4int GPD3CollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("ThirdStageScorerGPDAnnular/GPDAnnularThirdStage"); + GPD3HitMap = (NPS::HitsMap<G4double*>*)(event->GetHCofThisEvent()->GetHC(GPD3CollectionID)); + + // Loop on the GPD map + for (GPD3_itr = GPD3HitMap->GetMap()->begin(); GPD3_itr != GPD3HitMap->GetMap()->end(); GPD3_itr++) { + G4double* Info = *(GPD3_itr->second); + + double Energy = Info[0]; + if (Energy > EnergyThreshold) { + double Time = Info[1]; + int DetNbr = (int)Info[7]; + int StripFront = (int)Info[8]; + + // detector number + ms_Event->SetGPDTrkThirdStageEDetectorNbr(m_index["Annular"] + DetNbr); + ms_Event->SetGPDTrkThirdStageTDetectorNbr(m_index["Annular"] + DetNbr); + + // energy + ms_Event->SetGPDTrkThirdStageEEnergy(RandGauss::shoot(Energy, ResoThirdStage)); + + // time + Time = RandGauss::shoot(Time, ResoTimePPAC); + ms_Event->SetGPDTrkThirdStageTTime(RandGauss::shoot(Time, ResoTimeGpd)); + + // strips X and Y + ms_Event->SetGPDTrkThirdStageEPadNbr(StripFront); + ms_Event->SetGPDTrkThirdStageTPadNbr(StripFront); + } + } + // clear map for next event + GPD3HitMap->clear(); +} -void GaspardTrackerAnnular::InitializeScorers() -{ - // check whether scorers are already defined - bool already_exist = false; - m_FirstStageScorer = NPS::VDetector::CheckScorer("FirstStageScorerGPDAnnular", already_exist); - m_SecondStageScorer = NPS::VDetector::CheckScorer("SecondStageScorerGPDAnnular", already_exist); - m_ThirdStageScorer = NPS::VDetector::CheckScorer("ThirdStageScorerGPDAnnular", already_exist); - if (already_exist) return; - - - // First stage scorer - G4VPrimitiveScorer* GPDScorerFirstStage = - new SILICONSCORERS::PS_Silicon_Annular("GPDAnnularFirstStage", - 0, - m_FirstStageRmin[0], - m_FirstStageRmax[0], - 360*deg, - 0*deg, - NbThetaStrips, - NbPhiStrips, - 1); - - // Second stage scorer - G4VPrimitiveScorer* GPDScorerSecondStage = - new SILICONSCORERS::PS_Silicon_Annular("GPDAnnularSecondStage", - 0, - m_FirstStageRmin[0], - m_FirstStageRmax[0], - 0*deg, - 360*deg, - 1, - 1, - 1); - - // Third stage scorer - G4VPrimitiveScorer* GPDScorerThirdStage = - new SILICONSCORERS::PS_Silicon_Annular("GPDAnnularThirdStage", - 0, - m_FirstStageRmin[0], - m_FirstStageRmax[0], - 0*deg, - 360*deg, - 1, - 1, - 1); - - // register scorers to the multifunctionnal detector - m_FirstStageScorer ->RegisterPrimitive(GPDScorerFirstStage); - m_SecondStageScorer ->RegisterPrimitive(GPDScorerSecondStage); - m_ThirdStageScorer ->RegisterPrimitive(GPDScorerThirdStage); - - - -/* - // First stage Associate Scorer - G4VPrimitiveScorer* DetNbr = new OBSOLETEGENERALSCORERS::PSDetectorNumber("DetectorNumber", "GPDAnnular", 0); - G4VPrimitiveScorer* TOF = new OBSOLETEGENERALSCORERS::PSTOF("StripTime","GPDAnnular", 0); - G4VPrimitiveScorer* InteractionCoordinatesX = new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesX("InterCoordX","GPDAnnular", 0); - G4VPrimitiveScorer* InteractionCoordinatesY = new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesY("InterCoordY","GPDAnnular", 0); - G4VPrimitiveScorer* InteractionCoordinatesZ = new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesZ("InterCoordZ","GPDAnnular", 0); - G4VPrimitiveScorer* InteractionCoordinatesAngleTheta = new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesAngleTheta("InterCoordAngTheta","GPDAnnular", 0); - G4VPrimitiveScorer* InteractionCoordinatesAnglePhi = new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesAnglePhi("InterCoordAngPhi","GPDAnnular", 0); - G4VPrimitiveScorer* Energy = new GPDScorerFirstStageEnergy("StripEnergy", "GPDAnnular", 0); - G4VPrimitiveScorer* StripPositionX = new GPDScorerFirstStageFrontStripAnnular("StripNumberX", 0, FirstStageRmax, 128); - G4VPrimitiveScorer* StripPositionY = new GPDScorerFirstStageBackStripAnnular("StripNumberY", 0, FirstStageRmax, 128); - - //and register it to the multifunctionnal detector - m_FirstStageScorer->RegisterPrimitive(DetNbr); - m_FirstStageScorer->RegisterPrimitive(Energy); - m_FirstStageScorer->RegisterPrimitive(TOF); - m_FirstStageScorer->RegisterPrimitive(StripPositionX); - m_FirstStageScorer->RegisterPrimitive(StripPositionY); - m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesX); - m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesY); - m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesZ); - m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesAngleTheta); - m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesAnglePhi); - - // Second stage Associate Scorer - G4VPrimitiveScorer* SecondStageEnergy = new GPDScorerSecondStageEnergy("SecondStageEnergy", "GPDAnnular", 0); - m_SecondStageScorer->RegisterPrimitive(SecondStageEnergy); - - // Third stage Associate Scorer - G4VPrimitiveScorer* ThirdStageEnergy = new GPDScorerThirdStageEnergy("ThirdStageEnergy", "GPDAnnular", 0); - m_ThirdStageScorer->RegisterPrimitive(ThirdStageEnergy); -*/ - // Add All Scorer to the Global Scorer Manager - G4SDManager::GetSDMpointer()->AddNewDetector(m_FirstStageScorer); - G4SDManager::GetSDMpointer()->AddNewDetector(m_SecondStageScorer); - G4SDManager::GetSDMpointer()->AddNewDetector(m_ThirdStageScorer); +void GaspardTrackerAnnular::InitializeScorers() { + // check whether scorers are already defined + bool already_exist = false; + m_FirstStageScorer = NPS::VDetector::CheckScorer("FirstStageScorerGPDAnnular", already_exist); + m_SecondStageScorer = NPS::VDetector::CheckScorer("SecondStageScorerGPDAnnular", already_exist); + m_ThirdStageScorer = NPS::VDetector::CheckScorer("ThirdStageScorerGPDAnnular", already_exist); + if (already_exist) + return; + + // First stage scorer + G4VPrimitiveScorer* GPDScorerFirstStage = + new SILICONSCORERS::PS_Silicon_Annular("GPDAnnularFirstStage", 0, m_FirstStageRmin[0], m_FirstStageRmax[0], + 360 * deg, 0 * deg, NbThetaStrips, NbPhiStrips, 1); + + // Second stage scorer + G4VPrimitiveScorer* GPDScorerSecondStage = new SILICONSCORERS::PS_Silicon_Annular( + "GPDAnnularSecondStage", 0, m_FirstStageRmin[0], m_FirstStageRmax[0], 0 * deg, 360 * deg, 1, 1, 1); + + // Third stage scorer + G4VPrimitiveScorer* GPDScorerThirdStage = new SILICONSCORERS::PS_Silicon_Annular( + "GPDAnnularThirdStage", 0, m_FirstStageRmin[0], m_FirstStageRmax[0], 0 * deg, 360 * deg, 1, 1, 1); + + // register scorers to the multifunctionnal detector + m_FirstStageScorer->RegisterPrimitive(GPDScorerFirstStage); + m_SecondStageScorer->RegisterPrimitive(GPDScorerSecondStage); + m_ThirdStageScorer->RegisterPrimitive(GPDScorerThirdStage); + + /* + // First stage Associate Scorer + G4VPrimitiveScorer* DetNbr = new + OBSOLETEGENERALSCORERS::PSDetectorNumber("DetectorNumber", "GPDAnnular", 0); G4VPrimitiveScorer* TOF = new + OBSOLETEGENERALSCORERS::PSTOF("StripTime","GPDAnnular", 0); G4VPrimitiveScorer* InteractionCoordinatesX = + new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesX("InterCoordX","GPDAnnular", 0); G4VPrimitiveScorer* + InteractionCoordinatesY = new + OBSOLETEGENERALSCORERS::PSInteractionCoordinatesY("InterCoordY","GPDAnnular", 0); G4VPrimitiveScorer* + InteractionCoordinatesZ = new + OBSOLETEGENERALSCORERS::PSInteractionCoordinatesZ("InterCoordZ","GPDAnnular", 0); G4VPrimitiveScorer* + InteractionCoordinatesAngleTheta = new + OBSOLETEGENERALSCORERS::PSInteractionCoordinatesAngleTheta("InterCoordAngTheta","GPDAnnular", 0); + G4VPrimitiveScorer* InteractionCoordinatesAnglePhi = new + OBSOLETEGENERALSCORERS::PSInteractionCoordinatesAnglePhi("InterCoordAngPhi","GPDAnnular", 0); G4VPrimitiveScorer* + Energy = new GPDScorerFirstStageEnergy("StripEnergy", "GPDAnnular", 0); + G4VPrimitiveScorer* StripPositionX = new GPDScorerFirstStageFrontStripAnnular("StripNumberX", 0, + FirstStageRmax, 128); G4VPrimitiveScorer* StripPositionY = new + GPDScorerFirstStageBackStripAnnular("StripNumberY", 0, FirstStageRmax, 128); + + //and register it to the multifunctionnal detector + m_FirstStageScorer->RegisterPrimitive(DetNbr); + m_FirstStageScorer->RegisterPrimitive(Energy); + m_FirstStageScorer->RegisterPrimitive(TOF); + m_FirstStageScorer->RegisterPrimitive(StripPositionX); + m_FirstStageScorer->RegisterPrimitive(StripPositionY); + m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesX); + m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesY); + m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesZ); + m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesAngleTheta); + m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesAnglePhi); + + // Second stage Associate Scorer + G4VPrimitiveScorer* SecondStageEnergy = new GPDScorerSecondStageEnergy("SecondStageEnergy", "GPDAnnular", 0); + m_SecondStageScorer->RegisterPrimitive(SecondStageEnergy); + + // Third stage Associate Scorer + G4VPrimitiveScorer* ThirdStageEnergy = new GPDScorerThirdStageEnergy("ThirdStageEnergy", "GPDAnnular", 0); + m_ThirdStageScorer->RegisterPrimitive(ThirdStageEnergy); + */ + // Add All Scorer to the Global Scorer Manager + G4SDManager::GetSDMpointer()->AddNewDetector(m_FirstStageScorer); + G4SDManager::GetSDMpointer()->AddNewDetector(m_SecondStageScorer); + G4SDManager::GetSDMpointer()->AddNewDetector(m_ThirdStageScorer); } diff --git a/NPSimulation/Detectors/GASPARD/GaspardTrackerDummyShape.cc b/NPSimulation/Detectors/GASPARD/GaspardTrackerDummyShape.cc index 2e3118bf8a731de52e0a3047b34d101733c6c65e..68f5f79afe49d74a88d473ce77d381dcc0b84118 100644 --- a/NPSimulation/Detectors/GASPARD/GaspardTrackerDummyShape.cc +++ b/NPSimulation/Detectors/GASPARD/GaspardTrackerDummyShape.cc @@ -28,38 +28,38 @@ *****************************************************************************/ // C++ headers +#include <cmath> #include <sstream> #include <string> -#include <cmath> // G4 Geometry headers -#include "G4Trd.hh" #include "G4Box.hh" #include "G4Trap.hh" +#include "G4Trd.hh" // G4 various headers -#include "G4MaterialTable.hh" +#include "G4Colour.hh" #include "G4Element.hh" #include "G4ElementTable.hh" -#include "G4VisAttributes.hh" -#include "G4Colour.hh" +#include "G4MaterialTable.hh" +#include "G4PVDivision.hh" +#include "G4PVPlacement.hh" #include "G4RotationMatrix.hh" #include "G4Transform3D.hh" -#include "G4PVPlacement.hh" -#include "G4PVDivision.hh" +#include "G4VisAttributes.hh" // G4 sensitive -#include "G4SDManager.hh" #include "G4MultiFunctionalDetector.hh" +#include "G4SDManager.hh" // NPTool headers -#include "GaspardTrackerDummyShape.hh" -#include "ObsoleteGeneralScorers.hh" #include "GaspardScorers.hh" -#include "RootOutput.h" -#include "NPSVDetector.hh" +#include "GaspardTrackerDummyShape.hh" #include "NPOptionManager.h" #include "NPSDetectorFactory.hh" +#include "NPSVDetector.hh" +#include "ObsoleteGeneralScorers.hh" +#include "RootOutput.h" // CLHEP #include "CLHEP/Random/RandGauss.h" @@ -69,751 +69,698 @@ using namespace CLHEP; using namespace GPDDUMMYSHAPE; using namespace GPDSCORERS; - - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -GaspardTrackerDummyShape::GaspardTrackerDummyShape() -{ - ms_InterCoord = 0; -} - - +GaspardTrackerDummyShape::GaspardTrackerDummyShape() { ms_InterCoord = 0; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -GaspardTrackerDummyShape::~GaspardTrackerDummyShape() -{ -} - - +GaspardTrackerDummyShape::~GaspardTrackerDummyShape() {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void GaspardTrackerDummyShape::AddModule(G4ThreeVector X1_Y1 , - G4ThreeVector X128_Y1 , - G4ThreeVector X1_Y128 , - G4ThreeVector X128_Y128 , - bool wFirstStage , - bool wSecondStage , - bool wThirdStage) -{ - m_DefinitionType.push_back(true) ; - - m_X1_Y1.push_back(X1_Y1) ; - m_X128_Y1.push_back(X128_Y1) ; - m_X1_Y128.push_back(X1_Y128) ; - m_X128_Y128.push_back(X128_Y128) ; - - m_R.push_back(0) ; - m_Theta.push_back(0) ; - m_Phi.push_back(0) ; - m_beta_u.push_back(0) ; - m_beta_v.push_back(0) ; - m_beta_w.push_back(0) ; - - m_wFirstStage.push_back(wFirstStage) ; - m_wSecondStage.push_back(wSecondStage) ; - m_wThirdStage.push_back(wThirdStage) ; - -// m_wNumberStrip.push_back(wNumberStrip); +void GaspardTrackerDummyShape::AddModule(G4ThreeVector X1_Y1, G4ThreeVector X128_Y1, G4ThreeVector X1_Y128, + G4ThreeVector X128_Y128, bool wFirstStage, bool wSecondStage, + bool wThirdStage) { + m_DefinitionType.push_back(true); + + m_X1_Y1.push_back(X1_Y1); + m_X128_Y1.push_back(X128_Y1); + m_X1_Y128.push_back(X1_Y128); + m_X128_Y128.push_back(X128_Y128); + + m_R.push_back(0); + m_Theta.push_back(0); + m_Phi.push_back(0); + m_beta_u.push_back(0); + m_beta_v.push_back(0); + m_beta_w.push_back(0); + + m_wFirstStage.push_back(wFirstStage); + m_wSecondStage.push_back(wSecondStage); + m_wThirdStage.push_back(wThirdStage); + + // m_wNumberStrip.push_back(wNumberStrip); } - - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void GaspardTrackerDummyShape::AddModule(G4double R , - G4double Theta , - G4double Phi , - G4double beta_u , - G4double beta_v , - G4double beta_w , - bool wFirstStage , - bool wSecondStage , - bool wThirdStage) -{ - G4ThreeVector empty = G4ThreeVector(0, 0, 0); - - m_DefinitionType.push_back(false); - - m_X1_Y1.push_back(empty) ; - m_X128_Y1.push_back(empty) ; - m_X1_Y128.push_back(empty) ; - m_X128_Y128.push_back(empty) ; - - m_R.push_back(R) ; - m_Theta.push_back(Theta) ; - m_Phi.push_back(Phi) ; - m_beta_u.push_back(beta_u) ; - m_beta_v.push_back(beta_v) ; - m_beta_w.push_back(beta_w) ; - - m_wFirstStage.push_back(wFirstStage) ; - m_wSecondStage.push_back(wSecondStage) ; - m_wThirdStage.push_back(wThirdStage) ; +void GaspardTrackerDummyShape::AddModule(G4double R, G4double Theta, G4double Phi, G4double beta_u, G4double beta_v, + G4double beta_w, bool wFirstStage, bool wSecondStage, bool wThirdStage) { + G4ThreeVector empty = G4ThreeVector(0, 0, 0); + + m_DefinitionType.push_back(false); + + m_X1_Y1.push_back(empty); + m_X128_Y1.push_back(empty); + m_X1_Y128.push_back(empty); + m_X128_Y128.push_back(empty); + + m_R.push_back(R); + m_Theta.push_back(Theta); + m_Phi.push_back(Phi); + m_beta_u.push_back(beta_u); + m_beta_v.push_back(beta_v); + m_beta_w.push_back(beta_w); + + m_wFirstStage.push_back(wFirstStage); + m_wSecondStage.push_back(wSecondStage); + m_wThirdStage.push_back(wThirdStage); } - - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void GaspardTrackerDummyShape::VolumeMaker(G4int DetectorNumber, - G4ThreeVector MMpos, - G4RotationMatrix* MMrot, - bool wFirstStage, - bool wSecondStage, - bool wThirdStage, - G4LogicalVolume* world) -{ - G4double NbrTelescopes = DetectorNumber ; - G4String DetNumber ; - ostringstream Number ; - Number << NbrTelescopes ; - DetNumber = Number.str() ; - - ///////////////////////////////////////////////////////////////// - ////////////// Starting Volume Definition ////////////////////// - //////////////////////////////////////////////////////////////// - G4String Name = "GPDDummyShape" + DetNumber ; - - G4Box* solidGPDDummyShape = new G4Box(Name, 0.5*FaceFront, 0.5*FaceFront, 0.5*Length); - G4LogicalVolume* logicGPDDummyShape = new G4LogicalVolume(solidGPDDummyShape, m_MaterialVacuum, Name, 0, 0, 0); - - new G4PVPlacement(G4Transform3D(*MMrot, MMpos) , - logicGPDDummyShape , - Name , - world , - false , - DetectorNumber); - - logicGPDDummyShape->SetVisAttributes(G4VisAttributes::Invisible); - if (m_non_sensitive_part_visiualisation) logicGPDDummyShape->SetVisAttributes(G4VisAttributes(G4Colour(0.90, 0.90, 0.90))); - - //Place two marker to identify the u and v axis on silicon face: - //marker are placed a bit before the silicon itself so they don't perturbate simulation - //Uncomment to help debugging or if you want to understand the way the code work. - //I should recommand to Comment it during simulation to avoid perturbation of simulation - //Remember G4 is limitationg step on geometry constraints. - G4ThreeVector positionMarkerU = MMCenter*0.8 + MMu*FirstStageFace/4; - G4Box* solidMarkerU = new G4Box("solidMarkerU", FirstStageFace/4, 1*mm, 1*mm); - G4LogicalVolume* logicMarkerU = new G4LogicalVolume(solidMarkerU, m_MaterialVacuum, "logicMarkerU", 0, 0, 0); - new G4PVPlacement(G4Transform3D(*MMrot,positionMarkerU), logicMarkerU, "MarkerU", world, false, 0); - - G4VisAttributes* MarkerUVisAtt= new G4VisAttributes(G4Colour(0.,0.,0.5)); //blue - logicMarkerU->SetVisAttributes(MarkerUVisAtt); - - G4ThreeVector positionMarkerV = MMCenter*0.8 + MMv*FirstStageFace/4; - G4Box* solidMarkerV = new G4Box("solidMarkerU", 1*mm, FirstStageFace/4, 1*mm); - G4LogicalVolume* logicMarkerV = new G4LogicalVolume(solidMarkerV, m_MaterialVacuum, "logicMarkerV", 0, 0, 0); - new G4PVPlacement(G4Transform3D(*MMrot,positionMarkerV), logicMarkerV, "MarkerV", world, false, 0); - - G4VisAttributes* MarkerVVisAtt= new G4VisAttributes(G4Colour(0.,0.5,0.)); //green - logicMarkerV->SetVisAttributes(MarkerVVisAtt); - - //////////////////////////////////////////////////////////////// - ///////////////// First Stage Construction ///////////////////// - //////////////////////////////////////////////////////////////// - if (wFirstStage) { - // Dead layers -/* G4ThreeVector positionFirstStageDLFront = G4ThreeVector(0, 0, FirstStage_DL_Front_PosZ); - G4ThreeVector positionFirstStageDLBack = G4ThreeVector(0, 0, FirstStage_DL_Back_PosZ); - - G4Box* solidFirstStageDL = new G4Box("solidFirstStageDL", 0.5*FirstStageFace, 0.5*FirstStageFace, 0.5*FirstStageDeadLayer); - G4LogicalVolume* logicFirstStageDL = new G4LogicalVolume(solidFirstStageDL, Aluminium, "logicFirstStageDL", 0, 0, 0); - - PVPBuffer = new G4PVPlacement(0, positionFirstStageDLFront, logicFirstStageDL, Name + "_DLFront", logicGPDDummyShape, false, 0); - PVPBuffer = new G4PVPlacement(0, positionFirstStageDLBack, logicFirstStageDL, Name + "_DLBack", logicGPDDummyShape, false, 0); - - logicFirstStageDL->SetVisAttributes(G4VisAttributes::Invisible); -*/ - - // Silicon detector itself - G4ThreeVector positionFirstStage = G4ThreeVector(0, 0, FirstStage_PosZ); - - G4Box* solidFirstStage = new G4Box("solidFirstStage", 0.5*FirstStageFace, 0.5*FirstStageFace, 0.5*FirstStageThickness); - G4LogicalVolume* logicFirstStage = new G4LogicalVolume(solidFirstStage, m_MaterialSilicon, "logicFirstStage", 0, 0, 0); - - new G4PVPlacement(0, - positionFirstStage, - logicFirstStage, - Name + "_FirstStage", - logicGPDDummyShape, - false, - DetectorNumber); - - // Set First Stage sensible - logicFirstStage->SetSensitiveDetector(m_FirstStageScorer); - - ///Visualisation of FirstStage Strip - G4VisAttributes* FirstStageVisAtt = new G4VisAttributes(G4Colour(0.0, 0.0, 0.9)); // blue - logicFirstStage->SetVisAttributes(FirstStageVisAtt); - } - - //////////////////////////////////////////////////////////////// - //////////////////// Second Stage Construction //////////////// - //////////////////////////////////////////////////////////////// - if (wSecondStage) { - // Dead layers -/* G4ThreeVector positionSecondStageDLFront = G4ThreeVector(0, 0, SecondStage_DL_Front_PosZ); - G4ThreeVector positionSecondStageDLBack = G4ThreeVector(0, 0, SecondStage_DL_Back_PosZ); - - G4Box* solidSecondStageDL = new G4Box("solidSecondStageDL", 0.5*SecondStageFace, 0.5*SecondStageFace, 0.5*SecondStageDeadLayer); - G4LogicalVolume* logicSecondStageDL = new G4LogicalVolume(solidSecondStageDL, Aluminium, "logicSecondStageDL", 0, 0, 0); - - PVPBuffer = new G4PVPlacement(0, positionSecondStageDLFront, logicSecondStageDL, Name + "_DLFront", logicGPDDummyShape, false, 0); - PVPBuffer = new G4PVPlacement(0, positionSecondStageDLBack, logicSecondStageDL, Name + "_DLBack", logicGPDDummyShape, false, 0); - - logicSecondStageDL->SetVisAttributes(G4VisAttributes::Invisible); -*/ - - // Second stage silicon detector - G4ThreeVector positionSecondStage = G4ThreeVector(0, 0, SecondStage_PosZ); - - G4Box* solidSecondStage = new G4Box("solidSecondStage", 0.5*SecondStageFace, 0.5*SecondStageFace, 0.5*SecondStageThickness); - G4LogicalVolume* logicSecondStage = new G4LogicalVolume(solidSecondStage, m_MaterialSilicon, "logicSecondStage", 0, 0, 0); - - new G4PVPlacement(0, - positionSecondStage, - logicSecondStage, - Name + "_SecondStage", - logicGPDDummyShape, - false, - DetectorNumber); - - // Set Second Stage sensible - logicSecondStage->SetSensitiveDetector(m_SecondStageScorer); - - ///Visualisation of SecondStage Strip - G4VisAttributes* SecondStageVisAtt = new G4VisAttributes(G4Colour(0.5, 0.5, 0.5)); - logicSecondStage->SetVisAttributes(SecondStageVisAtt); - } - - //////////////////////////////////////////////////////////////// - ///////////////// Third Stage Construction ///////////////////// - //////////////////////////////////////////////////////////////// - if (wThirdStage) { - // Dead layers -/* G4ThreeVector positionThirdStageDLFront = G4ThreeVector(0, 0, ThirdStage_DL_Front_PosZ); - G4ThreeVector positionThirdStageDLBack = G4ThreeVector(0, 0, ThirdStage_DL_Back_PosZ); - - G4Box* solidThirdStageDL = new G4Box("solidThirdStageDL", 0.5*ThirdStageFace, 0.5*ThirdStageFace, 0.5*ThirdStageDeadLayer); - G4LogicalVolume* logicThirdStageDL = new G4LogicalVolume(solidThirdStageDL, Aluminium, "logicThirdStageDL", 0, 0, 0); - - PVPBuffer = new G4PVPlacement(0, positionThirdStageDLFront, logicThirdStageDL, Name + "_DLFront", logicGPDDummyShape, false, 0); - PVPBuffer = new G4PVPlacement(0, positionThirdStageDLBack, logicThirdStageDL, Name + "_DLBack", logicGPDDummyShape, false, 0); - - logicThirdStageDL->SetVisAttributes(G4VisAttributes::Invisible); -*/ - - // Third stage silicon detector - G4ThreeVector positionThirdStage = G4ThreeVector(0, 0, ThirdStage_PosZ); - - G4Box* solidThirdStage = new G4Box("solidThirdStage", 0.5*ThirdStageFace, 0.5*ThirdStageFace, 0.5*ThirdStageThickness); - G4LogicalVolume* logicThirdStage = new G4LogicalVolume(solidThirdStage, m_MaterialSilicon, "logicThirdStage", 0, 0, 0); - - new G4PVPlacement(0, - positionThirdStage, - logicThirdStage, - Name + "_ThirdStage", - logicGPDDummyShape, - false, - DetectorNumber); - - // Set Third Stage sensible - logicThirdStage->SetSensitiveDetector(m_ThirdStageScorer); - - ///Visualisation of Third Stage - G4VisAttributes* ThirdStageVisAtt = new G4VisAttributes(G4Colour(0.0, 0.9, 0.0)); // green - logicThirdStage->SetVisAttributes(ThirdStageVisAtt); - } +void GaspardTrackerDummyShape::VolumeMaker(G4int DetectorNumber, G4ThreeVector MMpos, G4RotationMatrix* MMrot, + bool wFirstStage, bool wSecondStage, bool wThirdStage, + G4LogicalVolume* world) { + G4double NbrTelescopes = DetectorNumber; + G4String DetNumber; + ostringstream Number; + Number << NbrTelescopes; + DetNumber = Number.str(); + + ///////////////////////////////////////////////////////////////// + ////////////// Starting Volume Definition ////////////////////// + //////////////////////////////////////////////////////////////// + G4String Name = "GPDDummyShape" + DetNumber; + + G4Box* solidGPDDummyShape = new G4Box(Name, 0.5 * FaceFront, 0.5 * FaceFront, 0.5 * Length); + G4LogicalVolume* logicGPDDummyShape = new G4LogicalVolume(solidGPDDummyShape, m_MaterialVacuum, Name, 0, 0, 0); + + new G4PVPlacement(G4Transform3D(*MMrot, MMpos), logicGPDDummyShape, Name, world, false, DetectorNumber); + + logicGPDDummyShape->SetVisAttributes(G4VisAttributes::GetInvisible()); + if (m_non_sensitive_part_visiualisation) + logicGPDDummyShape->SetVisAttributes(G4VisAttributes(G4Colour(0.90, 0.90, 0.90))); + + // Place two marker to identify the u and v axis on silicon face: + // marker are placed a bit before the silicon itself so they don't perturbate simulation + // Uncomment to help debugging or if you want to understand the way the code work. + // I should recommand to Comment it during simulation to avoid perturbation of simulation + // Remember G4 is limitationg step on geometry constraints. + G4ThreeVector positionMarkerU = MMCenter * 0.8 + MMu * FirstStageFace / 4; + G4Box* solidMarkerU = new G4Box("solidMarkerU", FirstStageFace / 4, 1 * mm, 1 * mm); + G4LogicalVolume* logicMarkerU = new G4LogicalVolume(solidMarkerU, m_MaterialVacuum, "logicMarkerU", 0, 0, 0); + new G4PVPlacement(G4Transform3D(*MMrot, positionMarkerU), logicMarkerU, "MarkerU", world, false, 0); + + G4VisAttributes* MarkerUVisAtt = new G4VisAttributes(G4Colour(0., 0., 0.5)); // blue + logicMarkerU->SetVisAttributes(MarkerUVisAtt); + + G4ThreeVector positionMarkerV = MMCenter * 0.8 + MMv * FirstStageFace / 4; + G4Box* solidMarkerV = new G4Box("solidMarkerU", 1 * mm, FirstStageFace / 4, 1 * mm); + G4LogicalVolume* logicMarkerV = new G4LogicalVolume(solidMarkerV, m_MaterialVacuum, "logicMarkerV", 0, 0, 0); + new G4PVPlacement(G4Transform3D(*MMrot, positionMarkerV), logicMarkerV, "MarkerV", world, false, 0); + + G4VisAttributes* MarkerVVisAtt = new G4VisAttributes(G4Colour(0., 0.5, 0.)); // green + logicMarkerV->SetVisAttributes(MarkerVVisAtt); + + //////////////////////////////////////////////////////////////// + ///////////////// First Stage Construction ///////////////////// + //////////////////////////////////////////////////////////////// + if (wFirstStage) { + // Dead layers + /* G4ThreeVector positionFirstStageDLFront = G4ThreeVector(0, 0, FirstStage_DL_Front_PosZ); + G4ThreeVector positionFirstStageDLBack = G4ThreeVector(0, 0, FirstStage_DL_Back_PosZ); + + G4Box* solidFirstStageDL = new G4Box("solidFirstStageDL", 0.5*FirstStageFace, 0.5*FirstStageFace, + 0.5*FirstStageDeadLayer); G4LogicalVolume* logicFirstStageDL = new G4LogicalVolume(solidFirstStageDL, Aluminium, + "logicFirstStageDL", 0, 0, 0); + + PVPBuffer = new G4PVPlacement(0, positionFirstStageDLFront, logicFirstStageDL, Name + "_DLFront", + logicGPDDummyShape, false, 0); PVPBuffer = new G4PVPlacement(0, positionFirstStageDLBack, logicFirstStageDL, + Name + "_DLBack", logicGPDDummyShape, false, 0); + + logicFirstStageDL->SetVisAttributes(G4VisAttributes::GetInvisible()); + */ + + // Silicon detector itself + G4ThreeVector positionFirstStage = G4ThreeVector(0, 0, FirstStage_PosZ); + + G4Box* solidFirstStage = + new G4Box("solidFirstStage", 0.5 * FirstStageFace, 0.5 * FirstStageFace, 0.5 * FirstStageThickness); + G4LogicalVolume* logicFirstStage = + new G4LogicalVolume(solidFirstStage, m_MaterialSilicon, "logicFirstStage", 0, 0, 0); + + new G4PVPlacement(0, positionFirstStage, logicFirstStage, Name + "_FirstStage", logicGPDDummyShape, false, + DetectorNumber); + + // Set First Stage sensible + logicFirstStage->SetSensitiveDetector(m_FirstStageScorer); + + /// Visualisation of FirstStage Strip + G4VisAttributes* FirstStageVisAtt = new G4VisAttributes(G4Colour(0.0, 0.0, 0.9)); // blue + logicFirstStage->SetVisAttributes(FirstStageVisAtt); + } + + //////////////////////////////////////////////////////////////// + //////////////////// Second Stage Construction //////////////// + //////////////////////////////////////////////////////////////// + if (wSecondStage) { + // Dead layers + /* G4ThreeVector positionSecondStageDLFront = G4ThreeVector(0, 0, SecondStage_DL_Front_PosZ); + G4ThreeVector positionSecondStageDLBack = G4ThreeVector(0, 0, SecondStage_DL_Back_PosZ); + + G4Box* solidSecondStageDL = new G4Box("solidSecondStageDL", 0.5*SecondStageFace, + 0.5*SecondStageFace, 0.5*SecondStageDeadLayer); G4LogicalVolume* logicSecondStageDL = new + G4LogicalVolume(solidSecondStageDL, Aluminium, "logicSecondStageDL", 0, 0, 0); + + PVPBuffer = new G4PVPlacement(0, positionSecondStageDLFront, logicSecondStageDL, Name + "_DLFront", + logicGPDDummyShape, false, 0); PVPBuffer = new G4PVPlacement(0, positionSecondStageDLBack, logicSecondStageDL, + Name + "_DLBack", logicGPDDummyShape, false, 0); + + logicSecondStageDL->SetVisAttributes(G4VisAttributes::GetInvisible()); + */ + + // Second stage silicon detector + G4ThreeVector positionSecondStage = G4ThreeVector(0, 0, SecondStage_PosZ); + + G4Box* solidSecondStage = + new G4Box("solidSecondStage", 0.5 * SecondStageFace, 0.5 * SecondStageFace, 0.5 * SecondStageThickness); + G4LogicalVolume* logicSecondStage = + new G4LogicalVolume(solidSecondStage, m_MaterialSilicon, "logicSecondStage", 0, 0, 0); + + new G4PVPlacement(0, positionSecondStage, logicSecondStage, Name + "_SecondStage", logicGPDDummyShape, false, + DetectorNumber); + + // Set Second Stage sensible + logicSecondStage->SetSensitiveDetector(m_SecondStageScorer); + + /// Visualisation of SecondStage Strip + G4VisAttributes* SecondStageVisAtt = new G4VisAttributes(G4Colour(0.5, 0.5, 0.5)); + logicSecondStage->SetVisAttributes(SecondStageVisAtt); + } + + //////////////////////////////////////////////////////////////// + ///////////////// Third Stage Construction ///////////////////// + //////////////////////////////////////////////////////////////// + if (wThirdStage) { + // Dead layers + /* G4ThreeVector positionThirdStageDLFront = G4ThreeVector(0, 0, ThirdStage_DL_Front_PosZ); + G4ThreeVector positionThirdStageDLBack = G4ThreeVector(0, 0, ThirdStage_DL_Back_PosZ); + + G4Box* solidThirdStageDL = new G4Box("solidThirdStageDL", 0.5*ThirdStageFace, 0.5*ThirdStageFace, + 0.5*ThirdStageDeadLayer); G4LogicalVolume* logicThirdStageDL = new G4LogicalVolume(solidThirdStageDL, Aluminium, + "logicThirdStageDL", 0, 0, 0); + + PVPBuffer = new G4PVPlacement(0, positionThirdStageDLFront, logicThirdStageDL, Name + "_DLFront", + logicGPDDummyShape, false, 0); PVPBuffer = new G4PVPlacement(0, positionThirdStageDLBack, logicThirdStageDL, + Name + "_DLBack", logicGPDDummyShape, false, 0); + + logicThirdStageDL->SetVisAttributes(G4VisAttributes::GetInvisible()); + */ + + // Third stage silicon detector + G4ThreeVector positionThirdStage = G4ThreeVector(0, 0, ThirdStage_PosZ); + + G4Box* solidThirdStage = + new G4Box("solidThirdStage", 0.5 * ThirdStageFace, 0.5 * ThirdStageFace, 0.5 * ThirdStageThickness); + G4LogicalVolume* logicThirdStage = + new G4LogicalVolume(solidThirdStage, m_MaterialSilicon, "logicThirdStage", 0, 0, 0); + + new G4PVPlacement(0, positionThirdStage, logicThirdStage, Name + "_ThirdStage", logicGPDDummyShape, false, + DetectorNumber); + + // Set Third Stage sensible + logicThirdStage->SetSensitiveDetector(m_ThirdStageScorer); + + /// Visualisation of Third Stage + G4VisAttributes* ThirdStageVisAtt = new G4VisAttributes(G4Colour(0.0, 0.9, 0.0)); // green + logicThirdStage->SetVisAttributes(ThirdStageVisAtt); + } } - - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Virtual Method of NPS::VDetector class // Read stream at Configfile to pick-up parameters of detector (Position,...) // Called in DetecorConstruction::ReadDetextorConfiguration Method -void GaspardTrackerDummyShape::ReadConfiguration(NPL::InputParser parser){ +void GaspardTrackerDummyShape::ReadConfiguration(NPL::InputParser parser) { vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithToken("GaspardTracker"); - vector<string> token_cart= {"X1_Y1","X128_Y1","X1_Y128","X128_Y128"}; - vector<string> token_sphe= {"R","THETA","PHI","BETA"}; + vector<string> token_cart = {"X1_Y1", "X128_Y1", "X1_Y128", "X128_Y128"}; + vector<string> token_sphe = {"R", "THETA", "PHI", "BETA"}; - vector<string> token={"FIRSTSTAGE","SECONDSTAGE","THIRDSTAGE"}; + vector<string> token = {"FIRSTSTAGE", "SECONDSTAGE", "THIRDSTAGE"}; - for(unsigned int i = 0 ; i < blocks.size() ; i++){ - if(blocks[i]->GetMainValue() == "DummyShape" && blocks[i]->HasTokenList(token) ){ - cout << "Gaspard Dummy Shape " << i+1 << ":" << endl; + for (unsigned int i = 0; i < blocks.size(); i++) { + if (blocks[i]->GetMainValue() == "DummyShape" && blocks[i]->HasTokenList(token)) { + cout << "Gaspard Dummy Shape " << i + 1 << ":" << endl; - bool first = blocks[i]->GetInt("FIRSTSTAGE"); bool second = blocks[i]->GetInt("SECONDSTAGE"); bool third = blocks[i]->GetInt("THIRDSTAGE"); - if(blocks[i]->HasToken("VIS")) - m_non_sensitive_part_visiualisation = blocks[i]->GetInt("VIS"); + if (blocks[i]->HasToken("VIS")) + m_non_sensitive_part_visiualisation = blocks[i]->GetInt("VIS"); - if(blocks[i]->HasTokenList(token_cart)){ + if (blocks[i]->HasTokenList(token_cart)) { // Add module - G4ThreeVector A = NPS::ConvertVector(blocks[i]->GetTVector3("X1_Y1","mm")); - G4ThreeVector B = NPS::ConvertVector(blocks[i]->GetTVector3("X128_Y1","mm")); - G4ThreeVector C = NPS::ConvertVector(blocks[i]->GetTVector3("X1_Y128","mm")); - G4ThreeVector D = NPS::ConvertVector(blocks[i]->GetTVector3("X128_Y128","mm")); - - AddModule(A,B,C,D,first,second,third); + G4ThreeVector A = NPS::ConvertVector(blocks[i]->GetTVector3("X1_Y1", "mm")); + G4ThreeVector B = NPS::ConvertVector(blocks[i]->GetTVector3("X128_Y1", "mm")); + G4ThreeVector C = NPS::ConvertVector(blocks[i]->GetTVector3("X1_Y128", "mm")); + G4ThreeVector D = NPS::ConvertVector(blocks[i]->GetTVector3("X128_Y128", "mm")); + + AddModule(A, B, C, D, first, second, third); } - else if(blocks[i]->HasTokenList(token_sphe)){ + else if (blocks[i]->HasTokenList(token_sphe)) { // Add module - double R = blocks[i]->GetDouble("R","mm"); - double Theta = blocks[i]->GetDouble("THETA","deg"); - double Phi = blocks[i]->GetDouble("PHI","deg"); - vector<double> beta = blocks[i]->GetVectorDouble("BETA","deg"); - - AddModule(R,Theta,Phi,beta[0],beta[1],beta[2],first,second,third); + double R = blocks[i]->GetDouble("R", "mm"); + double Theta = blocks[i]->GetDouble("THETA", "deg"); + double Phi = blocks[i]->GetDouble("PHI", "deg"); + vector<double> beta = blocks[i]->GetVectorDouble("BETA", "deg"); + + AddModule(R, Theta, Phi, beta[0], beta[1], beta[2], first, second, third); } } - } + } } // Construct detector and inialise sensitive part. // Called After DetecorConstruction::AddDetector Method -void GaspardTrackerDummyShape::ConstructDetector(G4LogicalVolume* world) -{ - G4RotationMatrix* MMrot = NULL ; - G4ThreeVector MMpos = G4ThreeVector(0, 0, 0) ; -// G4ThreeVector MMu = G4ThreeVector(0, 0, 0) ; -// G4ThreeVector MMv = G4ThreeVector(0, 0, 0) ; - G4ThreeVector MMw = G4ThreeVector(0, 0, 0) ; -// G4ThreeVector MMCenter = G4ThreeVector(0, 0, 0) ; - bool FirstStage = true ; - bool SecondStage = true ; - bool ThirdStage = true ; - - G4int NumberOfTelescope = m_DefinitionType.size() ; - - for (G4int i = 0; i < NumberOfTelescope; i++) { - // By Point - if (m_DefinitionType[i]) { - // (u,v,w) unitary vector associated to telescope referencial - // (u,v) // to silicon plan - // w perpendicular to (u,v) plan and pointing ThirdStage - MMu = m_X128_Y1[i] - m_X1_Y1[i]; - MMu = MMu.unit(); - - MMv = m_X1_Y128[i] - m_X1_Y1[i]; - MMv = MMv.unit(); - MMw = MMu.cross(MMv); - MMw = MMw.unit(); - - MMCenter = (m_X1_Y1[i] + m_X1_Y128[i] + m_X128_Y1[i] + m_X128_Y128[i]) / 4; - - // Passage Matrix from Lab Referential to Telescope Referential - MMrot = new G4RotationMatrix(MMu, MMv, MMw); - // translation to place Telescope - MMpos = MMw * Length * 0.5 + MMCenter; - } +void GaspardTrackerDummyShape::ConstructDetector(G4LogicalVolume* world) { + G4RotationMatrix* MMrot = NULL; + G4ThreeVector MMpos = G4ThreeVector(0, 0, 0); + // G4ThreeVector MMu = G4ThreeVector(0, 0, 0) ; + // G4ThreeVector MMv = G4ThreeVector(0, 0, 0) ; + G4ThreeVector MMw = G4ThreeVector(0, 0, 0); + // G4ThreeVector MMCenter = G4ThreeVector(0, 0, 0) ; + bool FirstStage = true; + bool SecondStage = true; + bool ThirdStage = true; + + G4int NumberOfTelescope = m_DefinitionType.size(); + + for (G4int i = 0; i < NumberOfTelescope; i++) { + // By Point + if (m_DefinitionType[i]) { + // (u,v,w) unitary vector associated to telescope referencial + // (u,v) // to silicon plan + // w perpendicular to (u,v) plan and pointing ThirdStage + MMu = m_X128_Y1[i] - m_X1_Y1[i]; + MMu = MMu.unit(); + + MMv = m_X1_Y128[i] - m_X1_Y1[i]; + MMv = MMv.unit(); + MMw = MMu.cross(MMv); + MMw = MMw.unit(); + + MMCenter = (m_X1_Y1[i] + m_X1_Y128[i] + m_X128_Y1[i] + m_X128_Y128[i]) / 4; + + // Passage Matrix from Lab Referential to Telescope Referential + MMrot = new G4RotationMatrix(MMu, MMv, MMw); + // translation to place Telescope + MMpos = MMw * Length * 0.5 + MMCenter; + } - // By Angle - else { - G4double Theta = m_Theta[i] ; - G4double Phi = m_Phi[i] ; - - // (u,v,w) unitary vector associated to telescope referencial - // (u,v) // to silicon plan - // w perpendicular to (u,v) plan and pointing ThirdStage - // Phi is angle between X axis and projection in (X,Y) plan - // Theta is angle between position vector and z axis - G4double wX = m_R[i] * sin(Theta / rad) * cos(Phi / rad); - G4double wY = m_R[i] * sin(Theta / rad) * sin(Phi / rad); - G4double wZ = m_R[i] * cos(Theta / rad); - MMw = G4ThreeVector(wX, wY, wZ); - - // vector corresponding to the center of the module - MMCenter = MMw; - - // vector parallel to one axis of silicon plane - G4double ii = cos(Theta / rad) * cos(Phi / rad); - G4double jj = cos(Theta / rad) * sin(Phi / rad); - G4double kk = -sin(Theta / rad); - G4ThreeVector Y = G4ThreeVector(ii, jj, kk); - - MMw = MMw.unit(); - MMu = MMw.cross(Y); - MMv = MMw.cross(MMu); - MMv = MMv.unit(); - MMu = MMu.unit(); - - // Passage Matrix from Lab Referential to Telescope Referential - MMrot = new G4RotationMatrix(MMu, MMv, MMw); - // Telescope is rotate of Beta angle around MMv axis. - MMrot->rotate(m_beta_u[i], MMu); - MMrot->rotate(m_beta_v[i], MMv); - MMrot->rotate(m_beta_w[i], MMw); - // translation to place Telescope - MMpos = MMw * Length * 0.5 + MMCenter; - } + // By Angle + else { + G4double Theta = m_Theta[i]; + G4double Phi = m_Phi[i]; + + // (u,v,w) unitary vector associated to telescope referencial + // (u,v) // to silicon plan + // w perpendicular to (u,v) plan and pointing ThirdStage + // Phi is angle between X axis and projection in (X,Y) plan + // Theta is angle between position vector and z axis + G4double wX = m_R[i] * sin(Theta / rad) * cos(Phi / rad); + G4double wY = m_R[i] * sin(Theta / rad) * sin(Phi / rad); + G4double wZ = m_R[i] * cos(Theta / rad); + MMw = G4ThreeVector(wX, wY, wZ); + + // vector corresponding to the center of the module + MMCenter = MMw; + + // vector parallel to one axis of silicon plane + G4double ii = cos(Theta / rad) * cos(Phi / rad); + G4double jj = cos(Theta / rad) * sin(Phi / rad); + G4double kk = -sin(Theta / rad); + G4ThreeVector Y = G4ThreeVector(ii, jj, kk); + + MMw = MMw.unit(); + MMu = MMw.cross(Y); + MMv = MMw.cross(MMu); + MMv = MMv.unit(); + MMu = MMu.unit(); + + // Passage Matrix from Lab Referential to Telescope Referential + MMrot = new G4RotationMatrix(MMu, MMv, MMw); + // Telescope is rotate of Beta angle around MMv axis. + MMrot->rotate(m_beta_u[i], MMu); + MMrot->rotate(m_beta_v[i], MMv); + MMrot->rotate(m_beta_w[i], MMw); + // translation to place Telescope + MMpos = MMw * Length * 0.5 + MMCenter; + } - FirstStage = m_wFirstStage[i] ; - SecondStage = m_wSecondStage[i] ; - ThirdStage = m_wThirdStage[i] ; + FirstStage = m_wFirstStage[i]; + SecondStage = m_wSecondStage[i]; + ThirdStage = m_wThirdStage[i]; - VolumeMaker(i + 1, MMpos, MMrot, FirstStage, SecondStage, ThirdStage, world); - } + VolumeMaker(i + 1, MMpos, MMrot, FirstStage, SecondStage, ThirdStage, world); + } - delete MMrot ; + delete MMrot; } - - // Connect the GaspardTrackingData class to the output TTree // of the simulation -void GaspardTrackerDummyShape::InitializeRootOutput() -{ -} +void GaspardTrackerDummyShape::InitializeRootOutput() {} +// Set the TinteractionCoordinates object from NPS::VDetector to the present class +void GaspardTrackerDummyShape::SetInterCoordPointer(TInteractionCoordinates* interCoord) { ms_InterCoord = interCoord; } +// Read sensitive part and fill the Root tree. +// Called at in the EventAction::EndOfEventAvtion +void GaspardTrackerDummyShape::ReadSensitive(const G4Event* event) { + ////////////////////////////////////////////////////////////////////////////////////// + //////////////////////// Used to Read Event Map of detector ////////////////////////// + ////////////////////////////////////////////////////////////////////////////////////// + // First Stage + std::map<G4int, G4int*>::iterator DetectorNumber_itr; + std::map<G4int, G4double*>::iterator Energy_itr; + std::map<G4int, G4double*>::iterator Time_itr; + std::map<G4int, G4int*>::iterator X_itr; + std::map<G4int, G4int*>::iterator Y_itr; + std::map<G4int, G4double*>::iterator Pos_X_itr; + std::map<G4int, G4double*>::iterator Pos_Y_itr; + std::map<G4int, G4double*>::iterator Pos_Z_itr; + std::map<G4int, G4double*>::iterator Ang_Theta_itr; + std::map<G4int, G4double*>::iterator Ang_Phi_itr; + + NPS::HitsMap<G4int>* DetectorNumberHitMap; + NPS::HitsMap<G4double>* EnergyHitMap; + NPS::HitsMap<G4double>* TimeHitMap; + NPS::HitsMap<G4int>* XHitMap; + NPS::HitsMap<G4int>* YHitMap; + NPS::HitsMap<G4double>* PosXHitMap; + NPS::HitsMap<G4double>* PosYHitMap; + NPS::HitsMap<G4double>* PosZHitMap; + NPS::HitsMap<G4double>* AngThetaHitMap; + NPS::HitsMap<G4double>* AngPhiHitMap; + + // NULL pointer are given to avoid warning at compilation + // Second Stage + std::map<G4int, G4double*>::iterator SecondStageEnergy_itr; + NPS::HitsMap<G4double>* SecondStageEnergyHitMap = NULL; + // Third Stage + std::map<G4int, G4double*>::iterator ThirdStageEnergy_itr; + NPS::HitsMap<G4double>* ThirdStageEnergyHitMap = NULL; + + // Read the Scorer associate to the Silicon Strip + // Detector Number + G4int StripDetCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerGPDDummyShape/DetectorNumber"); + DetectorNumberHitMap = (NPS::HitsMap<G4int>*)(event->GetHCofThisEvent()->GetHC(StripDetCollectionID)); + DetectorNumber_itr = DetectorNumberHitMap->GetMap()->begin(); + + // Energy + G4int StripEnergyCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerGPDDummyShape/StripEnergy"); + EnergyHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripEnergyCollectionID)); + Energy_itr = EnergyHitMap->GetMap()->begin(); + + // Time of Flight + G4int StripTimeCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerGPDDummyShape/StripTime"); + TimeHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripTimeCollectionID)); + Time_itr = TimeHitMap->GetMap()->begin(); + + // Strip Number X + G4int StripXCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerGPDDummyShape/StripIDFront"); + XHitMap = (NPS::HitsMap<G4int>*)(event->GetHCofThisEvent()->GetHC(StripXCollectionID)); + X_itr = XHitMap->GetMap()->begin(); + + // Strip Number Y + G4int StripYCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerGPDDummyShape/StripIDBack"); + YHitMap = (NPS::HitsMap<G4int>*)(event->GetHCofThisEvent()->GetHC(StripYCollectionID)); + Y_itr = YHitMap->GetMap()->begin(); + + // Interaction Coordinate X + G4int InterCoordXCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerGPDDummyShape/InterCoordX"); + PosXHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordXCollectionID)); + Pos_X_itr = PosXHitMap->GetMap()->begin(); + + // Interaction Coordinate Y + G4int InterCoordYCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerGPDDummyShape/InterCoordY"); + PosYHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordYCollectionID)); + Pos_Y_itr = PosYHitMap->GetMap()->begin(); + + // Interaction Coordinate Z + G4int InterCoordZCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerGPDDummyShape/InterCoordZ"); + PosZHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordZCollectionID)); + Pos_Z_itr = PosXHitMap->GetMap()->begin(); + + // Interaction Coordinate Angle Theta + G4int InterCoordAngThetaCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerGPDDummyShape/InterCoordAngTheta"); + AngThetaHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordAngThetaCollectionID)); + Ang_Theta_itr = AngThetaHitMap->GetMap()->begin(); + + // Interaction Coordinate Angle Phi + G4int InterCoordAngPhiCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerGPDDummyShape/InterCoordAngPhi"); + AngPhiHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordAngPhiCollectionID)); + Ang_Phi_itr = AngPhiHitMap->GetMap()->begin(); + + // Read the Scorer associate to the SecondStage + // Energy + G4int SecondStageEnergyCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("SecondStageScorerGPDDummyShape/SecondStageEnergy"); + SecondStageEnergyHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(SecondStageEnergyCollectionID)); + SecondStageEnergy_itr = SecondStageEnergyHitMap->GetMap()->begin(); + + // Read the Scorer associate to the ThirdStage + // Energy + G4int ThirdStageEnergyCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("ThirdStageScorerGPDDummyShape/ThirdStageEnergy"); + ThirdStageEnergyHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(ThirdStageEnergyCollectionID)); + ThirdStageEnergy_itr = ThirdStageEnergyHitMap->GetMap()->begin(); + + // Check the size of different map + G4int sizeN = DetectorNumberHitMap->entries(); + G4int sizeE = EnergyHitMap->entries(); + G4int sizeT = TimeHitMap->entries(); + G4int sizeX = XHitMap->entries(); + G4int sizeY = YHitMap->entries(); + + // G4cout << "sizeN:" << sizeN << G4endl; + + if (sizeE != sizeT || sizeT != sizeX || sizeX != sizeY) { + G4cout << "No match size Si Event Map: sE:" << sizeE << " sT:" << sizeT << " sX:" << sizeX << " sY:" << sizeY + << G4endl; + return; + } + + // Loop on FirstStage number + for (G4int l = 0; l < sizeN; l++) { + G4double N = *(DetectorNumber_itr->second); + G4int NTrackID = DetectorNumber_itr->first - N; + + if (N > 0) { + // Fill detector number + ms_Event->SetGPDTrkFirstStageFrontEDetectorNbr(m_index["DummyShape"] + N); + ms_Event->SetGPDTrkFirstStageFrontTDetectorNbr(m_index["DummyShape"] + N); + ms_Event->SetGPDTrkFirstStageBackEDetectorNbr(m_index["DummyShape"] + N); + ms_Event->SetGPDTrkFirstStageBackTDetectorNbr(m_index["DummyShape"] + N); + + // Energy + Energy_itr = EnergyHitMap->GetMap()->begin(); + for (G4int ll = 0; ll < sizeE; ll++) { + G4int ETrackID = Energy_itr->first - N; + G4double E = *(Energy_itr->second); + if (ETrackID == NTrackID) { + ms_Event->SetGPDTrkFirstStageFrontEEnergy(RandGauss::shoot(E, ResoFirstStage)); + ms_Event->SetGPDTrkFirstStageBackEEnergy(RandGauss::shoot(E, ResoFirstStage)); + } + Energy_itr++; + } -// Set the TinteractionCoordinates object from NPS::VDetector to the present class -void GaspardTrackerDummyShape::SetInterCoordPointer(TInteractionCoordinates* interCoord) -{ - ms_InterCoord = interCoord; -} + // 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) { + ms_Event->SetGPDTrkFirstStageFrontTTime(RandGauss::shoot(T, ResoTimeGpd)); + ms_Event->SetGPDTrkFirstStageBackTTime(RandGauss::shoot(T, ResoTimeGpd)); + } + Time_itr++; + } + // Strip X + X_itr = XHitMap->GetMap()->begin(); + for (G4int h = 0; h < sizeX; h++) { + G4int XTrackID = X_itr->first - N; + G4int X = *(X_itr->second); + if (XTrackID == NTrackID) { + ms_Event->SetGPDTrkFirstStageFrontEStripNbr(X); + ms_Event->SetGPDTrkFirstStageFrontTStripNbr(X); + } + X_itr++; + } + // Strip Y + Y_itr = YHitMap->GetMap()->begin(); + for (G4int h = 0; h < sizeY; h++) { + G4int YTrackID = Y_itr->first - N; + G4int Y = *(Y_itr->second); + if (YTrackID == NTrackID) { + ms_Event->SetGPDTrkFirstStageBackEStripNbr(Y); + ms_Event->SetGPDTrkFirstStageBackTStripNbr(Y); + } + Y_itr++; + } -// Read sensitive part and fill the Root tree. -// Called at in the EventAction::EndOfEventAvtion -void GaspardTrackerDummyShape::ReadSensitive(const G4Event* event) -{ - ////////////////////////////////////////////////////////////////////////////////////// - //////////////////////// Used to Read Event Map of detector ////////////////////////// - ////////////////////////////////////////////////////////////////////////////////////// - // First Stage - std::map<G4int, G4int*>::iterator DetectorNumber_itr; - std::map<G4int, G4double*>::iterator Energy_itr; - std::map<G4int, G4double*>::iterator Time_itr; - std::map<G4int, G4int*>::iterator X_itr; - std::map<G4int, G4int*>::iterator Y_itr; - std::map<G4int, G4double*>::iterator Pos_X_itr; - std::map<G4int, G4double*>::iterator Pos_Y_itr; - std::map<G4int, G4double*>::iterator Pos_Z_itr; - std::map<G4int, G4double*>::iterator Ang_Theta_itr; - std::map<G4int, G4double*>::iterator Ang_Phi_itr; - - NPS::HitsMap<G4int>* DetectorNumberHitMap; - NPS::HitsMap<G4double>* EnergyHitMap; - NPS::HitsMap<G4double>* TimeHitMap; - NPS::HitsMap<G4int>* XHitMap; - NPS::HitsMap<G4int>* YHitMap; - NPS::HitsMap<G4double>* PosXHitMap; - NPS::HitsMap<G4double>* PosYHitMap; - NPS::HitsMap<G4double>* PosZHitMap; - NPS::HitsMap<G4double>* AngThetaHitMap; - NPS::HitsMap<G4double>* AngPhiHitMap; - - // NULL pointer are given to avoid warning at compilation - // Second Stage - std::map<G4int, G4double*>::iterator SecondStageEnergy_itr ; - NPS::HitsMap<G4double>* SecondStageEnergyHitMap = NULL ; - // Third Stage - std::map<G4int, G4double*>::iterator ThirdStageEnergy_itr ; - NPS::HitsMap<G4double>* ThirdStageEnergyHitMap = NULL ; - - - // Read the Scorer associate to the Silicon Strip - //Detector Number - G4int StripDetCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerGPDDummyShape/DetectorNumber") ; - DetectorNumberHitMap = (NPS::HitsMap<G4int>*)(event->GetHCofThisEvent()->GetHC(StripDetCollectionID)) ; - DetectorNumber_itr = DetectorNumberHitMap->GetMap()->begin() ; - - //Energy - G4int StripEnergyCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerGPDDummyShape/StripEnergy") ; - EnergyHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripEnergyCollectionID)) ; - Energy_itr = EnergyHitMap->GetMap()->begin() ; - - //Time of Flight - G4int StripTimeCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerGPDDummyShape/StripTime") ; - TimeHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripTimeCollectionID)) ; - Time_itr = TimeHitMap->GetMap()->begin() ; - - //Strip Number X - G4int StripXCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerGPDDummyShape/StripIDFront") ; - XHitMap = (NPS::HitsMap<G4int>*)(event->GetHCofThisEvent()->GetHC(StripXCollectionID)) ; - X_itr = XHitMap->GetMap()->begin() ; - - //Strip Number Y - G4int StripYCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerGPDDummyShape/StripIDBack"); - YHitMap = (NPS::HitsMap<G4int>*)(event->GetHCofThisEvent()->GetHC(StripYCollectionID)) ; - Y_itr = YHitMap->GetMap()->begin() ; - - //Interaction Coordinate X - G4int InterCoordXCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerGPDDummyShape/InterCoordX") ; - PosXHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordXCollectionID)) ; - Pos_X_itr = PosXHitMap->GetMap()->begin() ; - - //Interaction Coordinate Y - G4int InterCoordYCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerGPDDummyShape/InterCoordY") ; - PosYHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordYCollectionID)) ; - Pos_Y_itr = PosYHitMap->GetMap()->begin() ; - - //Interaction Coordinate Z - G4int InterCoordZCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerGPDDummyShape/InterCoordZ") ; - PosZHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordZCollectionID)) ; - Pos_Z_itr = PosXHitMap->GetMap()->begin() ; - - //Interaction Coordinate Angle Theta - G4int InterCoordAngThetaCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerGPDDummyShape/InterCoordAngTheta") ; - AngThetaHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordAngThetaCollectionID)) ; - Ang_Theta_itr = AngThetaHitMap->GetMap()->begin() ; - - //Interaction Coordinate Angle Phi - G4int InterCoordAngPhiCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerGPDDummyShape/InterCoordAngPhi") ; - AngPhiHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordAngPhiCollectionID)) ; - Ang_Phi_itr = AngPhiHitMap->GetMap()->begin() ; - - - // Read the Scorer associate to the SecondStage - //Energy - G4int SecondStageEnergyCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("SecondStageScorerGPDDummyShape/SecondStageEnergy") ; - SecondStageEnergyHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(SecondStageEnergyCollectionID)) ; - SecondStageEnergy_itr = SecondStageEnergyHitMap->GetMap()->begin() ; - - - // Read the Scorer associate to the ThirdStage - //Energy - G4int ThirdStageEnergyCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("ThirdStageScorerGPDDummyShape/ThirdStageEnergy"); - ThirdStageEnergyHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(ThirdStageEnergyCollectionID)); - ThirdStageEnergy_itr = ThirdStageEnergyHitMap->GetMap()->begin(); - - - // Check the size of different map - G4int sizeN = DetectorNumberHitMap->entries(); - G4int sizeE = EnergyHitMap->entries(); - G4int sizeT = TimeHitMap->entries(); - G4int sizeX = XHitMap->entries(); - G4int sizeY = YHitMap->entries(); - - - //G4cout << "sizeN:" << sizeN << G4endl; - - if (sizeE != sizeT || sizeT != sizeX || sizeX != sizeY) { - G4cout << "No match size Si Event Map: sE:" - << sizeE << " sT:" << sizeT << " sX:" << sizeX << " sY:" << sizeY << G4endl ; - return; - } - - // Loop on FirstStage number - for (G4int l = 0; l < sizeN; l++) { - G4double N = *(DetectorNumber_itr->second); - G4int NTrackID = DetectorNumber_itr->first - N; - - if (N > 0) { - // Fill detector number - ms_Event->SetGPDTrkFirstStageFrontEDetectorNbr(m_index["DummyShape"] + N); - ms_Event->SetGPDTrkFirstStageFrontTDetectorNbr(m_index["DummyShape"] + N); - ms_Event->SetGPDTrkFirstStageBackEDetectorNbr(m_index["DummyShape"] + N); - ms_Event->SetGPDTrkFirstStageBackTDetectorNbr(m_index["DummyShape"] + N); - - // Energy - Energy_itr = EnergyHitMap->GetMap()->begin(); - for (G4int ll = 0 ; ll < sizeE ; ll++) { - G4int ETrackID = Energy_itr->first - N; - G4double E = *(Energy_itr->second); - if (ETrackID == NTrackID) { - ms_Event->SetGPDTrkFirstStageFrontEEnergy(RandGauss::shoot(E, ResoFirstStage)); - ms_Event->SetGPDTrkFirstStageBackEEnergy(RandGauss::shoot(E, ResoFirstStage)); - } - 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) { - ms_Event->SetGPDTrkFirstStageFrontTTime(RandGauss::shoot(T, ResoTimeGpd)); - ms_Event->SetGPDTrkFirstStageBackTTime(RandGauss::shoot(T, ResoTimeGpd)); - } - Time_itr++; - } - - // Strip X - X_itr = XHitMap->GetMap()->begin(); - for (G4int h = 0 ; h < sizeX ; h++) { - G4int XTrackID = X_itr->first - N; - G4int X = *(X_itr->second); - if (XTrackID == NTrackID) { - ms_Event->SetGPDTrkFirstStageFrontEStripNbr(X); - ms_Event->SetGPDTrkFirstStageFrontTStripNbr(X); - } - X_itr++; - } - - // Strip Y - Y_itr = YHitMap->GetMap()->begin() ; - for (G4int h = 0 ; h < sizeY ; h++) { - G4int YTrackID = Y_itr->first - N; - G4int Y = *(Y_itr->second); - if (YTrackID == NTrackID) { - ms_Event->SetGPDTrkFirstStageBackEStripNbr(Y); - ms_Event->SetGPDTrkFirstStageBackTStripNbr(Y); - } - Y_itr++; - } - - // Pos X - Pos_X_itr = PosXHitMap->GetMap()->begin(); - for (G4int h = 0; h < PosXHitMap->entries(); h++) { - G4int PosXTrackID = Pos_X_itr->first - N ; - G4double PosX = *(Pos_X_itr->second) ; - if (PosXTrackID == NTrackID) { - ms_InterCoord->SetDetectedPositionX(PosX) ; - } - Pos_X_itr++; - } - - // Pos Y - Pos_Y_itr = PosYHitMap->GetMap()->begin(); - for (G4int h = 0 ; h < PosYHitMap->entries(); h++) { - G4int PosYTrackID = Pos_Y_itr->first - N ; - G4double PosY = *(Pos_Y_itr->second) ; - if (PosYTrackID == NTrackID) { - ms_InterCoord->SetDetectedPositionY(PosY) ; - } - Pos_Y_itr++; - } - - // Pos Z - Pos_Z_itr = PosZHitMap->GetMap()->begin(); - for (G4int h = 0 ; h < PosZHitMap->entries(); h++) { - G4int PosZTrackID = Pos_Z_itr->first - N ; - G4double PosZ = *(Pos_Z_itr->second) ; - if (PosZTrackID == NTrackID) { - ms_InterCoord->SetDetectedPositionZ(PosZ) ; - } - Pos_Z_itr++; - } - - // Angle Theta - Ang_Theta_itr = AngThetaHitMap->GetMap()->begin(); - for (G4int h = 0; h < AngThetaHitMap->entries(); h++) { - G4int AngThetaTrackID = Ang_Theta_itr->first - N ; - G4double AngTheta = *(Ang_Theta_itr->second) ; - if (AngThetaTrackID == NTrackID) { - ms_InterCoord->SetDetectedAngleTheta(AngTheta) ; - } - Ang_Theta_itr++; - } - - // Angle Phi - Ang_Phi_itr = AngPhiHitMap->GetMap()->begin(); - for (G4int h = 0; h < AngPhiHitMap->entries(); h++) { - G4int AngPhiTrackID = Ang_Phi_itr->first - N ; - G4double AngPhi = *(Ang_Phi_itr->second) ; - if (AngPhiTrackID == NTrackID) { - ms_InterCoord->SetDetectedAnglePhi(AngPhi) ; - } - Ang_Phi_itr++; - } - - // Second Stage - SecondStageEnergy_itr = SecondStageEnergyHitMap->GetMap()->begin() ; - for (G4int h = 0 ; h < SecondStageEnergyHitMap->entries() ; h++) { - G4int SecondStageEnergyTrackID = SecondStageEnergy_itr->first - N; - G4double SecondStageEnergy = *(SecondStageEnergy_itr->second); - - if (SecondStageEnergyTrackID == NTrackID) { - ms_Event->SetGPDTrkSecondStageEEnergy(RandGauss::shoot(SecondStageEnergy, ResoSecondStage)) ; - ms_Event->SetGPDTrkSecondStageEPadNbr(1); - ms_Event->SetGPDTrkSecondStageTPadNbr(1); - ms_Event->SetGPDTrkSecondStageTTime(1); - ms_Event->SetGPDTrkSecondStageTDetectorNbr(m_index["DummyShape"] + N); - ms_Event->SetGPDTrkSecondStageEDetectorNbr(m_index["DummyShape"] + N); - } - SecondStageEnergy_itr++; - } - - // Third Stage - ThirdStageEnergy_itr = ThirdStageEnergyHitMap->GetMap()->begin() ; - for (G4int h = 0 ; h < ThirdStageEnergyHitMap->entries() ; h++) { - G4int ThirdStageEnergyTrackID = ThirdStageEnergy_itr->first - N; - G4double ThirdStageEnergy = *(ThirdStageEnergy_itr->second); - - if (ThirdStageEnergyTrackID == NTrackID) { - ms_Event->SetGPDTrkThirdStageEEnergy(RandGauss::shoot(ThirdStageEnergy, ResoThirdStage)); - ms_Event->SetGPDTrkThirdStageEPadNbr(1); - ms_Event->SetGPDTrkThirdStageTPadNbr(1); - ms_Event->SetGPDTrkThirdStageTTime(1); - ms_Event->SetGPDTrkThirdStageTDetectorNbr(m_index["DummyShape"] + N); - ms_Event->SetGPDTrkThirdStageEDetectorNbr(m_index["DummyShape"] + N); - } - ThirdStageEnergy_itr++; - } + // Pos X + Pos_X_itr = PosXHitMap->GetMap()->begin(); + for (G4int h = 0; h < PosXHitMap->entries(); h++) { + G4int PosXTrackID = Pos_X_itr->first - N; + G4double PosX = *(Pos_X_itr->second); + if (PosXTrackID == NTrackID) { + ms_InterCoord->SetDetectedPositionX(PosX); + } + Pos_X_itr++; + } + // Pos Y + Pos_Y_itr = PosYHitMap->GetMap()->begin(); + for (G4int h = 0; h < PosYHitMap->entries(); h++) { + G4int PosYTrackID = Pos_Y_itr->first - N; + G4double PosY = *(Pos_Y_itr->second); + if (PosYTrackID == NTrackID) { + ms_InterCoord->SetDetectedPositionY(PosY); + } + Pos_Y_itr++; } - DetectorNumber_itr++; - - - } - // clear map for next event - DetectorNumberHitMap -> clear(); - EnergyHitMap -> clear(); - TimeHitMap -> clear(); - XHitMap -> clear(); - YHitMap -> clear(); - PosXHitMap -> clear(); - PosYHitMap -> clear(); - PosZHitMap -> clear(); - AngThetaHitMap -> clear(); - AngPhiHitMap -> clear(); - SecondStageEnergyHitMap -> clear(); - ThirdStageEnergyHitMap -> clear(); -} + // Pos Z + Pos_Z_itr = PosZHitMap->GetMap()->begin(); + for (G4int h = 0; h < PosZHitMap->entries(); h++) { + G4int PosZTrackID = Pos_Z_itr->first - N; + G4double PosZ = *(Pos_Z_itr->second); + if (PosZTrackID == NTrackID) { + ms_InterCoord->SetDetectedPositionZ(PosZ); + } + Pos_Z_itr++; + } + // Angle Theta + Ang_Theta_itr = AngThetaHitMap->GetMap()->begin(); + for (G4int h = 0; h < AngThetaHitMap->entries(); h++) { + G4int AngThetaTrackID = Ang_Theta_itr->first - N; + G4double AngTheta = *(Ang_Theta_itr->second); + if (AngThetaTrackID == NTrackID) { + ms_InterCoord->SetDetectedAngleTheta(AngTheta); + } + Ang_Theta_itr++; + } + + // Angle Phi + Ang_Phi_itr = AngPhiHitMap->GetMap()->begin(); + for (G4int h = 0; h < AngPhiHitMap->entries(); h++) { + G4int AngPhiTrackID = Ang_Phi_itr->first - N; + G4double AngPhi = *(Ang_Phi_itr->second); + if (AngPhiTrackID == NTrackID) { + ms_InterCoord->SetDetectedAnglePhi(AngPhi); + } + Ang_Phi_itr++; + } + + // Second Stage + SecondStageEnergy_itr = SecondStageEnergyHitMap->GetMap()->begin(); + for (G4int h = 0; h < SecondStageEnergyHitMap->entries(); h++) { + G4int SecondStageEnergyTrackID = SecondStageEnergy_itr->first - N; + G4double SecondStageEnergy = *(SecondStageEnergy_itr->second); + + if (SecondStageEnergyTrackID == NTrackID) { + ms_Event->SetGPDTrkSecondStageEEnergy(RandGauss::shoot(SecondStageEnergy, ResoSecondStage)); + ms_Event->SetGPDTrkSecondStageEPadNbr(1); + ms_Event->SetGPDTrkSecondStageTPadNbr(1); + ms_Event->SetGPDTrkSecondStageTTime(1); + ms_Event->SetGPDTrkSecondStageTDetectorNbr(m_index["DummyShape"] + N); + ms_Event->SetGPDTrkSecondStageEDetectorNbr(m_index["DummyShape"] + N); + } + SecondStageEnergy_itr++; + } + + // Third Stage + ThirdStageEnergy_itr = ThirdStageEnergyHitMap->GetMap()->begin(); + for (G4int h = 0; h < ThirdStageEnergyHitMap->entries(); h++) { + G4int ThirdStageEnergyTrackID = ThirdStageEnergy_itr->first - N; + G4double ThirdStageEnergy = *(ThirdStageEnergy_itr->second); + + if (ThirdStageEnergyTrackID == NTrackID) { + ms_Event->SetGPDTrkThirdStageEEnergy(RandGauss::shoot(ThirdStageEnergy, ResoThirdStage)); + ms_Event->SetGPDTrkThirdStageEPadNbr(1); + ms_Event->SetGPDTrkThirdStageTPadNbr(1); + ms_Event->SetGPDTrkThirdStageTTime(1); + ms_Event->SetGPDTrkThirdStageTDetectorNbr(m_index["DummyShape"] + N); + ms_Event->SetGPDTrkThirdStageEDetectorNbr(m_index["DummyShape"] + N); + } + ThirdStageEnergy_itr++; + } + } + DetectorNumber_itr++; + } + // clear map for next event + DetectorNumberHitMap->clear(); + EnergyHitMap->clear(); + TimeHitMap->clear(); + XHitMap->clear(); + YHitMap->clear(); + PosXHitMap->clear(); + PosYHitMap->clear(); + PosZHitMap->clear(); + AngThetaHitMap->clear(); + AngPhiHitMap->clear(); + SecondStageEnergyHitMap->clear(); + ThirdStageEnergyHitMap->clear(); +} -void GaspardTrackerDummyShape::InitializeScorers() -{ - bool already_exist = false; - m_FirstStageScorer = NPS::VDetector::CheckScorer("FirstStageScorerGPDDummyShape", already_exist); - m_SecondStageScorer = NPS::VDetector::CheckScorer("SecondStageScorerGPDDummyShape",already_exist); - m_ThirdStageScorer = NPS::VDetector::CheckScorer("ThirdStageScorerGPDDummyShape",already_exist); - if(already_exist) return; - - // First stage Associate Scorer - G4VPrimitiveScorer* DetNbr = new OBSOLETEGENERALSCORERS::PSDetectorNumber("DetectorNumber", "GPDDummyShape", 0); - G4VPrimitiveScorer* TOF = new OBSOLETEGENERALSCORERS::PSTOF("StripTime","GPDDummyShape", 0); - G4VPrimitiveScorer* InteractionCoordinatesX = new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesX("InterCoordX","GPDDummyShape", 0); - G4VPrimitiveScorer* InteractionCoordinatesY = new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesY("InterCoordY","GPDDummyShape", 0); - G4VPrimitiveScorer* InteractionCoordinatesZ = new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesZ("InterCoordZ","GPDDummyShape", 0); - G4VPrimitiveScorer* InteractionCoordinatesAngleTheta = new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesAngleTheta("InterCoordAngTheta","GPDDummyShape", 0); - G4VPrimitiveScorer* InteractionCoordinatesAnglePhi = new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesAnglePhi("InterCoordAngPhi","GPDDummyShape", 0); - G4VPrimitiveScorer* Energy = new GPDScorerFirstStageEnergy("StripEnergy", "GPDDummyShape", 0); - G4VPrimitiveScorer* StripPositionX = new GPDScorerFirstStageFrontStripDummyShape("StripIDFront", 0, NumberOfStrips); - G4VPrimitiveScorer* StripPositionY = new GPDScorerFirstStageBackStripDummyShape("StripIDBack", 0, NumberOfStrips); - - //and register it to the multifunctionnal detector - m_FirstStageScorer->RegisterPrimitive(DetNbr); - m_FirstStageScorer->RegisterPrimitive(Energy); - m_FirstStageScorer->RegisterPrimitive(TOF); - m_FirstStageScorer->RegisterPrimitive(StripPositionX); - m_FirstStageScorer->RegisterPrimitive(StripPositionY); - m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesX); - m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesY); - m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesZ); - m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesAngleTheta); - m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesAnglePhi); - - - // Second stage Associate Scorer - G4VPrimitiveScorer* SecondStageEnergy = new GPDScorerSecondStageEnergy("SecondStageEnergy", "GPDDummyShape", 0); - m_SecondStageScorer->RegisterPrimitive(SecondStageEnergy); - - - // Third stage Associate Scorer - G4VPrimitiveScorer* ThirdStageEnergy = new GPDScorerThirdStageEnergy("ThirdStageEnergy", "GPDDummyShape", 0); - m_ThirdStageScorer->RegisterPrimitive(ThirdStageEnergy); - - - // Add All Scorer to the Global Scorer Manager - G4SDManager::GetSDMpointer()->AddNewDetector(m_FirstStageScorer); - G4SDManager::GetSDMpointer()->AddNewDetector(m_SecondStageScorer); - G4SDManager::GetSDMpointer()->AddNewDetector(m_ThirdStageScorer); +void GaspardTrackerDummyShape::InitializeScorers() { + bool already_exist = false; + m_FirstStageScorer = NPS::VDetector::CheckScorer("FirstStageScorerGPDDummyShape", already_exist); + m_SecondStageScorer = NPS::VDetector::CheckScorer("SecondStageScorerGPDDummyShape", already_exist); + m_ThirdStageScorer = NPS::VDetector::CheckScorer("ThirdStageScorerGPDDummyShape", already_exist); + if (already_exist) + return; + + // First stage Associate Scorer + G4VPrimitiveScorer* DetNbr = new OBSOLETEGENERALSCORERS::PSDetectorNumber("DetectorNumber", "GPDDummyShape", 0); + G4VPrimitiveScorer* TOF = new OBSOLETEGENERALSCORERS::PSTOF("StripTime", "GPDDummyShape", 0); + G4VPrimitiveScorer* InteractionCoordinatesX = + new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesX("InterCoordX", "GPDDummyShape", 0); + G4VPrimitiveScorer* InteractionCoordinatesY = + new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesY("InterCoordY", "GPDDummyShape", 0); + G4VPrimitiveScorer* InteractionCoordinatesZ = + new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesZ("InterCoordZ", "GPDDummyShape", 0); + G4VPrimitiveScorer* InteractionCoordinatesAngleTheta = + new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesAngleTheta("InterCoordAngTheta", "GPDDummyShape", 0); + G4VPrimitiveScorer* InteractionCoordinatesAnglePhi = + new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesAnglePhi("InterCoordAngPhi", "GPDDummyShape", 0); + G4VPrimitiveScorer* Energy = new GPDScorerFirstStageEnergy("StripEnergy", "GPDDummyShape", 0); + G4VPrimitiveScorer* StripPositionX = new GPDScorerFirstStageFrontStripDummyShape("StripIDFront", 0, NumberOfStrips); + G4VPrimitiveScorer* StripPositionY = new GPDScorerFirstStageBackStripDummyShape("StripIDBack", 0, NumberOfStrips); + + // and register it to the multifunctionnal detector + m_FirstStageScorer->RegisterPrimitive(DetNbr); + m_FirstStageScorer->RegisterPrimitive(Energy); + m_FirstStageScorer->RegisterPrimitive(TOF); + m_FirstStageScorer->RegisterPrimitive(StripPositionX); + m_FirstStageScorer->RegisterPrimitive(StripPositionY); + m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesX); + m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesY); + m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesZ); + m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesAngleTheta); + m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesAnglePhi); + + // Second stage Associate Scorer + G4VPrimitiveScorer* SecondStageEnergy = new GPDScorerSecondStageEnergy("SecondStageEnergy", "GPDDummyShape", 0); + m_SecondStageScorer->RegisterPrimitive(SecondStageEnergy); + + // Third stage Associate Scorer + G4VPrimitiveScorer* ThirdStageEnergy = new GPDScorerThirdStageEnergy("ThirdStageEnergy", "GPDDummyShape", 0); + m_ThirdStageScorer->RegisterPrimitive(ThirdStageEnergy); + + // Add All Scorer to the Global Scorer Manager + G4SDManager::GetSDMpointer()->AddNewDetector(m_FirstStageScorer); + G4SDManager::GetSDMpointer()->AddNewDetector(m_SecondStageScorer); + G4SDManager::GetSDMpointer()->AddNewDetector(m_ThirdStageScorer); } diff --git a/NPSimulation/Detectors/GeTAMU/GeTAMU.cc b/NPSimulation/Detectors/GeTAMU/GeTAMU.cc index 39fb0f2db5c685570893acc6046f141fb309666b..7fbf810995d6be87307cde324260ba16eb878a89 100644 --- a/NPSimulation/Detectors/GeTAMU/GeTAMU.cc +++ b/NPSimulation/Detectors/GeTAMU/GeTAMU.cc @@ -20,37 +20,36 @@ *****************************************************************************/ // C++ headers -#include <sstream> #include <cmath> #include <limits> -//G4 Geometry object +#include <sstream> +// G4 Geometry object #include "G4Box.hh" -#include "G4Tubs.hh" -#include "G4Trd.hh" -#include "G4Trap.hh" #include "G4Cons.hh" +#include "G4Trap.hh" +#include "G4Trd.hh" +#include "G4Tubs.hh" -//G4 sensitive -#include "G4SDManager.hh" +// G4 sensitive #include "G4MultiFunctionalDetector.hh" +#include "G4SDManager.hh" -//G4 various object +// G4 various object +#include "G4Colour.hh" +#include "G4IntersectionSolid.hh" +#include "G4LogicalVolume.hh" #include "G4Material.hh" +#include "G4PVPlacement.hh" #include "G4Polycone.hh" #include "G4Polyhedra.hh" -#include "G4LogicalVolume.hh" -#include "G4ThreeVector.hh" -#include "G4Transform3D.hh" #include "G4RotationMatrix.hh" -#include "G4PVPlacement.hh" -#include "G4VisAttributes.hh" -#include "G4Colour.hh" #include "G4RunManager.hh" -#include "G4ios.hh" #include "G4SubtractionSolid.hh" -#include "G4IntersectionSolid.hh" -#include "G4UnionSolid.hh" #include "G4ThreeVector.hh" +#include "G4Transform3D.hh" +#include "G4UnionSolid.hh" +#include "G4VisAttributes.hh" +#include "G4ios.hh" // NPS #include "GeTAMU.hh" @@ -73,75 +72,74 @@ using namespace CLHEP; namespace { -// Ge crystal -// Cylindrical part -const G4double CrystalOuterRadius = 30.0*mm; // outer radius for crystal -const G4double CrystalInnerRadius = 5.0*mm; // inner radius for hole in crystal -const G4double CrystalLength = 90.0*mm; // crystal length -const G4double CrystalHoleDepth = 15.0*mm; // depth at which starts the hole -//const G4double CrystaHoleRadius = 0*cm; -//const G4double CrystalInterDistance = 0.6*mm; // Distance between two crystal + // Ge crystal + // Cylindrical part + const G4double CrystalOuterRadius = 30.0 * mm; // outer radius for crystal + const G4double CrystalInnerRadius = 5.0 * mm; // inner radius for hole in crystal + const G4double CrystalLength = 90.0 * mm; // crystal length + const G4double CrystalHoleDepth = 15.0 * mm; // depth at which starts the hole + // const G4double CrystaHoleRadius = 0*cm; + // const G4double CrystalInterDistance = 0.6*mm; // Distance between two crystal -// Squared part -const G4double CrystalWidth = 56.5*mm; // Width of one crystal + // Squared part + const G4double CrystalWidth = 56.5 * mm; // Width of one crystal -// Exogam Stuff -const G4double CrystalEdgeOffset1 = 26.0*mm; // distance of the edge from the center of the crystal -const G4double CrystalEdgeOffset2 = 28.5*mm; // distance of the edge from the center of the crystal + // Exogam Stuff + const G4double CrystalEdgeOffset1 = 26.0 * mm; // distance of the edge from the center of the crystal + const G4double CrystalEdgeOffset2 = 28.5 * mm; // distance of the edge from the center of the crystal -const G4double CapsuleWidth = 1.5*mm; // capsule width -const G4double CapsuleLength = 110.*mm; // capsule length -const G4double CapsuleEdgeDepth = 3.3*cm; // same as crystal ! -const G4double CrystalToCapsule = 7*mm; // to be adjusted .. + const G4double CapsuleWidth = 1.5 * mm; // capsule width + const G4double CapsuleLength = 110. * mm; // capsule length + const G4double CapsuleEdgeDepth = 3.3 * cm; // same as crystal ! + const G4double CrystalToCapsule = 7 * mm; // to be adjusted .. -//const G4double BGOLength = 120.0*mm; -//const G4double BGOWidth = 25.0*mm; + // const G4double BGOLength = 120.0*mm; + // const G4double BGOWidth = 25.0*mm; -//const G4double CsILength = 20.0*mm; -} + // const G4double CsILength = 20.0*mm; +} // namespace //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // GeTAMU Specific Method -GeTAMU::GeTAMU(){ +GeTAMU::GeTAMU() { InitializeMaterial(); m_GeTAMUData = new TGeTAMUData(); - BlueVisAtt = new G4VisAttributes(G4Colour(0, 0, 1)) ; - GreenVisAtt = new G4VisAttributes(G4Colour(0, 1, 0)) ; - RedVisAtt = new G4VisAttributes(G4Colour(1, 0, 0)) ; - WhiteVisAtt = new G4VisAttributes(G4Colour(1, 1, 1)) ; - TrGreyVisAtt = new G4VisAttributes(G4Colour(0.5, 0.5, 0.5, 0.5)) ; + BlueVisAtt = new G4VisAttributes(G4Colour(0, 0, 1)); + GreenVisAtt = new G4VisAttributes(G4Colour(0, 1, 0)); + RedVisAtt = new G4VisAttributes(G4Colour(1, 0, 0)); + WhiteVisAtt = new G4VisAttributes(G4Colour(1, 1, 1)); + TrGreyVisAtt = new G4VisAttributes(G4Colour(0.5, 0.5, 0.5, 0.5)); m_LogicClover = 0; - } -GeTAMU::~GeTAMU(){ -// delete m_MaterialVacuum; +GeTAMU::~GeTAMU() { + // delete m_MaterialVacuum; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Virtual Method of NPS::VDetector class // Read stream at Configfile to pick-up parameters of detector (Position,...) // Called in DetecorConstruction::ReadDetextorConfiguration Method -void GeTAMU::ReadConfiguration(NPL::InputParser parser){ - - vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithTokenAndValue("GeTAMU","Clover"); - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << "//// " << blocks.size() << " clovers found " << endl; - - vector<string> token = {"CloverID","R","Theta","Phi","Beta"}; - - for(unsigned int i = 0 ; i < blocks.size() ; i++){ - if(blocks[i]->HasTokenList(token)){ - double R = blocks[i]->GetDouble("R","mm"); - double Theta = blocks[i]->GetDouble("Theta","deg"); - double Phi = blocks[i]->GetDouble("Phi","deg"); - vector<double> beta = blocks[i]->GetVectorDouble("Beta","deg"); - int id = blocks[i]->GetInt("CloverID"); - AddCloverFreePosition(id,R,Theta,Phi,beta[0],beta[1],beta[2]); +void GeTAMU::ReadConfiguration(NPL::InputParser parser) { + + vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithTokenAndValue("GeTAMU", "Clover"); + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks.size() << " clovers found " << endl; + + vector<string> token = {"CloverID", "R", "Theta", "Phi", "Beta"}; + + for (unsigned int i = 0; i < blocks.size(); i++) { + if (blocks[i]->HasTokenList(token)) { + double R = blocks[i]->GetDouble("R", "mm"); + double Theta = blocks[i]->GetDouble("Theta", "deg"); + double Phi = blocks[i]->GetDouble("Phi", "deg"); + vector<double> beta = blocks[i]->GetVectorDouble("Beta", "deg"); + int id = blocks[i]->GetInt("CloverID"); + AddCloverFreePosition(id, R, Theta, Phi, beta[0], beta[1], beta[2]); } - else{ + else { cout << "ERROR: check your input file formatting " << endl; exit(1); } @@ -150,177 +148,175 @@ void GeTAMU::ReadConfiguration(NPL::InputParser parser){ //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Return a G4VSolid modeling the Crystal -G4LogicalVolume* GeTAMU::ConstructCrystal(){ - G4Tubs* Crystal_Cylinder = new G4Tubs("Crystal_Cylinder", 0, CrystalOuterRadius, CrystalLength*0.5, 0, 2*M_PI); +G4LogicalVolume* GeTAMU::ConstructCrystal() { + G4Tubs* Crystal_Cylinder = new G4Tubs("Crystal_Cylinder", 0, CrystalOuterRadius, CrystalLength * 0.5, 0, 2 * M_PI); // Central Hole for cold finger - G4RotationMatrix* BoxRotation = new G4RotationMatrix(0,0,0); - G4Tubs* Crystal_Hole = new G4Tubs("Crystal_Hole", 0, CrystalInnerRadius, (CrystalLength-CrystalHoleDepth)*0.5, 0, 2*M_PI); - G4SubtractionSolid* Crystal_Stage1 = new G4SubtractionSolid("Crystal_Stage1",Crystal_Cylinder,Crystal_Hole,BoxRotation,G4ThreeVector(0,0,CrystalHoleDepth)); + G4RotationMatrix* BoxRotation = new G4RotationMatrix(0, 0, 0); + G4Tubs* Crystal_Hole = + new G4Tubs("Crystal_Hole", 0, CrystalInnerRadius, (CrystalLength - CrystalHoleDepth) * 0.5, 0, 2 * M_PI); + G4SubtractionSolid* Crystal_Stage1 = new G4SubtractionSolid("Crystal_Stage1", Crystal_Cylinder, Crystal_Hole, + BoxRotation, G4ThreeVector(0, 0, CrystalHoleDepth)); // Flat surface on the side - G4Box* Crystal_Box1 = new G4Box("Crystal_Box1", CrystalWidth*0.6, CrystalWidth*0.6,CrystalLength*0.6); - G4SubtractionSolid* Crystal_Stage2 = new G4SubtractionSolid("Crystal_Stage2",Crystal_Stage1,Crystal_Box1,BoxRotation,G4ThreeVector(24.5+CrystalWidth*0.6,0,0)); - G4SubtractionSolid* Crystal_Stage3 = new G4SubtractionSolid("Crystal_Stage3",Crystal_Stage2,Crystal_Box1,BoxRotation,G4ThreeVector(-29-CrystalWidth*0.6,0,0)); - G4SubtractionSolid* Crystal_Stage4 = new G4SubtractionSolid("Crystal_Stage4",Crystal_Stage3,Crystal_Box1,BoxRotation,G4ThreeVector(0,29+CrystalWidth*0.6,0)); - G4SubtractionSolid* Crystal_Stage5 = new G4SubtractionSolid("Crystal_Stage5",Crystal_Stage4,Crystal_Box1,BoxRotation,G4ThreeVector(0,-24.5-CrystalWidth*0.6,0)); + G4Box* Crystal_Box1 = new G4Box("Crystal_Box1", CrystalWidth * 0.6, CrystalWidth * 0.6, CrystalLength * 0.6); + G4SubtractionSolid* Crystal_Stage2 = new G4SubtractionSolid( + "Crystal_Stage2", Crystal_Stage1, Crystal_Box1, BoxRotation, G4ThreeVector(24.5 + CrystalWidth * 0.6, 0, 0)); + G4SubtractionSolid* Crystal_Stage3 = new G4SubtractionSolid( + "Crystal_Stage3", Crystal_Stage2, Crystal_Box1, BoxRotation, G4ThreeVector(-29 - CrystalWidth * 0.6, 0, 0)); + G4SubtractionSolid* Crystal_Stage4 = new G4SubtractionSolid( + "Crystal_Stage4", Crystal_Stage3, Crystal_Box1, BoxRotation, G4ThreeVector(0, 29 + CrystalWidth * 0.6, 0)); + G4SubtractionSolid* Crystal_Stage5 = new G4SubtractionSolid( + "Crystal_Stage5", Crystal_Stage4, Crystal_Box1, BoxRotation, G4ThreeVector(0, -24.5 - CrystalWidth * 0.6, 0)); // Bezel - G4RotationMatrix* BoxRotation1 = new G4RotationMatrix(0,0,0); - BoxRotation1->rotate(22.5*deg,G4ThreeVector(1,0,0)); - G4SubtractionSolid* Crystal_Stage6= new G4SubtractionSolid("Crystal_Stage6",Crystal_Stage5,Crystal_Box1,BoxRotation1,G4ThreeVector(0,20.54*mm+CrystalWidth*0.6,-45*mm)); - - G4RotationMatrix* BoxRotation2 = new G4RotationMatrix(0,0,0); - BoxRotation2->rotate(22.5*deg,G4ThreeVector(0,1,0)); - G4SubtractionSolid* Crystal_Stage7= new G4SubtractionSolid("Crystal_Stage7",Crystal_Stage6,Crystal_Box1,BoxRotation2,G4ThreeVector(-20.54*mm-CrystalWidth*0.6,0,-45*mm)); - - G4LogicalVolume* logicCrystal = - new G4LogicalVolume(Crystal_Stage7,m_MaterialGe,"LogicCrystal", 0, 0, 0); - - return logicCrystal; + G4RotationMatrix* BoxRotation1 = new G4RotationMatrix(0, 0, 0); + BoxRotation1->rotate(22.5 * deg, G4ThreeVector(1, 0, 0)); + G4SubtractionSolid* Crystal_Stage6 = + new G4SubtractionSolid("Crystal_Stage6", Crystal_Stage5, Crystal_Box1, BoxRotation1, + G4ThreeVector(0, 20.54 * mm + CrystalWidth * 0.6, -45 * mm)); + + G4RotationMatrix* BoxRotation2 = new G4RotationMatrix(0, 0, 0); + BoxRotation2->rotate(22.5 * deg, G4ThreeVector(0, 1, 0)); + G4SubtractionSolid* Crystal_Stage7 = + new G4SubtractionSolid("Crystal_Stage7", Crystal_Stage6, Crystal_Box1, BoxRotation2, + G4ThreeVector(-20.54 * mm - CrystalWidth * 0.6, 0, -45 * mm)); + + G4LogicalVolume* logicCrystal = new G4LogicalVolume(Crystal_Stage7, m_MaterialGe, "LogicCrystal", 0, 0, 0); + + return logicCrystal; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Return a G4VSolid modeling the Capsule -G4LogicalVolume* GeTAMU::ConstructCapsule(){ +G4LogicalVolume* GeTAMU::ConstructCapsule() { G4int nbslice = 7; - const G4double widthface = 45.5*mm; - G4double zSlice[7] = { 0.0*mm, - CapsuleWidth-0.1*mm, - CapsuleWidth, - CapsuleEdgeDepth, - CapsuleLength-CapsuleWidth, - CapsuleLength-CapsuleWidth-0.1*mm, - CapsuleLength }; - - G4double InnNullRad[7] = {0,0,0,0,0,0,0}; - - G4double InnRad[7] = { 0.0*mm, - 0.0*mm, - widthface-CapsuleWidth, - CrystalEdgeOffset1 + CrystalEdgeOffset2 + CrystalToCapsule - CapsuleWidth, - CrystalEdgeOffset1 + CrystalEdgeOffset2 + CrystalToCapsule - CapsuleWidth, - 0.0*mm, - 0.0*mm}; - - G4double OutRad[7] = { widthface-1.5*mm, - widthface, - widthface, - CrystalEdgeOffset1 + CrystalEdgeOffset2 + CrystalToCapsule, - CrystalEdgeOffset1 + CrystalEdgeOffset2 + CrystalToCapsule, - CrystalEdgeOffset1 + CrystalEdgeOffset2 + CrystalToCapsule, - CrystalEdgeOffset1 + CrystalEdgeOffset2 + CrystalToCapsule}; + const G4double widthface = 45.5 * mm; + G4double zSlice[7] = {0.0 * mm, CapsuleWidth - 0.1 * mm, CapsuleWidth, + CapsuleEdgeDepth, CapsuleLength - CapsuleWidth, CapsuleLength - CapsuleWidth - 0.1 * mm, + CapsuleLength}; + + G4double InnNullRad[7] = {0, 0, 0, 0, 0, 0, 0}; + + G4double InnRad[7] = {0.0 * mm, + 0.0 * mm, + widthface - CapsuleWidth, + CrystalEdgeOffset1 + CrystalEdgeOffset2 + CrystalToCapsule - CapsuleWidth, + CrystalEdgeOffset1 + CrystalEdgeOffset2 + CrystalToCapsule - CapsuleWidth, + 0.0 * mm, + 0.0 * mm}; + + G4double OutRad[7] = {widthface - 1.5 * mm, + widthface, + widthface, + CrystalEdgeOffset1 + CrystalEdgeOffset2 + CrystalToCapsule, + CrystalEdgeOffset1 + CrystalEdgeOffset2 + CrystalToCapsule, + CrystalEdgeOffset1 + CrystalEdgeOffset2 + CrystalToCapsule, + CrystalEdgeOffset1 + CrystalEdgeOffset2 + CrystalToCapsule}; // The whole volume of the Capsule, made of N2 - G4Polyhedra* caps = new G4Polyhedra(G4String("Capsule"), 45.*deg, 360.*deg, 4, nbslice, zSlice, InnNullRad, OutRad); - G4LogicalVolume* LogicCapsule= - new G4LogicalVolume(caps,m_MaterialN2,"LogicCapsule", 0, 0, 0); - LogicCapsule->SetVisAttributes(G4VisAttributes::Invisible); + G4Polyhedra* caps = + new G4Polyhedra(G4String("Capsule"), 45. * deg, 360. * deg, 4, nbslice, zSlice, InnNullRad, OutRad); + G4LogicalVolume* LogicCapsule = new G4LogicalVolume(caps, m_MaterialN2, "LogicCapsule", 0, 0, 0); + LogicCapsule->SetVisAttributes(G4VisAttributes::GetInvisible()); // The wall of the Capsule made of Al - G4Polyhedra* capsWall = new G4Polyhedra(G4String("CapsuleWall"), 45.*deg, 360.*deg, 4, nbslice, zSlice, InnRad, OutRad); - G4LogicalVolume* logicCapsuleWall = - new G4LogicalVolume(capsWall,m_MaterialAl,"LogicCapsuleWall", 0, 0, 0); + G4Polyhedra* capsWall = + new G4Polyhedra(G4String("CapsuleWall"), 45. * deg, 360. * deg, 4, nbslice, zSlice, InnRad, OutRad); + G4LogicalVolume* logicCapsuleWall = new G4LogicalVolume(capsWall, m_MaterialAl, "LogicCapsuleWall", 0, 0, 0); - new G4PVPlacement(G4Transform3D(*(new G4RotationMatrix()), G4ThreeVector(0,0,0)), - logicCapsuleWall,"CapsuleWall",LogicCapsule,false,1); + new G4PVPlacement(G4Transform3D(*(new G4RotationMatrix()), G4ThreeVector(0, 0, 0)), logicCapsuleWall, "CapsuleWall", + LogicCapsule, false, 1); logicCapsuleWall->SetVisAttributes(TrGreyVisAtt); return LogicCapsule; - } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -G4LogicalVolume* GeTAMU::ConstructDewar(){ - G4Tubs* DewarSolid = new G4Tubs("DewarSolid",0,90*mm*0.5,90*mm*0.5,0,2*M_PI); - G4Tubs* DewarCFSolid = new G4Tubs("DewarCFSolid",0,45*mm*0.5,145*mm*0.5,0,2*M_PI); +G4LogicalVolume* GeTAMU::ConstructDewar() { + G4Tubs* DewarSolid = new G4Tubs("DewarSolid", 0, 90 * mm * 0.5, 90 * mm * 0.5, 0, 2 * M_PI); + G4Tubs* DewarCFSolid = new G4Tubs("DewarCFSolid", 0, 45 * mm * 0.5, 145 * mm * 0.5, 0, 2 * M_PI); + + G4UnionSolid* DewarFull = new G4UnionSolid("Dewarfull", DewarSolid, DewarCFSolid, new G4RotationMatrix(), + G4ThreeVector(0, 0, -90 * mm - (145 - 90) * 0.5 * mm)); - G4UnionSolid* DewarFull = - new G4UnionSolid("Dewarfull", DewarSolid, DewarCFSolid, new G4RotationMatrix(),G4ThreeVector(0,0,-90*mm-(145-90)*0.5*mm)); + G4LogicalVolume* LogicDewar = new G4LogicalVolume(DewarFull, m_MaterialAl, "LogicDewar", 0, 0, 0); - G4LogicalVolume* LogicDewar = new G4LogicalVolume(DewarFull,m_MaterialAl,"LogicDewar",0,0,0); + G4Tubs* N2Solid = new G4Tubs("N2Solid", 0, 90 * mm * 0.5 - 1 * mm, 90 * mm * 0.5 - 1 * mm, 0, 2 * M_PI); + G4Tubs* N2CFSolid = new G4Tubs("N2CFSolid", 0, 45 * mm * 0.5 - 1 * mm, 145 * mm * 0.5 - 1 * mm, 0, 2 * M_PI); - G4Tubs* N2Solid = new G4Tubs("N2Solid",0,90*mm*0.5-1*mm,90*mm*0.5-1*mm,0,2*M_PI); - G4Tubs* N2CFSolid = new G4Tubs("N2CFSolid",0,45*mm*0.5-1*mm,145*mm*0.5-1*mm,0,2*M_PI); + G4LogicalVolume* LogicN2 = new G4LogicalVolume(N2Solid, m_MaterialN2, "LogicN2", 0, 0, 0); + G4LogicalVolume* LogicN2CF = new G4LogicalVolume(N2CFSolid, m_MaterialN2, "LogicN2CF", 0, 0, 0); - G4LogicalVolume* LogicN2 = new G4LogicalVolume(N2Solid,m_MaterialN2,"LogicN2",0,0,0); - G4LogicalVolume* LogicN2CF = new G4LogicalVolume(N2CFSolid,m_MaterialN2,"LogicN2CF",0,0,0); - LogicN2->SetVisAttributes(GreenVisAtt); LogicN2CF->SetVisAttributes(GreenVisAtt); - new G4PVPlacement(G4Transform3D(*(new G4RotationMatrix()), G4ThreeVector(0,0,0)), - LogicN2,"N2 Deware",LogicDewar,false,1); - - //new G4PVPlacement(G4Transform3D(*(new G4RotationMatrix()), G4ThreeVector(0,0,-90*mm)), - // LogicN2CF,"N2 Deware",LogicDewar,false,1); + new G4PVPlacement(G4Transform3D(*(new G4RotationMatrix()), G4ThreeVector(0, 0, 0)), LogicN2, "N2 Deware", LogicDewar, + false, 1); + + // new G4PVPlacement(G4Transform3D(*(new G4RotationMatrix()), G4ThreeVector(0,0,-90*mm)), + // LogicN2CF,"N2 Deware",LogicDewar,false,1); LogicDewar->SetVisAttributes(TrGreyVisAtt); return LogicDewar; } - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Return a G4VSolid modeling the BGO -G4LogicalVolume* GeTAMU::ConstructBGO(){ - - return NULL; - -} +G4LogicalVolume* GeTAMU::ConstructBGO() { return NULL; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Return a clover in the configuration given by option (not use a the moment) -void GeTAMU::ConstructClover(){ - if(m_LogicClover==0){ +void GeTAMU::ConstructClover() { + if (m_LogicClover == 0) { // Construct the clover itself m_LogicClover = ConstructCapsule(); - + // Place the cristal in the clover - double CrystalOffset = (24.5*mm+0.5*mm); + double CrystalOffset = (24.5 * mm + 0.5 * mm); G4LogicalVolume* logicCrystal = ConstructCrystal(); - G4RotationMatrix* CrystalRotation = new G4RotationMatrix(0,0,0); - G4ThreeVector CrystalPositionB = G4ThreeVector(-CrystalOffset,+CrystalOffset,0.5*CrystalLength+7*mm); - new G4PVPlacement(G4Transform3D(*CrystalRotation, CrystalPositionB), - logicCrystal,"LogicCrystalB",m_LogicClover,false,1); + G4RotationMatrix* CrystalRotation = new G4RotationMatrix(0, 0, 0); + G4ThreeVector CrystalPositionB = G4ThreeVector(-CrystalOffset, +CrystalOffset, 0.5 * CrystalLength + 7 * mm); + new G4PVPlacement(G4Transform3D(*CrystalRotation, CrystalPositionB), logicCrystal, "LogicCrystalB", m_LogicClover, + false, 1); logicCrystal->SetVisAttributes(BlueVisAtt); - CrystalRotation->rotate(-90*deg, G4ThreeVector(0,0,1)); - G4ThreeVector CrystalPositionG = G4ThreeVector(+CrystalOffset,+CrystalOffset,0.5*CrystalLength+7*mm); - new G4PVPlacement(G4Transform3D(*CrystalRotation, CrystalPositionG), - logicCrystal,"LogicCrystalG",m_LogicClover,false,2); - - CrystalRotation->rotate(-90*deg, G4ThreeVector(0,0,1)); - G4ThreeVector CrystalPositionR = G4ThreeVector(+CrystalOffset,-CrystalOffset,0.5*CrystalLength+7*mm); - new G4PVPlacement(G4Transform3D(*CrystalRotation, CrystalPositionR), - logicCrystal,"LogicCrystalR",m_LogicClover,false,3); + CrystalRotation->rotate(-90 * deg, G4ThreeVector(0, 0, 1)); + G4ThreeVector CrystalPositionG = G4ThreeVector(+CrystalOffset, +CrystalOffset, 0.5 * CrystalLength + 7 * mm); + new G4PVPlacement(G4Transform3D(*CrystalRotation, CrystalPositionG), logicCrystal, "LogicCrystalG", m_LogicClover, + false, 2); - CrystalRotation->rotate(-90*deg, G4ThreeVector(0,0,1)); - G4ThreeVector CrystalPositionW = G4ThreeVector(-CrystalOffset,-CrystalOffset,0.5*CrystalLength+7*mm); - new G4PVPlacement(G4Transform3D(*CrystalRotation, CrystalPositionW), - logicCrystal,"LogicCrystalW",m_LogicClover,false,4); + CrystalRotation->rotate(-90 * deg, G4ThreeVector(0, 0, 1)); + G4ThreeVector CrystalPositionR = G4ThreeVector(+CrystalOffset, -CrystalOffset, 0.5 * CrystalLength + 7 * mm); + new G4PVPlacement(G4Transform3D(*CrystalRotation, CrystalPositionR), logicCrystal, "LogicCrystalR", m_LogicClover, + false, 3); - logicCrystal->SetSensitiveDetector(m_HPGeScorer); - // m_LogicClover->SetSensitiveDetector(m_HPGeScorer); - } + CrystalRotation->rotate(-90 * deg, G4ThreeVector(0, 0, 1)); + G4ThreeVector CrystalPositionW = G4ThreeVector(-CrystalOffset, -CrystalOffset, 0.5 * CrystalLength + 7 * mm); + new G4PVPlacement(G4Transform3D(*CrystalRotation, CrystalPositionW), logicCrystal, "LogicCrystalW", m_LogicClover, + false, 4); + logicCrystal->SetSensitiveDetector(m_HPGeScorer); + // m_LogicClover->SetSensitiveDetector(m_HPGeScorer); + } } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Construct detector and inialise sensitive part. // Called After DetecorConstruction::AddDetector Method -void GeTAMU::ConstructDetector(G4LogicalVolume* world){ +void GeTAMU::ConstructDetector(G4LogicalVolume* world) { ConstructClover(); - G4RotationMatrix* DetectorRotation = new G4RotationMatrix(0,0,0); - for (unsigned int i = 0 ; i < m_CloverId.size(); i++) { + G4RotationMatrix* DetectorRotation = new G4RotationMatrix(0, 0, 0); + for (unsigned int i = 0; i < m_CloverId.size(); i++) { // Constructing the Detector referential and the transition matrix - G4ThreeVector U,V,W; - G4double wX = sin(m_Theta[i]) * cos(m_Phi[i]) ; - G4double wY = sin(m_Theta[i]) * sin(m_Phi[i]) ; + G4ThreeVector U, V, W; + G4double wX = sin(m_Theta[i]) * cos(m_Phi[i]); + G4double wY = sin(m_Theta[i]) * sin(m_Phi[i]); G4double wZ = cos(m_Theta[i]); - W = G4ThreeVector(wX, wY, wZ) ; + W = G4ThreeVector(wX, wY, wZ); // vector parallel to one axis of the entrance plane G4double vX = cos(m_Theta[i]) * cos(m_Phi[i]); @@ -340,194 +336,193 @@ void GeTAMU::ConstructDetector(G4LogicalVolume* world){ DetectorRotation->rotate(m_BetaX[i], U); DetectorRotation->rotate(m_BetaY[i], V); DetectorRotation->rotate(m_BetaZ[i], W); - G4ThreeVector DetectorPosition = m_R[i]*W; - - new G4PVPlacement(G4Transform3D(*DetectorRotation, DetectorPosition), - m_LogicClover,"Clover",world,false,m_CloverId[i]); - - G4LogicalVolume* LogicDewar = ConstructDewar(); - - new G4PVPlacement(G4Transform3D(*DetectorRotation, DetectorPosition+W*((90*mm+(145)*mm)+CapsuleLength*0.5+90*0.5*mm)), - LogicDewar,"Dewar",world,false,m_CloverId[i]); + G4ThreeVector DetectorPosition = m_R[i] * W; + + new G4PVPlacement(G4Transform3D(*DetectorRotation, DetectorPosition), m_LogicClover, "Clover", world, false, + m_CloverId[i]); + G4LogicalVolume* LogicDewar = ConstructDewar(); + new G4PVPlacement(G4Transform3D(*DetectorRotation, DetectorPosition + W * ((90 * mm + (145) * mm) + + CapsuleLength * 0.5 + 90 * 0.5 * mm)), + LogicDewar, "Dewar", world, false, m_CloverId[i]); } } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Add clover at the standard position of the array // Take as argument the standard clover Id. -void GeTAMU::AddCloverStandard(vector<int> CloverId){ +void GeTAMU::AddCloverStandard(vector<int> CloverId) { - for (unsigned int i = 0 ; i < CloverId.size(); i++) { - if(CloverId[i] == 1 ){ + for (unsigned int i = 0; i < CloverId.size(); i++) { + if (CloverId[i] == 1) { m_CloverId.push_back(CloverId[i]); - m_R.push_back(145*mm); - m_Theta.push_back(45*deg); - m_Phi.push_back(22.5*deg); + m_R.push_back(145 * mm); + m_Theta.push_back(45 * deg); + m_Phi.push_back(22.5 * deg); m_BetaX.push_back(0); m_BetaY.push_back(0); m_BetaZ.push_back(0); } - else if(CloverId[i] == 2 ){ + else if (CloverId[i] == 2) { m_CloverId.push_back(CloverId[i]); - m_R.push_back(145*mm); - m_Theta.push_back(45*deg); - m_Phi.push_back(112.5*deg); + m_R.push_back(145 * mm); + m_Theta.push_back(45 * deg); + m_Phi.push_back(112.5 * deg); m_BetaX.push_back(0); m_BetaY.push_back(0); m_BetaZ.push_back(0); } - else if(CloverId[i] == 3 ){ + else if (CloverId[i] == 3) { m_CloverId.push_back(CloverId[i]); - m_R.push_back(145*mm); - m_Theta.push_back(45*deg); - m_Phi.push_back(202.5*deg); + m_R.push_back(145 * mm); + m_Theta.push_back(45 * deg); + m_Phi.push_back(202.5 * deg); m_BetaX.push_back(0); m_BetaY.push_back(0); m_BetaZ.push_back(0); } - else if(CloverId[i] == 4 ){ + else if (CloverId[i] == 4) { m_CloverId.push_back(CloverId[i]); - m_R.push_back(145*mm); - m_Theta.push_back(45*deg); - m_Phi.push_back(292.5*deg); + m_R.push_back(145 * mm); + m_Theta.push_back(45 * deg); + m_Phi.push_back(292.5 * deg); m_BetaX.push_back(0); m_BetaY.push_back(0); m_BetaZ.push_back(0); } - else if(CloverId[i] == 5 ){ + else if (CloverId[i] == 5) { m_CloverId.push_back(CloverId[i]); - m_R.push_back(145*mm); - m_Theta.push_back(90*deg); - m_Phi.push_back(22.5*deg); + m_R.push_back(145 * mm); + m_Theta.push_back(90 * deg); + m_Phi.push_back(22.5 * deg); m_BetaX.push_back(0); m_BetaY.push_back(0); - m_BetaZ.push_back(180*deg); + m_BetaZ.push_back(180 * deg); } - else if(CloverId[i] == 6 ){ + else if (CloverId[i] == 6) { m_CloverId.push_back(CloverId[i]); - m_R.push_back(145*mm); - m_Theta.push_back(90*deg); - m_Phi.push_back(67.5*deg); + m_R.push_back(145 * mm); + m_Theta.push_back(90 * deg); + m_Phi.push_back(67.5 * deg); m_BetaX.push_back(0); m_BetaY.push_back(0); - m_BetaZ.push_back(180*deg); + m_BetaZ.push_back(180 * deg); } - else if(CloverId[i] == 7 ){ + else if (CloverId[i] == 7) { m_CloverId.push_back(CloverId[i]); - m_R.push_back(145*mm); - m_Theta.push_back(90*deg); - m_Phi.push_back(112.5*deg); + m_R.push_back(145 * mm); + m_Theta.push_back(90 * deg); + m_Phi.push_back(112.5 * deg); m_BetaX.push_back(0); m_BetaY.push_back(0); - m_BetaZ.push_back(180*deg); + m_BetaZ.push_back(180 * deg); } - else if(CloverId[i] == 8 ){ + else if (CloverId[i] == 8) { m_CloverId.push_back(CloverId[i]); - m_R.push_back(145*mm); - m_Theta.push_back(90*deg); - m_Phi.push_back(157.5*deg); + m_R.push_back(145 * mm); + m_Theta.push_back(90 * deg); + m_Phi.push_back(157.5 * deg); m_BetaX.push_back(0); m_BetaY.push_back(0); - m_BetaZ.push_back(180*deg); + m_BetaZ.push_back(180 * deg); } - else if(CloverId[i] == 9 ){ + else if (CloverId[i] == 9) { m_CloverId.push_back(CloverId[i]); - m_R.push_back(145*mm); - m_Theta.push_back(90*deg); - m_Phi.push_back(202.5*deg); + m_R.push_back(145 * mm); + m_Theta.push_back(90 * deg); + m_Phi.push_back(202.5 * deg); m_BetaX.push_back(0); m_BetaY.push_back(0); - m_BetaZ.push_back(180*deg); + m_BetaZ.push_back(180 * deg); } - else if(CloverId[i] == 10 ){ + else if (CloverId[i] == 10) { m_CloverId.push_back(CloverId[i]); - m_R.push_back(145*mm); - m_Theta.push_back(90*deg); - m_Phi.push_back(247.5*deg); + m_R.push_back(145 * mm); + m_Theta.push_back(90 * deg); + m_Phi.push_back(247.5 * deg); m_BetaX.push_back(0); m_BetaY.push_back(0); - m_BetaZ.push_back(180*deg); + m_BetaZ.push_back(180 * deg); } - else if(CloverId[i] == 11 ){ + else if (CloverId[i] == 11) { m_CloverId.push_back(CloverId[i]); - m_R.push_back(145*mm); - m_Theta.push_back(90*deg); - m_Phi.push_back(292.5*deg); + m_R.push_back(145 * mm); + m_Theta.push_back(90 * deg); + m_Phi.push_back(292.5 * deg); m_BetaX.push_back(0); m_BetaY.push_back(0); - m_BetaZ.push_back(180*deg); + m_BetaZ.push_back(180 * deg); } - else if(CloverId[i] == 12 ){ + else if (CloverId[i] == 12) { m_CloverId.push_back(CloverId[i]); - m_R.push_back(145*mm); - m_Theta.push_back(90*deg); - m_Phi.push_back(337.5*deg); + m_R.push_back(145 * mm); + m_Theta.push_back(90 * deg); + m_Phi.push_back(337.5 * deg); m_BetaX.push_back(0); m_BetaY.push_back(0); - m_BetaZ.push_back(180*deg); + m_BetaZ.push_back(180 * deg); } - else if(CloverId[i] == 13 ){ + else if (CloverId[i] == 13) { m_CloverId.push_back(CloverId[i]); - m_R.push_back(145*mm); - m_Theta.push_back(135*deg); - m_Phi.push_back(22.5*deg); + m_R.push_back(145 * mm); + m_Theta.push_back(135 * deg); + m_Phi.push_back(22.5 * deg); m_BetaX.push_back(0); m_BetaY.push_back(0); - m_BetaZ.push_back(180*deg); + m_BetaZ.push_back(180 * deg); } - else if(CloverId[i] == 14 ){ + else if (CloverId[i] == 14) { m_CloverId.push_back(CloverId[i]); - m_R.push_back(145*mm); - m_Theta.push_back(135*deg); - m_Phi.push_back(112.5*deg); + m_R.push_back(145 * mm); + m_Theta.push_back(135 * deg); + m_Phi.push_back(112.5 * deg); m_BetaX.push_back(0); m_BetaY.push_back(0); - m_BetaZ.push_back(180*deg); + m_BetaZ.push_back(180 * deg); } - else if(CloverId[i] == 15 ){ + else if (CloverId[i] == 15) { m_CloverId.push_back(CloverId[i]); - m_R.push_back(145*mm); - m_Theta.push_back(135*deg); - m_Phi.push_back(202.5*deg); + m_R.push_back(145 * mm); + m_Theta.push_back(135 * deg); + m_Phi.push_back(202.5 * deg); m_BetaX.push_back(0); m_BetaY.push_back(0); - m_BetaZ.push_back(180*deg); + m_BetaZ.push_back(180 * deg); } - else if(CloverId[i] == 16 ){ + else if (CloverId[i] == 16) { m_CloverId.push_back(CloverId[i]); - m_R.push_back(145*mm); - m_Theta.push_back(135*deg); - m_Phi.push_back(292.5*deg); + m_R.push_back(145 * mm); + m_Theta.push_back(135 * deg); + m_Phi.push_back(292.5 * deg); m_BetaX.push_back(0); m_BetaY.push_back(0); - m_BetaZ.push_back(180*deg); + m_BetaZ.push_back(180 * deg); } } - } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Add clover at a free position in space with coordinate // in spherical coordinate // Beta are the three angles of rotation in the Clover frame -void GeTAMU::AddCloverFreePosition(int CloverId,double R,double Theta,double Phi,double BetaX,double BetaY,double BetaZ){ +void GeTAMU::AddCloverFreePosition(int CloverId, double R, double Theta, double Phi, double BetaX, double BetaY, + double BetaZ) { m_CloverId.push_back(CloverId); m_R.push_back(R); @@ -536,46 +531,45 @@ void GeTAMU::AddCloverFreePosition(int CloverId,double R,double Theta,double Phi m_BetaX.push_back(BetaX); m_BetaY.push_back(BetaY); m_BetaZ.push_back(BetaZ); - } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Add Detector branch to the EventTree. // Called After DetecorConstruction::AddDetector Method -void GeTAMU::InitializeRootOutput(){ - RootOutput *pAnalysis = RootOutput::getInstance(); - TTree *pTree = pAnalysis->GetTree(); - if(!pTree->FindBranch("GeTAMU")){ - pTree->Branch("GeTAMU", "TGeTAMUData", &m_GeTAMUData) ; - } - pTree->SetBranchAddress("GeTAMU", &m_GeTAMUData) ; +void GeTAMU::InitializeRootOutput() { + RootOutput* pAnalysis = RootOutput::getInstance(); + TTree* pTree = pAnalysis->GetTree(); + if (!pTree->FindBranch("GeTAMU")) { + pTree->Branch("GeTAMU", "TGeTAMUData", &m_GeTAMUData); + } + pTree->SetBranchAddress("GeTAMU", &m_GeTAMUData); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Read sensitive part and fill the Root tree. // Called at in the EventAction::EndOfEventAvtion -void GeTAMU::ReadSensitive(const G4Event* event){ +void GeTAMU::ReadSensitive(const G4Event* event) { m_GeTAMUData->Clear(); /////////// // HPGE - NPS::HitsMap<G4double*>* HPGEHitMap; - std::map<G4int, G4double**>::iterator HPGE_itr; + NPS::HitsMap<G4double*>* HPGEHitMap; + std::map<G4int, G4double**>::iterator HPGE_itr; G4int HPGECollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("GeTAMU_Scorer/GeTAMU"); - if(HPGECollectionID == -1) { - G4cerr << "ERROR: No Collection found for HPGeScorer: Skipping processing of HPGe Hit" << G4endl; - return; - } + if (HPGECollectionID == -1) { + G4cerr << "ERROR: No Collection found for HPGeScorer: Skipping processing of HPGe Hit" << G4endl; + return; + } HPGEHitMap = (NPS::HitsMap<G4double*>*)(event->GetHCofThisEvent()->GetHC(HPGECollectionID)); // Loop on the HPGE map - for (HPGE_itr = HPGEHitMap->GetMap()->begin() ; HPGE_itr != HPGEHitMap->GetMap()->end() ; HPGE_itr++){ - - G4double* Info = *(HPGE_itr->second); + for (HPGE_itr = HPGEHitMap->GetMap()->begin(); HPGE_itr != HPGEHitMap->GetMap()->end(); HPGE_itr++) { - G4double Energy = Info[0]; - G4double Time = Info[1]; + G4double* Info = *(HPGE_itr->second); + + G4double Energy = Info[0]; + G4double Time = Info[1]; // G4double InterPos_X = Info[2]; G4double InterPos_Y = Info[3]; @@ -583,96 +577,99 @@ void GeTAMU::ReadSensitive(const G4Event* event){ G4double InterPos_Theta = Info[5]; G4double InterPos_Phi = Info[6]; // - G4int CloverNbr = (int)Info[7]; - G4int CrystalNbr = (int)Info[8]; - - // Figure out segment number - G4int SegmentNbr = 0; - if(fabs(InterPos_Z) < 20*mm) { SegmentNbr = 2; } // MIDDLE - else if(CrystalNbr == 1 || CrystalNbr == 4) { SegmentNbr = 1; } // RIGHT - else { SegmentNbr = 3; } // LEFT - - if(Energy>0.0*keV){ - m_GeTAMUData->SetCoreE(CloverNbr, CrystalNbr, Energy/keV); - m_GeTAMUData->SetCoreT(CloverNbr, CrystalNbr, Time/ns); - m_GeTAMUData->SetSegmentE(CloverNbr, SegmentNbr, Energy/keV); - m_GeTAMUData->SetSegmentT(CloverNbr, SegmentNbr, Time/ns); - - // If event passes through first stage fill the Interaction Coordinates - //Always calculated with respect to (0,0,0) - ms_InterCoord->SetDetectedPositionX(InterPos_X) ; - ms_InterCoord->SetDetectedPositionY(InterPos_Y) ; - ms_InterCoord->SetDetectedPositionZ(InterPos_Z) ; - ms_InterCoord->SetDetectedAngleTheta(InterPos_Theta/deg) ; - ms_InterCoord->SetDetectedAnglePhi(InterPos_Phi/deg) ; - - //add resolutions + G4int CloverNbr = (int)Info[7]; + G4int CrystalNbr = (int)Info[8]; + + // Figure out segment number + G4int SegmentNbr = 0; + if (fabs(InterPos_Z) < 20 * mm) { + SegmentNbr = 2; + } // MIDDLE + else if (CrystalNbr == 1 || CrystalNbr == 4) { + SegmentNbr = 1; + } // RIGHT + else { + SegmentNbr = 3; + } // LEFT + + if (Energy > 0.0 * keV) { + m_GeTAMUData->SetCoreE(CloverNbr, CrystalNbr, Energy / keV); + m_GeTAMUData->SetCoreT(CloverNbr, CrystalNbr, Time / ns); + m_GeTAMUData->SetSegmentE(CloverNbr, SegmentNbr, Energy / keV); + m_GeTAMUData->SetSegmentT(CloverNbr, SegmentNbr, Time / ns); + + // If event passes through first stage fill the Interaction Coordinates + // Always calculated with respect to (0,0,0) + ms_InterCoord->SetDetectedPositionX(InterPos_X); + ms_InterCoord->SetDetectedPositionY(InterPos_Y); + ms_InterCoord->SetDetectedPositionZ(InterPos_Z); + ms_InterCoord->SetDetectedAngleTheta(InterPos_Theta / deg); + ms_InterCoord->SetDetectedAnglePhi(InterPos_Phi / deg); + + // add resolutions G4double energyCry = RandGauss::shoot(Energy, ResoCry); G4double energySeg = RandGauss::shoot(Energy, ResoSeg); G4double time = RandGauss::shoot(Time, ResoTime); - - if(Energy > EnergyThreshold){ - m_GeTAMUData->SetCoreE(CloverNbr, CrystalNbr, energyCry/keV); - m_GeTAMUData->SetCoreT(CloverNbr, CrystalNbr, time/ns); - m_GeTAMUData->SetSegmentE(CloverNbr, SegmentNbr, energySeg/keV); - m_GeTAMUData->SetSegmentT(CloverNbr, SegmentNbr, time/ns); - } - + + if (Energy > EnergyThreshold) { + m_GeTAMUData->SetCoreE(CloverNbr, CrystalNbr, energyCry / keV); + m_GeTAMUData->SetCoreT(CloverNbr, CrystalNbr, time / ns); + m_GeTAMUData->SetSegmentE(CloverNbr, SegmentNbr, energySeg / keV); + m_GeTAMUData->SetSegmentT(CloverNbr, SegmentNbr, time / ns); + } } - } + } // clear map for next event HPGEHitMap->clear(); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void GeTAMU::InitializeScorers(){ - //Look for previous definition of the scorer (geometry reload) - //n.b. calls new G4MultiFunctionalDetector("GeTAMU_CoreScorer"); +void GeTAMU::InitializeScorers() { + // Look for previous definition of the scorer (geometry reload) + // n.b. calls new G4MultiFunctionalDetector("GeTAMU_CoreScorer"); bool already_exist = false; - m_HPGeScorer = CheckScorer("GeTAMU_Scorer",already_exist); + m_HPGeScorer = CheckScorer("GeTAMU_Scorer", already_exist); + + // if the scorer were created previously nothing else need to be made + if (already_exist) + return; - // if the scorer were created previously nothing else need to be made - if(already_exist) return; - // HPGe Associate Scorer - G4VPrimitiveScorer* HPGeScorer = new GETAMUSCORERS::PS_GeTAMU("GeTAMU",0); + G4VPrimitiveScorer* HPGeScorer = new GETAMUSCORERS::PS_GeTAMU("GeTAMU", 0); - //and register it to the multifunctionnal detector + // and register it to the multifunctionnal detector m_HPGeScorer->RegisterPrimitive(HPGeScorer); - // Add All Scorer to the Global Scorer Manager - G4SDManager::GetSDMpointer()->AddNewDetector(m_HPGeScorer) ; + // Add All Scorer to the Global Scorer Manager + G4SDManager::GetSDMpointer()->AddNewDetector(m_HPGeScorer); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //////////////////////////////////////////////////////////////// /////////////////Material Definition /////////////////////////// //////////////////////////////////////////////////////////////// -void GeTAMU::InitializeMaterial(){ +void GeTAMU::InitializeMaterial() { m_MaterialVacuum = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); - m_MaterialGe= MaterialManager::getInstance()->GetMaterialFromLibrary("Ge"); - m_MaterialAl= MaterialManager::getInstance()->GetMaterialFromLibrary("Al"); - m_MaterialN2= MaterialManager::getInstance()->GetMaterialFromLibrary("N2_liquid"); + m_MaterialGe = MaterialManager::getInstance()->GetMaterialFromLibrary("Ge"); + m_MaterialAl = MaterialManager::getInstance()->GetMaterialFromLibrary("Al"); + m_MaterialN2 = MaterialManager::getInstance()->GetMaterialFromLibrary("N2_liquid"); } - //////////////////////////////////////////////////////////////////////////////// // Construct Method to be pass to the DetectorFactory // //////////////////////////////////////////////////////////////////////////////// -NPS::VDetector* GeTAMU::Construct(){ - return (NPS::VDetector*) new GeTAMU(); -} +NPS::VDetector* GeTAMU::Construct() { return (NPS::VDetector*)new GeTAMU(); } //////////////////////////////////////////////////////////////////////////////// // Registering the construct method to the factory // //////////////////////////////////////////////////////////////////////////////// -extern"C" { -class proxy_nps_getamu{ -public: - proxy_nps_getamu(){ - NPS::DetectorFactory::getInstance()->AddToken("GeTAMU","GeTAMU"); - NPS::DetectorFactory::getInstance()->AddDetector("GeTAMU",GeTAMU::Construct); - } +extern "C" { +class proxy_nps_getamu { + public: + proxy_nps_getamu() { + NPS::DetectorFactory::getInstance()->AddToken("GeTAMU", "GeTAMU"); + NPS::DetectorFactory::getInstance()->AddDetector("GeTAMU", GeTAMU::Construct); + } }; proxy_nps_getamu p_nps_getamu; diff --git a/NPSimulation/Detectors/Helios/Helios.cc b/NPSimulation/Detectors/Helios/Helios.cc index c518a32d4510819d0b04e23e5cc94c56351b50c3..b17fa7ec91ee14bef6e80d0a6f0106035a7bb826 100644 --- a/NPSimulation/Detectors/Helios/Helios.cc +++ b/NPSimulation/Detectors/Helios/Helios.cc @@ -20,40 +20,40 @@ *****************************************************************************/ // C++ headers -#include <sstream> #include <cmath> #include <limits> -//G4 Geometry object -#include "G4Tubs.hh" +#include <sstream> +// G4 Geometry object #include "G4Box.hh" #include "G4SubtractionSolid.hh" +#include "G4Tubs.hh" -//G4 sensitive -#include "G4SDManager.hh" +// G4 sensitive #include "G4MultiFunctionalDetector.hh" +#include "G4SDManager.hh" -//G4 various object +// G4 various object +#include "G4Colour.hh" #include "G4Material.hh" -#include "G4Transform3D.hh" #include "G4PVPlacement.hh" +#include "G4Transform3D.hh" #include "G4VisAttributes.hh" -#include "G4Colour.hh" // G4 Field #include "G4FieldManager.hh" #include "G4MagneticField.hh" -#include "G4UniformMagField.hh" #include "G4TransportationManager.hh" +#include "G4UniformMagField.hh" // NPTool header -#include "Helios.hh" #include "DSSDScorers.hh" +#include "Helios.hh" #include "InteractionScorers.hh" -#include "RootOutput.h" #include "MaterialManager.hh" +#include "NPOptionManager.h" #include "NPSDetectorFactory.hh" +#include "RootOutput.h" #include "Target.hh" -#include "NPOptionManager.h" // CLHEP header #include "CLHEP/Random/RandGauss.h" @@ -61,141 +61,130 @@ using namespace std; using namespace CLHEP; //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -namespace Helios_NS{ +namespace Helios_NS { // Energy and time Resolution - const double EnergyThreshold = 100*keV; - const double ResoTime = 1*ns ; - const double ResoEnergyFront = 50*keV ; - const double ResoEnergyBack = 24*keV; - const double MagnetInnerRadius = 46*cm; - const double MagnetOutterRadius = 1*m; - const double MagnetLength = 2.35*m; - - const double SquareTubeSide = 16*mm; - const double SquareTubeExcess = 2.4*mm;// Wafer to Wafer distance - const double SquareTubeRadius = 5*mm; - const double WaferWidth = 12*mm ; - const double WaferLength = 56 *mm ; - const double ActiveWaferWidth = 9*mm ; - const double ActiveWaferLength = 50.5 *mm ; - const double AluThicness = 0.3*micrometer; - const double WaferThickness = 700* micrometer; -} + const double EnergyThreshold = 100 * keV; + const double ResoTime = 1 * ns; + const double ResoEnergyFront = 50 * keV; + const double ResoEnergyBack = 24 * keV; + const double MagnetInnerRadius = 46 * cm; + const double MagnetOutterRadius = 1 * m; + const double MagnetLength = 2.35 * m; + + const double SquareTubeSide = 16 * mm; + const double SquareTubeExcess = 2.4 * mm; // Wafer to Wafer distance + const double SquareTubeRadius = 5 * mm; + const double WaferWidth = 12 * mm; + const double WaferLength = 56 * mm; + const double ActiveWaferWidth = 9 * mm; + const double ActiveWaferLength = 50.5 * mm; + const double AluThicness = 0.3 * micrometer; + const double WaferThickness = 700 * micrometer; +} // namespace Helios_NS //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Helios Specific Method -Helios::Helios(){ - m_Event = new THeliosData() ; +Helios::Helios() { + m_Event = new THeliosData(); m_HeliosScorer = 0; m_SquareTube = 0; m_SiliconWafer = 0; m_ActiveWafer = 0; m_Magnet = 0; - m_B=0; + m_B = 0; // RGB Color + Transparency - m_VisSquareTube = new G4VisAttributes(G4Colour(0.8, 0.8, 0.8, 0.5)); - m_VisPassiveSilicon = new G4VisAttributes(G4Colour(0.1, 0.1, 0.1, 1)); - m_VisSilicon = new G4VisAttributes(G4Colour(0.3, 0.3, 0.3, 1)); - m_VisMagnet = new G4VisAttributes(G4Colour(0, 0.5, 1, 0.3)); + m_VisSquareTube = new G4VisAttributes(G4Colour(0.8, 0.8, 0.8, 0.5)); + m_VisPassiveSilicon = new G4VisAttributes(G4Colour(0.1, 0.1, 0.1, 1)); + m_VisSilicon = new G4VisAttributes(G4Colour(0.3, 0.3, 0.3, 1)); + m_VisMagnet = new G4VisAttributes(G4Colour(0, 0.5, 1, 0.3)); } -Helios::~Helios(){ -} +Helios::~Helios() {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Helios::AddHelios(double Z, string Face){ +void Helios::AddHelios(double Z, string Face) { m_Z.push_back(Z); m_Face.push_back(Face); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -G4LogicalVolume* Helios::BuildSquareTube(){ - if(!m_SquareTube){ - G4Box* box = new G4Box("Helios_Box",Helios_NS::SquareTubeSide*0.5, - Helios_NS::SquareTubeSide*0.5,0.5*(Helios_NS::SquareTubeExcess+Helios_NS::WaferLength)); - - G4Tubs* tubs = new G4Tubs("Helios_Box",0,Helios_NS::SquareTubeRadius, - (Helios_NS::SquareTubeExcess+Helios_NS::WaferLength),0,360*deg); +G4LogicalVolume* Helios::BuildSquareTube() { + if (!m_SquareTube) { + G4Box* box = new G4Box("Helios_Box", Helios_NS::SquareTubeSide * 0.5, Helios_NS::SquareTubeSide * 0.5, + 0.5 * (Helios_NS::SquareTubeExcess + Helios_NS::WaferLength)); + G4Tubs* tubs = new G4Tubs("Helios_Box", 0, Helios_NS::SquareTubeRadius, + (Helios_NS::SquareTubeExcess + Helios_NS::WaferLength), 0, 360 * deg); G4RotationMatrix* R = new G4RotationMatrix(); - G4ThreeVector P(0,0,0); - G4SubtractionSolid* sub = new G4SubtractionSolid("Helios_Sub",box,tubs,R,P); + G4ThreeVector P(0, 0, 0); + G4SubtractionSolid* sub = new G4SubtractionSolid("Helios_Sub", box, tubs, R, P); - G4Material* Al= MaterialManager::getInstance()->GetMaterialFromLibrary("Al"); - m_SquareTube= new G4LogicalVolume(sub,Al,"logic_Helios_Box",0,0,0); + G4Material* Al = MaterialManager::getInstance()->GetMaterialFromLibrary("Al"); + m_SquareTube = new G4LogicalVolume(sub, Al, "logic_Helios_Box", 0, 0, 0); m_SquareTube->SetVisAttributes(m_VisSquareTube); } return m_SquareTube; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -G4LogicalVolume* Helios::BuildSiliconWafer(){ - if(!m_SiliconWafer){ - G4Box* box1 = new G4Box("Helios_Box1",Helios_NS::WaferWidth*0.5, - Helios_NS::WaferThickness*0.5+Helios_NS::AluThicness,Helios_NS::WaferLength*0.5); - - G4Box* box2 = new G4Box("Helios_Box2",Helios_NS::ActiveWaferWidth*0.5, - Helios_NS::WaferThickness*0.5,Helios_NS::ActiveWaferLength*0.5); +G4LogicalVolume* Helios::BuildSiliconWafer() { + if (!m_SiliconWafer) { + G4Box* box1 = new G4Box("Helios_Box1", Helios_NS::WaferWidth * 0.5, + Helios_NS::WaferThickness * 0.5 + Helios_NS::AluThicness, Helios_NS::WaferLength * 0.5); + G4Box* box2 = new G4Box("Helios_Box2", Helios_NS::ActiveWaferWidth * 0.5, Helios_NS::WaferThickness * 0.5, + Helios_NS::ActiveWaferLength * 0.5); - G4Material* Si= MaterialManager::getInstance()->GetMaterialFromLibrary("Si"); - G4Material* Al= MaterialManager::getInstance()->GetMaterialFromLibrary("Al"); + G4Material* Si = MaterialManager::getInstance()->GetMaterialFromLibrary("Si"); + G4Material* Al = MaterialManager::getInstance()->GetMaterialFromLibrary("Al"); - m_SiliconWafer= new G4LogicalVolume(box1,Al,"logic_Helios_Wafer",0,0,0); - m_ActiveWafer= new G4LogicalVolume(box2,Si,"logic_Helios_ActiveWafer",0,0,0); + m_SiliconWafer = new G4LogicalVolume(box1, Al, "logic_Helios_Wafer", 0, 0, 0); + m_ActiveWafer = new G4LogicalVolume(box2, Si, "logic_Helios_ActiveWafer", 0, 0, 0); - G4ThreeVector AWPos(0,0,0); + G4ThreeVector AWPos(0, 0, 0); G4RotationMatrix* AWRot = new G4RotationMatrix(); - new G4PVPlacement(G4Transform3D(*AWRot,AWPos),m_ActiveWafer, - "Helios_ActiveWafer",m_SiliconWafer, true, 0); + new G4PVPlacement(G4Transform3D(*AWRot, AWPos), m_ActiveWafer, "Helios_ActiveWafer", m_SiliconWafer, true, 0); m_ActiveWafer->SetSensitiveDetector(m_HeliosScorer); m_SiliconWafer->SetVisAttributes(m_VisPassiveSilicon); m_ActiveWafer->SetVisAttributes(m_VisSilicon); - } - return m_SiliconWafer; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -G4LogicalVolume* Helios::BuildMagnet(){ - if(!m_Magnet){ - G4Tubs* tubs1 = new G4Tubs("Helios_MainFull",0, - Helios_NS::MagnetOutterRadius,Helios_NS::MagnetLength*0.5,0,360*deg); +G4LogicalVolume* Helios::BuildMagnet() { + if (!m_Magnet) { + G4Tubs* tubs1 = + new G4Tubs("Helios_MainFull", 0, Helios_NS::MagnetOutterRadius, Helios_NS::MagnetLength * 0.5, 0, 360 * deg); // Inner part of the Soleinoid minus the Target it self (placed in the world) - G4SubtractionSolid* tubs = new G4SubtractionSolid("Helios_Main", - tubs1, Target::GetTarget()->GetTargetSolid(), new G4RotationMatrix() ,Target::GetTarget()->GetTargetPosition()); + G4SubtractionSolid* tubs = new G4SubtractionSolid("Helios_Main", tubs1, Target::GetTarget()->GetTargetSolid(), + new G4RotationMatrix(), Target::GetTarget()->GetTargetPosition()); - G4Tubs* tubs2 = new G4Tubs("Helios_Mag",Helios_NS::MagnetInnerRadius, - Helios_NS::MagnetOutterRadius,Helios_NS::MagnetLength*0.5,0,360*deg); + G4Tubs* tubs2 = new G4Tubs("Helios_Mag", Helios_NS::MagnetInnerRadius, Helios_NS::MagnetOutterRadius, + Helios_NS::MagnetLength * 0.5, 0, 360 * deg); - G4Material* Fe= MaterialManager::getInstance()->GetMaterialFromLibrary("Fe"); - G4Material* Vc= MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); + G4Material* Fe = MaterialManager::getInstance()->GetMaterialFromLibrary("Fe"); + G4Material* Vc = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); - m_Magnet= new G4LogicalVolume(tubs,Vc,"logic_Helios_Main",0,0,0); - G4LogicalVolume* Mag = new G4LogicalVolume(tubs2,Fe,"logic_Helios_Magnet",0,0,0); + m_Magnet = new G4LogicalVolume(tubs, Vc, "logic_Helios_Main", 0, 0, 0); + G4LogicalVolume* Mag = new G4LogicalVolume(tubs2, Fe, "logic_Helios_Magnet", 0, 0, 0); Mag->SetVisAttributes(m_VisMagnet); - m_Magnet->SetVisAttributes(G4VisAttributes::Invisible); + m_Magnet->SetVisAttributes(G4VisAttributes::GetInvisible()); // Place the Solenoid - G4ThreeVector MagPos(0,0,0); + G4ThreeVector MagPos(0, 0, 0); G4RotationMatrix* MagRot = new G4RotationMatrix(); - new G4PVPlacement(G4Transform3D(*MagRot,MagPos), - Mag, - "Helios_Magnet",m_Magnet,false,0); - + new G4PVPlacement(G4Transform3D(*MagRot, MagPos), Mag, "Helios_Magnet", m_Magnet, false, 0); } return m_Magnet; } - - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... @@ -203,26 +192,26 @@ G4LogicalVolume* Helios::BuildMagnet(){ // Read stream at Configfile to pick-up parameters of detector (Position,...) // Called in DetecorConstruction::ReadDetextorConfiguration Method -void Helios::ReadConfiguration(NPL::InputParser parser ){ +void Helios::ReadConfiguration(NPL::InputParser parser) { vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithToken("Helios"); - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << "//// " << blocks.size() << " detectors found " << endl; + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks.size() << " detectors found " << endl; - vector<string> token = {"Z","Face"}; + vector<string> token = {"Z", "Face"}; - for(unsigned int i = 0 ; i < blocks.size() ; i++){ - if(blocks[i]->HasToken("MagneticField")) - m_B=blocks[i]->GetDouble("MagneticField","T"); + for (unsigned int i = 0; i < blocks.size(); i++) { + if (blocks[i]->HasToken("MagneticField")) + m_B = blocks[i]->GetDouble("MagneticField", "T"); - if(blocks[i]->HasTokenList(token)){ - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << endl << "//// Helios " << i+1 << endl; - double Z = blocks[i]->GetDouble("Z","mm"); + if (blocks[i]->HasTokenList(token)) { + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// Helios " << i + 1 << endl; + double Z = blocks[i]->GetDouble("Z", "mm"); string Face = blocks[i]->GetString("Face"); - AddHelios(Z,Face); + AddHelios(Z, Face); } - else{ + else { cout << "ERROR: check your input file formatting " << endl; exit(1); } @@ -233,148 +222,143 @@ void Helios::ReadConfiguration(NPL::InputParser parser ){ // Construct detector and inialise sensitive part. // Called After DetecorConstruction::AddDetector Method -void Helios::ConstructDetector(G4LogicalVolume* world){ +void Helios::ConstructDetector(G4LogicalVolume* world) { // Place the Solenoid - G4ThreeVector MagPos(0,0,0); + G4ThreeVector MagPos(0, 0, 0); G4RotationMatrix* MagRot = new G4RotationMatrix(); - new G4PVPlacement(G4Transform3D(*MagRot,MagPos), - BuildMagnet(), - "Helios",world,false,0); + new G4PVPlacement(G4Transform3D(*MagRot, MagPos), BuildMagnet(), "Helios", world, false, 0); // Add the Magnetic field static G4FieldManager* fieldMgr = new G4FieldManager(); - G4MagneticField* magField = new G4UniformMagField(G4ThreeVector(0.,0.,m_B)); + G4MagneticField* magField = new G4UniformMagField(G4ThreeVector(0., 0., m_B)); fieldMgr->SetDetectorField(magField); - if(!fieldMgr->GetChordFinder()) - fieldMgr->CreateChordFinder(magField); - BuildMagnet()->SetFieldManager(fieldMgr,true); + if (!fieldMgr->GetChordFinder()) + fieldMgr->CreateChordFinder(magField); + BuildMagnet()->SetFieldManager(fieldMgr, true); - fieldMgr->SetMinimumEpsilonStep( 1*mm); - fieldMgr->SetMaximumEpsilonStep( 10*m ); - fieldMgr->SetDeltaOneStep( 1 * mm ); + fieldMgr->SetMinimumEpsilonStep(1 * mm); + fieldMgr->SetMaximumEpsilonStep(10 * m); + fieldMgr->SetDeltaOneStep(1 * mm); // Place detectors and support inside it - for (unsigned short i = 0 ; i < m_Z.size() ; i++) { + for (unsigned short i = 0; i < m_Z.size(); i++) { G4ThreeVector DetPos; G4RotationMatrix* DetRot = NULL; - if(m_Face[i]=="Up"){ - DetPos = G4ThreeVector(0,Helios_NS::SquareTubeSide*0.5+1*mm,m_Z[i]); + if (m_Face[i] == "Up") { + DetPos = G4ThreeVector(0, Helios_NS::SquareTubeSide * 0.5 + 1 * mm, m_Z[i]); DetRot = new G4RotationMatrix(); } - else if(m_Face[i]=="Right"){ - DetPos = G4ThreeVector(Helios_NS::SquareTubeSide*0.5+1*mm,0,m_Z[i]); + else if (m_Face[i] == "Right") { + DetPos = G4ThreeVector(Helios_NS::SquareTubeSide * 0.5 + 1 * mm, 0, m_Z[i]); DetRot = new G4RotationMatrix(); - DetRot->rotateZ(90*deg); + DetRot->rotateZ(90 * deg); } - else if(m_Face[i]=="Down"){ - DetPos = G4ThreeVector(0,-Helios_NS::SquareTubeSide*0.5-1*mm,m_Z[i]); + else if (m_Face[i] == "Down") { + DetPos = G4ThreeVector(0, -Helios_NS::SquareTubeSide * 0.5 - 1 * mm, m_Z[i]); DetRot = new G4RotationMatrix(); - DetRot->rotateZ(180*deg); + DetRot->rotateZ(180 * deg); } - else if(m_Face[i]=="Left"){ - DetPos = G4ThreeVector(-Helios_NS::SquareTubeSide*0.5-1*mm,0,m_Z[i]); + else if (m_Face[i] == "Left") { + DetPos = G4ThreeVector(-Helios_NS::SquareTubeSide * 0.5 - 1 * mm, 0, m_Z[i]); DetRot = new G4RotationMatrix(); - DetRot->rotateZ(270*deg); + DetRot->rotateZ(270 * deg); } - else{ - cout << "Face orientation for Helios 2 detector "<< m_Face[i] << " Not Valid!" << endl; + else { + cout << "Face orientation for Helios 2 detector " << m_Face[i] << " Not Valid!" << endl; exit(1); } // Place the Silicon Wafer - new G4PVPlacement(G4Transform3D(*DetRot,DetPos), - BuildSiliconWafer(), - "Helios_SiliconWafer",BuildMagnet(),false,i+1); + new G4PVPlacement(G4Transform3D(*DetRot, DetPos), BuildSiliconWafer(), "Helios_SiliconWafer", BuildMagnet(), false, + i + 1); // Place the Square Tub - if(m_UsedZ.find(m_Z[i])==m_UsedZ.end()){ - G4ThreeVector TubePos(0,0,m_Z[i]); + if (m_UsedZ.find(m_Z[i]) == m_UsedZ.end()) { + G4ThreeVector TubePos(0, 0, m_Z[i]); G4RotationMatrix* TubeRot = new G4RotationMatrix(); - new G4PVPlacement(G4Transform3D(*TubeRot,TubePos), - BuildSquareTube(), - "Helios_SquareTube",BuildMagnet(),false,i+1); + new G4PVPlacement(G4Transform3D(*TubeRot, TubePos), BuildSquareTube(), "Helios_SquareTube", BuildMagnet(), false, + i + 1); m_UsedZ.insert(m_Z[i]); } } - } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Add Detector branch to the EventTree. // Called After DetecorConstruction::AddDetector Method -void Helios::InitializeRootOutput(){ - RootOutput *pAnalysis = RootOutput::getInstance(); - TTree *pTree = pAnalysis->GetTree(); - if(!pTree->FindBranch("Helios")){ - pTree->Branch("Helios", "THeliosData", &m_Event) ; +void Helios::InitializeRootOutput() { + RootOutput* pAnalysis = RootOutput::getInstance(); + TTree* pTree = pAnalysis->GetTree(); + if (!pTree->FindBranch("Helios")) { + pTree->Branch("Helios", "THeliosData", &m_Event); } - pTree->SetBranchAddress("Helios", &m_Event) ; - + pTree->SetBranchAddress("Helios", &m_Event); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Read sensitive part and fill the Root tree. // Called at in the EventAction::EndOfEventAvtion -void Helios::ReadSensitive(const G4Event* ){ +void Helios::ReadSensitive(const G4Event*) { m_Event->Clear(); /////////// // Resistiverimeter scorer - DSSDScorers::PS_Resistive* Scorer= (DSSDScorers::PS_Resistive*) m_HeliosScorer->GetPrimitive(0); - + DSSDScorers::PS_Resistive* Scorer = (DSSDScorers::PS_Resistive*)m_HeliosScorer->GetPrimitive(0); + // Loop on the Back unsigned int sizeBack = Scorer->GetBackMult(); - for(unsigned int i = 0 ; i < sizeBack ; i++){ - double EBack = RandGauss::shoot(Scorer->GetEnergyBack(i),Helios_NS::ResoEnergyBack); - double TBack = RandGauss::shoot(Scorer->GetTimeBack(i),Helios_NS::ResoTime); - if(EBack>Helios_NS::EnergyThreshold){ - m_Event->SetEBack(Scorer->GetDetectorBack(i),EBack); - m_Event->SetTBack(Scorer->GetDetectorBack(i),TBack); + for (unsigned int i = 0; i < sizeBack; i++) { + double EBack = RandGauss::shoot(Scorer->GetEnergyBack(i), Helios_NS::ResoEnergyBack); + double TBack = RandGauss::shoot(Scorer->GetTimeBack(i), Helios_NS::ResoTime); + if (EBack > Helios_NS::EnergyThreshold) { + m_Event->SetEBack(Scorer->GetDetectorBack(i), EBack); + m_Event->SetTBack(Scorer->GetDetectorBack(i), TBack); } } - // Loop on the Up + // Loop on the Up unsigned int sizeUp = Scorer->GetUpMult(); - for(unsigned int i = 0 ; i < sizeUp ; i++){ - double EUp = RandGauss::shoot(Scorer->GetEnergyUp(i),Helios_NS::ResoEnergyFront); - double TUp = RandGauss::shoot(Scorer->GetTimeUp(i),Helios_NS::ResoTime); - if(EUp>Helios_NS::EnergyThreshold){ - m_Event->SetEUp(Scorer->GetDetectorUp(i),EUp); - m_Event->SetTUp(Scorer->GetDetectorUp(i),TUp); + for (unsigned int i = 0; i < sizeUp; i++) { + double EUp = RandGauss::shoot(Scorer->GetEnergyUp(i), Helios_NS::ResoEnergyFront); + double TUp = RandGauss::shoot(Scorer->GetTimeUp(i), Helios_NS::ResoTime); + if (EUp > Helios_NS::EnergyThreshold) { + m_Event->SetEUp(Scorer->GetDetectorUp(i), EUp); + m_Event->SetTUp(Scorer->GetDetectorUp(i), TUp); } } - - // Loop on the Down + + // Loop on the Down unsigned int sizeDown = Scorer->GetDownMult(); - for(unsigned int i = 0 ; i < sizeDown ; i++){ - double EDw = RandGauss::shoot(Scorer->GetEnergyDown(i),Helios_NS::ResoEnergyFront); - double TDw = RandGauss::shoot(Scorer->GetTimeDown(i),Helios_NS::ResoTime); - if(EDw>Helios_NS::EnergyThreshold){ - m_Event->SetEDw(Scorer->GetDetectorDown(i),EDw); - m_Event->SetTDw(Scorer->GetDetectorDown(i),TDw); + for (unsigned int i = 0; i < sizeDown; i++) { + double EDw = RandGauss::shoot(Scorer->GetEnergyDown(i), Helios_NS::ResoEnergyFront); + double TDw = RandGauss::shoot(Scorer->GetTimeDown(i), Helios_NS::ResoTime); + if (EDw > Helios_NS::EnergyThreshold) { + m_Event->SetEDw(Scorer->GetDetectorDown(i), EDw); + m_Event->SetTDw(Scorer->GetDetectorDown(i), TDw); } } } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -//////////////////////////////////////////////////////////////// -void Helios::InitializeScorers() { +//////////////////////////////////////////////////////////////// +void Helios::InitializeScorers() { // This check is necessary in case the geometry is reloaded - bool already_exist = false; - m_HeliosScorer = CheckScorer("HeliosScorer",already_exist) ; + bool already_exist = false; + m_HeliosScorer = CheckScorer("HeliosScorer", already_exist); - if(already_exist) - return ; + if (already_exist) + return; // Otherwise the scorer is initialised - G4VPrimitiveScorer* Resistive= new DSSDScorers::PS_Resistive("Resistive",1,Helios_NS::WaferLength,Helios_NS::WaferWidth,1) ; - //and register it to the multifunctionnal detector + G4VPrimitiveScorer* Resistive = + new DSSDScorers::PS_Resistive("Resistive", "z", 1, Helios_NS::WaferLength, Helios_NS::WaferWidth, 1); + // and register it to the multifunctionnal detector m_HeliosScorer->RegisterPrimitive(Resistive); - G4VPrimitiveScorer* Inter = new InteractionScorers::PS_Interactions("Resistive",ms_InterCoord,1) ; + G4VPrimitiveScorer* Inter = new InteractionScorers::PS_Interactions("Resistive", ms_InterCoord, 1); m_HeliosScorer->RegisterPrimitive(Inter); - G4SDManager::GetSDMpointer()->AddNewDetector(m_HeliosScorer) ; + G4SDManager::GetSDMpointer()->AddNewDetector(m_HeliosScorer); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... @@ -383,22 +367,20 @@ void Helios::InitializeScorers() { //////////////////////////////////////////////////////////////////////////////// // Construct Method to be pass to the DetectorFactory // //////////////////////////////////////////////////////////////////////////////// -NPS::VDetector* Helios::Construct(){ - return (NPS::VDetector*) new Helios(); -} +NPS::VDetector* Helios::Construct() { return (NPS::VDetector*)new Helios(); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //////////////////////////////////////////////////////////////////////////////// // Registering the construct method to the factory // //////////////////////////////////////////////////////////////////////////////// -extern"C" { - class proxy_nps_Helios{ - public: - proxy_nps_Helios(){ - NPS::DetectorFactory::getInstance()->AddToken("Helios","Helios"); - NPS::DetectorFactory::getInstance()->AddDetector("Helios",Helios::Construct); - } - }; - - proxy_nps_Helios p_nps_Helios; +extern "C" { +class proxy_nps_Helios { + public: + proxy_nps_Helios() { + NPS::DetectorFactory::getInstance()->AddToken("Helios", "Helios"); + NPS::DetectorFactory::getInstance()->AddDetector("Helios", Helios::Construct); + } +}; + +proxy_nps_Helios p_nps_Helios; } diff --git a/NPSimulation/Detectors/Hira/Hira.cc b/NPSimulation/Detectors/Hira/Hira.cc index b68c39c58e45874bd02e8c5ddf49cae5c70bc41b..efb504727d7b02e257c47fa92b8f281096e7e475 100644 --- a/NPSimulation/Detectors/Hira/Hira.cc +++ b/NPSimulation/Detectors/Hira/Hira.cc @@ -20,41 +20,41 @@ *****************************************************************************/ // C++ headers -#include <sstream> #include <cmath> #include <limits> -//G4 Geometry object +#include <sstream> +// G4 Geometry object #include "G4Box.hh" -#include "G4Trd.hh" -#include "G4Trap.hh" -#include "G4Tubs.hh" #include "G4Cons.hh" -#include "G4UnionSolid.hh" #include "G4ExtrudedSolid.hh" +#include "G4Trap.hh" +#include "G4Trd.hh" +#include "G4Tubs.hh" #include "G4TwoVector.hh" -//G4 sensitive +#include "G4UnionSolid.hh" +// G4 sensitive #include "G4SDManager.hh" -//G4 various object -#include "G4Material.hh" -#include "G4Transform3D.hh" -#include "G4PVPlacement.hh" +// G4 various object #include "G4Colour.hh" +#include "G4Material.hh" #include "G4PVDivision.hh" +#include "G4PVPlacement.hh" #include "G4SubtractionSolid.hh" +#include "G4Transform3D.hh" // NPS +#include "CalorimeterScorers.hh" #include "Hira.hh" #include "MaterialManager.hh" #include "SiliconScorers.hh" -#include "CalorimeterScorers.hh" // NPL #include "NPOptionManager.h" -#include "RootOutput.h" #include "NPSDetectorFactory.hh" +#include "RootOutput.h" -//using namespace OBSOLETEGENERALSCORERS ; +// using namespace OBSOLETEGENERALSCORERS ; using namespace HIRA; @@ -65,495 +65,480 @@ using namespace std; using namespace CLHEP; //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -Hira::Hira(){ - InitializeMaterial(); - m_EventHira = new THiraData(); - - // Silicon - m_SiliconVisAtt = new G4VisAttributes(G4Colour(0.3, 0.28, 0.3, 0.95)) ; - m_SiliconVisAtt2 = new G4VisAttributes(G4Colour(0.3, 0.3, 0.3)) ; - // CsI Color - m_CsIVisAtt = new G4VisAttributes(G4Colour(0.529412, 0.807843, 0.980392, 0.95)) ; - m_CsIVisAtt->SetForceWireframe(false); - m_LogicThinSi = 0; - m_LogicThickSi = 0; - m_LogicCsICrystal = 0; - m_LogicCluster = 0; - - m_build_ThickSi= 1; - m_build_ThinSi= 1; - m_build_CsI= 1; +Hira::Hira() { + InitializeMaterial(); + m_EventHira = new THiraData(); + + // Silicon + m_SiliconVisAtt = new G4VisAttributes(G4Colour(0.3, 0.28, 0.3, 0.95)); + m_SiliconVisAtt2 = new G4VisAttributes(G4Colour(0.3, 0.3, 0.3)); + // CsI Color + m_CsIVisAtt = new G4VisAttributes(G4Colour(0.529412, 0.807843, 0.980392, 0.95)); + m_CsIVisAtt->SetForceWireframe(false); + m_LogicThinSi = 0; + m_LogicThickSi = 0; + m_LogicCsICrystal = 0; + m_LogicCluster = 0; + + m_build_ThickSi = 1; + m_build_ThinSi = 1; + m_build_CsI = 1; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -Hira::~Hira(){ -} +Hira::~Hira() {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Virtual Method of VDetector class // Read stream at Configfile to pick-up parameters of detector (Position,...) // Called in DetecorConstruction::ReadDetextorConfiguration Method -void Hira::ReadConfiguration(NPL::InputParser parser ){ - vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithToken("HiraTelescope"); - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << "//// " << blocks.size() << " Telescope found " << endl; - - // Cartesian Case - vector<string> cart = {"A","B","C","D","ThickSi_E","ThinSi_DE","CsI"}; - for(unsigned int i = 0 ; i < blocks.size() ; i++){ - if(blocks[i]->HasTokenList(cart)){ - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << endl << "//// Hira Telescope " << i+1 << endl; - G4ThreeVector A = NPS::ConvertVector(blocks[i]->GetTVector3("A","mm")); - G4ThreeVector B = NPS::ConvertVector(blocks[i]->GetTVector3("B","mm")); - G4ThreeVector C = NPS::ConvertVector(blocks[i]->GetTVector3("C","mm")); - G4ThreeVector D = NPS::ConvertVector(blocks[i]->GetTVector3("D","mm")); - m_build_ThinSi = blocks[i]->GetInt("ThinSi_DE"); - m_build_ThickSi = blocks[i]->GetInt("ThickSi_E"); - m_build_CsI = blocks[i]->GetInt("CsI"); - - AddTelescope(A,B,C,D) ; - } - - else{ - cout << "ERROR: Missing token for M2Telescope blocks, check your input file" << endl; - exit(1); - } +void Hira::ReadConfiguration(NPL::InputParser parser) { + vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithToken("HiraTelescope"); + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks.size() << " Telescope found " << endl; + + // Cartesian Case + vector<string> cart = {"A", "B", "C", "D", "ThickSi_E", "ThinSi_DE", "CsI"}; + for (unsigned int i = 0; i < blocks.size(); i++) { + if (blocks[i]->HasTokenList(cart)) { + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// Hira Telescope " << i + 1 << endl; + G4ThreeVector A = NPS::ConvertVector(blocks[i]->GetTVector3("A", "mm")); + G4ThreeVector B = NPS::ConvertVector(blocks[i]->GetTVector3("B", "mm")); + G4ThreeVector C = NPS::ConvertVector(blocks[i]->GetTVector3("C", "mm")); + G4ThreeVector D = NPS::ConvertVector(blocks[i]->GetTVector3("D", "mm")); + m_build_ThinSi = blocks[i]->GetInt("ThinSi_DE"); + m_build_ThickSi = blocks[i]->GetInt("ThickSi_E"); + m_build_CsI = blocks[i]->GetInt("CsI"); + + AddTelescope(A, B, C, D); } + + else { + cout << "ERROR: Missing token for M2Telescope blocks, check your input file" << endl; + exit(1); + } + } } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Hira::AddTelescope(G4ThreeVector Pos1, G4ThreeVector Pos2, G4ThreeVector Pos3, G4ThreeVector Pos4){ - G4ThreeVector Pos=(Pos1+Pos2+Pos3+Pos4)/4.; - G4ThreeVector u = Pos4-Pos2; - G4ThreeVector w = Pos.unit(); - G4ThreeVector v = w.cross(u); - u = u.unit(); v = v.unit(); w = w.unit(); - Pos = Pos + w*Length*0.5; - - m_Type.push_back(1); - m_Pos.push_back(Pos); - m_Rot.push_back(new G4RotationMatrix(u,v,w)); +void Hira::AddTelescope(G4ThreeVector Pos1, G4ThreeVector Pos2, G4ThreeVector Pos3, G4ThreeVector Pos4) { + G4ThreeVector Pos = (Pos1 + Pos2 + Pos3 + Pos4) / 4.; + G4ThreeVector u = Pos4 - Pos2; + G4ThreeVector w = Pos.unit(); + G4ThreeVector v = w.cross(u); + u = u.unit(); + v = v.unit(); + w = w.unit(); + Pos = Pos + w * Length * 0.5; + + m_Type.push_back(1); + m_Pos.push_back(Pos); + m_Rot.push_back(new G4RotationMatrix(u, v, w)); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Construct detector and inialise sensitive part. // Called After DetecorConstruction::AddDetector Method -void Hira::ConstructDetector(G4LogicalVolume* world){ - unsigned int mysize = m_Pos.size(); - - for(unsigned int i = 0 ; i < mysize ; i++){ - VolumeMaker(i + 1, m_Pos[i], m_Rot[i], world); - } -} - +void Hira::ConstructDetector(G4LogicalVolume* world) { + unsigned int mysize = m_Pos.size(); + for (unsigned int i = 0; i < mysize; i++) { + VolumeMaker(i + 1, m_Pos[i], m_Rot[i], world); + } +} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Read sensitive part and fill the Root tree. // Called at in the EventAction::EndOfEventAvtion -void Hira::ReadSensitive(const G4Event* event){ - m_EventHira->Clear(); - - // ThinSi // - if(m_build_ThinSi){ - NPS::HitsMap<G4double*>* ThinSiHitMap; - std::map<G4int, G4double**>::iterator ThinSi_itr; - - G4int ThinSiCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("Hira_ThinSiScorer/ThinSi"); - ThinSiHitMap = (NPS::HitsMap<G4double*>*)(event->GetHCofThisEvent()->GetHC(ThinSiCollectionID)); - - // Loop on the ThinSi map - for (ThinSi_itr = ThinSiHitMap->GetMap()->begin() ; ThinSi_itr != ThinSiHitMap->GetMap()->end() ; ThinSi_itr++){ - G4double* Info = *(ThinSi_itr->second); - double E_ThinSi = RandGauss::shoot(Info[0],ResoThinSi); - - if(E_ThinSi>EnergyThreshold){ - m_EventHira->SetHiraThinSiStripEEnergy(E_ThinSi); - m_EventHira->SetHiraThinSiStripEDetectorNbr(Info[7]-1); - m_EventHira->SetHiraThinSiStripEStripNbr(Info[8]-1); - - m_EventHira->SetHiraThinSiStripTTime(Info[1]); - m_EventHira->SetHiraThinSiStripTDetectorNbr(Info[7]-1); - m_EventHira->SetHiraThinSiStripTStripNbr(Info[8]-1); - } - } - - // Clear Map for next event - ThinSiHitMap->clear(); +void Hira::ReadSensitive(const G4Event* event) { + m_EventHira->Clear(); + + // ThinSi // + if (m_build_ThinSi) { + NPS::HitsMap<G4double*>* ThinSiHitMap; + std::map<G4int, G4double**>::iterator ThinSi_itr; + + G4int ThinSiCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("Hira_ThinSiScorer/ThinSi"); + ThinSiHitMap = (NPS::HitsMap<G4double*>*)(event->GetHCofThisEvent()->GetHC(ThinSiCollectionID)); + + // Loop on the ThinSi map + for (ThinSi_itr = ThinSiHitMap->GetMap()->begin(); ThinSi_itr != ThinSiHitMap->GetMap()->end(); ThinSi_itr++) { + G4double* Info = *(ThinSi_itr->second); + double E_ThinSi = RandGauss::shoot(Info[0], ResoThinSi); + + if (E_ThinSi > EnergyThreshold) { + m_EventHira->SetHiraThinSiStripEEnergy(E_ThinSi); + m_EventHira->SetHiraThinSiStripEDetectorNbr(Info[7] - 1); + m_EventHira->SetHiraThinSiStripEStripNbr(Info[8] - 1); + + m_EventHira->SetHiraThinSiStripTTime(Info[1]); + m_EventHira->SetHiraThinSiStripTDetectorNbr(Info[7] - 1); + m_EventHira->SetHiraThinSiStripTStripNbr(Info[8] - 1); + } } - - // ThickSi // - if(m_build_ThickSi){ - NPS::HitsMap<G4double*>* ThickSiHitMap; - std::map<G4int, G4double**>::iterator ThickSi_itr; - G4int ThickSiCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("Hira_ThickSiScorer/ThickSi"); - ThickSiHitMap = (NPS::HitsMap<G4double*>*)(event->GetHCofThisEvent()->GetHC(ThickSiCollectionID)); - - // Loop on the ThickSi map - for (ThickSi_itr = ThickSiHitMap->GetMap()->begin() ; ThickSi_itr != ThickSiHitMap->GetMap()->end() ; ThickSi_itr++){ - G4double* Info = *(ThickSi_itr->second); - double EF = RandGauss::shoot(Info[0],ResoThickSi); - double EB = RandGauss::shoot(Info[0],ResoThickSi); - - // Interraction Coordinates - ms_InterCoord->SetDetectedPositionX(Info[2]) ; - ms_InterCoord->SetDetectedPositionY(Info[3]) ; - ms_InterCoord->SetDetectedPositionZ(Info[4]) ; - ms_InterCoord->SetDetectedAngleTheta(Info[5]/deg) ; - ms_InterCoord->SetDetectedAnglePhi(Info[6]/deg) ; - - if(EF>EnergyThreshold){ - m_EventHira->SetHiraThickSiStripXEEnergy(EF); - m_EventHira->SetHiraThickSiStripXEDetectorNbr(Info[7]-1); - m_EventHira->SetHiraThickSiStripXEStripNbr(Info[8]-1); - - m_EventHira->SetHiraThickSiStripXTTime(Info[1]); - m_EventHira->SetHiraThickSiStripXTDetectorNbr(Info[7]-1); - m_EventHira->SetHiraThickSiStripXTStripNbr(Info[8]-1); - } - - if(EB>EnergyThreshold){ - m_EventHira->SetHiraThickSiStripYEEnergy(EB); - m_EventHira->SetHiraThickSiStripYEDetectorNbr(Info[7]-1); - m_EventHira->SetHiraThickSiStripYEStripNbr(Info[9]-1); - - m_EventHira->SetHiraThickSiStripYTTime(Info[1]); - m_EventHira->SetHiraThickSiStripYTDetectorNbr(Info[7]-1); - m_EventHira->SetHiraThickSiStripYTStripNbr(Info[9]-1); - - } - } - // Clear Map for next event - ThickSiHitMap->clear(); + + // Clear Map for next event + ThinSiHitMap->clear(); + } + + // ThickSi // + if (m_build_ThickSi) { + NPS::HitsMap<G4double*>* ThickSiHitMap; + std::map<G4int, G4double**>::iterator ThickSi_itr; + G4int ThickSiCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("Hira_ThickSiScorer/ThickSi"); + ThickSiHitMap = (NPS::HitsMap<G4double*>*)(event->GetHCofThisEvent()->GetHC(ThickSiCollectionID)); + + // Loop on the ThickSi map + for (ThickSi_itr = ThickSiHitMap->GetMap()->begin(); ThickSi_itr != ThickSiHitMap->GetMap()->end(); ThickSi_itr++) { + G4double* Info = *(ThickSi_itr->second); + double EF = RandGauss::shoot(Info[0], ResoThickSi); + double EB = RandGauss::shoot(Info[0], ResoThickSi); + + // Interraction Coordinates + ms_InterCoord->SetDetectedPositionX(Info[2]); + ms_InterCoord->SetDetectedPositionY(Info[3]); + ms_InterCoord->SetDetectedPositionZ(Info[4]); + ms_InterCoord->SetDetectedAngleTheta(Info[5] / deg); + ms_InterCoord->SetDetectedAnglePhi(Info[6] / deg); + + if (EF > EnergyThreshold) { + m_EventHira->SetHiraThickSiStripXEEnergy(EF); + m_EventHira->SetHiraThickSiStripXEDetectorNbr(Info[7] - 1); + m_EventHira->SetHiraThickSiStripXEStripNbr(Info[8] - 1); + + m_EventHira->SetHiraThickSiStripXTTime(Info[1]); + m_EventHira->SetHiraThickSiStripXTDetectorNbr(Info[7] - 1); + m_EventHira->SetHiraThickSiStripXTStripNbr(Info[8] - 1); + } + + if (EB > EnergyThreshold) { + m_EventHira->SetHiraThickSiStripYEEnergy(EB); + m_EventHira->SetHiraThickSiStripYEDetectorNbr(Info[7] - 1); + m_EventHira->SetHiraThickSiStripYEStripNbr(Info[9] - 1); + + m_EventHira->SetHiraThickSiStripYTTime(Info[1]); + m_EventHira->SetHiraThickSiStripYTDetectorNbr(Info[7] - 1); + m_EventHira->SetHiraThickSiStripYTStripNbr(Info[9] - 1); + } } - - // CsI // - if(m_build_CsI){ - CalorimeterScorers::PS_Calorimeter* Scorer= (CalorimeterScorers::PS_Calorimeter*) m_CsIScorer->GetPrimitive(0); - unsigned int size = Scorer->GetMult(); - for(unsigned int i = 0 ; i < size ; i++){ - vector<unsigned int> level = Scorer->GetLevel(i); - double E_CsI = RandGauss::shoot(Scorer->GetEnergy(i),ResoCsI); - if(E_CsI>EnergyThreshold){ - m_EventHira->SetHiraCsIEEnergy(E_CsI); - m_EventHira->SetHiraCsIEDetectorNbr(level[0]-1); - m_EventHira->SetHiraCsIECristalNbr(level[1]-1); - } - } + // Clear Map for next event + ThickSiHitMap->clear(); + } + + // CsI // + if (m_build_CsI) { + CalorimeterScorers::PS_Calorimeter* Scorer = (CalorimeterScorers::PS_Calorimeter*)m_CsIScorer->GetPrimitive(0); + unsigned int size = Scorer->GetMult(); + for (unsigned int i = 0; i < size; i++) { + vector<unsigned int> level = Scorer->GetLevel(i); + double E_CsI = RandGauss::shoot(Scorer->GetEnergy(i), ResoCsI); + if (E_CsI > EnergyThreshold) { + m_EventHira->SetHiraCsIEEnergy(E_CsI); + m_EventHira->SetHiraCsIEDetectorNbr(level[0] - 1); + m_EventHira->SetHiraCsIECristalNbr(level[1] - 1); + } } + } } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Hira::InitializeScorers(){ - //Look for previous definition of the scorer (geometry reload) - bool already_exist = false; - vector<G4int> NestingLevel; - NestingLevel.push_back(0); - NestingLevel.push_back(2); - - m_ThinSiStripScorer = CheckScorer("Hira_ThinSiScorer",already_exist); - m_ThickSiStripScorer = CheckScorer("Hira_ThickSiScorer",already_exist); - m_CsIScorer = CheckScorer("Hira_CsIScorer",already_exist); - - // if the scorer were created previously nothing else need to be made - if(already_exist) return; - - G4VPrimitiveScorer* ThinSiScorer = new SILICONSCORERS::PS_Silicon_Rectangle("ThinSi",0, - SiliconFace, - SiliconFace, - NumberOfStrip, - 1); - - m_ThinSiStripScorer->RegisterPrimitive(ThinSiScorer); - - G4VPrimitiveScorer* ThickSiScorer = new SILICONSCORERS::PS_Silicon_Rectangle("ThickSi",0, - SiliconFace, - SiliconFace, - NumberOfStrip, - NumberOfStrip); - - m_ThickSiStripScorer->RegisterPrimitive(ThickSiScorer); - - G4VPrimitiveScorer* CsIScorer= new CalorimeterScorers::PS_Calorimeter("CsI",NestingLevel); - - m_CsIScorer->RegisterPrimitive(CsIScorer); - - // Add All Scorer to the Global Scorer Manager - G4SDManager::GetSDMpointer()->AddNewDetector(m_ThinSiStripScorer) ; - G4SDManager::GetSDMpointer()->AddNewDetector(m_ThickSiStripScorer) ; - G4SDManager::GetSDMpointer()->AddNewDetector(m_CsIScorer) ; +void Hira::InitializeScorers() { + // Look for previous definition of the scorer (geometry reload) + bool already_exist = false; + vector<G4int> NestingLevel; + NestingLevel.push_back(0); + NestingLevel.push_back(2); + + m_ThinSiStripScorer = CheckScorer("Hira_ThinSiScorer", already_exist); + m_ThickSiStripScorer = CheckScorer("Hira_ThickSiScorer", already_exist); + m_CsIScorer = CheckScorer("Hira_CsIScorer", already_exist); + + // if the scorer were created previously nothing else need to be made + if (already_exist) + return; + + G4VPrimitiveScorer* ThinSiScorer = + new SILICONSCORERS::PS_Silicon_Rectangle("ThinSi", 0, SiliconFace, SiliconFace, NumberOfStrip, 1); + + m_ThinSiStripScorer->RegisterPrimitive(ThinSiScorer); + + G4VPrimitiveScorer* ThickSiScorer = + new SILICONSCORERS::PS_Silicon_Rectangle("ThickSi", 0, SiliconFace, SiliconFace, NumberOfStrip, NumberOfStrip); + + m_ThickSiStripScorer->RegisterPrimitive(ThickSiScorer); + + G4VPrimitiveScorer* CsIScorer = new CalorimeterScorers::PS_Calorimeter("CsI", NestingLevel); + + m_CsIScorer->RegisterPrimitive(CsIScorer); + + // Add All Scorer to the Global Scorer Manager + G4SDManager::GetSDMpointer()->AddNewDetector(m_ThinSiStripScorer); + G4SDManager::GetSDMpointer()->AddNewDetector(m_ThickSiStripScorer); + G4SDManager::GetSDMpointer()->AddNewDetector(m_CsIScorer); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Hira::InitializeRootOutput(){ - TTree *pTree = RootOutput::getInstance()->GetTree(); - if(!pTree->FindBranch("Hira")){ - pTree->Branch("Hira", "THiraData", &m_EventHira) ; - } - // This insure that the object are correctly bind in case of - // a redifinition of the geometry in the simulation - pTree->SetBranchAddress("Hira", &m_EventHira) ; +void Hira::InitializeRootOutput() { + TTree* pTree = RootOutput::getInstance()->GetTree(); + if (!pTree->FindBranch("Hira")) { + pTree->Branch("Hira", "THiraData", &m_EventHira); + } + // This insure that the object are correctly bind in case of + // a redifinition of the geometry in the simulation + pTree->SetBranchAddress("Hira", &m_EventHira); } - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Hira::VolumeMaker(G4int DetectorNumber, - G4ThreeVector MMpos, - G4RotationMatrix* MMrot, - G4LogicalVolume* world) -{ - G4double NbrTelescopes = DetectorNumber ; - G4String DetNumber ; - ostringstream Number ; - Number << NbrTelescopes ; - DetNumber = Number.str() ; - - - //////////////////////////////////////////////////////////////// - ////////////// Starting Volume Definition ////////////////////// - //////////////////////////////////////////////////////////////// - G4String Name = "Hira" + DetNumber ; - - // Definition of the volume containing the sensitive detector - G4Box* solidMotherVolume = new G4Box(Name, 0.5*FaceFront, 0.5*FaceBack, 0.5*Length); - m_logicMotherVolume = new G4LogicalVolume(solidMotherVolume, m_MaterialVacuum, Name, 0, 0, 0); - - new G4PVPlacement(G4Transform3D(*MMrot, MMpos), m_logicMotherVolume, Name, world, false, DetectorNumber); - - G4VisAttributes* MotherVolumeVisAtt = new G4VisAttributes(G4Colour(0.90, 0.90, 0.90)); - MotherVolumeVisAtt->SetForceWireframe(true); - m_logicMotherVolume->SetVisAttributes(G4VisAttributes::Invisible); - - /////////////////////////////////////////////////// - ///////////////////// Thin Si ///////////////////// - /////////////////////////////////////////////////// - G4String NameThinSi = "ThinSi"+DetNumber; - //if(!m_LogicThinSi){ - if(m_build_ThinSi){ - G4Box* solidThinSi = new G4Box(NameThinSi, 0.5*SiliconFace, 0.5*SiliconFace, 0.5*ThinSiThickness); ; - m_LogicThinSi = new G4LogicalVolume(solidThinSi, m_MaterialSilicon, "logicThinSi", 0, 0, 0); - - G4ThreeVector positionThinSi = G4ThreeVector(0, 0, ThinSi_PosZ); - - new G4PVPlacement(new G4RotationMatrix(0,0,0), - positionThinSi, - m_LogicThinSi,"ThinSi", - m_logicMotherVolume,false,DetectorNumber); - - // Set ThinSi sensible - m_LogicThinSi->SetSensitiveDetector(m_ThinSiStripScorer); - - // Visualisation of ThinSi - m_LogicThinSi->SetVisAttributes(m_SiliconVisAtt) ; - } - - /////////////////////////////////////////////////// - ///////////////////// Thick Si //////////////////// - /////////////////////////////////////////////////// - G4String NameThickSi = "ThickSi"+DetNumber; - //if(!m_LogicThickSi){ - if(m_build_ThickSi){ - G4Box* solidThickSi = new G4Box(NameThickSi, 0.5*SiliconFace, 0.5*SiliconFace, 0.5*ThickSiThickness); - m_LogicThickSi = new G4LogicalVolume(solidThickSi, m_MaterialSilicon, "logicThickSi", 0, 0, 0); - - G4ThreeVector positionThickSi = G4ThreeVector(0, 0, ThickSi_PosZ); - - new G4PVPlacement(new G4RotationMatrix(0,0,0), - positionThickSi, - m_LogicThickSi,"ThickSi", - m_logicMotherVolume,false,DetectorNumber); - - // Set ThickSi sensible - m_LogicThickSi->SetSensitiveDetector(m_ThickSiStripScorer); - - // Visualisation of ThickSi - m_LogicThickSi->SetVisAttributes(m_SiliconVisAtt2) ; - } - - /////////////////////////////////////////////////// - /////////////////////// CsI /////////////////////// - /////////////////////////////////////////////////// - G4String NameCsI = "CsI"+DetNumber; - - double X1 = (CsIXFront-CsIXBack)/2.; - double Y1 = (CsIYFront-CsIYBack)/2.; - double l = sqrt(pow(X1,2) + pow(Y1,2)); - - double pDz = 0.5*CsIThickness; - double pTheta = -atan( (l)/(CsIThickness) ); - double pPhi = atan( X1/Y1 ); - double pDy1 = 0.5*CsIYFront; - double pDx1 = 0.5*CsIXFront; - double pDx2 = 0.5*CsIXFront; - double pAlp1 = 0; - double pDy2 = 0.5*CsIYBack; - double pDx3 = 0.5*CsIXBack; - double pDx4 = 0.5*CsIXBack; - double pAlp2 = 0; - - G4Trap* solidCsIStage = new G4Trap(NameCsI, pDz, pTheta, pPhi, pDy1, pDx1, pDx2, pAlp1, pDy2, pDx3, pDx4, pAlp2); - - m_LogicCsICrystal = new G4LogicalVolume(solidCsIStage, m_MaterialCsI, "logicCsICrystal", 0, 0, 0); - - // Set CsI sensible - m_LogicCsICrystal->SetSensitiveDetector(m_CsIScorer); - - // Visualisation of CsI - m_LogicCsICrystal->SetVisAttributes(m_CsIVisAtt); - - //if(!m_LogicCluster){ - if(m_build_CsI){ - // Sub Mother Volume - G4Trd* solidCluster = new G4Trd("SolidCluster", 0.5*ClusterFaceFront,0.5*ClusterFaceBack,0.5*ClusterFaceFront,0.5*ClusterFaceBack, 0.5*CsIThickness); - m_LogicCluster = new G4LogicalVolume(solidCluster, m_MaterialVacuum, "LogicSolidCluster", 0, 0, 0); - m_LogicCluster->SetVisAttributes(G4VisAttributes::Invisible); - G4VisAttributes* TempVisAtt = new G4VisAttributes(G4Colour(0.415686, 0.352941, 0.803922, 0.1)) ; - TempVisAtt->SetForceWireframe(true); - m_LogicCluster->SetVisAttributes(TempVisAtt); - - G4ThreeVector FramePos(0,0,CsI_PosZ); - - new G4PVPlacement(new G4RotationMatrix(0,0,0), - FramePos, - m_LogicCluster,"Cluster", - m_logicMotherVolume,false,0); - - //double alpha = atan((CsIXBack-CsIXFront)/CsIThickness); - //double dl = (CsIThickness/2)*tan(alpha); - double dl = (CsIXBack-CsIXFront)/4; - const G4double CsIXMiddle = 0.5*CsIXFront + dl; - const G4double CsIYMiddle = 0.5*CsIYFront + dl; - const G4double DistInterCsIX = CsIXMiddle+0.5*DistInterCsI; - const G4double DistInterCsIY = CsIYMiddle+0.5*DistInterCsI; - - G4ThreeVector Origin(-(DistInterCsIX),-(DistInterCsIY),0); - G4ThreeVector Pos; - const G4double dangle = 90.*deg; - // A cluster is a 2 by 2 aggregat of CsI crystal - unsigned int CsINbr = 1; - for(unsigned int i = 0 ; i < 2 ; i++){ - for(unsigned int j = 0 ; j < 2 ; j++){ - G4RotationMatrix* rotM = new G4RotationMatrix; - unsigned int CrystalNbr = CsINbr++; - if(i==0 && j==0)rotM->rotateZ(0); - if(i==1 && j==0)rotM->rotateZ(dangle); - if(i==0 && j==1)rotM->rotateZ(-dangle); - if(i==1 && j==1)rotM->rotateZ(2*dangle); - - if(i==0 && j==0) Pos = Origin; - if(i==1 && j==0) Pos = G4ThreeVector((DistInterCsIX),-(DistInterCsIY),0); - if(i==0 && j==1) Pos = G4ThreeVector(-(DistInterCsIX),(DistInterCsIY),0); - if(i==1 && j==1) Pos = G4ThreeVector((DistInterCsIX),(DistInterCsIY),0); - //Pos = Origin + G4ThreeVector(i*(DistInterCsIX),j*(DistInterCsIY),0); - - new G4PVPlacement(G4Transform3D(*rotM,Pos), - m_LogicCsICrystal, - "CsI_Cristal", - m_LogicCluster, - false, - CrystalNbr,false); - delete rotM; - } - } - - ///////////////////// - // 3x3 CsI crystal // - ///////////////////// - /*double pTheta_1 = -5.6*deg; - double pPhi_1 = 46.5*deg; - G4Trap* solidCsI1 = new G4Trap(NameCsI, 0.5*CsIThickness, pTheta_1, pPhi_1, 0.5*23.73, 0.5*23.73, 0.5*23.73, 0, 0.5*32.53, 0.5*32.53, 0.5*32.53, 0); - - cout << "Theta1= " << pTheta_1*180/3.1415 << endl; - cout << "Phi1= " << pPhi_1*180/3.1415 << endl; - - double pTheta_2 = -4.0*deg; - double pPhi_2 = 0*deg; - G4Trap* solidCsI2 = new G4Trap(NameCsI, 0.5*CsIThickness, pTheta_2, pPhi_2, 0.5*22.55, 0.5*23.73, 0.5*23.73, 0, 0.5*28.05, 0.5*32.53, 0.5*32.53, 0); - - G4Trd* solidCsI3 = new G4Trd("SolidCluster", 0.5*22.55,0.5*28.05,0.5*22.55,0.5*28.05, 0.5*CsIThickness); - - G4RotationMatrix* rotM1 = new G4RotationMatrix; - m_LogicCsICrystal = new G4LogicalVolume(solidCsI1, m_MaterialCsI, "logicCsICrystal", 0, 0, 0); - m_LogicCsICrystal->SetSensitiveDetector(m_CsIScorer); - m_LogicCsICrystal->SetVisAttributes(m_CsIVisAtt); - double Xpos = 27; - double Ypos = 27; - Pos = G4ThreeVector(-Xpos,-Ypos,0); - rotM1->rotateZ(0*deg); - new G4PVPlacement(G4Transform3D(*rotM1,Pos),m_LogicCsICrystal,"CsI_Cristal1",m_LogicCluster,false,1,true); - - rotM1->rotateZ(-90*deg); - Pos = G4ThreeVector(-Xpos,Ypos,0); - new G4PVPlacement(G4Transform3D(*rotM1,Pos),m_LogicCsICrystal,"CsI_Cristal2",m_LogicCluster,false,3,true); - - rotM1->rotateZ(-90*deg); - Pos = G4ThreeVector(Xpos,Ypos,0); - new G4PVPlacement(G4Transform3D(*rotM1,Pos),m_LogicCsICrystal,"CsI_Cristal7",m_LogicCluster,false,7,true); - - rotM1->rotateZ(-90*deg); - Pos = G4ThreeVector(Xpos,-Ypos,0); - new G4PVPlacement(G4Transform3D(*rotM1,Pos),m_LogicCsICrystal,"CsI_Cristal9",m_LogicCluster,false,9,true); - - G4RotationMatrix* rotM3 = new G4RotationMatrix; - m_LogicCsICrystal = new G4LogicalVolume(solidCsI3, m_MaterialCsI, "logicCsICrystal", 0, 0, 0); - m_LogicCsICrystal->SetSensitiveDetector(m_CsIScorer); - m_LogicCsICrystal->SetVisAttributes(m_CsIVisAtt); - Pos = G4ThreeVector(0.,0.,0); - rotM3->rotateZ(0); - new G4PVPlacement(G4Transform3D(*rotM3,Pos),m_LogicCsICrystal,"CsI_Cristal5",m_LogicCluster,false,5,true); - - G4RotationMatrix* rotM2 = new G4RotationMatrix; - m_LogicCsICrystal = new G4LogicalVolume(solidCsI2, m_MaterialCsI, "logicCsICrystal", 0, 0, 0); - m_LogicCsICrystal->SetSensitiveDetector(m_CsIScorer); - m_LogicCsICrystal->SetVisAttributes(m_CsIVisAtt); - Pos = G4ThreeVector(-Xpos,0.,0); - rotM2->rotateZ(0*deg); - new G4PVPlacement(G4Transform3D(*rotM2,Pos),m_LogicCsICrystal,"CsI_Cristal2",m_LogicCluster,false,2,true); - - Pos = G4ThreeVector(Xpos,0.,0); - rotM2->rotateZ(180*deg); - new G4PVPlacement(G4Transform3D(*rotM2,Pos),m_LogicCsICrystal,"CsI_Cristal8",m_LogicCluster,false,8,true); - Pos = G4ThreeVector(0,-Ypos,0); - rotM2->rotateZ(-90*deg); - new G4PVPlacement(G4Transform3D(*rotM2,Pos),m_LogicCsICrystal,"CsI_Cristal4",m_LogicCluster,false,4,true); - - Pos = G4ThreeVector(0,Ypos,0); - rotM2->rotateZ(180*deg); - new G4PVPlacement(G4Transform3D(*rotM2,Pos),m_LogicCsICrystal,"CsI_Cristal6",m_LogicCluster,false,6,true);*/ - +void Hira::VolumeMaker(G4int DetectorNumber, G4ThreeVector MMpos, G4RotationMatrix* MMrot, G4LogicalVolume* world) { + G4double NbrTelescopes = DetectorNumber; + G4String DetNumber; + ostringstream Number; + Number << NbrTelescopes; + DetNumber = Number.str(); + + //////////////////////////////////////////////////////////////// + ////////////// Starting Volume Definition ////////////////////// + //////////////////////////////////////////////////////////////// + G4String Name = "Hira" + DetNumber; + + // Definition of the volume containing the sensitive detector + G4Box* solidMotherVolume = new G4Box(Name, 0.5 * FaceFront, 0.5 * FaceBack, 0.5 * Length); + m_logicMotherVolume = new G4LogicalVolume(solidMotherVolume, m_MaterialVacuum, Name, 0, 0, 0); + + new G4PVPlacement(G4Transform3D(*MMrot, MMpos), m_logicMotherVolume, Name, world, false, DetectorNumber); + + G4VisAttributes* MotherVolumeVisAtt = new G4VisAttributes(G4Colour(0.90, 0.90, 0.90)); + MotherVolumeVisAtt->SetForceWireframe(true); + m_logicMotherVolume->SetVisAttributes(G4VisAttributes::GetInvisible()); + + /////////////////////////////////////////////////// + ///////////////////// Thin Si ///////////////////// + /////////////////////////////////////////////////// + G4String NameThinSi = "ThinSi" + DetNumber; + // if(!m_LogicThinSi){ + if (m_build_ThinSi) { + G4Box* solidThinSi = new G4Box(NameThinSi, 0.5 * SiliconFace, 0.5 * SiliconFace, 0.5 * ThinSiThickness); + ; + m_LogicThinSi = new G4LogicalVolume(solidThinSi, m_MaterialSilicon, "logicThinSi", 0, 0, 0); + + G4ThreeVector positionThinSi = G4ThreeVector(0, 0, ThinSi_PosZ); + + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), positionThinSi, m_LogicThinSi, "ThinSi", m_logicMotherVolume, + false, DetectorNumber); + + // Set ThinSi sensible + m_LogicThinSi->SetSensitiveDetector(m_ThinSiStripScorer); + + // Visualisation of ThinSi + m_LogicThinSi->SetVisAttributes(m_SiliconVisAtt); + } + + /////////////////////////////////////////////////// + ///////////////////// Thick Si //////////////////// + /////////////////////////////////////////////////// + G4String NameThickSi = "ThickSi" + DetNumber; + // if(!m_LogicThickSi){ + if (m_build_ThickSi) { + G4Box* solidThickSi = new G4Box(NameThickSi, 0.5 * SiliconFace, 0.5 * SiliconFace, 0.5 * ThickSiThickness); + m_LogicThickSi = new G4LogicalVolume(solidThickSi, m_MaterialSilicon, "logicThickSi", 0, 0, 0); + + G4ThreeVector positionThickSi = G4ThreeVector(0, 0, ThickSi_PosZ); + + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), positionThickSi, m_LogicThickSi, "ThickSi", m_logicMotherVolume, + false, DetectorNumber); + + // Set ThickSi sensible + m_LogicThickSi->SetSensitiveDetector(m_ThickSiStripScorer); + + // Visualisation of ThickSi + m_LogicThickSi->SetVisAttributes(m_SiliconVisAtt2); + } + + /////////////////////////////////////////////////// + /////////////////////// CsI /////////////////////// + /////////////////////////////////////////////////// + G4String NameCsI = "CsI" + DetNumber; + + double X1 = (CsIXFront - CsIXBack) / 2.; + double Y1 = (CsIYFront - CsIYBack) / 2.; + double l = sqrt(pow(X1, 2) + pow(Y1, 2)); + + double pDz = 0.5 * CsIThickness; + double pTheta = -atan((l) / (CsIThickness)); + double pPhi = atan(X1 / Y1); + double pDy1 = 0.5 * CsIYFront; + double pDx1 = 0.5 * CsIXFront; + double pDx2 = 0.5 * CsIXFront; + double pAlp1 = 0; + double pDy2 = 0.5 * CsIYBack; + double pDx3 = 0.5 * CsIXBack; + double pDx4 = 0.5 * CsIXBack; + double pAlp2 = 0; + + G4Trap* solidCsIStage = new G4Trap(NameCsI, pDz, pTheta, pPhi, pDy1, pDx1, pDx2, pAlp1, pDy2, pDx3, pDx4, pAlp2); + + m_LogicCsICrystal = new G4LogicalVolume(solidCsIStage, m_MaterialCsI, "logicCsICrystal", 0, 0, 0); + + // Set CsI sensible + m_LogicCsICrystal->SetSensitiveDetector(m_CsIScorer); + + // Visualisation of CsI + m_LogicCsICrystal->SetVisAttributes(m_CsIVisAtt); + + // if(!m_LogicCluster){ + if (m_build_CsI) { + // Sub Mother Volume + G4Trd* solidCluster = new G4Trd("SolidCluster", 0.5 * ClusterFaceFront, 0.5 * ClusterFaceBack, + 0.5 * ClusterFaceFront, 0.5 * ClusterFaceBack, 0.5 * CsIThickness); + m_LogicCluster = new G4LogicalVolume(solidCluster, m_MaterialVacuum, "LogicSolidCluster", 0, 0, 0); + m_LogicCluster->SetVisAttributes(G4VisAttributes::GetInvisible()); + G4VisAttributes* TempVisAtt = new G4VisAttributes(G4Colour(0.415686, 0.352941, 0.803922, 0.1)); + TempVisAtt->SetForceWireframe(true); + m_LogicCluster->SetVisAttributes(TempVisAtt); + + G4ThreeVector FramePos(0, 0, CsI_PosZ); + + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), FramePos, m_LogicCluster, "Cluster", m_logicMotherVolume, false, + 0); + + // double alpha = atan((CsIXBack-CsIXFront)/CsIThickness); + // double dl = (CsIThickness/2)*tan(alpha); + double dl = (CsIXBack - CsIXFront) / 4; + const G4double CsIXMiddle = 0.5 * CsIXFront + dl; + const G4double CsIYMiddle = 0.5 * CsIYFront + dl; + const G4double DistInterCsIX = CsIXMiddle + 0.5 * DistInterCsI; + const G4double DistInterCsIY = CsIYMiddle + 0.5 * DistInterCsI; + + G4ThreeVector Origin(-(DistInterCsIX), -(DistInterCsIY), 0); + G4ThreeVector Pos; + const G4double dangle = 90. * deg; + // A cluster is a 2 by 2 aggregat of CsI crystal + unsigned int CsINbr = 1; + for (unsigned int i = 0; i < 2; i++) { + for (unsigned int j = 0; j < 2; j++) { + G4RotationMatrix* rotM = new G4RotationMatrix; + unsigned int CrystalNbr = CsINbr++; + if (i == 0 && j == 0) + rotM->rotateZ(0); + if (i == 1 && j == 0) + rotM->rotateZ(dangle); + if (i == 0 && j == 1) + rotM->rotateZ(-dangle); + if (i == 1 && j == 1) + rotM->rotateZ(2 * dangle); + + if (i == 0 && j == 0) + Pos = Origin; + if (i == 1 && j == 0) + Pos = G4ThreeVector((DistInterCsIX), -(DistInterCsIY), 0); + if (i == 0 && j == 1) + Pos = G4ThreeVector(-(DistInterCsIX), (DistInterCsIY), 0); + if (i == 1 && j == 1) + Pos = G4ThreeVector((DistInterCsIX), (DistInterCsIY), 0); + // Pos = Origin + G4ThreeVector(i*(DistInterCsIX),j*(DistInterCsIY),0); + + new G4PVPlacement(G4Transform3D(*rotM, Pos), m_LogicCsICrystal, "CsI_Cristal", m_LogicCluster, false, + CrystalNbr, false); + delete rotM; + } } -} + ///////////////////// + // 3x3 CsI crystal // + ///////////////////// + /*double pTheta_1 = -5.6*deg; + double pPhi_1 = 46.5*deg; + G4Trap* solidCsI1 = new G4Trap(NameCsI, 0.5*CsIThickness, pTheta_1, pPhi_1, 0.5*23.73, 0.5*23.73, 0.5*23.73, 0, + 0.5*32.53, 0.5*32.53, 0.5*32.53, 0); + + cout << "Theta1= " << pTheta_1*180/3.1415 << endl; + cout << "Phi1= " << pPhi_1*180/3.1415 << endl; + + double pTheta_2 = -4.0*deg; + double pPhi_2 = 0*deg; + G4Trap* solidCsI2 = new G4Trap(NameCsI, 0.5*CsIThickness, pTheta_2, pPhi_2, 0.5*22.55, 0.5*23.73, 0.5*23.73, 0, + 0.5*28.05, 0.5*32.53, 0.5*32.53, 0); + + G4Trd* solidCsI3 = new G4Trd("SolidCluster", 0.5*22.55,0.5*28.05,0.5*22.55,0.5*28.05, 0.5*CsIThickness); + + G4RotationMatrix* rotM1 = new G4RotationMatrix; + m_LogicCsICrystal = new G4LogicalVolume(solidCsI1, m_MaterialCsI, "logicCsICrystal", 0, 0, 0); + m_LogicCsICrystal->SetSensitiveDetector(m_CsIScorer); + m_LogicCsICrystal->SetVisAttributes(m_CsIVisAtt); + double Xpos = 27; + double Ypos = 27; + Pos = G4ThreeVector(-Xpos,-Ypos,0); + rotM1->rotateZ(0*deg); + new G4PVPlacement(G4Transform3D(*rotM1,Pos),m_LogicCsICrystal,"CsI_Cristal1",m_LogicCluster,false,1,true); + + rotM1->rotateZ(-90*deg); + Pos = G4ThreeVector(-Xpos,Ypos,0); + new G4PVPlacement(G4Transform3D(*rotM1,Pos),m_LogicCsICrystal,"CsI_Cristal2",m_LogicCluster,false,3,true); + + rotM1->rotateZ(-90*deg); + Pos = G4ThreeVector(Xpos,Ypos,0); + new G4PVPlacement(G4Transform3D(*rotM1,Pos),m_LogicCsICrystal,"CsI_Cristal7",m_LogicCluster,false,7,true); + + rotM1->rotateZ(-90*deg); + Pos = G4ThreeVector(Xpos,-Ypos,0); + new G4PVPlacement(G4Transform3D(*rotM1,Pos),m_LogicCsICrystal,"CsI_Cristal9",m_LogicCluster,false,9,true); + + G4RotationMatrix* rotM3 = new G4RotationMatrix; + m_LogicCsICrystal = new G4LogicalVolume(solidCsI3, m_MaterialCsI, "logicCsICrystal", 0, 0, 0); + m_LogicCsICrystal->SetSensitiveDetector(m_CsIScorer); + m_LogicCsICrystal->SetVisAttributes(m_CsIVisAtt); + Pos = G4ThreeVector(0.,0.,0); + rotM3->rotateZ(0); + new G4PVPlacement(G4Transform3D(*rotM3,Pos),m_LogicCsICrystal,"CsI_Cristal5",m_LogicCluster,false,5,true); + + G4RotationMatrix* rotM2 = new G4RotationMatrix; + m_LogicCsICrystal = new G4LogicalVolume(solidCsI2, m_MaterialCsI, "logicCsICrystal", 0, 0, 0); + m_LogicCsICrystal->SetSensitiveDetector(m_CsIScorer); + m_LogicCsICrystal->SetVisAttributes(m_CsIVisAtt); + Pos = G4ThreeVector(-Xpos,0.,0); + rotM2->rotateZ(0*deg); + new G4PVPlacement(G4Transform3D(*rotM2,Pos),m_LogicCsICrystal,"CsI_Cristal2",m_LogicCluster,false,2,true); + + Pos = G4ThreeVector(Xpos,0.,0); + rotM2->rotateZ(180*deg); + new G4PVPlacement(G4Transform3D(*rotM2,Pos),m_LogicCsICrystal,"CsI_Cristal8",m_LogicCluster,false,8,true); + Pos = G4ThreeVector(0,-Ypos,0); + rotM2->rotateZ(-90*deg); + new G4PVPlacement(G4Transform3D(*rotM2,Pos),m_LogicCsICrystal,"CsI_Cristal4",m_LogicCluster,false,4,true); + + Pos = G4ThreeVector(0,Ypos,0); + rotM2->rotateZ(180*deg); + new G4PVPlacement(G4Transform3D(*rotM2,Pos),m_LogicCsICrystal,"CsI_Cristal6",m_LogicCluster,false,6,true);*/ + } +} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Hira::InitializeMaterial(){ - m_MaterialSilicon = MaterialManager::getInstance()->GetMaterialFromLibrary("Si"); - m_MaterialAluminium = MaterialManager::getInstance()->GetMaterialFromLibrary("Al"); - m_MaterialCsI = MaterialManager::getInstance()->GetMaterialFromLibrary("CsI"); - m_MaterialMylar = MaterialManager::getInstance()->GetMaterialFromLibrary("Mylar"); - m_MaterialPCB = MaterialManager::getInstance()->GetMaterialFromLibrary("PCB"); - m_MaterialVacuum = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); +void Hira::InitializeMaterial() { + m_MaterialSilicon = MaterialManager::getInstance()->GetMaterialFromLibrary("Si"); + m_MaterialAluminium = MaterialManager::getInstance()->GetMaterialFromLibrary("Al"); + m_MaterialCsI = MaterialManager::getInstance()->GetMaterialFromLibrary("CsI"); + m_MaterialMylar = MaterialManager::getInstance()->GetMaterialFromLibrary("Mylar"); + m_MaterialPCB = MaterialManager::getInstance()->GetMaterialFromLibrary("PCB"); + m_MaterialVacuum = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); } //////////////////////////////////////////////////////////////////////////////// // Construct Method to be pass to the DetectorFactory // //////////////////////////////////////////////////////////////////////////////// -NPS::VDetector* Hira::Construct(){ - return (NPS::VDetector*) new Hira(); -} +NPS::VDetector* Hira::Construct() { return (NPS::VDetector*)new Hira(); } //////////////////////////////////////////////////////////////////////////////// // Registering the construct method to the factory // //////////////////////////////////////////////////////////////////////////////// -extern"C" { - class proxy_nps_hira{ - public: - proxy_nps_hira(){ - NPS::DetectorFactory::getInstance()->AddToken("HiraTelescope","Hira"); - NPS::DetectorFactory::getInstance()->AddDetector("HiraTelescope",Hira::Construct); - } - }; - - proxy_nps_hira p_nps_hira; +extern "C" { +class proxy_nps_hira { + public: + proxy_nps_hira() { + NPS::DetectorFactory::getInstance()->AddToken("HiraTelescope", "Hira"); + NPS::DetectorFactory::getInstance()->AddDetector("HiraTelescope", Hira::Construct); + } +}; + +proxy_nps_hira p_nps_hira; } diff --git a/NPSimulation/Detectors/Hyde2/Hyde2TrackerSquare1.cc b/NPSimulation/Detectors/Hyde2/Hyde2TrackerSquare1.cc index e1b5daddc92a69cba501839e029c32fabac4371f..cb4f1f1112f1d75912cc97314ac0212eeb912511 100644 --- a/NPSimulation/Detectors/Hyde2/Hyde2TrackerSquare1.cc +++ b/NPSimulation/Detectors/Hyde2/Hyde2TrackerSquare1.cc @@ -25,36 +25,36 @@ *****************************************************************************/ // C++ headers +#include <cmath> #include <sstream> #include <string> -#include <cmath> // G4 Geometry headers -#include "G4Trd.hh" #include "G4Box.hh" #include "G4Trap.hh" +#include "G4Trd.hh" // G4 various headers -#include "G4MaterialTable.hh" +#include "G4Colour.hh" #include "G4Element.hh" #include "G4ElementTable.hh" -#include "G4VisAttributes.hh" -#include "G4Colour.hh" +#include "G4MaterialTable.hh" +#include "G4PVDivision.hh" +#include "G4PVPlacement.hh" #include "G4RotationMatrix.hh" #include "G4Transform3D.hh" -#include "G4PVPlacement.hh" -#include "G4PVDivision.hh" +#include "G4VisAttributes.hh" // G4 sensitive -#include "G4SDManager.hh" #include "G4MultiFunctionalDetector.hh" +#include "G4SDManager.hh" // NPTool headers +#include "Hyde2Scorers.hh" #include "Hyde2TrackerSquare1.hh" +#include "NPSVDetector.hh" #include "ObsoleteGeneralScorers.hh" -#include "Hyde2Scorers.hh" #include "RootOutput.h" -#include "NPSVDetector.hh" // CLHEP #include "CLHEP/Random/RandGauss.h" @@ -62,137 +62,97 @@ using namespace std; using namespace CLHEP; using namespace HYD2SQUARE1; - - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -Hyde2TrackerSquare1::Hyde2TrackerSquare1() -{ - ms_InterCoord = 0; -} - - +Hyde2TrackerSquare1::Hyde2TrackerSquare1() { ms_InterCoord = 0; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -Hyde2TrackerSquare1::~Hyde2TrackerSquare1() -{ -} - - +Hyde2TrackerSquare1::~Hyde2TrackerSquare1() {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Hyde2TrackerSquare1::AddModule(G4ThreeVector X1_Y1 , - G4ThreeVector X128_Y1 , - G4ThreeVector X1_Y128 , - G4ThreeVector X128_Y128 , - bool wFirstStage , - bool wSecondStage , - bool wThirdStage , - bool wFourthStage , - bool wFifthStage , - bool wSixthStage) -{ - m_DefinitionType.push_back(true) ; - - m_X1_Y1.push_back(X1_Y1) ; - m_X128_Y1.push_back(X128_Y1) ; - m_X1_Y128.push_back(X1_Y128) ; - m_X128_Y128.push_back(X128_Y128) ; - m_wFirstStage.push_back(wFirstStage) ; - m_wSecondStage.push_back(wSecondStage) ; - m_wThirdStage.push_back(wThirdStage) ; - m_wFourthStage.push_back(wFourthStage) ; - m_wFifthStage.push_back(wFifthStage) ; - m_wSixthStage.push_back(wSixthStage) ; - - m_R.push_back(0) ; - m_Theta.push_back(0) ; - m_Phi.push_back(0) ; - m_beta_u.push_back(0) ; - m_beta_v.push_back(0) ; - m_beta_w.push_back(0) ; +void Hyde2TrackerSquare1::AddModule(G4ThreeVector X1_Y1, G4ThreeVector X128_Y1, G4ThreeVector X1_Y128, + G4ThreeVector X128_Y128, bool wFirstStage, bool wSecondStage, bool wThirdStage, + bool wFourthStage, bool wFifthStage, bool wSixthStage) { + m_DefinitionType.push_back(true); + + m_X1_Y1.push_back(X1_Y1); + m_X128_Y1.push_back(X128_Y1); + m_X1_Y128.push_back(X1_Y128); + m_X128_Y128.push_back(X128_Y128); + m_wFirstStage.push_back(wFirstStage); + m_wSecondStage.push_back(wSecondStage); + m_wThirdStage.push_back(wThirdStage); + m_wFourthStage.push_back(wFourthStage); + m_wFifthStage.push_back(wFifthStage); + m_wSixthStage.push_back(wSixthStage); + + m_R.push_back(0); + m_Theta.push_back(0); + m_Phi.push_back(0); + m_beta_u.push_back(0); + m_beta_v.push_back(0); + m_beta_w.push_back(0); } - - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Hyde2TrackerSquare1::AddModule(G4double R , - G4double Theta , - G4double Phi , - G4double beta_u , - G4double beta_v , - G4double beta_w , - bool wFirstStage , - bool wSecondStage , - bool wThirdStage , - bool wFourthStage , - bool wFifthStage , - bool wSixthStage) -{ - G4ThreeVector empty = G4ThreeVector(0, 0, 0); - - m_DefinitionType.push_back(false); - - m_R.push_back(R) ; - m_Theta.push_back(Theta) ; - m_Phi.push_back(Phi) ; - m_beta_u.push_back(beta_u) ; - m_beta_v.push_back(beta_v) ; - m_beta_w.push_back(beta_w) ; - m_wFirstStage.push_back(wFirstStage) ; - m_wSecondStage.push_back(wSecondStage) ; - m_wThirdStage.push_back(wThirdStage) ; - m_wFourthStage.push_back(wFourthStage) ; - m_wFifthStage.push_back(wFifthStage) ; - m_wSixthStage.push_back(wSixthStage) ; - - m_X1_Y1.push_back(empty) ; - m_X128_Y1.push_back(empty) ; - m_X1_Y128.push_back(empty) ; - m_X128_Y128.push_back(empty) ; +void Hyde2TrackerSquare1::AddModule(G4double R, G4double Theta, G4double Phi, G4double beta_u, G4double beta_v, + G4double beta_w, bool wFirstStage, bool wSecondStage, bool wThirdStage, + bool wFourthStage, bool wFifthStage, bool wSixthStage) { + G4ThreeVector empty = G4ThreeVector(0, 0, 0); + + m_DefinitionType.push_back(false); + + m_R.push_back(R); + m_Theta.push_back(Theta); + m_Phi.push_back(Phi); + m_beta_u.push_back(beta_u); + m_beta_v.push_back(beta_v); + m_beta_w.push_back(beta_w); + m_wFirstStage.push_back(wFirstStage); + m_wSecondStage.push_back(wSecondStage); + m_wThirdStage.push_back(wThirdStage); + m_wFourthStage.push_back(wFourthStage); + m_wFifthStage.push_back(wFifthStage); + m_wSixthStage.push_back(wSixthStage); + + m_X1_Y1.push_back(empty); + m_X128_Y1.push_back(empty); + m_X1_Y128.push_back(empty); + m_X128_Y128.push_back(empty); } - - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Hyde2TrackerSquare1::VolumeMaker(G4int TelescopeNumber, - G4ThreeVector MMpos, - G4RotationMatrix* MMrot, - bool wFirstStage, - bool wSecondStage, - bool wThirdStage, - bool wFourthStage, - bool wFifthStage , - bool wSixthStage , - G4LogicalVolume* world) -{ - G4double NbrTelescopes = TelescopeNumber ; - G4String DetectorNumber ; - ostringstream Number ; - Number << NbrTelescopes ; - DetectorNumber = Number.str() ; - - //////////////////////////////////////////////////////////////// - ////////////// Starting Volume Definition ////////////////////// - //////////////////////////////////////////////////////////////// - G4String Name = "HYD2Square1" + DetectorNumber; - - G4Box* solidHYD2Square1 = new G4Box(Name, 0.5*FaceFront, 0.5*FaceFront, 0.5*Length); - G4LogicalVolume* logicHYD2Square1 = new G4LogicalVolume(solidHYD2Square1, m_MaterialVacuum, Name, 0, 0, 0); - - new G4PVPlacement(G4Transform3D(*MMrot, MMpos), logicHYD2Square1, Name, world, false, 0); - - logicHYD2Square1->SetVisAttributes(G4VisAttributes::Invisible); - if (m_non_sensitive_part_visiualisation) logicHYD2Square1->SetVisAttributes(G4VisAttributes(G4Colour(0.90, 0.90, 0.90))); - - //Place two marker to identify the u and v axis on silicon face: - //marker are placed a bit before the silicon itself so they don't perturbate simulation - //Uncomment to help debugging or if you want to understand the way the code work. - //I should recommand to Comment it during simulation to avoid perturbation of simulation - //Remember G4 is limitationg step on geometry constraints. - /* +void Hyde2TrackerSquare1::VolumeMaker(G4int TelescopeNumber, G4ThreeVector MMpos, G4RotationMatrix* MMrot, + bool wFirstStage, bool wSecondStage, bool wThirdStage, bool wFourthStage, + bool wFifthStage, bool wSixthStage, G4LogicalVolume* world) { + G4double NbrTelescopes = TelescopeNumber; + G4String DetectorNumber; + ostringstream Number; + Number << NbrTelescopes; + DetectorNumber = Number.str(); + + //////////////////////////////////////////////////////////////// + ////////////// Starting Volume Definition ////////////////////// + //////////////////////////////////////////////////////////////// + G4String Name = "HYD2Square1" + DetectorNumber; + + G4Box* solidHYD2Square1 = new G4Box(Name, 0.5 * FaceFront, 0.5 * FaceFront, 0.5 * Length); + G4LogicalVolume* logicHYD2Square1 = new G4LogicalVolume(solidHYD2Square1, m_MaterialVacuum, Name, 0, 0, 0); + + new G4PVPlacement(G4Transform3D(*MMrot, MMpos), logicHYD2Square1, Name, world, false, 0); + + logicHYD2Square1->SetVisAttributes(G4VisAttributes::GetInvisible()); + if (m_non_sensitive_part_visiualisation) + logicHYD2Square1->SetVisAttributes(G4VisAttributes(G4Colour(0.90, 0.90, 0.90))); + + // Place two marker to identify the u and v axis on silicon face: + // marker are placed a bit before the silicon itself so they don't perturbate simulation + // Uncomment to help debugging or if you want to understand the way the code work. + // I should recommand to Comment it during simulation to avoid perturbation of simulation + // Remember G4 is limitationg step on geometry constraints. + /* G4ThreeVector positionMarkerU = CT*0.98 + MMu*SiliconFace/4; G4Box* solidMarkerU = new G4Box( "solidMarkerU" , SiliconFace/4 , 1*mm , 1*mm ) ; - G4LogicalVolume* logicMarkerU = new G4LogicalVolume( solidMarkerU , m_MaterialVacuum , "logicMarkerU",0,0,0) ; + G4LogicalVolume* logicMarkerU = new G4LogicalVolume( solidMarkerU , m_MaterialVacuum , "logicMarkerU",0,0,0) ; PVPBuffer = new G4PVPlacement(G4Transform3D(*MMrot,positionMarkerU),logicMarkerU,"MarkerU",world,false,0) ; G4VisAttributes* MarkerUVisAtt= new G4VisAttributes(G4Colour(0.,0.,0.5));//blue @@ -200,169 +160,144 @@ void Hyde2TrackerSquare1::VolumeMaker(G4int TelescopeNumber, G4ThreeVector positionMarkerV = CT*0.98 + MMv*SiliconFace/4; G4Box* solidMarkerV = new G4Box( "solidMarkerU" , 1*mm , SiliconFace/4 , 1*mm ) ; - G4LogicalVolume* logicMarkerV = new G4LogicalVolume( solidMarkerV , m_MaterialVacuum , "logicMarkerV",0,0,0) ; + G4LogicalVolume* logicMarkerV = new G4LogicalVolume( solidMarkerV , m_MaterialVacuum , "logicMarkerV",0,0,0) ; PVPBuffer = new G4PVPlacement(G4Transform3D(*MMrot,positionMarkerV),logicMarkerV,"MarkerV",world,false,0) ; G4VisAttributes* MarkerVVisAtt= new G4VisAttributes(G4Colour(0.,0.5,0.5));//green logicMarkerV->SetVisAttributes(MarkerVVisAtt); */ - //////////////////////////////////////////////////////////////// - //////////////// First Stage Construction ////////////////////// - //////////////////////////////////////////////////////////////// - if (wFirstStage) { - // Silicon detector itself - G4ThreeVector positionFirstStage = G4ThreeVector(0, 0, FirstStage_PosZ); - - G4Box* solidFirstStage = new G4Box("solidFirstStage", 0.5*FirstStageFace, 0.5*FirstStageFace, 0.5*FirstStageThickness); - G4LogicalVolume* logicFirstStage = new G4LogicalVolume(solidFirstStage, m_MaterialSilicon, "logicFirstStage", 0, 0, 0); - - new G4PVPlacement(0, - positionFirstStage, - logicFirstStage, - Name + "_FirstStage", - logicHYD2Square1, - false, - 0); - - // Set First Stage sensible - logicFirstStage->SetSensitiveDetector(m_FirstStageScorer); - - ///Visualisation of FirstStage Strip - G4VisAttributes* FirstStageVisAtt = new G4VisAttributes(G4Colour(0.0, 0.0, 0.9)); // blue - logicFirstStage->SetVisAttributes(FirstStageVisAtt); - } - - //////////////////////////////////////////////////////////////// - //////////////////// Second Stage Construction //////////////// - //////////////////////////////////////////////////////////////// - if (wSecondStage) { - // Second stage silicon detector - G4ThreeVector positionSecondStage = G4ThreeVector(0, 0, SecondStage_PosZ); - - G4Box* solidSecondStage = new G4Box("solidSecondStage", 0.5*SecondStageFace, 0.5*SecondStageFace, 0.5*SecondStageThickness); - G4LogicalVolume* logicSecondStage = new G4LogicalVolume(solidSecondStage, m_MaterialSilicon, "logicSecondStage", 0, 0, 0); - - new G4PVPlacement(0, - positionSecondStage, - logicSecondStage, - Name + "_SecondStage", - logicHYD2Square1, - false, - 0); - - // Set Second Stage sensible - logicSecondStage->SetSensitiveDetector(m_SecondStageScorer); - - ///Visualisation of SecondStage Strip - G4VisAttributes* SecondStageVisAtt = new G4VisAttributes(G4Colour(0.5, 0.5, 0.5)) ; - logicSecondStage->SetVisAttributes(SecondStageVisAtt) ; - } - - //////////////////////////////////////////////////////////////// - ///////////////// Third Stage Construction ///////////////////// - //////////////////////////////////////////////////////////////// - if (wThirdStage) { - // Third stage silicon detector - G4ThreeVector positionThirdStage = G4ThreeVector(0, 0, ThirdStage_PosZ); - - G4Box* solidThirdStage = new G4Box("solidThirdStage", 0.5*ThirdStageFace, 0.5*ThirdStageFace, 0.5*ThirdStageThickness); - G4LogicalVolume* logicThirdStage = new G4LogicalVolume(solidThirdStage, m_MaterialSilicon, "logicThirdStage", 0, 0, 0); - - new G4PVPlacement(0, - positionThirdStage, - logicThirdStage, - Name + "_ThirdStage", - logicHYD2Square1, - false, - 0); - - // Set Third Stage sensible - logicThirdStage->SetSensitiveDetector(m_ThirdStageScorer); - - ///Visualisation of Third Stage - G4VisAttributes* ThirdStageVisAtt = new G4VisAttributes(G4Colour(0.0, 0.9, 0.0)); // green - logicThirdStage->SetVisAttributes(ThirdStageVisAtt); - } - - //////////////////////////////////////////////////////////////// - ///////////////// Fourth Stage Construction///////////////////// - //////////////////////////////////////////////////////////////// - if (wFourthStage) { - // Fourth stage silicon detector - G4ThreeVector positionFourthStage = G4ThreeVector(0, 0, FourthStage_PosZ); - - G4Box* solidFourthStage = new G4Box("solidFourthStage", 0.5*FourthStageFace, 0.5*FourthStageFace, 0.5*FourthStageThickness); - G4LogicalVolume* logicFourthStage = new G4LogicalVolume(solidFourthStage, m_MaterialSilicon, "logicFourthStage", 0, 0, 0); - - new G4PVPlacement(0, - positionFourthStage, - logicFourthStage, - Name + "_FourthStage", - logicHYD2Square1, - false, - 0); - - // Set Fourth Stage sensible - logicFourthStage->SetSensitiveDetector(m_FourthStageScorer); - - ///Visualisation of Fourth Stage - G4VisAttributes* FourthStageVisAtt = new G4VisAttributes(G4Colour(0.0, 0.9, 0.0)); // green - logicFourthStage->SetVisAttributes(FourthStageVisAtt); - } - - //////////////////////////////////////////////////////////////// - ///////////////// Fifth Stage Construction///////////////////// - //////////////////////////////////////////////////////////////// - if (wFifthStage) { - // Fifth stage silicon detector - G4ThreeVector positionFifthStage = G4ThreeVector(0, 0, FifthStage_PosZ); - - G4Box* solidFifthStage = new G4Box("solidFifthStage", 0.5*FifthStageFace, 0.5*FifthStageFace, 0.5*FifthStageThickness); - G4LogicalVolume* logicFifthStage = new G4LogicalVolume(solidFifthStage, m_MaterialSilicon, "logicFifthStage", 0, 0, 0); - - new G4PVPlacement(0, - positionFifthStage, - logicFifthStage, - Name + "_FifthStage", - logicHYD2Square1, - false, - 0); - - // Set Fifth Stage sensible - logicFifthStage->SetSensitiveDetector(m_FifthStageScorer); - - ///Visualisation of Fifth Stage - G4VisAttributes* FifthStageVisAtt = new G4VisAttributes(G4Colour(0.0, 0.9, 0.0)); // green - logicFifthStage->SetVisAttributes(FifthStageVisAtt); - } - - //////////////////////////////////////////////////////////////// - ///////////////// Sixth Stage Construction///////////////////// - //////////////////////////////////////////////////////////////// - if (wSixthStage) { - // Sixth stage silicon detector - G4ThreeVector positionSixthStage = G4ThreeVector(0, 0, SixthStage_PosZ); - - G4Box* solidSixthStage = new G4Box("solidSixthStage", 0.5*SixthStageFace, 0.5*SixthStageFace, 0.5*SixthStageThickness); - G4LogicalVolume* logicSixthStage = new G4LogicalVolume(solidSixthStage, m_MaterialSilicon, "logicSixthStage", 0, 0, 0); - - new G4PVPlacement(0, - positionSixthStage, - logicSixthStage, - Name + "_SixthStage", - logicHYD2Square1, - false, - 0); - - // Set Sixth Stage sensible - logicSixthStage->SetSensitiveDetector(m_SixthStageScorer); - - ///Visualisation of Sixth Stage - G4VisAttributes* SixthStageVisAtt = new G4VisAttributes(G4Colour(0.0, 0.9, 0.0)); // green - logicSixthStage->SetVisAttributes(SixthStageVisAtt); - } - + //////////////////////////////////////////////////////////////// + //////////////// First Stage Construction ////////////////////// + //////////////////////////////////////////////////////////////// + if (wFirstStage) { + // Silicon detector itself + G4ThreeVector positionFirstStage = G4ThreeVector(0, 0, FirstStage_PosZ); + + G4Box* solidFirstStage = + new G4Box("solidFirstStage", 0.5 * FirstStageFace, 0.5 * FirstStageFace, 0.5 * FirstStageThickness); + G4LogicalVolume* logicFirstStage = + new G4LogicalVolume(solidFirstStage, m_MaterialSilicon, "logicFirstStage", 0, 0, 0); + + new G4PVPlacement(0, positionFirstStage, logicFirstStage, Name + "_FirstStage", logicHYD2Square1, false, 0); + + // Set First Stage sensible + logicFirstStage->SetSensitiveDetector(m_FirstStageScorer); + + /// Visualisation of FirstStage Strip + G4VisAttributes* FirstStageVisAtt = new G4VisAttributes(G4Colour(0.0, 0.0, 0.9)); // blue + logicFirstStage->SetVisAttributes(FirstStageVisAtt); + } + + //////////////////////////////////////////////////////////////// + //////////////////// Second Stage Construction //////////////// + //////////////////////////////////////////////////////////////// + if (wSecondStage) { + // Second stage silicon detector + G4ThreeVector positionSecondStage = G4ThreeVector(0, 0, SecondStage_PosZ); + + G4Box* solidSecondStage = + new G4Box("solidSecondStage", 0.5 * SecondStageFace, 0.5 * SecondStageFace, 0.5 * SecondStageThickness); + G4LogicalVolume* logicSecondStage = + new G4LogicalVolume(solidSecondStage, m_MaterialSilicon, "logicSecondStage", 0, 0, 0); + + new G4PVPlacement(0, positionSecondStage, logicSecondStage, Name + "_SecondStage", logicHYD2Square1, false, 0); + + // Set Second Stage sensible + logicSecondStage->SetSensitiveDetector(m_SecondStageScorer); + + /// Visualisation of SecondStage Strip + G4VisAttributes* SecondStageVisAtt = new G4VisAttributes(G4Colour(0.5, 0.5, 0.5)); + logicSecondStage->SetVisAttributes(SecondStageVisAtt); + } + + //////////////////////////////////////////////////////////////// + ///////////////// Third Stage Construction ///////////////////// + //////////////////////////////////////////////////////////////// + if (wThirdStage) { + // Third stage silicon detector + G4ThreeVector positionThirdStage = G4ThreeVector(0, 0, ThirdStage_PosZ); + + G4Box* solidThirdStage = + new G4Box("solidThirdStage", 0.5 * ThirdStageFace, 0.5 * ThirdStageFace, 0.5 * ThirdStageThickness); + G4LogicalVolume* logicThirdStage = + new G4LogicalVolume(solidThirdStage, m_MaterialSilicon, "logicThirdStage", 0, 0, 0); + + new G4PVPlacement(0, positionThirdStage, logicThirdStage, Name + "_ThirdStage", logicHYD2Square1, false, 0); + + // Set Third Stage sensible + logicThirdStage->SetSensitiveDetector(m_ThirdStageScorer); + + /// Visualisation of Third Stage + G4VisAttributes* ThirdStageVisAtt = new G4VisAttributes(G4Colour(0.0, 0.9, 0.0)); // green + logicThirdStage->SetVisAttributes(ThirdStageVisAtt); + } + + //////////////////////////////////////////////////////////////// + ///////////////// Fourth Stage Construction///////////////////// + //////////////////////////////////////////////////////////////// + if (wFourthStage) { + // Fourth stage silicon detector + G4ThreeVector positionFourthStage = G4ThreeVector(0, 0, FourthStage_PosZ); + + G4Box* solidFourthStage = + new G4Box("solidFourthStage", 0.5 * FourthStageFace, 0.5 * FourthStageFace, 0.5 * FourthStageThickness); + G4LogicalVolume* logicFourthStage = + new G4LogicalVolume(solidFourthStage, m_MaterialSilicon, "logicFourthStage", 0, 0, 0); + + new G4PVPlacement(0, positionFourthStage, logicFourthStage, Name + "_FourthStage", logicHYD2Square1, false, 0); + + // Set Fourth Stage sensible + logicFourthStage->SetSensitiveDetector(m_FourthStageScorer); + + /// Visualisation of Fourth Stage + G4VisAttributes* FourthStageVisAtt = new G4VisAttributes(G4Colour(0.0, 0.9, 0.0)); // green + logicFourthStage->SetVisAttributes(FourthStageVisAtt); + } + + //////////////////////////////////////////////////////////////// + ///////////////// Fifth Stage Construction///////////////////// + //////////////////////////////////////////////////////////////// + if (wFifthStage) { + // Fifth stage silicon detector + G4ThreeVector positionFifthStage = G4ThreeVector(0, 0, FifthStage_PosZ); + + G4Box* solidFifthStage = + new G4Box("solidFifthStage", 0.5 * FifthStageFace, 0.5 * FifthStageFace, 0.5 * FifthStageThickness); + G4LogicalVolume* logicFifthStage = + new G4LogicalVolume(solidFifthStage, m_MaterialSilicon, "logicFifthStage", 0, 0, 0); + + new G4PVPlacement(0, positionFifthStage, logicFifthStage, Name + "_FifthStage", logicHYD2Square1, false, 0); + + // Set Fifth Stage sensible + logicFifthStage->SetSensitiveDetector(m_FifthStageScorer); + + /// Visualisation of Fifth Stage + G4VisAttributes* FifthStageVisAtt = new G4VisAttributes(G4Colour(0.0, 0.9, 0.0)); // green + logicFifthStage->SetVisAttributes(FifthStageVisAtt); + } + + //////////////////////////////////////////////////////////////// + ///////////////// Sixth Stage Construction///////////////////// + //////////////////////////////////////////////////////////////// + if (wSixthStage) { + // Sixth stage silicon detector + G4ThreeVector positionSixthStage = G4ThreeVector(0, 0, SixthStage_PosZ); + + G4Box* solidSixthStage = + new G4Box("solidSixthStage", 0.5 * SixthStageFace, 0.5 * SixthStageFace, 0.5 * SixthStageThickness); + G4LogicalVolume* logicSixthStage = + new G4LogicalVolume(solidSixthStage, m_MaterialSilicon, "logicSixthStage", 0, 0, 0); + + new G4PVPlacement(0, positionSixthStage, logicSixthStage, Name + "_SixthStage", logicHYD2Square1, false, 0); + + // Set Sixth Stage sensible + logicSixthStage->SetSensitiveDetector(m_SixthStageScorer); + + /// Visualisation of Sixth Stage + G4VisAttributes* SixthStageVisAtt = new G4VisAttributes(G4Colour(0.0, 0.9, 0.0)); // green + logicSixthStage->SetVisAttributes(SixthStageVisAtt); + } } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... @@ -372,819 +307,803 @@ void Hyde2TrackerSquare1::VolumeMaker(G4int TelescopeNumber, // Read stream at Configfile to pick-up parameters of detector (Position,...) // Called in DetecorConstruction::ReadDetextorConfiguration Method -void Hyde2TrackerSquare1::ReadConfiguration(string Path) -{ - ifstream ConfigFile ; - ConfigFile.open(Path.c_str()) ; - string LineBuffer ; - string DataBuffer ; - - // A:X1_Y1 --> X:1 Y:1 - // B:X128_Y1 --> X:128 Y:1 - // C:X1_Y128 --> X:1 Y:128 - // D:X128_Y128 --> X:128 Y:128 - - G4double Ax , Bx , Cx , Dx , Ay , By , Cy , Dy , Az , Bz , Cz , Dz ; - G4ThreeVector A , B , C , D ; - G4double Theta = 0 , Phi = 0 , R = 0 , beta_u = 0 , beta_v = 0 , beta_w = 0 ; - int FIRSTSTAGE = 0 , SECONDSTAGE = 0 , THIRDSTAGE = 0 , FOURTHSTAGE = 0 , FIFTHSTAGE = 0, SIXTHSTAGE = 0 ; - - bool ReadingStatus = false ; - - bool check_A = false ; - bool check_C = false ; - bool check_B = false ; - bool check_D = false ; - - bool check_Theta = false ; - bool check_Phi = false ; - bool check_R = false ; -// bool check_beta = false ; - - bool check_FirstStage = false ; - bool check_SecondStage = false ; - bool check_ThirdStage = false ; - bool check_FourthStage = false ; - bool check_FifthStage = false ; - bool check_SixthStage = false ; - bool checkVis = false ; - - while (!ConfigFile.eof()) { - getline(ConfigFile, LineBuffer); - if (LineBuffer.compare(0, 11, "HYD2Square1") == 0) { - G4cout << "///" << G4endl ; - G4cout << "Square1 element found: " << G4endl ; - ReadingStatus = true ; - } - - while(ReadingStatus){ - - ConfigFile >> DataBuffer; - // Comment Line - if (DataBuffer.compare(0, 1, "%") == 0) {/*do nothing */;} - - // Position method - else if (DataBuffer.compare(0, 6, "X1_Y1=") == 0) { - check_A = true; - ConfigFile >> DataBuffer ; - Ax = atof(DataBuffer.c_str()) ; - Ax = Ax * mm ; - ConfigFile >> DataBuffer ; - Ay = atof(DataBuffer.c_str()) ; - Ay = Ay * mm ; - ConfigFile >> DataBuffer ; - Az = atof(DataBuffer.c_str()) ; - Az = Az * mm ; - - A = G4ThreeVector(Ax, Ay, Az); - G4cout << "X1 Y1 corner position : " << A << G4endl; - } - - else if (DataBuffer.compare(0, 8, "X128_Y1=") == 0) { - check_B = true; - ConfigFile >> DataBuffer ; - Bx = atof(DataBuffer.c_str()) ; - Bx = Bx * mm ; - ConfigFile >> DataBuffer ; - By = atof(DataBuffer.c_str()) ; - By = By * mm ; - ConfigFile >> DataBuffer ; - Bz = atof(DataBuffer.c_str()) ; - Bz = Bz * mm ; - - B = G4ThreeVector(Bx, By, Bz); - G4cout << "X128 Y1 corner position : " << B << G4endl; - } - - else if (DataBuffer.compare(0, 8, "X1_Y128=") == 0) { - check_C = true; - ConfigFile >> DataBuffer ; - Cx = atof(DataBuffer.c_str()) ; - Cx = Cx * mm ; - ConfigFile >> DataBuffer ; - Cy = atof(DataBuffer.c_str()) ; - Cy = Cy * mm ; - ConfigFile >> DataBuffer ; - Cz = atof(DataBuffer.c_str()) ; - Cz = Cz * mm ; - - C = G4ThreeVector(Cx, Cy, Cz); - G4cout << "X1 Y128 corner position : " << C << G4endl; - } - - else if (DataBuffer.compare(0, 10, "X128_Y128=") == 0) { - check_D = true; - ConfigFile >> DataBuffer ; - Dx = atof(DataBuffer.c_str()) ; - Dx = Dx * mm ; - ConfigFile >> DataBuffer ; - Dy = atof(DataBuffer.c_str()) ; - Dy = Dy * mm ; - ConfigFile >> DataBuffer ; - Dz = atof(DataBuffer.c_str()) ; - Dz = Dz * mm ; - - D = G4ThreeVector(Dx, Dy, Dz); - G4cout << "X128 Y128 corner position : " << D << G4endl; - } - - - // Angle method - else if (DataBuffer.compare(0, 6, "THETA=") == 0) { - check_Theta = true; - ConfigFile >> DataBuffer ; - Theta = atof(DataBuffer.c_str()) ; - Theta = Theta * deg; - G4cout << "Theta: " << Theta / deg << G4endl; - } - - else if (DataBuffer.compare(0, 4, "PHI=") == 0) { - check_Phi = true; - ConfigFile >> DataBuffer ; - Phi = atof(DataBuffer.c_str()) ; - Phi = Phi * deg; - G4cout << "Phi: " << Phi / deg << G4endl; - } - - else if (DataBuffer.compare(0, 2, "R=") == 0) { - check_R = true; - ConfigFile >> DataBuffer ; - R = atof(DataBuffer.c_str()) ; - R = R * mm; - G4cout << "R: " << R / mm << G4endl; - } - - else if (DataBuffer.compare(0, 5, "BETA=") == 0) { -// check_beta = true; - ConfigFile >> DataBuffer ; - beta_u = atof(DataBuffer.c_str()) ; - beta_u = beta_u * deg ; - ConfigFile >> DataBuffer ; - beta_v = atof(DataBuffer.c_str()) ; - beta_v = beta_v * deg ; - ConfigFile >> DataBuffer ; - beta_w = atof(DataBuffer.c_str()) ; - beta_w = beta_w * deg ; - G4cout << "Beta: " << beta_u / deg << " " << beta_v / deg << " " << beta_w / deg << G4endl ; - } - - else if (DataBuffer.compare(0, 11, "FIRSTSTAGE=") == 0) { - check_FirstStage = true ; - ConfigFile >> DataBuffer; - FIRSTSTAGE = atof(DataBuffer.c_str()) ; - } - - else if (DataBuffer.compare(0, 12, "SECONDSTAGE=") == 0) { - check_SecondStage = true ; - ConfigFile >> DataBuffer; - SECONDSTAGE = atof(DataBuffer.c_str()) ; - } - - else if (DataBuffer.compare(0, 11, "THIRDSTAGE=") == 0) { - check_ThirdStage = true ; - ConfigFile >> DataBuffer; - THIRDSTAGE = atof(DataBuffer.c_str()) ; - } - - else if (DataBuffer.compare(0, 12, "FOURTHSTAGE=") == 0) { - check_FourthStage = true ; - ConfigFile >> DataBuffer; - FOURTHSTAGE = atof(DataBuffer.c_str()) ; - } - - else if (DataBuffer.compare(0, 11, "FIFTHSTAGE=") == 0) { - check_FifthStage = true ; - ConfigFile >> DataBuffer; - FIFTHSTAGE = atof(DataBuffer.c_str()) ; - } - - else if (DataBuffer.compare(0, 11, "SIXTHSTAGE=") == 0) { - check_SixthStage = true ; - ConfigFile >> DataBuffer; - SIXTHSTAGE = atof(DataBuffer.c_str()) ; - } - - else if (DataBuffer.compare(0, 4, "VIS=") == 0) { - checkVis = true ; - ConfigFile >> DataBuffer; - if (DataBuffer.compare(0, 3, "all") == 0) m_non_sensitive_part_visiualisation = true; - } - - else G4cout << "WARNING: Wrong Token, Hyde2TrackerSquare1: Square1 Element not added" << G4endl; - - //Add The previously define telescope - //With position method - if ((check_A && check_B && check_C && check_D && check_FirstStage && check_SecondStage && check_ThirdStage && check_FourthStage && check_FifthStage && check_SixthStage && checkVis) && !(check_Theta && check_Phi && check_R)) { - - ReadingStatus = false ; - check_A = false ; - check_C = false ; - check_B = false ; - check_D = false ; - check_FirstStage = false ; - check_SecondStage = false ; - check_ThirdStage = false ; - check_FourthStage = false ; - check_FifthStage = false ; - check_SixthStage = false ; - checkVis = false ; - - AddModule(A , - B , - C , - D , - FIRSTSTAGE == 1 , - SECONDSTAGE == 1 , - THIRDSTAGE == 1 , - FOURTHSTAGE == 1 , - FIFTHSTAGE == 1 , - SIXTHSTAGE == 1); - } - - //with angle method - if ((check_Theta && check_Phi && check_R && check_FirstStage && check_SecondStage && check_ThirdStage && check_FourthStage && check_FifthStage && check_SixthStage && checkVis) && !(check_A && check_B && check_C && check_D)) { - ReadingStatus = false ; - check_Theta = false ; - check_Phi = false ; - check_R = false ; -// check_beta = false ; - check_FirstStage = false ; - check_SecondStage = false ; - check_ThirdStage = false ; - check_FourthStage = false ; - check_FifthStage = false ; - check_SixthStage = false ; - checkVis = false ; - - AddModule(R , - Theta , - Phi , - beta_u , - beta_v , - beta_w , - FIRSTSTAGE == 1 , - SECONDSTAGE == 1 , - THIRDSTAGE == 1 , - FOURTHSTAGE == 1 , - FIFTHSTAGE == 1 , - SIXTHSTAGE == 1); - } - - +void Hyde2TrackerSquare1::ReadConfiguration(string Path) { + ifstream ConfigFile; + ConfigFile.open(Path.c_str()); + string LineBuffer; + string DataBuffer; + + // A:X1_Y1 --> X:1 Y:1 + // B:X128_Y1 --> X:128 Y:1 + // C:X1_Y128 --> X:1 Y:128 + // D:X128_Y128 --> X:128 Y:128 + + G4double Ax, Bx, Cx, Dx, Ay, By, Cy, Dy, Az, Bz, Cz, Dz; + G4ThreeVector A, B, C, D; + G4double Theta = 0, Phi = 0, R = 0, beta_u = 0, beta_v = 0, beta_w = 0; + int FIRSTSTAGE = 0, SECONDSTAGE = 0, THIRDSTAGE = 0, FOURTHSTAGE = 0, FIFTHSTAGE = 0, SIXTHSTAGE = 0; + + bool ReadingStatus = false; + + bool check_A = false; + bool check_C = false; + bool check_B = false; + bool check_D = false; + + bool check_Theta = false; + bool check_Phi = false; + bool check_R = false; + // bool check_beta = false ; + + bool check_FirstStage = false; + bool check_SecondStage = false; + bool check_ThirdStage = false; + bool check_FourthStage = false; + bool check_FifthStage = false; + bool check_SixthStage = false; + bool checkVis = false; + + while (!ConfigFile.eof()) { + getline(ConfigFile, LineBuffer); + if (LineBuffer.compare(0, 11, "HYD2Square1") == 0) { + G4cout << "///" << G4endl; + G4cout << "Square1 element found: " << G4endl; + ReadingStatus = true; + } + + while (ReadingStatus) { + + ConfigFile >> DataBuffer; + // Comment Line + if (DataBuffer.compare(0, 1, "%") == 0) { /*do nothing */ + ; } - } -} -// Construct detector and inialise sensitive part. -// Called After DetecorConstruction::AddDetector Method -void Hyde2TrackerSquare1::ConstructDetector(G4LogicalVolume* world) -{ - G4RotationMatrix* MMrot = NULL ; - G4ThreeVector MMpos = G4ThreeVector(0, 0, 0) ; - G4ThreeVector MMu = G4ThreeVector(0, 0, 0) ; - G4ThreeVector MMv = G4ThreeVector(0, 0, 0) ; - G4ThreeVector MMw = G4ThreeVector(0, 0, 0) ; - G4ThreeVector MMCenter = G4ThreeVector(0, 0, 0) ; - bool FirstStage = true; - bool SecondStage = true; - bool ThirdStage = true; - bool FourthStage = true; - bool FifthStage = true; - bool SixthStage = true; - - G4int NumberOfTelescope = m_DefinitionType.size() ; - - for (G4int i = 0; i < NumberOfTelescope; i++) { - // By Point - if (m_DefinitionType[i]) { - // (u,v,w) unitary vector associated to telescope referencial - // (u,v) // to silicon plan - // w perpendicular to (u,v) plan and pointing ThirdStage - MMu = m_X128_Y1[i] - m_X1_Y1[i]; - MMu = MMu.unit(); - - MMv = m_X1_Y128[i] - m_X1_Y1[i]; - MMv = MMv.unit(); - - MMw = MMu.cross(MMv); - MMw = MMw.unit(); - - MMCenter = (m_X1_Y1[i] + m_X1_Y128[i] + m_X128_Y1[i] + m_X128_Y128[i]) / 4; - - // Passage Matrix from Lab Referential to Telescope Referential - MMrot = new G4RotationMatrix(MMu, MMv, MMw); - // translation to place Telescope - MMpos = MMw * Length * 0.5 + MMCenter; + // Position method + else if (DataBuffer.compare(0, 6, "X1_Y1=") == 0) { + check_A = true; + ConfigFile >> DataBuffer; + Ax = atof(DataBuffer.c_str()); + Ax = Ax * mm; + ConfigFile >> DataBuffer; + Ay = atof(DataBuffer.c_str()); + Ay = Ay * mm; + ConfigFile >> DataBuffer; + Az = atof(DataBuffer.c_str()); + Az = Az * mm; + + A = G4ThreeVector(Ax, Ay, Az); + G4cout << "X1 Y1 corner position : " << A << G4endl; } - // By Angle - else { - G4double Theta = m_Theta[i] ; - G4double Phi = m_Phi[i] ; - - // (u,v,w) unitary vector associated to telescope referencial - // (u,v) // to silicon plan - // w perpendicular to (u,v) plan and pointing ThirdStage - // Phi is angle between X axis and projection in (X,Y) plan - // Theta is angle between position vector and z axis - G4double wX = m_R[i] * sin(Theta / rad) * cos(Phi / rad); - G4double wY = m_R[i] * sin(Theta / rad) * sin(Phi / rad); - G4double wZ = m_R[i] * cos(Theta / rad); - MMw = G4ThreeVector(wX, wY, wZ); - - // vector corresponding to the center of the module - MMCenter = MMw; - - // vector parallel to one axis of silicon plane - G4double ii = cos(Theta / rad) * cos(Phi / rad); - G4double jj = cos(Theta / rad) * sin(Phi / rad); - G4double kk = -sin(Theta / rad); - G4ThreeVector Y = G4ThreeVector(ii, jj, kk); - - MMw = MMw.unit(); - MMu = MMw.cross(Y); - MMv = MMw.cross(MMu); - MMv = MMv.unit(); - MMu = MMu.unit(); - - // Passage Matrix from Lab Referential to Telescope Referential - // MUST2 - MMrot = new G4RotationMatrix(MMu, MMv, MMw); - // Telescope is rotate of Beta angle around MMv axis. - MMrot->rotate(m_beta_u[i], MMu); - MMrot->rotate(m_beta_v[i], MMv); - MMrot->rotate(m_beta_w[i], MMw); - // translation to place Telescope - MMpos = MMw * Length * 0.5 + MMCenter; + else if (DataBuffer.compare(0, 8, "X128_Y1=") == 0) { + check_B = true; + ConfigFile >> DataBuffer; + Bx = atof(DataBuffer.c_str()); + Bx = Bx * mm; + ConfigFile >> DataBuffer; + By = atof(DataBuffer.c_str()); + By = By * mm; + ConfigFile >> DataBuffer; + Bz = atof(DataBuffer.c_str()); + Bz = Bz * mm; + + B = G4ThreeVector(Bx, By, Bz); + G4cout << "X128 Y1 corner position : " << B << G4endl; } - FirstStage = m_wFirstStage[i] ; - SecondStage = m_wSecondStage[i] ; - ThirdStage = m_wThirdStage[i] ; - FourthStage = m_wFourthStage[i] ; - FifthStage = m_wFifthStage[i] ; - SixthStage = m_wSixthStage[i] ; + else if (DataBuffer.compare(0, 8, "X1_Y128=") == 0) { + check_C = true; + ConfigFile >> DataBuffer; + Cx = atof(DataBuffer.c_str()); + Cx = Cx * mm; + ConfigFile >> DataBuffer; + Cy = atof(DataBuffer.c_str()); + Cy = Cy * mm; + ConfigFile >> DataBuffer; + Cz = atof(DataBuffer.c_str()); + Cz = Cz * mm; + + C = G4ThreeVector(Cx, Cy, Cz); + G4cout << "X1 Y128 corner position : " << C << G4endl; + } - VolumeMaker(i + 1, MMpos, MMrot, FirstStage, SecondStage, ThirdStage , FourthStage, FifthStage, SixthStage, world); - } + else if (DataBuffer.compare(0, 10, "X128_Y128=") == 0) { + check_D = true; + ConfigFile >> DataBuffer; + Dx = atof(DataBuffer.c_str()); + Dx = Dx * mm; + ConfigFile >> DataBuffer; + Dy = atof(DataBuffer.c_str()); + Dy = Dy * mm; + ConfigFile >> DataBuffer; + Dz = atof(DataBuffer.c_str()); + Dz = Dz * mm; + + D = G4ThreeVector(Dx, Dy, Dz); + G4cout << "X128 Y128 corner position : " << D << G4endl; + } - delete MMrot ; -} + // Angle method + else if (DataBuffer.compare(0, 6, "THETA=") == 0) { + check_Theta = true; + ConfigFile >> DataBuffer; + Theta = atof(DataBuffer.c_str()); + Theta = Theta * deg; + G4cout << "Theta: " << Theta / deg << G4endl; + } + else if (DataBuffer.compare(0, 4, "PHI=") == 0) { + check_Phi = true; + ConfigFile >> DataBuffer; + Phi = atof(DataBuffer.c_str()); + Phi = Phi * deg; + G4cout << "Phi: " << Phi / deg << G4endl; + } + else if (DataBuffer.compare(0, 2, "R=") == 0) { + check_R = true; + ConfigFile >> DataBuffer; + R = atof(DataBuffer.c_str()); + R = R * mm; + G4cout << "R: " << R / mm << G4endl; + } -// Connect the Hyde2TrackingData class to the output TTree -// of the simulation -void Hyde2TrackerSquare1::InitializeRootOutput() -{ -} + else if (DataBuffer.compare(0, 5, "BETA=") == 0) { + // check_beta = true; + ConfigFile >> DataBuffer; + beta_u = atof(DataBuffer.c_str()); + beta_u = beta_u * deg; + ConfigFile >> DataBuffer; + beta_v = atof(DataBuffer.c_str()); + beta_v = beta_v * deg; + ConfigFile >> DataBuffer; + beta_w = atof(DataBuffer.c_str()); + beta_w = beta_w * deg; + G4cout << "Beta: " << beta_u / deg << " " << beta_v / deg << " " << beta_w / deg << G4endl; + } + else if (DataBuffer.compare(0, 11, "FIRSTSTAGE=") == 0) { + check_FirstStage = true; + ConfigFile >> DataBuffer; + FIRSTSTAGE = atof(DataBuffer.c_str()); + } + else if (DataBuffer.compare(0, 12, "SECONDSTAGE=") == 0) { + check_SecondStage = true; + ConfigFile >> DataBuffer; + SECONDSTAGE = atof(DataBuffer.c_str()); + } -// Set the TinteractionCoordinates object from NPS::VDetector to the present class -void Hyde2TrackerSquare1::SetInterCoordPointer(TInteractionCoordinates* interCoord) -{ - ms_InterCoord = interCoord; + else if (DataBuffer.compare(0, 11, "THIRDSTAGE=") == 0) { + check_ThirdStage = true; + ConfigFile >> DataBuffer; + THIRDSTAGE = atof(DataBuffer.c_str()); + } + + else if (DataBuffer.compare(0, 12, "FOURTHSTAGE=") == 0) { + check_FourthStage = true; + ConfigFile >> DataBuffer; + FOURTHSTAGE = atof(DataBuffer.c_str()); + } + + else if (DataBuffer.compare(0, 11, "FIFTHSTAGE=") == 0) { + check_FifthStage = true; + ConfigFile >> DataBuffer; + FIFTHSTAGE = atof(DataBuffer.c_str()); + } + + else if (DataBuffer.compare(0, 11, "SIXTHSTAGE=") == 0) { + check_SixthStage = true; + ConfigFile >> DataBuffer; + SIXTHSTAGE = atof(DataBuffer.c_str()); + } + + else if (DataBuffer.compare(0, 4, "VIS=") == 0) { + checkVis = true; + ConfigFile >> DataBuffer; + if (DataBuffer.compare(0, 3, "all") == 0) + m_non_sensitive_part_visiualisation = true; + } + + else + G4cout << "WARNING: Wrong Token, Hyde2TrackerSquare1: Square1 Element not added" << G4endl; + + // Add The previously define telescope + // With position method + if ((check_A && check_B && check_C && check_D && check_FirstStage && check_SecondStage && check_ThirdStage && + check_FourthStage && check_FifthStage && check_SixthStage && checkVis) && + !(check_Theta && check_Phi && check_R)) { + + ReadingStatus = false; + check_A = false; + check_C = false; + check_B = false; + check_D = false; + check_FirstStage = false; + check_SecondStage = false; + check_ThirdStage = false; + check_FourthStage = false; + check_FifthStage = false; + check_SixthStage = false; + checkVis = false; + + AddModule(A, B, C, D, FIRSTSTAGE == 1, SECONDSTAGE == 1, THIRDSTAGE == 1, FOURTHSTAGE == 1, FIFTHSTAGE == 1, + SIXTHSTAGE == 1); + } + + // with angle method + if ((check_Theta && check_Phi && check_R && check_FirstStage && check_SecondStage && check_ThirdStage && + check_FourthStage && check_FifthStage && check_SixthStage && checkVis) && + !(check_A && check_B && check_C && check_D)) { + ReadingStatus = false; + check_Theta = false; + check_Phi = false; + check_R = false; + // check_beta = false ; + check_FirstStage = false; + check_SecondStage = false; + check_ThirdStage = false; + check_FourthStage = false; + check_FifthStage = false; + check_SixthStage = false; + checkVis = false; + + AddModule(R, Theta, Phi, beta_u, beta_v, beta_w, FIRSTSTAGE == 1, SECONDSTAGE == 1, THIRDSTAGE == 1, + FOURTHSTAGE == 1, FIFTHSTAGE == 1, SIXTHSTAGE == 1); + } + } + } +} + +// Construct detector and inialise sensitive part. +// Called After DetecorConstruction::AddDetector Method +void Hyde2TrackerSquare1::ConstructDetector(G4LogicalVolume* world) { + G4RotationMatrix* MMrot = NULL; + G4ThreeVector MMpos = G4ThreeVector(0, 0, 0); + G4ThreeVector MMu = G4ThreeVector(0, 0, 0); + G4ThreeVector MMv = G4ThreeVector(0, 0, 0); + G4ThreeVector MMw = G4ThreeVector(0, 0, 0); + G4ThreeVector MMCenter = G4ThreeVector(0, 0, 0); + bool FirstStage = true; + bool SecondStage = true; + bool ThirdStage = true; + bool FourthStage = true; + bool FifthStage = true; + bool SixthStage = true; + + G4int NumberOfTelescope = m_DefinitionType.size(); + + for (G4int i = 0; i < NumberOfTelescope; i++) { + // By Point + if (m_DefinitionType[i]) { + // (u,v,w) unitary vector associated to telescope referencial + // (u,v) // to silicon plan + // w perpendicular to (u,v) plan and pointing ThirdStage + MMu = m_X128_Y1[i] - m_X1_Y1[i]; + MMu = MMu.unit(); + + MMv = m_X1_Y128[i] - m_X1_Y1[i]; + MMv = MMv.unit(); + + MMw = MMu.cross(MMv); + MMw = MMw.unit(); + + MMCenter = (m_X1_Y1[i] + m_X1_Y128[i] + m_X128_Y1[i] + m_X128_Y128[i]) / 4; + + // Passage Matrix from Lab Referential to Telescope Referential + MMrot = new G4RotationMatrix(MMu, MMv, MMw); + // translation to place Telescope + MMpos = MMw * Length * 0.5 + MMCenter; + } + + // By Angle + else { + G4double Theta = m_Theta[i]; + G4double Phi = m_Phi[i]; + + // (u,v,w) unitary vector associated to telescope referencial + // (u,v) // to silicon plan + // w perpendicular to (u,v) plan and pointing ThirdStage + // Phi is angle between X axis and projection in (X,Y) plan + // Theta is angle between position vector and z axis + G4double wX = m_R[i] * sin(Theta / rad) * cos(Phi / rad); + G4double wY = m_R[i] * sin(Theta / rad) * sin(Phi / rad); + G4double wZ = m_R[i] * cos(Theta / rad); + MMw = G4ThreeVector(wX, wY, wZ); + + // vector corresponding to the center of the module + MMCenter = MMw; + + // vector parallel to one axis of silicon plane + G4double ii = cos(Theta / rad) * cos(Phi / rad); + G4double jj = cos(Theta / rad) * sin(Phi / rad); + G4double kk = -sin(Theta / rad); + G4ThreeVector Y = G4ThreeVector(ii, jj, kk); + + MMw = MMw.unit(); + MMu = MMw.cross(Y); + MMv = MMw.cross(MMu); + MMv = MMv.unit(); + MMu = MMu.unit(); + + // Passage Matrix from Lab Referential to Telescope Referential + // MUST2 + MMrot = new G4RotationMatrix(MMu, MMv, MMw); + // Telescope is rotate of Beta angle around MMv axis. + MMrot->rotate(m_beta_u[i], MMu); + MMrot->rotate(m_beta_v[i], MMv); + MMrot->rotate(m_beta_w[i], MMw); + // translation to place Telescope + MMpos = MMw * Length * 0.5 + MMCenter; + } + + FirstStage = m_wFirstStage[i]; + SecondStage = m_wSecondStage[i]; + ThirdStage = m_wThirdStage[i]; + FourthStage = m_wFourthStage[i]; + FifthStage = m_wFifthStage[i]; + SixthStage = m_wSixthStage[i]; + + VolumeMaker(i + 1, MMpos, MMrot, FirstStage, SecondStage, ThirdStage, FourthStage, FifthStage, SixthStage, world); + } + + delete MMrot; } +// Connect the Hyde2TrackingData class to the output TTree +// of the simulation +void Hyde2TrackerSquare1::InitializeRootOutput() {} +// Set the TinteractionCoordinates object from NPS::VDetector to the present class +void Hyde2TrackerSquare1::SetInterCoordPointer(TInteractionCoordinates* interCoord) { ms_InterCoord = interCoord; } // Read sensitive part and fill the Root tree. // Called at in the EventAction::EndOfEventAvtion -void Hyde2TrackerSquare1::ReadSensitive(const G4Event* event) -{ -////////////////////////////////////////////////////////////////////////////////////// -//////////////////////// Used to Read Event Map of detector ////////////////////////// -////////////////////////////////////////////////////////////////////////////////////// - // First Stage - std::map<G4int, G4int*>::iterator DetectorNumber_itr; - std::map<G4int, G4double*>::iterator Energy_itr; - std::map<G4int, G4double*>::iterator Time_itr; - std::map<G4int, G4double*>::iterator X_itr; - std::map<G4int, G4double*>::iterator Y_itr; - std::map<G4int, G4double*>::iterator Pos_X_itr; - std::map<G4int, G4double*>::iterator Pos_Y_itr; - std::map<G4int, G4double*>::iterator Pos_Z_itr; - std::map<G4int, G4double*>::iterator Ang_Theta_itr; - std::map<G4int, G4double*>::iterator Ang_Phi_itr; - - G4THitsMap<G4int>* DetectorNumberHitMap; - G4THitsMap<G4double>* EnergyHitMap; - G4THitsMap<G4double>* TimeHitMap; - G4THitsMap<G4double>* XHitMap; - G4THitsMap<G4double>* YHitMap; - G4THitsMap<G4double>* PosXHitMap; - G4THitsMap<G4double>* PosYHitMap; - G4THitsMap<G4double>* PosZHitMap; - G4THitsMap<G4double>* AngThetaHitMap; - G4THitsMap<G4double>* AngPhiHitMap; - - // NULL pointer are given to avoid warning at compilation - // Second Stage - std::map<G4int, G4double*>::iterator SecondStageEnergy_itr ; - G4THitsMap<G4double>* SecondStageEnergyHitMap = NULL ; - // Third Stage - std::map<G4int, G4double*>::iterator ThirdStageEnergy_itr ; - G4THitsMap<G4double>* ThirdStageEnergyHitMap = NULL ; - // Fourth Stage - std::map<G4int, G4double*>::iterator FourthStageEnergy_itr ; - G4THitsMap<G4double>* FourthStageEnergyHitMap = NULL ; - // Fifth Stage - std::map<G4int, G4double*>::iterator FifthStageEnergy_itr ; - G4THitsMap<G4double>* FifthStageEnergyHitMap = NULL ; - // Sixth Stage - std::map<G4int, G4double*>::iterator SixthStageEnergy_itr ; - G4THitsMap<G4double>* SixthStageEnergyHitMap = NULL ; - - - - // Read the Scorer associate to the Silicon Strip - //Detector Number - G4int StripDetCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Square1/DetectorNumber") ; - DetectorNumberHitMap = (G4THitsMap<G4int>*)(event->GetHCofThisEvent()->GetHC(StripDetCollectionID)) ; - DetectorNumber_itr = DetectorNumberHitMap->GetMap()->begin() ; - - //Energy - G4int StripEnergyCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Square1/StripEnergy") ; - EnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripEnergyCollectionID)) ; - Energy_itr = EnergyHitMap->GetMap()->begin() ; - - //Time of Flight - G4int StripTimeCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Square1/StripTime") ; - TimeHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripTimeCollectionID)) ; - Time_itr = TimeHitMap->GetMap()->begin() ; - - //Strip Number X - G4int StripXCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Square1/StripNumberX") ; - XHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripXCollectionID)) ; - X_itr = XHitMap->GetMap()->begin() ; - - //Strip Number Y - G4int StripYCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Square1/StripNumberY") ; - YHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripYCollectionID)) ; - Y_itr = YHitMap->GetMap()->begin() ; - - //Interaction Coordinate X - G4int InterCoordXCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Square1/InterCoordX") ; - PosXHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordXCollectionID)) ; - Pos_X_itr = PosXHitMap->GetMap()->begin() ; - - //Interaction Coordinate Y - G4int InterCoordYCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Square1/InterCoordY") ; - PosYHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordYCollectionID)) ; - Pos_Y_itr = PosYHitMap->GetMap()->begin() ; - - //Interaction Coordinate Z - G4int InterCoordZCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Square1/InterCoordZ") ; - PosZHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordZCollectionID)) ; - Pos_Z_itr = PosXHitMap->GetMap()->begin() ; - - //Interaction Coordinate Angle Theta - G4int InterCoordAngThetaCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Square1/InterCoordAngTheta") ; - AngThetaHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordAngThetaCollectionID)) ; - Ang_Theta_itr = AngThetaHitMap->GetMap()->begin() ; - - //Interaction Coordinate Angle Phi - G4int InterCoordAngPhiCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Square1/InterCoordAngPhi") ; - AngPhiHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordAngPhiCollectionID)) ; - Ang_Phi_itr = AngPhiHitMap->GetMap()->begin() ; - - - // Read the Scorer associate to the SecondStage - //Energy - G4int SecondStageEnergyCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("SecondStageScorerHYD2Square1/SecondStageEnergy") ; - SecondStageEnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(SecondStageEnergyCollectionID)) ; - SecondStageEnergy_itr = SecondStageEnergyHitMap->GetMap()->begin() ; - - - // Read the Scorer associate to the ThirdStage - //Energy - G4int ThirdStageEnergyCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("ThirdStageScorerHYD2Square1/ThirdStageEnergy"); - ThirdStageEnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(ThirdStageEnergyCollectionID)); - ThirdStageEnergy_itr = ThirdStageEnergyHitMap->GetMap()->begin(); - - // Read the Scorer associate to the FourthStage - //Energy - G4int FourthStageEnergyCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FourthStageScorerHYD2Square1/FourthStageEnergy"); - FourthStageEnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(FourthStageEnergyCollectionID)); - FourthStageEnergy_itr = FourthStageEnergyHitMap->GetMap()->begin(); - - // Read the Scorer associate to the FifthStage - //Energy - G4int FifthStageEnergyCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FifthStageScorerHYD2Square1/FifthStageEnergy"); - FifthStageEnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(FifthStageEnergyCollectionID)); - FifthStageEnergy_itr = FifthStageEnergyHitMap->GetMap()->begin(); - - // Read the Scorer associate to the SixthStage - //Energy - G4int SixthStageEnergyCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("SixthStageScorerHYD2Square1/SixthStageEnergy"); - SixthStageEnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(SixthStageEnergyCollectionID)); - SixthStageEnergy_itr = SixthStageEnergyHitMap->GetMap()->begin(); - - // Check the size of different map - G4int sizeN = DetectorNumberHitMap->entries(); - G4int sizeE = EnergyHitMap->entries(); - G4int sizeT = TimeHitMap->entries(); - G4int sizeX = XHitMap->entries(); - G4int sizeY = YHitMap->entries(); - - if (sizeE != sizeT || sizeT != sizeX || sizeX != sizeY) { - G4cout << "No match size Si Event Map: sE:" - << sizeE << " sT:" << sizeT << " sX:" << sizeX << " sY:" << sizeY << G4endl ; - return; - } - - // Loop on FirstStage number - for (G4int l = 0; l < sizeN; l++) { - G4double N = *(DetectorNumber_itr->second); - G4int NTrackID = DetectorNumber_itr->first - N; - - if (N > 0) { - // Fill detector number - ms_Event->SetHYD2TrkFirstStageFrontEDetectorNbr(m_index["Square1"] + N); - ms_Event->SetHYD2TrkFirstStageFrontTDetectorNbr(m_index["Square1"] + N); - ms_Event->SetHYD2TrkFirstStageBackEDetectorNbr(m_index["Square1"] + N); - ms_Event->SetHYD2TrkFirstStageBackTDetectorNbr(m_index["Square1"] + N); - - // Energy - for (G4int ll = 0 ; ll < sizeE ; ll++) { - G4int ETrackID = Energy_itr->first - N; - G4double E = *(Energy_itr->second); - if (ETrackID == NTrackID) { - ms_Event->SetHYD2TrkFirstStageFrontEEnergy(RandGauss::shoot(E, ResoFirstStage)); - ms_Event->SetHYD2TrkFirstStageBackEEnergy(RandGauss::shoot(E, ResoFirstStage)); - } - 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) { - T = RandGauss::shoot(T, ResoTimePPAC) ; - ms_Event->SetHYD2TrkFirstStageFrontTTime(RandGauss::shoot(T, ResoTimeHyd2)) ; - ms_Event->SetHYD2TrkFirstStageBackTTime(RandGauss::shoot(T, ResoTimeHyd2)) ; - } - Time_itr++; - } - - // X - X_itr = XHitMap->GetMap()->begin(); - for (G4int h = 0 ; h < sizeX ; h++) { - G4int XTrackID = X_itr->first - N; - G4double X = *(X_itr->second); - if (XTrackID == NTrackID) { - ms_Event->SetHYD2TrkFirstStageFrontEStripNbr(X); - ms_Event->SetHYD2TrkFirstStageFrontTStripNbr(X); - } - - X_itr++; - } - - // Y - Y_itr = YHitMap->GetMap()->begin() ; - for (G4int h = 0 ; h < sizeY ; h++) { - G4int YTrackID = Y_itr->first - N; - G4double Y = *(Y_itr->second); - if (YTrackID == NTrackID) { - ms_Event->SetHYD2TrkFirstStageBackEStripNbr(Y); - ms_Event->SetHYD2TrkFirstStageBackTStripNbr(Y); - } - - Y_itr++; - } - - // Pos X - Pos_X_itr = PosXHitMap->GetMap()->begin(); - for (unsigned int h = 0; h < PosXHitMap->entries(); h++) { - G4int PosXTrackID = Pos_X_itr->first - N ; - G4double PosX = *(Pos_X_itr->second) ; - if (PosXTrackID == NTrackID) { - ms_InterCoord->SetDetectedPositionX(PosX) ; - } - Pos_X_itr++; - } - - // Pos Y - Pos_Y_itr = PosYHitMap->GetMap()->begin(); - for (unsigned int h = 0; h < PosYHitMap->entries(); h++) { - G4int PosYTrackID = Pos_Y_itr->first - N ; - G4double PosY = *(Pos_Y_itr->second) ; - if (PosYTrackID == NTrackID) { - ms_InterCoord->SetDetectedPositionY(PosY) ; - } - Pos_Y_itr++; - } - - // Pos Z - Pos_Z_itr = PosZHitMap->GetMap()->begin(); - for (unsigned int h = 0; h < PosZHitMap->entries(); h++) { - G4int PosZTrackID = Pos_Z_itr->first - N ; - G4double PosZ = *(Pos_Z_itr->second) ; - if (PosZTrackID == NTrackID) { - ms_InterCoord->SetDetectedPositionZ(PosZ) ; - } - Pos_Z_itr++; - } - - // Angle Theta - Ang_Theta_itr = AngThetaHitMap->GetMap()->begin(); - for (unsigned int h = 0; h < AngThetaHitMap->entries(); h++) { - G4int AngThetaTrackID = Ang_Theta_itr->first - N ; - G4double AngTheta = *(Ang_Theta_itr->second) ; - if (AngThetaTrackID == NTrackID) { - ms_InterCoord->SetDetectedAngleTheta(AngTheta) ; - } - Ang_Theta_itr++; - } - - // Angle Phi - Ang_Phi_itr = AngPhiHitMap->GetMap()->begin(); - for (unsigned int h = 0; h < AngPhiHitMap->entries(); h++) { - G4int AngPhiTrackID = Ang_Phi_itr->first - N ; - G4double AngPhi = *(Ang_Phi_itr->second) ; - if (AngPhiTrackID == NTrackID) { - ms_InterCoord->SetDetectedAnglePhi(AngPhi) ; - } - Ang_Phi_itr++; - } - - // Second Stage - SecondStageEnergy_itr = SecondStageEnergyHitMap->GetMap()->begin() ; - for (unsigned int h = 0 ; h < SecondStageEnergyHitMap->entries() ; h++) { - G4int SecondStageEnergyTrackID = SecondStageEnergy_itr->first - N; - G4double SecondStageEnergy = *(SecondStageEnergy_itr->second); - - if (SecondStageEnergyTrackID == NTrackID) { - ms_Event->SetHYD2TrkSecondStageEEnergy(RandGauss::shoot(SecondStageEnergy, ResoSecondStage)) ; - ms_Event->SetHYD2TrkSecondStageEPadNbr(1); - ms_Event->SetHYD2TrkSecondStageTPadNbr(1); - ms_Event->SetHYD2TrkSecondStageTTime(1); - ms_Event->SetHYD2TrkSecondStageTDetectorNbr(m_index["Square1"] + N); - ms_Event->SetHYD2TrkSecondStageEDetectorNbr(m_index["Square1"] + N); - } - - SecondStageEnergy_itr++; - } - - // Third Stage - ThirdStageEnergy_itr = ThirdStageEnergyHitMap->GetMap()->begin() ; - for (unsigned int h = 0 ; h < ThirdStageEnergyHitMap->entries() ; h++) { - G4int ThirdStageEnergyTrackID = ThirdStageEnergy_itr->first - N; - G4double ThirdStageEnergy = *(ThirdStageEnergy_itr->second) ; - - if (ThirdStageEnergyTrackID == NTrackID) { - ms_Event->SetHYD2TrkThirdStageEEnergy(RandGauss::shoot(ThirdStageEnergy, ResoThirdStage)); - ms_Event->SetHYD2TrkThirdStageEPadNbr(1); - ms_Event->SetHYD2TrkThirdStageTPadNbr(1); - ms_Event->SetHYD2TrkThirdStageTTime(1); - ms_Event->SetHYD2TrkThirdStageTDetectorNbr(m_index["Square1"] + N); - ms_Event->SetHYD2TrkThirdStageEDetectorNbr(m_index["Square1"] + N); - } - - ThirdStageEnergy_itr++; - } - - // Fourth Stage - FourthStageEnergy_itr = FourthStageEnergyHitMap->GetMap()->begin() ; - for (unsigned int h = 0 ; h < FourthStageEnergyHitMap->entries() ; h++) { - G4int FourthStageEnergyTrackID = FourthStageEnergy_itr->first - N; - G4double FourthStageEnergy = *(FourthStageEnergy_itr->second) ; - - if (FourthStageEnergyTrackID == NTrackID) { - ms_Event->SetHYD2TrkFourthStageEEnergy(RandGauss::shoot(FourthStageEnergy, ResoFourthStage)); - ms_Event->SetHYD2TrkFourthStageEPadNbr(1); - ms_Event->SetHYD2TrkFourthStageTPadNbr(1); - ms_Event->SetHYD2TrkFourthStageTTime(1); - ms_Event->SetHYD2TrkFourthStageTDetectorNbr(m_index["Square1"] + N); - ms_Event->SetHYD2TrkFourthStageEDetectorNbr(m_index["Square1"] + N); - } - - FourthStageEnergy_itr++; - } - - // Fifth Stage - FifthStageEnergy_itr = FifthStageEnergyHitMap->GetMap()->begin() ; - for (unsigned int h = 0 ; h < FifthStageEnergyHitMap->entries() ; h++) { - G4int FifthStageEnergyTrackID = FifthStageEnergy_itr->first - N; - G4double FifthStageEnergy = *(FifthStageEnergy_itr->second) ; - - if (FifthStageEnergyTrackID == NTrackID) { - ms_Event->SetHYD2TrkFifthStageEEnergy(RandGauss::shoot(FifthStageEnergy, ResoFifthStage)); - ms_Event->SetHYD2TrkFifthStageEPadNbr(1); - ms_Event->SetHYD2TrkFifthStageTPadNbr(1); - ms_Event->SetHYD2TrkFifthStageTTime(1); - ms_Event->SetHYD2TrkFifthStageTDetectorNbr(m_index["Square1"] + N); - ms_Event->SetHYD2TrkFifthStageEDetectorNbr(m_index["Square1"] + N); - } - - FifthStageEnergy_itr++; - } - - // Sixth Stage - SixthStageEnergy_itr = SixthStageEnergyHitMap->GetMap()->begin() ; - for (unsigned int h = 0 ; h < SixthStageEnergyHitMap->entries() ; h++) { - G4int SixthStageEnergyTrackID = SixthStageEnergy_itr->first - N; - G4double SixthStageEnergy = *(SixthStageEnergy_itr->second) ; - - if (SixthStageEnergyTrackID == NTrackID) { - ms_Event->SetHYD2TrkSixthStageEEnergy(RandGauss::shoot(SixthStageEnergy, ResoSixthStage)); - ms_Event->SetHYD2TrkSixthStageEPadNbr(1); - ms_Event->SetHYD2TrkSixthStageTPadNbr(1); - ms_Event->SetHYD2TrkSixthStageTTime(1); - ms_Event->SetHYD2TrkSixthStageTDetectorNbr(m_index["Square1"] + N); - ms_Event->SetHYD2TrkSixthStageEDetectorNbr(m_index["Square1"] + N); - } - - SixthStageEnergy_itr++; - } - - DetectorNumber_itr++; +void Hyde2TrackerSquare1::ReadSensitive(const G4Event* event) { + ////////////////////////////////////////////////////////////////////////////////////// + //////////////////////// Used to Read Event Map of detector ////////////////////////// + ////////////////////////////////////////////////////////////////////////////////////// + // First Stage + std::map<G4int, G4int*>::iterator DetectorNumber_itr; + std::map<G4int, G4double*>::iterator Energy_itr; + std::map<G4int, G4double*>::iterator Time_itr; + std::map<G4int, G4double*>::iterator X_itr; + std::map<G4int, G4double*>::iterator Y_itr; + std::map<G4int, G4double*>::iterator Pos_X_itr; + std::map<G4int, G4double*>::iterator Pos_Y_itr; + std::map<G4int, G4double*>::iterator Pos_Z_itr; + std::map<G4int, G4double*>::iterator Ang_Theta_itr; + std::map<G4int, G4double*>::iterator Ang_Phi_itr; + + G4THitsMap<G4int>* DetectorNumberHitMap; + G4THitsMap<G4double>* EnergyHitMap; + G4THitsMap<G4double>* TimeHitMap; + G4THitsMap<G4double>* XHitMap; + G4THitsMap<G4double>* YHitMap; + G4THitsMap<G4double>* PosXHitMap; + G4THitsMap<G4double>* PosYHitMap; + G4THitsMap<G4double>* PosZHitMap; + G4THitsMap<G4double>* AngThetaHitMap; + G4THitsMap<G4double>* AngPhiHitMap; + + // NULL pointer are given to avoid warning at compilation + // Second Stage + std::map<G4int, G4double*>::iterator SecondStageEnergy_itr; + G4THitsMap<G4double>* SecondStageEnergyHitMap = NULL; + // Third Stage + std::map<G4int, G4double*>::iterator ThirdStageEnergy_itr; + G4THitsMap<G4double>* ThirdStageEnergyHitMap = NULL; + // Fourth Stage + std::map<G4int, G4double*>::iterator FourthStageEnergy_itr; + G4THitsMap<G4double>* FourthStageEnergyHitMap = NULL; + // Fifth Stage + std::map<G4int, G4double*>::iterator FifthStageEnergy_itr; + G4THitsMap<G4double>* FifthStageEnergyHitMap = NULL; + // Sixth Stage + std::map<G4int, G4double*>::iterator SixthStageEnergy_itr; + G4THitsMap<G4double>* SixthStageEnergyHitMap = NULL; + + // Read the Scorer associate to the Silicon Strip + // Detector Number + G4int StripDetCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Square1/DetectorNumber"); + DetectorNumberHitMap = (G4THitsMap<G4int>*)(event->GetHCofThisEvent()->GetHC(StripDetCollectionID)); + DetectorNumber_itr = DetectorNumberHitMap->GetMap()->begin(); + + // Energy + G4int StripEnergyCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Square1/StripEnergy"); + EnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripEnergyCollectionID)); + Energy_itr = EnergyHitMap->GetMap()->begin(); + + // Time of Flight + G4int StripTimeCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Square1/StripTime"); + TimeHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripTimeCollectionID)); + Time_itr = TimeHitMap->GetMap()->begin(); + + // Strip Number X + G4int StripXCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Square1/StripNumberX"); + XHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripXCollectionID)); + X_itr = XHitMap->GetMap()->begin(); + + // Strip Number Y + G4int StripYCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Square1/StripNumberY"); + YHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripYCollectionID)); + Y_itr = YHitMap->GetMap()->begin(); + + // Interaction Coordinate X + G4int InterCoordXCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Square1/InterCoordX"); + PosXHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordXCollectionID)); + Pos_X_itr = PosXHitMap->GetMap()->begin(); + + // Interaction Coordinate Y + G4int InterCoordYCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Square1/InterCoordY"); + PosYHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordYCollectionID)); + Pos_Y_itr = PosYHitMap->GetMap()->begin(); + + // Interaction Coordinate Z + G4int InterCoordZCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Square1/InterCoordZ"); + PosZHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordZCollectionID)); + Pos_Z_itr = PosXHitMap->GetMap()->begin(); + + // Interaction Coordinate Angle Theta + G4int InterCoordAngThetaCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Square1/InterCoordAngTheta"); + AngThetaHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordAngThetaCollectionID)); + Ang_Theta_itr = AngThetaHitMap->GetMap()->begin(); + + // Interaction Coordinate Angle Phi + G4int InterCoordAngPhiCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Square1/InterCoordAngPhi"); + AngPhiHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordAngPhiCollectionID)); + Ang_Phi_itr = AngPhiHitMap->GetMap()->begin(); + + // Read the Scorer associate to the SecondStage + // Energy + G4int SecondStageEnergyCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("SecondStageScorerHYD2Square1/SecondStageEnergy"); + SecondStageEnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(SecondStageEnergyCollectionID)); + SecondStageEnergy_itr = SecondStageEnergyHitMap->GetMap()->begin(); + + // Read the Scorer associate to the ThirdStage + // Energy + G4int ThirdStageEnergyCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("ThirdStageScorerHYD2Square1/ThirdStageEnergy"); + ThirdStageEnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(ThirdStageEnergyCollectionID)); + ThirdStageEnergy_itr = ThirdStageEnergyHitMap->GetMap()->begin(); + + // Read the Scorer associate to the FourthStage + // Energy + G4int FourthStageEnergyCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("FourthStageScorerHYD2Square1/FourthStageEnergy"); + FourthStageEnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(FourthStageEnergyCollectionID)); + FourthStageEnergy_itr = FourthStageEnergyHitMap->GetMap()->begin(); + + // Read the Scorer associate to the FifthStage + // Energy + G4int FifthStageEnergyCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("FifthStageScorerHYD2Square1/FifthStageEnergy"); + FifthStageEnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(FifthStageEnergyCollectionID)); + FifthStageEnergy_itr = FifthStageEnergyHitMap->GetMap()->begin(); + + // Read the Scorer associate to the SixthStage + // Energy + G4int SixthStageEnergyCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("SixthStageScorerHYD2Square1/SixthStageEnergy"); + SixthStageEnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(SixthStageEnergyCollectionID)); + SixthStageEnergy_itr = SixthStageEnergyHitMap->GetMap()->begin(); + + // Check the size of different map + G4int sizeN = DetectorNumberHitMap->entries(); + G4int sizeE = EnergyHitMap->entries(); + G4int sizeT = TimeHitMap->entries(); + G4int sizeX = XHitMap->entries(); + G4int sizeY = YHitMap->entries(); + + if (sizeE != sizeT || sizeT != sizeX || sizeX != sizeY) { + G4cout << "No match size Si Event Map: sE:" << sizeE << " sT:" << sizeT << " sX:" << sizeX << " sY:" << sizeY + << G4endl; + return; + } + + // Loop on FirstStage number + for (G4int l = 0; l < sizeN; l++) { + G4double N = *(DetectorNumber_itr->second); + G4int NTrackID = DetectorNumber_itr->first - N; + + if (N > 0) { + // Fill detector number + ms_Event->SetHYD2TrkFirstStageFrontEDetectorNbr(m_index["Square1"] + N); + ms_Event->SetHYD2TrkFirstStageFrontTDetectorNbr(m_index["Square1"] + N); + ms_Event->SetHYD2TrkFirstStageBackEDetectorNbr(m_index["Square1"] + N); + ms_Event->SetHYD2TrkFirstStageBackTDetectorNbr(m_index["Square1"] + N); + + // Energy + for (G4int ll = 0; ll < sizeE; ll++) { + G4int ETrackID = Energy_itr->first - N; + G4double E = *(Energy_itr->second); + if (ETrackID == NTrackID) { + ms_Event->SetHYD2TrkFirstStageFrontEEnergy(RandGauss::shoot(E, ResoFirstStage)); + ms_Event->SetHYD2TrkFirstStageBackEEnergy(RandGauss::shoot(E, ResoFirstStage)); + } + Energy_itr++; } - // clear map for next event - DetectorNumberHitMap ->clear(); - EnergyHitMap ->clear() ; - TimeHitMap ->clear() ; - XHitMap ->clear() ; - YHitMap ->clear() ; - PosXHitMap ->clear(); - PosYHitMap ->clear(); - PosZHitMap ->clear(); - AngThetaHitMap ->clear(); - AngPhiHitMap ->clear(); - SecondStageEnergyHitMap ->clear() ; - ThirdStageEnergyHitMap ->clear() ; - FourthStageEnergyHitMap ->clear() ; - FifthStageEnergyHitMap ->clear() ; - SixthStageEnergyHitMap ->clear() ; - } -} + // 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) { + T = RandGauss::shoot(T, ResoTimePPAC); + ms_Event->SetHYD2TrkFirstStageFrontTTime(RandGauss::shoot(T, ResoTimeHyd2)); + ms_Event->SetHYD2TrkFirstStageBackTTime(RandGauss::shoot(T, ResoTimeHyd2)); + } + Time_itr++; + } + // X + X_itr = XHitMap->GetMap()->begin(); + for (G4int h = 0; h < sizeX; h++) { + G4int XTrackID = X_itr->first - N; + G4double X = *(X_itr->second); + if (XTrackID == NTrackID) { + ms_Event->SetHYD2TrkFirstStageFrontEStripNbr(X); + ms_Event->SetHYD2TrkFirstStageFrontTStripNbr(X); + } + + X_itr++; + } + // Y + Y_itr = YHitMap->GetMap()->begin(); + for (G4int h = 0; h < sizeY; h++) { + G4int YTrackID = Y_itr->first - N; + G4double Y = *(Y_itr->second); + if (YTrackID == NTrackID) { + ms_Event->SetHYD2TrkFirstStageBackEStripNbr(Y); + ms_Event->SetHYD2TrkFirstStageBackTStripNbr(Y); + } + + Y_itr++; + } + + // Pos X + Pos_X_itr = PosXHitMap->GetMap()->begin(); + for (unsigned int h = 0; h < PosXHitMap->entries(); h++) { + G4int PosXTrackID = Pos_X_itr->first - N; + G4double PosX = *(Pos_X_itr->second); + if (PosXTrackID == NTrackID) { + ms_InterCoord->SetDetectedPositionX(PosX); + } + Pos_X_itr++; + } + + // Pos Y + Pos_Y_itr = PosYHitMap->GetMap()->begin(); + for (unsigned int h = 0; h < PosYHitMap->entries(); h++) { + G4int PosYTrackID = Pos_Y_itr->first - N; + G4double PosY = *(Pos_Y_itr->second); + if (PosYTrackID == NTrackID) { + ms_InterCoord->SetDetectedPositionY(PosY); + } + Pos_Y_itr++; + } + + // Pos Z + Pos_Z_itr = PosZHitMap->GetMap()->begin(); + for (unsigned int h = 0; h < PosZHitMap->entries(); h++) { + G4int PosZTrackID = Pos_Z_itr->first - N; + G4double PosZ = *(Pos_Z_itr->second); + if (PosZTrackID == NTrackID) { + ms_InterCoord->SetDetectedPositionZ(PosZ); + } + Pos_Z_itr++; + } + + // Angle Theta + Ang_Theta_itr = AngThetaHitMap->GetMap()->begin(); + for (unsigned int h = 0; h < AngThetaHitMap->entries(); h++) { + G4int AngThetaTrackID = Ang_Theta_itr->first - N; + G4double AngTheta = *(Ang_Theta_itr->second); + if (AngThetaTrackID == NTrackID) { + ms_InterCoord->SetDetectedAngleTheta(AngTheta); + } + Ang_Theta_itr++; + } + + // Angle Phi + Ang_Phi_itr = AngPhiHitMap->GetMap()->begin(); + for (unsigned int h = 0; h < AngPhiHitMap->entries(); h++) { + G4int AngPhiTrackID = Ang_Phi_itr->first - N; + G4double AngPhi = *(Ang_Phi_itr->second); + if (AngPhiTrackID == NTrackID) { + ms_InterCoord->SetDetectedAnglePhi(AngPhi); + } + Ang_Phi_itr++; + } + + // Second Stage + SecondStageEnergy_itr = SecondStageEnergyHitMap->GetMap()->begin(); + for (unsigned int h = 0; h < SecondStageEnergyHitMap->entries(); h++) { + G4int SecondStageEnergyTrackID = SecondStageEnergy_itr->first - N; + G4double SecondStageEnergy = *(SecondStageEnergy_itr->second); + + if (SecondStageEnergyTrackID == NTrackID) { + ms_Event->SetHYD2TrkSecondStageEEnergy(RandGauss::shoot(SecondStageEnergy, ResoSecondStage)); + ms_Event->SetHYD2TrkSecondStageEPadNbr(1); + ms_Event->SetHYD2TrkSecondStageTPadNbr(1); + ms_Event->SetHYD2TrkSecondStageTTime(1); + ms_Event->SetHYD2TrkSecondStageTDetectorNbr(m_index["Square1"] + N); + ms_Event->SetHYD2TrkSecondStageEDetectorNbr(m_index["Square1"] + N); + } + + SecondStageEnergy_itr++; + } + + // Third Stage + ThirdStageEnergy_itr = ThirdStageEnergyHitMap->GetMap()->begin(); + for (unsigned int h = 0; h < ThirdStageEnergyHitMap->entries(); h++) { + G4int ThirdStageEnergyTrackID = ThirdStageEnergy_itr->first - N; + G4double ThirdStageEnergy = *(ThirdStageEnergy_itr->second); + + if (ThirdStageEnergyTrackID == NTrackID) { + ms_Event->SetHYD2TrkThirdStageEEnergy(RandGauss::shoot(ThirdStageEnergy, ResoThirdStage)); + ms_Event->SetHYD2TrkThirdStageEPadNbr(1); + ms_Event->SetHYD2TrkThirdStageTPadNbr(1); + ms_Event->SetHYD2TrkThirdStageTTime(1); + ms_Event->SetHYD2TrkThirdStageTDetectorNbr(m_index["Square1"] + N); + ms_Event->SetHYD2TrkThirdStageEDetectorNbr(m_index["Square1"] + N); + } + + ThirdStageEnergy_itr++; + } + + // Fourth Stage + FourthStageEnergy_itr = FourthStageEnergyHitMap->GetMap()->begin(); + for (unsigned int h = 0; h < FourthStageEnergyHitMap->entries(); h++) { + G4int FourthStageEnergyTrackID = FourthStageEnergy_itr->first - N; + G4double FourthStageEnergy = *(FourthStageEnergy_itr->second); + + if (FourthStageEnergyTrackID == NTrackID) { + ms_Event->SetHYD2TrkFourthStageEEnergy(RandGauss::shoot(FourthStageEnergy, ResoFourthStage)); + ms_Event->SetHYD2TrkFourthStageEPadNbr(1); + ms_Event->SetHYD2TrkFourthStageTPadNbr(1); + ms_Event->SetHYD2TrkFourthStageTTime(1); + ms_Event->SetHYD2TrkFourthStageTDetectorNbr(m_index["Square1"] + N); + ms_Event->SetHYD2TrkFourthStageEDetectorNbr(m_index["Square1"] + N); + } + + FourthStageEnergy_itr++; + } + + // Fifth Stage + FifthStageEnergy_itr = FifthStageEnergyHitMap->GetMap()->begin(); + for (unsigned int h = 0; h < FifthStageEnergyHitMap->entries(); h++) { + G4int FifthStageEnergyTrackID = FifthStageEnergy_itr->first - N; + G4double FifthStageEnergy = *(FifthStageEnergy_itr->second); + + if (FifthStageEnergyTrackID == NTrackID) { + ms_Event->SetHYD2TrkFifthStageEEnergy(RandGauss::shoot(FifthStageEnergy, ResoFifthStage)); + ms_Event->SetHYD2TrkFifthStageEPadNbr(1); + ms_Event->SetHYD2TrkFifthStageTPadNbr(1); + ms_Event->SetHYD2TrkFifthStageTTime(1); + ms_Event->SetHYD2TrkFifthStageTDetectorNbr(m_index["Square1"] + N); + ms_Event->SetHYD2TrkFifthStageEDetectorNbr(m_index["Square1"] + N); + } + + FifthStageEnergy_itr++; + } + + // Sixth Stage + SixthStageEnergy_itr = SixthStageEnergyHitMap->GetMap()->begin(); + for (unsigned int h = 0; h < SixthStageEnergyHitMap->entries(); h++) { + G4int SixthStageEnergyTrackID = SixthStageEnergy_itr->first - N; + G4double SixthStageEnergy = *(SixthStageEnergy_itr->second); + + if (SixthStageEnergyTrackID == NTrackID) { + ms_Event->SetHYD2TrkSixthStageEEnergy(RandGauss::shoot(SixthStageEnergy, ResoSixthStage)); + ms_Event->SetHYD2TrkSixthStageEPadNbr(1); + ms_Event->SetHYD2TrkSixthStageTPadNbr(1); + ms_Event->SetHYD2TrkSixthStageTTime(1); + ms_Event->SetHYD2TrkSixthStageTDetectorNbr(m_index["Square1"] + N); + ms_Event->SetHYD2TrkSixthStageEDetectorNbr(m_index["Square1"] + N); + } + + SixthStageEnergy_itr++; + } + + DetectorNumber_itr++; + } + + // clear map for next event + DetectorNumberHitMap->clear(); + EnergyHitMap->clear(); + TimeHitMap->clear(); + XHitMap->clear(); + YHitMap->clear(); + PosXHitMap->clear(); + PosYHitMap->clear(); + PosZHitMap->clear(); + AngThetaHitMap->clear(); + AngPhiHitMap->clear(); + SecondStageEnergyHitMap->clear(); + ThirdStageEnergyHitMap->clear(); + FourthStageEnergyHitMap->clear(); + FifthStageEnergyHitMap->clear(); + SixthStageEnergyHitMap->clear(); + } +} -void Hyde2TrackerSquare1::InitializeScorers() -{ - bool already_exist = false; - m_FirstStageScorer = NPS::VDetector::CheckScorer("FirstStageScorerHYD2Square1",already_exist); - m_SecondStageScorer = NPS::VDetector::CheckScorer("SecondStageScorerHYD2Square1",already_exist); - m_ThirdStageScorer = NPS::VDetector::CheckScorer("ThirdStageScorerHYD2Square1",already_exist); - m_FourthStageScorer = NPS::VDetector::CheckScorer("FourthStageScorerHYD2Square1",already_exist); - m_FifthStageScorer = NPS::VDetector::CheckScorer("FifthStageScorerHYD2Square1",already_exist); - m_SixthStageScorer = NPS::VDetector::CheckScorer("SixthStageScorerHYD2Square1",already_exist); - if(already_exist) return; - - // First stage Associate Scorer - G4VPrimitiveScorer* DetNbr = new OBSOLETEGENERALSCORERS::PSDetectorNumber("DetectorNumber", "HYD2Square1", 0); - G4VPrimitiveScorer* TOF = new OBSOLETEGENERALSCORERS::PSTOF("StripTime","HYD2Square1", 0); - G4VPrimitiveScorer* InteractionCoordinatesX = new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesX("InterCoordX","HYD2Square1", 0); - G4VPrimitiveScorer* InteractionCoordinatesY = new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesY("InterCoordY","HYD2Square1", 0); - G4VPrimitiveScorer* InteractionCoordinatesZ = new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesZ("InterCoordZ","HYD2Square1", 0); - G4VPrimitiveScorer* InteractionCoordinatesAngleTheta = new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesAngleTheta("InterCoordAngTheta","HYD2Square1", 0); - G4VPrimitiveScorer* InteractionCoordinatesAnglePhi = new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesAnglePhi("InterCoordAngPhi","HYD2Square1", 0); - G4VPrimitiveScorer* Energy = new HYD2ScorerFirstStageEnergy("StripEnergy", "HYD2Square1", 0); - G4VPrimitiveScorer* StripPositionX = new HYD2ScorerFirstStageFrontStripSquare1("StripNumberX", 0, NumberOfStrips); - G4VPrimitiveScorer* StripPositionY = new HYD2ScorerFirstStageBackStripSquare1("StripNumberY", 0, NumberOfStrips); - - //and register it to the multifunctionnal detector - m_FirstStageScorer->RegisterPrimitive(DetNbr); - m_FirstStageScorer->RegisterPrimitive(Energy); - m_FirstStageScorer->RegisterPrimitive(TOF); - m_FirstStageScorer->RegisterPrimitive(StripPositionX); - m_FirstStageScorer->RegisterPrimitive(StripPositionY); - m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesX); - m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesY); - m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesZ); - m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesAngleTheta); - m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesAnglePhi); - - // Second stage Associate Scorer - G4VPrimitiveScorer* SecondStageEnergy = new HYD2ScorerSecondStageEnergy("SecondStageEnergy", "HYD2Square1", 0); - m_SecondStageScorer->RegisterPrimitive(SecondStageEnergy); - - // Third stage Associate Scorer - G4VPrimitiveScorer* ThirdStageEnergy = new HYD2ScorerThirdStageEnergy("ThirdStageEnergy", "HYD2Square1", 0); - m_ThirdStageScorer->RegisterPrimitive(ThirdStageEnergy); - - // Fourth stage Associate Scorer - G4VPrimitiveScorer* FourthStageEnergy = new HYD2ScorerFourthStageEnergy("FourthStageEnergy", "HYD2Square1", 0); - m_FourthStageScorer->RegisterPrimitive(FourthStageEnergy); - - // Fifth stage Associate Scorer - G4VPrimitiveScorer* FifthStageEnergy = new HYD2ScorerFifthStageEnergy("FifthStageEnergy", "HYD2Square1", 0); - m_FifthStageScorer->RegisterPrimitive(FifthStageEnergy); - - // Sixth stage Associate Scorer - G4VPrimitiveScorer* SixthStageEnergy = new HYD2ScorerSixthStageEnergy("SixthStageEnergy", "HYD2Square1", 0); - m_SixthStageScorer->RegisterPrimitive(SixthStageEnergy); - - // Add All Scorer to the Global Scorer Manager - G4SDManager::GetSDMpointer()->AddNewDetector(m_FirstStageScorer); - G4SDManager::GetSDMpointer()->AddNewDetector(m_SecondStageScorer); - G4SDManager::GetSDMpointer()->AddNewDetector(m_ThirdStageScorer); - G4SDManager::GetSDMpointer()->AddNewDetector(m_FourthStageScorer); - G4SDManager::GetSDMpointer()->AddNewDetector(m_FifthStageScorer); - G4SDManager::GetSDMpointer()->AddNewDetector(m_SixthStageScorer); +void Hyde2TrackerSquare1::InitializeScorers() { + bool already_exist = false; + m_FirstStageScorer = NPS::VDetector::CheckScorer("FirstStageScorerHYD2Square1", already_exist); + m_SecondStageScorer = NPS::VDetector::CheckScorer("SecondStageScorerHYD2Square1", already_exist); + m_ThirdStageScorer = NPS::VDetector::CheckScorer("ThirdStageScorerHYD2Square1", already_exist); + m_FourthStageScorer = NPS::VDetector::CheckScorer("FourthStageScorerHYD2Square1", already_exist); + m_FifthStageScorer = NPS::VDetector::CheckScorer("FifthStageScorerHYD2Square1", already_exist); + m_SixthStageScorer = NPS::VDetector::CheckScorer("SixthStageScorerHYD2Square1", already_exist); + if (already_exist) + return; + + // First stage Associate Scorer + G4VPrimitiveScorer* DetNbr = new OBSOLETEGENERALSCORERS::PSDetectorNumber("DetectorNumber", "HYD2Square1", 0); + G4VPrimitiveScorer* TOF = new OBSOLETEGENERALSCORERS::PSTOF("StripTime", "HYD2Square1", 0); + G4VPrimitiveScorer* InteractionCoordinatesX = + new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesX("InterCoordX", "HYD2Square1", 0); + G4VPrimitiveScorer* InteractionCoordinatesY = + new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesY("InterCoordY", "HYD2Square1", 0); + G4VPrimitiveScorer* InteractionCoordinatesZ = + new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesZ("InterCoordZ", "HYD2Square1", 0); + G4VPrimitiveScorer* InteractionCoordinatesAngleTheta = + new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesAngleTheta("InterCoordAngTheta", "HYD2Square1", 0); + G4VPrimitiveScorer* InteractionCoordinatesAnglePhi = + new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesAnglePhi("InterCoordAngPhi", "HYD2Square1", 0); + G4VPrimitiveScorer* Energy = new HYD2ScorerFirstStageEnergy("StripEnergy", "HYD2Square1", 0); + G4VPrimitiveScorer* StripPositionX = new HYD2ScorerFirstStageFrontStripSquare1("StripNumberX", 0, NumberOfStrips); + G4VPrimitiveScorer* StripPositionY = new HYD2ScorerFirstStageBackStripSquare1("StripNumberY", 0, NumberOfStrips); + + // and register it to the multifunctionnal detector + m_FirstStageScorer->RegisterPrimitive(DetNbr); + m_FirstStageScorer->RegisterPrimitive(Energy); + m_FirstStageScorer->RegisterPrimitive(TOF); + m_FirstStageScorer->RegisterPrimitive(StripPositionX); + m_FirstStageScorer->RegisterPrimitive(StripPositionY); + m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesX); + m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesY); + m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesZ); + m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesAngleTheta); + m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesAnglePhi); + + // Second stage Associate Scorer + G4VPrimitiveScorer* SecondStageEnergy = new HYD2ScorerSecondStageEnergy("SecondStageEnergy", "HYD2Square1", 0); + m_SecondStageScorer->RegisterPrimitive(SecondStageEnergy); + + // Third stage Associate Scorer + G4VPrimitiveScorer* ThirdStageEnergy = new HYD2ScorerThirdStageEnergy("ThirdStageEnergy", "HYD2Square1", 0); + m_ThirdStageScorer->RegisterPrimitive(ThirdStageEnergy); + + // Fourth stage Associate Scorer + G4VPrimitiveScorer* FourthStageEnergy = new HYD2ScorerFourthStageEnergy("FourthStageEnergy", "HYD2Square1", 0); + m_FourthStageScorer->RegisterPrimitive(FourthStageEnergy); + + // Fifth stage Associate Scorer + G4VPrimitiveScorer* FifthStageEnergy = new HYD2ScorerFifthStageEnergy("FifthStageEnergy", "HYD2Square1", 0); + m_FifthStageScorer->RegisterPrimitive(FifthStageEnergy); + + // Sixth stage Associate Scorer + G4VPrimitiveScorer* SixthStageEnergy = new HYD2ScorerSixthStageEnergy("SixthStageEnergy", "HYD2Square1", 0); + m_SixthStageScorer->RegisterPrimitive(SixthStageEnergy); + + // Add All Scorer to the Global Scorer Manager + G4SDManager::GetSDMpointer()->AddNewDetector(m_FirstStageScorer); + G4SDManager::GetSDMpointer()->AddNewDetector(m_SecondStageScorer); + G4SDManager::GetSDMpointer()->AddNewDetector(m_ThirdStageScorer); + G4SDManager::GetSDMpointer()->AddNewDetector(m_FourthStageScorer); + G4SDManager::GetSDMpointer()->AddNewDetector(m_FifthStageScorer); + G4SDManager::GetSDMpointer()->AddNewDetector(m_SixthStageScorer); } diff --git a/NPSimulation/Detectors/Hyde2/Hyde2TrackerTrapezoid1.cc b/NPSimulation/Detectors/Hyde2/Hyde2TrackerTrapezoid1.cc index f4585fad7ef70e4009428feb58ad14dc84705fdc..3ed6b3d12d2c4cb76e723ed4e56586607006196a 100644 --- a/NPSimulation/Detectors/Hyde2/Hyde2TrackerTrapezoid1.cc +++ b/NPSimulation/Detectors/Hyde2/Hyde2TrackerTrapezoid1.cc @@ -23,177 +23,135 @@ *****************************************************************************/ // C++ headers +#include <cmath> #include <sstream> #include <string> -#include <cmath> // G4 Geometry headers #include "G4Box.hh" #include "G4Trap.hh" // G4 various headers -#include "G4MaterialTable.hh" +#include "G4Colour.hh" #include "G4Element.hh" #include "G4ElementTable.hh" -#include "G4VisAttributes.hh" -#include "G4Colour.hh" +#include "G4MaterialTable.hh" +#include "G4PVDivision.hh" +#include "G4PVPlacement.hh" #include "G4RotationMatrix.hh" #include "G4Transform3D.hh" -#include "G4PVPlacement.hh" -#include "G4PVDivision.hh" +#include "G4VisAttributes.hh" // G4 sensitive -#include "G4SDManager.hh" #include "G4MultiFunctionalDetector.hh" +#include "G4SDManager.hh" // NPTool headers +#include "Hyde2Scorers.hh" #include "Hyde2TrackerTrapezoid1.hh" +#include "NPSVDetector.hh" #include "ObsoleteGeneralScorers.hh" -#include "Hyde2Scorers.hh" #include "RootOutput.h" -#include "NPSVDetector.hh" // CLHEP #include "CLHEP/Random/RandGauss.h" using namespace std; using namespace CLHEP; -using namespace HYD2TRAP1 ; - - +using namespace HYD2TRAP1; //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -Hyde2TrackerTrapezoid1::Hyde2TrackerTrapezoid1() -{ - ms_InterCoord = 0; -} - - +Hyde2TrackerTrapezoid1::Hyde2TrackerTrapezoid1() { ms_InterCoord = 0; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -Hyde2TrackerTrapezoid1::~Hyde2TrackerTrapezoid1() -{ -} - - +Hyde2TrackerTrapezoid1::~Hyde2TrackerTrapezoid1() {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Hyde2TrackerTrapezoid1::AddModule(G4ThreeVector X1_Y1 , - G4ThreeVector X128_Y1 , - G4ThreeVector X1_Y128 , - G4ThreeVector X128_Y128 , - bool wFirstStage , - bool wSecondStage , - bool wThirdStage , - bool wFourthStage , - bool wFifthStage , - bool wSixthStage) -{ - m_DefinitionType.push_back(true) ; - - m_X1_Y1.push_back(X1_Y1) ; - m_X128_Y1.push_back(X128_Y1) ; - m_X1_Y128.push_back(X1_Y128) ; - m_X128_Y128.push_back(X128_Y128) ; - m_wFirstStage.push_back(wFirstStage) ; - m_wSecondStage.push_back(wSecondStage) ; - m_wThirdStage.push_back(wThirdStage) ; - m_wFourthStage.push_back(wFourthStage) ; - m_wFifthStage.push_back(wFifthStage) ; - m_wSixthStage.push_back(wSixthStage) ; - - m_R.push_back(0) ; - m_Theta.push_back(0) ; - m_Phi.push_back(0) ; - m_beta_u.push_back(0) ; - m_beta_v.push_back(0) ; - m_beta_w.push_back(0) ; +void Hyde2TrackerTrapezoid1::AddModule(G4ThreeVector X1_Y1, G4ThreeVector X128_Y1, G4ThreeVector X1_Y128, + G4ThreeVector X128_Y128, bool wFirstStage, bool wSecondStage, bool wThirdStage, + bool wFourthStage, bool wFifthStage, bool wSixthStage) { + m_DefinitionType.push_back(true); + + m_X1_Y1.push_back(X1_Y1); + m_X128_Y1.push_back(X128_Y1); + m_X1_Y128.push_back(X1_Y128); + m_X128_Y128.push_back(X128_Y128); + m_wFirstStage.push_back(wFirstStage); + m_wSecondStage.push_back(wSecondStage); + m_wThirdStage.push_back(wThirdStage); + m_wFourthStage.push_back(wFourthStage); + m_wFifthStage.push_back(wFifthStage); + m_wSixthStage.push_back(wSixthStage); + + m_R.push_back(0); + m_Theta.push_back(0); + m_Phi.push_back(0); + m_beta_u.push_back(0); + m_beta_v.push_back(0); + m_beta_w.push_back(0); } - - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Hyde2TrackerTrapezoid1::AddModule(G4double R , - G4double Theta , - G4double Phi , - G4double beta_u , - G4double beta_v , - G4double beta_w , - bool wFirstStage , - bool wSecondStage , - bool wThirdStage , - bool wFourthStage , - bool wFifthStage , - bool wSixthStage) -{ - G4ThreeVector empty = G4ThreeVector(0, 0, 0); - - m_DefinitionType.push_back(false); - - m_R.push_back(R) ; - m_Theta.push_back(Theta) ; - m_Phi.push_back(Phi) ; - m_beta_u.push_back(beta_u) ; - m_beta_v.push_back(beta_v) ; - m_beta_w.push_back(beta_w) ; - m_wFirstStage.push_back(wFirstStage) ; - m_wSecondStage.push_back(wSecondStage) ; - m_wThirdStage.push_back(wThirdStage) ; - m_wFourthStage.push_back(wFourthStage) ; - m_wFifthStage.push_back(wFifthStage) ; - m_wSixthStage.push_back(wSixthStage) ; - - m_X1_Y1.push_back(empty) ; - m_X128_Y1.push_back(empty) ; - m_X1_Y128.push_back(empty) ; - m_X128_Y128.push_back(empty) ; +void Hyde2TrackerTrapezoid1::AddModule(G4double R, G4double Theta, G4double Phi, G4double beta_u, G4double beta_v, + G4double beta_w, bool wFirstStage, bool wSecondStage, bool wThirdStage, + bool wFourthStage, bool wFifthStage, bool wSixthStage) { + G4ThreeVector empty = G4ThreeVector(0, 0, 0); + + m_DefinitionType.push_back(false); + + m_R.push_back(R); + m_Theta.push_back(Theta); + m_Phi.push_back(Phi); + m_beta_u.push_back(beta_u); + m_beta_v.push_back(beta_v); + m_beta_w.push_back(beta_w); + m_wFirstStage.push_back(wFirstStage); + m_wSecondStage.push_back(wSecondStage); + m_wThirdStage.push_back(wThirdStage); + m_wFourthStage.push_back(wFourthStage); + m_wFifthStage.push_back(wFifthStage); + m_wSixthStage.push_back(wSixthStage); + + m_X1_Y1.push_back(empty); + m_X128_Y1.push_back(empty); + m_X1_Y128.push_back(empty); + m_X128_Y128.push_back(empty); } - - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Hyde2TrackerTrapezoid1::VolumeMaker(G4int TelescopeNumber , - G4ThreeVector MMpos , - G4RotationMatrix* MMrot , - bool wFirstStage , - bool wSecondStage , - bool wThirdStage , - bool wFourthStage , - bool wFifthStage , - bool wSixthStage , - G4LogicalVolume* world) -{ - G4double NbrTelescopes = TelescopeNumber ; - G4String DetectorNumber ; - ostringstream Number ; - Number << NbrTelescopes ; - DetectorNumber = Number.str() ; - - //////////////////////////////////////////////////////////////// - ////////////// Starting Volume Definition ////////////////////// - //////////////////////////////////////////////////////////////// - G4String Name = "HYD2Trapezoid1" + DetectorNumber ; - - // Definition of the volume containing the sensitive detector - G4Trap* solidHYD2Trapezoid1 = new G4Trap(Name, - Length/2, 0*deg, 0*deg, - Height/2, BaseLarge/2, BaseSmall/2, 0*deg, - Height/2, BaseLarge/2, BaseSmall/2, 0*deg); - G4LogicalVolume* logicHYD2Trapezoid1 = new G4LogicalVolume(solidHYD2Trapezoid1, m_MaterialVacuum, Name, 0, 0, 0); - - new G4PVPlacement(G4Transform3D(*MMrot, MMpos), logicHYD2Trapezoid1, Name, world, false, 0); - - logicHYD2Trapezoid1->SetVisAttributes(G4VisAttributes::Invisible); - if (m_non_sensitive_part_visiualisation) logicHYD2Trapezoid1->SetVisAttributes(G4VisAttributes(G4Colour(0.90, 0.90, 0.90))); - - //Place two marker to identify the u and v axis on silicon face: - //marker are placed a bit before the silicon itself so they don't perturbate simulation - //Uncomment to help debugging or if you want to understand the way the code work. - //I should recommand to Comment it during simulation to avoid perturbation of simulation - //Remember G4 is limitationg step on geometry constraints. - /* +void Hyde2TrackerTrapezoid1::VolumeMaker(G4int TelescopeNumber, G4ThreeVector MMpos, G4RotationMatrix* MMrot, + bool wFirstStage, bool wSecondStage, bool wThirdStage, bool wFourthStage, + bool wFifthStage, bool wSixthStage, G4LogicalVolume* world) { + G4double NbrTelescopes = TelescopeNumber; + G4String DetectorNumber; + ostringstream Number; + Number << NbrTelescopes; + DetectorNumber = Number.str(); + + //////////////////////////////////////////////////////////////// + ////////////// Starting Volume Definition ////////////////////// + //////////////////////////////////////////////////////////////// + G4String Name = "HYD2Trapezoid1" + DetectorNumber; + + // Definition of the volume containing the sensitive detector + G4Trap* solidHYD2Trapezoid1 = new G4Trap(Name, Length / 2, 0 * deg, 0 * deg, Height / 2, BaseLarge / 2, BaseSmall / 2, + 0 * deg, Height / 2, BaseLarge / 2, BaseSmall / 2, 0 * deg); + G4LogicalVolume* logicHYD2Trapezoid1 = new G4LogicalVolume(solidHYD2Trapezoid1, m_MaterialVacuum, Name, 0, 0, 0); + + new G4PVPlacement(G4Transform3D(*MMrot, MMpos), logicHYD2Trapezoid1, Name, world, false, 0); + + logicHYD2Trapezoid1->SetVisAttributes(G4VisAttributes::GetInvisible()); + if (m_non_sensitive_part_visiualisation) + logicHYD2Trapezoid1->SetVisAttributes(G4VisAttributes(G4Colour(0.90, 0.90, 0.90))); + + // Place two marker to identify the u and v axis on silicon face: + // marker are placed a bit before the silicon itself so they don't perturbate simulation + // Uncomment to help debugging or if you want to understand the way the code work. + // I should recommand to Comment it during simulation to avoid perturbation of simulation + // Remember G4 is limitationg step on geometry constraints. + /* G4ThreeVector positionMarkerU = CT*0.98 + MMu*SiliconFace/4; G4Box* solidMarkerU = new G4Box( "solidMarkerU" , SiliconFace/4 , 1*mm , 1*mm ) ; - G4LogicalVolume* logicMarkerU = new G4LogicalVolume( solidMarkerU , m_MaterialVacuum , "logicMarkerU",0,0,0) ; + G4LogicalVolume* logicMarkerU = new G4LogicalVolume( solidMarkerU , m_MaterialVacuum , "logicMarkerU",0,0,0) ; PVPBuffer = new G4PVPlacement(G4Transform3D(*MMrot,positionMarkerU),logicMarkerU,"MarkerU",world,false,0) ; G4VisAttributes* MarkerUVisAtt= new G4VisAttributes(G4Colour(0.,0.,0.5));//blue @@ -201,187 +159,156 @@ void Hyde2TrackerTrapezoid1::VolumeMaker(G4int TelescopeNumber , G4ThreeVector positionMarkerV = CT*0.98 + MMv*SiliconFace/4; G4Box* solidMarkerV = new G4Box( "solidMarkerU" , 1*mm , SiliconFace/4 , 1*mm ) ; - G4LogicalVolume* logicMarkerV = new G4LogicalVolume( solidMarkerV , m_MaterialVacuum , "logicMarkerV",0,0,0) ; + G4LogicalVolume* logicMarkerV = new G4LogicalVolume( solidMarkerV , m_MaterialVacuum , "logicMarkerV",0,0,0) ; PVPBuffer = new G4PVPlacement(G4Transform3D(*MMrot,positionMarkerV),logicMarkerV,"MarkerV",world,false,0) ; G4VisAttributes* MarkerVVisAtt= new G4VisAttributes(G4Colour(0.,0.5,0.5));//green logicMarkerV->SetVisAttributes(MarkerVVisAtt); */ - //////////////////////////////////////////////////////////////// - /////////////////// First Stage Construction//////////////////// - //////////////////////////////////////////////////////////////// - if (wFirstStage) { - // Silicon detector itself - G4ThreeVector positionFirstStage = G4ThreeVector(0, 0, FirstStage_PosZ); - - G4Trap* solidFirstStage = new G4Trap("solidFirstStage", - FirstStageThickness/2, 0*deg, 0*deg, - FirstStageHeight/2, FirstStageBaseLarge/2, FirstStageBaseSmall/2, 0*deg, - FirstStageHeight/2, FirstStageBaseLarge/2, FirstStageBaseSmall/2, 0*deg); - G4LogicalVolume* logicFirstStage = new G4LogicalVolume(solidFirstStage, m_MaterialSilicon, "logicFirstStage", 0, 0, 0); - - new G4PVPlacement(0, - positionFirstStage, - logicFirstStage, - Name + "_FirstStage", - logicHYD2Trapezoid1, - false, - 0); - - // Set First Stage sensible - logicFirstStage->SetSensitiveDetector(m_FirstStageScorer); - - ///Visualisation of FirstStage Strip - G4VisAttributes* FirstStageVisAtt = new G4VisAttributes(G4Colour(0.0, 0.0, 0.9)); // blue - logicFirstStage->SetVisAttributes(FirstStageVisAtt); - } - - //////////////////////////////////////////////////////////////// - //////////////// Second Stage Construction //////////////////// - //////////////////////////////////////////////////////////////// - if (wSecondStage) { - // Second stage silicon detector - G4ThreeVector positionSecondStage = G4ThreeVector(0, 0, SecondStage_PosZ); - - G4Trap* solidSecondStage = new G4Trap("solidSecondStage", - SecondStageThickness/2, 0*deg, 0*deg, - FirstStageHeight/2, FirstStageBaseLarge/2, FirstStageBaseSmall/2, 0*deg, - FirstStageHeight/2, FirstStageBaseLarge/2, FirstStageBaseSmall/2, 0*deg); - G4LogicalVolume* logicSecondStage = new G4LogicalVolume(solidSecondStage, m_MaterialSilicon, "logicSecondStage", 0, 0, 0); - - new G4PVPlacement(0, - positionSecondStage, - logicSecondStage, - Name + "_SecondStage", - logicHYD2Trapezoid1, - false, - 0); - - // Set Second Stage sensible - logicSecondStage->SetSensitiveDetector(m_SecondStageScorer); - - ///Visualisation of SecondStage Strip - G4VisAttributes* SecondStageVisAtt = new G4VisAttributes(G4Colour(0.5, 0.5, 0.5)); - logicSecondStage->SetVisAttributes(SecondStageVisAtt); - } - - //////////////////////////////////////////////////////////////// - ///////////////// Third Stage Construction ///////////////////// - //////////////////////////////////////////////////////////////// - if (wThirdStage) { - // Third stage silicon detector - G4ThreeVector positionThirdStage = G4ThreeVector(0, 0, ThirdStage_PosZ); - - G4Trap* solidThirdStage = new G4Trap("solidThirdStage", - ThirdStageThickness/2, 0*deg, 0*deg, - FirstStageHeight/2, FirstStageBaseLarge/2, FirstStageBaseSmall/2, 0*deg, - FirstStageHeight/2, FirstStageBaseLarge/2, FirstStageBaseSmall/2, 0*deg); - G4LogicalVolume* logicThirdStage = new G4LogicalVolume(solidThirdStage, m_MaterialSilicon, "logicThirdStage", 0, 0, 0); - - new G4PVPlacement(0, - positionThirdStage, - logicThirdStage, - Name + "_ThirdStage", - logicHYD2Trapezoid1, - false, - 0); - - // Set Third Stage sensible - logicThirdStage->SetSensitiveDetector(m_ThirdStageScorer); - - ///Visualisation of Third Stage - G4VisAttributes* ThirdStageVisAtt = new G4VisAttributes(G4Colour(0.0, 0.9, 0.0)); // red - logicThirdStage->SetVisAttributes(ThirdStageVisAtt); - } - - //////////////////////////////////////////////////////////////// - ///////////////// Fourth Stage Construction //////////////////// - //////////////////////////////////////////////////////////////// - if (wFourthStage) { - // Fourth stage silicon detector - G4ThreeVector positionFourthStage = G4ThreeVector(0, 0, FourthStage_PosZ); - - G4Trap* solidFourthStage = new G4Trap("solidFourthStage", - FourthStageThickness/2, 0*deg, 0*deg, - FirstStageHeight/2, FirstStageBaseLarge/2, FirstStageBaseSmall/2, 0*deg, - FirstStageHeight/2, FirstStageBaseLarge/2, FirstStageBaseSmall/2, 0*deg); - G4LogicalVolume* logicFourthStage = new G4LogicalVolume(solidFourthStage, m_MaterialSilicon, "logicFourthStage", 0, 0, 0); - - new G4PVPlacement(0, - positionFourthStage, - logicFourthStage, - Name + "_FourthStage", - logicHYD2Trapezoid1, - false, - 0); - - // Set Fourth Stage sensible - logicFourthStage->SetSensitiveDetector(m_FourthStageScorer); - - ///Visualisation of Fourth Stage - G4VisAttributes* FourthStageVisAtt = new G4VisAttributes(G4Colour(0.0, 0.9, 0.0)); // red - logicFourthStage->SetVisAttributes(FourthStageVisAtt); - } - - //////////////////////////////////////////////////////////////// - ///////////////// Fifth Stage Construction ///////////////////// - //////////////////////////////////////////////////////////////// - if (wFifthStage) { - // Fifth stage silicon detector - G4ThreeVector positionFifthStage = G4ThreeVector(0, 0, FifthStage_PosZ); - - G4Trap* solidFifthStage = new G4Trap("solidFifthStage", - FifthStageThickness/2, 0*deg, 0*deg, - FirstStageHeight/2, FirstStageBaseLarge/2, FirstStageBaseSmall/2, 0*deg, - FirstStageHeight/2, FirstStageBaseLarge/2, FirstStageBaseSmall/2, 0*deg); - G4LogicalVolume* logicFifthStage = new G4LogicalVolume(solidFifthStage, m_MaterialSilicon, "logicFifthStage", 0, 0, 0); - - new G4PVPlacement(0, - positionFifthStage, - logicFifthStage, - Name + "_FifthStage", - logicHYD2Trapezoid1, - false, - 0); - - // Set Fifth Stage sensible - logicFifthStage->SetSensitiveDetector(m_FifthStageScorer); - - ///Visualisation of Fifth Stage - G4VisAttributes* FifthStageVisAtt = new G4VisAttributes(G4Colour(0.0, 0.9, 0.0)); // red - logicFifthStage->SetVisAttributes(FifthStageVisAtt); - } - - //////////////////////////////////////////////////////////////// - ///////////////// Sixth Stage Construction ///////////////////// - //////////////////////////////////////////////////////////////// - if (wSixthStage) { - // Sixth stage silicon detector - G4ThreeVector positionSixthStage = G4ThreeVector(0, 0, SixthStage_PosZ); - - G4Trap* solidSixthStage = new G4Trap("solidSixthStage", - SixthStageThickness/2, 0*deg, 0*deg, - FirstStageHeight/2, FirstStageBaseLarge/2, FirstStageBaseSmall/2, 0*deg, - FirstStageHeight/2, FirstStageBaseLarge/2, FirstStageBaseSmall/2, 0*deg); - G4LogicalVolume* logicSixthStage = new G4LogicalVolume(solidSixthStage, m_MaterialSilicon, "logicSixthStage", 0, 0, 0); - - new G4PVPlacement(0, - positionSixthStage, - logicSixthStage, - Name + "_SixthStage", - logicHYD2Trapezoid1, - false, - 0); - - // Set Sixth Stage sensible - logicSixthStage->SetSensitiveDetector(m_SixthStageScorer); - - ///Visualisation of Sixth Stage - G4VisAttributes* SixthStageVisAtt = new G4VisAttributes(G4Colour(0.0, 0.9, 0.0)); // red - logicSixthStage->SetVisAttributes(SixthStageVisAtt); - } - + //////////////////////////////////////////////////////////////// + /////////////////// First Stage Construction//////////////////// + //////////////////////////////////////////////////////////////// + if (wFirstStage) { + // Silicon detector itself + G4ThreeVector positionFirstStage = G4ThreeVector(0, 0, FirstStage_PosZ); + + G4Trap* solidFirstStage = + new G4Trap("solidFirstStage", FirstStageThickness / 2, 0 * deg, 0 * deg, FirstStageHeight / 2, + FirstStageBaseLarge / 2, FirstStageBaseSmall / 2, 0 * deg, FirstStageHeight / 2, + FirstStageBaseLarge / 2, FirstStageBaseSmall / 2, 0 * deg); + G4LogicalVolume* logicFirstStage = + new G4LogicalVolume(solidFirstStage, m_MaterialSilicon, "logicFirstStage", 0, 0, 0); + + new G4PVPlacement(0, positionFirstStage, logicFirstStage, Name + "_FirstStage", logicHYD2Trapezoid1, false, 0); + + // Set First Stage sensible + logicFirstStage->SetSensitiveDetector(m_FirstStageScorer); + + /// Visualisation of FirstStage Strip + G4VisAttributes* FirstStageVisAtt = new G4VisAttributes(G4Colour(0.0, 0.0, 0.9)); // blue + logicFirstStage->SetVisAttributes(FirstStageVisAtt); + } + + //////////////////////////////////////////////////////////////// + //////////////// Second Stage Construction //////////////////// + //////////////////////////////////////////////////////////////// + if (wSecondStage) { + // Second stage silicon detector + G4ThreeVector positionSecondStage = G4ThreeVector(0, 0, SecondStage_PosZ); + + G4Trap* solidSecondStage = + new G4Trap("solidSecondStage", SecondStageThickness / 2, 0 * deg, 0 * deg, FirstStageHeight / 2, + FirstStageBaseLarge / 2, FirstStageBaseSmall / 2, 0 * deg, FirstStageHeight / 2, + FirstStageBaseLarge / 2, FirstStageBaseSmall / 2, 0 * deg); + G4LogicalVolume* logicSecondStage = + new G4LogicalVolume(solidSecondStage, m_MaterialSilicon, "logicSecondStage", 0, 0, 0); + + new G4PVPlacement(0, positionSecondStage, logicSecondStage, Name + "_SecondStage", logicHYD2Trapezoid1, false, 0); + + // Set Second Stage sensible + logicSecondStage->SetSensitiveDetector(m_SecondStageScorer); + + /// Visualisation of SecondStage Strip + G4VisAttributes* SecondStageVisAtt = new G4VisAttributes(G4Colour(0.5, 0.5, 0.5)); + logicSecondStage->SetVisAttributes(SecondStageVisAtt); + } + + //////////////////////////////////////////////////////////////// + ///////////////// Third Stage Construction ///////////////////// + //////////////////////////////////////////////////////////////// + if (wThirdStage) { + // Third stage silicon detector + G4ThreeVector positionThirdStage = G4ThreeVector(0, 0, ThirdStage_PosZ); + + G4Trap* solidThirdStage = + new G4Trap("solidThirdStage", ThirdStageThickness / 2, 0 * deg, 0 * deg, FirstStageHeight / 2, + FirstStageBaseLarge / 2, FirstStageBaseSmall / 2, 0 * deg, FirstStageHeight / 2, + FirstStageBaseLarge / 2, FirstStageBaseSmall / 2, 0 * deg); + G4LogicalVolume* logicThirdStage = + new G4LogicalVolume(solidThirdStage, m_MaterialSilicon, "logicThirdStage", 0, 0, 0); + + new G4PVPlacement(0, positionThirdStage, logicThirdStage, Name + "_ThirdStage", logicHYD2Trapezoid1, false, 0); + + // Set Third Stage sensible + logicThirdStage->SetSensitiveDetector(m_ThirdStageScorer); + + /// Visualisation of Third Stage + G4VisAttributes* ThirdStageVisAtt = new G4VisAttributes(G4Colour(0.0, 0.9, 0.0)); // red + logicThirdStage->SetVisAttributes(ThirdStageVisAtt); + } + + //////////////////////////////////////////////////////////////// + ///////////////// Fourth Stage Construction //////////////////// + //////////////////////////////////////////////////////////////// + if (wFourthStage) { + // Fourth stage silicon detector + G4ThreeVector positionFourthStage = G4ThreeVector(0, 0, FourthStage_PosZ); + + G4Trap* solidFourthStage = + new G4Trap("solidFourthStage", FourthStageThickness / 2, 0 * deg, 0 * deg, FirstStageHeight / 2, + FirstStageBaseLarge / 2, FirstStageBaseSmall / 2, 0 * deg, FirstStageHeight / 2, + FirstStageBaseLarge / 2, FirstStageBaseSmall / 2, 0 * deg); + G4LogicalVolume* logicFourthStage = + new G4LogicalVolume(solidFourthStage, m_MaterialSilicon, "logicFourthStage", 0, 0, 0); + + new G4PVPlacement(0, positionFourthStage, logicFourthStage, Name + "_FourthStage", logicHYD2Trapezoid1, false, 0); + + // Set Fourth Stage sensible + logicFourthStage->SetSensitiveDetector(m_FourthStageScorer); + + /// Visualisation of Fourth Stage + G4VisAttributes* FourthStageVisAtt = new G4VisAttributes(G4Colour(0.0, 0.9, 0.0)); // red + logicFourthStage->SetVisAttributes(FourthStageVisAtt); + } + + //////////////////////////////////////////////////////////////// + ///////////////// Fifth Stage Construction ///////////////////// + //////////////////////////////////////////////////////////////// + if (wFifthStage) { + // Fifth stage silicon detector + G4ThreeVector positionFifthStage = G4ThreeVector(0, 0, FifthStage_PosZ); + + G4Trap* solidFifthStage = + new G4Trap("solidFifthStage", FifthStageThickness / 2, 0 * deg, 0 * deg, FirstStageHeight / 2, + FirstStageBaseLarge / 2, FirstStageBaseSmall / 2, 0 * deg, FirstStageHeight / 2, + FirstStageBaseLarge / 2, FirstStageBaseSmall / 2, 0 * deg); + G4LogicalVolume* logicFifthStage = + new G4LogicalVolume(solidFifthStage, m_MaterialSilicon, "logicFifthStage", 0, 0, 0); + + new G4PVPlacement(0, positionFifthStage, logicFifthStage, Name + "_FifthStage", logicHYD2Trapezoid1, false, 0); + + // Set Fifth Stage sensible + logicFifthStage->SetSensitiveDetector(m_FifthStageScorer); + + /// Visualisation of Fifth Stage + G4VisAttributes* FifthStageVisAtt = new G4VisAttributes(G4Colour(0.0, 0.9, 0.0)); // red + logicFifthStage->SetVisAttributes(FifthStageVisAtt); + } + + //////////////////////////////////////////////////////////////// + ///////////////// Sixth Stage Construction ///////////////////// + //////////////////////////////////////////////////////////////// + if (wSixthStage) { + // Sixth stage silicon detector + G4ThreeVector positionSixthStage = G4ThreeVector(0, 0, SixthStage_PosZ); + + G4Trap* solidSixthStage = + new G4Trap("solidSixthStage", SixthStageThickness / 2, 0 * deg, 0 * deg, FirstStageHeight / 2, + FirstStageBaseLarge / 2, FirstStageBaseSmall / 2, 0 * deg, FirstStageHeight / 2, + FirstStageBaseLarge / 2, FirstStageBaseSmall / 2, 0 * deg); + G4LogicalVolume* logicSixthStage = + new G4LogicalVolume(solidSixthStage, m_MaterialSilicon, "logicSixthStage", 0, 0, 0); + + new G4PVPlacement(0, positionSixthStage, logicSixthStage, Name + "_SixthStage", logicHYD2Trapezoid1, false, 0); + + // Set Sixth Stage sensible + logicSixthStage->SetSensitiveDetector(m_SixthStageScorer); + + /// Visualisation of Sixth Stage + G4VisAttributes* SixthStageVisAtt = new G4VisAttributes(G4Colour(0.0, 0.9, 0.0)); // red + logicSixthStage->SetVisAttributes(SixthStageVisAtt); + } } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... @@ -391,836 +318,825 @@ void Hyde2TrackerTrapezoid1::VolumeMaker(G4int TelescopeNumber , // Read stream at Configfile to pick-up parameters of detector (Position,...) // Called in DetecorConstruction::ReadDetextorConfiguration Method -void Hyde2TrackerTrapezoid1::ReadConfiguration(string Path) -{ - ifstream ConfigFile ; - ConfigFile.open(Path.c_str()) ; - string LineBuffer ; - string DataBuffer ; - - // A:X1_Y1 --> X:1 Y:1 - // B:X128_Y1 --> X:128 Y:1 - // C:X1_Y128 --> X:1 Y:128 - // D:X128_Y128 --> X:128 Y:128 - - G4double Ax , Bx , Cx , Dx , Ay , By , Cy , Dy , Az , Bz , Cz , Dz ; - G4ThreeVector A , B , C , D ; - G4double Theta = 0 , Phi = 0 , R = 0 , beta_u = 0 , beta_v = 0 , beta_w = 0 ; - int FIRSTSTAGE = 0 , SECONDSTAGE = 0 , THIRDSTAGE = 0 , FOURTHSTAGE = 0 , FIFTHSTAGE = 0 , SIXTHSTAGE = 0 ; - - bool ReadingStatus = false ; - - bool check_A = false ; - bool check_C = false ; - bool check_B = false ; - bool check_D = false ; - - bool check_Theta = false ; - bool check_Phi = false ; - bool check_R = false ; -// bool check_beta = false ; - - bool check_FirstStage = false ; - bool check_SecondStage = false ; - bool check_ThirdStage = false ; - bool check_FourthStage = false ; - bool check_FifthStage = false ; - bool check_SixthStage = false ; - bool checkVis = false ; - - while (!ConfigFile.eof()) { - getline(ConfigFile, LineBuffer); - if (LineBuffer.compare(0, 14, "HYD2Trapezoid1") == 0) { - G4cout << "///" << G4endl ; - G4cout << "Trapezoid1 element found: " << G4endl ; - ReadingStatus = true ; - } - - while(ReadingStatus){ - - ConfigFile >> DataBuffer; - // Comment Line - if (DataBuffer.compare(0, 1, "%") == 0) {/*do nothing */;} - - // Position method - else if (DataBuffer.compare(0, 6, "X1_Y1=") == 0) { - check_A = true; - ConfigFile >> DataBuffer ; - Ax = atof(DataBuffer.c_str()) ; - Ax = Ax * mm ; - ConfigFile >> DataBuffer ; - Ay = atof(DataBuffer.c_str()) ; - Ay = Ay * mm ; - ConfigFile >> DataBuffer ; - Az = atof(DataBuffer.c_str()) ; - Az = Az * mm ; - - A = G4ThreeVector(Ax, Ay, Az); - G4cout << "X1 Y1 corner position : " << A << G4endl; - } - - else if (DataBuffer.compare(0, 8, "X128_Y1=") == 0) { - check_B = true; - ConfigFile >> DataBuffer ; - Bx = atof(DataBuffer.c_str()) ; - Bx = Bx * mm ; - ConfigFile >> DataBuffer ; - By = atof(DataBuffer.c_str()) ; - By = By * mm ; - ConfigFile >> DataBuffer ; - Bz = atof(DataBuffer.c_str()) ; - Bz = Bz * mm ; - - B = G4ThreeVector(Bx, By, Bz); - G4cout << "X128 Y1 corner position : " << B << G4endl; - } - - else if (DataBuffer.compare(0, 8, "X1_Y128=") == 0) { - check_C = true; - ConfigFile >> DataBuffer ; - Cx = atof(DataBuffer.c_str()) ; - Cx = Cx * mm ; - ConfigFile >> DataBuffer ; - Cy = atof(DataBuffer.c_str()) ; - Cy = Cy * mm ; - ConfigFile >> DataBuffer ; - Cz = atof(DataBuffer.c_str()) ; - Cz = Cz * mm ; - - C = G4ThreeVector(Cx, Cy, Cz); - G4cout << "X1 Y128 corner position : " << C << G4endl; - } - - else if (DataBuffer.compare(0, 10, "X128_Y128=") == 0) { - check_D = true; - ConfigFile >> DataBuffer ; - Dx = atof(DataBuffer.c_str()) ; - Dx = Dx * mm ; - ConfigFile >> DataBuffer ; - Dy = atof(DataBuffer.c_str()) ; - Dy = Dy * mm ; - ConfigFile >> DataBuffer ; - Dz = atof(DataBuffer.c_str()) ; - Dz = Dz * mm ; - - D = G4ThreeVector(Dx, Dy, Dz); - G4cout << "X128 Y128 corner position : " << D << G4endl; - } - - - // Angle method - else if (DataBuffer.compare(0, 6, "THETA=") == 0) { - check_Theta = true; - ConfigFile >> DataBuffer ; - Theta = atof(DataBuffer.c_str()) ; - Theta = Theta * deg; - G4cout << "Theta: " << Theta / deg << G4endl; - } - - else if (DataBuffer.compare(0, 4, "PHI=") == 0) { - check_Phi = true; - ConfigFile >> DataBuffer ; - Phi = atof(DataBuffer.c_str()) ; - Phi = Phi * deg; - G4cout << "Phi: " << Phi / deg << G4endl; - } - - else if (DataBuffer.compare(0, 2, "R=") == 0) { - check_R = true; - ConfigFile >> DataBuffer ; - R = atof(DataBuffer.c_str()) ; - R = R * mm; - G4cout << "R: " << R / mm << G4endl; - } - - else if (DataBuffer.compare(0, 5, "BETA=") == 0) { -// check_beta = true; - ConfigFile >> DataBuffer ; - beta_u = atof(DataBuffer.c_str()) ; - beta_u = beta_u * deg ; - ConfigFile >> DataBuffer ; - beta_v = atof(DataBuffer.c_str()) ; - beta_v = beta_v * deg ; - ConfigFile >> DataBuffer ; - beta_w = atof(DataBuffer.c_str()) ; - beta_w = beta_w * deg ; - G4cout << "Beta: " << beta_u / deg << " " << beta_v / deg << " " << beta_w / deg << G4endl ; - } - - else if (DataBuffer.compare(0, 11, "FIRSTSTAGE=") == 0) { - check_FirstStage = true ; - ConfigFile >> DataBuffer; - FIRSTSTAGE = atof(DataBuffer.c_str()) ; - } - - else if (DataBuffer.compare(0, 12, "SECONDSTAGE=") == 0) { - check_SecondStage = true ; - ConfigFile >> DataBuffer; - SECONDSTAGE = atof(DataBuffer.c_str()) ; - } - - else if (DataBuffer.compare(0, 11, "THIRDSTAGE=") == 0) { - check_ThirdStage = true ; - ConfigFile >> DataBuffer; - THIRDSTAGE = atof(DataBuffer.c_str()) ; - } - - else if (DataBuffer.compare(0, 12, "FOURTHSTAGE=") == 0) { - check_FourthStage = true ; - ConfigFile >> DataBuffer; - FOURTHSTAGE = atof(DataBuffer.c_str()) ; - } - - else if (DataBuffer.compare(0, 11, "FIFTHSTAGE=") == 0) { - check_FifthStage = true ; - ConfigFile >> DataBuffer; - FIFTHSTAGE = atof(DataBuffer.c_str()) ; - } - - else if (DataBuffer.compare(0, 11, "SIXTHSTAGE=") == 0) { - check_SixthStage = true ; - ConfigFile >> DataBuffer; - SIXTHSTAGE = atof(DataBuffer.c_str()) ; - } - - else if (DataBuffer.compare(0, 4, "VIS=") == 0) { - checkVis = true ; - ConfigFile >> DataBuffer; - if (DataBuffer.compare(0, 3, "all") == 0) m_non_sensitive_part_visiualisation = true; - } - - else G4cout << "WARNING: Wrong Token, Hyde2TrackerTrapezoid1: Trapezoid1 Element not added" << G4endl; - - //Add The previously define telescope - //With position method - if ((check_A && check_B && check_C && check_D && check_FirstStage && check_SecondStage && check_ThirdStage && check_FourthStage && check_FifthStage && check_SixthStage && checkVis) && !(check_Theta && check_Phi && check_R)) { - - ReadingStatus = false ; - check_A = false ; - check_C = false ; - check_B = false ; - check_D = false ; - check_FirstStage = false ; - check_SecondStage = false ; - check_ThirdStage = false ; - check_FourthStage = false ; - check_FifthStage = false ; - check_SixthStage = false ; - checkVis = false ; - - AddModule(A , - B , - C , - D , - FIRSTSTAGE == 1 , - SECONDSTAGE == 1 , - THIRDSTAGE == 1 , - FOURTHSTAGE == 1 , - FIFTHSTAGE == 1 , - SIXTHSTAGE == 1); - } - - //with angle method - if ((check_Theta && check_Phi && check_R && check_FirstStage && check_SecondStage && check_ThirdStage && check_FourthStage && check_FifthStage && check_SixthStage && checkVis) && !(check_A && check_B && check_C && check_D)) { - ReadingStatus = false ; - check_Theta = false ; - check_Phi = false ; - check_R = false ; -// check_beta = false ; - check_FirstStage = false ; - check_SecondStage = false ; - check_ThirdStage = false ; - check_FourthStage = false ; - check_FifthStage = false ; - check_SixthStage = false ; - checkVis = false ; - - AddModule(R , - Theta , - Phi , - beta_u , - beta_v , - beta_w , - FIRSTSTAGE == 1 , - SECONDSTAGE == 1 , - THIRDSTAGE == 1 , - FOURTHSTAGE == 1 , - FIFTHSTAGE == 1 , - SIXTHSTAGE == 1); - } - - +void Hyde2TrackerTrapezoid1::ReadConfiguration(string Path) { + ifstream ConfigFile; + ConfigFile.open(Path.c_str()); + string LineBuffer; + string DataBuffer; + + // A:X1_Y1 --> X:1 Y:1 + // B:X128_Y1 --> X:128 Y:1 + // C:X1_Y128 --> X:1 Y:128 + // D:X128_Y128 --> X:128 Y:128 + + G4double Ax, Bx, Cx, Dx, Ay, By, Cy, Dy, Az, Bz, Cz, Dz; + G4ThreeVector A, B, C, D; + G4double Theta = 0, Phi = 0, R = 0, beta_u = 0, beta_v = 0, beta_w = 0; + int FIRSTSTAGE = 0, SECONDSTAGE = 0, THIRDSTAGE = 0, FOURTHSTAGE = 0, FIFTHSTAGE = 0, SIXTHSTAGE = 0; + + bool ReadingStatus = false; + + bool check_A = false; + bool check_C = false; + bool check_B = false; + bool check_D = false; + + bool check_Theta = false; + bool check_Phi = false; + bool check_R = false; + // bool check_beta = false ; + + bool check_FirstStage = false; + bool check_SecondStage = false; + bool check_ThirdStage = false; + bool check_FourthStage = false; + bool check_FifthStage = false; + bool check_SixthStage = false; + bool checkVis = false; + + while (!ConfigFile.eof()) { + getline(ConfigFile, LineBuffer); + if (LineBuffer.compare(0, 14, "HYD2Trapezoid1") == 0) { + G4cout << "///" << G4endl; + G4cout << "Trapezoid1 element found: " << G4endl; + ReadingStatus = true; + } + + while (ReadingStatus) { + + ConfigFile >> DataBuffer; + // Comment Line + if (DataBuffer.compare(0, 1, "%") == 0) { /*do nothing */ + ; } - } -} -// Construct detector and inialise sensitive part. -// Called After DetecorConstruction::AddDetector Method -void Hyde2TrackerTrapezoid1::ConstructDetector(G4LogicalVolume* world) -{ - G4RotationMatrix* MMrot = NULL; - G4ThreeVector MMpos = G4ThreeVector(0, 0, 0); - G4ThreeVector MMu = G4ThreeVector(0, 0, 0); - G4ThreeVector MMv = G4ThreeVector(0, 0, 0); - G4ThreeVector MMw = G4ThreeVector(0, 0, 0); - G4ThreeVector MMCenter = G4ThreeVector(0, 0, 0); - - bool FirstStage = true ; - bool SecondStage = true ; - bool ThirdStage = true ; - bool FourthStage = true ; - bool FifthStage = true ; - bool SixthStage = true ; - - G4int NumberOfModule = m_DefinitionType.size() ; - - for (G4int i = 0; i < NumberOfModule; i++) { - // By Point - if (m_DefinitionType[i]) { - // (u,v,w) unitary vector associated to trapezoidal referencial - // (u,v) // to silicon plan - // ------- - // / \ ^ - // / \ | v - // / \ | - // --------------- <------ - // u - // w perpendicular to (u,v) plan and pointing ThirdStage - G4cout << "XXXXXXXXXXXX Trapezoid1 " << i << " XXXXXXXXXXXXX" << G4endl; - MMu = m_X128_Y1[i] - m_X1_Y1[i]; - MMu = MMu.unit(); - G4cout << "MMu: " << MMu << G4endl; - - MMv = 0.5 * (m_X1_Y128[i] + m_X128_Y128[i] - m_X1_Y1[i] - m_X128_Y1[i]); - MMv = MMv.unit(); - G4cout << "MMv: " << MMv << G4endl; - - MMw = MMu.cross(MMv); - MMw = MMw.unit(); - G4cout << "MMw: " << MMw << G4endl; - - // Center of the module - MMCenter = (m_X1_Y1[i] + m_X1_Y128[i] + m_X128_Y1[i] + m_X128_Y128[i]) / 4; - - // Passage Matrix from Lab Referential to Module Referential - MMrot = new G4RotationMatrix(MMu, MMv, MMw); - // translation to place Module - MMpos = MMw * Length * 0.5 + MMCenter; + // Position method + else if (DataBuffer.compare(0, 6, "X1_Y1=") == 0) { + check_A = true; + ConfigFile >> DataBuffer; + Ax = atof(DataBuffer.c_str()); + Ax = Ax * mm; + ConfigFile >> DataBuffer; + Ay = atof(DataBuffer.c_str()); + Ay = Ay * mm; + ConfigFile >> DataBuffer; + Az = atof(DataBuffer.c_str()); + Az = Az * mm; + + A = G4ThreeVector(Ax, Ay, Az); + G4cout << "X1 Y1 corner position : " << A << G4endl; } - // By Angle - else { - G4double Theta = m_Theta[i]; - G4double Phi = m_Phi[i]; - - // (u,v,w) unitary vector associated to telescope referencial - // (u,v) // to silicon plan - // ------- - // / \ ^ - // / \ | v - // / \ | - // --------------- <------ - // u - // w perpendicular to (u,v) plan and pointing ThirdStage - // Phi is angle between X axis and projection in (X,Y) plan - // Theta is angle between position vector and z axis - G4double wX = m_R[i] * sin(Theta / rad) * cos(Phi / rad); - G4double wY = m_R[i] * sin(Theta / rad) * sin(Phi / rad); - G4double wZ = m_R[i] * cos(Theta / rad); - MMw = G4ThreeVector(wX, wY, wZ); - - // vector corresponding to the center of the module - MMCenter = MMw; - - // vector parallel to one axis of silicon plane - // in fact, this is vector u - G4double ii = cos(Theta / rad) * cos(Phi / rad); - G4double jj = cos(Theta / rad) * sin(Phi / rad); - G4double kk = -sin(Theta / rad); - G4ThreeVector Y = G4ThreeVector(ii, jj, kk); - - MMw = MMw.unit(); - MMv = MMw.cross(Y); - MMu = MMv.cross(MMw); - MMv = MMv.unit(); - MMu = MMu.unit(); - - G4cout << "XXXXXXXXXXXX Trapezoid1 " << i << " XXXXXXXXXXXXX" << G4endl; - G4cout << "MMu: " << MMu << G4endl; - G4cout << "MMv: " << MMv << G4endl; - G4cout << "MMw: " << MMw << G4endl; - - // Passage Matrix from Lab Referential to Telescope Referential - MMrot = new G4RotationMatrix(MMu, MMv, MMw); - // Telescope is rotate of Beta angle around MMv axis. - MMrot->rotate(m_beta_u[i], MMu); - MMrot->rotate(m_beta_v[i], MMv); - MMrot->rotate(m_beta_w[i], MMw); - // translation to place Telescope - MMpos = MMw * Length * 0.5 + MMCenter; + else if (DataBuffer.compare(0, 8, "X128_Y1=") == 0) { + check_B = true; + ConfigFile >> DataBuffer; + Bx = atof(DataBuffer.c_str()); + Bx = Bx * mm; + ConfigFile >> DataBuffer; + By = atof(DataBuffer.c_str()); + By = By * mm; + ConfigFile >> DataBuffer; + Bz = atof(DataBuffer.c_str()); + Bz = Bz * mm; + + B = G4ThreeVector(Bx, By, Bz); + G4cout << "X128 Y1 corner position : " << B << G4endl; } - FirstStage = m_wFirstStage[i]; - SecondStage = m_wSecondStage[i]; - ThirdStage = m_wThirdStage[i]; - FourthStage = m_wFourthStage[i]; - FifthStage = m_wFifthStage[i]; - SixthStage = m_wSixthStage[i]; + else if (DataBuffer.compare(0, 8, "X1_Y128=") == 0) { + check_C = true; + ConfigFile >> DataBuffer; + Cx = atof(DataBuffer.c_str()); + Cx = Cx * mm; + ConfigFile >> DataBuffer; + Cy = atof(DataBuffer.c_str()); + Cy = Cy * mm; + ConfigFile >> DataBuffer; + Cz = atof(DataBuffer.c_str()); + Cz = Cz * mm; + + C = G4ThreeVector(Cx, Cy, Cz); + G4cout << "X1 Y128 corner position : " << C << G4endl; + } - VolumeMaker(i + 1, MMpos, MMrot, FirstStage, SecondStage, ThirdStage, FourthStage, FifthStage, SixthStage, world); - } + else if (DataBuffer.compare(0, 10, "X128_Y128=") == 0) { + check_D = true; + ConfigFile >> DataBuffer; + Dx = atof(DataBuffer.c_str()); + Dx = Dx * mm; + ConfigFile >> DataBuffer; + Dy = atof(DataBuffer.c_str()); + Dy = Dy * mm; + ConfigFile >> DataBuffer; + Dz = atof(DataBuffer.c_str()); + Dz = Dz * mm; + + D = G4ThreeVector(Dx, Dy, Dz); + G4cout << "X128 Y128 corner position : " << D << G4endl; + } - delete MMrot; -} + // Angle method + else if (DataBuffer.compare(0, 6, "THETA=") == 0) { + check_Theta = true; + ConfigFile >> DataBuffer; + Theta = atof(DataBuffer.c_str()); + Theta = Theta * deg; + G4cout << "Theta: " << Theta / deg << G4endl; + } + else if (DataBuffer.compare(0, 4, "PHI=") == 0) { + check_Phi = true; + ConfigFile >> DataBuffer; + Phi = atof(DataBuffer.c_str()); + Phi = Phi * deg; + G4cout << "Phi: " << Phi / deg << G4endl; + } + else if (DataBuffer.compare(0, 2, "R=") == 0) { + check_R = true; + ConfigFile >> DataBuffer; + R = atof(DataBuffer.c_str()); + R = R * mm; + G4cout << "R: " << R / mm << G4endl; + } -// Connect the Hyde2TrackingData class to the output TTree -// of the simulation -void Hyde2TrackerTrapezoid1::InitializeRootOutput() -{ -} + else if (DataBuffer.compare(0, 5, "BETA=") == 0) { + // check_beta = true; + ConfigFile >> DataBuffer; + beta_u = atof(DataBuffer.c_str()); + beta_u = beta_u * deg; + ConfigFile >> DataBuffer; + beta_v = atof(DataBuffer.c_str()); + beta_v = beta_v * deg; + ConfigFile >> DataBuffer; + beta_w = atof(DataBuffer.c_str()); + beta_w = beta_w * deg; + G4cout << "Beta: " << beta_u / deg << " " << beta_v / deg << " " << beta_w / deg << G4endl; + } + else if (DataBuffer.compare(0, 11, "FIRSTSTAGE=") == 0) { + check_FirstStage = true; + ConfigFile >> DataBuffer; + FIRSTSTAGE = atof(DataBuffer.c_str()); + } + else if (DataBuffer.compare(0, 12, "SECONDSTAGE=") == 0) { + check_SecondStage = true; + ConfigFile >> DataBuffer; + SECONDSTAGE = atof(DataBuffer.c_str()); + } -// Set the TinteractionCoordinates object from NPS::VDetector to the present class -void Hyde2TrackerTrapezoid1::SetInterCoordPointer(TInteractionCoordinates* interCoord) -{ - ms_InterCoord = interCoord; + else if (DataBuffer.compare(0, 11, "THIRDSTAGE=") == 0) { + check_ThirdStage = true; + ConfigFile >> DataBuffer; + THIRDSTAGE = atof(DataBuffer.c_str()); + } + + else if (DataBuffer.compare(0, 12, "FOURTHSTAGE=") == 0) { + check_FourthStage = true; + ConfigFile >> DataBuffer; + FOURTHSTAGE = atof(DataBuffer.c_str()); + } + + else if (DataBuffer.compare(0, 11, "FIFTHSTAGE=") == 0) { + check_FifthStage = true; + ConfigFile >> DataBuffer; + FIFTHSTAGE = atof(DataBuffer.c_str()); + } + + else if (DataBuffer.compare(0, 11, "SIXTHSTAGE=") == 0) { + check_SixthStage = true; + ConfigFile >> DataBuffer; + SIXTHSTAGE = atof(DataBuffer.c_str()); + } + + else if (DataBuffer.compare(0, 4, "VIS=") == 0) { + checkVis = true; + ConfigFile >> DataBuffer; + if (DataBuffer.compare(0, 3, "all") == 0) + m_non_sensitive_part_visiualisation = true; + } + + else + G4cout << "WARNING: Wrong Token, Hyde2TrackerTrapezoid1: Trapezoid1 Element not added" << G4endl; + + // Add The previously define telescope + // With position method + if ((check_A && check_B && check_C && check_D && check_FirstStage && check_SecondStage && check_ThirdStage && + check_FourthStage && check_FifthStage && check_SixthStage && checkVis) && + !(check_Theta && check_Phi && check_R)) { + + ReadingStatus = false; + check_A = false; + check_C = false; + check_B = false; + check_D = false; + check_FirstStage = false; + check_SecondStage = false; + check_ThirdStage = false; + check_FourthStage = false; + check_FifthStage = false; + check_SixthStage = false; + checkVis = false; + + AddModule(A, B, C, D, FIRSTSTAGE == 1, SECONDSTAGE == 1, THIRDSTAGE == 1, FOURTHSTAGE == 1, FIFTHSTAGE == 1, + SIXTHSTAGE == 1); + } + + // with angle method + if ((check_Theta && check_Phi && check_R && check_FirstStage && check_SecondStage && check_ThirdStage && + check_FourthStage && check_FifthStage && check_SixthStage && checkVis) && + !(check_A && check_B && check_C && check_D)) { + ReadingStatus = false; + check_Theta = false; + check_Phi = false; + check_R = false; + // check_beta = false ; + check_FirstStage = false; + check_SecondStage = false; + check_ThirdStage = false; + check_FourthStage = false; + check_FifthStage = false; + check_SixthStage = false; + checkVis = false; + + AddModule(R, Theta, Phi, beta_u, beta_v, beta_w, FIRSTSTAGE == 1, SECONDSTAGE == 1, THIRDSTAGE == 1, + FOURTHSTAGE == 1, FIFTHSTAGE == 1, SIXTHSTAGE == 1); + } + } + } } +// Construct detector and inialise sensitive part. +// Called After DetecorConstruction::AddDetector Method +void Hyde2TrackerTrapezoid1::ConstructDetector(G4LogicalVolume* world) { + G4RotationMatrix* MMrot = NULL; + G4ThreeVector MMpos = G4ThreeVector(0, 0, 0); + G4ThreeVector MMu = G4ThreeVector(0, 0, 0); + G4ThreeVector MMv = G4ThreeVector(0, 0, 0); + G4ThreeVector MMw = G4ThreeVector(0, 0, 0); + G4ThreeVector MMCenter = G4ThreeVector(0, 0, 0); + + bool FirstStage = true; + bool SecondStage = true; + bool ThirdStage = true; + bool FourthStage = true; + bool FifthStage = true; + bool SixthStage = true; + + G4int NumberOfModule = m_DefinitionType.size(); + + for (G4int i = 0; i < NumberOfModule; i++) { + // By Point + if (m_DefinitionType[i]) { + // (u,v,w) unitary vector associated to trapezoidal referencial + // (u,v) // to silicon plan + // ------- + // / \ ^ + // / \ | v + // / \ | + // --------------- <------ + // u + // w perpendicular to (u,v) plan and pointing ThirdStage + G4cout << "XXXXXXXXXXXX Trapezoid1 " << i << " XXXXXXXXXXXXX" << G4endl; + MMu = m_X128_Y1[i] - m_X1_Y1[i]; + MMu = MMu.unit(); + G4cout << "MMu: " << MMu << G4endl; + + MMv = 0.5 * (m_X1_Y128[i] + m_X128_Y128[i] - m_X1_Y1[i] - m_X128_Y1[i]); + MMv = MMv.unit(); + G4cout << "MMv: " << MMv << G4endl; + + MMw = MMu.cross(MMv); + MMw = MMw.unit(); + G4cout << "MMw: " << MMw << G4endl; + + // Center of the module + MMCenter = (m_X1_Y1[i] + m_X1_Y128[i] + m_X128_Y1[i] + m_X128_Y128[i]) / 4; + + // Passage Matrix from Lab Referential to Module Referential + MMrot = new G4RotationMatrix(MMu, MMv, MMw); + // translation to place Module + MMpos = MMw * Length * 0.5 + MMCenter; + } + + // By Angle + else { + G4double Theta = m_Theta[i]; + G4double Phi = m_Phi[i]; + + // (u,v,w) unitary vector associated to telescope referencial + // (u,v) // to silicon plan + // ------- + // / \ ^ + // / \ | v + // / \ | + // --------------- <------ + // u + // w perpendicular to (u,v) plan and pointing ThirdStage + // Phi is angle between X axis and projection in (X,Y) plan + // Theta is angle between position vector and z axis + G4double wX = m_R[i] * sin(Theta / rad) * cos(Phi / rad); + G4double wY = m_R[i] * sin(Theta / rad) * sin(Phi / rad); + G4double wZ = m_R[i] * cos(Theta / rad); + MMw = G4ThreeVector(wX, wY, wZ); + + // vector corresponding to the center of the module + MMCenter = MMw; + + // vector parallel to one axis of silicon plane + // in fact, this is vector u + G4double ii = cos(Theta / rad) * cos(Phi / rad); + G4double jj = cos(Theta / rad) * sin(Phi / rad); + G4double kk = -sin(Theta / rad); + G4ThreeVector Y = G4ThreeVector(ii, jj, kk); + + MMw = MMw.unit(); + MMv = MMw.cross(Y); + MMu = MMv.cross(MMw); + MMv = MMv.unit(); + MMu = MMu.unit(); + + G4cout << "XXXXXXXXXXXX Trapezoid1 " << i << " XXXXXXXXXXXXX" << G4endl; + G4cout << "MMu: " << MMu << G4endl; + G4cout << "MMv: " << MMv << G4endl; + G4cout << "MMw: " << MMw << G4endl; + + // Passage Matrix from Lab Referential to Telescope Referential + MMrot = new G4RotationMatrix(MMu, MMv, MMw); + // Telescope is rotate of Beta angle around MMv axis. + MMrot->rotate(m_beta_u[i], MMu); + MMrot->rotate(m_beta_v[i], MMv); + MMrot->rotate(m_beta_w[i], MMw); + // translation to place Telescope + MMpos = MMw * Length * 0.5 + MMCenter; + } + + FirstStage = m_wFirstStage[i]; + SecondStage = m_wSecondStage[i]; + ThirdStage = m_wThirdStage[i]; + FourthStage = m_wFourthStage[i]; + FifthStage = m_wFifthStage[i]; + SixthStage = m_wSixthStage[i]; + + VolumeMaker(i + 1, MMpos, MMrot, FirstStage, SecondStage, ThirdStage, FourthStage, FifthStage, SixthStage, world); + } + + delete MMrot; +} +// Connect the Hyde2TrackingData class to the output TTree +// of the simulation +void Hyde2TrackerTrapezoid1::InitializeRootOutput() {} + +// Set the TinteractionCoordinates object from NPS::VDetector to the present class +void Hyde2TrackerTrapezoid1::SetInterCoordPointer(TInteractionCoordinates* interCoord) { ms_InterCoord = interCoord; } // Read sensitive part and fill the Root tree. // Called at in the EventAction::EndOfEventAvtion -void Hyde2TrackerTrapezoid1::ReadSensitive(const G4Event* event) -{ -////////////////////////////////////////////////////////////////////////////////////// -//////////////////////// Used to Read Event Map of detector ////////////////////////// -////////////////////////////////////////////////////////////////////////////////////// - // First Stage - std::map<G4int, G4int*>::iterator DetectorNumber_itr; - std::map<G4int, G4double*>::iterator Energy_itr; - std::map<G4int, G4double*>::iterator Time_itr; - std::map<G4int, G4double*>::iterator X_itr; - std::map<G4int, G4double*>::iterator Y_itr; - std::map<G4int, G4double*>::iterator Pos_X_itr; - std::map<G4int, G4double*>::iterator Pos_Y_itr; - std::map<G4int, G4double*>::iterator Pos_Z_itr; - std::map<G4int, G4double*>::iterator Ang_Theta_itr; - std::map<G4int, G4double*>::iterator Ang_Phi_itr; - - G4THitsMap<G4int>* DetectorNumberHitMap; - G4THitsMap<G4double>* EnergyHitMap; - G4THitsMap<G4double>* TimeHitMap; - G4THitsMap<G4double>* XHitMap; - G4THitsMap<G4double>* YHitMap; - G4THitsMap<G4double>* PosXHitMap; - G4THitsMap<G4double>* PosYHitMap; - G4THitsMap<G4double>* PosZHitMap; - G4THitsMap<G4double>* AngThetaHitMap; - G4THitsMap<G4double>* AngPhiHitMap; - - // NULL pointer are given to avoid warning at compilation - // Second Stage - std::map<G4int, G4double*>::iterator SecondStageEnergy_itr; - G4THitsMap<G4double>* SecondStageEnergyHitMap = NULL; - // Third Stage - std::map<G4int, G4double*>::iterator ThirdStageEnergy_itr; - G4THitsMap<G4double>* ThirdStageEnergyHitMap = NULL; - - // Fourth Stage - std::map<G4int, G4double*>::iterator FourthStageEnergy_itr; - G4THitsMap<G4double>* FourthStageEnergyHitMap = NULL; - - // Fifth Stage - std::map<G4int, G4double*>::iterator FifthStageEnergy_itr; - G4THitsMap<G4double>* FifthStageEnergyHitMap = NULL; - - // Sixth Stage - std::map<G4int, G4double*>::iterator SixthStageEnergy_itr; - G4THitsMap<G4double>* SixthStageEnergyHitMap = NULL; - - // Read the Scorer associated to the first Stage - //Detector Number - G4int StripDetCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid1/DetectorNumber") ; - DetectorNumberHitMap = (G4THitsMap<G4int>*)(event->GetHCofThisEvent()->GetHC(StripDetCollectionID)) ; - DetectorNumber_itr = DetectorNumberHitMap->GetMap()->begin() ; - - //Energy - G4int StripEnergyCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid1/StripEnergy") ; - EnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripEnergyCollectionID)) ; - Energy_itr = EnergyHitMap->GetMap()->begin() ; - - //Time of Flight - G4int StripTimeCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid1/StripTime") ; - TimeHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripTimeCollectionID)) ; - Time_itr = TimeHitMap->GetMap()->begin() ; - - //Strip Number X - G4int StripXCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid1/StripNumberX") ; - XHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripXCollectionID)) ; - X_itr = XHitMap->GetMap()->begin() ; - - //Strip Number Y - G4int StripYCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid1/StripNumberY") ; - YHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripYCollectionID)) ; - Y_itr = YHitMap->GetMap()->begin() ; - - //Interaction Coordinate X - G4int InterCoordXCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid1/InterCoordX") ; - PosXHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordXCollectionID)) ; - Pos_X_itr = PosXHitMap->GetMap()->begin() ; - - //Interaction Coordinate Y - G4int InterCoordYCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid1/InterCoordY") ; - PosYHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordYCollectionID)) ; - Pos_Y_itr = PosYHitMap->GetMap()->begin() ; - - //Interaction Coordinate Z - G4int InterCoordZCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid1/InterCoordZ") ; - PosZHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordZCollectionID)) ; - Pos_Z_itr = PosXHitMap->GetMap()->begin() ; - - //Interaction Coordinate Angle Theta - G4int InterCoordAngThetaCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid1/InterCoordAngTheta") ; - AngThetaHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordAngThetaCollectionID)) ; - Ang_Theta_itr = AngThetaHitMap->GetMap()->begin() ; - - //Interaction Coordinate Angle Phi - G4int InterCoordAngPhiCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid1/InterCoordAngPhi") ; - AngPhiHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordAngPhiCollectionID)) ; - Ang_Phi_itr = AngPhiHitMap->GetMap()->begin() ; - - // Read the Scorer associated to the Second and Third Stage - // Energy second stage - G4int SecondStageEnergyCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("SecondStageScorerHYD2Trapezoid1/SecondStageEnergy") ; - SecondStageEnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(SecondStageEnergyCollectionID)) ; - SecondStageEnergy_itr = SecondStageEnergyHitMap->GetMap()->begin() ; - // Energy third stage - G4int ThirdStageEnergyCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("ThirdStageScorerHYD2Trapezoid1/ThirdStageEnergy") ; - ThirdStageEnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(ThirdStageEnergyCollectionID)) ; - ThirdStageEnergy_itr = ThirdStageEnergyHitMap->GetMap()->begin() ; - // Energy Fourth stage - G4int FourthStageEnergyCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FourthStageScorerHYD2Trapezoid1/FourthStageEnergy") ; - FourthStageEnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(FourthStageEnergyCollectionID)) ; - FourthStageEnergy_itr = FourthStageEnergyHitMap->GetMap()->begin() ; - // Energy Fifth stage - G4int FifthStageEnergyCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FifthStageScorerHYD2Trapezoid1/FifthStageEnergy") ; - FifthStageEnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(FifthStageEnergyCollectionID)) ; - FifthStageEnergy_itr = FifthStageEnergyHitMap->GetMap()->begin() ; - // Energy Sixth stage - G4int SixthStageEnergyCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("SixthStageScorerHYD2Trapezoid1/SixthStageEnergy") ; - SixthStageEnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(SixthStageEnergyCollectionID)) ; - SixthStageEnergy_itr = SixthStageEnergyHitMap->GetMap()->begin() ; - - // Check the size of different map - G4int sizeN = DetectorNumberHitMap->entries(); - G4int sizeE = EnergyHitMap->entries(); - G4int sizeT = TimeHitMap->entries(); - G4int sizeX = XHitMap->entries(); - G4int sizeY = YHitMap->entries(); - - if (sizeE != sizeT || sizeT != sizeX || sizeX != sizeY) { - G4cout << "No match size Si Event Map: sE:" - << sizeE << " sT:" << sizeT << " sX:" << sizeX << " sY:" << sizeY << G4endl ; - return; +void Hyde2TrackerTrapezoid1::ReadSensitive(const G4Event* event) { + ////////////////////////////////////////////////////////////////////////////////////// + //////////////////////// Used to Read Event Map of detector ////////////////////////// + ////////////////////////////////////////////////////////////////////////////////////// + // First Stage + std::map<G4int, G4int*>::iterator DetectorNumber_itr; + std::map<G4int, G4double*>::iterator Energy_itr; + std::map<G4int, G4double*>::iterator Time_itr; + std::map<G4int, G4double*>::iterator X_itr; + std::map<G4int, G4double*>::iterator Y_itr; + std::map<G4int, G4double*>::iterator Pos_X_itr; + std::map<G4int, G4double*>::iterator Pos_Y_itr; + std::map<G4int, G4double*>::iterator Pos_Z_itr; + std::map<G4int, G4double*>::iterator Ang_Theta_itr; + std::map<G4int, G4double*>::iterator Ang_Phi_itr; + + G4THitsMap<G4int>* DetectorNumberHitMap; + G4THitsMap<G4double>* EnergyHitMap; + G4THitsMap<G4double>* TimeHitMap; + G4THitsMap<G4double>* XHitMap; + G4THitsMap<G4double>* YHitMap; + G4THitsMap<G4double>* PosXHitMap; + G4THitsMap<G4double>* PosYHitMap; + G4THitsMap<G4double>* PosZHitMap; + G4THitsMap<G4double>* AngThetaHitMap; + G4THitsMap<G4double>* AngPhiHitMap; + + // NULL pointer are given to avoid warning at compilation + // Second Stage + std::map<G4int, G4double*>::iterator SecondStageEnergy_itr; + G4THitsMap<G4double>* SecondStageEnergyHitMap = NULL; + // Third Stage + std::map<G4int, G4double*>::iterator ThirdStageEnergy_itr; + G4THitsMap<G4double>* ThirdStageEnergyHitMap = NULL; + + // Fourth Stage + std::map<G4int, G4double*>::iterator FourthStageEnergy_itr; + G4THitsMap<G4double>* FourthStageEnergyHitMap = NULL; + + // Fifth Stage + std::map<G4int, G4double*>::iterator FifthStageEnergy_itr; + G4THitsMap<G4double>* FifthStageEnergyHitMap = NULL; + + // Sixth Stage + std::map<G4int, G4double*>::iterator SixthStageEnergy_itr; + G4THitsMap<G4double>* SixthStageEnergyHitMap = NULL; + + // Read the Scorer associated to the first Stage + // Detector Number + G4int StripDetCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid1/DetectorNumber"); + DetectorNumberHitMap = (G4THitsMap<G4int>*)(event->GetHCofThisEvent()->GetHC(StripDetCollectionID)); + DetectorNumber_itr = DetectorNumberHitMap->GetMap()->begin(); + + // Energy + G4int StripEnergyCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid1/StripEnergy"); + EnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripEnergyCollectionID)); + Energy_itr = EnergyHitMap->GetMap()->begin(); + + // Time of Flight + G4int StripTimeCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid1/StripTime"); + TimeHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripTimeCollectionID)); + Time_itr = TimeHitMap->GetMap()->begin(); + + // Strip Number X + G4int StripXCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid1/StripNumberX"); + XHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripXCollectionID)); + X_itr = XHitMap->GetMap()->begin(); + + // Strip Number Y + G4int StripYCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid1/StripNumberY"); + YHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripYCollectionID)); + Y_itr = YHitMap->GetMap()->begin(); + + // Interaction Coordinate X + G4int InterCoordXCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid1/InterCoordX"); + PosXHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordXCollectionID)); + Pos_X_itr = PosXHitMap->GetMap()->begin(); + + // Interaction Coordinate Y + G4int InterCoordYCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid1/InterCoordY"); + PosYHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordYCollectionID)); + Pos_Y_itr = PosYHitMap->GetMap()->begin(); + + // Interaction Coordinate Z + G4int InterCoordZCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid1/InterCoordZ"); + PosZHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordZCollectionID)); + Pos_Z_itr = PosXHitMap->GetMap()->begin(); + + // Interaction Coordinate Angle Theta + G4int InterCoordAngThetaCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid1/InterCoordAngTheta"); + AngThetaHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordAngThetaCollectionID)); + Ang_Theta_itr = AngThetaHitMap->GetMap()->begin(); + + // Interaction Coordinate Angle Phi + G4int InterCoordAngPhiCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid1/InterCoordAngPhi"); + AngPhiHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordAngPhiCollectionID)); + Ang_Phi_itr = AngPhiHitMap->GetMap()->begin(); + + // Read the Scorer associated to the Second and Third Stage + // Energy second stage + G4int SecondStageEnergyCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("SecondStageScorerHYD2Trapezoid1/SecondStageEnergy"); + SecondStageEnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(SecondStageEnergyCollectionID)); + SecondStageEnergy_itr = SecondStageEnergyHitMap->GetMap()->begin(); + // Energy third stage + G4int ThirdStageEnergyCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("ThirdStageScorerHYD2Trapezoid1/ThirdStageEnergy"); + ThirdStageEnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(ThirdStageEnergyCollectionID)); + ThirdStageEnergy_itr = ThirdStageEnergyHitMap->GetMap()->begin(); + // Energy Fourth stage + G4int FourthStageEnergyCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("FourthStageScorerHYD2Trapezoid1/FourthStageEnergy"); + FourthStageEnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(FourthStageEnergyCollectionID)); + FourthStageEnergy_itr = FourthStageEnergyHitMap->GetMap()->begin(); + // Energy Fifth stage + G4int FifthStageEnergyCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("FifthStageScorerHYD2Trapezoid1/FifthStageEnergy"); + FifthStageEnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(FifthStageEnergyCollectionID)); + FifthStageEnergy_itr = FifthStageEnergyHitMap->GetMap()->begin(); + // Energy Sixth stage + G4int SixthStageEnergyCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("SixthStageScorerHYD2Trapezoid1/SixthStageEnergy"); + SixthStageEnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(SixthStageEnergyCollectionID)); + SixthStageEnergy_itr = SixthStageEnergyHitMap->GetMap()->begin(); + + // Check the size of different map + G4int sizeN = DetectorNumberHitMap->entries(); + G4int sizeE = EnergyHitMap->entries(); + G4int sizeT = TimeHitMap->entries(); + G4int sizeX = XHitMap->entries(); + G4int sizeY = YHitMap->entries(); + + if (sizeE != sizeT || sizeT != sizeX || sizeX != sizeY) { + G4cout << "No match size Si Event Map: sE:" << sizeE << " sT:" << sizeT << " sX:" << sizeX << " sY:" << sizeY + << G4endl; + return; + } + + // Loop on FirstStage number + for (G4int l = 0; l < sizeN; l++) { + G4double N = *(DetectorNumber_itr->second); + G4int NTrackID = DetectorNumber_itr->first - N; + + if (N > 0) { + // Fill detector number + ms_Event->SetHYD2TrkFirstStageFrontEDetectorNbr(m_index["Trapezoid1"] + N); + ms_Event->SetHYD2TrkFirstStageFrontTDetectorNbr(m_index["Trapezoid1"] + N); + ms_Event->SetHYD2TrkFirstStageBackEDetectorNbr(m_index["Trapezoid1"] + N); + ms_Event->SetHYD2TrkFirstStageBackTDetectorNbr(m_index["Trapezoid1"] + N); + + // Energy + for (G4int ll = 0; ll < sizeE; ll++) { + G4int ETrackID = Energy_itr->first - N; + G4double E = *(Energy_itr->second); + if (ETrackID == NTrackID) { + ms_Event->SetHYD2TrkFirstStageFrontEEnergy(RandGauss::shoot(E, ResoFirstStage)); + ms_Event->SetHYD2TrkFirstStageBackEEnergy(RandGauss::shoot(E, ResoFirstStage)); + } + Energy_itr++; } - // Loop on FirstStage number - for (G4int l = 0; l < sizeN; l++) { - G4double N = *(DetectorNumber_itr->second); - G4int NTrackID = DetectorNumber_itr->first - N; - - if (N > 0) { - // Fill detector number - ms_Event->SetHYD2TrkFirstStageFrontEDetectorNbr(m_index["Trapezoid1"] + N); - ms_Event->SetHYD2TrkFirstStageFrontTDetectorNbr(m_index["Trapezoid1"] + N); - ms_Event->SetHYD2TrkFirstStageBackEDetectorNbr(m_index["Trapezoid1"] + N); - ms_Event->SetHYD2TrkFirstStageBackTDetectorNbr(m_index["Trapezoid1"] + N); - - // Energy - for (G4int ll = 0 ; ll < sizeE ; ll++) { - G4int ETrackID = Energy_itr->first - N; - G4double E = *(Energy_itr->second); - if (ETrackID == NTrackID) { - ms_Event->SetHYD2TrkFirstStageFrontEEnergy(RandGauss::shoot(E, ResoFirstStage)); - ms_Event->SetHYD2TrkFirstStageBackEEnergy(RandGauss::shoot(E, ResoFirstStage)); - } - 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) { - T = RandGauss::shoot(T, ResoTimePPAC) ; - ms_Event->SetHYD2TrkFirstStageFrontTTime(RandGauss::shoot(T, ResoTimeHyd2)) ; - ms_Event->SetHYD2TrkFirstStageBackTTime(RandGauss::shoot(T, ResoTimeHyd2)) ; - } - Time_itr++; - } - - // X - X_itr = XHitMap->GetMap()->begin(); - for (G4int h = 0 ; h < sizeX ; h++) { - G4int XTrackID = X_itr->first - N; - G4double X = *(X_itr->second); - if (XTrackID == NTrackID) { - ms_Event->SetHYD2TrkFirstStageFrontEStripNbr(X); - ms_Event->SetHYD2TrkFirstStageFrontTStripNbr(X); - } - - X_itr++; - } - - // Y - Y_itr = YHitMap->GetMap()->begin() ; - for (G4int h = 0 ; h < sizeY ; h++) { - G4int YTrackID = Y_itr->first - N; - G4double Y = *(Y_itr->second); - if (YTrackID == NTrackID) { - ms_Event->SetHYD2TrkFirstStageBackEStripNbr(Y); - ms_Event->SetHYD2TrkFirstStageBackTStripNbr(Y); - } - - Y_itr++; - } - - // Pos X - Pos_X_itr = PosXHitMap->GetMap()->begin(); - for (unsigned int h = 0; h < PosXHitMap->entries(); h++) { - G4int PosXTrackID = Pos_X_itr->first - N ; - G4double PosX = *(Pos_X_itr->second) ; - if (PosXTrackID == NTrackID) { - ms_InterCoord->SetDetectedPositionX(PosX) ; - } - Pos_X_itr++; - } - - // Pos Y - Pos_Y_itr = PosYHitMap->GetMap()->begin(); - for (unsigned int h = 0; h < PosYHitMap->entries(); h++) { - G4int PosYTrackID = Pos_Y_itr->first - N ; - G4double PosY = *(Pos_Y_itr->second) ; - if (PosYTrackID == NTrackID) { - ms_InterCoord->SetDetectedPositionY(PosY) ; - } - Pos_Y_itr++; - } - - // Pos Z - Pos_Z_itr = PosZHitMap->GetMap()->begin(); - for (unsigned int h = 0; h < PosZHitMap->entries(); h++) { - G4int PosZTrackID = Pos_Z_itr->first - N ; - G4double PosZ = *(Pos_Z_itr->second) ; - if (PosZTrackID == NTrackID) { - ms_InterCoord->SetDetectedPositionZ(PosZ) ; - } - Pos_Z_itr++; - } - - // Angle Theta - Ang_Theta_itr = AngThetaHitMap->GetMap()->begin(); - for (unsigned int h = 0; h < AngThetaHitMap->entries(); h++) { - G4int AngThetaTrackID = Ang_Theta_itr->first - N ; - G4double AngTheta = *(Ang_Theta_itr->second) ; - if (AngThetaTrackID == NTrackID) { - ms_InterCoord->SetDetectedAngleTheta(AngTheta) ; - } - Ang_Theta_itr++; - } - - // Angle Phi - Ang_Phi_itr = AngPhiHitMap->GetMap()->begin(); - for (unsigned int h = 0; h < AngPhiHitMap->entries(); h++) { - G4int AngPhiTrackID = Ang_Phi_itr->first - N ; - G4double AngPhi = *(Ang_Phi_itr->second) ; - if (AngPhiTrackID == NTrackID) { - ms_InterCoord->SetDetectedAnglePhi(AngPhi) ; - } - Ang_Phi_itr++; - } - - // Second Stage - SecondStageEnergy_itr = SecondStageEnergyHitMap->GetMap()->begin() ; - for (unsigned int h = 0 ; h < SecondStageEnergyHitMap->entries() ; h++) { - G4int SecondStageEnergyTrackID = SecondStageEnergy_itr->first - N; - G4double SecondStageEnergy = *(SecondStageEnergy_itr->second); - - if (SecondStageEnergyTrackID == NTrackID) { - ms_Event->SetHYD2TrkSecondStageEEnergy(RandGauss::shoot(SecondStageEnergy, ResoSecondStage)); - ms_Event->SetHYD2TrkSecondStageEPadNbr(1); - ms_Event->SetHYD2TrkSecondStageTPadNbr(1); - ms_Event->SetHYD2TrkSecondStageTTime(1); - ms_Event->SetHYD2TrkSecondStageTDetectorNbr(m_index["Trapezoid1"] + N); - ms_Event->SetHYD2TrkSecondStageEDetectorNbr(m_index["Trapezoid1"] + N); - } - - SecondStageEnergy_itr++; - } - - // Third Stage - ThirdStageEnergy_itr = ThirdStageEnergyHitMap->GetMap()->begin() ; - for (unsigned int h = 0 ; h < ThirdStageEnergyHitMap->entries() ; h++) { - G4int ThirdStageEnergyTrackID = ThirdStageEnergy_itr->first - N; - G4double ThirdStageEnergy = *(ThirdStageEnergy_itr->second); - - if (ThirdStageEnergyTrackID == NTrackID) { - ms_Event->SetHYD2TrkThirdStageEEnergy(RandGauss::shoot(ThirdStageEnergy, ResoThirdStage)); - ms_Event->SetHYD2TrkThirdStageEPadNbr(1); - ms_Event->SetHYD2TrkThirdStageTPadNbr(1); - ms_Event->SetHYD2TrkThirdStageTTime(1); - ms_Event->SetHYD2TrkThirdStageTDetectorNbr(m_index["Trapezoid1"] + N); - ms_Event->SetHYD2TrkThirdStageEDetectorNbr(m_index["Trapezoid1"] + N); - } - - ThirdStageEnergy_itr++; - } - - // Fourth Stage - FourthStageEnergy_itr = FourthStageEnergyHitMap->GetMap()->begin() ; - for (unsigned int h = 0 ; h < FourthStageEnergyHitMap->entries() ; h++) { - G4int FourthStageEnergyTrackID = FourthStageEnergy_itr->first - N; - G4double FourthStageEnergy = *(FourthStageEnergy_itr->second); - - if (FourthStageEnergyTrackID == NTrackID) { - ms_Event->SetHYD2TrkFourthStageEEnergy(RandGauss::shoot(FourthStageEnergy, ResoFourthStage)); - ms_Event->SetHYD2TrkFourthStageEPadNbr(1); - ms_Event->SetHYD2TrkFourthStageTPadNbr(1); - ms_Event->SetHYD2TrkFourthStageTTime(1); - ms_Event->SetHYD2TrkFourthStageTDetectorNbr(m_index["Trapezoid1"] + N); - ms_Event->SetHYD2TrkFourthStageEDetectorNbr(m_index["Trapezoid1"] + N); - } - - FourthStageEnergy_itr++; - } - - // Fifth Stage - FifthStageEnergy_itr = FifthStageEnergyHitMap->GetMap()->begin() ; - for (unsigned int h = 0 ; h < FifthStageEnergyHitMap->entries() ; h++) { - G4int FifthStageEnergyTrackID = FifthStageEnergy_itr->first - N; - G4double FifthStageEnergy = *(FifthStageEnergy_itr->second); - - if (FifthStageEnergyTrackID == NTrackID) { - ms_Event->SetHYD2TrkFifthStageEEnergy(RandGauss::shoot(FifthStageEnergy, ResoFifthStage)); - ms_Event->SetHYD2TrkFifthStageEPadNbr(1); - ms_Event->SetHYD2TrkFifthStageTPadNbr(1); - ms_Event->SetHYD2TrkFifthStageTTime(1); - ms_Event->SetHYD2TrkFifthStageTDetectorNbr(m_index["Trapezoid1"] + N); - ms_Event->SetHYD2TrkFifthStageEDetectorNbr(m_index["Trapezoid1"] + N); - } - - FifthStageEnergy_itr++; - } - - // Sixth Stage - SixthStageEnergy_itr = SixthStageEnergyHitMap->GetMap()->begin() ; - for (unsigned int h = 0 ; h < SixthStageEnergyHitMap->entries() ; h++) { - G4int SixthStageEnergyTrackID = SixthStageEnergy_itr->first - N; - G4double SixthStageEnergy = *(SixthStageEnergy_itr->second); - - if (SixthStageEnergyTrackID == NTrackID) { - ms_Event->SetHYD2TrkSixthStageEEnergy(RandGauss::shoot(SixthStageEnergy, ResoSixthStage)); - ms_Event->SetHYD2TrkSixthStageEPadNbr(1); - ms_Event->SetHYD2TrkSixthStageTPadNbr(1); - ms_Event->SetHYD2TrkSixthStageTTime(1); - ms_Event->SetHYD2TrkSixthStageTDetectorNbr(m_index["Trapezoid1"] + N); - ms_Event->SetHYD2TrkSixthStageEDetectorNbr(m_index["Trapezoid1"] + N); - } - - SixthStageEnergy_itr++; - } - - DetectorNumber_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) { + T = RandGauss::shoot(T, ResoTimePPAC); + ms_Event->SetHYD2TrkFirstStageFrontTTime(RandGauss::shoot(T, ResoTimeHyd2)); + ms_Event->SetHYD2TrkFirstStageBackTTime(RandGauss::shoot(T, ResoTimeHyd2)); + } + Time_itr++; } - // clear map for next event - DetectorNumberHitMap ->clear(); - EnergyHitMap ->clear(); - TimeHitMap ->clear(); - XHitMap ->clear(); - YHitMap ->clear(); - PosXHitMap ->clear(); - PosYHitMap ->clear(); - PosZHitMap ->clear(); - AngThetaHitMap ->clear(); - AngPhiHitMap ->clear(); - SecondStageEnergyHitMap ->clear(); - ThirdStageEnergyHitMap ->clear(); - FourthStageEnergyHitMap ->clear(); - FifthStageEnergyHitMap ->clear(); - SixthStageEnergyHitMap ->clear(); - } -} + // X + X_itr = XHitMap->GetMap()->begin(); + for (G4int h = 0; h < sizeX; h++) { + G4int XTrackID = X_itr->first - N; + G4double X = *(X_itr->second); + if (XTrackID == NTrackID) { + ms_Event->SetHYD2TrkFirstStageFrontEStripNbr(X); + ms_Event->SetHYD2TrkFirstStageFrontTStripNbr(X); + } + + X_itr++; + } + // Y + Y_itr = YHitMap->GetMap()->begin(); + for (G4int h = 0; h < sizeY; h++) { + G4int YTrackID = Y_itr->first - N; + G4double Y = *(Y_itr->second); + if (YTrackID == NTrackID) { + ms_Event->SetHYD2TrkFirstStageBackEStripNbr(Y); + ms_Event->SetHYD2TrkFirstStageBackTStripNbr(Y); + } + + Y_itr++; + } + + // Pos X + Pos_X_itr = PosXHitMap->GetMap()->begin(); + for (unsigned int h = 0; h < PosXHitMap->entries(); h++) { + G4int PosXTrackID = Pos_X_itr->first - N; + G4double PosX = *(Pos_X_itr->second); + if (PosXTrackID == NTrackID) { + ms_InterCoord->SetDetectedPositionX(PosX); + } + Pos_X_itr++; + } + + // Pos Y + Pos_Y_itr = PosYHitMap->GetMap()->begin(); + for (unsigned int h = 0; h < PosYHitMap->entries(); h++) { + G4int PosYTrackID = Pos_Y_itr->first - N; + G4double PosY = *(Pos_Y_itr->second); + if (PosYTrackID == NTrackID) { + ms_InterCoord->SetDetectedPositionY(PosY); + } + Pos_Y_itr++; + } + + // Pos Z + Pos_Z_itr = PosZHitMap->GetMap()->begin(); + for (unsigned int h = 0; h < PosZHitMap->entries(); h++) { + G4int PosZTrackID = Pos_Z_itr->first - N; + G4double PosZ = *(Pos_Z_itr->second); + if (PosZTrackID == NTrackID) { + ms_InterCoord->SetDetectedPositionZ(PosZ); + } + Pos_Z_itr++; + } + + // Angle Theta + Ang_Theta_itr = AngThetaHitMap->GetMap()->begin(); + for (unsigned int h = 0; h < AngThetaHitMap->entries(); h++) { + G4int AngThetaTrackID = Ang_Theta_itr->first - N; + G4double AngTheta = *(Ang_Theta_itr->second); + if (AngThetaTrackID == NTrackID) { + ms_InterCoord->SetDetectedAngleTheta(AngTheta); + } + Ang_Theta_itr++; + } + + // Angle Phi + Ang_Phi_itr = AngPhiHitMap->GetMap()->begin(); + for (unsigned int h = 0; h < AngPhiHitMap->entries(); h++) { + G4int AngPhiTrackID = Ang_Phi_itr->first - N; + G4double AngPhi = *(Ang_Phi_itr->second); + if (AngPhiTrackID == NTrackID) { + ms_InterCoord->SetDetectedAnglePhi(AngPhi); + } + Ang_Phi_itr++; + } + // Second Stage + SecondStageEnergy_itr = SecondStageEnergyHitMap->GetMap()->begin(); + for (unsigned int h = 0; h < SecondStageEnergyHitMap->entries(); h++) { + G4int SecondStageEnergyTrackID = SecondStageEnergy_itr->first - N; + G4double SecondStageEnergy = *(SecondStageEnergy_itr->second); + + if (SecondStageEnergyTrackID == NTrackID) { + ms_Event->SetHYD2TrkSecondStageEEnergy(RandGauss::shoot(SecondStageEnergy, ResoSecondStage)); + ms_Event->SetHYD2TrkSecondStageEPadNbr(1); + ms_Event->SetHYD2TrkSecondStageTPadNbr(1); + ms_Event->SetHYD2TrkSecondStageTTime(1); + ms_Event->SetHYD2TrkSecondStageTDetectorNbr(m_index["Trapezoid1"] + N); + ms_Event->SetHYD2TrkSecondStageEDetectorNbr(m_index["Trapezoid1"] + N); + } + + SecondStageEnergy_itr++; + } + + // Third Stage + ThirdStageEnergy_itr = ThirdStageEnergyHitMap->GetMap()->begin(); + for (unsigned int h = 0; h < ThirdStageEnergyHitMap->entries(); h++) { + G4int ThirdStageEnergyTrackID = ThirdStageEnergy_itr->first - N; + G4double ThirdStageEnergy = *(ThirdStageEnergy_itr->second); + + if (ThirdStageEnergyTrackID == NTrackID) { + ms_Event->SetHYD2TrkThirdStageEEnergy(RandGauss::shoot(ThirdStageEnergy, ResoThirdStage)); + ms_Event->SetHYD2TrkThirdStageEPadNbr(1); + ms_Event->SetHYD2TrkThirdStageTPadNbr(1); + ms_Event->SetHYD2TrkThirdStageTTime(1); + ms_Event->SetHYD2TrkThirdStageTDetectorNbr(m_index["Trapezoid1"] + N); + ms_Event->SetHYD2TrkThirdStageEDetectorNbr(m_index["Trapezoid1"] + N); + } + + ThirdStageEnergy_itr++; + } + + // Fourth Stage + FourthStageEnergy_itr = FourthStageEnergyHitMap->GetMap()->begin(); + for (unsigned int h = 0; h < FourthStageEnergyHitMap->entries(); h++) { + G4int FourthStageEnergyTrackID = FourthStageEnergy_itr->first - N; + G4double FourthStageEnergy = *(FourthStageEnergy_itr->second); + + if (FourthStageEnergyTrackID == NTrackID) { + ms_Event->SetHYD2TrkFourthStageEEnergy(RandGauss::shoot(FourthStageEnergy, ResoFourthStage)); + ms_Event->SetHYD2TrkFourthStageEPadNbr(1); + ms_Event->SetHYD2TrkFourthStageTPadNbr(1); + ms_Event->SetHYD2TrkFourthStageTTime(1); + ms_Event->SetHYD2TrkFourthStageTDetectorNbr(m_index["Trapezoid1"] + N); + ms_Event->SetHYD2TrkFourthStageEDetectorNbr(m_index["Trapezoid1"] + N); + } + + FourthStageEnergy_itr++; + } + + // Fifth Stage + FifthStageEnergy_itr = FifthStageEnergyHitMap->GetMap()->begin(); + for (unsigned int h = 0; h < FifthStageEnergyHitMap->entries(); h++) { + G4int FifthStageEnergyTrackID = FifthStageEnergy_itr->first - N; + G4double FifthStageEnergy = *(FifthStageEnergy_itr->second); + + if (FifthStageEnergyTrackID == NTrackID) { + ms_Event->SetHYD2TrkFifthStageEEnergy(RandGauss::shoot(FifthStageEnergy, ResoFifthStage)); + ms_Event->SetHYD2TrkFifthStageEPadNbr(1); + ms_Event->SetHYD2TrkFifthStageTPadNbr(1); + ms_Event->SetHYD2TrkFifthStageTTime(1); + ms_Event->SetHYD2TrkFifthStageTDetectorNbr(m_index["Trapezoid1"] + N); + ms_Event->SetHYD2TrkFifthStageEDetectorNbr(m_index["Trapezoid1"] + N); + } + + FifthStageEnergy_itr++; + } + + // Sixth Stage + SixthStageEnergy_itr = SixthStageEnergyHitMap->GetMap()->begin(); + for (unsigned int h = 0; h < SixthStageEnergyHitMap->entries(); h++) { + G4int SixthStageEnergyTrackID = SixthStageEnergy_itr->first - N; + G4double SixthStageEnergy = *(SixthStageEnergy_itr->second); + + if (SixthStageEnergyTrackID == NTrackID) { + ms_Event->SetHYD2TrkSixthStageEEnergy(RandGauss::shoot(SixthStageEnergy, ResoSixthStage)); + ms_Event->SetHYD2TrkSixthStageEPadNbr(1); + ms_Event->SetHYD2TrkSixthStageTPadNbr(1); + ms_Event->SetHYD2TrkSixthStageTTime(1); + ms_Event->SetHYD2TrkSixthStageTDetectorNbr(m_index["Trapezoid1"] + N); + ms_Event->SetHYD2TrkSixthStageEDetectorNbr(m_index["Trapezoid1"] + N); + } + + SixthStageEnergy_itr++; + } + + DetectorNumber_itr++; + } + + // clear map for next event + DetectorNumberHitMap->clear(); + EnergyHitMap->clear(); + TimeHitMap->clear(); + XHitMap->clear(); + YHitMap->clear(); + PosXHitMap->clear(); + PosYHitMap->clear(); + PosZHitMap->clear(); + AngThetaHitMap->clear(); + AngPhiHitMap->clear(); + SecondStageEnergyHitMap->clear(); + ThirdStageEnergyHitMap->clear(); + FourthStageEnergyHitMap->clear(); + FifthStageEnergyHitMap->clear(); + SixthStageEnergyHitMap->clear(); + } +} -void Hyde2TrackerTrapezoid1::InitializeScorers() -{ - bool already_exist = false; - m_FirstStageScorer = NPS::VDetector::CheckScorer("FirstStageScorerHYD2Trapezoid1",already_exist); - m_SecondStageScorer = NPS::VDetector::CheckScorer("SecondStageScorerHYD2Trapezoid1",already_exist); - m_ThirdStageScorer = NPS::VDetector::CheckScorer("ThirdStageScorerHYD2Trapezoid1",already_exist); - m_FourthStageScorer = NPS::VDetector::CheckScorer("FourthStageScorerHYD2Trapezoid1",already_exist); - m_FifthStageScorer = NPS::VDetector::CheckScorer("FifthStageScorerHYD2Trapezoid1",already_exist); - m_SixthStageScorer = NPS::VDetector::CheckScorer("SixthStageScorerHYD2Trapezoid1",already_exist); - if(already_exist) return; - - - - // First stage Associate Scorer - G4VPrimitiveScorer* DetNbr = new OBSOLETEGENERALSCORERS::PSDetectorNumber("DetectorNumber", "HYD2Trapezoid1", 0); - G4VPrimitiveScorer* TOF = new OBSOLETEGENERALSCORERS::PSTOF("StripTime","HYD2Trapezoid1", 0); - G4VPrimitiveScorer* InteractionCoordinatesX = new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesX("InterCoordX","HYD2Trapezoid1", 0); - G4VPrimitiveScorer* InteractionCoordinatesY = new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesY("InterCoordY","HYD2Trapezoid1", 0); - G4VPrimitiveScorer* InteractionCoordinatesZ = new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesZ("InterCoordZ","HYD2Trapezoid1", 0); - G4VPrimitiveScorer* InteractionCoordinatesAngleTheta = new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesAngleTheta("InterCoordAngTheta","HYD2Trapezoid1", 0); - G4VPrimitiveScorer* InteractionCoordinatesAnglePhi = new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesAnglePhi("InterCoordAngPhi","HYD2Trapezoid1", 0); - G4VPrimitiveScorer* Energy = new HYD2ScorerFirstStageEnergy("StripEnergy", "HYD2Trapezoid1", 0); - G4VPrimitiveScorer* StripPositionX = new HYD2ScorerFirstStageFrontStripTrapezoid1("StripNumberX", 0, NumberOfStripsX); - G4VPrimitiveScorer* StripPositionY = new HYD2ScorerFirstStageBackStripTrapezoid1("StripNumberY", 0, NumberOfStripsY); - - //and register it to the multifunctionnal detector - m_FirstStageScorer->RegisterPrimitive(DetNbr); - m_FirstStageScorer->RegisterPrimitive(Energy); - m_FirstStageScorer->RegisterPrimitive(TOF); - m_FirstStageScorer->RegisterPrimitive(StripPositionX); - m_FirstStageScorer->RegisterPrimitive(StripPositionY); - m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesX); - m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesY); - m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesZ); - m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesAngleTheta); - m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesAnglePhi); - - // Second stage Associate Scorer - G4VPrimitiveScorer* SecondStageEnergy = new HYD2ScorerSecondStageEnergy("SecondStageEnergy", "HYD2Trapezoid1", 0); - m_SecondStageScorer->RegisterPrimitive(SecondStageEnergy); - - // Third stage Associate Scorer - G4VPrimitiveScorer* ThirdStageEnergy = new HYD2ScorerThirdStageEnergy("ThirdStageEnergy", "HYD2Trapezoid1", 0); - m_ThirdStageScorer->RegisterPrimitive(ThirdStageEnergy); - - // Fourth stage Associate Scorer - G4VPrimitiveScorer* FourthStageEnergy = new HYD2ScorerFourthStageEnergy("FourthStageEnergy", "HYD2Trapezoid1", 0); - m_FourthStageScorer->RegisterPrimitive(FourthStageEnergy); - - // Fifth stage Associate Scorer - G4VPrimitiveScorer* FifthStageEnergy = new HYD2ScorerFifthStageEnergy("FifthStageEnergy", "HYD2Trapezoid1", 0); - m_FifthStageScorer->RegisterPrimitive(FifthStageEnergy); - - // Sixth stage Associate Scorer - G4VPrimitiveScorer* SixthStageEnergy = new HYD2ScorerSixthStageEnergy("SixthStageEnergy", "HYD2Trapezoid1", 0); - m_SixthStageScorer->RegisterPrimitive(SixthStageEnergy); - - // Add All Scorer to the Global Scorer Manager - G4SDManager::GetSDMpointer()->AddNewDetector(m_FirstStageScorer); - G4SDManager::GetSDMpointer()->AddNewDetector(m_SecondStageScorer); - G4SDManager::GetSDMpointer()->AddNewDetector(m_ThirdStageScorer); - G4SDManager::GetSDMpointer()->AddNewDetector(m_FourthStageScorer); - G4SDManager::GetSDMpointer()->AddNewDetector(m_FifthStageScorer); - G4SDManager::GetSDMpointer()->AddNewDetector(m_SixthStageScorer); +void Hyde2TrackerTrapezoid1::InitializeScorers() { + bool already_exist = false; + m_FirstStageScorer = NPS::VDetector::CheckScorer("FirstStageScorerHYD2Trapezoid1", already_exist); + m_SecondStageScorer = NPS::VDetector::CheckScorer("SecondStageScorerHYD2Trapezoid1", already_exist); + m_ThirdStageScorer = NPS::VDetector::CheckScorer("ThirdStageScorerHYD2Trapezoid1", already_exist); + m_FourthStageScorer = NPS::VDetector::CheckScorer("FourthStageScorerHYD2Trapezoid1", already_exist); + m_FifthStageScorer = NPS::VDetector::CheckScorer("FifthStageScorerHYD2Trapezoid1", already_exist); + m_SixthStageScorer = NPS::VDetector::CheckScorer("SixthStageScorerHYD2Trapezoid1", already_exist); + if (already_exist) + return; + + // First stage Associate Scorer + G4VPrimitiveScorer* DetNbr = new OBSOLETEGENERALSCORERS::PSDetectorNumber("DetectorNumber", "HYD2Trapezoid1", 0); + G4VPrimitiveScorer* TOF = new OBSOLETEGENERALSCORERS::PSTOF("StripTime", "HYD2Trapezoid1", 0); + G4VPrimitiveScorer* InteractionCoordinatesX = + new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesX("InterCoordX", "HYD2Trapezoid1", 0); + G4VPrimitiveScorer* InteractionCoordinatesY = + new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesY("InterCoordY", "HYD2Trapezoid1", 0); + G4VPrimitiveScorer* InteractionCoordinatesZ = + new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesZ("InterCoordZ", "HYD2Trapezoid1", 0); + G4VPrimitiveScorer* InteractionCoordinatesAngleTheta = + new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesAngleTheta("InterCoordAngTheta", "HYD2Trapezoid1", 0); + G4VPrimitiveScorer* InteractionCoordinatesAnglePhi = + new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesAnglePhi("InterCoordAngPhi", "HYD2Trapezoid1", 0); + G4VPrimitiveScorer* Energy = new HYD2ScorerFirstStageEnergy("StripEnergy", "HYD2Trapezoid1", 0); + G4VPrimitiveScorer* StripPositionX = new HYD2ScorerFirstStageFrontStripTrapezoid1("StripNumberX", 0, NumberOfStripsX); + G4VPrimitiveScorer* StripPositionY = new HYD2ScorerFirstStageBackStripTrapezoid1("StripNumberY", 0, NumberOfStripsY); + + // and register it to the multifunctionnal detector + m_FirstStageScorer->RegisterPrimitive(DetNbr); + m_FirstStageScorer->RegisterPrimitive(Energy); + m_FirstStageScorer->RegisterPrimitive(TOF); + m_FirstStageScorer->RegisterPrimitive(StripPositionX); + m_FirstStageScorer->RegisterPrimitive(StripPositionY); + m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesX); + m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesY); + m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesZ); + m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesAngleTheta); + m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesAnglePhi); + + // Second stage Associate Scorer + G4VPrimitiveScorer* SecondStageEnergy = new HYD2ScorerSecondStageEnergy("SecondStageEnergy", "HYD2Trapezoid1", 0); + m_SecondStageScorer->RegisterPrimitive(SecondStageEnergy); + + // Third stage Associate Scorer + G4VPrimitiveScorer* ThirdStageEnergy = new HYD2ScorerThirdStageEnergy("ThirdStageEnergy", "HYD2Trapezoid1", 0); + m_ThirdStageScorer->RegisterPrimitive(ThirdStageEnergy); + + // Fourth stage Associate Scorer + G4VPrimitiveScorer* FourthStageEnergy = new HYD2ScorerFourthStageEnergy("FourthStageEnergy", "HYD2Trapezoid1", 0); + m_FourthStageScorer->RegisterPrimitive(FourthStageEnergy); + + // Fifth stage Associate Scorer + G4VPrimitiveScorer* FifthStageEnergy = new HYD2ScorerFifthStageEnergy("FifthStageEnergy", "HYD2Trapezoid1", 0); + m_FifthStageScorer->RegisterPrimitive(FifthStageEnergy); + + // Sixth stage Associate Scorer + G4VPrimitiveScorer* SixthStageEnergy = new HYD2ScorerSixthStageEnergy("SixthStageEnergy", "HYD2Trapezoid1", 0); + m_SixthStageScorer->RegisterPrimitive(SixthStageEnergy); + + // Add All Scorer to the Global Scorer Manager + G4SDManager::GetSDMpointer()->AddNewDetector(m_FirstStageScorer); + G4SDManager::GetSDMpointer()->AddNewDetector(m_SecondStageScorer); + G4SDManager::GetSDMpointer()->AddNewDetector(m_ThirdStageScorer); + G4SDManager::GetSDMpointer()->AddNewDetector(m_FourthStageScorer); + G4SDManager::GetSDMpointer()->AddNewDetector(m_FifthStageScorer); + G4SDManager::GetSDMpointer()->AddNewDetector(m_SixthStageScorer); } diff --git a/NPSimulation/Detectors/Hyde2/Hyde2TrackerTrapezoid2.cc b/NPSimulation/Detectors/Hyde2/Hyde2TrackerTrapezoid2.cc index bf88562769e126985c4049df1d93f9b98a2fd7ae..f11cdc94c23986189e353014f537adb0c7c6670f 100644 --- a/NPSimulation/Detectors/Hyde2/Hyde2TrackerTrapezoid2.cc +++ b/NPSimulation/Detectors/Hyde2/Hyde2TrackerTrapezoid2.cc @@ -23,177 +23,135 @@ *****************************************************************************/ // C++ headers +#include <cmath> #include <sstream> #include <string> -#include <cmath> // G4 Geometry headers #include "G4Box.hh" #include "G4Trap.hh" // G4 various headers -#include "G4MaterialTable.hh" +#include "G4Colour.hh" #include "G4Element.hh" #include "G4ElementTable.hh" -#include "G4VisAttributes.hh" -#include "G4Colour.hh" +#include "G4MaterialTable.hh" +#include "G4PVDivision.hh" +#include "G4PVPlacement.hh" #include "G4RotationMatrix.hh" #include "G4Transform3D.hh" -#include "G4PVPlacement.hh" -#include "G4PVDivision.hh" +#include "G4VisAttributes.hh" // G4 sensitive -#include "G4SDManager.hh" #include "G4MultiFunctionalDetector.hh" +#include "G4SDManager.hh" // NPTool headers +#include "Hyde2Scorers.hh" #include "Hyde2TrackerTrapezoid2.hh" +#include "NPSVDetector.hh" #include "ObsoleteGeneralScorers.hh" -#include "Hyde2Scorers.hh" #include "RootOutput.h" -#include "NPSVDetector.hh" // CLHEP #include "CLHEP/Random/RandGauss.h" using namespace std; using namespace CLHEP; -using namespace HYD2TRAP2 ; - - +using namespace HYD2TRAP2; //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -Hyde2TrackerTrapezoid2::Hyde2TrackerTrapezoid2() -{ - ms_InterCoord = 0; -} - - +Hyde2TrackerTrapezoid2::Hyde2TrackerTrapezoid2() { ms_InterCoord = 0; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -Hyde2TrackerTrapezoid2::~Hyde2TrackerTrapezoid2() -{ -} - - +Hyde2TrackerTrapezoid2::~Hyde2TrackerTrapezoid2() {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Hyde2TrackerTrapezoid2::AddModule(G4ThreeVector X1_Y1 , - G4ThreeVector X128_Y1 , - G4ThreeVector X1_Y128 , - G4ThreeVector X128_Y128 , - bool wFirstStage , - bool wSecondStage , - bool wThirdStage , - bool wFourthStage , - bool wFifthStage , - bool wSixthStage) -{ - m_DefinitionType.push_back(true) ; - - m_X1_Y1.push_back(X1_Y1) ; - m_X128_Y1.push_back(X128_Y1) ; - m_X1_Y128.push_back(X1_Y128) ; - m_X128_Y128.push_back(X128_Y128) ; - m_wFirstStage.push_back(wFirstStage) ; - m_wSecondStage.push_back(wSecondStage) ; - m_wThirdStage.push_back(wThirdStage) ; - m_wFourthStage.push_back(wFourthStage) ; - m_wFifthStage.push_back(wFifthStage) ; - m_wSixthStage.push_back(wSixthStage) ; - - m_R.push_back(0) ; - m_Theta.push_back(0) ; - m_Phi.push_back(0) ; - m_beta_u.push_back(0) ; - m_beta_v.push_back(0) ; - m_beta_w.push_back(0) ; +void Hyde2TrackerTrapezoid2::AddModule(G4ThreeVector X1_Y1, G4ThreeVector X128_Y1, G4ThreeVector X1_Y128, + G4ThreeVector X128_Y128, bool wFirstStage, bool wSecondStage, bool wThirdStage, + bool wFourthStage, bool wFifthStage, bool wSixthStage) { + m_DefinitionType.push_back(true); + + m_X1_Y1.push_back(X1_Y1); + m_X128_Y1.push_back(X128_Y1); + m_X1_Y128.push_back(X1_Y128); + m_X128_Y128.push_back(X128_Y128); + m_wFirstStage.push_back(wFirstStage); + m_wSecondStage.push_back(wSecondStage); + m_wThirdStage.push_back(wThirdStage); + m_wFourthStage.push_back(wFourthStage); + m_wFifthStage.push_back(wFifthStage); + m_wSixthStage.push_back(wSixthStage); + + m_R.push_back(0); + m_Theta.push_back(0); + m_Phi.push_back(0); + m_beta_u.push_back(0); + m_beta_v.push_back(0); + m_beta_w.push_back(0); } - - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Hyde2TrackerTrapezoid2::AddModule(G4double R , - G4double Theta , - G4double Phi , - G4double beta_u , - G4double beta_v , - G4double beta_w , - bool wFirstStage , - bool wSecondStage , - bool wThirdStage , - bool wFourthStage , - bool wFifthStage , - bool wSixthStage) -{ - G4ThreeVector empty = G4ThreeVector(0, 0, 0); - - m_DefinitionType.push_back(false); - - m_R.push_back(R) ; - m_Theta.push_back(Theta) ; - m_Phi.push_back(Phi) ; - m_beta_u.push_back(beta_u) ; - m_beta_v.push_back(beta_v) ; - m_beta_w.push_back(beta_w) ; - m_wFirstStage.push_back(wFirstStage) ; - m_wSecondStage.push_back(wSecondStage) ; - m_wThirdStage.push_back(wThirdStage) ; - m_wFourthStage.push_back(wFourthStage) ; - m_wFifthStage.push_back(wFifthStage) ; - m_wSixthStage.push_back(wSixthStage) ; - - m_X1_Y1.push_back(empty) ; - m_X128_Y1.push_back(empty) ; - m_X1_Y128.push_back(empty) ; - m_X128_Y128.push_back(empty) ; +void Hyde2TrackerTrapezoid2::AddModule(G4double R, G4double Theta, G4double Phi, G4double beta_u, G4double beta_v, + G4double beta_w, bool wFirstStage, bool wSecondStage, bool wThirdStage, + bool wFourthStage, bool wFifthStage, bool wSixthStage) { + G4ThreeVector empty = G4ThreeVector(0, 0, 0); + + m_DefinitionType.push_back(false); + + m_R.push_back(R); + m_Theta.push_back(Theta); + m_Phi.push_back(Phi); + m_beta_u.push_back(beta_u); + m_beta_v.push_back(beta_v); + m_beta_w.push_back(beta_w); + m_wFirstStage.push_back(wFirstStage); + m_wSecondStage.push_back(wSecondStage); + m_wThirdStage.push_back(wThirdStage); + m_wFourthStage.push_back(wFourthStage); + m_wFifthStage.push_back(wFifthStage); + m_wSixthStage.push_back(wSixthStage); + + m_X1_Y1.push_back(empty); + m_X128_Y1.push_back(empty); + m_X1_Y128.push_back(empty); + m_X128_Y128.push_back(empty); } - - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Hyde2TrackerTrapezoid2::VolumeMaker(G4int TelescopeNumber , - G4ThreeVector MMpos , - G4RotationMatrix* MMrot , - bool wFirstStage , - bool wSecondStage , - bool wThirdStage , - bool wFourthStage , - bool wFifthStage , - bool wSixthStage , - G4LogicalVolume* world) -{ - G4double NbrTelescopes = TelescopeNumber ; - G4String DetectorNumber ; - ostringstream Number ; - Number << NbrTelescopes ; - DetectorNumber = Number.str() ; - - //////////////////////////////////////////////////////////////// - ////////////// Starting Volume Definition ////////////////////// - //////////////////////////////////////////////////////////////// - G4String Name = "HYD2Trapezoid2" + DetectorNumber ; - - // Definition of the volume containing the sensitive detector - G4Trap* solidHYD2Trapezoid2 = new G4Trap(Name, - Length/2, 0*deg, 0*deg, - Height/2, BaseLarge/2, BaseSmall/2, 0*deg, - Height/2, BaseLarge/2, BaseSmall/2, 0*deg); - G4LogicalVolume* logicHYD2Trapezoid2 = new G4LogicalVolume(solidHYD2Trapezoid2, m_MaterialVacuum, Name, 0, 0, 0); - - new G4PVPlacement(G4Transform3D(*MMrot, MMpos), logicHYD2Trapezoid2, Name, world, false, 0); - - logicHYD2Trapezoid2->SetVisAttributes(G4VisAttributes::Invisible); - if (m_non_sensitive_part_visiualisation) logicHYD2Trapezoid2->SetVisAttributes(G4VisAttributes(G4Colour(0.90, 0.90, 0.90))); - - //Place two marker to identify the u and v axis on silicon face: - //marker are placed a bit before the silicon itself so they don't perturbate simulation - //Uncomment to help debugging or if you want to understand the way the code work. - //I should recommand to Comment it during simulation to avoid perturbation of simulation - //Remember G4 is limitationg step on geometry constraints. - /* +void Hyde2TrackerTrapezoid2::VolumeMaker(G4int TelescopeNumber, G4ThreeVector MMpos, G4RotationMatrix* MMrot, + bool wFirstStage, bool wSecondStage, bool wThirdStage, bool wFourthStage, + bool wFifthStage, bool wSixthStage, G4LogicalVolume* world) { + G4double NbrTelescopes = TelescopeNumber; + G4String DetectorNumber; + ostringstream Number; + Number << NbrTelescopes; + DetectorNumber = Number.str(); + + //////////////////////////////////////////////////////////////// + ////////////// Starting Volume Definition ////////////////////// + //////////////////////////////////////////////////////////////// + G4String Name = "HYD2Trapezoid2" + DetectorNumber; + + // Definition of the volume containing the sensitive detector + G4Trap* solidHYD2Trapezoid2 = new G4Trap(Name, Length / 2, 0 * deg, 0 * deg, Height / 2, BaseLarge / 2, BaseSmall / 2, + 0 * deg, Height / 2, BaseLarge / 2, BaseSmall / 2, 0 * deg); + G4LogicalVolume* logicHYD2Trapezoid2 = new G4LogicalVolume(solidHYD2Trapezoid2, m_MaterialVacuum, Name, 0, 0, 0); + + new G4PVPlacement(G4Transform3D(*MMrot, MMpos), logicHYD2Trapezoid2, Name, world, false, 0); + + logicHYD2Trapezoid2->SetVisAttributes(G4VisAttributes::GetInvisible()); + if (m_non_sensitive_part_visiualisation) + logicHYD2Trapezoid2->SetVisAttributes(G4VisAttributes(G4Colour(0.90, 0.90, 0.90))); + + // Place two marker to identify the u and v axis on silicon face: + // marker are placed a bit before the silicon itself so they don't perturbate simulation + // Uncomment to help debugging or if you want to understand the way the code work. + // I should recommand to Comment it during simulation to avoid perturbation of simulation + // Remember G4 is limitationg step on geometry constraints. + /* G4ThreeVector positionMarkerU = CT*0.98 + MMu*SiliconFace/4; G4Box* solidMarkerU = new G4Box( "solidMarkerU" , SiliconFace/4 , 1*mm , 1*mm ) ; - G4LogicalVolume* logicMarkerU = new G4LogicalVolume( solidMarkerU , m_MaterialVacuum , "logicMarkerU",0,0,0) ; + G4LogicalVolume* logicMarkerU = new G4LogicalVolume( solidMarkerU , m_MaterialVacuum , "logicMarkerU",0,0,0) ; PVPBuffer = new G4PVPlacement(G4Transform3D(*MMrot,positionMarkerU),logicMarkerU,"MarkerU",world,false,0) ; G4VisAttributes* MarkerUVisAtt= new G4VisAttributes(G4Colour(0.,0.,0.5));//blue @@ -201,187 +159,156 @@ void Hyde2TrackerTrapezoid2::VolumeMaker(G4int TelescopeNumber , G4ThreeVector positionMarkerV = CT*0.98 + MMv*SiliconFace/4; G4Box* solidMarkerV = new G4Box( "solidMarkerU" , 1*mm , SiliconFace/4 , 1*mm ) ; - G4LogicalVolume* logicMarkerV = new G4LogicalVolume( solidMarkerV , m_MaterialVacuum , "logicMarkerV",0,0,0) ; + G4LogicalVolume* logicMarkerV = new G4LogicalVolume( solidMarkerV , m_MaterialVacuum , "logicMarkerV",0,0,0) ; PVPBuffer = new G4PVPlacement(G4Transform3D(*MMrot,positionMarkerV),logicMarkerV,"MarkerV",world,false,0) ; G4VisAttributes* MarkerVVisAtt= new G4VisAttributes(G4Colour(0.,0.5,0.5));//green logicMarkerV->SetVisAttributes(MarkerVVisAtt); */ - //////////////////////////////////////////////////////////////// - /////////////////// First Stage Construction//////////////////// - //////////////////////////////////////////////////////////////// - if (wFirstStage) { - // Silicon detector itself - G4ThreeVector positionFirstStage = G4ThreeVector(0, 0, FirstStage_PosZ); - - G4Trap* solidFirstStage = new G4Trap("solidFirstStage", - FirstStageThickness/2, 0*deg, 0*deg, - FirstStageHeight/2, FirstStageBaseLarge/2, FirstStageBaseSmall/2, 0*deg, - FirstStageHeight/2, FirstStageBaseLarge/2, FirstStageBaseSmall/2, 0*deg); - G4LogicalVolume* logicFirstStage = new G4LogicalVolume(solidFirstStage, m_MaterialSilicon, "logicFirstStage", 0, 0, 0); - - new G4PVPlacement(0, - positionFirstStage, - logicFirstStage, - Name + "_FirstStage", - logicHYD2Trapezoid2, - false, - 0); - - // Set First Stage sensible - logicFirstStage->SetSensitiveDetector(m_FirstStageScorer); - - ///Visualisation of FirstStage Strip - G4VisAttributes* FirstStageVisAtt = new G4VisAttributes(G4Colour(0.0, 0.0, 0.9)); // blue - logicFirstStage->SetVisAttributes(FirstStageVisAtt); - } - - //////////////////////////////////////////////////////////////// - //////////////// Second Stage Construction //////////////////// - //////////////////////////////////////////////////////////////// - if (wSecondStage) { - // Second stage silicon detector - G4ThreeVector positionSecondStage = G4ThreeVector(0, 0, SecondStage_PosZ); - - G4Trap* solidSecondStage = new G4Trap("solidSecondStage", - SecondStageThickness/2, 0*deg, 0*deg, - FirstStageHeight/2, FirstStageBaseLarge/2, FirstStageBaseSmall/2, 0*deg, - FirstStageHeight/2, FirstStageBaseLarge/2, FirstStageBaseSmall/2, 0*deg); - G4LogicalVolume* logicSecondStage = new G4LogicalVolume(solidSecondStage, m_MaterialSilicon, "logicSecondStage", 0, 0, 0); - - new G4PVPlacement(0, - positionSecondStage, - logicSecondStage, - Name + "_SecondStage", - logicHYD2Trapezoid2, - false, - 0); - - // Set Second Stage sensible - logicSecondStage->SetSensitiveDetector(m_SecondStageScorer); - - ///Visualisation of SecondStage Strip - G4VisAttributes* SecondStageVisAtt = new G4VisAttributes(G4Colour(0.5, 0.5, 0.5)); - logicSecondStage->SetVisAttributes(SecondStageVisAtt); - } - - //////////////////////////////////////////////////////////////// - ///////////////// Third Stage Construction ///////////////////// - //////////////////////////////////////////////////////////////// - if (wThirdStage) { - // Third stage silicon detector - G4ThreeVector positionThirdStage = G4ThreeVector(0, 0, ThirdStage_PosZ); - - G4Trap* solidThirdStage = new G4Trap("solidThirdStage", - ThirdStageThickness/2, 0*deg, 0*deg, - FirstStageHeight/2, FirstStageBaseLarge/2, FirstStageBaseSmall/2, 0*deg, - FirstStageHeight/2, FirstStageBaseLarge/2, FirstStageBaseSmall/2, 0*deg); - G4LogicalVolume* logicThirdStage = new G4LogicalVolume(solidThirdStage, m_MaterialSilicon, "logicThirdStage", 0, 0, 0); - - new G4PVPlacement(0, - positionThirdStage, - logicThirdStage, - Name + "_ThirdStage", - logicHYD2Trapezoid2, - false, - 0); - - // Set Third Stage sensible - logicThirdStage->SetSensitiveDetector(m_ThirdStageScorer); - - ///Visualisation of Third Stage - G4VisAttributes* ThirdStageVisAtt = new G4VisAttributes(G4Colour(0.0, 0.9, 0.0)); // red - logicThirdStage->SetVisAttributes(ThirdStageVisAtt); - } - - //////////////////////////////////////////////////////////////// - ///////////////// Fourth Stage Construction //////////////////// - //////////////////////////////////////////////////////////////// - if (wFourthStage) { - // Fourth stage silicon detector - G4ThreeVector positionFourthStage = G4ThreeVector(0, 0, FourthStage_PosZ); - - G4Trap* solidFourthStage = new G4Trap("solidFourthStage", - FourthStageThickness/2, 0*deg, 0*deg, - FirstStageHeight/2, FirstStageBaseLarge/2, FirstStageBaseSmall/2, 0*deg, - FirstStageHeight/2, FirstStageBaseLarge/2, FirstStageBaseSmall/2, 0*deg); - G4LogicalVolume* logicFourthStage = new G4LogicalVolume(solidFourthStage, m_MaterialSilicon, "logicFourthStage", 0, 0, 0); - - new G4PVPlacement(0, - positionFourthStage, - logicFourthStage, - Name + "_FourthStage", - logicHYD2Trapezoid2, - false, - 0); - - // Set Fourth Stage sensible - logicFourthStage->SetSensitiveDetector(m_FourthStageScorer); - - ///Visualisation of Fourth Stage - G4VisAttributes* FourthStageVisAtt = new G4VisAttributes(G4Colour(0.0, 0.9, 0.0)); // red - logicFourthStage->SetVisAttributes(FourthStageVisAtt); - } - - //////////////////////////////////////////////////////////////// - ///////////////// Fifth Stage Construction ///////////////////// - //////////////////////////////////////////////////////////////// - if (wFifthStage) { - // Fifth stage silicon detector - G4ThreeVector positionFifthStage = G4ThreeVector(0, 0, FifthStage_PosZ); - - G4Trap* solidFifthStage = new G4Trap("solidFifthStage", - FifthStageThickness/2, 0*deg, 0*deg, - FirstStageHeight/2, FirstStageBaseLarge/2, FirstStageBaseSmall/2, 0*deg, - FirstStageHeight/2, FirstStageBaseLarge/2, FirstStageBaseSmall/2, 0*deg); - G4LogicalVolume* logicFifthStage = new G4LogicalVolume(solidFifthStage, m_MaterialSilicon, "logicFifthStage", 0, 0, 0); - - new G4PVPlacement(0, - positionFifthStage, - logicFifthStage, - Name + "_FifthStage", - logicHYD2Trapezoid2, - false, - 0); - - // Set Fifth Stage sensible - logicFifthStage->SetSensitiveDetector(m_FifthStageScorer); - - ///Visualisation of Fifth Stage - G4VisAttributes* FifthStageVisAtt = new G4VisAttributes(G4Colour(0.0, 0.9, 0.0)); // red - logicFifthStage->SetVisAttributes(FifthStageVisAtt); - } - - //////////////////////////////////////////////////////////////// - ///////////////// Sixth Stage Construction ///////////////////// - //////////////////////////////////////////////////////////////// - if (wSixthStage) { - // Sixth stage silicon detector - G4ThreeVector positionSixthStage = G4ThreeVector(0, 0, SixthStage_PosZ); - - G4Trap* solidSixthStage = new G4Trap("solidSixthStage", - SixthStageThickness/2, 0*deg, 0*deg, - FirstStageHeight/2, FirstStageBaseLarge/2, FirstStageBaseSmall/2, 0*deg, - FirstStageHeight/2, FirstStageBaseLarge/2, FirstStageBaseSmall/2, 0*deg); - G4LogicalVolume* logicSixthStage = new G4LogicalVolume(solidSixthStage, m_MaterialSilicon, "logicSixthStage", 0, 0, 0); - - new G4PVPlacement(0, - positionSixthStage, - logicSixthStage, - Name + "_SixthStage", - logicHYD2Trapezoid2, - false, - 0); - - // Set Sixth Stage sensible - logicSixthStage->SetSensitiveDetector(m_SixthStageScorer); - - ///Visualisation of Sixth Stage - G4VisAttributes* SixthStageVisAtt = new G4VisAttributes(G4Colour(0.0, 0.9, 0.0)); // red - logicSixthStage->SetVisAttributes(SixthStageVisAtt); - } - + //////////////////////////////////////////////////////////////// + /////////////////// First Stage Construction//////////////////// + //////////////////////////////////////////////////////////////// + if (wFirstStage) { + // Silicon detector itself + G4ThreeVector positionFirstStage = G4ThreeVector(0, 0, FirstStage_PosZ); + + G4Trap* solidFirstStage = + new G4Trap("solidFirstStage", FirstStageThickness / 2, 0 * deg, 0 * deg, FirstStageHeight / 2, + FirstStageBaseLarge / 2, FirstStageBaseSmall / 2, 0 * deg, FirstStageHeight / 2, + FirstStageBaseLarge / 2, FirstStageBaseSmall / 2, 0 * deg); + G4LogicalVolume* logicFirstStage = + new G4LogicalVolume(solidFirstStage, m_MaterialSilicon, "logicFirstStage", 0, 0, 0); + + new G4PVPlacement(0, positionFirstStage, logicFirstStage, Name + "_FirstStage", logicHYD2Trapezoid2, false, 0); + + // Set First Stage sensible + logicFirstStage->SetSensitiveDetector(m_FirstStageScorer); + + /// Visualisation of FirstStage Strip + G4VisAttributes* FirstStageVisAtt = new G4VisAttributes(G4Colour(0.0, 0.0, 0.9)); // blue + logicFirstStage->SetVisAttributes(FirstStageVisAtt); + } + + //////////////////////////////////////////////////////////////// + //////////////// Second Stage Construction //////////////////// + //////////////////////////////////////////////////////////////// + if (wSecondStage) { + // Second stage silicon detector + G4ThreeVector positionSecondStage = G4ThreeVector(0, 0, SecondStage_PosZ); + + G4Trap* solidSecondStage = + new G4Trap("solidSecondStage", SecondStageThickness / 2, 0 * deg, 0 * deg, FirstStageHeight / 2, + FirstStageBaseLarge / 2, FirstStageBaseSmall / 2, 0 * deg, FirstStageHeight / 2, + FirstStageBaseLarge / 2, FirstStageBaseSmall / 2, 0 * deg); + G4LogicalVolume* logicSecondStage = + new G4LogicalVolume(solidSecondStage, m_MaterialSilicon, "logicSecondStage", 0, 0, 0); + + new G4PVPlacement(0, positionSecondStage, logicSecondStage, Name + "_SecondStage", logicHYD2Trapezoid2, false, 0); + + // Set Second Stage sensible + logicSecondStage->SetSensitiveDetector(m_SecondStageScorer); + + /// Visualisation of SecondStage Strip + G4VisAttributes* SecondStageVisAtt = new G4VisAttributes(G4Colour(0.5, 0.5, 0.5)); + logicSecondStage->SetVisAttributes(SecondStageVisAtt); + } + + //////////////////////////////////////////////////////////////// + ///////////////// Third Stage Construction ///////////////////// + //////////////////////////////////////////////////////////////// + if (wThirdStage) { + // Third stage silicon detector + G4ThreeVector positionThirdStage = G4ThreeVector(0, 0, ThirdStage_PosZ); + + G4Trap* solidThirdStage = + new G4Trap("solidThirdStage", ThirdStageThickness / 2, 0 * deg, 0 * deg, FirstStageHeight / 2, + FirstStageBaseLarge / 2, FirstStageBaseSmall / 2, 0 * deg, FirstStageHeight / 2, + FirstStageBaseLarge / 2, FirstStageBaseSmall / 2, 0 * deg); + G4LogicalVolume* logicThirdStage = + new G4LogicalVolume(solidThirdStage, m_MaterialSilicon, "logicThirdStage", 0, 0, 0); + + new G4PVPlacement(0, positionThirdStage, logicThirdStage, Name + "_ThirdStage", logicHYD2Trapezoid2, false, 0); + + // Set Third Stage sensible + logicThirdStage->SetSensitiveDetector(m_ThirdStageScorer); + + /// Visualisation of Third Stage + G4VisAttributes* ThirdStageVisAtt = new G4VisAttributes(G4Colour(0.0, 0.9, 0.0)); // red + logicThirdStage->SetVisAttributes(ThirdStageVisAtt); + } + + //////////////////////////////////////////////////////////////// + ///////////////// Fourth Stage Construction //////////////////// + //////////////////////////////////////////////////////////////// + if (wFourthStage) { + // Fourth stage silicon detector + G4ThreeVector positionFourthStage = G4ThreeVector(0, 0, FourthStage_PosZ); + + G4Trap* solidFourthStage = + new G4Trap("solidFourthStage", FourthStageThickness / 2, 0 * deg, 0 * deg, FirstStageHeight / 2, + FirstStageBaseLarge / 2, FirstStageBaseSmall / 2, 0 * deg, FirstStageHeight / 2, + FirstStageBaseLarge / 2, FirstStageBaseSmall / 2, 0 * deg); + G4LogicalVolume* logicFourthStage = + new G4LogicalVolume(solidFourthStage, m_MaterialSilicon, "logicFourthStage", 0, 0, 0); + + new G4PVPlacement(0, positionFourthStage, logicFourthStage, Name + "_FourthStage", logicHYD2Trapezoid2, false, 0); + + // Set Fourth Stage sensible + logicFourthStage->SetSensitiveDetector(m_FourthStageScorer); + + /// Visualisation of Fourth Stage + G4VisAttributes* FourthStageVisAtt = new G4VisAttributes(G4Colour(0.0, 0.9, 0.0)); // red + logicFourthStage->SetVisAttributes(FourthStageVisAtt); + } + + //////////////////////////////////////////////////////////////// + ///////////////// Fifth Stage Construction ///////////////////// + //////////////////////////////////////////////////////////////// + if (wFifthStage) { + // Fifth stage silicon detector + G4ThreeVector positionFifthStage = G4ThreeVector(0, 0, FifthStage_PosZ); + + G4Trap* solidFifthStage = + new G4Trap("solidFifthStage", FifthStageThickness / 2, 0 * deg, 0 * deg, FirstStageHeight / 2, + FirstStageBaseLarge / 2, FirstStageBaseSmall / 2, 0 * deg, FirstStageHeight / 2, + FirstStageBaseLarge / 2, FirstStageBaseSmall / 2, 0 * deg); + G4LogicalVolume* logicFifthStage = + new G4LogicalVolume(solidFifthStage, m_MaterialSilicon, "logicFifthStage", 0, 0, 0); + + new G4PVPlacement(0, positionFifthStage, logicFifthStage, Name + "_FifthStage", logicHYD2Trapezoid2, false, 0); + + // Set Fifth Stage sensible + logicFifthStage->SetSensitiveDetector(m_FifthStageScorer); + + /// Visualisation of Fifth Stage + G4VisAttributes* FifthStageVisAtt = new G4VisAttributes(G4Colour(0.0, 0.9, 0.0)); // red + logicFifthStage->SetVisAttributes(FifthStageVisAtt); + } + + //////////////////////////////////////////////////////////////// + ///////////////// Sixth Stage Construction ///////////////////// + //////////////////////////////////////////////////////////////// + if (wSixthStage) { + // Sixth stage silicon detector + G4ThreeVector positionSixthStage = G4ThreeVector(0, 0, SixthStage_PosZ); + + G4Trap* solidSixthStage = + new G4Trap("solidSixthStage", SixthStageThickness / 2, 0 * deg, 0 * deg, FirstStageHeight / 2, + FirstStageBaseLarge / 2, FirstStageBaseSmall / 2, 0 * deg, FirstStageHeight / 2, + FirstStageBaseLarge / 2, FirstStageBaseSmall / 2, 0 * deg); + G4LogicalVolume* logicSixthStage = + new G4LogicalVolume(solidSixthStage, m_MaterialSilicon, "logicSixthStage", 0, 0, 0); + + new G4PVPlacement(0, positionSixthStage, logicSixthStage, Name + "_SixthStage", logicHYD2Trapezoid2, false, 0); + + // Set Sixth Stage sensible + logicSixthStage->SetSensitiveDetector(m_SixthStageScorer); + + /// Visualisation of Sixth Stage + G4VisAttributes* SixthStageVisAtt = new G4VisAttributes(G4Colour(0.0, 0.9, 0.0)); // red + logicSixthStage->SetVisAttributes(SixthStageVisAtt); + } } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... @@ -391,837 +318,825 @@ void Hyde2TrackerTrapezoid2::VolumeMaker(G4int TelescopeNumber , // Read stream at Configfile to pick-up parameters of detector (Position,...) // Called in DetecorConstruction::ReadDetextorConfiguration Method -void Hyde2TrackerTrapezoid2::ReadConfiguration(string Path) -{ - ifstream ConfigFile ; - ConfigFile.open(Path.c_str()) ; - string LineBuffer ; - string DataBuffer ; - - // A:X1_Y1 --> X:1 Y:1 - // B:X128_Y1 --> X:128 Y:1 - // C:X1_Y128 --> X:1 Y:128 - // D:X128_Y128 --> X:128 Y:128 - - G4double Ax , Bx , Cx , Dx , Ay , By , Cy , Dy , Az , Bz , Cz , Dz ; - G4ThreeVector A , B , C , D ; - G4double Theta = 0 , Phi = 0 , R = 0 , beta_u = 0 , beta_v = 0 , beta_w = 0 ; - int FIRSTSTAGE = 0 , SECONDSTAGE = 0 , THIRDSTAGE = 0 , FOURTHSTAGE = 0 , FIFTHSTAGE = 0 , SIXTHSTAGE = 0 ; - - bool ReadingStatus = false ; - - bool check_A = false ; - bool check_C = false ; - bool check_B = false ; - bool check_D = false ; - - bool check_Theta = false ; - bool check_Phi = false ; - bool check_R = false ; -// bool check_beta = false ; - - bool check_FirstStage = false ; - bool check_SecondStage = false ; - bool check_ThirdStage = false ; - bool check_FourthStage = false ; - bool check_FifthStage = false ; - bool check_SixthStage = false ; - bool checkVis = false ; - - while (!ConfigFile.eof()) { - getline(ConfigFile, LineBuffer); - if (LineBuffer.compare(0, 14, "HYD2Trapezoid2") == 0) { - G4cout << "///" << G4endl ; - G4cout << "Trapezoid2 element found: " << G4endl ; - ReadingStatus = true ; - } - - while(ReadingStatus){ - - ConfigFile >> DataBuffer; - // Comment Line - if (DataBuffer.compare(0, 1, "%") == 0) {/*do nothing */;} - - // Position method - else if (DataBuffer.compare(0, 6, "X1_Y1=") == 0) { - check_A = true; - ConfigFile >> DataBuffer ; - Ax = atof(DataBuffer.c_str()) ; - Ax = Ax * mm ; - ConfigFile >> DataBuffer ; - Ay = atof(DataBuffer.c_str()) ; - Ay = Ay * mm ; - ConfigFile >> DataBuffer ; - Az = atof(DataBuffer.c_str()) ; - Az = Az * mm ; - - A = G4ThreeVector(Ax, Ay, Az); - G4cout << "X1 Y1 corner position : " << A << G4endl; - } - - else if (DataBuffer.compare(0, 8, "X128_Y1=") == 0) { - check_B = true; - ConfigFile >> DataBuffer ; - Bx = atof(DataBuffer.c_str()) ; - Bx = Bx * mm ; - ConfigFile >> DataBuffer ; - By = atof(DataBuffer.c_str()) ; - By = By * mm ; - ConfigFile >> DataBuffer ; - Bz = atof(DataBuffer.c_str()) ; - Bz = Bz * mm ; - - B = G4ThreeVector(Bx, By, Bz); - G4cout << "X128 Y1 corner position : " << B << G4endl; - } - - else if (DataBuffer.compare(0, 8, "X1_Y128=") == 0) { - check_C = true; - ConfigFile >> DataBuffer ; - Cx = atof(DataBuffer.c_str()) ; - Cx = Cx * mm ; - ConfigFile >> DataBuffer ; - Cy = atof(DataBuffer.c_str()) ; - Cy = Cy * mm ; - ConfigFile >> DataBuffer ; - Cz = atof(DataBuffer.c_str()) ; - Cz = Cz * mm ; - - C = G4ThreeVector(Cx, Cy, Cz); - G4cout << "X1 Y128 corner position : " << C << G4endl; - } - - else if (DataBuffer.compare(0, 10, "X128_Y128=") == 0) { - check_D = true; - ConfigFile >> DataBuffer ; - Dx = atof(DataBuffer.c_str()) ; - Dx = Dx * mm ; - ConfigFile >> DataBuffer ; - Dy = atof(DataBuffer.c_str()) ; - Dy = Dy * mm ; - ConfigFile >> DataBuffer ; - Dz = atof(DataBuffer.c_str()) ; - Dz = Dz * mm ; - - D = G4ThreeVector(Dx, Dy, Dz); - G4cout << "X128 Y128 corner position : " << D << G4endl; - } - - - // Angle method - else if (DataBuffer.compare(0, 6, "THETA=") == 0) { - check_Theta = true; - ConfigFile >> DataBuffer ; - Theta = atof(DataBuffer.c_str()) ; - Theta = Theta * deg; - G4cout << "Theta: " << Theta / deg << G4endl; - } - - else if (DataBuffer.compare(0, 4, "PHI=") == 0) { - check_Phi = true; - ConfigFile >> DataBuffer ; - Phi = atof(DataBuffer.c_str()) ; - Phi = Phi * deg; - G4cout << "Phi: " << Phi / deg << G4endl; - } - - else if (DataBuffer.compare(0, 2, "R=") == 0) { - check_R = true; - ConfigFile >> DataBuffer ; - R = atof(DataBuffer.c_str()) ; - R = R * mm; - G4cout << "R: " << R / mm << G4endl; - } - - else if (DataBuffer.compare(0, 5, "BETA=") == 0) { -// check_beta = true; - ConfigFile >> DataBuffer ; - beta_u = atof(DataBuffer.c_str()) ; - beta_u = beta_u * deg ; - ConfigFile >> DataBuffer ; - beta_v = atof(DataBuffer.c_str()) ; - beta_v = beta_v * deg ; - ConfigFile >> DataBuffer ; - beta_w = atof(DataBuffer.c_str()) ; - beta_w = beta_w * deg ; - G4cout << "Beta: " << beta_u / deg << " " << beta_v / deg << " " << beta_w / deg << G4endl ; - } - - else if (DataBuffer.compare(0, 11, "FIRSTSTAGE=") == 0) { - check_FirstStage = true ; - ConfigFile >> DataBuffer; - FIRSTSTAGE = atof(DataBuffer.c_str()) ; - } - - else if (DataBuffer.compare(0, 12, "SECONDSTAGE=") == 0) { - check_SecondStage = true ; - ConfigFile >> DataBuffer; - SECONDSTAGE = atof(DataBuffer.c_str()) ; - } - - else if (DataBuffer.compare(0, 11, "THIRDSTAGE=") == 0) { - check_ThirdStage = true ; - ConfigFile >> DataBuffer; - THIRDSTAGE = atof(DataBuffer.c_str()) ; - } - - else if (DataBuffer.compare(0, 12, "FOURTHSTAGE=") == 0) { - check_FourthStage = true ; - ConfigFile >> DataBuffer; - FOURTHSTAGE = atof(DataBuffer.c_str()) ; - } - - else if (DataBuffer.compare(0, 11, "FIFTHSTAGE=") == 0) { - check_FifthStage = true ; - ConfigFile >> DataBuffer; - FIFTHSTAGE = atof(DataBuffer.c_str()) ; - } - - else if (DataBuffer.compare(0, 11, "SIXTHSTAGE=") == 0) { - check_SixthStage = true ; - ConfigFile >> DataBuffer; - SIXTHSTAGE = atof(DataBuffer.c_str()) ; - } - - else if (DataBuffer.compare(0, 4, "VIS=") == 0) { - checkVis = true ; - ConfigFile >> DataBuffer; - if (DataBuffer.compare(0, 3, "all") == 0) m_non_sensitive_part_visiualisation = true; - } - - else G4cout << "WARNING: Wrong Token, Hyde2TrackerTrapezoid2: Trapezoid2 Element not added" << G4endl; - - //Add The previously define telescope - //With position method - if ((check_A && check_B && check_C && check_D && check_FirstStage && check_SecondStage && check_ThirdStage && check_FourthStage && check_FifthStage && check_SixthStage && checkVis) && !(check_Theta && check_Phi && check_R)) { - - ReadingStatus = false ; - check_A = false ; - check_C = false ; - check_B = false ; - check_D = false ; - check_FirstStage = false ; - check_SecondStage = false ; - check_ThirdStage = false ; - check_FourthStage = false ; - check_FifthStage = false ; - check_SixthStage = false ; - checkVis = false ; - - AddModule(A , - B , - C , - D , - FIRSTSTAGE == 1 , - SECONDSTAGE == 1 , - THIRDSTAGE == 1 , - FOURTHSTAGE == 1 , - FIFTHSTAGE == 1 , - SIXTHSTAGE == 1); - } - - //with angle method - if ((check_Theta && check_Phi && check_R && check_FirstStage && check_SecondStage && check_ThirdStage && check_FourthStage && check_FifthStage && check_SixthStage && checkVis) && !(check_A && check_B && check_C && check_D)) { - ReadingStatus = false ; - check_Theta = false ; - check_Phi = false ; - check_R = false ; -// check_beta = false ; - check_FirstStage = false ; - check_SecondStage = false ; - check_ThirdStage = false ; - check_FourthStage = false ; - check_FifthStage = false ; - check_SixthStage = false ; - checkVis = false ; - - AddModule(R , - Theta , - Phi , - beta_u , - beta_v , - beta_w , - FIRSTSTAGE == 1 , - SECONDSTAGE == 1 , - THIRDSTAGE == 1 , - FOURTHSTAGE == 1 , - FIFTHSTAGE == 1 , - SIXTHSTAGE == 1); - } - - +void Hyde2TrackerTrapezoid2::ReadConfiguration(string Path) { + ifstream ConfigFile; + ConfigFile.open(Path.c_str()); + string LineBuffer; + string DataBuffer; + + // A:X1_Y1 --> X:1 Y:1 + // B:X128_Y1 --> X:128 Y:1 + // C:X1_Y128 --> X:1 Y:128 + // D:X128_Y128 --> X:128 Y:128 + + G4double Ax, Bx, Cx, Dx, Ay, By, Cy, Dy, Az, Bz, Cz, Dz; + G4ThreeVector A, B, C, D; + G4double Theta = 0, Phi = 0, R = 0, beta_u = 0, beta_v = 0, beta_w = 0; + int FIRSTSTAGE = 0, SECONDSTAGE = 0, THIRDSTAGE = 0, FOURTHSTAGE = 0, FIFTHSTAGE = 0, SIXTHSTAGE = 0; + + bool ReadingStatus = false; + + bool check_A = false; + bool check_C = false; + bool check_B = false; + bool check_D = false; + + bool check_Theta = false; + bool check_Phi = false; + bool check_R = false; + // bool check_beta = false ; + + bool check_FirstStage = false; + bool check_SecondStage = false; + bool check_ThirdStage = false; + bool check_FourthStage = false; + bool check_FifthStage = false; + bool check_SixthStage = false; + bool checkVis = false; + + while (!ConfigFile.eof()) { + getline(ConfigFile, LineBuffer); + if (LineBuffer.compare(0, 14, "HYD2Trapezoid2") == 0) { + G4cout << "///" << G4endl; + G4cout << "Trapezoid2 element found: " << G4endl; + ReadingStatus = true; + } + + while (ReadingStatus) { + + ConfigFile >> DataBuffer; + // Comment Line + if (DataBuffer.compare(0, 1, "%") == 0) { /*do nothing */ + ; } - } -} -// Construct detector and inialise sensitive part. -// Called After DetecorConstruction::AddDetector Method -void Hyde2TrackerTrapezoid2::ConstructDetector(G4LogicalVolume* world) -{ - G4RotationMatrix* MMrot = NULL; - G4ThreeVector MMpos = G4ThreeVector(0, 0, 0); - G4ThreeVector MMu = G4ThreeVector(0, 0, 0); - G4ThreeVector MMv = G4ThreeVector(0, 0, 0); - G4ThreeVector MMw = G4ThreeVector(0, 0, 0); - G4ThreeVector MMCenter = G4ThreeVector(0, 0, 0); - - bool FirstStage = true ; - bool SecondStage = true ; - bool ThirdStage = true ; - bool FourthStage = true ; - bool FifthStage = true ; - bool SixthStage = true ; - - G4int NumberOfModule = m_DefinitionType.size() ; - - for (G4int i = 0; i < NumberOfModule; i++) { - // By Point - if (m_DefinitionType[i]) { - // (u,v,w) unitary vector associated to trapezoidal referencial - // (u,v) // to silicon plan - // ------- - // / \ ^ - // / \ | v - // / \ | - // --------------- <------ - // u - // w perpendicular to (u,v) plan and pointing ThirdStage - G4cout << "XXXXXXXXXXXX Trapezoid2 " << i << " XXXXXXXXXXXXX" << G4endl; - MMu = m_X128_Y1[i] - m_X1_Y1[i]; - MMu = MMu.unit(); - G4cout << "MMu: " << MMu << G4endl; - - MMv = 0.5 * (m_X1_Y128[i] + m_X128_Y128[i] - m_X1_Y1[i] - m_X128_Y1[i]); - MMv = MMv.unit(); - G4cout << "MMv: " << MMv << G4endl; - - MMw = MMu.cross(MMv); - MMw = MMw.unit(); - G4cout << "MMw: " << MMw << G4endl; - - // Center of the module - MMCenter = (m_X1_Y1[i] + m_X1_Y128[i] + m_X128_Y1[i] + m_X128_Y128[i]) / 4; - - // Passage Matrix from Lab Referential to Module Referential - MMrot = new G4RotationMatrix(MMu, MMv, MMw); - // translation to place Module - MMpos = MMw * Length * 0.5 + MMCenter; + // Position method + else if (DataBuffer.compare(0, 6, "X1_Y1=") == 0) { + check_A = true; + ConfigFile >> DataBuffer; + Ax = atof(DataBuffer.c_str()); + Ax = Ax * mm; + ConfigFile >> DataBuffer; + Ay = atof(DataBuffer.c_str()); + Ay = Ay * mm; + ConfigFile >> DataBuffer; + Az = atof(DataBuffer.c_str()); + Az = Az * mm; + + A = G4ThreeVector(Ax, Ay, Az); + G4cout << "X1 Y1 corner position : " << A << G4endl; } - // By Angle - else { - G4double Theta = m_Theta[i]; - G4double Phi = m_Phi[i]; - - // (u,v,w) unitary vector associated to telescope referencial - // (u,v) // to silicon plan - // ------- - // / \ ^ - // / \ | v - // / \ | - // --------------- <------ - // u - // w perpendicular to (u,v) plan and pointing ThirdStage - // Phi is angle between X axis and projection in (X,Y) plan - // Theta is angle between position vector and z axis - G4double wX = m_R[i] * sin(Theta / rad) * cos(Phi / rad); - G4double wY = m_R[i] * sin(Theta / rad) * sin(Phi / rad); - G4double wZ = m_R[i] * cos(Theta / rad); - MMw = G4ThreeVector(wX, wY, wZ); - - // vector corresponding to the center of the module - MMCenter = MMw; - - // vector parallel to one axis of silicon plane - // in fact, this is vector u - G4double ii = cos(Theta / rad) * cos(Phi / rad); - G4double jj = cos(Theta / rad) * sin(Phi / rad); - G4double kk = -sin(Theta / rad); - G4ThreeVector Y = G4ThreeVector(ii, jj, kk); - - MMw = MMw.unit(); - MMv = MMw.cross(Y); - MMu = MMv.cross(MMw); - MMv = MMv.unit(); - MMu = MMu.unit(); - - G4cout << "XXXXXXXXXXXX Trapezoid2 " << i << " XXXXXXXXXXXXX" << G4endl; - G4cout << "MMu: " << MMu << G4endl; - G4cout << "MMv: " << MMv << G4endl; - G4cout << "MMw: " << MMw << G4endl; - - // Passage Matrix from Lab Referential to Telescope Referential - MMrot = new G4RotationMatrix(MMu, MMv, MMw); - // Telescope is rotate of Beta angle around MMv axis. - MMrot->rotate(m_beta_u[i], MMu); - MMrot->rotate(m_beta_v[i], MMv); - MMrot->rotate(m_beta_w[i], MMw); - // translation to place Telescope - MMpos = MMw * Length * 0.5 + MMCenter; + else if (DataBuffer.compare(0, 8, "X128_Y1=") == 0) { + check_B = true; + ConfigFile >> DataBuffer; + Bx = atof(DataBuffer.c_str()); + Bx = Bx * mm; + ConfigFile >> DataBuffer; + By = atof(DataBuffer.c_str()); + By = By * mm; + ConfigFile >> DataBuffer; + Bz = atof(DataBuffer.c_str()); + Bz = Bz * mm; + + B = G4ThreeVector(Bx, By, Bz); + G4cout << "X128 Y1 corner position : " << B << G4endl; } - FirstStage = m_wFirstStage[i]; - SecondStage = m_wSecondStage[i]; - ThirdStage = m_wThirdStage[i]; - FourthStage = m_wFourthStage[i]; - FifthStage = m_wFifthStage[i]; - SixthStage = m_wSixthStage[i]; + else if (DataBuffer.compare(0, 8, "X1_Y128=") == 0) { + check_C = true; + ConfigFile >> DataBuffer; + Cx = atof(DataBuffer.c_str()); + Cx = Cx * mm; + ConfigFile >> DataBuffer; + Cy = atof(DataBuffer.c_str()); + Cy = Cy * mm; + ConfigFile >> DataBuffer; + Cz = atof(DataBuffer.c_str()); + Cz = Cz * mm; + + C = G4ThreeVector(Cx, Cy, Cz); + G4cout << "X1 Y128 corner position : " << C << G4endl; + } - VolumeMaker(i + 1, MMpos, MMrot, FirstStage, SecondStage, ThirdStage, FourthStage, FifthStage, SixthStage, world); - } + else if (DataBuffer.compare(0, 10, "X128_Y128=") == 0) { + check_D = true; + ConfigFile >> DataBuffer; + Dx = atof(DataBuffer.c_str()); + Dx = Dx * mm; + ConfigFile >> DataBuffer; + Dy = atof(DataBuffer.c_str()); + Dy = Dy * mm; + ConfigFile >> DataBuffer; + Dz = atof(DataBuffer.c_str()); + Dz = Dz * mm; + + D = G4ThreeVector(Dx, Dy, Dz); + G4cout << "X128 Y128 corner position : " << D << G4endl; + } - delete MMrot; -} + // Angle method + else if (DataBuffer.compare(0, 6, "THETA=") == 0) { + check_Theta = true; + ConfigFile >> DataBuffer; + Theta = atof(DataBuffer.c_str()); + Theta = Theta * deg; + G4cout << "Theta: " << Theta / deg << G4endl; + } + else if (DataBuffer.compare(0, 4, "PHI=") == 0) { + check_Phi = true; + ConfigFile >> DataBuffer; + Phi = atof(DataBuffer.c_str()); + Phi = Phi * deg; + G4cout << "Phi: " << Phi / deg << G4endl; + } + else if (DataBuffer.compare(0, 2, "R=") == 0) { + check_R = true; + ConfigFile >> DataBuffer; + R = atof(DataBuffer.c_str()); + R = R * mm; + G4cout << "R: " << R / mm << G4endl; + } -// Connect the Hyde2TrackingData class to the output TTree -// of the simulation -void Hyde2TrackerTrapezoid2::InitializeRootOutput() -{ -} + else if (DataBuffer.compare(0, 5, "BETA=") == 0) { + // check_beta = true; + ConfigFile >> DataBuffer; + beta_u = atof(DataBuffer.c_str()); + beta_u = beta_u * deg; + ConfigFile >> DataBuffer; + beta_v = atof(DataBuffer.c_str()); + beta_v = beta_v * deg; + ConfigFile >> DataBuffer; + beta_w = atof(DataBuffer.c_str()); + beta_w = beta_w * deg; + G4cout << "Beta: " << beta_u / deg << " " << beta_v / deg << " " << beta_w / deg << G4endl; + } + else if (DataBuffer.compare(0, 11, "FIRSTSTAGE=") == 0) { + check_FirstStage = true; + ConfigFile >> DataBuffer; + FIRSTSTAGE = atof(DataBuffer.c_str()); + } + else if (DataBuffer.compare(0, 12, "SECONDSTAGE=") == 0) { + check_SecondStage = true; + ConfigFile >> DataBuffer; + SECONDSTAGE = atof(DataBuffer.c_str()); + } -// Set the TinteractionCoordinates object from NPS::VDetector to the present class -void Hyde2TrackerTrapezoid2::SetInterCoordPointer(TInteractionCoordinates* interCoord) -{ - ms_InterCoord = interCoord; + else if (DataBuffer.compare(0, 11, "THIRDSTAGE=") == 0) { + check_ThirdStage = true; + ConfigFile >> DataBuffer; + THIRDSTAGE = atof(DataBuffer.c_str()); + } + + else if (DataBuffer.compare(0, 12, "FOURTHSTAGE=") == 0) { + check_FourthStage = true; + ConfigFile >> DataBuffer; + FOURTHSTAGE = atof(DataBuffer.c_str()); + } + + else if (DataBuffer.compare(0, 11, "FIFTHSTAGE=") == 0) { + check_FifthStage = true; + ConfigFile >> DataBuffer; + FIFTHSTAGE = atof(DataBuffer.c_str()); + } + + else if (DataBuffer.compare(0, 11, "SIXTHSTAGE=") == 0) { + check_SixthStage = true; + ConfigFile >> DataBuffer; + SIXTHSTAGE = atof(DataBuffer.c_str()); + } + + else if (DataBuffer.compare(0, 4, "VIS=") == 0) { + checkVis = true; + ConfigFile >> DataBuffer; + if (DataBuffer.compare(0, 3, "all") == 0) + m_non_sensitive_part_visiualisation = true; + } + + else + G4cout << "WARNING: Wrong Token, Hyde2TrackerTrapezoid2: Trapezoid2 Element not added" << G4endl; + + // Add The previously define telescope + // With position method + if ((check_A && check_B && check_C && check_D && check_FirstStage && check_SecondStage && check_ThirdStage && + check_FourthStage && check_FifthStage && check_SixthStage && checkVis) && + !(check_Theta && check_Phi && check_R)) { + + ReadingStatus = false; + check_A = false; + check_C = false; + check_B = false; + check_D = false; + check_FirstStage = false; + check_SecondStage = false; + check_ThirdStage = false; + check_FourthStage = false; + check_FifthStage = false; + check_SixthStage = false; + checkVis = false; + + AddModule(A, B, C, D, FIRSTSTAGE == 1, SECONDSTAGE == 1, THIRDSTAGE == 1, FOURTHSTAGE == 1, FIFTHSTAGE == 1, + SIXTHSTAGE == 1); + } + + // with angle method + if ((check_Theta && check_Phi && check_R && check_FirstStage && check_SecondStage && check_ThirdStage && + check_FourthStage && check_FifthStage && check_SixthStage && checkVis) && + !(check_A && check_B && check_C && check_D)) { + ReadingStatus = false; + check_Theta = false; + check_Phi = false; + check_R = false; + // check_beta = false ; + check_FirstStage = false; + check_SecondStage = false; + check_ThirdStage = false; + check_FourthStage = false; + check_FifthStage = false; + check_SixthStage = false; + checkVis = false; + + AddModule(R, Theta, Phi, beta_u, beta_v, beta_w, FIRSTSTAGE == 1, SECONDSTAGE == 1, THIRDSTAGE == 1, + FOURTHSTAGE == 1, FIFTHSTAGE == 1, SIXTHSTAGE == 1); + } + } + } } +// Construct detector and inialise sensitive part. +// Called After DetecorConstruction::AddDetector Method +void Hyde2TrackerTrapezoid2::ConstructDetector(G4LogicalVolume* world) { + G4RotationMatrix* MMrot = NULL; + G4ThreeVector MMpos = G4ThreeVector(0, 0, 0); + G4ThreeVector MMu = G4ThreeVector(0, 0, 0); + G4ThreeVector MMv = G4ThreeVector(0, 0, 0); + G4ThreeVector MMw = G4ThreeVector(0, 0, 0); + G4ThreeVector MMCenter = G4ThreeVector(0, 0, 0); + + bool FirstStage = true; + bool SecondStage = true; + bool ThirdStage = true; + bool FourthStage = true; + bool FifthStage = true; + bool SixthStage = true; + + G4int NumberOfModule = m_DefinitionType.size(); + + for (G4int i = 0; i < NumberOfModule; i++) { + // By Point + if (m_DefinitionType[i]) { + // (u,v,w) unitary vector associated to trapezoidal referencial + // (u,v) // to silicon plan + // ------- + // / \ ^ + // / \ | v + // / \ | + // --------------- <------ + // u + // w perpendicular to (u,v) plan and pointing ThirdStage + G4cout << "XXXXXXXXXXXX Trapezoid2 " << i << " XXXXXXXXXXXXX" << G4endl; + MMu = m_X128_Y1[i] - m_X1_Y1[i]; + MMu = MMu.unit(); + G4cout << "MMu: " << MMu << G4endl; + + MMv = 0.5 * (m_X1_Y128[i] + m_X128_Y128[i] - m_X1_Y1[i] - m_X128_Y1[i]); + MMv = MMv.unit(); + G4cout << "MMv: " << MMv << G4endl; + + MMw = MMu.cross(MMv); + MMw = MMw.unit(); + G4cout << "MMw: " << MMw << G4endl; + + // Center of the module + MMCenter = (m_X1_Y1[i] + m_X1_Y128[i] + m_X128_Y1[i] + m_X128_Y128[i]) / 4; + + // Passage Matrix from Lab Referential to Module Referential + MMrot = new G4RotationMatrix(MMu, MMv, MMw); + // translation to place Module + MMpos = MMw * Length * 0.5 + MMCenter; + } + + // By Angle + else { + G4double Theta = m_Theta[i]; + G4double Phi = m_Phi[i]; + + // (u,v,w) unitary vector associated to telescope referencial + // (u,v) // to silicon plan + // ------- + // / \ ^ + // / \ | v + // / \ | + // --------------- <------ + // u + // w perpendicular to (u,v) plan and pointing ThirdStage + // Phi is angle between X axis and projection in (X,Y) plan + // Theta is angle between position vector and z axis + G4double wX = m_R[i] * sin(Theta / rad) * cos(Phi / rad); + G4double wY = m_R[i] * sin(Theta / rad) * sin(Phi / rad); + G4double wZ = m_R[i] * cos(Theta / rad); + MMw = G4ThreeVector(wX, wY, wZ); + + // vector corresponding to the center of the module + MMCenter = MMw; + + // vector parallel to one axis of silicon plane + // in fact, this is vector u + G4double ii = cos(Theta / rad) * cos(Phi / rad); + G4double jj = cos(Theta / rad) * sin(Phi / rad); + G4double kk = -sin(Theta / rad); + G4ThreeVector Y = G4ThreeVector(ii, jj, kk); + + MMw = MMw.unit(); + MMv = MMw.cross(Y); + MMu = MMv.cross(MMw); + MMv = MMv.unit(); + MMu = MMu.unit(); + + G4cout << "XXXXXXXXXXXX Trapezoid2 " << i << " XXXXXXXXXXXXX" << G4endl; + G4cout << "MMu: " << MMu << G4endl; + G4cout << "MMv: " << MMv << G4endl; + G4cout << "MMw: " << MMw << G4endl; + + // Passage Matrix from Lab Referential to Telescope Referential + MMrot = new G4RotationMatrix(MMu, MMv, MMw); + // Telescope is rotate of Beta angle around MMv axis. + MMrot->rotate(m_beta_u[i], MMu); + MMrot->rotate(m_beta_v[i], MMv); + MMrot->rotate(m_beta_w[i], MMw); + // translation to place Telescope + MMpos = MMw * Length * 0.5 + MMCenter; + } + + FirstStage = m_wFirstStage[i]; + SecondStage = m_wSecondStage[i]; + ThirdStage = m_wThirdStage[i]; + FourthStage = m_wFourthStage[i]; + FifthStage = m_wFifthStage[i]; + SixthStage = m_wSixthStage[i]; + + VolumeMaker(i + 1, MMpos, MMrot, FirstStage, SecondStage, ThirdStage, FourthStage, FifthStage, SixthStage, world); + } + + delete MMrot; +} +// Connect the Hyde2TrackingData class to the output TTree +// of the simulation +void Hyde2TrackerTrapezoid2::InitializeRootOutput() {} + +// Set the TinteractionCoordinates object from NPS::VDetector to the present class +void Hyde2TrackerTrapezoid2::SetInterCoordPointer(TInteractionCoordinates* interCoord) { ms_InterCoord = interCoord; } // Read sensitive part and fill the Root tree. // Called at in the EventAction::EndOfEventAvtion -void Hyde2TrackerTrapezoid2::ReadSensitive(const G4Event* event) -{ -////////////////////////////////////////////////////////////////////////////////////// -//////////////////////// Used to Read Event Map of detector ////////////////////////// -////////////////////////////////////////////////////////////////////////////////////// - // First Stage - std::map<G4int, G4int*>::iterator DetectorNumber_itr; - std::map<G4int, G4double*>::iterator Energy_itr; - std::map<G4int, G4double*>::iterator Time_itr; - std::map<G4int, G4double*>::iterator X_itr; - std::map<G4int, G4double*>::iterator Y_itr; - std::map<G4int, G4double*>::iterator Pos_X_itr; - std::map<G4int, G4double*>::iterator Pos_Y_itr; - std::map<G4int, G4double*>::iterator Pos_Z_itr; - std::map<G4int, G4double*>::iterator Ang_Theta_itr; - std::map<G4int, G4double*>::iterator Ang_Phi_itr; - - G4THitsMap<G4int>* DetectorNumberHitMap; - G4THitsMap<G4double>* EnergyHitMap; - G4THitsMap<G4double>* TimeHitMap; - G4THitsMap<G4double>* XHitMap; - G4THitsMap<G4double>* YHitMap; - G4THitsMap<G4double>* PosXHitMap; - G4THitsMap<G4double>* PosYHitMap; - G4THitsMap<G4double>* PosZHitMap; - G4THitsMap<G4double>* AngThetaHitMap; - G4THitsMap<G4double>* AngPhiHitMap; - - // NULL pointer are given to avoid warning at compilation - // Second Stage - std::map<G4int, G4double*>::iterator SecondStageEnergy_itr; - G4THitsMap<G4double>* SecondStageEnergyHitMap = NULL; - // Third Stage - std::map<G4int, G4double*>::iterator ThirdStageEnergy_itr; - G4THitsMap<G4double>* ThirdStageEnergyHitMap = NULL; - - // Fourth Stage - std::map<G4int, G4double*>::iterator FourthStageEnergy_itr; - G4THitsMap<G4double>* FourthStageEnergyHitMap = NULL; - - // Fifth Stage - std::map<G4int, G4double*>::iterator FifthStageEnergy_itr; - G4THitsMap<G4double>* FifthStageEnergyHitMap = NULL; - - // Sixth Stage - std::map<G4int, G4double*>::iterator SixthStageEnergy_itr; - G4THitsMap<G4double>* SixthStageEnergyHitMap = NULL; - - // Read the Scorer associated to the first Stage - //Detector Number - G4int StripDetCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid2/DetectorNumber") ; - DetectorNumberHitMap = (G4THitsMap<G4int>*)(event->GetHCofThisEvent()->GetHC(StripDetCollectionID)) ; - DetectorNumber_itr = DetectorNumberHitMap->GetMap()->begin() ; - - //Energy - G4int StripEnergyCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid2/StripEnergy") ; - EnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripEnergyCollectionID)) ; - Energy_itr = EnergyHitMap->GetMap()->begin() ; - - //Time of Flight - G4int StripTimeCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid2/StripTime") ; - TimeHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripTimeCollectionID)) ; - Time_itr = TimeHitMap->GetMap()->begin() ; - - //Strip Number X - G4int StripXCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid2/StripNumberX") ; - XHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripXCollectionID)) ; - X_itr = XHitMap->GetMap()->begin() ; - - //Strip Number Y - G4int StripYCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid2/StripNumberY") ; - YHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripYCollectionID)) ; - Y_itr = YHitMap->GetMap()->begin() ; - - //Interaction Coordinate X - G4int InterCoordXCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid2/InterCoordX") ; - PosXHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordXCollectionID)) ; - Pos_X_itr = PosXHitMap->GetMap()->begin() ; - - //Interaction Coordinate Y - G4int InterCoordYCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid2/InterCoordY") ; - PosYHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordYCollectionID)) ; - Pos_Y_itr = PosYHitMap->GetMap()->begin() ; - - //Interaction Coordinate Z - G4int InterCoordZCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid2/InterCoordZ") ; - PosZHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordZCollectionID)) ; - Pos_Z_itr = PosXHitMap->GetMap()->begin() ; - - //Interaction Coordinate Angle Theta - G4int InterCoordAngThetaCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid2/InterCoordAngTheta") ; - AngThetaHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordAngThetaCollectionID)) ; - Ang_Theta_itr = AngThetaHitMap->GetMap()->begin() ; - - //Interaction Coordinate Angle Phi - G4int InterCoordAngPhiCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid2/InterCoordAngPhi") ; - AngPhiHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordAngPhiCollectionID)) ; - Ang_Phi_itr = AngPhiHitMap->GetMap()->begin() ; - - // Read the Scorer associated to the Second and Third Stage - // Energy second stage - G4int SecondStageEnergyCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("SecondStageScorerHYD2Trapezoid2/SecondStageEnergy") ; - SecondStageEnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(SecondStageEnergyCollectionID)) ; - SecondStageEnergy_itr = SecondStageEnergyHitMap->GetMap()->begin() ; - // Energy third stage - G4int ThirdStageEnergyCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("ThirdStageScorerHYD2Trapezoid2/ThirdStageEnergy") ; - ThirdStageEnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(ThirdStageEnergyCollectionID)) ; - ThirdStageEnergy_itr = ThirdStageEnergyHitMap->GetMap()->begin() ; - // Energy Fourth stage - G4int FourthStageEnergyCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FourthStageScorerHYD2Trapezoid2/FourthStageEnergy") ; - FourthStageEnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(FourthStageEnergyCollectionID)) ; - FourthStageEnergy_itr = FourthStageEnergyHitMap->GetMap()->begin() ; - // Energy Fifth stage - G4int FifthStageEnergyCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("FifthStageScorerHYD2Trapezoid2/FifthStageEnergy") ; - FifthStageEnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(FifthStageEnergyCollectionID)) ; - FifthStageEnergy_itr = FifthStageEnergyHitMap->GetMap()->begin() ; - // Energy Sixth stage - G4int SixthStageEnergyCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("SixthStageScorerHYD2Trapezoid2/SixthStageEnergy") ; - SixthStageEnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(SixthStageEnergyCollectionID)) ; - SixthStageEnergy_itr = SixthStageEnergyHitMap->GetMap()->begin() ; - - // Check the size of different map - G4int sizeN = DetectorNumberHitMap->entries(); - G4int sizeE = EnergyHitMap->entries(); - G4int sizeT = TimeHitMap->entries(); - G4int sizeX = XHitMap->entries(); - G4int sizeY = YHitMap->entries(); - - if (sizeE != sizeT || sizeT != sizeX || sizeX != sizeY) { - G4cout << "No match size Si Event Map: sE:" - << sizeE << " sT:" << sizeT << " sX:" << sizeX << " sY:" << sizeY << G4endl ; - return; +void Hyde2TrackerTrapezoid2::ReadSensitive(const G4Event* event) { + ////////////////////////////////////////////////////////////////////////////////////// + //////////////////////// Used to Read Event Map of detector ////////////////////////// + ////////////////////////////////////////////////////////////////////////////////////// + // First Stage + std::map<G4int, G4int*>::iterator DetectorNumber_itr; + std::map<G4int, G4double*>::iterator Energy_itr; + std::map<G4int, G4double*>::iterator Time_itr; + std::map<G4int, G4double*>::iterator X_itr; + std::map<G4int, G4double*>::iterator Y_itr; + std::map<G4int, G4double*>::iterator Pos_X_itr; + std::map<G4int, G4double*>::iterator Pos_Y_itr; + std::map<G4int, G4double*>::iterator Pos_Z_itr; + std::map<G4int, G4double*>::iterator Ang_Theta_itr; + std::map<G4int, G4double*>::iterator Ang_Phi_itr; + + G4THitsMap<G4int>* DetectorNumberHitMap; + G4THitsMap<G4double>* EnergyHitMap; + G4THitsMap<G4double>* TimeHitMap; + G4THitsMap<G4double>* XHitMap; + G4THitsMap<G4double>* YHitMap; + G4THitsMap<G4double>* PosXHitMap; + G4THitsMap<G4double>* PosYHitMap; + G4THitsMap<G4double>* PosZHitMap; + G4THitsMap<G4double>* AngThetaHitMap; + G4THitsMap<G4double>* AngPhiHitMap; + + // NULL pointer are given to avoid warning at compilation + // Second Stage + std::map<G4int, G4double*>::iterator SecondStageEnergy_itr; + G4THitsMap<G4double>* SecondStageEnergyHitMap = NULL; + // Third Stage + std::map<G4int, G4double*>::iterator ThirdStageEnergy_itr; + G4THitsMap<G4double>* ThirdStageEnergyHitMap = NULL; + + // Fourth Stage + std::map<G4int, G4double*>::iterator FourthStageEnergy_itr; + G4THitsMap<G4double>* FourthStageEnergyHitMap = NULL; + + // Fifth Stage + std::map<G4int, G4double*>::iterator FifthStageEnergy_itr; + G4THitsMap<G4double>* FifthStageEnergyHitMap = NULL; + + // Sixth Stage + std::map<G4int, G4double*>::iterator SixthStageEnergy_itr; + G4THitsMap<G4double>* SixthStageEnergyHitMap = NULL; + + // Read the Scorer associated to the first Stage + // Detector Number + G4int StripDetCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid2/DetectorNumber"); + DetectorNumberHitMap = (G4THitsMap<G4int>*)(event->GetHCofThisEvent()->GetHC(StripDetCollectionID)); + DetectorNumber_itr = DetectorNumberHitMap->GetMap()->begin(); + + // Energy + G4int StripEnergyCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid2/StripEnergy"); + EnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripEnergyCollectionID)); + Energy_itr = EnergyHitMap->GetMap()->begin(); + + // Time of Flight + G4int StripTimeCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid2/StripTime"); + TimeHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripTimeCollectionID)); + Time_itr = TimeHitMap->GetMap()->begin(); + + // Strip Number X + G4int StripXCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid2/StripNumberX"); + XHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripXCollectionID)); + X_itr = XHitMap->GetMap()->begin(); + + // Strip Number Y + G4int StripYCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid2/StripNumberY"); + YHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripYCollectionID)); + Y_itr = YHitMap->GetMap()->begin(); + + // Interaction Coordinate X + G4int InterCoordXCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid2/InterCoordX"); + PosXHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordXCollectionID)); + Pos_X_itr = PosXHitMap->GetMap()->begin(); + + // Interaction Coordinate Y + G4int InterCoordYCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid2/InterCoordY"); + PosYHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordYCollectionID)); + Pos_Y_itr = PosYHitMap->GetMap()->begin(); + + // Interaction Coordinate Z + G4int InterCoordZCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid2/InterCoordZ"); + PosZHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordZCollectionID)); + Pos_Z_itr = PosXHitMap->GetMap()->begin(); + + // Interaction Coordinate Angle Theta + G4int InterCoordAngThetaCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid2/InterCoordAngTheta"); + AngThetaHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordAngThetaCollectionID)); + Ang_Theta_itr = AngThetaHitMap->GetMap()->begin(); + + // Interaction Coordinate Angle Phi + G4int InterCoordAngPhiCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("FirstStageScorerHYD2Trapezoid2/InterCoordAngPhi"); + AngPhiHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordAngPhiCollectionID)); + Ang_Phi_itr = AngPhiHitMap->GetMap()->begin(); + + // Read the Scorer associated to the Second and Third Stage + // Energy second stage + G4int SecondStageEnergyCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("SecondStageScorerHYD2Trapezoid2/SecondStageEnergy"); + SecondStageEnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(SecondStageEnergyCollectionID)); + SecondStageEnergy_itr = SecondStageEnergyHitMap->GetMap()->begin(); + // Energy third stage + G4int ThirdStageEnergyCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("ThirdStageScorerHYD2Trapezoid2/ThirdStageEnergy"); + ThirdStageEnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(ThirdStageEnergyCollectionID)); + ThirdStageEnergy_itr = ThirdStageEnergyHitMap->GetMap()->begin(); + // Energy Fourth stage + G4int FourthStageEnergyCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("FourthStageScorerHYD2Trapezoid2/FourthStageEnergy"); + FourthStageEnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(FourthStageEnergyCollectionID)); + FourthStageEnergy_itr = FourthStageEnergyHitMap->GetMap()->begin(); + // Energy Fifth stage + G4int FifthStageEnergyCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("FifthStageScorerHYD2Trapezoid2/FifthStageEnergy"); + FifthStageEnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(FifthStageEnergyCollectionID)); + FifthStageEnergy_itr = FifthStageEnergyHitMap->GetMap()->begin(); + // Energy Sixth stage + G4int SixthStageEnergyCollectionID = + G4SDManager::GetSDMpointer()->GetCollectionID("SixthStageScorerHYD2Trapezoid2/SixthStageEnergy"); + SixthStageEnergyHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(SixthStageEnergyCollectionID)); + SixthStageEnergy_itr = SixthStageEnergyHitMap->GetMap()->begin(); + + // Check the size of different map + G4int sizeN = DetectorNumberHitMap->entries(); + G4int sizeE = EnergyHitMap->entries(); + G4int sizeT = TimeHitMap->entries(); + G4int sizeX = XHitMap->entries(); + G4int sizeY = YHitMap->entries(); + + if (sizeE != sizeT || sizeT != sizeX || sizeX != sizeY) { + G4cout << "No match size Si Event Map: sE:" << sizeE << " sT:" << sizeT << " sX:" << sizeX << " sY:" << sizeY + << G4endl; + return; + } + + // Loop on FirstStage number + for (G4int l = 0; l < sizeN; l++) { + G4double N = *(DetectorNumber_itr->second); + G4int NTrackID = DetectorNumber_itr->first - N; + + if (N > 0) { + // Fill detector number + ms_Event->SetHYD2TrkFirstStageFrontEDetectorNbr(m_index["Trapezoid2"] + N); + ms_Event->SetHYD2TrkFirstStageFrontTDetectorNbr(m_index["Trapezoid2"] + N); + ms_Event->SetHYD2TrkFirstStageBackEDetectorNbr(m_index["Trapezoid2"] + N); + ms_Event->SetHYD2TrkFirstStageBackTDetectorNbr(m_index["Trapezoid2"] + N); + + // Energy + for (G4int ll = 0; ll < sizeE; ll++) { + G4int ETrackID = Energy_itr->first - N; + G4double E = *(Energy_itr->second); + if (ETrackID == NTrackID) { + ms_Event->SetHYD2TrkFirstStageFrontEEnergy(RandGauss::shoot(E, ResoFirstStage)); + ms_Event->SetHYD2TrkFirstStageBackEEnergy(RandGauss::shoot(E, ResoFirstStage)); + } + Energy_itr++; } - // Loop on FirstStage number - for (G4int l = 0; l < sizeN; l++) { - G4double N = *(DetectorNumber_itr->second); - G4int NTrackID = DetectorNumber_itr->first - N; - - if (N > 0) { - // Fill detector number - ms_Event->SetHYD2TrkFirstStageFrontEDetectorNbr(m_index["Trapezoid2"] + N); - ms_Event->SetHYD2TrkFirstStageFrontTDetectorNbr(m_index["Trapezoid2"] + N); - ms_Event->SetHYD2TrkFirstStageBackEDetectorNbr(m_index["Trapezoid2"] + N); - ms_Event->SetHYD2TrkFirstStageBackTDetectorNbr(m_index["Trapezoid2"] + N); - - // Energy - for (G4int ll = 0 ; ll < sizeE ; ll++) { - G4int ETrackID = Energy_itr->first - N; - G4double E = *(Energy_itr->second); - if (ETrackID == NTrackID) { - ms_Event->SetHYD2TrkFirstStageFrontEEnergy(RandGauss::shoot(E, ResoFirstStage)); - ms_Event->SetHYD2TrkFirstStageBackEEnergy(RandGauss::shoot(E, ResoFirstStage)); - } - 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) { - T = RandGauss::shoot(T, ResoTimePPAC) ; - ms_Event->SetHYD2TrkFirstStageFrontTTime(RandGauss::shoot(T, ResoTimeHyd2)) ; - ms_Event->SetHYD2TrkFirstStageBackTTime(RandGauss::shoot(T, ResoTimeHyd2)) ; - } - Time_itr++; - } - - // X - X_itr = XHitMap->GetMap()->begin(); - for (G4int h = 0 ; h < sizeX ; h++) { - G4int XTrackID = X_itr->first - N; - G4double X = *(X_itr->second); - if (XTrackID == NTrackID) { - ms_Event->SetHYD2TrkFirstStageFrontEStripNbr(X); - ms_Event->SetHYD2TrkFirstStageFrontTStripNbr(X); - } - - X_itr++; - } - - // Y - Y_itr = YHitMap->GetMap()->begin() ; - for (G4int h = 0 ; h < sizeY ; h++) { - G4int YTrackID = Y_itr->first - N; - G4double Y = *(Y_itr->second); - if (YTrackID == NTrackID) { - ms_Event->SetHYD2TrkFirstStageBackEStripNbr(Y); - ms_Event->SetHYD2TrkFirstStageBackTStripNbr(Y); - } - - Y_itr++; - } - - // Pos X - Pos_X_itr = PosXHitMap->GetMap()->begin(); - for (unsigned int h = 0; h < PosXHitMap->entries(); h++) { - G4int PosXTrackID = Pos_X_itr->first - N ; - G4double PosX = *(Pos_X_itr->second) ; - if (PosXTrackID == NTrackID) { - ms_InterCoord->SetDetectedPositionX(PosX) ; - } - Pos_X_itr++; - } - - // Pos Y - Pos_Y_itr = PosYHitMap->GetMap()->begin(); - for (unsigned int h = 0; h < PosYHitMap->entries(); h++) { - G4int PosYTrackID = Pos_Y_itr->first - N ; - G4double PosY = *(Pos_Y_itr->second) ; - if (PosYTrackID == NTrackID) { - ms_InterCoord->SetDetectedPositionY(PosY) ; - } - Pos_Y_itr++; - } - - // Pos Z - Pos_Z_itr = PosZHitMap->GetMap()->begin(); - for (unsigned int h = 0; h < PosZHitMap->entries(); h++) { - G4int PosZTrackID = Pos_Z_itr->first - N ; - G4double PosZ = *(Pos_Z_itr->second) ; - if (PosZTrackID == NTrackID) { - ms_InterCoord->SetDetectedPositionZ(PosZ) ; - } - Pos_Z_itr++; - } - - // Angle Theta - Ang_Theta_itr = AngThetaHitMap->GetMap()->begin(); - for (unsigned int h = 0; h < AngThetaHitMap->entries(); h++) { - G4int AngThetaTrackID = Ang_Theta_itr->first - N ; - G4double AngTheta = *(Ang_Theta_itr->second) ; - if (AngThetaTrackID == NTrackID) { - ms_InterCoord->SetDetectedAngleTheta(AngTheta) ; - } - Ang_Theta_itr++; - } - - // Angle Phi - Ang_Phi_itr = AngPhiHitMap->GetMap()->begin(); - for (unsigned int h = 0; h < AngPhiHitMap->entries(); h++) { - G4int AngPhiTrackID = Ang_Phi_itr->first - N ; - G4double AngPhi = *(Ang_Phi_itr->second) ; - if (AngPhiTrackID == NTrackID) { - ms_InterCoord->SetDetectedAnglePhi(AngPhi) ; - } - Ang_Phi_itr++; - } - - // Second Stage - SecondStageEnergy_itr = SecondStageEnergyHitMap->GetMap()->begin() ; - for (unsigned int h = 0 ; h < SecondStageEnergyHitMap->entries() ; h++) { - G4int SecondStageEnergyTrackID = SecondStageEnergy_itr->first - N; - G4double SecondStageEnergy = *(SecondStageEnergy_itr->second); - - if (SecondStageEnergyTrackID == NTrackID) { - ms_Event->SetHYD2TrkSecondStageEEnergy(RandGauss::shoot(SecondStageEnergy, ResoSecondStage)); - ms_Event->SetHYD2TrkSecondStageEPadNbr(1); - ms_Event->SetHYD2TrkSecondStageTPadNbr(1); - ms_Event->SetHYD2TrkSecondStageTTime(1); - ms_Event->SetHYD2TrkSecondStageTDetectorNbr(m_index["Trapezoid2"] + N); - ms_Event->SetHYD2TrkSecondStageEDetectorNbr(m_index["Trapezoid2"] + N); - } - - SecondStageEnergy_itr++; - } - - // Third Stage - ThirdStageEnergy_itr = ThirdStageEnergyHitMap->GetMap()->begin() ; - for (unsigned int h = 0 ; h < ThirdStageEnergyHitMap->entries() ; h++) { - G4int ThirdStageEnergyTrackID = ThirdStageEnergy_itr->first - N; - G4double ThirdStageEnergy = *(ThirdStageEnergy_itr->second); - - if (ThirdStageEnergyTrackID == NTrackID) { - ms_Event->SetHYD2TrkThirdStageEEnergy(RandGauss::shoot(ThirdStageEnergy, ResoThirdStage)); - ms_Event->SetHYD2TrkThirdStageEPadNbr(1); - ms_Event->SetHYD2TrkThirdStageTPadNbr(1); - ms_Event->SetHYD2TrkThirdStageTTime(1); - ms_Event->SetHYD2TrkThirdStageTDetectorNbr(m_index["Trapezoid2"] + N); - ms_Event->SetHYD2TrkThirdStageEDetectorNbr(m_index["Trapezoid2"] + N); - } - - ThirdStageEnergy_itr++; - } - - // Fourth Stage - FourthStageEnergy_itr = FourthStageEnergyHitMap->GetMap()->begin() ; - for (unsigned int h = 0 ; h < FourthStageEnergyHitMap->entries() ; h++) { - G4int FourthStageEnergyTrackID = FourthStageEnergy_itr->first - N; - G4double FourthStageEnergy = *(FourthStageEnergy_itr->second); - - if (FourthStageEnergyTrackID == NTrackID) { - ms_Event->SetHYD2TrkFourthStageEEnergy(RandGauss::shoot(FourthStageEnergy, ResoFourthStage)); - ms_Event->SetHYD2TrkFourthStageEPadNbr(1); - ms_Event->SetHYD2TrkFourthStageTPadNbr(1); - ms_Event->SetHYD2TrkFourthStageTTime(1); - ms_Event->SetHYD2TrkFourthStageTDetectorNbr(m_index["Trapezoid2"] + N); - ms_Event->SetHYD2TrkFourthStageEDetectorNbr(m_index["Trapezoid2"] + N); - } - - FourthStageEnergy_itr++; - } - - // Fifth Stage - FifthStageEnergy_itr = FifthStageEnergyHitMap->GetMap()->begin() ; - for (unsigned int h = 0 ; h < FifthStageEnergyHitMap->entries() ; h++) { - G4int FifthStageEnergyTrackID = FifthStageEnergy_itr->first - N; - G4double FifthStageEnergy = *(FifthStageEnergy_itr->second); - - if (FifthStageEnergyTrackID == NTrackID) { - ms_Event->SetHYD2TrkFifthStageEEnergy(RandGauss::shoot(FifthStageEnergy, ResoFifthStage)); - ms_Event->SetHYD2TrkFifthStageEPadNbr(1); - ms_Event->SetHYD2TrkFifthStageTPadNbr(1); - ms_Event->SetHYD2TrkFifthStageTTime(1); - ms_Event->SetHYD2TrkFifthStageTDetectorNbr(m_index["Trapezoid2"] + N); - ms_Event->SetHYD2TrkFifthStageEDetectorNbr(m_index["Trapezoid2"] + N); - } - - FifthStageEnergy_itr++; - } - - // Sixth Stage - SixthStageEnergy_itr = SixthStageEnergyHitMap->GetMap()->begin() ; - for (unsigned int h = 0 ; h < SixthStageEnergyHitMap->entries() ; h++) { - G4int SixthStageEnergyTrackID = SixthStageEnergy_itr->first - N; - G4double SixthStageEnergy = *(SixthStageEnergy_itr->second); - - if (SixthStageEnergyTrackID == NTrackID) { - ms_Event->SetHYD2TrkSixthStageEEnergy(RandGauss::shoot(SixthStageEnergy, ResoSixthStage)); - ms_Event->SetHYD2TrkSixthStageEPadNbr(1); - ms_Event->SetHYD2TrkSixthStageTPadNbr(1); - ms_Event->SetHYD2TrkSixthStageTTime(1); - ms_Event->SetHYD2TrkSixthStageTDetectorNbr(m_index["Trapezoid2"] + N); - ms_Event->SetHYD2TrkSixthStageEDetectorNbr(m_index["Trapezoid2"] + N); - } - - SixthStageEnergy_itr++; - } - - DetectorNumber_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) { + T = RandGauss::shoot(T, ResoTimePPAC); + ms_Event->SetHYD2TrkFirstStageFrontTTime(RandGauss::shoot(T, ResoTimeHyd2)); + ms_Event->SetHYD2TrkFirstStageBackTTime(RandGauss::shoot(T, ResoTimeHyd2)); + } + Time_itr++; } - // clear map for next event - DetectorNumberHitMap ->clear(); - EnergyHitMap ->clear(); - TimeHitMap ->clear(); - XHitMap ->clear(); - YHitMap ->clear(); - PosXHitMap ->clear(); - PosYHitMap ->clear(); - PosZHitMap ->clear(); - AngThetaHitMap ->clear(); - AngPhiHitMap ->clear(); - SecondStageEnergyHitMap ->clear(); - ThirdStageEnergyHitMap ->clear(); - FourthStageEnergyHitMap ->clear(); - FifthStageEnergyHitMap ->clear(); - SixthStageEnergyHitMap ->clear(); - } -} + // X + X_itr = XHitMap->GetMap()->begin(); + for (G4int h = 0; h < sizeX; h++) { + G4int XTrackID = X_itr->first - N; + G4double X = *(X_itr->second); + if (XTrackID == NTrackID) { + ms_Event->SetHYD2TrkFirstStageFrontEStripNbr(X); + ms_Event->SetHYD2TrkFirstStageFrontTStripNbr(X); + } + + X_itr++; + } + // Y + Y_itr = YHitMap->GetMap()->begin(); + for (G4int h = 0; h < sizeY; h++) { + G4int YTrackID = Y_itr->first - N; + G4double Y = *(Y_itr->second); + if (YTrackID == NTrackID) { + ms_Event->SetHYD2TrkFirstStageBackEStripNbr(Y); + ms_Event->SetHYD2TrkFirstStageBackTStripNbr(Y); + } + + Y_itr++; + } + + // Pos X + Pos_X_itr = PosXHitMap->GetMap()->begin(); + for (unsigned int h = 0; h < PosXHitMap->entries(); h++) { + G4int PosXTrackID = Pos_X_itr->first - N; + G4double PosX = *(Pos_X_itr->second); + if (PosXTrackID == NTrackID) { + ms_InterCoord->SetDetectedPositionX(PosX); + } + Pos_X_itr++; + } + + // Pos Y + Pos_Y_itr = PosYHitMap->GetMap()->begin(); + for (unsigned int h = 0; h < PosYHitMap->entries(); h++) { + G4int PosYTrackID = Pos_Y_itr->first - N; + G4double PosY = *(Pos_Y_itr->second); + if (PosYTrackID == NTrackID) { + ms_InterCoord->SetDetectedPositionY(PosY); + } + Pos_Y_itr++; + } + + // Pos Z + Pos_Z_itr = PosZHitMap->GetMap()->begin(); + for (unsigned int h = 0; h < PosZHitMap->entries(); h++) { + G4int PosZTrackID = Pos_Z_itr->first - N; + G4double PosZ = *(Pos_Z_itr->second); + if (PosZTrackID == NTrackID) { + ms_InterCoord->SetDetectedPositionZ(PosZ); + } + Pos_Z_itr++; + } + + // Angle Theta + Ang_Theta_itr = AngThetaHitMap->GetMap()->begin(); + for (unsigned int h = 0; h < AngThetaHitMap->entries(); h++) { + G4int AngThetaTrackID = Ang_Theta_itr->first - N; + G4double AngTheta = *(Ang_Theta_itr->second); + if (AngThetaTrackID == NTrackID) { + ms_InterCoord->SetDetectedAngleTheta(AngTheta); + } + Ang_Theta_itr++; + } + + // Angle Phi + Ang_Phi_itr = AngPhiHitMap->GetMap()->begin(); + for (unsigned int h = 0; h < AngPhiHitMap->entries(); h++) { + G4int AngPhiTrackID = Ang_Phi_itr->first - N; + G4double AngPhi = *(Ang_Phi_itr->second); + if (AngPhiTrackID == NTrackID) { + ms_InterCoord->SetDetectedAnglePhi(AngPhi); + } + Ang_Phi_itr++; + } + // Second Stage + SecondStageEnergy_itr = SecondStageEnergyHitMap->GetMap()->begin(); + for (unsigned int h = 0; h < SecondStageEnergyHitMap->entries(); h++) { + G4int SecondStageEnergyTrackID = SecondStageEnergy_itr->first - N; + G4double SecondStageEnergy = *(SecondStageEnergy_itr->second); + + if (SecondStageEnergyTrackID == NTrackID) { + ms_Event->SetHYD2TrkSecondStageEEnergy(RandGauss::shoot(SecondStageEnergy, ResoSecondStage)); + ms_Event->SetHYD2TrkSecondStageEPadNbr(1); + ms_Event->SetHYD2TrkSecondStageTPadNbr(1); + ms_Event->SetHYD2TrkSecondStageTTime(1); + ms_Event->SetHYD2TrkSecondStageTDetectorNbr(m_index["Trapezoid2"] + N); + ms_Event->SetHYD2TrkSecondStageEDetectorNbr(m_index["Trapezoid2"] + N); + } + + SecondStageEnergy_itr++; + } + + // Third Stage + ThirdStageEnergy_itr = ThirdStageEnergyHitMap->GetMap()->begin(); + for (unsigned int h = 0; h < ThirdStageEnergyHitMap->entries(); h++) { + G4int ThirdStageEnergyTrackID = ThirdStageEnergy_itr->first - N; + G4double ThirdStageEnergy = *(ThirdStageEnergy_itr->second); + + if (ThirdStageEnergyTrackID == NTrackID) { + ms_Event->SetHYD2TrkThirdStageEEnergy(RandGauss::shoot(ThirdStageEnergy, ResoThirdStage)); + ms_Event->SetHYD2TrkThirdStageEPadNbr(1); + ms_Event->SetHYD2TrkThirdStageTPadNbr(1); + ms_Event->SetHYD2TrkThirdStageTTime(1); + ms_Event->SetHYD2TrkThirdStageTDetectorNbr(m_index["Trapezoid2"] + N); + ms_Event->SetHYD2TrkThirdStageEDetectorNbr(m_index["Trapezoid2"] + N); + } + + ThirdStageEnergy_itr++; + } + + // Fourth Stage + FourthStageEnergy_itr = FourthStageEnergyHitMap->GetMap()->begin(); + for (unsigned int h = 0; h < FourthStageEnergyHitMap->entries(); h++) { + G4int FourthStageEnergyTrackID = FourthStageEnergy_itr->first - N; + G4double FourthStageEnergy = *(FourthStageEnergy_itr->second); + + if (FourthStageEnergyTrackID == NTrackID) { + ms_Event->SetHYD2TrkFourthStageEEnergy(RandGauss::shoot(FourthStageEnergy, ResoFourthStage)); + ms_Event->SetHYD2TrkFourthStageEPadNbr(1); + ms_Event->SetHYD2TrkFourthStageTPadNbr(1); + ms_Event->SetHYD2TrkFourthStageTTime(1); + ms_Event->SetHYD2TrkFourthStageTDetectorNbr(m_index["Trapezoid2"] + N); + ms_Event->SetHYD2TrkFourthStageEDetectorNbr(m_index["Trapezoid2"] + N); + } + + FourthStageEnergy_itr++; + } + + // Fifth Stage + FifthStageEnergy_itr = FifthStageEnergyHitMap->GetMap()->begin(); + for (unsigned int h = 0; h < FifthStageEnergyHitMap->entries(); h++) { + G4int FifthStageEnergyTrackID = FifthStageEnergy_itr->first - N; + G4double FifthStageEnergy = *(FifthStageEnergy_itr->second); + + if (FifthStageEnergyTrackID == NTrackID) { + ms_Event->SetHYD2TrkFifthStageEEnergy(RandGauss::shoot(FifthStageEnergy, ResoFifthStage)); + ms_Event->SetHYD2TrkFifthStageEPadNbr(1); + ms_Event->SetHYD2TrkFifthStageTPadNbr(1); + ms_Event->SetHYD2TrkFifthStageTTime(1); + ms_Event->SetHYD2TrkFifthStageTDetectorNbr(m_index["Trapezoid2"] + N); + ms_Event->SetHYD2TrkFifthStageEDetectorNbr(m_index["Trapezoid2"] + N); + } + + FifthStageEnergy_itr++; + } + + // Sixth Stage + SixthStageEnergy_itr = SixthStageEnergyHitMap->GetMap()->begin(); + for (unsigned int h = 0; h < SixthStageEnergyHitMap->entries(); h++) { + G4int SixthStageEnergyTrackID = SixthStageEnergy_itr->first - N; + G4double SixthStageEnergy = *(SixthStageEnergy_itr->second); + + if (SixthStageEnergyTrackID == NTrackID) { + ms_Event->SetHYD2TrkSixthStageEEnergy(RandGauss::shoot(SixthStageEnergy, ResoSixthStage)); + ms_Event->SetHYD2TrkSixthStageEPadNbr(1); + ms_Event->SetHYD2TrkSixthStageTPadNbr(1); + ms_Event->SetHYD2TrkSixthStageTTime(1); + ms_Event->SetHYD2TrkSixthStageTDetectorNbr(m_index["Trapezoid2"] + N); + ms_Event->SetHYD2TrkSixthStageEDetectorNbr(m_index["Trapezoid2"] + N); + } + + SixthStageEnergy_itr++; + } + + DetectorNumber_itr++; + } + + // clear map for next event + DetectorNumberHitMap->clear(); + EnergyHitMap->clear(); + TimeHitMap->clear(); + XHitMap->clear(); + YHitMap->clear(); + PosXHitMap->clear(); + PosYHitMap->clear(); + PosZHitMap->clear(); + AngThetaHitMap->clear(); + AngPhiHitMap->clear(); + SecondStageEnergyHitMap->clear(); + ThirdStageEnergyHitMap->clear(); + FourthStageEnergyHitMap->clear(); + FifthStageEnergyHitMap->clear(); + SixthStageEnergyHitMap->clear(); + } +} -void Hyde2TrackerTrapezoid2::InitializeScorers() -{ - bool already_exist = false; - m_FirstStageScorer = NPS::VDetector::CheckScorer("FirstStageScorerHYD2Trapezoid2",already_exist); - m_SecondStageScorer = NPS::VDetector::CheckScorer("SecondStageScorerHYD2Trapezoid2",already_exist); - m_ThirdStageScorer = NPS::VDetector::CheckScorer("ThirdStageScorerHYD2Trapezoid2",already_exist); - m_FourthStageScorer = NPS::VDetector::CheckScorer("FourthStageScorerHYD2Trapezoid2",already_exist); - m_FifthStageScorer = NPS::VDetector::CheckScorer("FifthStageScorerHYD2Trapezoid2",already_exist); - m_SixthStageScorer = NPS::VDetector::CheckScorer("SixthStageScorerHYD2Trapezoid2",already_exist); - if(already_exist) return; - - - - - // First stage Associate Scorer - G4VPrimitiveScorer* DetNbr = new OBSOLETEGENERALSCORERS::PSDetectorNumber("DetectorNumber", "HYD2Trapezoid2", 0); - G4VPrimitiveScorer* TOF = new OBSOLETEGENERALSCORERS::PSTOF("StripTime","HYD2Trapezoid2", 0); - G4VPrimitiveScorer* InteractionCoordinatesX = new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesX("InterCoordX","HYD2Trapezoid2", 0); - G4VPrimitiveScorer* InteractionCoordinatesY = new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesY("InterCoordY","HYD2Trapezoid2", 0); - G4VPrimitiveScorer* InteractionCoordinatesZ = new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesZ("InterCoordZ","HYD2Trapezoid2", 0); - G4VPrimitiveScorer* InteractionCoordinatesAngleTheta = new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesAngleTheta("InterCoordAngTheta","HYD2Trapezoid2", 0); - G4VPrimitiveScorer* InteractionCoordinatesAnglePhi = new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesAnglePhi("InterCoordAngPhi","HYD2Trapezoid2", 0); - G4VPrimitiveScorer* Energy = new HYD2ScorerFirstStageEnergy("StripEnergy", "HYD2Trapezoid2", 0); - G4VPrimitiveScorer* StripPositionX = new HYD2ScorerFirstStageFrontStripTrapezoid2("StripNumberX", 0, NumberOfStripsX); - G4VPrimitiveScorer* StripPositionY = new HYD2ScorerFirstStageBackStripTrapezoid2("StripNumberY", 0, NumberOfStripsY); - - //and register it to the multifunctionnal detector - m_FirstStageScorer->RegisterPrimitive(DetNbr); - m_FirstStageScorer->RegisterPrimitive(Energy); - m_FirstStageScorer->RegisterPrimitive(TOF); - m_FirstStageScorer->RegisterPrimitive(StripPositionX); - m_FirstStageScorer->RegisterPrimitive(StripPositionY); - m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesX); - m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesY); - m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesZ); - m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesAngleTheta); - m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesAnglePhi); - - // Second stage Associate Scorer - G4VPrimitiveScorer* SecondStageEnergy = new HYD2ScorerSecondStageEnergy("SecondStageEnergy", "HYD2Trapezoid2", 0); - m_SecondStageScorer->RegisterPrimitive(SecondStageEnergy); - - // Third stage Associate Scorer - G4VPrimitiveScorer* ThirdStageEnergy = new HYD2ScorerThirdStageEnergy("ThirdStageEnergy", "HYD2Trapezoid2", 0); - m_ThirdStageScorer->RegisterPrimitive(ThirdStageEnergy); - - // Fourth stage Associate Scorer - G4VPrimitiveScorer* FourthStageEnergy = new HYD2ScorerFourthStageEnergy("FourthStageEnergy", "HYD2Trapezoid2", 0); - m_FourthStageScorer->RegisterPrimitive(FourthStageEnergy); - - // Fifth stage Associate Scorer - G4VPrimitiveScorer* FifthStageEnergy = new HYD2ScorerFifthStageEnergy("FifthStageEnergy", "HYD2Trapezoid2", 0); - m_FifthStageScorer->RegisterPrimitive(FifthStageEnergy); - - // Sixth stage Associate Scorer - G4VPrimitiveScorer* SixthStageEnergy = new HYD2ScorerSixthStageEnergy("SixthStageEnergy", "HYD2Trapezoid2", 0); - m_SixthStageScorer->RegisterPrimitive(SixthStageEnergy); - - // Add All Scorer to the Global Scorer Manager - G4SDManager::GetSDMpointer()->AddNewDetector(m_FirstStageScorer); - G4SDManager::GetSDMpointer()->AddNewDetector(m_SecondStageScorer); - G4SDManager::GetSDMpointer()->AddNewDetector(m_ThirdStageScorer); - G4SDManager::GetSDMpointer()->AddNewDetector(m_FourthStageScorer); - G4SDManager::GetSDMpointer()->AddNewDetector(m_FifthStageScorer); - G4SDManager::GetSDMpointer()->AddNewDetector(m_SixthStageScorer); +void Hyde2TrackerTrapezoid2::InitializeScorers() { + bool already_exist = false; + m_FirstStageScorer = NPS::VDetector::CheckScorer("FirstStageScorerHYD2Trapezoid2", already_exist); + m_SecondStageScorer = NPS::VDetector::CheckScorer("SecondStageScorerHYD2Trapezoid2", already_exist); + m_ThirdStageScorer = NPS::VDetector::CheckScorer("ThirdStageScorerHYD2Trapezoid2", already_exist); + m_FourthStageScorer = NPS::VDetector::CheckScorer("FourthStageScorerHYD2Trapezoid2", already_exist); + m_FifthStageScorer = NPS::VDetector::CheckScorer("FifthStageScorerHYD2Trapezoid2", already_exist); + m_SixthStageScorer = NPS::VDetector::CheckScorer("SixthStageScorerHYD2Trapezoid2", already_exist); + if (already_exist) + return; + + // First stage Associate Scorer + G4VPrimitiveScorer* DetNbr = new OBSOLETEGENERALSCORERS::PSDetectorNumber("DetectorNumber", "HYD2Trapezoid2", 0); + G4VPrimitiveScorer* TOF = new OBSOLETEGENERALSCORERS::PSTOF("StripTime", "HYD2Trapezoid2", 0); + G4VPrimitiveScorer* InteractionCoordinatesX = + new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesX("InterCoordX", "HYD2Trapezoid2", 0); + G4VPrimitiveScorer* InteractionCoordinatesY = + new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesY("InterCoordY", "HYD2Trapezoid2", 0); + G4VPrimitiveScorer* InteractionCoordinatesZ = + new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesZ("InterCoordZ", "HYD2Trapezoid2", 0); + G4VPrimitiveScorer* InteractionCoordinatesAngleTheta = + new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesAngleTheta("InterCoordAngTheta", "HYD2Trapezoid2", 0); + G4VPrimitiveScorer* InteractionCoordinatesAnglePhi = + new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesAnglePhi("InterCoordAngPhi", "HYD2Trapezoid2", 0); + G4VPrimitiveScorer* Energy = new HYD2ScorerFirstStageEnergy("StripEnergy", "HYD2Trapezoid2", 0); + G4VPrimitiveScorer* StripPositionX = new HYD2ScorerFirstStageFrontStripTrapezoid2("StripNumberX", 0, NumberOfStripsX); + G4VPrimitiveScorer* StripPositionY = new HYD2ScorerFirstStageBackStripTrapezoid2("StripNumberY", 0, NumberOfStripsY); + + // and register it to the multifunctionnal detector + m_FirstStageScorer->RegisterPrimitive(DetNbr); + m_FirstStageScorer->RegisterPrimitive(Energy); + m_FirstStageScorer->RegisterPrimitive(TOF); + m_FirstStageScorer->RegisterPrimitive(StripPositionX); + m_FirstStageScorer->RegisterPrimitive(StripPositionY); + m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesX); + m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesY); + m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesZ); + m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesAngleTheta); + m_FirstStageScorer->RegisterPrimitive(InteractionCoordinatesAnglePhi); + + // Second stage Associate Scorer + G4VPrimitiveScorer* SecondStageEnergy = new HYD2ScorerSecondStageEnergy("SecondStageEnergy", "HYD2Trapezoid2", 0); + m_SecondStageScorer->RegisterPrimitive(SecondStageEnergy); + + // Third stage Associate Scorer + G4VPrimitiveScorer* ThirdStageEnergy = new HYD2ScorerThirdStageEnergy("ThirdStageEnergy", "HYD2Trapezoid2", 0); + m_ThirdStageScorer->RegisterPrimitive(ThirdStageEnergy); + + // Fourth stage Associate Scorer + G4VPrimitiveScorer* FourthStageEnergy = new HYD2ScorerFourthStageEnergy("FourthStageEnergy", "HYD2Trapezoid2", 0); + m_FourthStageScorer->RegisterPrimitive(FourthStageEnergy); + + // Fifth stage Associate Scorer + G4VPrimitiveScorer* FifthStageEnergy = new HYD2ScorerFifthStageEnergy("FifthStageEnergy", "HYD2Trapezoid2", 0); + m_FifthStageScorer->RegisterPrimitive(FifthStageEnergy); + + // Sixth stage Associate Scorer + G4VPrimitiveScorer* SixthStageEnergy = new HYD2ScorerSixthStageEnergy("SixthStageEnergy", "HYD2Trapezoid2", 0); + m_SixthStageScorer->RegisterPrimitive(SixthStageEnergy); + + // Add All Scorer to the Global Scorer Manager + G4SDManager::GetSDMpointer()->AddNewDetector(m_FirstStageScorer); + G4SDManager::GetSDMpointer()->AddNewDetector(m_SecondStageScorer); + G4SDManager::GetSDMpointer()->AddNewDetector(m_ThirdStageScorer); + G4SDManager::GetSDMpointer()->AddNewDetector(m_FourthStageScorer); + G4SDManager::GetSDMpointer()->AddNewDetector(m_FifthStageScorer); + G4SDManager::GetSDMpointer()->AddNewDetector(m_SixthStageScorer); } diff --git a/NPSimulation/Detectors/Iss/CMakeLists.txt b/NPSimulation/Detectors/Iss/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..c7ed528ec5fbb81fea049fd864fd0438f41aece2 --- /dev/null +++ b/NPSimulation/Detectors/Iss/CMakeLists.txt @@ -0,0 +1,5 @@ +# Check for gdml support +if(Geant4_gdml_FOUND) +add_library(NPSIss SHARED IssArray.cc) +target_link_libraries(NPSIss NPSCore ${ROOT_LIBRARIES} ${Geant4_LIBRARIES} NPIss) +endif() diff --git a/NPSimulation/Detectors/Iss/IssArray.cc b/NPSimulation/Detectors/Iss/IssArray.cc new file mode 100644 index 0000000000000000000000000000000000000000..6862e922f288315c74560f38e5b512be9f02ba78 --- /dev/null +++ b/NPSimulation/Detectors/Iss/IssArray.cc @@ -0,0 +1,858 @@ +/***************************************************************************** + * Copyright (C) 2009-2019 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 * + *****************************************************************************/ + +/***************************************************************************** +* Author: M. Labiche address: marc.labiche@stfc.ac.uk * + * * + * Creation Date : July 2019 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This file describe the Iss charge particle Detector * + * * + *---------------------------------------------------------------------------* + * Comment: * + * Iss is a modular array made of DSSSD (Telescope). Each * + * Telescope is made of a single Stage: * + * - A 300um Silicium, double-sided strip * + * - possibility to add a second layer in future * + *****************************************************************************/ +#include "IssArray.hh" + +// Geant4 +#include "G4Box.hh" +#include "G4Colour.hh" +#include "G4Element.hh" +#include "G4ElementTable.hh" +#include "G4MaterialTable.hh" +#include "G4PVDivision.hh" +#include "G4PVPlacement.hh" +#include "G4RotationMatrix.hh" +#include "G4Transform3D.hh" +#include "G4Trap.hh" +#include "G4Trd.hh" +#include "G4Tubs.hh" +#include "G4VisAttributes.hh" +#include "Randomize.hh" + +// For the magnetic field +#include "MyMagneticField.hh" +#include "G4FieldManager.hh" +#include "G4TransportationManager.hh" +#include "G4ChordFinder.hh" +#include "G4MagIntegratorStepper.hh" + +// NPS +#include "CalorimeterScorers.hh" +#include "DSSDScorers.hh" +#include "InteractionScorers.hh" +#include "MaterialManager.hh" +#include "NPOptionManager.h" +#include "NPSDetectorFactory.hh" +// NPL +#include "NPCore.h" +// ROOT +#include "RootOutput.h" + +// CLHEP +#include "CLHEP/Random/RandGauss.h" + +// STL +#include <cmath> +#include <set> +#include <sstream> +#include <string> +using namespace std; +using namespace CLHEP; +using namespace ISS; +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +// IssArray Specific Method +IssArray::IssArray() { + m_Event = new TIssData(); + InitializeMaterial(); + // if using mask: m_StripScorer = 0; + m_BOXScorer = 0; + +} + +IssArray::~IssArray() {} + + + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +void IssArray::AddTelescope(G4ThreeVector X1_Y1, G4ThreeVector X128_Y1, + G4ThreeVector X1_Y128, G4ThreeVector X128_Y128, + bool wSi) { + m_DefinitionType.push_back(true); + + m_X1_Y1.push_back(X1_Y1); + m_X128_Y1.push_back(X128_Y1); + m_X1_Y128.push_back(X1_Y128); + m_X128_Y128.push_back(X128_Y128); + m_wSi.push_back(wSi); + + + m_R.push_back(0); + m_Theta.push_back(0); + m_Phi.push_back(0); + m_beta_u.push_back(0); + m_beta_v.push_back(0); + m_beta_w.push_back(0); +} + +void IssArray::AddTelescope(G4double R, G4double Theta, G4double Phi, + G4double beta_u, G4double beta_v, G4double beta_w, + bool wSi) { + G4ThreeVector empty = G4ThreeVector(0, 0, 0); + + m_DefinitionType.push_back(false); + + m_R.push_back(R); + m_Theta.push_back(Theta); + m_Phi.push_back(Phi); + m_beta_u.push_back(beta_u); + m_beta_v.push_back(beta_v); + m_beta_w.push_back(beta_w); + m_wSi.push_back(wSi); + + + m_X1_Y1.push_back(empty); + m_X128_Y1.push_back(empty); + m_X1_Y128.push_back(empty); + m_X128_Y128.push_back(empty); +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +void IssArray::VolumeMaker(G4int TelescopeNumber, G4double DetTgt, G4ThreeVector MMpos, + G4RotationMatrix* MMrot, bool wSi, G4LogicalVolume* world) { + + G4double NbrTelescopes = TelescopeNumber; + G4String DetectorNumber; + std::ostringstream Number; + Number << NbrTelescopes; + DetectorNumber = Number.str(); + + //////////////////////////////////////////////////////////////// + ////////////// Starting Volume Definition ////////////////////// + //////////////////////////////////////////////////////////////// + + // + // Mechanical structure to be included only once with the 1st helios module + // + + const char* ToMyGDML=NULL; + G4String MyGDMLPath; + + if(getenv("MyGDML")) + { + //const char* ToMyGDML= getenv("MyGDML"); // "/mnt/hgfs/Documents/NPhelisol/gdml/"; + MyGDMLPath= G4String(getenv("MyGDML")); + } + + if(TelescopeNumber==1){ + // + // Aluminium support plate (gdml) + // + + + if(MyGDMLPath){ + + cout << "Construction using gdml files" << endl; + + m_gdmlparser.Read(MyGDMLPath+"/ISSNudePlate.gdml"); + G4LogicalVolume* m_LogicalAlPlate= m_gdmlparser.GetVolume("StructPlate"); + + + m_gdmlparser.Read(MyGDMLPath+"/ISSTarg.gdml"); + G4LogicalVolume* m_LogicalSupTarg= m_gdmlparser.GetVolume("StructTarg"); + + m_gdmlparser.Read(MyGDMLPath+"/ISSDetStrut.gdml"); + G4LogicalVolume* m_LogicalSupDet= m_gdmlparser.GetVolume("StructDet"); + + +/* m_gdmlparser.Read("/mnt/hgfs/Documents/NPhelisol/gdml/ISSNudePlate.gdml"); + G4LogicalVolume* m_LogicalAlPlate= m_gdmlparser.GetVolume("StructPlate"); + + m_gdmlparser.Read("/mnt/hgfs/Documents/NPhelisol/gdml/ISSTarg.gdml"); + G4LogicalVolume* m_LogicalSupTarg= m_gdmlparser.GetVolume("StructTarg"); + + m_gdmlparser.Read("/mnt/hgfs/Documents/NPhelisol/gdml/ISSDetStrut.gdml"); + G4LogicalVolume* m_LogicalSupDet= m_gdmlparser.GetVolume("StructDet"); +*/ + m_LogicalAlPlate->SetVisAttributes(G4VisAttributes::Invisible); // set world of Al Plate invisible + m_LogicalSupTarg->SetVisAttributes(G4VisAttributes::Invisible); // set world of Al Plate invisible + m_LogicalSupDet->SetVisAttributes(G4VisAttributes::Invisible); // set world of Al Plate invisible + + //G4VisAttributes *TargVol = new G4VisAttributes(G4Colour(1.0, .5, .5)); + //TargVol->SetForceSolid(false); + //m_LogicalSupTarg->SetVisAttributes(TargVol); + + //G4VisAttributes *SupDetVol = new G4VisAttributes(G4Colour(1.0, .5, .5)); + //SupDetVol->SetForceWireframe(false); + //m_LogicalSupDet->SetVisAttributes(SupDetVol); + + G4RotationMatrix* RotY_DetSup = new G4RotationMatrix(); + RotY_DetSup->rotateY(180*deg); + + cout << "MMpos0: " << MMpos(0) << endl; + cout << "MMpos1: " << MMpos(1) << endl; + cout << "MMpos2: " << MMpos(2) << endl; + + if(DetTgt<0){ // ie: detector at backward angles + new G4PVPlacement(0, G4ThreeVector(0., -353, 0.), m_LogicalAlPlate,"AlumPlate", world, false, 0 ); + new G4PVPlacement(0, G4ThreeVector(13.5, -200.+(27.830127-5.66), 87.910256-5.+4.), m_LogicalSupTarg,"SupTarg", world, false, 0 ); + new G4PVPlacement(0, G4ThreeVector(0., 0., -6.5+(DetTgt+100)), m_LogicalSupDet,"SupDet", world, false, 0 ); + }else // ie: detector at forward angle + { + new G4PVPlacement(RotY_DetSup, G4ThreeVector(0., -370., 0.), m_LogicalAlPlate,"AlumPlate", world, false, 0 ); + new G4PVPlacement(RotY_DetSup, G4ThreeVector(-13.5, -200.+(27.830127-5.66), -87.910256+5.-4.), m_LogicalSupTarg,"SupTarg", world, false, 0 ); + + new G4PVPlacement(RotY_DetSup, G4ThreeVector(0., 0., 6.5+(DetTgt-100)), m_LogicalSupDet,"SupDet", world, false, 1 ); // for detecmm + } + +/* + new G4PVPlacement(0, G4ThreeVector(0., -370., 0.), m_LogicalAlPlate,"AlumPlate", world, false, 0 ); + new G4PVPlacement(0, G4ThreeVector(13.5, -200.+(27.830127-5.66), 87.910256-5.+4.), m_LogicalSupTarg,"SupTarg", world, false, 0 ); // for backward angles + //new G4PVPlacement(RotY_DetSup, G4ThreeVector(0., -370., 0.), m_LogicalAlPlate,"AlumPlate", world, false, 0 ); // for forward angles + //new G4PVPlacement(RotY_DetSup, G4ThreeVector(-13.5, -200.+(27.830127-5.66), -87.910256+5.-4.), m_LogicalSupTarg,"SupTarg", world, false, 0 ); // for forward angles + + //new G4PVPlacement(0, G4ThreeVector(0., 0., -156.5), m_LogicalSupDet,"SupDet", world, false, 0 ); // for detector at -250mm + //new G4PVPlacement(0, G4ThreeVector(0., 0., -6.5), m_LogicalSupDet,"SupDet", world, false, 0 ); // for detector at -100mm + new G4PVPlacement(0, G4ThreeVector(0., 0., -26.5), m_LogicalSupDet,"SupDet", world, false, 0 ); // for detector at -120mm + //new G4PVPlacement(0, G4ThreeVector(0., 0., -106.5), m_LogicalSupDet,"SupDet", world, false, 0 ); // for detector at -200mm + //new G4PVPlacement(RotY_DetSup, G4ThreeVector(0., 0., 156.5), m_LogicalSupDet,"SupDet", world, false, 1 ); // for detector at 156.5mm + //new G4PVPlacement(RotY_DetSup, G4ThreeVector(0., 0., 36.5), m_LogicalSupDet,"SupDet", world, false, 1 ); // for detector at 130.mm + +*/ + + }else + { + + // + // Detector support structure (rods) + // + + cout << "Construction without gdml files" << endl; + cout << "to add gdml geometry files, make sure the environment variable MyGDML in nptool.sh or .csh point to your gdml directory " << endl; + + + // Add the Aluminium rod + + G4double RodTgt; + + if(DetTgt<0)RodTgt=-10-DetTgt; + if(DetTgt>0)RodTgt=-10+DetTgt; + + const G4double Zplan[2]={(RodTgt), (RodTgt+530)}; + //const G4double Zplan[2]={140*mm, 670*mm}; // if first silicons are at 150mm to target (helisol.detector) + //const G4double Zplan[2]={90*mm, 620*mm}; // if first silicon at 100mm to target (helisol_2.detector) + //const G4double Zplan[2]={40*mm, 570*mm}; // if first silicon at 50mm to target (helisol_3.detector) + const G4double Rinner[2]={15*mm, 15*mm}; + const G4double Router[2]={24*mm, 24*mm}; + G4Polyhedra* Al_rod= new G4Polyhedra("Al_rod", 0., 360*deg, 6, 2, Zplan, Rinner, Router); + + G4LogicalVolume* Al_rod_log = new G4LogicalVolume(Al_rod, m_MaterialAluminium, "Al_rod", 0, 0, 0); + + G4RotationMatrix* RotZ30Y180 = new G4RotationMatrix(); + RotZ30Y180->rotateY(180*deg); + RotZ30Y180->rotateZ(30*deg); + G4RotationMatrix* RotZ30 = new G4RotationMatrix(); + RotZ30->rotateZ(30*deg); + + + if(DetTgt<0){ + new G4PVPlacement(RotZ30Y180, G4ThreeVector(0.,0., 0.), Al_rod_log, "Al_rod", world, false, 1); // backward + }else + { + new G4PVPlacement(RotZ30, G4ThreeVector(0.,0., 0.), Al_rod_log, "Al_rod", world, false, 1); // forward + } + + //new G4PVPlacement(RotZ30, G4ThreeVector(0.,0., 100., Al_rod_log, "Al_rod", world, false, 0); // forward + //new G4PVPlacement(RotZ30Y180, G4ThreeVector(0.,0., -150.), Al_rod_log, "Al_rod", world, false, 1); // backward + + + G4VisAttributes* VisAtt1 = new G4VisAttributes(G4Colour(1, 0.8, 0)); + Al_rod_log->SetVisAttributes(VisAtt1); + + } + + + // + // Add the Aluminium chamber + // + G4double Al_chamber_rmin = 50. * cm; + G4double Al_chamber_rmax = 50.5 * cm; + G4double Al_chamber_z = 150.0 * cm; + + //G4Tubs* Al_chamber_tub + // = new G4Tubs("Al_chamber_tub", Al_chamber_rmin, Al_chamber_rmax, Al_chamber_z, 0.*deg, 180*deg); + G4Tubs* Al_chamber_tub + = new G4Tubs("Al_chamber_tub", Al_chamber_rmin, Al_chamber_rmax, Al_chamber_z, 0.*deg, 240*deg); + + G4LogicalVolume* Al_chamber_log = new G4LogicalVolume(Al_chamber_tub, m_MaterialAluminium, "Al_chamber", 0, 0, 0); + + G4RotationMatrix* RotZ = new G4RotationMatrix(); + RotZ->rotateZ(-90*deg); + + new G4PVPlacement(RotZ, G4ThreeVector(0.,0.,0.), Al_chamber_log, "Al_chamber", world, false, 0); + + + G4VisAttributes* VisAtt2 = new G4VisAttributes(G4Colour(0, 0.8, 0.5)); + //VisAtt2->SetForceWireframe("True"); + Al_chamber_log->SetVisAttributes(VisAtt2); + + // + // Add the Aluminium shield after target to stop most shallow angle particles + // + G4double Al_tgt_rmin = 0.03 * cm; + G4double Al_tgt_rmax = 0.13 * cm; + G4double Al_tgt_z = .05 * cm; + + G4Tubs* Al_tgt_shield + = new G4Tubs("Al_tgt_shield", Al_tgt_rmin, Al_tgt_rmax, Al_tgt_z, 0.*deg, 360*deg); + + G4LogicalVolume* Al_tgt_log = new G4LogicalVolume(Al_tgt_shield, m_MaterialAluminium, "Al_tgt_shield", 0, 0, 0); + + //new G4PVPlacement(RotZ, G4ThreeVector(0.,0.,-0.2*cm), Al_tgt_log, "Al_tgt_shield", world, false, 0); + + + } // endof of TelescopNumber==1 + + + + //////////////////////////////////////////////////////////////// + ///////////////// First & single Stage Construction ///////////////////// + //////////////////////////////////////////////////////////////// + + // Mother volume: + G4Box* solidMM = new G4Box("ISSDet" + DetectorNumber, 0.5 * FaceLength, 0.5 * FaceWidth, 0.5 * Length); + G4LogicalVolume* logicMM = new G4LogicalVolume(solidMM, m_MaterialVacuum, "ISSDet" + DetectorNumber, 0, 0, 0); + G4String Name = "ISSDet" + DetectorNumber; + + new G4PVPlacement(G4Transform3D(*MMrot, MMpos), logicMM, Name, world, false,TelescopeNumber); + + if (m_non_sensitive_part_visiualisation) { + G4VisAttributes* FrameVisAtt + = new G4VisAttributes(G4Colour(0.80, 0.80, 0.80)); + FrameVisAtt->SetForceWireframe(true); + logicMM->SetVisAttributes(FrameVisAtt); + } else + logicMM->SetVisAttributes(G4VisAttributes::Invisible); + + G4ThreeVector positionVacBox = G4ThreeVector(0, 0, VacBox_PosZ); + + G4Box* solidVacBox + = new G4Box("solidVacBox", 0.5 * SiliconFaceLength, 0.5 * SiliconFaceWidth, 0.5 * VacBoxThickness); + G4LogicalVolume* logicVacBox = new G4LogicalVolume(solidVacBox, m_MaterialVacuum, "logicVacBox", 0, 0, 0); + + new G4PVPlacement(0, positionVacBox, logicVacBox, Name + "_VacBox", logicMM, + false, TelescopeNumber); + + logicVacBox->SetVisAttributes(G4VisAttributes::Invisible); + + G4VisAttributes* SiliconVisAtt = new G4VisAttributes(G4Colour(0.3, 0.3, 0.3)); + + // Silicon: + if (wSi) { + + //Aluminium layer + + G4ThreeVector positionAluStripFront + = G4ThreeVector(0, 0, AluStripFront_PosZ); + G4ThreeVector positionAluStripBack = G4ThreeVector(0, 0, AluStripBack_PosZ); + + G4Box* solidAluStrip + = new G4Box("AluBox", 0.5 * SiliconFaceLength, 0.5 * SiliconFaceWidth, + 0.5 * AluStripThickness); + G4LogicalVolume* logicAluStrip = new G4LogicalVolume( + solidAluStrip, m_MaterialAluminium, "logicAluStrip", 0, 0, 0); + + new G4PVPlacement(0, positionAluStripFront, logicAluStrip, + Name + "_AluStripFront", logicMM, false, TelescopeNumber); + new G4PVPlacement(0, positionAluStripBack, logicAluStrip, + Name + "_AluStripBack", logicMM, false, TelescopeNumber); + + logicAluStrip->SetVisAttributes(G4VisAttributes::Invisible); + + // Silicon detector itself + + G4ThreeVector positionSilicon = G4ThreeVector(0, 0, Silicon_PosZ); + + G4Box* solidSilicon = new G4Box("solidSilicon", 0.5*SiliconFaceLength, 0.5*SiliconFaceWidth, 0.5*SiliconThickness); + G4LogicalVolume* logicSilicon = new G4LogicalVolume(solidSilicon, m_MaterialSilicon, "logicSilicon", 0, 0, 0); + + new G4PVPlacement(0, positionSilicon, logicSilicon, Name + "_Silicon", + logicMM, false, TelescopeNumber); + + /// Set Silicon strip sensible + logicSilicon->SetSensitiveDetector(m_BOXScorer); + // if using mask: logicSilicon->SetSensitiveDetector(m_StripScorer); + + /// Visualisation of Silicon Strip + logicSilicon->SetVisAttributes(SiliconVisAtt); + + + } + + + +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +// Virtual Method of NPS::VDetector class + +// Read stream at Configfile to pick-up parameters of detector (Position,...) +// Called in DetecorConstruction::ReadDetextorConfiguration Method +void IssArray::ReadConfiguration(NPL::InputParser parser) { + vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithToken("ISSDet"); + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks.size() << " detector found" << endl; + for (unsigned int i = 0; i < blocks.size(); i++) { + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// Iss det " << i + 1 << endl; + // Cartesian Case + vector<string> cart + = {"X1_Y1", "X1_Y128", "X128_Y1", "X128_Y128", "SI"}; + // Spherical Case + vector<string> sphe = {"R", "THETA", "PHI", "BETA", "SI"}; + + + if(blocks[i]->HasToken("MField")){ + double Bz=blocks[i]->GetDouble("MField","T"); + MyMagneticField* myField = new MyMagneticField(G4ThreeVector(0.,0.,Bz)); + G4FieldManager* fieldMgr= G4TransportationManager::GetTransportationManager()->GetFieldManager(); + fieldMgr->SetDetectorField(myField); + fieldMgr->CreateChordFinder(myField); + } + + + + if (blocks[i]->HasTokenList(cart)) { + G4ThreeVector A + = NPS::ConvertVector(blocks[i]->GetTVector3("X1_Y1", "mm")); + G4ThreeVector B + = NPS::ConvertVector(blocks[i]->GetTVector3("X128_Y1", "mm")); + G4ThreeVector C + = NPS::ConvertVector(blocks[i]->GetTVector3("X1_Y128", "mm")); + G4ThreeVector D + = NPS::ConvertVector(blocks[i]->GetTVector3("X128_Y128", "mm")); + int SI = blocks[i]->GetInt("SI"); + + AddTelescope(A, B, C, D, SI == 1); + } + + else if (blocks[i]->HasTokenList(sphe)) { + + double Theta = blocks[i]->GetDouble("THETA", "deg"); + double Phi = blocks[i]->GetDouble("PHI", "deg"); + double R = blocks[i]->GetDouble("R", "mm"); + vector<double> beta = blocks[i]->GetVectorDouble("BETA", "deg"); + int SI = blocks[i]->GetInt("SI"); + AddTelescope(R, Theta, Phi, beta[0], beta[1], beta[2], SI == 1); + } + + else { + cout << "WARNING: Missing token for ISSDet blocks, check your input " + "file" + << endl; + exit(1); + } + + if (blocks[i]->GetString("VIS") == "all") + m_non_sensitive_part_visiualisation = true; + } +} + +// Construct detector and inialise sensitive part. +// Called After DetecorConstruction::AddDetector Method +void IssArray::ConstructDetector(G4LogicalVolume* world) { + G4RotationMatrix* MMrot = NULL; + G4ThreeVector MMpos = G4ThreeVector(0, 0, 0); + G4ThreeVector MMu = G4ThreeVector(0, 0, 0); + G4ThreeVector MMv = G4ThreeVector(0, 0, 0); + G4ThreeVector MMw = G4ThreeVector(0, 0, 0); + G4ThreeVector MMCenter = G4ThreeVector(0, 0, 0); + G4double DetTgt = 0; + bool Si = true; + + G4int NumberOfTelescope = m_DefinitionType.size(); + + for (G4int i = 0; i < NumberOfTelescope; i++) { + + if(i==0){ // first telescope found + MMu=m_X1_Y1[i]; + DetTgt=MMu(2); + } + + // By Point + if (m_DefinitionType[i]) { + // (u,v,w) unitary vector associated to telescope referencial + // (u,v) // to silicon plan + // w perpendicular to (u,v) plan and pointing CsI + MMu = m_X128_Y1[i] - m_X1_Y1[i]; + MMu = MMu.unit(); + + MMv = m_X1_Y128[i] - m_X1_Y1[i]; + MMv = MMv.unit(); + + MMw = MMv.cross(MMu); + // if (MMw.z() > 0)MMw = MMv.cross(MMu) ; + MMw = MMw.unit(); + + MMCenter + = (m_X1_Y1[i] + m_X1_Y128[i] + m_X128_Y1[i] + m_X128_Y128[i]) / 4; + + // Passage Matrix from Lab Referential to Telescope Referential + MMrot = new G4RotationMatrix(MMv, MMu, MMw); + MMpos = MMw * Length * 0.5 + MMCenter; + } + + // By Angle + else { + G4double Theta = m_Theta[i]; + G4double Phi = m_Phi[i]; + + // (u,v,w) unitary vector associated to telescope referencial + // (u,v) // to silicon plan + // w perpendicular to (u,v) plan and pointing ThirdStage + // Phi is angle between X axis and projection in (X,Y) plan + // Theta is angle between position vector and z axis + G4double wX = m_R[i] * sin(Theta / rad) * cos(Phi / rad); + G4double wY = m_R[i] * sin(Theta / rad) * sin(Phi / rad); + G4double wZ = m_R[i] * cos(Theta / rad); + MMw = G4ThreeVector(wX, wY, wZ); + + // vector corresponding to the center of the module + G4ThreeVector CT = MMw; + + // vector parallel to one axis of silicon plane + G4double ii = cos(Theta / rad) * cos(Phi / rad); + G4double jj = cos(Theta / rad) * sin(Phi / rad); + G4double kk = -sin(Theta / rad); + G4ThreeVector Y = G4ThreeVector(ii, jj, kk); + + MMw = MMw.unit(); + MMu = MMw.cross(Y); + MMv = MMw.cross(MMu); + MMv = MMv.unit(); + MMu = MMu.unit(); + + // Passage Matrix from Lab Referential to Telescope Referential + // Iss + MMrot = new G4RotationMatrix(MMu, MMv, MMw); + // Telescope is rotate of Beta angle around MMv axis. + MMrot->rotate(m_beta_u[i], MMu); + MMrot->rotate(m_beta_v[i], MMv); + MMrot->rotate(m_beta_w[i], MMw); + // translation to place Telescope + MMpos = MMw * Length * 0.5 + CT; + } + + Si = m_wSi[i]; + + VolumeMaker(i + 1, DetTgt, MMpos, MMrot, Si, world); + } + + delete MMrot; +} + +// Add Detector branch to the EventTree. +// Called After DetecorConstruction::AddDetector Method + +void IssArray::InitializeRootOutput() { + RootOutput* pAnalysis = RootOutput::getInstance(); + TTree* pTree = pAnalysis->GetTree(); + if (!pTree->FindBranch("ISS")) { + pTree->Branch("ISS", "TIssData", &m_Event); + } + pTree->SetBranchAddress("ISS", &m_Event); +} + +// Read sensitive part and fill the Root tree. +// Called at in the EventAction::EndOfEventAvtion +void IssArray::ReadSensitive(const G4Event*) { + m_Event->Clear(); + + ////////////////////////////////////////////////////////////////////////////////////// + //////////////////////// Used to Read Event Map of detector + ///////////////////////////// + ////////////////////////////////////////////////////////////////////////////////////// + + ///////////////////// + // Read the Scorer associate to the Silicon Strip in case of PS_Images (See NPLib/Detectors/Iss/ressources) + /////////// + // BOX + DSSDScorers::PS_Rectangle* BOXScorer = (DSSDScorers::PS_Rectangle*) m_BOXScorer->GetPrimitive(0); + + + // Loop on the BOX map + unsigned int sizeFront= BOXScorer->GetLengthMult(); + + for (unsigned int i=0 ; i<sizeFront ; i++){ + + double Energy = BOXScorer->GetEnergyLength(i); + + if(Energy>ThresholdSi){ + double Time = BOXScorer->GetTimeLength(i); + int DetNbr = BOXScorer->GetDetectorLength(i); + int StripFront = BOXScorer->GetStripLength(i); + + m_Event->SetFront(DetNbr, + StripFront, + RandGauss::shoot(Energy, ResoStrip), + RandGauss::shoot(Time, ResoTime), + RandGauss::shoot(Time, ResoTime)); + } + } + + unsigned int sizeBack= BOXScorer->GetWidthMult(); + for (unsigned int i=0 ; i<sizeBack ; i++){ + + double Energy = BOXScorer->GetEnergyWidth(i); + + if(Energy>ThresholdSi){ + double Time = BOXScorer->GetTimeWidth(i); + int DetNbr = BOXScorer->GetDetectorWidth(i); + int StripBack = BOXScorer->GetStripWidth(i); + + m_Event->SetBack(DetNbr, + Silicon_Back_NumberOfStrip-StripBack+1, + RandGauss::shoot(Energy, ResoStrip), + RandGauss::shoot(Time, ResoTime), + RandGauss::shoot(Time, ResoTime)); + } + } + // clear map for next event + BOXScorer->clear(); + + + + ///////////////////// + // Read the Scorer associate to the Silicon Strip in case of using mask ( See NPLib/Detectors/Iss/ressources) + /* DSSDScorers::PS_Images* SiScorer + = (DSSDScorers::PS_Images*)m_StripScorer->GetPrimitive(0); + + bool SiScoredHit; // flag true if first stage scores a hit above threshold + set<int> trig; // list of telescope that got a Si trigger + unsigned int sizeFront = SiScorer->GetFrontMult(); + unsigned int sizeBack = SiScorer->GetBackMult(); + + // Check for double match Strip : + // rare case where a particle hit a strip and then an interstrip + // since the map idex is build on pixel value, we end up with the same strip + // fired twice, which is impossible in reality. + std::map< unsigned int, std::pair<double,double> > mapFront; + std::map< unsigned int, std::pair<double,double> >::iterator it; + + for (unsigned int i = 0; i < sizeFront; i++) { + double energy = SiScorer->GetEnergyFront(i); + int detectorNbr = SiScorer->GetDetectorFront(i); + double time = SiScorer->GetTimeFront(i); + // Pixel value at interaction point + unsigned int a, r, g, b; + // pixel + SiScorer->GetARGBFront(i, a, r, g, b); + if (r == 0) { + mapFront[b+detectorNbr*1e6].first+=energy; + mapFront[b+detectorNbr*1e6].second=time; + } + + else { // Interstrip X, keep maximum shared energy + double rand = G4UniformRand(); + if (rand > 0.5) { + double energyX = rand * energy; + mapFront[b+detectorNbr*1e6].first+=energyX; + mapFront[b+detectorNbr*1e6].second=time; + } + + else { + double energyX = (1 - rand) * energy; + mapFront[g+detectorNbr*1e6].first+=energyX; + mapFront[g+detectorNbr*1e6].second=time; + } + } + } + + for(it=mapFront.begin();it!=mapFront.end();it++){ + double energyX = RandGauss::shoot(it->second.first, ResoStrip); + double timeX = TimeOffset - RandGauss::shoot(it->second.second, ResoTimeMust); + unsigned int strip = it->first-1000000*(it->first/1000000); + unsigned int det = it->first/1000000; + if (energyX > ThresholdSi) { + trig.insert(det); + SiScoredHit = true; + m_Event->SetStripXE(det, strip , + NPL::EnergyToADC(energyX, 0, 63, 8192, 16384)); + m_Event->SetStripXT(det, strip , + NPL::EnergyToADC(timeX, 0, 1000, 8192, 16384)); + } + } + + // Check for double match Strip : + // rare case where a particle hit a strip and then an interstrip + // since the map idex is build on pixel value, we end up with the same strip + // fired twice, which is impossible in reality. + std::map< unsigned int, std::pair<double,double> > mapBack; + + for (unsigned int i = 0; i < sizeBack; i++) { + double energy = SiScorer->GetEnergyBack(i); + int detectorNbr = SiScorer->GetDetectorBack(i); + double time = SiScorer->GetTimeBack(i); + + // Pixel value at interaction point + unsigned int a, r, g, b; + // pixel + SiScorer->GetARGBBack(i, a, r, g, b); + if (r == 0) { + mapBack[b+detectorNbr*1e6].first+=energy; + mapBack[b+detectorNbr*1e6].second=time; + } + else { // Interstrip Y, keep both strip with shared energy + double rand = G4UniformRand(); + double energyY1 = rand * energy; + mapBack[b+detectorNbr*1e6].first+=energyY1; + mapBack[b+detectorNbr*1e6].second=time; + + double energyY2 = (1 - rand) * energy; + mapBack[g+detectorNbr*1e6].first+=energyY2; + mapBack[g+detectorNbr*1e6].second=time; + } + } + + for(it=mapBack.begin();it!=mapBack.end();it++){ + double energyY = RandGauss::shoot(it->second.first, ResoStrip); + double timeX = TimeOffset - RandGauss::shoot(it->second.second, ResoTimeMust); + unsigned int strip = it->first-1000000*(it->first/1000000); + unsigned int det = it->first/1000000; + if (energyY > ThresholdSi) { + trig.insert(det); + SiScoredHit = true; + m_Event->SetStripYE(det, strip , + NPL::EnergyToADC(energyY, 0, 63, 8192, 0)); + m_Event->SetStripYT(det, strip , + NPL::EnergyToADC(timeX, 0, 1000, 8192, 16384)); + } + } +*/ + + // Look for 2nd and 3rd stage only if 1st stage is hit +/* if (SiScoredHit) { + } +*/ +} + + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +void IssArray::InitializeScorers() { + // Silicon Associate Scorer + + bool already_exist = false; + //m_StripScorer = CheckScorer("ISS_StripScorer", already_exist); + m_BOXScorer = CheckScorer("ISS_BOXScorer",already_exist); + + + // if the scorer were created previously nothing else need to be made + if (already_exist){ + cout << "SCORER already exist" << endl; + return; + } + + string nptool = getenv("NPTOOL"); + + + G4VPrimitiveScorer* BOXScorer = + new DSSDScorers::PS_Rectangle("IssBOX",0, + SiliconFaceLength, + SiliconFaceWidth, + Silicon_Front_NumberOfStrip , + Silicon_Back_NumberOfStrip); + + +/* is using mask: + G4VPrimitiveScorer* SiScorer = new DSSDScorers::PS_Images( + "SiScorer", nptool + "/NPLib/Detectors/Iss/ressources/maskFront.png", + nptool + "/NPLib/Detectors/Iss/ressources/maskBack.png", 127./12800, 19.9/1100, 0, + 0, 0xffff0000, 0); +*/ + + G4VPrimitiveScorer* InterScorer + = new InteractionScorers::PS_Interactions("SiScorer", ms_InterCoord, 0); + + // and register it to the multifunctionnal detector + m_BOXScorer->RegisterPrimitive(BOXScorer); + m_BOXScorer->RegisterPrimitive(InterScorer); +// if using mask: +// m_StripScorer->RegisterPrimitive(SiScorer); +// m_StripScorer->RegisterPrimitive(InterScorer); + + + + // Add All Scorer to the Global Scorer Manager + G4SDManager::GetSDMpointer()->AddNewDetector(m_BOXScorer); + //G4SDManager::GetSDMpointer()->AddNewDetector(m_StripScorer); + +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +void IssArray::InitializeMaterial() { + + m_MaterialSilicon + = MaterialManager::getInstance()->GetMaterialFromLibrary("Si"); + m_MaterialAluminium + = MaterialManager::getInstance()->GetMaterialFromLibrary("Al"); + m_MaterialIron = MaterialManager::getInstance()->GetMaterialFromLibrary("Fe"); + m_MaterialVacuum + = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +G4RotationMatrix* Rotation(double tetaX, double tetaY, double tetaZ) { + double PI = 3.141592653589793238; + double radX = tetaX * PI / 180.; + double radY = tetaY * PI / 180.; + double radZ = tetaZ * PI / 180.; + + G4ThreeVector col1 = G4ThreeVector(cos(radZ) * cos(radY), + -sin(radZ) * cos(radY), -sin(radY)); + G4ThreeVector col2 + = G4ThreeVector(sin(radZ) * cos(radX) - cos(radZ) * sin(radY) * sin(radX), + cos(radZ) * cos(radX) + sin(radZ) * sin(radY) * sin(radX), + -cos(radY) * sin(radX)); + G4ThreeVector col3 + = G4ThreeVector(sin(radZ) * sin(radX) + cos(radZ) * sin(radY) * sin(radX), + cos(radZ) * sin(radX) - sin(radZ) * sin(radY) * cos(radX), + cos(radY) * cos(radX)); + + return (new G4RotationMatrix(col1, col2, col3)); +} + +//////////////////////////////////////////////////////////////////////////////// +// Construct Method to be pass to the DetectorFactory // +//////////////////////////////////////////////////////////////////////////////// +NPS::VDetector* IssArray::Construct() { + return (NPS::VDetector*)new IssArray(); +} + +//////////////////////////////////////////////////////////////////////////////// +// Registering the construct method to the factory // +//////////////////////////////////////////////////////////////////////////////// +extern "C" { + class proxy_nps_iss{ + public: + proxy_nps_iss() { + NPS::DetectorFactory::getInstance()->AddToken("ISSDet", "ISS"); + NPS::DetectorFactory::getInstance()->AddDetector("ISSDet", + IssArray::Construct); + } + }; + + proxy_nps_iss p_nps_iss; +} diff --git a/NPSimulation/Detectors/Iss/IssArray.hh b/NPSimulation/Detectors/Iss/IssArray.hh new file mode 100644 index 0000000000000000000000000000000000000000..3d0430a4b6d43fbe80453f88b002a26069ed56bf --- /dev/null +++ b/NPSimulation/Detectors/Iss/IssArray.hh @@ -0,0 +1,201 @@ +#ifndef ISSArray_h +#define ISSArray_h 1 +/***************************************************************************** + * Copyright (C) 2009-2019 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 * + *****************************************************************************/ + +/***************************************************************************** + * Author: M. Labiche address: marc.labiche@stfc.ac.uk * + * * + * Creation Date : July 2019 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * This file describe the Iss charge particle Detector * + * * + *---------------------------------------------------------------------------* + * Comment: * + * Iss is a modular array made of DSSSD (Telescope). Each * + * Telescope is made of a single Stage: * + * - A 300um Silicium, double-sided strip * + * - possibility to add a second layer in future * + *****************************************************************************/ +#include "NPSVDetector.hh" +#include "TIssData.h" +#include "G4SDManager.hh" +#include "G4MultiFunctionalDetector.hh" +#include "NPInputParser.h" +#include "G4GDMLParser.hh" +#include <vector> + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +namespace ISS +{ + // Resolution + const G4double ResoTime = 0.212765957 ;// = 500ps same as MUST for now // Unit is ns/2.35 + //const G4double ResoTimeMust = 0.212765957 ;// = 500ps // Unit is ns/2.35 + const G4double ResoStrip = 0.0149 ;// 0.0223 = 52keV of Resolution // Unit is MeV/2.35 14.861996 + const G4double TimeOffset = 500 ;// 500 ns stop + // Threshold + const G4double ThresholdSi = 50 * keV; + // Geometry mother volume + const G4double FaceWidth = 23.*mm ; + const G4double FaceLength = 126*mm ; + const G4double Length = 1.008*mm ; + + const G4double AluStripThickness = 0.4*micrometer ; + const G4double SiliconThickness = 1000.*micrometer ; + const G4double SiliconFaceWidth = 22.*mm ; + const G4double SiliconFaceLength = 125.*mm ; + const G4double VacBoxThickness = 1.008*mm ; + + const G4int Silicon_Front_NumberOfStrip = 128 ; + const G4int Silicon_Back_NumberOfStrip = 11 ; + + // Starting at the front and going to CsI + const G4double AluStripFront_PosZ = Length* -0.5 + 0.5*AluStripThickness; + const G4double Silicon_PosZ = AluStripFront_PosZ + 0.5*AluStripThickness + 0.5*SiliconThickness; + const G4double AluStripBack_PosZ = Silicon_PosZ + 0.5*SiliconThickness + 0.5*AluStripThickness; + const G4double VacBox_PosZ = AluStripBack_PosZ + 0.5*AluStripThickness + 0.5* VacBoxThickness; +} + +class IssArray : public NPS::VDetector +{ + //////////////////////////////////////////////////// + /////// Default Constructor and Destructor ///////// + //////////////////////////////////////////////////// +public: + IssArray() ; + virtual ~IssArray() ; + + //////////////////////////////////////////////////// + //////// Specific Function of this Class /////////// + //////////////////////////////////////////////////// +public: + // By Position Method + void AddTelescope( G4ThreeVector TL , + G4ThreeVector BL , + G4ThreeVector BR , + G4ThreeVector CT , + bool wSi ); + // By Angle Method + void AddTelescope( G4double R , + G4double Theta , + G4double Phi , + G4double beta_u , + G4double beta_v , + G4double beta_w , + bool wSi ); + + // Effectively construct Volume + // Avoid to have two time same code for Angle and Point definition + void VolumeMaker( G4int TelescopeNumber , + G4double DetTgt , + G4ThreeVector MMpos , + G4RotationMatrix* MMrot , + bool wSi , + G4LogicalVolume* world ); + + + //////////////////////////////////////////////////// + ///////// Inherite from NPS::VDetector class /////////// + //////////////////////////////////////////////////// +public: + // Read stream at Configfile to pick-up parameters of detector (Position,...) + // Called in DetecorConstruction::ReadDetextorConfiguration Method + void ReadConfiguration(NPL::InputParser); + + // Construct detector and inialise sensitive part. + // Called After DetecorConstruction::AddDetector Method + void ConstructDetector(G4LogicalVolume* world); + + // Add Detector branch to the EventTree. + // Called After DetecorConstruction::AddDetector Method + void InitializeRootOutput(); + + // Read sensitive part and fill the Root tree. + // Called at in the EventAction::EndOfEventAvtion + void ReadSensitive(const G4Event* event); + + + //////////////////////////////////////////////////// + ///////////Event class to store Data//////////////// + //////////////////////////////////////////////////// +private: + TIssData* m_Event; + + //////////////////////////////////////////////////// + ///////////////Private intern Data////////////////// + //////////////////////////////////////////////////// +private: + + // For gdml geometries + G4GDMLParser m_gdmlparser; + + // True if Define by Position, False is Define by angle + vector<bool> m_DefinitionType ; + + // Used for "By Point Definition" + vector<G4ThreeVector> m_X1_Y1 ; // Top Left Corner Position Vector + vector<G4ThreeVector> m_X1_Y128 ; // Bottom Left Corner Position Vector + vector<G4ThreeVector> m_X128_Y1 ; // Bottom Right Corner Position Vector + vector<G4ThreeVector> m_X128_Y128 ; // Center Corner Position Vector + + // Used for "By Angle Definition" + vector<G4double> m_R ; // | + vector<G4double> m_Theta ; // > Spherical coordinate of Strips Silicium Plate + vector<G4double> m_Phi ; // | + + vector<G4double> m_beta_u ; // | + vector<G4double> m_beta_v ; // > Tilt angle of the Telescope + vector<G4double> m_beta_w ; // | + + // If Set to true if you want this stage on you telescope + vector<bool> m_wSi ; // Silicium Strip 300um 128*128 Strip + + vector<bool> m_wAddSi ; // Additionnal Thin Silicium Strip + + // Set to true if you want to see Telescope Frame in your visualisation + bool m_non_sensitive_part_visiualisation ; + + + //////////////////////////////////////////////////// + ///////////////////// Scorer /////////////////////// + //////////////////////////////////////////////////// +private: + // Initialize all Scorer used by the IssArray + void InitializeScorers() ; + + // Silicon Associate Scorer + G4MultiFunctionalDetector* m_BOXScorer ; + //G4MultiFunctionalDetector* m_StripScorer ; + + + + //////////////////////////////////////////////////// + //////////////////// Material ////////////////////// + //////////////////////////////////////////////////// +private: + // Declare all material used by the IssArray + void InitializeMaterial() ; + // Si + G4Material* m_MaterialSilicon; + // Al + G4Material* m_MaterialAluminium; + // Iron + G4Material* m_MaterialIron; + // CsI + G4Material* m_MaterialCsI; + // Vacuum + G4Material* m_MaterialVacuum ; + // Mylar + G4Material* m_MaterialMyl; +public: + static NPS::VDetector* Construct(); +}; + +extern G4RotationMatrix* Rotation(double tetaX, double tetaY, double tetaZ); +#endif diff --git a/NPSimulation/Detectors/Lassa/Lassa.cc b/NPSimulation/Detectors/Lassa/Lassa.cc index 857e4f02fac8937047dae1655e1b5dfb0f0e0621..4ebaa8d3c60d8d0a59df526bd00b1eb1a4a086db 100644 --- a/NPSimulation/Detectors/Lassa/Lassa.cc +++ b/NPSimulation/Detectors/Lassa/Lassa.cc @@ -20,40 +20,40 @@ *****************************************************************************/ // C++ headers -#include <sstream> #include <cmath> #include <limits> -//G4 Geometry object +#include <sstream> +// G4 Geometry object #include "G4Box.hh" -#include "G4Trd.hh" -#include "G4Trap.hh" -#include "G4Tubs.hh" #include "G4Cons.hh" -#include "G4UnionSolid.hh" #include "G4ExtrudedSolid.hh" +#include "G4Trap.hh" +#include "G4Trd.hh" +#include "G4Tubs.hh" #include "G4TwoVector.hh" -//G4 sensitive +#include "G4UnionSolid.hh" +// G4 sensitive #include "G4SDManager.hh" -//G4 various object -#include "G4Material.hh" -#include "G4Transform3D.hh" -#include "G4PVPlacement.hh" +// G4 various object #include "G4Colour.hh" +#include "G4Material.hh" #include "G4PVDivision.hh" +#include "G4PVPlacement.hh" #include "G4SubtractionSolid.hh" +#include "G4Transform3D.hh" // NPS +#include "CalorimeterScorers.hh" #include "Lassa.hh" #include "MaterialManager.hh" #include "SiliconScorers.hh" -#include "CalorimeterScorers.hh" // NPL #include "NPOptionManager.h" -#include "RootOutput.h" #include "NPSDetectorFactory.hh" -//using namespace OBSOLETEGENERALSCORERS ; +#include "RootOutput.h" +// using namespace OBSOLETEGENERALSCORERS ; using namespace LASSA; @@ -64,46 +64,45 @@ using namespace std; using namespace CLHEP; //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -Lassa::Lassa(){ - InitializeMaterial(); - m_EventLassa = new TLassaData(); - - // Dark Grey - m_SiliconVisAtt = new G4VisAttributes(G4Colour(0.3, 0.3, 0.3)) ; - - m_CsIVisAtt = new G4VisAttributes(G4Colour(0.529412, 0.807843, 0.980392, 0.95)) ; - //m_CsIVisAtt->SetForceWireframe(true); - m_LogicThickSi = 0; - m_LogicCsICrystal = 0; - m_LogicCluster = 0; +Lassa::Lassa() { + InitializeMaterial(); + m_EventLassa = new TLassaData(); + + // Dark Grey + m_SiliconVisAtt = new G4VisAttributes(G4Colour(0.3, 0.3, 0.3)); + + m_CsIVisAtt = new G4VisAttributes(G4Colour(0.529412, 0.807843, 0.980392, 0.95)); + // m_CsIVisAtt->SetForceWireframe(true); + m_LogicThickSi = 0; + m_LogicCsICrystal = 0; + m_LogicCluster = 0; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -Lassa::~Lassa(){ -} +Lassa::~Lassa() {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Virtual Method of VDetector class // Read stream at Configfile to pick-up parameters of detector (Position,...) // Called in DetecorConstruction::ReadDetextorConfiguration Method -void Lassa::ReadConfiguration(NPL::InputParser parser){ +void Lassa::ReadConfiguration(NPL::InputParser parser) { vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithToken("LassaTelescope"); - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << "//// " << blocks.size() << " Telescope found " << endl; + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks.size() << " Telescope found " << endl; // Cartesian Case - vector<string> cart = {"A","B","C","D"}; - for(unsigned int i = 0 ; i < blocks.size() ; i++){ - if(blocks[i]->HasTokenList(cart)){ - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << endl << "//// Lassa Telescope " << i+1 << endl; - G4ThreeVector A = NPS::ConvertVector(blocks[i]->GetTVector3("A","mm")); - G4ThreeVector B = NPS::ConvertVector(blocks[i]->GetTVector3("B","mm")); - G4ThreeVector C = NPS::ConvertVector(blocks[i]->GetTVector3("C","mm")); - G4ThreeVector D = NPS::ConvertVector(blocks[i]->GetTVector3("D","mm")); - AddTelescope(A,B,C,D) ; + vector<string> cart = {"A", "B", "C", "D"}; + for (unsigned int i = 0; i < blocks.size(); i++) { + if (blocks[i]->HasTokenList(cart)) { + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// Lassa Telescope " << i + 1 << endl; + G4ThreeVector A = NPS::ConvertVector(blocks[i]->GetTVector3("A", "mm")); + G4ThreeVector B = NPS::ConvertVector(blocks[i]->GetTVector3("B", "mm")); + G4ThreeVector C = NPS::ConvertVector(blocks[i]->GetTVector3("C", "mm")); + G4ThreeVector D = NPS::ConvertVector(blocks[i]->GetTVector3("D", "mm")); + AddTelescope(A, B, C, D); } - else{ + else { cout << "ERROR: Missing token for M2Telescope blocks, check your input file" << endl; exit(1); } @@ -111,305 +110,291 @@ void Lassa::ReadConfiguration(NPL::InputParser parser){ } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Lassa::AddTelescope(G4ThreeVector Pos1, G4ThreeVector Pos2, G4ThreeVector Pos3, G4ThreeVector Pos4){ - G4ThreeVector Pos=(Pos1+Pos2+Pos3+Pos4)/4.; - G4ThreeVector u = Pos4-Pos2; - G4ThreeVector w = Pos.unit(); - G4ThreeVector v = w.cross(u); - u = u.unit(); v = v.unit(); w = w.unit(); - Pos = Pos + w*Length*0.5; - - m_Type.push_back(1); - m_Pos.push_back(Pos); - m_Rot.push_back(new G4RotationMatrix(u,v,w)); +void Lassa::AddTelescope(G4ThreeVector Pos1, G4ThreeVector Pos2, G4ThreeVector Pos3, G4ThreeVector Pos4) { + G4ThreeVector Pos = (Pos1 + Pos2 + Pos3 + Pos4) / 4.; + G4ThreeVector u = Pos4 - Pos2; + G4ThreeVector w = Pos.unit(); + G4ThreeVector v = w.cross(u); + u = u.unit(); + v = v.unit(); + w = w.unit(); + Pos = Pos + w * Length * 0.5; + + m_Type.push_back(1); + m_Pos.push_back(Pos); + m_Rot.push_back(new G4RotationMatrix(u, v, w)); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Construct detector and inialise sensitive part. // Called After DetecorConstruction::AddDetector Method -void Lassa::ConstructDetector(G4LogicalVolume* world){ - unsigned int mysize = m_Pos.size(); - - for(unsigned int i = 0 ; i < mysize ; i++){ - VolumeMaker(i+1, m_Pos[i], m_Rot[i], world); - } -} - +void Lassa::ConstructDetector(G4LogicalVolume* world) { + unsigned int mysize = m_Pos.size(); + for (unsigned int i = 0; i < mysize; i++) { + VolumeMaker(i + 1, m_Pos[i], m_Rot[i], world); + } +} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Read sensitive part and fill the Root tree. // Called at in the EventAction::EndOfEventAvtion -void Lassa::ReadSensitive(const G4Event* event){ - m_EventLassa->Clear(); - - // ThickSi // - NPS::HitsMap<G4double*>* ThickSiHitMap; - std::map<G4int, G4double**>::iterator ThickSi_itr; - G4int ThickSiCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("Lassa_ThickSiScorer/ThickSi"); - ThickSiHitMap = (NPS::HitsMap<G4double*>*)(event->GetHCofThisEvent()->GetHC(ThickSiCollectionID)); - - // Loop on the ThickSi map - for (ThickSi_itr = ThickSiHitMap->GetMap()->begin() ; ThickSi_itr != ThickSiHitMap->GetMap()->end() ; ThickSi_itr++){ - G4double* Info = *(ThickSi_itr->second); - double E_ThickSi = RandGauss::shoot(Info[0],ResoThickSi); - if(E_ThickSi>EnergyThreshold){ - m_EventLassa->SetLassaThickSiStripXEEnergy(E_ThickSi); - m_EventLassa->SetLassaThickSiStripXEDetectorNbr(Info[7]-1); - m_EventLassa->SetLassaThickSiStripXEStripNbr(Info[8]-1); - - m_EventLassa->SetLassaThickSiStripXTTime(Info[1]); - m_EventLassa->SetLassaThickSiStripXTDetectorNbr(Info[7]-1); - m_EventLassa->SetLassaThickSiStripXTStripNbr(Info[8]-1); - - m_EventLassa->SetLassaThickSiStripYEEnergy(E_ThickSi); - m_EventLassa->SetLassaThickSiStripYEDetectorNbr(Info[7]-1); - m_EventLassa->SetLassaThickSiStripYEStripNbr(Info[9]-1); - - m_EventLassa->SetLassaThickSiStripYTTime(Info[1]); - m_EventLassa->SetLassaThickSiStripYTDetectorNbr(Info[7]-1); - m_EventLassa->SetLassaThickSiStripYTStripNbr(Info[9]-1); - - // Interraction Coordinates - ms_InterCoord->SetDetectedPositionX(Info[2]) ; - ms_InterCoord->SetDetectedPositionY(Info[3]) ; - ms_InterCoord->SetDetectedPositionZ(Info[4]) ; - ms_InterCoord->SetDetectedAngleTheta(Info[5]/deg) ; - ms_InterCoord->SetDetectedAnglePhi(Info[6]/deg) ; - } +void Lassa::ReadSensitive(const G4Event* event) { + m_EventLassa->Clear(); + + // ThickSi // + NPS::HitsMap<G4double*>* ThickSiHitMap; + std::map<G4int, G4double**>::iterator ThickSi_itr; + G4int ThickSiCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("Lassa_ThickSiScorer/ThickSi"); + ThickSiHitMap = (NPS::HitsMap<G4double*>*)(event->GetHCofThisEvent()->GetHC(ThickSiCollectionID)); + + // Loop on the ThickSi map + for (ThickSi_itr = ThickSiHitMap->GetMap()->begin(); ThickSi_itr != ThickSiHitMap->GetMap()->end(); ThickSi_itr++) { + G4double* Info = *(ThickSi_itr->second); + double E_ThickSi = RandGauss::shoot(Info[0], ResoThickSi); + if (E_ThickSi > EnergyThreshold) { + m_EventLassa->SetLassaThickSiStripXEEnergy(E_ThickSi); + m_EventLassa->SetLassaThickSiStripXEDetectorNbr(Info[7] - 1); + m_EventLassa->SetLassaThickSiStripXEStripNbr(Info[8] - 1); + + m_EventLassa->SetLassaThickSiStripXTTime(Info[1]); + m_EventLassa->SetLassaThickSiStripXTDetectorNbr(Info[7] - 1); + m_EventLassa->SetLassaThickSiStripXTStripNbr(Info[8] - 1); + + m_EventLassa->SetLassaThickSiStripYEEnergy(E_ThickSi); + m_EventLassa->SetLassaThickSiStripYEDetectorNbr(Info[7] - 1); + m_EventLassa->SetLassaThickSiStripYEStripNbr(Info[9] - 1); + + m_EventLassa->SetLassaThickSiStripYTTime(Info[1]); + m_EventLassa->SetLassaThickSiStripYTDetectorNbr(Info[7] - 1); + m_EventLassa->SetLassaThickSiStripYTStripNbr(Info[9] - 1); + + // Interraction Coordinates + ms_InterCoord->SetDetectedPositionX(Info[2]); + ms_InterCoord->SetDetectedPositionY(Info[3]); + ms_InterCoord->SetDetectedPositionZ(Info[4]); + ms_InterCoord->SetDetectedAngleTheta(Info[5] / deg); + ms_InterCoord->SetDetectedAnglePhi(Info[6] / deg); } - // Clear Map for next event - ThickSiHitMap->clear(); - - CalorimeterScorers::PS_Calorimeter* Scorer= (CalorimeterScorers::PS_Calorimeter*) m_CsIScorer->GetPrimitive(0); - - unsigned int size = Scorer->GetMult(); - for(unsigned int i = 0 ; i < size ; i++){ - vector<unsigned int> level = Scorer->GetLevel(i); - double E_CsI = RandGauss::shoot(Scorer->GetEnergy(i),ResoCsI); - if(E_CsI>EnergyThreshold){ - m_EventLassa->SetLassaCsIEEnergy(E_CsI); - m_EventLassa->SetLassaCsIEDetectorNbr(level[0]-1); - m_EventLassa->SetLassaCsIECristalNbr(level[1]-1); - } + } + // Clear Map for next event + ThickSiHitMap->clear(); + + CalorimeterScorers::PS_Calorimeter* Scorer = (CalorimeterScorers::PS_Calorimeter*)m_CsIScorer->GetPrimitive(0); + + unsigned int size = Scorer->GetMult(); + for (unsigned int i = 0; i < size; i++) { + vector<unsigned int> level = Scorer->GetLevel(i); + double E_CsI = RandGauss::shoot(Scorer->GetEnergy(i), ResoCsI); + if (E_CsI > EnergyThreshold) { + m_EventLassa->SetLassaCsIEEnergy(E_CsI); + m_EventLassa->SetLassaCsIEDetectorNbr(level[0] - 1); + m_EventLassa->SetLassaCsIECristalNbr(level[1] - 1); } + } } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Lassa::InitializeScorers(){ - //Look for previous definition of the scorer (geometry reload) - bool already_exist = false; - vector<G4int> NestingLevel; - NestingLevel.push_back(0); - NestingLevel.push_back(2); - - m_ThickSiStripScorer = CheckScorer("Lassa_ThickSiScorer",already_exist); - m_CsIScorer = CheckScorer("Lassa_CsIScorer",already_exist); - - // if the scorer were created previously nothing else need to be made - if(already_exist) return; - - G4VPrimitiveScorer* ThickSiScorer = new SILICONSCORERS::PS_Silicon_Rectangle("ThickSi",0, - SiliconFace, - SiliconFace, - NumberOfStrip, - NumberOfStrip); - - m_ThickSiStripScorer->RegisterPrimitive(ThickSiScorer); - - G4VPrimitiveScorer* CsIScorer= new CalorimeterScorers::PS_Calorimeter("CsI",NestingLevel); - - m_CsIScorer->RegisterPrimitive(CsIScorer); - - // Add All Scorer to the Global Scorer Manager - G4SDManager::GetSDMpointer()->AddNewDetector(m_ThickSiStripScorer) ; - G4SDManager::GetSDMpointer()->AddNewDetector(m_CsIScorer) ; +void Lassa::InitializeScorers() { + // Look for previous definition of the scorer (geometry reload) + bool already_exist = false; + vector<G4int> NestingLevel; + NestingLevel.push_back(0); + NestingLevel.push_back(2); + + m_ThickSiStripScorer = CheckScorer("Lassa_ThickSiScorer", already_exist); + m_CsIScorer = CheckScorer("Lassa_CsIScorer", already_exist); + + // if the scorer were created previously nothing else need to be made + if (already_exist) + return; + + G4VPrimitiveScorer* ThickSiScorer = + new SILICONSCORERS::PS_Silicon_Rectangle("ThickSi", 0, SiliconFace, SiliconFace, NumberOfStrip, NumberOfStrip); + + m_ThickSiStripScorer->RegisterPrimitive(ThickSiScorer); + + G4VPrimitiveScorer* CsIScorer = new CalorimeterScorers::PS_Calorimeter("CsI", NestingLevel); + + m_CsIScorer->RegisterPrimitive(CsIScorer); + + // Add All Scorer to the Global Scorer Manager + G4SDManager::GetSDMpointer()->AddNewDetector(m_ThickSiStripScorer); + G4SDManager::GetSDMpointer()->AddNewDetector(m_CsIScorer); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Lassa::InitializeRootOutput(){ - TTree *pTree = RootOutput::getInstance()->GetTree(); - if(!pTree->FindBranch("Lassa")){ - pTree->Branch("Lassa", "TLassaData", &m_EventLassa) ; - } - // This insure that the object are correctly bind in case of - // a redifinition of the geometry in the simulation - pTree->SetBranchAddress("Lassa", &m_EventLassa) ; +void Lassa::InitializeRootOutput() { + TTree* pTree = RootOutput::getInstance()->GetTree(); + if (!pTree->FindBranch("Lassa")) { + pTree->Branch("Lassa", "TLassaData", &m_EventLassa); + } + // This insure that the object are correctly bind in case of + // a redifinition of the geometry in the simulation + pTree->SetBranchAddress("Lassa", &m_EventLassa); } - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Lassa::VolumeMaker(G4int DetectorNumber, - G4ThreeVector MMpos, - G4RotationMatrix* MMrot, - G4LogicalVolume* world) -{ - G4double NbrTelescopes = DetectorNumber ; - G4String DetNumber ; - ostringstream Number ; - Number << NbrTelescopes ; - DetNumber = Number.str() ; - - - //////////////////////////////////////////////////////////////// - ////////////// Starting Volume Definition ////////////////////// - //////////////////////////////////////////////////////////////// - G4String Name = "Lassa" + DetNumber ; - - // Definition of the volume containing the sensitive detector - G4Box* solidMotherVolume = new G4Box(Name, 0.5*FaceFront, 0.5*FaceBack, 0.5*Length); - m_logicMotherVolume = new G4LogicalVolume(solidMotherVolume, m_MaterialVacuum, Name, 0, 0, 0); - - new G4PVPlacement(G4Transform3D(*MMrot, MMpos), m_logicMotherVolume, Name, world, false, DetectorNumber); - - G4VisAttributes* MotherVolumeVisAtt = new G4VisAttributes(G4Colour(0.90, 0.90, 0.90)); - MotherVolumeVisAtt->SetForceWireframe(true); - m_logicMotherVolume->SetVisAttributes(G4VisAttributes::Invisible); - - /////////////////////////////////////////////////// - ///////////////////// Thick Si //////////////////// - /////////////////////////////////////////////////// - G4String NameThickSi = "ThickSi"+DetNumber; - //if(!m_LogicThickSi){ - if(0==0){ - G4Box* solidThickSi = new G4Box(NameThickSi, 0.5*SiliconFace, 0.5*SiliconFace, 0.5*ThickSiThickness); - m_LogicThickSi = new G4LogicalVolume(solidThickSi, m_MaterialSilicon, "logicThickSi", 0, 0, 0); - - G4ThreeVector positionThickSi = G4ThreeVector(0, 0, ThickSi_PosZ); - - new G4PVPlacement(new G4RotationMatrix(0,0,0), - positionThickSi, - m_LogicThickSi,"ThickSi", - m_logicMotherVolume,false,DetectorNumber); - - // Set ThickSi sensible - m_LogicThickSi->SetSensitiveDetector(m_ThickSiStripScorer); - - // Visualisation of ThickSi - m_LogicThickSi->SetVisAttributes(m_SiliconVisAtt) ; - } - - /////////////////////////////////////////////////// - /////////////////////// CsI /////////////////////// - /////////////////////////////////////////////////// - G4String NameCsI = "CsI"+DetNumber; - - double X1 = (CsIXFront-CsIXBack)/2.; - double Y1 = (CsIYFront-CsIYBack)/2.; - double l = sqrt(pow(X1,2) + pow(Y1,2)); - - double pDz = 0.5*CsIThickness; - double pTheta = -atan( (l)/(CsIThickness) ); - double pPhi = atan( X1/Y1 ); - double pDy1 = 0.5*CsIYFront; - double pDx1 = 0.5*CsIXFront; - double pDx2 = 0.5*CsIXFront; - double pAlp1 = 0; - double pDy2 = 0.5*CsIYBack; - double pDx3 = 0.5*CsIXBack; - double pDx4 = 0.5*CsIXBack; - double pAlp2 = 0; - - G4Trap* solidCsIStage = new G4Trap(NameCsI, pDz, pTheta, pPhi, pDy1, pDx1, pDx2, pAlp1, pDy2, pDx3, pDx4, pAlp2); - - - m_LogicCsICrystal = new G4LogicalVolume(solidCsIStage, m_MaterialCsI, "logicCsICrystal", 0, 0, 0); - - // Set CsI sensible - m_LogicCsICrystal->SetSensitiveDetector(m_CsIScorer); - - // Visualisation of CsI - m_LogicCsICrystal->SetVisAttributes(m_CsIVisAtt); - - //if(!m_LogicCluster){ - if(0==0){ - // Sub Mother Volume - G4Trd* solidCluster = new G4Trd("SolidCluster", 0.5*ClusterFaceFront,0.5*ClusterFaceBack,0.5*ClusterFaceFront,0.5*ClusterFaceBack, 0.5*CsIThickness); - m_LogicCluster = new G4LogicalVolume(solidCluster, m_MaterialVacuum, "LogicSolidCluster", 0, 0, 0); - m_LogicCluster->SetVisAttributes(G4VisAttributes::Invisible); - - G4ThreeVector FramePos(0,0,CsI_PosZ); - - new G4PVPlacement(new G4RotationMatrix(0,0,0), - FramePos, - m_LogicCluster,"Cluster", - m_logicMotherVolume,false,0); - - //const G4double CsIXMiddle = CsIXFront + (CsIThickness/2)*tan(-pTheta)*sin(pPhi); - //const G4double CsIYMiddle = CsIYFront + (CsIThickness/2)*tan(-pTheta)*cos(pPhi); - //double alpha = atan((CsIXBack-CsIXFront)/CsIThickness); - //double dl = (CsIThickness/2)*tan(alpha); - double dl = (CsIXBack-CsIXFront)/4; - const G4double CsIXMiddle = 0.5*CsIXFront + dl; - const G4double CsIYMiddle = 0.5*CsIYFront + dl; - const G4double DistInterCsIX = CsIXMiddle+0.5*DistInterCsI; - const G4double DistInterCsIY = CsIYMiddle+0.5*DistInterCsI; - - G4ThreeVector Origin(-DistInterCsIX,-DistInterCsIY,0); - G4ThreeVector Pos; - const G4double dangle = 90.*deg; - // A cluster is a 2 by 2 aggregat of CsI crystal - unsigned int CsINbr = 1; - for(unsigned int i = 0 ; i < 2 ; i++){ - for(unsigned int j = 0 ; j < 2 ; j++){ - G4RotationMatrix* rotM = new G4RotationMatrix; - unsigned int CrystalNbr = CsINbr++; - if(i==0 && j==0)rotM->rotateZ(0); - if(i==1 && j==0)rotM->rotateZ(dangle); - if(i==0 && j==1)rotM->rotateZ(-dangle); - if(i==1 && j==1)rotM->rotateZ(2*dangle); - - if(i==0 && j==0) Pos = Origin; - if(i==1 && j==0) Pos = G4ThreeVector((DistInterCsIX),-(DistInterCsIY),0); - if(i==0 && j==1) Pos = G4ThreeVector(-(DistInterCsIX),(DistInterCsIY),0); - if(i==1 && j==1) Pos = G4ThreeVector((DistInterCsIX),(DistInterCsIY),0); - //Pos = Origin + G4ThreeVector(i*DistInterCsIX,j*DistInterCsIY,0); - - new G4PVPlacement(G4Transform3D(*rotM,Pos), - m_LogicCsICrystal, - "CsI_Cristal", - m_LogicCluster, - false, - CrystalNbr, true); - delete rotM; - } - } - +void Lassa::VolumeMaker(G4int DetectorNumber, G4ThreeVector MMpos, G4RotationMatrix* MMrot, G4LogicalVolume* world) { + G4double NbrTelescopes = DetectorNumber; + G4String DetNumber; + ostringstream Number; + Number << NbrTelescopes; + DetNumber = Number.str(); + + //////////////////////////////////////////////////////////////// + ////////////// Starting Volume Definition ////////////////////// + //////////////////////////////////////////////////////////////// + G4String Name = "Lassa" + DetNumber; + + // Definition of the volume containing the sensitive detector + G4Box* solidMotherVolume = new G4Box(Name, 0.5 * FaceFront, 0.5 * FaceBack, 0.5 * Length); + m_logicMotherVolume = new G4LogicalVolume(solidMotherVolume, m_MaterialVacuum, Name, 0, 0, 0); + + new G4PVPlacement(G4Transform3D(*MMrot, MMpos), m_logicMotherVolume, Name, world, false, DetectorNumber); + + G4VisAttributes* MotherVolumeVisAtt = new G4VisAttributes(G4Colour(0.90, 0.90, 0.90)); + MotherVolumeVisAtt->SetForceWireframe(true); + m_logicMotherVolume->SetVisAttributes(G4VisAttributes::GetInvisible()); + + /////////////////////////////////////////////////// + ///////////////////// Thick Si //////////////////// + /////////////////////////////////////////////////// + G4String NameThickSi = "ThickSi" + DetNumber; + // if(!m_LogicThickSi){ + if (0 == 0) { + G4Box* solidThickSi = new G4Box(NameThickSi, 0.5 * SiliconFace, 0.5 * SiliconFace, 0.5 * ThickSiThickness); + m_LogicThickSi = new G4LogicalVolume(solidThickSi, m_MaterialSilicon, "logicThickSi", 0, 0, 0); + + G4ThreeVector positionThickSi = G4ThreeVector(0, 0, ThickSi_PosZ); + + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), positionThickSi, m_LogicThickSi, "ThickSi", m_logicMotherVolume, + false, DetectorNumber); + + // Set ThickSi sensible + m_LogicThickSi->SetSensitiveDetector(m_ThickSiStripScorer); + + // Visualisation of ThickSi + m_LogicThickSi->SetVisAttributes(m_SiliconVisAtt); + } + + /////////////////////////////////////////////////// + /////////////////////// CsI /////////////////////// + /////////////////////////////////////////////////// + G4String NameCsI = "CsI" + DetNumber; + + double X1 = (CsIXFront - CsIXBack) / 2.; + double Y1 = (CsIYFront - CsIYBack) / 2.; + double l = sqrt(pow(X1, 2) + pow(Y1, 2)); + + double pDz = 0.5 * CsIThickness; + double pTheta = -atan((l) / (CsIThickness)); + double pPhi = atan(X1 / Y1); + double pDy1 = 0.5 * CsIYFront; + double pDx1 = 0.5 * CsIXFront; + double pDx2 = 0.5 * CsIXFront; + double pAlp1 = 0; + double pDy2 = 0.5 * CsIYBack; + double pDx3 = 0.5 * CsIXBack; + double pDx4 = 0.5 * CsIXBack; + double pAlp2 = 0; + + G4Trap* solidCsIStage = new G4Trap(NameCsI, pDz, pTheta, pPhi, pDy1, pDx1, pDx2, pAlp1, pDy2, pDx3, pDx4, pAlp2); + + m_LogicCsICrystal = new G4LogicalVolume(solidCsIStage, m_MaterialCsI, "logicCsICrystal", 0, 0, 0); + + // Set CsI sensible + m_LogicCsICrystal->SetSensitiveDetector(m_CsIScorer); + + // Visualisation of CsI + m_LogicCsICrystal->SetVisAttributes(m_CsIVisAtt); + + // if(!m_LogicCluster){ + if (0 == 0) { + // Sub Mother Volume + G4Trd* solidCluster = new G4Trd("SolidCluster", 0.5 * ClusterFaceFront, 0.5 * ClusterFaceBack, + 0.5 * ClusterFaceFront, 0.5 * ClusterFaceBack, 0.5 * CsIThickness); + m_LogicCluster = new G4LogicalVolume(solidCluster, m_MaterialVacuum, "LogicSolidCluster", 0, 0, 0); + m_LogicCluster->SetVisAttributes(G4VisAttributes::GetInvisible()); + + G4ThreeVector FramePos(0, 0, CsI_PosZ); + + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), FramePos, m_LogicCluster, "Cluster", m_logicMotherVolume, false, + 0); + + // const G4double CsIXMiddle = CsIXFront + (CsIThickness/2)*tan(-pTheta)*sin(pPhi); + // const G4double CsIYMiddle = CsIYFront + (CsIThickness/2)*tan(-pTheta)*cos(pPhi); + // double alpha = atan((CsIXBack-CsIXFront)/CsIThickness); + // double dl = (CsIThickness/2)*tan(alpha); + double dl = (CsIXBack - CsIXFront) / 4; + const G4double CsIXMiddle = 0.5 * CsIXFront + dl; + const G4double CsIYMiddle = 0.5 * CsIYFront + dl; + const G4double DistInterCsIX = CsIXMiddle + 0.5 * DistInterCsI; + const G4double DistInterCsIY = CsIYMiddle + 0.5 * DistInterCsI; + + G4ThreeVector Origin(-DistInterCsIX, -DistInterCsIY, 0); + G4ThreeVector Pos; + const G4double dangle = 90. * deg; + // A cluster is a 2 by 2 aggregat of CsI crystal + unsigned int CsINbr = 1; + for (unsigned int i = 0; i < 2; i++) { + for (unsigned int j = 0; j < 2; j++) { + G4RotationMatrix* rotM = new G4RotationMatrix; + unsigned int CrystalNbr = CsINbr++; + if (i == 0 && j == 0) + rotM->rotateZ(0); + if (i == 1 && j == 0) + rotM->rotateZ(dangle); + if (i == 0 && j == 1) + rotM->rotateZ(-dangle); + if (i == 1 && j == 1) + rotM->rotateZ(2 * dangle); + + if (i == 0 && j == 0) + Pos = Origin; + if (i == 1 && j == 0) + Pos = G4ThreeVector((DistInterCsIX), -(DistInterCsIY), 0); + if (i == 0 && j == 1) + Pos = G4ThreeVector(-(DistInterCsIX), (DistInterCsIY), 0); + if (i == 1 && j == 1) + Pos = G4ThreeVector((DistInterCsIX), (DistInterCsIY), 0); + // Pos = Origin + G4ThreeVector(i*DistInterCsIX,j*DistInterCsIY,0); + + new G4PVPlacement(G4Transform3D(*rotM, Pos), m_LogicCsICrystal, "CsI_Cristal", m_LogicCluster, false, + CrystalNbr, true); + delete rotM; + } } + } } - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Lassa::InitializeMaterial(){ - m_MaterialSilicon = MaterialManager::getInstance()->GetMaterialFromLibrary("Si"); - m_MaterialAluminium = MaterialManager::getInstance()->GetMaterialFromLibrary("Al"); - m_MaterialCsI = MaterialManager::getInstance()->GetMaterialFromLibrary("CsI"); - m_MaterialMylar = MaterialManager::getInstance()->GetMaterialFromLibrary("Mylar"); - m_MaterialPCB = MaterialManager::getInstance()->GetMaterialFromLibrary("PCB"); - m_MaterialVacuum = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); +void Lassa::InitializeMaterial() { + m_MaterialSilicon = MaterialManager::getInstance()->GetMaterialFromLibrary("Si"); + m_MaterialAluminium = MaterialManager::getInstance()->GetMaterialFromLibrary("Al"); + m_MaterialCsI = MaterialManager::getInstance()->GetMaterialFromLibrary("CsI"); + m_MaterialMylar = MaterialManager::getInstance()->GetMaterialFromLibrary("Mylar"); + m_MaterialPCB = MaterialManager::getInstance()->GetMaterialFromLibrary("PCB"); + m_MaterialVacuum = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); } //////////////////////////////////////////////////////////////////////////////// // Construct Method to be pass to the DetectorFactory // //////////////////////////////////////////////////////////////////////////////// -NPS::VDetector* Lassa::Construct(){ - return (NPS::VDetector*) new Lassa(); -} +NPS::VDetector* Lassa::Construct() { return (NPS::VDetector*)new Lassa(); } //////////////////////////////////////////////////////////////////////////////// // Registering the construct method to the factory // //////////////////////////////////////////////////////////////////////////////// -extern"C" { - class proxy_nps_lassa{ - public: - proxy_nps_lassa(){ - NPS::DetectorFactory::getInstance()->AddToken("LASSAArray","Lassa"); - NPS::DetectorFactory::getInstance()->AddDetector("LASSAArray",Lassa::Construct); - } - }; - - proxy_nps_lassa p_nps_lassa; -} - +extern "C" { +class proxy_nps_lassa { + public: + proxy_nps_lassa() { + NPS::DetectorFactory::getInstance()->AddToken("LASSAArray", "Lassa"); + NPS::DetectorFactory::getInstance()->AddDetector("LASSAArray", Lassa::Construct); + } +}; +proxy_nps_lassa p_nps_lassa; +} diff --git a/NPSimulation/Detectors/LightPipe/LightPipe.cc b/NPSimulation/Detectors/LightPipe/LightPipe.cc index b9c0ee23aa1088b4f0d472182edd49e4df920e1b..af89e744031cc434151fc66b9f0c1caf8bf5535d 100644 --- a/NPSimulation/Detectors/LightPipe/LightPipe.cc +++ b/NPSimulation/Detectors/LightPipe/LightPipe.cc @@ -20,226 +20,215 @@ *****************************************************************************/ // C++ headers -#include <sstream> +#include <algorithm> #include <cmath> -#include <limits> #include <fstream> -#include <algorithm> -//G4 Geometry object -#include "G4Tubs.hh" +#include <limits> +#include <sstream> +// G4 Geometry object #include "G4Box.hh" +#include "G4Tubs.hh" -//G4 sensitive -#include "G4SDManager.hh" +// G4 sensitive #include "G4MultiFunctionalDetector.hh" +#include "G4SDManager.hh" -//G4 various object -#include "G4Material.hh" -#include "G4Transform3D.hh" -#include "G4PVPlacement.hh" -#include "G4VisAttributes.hh" +// G4 various object #include "G4Colour.hh" -#include "G4OpticalSurface.hh" #include "G4LogicalBorderSurface.hh" #include "G4LogicalSkinSurface.hh" +#include "G4Material.hh" +#include "G4OpticalSurface.hh" +#include "G4PVPlacement.hh" +#include "G4Transform3D.hh" +#include "G4VisAttributes.hh" // ROOT -#include "TSystem.h" #include "TMath.h" +#include "TSystem.h" // NPTool header -#include "LightPipe.hh" #include "CalorimeterScorers.hh" -#include "PhotoDiodeScorers.hh" -#include "RootOutput.h" +#include "LightPipe.hh" #include "MaterialManager.hh" -#include "NPSDetectorFactory.hh" #include "NPOptionManager.h" +#include "NPSDetectorFactory.hh" #include "NPSHitsMap.hh" +#include "PhotoDiodeScorers.hh" +#include "RootOutput.h" // CLHEP header #include "CLHEP/Random/RandGauss.h" using namespace std; using namespace CLHEP; - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // LightPipe Specific Method -LightPipe::LightPipe(){ - m_Event = new TLightPipeData() ; +LightPipe::LightPipe() { + m_Event = new TLightPipeData(); m_LightPipeScorer = 0; // RGB Color + Transparency m_VisSquare = new G4VisAttributes(G4Colour(0, 0, 1, 0.5)); - m_VisPipe = new G4VisAttributes(G4Colour(0, 1, 0, 0.5)); - m_VisPD = new G4VisAttributes(G4Colour(0.1, 0.2, 0.3)); - m_ScintillatorMaterial = CreateScintillatorMaterial(); - m_PipeMaterial = CreatePipeMaterial(); - //m_WrappingMaterial = CreateWrappingMaterial(); -// m_WrappingMaterial = NULL; - m_ReflectiveSurface = CreateReflectiveSurface(); - - m_VisSquare->SetForceWireframe(true); - m_VisPipe->SetForceWireframe(true); + m_VisPipe = new G4VisAttributes(G4Colour(0, 1, 0, 0.5)); + m_VisPD = new G4VisAttributes(G4Colour(0.1, 0.2, 0.3)); + m_ScintillatorMaterial = CreateScintillatorMaterial(); + m_PipeMaterial = CreatePipeMaterial(); + // m_WrappingMaterial = CreateWrappingMaterial(); + // m_WrappingMaterial = NULL; + m_ReflectiveSurface = CreateReflectiveSurface(); + + m_VisSquare->SetForceWireframe(true); + m_VisPipe->SetForceWireframe(true); } -LightPipe::~LightPipe(){ -} +LightPipe::~LightPipe() {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void LightPipe::AddDetector(G4int nrow, G4int ncol, G4int nlayer, G4double width, G4double thickness, G4double pipe_width, G4double pipe_thickness){ - m_Detector.emplace_back(make_tuple(nrow,ncol,nlayer,width,thickness,pipe_width,pipe_thickness)); +void LightPipe::AddDetector(G4int nrow, G4int ncol, G4int nlayer, G4double width, G4double thickness, + G4double pipe_width, G4double pipe_thickness) { + m_Detector.emplace_back(make_tuple(nrow, ncol, nlayer, width, thickness, pipe_width, pipe_thickness)); } - - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Virtual Method of NPS::VDetector class // Read stream at Configfile to pick-up parameters of detector (Position,...) // Called in DetecorConstruction::ReadDetextorConfiguration Method -void LightPipe::ReadConfiguration(NPL::InputParser parser){ +void LightPipe::ReadConfiguration(NPL::InputParser parser) { - G4double width = 10*mm; - G4double thickness = 10*mm; - G4double pipe_width = 3*mm; - G4double pipe_thickness = 1*mm; - G4int nrow = 1; - G4int ncol = 1; - G4int nlayer = 1; + G4double width = 10 * mm; + G4double thickness = 10 * mm; + G4double pipe_width = 3 * mm; + G4double pipe_thickness = 1 * mm; + G4int nrow = 1; + G4int ncol = 1; + G4int nlayer = 1; vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithToken("LightPipe"); - if(true || NPOptionManager::getInstance()->GetVerboseLevel()) - cout << "//// " << blocks.size() << " detectors found " << endl; - vector<string> lp = {"WIDTH","THICKNESS","PIPE_WIDTH","PIPE_THICKNESS","NROW","NCOL","NLAYER"}; - - for(unsigned int i = 0 ; i < blocks.size() ; i++){ - if(blocks[i]->HasTokenList(lp)){ - if(true || NPOptionManager::getInstance()->GetVerboseLevel()){ - cout << endl << "//// LightPipe " << i+1 << endl; - } - width = blocks[i]->GetDouble("WIDTH", "mm"); - thickness = blocks[i]->GetDouble("THICKNESS", "mm"); - pipe_width = blocks[i]->GetDouble("PIPE_WIDTH", "mm"); - pipe_thickness = blocks[i]->GetDouble("PIPE_THICKNESS", "mm"); - nrow = blocks[i]->GetInt("NROW"); - ncol = blocks[i]->GetInt("NCOL"); - nlayer = blocks[i]->GetInt("NLAYER"); + if (true || NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks.size() << " detectors found " << endl; + vector<string> lp = {"WIDTH", "THICKNESS", "PIPE_WIDTH", "PIPE_THICKNESS", "NROW", "NCOL", "NLAYER"}; + + for (unsigned int i = 0; i < blocks.size(); i++) { + if (blocks[i]->HasTokenList(lp)) { + if (true || NPOptionManager::getInstance()->GetVerboseLevel()) { + cout << endl << "//// LightPipe " << i + 1 << endl; + } + width = blocks[i]->GetDouble("WIDTH", "mm"); + thickness = blocks[i]->GetDouble("THICKNESS", "mm"); + pipe_width = blocks[i]->GetDouble("PIPE_WIDTH", "mm"); + pipe_thickness = blocks[i]->GetDouble("PIPE_THICKNESS", "mm"); + nrow = blocks[i]->GetInt("NROW"); + ncol = blocks[i]->GetInt("NCOL"); + nlayer = blocks[i]->GetInt("NLAYER"); } - else{ + else { cout << "ERROR: check your input file formatting " << endl; exit(1); } } - // - AddDetector(nrow, ncol, nlayer, width, thickness, pipe_width, pipe_thickness); + // + AddDetector(nrow, ncol, nlayer, width, thickness, pipe_width, pipe_thickness); } - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Construct detector and inialise sensitive part. // Called After DetecorConstruction::AddDetector Method -void LightPipe::ConstructDetector(G4LogicalVolume* world){ - bool warnOverlap = false; - - - //Create experimental hall - G4Material* Vacuum = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum") ; - G4double expHall_x = 10.*m; - G4double expHall_y = 10.*m; - G4double expHall_z = 10.*m; - - G4Box* fExperimentalHall_box = new G4Box("expHall_box",expHall_x,expHall_y,expHall_z); - G4LogicalVolume* fExperimentalHall_log = new G4LogicalVolume(fExperimentalHall_box, - Vacuum,"expHall_log",0,0,0); - G4VPhysicalVolume* fExperimentalHall_phys = new G4PVPlacement(0,G4ThreeVector(), - fExperimentalHall_log,"expHall",0,false,0); - - fExperimentalHall_log->SetVisAttributes(G4VisAttributes::Invisible); - - auto BuildRectangle = [this](G4double width, G4double length, G4double thickness, G4Material* material){ - G4Box* box = new G4Box("LightPipe_Box",width*0.5, - length*0.5,thickness*0.5); - G4LogicalVolume* Detector = new G4LogicalVolume(box,material,"logic_LightPipe_Box",0,0,0); +void LightPipe::ConstructDetector(G4LogicalVolume* world) { + bool warnOverlap = false; + + // Create experimental hall + G4Material* Vacuum = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); + G4double expHall_x = 10. * m; + G4double expHall_y = 10. * m; + G4double expHall_z = 10. * m; + + G4Box* fExperimentalHall_box = new G4Box("expHall_box", expHall_x, expHall_y, expHall_z); + G4LogicalVolume* fExperimentalHall_log = new G4LogicalVolume(fExperimentalHall_box, Vacuum, "expHall_log", 0, 0, 0); + G4VPhysicalVolume* fExperimentalHall_phys = + new G4PVPlacement(0, G4ThreeVector(), fExperimentalHall_log, "expHall", 0, false, 0); + + fExperimentalHall_log->SetVisAttributes(G4VisAttributes::GetInvisible()); + + auto BuildRectangle = [this](G4double width, G4double length, G4double thickness, G4Material* material) { + G4Box* box = new G4Box("LightPipe_Box", width * 0.5, length * 0.5, thickness * 0.5); + G4LogicalVolume* Detector = new G4LogicalVolume(box, material, "logic_LightPipe_Box", 0, 0, 0); Detector->SetVisAttributes(this->m_VisSquare); -// Detector->SetSensitiveDetector(this->m_LightPipeScorer); - return Detector; - }; - auto getCenter = [&](int i, int imax, double width){ - return (i - (imax/2.))*width + width/2.; - }; - - //int i=0, j=0, k=0; - - int iPipeX=1,/* iPipeY=1,*/ iDet=1; - for(const auto& det : m_Detector) { - const G4int& nrow = get<0>(det); - const G4int& ncol = get<1>(det); - //const G4int& nlayer = get<2>(det); - const G4double& width = get<3>(det); - const G4double& thickness = get<4>(det); - const G4double& pipe_width = get<5>(det); - const G4double& pipe_thickness = get<6>(det); - //const G4double pd_thickness = 1*mm; - - vector<vector<G4PVPlacement*> > physVol(nrow); - for(auto& v : physVol) { v.resize(ncol); } - - - auto buildRow = [&](G4int irow, G4double z){ - //G4double rowWidthX = nrow*width; - G4double pipe_length = width*ncol + 1*cm; - // - // Build light pipe above detectors - // - // Create geometric object - G4ThreeVector pipePos( - 0, getCenter(irow, nrow, width) + width/2. + pipe_thickness/2., z); - auto pipe = BuildRectangle( - pipe_length, pipe_width, pipe_thickness, m_PipeMaterial); - pipe->SetVisAttributes(m_VisPipe); - // Rotate it - G4RotationMatrix* myRotation = new G4RotationMatrix(); - myRotation->rotateX(90.*deg); - // Create PV Placement - new G4PVPlacement( - myRotation, pipePos, pipe, "LightPipe_PipeX", world, false, iPipeX++, warnOverlap); - - std::vector<G4PVPlacement*> pvRow; - for(int icol=0; icol< ncol; ++icol){ - // - // Build row of detectors - // - // - // Create geometric object - G4ThreeVector Det_pos - (getCenter(icol,ncol,width), getCenter(irow,nrow,width), z); - auto Scintillator = BuildRectangle(width, width, thickness, m_ScintillatorMaterial); -// Scintillator->SetSensitiveDetector(this->m_LightPipeScorer); - // Create PV placement - pvRow.push_back( - new G4PVPlacement( - 0, Det_pos, Scintillator, "LightPipe_Detector", world, false, iDet++, warnOverlap) ); - } - // Create reflective surfaces between detectors - for(int icol=0; icol< ncol; ++icol){ - // to the left - if(icol != 0) { - new G4LogicalBorderSurface("CrystalSurface", pvRow.at(icol-1), pvRow.at(icol), m_ReflectiveSurface); - } else { - new G4LogicalBorderSurface("CrystalSurface", fExperimentalHall_phys, pvRow.at(icol), m_ReflectiveSurface); - } - // to the right - if(icol != ncol-1) { - new G4LogicalBorderSurface("CrystalSurface", pvRow.at(icol), pvRow.at(icol+1), m_ReflectiveSurface); - } else { - new G4LogicalBorderSurface("CrystalSurface", pvRow.at(icol), fExperimentalHall_phys, m_ReflectiveSurface); - } - } - return pvRow; - }; + // Detector->SetSensitiveDetector(this->m_LightPipeScorer); + return Detector; + }; + auto getCenter = [&](int i, int imax, double width) { return (i - (imax / 2.)) * width + width / 2.; }; + + // int i=0, j=0, k=0; + + int iPipeX = 1, /* iPipeY=1,*/ iDet = 1; + for (const auto& det : m_Detector) { + const G4int& nrow = get<0>(det); + const G4int& ncol = get<1>(det); + // const G4int& nlayer = get<2>(det); + const G4double& width = get<3>(det); + const G4double& thickness = get<4>(det); + const G4double& pipe_width = get<5>(det); + const G4double& pipe_thickness = get<6>(det); + // const G4double pd_thickness = 1*mm; + + vector<vector<G4PVPlacement*>> physVol(nrow); + for (auto& v : physVol) { + v.resize(ncol); + } - buildRow(5,0); + auto buildRow = [&](G4int irow, G4double z) { + // G4double rowWidthX = nrow*width; + G4double pipe_length = width * ncol + 1 * cm; + // + // Build light pipe above detectors + // + // Create geometric object + G4ThreeVector pipePos(0, getCenter(irow, nrow, width) + width / 2. + pipe_thickness / 2., z); + auto pipe = BuildRectangle(pipe_length, pipe_width, pipe_thickness, m_PipeMaterial); + pipe->SetVisAttributes(m_VisPipe); + // Rotate it + G4RotationMatrix* myRotation = new G4RotationMatrix(); + myRotation->rotateX(90. * deg); + // Create PV Placement + new G4PVPlacement(myRotation, pipePos, pipe, "LightPipe_PipeX", world, false, iPipeX++, warnOverlap); + + std::vector<G4PVPlacement*> pvRow; + for (int icol = 0; icol < ncol; ++icol) { + // + // Build row of detectors + // + // + // Create geometric object + G4ThreeVector Det_pos(getCenter(icol, ncol, width), getCenter(irow, nrow, width), z); + auto Scintillator = BuildRectangle(width, width, thickness, m_ScintillatorMaterial); + // Scintillator->SetSensitiveDetector(this->m_LightPipeScorer); + // Create PV placement + pvRow.push_back( + new G4PVPlacement(0, Det_pos, Scintillator, "LightPipe_Detector", world, false, iDet++, warnOverlap)); + } + // Create reflective surfaces between detectors + for (int icol = 0; icol < ncol; ++icol) { + // to the left + if (icol != 0) { + new G4LogicalBorderSurface("CrystalSurface", pvRow.at(icol - 1), pvRow.at(icol), m_ReflectiveSurface); + } + else { + new G4LogicalBorderSurface("CrystalSurface", fExperimentalHall_phys, pvRow.at(icol), m_ReflectiveSurface); + } + // to the right + if (icol != ncol - 1) { + new G4LogicalBorderSurface("CrystalSurface", pvRow.at(icol), pvRow.at(icol + 1), m_ReflectiveSurface); + } + else { + new G4LogicalBorderSurface("CrystalSurface", pvRow.at(icol), fExperimentalHall_phys, m_ReflectiveSurface); + } + } + return pvRow; + }; + + buildRow(5, 0); #if 0 int pdNum = 1; @@ -363,26 +352,26 @@ void LightPipe::ConstructDetector(G4LogicalVolume* world){ buildPipe(true, detZ); } // for(ilayer) #endif - } + } } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Add Detector branch to the EventTree. // Called After DetecorConstruction::AddDetector Method -void LightPipe::InitializeRootOutput(){ - RootOutput *pAnalysis = RootOutput::getInstance(); - TTree *pTree = pAnalysis->GetTree(); - if(!pTree->FindBranch("LightPipe")){ - pTree->Branch("LightPipe", "TLightPipeData", &m_Event) ; +void LightPipe::InitializeRootOutput() { + RootOutput* pAnalysis = RootOutput::getInstance(); + TTree* pTree = pAnalysis->GetTree(); + if (!pTree->FindBranch("LightPipe")) { + pTree->Branch("LightPipe", "TLightPipeData", &m_Event); } - pTree->SetBranchAddress("LightPipe", &m_Event) ; + pTree->SetBranchAddress("LightPipe", &m_Event); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Read sensitive part and fill the Root tree. // Called at in the EventAction::EndOfEventAvtion -void LightPipe::ReadSensitive(const G4Event* event){ +void LightPipe::ReadSensitive(const G4Event* event) { m_Event->Clear(); - return; + return; /////////// // Calorimeter scorer NPS::HitsMap<G4double*>* CaloHitMap; @@ -407,222 +396,224 @@ void LightPipe::ReadSensitive(const G4Event* event){ // clear map for next event CaloHitMap->clear(); - // PhotoDiode // - NPS::HitsMap<G4double*>* PhotoDiodeHitMap; - std::map<G4int, G4double**>::iterator PhotoDiode_itr; - - G4int PhotoDiodeCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("PDScorer/PhotoDiode"); - PhotoDiodeHitMap = (NPS::HitsMap<G4double*>*)(event->GetHCofThisEvent()->GetHC(PhotoDiodeCollectionID)); - - // Loop on the PhotoDiode map - map<int, int> NumberOfOpticalPhoton; // <det no, # photons> - for(const auto& hit : *PhotoDiodeHitMap->GetMap()) { - G4double* Info = *(hit.second); - G4int detectorNumber = Info[7]; - if(NumberOfOpticalPhoton.find(detectorNumber) == NumberOfOpticalPhoton.end()){ - NumberOfOpticalPhoton[detectorNumber] = 0; - } - NumberOfOpticalPhoton[detectorNumber] += Info[8]; - } - - for(const auto& pd : NumberOfOpticalPhoton) { - int det = pd.first; // detector number - int numPhoton = pd.second; - auto detMap = m_DetectorMap.find(det); - if(detMap != m_DetectorMap.end()){ - const auto& side = get<0>(detMap->second); - const auto& layer = get<1>(detMap->second); - const auto& row = get<2>(detMap->second); - m_Event->SetEnergy(side, layer, row, numPhoton); - } else { - std::cerr << "WARNING:: Detector number encountered without map! The number is: " << det << "\nSkipping event...\n"; - } - } - - PhotoDiodeHitMap->clear(); + // PhotoDiode // + NPS::HitsMap<G4double*>* PhotoDiodeHitMap; + std::map<G4int, G4double**>::iterator PhotoDiode_itr; + + G4int PhotoDiodeCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("PDScorer/PhotoDiode"); + PhotoDiodeHitMap = (NPS::HitsMap<G4double*>*)(event->GetHCofThisEvent()->GetHC(PhotoDiodeCollectionID)); + + // Loop on the PhotoDiode map + map<int, int> NumberOfOpticalPhoton; // <det no, # photons> + for (const auto& hit : *PhotoDiodeHitMap->GetMap()) { + G4double* Info = *(hit.second); + G4int detectorNumber = Info[7]; + if (NumberOfOpticalPhoton.find(detectorNumber) == NumberOfOpticalPhoton.end()) { + NumberOfOpticalPhoton[detectorNumber] = 0; + } + NumberOfOpticalPhoton[detectorNumber] += Info[8]; + } + + for (const auto& pd : NumberOfOpticalPhoton) { + int det = pd.first; // detector number + int numPhoton = pd.second; + auto detMap = m_DetectorMap.find(det); + if (detMap != m_DetectorMap.end()) { + const auto& side = get<0>(detMap->second); + const auto& layer = get<1>(detMap->second); + const auto& row = get<2>(detMap->second); + m_Event->SetEnergy(side, layer, row, numPhoton); + } + else { + std::cerr << "WARNING:: Detector number encountered without map! The number is: " << det + << "\nSkipping event...\n"; + } + } + + PhotoDiodeHitMap->clear(); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -//////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////// void LightPipe::InitializeScorers() { // This check is necessary in case the geometry is reloaded bool already_exist = false; - vector<G4int> NestingLevel; - NestingLevel.push_back(0); - NestingLevel.push_back(1); - m_LightPipeScorer = CheckScorer("LightPipeScorer",already_exist) ; - m_PDScorer = CheckScorer("PDScorer",already_exist) ; - - if(already_exist) { - return ; - } + vector<G4int> NestingLevel; + NestingLevel.push_back(0); + NestingLevel.push_back(1); + m_LightPipeScorer = CheckScorer("LightPipeScorer", already_exist); + m_PDScorer = CheckScorer("PDScorer", already_exist); + + if (already_exist) { + return; + } // Otherwise the scorer is initialised - vector<int> level; level.push_back(0); - G4VPrimitiveScorer* Calorimeter= new CalorimeterScorers::PS_Calorimeter("Calorimeter",NestingLevel, 0) ; - //and register it to the multifunctionnal detector + vector<int> level; + level.push_back(0); + G4VPrimitiveScorer* Calorimeter = new CalorimeterScorers::PS_Calorimeter("Calorimeter", NestingLevel, 0); + // and register it to the multifunctionnal detector m_LightPipeScorer->RegisterPrimitive(Calorimeter); - G4VPrimitiveScorer* PDScorer = - new PHOTODIODESCORERS::PS_PhotoDiode_Rectangle - ("PhotoDiode",0,GetPipeWidth(0),GetPipeWidth(0),1,1); - m_PDScorer->RegisterPrimitive(PDScorer); - - G4SDManager::GetSDMpointer()->AddNewDetector(m_LightPipeScorer) ; - G4SDManager::GetSDMpointer()->AddNewDetector(m_PDScorer) ; + G4VPrimitiveScorer* PDScorer = + new PHOTODIODESCORERS::PS_PhotoDiode_Rectangle("PhotoDiode", 0, GetPipeWidth(0), GetPipeWidth(0), 1, 1); + m_PDScorer->RegisterPrimitive(PDScorer); + + G4SDManager::GetSDMpointer()->AddNewDetector(m_LightPipeScorer); + G4SDManager::GetSDMpointer()->AddNewDetector(m_PDScorer); } - + G4Material* LightPipe::CreateScintillatorMaterial() const { - // p-Terphenyl - // Taken from Proteus, Inc. specs - // See here: http://people.physics.tamu.edu/christian/files/p-terphenyl.png - // - G4double specificGravity = 1.23; // from proteus - G4double densityReference = 0.999972*g/cm3; // water @4-deg C [ the standard ] - G4double density = specificGravity*densityReference; - - G4Material* material = new G4Material("p_Terphenyl_Scint", density, 2); - material->AddElement(MaterialManager::getInstance()->GetElementFromLibrary("H"), 10); - material->AddElement(MaterialManager::getInstance()->GetElementFromLibrary("C"), 14); - - // Adding Scintillation property: - vector<double> energy, scint, fast, slow, rindx, atten; - { - // Read emission spectrum from datfile (+ add constant parameters) - ifstream ifs(gSystem->ExpandPathName("$NPTOOL/NPSimulation/Detectors/LightPipe/p-terphenyl_emission.dat")); - if(!ifs.good()){ - std::cerr << "ERROR: Couldn't open file: \"$NPTOOL/NPSimulation/Detectors/LightPipe/p-terphenyl_emission.dat\"\n"; - exit(1); - } - double wl, pr; - while(ifs >> wl >> pr) { - energy.emplace_back( h_Planck*c_light / (wl*nm) ); // convert to energy - scint.emplace_back(pr); // scintillation probability - rindx.emplace_back(1.65); // refractive index - fast.emplace_back(3*ns); // FAST component ??? - slow.emplace_back(100*ns); // SLOW component ??? - atten.emplace_back(4.73*mm); // Attenuation length (from https://arxiv.org/pdf/1305.0442.pdf) - } - } - - // Set Material Properties - G4int numPoints = energy.size(); - G4MaterialPropertiesTable* MPT = new G4MaterialPropertiesTable(); - MPT->AddConstProperty("SCINTILLATIONYIELD", 27000/MeV); // from proteus - MPT->AddProperty("SCINTILLATION", &energy[0], &scint[0], numPoints); - MPT->AddProperty("RINDEX", &energy[0], &rindx[0], numPoints) ; - MPT->AddProperty("ABSLENGTH", &energy[0], &atten[0], numPoints); - MPT->AddProperty("FASTCOMPONENT", &energy[0], &fast[0], numPoints); - MPT->AddProperty("SLOWCOMPONENT", &energy[0], &slow[0], numPoints); - MPT->AddConstProperty("RESOLUTIONSCALE", 1.0); - MPT->AddConstProperty("FASTTIMECONSTANT", 20*ns); // ????? - MPT->AddConstProperty("SLOWTIMECONSTANT", 100*ns); // ????? - MPT->AddConstProperty("YIELDRATIO",1.0); // ????? - material->SetMaterialPropertiesTable(MPT); - return material; + // p-Terphenyl + // Taken from Proteus, Inc. specs + // See here: http://people.physics.tamu.edu/christian/files/p-terphenyl.png + // + G4double specificGravity = 1.23; // from proteus + G4double densityReference = 0.999972 * g / cm3; // water @4-deg C [ the standard ] + G4double density = specificGravity * densityReference; + + G4Material* material = new G4Material("p_Terphenyl_Scint", density, 2); + material->AddElement(MaterialManager::getInstance()->GetElementFromLibrary("H"), 10); + material->AddElement(MaterialManager::getInstance()->GetElementFromLibrary("C"), 14); + + // Adding Scintillation property: + vector<double> energy, scint, fast, slow, rindx, atten; + { + // Read emission spectrum from datfile (+ add constant parameters) + ifstream ifs(gSystem->ExpandPathName("$NPTOOL/NPSimulation/Detectors/LightPipe/p-terphenyl_emission.dat")); + if (!ifs.good()) { + std::cerr << "ERROR: Couldn't open file: \"$NPTOOL/NPSimulation/Detectors/LightPipe/p-terphenyl_emission.dat\"\n"; + exit(1); + } + double wl, pr; + while (ifs >> wl >> pr) { + energy.emplace_back(h_Planck * c_light / (wl * nm)); // convert to energy + scint.emplace_back(pr); // scintillation probability + rindx.emplace_back(1.65); // refractive index + fast.emplace_back(3 * ns); // FAST component ??? + slow.emplace_back(100 * ns); // SLOW component ??? + atten.emplace_back(4.73 * mm); // Attenuation length (from https://arxiv.org/pdf/1305.0442.pdf) + } + } + + // Set Material Properties + G4int numPoints = energy.size(); + G4MaterialPropertiesTable* MPT = new G4MaterialPropertiesTable(); + MPT->AddConstProperty("SCINTILLATIONYIELD", 27000 / MeV); // from proteus + MPT->AddProperty("SCINTILLATION", &energy[0], &scint[0], numPoints); + MPT->AddProperty("RINDEX", &energy[0], &rindx[0], numPoints); + MPT->AddProperty("ABSLENGTH", &energy[0], &atten[0], numPoints); + MPT->AddProperty("FASTCOMPONENT", &energy[0], &fast[0], numPoints); + MPT->AddProperty("SLOWCOMPONENT", &energy[0], &slow[0], numPoints); + MPT->AddConstProperty("RESOLUTIONSCALE", 1.0); + MPT->AddConstProperty("FASTTIMECONSTANT", 20 * ns); // ????? + MPT->AddConstProperty("SLOWTIMECONSTANT", 100 * ns); // ????? + MPT->AddConstProperty("YIELDRATIO", 1.0); // ????? + material->SetMaterialPropertiesTable(MPT); + return material; } G4Material* LightPipe::CreatePipeMaterial() const { - // Bicron BC-482A - // https://www.crystals.saint-gobain.com/sites/imdf.crystals.com/files/documents/bc482a-bc484-data-sheet.pdf - // https://www.crystals.saint-gobain.com/sites/imdf.crystals.com/files/documents/organics-plastic-scintillators.pdf - // - G4double density = 1.03*g/cm3; - - G4Material* material = new G4Material("BC482A_WLS", density, 2); - material->AddElement(MaterialManager::getInstance()->GetElementFromLibrary("H"), 10); // H:C ratio - 1.110 - material->AddElement(MaterialManager::getInstance()->GetElementFromLibrary("C"), 9); - - // Adding WLS property - auto readDatfile = [](const char* fname, vector<double>& energy, vector<double>& abs, vector<double>& emit){ - ifstream ifs(gSystem->ExpandPathName(fname)); - if(!ifs.good()) { - std::cerr << "ERROR: no file: \"" << fname << "\"\n"; - exit(1); - } - // skip header - std::string dummy; - std::getline(ifs, dummy); - - double wl, pr_a, pr_e; - while(ifs >> wl >> pr_a >> pr_e) { - energy.emplace_back( h_Planck*c_light / (wl*nm) ); // convert to energy - abs.emplace_back(pr_a); // absorption probability - emit.emplace_back(pr_e); // emission probability - } - // SORT IN ORDER OF INCREASING ENERGY - vector<int> isort(energy.size()); - vector<double> e0 = energy, pa0 = abs, pe0 = emit; - TMath::Sort((int)energy.size(), &energy[0], &isort[0]); - for(size_t i=0; i< energy.size(); ++i){ - energy.at(i) = e0.at(isort.at(i)); - abs.at(i) = pa0.at(isort.at(i)); - emit.at(i) = pe0.at(isort.at(i)); - } - }; - // Absorption & Emission - vector<double> energy, p_abs, p_emit; - readDatfile("$NPTOOL/NPSimulation/Detectors/LightPipe/BC482A_properties.dat", energy, p_abs, p_emit); - // - // Absorption is given as a probability, but GEANT4 needs a length - // Invert and set the minimum to 0.4336 mm, which is the (measured) - // attenuation length for EJ-280 @peak absorption. - // This is not exact, but it's close. - // For absorption of 0, set attenuation length very long (5 m) - for(auto&& p : p_abs) { - p = p > 0 ? (0.4336*mm) / p : 5*m; - } - - // - const size_t numPoints = energy.size(); - vector<double> rindx(numPoints, 1.59); - vector<double> abslength(numPoints, 400*cm); // BULK attenuation length - - // Set Material Properties - G4MaterialPropertiesTable* MPT = new G4MaterialPropertiesTable(); - MPT->AddProperty("RINDEX", &energy[0], &rindx[0], numPoints); - MPT->AddProperty("ABSLENGTH", &energy[0], &abslength[0], numPoints); - MPT->AddProperty("WLSABSLENGTH", &energy[0], &p_abs[0], numPoints); - MPT->AddProperty("WLSCOMPONENT", &energy[0], &p_emit[0], numPoints); - MPT->AddConstProperty("WLSTIMECONSTANT", 12.*ns); - MPT->AddConstProperty("WLSMEANNUMBEROFPHOTONS", 0.86); - - material->SetMaterialPropertiesTable(MPT); - return material; + // Bicron BC-482A + // https://www.crystals.saint-gobain.com/sites/imdf.crystals.com/files/documents/bc482a-bc484-data-sheet.pdf + // https://www.crystals.saint-gobain.com/sites/imdf.crystals.com/files/documents/organics-plastic-scintillators.pdf + // + G4double density = 1.03 * g / cm3; + + G4Material* material = new G4Material("BC482A_WLS", density, 2); + material->AddElement(MaterialManager::getInstance()->GetElementFromLibrary("H"), 10); // H:C ratio - 1.110 + material->AddElement(MaterialManager::getInstance()->GetElementFromLibrary("C"), 9); + + // Adding WLS property + auto readDatfile = [](const char* fname, vector<double>& energy, vector<double>& abs, vector<double>& emit) { + ifstream ifs(gSystem->ExpandPathName(fname)); + if (!ifs.good()) { + std::cerr << "ERROR: no file: \"" << fname << "\"\n"; + exit(1); + } + // skip header + std::string dummy; + std::getline(ifs, dummy); + + double wl, pr_a, pr_e; + while (ifs >> wl >> pr_a >> pr_e) { + energy.emplace_back(h_Planck * c_light / (wl * nm)); // convert to energy + abs.emplace_back(pr_a); // absorption probability + emit.emplace_back(pr_e); // emission probability + } + // SORT IN ORDER OF INCREASING ENERGY + vector<int> isort(energy.size()); + vector<double> e0 = energy, pa0 = abs, pe0 = emit; + TMath::Sort((int)energy.size(), &energy[0], &isort[0]); + for (size_t i = 0; i < energy.size(); ++i) { + energy.at(i) = e0.at(isort.at(i)); + abs.at(i) = pa0.at(isort.at(i)); + emit.at(i) = pe0.at(isort.at(i)); + } + }; + // Absorption & Emission + vector<double> energy, p_abs, p_emit; + readDatfile("$NPTOOL/NPSimulation/Detectors/LightPipe/BC482A_properties.dat", energy, p_abs, p_emit); + // + // Absorption is given as a probability, but GEANT4 needs a length + // Invert and set the minimum to 0.4336 mm, which is the (measured) + // attenuation length for EJ-280 @peak absorption. + // This is not exact, but it's close. + // For absorption of 0, set attenuation length very long (5 m) + for (auto&& p : p_abs) { + p = p > 0 ? (0.4336 * mm) / p : 5 * m; + } + + // + const size_t numPoints = energy.size(); + vector<double> rindx(numPoints, 1.59); + vector<double> abslength(numPoints, 400 * cm); // BULK attenuation length + + // Set Material Properties + G4MaterialPropertiesTable* MPT = new G4MaterialPropertiesTable(); + MPT->AddProperty("RINDEX", &energy[0], &rindx[0], numPoints); + MPT->AddProperty("ABSLENGTH", &energy[0], &abslength[0], numPoints); + MPT->AddProperty("WLSABSLENGTH", &energy[0], &p_abs[0], numPoints); + MPT->AddProperty("WLSCOMPONENT", &energy[0], &p_emit[0], numPoints); + MPT->AddConstProperty("WLSTIMECONSTANT", 12. * ns); + MPT->AddConstProperty("WLSMEANNUMBEROFPHOTONS", 0.86); + + material->SetMaterialPropertiesTable(MPT); + return material; } G4Material* LightPipe::CreateWrappingMaterial() const { - // Teflon (C2F4) -- for now - // - G4double density = 2.2*g/cm3; - - G4Material* material = new G4Material("TEFLON", density, 2); - material->AddElement(MaterialManager::getInstance()->GetElementFromLibrary("F"), 4); // H:C ratio - 1.110 - material->AddElement(MaterialManager::getInstance()->GetElementFromLibrary("C"), 2); - return material; + // Teflon (C2F4) -- for now + // + G4double density = 2.2 * g / cm3; + + G4Material* material = new G4Material("TEFLON", density, 2); + material->AddElement(MaterialManager::getInstance()->GetElementFromLibrary("F"), 4); // H:C ratio - 1.110 + material->AddElement(MaterialManager::getInstance()->GetElementFromLibrary("C"), 2); + return material; } G4OpticalSurface* LightPipe::CreateReflectiveSurface() const { - G4OpticalSurface* OpticalCrystalSurface = new G4OpticalSurface("CrystalSurface"); - OpticalCrystalSurface->SetType(dielectric_metal); - //polished: smooth perfectly polished surcface - //ground: rough surface - OpticalCrystalSurface->SetFinish(polished); - //unified - //glisur - OpticalCrystalSurface->SetModel(glisur); - - G4double pp[] = {0.01*eV, 10*eV}; - const G4int num = sizeof(pp)/sizeof(G4double); - G4double reflectivity[] = {1., 1.}; - G4double efficiency[] = {1., 1.}; - - G4MaterialPropertiesTable* OpticalCrystalSurfaceProperty = new G4MaterialPropertiesTable(); - - OpticalCrystalSurfaceProperty->AddProperty("REFLECTIVITY",pp,reflectivity,num); - OpticalCrystalSurfaceProperty->AddProperty("EFFICIENCY",pp,efficiency,num); - OpticalCrystalSurface->SetMaterialPropertiesTable(OpticalCrystalSurfaceProperty); - return OpticalCrystalSurface; + G4OpticalSurface* OpticalCrystalSurface = new G4OpticalSurface("CrystalSurface"); + OpticalCrystalSurface->SetType(dielectric_metal); + // polished: smooth perfectly polished surcface + // ground: rough surface + OpticalCrystalSurface->SetFinish(polished); + // unified + // glisur + OpticalCrystalSurface->SetModel(glisur); + + G4double pp[] = {0.01 * eV, 10 * eV}; + const G4int num = sizeof(pp) / sizeof(G4double); + G4double reflectivity[] = {1., 1.}; + G4double efficiency[] = {1., 1.}; + + G4MaterialPropertiesTable* OpticalCrystalSurfaceProperty = new G4MaterialPropertiesTable(); + + OpticalCrystalSurfaceProperty->AddProperty("REFLECTIVITY", pp, reflectivity, num); + OpticalCrystalSurfaceProperty->AddProperty("EFFICIENCY", pp, efficiency, num); + OpticalCrystalSurface->SetMaterialPropertiesTable(OpticalCrystalSurfaceProperty); + return OpticalCrystalSurface; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... @@ -631,21 +622,19 @@ G4OpticalSurface* LightPipe::CreateReflectiveSurface() const { //////////////////////////////////////////////////////////////////////////////// // Construct Method to be pass to the DetectorFactory // //////////////////////////////////////////////////////////////////////////////// -NPS::VDetector* LightPipe::Construct(){ - return (NPS::VDetector*) new LightPipe(); -} +NPS::VDetector* LightPipe::Construct() { return (NPS::VDetector*)new LightPipe(); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //////////////////////////////////////////////////////////////////////////////// // Registering the construct method to the factory // //////////////////////////////////////////////////////////////////////////////// -extern"C" { -class proxy_nps_LightPipe{ -public: - proxy_nps_LightPipe(){ - NPS::DetectorFactory::getInstance()->AddToken("LightPipe","LightPipe"); - NPS::DetectorFactory::getInstance()->AddDetector("LightPipe",LightPipe::Construct); - } +extern "C" { +class proxy_nps_LightPipe { + public: + proxy_nps_LightPipe() { + NPS::DetectorFactory::getInstance()->AddToken("LightPipe", "LightPipe"); + NPS::DetectorFactory::getInstance()->AddDetector("LightPipe", LightPipe::Construct); + } }; proxy_nps_LightPipe p_nps_LightPipe; diff --git a/NPSimulation/Detectors/MUST2/MUST2Array.cc b/NPSimulation/Detectors/MUST2/MUST2Array.cc index 1545d2bdce5bf84f798016164862679157e26a07..439dc81ad47b517e407583a30113dd47cc2a678c 100644 --- a/NPSimulation/Detectors/MUST2/MUST2Array.cc +++ b/NPSimulation/Detectors/MUST2/MUST2Array.cc @@ -69,18 +69,15 @@ MUST2Array::MUST2Array() { m_Event = new TMust2Data(); InitializeMaterial(); m_StripScorer = 0; - m_SiLiScorer = 0; - m_CsIScorer = 0; + m_SiLiScorer = 0; + m_CsIScorer = 0; } MUST2Array::~MUST2Array() {} - - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void MUST2Array::AddTelescope(G4ThreeVector X1_Y1, G4ThreeVector X128_Y1, - G4ThreeVector X1_Y128, G4ThreeVector X128_Y128, - bool wSi, bool wSiLi, bool wCsI) { +void MUST2Array::AddTelescope(G4ThreeVector X1_Y1, G4ThreeVector X128_Y1, G4ThreeVector X1_Y128, + G4ThreeVector X128_Y128, bool wSi, bool wSiLi, bool wCsI) { m_DefinitionType.push_back(true); m_X1_Y1.push_back(X1_Y1); @@ -99,9 +96,8 @@ void MUST2Array::AddTelescope(G4ThreeVector X1_Y1, G4ThreeVector X128_Y1, m_beta_w.push_back(0); } -void MUST2Array::AddTelescope(G4double R, G4double Theta, G4double Phi, - G4double beta_u, G4double beta_v, G4double beta_w, - bool wSi, bool wSiLi, bool wCsI) { +void MUST2Array::AddTelescope(G4double R, G4double Theta, G4double Phi, G4double beta_u, G4double beta_v, + G4double beta_w, bool wSi, bool wSiLi, bool wCsI) { G4ThreeVector empty = G4ThreeVector(0, 0, 0); m_DefinitionType.push_back(false); @@ -123,11 +119,10 @@ void MUST2Array::AddTelescope(G4double R, G4double Theta, G4double Phi, } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void MUST2Array::VolumeMaker(G4int TelescopeNumber, G4ThreeVector MMpos, - G4RotationMatrix* MMrot, bool wSi, bool wSiLi, - bool wCsI, G4LogicalVolume* world) { - G4double NbrTelescopes = TelescopeNumber; - G4String DetectorNumber; +void MUST2Array::VolumeMaker(G4int TelescopeNumber, G4ThreeVector MMpos, G4RotationMatrix* MMrot, bool wSi, bool wSiLi, + bool wCsI, G4LogicalVolume* world) { + G4double NbrTelescopes = TelescopeNumber; + G4String DetectorNumber; std::ostringstream Number; Number << NbrTelescopes; DetectorNumber = Number.str(); @@ -135,36 +130,30 @@ void MUST2Array::VolumeMaker(G4int TelescopeNumber, G4ThreeVector MMpos, //////////////////////////////////////////////////////////////// ////////////// Starting Volume Definition ////////////////////// //////////////////////////////////////////////////////////////// - G4Trd* solidMM = new G4Trd("MUST2Telescope" + DetectorNumber, 0.5 * FaceFront, - 0.5 * FaceBack, 0.5 * FaceFront, 0.5 * FaceBack, - 0.5 * Length); - G4LogicalVolume* logicMM = new G4LogicalVolume( - solidMM, m_MaterialIron, "MUST2Telescope" + DetectorNumber, 0, 0, 0); + G4Trd* solidMM = new G4Trd("MUST2Telescope" + DetectorNumber, 0.5 * FaceFront, 0.5 * FaceBack, 0.5 * FaceFront, + 0.5 * FaceBack, 0.5 * Length); + G4LogicalVolume* logicMM = new G4LogicalVolume(solidMM, m_MaterialIron, "MUST2Telescope" + DetectorNumber, 0, 0, 0); G4String Name = "MUST2Telescope" + DetectorNumber; - new G4PVPlacement(G4Transform3D(*MMrot, MMpos), logicMM, Name, world, false, - TelescopeNumber); + new G4PVPlacement(G4Transform3D(*MMrot, MMpos), logicMM, Name, world, false, TelescopeNumber); if (m_non_sensitive_part_visiualisation) { - G4VisAttributes* FrameVisAtt - = new G4VisAttributes(G4Colour(0.80, 0.80, 0.80)); + G4VisAttributes* FrameVisAtt = new G4VisAttributes(G4Colour(0.80, 0.80, 0.80)); FrameVisAtt->SetForceWireframe(true); logicMM->SetVisAttributes(FrameVisAtt); - } else - logicMM->SetVisAttributes(G4VisAttributes::Invisible); + } + else + logicMM->SetVisAttributes(G4VisAttributes::GetInvisible()); G4ThreeVector positionVacBox = G4ThreeVector(0, 0, VacBox_PosZ); - G4Trd* solidVacBox - = new G4Trd("solidVacBox", 0.5 * SiliconFace, 0.5 * CsIFaceFront, - 0.5 * SiliconFace, 0.5 * CsIFaceFront, 0.5 * VacBoxThickness); - G4LogicalVolume* logicVacBox = new G4LogicalVolume( - solidVacBox, m_MaterialVacuum, "logicVacBox", 0, 0, 0); + G4Trd* solidVacBox = new G4Trd("solidVacBox", 0.5 * SiliconFace, 0.5 * CsIFaceFront, 0.5 * SiliconFace, + 0.5 * CsIFaceFront, 0.5 * VacBoxThickness); + G4LogicalVolume* logicVacBox = new G4LogicalVolume(solidVacBox, m_MaterialVacuum, "logicVacBox", 0, 0, 0); - new G4PVPlacement(0, positionVacBox, logicVacBox, Name + "_VacBox", logicMM, - false, TelescopeNumber); + new G4PVPlacement(0, positionVacBox, logicVacBox, Name + "_VacBox", logicMM, false, TelescopeNumber); - logicVacBox->SetVisAttributes(G4VisAttributes::Invisible); + logicVacBox->SetVisAttributes(G4VisAttributes::GetInvisible()); G4VisAttributes* SiliconVisAtt = new G4VisAttributes(G4Colour(0.3, 0.3, 0.3)); @@ -173,32 +162,24 @@ void MUST2Array::VolumeMaker(G4int TelescopeNumber, G4ThreeVector MMpos, //////////////////////////////////////////////////////////////// if (wSi) { - G4ThreeVector positionAluStripFront - = G4ThreeVector(0, 0, AluStripFront_PosZ); + G4ThreeVector positionAluStripFront = G4ThreeVector(0, 0, AluStripFront_PosZ); G4ThreeVector positionAluStripBack = G4ThreeVector(0, 0, AluStripBack_PosZ); - G4Box* solidAluStrip - = new G4Box("AluBox", 0.5 * SiliconFace, 0.5 * SiliconFace, - 0.5 * AluStripThickness); - G4LogicalVolume* logicAluStrip = new G4LogicalVolume( - solidAluStrip, m_MaterialAluminium, "logicAluStrip", 0, 0, 0); + G4Box* solidAluStrip = new G4Box("AluBox", 0.5 * SiliconFace, 0.5 * SiliconFace, 0.5 * AluStripThickness); + G4LogicalVolume* logicAluStrip = new G4LogicalVolume(solidAluStrip, m_MaterialAluminium, "logicAluStrip", 0, 0, 0); - new G4PVPlacement(0, positionAluStripFront, logicAluStrip, - Name + "_AluStripFront", logicMM, false, TelescopeNumber); - new G4PVPlacement(0, positionAluStripBack, logicAluStrip, - Name + "_AluStripBack", logicMM, false, TelescopeNumber); + new G4PVPlacement(0, positionAluStripFront, logicAluStrip, Name + "_AluStripFront", logicMM, false, + TelescopeNumber); + new G4PVPlacement(0, positionAluStripBack, logicAluStrip, Name + "_AluStripBack", logicMM, false, TelescopeNumber); - logicAluStrip->SetVisAttributes(G4VisAttributes::Invisible); + logicAluStrip->SetVisAttributes(G4VisAttributes::GetInvisible()); G4ThreeVector positionSilicon = G4ThreeVector(0, 0, Silicon_PosZ); - G4Box* solidSilicon = new G4Box("solidSilicon", 0.5 * SiliconFace, - 0.5 * SiliconFace, 0.5 * SiliconThickness); - G4LogicalVolume* logicSilicon = new G4LogicalVolume( - solidSilicon, m_MaterialSilicon, "logicSilicon", 0, 0, 0); + G4Box* solidSilicon = new G4Box("solidSilicon", 0.5 * SiliconFace, 0.5 * SiliconFace, 0.5 * SiliconThickness); + G4LogicalVolume* logicSilicon = new G4LogicalVolume(solidSilicon, m_MaterialSilicon, "logicSilicon", 0, 0, 0); - new G4PVPlacement(0, positionSilicon, logicSilicon, Name + "_Silicon", - logicMM, false, TelescopeNumber); + new G4PVPlacement(0, positionSilicon, logicSilicon, Name + "_Silicon", logicMM, false, TelescopeNumber); /// Set Silicon strip sensible logicSilicon->SetSensitiveDetector(m_StripScorer); @@ -212,207 +193,148 @@ void MUST2Array::VolumeMaker(G4int TelescopeNumber, G4ThreeVector MMpos, //////////////////////////////////////////////////////////////// if (wSiLi) { - G4double SiLiSpace = 8 * mm; - G4RotationMatrix* rotSiLi = new G4RotationMatrix(0, 0, 0); - G4Box* solidSiLi = new G4Box("SiLi", 0.5 * SiliconFace + 0.5 * SiLiSpace, - 0.5 * SiliconFace, 0.5 * SiLiThickness); - G4LogicalVolume* logicSiLi = new G4LogicalVolume( - solidSiLi, m_MaterialAluminium, Name + "_SiLi", 0, 0, 0); + G4double SiLiSpace = 8 * mm; + G4RotationMatrix* rotSiLi = new G4RotationMatrix(0, 0, 0); + G4Box* solidSiLi = new G4Box("SiLi", 0.5 * SiliconFace + 0.5 * SiLiSpace, 0.5 * SiliconFace, 0.5 * SiLiThickness); + G4LogicalVolume* logicSiLi = new G4LogicalVolume(solidSiLi, m_MaterialAluminium, Name + "_SiLi", 0, 0, 0); - logicSiLi->SetVisAttributes(G4VisAttributes::Invisible); + logicSiLi->SetVisAttributes(G4VisAttributes::GetInvisible()); - new G4PVPlacement(G4Transform3D(*rotSiLi, G4ThreeVector(0, 0, 0)), - logicSiLi, Name + "_SiLi", logicVacBox, false, 0); + new G4PVPlacement(G4Transform3D(*rotSiLi, G4ThreeVector(0, 0, 0)), logicSiLi, Name + "_SiLi", logicVacBox, false, + 0); // SiLi are placed inside of the VacBox... // Left/Right define when looking to detector from Si to CsI - G4double SiLi_HighY_Upper = 19.86 * mm; + G4double SiLi_HighY_Upper = 19.86 * mm; G4double SiLi_HighY_Center = 25.39 * mm; - G4double SiLi_WidthX_Left = 22.85 * mm; + G4double SiLi_WidthX_Left = 22.85 * mm; G4double SiLi_WidthX_Right = 24.9 * mm; - G4double SiLi_ShiftX = 0.775 * mm; + G4double SiLi_ShiftX = 0.775 * mm; // SiLi are organized by two group of 8 Up(9 to 15) and Down(1 to 8). - G4ThreeVector ShiftSiLiUp - = G4ThreeVector(-0.25 * SiliconFace - 0.5 * SiLiSpace, 0, 0); - G4ThreeVector ShiftSiLiDown - = G4ThreeVector(0.25 * SiliconFace + 0.5 * SiLiSpace, 0, 0); + G4ThreeVector ShiftSiLiUp = G4ThreeVector(-0.25 * SiliconFace - 0.5 * SiLiSpace, 0, 0); + G4ThreeVector ShiftSiLiDown = G4ThreeVector(0.25 * SiliconFace + 0.5 * SiLiSpace, 0, 0); // SiLi : left side of SiLi detector - G4Box* solidSiLi_LT - = new G4Box("SiLi_LT", 0.5 * SiLi_WidthX_Left, 0.5 * SiLi_HighY_Upper, - 0.5 * SiLiThickness); - G4Box* solidSiLi_RT - = new G4Box("SiLi_RT", 0.5 * SiLi_WidthX_Right, 0.5 * SiLi_HighY_Upper, - 0.5 * SiLiThickness); - G4Box* solidSiLi_LC1 - = new G4Box("SiLi_LC1", 0.5 * SiLi_WidthX_Left, 0.5 * SiLi_HighY_Center, - 0.5 * SiLiThickness); - G4Box* solidSiLi_RC1 - = new G4Box("SiLi_RC1", 0.5 * SiLi_WidthX_Right, - 0.5 * SiLi_HighY_Center, 0.5 * SiLiThickness); - G4Box* solidSiLi_LB - = new G4Box("SiLi_LB", 0.5 * SiLi_WidthX_Left, 0.5 * SiLi_HighY_Upper, - 0.5 * SiLiThickness); - G4Box* solidSiLi_RB - = new G4Box("SiLi_RB", 0.5 * SiLi_WidthX_Right, 0.5 * SiLi_HighY_Upper, - 0.5 * SiLiThickness); - G4Box* solidSiLi_LC2 - = new G4Box("SiLi_LC2", 0.5 * SiLi_WidthX_Left, 0.5 * SiLi_HighY_Center, - 0.5 * SiLiThickness); - G4Box* solidSiLi_RC2 - = new G4Box("SiLi_RC2", 0.5 * SiLi_WidthX_Right, - 0.5 * SiLi_HighY_Center, 0.5 * SiLiThickness); - - G4LogicalVolume* logicSiLi_LT = new G4LogicalVolume( - solidSiLi_LT, m_MaterialSilicon, "SiLi_LT", 0, 0, 0); - G4LogicalVolume* logicSiLi_RT = new G4LogicalVolume( - solidSiLi_RT, m_MaterialSilicon, "SiLi_RT", 0, 0, 0); - G4LogicalVolume* logicSiLi_LC1 = new G4LogicalVolume( - solidSiLi_LC1, m_MaterialSilicon, "SiLi_LC1", 0, 0, 0); - G4LogicalVolume* logicSiLi_RC1 = new G4LogicalVolume( - solidSiLi_RC1, m_MaterialSilicon, "SiLi_RC1", 0, 0, 0); - G4LogicalVolume* logicSiLi_LB = new G4LogicalVolume( - solidSiLi_LB, m_MaterialSilicon, "SiLi_LB", 0, 0, 0); - G4LogicalVolume* logicSiLi_RB = new G4LogicalVolume( - solidSiLi_RB, m_MaterialSilicon, "SiLi_RB", 0, 0, 0); - G4LogicalVolume* logicSiLi_LC2 = new G4LogicalVolume( - solidSiLi_LC2, m_MaterialSilicon, "SiLi_LC2", 0, 0, 0); - G4LogicalVolume* logicSiLi_RC2 = new G4LogicalVolume( - solidSiLi_RC2, m_MaterialSilicon, "SiLi_RC2", 0, 0, 0); + G4Box* solidSiLi_LT = new G4Box("SiLi_LT", 0.5 * SiLi_WidthX_Left, 0.5 * SiLi_HighY_Upper, 0.5 * SiLiThickness); + G4Box* solidSiLi_RT = new G4Box("SiLi_RT", 0.5 * SiLi_WidthX_Right, 0.5 * SiLi_HighY_Upper, 0.5 * SiLiThickness); + G4Box* solidSiLi_LC1 = new G4Box("SiLi_LC1", 0.5 * SiLi_WidthX_Left, 0.5 * SiLi_HighY_Center, 0.5 * SiLiThickness); + G4Box* solidSiLi_RC1 = new G4Box("SiLi_RC1", 0.5 * SiLi_WidthX_Right, 0.5 * SiLi_HighY_Center, 0.5 * SiLiThickness); + G4Box* solidSiLi_LB = new G4Box("SiLi_LB", 0.5 * SiLi_WidthX_Left, 0.5 * SiLi_HighY_Upper, 0.5 * SiLiThickness); + G4Box* solidSiLi_RB = new G4Box("SiLi_RB", 0.5 * SiLi_WidthX_Right, 0.5 * SiLi_HighY_Upper, 0.5 * SiLiThickness); + G4Box* solidSiLi_LC2 = new G4Box("SiLi_LC2", 0.5 * SiLi_WidthX_Left, 0.5 * SiLi_HighY_Center, 0.5 * SiLiThickness); + G4Box* solidSiLi_RC2 = new G4Box("SiLi_RC2", 0.5 * SiLi_WidthX_Right, 0.5 * SiLi_HighY_Center, 0.5 * SiLiThickness); + + G4LogicalVolume* logicSiLi_LT = new G4LogicalVolume(solidSiLi_LT, m_MaterialSilicon, "SiLi_LT", 0, 0, 0); + G4LogicalVolume* logicSiLi_RT = new G4LogicalVolume(solidSiLi_RT, m_MaterialSilicon, "SiLi_RT", 0, 0, 0); + G4LogicalVolume* logicSiLi_LC1 = new G4LogicalVolume(solidSiLi_LC1, m_MaterialSilicon, "SiLi_LC1", 0, 0, 0); + G4LogicalVolume* logicSiLi_RC1 = new G4LogicalVolume(solidSiLi_RC1, m_MaterialSilicon, "SiLi_RC1", 0, 0, 0); + G4LogicalVolume* logicSiLi_LB = new G4LogicalVolume(solidSiLi_LB, m_MaterialSilicon, "SiLi_LB", 0, 0, 0); + G4LogicalVolume* logicSiLi_RB = new G4LogicalVolume(solidSiLi_RB, m_MaterialSilicon, "SiLi_RB", 0, 0, 0); + G4LogicalVolume* logicSiLi_LC2 = new G4LogicalVolume(solidSiLi_LC2, m_MaterialSilicon, "SiLi_LC2", 0, 0, 0); + G4LogicalVolume* logicSiLi_RC2 = new G4LogicalVolume(solidSiLi_RC2, m_MaterialSilicon, "SiLi_RC2", 0, 0, 0); G4double interSiLi = 0.5 * mm; // Top - G4ThreeVector positionSiLi_LT_up = G4ThreeVector( - -0.5 * SiLi_WidthX_Left - interSiLi - SiLi_ShiftX, - 0.5 * SiLi_HighY_Upper + SiLi_HighY_Center + 1.5 * interSiLi, 0); + G4ThreeVector positionSiLi_LT_up = G4ThreeVector(-0.5 * SiLi_WidthX_Left - interSiLi - SiLi_ShiftX, + 0.5 * SiLi_HighY_Upper + SiLi_HighY_Center + 1.5 * interSiLi, 0); positionSiLi_LT_up += ShiftSiLiUp; - G4ThreeVector positionSiLi_RT_up = G4ThreeVector( - 0.5 * SiLi_WidthX_Right - SiLi_ShiftX, - 0.5 * SiLi_HighY_Upper + SiLi_HighY_Center + 1.5 * interSiLi, 0); + G4ThreeVector positionSiLi_RT_up = G4ThreeVector(0.5 * SiLi_WidthX_Right - SiLi_ShiftX, + 0.5 * SiLi_HighY_Upper + SiLi_HighY_Center + 1.5 * interSiLi, 0); positionSiLi_RT_up += ShiftSiLiUp; - G4ThreeVector positionSiLi_LC1_up - = G4ThreeVector(-0.5 * SiLi_WidthX_Left - interSiLi - SiLi_ShiftX, - 0.5 * SiLi_HighY_Center + 0.5 * interSiLi, 0); + G4ThreeVector positionSiLi_LC1_up = + G4ThreeVector(-0.5 * SiLi_WidthX_Left - interSiLi - SiLi_ShiftX, 0.5 * SiLi_HighY_Center + 0.5 * interSiLi, 0); positionSiLi_LC1_up += ShiftSiLiUp; - G4ThreeVector positionSiLi_RC1_up - = G4ThreeVector(0.5 * SiLi_WidthX_Right - SiLi_ShiftX, - 0.5 * SiLi_HighY_Center + 0.5 * interSiLi, 0); + G4ThreeVector positionSiLi_RC1_up = + G4ThreeVector(0.5 * SiLi_WidthX_Right - SiLi_ShiftX, 0.5 * SiLi_HighY_Center + 0.5 * interSiLi, 0); positionSiLi_RC1_up += ShiftSiLiUp; - G4ThreeVector positionSiLi_LB_up = G4ThreeVector( - -0.5 * SiLi_WidthX_Left - interSiLi - SiLi_ShiftX, - -0.5 * SiLi_HighY_Upper - SiLi_HighY_Center - 1.5 * interSiLi, 0); + G4ThreeVector positionSiLi_LB_up = G4ThreeVector(-0.5 * SiLi_WidthX_Left - interSiLi - SiLi_ShiftX, + -0.5 * SiLi_HighY_Upper - SiLi_HighY_Center - 1.5 * interSiLi, 0); positionSiLi_LB_up += ShiftSiLiUp; - G4ThreeVector positionSiLi_RB_up = G4ThreeVector( - 0.5 * SiLi_WidthX_Right - SiLi_ShiftX, - -0.5 * SiLi_HighY_Upper - SiLi_HighY_Center - 1.5 * interSiLi, 0); + G4ThreeVector positionSiLi_RB_up = G4ThreeVector(0.5 * SiLi_WidthX_Right - SiLi_ShiftX, + -0.5 * SiLi_HighY_Upper - SiLi_HighY_Center - 1.5 * interSiLi, 0); positionSiLi_RB_up += ShiftSiLiUp; - G4ThreeVector positionSiLi_LC2_up - = G4ThreeVector(-0.5 * SiLi_WidthX_Left - interSiLi - SiLi_ShiftX, - -0.5 * SiLi_HighY_Center - 0.5 * interSiLi, 0); + G4ThreeVector positionSiLi_LC2_up = + G4ThreeVector(-0.5 * SiLi_WidthX_Left - interSiLi - SiLi_ShiftX, -0.5 * SiLi_HighY_Center - 0.5 * interSiLi, 0); positionSiLi_LC2_up += ShiftSiLiUp; - G4ThreeVector positionSiLi_RC2_up - = G4ThreeVector(0.5 * SiLi_WidthX_Right - SiLi_ShiftX, - -0.5 * SiLi_HighY_Center - 0.5 * interSiLi, 0); + G4ThreeVector positionSiLi_RC2_up = + G4ThreeVector(0.5 * SiLi_WidthX_Right - SiLi_ShiftX, -0.5 * SiLi_HighY_Center - 0.5 * interSiLi, 0); positionSiLi_RC2_up += ShiftSiLiUp; // Down - G4ThreeVector positionSiLi_LT_down = G4ThreeVector( - -0.5 * SiLi_WidthX_Left - interSiLi - SiLi_ShiftX, - 0.5 * SiLi_HighY_Upper + SiLi_HighY_Center + 1.5 * interSiLi, 0); + G4ThreeVector positionSiLi_LT_down = G4ThreeVector(-0.5 * SiLi_WidthX_Left - interSiLi - SiLi_ShiftX, + 0.5 * SiLi_HighY_Upper + SiLi_HighY_Center + 1.5 * interSiLi, 0); positionSiLi_LT_down += ShiftSiLiDown; - G4ThreeVector positionSiLi_RT_down = G4ThreeVector( - 0.5 * SiLi_WidthX_Right - SiLi_ShiftX, - 0.5 * SiLi_HighY_Upper + SiLi_HighY_Center + 1.5 * interSiLi, 0); + G4ThreeVector positionSiLi_RT_down = G4ThreeVector(0.5 * SiLi_WidthX_Right - SiLi_ShiftX, + 0.5 * SiLi_HighY_Upper + SiLi_HighY_Center + 1.5 * interSiLi, 0); positionSiLi_RT_down += ShiftSiLiDown; - G4ThreeVector positionSiLi_LC1_down - = G4ThreeVector(-0.5 * SiLi_WidthX_Left - interSiLi - SiLi_ShiftX, - 0.5 * SiLi_HighY_Center + 0.5 * interSiLi, 0); + G4ThreeVector positionSiLi_LC1_down = + G4ThreeVector(-0.5 * SiLi_WidthX_Left - interSiLi - SiLi_ShiftX, 0.5 * SiLi_HighY_Center + 0.5 * interSiLi, 0); positionSiLi_LC1_down += ShiftSiLiDown; - G4ThreeVector positionSiLi_RC1_down - = G4ThreeVector(0.5 * SiLi_WidthX_Right - SiLi_ShiftX, - 0.5 * SiLi_HighY_Center + 0.5 * interSiLi, 0); + G4ThreeVector positionSiLi_RC1_down = + G4ThreeVector(0.5 * SiLi_WidthX_Right - SiLi_ShiftX, 0.5 * SiLi_HighY_Center + 0.5 * interSiLi, 0); positionSiLi_RC1_down += ShiftSiLiDown; - G4ThreeVector positionSiLi_LB_down = G4ThreeVector( - -0.5 * SiLi_WidthX_Left - interSiLi - SiLi_ShiftX, - -0.5 * SiLi_HighY_Upper - SiLi_HighY_Center - 1.5 * interSiLi, 0); + G4ThreeVector positionSiLi_LB_down = + G4ThreeVector(-0.5 * SiLi_WidthX_Left - interSiLi - SiLi_ShiftX, + -0.5 * SiLi_HighY_Upper - SiLi_HighY_Center - 1.5 * interSiLi, 0); positionSiLi_LB_down += ShiftSiLiDown; G4ThreeVector positionSiLi_RB_down = G4ThreeVector( - 0.5 * SiLi_WidthX_Right - SiLi_ShiftX, - -0.5 * SiLi_HighY_Upper - SiLi_HighY_Center - 1.5 * interSiLi, 0); + 0.5 * SiLi_WidthX_Right - SiLi_ShiftX, -0.5 * SiLi_HighY_Upper - SiLi_HighY_Center - 1.5 * interSiLi, 0); positionSiLi_RB_down += ShiftSiLiDown; - G4ThreeVector positionSiLi_LC2_down - = G4ThreeVector(-0.5 * SiLi_WidthX_Left - interSiLi - SiLi_ShiftX, - -0.5 * SiLi_HighY_Center - 0.5 * interSiLi, 0); + G4ThreeVector positionSiLi_LC2_down = + G4ThreeVector(-0.5 * SiLi_WidthX_Left - interSiLi - SiLi_ShiftX, -0.5 * SiLi_HighY_Center - 0.5 * interSiLi, 0); positionSiLi_LC2_down += ShiftSiLiDown; - G4ThreeVector positionSiLi_RC2_down - = G4ThreeVector(0.5 * SiLi_WidthX_Right - SiLi_ShiftX, - -0.5 * SiLi_HighY_Center - 0.5 * interSiLi, 0); + G4ThreeVector positionSiLi_RC2_down = + G4ThreeVector(0.5 * SiLi_WidthX_Right - SiLi_ShiftX, -0.5 * SiLi_HighY_Center - 0.5 * interSiLi, 0); positionSiLi_RC2_down += ShiftSiLiDown; - new G4PVPlacement(0, positionSiLi_RT_down, logicSiLi_RT, - Name + "_SiLi_Pad1", logicSiLi, false, 1); - new G4PVPlacement(0, positionSiLi_LT_down, logicSiLi_LT, - Name + "_SiLi_Pad2", logicSiLi, false, 2); - new G4PVPlacement(0, positionSiLi_RC1_down, logicSiLi_RC1, - Name + "_SiLi_Pad3", logicSiLi, false, 3); - new G4PVPlacement(0, positionSiLi_LC1_down, logicSiLi_LC1, - Name + "_SiLi_Pad4", logicSiLi, false, 4); - new G4PVPlacement(0, positionSiLi_LC2_down, logicSiLi_LC2, - Name + "_SiLi_Pad5", logicSiLi, false, 5); - new G4PVPlacement(0, positionSiLi_RC2_down, logicSiLi_RC2, - Name + "_SiLi_Pad6", logicSiLi, false, 6); - new G4PVPlacement(0, positionSiLi_LB_down, logicSiLi_LB, - Name + "_SiLi_Pad7", logicSiLi, false, 7); - new G4PVPlacement(0, positionSiLi_RB_down, logicSiLi_RB, - Name + "_SiLi_Pad8", logicSiLi, false, 8); - new G4PVPlacement(0, positionSiLi_LT_up, logicSiLi_LT, Name + "_SiLi_Pad9", - logicSiLi, false, 9); - new G4PVPlacement(0, positionSiLi_RT_up, logicSiLi_RT, Name + "_SiLi_Pad10", - logicSiLi, false, 10); - new G4PVPlacement(0, positionSiLi_LC1_up, logicSiLi_LC1, - Name + "_SiLi_Pad11", logicSiLi, false, 11); - new G4PVPlacement(0, positionSiLi_RC1_up, logicSiLi_RC1, - Name + "_SiLi_Pad12", logicSiLi, false, 12); - new G4PVPlacement(0, positionSiLi_RC2_up, logicSiLi_RC2, - Name + "_SiLi_Pad13", logicSiLi, false, 13); - new G4PVPlacement(0, positionSiLi_LC2_up, logicSiLi_LC2, - Name + "_SiLi_Pad14", logicSiLi, false, 14); - new G4PVPlacement(0, positionSiLi_RB_up, logicSiLi_RB, Name + "_SiLi_Pad15", - logicSiLi, false, 15); - new G4PVPlacement(0, positionSiLi_LB_up, logicSiLi_LB, Name + "_SiLi_Pad16", - logicSiLi, false, 16); + new G4PVPlacement(0, positionSiLi_RT_down, logicSiLi_RT, Name + "_SiLi_Pad1", logicSiLi, false, 1); + new G4PVPlacement(0, positionSiLi_LT_down, logicSiLi_LT, Name + "_SiLi_Pad2", logicSiLi, false, 2); + new G4PVPlacement(0, positionSiLi_RC1_down, logicSiLi_RC1, Name + "_SiLi_Pad3", logicSiLi, false, 3); + new G4PVPlacement(0, positionSiLi_LC1_down, logicSiLi_LC1, Name + "_SiLi_Pad4", logicSiLi, false, 4); + new G4PVPlacement(0, positionSiLi_LC2_down, logicSiLi_LC2, Name + "_SiLi_Pad5", logicSiLi, false, 5); + new G4PVPlacement(0, positionSiLi_RC2_down, logicSiLi_RC2, Name + "_SiLi_Pad6", logicSiLi, false, 6); + new G4PVPlacement(0, positionSiLi_LB_down, logicSiLi_LB, Name + "_SiLi_Pad7", logicSiLi, false, 7); + new G4PVPlacement(0, positionSiLi_RB_down, logicSiLi_RB, Name + "_SiLi_Pad8", logicSiLi, false, 8); + new G4PVPlacement(0, positionSiLi_LT_up, logicSiLi_LT, Name + "_SiLi_Pad9", logicSiLi, false, 9); + new G4PVPlacement(0, positionSiLi_RT_up, logicSiLi_RT, Name + "_SiLi_Pad10", logicSiLi, false, 10); + new G4PVPlacement(0, positionSiLi_LC1_up, logicSiLi_LC1, Name + "_SiLi_Pad11", logicSiLi, false, 11); + new G4PVPlacement(0, positionSiLi_RC1_up, logicSiLi_RC1, Name + "_SiLi_Pad12", logicSiLi, false, 12); + new G4PVPlacement(0, positionSiLi_RC2_up, logicSiLi_RC2, Name + "_SiLi_Pad13", logicSiLi, false, 13); + new G4PVPlacement(0, positionSiLi_LC2_up, logicSiLi_LC2, Name + "_SiLi_Pad14", logicSiLi, false, 14); + new G4PVPlacement(0, positionSiLi_RB_up, logicSiLi_RB, Name + "_SiLi_Pad15", logicSiLi, false, 15); + new G4PVPlacement(0, positionSiLi_LB_up, logicSiLi_LB, Name + "_SiLi_Pad16", logicSiLi, false, 16); // Set SiLi sensible logicSiLi_LT->SetSensitiveDetector(m_SiLiScorer); @@ -446,104 +368,82 @@ void MUST2Array::VolumeMaker(G4int TelescopeNumber, G4ThreeVector MMpos, //////////////////////////////////////////////////////////////// if (wCsI) { - m_MaterialMyl - = MaterialManager::getInstance()->GetMaterialFromLibrary("Mylar"); - m_MaterialCsI - = MaterialManager::getInstance()->GetMaterialFromLibrary("CsI"); + m_MaterialMyl = MaterialManager::getInstance()->GetMaterialFromLibrary("Mylar"); + m_MaterialCsI = MaterialManager::getInstance()->GetMaterialFromLibrary("CsI"); G4ThreeVector positionCsI = G4ThreeVector(0, 0, CsI_PosZ); - G4Trd* solidCsI - = new G4Trd("csI", 0.5 * CsIFaceFront, 0.5 * CsIFaceBack, - 0.5 * CsIFaceFront, 0.5 * CsIFaceBack, 0.5 * CsIThickness); + G4Trd* solidCsI = new G4Trd("csI", 0.5 * CsIFaceFront, 0.5 * CsIFaceBack, 0.5 * CsIFaceFront, 0.5 * CsIFaceBack, + 0.5 * CsIThickness); - G4LogicalVolume* logicCsI = new G4LogicalVolume( - solidCsI, m_MaterialAluminium, Name + "_CsI_Mylar", 0, 0, 0); - new G4PVPlacement(0, positionCsI, logicCsI, Name + "_CsI_Mylar", logicMM, - false, 0); + G4LogicalVolume* logicCsI = new G4LogicalVolume(solidCsI, m_MaterialAluminium, Name + "_CsI_Mylar", 0, 0, 0); + new G4PVPlacement(0, positionCsI, logicCsI, Name + "_CsI_Mylar", logicMM, false, 0); - G4ThreeVector positionMylarCsI - = G4ThreeVector(0, 0, MylarCsIThickness * 0.5 - CsIThickness * 0.5); + G4ThreeVector positionMylarCsI = G4ThreeVector(0, 0, MylarCsIThickness * 0.5 - CsIThickness * 0.5); - G4Box* solidMylarCsI - = new G4Box("MylarCsIBox", 0.5 * CsIFaceFront, 0.5 * CsIFaceFront, - 0.5 * MylarCsIThickness); - G4LogicalVolume* logicMylarCsI = new G4LogicalVolume( - solidMylarCsI, m_MaterialMyl, Name + "_CsI_Mylar", 0, 0, 0); + G4Box* solidMylarCsI = new G4Box("MylarCsIBox", 0.5 * CsIFaceFront, 0.5 * CsIFaceFront, 0.5 * MylarCsIThickness); + G4LogicalVolume* logicMylarCsI = new G4LogicalVolume(solidMylarCsI, m_MaterialMyl, Name + "_CsI_Mylar", 0, 0, 0); - new G4PVPlacement(0, positionMylarCsI, logicMylarCsI, Name + "_CsI_Mylar", - logicCsI, false, 0); + new G4PVPlacement(0, positionMylarCsI, logicMylarCsI, Name + "_CsI_Mylar", logicCsI, false, 0); - logicCsI->SetVisAttributes(G4VisAttributes::Invisible); - logicMylarCsI->SetVisAttributes(G4VisAttributes::Invisible); + logicCsI->SetVisAttributes(G4VisAttributes::GetInvisible()); + logicMylarCsI->SetVisAttributes(G4VisAttributes::GetInvisible()); // Cristal1 - G4Trap* solidCristal1 = new G4Trap( - "Cristal1", 40. * mm / 2., 6.693896 * deg, 41.97814 * deg, - 33.1 * mm / 2., 37.39 * mm / 2., 37.39 * mm / 2., 0. * deg, - 26.9 * mm / 2., 30.41 * mm / 2., 30.41 * mm / 2., 0. * deg); - G4LogicalVolume* logicCristal1 = new G4LogicalVolume( - solidCristal1, m_MaterialCsI, Name + "_CsI_Cristal1", 0, 0, 0); + G4Trap* solidCristal1 = + new G4Trap("Cristal1", 40. * mm / 2., 6.693896 * deg, 41.97814 * deg, 33.1 * mm / 2., 37.39 * mm / 2., + 37.39 * mm / 2., 0. * deg, 26.9 * mm / 2., 30.41 * mm / 2., 30.41 * mm / 2., 0. * deg); + G4LogicalVolume* logicCristal1 = new G4LogicalVolume(solidCristal1, m_MaterialCsI, Name + "_CsI_Cristal1", 0, 0, 0); // Cristal2 - G4Trap* solidCristal2 = new G4Trap( - "Cristal2", 40. * mm / 2., 17.8836 * deg, (74.3122 + 180) * deg, - 43.49 * mm / 2., 37.39 * mm / 2., 37.39 * mm / 2., 0. * deg, - 31.0377 * mm / 2., 30.41 * mm / 2., 30.41 * mm / 2., 0. * deg); - G4LogicalVolume* logicCristal2 = new G4LogicalVolume( - solidCristal2, m_MaterialCsI, Name + "_CsI_Cristal2", 0, 0, 0); + G4Trap* solidCristal2 = + new G4Trap("Cristal2", 40. * mm / 2., 17.8836 * deg, (74.3122 + 180) * deg, 43.49 * mm / 2., 37.39 * mm / 2., + 37.39 * mm / 2., 0. * deg, 31.0377 * mm / 2., 30.41 * mm / 2., 30.41 * mm / 2., 0. * deg); + G4LogicalVolume* logicCristal2 = new G4LogicalVolume(solidCristal2, m_MaterialCsI, Name + "_CsI_Cristal2", 0, 0, 0); // Cristal3 - G4Trap* solidCristal3 = new G4Trap( - "Cristal3", 40. * mm / 2., 18.243 * deg, 13.5988 * deg, 33.11 * mm / 2., - 39.25 * mm / 2., 39.25 * mm / 2., 0. * deg, 26.91 * mm / 2., - 27.58 * mm / 2., 27.58 * mm / 2., 0. * deg); - G4LogicalVolume* logicCristal3 = new G4LogicalVolume( - solidCristal3, m_MaterialCsI, Name + "_CsI_Cristal3", 0, 0, 0); + G4Trap* solidCristal3 = + new G4Trap("Cristal3", 40. * mm / 2., 18.243 * deg, 13.5988 * deg, 33.11 * mm / 2., 39.25 * mm / 2., + 39.25 * mm / 2., 0. * deg, 26.91 * mm / 2., 27.58 * mm / 2., 27.58 * mm / 2., 0. * deg); + G4LogicalVolume* logicCristal3 = new G4LogicalVolume(solidCristal3, m_MaterialCsI, Name + "_CsI_Cristal3", 0, 0, 0); // Cristal4 - G4Trap* solidCristal4 = new G4Trap( - "Cristal4", 40. * mm / 2., 24.0482 * deg, 44.1148 * deg, - 43.49 * mm / 2., 39.19 * mm / 2., 39.19 * mm / 2., 0. * deg, - 31.04 * mm / 2., 27.52 * mm / 2., 27.52 * mm / 2., 0. * deg); - G4LogicalVolume* logicCristal4 = new G4LogicalVolume( - solidCristal4, m_MaterialCsI, Name + "_CsI_Cristal4", 0, 0, 0); + G4Trap* solidCristal4 = + new G4Trap("Cristal4", 40. * mm / 2., 24.0482 * deg, 44.1148 * deg, 43.49 * mm / 2., 39.19 * mm / 2., + 39.19 * mm / 2., 0. * deg, 31.04 * mm / 2., 27.52 * mm / 2., 27.52 * mm / 2., 0. * deg); + G4LogicalVolume* logicCristal4 = new G4LogicalVolume(solidCristal4, m_MaterialCsI, Name + "_CsI_Cristal4", 0, 0, 0); // Cristal1s - G4Trap* solidCristal1s = new G4Trap( - "Cristal1s", 40. * mm / 2., 6.693896 * deg, -41.97814 * deg, - 33.1 * mm / 2., 37.39 * mm / 2., 37.39 * mm / 2., 0. * deg, - 26.9 * mm / 2., 30.41 * mm / 2., 30.41 * mm / 2., 0. * deg); - G4LogicalVolume* logicCristal1s = new G4LogicalVolume( - solidCristal1s, m_MaterialCsI, Name + "_CsI_Cristal1s", 0, 0, 0); + G4Trap* solidCristal1s = + new G4Trap("Cristal1s", 40. * mm / 2., 6.693896 * deg, -41.97814 * deg, 33.1 * mm / 2., 37.39 * mm / 2., + 37.39 * mm / 2., 0. * deg, 26.9 * mm / 2., 30.41 * mm / 2., 30.41 * mm / 2., 0. * deg); + G4LogicalVolume* logicCristal1s = + new G4LogicalVolume(solidCristal1s, m_MaterialCsI, Name + "_CsI_Cristal1s", 0, 0, 0); // Cristal2s - G4Trap* solidCristal2s = new G4Trap( - "Cristal2s", 40. * mm / 2., 17.8836 * deg, -(74.3122 + 180) * deg, - 43.49 * mm / 2., 37.39 * mm / 2., 37.39 * mm / 2., 0. * deg, - 31.0377 * mm / 2., 30.41 * mm / 2., 30.41 * mm / 2., 0. * deg); - G4LogicalVolume* logicCristal2s = new G4LogicalVolume( - solidCristal2s, m_MaterialCsI, Name + "_CsI_Cristal2s", 0, 0, 0); + G4Trap* solidCristal2s = + new G4Trap("Cristal2s", 40. * mm / 2., 17.8836 * deg, -(74.3122 + 180) * deg, 43.49 * mm / 2., 37.39 * mm / 2., + 37.39 * mm / 2., 0. * deg, 31.0377 * mm / 2., 30.41 * mm / 2., 30.41 * mm / 2., 0. * deg); + G4LogicalVolume* logicCristal2s = + new G4LogicalVolume(solidCristal2s, m_MaterialCsI, Name + "_CsI_Cristal2s", 0, 0, 0); // Cristal3s - G4Trap* solidCristal3s = new G4Trap( - "Cristal3s", 40. * mm / 2., 18.243 * deg, -13.5988 * deg, - 33.11 * mm / 2., 39.25 * mm / 2., 39.25 * mm / 2., 0. * deg, - 26.91 * mm / 2., 27.58 * mm / 2., 27.58 * mm / 2., 0. * deg); - G4LogicalVolume* logicCristal3s = new G4LogicalVolume( - solidCristal3s, m_MaterialCsI, Name + "_CsI_Cristal3s", 0, 0, 0); + G4Trap* solidCristal3s = + new G4Trap("Cristal3s", 40. * mm / 2., 18.243 * deg, -13.5988 * deg, 33.11 * mm / 2., 39.25 * mm / 2., + 39.25 * mm / 2., 0. * deg, 26.91 * mm / 2., 27.58 * mm / 2., 27.58 * mm / 2., 0. * deg); + G4LogicalVolume* logicCristal3s = + new G4LogicalVolume(solidCristal3s, m_MaterialCsI, Name + "_CsI_Cristal3s", 0, 0, 0); // Cristal4s - G4Trap* solidCristal4s = new G4Trap( - "Cristal4s", 40. * mm / 2., 24.0482 * deg, -44.1148 * deg, - 43.49 * mm / 2., 39.19 * mm / 2., 39.19 * mm / 2., 0. * deg, - 31.04 * mm / 2., 27.52 * mm / 2., 27.52 * mm / 2., 0. * deg); - G4LogicalVolume* logicCristal4s = new G4LogicalVolume( - solidCristal4s, m_MaterialCsI, Name + "_CsI_Cristal4s", 0, 0, 0); + G4Trap* solidCristal4s = + new G4Trap("Cristal4s", 40. * mm / 2., 24.0482 * deg, -44.1148 * deg, 43.49 * mm / 2., 39.19 * mm / 2., + 39.19 * mm / 2., 0. * deg, 31.04 * mm / 2., 27.52 * mm / 2., 27.52 * mm / 2., 0. * deg); + G4LogicalVolume* logicCristal4s = + new G4LogicalVolume(solidCristal4s, m_MaterialCsI, Name + "_CsI_Cristal4s", 0, 0, 0); G4double XEdge1 = 16.96 * mm + DistInterCsI * 0.5; G4double YEdge1 = 15.01 * mm + DistInterCsI * 0.5; @@ -555,63 +455,63 @@ void MUST2Array::VolumeMaker(G4int TelescopeNumber, G4ThreeVector MMpos, G4ThreeVector positionCristal3 = G4ThreeVector(-XEdge2, YEdge1, 0); G4ThreeVector positionCristal4 = G4ThreeVector(-XEdge2, YEdge2, 0); - new G4PVPlacement(Rotation(180., 0., 0.), positionCristal1, logicCristal1, - Name + "_CsI_Cristal1", logicCsI, false, 6); // 1 - new G4PVPlacement(Rotation(180., 0., 180.), positionCristal2, logicCristal2, - Name + "_CsI_Cristal2", logicCsI, false, 3); // 2 - new G4PVPlacement(Rotation(180., 0., 0.), positionCristal3, logicCristal3, - Name + "_CsI_Cristal3", logicCsI, false, 5); // 3 - new G4PVPlacement(Rotation(180., 0., 0.), positionCristal4, logicCristal4, - Name + "_CsI_Cristal4", logicCsI, false, 4); // 4 + new G4PVPlacement(Rotation(180., 0., 0.), positionCristal1, logicCristal1, Name + "_CsI_Cristal1", logicCsI, false, + 6); // 1 + new G4PVPlacement(Rotation(180., 0., 180.), positionCristal2, logicCristal2, Name + "_CsI_Cristal2", logicCsI, + false, 3); // 2 + new G4PVPlacement(Rotation(180., 0., 0.), positionCristal3, logicCristal3, Name + "_CsI_Cristal3", logicCsI, false, + 5); // 3 + new G4PVPlacement(Rotation(180., 0., 0.), positionCristal4, logicCristal4, Name + "_CsI_Cristal4", logicCsI, false, + 4); // 4 G4ThreeVector positionCristal1b = G4ThreeVector(XEdge1, -YEdge1, 0 * mm); G4ThreeVector positionCristal2b = G4ThreeVector(XEdge1, -YEdge2, 0); G4ThreeVector positionCristal3b = G4ThreeVector(XEdge2, -YEdge1, 0); G4ThreeVector positionCristal4b = G4ThreeVector(XEdge2, -YEdge2, 0); - new G4PVPlacement(Rotation(180., 0., 180.), positionCristal1b, - logicCristal1, Name + "_CsI_Cristal5", logicCsI, false, - 11); // 5 - new G4PVPlacement(Rotation(180., 0., 0.), positionCristal2b, logicCristal2, - Name + "_CsI_Cristal6", logicCsI, false, 15); // 6 - new G4PVPlacement(Rotation(180., 0., 180.), positionCristal3b, - logicCristal3, Name + "_CsI_Cristal7", logicCsI, false, - 12); // 7 - new G4PVPlacement(Rotation(180., 0., 180.), positionCristal4b, - logicCristal4, Name + "_CsI_Cristal8", logicCsI, false, - 16); // 8 + new G4PVPlacement(Rotation(180., 0., 180.), positionCristal1b, logicCristal1, Name + "_CsI_Cristal5", logicCsI, + false, + 11); // 5 + new G4PVPlacement(Rotation(180., 0., 0.), positionCristal2b, logicCristal2, Name + "_CsI_Cristal6", logicCsI, false, + 15); // 6 + new G4PVPlacement(Rotation(180., 0., 180.), positionCristal3b, logicCristal3, Name + "_CsI_Cristal7", logicCsI, + false, + 12); // 7 + new G4PVPlacement(Rotation(180., 0., 180.), positionCristal4b, logicCristal4, Name + "_CsI_Cristal8", logicCsI, + false, + 16); // 8 G4ThreeVector positionCristal1s = G4ThreeVector(-XEdge1, -YEdge1, 0 * mm); G4ThreeVector positionCristal2s = G4ThreeVector(-XEdge1, -YEdge2, 0); G4ThreeVector positionCristal3s = G4ThreeVector(-XEdge2, -YEdge1, 0); G4ThreeVector positionCristal4s = G4ThreeVector(-XEdge2, -YEdge2, 0); - new G4PVPlacement(Rotation(180., 0., 0.), positionCristal1s, logicCristal1s, - Name + "_CsI_Cristal9", logicCsI, false, 10); // 9 - new G4PVPlacement(Rotation(180., 0., 180.), positionCristal2s, - logicCristal2s, Name + "_CsI_Cristal10", logicCsI, false, - 14); // 10 - new G4PVPlacement(Rotation(180., 0., 0.), positionCristal3s, logicCristal3s, - Name + "_CsI_Cristal11", logicCsI, false, 9); // 11 - new G4PVPlacement(Rotation(180., 0., 0.), positionCristal4s, logicCristal4s, - Name + "_CsI_Cristal12", logicCsI, false, 13); // 12 + new G4PVPlacement(Rotation(180., 0., 0.), positionCristal1s, logicCristal1s, Name + "_CsI_Cristal9", logicCsI, + false, 10); // 9 + new G4PVPlacement(Rotation(180., 0., 180.), positionCristal2s, logicCristal2s, Name + "_CsI_Cristal10", logicCsI, + false, + 14); // 10 + new G4PVPlacement(Rotation(180., 0., 0.), positionCristal3s, logicCristal3s, Name + "_CsI_Cristal11", logicCsI, + false, 9); // 11 + new G4PVPlacement(Rotation(180., 0., 0.), positionCristal4s, logicCristal4s, Name + "_CsI_Cristal12", logicCsI, + false, 13); // 12 G4ThreeVector positionCristal1sb = G4ThreeVector(XEdge1, YEdge1, 0 * mm); G4ThreeVector positionCristal2sb = G4ThreeVector(XEdge1, YEdge2, 0); G4ThreeVector positionCristal3sb = G4ThreeVector(XEdge2, YEdge1, 0); G4ThreeVector positionCristal4sb = G4ThreeVector(XEdge2, YEdge2, 0); - new G4PVPlacement(Rotation(180., 0., 180.), positionCristal1sb, - logicCristal1s, Name + "_CsI_Cristal13", logicCsI, false, - 7); // 13 - new G4PVPlacement(Rotation(180, 0, 0), positionCristal2sb, logicCristal2s, - Name + "_CsI_Cristal14", logicCsI, false, 2); // 14 - new G4PVPlacement(Rotation(180., 0., 180.), positionCristal3sb, - logicCristal3s, Name + "_CsI_Cristal15", logicCsI, false, - 8); // 15 - new G4PVPlacement(Rotation(180., 0., 180.), positionCristal4sb, - logicCristal4s, Name + "_CsI_Cristal16", logicCsI, false, - 1); // 16 + new G4PVPlacement(Rotation(180., 0., 180.), positionCristal1sb, logicCristal1s, Name + "_CsI_Cristal13", logicCsI, + false, + 7); // 13 + new G4PVPlacement(Rotation(180, 0, 0), positionCristal2sb, logicCristal2s, Name + "_CsI_Cristal14", logicCsI, false, + 2); // 14 + new G4PVPlacement(Rotation(180., 0., 180.), positionCristal3sb, logicCristal3s, Name + "_CsI_Cristal15", logicCsI, + false, + 8); // 15 + new G4PVPlacement(Rotation(180., 0., 180.), positionCristal4sb, logicCristal4s, Name + "_CsI_Cristal16", logicCsI, + false, + 1); // 16 /// Set CsI sensible logicCristal1->SetSensitiveDetector(m_CsIScorer); @@ -652,43 +552,37 @@ void MUST2Array::ReadConfiguration(NPL::InputParser parser) { if (NPOptionManager::getInstance()->GetVerboseLevel()) cout << endl << "//// Must 2 Telecope " << i + 1 << endl; // Cartesian Case - vector<string> cart - = {"X1_Y1", "X1_Y128", "X128_Y1", "X128_Y128", "SI", "SILI", "CSI"}; + vector<string> cart = {"X1_Y1", "X1_Y128", "X128_Y1", "X128_Y128", "SI", "SILI", "CSI"}; // Spherical Case vector<string> sphe = {"R", "THETA", "PHI", "BETA", "SI", "SILI", "CSI"}; if (blocks[i]->HasTokenList(cart)) { - G4ThreeVector A - = NPS::ConvertVector(blocks[i]->GetTVector3("X1_Y1", "mm")); - G4ThreeVector B - = NPS::ConvertVector(blocks[i]->GetTVector3("X128_Y1", "mm")); - G4ThreeVector C - = NPS::ConvertVector(blocks[i]->GetTVector3("X1_Y128", "mm")); - G4ThreeVector D - = NPS::ConvertVector(blocks[i]->GetTVector3("X128_Y128", "mm")); - int SI = blocks[i]->GetInt("SI"); + G4ThreeVector A = NPS::ConvertVector(blocks[i]->GetTVector3("X1_Y1", "mm")); + G4ThreeVector B = NPS::ConvertVector(blocks[i]->GetTVector3("X128_Y1", "mm")); + G4ThreeVector C = NPS::ConvertVector(blocks[i]->GetTVector3("X1_Y128", "mm")); + G4ThreeVector D = NPS::ConvertVector(blocks[i]->GetTVector3("X128_Y128", "mm")); + int SI = blocks[i]->GetInt("SI"); int SILI = blocks[i]->GetInt("SILI"); - int CSI = blocks[i]->GetInt("CSI"); + int CSI = blocks[i]->GetInt("CSI"); AddTelescope(A, B, C, D, SI == 1, SILI == 1, CSI == 1); } else if (blocks[i]->HasTokenList(sphe)) { - double Theta = blocks[i]->GetDouble("THETA", "deg"); - double Phi = blocks[i]->GetDouble("PHI", "deg"); - double R = blocks[i]->GetDouble("R", "mm"); - vector<double> beta = blocks[i]->GetVectorDouble("BETA", "deg"); - int SI = blocks[i]->GetInt("SI"); - int SILI = blocks[i]->GetInt("SILI"); - int CSI = blocks[i]->GetInt("CSI"); - AddTelescope(R, Theta, Phi, beta[0], beta[1], beta[2], SI == 1, SILI == 1, - CSI == 1); + double Theta = blocks[i]->GetDouble("THETA", "deg"); + double Phi = blocks[i]->GetDouble("PHI", "deg"); + double R = blocks[i]->GetDouble("R", "mm"); + vector<double> beta = blocks[i]->GetVectorDouble("BETA", "deg"); + int SI = blocks[i]->GetInt("SI"); + int SILI = blocks[i]->GetInt("SILI"); + int CSI = blocks[i]->GetInt("CSI"); + AddTelescope(R, Theta, Phi, beta[0], beta[1], beta[2], SI == 1, SILI == 1, CSI == 1); } else { cout << "WARNING: Missing token for M2Telescope blocks, check your input " - "file" - << endl; + "file" + << endl; exit(1); } @@ -697,9 +591,9 @@ void MUST2Array::ReadConfiguration(NPL::InputParser parser) { } //////////////////// - //Read the thresholds from the analysis config - //////////////////// - + // Read the thresholds from the analysis config + //////////////////// + bool ReadingStatus = false; // path to file @@ -736,81 +630,81 @@ void MUST2Array::ReadConfiguration(NPL::InputParser parser) { if (whatToDo.compare(0, 1, "%") == 0) { AnalysisConfigFile.ignore(numeric_limits<streamsize>::max(), '\n'); } - //Resolutions + // Resolutions else if (whatToDo == "SI_E_RESOLUTION") { AnalysisConfigFile >> DataBuffer; ResoStrip = atof(DataBuffer.c_str()); - ResoStrip = ResoStrip*keV/2.35; - cout << whatToDo << " " << ResoStrip << " MeV/2.35 "<< endl; + ResoStrip = ResoStrip * keV / 2.35; + cout << whatToDo << " " << ResoStrip << " MeV/2.35 " << endl; } else if (whatToDo == "SILI_E_RESOLUTION") { AnalysisConfigFile >> DataBuffer; ResoSiLi = atof(DataBuffer.c_str()); - ResoSiLi = ResoSiLi*keV/2.35; - cout << whatToDo << " " << ResoSiLi << " MeV/2.35 "<< endl; + ResoSiLi = ResoSiLi * keV / 2.35; + cout << whatToDo << " " << ResoSiLi << " MeV/2.35 " << endl; } else if (whatToDo == "CSI_E_RESOLUTION") { AnalysisConfigFile >> DataBuffer; ResoCsI = atof(DataBuffer.c_str()); - ResoCsI = ResoCsI*keV/2.35; - cout << whatToDo << " " << ResoCsI << " MeV/2.35 "<< endl; + ResoCsI = ResoCsI * keV / 2.35; + cout << whatToDo << " " << ResoCsI << " MeV/2.35 " << endl; } - //Time + // Time else if (whatToDo == "MUST_T_RESOLUTION") { AnalysisConfigFile >> DataBuffer; ResoTimeMust = atof(DataBuffer.c_str()); - ResoTimeMust = ResoTimeMust*ns/2.35; - cout << whatToDo << " " << ResoTimeMust << " ns/2.35 "<< endl; + ResoTimeMust = ResoTimeMust * ns / 2.35; + cout << whatToDo << " " << ResoTimeMust << " ns/2.35 " << endl; } else if (whatToDo == "SI_T_OFFSET") { AnalysisConfigFile >> DataBuffer; TimeOffset = atof(DataBuffer.c_str()); - TimeOffset = TimeOffset*ns; - cout << whatToDo << " " << TimeOffset << " ns "<< endl; + TimeOffset = TimeOffset * ns; + cout << whatToDo << " " << TimeOffset << " ns " << endl; } - //Thresholds + // Thresholds else if (whatToDo == "SI_X_E_THRESHOLD") { AnalysisConfigFile >> DataBuffer; ThresholdSiX = atof(DataBuffer.c_str()); - ThresholdSiX = ThresholdSiX*keV; - cout << whatToDo << " " << ThresholdSiX << " MeV "<< endl; + ThresholdSiX = ThresholdSiX * keV; + cout << whatToDo << " " << ThresholdSiX << " MeV " << endl; } else if (whatToDo == "SI_Y_E_THRESHOLD") { AnalysisConfigFile >> DataBuffer; ThresholdSiY = atof(DataBuffer.c_str()); - ThresholdSiY = ThresholdSiY*keV; - cout << whatToDo << " " << ThresholdSiY << " MeV "<< endl; + ThresholdSiY = ThresholdSiY * keV; + cout << whatToDo << " " << ThresholdSiY << " MeV " << endl; } else if (whatToDo == "SILI_E_THRESHOLD") { AnalysisConfigFile >> DataBuffer; ThresholdSiLi = atof(DataBuffer.c_str()); - ThresholdSiLi = ThresholdSiLi*keV; - cout << whatToDo << " " << ThresholdSiLi << " MeV "<< endl; + ThresholdSiLi = ThresholdSiLi * keV; + cout << whatToDo << " " << ThresholdSiLi << " MeV " << endl; } else if (whatToDo == "CSI_E_THRESHOLD") { AnalysisConfigFile >> DataBuffer; ThresholdCsI = atof(DataBuffer.c_str()); - ThresholdCsI = ThresholdCsI*keV; - cout << whatToDo << " " << ThresholdCsI << " MeV "<< endl; - } - else if (AnalysisConfigFile.eof()) ReadingStatus = false; + ThresholdCsI = ThresholdCsI * keV; + cout << whatToDo << " " << ThresholdCsI << " MeV " << endl; + } + else if (AnalysisConfigFile.eof()) + ReadingStatus = false; } } } - // Construct detector and inialise sensitive part. // Called After DetecorConstruction::AddDetector Method void MUST2Array::ConstructDetector(G4LogicalVolume* world) { - G4RotationMatrix* MMrot = NULL; - G4ThreeVector MMpos = G4ThreeVector(0, 0, 0); - G4ThreeVector MMu = G4ThreeVector(0, 0, 0); - G4ThreeVector MMv = G4ThreeVector(0, 0, 0); - G4ThreeVector MMw = G4ThreeVector(0, 0, 0); - G4ThreeVector MMCenter = G4ThreeVector(0, 0, 0); - bool Si = true; - bool SiLi = true; - bool CsI = true; + G4RotationMatrix* MMrot = NULL; + G4ThreeVector MMpos = G4ThreeVector(0, 0, 0); + G4ThreeVector MMu = G4ThreeVector(0, 0, 0); + G4ThreeVector MMv = G4ThreeVector(0, 0, 0); + G4ThreeVector MMw = G4ThreeVector(0, 0, 0); + G4ThreeVector MMCenter = G4ThreeVector(0, 0, 0); + bool Si = true; + bool SiLi = true; + bool CsI = true; G4int NumberOfTelescope = m_DefinitionType.size(); @@ -830,8 +724,7 @@ void MUST2Array::ConstructDetector(G4LogicalVolume* world) { // if (MMw.z() > 0)MMw = MMv.cross(MMu) ; MMw = MMw.unit(); - MMCenter - = (m_X1_Y1[i] + m_X1_Y128[i] + m_X128_Y1[i] + m_X128_Y128[i]) / 4; + MMCenter = (m_X1_Y1[i] + m_X1_Y128[i] + m_X128_Y1[i] + m_X128_Y128[i]) / 4; // Passage Matrix from Lab Referential to Telescope Referential MMrot = new G4RotationMatrix(MMv, MMu, MMw); @@ -841,7 +734,7 @@ void MUST2Array::ConstructDetector(G4LogicalVolume* world) { // By Angle else { G4double Theta = m_Theta[i]; - G4double Phi = m_Phi[i]; + G4double Phi = m_Phi[i]; // (u,v,w) unitary vector associated to telescope referencial // (u,v) // to silicon plan @@ -851,16 +744,16 @@ void MUST2Array::ConstructDetector(G4LogicalVolume* world) { G4double wX = m_R[i] * sin(Theta / rad) * cos(Phi / rad); G4double wY = m_R[i] * sin(Theta / rad) * sin(Phi / rad); G4double wZ = m_R[i] * cos(Theta / rad); - MMw = G4ThreeVector(wX, wY, wZ); + MMw = G4ThreeVector(wX, wY, wZ); // vector corresponding to the center of the module G4ThreeVector CT = MMw; // vector parallel to one axis of silicon plane - G4double ii = cos(Theta / rad) * cos(Phi / rad); - G4double jj = cos(Theta / rad) * sin(Phi / rad); - G4double kk = -sin(Theta / rad); - G4ThreeVector Y = G4ThreeVector(ii, jj, kk); + G4double ii = cos(Theta / rad) * cos(Phi / rad); + G4double jj = cos(Theta / rad) * sin(Phi / rad); + G4double kk = -sin(Theta / rad); + G4ThreeVector Y = G4ThreeVector(ii, jj, kk); MMw = MMw.unit(); MMu = MMw.cross(Y); @@ -879,9 +772,9 @@ void MUST2Array::ConstructDetector(G4LogicalVolume* world) { MMpos = MMw * Length * 0.5 + CT; } - Si = m_wSi[i]; + Si = m_wSi[i]; SiLi = m_wSiLi[i]; - CsI = m_wCsI[i]; + CsI = m_wCsI[i]; VolumeMaker(i + 1, MMpos, MMrot, Si, SiLi, CsI, world); } @@ -894,7 +787,7 @@ void MUST2Array::ConstructDetector(G4LogicalVolume* world) { void MUST2Array::InitializeRootOutput() { RootOutput* pAnalysis = RootOutput::getInstance(); - TTree* pTree = pAnalysis->GetTree(); + TTree* pTree = pAnalysis->GetTree(); if (!pTree->FindBranch("MUST2")) { pTree->Branch("MUST2", "TMust2Data", &m_Event); } @@ -913,145 +806,133 @@ void MUST2Array::ReadSensitive(const G4Event*) { ///////////////////// // Read the Scorer associate to the Silicon Strip - DSSDScorers::PS_Images* SiScorer - = (DSSDScorers::PS_Images*)m_StripScorer->GetPrimitive(0); + DSSDScorers::PS_Images* SiScorer = (DSSDScorers::PS_Images*)m_StripScorer->GetPrimitive(0); - bool SiScoredHit; // flag true if first stage scores a hit above threshold - set<int> trig; // list of telescope that got a Si trigger + bool SiScoredHit; // flag true if first stage scores a hit above threshold + set<int> trig; // list of telescope that got a Si trigger unsigned int sizeFront = SiScorer->GetFrontMult(); - unsigned int sizeBack = SiScorer->GetBackMult(); + unsigned int sizeBack = SiScorer->GetBackMult(); - // Check for double match Strip : + // Check for double match Strip : // rare case where a particle hit a strip and then an interstrip // since the map idex is build on pixel value, we end up with the same strip // fired twice, which is impossible in reality. - std::map< unsigned int, std::pair<double,double> > mapFront; - std::map< unsigned int, std::pair<double,double> >::iterator it; + std::map<unsigned int, std::pair<double, double>> mapFront; + std::map<unsigned int, std::pair<double, double>>::iterator it; for (unsigned int i = 0; i < sizeFront; i++) { - double energy = SiScorer->GetEnergyFront(i); - int detectorNbr = SiScorer->GetDetectorFront(i); - double time = SiScorer->GetTimeFront(i); + double energy = SiScorer->GetEnergyFront(i); + int detectorNbr = SiScorer->GetDetectorFront(i); + double time = SiScorer->GetTimeFront(i); // Pixel value at interaction point unsigned int a, r, g, b; // pixel SiScorer->GetARGBFront(i, a, r, g, b); if (r == 0) { - mapFront[b+detectorNbr*1e6].first+=energy; - mapFront[b+detectorNbr*1e6].second=time; - } + mapFront[b + detectorNbr * 1e6].first += energy; + mapFront[b + detectorNbr * 1e6].second = time; + } else { // Interstrip X, keep maximum shared energy double rand = G4UniformRand(); if (rand > 0.5) { double energyX = rand * energy; - mapFront[b+detectorNbr*1e6].first+=energyX; - mapFront[b+detectorNbr*1e6].second=time; - } + mapFront[b + detectorNbr * 1e6].first += energyX; + mapFront[b + detectorNbr * 1e6].second = time; + } else { - double energyX = (1 - rand) * energy; - mapFront[g+detectorNbr*1e6].first+=energyX; - mapFront[g+detectorNbr*1e6].second=time; - } + double energyX = (1 - rand) * energy; + mapFront[g + detectorNbr * 1e6].first += energyX; + mapFront[g + detectorNbr * 1e6].second = time; } } + } - for(it=mapFront.begin();it!=mapFront.end();it++){ + for (it = mapFront.begin(); it != mapFront.end(); it++) { double energyX = RandGauss::shoot(it->second.first, ResoStrip); double timeX = TimeOffset - RandGauss::shoot(it->second.second, ResoTimeMust); - unsigned int strip = it->first-1000000*(it->first/1000000); - unsigned int det = it->first/1000000; + unsigned int strip = it->first - 1000000 * (it->first / 1000000); + unsigned int det = it->first / 1000000; if (energyX > ThresholdSiX) { trig.insert(det); SiScoredHit = true; - m_Event->SetStripXE(det, strip , - NPL::EnergyToADC(energyX, 0, 63, 8192, 16384)); - m_Event->SetStripXT(det, strip , - NPL::EnergyToADC(timeX, 0, 1000, 8192, 16384)); + m_Event->SetStripXE(det, strip, NPL::EnergyToADC(energyX, 0, 63, 8192, 16384)); + m_Event->SetStripXT(det, strip, NPL::EnergyToADC(timeX, 0, 1000, 8192, 16384)); } } - // Check for double match Strip : + // Check for double match Strip : // rare case where a particle hit a strip and then an interstrip // since the map idex is build on pixel value, we end up with the same strip // fired twice, which is impossible in reality. - std::map< unsigned int, std::pair<double,double> > mapBack; + std::map<unsigned int, std::pair<double, double>> mapBack; for (unsigned int i = 0; i < sizeBack; i++) { - double energy = SiScorer->GetEnergyBack(i); - int detectorNbr = SiScorer->GetDetectorBack(i); - double time = SiScorer->GetTimeBack(i); - - // Pixel value at interaction point - unsigned int a, r, g, b; - // pixel - SiScorer->GetARGBBack(i, a, r, g, b); - if (r == 0) { - mapBack[b+detectorNbr*1e6].first+=energy; - mapBack[b+detectorNbr*1e6].second=time; - } - else { // Interstrip Y, keep both strip with shared energy - double rand = G4UniformRand(); - double energyY1 = rand * energy; - mapBack[b+detectorNbr*1e6].first+=energyY1; - mapBack[b+detectorNbr*1e6].second=time; - - double energyY2 = (1 - rand) * energy; - mapBack[g+detectorNbr*1e6].first+=energyY2; - mapBack[g+detectorNbr*1e6].second=time; - } - } + double energy = SiScorer->GetEnergyBack(i); + int detectorNbr = SiScorer->GetDetectorBack(i); + double time = SiScorer->GetTimeBack(i); - for(it=mapBack.begin();it!=mapBack.end();it++){ + // Pixel value at interaction point + unsigned int a, r, g, b; + // pixel + SiScorer->GetARGBBack(i, a, r, g, b); + if (r == 0) { + mapBack[b + detectorNbr * 1e6].first += energy; + mapBack[b + detectorNbr * 1e6].second = time; + } + else { // Interstrip Y, keep both strip with shared energy + double rand = G4UniformRand(); + double energyY1 = rand * energy; + mapBack[b + detectorNbr * 1e6].first += energyY1; + mapBack[b + detectorNbr * 1e6].second = time; + + double energyY2 = (1 - rand) * energy; + mapBack[g + detectorNbr * 1e6].first += energyY2; + mapBack[g + detectorNbr * 1e6].second = time; + } + } + + for (it = mapBack.begin(); it != mapBack.end(); it++) { double energyY = RandGauss::shoot(it->second.first, ResoStrip); double timeY = TimeOffset - RandGauss::shoot(it->second.second, ResoTimeMust); - unsigned int strip = it->first-1000000*(it->first/1000000); - unsigned int det = it->first/1000000; + unsigned int strip = it->first - 1000000 * (it->first / 1000000); + unsigned int det = it->first / 1000000; if (energyY > ThresholdSiY) { trig.insert(det); SiScoredHit = true; - m_Event->SetStripYE(det, strip , - NPL::EnergyToADC(energyY, 0, 63, 8192, 0)); - m_Event->SetStripYT(det, strip , - NPL::EnergyToADC(timeY, 0, 1000, 8192, 16384)); + m_Event->SetStripYE(det, strip, NPL::EnergyToADC(energyY, 0, 63, 8192, 0)); + m_Event->SetStripYT(det, strip, NPL::EnergyToADC(timeY, 0, 1000, 8192, 16384)); } } - // Look for 2nd and 3rd stage only if 1st stage is hit if (SiScoredHit) { // SiLi // - CalorimeterScorers::PS_Calorimeter* SiLiScorer - = (CalorimeterScorers::PS_Calorimeter*)m_SiLiScorer->GetPrimitive(0); + CalorimeterScorers::PS_Calorimeter* SiLiScorer = (CalorimeterScorers::PS_Calorimeter*)m_SiLiScorer->GetPrimitive(0); unsigned int sizeSiLi = SiLiScorer->GetMult(); for (unsigned int i = 0; i < sizeSiLi; i++) { double ESiLi = RandGauss::shoot(SiLiScorer->GetEnergy(i), ResoSiLi); vector<unsigned int> level = SiLiScorer->GetLevel(i); - if(ESiLi>ThresholdSiLi){ - m_Event->SetSiLiE(level[0], level[1], - NPL::EnergyToADC(ESiLi, 0, 250, 8192, 16384)); + if (ESiLi > ThresholdSiLi) { + m_Event->SetSiLiE(level[0], level[1], NPL::EnergyToADC(ESiLi, 0, 250, 8192, 16384)); double timeSiLi = RandGauss::shoot(SiLiScorer->GetTime(i), ResoTimeMust); - m_Event->SetSiLiT(level[0], level[1], - NPL::EnergyToADC(timeSiLi, 0, 1000, 16384, 8192)); + m_Event->SetSiLiT(level[0], level[1], NPL::EnergyToADC(timeSiLi, 0, 1000, 16384, 8192)); } } // CsI // - CalorimeterScorers::PS_Calorimeter* CsIScorer - = (CalorimeterScorers::PS_Calorimeter*)m_CsIScorer->GetPrimitive(0); + CalorimeterScorers::PS_Calorimeter* CsIScorer = (CalorimeterScorers::PS_Calorimeter*)m_CsIScorer->GetPrimitive(0); unsigned int sizeCsI = CsIScorer->GetMult(); for (unsigned int i = 0; i < sizeCsI; i++) { double ECsI = RandGauss::shoot(CsIScorer->GetEnergy(i), ResoCsI); vector<unsigned int> level = CsIScorer->GetLevel(i); - if(ECsI>ThresholdCsI){ - m_Event->SetCsIE(level[0], level[1], - NPL::EnergyToADC(ECsI, 0, 250, 8192, 16384)); + if (ECsI > ThresholdCsI) { + m_Event->SetCsIE(level[0], level[1], NPL::EnergyToADC(ECsI, 0, 250, 8192, 16384)); double timeCsI = RandGauss::shoot(CsIScorer->GetTime(i), ResoTimeMust); - m_Event->SetCsIT(level[0], level[1], - NPL::EnergyToADC(timeCsI, 0, 1000, 16384, 8192)); + m_Event->SetCsIT(level[0], level[1], NPL::EnergyToADC(timeCsI, 0, 1000, 16384, 8192)); } } } @@ -1062,37 +943,33 @@ void MUST2Array::InitializeScorers() { // Silicon Associate Scorer bool already_exist = false; - m_StripScorer = CheckScorer("MUST2_StripScorer", already_exist); - m_SiLiScorer = CheckScorer("MUST2_SiLiScorer", already_exist); - m_CsIScorer = CheckScorer("MUST2_CsIScorer", already_exist); + m_StripScorer = CheckScorer("MUST2_StripScorer", already_exist); + m_SiLiScorer = CheckScorer("MUST2_SiLiScorer", already_exist); + m_CsIScorer = CheckScorer("MUST2_CsIScorer", already_exist); // if the scorer were created previously nothing else need to be made if (already_exist) return; - string nptool = getenv("NPTOOL"); + string nptool = getenv("NPTOOL"); G4VPrimitiveScorer* SiScorer = new DSSDScorers::PS_Images( "SiScorer", nptool + "/NPLib/Detectors/MUST2/ressources/maskFront.png", - nptool + "/NPLib/Detectors/MUST2/ressources/maskBack.png", 97.22/12800, 97.22/12800, 0, - 0, 0xffff0000, 0); + nptool + "/NPLib/Detectors/MUST2/ressources/maskBack.png", 97.22 / 12800, 97.22 / 12800, 0, 0, 0xffff0000, 0); - G4VPrimitiveScorer* InterScorer - = new InteractionScorers::PS_Interactions("SiScorer", ms_InterCoord, 0); + G4VPrimitiveScorer* InterScorer = new InteractionScorers::PS_Interactions("SiScorer", ms_InterCoord, 0); // and register it to the multifunctionnal detector m_StripScorer->RegisterPrimitive(SiScorer); m_StripScorer->RegisterPrimitive(InterScorer); // SiLi Associate Scorer - vector<int> SiLi_nesting = {3, 0}; - G4VPrimitiveScorer* SiLiScorer - = new CalorimeterScorers::PS_Calorimeter("SiLiScorer", SiLi_nesting); + vector<int> SiLi_nesting = {3, 0}; + G4VPrimitiveScorer* SiLiScorer = new CalorimeterScorers::PS_Calorimeter("SiLiScorer", SiLi_nesting); m_SiLiScorer->RegisterPrimitive(SiLiScorer); // CsI Associate Scorer - vector<int> CsI_nesting = {2, 0}; - G4VPrimitiveScorer* CsIScorer - = new CalorimeterScorers::PS_Calorimeter("CsIScorer", CsI_nesting, 0); + vector<int> CsI_nesting = {2, 0}; + G4VPrimitiveScorer* CsIScorer = new CalorimeterScorers::PS_Calorimeter("CsIScorer", CsI_nesting, 0); m_CsIScorer->RegisterPrimitive(CsIScorer); // Add All Scorer to the Global Scorer Manager @@ -1104,32 +981,24 @@ void MUST2Array::InitializeScorers() { //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... void MUST2Array::InitializeMaterial() { - m_MaterialSilicon - = MaterialManager::getInstance()->GetMaterialFromLibrary("Si"); - m_MaterialAluminium - = MaterialManager::getInstance()->GetMaterialFromLibrary("Al"); + m_MaterialSilicon = MaterialManager::getInstance()->GetMaterialFromLibrary("Si"); + m_MaterialAluminium = MaterialManager::getInstance()->GetMaterialFromLibrary("Al"); m_MaterialIron = MaterialManager::getInstance()->GetMaterialFromLibrary("Fe"); - m_MaterialVacuum - = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); + m_MaterialVacuum = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... G4RotationMatrix* Rotation(double tetaX, double tetaY, double tetaZ) { - double PI = 3.141592653589793238; + double PI = 3.141592653589793238; double radX = tetaX * PI / 180.; double radY = tetaY * PI / 180.; double radZ = tetaZ * PI / 180.; - G4ThreeVector col1 = G4ThreeVector(cos(radZ) * cos(radY), - -sin(radZ) * cos(radY), -sin(radY)); - G4ThreeVector col2 - = G4ThreeVector(sin(radZ) * cos(radX) - cos(radZ) * sin(radY) * sin(radX), - cos(radZ) * cos(radX) + sin(radZ) * sin(radY) * sin(radX), - -cos(radY) * sin(radX)); - G4ThreeVector col3 - = G4ThreeVector(sin(radZ) * sin(radX) + cos(radZ) * sin(radY) * sin(radX), - cos(radZ) * sin(radX) - sin(radZ) * sin(radY) * cos(radX), - cos(radY) * cos(radX)); + G4ThreeVector col1 = G4ThreeVector(cos(radZ) * cos(radY), -sin(radZ) * cos(radY), -sin(radY)); + G4ThreeVector col2 = G4ThreeVector(sin(radZ) * cos(radX) - cos(radZ) * sin(radY) * sin(radX), + cos(radZ) * cos(radX) + sin(radZ) * sin(radY) * sin(radX), -cos(radY) * sin(radX)); + G4ThreeVector col3 = G4ThreeVector(sin(radZ) * sin(radX) + cos(radZ) * sin(radY) * sin(radX), + cos(radZ) * sin(radX) - sin(radZ) * sin(radY) * cos(radX), cos(radY) * cos(radX)); return (new G4RotationMatrix(col1, col2, col3)); } @@ -1137,22 +1006,19 @@ G4RotationMatrix* Rotation(double tetaX, double tetaY, double tetaZ) { //////////////////////////////////////////////////////////////////////////////// // Construct Method to be pass to the DetectorFactory // //////////////////////////////////////////////////////////////////////////////// -NPS::VDetector* MUST2Array::Construct() { - return (NPS::VDetector*)new MUST2Array(); -} +NPS::VDetector* MUST2Array::Construct() { return (NPS::VDetector*)new MUST2Array(); } //////////////////////////////////////////////////////////////////////////////// // Registering the construct method to the factory // //////////////////////////////////////////////////////////////////////////////// extern "C" { - class proxy_nps_must2 { - public: - proxy_nps_must2() { - NPS::DetectorFactory::getInstance()->AddToken("M2Telescope", "MUST2"); - NPS::DetectorFactory::getInstance()->AddDetector("M2Telescope", - MUST2Array::Construct); - } - }; +class proxy_nps_must2 { + public: + proxy_nps_must2() { + NPS::DetectorFactory::getInstance()->AddToken("M2Telescope", "MUST2"); + NPS::DetectorFactory::getInstance()->AddDetector("M2Telescope", MUST2Array::Construct); + } +}; - proxy_nps_must2 p_nps_must2; +proxy_nps_must2 p_nps_must2; } diff --git a/NPSimulation/Detectors/Miniball/Miniball.cc b/NPSimulation/Detectors/Miniball/Miniball.cc index d8bcf5ae788c8e94db4bde464cec82e0f025c76c..fac982b5bf53c6dc653fd7b3dccc7bc330acc939 100644 --- a/NPSimulation/Detectors/Miniball/Miniball.cc +++ b/NPSimulation/Detectors/Miniball/Miniball.cc @@ -20,151 +20,150 @@ *****************************************************************************/ // C++ headers -#include <sstream> #include <cmath> #include <limits> -//G4 Geometry object -#include "G4Tubs.hh" +#include <sstream> +// G4 Geometry object #include "G4Box.hh" +#include "G4Tubs.hh" -//G4 sensitive -#include "G4SDManager.hh" +// G4 sensitive #include "G4MultiFunctionalDetector.hh" +#include "G4SDManager.hh" -//G4 various object +// G4 various object +#include "G4Colour.hh" #include "G4Material.hh" -#include "G4Transform3D.hh" #include "G4PVPlacement.hh" +#include "G4Transform3D.hh" #include "G4VisAttributes.hh" -#include "G4Colour.hh" // NPTool header -#include "Miniball.hh" #include "CalorimeterScorers.hh" #include "InteractionScorers.hh" -#include "RootOutput.h" #include "MaterialManager.hh" -#include "NPSDetectorFactory.hh" +#include "Miniball.hh" #include "NPOptionManager.h" +#include "NPSDetectorFactory.hh" +#include "RootOutput.h" // CLHEP header #include "CLHEP/Random/RandGauss.h" using namespace std; using namespace CLHEP; - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -namespace Miniball_NS{ +namespace Miniball_NS { // Energy and time Resolution - const double EnergyThreshold = 0.01*MeV; - const double ResoTime = 4.5*ns ; - const double ResoEnergy = 0.003*MeV ; - const double ResoAngle = 5*deg; -} + const double EnergyThreshold = 0.01 * MeV; + const double ResoTime = 4.5 * ns; + const double ResoEnergy = 0.003 * MeV; + const double ResoAngle = 5 * deg; +} // namespace Miniball_NS //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Miniball Specific Method -Miniball::Miniball(){ - m_Event = new TMiniballData() ; +Miniball::Miniball() { + m_Event = new TMiniballData(); m_MiniballScorer = 0; m_ClusterDetector = 0; m_NumberOfPlacedVolume = 0; - m_Inter=new TInteractionCoordinates(); + m_Inter = new TInteractionCoordinates(); } -Miniball::~Miniball(){ -} +Miniball::~Miniball() {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Miniball::AddMiniball(double R, double Theta, double Phi){ +void Miniball::AddMiniball(double R, double Theta, double Phi) { m_R.push_back(R); m_Theta.push_back(Theta); m_Phi.push_back(Phi); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -G4AssemblyVolume* Miniball::BuildClusterDetector(){ - if(!m_ClusterDetector){ - m_ClusterDetector= new G4AssemblyVolume(); - cout << "Miniball geometry is based on Munich Group Simulation exported in GDML"<< endl; +G4AssemblyVolume* Miniball::BuildClusterDetector() { + if (!m_ClusterDetector) { + m_ClusterDetector = new G4AssemblyVolume(); + cout << "Miniball geometry is based on Munich Group Simulation exported in GDML" << endl; string basepath = getenv("NPTOOL"); - string path=basepath+"/NPSimulation/Detectors/Miniball/Miniball.gdml"; - m_gdmlparser.Read(path,false); + string path = basepath + "/NPSimulation/Detectors/Miniball/Miniball.gdml"; + m_gdmlparser.Read(path, false); - G4VisAttributes* Red = new G4VisAttributes(G4Color(1,0.5,0.5)); - G4VisAttributes* Green= new G4VisAttributes(G4Color(0.5,1,0.5)); - G4VisAttributes* Blue = new G4VisAttributes(G4Color(0.5,0.5,1)); - G4VisAttributes* Caps = new G4VisAttributes(G4Color(0.5,0.5,0.5,0.5)); + G4VisAttributes* Red = new G4VisAttributes(G4Color(1, 0.5, 0.5)); + G4VisAttributes* Green = new G4VisAttributes(G4Color(0.5, 1, 0.5)); + G4VisAttributes* Blue = new G4VisAttributes(G4Color(0.5, 0.5, 1)); + G4VisAttributes* Caps = new G4VisAttributes(G4Color(0.5, 0.5, 0.5, 0.5)); - G4VisAttributes* DL = new G4VisAttributes(G4VisAttributes::Invisible); + G4VisAttributes* DL = new G4VisAttributes(G4VisAttributes::GetInvisible()); - G4LogicalVolume* World = m_gdmlparser.GetVolume("MexpHall_log"); - string name,dname; - for(unsigned int i = 0 ; i < World->GetNoDaughters () ;i++){ + G4LogicalVolume* World = m_gdmlparser.GetVolume("MexpHall_log"); + string name, dname; + for (unsigned int i = 0; i < World->GetNoDaughters(); i++) { G4VPhysicalVolume* VPV = World->GetDaughter(i); name = VPV->GetLogicalVolume()->GetName(); - if(name == "cluster0_0_HPGe_A_0_det_env_log"){ - G4LogicalVolume* HPGE = VPV->GetLogicalVolume(); + if (name == "cluster0_0_HPGe_A_0_det_env_log") { + G4LogicalVolume* HPGE = VPV->GetLogicalVolume(); HPGE->GetDaughter(0)->GetLogicalVolume()->SetSensitiveDetector(m_MiniballScorer); HPGE->SetVisAttributes(Red); - G4RotationMatrix* Rot = VPV->GetObjectRotation(); - G4ThreeVector Pos = VPV->GetObjectTranslation(); - G4Transform3D Trans(*Rot,Pos); - m_ClusterDetector->AddPlacedVolume(HPGE,Trans); + G4RotationMatrix* Rot = VPV->GetObjectRotation(); + G4ThreeVector Pos = VPV->GetObjectTranslation(); + G4Transform3D Trans(*Rot, Pos); + m_ClusterDetector->AddPlacedVolume(HPGE, Trans); m_NumberOfPlacedVolume++; - for(unsigned int d = 0 ; d < HPGE->GetNoDaughters () ;d++){ - G4VPhysicalVolume* dVPV = HPGE->GetDaughter(d); + for (unsigned int d = 0; d < HPGE->GetNoDaughters(); d++) { + G4VPhysicalVolume* dVPV = HPGE->GetDaughter(d); dname = dVPV->GetLogicalVolume()->GetName(); - if(dname == "cluster0_0_HPGe_A_0_deadlayer_log"){ - G4LogicalVolume* DeadLayer = dVPV->GetLogicalVolume(); - DeadLayer->SetVisAttributes(DL); + if (dname == "cluster0_0_HPGe_A_0_deadlayer_log") { + G4LogicalVolume* DeadLayer = dVPV->GetLogicalVolume(); + DeadLayer->SetVisAttributes(DL); } } } - else if(name == "cluster0_0_HPGe_B_1_det_env_log"){ - G4LogicalVolume* HPGE = VPV->GetLogicalVolume(); + else if (name == "cluster0_0_HPGe_B_1_det_env_log") { + G4LogicalVolume* HPGE = VPV->GetLogicalVolume(); HPGE->GetDaughter(0)->GetLogicalVolume()->SetSensitiveDetector(m_MiniballScorer); HPGE->SetVisAttributes(Green); - G4RotationMatrix* Rot = VPV->GetObjectRotation(); - G4ThreeVector Pos = VPV->GetObjectTranslation(); - G4Transform3D Trans(*Rot,Pos); - m_ClusterDetector->AddPlacedVolume(HPGE,Trans); + G4RotationMatrix* Rot = VPV->GetObjectRotation(); + G4ThreeVector Pos = VPV->GetObjectTranslation(); + G4Transform3D Trans(*Rot, Pos); + m_ClusterDetector->AddPlacedVolume(HPGE, Trans); m_NumberOfPlacedVolume++; - for(unsigned int d = 0 ; d < HPGE->GetNoDaughters () ;d++){ - G4VPhysicalVolume* dVPV = HPGE->GetDaughter(d); + for (unsigned int d = 0; d < HPGE->GetNoDaughters(); d++) { + G4VPhysicalVolume* dVPV = HPGE->GetDaughter(d); dname = dVPV->GetLogicalVolume()->GetName(); - if(dname == "cluster0_0_HPGe_B_1_deadlayer_log"){ - G4LogicalVolume* DeadLayer = dVPV->GetLogicalVolume(); - DeadLayer->SetVisAttributes(DL); + if (dname == "cluster0_0_HPGe_B_1_deadlayer_log") { + G4LogicalVolume* DeadLayer = dVPV->GetLogicalVolume(); + DeadLayer->SetVisAttributes(DL); } } } - else if(name == "cluster0_0_HPGe_C_2_det_env_log"){ - G4LogicalVolume* HPGE = VPV->GetLogicalVolume(); + else if (name == "cluster0_0_HPGe_C_2_det_env_log") { + G4LogicalVolume* HPGE = VPV->GetLogicalVolume(); HPGE->GetDaughter(0)->GetLogicalVolume()->SetSensitiveDetector(m_MiniballScorer); HPGE->SetVisAttributes(Blue); - G4RotationMatrix* Rot = VPV->GetObjectRotation(); - G4ThreeVector Pos = VPV->GetObjectTranslation(); - G4Transform3D Trans(*Rot,Pos); - m_ClusterDetector->AddPlacedVolume(HPGE,Trans); - for(unsigned int d = 0 ; d < HPGE->GetNoDaughters () ;d++){ - G4VPhysicalVolume* dVPV = HPGE->GetDaughter(d); + G4RotationMatrix* Rot = VPV->GetObjectRotation(); + G4ThreeVector Pos = VPV->GetObjectTranslation(); + G4Transform3D Trans(*Rot, Pos); + m_ClusterDetector->AddPlacedVolume(HPGE, Trans); + for (unsigned int d = 0; d < HPGE->GetNoDaughters(); d++) { + G4VPhysicalVolume* dVPV = HPGE->GetDaughter(d); dname = dVPV->GetLogicalVolume()->GetName(); - if(dname == "cluster0_0_HPGe_C_2_deadlayer_log"){ - G4LogicalVolume* DeadLayer = dVPV->GetLogicalVolume(); - DeadLayer->SetVisAttributes(DL); + if (dname == "cluster0_0_HPGe_C_2_deadlayer_log") { + G4LogicalVolume* DeadLayer = dVPV->GetLogicalVolume(); + DeadLayer->SetVisAttributes(DL); } - } m_NumberOfPlacedVolume++; + } + m_NumberOfPlacedVolume++; } - else if(name.compare(0,8,"cluster0")==0 || name == "nozzle_log"){ - G4LogicalVolume* Capsule= VPV->GetLogicalVolume(); + else if (name.compare(0, 8, "cluster0") == 0 || name == "nozzle_log") { + G4LogicalVolume* Capsule = VPV->GetLogicalVolume(); Capsule->SetVisAttributes(Caps); - G4RotationMatrix* Rot = VPV->GetObjectRotation(); - G4ThreeVector Pos = VPV->GetObjectTranslation(); - G4Transform3D Trans(*Rot,Pos); - m_ClusterDetector->AddPlacedVolume(Capsule,Trans); + G4RotationMatrix* Rot = VPV->GetObjectRotation(); + G4ThreeVector Pos = VPV->GetObjectTranslation(); + G4Transform3D Trans(*Rot, Pos); + m_ClusterDetector->AddPlacedVolume(Capsule, Trans); m_NumberOfPlacedVolume++; } } @@ -179,25 +178,25 @@ G4AssemblyVolume* Miniball::BuildClusterDetector(){ // Read stream at Configfile to pick-up parameters of detector (Position,...) // Called in DetecorConstruction::ReadDetextorConfiguration Method -void Miniball::ReadConfiguration(NPL::InputParser parser){ +void Miniball::ReadConfiguration(NPL::InputParser parser) { vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithToken("Miniball"); - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << "//// " << blocks.size() << " detectors found " << endl; + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks.size() << " detectors found " << endl; - vector<string> token = {"R","Theta","Phi"}; + vector<string> token = {"R", "Theta", "Phi"}; - for(unsigned int i = 0 ; i < blocks.size() ; i++){ - if(blocks[i]->HasTokenList(token)){ - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << endl << "//// Miniball Cluster" << i+1 << endl; - double R = blocks[i]->GetDouble("R","mm"); - double Theta = blocks[i]->GetDouble("Theta","deg"); - double Phi = blocks[i]->GetDouble("Phi","deg"); + for (unsigned int i = 0; i < blocks.size(); i++) { + if (blocks[i]->HasTokenList(token)) { + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// Miniball Cluster" << i + 1 << endl; + double R = blocks[i]->GetDouble("R", "mm"); + double Theta = blocks[i]->GetDouble("Theta", "deg"); + double Phi = blocks[i]->GetDouble("Phi", "deg"); - AddMiniball(R,Theta,Phi); + AddMiniball(R, Theta, Phi); } - else{ + else { cout << "ERROR: check your input file formatting " << endl; exit(1); } @@ -207,106 +206,107 @@ void Miniball::ReadConfiguration(NPL::InputParser parser){ // Construct detector and inialise sensitive part. // Called After DetecorConstruction::AddDetector Method -void Miniball::ConstructDetector(G4LogicalVolume* world){ +void Miniball::ConstructDetector(G4LogicalVolume* world) { BuildClusterDetector(); - for (unsigned short i = 0 ; i < m_R.size() ; i++) { + for (unsigned short i = 0; i < m_R.size(); i++) { - G4double wX = m_R[i] * sin(m_Theta[i] ) * cos(m_Phi[i] ) ; - G4double wY = m_R[i] * sin(m_Theta[i] ) * sin(m_Phi[i] ) ; - G4double wZ = m_R[i] * cos(m_Theta[i] ) ; - G4ThreeVector Det_pos = G4ThreeVector(wX, wY, wZ) ; + G4double wX = m_R[i] * sin(m_Theta[i]) * cos(m_Phi[i]); + G4double wY = m_R[i] * sin(m_Theta[i]) * sin(m_Phi[i]); + G4double wZ = m_R[i] * cos(m_Theta[i]); + G4ThreeVector Det_pos = G4ThreeVector(wX, wY, wZ); G4ThreeVector d = Det_pos.unit(); - Det_pos= Det_pos-d*100*mm; + Det_pos = Det_pos - d * 100 * mm; // Building Detector reference frame G4double ii = cos(m_Theta[i]) * cos(m_Phi[i]); G4double jj = cos(m_Theta[i]) * sin(m_Phi[i]); G4double kk = -sin(m_Theta[i]); - G4ThreeVector Y(ii,jj,kk); + G4ThreeVector Y(ii, jj, kk); G4ThreeVector w = Det_pos.unit(); G4ThreeVector u = w.cross(Y); G4ThreeVector v = w.cross(u); v = v.unit(); u = u.unit(); - - G4RotationMatrix* Rot = new G4RotationMatrix(u,v,w); - G4Transform3D Trans(*Rot,Det_pos); - m_ClusterDetector->MakeImprint(world,Det_pos, Rot,i+1); - // set a nicer name - std::vector< G4VPhysicalVolume * >::iterator it = m_ClusterDetector->GetVolumesIterator(); - it+=m_ClusterDetector->GetImprintsCount()*m_NumberOfPlacedVolume-1; - for(unsigned int l = 0 ; l < m_NumberOfPlacedVolume-3 ; l++){ + G4RotationMatrix* Rot = new G4RotationMatrix(u, v, w); + G4Transform3D Trans(*Rot, Det_pos); + m_ClusterDetector->MakeImprint(world, Det_pos, Rot, i + 1); + // set a nicer name + std::vector<G4VPhysicalVolume*>::iterator it = m_ClusterDetector->GetVolumesIterator(); + it += m_ClusterDetector->GetImprintsCount() * m_NumberOfPlacedVolume - 1; + for (unsigned int l = 0; l < m_NumberOfPlacedVolume - 3; l++) { (*it)->SetName("Capsule"); - (*it)->SetCopyNo(i+1); + (*it)->SetCopyNo(i + 1); it--; - } (*it)->SetName("HPGe_A"); - (*it)->SetCopyNo(i+1); + (*it)->SetCopyNo(i + 1); it--; (*it)->SetName("HPGe_B"); - (*it)->SetCopyNo(i+1); + (*it)->SetCopyNo(i + 1); it--; (*it)->SetName("HPGe_C"); - (*it)->SetCopyNo(i+1);; + (*it)->SetCopyNo(i + 1); + ; } } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Add Detector branch to the EventTree. // Called After DetecorConstruction::AddDetector Method -void Miniball::InitializeRootOutput(){ - RootOutput *pAnalysis = RootOutput::getInstance(); - TTree *pTree = pAnalysis->GetTree(); - if(!pTree->FindBranch("Miniball")){ - pTree->Branch("Miniball", "TMiniballData", &m_Event) ; +void Miniball::InitializeRootOutput() { + RootOutput* pAnalysis = RootOutput::getInstance(); + TTree* pTree = pAnalysis->GetTree(); + if (!pTree->FindBranch("Miniball")) { + pTree->Branch("Miniball", "TMiniballData", &m_Event); } - pTree->SetBranchAddress("Miniball", &m_Event) ; + pTree->SetBranchAddress("Miniball", &m_Event); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Read sensitive part and fill the Root tree. // Called at in the EventAction::EndOfEventAction -void Miniball::ReadSensitive(const G4Event* ){ +void Miniball::ReadSensitive(const G4Event*) { m_Event->Clear(); /////////// - CalorimeterScorers::PS_Calorimeter* Scorer= (CalorimeterScorers::PS_Calorimeter*) m_MiniballScorer->GetPrimitive(0); - // InteractionScorers::PS_Interactions* Inter= (InteractionScorers::PS_Interactions*) m_MiniballScorer->GetPrimitive(1); - - unsigned int size = Scorer->GetMult(); - for(unsigned int i = 0 ; i < size ; i++){ - vector<unsigned int> level = Scorer->GetLevel(i); - double Energy = RandGauss::shoot(Scorer->GetEnergy(i),Miniball_NS::ResoEnergy); - if(Energy>Miniball_NS::EnergyThreshold){ - double Time = RandGauss::shoot(Scorer->GetTime(i),Miniball_NS::ResoTime); + CalorimeterScorers::PS_Calorimeter* Scorer = (CalorimeterScorers::PS_Calorimeter*)m_MiniballScorer->GetPrimitive(0); + // InteractionScorers::PS_Interactions* Inter= (InteractionScorers::PS_Interactions*) + // m_MiniballScorer->GetPrimitive(1); + + unsigned int size = Scorer->GetMult(); + for (unsigned int i = 0; i < size; i++) { + vector<unsigned int> level = Scorer->GetLevel(i); + double Energy = RandGauss::shoot(Scorer->GetEnergy(i), Miniball_NS::ResoEnergy); + if (Energy > Miniball_NS::EnergyThreshold) { + double Time = RandGauss::shoot(Scorer->GetTime(i), Miniball_NS::ResoTime); int DetectorNbr = level[0]; - //double Angle = RandGauss::shoot(Info[5]/deg,Miniball_NS::ResoAngle); - m_Event->SetEnergy(DetectorNbr,Energy); - //m_Event->SetAngle(DetectorNbr,Angle); - m_Event->SetTime(DetectorNbr,Time); + // double Angle = RandGauss::shoot(Info[5]/deg,Miniball_NS::ResoAngle); + m_Event->SetEnergy(DetectorNbr, Energy); + // m_Event->SetAngle(DetectorNbr,Angle); + m_Event->SetTime(DetectorNbr, Time); m_Event->SetAngle(DetectorNbr, m_Inter->GetDetectedAngleTheta(i)); } } } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -//////////////////////////////////////////////////////////////// -void Miniball::InitializeScorers() { +//////////////////////////////////////////////////////////////// +void Miniball::InitializeScorers() { // This check is necessary in case the geometry is reloaded - bool already_exist = false; - m_MiniballScorer = CheckScorer("MiniballScorer",already_exist) ; + bool already_exist = false; + m_MiniballScorer = CheckScorer("MiniballScorer", already_exist); - if(already_exist) - return ; + if (already_exist) + return; // Otherwise the scorer is initialised - vector<int> level; level.push_back(1); - G4VPrimitiveScorer* Calorimeter= new CalorimeterScorers::PS_Calorimeter("Crystal",level, 0) ; - G4VPrimitiveScorer* Inter= new InteractionScorers::PS_Interactions("Inter",m_Inter, 1) ; - //and register it to the multifunctionnal detector + vector<int> level; + level.push_back(1); + G4VPrimitiveScorer* Calorimeter = new CalorimeterScorers::PS_Calorimeter("Crystal", level, 0); + G4VPrimitiveScorer* Inter = new InteractionScorers::PS_Interactions("Inter", m_Inter, 1); + // and register it to the multifunctionnal detector m_MiniballScorer->RegisterPrimitive(Calorimeter); m_MiniballScorer->RegisterPrimitive(Inter); - G4SDManager::GetSDMpointer()->AddNewDetector(m_MiniballScorer) ; + G4SDManager::GetSDMpointer()->AddNewDetector(m_MiniballScorer); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... @@ -315,22 +315,20 @@ void Miniball::InitializeScorers() { //////////////////////////////////////////////////////////////////////////////// // Construct Method to be pass to the DetectorFactory // //////////////////////////////////////////////////////////////////////////////// -NPS::VDetector* Miniball::Construct(){ - return (NPS::VDetector*) new Miniball(); -} +NPS::VDetector* Miniball::Construct() { return (NPS::VDetector*)new Miniball(); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //////////////////////////////////////////////////////////////////////////////// // Registering the construct method to the factory // //////////////////////////////////////////////////////////////////////////////// -extern"C" { - class proxy_nps_plastic{ - public: - proxy_nps_plastic(){ - NPS::DetectorFactory::getInstance()->AddToken("Miniball","Miniball"); - NPS::DetectorFactory::getInstance()->AddDetector("Miniball",Miniball::Construct); - } - }; +extern "C" { +class proxy_nps_plastic { + public: + proxy_nps_plastic() { + NPS::DetectorFactory::getInstance()->AddToken("Miniball", "Miniball"); + NPS::DetectorFactory::getInstance()->AddDetector("Miniball", Miniball::Construct); + } +}; - proxy_nps_plastic p_nps_plastic; +proxy_nps_plastic p_nps_plastic; } diff --git a/NPSimulation/Detectors/Minos/Minos.cc b/NPSimulation/Detectors/Minos/Minos.cc index 2d19c944d573b1b25df9c5720e83c758273a08e8..88a18ed5cfae669704d05299c7f060d9558ada3a 100644 --- a/NPSimulation/Detectors/Minos/Minos.cc +++ b/NPSimulation/Detectors/Minos/Minos.cc @@ -21,134 +21,131 @@ *****************************************************************************/ // C++ headers -#include <sstream> #include <cmath> #include <limits> -//G4 Geometry object -#include "G4Tubs.hh" +#include <sstream> +// G4 Geometry object #include "G4Box.hh" #include "G4Trd.hh" +#include "G4Tubs.hh" -//G4 sensitive -#include "G4SDManager.hh" +// G4 sensitive #include "G4MultiFunctionalDetector.hh" +#include "G4SDManager.hh" -//G4 various object -#include "G4Material.hh" -#include "G4Transform3D.hh" -#include "G4PVPlacement.hh" -#include "G4VisAttributes.hh" +// G4 various object #include "G4Colour.hh" -#include "G4PVReplica.hh" +#include "G4Material.hh" #include "G4PVParameterised.hh" +#include "G4PVPlacement.hh" +#include "G4PVReplica.hh" +#include "G4Transform3D.hh" #include "G4VPVParameterisation.hh" +#include "G4VisAttributes.hh" // G4 Field -#include "G4FieldManager.hh" +#include "G4ChordFinder.hh" +#include "G4ClassicalRK4.hh" #include "G4ElectricField.hh" -#include "G4UniformElectricField.hh" -#include "G4TransportationManager.hh" #include "G4EqMagElectricField.hh" -#include "G4MagIntegratorStepper.hh" -#include "G4ClassicalRK4.hh" +#include "G4FieldManager.hh" #include "G4MagIntegratorDriver.hh" -#include "G4ChordFinder.hh" +#include "G4MagIntegratorStepper.hh" #include "G4MaterialPropertiesTable.hh" +#include "G4TransportationManager.hh" +#include "G4UniformElectricField.hh" // NPTool header -#include "Minos.hh" #include "InteractionScorers.hh" +#include "Minos.hh" /* #include "TPCScorers.hh" */ #include "CylinderTPCScorers.hh" #include "MaterialManager.hh" -#include "NPSDetectorFactory.hh" #include "NPOptionManager.h" +#include "NPSDetectorFactory.hh" #include "NPSHitsMap.hh" // CLHEP header #include "CLHEP/Random/RandGauss.h" // ROOT -#include "TH1F.h" -#include "TF1.h" #include "RootOutput.h" +#include "TF1.h" +#include "TH1F.h" using namespace std; using namespace CLHEP; - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -namespace Minos_NS{ +namespace Minos_NS { // TPC - const G4double ChamberInnerRadius = 37.*mm; - /* const G4double ChamberInnerRadius = 29*mm; */ //big TPC - //const G4double ChamberThickness = 2.*mm; - const G4double ChamberLength = 300.*mm; - const G4double KaptonThickness = 0.125*mm; - const G4double RohacellThickness = 2.*mm; - const G4double TPCRadiusExt = 91.525*mm; + const G4double ChamberInnerRadius = 37. * mm; + /* const G4double ChamberInnerRadius = 29*mm; */ // big TPC + // const G4double ChamberThickness = 2.*mm; + const G4double ChamberLength = 300. * mm; + const G4double KaptonThickness = 0.125 * mm; + const G4double RohacellThickness = 2. * mm; + const G4double TPCRadiusExt = 91.525 * mm; /* const G4double TPCRadiusExt = 150*mm; //big TPC */ // MINOS - const G4double TargetRadius = 28.*mm; - const G4double WindowThickness = 0.150*mm; + const G4double TargetRadius = 28. * mm; + const G4double WindowThickness = 0.150 * mm; -} +} // namespace Minos_NS using namespace Minos_NS; //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Minos Specific Method -Minos::Minos(){ - m_Event = new TMinosData() ; +Minos::Minos() { + m_Event = new TMinosData(); m_MinosPadScorer = 0; - m_ReactionRegion=NULL; + m_ReactionRegion = NULL; // RGB Color + Transparency - m_VisTarget= new G4VisAttributes(G4Colour(0.6,1.,1., .4)); - m_VissimpleBox= new G4VisAttributes(G4Colour(0,1,0,.6)); - m_VisTPC= new G4VisAttributes(G4Colour(1.,0.5,0.6,0.3)); - m_VisRohacell= new G4VisAttributes(G4Colour(1.,1.,1., .8)); - m_VisKapton = new G4VisAttributes(G4Colour(1.,1.,0.6,0.4)); - m_VisTargetCell = new G4VisAttributes(G4Colour(0,0,1, .4)); + m_VisTarget = new G4VisAttributes(G4Colour(0.6, 1., 1., .4)); + m_VissimpleBox = new G4VisAttributes(G4Colour(0, 1, 0, .6)); + m_VisTPC = new G4VisAttributes(G4Colour(1., 0.5, 0.6, 0.3)); + m_VisRohacell = new G4VisAttributes(G4Colour(1., 1., 1., .8)); + m_VisKapton = new G4VisAttributes(G4Colour(1., 1., 0.6, 0.4)); + m_VisTargetCell = new G4VisAttributes(G4Colour(0, 0, 1, .4)); m_VisTargetCell->SetForceSolid(true); - m_VisOuterKapton = new G4VisAttributes(G4Colour(1.,1.,0.6,0.8)); + m_VisOuterKapton = new G4VisAttributes(G4Colour(1., 1., 0.6, 0.8)); - Raw_Signal = new TH1F("raw_Signal","raw_Signal",512,0,512); - Elec_Signal = new TH1F("Elec_Signal","Elec_Signal",512,0,512); + Raw_Signal = new TH1F("raw_Signal", "raw_Signal", 512, 0, 512); + Elec_Signal = new TH1F("Elec_Signal", "Elec_Signal", 512, 0, 512); /* Raw_Signal = new TH1F;*/ /* Elec_Signal = new TH1F;*/ - - fa1 = new TF1("fa1","abs((x>[1]&&x<512)*([0]*exp(-3.*(x-[1])/[2]) * sin((x-[1])/[2]) * pow((x-[1])/[2],3))+[3])",0,1000); + fa1 = new TF1("fa1", "abs((x>[1]&&x<512)*([0]*exp(-3.*(x-[1])/[2]) * sin((x-[1])/[2]) * pow((x-[1])/[2],3))+[3])", 0, + 1000); fa1->SetNpx(512); - solidTarget=0; - logicTarget=0; - solidChamber=0; - logicChamber=0; - solidTPC=0; - logicTPC=0; - solidWindow0=0; - logicWindow0=0; - solidRohacell=0; - logicRohacell=0; - solidKapton=0; - logicKapton=0; + solidTarget = 0; + logicTarget = 0; + solidChamber = 0; + logicChamber = 0; + solidTPC = 0; + logicTPC = 0; + solidWindow0 = 0; + logicWindow0 = 0; + solidRohacell = 0; + logicRohacell = 0; + solidKapton = 0; + logicKapton = 0; } -Minos::~Minos(){ -} +Minos::~Minos() {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... - - /* void Minos::AddDetector(G4ThreeVector POS, double LengthOfTarget, int PresenceOfMinos){ */ -void Minos::AddDetector(G4ThreeVector POS,double TargetZOffset, double LengthOfTarget, G4String MaterialOfTarget,G4String MaterialOfCell, int PresenceOfMinos){ +void Minos::AddDetector(G4ThreeVector POS, double TargetZOffset, double LengthOfTarget, G4String MaterialOfTarget, + G4String MaterialOfCell, int PresenceOfMinos) { m_POS.push_back(POS); m_TargetLength.push_back(LengthOfTarget); m_TargetMaterial.push_back(MaterialOfTarget); @@ -159,7 +156,6 @@ void Minos::AddDetector(G4ThreeVector POS,double TargetZOffset, double LengthOfT //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... @@ -167,32 +163,31 @@ void Minos::AddDetector(G4ThreeVector POS,double TargetZOffset, double LengthOfT // vis/OpenInventor driver : //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -G4LogicalVolume* Minos::BuildTarget(){ - if(!logicTarget){ - // +G4LogicalVolume* Minos::BuildTarget() { + if (!logicTarget) { + // // Target - // - solidTarget = new G4Tubs("Target", //its name - 0.,TargetRadius,m_TargetLength[0]/2.,0,360.);//size - logicTarget = new G4LogicalVolume(solidTarget, //its solid - TargetMaterial, //its material - "Target"); //its name + // + solidTarget = new G4Tubs("Target", // its name + 0., TargetRadius, m_TargetLength[0] / 2., 0, 360.); // size + logicTarget = new G4LogicalVolume(solidTarget, // its solid + TargetMaterial, // its material + "Target"); // its name logicTarget->SetVisAttributes(m_VisTarget); } return logicTarget; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -G4LogicalVolume* Minos::BuildTPC(){ - if(!logicTPC){ - // +G4LogicalVolume* Minos::BuildTPC() { + if (!logicTPC) { + // // TPC // - solidTPC = new G4Tubs("TPC", - ChamberInnerRadius ,TPCRadiusExt,ChamberLength/2.,0,360.); - logicTPC = new G4LogicalVolume(solidTPC, //its solid - TPCMaterial, //its material - "TPC"); //name + solidTPC = new G4Tubs("TPC", ChamberInnerRadius, TPCRadiusExt, ChamberLength / 2., 0, 360.); + logicTPC = new G4LogicalVolume(solidTPC, // its solid + TPCMaterial, // its material + "TPC"); // name logicTPC->SetVisAttributes(m_VisTPC); } return logicTPC; @@ -205,7 +200,7 @@ G4LogicalVolume* Minos::BuildTPC(){ /* ChamberInnerRadius,ChamberInnerRadius+ChamberThickness,ChamberLength/2.,0,360.); //size */ /* logicChamber = new G4LogicalVolume(solidChamber, //its solid */ /* ChamberMaterial, //its material */ -/* "Chamber"); //its name */ +/* "Chamber"); //its name */ /* m_VissimpleBox->SetVisibility(true); */ /* logicChamber->SetVisAttributes(m_VissimpleBox); */ /* } */ @@ -213,13 +208,14 @@ G4LogicalVolume* Minos::BuildTPC(){ /* } */ //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -G4LogicalVolume* Minos::BuildInnerRohacell(){ - if(!logicRohacell){ - solidRohacell = new G4Tubs("InnerRohacell", //its name - ChamberInnerRadius ,ChamberInnerRadius + RohacellThickness ,ChamberLength/2.,0,360.); //size - logicRohacell = new G4LogicalVolume(solidRohacell, //its solid - RohacellMaterial, //its material - "InnerRohacell"); //its name +G4LogicalVolume* Minos::BuildInnerRohacell() { + if (!logicRohacell) { + solidRohacell = + new G4Tubs("InnerRohacell", // its name + ChamberInnerRadius, ChamberInnerRadius + RohacellThickness, ChamberLength / 2., 0, 360.); // size + logicRohacell = new G4LogicalVolume(solidRohacell, // its solid + RohacellMaterial, // its material + "InnerRohacell"); // its name logicRohacell->SetVisAttributes(m_VisRohacell); } return logicRohacell; @@ -227,60 +223,60 @@ G4LogicalVolume* Minos::BuildInnerRohacell(){ //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... - -G4LogicalVolume* Minos::BuildOuterRohacell(){ - if(logicRohacell){ - solidRohacell = new G4Tubs("OuterRohacell", //its name - TPCRadiusExt-RohacellThickness, TPCRadiusExt ,ChamberLength/2.,0,360.); //size - logicRohacell = new G4LogicalVolume(solidRohacell, //its solid - RohacellMaterial, //its material - "OuterRohacell"); //its name +G4LogicalVolume* Minos::BuildOuterRohacell() { + if (logicRohacell) { + solidRohacell = new G4Tubs("OuterRohacell", // its name + TPCRadiusExt - RohacellThickness, TPCRadiusExt, ChamberLength / 2., 0, 360.); // size + logicRohacell = new G4LogicalVolume(solidRohacell, // its solid + RohacellMaterial, // its material + "OuterRohacell"); // its name logicRohacell->SetVisAttributes(m_VisRohacell); } return logicRohacell; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -G4LogicalVolume* Minos::BuildKapton(){ - if(!logicKapton){ - solidKapton = new G4Tubs("Kapton", //its name - ChamberInnerRadius+RohacellThickness ,ChamberInnerRadius+RohacellThickness+KaptonThickness,ChamberLength/2.,0,360.); //size - logicKapton = new G4LogicalVolume(solidKapton, //its solid - KaptonMaterial, //its material - "Kapton"); //its name +G4LogicalVolume* Minos::BuildKapton() { + if (!logicKapton) { + solidKapton = + new G4Tubs("Kapton", // its name + ChamberInnerRadius + RohacellThickness, ChamberInnerRadius + RohacellThickness + KaptonThickness, + ChamberLength / 2., 0, 360.); // size + logicKapton = new G4LogicalVolume(solidKapton, // its solid + KaptonMaterial, // its material + "Kapton"); // its name logicKapton->SetVisAttributes(m_VisKapton); } return logicKapton; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -G4LogicalVolume* Minos::BuildOuterKapton(){ - if(logicKapton){ - solidKapton = new G4Tubs("Kapton", //its name - TPCRadiusExt-RohacellThickness-KaptonThickness, TPCRadiusExt-RohacellThickness,ChamberLength/2.,0,360.); //size - logicKapton = new G4LogicalVolume(solidKapton, //its solid - KaptonMaterial, //its material - "Kapton"); //its name +G4LogicalVolume* Minos::BuildOuterKapton() { + if (logicKapton) { + solidKapton = new G4Tubs("Kapton", // its name + TPCRadiusExt - RohacellThickness - KaptonThickness, TPCRadiusExt - RohacellThickness, + ChamberLength / 2., 0, 360.); // size + logicKapton = new G4LogicalVolume(solidKapton, // its solid + KaptonMaterial, // its material + "Kapton"); // its name logicKapton->SetVisAttributes(m_VisOuterKapton); } return logicKapton; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... - - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -// +// // windows // //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -G4LogicalVolume* Minos::BuildWindow0(){ - if(!logicWindow0){ - solidWindow0 = new G4Tubs("WindowTube", //its name - 0.,TargetRadius+WindowThickness,m_TargetLength[0]/2.+WindowThickness,0,360.); - logicWindow0 = new G4LogicalVolume(solidWindow0, //its solid - WindowMaterial, //its material - "WindowTube"); //name +G4LogicalVolume* Minos::BuildWindow0() { + if (!logicWindow0) { + solidWindow0 = new G4Tubs("WindowTube", // its name + 0., TargetRadius + WindowThickness, m_TargetLength[0] / 2. + WindowThickness, 0, 360.); + logicWindow0 = new G4LogicalVolume(solidWindow0, // its solid + WindowMaterial, // its material + "WindowTube"); // name logicWindow0->SetVisAttributes(m_VisTargetCell); } return logicWindow0; @@ -292,279 +288,274 @@ G4LogicalVolume* Minos::BuildWindow0(){ // Read stream at Configfile to pick-up parameters of detector (Position,...) // Called in DetecorConstruction::ReadDetextorConfiguration Method -void Minos::ReadConfiguration(NPL::InputParser parser){ +void Minos::ReadConfiguration(NPL::InputParser parser) { vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithToken("Minos"); - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << "//// " << blocks.size() << " detectors found " << endl; + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks.size() << " detectors found " << endl; vector<string> simu = {"TPCOnly"}; - vector<string> token= {"XML","Position","TargetZOffset","TargetMaterial","TargetLength","CellMaterial","TimeBin","ShapingTime","Baseline","Sampling","ZOffset"}; - - for(unsigned int i = 0 ; i < blocks.size() ; i++){ - if(blocks[i]->HasTokenList(token)){ - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << endl << "//// Minos " << i+1 << endl; - G4ThreeVector Pos = NPS::ConvertVector(blocks[i]->GetTVector3("Position","mm")); - double TargetLength = blocks[i]->GetDouble("TargetLength","mm"); - double TargetZOffset= blocks[i]->GetDouble("TargetZOffset","mm"); + vector<string> token = {"XML", "Position", "TargetZOffset", "TargetMaterial", "TargetLength", "CellMaterial", + "TimeBin", "ShapingTime", "Baseline", "Sampling", "ZOffset"}; + + for (unsigned int i = 0; i < blocks.size(); i++) { + if (blocks[i]->HasTokenList(token)) { + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// Minos " << i + 1 << endl; + G4ThreeVector Pos = NPS::ConvertVector(blocks[i]->GetTVector3("Position", "mm")); + double TargetLength = blocks[i]->GetDouble("TargetLength", "mm"); + double TargetZOffset = blocks[i]->GetDouble("TargetZOffset", "mm"); G4String TargetMaterialname = blocks[i]->GetString("TargetMaterial"); G4String CellMaterial = blocks[i]->GetString("CellMaterial"); - m_ShapingTime = blocks[i]->GetDouble("ShapingTime","ns")/ns; - m_TimeBin = blocks[i]->GetDouble("TimeBin","ns")/ns; - m_Sampling= blocks[i]->GetInt("Sampling"); - m_Baseline= blocks[i]->GetInt("BaseLine"); - m_ZOffset = blocks[i]->GetDouble("ZOffset","mm"); + m_ShapingTime = blocks[i]->GetDouble("ShapingTime", "ns") / ns; + m_TimeBin = blocks[i]->GetDouble("TimeBin", "ns") / ns; + m_Sampling = blocks[i]->GetInt("Sampling"); + m_Baseline = blocks[i]->GetInt("BaseLine"); + m_ZOffset = blocks[i]->GetDouble("ZOffset", "mm"); string xmlpath = blocks[i]->GetString("XML"); NPL::XmlParser xml; xml.LoadFile(xmlpath); ReadXML(xml); - TPCOnly=1; - if(blocks[i]->HasTokenList(simu)) + TPCOnly = 1; + if (blocks[i]->HasTokenList(simu)) TPCOnly = blocks[i]->GetInt("TPCOnly"); - AddDetector(Pos,TargetZOffset,TargetLength,TargetMaterialname, CellMaterial, TPCOnly); - + AddDetector(Pos, TargetZOffset, TargetLength, TargetMaterialname, CellMaterial, TPCOnly); } - else{ + else { cout << "ERROR: check your input file formatting " << endl; exit(1); } } } - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Construct detector and inialise sensitive part. // Called After DetecorConstruction::AddDetector Method -void Minos::ConstructDetector(G4LogicalVolume* world){ - for (unsigned short i = 0 ; i < m_POS.size() ; i++) { +void Minos::ConstructDetector(G4LogicalVolume* world) { + for (unsigned short i = 0; i < m_POS.size(); i++) { bool TPCOnly = m_TPCOnly[i]; - /* TargetMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); */ - TargetMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary("LH2"); + /* TargetMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); */ + TargetMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary("LH2"); WindowMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary("Mylar"); - ChamberMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary("Al"); + ChamberMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary("Al"); KaptonMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary("Kapton"); RohacellMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary("Rohacell"); TPCMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary("mixMINOS"); - /* TargetMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); */ + /* TargetMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); */ /* WindowMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); */ - /* ChamberMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); */ + /* ChamberMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); */ /* KaptonMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); */ /* RohacellMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); */ /* TPCMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary("mixMINOS"); */ ///////// Drift properties - G4MaterialPropertiesTable* MPT = new G4MaterialPropertiesTable(); - MPT->AddConstProperty("DE_PAIRENERGY",30*eV); - MPT->AddConstProperty("DE_ABSLENGTH",10*pc); - MPT->AddConstProperty("DE_DRIFTSPEED",3.475*cm/microsecond); - MPT->AddConstProperty("DE_TRANSVERSALSPREAD",7e-5*mm2/ns); - MPT->AddConstProperty("DE_LONGITUDINALSPREAD",7e-5*mm2/ns); + G4MaterialPropertiesTable* MPT = new G4MaterialPropertiesTable(); + MPT->AddConstProperty("DE_PAIRENERGY", 30 * eV); + MPT->AddConstProperty("DE_ABSLENGTH", 10 * pc); + MPT->AddConstProperty("DE_DRIFTSPEED", 3.475 * cm / microsecond); + MPT->AddConstProperty("DE_TRANSVERSALSPREAD", 7e-5 * mm2 / ns); + MPT->AddConstProperty("DE_LONGITUDINALSPREAD", 7e-5 * mm2 / ns); /* MPT->AddConstProperty("DE_TRANSVERSALSPREAD",0*mm2/ns); */ /* MPT->AddConstProperty("DE_LONGITUDINALSPREAD",0*mm2/ns); */ TPCMaterial->SetMaterialPropertiesTable(MPT); - G4ThreeVector Det_pos = m_POS[i] ; + G4ThreeVector Det_pos = m_POS[i]; - double MinosX = Det_pos.x(); - double MinosY= Det_pos.y(); - double MinosZ = Det_pos.z() + m_TargetLength[i]/2. ; + double MinosX = Det_pos.x(); + double MinosY = Det_pos.y(); + double MinosZ = Det_pos.z() + m_TargetLength[i] / 2.; - new G4PVPlacement(0,//its name - G4ThreeVector(0,0,+ChamberLength/2 ), - /* G4ThreeVector(wX,wY, wZ + ChamberLength - m_TargetLength[i]-WindowThickness*2. - 5*mm ), // Z positioning putting TPC beginn and Target beginning w/ difference of 5mm */ - BuildTPC(), //its logical volume - "TPC", //its name - world, //its mother volume - false, //no boolean operation - 0); //copy number + new G4PVPlacement(0, // its name + G4ThreeVector(0, 0, +ChamberLength / 2), + /* G4ThreeVector(wX,wY, wZ + ChamberLength - m_TargetLength[i]-WindowThickness*2. - 5*mm ), // Z + positioning putting TPC beginn and Target beginning w/ difference of 5mm */ + BuildTPC(), // its logical volume + "TPC", // its name + world, // its mother volume + false, // no boolean operation + 0); // copy number //////// ELECTRIC FIELD - G4ElectricField* field = new G4UniformElectricField(G4ThreeVector(0.0,0.0,200*volt/cm)); + G4ElectricField* field = new G4UniformElectricField(G4ThreeVector(0.0, 0.0, 200 * volt / cm)); // Create an equation of motion for this field - G4EqMagElectricField* Equation = new G4EqMagElectricField(field); - G4MagIntegratorStepper* Stepper = new G4ClassicalRK4( Equation, 8 ); - // Get the global field manager - G4FieldManager* FieldManager= new G4FieldManager(); - // Set this field to the global field manager - FieldManager->SetDetectorField(field ); - BuildTPC()->SetFieldManager(FieldManager,true); - - G4MagInt_Driver* IntgrDriver = new G4MagInt_Driver(0.1*mm, - Stepper, - Stepper->GetNumberOfVariables() ); + G4EqMagElectricField* Equation = new G4EqMagElectricField(field); + G4MagIntegratorStepper* Stepper = new G4ClassicalRK4(Equation, 8); + // Get the global field manager + G4FieldManager* FieldManager = new G4FieldManager(); + // Set this field to the global field manager + FieldManager->SetDetectorField(field); + BuildTPC()->SetFieldManager(FieldManager, true); + + G4MagInt_Driver* IntgrDriver = new G4MagInt_Driver(0.1 * mm, Stepper, Stepper->GetNumberOfVariables()); G4ChordFinder* ChordFinder = new G4ChordFinder(IntgrDriver); - FieldManager->SetChordFinder( ChordFinder ); + FieldManager->SetChordFinder(ChordFinder); - G4Material* Cu - = MaterialManager::getInstance()->GetMaterialFromLibrary("Cu"); + G4Material* Cu = MaterialManager::getInstance()->GetMaterialFromLibrary("Cu"); - ///////// CONSTRUCT PADS using parametrized volumes or replica (uncomment the correct section) + ///////// CONSTRUCT PADS using parametrized volumes or replica (uncomment the correct section) //// Using REPLICA // Construct Pads ring by ring - for (int RingNbr = 0; RingNbr < 18; RingNbr++){ + for (int RingNbr = 0; RingNbr < 18; RingNbr++) { - int PadsPerRing[18]={144,152,156,164,172,176,184,192,196,204,212,216,224,228,236,244,248,256}; + int PadsPerRing[18] = {144, 152, 156, 164, 172, 176, 184, 192, 196, 204, 212, 216, 224, 228, 236, 244, 248, 256}; /* G4double InnerRadius = (45.2+RingNbr*2.1+0.02)*mm;// 0.02 mm between each ring */ - G4double InnerRadius = (45.75+RingNbr*2.1)*mm; - G4double OuterRadius = (47.75+RingNbr*2.1)*mm; - - //Volume where are placed replica pads - G4VSolid* AnodeRing = new G4Tubs("ring",InnerRadius,OuterRadius, - 0.01*mm,0.,360*deg); - G4LogicalVolume * AnodeRing_log = new G4LogicalVolume(AnodeRing, - /* mix, "ringL", 0, 0, 0); */ - TPCMaterial, "ringL", 0, 0, 0); - - {G4VisAttributes* atb= new G4VisAttributes(G4Colour(0.8, 0.4, 0.,0.4)); - AnodeRing_log->SetVisAttributes(atb);} + G4double InnerRadius = (45.75 + RingNbr * 2.1) * mm; + G4double OuterRadius = (47.75 + RingNbr * 2.1) * mm; + + // Volume where are placed replica pads + G4VSolid* AnodeRing = new G4Tubs("ring", InnerRadius, OuterRadius, 0.01 * mm, 0., 360 * deg); + G4LogicalVolume* AnodeRing_log = new G4LogicalVolume(AnodeRing, + /* mix, "ringL", 0, 0, 0); */ + TPCMaterial, "ringL", 0, 0, 0); + + { + G4VisAttributes* atb = new G4VisAttributes(G4Colour(0.8, 0.4, 0., 0.4)); + AnodeRing_log->SetVisAttributes(atb); + } - new G4PVPlacement(0,G4ThreeVector(0,0,-ChamberLength/2+0.01*mm), - AnodeRing_log,"ring", logicTPC, false, RingNbr); + new G4PVPlacement(0, G4ThreeVector(0, 0, -ChamberLength / 2 + 0.01 * mm), AnodeRing_log, "ring", logicTPC, false, + RingNbr); - G4double Pad_dPhi = (360./(PadsPerRing[RingNbr]+1))*deg; // longitudinal component of Pad - G4double Pad_shift = (360./PadsPerRing[RingNbr])*deg; // dPhi between each Pads + G4double Pad_dPhi = (360. / (PadsPerRing[RingNbr] + 1)) * deg; // longitudinal component of Pad + G4double Pad_shift = (360. / PadsPerRing[RingNbr]) * deg; // dPhi between each Pads - G4VSolid* Pad = new G4Tubs("div_ring", InnerRadius, OuterRadius, - 0.01*mm,0, Pad_dPhi); + G4VSolid* Pad = new G4Tubs("div_ring", InnerRadius, OuterRadius, 0.01 * mm, 0, Pad_dPhi); - G4LogicalVolume* Pad_log = new G4LogicalVolume(Pad, - Cu,"div_ringL",0,0,0); + G4LogicalVolume* Pad_log = new G4LogicalVolume(Pad, Cu, "div_ringL", 0, 0, 0); - {G4VisAttributes* atb= new G4VisAttributes(G4Colour(0.8, 0.4, 0.,0.4)); - Pad_log->SetVisAttributes(atb);} + { + G4VisAttributes* atb = new G4VisAttributes(G4Colour(0.8, 0.4, 0., 0.4)); + Pad_log->SetVisAttributes(atb); + } Pad_log->SetSensitiveDetector(m_MinosPadScorer); - new G4PVReplica("div_ring_phys", Pad_log, - AnodeRing_log, kPhi, PadsPerRing[RingNbr],Pad_shift ,0); + new G4PVReplica("div_ring_phys", Pad_log, AnodeRing_log, kPhi, PadsPerRing[RingNbr], Pad_shift, 0); } ////////////////////////////////////// - new G4PVPlacement(0, //its name - G4ThreeVector(0,0,0), //at (0,0,0) - BuildInnerRohacell(), //its logical volume - "InnerRohacell", //its name - logicTPC, //its mother volume - false, //no boolean operation - 0); //copy number - - new G4PVPlacement(0, //its name - G4ThreeVector(0,0,0), //at (0,0,0) - BuildOuterRohacell(), //its logical volume - "OuterRohacell", //its name - logicTPC, //its mother volume - /* logicTPC, //its mother volume */ - false, //no boolean operation - 0); //copy number - - new G4PVPlacement(0, G4ThreeVector(0,0,0), //at (0,0,0) - BuildKapton(), //its logical volume - "InnerKapton", //its name - logicTPC, //its mother volume - false, //no boolean operation - 0); //copy number - - new G4PVPlacement(0, //its name - G4ThreeVector(0,0,0), //at (0,0,0) - BuildOuterKapton(), //its logical volume - "OuterKapton", //its name - logicTPC, //its mother volume - false, //no boolean operation - 0); //copy number - - if(TPCOnly!=1){ - new G4PVPlacement(0, //its name - G4ThreeVector(MinosX,MinosY,MinosZ+m_TargetZOffset[0]), //at (0,0,TargetZOffset) - BuildWindow0(), //its logical volume - "WindowTube", //its name - world, //its mother volume - false, //no boolean operation - 0); - - new G4PVPlacement(0,//no rotation - G4ThreeVector(0,0,0), //at (0,0,0) - BuildTarget(), //its logical volume - "Target", //its name - logicWindow0, //its mother volume - false, //no boolean operation - 0); //copy number - - if(!m_ReactionRegion){ - m_ReactionRegion= new G4Region("NPSimulationProcess"); - m_ReactionRegion -> AddRootLogicalVolume(logicTarget); - m_ReactionRegion->SetUserLimits(new G4UserLimits(1.2*mm)); //??? + new G4PVPlacement(0, // its name + G4ThreeVector(0, 0, 0), // at (0,0,0) + BuildInnerRohacell(), // its logical volume + "InnerRohacell", // its name + logicTPC, // its mother volume + false, // no boolean operation + 0); // copy number + + new G4PVPlacement(0, // its name + G4ThreeVector(0, 0, 0), // at (0,0,0) + BuildOuterRohacell(), // its logical volume + "OuterRohacell", // its name + logicTPC, // its mother volume + /* logicTPC, //its mother volume */ + false, // no boolean operation + 0); // copy number + + new G4PVPlacement(0, G4ThreeVector(0, 0, 0), // at (0,0,0) + BuildKapton(), // its logical volume + "InnerKapton", // its name + logicTPC, // its mother volume + false, // no boolean operation + 0); // copy number + + new G4PVPlacement(0, // its name + G4ThreeVector(0, 0, 0), // at (0,0,0) + BuildOuterKapton(), // its logical volume + "OuterKapton", // its name + logicTPC, // its mother volume + false, // no boolean operation + 0); // copy number + + if (TPCOnly != 1) { + new G4PVPlacement(0, // its name + G4ThreeVector(MinosX, MinosY, MinosZ + m_TargetZOffset[0]), // at (0,0,TargetZOffset) + BuildWindow0(), // its logical volume + "WindowTube", // its name + world, // its mother volume + false, // no boolean operation + 0); + + new G4PVPlacement(0, // no rotation + G4ThreeVector(0, 0, 0), // at (0,0,0) + BuildTarget(), // its logical volume + "Target", // its name + logicWindow0, // its mother volume + false, // no boolean operation + 0); // copy number + + if (!m_ReactionRegion) { + m_ReactionRegion = new G4Region("NPSimulationProcess"); + m_ReactionRegion->AddRootLogicalVolume(logicTarget); + m_ReactionRegion->SetUserLimits(new G4UserLimits(1.2 * mm)); //??? } G4FastSimulationManager* mng = m_ReactionRegion->GetFastSimulationManager(); unsigned int size = m_ReactionModel.size(); - for(unsigned int o = 0 ; o < size ; o++){ + for (unsigned int o = 0; o < size; o++) { mng->RemoveFastSimulationModel(m_ReactionModel[o]); } m_ReactionModel.clear(); G4VFastSimulationModel* fsm; - fsm = new NPS::BeamReaction("BeamReaction",m_ReactionRegion); - ((NPS::BeamReaction*) fsm)->SetStepSize(1.2*mm); + fsm = new NPS::BeamReaction("BeamReaction", m_ReactionRegion); + ((NPS::BeamReaction*)fsm)->SetStepSize(1.2 * mm); m_ReactionModel.push_back(fsm); - fsm = new NPS::Decay("Decay",m_ReactionRegion); + fsm = new NPS::Decay("Decay", m_ReactionRegion); m_ReactionModel.push_back(fsm); } } // Visualization attributes - world->SetVisAttributes (G4VisAttributes::Invisible); - + world->SetVisAttributes(G4VisAttributes::GetInvisible()); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Add Detector branch to the EventTree. // Called After DetecorConstruction::AddDetector Method -void Minos::InitializeRootOutput(){ - RootOutput *pAnalysis = RootOutput::getInstance(); - TTree *pTree = pAnalysis->GetTree(); - if(!pTree->FindBranch("Minos")){ - pTree->Branch("Minos", "TMinosData", &m_Event) ; +void Minos::InitializeRootOutput() { + RootOutput* pAnalysis = RootOutput::getInstance(); + TTree* pTree = pAnalysis->GetTree(); + if (!pTree->FindBranch("Minos")) { + pTree->Branch("Minos", "TMinosData", &m_Event); } - pTree->SetBranchAddress("Minos", &m_Event) ; + pTree->SetBranchAddress("Minos", &m_Event); } //....oooOO0OOooo.; // Read sensitive part and fill the Root tree. // Called at in the EventAction::EndOfEventAction -void Minos::ReadSensitive(const G4Event* ){ +void Minos::ReadSensitive(const G4Event*) { m_Event->Clear(); /////////// // DriftElectron scorer - CylinderTPCScorers::PS_TPCAnode* Scorer2= (CylinderTPCScorers::PS_TPCAnode*) m_MinosPadScorer->GetPrimitive(0); + CylinderTPCScorers::PS_TPCAnode* Scorer2 = (CylinderTPCScorers::PS_TPCAnode*)m_MinosPadScorer->GetPrimitive(0); unsigned int size2 = Scorer2->GetMult(); - for(unsigned int i = 0 ; i < size2 ; i++){ - int Pad = FindPadID(Scorer2->GetPad(i),Scorer2->GetX(i),Scorer2->GetY(i)); - SimulateGainAndDigitizer(Scorer2->GetT(i), Scorer2->GetQ(i),T,Q); + for (unsigned int i = 0; i < size2; i++) { + int Pad = FindPadID(Scorer2->GetPad(i), Scorer2->GetX(i), Scorer2->GetY(i)); + SimulateGainAndDigitizer(Scorer2->GetT(i), Scorer2->GetQ(i), T, Q); - m_Event->SetPad(Pad, Scorer2->GetQ(i)->size(),&T,&Q); + m_Event->SetPad(Pad, Scorer2->GetQ(i)->size(), &T, &Q); } - } -void Minos::SimulateGainAndDigitizer(vector<double>* rawT, vector<double>* rawQ,vector<int>& T, vector<int>& Q){ +void Minos::SimulateGainAndDigitizer(vector<double>* rawT, vector<double>* rawQ, vector<int>& T, vector<int>& Q) { T.clear(); Q.clear(); Raw_Signal->Reset(); Elec_Signal->Reset(); - // Add white noise; + // Add white noise; /* for( int bin = 0 ; bin < Elec_Signal->GetNbinsX() ; bin++) */ - /* Elec_Signal->SetBinContent(bin,20+(10-gRandom->Uniform(20)*20)); */ + /* Elec_Signal->SetBinContent(bin,20+(10-gRandom->Uniform(20)*20)); */ // Reallocate electrons from each pack /* if (rawQ.sze()==1) { */ @@ -574,106 +565,108 @@ void Minos::SimulateGainAndDigitizer(vector<double>* rawT, vector<double>* rawQ, /* } */ /* else{ */ /* for ( int j = 1; j < rawQ.size()-1; j++){ */ - /* time = (rawT[j+1]-rawT[j-1])/rawQ[j]; */ + /* time = (rawT[j+1]-rawT[j-1])/rawQ[j]; */ /* for ( int k = -rawQ[0]/2; k < (rawQ[0]/2); k++){ */ /* Raw_Signal->Fill((rawT[j]+k*time)/30.); */ /* } */ /* } */ /* } */ - for ( unsigned int j = 0; j < rawQ->size(); j++){ - for ( int i = 0 ; i < (*rawQ)[j]; i++ ){ - Raw_Signal->Fill(((*rawT)[j])/m_TimeBin); + for (unsigned int j = 0; j < rawQ->size(); j++) { + for (int i = 0; i < (*rawQ)[j]; i++) { + Raw_Signal->Fill(((*rawT)[j]) / m_TimeBin); } } // Application of the electronic reponse function - for ( int x=0; x < Raw_Signal->GetNbinsX(); x++){ - if(Raw_Signal->GetBinContent(x) > 0.5){ + for (int x = 0; x < Raw_Signal->GetNbinsX(); x++) { + if (Raw_Signal->GetBinContent(x) > 0.5) { start = Raw_Signal->GetBinCenter(x); - end = Raw_Signal->GetBinCenter(x)+512; + end = Raw_Signal->GetBinCenter(x) + 512; // DriftTime = Raw_Signal->GetBinCenter(x); fa1->SetRange(start, end); - fa1->SetParameter(0,1500); - fa1->SetParameter(1,start); - fa1->SetParameter(2,m_ShapingTime/(log(2)*m_TimeBin)); - fa1->SetParameter(3,0); - - for (int p=0; p < Raw_Signal->GetBinContent(x)*1500; p++) - Elec_Signal->Fill(fa1->GetRandom(start,end)); - } + fa1->SetParameter(0, 1500); + fa1->SetParameter(1, start); + fa1->SetParameter(2, m_ShapingTime / (log(2) * m_TimeBin)); + fa1->SetParameter(3, 0); + + for (int p = 0; p < Raw_Signal->GetBinContent(x) * 1500; p++) + Elec_Signal->Fill(fa1->GetRandom(start, end)); + } } - for ( int bin=0; bin < Elec_Signal->GetNbinsX(); bin++){ - if(Elec_Signal->GetBinContent(bin)){ - Q.push_back(Elec_Signal->GetBinContent(bin)+m_Baseline); - T.push_back(Elec_Signal->GetBinCenter(bin)); - } - } + for (int bin = 0; bin < Elec_Signal->GetNbinsX(); bin++) { + if (Elec_Signal->GetBinContent(bin)) { + Q.push_back(Elec_Signal->GetBinContent(bin) + m_Baseline); + T.push_back(Elec_Signal->GetBinCenter(bin)); + } + } } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -//////////////////////////////////////////////////////////////// -void Minos::InitializeScorers() { +//////////////////////////////////////////////////////////////// +void Minos::InitializeScorers() { // This check is necessary in case the geometry is reloaded bool already_exist = false; bool already_exist2 = false; bool already_exist3 = false; - m_MinosPadScorer = CheckScorer("MinosPadScorer",already_exist3) ; + m_MinosPadScorer = CheckScorer("MinosPadScorer", already_exist3); - if(already_exist && already_exist2 && already_exist3 ) - return ; + if (already_exist && already_exist2 && already_exist3) + return; // Otherwise the scorer is initialised - vector<int> level; level.push_back(0); + vector<int> level; + level.push_back(0); - G4VPrimitiveScorer* DriftElectronMinosTPCScorer= new CylinderTPCScorers::PS_TPCAnode("DriftElectronsScore",level, 0) ; + G4VPrimitiveScorer* DriftElectronMinosTPCScorer = + new CylinderTPCScorers::PS_TPCAnode("DriftElectronsScore", level, 0); - //and register it to the multifunctionnal detector + // and register it to the multifunctionnal detector m_MinosPadScorer->RegisterPrimitive(DriftElectronMinosTPCScorer); - G4VPrimitiveScorer* PadScorer= new CylinderTPCScorers::PS_TPCAnode("MinosTPCAnode",level, 0); + G4VPrimitiveScorer* PadScorer = new CylinderTPCScorers::PS_TPCAnode("MinosTPCAnode", level, 0); m_MinosPadScorer->RegisterPrimitive(PadScorer); - G4SDManager::GetSDMpointer()->AddNewDetector(m_MinosPadScorer) ; + G4SDManager::GetSDMpointer()->AddNewDetector(m_MinosPadScorer); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Minos::ReadXML(NPL::XmlParser& xml){ - std::vector<NPL::XML::block*> b = xml.GetAllBlocksWithName("MINOS"); +void Minos::ReadXML(NPL::XmlParser& xml) { + std::vector<NPL::XML::block*> b = xml.GetAllBlocksWithName("MINOS"); unsigned int size = b.size(); - for(unsigned int i = 0 ; i < size ; i++){ - unsigned short ID = b[i]->AsInt("ID"); - m_XY[ID] = std::make_pair(b[i]->AsDouble("X"),b[i]->AsDouble("Y")); + for (unsigned int i = 0; i < size; i++) { + unsigned short ID = b[i]->AsInt("ID"); + m_XY[ID] = std::make_pair(b[i]->AsDouble("X"), b[i]->AsDouble("Y")); } } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -unsigned int Minos::FindPadID(unsigned int G4ID, double X,double Y){ - // if no XML is provided, do nothing - if(m_XY.size()==0) - return G4ID; - // The pad is already identified - if(m_ID.find(G4ID)!=m_ID.end()) - return m_ID[G4ID]; - - // look for the closest pad - else{ - double d = 1e6; - double id=0; - for(auto it = m_XY.begin();it!=m_XY.end();it++){ - double dd = sqrt((it->second.first-X)*(it->second.first-X)+(it->second.second-Y)*(it->second.second-Y)); - if(dd<d){ - d=dd; - id=it->first; - } - } - //cout << G4ID << " " << id << endl; - m_ID[G4ID]=id; - return id; - } - +unsigned int Minos::FindPadID(unsigned int G4ID, double X, double Y) { + // if no XML is provided, do nothing + if (m_XY.size() == 0) + return G4ID; + // The pad is already identified + if (m_ID.find(G4ID) != m_ID.end()) + return m_ID[G4ID]; + + // look for the closest pad + else { + double d = 1e6; + double id = 0; + for (auto it = m_XY.begin(); it != m_XY.end(); it++) { + double dd = + sqrt((it->second.first - X) * (it->second.first - X) + (it->second.second - Y) * (it->second.second - Y)); + if (dd < d) { + d = dd; + id = it->first; + } + } + // cout << G4ID << " " << id << endl; + m_ID[G4ID] = id; + return id; + } } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... @@ -682,22 +675,20 @@ unsigned int Minos::FindPadID(unsigned int G4ID, double X,double Y){ //////////////////////////////////////////////////////////////////////////////// // Construct Method to be pass to the DetectorFactory // //////////////////////////////////////////////////////////////////////////////// -NPS::VDetector* Minos::Construct(){ - return (NPS::VDetector*) new Minos(); -} +NPS::VDetector* Minos::Construct() { return (NPS::VDetector*)new Minos(); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //////////////////////////////////////////////////////////////////////////////// // Registering the construct method to the factory // //////////////////////////////////////////////////////////////////////////////// -extern"C" { - class proxy_nps_Minos{ - public: - proxy_nps_Minos(){ - NPS::DetectorFactory::getInstance()->AddToken("Minos","Minos"); - NPS::DetectorFactory::getInstance()->AddDetector("Minos",Minos::Construct); - } - }; +extern "C" { +class proxy_nps_Minos { + public: + proxy_nps_Minos() { + NPS::DetectorFactory::getInstance()->AddToken("Minos", "Minos"); + NPS::DetectorFactory::getInstance()->AddDetector("Minos", Minos::Construct); + } +}; - proxy_nps_Minos p_nps_Minos; +proxy_nps_Minos p_nps_Minos; } diff --git a/NPSimulation/Detectors/Mugast/Mugast.cc b/NPSimulation/Detectors/Mugast/Mugast.cc index 6efd81e8ba5b9b6a76eb3041e2a35b917f036412..5ed8c94e2224496829582db95711fe399f9bc142 100644 --- a/NPSimulation/Detectors/Mugast/Mugast.cc +++ b/NPSimulation/Detectors/Mugast/Mugast.cc @@ -20,38 +20,38 @@ *****************************************************************************/ // C++ headers -#include <sstream> #include <cmath> #include <limits> -//G4 Geometry object -#include "G4Tubs.hh" +#include <sstream> +// G4 Geometry object #include "G4Box.hh" #include "G4Trap.hh" +#include "G4Tubs.hh" -//G4 sensitive -#include "G4SDManager.hh" +// G4 sensitive #include "G4MultiFunctionalDetector.hh" +#include "G4SDManager.hh" -//G4 various object -#include "G4Material.hh" -#include "G4Transform3D.hh" -#include "G4PVPlacement.hh" -#include "G4VisAttributes.hh" +// G4 various object #include "G4Colour.hh" -#include "G4TwoVector.hh" #include "G4ExtrudedSolid.hh" +#include "G4Material.hh" +#include "G4PVPlacement.hh" #include "G4SubtractionSolid.hh" +#include "G4Transform3D.hh" +#include "G4TwoVector.hh" +#include "G4VisAttributes.hh" // NPTool header -#include "Mugast.hh" -#include "MugastReverseMap.h" #include "DSSDScorers.hh" #include "InteractionScorers.hh" -#include "RootOutput.h" #include "MaterialManager.hh" -#include "NPSDetectorFactory.hh" +#include "Mugast.hh" +#include "MugastReverseMap.h" +#include "NPCore.h" #include "NPOptionManager.h" +#include "NPSDetectorFactory.hh" #include "NPSHitsMap.hh" -#include "NPCore.h" +#include "RootOutput.h" // CLHEP header #include "CLHEP/Random/RandGauss.h" @@ -59,182 +59,164 @@ using namespace std; using namespace CLHEP; - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -namespace Mugast_NS{ +namespace Mugast_NS { // Resolution - const G4double SigmaTime = 0.212765957 ;// = 500ps - const G4double SigmaEnergy = 0.019 ;// -// const G4double TimeOffset = 500 ;// 500 ns stop + const G4double SigmaTime = 0.212765957; // = 500ps + const G4double SigmaEnergy = 0.019; // + // const G4double TimeOffset = 500 ;// 500 ns stop // Threshold const G4double EnergyThreshold = 1 * MeV; // Geometry - //const G4double AluStripThickness = 0.4*micrometer ; - const G4double SiliconThickness = 300*micrometer ; + // const G4double AluStripThickness = 0.4*micrometer ; + const G4double SiliconThickness = 300 * micrometer; // Square // const G4double SquareBase = 88*mm; // const G4double SquareHeight = 87*mm; - const G4double SquareBase = 91.716*mm; - const G4double SquareHeight = 94.916*mm; + const G4double SquareBase = 91.716 * mm; + const G4double SquareHeight = 94.916 * mm; // const G4double SquareHeight = 194.916*mm; - const G4double SquareLength = 1*cm; - // Trapezoid - const G4double TrapezoidBaseLarge = 91.48*mm; - const G4double TrapezoidBaseSmall = 26*mm; - const G4double TrapezoidHeight = 104.688*mm; - const G4double TrapezoidLength = 1*cm; - //Annular - const G4int NbrRingStrips = 16; - const G4int NbrSectorStrips = 16; - const G4int NbQuadrant = 4; - const G4double WaferOutterRadius = 50*mm; - const G4double WaferInnerRadius = 23*mm; - const G4double WaferThickness = 500*micrometer; - const G4double WaferRCut = 45.5*mm; - const G4double ActiveWaferOutterRadius = 48*mm; - const G4double ActiveWaferInnerRadius = 24*mm; - const G4double ActiveWaferRCut = 44.5*mm; - const G4double PCBPointsX[8]={-40,40,60,60,40,-40,-60,-60}; - const G4double PCBPointsY[8]={60,60,40,-40,-60,-60,-40,40}; - const G4double PCBThickness=3.2*mm; - //const G4double PCBInnerRadius=0*mm; - - - -} + const G4double SquareLength = 1 * cm; + // Trapezoid + const G4double TrapezoidBaseLarge = 91.48 * mm; + const G4double TrapezoidBaseSmall = 26 * mm; + const G4double TrapezoidHeight = 104.688 * mm; + const G4double TrapezoidLength = 1 * cm; + // Annular + const G4int NbrRingStrips = 16; + const G4int NbrSectorStrips = 16; + const G4int NbQuadrant = 4; + const G4double WaferOutterRadius = 50 * mm; + const G4double WaferInnerRadius = 23 * mm; + const G4double WaferThickness = 500 * micrometer; + const G4double WaferRCut = 45.5 * mm; + const G4double ActiveWaferOutterRadius = 48 * mm; + const G4double ActiveWaferInnerRadius = 24 * mm; + const G4double ActiveWaferRCut = 44.5 * mm; + const G4double PCBPointsX[8] = {-40, 40, 60, 60, 40, -40, -60, -60}; + const G4double PCBPointsY[8] = {60, 60, 40, -40, -60, -60, -40, 40}; + const G4double PCBThickness = 3.2 * mm; + // const G4double PCBInnerRadius=0*mm; + +} // namespace Mugast_NS using namespace Mugast_NS; //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Mugast Specific Method -Mugast::Mugast(){ - m_Event = new TMugastData() ; - m_SquareScorer= 0; - m_TrapezoidScorer= 0; - m_AnnularScorer= 0; +Mugast::Mugast() { + m_Event = new TMugastData(); + m_SquareScorer = 0; + m_TrapezoidScorer = 0; + m_AnnularScorer = 0; m_SquareDetector = 0; m_TrapezoidDetector = 0; m_AnnularDetector = 0; // RGB Color + Transparency - m_VisSquare = new G4VisAttributes(G4Colour(0, 1, 0, 0.5)); - m_VisCylinder = new G4VisAttributes(G4Colour(0, 0, 1, 0.5)); - + m_VisSquare = new G4VisAttributes(G4Colour(0, 1, 0, 0.5)); + m_VisCylinder = new G4VisAttributes(G4Colour(0, 0, 1, 0.5)); } -Mugast::~Mugast(){ -} +Mugast::~Mugast() {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Mugast::AddDetector(int DetectorNumber,string Shape,G4ThreeVector PX1_Y1 ,G4ThreeVector PX1_Y128 ,G4ThreeVector PX128_Y1,G4ThreeVector PX128_Y128){ - m_X1_Y1.push_back(PX1_Y1); // Top Left Corner Position Vector - m_X1_Y128.push_back(PX1_Y128); // Bottom Left Corner Position Vector - m_X128_Y1.push_back(PX128_Y1); // Bottom Right Corner Position Vector +void Mugast::AddDetector(int DetectorNumber, string Shape, G4ThreeVector PX1_Y1, G4ThreeVector PX1_Y128, + G4ThreeVector PX128_Y1, G4ThreeVector PX128_Y128) { + m_X1_Y1.push_back(PX1_Y1); // Top Left Corner Position Vector + m_X1_Y128.push_back(PX1_Y128); // Bottom Left Corner Position Vector + m_X128_Y1.push_back(PX128_Y1); // Bottom Right Corner Position Vector m_X128_Y128.push_back(PX128_Y128); // Center Corner Position Vector m_DetectorNumber.push_back(DetectorNumber); m_Shape.push_back(Shape); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -G4LogicalVolume* Mugast::BuildSquareDetector(){ - if(!m_SquareDetector){ +G4LogicalVolume* Mugast::BuildSquareDetector() { + if (!m_SquareDetector) { G4String Name = "MugastSquare"; - G4Box* solidSquare = new G4Box(Name, 0.5*SquareBase, 0.5*SquareHeight, 0.5*SquareLength); - G4LogicalVolume* logicSquare = new G4LogicalVolume(solidSquare, - MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"), - Name, 0, 0, 0); + G4Box* solidSquare = new G4Box(Name, 0.5 * SquareBase, 0.5 * SquareHeight, 0.5 * SquareLength); + G4LogicalVolume* logicSquare = new G4LogicalVolume( + solidSquare, MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"), Name, 0, 0, 0); - G4VisAttributes* SquareVisAtt = new G4VisAttributes(G4Colour(0.90, 0.90, 0.90)); - SquareVisAtt->SetForceWireframe(true); + G4VisAttributes* SquareVisAtt = new G4VisAttributes(G4Colour(0.90, 0.90, 0.90)); + SquareVisAtt->SetForceWireframe(true); logicSquare->SetVisAttributes(SquareVisAtt); // Silicon detector itself - G4ThreeVector positionFirstStage = G4ThreeVector(0, 0, 0); + G4ThreeVector positionFirstStage = G4ThreeVector(0, 0, 0); - G4Box* solidFirstStage = new G4Box("solidFirstStage", 0.5*SquareBase, 0.5*SquareHeight, 0.5*SiliconThickness); - G4LogicalVolume* logicFirstStage = new G4LogicalVolume(solidFirstStage, - MaterialManager::getInstance()->GetMaterialFromLibrary("Si"), - "logicFirstStage", - 0, 0, 0); + G4Box* solidFirstStage = new G4Box("solidFirstStage", 0.5 * SquareBase, 0.5 * SquareHeight, 0.5 * SiliconThickness); + G4LogicalVolume* logicFirstStage = new G4LogicalVolume( + solidFirstStage, MaterialManager::getInstance()->GetMaterialFromLibrary("Si"), "logicFirstStage", 0, 0, 0); new G4PVPlacement(0, positionFirstStage, logicFirstStage, Name + "_FirstStage", logicSquare, false, 0); m_SquareDetector = logicSquare; // Set First Stage sensible logicFirstStage->SetSensitiveDetector(m_SquareScorer); - ///Visualisation of FirstStage Strip - G4VisAttributes* FirstStageVisAtt = new G4VisAttributes(G4Colour(0.3, 0.3, 0.3)); + /// Visualisation of FirstStage Strip + G4VisAttributes* FirstStageVisAtt = new G4VisAttributes(G4Colour(0.3, 0.3, 0.3)); logicFirstStage->SetVisAttributes(FirstStageVisAtt); } return m_SquareDetector; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -G4LogicalVolume* Mugast::BuildTrapezoidDetector(){ - if(!m_TrapezoidDetector){ +G4LogicalVolume* Mugast::BuildTrapezoidDetector() { + if (!m_TrapezoidDetector) { G4String Name = "MugastTrapezoid"; // Definition of the volume containing the sensitive detector - G4Trap* solidTrapezoid = new G4Trap(Name, - TrapezoidLength*0.5, 0*deg, 0*deg, - TrapezoidHeight*0.5, TrapezoidBaseSmall*0.5,TrapezoidBaseLarge*0.5, 0*deg, - TrapezoidHeight*0.5, TrapezoidBaseSmall*0.5,TrapezoidBaseLarge*0.5, 0*deg); - G4LogicalVolume* logicTrapezoid = new G4LogicalVolume(solidTrapezoid, - MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"), - Name, - 0, 0, 0); + G4Trap* solidTrapezoid = + new G4Trap(Name, TrapezoidLength * 0.5, 0 * deg, 0 * deg, TrapezoidHeight * 0.5, TrapezoidBaseSmall * 0.5, + TrapezoidBaseLarge * 0.5, 0 * deg, TrapezoidHeight * 0.5, TrapezoidBaseSmall * 0.5, + TrapezoidBaseLarge * 0.5, 0 * deg); + G4LogicalVolume* logicTrapezoid = new G4LogicalVolume( + solidTrapezoid, MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"), Name, 0, 0, 0); G4VisAttributes* TrapezoideVisAtt = new G4VisAttributes(G4Colour(0.90, 0.90, 0.90)); - TrapezoideVisAtt->SetForceWireframe(true); + TrapezoideVisAtt->SetForceWireframe(true); logicTrapezoid->SetVisAttributes(TrapezoideVisAtt); // Silicon detector itself - G4ThreeVector positionFirstStage = G4ThreeVector(0, 0, 0); - - G4Trap* solidFirstStage = new G4Trap("solidFirstStage", - 0.5*SiliconThickness, 0*deg, 0*deg, - TrapezoidHeight*0.5, TrapezoidBaseSmall*0.5,TrapezoidBaseLarge*0.5, 0*deg, - TrapezoidHeight*0.5, TrapezoidBaseSmall*0.5,TrapezoidBaseLarge*0.5, 0*deg); - G4LogicalVolume* logicFirstStage = new G4LogicalVolume(solidFirstStage, - MaterialManager::getInstance()->GetMaterialFromLibrary("Si"), - "logicFirstStage", - 0, 0, 0); - - new G4PVPlacement(0, - positionFirstStage, - logicFirstStage, - Name + "_FirstStage", - logicTrapezoid, - false, - 0); + G4ThreeVector positionFirstStage = G4ThreeVector(0, 0, 0); + + G4Trap* solidFirstStage = + new G4Trap("solidFirstStage", 0.5 * SiliconThickness, 0 * deg, 0 * deg, TrapezoidHeight * 0.5, + TrapezoidBaseSmall * 0.5, TrapezoidBaseLarge * 0.5, 0 * deg, TrapezoidHeight * 0.5, + TrapezoidBaseSmall * 0.5, TrapezoidBaseLarge * 0.5, 0 * deg); + G4LogicalVolume* logicFirstStage = new G4LogicalVolume( + solidFirstStage, MaterialManager::getInstance()->GetMaterialFromLibrary("Si"), "logicFirstStage", 0, 0, 0); + + new G4PVPlacement(0, positionFirstStage, logicFirstStage, Name + "_FirstStage", logicTrapezoid, false, 0); // Set First Stage sensible logicFirstStage->SetSensitiveDetector(m_TrapezoidScorer); - ///Visualisation of FirstStage Strip - G4VisAttributes* FirstStageVisAtt = new G4VisAttributes(G4Colour(0.3, 0.3, 0.3)); + /// Visualisation of FirstStage Strip + G4VisAttributes* FirstStageVisAtt = new G4VisAttributes(G4Colour(0.3, 0.3, 0.3)); logicFirstStage->SetVisAttributes(FirstStageVisAtt); - m_TrapezoidDetector=logicTrapezoid; + m_TrapezoidDetector = logicTrapezoid; } return m_TrapezoidDetector; } - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -G4LogicalVolume* Mugast::BuildAnnularDetector(){ +G4LogicalVolume* Mugast::BuildAnnularDetector() { - if(!m_AnnularDetector){ + if (!m_AnnularDetector) { G4Material* Silicon = MaterialManager::getInstance()->GetMaterialFromLibrary("Si"); - G4Material* Vacuum = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); - G4Material* PCB = MaterialManager::getInstance()->GetMaterialFromLibrary("PCB"); + G4Material* Vacuum = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); + G4Material* PCB = MaterialManager::getInstance()->GetMaterialFromLibrary("PCB"); //////////////////////////////////////////////////////////////// ////////////// Starting Volume Definition ////////////////////// //////////////////////////////////////////////////////////////// @@ -244,139 +226,93 @@ G4LogicalVolume* Mugast::BuildAnnularDetector(){ // Building the PCB // The PCB is a simple extruded volume from 8 reference points vector<G4TwoVector> polygon; - for(unsigned int i = 0 ; i < 8 ; i++){ - G4TwoVector Point(PCBPointsX[i],PCBPointsY[i]); + for (unsigned int i = 0; i < 8; i++) { + G4TwoVector Point(PCBPointsX[i], PCBPointsY[i]); polygon.push_back(Point); } // Master volume containing all the detector - G4ExtrudedSolid* solidAnnularS1 = new G4ExtrudedSolid(Name, - polygon, - PCBThickness*0.5, - G4TwoVector(0,0),1, - G4TwoVector(0,0),1); + G4ExtrudedSolid* solidAnnularS1 = + new G4ExtrudedSolid(Name, polygon, PCBThickness * 0.5, G4TwoVector(0, 0), 1, G4TwoVector(0, 0), 1); // Definition of the volume containing the sensitive detector - m_AnnularDetector= new G4LogicalVolume(solidAnnularS1, Vacuum, Name, 0, 0, 0); - m_AnnularDetector->SetVisAttributes(G4VisAttributes::Invisible); + m_AnnularDetector = new G4LogicalVolume(solidAnnularS1, Vacuum, Name, 0, 0, 0); + m_AnnularDetector->SetVisAttributes(G4VisAttributes::GetInvisible()); // PCB Base - G4ExtrudedSolid* solidPCBBase = new G4ExtrudedSolid("PCBBase", - polygon, - PCBThickness*0.5, - G4TwoVector(0,0),1, - G4TwoVector(0,0),1); + G4ExtrudedSolid* solidPCBBase = + new G4ExtrudedSolid("PCBBase", polygon, PCBThickness * 0.5, G4TwoVector(0, 0), 1, G4TwoVector(0, 0), 1); // Wafer Shape to be substracted to the PCB - G4Tubs* solidWaferShapeBase = new G4Tubs("WaferShape", - 0, - WaferOutterRadius, - PCBThickness, - 0*deg, - 360*deg); + G4Tubs* solidWaferShapeBase = new G4Tubs("WaferShape", 0, WaferOutterRadius, PCBThickness, 0 * deg, 360 * deg); // A no rotation matrix is always handy ;) - G4RotationMatrix* norotation = new G4RotationMatrix(); - // Rotation of the box that make the Si cut - G4RotationMatrix* cutrotation = new G4RotationMatrix(G4ThreeVector(0,0,1),45*deg); - G4ThreeVector cutposition1(80*mm+WaferRCut,0,0); cutposition1.setPhi(45*deg); - G4Transform3D transform1(*cutrotation,cutposition1); + G4RotationMatrix* norotation = new G4RotationMatrix(); + // Rotation of the box that make the Si cut + G4RotationMatrix* cutrotation = new G4RotationMatrix(G4ThreeVector(0, 0, 1), 45 * deg); + G4ThreeVector cutposition1(80 * mm + WaferRCut, 0, 0); + cutposition1.setPhi(45 * deg); + G4Transform3D transform1(*cutrotation, cutposition1); - G4Box* solidCutout = new G4Box("cuttout",80*mm,80*mm,80*mm); + G4Box* solidCutout = new G4Box("cuttout", 80 * mm, 80 * mm, 80 * mm); - G4SubtractionSolid* solidWaferShape1 = new G4SubtractionSolid("WaferShape1", - solidWaferShapeBase, - solidCutout, - transform1); - - - G4ThreeVector cutposition2(-80*mm-WaferRCut,0,0); cutposition2.setPhi(-135*deg); - G4Transform3D transform2(*cutrotation,cutposition2); - G4SubtractionSolid* solidWaferShape = new G4SubtractionSolid("WaferShape", - solidWaferShape1, - solidCutout, - transform2); + G4SubtractionSolid* solidWaferShape1 = + new G4SubtractionSolid("WaferShape1", solidWaferShapeBase, solidCutout, transform1); + G4ThreeVector cutposition2(-80 * mm - WaferRCut, 0, 0); + cutposition2.setPhi(-135 * deg); + G4Transform3D transform2(*cutrotation, cutposition2); + G4SubtractionSolid* solidWaferShape = + new G4SubtractionSolid("WaferShape", solidWaferShape1, solidCutout, transform2); // PCB final - G4SubtractionSolid* solidPCB = new G4SubtractionSolid("MugastAnnular_PCB1", - solidPCBBase, - solidWaferShape); + G4SubtractionSolid* solidPCB = new G4SubtractionSolid("MugastAnnular_PCB1", solidPCBBase, solidWaferShape); G4LogicalVolume* logicPCB = new G4LogicalVolume(solidPCB, PCB, "MugastAnnular_PCB", 0, 0, 0); - new G4PVPlacement(G4Transform3D(*norotation, G4ThreeVector()), - logicPCB, - "MugastAnnular_PCB", - m_AnnularDetector, - false, - 0); + new G4PVPlacement(G4Transform3D(*norotation, G4ThreeVector()), logicPCB, "MugastAnnular_PCB", m_AnnularDetector, + false, 0); - G4VisAttributes* PCBVisAtt = new G4VisAttributes(G4Colour(0.2, 0.5, 0.2)) ; + G4VisAttributes* PCBVisAtt = new G4VisAttributes(G4Colour(0.2, 0.5, 0.2)); logicPCB->SetVisAttributes(PCBVisAtt); - // Wafer itself - G4Tubs* solidWaferBase = new G4Tubs("Wafer", - WaferInnerRadius, - WaferOutterRadius, - 0.5*WaferThickness, - 0*deg, - 360*deg); - - G4SubtractionSolid* solidWafer1 = new G4SubtractionSolid("Wafer1", - solidWaferBase, - solidCutout, - transform1); - - G4SubtractionSolid* solidWafer = new G4SubtractionSolid("Wafer", - solidWafer1, - solidCutout, - transform2); + G4Tubs* solidWaferBase = + new G4Tubs("Wafer", WaferInnerRadius, WaferOutterRadius, 0.5 * WaferThickness, 0 * deg, 360 * deg); + + G4SubtractionSolid* solidWafer1 = new G4SubtractionSolid("Wafer1", solidWaferBase, solidCutout, transform1); + + G4SubtractionSolid* solidWafer = new G4SubtractionSolid("Wafer", solidWafer1, solidCutout, transform2); G4LogicalVolume* logicWafer = new G4LogicalVolume(solidWafer, Silicon, "MugastAnnular_Wafer", 0, 0, 0); - new G4PVPlacement(G4Transform3D(*norotation, G4ThreeVector()), - logicWafer, - "MugastAnnular_Wafer", - m_AnnularDetector, - false, - 0); + new G4PVPlacement(G4Transform3D(*norotation, G4ThreeVector()), logicWafer, "MugastAnnular_Wafer", m_AnnularDetector, + false, 0); - G4VisAttributes* SiVisAtt = new G4VisAttributes(G4Colour(0.3, 0.3, 0.3)) ; - logicWafer->SetVisAttributes(SiVisAtt); + G4VisAttributes* SiVisAtt = new G4VisAttributes(G4Colour(0.3, 0.3, 0.3)); + logicWafer->SetVisAttributes(SiVisAtt); // Active Wafer - G4Tubs* solidActiveWaferBase = new G4Tubs("ActiveWafer", - ActiveWaferInnerRadius, - ActiveWaferOutterRadius, - 0.5*WaferThickness, - 0*deg, - 360*deg); - - - G4ThreeVector activecutposition1(80*mm+ActiveWaferRCut,0,0); activecutposition1.setPhi(45*deg); - G4Transform3D activetransform1(*cutrotation,activecutposition1); - - G4SubtractionSolid* solidActiveWafer1 = new G4SubtractionSolid("ActiveWafer1", - solidActiveWaferBase, - solidCutout, - activetransform1); - - G4ThreeVector activecutposition2(-80*mm-ActiveWaferRCut,0,0); activecutposition2.setPhi(-135*deg); - G4Transform3D activetransform2(*cutrotation,activecutposition2); - - G4SubtractionSolid* solidActiveWafer = new G4SubtractionSolid("ActiveWafer", - solidActiveWafer1, - solidCutout, - activetransform2); - - G4LogicalVolume* logicActiveWafer = new G4LogicalVolume(solidActiveWafer, Silicon, "MugastAnnular_ActiveWafer", 0, 0, 0); - new G4PVPlacement(G4Transform3D(*norotation, G4ThreeVector()), - logicActiveWafer, - "MugastAnnular_ActiveWafer", - logicWafer, - false, - 0); + G4Tubs* solidActiveWaferBase = new G4Tubs("ActiveWafer", ActiveWaferInnerRadius, ActiveWaferOutterRadius, + 0.5 * WaferThickness, 0 * deg, 360 * deg); + + G4ThreeVector activecutposition1(80 * mm + ActiveWaferRCut, 0, 0); + activecutposition1.setPhi(45 * deg); + G4Transform3D activetransform1(*cutrotation, activecutposition1); + + G4SubtractionSolid* solidActiveWafer1 = + new G4SubtractionSolid("ActiveWafer1", solidActiveWaferBase, solidCutout, activetransform1); + + G4ThreeVector activecutposition2(-80 * mm - ActiveWaferRCut, 0, 0); + activecutposition2.setPhi(-135 * deg); + G4Transform3D activetransform2(*cutrotation, activecutposition2); + + G4SubtractionSolid* solidActiveWafer = + new G4SubtractionSolid("ActiveWafer", solidActiveWafer1, solidCutout, activetransform2); + + G4LogicalVolume* logicActiveWafer = + new G4LogicalVolume(solidActiveWafer, Silicon, "MugastAnnular_ActiveWafer", 0, 0, 0); + new G4PVPlacement(G4Transform3D(*norotation, G4ThreeVector()), logicActiveWafer, "MugastAnnular_ActiveWafer", + logicWafer, false, 0); logicActiveWafer->SetVisAttributes(SiVisAtt); @@ -386,10 +322,6 @@ G4LogicalVolume* Mugast::BuildAnnularDetector(){ return m_AnnularDetector; } - - - - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... @@ -403,8 +335,8 @@ void Mugast::ReadConfiguration(NPL::InputParser parser) { cout << "//// " << blocks.size() << " detector found" << endl; // Cartesian Case - vector<string> cart = {"DetectorNumber","X1_Y1", "X1_Y128", "X128_Y1", "X128_Y128"}; - vector<string> annular = {"DetectorNumber","Center"}; + vector<string> cart = {"DetectorNumber", "X1_Y1", "X1_Y128", "X128_Y1", "X128_Y128"}; + vector<string> annular = {"DetectorNumber", "Center"}; for (unsigned int i = 0; i < blocks.size(); i++) { @@ -413,30 +345,25 @@ void Mugast::ReadConfiguration(NPL::InputParser parser) { if (NPOptionManager::getInstance()->GetVerboseLevel()) cout << endl << "//// Mugast detector " << shape << endl; - if (blocks[i]->HasTokenList(cart)&& (shape=="Square"|| shape=="Trapezoid")) { + if (blocks[i]->HasTokenList(cart) && (shape == "Square" || shape == "Trapezoid")) { int DetectorNumber = blocks[i]->GetInt("DetectorNumber"); - G4ThreeVector A - = NPS::ConvertVector(blocks[i]->GetTVector3("X1_Y1", "mm")); - G4ThreeVector B - = NPS::ConvertVector(blocks[i]->GetTVector3("X1_Y128", "mm")); - G4ThreeVector C - = NPS::ConvertVector(blocks[i]->GetTVector3("X128_Y1", "mm")); - G4ThreeVector D - = NPS::ConvertVector(blocks[i]->GetTVector3("X128_Y128", "mm")); - - AddDetector(DetectorNumber,shape,A,B,C,D); + G4ThreeVector A = NPS::ConvertVector(blocks[i]->GetTVector3("X1_Y1", "mm")); + G4ThreeVector B = NPS::ConvertVector(blocks[i]->GetTVector3("X1_Y128", "mm")); + G4ThreeVector C = NPS::ConvertVector(blocks[i]->GetTVector3("X128_Y1", "mm")); + G4ThreeVector D = NPS::ConvertVector(blocks[i]->GetTVector3("X128_Y128", "mm")); + + AddDetector(DetectorNumber, shape, A, B, C, D); } - else if (blocks[i]->HasTokenList(annular)&& (shape=="Annular")) { + else if (blocks[i]->HasTokenList(annular) && (shape == "Annular")) { int DetectorNumber = blocks[i]->GetInt("DetectorNumber"); - G4ThreeVector A - = NPS::ConvertVector(blocks[i]->GetTVector3("Center", "mm")); - AddDetector(DetectorNumber,shape,A); + G4ThreeVector A = NPS::ConvertVector(blocks[i]->GetTVector3("Center", "mm")); + AddDetector(DetectorNumber, shape, A); } else { cout << "WARNING: Missing token for Mugast blocks, check your input " - "file" - << endl; + "file" + << endl; exit(1); } } @@ -447,16 +374,16 @@ void Mugast::ReadConfiguration(NPL::InputParser parser) { // Construct detector and inialise sensitive part. // Called After Detecor // onstruction::AddDetector Method -void Mugast::ConstructDetector(G4LogicalVolume* world){ - - for (unsigned short i = 0 ; i < m_DetectorNumber.size() ; i++) { - if(m_Shape[i]=="Square"){ - G4RotationMatrix* rot = NULL ; - G4ThreeVector pos = G4ThreeVector(0, 0, 0) ; - G4ThreeVector u = G4ThreeVector(0, 0, 0) ; - G4ThreeVector v = G4ThreeVector(0, 0, 0) ; - G4ThreeVector w = G4ThreeVector(0, 0, 0) ; - G4ThreeVector Center = G4ThreeVector(0, 0, 0) ; +void Mugast::ConstructDetector(G4LogicalVolume* world) { + + for (unsigned short i = 0; i < m_DetectorNumber.size(); i++) { + if (m_Shape[i] == "Square") { + G4RotationMatrix* rot = NULL; + G4ThreeVector pos = G4ThreeVector(0, 0, 0); + G4ThreeVector u = G4ThreeVector(0, 0, 0); + G4ThreeVector v = G4ThreeVector(0, 0, 0); + G4ThreeVector w = G4ThreeVector(0, 0, 0); + G4ThreeVector Center = G4ThreeVector(0, 0, 0); // (u,v,w) unitary vector associated to telescope referencial // (u,v) // to silicon plan // w perpendicular to (u,v) plan and pointing ThirdStage @@ -474,23 +401,24 @@ void Mugast::ConstructDetector(G4LogicalVolume* world){ // Passage Matrix from Lab Referential to Telescope Referential rot = new G4RotationMatrix(u, v, w); // translation to place Telescope - pos = w * SiliconThickness* 0.5 + Center; - new G4PVPlacement(G4Transform3D(*rot, pos), BuildSquareDetector(), "MugastSquare", world, false, m_DetectorNumber[i]); + pos = w * SiliconThickness * 0.5 + Center; + new G4PVPlacement(G4Transform3D(*rot, pos), BuildSquareDetector(), "MugastSquare", world, false, + m_DetectorNumber[i]); } - else if(m_Shape[i]=="Trapezoid"){ - G4RotationMatrix* rot = NULL ; - G4ThreeVector pos = G4ThreeVector(0, 0, 0) ; - G4ThreeVector u = G4ThreeVector(0, 0, 0) ; - G4ThreeVector v = G4ThreeVector(0, 0, 0) ; - G4ThreeVector w = G4ThreeVector(0, 0, 0) ; - G4ThreeVector Center = G4ThreeVector(0, 0, 0) ; + else if (m_Shape[i] == "Trapezoid") { + G4RotationMatrix* rot = NULL; + G4ThreeVector pos = G4ThreeVector(0, 0, 0); + G4ThreeVector u = G4ThreeVector(0, 0, 0); + G4ThreeVector v = G4ThreeVector(0, 0, 0); + G4ThreeVector w = G4ThreeVector(0, 0, 0); + G4ThreeVector Center = G4ThreeVector(0, 0, 0); // (u,v,w) unitary vector associated to telescope referencial // (u,v) // to silicon plan // w perpendicular to (u,v) plan and pointing ThirdStage u = m_X128_Y1[i] - m_X1_Y1[i]; u = u.unit(); - v = (m_X1_Y128[i] + m_X128_Y128[i] - m_X1_Y1[i] - m_X128_Y1[i] ); + v = (m_X1_Y128[i] + m_X128_Y128[i] - m_X1_Y1[i] - m_X128_Y1[i]); v = v.unit(); w = u.cross(v); @@ -500,80 +428,76 @@ void Mugast::ConstructDetector(G4LogicalVolume* world){ // Passage Matrix from Lab Referential to Telescope Referential rot = new G4RotationMatrix(u, v, w); - rot->rotate(180*deg,w); + rot->rotate(180 * deg, w); // translation to place Telescope - pos = w * SiliconThickness* 0.5 + Center; - new G4PVPlacement(G4Transform3D(*rot, pos), BuildTrapezoidDetector(), "MugastTrapezoid", world, false, m_DetectorNumber[i]); + pos = w * SiliconThickness * 0.5 + Center; + new G4PVPlacement(G4Transform3D(*rot, pos), BuildTrapezoidDetector(), "MugastTrapezoid", world, false, + m_DetectorNumber[i]); } - else if(m_Shape[i]=="Annular"){ + else if (m_Shape[i] == "Annular") { G4RotationMatrix* rot = new G4RotationMatrix(); - new G4PVPlacement(G4Transform3D(*rot,m_X1_Y1[i]), BuildAnnularDetector(), "MugastAnnular", world, false, m_DetectorNumber[i]); - } + new G4PVPlacement(G4Transform3D(*rot, m_X1_Y1[i]), BuildAnnularDetector(), "MugastAnnular", world, false, + m_DetectorNumber[i]); + } } } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Add Detector branch to the EventTree. // Called After DetecorConstruction::AddDetector Method -void Mugast::InitializeRootOutput(){ - RootOutput *pAnalysis = RootOutput::getInstance(); - TTree *pTree = pAnalysis->GetTree(); - if(!pTree->FindBranch("Mugast")){ - pTree->Branch("Mugast", "TMugastData", &m_Event) ; +void Mugast::InitializeRootOutput() { + RootOutput* pAnalysis = RootOutput::getInstance(); + TTree* pTree = pAnalysis->GetTree(); + if (!pTree->FindBranch("Mugast")) { + pTree->Branch("Mugast", "TMugastData", &m_Event); } - pTree->SetBranchAddress("Mugast", &m_Event) ; + pTree->SetBranchAddress("Mugast", &m_Event); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Read sensitive part and fill the Root tree. // Called at in the EventAction::EndOfEventAvtion -void Mugast::ReadSensitive(const G4Event* ){ +void Mugast::ReadSensitive(const G4Event*) { m_Event->Clear(); /////////// // Square - DSSDScorers::PS_Rectangle* SquareScorer = (DSSDScorers::PS_Rectangle*) m_SquareScorer->GetPrimitive(0); - + DSSDScorers::PS_Rectangle* SquareScorer = (DSSDScorers::PS_Rectangle*)m_SquareScorer->GetPrimitive(0); // Loop on the Square map - unsigned int sizeFront= SquareScorer->GetLengthMult(); + unsigned int sizeFront = SquareScorer->GetLengthMult(); - for (unsigned int i=0 ; i<sizeFront ; i++){ + for (unsigned int i = 0; i < sizeFront; i++) { double Energy = RandGauss::shoot(SquareScorer->GetEnergyLength(i), SigmaEnergy); - if(Energy>EnergyThreshold){ - double Time = RandGauss::shoot(SquareScorer->GetTimeLength(i), SigmaTime); - int DetNbr = SquareScorer->GetDetectorLength(i); - int StripFront = SquareScorer->GetStripLength(i); + if (Energy > EnergyThreshold) { + double Time = RandGauss::shoot(SquareScorer->GetTimeLength(i), SigmaTime); + int DetNbr = SquareScorer->GetDetectorLength(i); + int StripFront = SquareScorer->GetStripLength(i); - m_Event->SetDSSDXE(MG_DetectorType::MG_NOCHANGE,DetNbr, - MUGAST_MAP::ReverseSquareX[StripFront-1], - NPL::EnergyToADC(Energy, 0, 63, 8192, 16384)); - - m_Event->SetDSSDXT(MG_DetectorType::MG_NOCHANGE,DetNbr, - MUGAST_MAP::ReverseSquareX[StripFront-1], - NPL::EnergyToADC(Time, 0, 1000, 8192, 16384)); + m_Event->SetDSSDXE(MG_DetectorType::MG_NOCHANGE, DetNbr, MUGAST_MAP::ReverseSquareX[StripFront - 1], + NPL::EnergyToADC(Energy, 0, 63, 8192, 16384)); + m_Event->SetDSSDXT(MG_DetectorType::MG_NOCHANGE, DetNbr, MUGAST_MAP::ReverseSquareX[StripFront - 1], + NPL::EnergyToADC(Time, 0, 1000, 8192, 16384)); } - } + } - unsigned int sizeBack= SquareScorer->GetWidthMult(); - for (unsigned int i=0 ; i<sizeBack ; i++){ + unsigned int sizeBack = SquareScorer->GetWidthMult(); + for (unsigned int i = 0; i < sizeBack; i++) { double Energy = RandGauss::shoot(SquareScorer->GetEnergyWidth(i), SigmaEnergy); - if(Energy>EnergyThreshold){ - double Time = RandGauss::shoot(SquareScorer->GetTimeWidth(i), SigmaTime); - int DetNbr = SquareScorer->GetDetectorWidth(i); - int StripBack = SquareScorer->GetStripWidth(i); + if (Energy > EnergyThreshold) { + double Time = RandGauss::shoot(SquareScorer->GetTimeWidth(i), SigmaTime); + int DetNbr = SquareScorer->GetDetectorWidth(i); + int StripBack = SquareScorer->GetStripWidth(i); - m_Event->SetDSSDYE(MG_DetectorType::MG_NOCHANGE,DetNbr, - MUGAST_MAP::ReverseSquareY[StripBack-1], - NPL::EnergyToADC(Energy, 0, 63, 8192, 0)); + m_Event->SetDSSDYE(MG_DetectorType::MG_NOCHANGE, DetNbr, MUGAST_MAP::ReverseSquareY[StripBack - 1], + NPL::EnergyToADC(Energy, 0, 63, 8192, 0)); - m_Event->SetDSSDYT(MG_DetectorType::MG_NOCHANGE,DetNbr, - MUGAST_MAP::ReverseSquareY[StripBack-1], - NPL::EnergyToADC(Time, 0, 1000, 8192, 16384)); + m_Event->SetDSSDYT(MG_DetectorType::MG_NOCHANGE, DetNbr, MUGAST_MAP::ReverseSquareY[StripBack - 1], + NPL::EnergyToADC(Time, 0, 1000, 8192, 16384)); } } // clear map for next event @@ -581,49 +505,43 @@ void Mugast::ReadSensitive(const G4Event* ){ /////////// // Trapezoid - DSSDScorers::PS_Rectangle* TrapezoidScorer = (DSSDScorers::PS_Rectangle*) m_TrapezoidScorer->GetPrimitive(0); - + DSSDScorers::PS_Rectangle* TrapezoidScorer = (DSSDScorers::PS_Rectangle*)m_TrapezoidScorer->GetPrimitive(0); // Loop on the Trapezoid map - sizeFront= TrapezoidScorer->GetLengthMult(); + sizeFront = TrapezoidScorer->GetLengthMult(); - for (unsigned int i=0 ; i<sizeFront ; i++){ + for (unsigned int i = 0; i < sizeFront; i++) { double Energy = RandGauss::shoot(TrapezoidScorer->GetEnergyLength(i), SigmaEnergy); - if(Energy>EnergyThreshold){ - double Time = RandGauss::shoot(TrapezoidScorer->GetTimeLength(i), SigmaTime); - int DetNbr = TrapezoidScorer->GetDetectorLength(i); - int StripFront = TrapezoidScorer->GetStripLength(i); + if (Energy > EnergyThreshold) { + double Time = RandGauss::shoot(TrapezoidScorer->GetTimeLength(i), SigmaTime); + int DetNbr = TrapezoidScorer->GetDetectorLength(i); + int StripFront = TrapezoidScorer->GetStripLength(i); - m_Event->SetDSSDXE(MG_DetectorType::MG_NOCHANGE,DetNbr, - MUGAST_MAP::ReverseTrapezeX[StripFront-1], - NPL::EnergyToADC(Energy, 0, 63, 8192, 16384)); - - m_Event->SetDSSDXT(MG_DetectorType::MG_NOCHANGE,DetNbr, - MUGAST_MAP::ReverseTrapezeX[StripFront-1], - NPL::EnergyToADC(Time, 0, 1000, 8192, 16384)); + m_Event->SetDSSDXE(MG_DetectorType::MG_NOCHANGE, DetNbr, MUGAST_MAP::ReverseTrapezeX[StripFront - 1], + NPL::EnergyToADC(Energy, 0, 63, 8192, 16384)); + m_Event->SetDSSDXT(MG_DetectorType::MG_NOCHANGE, DetNbr, MUGAST_MAP::ReverseTrapezeX[StripFront - 1], + NPL::EnergyToADC(Time, 0, 1000, 8192, 16384)); } - } + } - sizeBack= TrapezoidScorer->GetWidthMult(); - for (unsigned int i=0 ; i<sizeBack ; i++){ + sizeBack = TrapezoidScorer->GetWidthMult(); + for (unsigned int i = 0; i < sizeBack; i++) { double Energy = RandGauss::shoot(TrapezoidScorer->GetEnergyWidth(i), SigmaEnergy); - if(Energy>EnergyThreshold){ - double Time = RandGauss::shoot(TrapezoidScorer->GetTimeWidth(i), SigmaTime); - int DetNbr = TrapezoidScorer->GetDetectorWidth(i); - int StripBack = 128-TrapezoidScorer->GetStripWidth(i)+1; + if (Energy > EnergyThreshold) { + double Time = RandGauss::shoot(TrapezoidScorer->GetTimeWidth(i), SigmaTime); + int DetNbr = TrapezoidScorer->GetDetectorWidth(i); + int StripBack = 128 - TrapezoidScorer->GetStripWidth(i) + 1; - m_Event->SetDSSDYE(MG_DetectorType::MG_NOCHANGE,DetNbr, - MUGAST_MAP::ReverseTrapezeY[StripBack-1], - NPL::EnergyToADC(Energy, 0, 63, 8192, 0)); + m_Event->SetDSSDYE(MG_DetectorType::MG_NOCHANGE, DetNbr, MUGAST_MAP::ReverseTrapezeY[StripBack - 1], + NPL::EnergyToADC(Energy, 0, 63, 8192, 0)); - m_Event->SetDSSDYT(MG_DetectorType::MG_NOCHANGE,DetNbr, - MUGAST_MAP::ReverseTrapezeY[StripBack-1], - NPL::EnergyToADC(Time, 0, 1000, 8192, 16384)); + m_Event->SetDSSDYT(MG_DetectorType::MG_NOCHANGE, DetNbr, MUGAST_MAP::ReverseTrapezeY[StripBack - 1], + NPL::EnergyToADC(Time, 0, 1000, 8192, 16384)); } } // clear map for next event @@ -631,107 +549,86 @@ void Mugast::ReadSensitive(const G4Event* ){ /////////// // Annular - DSSDScorers::PS_Annular* AnnularScorer = (DSSDScorers::PS_Annular*) m_AnnularScorer->GetPrimitive(0); - + DSSDScorers::PS_Annular* AnnularScorer = (DSSDScorers::PS_Annular*)m_AnnularScorer->GetPrimitive(0); // Loop on the Annular map - sizeFront= AnnularScorer->GetRingMult(); - unsigned int sizeQuadrant= AnnularScorer->GetQuadrantMult(); + sizeFront = AnnularScorer->GetRingMult(); + unsigned int sizeQuadrant = AnnularScorer->GetQuadrantMult(); - for (unsigned int i=0 ; i<sizeFront ; i++){ + for (unsigned int i = 0; i < sizeFront; i++) { double Energy = RandGauss::shoot(AnnularScorer->GetEnergyRing(i), SigmaEnergy); - if(Energy>EnergyThreshold){ - double Time = RandGauss::shoot(AnnularScorer->GetTimeRing(i), SigmaTime); - unsigned int DetNbr = AnnularScorer->GetDetectorRing(i); - unsigned int StripFront = AnnularScorer->GetStripRing(i); - + if (Energy > EnergyThreshold) { + double Time = RandGauss::shoot(AnnularScorer->GetTimeRing(i), SigmaTime); + unsigned int DetNbr = AnnularScorer->GetDetectorRing(i); + unsigned int StripFront = AnnularScorer->GetStripRing(i); + // Check for associated Quadrant strip int StripQuadrant = 0; - for(unsigned int q = 0 ; q < sizeQuadrant ; q++){ - if(AnnularScorer->GetDetectorQuadrant(q)==DetNbr){ - StripQuadrant = AnnularScorer->GetStripQuadrant(q)-1; + for (unsigned int q = 0; q < sizeQuadrant; q++) { + if (AnnularScorer->GetDetectorQuadrant(q) == DetNbr) { + StripQuadrant = AnnularScorer->GetStripQuadrant(q) - 1; break; - } + } } - StripFront=StripFront+StripQuadrant*NbrRingStrips; - m_Event->SetDSSDXE(MG_DetectorType::MG_NOCHANGE,DetNbr, - MUGAST_MAP::ReverseAnnularX[StripFront-1], - NPL::EnergyToADC(Energy, 0, 63, 8192, 16384)); - - m_Event->SetDSSDXT(MG_DetectorType::MG_NOCHANGE,DetNbr, - MUGAST_MAP::ReverseAnnularX[StripFront-1], - NPL::EnergyToADC(Time, 0, 1000, 8192, 16384)); + StripFront = StripFront + StripQuadrant * NbrRingStrips; + m_Event->SetDSSDXE(MG_DetectorType::MG_NOCHANGE, DetNbr, MUGAST_MAP::ReverseAnnularX[StripFront - 1], + NPL::EnergyToADC(Energy, 0, 63, 8192, 16384)); + m_Event->SetDSSDXT(MG_DetectorType::MG_NOCHANGE, DetNbr, MUGAST_MAP::ReverseAnnularX[StripFront - 1], + NPL::EnergyToADC(Time, 0, 1000, 8192, 16384)); } - } + } - sizeBack= AnnularScorer->GetSectorMult(); - for (unsigned int i=0 ; i<sizeBack ; i++){ + sizeBack = AnnularScorer->GetSectorMult(); + for (unsigned int i = 0; i < sizeBack; i++) { double Energy = RandGauss::shoot(AnnularScorer->GetEnergySector(i), SigmaEnergy); - if(Energy>EnergyThreshold){ - double Time = RandGauss::shoot(AnnularScorer->GetTimeSector(i), SigmaTime); - int DetNbr = AnnularScorer->GetDetectorSector(i); - int StripBack = AnnularScorer->GetStripSector(i); - m_Event->SetDSSDYE(MG_DetectorType::MG_NOCHANGE,DetNbr, - MUGAST_MAP::ReverseAnnularY[StripBack-1], - NPL::EnergyToADC(Energy, 0, 63, 8192, 0)); - - m_Event->SetDSSDYT(MG_DetectorType::MG_NOCHANGE,DetNbr, - MUGAST_MAP::ReverseAnnularY[StripBack-1], - NPL::EnergyToADC(Time, 0, 1000, 8192, 16384)); + if (Energy > EnergyThreshold) { + double Time = RandGauss::shoot(AnnularScorer->GetTimeSector(i), SigmaTime); + int DetNbr = AnnularScorer->GetDetectorSector(i); + int StripBack = AnnularScorer->GetStripSector(i); + m_Event->SetDSSDYE(MG_DetectorType::MG_NOCHANGE, DetNbr, MUGAST_MAP::ReverseAnnularY[StripBack - 1], + NPL::EnergyToADC(Energy, 0, 63, 8192, 0)); + + m_Event->SetDSSDYT(MG_DetectorType::MG_NOCHANGE, DetNbr, MUGAST_MAP::ReverseAnnularY[StripBack - 1], + NPL::EnergyToADC(Time, 0, 1000, 8192, 16384)); } } // clear map for next event AnnularScorer->clear(); - - } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -//////////////////////////////////////////////////////////////// -void Mugast::InitializeScorers() { +//////////////////////////////////////////////////////////////// +void Mugast::InitializeScorers() { // This check is necessary in case the geometry is reloaded - bool already_exist = false; - m_SquareScorer= CheckScorer("SquareScorer",already_exist) ; - m_TrapezoidScorer= CheckScorer("TrapezoidScorer",already_exist) ; - m_AnnularScorer= CheckScorer("AnnularScorer",already_exist) ; + bool already_exist = false; + m_SquareScorer = CheckScorer("SquareScorer", already_exist); + m_TrapezoidScorer = CheckScorer("TrapezoidScorer", already_exist); + m_AnnularScorer = CheckScorer("AnnularScorer", already_exist); - if(already_exist) - return ; + if (already_exist) + return; // Otherwise the scorer is initialised - G4VPrimitiveScorer* SquareScorer = new DSSDScorers::PS_Rectangle("MugastSquareScorer",1, - SquareBase, - SquareHeight, - 128, - 128); - - - G4VPrimitiveScorer* TrapezoidScorer = new DSSDScorers::PS_Rectangle("MugastTrapezoidScorer",1, - TrapezoidBaseLarge, - TrapezoidHeight, - 128, - 128); - - G4VPrimitiveScorer* AnnularScorer = new DSSDScorers::PS_Annular("MugastAnnularScorer", - 2, - ActiveWaferInnerRadius, - ActiveWaferOutterRadius, - -8*22.5*deg, //MUST2 campaign 2009, See: Phd Sandra Giron - +8*22.5*deg, - NbrRingStrips, - NbrSectorStrips, - NbQuadrant); - - - G4VPrimitiveScorer* InteractionS= new InteractionScorers::PS_Interactions("InteractionS",ms_InterCoord, 0) ; - G4VPrimitiveScorer* InteractionT= new InteractionScorers::PS_Interactions("InteractionT",ms_InterCoord, 0) ; - G4VPrimitiveScorer* InteractionA= new InteractionScorers::PS_Interactions("InteractionA",ms_InterCoord, 0) ; - //and register it to the multifunctionnal detector + G4VPrimitiveScorer* SquareScorer = + new DSSDScorers::PS_Rectangle("MugastSquareScorer", 1, SquareBase, SquareHeight, 128, 128); + + G4VPrimitiveScorer* TrapezoidScorer = + new DSSDScorers::PS_Rectangle("MugastTrapezoidScorer", 1, TrapezoidBaseLarge, TrapezoidHeight, 128, 128); + + G4VPrimitiveScorer* AnnularScorer = + new DSSDScorers::PS_Annular("MugastAnnularScorer", 2, ActiveWaferInnerRadius, ActiveWaferOutterRadius, + -8 * 22.5 * deg, // MUST2 campaign 2009, See: Phd Sandra Giron + +8 * 22.5 * deg, NbrRingStrips, NbrSectorStrips, NbQuadrant); + + G4VPrimitiveScorer* InteractionS = new InteractionScorers::PS_Interactions("InteractionS", ms_InterCoord, 0); + G4VPrimitiveScorer* InteractionT = new InteractionScorers::PS_Interactions("InteractionT", ms_InterCoord, 0); + G4VPrimitiveScorer* InteractionA = new InteractionScorers::PS_Interactions("InteractionA", ms_InterCoord, 0); + // and register it to the multifunctionnal detector m_SquareScorer->RegisterPrimitive(SquareScorer); m_SquareScorer->RegisterPrimitive(InteractionS); m_TrapezoidScorer->RegisterPrimitive(TrapezoidScorer); @@ -739,9 +636,9 @@ void Mugast::InitializeScorers() { m_AnnularScorer->RegisterPrimitive(AnnularScorer); m_AnnularScorer->RegisterPrimitive(InteractionA); - G4SDManager::GetSDMpointer()->AddNewDetector(m_SquareScorer) ; - G4SDManager::GetSDMpointer()->AddNewDetector(m_TrapezoidScorer) ; - G4SDManager::GetSDMpointer()->AddNewDetector(m_AnnularScorer) ; + G4SDManager::GetSDMpointer()->AddNewDetector(m_SquareScorer); + G4SDManager::GetSDMpointer()->AddNewDetector(m_TrapezoidScorer); + G4SDManager::GetSDMpointer()->AddNewDetector(m_AnnularScorer); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... @@ -750,22 +647,20 @@ void Mugast::InitializeScorers() { //////////////////////////////////////////////////////////////////////////////// // Construct Method to be pass to the DetectorFactory // //////////////////////////////////////////////////////////////////////////////// -NPS::VDetector* Mugast::Construct(){ - return (NPS::VDetector*) new Mugast(); -} +NPS::VDetector* Mugast::Construct() { return (NPS::VDetector*)new Mugast(); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //////////////////////////////////////////////////////////////////////////////// // Registering the construct method to the factory // //////////////////////////////////////////////////////////////////////////////// -extern"C" { - class proxy_nps_Mugast{ - public: - proxy_nps_Mugast(){ - NPS::DetectorFactory::getInstance()->AddToken("Mugast","Mugast"); - NPS::DetectorFactory::getInstance()->AddDetector("Mugast",Mugast::Construct); - } - }; +extern "C" { +class proxy_nps_Mugast { + public: + proxy_nps_Mugast() { + NPS::DetectorFactory::getInstance()->AddToken("Mugast", "Mugast"); + NPS::DetectorFactory::getInstance()->AddDetector("Mugast", Mugast::Construct); + } +}; - proxy_nps_Mugast p_nps_Mugast; +proxy_nps_Mugast p_nps_Mugast; } diff --git a/NPSimulation/Detectors/Nana/Nana.cc b/NPSimulation/Detectors/Nana/Nana.cc index f5058b431e26b49a4fc799f47addd98233d35a55..f3c02c1deafefaf465bc7d4e3e62349502c0e68c 100644 --- a/NPSimulation/Detectors/Nana/Nana.cc +++ b/NPSimulation/Detectors/Nana/Nana.cc @@ -20,23 +20,23 @@ *****************************************************************************/ // C++ headers -#include <sstream> #include <cmath> #include <limits> +#include <sstream> using namespace std; -//Geant4 -#include "G4VSolid.hh" +// Geant4 #include "G4Box.hh" -#include "G4Tubs.hh" +#include "G4Colour.hh" #include "G4ExtrudedSolid.hh" -#include "G4TwoVector.hh" -#include "G4UnionSolid.hh" -#include "G4SubtractionSolid.hh" +#include "G4PVPlacement.hh" #include "G4SDManager.hh" +#include "G4SubtractionSolid.hh" #include "G4Transform3D.hh" -#include "G4PVPlacement.hh" -#include "G4Colour.hh" +#include "G4Tubs.hh" +#include "G4TwoVector.hh" +#include "G4UnionSolid.hh" +#include "G4VSolid.hh" // NPS #include "Nana.hh" @@ -55,7 +55,7 @@ using namespace CLHEP; //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Nana Specific Method -Nana::Nana(){ +Nana::Nana() { m_Event = new TNanaData(); // Blue @@ -68,28 +68,28 @@ Nana::Nana(){ m_DetectorCasingVisAtt = new G4VisAttributes(G4Colour(0.125, 0.125, 0.125, 0.4)); m_LogicalDetector = 0; - m_LaBr3Scorer = 0 ; + m_LaBr3Scorer = 0; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -Nana::~Nana(){ -} +Nana::~Nana() {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Nana::AddDetector(G4ThreeVector Pos1, G4ThreeVector Pos2, G4ThreeVector Pos3, G4ThreeVector Pos4){ - G4ThreeVector Pos=(Pos1+Pos2+Pos3+Pos4)/4.; - G4ThreeVector u = Pos1-Pos2; - G4ThreeVector v = Pos1-Pos4; - u = u.unit(); v = v.unit(); +void Nana::AddDetector(G4ThreeVector Pos1, G4ThreeVector Pos2, G4ThreeVector Pos3, G4ThreeVector Pos4) { + G4ThreeVector Pos = (Pos1 + Pos2 + Pos3 + Pos4) / 4.; + G4ThreeVector u = Pos1 - Pos2; + G4ThreeVector v = Pos1 - Pos4; + u = u.unit(); + v = v.unit(); G4ThreeVector w = Pos.unit(); - Pos = Pos + w*Length*0.5; + Pos = Pos + w * Length * 0.5; m_Pos.push_back(Pos); - m_Rot.push_back(new G4RotationMatrix(u,v,w)); + m_Rot.push_back(new G4RotationMatrix(u, v, w)); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Nana::AddDetector(G4ThreeVector Pos, double beta_u, double beta_v, double beta_w){ +void Nana::AddDetector(G4ThreeVector Pos, double beta_u, double beta_v, double beta_w) { double Theta = Pos.theta(); double Phi = Pos.phi(); @@ -105,10 +105,10 @@ void Nana::AddDetector(G4ThreeVector Pos, double beta_u, double beta_v, double b v = v.unit(); u = u.unit(); - G4RotationMatrix* r = new G4RotationMatrix(u,v,w); - r->rotate(beta_u,u); - r->rotate(beta_v,v); - r->rotate(beta_w,w); + G4RotationMatrix* r = new G4RotationMatrix(u, v, w); + r->rotate(beta_u, u); + r->rotate(beta_v, v); + r->rotate(beta_w, w); m_Pos.push_back(Pos); m_Rot.push_back(r); @@ -118,38 +118,37 @@ void Nana::AddDetector(G4ThreeVector Pos, double beta_u, double beta_v, double b // Virtual Method of NPS::VDetector class // Read stream at Configfile to pick-up parameters of detector (Position,...) // Called in DetecorConstruction::ReadDetextorConfiguration Method -void Nana::ReadConfiguration(NPL::InputParser parser){ +void Nana::ReadConfiguration(NPL::InputParser parser) { vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithToken("Nana"); - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << "//// " << blocks.size() << " detectors found " << endl; - - - vector<string> cart = {"A","B","C","D"}; - vector<string> sphe= {"R","Theta","Phi","Beta"}; - - for(unsigned int i = 0 ; i < blocks.size() ; i++){ - if(blocks[i]->HasTokenList(cart)){ - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << endl << "//// Nana " << i+1 << endl; - G4ThreeVector A = NPS::ConvertVector( blocks[i]->GetTVector3("A","mm")); - G4ThreeVector B = NPS::ConvertVector(blocks[i]->GetTVector3("B","mm")); - G4ThreeVector C = NPS::ConvertVector(blocks[i]->GetTVector3("C","mm")); - G4ThreeVector D = NPS::ConvertVector(blocks[i]->GetTVector3("D","mm")); - AddDetector(A,B,C,D) ; + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks.size() << " detectors found " << endl; + + vector<string> cart = {"A", "B", "C", "D"}; + vector<string> sphe = {"R", "Theta", "Phi", "Beta"}; + + for (unsigned int i = 0; i < blocks.size(); i++) { + if (blocks[i]->HasTokenList(cart)) { + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// Nana " << i + 1 << endl; + G4ThreeVector A = NPS::ConvertVector(blocks[i]->GetTVector3("A", "mm")); + G4ThreeVector B = NPS::ConvertVector(blocks[i]->GetTVector3("B", "mm")); + G4ThreeVector C = NPS::ConvertVector(blocks[i]->GetTVector3("C", "mm")); + G4ThreeVector D = NPS::ConvertVector(blocks[i]->GetTVector3("D", "mm")); + AddDetector(A, B, C, D); } - - else if(blocks[i]->HasTokenList(sphe)){ - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << endl << "//// Nana " << i+1 << endl; - double R = blocks[i]->GetDouble("R","mm"); - double Theta = blocks[i]->GetDouble("Theta","deg"); - double Phi = blocks[i]->GetDouble("Phi","deg"); - vector<double> Beta = blocks[i]->GetVectorDouble("Beta","def"); - R = R + 0.5*Length; - G4ThreeVector Pos(R*sin(Theta)*cos(Phi),R*sin(Theta)*sin(Phi),R*cos(Theta)); - AddDetector(Pos,Beta[0],Beta[1],Beta[2]) ; + + else if (blocks[i]->HasTokenList(sphe)) { + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// Nana " << i + 1 << endl; + double R = blocks[i]->GetDouble("R", "mm"); + double Theta = blocks[i]->GetDouble("Theta", "deg"); + double Phi = blocks[i]->GetDouble("Phi", "deg"); + vector<double> Beta = blocks[i]->GetVectorDouble("Beta", "def"); + R = R + 0.5 * Length; + G4ThreeVector Pos(R * sin(Theta) * cos(Phi), R * sin(Theta) * sin(Phi), R * cos(Theta)); + AddDetector(Pos, Beta[0], Beta[1], Beta[2]); } - else{ + else { cout << "ERROR: Missing token for M2Telescope blocks, check your input file" << endl; exit(1); } @@ -159,130 +158,111 @@ void Nana::ReadConfiguration(NPL::InputParser parser){ //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Construct detector and inialise sensitive part. // Called After DetecorConstruction::AddDetector Method -void Nana::ConstructDetector(G4LogicalVolume* world){ +void Nana::ConstructDetector(G4LogicalVolume* world) { // Lead block supporting Detector G4Material* Lead = MaterialManager::getInstance()->GetMaterialFromLibrary("Pb"); - // G4Box* solidLead = new G4Box("solidLead",10*cm,5*cm,12.5*cm); + // G4Box* solidLead = new G4Box("solidLead",10*cm,5*cm,12.5*cm); std::vector<G4TwoVector> polygon; - polygon.push_back(G4TwoVector(0,50)); - polygon.push_back(G4TwoVector(-25,25)); - polygon.push_back(G4TwoVector(-25,-75)); - polygon.push_back(G4TwoVector(0,-50)); - polygon.push_back(G4TwoVector(25,-75)); - polygon.push_back(G4TwoVector(25,25)); - - std::vector<G4ExtrudedSolid::ZSection> zsections; - zsections.push_back(G4ExtrudedSolid::ZSection(-6.25*cm,G4TwoVector(0,0),1)); - zsections.push_back(G4ExtrudedSolid::ZSection(+6.25*cm,G4TwoVector(0,0),1)); - - G4ExtrudedSolid* solidLead = new G4ExtrudedSolid("solidLead", - polygon, - zsections); - - G4LogicalVolume* logicLead = new G4LogicalVolume(solidLead, Lead, "logicLead", 0, 0, 0); - G4VisAttributes* lead_vis= new G4VisAttributes(G4Colour(0.3, 0.3, 0.3)); + polygon.push_back(G4TwoVector(0, 50)); + polygon.push_back(G4TwoVector(-25, 25)); + polygon.push_back(G4TwoVector(-25, -75)); + polygon.push_back(G4TwoVector(0, -50)); + polygon.push_back(G4TwoVector(25, -75)); + polygon.push_back(G4TwoVector(25, 25)); + + std::vector<G4ExtrudedSolid::ZSection> zsections; + zsections.push_back(G4ExtrudedSolid::ZSection(-6.25 * cm, G4TwoVector(0, 0), 1)); + zsections.push_back(G4ExtrudedSolid::ZSection(+6.25 * cm, G4TwoVector(0, 0), 1)); + + G4ExtrudedSolid* solidLead = new G4ExtrudedSolid("solidLead", polygon, zsections); + + G4LogicalVolume* logicLead = new G4LogicalVolume(solidLead, Lead, "logicLead", 0, 0, 0); + G4VisAttributes* lead_vis = new G4VisAttributes(G4Colour(0.3, 0.3, 0.3)); logicLead->SetVisAttributes(lead_vis); - unsigned int mysize = m_Pos.size(); - for(unsigned int i = 0 ; i < mysize ; i++){ - new G4PVPlacement(G4Transform3D(*m_Rot[i], m_Pos[i]), ConstructDetector(), "NanaDetector", world, false, i+2); - - - G4Material* Wood = MaterialManager::getInstance()->GetMaterialFromLibrary("Wood"); - - G4Box* table = new G4Box("Table",1*m,1*m,1*cm); - G4LogicalVolume* logicTable= new G4LogicalVolume(table, Wood, "logicTable", 0, 0, 0); - - G4RotationMatrix* r = new G4RotationMatrix(); - r->rotateX(90*deg); - new G4PVPlacement(r,G4ThreeVector(0,-5*cm,0), - logicTable, - "Nana_Table", - world, - false, - 0); - - - - -/* G4RotationMatrix* r = new G4RotationMatrix(); - r->rotateX(-90*deg); - r->rotateY(60*deg); - - G4ThreeVector Pos(PMTFace,0.25*6.25*cm, 90*mm); - Pos.setTheta(60*deg); - new G4PVPlacement(G4Transform3D(*r, Pos+G4ThreeVector(0,0, +PMTFace)), - logicLead, - "Nana_Lead_Support", - world, - false, - i+1); - - new G4PVPlacement(G4Transform3D(*r, Pos+G4ThreeVector(1.1*PMTFace,0, -0.5*PMTFace)), - logicLead, - "Nana_Lead_Support", - world, - false, - i+1); - - G4RotationMatrix* r2 = new G4RotationMatrix(); - r2->rotateX(-90*deg); - r2->rotateY(300*deg); - - G4ThreeVector Pos2(PMTFace,-0.25*6.25*cm, 90*mm); - Pos2.setTheta(300*deg); - new G4PVPlacement(G4Transform3D(*r2, Pos2+G4ThreeVector(0,0, +PMTFace)), - logicLead, - "Nana_Lead_Support", - world, - false, - i+1); - - new G4PVPlacement(G4Transform3D(*r2, Pos2+G4ThreeVector(-1.1*PMTFace,0, -0.5*PMTFace)), - logicLead, - "Nana_Lead_Support", - world, - false, - i+1); -*/ + unsigned int mysize = m_Pos.size(); + for (unsigned int i = 0; i < mysize; i++) { + new G4PVPlacement(G4Transform3D(*m_Rot[i], m_Pos[i]), ConstructDetector(), "NanaDetector", world, false, i + 2); + + G4Material* Wood = MaterialManager::getInstance()->GetMaterialFromLibrary("Wood"); + + G4Box* table = new G4Box("Table", 1 * m, 1 * m, 1 * cm); + G4LogicalVolume* logicTable = new G4LogicalVolume(table, Wood, "logicTable", 0, 0, 0); + + G4RotationMatrix* r = new G4RotationMatrix(); + r->rotateX(90 * deg); + new G4PVPlacement(r, G4ThreeVector(0, -5 * cm, 0), logicTable, "Nana_Table", world, false, 0); + + /* G4RotationMatrix* r = new G4RotationMatrix(); + r->rotateX(-90*deg); + r->rotateY(60*deg); + + G4ThreeVector Pos(PMTFace,0.25*6.25*cm, 90*mm); + Pos.setTheta(60*deg); + new G4PVPlacement(G4Transform3D(*r, Pos+G4ThreeVector(0,0, +PMTFace)), + logicLead, + "Nana_Lead_Support", + world, + false, + i+1); + + new G4PVPlacement(G4Transform3D(*r, Pos+G4ThreeVector(1.1*PMTFace,0, -0.5*PMTFace)), + logicLead, + "Nana_Lead_Support", + world, + false, + i+1); + + G4RotationMatrix* r2 = new G4RotationMatrix(); + r2->rotateX(-90*deg); + r2->rotateY(300*deg); + + G4ThreeVector Pos2(PMTFace,-0.25*6.25*cm, 90*mm); + Pos2.setTheta(300*deg); + new G4PVPlacement(G4Transform3D(*r2, Pos2+G4ThreeVector(0,0, +PMTFace)), + logicLead, + "Nana_Lead_Support", + world, + false, + i+1); + + new G4PVPlacement(G4Transform3D(*r2, Pos2+G4ThreeVector(-1.1*PMTFace,0, -0.5*PMTFace)), + logicLead, + "Nana_Lead_Support", + world, + false, + i+1); + */ } } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -G4LogicalVolume* Nana::ConstructDetector(){ - if(!m_LogicalDetector){ +G4LogicalVolume* Nana::ConstructDetector() { + if (!m_LogicalDetector) { G4Material* Vacuum = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); G4Material* Alu = MaterialManager::getInstance()->GetMaterialFromLibrary("Al"); - G4Material* Kovar= MaterialManager::getInstance()->GetMaterialFromLibrary("Kovar"); + G4Material* Kovar = MaterialManager::getInstance()->GetMaterialFromLibrary("Kovar"); G4Material* Lead = MaterialManager::getInstance()->GetMaterialFromLibrary("Pb"); G4Material* LaBr3 = MaterialManager::getInstance()->GetMaterialFromLibrary("LaBr3_Ce"); - G4Material* Glass= MaterialManager::getInstance()->GetMaterialFromLibrary("Borosillicate_Glass"); + G4Material* Glass = MaterialManager::getInstance()->GetMaterialFromLibrary("Borosillicate_Glass"); // Mother Volume - G4Tubs* solidNanaDetector = - new G4Tubs("Nana",0, 0.5*FaceFront, 0.5*Length, 0.*deg, 360.*deg); - m_LogicalDetector = - new G4LogicalVolume(solidNanaDetector, Vacuum, "Nana", 0, 0, 0); + G4Tubs* solidNanaDetector = new G4Tubs("Nana", 0, 0.5 * FaceFront, 0.5 * Length, 0. * deg, 360. * deg); + m_LogicalDetector = new G4LogicalVolume(solidNanaDetector, Vacuum, "Nana", 0, 0, 0); - m_LogicalDetector->SetVisAttributes(G4VisAttributes::Invisible); + m_LogicalDetector->SetVisAttributes(G4VisAttributes::GetInvisible()); // Detector construction // LaBr3 - G4ThreeVector positionLaBr3 = G4ThreeVector(0, 0, LaBr3_PosZ); + G4ThreeVector positionLaBr3 = G4ThreeVector(0, 0, LaBr3_PosZ); - G4Tubs* solidLaBr3 = new G4Tubs("solidLaBr3", 0., 0.5*LaBr3Face, 0.5*LaBr3Thickness, 0.*deg, 360.*deg); + G4Tubs* solidLaBr3 = new G4Tubs("solidLaBr3", 0., 0.5 * LaBr3Face, 0.5 * LaBr3Thickness, 0. * deg, 360. * deg); G4LogicalVolume* logicLaBr3 = new G4LogicalVolume(solidLaBr3, LaBr3, "logicLaBr3", 0, 0, 0); - new G4PVPlacement(0, - positionLaBr3, - logicLaBr3, - "Nana_LaBr3", - m_LogicalDetector, - false, - 0); + new G4PVPlacement(0, positionLaBr3, logicLaBr3, "Nana_LaBr3", m_LogicalDetector, false, 0); // Set LaBr3 sensible logicLaBr3->SetSensitiveDetector(m_LaBr3Scorer); @@ -292,76 +272,53 @@ G4LogicalVolume* Nana::ConstructDetector(){ // Aluminium can around LaBr3 // LaBr3 Can - G4ThreeVector positionLaBr3Can = G4ThreeVector(0, 0, LaBr3Can_PosZ); + G4ThreeVector positionLaBr3Can = G4ThreeVector(0, 0, LaBr3Can_PosZ); - G4Tubs* solidLaBr3Can = new G4Tubs("solidLaBr3Can", 0.5*CanInnerDiameter, 0.5*CanOuterDiameter, 0.5*CanLength, 0.*deg, 360.*deg); + G4Tubs* solidLaBr3Can = new G4Tubs("solidLaBr3Can", 0.5 * CanInnerDiameter, 0.5 * CanOuterDiameter, 0.5 * CanLength, + 0. * deg, 360. * deg); G4LogicalVolume* logicLaBr3Can = new G4LogicalVolume(solidLaBr3Can, Glass, "logicLaBr3Can", 0, 0, 0); - new G4PVPlacement(0, - positionLaBr3Can, - logicLaBr3Can, - "Nana_LaBr3Can", - m_LogicalDetector, - false, - 0); + new G4PVPlacement(0, positionLaBr3Can, logicLaBr3Can, "Nana_LaBr3Can", m_LogicalDetector, false, 0); // Visualisation of LaBr3Can logicLaBr3Can->SetVisAttributes(m_DetectorCasingVisAtt); // Aluminium window in front of LaBr3 // LaBr3 Window - G4ThreeVector positionLaBr3Win = G4ThreeVector(0, 0, LaBr3Win_PosZ); + G4ThreeVector positionLaBr3Win = G4ThreeVector(0, 0, LaBr3Win_PosZ); - G4Tubs* solidLaBr3Win = new G4Tubs("solidLaBr3Win", 0.5*WinInnerDiameter, 0.5*WinOuterDiameter, 0.5*WinLength, 0.*deg, 360.*deg); + G4Tubs* solidLaBr3Win = new G4Tubs("solidLaBr3Win", 0.5 * WinInnerDiameter, 0.5 * WinOuterDiameter, 0.5 * WinLength, + 0. * deg, 360. * deg); G4LogicalVolume* logicLaBr3Win = new G4LogicalVolume(solidLaBr3Win, Alu, "logicLaBr3Win", 0, 0, 0); - new G4PVPlacement(0, - positionLaBr3Win, - logicLaBr3Win, - "Nana_LaBr3Win", - m_LogicalDetector, - false, - 0); + new G4PVPlacement(0, positionLaBr3Win, logicLaBr3Win, "Nana_LaBr3Win", m_LogicalDetector, false, 0); // Visualisation of LaBr3Win logicLaBr3Win->SetVisAttributes(m_DetectorCasingVisAtt); // PMT - G4ThreeVector positionPMT = G4ThreeVector(0, 0, PMT_PosZ); + G4ThreeVector positionPMT = G4ThreeVector(0, 0, PMT_PosZ); /* G4Tubs* solidPMout = new G4Tubs("solidPMOut", 0.5*LaBr3Face, 0.5*PMTFace, 0.5*PMTThickness, 0.*deg, 360.*deg); - G4Tubs* solidPMin = new G4Tubs("solidPMIn", 0.5*LaBr3Face-0.1*cm, 0.5*PMTFace-0.5*cm, 0.5*(PMTThickness-2.*cm)-0.1*cm, 0.*deg, 360.*deg); - G4RotationMatrix* RotMat=NULL; - const G4ThreeVector &Trans= G4ThreeVector(0.,0.,1.*cm); - G4SubtractionSolid* solidPMT = new G4SubtractionSolid("solidPMT", solidPMout,solidPMin, RotMat, Trans); + G4Tubs* solidPMin = new G4Tubs("solidPMIn", 0.5*LaBr3Face-0.1*cm, 0.5*PMTFace-0.5*cm, + 0.5*(PMTThickness-2.*cm)-0.1*cm, 0.*deg, 360.*deg); G4RotationMatrix* RotMat=NULL; const G4ThreeVector &Trans= + G4ThreeVector(0.,0.,1.*cm); G4SubtractionSolid* solidPMT = new G4SubtractionSolid("solidPMT", + solidPMout,solidPMin, RotMat, Trans); */ - G4Tubs* solidPMT= new G4Tubs("solidPMOut", 0.5*LaBr3Face, 0.5*PMTFace, 0.5*PMTThickness, 0.*deg, 360.*deg); + G4Tubs* solidPMT = + new G4Tubs("solidPMOut", 0.5 * LaBr3Face, 0.5 * PMTFace, 0.5 * PMTThickness, 0. * deg, 360. * deg); G4LogicalVolume* logicPMT = new G4LogicalVolume(solidPMT, Kovar, "logicPMT", 0, 0, 0); - G4Tubs* solidPMTWin = new G4Tubs("solidPMTWin", 0, 0.5*LaBr3Face, 0.5*WinLength, 0.*deg, 360.*deg); + G4Tubs* solidPMTWin = new G4Tubs("solidPMTWin", 0, 0.5 * LaBr3Face, 0.5 * WinLength, 0. * deg, 360. * deg); G4LogicalVolume* logicPMTWin = new G4LogicalVolume(solidPMTWin, Glass, "logicPMTWin", 0, 0, 0); + new G4PVPlacement(0, positionPMT, logicPMT, "Nana_PMT", m_LogicalDetector, false, 0); - new G4PVPlacement(0, - positionPMT, - logicPMT, - "Nana_PMT", - m_LogicalDetector, - false, - 0); - - new G4PVPlacement(0, - positionPMT+G4ThreeVector(0,0,-0.45*PMTThickness), - logicPMTWin, - "Nana_PMTWind", - m_LogicalDetector, - false, - 0); - + new G4PVPlacement(0, positionPMT + G4ThreeVector(0, 0, -0.45 * PMTThickness), logicPMTWin, "Nana_PMTWind", + m_LogicalDetector, false, 0); // Visualisation of PMT Strip logicPMT->SetVisAttributes(m_PMTVisAtt); - /* // Plastic Lead shielding //plastic definition @@ -385,24 +342,24 @@ G4LogicalVolume* Nana::ConstructDetector(){ G4Tubs* solidLeadA = new G4Tubs("solidLead", 0.5*LeadAMinR, 0.5*LeadAMaxR, 0.5*LeadALength, 0.*deg, 360.*deg); G4LogicalVolume* logicLeadAShield = new G4LogicalVolume(solidLeadA, PCA, "logicLeadAShield", 0, 0, 0); - new G4PVPlacement(0, - positionLeadAShield, - logicLeadAShield, - "Nana_LeadAShield", - m_LogicalDetector, - false, + new G4PVPlacement(0, + positionLeadAShield, + logicLeadAShield, + "Nana_LeadAShield", + m_LogicalDetector, + false, 0); // B G4ThreeVector positionLeadBShield = G4ThreeVector(0, 0, LeadBShield_PosZ); - G4Tubs* solidLeadB = new G4Tubs("solidLead", 0.5*LeadBMinR, 0.5*LeadBMaxR, 0.5*LeadBLength, 0.*deg, 360.*deg); - G4LogicalVolume* logicLeadBShield = new G4LogicalVolume(solidLeadB, PCA, "logicLeadBShield", 0, 0, 0); - - new G4PVPlacement(0, - positionLeadBShield, - logicLeadBShield, - "Nana_LeadBShield", - m_LogicalDetector, - false, + G4Tubs* solidLeadB = new G4Tubs("solidLead", 0.5*LeadBMinR, 0.5*LeadBMaxR, 0.5*LeadBLength, 0.*deg, + 360.*deg); G4LogicalVolume* logicLeadBShield = new G4LogicalVolume(solidLeadB, PCA, "logicLeadBShield", 0, 0, 0); + + new G4PVPlacement(0, + positionLeadBShield, + logicLeadBShield, + "Nana_LeadBShield", + m_LogicalDetector, + false, 0); @@ -417,36 +374,25 @@ G4LogicalVolume* Nana::ConstructDetector(){ */ // Lead shielding // A - G4ThreeVector positionLeadAShield = G4ThreeVector(0, 0, LeadAShield_PosZ); - G4Tubs* solidLeadA = new G4Tubs("solidLead", 0.5*LeadAMinR, 0.5*LeadAMaxR, 0.5*LeadALength, 0.*deg, 360.*deg); + G4ThreeVector positionLeadAShield = G4ThreeVector(0, 0, LeadAShield_PosZ); + G4Tubs* solidLeadA = + new G4Tubs("solidLead", 0.5 * LeadAMinR, 0.5 * LeadAMaxR, 0.5 * LeadALength, 0. * deg, 360. * deg); G4LogicalVolume* logicLeadAShield = new G4LogicalVolume(solidLeadA, Lead, "logicLeadAShield", 0, 0, 0); - new G4PVPlacement(0, - positionLeadAShield, - logicLeadAShield, - "Nana_LeadAShield", - m_LogicalDetector, - false, - 0); + new G4PVPlacement(0, positionLeadAShield, logicLeadAShield, "Nana_LeadAShield", m_LogicalDetector, false, 0); // B - G4ThreeVector positionLeadBShield = G4ThreeVector(0, 0, LeadBShield_PosZ); - G4Tubs* solidLeadB = new G4Tubs("solidLead", 0.5*LeadBMinR, 0.5*LeadBMaxR, 0.5*LeadBLength, 0.*deg, 360.*deg); + G4ThreeVector positionLeadBShield = G4ThreeVector(0, 0, LeadBShield_PosZ); + G4Tubs* solidLeadB = + new G4Tubs("solidLead", 0.5 * LeadBMinR, 0.5 * LeadBMaxR, 0.5 * LeadBLength, 0. * deg, 360. * deg); G4LogicalVolume* logicLeadBShield = new G4LogicalVolume(solidLeadB, Lead, "logicLeadBShield", 0, 0, 0); - new G4PVPlacement(0, - positionLeadBShield, - logicLeadBShield, - "Nana_LeadBShield", - m_LogicalDetector, - false, - 0); + new G4PVPlacement(0, positionLeadBShield, logicLeadBShield, "Nana_LeadBShield", m_LogicalDetector, false, 0); // Visualisation of PMT Strip G4VisAttributes* LeadVisAtt = new G4VisAttributes(G4Colour(.66, .66, .66)); logicLeadAShield->SetVisAttributes(LeadVisAtt); logicLeadBShield->SetVisAttributes(LeadVisAtt); - } return m_LogicalDetector; @@ -455,76 +401,73 @@ G4LogicalVolume* Nana::ConstructDetector(){ //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Add Detector branch to the EventTree. // Called After DetecorConstruction::AddDetector Method -void Nana::InitializeRootOutput(){ - RootOutput *pAnalysis = RootOutput::getInstance(); - TTree *pTree = pAnalysis->GetTree(); - if(!pTree->FindBranch("Nana")){ - pTree->Branch("Nana", "TNanaData", &m_Event) ; +void Nana::InitializeRootOutput() { + RootOutput* pAnalysis = RootOutput::getInstance(); + TTree* pTree = pAnalysis->GetTree(); + if (!pTree->FindBranch("Nana")) { + pTree->Branch("Nana", "TNanaData", &m_Event); } - pTree->SetBranchAddress("Nana", &m_Event) ; + pTree->SetBranchAddress("Nana", &m_Event); } - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Read sensitive part and fill the Root tree. // Called at in the EventAction::EndOfEventAvtion -void Nana::ReadSensitive(const G4Event* ){ +void Nana::ReadSensitive(const G4Event*) { m_Event->Clear(); /////////// - CalorimeterScorers::PS_Calorimeter* Scorer= (CalorimeterScorers::PS_Calorimeter*) m_LaBr3Scorer->GetPrimitive(0); - - unsigned int size = Scorer->GetMult(); - for(unsigned int i = 0 ; i < size ; i++){ - double E = Scorer->GetEnergy(i); - double Energy = RandGauss::shoot(E,(E*0.0325637)/(2.35*pow(E-0.00975335,0.475759))); - if(Energy>EnergyThreshold){ - double Time = Scorer->GetTime(i); - int DetectorNbr = Scorer->GetLevel(i)[0]; - m_Event->SetNanaLaBr3(DetectorNbr,Energy,Energy,(unsigned short) Time,0,0); + CalorimeterScorers::PS_Calorimeter* Scorer = (CalorimeterScorers::PS_Calorimeter*)m_LaBr3Scorer->GetPrimitive(0); + + unsigned int size = Scorer->GetMult(); + for (unsigned int i = 0; i < size; i++) { + double E = Scorer->GetEnergy(i); + double Energy = RandGauss::shoot(E, (E * 0.0325637) / (2.35 * pow(E - 0.00975335, 0.475759))); + if (Energy > EnergyThreshold) { + double Time = Scorer->GetTime(i); + int DetectorNbr = Scorer->GetLevel(i)[0]; + m_Event->SetNanaLaBr3(DetectorNbr, Energy, Energy, (unsigned short)Time, 0, 0); } } } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Nana::InitializeScorers(){ +void Nana::InitializeScorers() { vector<G4int> NestingLevel; NestingLevel.push_back(1); // LaBr3 Associate Scorer bool already_exist = false; - m_LaBr3Scorer = CheckScorer("Nana_LaBr3Scorer",already_exist); + m_LaBr3Scorer = CheckScorer("Nana_LaBr3Scorer", already_exist); // if the scorer were created previously nothing else need to be made - if(already_exist) return; + if (already_exist) + return; - G4VPrimitiveScorer* LaBr3Scorer = - new CalorimeterScorers::PS_Calorimeter("NanaLaBr3",NestingLevel); - //and register it to the multifunctionnal detector + G4VPrimitiveScorer* LaBr3Scorer = new CalorimeterScorers::PS_Calorimeter("NanaLaBr3", NestingLevel); + // and register it to the multifunctionnal detector m_LaBr3Scorer->RegisterPrimitive(LaBr3Scorer); // Add All Scorer to the Global Scorer Manager - G4SDManager::GetSDMpointer()->AddNewDetector(m_LaBr3Scorer) ; + G4SDManager::GetSDMpointer()->AddNewDetector(m_LaBr3Scorer); } //////////////////////////////////////////////////////////////////////////////// // Construct Method to be pass to the DetectorFactory // //////////////////////////////////////////////////////////////////////////////// -NPS::VDetector* Nana::Construct(){ - return (NPS::VDetector*) new Nana(); -} +NPS::VDetector* Nana::Construct() { return (NPS::VDetector*)new Nana(); } //////////////////////////////////////////////////////////////////////////////// // Registering the construct method to the factory // //////////////////////////////////////////////////////////////////////////////// -extern"C" { - class proxy_nps_nana{ - public: - proxy_nps_nana(){ - NPS::DetectorFactory::getInstance()->AddToken("Nana","Nana"); - NPS::DetectorFactory::getInstance()->AddDetector("Nana",Nana::Construct); - } - }; - - proxy_nps_nana p_nps_nana; +extern "C" { +class proxy_nps_nana { + public: + proxy_nps_nana() { + NPS::DetectorFactory::getInstance()->AddToken("Nana", "Nana"); + NPS::DetectorFactory::getInstance()->AddDetector("Nana", Nana::Construct); + } +}; + +proxy_nps_nana p_nps_nana; } diff --git a/NPSimulation/Detectors/Nebula/Nebula.cc b/NPSimulation/Detectors/Nebula/Nebula.cc index 98648115abb66c4a727571d4b2d433256dd550b0..11d1b18eb5340018635b9ac8e5f80d6bb180fca4 100644 --- a/NPSimulation/Detectors/Nebula/Nebula.cc +++ b/NPSimulation/Detectors/Nebula/Nebula.cc @@ -40,7 +40,7 @@ // NPTool header #include "Nebula.hh" -#include "CalorimeterScorers.hh" +#include "PlasticBar.hh" #include "InteractionScorers.hh" #include "RootOutput.h" #include "MaterialManager.hh" @@ -216,7 +216,7 @@ void Nebula::ReadSensitive(const G4Event* ){ /////////// // Module scorer - CalorimeterScorers::PS_Calorimeter* Scorer= (CalorimeterScorers::PS_Calorimeter*) m_ModuleScorer->GetPrimitive(0); + PlasticBar::PS_PlasticBar* Scorer= (PlasticBar::PS_PlasticBar*) m_ModuleScorer->GetPrimitive(0); unsigned int size = Scorer->GetMult(); for(unsigned int i = 0 ; i < size ; i++){ @@ -225,8 +225,10 @@ void Nebula::ReadSensitive(const G4Event* ){ if(Energy>Nebula_NS::EnergyThreshold){ double Time = RandGauss::shoot(Scorer->GetTime(i),Nebula_NS::ResoTime); int DetectorNbr = level[0]; - //m_Event->SetEnergy(DetectorNbr,Energy); - //m_Event->SetTime(DetectorNbr,Time); + m_Event->SetChargeUp(DetectorNbr,Energy/2); + m_Event->SetChargeDown(DetectorNbr,Energy/2); + m_Event->SetTimeUp(DetectorNbr,Time/2); + m_Event->SetTimeDown(DetectorNbr,Time/2); } } } @@ -245,18 +247,18 @@ void Nebula::InitializeScorers() { // Otherwise the scorer is initialise // Module vector<int> level; level.push_back(0); - G4VPrimitiveScorer* ModuleCalorimeter= new CalorimeterScorers::PS_Calorimeter("ModuleCalorimeter",level, 0) ; + G4VPrimitiveScorer* ModulePlasticBar= new PlasticBar::PS_PlasticBar("ModulePlasticBar",level, 0) ; G4VPrimitiveScorer* ModuleInteraction= new InteractionScorers::PS_Interactions("ModuleInteraction",ms_InterCoord, 0) ; //and register it to the multifunctionnal detector - m_ModuleScorer->RegisterPrimitive(ModuleCalorimeter); + m_ModuleScorer->RegisterPrimitive(ModulePlasticBar); m_ModuleScorer->RegisterPrimitive(ModuleInteraction); G4SDManager::GetSDMpointer()->AddNewDetector(m_ModuleScorer) ; // Veto - G4VPrimitiveScorer* VetoCalorimeter= new CalorimeterScorers::PS_Calorimeter("VetoCalorimeter",level, 0) ; + G4VPrimitiveScorer* VetoPlasticBar= new PlasticBar::PS_PlasticBar("VetoPlasticBar",level, 0) ; G4VPrimitiveScorer* VetoInteraction= new InteractionScorers::PS_Interactions("VetoInteraction",ms_InterCoord, 0) ; //and register it to the multifunctionnal detector - m_VetoScorer->RegisterPrimitive(VetoCalorimeter); + m_VetoScorer->RegisterPrimitive(VetoPlasticBar); m_VetoScorer->RegisterPrimitive(VetoInteraction); G4SDManager::GetSDMpointer()->AddNewDetector(m_VetoScorer) ; diff --git a/NPSimulation/Detectors/Paris/Paris.cc b/NPSimulation/Detectors/Paris/Paris.cc index 21d25b80ad1b79fb6e29ccef18a9bd949b69363a..8ab683330c261a545a1f7b96f9254488fee206b9 100644 --- a/NPSimulation/Detectors/Paris/Paris.cc +++ b/NPSimulation/Detectors/Paris/Paris.cc @@ -20,21 +20,21 @@ *****************************************************************************/ // C++ headers -#include <sstream> #include <cmath> #include <limits> +#include <sstream> using namespace std; -//Geant4 -#include "G4VSolid.hh" +// Geant4 #include "G4Box.hh" -#include "G4Tubs.hh" -#include "G4UnionSolid.hh" -#include "G4SubtractionSolid.hh" +#include "G4Colour.hh" +#include "G4PVPlacement.hh" #include "G4SDManager.hh" +#include "G4SubtractionSolid.hh" #include "G4Transform3D.hh" -#include "G4PVPlacement.hh" -#include "G4Colour.hh" +#include "G4Tubs.hh" +#include "G4UnionSolid.hh" +#include "G4VSolid.hh" // NPS #include "Paris.hh" @@ -53,11 +53,11 @@ using namespace CLHEP; //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Paris Specific Method -Paris::Paris(){ +Paris::Paris() { m_Event = new TParisData(); - // Orange - m_NaIVisAtt = new G4VisAttributes(G4Colour(1, 0.5, 0)) ; + // Orange + m_NaIVisAtt = new G4VisAttributes(G4Colour(1, 0.5, 0)); // Blue m_LaBr3VisAtt = new G4VisAttributes(G4Colour(0, 0.5, 1)); @@ -66,36 +66,36 @@ Paris::Paris(){ m_PMTVisAtt = new G4VisAttributes(G4Colour(0.1, 0.1, 0.1)); // Grey wireframe - m_PhoswichCasingVisAtt = new G4VisAttributes(G4Colour(0.5, 0.5, 0.5,0.2)); + m_PhoswichCasingVisAtt = new G4VisAttributes(G4Colour(0.5, 0.5, 0.5, 0.2)); // White wireframe - m_ClusterCasingVisAtt = new G4VisAttributes(G4Colour(0.7, 0.7, 0.7)); + m_ClusterCasingVisAtt = new G4VisAttributes(G4Colour(0.7, 0.7, 0.7)); m_LogicalPhoswich = 0; - m_LogicalCluster = 0; - m_NaIScorer = 0 ; - m_LaBr3Scorer = 0 ; + m_LogicalCluster = 0; + m_NaIScorer = 0; + m_LaBr3Scorer = 0; } -Paris::~Paris(){ -} +Paris::~Paris() {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Paris::AddCluster(G4ThreeVector Pos1, G4ThreeVector Pos2, G4ThreeVector Pos3, G4ThreeVector Pos4){ - G4ThreeVector Pos=(Pos1+Pos2+Pos3+Pos4)/4.; - G4ThreeVector u = Pos1-Pos2; - G4ThreeVector v = Pos1-Pos4; - u = u.unit(); v = v.unit(); +void Paris::AddCluster(G4ThreeVector Pos1, G4ThreeVector Pos2, G4ThreeVector Pos3, G4ThreeVector Pos4) { + G4ThreeVector Pos = (Pos1 + Pos2 + Pos3 + Pos4) / 4.; + G4ThreeVector u = Pos1 - Pos2; + G4ThreeVector v = Pos1 - Pos4; + u = u.unit(); + v = v.unit(); G4ThreeVector w = v.cross(u); - Pos = Pos + w*Length*0.5; + Pos = Pos + w * Length * 0.5; - m_Type.push_back(1); + m_Type.push_back(1); m_Pos.push_back(Pos); - m_Rot.push_back(new G4RotationMatrix(u,v,w)); + m_Rot.push_back(new G4RotationMatrix(u, v, w)); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Paris::AddCluster(G4ThreeVector Pos, double beta_u, double beta_v, double beta_w){ +void Paris::AddCluster(G4ThreeVector Pos, double beta_u, double beta_v, double beta_w) { double Theta = Pos.theta(); double Phi = Pos.phi(); @@ -111,10 +111,10 @@ void Paris::AddCluster(G4ThreeVector Pos, double beta_u, double beta_v, double b v = v.unit(); u = u.unit(); - G4RotationMatrix* r = new G4RotationMatrix(u,v,w); - r->rotate(beta_u,u); - r->rotate(beta_v,v); - r->rotate(beta_w,w); + G4RotationMatrix* r = new G4RotationMatrix(u, v, w); + r->rotate(beta_u, u); + r->rotate(beta_v, v); + r->rotate(beta_w, w); m_Type.push_back(1); m_Pos.push_back(Pos); @@ -122,21 +122,22 @@ void Paris::AddCluster(G4ThreeVector Pos, double beta_u, double beta_v, double b } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Paris::AddPhoswich(G4ThreeVector Pos1, G4ThreeVector Pos2, G4ThreeVector Pos3, G4ThreeVector Pos4){ - G4ThreeVector Pos=(Pos1+Pos2+Pos3+Pos4)/4.; - G4ThreeVector u = Pos1-Pos2; - G4ThreeVector v = Pos1-Pos4; - u = u.unit(); v = v.unit(); +void Paris::AddPhoswich(G4ThreeVector Pos1, G4ThreeVector Pos2, G4ThreeVector Pos3, G4ThreeVector Pos4) { + G4ThreeVector Pos = (Pos1 + Pos2 + Pos3 + Pos4) / 4.; + G4ThreeVector u = Pos1 - Pos2; + G4ThreeVector v = Pos1 - Pos4; + u = u.unit(); + v = v.unit(); G4ThreeVector w = Pos.unit(); - Pos = Pos + w*Length*0.5; + Pos = Pos + w * Length * 0.5; - m_Type.push_back(0); + m_Type.push_back(0); m_Pos.push_back(Pos); - m_Rot.push_back(new G4RotationMatrix(u,v,w)); + m_Rot.push_back(new G4RotationMatrix(u, v, w)); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Paris::AddPhoswich(G4ThreeVector Pos, double beta_u, double beta_v, double beta_w){ +void Paris::AddPhoswich(G4ThreeVector Pos, double beta_u, double beta_v, double beta_w) { double Theta = Pos.theta(); double Phi = Pos.phi(); @@ -152,10 +153,10 @@ void Paris::AddPhoswich(G4ThreeVector Pos, double beta_u, double beta_v, double v = v.unit(); u = u.unit(); - G4RotationMatrix* r = new G4RotationMatrix(u,v,w); - r->rotate(beta_u,u); - r->rotate(beta_v,v); - r->rotate(beta_w,w); + G4RotationMatrix* r = new G4RotationMatrix(u, v, w); + r->rotate(beta_u, u); + r->rotate(beta_v, v); + r->rotate(beta_w, w); m_Type.push_back(0); m_Pos.push_back(Pos); @@ -166,60 +167,60 @@ void Paris::AddPhoswich(G4ThreeVector Pos, double beta_u, double beta_v, double // Virtual Method of NPS::VDetector class // Read stream at Configfile to pick-up parameters of detector (Position,...) // Called in DetecorConstruction::ReadDetextorConfiguration Method -void Paris::ReadConfiguration(NPL::InputParser parser){ +void Paris::ReadConfiguration(NPL::InputParser parser) { vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithToken("Paris"); - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << "//// " << blocks.size() << " detectors found " << endl; - - vector<string> cart = {"A","B","C","D"}; - vector<string> sphe = {"R","THETA","PHI","BETA"}; - - for(unsigned int i = 0 ; i < blocks.size() ; i++){ - if(blocks[i]->HasTokenList(cart) && blocks[i]->GetMainValue()=="Cluster"){ - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << endl << "//// Cluster " << i+1 << endl; - G4ThreeVector A = NPS::ConvertVector(blocks[i]->GetTVector3("A","mm")); - G4ThreeVector B = NPS::ConvertVector(blocks[i]->GetTVector3("B","mm")); - G4ThreeVector C = NPS::ConvertVector(blocks[i]->GetTVector3("C","mm")); - G4ThreeVector D = NPS::ConvertVector(blocks[i]->GetTVector3("D","mm")); - - AddCluster(A,B,C,D); + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks.size() << " detectors found " << endl; + + vector<string> cart = {"A", "B", "C", "D"}; + vector<string> sphe = {"R", "THETA", "PHI", "BETA"}; + + for (unsigned int i = 0; i < blocks.size(); i++) { + if (blocks[i]->HasTokenList(cart) && blocks[i]->GetMainValue() == "Cluster") { + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// Cluster " << i + 1 << endl; + G4ThreeVector A = NPS::ConvertVector(blocks[i]->GetTVector3("A", "mm")); + G4ThreeVector B = NPS::ConvertVector(blocks[i]->GetTVector3("B", "mm")); + G4ThreeVector C = NPS::ConvertVector(blocks[i]->GetTVector3("C", "mm")); + G4ThreeVector D = NPS::ConvertVector(blocks[i]->GetTVector3("D", "mm")); + + AddCluster(A, B, C, D); } - else if(blocks[i]->HasTokenList(sphe)&& blocks[i]->GetMainValue()=="Cluster"){ - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << endl << "//// Cluster " << i+1 << endl; - double R = blocks[i]->GetDouble("R","mm"); - double Theta = blocks[i]->GetDouble("THETA","deg"); - double Phi = blocks[i]->GetDouble("PHI","deg"); - vector<double> Beta = blocks[i]->GetVectorDouble("BETA","deg"); - R = R + 0.5*Length; - G4ThreeVector Pos(R*sin(Theta)*cos(Phi),R*sin(Theta)*sin(Phi),R*cos(Theta)); - AddCluster(Pos,Beta[0],Beta[1],Beta[2]); + else if (blocks[i]->HasTokenList(sphe) && blocks[i]->GetMainValue() == "Cluster") { + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// Cluster " << i + 1 << endl; + double R = blocks[i]->GetDouble("R", "mm"); + double Theta = blocks[i]->GetDouble("THETA", "deg"); + double Phi = blocks[i]->GetDouble("PHI", "deg"); + vector<double> Beta = blocks[i]->GetVectorDouble("BETA", "deg"); + R = R + 0.5 * Length; + G4ThreeVector Pos(R * sin(Theta) * cos(Phi), R * sin(Theta) * sin(Phi), R * cos(Theta)); + AddCluster(Pos, Beta[0], Beta[1], Beta[2]); } - else if(blocks[i]->HasTokenList(cart)&& blocks[i]->GetMainValue()=="Phoswich"){ - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << endl << "//// Phoswich" << i+1 << endl; - G4ThreeVector A = NPS::ConvertVector(blocks[i]->GetTVector3("A","mm")); - G4ThreeVector B = NPS::ConvertVector(blocks[i]->GetTVector3("B","mm")); - G4ThreeVector C = NPS::ConvertVector(blocks[i]->GetTVector3("C","mm")); - G4ThreeVector D = NPS::ConvertVector(blocks[i]->GetTVector3("D","mm")); - - AddPhoswich(A,B,C,D); + else if (blocks[i]->HasTokenList(cart) && blocks[i]->GetMainValue() == "Phoswich") { + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// Phoswich" << i + 1 << endl; + G4ThreeVector A = NPS::ConvertVector(blocks[i]->GetTVector3("A", "mm")); + G4ThreeVector B = NPS::ConvertVector(blocks[i]->GetTVector3("B", "mm")); + G4ThreeVector C = NPS::ConvertVector(blocks[i]->GetTVector3("C", "mm")); + G4ThreeVector D = NPS::ConvertVector(blocks[i]->GetTVector3("D", "mm")); + + AddPhoswich(A, B, C, D); } - else if(blocks[i]->HasTokenList(sphe)&& blocks[i]->GetMainValue()=="Phoswich"){ - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << endl << "//// Phoswich " << i+1 << endl; - double R = blocks[i]->GetDouble("R","mm"); - double Theta = blocks[i]->GetDouble("THETA","deg"); - double Phi = blocks[i]->GetDouble("PHI","deg"); - vector<double> Beta = blocks[i]->GetVectorDouble("BETA","deg"); - R = R + 0.5*Length; - G4ThreeVector Pos(R*sin(Theta)*cos(Phi),R*sin(Theta)*sin(Phi),R*cos(Theta)); - AddPhoswich(Pos,Beta[0],Beta[1],Beta[2]); + else if (blocks[i]->HasTokenList(sphe) && blocks[i]->GetMainValue() == "Phoswich") { + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// Phoswich " << i + 1 << endl; + double R = blocks[i]->GetDouble("R", "mm"); + double Theta = blocks[i]->GetDouble("THETA", "deg"); + double Phi = blocks[i]->GetDouble("PHI", "deg"); + vector<double> Beta = blocks[i]->GetVectorDouble("BETA", "deg"); + R = R + 0.5 * Length; + G4ThreeVector Pos(R * sin(Theta) * cos(Phi), R * sin(Theta) * sin(Phi), R * cos(Theta)); + AddPhoswich(Pos, Beta[0], Beta[1], Beta[2]); } - else{ + else { cout << "ERROR: check your input file formatting " << endl; exit(1); } @@ -229,92 +230,72 @@ void Paris::ReadConfiguration(NPL::InputParser parser){ //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Construct detector and inialise sensitive part. // Called After DetecorConstruction::AddDetector Method -void Paris::ConstructDetector(G4LogicalVolume* world){ +void Paris::ConstructDetector(G4LogicalVolume* world) { unsigned int mysize = m_Pos.size(); - for(unsigned int i = 0 ; i < mysize ; i++){ - if(m_Type[i]) - new G4PVPlacement(G4Transform3D(*m_Rot[i], m_Pos[i]), ConstructCluster(), "ParisCluster", world, false, i+1); + for (unsigned int i = 0; i < mysize; i++) { + if (m_Type[i]) + new G4PVPlacement(G4Transform3D(*m_Rot[i], m_Pos[i]), ConstructCluster(), "ParisCluster", world, false, i + 1); else - new G4PVPlacement(G4Transform3D(*m_Rot[i], m_Pos[i]), ConstructPhoswich(), "ParisPhoswich", world, false, i+1); + new G4PVPlacement(G4Transform3D(*m_Rot[i], m_Pos[i]), ConstructPhoswich(), "ParisPhoswich", world, false, i + 1); } } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -G4LogicalVolume* Paris::ConstructPhoswich(){ +G4LogicalVolume* Paris::ConstructPhoswich() { - if(!m_LogicalPhoswich){ + if (!m_LogicalPhoswich) { G4Material* Vacuum = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); G4Material* Alu = MaterialManager::getInstance()->GetMaterialFromLibrary("Al"); G4Material* NaI = MaterialManager::getInstance()->GetMaterialFromLibrary("NaI"); G4Material* LaBr3 = MaterialManager::getInstance()->GetMaterialFromLibrary("LaBr3"); - G4Box* solidParisPhoswich = new G4Box("SolidParisPhoswich", 0.5*PhoswichCasingWidth, 0.5*PhoswichCasingWidth, 0.5*PhoswichCasingLenth+0.5*PMTLength); + G4Box* solidParisPhoswich = new G4Box("SolidParisPhoswich", 0.5 * PhoswichCasingWidth, 0.5 * PhoswichCasingWidth, + 0.5 * PhoswichCasingLenth + 0.5 * PMTLength); m_LogicalPhoswich = new G4LogicalVolume(solidParisPhoswich, Vacuum, "LogicParisPhoswich", 0, 0, 0); - m_LogicalPhoswich->SetVisAttributes(G4VisAttributes::Invisible); + m_LogicalPhoswich->SetVisAttributes(G4VisAttributes::GetInvisible()); // Phoswich construction // Casing - G4Box* solidCasing = new G4Box("SolidParisPhoswichCasing", 0.5*PhoswichCasingWidth, 0.5*PhoswichCasingWidth, 0.5*PhoswichCasingLenth); + G4Box* solidCasing = new G4Box("SolidParisPhoswichCasing", 0.5 * PhoswichCasingWidth, 0.5 * PhoswichCasingWidth, + 0.5 * PhoswichCasingLenth); G4LogicalVolume* LogicalCasing = new G4LogicalVolume(solidCasing, Alu, "LogicParisPhoswichCasing", 0, 0, 0); LogicalCasing->SetVisAttributes(m_PhoswichCasingVisAtt); - new G4PVPlacement(0, - G4ThreeVector(0,0,-PMTLength), - LogicalCasing, - "ParisPhoswich_Casing", - m_LogicalPhoswich, - false, - 0); + new G4PVPlacement(0, G4ThreeVector(0, 0, -PMTLength), LogicalCasing, "ParisPhoswich_Casing", m_LogicalPhoswich, + false, 0); // PMT - G4Tubs* solidPMT = new G4Tubs("SolidPMT",0,PMTRadius,0.5*PMTLength,0,360*deg); - G4LogicalVolume* LogicalPMT = new G4LogicalVolume(solidPMT, Alu, "LogicPMT" ,0,0,0); - new G4PVPlacement(0, - G4ThreeVector(0,0,0.5*Length-PMTLength), - LogicalPMT, - "ParisPhoswich_PMT", - m_LogicalPhoswich, - false, - 0); + G4Tubs* solidPMT = new G4Tubs("SolidPMT", 0, PMTRadius, 0.5 * PMTLength, 0, 360 * deg); + G4LogicalVolume* LogicalPMT = new G4LogicalVolume(solidPMT, Alu, "LogicPMT", 0, 0, 0); + new G4PVPlacement(0, G4ThreeVector(0, 0, 0.5 * Length - PMTLength), LogicalPMT, "ParisPhoswich_PMT", + m_LogicalPhoswich, false, 0); LogicalPMT->SetVisAttributes(m_PMTVisAtt); // LaBr3 - G4Box* solidLaBr3Stage = new G4Box("solidLaBr3Stage", 0.5*LaBr3Face, 0.5*LaBr3Face, 0.5*LaBr3Thickness); + G4Box* solidLaBr3Stage = new G4Box("solidLaBr3Stage", 0.5 * LaBr3Face, 0.5 * LaBr3Face, 0.5 * LaBr3Thickness); G4LogicalVolume* logicLaBr3Stage = new G4LogicalVolume(solidLaBr3Stage, LaBr3, "logicLaBr3Stage", 0, 0, 0); - G4ThreeVector positionLaBr3Stage = G4ThreeVector(0, 0, LaBr3Stage_PosZ); + G4ThreeVector positionLaBr3Stage = G4ThreeVector(0, 0, LaBr3Stage_PosZ); - new G4PVPlacement(0, - positionLaBr3Stage, - logicLaBr3Stage, - "ParisPhoswich_LaBr3Stage", - LogicalCasing, - false, - 0); + new G4PVPlacement(0, positionLaBr3Stage, logicLaBr3Stage, "ParisPhoswich_LaBr3Stage", LogicalCasing, false, 0); // Set LaBr3 sensible logicLaBr3Stage->SetSensitiveDetector(m_LaBr3Scorer); - // Visualisation of LaBr3 stage + // Visualisation of LaBr3 stage logicLaBr3Stage->SetVisAttributes(m_LaBr3VisAtt); // NaI - G4ThreeVector positionNaIStage = G4ThreeVector(0, 0, NaIStage_PosZ); + G4ThreeVector positionNaIStage = G4ThreeVector(0, 0, NaIStage_PosZ); - G4Box* solidNaIStage = new G4Box("solidNaIStage", 0.5*NaIFace, 0.5*NaIFace, 0.5*NaIThickness); + G4Box* solidNaIStage = new G4Box("solidNaIStage", 0.5 * NaIFace, 0.5 * NaIFace, 0.5 * NaIThickness); G4LogicalVolume* logicNaIStage = new G4LogicalVolume(solidNaIStage, NaI, "logicNaIStage", 0, 0, 0); - new G4PVPlacement(0, - positionNaIStage, - logicNaIStage, - "ParisPhoswich_NaIStage", - LogicalCasing, - false, - 0); + new G4PVPlacement(0, positionNaIStage, logicNaIStage, "ParisPhoswich_NaIStage", LogicalCasing, false, 0); // Set NaI sensible logicNaIStage->SetSensitiveDetector(m_NaIScorer); - // Visualisation of the NaI stage + // Visualisation of the NaI stage logicNaIStage->SetVisAttributes(m_NaIVisAtt); } @@ -322,177 +303,162 @@ G4LogicalVolume* Paris::ConstructPhoswich(){ } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -G4LogicalVolume* Paris::ConstructCluster(){ +G4LogicalVolume* Paris::ConstructCluster() { - if(!m_LogicalCluster){ - G4Material* Vacuum = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); - G4Material* Alu = MaterialManager::getInstance()->GetMaterialFromLibrary("Al"); + if (!m_LogicalCluster) { + G4Material* Vacuum = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); + G4Material* Alu = MaterialManager::getInstance()->GetMaterialFromLibrary("Al"); // Mother Volume - G4Box* solidParisCluster1 = new G4Box("SolidParisCluster1", 0.5*FaceFront, 0.5*FaceFront, 0.5*Length); - G4Box* solidParisCluster2 = new G4Box("SolidParisCluster2", 0.5*ClusterFrameWidth, 0.5*ClusterFrameWidth, 0.5*ClusterFrameLength); + G4Box* solidParisCluster1 = new G4Box("SolidParisCluster1", 0.5 * FaceFront, 0.5 * FaceFront, 0.5 * Length); + G4Box* solidParisCluster2 = + new G4Box("SolidParisCluster2", 0.5 * ClusterFrameWidth, 0.5 * ClusterFrameWidth, 0.5 * ClusterFrameLength); // The cluster is made of a metal frame that hold the phoswich via the pmt - G4ThreeVector FramePos(0,0,Length*0.5-PMTLength+ClusterFrameLength*0.5+ClusterOffset); - G4UnionSolid* solidParisCluster = new G4UnionSolid("solidParisCluster",solidParisCluster1,solidParisCluster2,0,FramePos); + G4ThreeVector FramePos(0, 0, Length * 0.5 - PMTLength + ClusterFrameLength * 0.5 + ClusterOffset); + G4UnionSolid* solidParisCluster = + new G4UnionSolid("solidParisCluster", solidParisCluster1, solidParisCluster2, 0, FramePos); m_LogicalCluster = new G4LogicalVolume(solidParisCluster, Vacuum, "LogicSolidParisCluster", 0, 0, 0); - m_LogicalCluster->SetVisAttributes(G4VisAttributes::Invisible); + m_LogicalCluster->SetVisAttributes(G4VisAttributes::GetInvisible()); - if(!m_LogicalPhoswich) ConstructPhoswich(); + if (!m_LogicalPhoswich) + ConstructPhoswich(); // The frame is a plate with hole for the PMT G4VSolid* solidClusterFrame = solidParisCluster2; - G4ThreeVector Origin(-PhoswichCasingWidth,-PhoswichCasingWidth,0.5*PMTLength); - G4Tubs* solidPMT = new G4Tubs("SolidPMT",0,PMTRadius,10*PMTLength,0,360*deg); + G4ThreeVector Origin(-PhoswichCasingWidth, -PhoswichCasingWidth, 0.5 * PMTLength); + G4Tubs* solidPMT = new G4Tubs("SolidPMT", 0, PMTRadius, 10 * PMTLength, 0, 360 * deg); // A cluster is a 3 by 3 aggregat of phoswich unsigned int PhoswichNbr = 1; - for(unsigned int i = 0 ; i < 3 ; i++){ - for(unsigned int j = 0 ; j <3 ; j++){ - G4ThreeVector Pos = Origin + G4ThreeVector(i*PhoswichCasingWidth,j*PhoswichCasingWidth,0); - new G4PVPlacement(0, - Pos, - m_LogicalPhoswich, - "Paris_Phoswich", - m_LogicalCluster, - false, - PhoswichNbr++); + for (unsigned int i = 0; i < 3; i++) { + for (unsigned int j = 0; j < 3; j++) { + G4ThreeVector Pos = Origin + G4ThreeVector(i * PhoswichCasingWidth, j * PhoswichCasingWidth, 0); + new G4PVPlacement(0, Pos, m_LogicalPhoswich, "Paris_Phoswich", m_LogicalCluster, false, PhoswichNbr++); // make room for the PMT in the cluster frame - solidClusterFrame = new G4SubtractionSolid("ClusterFrame",solidClusterFrame,solidPMT,0,Pos); + solidClusterFrame = new G4SubtractionSolid("ClusterFrame", solidClusterFrame, solidPMT, 0, Pos); } } - G4LogicalVolume* LogicalClusterFrame = new G4LogicalVolume(solidClusterFrame, Alu, "LogicSolidClusterFrame", 0, 0, 0); + G4LogicalVolume* LogicalClusterFrame = + new G4LogicalVolume(solidClusterFrame, Alu, "LogicSolidClusterFrame", 0, 0, 0); LogicalClusterFrame->SetVisAttributes(m_ClusterCasingVisAtt); - new G4PVPlacement(0, - FramePos, - LogicalClusterFrame, - "Paris_ClusterFrame", - m_LogicalCluster, - false, - 0); - + new G4PVPlacement(0, FramePos, LogicalClusterFrame, "Paris_ClusterFrame", m_LogicalCluster, false, 0); } return m_LogicalCluster; - } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Add Detector branch to the EventTree. // Called After DetecorConstruction::AddDetector Method -void Paris::InitializeRootOutput(){ - RootOutput *pAnalysis = RootOutput::getInstance(); - TTree *pTree = pAnalysis->GetTree(); - if(!pTree->FindBranch("Paris")){ - pTree->Branch("Paris", "TParisData", &m_Event) ; +void Paris::InitializeRootOutput() { + RootOutput* pAnalysis = RootOutput::getInstance(); + TTree* pTree = pAnalysis->GetTree(); + if (!pTree->FindBranch("Paris")) { + pTree->Branch("Paris", "TParisData", &m_Event); } - pTree->SetBranchAddress("Paris", &m_Event) ; + pTree->SetBranchAddress("Paris", &m_Event); } - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Read sensitive part and fill the Root tree. // Called at in the EventAction::EndOfEventAvtion -void Paris::ReadSensitive(const G4Event* ){ +void Paris::ReadSensitive(const G4Event*) { m_Event->Clear(); /////////// // LaBr3 - CalorimeterScorers::PS_Calorimeter* ScorerLaBr= (CalorimeterScorers::PS_Calorimeter*) m_LaBr3Scorer->GetPrimitive(0); + CalorimeterScorers::PS_Calorimeter* ScorerLaBr = (CalorimeterScorers::PS_Calorimeter*)m_LaBr3Scorer->GetPrimitive(0); - unsigned int sizeLaBr = ScorerLaBr->GetMult(); - for(unsigned int i = 0 ; i < sizeLaBr ; i++){ - vector<unsigned int> level = ScorerLaBr->GetLevel(i); - double Energy = RandGauss::shoot(ScorerLaBr->GetEnergy(i),ResoFirstStage); + unsigned int sizeLaBr = ScorerLaBr->GetMult(); + for (unsigned int i = 0; i < sizeLaBr; i++) { + vector<unsigned int> level = ScorerLaBr->GetLevel(i); + double Energy = RandGauss::shoot(ScorerLaBr->GetEnergy(i), ResoFirstStage); - if(Energy>EnergyThreshold){ + if (Energy > EnergyThreshold) { double Time = ScorerLaBr->GetTime(i); int PhoswichNbr = level[0]; int ClusterNbr = level[1]; - m_Event->SetParisLaBr3E(ClusterNbr,PhoswichNbr,Energy); - m_Event->SetParisLaBr3T(ClusterNbr,PhoswichNbr,Time); + m_Event->SetParisLaBr3E(ClusterNbr, PhoswichNbr, Energy); + m_Event->SetParisLaBr3T(ClusterNbr, PhoswichNbr, Time); } } /////////// // NaI - CalorimeterScorers::PS_Calorimeter* ScorerNaI= (CalorimeterScorers::PS_Calorimeter*) m_NaIScorer->GetPrimitive(0); + CalorimeterScorers::PS_Calorimeter* ScorerNaI = (CalorimeterScorers::PS_Calorimeter*)m_NaIScorer->GetPrimitive(0); - unsigned int sizeNaI = ScorerNaI->GetMult(); - for(unsigned int i = 0 ; i < sizeNaI ; i++){ - vector<unsigned int> level = ScorerNaI->GetLevel(i); - double Energy = RandGauss::shoot(ScorerNaI->GetEnergy(i),ResoSecondStage); + unsigned int sizeNaI = ScorerNaI->GetMult(); + for (unsigned int i = 0; i < sizeNaI; i++) { + vector<unsigned int> level = ScorerNaI->GetLevel(i); + double Energy = RandGauss::shoot(ScorerNaI->GetEnergy(i), ResoSecondStage); - if(Energy>EnergyThreshold){ + if (Energy > EnergyThreshold) { double Time = ScorerNaI->GetTime(i); int PhoswichNbr = level[0]; int ClusterNbr = level[1]; - m_Event->SetParisNaIE(ClusterNbr,PhoswichNbr,Energy); - m_Event->SetParisNaIT(ClusterNbr,PhoswichNbr,Time); + m_Event->SetParisNaIE(ClusterNbr, PhoswichNbr, Energy); + m_Event->SetParisNaIT(ClusterNbr, PhoswichNbr, Time); } } } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Paris::InitializeScorers(){ +void Paris::InitializeScorers() { vector<G4int> NestingLevel; NestingLevel.push_back(2); NestingLevel.push_back(3); // LaBr3 Associate Scorer bool already_exist = false; - m_LaBr3Scorer = CheckScorer("Paris_LaBr3Scorer",already_exist); + m_LaBr3Scorer = CheckScorer("Paris_LaBr3Scorer", already_exist); // if the scorer were created previously nothing else need to be made - if(already_exist) return; + if (already_exist) + return; - G4VPrimitiveScorer* LaBr3Scorer = - new CalorimeterScorers::PS_Calorimeter("ParisLaBr3",NestingLevel); - //and register it to the multifunctionnal detector + G4VPrimitiveScorer* LaBr3Scorer = new CalorimeterScorers::PS_Calorimeter("ParisLaBr3", NestingLevel); + // and register it to the multifunctionnal detector m_LaBr3Scorer->RegisterPrimitive(LaBr3Scorer); // Add All Scorer to the Global Scorer Manager - G4SDManager::GetSDMpointer()->AddNewDetector(m_LaBr3Scorer) ; - + G4SDManager::GetSDMpointer()->AddNewDetector(m_LaBr3Scorer); // NaI Associate Scorer already_exist = false; - m_NaIScorer = CheckScorer("Paris_NaIScorer",already_exist); + m_NaIScorer = CheckScorer("Paris_NaIScorer", already_exist); // if the scorer were created previously nothing else need to be made - if(already_exist) return; + if (already_exist) + return; - G4VPrimitiveScorer* NaIScorer = - new CalorimeterScorers::PS_Calorimeter("ParisNaI",NestingLevel); - //and register it to the multifunctionnal detector + G4VPrimitiveScorer* NaIScorer = new CalorimeterScorers::PS_Calorimeter("ParisNaI", NestingLevel); + // and register it to the multifunctionnal detector m_NaIScorer->RegisterPrimitive(NaIScorer); // Add All Scorer to the Global Scorer Manager - G4SDManager::GetSDMpointer()->AddNewDetector(m_NaIScorer) ; - + G4SDManager::GetSDMpointer()->AddNewDetector(m_NaIScorer); } //////////////////////////////////////////////////////////////////////////////// // Construct Method to be pass to the DetectorFactory // //////////////////////////////////////////////////////////////////////////////// -NPS::VDetector* Paris::Construct(){ - return (NPS::VDetector*) new Paris(); -} +NPS::VDetector* Paris::Construct() { return (NPS::VDetector*)new Paris(); } //////////////////////////////////////////////////////////////////////////////// // Registering the construct method to the factory // //////////////////////////////////////////////////////////////////////////////// -extern"C" { - class proxy_nps_paris{ - public: - proxy_nps_paris(){ - NPS::DetectorFactory::getInstance()->AddToken("Paris","Paris"); - NPS::DetectorFactory::getInstance()->AddDetector("Paris",Paris::Construct); - } - }; +extern "C" { +class proxy_nps_paris { + public: + proxy_nps_paris() { + NPS::DetectorFactory::getInstance()->AddToken("Paris", "Paris"); + NPS::DetectorFactory::getInstance()->AddDetector("Paris", Paris::Construct); + } +}; - proxy_nps_paris p_nps_proxy; +proxy_nps_paris p_nps_proxy; } diff --git a/NPSimulation/Detectors/Plastic/Plastic.cc b/NPSimulation/Detectors/Plastic/Plastic.cc index fe2a6008e813d1f645e329a0cce7dd81ca5c61f3..2be3b77a477e39e93b975f2cc2e2b9440c7b6f01 100644 --- a/NPSimulation/Detectors/Plastic/Plastic.cc +++ b/NPSimulation/Detectors/Plastic/Plastic.cc @@ -60,7 +60,7 @@ using namespace CLHEP; namespace PLASTIC{ // Energy and time Resolution const G4double ResoTime = 1. ;// Resolution in ns // - //const G4double ResoEnergy = 0.1 ;// Resolution in % + //const G4double ResoEnergy = 0.08/2.35 ;// Resolution in % const G4double ResoEnergy = 1*keV; // Resolution } @@ -347,6 +347,7 @@ void Plastic::ReadSensitive(const G4Event* event){ unsigned int size = Scorer->GetMult(); for(unsigned int i=0; i<size; i++){ + //double Energy = RandGauss::shoot(Scorer->GetEnergy(i), Scorer->GetEnergy(i)*ResoEnergy); double Energy = RandGauss::shoot(Scorer->GetEnergy(i), ResoEnergy); double Time = RandGauss::shoot(Scorer->GetTime(i), ResoTime); int DetectorNbr = Scorer->GetLevel(i)[0]; diff --git a/NPSimulation/Detectors/Pyramid/Pyramid.cc b/NPSimulation/Detectors/Pyramid/Pyramid.cc index 87a128c6c517040f2dbf5ae797893389c4d29785..733e058fe24405f90d8ddbfb66db94779ac23a2e 100644 --- a/NPSimulation/Detectors/Pyramid/Pyramid.cc +++ b/NPSimulation/Detectors/Pyramid/Pyramid.cc @@ -19,34 +19,33 @@ * Comment: * * * *****************************************************************************/ - + // C++ headers -#include <sstream> #include <cmath> #include <limits> -//G4 Geometry object +#include <sstream> +// G4 Geometry object #include "G4Box.hh" -#include "G4Tubs.hh" #include "G4Cons.hh" -#include "G4UnionSolid.hh" #include "G4ExtrudedSolid.hh" +#include "G4Tubs.hh" #include "G4TwoVector.hh" -//G4 sensitive +#include "G4UnionSolid.hh" +// G4 sensitive #include "G4SDManager.hh" -//G4 various object -#include "G4Material.hh" -#include "G4Transform3D.hh" -#include "G4PVPlacement.hh" +// G4 various object #include "G4Colour.hh" +#include "G4Material.hh" #include "G4PVDivision.hh" +#include "G4PVPlacement.hh" #include "G4SubtractionSolid.hh" +#include "G4Transform3D.hh" // NPS -#include "Pyramid.hh" -#include "NPSDetectorFactory.hh" #include "MaterialManager.hh" #include "NPSDetectorFactory.hh" +#include "Pyramid.hh" #include "SiliconScorers.hh" // NPL @@ -60,94 +59,87 @@ using namespace PYRAMID; using namespace std; using namespace CLHEP; - - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -Pyramid::Pyramid(){ +Pyramid::Pyramid() { InitializeMaterial(); m_EventPyramid = new TPyramidData(); // Dark Grey - SiliconVisAtt = new G4VisAttributes(G4Colour(0.3, 0.3, 0.3)) ; + SiliconVisAtt = new G4VisAttributes(G4Colour(0.3, 0.3, 0.3)); // Green - PCBVisAtt = new G4VisAttributes(G4Colour(0.2, 0.5, 0.2)) ; + PCBVisAtt = new G4VisAttributes(G4Colour(0.2, 0.5, 0.2)); // Gold Yellow - PADVisAtt = new G4VisAttributes(G4Colour(0.5, 0.5, 0.2)) ; + PADVisAtt = new G4VisAttributes(G4Colour(0.5, 0.5, 0.2)); // Light Grey - FrameVisAtt = new G4VisAttributes(G4Colour(0.5, 0.5, 0.5)) ; + FrameVisAtt = new G4VisAttributes(G4Colour(0.5, 0.5, 0.5)); // Light Blue - GuardRingVisAtt = new G4VisAttributes(G4Colour(0.1, 0.1, 0.1)) ; + GuardRingVisAtt = new G4VisAttributes(G4Colour(0.1, 0.1, 0.1)); m_boolChamber = false; m_boolInner.clear(); m_boolOuter.clear(); m_ANGLE.clear(); m_Z.clear(); - - m_InnerScorer = 0 ; - m_OuterScorer = 0 ; + m_InnerScorer = 0; + m_OuterScorer = 0; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -Pyramid::~Pyramid(){ -} +Pyramid::~Pyramid() {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Virtual Method of NPS::VDetector class // Read stream at Configfile to pick-up parameters of detector (Position,...) // Called in DetecorConstruction::ReadDetextorConfiguration Method -void Pyramid::ReadConfiguration(NPL::InputParser parser){ +void Pyramid::ReadConfiguration(NPL::InputParser parser) { vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithToken("Pyramid"); - if(NPOptionManager::getInstance()->GetVerboseLevel()) + if (NPOptionManager::getInstance()->GetVerboseLevel()) cout << "//// " << blocks.size() << " detectors found " << endl; - vector<string> token = {"Inner","Outer","Z","ANGLE"}; - - for(unsigned int i = 0 ; i < blocks.size() ; i++){ - if(blocks[i]->HasTokenList(token)){ - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << endl << "//// Pyramid " << i+1 << endl; + vector<string> token = {"Inner", "Outer", "Z", "ANGLE"}; + + for (unsigned int i = 0; i < blocks.size(); i++) { + if (blocks[i]->HasTokenList(token)) { + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// Pyramid " << i + 1 << endl; m_boolInner.push_back(blocks[i]->GetInt("Inner")); m_boolOuter.push_back(blocks[i]->GetInt("Outer")); - //m_boolChamber = blocks[i]->GetInt("Chamber"); - m_Z.push_back(blocks[i]->GetDouble("Z","mm")); - m_ANGLE.push_back(blocks[i]->GetDouble("ANGLE","deg")); + // m_boolChamber = blocks[i]->GetInt("Chamber"); + m_Z.push_back(blocks[i]->GetDouble("Z", "mm")); + m_ANGLE.push_back(blocks[i]->GetDouble("ANGLE", "deg")); } - else{ + else { cout << "ERROR: check your input file formatting " << endl; exit(1); } } blocks.clear(); - } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Construct detector and inialise sensitive part. // Called After DetecorConstruction::AddDetector Method -void Pyramid::ConstructDetector(G4LogicalVolume* world){ +void Pyramid::ConstructDetector(G4LogicalVolume* world) { - if(m_boolChamber) + if (m_boolChamber) ConstructChamber(world); - for (unsigned i = 0 ; i < m_boolInner.size() ; i++) - if(m_boolInner[i]) + for (unsigned i = 0; i < m_boolInner.size(); i++) + if (m_boolInner[i]) ConstructInner(world, m_ANGLE[i], m_Z[i]); - for (unsigned i = 0 ; i < m_boolOuter.size() ; i++) - if(m_boolOuter[i]) + for (unsigned i = 0; i < m_boolOuter.size(); i++) + if (m_boolOuter[i]) ConstructOuter(world, m_ANGLE[i], m_Z[i]); - } // Read sensitive part and fill the Root tree. // Called at in the EventAction::EndOfEventAvtion -void Pyramid::ReadSensitive(const G4Event* event){ +void Pyramid::ReadSensitive(const G4Event* event) { m_EventPyramid->Clear(); - // Inner // NPS::HitsMap<G4double*>* InnerHitMap; std::map<G4int, G4double**>::iterator Inner_itr; @@ -155,36 +147,37 @@ void Pyramid::ReadSensitive(const G4Event* event){ InnerHitMap = (NPS::HitsMap<G4double*>*)(event->GetHCofThisEvent()->GetHC(InnerCollectionID)); // Loop on the Inner map - for (Inner_itr = InnerHitMap->GetMap()->begin() ; Inner_itr != InnerHitMap->GetMap()->end() ; Inner_itr++){ + for (Inner_itr = InnerHitMap->GetMap()->begin(); Inner_itr != InnerHitMap->GetMap()->end(); Inner_itr++) { G4double* Info = *(Inner_itr->second); // Downstream Energy - double ED = RandGauss::shoot(Info[0],ResoEnergyInner); - if(ED>EnergyThreshold){ - m_EventPyramid->SetFrontDownstreamE(Info[3],Info[4],ED); - m_EventPyramid->SetFrontDownstreamT(Info[3],Info[4],Info[2]); + double ED = RandGauss::shoot(Info[0], ResoEnergyInner); + if (ED > EnergyThreshold) { + m_EventPyramid->SetFrontDownstreamE(Info[3], Info[4], ED); + m_EventPyramid->SetFrontDownstreamT(Info[3], Info[4], Info[2]); } // Upstream Energy - double EU = RandGauss::shoot(Info[1],ResoEnergyInner); - if(EU>EnergyThreshold){ - m_EventPyramid->SetFrontUpstreamE(Info[3],Info[4],EU); - m_EventPyramid->SetFrontUpstreamT(Info[3],Info[4],Info[2]); - //cout << "Pyramid " << Info[3] << " STRIP " << Info[4] << " " << Info[9]/deg << " " << Info[5] << " " << Info[6] << " " << Info[7] << endl; + double EU = RandGauss::shoot(Info[1], ResoEnergyInner); + if (EU > EnergyThreshold) { + m_EventPyramid->SetFrontUpstreamE(Info[3], Info[4], EU); + m_EventPyramid->SetFrontUpstreamT(Info[3], Info[4], Info[2]); + // cout << "Pyramid " << Info[3] << " STRIP " << Info[4] << " " << Info[9]/deg << " " << Info[5] << " " << Info[6] + // << " " << Info[7] << endl; } // Back Energy - double EB = RandGauss::shoot(Info[1]+Info[0],ResoEnergyInner); - if(EB>EnergyThreshold){ - m_EventPyramid->SetBackE(Info[3],EB); - m_EventPyramid->SetBackT(Info[3],Info[2]); + double EB = RandGauss::shoot(Info[1] + Info[0], ResoEnergyInner); + if (EB > EnergyThreshold) { + m_EventPyramid->SetBackE(Info[3], EB); + m_EventPyramid->SetBackT(Info[3], Info[2]); } - // Interaction Coordinates - ms_InterCoord->SetDetectedPositionX(Info[5]) ; - ms_InterCoord->SetDetectedPositionY(Info[6]) ; - ms_InterCoord->SetDetectedPositionZ(Info[7]) ; - ms_InterCoord->SetDetectedAngleTheta(Info[8]/deg) ; - ms_InterCoord->SetDetectedAnglePhi(Info[9]/deg) ; + // Interaction Coordinates + ms_InterCoord->SetDetectedPositionX(Info[5]); + ms_InterCoord->SetDetectedPositionY(Info[6]); + ms_InterCoord->SetDetectedPositionZ(Info[7]); + ms_InterCoord->SetDetectedAngleTheta(Info[8] / deg); + ms_InterCoord->SetDetectedAnglePhi(Info[9] / deg); } // Clear Map for next event InnerHitMap->clear(); @@ -196,76 +189,65 @@ void Pyramid::ReadSensitive(const G4Event* event){ OuterHitMap = (NPS::HitsMap<G4double*>*)(event->GetHCofThisEvent()->GetHC(OuterCollectionID)); // Loop on the Outer map - for (Outer_itr = OuterHitMap->GetMap()->begin() ; Outer_itr != OuterHitMap->GetMap()->end() ; Outer_itr++){ + for (Outer_itr = OuterHitMap->GetMap()->begin(); Outer_itr != OuterHitMap->GetMap()->end(); Outer_itr++) { G4double* Info = *(Outer_itr->second); - double E = RandGauss::shoot(Info[0]/keV,ResoEnergyOuter); - if(E>EnergyThreshold){ - m_EventPyramid->SetOuterE(Info[7],Info[9],E); - m_EventPyramid->SetOuterT(Info[7],Info[9],Info[1]); + double E = RandGauss::shoot(Info[0] / keV, ResoEnergyOuter); + if (E > EnergyThreshold) { + m_EventPyramid->SetOuterE(Info[7], Info[9], E); + m_EventPyramid->SetOuterT(Info[7], Info[9], Info[1]); } - // Interaction Coordinates - ms_InterCoord->SetDetectedPositionX(Info[5]) ; - ms_InterCoord->SetDetectedPositionY(Info[6]) ; - ms_InterCoord->SetDetectedPositionZ(Info[7]) ; - ms_InterCoord->SetDetectedAngleTheta(Info[8]/deg) ; - ms_InterCoord->SetDetectedAnglePhi(Info[9]/deg) ; + // Interaction Coordinates + ms_InterCoord->SetDetectedPositionX(Info[5]); + ms_InterCoord->SetDetectedPositionY(Info[6]); + ms_InterCoord->SetDetectedPositionZ(Info[7]); + ms_InterCoord->SetDetectedAngleTheta(Info[8] / deg); + ms_InterCoord->SetDetectedAnglePhi(Info[9] / deg); } // Clear Map for next event OuterHitMap->clear(); - - } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Pyramid::InitializeScorers(){ - //Look for previous definition of the scorer (geometry reload) +void Pyramid::InitializeScorers() { + // Look for previous definition of the scorer (geometry reload) bool already_exist = false; - m_InnerScorer = CheckScorer("Pyramid_InnerScorer",already_exist); - m_OuterScorer = CheckScorer("Pyramid_OuterScorer",already_exist); - + m_InnerScorer = CheckScorer("Pyramid_InnerScorer", already_exist); + m_OuterScorer = CheckScorer("Pyramid_OuterScorer", already_exist); // if the scorer were created previously nothing else need to be made - if(already_exist) return; + if (already_exist) + return; - G4VPrimitiveScorer* Inner = new SILICONSCORERS::PS_Silicon_Resistive("Inner",1, - Inner_ActiveWafer_Length, - Inner_ActiveWafer_Width, - Inner_NumberOfStrip); + G4VPrimitiveScorer* Inner = new SILICONSCORERS::PS_Silicon_Resistive("Inner", 1, Inner_ActiveWafer_Length, + Inner_ActiveWafer_Width, Inner_NumberOfStrip); m_InnerScorer->RegisterPrimitive(Inner); - G4VPrimitiveScorer* Outer = new SILICONSCORERS::PS_Silicon_Rectangle("Outer",1, - Inner_ActiveWafer_Length, - Inner_ActiveWafer_Width, - 1, - Outer_NumberOfStrip); + G4VPrimitiveScorer* Outer = new SILICONSCORERS::PS_Silicon_Rectangle("Outer", 1, Inner_ActiveWafer_Length, + Inner_ActiveWafer_Width, 1, Outer_NumberOfStrip); m_OuterScorer->RegisterPrimitive(Outer); - // Add All Scorer to the Global Scorer Manager - G4SDManager::GetSDMpointer()->AddNewDetector(m_InnerScorer) ; - G4SDManager::GetSDMpointer()->AddNewDetector(m_OuterScorer) ; - + G4SDManager::GetSDMpointer()->AddNewDetector(m_InnerScorer); + G4SDManager::GetSDMpointer()->AddNewDetector(m_OuterScorer); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Pyramid::InitializeRootOutput(){ - TTree *pTree = RootOutput::getInstance()->GetTree(); - if(!pTree->FindBranch("Pyramid")){ - pTree->Branch("Pyramid", "TPyramidData", &m_EventPyramid) ; +void Pyramid::InitializeRootOutput() { + TTree* pTree = RootOutput::getInstance()->GetTree(); + if (!pTree->FindBranch("Pyramid")) { + pTree->Branch("Pyramid", "TPyramidData", &m_EventPyramid); } - // This insure that the object are correctly bind in case of // a redifinition of the geometry in the simulation - pTree->SetBranchAddress("Pyramid", &m_EventPyramid) ; - + pTree->SetBranchAddress("Pyramid", &m_EventPyramid); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Pyramid::ConstructInner(G4LogicalVolume* world, double angle, double z){ +void Pyramid::ConstructInner(G4LogicalVolume* world, double angle, double z) { // Pyramid Pyramid // The Pyramid is made of 4 identical resistive strip detector // The PCB is made from a G4ExtrudeSolid, because it has beveled edge @@ -276,100 +258,74 @@ void Pyramid::ConstructInner(G4LogicalVolume* world, double angle, double z){ // Start by making a full pcb // We start by the definition of the point forming a PCB cross section vector<G4TwoVector> PCBCrossSection; - double l1 = Inner_PCB_Thickness*0.5/tan(Inner_PCB_Bevel1_Theta); - double l2 = Inner_PCB_Thickness*0.5/tan(Inner_PCB_Bevel2_Theta); + double l1 = Inner_PCB_Thickness * 0.5 / tan(Inner_PCB_Bevel1_Theta); + double l2 = Inner_PCB_Thickness * 0.5 / tan(Inner_PCB_Bevel2_Theta); - PCBCrossSection.push_back(G4TwoVector(Inner_PCB_Width/2.-l2,-Inner_PCB_Thickness*0.5)); - PCBCrossSection.push_back(G4TwoVector(Inner_PCB_Width/2.,0)); - PCBCrossSection.push_back(G4TwoVector(Inner_PCB_Width/2.-l1,Inner_PCB_Thickness*0.5)); + PCBCrossSection.push_back(G4TwoVector(Inner_PCB_Width / 2. - l2, -Inner_PCB_Thickness * 0.5)); + PCBCrossSection.push_back(G4TwoVector(Inner_PCB_Width / 2., 0)); + PCBCrossSection.push_back(G4TwoVector(Inner_PCB_Width / 2. - l1, Inner_PCB_Thickness * 0.5)); - PCBCrossSection.push_back(G4TwoVector(-Inner_PCB_Width/2.+l1,Inner_PCB_Thickness*0.5)); - PCBCrossSection.push_back(G4TwoVector(-Inner_PCB_Width/2.,0)); - PCBCrossSection.push_back(G4TwoVector(-Inner_PCB_Width/2.+l2,-Inner_PCB_Thickness*0.5)); + PCBCrossSection.push_back(G4TwoVector(-Inner_PCB_Width / 2. + l1, Inner_PCB_Thickness * 0.5)); + PCBCrossSection.push_back(G4TwoVector(-Inner_PCB_Width / 2., 0)); + PCBCrossSection.push_back(G4TwoVector(-Inner_PCB_Width / 2. + l2, -Inner_PCB_Thickness * 0.5)); - G4ExtrudedSolid* PCBFull = - new G4ExtrudedSolid("PCBFull", - PCBCrossSection, - Inner_PCB_Length/2., - G4TwoVector(0,0),1, - G4TwoVector(0,0),1); + G4ExtrudedSolid* PCBFull = new G4ExtrudedSolid("PCBFull", PCBCrossSection, Inner_PCB_Length / 2., G4TwoVector(0, 0), + 1, G4TwoVector(0, 0), 1); // A box having Wafer dimension but thicker than the PCB // Will be used to remove material from the PCB to have space for the wafer // Calculate the hole shift within the PCB - G4ThreeVector HoleShift = G4ThreeVector( - 0, - 0, - Inner_PCB_Offset-(Inner_PCB_Length/2-Inner_PCB_HoleLength/2)); + G4ThreeVector HoleShift = G4ThreeVector(0, 0, Inner_PCB_Offset - (Inner_PCB_Length / 2 - Inner_PCB_HoleLength / 2)); - G4Box* HoleShape = new G4Box("HoleShape", - Inner_ActiveWafer_Width/2., - Inner_PCB_Thickness/2.+0.1*mm, - Inner_PCB_HoleLength/2.); + G4Box* HoleShape = new G4Box("HoleShape", Inner_ActiveWafer_Width / 2., Inner_PCB_Thickness / 2. + 0.1 * mm, + Inner_PCB_HoleLength / 2.); - G4Box* WaferShape = new G4Box("WaferShape", - Inner_InertWafer_Width/2., - Inner_PCB_Thickness/2., - Inner_InertWafer_Length/2.); + G4Box* WaferShape = + new G4Box("WaferShape", Inner_InertWafer_Width / 2., Inner_PCB_Thickness / 2., Inner_InertWafer_Length / 2.); // The Silicon Wafer itself - G4Box* InertWaferFull = new G4Box("InertWaferFull", - Inner_InertWafer_Width/2., - Inner_InertWafer_Thickness/2., - Inner_InertWafer_Length/2.); - - G4Box* ActiveWafer = new G4Box("ActiveWafer", - Inner_ActiveWafer_Width/2., - Inner_ActiveWafer_Thickness/2., - Inner_ActiveWafer_Length/2.); + G4Box* InertWaferFull = new G4Box("InertWaferFull", Inner_InertWafer_Width / 2., Inner_InertWafer_Thickness / 2., + Inner_InertWafer_Length / 2.); - G4Box* DeadLayer = new G4Box("DeadLayer", - Inner_ActiveWafer_Width/2., - Inner_ActiveWafer_DeadLayerThickness/2., - Inner_ActiveWafer_Length/2.); + G4Box* ActiveWafer = new G4Box("ActiveWafer", Inner_ActiveWafer_Width / 2., Inner_ActiveWafer_Thickness / 2., + Inner_ActiveWafer_Length / 2.); - G4Box* ActiveWaferShape = new G4Box("ActiveWaferShape", - Inner_ActiveWafer_Width/2., - Inner_PCB_Thickness/2., - Inner_ActiveWafer_Length/2.); + G4Box* DeadLayer = new G4Box("DeadLayer", Inner_ActiveWafer_Width / 2., Inner_ActiveWafer_DeadLayerThickness / 2., + Inner_ActiveWafer_Length / 2.); + G4Box* ActiveWaferShape = new G4Box("ActiveWaferShape", Inner_ActiveWafer_Width / 2., Inner_PCB_Thickness / 2., + Inner_ActiveWafer_Length / 2.); // Substracting the hole Shape from the Stock PCB - G4SubtractionSolid* PCB_1 = new G4SubtractionSolid("PCB_1", PCBFull, HoleShape, - new G4RotationMatrix,HoleShift); + G4SubtractionSolid* PCB_1 = new G4SubtractionSolid("PCB_1", PCBFull, HoleShape, new G4RotationMatrix, HoleShift); // Substracting the wafer space from the Stock PCB - G4SubtractionSolid* PCB = new G4SubtractionSolid("PCB", PCB_1, WaferShape, - new G4RotationMatrix, - G4ThreeVector(0,Inner_PCB_Thickness/2.-Inner_PCB_WaferDepth,0)); + G4SubtractionSolid* PCB = + new G4SubtractionSolid("PCB", PCB_1, WaferShape, new G4RotationMatrix, + G4ThreeVector(0, Inner_PCB_Thickness / 2. - Inner_PCB_WaferDepth, 0)); // Substract active part from inert part of the Wafer G4SubtractionSolid* InertWafer = new G4SubtractionSolid("InertWafer", InertWaferFull, ActiveWaferShape, - new G4RotationMatrix, - G4ThreeVector(0,0,0)); + new G4RotationMatrix, G4ThreeVector(0, 0, 0)); // Master Volume that encompass everything else - G4LogicalVolume* logicPyramidDetector = - new G4LogicalVolume(PCBFull,m_MaterialVacuum,"logicBoxDetector", 0, 0, 0); - logicPyramidDetector->SetVisAttributes(G4VisAttributes::Invisible); + G4LogicalVolume* logicPyramidDetector = new G4LogicalVolume(PCBFull, m_MaterialVacuum, "logicBoxDetector", 0, 0, 0); + logicPyramidDetector->SetVisAttributes(G4VisAttributes::GetInvisible()); // Sub Volume PCB - G4LogicalVolume* logicPCB = - new G4LogicalVolume(PCB,m_MaterialPCB,"logicPCB", 0, 0, 0); + G4LogicalVolume* logicPCB = new G4LogicalVolume(PCB, m_MaterialPCB, "logicPCB", 0, 0, 0); logicPCB->SetVisAttributes(PCBVisAtt); // Sub Volume Wafer - G4LogicalVolume* logicInertWafer = - new G4LogicalVolume(InertWafer,m_MaterialSilicon,"logicInertWafer", 0, 0, 0); + G4LogicalVolume* logicInertWafer = new G4LogicalVolume(InertWafer, m_MaterialSilicon, "logicInertWafer", 0, 0, 0); logicInertWafer->SetVisAttributes(GuardRingVisAtt); - G4LogicalVolume* logicActiveWafer = - new G4LogicalVolume(ActiveWafer,m_MaterialSilicon,"logicActiveWafer", 0, 0, 0); + G4LogicalVolume* logicActiveWafer = new G4LogicalVolume(ActiveWafer, m_MaterialSilicon, "logicActiveWafer", 0, 0, 0); logicActiveWafer->SetVisAttributes(SiliconVisAtt); G4LogicalVolume* logicDeadLayer = - new G4LogicalVolume(DeadLayer,m_MaterialSilicon,"logicActiveWaferDeadLayer", 0, 0, 0); + new G4LogicalVolume(DeadLayer, m_MaterialSilicon, "logicActiveWaferDeadLayer", 0, 0, 0); logicDeadLayer->SetVisAttributes(SiliconVisAtt); // Set the sensitive volume @@ -378,66 +334,51 @@ void Pyramid::ConstructInner(G4LogicalVolume* world, double angle, double z){ // Place the sub volumes in the master volume // Last argument is the detector number, used in the scorer to get the // revelant information - new G4PVPlacement(new G4RotationMatrix(0,0,0), - G4ThreeVector(0,0,0), - logicPCB,"Pyramid_Pyramid_PCB",logicPyramidDetector, - false,0); - - G4ThreeVector WaferPosition(0, - 0.5*(Inner_PCB_Thickness+Inner_InertWafer_Thickness)-Inner_PCB_WaferDepth - ,0); - - G4ThreeVector DeadLayerPositionF = WaferPosition + G4ThreeVector(0,-Inner_ActiveWafer_Thickness*0.5-Inner_ActiveWafer_DeadLayerThickness*0.5,0); + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), G4ThreeVector(0, 0, 0), logicPCB, "Pyramid_Pyramid_PCB", + logicPyramidDetector, false, 0); - G4ThreeVector DeadLayerPositionB = WaferPosition + G4ThreeVector(0,Inner_ActiveWafer_Thickness*0.5+Inner_ActiveWafer_DeadLayerThickness*0.5,0); + G4ThreeVector WaferPosition(0, 0.5 * (Inner_PCB_Thickness + Inner_InertWafer_Thickness) - Inner_PCB_WaferDepth, 0); + G4ThreeVector DeadLayerPositionF = + WaferPosition + + G4ThreeVector(0, -Inner_ActiveWafer_Thickness * 0.5 - Inner_ActiveWafer_DeadLayerThickness * 0.5, 0); + G4ThreeVector DeadLayerPositionB = + WaferPosition + + G4ThreeVector(0, Inner_ActiveWafer_Thickness * 0.5 + Inner_ActiveWafer_DeadLayerThickness * 0.5, 0); - new G4PVPlacement(new G4RotationMatrix(0,0,0), - WaferPosition, - logicActiveWafer,"Pyramid_Wafer", - logicPyramidDetector,false,0); + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), WaferPosition, logicActiveWafer, "Pyramid_Wafer", + logicPyramidDetector, false, 0); - new G4PVPlacement(new G4RotationMatrix(0,0,0), - DeadLayerPositionF, - logicDeadLayer,"Pyramid_WaferDeadLayerFront", - logicPyramidDetector,false,0); + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), DeadLayerPositionF, logicDeadLayer, "Pyramid_WaferDeadLayerFront", + logicPyramidDetector, false, 0); - new G4PVPlacement(new G4RotationMatrix(0,0,0), - DeadLayerPositionB, - logicDeadLayer,"Pyramid_WaferDeadLayerBack", - logicPyramidDetector,false,0); + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), DeadLayerPositionB, logicDeadLayer, "Pyramid_WaferDeadLayerBack", + logicPyramidDetector, false, 0); - - new G4PVPlacement(new G4RotationMatrix(0,0,0), - WaferPosition, - logicInertWafer,"Pyramid_Wafer_GuardRing", - logicPyramidDetector,false,0); + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), WaferPosition, logicInertWafer, "Pyramid_Wafer_GuardRing", + logicPyramidDetector, false, 0); // The Distance from target is given by half the width of a detector - G4double DistanceFromTarget = Inner_PCB_Width*(0.5) - + Inner_PCB_Length*(0.5)*fabs(sin(angle)) ; - for( unsigned int i = 0; i < 4; i ++){ + G4double DistanceFromTarget = Inner_PCB_Width * (0.5) + Inner_PCB_Length * (0.5) * fabs(sin(angle)); + for (unsigned int i = 0; i < 4; i++) { // The following builds the Pyramid, with detector one at the top // and going anticlockwise looking downstream - double sign = -z/fabs(z); + double sign = -z / fabs(z); // Detector are rotate by 90deg with each other - G4RotationMatrix* DetectorRotation = - new G4RotationMatrix(0,sign*angle,i*90*deg); + G4RotationMatrix* DetectorRotation = new G4RotationMatrix(0, sign * angle, i * 90 * deg); // There center is also rotated by 90deg - G4ThreeVector DetectorPosition(0,DistanceFromTarget,z-(0.5)*Inner_ActiveWafer_Length); - DetectorPosition.rotate(i*90*deg,G4ThreeVector(0,0,-1)); + G4ThreeVector DetectorPosition(0, DistanceFromTarget, z - (0.5) * Inner_ActiveWafer_Length); + DetectorPosition.rotate(i * 90 * deg, G4ThreeVector(0, 0, -1)); // Place the Master volume with its two daugther volume at the final place - new G4PVPlacement(G4Transform3D(*DetectorRotation,DetectorPosition), - logicPyramidDetector,"Pyramid_Inner_Detector", - world,false,i+1); + new G4PVPlacement(G4Transform3D(*DetectorRotation, DetectorPosition), logicPyramidDetector, + "Pyramid_Inner_Detector", world, false, i + 1); } - } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Pyramid::ConstructOuter(G4LogicalVolume* world, double angle, double z){ +void Pyramid::ConstructOuter(G4LogicalVolume* world, double angle, double z) { // Pyramid Outer Pyramid // The outer Pyramid is identical to the inner Pyramid but wider in terms of // geometry. It feature four non resistive strip on the front face @@ -445,91 +386,67 @@ void Pyramid::ConstructOuter(G4LogicalVolume* world, double angle, double z){ // Start by making a full pcb // We start by the definition of the point forming a PCB cross section vector<G4TwoVector> PCBCrossSection; - double l1 = Outer_PCB_Thickness*0.5/tan(Outer_PCB_Bevel1_Theta); - double l2 = Outer_PCB_Thickness*0.5/tan(Outer_PCB_Bevel2_Theta); + double l1 = Outer_PCB_Thickness * 0.5 / tan(Outer_PCB_Bevel1_Theta); + double l2 = Outer_PCB_Thickness * 0.5 / tan(Outer_PCB_Bevel2_Theta); - PCBCrossSection.push_back(G4TwoVector(Outer_PCB_Width/2.-l2,-Outer_PCB_Thickness*0.5)); - PCBCrossSection.push_back(G4TwoVector(Outer_PCB_Width/2.,0)); - PCBCrossSection.push_back(G4TwoVector(Outer_PCB_Width/2.-l1,Outer_PCB_Thickness*0.5)); + PCBCrossSection.push_back(G4TwoVector(Outer_PCB_Width / 2. - l2, -Outer_PCB_Thickness * 0.5)); + PCBCrossSection.push_back(G4TwoVector(Outer_PCB_Width / 2., 0)); + PCBCrossSection.push_back(G4TwoVector(Outer_PCB_Width / 2. - l1, Outer_PCB_Thickness * 0.5)); - PCBCrossSection.push_back(G4TwoVector(-Outer_PCB_Width/2.+l1,Outer_PCB_Thickness*0.5)); - PCBCrossSection.push_back(G4TwoVector(-Outer_PCB_Width/2.,0)); - PCBCrossSection.push_back(G4TwoVector(-Outer_PCB_Width/2.+l2,-Outer_PCB_Thickness*0.5)); + PCBCrossSection.push_back(G4TwoVector(-Outer_PCB_Width / 2. + l1, Outer_PCB_Thickness * 0.5)); + PCBCrossSection.push_back(G4TwoVector(-Outer_PCB_Width / 2., 0)); + PCBCrossSection.push_back(G4TwoVector(-Outer_PCB_Width / 2. + l2, -Outer_PCB_Thickness * 0.5)); - G4ExtrudedSolid* PCBFull = - new G4ExtrudedSolid("PCBFull", - PCBCrossSection, - Outer_PCB_Length/2., - G4TwoVector(0,0),1, - G4TwoVector(0,0),1); + G4ExtrudedSolid* PCBFull = new G4ExtrudedSolid("PCBFull", PCBCrossSection, Outer_PCB_Length / 2., G4TwoVector(0, 0), + 1, G4TwoVector(0, 0), 1); // A box having Wafer dimension but thicker than the PCB // Will be used to remove material from the PCB to have space for the wafer // Calculate the hole shift within the PCB - G4ThreeVector HoleShift = G4ThreeVector( - 0, - 0, - Outer_PCB_Offset-(Outer_PCB_Length/2-Outer_PCB_HoleLength/2)); + G4ThreeVector HoleShift = G4ThreeVector(0, 0, Outer_PCB_Offset - (Outer_PCB_Length / 2 - Outer_PCB_HoleLength / 2)); - G4Box* HoleShape = new G4Box("HoleShape", - Outer_ActiveWafer_Width/2., - Outer_PCB_Thickness/2.+0.1*mm, - Outer_PCB_HoleLength/2.); + G4Box* HoleShape = new G4Box("HoleShape", Outer_ActiveWafer_Width / 2., Outer_PCB_Thickness / 2. + 0.1 * mm, + Outer_PCB_HoleLength / 2.); - G4Box* WaferShape = new G4Box("WaferShape", - Outer_InertWafer_Width/2., - Outer_PCB_Thickness/2., - Outer_InertWafer_Length/2.); + G4Box* WaferShape = + new G4Box("WaferShape", Outer_InertWafer_Width / 2., Outer_PCB_Thickness / 2., Outer_InertWafer_Length / 2.); // The Silicon Wafer itself - G4Box* InertWaferFull = new G4Box("InertWaferFull", - Outer_InertWafer_Width/2., - Outer_ActiveWafer_Thickness/2., - Outer_InertWafer_Length/2.); - - G4Box* ActiveWafer = new G4Box("ActiveWafer", - Outer_ActiveWafer_Width/2., - Outer_ActiveWafer_Thickness/2., - Outer_ActiveWafer_Length/2.); + G4Box* InertWaferFull = new G4Box("InertWaferFull", Outer_InertWafer_Width / 2., Outer_ActiveWafer_Thickness / 2., + Outer_InertWafer_Length / 2.); - G4Box* ActiveWaferShape = new G4Box("ActiveWaferShape", - Outer_ActiveWafer_Width/2., - Outer_PCB_Thickness/2., - Outer_ActiveWafer_Length/2.); + G4Box* ActiveWafer = new G4Box("ActiveWafer", Outer_ActiveWafer_Width / 2., Outer_ActiveWafer_Thickness / 2., + Outer_ActiveWafer_Length / 2.); + G4Box* ActiveWaferShape = new G4Box("ActiveWaferShape", Outer_ActiveWafer_Width / 2., Outer_PCB_Thickness / 2., + Outer_ActiveWafer_Length / 2.); // Substracting the hole Shape from the Stock PCB - G4SubtractionSolid* PCB_1 = new G4SubtractionSolid("PCB_1", PCBFull, HoleShape, - new G4RotationMatrix,HoleShift); + G4SubtractionSolid* PCB_1 = new G4SubtractionSolid("PCB_1", PCBFull, HoleShape, new G4RotationMatrix, HoleShift); // Substracting the wafer space from the Stock PCB - G4SubtractionSolid* PCB = new G4SubtractionSolid("PCB", PCB_1, WaferShape, - new G4RotationMatrix, - G4ThreeVector(0,Outer_PCB_Thickness/2.-Outer_PCB_WaferDepth,0)); + G4SubtractionSolid* PCB = + new G4SubtractionSolid("PCB", PCB_1, WaferShape, new G4RotationMatrix, + G4ThreeVector(0, Outer_PCB_Thickness / 2. - Outer_PCB_WaferDepth, 0)); // Substract active part from inert part of the Wafer G4SubtractionSolid* InertWafer = new G4SubtractionSolid("InertWafer", InertWaferFull, ActiveWaferShape, - new G4RotationMatrix, - G4ThreeVector(0,0,0)); + new G4RotationMatrix, G4ThreeVector(0, 0, 0)); // Master Volume that encompass everything else - G4LogicalVolume* logicPyramidDetector = - new G4LogicalVolume(PCBFull,m_MaterialVacuum,"logicBoxDetector", 0, 0, 0); - logicPyramidDetector->SetVisAttributes(G4VisAttributes::Invisible); + G4LogicalVolume* logicPyramidDetector = new G4LogicalVolume(PCBFull, m_MaterialVacuum, "logicBoxDetector", 0, 0, 0); + logicPyramidDetector->SetVisAttributes(G4VisAttributes::GetInvisible()); // Sub Volume PCB - G4LogicalVolume* logicPCB = - new G4LogicalVolume(PCB,m_MaterialPCB,"logicPCB", 0, 0, 0); + G4LogicalVolume* logicPCB = new G4LogicalVolume(PCB, m_MaterialPCB, "logicPCB", 0, 0, 0); logicPCB->SetVisAttributes(PCBVisAtt); // Sub Volume Wafer - G4LogicalVolume* logicInertWafer = - new G4LogicalVolume(InertWafer,m_MaterialSilicon,"logicInertWafer", 0, 0, 0); + G4LogicalVolume* logicInertWafer = new G4LogicalVolume(InertWafer, m_MaterialSilicon, "logicInertWafer", 0, 0, 0); logicInertWafer->SetVisAttributes(GuardRingVisAtt); - G4LogicalVolume* logicActiveWafer = - new G4LogicalVolume(ActiveWafer,m_MaterialSilicon,"logicActiveWafer", 0, 0, 0); + G4LogicalVolume* logicActiveWafer = new G4LogicalVolume(ActiveWafer, m_MaterialSilicon, "logicActiveWafer", 0, 0, 0); logicActiveWafer->SetVisAttributes(SiliconVisAtt); // Set the sensitive detector @@ -537,56 +454,41 @@ void Pyramid::ConstructOuter(G4LogicalVolume* world, double angle, double z){ // The Distance from target is given by half the width of a detector // plus 0.75 cm - G4double DistanceFromTarget = Inner_PCB_Width*(0.5)+0.5*cm - + Inner_PCB_Length*(0.5)*fabs(sin(angle)) ; - + G4double DistanceFromTarget = Inner_PCB_Width * (0.5) + 0.5 * cm + Inner_PCB_Length * (0.5) * fabs(sin(angle)); + // Place the sub volumes in the master volume // Last argument is the detector number, used in the scorer to get the // revelant information - new G4PVPlacement(new G4RotationMatrix(0,0,0), - G4ThreeVector(0,0,0), - logicPCB,"Pyramid_Outer_PCB",logicPyramidDetector, - false,0); + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), G4ThreeVector(0, 0, 0), logicPCB, "Pyramid_Outer_PCB", + logicPyramidDetector, false, 0); + G4ThreeVector WaferPosition(0, 0.5 * (Outer_PCB_Thickness + Outer_ActiveWafer_Thickness) - Outer_PCB_WaferDepth, 0); - G4ThreeVector WaferPosition(0, - 0.5*(Outer_PCB_Thickness+Outer_ActiveWafer_Thickness)-Outer_PCB_WaferDepth - ,0); + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), WaferPosition, logicActiveWafer, "Outer_Wafer", logicPyramidDetector, + false, 0); - new G4PVPlacement(new G4RotationMatrix(0,0,0), - WaferPosition, - logicActiveWafer,"Outer_Wafer", - logicPyramidDetector,false,0); + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), WaferPosition, logicInertWafer, "Outer_Wafer_GuardRing", + logicPyramidDetector, false, 0); - new G4PVPlacement(new G4RotationMatrix(0,0,0), - WaferPosition, - logicInertWafer,"Outer_Wafer_GuardRing", - logicPyramidDetector,false,0); - - // The following build the Pyramid, with detector one at the top // and going clowise looking upstrea - for( unsigned int i = 0; i < 4; i ++){ + for (unsigned int i = 0; i < 4; i++) { // Detector are rotate by 90 deg with each other - double sign = -z/fabs(z); - G4RotationMatrix* DetectorRotation = - new G4RotationMatrix(0*deg,sign*angle,i*90*deg); + double sign = -z / fabs(z); + G4RotationMatrix* DetectorRotation = new G4RotationMatrix(0 * deg, sign * angle, i * 90 * deg); // There center is also rotated by 90deg - G4ThreeVector DetectorPosition(0,DistanceFromTarget,z); - DetectorPosition.rotate(i*90*deg,G4ThreeVector(0,0,-1)); + G4ThreeVector DetectorPosition(0, DistanceFromTarget, z); + DetectorPosition.rotate(i * 90 * deg, G4ThreeVector(0, 0, -1)); // Place the Master volume with its daugthers at the final place - new G4PVPlacement(G4Transform3D(*DetectorRotation,DetectorPosition), - logicPyramidDetector,"Pyramid_Outer_Detector", - world,false,i+1); + new G4PVPlacement(G4Transform3D(*DetectorRotation, DetectorPosition), logicPyramidDetector, + "Pyramid_Outer_Detector", world, false, i + 1); } - } - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Pyramid::ConstructChamber(G4LogicalVolume* world){ +void Pyramid::ConstructChamber(G4LogicalVolume* world) { // Vaccum Chamber of Pyramid // The chamber is made of a central cylinder surrounding the Pyramid Si // Two Cone that expeand out of the central cylinder to let room for Exogam @@ -598,61 +500,52 @@ void Pyramid::ConstructChamber(G4LogicalVolume* world){ // Central Tube G4Tubs* solidCentralTube = - new G4Tubs("PyramidChamberCentralTube",CHAMBER_CentralTube_Inner_Radius, - CHAMBER_CentralTube_Outer_Radius,CHAMBER_CentralTube_Length/2., - 0*deg,360*deg); + new G4Tubs("PyramidChamberCentralTube", CHAMBER_CentralTube_Inner_Radius, CHAMBER_CentralTube_Outer_Radius, + CHAMBER_CentralTube_Length / 2., 0 * deg, 360 * deg); // Forward-Backward Cones G4Cons* solidOuterCone = - new G4Cons("PyramidChamberOuterCone",CHAMBER_CentralTube_Inner_Radius, - CHAMBER_CentralTube_Outer_Radius,CHAMBER_OuterCylinder_Inner_Radius, - CHAMBER_OuterCylinder_Outer_Radius,CHAMBER_OuterCone_Length/2., - 0*deg,360*deg); + new G4Cons("PyramidChamberOuterCone", CHAMBER_CentralTube_Inner_Radius, CHAMBER_CentralTube_Outer_Radius, + CHAMBER_OuterCylinder_Inner_Radius, CHAMBER_OuterCylinder_Outer_Radius, CHAMBER_OuterCone_Length / 2., + 0 * deg, 360 * deg); // Outer Cylinder G4Tubs* solidOuterCylinder = - new G4Tubs("PyramidChamberOuterCylinder",CHAMBER_OuterCylinder_Inner_Radius, - CHAMBER_OuterCylinder_Outer_Radius,CHAMBER_OuterCylinder_Length/2., - 0*deg,360*deg); + new G4Tubs("PyramidChamberOuterCylinder", CHAMBER_OuterCylinder_Inner_Radius, CHAMBER_OuterCylinder_Outer_Radius, + CHAMBER_OuterCylinder_Length / 2., 0 * deg, 360 * deg); // Add the volume together G4UnionSolid* solidPyramidChamberStep1 = - new G4UnionSolid("PyramidChamber", solidCentralTube, solidOuterCone, - new G4RotationMatrix, - G4ThreeVector(0,0,CHAMBER_OuterCone_Z_Pos)); + new G4UnionSolid("PyramidChamber", solidCentralTube, solidOuterCone, new G4RotationMatrix, + G4ThreeVector(0, 0, CHAMBER_OuterCone_Z_Pos)); G4UnionSolid* solidPyramidChamberStep2 = - new G4UnionSolid("PyramidChamber", solidPyramidChamberStep1, solidOuterCone, - new G4RotationMatrix(0,180*deg,0), - G4ThreeVector(0,0,-CHAMBER_OuterCone_Z_Pos)); + new G4UnionSolid("PyramidChamber", solidPyramidChamberStep1, solidOuterCone, + new G4RotationMatrix(0, 180 * deg, 0), G4ThreeVector(0, 0, -CHAMBER_OuterCone_Z_Pos)); G4UnionSolid* solidPyramidChamberStep3 = - new G4UnionSolid("PyramidChamber", solidPyramidChamberStep2, solidOuterCylinder, - new G4RotationMatrix, - G4ThreeVector(0,0,CHAMBER_OuterCylinder_Z_Pos)); + new G4UnionSolid("PyramidChamber", solidPyramidChamberStep2, solidOuterCylinder, new G4RotationMatrix, + G4ThreeVector(0, 0, CHAMBER_OuterCylinder_Z_Pos)); G4UnionSolid* solidPyramidChamberStep4 = - new G4UnionSolid("PyramidChamber", solidPyramidChamberStep3, solidOuterCylinder, - new G4RotationMatrix, - G4ThreeVector(0,0,-CHAMBER_OuterCylinder_Z_Pos)); + new G4UnionSolid("PyramidChamber", solidPyramidChamberStep3, solidOuterCylinder, new G4RotationMatrix, + G4ThreeVector(0, 0, -CHAMBER_OuterCylinder_Z_Pos)); // Create Logic Volume G4LogicalVolume* logicPyramidChamber = - new G4LogicalVolume(solidPyramidChamberStep4,m_MaterialAl,"logicPyramidChamber", 0, 0, 0); + new G4LogicalVolume(solidPyramidChamberStep4, m_MaterialAl, "logicPyramidChamber", 0, 0, 0); // Visual Attribute - G4VisAttributes* ChamberVisAtt - = new G4VisAttributes(G4Colour(0.0,0.4,0.5,0.2)); + G4VisAttributes* ChamberVisAtt = new G4VisAttributes(G4Colour(0.0, 0.4, 0.5, 0.2)); logicPyramidChamber->SetVisAttributes(ChamberVisAtt); // Place the whole chamber - new G4PVPlacement(new G4RotationMatrix(0,0,0), G4ThreeVector(0,0,0), - logicPyramidChamber,"PyramidChamber",world,false,0); - + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), G4ThreeVector(0, 0, 0), logicPyramidChamber, "PyramidChamber", world, + false, 0); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Pyramid::InitializeMaterial(){ +void Pyramid::InitializeMaterial() { m_MaterialSilicon = MaterialManager::getInstance()->GetMaterialFromLibrary("Si"); m_MaterialAl = MaterialManager::getInstance()->GetMaterialFromLibrary("Al"); m_MaterialPCB = MaterialManager::getInstance()->GetMaterialFromLibrary("PCB"); @@ -662,23 +555,21 @@ void Pyramid::InitializeMaterial(){ //////////////////////////////////////////////////////////////////////////////// // Construct Method to be pass to the DetectorFactory // //////////////////////////////////////////////////////////////////////////////// -NPS::VDetector* Pyramid::Construct(){ - return (NPS::VDetector*) new Pyramid(); -} +NPS::VDetector* Pyramid::Construct() { return (NPS::VDetector*)new Pyramid(); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //////////////////////////////////////////////////////////////////////////////// // Registering the construct method to the factory // //////////////////////////////////////////////////////////////////////////////// -extern"C" { - class proxy_nps_Pyramid{ - public: - proxy_nps_Pyramid(){ - NPS::DetectorFactory::getInstance()->AddToken("Pyramid","Pyramid"); - NPS::DetectorFactory::getInstance()->AddDetector("Pyramid",Pyramid::Construct); - } - }; - - proxy_nps_Pyramid p_nps_Pyramid; +extern "C" { +class proxy_nps_Pyramid { + public: + proxy_nps_Pyramid() { + NPS::DetectorFactory::getInstance()->AddToken("Pyramid", "Pyramid"); + NPS::DetectorFactory::getInstance()->AddDetector("Pyramid", Pyramid::Construct); + } +}; + +proxy_nps_Pyramid p_nps_Pyramid; } diff --git a/NPSimulation/Detectors/QQQ/QQQ.cc b/NPSimulation/Detectors/QQQ/QQQ.cc index 43fd01420af3043b69c6b61b844ccef734007472..d593a28d09996db521489e642536584251cbcec6 100644 --- a/NPSimulation/Detectors/QQQ/QQQ.cc +++ b/NPSimulation/Detectors/QQQ/QQQ.cc @@ -20,35 +20,35 @@ *****************************************************************************/ // C++ headers -#include <sstream> #include <cmath> #include <limits> -//G4 Geometry object -#include "G4Trd.hh" +#include <sstream> +// G4 Geometry object #include "G4Box.hh" -#include "G4Tubs.hh" #include "G4Trap.hh" +#include "G4Trd.hh" +#include "G4Tubs.hh" -//G4 sensitive -#include "G4SDManager.hh" +// G4 sensitive #include "G4MultiFunctionalDetector.hh" +#include "G4SDManager.hh" -//G4 various object -#include "G4Material.hh" -#include "G4Transform3D.hh" -#include "G4PVPlacement.hh" -#include "G4VisAttributes.hh" +// G4 various object #include "G4Colour.hh" +#include "G4Material.hh" #include "G4PVDivision.hh" +#include "G4PVPlacement.hh" #include "G4SubtractionSolid.hh" +#include "G4Transform3D.hh" +#include "G4VisAttributes.hh" // NPTool header -#include "QQQ.hh" #include "MaterialManager.hh" +#include "NPOptionManager.h" #include "NPSDetectorFactory.hh" -#include "SiliconScorers.hh" +#include "QQQ.hh" #include "RootOutput.h" -#include "NPOptionManager.h" +#include "SiliconScorers.hh" using namespace QQQ_LOCAL; // CLHEP header @@ -61,21 +61,16 @@ using namespace CLHEP; //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // QQQ Specific Method -QQQ::QQQ(){ +QQQ::QQQ() { InitializeMaterial(); m_Event = new TQQQData(); - m_StripScorer=0; + m_StripScorer = 0; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -QQQ::~QQQ(){ -} +QQQ::~QQQ() {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void QQQ::AddTelescope( G4ThreeVector TL, - G4ThreeVector BL, - G4ThreeVector BR, - G4ThreeVector TR) -{ +void QQQ::AddTelescope(G4ThreeVector TL, G4ThreeVector BL, G4ThreeVector BR, G4ThreeVector TR) { m_DefinitionType.push_back(true); m_TL.push_back(TL); @@ -91,13 +86,7 @@ void QQQ::AddTelescope( G4ThreeVector TL, m_beta_w.push_back(0); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void QQQ::AddTelescope( G4double R, - G4double Theta, - G4double Phi, - G4double beta_u, - G4double beta_v, - G4double beta_w) -{ +void QQQ::AddTelescope(G4double R, G4double Theta, G4double Phi, G4double beta_u, G4double beta_v, G4double beta_w) { G4ThreeVector empty = G4ThreeVector(0, 0, 0); m_DefinitionType.push_back(false); @@ -113,20 +102,15 @@ void QQQ::AddTelescope( G4double R, m_BL.push_back(empty); m_BR.push_back(empty); m_TR.push_back(empty); - } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void QQQ::VolumeMaker( G4int DetNumber , - G4ThreeVector Det_pos , - G4RotationMatrix* Det_rot , - G4LogicalVolume* world ) -{ - G4double NbrTelescopes = DetNumber ; - G4String DetectorNumber ; - std::ostringstream Number ; - Number << NbrTelescopes ; - DetectorNumber = Number.str() ; +void QQQ::VolumeMaker(G4int DetNumber, G4ThreeVector Det_pos, G4RotationMatrix* Det_rot, G4LogicalVolume* world) { + G4double NbrTelescopes = DetNumber; + G4String DetectorNumber; + std::ostringstream Number; + Number << NbrTelescopes; + DetectorNumber = Number.str(); //////////////////////////////////////////////////////////////// /////////General Geometry Parameter Definition ///////////////// @@ -134,124 +118,105 @@ void QQQ::VolumeMaker( G4int DetNumber , /////// Starting Volume Definition /////// G4String Name = "QQQ" + DetectorNumber; -// G4Box* solidQQQ = new G4Box(Name+"Solid", 0.5*DetectorSize, 0.5*DetectorSize, 0.5*FrameThickness); - G4Tubs* solidQQQ = new G4Tubs(Name+"Solid", FrameRMin, FrameRMax, 0.5*FrameThickness, FrameStartPhi, FrameDeltaPhi); + // G4Box* solidQQQ = new G4Box(Name+"Solid", 0.5*DetectorSize, 0.5*DetectorSize, 0.5*FrameThickness); + G4Tubs* solidQQQ = + new G4Tubs(Name + "Solid", FrameRMin, FrameRMax, 0.5 * FrameThickness, FrameStartPhi, FrameDeltaPhi); + + G4LogicalVolume* logicQQQ = new G4LogicalVolume(solidQQQ, m_MaterialVacuum, Name + "_logic", 0, 0); - G4LogicalVolume* logicQQQ = - new G4LogicalVolume(solidQQQ, m_MaterialVacuum, Name+"_logic", 0, 0); + new G4PVPlacement(G4Transform3D(*Det_rot, Det_pos), logicQQQ, Name, world, false, DetNumber); - new G4PVPlacement( G4Transform3D(*Det_rot, Det_pos) , - logicQQQ , - Name , - world , - false , - DetNumber); + logicQQQ->SetVisAttributes(G4VisAttributes::GetInvisible()); - logicQQQ->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) ; - - //G4LogicalVolume* logicFrameHorizontal = new G4LogicalVolume(solidFrameHorizontal, m_MaterialAl, Name, 0, 0); - //G4VisAttributes* VisAtt1 = new G4VisAttributes(G4Colour(0.0, 0.5, 1)); - //logicFrameHorizontal->SetVisAttributes(VisAtt1); - - - //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) ; - //G4ThreeVector FrameRightPosition = G4ThreeVector(-0.5 * SiliconSize - 0.5 * (DetectorSize - SiliconSize) / 2 , 0 , 0) ; - - - //new G4PVPlacement( 0, - // FrameTopPosition, - // logicFrameHorizontal, - // Name + "_Frame", - // logicQQQ, - // false, - // DetNumber); - - //new G4PVPlacement( 0, - // FrameBottomPosition, - // logicFrameHorizontal, - // Name + "_Frame", - // logicQQQ, - // false, - // DetNumber); - - //new G4PVPlacement( 0, - // FrameLeftPosition, - // logicFrameVertical, - // Name + "_Frame", - // logicQQQ, - // false, - // DetNumber); - - //new G4PVPlacement( 0, - // FrameRightPosition, + // 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) ; + + // G4LogicalVolume* logicFrameHorizontal = new G4LogicalVolume(solidFrameHorizontal, m_MaterialAl, Name, 0, 0); + // G4VisAttributes* VisAtt1 = new G4VisAttributes(G4Colour(0.0, 0.5, 1)); + // logicFrameHorizontal->SetVisAttributes(VisAtt1); + + // 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) ; G4ThreeVector FrameRightPosition = G4ThreeVector(-0.5 * SiliconSize - 0.5 * (DetectorSize - + // SiliconSize) / 2 , 0 , 0) ; + + // new G4PVPlacement( 0, + // FrameTopPosition, + // logicFrameHorizontal, + // Name + "_Frame", + // logicQQQ, + // false, + // DetNumber); + + // new G4PVPlacement( 0, + // FrameBottomPosition, + // logicFrameHorizontal, + // Name + "_Frame", + // logicQQQ, + // false, + // DetNumber); + + // new G4PVPlacement( 0, + // FrameLeftPosition, // logicFrameVertical, - // Name + "_Frame", - // logicQQQ, - // false, - // DetNumber); - + // Name + "_Frame", + // logicQQQ, + // false, + // DetNumber); - G4ThreeVector posAluFront = G4ThreeVector(0 , 0 , AluStripFront_PosZ) ; - G4ThreeVector posSi1 = G4ThreeVector(0 , 0 , 0 ) ; - G4ThreeVector posSi2 = G4ThreeVector(0 , 0 , 0.5*SiliconThickness1 + AluThickness + DetGap + 0.5*SiliconThickness2 ) ; - G4ThreeVector posAluBack = G4ThreeVector(0 , 0 , AluStripBack_PosZ ) ; + // new G4PVPlacement( 0, + // FrameRightPosition, + // logicFrameVertical, + // Name + "_Frame", + // logicQQQ, + // false, + // DetNumber); - G4Tubs* solidAlu = - new G4Tubs("QQQAlu", DetectorRMin, DetectorRMax, 0.5*AluThickness, DetStartPhi, DetDeltaPhi) ; + G4ThreeVector posAluFront = G4ThreeVector(0, 0, AluStripFront_PosZ); + G4ThreeVector posSi1 = G4ThreeVector(0, 0, 0); + G4ThreeVector posSi2 = G4ThreeVector(0, 0, 0.5 * SiliconThickness1 + AluThickness + DetGap + 0.5 * SiliconThickness2); + G4ThreeVector posAluBack = G4ThreeVector(0, 0, AluStripBack_PosZ); - G4LogicalVolume* logicAlu = - new G4LogicalVolume(solidAlu, m_MaterialAl, "logicAlu", 0, 0, 0) ; + G4Tubs* solidAlu = new G4Tubs("QQQAlu", DetectorRMin, DetectorRMax, 0.5 * AluThickness, DetStartPhi, DetDeltaPhi); + G4LogicalVolume* logicAlu = new G4LogicalVolume(solidAlu, m_MaterialAl, "logicAlu", 0, 0, 0); - new G4PVPlacement(0 , posAluFront , logicAlu , Name + "_AluFront" , logicQQQ , true, DetNumber) ; - new G4PVPlacement(0 , posAluBack , logicAlu , Name + "_AluBack" , logicQQQ , true, DetNumber) ; + new G4PVPlacement(0, posAluFront, logicAlu, Name + "_AluFront", logicQQQ, true, DetNumber); + new G4PVPlacement(0, posAluBack, logicAlu, Name + "_AluBack", logicQQQ, true, DetNumber); + // delta E detector -// delta E detector + G4Tubs* solidSi1 = new G4Tubs("QQQ1", DetectorRMin, DetectorRMax, 0.5 * SiliconThickness1, DetStartPhi, DetDeltaPhi); - G4Tubs* solidSi1 = - new G4Tubs("QQQ1", DetectorRMin, DetectorRMax, 0.5*SiliconThickness1, DetStartPhi,DetDeltaPhi); + G4LogicalVolume* logicSi1 = new G4LogicalVolume(solidSi1, m_MaterialSilicon, "logicSi1", 0, 0, 0); - G4LogicalVolume* logicSi1 = - new G4LogicalVolume(solidSi1, m_MaterialSilicon, "logicSi1", 0, 0, 0); - - //logicAlu->SetVisAttributes(G4VisAttributes::Invisible); + // logicAlu->SetVisAttributes(G4VisAttributes::GetInvisible()); new G4PVPlacement(0, posSi1, logicSi1, Name + "_Si", logicQQQ, true, DetNumber); + logicSi1->SetVisAttributes(G4VisAttributes(G4Colour(1.0, 0.0, 0.0))); // red - logicSi1->SetVisAttributes(G4VisAttributes(G4Colour(1.0, 0.0, 0.0))); // red - -// E detector: + // E detector: - G4Tubs* solidSi2 = - new G4Tubs("QQQ2", DetectorRMin, DetectorRMax, 0.5*SiliconThickness2, DetStartPhi,DetDeltaPhi); + G4Tubs* solidSi2 = new G4Tubs("QQQ2", DetectorRMin, DetectorRMax, 0.5 * SiliconThickness2, DetStartPhi, DetDeltaPhi); - G4LogicalVolume* logicSi2 = - new G4LogicalVolume(solidSi2, m_MaterialSilicon, "logicSi2", 0, 0, 0); + G4LogicalVolume* logicSi2 = new G4LogicalVolume(solidSi2, m_MaterialSilicon, "logicSi2", 0, 0, 0); - //logicAlu->SetVisAttributes(G4VisAttributes::Invisible); + // logicAlu->SetVisAttributes(G4VisAttributes::GetInvisible()); new G4PVPlacement(0, posSi2, logicSi2, Name + "_Si", logicQQQ, true, DetNumber); + logicSi2->SetVisAttributes(G4VisAttributes(G4Colour(1.0, 0.0, 0.0))); // red - logicSi2->SetVisAttributes(G4VisAttributes(G4Colour(1.0, 0.0, 0.0))); // red - - - //attach it to the Silicon plate - logicSi1 ->SetSensitiveDetector(m_StripScorer); - logicSi2 ->SetSensitiveDetector(m_StripScorer); - - + // attach it to the Silicon plate + logicSi1->SetSensitiveDetector(m_StripScorer); + logicSi2->SetSensitiveDetector(m_StripScorer); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... @@ -262,56 +227,54 @@ void QQQ::VolumeMaker( G4int DetNumber , //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Read stream at Configfile to pick-up parameters of detector (Position,...) // Called in DetecorConstruction::ReadDetextorConfiguration Method -void QQQ::ReadConfiguration(NPL::InputParser parser){ +void QQQ::ReadConfiguration(NPL::InputParser parser) { vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithToken("QQQ"); - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << "//// " << blocks.size() << " detectors found " << endl; - - vector<string> cart = {"A","B","C","D"}; - vector<string> sphe = {"R","THETA","PHI","BETA"}; - - for(unsigned int i = 0 ; i < blocks.size() ; i++){ - if(blocks[i]->HasTokenList(cart)){ - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << endl << "//// QQQ " << i+1 << endl; - G4ThreeVector A = NPS::ConvertVector(blocks[i]->GetTVector3("A","mm")); - G4ThreeVector B = NPS::ConvertVector(blocks[i]->GetTVector3("B","mm")); - G4ThreeVector C = NPS::ConvertVector(blocks[i]->GetTVector3("C","mm")); - G4ThreeVector D = NPS::ConvertVector(blocks[i]->GetTVector3("D","mm")); - AddTelescope(A,B,C,D); - + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks.size() << " detectors found " << endl; + + vector<string> cart = {"A", "B", "C", "D"}; + vector<string> sphe = {"R", "THETA", "PHI", "BETA"}; + + for (unsigned int i = 0; i < blocks.size(); i++) { + if (blocks[i]->HasTokenList(cart)) { + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// QQQ " << i + 1 << endl; + G4ThreeVector A = NPS::ConvertVector(blocks[i]->GetTVector3("A", "mm")); + G4ThreeVector B = NPS::ConvertVector(blocks[i]->GetTVector3("B", "mm")); + G4ThreeVector C = NPS::ConvertVector(blocks[i]->GetTVector3("C", "mm")); + G4ThreeVector D = NPS::ConvertVector(blocks[i]->GetTVector3("D", "mm")); + AddTelescope(A, B, C, D); } - else if(blocks[i]->HasTokenList(sphe)){ - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << endl << "//// QQQ " << i+1 << endl; - double R = blocks[i]->GetDouble("R","mm"); - double Theta = blocks[i]->GetDouble("THETA","deg"); - double Phi = blocks[i]->GetDouble("PHI","deg"); - vector<double> beta = blocks[i]->GetVectorDouble("BETA","deg"); - AddTelescope(R,Theta,Phi,beta[0],beta[1],beta[2]); + else if (blocks[i]->HasTokenList(sphe)) { + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// QQQ " << i + 1 << endl; + double R = blocks[i]->GetDouble("R", "mm"); + double Theta = blocks[i]->GetDouble("THETA", "deg"); + double Phi = blocks[i]->GetDouble("PHI", "deg"); + vector<double> beta = blocks[i]->GetVectorDouble("BETA", "deg"); + AddTelescope(R, Theta, Phi, beta[0], beta[1], beta[2]); } - else{ + else { cout << "ERROR: check your input file formatting " << endl; exit(1); } } } - - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Construct detector and inialise sensitive part. // Called After DetecorConstruction::AddDetector Method -void QQQ::ConstructDetector(G4LogicalVolume* world){ +void QQQ::ConstructDetector(G4LogicalVolume* world) { - G4RotationMatrix* Det_rot = NULL; - G4ThreeVector Det_pos = G4ThreeVector(0, 0, 0); - G4ThreeVector Det_u = G4ThreeVector(0, 0, 0); - G4ThreeVector Det_v = G4ThreeVector(0, 0, 0); - G4ThreeVector Det_w = G4ThreeVector(0, 0, 0); + G4RotationMatrix* Det_rot = NULL; + G4ThreeVector Det_pos = G4ThreeVector(0, 0, 0); + G4ThreeVector Det_u = G4ThreeVector(0, 0, 0); + G4ThreeVector Det_v = G4ThreeVector(0, 0, 0); + G4ThreeVector Det_w = G4ThreeVector(0, 0, 0); G4int NumberOfDetector = m_DefinitionType.size(); - for (G4int i = 0 ; i < NumberOfDetector ; i++) { + for (G4int i = 0; i < NumberOfDetector; i++) { // By Point if (m_DefinitionType[i]) { // (u,v,w) unitary vector associated to telescope referencial @@ -327,26 +290,28 @@ void QQQ::ConstructDetector(G4LogicalVolume* world){ // MUST2 Det_rot = new G4RotationMatrix(Det_u, Det_v, Det_w); // translation to place Telescope - Det_pos = (m_TR[i]+m_TL[i]+m_BL[i]+m_BR[i])/4 ; + Det_pos = (m_TR[i] + m_TL[i] + m_BL[i] + m_BR[i]) / 4; } // By Angle else { G4double Theta = m_Theta[i]; - G4double Phi = m_Phi[i]; - //This part because if Phi and Theta = 0 equation are false - if (Theta == 0) Theta = 0.0001; - if (Theta == 2*cos(0)) Theta = 2 * acos(0) - 0.00001; - if (Phi == 0) Phi = 0.0001; - + G4double Phi = m_Phi[i]; + // This part because if Phi and Theta = 0 equation are false + if (Theta == 0) + Theta = 0.0001; + if (Theta == 2 * cos(0)) + Theta = 2 * acos(0) - 0.00001; + if (Phi == 0) + Phi = 0.0001; // (u,v,w) unitary vector associated to telescope referencial // (u,v) // to silicon plan // w perpendicular to (u,v) plan and pointing ThirdStage // Phi is angle between X axis and projection in (X,Y) plan // Theta is angle between position vector and z axis - G4double wX = m_R[i] * sin(Theta / rad) * cos(Phi / rad) ; - G4double wY = m_R[i] * sin(Theta / rad) * sin(Phi / rad) ; + G4double wX = m_R[i] * sin(Theta / rad) * cos(Phi / rad); + G4double wY = m_R[i] * sin(Theta / rad) * sin(Phi / rad); G4double wZ = m_R[i] * cos(Theta / rad); Det_w = G4ThreeVector(wX, wY, wZ); @@ -373,79 +338,73 @@ void QQQ::ConstructDetector(G4LogicalVolume* world){ Det_rot->rotate(m_beta_v[i], Det_v); Det_rot->rotate(m_beta_w[i], Det_w); // translation to place Telescope - Det_pos = Det_w + CT ; + Det_pos = Det_w + CT; } - VolumeMaker(i + 1 , Det_pos , Det_rot , world); + VolumeMaker(i + 1, Det_pos, Det_rot, world); } - delete Det_rot ; + delete Det_rot; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Add Detector branch to the EventTree. // Called After DetecorConstruction::AddDetector Method -void QQQ::InitializeRootOutput(){ - RootOutput *pAnalysis = RootOutput::getInstance(); - TTree *pTree = pAnalysis->GetTree(); - if(!pTree->FindBranch("QQQ")){ - pTree->Branch("QQQ", "TQQQData", &m_Event) ; +void QQQ::InitializeRootOutput() { + RootOutput* pAnalysis = RootOutput::getInstance(); + TTree* pTree = pAnalysis->GetTree(); + if (!pTree->FindBranch("QQQ")) { + pTree->Branch("QQQ", "TQQQData", &m_Event); } - pTree->SetBranchAddress("QQQ", &m_Event) ; + pTree->SetBranchAddress("QQQ", &m_Event); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Read sensitive part and fill the Root tree. // Called at in the EventAction::EndOfEventAvtion -void QQQ::ReadSensitive(const G4Event* event){ +void QQQ::ReadSensitive(const G4Event* event) { m_Event->Clear(); /////////// NPS::HitsMap<G4double*>* StripHitMap; std::map<G4int, G4double**>::iterator Strip_itr; - + G4int StripCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("QQQ_Scorer/StripScorer"); StripHitMap = (NPS::HitsMap<G4double*>*)(event->GetHCofThisEvent()->GetHC(StripCollectionID)); - + // Loop on the Strip map - for (Strip_itr = StripHitMap->GetMap()->begin() ; Strip_itr != StripHitMap->GetMap()->end() ; Strip_itr++){ - + 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]; + + 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)); - } } // clear map for next event StripHitMap->clear(); - - } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void QQQ::InitializeScorers(){ +void QQQ::InitializeScorers() { bool already_exist = false; // Silicon Associate Scorer - m_StripScorer = CheckScorer("QQQ_Scorer",already_exist); - if(already_exist) return; + m_StripScorer = CheckScorer("QQQ_Scorer", already_exist); + if (already_exist) + return; G4VPrimitiveScorer* StripScorer = - new SILICONSCORERS::PS_Silicon_Rectangle("StripScorer",0, - DetectorSize, - DetectorSize, - NumberOfStrip, - 1); + new SILICONSCORERS::PS_Silicon_Rectangle("StripScorer", 0, DetectorSize, DetectorSize, NumberOfStrip, 1); m_StripScorer->RegisterPrimitive(StripScorer); G4SDManager::GetSDMpointer()->AddNewDetector(m_StripScorer); @@ -455,7 +414,7 @@ void QQQ::InitializeScorers(){ //////////////////////////////////////////////////////////////// /////////////////Material Definition /////////////////////////// //////////////////////////////////////////////////////////////// -void QQQ::InitializeMaterial(){ +void QQQ::InitializeMaterial() { m_MaterialSilicon = MaterialManager::getInstance()->GetMaterialFromLibrary("Si"); m_MaterialAl = MaterialManager::getInstance()->GetMaterialFromLibrary("Al"); m_MaterialVacuum = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); @@ -464,25 +423,22 @@ void QQQ::InitializeMaterial(){ //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... - //////////////////////////////////////////////////////////////////////////////// // Construct Method to be pass to the DetectorFactory // //////////////////////////////////////////////////////////////////////////////// -NPS::VDetector* QQQ::Construct(){ - return (NPS::VDetector*) new QQQ(); -} +NPS::VDetector* QQQ::Construct() { return (NPS::VDetector*)new QQQ(); } //////////////////////////////////////////////////////////////////////////////// // Registering the construct method to the factory // //////////////////////////////////////////////////////////////////////////////// -extern"C" { - class proxy_nps_qqq{ - public: - proxy_nps_qqq(){ - NPS::DetectorFactory::getInstance()->AddToken("QQQ","QQQ"); - NPS::DetectorFactory::getInstance()->AddDetector("QQQ",QQQ::Construct); - } - }; - - proxy_nps_qqq p_nps_qqq; +extern "C" { +class proxy_nps_qqq { + public: + proxy_nps_qqq() { + NPS::DetectorFactory::getInstance()->AddToken("QQQ", "QQQ"); + NPS::DetectorFactory::getInstance()->AddDetector("QQQ", QQQ::Construct); + } +}; + +proxy_nps_qqq p_nps_qqq; } diff --git a/NPSimulation/Detectors/SSSD/SSSD.cc b/NPSimulation/Detectors/SSSD/SSSD.cc index f97dd4f9029b3837c04ebe57365d101ef2b76c6d..218c52c7b4a9f3e0055948e9085cbb53cf1b3781 100644 --- a/NPSimulation/Detectors/SSSD/SSSD.cc +++ b/NPSimulation/Detectors/SSSD/SSSD.cc @@ -20,34 +20,34 @@ *****************************************************************************/ // C++ headers -#include <sstream> #include <cmath> #include <limits> -//G4 Geometry object -#include "G4Trd.hh" +#include <sstream> +// G4 Geometry object #include "G4Box.hh" #include "G4Trap.hh" +#include "G4Trd.hh" -//G4 sensitive -#include "G4SDManager.hh" +// G4 sensitive #include "G4MultiFunctionalDetector.hh" +#include "G4SDManager.hh" -//G4 various object -#include "G4Material.hh" -#include "G4Transform3D.hh" -#include "G4PVPlacement.hh" -#include "G4VisAttributes.hh" +// G4 various object #include "G4Colour.hh" +#include "G4Material.hh" #include "G4PVDivision.hh" +#include "G4PVPlacement.hh" #include "G4SubtractionSolid.hh" +#include "G4Transform3D.hh" +#include "G4VisAttributes.hh" // NPTool header -#include "SSSD.hh" #include "MaterialManager.hh" +#include "NPOptionManager.h" #include "NPSDetectorFactory.hh" -#include "SiliconScorers.hh" #include "RootOutput.h" -#include "NPOptionManager.h" +#include "SSSD.hh" +#include "SiliconScorers.hh" using namespace SSSD_LOCAL; // CLHEP header @@ -60,21 +60,16 @@ using namespace CLHEP; //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // SSSD Specific Method -SSSD::SSSD(){ +SSSD::SSSD() { InitializeMaterial(); m_Event = new TSSSDData(); - m_StripScorer=0; + m_StripScorer = 0; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -SSSD::~SSSD(){ -} +SSSD::~SSSD() {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void SSSD::AddTelescope( G4ThreeVector TL, - G4ThreeVector BL, - G4ThreeVector BR, - G4ThreeVector TR) -{ +void SSSD::AddTelescope(G4ThreeVector TL, G4ThreeVector BL, G4ThreeVector BR, G4ThreeVector TR) { m_DefinitionType.push_back(true); m_TL.push_back(TL); @@ -90,13 +85,7 @@ void SSSD::AddTelescope( G4ThreeVector TL, m_beta_w.push_back(0); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void SSSD::AddTelescope( G4double R, - G4double Theta, - G4double Phi, - G4double beta_u, - G4double beta_v, - G4double beta_w) -{ +void SSSD::AddTelescope(G4double R, G4double Theta, G4double Phi, G4double beta_u, G4double beta_v, G4double beta_w) { G4ThreeVector empty = G4ThreeVector(0, 0, 0); m_DefinitionType.push_back(false); @@ -112,20 +101,15 @@ void SSSD::AddTelescope( G4double R, m_BL.push_back(empty); m_BR.push_back(empty); m_TR.push_back(empty); - } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void SSSD::VolumeMaker( G4int DetNumber , - G4ThreeVector Det_pos , - G4RotationMatrix* Det_rot , - G4LogicalVolume* world ) -{ - G4double NbrTelescopes = DetNumber ; - G4String DetectorNumber ; - std::ostringstream Number ; - Number << NbrTelescopes ; - DetectorNumber = Number.str() ; +void SSSD::VolumeMaker(G4int DetNumber, G4ThreeVector Det_pos, G4RotationMatrix* Det_rot, G4LogicalVolume* world) { + G4double NbrTelescopes = DetNumber; + G4String DetectorNumber; + std::ostringstream Number; + Number << NbrTelescopes; + DetectorNumber = Number.str(); //////////////////////////////////////////////////////////////// /////////General Geometry Parameter Definition ///////////////// @@ -133,97 +117,61 @@ void SSSD::VolumeMaker( G4int DetNumber , /////// Starting Volume Definition /////// G4String Name = "SSSD" + DetectorNumber; - G4Box* solidSSSD = 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* logicSSSD = - new G4LogicalVolume(solidSSSD, m_MaterialVacuum, Name+"_logic", 0, 0); + G4LogicalVolume* logicSSSD = new G4LogicalVolume(solidSSSD, m_MaterialVacuum, Name + "_logic", 0, 0); - new G4PVPlacement( G4Transform3D(*Det_rot, Det_pos) , - logicSSSD , - Name , - world , - false , - DetNumber); + new G4PVPlacement(G4Transform3D(*Det_rot, Det_pos), logicSSSD, Name, world, false, DetNumber); - logicSSSD->SetVisAttributes(G4VisAttributes::Invisible); + logicSSSD->SetVisAttributes(G4VisAttributes::GetInvisible()); // 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) ; + 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); G4LogicalVolume* logicFrameHorizontal = new G4LogicalVolume(solidFrameHorizontal, m_MaterialAl, Name, 0, 0); G4VisAttributes* VisAtt1 = new G4VisAttributes(G4Colour(0.0, 0.5, 1)); logicFrameHorizontal->SetVisAttributes(VisAtt1); - 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) ; - G4ThreeVector FrameRightPosition = G4ThreeVector(-0.5 * SiliconSize - 0.5 * (DetectorSize - SiliconSize) / 2 , 0 , 0) ; - + logicFrameVertical->SetVisAttributes(VisAtt1); - new G4PVPlacement( 0, - FrameTopPosition, - logicFrameHorizontal, - Name + "_Frame", - logicSSSD, - false, - DetNumber); + 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); + G4ThreeVector FrameRightPosition = G4ThreeVector(-0.5 * SiliconSize - 0.5 * (DetectorSize - SiliconSize) / 2, 0, 0); - new G4PVPlacement( 0, - FrameBottomPosition, - logicFrameHorizontal, - Name + "_Frame", - logicSSSD, - false, - DetNumber); + new G4PVPlacement(0, FrameTopPosition, logicFrameHorizontal, Name + "_Frame", logicSSSD, false, DetNumber); - new G4PVPlacement( 0, - FrameLeftPosition, - logicFrameVertical, - Name + "_Frame", - logicSSSD, - false, - DetNumber); + new G4PVPlacement(0, FrameBottomPosition, logicFrameHorizontal, Name + "_Frame", logicSSSD, false, DetNumber); - new G4PVPlacement( 0, - FrameRightPosition, - logicFrameVertical, - Name + "_Frame", - logicSSSD, - false, - DetNumber); + new G4PVPlacement(0, FrameLeftPosition, logicFrameVertical, Name + "_Frame", logicSSSD, false, DetNumber); + new G4PVPlacement(0, FrameRightPosition, logicFrameVertical, Name + "_Frame", logicSSSD, false, DetNumber); - G4ThreeVector posAluFront = G4ThreeVector(0 , 0 , AluStripFront_PosZ) ; - G4ThreeVector posSi = G4ThreeVector(0 , 0 , 0 ) ; - G4ThreeVector posAluBack = G4ThreeVector(0 , 0 , AluStripBack_PosZ ) ; + G4ThreeVector posAluFront = G4ThreeVector(0, 0, AluStripFront_PosZ); + G4ThreeVector posSi = G4ThreeVector(0, 0, 0); + G4ThreeVector posAluBack = G4ThreeVector(0, 0, AluStripBack_PosZ); - G4Box* solidAlu = - new G4Box("SSSDAlu", 0.5*SiliconSize, 0.5*SiliconSize, 0.5*AluThickness) ; + G4Box* solidAlu = new G4Box("SSSDAlu", 0.5 * SiliconSize, 0.5 * SiliconSize, 0.5 * AluThickness); - G4LogicalVolume* logicAlu = - new G4LogicalVolume(solidAlu, m_MaterialAl, "logicAlu", 0, 0, 0) ; + G4LogicalVolume* logicAlu = new G4LogicalVolume(solidAlu, m_MaterialAl, "logicAlu", 0, 0, 0); + new G4PVPlacement(0, posAluFront, logicAlu, Name + "_AluFront", logicSSSD, true, DetNumber); - new G4PVPlacement(0 , posAluFront , logicAlu , Name + "_AluFront" , logicSSSD , true, DetNumber) ; + new G4PVPlacement(0, posAluBack, logicAlu, Name + "_AluBack", logicSSSD, true, DetNumber); - new G4PVPlacement(0 , posAluBack , logicAlu , Name + "_AluBack" , logicSSSD , true, DetNumber) ; + G4Box* solidSi = new G4Box("SSSD", 0.5 * SiliconSize, 0.5 * SiliconSize, 0.5 * SiliconThickness); - G4Box* solidSi = - new G4Box("SSSD", 0.5*SiliconSize, 0.5*SiliconSize, 0.5*SiliconThickness); + G4LogicalVolume* logicSi = new G4LogicalVolume(solidSi, m_MaterialSilicon, "logicSi", 0, 0, 0); - G4LogicalVolume* logicSi = - new G4LogicalVolume(solidSi, m_MaterialSilicon, "logicSi", 0, 0, 0); - - logicAlu->SetVisAttributes(G4VisAttributes::Invisible); + logicAlu->SetVisAttributes(G4VisAttributes::GetInvisible()); new G4PVPlacement(0, posSi, logicSi, Name + "_Si", logicSSSD, true, DetNumber); - //attach it to the Silicon plate - logicSi ->SetSensitiveDetector(m_StripScorer); + // attach it to the Silicon plate + logicSi->SetSensitiveDetector(m_StripScorer); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... @@ -234,55 +182,54 @@ void SSSD::VolumeMaker( G4int DetNumber , //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Read stream at Configfile to pick-up parameters of detector (Position,...) // Called in DetecorConstruction::ReadDetextorConfiguration Method -void SSSD::ReadConfiguration(NPL::InputParser parser){ -vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithToken("SSSD"); - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << "//// " << blocks.size() << " detectors found " << endl; - - vector<string> cart = {"A","B","C","D"}; - vector<string> sphe = {"R","THETA","PHI","BETA"}; - - for(unsigned int i = 0 ; i < blocks.size() ; i++){ - if(blocks[i]->HasTokenList(cart)){ - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << endl << "//// SSSD " << i+1 << endl; - G4ThreeVector A = NPS::ConvertVector(blocks[i]->GetTVector3("A","mm")); - G4ThreeVector B = NPS::ConvertVector(blocks[i]->GetTVector3("B","mm")); - G4ThreeVector C = NPS::ConvertVector(blocks[i]->GetTVector3("C","mm")); - G4ThreeVector D = NPS::ConvertVector(blocks[i]->GetTVector3("D","mm")); - AddTelescope(A,B,C,D); +void SSSD::ReadConfiguration(NPL::InputParser parser) { + vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithToken("SSSD"); + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks.size() << " detectors found " << endl; + + vector<string> cart = {"A", "B", "C", "D"}; + vector<string> sphe = {"R", "THETA", "PHI", "BETA"}; + + for (unsigned int i = 0; i < blocks.size(); i++) { + if (blocks[i]->HasTokenList(cart)) { + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// SSSD " << i + 1 << endl; + G4ThreeVector A = NPS::ConvertVector(blocks[i]->GetTVector3("A", "mm")); + G4ThreeVector B = NPS::ConvertVector(blocks[i]->GetTVector3("B", "mm")); + G4ThreeVector C = NPS::ConvertVector(blocks[i]->GetTVector3("C", "mm")); + G4ThreeVector D = NPS::ConvertVector(blocks[i]->GetTVector3("D", "mm")); + AddTelescope(A, B, C, D); } - else if(blocks[i]->HasTokenList(sphe)){ - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << endl << "//// SSSD " << i+1 << endl; - double R = blocks[i]->GetDouble("R","mm"); - double Theta = blocks[i]->GetDouble("THETA","deg"); - double Phi = blocks[i]->GetDouble("PHI","deg"); - vector<double> beta = blocks[i]->GetVectorDouble("BETA","deg"); - AddTelescope(R,Theta,Phi,beta[0],beta[1],beta[2]); + else if (blocks[i]->HasTokenList(sphe)) { + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// SSSD " << i + 1 << endl; + double R = blocks[i]->GetDouble("R", "mm"); + double Theta = blocks[i]->GetDouble("THETA", "deg"); + double Phi = blocks[i]->GetDouble("PHI", "deg"); + vector<double> beta = blocks[i]->GetVectorDouble("BETA", "deg"); + AddTelescope(R, Theta, Phi, beta[0], beta[1], beta[2]); } - else{ + else { cout << "ERROR: check your input file formatting " << endl; exit(1); } } } - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Construct detector and inialise sensitive part. // Called After DetecorConstruction::AddDetector Method -void SSSD::ConstructDetector(G4LogicalVolume* world){ +void SSSD::ConstructDetector(G4LogicalVolume* world) { - G4RotationMatrix* Det_rot = NULL; - G4ThreeVector Det_pos = G4ThreeVector(0, 0, 0); - G4ThreeVector Det_u = G4ThreeVector(0, 0, 0); - G4ThreeVector Det_v = G4ThreeVector(0, 0, 0); - G4ThreeVector Det_w = G4ThreeVector(0, 0, 0); + G4RotationMatrix* Det_rot = NULL; + G4ThreeVector Det_pos = G4ThreeVector(0, 0, 0); + G4ThreeVector Det_u = G4ThreeVector(0, 0, 0); + G4ThreeVector Det_v = G4ThreeVector(0, 0, 0); + G4ThreeVector Det_w = G4ThreeVector(0, 0, 0); G4int NumberOfDetector = m_DefinitionType.size(); - for (G4int i = 0 ; i < NumberOfDetector ; i++) { + for (G4int i = 0; i < NumberOfDetector; i++) { // By Point if (m_DefinitionType[i]) { // (u,v,w) unitary vector associated to telescope referencial @@ -298,26 +245,28 @@ void SSSD::ConstructDetector(G4LogicalVolume* world){ // MUST2 Det_rot = new G4RotationMatrix(Det_u, Det_v, Det_w); // translation to place Telescope - Det_pos = (m_TR[i]+m_TL[i]+m_BL[i]+m_BR[i])/4 ; + Det_pos = (m_TR[i] + m_TL[i] + m_BL[i] + m_BR[i]) / 4; } // By Angle else { G4double Theta = m_Theta[i]; - G4double Phi = m_Phi[i]; - //This part because if Phi and Theta = 0 equation are false - if (Theta == 0) Theta = 0.0001; - if (Theta == 2*cos(0)) Theta = 2 * acos(0) - 0.00001; - if (Phi == 0) Phi = 0.0001; - + G4double Phi = m_Phi[i]; + // This part because if Phi and Theta = 0 equation are false + if (Theta == 0) + Theta = 0.0001; + if (Theta == 2 * cos(0)) + Theta = 2 * acos(0) - 0.00001; + if (Phi == 0) + Phi = 0.0001; // (u,v,w) unitary vector associated to telescope referencial // (u,v) // to silicon plan // w perpendicular to (u,v) plan and pointing ThirdStage // Phi is angle between X axis and projection in (X,Y) plan // Theta is angle between position vector and z axis - G4double wX = m_R[i] * sin(Theta / rad) * cos(Phi / rad) ; - G4double wY = m_R[i] * sin(Theta / rad) * sin(Phi / rad) ; + G4double wX = m_R[i] * sin(Theta / rad) * cos(Phi / rad); + G4double wY = m_R[i] * sin(Theta / rad) * sin(Phi / rad); G4double wZ = m_R[i] * cos(Theta / rad); Det_w = G4ThreeVector(wX, wY, wZ); @@ -344,79 +293,73 @@ void SSSD::ConstructDetector(G4LogicalVolume* world){ Det_rot->rotate(m_beta_v[i], Det_v); Det_rot->rotate(m_beta_w[i], Det_w); // translation to place Telescope - Det_pos = Det_w + CT ; + Det_pos = Det_w + CT; } - VolumeMaker(i + 1 , Det_pos , Det_rot , world); + VolumeMaker(i + 1, Det_pos, Det_rot, world); } - delete Det_rot ; + delete Det_rot; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Add Detector branch to the EventTree. // Called After DetecorConstruction::AddDetector Method -void SSSD::InitializeRootOutput(){ - RootOutput *pAnalysis = RootOutput::getInstance(); - TTree *pTree = pAnalysis->GetTree(); - if(!pTree->FindBranch("SSSD")){ - pTree->Branch("SSSD", "TSSSDData", &m_Event) ; +void SSSD::InitializeRootOutput() { + RootOutput* pAnalysis = RootOutput::getInstance(); + TTree* pTree = pAnalysis->GetTree(); + if (!pTree->FindBranch("SSSD")) { + pTree->Branch("SSSD", "TSSSDData", &m_Event); } - pTree->SetBranchAddress("SSSD", &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 SSSD::ReadSensitive(const G4Event* event){ +void SSSD::ReadSensitive(const G4Event* event) { m_Event->Clear(); /////////// NPS::HitsMap<G4double*>* StripHitMap; std::map<G4int, G4double**>::iterator Strip_itr; - + G4int StripCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("SSSD_Scorer/StripScorer"); StripHitMap = (NPS::HitsMap<G4double*>*)(event->GetHCofThisEvent()->GetHC(StripCollectionID)); - + // Loop on the Strip map - for (Strip_itr = StripHitMap->GetMap()->begin() ; Strip_itr != StripHitMap->GetMap()->end() ; Strip_itr++){ - + 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]; + + 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)); - } } // clear map for next event StripHitMap->clear(); - - } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void SSSD::InitializeScorers(){ +void SSSD::InitializeScorers() { bool already_exist = false; // Silicon Associate Scorer - m_StripScorer = CheckScorer("SSSD_Scorer",already_exist); - if(already_exist) return; + m_StripScorer = CheckScorer("SSSD_Scorer", already_exist); + if (already_exist) + return; G4VPrimitiveScorer* StripScorer = - new SILICONSCORERS::PS_Silicon_Rectangle("StripScorer",0, - DetectorSize, - DetectorSize, - NumberOfStrip, - 1); + new SILICONSCORERS::PS_Silicon_Rectangle("StripScorer", 0, DetectorSize, DetectorSize, NumberOfStrip, 1); m_StripScorer->RegisterPrimitive(StripScorer); G4SDManager::GetSDMpointer()->AddNewDetector(m_StripScorer); @@ -426,7 +369,7 @@ void SSSD::InitializeScorers(){ //////////////////////////////////////////////////////////////// /////////////////Material Definition /////////////////////////// //////////////////////////////////////////////////////////////// -void SSSD::InitializeMaterial(){ +void SSSD::InitializeMaterial() { m_MaterialSilicon = MaterialManager::getInstance()->GetMaterialFromLibrary("Si"); m_MaterialAl = MaterialManager::getInstance()->GetMaterialFromLibrary("Al"); m_MaterialVacuum = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); @@ -435,25 +378,22 @@ void SSSD::InitializeMaterial(){ //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... - //////////////////////////////////////////////////////////////////////////////// // Construct Method to be pass to the DetectorFactory // //////////////////////////////////////////////////////////////////////////////// -NPS::VDetector* SSSD::Construct(){ - return (NPS::VDetector*) new SSSD(); -} +NPS::VDetector* SSSD::Construct() { return (NPS::VDetector*)new SSSD(); } //////////////////////////////////////////////////////////////////////////////// // Registering the construct method to the factory // //////////////////////////////////////////////////////////////////////////////// -extern"C" { - class proxy_nps_sssd{ - public: - proxy_nps_sssd(){ - NPS::DetectorFactory::getInstance()->AddToken("SSSD","SSSD"); - NPS::DetectorFactory::getInstance()->AddDetector("SSSD",SSSD::Construct); - } - }; - - proxy_nps_sssd p_nps_sssd; +extern "C" { +class proxy_nps_sssd { + public: + proxy_nps_sssd() { + NPS::DetectorFactory::getInstance()->AddToken("SSSD", "SSSD"); + NPS::DetectorFactory::getInstance()->AddDetector("SSSD", SSSD::Construct); + } +}; + +proxy_nps_sssd p_nps_sssd; } diff --git a/NPSimulation/Detectors/Sharc/Sharc.cc b/NPSimulation/Detectors/Sharc/Sharc.cc index fc0dd0decec2328faaf8e2e799622ebf2e8bb430..8def44b37edbf6675542aab171b47d474de95d24 100644 --- a/NPSimulation/Detectors/Sharc/Sharc.cc +++ b/NPSimulation/Detectors/Sharc/Sharc.cc @@ -20,32 +20,32 @@ *****************************************************************************/ // C++ headers -#include <sstream> #include <cmath> #include <limits> -//G4 Geometry object +#include <sstream> +// G4 Geometry object #include "G4Box.hh" #include "G4Tubs.hh" -//G4 sensitive +// G4 sensitive #include "G4SDManager.hh" -//G4 various object -#include "G4MaterialTable.hh" +// G4 various object +#include "G4Colour.hh" #include "G4Element.hh" #include "G4ElementTable.hh" -#include "G4Transform3D.hh" -#include "G4PVPlacement.hh" -#include "G4Colour.hh" +#include "G4MaterialTable.hh" #include "G4PVDivision.hh" +#include "G4PVPlacement.hh" #include "G4SubtractionSolid.hh" +#include "G4Transform3D.hh" #include "G4UnionSolid.hh" // NPS -#include "Sharc.hh" #include "DSSDScorers.hh" #include "InteractionScorers.hh" #include "MaterialManager.hh" #include "NPSDetectorFactory.hh" +#include "Sharc.hh" // NPL #include "NPOptionManager.h" @@ -60,33 +60,34 @@ using namespace CLHEP; //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Sharc Specific Method -Sharc::Sharc(){ +Sharc::Sharc() { InitializeMaterial(); m_Event = new TSharcData(); // Dark Grey - SiliconVisAtt = new G4VisAttributes(G4Colour(0.3, 0.3, 0.3)) ; + SiliconVisAtt = new G4VisAttributes(G4Colour(0.3, 0.3, 0.3)); // Green - PCBVisAtt = new G4VisAttributes(G4Colour(0.2, 0.5, 0.2)) ; + PCBVisAtt = new G4VisAttributes(G4Colour(0.2, 0.5, 0.2)); // Gold Yellow - PADVisAtt = new G4VisAttributes(G4Colour(0.5, 0.5, 0.2)) ; + PADVisAtt = new G4VisAttributes(G4Colour(0.5, 0.5, 0.2)); // Light Grey - FrameVisAtt = new G4VisAttributes(G4Colour(0.5, 0.5, 0.5)) ; + FrameVisAtt = new G4VisAttributes(G4Colour(0.5, 0.5, 0.5)); - m_BOXScorer = 0 ; - m_PADScorer = 0 ; + m_BOXScorer = 0; + m_PADScorer = 0; m_QQQScorer = 0; - } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -Sharc::~Sharc(){ - //delete m_BOXScorer; - //delete m_PADScorer; - //delete m_QQQScorer; +Sharc::~Sharc() { + // delete m_BOXScorer; + // delete m_PADScorer; + // delete m_QQQScorer; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Sharc::AddBoxDetector(G4double Z,G4double Thickness1,G4double Thickness2,G4double Thickness3,G4double Thickness4,G4double ThicknessPAD1,G4double ThicknessPAD2,G4double ThicknessPAD3,G4double ThicknessPAD4){ +void Sharc::AddBoxDetector(G4double Z, G4double Thickness1, G4double Thickness2, G4double Thickness3, + G4double Thickness4, G4double ThicknessPAD1, G4double ThicknessPAD2, G4double ThicknessPAD3, + G4double ThicknessPAD4) { m_Type.push_back(true); m_Z.push_back(Z); @@ -104,11 +105,10 @@ void Sharc::AddBoxDetector(G4double Z,G4double Thickness1,G4double Thickness2,G4 ThicknessPAD.push_back(ThicknessPAD3); ThicknessPAD.push_back(ThicknessPAD4); m_ThicknessPAD.push_back(ThicknessPAD); - } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Sharc::AddQQQDetector(G4ThreeVector Pos,G4double Thickness){ +void Sharc::AddQQQDetector(G4ThreeVector Pos, G4double Thickness) { m_Type.push_back(false); m_Pos.push_back(Pos); m_ThicknessQQQ.push_back(Thickness); @@ -118,43 +118,50 @@ void Sharc::AddQQQDetector(G4ThreeVector Pos,G4double Thickness){ // Virtual Method of NPS::VDetector class // Read stream at Configfile to pick-up parameters of detector (Position,...) // Called in DetecorConstruction::ReadDetextorConfiguration Method -void Sharc::ReadConfiguration(NPL::InputParser parser){ +void Sharc::ReadConfiguration(NPL::InputParser parser) { vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithToken("Sharc"); - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << "//// " << blocks.size() << " detectors found " << endl; - - vector<string> tokenQQQ = {"Z","R","Phi","ThicknessDetector"}; - vector<string> tokenBOX = {"Z","ThicknessDetector1","ThicknessDetector2","ThicknessDetector3","ThicknessDetector4","ThicknessPAD1","ThicknessPAD2","ThicknessPAD3","ThicknessPAD4"}; - - for(unsigned int i = 0 ; i < blocks.size() ; i++){ - - if(blocks[i]->GetMainValue()=="QQQ" && blocks[i]->HasTokenList(tokenQQQ)){ - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << endl << "//// Sharc QQQ " << i+1 << endl; - double Z = blocks[i]->GetDouble("Z","mm"); - double R = blocks[i]->GetDouble("R","mm"); - double Phi = blocks[i]->GetDouble("Phi","deg"); - double Thickness= blocks[i]->GetDouble("ThicknessDetector","micrometer"); - AddQQQDetector(G4ThreeVector(R,Phi,Z),Thickness); + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks.size() << " detectors found " << endl; + + vector<string> tokenQQQ = {"Z", "R", "Phi", "ThicknessDetector"}; + vector<string> tokenBOX = {"Z", + "ThicknessDetector1", + "ThicknessDetector2", + "ThicknessDetector3", + "ThicknessDetector4", + "ThicknessPAD1", + "ThicknessPAD2", + "ThicknessPAD3", + "ThicknessPAD4"}; + + for (unsigned int i = 0; i < blocks.size(); i++) { + + if (blocks[i]->GetMainValue() == "QQQ" && blocks[i]->HasTokenList(tokenQQQ)) { + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// Sharc QQQ " << i + 1 << endl; + double Z = blocks[i]->GetDouble("Z", "mm"); + double R = blocks[i]->GetDouble("R", "mm"); + double Phi = blocks[i]->GetDouble("Phi", "deg"); + double Thickness = blocks[i]->GetDouble("ThicknessDetector", "micrometer"); + AddQQQDetector(G4ThreeVector(R, Phi, Z), Thickness); } - else if(blocks[i]->GetMainValue()=="BOX" && blocks[i]->HasTokenList(tokenBOX)){ - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << endl << "//// Sharc Box " << i+1 << endl; - double Z = blocks[i]->GetDouble("Z","mm"); - double Thickness1= blocks[i]->GetDouble("ThicknessDetector1","micrometer"); - double Thickness2= blocks[i]->GetDouble("ThicknessDetector2","micrometer"); - double Thickness3= blocks[i]->GetDouble("ThicknessDetector3","micrometer"); - double Thickness4= blocks[i]->GetDouble("ThicknessDetector4","micrometer"); - double ThicknessPAD1 = blocks[i]->GetDouble("ThicknessPAD1","micrometer"); - double ThicknessPAD2 = blocks[i]->GetDouble("ThicknessPAD2","micrometer"); - double ThicknessPAD3 = blocks[i]->GetDouble("ThicknessPAD3","micrometer"); - double ThicknessPAD4 = blocks[i]->GetDouble("ThicknessPAD4","micrometer"); - AddBoxDetector(Z,Thickness1,Thickness2,Thickness3,Thickness4, - ThicknessPAD1,ThicknessPAD2,ThicknessPAD3,ThicknessPAD4); - + else if (blocks[i]->GetMainValue() == "BOX" && blocks[i]->HasTokenList(tokenBOX)) { + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// Sharc Box " << i + 1 << endl; + double Z = blocks[i]->GetDouble("Z", "mm"); + double Thickness1 = blocks[i]->GetDouble("ThicknessDetector1", "micrometer"); + double Thickness2 = blocks[i]->GetDouble("ThicknessDetector2", "micrometer"); + double Thickness3 = blocks[i]->GetDouble("ThicknessDetector3", "micrometer"); + double Thickness4 = blocks[i]->GetDouble("ThicknessDetector4", "micrometer"); + double ThicknessPAD1 = blocks[i]->GetDouble("ThicknessPAD1", "micrometer"); + double ThicknessPAD2 = blocks[i]->GetDouble("ThicknessPAD2", "micrometer"); + double ThicknessPAD3 = blocks[i]->GetDouble("ThicknessPAD3", "micrometer"); + double ThicknessPAD4 = blocks[i]->GetDouble("ThicknessPAD4", "micrometer"); + AddBoxDetector(Z, Thickness1, Thickness2, Thickness3, Thickness4, ThicknessPAD1, ThicknessPAD2, ThicknessPAD3, + ThicknessPAD4); } - else{ + else { cout << "Warning: check your input file formatting " << endl; } } @@ -163,166 +170,136 @@ void Sharc::ReadConfiguration(NPL::InputParser parser){ //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Construct detector and inialise sensitive part. // Called After DetecorConstruction::AddDetector Method -void Sharc::ConstructDetector(G4LogicalVolume* world){ +void Sharc::ConstructDetector(G4LogicalVolume* world) { ConstructBOXDetector(world); ConstructQQQDetector(world); ConstructTargetFan(world); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Sharc::ConstructTargetFan(G4LogicalVolume* world){ - G4double FanBase_OutterRadius = 8*mm; - G4double FanBase_InnerRadius = 4*mm; - G4double FanBase_Thickness = 9*mm; - - G4double FanPlate_OutterRadius = 66*mm; - G4double FanPlate_InnerRadius = 0*mm; - G4double FanPlateHole_OutterRadius = 53*mm; - G4double FanPlateHole_InnerRadius = 18*mm; - G4double FanPlate_Thickness = 3*mm; - - //G4double TargetFrame_Thickness; - //TargetFrame_Thickness= 0.5*mm; - G4double Fan_Shift = 70*mm+16*mm; - - G4Tubs* FanBaseSolid= new G4Tubs("TargetFanBase" , - FanBase_InnerRadius, - FanBase_OutterRadius, - FanBase_Thickness*0.5, - 0., - M_PI*2); - - G4Tubs* FanPlateWholeSolid= new G4Tubs("TargetFanPlate" , - FanPlate_InnerRadius, - FanPlate_OutterRadius, - FanPlate_Thickness*0.5, - 0*deg, - 60*deg); - - G4Tubs* FanPlateHoleSolid= new G4Tubs("TargetFanPlateHole" , - FanPlateHole_InnerRadius, - FanPlateHole_OutterRadius, - FanPlate_Thickness, - 0*deg, - 60*deg); - - G4SubtractionSolid* FanPlateSolid = - new G4SubtractionSolid("TargetFanSolid",FanPlateWholeSolid,FanPlateHoleSolid,new G4RotationMatrix(),G4ThreeVector(8*mm*sin(60*deg),8*mm*cos(60*deg),0)); +void Sharc::ConstructTargetFan(G4LogicalVolume* world) { + G4double FanBase_OutterRadius = 8 * mm; + G4double FanBase_InnerRadius = 4 * mm; + G4double FanBase_Thickness = 9 * mm; + G4double FanPlate_OutterRadius = 66 * mm; + G4double FanPlate_InnerRadius = 0 * mm; + G4double FanPlateHole_OutterRadius = 53 * mm; + G4double FanPlateHole_InnerRadius = 18 * mm; + G4double FanPlate_Thickness = 3 * mm; - G4UnionSolid* TargetFanSolid = - new G4UnionSolid("TargetFanSolid",FanPlateSolid,FanBaseSolid,new G4RotationMatrix(),G4ThreeVector(16*mm*sin(60*deg),16*mm*cos(60*deg),FanPlate_Thickness)); + // G4double TargetFrame_Thickness; + // TargetFrame_Thickness= 0.5*mm; + G4double Fan_Shift = 70 * mm + 16 * mm; + G4Tubs* FanBaseSolid = + new G4Tubs("TargetFanBase", FanBase_InnerRadius, FanBase_OutterRadius, FanBase_Thickness * 0.5, 0., M_PI * 2); - G4LogicalVolume* TargetFan = - new G4LogicalVolume(TargetFanSolid,m_MaterialVacuum,"TargetFan", 0, 0, 0); + G4Tubs* FanPlateWholeSolid = new G4Tubs("TargetFanPlate", FanPlate_InnerRadius, FanPlate_OutterRadius, + FanPlate_Thickness * 0.5, 0 * deg, 60 * deg); - G4RotationMatrix* Rot = new G4RotationMatrix(); - Rot->rotateZ(30*deg-9*deg); - new G4PVPlacement(Rot, - G4ThreeVector(-Fan_Shift,0,0.5*FanPlate_Thickness), - TargetFan,"TargetFan",world,false,0); + G4Tubs* FanPlateHoleSolid = new G4Tubs("TargetFanPlateHole", FanPlateHole_InnerRadius, FanPlateHole_OutterRadius, + FanPlate_Thickness, 0 * deg, 60 * deg); + G4SubtractionSolid* FanPlateSolid = + new G4SubtractionSolid("TargetFanSolid", FanPlateWholeSolid, FanPlateHoleSolid, new G4RotationMatrix(), + G4ThreeVector(8 * mm * sin(60 * deg), 8 * mm * cos(60 * deg), 0)); + G4UnionSolid* TargetFanSolid = + new G4UnionSolid("TargetFanSolid", FanPlateSolid, FanBaseSolid, new G4RotationMatrix(), + G4ThreeVector(16 * mm * sin(60 * deg), 16 * mm * cos(60 * deg), FanPlate_Thickness)); + + G4LogicalVolume* TargetFan = new G4LogicalVolume(TargetFanSolid, m_MaterialVacuum, "TargetFan", 0, 0, 0); + + G4RotationMatrix* Rot = new G4RotationMatrix(); + Rot->rotateZ(30 * deg - 9 * deg); + new G4PVPlacement(Rot, G4ThreeVector(-Fan_Shift, 0, 0.5 * FanPlate_Thickness), TargetFan, "TargetFan", world, false, + 0); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Sharc::ConstructBOXDetector(G4LogicalVolume* world){ - for(unsigned int i = 0 ; i < m_Z.size() ; i++){ - for (unsigned int j = 0 ; j < 4; j++) { +void Sharc::ConstructBOXDetector(G4LogicalVolume* world) { + for (unsigned int i = 0; i < m_Z.size(); i++) { + for (unsigned int j = 0; j < 4; j++) { int DetNbr = 0; - if(m_Z[i]<0) DetNbr=j+1+4; - else DetNbr=j+1+8; + if (m_Z[i] < 0) + DetNbr = j + 1 + 4; + else + DetNbr = j + 1 + 8; // create the Box DSSD // Make the a single detector geometry - G4Box* PCBFull = new G4Box("PCBFull" , - BOX_PCB_Length/2., - BOX_PCB_Width/2., - BOX_PCB_Thickness/2.); - - G4Box* WaferShape = new G4Box("WaferShape", - BOX_Wafer_Length/2., - BOX_Wafer_Width/2., - BOX_PCB_Thickness/2.+0.1*mm); - - G4Box* Wafer = new G4Box("Wafer", - BOX_Wafer_Length/2., - BOX_Wafer_Width/2., - m_ThicknessBOX[i][j]/2.); - - G4Box* ActiveWafer = new G4Box("ActiveWafer", - BOX_ActiveWafer_Length/2., - BOX_ActiveWafer_Width/2., - m_ThicknessBOX[i][j]/2.); + G4Box* PCBFull = new G4Box("PCBFull", BOX_PCB_Length / 2., BOX_PCB_Width / 2., BOX_PCB_Thickness / 2.); + + G4Box* WaferShape = + new G4Box("WaferShape", BOX_Wafer_Length / 2., BOX_Wafer_Width / 2., BOX_PCB_Thickness / 2. + 0.1 * mm); + + G4Box* Wafer = new G4Box("Wafer", BOX_Wafer_Length / 2., BOX_Wafer_Width / 2., m_ThicknessBOX[i][j] / 2.); + + G4Box* ActiveWafer = + new G4Box("ActiveWafer", BOX_ActiveWafer_Length / 2., BOX_ActiveWafer_Width / 2., m_ThicknessBOX[i][j] / 2.); G4double BOX_PCB_Slot_Width; G4double BOX_PCB_Slot_Deepness; G4double BOX_PCB_Slot_Position; G4double BOX_DetectorSpacing; - if(m_ThicknessPAD[i][j]>0){ //PAD Case + if (m_ThicknessPAD[i][j] > 0) { // PAD Case BOX_PCB_Slot_Width = BOX_PCB_Slot_Width2; BOX_PCB_Slot_Deepness = BOX_PCB_Slot_Deepness2; BOX_PCB_Slot_Position = BOX_PCB_Slot_Position2; - BOX_DetectorSpacing = BOX_DetectorSpacing2; + BOX_DetectorSpacing = BOX_DetectorSpacing2; } - else{ // No Pad Case + else { // No Pad Case BOX_PCB_Slot_Width = BOX_PCB_Slot_Width1; BOX_PCB_Slot_Deepness = BOX_PCB_Slot_Deepness1; BOX_PCB_Slot_Position = BOX_PCB_Slot_Position1; - BOX_DetectorSpacing = BOX_DetectorSpacing1 ; + BOX_DetectorSpacing = BOX_DetectorSpacing1; } - G4Box* SlotShape = new G4Box("SlotShape", - BOX_PCB_Slot_Width/2., - BOX_PCB_Width/2.+0.1*mm, - BOX_PCB_Slot_Deepness); + G4Box* SlotShape = + new G4Box("SlotShape", BOX_PCB_Slot_Width / 2., BOX_PCB_Width / 2. + 0.1 * mm, BOX_PCB_Slot_Deepness); - - G4ThreeVector Box_Wafer_Offset ; - if(m_Z[i]<0 ){ - Box_Wafer_Offset = G4ThreeVector(BOX_Wafer_Length_Offset1, BOX_Wafer_Width_Offset1,0 ); + G4ThreeVector Box_Wafer_Offset; + if (m_Z[i] < 0) { + Box_Wafer_Offset = G4ThreeVector(BOX_Wafer_Length_Offset1, BOX_Wafer_Width_Offset1, 0); } - else{ - Box_Wafer_Offset = G4ThreeVector(BOX_Wafer_Length_Offset2, BOX_Wafer_Width_Offset2,0 ); + else { + Box_Wafer_Offset = G4ThreeVector(BOX_Wafer_Length_Offset2, BOX_Wafer_Width_Offset2, 0); } - G4SubtractionSolid* PCB1 = new G4SubtractionSolid("PCB", PCBFull, SlotShape,new G4RotationMatrix,G4ThreeVector(BOX_PCB_Slot_Position, 0,0.5*BOX_PCB_Thickness)); - G4SubtractionSolid* PCB = new G4SubtractionSolid("PCB", PCB1, WaferShape,new G4RotationMatrix,Box_Wafer_Offset); + G4SubtractionSolid* PCB1 = + new G4SubtractionSolid("PCB", PCBFull, SlotShape, new G4RotationMatrix, + G4ThreeVector(BOX_PCB_Slot_Position, 0, 0.5 * BOX_PCB_Thickness)); + G4SubtractionSolid* PCB = new G4SubtractionSolid("PCB", PCB1, WaferShape, new G4RotationMatrix, Box_Wafer_Offset); // Master Volume - G4LogicalVolume* logicBoxDetector = - new G4LogicalVolume(PCB1,m_MaterialVacuum,"logicBoxDetector", 0, 0, 0); - logicBoxDetector->SetVisAttributes(G4VisAttributes::Invisible); + G4LogicalVolume* logicBoxDetector = new G4LogicalVolume(PCB1, m_MaterialVacuum, "logicBoxDetector", 0, 0, 0); + logicBoxDetector->SetVisAttributes(G4VisAttributes::GetInvisible()); // Sub Volume PCB - G4LogicalVolume* logicPCB = - new G4LogicalVolume(PCB,m_MaterialPCB,"logicPCB", 0, 0, 0); + G4LogicalVolume* logicPCB = new G4LogicalVolume(PCB, m_MaterialPCB, "logicPCB", 0, 0, 0); logicPCB->SetVisAttributes(PCBVisAtt); // Sub Volume Wafer - G4LogicalVolume* logicWafer = - new G4LogicalVolume(Wafer,m_MaterialSilicon,"logicWafer", 0, 0, 0); + G4LogicalVolume* logicWafer = new G4LogicalVolume(Wafer, m_MaterialSilicon, "logicWafer", 0, 0, 0); G4LogicalVolume* logicActiveWafer = - new G4LogicalVolume(ActiveWafer,m_MaterialSilicon,"logicActiveWafer", 0, 0, 0); + new G4LogicalVolume(ActiveWafer, m_MaterialSilicon, "logicActiveWafer", 0, 0, 0); logicWafer->SetVisAttributes(SiliconVisAtt); logicActiveWafer->SetVisAttributes(SiliconVisAtt); // Place the sub volume in the master volume - new G4PVPlacement(new G4RotationMatrix(0,0,0), - G4ThreeVector(0,0,0), - logicPCB,"Box_PCB",logicBoxDetector,false,DetNbr); - - if(m_ThicknessBOX[i][j]>0){ - new G4PVPlacement(new G4RotationMatrix(0,0,0), - Box_Wafer_Offset+G4ThreeVector(0,0,0.5*BOX_PCB_Thickness-0.5*m_ThicknessBOX[i][j]), - logicWafer,"Box_Wafer",logicBoxDetector,false,DetNbr); - new G4PVPlacement(new G4RotationMatrix(0,0,0), - G4ThreeVector(0,0,0), - logicActiveWafer,"Box_ActiveWafer",logicWafer,false,DetNbr); + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), G4ThreeVector(0, 0, 0), logicPCB, "Box_PCB", logicBoxDetector, + false, DetNbr); + + if (m_ThicknessBOX[i][j] > 0) { + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), + Box_Wafer_Offset + G4ThreeVector(0, 0, 0.5 * BOX_PCB_Thickness - 0.5 * m_ThicknessBOX[i][j]), + logicWafer, "Box_Wafer", logicBoxDetector, false, DetNbr); + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), G4ThreeVector(0, 0, 0), logicActiveWafer, "Box_ActiveWafer", + logicWafer, false, DetNbr); logicActiveWafer->SetSensitiveDetector(m_BOXScorer); } @@ -331,397 +308,322 @@ void Sharc::ConstructBOXDetector(G4LogicalVolume* world){ // Make a single detector geometry G4LogicalVolume* logicPADDetector = NULL; - G4ThreeVector PAD_Wafer_Offset = - G4ThreeVector(PAD_Wafer_Length_Offset, PAD_Wafer_Width_Offset,0 ); - if(m_ThicknessPAD[i][j]>0){ - G4Box* PADDetector = new G4Box("PADDetector" , - PAD_PCB_Length/2., - PAD_PCB_Width/2., - PAD_PCB_Thickness/2.); - - G4Box* PADPCBFull = new G4Box("PCBFull" , - PAD_PCB_Length/2., - PAD_PCB_Width/2., - PAD_PCB_Thickness/2.); + G4ThreeVector PAD_Wafer_Offset = G4ThreeVector(PAD_Wafer_Length_Offset, PAD_Wafer_Width_Offset, 0); + if (m_ThicknessPAD[i][j] > 0) { + G4Box* PADDetector = new G4Box("PADDetector", PAD_PCB_Length / 2., PAD_PCB_Width / 2., PAD_PCB_Thickness / 2.); - G4Box* PADWaferShape = new G4Box("PADWaferShape", - PAD_Wafer_Length/2., - PAD_Wafer_Width/2., - PAD_PCB_Thickness/2.+0.1*mm); + G4Box* PADPCBFull = new G4Box("PCBFull", PAD_PCB_Length / 2., PAD_PCB_Width / 2., PAD_PCB_Thickness / 2.); - G4Box* PADWafer = new G4Box("PADWafer", - PAD_Wafer_Length/2., - PAD_Wafer_Width/2., - m_ThicknessPAD[i][j]/2.); + G4Box* PADWaferShape = + new G4Box("PADWaferShape", PAD_Wafer_Length / 2., PAD_Wafer_Width / 2., PAD_PCB_Thickness / 2. + 0.1 * mm); - G4Box* PADActiveWafer = new G4Box("PADActiveWafer", - PAD_ActiveWafer_Length/2., - PAD_ActiveWafer_Width/2., - m_ThicknessPAD[i][j]/2.); + G4Box* PADWafer = new G4Box("PADWafer", PAD_Wafer_Length / 2., PAD_Wafer_Width / 2., m_ThicknessPAD[i][j] / 2.); + G4Box* PADActiveWafer = new G4Box("PADActiveWafer", PAD_ActiveWafer_Length / 2., PAD_ActiveWafer_Width / 2., + m_ThicknessPAD[i][j] / 2.); - G4SubtractionSolid* PADPCB = new G4SubtractionSolid("PADPCB", PADPCBFull, PADWaferShape,new G4RotationMatrix,PAD_Wafer_Offset); + G4SubtractionSolid* PADPCB = + new G4SubtractionSolid("PADPCB", PADPCBFull, PADWaferShape, new G4RotationMatrix, PAD_Wafer_Offset); // Master Volume - logicPADDetector = - new G4LogicalVolume(PADDetector,m_MaterialVacuum,"logicPADDetector", 0, 0, 0); - logicPADDetector->SetVisAttributes(G4VisAttributes::Invisible); + logicPADDetector = new G4LogicalVolume(PADDetector, m_MaterialVacuum, "logicPADDetector", 0, 0, 0); + logicPADDetector->SetVisAttributes(G4VisAttributes::GetInvisible()); // Sub Volume PCB - G4LogicalVolume* logicPADPCB = - new G4LogicalVolume(PADPCB,m_MaterialPCB,"logicPADPCB", 0, 0, 0); + G4LogicalVolume* logicPADPCB = new G4LogicalVolume(PADPCB, m_MaterialPCB, "logicPADPCB", 0, 0, 0); logicPADPCB->SetVisAttributes(PADVisAtt); // Sub Volume Wafer - G4LogicalVolume* logicPADWafer = - new G4LogicalVolume(PADWafer,m_MaterialSilicon,"logicPADWafer", 0, 0, 0); + G4LogicalVolume* logicPADWafer = new G4LogicalVolume(PADWafer, m_MaterialSilicon, "logicPADWafer", 0, 0, 0); logicPADWafer->SetVisAttributes(SiliconVisAtt); // Sub Volume ActiveWafer G4LogicalVolume* logicPADActiveWafer = - new G4LogicalVolume(PADActiveWafer,m_MaterialSilicon,"logicPADActiveWafer", 0, 0, 0); + new G4LogicalVolume(PADActiveWafer, m_MaterialSilicon, "logicPADActiveWafer", 0, 0, 0); logicPADActiveWafer->SetVisAttributes(SiliconVisAtt); // Sensitive Volume logicPADActiveWafer->SetSensitiveDetector(m_PADScorer); // Place the sub volume in the master volume - new G4PVPlacement(new G4RotationMatrix(0,0,0), - G4ThreeVector(0,0,0), - logicPADPCB,"PAD_PCB",logicPADDetector,false,DetNbr); + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), G4ThreeVector(0, 0, 0), logicPADPCB, "PAD_PCB", + logicPADDetector, false, DetNbr); - new G4PVPlacement(new G4RotationMatrix(0,0,0), - PAD_Wafer_Offset-G4ThreeVector(0,0,0.5*PAD_PCB_Thickness-0.5*m_ThicknessPAD[i][j]), - logicPADWafer,"PAD_Wafer",logicPADDetector,false,DetNbr); + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), + PAD_Wafer_Offset - G4ThreeVector(0, 0, 0.5 * PAD_PCB_Thickness - 0.5 * m_ThicknessPAD[i][j]), + logicPADWafer, "PAD_Wafer", logicPADDetector, false, DetNbr); - new G4PVPlacement(new G4RotationMatrix(0,0,0), - G4ThreeVector(0,0,0), - logicPADActiveWafer,"PAD_ActiveWafer",logicPADWafer,false,DetNbr); + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), G4ThreeVector(0, 0, 0), logicPADActiveWafer, "PAD_ActiveWafer", + logicPADWafer, false, DetNbr); } /////////////////////////////////////////////////////////////////////////////////// // Place the detector in the world // Position of the center of the PCB G4ThreeVector DetectorPosition; - if(m_ThicknessPAD[i][j]>0){ //PAD Case - DetectorPosition = G4ThreeVector(-BOX_CenterOffset2,-Box_Wafer_Offset.y(),0); + if (m_ThicknessPAD[i][j] > 0) { // PAD Case + DetectorPosition = G4ThreeVector(-BOX_CenterOffset2, -Box_Wafer_Offset.y(), 0); } - else{ // No Pad Case - DetectorPosition = G4ThreeVector(-BOX_CenterOffset1,-Box_Wafer_Offset.y(),0); + else { // No Pad Case + DetectorPosition = G4ThreeVector(-BOX_CenterOffset1, -Box_Wafer_Offset.y(), 0); } // Distance of the PCB to the target - G4ThreeVector DetectorSpacing = - -G4ThreeVector(0,0,BOX_DetectorSpacing); + G4ThreeVector DetectorSpacing = -G4ThreeVector(0, 0, BOX_DetectorSpacing); - DetectorPosition+=DetectorSpacing; - - G4ThreeVector PADDetectorPosition = DetectorPosition ; - G4ThreeVector PADDetectorSpacing = - -G4ThreeVector(0,0,0.5*BOX_PCB_Thickness+0.5*PAD_PCB_Thickness); + DetectorPosition += DetectorSpacing; + G4ThreeVector PADDetectorPosition = DetectorPosition; + G4ThreeVector PADDetectorSpacing = -G4ThreeVector(0, 0, 0.5 * BOX_PCB_Thickness + 0.5 * PAD_PCB_Thickness); PADDetectorPosition += PADDetectorSpacing; - G4RotationMatrix* DetectorRotation= new G4RotationMatrix; + G4RotationMatrix* DetectorRotation = new G4RotationMatrix; // The Rotation Matrix is different for each detector - double Z= 0; - if(m_Z[i]<0){ - if(j==0){ - DetectorRotation->rotateX(90*deg); + double Z = 0; + if (m_Z[i] < 0) { + if (j == 0) { + DetectorRotation->rotateX(90 * deg); } - else if(j==1){ - DetectorRotation->rotateX(90*deg); - DetectorRotation->rotateZ(-90*deg); + else if (j == 1) { + DetectorRotation->rotateX(90 * deg); + DetectorRotation->rotateZ(-90 * deg); } - else if(j==2){ - DetectorRotation->rotateZ(180*deg); - DetectorRotation->rotateX(-90*deg); + else if (j == 2) { + DetectorRotation->rotateZ(180 * deg); + DetectorRotation->rotateX(-90 * deg); } - else if(j==3){ - DetectorRotation->rotateX(90*deg); - DetectorRotation->rotateZ(90*deg); + else if (j == 3) { + DetectorRotation->rotateX(90 * deg); + DetectorRotation->rotateZ(90 * deg); } - DetectorRotation->rotateY(180*deg); - Z = m_Z[i] -2*mm; + DetectorRotation->rotateY(180 * deg); + Z = m_Z[i] - 2 * mm; } - else{ - if(j==0){ - DetectorRotation->rotateX(90*deg); + else { + if (j == 0) { + DetectorRotation->rotateX(90 * deg); } - else if(j==1){ - DetectorRotation->rotateX(90*deg); - DetectorRotation->rotateZ(90*deg); - + else if (j == 1) { + DetectorRotation->rotateX(90 * deg); + DetectorRotation->rotateZ(90 * deg); } - else if(j==2){ - DetectorRotation->rotateZ(180*deg); - DetectorRotation->rotateX(-90*deg); + else if (j == 2) { + DetectorRotation->rotateZ(180 * deg); + DetectorRotation->rotateX(-90 * deg); } - else if(j==3){ - DetectorRotation->rotateX(90*deg); - DetectorRotation->rotateZ(-90*deg); + else if (j == 3) { + DetectorRotation->rotateX(90 * deg); + DetectorRotation->rotateZ(-90 * deg); } - Z= m_Z[i]+2*mm; + Z = m_Z[i] + 2 * mm; } DetectorPosition.transform(*DetectorRotation); - DetectorPosition+=G4ThreeVector(0,0,Z); + DetectorPosition += G4ThreeVector(0, 0, Z); PADDetectorPosition.transform(*DetectorRotation); - PADDetectorPosition+=G4ThreeVector(0,0,Z); + PADDetectorPosition += G4ThreeVector(0, 0, Z); - new G4PVPlacement(G4Transform3D(*DetectorRotation,DetectorPosition), logicBoxDetector,"Box",world,false,DetNbr); + new G4PVPlacement(G4Transform3D(*DetectorRotation, DetectorPosition), logicBoxDetector, "Box", world, false, + DetNbr); - if(m_ThicknessPAD[i][j]>0){ - new G4PVPlacement(G4Transform3D(*DetectorRotation, PADDetectorPosition), - logicPADDetector,"PAD",world,false,DetNbr); + if (m_ThicknessPAD[i][j] > 0) { + new G4PVPlacement(G4Transform3D(*DetectorRotation, PADDetectorPosition), logicPADDetector, "PAD", world, false, + DetNbr); } } } } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Sharc::ConstructQQQDetector(G4LogicalVolume* world){ +void Sharc::ConstructQQQDetector(G4LogicalVolume* world) { // create the QQQ - for(unsigned int i = 0 ; i < m_Pos.size() ; i++){ + for (unsigned int i = 0; i < m_Pos.size(); i++) { int DetNbr = 0; - if(m_Pos[i].z()<0) DetNbr = i+1; - else DetNbr = i+1 + 8; + if (m_Pos[i].z() < 0) + DetNbr = i + 1; + else + DetNbr = i + 1 + 8; // Make the a single detector geometry - G4Tubs* QQQDetector = new G4Tubs("QQQDetector" , - QQQ_PCB_Inner_Radius, - QQQ_PCB_Outer_Radius, - QQQ_PCB_Thickness*0.5, - 0., - M_PI/2.); - - G4Tubs* PCBFull = new G4Tubs("PCBFull" , - QQQ_PCB_Inner_Radius, - QQQ_PCB_Outer_Radius, - QQQ_PCB_Thickness*0.5, - 0., - M_PI*0.5); - - G4Tubs* WaferShape = new G4Tubs("WaferShape" , - QQQ_Wafer_Inner_Radius, - QQQ_Wafer_Outer_Radius, - QQQ_PCB_Thickness*0.5+0.1*mm, - QQQ_Wafer_Starting_Phi, - QQQ_Wafer_Stopping_Phi); - - G4Tubs* Wafer = new G4Tubs("Wafer" , - QQQ_Wafer_Inner_Radius, - QQQ_Wafer_Outer_Radius, - m_ThicknessQQQ[i]*0.5, - QQQ_Wafer_Starting_Phi, - QQQ_Wafer_Stopping_Phi); - - G4SubtractionSolid* PCB = - new G4SubtractionSolid("PCB", PCBFull, WaferShape,new G4RotationMatrix, - G4ThreeVector(0, 0,0)); + G4Tubs* QQQDetector = + new G4Tubs("QQQDetector", QQQ_PCB_Inner_Radius, QQQ_PCB_Outer_Radius, QQQ_PCB_Thickness * 0.5, 0., M_PI / 2.); + + G4Tubs* PCBFull = + new G4Tubs("PCBFull", QQQ_PCB_Inner_Radius, QQQ_PCB_Outer_Radius, QQQ_PCB_Thickness * 0.5, 0., M_PI * 0.5); + + G4Tubs* WaferShape = new G4Tubs("WaferShape", QQQ_Wafer_Inner_Radius, QQQ_Wafer_Outer_Radius, + QQQ_PCB_Thickness * 0.5 + 0.1 * mm, QQQ_Wafer_Starting_Phi, QQQ_Wafer_Stopping_Phi); + + G4Tubs* Wafer = new G4Tubs("Wafer", QQQ_Wafer_Inner_Radius, QQQ_Wafer_Outer_Radius, m_ThicknessQQQ[i] * 0.5, + QQQ_Wafer_Starting_Phi, QQQ_Wafer_Stopping_Phi); + + G4SubtractionSolid* PCB = + new G4SubtractionSolid("PCB", PCBFull, WaferShape, new G4RotationMatrix, G4ThreeVector(0, 0, 0)); // Master Volume - G4LogicalVolume* logicQQQDetector = - new G4LogicalVolume(QQQDetector,m_MaterialVacuum,"logicQQQDetector", 0, 0, 0); - logicQQQDetector->SetVisAttributes(G4VisAttributes::Invisible); + G4LogicalVolume* logicQQQDetector = new G4LogicalVolume(QQQDetector, m_MaterialVacuum, "logicQQQDetector", 0, 0, 0); + logicQQQDetector->SetVisAttributes(G4VisAttributes::GetInvisible()); // Sub Volume PCB - G4LogicalVolume* logicPCB = - new G4LogicalVolume(PCB,m_MaterialPCB,"logicPCB", 0, 0, 0); + G4LogicalVolume* logicPCB = new G4LogicalVolume(PCB, m_MaterialPCB, "logicPCB", 0, 0, 0); logicPCB->SetVisAttributes(PCBVisAtt); // Sub Volume Wafer - G4LogicalVolume* logicWafer = - new G4LogicalVolume(Wafer,m_MaterialSilicon,"logicWafer", 0, 0, 0); + G4LogicalVolume* logicWafer = new G4LogicalVolume(Wafer, m_MaterialSilicon, "logicWafer", 0, 0, 0); logicWafer->SetVisAttributes(SiliconVisAtt); logicWafer->SetSensitiveDetector(m_QQQScorer); - // Place the sub volume in the master volume - new G4PVPlacement(new G4RotationMatrix(0,0,0), - G4ThreeVector(0,0,0), - logicPCB,"QQQ_PCB",logicQQQDetector,false,DetNbr); + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), G4ThreeVector(0, 0, 0), logicPCB, "QQQ_PCB", logicQQQDetector, + false, DetNbr); - new G4PVPlacement(new G4RotationMatrix(0,0,0), - G4ThreeVector(0,0,0), - logicWafer,"QQQ_Wafer",logicQQQDetector,false,DetNbr); + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), G4ThreeVector(0, 0, 0), logicWafer, "QQQ_Wafer", logicQQQDetector, + false, DetNbr); // Place the masters volume in the world - new G4PVPlacement(new G4RotationMatrix(0,0,m_Pos[i].y()), - G4ThreeVector(0,0,m_Pos[i].z()), - logicQQQDetector,"QQQ",world,false,DetNbr); + new G4PVPlacement(new G4RotationMatrix(0, 0, m_Pos[i].y()), G4ThreeVector(0, 0, m_Pos[i].z()), logicQQQDetector, + "QQQ", world, false, DetNbr); } } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Add Detector branch to the EventTree. // Called After DetecorConstruction::AddDetector Method -void Sharc::InitializeRootOutput(){ - RootOutput *pAnalysis = RootOutput::getInstance(); - TTree *pTree = pAnalysis->GetTree(); - if(!pTree->FindBranch("Sharc")){ - pTree->Branch("Sharc", "TSharcData", &m_Event) ; +void Sharc::InitializeRootOutput() { + RootOutput* pAnalysis = RootOutput::getInstance(); + TTree* pTree = pAnalysis->GetTree(); + if (!pTree->FindBranch("Sharc")) { + pTree->Branch("Sharc", "TSharcData", &m_Event); } - pTree->SetBranchAddress("Sharc", &m_Event) ; - + pTree->SetBranchAddress("Sharc", &m_Event); } - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Read sensitive part and fill the Root tree. // Called at in the EventAction::EndOfEventAvtion -void Sharc::ReadSensitive(const G4Event* ){ +void Sharc::ReadSensitive(const G4Event*) { m_Event->Clear(); /////////// // BOX - DSSDScorers::PS_Rectangle* BOXScorer = (DSSDScorers::PS_Rectangle*) m_BOXScorer->GetPrimitive(0); - + DSSDScorers::PS_Rectangle* BOXScorer = (DSSDScorers::PS_Rectangle*)m_BOXScorer->GetPrimitive(0); // Loop on the BOX map - unsigned int sizeFront= BOXScorer->GetLengthMult(); + unsigned int sizeFront = BOXScorer->GetLengthMult(); - for (unsigned int i=0 ; i<sizeFront ; i++){ + for (unsigned int i = 0; i < sizeFront; i++) { double Energy = BOXScorer->GetEnergyLength(i); - if(Energy>EnergyThreshold){ - double Time = BOXScorer->GetTimeLength(i); - int DetNbr = BOXScorer->GetDetectorLength(i); - int StripFront = BOXScorer->GetStripLength(i); - - m_Event->SetFront(DetNbr, - StripFront, - RandGauss::shoot(Energy, ResoEnergy), - RandGauss::shoot(Time, ResoTime), - RandGauss::shoot(Time, ResoTime)); + if (Energy > EnergyThreshold) { + double Time = BOXScorer->GetTimeLength(i); + int DetNbr = BOXScorer->GetDetectorLength(i); + int StripFront = BOXScorer->GetStripLength(i); + + m_Event->SetFront(DetNbr, StripFront, RandGauss::shoot(Energy, ResoEnergy), RandGauss::shoot(Time, ResoTime), + RandGauss::shoot(Time, ResoTime)); } - } + } - unsigned int sizeBack= BOXScorer->GetWidthMult(); - for (unsigned int i=0 ; i<sizeBack ; i++){ + unsigned int sizeBack = BOXScorer->GetWidthMult(); + for (unsigned int i = 0; i < sizeBack; i++) { double Energy = BOXScorer->GetEnergyWidth(i); - if(Energy>EnergyThreshold){ - double Time = BOXScorer->GetTimeWidth(i); - int DetNbr = BOXScorer->GetDetectorWidth(i); - int StripBack = BOXScorer->GetStripWidth(i); + if (Energy > EnergyThreshold) { + double Time = BOXScorer->GetTimeWidth(i); + int DetNbr = BOXScorer->GetDetectorWidth(i); + int StripBack = BOXScorer->GetStripWidth(i); - m_Event->SetBack(DetNbr, - BOX_Wafer_Back_NumberOfStrip-StripBack+1, - RandGauss::shoot(Energy, ResoEnergy), - RandGauss::shoot(Time, ResoTime), - RandGauss::shoot(Time, ResoTime)); + m_Event->SetBack(DetNbr, BOX_Wafer_Back_NumberOfStrip - StripBack + 1, RandGauss::shoot(Energy, ResoEnergy), + RandGauss::shoot(Time, ResoTime), RandGauss::shoot(Time, ResoTime)); } } // clear map for next event BOXScorer->clear(); /////////// // PAD - DSSDScorers::PS_Rectangle* PADScorer = (DSSDScorers::PS_Rectangle*) m_PADScorer->GetPrimitive(0); - + DSSDScorers::PS_Rectangle* PADScorer = (DSSDScorers::PS_Rectangle*)m_PADScorer->GetPrimitive(0); // Loop on the PAD map - unsigned int sizePAD= PADScorer->GetLengthMult(); - for (unsigned int i=0 ; i<sizePAD ; i++){ + unsigned int sizePAD = PADScorer->GetLengthMult(); + for (unsigned int i = 0; i < sizePAD; i++) { double Energy = PADScorer->GetEnergyLength(i); - if(Energy>EnergyThreshold){ - double Time = PADScorer->GetTimeLength(i); - int DetNbr = PADScorer->GetDetectorLength(i); - m_Event->SetPAD(DetNbr, - RandGauss::shoot(Energy, ResoEnergy), - RandGauss::shoot(Time, ResoTime), - RandGauss::shoot(Time, ResoTime)); + if (Energy > EnergyThreshold) { + double Time = PADScorer->GetTimeLength(i); + int DetNbr = PADScorer->GetDetectorLength(i); + m_Event->SetPAD(DetNbr, RandGauss::shoot(Energy, ResoEnergy), RandGauss::shoot(Time, ResoTime), + RandGauss::shoot(Time, ResoTime)); } - } + } // clear map for next event PADScorer->clear(); /////////// // QQQ - DSSDScorers::PS_Annular* QQQScorer = (DSSDScorers::PS_Annular*) m_QQQScorer->GetPrimitive(0); + DSSDScorers::PS_Annular* QQQScorer = (DSSDScorers::PS_Annular*)m_QQQScorer->GetPrimitive(0); // Loop on the QQQ map - unsigned int sizeRing= QQQScorer->GetRingMult(); - for (unsigned int i=0 ; i<sizeRing ; i++){ + unsigned int sizeRing = QQQScorer->GetRingMult(); + for (unsigned int i = 0; i < sizeRing; i++) { double Energy = QQQScorer->GetEnergyRing(i); - if(Energy>EnergyThreshold){ - double Time = QQQScorer->GetTimeRing(i); - int DetNbr = QQQScorer->GetDetectorRing(i); - int StripRing = QQQScorer->GetStripRing(i); - m_Event->SetFront(DetNbr, - QQQ_Wafer_NumberOf_AnnularStrip-StripRing+1, - RandGauss::shoot(Energy, ResoEnergy), - RandGauss::shoot(Time, ResoTime), - RandGauss::shoot(Time, ResoTime)); + if (Energy > EnergyThreshold) { + double Time = QQQScorer->GetTimeRing(i); + int DetNbr = QQQScorer->GetDetectorRing(i); + int StripRing = QQQScorer->GetStripRing(i); + m_Event->SetFront(DetNbr, QQQ_Wafer_NumberOf_AnnularStrip - StripRing + 1, RandGauss::shoot(Energy, ResoEnergy), + RandGauss::shoot(Time, ResoTime), RandGauss::shoot(Time, ResoTime)); } - } + } - unsigned int sizeSector= QQQScorer->GetSectorMult(); - for (unsigned int i=0 ; i<sizeSector ; i++){ + unsigned int sizeSector = QQQScorer->GetSectorMult(); + for (unsigned int i = 0; i < sizeSector; i++) { double Energy = QQQScorer->GetEnergySector(i); - if(Energy>EnergyThreshold){ - double Time = QQQScorer->GetTimeSector(i); - int DetNbr = QQQScorer->GetDetectorSector(i); - int StripSector = QQQScorer->GetStripSector(i); + if (Energy > EnergyThreshold) { + double Time = QQQScorer->GetTimeSector(i); + int DetNbr = QQQScorer->GetDetectorSector(i); + int StripSector = QQQScorer->GetStripSector(i); - m_Event->SetBack(DetNbr, - StripSector, - RandGauss::shoot(Energy, ResoEnergy), - RandGauss::shoot(Time, ResoTime), - RandGauss::shoot(Time, ResoTime)); + m_Event->SetBack(DetNbr, StripSector, RandGauss::shoot(Energy, ResoEnergy), RandGauss::shoot(Time, ResoTime), + RandGauss::shoot(Time, ResoTime)); } } // clear map for next event QQQScorer->clear(); - } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Sharc::InitializeScorers(){ +void Sharc::InitializeScorers() { // Silicon Associate Scorer bool already_exist = false; - m_BOXScorer = CheckScorer("Sharc_BOXScorer",already_exist); - m_PADScorer = CheckScorer("Sharc_PADScorer",already_exist); - m_QQQScorer = CheckScorer("Sharc_QQQScorer",already_exist); + m_BOXScorer = CheckScorer("Sharc_BOXScorer", already_exist); + m_PADScorer = CheckScorer("Sharc_PADScorer", already_exist); + m_QQQScorer = CheckScorer("Sharc_QQQScorer", already_exist); // if the scorer were created previously nothing else need to be made - if(already_exist) return; + if (already_exist) + return; G4VPrimitiveScorer* BOXScorer = - new DSSDScorers::PS_Rectangle("SharcBOX",0, - BOX_ActiveWafer_Length, - BOX_ActiveWafer_Width, - BOX_Wafer_Front_NumberOfStrip , - BOX_Wafer_Back_NumberOfStrip); - - G4VPrimitiveScorer* PADScorer = - new DSSDScorers::PS_Rectangle("SharcPAD",0, - PAD_Wafer_Length, - PAD_Wafer_Width, - 1 , - 0); - - G4VPrimitiveScorer* QQQScorer = - new DSSDScorers::PS_Annular("SharcQQQ",0, - QQQ_Wafer_Inner_Radius, - QQQ_Wafer_Outer_Radius, - QQQ_Wafer_Starting_Phi, - QQQ_Wafer_Stopping_Phi, - QQQ_Wafer_NumberOf_AnnularStrip, - QQQ_Wafer_NumberOf_RadialStrip,1); - - G4VPrimitiveScorer* InterScorerBOX = - new InteractionScorers::PS_Interactions("SharcBOXInteractionScorer",ms_InterCoord,0); - - G4VPrimitiveScorer* InterScorerQQQ = - new InteractionScorers::PS_Interactions("SharcQQQInteractionScorer",ms_InterCoord,0); - - //and register it to the multifunctionnal detector + new DSSDScorers::PS_Rectangle("SharcBOX", 0, BOX_ActiveWafer_Length, BOX_ActiveWafer_Width, + BOX_Wafer_Front_NumberOfStrip, BOX_Wafer_Back_NumberOfStrip); + + G4VPrimitiveScorer* PADScorer = new DSSDScorers::PS_Rectangle("SharcPAD", 0, PAD_Wafer_Length, PAD_Wafer_Width, 1, 0); + + G4VPrimitiveScorer* QQQScorer = new DSSDScorers::PS_Annular( + "SharcQQQ", 0, QQQ_Wafer_Inner_Radius, QQQ_Wafer_Outer_Radius, QQQ_Wafer_Starting_Phi, QQQ_Wafer_Stopping_Phi, + QQQ_Wafer_NumberOf_AnnularStrip, QQQ_Wafer_NumberOf_RadialStrip, 1); + + G4VPrimitiveScorer* InterScorerBOX = + new InteractionScorers::PS_Interactions("SharcBOXInteractionScorer", ms_InterCoord, 0); + + G4VPrimitiveScorer* InterScorerQQQ = + new InteractionScorers::PS_Interactions("SharcQQQInteractionScorer", ms_InterCoord, 0); + + // and register it to the multifunctionnal detector m_BOXScorer->RegisterPrimitive(BOXScorer); m_BOXScorer->RegisterPrimitive(InterScorerBOX); m_PADScorer->RegisterPrimitive(PADScorer); @@ -730,42 +632,37 @@ void Sharc::InitializeScorers(){ G4SDManager::GetSDMpointer()->ListTree(); // Add All Scorer to the Global Scorer Manager - G4SDManager::GetSDMpointer()->AddNewDetector(m_BOXScorer) ; - G4SDManager::GetSDMpointer()->AddNewDetector(m_PADScorer) ; - G4SDManager::GetSDMpointer()->AddNewDetector(m_QQQScorer) ; - + G4SDManager::GetSDMpointer()->AddNewDetector(m_BOXScorer); + G4SDManager::GetSDMpointer()->AddNewDetector(m_PADScorer); + G4SDManager::GetSDMpointer()->AddNewDetector(m_QQQScorer); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //////////////////////////////////////////////////////////////// /////////////////Material Definition /////////////////////////// //////////////////////////////////////////////////////////////// -void Sharc::InitializeMaterial(){ +void Sharc::InitializeMaterial() { m_MaterialSilicon = MaterialManager::getInstance()->GetMaterialFromLibrary("Si"); m_MaterialPCB = MaterialManager::getInstance()->GetMaterialFromLibrary("PCB"); m_MaterialVacuum = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); - } - //////////////////////////////////////////////////////////////////////////////// // Construct Method to be pass to the DetectorFactory // //////////////////////////////////////////////////////////////////////////////// -NPS::VDetector* Sharc::Construct(){ - return (NPS::VDetector*) new Sharc(); -} +NPS::VDetector* Sharc::Construct() { return (NPS::VDetector*)new Sharc(); } //////////////////////////////////////////////////////////////////////////////// // Registering the construct method to the factory // //////////////////////////////////////////////////////////////////////////////// -extern"C" { - class proxy_nps_sharc{ - public: - proxy_nps_sharc(){ - NPS::DetectorFactory::getInstance()->AddToken("Sharc","Sharc"); - NPS::DetectorFactory::getInstance()->AddDetector("Sharc",Sharc::Construct); - } - }; +extern "C" { +class proxy_nps_sharc { + public: + proxy_nps_sharc() { + NPS::DetectorFactory::getInstance()->AddToken("Sharc", "Sharc"); + NPS::DetectorFactory::getInstance()->AddDetector("Sharc", Sharc::Construct); + } +}; - proxy_nps_sharc p_nps_sharc; +proxy_nps_sharc p_nps_sharc; } diff --git a/NPSimulation/Detectors/Sofia/SofTofW.cc b/NPSimulation/Detectors/Sofia/SofTofW.cc index 18d1864d971f4eb99069b54aa27865e276a34938..1607053412bb490641d777de314ded4b6344ae71 100644 --- a/NPSimulation/Detectors/Sofia/SofTofW.cc +++ b/NPSimulation/Detectors/Sofia/SofTofW.cc @@ -199,7 +199,7 @@ G4LogicalVolume* SofTofW::BuildGLADFromSTL() auto mesh = CADMesh::TessellatedMesh::FromSTL((char*) path.c_str()); mesh->SetScale(mm); - G4Material* GLAD_Material = MaterialManager::getInstance()->GetMaterialFromLibrary("Al"); + G4Material* GLAD_Material = MaterialManager::getInstance()->GetMaterialFromLibrary("Inox"); auto cad_solid = mesh->GetSolid(); m_GLAD_STL = new G4LogicalVolume(cad_solid,GLAD_Material,"GLAD_Magnet",0,0,0); @@ -318,7 +318,8 @@ void SofTofW::ConstructDetector(G4LogicalVolume* world){ u = u.unit(); G4RotationMatrix* Rot = new G4RotationMatrix(u,v,w); - G4ThreeVector Z_translation = G4ThreeVector(0,0,4*m); + //G4ThreeVector Z_translation = G4ThreeVector(0,0,4*m); + G4ThreeVector Z_translation = G4ThreeVector(0,0,m_GLAD_DistanceFromTarget); Det_pos += Z_translation; BuildTOFDetector()->MakeImprint(world,Det_pos,Rot); } diff --git a/NPSimulation/Detectors/Spice/Spice.cc b/NPSimulation/Detectors/Spice/Spice.cc index 86ce150ffc52c32cb3cad22b3b45604c9a3de843..b03cd6aad2695cabd3c823b8a399fd35000338ad 100644 --- a/NPSimulation/Detectors/Spice/Spice.cc +++ b/NPSimulation/Detectors/Spice/Spice.cc @@ -21,61 +21,57 @@ *****************************************************************************/ // C++ headers +#include <cmath> #include <sstream> #include <string> -#include <cmath> -// Geant4 +// Geant4 #include "G4Box.hh" -#include "G4Tubs.hh" -#include "G4VisAttributes.hh" #include "G4Colour.hh" -#include "G4RotationMatrix.hh" -#include "G4Transform3D.hh" -#include "G4PVPlacement.hh" +#include "G4MultiFunctionalDetector.hh" #include "G4PVDivision.hh" +#include "G4PVPlacement.hh" +#include "G4RotationMatrix.hh" #include "G4SDManager.hh" -#include "G4MultiFunctionalDetector.hh" +#include "G4Transform3D.hh" +#include "G4Tubs.hh" +#include "G4VisAttributes.hh" // NPTool headers -#include "Spice.hh" #include "MaterialManager.hh" +#include "NPOptionManager.h" #include "NPSDetectorFactory.hh" -#include "SiliconScorers.hh" #include "RootOutput.h" -#include "NPOptionManager.h" +#include "SiliconScorers.hh" +#include "Spice.hh" // CLHEP #include "CLHEP/Random/RandGauss.h" using namespace std; //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -Spice::Spice(){ - m_LogicalDetector=0; -} +Spice::Spice() { m_LogicalDetector = 0; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -Spice::~Spice(){ -} +Spice::~Spice() {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -G4LogicalVolume* Spice::ConstructVolume(){ - if(!m_LogicalDetector){ +G4LogicalVolume* Spice::ConstructVolume() { + if (!m_LogicalDetector) { m_gdmlparser.Read("Spice/Spice.gdml"); - m_LogicalDetector= m_gdmlparser.GetVolume("World"); + m_LogicalDetector = m_gdmlparser.GetVolume("World"); // Set a few visual attribute - G4VisAttributes* MagnetVisAtt = new G4VisAttributes(G4Colour(0.2,0.2, 1, 0.5)) ; - G4VisAttributes* PhotonShieldVisAtt = new G4VisAttributes(G4Colour(0.2,1, 0.2, 0.5)) ; + G4VisAttributes* MagnetVisAtt = new G4VisAttributes(G4Colour(0.2, 0.2, 1, 0.5)); + G4VisAttributes* PhotonShieldVisAtt = new G4VisAttributes(G4Colour(0.2, 1, 0.2, 0.5)); - G4VisAttributes* SiliconVisAtt = new G4VisAttributes(G4Colour(0.3, 0.3, 0.3)) ; - G4VisAttributes* ColdFingerVisAtt = new G4VisAttributes(G4Colour(0.8, 0.3, 0.3)) ; - G4VisAttributes* TargetMechanismVisAtt = new G4VisAttributes(G4Colour(0.5, 0.5, 0.3)) ; + G4VisAttributes* SiliconVisAtt = new G4VisAttributes(G4Colour(0.3, 0.3, 0.3)); + G4VisAttributes* ColdFingerVisAtt = new G4VisAttributes(G4Colour(0.8, 0.3, 0.3)); + G4VisAttributes* TargetMechanismVisAtt = new G4VisAttributes(G4Colour(0.5, 0.5, 0.3)); - G4VisAttributes* ChamberVisAtt - = new G4VisAttributes(G4Colour(0.0,0.4,0.5,0.2)); + G4VisAttributes* ChamberVisAtt = new G4VisAttributes(G4Colour(0.0, 0.4, 0.5, 0.2)); // World box - m_LogicalDetector->SetVisAttributes(G4VisAttributes::Invisible); + m_LogicalDetector->SetVisAttributes(G4VisAttributes::GetInvisible()); // chamber m_gdmlparser.GetVolume("electro_box_log")->SetVisAttributes(ChamberVisAtt); @@ -87,19 +83,17 @@ G4LogicalVolume* Spice::ConstructVolume(){ // Cold Finger m_gdmlparser.GetVolume("cold_finger_log")->SetVisAttributes(ColdFingerVisAtt); - // Magnet - m_gdmlparser.GetVolume("magnet_log")->SetVisAttributes(MagnetVisAtt); - m_gdmlparser.GetVolume("magnet_clamp_chamber_log")->SetVisAttributes(MagnetVisAtt); - m_gdmlparser.GetVolume("magnet_clamp_shield_log")->SetVisAttributes(MagnetVisAtt); + m_gdmlparser.GetVolume("magnet_log")->SetVisAttributes(MagnetVisAtt); + m_gdmlparser.GetVolume("magnet_clamp_chamber_log")->SetVisAttributes(MagnetVisAtt); + m_gdmlparser.GetVolume("magnet_clamp_shield_log")->SetVisAttributes(MagnetVisAtt); // Photon Shield - m_gdmlparser.GetVolume("photon_shield_layer_one_log")->SetVisAttributes(PhotonShieldVisAtt); - m_gdmlparser.GetVolume("photon_shield_layer_two_log")->SetVisAttributes(PhotonShieldVisAtt); - m_gdmlparser.GetVolume("photon_shield_layer_three_log")->SetVisAttributes(PhotonShieldVisAtt); - m_gdmlparser.GetVolume("ps_detector_clamp_log")->SetVisAttributes(PhotonShieldVisAtt); - m_gdmlparser.GetVolume("ps_target_clamp_log")->SetVisAttributes(PhotonShieldVisAtt); - + m_gdmlparser.GetVolume("photon_shield_layer_one_log")->SetVisAttributes(PhotonShieldVisAtt); + m_gdmlparser.GetVolume("photon_shield_layer_two_log")->SetVisAttributes(PhotonShieldVisAtt); + m_gdmlparser.GetVolume("photon_shield_layer_three_log")->SetVisAttributes(PhotonShieldVisAtt); + m_gdmlparser.GetVolume("ps_detector_clamp_log")->SetVisAttributes(PhotonShieldVisAtt); + m_gdmlparser.GetVolume("ps_target_clamp_log")->SetVisAttributes(PhotonShieldVisAtt); // Target Mechanism m_gdmlparser.GetVolume("target_wheel_log")->SetVisAttributes(TargetMechanismVisAtt); @@ -111,28 +105,24 @@ G4LogicalVolume* Spice::ConstructVolume(){ m_gdmlparser.GetVolume("gear_stick_log")->SetVisAttributes(TargetMechanismVisAtt); m_gdmlparser.GetVolume("target_mount_plate_log")->SetVisAttributes(TargetMechanismVisAtt); - - - // S3 color - for(unsigned int ring = 1 ; ring < 24 ; ring++){ + for (unsigned int ring = 1; ring < 24; ring++) { ostringstream os; os << "siDetS3Ring_" << ring << "_Log"; - m_gdmlparser.GetVolume(os.str())->SetVisAttributes(SiliconVisAtt); + m_gdmlparser.GetVolume(os.str())->SetVisAttributes(SiliconVisAtt); } - //Spice color - for(unsigned int ring = 0 ; ring < 10 ; ring++){ + // Spice color + for (unsigned int ring = 0; ring < 10; ring++) { ostringstream os; os << "siDetSpiceRing_" << ring << "_Log"; - m_gdmlparser.GetVolume(os.str())->SetVisAttributes(SiliconVisAtt); + m_gdmlparser.GetVolume(os.str())->SetVisAttributes(SiliconVisAtt); } - m_gdmlparser.GetVolume("innerGuardRing")->SetVisAttributes(SiliconVisAtt); - m_gdmlparser.GetVolume("outerGuardRing")->SetVisAttributes(SiliconVisAtt); + m_gdmlparser.GetVolume("innerGuardRing")->SetVisAttributes(SiliconVisAtt); + m_gdmlparser.GetVolume("outerGuardRing")->SetVisAttributes(SiliconVisAtt); } return m_LogicalDetector; - } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... @@ -143,58 +133,49 @@ G4LogicalVolume* Spice::ConstructVolume(){ //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Read stream at Configfile to pick-up parameters of detector (Position,...) // Called in DetecorConstruction::ReadDetextorConfiguration Method -void Spice::ReadConfiguration(NPL::InputParser){ -} +void Spice::ReadConfiguration(NPL::InputParser) {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Construct detector and inialise sensitive part. // Called After DetecorConstruction::AddDetector Method -void Spice::ConstructDetector(G4LogicalVolume* world){ +void Spice::ConstructDetector(G4LogicalVolume* world) { ConstructVolume(); - new G4PVPlacement(new G4RotationMatrix(0,0,0), - G4ThreeVector(0,0,0), - m_LogicalDetector,"Spice",world,false,1); + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), G4ThreeVector(0, 0, 0), m_LogicalDetector, "Spice", world, false, 1); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Connect the GaspardTrackingData class to the output TTree // of the simulation -void Spice::InitializeRootOutput(){ -} +void Spice::InitializeRootOutput() {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Read sensitive part and fill the Root tree. // Called at in the EventAction::EndOfEventAvtion -void Spice::ReadSensitive(const G4Event* event){ - if(event) +void Spice::ReadSensitive(const G4Event* event) { + if (event) event = 0; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -// Initilize the Scorer use to read out the sensitive volume -void Spice::InitializeScorers(){ - m_Scorer = 0; -} +// Initilize the Scorer use to read out the sensitive volume +void Spice::InitializeScorers() { m_Scorer = 0; } //////////////////////////////////////////////////////////////////////////////// // Construct Method to be pass to the DetectorFactory // //////////////////////////////////////////////////////////////////////////////// -NPS::VDetector* Spice::Construct(){ - return (NPS::VDetector*) new Spice(); -} +NPS::VDetector* Spice::Construct() { return (NPS::VDetector*)new Spice(); } //////////////////////////////////////////////////////////////////////////////// // Registering the construct method to the factory // //////////////////////////////////////////////////////////////////////////////// -extern "C"{ -class proxy_nps_spice{ - public: - proxy_nps_spice(){ - NPS::DetectorFactory::getInstance()->AddToken("Spice","Spice"); - NPS::DetectorFactory::getInstance()->AddDetector("Spice",Spice::Construct); - } +extern "C" { +class proxy_nps_spice { + public: + proxy_nps_spice() { + NPS::DetectorFactory::getInstance()->AddToken("Spice", "Spice"); + NPS::DetectorFactory::getInstance()->AddDetector("Spice", Spice::Construct); + } }; proxy_nps_spice p_nps_spice; } - diff --git a/NPSimulation/Detectors/Strasse/Strasse.cc b/NPSimulation/Detectors/Strasse/Strasse.cc index f751000d70c946625fe33eab4722233f35495ed3..230a0e44e20d9ab8989a5372cc79150ee873d9f6 100644 --- a/NPSimulation/Detectors/Strasse/Strasse.cc +++ b/NPSimulation/Detectors/Strasse/Strasse.cc @@ -20,38 +20,38 @@ *****************************************************************************/ // C++ headers -#include <sstream> #include <cmath> #include <limits> -//G4 Geometry object -#include "G4Tubs.hh" +#include <sstream> +// G4 Geometry object #include "G4Box.hh" -#include "G4Sphere.hh" -#include "G4UnionSolid.hh" #include "G4ExtrudedSolid.hh" +#include "G4Sphere.hh" #include "G4SubtractionSolid.hh" +#include "G4Tubs.hh" #include "G4TwoVector.hh" +#include "G4UnionSolid.hh" -//G4 sensitive -#include "G4SDManager.hh" +// G4 sensitive #include "G4MultiFunctionalDetector.hh" +#include "G4SDManager.hh" -//G4 various object +// G4 various object +#include "G4Colour.hh" #include "G4Material.hh" -#include "G4Transform3D.hh" #include "G4PVPlacement.hh" +#include "G4Transform3D.hh" #include "G4VisAttributes.hh" -#include "G4Colour.hh" // NPTool header -#include "Strasse.hh" #include "DSSDScorers.hh" #include "InteractionScorers.hh" -#include "RootOutput.h" #include "MaterialManager.hh" -#include "NPSDetectorFactory.hh" #include "NPOptionManager.h" +#include "NPSDetectorFactory.hh" #include "NPSHitsMap.hh" +#include "RootOutput.h" +#include "Strasse.hh" // CLHEP header #include "CLHEP/Random/RandGauss.h" @@ -61,122 +61,120 @@ using namespace std; using namespace CLHEP; - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -namespace Strasse_NS{ +namespace Strasse_NS { // Energy and time Resolution - const double EnergyThreshold = 10*keV; - const double ResoEnergy = 0.015*MeV ; + const double EnergyThreshold = 10 * keV; + const double ResoEnergy = 0.015 * MeV; //////////////////// // Inner Detector // //////////////////// // Wafer parameter - double Inner_Wafer_Length=100*mm; - double Inner_Wafer_Width=50*mm; - double Inner_Wafer_Thickness=300*micrometer; - double Inner_Wafer_AlThickness=0.4*micrometer; - double Inner_Wafer_PADExternal=1*cm; - double Inner_Wafer_PADInternal=1*mm; - double Inner_Wafer_GuardRing=0.5*mm; + double Inner_Wafer_Length = 100 * mm; + double Inner_Wafer_Width = 50 * mm; + double Inner_Wafer_Thickness = 300 * micrometer; + double Inner_Wafer_AlThickness = 0.4 * micrometer; + double Inner_Wafer_PADExternal = 1 * cm; + double Inner_Wafer_PADInternal = 1 * mm; + double Inner_Wafer_GuardRing = 0.5 * mm; // PCB parameter - double Inner_PCB_PortWidth=1*cm; - double Inner_PCB_StarboardWidth=2*mm; - double Inner_PCB_BevelAngle= 60*deg; - double Inner_PCB_UpstreamWidth=1*cm; - double Inner_PCB_DownstreamWidth=2*mm; - double Inner_PCB_MidWidth=2*mm; - double Inner_PCB_Thickness=3*mm; - double Inner_PCB_Ledge = 1*mm ; - double Inner_PCB_Step = 2*mm ; - double Inner_Wafer_TransverseStrips= 128; - double Inner_Wafer_LongitudinalStrips= 128; + double Inner_PCB_PortWidth = 1 * cm; + double Inner_PCB_StarboardWidth = 2 * mm; + double Inner_PCB_BevelAngle = 60 * deg; + double Inner_PCB_UpstreamWidth = 1 * cm; + double Inner_PCB_DownstreamWidth = 2 * mm; + double Inner_PCB_MidWidth = 2 * mm; + double Inner_PCB_Thickness = 3 * mm; + double Inner_PCB_Ledge = 1 * mm; + double Inner_PCB_Step = 2 * mm; + double Inner_Wafer_TransverseStrips = 128; + double Inner_Wafer_LongitudinalStrips = 128; //////////////////// // Outer Detector // //////////////////// // Wafer parameter - double Outer_Wafer_Length=150*mm; - double Outer_Wafer_Width=75*mm; - double Outer_Wafer_Thickness=300*micrometer; - double Outer_Wafer_AlThickness=0.4*micrometer; - double Outer_Wafer_PADExternal=1*cm; - double Outer_Wafer_PADInternal=1*mm; - double Outer_Wafer_GuardRing=0.5*mm; + double Outer_Wafer_Length = 150 * mm; + double Outer_Wafer_Width = 75 * mm; + double Outer_Wafer_Thickness = 300 * micrometer; + double Outer_Wafer_AlThickness = 0.4 * micrometer; + double Outer_Wafer_PADExternal = 1 * cm; + double Outer_Wafer_PADInternal = 1 * mm; + double Outer_Wafer_GuardRing = 0.5 * mm; // PCB parameter - double Outer_PCB_PortWidth=1*cm; - double Outer_PCB_StarboardWidth=2*mm; - double Outer_PCB_BevelAngle= 60*deg; - double Outer_PCB_UpstreamWidth=1*cm; - double Outer_PCB_DownstreamWidth=2*mm; - double Outer_PCB_MidWidth=2*mm; - double Outer_PCB_Thickness=3*mm; - double Outer_PCB_Ledge = 1*mm ; - double Outer_PCB_Step = 2*mm ; - double Outer_Wafer_TransverseStrips= 128; - double Outer_Wafer_LongitudinalStrips= 128; + double Outer_PCB_PortWidth = 1 * cm; + double Outer_PCB_StarboardWidth = 2 * mm; + double Outer_PCB_BevelAngle = 60 * deg; + double Outer_PCB_UpstreamWidth = 1 * cm; + double Outer_PCB_DownstreamWidth = 2 * mm; + double Outer_PCB_MidWidth = 2 * mm; + double Outer_PCB_Thickness = 3 * mm; + double Outer_PCB_Ledge = 1 * mm; + double Outer_PCB_Step = 2 * mm; + double Outer_Wafer_TransverseStrips = 128; + double Outer_Wafer_LongitudinalStrips = 128; //////////////////// // Vacuum Chamber // //////////////////// - double Chamber_Thickness= 3*mm; - double Chamber_Cylinder_Length= 400*mm; - double Chamber_Radius= 180*mm; - double Chamber_ExitTube_Radius= 79.5*mm ; - double Chamber_ExitTube_Length= 100*mm; - double Chamber_Flange_Inner_Radius= 150*mm; - double Chamber_Sphere_Radius= 220*mm ; - double Chamber_Sphere_Shift= 60*mm; + double Chamber_Thickness = 3 * mm; + double Chamber_Cylinder_Length = 400 * mm; + double Chamber_Radius = 180 * mm; + double Chamber_ExitTube_Radius = 79.5 * mm; + double Chamber_ExitTube_Length = 100 * mm; + double Chamber_Flange_Inner_Radius = 150 * mm; + double Chamber_Sphere_Radius = 220 * mm; + double Chamber_Sphere_Shift = 60 * mm; -} +} // namespace Strasse_NS using namespace Strasse_NS; //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Strasse Specific Method -Strasse::Strasse(){ +Strasse::Strasse() { InitializeMaterial(); - m_Event = new TStrasseData() ; + m_Event = new TStrasseData(); m_InnerScorer1 = 0; m_OuterScorer1 = 0; m_InnerScorer2 = 0; m_OuterScorer2 = 0; - m_InnerDetector=0; - m_OuterDetector=0; - m_Chamber=0; - m_Blades=0; - m_Stars=0; - m_Base=0; - m_Electronic=0; + m_InnerDetector = 0; + m_OuterDetector = 0; + m_Chamber = 0; + m_Blades = 0; + m_Stars = 0; + m_Base = 0; + m_Electronic = 0; found_chamber = false; found_stars = false; found_blades = false; found_base = false; // Dark Grey - SiliconVisAtt = new G4VisAttributes(G4Colour(0.5, 0.5, 0.5)) ; + SiliconVisAtt = new G4VisAttributes(G4Colour(0.5, 0.5, 0.5)); // Green - PCBVisAtt = new G4VisAttributes(G4Colour(0.2, 0.5, 0.2)) ; + PCBVisAtt = new G4VisAttributes(G4Colour(0.2, 0.5, 0.2)); // Gold Yellow - PADVisAtt = new G4VisAttributes(G4Colour(0.5, 0.5, 0.2)) ; + PADVisAtt = new G4VisAttributes(G4Colour(0.5, 0.5, 0.2)); // Light Grey - StarsVisAtt = new G4VisAttributes(G4Colour(0.5, 0.5, 0.5)) ; + StarsVisAtt = new G4VisAttributes(G4Colour(0.5, 0.5, 0.5)); // Space transparent - ChamberVisAtt = new G4VisAttributes(G4Colour(0.3, 0.4, 0.5,0.2)) ; + ChamberVisAtt = new G4VisAttributes(G4Colour(0.3, 0.4, 0.5, 0.2)); // Light Blue - GuardRingVisAtt = new G4VisAttributes(G4Colour(0.85, 0.85, 0.85,0.5)) ; + GuardRingVisAtt = new G4VisAttributes(G4Colour(0.85, 0.85, 0.85, 0.5)); // Light Blue - BladeVisAtt = new G4VisAttributes(G4Colour(1, 0.65, 0.0,0.7)) ; + BladeVisAtt = new G4VisAttributes(G4Colour(1, 0.65, 0.0, 0.7)); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -Strasse::~Strasse(){ -} +Strasse::~Strasse() {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Strasse::AddInnerDetector(double R, double Z, double Phi, double Shift, G4ThreeVector Ref){ +void Strasse::AddInnerDetector(double R, double Z, double Phi, double Shift, G4ThreeVector Ref) { m_Inner_R.push_back(R); m_Inner_Z.push_back(Z); m_Inner_Phi.push_back(Phi); @@ -185,7 +183,7 @@ void Strasse::AddInnerDetector(double R, double Z, double Phi, double Shift, } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Strasse::AddOuterDetector(double R, double Z, double Phi, double Shift, G4ThreeVector Ref){ +void Strasse::AddOuterDetector(double R, double Z, double Phi, double Shift, G4ThreeVector Ref) { m_Outer_R.push_back(R); m_Outer_Z.push_back(Z); m_Outer_Phi.push_back(Phi); @@ -194,444 +192,366 @@ void Strasse::AddOuterDetector(double R, double Z, double Phi, double Shift, } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Strasse::AddChamber(double Z){ - m_Chamber_Z.push_back(Z); -} +void Strasse::AddChamber(double Z) { m_Chamber_Z.push_back(Z); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -G4LogicalVolume* Strasse::BuildInnerDetector(){ - if(!m_InnerDetector){ +G4LogicalVolume* Strasse::BuildInnerDetector() { + if (!m_InnerDetector) { // Compute the needed full length of the PCB // along beam axis - double Inner_PCB_Length= 2*Inner_Wafer_Length - +Inner_PCB_UpstreamWidth - +Inner_PCB_MidWidth - +Inner_PCB_DownstreamWidth; + double Inner_PCB_Length = + 2 * Inner_Wafer_Length + Inner_PCB_UpstreamWidth + Inner_PCB_MidWidth + Inner_PCB_DownstreamWidth; // perpendicular to beam axis - double Inner_PCB_Width= Inner_Wafer_Width - +Inner_PCB_StarboardWidth - +Inner_PCB_PortWidth; + double Inner_PCB_Width = Inner_Wafer_Width + Inner_PCB_StarboardWidth + Inner_PCB_PortWidth; vector<G4TwoVector> PCBCrossSection; - + double l1; - if(Inner_PCB_BevelAngle==90) l1 = 0; - else l1 = Inner_PCB_Thickness*0.5/tan(Inner_PCB_BevelAngle); + if (Inner_PCB_BevelAngle == 90) + l1 = 0; + else + l1 = Inner_PCB_Thickness * 0.5 / tan(Inner_PCB_BevelAngle); - PCBCrossSection.push_back(G4TwoVector(Inner_PCB_Width*0.5-l1,-Inner_PCB_Thickness*0.5)); - PCBCrossSection.push_back(G4TwoVector(Inner_PCB_Width*0.5,Inner_PCB_Thickness*0.5)); - PCBCrossSection.push_back(G4TwoVector(-Inner_PCB_Width*0.5,Inner_PCB_Thickness*0.5)); - PCBCrossSection.push_back(G4TwoVector(-Inner_PCB_Width*0.5+l1,-Inner_PCB_Thickness*0.5)); + PCBCrossSection.push_back(G4TwoVector(Inner_PCB_Width * 0.5 - l1, -Inner_PCB_Thickness * 0.5)); + PCBCrossSection.push_back(G4TwoVector(Inner_PCB_Width * 0.5, Inner_PCB_Thickness * 0.5)); + PCBCrossSection.push_back(G4TwoVector(-Inner_PCB_Width * 0.5, Inner_PCB_Thickness * 0.5)); + PCBCrossSection.push_back(G4TwoVector(-Inner_PCB_Width * 0.5 + l1, -Inner_PCB_Thickness * 0.5)); - G4ExtrudedSolid* PCBFull = - new G4ExtrudedSolid("PCBFull", - PCBCrossSection, - Inner_PCB_Length*0.5,// half length - G4TwoVector(0,0),1,// offset, scale - G4TwoVector(0,0),1);// offset, scale + G4ExtrudedSolid* PCBFull = new G4ExtrudedSolid("PCBFull", PCBCrossSection, + Inner_PCB_Length * 0.5, // half length + G4TwoVector(0, 0), 1, // offset, scale + G4TwoVector(0, 0), 1); // offset, scale // Master Volume that encompass everything else - m_InnerDetector = - new G4LogicalVolume(PCBFull,m_MaterialVacuum,"logicBoxDetector", 0, 0, 0); - m_InnerDetector->SetVisAttributes(G4VisAttributes::Invisible); + m_InnerDetector = new G4LogicalVolume(PCBFull, m_MaterialVacuum, "logicBoxDetector", 0, 0, 0); + m_InnerDetector->SetVisAttributes(G4VisAttributes::GetInvisible()); /////////////////////////////////////////////////////////////////////////// // Build the external PCB frame // Calculate the hole shift within the PCB - double Width_Shift= -0.5*Inner_PCB_Width + 0.5*Inner_Wafer_Width // Flush to border - +Inner_PCB_PortWidth; // add the port side shift + double Width_Shift = -0.5 * Inner_PCB_Width + 0.5 * Inner_Wafer_Width // Flush to border + + Inner_PCB_PortWidth; // add the port side shift - double Length_Shift1 = -0.5*Inner_PCB_Length + 0.5*Inner_Wafer_Length // Flush to border - + Inner_PCB_UpstreamWidth;// add Upstream side shift + double Length_Shift1 = -0.5 * Inner_PCB_Length + 0.5 * Inner_Wafer_Length // Flush to border + + Inner_PCB_UpstreamWidth; // add Upstream side shift - double Length_Shift2 = Length_Shift1 // overlap detector 1 - + Inner_Wafer_Length // at opposing edge - + Inner_PCB_MidWidth; // after mid width + double Length_Shift2 = Length_Shift1 // overlap detector 1 + + Inner_Wafer_Length // at opposing edge + + Inner_PCB_MidWidth; // after mid width G4ThreeVector HoleShift1 = G4ThreeVector(Width_Shift, 0, Length_Shift1); G4ThreeVector HoleShift2 = G4ThreeVector(Width_Shift, 0, Length_Shift2); - G4Box* HoleShape = new G4Box("HoleShape", - Inner_Wafer_Width*0.5, - Inner_PCB_Thickness*0.5+0.1*mm, - Inner_Wafer_Length*0.5); + G4Box* HoleShape = + new G4Box("HoleShape", Inner_Wafer_Width * 0.5, Inner_PCB_Thickness * 0.5 + 0.1 * mm, Inner_Wafer_Length * 0.5); // Substracting the hole Shape from the Stock PCB - G4SubtractionSolid* PCB_1 = new G4SubtractionSolid("PCB_1", PCBFull, HoleShape, - new G4RotationMatrix,HoleShift1); - G4SubtractionSolid* PCB = new G4SubtractionSolid("PCB", PCB_1, HoleShape, - new G4RotationMatrix,HoleShift2); + G4SubtractionSolid* PCB_1 = new G4SubtractionSolid("PCB_1", PCBFull, HoleShape, new G4RotationMatrix, HoleShift1); + G4SubtractionSolid* PCB = new G4SubtractionSolid("PCB", PCB_1, HoleShape, new G4RotationMatrix, HoleShift2); // Sub Volume PCB - G4LogicalVolume* logicPCB = - new G4LogicalVolume(PCB,m_MaterialPCB,"logicPCB", 0, 0, 0); + G4LogicalVolume* logicPCB = new G4LogicalVolume(PCB, m_MaterialPCB, "logicPCB", 0, 0, 0); logicPCB->SetVisAttributes(PCBVisAtt); - new G4PVPlacement(new G4RotationMatrix(0,0,0), - G4ThreeVector(0,0,0), - logicPCB,"Strasse_Inner_PCB",m_InnerDetector, - false,0); + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), G4ThreeVector(0, 0, 0), logicPCB, "Strasse_Inner_PCB", + m_InnerDetector, false, 0); /////////////////////////////////////////////////////////////////////////// // Build the PCB Ledge on wich Silicon is glued - double Inner_PCB2_Thickness = Inner_PCB_Step; //Step size - double offsetPCB2 = Inner_PCB2_Thickness - Inner_PCB_Thickness; + double Inner_PCB2_Thickness = Inner_PCB_Step; // Step size + double offsetPCB2 = Inner_PCB2_Thickness - Inner_PCB_Thickness; - double Inner_PCB2_MidWidth = Inner_PCB_MidWidth; + double Inner_PCB2_MidWidth = Inner_PCB_MidWidth; // perpendicular to beam axis - double Inner_PCB2_Width= Inner_Wafer_Width; + double Inner_PCB2_Width = Inner_Wafer_Width; vector<G4TwoVector> PCB2CrossSection; - PCB2CrossSection.push_back(G4TwoVector(Inner_PCB2_Width*0.5,-Inner_PCB2_Thickness*0.5)); - PCB2CrossSection.push_back(G4TwoVector(Inner_PCB2_Width*0.5,Inner_PCB2_Thickness*0.5)); - PCB2CrossSection.push_back(G4TwoVector(-Inner_PCB2_Width*0.5,Inner_PCB2_Thickness*0.5)); - PCB2CrossSection.push_back(G4TwoVector(-Inner_PCB2_Width*0.5,-Inner_PCB2_Thickness*0.5)); - - //double Inner_PCB2_Length= Inner_PCB_Length; - double Inner_PCB2_Length= 2*Inner_Wafer_Length + Inner_PCB_MidWidth; - - G4ExtrudedSolid* PCB2Full = - new G4ExtrudedSolid("PCB2Full", - PCB2CrossSection, - Inner_PCB2_Length*0.5,// half length - G4TwoVector(0,0),1,// offset, scale - G4TwoVector(0,0),1);// offset, scale - - - double Length_Shift21 = -0.5*Inner_PCB_Length // Flush to border - + 0.5*(Inner_PCB_UpstreamWidth+Inner_PCB_DownstreamWidth) // add Upstream side shift - + 0.5*Inner_Wafer_Length; - double Length_Shift22 = Length_Shift21 // overlap detector 1 - + Inner_Wafer_Length // at opposing edge - + Inner_PCB_MidWidth; // after mid width + PCB2CrossSection.push_back(G4TwoVector(Inner_PCB2_Width * 0.5, -Inner_PCB2_Thickness * 0.5)); + PCB2CrossSection.push_back(G4TwoVector(Inner_PCB2_Width * 0.5, Inner_PCB2_Thickness * 0.5)); + PCB2CrossSection.push_back(G4TwoVector(-Inner_PCB2_Width * 0.5, Inner_PCB2_Thickness * 0.5)); + PCB2CrossSection.push_back(G4TwoVector(-Inner_PCB2_Width * 0.5, -Inner_PCB2_Thickness * 0.5)); + + // double Inner_PCB2_Length= Inner_PCB_Length; + double Inner_PCB2_Length = 2 * Inner_Wafer_Length + Inner_PCB_MidWidth; + + G4ExtrudedSolid* PCB2Full = new G4ExtrudedSolid("PCB2Full", PCB2CrossSection, + Inner_PCB2_Length * 0.5, // half length + G4TwoVector(0, 0), 1, // offset, scale + G4TwoVector(0, 0), 1); // offset, scale + + double Length_Shift21 = -0.5 * Inner_PCB_Length // Flush to border + + 0.5 * (Inner_PCB_UpstreamWidth + Inner_PCB_DownstreamWidth) // add Upstream side shift + + 0.5 * Inner_Wafer_Length; + double Length_Shift22 = Length_Shift21 // overlap detector 1 + + Inner_Wafer_Length // at opposing edge + + Inner_PCB_MidWidth; // after mid width G4ThreeVector HoleShift21 = G4ThreeVector(0, 0, Length_Shift21); G4ThreeVector HoleShift22 = G4ThreeVector(0, 0, Length_Shift22); - G4Box* HoleShape2 = new G4Box("HoleShape2", - Inner_Wafer_Width*0.5 - Inner_PCB_Ledge, - Inner_PCB2_Thickness, - Inner_Wafer_Length*0.5 - Inner_PCB_Ledge); + G4Box* HoleShape2 = new G4Box("HoleShape2", Inner_Wafer_Width * 0.5 - Inner_PCB_Ledge, Inner_PCB2_Thickness, + Inner_Wafer_Length * 0.5 - Inner_PCB_Ledge); // Substracting the hole Shape from the Stock PCB - G4SubtractionSolid* PCB2_1 = new G4SubtractionSolid("PCB2_1", PCB2Full, HoleShape2, - new G4RotationMatrix,HoleShift21); - G4SubtractionSolid* PCB2_2 = new G4SubtractionSolid("PCB2_2", PCB2_1, HoleShape2, - new G4RotationMatrix,HoleShift22); + G4SubtractionSolid* PCB2_1 = + new G4SubtractionSolid("PCB2_1", PCB2Full, HoleShape2, new G4RotationMatrix, HoleShift21); + G4SubtractionSolid* PCB2_2 = + new G4SubtractionSolid("PCB2_2", PCB2_1, HoleShape2, new G4RotationMatrix, HoleShift22); G4ThreeVector HoleCenterBar = G4ThreeVector(0, 0, 0); - G4Box* HoleShapeCenterBar = new G4Box("HoleShapeCenterBar", - Inner_PCB2_Width*0.5+0.1, - Inner_PCB2_Thickness, - Inner_PCB2_MidWidth*0.5); + G4Box* HoleShapeCenterBar = + new G4Box("HoleShapeCenterBar", Inner_PCB2_Width * 0.5 + 0.1, Inner_PCB2_Thickness, Inner_PCB2_MidWidth * 0.5); - G4SubtractionSolid* PCB2_3 = new G4SubtractionSolid("PCB2_3", PCB2_2, HoleShapeCenterBar, - new G4RotationMatrix,HoleCenterBar); + G4SubtractionSolid* PCB2_3 = + new G4SubtractionSolid("PCB2_3", PCB2_2, HoleShapeCenterBar, new G4RotationMatrix, HoleCenterBar); // Sub Volume PCB - G4LogicalVolume* logicPCB2 = - new G4LogicalVolume(PCB2_3,m_MaterialPCB,"logicPCB2", 0, 0, 0); + G4LogicalVolume* logicPCB2 = new G4LogicalVolume(PCB2_3, m_MaterialPCB, "logicPCB2", 0, 0, 0); logicPCB2->SetVisAttributes(PADVisAtt); // Offset along beam axis between PCB middle and (2*Wafer+MiddleBar) volume center - double CentralZOffset = - Inner_PCB_Length*0.5 - + Inner_PCB_UpstreamWidth - + Inner_Wafer_Length - + Inner_PCB_MidWidth*0.5; - - new G4PVPlacement(new G4RotationMatrix(0,0,0), - G4ThreeVector(0,-0.5*offsetPCB2,CentralZOffset), - logicPCB2,"Strasse_Inner_PCB2",m_InnerDetector, - false,0); + double CentralZOffset = + -Inner_PCB_Length * 0.5 + Inner_PCB_UpstreamWidth + Inner_Wafer_Length + Inner_PCB_MidWidth * 0.5; + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), G4ThreeVector(0, -0.5 * offsetPCB2, CentralZOffset), logicPCB2, + "Strasse_Inner_PCB2", m_InnerDetector, false, 0); - /////////////////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////////// // Build the Wafer // Sub volume Wafer - G4Box* WaferShape = new G4Box("WaferShape", - Inner_Wafer_Width*0.5, - Inner_Wafer_Thickness*0.5+Inner_Wafer_AlThickness, - Inner_Wafer_Length*0.5); + G4Box* WaferShape = new G4Box("WaferShape", Inner_Wafer_Width * 0.5, + Inner_Wafer_Thickness * 0.5 + Inner_Wafer_AlThickness, Inner_Wafer_Length * 0.5); - G4LogicalVolume* logicWafer1 = - new G4LogicalVolume(WaferShape,m_MaterialSilicon,"logicWafer1", 0, 0, 0); + G4LogicalVolume* logicWafer1 = new G4LogicalVolume(WaferShape, m_MaterialSilicon, "logicWafer1", 0, 0, 0); logicWafer1->SetVisAttributes(GuardRingVisAtt); - G4LogicalVolume* logicWafer2 = - new G4LogicalVolume(WaferShape,m_MaterialSilicon,"logicWafer2", 0, 0, 0); + G4LogicalVolume* logicWafer2 = new G4LogicalVolume(WaferShape, m_MaterialSilicon, "logicWafer2", 0, 0, 0); logicWafer2->SetVisAttributes(GuardRingVisAtt); // Shift along Y to flush the wafer to the pcb ledge on one side - G4ThreeVector WaferShiftY = G4ThreeVector(0,-0.5*Inner_Wafer_Thickness - -Inner_Wafer_AlThickness - -0.5*Inner_PCB_Thickness - -offsetPCB2-0.05,0); - - //G4ThreeVector WaferShiftZ = G4ThreeVector(0,0,-Inner_PCB_UpstreamWidth-Inner_PCB_MidWidth); - G4ThreeVector WaferShiftZ = G4ThreeVector(0,0,CentralZOffset); - - new G4PVPlacement(new G4RotationMatrix(0,0,0), - WaferShiftY+WaferShiftZ // Shift along Y - +HoleShift21, // Shift along Z to putwafer in the 1st hole - logicWafer1,"Strasse_Inner_Wafer1",m_InnerDetector, - false,0); - - new G4PVPlacement(new G4RotationMatrix(0,0,0), - WaferShiftY+WaferShiftZ// Shift along Y - +HoleShift22, // Shift along Z to put wafer in the 2nd hole - logicWafer2,"Strasse_Inner_Wafer2",m_InnerDetector, - false,0); + G4ThreeVector WaferShiftY = G4ThreeVector( + 0, -0.5 * Inner_Wafer_Thickness - Inner_Wafer_AlThickness - 0.5 * Inner_PCB_Thickness - offsetPCB2 - 0.05, 0); + + // G4ThreeVector WaferShiftZ = G4ThreeVector(0,0,-Inner_PCB_UpstreamWidth-Inner_PCB_MidWidth); + G4ThreeVector WaferShiftZ = G4ThreeVector(0, 0, CentralZOffset); + + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), + WaferShiftY + WaferShiftZ // Shift along Y + + HoleShift21, // Shift along Z to putwafer in the 1st hole + logicWafer1, "Strasse_Inner_Wafer1", m_InnerDetector, false, 0); + + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), + WaferShiftY + WaferShiftZ // Shift along Y + + HoleShift22, // Shift along Z to put wafer in the 2nd hole + logicWafer2, "Strasse_Inner_Wafer2", m_InnerDetector, false, 0); // Sub volume Active Wafer - G4Box* ActiveWaferShape = new G4Box("InnerActiveWaferShape", - 0.5*m_Active_InnerWafer_Width, - 0.5*Inner_Wafer_Thickness, - 0.5*m_Active_InnerWafer_Length); + G4Box* ActiveWaferShape = new G4Box("InnerActiveWaferShape", 0.5 * m_Active_InnerWafer_Width, + 0.5 * Inner_Wafer_Thickness, 0.5 * m_Active_InnerWafer_Length); G4LogicalVolume* logicActiveWafer1 = - new G4LogicalVolume(ActiveWaferShape,m_MaterialSilicon,"logicActiveWafer1", 0, 0, 0); + new G4LogicalVolume(ActiveWaferShape, m_MaterialSilicon, "logicActiveWafer1", 0, 0, 0); logicActiveWafer1->SetVisAttributes(SiliconVisAtt); logicActiveWafer1->SetSensitiveDetector(m_InnerScorer1); G4LogicalVolume* logicActiveWafer2 = - new G4LogicalVolume(ActiveWaferShape,m_MaterialSilicon,"logicActiveWafer2", 0, 0, 0); + new G4LogicalVolume(ActiveWaferShape, m_MaterialSilicon, "logicActiveWafer2", 0, 0, 0); logicActiveWafer2->SetVisAttributes(SiliconVisAtt); logicActiveWafer2->SetSensitiveDetector(m_InnerScorer2); - new G4PVPlacement(new G4RotationMatrix(0,0,0), - G4ThreeVector(0,0,0.5*(Inner_Wafer_PADExternal-Inner_Wafer_PADInternal)), // assymetric pading for bounding - logicActiveWafer1,"Strasse_Inner_ActiveWafer1",logicWafer1, - false,1); - - new G4PVPlacement(new G4RotationMatrix(0,0,0), - G4ThreeVector(0,0,-0.5*(Inner_Wafer_PADExternal-Inner_Wafer_PADInternal)), // assymetric pading for bounding - logicActiveWafer2,"Strasse_Inner_ActiveWafer2",logicWafer2, - false,2); - + new G4PVPlacement( + new G4RotationMatrix(0, 0, 0), + G4ThreeVector(0, 0, + 0.5 * (Inner_Wafer_PADExternal - Inner_Wafer_PADInternal)), // assymetric pading for bounding + logicActiveWafer1, "Strasse_Inner_ActiveWafer1", logicWafer1, false, 1); + + new G4PVPlacement( + new G4RotationMatrix(0, 0, 0), + G4ThreeVector(0, 0, + -0.5 * (Inner_Wafer_PADExternal - Inner_Wafer_PADInternal)), // assymetric pading for bounding + logicActiveWafer2, "Strasse_Inner_ActiveWafer2", logicWafer2, false, 2); } return m_InnerDetector; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -G4LogicalVolume* Strasse::BuildOuterDetector(){ - if(!m_OuterDetector){ +G4LogicalVolume* Strasse::BuildOuterDetector() { + if (!m_OuterDetector) { // Compute the needed full length of the PCB // along beam axis - double Outer_PCB_Length= 2*Outer_Wafer_Length - +Outer_PCB_UpstreamWidth - +Outer_PCB_MidWidth - +Outer_PCB_DownstreamWidth; + double Outer_PCB_Length = + 2 * Outer_Wafer_Length + Outer_PCB_UpstreamWidth + Outer_PCB_MidWidth + Outer_PCB_DownstreamWidth; // perpendicular to beam axis - double Outer_PCB_Width= Outer_Wafer_Width - +Outer_PCB_StarboardWidth - +Outer_PCB_PortWidth; - + double Outer_PCB_Width = Outer_Wafer_Width + Outer_PCB_StarboardWidth + Outer_PCB_PortWidth; vector<G4TwoVector> PCBCrossSection; double l1; - if(Outer_PCB_BevelAngle==90) l1 = 0; - else l1 = Outer_PCB_Thickness*0.5/tan(Outer_PCB_BevelAngle); + if (Outer_PCB_BevelAngle == 90) + l1 = 0; + else + l1 = Outer_PCB_Thickness * 0.5 / tan(Outer_PCB_BevelAngle); - PCBCrossSection.push_back(G4TwoVector(Outer_PCB_Width*0.5-l1,-Outer_PCB_Thickness*0.5)); - PCBCrossSection.push_back(G4TwoVector(Outer_PCB_Width*0.5,Outer_PCB_Thickness*0.5)); - PCBCrossSection.push_back(G4TwoVector(-Outer_PCB_Width*0.5,Outer_PCB_Thickness*0.5)); - PCBCrossSection.push_back(G4TwoVector(-Outer_PCB_Width*0.5+l1,-Outer_PCB_Thickness*0.5)); + PCBCrossSection.push_back(G4TwoVector(Outer_PCB_Width * 0.5 - l1, -Outer_PCB_Thickness * 0.5)); + PCBCrossSection.push_back(G4TwoVector(Outer_PCB_Width * 0.5, Outer_PCB_Thickness * 0.5)); + PCBCrossSection.push_back(G4TwoVector(-Outer_PCB_Width * 0.5, Outer_PCB_Thickness * 0.5)); + PCBCrossSection.push_back(G4TwoVector(-Outer_PCB_Width * 0.5 + l1, -Outer_PCB_Thickness * 0.5)); - G4ExtrudedSolid* PCBFull = - new G4ExtrudedSolid("PCBFull", - PCBCrossSection, - Outer_PCB_Length*0.5,// half length - G4TwoVector(0,0),1,// offset, scale - G4TwoVector(0,0),1);// offset, scale + G4ExtrudedSolid* PCBFull = new G4ExtrudedSolid("PCBFull", PCBCrossSection, + Outer_PCB_Length * 0.5, // half length + G4TwoVector(0, 0), 1, // offset, scale + G4TwoVector(0, 0), 1); // offset, scale // Master Volume that encompass everything else - m_OuterDetector = - new G4LogicalVolume(PCBFull,m_MaterialVacuum,"logicBoxDetector", 0, 0, 0); - m_OuterDetector->SetVisAttributes(G4VisAttributes::Invisible); + m_OuterDetector = new G4LogicalVolume(PCBFull, m_MaterialVacuum, "logicBoxDetector", 0, 0, 0); + m_OuterDetector->SetVisAttributes(G4VisAttributes::GetInvisible()); // Build the PCB // Calculate the hole shift within the PCB - double Width_Shift= -0.5*Outer_PCB_Width + 0.5*Outer_Wafer_Width // Flush to border - +Outer_PCB_PortWidth; // add the port side shift + double Width_Shift = -0.5 * Outer_PCB_Width + 0.5 * Outer_Wafer_Width // Flush to border + + Outer_PCB_PortWidth; // add the port side shift - double Length_Shift1 = -0.5*Outer_PCB_Length + 0.5*Outer_Wafer_Length // Flush to border - + Outer_PCB_UpstreamWidth;// add Upstream side shift + double Length_Shift1 = -0.5 * Outer_PCB_Length + 0.5 * Outer_Wafer_Length // Flush to border + + Outer_PCB_UpstreamWidth; // add Upstream side shift - double Length_Shift2 = Length_Shift1 // overlap detector 1 - + Outer_Wafer_Length // at opposing edge - + Outer_PCB_MidWidth; // after mid width + double Length_Shift2 = Length_Shift1 // overlap detector 1 + + Outer_Wafer_Length // at opposing edge + + Outer_PCB_MidWidth; // after mid width G4ThreeVector HoleShift1 = G4ThreeVector(Width_Shift, 0, Length_Shift1); G4ThreeVector HoleShift2 = G4ThreeVector(Width_Shift, 0, Length_Shift2); - G4Box* HoleShape = new G4Box("HoleShape", - Outer_Wafer_Width*0.5, - Outer_PCB_Thickness*0.5+0.1*mm, - Outer_Wafer_Length*0.5); + G4Box* HoleShape = + new G4Box("HoleShape", Outer_Wafer_Width * 0.5, Outer_PCB_Thickness * 0.5 + 0.1 * mm, Outer_Wafer_Length * 0.5); // Substracting the hole Shape from the Stock PCB - G4SubtractionSolid* PCB_1 = new G4SubtractionSolid("PCB_1", PCBFull, HoleShape, - new G4RotationMatrix,HoleShift1); - G4SubtractionSolid* PCB = new G4SubtractionSolid("PCB", PCB_1, HoleShape, - new G4RotationMatrix,HoleShift2); + G4SubtractionSolid* PCB_1 = new G4SubtractionSolid("PCB_1", PCBFull, HoleShape, new G4RotationMatrix, HoleShift1); + G4SubtractionSolid* PCB = new G4SubtractionSolid("PCB", PCB_1, HoleShape, new G4RotationMatrix, HoleShift2); // Sub Volume PCB - G4LogicalVolume* logicPCB = - new G4LogicalVolume(PCB,m_MaterialPCB,"logicPCB", 0, 0, 0); + G4LogicalVolume* logicPCB = new G4LogicalVolume(PCB, m_MaterialPCB, "logicPCB", 0, 0, 0); logicPCB->SetVisAttributes(PCBVisAtt); - new G4PVPlacement(new G4RotationMatrix(0,0,0), - G4ThreeVector(0,0,0), - logicPCB,"Strasse_Outer_PCB",m_OuterDetector, - false,0); + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), G4ThreeVector(0, 0, 0), logicPCB, "Strasse_Outer_PCB", + m_OuterDetector, false, 0); /////////////////////////////////////////////////////////////////////////// // Build the internal PCB layer - double Outer_PCB2_Thickness = Outer_PCB_Step;//Step size + double Outer_PCB2_Thickness = Outer_PCB_Step; // Step size double offsetPCB2 = Outer_PCB2_Thickness - Outer_PCB_Thickness; - double Outer_PCB2_MidWidth = Outer_PCB_MidWidth; + double Outer_PCB2_MidWidth = Outer_PCB_MidWidth; // perpendicular to beam axis - double Outer_PCB2_Width= Outer_Wafer_Width; + double Outer_PCB2_Width = Outer_Wafer_Width; vector<G4TwoVector> PCB2CrossSection; - PCB2CrossSection.push_back(G4TwoVector(Outer_PCB2_Width*0.5,-Outer_PCB2_Thickness*0.5)); - PCB2CrossSection.push_back(G4TwoVector(Outer_PCB2_Width*0.5,Outer_PCB2_Thickness*0.5)); - PCB2CrossSection.push_back(G4TwoVector(-Outer_PCB2_Width*0.5,Outer_PCB2_Thickness*0.5)); - PCB2CrossSection.push_back(G4TwoVector(-Outer_PCB2_Width*0.5,-Outer_PCB2_Thickness*0.5)); - - - double Outer_PCB2_Length= 2*Outer_Wafer_Length + Outer_PCB_MidWidth; + PCB2CrossSection.push_back(G4TwoVector(Outer_PCB2_Width * 0.5, -Outer_PCB2_Thickness * 0.5)); + PCB2CrossSection.push_back(G4TwoVector(Outer_PCB2_Width * 0.5, Outer_PCB2_Thickness * 0.5)); + PCB2CrossSection.push_back(G4TwoVector(-Outer_PCB2_Width * 0.5, Outer_PCB2_Thickness * 0.5)); + PCB2CrossSection.push_back(G4TwoVector(-Outer_PCB2_Width * 0.5, -Outer_PCB2_Thickness * 0.5)); - G4ExtrudedSolid* PCB2Full = - new G4ExtrudedSolid("PCB2Full", - PCB2CrossSection, - Outer_PCB2_Length*0.5,// half length - G4TwoVector(0,0),1,// offset, scale - G4TwoVector(0,0),1);// offset, scale + double Outer_PCB2_Length = 2 * Outer_Wafer_Length + Outer_PCB_MidWidth; + G4ExtrudedSolid* PCB2Full = new G4ExtrudedSolid("PCB2Full", PCB2CrossSection, + Outer_PCB2_Length * 0.5, // half length + G4TwoVector(0, 0), 1, // offset, scale + G4TwoVector(0, 0), 1); // offset, scale - double Length_Shift21 = -0.5*Outer_PCB_Length // Flush to border - + 0.5*(Outer_PCB_UpstreamWidth+Outer_PCB_DownstreamWidth) - + 0.5*Outer_Wafer_Length; - double Length_Shift22 = Length_Shift21 // overlap detector 1 - + Outer_Wafer_Length // at opposing edge - + Outer_PCB_MidWidth; // after mid width + double Length_Shift21 = -0.5 * Outer_PCB_Length // Flush to border + + 0.5 * (Outer_PCB_UpstreamWidth + Outer_PCB_DownstreamWidth) + 0.5 * Outer_Wafer_Length; + double Length_Shift22 = Length_Shift21 // overlap detector 1 + + Outer_Wafer_Length // at opposing edge + + Outer_PCB_MidWidth; // after mid width G4ThreeVector HoleShift21 = G4ThreeVector(0, 0, Length_Shift21); G4ThreeVector HoleShift22 = G4ThreeVector(0, 0, Length_Shift22); - G4Box* HoleShape2 = new G4Box("HoleShape2", - Outer_Wafer_Width*0.5 - Outer_PCB_Ledge, - Outer_PCB2_Thickness, - Outer_Wafer_Length*0.5 - Outer_PCB_Ledge); + G4Box* HoleShape2 = new G4Box("HoleShape2", Outer_Wafer_Width * 0.5 - Outer_PCB_Ledge, Outer_PCB2_Thickness, + Outer_Wafer_Length * 0.5 - Outer_PCB_Ledge); // Substracting the hole Shape from the Stock PCB - G4SubtractionSolid* PCB2_1 = new G4SubtractionSolid("PCB2_1", PCB2Full, HoleShape2, - new G4RotationMatrix,HoleShift21); - G4SubtractionSolid* PCB2_2 = new G4SubtractionSolid("PCB2_2", PCB2_1, HoleShape2, - new G4RotationMatrix,HoleShift22); - + G4SubtractionSolid* PCB2_1 = + new G4SubtractionSolid("PCB2_1", PCB2Full, HoleShape2, new G4RotationMatrix, HoleShift21); + G4SubtractionSolid* PCB2_2 = + new G4SubtractionSolid("PCB2_2", PCB2_1, HoleShape2, new G4RotationMatrix, HoleShift22); + G4ThreeVector HoleCenterBar = G4ThreeVector(0, 0, 0); - G4Box* HoleShapeCenterBar = new G4Box("HoleShapeCenterBar", - Outer_PCB2_Width*0.5+0.1, - Outer_PCB2_Thickness, - Outer_PCB2_MidWidth*0.5); + G4Box* HoleShapeCenterBar = + new G4Box("HoleShapeCenterBar", Outer_PCB2_Width * 0.5 + 0.1, Outer_PCB2_Thickness, Outer_PCB2_MidWidth * 0.5); - G4SubtractionSolid* PCB2_3 = new G4SubtractionSolid("PCB2_3", PCB2_2, HoleShapeCenterBar, - new G4RotationMatrix,HoleCenterBar); + G4SubtractionSolid* PCB2_3 = + new G4SubtractionSolid("PCB2_3", PCB2_2, HoleShapeCenterBar, new G4RotationMatrix, HoleCenterBar); // Sub Volume PCB - G4LogicalVolume* logicPCB2 = - new G4LogicalVolume(PCB2_3,m_MaterialPCB,"logicPCB2", 0, 0, 0); + G4LogicalVolume* logicPCB2 = new G4LogicalVolume(PCB2_3, m_MaterialPCB, "logicPCB2", 0, 0, 0); logicPCB2->SetVisAttributes(PADVisAtt); // Offset along beam axis between PCB middle and (2*Wafer+MiddleBar) volume center - double CentralZOffset = - Outer_PCB_Length*0.5 - + Outer_PCB_UpstreamWidth - + Outer_Wafer_Length - + Outer_PCB_MidWidth*0.5; + double CentralZOffset = + -Outer_PCB_Length * 0.5 + Outer_PCB_UpstreamWidth + Outer_Wafer_Length + Outer_PCB_MidWidth * 0.5; - new G4PVPlacement(new G4RotationMatrix(0,0,0), - G4ThreeVector(0,-0.5*offsetPCB2,CentralZOffset), - logicPCB2,"Strasse_Outer_PCB2",m_OuterDetector, - false,0); + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), G4ThreeVector(0, -0.5 * offsetPCB2, CentralZOffset), logicPCB2, + "Strasse_Outer_PCB2", m_OuterDetector, false, 0); ////////////////////////////////////////////////////////////////// // Build the Wafer // Sub volume Wafer - G4Box* WaferShape = new G4Box("WaferShape", - Outer_Wafer_Width*0.5, - Outer_Wafer_Thickness*0.5+Outer_Wafer_AlThickness, - Outer_Wafer_Length*0.5); + G4Box* WaferShape = new G4Box("WaferShape", Outer_Wafer_Width * 0.5, + Outer_Wafer_Thickness * 0.5 + Outer_Wafer_AlThickness, Outer_Wafer_Length * 0.5); - G4LogicalVolume* logicWafer1 = - new G4LogicalVolume(WaferShape,m_MaterialSilicon,"logicWafer1", 0, 0, 0); + G4LogicalVolume* logicWafer1 = new G4LogicalVolume(WaferShape, m_MaterialSilicon, "logicWafer1", 0, 0, 0); logicWafer1->SetVisAttributes(GuardRingVisAtt); - G4LogicalVolume* logicWafer2 = - new G4LogicalVolume(WaferShape,m_MaterialSilicon,"logicWafer2", 0, 0, 0); + G4LogicalVolume* logicWafer2 = new G4LogicalVolume(WaferShape, m_MaterialSilicon, "logicWafer2", 0, 0, 0); logicWafer2->SetVisAttributes(GuardRingVisAtt); // Shift along Y to flush the wafer to the pcb ledge on one side - G4ThreeVector WaferShiftY = G4ThreeVector(0,-0.5*Outer_Wafer_Thickness - -Outer_Wafer_AlThickness - -0.5*Outer_PCB_Thickness - -offsetPCB2-0.05,0); - - //G4ThreeVector WaferShiftZ = G4ThreeVector(0,0,-Outer_PCB_UpstreamWidth-Outer_PCB_MidWidth); - G4ThreeVector WaferShiftZ = G4ThreeVector(0,0,CentralZOffset); - - new G4PVPlacement(new G4RotationMatrix(0,0,0), - WaferShiftY+WaferShiftZ - +HoleShift21, // Shift along Z to put wafer in the 1st hole - logicWafer1,"Strasse_Outer_Wafer1",m_OuterDetector, - false,0); - - new G4PVPlacement(new G4RotationMatrix(0,0,0), - WaferShiftY+WaferShiftZ - +HoleShift22, // Shift along Z to put wafer in the 1st hole - logicWafer2,"Strasse_Outer_Wafer2",m_OuterDetector, - false,0); + G4ThreeVector WaferShiftY = G4ThreeVector( + 0, -0.5 * Outer_Wafer_Thickness - Outer_Wafer_AlThickness - 0.5 * Outer_PCB_Thickness - offsetPCB2 - 0.05, 0); + + // G4ThreeVector WaferShiftZ = G4ThreeVector(0,0,-Outer_PCB_UpstreamWidth-Outer_PCB_MidWidth); + G4ThreeVector WaferShiftZ = G4ThreeVector(0, 0, CentralZOffset); + + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), + WaferShiftY + WaferShiftZ + HoleShift21, // Shift along Z to put wafer in the 1st hole + logicWafer1, "Strasse_Outer_Wafer1", m_OuterDetector, false, 0); + + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), + WaferShiftY + WaferShiftZ + HoleShift22, // Shift along Z to put wafer in the 1st hole + logicWafer2, "Strasse_Outer_Wafer2", m_OuterDetector, false, 0); // Sub volume Active Wafer - G4Box* ActiveWaferShape = new G4Box("OuterActiveWaferShape", - 0.5*m_Active_OuterWafer_Width, - 0.5*Outer_Wafer_Thickness, - 0.5*m_Active_OuterWafer_Length); + G4Box* ActiveWaferShape = new G4Box("OuterActiveWaferShape", 0.5 * m_Active_OuterWafer_Width, + 0.5 * Outer_Wafer_Thickness, 0.5 * m_Active_OuterWafer_Length); G4LogicalVolume* logicActiveWafer1 = - new G4LogicalVolume(ActiveWaferShape,m_MaterialSilicon,"logicActiveWafer1", 0, 0, 0); + new G4LogicalVolume(ActiveWaferShape, m_MaterialSilicon, "logicActiveWafer1", 0, 0, 0); logicActiveWafer1->SetVisAttributes(SiliconVisAtt); logicActiveWafer1->SetSensitiveDetector(m_OuterScorer1); G4LogicalVolume* logicActiveWafer2 = - new G4LogicalVolume(ActiveWaferShape,m_MaterialSilicon,"logicActiveWafer2", 0, 0, 0); + new G4LogicalVolume(ActiveWaferShape, m_MaterialSilicon, "logicActiveWafer2", 0, 0, 0); logicActiveWafer2->SetVisAttributes(SiliconVisAtt); logicActiveWafer2->SetSensitiveDetector(m_OuterScorer2); - new G4PVPlacement(new G4RotationMatrix(0,0,0), - G4ThreeVector(0,0,0.5*(Outer_Wafer_PADExternal-Outer_Wafer_PADInternal)), - logicActiveWafer1,"Strasse_Outer_ActiveWafer1",logicWafer1, - false,1); - - new G4PVPlacement(new G4RotationMatrix(0,0,0), - G4ThreeVector(0,0,-0.5*(Outer_Wafer_PADExternal-Outer_Wafer_PADInternal)), - logicActiveWafer2,"Strasse_Outer_ActiveWafer2",logicWafer2, - false,2); + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), + G4ThreeVector(0, 0, 0.5 * (Outer_Wafer_PADExternal - Outer_Wafer_PADInternal)), logicActiveWafer1, + "Strasse_Outer_ActiveWafer1", logicWafer1, false, 1); + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), + G4ThreeVector(0, 0, -0.5 * (Outer_Wafer_PADExternal - Outer_Wafer_PADInternal)), + logicActiveWafer2, "Strasse_Outer_ActiveWafer2", logicWafer2, false, 2); } return m_OuterDetector; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -G4LogicalVolume* Strasse::BuildChamber(){ - if(!m_Chamber){ +G4LogicalVolume* Strasse::BuildChamber() { + if (!m_Chamber) { // Needed Element // G4Material* Material = MaterialManager::getInstance()->GetMaterialFromLibrary("Al"); G4Material* Material = MaterialManager::getInstance()->GetMaterialFromLibrary("Al5754"); @@ -639,141 +559,118 @@ G4LogicalVolume* Strasse::BuildChamber(){ G4RotationMatrix* Rot = new G4RotationMatrix(); // Main Cylinder - G4Tubs* Cylinder = new G4Tubs("StrasseCylinderVolume", - Chamber_Radius-Chamber_Thickness, - Chamber_Radius,Chamber_Cylinder_Length*0.5, - 0,360*deg); + G4Tubs* Cylinder = new G4Tubs("StrasseCylinderVolume", Chamber_Radius - Chamber_Thickness, Chamber_Radius, + Chamber_Cylinder_Length * 0.5, 0, 360 * deg); // for substraction - G4Tubs* DummyCyl = new G4Tubs("StrasseDummyCylVolume", - 0, - Chamber_Sphere_Radius*1.1,Chamber_Cylinder_Length*0.5, - 0,360*deg); + G4Tubs* DummyCyl = new G4Tubs("StrasseDummyCylVolume", 0, Chamber_Sphere_Radius * 1.1, + Chamber_Cylinder_Length * 0.5, 0, 360 * deg); - - // G4LogicalVolume* ChamberCyl = new G4LogicalVolume(Cyl,Material,"logic_Strasse_Chamber",0,0,0); + // G4LogicalVolume* ChamberCyl = new G4LogicalVolume(Cyl,Material,"logic_Strasse_Chamber",0,0,0); // Entrance Flange - G4Tubs* Flange = new G4Tubs("StrasseFlangeVolume", - Chamber_Flange_Inner_Radius, - Chamber_Radius,1*cm, - 0,360*deg); + G4Tubs* Flange = + new G4Tubs("StrasseFlangeVolume", Chamber_Flange_Inner_Radius, Chamber_Radius, 1 * cm, 0, 360 * deg); - // G4LogicalVolume* ChamberFlange = new G4LogicalVolume(Flange,Material,"logic_Strasse_Flange",0,0,0); + // G4LogicalVolume* ChamberFlange = new G4LogicalVolume(Flange,Material,"logic_Strasse_Flange",0,0,0); // Spherial Portion - G4Sphere* Sphere= new G4Sphere("StrasseSphereVolume", - Chamber_Sphere_Radius-Chamber_Thickness, - Chamber_Sphere_Radius, - 0,360*deg, - 0,180*deg); - + G4Sphere* Sphere = new G4Sphere("StrasseSphereVolume", Chamber_Sphere_Radius - Chamber_Thickness, + Chamber_Sphere_Radius, 0, 360 * deg, 0, 180 * deg); + // Exit tube portion - G4Tubs* Tube = new G4Tubs("StrasseTubeVolume", - Chamber_ExitTube_Radius-Chamber_Thickness, - Chamber_ExitTube_Radius,Chamber_ExitTube_Length*0.5, - 0,360*deg); - G4Tubs* DummyTube = new G4Tubs("StrasseDummyTubeVolume", - 0, - Chamber_ExitTube_Radius*0.99,Chamber_ExitTube_Length*0.5, - 0,360*deg); - - //Partial Sphere - - G4SubtractionSolid* Sphere1= new G4SubtractionSolid("Sphere1",Sphere,DummyCyl, - Rot,G4ThreeVector(0,0,-Chamber_Sphere_Shift)); - G4SubtractionSolid* Sphere2= new G4SubtractionSolid("Sphere2",Sphere1,DummyTube, - Rot,G4ThreeVector(0,0,Chamber_Sphere_Radius+Chamber_ExitTube_Length*0.5-2*cm)); - + G4Tubs* Tube = new G4Tubs("StrasseTubeVolume", Chamber_ExitTube_Radius - Chamber_Thickness, Chamber_ExitTube_Radius, + Chamber_ExitTube_Length * 0.5, 0, 360 * deg); + G4Tubs* DummyTube = new G4Tubs("StrasseDummyTubeVolume", 0, Chamber_ExitTube_Radius * 0.99, + Chamber_ExitTube_Length * 0.5, 0, 360 * deg); + + // Partial Sphere + + G4SubtractionSolid* Sphere1 = + new G4SubtractionSolid("Sphere1", Sphere, DummyCyl, Rot, G4ThreeVector(0, 0, -Chamber_Sphere_Shift)); + G4SubtractionSolid* Sphere2 = + new G4SubtractionSolid("Sphere2", Sphere1, DummyTube, Rot, + G4ThreeVector(0, 0, Chamber_Sphere_Radius + Chamber_ExitTube_Length * 0.5 - 2 * cm)); + // Building the whole chamber - G4UnionSolid* Chamber1= new G4UnionSolid("Chamber1",Cylinder,Flange, - Rot,G4ThreeVector(0,0,-Chamber_Cylinder_Length*0.5)); + G4UnionSolid* Chamber1 = + new G4UnionSolid("Chamber1", Cylinder, Flange, Rot, G4ThreeVector(0, 0, -Chamber_Cylinder_Length * 0.5)); - G4UnionSolid* Chamber2= new G4UnionSolid("Chamber2",Chamber1,Sphere2, - Rot,G4ThreeVector(0,0,Chamber_Sphere_Shift)); + G4UnionSolid* Chamber2 = + new G4UnionSolid("Chamber2", Chamber1, Sphere2, Rot, G4ThreeVector(0, 0, Chamber_Sphere_Shift)); - G4UnionSolid* Chamber3= new G4UnionSolid("Chamber3",Chamber2,Tube, - Rot,G4ThreeVector(0,0,Chamber_Sphere_Shift+Chamber_Sphere_Radius+Chamber_ExitTube_Length*0.5-2*cm)); + G4UnionSolid* Chamber3 = new G4UnionSolid( + "Chamber3", Chamber2, Tube, Rot, + G4ThreeVector(0, 0, Chamber_Sphere_Shift + Chamber_Sphere_Radius + Chamber_ExitTube_Length * 0.5 - 2 * cm)); - m_Chamber = new G4LogicalVolume(Chamber3,Material,"logic_Strasse_Chamber",0,0,0); + m_Chamber = new G4LogicalVolume(Chamber3, Material, "logic_Strasse_Chamber", 0, 0, 0); m_Chamber->SetVisAttributes(ChamberVisAtt); } - return m_Chamber; - } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -G4LogicalVolume* Strasse::BuildChamberFromCAD(string path){ - if(!m_Chamber){ - auto mesh = CADMesh::TessellatedMesh::FromSTL((char*) path.c_str()); - mesh->SetScale(mm); - //mesh->SetOffset(offset); - mesh->SetReverse(false); - - auto cad_solid = mesh->GetSolid(); - m_Chamber = new G4LogicalVolume(cad_solid, - m_MaterialAl, - "Strasse_Chamber", 0, 0, 0); - - m_Chamber->SetVisAttributes(ChamberVisAtt); - } - return m_Chamber; +G4LogicalVolume* Strasse::BuildChamberFromCAD(string path) { + if (!m_Chamber) { + auto mesh = CADMesh::TessellatedMesh::FromSTL((char*)path.c_str()); + mesh->SetScale(mm); + // mesh->SetOffset(offset); + mesh->SetReverse(false); + auto cad_solid = mesh->GetSolid(); + m_Chamber = new G4LogicalVolume(cad_solid, m_MaterialAl, "Strasse_Chamber", 0, 0, 0); + + m_Chamber->SetVisAttributes(ChamberVisAtt); + } + return m_Chamber; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -G4LogicalVolume* Strasse::BuildBlades(string path){ - if(!m_Blades){ - auto mesh = CADMesh::TessellatedMesh::FromSTL((char*) path.c_str()); - mesh->SetScale(mm); - //mesh->SetOffset(offset); - mesh->SetReverse(false); - - auto cad_solid = mesh->GetSolid(); - m_Blades = new G4LogicalVolume(cad_solid, - m_MaterialCu, - "Strasse_Blades", 0, 0, 0); - - m_Blades->SetVisAttributes(BladeVisAtt); - } - return m_Blades; +G4LogicalVolume* Strasse::BuildBlades(string path) { + if (!m_Blades) { + auto mesh = CADMesh::TessellatedMesh::FromSTL((char*)path.c_str()); + mesh->SetScale(mm); + // mesh->SetOffset(offset); + mesh->SetReverse(false); + + auto cad_solid = mesh->GetSolid(); + m_Blades = new G4LogicalVolume(cad_solid, m_MaterialCu, "Strasse_Blades", 0, 0, 0); + + m_Blades->SetVisAttributes(BladeVisAtt); + } + return m_Blades; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -G4LogicalVolume* Strasse::BuildStars(string path){ - if(!m_Stars){ - auto mesh = CADMesh::TessellatedMesh::FromSTL((char*) path.c_str()); - mesh->SetScale(mm); - //mesh->SetOffset(offset); - mesh->SetReverse(false); - - auto cad_solid = mesh->GetSolid(); - m_Stars = new G4LogicalVolume(cad_solid, - m_MaterialAl, - "Strasse_Stars", 0, 0, 0); - - m_Stars->SetVisAttributes(StarsVisAtt); - } - return m_Stars; +G4LogicalVolume* Strasse::BuildStars(string path) { + if (!m_Stars) { + auto mesh = CADMesh::TessellatedMesh::FromSTL((char*)path.c_str()); + mesh->SetScale(mm); + // mesh->SetOffset(offset); + mesh->SetReverse(false); + + auto cad_solid = mesh->GetSolid(); + m_Stars = new G4LogicalVolume(cad_solid, m_MaterialAl, "Strasse_Stars", 0, 0, 0); + + m_Stars->SetVisAttributes(StarsVisAtt); + } + return m_Stars; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -G4LogicalVolume* Strasse::BuildBase(string path){ - if(!m_Base){ - auto mesh = CADMesh::TessellatedMesh::FromSTL((char*) path.c_str()); - mesh->SetScale(mm); - //mesh->SetOffset(offset); - mesh->SetReverse(false); - - auto cad_solid = mesh->GetSolid(); - m_Base = new G4LogicalVolume(cad_solid, - m_MaterialAl, - "Strasse_Base", 0, 0, 0); - - m_Base->SetVisAttributes(StarsVisAtt); - } - return m_Base; +G4LogicalVolume* Strasse::BuildBase(string path) { + if (!m_Base) { + auto mesh = CADMesh::TessellatedMesh::FromSTL((char*)path.c_str()); + mesh->SetScale(mm); + // mesh->SetOffset(offset); + mesh->SetReverse(false); + + auto cad_solid = mesh->GetSolid(); + m_Base = new G4LogicalVolume(cad_solid, m_MaterialAl, "Strasse_Base", 0, 0, 0); + + m_Base->SetVisAttributes(StarsVisAtt); + } + return m_Base; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... @@ -783,460 +680,432 @@ G4LogicalVolume* Strasse::BuildBase(string path){ // Read stream at Configfile to pick-up parameters of detector (Position,...) // Called in DetecorConstruction::ReadDetextorConfiguration Method -void Strasse::ReadConfiguration(NPL::InputParser parser){ +void Strasse::ReadConfiguration(NPL::InputParser parser) { // Info block - vector<NPL::InputBlock*> blocks_info = parser.GetAllBlocksWithTokenAndValue("Strasse","Info"); - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << "//// " << blocks_info.size() << " info block founds " << endl; + vector<NPL::InputBlock*> blocks_info = parser.GetAllBlocksWithTokenAndValue("Strasse", "Info"); + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks_info.size() << " info block founds " << endl; - if(blocks_info.size()>1){ - cout << "ERROR: can only accepte one info block, " << blocks_info.size() << " info block founds." << endl; - exit(1); + if (blocks_info.size() > 1) { + cout << "ERROR: can only accepte one info block, " << blocks_info.size() << " info block founds." << endl; + exit(1); } - vector<string> info = { - "Inner_Wafer_Length", - "Inner_Wafer_Width", - "Inner_Wafer_Thickness", - "Inner_Wafer_AlThickness", - "Inner_Wafer_PADExternal", - "Inner_Wafer_PADInternal", - "Inner_Wafer_GuardRing", - "Inner_PCB_PortWidth", - "Inner_PCB_StarboardWidth", - "Inner_PCB_BevelAngle", - "Inner_PCB_UpstreamWidth", - "Inner_PCB_DownstreamWidth", - "Inner_PCB_MidWidth", - "Inner_PCB_Thickness", - "Inner_PCB_Ledge", - "Inner_PCB_Step", - "Inner_Wafer_TransverseStrips", - "Inner_Wafer_LongitudinalStrips", - "Outer_Wafer_Length", - "Outer_Wafer_Width", - "Outer_Wafer_Thickness", - "Outer_Wafer_AlThickness", - "Outer_Wafer_PADExternal", - "Outer_Wafer_PADInternal", - "Outer_Wafer_GuardRing", - "Outer_PCB_PortWidth", - "Outer_PCB_StarboardWidth", - "Outer_PCB_BevelAngle", - "Outer_PCB_UpstreamWidth", - "Outer_PCB_DownstreamWidth", - "Outer_PCB_MidWidth", - "Outer_PCB_Thickness", - "Outer_PCB_Ledge", - "Outer_PCB_Step", - "Outer_Wafer_TransverseStrips", - "Outer_Wafer_LongitudinalStrips", - "Chamber_Thickness", - "Chamber_Cylinder_Length", - "Chamber_Radius", - "Chamber_ExitTube_Radius", - "Chamber_ExitTube_Length", - "Chamber_Flange_Inner_Radius", - "Chamber_Sphere_Radius", - "Chamber_Sphere_Shift" - }; - - if(blocks_info[0]->HasTokenList(info)){ - cout << endl << "//// Strasse info block" << endl; - Inner_Wafer_Length = blocks_info[0]->GetDouble("Inner_Wafer_Length","mm"); - Inner_Wafer_Width = blocks_info[0]->GetDouble("Inner_Wafer_Width","mm"); - Inner_Wafer_Thickness = blocks_info[0]->GetDouble("Inner_Wafer_Thickness","micrometer"); - Inner_Wafer_AlThickness = blocks_info[0]->GetDouble("Inner_Wafer_AlThickness","micrometer"); - Inner_Wafer_PADExternal = blocks_info[0]->GetDouble("Inner_Wafer_PADExternal","mm"); - Inner_Wafer_PADInternal = blocks_info[0]->GetDouble("Inner_Wafer_PADInternal","mm"); - Inner_Wafer_GuardRing = blocks_info[0]->GetDouble("Inner_Wafer_GuardRing","mm"); - Inner_Wafer_TransverseStrips = blocks_info[0]->GetInt("Inner_Wafer_TransverseStrips"); - Inner_Wafer_LongitudinalStrips = blocks_info[0]->GetInt("Inner_Wafer_LongitudinalStrips"); - Inner_PCB_PortWidth = blocks_info[0]->GetDouble("Inner_PCB_PortWidth","mm"); - Inner_PCB_StarboardWidth = blocks_info[0]->GetDouble("Inner_PCB_StarboardWidth","mm"); - Inner_PCB_BevelAngle = blocks_info[0]->GetDouble("Inner_PCB_BevelAngle","mm"); - Inner_PCB_UpstreamWidth = blocks_info[0]->GetDouble("Inner_PCB_UpstreamWidth","mm"); - Inner_PCB_DownstreamWidth = blocks_info[0]->GetDouble("Inner_PCB_DownstreamWidth","mm"); - Inner_PCB_MidWidth = blocks_info[0]->GetDouble("Inner_PCB_MidWidth","mm"); - Inner_PCB_Thickness = blocks_info[0]->GetDouble("Inner_PCB_Thickness","mm"); - Inner_PCB_Ledge = blocks_info[0]->GetDouble("Inner_PCB_Ledge","mm"); - Inner_PCB_Step = blocks_info[0]->GetDouble("Inner_PCB_Step","mm"); - Outer_Wafer_Length = blocks_info[0]->GetDouble("Outer_Wafer_Length","mm"); - Outer_Wafer_Width = blocks_info[0]->GetDouble("Outer_Wafer_Width","mm"); - Outer_Wafer_Thickness = blocks_info[0]->GetDouble("Outer_Wafer_Thickness","mm"); - Outer_Wafer_AlThickness = blocks_info[0]->GetDouble("Outer_Wafer_AlThickness","micrometer"); - Outer_Wafer_PADExternal = blocks_info[0]->GetDouble("Outer_Wafer_PADExternal","mm"); - Outer_Wafer_PADInternal = blocks_info[0]->GetDouble("Outer_Wafer_PADInternal","mm"); - Outer_Wafer_GuardRing = blocks_info[0]->GetDouble("Outer_Wafer_GuardRing","mm"); - Outer_Wafer_TransverseStrips = blocks_info[0]->GetInt("Outer_Wafer_TransverseStrips"); - Outer_Wafer_LongitudinalStrips = blocks_info[0]->GetInt("Outer_Wafer_LongitudinalStrips"); - Outer_PCB_PortWidth = blocks_info[0]->GetDouble("Outer_PCB_PortWidth","mm"); - Outer_PCB_StarboardWidth = blocks_info[0]->GetDouble("Outer_PCB_StarboardWidth","mm"); - Outer_PCB_BevelAngle = blocks_info[0]->GetDouble("Outer_PCB_BevelAngle","deg"); - Outer_PCB_UpstreamWidth = blocks_info[0]->GetDouble("Outer_PCB_UpstreamWidth","mm"); - Outer_PCB_DownstreamWidth = blocks_info[0]->GetDouble("Outer_PCB_DownstreamWidth","mm"); - Outer_PCB_MidWidth = blocks_info[0]->GetDouble("Outer_PCB_MidWidth","mm"); - Outer_PCB_Thickness = blocks_info[0]->GetDouble("Outer_PCB_Thickness","mm"); - Outer_PCB_Ledge = blocks_info[0]->GetDouble("Outer_PCB_Ledge","mm"); - Outer_PCB_Step = blocks_info[0]->GetDouble("Outer_PCB_Step","mm"); - Chamber_Thickness= blocks_info[0]->GetDouble("Chamber_Thickness","mm"); - Chamber_Cylinder_Length= blocks_info[0]->GetDouble("Chamber_Cylinder_Length","mm"); - Chamber_Radius= blocks_info[0]->GetDouble("Chamber_Radius","mm"); - Chamber_ExitTube_Radius=blocks_info[0]->GetDouble("Chamber_ExitTube_Radius","mm"); - Chamber_ExitTube_Length=blocks_info[0]->GetDouble("Chamber_ExitTube_Length","mm"); - Chamber_Flange_Inner_Radius=blocks_info[0]->GetDouble("Chamber_Flange_Inner_Radius","mm"); - Chamber_Sphere_Radius=blocks_info[0]->GetDouble("Chamber_Sphere_Radius","mm"); - Chamber_Sphere_Shift=blocks_info[0]->GetDouble("Chamber_Sphere_Shift","mm"); + vector<string> info = {"Inner_Wafer_Length", + "Inner_Wafer_Width", + "Inner_Wafer_Thickness", + "Inner_Wafer_AlThickness", + "Inner_Wafer_PADExternal", + "Inner_Wafer_PADInternal", + "Inner_Wafer_GuardRing", + "Inner_PCB_PortWidth", + "Inner_PCB_StarboardWidth", + "Inner_PCB_BevelAngle", + "Inner_PCB_UpstreamWidth", + "Inner_PCB_DownstreamWidth", + "Inner_PCB_MidWidth", + "Inner_PCB_Thickness", + "Inner_PCB_Ledge", + "Inner_PCB_Step", + "Inner_Wafer_TransverseStrips", + "Inner_Wafer_LongitudinalStrips", + "Outer_Wafer_Length", + "Outer_Wafer_Width", + "Outer_Wafer_Thickness", + "Outer_Wafer_AlThickness", + "Outer_Wafer_PADExternal", + "Outer_Wafer_PADInternal", + "Outer_Wafer_GuardRing", + "Outer_PCB_PortWidth", + "Outer_PCB_StarboardWidth", + "Outer_PCB_BevelAngle", + "Outer_PCB_UpstreamWidth", + "Outer_PCB_DownstreamWidth", + "Outer_PCB_MidWidth", + "Outer_PCB_Thickness", + "Outer_PCB_Ledge", + "Outer_PCB_Step", + "Outer_Wafer_TransverseStrips", + "Outer_Wafer_LongitudinalStrips", + "Chamber_Thickness", + "Chamber_Cylinder_Length", + "Chamber_Radius", + "Chamber_ExitTube_Radius", + "Chamber_ExitTube_Length", + "Chamber_Flange_Inner_Radius", + "Chamber_Sphere_Radius", + "Chamber_Sphere_Shift"}; + + if (blocks_info[0]->HasTokenList(info)) { + cout << endl << "//// Strasse info block" << endl; + Inner_Wafer_Length = blocks_info[0]->GetDouble("Inner_Wafer_Length", "mm"); + Inner_Wafer_Width = blocks_info[0]->GetDouble("Inner_Wafer_Width", "mm"); + Inner_Wafer_Thickness = blocks_info[0]->GetDouble("Inner_Wafer_Thickness", "micrometer"); + Inner_Wafer_AlThickness = blocks_info[0]->GetDouble("Inner_Wafer_AlThickness", "micrometer"); + Inner_Wafer_PADExternal = blocks_info[0]->GetDouble("Inner_Wafer_PADExternal", "mm"); + Inner_Wafer_PADInternal = blocks_info[0]->GetDouble("Inner_Wafer_PADInternal", "mm"); + Inner_Wafer_GuardRing = blocks_info[0]->GetDouble("Inner_Wafer_GuardRing", "mm"); + Inner_Wafer_TransverseStrips = blocks_info[0]->GetInt("Inner_Wafer_TransverseStrips"); + Inner_Wafer_LongitudinalStrips = blocks_info[0]->GetInt("Inner_Wafer_LongitudinalStrips"); + Inner_PCB_PortWidth = blocks_info[0]->GetDouble("Inner_PCB_PortWidth", "mm"); + Inner_PCB_StarboardWidth = blocks_info[0]->GetDouble("Inner_PCB_StarboardWidth", "mm"); + Inner_PCB_BevelAngle = blocks_info[0]->GetDouble("Inner_PCB_BevelAngle", "mm"); + Inner_PCB_UpstreamWidth = blocks_info[0]->GetDouble("Inner_PCB_UpstreamWidth", "mm"); + Inner_PCB_DownstreamWidth = blocks_info[0]->GetDouble("Inner_PCB_DownstreamWidth", "mm"); + Inner_PCB_MidWidth = blocks_info[0]->GetDouble("Inner_PCB_MidWidth", "mm"); + Inner_PCB_Thickness = blocks_info[0]->GetDouble("Inner_PCB_Thickness", "mm"); + Inner_PCB_Ledge = blocks_info[0]->GetDouble("Inner_PCB_Ledge", "mm"); + Inner_PCB_Step = blocks_info[0]->GetDouble("Inner_PCB_Step", "mm"); + Outer_Wafer_Length = blocks_info[0]->GetDouble("Outer_Wafer_Length", "mm"); + Outer_Wafer_Width = blocks_info[0]->GetDouble("Outer_Wafer_Width", "mm"); + Outer_Wafer_Thickness = blocks_info[0]->GetDouble("Outer_Wafer_Thickness", "mm"); + Outer_Wafer_AlThickness = blocks_info[0]->GetDouble("Outer_Wafer_AlThickness", "micrometer"); + Outer_Wafer_PADExternal = blocks_info[0]->GetDouble("Outer_Wafer_PADExternal", "mm"); + Outer_Wafer_PADInternal = blocks_info[0]->GetDouble("Outer_Wafer_PADInternal", "mm"); + Outer_Wafer_GuardRing = blocks_info[0]->GetDouble("Outer_Wafer_GuardRing", "mm"); + Outer_Wafer_TransverseStrips = blocks_info[0]->GetInt("Outer_Wafer_TransverseStrips"); + Outer_Wafer_LongitudinalStrips = blocks_info[0]->GetInt("Outer_Wafer_LongitudinalStrips"); + Outer_PCB_PortWidth = blocks_info[0]->GetDouble("Outer_PCB_PortWidth", "mm"); + Outer_PCB_StarboardWidth = blocks_info[0]->GetDouble("Outer_PCB_StarboardWidth", "mm"); + Outer_PCB_BevelAngle = blocks_info[0]->GetDouble("Outer_PCB_BevelAngle", "deg"); + Outer_PCB_UpstreamWidth = blocks_info[0]->GetDouble("Outer_PCB_UpstreamWidth", "mm"); + Outer_PCB_DownstreamWidth = blocks_info[0]->GetDouble("Outer_PCB_DownstreamWidth", "mm"); + Outer_PCB_MidWidth = blocks_info[0]->GetDouble("Outer_PCB_MidWidth", "mm"); + Outer_PCB_Thickness = blocks_info[0]->GetDouble("Outer_PCB_Thickness", "mm"); + Outer_PCB_Ledge = blocks_info[0]->GetDouble("Outer_PCB_Ledge", "mm"); + Outer_PCB_Step = blocks_info[0]->GetDouble("Outer_PCB_Step", "mm"); + Chamber_Thickness = blocks_info[0]->GetDouble("Chamber_Thickness", "mm"); + Chamber_Cylinder_Length = blocks_info[0]->GetDouble("Chamber_Cylinder_Length", "mm"); + Chamber_Radius = blocks_info[0]->GetDouble("Chamber_Radius", "mm"); + Chamber_ExitTube_Radius = blocks_info[0]->GetDouble("Chamber_ExitTube_Radius", "mm"); + Chamber_ExitTube_Length = blocks_info[0]->GetDouble("Chamber_ExitTube_Length", "mm"); + Chamber_Flange_Inner_Radius = blocks_info[0]->GetDouble("Chamber_Flange_Inner_Radius", "mm"); + Chamber_Sphere_Radius = blocks_info[0]->GetDouble("Chamber_Sphere_Radius", "mm"); + Chamber_Sphere_Shift = blocks_info[0]->GetDouble("Chamber_Sphere_Shift", "mm"); } - else{ + else { cout << "ERROR: check your input file formatting " << endl; exit(1); } - // Inner Barrel - vector<NPL::InputBlock*> blocks_inner = parser.GetAllBlocksWithTokenAndValue("Strasse","Inner"); - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << "//// " << blocks_inner.size() << " inner detectors found " << endl; - - vector<string> coord = {"Radius","Z","Phi","Shift","Ref"}; - - for(unsigned int i = 0 ; i < blocks_inner.size() ; i++){ - if(blocks_inner[i]->HasTokenList(coord)){ - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << endl << "//// Strasse inner detector" << i+1 << endl; - - double R = blocks_inner[i]->GetDouble("Radius","mm"); - double Z= blocks_inner[i]->GetDouble("Z","mm"); - double Phi = blocks_inner[i]->GetDouble("Phi","deg"); - double Shift = blocks_inner[i]->GetDouble("Shift","mm"); - G4ThreeVector Ref = NPS::ConvertVector(blocks_inner[i]->GetTVector3("Ref","mm")); - AddInnerDetector(R,Z,Phi,Shift,Ref); + vector<NPL::InputBlock*> blocks_inner = parser.GetAllBlocksWithTokenAndValue("Strasse", "Inner"); + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks_inner.size() << " inner detectors found " << endl; + + vector<string> coord = {"Radius", "Z", "Phi", "Shift", "Ref"}; + + for (unsigned int i = 0; i < blocks_inner.size(); i++) { + if (blocks_inner[i]->HasTokenList(coord)) { + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// Strasse inner detector" << i + 1 << endl; + + double R = blocks_inner[i]->GetDouble("Radius", "mm"); + double Z = blocks_inner[i]->GetDouble("Z", "mm"); + double Phi = blocks_inner[i]->GetDouble("Phi", "deg"); + double Shift = blocks_inner[i]->GetDouble("Shift", "mm"); + G4ThreeVector Ref = NPS::ConvertVector(blocks_inner[i]->GetTVector3("Ref", "mm")); + AddInnerDetector(R, Z, Phi, Shift, Ref); } - else{ - cout << "ERROR: check your input file formatting on " << i+1 << " inner block " <<endl; + else { + cout << "ERROR: check your input file formatting on " << i + 1 << " inner block " << endl; exit(1); } } // Outer barrel - vector<NPL::InputBlock*> blocks_outer = parser.GetAllBlocksWithTokenAndValue("Strasse","Outer"); - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << "//// " << blocks_outer.size() << " outer detectors found " << endl; - - for(unsigned int i = 0 ; i < blocks_outer.size() ; i++){ - if(blocks_outer[i]->HasTokenList(coord)){ - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << endl << "//// Strasse outer detector" << i+1 << endl; - - double R = blocks_outer[i]->GetDouble("Radius","mm"); - double Z= blocks_outer[i]->GetDouble("Z","mm"); - double Phi = blocks_outer[i]->GetDouble("Phi","deg"); - double Shift = blocks_outer[i]->GetDouble("Shift","mm"); - G4ThreeVector Ref = NPS::ConvertVector(blocks_inner[i]->GetTVector3("Ref","mm")); - AddOuterDetector(R,Z,Phi,Shift,Ref); + vector<NPL::InputBlock*> blocks_outer = parser.GetAllBlocksWithTokenAndValue("Strasse", "Outer"); + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks_outer.size() << " outer detectors found " << endl; + + for (unsigned int i = 0; i < blocks_outer.size(); i++) { + if (blocks_outer[i]->HasTokenList(coord)) { + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// Strasse outer detector" << i + 1 << endl; + + double R = blocks_outer[i]->GetDouble("Radius", "mm"); + double Z = blocks_outer[i]->GetDouble("Z", "mm"); + double Phi = blocks_outer[i]->GetDouble("Phi", "deg"); + double Shift = blocks_outer[i]->GetDouble("Shift", "mm"); + G4ThreeVector Ref = NPS::ConvertVector(blocks_inner[i]->GetTVector3("Ref", "mm")); + AddOuterDetector(R, Z, Phi, Shift, Ref); } - else{ + else { - cout << "ERROR: check your input file formatting on " << i+1 << " outer block " <<endl; + cout << "ERROR: check your input file formatting on " << i + 1 << " outer block " << endl; exit(1); } } // Chamber vector<std::string> token = {"Z"}; - vector<NPL::InputBlock*> blocks_chamber = parser.GetAllBlocksWithTokenAndValue("Strasse","Chamber"); - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << "//// " << blocks_chamber.size() << " chamber detectors found " << endl; + vector<NPL::InputBlock*> blocks_chamber = parser.GetAllBlocksWithTokenAndValue("Strasse", "Chamber"); + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks_chamber.size() << " chamber detectors found " << endl; - for(unsigned int i = 0 ; i < blocks_chamber.size() ; i++){ - if(blocks_chamber[i]->HasTokenList(token)){ - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << endl << "//// Strasse chamber detector" << i+1 << endl; + for (unsigned int i = 0; i < blocks_chamber.size(); i++) { + if (blocks_chamber[i]->HasTokenList(token)) { + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// Strasse chamber detector" << i + 1 << endl; - double Z= blocks_chamber[i]->GetDouble("Z","mm"); + double Z = blocks_chamber[i]->GetDouble("Z", "mm"); AddChamber(Z); } - else{ + else { - cout << "ERROR: check your input file formatting on " << i+1 << " chamber block " <<endl; + cout << "ERROR: check your input file formatting on " << i + 1 << " chamber block " << endl; exit(1); } } - // Inactive material inside chamber imported form CAD drawings - vector<NPL::InputBlock*> blocks_material = parser.GetAllBlocksWithTokenAndValue("Strasse","InactiveMaterial"); - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << "//// " << blocks_material.size() << " inactive material found " << endl; - - for(unsigned int i = 0 ; i < blocks_material.size() ; i++){ - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << endl << "//// Strasse Inactive material from CAD " << i+1 << endl; - - if(blocks_material[i]->HasToken("Chamber")){ - ChamberPath= blocks_material[i]->GetString("Chamber"); - found_chamber = true; - } - if(blocks_material[i]->HasToken("Stars")){ - StarsPath= blocks_material[i]->GetString("Stars"); - found_stars = true; - } - if(blocks_material[i]->HasToken("Blades")){ - BladesPath= blocks_material[i]->GetString("Blades"); - found_blades = true; - } - if(blocks_material[i]->HasToken("Base")){ - BasePath= blocks_material[i]->GetString("Base"); - found_base = true; - } + vector<NPL::InputBlock*> blocks_material = parser.GetAllBlocksWithTokenAndValue("Strasse", "InactiveMaterial"); + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks_material.size() << " inactive material found " << endl; + + for (unsigned int i = 0; i < blocks_material.size(); i++) { + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// Strasse Inactive material from CAD " << i + 1 << endl; + + if (blocks_material[i]->HasToken("Chamber")) { + ChamberPath = blocks_material[i]->GetString("Chamber"); + found_chamber = true; + } + if (blocks_material[i]->HasToken("Stars")) { + StarsPath = blocks_material[i]->GetString("Stars"); + found_stars = true; + } + if (blocks_material[i]->HasToken("Blades")) { + BladesPath = blocks_material[i]->GetString("Blades"); + found_blades = true; + } + if (blocks_material[i]->HasToken("Base")) { + BasePath = blocks_material[i]->GetString("Base"); + found_base = true; + } } } - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Construct detector and inialise sensitive part. // Called After DetecorConstruction::AddDetector Method -void Strasse::ConstructDetector(G4LogicalVolume* world){ +void Strasse::ConstructDetector(G4LogicalVolume* world) { // Inner Barrel - for (unsigned short i = 0 ; i < m_Inner_R.size() ; i++) { - G4ThreeVector Det_pos = G4ThreeVector(m_Inner_Shift[i],m_Inner_R[i]+0.5*Inner_PCB_Thickness+0.001,m_Inner_Z[i]) ; //0.001 offset just to avoid overlap with frame - Det_pos.rotate(-m_Inner_Phi[i],G4ThreeVector(0,0,1)); - G4RotationMatrix* Rot = new G4RotationMatrix(0*deg,0*deg,m_Inner_Phi[i]); - - new G4PVPlacement(G4Transform3D(*Rot,Det_pos+m_Inner_Ref[i]), - BuildInnerDetector(), - "Strasse",world,false,i+1); + for (unsigned short i = 0; i < m_Inner_R.size(); i++) { + G4ThreeVector Det_pos = G4ThreeVector(m_Inner_Shift[i], m_Inner_R[i] + 0.5 * Inner_PCB_Thickness + 0.001, + m_Inner_Z[i]); // 0.001 offset just to avoid overlap with frame + Det_pos.rotate(-m_Inner_Phi[i], G4ThreeVector(0, 0, 1)); + G4RotationMatrix* Rot = new G4RotationMatrix(0 * deg, 0 * deg, m_Inner_Phi[i]); + + new G4PVPlacement(G4Transform3D(*Rot, Det_pos + m_Inner_Ref[i]), BuildInnerDetector(), "Strasse", world, false, + i + 1); + } + + // Outer Barrel + for (unsigned short i = 0; i < m_Outer_R.size(); i++) { + G4ThreeVector Det_pos = G4ThreeVector(m_Outer_Shift[i], m_Outer_R[i] + 0.5 * Inner_PCB_Thickness + 0.001, + m_Outer_Z[i]); // 0.001 offset just to avoid overlap with frame + Det_pos.rotate(-m_Outer_Phi[i], G4ThreeVector(0, 0, 1)); + G4RotationMatrix* Rot = new G4RotationMatrix(0 * deg, 0 * deg, m_Outer_Phi[i]); + + new G4PVPlacement(G4Transform3D(*Rot, Det_pos + m_Outer_Ref[i]), BuildOuterDetector(), "Strasse", world, false, + i + 1); } - // Outer Barrel - for (unsigned short i = 0 ; i < m_Outer_R.size() ; i++) { - G4ThreeVector Det_pos = G4ThreeVector(m_Outer_Shift[i],m_Outer_R[i]+0.5*Inner_PCB_Thickness+0.001,m_Outer_Z[i]) ;//0.001 offset just to avoid overlap with frame - Det_pos.rotate(-m_Outer_Phi[i],G4ThreeVector(0,0,1)); - G4RotationMatrix* Rot = new G4RotationMatrix(0*deg,0*deg,m_Outer_Phi[i]); + // Chamber + + for (unsigned short i = 0; i < m_Chamber_Z.size(); i++) { + G4ThreeVector Det_pos = G4ThreeVector(0, 0, -m_Chamber_Z[i]); + G4RotationMatrix* Rot = new G4RotationMatrix(); - new G4PVPlacement(G4Transform3D(*Rot,Det_pos+m_Outer_Ref[i]), - BuildOuterDetector(), - "Strasse",world,false,i+1); + new G4PVPlacement(G4Transform3D(*Rot, Det_pos), BuildChamber(), "Strasse", world, false, i + 1); } - // Chamber - - for (unsigned short i = 0 ; i < m_Chamber_Z.size() ; i++) { - G4ThreeVector Det_pos = G4ThreeVector(0,0,-m_Chamber_Z[i]) ; - G4RotationMatrix* Rot = new G4RotationMatrix(); + // G4ThreeVector Det_pos = G4ThreeVector(0,0,+11.5) ; + G4ThreeVector Det_pos = G4ThreeVector(0, 0, 0); + G4RotationMatrix* Rot = new G4RotationMatrix(); + Rot->rotateY(270. * deg); + Rot->rotateX(0. * deg); - new G4PVPlacement(G4Transform3D(*Rot,Det_pos), - BuildChamber(), - "Strasse",world,false,i+1); + if (found_chamber) { + new G4PVPlacement(Rot, Det_pos, BuildChamberFromCAD(ChamberPath), "Strasse_Chamber", world, false, 0); } - - - - //G4ThreeVector Det_pos = G4ThreeVector(0,0,+11.5) ; - G4ThreeVector Det_pos = G4ThreeVector(0,0,0) ; - G4RotationMatrix* Rot = new G4RotationMatrix(); - Rot->rotateY(270.*deg); - Rot->rotateX(0.*deg); - - if(found_chamber){ - new G4PVPlacement(Rot, Det_pos, BuildChamberFromCAD(ChamberPath), - "Strasse_Chamber",world, false, 0); - } - - if(found_blades){ - new G4PVPlacement(Rot, Det_pos, BuildBlades(BladesPath), - "Strasse_Blades",world, false, 0); - } - if(found_stars){ - G4ThreeVector Det_pos2 = G4ThreeVector(0,0,0) ; - new G4PVPlacement(Rot, Det_pos2, BuildStars(StarsPath), - "Strasse_Stars",world, false, 0); - } - if(found_base){ - G4ThreeVector Det_pos3 = G4ThreeVector(0,0,0) ; - new G4PVPlacement(Rot, Det_pos3, BuildBase(BasePath), - "Strasse_Base",world, false, 0); - } + if (found_blades) { + new G4PVPlacement(Rot, Det_pos, BuildBlades(BladesPath), "Strasse_Blades", world, false, 0); + } + if (found_stars) { + G4ThreeVector Det_pos2 = G4ThreeVector(0, 0, 0); + new G4PVPlacement(Rot, Det_pos2, BuildStars(StarsPath), "Strasse_Stars", world, false, 0); + } + if (found_base) { + G4ThreeVector Det_pos3 = G4ThreeVector(0, 0, 0); + new G4PVPlacement(Rot, Det_pos3, BuildBase(BasePath), "Strasse_Base", world, false, 0); + } } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Add Detector branch to the EventTree. // Called After DetecorConstruction::AddDetector Method -void Strasse::InitializeRootOutput(){ - RootOutput *pAnalysis = RootOutput::getInstance(); - TTree *pTree = pAnalysis->GetTree(); - if(!pTree->FindBranch("Strasse")){ - pTree->Branch("Strasse", "TStrasseData", &m_Event) ; +void Strasse::InitializeRootOutput() { + RootOutput* pAnalysis = RootOutput::getInstance(); + TTree* pTree = pAnalysis->GetTree(); + if (!pTree->FindBranch("Strasse")) { + pTree->Branch("Strasse", "TStrasseData", &m_Event); } - pTree->SetBranchAddress("Strasse", &m_Event) ; + pTree->SetBranchAddress("Strasse", &m_Event); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Read sensitive part and fill the Root tree. // Called at in the EventAction::EndOfEventAvtion -void Strasse::ReadSensitive(const G4Event* ){ +void Strasse::ReadSensitive(const G4Event*) { m_Event->Clear(); /////////// // Inner barrel scorer - DSSDScorers::PS_Rectangle* InnerScorer1= (DSSDScorers::PS_Rectangle*) m_InnerScorer1->GetPrimitive(0); + DSSDScorers::PS_Rectangle* InnerScorer1 = (DSSDScorers::PS_Rectangle*)m_InnerScorer1->GetPrimitive(0); - unsigned int size = InnerScorer1->GetWidthMult(); - for(unsigned int i = 0 ; i < size; i++){ - double Energy = RandGauss::shoot(InnerScorer1->GetEnergyWidth(i), ResoEnergy); - if(Energy>EnergyThreshold){ - int DetNbr = InnerScorer1->GetDetectorWidth(i); + unsigned int size = InnerScorer1->GetWidthMult(); + for (unsigned int i = 0; i < size; i++) { + double Energy = RandGauss::shoot(InnerScorer1->GetEnergyWidth(i), ResoEnergy); + if (Energy > EnergyThreshold) { + int DetNbr = InnerScorer1->GetDetectorWidth(i); int StripTransverse = InnerScorer1->GetStripWidth(i); m_Event->SetInnerTE(DetNbr, StripTransverse, Energy); } } - size = InnerScorer1->GetLengthMult(); - for(unsigned int i = 0 ; i < size ; i++){ - double Energy = RandGauss::shoot(InnerScorer1->GetEnergyLength(i), ResoEnergy); - if(Energy>EnergyThreshold){ - int DetNbr = InnerScorer1->GetDetectorLength(i); - int StripLongitudinal= InnerScorer1->GetStripLength(i); + size = InnerScorer1->GetLengthMult(); + for (unsigned int i = 0; i < size; i++) { + double Energy = RandGauss::shoot(InnerScorer1->GetEnergyLength(i), ResoEnergy); + if (Energy > EnergyThreshold) { + int DetNbr = InnerScorer1->GetDetectorLength(i); + int StripLongitudinal = InnerScorer1->GetStripLength(i); m_Event->SetInnerLE(DetNbr, StripLongitudinal, Energy); } } InnerScorer1->clear(); // second silicon - DSSDScorers::PS_Rectangle* InnerScorer2= (DSSDScorers::PS_Rectangle*) m_InnerScorer2->GetPrimitive(0); - - size = InnerScorer2->GetWidthMult(); - for(unsigned int i = 0 ; i < size; i++){ - double Energy = RandGauss::shoot(InnerScorer2->GetEnergyWidth(i), ResoEnergy); - if(Energy>EnergyThreshold){ - int DetNbr = InnerScorer2->GetDetectorWidth(i); - int StripTransverse = InnerScorer2->GetStripWidth(i)+Inner_Wafer_TransverseStrips; + DSSDScorers::PS_Rectangle* InnerScorer2 = (DSSDScorers::PS_Rectangle*)m_InnerScorer2->GetPrimitive(0); + + size = InnerScorer2->GetWidthMult(); + for (unsigned int i = 0; i < size; i++) { + double Energy = RandGauss::shoot(InnerScorer2->GetEnergyWidth(i), ResoEnergy); + if (Energy > EnergyThreshold) { + int DetNbr = InnerScorer2->GetDetectorWidth(i); + int StripTransverse = InnerScorer2->GetStripWidth(i) + Inner_Wafer_TransverseStrips; m_Event->SetInnerTE(DetNbr, StripTransverse, Energy); } } - size = InnerScorer2->GetLengthMult(); - for(unsigned int i = 0 ; i < size ; i++){ - double Energy = RandGauss::shoot(InnerScorer2->GetEnergyLength(i), ResoEnergy); - if(Energy>EnergyThreshold){ - int DetNbr = InnerScorer2->GetDetectorLength(i); - int StripLongitudinal= InnerScorer2->GetStripLength(i); + size = InnerScorer2->GetLengthMult(); + for (unsigned int i = 0; i < size; i++) { + double Energy = RandGauss::shoot(InnerScorer2->GetEnergyLength(i), ResoEnergy); + if (Energy > EnergyThreshold) { + int DetNbr = InnerScorer2->GetDetectorLength(i); + int StripLongitudinal = InnerScorer2->GetStripLength(i); m_Event->SetInnerLE(DetNbr, StripLongitudinal, Energy); } } InnerScorer2->clear(); - - /////////// // Outer barrel scorer - DSSDScorers::PS_Rectangle* OuterScorer1= (DSSDScorers::PS_Rectangle*) m_OuterScorer1->GetPrimitive(0); + DSSDScorers::PS_Rectangle* OuterScorer1 = (DSSDScorers::PS_Rectangle*)m_OuterScorer1->GetPrimitive(0); - size = OuterScorer1->GetWidthMult(); - for(unsigned int i = 0 ; i < size; i++){ - double Energy = RandGauss::shoot(OuterScorer1->GetEnergyWidth(i), ResoEnergy); - if(Energy>EnergyThreshold){ - int DetNbr = OuterScorer1->GetDetectorWidth(i); + size = OuterScorer1->GetWidthMult(); + for (unsigned int i = 0; i < size; i++) { + double Energy = RandGauss::shoot(OuterScorer1->GetEnergyWidth(i), ResoEnergy); + if (Energy > EnergyThreshold) { + int DetNbr = OuterScorer1->GetDetectorWidth(i); int StripTransverse = OuterScorer1->GetStripWidth(i); m_Event->SetOuterTE(DetNbr, StripTransverse, Energy); } } - size = OuterScorer1->GetLengthMult(); - for(unsigned int i = 0 ; i < size ; i++){ - double Energy = RandGauss::shoot(OuterScorer1->GetEnergyLength(i), ResoEnergy); - if(Energy>EnergyThreshold){ - int DetNbr = OuterScorer1->GetDetectorLength(i); - int StripLongitudinal= OuterScorer1->GetStripLength(i); + size = OuterScorer1->GetLengthMult(); + for (unsigned int i = 0; i < size; i++) { + double Energy = RandGauss::shoot(OuterScorer1->GetEnergyLength(i), ResoEnergy); + if (Energy > EnergyThreshold) { + int DetNbr = OuterScorer1->GetDetectorLength(i); + int StripLongitudinal = OuterScorer1->GetStripLength(i); m_Event->SetOuterLE(DetNbr, StripLongitudinal, Energy); } } OuterScorer1->clear(); // Second silicon - DSSDScorers::PS_Rectangle* OuterScorer2= (DSSDScorers::PS_Rectangle*) m_OuterScorer2->GetPrimitive(0); - - size = OuterScorer2->GetWidthMult(); - for(unsigned int i = 0 ; i < size; i++){ - double Energy = RandGauss::shoot(OuterScorer2->GetEnergyWidth(i), ResoEnergy); - if(Energy>EnergyThreshold){ - int DetNbr = OuterScorer2->GetDetectorWidth(i); - int StripTransverse = OuterScorer2->GetStripWidth(i)+Outer_Wafer_TransverseStrips; + DSSDScorers::PS_Rectangle* OuterScorer2 = (DSSDScorers::PS_Rectangle*)m_OuterScorer2->GetPrimitive(0); + + size = OuterScorer2->GetWidthMult(); + for (unsigned int i = 0; i < size; i++) { + double Energy = RandGauss::shoot(OuterScorer2->GetEnergyWidth(i), ResoEnergy); + if (Energy > EnergyThreshold) { + int DetNbr = OuterScorer2->GetDetectorWidth(i); + int StripTransverse = OuterScorer2->GetStripWidth(i) + Outer_Wafer_TransverseStrips; m_Event->SetOuterTE(DetNbr, StripTransverse, Energy); } } - size = OuterScorer2->GetLengthMult(); - for(unsigned int i = 0 ; i < size ; i++){ - double Energy = RandGauss::shoot(OuterScorer2->GetEnergyLength(i), ResoEnergy); - if(Energy>EnergyThreshold){ - int DetNbr = OuterScorer2->GetDetectorLength(i); - int StripLongitudinal= OuterScorer2->GetStripLength(i); + size = OuterScorer2->GetLengthMult(); + for (unsigned int i = 0; i < size; i++) { + double Energy = RandGauss::shoot(OuterScorer2->GetEnergyLength(i), ResoEnergy); + if (Energy > EnergyThreshold) { + int DetNbr = OuterScorer2->GetDetectorLength(i); + int StripLongitudinal = OuterScorer2->GetStripLength(i); m_Event->SetOuterLE(DetNbr, StripLongitudinal, Energy); } } OuterScorer2->clear(); - - } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -//////////////////////////////////////////////////////////////// -void Strasse::InitializeScorers() { +//////////////////////////////////////////////////////////////// +void Strasse::InitializeScorers() { // This check is necessary in case the geometry is reloaded - bool already_exist = false; - m_InnerScorer1 = CheckScorer("InnerScorer1",already_exist) ; - m_OuterScorer1 = CheckScorer("OuterScorer1",already_exist) ; - m_InnerScorer2 = CheckScorer("InnerScorer2",already_exist) ; - m_OuterScorer2 = CheckScorer("OuterScorer2",already_exist) ; + bool already_exist = false; + m_InnerScorer1 = CheckScorer("InnerScorer1", already_exist); + m_OuterScorer1 = CheckScorer("OuterScorer1", already_exist); + m_InnerScorer2 = CheckScorer("InnerScorer2", already_exist); + m_OuterScorer2 = CheckScorer("OuterScorer2", already_exist); - if(already_exist) - return ; + if (already_exist) + return; // Otherwise the scorer is initialised - m_Active_InnerWafer_Width= Inner_Wafer_Width-2.*Inner_Wafer_GuardRing; - m_Active_InnerWafer_Length= - Inner_Wafer_Length-Inner_Wafer_PADExternal-Inner_Wafer_PADInternal-2*Inner_Wafer_GuardRing; - - - G4VPrimitiveScorer* InnerScorer1 = new DSSDScorers::PS_Rectangle("InnerScorer1",2, - m_Active_InnerWafer_Width, - m_Active_InnerWafer_Length, - Inner_Wafer_LongitudinalStrips, - Inner_Wafer_TransverseStrips,0,"xz"); - - G4VPrimitiveScorer* InnerScorer2 = new DSSDScorers::PS_Rectangle("InnerScorer2",2, - m_Active_InnerWafer_Width, - m_Active_InnerWafer_Length, - Inner_Wafer_LongitudinalStrips, - Inner_Wafer_TransverseStrips,0,"xz"); - - - m_Active_OuterWafer_Width=Outer_Wafer_Width-2.*Outer_Wafer_GuardRing; - m_Active_OuterWafer_Length= - Outer_Wafer_Length-Outer_Wafer_PADExternal-Outer_Wafer_PADInternal-2*Outer_Wafer_GuardRing; - - - G4VPrimitiveScorer* OuterScorer1 = new DSSDScorers::PS_Rectangle("OuterScorer1",2, - m_Active_OuterWafer_Width, - m_Active_OuterWafer_Length, - Outer_Wafer_LongitudinalStrips, - Outer_Wafer_TransverseStrips,0,"xz"); - - G4VPrimitiveScorer* OuterScorer2 = new DSSDScorers::PS_Rectangle("OuterScorer2",2, - m_Active_OuterWafer_Width, - m_Active_OuterWafer_Length, - Outer_Wafer_LongitudinalStrips, - Outer_Wafer_TransverseStrips,0,"xz"); - - - - G4VPrimitiveScorer* InteractionInner1 = new InteractionScorers::PS_Interactions("InteractionInner1",ms_InterCoord,0); - G4VPrimitiveScorer* InteractionOuter1 = new InteractionScorers::PS_Interactions("InteractionOuter1",ms_InterCoord,0); - G4VPrimitiveScorer* InteractionInner2 = new InteractionScorers::PS_Interactions("InteractionInner2",ms_InterCoord,0); - G4VPrimitiveScorer* InteractionOuter2 = new InteractionScorers::PS_Interactions("InteractionOuter2",ms_InterCoord,0); - + m_Active_InnerWafer_Width = Inner_Wafer_Width - 2. * Inner_Wafer_GuardRing; + m_Active_InnerWafer_Length = + Inner_Wafer_Length - Inner_Wafer_PADExternal - Inner_Wafer_PADInternal - 2 * Inner_Wafer_GuardRing; + + G4VPrimitiveScorer* InnerScorer1 = + new DSSDScorers::PS_Rectangle("InnerScorer1", 2, m_Active_InnerWafer_Width, m_Active_InnerWafer_Length, + Inner_Wafer_LongitudinalStrips, Inner_Wafer_TransverseStrips, 0, "xz"); + + G4VPrimitiveScorer* InnerScorer2 = + new DSSDScorers::PS_Rectangle("InnerScorer2", 2, m_Active_InnerWafer_Width, m_Active_InnerWafer_Length, + Inner_Wafer_LongitudinalStrips, Inner_Wafer_TransverseStrips, 0, "xz"); + + m_Active_OuterWafer_Width = Outer_Wafer_Width - 2. * Outer_Wafer_GuardRing; + m_Active_OuterWafer_Length = + Outer_Wafer_Length - Outer_Wafer_PADExternal - Outer_Wafer_PADInternal - 2 * Outer_Wafer_GuardRing; + + G4VPrimitiveScorer* OuterScorer1 = + new DSSDScorers::PS_Rectangle("OuterScorer1", 2, m_Active_OuterWafer_Width, m_Active_OuterWafer_Length, + Outer_Wafer_LongitudinalStrips, Outer_Wafer_TransverseStrips, 0, "xz"); + + G4VPrimitiveScorer* OuterScorer2 = + new DSSDScorers::PS_Rectangle("OuterScorer2", 2, m_Active_OuterWafer_Width, m_Active_OuterWafer_Length, + Outer_Wafer_LongitudinalStrips, Outer_Wafer_TransverseStrips, 0, "xz"); + + G4VPrimitiveScorer* InteractionInner1 = + new InteractionScorers::PS_Interactions("InteractionInner1", ms_InterCoord, 0); + G4VPrimitiveScorer* InteractionOuter1 = + new InteractionScorers::PS_Interactions("InteractionOuter1", ms_InterCoord, 0); + G4VPrimitiveScorer* InteractionInner2 = + new InteractionScorers::PS_Interactions("InteractionInner2", ms_InterCoord, 0); + G4VPrimitiveScorer* InteractionOuter2 = + new InteractionScorers::PS_Interactions("InteractionOuter2", ms_InterCoord, 0); // Register it to the multifunctionnal detector m_InnerScorer1->RegisterPrimitive(InnerScorer1); @@ -1248,13 +1117,10 @@ void Strasse::InitializeScorers() { m_OuterScorer2->RegisterPrimitive(OuterScorer2); m_OuterScorer2->RegisterPrimitive(InteractionOuter2); - G4SDManager::GetSDMpointer()->AddNewDetector(m_InnerScorer1); G4SDManager::GetSDMpointer()->AddNewDetector(m_OuterScorer1); G4SDManager::GetSDMpointer()->AddNewDetector(m_InnerScorer2); G4SDManager::GetSDMpointer()->AddNewDetector(m_OuterScorer2); - - } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... @@ -1263,12 +1129,10 @@ void Strasse::InitializeScorers() { //////////////////////////////////////////////////////////////////////////////// // Construct Method to be pass to the DetectorFactory // //////////////////////////////////////////////////////////////////////////////// -NPS::VDetector* Strasse::Construct(){ - return (NPS::VDetector*) new Strasse(); -} +NPS::VDetector* Strasse::Construct() { return (NPS::VDetector*)new Strasse(); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Strasse::InitializeMaterial(){ +void Strasse::InitializeMaterial() { m_MaterialSilicon = MaterialManager::getInstance()->GetMaterialFromLibrary("Si"); m_MaterialAl = MaterialManager::getInstance()->GetMaterialFromLibrary("Al"); m_MaterialPCB = MaterialManager::getInstance()->GetMaterialFromLibrary("PCB"); @@ -1280,14 +1144,14 @@ void Strasse::InitializeMaterial(){ //////////////////////////////////////////////////////////////////////////////// // Registering the construct method to the factory // //////////////////////////////////////////////////////////////////////////////// -extern"C" { - class proxy_nps_Strasse{ - public: - proxy_nps_Strasse(){ - NPS::DetectorFactory::getInstance()->AddToken("Strasse","Strasse"); - NPS::DetectorFactory::getInstance()->AddDetector("Strasse",Strasse::Construct); - } - }; - - proxy_nps_Strasse p_nps_Strasse; +extern "C" { +class proxy_nps_Strasse { + public: + proxy_nps_Strasse() { + NPS::DetectorFactory::getInstance()->AddToken("Strasse", "Strasse"); + NPS::DetectorFactory::getInstance()->AddDetector("Strasse", Strasse::Construct); + } +}; + +proxy_nps_Strasse p_nps_Strasse; } diff --git a/NPSimulation/Detectors/SuperX3/CMakeLists.txt b/NPSimulation/Detectors/SuperX3/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..d7cfe0cfc519a0d30fd35315150de56015aaf586 --- /dev/null +++ b/NPSimulation/Detectors/SuperX3/CMakeLists.txt @@ -0,0 +1,2 @@ +add_library(NPSSuperX3 SHARED SuperX3.cc ) +target_link_libraries(NPSSuperX3 NPSCore ${ROOT_LIBRARIES} ${Geant4_LIBRARIES} NPSuperX3) diff --git a/NPSimulation/Detectors/SuperX3/SuperX3.cc b/NPSimulation/Detectors/SuperX3/SuperX3.cc new file mode 100644 index 0000000000000000000000000000000000000000..672e7b6f5577151bc2916303f8841875db1e702e --- /dev/null +++ b/NPSimulation/Detectors/SuperX3/SuperX3.cc @@ -0,0 +1,377 @@ +/***************************************************************************** + * 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: N. de Sereville contact address: deserevi@ipno.in2p3.fr * + * * + * Creation Date : 12/01/11 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: Define the SuperX3 detector from Micron * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ + +// C++ headers +#include <cmath> +#include <sstream> +#include <string> + +// G4 Geometry headers +#include "G4Box.hh" +#include "G4Tubs.hh" + +// G4 various headers +#include "G4Colour.hh" +#include "G4Material.hh" +#include "G4PVDivision.hh" +#include "G4PVPlacement.hh" +#include "G4RotationMatrix.hh" +#include "G4Transform3D.hh" +#include "G4VisAttributes.hh" + +// G4 sensitive +#include "G4MultiFunctionalDetector.hh" +#include "G4SDManager.hh" + +// NPTool headers +#include "DSSDScorers.hh" +#include "MaterialManager.hh" +#include "NPOptionManager.h" +#include "NPSDetectorFactory.hh" + +#include "InteractionScorers.hh" +#include "RootOutput.h" +#include "SuperX3.hh" +#include "TSuperX3Data.h" + +// CLHEP +#include "CLHEP/Random/RandGauss.h" + +using namespace std; +using namespace CLHEP; +using namespace SuperX3SQUARE; + +SuperX3::SuperX3() : m_Event(new TSuperX3Data) { InitializeMaterials(); } + +SuperX3::~SuperX3() { delete m_Event; } + +void SuperX3::AddDetector(G4ThreeVector X1_Y1, G4ThreeVector X16_Y1, G4ThreeVector X1_Y16, G4ThreeVector X16_Y16) { + m_DefinitionType.push_back(true); + + m_X1_Y1.push_back(X1_Y1); + m_X16_Y1.push_back(X16_Y1); + m_X1_Y16.push_back(X1_Y16); + m_X16_Y16.push_back(X16_Y16); + + m_R.push_back(0); + m_Theta.push_back(0); + m_Phi.push_back(0); + m_beta_u.push_back(0); + m_beta_v.push_back(0); + m_beta_w.push_back(0); +} + +void SuperX3::AddDetector(G4double R, G4double Theta, G4double Phi, G4double beta_u, G4double beta_v, G4double beta_w) { + G4ThreeVector empty = G4ThreeVector(0, 0, 0); + + m_DefinitionType.push_back(false); + + m_R.push_back(R); + m_Theta.push_back(Theta); + m_Phi.push_back(Phi); + m_beta_u.push_back(beta_u); + m_beta_v.push_back(beta_v); + m_beta_w.push_back(beta_w); + + m_X1_Y1.push_back(empty); + m_X16_Y1.push_back(empty); + m_X1_Y16.push_back(empty); + m_X16_Y16.push_back(empty); +} + +void SuperX3::VolumeMaker(G4int DetecNumber, G4ThreeVector position, G4RotationMatrix* rotation, + G4LogicalVolume* world) { + G4double NbrTelescopes = DetecNumber; + G4String DetectorNumber; + ostringstream Number; + Number << NbrTelescopes; + DetectorNumber = Number.str(); + + //////////////////////////////////////////////////////////////// + ////////////// Starting Volume Definition ////////////////////// + //////////////////////////////////////////////////////////////// + G4String Name = "SuperX3Square" + DetectorNumber; + + // Definition of the volume containing the sensitive detector + G4Box* solidSuperX3 = new G4Box(Name, 0.5 * FaceFront, 0.5 * SiliconFaceLength * mm, 0.5 * Length); + G4LogicalVolume* logicSuperX3 = new G4LogicalVolume(solidSuperX3, m_MaterialVacuum, Name, 0, 0, 0); + + new G4PVPlacement(G4Transform3D(*rotation, position), logicSuperX3, Name, world, false, DetecNumber); + + logicSuperX3->SetVisAttributes(G4VisAttributes::GetInvisible()); + if (m_non_sensitive_part_visiualisation) + logicSuperX3->SetVisAttributes(G4VisAttributes(G4Colour(0.90, 0.90, 0.90))); + + // Aluminium dead layers + G4ThreeVector positionAluStripFront = G4ThreeVector(0, 0, AluStripBack_PosZ); + G4ThreeVector positionAluStripBack = G4ThreeVector(0, 0, AluStripFront_PosZ); + + G4Box* solidAluStrip = new G4Box("AluBox", 0.5 * SiliconFaceWidth, 0.5 * SiliconFaceLength, 0.5 * AluStripThickness); + // G4LogicalVolume* logicAluStrip = new G4LogicalVolume(solidAluStrip, + // m_MaterialAluminium, "logicAluStrip", 0, 0, 0); + G4LogicalVolume* logicAluStrip = new G4LogicalVolume(solidAluStrip, m_MaterialVacuum, "logicAluStrip", 0, 0, 0); + + new G4PVPlacement(0, positionAluStripFront, logicAluStrip, Name + "_AluStripFront", logicSuperX3, false, DetecNumber); + new G4PVPlacement(0, positionAluStripBack, logicAluStrip, Name + "_AluStripBack", logicSuperX3, false, DetecNumber); + + logicAluStrip->SetVisAttributes(G4VisAttributes(G4Colour(1.90, 0.0, 0.0))); + + // Silicon detector itself + G4ThreeVector positionSilicon = G4ThreeVector(0, 0, Silicon_PosZ); + + G4Box* solidSilicon = + new G4Box("solidSilicon", 0.5 * SiliconFaceWidth, 0.5 * SiliconFaceLength * mm, 0.5 * SiliconThickness); + G4LogicalVolume* logicSilicon = new G4LogicalVolume(solidSilicon, m_MaterialSilicon, "logicSilicon", 0, 0, 0); + + new G4PVPlacement(0, positionSilicon, logicSilicon, Name + "_Silicon", logicSuperX3, false, DetecNumber); + + // Set Silicon strip sensible + logicSilicon->SetSensitiveDetector(m_Scorer); + + /// Visualisation of Silicon Strip + G4VisAttributes* SiliconVisAtt = new G4VisAttributes(G4Colour(0.0, 0.0, 0.9)); + logicSilicon->SetVisAttributes(SiliconVisAtt); +} + +// Read stream at Configfile to pick-up parameters of detector (Position,...) +// Called in DetecorConstruction::ReadDetextorConfiguration Method +void SuperX3::ReadConfiguration(NPL::InputParser parser) { + vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithToken("SuperX3"); + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks.size() << " detectors found " << endl; + for (unsigned int i = 0; i < blocks.size(); i++) { + // Cartesian Case + vector<string> cart = {"X1_Y1", "X1_Y16", "X16_Y1", "X16_Y16", "VIS"}; + // Spherical Case + vector<string> sphe = {"R", "THETA", "PHI", "BETA", "VIS"}; + + if (blocks[i]->HasTokenList(cart)) { + cout << endl << "//// SuperX3 " << i + 1 << endl; + G4ThreeVector A = NPS::ConvertVector(blocks[i]->GetTVector3("X1_Y1", "mm")); + G4ThreeVector B = NPS::ConvertVector(blocks[i]->GetTVector3("X16_Y1", "mm")); + G4ThreeVector C = NPS::ConvertVector(blocks[i]->GetTVector3("X1_Y16", "mm")); + G4ThreeVector D = NPS::ConvertVector(blocks[i]->GetTVector3("X16_Y16", "mm")); + if (blocks[i]->GetInt("VIS")) + m_non_sensitive_part_visiualisation = true; + AddDetector(A, B, C, D); + } + + else if (blocks[i]->HasTokenList(sphe)) { + cout << endl << "//// SuperX3 " << i + 1 << endl; + double Theta = blocks[i]->GetDouble("THETA", "deg"); + double Phi = blocks[i]->GetDouble("PHI", "deg"); + double R = blocks[i]->GetDouble("R", "mm"); + vector<double> beta = blocks[i]->GetVectorDouble("BETA", "deg"); + if (blocks[i]->GetInt("VIS")) + m_non_sensitive_part_visiualisation = true; + + AddDetector(R, Theta, Phi, beta[0], beta[1], beta[2]); + } + + else { + cout << "ERROR: Missing token for SuperX3 blocks, check your input file" << endl; + exit(1); + } + } +} + +// Construct detector and inialise sensitive part. +// Called After DetecorConstruction::AddDetector Method +void SuperX3::ConstructDetector(G4LogicalVolume* world) { + G4RotationMatrix* SuperX3rot = NULL; + G4ThreeVector SuperX3pos = G4ThreeVector(0, 0, 0); + G4ThreeVector SuperX3u = G4ThreeVector(0, 0, 0); + G4ThreeVector SuperX3v = G4ThreeVector(0, 0, 0); + G4ThreeVector SuperX3w = G4ThreeVector(0, 0, 0); + G4ThreeVector SuperX3Center = G4ThreeVector(0, 0, 0); + + G4int NumberOfDetector = m_DefinitionType.size(); + for (G4int i = 0; i < NumberOfDetector; i++) { + // By Point + if (m_DefinitionType[i]) { + // (u,v,w) unitary vector associated to telescope referencial + // (u,v) // to silicon plan + // w perpendicular to (u,v) plan and pointing ThirdStage + SuperX3u = m_X16_Y1[i] - m_X1_Y1[i]; + SuperX3u = SuperX3u.unit(); + + SuperX3v = m_X1_Y16[i] - m_X1_Y1[i]; + SuperX3v = SuperX3v.unit(); + + SuperX3w = SuperX3u.cross(SuperX3v); + SuperX3w = SuperX3w.unit(); + + SuperX3Center = (m_X1_Y1[i] + m_X1_Y16[i] + m_X16_Y1[i] + m_X16_Y16[i]) / 4; + + // Passage Matrix from Lab Referential to Telescope Referential + SuperX3rot = new G4RotationMatrix(SuperX3u, SuperX3v, SuperX3w); + // translation to place Telescope + SuperX3pos = SuperX3w * Length * 0.5 + SuperX3Center; + } + + // By Angle + else { + G4double Theta = m_Theta[i]; + G4double Phi = m_Phi[i]; + + // (u,v,w) unitary vector associated to telescope referencial + // (u,v) // to silicon plan + // w perpendicular to (u,v) plan and pointing ThirdStage + // Phi is angle between X axis and projection in (X,Y) plan + // Theta is angle between position vector and z axis + G4double wX = m_R[i] * sin(Theta) * cos(Phi); + G4double wY = m_R[i] * sin(Theta) * sin(Phi); + G4double wZ = m_R[i] * cos(Theta); + SuperX3w = G4ThreeVector(wX, wY, wZ); + + // vector corresponding to the center of the module + SuperX3Center = SuperX3w; + + // vector parallel to one axis of silicon plane + G4double ii = cos(Theta) * cos(Phi); + G4double jj = cos(Theta) * sin(Phi); + G4double kk = -sin(Theta); + G4ThreeVector Y = G4ThreeVector(ii, jj, kk); + + SuperX3w = SuperX3w.unit(); + SuperX3u = SuperX3w.cross(Y); + SuperX3v = SuperX3w.cross(SuperX3u); + SuperX3v = SuperX3v.unit(); + SuperX3u = SuperX3u.unit(); + + // Passage Matrix from Lab Referential to Telescope Referential + // MUST2 + SuperX3rot = new G4RotationMatrix(SuperX3u, SuperX3v, SuperX3w); + // Telescope is rotate of Beta angle around SuperX3v axis. + SuperX3rot->rotate(m_beta_u[i], SuperX3u); + SuperX3rot->rotate(m_beta_v[i], SuperX3v); + SuperX3rot->rotate(m_beta_w[i], SuperX3w); + // translation to place Telescope + SuperX3pos = SuperX3w * (SiliconThickness + AluStripThickness) * 0.5 + SuperX3Center; + } + + VolumeMaker(i + 1, SuperX3pos, SuperX3rot, world); + } + + delete SuperX3rot; +} + +// Connect the GaspardTrackingData class to the output TTree +// of the simulation +void SuperX3::InitializeRootOutput() { + RootOutput* pAnalysis = RootOutput::getInstance(); + TTree* pTree = pAnalysis->GetTree(); + if (!pTree->FindBranch("SuperX3")) { + pTree->Branch("SuperX3", "TSuperX3Data", &m_Event); + } + pTree->SetBranchAddress("SuperX3", &m_Event); +} + +// Read sensitive part and fill the Root tree. +// Called at in the EventAction::EndOfEventAvtion +void SuperX3::ReadSensitive(const G4Event*) { + // Clear ROOT objects + m_Event->Clear(); + + auto resistive = (DSSDScorers::PS_Resistive*)m_Scorer->GetPrimitive(0); + auto backstrip = (DSSDScorers::PS_Rectangle*)m_Scorer->GetPrimitive(1); + auto sizeUp = resistive->GetUpMult(); + for (unsigned int i = 0; i < sizeUp; i++) { + double energy = resistive->GetEnergyUp(i); + double time = resistive->GetTimeUp(i); + int det = resistive->GetDetectorUp(i); + int strip = resistive->GetStripUp(i); + m_Event->SetUpE(det, strip, energy); + m_Event->SetUpT(det, strip, time); + } + auto sizeDown = resistive->GetDownMult(); + for (unsigned int i = 0; i < sizeDown; i++) { + double energy = resistive->GetEnergyDown(i); + double time = resistive->GetTimeDown(i); + int det = resistive->GetDetectorDown(i); + int strip = resistive->GetStripDown(i); + m_Event->SetDownE(det, strip, energy); + m_Event->SetDownT(det, strip, time); + } + auto sizeBack = backstrip->GetLengthMult(); + for (unsigned int i = 0; i < sizeBack; i++) { + double energy = backstrip->GetEnergyLength(i); + double time = backstrip->GetTimeLength(i); + int det = backstrip->GetDetectorLength(i); + int strip = backstrip->GetStripLength(i); + m_Event->SetBackE(det, strip, energy); + m_Event->SetBackT(det, strip, time); + } + resistive->clear(); + backstrip->clear(); +} + +void SuperX3::InitializeMaterials() { + m_MaterialSilicon = MaterialManager::getInstance()->GetMaterialFromLibrary("Si"); + m_MaterialAluminium = MaterialManager::getInstance()->GetMaterialFromLibrary("Al"); + m_MaterialIron = MaterialManager::getInstance()->GetMaterialFromLibrary("Fe"); + m_MaterialVacuum = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); +} + +void SuperX3::InitializeScorers() { + bool already_exist = false; + // Associate Scorer + m_Scorer = CheckScorer("ScorerSuperX3", already_exist); + if (already_exist) + return; + + //..... resistive starts.. + G4VPrimitiveScorer* resistivestrip = + new DSSDScorers::PS_Resistive("resistivestrip", "y", 0, SiliconFaceLength, SiliconFaceWidth, NbStrips, 0); + G4VPrimitiveScorer* backstrip = + new DSSDScorers::PS_Rectangle("backstrip", 0, SiliconFaceLength, SiliconFaceWidth, 4, 1, 0); + + G4VPrimitiveScorer* interaction = new InteractionScorers::PS_Interactions("Interaction", ms_InterCoord, 0); + //... resistive ends...... + // and register it to the multifunctionnal detector + //.... resistive starts... + m_Scorer->RegisterPrimitive(resistivestrip); + m_Scorer->RegisterPrimitive(backstrip); + m_Scorer->RegisterPrimitive(interaction); + //.....resistive ends... + + // Add All Scorer to the Global Scorer Manager + G4SDManager::GetSDMpointer()->AddNewDetector(m_Scorer); +} +//////////////////////////////////////////////////////////////////////////////// +// Construct Method to be pass to the DetectorFactory // +//////////////////////////////////////////////////////////////////////////////// +NPS::VDetector* SuperX3::Construct() { return (NPS::VDetector*)new SuperX3(); } + +//////////////////////////////////////////////////////////////////////////////// +// Registering the construct method to the factory // +//////////////////////////////////////////////////////////////////////////////// +extern "C" { +class proxy_nps_w1 { + public: + proxy_nps_w1() { + NPS::DetectorFactory::getInstance()->AddToken("SuperX3", "SuperX3"); + NPS::DetectorFactory::getInstance()->AddDetector("SuperX3", SuperX3::Construct); + } +}; + +proxy_nps_w1 p_nps_w1; +} diff --git a/NPSimulation/Detectors/SuperX3/SuperX3.hh b/NPSimulation/Detectors/SuperX3/SuperX3.hh new file mode 100644 index 0000000000000000000000000000000000000000..bff28fdffc449a9373518ede0eaf69778ce11ae4 --- /dev/null +++ b/NPSimulation/Detectors/SuperX3/SuperX3.hh @@ -0,0 +1,174 @@ +#ifndef SuperX3_h +#define SuperX3_h 1 +/***************************************************************************** + * Copyright (C) 2009-2016 this file is part of the NPTool Project * + * * + * For the licensing terms see $NPTOOL/Licence/NPTool_Licence * + * For the list of contributors see $NPTOOL/Licence/Contributors * + *****************************************************************************/ + +/***************************************************************************** + * Original Author: N. de Sereville contact address: deserevi@ipno.in2p3.fr * + * * + * Creation Date : 12/01/11 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: Define the SuperX3 detector from Micron * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ + +// C++ headers +#include <vector> + +// NPTool header +#include "NPSVDetector.hh" + +// Geant4 headers +#include "G4MultiFunctionalDetector.hh" + +// NPTool - ROOT headers +#include "NPInputParser.h" +#include "TSuperX3Data.h" +using namespace std; +using namespace CLHEP; + +class SuperX3 : public NPS::VDetector { + //////////////////////////////////////////////////// + /////// Default Constructor and Destructor ///////// + //////////////////////////////////////////////////// + public: + SuperX3(); + virtual ~SuperX3(); + + //////////////////////////////////////////////////// + //////// Specific Function of this Class /////////// + //////////////////////////////////////////////////// + public: + // Detector positionning + // By Position Method + void AddDetector(G4ThreeVector TL, G4ThreeVector BL, G4ThreeVector BR, + G4ThreeVector CT); + // By Angle Method + void AddDetector(G4double R, G4double Theta, G4double Phi, G4double beta_u, + G4double beta_v, G4double beta_w); + + // Effectively construct Volume + // Avoid to have two time same code for Angle and Point definition + void VolumeMaker(G4int DetecNumber, G4ThreeVector pos, G4RotationMatrix* rot, + G4LogicalVolume* world); + + ///////////////////////////////////////// + //// Inherite from NPS::VDetector class ///// + ///////////////////////////////////////// + public: + // Read stream at Configfile to pick-up parameters of detector (Position,...) + // Called in DetecorConstruction::ReadDetextorConfiguration Method + void ReadConfiguration(NPL::InputParser); + + // Construct detector and inialise sensitive part. + // Called After DetecorConstruction::AddDetector Method + void ConstructDetector(G4LogicalVolume* world); + + // Add Detector branch to the EventTree. + // Called After DetecorConstruction::AddDetector Method + void InitializeRootOutput(); + + // Initialize all scorers necessary for the detector + void InitializeScorers(); + + // Read sensitive part and fill the Root tree. + // Called at in the EventAction::EndOfEventAvtion + void ReadSensitive(const G4Event* event); + + //////////////////////////////////////////////////// + ///////////Event class to store Data//////////////// + //////////////////////////////////////////////////// + private: + TSuperX3Data* m_Event; + + //////////////////////////////////////////////////// + //////////////////// Scorers /////////////////////// + //////////////////////////////////////////////////// + private: + G4MultiFunctionalDetector* m_Scorer; + + //////////////////////////////////////////////////// + //////////////////// Material ////////////////////// + //////////////////////////////////////////////////// + private: + // Declare all material used by theSuperX3 detector + void InitializeMaterials(); + + // Vacuum + G4Material* m_MaterialVacuum; + // Si + G4Material* m_MaterialSilicon; + // Al + G4Material* m_MaterialAluminium; + // Iron + G4Material* m_MaterialIron; + + //////////////////////////////////////////////////// + ///////////////Private intern Data////////////////// + //////////////////////////////////////////////////// + private: + // True if Define by Position, False is Define by angle + vector<bool> m_DefinitionType; + + // Used for "By Point Definition" + vector<G4ThreeVector> m_X1_Y1; // Top Left Corner Position Vector + vector<G4ThreeVector> m_X1_Y16; // Bottom Left Corner Position Vector + vector<G4ThreeVector> m_X16_Y1; // Bottom Right Corner Position Vector + vector<G4ThreeVector> m_X16_Y16; // Center Corner Position Vector + + // Used for "By Angle Definition" + vector<G4double> m_R; // | + vector<G4double> m_Theta; // > Spherical coordinate of Strips Silicium Plate + vector<G4double> m_Phi; // | + + vector<G4double> m_beta_u; // | + vector<G4double> m_beta_v; // > Tilt angle of the Telescope + vector<G4double> m_beta_w; // | + + // Set to true if you want to see Telescope Frame in your visualisation + bool m_non_sensitive_part_visiualisation; + + public: + static NPS::VDetector* Construct(); +}; + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +namespace SuperX3SQUARE { +// Energy/Time resolutions for the different layers +const G4double EnergyResolution = 12.8e-3; // 30 keV FWHM +const G4double TimeResolution = 0.638; // 1.5 ns (FWHM) + +// Geometry +const G4double FaceFront = 40 * mm; +const G4double Length = 10 * mm; + +// First stage +// const G4double AluStripThickness = 0.00000001*micrometer; +const G4double AluStripThickness = 0.4 * micrometer; +const G4double SiliconThickness = 1000 * micrometer; +const G4double SiliconFace = 40.0 * mm; +const G4double SiliconFaceWidth = 40.0 * mm; +const G4double SiliconFaceLength = 75.0 * mm; +// const G4double SiliconFaceWidtht = 75*mm; +// const G4double SiliconFaceLengtht = 39.6*mm; +// Characteristics +const G4int NbStrips = 4; + +// Starting at the front and going in direction of third stage +const G4double AluStripFront_PosZ = Length * -0.5 + 0.5 * AluStripThickness; +const G4double Silicon_PosZ = + AluStripFront_PosZ + 0.5 * AluStripThickness + 0.5 * SiliconThickness; +const G4double AluStripBack_PosZ = + Silicon_PosZ + 0.5 * SiliconThickness + 0.5 * AluStripThickness; +} // namespace SuperX3SQUARE + +#endif diff --git a/NPSimulation/Detectors/Tiara/Tiara.cc b/NPSimulation/Detectors/Tiara/Tiara.cc index 70a986d7c8eb1bd6748990193c5797067c165a9a..c5a0aee9218606d1d1dff39c18f9be41ff3c4977 100644 --- a/NPSimulation/Detectors/Tiara/Tiara.cc +++ b/NPSimulation/Detectors/Tiara/Tiara.cc @@ -20,33 +20,32 @@ *****************************************************************************/ // C++ headers -#include <sstream> #include <cmath> #include <limits> -//G4 Geometry object +#include <sstream> +// G4 Geometry object #include "G4Box.hh" -#include "G4Tubs.hh" #include "G4Cons.hh" -#include "G4UnionSolid.hh" #include "G4ExtrudedSolid.hh" +#include "G4Tubs.hh" #include "G4TwoVector.hh" -//G4 sensitive +#include "G4UnionSolid.hh" +// G4 sensitive #include "G4SDManager.hh" -//G4 various object -#include "G4Material.hh" -#include "G4Transform3D.hh" -#include "G4PVPlacement.hh" +// G4 various object #include "G4Colour.hh" +#include "G4Material.hh" #include "G4PVDivision.hh" +#include "G4PVPlacement.hh" #include "G4SubtractionSolid.hh" +#include "G4Transform3D.hh" // NPS -#include "Tiara.hh" -#include "NPSDetectorFactory.hh" #include "MaterialManager.hh" #include "NPSDetectorFactory.hh" #include "SiliconScorers.hh" +#include "Tiara.hh" // NPL #include "NPOptionManager.h" @@ -60,85 +59,83 @@ using namespace std; using namespace CLHEP; //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -Tiara::Tiara(){ +Tiara::Tiara() { InitializeMaterial(); m_EventBarrel = new TTiaraBarrelData(); m_EventHyball = new TTiaraHyballData(); // Dark Grey - SiliconVisAtt = new G4VisAttributes(G4Colour(0.3, 0.3, 0.3)) ; + SiliconVisAtt = new G4VisAttributes(G4Colour(0.3, 0.3, 0.3)); // Green - PCBVisAtt = new G4VisAttributes(G4Colour(0.2, 0.5, 0.2)) ; + PCBVisAtt = new G4VisAttributes(G4Colour(0.2, 0.5, 0.2)); // Gold Yellow - PADVisAtt = new G4VisAttributes(G4Colour(0.5, 0.5, 0.2)) ; + PADVisAtt = new G4VisAttributes(G4Colour(0.5, 0.5, 0.2)); // Light Grey - FrameVisAtt = new G4VisAttributes(G4Colour(0.5, 0.5, 0.5)) ; + FrameVisAtt = new G4VisAttributes(G4Colour(0.5, 0.5, 0.5)); // Light Blue - GuardRingVisAtt = new G4VisAttributes(G4Colour(0.1, 0.1, 0.1)) ; + GuardRingVisAtt = new G4VisAttributes(G4Colour(0.1, 0.1, 0.1)); m_boolChamber = false; m_boolInner = false; m_boolOuter = false; - m_InnerBarrelScorer = 0 ; - m_OuterBarrelScorer = 0 ; - m_HyballScorer = 0 ; - + m_InnerBarrelScorer = 0; + m_OuterBarrelScorer = 0; + m_HyballScorer = 0; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -Tiara::~Tiara(){ -} +Tiara::~Tiara() {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Virtual Method of NPS::VDetector class // Read stream at Configfile to pick-up parameters of detector (Position,...) // Called in DetecorConstruction::ReadDetextorConfiguration Method -void Tiara::ReadConfiguration(NPL::InputParser parser){ - vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithTokenAndValue("Tiara","Barrel"); +void Tiara::ReadConfiguration(NPL::InputParser parser) { + vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithTokenAndValue("Tiara", "Barrel"); - if(NPOptionManager::getInstance()->GetVerboseLevel()) + if (NPOptionManager::getInstance()->GetVerboseLevel()) cout << "//// " << blocks.size() << " detectors found " << endl; - vector<string> token = {"InnerBarrel","OuterBarrel","Chamber"}; + vector<string> token = {"InnerBarrel", "OuterBarrel", "Chamber"}; - for(unsigned int i = 0 ; i < blocks.size() ; i++){ - if(blocks[i]->HasTokenList(token)){ - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << endl << "//// Barrel " << i+1 << endl; - m_boolInner = blocks[i]->GetInt("InnerBarrel"); - m_boolOuter = blocks[i]->GetInt("OuterBarrel"); + for (unsigned int i = 0; i < blocks.size(); i++) { + if (blocks[i]->HasTokenList(token)) { + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// Barrel " << i + 1 << endl; + m_boolInner = blocks[i]->GetInt("InnerBarrel"); + m_boolOuter = blocks[i]->GetInt("OuterBarrel"); m_boolChamber = blocks[i]->GetInt("Chamber"); } - else{ + else { cout << "ERROR: check your input file formatting " << endl; exit(1); } } blocks.clear(); -//by Shuya 180426 - // blocks = parser.GetAllBlocksWithToken("TiaraHyballWedge"); - blocks = parser.GetAllBlocksWithTokenAndValue("Tiara","Hyball"); + // by Shuya 180426 + // blocks = parser.GetAllBlocksWithToken("TiaraHyballWedge"); + blocks = parser.GetAllBlocksWithTokenAndValue("Tiara", "Hyball"); - if(NPOptionManager::getInstance()->GetVerboseLevel()) + if (NPOptionManager::getInstance()->GetVerboseLevel()) cout << "//// " << blocks.size() << " detectors found " << endl; token.clear(); - token = {"Z","R","Phi"}; - - for(unsigned int i = 0 ; i < blocks.size() ; i++){ - if(blocks[i]->HasTokenList(token)){ - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << endl << "//// Hyball Wedge" << i+1 << endl; - double Z = blocks[i]->GetDouble("Z","mm"); - double R = blocks[i]->GetDouble("R","mm"); - double Phi = blocks[i]->GetDouble("Phi","deg"); + token = {"Z", "R", "Phi"}; + + for (unsigned int i = 0; i < blocks.size(); i++) { + if (blocks[i]->HasTokenList(token)) { + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// Hyball Wedge" << i + 1 << endl; + double Z = blocks[i]->GetDouble("Z", "mm"); + double R = blocks[i]->GetDouble("R", "mm"); + double Phi = blocks[i]->GetDouble("Phi", "deg"); m_HyballZ.push_back(Z); m_HyballR.push_back(R); m_HyballPhi.push_back(Phi); } - else{ + else { cout << "ERROR: check your input file formatting " << endl; exit(1); } @@ -148,23 +145,23 @@ void Tiara::ReadConfiguration(NPL::InputParser parser){ //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Construct detector and inialise sensitive part. // Called After DetecorConstruction::AddDetector Method -void Tiara::ConstructDetector(G4LogicalVolume* world){ +void Tiara::ConstructDetector(G4LogicalVolume* world) { - if(m_boolChamber) + if (m_boolChamber) ConstructChamber(world); - if(m_boolInner) + if (m_boolInner) ConstructInnerBarrel(world); - if(m_boolOuter) + if (m_boolOuter) ConstructOuterBarrel(world); - if(m_HyballZ.size()) + if (m_HyballZ.size()) ConstructHyball(world); } // Read sensitive part and fill the Root tree. // Called at in the EventAction::EndOfEventAvtion -void Tiara::ReadSensitive(const G4Event* event){ +void Tiara::ReadSensitive(const G4Event* event) { m_EventBarrel->Clear(); m_EventHyball->Clear(); @@ -175,42 +172,44 @@ void Tiara::ReadSensitive(const G4Event* event){ InnerBarrelHitMap = (NPS::HitsMap<G4double*>*)(event->GetHCofThisEvent()->GetHC(InnerBarrelCollectionID)); // Loop on the InnerBarrel map - for (InnerBarrel_itr = InnerBarrelHitMap->GetMap()->begin() ; InnerBarrel_itr != InnerBarrelHitMap->GetMap()->end() ; InnerBarrel_itr++){ + for (InnerBarrel_itr = InnerBarrelHitMap->GetMap()->begin(); InnerBarrel_itr != InnerBarrelHitMap->GetMap()->end(); + InnerBarrel_itr++) { G4double* Info = *(InnerBarrel_itr->second); // Downstream Energy - //by Shuya 180504. Note I changed this unit from MeV to keV because Barrel data are given in keV in real data. - //double ED = RandGauss::shoot(Info[0],ResoEnergyInnerBarrel); - double ED = RandGauss::shoot(Info[0]/keV,ResoEnergyInnerBarrel); - if(ED>EnergyThreshold){ - m_EventBarrel->SetFrontDownstreamE(Info[3],Info[4],ED); - m_EventBarrel->SetFrontDownstreamT(Info[3],Info[4],Info[2]); + // by Shuya 180504. Note I changed this unit from MeV to keV because Barrel data are given in keV in real data. + // double ED = RandGauss::shoot(Info[0],ResoEnergyInnerBarrel); + double ED = RandGauss::shoot(Info[0] / keV, ResoEnergyInnerBarrel); + if (ED > EnergyThreshold) { + m_EventBarrel->SetFrontDownstreamE(Info[3], Info[4], ED); + m_EventBarrel->SetFrontDownstreamT(Info[3], Info[4], Info[2]); } // Upstream Energy - //by Shuya 180504. Note I changed this unit from MeV to keV because Barrel data are given in keV in real data. - //double EU = RandGauss::shoot(Info[1],ResoEnergyInnerBarrel); - double EU = RandGauss::shoot(Info[1]/keV,ResoEnergyInnerBarrel); - if(EU>EnergyThreshold){ - m_EventBarrel->SetFrontUpstreamE(Info[3],Info[4],EU); - m_EventBarrel->SetFrontUpstreamT(Info[3],Info[4],Info[2]); - //cout << "BARREL " << Info[3] << " STRIP " << Info[4] << " " << Info[9]/deg << " " << Info[5] << " " << Info[6] << " " << Info[7] << endl; + // by Shuya 180504. Note I changed this unit from MeV to keV because Barrel data are given in keV in real data. + // double EU = RandGauss::shoot(Info[1],ResoEnergyInnerBarrel); + double EU = RandGauss::shoot(Info[1] / keV, ResoEnergyInnerBarrel); + if (EU > EnergyThreshold) { + m_EventBarrel->SetFrontUpstreamE(Info[3], Info[4], EU); + m_EventBarrel->SetFrontUpstreamT(Info[3], Info[4], Info[2]); + // cout << "BARREL " << Info[3] << " STRIP " << Info[4] << " " << Info[9]/deg << " " << Info[5] << " " << Info[6] + // << " " << Info[7] << endl; } // Back Energy - //by Shuya 180504. Note I changed this unit from MeV to keV because Barrel data are given in keV in real data. - //double EB = RandGauss::shoot(Info[1]+Info[0],ResoEnergyInnerBarrel); - double EB = RandGauss::shoot(Info[1]/keV+Info[0]*keV,ResoEnergyInnerBarrel); - if(EB>EnergyThreshold){ - m_EventBarrel->SetBackE(Info[3],EB); - m_EventBarrel->SetBackT(Info[3],Info[2]); + // by Shuya 180504. Note I changed this unit from MeV to keV because Barrel data are given in keV in real data. + // double EB = RandGauss::shoot(Info[1]+Info[0],ResoEnergyInnerBarrel); + double EB = RandGauss::shoot(Info[1] / keV + Info[0] * keV, ResoEnergyInnerBarrel); + if (EB > EnergyThreshold) { + m_EventBarrel->SetBackE(Info[3], EB); + m_EventBarrel->SetBackT(Info[3], Info[2]); } - // Interaction Coordinates - ms_InterCoord->SetDetectedPositionX(Info[5]) ; - ms_InterCoord->SetDetectedPositionY(Info[6]) ; - ms_InterCoord->SetDetectedPositionZ(Info[7]) ; - ms_InterCoord->SetDetectedAngleTheta(Info[8]/deg) ; - ms_InterCoord->SetDetectedAnglePhi(Info[9]/deg) ; + // Interaction Coordinates + ms_InterCoord->SetDetectedPositionX(Info[5]); + ms_InterCoord->SetDetectedPositionY(Info[6]); + ms_InterCoord->SetDetectedPositionZ(Info[7]); + ms_InterCoord->SetDetectedAngleTheta(Info[8] / deg); + ms_InterCoord->SetDetectedAnglePhi(Info[9] / deg); } // Clear Map for next event InnerBarrelHitMap->clear(); @@ -222,25 +221,25 @@ void Tiara::ReadSensitive(const G4Event* event){ OuterBarrelHitMap = (NPS::HitsMap<G4double*>*)(event->GetHCofThisEvent()->GetHC(OuterBarrelCollectionID)); // Loop on the OuterBarrel map - for (OuterBarrel_itr = OuterBarrelHitMap->GetMap()->begin() ; OuterBarrel_itr != OuterBarrelHitMap->GetMap()->end() ; OuterBarrel_itr++){ + for (OuterBarrel_itr = OuterBarrelHitMap->GetMap()->begin(); OuterBarrel_itr != OuterBarrelHitMap->GetMap()->end(); + OuterBarrel_itr++) { G4double* Info = *(OuterBarrel_itr->second); - double E = RandGauss::shoot(Info[0]/keV,ResoEnergyOuterBarrel); - if(E>EnergyThreshold){ - m_EventBarrel->SetOuterE(Info[7],Info[9],E); - m_EventBarrel->SetOuterT(Info[7],Info[9],Info[1]); + double E = RandGauss::shoot(Info[0] / keV, ResoEnergyOuterBarrel); + if (E > EnergyThreshold) { + m_EventBarrel->SetOuterE(Info[7], Info[9], E); + m_EventBarrel->SetOuterT(Info[7], Info[9], Info[1]); } - // Interaction Coordinates - ms_InterCoord->SetDetectedPositionX(Info[5]) ; - ms_InterCoord->SetDetectedPositionY(Info[6]) ; - ms_InterCoord->SetDetectedPositionZ(Info[7]) ; - ms_InterCoord->SetDetectedAngleTheta(Info[8]/deg) ; - ms_InterCoord->SetDetectedAnglePhi(Info[9]/deg) ; + // Interaction Coordinates + ms_InterCoord->SetDetectedPositionX(Info[5]); + ms_InterCoord->SetDetectedPositionY(Info[6]); + ms_InterCoord->SetDetectedPositionZ(Info[7]); + ms_InterCoord->SetDetectedAngleTheta(Info[8] / deg); + ms_InterCoord->SetDetectedAnglePhi(Info[9] / deg); } // Clear Map for next event OuterBarrelHitMap->clear(); - // Hyball // NPS::HitsMap<G4double*>* HyballHitMap; std::map<G4int, G4double**>::iterator Hyball_itr; @@ -248,124 +247,125 @@ void Tiara::ReadSensitive(const G4Event* event){ HyballHitMap = (NPS::HitsMap<G4double*>*)(event->GetHCofThisEvent()->GetHC(HyballCollectionID)); // Loop on the Hyball map - for (Hyball_itr = HyballHitMap->GetMap()->begin() ; Hyball_itr != HyballHitMap->GetMap()->end() ; Hyball_itr++){ + for (Hyball_itr = HyballHitMap->GetMap()->begin(); Hyball_itr != HyballHitMap->GetMap()->end(); Hyball_itr++) { G4double* Info = *(Hyball_itr->second); // Front Energy - double EF = RandGauss::shoot(Info[0],ResoEnergyHyball); - if(EF>EnergyThreshold){ - int RingNumber=Info[8]; - //by Shuya 171009 - RingNumber=abs(RingNumber); - //RingNumber=abs(RingNumber-17); - Info[8]=RingNumber; - m_EventHyball->SetRingE(Info[7],Info[8],EF); - m_EventHyball->SetRingT(Info[7],Info[8],Info[1]); + double EF = RandGauss::shoot(Info[0], ResoEnergyHyball); + if (EF > EnergyThreshold) { + int RingNumber = Info[8]; + // by Shuya 171009 + RingNumber = abs(RingNumber); + // RingNumber=abs(RingNumber-17); + Info[8] = RingNumber; + m_EventHyball->SetRingE(Info[7], Info[8], EF); + m_EventHyball->SetRingT(Info[7], Info[8], Info[1]); } // Back Energy -//by Shuya 171009. Infor[1] is Timing data... no make sense. - //double EB = RandGauss::shoot(Info[1]+Info[0],ResoEnergyHyball); - double EB = RandGauss::shoot(Info[0],ResoEnergyHyball); - if(EB>EnergyThreshold){ -//by Shuya 171012. - double m_axis = -100.0; - double m_phi = Info[6]; - if(Info[6]<0) m_phi = Info[6]+2.0*M_PI; - - if(Info[7]==1) m_axis = 210.0/180.0*M_PI; - else if(Info[7]==2) m_axis = 150.0/180.0*M_PI; - else if(Info[7]==3) m_axis = 90.0/180.0*M_PI; - else if(Info[7]==4) m_axis = 30.0/180.0*M_PI; - else if(Info[7]==5) m_axis = 330.0/180.0*M_PI; - else if(Info[7]==6) m_axis = 270.0/180.0*M_PI; - - double m_StripPitchSector_Tiara = (0.5*HYBALL_ActiveWafer_Angle-(-0.5*HYBALL_ActiveWafer_Angle))/HYBALL_NumberOfRadialStrip; - Info[9] = (int)((m_phi - (m_axis - 0.5*HYBALL_ActiveWafer_Angle)) / m_StripPitchSector_Tiara ) + 1 ; - -//by Shuya 171009 - //m_EventHyball->SetSectorE(Info[7],Info[9],EF); - m_EventHyball->SetSectorE(Info[7],Info[9],EB); - m_EventHyball->SetSectorT(Info[7],Info[9],Info[1]); + // by Shuya 171009. Infor[1] is Timing data... no make sense. + // double EB = RandGauss::shoot(Info[1]+Info[0],ResoEnergyHyball); + double EB = RandGauss::shoot(Info[0], ResoEnergyHyball); + if (EB > EnergyThreshold) { + // by Shuya 171012. + double m_axis = -100.0; + double m_phi = Info[6]; + if (Info[6] < 0) + m_phi = Info[6] + 2.0 * M_PI; + + if (Info[7] == 1) + m_axis = 210.0 / 180.0 * M_PI; + else if (Info[7] == 2) + m_axis = 150.0 / 180.0 * M_PI; + else if (Info[7] == 3) + m_axis = 90.0 / 180.0 * M_PI; + else if (Info[7] == 4) + m_axis = 30.0 / 180.0 * M_PI; + else if (Info[7] == 5) + m_axis = 330.0 / 180.0 * M_PI; + else if (Info[7] == 6) + m_axis = 270.0 / 180.0 * M_PI; + + double m_StripPitchSector_Tiara = + (0.5 * HYBALL_ActiveWafer_Angle - (-0.5 * HYBALL_ActiveWafer_Angle)) / HYBALL_NumberOfRadialStrip; + Info[9] = (int)((m_phi - (m_axis - 0.5 * HYBALL_ActiveWafer_Angle)) / m_StripPitchSector_Tiara) + 1; + + // by Shuya 171009 + // m_EventHyball->SetSectorE(Info[7],Info[9],EF); + m_EventHyball->SetSectorE(Info[7], Info[9], EB); + m_EventHyball->SetSectorT(Info[7], Info[9], Info[1]); } // Interaction Coordinates -//by Shuya 171009 -/* - ms_InterCoord->SetDetectedPositionX(Info[5]) ; - ms_InterCoord->SetDetectedPositionY(Info[6]) ; - ms_InterCoord->SetDetectedPositionZ(Info[7]) ; - ms_InterCoord->SetDetectedAngleTheta(Info[8]/deg) ; - ms_InterCoord->SetDetectedAnglePhi(Info[9]/deg) ; -*/ - ms_InterCoord->SetDetectedPositionX(Info[2]) ; - ms_InterCoord->SetDetectedPositionY(Info[3]) ; - ms_InterCoord->SetDetectedPositionZ(Info[4]) ; - ms_InterCoord->SetDetectedAngleTheta(Info[5]/deg) ; - ms_InterCoord->SetDetectedAnglePhi(Info[6]/deg) ; + // by Shuya 171009 + /* + ms_InterCoord->SetDetectedPositionX(Info[5]) ; + ms_InterCoord->SetDetectedPositionY(Info[6]) ; + ms_InterCoord->SetDetectedPositionZ(Info[7]) ; + ms_InterCoord->SetDetectedAngleTheta(Info[8]/deg) ; + ms_InterCoord->SetDetectedAnglePhi(Info[9]/deg) ; + */ + ms_InterCoord->SetDetectedPositionX(Info[2]); + ms_InterCoord->SetDetectedPositionY(Info[3]); + ms_InterCoord->SetDetectedPositionZ(Info[4]); + ms_InterCoord->SetDetectedAngleTheta(Info[5] / deg); + ms_InterCoord->SetDetectedAnglePhi(Info[6] / deg); } // Clear Map for next event HyballHitMap->clear(); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Tiara::InitializeScorers(){ - //Look for previous definition of the scorer (geometry reload) +void Tiara::InitializeScorers() { + // Look for previous definition of the scorer (geometry reload) bool already_exist = false; - m_InnerBarrelScorer = CheckScorer("Tiara_InnerBarrelScorer",already_exist); - m_OuterBarrelScorer = CheckScorer("Tiara_OuterBarrelScorer",already_exist); - m_HyballScorer = CheckScorer("Tiara_HyballScorer",already_exist); + m_InnerBarrelScorer = CheckScorer("Tiara_InnerBarrelScorer", already_exist); + m_OuterBarrelScorer = CheckScorer("Tiara_OuterBarrelScorer", already_exist); + m_HyballScorer = CheckScorer("Tiara_HyballScorer", already_exist); // if the scorer were created previously nothing else need to be made - if(already_exist) return; + if (already_exist) + return; - G4VPrimitiveScorer* InnerBarrel = new SILICONSCORERS::PS_Silicon_Resistive("InnerBarrel",1, - INNERBARREL_ActiveWafer_Length, - INNERBARREL_ActiveWafer_Width, - INNERBARREL_NumberOfStrip); + G4VPrimitiveScorer* InnerBarrel = new SILICONSCORERS::PS_Silicon_Resistive( + "InnerBarrel", 1, INNERBARREL_ActiveWafer_Length, INNERBARREL_ActiveWafer_Width, INNERBARREL_NumberOfStrip); m_InnerBarrelScorer->RegisterPrimitive(InnerBarrel); - G4VPrimitiveScorer* OuterBarrel = new SILICONSCORERS::PS_Silicon_Rectangle("OuterBarrel",1, - INNERBARREL_ActiveWafer_Length, - INNERBARREL_ActiveWafer_Width, - 1, - OUTERBARREL_NumberOfStrip); + G4VPrimitiveScorer* OuterBarrel = new SILICONSCORERS::PS_Silicon_Rectangle( + "OuterBarrel", 1, INNERBARREL_ActiveWafer_Length, INNERBARREL_ActiveWafer_Width, 1, OUTERBARREL_NumberOfStrip); m_OuterBarrelScorer->RegisterPrimitive(OuterBarrel); - G4VPrimitiveScorer* Hyball= new SILICONSCORERS::PS_Silicon_Annular("Hyball",1, - HYBALL_ActiveWafer_InnerRadius, - HYBALL_ActiveWafer_OuterRadius, - -0.5*HYBALL_ActiveWafer_Angle,0.5*HYBALL_ActiveWafer_Angle, - HYBALL_NumberOfAnnularStrip, - HYBALL_NumberOfRadialStrip); + G4VPrimitiveScorer* Hyball = new SILICONSCORERS::PS_Silicon_Annular( + "Hyball", 1, HYBALL_ActiveWafer_InnerRadius, HYBALL_ActiveWafer_OuterRadius, -0.5 * HYBALL_ActiveWafer_Angle, + 0.5 * HYBALL_ActiveWafer_Angle, HYBALL_NumberOfAnnularStrip, HYBALL_NumberOfRadialStrip); m_HyballScorer->RegisterPrimitive(Hyball); // Add All Scorer to the Global Scorer Manager - G4SDManager::GetSDMpointer()->AddNewDetector(m_InnerBarrelScorer) ; - G4SDManager::GetSDMpointer()->AddNewDetector(m_OuterBarrelScorer) ; - G4SDManager::GetSDMpointer()->AddNewDetector(m_HyballScorer) ; + G4SDManager::GetSDMpointer()->AddNewDetector(m_InnerBarrelScorer); + G4SDManager::GetSDMpointer()->AddNewDetector(m_OuterBarrelScorer); + G4SDManager::GetSDMpointer()->AddNewDetector(m_HyballScorer); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Tiara::InitializeRootOutput(){ - TTree *pTree = RootOutput::getInstance()->GetTree(); - if(!pTree->FindBranch("TiaraBarrel")){ - pTree->Branch("TiaraBarrel", "TTiaraBarrelData", &m_EventBarrel) ; +void Tiara::InitializeRootOutput() { + TTree* pTree = RootOutput::getInstance()->GetTree(); + if (!pTree->FindBranch("TiaraBarrel")) { + pTree->Branch("TiaraBarrel", "TTiaraBarrelData", &m_EventBarrel); } - if(!pTree->FindBranch("TiaraHyball")){ - pTree->Branch("TiaraHyball", "TTiaraHyballData", &m_EventHyball) ; + if (!pTree->FindBranch("TiaraHyball")) { + pTree->Branch("TiaraHyball", "TTiaraHyballData", &m_EventHyball); } // This insure that the object are correctly bind in case of // a redifinition of the geometry in the simulation - pTree->SetBranchAddress("TiaraBarrel", &m_EventBarrel) ; - pTree->SetBranchAddress("TiaraHyball", &m_EventHyball) ; + pTree->SetBranchAddress("TiaraBarrel", &m_EventBarrel); + pTree->SetBranchAddress("TiaraHyball", &m_EventHyball); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Tiara::ConstructInnerBarrel(G4LogicalVolume* world){ +void Tiara::ConstructInnerBarrel(G4LogicalVolume* world) { // Tiara Barrel // The Barrel is made of 8 identical resistive strip detector // The PCB is made from a G4ExtrudeSolid, because it has beveled edge @@ -376,100 +376,75 @@ void Tiara::ConstructInnerBarrel(G4LogicalVolume* world){ // Start by making a full pcb // We start by the definition of the point forming a PCB cross section vector<G4TwoVector> PCBCrossSection; - double l1 = INNERBARREL_PCB_Thickness*0.5/tan(INNERBARREL_PCB_Bevel1_Theta); - double l2 = INNERBARREL_PCB_Thickness*0.5/tan(INNERBARREL_PCB_Bevel2_Theta); + double l1 = INNERBARREL_PCB_Thickness * 0.5 / tan(INNERBARREL_PCB_Bevel1_Theta); + double l2 = INNERBARREL_PCB_Thickness * 0.5 / tan(INNERBARREL_PCB_Bevel2_Theta); - PCBCrossSection.push_back(G4TwoVector(INNERBARREL_PCB_Width/2.-l2,-INNERBARREL_PCB_Thickness*0.5)); - PCBCrossSection.push_back(G4TwoVector(INNERBARREL_PCB_Width/2.,0)); - PCBCrossSection.push_back(G4TwoVector(INNERBARREL_PCB_Width/2.-l1,INNERBARREL_PCB_Thickness*0.5)); + PCBCrossSection.push_back(G4TwoVector(INNERBARREL_PCB_Width / 2. - l2, -INNERBARREL_PCB_Thickness * 0.5)); + PCBCrossSection.push_back(G4TwoVector(INNERBARREL_PCB_Width / 2., 0)); + PCBCrossSection.push_back(G4TwoVector(INNERBARREL_PCB_Width / 2. - l1, INNERBARREL_PCB_Thickness * 0.5)); - PCBCrossSection.push_back(G4TwoVector(-INNERBARREL_PCB_Width/2.+l1,INNERBARREL_PCB_Thickness*0.5)); - PCBCrossSection.push_back(G4TwoVector(-INNERBARREL_PCB_Width/2.,0)); - PCBCrossSection.push_back(G4TwoVector(-INNERBARREL_PCB_Width/2.+l2,-INNERBARREL_PCB_Thickness*0.5)); + PCBCrossSection.push_back(G4TwoVector(-INNERBARREL_PCB_Width / 2. + l1, INNERBARREL_PCB_Thickness * 0.5)); + PCBCrossSection.push_back(G4TwoVector(-INNERBARREL_PCB_Width / 2., 0)); + PCBCrossSection.push_back(G4TwoVector(-INNERBARREL_PCB_Width / 2. + l2, -INNERBARREL_PCB_Thickness * 0.5)); - G4ExtrudedSolid* PCBFull = - new G4ExtrudedSolid("PCBFull", - PCBCrossSection, - INNERBARREL_PCB_Length/2., - G4TwoVector(0,0),1, - G4TwoVector(0,0),1); + G4ExtrudedSolid* PCBFull = new G4ExtrudedSolid("PCBFull", PCBCrossSection, INNERBARREL_PCB_Length / 2., + G4TwoVector(0, 0), 1, G4TwoVector(0, 0), 1); // A box having Wafer dimension but thicker than the PCB // Will be used to remove material from the PCB to have space for the wafer // Calculate the hole shift within the PCB - G4ThreeVector HoleShift = G4ThreeVector( - 0, - 0, - INNERBARREL_PCB_Offset-(INNERBARREL_PCB_Length/2-INNERBARREL_PCB_HoleLength/2)); + G4ThreeVector HoleShift = + G4ThreeVector(0, 0, INNERBARREL_PCB_Offset - (INNERBARREL_PCB_Length / 2 - INNERBARREL_PCB_HoleLength / 2)); - G4Box* HoleShape = new G4Box("HoleShape", - INNERBARREL_ActiveWafer_Width/2., - INNERBARREL_PCB_Thickness/2.+0.1*mm, - INNERBARREL_PCB_HoleLength/2.); + G4Box* HoleShape = new G4Box("HoleShape", INNERBARREL_ActiveWafer_Width / 2., + INNERBARREL_PCB_Thickness / 2. + 0.1 * mm, INNERBARREL_PCB_HoleLength / 2.); - G4Box* WaferShape = new G4Box("WaferShape", - INNERBARREL_InertWafer_Width/2., - INNERBARREL_PCB_Thickness/2., - INNERBARREL_InertWafer_Length/2.); + G4Box* WaferShape = new G4Box("WaferShape", INNERBARREL_InertWafer_Width / 2., INNERBARREL_PCB_Thickness / 2., + INNERBARREL_InertWafer_Length / 2.); // The Silicon Wafer itself - G4Box* InertWaferFull = new G4Box("InertWaferFull", - INNERBARREL_InertWafer_Width/2., - INNERBARREL_InertWafer_Thickness/2., - INNERBARREL_InertWafer_Length/2.); - - G4Box* ActiveWafer = new G4Box("ActiveWafer", - INNERBARREL_ActiveWafer_Width/2., - INNERBARREL_ActiveWafer_Thickness/2., - INNERBARREL_ActiveWafer_Length/2.); + G4Box* InertWaferFull = new G4Box("InertWaferFull", INNERBARREL_InertWafer_Width / 2., + INNERBARREL_InertWafer_Thickness / 2., INNERBARREL_InertWafer_Length / 2.); - G4Box* DeadLayer = new G4Box("DeadLayer", - INNERBARREL_ActiveWafer_Width/2., - INNERBARREL_ActiveWafer_DeadLayerThickness/2., - INNERBARREL_ActiveWafer_Length/2.); + G4Box* ActiveWafer = new G4Box("ActiveWafer", INNERBARREL_ActiveWafer_Width / 2., + INNERBARREL_ActiveWafer_Thickness / 2., INNERBARREL_ActiveWafer_Length / 2.); - G4Box* ActiveWaferShape = new G4Box("ActiveWaferShape", - INNERBARREL_ActiveWafer_Width/2., - INNERBARREL_PCB_Thickness/2., - INNERBARREL_ActiveWafer_Length/2.); + G4Box* DeadLayer = new G4Box("DeadLayer", INNERBARREL_ActiveWafer_Width / 2., + INNERBARREL_ActiveWafer_DeadLayerThickness / 2., INNERBARREL_ActiveWafer_Length / 2.); + G4Box* ActiveWaferShape = new G4Box("ActiveWaferShape", INNERBARREL_ActiveWafer_Width / 2., + INNERBARREL_PCB_Thickness / 2., INNERBARREL_ActiveWafer_Length / 2.); // Substracting the hole Shape from the Stock PCB - G4SubtractionSolid* PCB_1 = new G4SubtractionSolid("PCB_1", PCBFull, HoleShape, - new G4RotationMatrix,HoleShift); + G4SubtractionSolid* PCB_1 = new G4SubtractionSolid("PCB_1", PCBFull, HoleShape, new G4RotationMatrix, HoleShift); // Substracting the wafer space from the Stock PCB - G4SubtractionSolid* PCB = new G4SubtractionSolid("PCB", PCB_1, WaferShape, - new G4RotationMatrix, - G4ThreeVector(0,INNERBARREL_PCB_Thickness/2.-INNERBARREL_PCB_WaferDepth,0)); + G4SubtractionSolid* PCB = + new G4SubtractionSolid("PCB", PCB_1, WaferShape, new G4RotationMatrix, + G4ThreeVector(0, INNERBARREL_PCB_Thickness / 2. - INNERBARREL_PCB_WaferDepth, 0)); // Substract active part from inert part of the Wafer G4SubtractionSolid* InertWafer = new G4SubtractionSolid("InertWafer", InertWaferFull, ActiveWaferShape, - new G4RotationMatrix, - G4ThreeVector(0,0,0)); + new G4RotationMatrix, G4ThreeVector(0, 0, 0)); // Master Volume that encompass everything else - G4LogicalVolume* logicBarrelDetector = - new G4LogicalVolume(PCBFull,m_MaterialVacuum,"logicBoxDetector", 0, 0, 0); - logicBarrelDetector->SetVisAttributes(G4VisAttributes::Invisible); + G4LogicalVolume* logicBarrelDetector = new G4LogicalVolume(PCBFull, m_MaterialVacuum, "logicBoxDetector", 0, 0, 0); + logicBarrelDetector->SetVisAttributes(G4VisAttributes::GetInvisible()); // Sub Volume PCB - G4LogicalVolume* logicPCB = - new G4LogicalVolume(PCB,m_MaterialPCB,"logicPCB", 0, 0, 0); + G4LogicalVolume* logicPCB = new G4LogicalVolume(PCB, m_MaterialPCB, "logicPCB", 0, 0, 0); logicPCB->SetVisAttributes(PCBVisAtt); // Sub Volume Wafer - G4LogicalVolume* logicInertWafer = - new G4LogicalVolume(InertWafer,m_MaterialSilicon,"logicInertWafer", 0, 0, 0); + G4LogicalVolume* logicInertWafer = new G4LogicalVolume(InertWafer, m_MaterialSilicon, "logicInertWafer", 0, 0, 0); logicInertWafer->SetVisAttributes(GuardRingVisAtt); - G4LogicalVolume* logicActiveWafer = - new G4LogicalVolume(ActiveWafer,m_MaterialSilicon,"logicActiveWafer", 0, 0, 0); + G4LogicalVolume* logicActiveWafer = new G4LogicalVolume(ActiveWafer, m_MaterialSilicon, "logicActiveWafer", 0, 0, 0); logicActiveWafer->SetVisAttributes(SiliconVisAtt); G4LogicalVolume* logicDeadLayer = - new G4LogicalVolume(DeadLayer,m_MaterialSilicon,"logicActiveWaferDeadLayer", 0, 0, 0); + new G4LogicalVolume(DeadLayer, m_MaterialSilicon, "logicActiveWaferDeadLayer", 0, 0, 0); logicDeadLayer->SetVisAttributes(SiliconVisAtt); // Set the sensitive volume @@ -478,70 +453,59 @@ void Tiara::ConstructInnerBarrel(G4LogicalVolume* world){ // Place the sub volumes in the master volume // Last argument is the detector number, used in the scorer to get the // revelant information - new G4PVPlacement(new G4RotationMatrix(0,0,0), - G4ThreeVector(0,0,0), - logicPCB,"Tiara_Barrel_PCB",logicBarrelDetector, - false,0); + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), G4ThreeVector(0, 0, 0), logicPCB, "Tiara_Barrel_PCB", + logicBarrelDetector, false, 0); - G4ThreeVector WaferPosition(0, - 0.5*(INNERBARREL_PCB_Thickness+INNERBARREL_InertWafer_Thickness)-INNERBARREL_PCB_WaferDepth - ,0); + G4ThreeVector WaferPosition( + 0, 0.5 * (INNERBARREL_PCB_Thickness + INNERBARREL_InertWafer_Thickness) - INNERBARREL_PCB_WaferDepth, 0); - G4ThreeVector DeadLayerPositionF = WaferPosition + G4ThreeVector(0,-INNERBARREL_ActiveWafer_Thickness*0.5-INNERBARREL_ActiveWafer_DeadLayerThickness*0.5,0); + G4ThreeVector DeadLayerPositionF = + WaferPosition + + G4ThreeVector(0, -INNERBARREL_ActiveWafer_Thickness * 0.5 - INNERBARREL_ActiveWafer_DeadLayerThickness * 0.5, 0); - G4ThreeVector DeadLayerPositionB = WaferPosition + G4ThreeVector(0,INNERBARREL_ActiveWafer_Thickness*0.5+INNERBARREL_ActiveWafer_DeadLayerThickness*0.5,0); + G4ThreeVector DeadLayerPositionB = + WaferPosition + + G4ThreeVector(0, INNERBARREL_ActiveWafer_Thickness * 0.5 + INNERBARREL_ActiveWafer_DeadLayerThickness * 0.5, 0); + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), WaferPosition, logicActiveWafer, "Barrel_Wafer", logicBarrelDetector, + false, 0); + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), DeadLayerPositionF, logicDeadLayer, "Barrel_WaferDeadLayerFront", + logicBarrelDetector, false, 0); - new G4PVPlacement(new G4RotationMatrix(0,0,0), - WaferPosition, - logicActiveWafer,"Barrel_Wafer", - logicBarrelDetector,false,0); + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), DeadLayerPositionB, logicDeadLayer, "Barrel_WaferDeadLayerBack", + logicBarrelDetector, false, 0); - new G4PVPlacement(new G4RotationMatrix(0,0,0), - DeadLayerPositionF, - logicDeadLayer,"Barrel_WaferDeadLayerFront", - logicBarrelDetector,false,0); - - new G4PVPlacement(new G4RotationMatrix(0,0,0), - DeadLayerPositionB, - logicDeadLayer,"Barrel_WaferDeadLayerBack", - logicBarrelDetector,false,0); - - - new G4PVPlacement(new G4RotationMatrix(0,0,0), - WaferPosition, - logicInertWafer,"Barrel_Wafer_GuardRing", - logicBarrelDetector,false,0); + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), WaferPosition, logicInertWafer, "Barrel_Wafer_GuardRing", + logicBarrelDetector, false, 0); // 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 ++){ + G4double DistanceFromTarget = INNERBARREL_PCB_Width * (0.5 + sin(45 * deg)); + for (unsigned int i = 0; i < 8; i++) { // The following build the barrel, with detector one at the top // and going clowise looking upstrea // Detector are rotate by 45deg with each other // Detector 3 [i=2] is perpendicular to positive y-axis, Detector 5 [i=4] is perpendicular to positive x-axis, G4RotationMatrix* DetectorRotation = -//by Shuya 180521. This seems to give the right directio of Barrel geometry. Tentative. Wait to be comfirmed. - //new G4RotationMatrix(0*deg,0*deg,(360+(2-i)*45)*deg); - new G4RotationMatrix(0*deg,0*deg,(360+(2-i)*-45)*deg); + // by Shuya 180521. This seems to give the right directio of Barrel geometry. Tentative. Wait to be comfirmed. + // new G4RotationMatrix(0*deg,0*deg,(360+(2-i)*45)*deg); + new G4RotationMatrix(0 * deg, 0 * deg, (360 + (2 - i) * -45) * deg); // There center is also rotated by 45deg - G4ThreeVector DetectorPosition(0,DistanceFromTarget,0); -//by Shuya 180521. This seems to give the right directio of Barrel geometry. Tentative. Wait to be comfirmed. - //DetectorPosition.rotate((360+(2-i)*-45)*deg,G4ThreeVector(0,0,1)); - DetectorPosition.rotate((360+(2-i)*45)*deg,G4ThreeVector(0,0,1)); + G4ThreeVector DetectorPosition(0, DistanceFromTarget, 0); + // by Shuya 180521. This seems to give the right directio of Barrel geometry. Tentative. Wait to be comfirmed. + // DetectorPosition.rotate((360+(2-i)*-45)*deg,G4ThreeVector(0,0,1)); + DetectorPosition.rotate((360 + (2 - i) * 45) * deg, G4ThreeVector(0, 0, 1)); // Place the Master volume with its two daugther volume at the final place - new G4PVPlacement(G4Transform3D(*DetectorRotation,DetectorPosition), - logicBarrelDetector,"Tiara_InnerBarrel_Detector", - world,false,i+1); + new G4PVPlacement(G4Transform3D(*DetectorRotation, DetectorPosition), logicBarrelDetector, + "Tiara_InnerBarrel_Detector", world, false, i + 1); } } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Tiara::ConstructOuterBarrel(G4LogicalVolume* world){ +void Tiara::ConstructOuterBarrel(G4LogicalVolume* world) { // Tiara Outer Barrel // The outer Barrel is identical to the inner barrel but wider in terms of // geometry. It feature four non resistive strip on the front face @@ -549,91 +513,68 @@ void Tiara::ConstructOuterBarrel(G4LogicalVolume* world){ // Start by making a full pcb // We start by the definition of the point forming a PCB cross section vector<G4TwoVector> PCBCrossSection; - double l1 = OUTERBARREL_PCB_Thickness*0.5/tan(OUTERBARREL_PCB_Bevel1_Theta); - double l2 = OUTERBARREL_PCB_Thickness*0.5/tan(OUTERBARREL_PCB_Bevel2_Theta); + double l1 = OUTERBARREL_PCB_Thickness * 0.5 / tan(OUTERBARREL_PCB_Bevel1_Theta); + double l2 = OUTERBARREL_PCB_Thickness * 0.5 / tan(OUTERBARREL_PCB_Bevel2_Theta); - PCBCrossSection.push_back(G4TwoVector(OUTERBARREL_PCB_Width/2.-l2,-OUTERBARREL_PCB_Thickness*0.5)); - PCBCrossSection.push_back(G4TwoVector(OUTERBARREL_PCB_Width/2.,0)); - PCBCrossSection.push_back(G4TwoVector(OUTERBARREL_PCB_Width/2.-l1,OUTERBARREL_PCB_Thickness*0.5)); + PCBCrossSection.push_back(G4TwoVector(OUTERBARREL_PCB_Width / 2. - l2, -OUTERBARREL_PCB_Thickness * 0.5)); + PCBCrossSection.push_back(G4TwoVector(OUTERBARREL_PCB_Width / 2., 0)); + PCBCrossSection.push_back(G4TwoVector(OUTERBARREL_PCB_Width / 2. - l1, OUTERBARREL_PCB_Thickness * 0.5)); - PCBCrossSection.push_back(G4TwoVector(-OUTERBARREL_PCB_Width/2.+l1,OUTERBARREL_PCB_Thickness*0.5)); - PCBCrossSection.push_back(G4TwoVector(-OUTERBARREL_PCB_Width/2.,0)); - PCBCrossSection.push_back(G4TwoVector(-OUTERBARREL_PCB_Width/2.+l2,-OUTERBARREL_PCB_Thickness*0.5)); + PCBCrossSection.push_back(G4TwoVector(-OUTERBARREL_PCB_Width / 2. + l1, OUTERBARREL_PCB_Thickness * 0.5)); + PCBCrossSection.push_back(G4TwoVector(-OUTERBARREL_PCB_Width / 2., 0)); + PCBCrossSection.push_back(G4TwoVector(-OUTERBARREL_PCB_Width / 2. + l2, -OUTERBARREL_PCB_Thickness * 0.5)); - G4ExtrudedSolid* PCBFull = - new G4ExtrudedSolid("PCBFull", - PCBCrossSection, - OUTERBARREL_PCB_Length/2., - G4TwoVector(0,0),1, - G4TwoVector(0,0),1); + G4ExtrudedSolid* PCBFull = new G4ExtrudedSolid("PCBFull", PCBCrossSection, OUTERBARREL_PCB_Length / 2., + G4TwoVector(0, 0), 1, G4TwoVector(0, 0), 1); // A box having Wafer dimension but thicker than the PCB // Will be used to remove material from the PCB to have space for the wafer // Calculate the hole shift within the PCB - G4ThreeVector HoleShift = G4ThreeVector( - 0, - 0, - OUTERBARREL_PCB_Offset-(OUTERBARREL_PCB_Length/2-OUTERBARREL_PCB_HoleLength/2)); + G4ThreeVector HoleShift = + G4ThreeVector(0, 0, OUTERBARREL_PCB_Offset - (OUTERBARREL_PCB_Length / 2 - OUTERBARREL_PCB_HoleLength / 2)); - G4Box* HoleShape = new G4Box("HoleShape", - OUTERBARREL_ActiveWafer_Width/2., - OUTERBARREL_PCB_Thickness/2.+0.1*mm, - OUTERBARREL_PCB_HoleLength/2.); + G4Box* HoleShape = new G4Box("HoleShape", OUTERBARREL_ActiveWafer_Width / 2., + OUTERBARREL_PCB_Thickness / 2. + 0.1 * mm, OUTERBARREL_PCB_HoleLength / 2.); - G4Box* WaferShape = new G4Box("WaferShape", - OUTERBARREL_InertWafer_Width/2., - OUTERBARREL_PCB_Thickness/2., - OUTERBARREL_InertWafer_Length/2.); + G4Box* WaferShape = new G4Box("WaferShape", OUTERBARREL_InertWafer_Width / 2., OUTERBARREL_PCB_Thickness / 2., + OUTERBARREL_InertWafer_Length / 2.); // The Silicon Wafer itself - G4Box* InertWaferFull = new G4Box("InertWaferFull", - OUTERBARREL_InertWafer_Width/2., - OUTERBARREL_ActiveWafer_Thickness/2., - OUTERBARREL_InertWafer_Length/2.); + G4Box* InertWaferFull = new G4Box("InertWaferFull", OUTERBARREL_InertWafer_Width / 2., + OUTERBARREL_ActiveWafer_Thickness / 2., OUTERBARREL_InertWafer_Length / 2.); - G4Box* ActiveWafer = new G4Box("ActiveWafer", - OUTERBARREL_ActiveWafer_Width/2., - OUTERBARREL_ActiveWafer_Thickness/2., - OUTERBARREL_ActiveWafer_Length/2.); - - G4Box* ActiveWaferShape = new G4Box("ActiveWaferShape", - OUTERBARREL_ActiveWafer_Width/2., - OUTERBARREL_PCB_Thickness/2., - OUTERBARREL_ActiveWafer_Length/2.); + G4Box* ActiveWafer = new G4Box("ActiveWafer", OUTERBARREL_ActiveWafer_Width / 2., + OUTERBARREL_ActiveWafer_Thickness / 2., OUTERBARREL_ActiveWafer_Length / 2.); + G4Box* ActiveWaferShape = new G4Box("ActiveWaferShape", OUTERBARREL_ActiveWafer_Width / 2., + OUTERBARREL_PCB_Thickness / 2., OUTERBARREL_ActiveWafer_Length / 2.); // Substracting the hole Shape from the Stock PCB - G4SubtractionSolid* PCB_1 = new G4SubtractionSolid("PCB_1", PCBFull, HoleShape, - new G4RotationMatrix,HoleShift); + G4SubtractionSolid* PCB_1 = new G4SubtractionSolid("PCB_1", PCBFull, HoleShape, new G4RotationMatrix, HoleShift); // Substracting the wafer space from the Stock PCB - G4SubtractionSolid* PCB = new G4SubtractionSolid("PCB", PCB_1, WaferShape, - new G4RotationMatrix, - G4ThreeVector(0,OUTERBARREL_PCB_Thickness/2.-OUTERBARREL_PCB_WaferDepth,0)); + G4SubtractionSolid* PCB = + new G4SubtractionSolid("PCB", PCB_1, WaferShape, new G4RotationMatrix, + G4ThreeVector(0, OUTERBARREL_PCB_Thickness / 2. - OUTERBARREL_PCB_WaferDepth, 0)); // Substract active part from inert part of the Wafer G4SubtractionSolid* InertWafer = new G4SubtractionSolid("InertWafer", InertWaferFull, ActiveWaferShape, - new G4RotationMatrix, - G4ThreeVector(0,0,0)); + new G4RotationMatrix, G4ThreeVector(0, 0, 0)); // Master Volume that encompass everything else - G4LogicalVolume* logicBarrelDetector = - new G4LogicalVolume(PCBFull,m_MaterialVacuum,"logicBoxDetector", 0, 0, 0); - logicBarrelDetector->SetVisAttributes(G4VisAttributes::Invisible); + G4LogicalVolume* logicBarrelDetector = new G4LogicalVolume(PCBFull, m_MaterialVacuum, "logicBoxDetector", 0, 0, 0); + logicBarrelDetector->SetVisAttributes(G4VisAttributes::GetInvisible()); // Sub Volume PCB - G4LogicalVolume* logicPCB = - new G4LogicalVolume(PCB,m_MaterialPCB,"logicPCB", 0, 0, 0); + G4LogicalVolume* logicPCB = new G4LogicalVolume(PCB, m_MaterialPCB, "logicPCB", 0, 0, 0); logicPCB->SetVisAttributes(PCBVisAtt); // Sub Volume Wafer - G4LogicalVolume* logicInertWafer = - new G4LogicalVolume(InertWafer,m_MaterialSilicon,"logicInertWafer", 0, 0, 0); + G4LogicalVolume* logicInertWafer = new G4LogicalVolume(InertWafer, m_MaterialSilicon, "logicInertWafer", 0, 0, 0); logicInertWafer->SetVisAttributes(GuardRingVisAtt); - G4LogicalVolume* logicActiveWafer = - new G4LogicalVolume(ActiveWafer,m_MaterialSilicon,"logicActiveWafer", 0, 0, 0); + G4LogicalVolume* logicActiveWafer = new G4LogicalVolume(ActiveWafer, m_MaterialSilicon, "logicActiveWafer", 0, 0, 0); logicActiveWafer->SetVisAttributes(SiliconVisAtt); // Set the sensitive detector @@ -641,177 +582,135 @@ void Tiara::ConstructOuterBarrel(G4LogicalVolume* world){ // 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)) ; + G4double DistanceFromTarget = OUTERBARREL_PCB_Width * (0.5 + sin(45 * deg)); // Place the sub volumes in the master volume // Last argument is the detector number, used in the scorer to get the // revelant information - new G4PVPlacement(new G4RotationMatrix(0,0,0), - G4ThreeVector(0,0,0), - logicPCB,"Tiara_OuterBarrel_PCB",logicBarrelDetector, - false,0); - - - G4ThreeVector WaferPosition(0, - 0.5*(OUTERBARREL_PCB_Thickness+OUTERBARREL_ActiveWafer_Thickness)-OUTERBARREL_PCB_WaferDepth - ,0); + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), G4ThreeVector(0, 0, 0), logicPCB, "Tiara_OuterBarrel_PCB", + logicBarrelDetector, false, 0); - new G4PVPlacement(new G4RotationMatrix(0,0,0), - WaferPosition, - logicActiveWafer,"OuterBarrel_Wafer", - logicBarrelDetector,false,0); + G4ThreeVector WaferPosition( + 0, 0.5 * (OUTERBARREL_PCB_Thickness + OUTERBARREL_ActiveWafer_Thickness) - OUTERBARREL_PCB_WaferDepth, 0); - new G4PVPlacement(new G4RotationMatrix(0,0,0), - WaferPosition, - logicInertWafer,"OuterBarrel_Wafer_GuardRing", - logicBarrelDetector,false,0); + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), WaferPosition, logicActiveWafer, "OuterBarrel_Wafer", + logicBarrelDetector, false, 0); + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), WaferPosition, logicInertWafer, "OuterBarrel_Wafer_GuardRing", + logicBarrelDetector, false, 0); // The following build the barrel, with detector one at the top // and going clowise looking upstrea - for( unsigned int i = 0; i < 8; i ++){ + for (unsigned int i = 0; i < 8; i++) { // Detector are rotate by 45deg with each other - G4RotationMatrix* DetectorRotation = - new G4RotationMatrix(0*deg,0*deg,i*45*deg); + G4RotationMatrix* DetectorRotation = new G4RotationMatrix(0 * deg, 0 * deg, i * 45 * deg); // There center is also rotated by 45deg - G4ThreeVector DetectorPosition(0,DistanceFromTarget,0); - DetectorPosition.rotate(i*45*deg,G4ThreeVector(0,0,-1)); + G4ThreeVector DetectorPosition(0, DistanceFromTarget, 0); + DetectorPosition.rotate(i * 45 * deg, G4ThreeVector(0, 0, -1)); // Place the Master volume with its daugthers at the final place - new G4PVPlacement(G4Transform3D(*DetectorRotation,DetectorPosition), - logicBarrelDetector,"Tiara_OuterBarrel_Detector", - world,false,i+1); + new G4PVPlacement(G4Transform3D(*DetectorRotation, DetectorPosition), logicBarrelDetector, + "Tiara_OuterBarrel_Detector", world, false, i + 1); } - } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Tiara::ConstructHyball(G4LogicalVolume* world){ +void Tiara::ConstructHyball(G4LogicalVolume* world) { vector<G4TwoVector> PCBCrossSection; - PCBCrossSection.push_back(G4TwoVector(28.108*mm ,-14.551*mm)); - PCBCrossSection.push_back(G4TwoVector(128.808*mm,-66.683*mm)); - PCBCrossSection.push_back(G4TwoVector(163.618*mm,-30.343*mm)); - PCBCrossSection.push_back(G4TwoVector(163.618*mm, 30.941*mm)); - PCBCrossSection.push_back(G4TwoVector(125.718*mm, 73.677*mm)); - PCBCrossSection.push_back(G4TwoVector(28.108*mm , 16.473*mm)); - - G4ExtrudedSolid* PCBFull = - new G4ExtrudedSolid("PCBFull", - PCBCrossSection, - 0.5*HYBALL_PCB_THICKNESS, - G4TwoVector(0,0),1, - G4TwoVector(0,0),1); + PCBCrossSection.push_back(G4TwoVector(28.108 * mm, -14.551 * mm)); + PCBCrossSection.push_back(G4TwoVector(128.808 * mm, -66.683 * mm)); + PCBCrossSection.push_back(G4TwoVector(163.618 * mm, -30.343 * mm)); + PCBCrossSection.push_back(G4TwoVector(163.618 * mm, 30.941 * mm)); + PCBCrossSection.push_back(G4TwoVector(125.718 * mm, 73.677 * mm)); + PCBCrossSection.push_back(G4TwoVector(28.108 * mm, 16.473 * mm)); + + G4ExtrudedSolid* PCBFull = new G4ExtrudedSolid("PCBFull", PCBCrossSection, 0.5 * HYBALL_PCB_THICKNESS, + G4TwoVector(0, 0), 1, G4TwoVector(0, 0), 1); vector<G4TwoVector> WaferCrossSection; - WaferCrossSection.push_back(G4TwoVector(29.108*mm ,-13.943*mm )); - WaferCrossSection.push_back(G4TwoVector(123.022*mm,-62.561*mm )); - WaferCrossSection.push_back(G4TwoVector(137.00*mm ,-24.157*mm )); - WaferCrossSection.push_back(G4TwoVector(137.00*mm , 24.157*mm )); - WaferCrossSection.push_back(G4TwoVector(122.677*mm, 63.508*mm )); - WaferCrossSection.push_back(G4TwoVector(29.108*mm , 15.069*mm)); - - G4ExtrudedSolid* WaferFull = - new G4ExtrudedSolid("WaferFull", - WaferCrossSection, - 0.5*HYBALL_ActiveWafer_Thickness, - G4TwoVector(0,0),1, - G4TwoVector(0,0),1); - - G4ExtrudedSolid* WaferShape = - new G4ExtrudedSolid("WaferShape", - WaferCrossSection, - 0.6*HYBALL_PCB_THICKNESS, - G4TwoVector(0,0),1, - G4TwoVector(0,0),1); + WaferCrossSection.push_back(G4TwoVector(29.108 * mm, -13.943 * mm)); + WaferCrossSection.push_back(G4TwoVector(123.022 * mm, -62.561 * mm)); + WaferCrossSection.push_back(G4TwoVector(137.00 * mm, -24.157 * mm)); + WaferCrossSection.push_back(G4TwoVector(137.00 * mm, 24.157 * mm)); + WaferCrossSection.push_back(G4TwoVector(122.677 * mm, 63.508 * mm)); + WaferCrossSection.push_back(G4TwoVector(29.108 * mm, 15.069 * mm)); + + G4ExtrudedSolid* WaferFull = new G4ExtrudedSolid("WaferFull", WaferCrossSection, 0.5 * HYBALL_ActiveWafer_Thickness, + G4TwoVector(0, 0), 1, G4TwoVector(0, 0), 1); + + G4ExtrudedSolid* WaferShape = new G4ExtrudedSolid("WaferShape", WaferCrossSection, 0.6 * HYBALL_PCB_THICKNESS, + G4TwoVector(0, 0), 1, G4TwoVector(0, 0), 1); // Active Wafer G4Tubs* ActiveWafer = - new G4Tubs("HyballActiveWafer",HYBALL_ActiveWafer_InnerRadius, - HYBALL_ActiveWafer_OuterRadius,0.5*HYBALL_ActiveWafer_Thickness, - -0.5*HYBALL_ActiveWafer_Angle,HYBALL_ActiveWafer_Angle); + new G4Tubs("HyballActiveWafer", HYBALL_ActiveWafer_InnerRadius, HYBALL_ActiveWafer_OuterRadius, + 0.5 * HYBALL_ActiveWafer_Thickness, -0.5 * HYBALL_ActiveWafer_Angle, HYBALL_ActiveWafer_Angle); G4Tubs* ActiveWaferShape = - new G4Tubs("HyballActiveWaferShape",HYBALL_ActiveWafer_InnerRadius, - HYBALL_ActiveWafer_OuterRadius,0.6*HYBALL_ActiveWafer_Thickness, - -0.5*HYBALL_ActiveWafer_Angle,HYBALL_ActiveWafer_Angle); + new G4Tubs("HyballActiveWaferShape", HYBALL_ActiveWafer_InnerRadius, HYBALL_ActiveWafer_OuterRadius, + 0.6 * HYBALL_ActiveWafer_Thickness, -0.5 * HYBALL_ActiveWafer_Angle, HYBALL_ActiveWafer_Angle); - //by Shuya 180219. Hyball DeadLayer + // by Shuya 180219. Hyball DeadLayer G4Tubs* Hyball_DeadLayer = - new G4Tubs("HyballDeadLayer",HYBALL_ActiveWafer_InnerRadius, - HYBALL_ActiveWafer_OuterRadius,0.5*HYBALL_DeadLayer_Thickness, - -0.5*HYBALL_ActiveWafer_Angle,HYBALL_ActiveWafer_Angle); - + new G4Tubs("HyballDeadLayer", HYBALL_ActiveWafer_InnerRadius, HYBALL_ActiveWafer_OuterRadius, + 0.5 * HYBALL_DeadLayer_Thickness, -0.5 * HYBALL_ActiveWafer_Angle, HYBALL_ActiveWafer_Angle); // Substract Active Wafer from Wafer G4SubtractionSolid* InertWafer = new G4SubtractionSolid("Hyball_InertWafer", WaferFull, ActiveWaferShape, - new G4RotationMatrix(0,0,0),G4ThreeVector(0,0,0)); - + new G4RotationMatrix(0, 0, 0), G4ThreeVector(0, 0, 0)); // Substract Wafer shape from PCB - G4SubtractionSolid* PCB = new G4SubtractionSolid("Hyball_PCB", PCBFull, WaferShape, - new G4RotationMatrix,G4ThreeVector(0,0,0)); + G4SubtractionSolid* PCB = + new G4SubtractionSolid("Hyball_PCB", PCBFull, WaferShape, new G4RotationMatrix, G4ThreeVector(0, 0, 0)); // Logic Volume // // Logic Mother Volume - G4LogicalVolume* logicHyball = - new G4LogicalVolume(PCBFull,m_MaterialVacuum,"logicHyball", 0, 0, 0); - logicHyball->SetVisAttributes(G4VisAttributes::Invisible); + G4LogicalVolume* logicHyball = new G4LogicalVolume(PCBFull, m_MaterialVacuum, "logicHyball", 0, 0, 0); + logicHyball->SetVisAttributes(G4VisAttributes::GetInvisible()); // logic PCB - G4LogicalVolume* logicPCB = - new G4LogicalVolume(PCB,m_MaterialPCB,"logicPCB", 0, 0, 0); + G4LogicalVolume* logicPCB = new G4LogicalVolume(PCB, m_MaterialPCB, "logicPCB", 0, 0, 0); logicPCB->SetVisAttributes(PCBVisAtt); // logic Inert Wafer - G4LogicalVolume* logicIW = - new G4LogicalVolume(InertWafer,m_MaterialSilicon,"logicIW", 0, 0, 0); + G4LogicalVolume* logicIW = new G4LogicalVolume(InertWafer, m_MaterialSilicon, "logicIW", 0, 0, 0); logicIW->SetVisAttributes(GuardRingVisAtt); // logic Active Wafer - G4LogicalVolume* logicAW = - new G4LogicalVolume(ActiveWafer,m_MaterialSilicon,"logicAW", 0, 0, 0); + G4LogicalVolume* logicAW = new G4LogicalVolume(ActiveWafer, m_MaterialSilicon, "logicAW", 0, 0, 0); logicAW->SetVisAttributes(SiliconVisAtt); logicAW->SetSensitiveDetector(m_HyballScorer); - //by Shuya 180219 - // logic Hyball DeadLayer - G4LogicalVolume* logicDL = - new G4LogicalVolume(Hyball_DeadLayer,m_MaterialSilicon,"logicDL", 0, 0, 0); + // by Shuya 180219 + // logic Hyball DeadLayer + G4LogicalVolume* logicDL = new G4LogicalVolume(Hyball_DeadLayer, m_MaterialSilicon, "logicDL", 0, 0, 0); logicDL->SetVisAttributes(SiliconVisAtt); // Place all the Piece in the mother volume - new G4PVPlacement(new G4RotationMatrix(0,0,0), - G4ThreeVector(0,0,0), - logicPCB,"Hyball_PCB", - logicHyball,false,0); - - new G4PVPlacement(new G4RotationMatrix(0,0,0), - G4ThreeVector(0,0,0), - logicIW,"Hyball_InertWafer", - logicHyball,false,0); - - new G4PVPlacement(new G4RotationMatrix(0,0,0), - G4ThreeVector(0,0,0), - logicAW,"Hyball_ActiveWafer", - logicHyball,false,0); - - //by Shuya 180219. Note beacause Hyball is placed in negative direction (such as -147 mm) in world coordinate, deadlayer (front side) positions must be added in positive direction. - new G4PVPlacement(new G4RotationMatrix(0,0,0), - G4ThreeVector(0,0,0.5*HYBALL_ActiveWafer_Thickness+0.5*HYBALL_DeadLayer_Thickness), - logicDL,"Hyball_DeadLayer", - logicHyball,false,0); - - for(unsigned int i = 0 ; i < m_HyballZ.size() ; i++){ + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), G4ThreeVector(0, 0, 0), logicPCB, "Hyball_PCB", logicHyball, false, + 0); + + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), G4ThreeVector(0, 0, 0), logicIW, "Hyball_InertWafer", logicHyball, + false, 0); + + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), G4ThreeVector(0, 0, 0), logicAW, "Hyball_ActiveWafer", logicHyball, + false, 0); + + // by Shuya 180219. Note beacause Hyball is placed in negative direction (such as -147 mm) in world coordinate, + // deadlayer (front side) positions must be added in positive direction. + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), + G4ThreeVector(0, 0, 0.5 * HYBALL_ActiveWafer_Thickness + 0.5 * HYBALL_DeadLayer_Thickness), logicDL, + "Hyball_DeadLayer", logicHyball, false, 0); + + for (unsigned int i = 0; i < m_HyballZ.size(); i++) { // Place mother volume - new G4PVPlacement(new G4RotationMatrix(0,0,m_HyballPhi[i]), - G4ThreeVector(0,0,m_HyballZ[i]), - logicHyball,"Hyball", - world,false,i+1); + new G4PVPlacement(new G4RotationMatrix(0, 0, m_HyballPhi[i]), G4ThreeVector(0, 0, m_HyballZ[i]), logicHyball, + "Hyball", world, false, i + 1); } } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Tiara::ConstructChamber(G4LogicalVolume* world){ +void Tiara::ConstructChamber(G4LogicalVolume* world) { // Vaccum Chamber of Tiara // The chamber is made of a central cylinder surrounding the barrel Si // Two Cone that expeand out of the central cylinder to let room for Exogam @@ -825,61 +724,52 @@ void Tiara::ConstructChamber(G4LogicalVolume* world){ // Central Tube G4Tubs* solidCentralTube = - new G4Tubs("TiaraChamberCentralTube",CHAMBER_CentralTube_Inner_Radius, - CHAMBER_CentralTube_Outer_Radius,CHAMBER_CentralTube_Length/2., - 0*deg,360*deg); + new G4Tubs("TiaraChamberCentralTube", CHAMBER_CentralTube_Inner_Radius, CHAMBER_CentralTube_Outer_Radius, + CHAMBER_CentralTube_Length / 2., 0 * deg, 360 * deg); // Forward-Backward Cones G4Cons* solidOuterCone = - new G4Cons("TiaraChamberOuterCone",CHAMBER_CentralTube_Inner_Radius, - CHAMBER_CentralTube_Outer_Radius,CHAMBER_OuterCylinder_Inner_Radius, - CHAMBER_OuterCylinder_Outer_Radius,CHAMBER_OuterCone_Length/2., - 0*deg,360*deg); + new G4Cons("TiaraChamberOuterCone", CHAMBER_CentralTube_Inner_Radius, CHAMBER_CentralTube_Outer_Radius, + CHAMBER_OuterCylinder_Inner_Radius, CHAMBER_OuterCylinder_Outer_Radius, CHAMBER_OuterCone_Length / 2., + 0 * deg, 360 * deg); // Outer Cylinder G4Tubs* solidOuterCylinder = - new G4Tubs("TiaraChamberOuterCylinder",CHAMBER_OuterCylinder_Inner_Radius, - CHAMBER_OuterCylinder_Outer_Radius,CHAMBER_OuterCylinder_Length/2., - 0*deg,360*deg); + new G4Tubs("TiaraChamberOuterCylinder", CHAMBER_OuterCylinder_Inner_Radius, CHAMBER_OuterCylinder_Outer_Radius, + CHAMBER_OuterCylinder_Length / 2., 0 * deg, 360 * deg); // Add the volume together G4UnionSolid* solidTiaraChamberStep1 = - new G4UnionSolid("TiaraChamber", solidCentralTube, solidOuterCone, - new G4RotationMatrix, - G4ThreeVector(0,0,CHAMBER_OuterCone_Z_Pos)); + new G4UnionSolid("TiaraChamber", solidCentralTube, solidOuterCone, new G4RotationMatrix, + G4ThreeVector(0, 0, CHAMBER_OuterCone_Z_Pos)); G4UnionSolid* solidTiaraChamberStep2 = - new G4UnionSolid("TiaraChamber", solidTiaraChamberStep1, solidOuterCone, - new G4RotationMatrix(0,180*deg,0), - G4ThreeVector(0,0,-CHAMBER_OuterCone_Z_Pos)); + new G4UnionSolid("TiaraChamber", solidTiaraChamberStep1, solidOuterCone, new G4RotationMatrix(0, 180 * deg, 0), + G4ThreeVector(0, 0, -CHAMBER_OuterCone_Z_Pos)); G4UnionSolid* solidTiaraChamberStep3 = - new G4UnionSolid("TiaraChamber", solidTiaraChamberStep2, solidOuterCylinder, - new G4RotationMatrix, - G4ThreeVector(0,0,CHAMBER_OuterCylinder_Z_Pos)); + new G4UnionSolid("TiaraChamber", solidTiaraChamberStep2, solidOuterCylinder, new G4RotationMatrix, + G4ThreeVector(0, 0, CHAMBER_OuterCylinder_Z_Pos)); G4UnionSolid* solidTiaraChamberStep4 = - new G4UnionSolid("TiaraChamber", solidTiaraChamberStep3, solidOuterCylinder, - new G4RotationMatrix, - G4ThreeVector(0,0,-CHAMBER_OuterCylinder_Z_Pos)); + new G4UnionSolid("TiaraChamber", solidTiaraChamberStep3, solidOuterCylinder, new G4RotationMatrix, + G4ThreeVector(0, 0, -CHAMBER_OuterCylinder_Z_Pos)); // Create Logic Volume G4LogicalVolume* logicTiaraChamber = - new G4LogicalVolume(solidTiaraChamberStep4,m_MaterialAl,"logicTiaraChamber", 0, 0, 0); + new G4LogicalVolume(solidTiaraChamberStep4, m_MaterialAl, "logicTiaraChamber", 0, 0, 0); // Visual Attribute - G4VisAttributes* ChamberVisAtt - = new G4VisAttributes(G4Colour(0.0,0.4,0.5,0.2)); + G4VisAttributes* ChamberVisAtt = new G4VisAttributes(G4Colour(0.0, 0.4, 0.5, 0.2)); logicTiaraChamber->SetVisAttributes(ChamberVisAtt); // Place the whole chamber - new G4PVPlacement(new G4RotationMatrix(0,0,0), G4ThreeVector(0,0,0), - logicTiaraChamber,"TiaraChamber",world,false,0); - + new G4PVPlacement(new G4RotationMatrix(0, 0, 0), G4ThreeVector(0, 0, 0), logicTiaraChamber, "TiaraChamber", world, + false, 0); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Tiara::InitializeMaterial(){ +void Tiara::InitializeMaterial() { m_MaterialSilicon = MaterialManager::getInstance()->GetMaterialFromLibrary("Si"); m_MaterialAl = MaterialManager::getInstance()->GetMaterialFromLibrary("Al"); m_MaterialPCB = MaterialManager::getInstance()->GetMaterialFromLibrary("PCB"); @@ -889,20 +779,18 @@ void Tiara::InitializeMaterial(){ //////////////////////////////////////////////////////////////////////////////// // Construct Method to be pass to the DetectorFactory // //////////////////////////////////////////////////////////////////////////////// -NPS::VDetector* Tiara::Construct(){ - return (NPS::VDetector*) new Tiara(); -} +NPS::VDetector* Tiara::Construct() { return (NPS::VDetector*)new Tiara(); } //////////////////////////////////////////////////////////////////////////////// // Registering the construct method to the factory // //////////////////////////////////////////////////////////////////////////////// -extern "C"{ -class proxy_nps_tiara{ - public: - proxy_nps_tiara(){ - NPS::DetectorFactory::getInstance()->AddToken("Tiara","Tiara"); - NPS::DetectorFactory::getInstance()->AddDetector("Tiara",Tiara::Construct); - } +extern "C" { +class proxy_nps_tiara { + public: + proxy_nps_tiara() { + NPS::DetectorFactory::getInstance()->AddToken("Tiara", "Tiara"); + NPS::DetectorFactory::getInstance()->AddDetector("Tiara", Tiara::Construct); + } }; proxy_nps_tiara p_nps_tiara; diff --git a/NPSimulation/Detectors/Tigress/Tigress.cc b/NPSimulation/Detectors/Tigress/Tigress.cc index 2e73ef568e6d948be7a21619e4fee563c4a240d2..10339bea22d875e99a11e22f658f4afd734aa42f 100644 --- a/NPSimulation/Detectors/Tigress/Tigress.cc +++ b/NPSimulation/Detectors/Tigress/Tigress.cc @@ -20,44 +20,43 @@ *****************************************************************************/ // C++ headers -#include <sstream> #include <cmath> #include <limits> -//G4 Geometry object +#include <sstream> +// G4 Geometry object #include "G4Box.hh" -#include "G4Tubs.hh" -#include "G4Trd.hh" -#include "G4Trap.hh" #include "G4Cons.hh" +#include "G4Trap.hh" +#include "G4Trd.hh" +#include "G4Tubs.hh" -//G4 sensitive -#include "G4SDManager.hh" +// G4 sensitive #include "G4MultiFunctionalDetector.hh" +#include "G4SDManager.hh" -//G4 various object +// G4 various object +#include "G4Colour.hh" +#include "G4IntersectionSolid.hh" +#include "G4LogicalVolume.hh" #include "G4Material.hh" +#include "G4PVPlacement.hh" #include "G4Polycone.hh" #include "G4Polyhedra.hh" -#include "G4LogicalVolume.hh" -#include "G4ThreeVector.hh" -#include "G4Transform3D.hh" #include "G4RotationMatrix.hh" -#include "G4PVPlacement.hh" -#include "G4VisAttributes.hh" -#include "G4Colour.hh" #include "G4RunManager.hh" -#include "G4ios.hh" #include "G4SubtractionSolid.hh" -#include "G4IntersectionSolid.hh" -#include "G4UnionSolid.hh" #include "G4ThreeVector.hh" +#include "G4Transform3D.hh" +#include "G4UnionSolid.hh" +#include "G4VisAttributes.hh" +#include "G4ios.hh" // NPS -#include "Tigress.hh" -#include "TigressScorers.hh" #include "MaterialManager.hh" #include "NPSDetectorFactory.hh" #include "NPSHitsMap.hh" +#include "Tigress.hh" +#include "TigressScorers.hh" // NPL #include "NPOptionManager.h" @@ -75,92 +74,89 @@ namespace { // Ge crystal // Cylindrical part - const G4double CrystalOuterRadius = 30.0*mm; // outer radius for crystal - const G4double CrystalInnerRadius = 5.0*mm; // inner radius for hole in crystal - const G4double CrystalLength = 90.0*mm; // crystal length - const G4double CrystalHoleDepth = 15.0*mm; // depth at which starts the hole - //const G4double CrystaHoleRadius = 0*cm; - //const G4double CrystalInterDistance = 0.6*mm; // Distance between two crystal + const G4double CrystalOuterRadius = 30.0 * mm; // outer radius for crystal + const G4double CrystalInnerRadius = 5.0 * mm; // inner radius for hole in crystal + const G4double CrystalLength = 90.0 * mm; // crystal length + const G4double CrystalHoleDepth = 15.0 * mm; // depth at which starts the hole + // const G4double CrystaHoleRadius = 0*cm; + // const G4double CrystalInterDistance = 0.6*mm; // Distance between two crystal // Squared part - const G4double CrystalWidth = 56.5*mm; // Width of one crystal + const G4double CrystalWidth = 56.5 * mm; // Width of one crystal // Exogam Stuff - const G4double CrystalEdgeOffset1 = 26.0*mm; // distance of the edge from the center of the crystal - const G4double CrystalEdgeOffset2 = 28.5*mm; // distance of the edge from the center of the crystal + const G4double CrystalEdgeOffset1 = 26.0 * mm; // distance of the edge from the center of the crystal + const G4double CrystalEdgeOffset2 = 28.5 * mm; // distance of the edge from the center of the crystal - const G4double CapsuleWidth = 1.5*mm; // capsule width - const G4double CapsuleLength = 110.*mm; // capsule length - const G4double CapsuleEdgeDepth = 3.3*cm; // same as crystal ! - const G4double CrystalToCapsule = 7*mm; // to be adjusted .. + const G4double CapsuleWidth = 1.5 * mm; // capsule width + const G4double CapsuleLength = 110. * mm; // capsule length + const G4double CapsuleEdgeDepth = 3.3 * cm; // same as crystal ! + const G4double CrystalToCapsule = 7 * mm; // to be adjusted .. - //const G4double BGOLength = 120.0*mm; - //const G4double BGOWidth = 25.0*mm; + // const G4double BGOLength = 120.0*mm; + // const G4double BGOWidth = 25.0*mm; - //const G4double CsILength = 20.0*mm; -} + // const G4double CsILength = 20.0*mm; +} // namespace //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Tigress Specific Method -Tigress::Tigress(){ +Tigress::Tigress() { InitializeMaterial(); m_TigressData = new TTigressData(); - BlueVisAtt = new G4VisAttributes(G4Colour(0, 0, 1)) ; - GreenVisAtt = new G4VisAttributes(G4Colour(0, 1, 0)) ; - RedVisAtt = new G4VisAttributes(G4Colour(1, 0, 0)) ; - WhiteVisAtt = new G4VisAttributes(G4Colour(1, 1, 1)) ; - TrGreyVisAtt = new G4VisAttributes(G4Colour(0.5, 0.5, 0.5, 0.5)) ; + BlueVisAtt = new G4VisAttributes(G4Colour(0, 0, 1)); + GreenVisAtt = new G4VisAttributes(G4Colour(0, 1, 0)); + RedVisAtt = new G4VisAttributes(G4Colour(1, 0, 0)); + WhiteVisAtt = new G4VisAttributes(G4Colour(1, 1, 1)); + TrGreyVisAtt = new G4VisAttributes(G4Colour(0.5, 0.5, 0.5, 0.5)); m_LogicClover = 0; - } -Tigress::~Tigress(){ - delete m_MaterialVacuum; -} +Tigress::~Tigress() { delete m_MaterialVacuum; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Virtual Method of NPS::VDetector class // Read stream at Configfile to pick-up parameters of detector (Position,...) // Called in DetecorConstruction::ReadDetextorConfiguration Method -void Tigress::ReadConfiguration(NPL::InputParser parser){ - - vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithTokenAndValue("Tigress","Clover"); - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << "//// " << blocks.size() << " free clovers found " << endl; - - vector<string> token = {"CloverID","R","Theta","Phi","Beta"}; - - for(unsigned int i = 0 ; i < blocks.size() ; i++){ - if(blocks[i]->HasTokenList(token)){ - double R = blocks[i]->GetDouble("R","mm"); - double Theta = blocks[i]->GetDouble("Theta","deg"); - double Phi = blocks[i]->GetDouble("Phi","deg"); - vector<double> beta = blocks[i]->GetVectorDouble("Beta","deg"); - int id = blocks[i]->GetInt("CloverID"); - AddCloverFreePosition(id,R,Theta,Phi,beta[0],beta[1],beta[2]); +void Tigress::ReadConfiguration(NPL::InputParser parser) { + + vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithTokenAndValue("Tigress", "Clover"); + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks.size() << " free clovers found " << endl; + + vector<string> token = {"CloverID", "R", "Theta", "Phi", "Beta"}; + + for (unsigned int i = 0; i < blocks.size(); i++) { + if (blocks[i]->HasTokenList(token)) { + double R = blocks[i]->GetDouble("R", "mm"); + double Theta = blocks[i]->GetDouble("Theta", "deg"); + double Phi = blocks[i]->GetDouble("Phi", "deg"); + vector<double> beta = blocks[i]->GetVectorDouble("Beta", "deg"); + int id = blocks[i]->GetInt("CloverID"); + AddCloverFreePosition(id, R, Theta, Phi, beta[0], beta[1], beta[2]); } - else{ + else { cout << "Warning: check your input file formatting " << endl; } } blocks.clear(); - blocks = parser.GetAllBlocksWithTokenAndValue("Tigress","Standard"); - token.clear(); + blocks = parser.GetAllBlocksWithTokenAndValue("Tigress", "Standard"); + token.clear(); token = {"CloverID"}; - for(unsigned int i = 0 ; i < blocks.size() ; i++){ - if(blocks[i]->HasTokenList(token)){ - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << "//// Standard clovers found " << endl; + for (unsigned int i = 0; i < blocks.size(); i++) { + if (blocks[i]->HasTokenList(token)) { + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// Standard clovers found " << endl; vector<int> id = blocks[i]->GetVectorInt("CloverID"); - + AddCloverStandard(id); } - else{ + else { cout << "Warning: check your input file formatting " << endl; } } @@ -168,177 +164,175 @@ void Tigress::ReadConfiguration(NPL::InputParser parser){ //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Return a G4VSolid modeling the Crystal -G4LogicalVolume* Tigress::ConstructCrystal(){ - G4Tubs* Crystal_Cylinder = new G4Tubs("Crystal_Cylinder", 0, CrystalOuterRadius, CrystalLength*0.5, 0, 2*M_PI); +G4LogicalVolume* Tigress::ConstructCrystal() { + G4Tubs* Crystal_Cylinder = new G4Tubs("Crystal_Cylinder", 0, CrystalOuterRadius, CrystalLength * 0.5, 0, 2 * M_PI); // Central Hole for cold finger - G4RotationMatrix* BoxRotation = new G4RotationMatrix(0,0,0); - G4Tubs* Crystal_Hole = new G4Tubs("Crystal_Hole", 0, CrystalInnerRadius, (CrystalLength-CrystalHoleDepth)*0.5, 0, 2*M_PI); - G4SubtractionSolid* Crystal_Stage1 = new G4SubtractionSolid("Crystal_Stage1",Crystal_Cylinder,Crystal_Hole,BoxRotation,G4ThreeVector(0,0,CrystalHoleDepth)); + G4RotationMatrix* BoxRotation = new G4RotationMatrix(0, 0, 0); + G4Tubs* Crystal_Hole = + new G4Tubs("Crystal_Hole", 0, CrystalInnerRadius, (CrystalLength - CrystalHoleDepth) * 0.5, 0, 2 * M_PI); + G4SubtractionSolid* Crystal_Stage1 = new G4SubtractionSolid("Crystal_Stage1", Crystal_Cylinder, Crystal_Hole, + BoxRotation, G4ThreeVector(0, 0, CrystalHoleDepth)); // Flat surface on the side - G4Box* Crystal_Box1 = new G4Box("Crystal_Box1", CrystalWidth*0.6, CrystalWidth*0.6,CrystalLength*0.6); - G4SubtractionSolid* Crystal_Stage2 = new G4SubtractionSolid("Crystal_Stage2",Crystal_Stage1,Crystal_Box1,BoxRotation,G4ThreeVector(24.5+CrystalWidth*0.6,0,0)); - G4SubtractionSolid* Crystal_Stage3 = new G4SubtractionSolid("Crystal_Stage3",Crystal_Stage2,Crystal_Box1,BoxRotation,G4ThreeVector(-29-CrystalWidth*0.6,0,0)); - G4SubtractionSolid* Crystal_Stage4 = new G4SubtractionSolid("Crystal_Stage4",Crystal_Stage3,Crystal_Box1,BoxRotation,G4ThreeVector(0,29+CrystalWidth*0.6,0)); - G4SubtractionSolid* Crystal_Stage5 = new G4SubtractionSolid("Crystal_Stage5",Crystal_Stage4,Crystal_Box1,BoxRotation,G4ThreeVector(0,-24.5-CrystalWidth*0.6,0)); + G4Box* Crystal_Box1 = new G4Box("Crystal_Box1", CrystalWidth * 0.6, CrystalWidth * 0.6, CrystalLength * 0.6); + G4SubtractionSolid* Crystal_Stage2 = new G4SubtractionSolid( + "Crystal_Stage2", Crystal_Stage1, Crystal_Box1, BoxRotation, G4ThreeVector(24.5 + CrystalWidth * 0.6, 0, 0)); + G4SubtractionSolid* Crystal_Stage3 = new G4SubtractionSolid( + "Crystal_Stage3", Crystal_Stage2, Crystal_Box1, BoxRotation, G4ThreeVector(-29 - CrystalWidth * 0.6, 0, 0)); + G4SubtractionSolid* Crystal_Stage4 = new G4SubtractionSolid( + "Crystal_Stage4", Crystal_Stage3, Crystal_Box1, BoxRotation, G4ThreeVector(0, 29 + CrystalWidth * 0.6, 0)); + G4SubtractionSolid* Crystal_Stage5 = new G4SubtractionSolid( + "Crystal_Stage5", Crystal_Stage4, Crystal_Box1, BoxRotation, G4ThreeVector(0, -24.5 - CrystalWidth * 0.6, 0)); // Bezel - G4RotationMatrix* BoxRotation1 = new G4RotationMatrix(0,0,0); - BoxRotation1->rotate(22.5*deg,G4ThreeVector(1,0,0)); - G4SubtractionSolid* Crystal_Stage6= new G4SubtractionSolid("Crystal_Stage6",Crystal_Stage5,Crystal_Box1,BoxRotation1,G4ThreeVector(0,20.54*mm+CrystalWidth*0.6,-45*mm)); - - G4RotationMatrix* BoxRotation2 = new G4RotationMatrix(0,0,0); - BoxRotation2->rotate(22.5*deg,G4ThreeVector(0,1,0)); - G4SubtractionSolid* Crystal_Stage7= new G4SubtractionSolid("Crystal_Stage7",Crystal_Stage6,Crystal_Box1,BoxRotation2,G4ThreeVector(-20.54*mm-CrystalWidth*0.6,0,-45*mm)); - - G4LogicalVolume* logicCrystal = - new G4LogicalVolume(Crystal_Stage7,m_MaterialGe,"LogicCrystal", 0, 0, 0); - - return logicCrystal; + G4RotationMatrix* BoxRotation1 = new G4RotationMatrix(0, 0, 0); + BoxRotation1->rotate(22.5 * deg, G4ThreeVector(1, 0, 0)); + G4SubtractionSolid* Crystal_Stage6 = + new G4SubtractionSolid("Crystal_Stage6", Crystal_Stage5, Crystal_Box1, BoxRotation1, + G4ThreeVector(0, 20.54 * mm + CrystalWidth * 0.6, -45 * mm)); + + G4RotationMatrix* BoxRotation2 = new G4RotationMatrix(0, 0, 0); + BoxRotation2->rotate(22.5 * deg, G4ThreeVector(0, 1, 0)); + G4SubtractionSolid* Crystal_Stage7 = + new G4SubtractionSolid("Crystal_Stage7", Crystal_Stage6, Crystal_Box1, BoxRotation2, + G4ThreeVector(-20.54 * mm - CrystalWidth * 0.6, 0, -45 * mm)); + + G4LogicalVolume* logicCrystal = new G4LogicalVolume(Crystal_Stage7, m_MaterialGe, "LogicCrystal", 0, 0, 0); + + return logicCrystal; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Return a G4VSolid modeling the Capsule -G4LogicalVolume* Tigress::ConstructCapsule(){ +G4LogicalVolume* Tigress::ConstructCapsule() { G4int nbslice = 7; - const G4double widthface = 45.5*mm; - G4double zSlice[7] = { 0.0*mm, - CapsuleWidth-0.1*mm, - CapsuleWidth, - CapsuleEdgeDepth, - CapsuleLength-CapsuleWidth, - CapsuleLength-CapsuleWidth-0.1*mm, - CapsuleLength }; - - G4double InnNullRad[7] = {0,0,0,0,0,0,0}; - - G4double InnRad[7] = { 0.0*mm, - 0.0*mm, - widthface-CapsuleWidth, - CrystalEdgeOffset1 + CrystalEdgeOffset2 + CrystalToCapsule - CapsuleWidth, - CrystalEdgeOffset1 + CrystalEdgeOffset2 + CrystalToCapsule - CapsuleWidth, - 0.0*mm, - 0.0*mm}; - - G4double OutRad[7] = { widthface-1.5*mm, - widthface, - widthface, - CrystalEdgeOffset1 + CrystalEdgeOffset2 + CrystalToCapsule, - CrystalEdgeOffset1 + CrystalEdgeOffset2 + CrystalToCapsule, - CrystalEdgeOffset1 + CrystalEdgeOffset2 + CrystalToCapsule, - CrystalEdgeOffset1 + CrystalEdgeOffset2 + CrystalToCapsule}; + const G4double widthface = 45.5 * mm; + G4double zSlice[7] = {0.0 * mm, CapsuleWidth - 0.1 * mm, CapsuleWidth, + CapsuleEdgeDepth, CapsuleLength - CapsuleWidth, CapsuleLength - CapsuleWidth - 0.1 * mm, + CapsuleLength}; + + G4double InnNullRad[7] = {0, 0, 0, 0, 0, 0, 0}; + + G4double InnRad[7] = {0.0 * mm, + 0.0 * mm, + widthface - CapsuleWidth, + CrystalEdgeOffset1 + CrystalEdgeOffset2 + CrystalToCapsule - CapsuleWidth, + CrystalEdgeOffset1 + CrystalEdgeOffset2 + CrystalToCapsule - CapsuleWidth, + 0.0 * mm, + 0.0 * mm}; + + G4double OutRad[7] = {widthface - 1.5 * mm, + widthface, + widthface, + CrystalEdgeOffset1 + CrystalEdgeOffset2 + CrystalToCapsule, + CrystalEdgeOffset1 + CrystalEdgeOffset2 + CrystalToCapsule, + CrystalEdgeOffset1 + CrystalEdgeOffset2 + CrystalToCapsule, + CrystalEdgeOffset1 + CrystalEdgeOffset2 + CrystalToCapsule}; // The whole volume of the Capsule, made of N2 - G4Polyhedra* caps = new G4Polyhedra(G4String("Capsule"), 45.*deg, 360.*deg, 4, nbslice, zSlice, InnNullRad, OutRad); - G4LogicalVolume* LogicCapsule= - new G4LogicalVolume(caps,m_MaterialN2,"LogicCapsule", 0, 0, 0); - LogicCapsule->SetVisAttributes(G4VisAttributes::Invisible); + G4Polyhedra* caps = + new G4Polyhedra(G4String("Capsule"), 45. * deg, 360. * deg, 4, nbslice, zSlice, InnNullRad, OutRad); + G4LogicalVolume* LogicCapsule = new G4LogicalVolume(caps, m_MaterialN2, "LogicCapsule", 0, 0, 0); + LogicCapsule->SetVisAttributes(G4VisAttributes::GetInvisible()); // The wall of the Capsule made of Al - G4Polyhedra* capsWall = new G4Polyhedra(G4String("CapsuleWall"), 45.*deg, 360.*deg, 4, nbslice, zSlice, InnRad, OutRad); - G4LogicalVolume* logicCapsuleWall = - new G4LogicalVolume(capsWall,m_MaterialAl,"LogicCapsuleWall", 0, 0, 0); + G4Polyhedra* capsWall = + new G4Polyhedra(G4String("CapsuleWall"), 45. * deg, 360. * deg, 4, nbslice, zSlice, InnRad, OutRad); + G4LogicalVolume* logicCapsuleWall = new G4LogicalVolume(capsWall, m_MaterialAl, "LogicCapsuleWall", 0, 0, 0); - new G4PVPlacement(G4Transform3D(*(new G4RotationMatrix()), G4ThreeVector(0,0,0)), - logicCapsuleWall,"CapsuleWall",LogicCapsule,false,1); + new G4PVPlacement(G4Transform3D(*(new G4RotationMatrix()), G4ThreeVector(0, 0, 0)), logicCapsuleWall, "CapsuleWall", + LogicCapsule, false, 1); logicCapsuleWall->SetVisAttributes(TrGreyVisAtt); return LogicCapsule; - } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -G4LogicalVolume* Tigress::ConstructDewar(){ - G4Tubs* DewarSolid = new G4Tubs("DewarSolid",0,90*mm*0.5,90*mm*0.5,0,2*M_PI); - G4Tubs* DewarCFSolid = new G4Tubs("DewarCFSolid",0,45*mm*0.5,145*mm*0.5,0,2*M_PI); +G4LogicalVolume* Tigress::ConstructDewar() { + G4Tubs* DewarSolid = new G4Tubs("DewarSolid", 0, 90 * mm * 0.5, 90 * mm * 0.5, 0, 2 * M_PI); + G4Tubs* DewarCFSolid = new G4Tubs("DewarCFSolid", 0, 45 * mm * 0.5, 145 * mm * 0.5, 0, 2 * M_PI); + + G4UnionSolid* DewarFull = new G4UnionSolid("Dewarfull", DewarSolid, DewarCFSolid, new G4RotationMatrix(), + G4ThreeVector(0, 0, -90 * mm - (145 - 90) * 0.5 * mm)); - G4UnionSolid* DewarFull = - new G4UnionSolid("Dewarfull", DewarSolid, DewarCFSolid, new G4RotationMatrix(),G4ThreeVector(0,0,-90*mm-(145-90)*0.5*mm)); + G4LogicalVolume* LogicDewar = new G4LogicalVolume(DewarFull, m_MaterialAl, "LogicDewar", 0, 0, 0); - G4LogicalVolume* LogicDewar = new G4LogicalVolume(DewarFull,m_MaterialAl,"LogicDewar",0,0,0); + G4Tubs* N2Solid = new G4Tubs("N2Solid", 0, 90 * mm * 0.5 - 1 * mm, 90 * mm * 0.5 - 1 * mm, 0, 2 * M_PI); + G4Tubs* N2CFSolid = new G4Tubs("N2CFSolid", 0, 45 * mm * 0.5 - 1 * mm, 145 * mm * 0.5 - 1 * mm, 0, 2 * M_PI); - G4Tubs* N2Solid = new G4Tubs("N2Solid",0,90*mm*0.5-1*mm,90*mm*0.5-1*mm,0,2*M_PI); - G4Tubs* N2CFSolid = new G4Tubs("N2CFSolid",0,45*mm*0.5-1*mm,145*mm*0.5-1*mm,0,2*M_PI); + G4LogicalVolume* LogicN2 = new G4LogicalVolume(N2Solid, m_MaterialN2, "LogicN2", 0, 0, 0); + G4LogicalVolume* LogicN2CF = new G4LogicalVolume(N2CFSolid, m_MaterialN2, "LogicN2CF", 0, 0, 0); - G4LogicalVolume* LogicN2 = new G4LogicalVolume(N2Solid,m_MaterialN2,"LogicN2",0,0,0); - G4LogicalVolume* LogicN2CF = new G4LogicalVolume(N2CFSolid,m_MaterialN2,"LogicN2CF",0,0,0); - LogicN2->SetVisAttributes(GreenVisAtt); LogicN2CF->SetVisAttributes(GreenVisAtt); - new G4PVPlacement(G4Transform3D(*(new G4RotationMatrix()), G4ThreeVector(0,0,0)), - LogicN2,"N2 Deware",LogicDewar,false,1); - - //new G4PVPlacement(G4Transform3D(*(new G4RotationMatrix()), G4ThreeVector(0,0,-90*mm)), - // LogicN2CF,"N2 Deware",LogicDewar,false,1); + new G4PVPlacement(G4Transform3D(*(new G4RotationMatrix()), G4ThreeVector(0, 0, 0)), LogicN2, "N2 Deware", LogicDewar, + false, 1); + + // new G4PVPlacement(G4Transform3D(*(new G4RotationMatrix()), G4ThreeVector(0,0,-90*mm)), + // LogicN2CF,"N2 Deware",LogicDewar,false,1); LogicDewar->SetVisAttributes(TrGreyVisAtt); return LogicDewar; } - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Return a G4VSolid modeling the BGO -G4LogicalVolume* Tigress::ConstructBGO(){ - - return NULL; - -} +G4LogicalVolume* Tigress::ConstructBGO() { return NULL; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Return a clover in the configuration given by option (not use a the moment) -void Tigress::ConstructClover(){ - if(m_LogicClover==0){ +void Tigress::ConstructClover() { + if (m_LogicClover == 0) { // Construct the clover itself m_LogicClover = ConstructCapsule(); - + // Place the cristal in the clover - double CrystalOffset = (24.5*mm+0.5*mm); + double CrystalOffset = (24.5 * mm + 0.5 * mm); G4LogicalVolume* logicCrystal = ConstructCrystal(); - G4RotationMatrix* CrystalRotation = new G4RotationMatrix(0,0,0); - G4ThreeVector CrystalPositionB = G4ThreeVector(-CrystalOffset,+CrystalOffset,0.5*CrystalLength+7*mm); - new G4PVPlacement(G4Transform3D(*CrystalRotation, CrystalPositionB), - logicCrystal,"LogicCrystalB",m_LogicClover,false,1); + G4RotationMatrix* CrystalRotation = new G4RotationMatrix(0, 0, 0); + G4ThreeVector CrystalPositionB = G4ThreeVector(-CrystalOffset, +CrystalOffset, 0.5 * CrystalLength + 7 * mm); + new G4PVPlacement(G4Transform3D(*CrystalRotation, CrystalPositionB), logicCrystal, "LogicCrystalB", m_LogicClover, + false, 1); logicCrystal->SetVisAttributes(BlueVisAtt); - CrystalRotation->rotate(-90*deg, G4ThreeVector(0,0,1)); - G4ThreeVector CrystalPositionG = G4ThreeVector(+CrystalOffset,+CrystalOffset,0.5*CrystalLength+7*mm); - new G4PVPlacement(G4Transform3D(*CrystalRotation, CrystalPositionG), - logicCrystal,"LogicCrystalG",m_LogicClover,false,2); - - CrystalRotation->rotate(-90*deg, G4ThreeVector(0,0,1)); - G4ThreeVector CrystalPositionR = G4ThreeVector(+CrystalOffset,-CrystalOffset,0.5*CrystalLength+7*mm); - new G4PVPlacement(G4Transform3D(*CrystalRotation, CrystalPositionR), - logicCrystal,"LogicCrystalR",m_LogicClover,false,3); + CrystalRotation->rotate(-90 * deg, G4ThreeVector(0, 0, 1)); + G4ThreeVector CrystalPositionG = G4ThreeVector(+CrystalOffset, +CrystalOffset, 0.5 * CrystalLength + 7 * mm); + new G4PVPlacement(G4Transform3D(*CrystalRotation, CrystalPositionG), logicCrystal, "LogicCrystalG", m_LogicClover, + false, 2); - CrystalRotation->rotate(-90*deg, G4ThreeVector(0,0,1)); - G4ThreeVector CrystalPositionW = G4ThreeVector(-CrystalOffset,-CrystalOffset,0.5*CrystalLength+7*mm); - new G4PVPlacement(G4Transform3D(*CrystalRotation, CrystalPositionW), - logicCrystal,"LogicCrystalW",m_LogicClover,false,4); + CrystalRotation->rotate(-90 * deg, G4ThreeVector(0, 0, 1)); + G4ThreeVector CrystalPositionR = G4ThreeVector(+CrystalOffset, -CrystalOffset, 0.5 * CrystalLength + 7 * mm); + new G4PVPlacement(G4Transform3D(*CrystalRotation, CrystalPositionR), logicCrystal, "LogicCrystalR", m_LogicClover, + false, 3); - logicCrystal->SetSensitiveDetector(m_HPGeScorer); - // m_LogicClover->SetSensitiveDetector(m_HPGeScorer); - } + CrystalRotation->rotate(-90 * deg, G4ThreeVector(0, 0, 1)); + G4ThreeVector CrystalPositionW = G4ThreeVector(-CrystalOffset, -CrystalOffset, 0.5 * CrystalLength + 7 * mm); + new G4PVPlacement(G4Transform3D(*CrystalRotation, CrystalPositionW), logicCrystal, "LogicCrystalW", m_LogicClover, + false, 4); + logicCrystal->SetSensitiveDetector(m_HPGeScorer); + // m_LogicClover->SetSensitiveDetector(m_HPGeScorer); + } } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Construct detector and inialise sensitive part. // Called After DetecorConstruction::AddDetector Method -void Tigress::ConstructDetector(G4LogicalVolume* world){ +void Tigress::ConstructDetector(G4LogicalVolume* world) { ConstructClover(); - G4RotationMatrix* DetectorRotation = new G4RotationMatrix(0,0,0); - for (unsigned int i = 0 ; i < m_CloverId.size(); i++) { + G4RotationMatrix* DetectorRotation = new G4RotationMatrix(0, 0, 0); + for (unsigned int i = 0; i < m_CloverId.size(); i++) { // Constructing the Detector referential and the transition matrix - G4ThreeVector U,V,W; - G4double wX = sin(m_Theta[i]) * cos(m_Phi[i]) ; - G4double wY = sin(m_Theta[i]) * sin(m_Phi[i]) ; + G4ThreeVector U, V, W; + G4double wX = sin(m_Theta[i]) * cos(m_Phi[i]); + G4double wY = sin(m_Theta[i]) * sin(m_Phi[i]); G4double wZ = cos(m_Theta[i]); - W = G4ThreeVector(wX, wY, wZ) ; + W = G4ThreeVector(wX, wY, wZ); // vector parallel to one axis of the entrance plane G4double vX = cos(m_Theta[i]) * cos(m_Phi[i]); @@ -358,194 +352,193 @@ void Tigress::ConstructDetector(G4LogicalVolume* world){ DetectorRotation->rotate(m_BetaX[i], U); DetectorRotation->rotate(m_BetaY[i], V); DetectorRotation->rotate(m_BetaZ[i], W); - G4ThreeVector DetectorPosition = m_R[i]*W; - - new G4PVPlacement(G4Transform3D(*DetectorRotation, DetectorPosition), - m_LogicClover,"Clover",world,false,m_CloverId[i]); - - G4LogicalVolume* LogicDewar = ConstructDewar(); - - new G4PVPlacement(G4Transform3D(*DetectorRotation, DetectorPosition+W*((90*mm+(145)*mm)+CapsuleLength*0.5+90*0.5*mm)), - LogicDewar,"Dewar",world,false,m_CloverId[i]); + G4ThreeVector DetectorPosition = m_R[i] * W; + new G4PVPlacement(G4Transform3D(*DetectorRotation, DetectorPosition), m_LogicClover, "Clover", world, false, + m_CloverId[i]); + G4LogicalVolume* LogicDewar = ConstructDewar(); + + new G4PVPlacement(G4Transform3D(*DetectorRotation, DetectorPosition + W * ((90 * mm + (145) * mm) + + CapsuleLength * 0.5 + 90 * 0.5 * mm)), + LogicDewar, "Dewar", world, false, m_CloverId[i]); } } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Add clover at the standard position of the array // Take as argument the standard clover Id. -void Tigress::AddCloverStandard(vector<int> CloverId){ +void Tigress::AddCloverStandard(vector<int> CloverId) { - for (unsigned int i = 0 ; i < CloverId.size(); i++) { - if(CloverId[i] == 1 ){ + for (unsigned int i = 0; i < CloverId.size(); i++) { + if (CloverId[i] == 1) { m_CloverId.push_back(CloverId[i]); - m_R.push_back(145*mm); - m_Theta.push_back(45*deg); - m_Phi.push_back(22.5*deg); + m_R.push_back(145 * mm); + m_Theta.push_back(45 * deg); + m_Phi.push_back(22.5 * deg); m_BetaX.push_back(0); m_BetaY.push_back(0); m_BetaZ.push_back(0); } - else if(CloverId[i] == 2 ){ + else if (CloverId[i] == 2) { m_CloverId.push_back(CloverId[i]); - m_R.push_back(145*mm); - m_Theta.push_back(45*deg); - m_Phi.push_back(112.5*deg); + m_R.push_back(145 * mm); + m_Theta.push_back(45 * deg); + m_Phi.push_back(112.5 * deg); m_BetaX.push_back(0); m_BetaY.push_back(0); m_BetaZ.push_back(0); } - else if(CloverId[i] == 3 ){ + else if (CloverId[i] == 3) { m_CloverId.push_back(CloverId[i]); - m_R.push_back(145*mm); - m_Theta.push_back(45*deg); - m_Phi.push_back(202.5*deg); + m_R.push_back(145 * mm); + m_Theta.push_back(45 * deg); + m_Phi.push_back(202.5 * deg); m_BetaX.push_back(0); m_BetaY.push_back(0); m_BetaZ.push_back(0); } - else if(CloverId[i] == 4 ){ + else if (CloverId[i] == 4) { m_CloverId.push_back(CloverId[i]); - m_R.push_back(145*mm); - m_Theta.push_back(45*deg); - m_Phi.push_back(292.5*deg); + m_R.push_back(145 * mm); + m_Theta.push_back(45 * deg); + m_Phi.push_back(292.5 * deg); m_BetaX.push_back(0); m_BetaY.push_back(0); m_BetaZ.push_back(0); } - else if(CloverId[i] == 5 ){ + else if (CloverId[i] == 5) { m_CloverId.push_back(CloverId[i]); - m_R.push_back(145*mm); - m_Theta.push_back(90*deg); - m_Phi.push_back(22.5*deg); + m_R.push_back(145 * mm); + m_Theta.push_back(90 * deg); + m_Phi.push_back(22.5 * deg); m_BetaX.push_back(0); m_BetaY.push_back(0); - m_BetaZ.push_back(180*deg); + m_BetaZ.push_back(180 * deg); } - else if(CloverId[i] == 6 ){ + else if (CloverId[i] == 6) { m_CloverId.push_back(CloverId[i]); - m_R.push_back(145*mm); - m_Theta.push_back(90*deg); - m_Phi.push_back(67.5*deg); + m_R.push_back(145 * mm); + m_Theta.push_back(90 * deg); + m_Phi.push_back(67.5 * deg); m_BetaX.push_back(0); m_BetaY.push_back(0); - m_BetaZ.push_back(180*deg); + m_BetaZ.push_back(180 * deg); } - else if(CloverId[i] == 7 ){ + else if (CloverId[i] == 7) { m_CloverId.push_back(CloverId[i]); - m_R.push_back(145*mm); - m_Theta.push_back(90*deg); - m_Phi.push_back(112.5*deg); + m_R.push_back(145 * mm); + m_Theta.push_back(90 * deg); + m_Phi.push_back(112.5 * deg); m_BetaX.push_back(0); m_BetaY.push_back(0); - m_BetaZ.push_back(180*deg); + m_BetaZ.push_back(180 * deg); } - else if(CloverId[i] == 8 ){ + else if (CloverId[i] == 8) { m_CloverId.push_back(CloverId[i]); - m_R.push_back(145*mm); - m_Theta.push_back(90*deg); - m_Phi.push_back(157.5*deg); + m_R.push_back(145 * mm); + m_Theta.push_back(90 * deg); + m_Phi.push_back(157.5 * deg); m_BetaX.push_back(0); m_BetaY.push_back(0); - m_BetaZ.push_back(180*deg); + m_BetaZ.push_back(180 * deg); } - else if(CloverId[i] == 9 ){ + else if (CloverId[i] == 9) { m_CloverId.push_back(CloverId[i]); - m_R.push_back(145*mm); - m_Theta.push_back(90*deg); - m_Phi.push_back(202.5*deg); + m_R.push_back(145 * mm); + m_Theta.push_back(90 * deg); + m_Phi.push_back(202.5 * deg); m_BetaX.push_back(0); m_BetaY.push_back(0); - m_BetaZ.push_back(180*deg); + m_BetaZ.push_back(180 * deg); } - else if(CloverId[i] == 10 ){ + else if (CloverId[i] == 10) { m_CloverId.push_back(CloverId[i]); - m_R.push_back(145*mm); - m_Theta.push_back(90*deg); - m_Phi.push_back(247.5*deg); + m_R.push_back(145 * mm); + m_Theta.push_back(90 * deg); + m_Phi.push_back(247.5 * deg); m_BetaX.push_back(0); m_BetaY.push_back(0); - m_BetaZ.push_back(180*deg); + m_BetaZ.push_back(180 * deg); } - else if(CloverId[i] == 11 ){ + else if (CloverId[i] == 11) { m_CloverId.push_back(CloverId[i]); - m_R.push_back(145*mm); - m_Theta.push_back(90*deg); - m_Phi.push_back(292.5*deg); + m_R.push_back(145 * mm); + m_Theta.push_back(90 * deg); + m_Phi.push_back(292.5 * deg); m_BetaX.push_back(0); m_BetaY.push_back(0); - m_BetaZ.push_back(180*deg); + m_BetaZ.push_back(180 * deg); } - else if(CloverId[i] == 12 ){ + else if (CloverId[i] == 12) { m_CloverId.push_back(CloverId[i]); - m_R.push_back(145*mm); - m_Theta.push_back(90*deg); - m_Phi.push_back(337.5*deg); + m_R.push_back(145 * mm); + m_Theta.push_back(90 * deg); + m_Phi.push_back(337.5 * deg); m_BetaX.push_back(0); m_BetaY.push_back(0); - m_BetaZ.push_back(180*deg); + m_BetaZ.push_back(180 * deg); } - else if(CloverId[i] == 13 ){ + else if (CloverId[i] == 13) { m_CloverId.push_back(CloverId[i]); - m_R.push_back(145*mm); - m_Theta.push_back(135*deg); - m_Phi.push_back(22.5*deg); + m_R.push_back(145 * mm); + m_Theta.push_back(135 * deg); + m_Phi.push_back(22.5 * deg); m_BetaX.push_back(0); m_BetaY.push_back(0); - m_BetaZ.push_back(180*deg); + m_BetaZ.push_back(180 * deg); } - else if(CloverId[i] == 14 ){ + else if (CloverId[i] == 14) { m_CloverId.push_back(CloverId[i]); - m_R.push_back(145*mm); - m_Theta.push_back(135*deg); - m_Phi.push_back(112.5*deg); + m_R.push_back(145 * mm); + m_Theta.push_back(135 * deg); + m_Phi.push_back(112.5 * deg); m_BetaX.push_back(0); m_BetaY.push_back(0); - m_BetaZ.push_back(180*deg); + m_BetaZ.push_back(180 * deg); } - else if(CloverId[i] == 15 ){ + else if (CloverId[i] == 15) { m_CloverId.push_back(CloverId[i]); - m_R.push_back(145*mm); - m_Theta.push_back(135*deg); - m_Phi.push_back(202.5*deg); + m_R.push_back(145 * mm); + m_Theta.push_back(135 * deg); + m_Phi.push_back(202.5 * deg); m_BetaX.push_back(0); m_BetaY.push_back(0); - m_BetaZ.push_back(180*deg); + m_BetaZ.push_back(180 * deg); } - else if(CloverId[i] == 16 ){ + else if (CloverId[i] == 16) { m_CloverId.push_back(CloverId[i]); - m_R.push_back(145*mm); - m_Theta.push_back(135*deg); - m_Phi.push_back(292.5*deg); + m_R.push_back(145 * mm); + m_Theta.push_back(135 * deg); + m_Phi.push_back(292.5 * deg); m_BetaX.push_back(0); m_BetaY.push_back(0); - m_BetaZ.push_back(180*deg); + m_BetaZ.push_back(180 * deg); } } - } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Add clover at a free position in space with coordinate // in spherical coordinate // Beta are the three angles of rotation in the Clover frame -void Tigress::AddCloverFreePosition(int CloverId,double R,double Theta,double Phi,double BetaX,double BetaY,double BetaZ){ +void Tigress::AddCloverFreePosition(int CloverId, double R, double Theta, double Phi, double BetaX, double BetaY, + double BetaZ) { m_CloverId.push_back(CloverId); m_R.push_back(R); @@ -554,116 +547,113 @@ void Tigress::AddCloverFreePosition(int CloverId,double R,double Theta,double Ph m_BetaX.push_back(BetaX); m_BetaY.push_back(BetaY); m_BetaZ.push_back(BetaZ); - } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Add Detector branch to the EventTree. // Called After DetecorConstruction::AddDetector Method -void Tigress::InitializeRootOutput(){ - RootOutput *pAnalysis = RootOutput::getInstance(); - TTree *pTree = pAnalysis->GetTree(); - if(!pTree->FindBranch("Tigress")){ - pTree->Branch("Tigress", "TTigressData", &m_TigressData) ; +void Tigress::InitializeRootOutput() { + RootOutput* pAnalysis = RootOutput::getInstance(); + TTree* pTree = pAnalysis->GetTree(); + if (!pTree->FindBranch("Tigress")) { + pTree->Branch("Tigress", "TTigressData", &m_TigressData); } - pTree->SetBranchAddress("Tigress", &m_TigressData) ; + pTree->SetBranchAddress("Tigress", &m_TigressData); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Read sensitive part and fill the Root tree. // Called at in the EventAction::EndOfEventAvtion -void Tigress::ReadSensitive(const G4Event* event){ +void Tigress::ReadSensitive(const G4Event* event) { m_TigressData->Clear(); /////////// // HPGE - NPS::HitsMap<G4double*>* HPGEHitMap; - std::map<G4int, G4double**>::iterator HPGE_itr; + NPS::HitsMap<G4double*>* HPGEHitMap; + std::map<G4int, G4double**>::iterator HPGE_itr; G4int HPGECollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("Tigress_Scorer/Tigress"); - if(HPGECollectionID == -1) { - G4cerr << "ERROR: No Collection found for HPGeScorer: Skipping processing of HPGe Hit" << G4endl; - return; - } + if (HPGECollectionID == -1) { + G4cerr << "ERROR: No Collection found for HPGeScorer: Skipping processing of HPGe Hit" << G4endl; + return; + } HPGEHitMap = (NPS::HitsMap<G4double*>*)(event->GetHCofThisEvent()->GetHC(HPGECollectionID)); // Loop on the HPGE map - /* for (HPGE_itr = HPGEHitMap->GetMap()->begin() ; HPGE_itr != HPGEHitMap->GetMap()->end() ; HPGE_itr++){ - - G4double* Info = *(HPGE_itr->second); - - G4double Energy = Info[0]; // RandGauss::shoot(Info[0], ResoEnergy/2.334); - G4double Time = Info[1]; - G4int CloverNbr = (int)Info[7]; - G4int CrystalNbr = (int)Info[8]; - - // Figure out segment number, in progress - G4int SegmentNbr = 0; - G4double zpos = Info[4]; // mm - if(fabs(zpos) < 10) { SegmentNbr = 2; } // MIDDLE - else if(CrystalNbr == 1 || CrystalNbr == 4) { SegmentNbr = 1; } // RIGHT - else { SegmentNbr = 3; } // LEFT - - //m_TigressData->SetCoreE(CloverNbr, CrystalNbr, Energy/keV); - //m_TigressData->SetCoreT(CloverNbr, CrystalNbr, Time/ns); - //m_TigressData->SetSegmentE(CloverNbr, SegmentNbr, Energy/keV); - //m_TigressData->SetSegmentT(CloverNbr, SegmentNbr, Time/keV); - } -*/ + /* for (HPGE_itr = HPGEHitMap->GetMap()->begin() ; HPGE_itr != HPGEHitMap->GetMap()->end() ; HPGE_itr++){ + + G4double* Info = *(HPGE_itr->second); + + G4double Energy = Info[0]; // RandGauss::shoot(Info[0], ResoEnergy/2.334); + G4double Time = Info[1]; + G4int CloverNbr = (int)Info[7]; + G4int CrystalNbr = (int)Info[8]; + + // Figure out segment number, in progress + G4int SegmentNbr = 0; + G4double zpos = Info[4]; // mm + if(fabs(zpos) < 10) { SegmentNbr = 2; } // MIDDLE + else if(CrystalNbr == 1 || CrystalNbr == 4) { SegmentNbr = 1; } // RIGHT + else { SegmentNbr = 3; } // LEFT + + //m_TigressData->SetCoreE(CloverNbr, CrystalNbr, Energy/keV); + //m_TigressData->SetCoreT(CloverNbr, CrystalNbr, Time/ns); + //m_TigressData->SetSegmentE(CloverNbr, SegmentNbr, Energy/keV); + //m_TigressData->SetSegmentT(CloverNbr, SegmentNbr, Time/keV); + } + */ // clear map for next event HPGEHitMap->clear(); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void Tigress::InitializeScorers(){ - //Look for previous definition of the scorer (geometry reload) - //n.b. calls new G4MultiFunctionalDetector("Tigress_CoreScorer"); +void Tigress::InitializeScorers() { + // Look for previous definition of the scorer (geometry reload) + // n.b. calls new G4MultiFunctionalDetector("Tigress_CoreScorer"); bool already_exist = false; - m_HPGeScorer = CheckScorer("Tigress_Scorer",already_exist); + m_HPGeScorer = CheckScorer("Tigress_Scorer", already_exist); + + // if the scorer were created previously nothing else need to be made + if (already_exist) + return; - // if the scorer were created previously nothing else need to be made - if(already_exist) return; - // HPGe Associate Scorer - G4VPrimitiveScorer* HPGeScorer = new TIGRESSSCORERS::PS_Tigress("Tigress",0); + G4VPrimitiveScorer* HPGeScorer = new TIGRESSSCORERS::PS_Tigress("Tigress", 0); - //and register it to the multifunctionnal detector + // and register it to the multifunctionnal detector m_HPGeScorer->RegisterPrimitive(HPGeScorer); - // Add All Scorer to the Global Scorer Manager - G4SDManager::GetSDMpointer()->AddNewDetector(m_HPGeScorer) ; + // Add All Scorer to the Global Scorer Manager + G4SDManager::GetSDMpointer()->AddNewDetector(m_HPGeScorer); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //////////////////////////////////////////////////////////////// /////////////////Material Definition /////////////////////////// //////////////////////////////////////////////////////////////// -void Tigress::InitializeMaterial(){ +void Tigress::InitializeMaterial() { m_MaterialVacuum = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); - m_MaterialGe= MaterialManager::getInstance()->GetMaterialFromLibrary("Ge"); - m_MaterialAl= MaterialManager::getInstance()->GetMaterialFromLibrary("Al"); - m_MaterialN2= MaterialManager::getInstance()->GetMaterialFromLibrary("N2_liquid"); + m_MaterialGe = MaterialManager::getInstance()->GetMaterialFromLibrary("Ge"); + m_MaterialAl = MaterialManager::getInstance()->GetMaterialFromLibrary("Al"); + m_MaterialN2 = MaterialManager::getInstance()->GetMaterialFromLibrary("N2_liquid"); } - //////////////////////////////////////////////////////////////////////////////// // Construct Method to be pass to the DetectorFactory // //////////////////////////////////////////////////////////////////////////////// -NPS::VDetector* Tigress::Construct(){ - return (NPS::VDetector*) new Tigress(); -} +NPS::VDetector* Tigress::Construct() { return (NPS::VDetector*)new Tigress(); } //////////////////////////////////////////////////////////////////////////////// // Registering the construct method to the factory // //////////////////////////////////////////////////////////////////////////////// -extern"C" { - class proxy_nps_tigress{ - public: - proxy_nps_tigress(){ - NPS::DetectorFactory::getInstance()->AddToken("Tigress","Tigress"); - NPS::DetectorFactory::getInstance()->AddDetector("Tigress",Tigress::Construct); - } - }; - - proxy_nps_tigress p_nps_tigress; +extern "C" { +class proxy_nps_tigress { + public: + proxy_nps_tigress() { + NPS::DetectorFactory::getInstance()->AddToken("Tigress", "Tigress"); + NPS::DetectorFactory::getInstance()->AddDetector("Tigress", Tigress::Construct); + } +}; + +proxy_nps_tigress p_nps_tigress; } diff --git a/NPSimulation/Detectors/W1/W1.cc b/NPSimulation/Detectors/W1/W1.cc index 87bb907f5f7215e5c932709954b2860c5891e6a6..a6916ea156079a60c43a6a5168edb44314e8e918 100644 --- a/NPSimulation/Detectors/W1/W1.cc +++ b/NPSimulation/Detectors/W1/W1.cc @@ -20,36 +20,36 @@ *****************************************************************************/ // C++ headers +#include <cmath> #include <sstream> #include <string> -#include <cmath> // G4 Geometry headers #include "G4Box.hh" #include "G4Tubs.hh" // G4 various headers -#include "G4Material.hh" -#include "G4VisAttributes.hh" #include "G4Colour.hh" +#include "G4Material.hh" +#include "G4PVDivision.hh" +#include "G4PVPlacement.hh" #include "G4RotationMatrix.hh" #include "G4Transform3D.hh" -#include "G4PVPlacement.hh" -#include "G4PVDivision.hh" +#include "G4VisAttributes.hh" // G4 sensitive -#include "G4SDManager.hh" #include "G4MultiFunctionalDetector.hh" +#include "G4SDManager.hh" // NPTool headers -#include "ObsoleteGeneralScorers.hh" #include "MaterialManager.hh" +#include "NPOptionManager.h" #include "NPSDetectorFactory.hh" +#include "ObsoleteGeneralScorers.hh" +#include "RootOutput.h" +#include "TW1Data.h" #include "W1.hh" #include "W1Scorers.hh" -#include "TW1Data.h" -#include "RootOutput.h" -#include "NPOptionManager.h" // CLHEP #include "CLHEP/Random/RandGauss.h" @@ -58,46 +58,27 @@ using namespace std; using namespace CLHEP; using namespace W1SQUARE; +W1::W1() : m_Event(new TW1Data) { InitializeMaterials(); } +W1::~W1() { delete m_Event; } -W1::W1() - : m_Event(new TW1Data) -{ - InitializeMaterials(); -} +void W1::AddDetector(G4ThreeVector X1_Y1, G4ThreeVector X16_Y1, G4ThreeVector X1_Y16, G4ThreeVector X16_Y16) { + m_DefinitionType.push_back(true); + m_X1_Y1.push_back(X1_Y1); + m_X16_Y1.push_back(X16_Y1); + m_X1_Y16.push_back(X1_Y16); + m_X16_Y16.push_back(X16_Y16); - -W1::~W1() -{ - delete m_Event; + m_R.push_back(0); + m_Theta.push_back(0); + m_Phi.push_back(0); + m_beta_u.push_back(0); + m_beta_v.push_back(0); + m_beta_w.push_back(0); } - - -void W1::AddDetector(G4ThreeVector X1_Y1, G4ThreeVector X16_Y1, - G4ThreeVector X1_Y16, G4ThreeVector X16_Y16) -{ - m_DefinitionType.push_back(true); - - m_X1_Y1.push_back(X1_Y1); - m_X16_Y1.push_back(X16_Y1); - m_X1_Y16.push_back(X1_Y16); - m_X16_Y16.push_back(X16_Y16); - - m_R.push_back(0); - m_Theta.push_back(0); - m_Phi.push_back(0); - m_beta_u.push_back(0); - m_beta_v.push_back(0); - m_beta_w.push_back(0); -} - - - -void W1::AddDetector(G4double R, G4double Theta, G4double Phi, - G4double beta_u, G4double beta_v, G4double beta_w) -{ +void W1::AddDetector(G4double R, G4double Theta, G4double Phi, G4double beta_u, G4double beta_v, G4double beta_w) { G4ThreeVector empty = G4ThreeVector(0, 0, 0); m_DefinitionType.push_back(false); @@ -113,104 +94,96 @@ void W1::AddDetector(G4double R, G4double Theta, G4double Phi, m_X16_Y1.push_back(empty); m_X1_Y16.push_back(empty); m_X16_Y16.push_back(empty); - } +void W1::VolumeMaker(G4int DetecNumber, G4ThreeVector position, G4RotationMatrix* rotation, G4LogicalVolume* world) { + G4double NbrTelescopes = DetecNumber; + G4String DetectorNumber; + ostringstream Number; + Number << NbrTelescopes; + DetectorNumber = Number.str(); + //////////////////////////////////////////////////////////////// + ////////////// Starting Volume Definition ////////////////////// + //////////////////////////////////////////////////////////////// + G4String Name = "W1Square" + DetectorNumber; -void W1::VolumeMaker(G4int DetecNumber, - G4ThreeVector position, - G4RotationMatrix* rotation, - G4LogicalVolume* world) -{ - G4double NbrTelescopes = DetecNumber; - G4String DetectorNumber; - ostringstream Number; - Number << NbrTelescopes; - DetectorNumber = Number.str(); + // Definition of the volume containing the sensitive detector + G4Box* solidW1 = new G4Box(Name, 0.5 * FaceFront, 0.5 * FaceFront, 0.5 * Length); + G4LogicalVolume* logicW1 = new G4LogicalVolume(solidW1, m_MaterialVacuum, Name, 0, 0, 0); - //////////////////////////////////////////////////////////////// - ////////////// Starting Volume Definition ////////////////////// - //////////////////////////////////////////////////////////////// - G4String Name = "W1Square" + DetectorNumber; + new G4PVPlacement(G4Transform3D(*rotation, position), logicW1, Name, world, false, 0); - // Definition of the volume containing the sensitive detector - G4Box* solidW1 = new G4Box(Name, 0.5*FaceFront, 0.5*FaceFront, 0.5*Length); - G4LogicalVolume* logicW1 = new G4LogicalVolume(solidW1, m_MaterialVacuum, Name, 0, 0, 0); + logicW1->SetVisAttributes(G4VisAttributes::GetInvisible()); + if (m_non_sensitive_part_visiualisation) + logicW1->SetVisAttributes(G4VisAttributes(G4Colour(0.90, 0.90, 0.90))); - new G4PVPlacement(G4Transform3D(*rotation, position), logicW1, Name, world, false, 0); + // Aluminium dead layers + G4ThreeVector positionAluStripFront = G4ThreeVector(0, 0, AluStripFront_PosZ); + G4ThreeVector positionAluStripBack = G4ThreeVector(0, 0, AluStripBack_PosZ); - logicW1->SetVisAttributes(G4VisAttributes::Invisible); - if (m_non_sensitive_part_visiualisation) logicW1->SetVisAttributes(G4VisAttributes(G4Colour(0.90, 0.90, 0.90))); + G4Box* solidAluStrip = new G4Box("AluBox", 0.5 * SiliconFace, 0.5 * SiliconFace, 0.5 * AluStripThickness); + // G4LogicalVolume* logicAluStrip = new G4LogicalVolume(solidAluStrip, m_MaterialAluminium, "logicAluStrip", 0, 0, + // 0); + G4LogicalVolume* logicAluStrip = new G4LogicalVolume(solidAluStrip, m_MaterialVacuum, "logicAluStrip", 0, 0, 0); - // Aluminium dead layers - G4ThreeVector positionAluStripFront = G4ThreeVector(0, 0, AluStripFront_PosZ); - G4ThreeVector positionAluStripBack = G4ThreeVector(0, 0, AluStripBack_PosZ); + new G4PVPlacement(0, positionAluStripFront, logicAluStrip, Name + "_AluStripFront", logicW1, false, 0); + new G4PVPlacement(0, positionAluStripBack, logicAluStrip, Name + "_AluStripBack", logicW1, false, 0); - G4Box* solidAluStrip = new G4Box("AluBox", 0.5*SiliconFace, 0.5*SiliconFace, 0.5*AluStripThickness); -// G4LogicalVolume* logicAluStrip = new G4LogicalVolume(solidAluStrip, m_MaterialAluminium, "logicAluStrip", 0, 0, 0); - G4LogicalVolume* logicAluStrip = new G4LogicalVolume(solidAluStrip, m_MaterialVacuum, "logicAluStrip", 0, 0, 0); + logicAluStrip->SetVisAttributes(G4VisAttributes::GetInvisible()); - new G4PVPlacement(0, positionAluStripFront, logicAluStrip, Name + "_AluStripFront", logicW1, false, 0); - new G4PVPlacement(0, positionAluStripBack, logicAluStrip, Name + "_AluStripBack", logicW1, false, 0); + // Silicon detector itself + G4ThreeVector positionSilicon = G4ThreeVector(0, 0, Silicon_PosZ); - logicAluStrip->SetVisAttributes(G4VisAttributes::Invisible); + G4Box* solidSilicon = new G4Box("solidSilicon", 0.5 * SiliconFace, 0.5 * SiliconFace, 0.5 * SiliconThickness); + G4LogicalVolume* logicSilicon = new G4LogicalVolume(solidSilicon, m_MaterialSilicon, "logicSilicon", 0, 0, 0); - // Silicon detector itself - G4ThreeVector positionSilicon = G4ThreeVector(0, 0, Silicon_PosZ); + new G4PVPlacement(0, positionSilicon, logicSilicon, Name + "_Silicon", logicW1, false, 0); - G4Box* solidSilicon = new G4Box("solidSilicon", 0.5*SiliconFace, 0.5*SiliconFace, 0.5*SiliconThickness); - G4LogicalVolume* logicSilicon = new G4LogicalVolume(solidSilicon, m_MaterialSilicon, "logicSilicon", 0, 0, 0); + // Set Silicon strip sensible + logicSilicon->SetSensitiveDetector(m_Scorer); - new G4PVPlacement(0, positionSilicon, logicSilicon, Name + "_Silicon", logicW1, false, 0); - - // Set Silicon strip sensible - logicSilicon->SetSensitiveDetector(m_Scorer); - - ///Visualisation of Silicon Strip - G4VisAttributes* SiliconVisAtt = new G4VisAttributes(G4Colour(0.0, 0.0, 0.9)); - logicSilicon->SetVisAttributes(SiliconVisAtt); + /// Visualisation of Silicon Strip + G4VisAttributes* SiliconVisAtt = new G4VisAttributes(G4Colour(0.0, 0.0, 0.9)); + logicSilicon->SetVisAttributes(SiliconVisAtt); } - - // Read stream at Configfile to pick-up parameters of detector (Position,...) // Called in DetecorConstruction::ReadDetextorConfiguration Method -void W1::ReadConfiguration(NPL::InputParser parser){ +void W1::ReadConfiguration(NPL::InputParser parser) { vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithToken("W1"); - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << "//// " << blocks.size() << " detectors found " << endl; - for(unsigned int i = 0 ; i < blocks.size() ; i++){ + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks.size() << " detectors found " << endl; + for (unsigned int i = 0; i < blocks.size(); i++) { // Cartesian Case - vector<string> cart = {"X1_Y1","X1_Y16","X16_Y1","X16_Y16","VIS"}; + vector<string> cart = {"X1_Y1", "X1_Y16", "X16_Y1", "X16_Y16", "VIS"}; // Spherical Case - vector<string> sphe= {"R","THETA","PHI","BETA","VIS"}; - - if(blocks[i]->HasTokenList(cart)){ - cout << endl << "//// W1 " << i+1 << endl; - G4ThreeVector A = NPS::ConvertVector(blocks[i]->GetTVector3("X1_Y1","mm")); - G4ThreeVector B = NPS::ConvertVector(blocks[i]->GetTVector3("X16_Y1","mm")); - G4ThreeVector C = NPS::ConvertVector(blocks[i]->GetTVector3("X1_Y16","mm")); - G4ThreeVector D = NPS::ConvertVector(blocks[i]->GetTVector3("X16_Y16","mm")); - if(blocks[i]->GetInt("VIS")) + vector<string> sphe = {"R", "THETA", "PHI", "BETA", "VIS"}; + + if (blocks[i]->HasTokenList(cart)) { + cout << endl << "//// W1 " << i + 1 << endl; + G4ThreeVector A = NPS::ConvertVector(blocks[i]->GetTVector3("X1_Y1", "mm")); + G4ThreeVector B = NPS::ConvertVector(blocks[i]->GetTVector3("X16_Y1", "mm")); + G4ThreeVector C = NPS::ConvertVector(blocks[i]->GetTVector3("X1_Y16", "mm")); + G4ThreeVector D = NPS::ConvertVector(blocks[i]->GetTVector3("X16_Y16", "mm")); + if (blocks[i]->GetInt("VIS")) m_non_sensitive_part_visiualisation = true; - AddDetector(A,B,C,D) ; + AddDetector(A, B, C, D); } - else if(blocks[i]->HasTokenList(sphe)){ - cout << endl << "//// W1 " << i+1 << endl; - double Theta = blocks[i]->GetDouble("THETA","deg"); - double Phi= blocks[i]->GetDouble("PHI","deg"); - double R = blocks[i]->GetDouble("R","mm"); - vector<double> beta = blocks[i]->GetVectorDouble("BETA","deg"); - if(blocks[i]->GetInt("VIS")) + else if (blocks[i]->HasTokenList(sphe)) { + cout << endl << "//// W1 " << i + 1 << endl; + double Theta = blocks[i]->GetDouble("THETA", "deg"); + double Phi = blocks[i]->GetDouble("PHI", "deg"); + double R = blocks[i]->GetDouble("R", "mm"); + vector<double> beta = blocks[i]->GetVectorDouble("BETA", "deg"); + if (blocks[i]->GetInt("VIS")) m_non_sensitive_part_visiualisation = true; - AddDetector(Theta,Phi,R,beta[0],beta[1],beta[2]); - + AddDetector(Theta, Phi, R, beta[0], beta[1], beta[2]); } - else{ + else { cout << "ERROR: Missing token for W1 blocks, check your input file" << endl; exit(1); } @@ -219,396 +192,389 @@ void W1::ReadConfiguration(NPL::InputParser parser){ // Construct detector and inialise sensitive part. // Called After DetecorConstruction::AddDetector Method -void W1::ConstructDetector(G4LogicalVolume* world) -{ - G4RotationMatrix* W1rot = NULL; - G4ThreeVector W1pos = G4ThreeVector(0, 0, 0) ; - G4ThreeVector W1u = G4ThreeVector(0, 0, 0) ; - G4ThreeVector W1v = G4ThreeVector(0, 0, 0) ; - G4ThreeVector W1w = G4ThreeVector(0, 0, 0) ; - G4ThreeVector W1Center = G4ThreeVector(0, 0, 0) ; - - G4int NumberOfDetector = m_DefinitionType.size() ; - for (G4int i = 0; i < NumberOfDetector; i++) { - // By Point - if (m_DefinitionType[i]) { - // (u,v,w) unitary vector associated to telescope referencial - // (u,v) // to silicon plan - // w perpendicular to (u,v) plan and pointing ThirdStage - W1u = m_X16_Y1[i] - m_X1_Y1[i]; - W1u = W1u.unit(); - - W1v = m_X1_Y16[i] - m_X1_Y1[i]; - W1v = W1v.unit(); - - W1w = W1u.cross(W1v); - W1w = W1w.unit(); - - W1Center = (m_X1_Y1[i] + m_X1_Y16[i] + m_X16_Y1[i] + m_X16_Y16[i]) / 4; - - // Passage Matrix from Lab Referential to Telescope Referential - W1rot = new G4RotationMatrix(W1u, W1v, W1w); - // translation to place Telescope - W1pos = W1w * Length * 0.5 + W1Center; - } +void W1::ConstructDetector(G4LogicalVolume* world) { + G4RotationMatrix* W1rot = NULL; + G4ThreeVector W1pos = G4ThreeVector(0, 0, 0); + G4ThreeVector W1u = G4ThreeVector(0, 0, 0); + G4ThreeVector W1v = G4ThreeVector(0, 0, 0); + G4ThreeVector W1w = G4ThreeVector(0, 0, 0); + G4ThreeVector W1Center = G4ThreeVector(0, 0, 0); + + G4int NumberOfDetector = m_DefinitionType.size(); + for (G4int i = 0; i < NumberOfDetector; i++) { + // By Point + if (m_DefinitionType[i]) { + // (u,v,w) unitary vector associated to telescope referencial + // (u,v) // to silicon plan + // w perpendicular to (u,v) plan and pointing ThirdStage + W1u = m_X16_Y1[i] - m_X1_Y1[i]; + W1u = W1u.unit(); + + W1v = m_X1_Y16[i] - m_X1_Y1[i]; + W1v = W1v.unit(); + + W1w = W1u.cross(W1v); + W1w = W1w.unit(); + + W1Center = (m_X1_Y1[i] + m_X1_Y16[i] + m_X16_Y1[i] + m_X16_Y16[i]) / 4; + + // Passage Matrix from Lab Referential to Telescope Referential + W1rot = new G4RotationMatrix(W1u, W1v, W1w); + // translation to place Telescope + W1pos = W1w * Length * 0.5 + W1Center; + } - // By Angle - else { - G4double Theta = m_Theta[i]; - G4double Phi = m_Phi[i]; - - // (u,v,w) unitary vector associated to telescope referencial - // (u,v) // to silicon plan - // w perpendicular to (u,v) plan and pointing ThirdStage - // Phi is angle between X axis and projection in (X,Y) plan - // Theta is angle between position vector and z axis - G4double wX = m_R[i] * sin(Theta / rad) * cos(Phi / rad); - G4double wY = m_R[i] * sin(Theta / rad) * sin(Phi / rad); - G4double wZ = m_R[i] * cos(Theta / rad); - W1w = G4ThreeVector(wX, wY, wZ); - - // vector corresponding to the center of the module - W1Center = W1w; - - // vector parallel to one axis of silicon plane - G4double ii = cos(Theta / rad) * cos(Phi / rad); - G4double jj = cos(Theta / rad) * sin(Phi / rad); - G4double kk = -sin(Theta / rad); - G4ThreeVector Y = G4ThreeVector(ii, jj, kk); - - W1w = W1w.unit(); - W1u = W1w.cross(Y); - W1v = W1w.cross(W1u); - W1v = W1v.unit(); - W1u = W1u.unit(); - - // Passage Matrix from Lab Referential to Telescope Referential - // MUST2 - W1rot = new G4RotationMatrix(W1u, W1v, W1w); - // Telescope is rotate of Beta angle around W1v axis. - W1rot->rotate(m_beta_u[i], W1u); - W1rot->rotate(m_beta_v[i], W1v); - W1rot->rotate(m_beta_w[i], W1w); - // translation to place Telescope - W1pos = W1w * Length * 0.5 + W1Center; - } + // By Angle + else { + G4double Theta = m_Theta[i]; + G4double Phi = m_Phi[i]; + + // (u,v,w) unitary vector associated to telescope referencial + // (u,v) // to silicon plan + // w perpendicular to (u,v) plan and pointing ThirdStage + // Phi is angle between X axis and projection in (X,Y) plan + // Theta is angle between position vector and z axis + G4double wX = m_R[i] * sin(Theta / rad) * cos(Phi / rad); + G4double wY = m_R[i] * sin(Theta / rad) * sin(Phi / rad); + G4double wZ = m_R[i] * cos(Theta / rad); + W1w = G4ThreeVector(wX, wY, wZ); + + // vector corresponding to the center of the module + W1Center = W1w; + + // vector parallel to one axis of silicon plane + G4double ii = cos(Theta / rad) * cos(Phi / rad); + G4double jj = cos(Theta / rad) * sin(Phi / rad); + G4double kk = -sin(Theta / rad); + G4ThreeVector Y = G4ThreeVector(ii, jj, kk); + + W1w = W1w.unit(); + W1u = W1w.cross(Y); + W1v = W1w.cross(W1u); + W1v = W1v.unit(); + W1u = W1u.unit(); + + // Passage Matrix from Lab Referential to Telescope Referential + // MUST2 + W1rot = new G4RotationMatrix(W1u, W1v, W1w); + // Telescope is rotate of Beta angle around W1v axis. + W1rot->rotate(m_beta_u[i], W1u); + W1rot->rotate(m_beta_v[i], W1v); + W1rot->rotate(m_beta_w[i], W1w); + // translation to place Telescope + W1pos = W1w * Length * 0.5 + W1Center; + } - VolumeMaker(i + 1, W1pos, W1rot, world); - } + VolumeMaker(i + 1, W1pos, W1rot, world); + } - delete W1rot; + delete W1rot; } - - // Connect the GaspardTrackingData class to the output TTree // of the simulation -void W1::InitializeRootOutput() -{ - RootOutput *pAnalysis = RootOutput::getInstance(); - TTree *pTree = pAnalysis->GetTree(); - if(!pTree->FindBranch("W1")){ +void W1::InitializeRootOutput() { + RootOutput* pAnalysis = RootOutput::getInstance(); + TTree* pTree = pAnalysis->GetTree(); + if (!pTree->FindBranch("W1")) { pTree->Branch("W1", "TW1Data", &m_Event); - } - pTree->SetBranchAddress("W1", &m_Event); + } + pTree->SetBranchAddress("W1", &m_Event); } - - // Read sensitive part and fill the Root tree. // Called at in the EventAction::EndOfEventAvtion -void W1::ReadSensitive(const G4Event* event) -{ - // Clear ROOT objects - m_Event->Clear(); - - ////////////////////////////////////////////////////////////////////////////////// - /////////////// Variables Used to Read Event Map of detector //////////////////// - ////////////////////////////////////////////////////////////////////////////////// - // First Stage - std::map<G4int, G4int*>::iterator DetectorNumber_itr; - std::map<G4int, G4double*>::iterator Energy_itr; - std::map<G4int, G4double*>::iterator Time_itr; - std::map<G4int, G4double*>::iterator X_itr; - std::map<G4int, G4double*>::iterator Y_itr; - std::map<G4int, G4double*>::iterator Pos_X_itr; - std::map<G4int, G4double*>::iterator Pos_Y_itr; - std::map<G4int, G4double*>::iterator Pos_Z_itr; - std::map<G4int, G4double*>::iterator Ang_Theta_itr; - std::map<G4int, G4double*>::iterator Ang_Phi_itr; - - NPS::HitsMap<G4int>* DetectorNumberHitMap; - NPS::HitsMap<G4double>* EnergyHitMap; - NPS::HitsMap<G4double>* TimeHitMap; - NPS::HitsMap<G4double>* XHitMap; - NPS::HitsMap<G4double>* YHitMap; - NPS::HitsMap<G4double>* PosXHitMap; - NPS::HitsMap<G4double>* PosYHitMap; - NPS::HitsMap<G4double>* PosZHitMap; - NPS::HitsMap<G4double>* AngThetaHitMap; - NPS::HitsMap<G4double>* AngPhiHitMap; - - ///////////////////////////////////////////////////////////////////////////////// - ////////////////// Read scorers //////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////////////////// - // Read the Scorer associated to the first Stage - //Detector Number - G4int StripDetCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("ScorerW1/DetectorNumber"); - DetectorNumberHitMap = (NPS::HitsMap<G4int>*)(event->GetHCofThisEvent()->GetHC(StripDetCollectionID)); - DetectorNumber_itr = DetectorNumberHitMap->GetMap()->begin(); - - //Energy - G4int StripEnergyCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("ScorerW1/StripEnergy") ; - EnergyHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripEnergyCollectionID)) ; - Energy_itr = EnergyHitMap->GetMap()->begin() ; - - //Time of Flight - G4int StripTimeCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("ScorerW1/StripTime") ; - TimeHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripTimeCollectionID)) ; - Time_itr = TimeHitMap->GetMap()->begin() ; - - //Strip Number X - G4int StripXCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("ScorerW1/FrontStripNumber"); - XHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripXCollectionID)); - X_itr = XHitMap->GetMap()->begin(); - - //Strip Number Y - G4int StripYCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("ScorerW1/BackStripNumber"); - YHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripYCollectionID)) ; - Y_itr = YHitMap->GetMap()->begin() ; - - //Interaction Coordinate X - G4int InterCoordXCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("ScorerW1/InterCoordX") ; - PosXHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordXCollectionID)) ; - Pos_X_itr = PosXHitMap->GetMap()->begin() ; - - //Interaction Coordinate Y - G4int InterCoordYCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("ScorerW1/InterCoordY") ; - PosYHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordYCollectionID)) ; - Pos_Y_itr = PosYHitMap->GetMap()->begin() ; - - //Interaction Coordinate Z - G4int InterCoordZCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("ScorerW1/InterCoordZ") ; - PosZHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordZCollectionID)) ; - Pos_Z_itr = PosXHitMap->GetMap()->begin() ; - - //Interaction Coordinate Angle Theta - G4int InterCoordAngThetaCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("ScorerW1/InterCoordAngTheta") ; - AngThetaHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordAngThetaCollectionID)) ; - Ang_Theta_itr = AngThetaHitMap->GetMap()->begin() ; - - //Interaction Coordinate Angle Phi - G4int InterCoordAngPhiCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("ScorerW1/InterCoordAngPhi"); - AngPhiHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordAngPhiCollectionID)); - Ang_Phi_itr = AngPhiHitMap->GetMap()->begin(); - - // Check the size of different map - G4int sizeN = DetectorNumberHitMap->entries(); - G4int sizeE = EnergyHitMap->entries(); - G4int sizeT = TimeHitMap->entries(); - G4int sizeX = XHitMap->entries(); - G4int sizeY = YHitMap->entries(); - - if (sizeE != sizeT || sizeT != sizeX || sizeX != sizeY) { - G4cout << "No match size Si Event Map: sE:" - << sizeE << " sT:" << sizeT << " sX:" << sizeX << " sY:" << sizeY << G4endl ; - return; - } - - // Loop on W1 number - for (G4int l = 0; l < sizeN; l++) { - G4double N = *(DetectorNumber_itr->second); - G4int NTrackID = DetectorNumber_itr->first - N; - - if (N > 0) { - // Fill detector number - m_Event->SetFrontEDetectorNbr(N); - m_Event->SetFrontTDetectorNbr(N); - m_Event->SetBackEDetectorNbr(N); - m_Event->SetBackTDetectorNbr(N); - - // 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->SetFrontEEnergy(RandGauss::shoot(E, EnergyResolution)); - m_Event->SetBackEEnergy(RandGauss::shoot(E, EnergyResolution)); - } - 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->SetFrontTTime(RandGauss::shoot(T, TimeResolution)); - m_Event->SetBackTTime(RandGauss::shoot(T, TimeResolution)); - } - Time_itr++; - } - - // strip front - X_itr = XHitMap->GetMap()->begin(); - for (G4int h = 0 ; h < sizeX ; h++) { - G4int XTrackID = X_itr->first - N; - G4double X = *(X_itr->second); - if (XTrackID == NTrackID) { - m_Event->SetFrontEStripNbr(X) ; - m_Event->SetFrontTStripNbr(X) ; - } - X_itr++; - } - - // strip back - Y_itr = YHitMap->GetMap()->begin(); - for (G4int h = 0 ; h < sizeY ; h++) { - G4int YTrackID = Y_itr->first - N; - G4double Y = *(Y_itr->second); - if (YTrackID == NTrackID) { - m_Event->SetBackEStripNbr(Y); - m_Event->SetBackTStripNbr(Y); - } - Y_itr++; - } - - // Pos X - Pos_X_itr = PosXHitMap->GetMap()->begin(); - for (G4int h = 0; h < PosXHitMap->entries(); h++) { - G4int PosXTrackID = Pos_X_itr->first - N; - G4double PosX = *(Pos_X_itr->second); - if (PosXTrackID == NTrackID) { - ms_InterCoord->SetDetectedPositionX(PosX); - } - Pos_X_itr++; - } - - // Pos Y - Pos_Y_itr = PosYHitMap->GetMap()->begin(); - for (G4int h = 0; h < PosYHitMap->entries(); h++) { - G4int PosYTrackID = Pos_Y_itr->first - N; - G4double PosY = *(Pos_Y_itr->second); - if (PosYTrackID == NTrackID) { - ms_InterCoord->SetDetectedPositionY(PosY); - } - Pos_Y_itr++; - } - - // Pos Z - Pos_Z_itr = PosZHitMap->GetMap()->begin(); - for (G4int h = 0; h < PosZHitMap->entries(); h++) { - G4int PosZTrackID = Pos_Z_itr->first - N; - G4double PosZ = *(Pos_Z_itr->second); - if (PosZTrackID == NTrackID) { - ms_InterCoord->SetDetectedPositionZ(PosZ); - } - Pos_Z_itr++; - } - - // Angle Theta - Ang_Theta_itr = AngThetaHitMap->GetMap()->begin(); - for (G4int h = 0; h < AngThetaHitMap->entries(); h++) { - G4int AngThetaTrackID = Ang_Theta_itr->first - N; - G4double AngTheta = *(Ang_Theta_itr->second); - if (AngThetaTrackID == NTrackID) { - ms_InterCoord->SetDetectedAngleTheta(AngTheta); - } - Ang_Theta_itr++; - } - - // Angle Phi - Ang_Phi_itr = AngPhiHitMap->GetMap()->begin(); - for (G4int h = 0; h < AngPhiHitMap->entries(); h++) { - G4int AngPhiTrackID = Ang_Phi_itr->first - N; - G4double AngPhi = *(Ang_Phi_itr->second); - if (AngPhiTrackID == NTrackID) { - ms_InterCoord->SetDetectedAnglePhi(AngPhi); - } - Ang_Phi_itr++; - } - - } // end if number of detector > 0 - - DetectorNumber_itr++; - } // end loop on detector multiplicity - - // clear map for next event - DetectorNumberHitMap -> clear(); - EnergyHitMap -> clear(); - TimeHitMap -> clear(); - XHitMap -> clear(); - YHitMap -> clear(); - PosXHitMap -> clear(); - PosYHitMap -> clear(); - PosZHitMap -> clear(); - AngThetaHitMap -> clear(); - AngPhiHitMap -> clear(); -} +void W1::ReadSensitive(const G4Event* event) { + // Clear ROOT objects + m_Event->Clear(); + + ////////////////////////////////////////////////////////////////////////////////// + /////////////// Variables Used to Read Event Map of detector //////////////////// + ////////////////////////////////////////////////////////////////////////////////// + // First Stage + std::map<G4int, G4int*>::iterator DetectorNumber_itr; + std::map<G4int, G4double*>::iterator Energy_itr; + std::map<G4int, G4double*>::iterator Time_itr; + std::map<G4int, G4double*>::iterator X_itr; + std::map<G4int, G4double*>::iterator Y_itr; + std::map<G4int, G4double*>::iterator Pos_X_itr; + std::map<G4int, G4double*>::iterator Pos_Y_itr; + std::map<G4int, G4double*>::iterator Pos_Z_itr; + std::map<G4int, G4double*>::iterator Ang_Theta_itr; + std::map<G4int, G4double*>::iterator Ang_Phi_itr; + + NPS::HitsMap<G4int>* DetectorNumberHitMap; + NPS::HitsMap<G4double>* EnergyHitMap; + NPS::HitsMap<G4double>* TimeHitMap; + NPS::HitsMap<G4double>* XHitMap; + NPS::HitsMap<G4double>* YHitMap; + NPS::HitsMap<G4double>* PosXHitMap; + NPS::HitsMap<G4double>* PosYHitMap; + NPS::HitsMap<G4double>* PosZHitMap; + NPS::HitsMap<G4double>* AngThetaHitMap; + NPS::HitsMap<G4double>* AngPhiHitMap; + + ///////////////////////////////////////////////////////////////////////////////// + ////////////////// Read scorers //////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////////////// + // Read the Scorer associated to the first Stage + // Detector Number + G4int StripDetCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("ScorerW1/DetectorNumber"); + DetectorNumberHitMap = (NPS::HitsMap<G4int>*)(event->GetHCofThisEvent()->GetHC(StripDetCollectionID)); + DetectorNumber_itr = DetectorNumberHitMap->GetMap()->begin(); + + // Energy + G4int StripEnergyCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("ScorerW1/StripEnergy"); + EnergyHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripEnergyCollectionID)); + Energy_itr = EnergyHitMap->GetMap()->begin(); + + // Time of Flight + G4int StripTimeCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("ScorerW1/StripTime"); + TimeHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripTimeCollectionID)); + Time_itr = TimeHitMap->GetMap()->begin(); + + // Strip Number X + G4int StripXCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("ScorerW1/FrontStripNumber"); + XHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripXCollectionID)); + X_itr = XHitMap->GetMap()->begin(); + + // Strip Number Y + G4int StripYCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("ScorerW1/BackStripNumber"); + YHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(StripYCollectionID)); + Y_itr = YHitMap->GetMap()->begin(); + + // Interaction Coordinate X + G4int InterCoordXCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("ScorerW1/InterCoordX"); + PosXHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordXCollectionID)); + Pos_X_itr = PosXHitMap->GetMap()->begin(); + + // Interaction Coordinate Y + G4int InterCoordYCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("ScorerW1/InterCoordY"); + PosYHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordYCollectionID)); + Pos_Y_itr = PosYHitMap->GetMap()->begin(); + + // Interaction Coordinate Z + G4int InterCoordZCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("ScorerW1/InterCoordZ"); + PosZHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordZCollectionID)); + Pos_Z_itr = PosXHitMap->GetMap()->begin(); + + // Interaction Coordinate Angle Theta + G4int InterCoordAngThetaCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("ScorerW1/InterCoordAngTheta"); + AngThetaHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordAngThetaCollectionID)); + Ang_Theta_itr = AngThetaHitMap->GetMap()->begin(); + + // Interaction Coordinate Angle Phi + G4int InterCoordAngPhiCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("ScorerW1/InterCoordAngPhi"); + AngPhiHitMap = (NPS::HitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(InterCoordAngPhiCollectionID)); + Ang_Phi_itr = AngPhiHitMap->GetMap()->begin(); + + // Check the size of different map + G4int sizeN = DetectorNumberHitMap->entries(); + G4int sizeE = EnergyHitMap->entries(); + G4int sizeT = TimeHitMap->entries(); + G4int sizeX = XHitMap->entries(); + G4int sizeY = YHitMap->entries(); + + if (sizeE != sizeT || sizeT != sizeX || sizeX != sizeY) { + G4cout << "No match size Si Event Map: sE:" << sizeE << " sT:" << sizeT << " sX:" << sizeX << " sY:" << sizeY + << G4endl; + return; + } + // Loop on W1 number + for (G4int l = 0; l < sizeN; l++) { + G4double N = *(DetectorNumber_itr->second); + G4int NTrackID = DetectorNumber_itr->first - N; + + if (N > 0) { + // Fill detector number + m_Event->SetFrontEDetectorNbr(N); + m_Event->SetFrontTDetectorNbr(N); + m_Event->SetBackEDetectorNbr(N); + m_Event->SetBackTDetectorNbr(N); + + // 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->SetFrontEEnergy(RandGauss::shoot(E, EnergyResolution)); + m_Event->SetBackEEnergy(RandGauss::shoot(E, EnergyResolution)); + } + 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->SetFrontTTime(RandGauss::shoot(T, TimeResolution)); + m_Event->SetBackTTime(RandGauss::shoot(T, TimeResolution)); + } + Time_itr++; + } -void W1::InitializeMaterials(){ - m_MaterialSilicon = MaterialManager::getInstance()->GetMaterialFromLibrary("Si"); - m_MaterialAluminium =MaterialManager::getInstance()->GetMaterialFromLibrary("Al"); - m_MaterialIron = MaterialManager::getInstance()->GetMaterialFromLibrary("Fe"); - m_MaterialVacuum = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); -} + // strip front + X_itr = XHitMap->GetMap()->begin(); + for (G4int h = 0; h < sizeX; h++) { + G4int XTrackID = X_itr->first - N; + G4double X = *(X_itr->second); + if (XTrackID == NTrackID) { + m_Event->SetFrontEStripNbr(X); + m_Event->SetFrontTStripNbr(X); + } + X_itr++; + } + // strip back + Y_itr = YHitMap->GetMap()->begin(); + for (G4int h = 0; h < sizeY; h++) { + G4int YTrackID = Y_itr->first - N; + G4double Y = *(Y_itr->second); + if (YTrackID == NTrackID) { + m_Event->SetBackEStripNbr(Y); + m_Event->SetBackTStripNbr(Y); + } + Y_itr++; + } + // Pos X + Pos_X_itr = PosXHitMap->GetMap()->begin(); + for (G4int h = 0; h < PosXHitMap->entries(); h++) { + G4int PosXTrackID = Pos_X_itr->first - N; + G4double PosX = *(Pos_X_itr->second); + if (PosXTrackID == NTrackID) { + ms_InterCoord->SetDetectedPositionX(PosX); + } + Pos_X_itr++; + } -void W1::InitializeScorers(){ + // Pos Y + Pos_Y_itr = PosYHitMap->GetMap()->begin(); + for (G4int h = 0; h < PosYHitMap->entries(); h++) { + G4int PosYTrackID = Pos_Y_itr->first - N; + G4double PosY = *(Pos_Y_itr->second); + if (PosYTrackID == NTrackID) { + ms_InterCoord->SetDetectedPositionY(PosY); + } + Pos_Y_itr++; + } + + // Pos Z + Pos_Z_itr = PosZHitMap->GetMap()->begin(); + for (G4int h = 0; h < PosZHitMap->entries(); h++) { + G4int PosZTrackID = Pos_Z_itr->first - N; + G4double PosZ = *(Pos_Z_itr->second); + if (PosZTrackID == NTrackID) { + ms_InterCoord->SetDetectedPositionZ(PosZ); + } + Pos_Z_itr++; + } + + // Angle Theta + Ang_Theta_itr = AngThetaHitMap->GetMap()->begin(); + for (G4int h = 0; h < AngThetaHitMap->entries(); h++) { + G4int AngThetaTrackID = Ang_Theta_itr->first - N; + G4double AngTheta = *(Ang_Theta_itr->second); + if (AngThetaTrackID == NTrackID) { + ms_InterCoord->SetDetectedAngleTheta(AngTheta); + } + Ang_Theta_itr++; + } + + // Angle Phi + Ang_Phi_itr = AngPhiHitMap->GetMap()->begin(); + for (G4int h = 0; h < AngPhiHitMap->entries(); h++) { + G4int AngPhiTrackID = Ang_Phi_itr->first - N; + G4double AngPhi = *(Ang_Phi_itr->second); + if (AngPhiTrackID == NTrackID) { + ms_InterCoord->SetDetectedAnglePhi(AngPhi); + } + Ang_Phi_itr++; + } + + } // end if number of detector > 0 + + DetectorNumber_itr++; + } // end loop on detector multiplicity + + // clear map for next event + DetectorNumberHitMap->clear(); + EnergyHitMap->clear(); + TimeHitMap->clear(); + XHitMap->clear(); + YHitMap->clear(); + PosXHitMap->clear(); + PosYHitMap->clear(); + PosZHitMap->clear(); + AngThetaHitMap->clear(); + AngPhiHitMap->clear(); +} + +void W1::InitializeMaterials() { + m_MaterialSilicon = MaterialManager::getInstance()->GetMaterialFromLibrary("Si"); + m_MaterialAluminium = MaterialManager::getInstance()->GetMaterialFromLibrary("Al"); + m_MaterialIron = MaterialManager::getInstance()->GetMaterialFromLibrary("Fe"); + m_MaterialVacuum = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); +} + +void W1::InitializeScorers() { bool already_exist = false; - // Associate Scorer - m_Scorer = CheckScorer("ScorerW1",already_exist); - if(already_exist) return; - - G4VPrimitiveScorer* DetNbr = new OBSOLETEGENERALSCORERS::PSDetectorNumber("DetectorNumber", "W1Square", 0); - G4VPrimitiveScorer* Energy = new OBSOLETEGENERALSCORERS::PSEnergy("StripEnergy", "W1Square", 0); - G4VPrimitiveScorer* TOF = new OBSOLETEGENERALSCORERS::PSTOF("StripTime", "W1Square", 0); - G4VPrimitiveScorer* InteractionCoordinatesX = new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesX("InterCoordX","W1Square", 0); - G4VPrimitiveScorer* InteractionCoordinatesY = new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesY("InterCoordY","W1Square", 0); - G4VPrimitiveScorer* InteractionCoordinatesZ = new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesZ("InterCoordZ","W1Square", 0); - G4VPrimitiveScorer* InteractionCoordinatesAngleTheta = new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesAngleTheta("InterCoordAngTheta","W1Square", 0); - G4VPrimitiveScorer* InteractionCoordinatesAnglePhi = new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesAnglePhi("InterCoordAngPhi","W1Square", 0); - G4VPrimitiveScorer* ThetaStripPosition = new W1ScorerFrontStripNumber("FrontStripNumber", 0, NbStrips); - G4VPrimitiveScorer* PhiStripPosition = new W1ScorerBackStripNumber("BackStripNumber", 0, NbStrips); - - //and register it to the multifunctionnal detector - m_Scorer->RegisterPrimitive(DetNbr); - m_Scorer->RegisterPrimitive(Energy); - m_Scorer->RegisterPrimitive(TOF); - m_Scorer->RegisterPrimitive(ThetaStripPosition); - m_Scorer->RegisterPrimitive(PhiStripPosition); - m_Scorer->RegisterPrimitive(InteractionCoordinatesX); - m_Scorer->RegisterPrimitive(InteractionCoordinatesY); - m_Scorer->RegisterPrimitive(InteractionCoordinatesZ); - m_Scorer->RegisterPrimitive(InteractionCoordinatesAngleTheta); - m_Scorer->RegisterPrimitive(InteractionCoordinatesAnglePhi); - - // Add All Scorer to the Global Scorer Manager - G4SDManager::GetSDMpointer()->AddNewDetector(m_Scorer); + // Associate Scorer + m_Scorer = CheckScorer("ScorerW1", already_exist); + if (already_exist) + return; + + G4VPrimitiveScorer* DetNbr = new OBSOLETEGENERALSCORERS::PSDetectorNumber("DetectorNumber", "W1Square", 0); + G4VPrimitiveScorer* Energy = new OBSOLETEGENERALSCORERS::PSEnergy("StripEnergy", "W1Square", 0); + G4VPrimitiveScorer* TOF = new OBSOLETEGENERALSCORERS::PSTOF("StripTime", "W1Square", 0); + G4VPrimitiveScorer* InteractionCoordinatesX = + new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesX("InterCoordX", "W1Square", 0); + G4VPrimitiveScorer* InteractionCoordinatesY = + new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesY("InterCoordY", "W1Square", 0); + G4VPrimitiveScorer* InteractionCoordinatesZ = + new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesZ("InterCoordZ", "W1Square", 0); + G4VPrimitiveScorer* InteractionCoordinatesAngleTheta = + new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesAngleTheta("InterCoordAngTheta", "W1Square", 0); + G4VPrimitiveScorer* InteractionCoordinatesAnglePhi = + new OBSOLETEGENERALSCORERS::PSInteractionCoordinatesAnglePhi("InterCoordAngPhi", "W1Square", 0); + G4VPrimitiveScorer* ThetaStripPosition = new W1ScorerFrontStripNumber("FrontStripNumber", 0, NbStrips); + G4VPrimitiveScorer* PhiStripPosition = new W1ScorerBackStripNumber("BackStripNumber", 0, NbStrips); + + // and register it to the multifunctionnal detector + m_Scorer->RegisterPrimitive(DetNbr); + m_Scorer->RegisterPrimitive(Energy); + m_Scorer->RegisterPrimitive(TOF); + m_Scorer->RegisterPrimitive(ThetaStripPosition); + m_Scorer->RegisterPrimitive(PhiStripPosition); + m_Scorer->RegisterPrimitive(InteractionCoordinatesX); + m_Scorer->RegisterPrimitive(InteractionCoordinatesY); + m_Scorer->RegisterPrimitive(InteractionCoordinatesZ); + m_Scorer->RegisterPrimitive(InteractionCoordinatesAngleTheta); + m_Scorer->RegisterPrimitive(InteractionCoordinatesAnglePhi); + + // Add All Scorer to the Global Scorer Manager + G4SDManager::GetSDMpointer()->AddNewDetector(m_Scorer); } - //////////////////////////////////////////////////////////////////////////////// - // Construct Method to be pass to the DetectorFactory // - //////////////////////////////////////////////////////////////////////////////// - NPS::VDetector* W1::Construct(){ - return (NPS::VDetector*) new W1(); - } - - //////////////////////////////////////////////////////////////////////////////// - // Registering the construct method to the factory // - //////////////////////////////////////////////////////////////////////////////// - extern"C" { - class proxy_nps_w1{ - public: - proxy_nps_w1(){ - NPS::DetectorFactory::getInstance()->AddToken("W1","W1"); - NPS::DetectorFactory::getInstance()->AddDetector("W1",W1::Construct); - } +//////////////////////////////////////////////////////////////////////////////// +// Construct Method to be pass to the DetectorFactory // +//////////////////////////////////////////////////////////////////////////////// +NPS::VDetector* W1::Construct() { return (NPS::VDetector*)new W1(); } + +//////////////////////////////////////////////////////////////////////////////// +// Registering the construct method to the factory // +//////////////////////////////////////////////////////////////////////////////// +extern "C" { +class proxy_nps_w1 { + public: + proxy_nps_w1() { + NPS::DetectorFactory::getInstance()->AddToken("W1", "W1"); + NPS::DetectorFactory::getInstance()->AddDetector("W1", W1::Construct); + } }; - proxy_nps_w1 p_nps_w1; - } +proxy_nps_w1 p_nps_w1; +} diff --git a/NPSimulation/Detectors/eAGanil/eAGanil.cc b/NPSimulation/Detectors/eAGanil/eAGanil.cc index c3a5e47ae1c95c61b95d6bb3d98a1d0d539f0453..c4faf1fcb103fae75a338118987d5734e8e35f89 100644 --- a/NPSimulation/Detectors/eAGanil/eAGanil.cc +++ b/NPSimulation/Detectors/eAGanil/eAGanil.cc @@ -20,69 +20,67 @@ *****************************************************************************/ // C++ headers -#include <sstream> #include <cmath> #include <limits> -//G4 Geometry object -#include "G4Tubs.hh" +#include <sstream> +// G4 Geometry object #include "G4Box.hh" +#include "G4Tubs.hh" -//G4 sensitive -#include "G4SDManager.hh" +// G4 sensitive #include "G4MultiFunctionalDetector.hh" +#include "G4SDManager.hh" -//G4 various object +// G4 various object +#include "G4Colour.hh" #include "G4Material.hh" -#include "G4Transform3D.hh" #include "G4PVPlacement.hh" +#include "G4Transform3D.hh" #include "G4VisAttributes.hh" -#include "G4Colour.hh" // NPTool header -#include "eAGanil.hh" #include "CalorimeterScorers.hh" #include "InteractionScorers.hh" -#include "RootOutput.h" #include "MaterialManager.hh" -#include "NPSDetectorFactory.hh" #include "NPOptionManager.h" +#include "NPSDetectorFactory.hh" #include "NPSHitsMap.hh" +#include "RootOutput.h" +#include "eAGanil.hh" // CLHEP header #include "CLHEP/Random/RandGauss.h" using namespace std; using namespace CLHEP; - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -namespace eAGanil_NS{ +namespace eAGanil_NS { // Energy and time Resolution - const double EnergyThreshold = 0.1*MeV; - const double ResoTime = 4.5*ns ; - const double ResoEnergy = 1.0*MeV ; - const double Thickness = 500*mm ; + const double EnergyThreshold = 0.1 * MeV; + const double ResoTime = 4.5 * ns; + const double ResoEnergy = 1.0 * MeV; + const double Thickness = 500 * mm; const string Material = "Pb"; -} +} // namespace eAGanil_NS //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // eAGanil Specific Method -eAGanil::eAGanil(){ - m_Event = new TeAGanilData() ; +eAGanil::eAGanil() { + m_Event = new TeAGanilData(); m_eAGanilScorer = 0; - m_Length=0; + m_Length = 0; // RGB Color + Transparency - m_VisDetector = new G4VisAttributes(G4Colour(0, 1, 0, 0.5)); - m_VisTrap = new G4VisAttributes(G4Colour(0.3, 0.3, 0.3, 0.5)); + m_VisDetector = new G4VisAttributes(G4Colour(0, 1, 0, 0.5)); + m_VisTrap = new G4VisAttributes(G4Colour(0.3, 0.3, 0.3, 0.5)); } -eAGanil::~eAGanil(){ -} +eAGanil::~eAGanil() {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void eAGanil::AddDetector(double R, double Theta, double Phi, double EntranceWidth,double EntranceHeigh,double MR){ +void eAGanil::AddDetector(double R, double Theta, double Phi, double EntranceWidth, double EntranceHeigh, double MR) { m_SpecR.push_back(R); m_SpecTheta.push_back(Theta); m_SpecPhi.push_back(Phi); @@ -92,60 +90,54 @@ void eAGanil::AddDetector(double R, double Theta, double Phi, double Entrance } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void eAGanil::SetTrap(double Length, double InnerRadius, double OuterRadius, double BladesThickness, int NumberOfBlades,double Phi, double WindowsThickness){ - m_Length=Length; - m_InnerRadius=InnerRadius; - m_OuterRadius=OuterRadius; - m_BladesThickness=BladesThickness; - m_NumberOfBlades=NumberOfBlades; - m_Phi=Phi; - m_WindowsThickness=WindowsThickness; +void eAGanil::SetTrap(double Length, double InnerRadius, double OuterRadius, double BladesThickness, int NumberOfBlades, + double Phi, double WindowsThickness) { + m_Length = Length; + m_InnerRadius = InnerRadius; + m_OuterRadius = OuterRadius; + m_BladesThickness = BladesThickness; + m_NumberOfBlades = NumberOfBlades; + m_Phi = Phi; + m_WindowsThickness = WindowsThickness; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -G4LogicalVolume* eAGanil::BuildDetector(unsigned int i){ - G4Box* box = new G4Box("eAGanil_Box",m_SpecEntranceHeigh[i]*0.5, - m_SpecEntranceWidth[i]*0.5,eAGanil_NS::Thickness*0.5); +G4LogicalVolume* eAGanil::BuildDetector(unsigned int i) { + G4Box* box = + new G4Box("eAGanil_Box", m_SpecEntranceHeigh[i] * 0.5, m_SpecEntranceWidth[i] * 0.5, eAGanil_NS::Thickness * 0.5); G4Material* DetectorMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary(eAGanil_NS::Material); - G4LogicalVolume* Detector = new G4LogicalVolume(box,DetectorMaterial,"logic_eAGanil_spec",0,0,0); + G4LogicalVolume* Detector = new G4LogicalVolume(box, DetectorMaterial, "logic_eAGanil_spec", 0, 0, 0); Detector->SetVisAttributes(m_VisDetector); Detector->SetSensitiveDetector(m_eAGanilScorer); return Detector; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -G4LogicalVolume* eAGanil::BuildTrap(){ - G4Tubs* tubs = new G4Tubs("eAGanil_Trap",m_InnerRadius*0.9,m_OuterRadius*1.1,m_Length*0.5,0,360*deg ); +G4LogicalVolume* eAGanil::BuildTrap() { + G4Tubs* tubs = new G4Tubs("eAGanil_Trap", m_InnerRadius * 0.9, m_OuterRadius * 1.1, m_Length * 0.5, 0, 360 * deg); G4Material* VacuumMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary("Vacuum"); - G4LogicalVolume* Trap = new G4LogicalVolume(tubs,VacuumMaterial,"logic_eAGanil_trap",0,0,0); - Trap->SetVisAttributes(G4VisAttributes::Invisible); + G4LogicalVolume* Trap = new G4LogicalVolume(tubs, VacuumMaterial, "logic_eAGanil_trap", 0, 0, 0); + Trap->SetVisAttributes(G4VisAttributes::GetInvisible()); - - G4Box* box = new G4Box("eAGanil_Blades", - m_BladesThickness*0.5, - (m_OuterRadius-m_InnerRadius)*0.5, - m_Length*0.5 - ); + G4Box* box = + new G4Box("eAGanil_Blades", m_BladesThickness * 0.5, (m_OuterRadius - m_InnerRadius) * 0.5, m_Length * 0.5); G4Material* TrapMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary("Al"); - G4LogicalVolume* Blades = new G4LogicalVolume(box,TrapMaterial,"logic_eAGanil_trap",0,0,0); + G4LogicalVolume* Blades = new G4LogicalVolume(box, TrapMaterial, "logic_eAGanil_trap", 0, 0, 0); Blades->SetVisAttributes(m_VisTrap); G4RotationMatrix* Rot = new G4RotationMatrix(); - G4ThreeVector Pos(0,(m_OuterRadius-m_InnerRadius)*0.5+m_InnerRadius,0); - for(unsigned int i = 0 ; i < m_NumberOfBlades ; i++){ - Rot->rotateZ(360.*deg/m_NumberOfBlades); - Pos.rotateZ(360.*deg/m_NumberOfBlades); - new G4PVPlacement(G4Transform3D(*Rot,Pos), - Blades, - "eAGanil",Trap,false,1); - } - + G4ThreeVector Pos(0, (m_OuterRadius - m_InnerRadius) * 0.5 + m_InnerRadius, 0); + for (unsigned int i = 0; i < m_NumberOfBlades; i++) { + Rot->rotateZ(360. * deg / m_NumberOfBlades); + Pos.rotateZ(360. * deg / m_NumberOfBlades); + new G4PVPlacement(G4Transform3D(*Rot, Pos), Blades, "eAGanil", Trap, false, 1); + } + return Trap; } - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... @@ -153,151 +145,147 @@ G4LogicalVolume* eAGanil::BuildTrap(){ // Read stream at Configfile to pick-up parameters of detector (Position,...) // Called in DetecorConstruction::ReadDetextorConfiguration Method -void eAGanil::ReadConfiguration(NPL::InputParser parser){ - vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithTokenAndValue("eAGanil","Spectrometer"); - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << "//// " << blocks.size() << " detectors found " << endl; - - vector<string> sphe = {"R","Theta","Phi","EntranceWidth","EntranceHeight","MomentumResolution"}; - - for(unsigned int i = 0 ; i < blocks.size() ; i++){ - if(blocks[i]->HasTokenList(sphe)){ - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << endl << "//// eAGanil " << i+1 << endl; - double R = blocks[i]->GetDouble("R","mm"); - double Theta = blocks[i]->GetDouble("Theta","deg"); - double Phi = blocks[i]->GetDouble("Phi","deg"); - double EW = blocks[i]->GetDouble("EntranceWidth","cm"); - double EH = blocks[i]->GetDouble("EntranceHeight","cm"); - double MR = blocks[i]->GetDouble("MomentumResolution","void"); - AddDetector(R,Theta,Phi,EW,EH,MR); +void eAGanil::ReadConfiguration(NPL::InputParser parser) { + vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithTokenAndValue("eAGanil", "Spectrometer"); + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks.size() << " detectors found " << endl; + + vector<string> sphe = {"R", "Theta", "Phi", "EntranceWidth", "EntranceHeight", "MomentumResolution"}; + + for (unsigned int i = 0; i < blocks.size(); i++) { + if (blocks[i]->HasTokenList(sphe)) { + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// eAGanil " << i + 1 << endl; + double R = blocks[i]->GetDouble("R", "mm"); + double Theta = blocks[i]->GetDouble("Theta", "deg"); + double Phi = blocks[i]->GetDouble("Phi", "deg"); + double EW = blocks[i]->GetDouble("EntranceWidth", "cm"); + double EH = blocks[i]->GetDouble("EntranceHeight", "cm"); + double MR = blocks[i]->GetDouble("MomentumResolution", "void"); + AddDetector(R, Theta, Phi, EW, EH, MR); } - else{ + else { cout << "ERROR: check your input file formatting " << endl; exit(1); } } - blocks = parser.GetAllBlocksWithTokenAndValue("eAGanil","Trap"); - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << "//// " << blocks.size() << " detectors found " << endl; - - vector<string> trap= {"Length","InnerRadius", "OuterRadius","BladesThickness","NumberOfBlades","Phi","WindowsThickness"}; - - for(unsigned int i = 0 ; i < blocks.size() ; i++){ - if(blocks[i]->HasTokenList(trap)){ - if(NPOptionManager::getInstance()->GetVerboseLevel()) - cout << endl << "//// eAGanil " << i+1 << endl; - - double L = blocks[i]->GetDouble("Length","mm"); - double iR = blocks[i]->GetDouble("InnerRadius","mm"); - double oR = blocks[i]->GetDouble("OuterRadius","mm"); - double fT = blocks[i]->GetDouble("BladesThickness","mm"); - int nF = blocks[i]->GetInt("NumberOfBlades"); - double Phi = blocks[i]->GetDouble("Phi","deg"); - double wT = blocks[i]->GetDouble("WindowsThickness","mm"); - SetTrap(L,iR,oR,fT,nF,Phi,wT); + blocks = parser.GetAllBlocksWithTokenAndValue("eAGanil", "Trap"); + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << "//// " << blocks.size() << " detectors found " << endl; + + vector<string> trap = {"Length", "InnerRadius", "OuterRadius", "BladesThickness", + "NumberOfBlades", "Phi", "WindowsThickness"}; + + for (unsigned int i = 0; i < blocks.size(); i++) { + if (blocks[i]->HasTokenList(trap)) { + if (NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// eAGanil " << i + 1 << endl; + + double L = blocks[i]->GetDouble("Length", "mm"); + double iR = blocks[i]->GetDouble("InnerRadius", "mm"); + double oR = blocks[i]->GetDouble("OuterRadius", "mm"); + double fT = blocks[i]->GetDouble("BladesThickness", "mm"); + int nF = blocks[i]->GetInt("NumberOfBlades"); + double Phi = blocks[i]->GetDouble("Phi", "deg"); + double wT = blocks[i]->GetDouble("WindowsThickness", "mm"); + SetTrap(L, iR, oR, fT, nF, Phi, wT); } - else{ + else { cout << "ERROR: check your input file formatting " << endl; exit(1); } } - } - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Construct detector and inialise sensitive part. // Called After DetecorConstruction::AddDetector Method -void eAGanil::ConstructDetector(G4LogicalVolume* world){ - for (unsigned short i = 0 ; i < m_SpecR.size() ; i++) { - G4double wX = m_SpecR[i] * sin(m_SpecTheta[i] ) * cos(m_SpecPhi[i] ) ; - G4double wY = m_SpecR[i] * sin(m_SpecTheta[i] ) * sin(m_SpecPhi[i] ) ; - G4double wZ = m_SpecR[i] * cos(m_SpecTheta[i] ) ; - G4ThreeVector Det_pos = G4ThreeVector(wX, wY, wZ) ; +void eAGanil::ConstructDetector(G4LogicalVolume* world) { + for (unsigned short i = 0; i < m_SpecR.size(); i++) { + G4double wX = m_SpecR[i] * sin(m_SpecTheta[i]) * cos(m_SpecPhi[i]); + G4double wY = m_SpecR[i] * sin(m_SpecTheta[i]) * sin(m_SpecPhi[i]); + G4double wZ = m_SpecR[i] * cos(m_SpecTheta[i]); + G4ThreeVector Det_pos = G4ThreeVector(wX, wY, wZ); // So the face of the detector is at R instead of the middle - Det_pos+=Det_pos.unit()*eAGanil_NS::Thickness*0.5; + Det_pos += Det_pos.unit() * eAGanil_NS::Thickness * 0.5; // Building Detector reference frame G4double ii = cos(m_SpecTheta[i]) * cos(m_SpecPhi[i]); G4double jj = cos(m_SpecTheta[i]) * sin(m_SpecPhi[i]); G4double kk = -sin(m_SpecTheta[i]); - G4ThreeVector Y(ii,jj,kk); + G4ThreeVector Y(ii, jj, kk); G4ThreeVector w = Det_pos.unit(); G4ThreeVector u = w.cross(Y); G4ThreeVector v = w.cross(u); v = v.unit(); u = u.unit(); - G4RotationMatrix* Rot = new G4RotationMatrix(u,v,w); + G4RotationMatrix* Rot = new G4RotationMatrix(u, v, w); - new G4PVPlacement(G4Transform3D(*Rot,Det_pos), - BuildDetector(i), - "eAGanil",world,false,i+1); + new G4PVPlacement(G4Transform3D(*Rot, Det_pos), BuildDetector(i), "eAGanil", world, false, i + 1); } - if(m_Length){ + if (m_Length) { G4RotationMatrix* Rot = new G4RotationMatrix(); Rot->rotateZ(m_Phi); - - new G4PVPlacement(G4Transform3D(*Rot,G4ThreeVector(0,0,0)), - BuildTrap(), - "eAGanil",world,false,1); + + new G4PVPlacement(G4Transform3D(*Rot, G4ThreeVector(0, 0, 0)), BuildTrap(), "eAGanil", world, false, 1); } } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Add Detector branch to the EventTree. // Called After DetecorConstruction::AddDetector Method -void eAGanil::InitializeRootOutput(){ - RootOutput *pAnalysis = RootOutput::getInstance(); - TTree *pTree = pAnalysis->GetTree(); - if(!pTree->FindBranch("eAGanil")){ - pTree->Branch("eAGanil", "TeAGanilData", &m_Event) ; +void eAGanil::InitializeRootOutput() { + RootOutput* pAnalysis = RootOutput::getInstance(); + TTree* pTree = pAnalysis->GetTree(); + if (!pTree->FindBranch("eAGanil")) { + pTree->Branch("eAGanil", "TeAGanilData", &m_Event); } - pTree->SetBranchAddress("eAGanil", &m_Event) ; + pTree->SetBranchAddress("eAGanil", &m_Event); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Read sensitive part and fill the Root tree. // Called at in the EventAction::EndOfEventAvtion -void eAGanil::ReadSensitive(const G4Event* ){ +void eAGanil::ReadSensitive(const G4Event*) { m_Event->Clear(); /////////// // Calorimeter scorer - CalorimeterScorers::PS_Calorimeter* Scorer= (CalorimeterScorers::PS_Calorimeter*) m_eAGanilScorer->GetPrimitive(0); - - unsigned int size = Scorer->GetMult(); - for(unsigned int i = 0 ; i < size ; i++){ - vector<unsigned int> level = Scorer->GetLevel(i); - double Energy = RandGauss::shoot(Scorer->GetEnergy(i),eAGanil_NS::ResoEnergy); - if(Energy>eAGanil_NS::EnergyThreshold){ - double Time = RandGauss::shoot(Scorer->GetTime(i),eAGanil_NS::ResoTime); + CalorimeterScorers::PS_Calorimeter* Scorer = (CalorimeterScorers::PS_Calorimeter*)m_eAGanilScorer->GetPrimitive(0); + + unsigned int size = Scorer->GetMult(); + for (unsigned int i = 0; i < size; i++) { + vector<unsigned int> level = Scorer->GetLevel(i); + double Energy = RandGauss::shoot(Scorer->GetEnergy(i), eAGanil_NS::ResoEnergy); + if (Energy > eAGanil_NS::EnergyThreshold) { + double Time = RandGauss::shoot(Scorer->GetTime(i), eAGanil_NS::ResoTime); int DetectorNbr = level[0]; - m_Event->SetEnergy(DetectorNbr,Energy); - m_Event->SetTime(DetectorNbr,Time); + m_Event->SetEnergy(DetectorNbr, Energy); + m_Event->SetTime(DetectorNbr, Time); } } } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -//////////////////////////////////////////////////////////////// -void eAGanil::InitializeScorers() { +//////////////////////////////////////////////////////////////// +void eAGanil::InitializeScorers() { // This check is necessary in case the geometry is reloaded - bool already_exist = false; - m_eAGanilScorer = CheckScorer("eAGanilScorer",already_exist) ; + bool already_exist = false; + m_eAGanilScorer = CheckScorer("eAGanilScorer", already_exist); - if(already_exist) - return ; + if (already_exist) + return; // Otherwise the scorer is initialised - vector<int> level; level.push_back(0); - G4VPrimitiveScorer* Calorimeter= new CalorimeterScorers::PS_Calorimeter("Calorimeter",level, 0) ; - G4VPrimitiveScorer* Interaction= new InteractionScorers::PS_Interactions("Interaction",ms_InterCoord, 0) ; - //and register it to the multifunctionnal detector + vector<int> level; + level.push_back(0); + G4VPrimitiveScorer* Calorimeter = new CalorimeterScorers::PS_Calorimeter("Calorimeter", level, 0); + G4VPrimitiveScorer* Interaction = new InteractionScorers::PS_Interactions("Interaction", ms_InterCoord, 0); + // and register it to the multifunctionnal detector m_eAGanilScorer->RegisterPrimitive(Calorimeter); m_eAGanilScorer->RegisterPrimitive(Interaction); - G4SDManager::GetSDMpointer()->AddNewDetector(m_eAGanilScorer) ; + G4SDManager::GetSDMpointer()->AddNewDetector(m_eAGanilScorer); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... @@ -306,22 +294,20 @@ void eAGanil::InitializeScorers() { //////////////////////////////////////////////////////////////////////////////// // Construct Method to be pass to the DetectorFactory // //////////////////////////////////////////////////////////////////////////////// -NPS::VDetector* eAGanil::Construct(){ - return (NPS::VDetector*) new eAGanil(); -} +NPS::VDetector* eAGanil::Construct() { return (NPS::VDetector*)new eAGanil(); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //////////////////////////////////////////////////////////////////////////////// // Registering the construct method to the factory // //////////////////////////////////////////////////////////////////////////////// -extern"C" { - class proxy_nps_eAGanil{ - public: - proxy_nps_eAGanil(){ - NPS::DetectorFactory::getInstance()->AddToken("eAGanil","eAGanil"); - NPS::DetectorFactory::getInstance()->AddDetector("eAGanil",eAGanil::Construct); - } - }; - - proxy_nps_eAGanil p_nps_eAGanil; +extern "C" { +class proxy_nps_eAGanil { + public: + proxy_nps_eAGanil() { + NPS::DetectorFactory::getInstance()->AddToken("eAGanil", "eAGanil"); + NPS::DetectorFactory::getInstance()->AddDetector("eAGanil", eAGanil::Construct); + } +}; + +proxy_nps_eAGanil p_nps_eAGanil; } diff --git a/NPSimulation/Process/BeamReaction.cc b/NPSimulation/Process/BeamReaction.cc index 67f2e57262b78fba39c689cc013d48dd239c2e13..73ae9ab1de7432b17f208c9262322fa38b4b8c04 100644 --- a/NPSimulation/Process/BeamReaction.cc +++ b/NPSimulation/Process/BeamReaction.cc @@ -23,86 +23,85 @@ #include "BeamReaction.hh" #include "G4Electron.hh" -#include "G4Gamma.hh" -#include "G4SystemOfUnits.hh" #include "G4EmCalculator.hh" -#include "G4VPhysicalVolume.hh" +#include "G4Gamma.hh" #include "G4IonTable.hh" +#include "G4SystemOfUnits.hh" #include "G4UserLimits.hh" +#include "G4VPhysicalVolume.hh" #include "NPFunction.h" #include "NPInputParser.h" #include "NPOptionManager.h" +#include "NPSFunction.hh" #include "RootOutput.h" #include "TLorentzVector.h" -#include "NPSFunction.hh" #include <Randomize.hh> #include <iostream> #include <string> -#include "G4UserLimits.hh" //////////////////////////////////////////////////////////////////////////////// -NPS::BeamReaction::BeamReaction(G4String modelName, G4Region* envelope) - : G4VFastSimulationModel(modelName, envelope) { - ReadConfiguration(); - m_shoot=false; - m_rand=0; - m_Z=0; - m_event_weight=1; - ABLA = new G4AblaInterface(); - } +NPS::BeamReaction::BeamReaction(G4String modelName, G4Region* envelope) : G4VFastSimulationModel(modelName, envelope) { + ReadConfiguration(); + m_shoot = false; + m_rand = 0; + m_Z = 0; + m_event_weight = 1; + ABLA = new G4AblaInterface(); +} //////////////////////////////////////////////////////////////////////////////// -NPS::BeamReaction::BeamReaction(G4String modelName) - : G4VFastSimulationModel(modelName) {} - - //////////////////////////////////////////////////////////////////////////////// - NPS::BeamReaction::~BeamReaction() {} - - //////////////////////////////////////////////////////////////////////////////// - void NPS::BeamReaction::AttachReactionConditions() { - // Reasssigned the branch address - if (RootOutput::getInstance()->GetTree()->FindBranch("ReactionConditions")) - RootOutput::getInstance()->GetTree()->SetBranchAddress( - "ReactionConditions", &m_ReactionConditions); - } +NPS::BeamReaction::BeamReaction(G4String modelName) : G4VFastSimulationModel(modelName) {} + +//////////////////////////////////////////////////////////////////////////////// +NPS::BeamReaction::~BeamReaction() {} + +//////////////////////////////////////////////////////////////////////////////// +void NPS::BeamReaction::AttachReactionConditions() { + // Reasssigned the branch address + if (RootOutput::getInstance()->GetTree()->FindBranch("ReactionConditions")) + RootOutput::getInstance()->GetTree()->SetBranchAddress("ReactionConditions", &m_ReactionConditions); +} //////////////////////////////////////////////////////////////////////////////// void NPS::BeamReaction::ReadConfiguration() { NPL::InputParser input(NPOptionManager::getInstance()->GetReactionFile()); - if(input.GetAllBlocksWithToken("TwoBodyReaction").size()>0) m_ReactionType =TwoBody; - else if(input.GetAllBlocksWithToken("QFSReaction").size()>0) m_ReactionType =QFS; - else if(input.GetAllBlocksWithToken("PhaseSpace").size()>0) m_ReactionType =PhaseSpace; - else if(input.GetAllBlocksWithToken("FusionReaction").size()>0) m_ReactionType =Fusion; + if (input.GetAllBlocksWithToken("TwoBodyReaction").size() > 0) + m_ReactionType = TwoBody; + else if (input.GetAllBlocksWithToken("QFSReaction").size() > 0) + m_ReactionType = QFS; + else if (input.GetAllBlocksWithToken("PhaseSpace").size() > 0) + m_ReactionType = PhaseSpace; + else if (input.GetAllBlocksWithToken("FusionReaction").size() > 0) + m_ReactionType = Fusion; // Two body - if (m_ReactionType==TwoBody ) { + if (m_ReactionType == TwoBody) { m_Reaction.ReadConfigurationFile(input); m_BeamName = NPL::ChangeNameToG4Standard(m_Reaction.GetParticle1()->GetName()); - if(m_Reaction.GetParticle3()->GetName() != ""){ + if (m_Reaction.GetParticle3()->GetName() != "") { m_active = true; m_ReactionConditions = new TReactionConditions(); AttachReactionConditions(); if (!RootOutput::getInstance()->GetTree()->FindBranch("ReactionConditions")) - RootOutput::getInstance()->GetTree()->Branch( - "ReactionConditions", "TReactionConditions", &m_ReactionConditions); + RootOutput::getInstance()->GetTree()->Branch("ReactionConditions", "TReactionConditions", + &m_ReactionConditions); } - } + } // QFS - else if (m_ReactionType==QFS) { + else if (m_ReactionType == QFS) { m_QFS.ReadConfigurationFile(input); m_BeamName = NPL::ChangeNameToG4Standard(m_QFS.GetParticleA()->GetName()); m_active = true; m_ReactionConditions = new TReactionConditions(); AttachReactionConditions(); if (!RootOutput::getInstance()->GetTree()->FindBranch("ReactionConditions")) - RootOutput::getInstance()->GetTree()->Branch( - "ReactionConditions", "TReactionConditions", &m_ReactionConditions); + RootOutput::getInstance()->GetTree()->Branch("ReactionConditions", "TReactionConditions", &m_ReactionConditions); } // PhaseSpace - else if (m_ReactionType==PhaseSpace) { + else if (m_ReactionType == PhaseSpace) { m_PhaseSpace.ReadConfigurationFile(input); m_BeamName = NPL::ChangeNameToG4Standard(m_PhaseSpace.GetBeam()->GetName()); m_active = true; @@ -113,12 +112,12 @@ void NPS::BeamReaction::ReadConfiguration() { } // Fusion - else if (m_ReactionType==Fusion) { - vector<InputBlock*> blocks=input.GetAllBlocksWithToken("FusionReaction"); + else if (m_ReactionType == Fusion) { + vector<InputBlock*> blocks = input.GetAllBlocksWithToken("FusionReaction"); m_BeamName = NPL::ChangeNameToG4Standard(blocks[0]->GetString("Beam")); m_TargetNuclei = blocks[0]->GetString("Target"); m_FusionProduct = blocks[0]->GetString("Product"); - m_FusionExcitation = blocks[0]->GetDouble("ExcitationEnergy","MeV"); + m_FusionExcitation = blocks[0]->GetDouble("ExcitationEnergy", "MeV"); m_active = true; // not used m_ReactionConditions = new TReactionConditions(); @@ -135,8 +134,10 @@ G4bool NPS::BeamReaction::IsApplicable(const G4ParticleDefinition& particleType) static std::string particleName; particleName = particleType.GetParticleName(); - if(particleName=="neutron") particleName="n1"; - else if(particleName=="e-") particleName="electron"; + if (particleName == "neutron") + particleName = "n1"; + else if (particleName == "e-") + particleName = "electron"; if (particleName.find(m_BeamName) != std::string::npos) { return true; } @@ -145,78 +146,72 @@ G4bool NPS::BeamReaction::IsApplicable(const G4ParticleDefinition& particleType) //////////////////////////////////////////////////////////////////////////////// G4bool NPS::BeamReaction::ModelTrigger(const G4FastTrack& fastTrack) { - //cout<< "--------- MODEL TRIG ---------"<<endl; + // cout<< "--------- MODEL TRIG ---------"<<endl; const G4Track* PrimaryTrack = fastTrack.GetPrimaryTrack(); m_Parent_ID = PrimaryTrack->GetParentID(); // process reserved to the beam - if(m_Parent_ID!=0) + if (m_Parent_ID != 0) return false; - G4ThreeVector V = PrimaryTrack->GetMomentum().unit(); - G4ThreeVector P = fastTrack.GetPrimaryTrackLocalPosition(); - G4VSolid* solid = fastTrack.GetPrimaryTrack() - ->GetVolume() - ->GetLogicalVolume() - ->GetSolid(); - double to_exit = solid->DistanceToOut(P, V); - double to_entrance = solid->DistanceToOut(P, -V); - bool is_first = (to_entrance==0); - - if(is_first && m_shoot){ + G4ThreeVector V = PrimaryTrack->GetMomentum().unit(); + G4ThreeVector P = fastTrack.GetPrimaryTrackLocalPosition(); + G4VSolid* solid = fastTrack.GetPrimaryTrack()->GetVolume()->GetLogicalVolume()->GetSolid(); + double to_exit = solid->DistanceToOut(P, V); + double to_entrance = solid->DistanceToOut(P, -V); + bool is_first = (to_entrance == 0); + + if (is_first && m_shoot) { /* Does occur rarely when event is tangent to the target surface and scatters out - std::cout << "Something went wrong in beam reaction, m_shoot and is_first variables cannot be true simultaneously" << std::endl; - std::cout << "m_shoot: " << m_shoot << std::endl; - std::cout << "rand: " << m_rand << std::endl; - std::cout << "to_entrance: " << to_entrance << std::endl; - std::cout << "to_exit: " << to_exit << std::endl; - std::cout << "length: " << m_length << std::endl; - std::cout << "step: " << m_StepSize << std::endl; + std::cout << "Something went wrong in beam reaction, m_shoot and is_first variables cannot be true + simultaneously" << std::endl; std::cout << "m_shoot: " << m_shoot << std::endl; std::cout << "rand: " << m_rand + << std::endl; std::cout << "to_entrance: " << to_entrance << std::endl; std::cout << "to_exit: " << to_exit << + std::endl; std::cout << "length: " << m_length << std::endl; std::cout << "step: " << m_StepSize << std::endl; std::cout << "Z: " << m_Z << std::endl; std::cout << "S: " << m_S << std::endl; */ m_shoot = false; } - if(is_first){ - m_rand = G4RandFlat::shoot(); + if (is_first) { + m_rand = G4RandFlat::shoot(); // random Z in the Volume - m_Z = m_rand*(to_exit+to_entrance)-0.5*(to_exit+to_entrance); + m_Z = m_rand * (to_exit + to_entrance) - 0.5 * (to_exit + to_entrance); // Clear Previous Event m_ReactionConditions->Clear(); - m_shoot=true; + m_shoot = true; } // curviligne coordinate along beam path - m_S = to_entrance - 0.5*(to_exit+to_entrance); - m_length = m_Z-m_S; + m_S = to_entrance - 0.5 * (to_exit + to_entrance); + m_length = m_Z - m_S; m_StepSize = PrimaryTrack->GetVolume()->GetLogicalVolume()->GetUserLimits()->GetMaxAllowedStep(*PrimaryTrack); // If the condition is met, the event is generated if (m_shoot && m_length < m_StepSize) { - if(m_ReactionType==QFS){ - //if ( m_QFS.IsAllowed() ) { + if (m_ReactionType == QFS) { + // if ( m_QFS.IsAllowed() ) { return true; //} - //else{ + // else{ // m_shoot=false; // std::cout << "QFS not allowed" << std::endl; //} } - else if(m_ReactionType==TwoBody){ - if ( m_Reaction.IsAllowed(PrimaryTrack->GetKineticEnergy()) ) { + else if (m_ReactionType == TwoBody) { + if (m_Reaction.IsAllowed(PrimaryTrack->GetKineticEnergy())) { return true; - } - else{ - m_shoot=false; + } + else { + m_shoot = false; std::cout << "Two body reaction not allowed" << std::endl; } } - else if(m_ReactionType==Fusion){ + else if (m_ReactionType == Fusion) { return true; } - else if(m_ReactionType==PhaseSpace){ + else if (m_ReactionType == PhaseSpace) { return true; } } @@ -225,35 +220,25 @@ G4bool NPS::BeamReaction::ModelTrigger(const G4FastTrack& fastTrack) { } //////////////////////////////////////////////////////////////////////////////// -void NPS::BeamReaction::DoIt(const G4FastTrack& fastTrack, - G4FastStep& fastStep) { +void NPS::BeamReaction::DoIt(const G4FastTrack& fastTrack, G4FastStep& fastStep) { - // std::cout << "DOIT" << std::endl; - m_shoot=false; - m_length=abs(m_length); + // std::cout << "DOIT" << std::endl; + m_shoot = false; + m_length = abs(m_length); // Get the track info const G4Track* PrimaryTrack = fastTrack.GetPrimaryTrack(); - G4ThreeVector pdirection = PrimaryTrack->GetMomentum().unit(); - G4ThreeVector localdir = fastTrack.GetPrimaryTrackLocalDirection(); + G4ThreeVector pdirection = PrimaryTrack->GetMomentum().unit(); + G4ThreeVector localdir = fastTrack.GetPrimaryTrackLocalDirection(); G4ThreeVector worldPosition = PrimaryTrack->GetPosition(); G4ThreeVector localPosition = fastTrack.GetPrimaryTrackLocalPosition(); - G4Material* material = fastTrack.GetPrimaryTrack() - ->GetVolume() - ->GetLogicalVolume() - ->GetMaterial(); + G4Material* material = fastTrack.GetPrimaryTrack()->GetVolume()->GetLogicalVolume()->GetMaterial(); double energy = PrimaryTrack->GetKineticEnergy(); - double speed = PrimaryTrack->GetVelocity(); - double time = PrimaryTrack->GetGlobalTime()+m_length/speed; - - - double reac_energy = SlowDownBeam ( - PrimaryTrack->GetParticleDefinition(), - energy, - m_length, - material); + double speed = PrimaryTrack->GetVelocity(); + double time = PrimaryTrack->GetGlobalTime() + m_length / speed; + double reac_energy = SlowDownBeam(PrimaryTrack->GetParticleDefinition(), energy, m_length, material); G4ThreeVector ldir = pdirection; ldir *= m_length; @@ -263,41 +248,37 @@ void NPS::BeamReaction::DoIt(const G4FastTrack& fastTrack, fastStep.SetPrimaryTrackFinalKineticEnergyAndDirection(0, pdirection); fastStep.SetPrimaryTrackFinalPosition(worldPosition); fastStep.SetTotalEnergyDeposited(0); - fastStep.SetPrimaryTrackFinalTime(time);// FIXME + fastStep.SetPrimaryTrackFinalTime(time); // FIXME fastStep.KillPrimaryTrack(); fastStep.SetPrimaryTrackPathLength(0.0); /////////////////////////////// // Two-Body Reaction Case ///// /////////////////////////////// - if (m_ReactionType==TwoBody) { + if (m_ReactionType == TwoBody) { - static G4IonTable* IonTable - = G4ParticleTable::GetParticleTable()->GetIonTable(); + static G4IonTable* IonTable = G4ParticleTable::GetParticleTable()->GetIonTable(); //////Define the kind of particle to shoot//////// // Particle 3 G4ParticleDefinition* LightName; - if(m_Reaction.GetParticle3()->GetName()=="electron"){ - LightName=G4Electron::Definition(); + if (m_Reaction.GetParticle3()->GetName() == "electron") { + LightName = G4Electron::Definition(); } - else{ + else { int LightZ = m_Reaction.GetParticle3()->GetZ(); int LightA = m_Reaction.GetParticle3()->GetA(); - if (LightZ == 0 && LightA == 1){ + if (LightZ == 0 && LightA == 1) { LightName = G4Neutron::Definition(); - } + } else { if (m_Reaction.GetUseExInGeant4()) - LightName - = IonTable->GetIon(LightZ, LightA, m_Reaction.GetExcitation3() * MeV); + LightName = IonTable->GetIon(LightZ, LightA, m_Reaction.GetExcitation3() * MeV); else LightName = IonTable->GetIon(LightZ, LightA); } - } - // Particle 4 G4int HeavyZ = m_Reaction.GetParticle4()->GetZ(); G4int HeavyA = m_Reaction.GetParticle4()->GetA(); @@ -309,8 +290,7 @@ void NPS::BeamReaction::DoIt(const G4FastTrack& fastTrack, G4ParticleDefinition* HeavyName; if (m_Reaction.GetUseExInGeant4()) - HeavyName - = IonTable->GetIon(HeavyZ, HeavyA, m_Reaction.GetExcitation4() * MeV); + HeavyName = IonTable->GetIon(HeavyZ, HeavyA, m_Reaction.GetExcitation4() * MeV); else HeavyName = IonTable->GetIon(HeavyZ, HeavyA); @@ -318,13 +298,12 @@ void NPS::BeamReaction::DoIt(const G4FastTrack& fastTrack, m_Reaction.SetBeamEnergy(reac_energy); double Beam_theta = pdirection.theta(); - double Beam_phi = pdirection.phi(); + double Beam_phi = pdirection.phi(); /////////////////////////// ///// Beam Parameters ///// /////////////////////////// - m_ReactionConditions->SetBeamParticleName( - PrimaryTrack->GetParticleDefinition()->GetParticleName()); + m_ReactionConditions->SetBeamParticleName(PrimaryTrack->GetParticleDefinition()->GetParticleName()); m_ReactionConditions->SetBeamReactionEnergy(reac_energy); m_ReactionConditions->SetVertexPositionX(localPosition.x()); @@ -334,21 +313,16 @@ void NPS::BeamReaction::DoIt(const G4FastTrack& fastTrack, G4ThreeVector U(1, 0, 0); G4ThreeVector V(0, 1, 0); G4ThreeVector ZZ(0, 0, 1); - m_ReactionConditions->SetBeamEmittanceTheta( - PrimaryTrack->GetMomentumDirection().theta() / deg); - m_ReactionConditions->SetBeamEmittancePhi( - PrimaryTrack->GetMomentumDirection().phi() / deg); - m_ReactionConditions->SetBeamEmittanceThetaX( - PrimaryTrack->GetMomentumDirection().angle(U) / deg); - m_ReactionConditions->SetBeamEmittancePhiY( - PrimaryTrack->GetMomentumDirection().angle(V) / deg); + m_ReactionConditions->SetBeamEmittanceTheta(PrimaryTrack->GetMomentumDirection().theta() / deg); + m_ReactionConditions->SetBeamEmittancePhi(PrimaryTrack->GetMomentumDirection().phi() / deg); + m_ReactionConditions->SetBeamEmittanceThetaX(PrimaryTrack->GetMomentumDirection().angle(U) / deg); + m_ReactionConditions->SetBeamEmittancePhiY(PrimaryTrack->GetMomentumDirection().angle(V) / deg); ////////////////////////////////////////////////////////// ///// Build rotation matrix to go from the incident ////// ///// beam frame to the "world" frame ////// ////////////////////////////////////////////////////////// - // G4ThreeVector col1(cos(Beam_theta) * cos(Beam_phi), // cos(Beam_theta) * sin(Beam_phi), // -sin(Beam_theta)); @@ -380,22 +354,20 @@ void NPS::BeamReaction::DoIt(const G4FastTrack& fastTrack, // Compute Kinematic using previously defined ThetaCM m_Reaction.KineRelativistic(Theta3, Energy3, Theta4, Energy4); // Momentum in beam frame for light particle - G4ThreeVector momentum_kine3_beam(sin(Theta3) * cos(phi), - sin(Theta3) * sin(phi), cos(Theta3)); + G4ThreeVector momentum_kine3_beam(sin(Theta3) * cos(phi), sin(Theta3) * sin(phi), cos(Theta3)); // Momentum in World frame //to go from the incident beam frame to the "world" // frame G4ThreeVector momentum_kine3_world = momentum_kine3_beam; momentum_kine3_world.rotate(Beam_theta, - V); // rotation of Beam_theta on Y axis + V); // rotation of Beam_theta on Y axis momentum_kine3_world.rotate(Beam_phi, ZZ); // rotation of Beam_phi on Z axis // Momentum in beam frame for heavy particle - G4ThreeVector momentum_kine4_beam(sin(Theta4) * cos(phi + pi), - sin(Theta4) * sin(phi + pi), cos(Theta4)); + G4ThreeVector momentum_kine4_beam(sin(Theta4) * cos(phi + pi), sin(Theta4) * sin(phi + pi), cos(Theta4)); // Momentum in World frame G4ThreeVector momentum_kine4_world = momentum_kine4_beam; momentum_kine4_world.rotate(Beam_theta, - V); // rotation of Beam_theta on Y axis + V); // rotation of Beam_theta on Y axis momentum_kine4_world.rotate(Beam_phi, ZZ); // rotation of Beam_phi on Z axis // Emitt secondary @@ -442,22 +414,20 @@ void NPS::BeamReaction::DoIt(const G4FastTrack& fastTrack, m_ReactionConditions->SetMomentumDirectionZ(momentum_kine3_world.z()); m_ReactionConditions->SetMomentumDirectionZ(momentum_kine4_world.z()); - }// end if TwoBodyReaction - + } // end if TwoBodyReaction // QFS - else if (m_ReactionType==QFS ) { + else if (m_ReactionType == QFS) { //////Define the kind of particle to shoot//////// - // A --> T ==> B + (c -> T) => B + 1 + 2 + // A --> T ==> B + (c -> T) => B + 1 + 2 int Light1_Z = m_QFS.GetParticle1()->GetZ(); int Light1_A = m_QFS.GetParticle1()->GetA(); int Light2_Z = m_QFS.GetParticle2()->GetZ(); int Light2_A = m_QFS.GetParticle2()->GetA(); - static G4IonTable* IonTable - = G4ParticleTable::GetParticleTable()->GetIonTable(); + static G4IonTable* IonTable = G4ParticleTable::GetParticleTable()->GetIonTable(); G4ParticleDefinition* Light1Name; G4ParticleDefinition* Light2Name; @@ -465,14 +435,16 @@ void NPS::BeamReaction::DoIt(const G4FastTrack& fastTrack, if (Light1_Z == 0 && Light1_A == 1) // neutron is special case { Light1Name = G4Neutron::Definition(); - } else { + } + else { Light1Name = IonTable->GetIon(Light1_Z, Light1_A); } if (Light2_Z == 0 && Light2_A == 1) // neutron is special case { Light2Name = G4Neutron::Definition(); - } else { + } + else { Light2Name = IonTable->GetIon(Light2_Z, Light2_A); } @@ -482,28 +454,26 @@ void NPS::BeamReaction::DoIt(const G4FastTrack& fastTrack, G4ParticleDefinition* HeavyName; if (m_QFS.GetUseExInGeant4()) - HeavyName - = IonTable->GetIon(Heavy_Z, Heavy_A, m_QFS.GetExcitationB() * MeV); + HeavyName = IonTable->GetIon(Heavy_Z, Heavy_A, m_QFS.GetExcitationB() * MeV); else HeavyName = IonTable->GetIon(Heavy_Z, Heavy_A); // Set the Energy of the reaction m_QFS.SetBeamEnergy(reac_energy); - // Shoot and Set a Random ThetaCM double costheta = G4RandFlat::shoot() * 2 - 1; double theta = acos(costheta); - double phi = G4RandFlat::shoot() * 2. * pi - pi; //rand in [-pi,pi] + double phi = G4RandFlat::shoot() * 2. * pi - pi; // rand in [-pi,pi] m_QFS.SetThetaCM(theta); m_QFS.SetPhiCM(phi); // Lab frame variables where to store results double Theta1, Phi1, TKE1, Theta2, Phi2, TKE2, ThetaB, PhiB, TKEB; - int j=0; + int j = 0; m_QFS.SetIsAllowed(false); - while(!m_QFS.IsAllowed()){ + while (!m_QFS.IsAllowed()) { // Shoot internal momentum for the removed cluster // if a momentum Sigma is given then shoot in 3 indep. Gaussians // if input files are given for distributions use them instead @@ -513,57 +483,56 @@ void NPS::BeamReaction::DoIt(const G4FastTrack& fastTrack, m_QFS.KineRelativistic(Theta1, Phi1, TKE1, Theta2, Phi2, TKE2); j++; - if(j>100) cout<< "ERROR: too many iteration and QFS kinematical conditions not allowed"<<endl; + if (j > 100) + cout << "ERROR: too many iteration and QFS kinematical conditions not allowed" << endl; } //--------------------------------------------------------- - //Rotations to switch from frame with beam along Z to world + // Rotations to switch from frame with beam along Z to world //--------------------------------------------------------- double Beam_theta = pdirection.theta(); - double Beam_phi = pdirection.phi(); + double Beam_phi = pdirection.phi(); G4ThreeVector ux(1, 0, 0); G4ThreeVector uy(0, 1, 0); G4ThreeVector uz(0, 0, 1); // Momentum in beam and world frame for light particle 1 - G4ThreeVector momentum_kine1_beam(sin(Theta1) * cos(Phi1), - sin(Theta1) * sin(Phi1), cos(Theta1)); + G4ThreeVector momentum_kine1_beam(sin(Theta1) * cos(Phi1), sin(Theta1) * sin(Phi1), cos(Theta1)); G4ThreeVector momentum_kine1_world = momentum_kine1_beam; momentum_kine1_world.rotate(Beam_theta, uy); // rotation of Beam_theta around Y axis - momentum_kine1_world.rotate(Beam_phi, uz); // rotation of Beam_phi around Z axis + momentum_kine1_world.rotate(Beam_phi, uz); // rotation of Beam_phi around Z axis // Momentum in beam and world frame for light particle 2 - G4ThreeVector momentum_kine2_beam(sin(Theta2) * cos(Phi2), - sin(Theta2) * sin(Phi2), cos(Theta2)); + G4ThreeVector momentum_kine2_beam(sin(Theta2) * cos(Phi2), sin(Theta2) * sin(Phi2), cos(Theta2)); G4ThreeVector momentum_kine2_world = momentum_kine2_beam; momentum_kine2_world.rotate(Beam_theta, uy); // rotation of Beam_theta on Y axis - momentum_kine2_world.rotate(Beam_phi, uz); // rotation of Beam_phi on Z axis + momentum_kine2_world.rotate(Beam_phi, uz); // rotation of Beam_phi on Z axis // Momentum in beam and world frame for heavy residual // - //G4ThreeVector momentum_kineB_beam(sin(ThetaB) * cos(PhiB + pi), + // G4ThreeVector momentum_kineB_beam(sin(ThetaB) * cos(PhiB + pi), // sin(ThetaB) * sin(PhiB + pi), cos(ThetaB)); - //G4ThreeVector momentum_kineB_world = momentum_kineB_beam; - //momentum_kineB_world.rotate(Beam_theta, uy); // rotation of Beam_theta on Y axis - //momentum_kineB_world.rotate(Beam_phi, uz); // rotation of Beam_phi on Z axis + // G4ThreeVector momentum_kineB_world = momentum_kineB_beam; + // momentum_kineB_world.rotate(Beam_theta, uy); // rotation of Beam_theta on Y axis + // momentum_kineB_world.rotate(Beam_phi, uz); // rotation of Beam_phi on Z axis TLorentzVector* P_A = m_QFS.GetEnergyImpulsionLab_A(); TLorentzVector* P_B = m_QFS.GetEnergyImpulsionLab_B(); - G4ThreeVector momentum_kineB_beam( P_B->Px(), P_B->Py(), P_B->Pz() ); + G4ThreeVector momentum_kineB_beam(P_B->Px(), P_B->Py(), P_B->Pz()); momentum_kineB_beam = momentum_kineB_beam.unit(); TKEB = P_B->Energy() - m_QFS.GetParticleB()->Mass(); - G4ThreeVector momentum_kineB_world = momentum_kineB_beam; + G4ThreeVector momentum_kineB_world = momentum_kineB_beam; momentum_kineB_world.rotate(Beam_theta, uy); // rotation of Beam_theta on Y axis - momentum_kineB_world.rotate(Beam_phi, uz); // rotation of Beam_phi on Z axis + momentum_kineB_world.rotate(Beam_phi, uz); // rotation of Beam_phi on Z axis ThetaB = P_B->Angle(P_A->Vect()); - //if (ThetaB < 0) ThetaB += M_PI; - //PhiB = M_PI + P_B->Vect().Phi(); - PhiB = P_B->Vect().Phi(); - if (fabs(PhiB) < 1e-6) PhiB = 0; - + // if (ThetaB < 0) ThetaB += M_PI; + // PhiB = M_PI + P_B->Vect().Phi(); + PhiB = P_B->Vect().Phi(); + if (fabs(PhiB) < 1e-6) + PhiB = 0; // Emitt secondary if (m_QFS.GetShoot1()) { @@ -576,12 +545,12 @@ void NPS::BeamReaction::DoIt(const G4FastTrack& fastTrack, fastStep.CreateSecondaryTrack(particle2, localPosition, time); } if (m_QFS.GetShootB()) { - if(m_QFS.GetDeexcitation()){ - double P_B2 = P_B->Px()*P_B->Px() + P_B->Py()*P_B->Py() + P_B->Pz()*P_B->Pz(); - double scaling = 1; - if(P_B2>0.0){ - double P_Bnew2 = TKEB*TKEB + 2 * TKEB * m_QFS.GetParticleB()->Mass(); - scaling = sqrt(P_Bnew2)/sqrt(P_B2); + if (m_QFS.GetDeexcitation()) { + double P_B2 = P_B->Px() * P_B->Px() + P_B->Py() * P_B->Py() + P_B->Pz() * P_B->Pz(); + // double scaling = 1; + if (P_B2 > 0.0) { + double P_Bnew2 = TKEB * TKEB + 2 * TKEB * m_QFS.GetParticleB()->Mass(); + // scaling = sqrt(P_Bnew2)/sqrt(P_B2); } G4LorentzVector G4HeavyMomentum; G4HeavyMomentum.setE(P_B->Energy()); @@ -592,20 +561,20 @@ void NPS::BeamReaction::DoIt(const G4FastTrack& fastTrack, G4ReactionProductVector* HeavyDeexcitation = ABLA->DeExcite(HeavyFragment); unsigned int sizeFrag = HeavyDeexcitation->size(); - G4ThreeVector Momsum(0,0,0); - for(unsigned int i = 0 ; i < sizeFrag ; i++){ + G4ThreeVector Momsum(0, 0, 0); + for (unsigned int i = 0; i < sizeFrag; i++) { const G4ParticleDefinition* HeavyFragName = HeavyDeexcitation->at(i)->GetDefinition(); G4ThreeVector HeavyFragMomentum = HeavyDeexcitation->at(i)->GetMomentum(); double TKEFrag = HeavyDeexcitation->at(i)->GetKineticEnergy(); - double HeavyFragModule = sqrt(TKEFrag*TKEFrag + 2*TKEFrag*HeavyDeexcitation->at(i)->GetMass()); - G4ThreeVector HeavyFragMomentumDirection(HeavyFragMomentum.x()/HeavyFragModule, - HeavyFragMomentum.y()/HeavyFragModule, - HeavyFragMomentum.z()/HeavyFragModule); + double HeavyFragModule = sqrt(TKEFrag * TKEFrag + 2 * TKEFrag * HeavyDeexcitation->at(i)->GetMass()); + G4ThreeVector HeavyFragMomentumDirection(HeavyFragMomentum.x() / HeavyFragModule, + HeavyFragMomentum.y() / HeavyFragModule, + HeavyFragMomentum.z() / HeavyFragModule); G4DynamicParticle particleFrag(HeavyFragName, HeavyFragMomentumDirection, TKEFrag); fastStep.CreateSecondaryTrack(particleFrag, localPosition, time); } } - else{ + else { G4DynamicParticle particleB(HeavyName, momentum_kineB_world, TKEB); fastStep.CreateSecondaryTrack(particleB, localPosition, time); } @@ -614,21 +583,16 @@ void NPS::BeamReaction::DoIt(const G4FastTrack& fastTrack, /////////////////////////////////// ///// Reaction Condition Save ///// /////////////////////////////////// - m_ReactionConditions->SetBeamParticleName( - PrimaryTrack->GetParticleDefinition()->GetParticleName()); + m_ReactionConditions->SetBeamParticleName(PrimaryTrack->GetParticleDefinition()->GetParticleName()); m_ReactionConditions->SetBeamReactionEnergy(reac_energy); m_ReactionConditions->SetVertexPositionX(localPosition.x()); m_ReactionConditions->SetVertexPositionY(localPosition.y()); m_ReactionConditions->SetVertexPositionZ(localPosition.z()); - m_ReactionConditions->SetBeamEmittanceTheta( - PrimaryTrack->GetMomentumDirection().theta() / deg); - m_ReactionConditions->SetBeamEmittancePhi( - PrimaryTrack->GetMomentumDirection().phi() / deg); - m_ReactionConditions->SetBeamEmittanceThetaX( - PrimaryTrack->GetMomentumDirection().perpPart(uy).angle(uz) / deg); - m_ReactionConditions->SetBeamEmittancePhiY( - PrimaryTrack->GetMomentumDirection().perpPart(ux).angle(uz) / deg); + m_ReactionConditions->SetBeamEmittanceTheta(PrimaryTrack->GetMomentumDirection().theta() / deg); + m_ReactionConditions->SetBeamEmittancePhi(PrimaryTrack->GetMomentumDirection().phi() / deg); + m_ReactionConditions->SetBeamEmittanceThetaX(PrimaryTrack->GetMomentumDirection().perpPart(uy).angle(uz) / deg); + m_ReactionConditions->SetBeamEmittancePhiY(PrimaryTrack->GetMomentumDirection().perpPart(ux).angle(uz) / deg); // Names 1,2 and B// m_ReactionConditions->SetParticleName(Light1Name->GetParticleName()); @@ -648,7 +612,7 @@ void NPS::BeamReaction::DoIt(const G4FastTrack& fastTrack, // ThetaCM, Ex and Internal Momentum of removed cluster// m_ReactionConditions->SetThetaCM(m_QFS.GetThetaCM() / deg); m_ReactionConditions->SetInternalMomentum(m_QFS.GetInternalMomentum()); - //Excitation energy of reaction product B + // Excitation energy of reaction product B m_ReactionConditions->SetExcitationEnergy4(m_QFS.GetExcitationB()); // Momentum Dir. X 1,2 and B in world frame // m_ReactionConditions->SetMomentumDirectionX(momentum_kine1_world.x()); @@ -663,43 +627,41 @@ void NPS::BeamReaction::DoIt(const G4FastTrack& fastTrack, m_ReactionConditions->SetMomentumDirectionZ(momentum_kine2_world.z()); m_ReactionConditions->SetMomentumDirectionZ(momentum_kineB_world.z()); - }// end QFS + } // end QFS ////////////////////////// // Phase space Case // ////////////////////////// - else if(m_ReactionType==PhaseSpace){ + else if (m_ReactionType == PhaseSpace) { // Prepare beam LV - static int d_Z,d_A; + static int d_Z, d_A; static double d_Ex; - if(m_PhaseSpace.SetBeamLV(pdirection.x(),pdirection.y(),pdirection.z(),energy)){ - m_event_weight= m_PhaseSpace.Generate(); + if (m_PhaseSpace.SetBeamLV(pdirection.x(), pdirection.y(), pdirection.z(), energy)) { + m_event_weight = m_PhaseSpace.Generate(); unsigned int size = m_PhaseSpace.GetDecaySize(); - for(unsigned int i = 0; i < size ; i++){ + for (unsigned int i = 0; i < size; i++) { d_Z = m_PhaseSpace.GetParticle(i)->GetZ(); d_A = m_PhaseSpace.GetParticle(i)->GetA(); - d_Ex =m_PhaseSpace.GetExcitation(i); + d_Ex = m_PhaseSpace.GetExcitation(i); - static G4IonTable* IonTable - = G4ParticleTable::GetParticleTable()->GetIonTable(); + static G4IonTable* IonTable = G4ParticleTable::GetParticleTable()->GetIonTable(); G4ParticleDefinition* dName; if (d_Z == 0 && d_A == 1) // neutron is special case dName = G4Neutron::Definition(); - else - dName = IonTable->GetIon(d_Z, d_A,d_Ex); + else + dName = IonTable->GetIon(d_Z, d_A, d_Ex); auto dLV = m_PhaseSpace.GetDecayLV(i); - G4ThreeVector dir(dLV->Px(),dLV->Py(),dLV->Pz()); - dir=dir.unit(); + G4ThreeVector dir(dLV->Px(), dLV->Py(), dLV->Pz()); + dir = dir.unit(); m_PhaseSpace.GetParticle(i)->SetBeta(dLV->Beta()); - // Emmit daughter - G4DynamicParticle particle(dName, dir,m_PhaseSpace.GetParticle(i)->GetEnergy()); + // Emmit daughter + G4DynamicParticle particle(dName, dir, m_PhaseSpace.GetParticle(i)->GetEnergy()); fastStep.CreateSecondaryTrack(particle, localPosition, time); - } } } @@ -707,64 +669,59 @@ void NPS::BeamReaction::DoIt(const G4FastTrack& fastTrack, //////////////////// // Fusion Case // //////////////////// - else if(m_ReactionType==Fusion){ - static G4IonTable* IonTable - = G4ParticleTable::GetParticleTable()->GetIonTable(); + else if (m_ReactionType == Fusion) { + static G4IonTable* IonTable = G4ParticleTable::GetParticleTable()->GetIonTable(); //////Define the kind of particle to shoot//////// G4ParticleDefinition* Product; - NPL::Particle N(m_FusionProduct); + NPL::Particle N(m_FusionProduct); N.SetExcitationEnergy(m_FusionExcitation); - NPL::Particle T(m_TargetNuclei); + NPL::Particle T(m_TargetNuclei); int PZ = N.GetZ(); int PA = N.GetA(); - Product = IonTable->GetIon(PZ, PA, m_FusionExcitation*MeV); + Product = IonTable->GetIon(PZ, PA, m_FusionExcitation * MeV); // setup the daugter ///////////////////////////////////////////////////////////////////////// - TVector3 BeamP = NPS::ConvertVector(PrimaryTrack->GetMomentum()); + TVector3 BeamP = NPS::ConvertVector(PrimaryTrack->GetMomentum()); TLorentzVector BeamLV; - BeamLV.SetVectM(BeamP,N.Mass()*MeV); + BeamLV.SetVectM(BeamP, N.Mass() * MeV); TLorentzVector TargetLV; - TargetLV.SetVectM(TVector3(0,0,0),T.Mass()*MeV); - TLorentzVector TotalLV=BeamLV+TargetLV; + TargetLV.SetVectM(TVector3(0, 0, 0), T.Mass() * MeV); + TLorentzVector TotalLV = BeamLV + TargetLV; - // energy lost in the fusion process to be removed to the total energy + // energy lost in the fusion process to be removed to the total energy // Total Available Ek = Initial Ek + (InitialMass-FinalMass) - double KineAvailable= TotalLV.Et()+ (TotalLV.Mag()-N.Mass()); + double KineAvailable = TotalLV.Et() + (TotalLV.Mag() - N.Mass()); G4ThreeVector momentum_dir = NPS::ConvertVector(TotalLV.Vect().Unit()); //////FIXME Unsure of this part // Randomize Phi after the reaction - double Phi = CLHEP::RandFlat::shoot()*2*M_PI ; - momentum_dir.rotate(Phi,PrimaryTrack->GetMomentum()); + double Phi = CLHEP::RandFlat::shoot() * 2 * M_PI; + momentum_dir.rotate(Phi, PrimaryTrack->GetMomentum()); G4DynamicParticle particle(Product, momentum_dir, KineAvailable); fastStep.CreateSecondaryTrack(particle, localPosition, time); - }// end fusion - + } // end fusion } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... // Return the slow down beam in given thickness of material -double NPS::BeamReaction::SlowDownBeam(const G4ParticleDefinition* Beam, - double IncidentEnergy, - double Thickness, - G4Material* Material){ +double NPS::BeamReaction::SlowDownBeam(const G4ParticleDefinition* Beam, double IncidentEnergy, double Thickness, + G4Material* Material) { - - if(Beam->GetParticleName()=="neutron"){ + if (Beam->GetParticleName() == "neutron") { return IncidentEnergy; } - double dedx,de; + double dedx, de; int NbSlice = 100; static G4EmCalculator emCalculator; - if(Thickness!=0){ - for (G4int i = 0; i < NbSlice; i++){ + if (Thickness != 0) { + for (G4int i = 0; i < NbSlice; i++) { dedx = emCalculator.ComputeTotalDEDX(IncidentEnergy, Beam, Material); - de = dedx * Thickness / NbSlice; + de = dedx * Thickness / NbSlice; IncidentEnergy -= de; - if(IncidentEnergy<0){ + if (IncidentEnergy < 0) { IncidentEnergy = 0; break; } @@ -772,6 +729,5 @@ double NPS::BeamReaction::SlowDownBeam(const G4ParticleDefinition* Beam, } return IncidentEnergy; - } diff --git a/NPSimulation/Process/CMakeLists.txt b/NPSimulation/Process/CMakeLists.txt index a60305f9a1777f2c12a007f938de0e203149b97f..e1a126cd05d664e8738110b80d1f051c9a27d47f 100644 --- a/NPSimulation/Process/CMakeLists.txt +++ b/NPSimulation/Process/CMakeLists.txt @@ -1,16 +1,21 @@ +if(Geant4_VERSION_MAJOR GREATER 10) + message("Compiling without IonIonElastic") + add_library(NPSProcess OBJECT FissionDecay.cc Decay.cc BeamReaction.cc FastDriftElectron.cc PhysicsList.cc G4DriftElectron.cc G4IonizationWithDE.cc G4DriftElectronPhysics.cc G4DEAbsorption.cc G4DEAmplification.cc G4DETransport.cc menate_R.cc ) + add_definitions(-DGEANT4_11) +else() + if(Geant4_VERSION_MAJOR GREATER 9) + if(Geant4_VERSION_MINOR GREATER 4) + message("Compiling with NeutronHPphysics") + add_library(NPSProcess OBJECT FissionDecay.cc Decay.cc BeamReaction.cc FastDriftElectron.cc NPIonIonInelasticPhysic.cc PhysicsList.cc G4DriftElectron.cc G4IonizationWithDE.cc G4DriftElectronPhysics.cc G4DEAbsorption.cc G4DEAmplification.cc G4DETransport.cc menate_R.cc NeutronHPphysics.cc NeutronHPMessenger.cc) + add_definitions(-DUSE_NEUTRONHP) + else () + + message("Compiling WITHOUT NeutronHPphysics, install geant4 10.5 or greater for this physics list") + add_library(NPSProcess OBJECT FissionDecay.cc Decay.cc BeamReaction.cc FastDriftElectron.cc NPIonIonInelasticPhysic.cc PhysicsList.cc G4DriftElectron.cc G4IonizationWithDE.cc G4DriftElectronPhysics.cc G4DEAbsorption.cc G4DEAmplification.cc G4DETransport.cc menate_R.cc) + endif() + endif() +endif() -if(Geant4_VERSION_MAJOR GREATER 9) - if(Geant4_VERSION_MINOR GREATER 4) - - message("Compiling with NeutronHPphysics") - add_library(NPSProcess OBJECT FissionDecay.cc Decay.cc BeamReaction.cc FastDriftElectron.cc NPIonIonInelasticPhysic.cc PhysicsList.cc G4DriftElectron.cc G4IonizationWithDE.cc G4DriftElectronPhysics.cc G4DEAbsorption.cc G4DEAmplification.cc G4DETransport.cc menate_R.cc NeutronHPphysics.cc NeutronHPMessenger.cc) - add_definitions(-DUSE_NEUTRONHP) - else () - - message("Compiling WITHOUT NeutronHPphysics, install geant4 10.5 or greater for this physics list") - add_library(NPSProcess OBJECT FissionDecay.cc Decay.cc BeamReaction.cc FastDriftElectron.cc NPIonIonInelasticPhysic.cc PhysicsList.cc G4DriftElectron.cc G4IonizationWithDE.cc G4DriftElectronPhysics.cc G4DEAbsorption.cc G4DEAmplification.cc G4DETransport.cc menate_R.cc) - endif() - endif() # target_link_libraries(NPSProcess ${ROOT_LIBRARIES} ${Geant4_LIBRARIES} NPSCore ${NPLib_LIBRARIES} NPInitialConditions NPInteractionCoordinates NPReactionConditions NPFissionConditions NPSamurai) diff --git a/NPSimulation/Process/NPIonIonInelasticPhysic.cc b/NPSimulation/Process/NPIonIonInelasticPhysic.cc index 31f96dfce4f6fcee5195e0efe6daa194d85969d3..bfea0a0b8489bdc35edf5ca40ff28c3904a6f2a4 100755 --- a/NPSimulation/Process/NPIonIonInelasticPhysic.cc +++ b/NPSimulation/Process/NPIonIonInelasticPhysic.cc @@ -31,247 +31,238 @@ // and The Wilson. // For hadrotherapy pouposes, where distributions of produced fragments is importante we strongly -// suggest to use Binary or QMD. The Binary model is the default and at moment, you can swith beetween models decommenting -// the line of code and recompiling +// suggest to use Binary or QMD. The Binary model is the default and at moment, you can swith beetween models +// decommenting the line of code and recompiling #include "NPIonIonInelasticPhysic.hh" -#include "G4SystemOfUnits.hh" #include "G4ParticleDefinition.hh" #include "G4ProcessManager.hh" +#include "G4SystemOfUnits.hh" // Total cross section for inelastic processes -#include "G4GeneralSpaceNNCrossSection.hh" -#include "G4TripathiCrossSection.hh" -#include "G4TripathiLightCrossSection.hh" -#include "G4IonsShenCrossSection.hh" #include "G4BGGNucleonElasticXS.hh" #include "G4ComponentGGHadronNucleusXsc.hh" #include "G4CrossSectionInelastic.hh" - +#include "G4GeneralSpaceNNCrossSection.hh" +#include "G4IonsShenCrossSection.hh" +#include "G4TripathiCrossSection.hh" +#include "G4TripathiLightCrossSection.hh" // Elastic -#include "G4HadronElasticProcess.hh" -#include "G4ElasticHadrNucleusHE.hh" #include "G4DiffuseElastic.hh" +#include "G4ElasticHadrNucleusHE.hh" #include "G4HadronElastic.hh" +#include "G4HadronElasticProcess.hh" // Inelastic -#include "G4ProtonInelasticProcess.hh" -#include "G4DeuteronInelasticProcess.hh" -#include "G4TritonInelasticProcess.hh" -#include "G4He3InelasticProcess.hh" #include "G4AlphaInelasticProcess.hh" #include "G4BinaryLightIonReaction.hh" -#include "G4QMDReaction.hh" +#include "G4DeuteronInelasticProcess.hh" +#include "G4He3InelasticProcess.hh" #include "G4IonInelasticProcess.hh" -#include "G4GeneralSpaceNNCrossSection.hh" +#include "G4ProtonInelasticProcess.hh" +#include "G4QMDReaction.hh" +#include "G4TritonInelasticProcess.hh" using namespace std; ///////////////////////////////////////////////////////////////////////////// -NPIonIonInelasticPhysic::NPIonIonInelasticPhysic(const G4String& name): -G4VPhysicsConstructor(name) -{ - G4cout << G4endl - << "A local inelastic model is activated for all ions" - << G4endl; +NPIonIonInelasticPhysic::NPIonIonInelasticPhysic(const G4String& name) : G4VPhysicsConstructor(name) { + G4cout << G4endl << "A local inelastic model is activated for all ions" << G4endl; } ///////////////////////////////////////////////////////////////////////////// -NPIonIonInelasticPhysic::~NPIonIonInelasticPhysic() -{} +NPIonIonInelasticPhysic::~NPIonIonInelasticPhysic() {} ///////////////////////////////////////////////////////////////////////////// -void NPIonIonInelasticPhysic::ConstructProcess() -{ - G4ParticleDefinition* particle = 0; - G4ProcessManager* processManager = 0; - - // **************************************************************** - // *** Ion-Ion models definition *** - // **************************************************************** - G4QMDReaction* JQMDmodel = new G4QMDReaction(); - JQMDmodel -> SetMinEnergy(0*MeV); - JQMDmodel -> SetMaxEnergy(10*GeV); - - G4BinaryLightIonReaction* ligthBinary = new G4BinaryLightIonReaction(); - ligthBinary -> SetMinEnergy(0*MeV); - ligthBinary -> SetMaxEnergy(10*GeV); - - //G4GeneralSpaceNNCrossSection* GeneralSpaceNNCrossSection = new G4GeneralSpaceNNCrossSection; - - // Tripathi - //G4TripathiCrossSection* TripathiCrossSections = new G4TripathiCrossSection; - G4TripathiLightCrossSection* TripathiLightCrossSections = new G4TripathiLightCrossSection; - - //Shen - G4IonsShenCrossSection* ShenCrossSections = new G4IonsShenCrossSection; - - // Glauber - G4ComponentGGHadronNucleusXsc* GlauberGribovCrossSection = new G4ComponentGGHadronNucleusXsc(); - G4CrossSectionInelastic* GlauberGribovDataSet = new G4CrossSectionInelastic(GlauberGribovCrossSection); - - // ****************** - // **** Elastic **** - // ****************** - /*particle = G4Proton::Proton(); - //G4ElasticHadrNucleusHE* hadronElasticModel = new G4ElasticHadrNucleusHE(); - //G4HadronElastic* hadronElasticModel1 = new G4HadronElastic(); - G4DiffuseElastic* hadronElasticModel2 = new G4DiffuseElastic(); - hadronElasticModel2->SetPlabLowLimit(0.1*MeV);//Default is 20 MeV - hadronElasticModel2->SetRecoilKinEnergyLimit(10*keV);//Default is 100 keV - hadronElasticModel2->SetLowestEnergyLimit(0.0*keV);//Default value is 0 keV - hadronElasticModel2->SetHEModelLowLimit(0.0*keV);//Default value is 0 keV - hadronElasticModel2->SetQModelLowLimit(0.0*keV);//Default value is 0 keV - - G4HadronElasticProcess* hadronElasticProcess = new G4HadronElasticProcess(); - - hadronElasticProcess->AddDataSet(GlauberGribovDataSet); - //hadronElasticProcess->AddDataSet( new G4BGGNucleonElasticXS(particle)); - - //hadronElasticProcess->RegisterMe(hadronElasticModel1); - hadronElasticProcess->RegisterMe(hadronElasticModel2); - - - processManager = particle -> GetProcessManager(); - processManager -> AddDiscreteProcess(hadronElasticProcess);*/ - - // **************** - // **** Proton **** - // **************** - G4ProtonInelasticProcess* protonInelasticProcess = new G4ProtonInelasticProcess; - - //protonInelasticProcess -> AddDataSet(ShenCrossSections); - //protonInelasticProcess -> AddDataSet(TripathiCrossSections); - //protonInelasticProcess -> AddDataSet(TripathiLightCrossSections); - protonInelasticProcess -> AddDataSet(GlauberGribovDataSet); - - protonInelasticProcess -> RegisterMe(ligthBinary); - //protonInelasticProcess -> RegisterMe(JQMDmodel); - - particle = G4Proton::Proton(); - processManager = particle -> GetProcessManager(); - processManager -> AddDiscreteProcess(protonInelasticProcess); - - //////////////////////////// - // Printing Cross-Section // - //////////////////////////// - /*double energy = 0; - int Z = 55; - int A = 133; - particle = G4Proton::Proton(); - for(int i=0; i<1000;i++){ - energy += 1; - - G4DynamicParticle* dp = new G4DynamicParticle(particle,G4ThreeVector(0,0,1),energy*MeV); - //G4Element* element = new G4Element("Sn","Sn",1); - //G4Isotope *isotope = new G4Isotope("Sn",50,70,120*g/mole); - //element->AddIsotope(isotope,1); - // Glauber-Gribov - //cout << energy << " " << GlauberGribovCrossSection->GetInelasticIsotopeCrossSection(particle,energy*MeV,Z,A)/barn << endl; - //cout << energy << " " << GlauberGribovCrossSection->GetInelasticGlauberGribov(dp,Z,A)/barn << endl; - //cout << energy << " " << GlauberGribovCrossSection->GetTotalIsotopeCrossSection(particle,energy*MeV,Z,A)/barn << endl; - //cout << energy << " " << GlauberGribovCrossSection->GetHadronNucleonXsc(dp,A,Z)/barn << endl; - //cout << energy << " " << GlauberGribovCrossSection-> GetTotalGlauberGribovXsc()/barn << endl; - - - // Tripathi - cout << energy << " " << TripathiLightCrossSections->GetElementCrossSection(dp,Z,0)/barn << endl; - //cout << energy << " " << TripathiCrossSections->GetElementCrossSection(dp,Z,0)/barn << endl; - - // Shen - //cout << energy << " " << ShenCrossSections->GetElementCrossSection(dp,Z,0)/barn << endl; - - }*/ - - // **************** - // *** Deuteron *** - // **************** - G4DeuteronInelasticProcess* deuteronInelasticProcess = new G4DeuteronInelasticProcess; - - deuteronInelasticProcess -> AddDataSet(ShenCrossSections); - //deuteronInelasticProcess -> AddDataSet(TripathiCrossSections); - //deuteronInelasticProcess -> AddDataSet(TripathiLightCrossSections); - //deuteronInelasticProcess -> AddDataSet(GlauberGribovDataSet); - - deuteronInelasticProcess -> RegisterMe(ligthBinary); - //deuteronInelasticProcess -> RegisterMe(JQMDmodel); - //deuteronInelasticProcess -> RegisterMe(WilsonModel); - - particle = G4Deuteron::Deuteron(); - processManager = particle -> GetProcessManager(); - processManager -> AddDiscreteProcess(deuteronInelasticProcess); - - // ************** - // *** Triton *** - // ************** - G4TritonInelasticProcess* tritonInelasticProcess = new G4TritonInelasticProcess; - - tritonInelasticProcess -> AddDataSet(ShenCrossSections); - //tritonInelasticProcess -> AddDataSet(TripathiCrossSections); - //tritonInelasticProcess -> AddDataSet(TripathiLightCrossSections); - //tritonInelasticProcess -> AddDataSet(GlauberGribovDataSet); - - tritonInelasticProcess -> RegisterMe(ligthBinary); - //tritonInelasticProcess -> RegisterMe(JQMDmodel); - //tritonInelasticProcess -> RegisterMe(WilsonModel); - - particle = G4Triton::Triton(); - processManager = particle -> GetProcessManager(); - processManager -> AddDiscreteProcess(tritonInelasticProcess); - - // *********** - // *** 3He *** - // *********** - G4He3InelasticProcess* He3InelasticProcess = new G4He3InelasticProcess; - - //He3InelasticProcess -> AddDataSet(ShenCrossSections); - //He3InelasticProcess -> AddDataSet(TripathiCrossSections); - He3InelasticProcess -> AddDataSet(TripathiLightCrossSections); - //He3InelasticProcess -> AddDataSet(GlauberGribovDataSet); - - He3InelasticProcess -> RegisterMe(ligthBinary); - //G4He3InelasticProcess -> RegisterMe(JQMDmodel); - - particle = G4He3::He3(); - processManager = particle -> GetProcessManager(); - processManager -> AddDiscreteProcess(He3InelasticProcess); - - - // ************* - // *** Alpha *** - // ************* - G4AlphaInelasticProcess* alphaInelasticProcess = new G4AlphaInelasticProcess; - - //alphaInelasticProcess -> AddDataSet(ShenCrossSections); - //alphaInelasticProcess -> AddDataSet(TripathiCrossSections); - alphaInelasticProcess -> AddDataSet(TripathiLightCrossSections); - //alphaInelasticProcess -> AddDataSet(GlauberGribovDataSet); - - alphaInelasticProcess -> RegisterMe(ligthBinary); - //alphaInelasticProcess -> RegisterMe(JQMDmodel); - //alphaIonInelasticProcess -> RegisterMe(WilsonModel); - - particle = G4Alpha::Alpha(); - processManager = particle -> GetProcessManager(); - processManager -> AddDiscreteProcess(alphaInelasticProcess); - - // ******************* - // *** Generic Ion *** - // ******************* - G4IonInelasticProcess* genericIonInelasticProcess = new G4IonInelasticProcess(); - - //genericIonInelasticProcess -> AddDataSet(ShenCrossSections); - //genericIonInelasticProcess -> AddDataSet(TripathiCrossSections); - genericIonInelasticProcess -> AddDataSet(GlauberGribovDataSet); - - genericIonInelasticProcess -> RegisterMe(ligthBinary); - //genericIonInelasticProcess -> RegisterMe(JQMDmodel); - //genericIonInelasticProcess -> RegisterMe(WilsonModel); - - particle = G4GenericIon::GenericIon(); - processManager = particle -> GetProcessManager(); - processManager -> AddDiscreteProcess(genericIonInelasticProcess); -} +void NPIonIonInelasticPhysic::ConstructProcess() { + G4ParticleDefinition* particle = 0; + G4ProcessManager* processManager = 0; + + // **************************************************************** + // *** Ion-Ion models definition *** + // **************************************************************** + G4QMDReaction* JQMDmodel = new G4QMDReaction(); + JQMDmodel->SetMinEnergy(0 * MeV); + JQMDmodel->SetMaxEnergy(10 * GeV); + + G4BinaryLightIonReaction* ligthBinary = new G4BinaryLightIonReaction(); + ligthBinary->SetMinEnergy(0 * MeV); + ligthBinary->SetMaxEnergy(10 * GeV); + + // G4GeneralSpaceNNCrossSection* GeneralSpaceNNCrossSection = new G4GeneralSpaceNNCrossSection; + + // Tripathi + // G4TripathiCrossSection* TripathiCrossSections = new G4TripathiCrossSection; + G4TripathiLightCrossSection* TripathiLightCrossSections = new G4TripathiLightCrossSection; + + // Shen + G4IonsShenCrossSection* ShenCrossSections = new G4IonsShenCrossSection; + + // Glauber + G4ComponentGGHadronNucleusXsc* GlauberGribovCrossSection = new G4ComponentGGHadronNucleusXsc(); + G4CrossSectionInelastic* GlauberGribovDataSet = new G4CrossSectionInelastic(GlauberGribovCrossSection); + + // ****************** + // **** Elastic **** + // ****************** + /*particle = G4Proton::Proton(); + //G4ElasticHadrNucleusHE* hadronElasticModel = new G4ElasticHadrNucleusHE(); + //G4HadronElastic* hadronElasticModel1 = new G4HadronElastic(); + G4DiffuseElastic* hadronElasticModel2 = new G4DiffuseElastic(); + hadronElasticModel2->SetPlabLowLimit(0.1*MeV);//Default is 20 MeV + hadronElasticModel2->SetRecoilKinEnergyLimit(10*keV);//Default is 100 keV + hadronElasticModel2->SetLowestEnergyLimit(0.0*keV);//Default value is 0 keV + hadronElasticModel2->SetHEModelLowLimit(0.0*keV);//Default value is 0 keV + hadronElasticModel2->SetQModelLowLimit(0.0*keV);//Default value is 0 keV + G4HadronElasticProcess* hadronElasticProcess = new G4HadronElasticProcess(); + hadronElasticProcess->AddDataSet(GlauberGribovDataSet); + //hadronElasticProcess->AddDataSet( new G4BGGNucleonElasticXS(particle)); + + //hadronElasticProcess->RegisterMe(hadronElasticModel1); + hadronElasticProcess->RegisterMe(hadronElasticModel2); + + + processManager = particle -> GetProcessManager(); + processManager -> AddDiscreteProcess(hadronElasticProcess);*/ + + // **************** + // **** Proton **** + // **************** + G4ProtonInelasticProcess* protonInelasticProcess = new G4ProtonInelasticProcess; + + // protonInelasticProcess -> AddDataSet(ShenCrossSections); + // protonInelasticProcess -> AddDataSet(TripathiCrossSections); + // protonInelasticProcess -> AddDataSet(TripathiLightCrossSections); + protonInelasticProcess->AddDataSet(GlauberGribovDataSet); + + protonInelasticProcess->RegisterMe(ligthBinary); + // protonInelasticProcess -> RegisterMe(JQMDmodel); + + particle = G4Proton::Proton(); + processManager = particle->GetProcessManager(); + processManager->AddDiscreteProcess(protonInelasticProcess); + + //////////////////////////// + // Printing Cross-Section // + //////////////////////////// + /*double energy = 0; + int Z = 55; + int A = 133; + particle = G4Proton::Proton(); + for(int i=0; i<1000;i++){ + energy += 1; + + G4DynamicParticle* dp = new G4DynamicParticle(particle,G4ThreeVector(0,0,1),energy*MeV); + //G4Element* element = new G4Element("Sn","Sn",1); + //G4Isotope *isotope = new G4Isotope("Sn",50,70,120*g/mole); + //element->AddIsotope(isotope,1); + // Glauber-Gribov + //cout << energy << " " << + GlauberGribovCrossSection->GetInelasticIsotopeCrossSection(particle,energy*MeV,Z,A)/barn << endl; + //cout << energy << " " << GlauberGribovCrossSection->GetInelasticGlauberGribov(dp,Z,A)/barn << endl; + //cout << energy << " " << GlauberGribovCrossSection->GetTotalIsotopeCrossSection(particle,energy*MeV,Z,A)/barn << + endl; + //cout << energy << " " << GlauberGribovCrossSection->GetHadronNucleonXsc(dp,A,Z)/barn << endl; + //cout << energy << " " << GlauberGribovCrossSection-> GetTotalGlauberGribovXsc()/barn << endl; + + + // Tripathi + cout << energy << " " << TripathiLightCrossSections->GetElementCrossSection(dp,Z,0)/barn << endl; + //cout << energy << " " << TripathiCrossSections->GetElementCrossSection(dp,Z,0)/barn << endl; + + // Shen + //cout << energy << " " << ShenCrossSections->GetElementCrossSection(dp,Z,0)/barn << endl; + + }*/ + + // **************** + // *** Deuteron *** + // **************** + G4DeuteronInelasticProcess* deuteronInelasticProcess = new G4DeuteronInelasticProcess; + + deuteronInelasticProcess->AddDataSet(ShenCrossSections); + // deuteronInelasticProcess -> AddDataSet(TripathiCrossSections); + // deuteronInelasticProcess -> AddDataSet(TripathiLightCrossSections); + // deuteronInelasticProcess -> AddDataSet(GlauberGribovDataSet); + + deuteronInelasticProcess->RegisterMe(ligthBinary); + // deuteronInelasticProcess -> RegisterMe(JQMDmodel); + // deuteronInelasticProcess -> RegisterMe(WilsonModel); + + particle = G4Deuteron::Deuteron(); + processManager = particle->GetProcessManager(); + processManager->AddDiscreteProcess(deuteronInelasticProcess); + + // ************** + // *** Triton *** + // ************** + G4TritonInelasticProcess* tritonInelasticProcess = new G4TritonInelasticProcess; + + tritonInelasticProcess->AddDataSet(ShenCrossSections); + // tritonInelasticProcess -> AddDataSet(TripathiCrossSections); + // tritonInelasticProcess -> AddDataSet(TripathiLightCrossSections); + // tritonInelasticProcess -> AddDataSet(GlauberGribovDataSet); + + tritonInelasticProcess->RegisterMe(ligthBinary); + // tritonInelasticProcess -> RegisterMe(JQMDmodel); + // tritonInelasticProcess -> RegisterMe(WilsonModel); + + particle = G4Triton::Triton(); + processManager = particle->GetProcessManager(); + processManager->AddDiscreteProcess(tritonInelasticProcess); + + // *********** + // *** 3He *** + // *********** + G4He3InelasticProcess* He3InelasticProcess = new G4He3InelasticProcess; + + // He3InelasticProcess -> AddDataSet(ShenCrossSections); + // He3InelasticProcess -> AddDataSet(TripathiCrossSections); + He3InelasticProcess->AddDataSet(TripathiLightCrossSections); + // He3InelasticProcess -> AddDataSet(GlauberGribovDataSet); + + He3InelasticProcess->RegisterMe(ligthBinary); + // G4He3InelasticProcess -> RegisterMe(JQMDmodel); + + particle = G4He3::He3(); + processManager = particle->GetProcessManager(); + processManager->AddDiscreteProcess(He3InelasticProcess); + + // ************* + // *** Alpha *** + // ************* + G4AlphaInelasticProcess* alphaInelasticProcess = new G4AlphaInelasticProcess; + + // alphaInelasticProcess -> AddDataSet(ShenCrossSections); + // alphaInelasticProcess -> AddDataSet(TripathiCrossSections); + alphaInelasticProcess->AddDataSet(TripathiLightCrossSections); + // alphaInelasticProcess -> AddDataSet(GlauberGribovDataSet); + + alphaInelasticProcess->RegisterMe(ligthBinary); + // alphaInelasticProcess -> RegisterMe(JQMDmodel); + // alphaIonInelasticProcess -> RegisterMe(WilsonModel); + + particle = G4Alpha::Alpha(); + processManager = particle->GetProcessManager(); + processManager->AddDiscreteProcess(alphaInelasticProcess); + + // ******************* + // *** Generic Ion *** + // ******************* + G4IonInelasticProcess* genericIonInelasticProcess = new G4IonInelasticProcess(); + + // genericIonInelasticProcess -> AddDataSet(ShenCrossSections); + // genericIonInelasticProcess -> AddDataSet(TripathiCrossSections); + genericIonInelasticProcess->AddDataSet(GlauberGribovDataSet); + + genericIonInelasticProcess->RegisterMe(ligthBinary); + // genericIonInelasticProcess -> RegisterMe(JQMDmodel); + // genericIonInelasticProcess -> RegisterMe(WilsonModel); + + particle = G4GenericIon::GenericIon(); + processManager = particle->GetProcessManager(); + processManager->AddDiscreteProcess(genericIonInelasticProcess); +} diff --git a/NPSimulation/Process/NeutronHPphysics.cc b/NPSimulation/Process/NeutronHPphysics.cc index 91f61a45eaaa34f187540bcb647b25f6effb138e..20f553ac3db979bbb276552a270c2c1d35096f2a 100644 --- a/NPSimulation/Process/NeutronHPphysics.cc +++ b/NPSimulation/Process/NeutronHPphysics.cc @@ -41,52 +41,47 @@ // Processes #include "G4HadronElasticProcess.hh" -#include "G4ParticleHPElasticData.hh" -#include "G4ParticleHPThermalScatteringData.hh" #include "G4ParticleHPElastic.hh" +#include "G4ParticleHPElasticData.hh" #include "G4ParticleHPThermalScattering.hh" +#include "G4ParticleHPThermalScatteringData.hh" #include "G4NeutronInelasticProcess.hh" -#include "G4ParticleHPInelasticData.hh" #include "G4ParticleHPInelastic.hh" +#include "G4ParticleHPInelasticData.hh" #include "G4HadronCaptureProcess.hh" -#include "G4ParticleHPCaptureData.hh" #include "G4ParticleHPCapture.hh" +#include "G4ParticleHPCaptureData.hh" #include "G4HadronFissionProcess.hh" -#include "G4ParticleHPFissionData.hh" #include "G4ParticleHPFission.hh" +#include "G4ParticleHPFissionData.hh" #include "G4SystemOfUnits.hh" #include "G4DynamicParticle.hh" #include "G4Element.hh" -#include "G4Material.hh" -#include "G4Isotope.hh" #include "G4HadronicProcessStore.hh" +#include "G4Isotope.hh" +#include "G4Material.hh" #include "G4NistManager.hh" using namespace std; //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... NeutronHPphysics::NeutronHPphysics(const G4String& name) - : G4VPhysicsConstructor(name), fThermal(true), fNeutronMessenger(0) -{ + : G4VPhysicsConstructor(name), fThermal(true), fNeutronMessenger(0) { fNeutronMessenger = new NeutronHPMessenger(this); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -NeutronHPphysics::~NeutronHPphysics() -{ - delete fNeutronMessenger; -} +NeutronHPphysics::~NeutronHPphysics() { delete fNeutronMessenger; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void NeutronHPphysics::ConstructProcess() -{ +void NeutronHPphysics::ConstructProcess() { G4ParticleDefinition* neutron = G4Neutron::Neutron(); G4ProcessManager* pManager = neutron->GetProcessManager(); @@ -94,89 +89,93 @@ void NeutronHPphysics::ConstructProcess() // G4VProcess* process = 0; process = pManager->GetProcess("hadElastic"); - if (process) pManager->RemoveProcess(process); + if (process) + pManager->RemoveProcess(process); // process = pManager->GetProcess("neutronInelastic"); - if (process) pManager->RemoveProcess(process); + if (process) + pManager->RemoveProcess(process); // - process = pManager->GetProcess("nCapture"); - if (process) pManager->RemoveProcess(process); + process = pManager->GetProcess("nCapture"); + if (process) + pManager->RemoveProcess(process); // - process = pManager->GetProcess("nFission"); - if (process) pManager->RemoveProcess(process); - + process = pManager->GetProcess("nFission"); + if (process) + pManager->RemoveProcess(process); + // (re) create process: elastic // G4HadronElasticProcess* process1 = new G4HadronElasticProcess(); pManager->AddDiscreteProcess(process1); // // model1a - G4ParticleHPElastic* model1a = new G4ParticleHPElastic(); + G4ParticleHPElastic* model1a = new G4ParticleHPElastic(); process1->RegisterMe(model1a); process1->AddDataSet(new G4ParticleHPElasticData()); - - //--- test ---// - /* G4ParticleHPElasticData* dataSet1 = new G4ParticleHPElasticData(); - dataSet1->BuildPhysicsTable(*G4Neutron::Neutron()); - dataSet1->DumpPhysicsTable(*G4Neutron::Neutron()); - - G4ParticleDefinition* particle; - particle = G4Neutron::Neutron(); - G4Element* element = new G4Element("C","C",1); - G4Isotope* isotope = new G4Isotope("C",6,12); - element->AddIsotope(isotope,1); - G4Material* mat = new G4Material("C",2.26*g/cm3,1); - mat->AddElement(element,1); - - for(int i=0; i<20; i++){ - double energy = (1+i)*MeV; - G4DynamicParticle *dn = new G4DynamicParticle(particle,G4ThreeVector(0,0,1), energy); - cout << "--- " << energy << " is ok? ---" << endl; - cout << dn->GetKineticEnergy() << endl; - cout << dn->GetMomentum() << endl; - cout << dataSet1->IsIsoApplicable(dn, 6, 12, element, mat) << endl; - //cout << dataSet1->GetCrossSection(dn,element,273) << endl; - } -*/ + //--- test ---// + /* G4ParticleHPElasticData* dataSet1 = new G4ParticleHPElasticData(); + dataSet1->BuildPhysicsTable(*G4Neutron::Neutron()); + dataSet1->DumpPhysicsTable(*G4Neutron::Neutron()); + + G4ParticleDefinition* particle; + particle = G4Neutron::Neutron(); + G4Element* element = new G4Element("C","C",1); + G4Isotope* isotope = new G4Isotope("C",6,12); + element->AddIsotope(isotope,1); + G4Material* mat = new G4Material("C",2.26*g/cm3,1); + mat->AddElement(element,1); + + for(int i=0; i<20; i++){ + double energy = (1+i)*MeV; + G4DynamicParticle *dn = new G4DynamicParticle(particle,G4ThreeVector(0,0,1), energy); + cout << "--- " << energy << " is ok? ---" << endl; + cout << dn->GetKineticEnergy() << endl; + cout << dn->GetMomentum() << endl; + cout << dataSet1->IsIsoApplicable(dn, 6, 12, element, mat) << endl; + + //cout << dataSet1->GetCrossSection(dn,element,273) << endl; + } + */ // // model1b if (fThermal) { - model1a->SetMinEnergy(4*eV); + model1a->SetMinEnergy(4 * eV); G4ParticleHPThermalScattering* model1b = new G4ParticleHPThermalScattering(); process1->RegisterMe(model1b); process1->AddDataSet(new G4ParticleHPThermalScatteringData()); } - + // (re) create process: inelastic // G4NeutronInelasticProcess* process2 = new G4NeutronInelasticProcess(); - pManager->AddDiscreteProcess(process2); + pManager->AddDiscreteProcess(process2); // // cross section data set G4ParticleHPInelasticData* dataSet2 = new G4ParticleHPInelasticData(); - process2->AddDataSet(dataSet2); + process2->AddDataSet(dataSet2); // // models G4ParticleHPInelastic* model2 = new G4ParticleHPInelastic(); - process2->RegisterMe(model2); + process2->RegisterMe(model2); - // (re) create process: nCapture + // (re) create process: nCapture // G4HadronCaptureProcess* process3 = new G4HadronCaptureProcess(); - pManager->AddDiscreteProcess(process3); + pManager->AddDiscreteProcess(process3); // // cross section data set G4ParticleHPCaptureData* dataSet3 = new G4ParticleHPCaptureData(); process3->AddDataSet(dataSet3); - //dataSet3->BuildPhysicsTable(*G4Neutron::Neutron()); - //dataSet3->DumpPhysicsTable(*G4Neutron::Neutron()); + // dataSet3->BuildPhysicsTable(*G4Neutron::Neutron()); + // dataSet3->DumpPhysicsTable(*G4Neutron::Neutron()); // - // models + // models G4ParticleHPCapture* model3 = new G4ParticleHPCapture(); process3->RegisterMe(model3); - + //--- test ---// /*G4ParticleDefinition* particle; particle = G4Neutron::Neutron(); @@ -193,14 +192,14 @@ void NeutronHPphysics::ConstructProcess() //cout << dataSet3->GetCrossSection(dn,element,12) << endl; }*/ - // (re) create process: nFission + // (re) create process: nFission // G4HadronFissionProcess* process4 = new G4HadronFissionProcess(); pManager->AddDiscreteProcess(process4); // // cross section data set G4ParticleHPFissionData* dataSet4 = new G4ParticleHPFissionData(); - process4->AddDataSet(dataSet4); + process4->AddDataSet(dataSet4); // // models G4ParticleHPFission* model4 = new G4ParticleHPFission(); diff --git a/NPSimulation/Process/PhysicsList.cc b/NPSimulation/Process/PhysicsList.cc index 84219207d2ac090f6adc2cc775fce6d80973d1c1..5ed50f131d7a85c11cee15886386db6f908bf7e8 100644 --- a/NPSimulation/Process/PhysicsList.cc +++ b/NPSimulation/Process/PhysicsList.cc @@ -21,51 +21,53 @@ * * *****************************************************************************/ -//NPS +// NPS #include "PhysicsList.hh" -//NPL +// NPL #include "NPInputParser.h" -#include "NPOptionManager.h" #include "NPNucleus.h" +#include "NPOptionManager.h" // Local physic directly implemented from the Hadronthrapy example // Physic dedicated to the ion-ion inelastic processes -#include "NPIonIonInelasticPhysic.hh" #include "Decay.hh" +#ifndef GEANT4_11 +#include "NPIonIonInelasticPhysic.hh" +#endif // G4 -#include "G4SystemOfUnits.hh" -#include "G4RunManager.hh" -#include "G4PhysListFactory.hh" -#include "G4VPhysicsConstructor.hh" -#include "G4LossTableManager.hh" -#include "G4UnitsTable.hh" -#include "G4ProcessManager.hh" -#include "G4FastSimulationManagerProcess.hh" -#include "G4StepLimiter.hh" -#include "G4BraggIonGasModel.hh" #include "G4BetheBlochIonGasModel.hh" +#include "G4BraggIonGasModel.hh" +#include "G4FastSimulationManagerProcess.hh" #include "G4IonFluctuations.hh" #include "G4IonParametrisedLossModel.hh" -#include "G4UniversalFluctuation.hh" -#include "G4UImanager.hh" -#include "G4NuclearLevelData.hh" #include "G4LevelManager.hh" +#include "G4LossTableManager.hh" +#include "G4NuclearLevelData.hh" #include "G4PAIModel.hh" #include "G4PAIPhotModel.hh" +#include "G4PhysListFactory.hh" +#include "G4ProcessManager.hh" #include "G4RadioactiveDecay.hh" +#include "G4RunManager.hh" +#include "G4StepLimiter.hh" +#include "G4SystemOfUnits.hh" +#include "G4UImanager.hh" +#include "G4UnitsTable.hh" +#include "G4UniversalFluctuation.hh" +#include "G4VPhysicsConstructor.hh" #include "menate_R.hh" #ifdef USE_NEUTRONHP #include "NeutronHPphysics.hh" #endif ///////////////////////////////////////////////////////////////////////////// -PhysicsList::PhysicsList() : G4VUserPhysicsList(){ +PhysicsList::PhysicsList() : G4VUserPhysicsList() { // UI commands to activate one or more High Energy Processes // G4UImanager* UI = G4UImanager::GetUIpointer(); // UI->ApplyCommand("/physics_list/em/MuonNuclear true"); m_EmList = "Option4"; - defaultCutValue = 1*mm;//0.2*mm; + defaultCutValue = 1 * mm; // 0.2*mm; opticalPhysicsList = NULL; driftElectronPhysicsList = NULL; ReadConfiguration("PhysicsListOption.txt"); @@ -86,122 +88,126 @@ PhysicsList::PhysicsList() : G4VUserPhysicsList(){ // Elecromagnetic physics // Using the more accurate option4 - emPhysicsList=NULL; - if(m_EmList == "Option4"){ + emPhysicsList = NULL; + if (m_EmList == "Option4") { emPhysicsList = new G4EmStandardPhysics_option4(); cout << "//// Using G4EmStandardPhysics_option4 Physics List ////" << endl; } - else if(m_EmList== "Option1"){ + else if (m_EmList == "Option1") { emPhysicsList = new G4EmStandardPhysics_option1(); cout << "//// Using G4EmStandardPhysics_option1 Physics List ////" << endl; } - else if(m_EmList== "Option2"){ + else if (m_EmList == "Option2") { emPhysicsList = new G4EmStandardPhysics_option2(); cout << "//// Using G4EmStandardPhysics_option2 Physics List ////" << endl; } - else if(m_EmList== "Option3"){ + else if (m_EmList == "Option3") { emPhysicsList = new G4EmStandardPhysics_option3(); cout << "//// Using G4EmStandardPhysics_option3 Physics List ////" << endl; } - else if(m_EmList== "Standard"){ + else if (m_EmList == "Standard") { emPhysicsList = new G4EmStandardPhysics(); cout << "//// Using G4EmStandardPhysics default EM constructor Physics List ////" << endl; } - else if(m_EmList== "Livermore"){ + else if (m_EmList == "Livermore") { emPhysicsList = new G4EmLivermorePhysics(); cout << "//// Using G4EmLivermorePhysics Physics List ////" << endl; } - else if( m_EmList == "Penelope"){ + else if (m_EmList == "Penelope") { emPhysicsList = new G4EmPenelopePhysics(); cout << "//// Using G4EmPenelopePhysics Physics List ////" << endl; } - else{ - std::cout << "\r\033[1;31mERROR: User given physics list " << m_EmList << " is not supported, option are Option4 Livermore Penelope\033[0m" <<std::endl; + else { + std::cout << "\r\033[1;31mERROR: User given physics list " << m_EmList + << " is not supported, option are Option4 Livermore Penelope\033[0m" << std::endl; exit(1); } emConfig = G4LossTableManager::Instance()->EmConfigurator(); // Hadronic physics - if(m_IonBinaryCascadePhysics){ + if (m_IonBinaryCascadePhysics) { m_PhysList["IonBinaryCascadePhysics"] = new G4IonBinaryCascadePhysics(); cout << "//// Using G4IonBinaryCascadePhysics Physics List ////" << endl; } - if(m_EmExtraPhysics) - m_PhysList["EmExtraPhysics"]=new G4EmExtraPhysics(); + if (m_EmExtraPhysics) + m_PhysList["EmExtraPhysics"] = new G4EmExtraPhysics(); - if(m_HadronElasticPhysics){ - m_PhysList["G4HadronElasticPhysics"]=new G4HadronElasticPhysics(); - m_PhysList["G4IonElasticPhysics"]=new G4IonElasticPhysics(); + if (m_HadronElasticPhysics) { + m_PhysList["G4HadronElasticPhysics"] = new G4HadronElasticPhysics(); + m_PhysList["G4IonElasticPhysics"] = new G4IonElasticPhysics(); cout << "//// Using G4HadronElasticPhysics Physics List ////" << endl; cout << "//// Using G4IonElasticPhysics Physics List ////" << endl; } - if(m_NPIonInelasticPhysics){ - m_PhysList["NPIonInelasticPhysics"]=new NPIonIonInelasticPhysic(); +#ifndef GEANT4_11 + if (m_NPIonInelasticPhysics) { + m_PhysList["NPIonInelasticPhysics"] = new NPIonIonInelasticPhysic(); cout << "//// Using NPIonIonInelasticPhysic Physics List ////" << endl; } - +#endif #ifdef USE_NEUTRONHP - if(m_NeutronHP){ + if (m_NeutronHP) { m_PhysList["NeutronHPphysics"] = new NeutronHPphysics("neutronHP"); cout << "//// Using NeutronHPPhysics ////" << endl; } #endif - if(m_StoppingPhysics){ - m_PhysList["StoppingPhysics"]=new G4StoppingPhysics(); + if (m_StoppingPhysics) { + m_PhysList["StoppingPhysics"] = new G4StoppingPhysics(); cout << "//// Using G4StoppingPhysics Physics List ////" << endl; } - if(m_HadronPhysicsINCLXX){ + if (m_HadronPhysicsINCLXX) { m_PhysList["HadronPhysicsINCLXX"] = new G4HadronPhysicsINCLXX(); m_PhysList["IonPhysicsINCLXX"] = new G4IonINCLXXPhysics(); cout << "//// Using INCLXX Physics List ////" << endl; } - if(m_HadronPhysicsQGSP_BIC_HP){ + if (m_HadronPhysicsQGSP_BIC_HP) { #if NPS_GEANT4_VERSION_MAJOR > 9 m_PhysList["HadronPhysicsQGSP_BIC_HP"] = new G4HadronPhysicsQGSP_BIC_HP(); cout << "//// Using QGSP_BIC_HP Physics List ////" << endl; #else - std::cout << "\r\032[1;31m Warning: physics list HadronPhysicsQGSP_BIC_HP require Geant4 10, process not activated \033[0m" <<std::endl; + std::cout << "\r\032[1;31m Warning: physics list HadronPhysicsQGSP_BIC_HP require Geant4 10, process not activated " + "\033[0m" + << std::endl; #endif } - if(m_HadronPhysicsQGSP_BERT_HP){ + if (m_HadronPhysicsQGSP_BERT_HP) { m_PhysList["HadronPhysicsQGSP_BERT_HP"] = new G4HadronPhysicsQGSP_BERT_HP(); cout << "//// Using QGSP_BERT_HP Physics List ////" << endl; } // Optical Photon for scintillator simulation - if(m_OpticalPhysics){ + if (m_OpticalPhysics) { opticalPhysicsList = new G4OpticalPhysics(0); - opticalPhysicsList->SetMaxNumPhotonsPerStep(100); + /*opticalPhysicsList->SetMaxNumPhotonsPerStep(100); opticalPhysicsList->SetScintillationYieldFactor(0.1); opticalPhysicsList->SetTrackSecondariesFirst(kScintillation,true); opticalPhysicsList->SetTrackSecondariesFirst(kCerenkov,true); - +*/ cout << "//// Using Optical Photon Physics List ////" << endl; } // Drift electron for gazeous detector simulation - if(m_DriftElectronPhysics){ + if (m_DriftElectronPhysics) { driftElectronPhysicsList = new G4DriftElectronPhysics(0); driftElectronPhysicsList->SetMaxNumDriftElectronPerStep(1e6); cout << "//// Using Drift Electron Physics List ////" << endl; } - if(m_IonGasModels){ + if (m_IonGasModels) { AddIonGasModels(); cout << "//// Using Ion Gas Model Physics List ////" << endl; } - if(m_pai){ + if (m_pai) { AddPAIModel("pai"); cout << "//// Using PAI Model Physics List ////" << endl; } - if(m_pai_photon){ + if (m_pai_photon) { AddPAIModel("pai_photon"); cout << "//// Using PAI PHOTON Model Physics List ////" << endl; } @@ -209,22 +215,21 @@ PhysicsList::PhysicsList() : G4VUserPhysicsList(){ // Decay physics // Add Radioactive decay // Gamma decay of known states - if(m_Decay){ - decay_List = new G4DecayPhysics(); - radioactiveDecay_List = new G4RadioactiveDecayPhysics() ; - m_PhysList["decay_list"]= decay_List; - m_PhysList["radioactiveDecay"]=radioactiveDecay_List; + if (m_Decay) { + decay_List = new G4DecayPhysics(); + radioactiveDecay_List = new G4RadioactiveDecayPhysics(); + m_PhysList["decay_list"] = decay_List; + m_PhysList["radioactiveDecay"] = radioactiveDecay_List; } - else{ + else { decay_List = 0; radioactiveDecay_List = 0; } - } //////////////////////////////////////////////////////////////////////////////// -void PhysicsList::ReadConfiguration(std::string filename){ +void PhysicsList::ReadConfiguration(std::string filename) { m_IonBinaryCascadePhysics = 0; m_EmExtraPhysics = 0; m_HadronElasticPhysics = 0; @@ -237,15 +242,16 @@ void PhysicsList::ReadConfiguration(std::string filename){ m_HadronPhysicsINCLXX = 0; m_Decay = 0; m_IonGasModels = 0; - m_pai= 0; - m_pai_photon= 0; + m_pai = 0; + m_pai_photon = 0; m_Menate_R = 0; m_NeutronHP = 0; std::ifstream file(filename.c_str()); - if(!file.is_open()){ - std::cout << "WARNING: Could not find Physics List option file " << filename << " | Using default Physics List" << std::endl; + if (!file.is_open()) { + std::cout << "WARNING: Could not find Physics List option file " << filename << " | Using default Physics List" + << std::endl; return; } @@ -254,36 +260,36 @@ void PhysicsList::ReadConfiguration(std::string filename){ std::string name; std::string str_value; double value; - while(file >> name >> str_value){ + while (file >> name >> str_value) { value = std::atof(str_value.c_str()); - if(name == "EmPhysicsList") + if (name == "EmPhysicsList") m_EmList = str_value; - else if(name == "DefaultCutOff") - defaultCutValue = value*mm; - else if(name == "IonBinaryCascadePhysics") + else if (name == "DefaultCutOff") + defaultCutValue = value * mm; + else if (name == "IonBinaryCascadePhysics") m_IonBinaryCascadePhysics = value; - else if(name == "NPIonInelasticPhysics") + else if (name == "NPIonInelasticPhysics") m_NPIonInelasticPhysics = value; else if (name == "EmExtraPhysics") - m_EmExtraPhysics= value; + m_EmExtraPhysics = value; else if (name == "HadronElasticPhysics") - m_HadronElasticPhysics= value; + m_HadronElasticPhysics = value; else if (name == "StoppingPhysics") - m_StoppingPhysics= value; + m_StoppingPhysics = value; else if (name == "OpticalPhysics") - m_OpticalPhysics= value; + m_OpticalPhysics = value; else if (name == "DriftElectronPhysics") - m_DriftElectronPhysics= value; + m_DriftElectronPhysics = value; else if (name == "HadronPhysicsQGSP_BIC_HP") - m_HadronPhysicsQGSP_BIC_HP= value; + m_HadronPhysicsQGSP_BIC_HP = value; else if (name == "HadronPhysicsQGSP_BERT_HP") - m_HadronPhysicsQGSP_BERT_HP= value; + m_HadronPhysicsQGSP_BERT_HP = value; else if (name == "HadronPhysicsINCLXX") - m_HadronPhysicsINCLXX= value; + m_HadronPhysicsINCLXX = value; else if (name == "Decay") m_Decay = value; else if (name == "IonGasModels") - m_IonGasModels= value; + m_IonGasModels = value; else if (name == "pai") m_pai = value; else if (name == "pai_photon") @@ -293,100 +299,88 @@ void PhysicsList::ReadConfiguration(std::string filename){ else if (name == "NeutronHP") m_NeutronHP = value; else - std::cout <<"WARNING: Physics List Token '" << name << "' unknown. Token is ignored." << std::endl; + std::cout << "WARNING: Physics List Token '" << name << "' unknown. Token is ignored." << std::endl; } // Most special process need decay to be activated - if( (m_IonBinaryCascadePhysics || m_EmExtraPhysics || m_HadronElasticPhysics || m_NPIonInelasticPhysics - || m_StoppingPhysics || m_HadronPhysicsQGSP_BIC_HP || m_HadronPhysicsQGSP_BERT_HP || m_HadronPhysicsINCLXX) && !m_Decay){ + if ((m_IonBinaryCascadePhysics || m_EmExtraPhysics || m_HadronElasticPhysics || m_NPIonInelasticPhysics || + m_StoppingPhysics || m_HadronPhysicsQGSP_BIC_HP || m_HadronPhysicsQGSP_BERT_HP || m_HadronPhysicsINCLXX) && + !m_Decay) { m_Decay = true; std::cout << "Information: Selected process require Decay to be activated." << std::endl; } - } ///////////////////////////////////////////////////////////////////////////// -PhysicsList::~PhysicsList(){ -} +PhysicsList::~PhysicsList() {} ///////////////////////////////////////////////////////////////////////////// -void PhysicsList::AddIonGasModels() -{ +void PhysicsList::AddIonGasModels() { G4ParticleTable::G4PTblDicIterator* particleIterator = G4ParticleTable::GetParticleTable()->GetIterator(); particleIterator->reset(); - while ((*particleIterator)()) - { + while ((*particleIterator)()) { G4ParticleDefinition* particle = particleIterator->value(); G4String partname = particle->GetParticleName(); - if(partname == "p" || partname == "proton" || partname == "alpha" || partname == "He3" || partname == "GenericIon") { + if (partname == "p" || partname == "proton" || partname == "alpha" || partname == "He3" || + partname == "GenericIon") { G4BraggIonGasModel* mod1 = new G4BraggIonGasModel(); G4BetheBlochIonGasModel* mod2 = new G4BetheBlochIonGasModel(); - G4double eth = 2.*MeV*particle->GetPDGMass()/proton_mass_c2; - emConfig->SetExtraEmModel(partname,"ionIoni",mod1,"",0.0,eth,new G4IonFluctuations()); - emConfig->SetExtraEmModel(partname,"ionIoni",mod2,"",eth,100*TeV,new G4UniversalFluctuation()); + G4double eth = 2. * MeV * particle->GetPDGMass() / proton_mass_c2; + emConfig->SetExtraEmModel(partname, "ionIoni", mod1, "", 0.0, eth, new G4IonFluctuations()); + emConfig->SetExtraEmModel(partname, "ionIoni", mod2, "", eth, 100 * TeV, new G4UniversalFluctuation()); } } } ///////////////////////////////////////////////////////////////////////////// -void PhysicsList::AddPAIModel(const G4String& modname) -{ +void PhysicsList::AddPAIModel(const G4String& modname) { G4ParticleTable::G4PTblDicIterator* particleIterator = G4ParticleTable::GetParticleTable()->GetIterator(); particleIterator->reset(); - while ((*particleIterator)()) - { + while ((*particleIterator)()) { G4ParticleDefinition* particle = particleIterator->value(); G4String partname = particle->GetParticleName(); - if(partname == "e-" || partname == "e+") { + if (partname == "e-" || partname == "e+") { NewPAIModel(particle, modname, "eIoni"); - - } else if(partname == "mu-" || partname == "mu+") { + } + else if (partname == "mu-" || partname == "mu+") { NewPAIModel(particle, modname, "muIoni"); - - } else if(partname == "proton" || - partname == "pi+" || - partname == "pi-" - ) { + } + else if (partname == "proton" || partname == "pi+" || partname == "pi-") { NewPAIModel(particle, modname, "hIoni"); } } } ///////////////////////////////////////////////////////////////////////////// -void PhysicsList::NewPAIModel(const G4ParticleDefinition* part, - const G4String& modname, - const G4String& procname) -{ +void PhysicsList::NewPAIModel(const G4ParticleDefinition* part, const G4String& modname, const G4String& procname) { G4String partname = part->GetParticleName(); - if(modname == "pai"){ - G4PAIModel* pai = new G4PAIModel(part,"PAIModel"); - emConfig->SetExtraEmModel(partname,procname,pai,"GasDetector",0.0,100.*TeV,pai); + if (modname == "pai") { + G4PAIModel* pai = new G4PAIModel(part, "PAIModel"); + emConfig->SetExtraEmModel(partname, procname, pai, "GasDetector", 0.0, 100. * TeV, pai); } - else if(modname == "pai_photon") { - G4PAIPhotModel* pai = new G4PAIPhotModel(part,"PAIPhotModel"); - emConfig->SetExtraEmModel(partname,procname,pai,"GasDetector",0.0,100.*TeV,pai); + else if (modname == "pai_photon") { + G4PAIPhotModel* pai = new G4PAIPhotModel(part, "PAIPhotModel"); + emConfig->SetExtraEmModel(partname, procname, pai, "GasDetector", 0.0, 100. * TeV, pai); } } - ///////////////////////////////////////////////////////////////////////////// -void PhysicsList::ConstructParticle(){ - if(m_OpticalPhysics){ - //G4OpticalPhoton::OpticalPhotonDefinition(); - ((G4VPhysicsConstructor*) opticalPhysicsList)->ConstructParticle(); - +void PhysicsList::ConstructParticle() { + if (m_OpticalPhysics) { + // G4OpticalPhoton::OpticalPhotonDefinition(); + ((G4VPhysicsConstructor*)opticalPhysicsList)->ConstructParticle(); } - if(m_DriftElectronPhysics){ - ((G4VPhysicsConstructor*) driftElectronPhysicsList)->ConstructParticle(); + if (m_DriftElectronPhysics) { + ((G4VPhysicsConstructor*)driftElectronPhysicsList)->ConstructParticle(); } - if(decay_List){ - decay_List -> ConstructParticle(); + if (decay_List) { + decay_List->ConstructParticle(); radioactiveDecay_List->ConstructParticle(); } - else{ + else { // If decay is not activated we have to declare the particle ourself G4He3::He3Definition(); G4Deuteron::DeuteronDefinition(); @@ -405,52 +399,52 @@ void PhysicsList::ConstructParticle(){ G4ChargedGeantino::ChargedGeantinoDefinition(); G4Gamma::GammaDefinition(); // mesons - G4PionPlus ::PionPlusDefinition(); - G4PionMinus ::PionMinusDefinition(); - G4PionZero ::PionZeroDefinition(); - G4Eta ::EtaDefinition(); - G4EtaPrime ::EtaPrimeDefinition(); + G4PionPlus ::PionPlusDefinition(); + G4PionMinus ::PionMinusDefinition(); + G4PionZero ::PionZeroDefinition(); + G4Eta ::EtaDefinition(); + G4EtaPrime ::EtaPrimeDefinition(); // G4RhoZero ::RhoZeroDefinition(); - G4KaonPlus ::KaonPlusDefinition(); - G4KaonMinus ::KaonMinusDefinition(); - G4KaonZero ::KaonZeroDefinition(); + G4KaonPlus ::KaonPlusDefinition(); + G4KaonMinus ::KaonMinusDefinition(); + G4KaonZero ::KaonZeroDefinition(); G4AntiKaonZero ::AntiKaonZeroDefinition(); G4KaonZeroLong ::KaonZeroLongDefinition(); G4KaonZeroShort::KaonZeroShortDefinition(); // Ion - G4IonConstructor ionConstructor ; - ionConstructor.ConstructParticle() ; + G4IonConstructor ionConstructor; + ionConstructor.ConstructParticle(); } } ///////////////////////////////////////////////////////////////////////////// -void PhysicsList::ConstructProcess(){ +void PhysicsList::ConstructProcess() { // Transportation AddTransportation(); // Electromagnetic physics - emPhysicsList -> ConstructProcess(); - if(opticalPhysicsList){ - ((G4VPhysicsConstructor*) opticalPhysicsList)->ConstructProcess(); + emPhysicsList->ConstructProcess(); + if (opticalPhysicsList) { + ((G4VPhysicsConstructor*)opticalPhysicsList)->ConstructProcess(); } - if(driftElectronPhysicsList){ - ((G4VPhysicsConstructor*) driftElectronPhysicsList)->ConstructProcess(); + if (driftElectronPhysicsList) { + ((G4VPhysicsConstructor*)driftElectronPhysicsList)->ConstructProcess(); } // Hadronic physics - std::map<std::string,G4VPhysicsConstructor*>::iterator it; - for(it = m_PhysList.begin(); it!= m_PhysList.end(); it++){ - it->second -> ConstructProcess(); + std::map<std::string, G4VPhysicsConstructor*>::iterator it; + for (it = m_PhysList.begin(); it != m_PhysList.end(); it++) { + it->second->ConstructProcess(); } - + BiasCrossSectionByFactor(m_IonBinaryCascadePhysics); - em_parameters=G4EmParameters::Instance(); + em_parameters = G4EmParameters::Instance(); em_parameters->SetFluo(true); em_parameters->SetAuger(true); #if NPS_GEANT4_VERSION_MAJOR > 10 #if NPS_GEANT4_VERSION_MINOR > 2 - em_parameters->SetDeexActiveRegion ("DefaultRegionForTheWorld", true, true,true); + em_parameters->SetDeexActiveRegion("DefaultRegionForTheWorld", true, true, true); em_parameters->SetDeexcitationIgnoreCut(true); #endif #endif @@ -460,12 +454,10 @@ void PhysicsList::ConstructProcess(){ return; } ///////////////////////////////////////////////////////////////////////////// -void PhysicsList::AddStepMax(){ -} +void PhysicsList::AddStepMax() {} ///////////////////////////////////////////////////////////////////////////// -void PhysicsList::AddParametrisation(){ - G4FastSimulationManagerProcess* BeamReaction = - new G4FastSimulationManagerProcess("NPSimulationProcess"); +void PhysicsList::AddParametrisation() { + G4FastSimulationManagerProcess* BeamReaction = new G4FastSimulationManagerProcess("NPSimulationProcess"); // For 10.3 and higher #ifndef theParticleIterator @@ -473,81 +465,75 @@ void PhysicsList::AddParametrisation(){ #endif theParticleIterator->reset(); - while ((*theParticleIterator)()){ + while ((*theParticleIterator)()) { G4ParticleDefinition* particle = theParticleIterator->value(); G4ProcessManager* pmanager = particle->GetProcessManager(); std::string name = particle->GetParticleName(); pmanager->AddDiscreteProcess(BeamReaction); // Add a Step limiter to the beam particle. // This will be used to limit the step of the beam in the target - pmanager->AddProcess(new G4StepLimiter,-1,-1,5); + pmanager->AddProcess(new G4StepLimiter, -1, -1, 5); // Add menate R to the process manager for neutrons // (if selected as a option) - if(m_Menate_R > 0 && name == "neutron") { + if (m_Menate_R > 0 && name == "neutron") { menate_R* theMenate = new menate_R("menateR_neutron"); theMenate->SetMeanFreePathCalcMethod("ORIGINAL"); pmanager->AddDiscreteProcess(theMenate); - std::cout <<"||--------------------------------------------------||" << std::endl; - std::cout <<" MENATE_R Added to Process Manager " << std::endl; - std::cout <<"||--------------------------------------------------||" << std::endl; + std::cout << "||--------------------------------------------------||" << std::endl; + std::cout << " MENATE_R Added to Process Manager " << std::endl; + std::cout << "||--------------------------------------------------||" << std::endl; } } } //////////////////////////////////////////////////////////////////////////////// -void PhysicsList::AddLevelData(){ +void PhysicsList::AddLevelData() { NPL::InputParser parser(NPOptionManager::getInstance()->GetReactionFile()); vector<NPL::InputBlock*> blocks; blocks = parser.GetAllBlocksWithToken("LevelData"); // Loop over all blocks - if (blocks.size()>0 && NPOptionManager::getInstance()->GetVerboseLevel()) - cout << endl << "//// Reading user level data " << endl; - + if (blocks.size() > 0 && NPOptionManager::getInstance()->GetVerboseLevel()) + cout << endl << "//// Reading user level data " << endl; + for (unsigned int i = 0; i < blocks.size(); i++) { - NPL::Nucleus N(blocks[i]->GetMainValue()); - int Z =N.GetZ() ; int A=N.GetA(); + NPL::Nucleus N(blocks[i]->GetMainValue()); + int Z = N.GetZ(); + int A = N.GetA(); cout << " Nuclei: " << N.GetName() << endl; string level_path = blocks[i]->GetString("Path"); G4IonTable* ionTable = G4IonTable::GetIonTable(); G4NuclearLevelData* levelData = G4NuclearLevelData::GetInstance(); levelData->AddPrivateData(Z, A, level_path); const G4LevelManager* levelManager = levelData->GetLevelManager(Z, A); - G4int Nentries = levelManager->NumberOfTransitions()+1; - cout << " Found " << Nentries << " states including g.s." << endl; - for(G4int j = 1; j < Nentries; j++){ // Excited states - cout << " - Level " << j - << " energy = " << levelManager->LevelEnergy(j) - << " MeV \t lifetime = " << levelManager->LifeTime(j) - << " ns \t half-life = " << levelManager->LifeTime(j)*log(2) << " ns" - << endl; - G4ParticleDefinition* excitedState - = ionTable->GetIon(Z,A,levelManager->LevelEnergy(j)); + G4int Nentries = levelManager->NumberOfTransitions() + 1; + cout << " Found " << Nentries << " states including g.s." << endl; + for (G4int j = 1; j < Nentries; j++) { // Excited states + cout << " - Level " << j << " energy = " << levelManager->LevelEnergy(j) + << " MeV \t lifetime = " << levelManager->LifeTime(j) + << " ns \t half-life = " << levelManager->LifeTime(j) * log(2) << " ns" << endl; + G4ParticleDefinition* excitedState = ionTable->GetIon(Z, A, levelManager->LevelEnergy(j)); excitedState->SetPDGStable(false); excitedState->SetPDGLifeTime(levelManager->LifeTime(j)); } - } - } ///////////////////////////////////////////////////////////////////////////// -void PhysicsList::SetCuts(){ +void PhysicsList::SetCuts() { - if (verboseLevel >0){ + if (verboseLevel > 0) { G4cout << "PhysicsList::SetCuts:"; - G4cout << "CutLength : " << G4BestUnit(defaultCutValue,"Length") << G4endl; + G4cout << "CutLength : " << G4BestUnit(defaultCutValue, "Length") << G4endl; } // Special Cut for optical photon to be emmitted SetCutsWithDefault(); - if(m_NeutronHP) - SetCutValue(0*mm,"proton"); + if (m_NeutronHP) + SetCutValue(0 * mm, "proton"); } //////////////////////////////////////////////////////////////////////////////// /////// Friend Method for CS biasing //////////////////////////////////////////////////////////////////////////////// -void PhysicsList::BiasCrossSectionByFactor(double factor){ - factor++; -} +void PhysicsList::BiasCrossSectionByFactor(double factor) { factor++; } diff --git a/NPSimulation/Process/menate_R.cc b/NPSimulation/Process/menate_R.cc index 38cdf914b0df7d54cc4402534045401946933cbf..757ac4a0f387173f8ca1a82ea41c5b9b22de6481 100644 --- a/NPSimulation/Process/menate_R.cc +++ b/NPSimulation/Process/menate_R.cc @@ -1,13 +1,13 @@ //-------------------------------------------------------------------- //-------------------------------------------------------------------- // -// menate_R.cc +// menate_R.cc // // Description - contains member functions declared in menate_R.hh // // started on 6 May 2008 // -// Written by: Brian Roeder, Postdoc, LPC Caen, Texas A&M Univ. +// Written by: Brian Roeder, Postdoc, LPC Caen, Texas A&M Univ. // email - broeder@comp.tamu.edu // // -Kinematics processes in PostStepDoIt translated from FORTRAN code @@ -19,7 +19,7 @@ // other processes. //--------------------------------------------------------------------- // Version Comments - (other changes/fixes noted in menate_R.hh) -// +// // 23 April 2008 - version 1.0 -> working version -> by Brian Roeder // modified functions and cross section read-in functions // added all reactions considered in original MENATE including: @@ -79,16 +79,15 @@ #include <iomanip> using namespace CLHEP; -menate_R::menate_R(const G4String& processName) : G4VDiscreteProcess(processName) -{ +menate_R::menate_R(const G4String& processName) : G4VDiscreteProcess(processName) { Pi = CLHEP::pi; - Two_Pi = 2.*Pi; + Two_Pi = 2. * Pi; AMass_Material = 12.; // Atomic Mass of C12 for certain inelastic reactions // If Used with materials other than C12, need to // give atomic Mass here or in PostStepDoIt Method (as for NE213) - CalcMeth="ORIGINAL"; + CalcMeth = "ORIGINAL"; G4cout << "Constructor for menate_R process was called! " << G4endl; G4cout << "A non-relativistic model for n - scattering "; @@ -97,9 +96,9 @@ menate_R::menate_R(const G4String& processName) : G4VDiscreteProcess(processName Setup_FeElastic_AngDist(); Setup_AlElastic_AngDist(); - + const G4MaterialTable* theMaterialList = G4Material::GetMaterialTable(); - G4int NumberOfMaterials = G4Material::GetNumberOfMaterials(); + G4int NumberOfMaterials = G4Material::GetNumberOfMaterials(); // Read Each Material to get List of Elements H_Switch = false; @@ -107,211 +106,200 @@ menate_R::menate_R(const G4String& processName) : G4VDiscreteProcess(processName Fe_Switch = false; Al_Switch = false; - for(G4int i=0; i<NumberOfMaterials; i++) - { - // Searches to see if Carbon and Hydrogen defined. - // Can add other elements to this process later if needed. - - const G4Material* theMaterial = (*theMaterialList)[i]; - G4String MaterialName = theMaterial->GetName(); - const G4ElementVector* theElementList = theMaterial->GetElementVector(); - G4int NumberOfElements = theMaterial->GetNumberOfElements(); - - for(G4int j=0;j<NumberOfElements; j++) - { - if(j == 0) - {G4cout << "Reading Elements in Material : " << MaterialName << G4endl;} - - const G4Element* theElement = (*theElementList)[j]; - G4String theElementName = theElement->GetName(); - - if(theElementName == "Hydrogen" || theElementName == "H") - { H_Switch = true; } // Hydrogen defined - else if(theElementName == "Carbon" || theElementName == "C") - { C_Switch = true; } // Carbon defined - else if(theElementName == "Iron" || theElementName == "Fe") - { Fe_Switch = true; } // Iron defined - else if(theElementName == "Aluminum" || theElementName == "Al") - { Al_Switch = true; } // Al defined - } + for (G4int i = 0; i < NumberOfMaterials; i++) { + // Searches to see if Carbon and Hydrogen defined. + // Can add other elements to this process later if needed. + + const G4Material* theMaterial = (*theMaterialList)[i]; + G4String MaterialName = theMaterial->GetName(); + const G4ElementVector* theElementList = theMaterial->GetElementVector(); + G4int NumberOfElements = theMaterial->GetNumberOfElements(); + + for (G4int j = 0; j < NumberOfElements; j++) { + if (j == 0) { + G4cout << "Reading Elements in Material : " << MaterialName << G4endl; + } + + const G4Element* theElement = (*theElementList)[j]; + G4String theElementName = theElement->GetName(); + + if (theElementName == "Hydrogen" || theElementName == "H") { + H_Switch = true; + } // Hydrogen defined + else if (theElementName == "Carbon" || theElementName == "C") { + C_Switch = true; + } // Carbon defined + else if (theElementName == "Iron" || theElementName == "Fe") { + Fe_Switch = true; + } // Iron defined + else if (theElementName == "Aluminum" || theElementName == "Al") { + Al_Switch = true; + } // Al defined } + } // Load Cross Sections if Element is Found - if(H_Switch == true) - { ReadCrossSectionFile("Hydrogen1_el.dat",theHydrogenXS);} - - if(C_Switch == true) - { - // Load all Carbon Elastic and Inelastic Cross Sections - ReadCrossSectionFile("Carbon12_el.dat",theCarbonXS); - ReadCrossSectionFile("Carbon12_nng4_4.dat",theC12NGammaXS); - ReadCrossSectionFile("Carbon12_na9Be.dat",theC12ABe9XS); - ReadCrossSectionFile("Carbon12_np12B.dat",theC12NPB12XS); -// ReadCrossSectionFile("Carbon12_nnp11B.dat",theC12NNPB11XS); - ReadCrossSectionFile("MODIFIED_12Cnnp11B.dat",theC12NNPB11XS); - ReadCrossSectionFile("Carbon12_2n11C.dat",theC12N2NC11XS); - ReadCrossSectionFile("Carbon12_nn3a.dat",theC12NN3AlphaXS); - } - - if(Fe_Switch == true){ - ReadCrossSectionFile("Iron56_el.dat",theIronElasXS); - ReadCrossSectionFile("Iron56_nonel.dat",theIronNonelasXS); - } - - if(Al_Switch == true){ - ReadCrossSectionFile("Al27_el.dat",theAlElasXS); - ReadCrossSectionFile("Al27_nonel.dat",theAlNonelasXS); - } - - G4cout << "Finished Building Cross Section Table! " << G4endl; -} + if (H_Switch == true) { + ReadCrossSectionFile("Hydrogen1_el.dat", theHydrogenXS); + } + + if (C_Switch == true) { + // Load all Carbon Elastic and Inelastic Cross Sections + ReadCrossSectionFile("Carbon12_el.dat", theCarbonXS); + ReadCrossSectionFile("Carbon12_nng4_4.dat", theC12NGammaXS); + ReadCrossSectionFile("Carbon12_na9Be.dat", theC12ABe9XS); + ReadCrossSectionFile("Carbon12_np12B.dat", theC12NPB12XS); + // ReadCrossSectionFile("Carbon12_nnp11B.dat",theC12NNPB11XS); + ReadCrossSectionFile("MODIFIED_12Cnnp11B.dat", theC12NNPB11XS); + ReadCrossSectionFile("Carbon12_2n11C.dat", theC12N2NC11XS); + ReadCrossSectionFile("Carbon12_nn3a.dat", theC12NN3AlphaXS); + } + if (Fe_Switch == true) { + ReadCrossSectionFile("Iron56_el.dat", theIronElasXS); + ReadCrossSectionFile("Iron56_nonel.dat", theIronNonelasXS); + } + + if (Al_Switch == true) { + ReadCrossSectionFile("Al27_el.dat", theAlElasXS); + ReadCrossSectionFile("Al27_nonel.dat", theAlNonelasXS); + } -menate_R::~menate_R() -{;} + G4cout << "Finished Building Cross Section Table! " << G4endl; +} +menate_R::~menate_R() { ; } -G4double menate_R::Absolute(G4double Num) -{ - if(Num < 0.) - { Num *= -1.;} +G4double menate_R::Absolute(G4double Num) { + if (Num < 0.) { + Num *= -1.; + } return Num; } -G4double menate_R::SIGN(G4double A1, G4double B2) -{ +G4double menate_R::SIGN(G4double A1, G4double B2) { // Does FORTRAN sign command // Return "A1" with the sign of B2 - if(B2 >= 0.) - {A1 = Absolute(A1);} - else - {A1 = -1.*Absolute(A1);} + if (B2 >= 0.) { + A1 = Absolute(A1); + } + else { + A1 = -1. * Absolute(A1); + } return A1; } -void menate_R::ReadCrossSectionFile(G4String FileName, CrossSectionClass* theReactionXS) -{ - if(!getenv("NPTOOL")) - { - G4cerr << "Please set NPTOOL environment variable!" << G4endl; - exit(1); - } - G4String DirName = G4String(getenv("NPTOOL")) + "/Inputs/CrossSection/MENATE_R"; +void menate_R::ReadCrossSectionFile(G4String FileName, CrossSectionClass* theReactionXS) { + if (!getenv("NPTOOL")) { + G4cerr << "Please set NPTOOL environment variable!" << G4endl; + exit(1); + } + G4String DirName = G4String(getenv("NPTOOL")) + "/Inputs/CrossSection/MENATE_R"; - FileName = DirName+"/"+FileName; + FileName = DirName + "/" + FileName; G4String ElementName_; G4int NumberOfLines = 0; std::fstream theFile; - theFile.open(FileName, std::fstream::in ); - theFile >> NumberOfLines; - - if(theFile.good()) - { - theFile >> ElementName_; - - G4cout << "Loading Data For : " << ElementName_ << " , FileName = " << FileName << G4endl; - for(G4int k=0; k<NumberOfLines; k++) - { - G4double theEnergy; - G4double theCrossSection; - theFile >> theEnergy >> theCrossSection; - - if(FileName.contains("Iron") || FileName.contains("Al27") ){ - theReactionXS[k].SetNumberOfLines(NumberOfLines); - theReactionXS[k].SetElementName(ElementName_); - theReactionXS[k].SetKinEng(theEnergy*eV); - theReactionXS[k].SetTotalCrossSection(theCrossSection*barn); - //G4cout << theReactionXS[k].GetKinEng()/MeV << " " << theReactionXS[k].GetTotalCrossSection()/barn << G4endl; - } else{ - theReactionXS[k].SetNumberOfLines(NumberOfLines); - theReactionXS[k].SetElementName(ElementName_); - theReactionXS[k].SetKinEng(theEnergy*MeV); - theReactionXS[k].SetTotalCrossSection(theCrossSection*barn); - } - - /*//zwk adjusting cross sections - if(FileName.contains("nng4")){ - theReactionXS[k].SetTotalCrossSection(50*theCrossSection*barn); - G4cout << "nng4 cross section enhanced :) !!" << G4endl; - } - else theReactionXS[k].SetTotalCrossSection(theCrossSection*barn); */ - //theReactionXS[k].DumpData(); - } - G4cout << "Successfully Loaded !" << G4endl; - theFile.close(); - } - else - { - G4cerr << "File = " << FileName << " not found or in improper format." << G4endl; - enum G4ExceptionSeverity severity; - severity = JustWarning; - G4Exception("Program aborted in menate::ReadCrossSectionFile() method!","",severity,""); + theFile.open(FileName, std::fstream::in); + theFile >> NumberOfLines; + + if (theFile.good()) { + theFile >> ElementName_; + + G4cout << "Loading Data For : " << ElementName_ << " , FileName = " << FileName << G4endl; + for (G4int k = 0; k < NumberOfLines; k++) { + G4double theEnergy; + G4double theCrossSection; + theFile >> theEnergy >> theCrossSection; + + if (FileName.contains("Iron") || FileName.contains("Al27")) { + theReactionXS[k].SetNumberOfLines(NumberOfLines); + theReactionXS[k].SetElementName(ElementName_); + theReactionXS[k].SetKinEng(theEnergy * eV); + theReactionXS[k].SetTotalCrossSection(theCrossSection * barn); + // G4cout << theReactionXS[k].GetKinEng()/MeV << " " << theReactionXS[k].GetTotalCrossSection()/barn << G4endl; + } + else { + theReactionXS[k].SetNumberOfLines(NumberOfLines); + theReactionXS[k].SetElementName(ElementName_); + theReactionXS[k].SetKinEng(theEnergy * MeV); + theReactionXS[k].SetTotalCrossSection(theCrossSection * barn); + } + + /*//zwk adjusting cross sections + if(FileName.contains("nng4")){ + theReactionXS[k].SetTotalCrossSection(50*theCrossSection*barn); + G4cout << "nng4 cross section enhanced :) !!" << G4endl; + } + else theReactionXS[k].SetTotalCrossSection(theCrossSection*barn); */ + // theReactionXS[k].DumpData(); } -} - + G4cout << "Successfully Loaded !" << G4endl; + theFile.close(); + } + else { + G4cerr << "File = " << FileName << " not found or in improper format." << G4endl; + enum G4ExceptionSeverity severity; + severity = JustWarning; + G4Exception("Program aborted in menate::ReadCrossSectionFile() method!", "", severity, ""); + } +} -G4double menate_R::GetCrossSection(G4double KinEng, CrossSectionClass* theReactionXS) -{ - G4double CrossSection=0.; +G4double menate_R::GetCrossSection(G4double KinEng, CrossSectionClass* theReactionXS) { + G4double CrossSection = 0.; G4int NumberOfLines; - NumberOfLines = theReactionXS[0].GetNumberOfLines(); - - if(KinEng > (theReactionXS[NumberOfLines-1].GetKinEng())) - { - G4cout << "The Neutron Energy is higher than the Total Cross Section DataFile!" << G4endl; - G4cout << "Using last cross section available!!!!!!!!" << G4endl; - G4cout << " Name: " << theReactionXS[0].GetElementName() << G4endl; - G4cout << " Max XS Energy: " << theReactionXS[NumberOfLines-1].GetKinEng() << G4endl; - //G4cerr << "Setting Cross Section = 0 !!!!!!!!!!!!!!!!!!!!!!!" << G4endl; - //return 0.; - //zwk use last cross section rather than nothing - return theReactionXS[NumberOfLines-1].GetTotalCrossSection(); - } - - for(G4int k=0; k<NumberOfLines; k++) - { - if((theReactionXS[k].GetKinEng()) == KinEng) - { - CrossSection = theReactionXS[k].GetTotalCrossSection(); - //G4cout << CrossSection/barn << " barn" << G4endl; - return CrossSection; - } - else if ((theReactionXS[k].GetKinEng()) > KinEng) - { - //G4cout << "Calculating average Cross Section (no exact match)" << G4endl; - //G4cout << KinEng/MeV << G4endl; - G4double LowEng = (theReactionXS[k-1].GetKinEng()); - G4double HighEng = (theReactionXS[k].GetKinEng()); - G4double LowerXS = (theReactionXS[k-1].GetTotalCrossSection()); - G4double UpperXS = (theReactionXS[k].GetTotalCrossSection()); - CrossSection = GetXSInterpolation(KinEng,LowEng,HighEng,LowerXS,UpperXS); - //G4cout << CrossSection/barn << " barn" << G4endl; - return CrossSection; - } - } - + NumberOfLines = theReactionXS[0].GetNumberOfLines(); + + if (KinEng > (theReactionXS[NumberOfLines - 1].GetKinEng())) { + G4cout << "The Neutron Energy is higher than the Total Cross Section DataFile!" << G4endl; + G4cout << "Using last cross section available!!!!!!!!" << G4endl; + G4cout << " Name: " << theReactionXS[0].GetElementName() << G4endl; + G4cout << " Max XS Energy: " << theReactionXS[NumberOfLines - 1].GetKinEng() << G4endl; + // G4cerr << "Setting Cross Section = 0 !!!!!!!!!!!!!!!!!!!!!!!" << G4endl; + // return 0.; + // zwk use last cross section rather than nothing + return theReactionXS[NumberOfLines - 1].GetTotalCrossSection(); + } + + for (G4int k = 0; k < NumberOfLines; k++) { + if ((theReactionXS[k].GetKinEng()) == KinEng) { + CrossSection = theReactionXS[k].GetTotalCrossSection(); + // G4cout << CrossSection/barn << " barn" << G4endl; + return CrossSection; + } + else if ((theReactionXS[k].GetKinEng()) > KinEng) { + // G4cout << "Calculating average Cross Section (no exact match)" << G4endl; + // G4cout << KinEng/MeV << G4endl; + G4double LowEng = (theReactionXS[k - 1].GetKinEng()); + G4double HighEng = (theReactionXS[k].GetKinEng()); + G4double LowerXS = (theReactionXS[k - 1].GetTotalCrossSection()); + G4double UpperXS = (theReactionXS[k].GetTotalCrossSection()); + CrossSection = GetXSInterpolation(KinEng, LowEng, HighEng, LowerXS, UpperXS); + // G4cout << CrossSection/barn << " barn" << G4endl; + return CrossSection; + } + } + return CrossSection; } -G4double menate_R::GetXSInterpolation(G4double KinEng, G4double LowEng, G4double HighEng, - G4double LowXS, G4double HighXS) -{ - G4double slope = (HighXS-LowXS)/(HighEng-LowEng); - G4double y_inter = HighXS-(slope*HighEng); +G4double menate_R::GetXSInterpolation(G4double KinEng, G4double LowEng, G4double HighEng, G4double LowXS, + G4double HighXS) { + G4double slope = (HighXS - LowXS) / (HighEng - LowEng); + G4double y_inter = HighXS - (slope * HighEng); - G4double Interpol_XS = y_inter + (slope*KinEng); + G4double Interpol_XS = y_inter + (slope * KinEng); return Interpol_XS; } -G4ThreeVector menate_R::GenMomDir(G4ThreeVector MomDirIn, G4double theta, G4double phi) -{ +G4ThreeVector menate_R::GenMomDir(G4ThreeVector MomDirIn, G4double theta, G4double phi) { // Generates final momentum direction in frame of initial particle // follows routine of "MEN_COMPUTE_DIRECTION" // Accounts for initial direction of neutron not parallel to z-axis @@ -322,51 +310,45 @@ G4ThreeVector menate_R::GenMomDir(G4ThreeVector MomDirIn, G4double theta, G4doub G4double CosTh = cos(theta); G4double SinPh = sin(phi); G4double CosPh = cos(phi); - G4double CONS = sqrt( Absolute((1. - pow(MomDirIn[2],2))) ); + G4double CONS = sqrt(Absolute((1. - pow(MomDirIn[2], 2)))); G4ThreeVector MomDirOut; - MomDirOut[0] = SinTh*CosPh; - MomDirOut[1] = SinTh*SinPh; + MomDirOut[0] = SinTh * CosPh; + MomDirOut[1] = SinTh * SinPh; MomDirOut[2] = CosTh; - if(CONS > 1e-8) - { - // If CONS > 1e-8, not on z-axis, so need to change frames as below: - MomDirOut[0] = (SinTh*CosPh*MomDirIn[0]*MomDirIn[2]/CONS) + - (SinTh*SinPh*MomDirIn[1]/CONS) + - (CosTh*MomDirIn[0]); - MomDirOut[1] = (SinTh*CosPh*MomDirIn[1]*MomDirIn[2]/CONS) - - (SinTh*SinPh*MomDirIn[0]/CONS) + - (CosTh*MomDirIn[1]); - MomDirOut[2] = -(SinTh*CosPh*CONS) + CosTh*MomDirIn[2]; - } + if (CONS > 1e-8) { + // If CONS > 1e-8, not on z-axis, so need to change frames as below: + MomDirOut[0] = (SinTh * CosPh * MomDirIn[0] * MomDirIn[2] / CONS) + (SinTh * SinPh * MomDirIn[1] / CONS) + + (CosTh * MomDirIn[0]); + MomDirOut[1] = (SinTh * CosPh * MomDirIn[1] * MomDirIn[2] / CONS) - (SinTh * SinPh * MomDirIn[0] / CONS) + + (CosTh * MomDirIn[1]); + MomDirOut[2] = -(SinTh * CosPh * CONS) + CosTh * MomDirIn[2]; + } - G4double Norm = sqrt(pow(MomDirOut[0],2)+pow(MomDirOut[1],2)+pow(MomDirOut[2],2)); + G4double Norm = sqrt(pow(MomDirOut[0], 2) + pow(MomDirOut[1], 2) + pow(MomDirOut[2], 2)); // G4double DiffNorm = Absolute(1.-Norm); - if(Norm != 1.) - { - //zwk commented out - //only occured once when running millions of events - // if(DiffNorm >= 1e-6) - // {G4Exception(" Momentum Direction not a unit vector in menate_R::GenMomDir(): Aborted!");} + if (Norm != 1.) { + // zwk commented out + // only occured once when running millions of events + // if(DiffNorm >= 1e-6) + // {G4Exception(" Momentum Direction not a unit vector in menate_R::GenMomDir(): Aborted!");} - // Fixes slight norm diff due to rounding to avoid G4 error + // Fixes slight norm diff due to rounding to avoid G4 error - MomDirOut[0] /= Norm; - MomDirOut[1] /= Norm; - MomDirOut[2] /= Norm; - - } + MomDirOut[0] /= Norm; + MomDirOut[1] /= Norm; + MomDirOut[2] /= Norm; + } return MomDirOut; } -G4double menate_R::ShareGammaEngC12(G4double Available_Eng) -{ +G4double menate_R::ShareGammaEngC12(G4double Available_Eng) { // 24 Apr. 2008 - This function translated from original FORTRAN "MENATE_R" // Bleeds excitation energy of C12* into 400 keV gamma rays unless there - // is enough energy to create the 4.439 MeV (2+->g.s.) gamma. + // is enough energy to create the 4.439 MeV (2+->g.s.) gamma. // Addition of this function effects neutron det. efficiency in region // between 5-11 MeV (lowers eff. by a few percent). @@ -376,116 +358,114 @@ G4double menate_R::ShareGammaEngC12(G4double Available_Eng) G4double Remaining_Eng = Available_Eng; - while(Remaining_Eng > 4.439*MeV) - { - Num_gamma_4439k++; - Remaining_Eng -= 4.439*MeV; - } + while (Remaining_Eng > 4.439 * MeV) { + Num_gamma_4439k++; + Remaining_Eng -= 4.439 * MeV; + } - G4double Tot_Gamma_Eng = static_cast<G4double>(Num_gamma_4439k)*4.439*MeV; + G4double Tot_Gamma_Eng = static_cast<G4double>(Num_gamma_4439k) * 4.439 * MeV; - return Tot_Gamma_Eng; + return Tot_Gamma_Eng; } - -G4double menate_R::Evaporate_Eng(G4double AMass,G4double Available_Eng) -{ +G4double menate_R::Evaporate_Eng(G4double AMass, G4double Available_Eng) { // Calculate an energy included between 0 and Available_Eng following a probability // density dp/de = e/n*exp(-e/t) --- copied from MENATE_R fortran code - + G4double Evap_Eng = 0.; - G4double Temperature = sqrt(8.*Available_Eng/AMass); + G4double Temperature = sqrt(8. * Available_Eng / AMass); - if(Temperature == 0.) - { - Evap_Eng = 0.; - return Evap_Eng; - } + if (Temperature == 0.) { + Evap_Eng = 0.; + return Evap_Eng; + } G4double ALEA = G4UniformRand(); - G4double XEV = Available_Eng/Temperature; + G4double XEV = Available_Eng / Temperature; - if(XEV < 1e-4) - { Evap_Eng = 0.; } - else - { - G4double ZNORM = 1. - (1.-(1.+XEV)*exp(-XEV))*ALEA; - if(ZNORM == 0.) - { - Evap_Eng = 0.; - return Evap_Eng; - } - G4double YEV = XEV*ALEA; - G4double XEV1; - - do{ - XEV1 = YEV; - YEV = log((1.+XEV1)/ZNORM); - if( XEV1 == 0.) - { - Evap_Eng = 0.; - return Evap_Eng; - } - } - while(Absolute((YEV/XEV1)-1.) > 1e-6); - - Evap_Eng = YEV*Temperature; - } - - if(Evap_Eng >= Available_Eng) - { Evap_Eng = Available_Eng; } + if (XEV < 1e-4) { + Evap_Eng = 0.; + } + else { + G4double ZNORM = 1. - (1. - (1. + XEV) * exp(-XEV)) * ALEA; + if (ZNORM == 0.) { + Evap_Eng = 0.; + return Evap_Eng; + } + G4double YEV = XEV * ALEA; + G4double XEV1; + + do { + XEV1 = YEV; + YEV = log((1. + XEV1) / ZNORM); + if (XEV1 == 0.) { + Evap_Eng = 0.; + return Evap_Eng; + } + } while (Absolute((YEV / XEV1) - 1.) > 1e-6); + + Evap_Eng = YEV * Temperature; + } + + if (Evap_Eng >= Available_Eng) { + Evap_Eng = Available_Eng; + } return Evap_Eng; } - -void menate_R::SetMeanFreePathCalcMethod(G4String Method) -{ +void menate_R::SetMeanFreePathCalcMethod(G4String Method) { CalcMeth = Method; G4cout << "The MeanFreePath and Reaction Calculations method is set to : " << CalcMeth << G4endl; } - -G4String menate_R::ChooseReaction() -{ - // Chooses Reaction that is used in PostStepDoIt +G4String menate_R::ChooseReaction() { + // Chooses Reaction that is used in PostStepDoIt G4String theReaction = "NoReaction"; - if(H_Switch == true && C_Switch == false && Fe_Switch==false && Al_Switch==false) - { theReaction = "N_P_elastic"; } - else if(C_Switch == true || Fe_Switch == true || Al_Switch==true) - { - // Get number of probabilities considered - // Only include if Cross Section > 0 ! - G4double ProbSigma[12]; - G4double ProbLimit[12]; - if(H_Switch == false){ - ProbSigma[0] = 0.; - ProbLimit[0] = 0.; - } - if(C_Switch == false){ - for(int p=1; p<8; p++){ProbSigma[p]=0.; ProbLimit[0]=0.;} - } - if(Fe_Switch == false){ - ProbSigma[8]=0; ProbLimit[8]=0; - ProbSigma[9]=0; ProbLimit[9]=0; - } - if(Al_Switch == false){ - ProbSigma[10]=0; ProbLimit[10]=0; - ProbSigma[11]=0; ProbLimit[11]=0; - } - - for(G4int i=0; i<12; i++) - { - ProbSigma[i] = ProbDistPerReaction[i]/ProbTot; - - if( i == 0 ) - { ProbLimit[i] = ProbSigma[i]; } - else - { ProbLimit[i] = ProbLimit[i-1] + ProbSigma[i]; } - //G4cout << "ProbSigma " << i << " is : " << ProbSigma[i] << " ProbLimit = " << ProbLimit[i] << G4endl; - } + if (H_Switch == true && C_Switch == false && Fe_Switch == false && Al_Switch == false) { + theReaction = "N_P_elastic"; + } + else if (C_Switch == true || Fe_Switch == true || Al_Switch == true) { + // Get number of probabilities considered + // Only include if Cross Section > 0 ! + G4double ProbSigma[12]; + G4double ProbLimit[12]; + if (H_Switch == false) { + ProbSigma[0] = 0.; + ProbLimit[0] = 0.; + } + if (C_Switch == false) { + for (int p = 1; p < 8; p++) { + ProbSigma[p] = 0.; + ProbLimit[0] = 0.; + } + } + if (Fe_Switch == false) { + ProbSigma[8] = 0; + ProbLimit[8] = 0; + ProbSigma[9] = 0; + ProbLimit[9] = 0; + } + if (Al_Switch == false) { + ProbSigma[10] = 0; + ProbLimit[10] = 0; + ProbSigma[11] = 0; + ProbLimit[11] = 0; + } + + for (G4int i = 0; i < 12; i++) { + ProbSigma[i] = ProbDistPerReaction[i] / ProbTot; + + if (i == 0) { + ProbLimit[i] = ProbSigma[i]; + } + else { + ProbLimit[i] = ProbLimit[i - 1] + ProbSigma[i]; + } + // G4cout << "ProbSigma " << i << " is : " << ProbSigma[i] << " ProbLimit = " << ProbLimit[i] << G4endl; + } // Set Reaction Type // H(n,np) - N_P_elastic @@ -496,99 +476,108 @@ G4String menate_R::ChooseReaction() // 12C(n,np)11B - N_C12_NNP_B11 // 12C(n,2n)11C - N_C12_N2N_C11 // 12C(n,n')3alpha - N_C12_NN3Alpha - //Fe (n,n) - N_Fe_elastic - //Fe (n,x) - N_Fe_nonelastic - //Al (n,n) - N_Al_elastic - //Al (n,x) - N_Al_nonelastic - - while(theReaction == "NoReaction") - { - // Loop through reactions until one is chosen. - // If Prob = 0. for a Reaction, disregarded - G4double RecRandnum = G4UniformRand(); - if(RecRandnum < ProbLimit[0] && ProbSigma[0] > 0.) - { theReaction = "N_P_elastic"; } - if(RecRandnum >= ProbLimit[0] && RecRandnum < ProbLimit[1] && ProbSigma[1] > 0.) - { theReaction = "N_C12_elastic"; } - if(RecRandnum >= ProbLimit[1] && RecRandnum < ProbLimit[2] && ProbSigma[2] > 0.) - { theReaction = "N_C12_NGamma"; } - if(RecRandnum >= ProbLimit[2] && RecRandnum < ProbLimit[3] && ProbSigma[3] > 0.) - { theReaction = "N_C12_A_Be9"; } - if(RecRandnum >= ProbLimit[3] && RecRandnum < ProbLimit[4] && ProbSigma[4] > 0.) - { theReaction = "N_C12_P_B12"; } - if(RecRandnum >= ProbLimit[4] && RecRandnum < ProbLimit[5] && ProbSigma[5] > 0.) - { theReaction = "N_C12_NNP_B11"; } - if(RecRandnum >= ProbLimit[5] && RecRandnum < ProbLimit[6] && ProbSigma[6] > 0.) - { theReaction = "N_C12_N2N_C11"; } - if(RecRandnum >= ProbLimit[6] && RecRandnum < ProbLimit[7] && ProbSigma[7] > 0.) - { theReaction = "N_C12_NN3Alpha"; } - if(RecRandnum >= ProbLimit[7] && RecRandnum < ProbLimit[8] && ProbSigma[8] > 0.) - { theReaction = "N_Fe_elastic"; } - if(RecRandnum >= ProbLimit[8] && RecRandnum < ProbLimit[9] && ProbSigma[9] > 0.) - { theReaction = "N_Fe_nonelastic"; } - if(RecRandnum >= ProbLimit[9] && RecRandnum < ProbLimit[10] && ProbSigma[10] > 0.) - { theReaction = "N_Al_elastic"; } - if(RecRandnum >= ProbLimit[10] && RecRandnum < ProbLimit[11] && ProbSigma[11] > 0.) - { theReaction = "N_Al_nonelastic"; } - } - - - // G4cout << "***************Reaction Chosen was : " << theReaction << G4endl; - } - return theReaction; + // Fe (n,n) - N_Fe_elastic + // Fe (n,x) - N_Fe_nonelastic + // Al (n,n) - N_Al_elastic + // Al (n,x) - N_Al_nonelastic + + while (theReaction == "NoReaction") { + // Loop through reactions until one is chosen. + // If Prob = 0. for a Reaction, disregarded + G4double RecRandnum = G4UniformRand(); + if (RecRandnum < ProbLimit[0] && ProbSigma[0] > 0.) { + theReaction = "N_P_elastic"; + } + if (RecRandnum >= ProbLimit[0] && RecRandnum < ProbLimit[1] && ProbSigma[1] > 0.) { + theReaction = "N_C12_elastic"; + } + if (RecRandnum >= ProbLimit[1] && RecRandnum < ProbLimit[2] && ProbSigma[2] > 0.) { + theReaction = "N_C12_NGamma"; + } + if (RecRandnum >= ProbLimit[2] && RecRandnum < ProbLimit[3] && ProbSigma[3] > 0.) { + theReaction = "N_C12_A_Be9"; + } + if (RecRandnum >= ProbLimit[3] && RecRandnum < ProbLimit[4] && ProbSigma[4] > 0.) { + theReaction = "N_C12_P_B12"; + } + if (RecRandnum >= ProbLimit[4] && RecRandnum < ProbLimit[5] && ProbSigma[5] > 0.) { + theReaction = "N_C12_NNP_B11"; + } + if (RecRandnum >= ProbLimit[5] && RecRandnum < ProbLimit[6] && ProbSigma[6] > 0.) { + theReaction = "N_C12_N2N_C11"; + } + if (RecRandnum >= ProbLimit[6] && RecRandnum < ProbLimit[7] && ProbSigma[7] > 0.) { + theReaction = "N_C12_NN3Alpha"; + } + if (RecRandnum >= ProbLimit[7] && RecRandnum < ProbLimit[8] && ProbSigma[8] > 0.) { + theReaction = "N_Fe_elastic"; + } + if (RecRandnum >= ProbLimit[8] && RecRandnum < ProbLimit[9] && ProbSigma[9] > 0.) { + theReaction = "N_Fe_nonelastic"; + } + if (RecRandnum >= ProbLimit[9] && RecRandnum < ProbLimit[10] && ProbSigma[10] > 0.) { + theReaction = "N_Al_elastic"; + } + if (RecRandnum >= ProbLimit[10] && RecRandnum < ProbLimit[11] && ProbSigma[11] > 0.) { + theReaction = "N_Al_nonelastic"; + } + } + + // G4cout << "***************Reaction Chosen was : " << theReaction << G4endl; + } + return theReaction; } //----------------------------------------------------------- // Angular Distribution generators - Added 6 May 2008 BTR //----------------------------------------------------------- -G4double menate_R::NP_AngDist(G4double NEng) -{ - //NP scattering from DEMONS by Reese, Yariv and Sailor et al. - //originally written by Stanton - //based on equation - a + 3b cos(theta) - // adjusted "30." in original routine with "29.", including - // minimum energy for "dip" to 29 MeV - BTR 7 May 2008. +G4double menate_R::NP_AngDist(G4double NEng) { + // NP scattering from DEMONS by Reese, Yariv and Sailor et al. + // originally written by Stanton + // based on equation - a + 3b cos(theta) + // adjusted "30." in original routine with "29.", including + // minimum energy for "dip" to 29 MeV - BTR 7 May 2008. G4double CosCM = 0.; - if(NEng < 29.*MeV) - { - CosCM = 2.*G4UniformRand()-1.; - return CosCM; - } + if (NEng < 29. * MeV) { + CosCM = 2. * G4UniformRand() - 1.; + return CosCM; + } - // a = 3.0/(3.0+rMax) - // b = rMax*a/3.0 - // RAT = a/(a+b) + // a = 3.0/(3.0+rMax) + // b = rMax*a/3.0 + // RAT = a/(a+b) - G4double rMax = NEng/29.-1.; - G4double RAT = 1./(1.+(rMax/3.)); + G4double rMax = NEng / 29. - 1.; + G4double RAT = 1. / (1. + (rMax / 3.)); G4double ran1, ran2, absRan2; ran1 = G4UniformRand(); - ran2 = 2.*G4UniformRand()-1.; + ran2 = 2. * G4UniformRand() - 1.; absRan2 = Absolute(ran2); - if(absRan2 < RAT) - {CosCM = 2.0*ran1-1.0;} - else - {CosCM = SIGN(pow(ran1,(1./3.)),ran2);} + if (absRan2 < RAT) { + CosCM = 2.0 * ran1 - 1.0; + } + else { + CosCM = SIGN(pow(ran1, (1. / 3.)), ran2); + } - return CosCM; + return CosCM; } -G4double menate_R::NC12_DIFF(G4double NEng) -{ +G4double menate_R::NC12_DIFF(G4double NEng) { // Generates Angular Distribution for n+12C scattering // in center of mass system. Kinematics in PostStepDoIt - // convert result to lab angle. + // convert result to lab angle. // Uses parameterization in DEMONS by Reese, Yariv and Sailor et al. // n+12C cross section is considered isotropic for NEng < 7.35 MeV. // The orignal "FitParam" was tweaked to 0.5 to provide a better fit // to the C12 diffractive peak at forward angles between 7.3 and 70 MeV. - // For NEng>70MeV, FitParam is returned to original value + // For NEng>70MeV, FitParam is returned to original value // (1.17 fits 96 MeV) with a linear increase (shown below). // Fits ang dist data up to 150 MeV. // Assume a "global" split between diffractive and non-diffractive @@ -596,7 +585,7 @@ G4double menate_R::NC12_DIFF(G4double NEng) // References for n+12C angular distributions (elastic) include : // Z.P Chen et al. - J. Phys. G: Nucl. Part. Phys. 31, 1249 (2005). - // T. Kaneko et al. - Phys. Rev. C 46, 298 (1992). + // T. Kaneko et al. - Phys. Rev. C 46, 298 (1992). // Z.M. Chen et al. - J. Phys. G: Nucl. Part. Phys. 19, 877 (1993). // J.S. Petler et al. - Phys. Rev. C 32, 673 (1985). // P. Mermod et al. - Phys. Rev. C 74, 054002 (2006). @@ -607,606 +596,549 @@ G4double menate_R::NC12_DIFF(G4double NEng) G4double CosCM = 0.; G4double DiffSigma; G4double FitParam = 0.5; - if(NEng >= 70.*MeV) - {FitParam = 0.021613*NEng-0.90484;} // Fit to AngDist Data + if (NEng >= 70. * MeV) { + FitParam = 0.021613 * NEng - 0.90484; + } // Fit to AngDist Data - if(NEng < 7.35*MeV) - { - CosCM = 1.-2.*G4UniformRand(); - return CosCM; + if (NEng < 7.35 * MeV) { + CosCM = 1. - 2. * G4UniformRand(); + return CosCM; + } + else { + G4double rand = G4UniformRand(); + if (rand > 0.9) { + CosCM = 1. - 2. * G4UniformRand(); } - else - { - G4double rand = G4UniformRand(); - if(rand > 0.9) - {CosCM = 1.-2.*G4UniformRand();} - else - { - DiffSigma = GetCrossSection(NEng,theCarbonXS)/barn; - do - { - G4double rand2 = 0.; - rand2 = G4UniformRand(); - //CosCM = 1.0+log(rand2)/1.17/DiffSigma/NEng; - CosCM = 1.0+log(rand2)/FitParam/DiffSigma/NEng; - } - while(CosCM < -1. || CosCM > 1.); - } + else { + DiffSigma = GetCrossSection(NEng, theCarbonXS) / barn; + do { + G4double rand2 = 0.; + rand2 = G4UniformRand(); + // CosCM = 1.0+log(rand2)/1.17/DiffSigma/NEng; + CosCM = 1.0 + log(rand2) / FitParam / DiffSigma / NEng; + } while (CosCM < -1. || CosCM > 1.); } + } return CosCM; } - -void menate_R::Setup_AlElastic_AngDist(){ - +void menate_R::Setup_AlElastic_AngDist() { const int num = 146; - //30MeV------- - double dist_30[num]={ - -1.000000+0, 1.143092e-2, -9.990482e-1, 1.124223e-2, -9.961947e-1, 1.069678e-2, - -9.914449e-1, 9.853178e-3, -9.848078e-1, 8.801133e-3, -9.762960e-1, 7.649630e-3, - -9.659258e-1, 6.513742e-3, -9.537170e-1, 5.500872e-3, -9.396926e-1, 4.698089e-3, - -9.238795e-1, 4.163449e-3, -9.063078e-1, 3.920835e-3, -8.870108e-1, 3.959841e-3, - -8.660254e-1, 4.239958e-3, -8.433914e-1, 4.698323e-3, -8.191520e-1, 5.259733e-3, - -7.933533e-1, 5.847400e-3, -7.660444e-1, 6.392955e-3, -7.372773e-1, 6.844546e-3, - -7.071068e-1, 7.172467e-3, -6.755902e-1, 7.371493e-3, -6.427876e-1, 7.460832e-3, - -6.087614e-1, 7.481616e-3, -5.735764e-1, 7.493423e-3, -5.372996e-1, 7.569377e-3, - -5.000000e-1, 7.791201e-3, -4.617486e-1, 8.243935e-3, -4.226183e-1, 9.009845e-3, - -3.826834e-1, 1.016157e-2, -3.420201e-1, 1.175351e-2, -3.007058e-1, 1.381233e-2, - -2.588190e-1, 1.632611e-2, -2.164396e-1, 1.923550e-2, -1.736482e-1, 2.242820e-2, - -1.305262e-1, 2.574168e-2, -8.715574e-2, 2.897774e-2, -4.361939e-2, 3.193267e-2, - 0.000000+0, 3.444537e-2, 4.361939e-2, 3.646164e-2, 8.715574e-2, 3.811006e-2, - 1.305262e-1, 3.977790e-2, 1.736482e-1, 4.217155e-2, 2.164396e-1, 4.633969e-2, - 2.588190e-1, 5.363686e-2, 3.007058e-1, 6.560642e-2, 3.420201e-1, 8.376855e-2, - 3.826834e-1, 1.093183e-1, 4.226183e-1, 1.427545e-1, 4.617486e-1, 1.834979e-1, - 5.000000e-1, 2.295749e-1, 5.372996e-1, 2.774898e-1, 5.735764e-1, 3.224090e-1, - 6.087614e-1, 3.587789e-1, 6.427876e-1, 3.814766e-1, 6.755902e-1, 3.875034e-1, - 7.071068e-1, 3.781310e-1, 7.372773e-1, 3.612692e-1, 7.660444e-1, 3.536586e-1, - 7.933533e-1, 3.823776e-1, 8.191520e-1, 4.850586e-1, 8.433914e-1, 7.082584e-1, - 8.660254e-1, 1.103586+0, 8.870108e-1, 1.721515+0, 9.063078e-1, 2.603299+0, - 9.238795e-1, 3.771875+0, 9.396926e-1, 5.223208+0, 9.537170e-1, 6.919739+0, - 9.659258e-1, 8.787858+0, 9.762960e-1, 1.072018+1, 9.848078e-1, 1.258416+1, - 9.914449e-1, 1.423525+1, 9.961947e-1, 1.553436+1, 9.990482e-1, 1.636534+1, - 1.000000+0, 1.665131+1 }; - - hAl_AngDist_30MeV = new TH1F("hAl_AngDist_30MeV","hAl_AngDist_30MeV",300, -1.1, 1.1); - for(int i=0; i<num; i++){ + // 30MeV------- + double dist_30[num] = { + -1.000000 + 0, 1.143092e-2, -9.990482e-1, 1.124223e-2, -9.961947e-1, 1.069678e-2, -9.914449e-1, 9.853178e-3, + -9.848078e-1, 8.801133e-3, -9.762960e-1, 7.649630e-3, -9.659258e-1, 6.513742e-3, -9.537170e-1, 5.500872e-3, + -9.396926e-1, 4.698089e-3, -9.238795e-1, 4.163449e-3, -9.063078e-1, 3.920835e-3, -8.870108e-1, 3.959841e-3, + -8.660254e-1, 4.239958e-3, -8.433914e-1, 4.698323e-3, -8.191520e-1, 5.259733e-3, -7.933533e-1, 5.847400e-3, + -7.660444e-1, 6.392955e-3, -7.372773e-1, 6.844546e-3, -7.071068e-1, 7.172467e-3, -6.755902e-1, 7.371493e-3, + -6.427876e-1, 7.460832e-3, -6.087614e-1, 7.481616e-3, -5.735764e-1, 7.493423e-3, -5.372996e-1, 7.569377e-3, + -5.000000e-1, 7.791201e-3, -4.617486e-1, 8.243935e-3, -4.226183e-1, 9.009845e-3, -3.826834e-1, 1.016157e-2, + -3.420201e-1, 1.175351e-2, -3.007058e-1, 1.381233e-2, -2.588190e-1, 1.632611e-2, -2.164396e-1, 1.923550e-2, + -1.736482e-1, 2.242820e-2, -1.305262e-1, 2.574168e-2, -8.715574e-2, 2.897774e-2, -4.361939e-2, 3.193267e-2, + 0.000000 + 0, 3.444537e-2, 4.361939e-2, 3.646164e-2, 8.715574e-2, 3.811006e-2, 1.305262e-1, 3.977790e-2, + 1.736482e-1, 4.217155e-2, 2.164396e-1, 4.633969e-2, 2.588190e-1, 5.363686e-2, 3.007058e-1, 6.560642e-2, + 3.420201e-1, 8.376855e-2, 3.826834e-1, 1.093183e-1, 4.226183e-1, 1.427545e-1, 4.617486e-1, 1.834979e-1, + 5.000000e-1, 2.295749e-1, 5.372996e-1, 2.774898e-1, 5.735764e-1, 3.224090e-1, 6.087614e-1, 3.587789e-1, + 6.427876e-1, 3.814766e-1, 6.755902e-1, 3.875034e-1, 7.071068e-1, 3.781310e-1, 7.372773e-1, 3.612692e-1, + 7.660444e-1, 3.536586e-1, 7.933533e-1, 3.823776e-1, 8.191520e-1, 4.850586e-1, 8.433914e-1, 7.082584e-1, + 8.660254e-1, 1.103586 + 0, 8.870108e-1, 1.721515 + 0, 9.063078e-1, 2.603299 + 0, 9.238795e-1, 3.771875 + 0, + 9.396926e-1, 5.223208 + 0, 9.537170e-1, 6.919739 + 0, 9.659258e-1, 8.787858 + 0, 9.762960e-1, 1.072018 + 1, + 9.848078e-1, 1.258416 + 1, 9.914449e-1, 1.423525 + 1, 9.961947e-1, 1.553436 + 1, 9.990482e-1, 1.636534 + 1, + 1.000000 + 0, 1.665131 + 1}; + + hAl_AngDist_30MeV = new TH1F("hAl_AngDist_30MeV", "hAl_AngDist_30MeV", 300, -1.1, 1.1); + for (int i = 0; i < num; i++) { double angle = dist_30[i]; - double prob = dist_30[i+1]; - //G4cout << i << " " << angle << " " << prob << G4endl; + double prob = dist_30[i + 1]; + // G4cout << i << " " << angle << " " << prob << G4endl; i++; double bin = hAl_AngDist_30MeV->FindBin(angle); hAl_AngDist_30MeV->SetBinContent(bin, prob); } - - //50MeV----- - double dist_50[num]={ - -1.000000+0, 6.709124e-4, -9.990482e-1, 6.603906e-4, -9.961947e-1, 6.304766e-4, - -9.914449e-1, 5.858351e-4, -9.848078e-1, 5.332814e-4, -9.762960e-1, 4.805843e-4, - -9.659258e-1, 4.350849e-4, -9.537170e-1, 4.024467e-4, -9.396926e-1, 3.857654e-4, - -9.238795e-1, 3.852123e-4, -9.063078e-1, 3.982495e-4, -8.870108e-1, 4.203689e-4, - -8.660254e-1, 4.461890e-4, -8.433914e-1, 4.707079e-4, -8.191520e-1, 4.904874e-4, - -7.933533e-1, 5.045640e-4, -7.660444e-1, 5.149420e-4, -7.372773e-1, 5.265894e-4, - -7.071068e-1, 5.469609e-4, -6.755902e-1, 5.851284e-4, -6.427876e-1, 6.506459e-4, - -6.087614e-1, 7.522636e-4, -5.735764e-1, 8.966486e-4, -5.372996e-1, 1.087158e-3, - -5.000000e-1, 1.322876e-3, -4.617486e-1, 1.598021e-3, -4.226183e-1, 1.902000e-3, - -3.826834e-1, 2.220344e-3, -3.420201e-1, 2.536745e-3, -3.007058e-1, 2.836444e-3, - -2.588190e-1, 3.110933e-3, -2.164396e-1, 3.363524e-3, -1.736482e-1, 3.614936e-3, - -1.305262e-1, 3.907434e-3, -8.715574e-2, 4.305532e-3, -4.361939e-2, 4.891377e-3, - 0.000000+0, 5.753370e-3, 4.361939e-2, 6.967889e-3, 8.715574e-2, 8.576699e-3, - 1.305262e-1, 1.056473e-2, 1.736482e-1, 1.284832e-2, 2.164396e-1, 1.528370e-2, - 2.588190e-1, 1.770778e-2, 3.007058e-1, 2.001875e-2, 3.420201e-1, 2.229245e-2, - 3.826834e-1, 2.491798e-2, 4.226183e-1, 2.871318e-2, 4.617486e-1, 3.496300e-2, - 5.000000e-1, 4.531408e-2, 5.372996e-1, 6.146544e-2, 5.735764e-1, 8.463770e-2, - 6.087614e-1, 1.148850e-1, 6.427876e-1, 1.504327e-1, 6.755902e-1, 1.873634e-1, - 7.071068e-1, 2.201177e-1, 7.372773e-1, 2.432984e-1, 7.660444e-1, 2.551966e-1, - 7.933533e-1, 2.630871e-1, 8.191520e-1, 2.897874e-1, 8.433914e-1, 3.801505e-1, - 8.660254e-1, 6.053457e-1, 8.870108e-1, 1.062217+0, 9.063078e-1, 1.865062+0, - 9.238795e-1, 3.128298+0, 9.396926e-1, 4.940641+0, 9.537170e-1, 7.334422+0, - 9.659258e-1, 1.025697+1, 9.762960e-1, 1.355285+1, 9.848078e-1, 1.696543+1, - 9.914449e-1, 2.016259+1, 9.961947e-1, 2.278521+1, 9.990482e-1, 2.450986+1, - 1.000000+0, 2.511166+1 }; - - hAl_AngDist_50MeV = new TH1F("hAl_AngDist_50MeV","hAl_AngDist_50MeV",300, -1.1, 1.1); - for(int i=0; i<num; i++){ + // 50MeV----- + double dist_50[num] = { + -1.000000 + 0, 6.709124e-4, -9.990482e-1, 6.603906e-4, -9.961947e-1, 6.304766e-4, -9.914449e-1, 5.858351e-4, + -9.848078e-1, 5.332814e-4, -9.762960e-1, 4.805843e-4, -9.659258e-1, 4.350849e-4, -9.537170e-1, 4.024467e-4, + -9.396926e-1, 3.857654e-4, -9.238795e-1, 3.852123e-4, -9.063078e-1, 3.982495e-4, -8.870108e-1, 4.203689e-4, + -8.660254e-1, 4.461890e-4, -8.433914e-1, 4.707079e-4, -8.191520e-1, 4.904874e-4, -7.933533e-1, 5.045640e-4, + -7.660444e-1, 5.149420e-4, -7.372773e-1, 5.265894e-4, -7.071068e-1, 5.469609e-4, -6.755902e-1, 5.851284e-4, + -6.427876e-1, 6.506459e-4, -6.087614e-1, 7.522636e-4, -5.735764e-1, 8.966486e-4, -5.372996e-1, 1.087158e-3, + -5.000000e-1, 1.322876e-3, -4.617486e-1, 1.598021e-3, -4.226183e-1, 1.902000e-3, -3.826834e-1, 2.220344e-3, + -3.420201e-1, 2.536745e-3, -3.007058e-1, 2.836444e-3, -2.588190e-1, 3.110933e-3, -2.164396e-1, 3.363524e-3, + -1.736482e-1, 3.614936e-3, -1.305262e-1, 3.907434e-3, -8.715574e-2, 4.305532e-3, -4.361939e-2, 4.891377e-3, + 0.000000 + 0, 5.753370e-3, 4.361939e-2, 6.967889e-3, 8.715574e-2, 8.576699e-3, 1.305262e-1, 1.056473e-2, + 1.736482e-1, 1.284832e-2, 2.164396e-1, 1.528370e-2, 2.588190e-1, 1.770778e-2, 3.007058e-1, 2.001875e-2, + 3.420201e-1, 2.229245e-2, 3.826834e-1, 2.491798e-2, 4.226183e-1, 2.871318e-2, 4.617486e-1, 3.496300e-2, + 5.000000e-1, 4.531408e-2, 5.372996e-1, 6.146544e-2, 5.735764e-1, 8.463770e-2, 6.087614e-1, 1.148850e-1, + 6.427876e-1, 1.504327e-1, 6.755902e-1, 1.873634e-1, 7.071068e-1, 2.201177e-1, 7.372773e-1, 2.432984e-1, + 7.660444e-1, 2.551966e-1, 7.933533e-1, 2.630871e-1, 8.191520e-1, 2.897874e-1, 8.433914e-1, 3.801505e-1, + 8.660254e-1, 6.053457e-1, 8.870108e-1, 1.062217 + 0, 9.063078e-1, 1.865062 + 0, 9.238795e-1, 3.128298 + 0, + 9.396926e-1, 4.940641 + 0, 9.537170e-1, 7.334422 + 0, 9.659258e-1, 1.025697 + 1, 9.762960e-1, 1.355285 + 1, + 9.848078e-1, 1.696543 + 1, 9.914449e-1, 2.016259 + 1, 9.961947e-1, 2.278521 + 1, 9.990482e-1, 2.450986 + 1, + 1.000000 + 0, 2.511166 + 1}; + + hAl_AngDist_50MeV = new TH1F("hAl_AngDist_50MeV", "hAl_AngDist_50MeV", 300, -1.1, 1.1); + for (int i = 0; i < num; i++) { double angle = dist_50[i]; - double prob = dist_50[i+1]; - //G4cout << i << " " << angle << " " << prob << G4endl; + double prob = dist_50[i + 1]; + // G4cout << i << " " << angle << " " << prob << G4endl; i++; double bin = hAl_AngDist_50MeV->FindBin(angle); hAl_AngDist_50MeV->SetBinContent(bin, prob); } - - //70MeV----- - double dist_70[num]={ - -1.000000+0, 3.282137e-6, -9.990482e-1, 3.320258e-6, -9.961947e-1, 3.435988e-6, - -9.914449e-1, 3.627566e-6, -9.848078e-1, 3.879130e-6, -9.762960e-1, 4.156161e-6, - -9.659258e-1, 4.410307e-6, -9.537170e-1, 4.586605e-6, -9.396926e-1, 4.627784e-6, - -9.238795e-1, 4.480618e-6, -9.063078e-1, 4.114588e-6, -8.870108e-1, 3.553527e-6, - -8.660254e-1, 2.905423e-6, -8.433914e-1, 2.372443e-6, -8.191520e-1, 2.238375e-6, - -7.933533e-1, 2.843672e-6, -7.660444e-1, 4.551534e-6, -7.372773e-1, 7.691386e-6, - -7.071068e-1, 1.246622e-5, -6.755902e-1, 1.883831e-5, -6.427876e-1, 2.643986e-5, - -6.087614e-1, 3.455596e-5, -5.735764e-1, 4.220604e-5, -5.372996e-1, 4.833323e-5, - -5.000000e-1, 5.212627e-5, -4.617486e-1, 5.349607e-5, -4.226183e-1, 5.366340e-5, - -3.826834e-1, 5.568937e-5, -3.420201e-1, 6.468955e-5, -3.007058e-1, 8.747101e-5, - -2.588190e-1, 1.314276e-4, -2.164396e-1, 2.026794e-4, -1.736482e-1, 3.036667e-4, - -1.305262e-1, 4.308042e-4, -8.715574e-2, 5.733049e-4, -4.361939e-2, 7.146489e-4, - 0.000000+0, 8.379677e-4, 4.361939e-2, 9.356725e-4, 8.715574e-2, 1.021972e-3, - 1.305262e-1, 1.144510e-3, 1.736482e-1, 1.389505e-3, 2.164396e-1, 1.873184e-3, - 2.588190e-1, 2.714392e-3, 3.007058e-1, 3.989167e-3, 3.420201e-1, 5.679383e-3, - 3.826834e-1, 7.640669e-3, 4.226183e-1, 9.625927e-3, 4.617486e-1, 1.139963e-2, - 5.000000e-1, 1.295828e-2, 5.372996e-1, 1.482605e-2, 5.735764e-1, 1.832085e-2, - 6.087614e-1, 2.561511e-2, 6.427876e-1, 3.937859e-2, 6.755902e-1, 6.185808e-2, - 7.071068e-1, 9.347093e-2, 7.372773e-1, 1.313941e-1, 7.660444e-1, 1.691515e-1, - 7.933533e-1, 1.987067e-1, 8.191520e-1, 2.166963e-1, 8.433914e-1, 2.358658e-1, - 8.660254e-1, 3.010805e-1, 8.870108e-1, 5.064869e-1, 9.063078e-1, 1.006997+0, - 9.238795e-1, 2.014608+0, 9.396926e-1, 3.770019+0, 9.537170e-1, 6.484900+0, - 9.659258e-1, 1.026029+1, 9.762960e-1, 1.500126+1, 9.848078e-1, 2.035945+1, - 9.914449e-1, 2.573888+1, 9.961947e-1, 3.038484+1, 9.990482e-1, 3.354666+1, - 1.000000+0, 3.466892+1 }; - - hAl_AngDist_70MeV = new TH1F("hAl_AngDist_70MeV","hAl_AngDist_70MeV",300, -1.1, 1.1); - for(int i=0; i<num; i++){ + // 70MeV----- + double dist_70[num] = { + -1.000000 + 0, 3.282137e-6, -9.990482e-1, 3.320258e-6, -9.961947e-1, 3.435988e-6, -9.914449e-1, 3.627566e-6, + -9.848078e-1, 3.879130e-6, -9.762960e-1, 4.156161e-6, -9.659258e-1, 4.410307e-6, -9.537170e-1, 4.586605e-6, + -9.396926e-1, 4.627784e-6, -9.238795e-1, 4.480618e-6, -9.063078e-1, 4.114588e-6, -8.870108e-1, 3.553527e-6, + -8.660254e-1, 2.905423e-6, -8.433914e-1, 2.372443e-6, -8.191520e-1, 2.238375e-6, -7.933533e-1, 2.843672e-6, + -7.660444e-1, 4.551534e-6, -7.372773e-1, 7.691386e-6, -7.071068e-1, 1.246622e-5, -6.755902e-1, 1.883831e-5, + -6.427876e-1, 2.643986e-5, -6.087614e-1, 3.455596e-5, -5.735764e-1, 4.220604e-5, -5.372996e-1, 4.833323e-5, + -5.000000e-1, 5.212627e-5, -4.617486e-1, 5.349607e-5, -4.226183e-1, 5.366340e-5, -3.826834e-1, 5.568937e-5, + -3.420201e-1, 6.468955e-5, -3.007058e-1, 8.747101e-5, -2.588190e-1, 1.314276e-4, -2.164396e-1, 2.026794e-4, + -1.736482e-1, 3.036667e-4, -1.305262e-1, 4.308042e-4, -8.715574e-2, 5.733049e-4, -4.361939e-2, 7.146489e-4, + 0.000000 + 0, 8.379677e-4, 4.361939e-2, 9.356725e-4, 8.715574e-2, 1.021972e-3, 1.305262e-1, 1.144510e-3, + 1.736482e-1, 1.389505e-3, 2.164396e-1, 1.873184e-3, 2.588190e-1, 2.714392e-3, 3.007058e-1, 3.989167e-3, + 3.420201e-1, 5.679383e-3, 3.826834e-1, 7.640669e-3, 4.226183e-1, 9.625927e-3, 4.617486e-1, 1.139963e-2, + 5.000000e-1, 1.295828e-2, 5.372996e-1, 1.482605e-2, 5.735764e-1, 1.832085e-2, 6.087614e-1, 2.561511e-2, + 6.427876e-1, 3.937859e-2, 6.755902e-1, 6.185808e-2, 7.071068e-1, 9.347093e-2, 7.372773e-1, 1.313941e-1, + 7.660444e-1, 1.691515e-1, 7.933533e-1, 1.987067e-1, 8.191520e-1, 2.166963e-1, 8.433914e-1, 2.358658e-1, + 8.660254e-1, 3.010805e-1, 8.870108e-1, 5.064869e-1, 9.063078e-1, 1.006997 + 0, 9.238795e-1, 2.014608 + 0, + 9.396926e-1, 3.770019 + 0, 9.537170e-1, 6.484900 + 0, 9.659258e-1, 1.026029 + 1, 9.762960e-1, 1.500126 + 1, + 9.848078e-1, 2.035945 + 1, 9.914449e-1, 2.573888 + 1, 9.961947e-1, 3.038484 + 1, 9.990482e-1, 3.354666 + 1, + 1.000000 + 0, 3.466892 + 1}; + + hAl_AngDist_70MeV = new TH1F("hAl_AngDist_70MeV", "hAl_AngDist_70MeV", 300, -1.1, 1.1); + for (int i = 0; i < num; i++) { double angle = dist_70[i]; - double prob = dist_70[i+1]; - //G4cout << i << " " << angle << " " << prob << G4endl; + double prob = dist_70[i + 1]; + // G4cout << i << " " << angle << " " << prob << G4endl; i++; double bin = hAl_AngDist_70MeV->FindBin(angle); hAl_AngDist_70MeV->SetBinContent(bin, prob); } - - - } -void menate_R::Setup_FeElastic_AngDist(){ +void menate_R::Setup_FeElastic_AngDist() { const int num = 146; - //30MeV------- - double dist_30[num]={ - -1.000000e+0, 6.864330e-2, -9.990482e-1, 6.799924e-2, -9.961947e-1, 6.606658e-2, - -9.914449e-1, 6.285744e-2, -9.848078e-1, 5.841792e-2, -9.762960e-1, 5.286584e-2, - -9.659258e-1, 4.642469e-2, -9.537170e-1, 3.944496e-2, -9.396926e-1, 3.240171e-2, - -9.238795e-1, 2.585606e-2, -9.063078e-1, 2.038231e-2, -8.870108e-1, 1.646921e-2, - -8.660254e-1, 1.441510e-2, -8.433914e-1, 1.424461e-2, -8.191520e-1, 1.567324e-2, - -7.933533e-1, 1.813968e-2, -7.660444e-1, 2.090887e-2, -7.372773e-1, 2.322993e-2, - -7.071068e-1, 2.451358e-2, -6.755902e-1, 2.448392e-2, -6.427876e-1, 2.326010e-2, - -6.087614e-1, 2.133853e-2, -5.735764e-1, 1.947210e-2, -5.372996e-1, 1.847261e-2, - -5.000000e-1, 1.898707e-2, -4.617486e-1, 2.130970e-2, -4.226183e-1, 2.528576e-2, - -3.826834e-1, 3.033819e-2, -3.420201e-1, 3.561518e-2, -3.007058e-1, 4.022124e-2, - -2.588190e-1, 4.346884e-2, -2.164396e-1, 4.508347e-2, -1.736482e-1, 4.530519e-2, - -1.305262e-1, 4.486399e-2, -8.715574e-2, 4.483712e-2, -4.361939e-2, 4.643046e-2, - 0.000000e+0, 5.073712e-2, 4.361939e-2, 5.852223e-2, 8.715574e-2, 7.006881e-2, - 1.305262e-1, 8.508392e-2, 1.736482e-1, 1.026739e-1, 2.164396e-1, 1.213783e-1, - 2.588190e-1, 1.392980e-1, 3.007058e-1, 1.543629e-1, 3.420201e-1, 1.647997e-1, - 3.826834e-1, 1.698153e-1, 4.226183e-1, 1.704198e-1, 4.617486e-1, 1.701846e-1, - 5.000000e-1, 1.755779e-1, 5.372996e-1, 1.954684e-1, 5.735764e-1, 2.394566e-1, - 6.087614e-1, 3.149690e-1, 6.427876e-1, 4.235233e-1, 6.755902e-1, 5.571453e-1, - 7.071068e-1, 6.964176e-1, 7.372773e-1, 8.118647e-1, 7.660444e-1, 8.699422e-1, - 7.933533e-1, 8.440213e-1, 8.191520e-1, 7.290353e-1, 8.433914e-1, 5.566144e-1, - 8.660254e-1, 4.061517e-1, 8.870108e-1, 4.064349e-1, 9.063078e-1, 7.237915e-1, - 9.238795e-1, 1.535223e+0, 9.396926e-1, 2.989307e+0, 9.537170e-1, 5.162009e+0, - 9.659258e-1, 8.018149e+0, 9.762960e-1, 1.139005e+1, 9.848078e-1, 1.498265e+1, - 9.914449e-1, 1.840853e+1, 9.961947e-1, 2.124884e+1, 9.990482e-1, 2.312784e+1, - 1.000000e+0, 2.378523e+1}; - - hFe_AngDist_30MeV = new TH1F("hFe_AngDist_30MeV","hFe_AngDist_30MeV",300, -1.1, 1.1); - for(int i=0; i<num; i++){ + // 30MeV------- + double dist_30[num] = { + -1.000000e+0, 6.864330e-2, -9.990482e-1, 6.799924e-2, -9.961947e-1, 6.606658e-2, -9.914449e-1, 6.285744e-2, + -9.848078e-1, 5.841792e-2, -9.762960e-1, 5.286584e-2, -9.659258e-1, 4.642469e-2, -9.537170e-1, 3.944496e-2, + -9.396926e-1, 3.240171e-2, -9.238795e-1, 2.585606e-2, -9.063078e-1, 2.038231e-2, -8.870108e-1, 1.646921e-2, + -8.660254e-1, 1.441510e-2, -8.433914e-1, 1.424461e-2, -8.191520e-1, 1.567324e-2, -7.933533e-1, 1.813968e-2, + -7.660444e-1, 2.090887e-2, -7.372773e-1, 2.322993e-2, -7.071068e-1, 2.451358e-2, -6.755902e-1, 2.448392e-2, + -6.427876e-1, 2.326010e-2, -6.087614e-1, 2.133853e-2, -5.735764e-1, 1.947210e-2, -5.372996e-1, 1.847261e-2, + -5.000000e-1, 1.898707e-2, -4.617486e-1, 2.130970e-2, -4.226183e-1, 2.528576e-2, -3.826834e-1, 3.033819e-2, + -3.420201e-1, 3.561518e-2, -3.007058e-1, 4.022124e-2, -2.588190e-1, 4.346884e-2, -2.164396e-1, 4.508347e-2, + -1.736482e-1, 4.530519e-2, -1.305262e-1, 4.486399e-2, -8.715574e-2, 4.483712e-2, -4.361939e-2, 4.643046e-2, + 0.000000e+0, 5.073712e-2, 4.361939e-2, 5.852223e-2, 8.715574e-2, 7.006881e-2, 1.305262e-1, 8.508392e-2, + 1.736482e-1, 1.026739e-1, 2.164396e-1, 1.213783e-1, 2.588190e-1, 1.392980e-1, 3.007058e-1, 1.543629e-1, + 3.420201e-1, 1.647997e-1, 3.826834e-1, 1.698153e-1, 4.226183e-1, 1.704198e-1, 4.617486e-1, 1.701846e-1, + 5.000000e-1, 1.755779e-1, 5.372996e-1, 1.954684e-1, 5.735764e-1, 2.394566e-1, 6.087614e-1, 3.149690e-1, + 6.427876e-1, 4.235233e-1, 6.755902e-1, 5.571453e-1, 7.071068e-1, 6.964176e-1, 7.372773e-1, 8.118647e-1, + 7.660444e-1, 8.699422e-1, 7.933533e-1, 8.440213e-1, 8.191520e-1, 7.290353e-1, 8.433914e-1, 5.566144e-1, + 8.660254e-1, 4.061517e-1, 8.870108e-1, 4.064349e-1, 9.063078e-1, 7.237915e-1, 9.238795e-1, 1.535223e+0, + 9.396926e-1, 2.989307e+0, 9.537170e-1, 5.162009e+0, 9.659258e-1, 8.018149e+0, 9.762960e-1, 1.139005e+1, + 9.848078e-1, 1.498265e+1, 9.914449e-1, 1.840853e+1, 9.961947e-1, 2.124884e+1, 9.990482e-1, 2.312784e+1, + 1.000000e+0, 2.378523e+1}; + + hFe_AngDist_30MeV = new TH1F("hFe_AngDist_30MeV", "hFe_AngDist_30MeV", 300, -1.1, 1.1); + for (int i = 0; i < num; i++) { double angle = dist_30[i]; - double prob = dist_30[i+1]; - //G4cout << i << " " << angle << " " << prob << G4endl; + double prob = dist_30[i + 1]; + // G4cout << i << " " << angle << " " << prob << G4endl; i++; double bin = hFe_AngDist_30MeV->FindBin(angle); hFe_AngDist_30MeV->SetBinContent(bin, prob); } - - //50MeV----- - double dist_50[num]={ - -1.000000e+0, 3.691942e-3, -9.990482e-1, 3.578426e-3, -9.961947e-1, 3.262122e-3, - -9.914449e-1, 2.808433e-3, -9.848078e-1, 2.304621e-3, -9.762960e-1, 1.835324e-3, - -9.659258e-1, 1.461301e-3, -9.537170e-1, 1.208336e-3, -9.396926e-1, 1.068867e-3, - -9.238795e-1, 1.014110e-3, -9.063078e-1, 1.010602e-3, -8.870108e-1, 1.034141e-3, - -8.660254e-1, 1.076051e-3, -8.433914e-1, 1.140557e-3, -8.191520e-1, 1.236001e-3, - -7.933533e-1, 1.364980e-3, -7.660444e-1, 1.518547e-3, -7.372773e-1, 1.677278e-3, - -7.071068e-1, 1.818750e-3, -6.755902e-1, 1.928005e-3, -6.427876e-1, 2.006146e-3, - -6.087614e-1, 2.073045e-3, -5.735764e-1, 2.162751e-3, -5.372996e-1, 2.313195e-3, - -5.000000e-1, 2.554042e-3, -4.617486e-1, 2.896975e-3, -4.226183e-1, 3.331733e-3, - -3.826834e-1, 3.829010e-3, -3.420201e-1, 4.349491e-3, -3.007058e-1, 4.856640e-3, - -2.588190e-1, 5.330337e-3, -2.164396e-1, 5.777631e-3, -1.736482e-1, 6.238028e-3, - -1.305262e-1, 6.779185e-3, -8.715574e-2, 7.482344e-3, -4.361939e-2, 8.417194e-3, - 0.000000e+0, 9.613124e-3, 4.361939e-2, 1.103728e-2, 8.715574e-2, 1.259760e-2, - 1.305262e-1, 1.418379e-2, 1.736482e-1, 1.574889e-2, 2.164396e-1, 1.740999e-2, - 2.588190e-1, 1.951995e-2, 3.007058e-1, 2.264527e-2, 3.420201e-1, 2.739634e-2, - 3.826834e-1, 3.411133e-2, 4.226183e-1, 4.249017e-2, 4.617486e-1, 5.138349e-2, - 5.000000e-1, 5.900207e-2, 5.372996e-1, 6.375657e-2, 5.735764e-1, 6.569038e-2, - 6.087614e-1, 6.807300e-2, 6.427876e-1, 7.826655e-2, 6.755902e-1, 1.067589e-1, - 7.071068e-1, 1.635344e-1, 7.372773e-1, 2.520196e-1, 7.660444e-1, 3.625788e-1, - 7.933533e-1, 4.694480e-1, 8.191520e-1, 5.360762e-1, 8.433914e-1, 5.328226e-1, - 8.660254e-1, 4.670148e-1, 8.870108e-1, 4.188167e-1, 9.063078e-1, 5.690737e-1, - 9.238795e-1, 1.200984e+0, 9.396926e-1, 2.659844e+0, 9.537170e-1, 5.266500e+0, - 9.659258e-1, 9.198724e+0, 9.762960e-1, 1.437487e+1, 9.848078e-1, 2.038495e+1, - 9.914449e-1, 2.650916e+1, 9.961947e-1, 3.183898e+1, 9.990482e-1, 3.547902e+1, - 1.000000e+0, 3.677275e+1}; - - hFe_AngDist_50MeV = new TH1F("hFe_AngDist_50MeV","hFe_AngDist_50MeV",300, -1.1, 1.1); - for(int i=0; i<num; i++){ + // 50MeV----- + double dist_50[num] = { + -1.000000e+0, 3.691942e-3, -9.990482e-1, 3.578426e-3, -9.961947e-1, 3.262122e-3, -9.914449e-1, 2.808433e-3, + -9.848078e-1, 2.304621e-3, -9.762960e-1, 1.835324e-3, -9.659258e-1, 1.461301e-3, -9.537170e-1, 1.208336e-3, + -9.396926e-1, 1.068867e-3, -9.238795e-1, 1.014110e-3, -9.063078e-1, 1.010602e-3, -8.870108e-1, 1.034141e-3, + -8.660254e-1, 1.076051e-3, -8.433914e-1, 1.140557e-3, -8.191520e-1, 1.236001e-3, -7.933533e-1, 1.364980e-3, + -7.660444e-1, 1.518547e-3, -7.372773e-1, 1.677278e-3, -7.071068e-1, 1.818750e-3, -6.755902e-1, 1.928005e-3, + -6.427876e-1, 2.006146e-3, -6.087614e-1, 2.073045e-3, -5.735764e-1, 2.162751e-3, -5.372996e-1, 2.313195e-3, + -5.000000e-1, 2.554042e-3, -4.617486e-1, 2.896975e-3, -4.226183e-1, 3.331733e-3, -3.826834e-1, 3.829010e-3, + -3.420201e-1, 4.349491e-3, -3.007058e-1, 4.856640e-3, -2.588190e-1, 5.330337e-3, -2.164396e-1, 5.777631e-3, + -1.736482e-1, 6.238028e-3, -1.305262e-1, 6.779185e-3, -8.715574e-2, 7.482344e-3, -4.361939e-2, 8.417194e-3, + 0.000000e+0, 9.613124e-3, 4.361939e-2, 1.103728e-2, 8.715574e-2, 1.259760e-2, 1.305262e-1, 1.418379e-2, + 1.736482e-1, 1.574889e-2, 2.164396e-1, 1.740999e-2, 2.588190e-1, 1.951995e-2, 3.007058e-1, 2.264527e-2, + 3.420201e-1, 2.739634e-2, 3.826834e-1, 3.411133e-2, 4.226183e-1, 4.249017e-2, 4.617486e-1, 5.138349e-2, + 5.000000e-1, 5.900207e-2, 5.372996e-1, 6.375657e-2, 5.735764e-1, 6.569038e-2, 6.087614e-1, 6.807300e-2, + 6.427876e-1, 7.826655e-2, 6.755902e-1, 1.067589e-1, 7.071068e-1, 1.635344e-1, 7.372773e-1, 2.520196e-1, + 7.660444e-1, 3.625788e-1, 7.933533e-1, 4.694480e-1, 8.191520e-1, 5.360762e-1, 8.433914e-1, 5.328226e-1, + 8.660254e-1, 4.670148e-1, 8.870108e-1, 4.188167e-1, 9.063078e-1, 5.690737e-1, 9.238795e-1, 1.200984e+0, + 9.396926e-1, 2.659844e+0, 9.537170e-1, 5.266500e+0, 9.659258e-1, 9.198724e+0, 9.762960e-1, 1.437487e+1, + 9.848078e-1, 2.038495e+1, 9.914449e-1, 2.650916e+1, 9.961947e-1, 3.183898e+1, 9.990482e-1, 3.547902e+1, + 1.000000e+0, 3.677275e+1}; + + hFe_AngDist_50MeV = new TH1F("hFe_AngDist_50MeV", "hFe_AngDist_50MeV", 300, -1.1, 1.1); + for (int i = 0; i < num; i++) { double angle = dist_50[i]; - double prob = dist_50[i+1]; - //G4cout << i << " " << angle << " " << prob << G4endl; + double prob = dist_50[i + 1]; + // G4cout << i << " " << angle << " " << prob << G4endl; i++; double bin = hFe_AngDist_50MeV->FindBin(angle); hFe_AngDist_50MeV->SetBinContent(bin, prob); } - - //70MeV----- - double dist_70[num]={ - -1.000000e+0, 1.983425e-6, -9.990482e-1, 1.965798e-6, -9.961947e-1, 1.905855e-6, - -9.914449e-1, 1.789217e-6, -9.848078e-1, 1.608414e-6, -9.762960e-1, 1.374194e-6, - -9.659258e-1, 1.121800e-6, -9.537170e-1, 9.156061e-7, -9.396926e-1, 8.487982e-7, - -9.238795e-1, 1.028369e-6, -9.063078e-1, 1.543452e-6, -8.870108e-1, 2.426820e-6, - -8.660254e-1, 3.620830e-6, -8.433914e-1, 4.955293e-6, -8.191520e-1, 6.152640e-6, - -7.933533e-1, 6.884876e-6, -7.660444e-1, 6.894530e-6, -7.372773e-1, 6.152684e-6, - -7.071068e-1, 5.003299e-6, -6.755902e-1, 4.240556e-6, -6.427876e-1, 5.065765e-6, - -6.087614e-1, 8.855034e-6, -5.735764e-1, 1.670012e-5, -5.372996e-1, 2.880136e-5, - -5.000000e-1, 4.395150e-5, -4.617486e-1, 5.943709e-5, -4.226183e-1, 7.165837e-5, - -3.826834e-1, 7.762420e-5, -3.420201e-1, 7.715392e-5, -3.007058e-1, 7.507574e-5, - -2.588190e-1, 8.212670e-5, -2.164396e-1, 1.131184e-4, -1.736482e-1, 1.816766e-4, - -1.305262e-1, 2.925482e-4, -8.715574e-2, 4.346801e-4, -4.361939e-2, 5.800715e-4, - 0.000000e+0, 6.933060e-4, 4.361939e-2, 7.530309e-4, 8.715574e-2, 7.790938e-4, - 1.305262e-1, 8.502975e-4, 1.736482e-1, 1.093673e-3, 2.164396e-1, 1.633476e-3, - 2.588190e-1, 2.510481e-3, 3.007058e-1, 3.613760e-3, 3.420201e-1, 4.690171e-3, - 3.826834e-1, 5.484783e-3, 4.226183e-1, 5.996965e-3, 4.617486e-1, 6.725686e-3, - 5.000000e-1, 8.681963e-3, 5.372996e-1, 1.297100e-2, 5.735764e-1, 1.997476e-2, - 6.087614e-1, 2.857775e-2, 6.427876e-1, 3.626075e-2, 6.755902e-1, 4.084107e-2, - 7.071068e-1, 4.379671e-2, 7.372773e-1, 5.349841e-2, 7.660444e-1, 8.508892e-2, - 7.933533e-1, 1.537562e-1, 8.191520e-1, 2.613914e-1, 8.433914e-1, 3.833791e-1, - 8.660254e-1, 4.699469e-1, 8.870108e-1, 4.791521e-1, 9.063078e-1, 4.493164e-1, - 9.238795e-1, 5.943887e-1, 9.396926e-1, 1.373549e+0, 9.537170e-1, 3.465226e+0, - 9.659258e-1, 7.589794e+0, 9.762960e-1, 1.418895e+1, 9.848078e-1, 2.306574e+1, - 9.914449e-1, 3.316772e+1, 9.961947e-1, 4.268799e+1, 9.990482e-1, 4.953558e+1, - 1.000000e+0, 5.203243e+1 }; - - hFe_AngDist_70MeV = new TH1F("hFe_AngDist_70MeV","hFe_AngDist_70MeV",300, -1.1, 1.1); - for(int i=0; i<num; i++){ + // 70MeV----- + double dist_70[num] = { + -1.000000e+0, 1.983425e-6, -9.990482e-1, 1.965798e-6, -9.961947e-1, 1.905855e-6, -9.914449e-1, 1.789217e-6, + -9.848078e-1, 1.608414e-6, -9.762960e-1, 1.374194e-6, -9.659258e-1, 1.121800e-6, -9.537170e-1, 9.156061e-7, + -9.396926e-1, 8.487982e-7, -9.238795e-1, 1.028369e-6, -9.063078e-1, 1.543452e-6, -8.870108e-1, 2.426820e-6, + -8.660254e-1, 3.620830e-6, -8.433914e-1, 4.955293e-6, -8.191520e-1, 6.152640e-6, -7.933533e-1, 6.884876e-6, + -7.660444e-1, 6.894530e-6, -7.372773e-1, 6.152684e-6, -7.071068e-1, 5.003299e-6, -6.755902e-1, 4.240556e-6, + -6.427876e-1, 5.065765e-6, -6.087614e-1, 8.855034e-6, -5.735764e-1, 1.670012e-5, -5.372996e-1, 2.880136e-5, + -5.000000e-1, 4.395150e-5, -4.617486e-1, 5.943709e-5, -4.226183e-1, 7.165837e-5, -3.826834e-1, 7.762420e-5, + -3.420201e-1, 7.715392e-5, -3.007058e-1, 7.507574e-5, -2.588190e-1, 8.212670e-5, -2.164396e-1, 1.131184e-4, + -1.736482e-1, 1.816766e-4, -1.305262e-1, 2.925482e-4, -8.715574e-2, 4.346801e-4, -4.361939e-2, 5.800715e-4, + 0.000000e+0, 6.933060e-4, 4.361939e-2, 7.530309e-4, 8.715574e-2, 7.790938e-4, 1.305262e-1, 8.502975e-4, + 1.736482e-1, 1.093673e-3, 2.164396e-1, 1.633476e-3, 2.588190e-1, 2.510481e-3, 3.007058e-1, 3.613760e-3, + 3.420201e-1, 4.690171e-3, 3.826834e-1, 5.484783e-3, 4.226183e-1, 5.996965e-3, 4.617486e-1, 6.725686e-3, + 5.000000e-1, 8.681963e-3, 5.372996e-1, 1.297100e-2, 5.735764e-1, 1.997476e-2, 6.087614e-1, 2.857775e-2, + 6.427876e-1, 3.626075e-2, 6.755902e-1, 4.084107e-2, 7.071068e-1, 4.379671e-2, 7.372773e-1, 5.349841e-2, + 7.660444e-1, 8.508892e-2, 7.933533e-1, 1.537562e-1, 8.191520e-1, 2.613914e-1, 8.433914e-1, 3.833791e-1, + 8.660254e-1, 4.699469e-1, 8.870108e-1, 4.791521e-1, 9.063078e-1, 4.493164e-1, 9.238795e-1, 5.943887e-1, + 9.396926e-1, 1.373549e+0, 9.537170e-1, 3.465226e+0, 9.659258e-1, 7.589794e+0, 9.762960e-1, 1.418895e+1, + 9.848078e-1, 2.306574e+1, 9.914449e-1, 3.316772e+1, 9.961947e-1, 4.268799e+1, 9.990482e-1, 4.953558e+1, + 1.000000e+0, 5.203243e+1}; + + hFe_AngDist_70MeV = new TH1F("hFe_AngDist_70MeV", "hFe_AngDist_70MeV", 300, -1.1, 1.1); + for (int i = 0; i < num; i++) { double angle = dist_70[i]; - double prob = dist_70[i+1]; - //G4cout << i << " " << angle << " " << prob << G4endl; + double prob = dist_70[i + 1]; + // G4cout << i << " " << angle << " " << prob << G4endl; i++; double bin = hFe_AngDist_70MeV->FindBin(angle); hFe_AngDist_70MeV->SetBinContent(bin, prob); } - //+++ --- } - -G4double menate_R:: AlElastic_AngDist(G4double NEng){ +G4double menate_R::AlElastic_AngDist(G4double NEng) { double ang_CM = 0; - if(NEng<=15*MeV) ang_CM = G4UniformRand(); - else if(NEng<=40*MeV ) ang_CM = hAl_AngDist_30MeV->GetRandom(); - else if(NEng<=60*MeV ) ang_CM = hAl_AngDist_50MeV->GetRandom(); - else if(NEng>60*MeV ) ang_CM = hAl_AngDist_70MeV->GetRandom(); + if (NEng <= 15 * MeV) + ang_CM = G4UniformRand(); + else if (NEng <= 40 * MeV) + ang_CM = hAl_AngDist_30MeV->GetRandom(); + else if (NEng <= 60 * MeV) + ang_CM = hAl_AngDist_50MeV->GetRandom(); + else if (NEng > 60 * MeV) + ang_CM = hAl_AngDist_70MeV->GetRandom(); return ang_CM; } -G4double menate_R:: FeElastic_AngDist(G4double NEng){ +G4double menate_R::FeElastic_AngDist(G4double NEng) { double ang_CM = 0; - if(NEng<=15*MeV) ang_CM = G4UniformRand(); - else if(NEng<=40*MeV ) ang_CM = hFe_AngDist_30MeV->GetRandom(); - else if(NEng<=60*MeV ) ang_CM = hFe_AngDist_50MeV->GetRandom(); - else if(NEng>60*MeV ) ang_CM = hFe_AngDist_70MeV->GetRandom(); + if (NEng <= 15 * MeV) + ang_CM = G4UniformRand(); + else if (NEng <= 40 * MeV) + ang_CM = hFe_AngDist_30MeV->GetRandom(); + else if (NEng <= 60 * MeV) + ang_CM = hFe_AngDist_50MeV->GetRandom(); + else if (NEng > 60 * MeV) + ang_CM = hFe_AngDist_70MeV->GetRandom(); return ang_CM; } -//e-e-e-e-e------------------------------------------------------------------ +// e-e-e-e-e------------------------------------------------------------------ //---------------------------------------------------------------------- -// The Below are the GEANT4:: G4VDiscreteProcess class methods that must -// be overridden to run this process in G4. +// The Below are the GEANT4:: G4VDiscreteProcess class methods that must +// be overridden to run this process in G4. //---------------------------------------------------------------------- //---------------------------------------------------------------------- - -G4bool menate_R::IsApplicable(const G4ParticleDefinition& particle) -{ -// returns "true" if this model can be applied to the particle-type - //G4cout << "IsApplicable loaded!" << G4endl; +G4bool menate_R::IsApplicable(const G4ParticleDefinition& particle) { + // returns "true" if this model can be applied to the particle-type + // G4cout << "IsApplicable loaded!" << G4endl; - if (particle == *( G4Neutron::Neutron() )) - { - //G4cout << "Found the Neutron ! " << G4endl; - return true; - } - else - { enum G4ExceptionSeverity severity; - severity = JustWarning; - G4Exception("Model \"menate_R\" can only be used for neutron scattering!","",severity,"");} + if (particle == *(G4Neutron::Neutron())) { + // G4cout << "Found the Neutron ! " << G4endl; + return true; + } + else { + enum G4ExceptionSeverity severity; + severity = JustWarning; + G4Exception("Model \"menate_R\" can only be used for neutron scattering!", "", severity, ""); + } return false; } +G4double menate_R::GetMeanFreePath(const G4Track& aTrack, G4double, // previousStepSize, + G4ForceCondition* condition) { + // G4cout << "menate_R GetMeanFreePath called!" << G4endl; -G4double menate_R::GetMeanFreePath(const G4Track& aTrack, G4double, // previousStepSize, - G4ForceCondition* condition) -{ - //G4cout << "menate_R GetMeanFreePath called!" << G4endl; - const G4Step* theStep = aTrack.GetStep(); G4StepPoint* thePoint = theStep->GetPreStepPoint(); - G4String theVolume = thePoint->GetPhysicalVolume()->GetName(); - + G4String theVolume = thePoint->GetPhysicalVolume()->GetName(); + /* - if(theVolume == "target") + if(theVolume == "target") {*condition = Forced;} else {*condition = NotForced;} - */ + */ *condition = NotForced; - -// G4double previousStepSize = 0.1*mm; + + // G4double previousStepSize = 0.1*mm; const G4DynamicParticle* projectile = aTrack.GetDynamicParticle(); G4double theKinEng = projectile->GetKineticEnergy(); - if(theKinEng < 1e-4*MeV) - {return DBL_MAX;} // Energy too low for this model! + if (theKinEng < 1e-4 * MeV) { + return DBL_MAX; + } // Energy too low for this model! // Now read the medium to get mean free path at this energy! - const G4Material* theMaterial = aTrack.GetMaterial(); - - // GetVecNbOfAtomsPerVolume() returns (NumberOfAtoms/mm3)! - const G4double* N_Per_Volume = theMaterial->GetVecNbOfAtomsPerVolume(); - - // Get List of Elements in Material, also get number! - const G4ElementVector* theElementList = theMaterial->GetElementVector(); - G4int NumberOfElements = theMaterial->GetNumberOfElements(); - - // Only do MeanFreePath calculation if in a material - // that has Hydrogen or Carbon ! - H_Switch = false; - C_Switch = false; - Fe_Switch = false; - Al_Switch = false; - - for(G4int ne=0;ne<NumberOfElements;ne++) - { - G4Element* theElement = (*theElementList)[ne]; - - //G4cout << "The Element is : " << theElement->GetName() << G4endl; - Z = static_cast<int>(theElement->GetZ()); - A = static_cast<int>(theElement->GetN()); // returns Atomic Weight - //G4cout << Z << " " << A << G4endl; - - //G4cout << theMaterial->GetName() << G4endl; - if(Z == 1 && A == 1) - { - H_Switch = true; - Num_H = N_Per_Volume[ne]; - } - else if(Z == 6 && A == 12) - { - C_Switch = true; - Num_C = N_Per_Volume[ne]; - } - else if(Z == 26){ - Fe_Switch = true; - //G4cout << "Inside IRON !!" << G4endl; - Num_Fe = N_Per_Volume[ne]; - } - else if(Z == 13){ - Al_Switch = true; - //G4cout << "Inside IRON !!" << G4endl; - Num_Al = N_Per_Volume[ne]; - } - } - - if(H_Switch == false && C_Switch == false && Fe_Switch == false && Al_Switch == false) - { return DBL_MAX; } - - // Calculate Total Mean Free Path (From Total Cross Section and Density) - // Does not decide reaction --- PostStepDoIt decides reaction if n-scattering occurs - - if(CalcMeth == "ORIGINAL") - { - G4int k_tot = 0; - - if(H_Switch == true) - { - // Returns Cross Section in Barns, pre-loaded in constructor - Sigma = GetCrossSection(theKinEng,theHydrogenXS); - //G4cout << "Sigma = " << Sigma/barn << G4endl; - ProbDistPerReaction[0] = Sigma*Num_H; - k_tot = 1; - } - else - { - // Clears array element - ProbDistPerReaction[0] = 0.; - } - - if(C_Switch == true) - { - Sigma = GetCrossSection(theKinEng,theCarbonXS); - ProbDistPerReaction[1] = Sigma*Num_C; - Sigma = GetCrossSection(theKinEng,theC12NGammaXS); - ProbDistPerReaction[2] = Sigma*Num_C; - Sigma = GetCrossSection(theKinEng,theC12ABe9XS); - ProbDistPerReaction[3] = Sigma*Num_C; - Sigma = GetCrossSection(theKinEng,theC12NPB12XS); - ProbDistPerReaction[4] = Sigma*Num_C; - Sigma = GetCrossSection(theKinEng,theC12NNPB11XS); - ProbDistPerReaction[5] = Sigma*Num_C; - Sigma = GetCrossSection(theKinEng,theC12N2NC11XS); - ProbDistPerReaction[6] = Sigma*Num_C; - Sigma = GetCrossSection(theKinEng,theC12NN3AlphaXS); - ProbDistPerReaction[7] = Sigma*Num_C; - - k_tot = 8; - } - else - { - // Clears array element - for(G4int i=1;i<8;i++) - { ProbDistPerReaction[i] = 0.; } - } - - if(Fe_Switch == true) - { - Sigma = GetCrossSection(theKinEng,theIronElasXS); - ProbDistPerReaction[8] = Sigma*Num_Fe; - Sigma = GetCrossSection(theKinEng,theIronNonelasXS); - ProbDistPerReaction[9] = Sigma*Num_Fe; - - k_tot = 10; - } - else - { - // Clears array element - for(G4int i=8;i<10;i++) - { ProbDistPerReaction[i] = 0.; } - } - - if(Al_Switch == true) - { - Sigma = GetCrossSection(theKinEng,theAlElasXS); - ProbDistPerReaction[10] = Sigma*Num_Al; - Sigma = GetCrossSection(theKinEng,theAlNonelasXS); - ProbDistPerReaction[11] = Sigma*Num_Al; - - k_tot = 12; - } - else - { - // Clears array element - for(G4int i=10;i<12;i++) - { ProbDistPerReaction[i] = 0.; } - } - - - ProbTot = 0.; // Reset Probtot - - for(G4int k=0; k<k_tot; k++) - {ProbTot += ProbDistPerReaction[k];} - - if(ProbTot > 1.e-6) - { - G4double total_mean_free_path = 1/(ProbTot); - //G4cout << "The mean free path was : " << total_mean_free_path/cm << " cm" << G4endl; - return total_mean_free_path; - } - } - else if(CalcMeth == "MENATE") - { - // MENATE MeanFreePath method is as follows: - // Adds up total cross section for hydrogen and carbon and then uses molecular weight, - // density of NE213 to calculate MeanFreePath - - // 30 April 2008 - BTR - After comparison with program DECOI, determined the difference - // between the ORIGINAL mean free path calculation above and the MENATE calculation - // is that the MENATE calculation lacks a factor 1.213 that is multiplied to the n-p - // total cross section. The 1.213 factor comes from the ratio of Carbon to Hydrogen in - // NE213. This disagreement is "fixed" in the original MENATE FORTRAN code by mulitiplying - // the Hydrogren cross sections in the data file by a factor of 1.2. - // I have left here the original method in the FORTRAN MENATE code for mean free path - // calculation for comparison with the ORIGINAL (standard) method. Note that the methods - // do not agree unless the n-p total cross sections in the data file are muliplied by 1.2 - // as in the FORTRAN version data files. - - G4String MaterialName = theMaterial->GetName(); - if(MaterialName == "NE213") - { AMass_Material = 13.213; } - else - { AMass_Material = theMaterial->GetA(); } - - // Get Cross Section Sum at this energy - ProbDistPerReaction[0] = (GetCrossSection(theKinEng,theHydrogenXS))/barn; - ProbDistPerReaction[1] = (GetCrossSection(theKinEng,theCarbonXS))/barn; - ProbDistPerReaction[2] = (GetCrossSection(theKinEng,theC12NGammaXS))/barn; - ProbDistPerReaction[3] = (GetCrossSection(theKinEng,theC12ABe9XS))/barn; - ProbDistPerReaction[4] = (GetCrossSection(theKinEng,theC12NPB12XS))/barn; - ProbDistPerReaction[5] = (GetCrossSection(theKinEng,theC12NNPB11XS))/barn; - ProbDistPerReaction[6] = (GetCrossSection(theKinEng,theC12N2NC11XS))/barn; - ProbDistPerReaction[7] = (GetCrossSection(theKinEng,theC12NN3AlphaXS))/barn; - - // Add up Cross Sections - ProbTot = 0.; // Reset Probtot - - for(G4int k=0; k<8; k++) - {ProbTot += ProbDistPerReaction[k];} - - G4double NE213dens = 0.874; - G4double NumAvagadro = 0.60221367; // Num Avagadro*conversion to barns - G4double Constant = 10.*AMass_Material/NumAvagadro/NE213dens; - G4double total_mean_free_path = Constant/ProbTot; - //G4cout << "The mean free path was : " << total_mean_free_path/cm << " cm" << G4endl; - - if(total_mean_free_path < DBL_MAX) - {return total_mean_free_path;} - - } - else if(CalcMeth == "carbon_el_only" && C_Switch == true) - { - // Added 7 May 2007 - For carbon elastic scattering only - // Clears array elements - for(G4int i=0;i<8;i++) - { ProbDistPerReaction[i] = 0.; } - Sigma = GetCrossSection(theKinEng,theCarbonXS); - ProbDistPerReaction[1] = Sigma*Num_C; - ProbTot = ProbDistPerReaction[1]; - if(ProbTot > 1.e-6) - { - G4double total_mean_free_path = 1/(ProbTot); - //G4cout << "The mean free path was : " << total_mean_free_path/cm << " cm" << G4endl; - return total_mean_free_path; - } - } - - return DBL_MAX; -} + const G4Material* theMaterial = aTrack.GetMaterial(); + + // GetVecNbOfAtomsPerVolume() returns (NumberOfAtoms/mm3)! + const G4double* N_Per_Volume = theMaterial->GetVecNbOfAtomsPerVolume(); + + // Get List of Elements in Material, also get number! + const G4ElementVector* theElementList = theMaterial->GetElementVector(); + G4int NumberOfElements = theMaterial->GetNumberOfElements(); + + // Only do MeanFreePath calculation if in a material + // that has Hydrogen or Carbon ! + H_Switch = false; + C_Switch = false; + Fe_Switch = false; + Al_Switch = false; + + for (G4int ne = 0; ne < NumberOfElements; ne++) { + auto theElement = (*theElementList)[ne]; + + // G4cout << "The Element is : " << theElement->GetName() << G4endl; + Z = static_cast<int>(theElement->GetZ()); + A = static_cast<int>(theElement->GetN()); // returns Atomic Weight + // G4cout << Z << " " << A << G4endl; + + // G4cout << theMaterial->GetName() << G4endl; + if (Z == 1 && A == 1) { + H_Switch = true; + Num_H = N_Per_Volume[ne]; + } + else if (Z == 6 && A == 12) { + C_Switch = true; + Num_C = N_Per_Volume[ne]; + } + else if (Z == 26) { + Fe_Switch = true; + // G4cout << "Inside IRON !!" << G4endl; + Num_Fe = N_Per_Volume[ne]; + } + else if (Z == 13) { + Al_Switch = true; + // G4cout << "Inside IRON !!" << G4endl; + Num_Al = N_Per_Volume[ne]; + } + } + + if (H_Switch == false && C_Switch == false && Fe_Switch == false && Al_Switch == false) { + return DBL_MAX; + } + + // Calculate Total Mean Free Path (From Total Cross Section and Density) + // Does not decide reaction --- PostStepDoIt decides reaction if n-scattering occurs + + if (CalcMeth == "ORIGINAL") { + G4int k_tot = 0; + + if (H_Switch == true) { + // Returns Cross Section in Barns, pre-loaded in constructor + Sigma = GetCrossSection(theKinEng, theHydrogenXS); + // G4cout << "Sigma = " << Sigma/barn << G4endl; + ProbDistPerReaction[0] = Sigma * Num_H; + k_tot = 1; + } + else { + // Clears array element + ProbDistPerReaction[0] = 0.; + } + + if (C_Switch == true) { + Sigma = GetCrossSection(theKinEng, theCarbonXS); + ProbDistPerReaction[1] = Sigma * Num_C; + Sigma = GetCrossSection(theKinEng, theC12NGammaXS); + ProbDistPerReaction[2] = Sigma * Num_C; + Sigma = GetCrossSection(theKinEng, theC12ABe9XS); + ProbDistPerReaction[3] = Sigma * Num_C; + Sigma = GetCrossSection(theKinEng, theC12NPB12XS); + ProbDistPerReaction[4] = Sigma * Num_C; + Sigma = GetCrossSection(theKinEng, theC12NNPB11XS); + ProbDistPerReaction[5] = Sigma * Num_C; + Sigma = GetCrossSection(theKinEng, theC12N2NC11XS); + ProbDistPerReaction[6] = Sigma * Num_C; + Sigma = GetCrossSection(theKinEng, theC12NN3AlphaXS); + ProbDistPerReaction[7] = Sigma * Num_C; + + k_tot = 8; + } + else { + // Clears array element + for (G4int i = 1; i < 8; i++) { + ProbDistPerReaction[i] = 0.; + } + } + + if (Fe_Switch == true) { + Sigma = GetCrossSection(theKinEng, theIronElasXS); + ProbDistPerReaction[8] = Sigma * Num_Fe; + Sigma = GetCrossSection(theKinEng, theIronNonelasXS); + ProbDistPerReaction[9] = Sigma * Num_Fe; + + k_tot = 10; + } + else { + // Clears array element + for (G4int i = 8; i < 10; i++) { + ProbDistPerReaction[i] = 0.; + } + } + + if (Al_Switch == true) { + Sigma = GetCrossSection(theKinEng, theAlElasXS); + ProbDistPerReaction[10] = Sigma * Num_Al; + Sigma = GetCrossSection(theKinEng, theAlNonelasXS); + ProbDistPerReaction[11] = Sigma * Num_Al; + + k_tot = 12; + } + else { + // Clears array element + for (G4int i = 10; i < 12; i++) { + ProbDistPerReaction[i] = 0.; + } + } + + ProbTot = 0.; // Reset Probtot + + for (G4int k = 0; k < k_tot; k++) { + ProbTot += ProbDistPerReaction[k]; + } + + if (ProbTot > 1.e-6) { + G4double total_mean_free_path = 1 / (ProbTot); + // G4cout << "The mean free path was : " << total_mean_free_path/cm << " cm" << G4endl; + return total_mean_free_path; + } + } + else if (CalcMeth == "MENATE") { + // MENATE MeanFreePath method is as follows: + // Adds up total cross section for hydrogen and carbon and then uses molecular weight, + // density of NE213 to calculate MeanFreePath + + // 30 April 2008 - BTR - After comparison with program DECOI, determined the difference + // between the ORIGINAL mean free path calculation above and the MENATE calculation + // is that the MENATE calculation lacks a factor 1.213 that is multiplied to the n-p + // total cross section. The 1.213 factor comes from the ratio of Carbon to Hydrogen in + // NE213. This disagreement is "fixed" in the original MENATE FORTRAN code by mulitiplying + // the Hydrogren cross sections in the data file by a factor of 1.2. + // I have left here the original method in the FORTRAN MENATE code for mean free path + // calculation for comparison with the ORIGINAL (standard) method. Note that the methods + // do not agree unless the n-p total cross sections in the data file are muliplied by 1.2 + // as in the FORTRAN version data files. + + G4String MaterialName = theMaterial->GetName(); + if (MaterialName == "NE213") { + AMass_Material = 13.213; + } + else { + AMass_Material = theMaterial->GetA(); + } + + // Get Cross Section Sum at this energy + ProbDistPerReaction[0] = (GetCrossSection(theKinEng, theHydrogenXS)) / barn; + ProbDistPerReaction[1] = (GetCrossSection(theKinEng, theCarbonXS)) / barn; + ProbDistPerReaction[2] = (GetCrossSection(theKinEng, theC12NGammaXS)) / barn; + ProbDistPerReaction[3] = (GetCrossSection(theKinEng, theC12ABe9XS)) / barn; + ProbDistPerReaction[4] = (GetCrossSection(theKinEng, theC12NPB12XS)) / barn; + ProbDistPerReaction[5] = (GetCrossSection(theKinEng, theC12NNPB11XS)) / barn; + ProbDistPerReaction[6] = (GetCrossSection(theKinEng, theC12N2NC11XS)) / barn; + ProbDistPerReaction[7] = (GetCrossSection(theKinEng, theC12NN3AlphaXS)) / barn; + + // Add up Cross Sections + ProbTot = 0.; // Reset Probtot + + for (G4int k = 0; k < 8; k++) { + ProbTot += ProbDistPerReaction[k]; + } + + G4double NE213dens = 0.874; + G4double NumAvagadro = 0.60221367; // Num Avagadro*conversion to barns + G4double Constant = 10. * AMass_Material / NumAvagadro / NE213dens; + G4double total_mean_free_path = Constant / ProbTot; + // G4cout << "The mean free path was : " << total_mean_free_path/cm << " cm" << G4endl; + + if (total_mean_free_path < DBL_MAX) { + return total_mean_free_path; + } + } + else if (CalcMeth == "carbon_el_only" && C_Switch == true) { + // Added 7 May 2007 - For carbon elastic scattering only + // Clears array elements + for (G4int i = 0; i < 8; i++) { + ProbDistPerReaction[i] = 0.; + } + Sigma = GetCrossSection(theKinEng, theCarbonXS); + ProbDistPerReaction[1] = Sigma * Num_C; + ProbTot = ProbDistPerReaction[1]; + if (ProbTot > 1.e-6) { + G4double total_mean_free_path = 1 / (ProbTot); + // G4cout << "The mean free path was : " << total_mean_free_path/cm << " cm" << G4endl; + return total_mean_free_path; + } + } + return DBL_MAX; +} -G4VParticleChange* menate_R::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep) -{ +G4VParticleChange* menate_R::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep) { // Now we tell GEANT what to do if MeanFreePath condition is satisfied! // Overrides PostStepDoIt function in G4VDiscreteProcess const G4DynamicParticle* projectile = aTrack.GetDynamicParticle(); - //const G4ParticleDefinition* particle = projectile->GetDefinition(); + // const G4ParticleDefinition* particle = projectile->GetDefinition(); const G4Material* theMaterial = aTrack.GetMaterial(); G4String MaterialName = theMaterial->GetName(); G4double KinEng_Int = projectile->GetKineticEnergy(); G4ThreeVector MomDir_Int = projectile->GetMomentumDirection(); - G4double GlobalTime = aTrack.GetGlobalTime(); + G4double GlobalTime = aTrack.GetGlobalTime(); G4ThreeVector thePosition = aTrack.GetPosition(); G4TouchableHandle theTouchable = aTrack.GetTouchableHandle(); - - //zwk Found that Genat4 gets hung up randomly with a position of (nan,nan,nan) - //Therefore if this happens reset position to previous set - if(std::isnan(thePosition.x())||std::isnan(thePosition.y())||std::isnan(thePosition.z())){ - //G4cout << "MENATE_R: Current position is (nan,nan,nan): resetting to presteppoint" << G4endl; + // zwk Found that Genat4 gets hung up randomly with a position of (nan,nan,nan) + // Therefore if this happens reset position to previous set + if (std::isnan(thePosition.x()) || std::isnan(thePosition.y()) || std::isnan(thePosition.z())) { + // G4cout << "MENATE_R: Current position is (nan,nan,nan): resetting to presteppoint" << G4endl; G4cout << aTrack.GetMaterial()->GetName() << G4endl; G4cout << aTrack.GetNextMaterial()->GetName() << G4endl; - G4cout << aStep.GetPreStepPoint()->GetPosition().z()/cm << G4endl; - G4cout << aStep.GetPostStepPoint()->GetPosition().z()/cm << G4endl; + G4cout << aStep.GetPreStepPoint()->GetPosition().z() / cm << G4endl; + G4cout << aStep.GetPostStepPoint()->GetPosition().z() / cm << G4endl; G4cout << aStep.GetPreStepPoint()->GetMaterial()->GetName() << G4endl; G4cout << aStep.GetPostStepPoint()->GetMaterial()->GetName() << G4endl; thePosition = aStep.GetPreStepPoint()->GetPosition(); - } /* @@ -1216,40 +1148,40 @@ G4VParticleChange* menate_R::PostStepDoIt(const G4Track& aTrack, const G4Step& a G4double theProjMass = projectile->GetMass(); */ - //zwk changed from 10-5 MeV - if(KinEng_Int < 0.5e-3*MeV) - { - //G4cout << "Neutron Energy = " << KinEng_Int << G4endl; - //G4cout << "Do Nothing, Kill Event! " << G4endl; + // zwk changed from 10-5 MeV + if (KinEng_Int < 0.5e-3 * MeV) { + // G4cout << "Neutron Energy = " << KinEng_Int << G4endl; + // G4cout << "Do Nothing, Kill Event! " << G4endl; aParticleChange.ProposeTrackStatus(fStopAndKill); aParticleChange.ProposeEnergy(0.); aParticleChange.ProposePosition(thePosition); return pParticleChange; - } + } - if(MaterialName == "NE213") - { AMass_Material = 13.213; } + if (MaterialName == "NE213") { + AMass_Material = 13.213; + } // Define Reaction - // Chooses Reaction based on ProbDistPerReaction Vector defined in GetMeanFreePath() - G4String ReactionName = ChooseReaction(); + G4String ReactionName = ChooseReaction(); // //*******MENATE Reaction Kinematics************* // - - //zwk modification Bool_t fwrdANGLES = true means use cos_theta_iso=pow(G4uniformRand,1/4), so becomes very forward focused rather than isotropic - G4bool fwrdANGLES = false; -if(ReactionName == "N_P_elastic") - { + // zwk modification Bool_t fwrdANGLES = true means use cos_theta_iso=pow(G4uniformRand,1/4), so becomes very forward + // focused rather than isotropic + G4bool fwrdANGLES = false; + + if (ReactionName == "N_P_elastic") { - G4double mass_ratio = 939.6/938.3; // Mass ratio N/P + G4double mass_ratio = 939.6 / 938.3; // Mass ratio N/P G4double cos_theta = 0.; G4double theta_cm = 0.; - G4double theta_N = 0.; + G4double theta_N = 0.; G4double phi_N = 0.; G4double T_N = 0.; G4ThreeVector MomDir_N; @@ -1261,31 +1193,31 @@ if(ReactionName == "N_P_elastic") G4ThreeVector MomDir_P; // *** 6 May 2008 - Added n-p angular distribution as in DEMONS - BTR - // Made slight adjustment to routine (changed "30" to "29") to improve + // Made slight adjustment to routine (changed "30" to "29") to improve // agreement with data. - // Calculate recoil energy as in Knoll + // Calculate recoil energy as in Knoll cos_theta = NP_AngDist(KinEng_Int); // cosine of cm_angle theta_cm = acos(cos_theta); // Following Knoll, calculate energy for proton first - cos_theta_P = sqrt((1.-cos_theta)/2.); + cos_theta_P = sqrt((1. - cos_theta) / 2.); theta_P = acos(cos_theta_P); - phi_P = 2.*Pi*G4UniformRand(); + phi_P = 2. * Pi * G4UniformRand(); - T_P = KinEng_Int*pow(cos_theta_P,2); + T_P = KinEng_Int * pow(cos_theta_P, 2); - MomDir_P = GenMomDir(MomDir_Int,theta_P,phi_P); + MomDir_P = GenMomDir(MomDir_Int, theta_P, phi_P); // scattered neutron ---------------- // angles changed from cm to lab as in Marian and Young - theta_N = atan(sin(theta_cm)/(cos_theta+mass_ratio)); - phi_N = phi_P+Pi; + theta_N = atan(sin(theta_cm) / (cos_theta + mass_ratio)); + phi_N = phi_P + Pi; - T_N = KinEng_Int - T_P; + T_N = KinEng_Int - T_P; + + MomDir_N = GenMomDir(MomDir_Int, theta_N, phi_N); - MomDir_N = GenMomDir(MomDir_Int,theta_N,phi_N); - // Generate a Secondary Neutron G4DynamicParticle* theSecNeutron = new G4DynamicParticle; G4ParticleDefinition* theSecNeutronDefinition = G4Neutron::Neutron(); @@ -1299,1227 +1231,1235 @@ if(ReactionName == "N_P_elastic") theSecProton->SetDefinition(theSecProtonDefinition); theSecProton->SetKineticEnergy(T_P); theSecProton->SetMomentumDirection(MomDir_P); - + // Kill the Parent Neutron ----------------------- aParticleChange.ProposeTrackStatus(fStopAndKill); aParticleChange.ProposeEnergy(0.); aParticleChange.ProposePosition(thePosition); - - // Set final tracks in motion! - G4Track* theNTrack = new G4Track(theSecNeutron,GlobalTime,thePosition); + + // Set final tracks in motion! + G4Track* theNTrack = new G4Track(theSecNeutron, GlobalTime, thePosition); theNTrack->SetTouchableHandle(theTouchable); - G4Track* thePTrack = new G4Track(theSecProton,GlobalTime,thePosition); + G4Track* thePTrack = new G4Track(theSecProton, GlobalTime, thePosition); thePTrack->SetTouchableHandle(theTouchable); aParticleChange.SetNumberOfSecondaries(2); aParticleChange.AddSecondary(theNTrack); aParticleChange.AddSecondary(thePTrack); - + // G4cout << "Made it to the end ! " << G4endl; - } - else if(ReactionName == "N_C12_elastic") - { - G4double theta_N = 0.; - G4double phi_N = 0.; - - G4double T_N = 0.; - G4double T_C12el = 0.; - G4ThreeVector MomDir_N; - G4ThreeVector MomDir_C12; - - // For n,12C elastic scattering, follows model of Knoll - // Original MENATE distribution was isotropic in CM - // G4double cos_sq_theta = G4UniformRand(); - - // Calls diffractive angular distribution as in DEMONS - G4double cos_theta_cm = NC12_DIFF(KinEng_Int); - - // Convert according to Knoll - G4double cos_theta_lab = sqrt((1.-cos_theta_cm)/2.); - - G4double cos_sq_theta = pow(cos_theta_lab,2); - - // .2840237 =4*Mc12*Mn/(Mc12+Mn)^2 - T_C12el = 0.2840237*KinEng_Int*cos_sq_theta; - - T_N = KinEng_Int - T_C12el; - - if(T_N > 1.e-5) - { - G4double arg = (sqrt(KinEng_Int)-sqrt(12.*T_C12el*cos_sq_theta))/sqrt(T_N); - if(arg > 1.) - {arg = 1.;} - theta_N = acos(arg); - phi_N = 2.*Pi*G4UniformRand(); - } - - MomDir_N = GenMomDir(MomDir_Int,theta_N,phi_N); - - // Carbon angles - G4double theta_C12 = acos(sqrt(cos_sq_theta)); - G4double phi_C12 = phi_N+Pi; - - MomDir_C12 = GenMomDir(MomDir_Int,theta_C12,phi_C12); - - // Generate a Secondary Neutron - G4DynamicParticle* theSecNeutron = new G4DynamicParticle; - G4ParticleDefinition* theSecNeutronDefinition = G4Neutron::Neutron(); - theSecNeutron->SetDefinition(theSecNeutronDefinition); - theSecNeutron->SetKineticEnergy(T_N); - theSecNeutron->SetMomentumDirection(MomDir_N); - - // Generate a Secondary C12 - G4DynamicParticle* theSecC12 = new G4DynamicParticle; - // GetIon() Method works whether particle exists in physicslist or not. - // Arguements are GetIon(Charge,Mass,ExcitationEng) - G4ParticleDefinition* theSecC12Definition = G4IonTable::GetIonTable()->GetIon(6,12,0.); - theSecC12->SetDefinition(theSecC12Definition); - theSecC12->SetKineticEnergy(T_C12el); - theSecC12->SetMomentumDirection(MomDir_C12); - - // Kill the Parent Neutron ----------------------- - aParticleChange.ProposeTrackStatus(fStopAndKill); - aParticleChange.ProposeEnergy(0.); - aParticleChange.ProposePosition(thePosition); - - // Set final tracks in motion! - G4Track* theNTrack = new G4Track(theSecNeutron,GlobalTime,thePosition); - theNTrack->SetTouchableHandle(theTouchable); - G4Track* theC12Track = new G4Track(theSecC12,GlobalTime,thePosition); - theC12Track->SetTouchableHandle(theTouchable); - - aParticleChange.SetNumberOfSecondaries(2); - aParticleChange.AddSecondary(theNTrack); - aParticleChange.AddSecondary(theC12Track); - - // G4cout << "Made it to the end ! " << G4endl; - } - else if(ReactionName == "N_C12_NGamma") - { - // 24 Apr. 2008 - BTR - This version replaces version in previous - // menate.cc to 12C(n,n'gamma) reaction in orig FORTRAN MENATE - - G4double Available_Eng; - - if(KinEng_Int >= 8.5*MeV) - { Available_Eng = 8.5*MeV*(G4UniformRand()); } // Max available Eng = 8.5 MeV ? - else - { Available_Eng = KinEng_Int*G4UniformRand(); } - - - //G4double Total_Gamma_Eng = ShareGammaEngC12(Available_Eng); - //Changed such that one 4.4 MeV gamma is always produced if the - //nng4 reaction is called. - //if the energy is >4.43 MeV then 1 gamma is produced. - G4double enough_gamma_eng=0*MeV; - if(KinEng_Int >= 4.5*MeV) enough_gamma_eng = 5.0*MeV; - G4double Total_Gamma_Eng = ShareGammaEngC12(enough_gamma_eng); - - G4ThreeVector MomDir_N; - G4ThreeVector MomDir_C12; - - // N' - - Available_Eng = 0.9230769*KinEng_Int-Total_Gamma_Eng; - if(Available_Eng <= 0.) - {Available_Eng = 0.;} // = 0 in Fortran code - BTR - - G4double cos_theta_iso = 1.-(2.*G4UniformRand()); - //zwk - if(fwrdANGLES) cos_theta_iso = pow(G4UniformRand(),1./4.0); - - G4double T_N = KinEng_Int/169.+0.9230769*Available_Eng + - (0.1478106*sqrt(KinEng_Int*Available_Eng))*cos_theta_iso; - G4double theta_N = acos(cos_theta_iso); - G4double phi_N = 2.*Pi*G4UniformRand(); - - MomDir_N = GenMomDir(MomDir_Int,theta_N,phi_N); - - // C12* - - G4double T_C12 = KinEng_Int - T_N - Total_Gamma_Eng; - if(T_C12 <= 0.) - {T_C12 = 0.;} - G4double theta_C12 = Pi - theta_N; - G4double phi_C12 = Pi + phi_N; - - MomDir_C12 = GenMomDir(MomDir_Int,theta_C12,phi_C12); - - // Generate a Secondary Neutron - G4DynamicParticle* theSecNeutron = new G4DynamicParticle; - G4ParticleDefinition* theSecNeutronDefinition = G4Neutron::Neutron(); - theSecNeutron->SetDefinition(theSecNeutronDefinition); - theSecNeutron->SetKineticEnergy(T_N); - theSecNeutron->SetMomentumDirection(MomDir_N); - - // Generate a Secondary C12* - G4DynamicParticle* theSecC12 = new G4DynamicParticle; - // GetIon() Method works whether particle exists in physicslist or not. - // Arguements are GetIon(Charge,Mass,ExcitationEng) - G4ParticleDefinition* theSecC12Definition = G4IonTable::GetIonTable()->GetIon(6,12,0.); - theSecC12->SetDefinition(theSecC12Definition); - theSecC12->SetKineticEnergy(T_C12); - theSecC12->SetMomentumDirection(MomDir_C12); - - // 4.439 MeV Gamma - emitted isotropically from reaction point.. - // -- 24 Apr 2008 - BTR - With 8.5 MeV limit given at start of - // MENATE function for this reaction, can not produce more - // than one 4.439 MeV gamma. - // - 19 May 2008 - BTR - // --- Removed 400 keV gamma ray counter from original MENATE code - - G4int NumberOfSec = 2+Num_gamma_4439k; - aParticleChange.SetNumberOfSecondaries(NumberOfSec); - - //G4cout << Available_Eng/MeV << G4endl; - //G4cout << "Num gammas: " << Num_gamma_4439k << G4endl; - if(Num_gamma_4439k > 0) - { - G4double T_Gamma = 4.439*MeV; - G4double theta_Gamma = acos(1.-(2.*G4UniformRand())); - G4double phi_Gamma = 2.*Pi*G4UniformRand(); - - G4ThreeVector MomDir_Gamma; - MomDir_Gamma = GenMomDir(MomDir_Int,theta_Gamma,phi_Gamma); - - // Generate a Secondary Gamma (4.439 MeV) - G4DynamicParticle* theSecGamma = new G4DynamicParticle; - G4ParticleDefinition* theGammaDefinition = G4Gamma::Gamma(); - theSecGamma->SetDefinition(theGammaDefinition); - theSecGamma->SetKineticEnergy(T_Gamma); - theSecGamma->SetMomentumDirection(MomDir_Gamma); - - aParticleChange.SetNumberOfSecondaries(2+Num_gamma_4439k); - - G4Track* theGammaTrack = new G4Track(theSecGamma,GlobalTime,thePosition); - theGammaTrack->SetTouchableHandle(theTouchable); - aParticleChange.AddSecondary(theGammaTrack); - } - - // Kill the Parent Neutron ----------------------- - aParticleChange.ProposeTrackStatus(fStopAndKill); - aParticleChange.ProposeEnergy(0.); - aParticleChange.ProposePosition(thePosition); - - // Set final tracks in motion! - G4Track* theNTrack = new G4Track(theSecNeutron,GlobalTime,thePosition); - theNTrack->SetTouchableHandle(theTouchable); - G4Track* theC12Track = new G4Track(theSecC12,GlobalTime,thePosition); - theC12Track->SetTouchableHandle(theTouchable); - - aParticleChange.AddSecondary(theNTrack); - aParticleChange.AddSecondary(theC12Track); - - // G4cout << "Made it to the end ! " << G4endl; - - } - else if(ReactionName == "N_C12_A_Be9") - { - // Copied from MENATE - // Reaction can not occur if incoming neutron energy is below 6.176 MeV - // Q Value = - 5.701 MeV - - // Uses formula for C12 recoil to calculate direction of 9Be - - G4ThreeVector MomDir_Alpha; - G4ThreeVector MomDir_Be9; - - G4double Q_value = -5.701*MeV; - // 0.9230769 = Mass_C12/(Mass_N+Mass_C12) - converts to CM frame energy - G4double Available_Eng = 0.9230769*KinEng_Int+Q_value; - - if(Available_Eng <= 0.) - { Available_Eng = 0.; } - - // the alpha - - G4double cos_theta_iso = 1.-(2.*G4UniformRand()); - //zwk - if(fwrdANGLES) cos_theta_iso = pow(G4UniformRand(),1./4.0); - - // 0.0236686 = Malpha*MassN/(MassC12+MassN)^2 - // 0.6923077 = MBe9/(MassN+MassC12) - // 0.2560155 = 2.*sqrt(Mn*MBe9*Malpha/(MassC12+MassN)^3) - - G4double T_Alpha = 0.0236686*KinEng_Int+0.6923077*Available_Eng+ - (0.2560155*sqrt(KinEng_Int*Available_Eng))*cos_theta_iso; - - G4double theta_Alpha = 0.; - G4double phi_Alpha = 0.; - - if(T_Alpha > 1.e-5) - { - // 0.1538462 = sqrt(Malpha*Mn)/(Mn+Mc12) - // 0.8320503 = sqrt(MBe9/(MassC12+MassN)) - - G4double Arg = (0.1538462*sqrt(KinEng_Int)+0.8320503*sqrt(Available_Eng)*cos_theta_iso)/(sqrt(T_Alpha)); - - if(Arg > 1.) - { Arg = 1.; } - - theta_Alpha = acos(Arg); - phi_Alpha = 2.*Pi*G4UniformRand(); - } - - MomDir_Alpha = GenMomDir(MomDir_Int,theta_Alpha,phi_Alpha); - - // Be9 - Need to check kinematics - maybe not right - 18 Apr 2008, BTR - - G4double T_Be9 = KinEng_Int + Q_value - T_Alpha; - G4double theta_Be9 = Pi - theta_Alpha; - G4double phi_Be9 = Pi + phi_Alpha; - - MomDir_Be9 = GenMomDir(MomDir_Int,theta_Be9,phi_Be9); - - // Generate a Secondary Alpha - G4DynamicParticle* theSecAlpha = new G4DynamicParticle; - G4ParticleDefinition* theSecAlphaDefinition = G4Alpha::Alpha(); - theSecAlpha->SetDefinition(theSecAlphaDefinition); - theSecAlpha->SetKineticEnergy(T_Alpha); - theSecAlpha->SetMomentumDirection(MomDir_Alpha); - - // Generate a Secondary Be9 - G4DynamicParticle* theSecBe9 = new G4DynamicParticle; - // GetIon() Method works whether particle exists in physicslist or not. - // Arguements are GetIon(Charge,Mass,ExcitationEng) - G4ParticleDefinition* theSecBe9Definition = G4IonTable::GetIonTable()->GetIon(4,9,0.); - theSecBe9->SetDefinition(theSecBe9Definition); - theSecBe9->SetKineticEnergy(T_Be9); - theSecBe9->SetMomentumDirection(MomDir_Be9); + else if (ReactionName == "N_C12_elastic") { + G4double theta_N = 0.; + G4double phi_N = 0.; - // Kill the Parent Neutron ----------------------- - aParticleChange.ProposeTrackStatus(fStopAndKill); - aParticleChange.ProposeEnergy(0.); - aParticleChange.ProposePosition(thePosition); - - // Set final tracks in motion! - G4Track* theAlphaTrack = new G4Track(theSecAlpha,GlobalTime,thePosition); - theAlphaTrack->SetTouchableHandle(theTouchable); - G4Track* theBe9Track = new G4Track(theSecBe9,GlobalTime,thePosition); - theBe9Track->SetTouchableHandle(theTouchable); - - aParticleChange.SetNumberOfSecondaries(2); - aParticleChange.AddSecondary(theAlphaTrack); - aParticleChange.AddSecondary(theBe9Track); - - /* - //---Test Momentum Conservation---- - G4cout << "\n\n------------------"<< G4endl; - - //incoming neutron - G4DynamicParticle *p1 = (G4DynamicParticle*) aTrack.GetDynamicParticle(); - G4ThreeVector vec1 = p1->GetMomentum(); - G4cout << "p1, px: " << vec1.x()/MeV << " py: " << vec1.y()/MeV << " pz: " << vec1.z()/MeV << " mag: " << vec1.mag()/MeV << G4endl; - G4cout << " Total Mom: " << p1 ->GetTotalMomentum()/MeV << " TotalE: " << p1->GetTotalEnergy()/MeV << " KE: " << p1->GetKineticEnergy()/MeV << G4endl; - - - G4DynamicParticle *p2 = (G4DynamicParticle*) theAlphaTrack->GetDynamicParticle(); - G4ThreeVector vec2 = p2->GetMomentum(); - G4cout << "p2, px: " << vec2.x()/MeV << " py: " << vec2.y()/MeV << " pz: " << vec2.z()/MeV << " mag: " << vec2.mag()/MeV << G4endl; - G4cout << " Total Mom: " << p2->GetTotalMomentum()/MeV << " TotalE: " << p2->GetTotalEnergy()/MeV << " KE: " << p2->GetKineticEnergy()/MeV << G4endl; - - - G4DynamicParticle *p3 = (G4DynamicParticle*) theBe9Track->GetDynamicParticle(); - G4ThreeVector vec3 = p3->GetMomentum(); - G4cout << "p3, px: " << vec3.x()/MeV << " py: " << vec3.y()/MeV << " pz: " << vec3.z()/MeV << " mag: " << vec3.mag()/MeV << G4endl; - G4cout << " Total Mom: " << p3->GetTotalMomentum()/MeV << " TotalE: " << p3->GetTotalEnergy()/MeV << " KE: " << p3->GetKineticEnergy()/MeV << G4endl; - //----------- - */ + G4double T_N = 0.; + G4double T_C12el = 0.; + G4ThreeVector MomDir_N; + G4ThreeVector MomDir_C12; - // G4cout << "Made it to the end ! " << G4endl; - } - else if(ReactionName == "N_C12_P_B12") - { - // Charge exchange Reaction copied from MENATE - G4double Q_value = -12.587*MeV; - - G4ThreeVector MomDir_P; - G4ThreeVector MomDir_B12; - - G4double Available_Eng = 0.9230769*KinEng_Int+Q_value; - - if(Available_Eng < 0.) - { Available_Eng = 0.; } - - // the proton - - G4double cos_theta_iso = 1.-(2.*G4UniformRand()); - //zwk - if(fwrdANGLES) cos_theta_iso = pow(G4UniformRand(),1./4.0); - - //1/169. = Mp*Mn/(Mn+MC12)^2 - // .9230769 = MB12/(Mn+MC12) - // .1478106 = 2*sqrt(Mn*MB12*Mp/(Mc12+Mn)^3) - - G4double T_P = KinEng_Int/169. + 0.9230769*Available_Eng + - (0.1478106*sqrt(KinEng_Int*Available_Eng))*cos_theta_iso; - - G4double theta_P = 0.; - G4double phi_P = 0.; - - if(T_P > 1.e-5) - { - // 1/13. = sqrt(Mp*Mn)/(Mn+Mc) - // 0.9607689 = sqrt(MB12/(Mn+MC12)) - - G4double Arg = (sqrt(KinEng_Int)/13. + 0.9607689*sqrt(Available_Eng)*cos_theta_iso)/(sqrt(T_P)); - if( Arg > 1.) - { Arg = 1.; } - theta_P = acos(Arg); - phi_P = 2.*Pi*G4UniformRand(); - } - - MomDir_P = GenMomDir(MomDir_Int,theta_P,phi_P); - - // B12 - Need to check kinematics - maybe not right - 18 Apr 2008, BTR - - G4double T_B12 = KinEng_Int + Q_value - T_P; - G4double theta_B12 = Pi - theta_P; - G4double phi_B12 = Pi + phi_P; - - MomDir_B12 = GenMomDir(MomDir_Int,theta_B12,phi_B12); - - // Generate a Secondary Proton - G4DynamicParticle* theSecProton = new G4DynamicParticle; - G4ParticleDefinition* theSecPDefinition = G4Proton::Proton(); - theSecProton->SetDefinition(theSecPDefinition); - theSecProton->SetKineticEnergy(T_P); - theSecProton->SetMomentumDirection(MomDir_P); - - // Generate a Secondary B12 - G4DynamicParticle* theSecB12 = new G4DynamicParticle; - // GetIon() Method works whether particle exists in physicslist or not. - // Arguements are GetIon(Charge,Mass,ExcitationEng) - G4ParticleDefinition* theSecB12Definition = G4IonTable::GetIonTable()->GetIon(5,12,0.); - theSecB12->SetDefinition(theSecB12Definition); - theSecB12->SetKineticEnergy(T_B12); - theSecB12->SetMomentumDirection(MomDir_B12); + // For n,12C elastic scattering, follows model of Knoll + // Original MENATE distribution was isotropic in CM + // G4double cos_sq_theta = G4UniformRand(); - // Kill the Parent Neutron ----------------------- - aParticleChange.ProposeTrackStatus(fStopAndKill); - aParticleChange.ProposeEnergy(0.); - aParticleChange.ProposePosition(thePosition); - - // Set final tracks in motion! - G4Track* thePTrack = new G4Track(theSecProton,GlobalTime,thePosition); - thePTrack->SetTouchableHandle(theTouchable); - G4Track* theB12Track = new G4Track(theSecB12,GlobalTime,thePosition); - theB12Track->SetTouchableHandle(theTouchable); - - aParticleChange.SetNumberOfSecondaries(2); - aParticleChange.AddSecondary(thePTrack); - aParticleChange.AddSecondary(theB12Track); - - // G4cout << "Made it to the end ! " << G4endl; - } - else if(ReactionName == "N_C12_NNP_B11") - { - // Reaction copied from MENATE - // Treated as : - // n + 12C ---> 12C* + n' - // 12C* ---> 11B + p - - G4double Q_value = -15.956*MeV; - - G4ThreeVector MomDir_N; - G4ThreeVector MomDir_P; - G4ThreeVector MomDir_B11; - - // Scattered neutron (n') - G4double Available_Eng = 0.9230769*KinEng_Int+Q_value; - - if(Available_Eng < 0.) - { Available_Eng = 1.e-3; } - - G4double Eng_Evap1 = Evaporate_Eng(AMass_Material,Available_Eng); - - G4double cos_theta_iso = 1.-2.*G4UniformRand(); - //zwk - if(fwrdANGLES) cos_theta_iso = pow(G4UniformRand(),1./4.0); - - // 1/169. = (Mn/(Mn+Mc))^2 - // 0.1538462 = 2Mn/(Mn+Mc) - - G4double T_N = KinEng_Int/169. + Eng_Evap1 + (0.1538462*sqrt(KinEng_Int*Eng_Evap1))*cos_theta_iso; - - G4double theta_N = 0.; - G4double phi_N = 0.; - - if(T_N > 1.e-5) - { - // 1/13. = Mn/(Mn+Mc) - - G4double Arg = (sqrt(KinEng_Int)/13. + (sqrt(Eng_Evap1)*cos_theta_iso))/(sqrt(T_N)); - if( Arg > 1.) - { Arg = 1.; } - theta_N = acos(Arg); - phi_N = 2.*Pi*G4UniformRand(); - //G4cout << "12C(n,np)11B angle of neutron: " << theta_N*180/3.14 << G4endl; - } - - MomDir_N = GenMomDir(MomDir_Int,theta_N,phi_N); - - // Scattered 12C* - // 1/13. = Mn(Mc+Mn) - // 1.0833333 = (Mc+Mn)/Mc - - G4double T_C12Star = KinEng_Int/13. + 1.0833333*Eng_Evap1 - T_N; - - G4double theta_C12Star = 0.; - G4double phi_C12Star = phi_N+Pi; - - if(T_C12Star > 1.e-5) - { - // 0.2664694 = sqrt(Mn*Mc)/(Mn+Mc) - // 0.2886751 = sqrt(Mn/Mc) - G4double Arg = (0.2664694*sqrt(KinEng_Int) - (0.2886751*sqrt(Eng_Evap1)*cos_theta_iso))/(sqrt(T_C12Star)); - if( Arg > 1.) - { Arg = 1.; } - theta_C12Star = acos(Arg); - } - - // Now the proton is emitted in the frame of the scattered C12* - // At the end, the angles are put back into the frame of the original neutron - - Available_Eng = KinEng_Int + Q_value - T_N - T_C12Star; - - if(Available_Eng < 0.) - { Available_Eng = 0.; } - - cos_theta_iso = 1.-(2.*G4UniformRand()); - - // 1/12. = Mp/MC12 - // .9166667 = MB11/MC12 - // .5527708 = 2*sqrt(MB11*Mp)/Mc - - G4double T_P = T_C12Star/12. + 0.9166667*Available_Eng + - (0.5527708*sqrt(Available_Eng*T_C12Star))*cos_theta_iso; - - G4double theta_C12_P = 0.; - G4double phi_C12_P = 0.; - - if(T_P > 1.e-5) - { - // 0.2886751 = sqrt(Mp/Mc) - // 0.9574271 = sqrt((MB11)/(MC12)) - - G4double Arg = (0.2886751*sqrt(T_C12Star) + 0.9574271*sqrt(Available_Eng)*cos_theta_iso)/(sqrt(T_P)); - if( Arg > 1.) - { Arg = 1.; } - theta_C12_P = acos(Arg); - phi_C12_P = 2.*Pi*G4UniformRand(); - } - - // Now Start With Z-Axis and then go to incoming neutron frame ? - //G4ThreeVector MomDir_ZAxis = G4ThreeVector(0.,0.,1.); - - G4ThreeVector MomDir_ZAxis = MomDir_Int; - G4ThreeVector MomDir_C12Star = GenMomDir(MomDir_ZAxis,theta_C12Star,phi_C12Star); - - MomDir_P = GenMomDir(MomDir_C12Star,theta_C12_P,phi_C12_P); - - // B11 - Need to check kinematics - maybe not right - 18 Apr 2008, BTR - - G4double T_B11 = KinEng_Int + Q_value - T_N - T_P; // Remaining Eng - if(T_B11 < 0.) - {T_B11 = 1e-9;} - - G4double theta_B11 = Pi - theta_C12_P; - G4double phi_B11 = Pi + phi_C12_P; - - MomDir_B11 = GenMomDir(MomDir_Int,theta_B11,phi_B11); - -// Generate a Secondary Neutron - G4DynamicParticle* theSecNeutron = new G4DynamicParticle; - G4ParticleDefinition* theSecNDefinition = G4Neutron::Neutron(); - theSecNeutron->SetDefinition(theSecNDefinition); - theSecNeutron->SetKineticEnergy(T_N); - theSecNeutron->SetMomentumDirection(MomDir_N); - -// Generate a Secondary Proton - G4DynamicParticle* theSecProton = new G4DynamicParticle; - G4ParticleDefinition* theSecPDefinition = G4Proton::Proton(); - theSecProton->SetDefinition(theSecPDefinition); - theSecProton->SetKineticEnergy(T_P); - theSecProton->SetMomentumDirection(MomDir_P); - - // Generate a Secondary B11 - G4DynamicParticle* theSecB11 = new G4DynamicParticle; - // GetIon() Method works whether particle exists in physicslist or not. - // Arguements are GetIon(Charge,Mass,ExcitationEng) - G4ParticleDefinition* theSecB11Definition = G4IonTable::GetIonTable()->GetIon(5,11,0.); - theSecB11->SetDefinition(theSecB11Definition); - theSecB11->SetKineticEnergy(T_B11); - theSecB11->SetMomentumDirection(MomDir_B11); + // Calls diffractive angular distribution as in DEMONS + G4double cos_theta_cm = NC12_DIFF(KinEng_Int); + + // Convert according to Knoll + G4double cos_theta_lab = sqrt((1. - cos_theta_cm) / 2.); + + G4double cos_sq_theta = pow(cos_theta_lab, 2); + + // .2840237 =4*Mc12*Mn/(Mc12+Mn)^2 + T_C12el = 0.2840237 * KinEng_Int * cos_sq_theta; + + T_N = KinEng_Int - T_C12el; + + if (T_N > 1.e-5) { + G4double arg = (sqrt(KinEng_Int) - sqrt(12. * T_C12el * cos_sq_theta)) / sqrt(T_N); + if (arg > 1.) { + arg = 1.; + } + theta_N = acos(arg); + phi_N = 2. * Pi * G4UniformRand(); + } + + MomDir_N = GenMomDir(MomDir_Int, theta_N, phi_N); + + // Carbon angles + G4double theta_C12 = acos(sqrt(cos_sq_theta)); + G4double phi_C12 = phi_N + Pi; + + MomDir_C12 = GenMomDir(MomDir_Int, theta_C12, phi_C12); + + // Generate a Secondary Neutron + G4DynamicParticle* theSecNeutron = new G4DynamicParticle; + G4ParticleDefinition* theSecNeutronDefinition = G4Neutron::Neutron(); + theSecNeutron->SetDefinition(theSecNeutronDefinition); + theSecNeutron->SetKineticEnergy(T_N); + theSecNeutron->SetMomentumDirection(MomDir_N); + + // Generate a Secondary C12 + G4DynamicParticle* theSecC12 = new G4DynamicParticle; + // GetIon() Method works whether particle exists in physicslist or not. + // Arguements are GetIon(Charge,Mass,ExcitationEng) + G4ParticleDefinition* theSecC12Definition = G4IonTable::GetIonTable()->GetIon(6, 12, 0.); + theSecC12->SetDefinition(theSecC12Definition); + theSecC12->SetKineticEnergy(T_C12el); + theSecC12->SetMomentumDirection(MomDir_C12); // Kill the Parent Neutron ----------------------- - aParticleChange.ProposeTrackStatus(fStopAndKill); - aParticleChange.ProposeEnergy(0.); - aParticleChange.ProposePosition(thePosition); - - // Set final tracks in motion! - G4Track* theNTrack = new G4Track(theSecNeutron,GlobalTime,thePosition); - theNTrack->SetTouchableHandle(theTouchable); - G4Track* thePTrack = new G4Track(theSecProton,GlobalTime,thePosition); - thePTrack->SetTouchableHandle(theTouchable); - G4Track* theB11Track = new G4Track(theSecB11,GlobalTime,thePosition); - theB11Track->SetTouchableHandle(theTouchable); - - aParticleChange.SetNumberOfSecondaries(3); - aParticleChange.AddSecondary(theNTrack); - aParticleChange.AddSecondary(thePTrack); - aParticleChange.AddSecondary(theB11Track); - + aParticleChange.ProposeTrackStatus(fStopAndKill); + aParticleChange.ProposeEnergy(0.); + aParticleChange.ProposePosition(thePosition); + + // Set final tracks in motion! + G4Track* theNTrack = new G4Track(theSecNeutron, GlobalTime, thePosition); + theNTrack->SetTouchableHandle(theTouchable); + G4Track* theC12Track = new G4Track(theSecC12, GlobalTime, thePosition); + theC12Track->SetTouchableHandle(theTouchable); + + aParticleChange.SetNumberOfSecondaries(2); + aParticleChange.AddSecondary(theNTrack); + aParticleChange.AddSecondary(theC12Track); + // G4cout << "Made it to the end ! " << G4endl; - } - else if(ReactionName == "N_C12_N2N_C11") - { - // Reaction copied from MENATE - // Treated as : - // n + 12C ---> 12C* + n' - // 12C* ---> 11C + n - - G4double Q_value = -18.721*MeV; - - G4ThreeVector MomDir_N1; - G4ThreeVector MomDir_N2; - G4ThreeVector MomDir_C11; - - // Scattered neutron (n') - G4double Available_Eng = 0.9230769*KinEng_Int+Q_value; - - if(Available_Eng < 0.) - { Available_Eng = 1.e-3; } - - G4double Eng_Evap1 = Evaporate_Eng(AMass_Material,Available_Eng); - - G4double cos_theta_iso = 1.-(2.*G4UniformRand()); - //zwk - if(fwrdANGLES) cos_theta_iso = pow(G4UniformRand(),1./4.0); - - // 1/169. = (Mn/(Mn+Mc))^2 - // 0.1538462 = 2Mn/(Mn+Mc) - - G4double T_N1 = KinEng_Int/169. + Eng_Evap1 + (0.1538462*sqrt(KinEng_Int*Eng_Evap1))*cos_theta_iso; - - G4double theta_N1 = 0.; - G4double phi_N1 = 0.; - - if(T_N1 > 1.e-5) - { - // 1/13. = Mn/(Mn+Mc) - - G4double Arg = (sqrt(KinEng_Int)/13. + (sqrt(Eng_Evap1)*cos_theta_iso))/(sqrt(T_N1)); - if( Arg > 1.) - { Arg = 1.; } - theta_N1 = acos(Arg); - phi_N1 = 2.*Pi*G4UniformRand(); - } - - MomDir_N1 = GenMomDir(MomDir_Int,theta_N1,phi_N1); - - // Scattered 12C* - // 1/13. = Mn(Mc+Mn) - // 1.0833333 = (Mc+Mn)/Mc - - G4double T_C12Star = KinEng_Int/13. + 1.0833333*Eng_Evap1 - T_N1; - - G4double theta_C12Star = 0.; - G4double phi_C12Star = phi_N1+Pi; - - if(T_C12Star > 1.e-5) - { - // 0.2664694 = sqrt(Mn*Mc)/(Mn+Mc) - // 0.2886751 = sqrt(Mn/Mc) - G4double Arg = (0.2664694*sqrt(KinEng_Int) - (0.2886751*sqrt(Eng_Evap1)*cos_theta_iso))/(sqrt(T_C12Star)); - if( Arg > 1.) - { Arg = 1.; } - theta_C12Star = acos(Arg); - } - - // Now neutron2 is emitted in the frame of the scattered C12* - // At the end, the angles are put back into the frame of the original neutron - - Available_Eng = KinEng_Int + Q_value - T_N1 - T_C12Star; - - if(Available_Eng < 0.) - { Available_Eng = 1.e-3; } - - G4double Eng_Evap2 = Evaporate_Eng(AMass_Material,Available_Eng); - - cos_theta_iso = 1.-(2.*G4UniformRand()); - - // .5773503 = 2*sqrt(Mn/Mc) - - G4double T_N2 = T_C12Star/12. + Eng_Evap2 + - (0.5773503*sqrt(T_C12Star*Eng_Evap2))*cos_theta_iso; - - G4double theta_C12_N2 = acos(cos_theta_iso); - G4double phi_C12_N2 = 2.*Pi*G4UniformRand(); - - // Now Start With Z-Axis and then go to incoming neutron frame ? - //G4ThreeVector MomDir_ZAxis = G4ThreeVector(0.,0.,1.); - - G4ThreeVector MomDir_ZAxis = MomDir_Int; - G4ThreeVector MomDir_C12Star = GenMomDir(MomDir_ZAxis,theta_C12Star,phi_C12Star); - - MomDir_N2 = GenMomDir(MomDir_C12Star,theta_C12_N2,phi_C12_N2); - - // C11 - Need to check kinematics - maybe not right - 18 Apr 2008, BTR - - G4double T_C11 = KinEng_Int + Q_value - T_N1 - T_N2; // Remaining Eng - if(T_C11 <= 0.) - {T_C11 = 1e-9;} - - G4double theta_C11 = Pi - theta_C12_N2; - G4double phi_C11 = Pi + phi_C12_N2; - - MomDir_C11 = GenMomDir(MomDir_Int,theta_C11,phi_C11); - -// Generate a Secondary Neutron1 - G4DynamicParticle* theSecNeutron1 = new G4DynamicParticle; - G4ParticleDefinition* theSecN1Definition = G4Neutron::Neutron(); - theSecNeutron1->SetDefinition(theSecN1Definition); - theSecNeutron1->SetKineticEnergy(T_N1); - theSecNeutron1->SetMomentumDirection(MomDir_N1); - -// Generate a Secondary Neutron2 - G4DynamicParticle* theSecNeutron2 = new G4DynamicParticle; - G4ParticleDefinition* theSecN2Definition = G4Neutron::Neutron(); - theSecNeutron2->SetDefinition(theSecN2Definition); - theSecNeutron2->SetKineticEnergy(T_N2); - theSecNeutron2->SetMomentumDirection(MomDir_N2); - - // Generate a Secondary C11 - G4DynamicParticle* theSecC11 = new G4DynamicParticle; - // GetIon() Method works whether particle exists in physicslist or not. - // Arguements are GetIon(Charge,Mass,ExcitationEng) - G4ParticleDefinition* theSecC11Definition = G4IonTable::GetIonTable()->GetIon(6,11,0.); - theSecC11->SetDefinition(theSecC11Definition); - theSecC11->SetKineticEnergy(T_C11); - theSecC11->SetMomentumDirection(MomDir_C11); + } + else if (ReactionName == "N_C12_NGamma") { + // 24 Apr. 2008 - BTR - This version replaces version in previous + // menate.cc to 12C(n,n'gamma) reaction in orig FORTRAN MENATE + + G4double Available_Eng; + + if (KinEng_Int >= 8.5 * MeV) { + Available_Eng = 8.5 * MeV * (G4UniformRand()); + } // Max available Eng = 8.5 MeV ? + else { + Available_Eng = KinEng_Int * G4UniformRand(); + } + + // G4double Total_Gamma_Eng = ShareGammaEngC12(Available_Eng); + // Changed such that one 4.4 MeV gamma is always produced if the + // nng4 reaction is called. + // if the energy is >4.43 MeV then 1 gamma is produced. + G4double enough_gamma_eng = 0 * MeV; + if (KinEng_Int >= 4.5 * MeV) + enough_gamma_eng = 5.0 * MeV; + G4double Total_Gamma_Eng = ShareGammaEngC12(enough_gamma_eng); + + G4ThreeVector MomDir_N; + G4ThreeVector MomDir_C12; + + // N' + + Available_Eng = 0.9230769 * KinEng_Int - Total_Gamma_Eng; + if (Available_Eng <= 0.) { + Available_Eng = 0.; + } // = 0 in Fortran code - BTR + + G4double cos_theta_iso = 1. - (2. * G4UniformRand()); + // zwk + if (fwrdANGLES) + cos_theta_iso = pow(G4UniformRand(), 1. / 4.0); + + G4double T_N = + KinEng_Int / 169. + 0.9230769 * Available_Eng + (0.1478106 * sqrt(KinEng_Int * Available_Eng)) * cos_theta_iso; + G4double theta_N = acos(cos_theta_iso); + G4double phi_N = 2. * Pi * G4UniformRand(); + + MomDir_N = GenMomDir(MomDir_Int, theta_N, phi_N); + + // C12* + + G4double T_C12 = KinEng_Int - T_N - Total_Gamma_Eng; + if (T_C12 <= 0.) { + T_C12 = 0.; + } + G4double theta_C12 = Pi - theta_N; + G4double phi_C12 = Pi + phi_N; + + MomDir_C12 = GenMomDir(MomDir_Int, theta_C12, phi_C12); + + // Generate a Secondary Neutron + G4DynamicParticle* theSecNeutron = new G4DynamicParticle; + G4ParticleDefinition* theSecNeutronDefinition = G4Neutron::Neutron(); + theSecNeutron->SetDefinition(theSecNeutronDefinition); + theSecNeutron->SetKineticEnergy(T_N); + theSecNeutron->SetMomentumDirection(MomDir_N); + + // Generate a Secondary C12* + G4DynamicParticle* theSecC12 = new G4DynamicParticle; + // GetIon() Method works whether particle exists in physicslist or not. + // Arguements are GetIon(Charge,Mass,ExcitationEng) + G4ParticleDefinition* theSecC12Definition = G4IonTable::GetIonTable()->GetIon(6, 12, 0.); + theSecC12->SetDefinition(theSecC12Definition); + theSecC12->SetKineticEnergy(T_C12); + theSecC12->SetMomentumDirection(MomDir_C12); + + // 4.439 MeV Gamma - emitted isotropically from reaction point.. + // -- 24 Apr 2008 - BTR - With 8.5 MeV limit given at start of + // MENATE function for this reaction, can not produce more + // than one 4.439 MeV gamma. + // - 19 May 2008 - BTR + // --- Removed 400 keV gamma ray counter from original MENATE code + + G4int NumberOfSec = 2 + Num_gamma_4439k; + aParticleChange.SetNumberOfSecondaries(NumberOfSec); + + // G4cout << Available_Eng/MeV << G4endl; + // G4cout << "Num gammas: " << Num_gamma_4439k << G4endl; + if (Num_gamma_4439k > 0) { + G4double T_Gamma = 4.439 * MeV; + G4double theta_Gamma = acos(1. - (2. * G4UniformRand())); + G4double phi_Gamma = 2. * Pi * G4UniformRand(); + + G4ThreeVector MomDir_Gamma; + MomDir_Gamma = GenMomDir(MomDir_Int, theta_Gamma, phi_Gamma); + + // Generate a Secondary Gamma (4.439 MeV) + G4DynamicParticle* theSecGamma = new G4DynamicParticle; + G4ParticleDefinition* theGammaDefinition = G4Gamma::Gamma(); + theSecGamma->SetDefinition(theGammaDefinition); + theSecGamma->SetKineticEnergy(T_Gamma); + theSecGamma->SetMomentumDirection(MomDir_Gamma); + + aParticleChange.SetNumberOfSecondaries(2 + Num_gamma_4439k); + + G4Track* theGammaTrack = new G4Track(theSecGamma, GlobalTime, thePosition); + theGammaTrack->SetTouchableHandle(theTouchable); + aParticleChange.AddSecondary(theGammaTrack); + } // Kill the Parent Neutron ----------------------- - aParticleChange.ProposeTrackStatus(fStopAndKill); - aParticleChange.ProposeEnergy(0.); - aParticleChange.ProposePosition(thePosition); - - // Set final tracks in motion! - G4Track* theN1Track = new G4Track(theSecNeutron1,GlobalTime,thePosition); - theN1Track->SetTouchableHandle(theTouchable); - G4Track* theN2Track = new G4Track(theSecNeutron2,GlobalTime,thePosition); - theN2Track->SetTouchableHandle(theTouchable); - G4Track* theC11Track = new G4Track(theSecC11,GlobalTime,thePosition); - theC11Track->SetTouchableHandle(theTouchable); - - aParticleChange.SetNumberOfSecondaries(3); - aParticleChange.AddSecondary(theN1Track); - aParticleChange.AddSecondary(theN2Track); - aParticleChange.AddSecondary(theC11Track); - - /* - G4double T_N_Sum = T_N1+T_N2; - G4cout << "n, 2n C11 event! " << G4endl; - G4cout << "T_N1 = " << T_N1 << "T_N2 = " << T_N2 << " , T_Sum = " << T_N_Sum << G4endl; - G4cout << "Total Eng Final State : " << T_N_Sum+T_C11 << " , Eng_Int+Qvalue = " << KinEng_Int+Q_value << G4endl; - */ + aParticleChange.ProposeTrackStatus(fStopAndKill); + aParticleChange.ProposeEnergy(0.); + aParticleChange.ProposePosition(thePosition); + + // Set final tracks in motion! + G4Track* theNTrack = new G4Track(theSecNeutron, GlobalTime, thePosition); + theNTrack->SetTouchableHandle(theTouchable); + G4Track* theC12Track = new G4Track(theSecC12, GlobalTime, thePosition); + theC12Track->SetTouchableHandle(theTouchable); + + aParticleChange.AddSecondary(theNTrack); + aParticleChange.AddSecondary(theC12Track); + // G4cout << "Made it to the end ! " << G4endl; - } -else if(ReactionName == "N_C12_NN3Alpha") - { - // Reaction copied from MENATE - // Treated as : - // n + 12C ---> 12C* + n' - // 12C* ---> 8Be + alpha1 - // 8Be* ---> alpha2+alpha3 - - G4double Q_value = -7.275*MeV; - - G4ThreeVector MomDir_N; - G4ThreeVector MomDir_Alpha1; - G4ThreeVector MomDir_Alpha2; - G4ThreeVector MomDir_Alpha3; - - // Scattered neutron (n') - G4double Available_Eng = 0.9230769*KinEng_Int+Q_value; - - if(Available_Eng < 0.) - { Available_Eng = 1.e-3; } - - G4double Eng_Evap1 = Evaporate_Eng(AMass_Material,Available_Eng); - - G4double cos_theta_iso = 1.-(2.*G4UniformRand()); - //zwk - if(fwrdANGLES) cos_theta_iso = pow(G4UniformRand(),1./4.0); - - // 1/169. = (Mn/(Mn+Mc))^2 - // 0.1538462 = 2Mn/(Mn+Mc) - - G4double T_N = KinEng_Int/169. + Eng_Evap1 + (0.1538462*sqrt(KinEng_Int*Eng_Evap1))*cos_theta_iso; - - G4double theta_N = 0.; - G4double phi_N = 0.; - - if(T_N > 1.e-5) - { - // 1/13. = Mn/(Mn+Mc) - - G4double Arg = (sqrt(KinEng_Int)/13. + (sqrt(Eng_Evap1)*cos_theta_iso))/(sqrt(T_N)); - if( Arg > 1.) - { Arg = 1.; } - theta_N = acos(Arg); - phi_N = 2.*Pi*G4UniformRand(); - } - - MomDir_N = GenMomDir(MomDir_Int,theta_N,phi_N); - - // Scattered 12C* - // 1/13. = Mn(Mc+Mn) - // 1.0833333 = (Mc+Mn)/Mc - - G4double T_C12Star = KinEng_Int/13. + 1.0833333*Eng_Evap1 - T_N; - - G4double theta_C12Star = 0.; - G4double phi_C12Star = phi_N+Pi; - - if(T_C12Star > 1.e-5) - { - // 0.2664694 = sqrt(Mn*Mc)/(Mn+Mc) - // 0.2886751 = sqrt(Mn/Mc) - G4double Arg = (0.2664694*sqrt(KinEng_Int) - (0.2886751*sqrt(Eng_Evap1)*cos_theta_iso))/(sqrt(T_C12Star)); - if( Arg > 1.) - { Arg = 1.; } - theta_C12Star = acos(Arg); - } - - // Now Alpha1 is emitted in the frame of the scattered C12* - // At the end, the angles are put back into the frame of the original neutron - - Available_Eng = (KinEng_Int + Q_value - T_N - T_C12Star)*G4UniformRand(); - - if(Available_Eng < 0.) - { Available_Eng = 0.; } - - cos_theta_iso = 1.-(2.*G4UniformRand()); - - // 1./3. = MA1/MC12 - // 0.6666667 = MBe8/MC12 - // 0.9428090 = 2*sqrt(Malpha*M8Be)/Mc12) - - G4double T_Alpha1 = T_C12Star/3. + 0.6666667*Available_Eng + - (0.9428090*sqrt(Available_Eng*T_C12Star))*cos_theta_iso; - - G4double theta_Alpha1 = 0.; - G4double phi_Alpha1 = 0.; - - if(T_Alpha1 > 1.e-5) - { - // 0.5773503 = sqrt(Malpha/MC12) - // 0.8164966 = sqrt((MBe8)/(MC12)) - - G4double Arg = (0.5773503*sqrt(T_C12Star) + 0.8164966*sqrt(Available_Eng)*cos_theta_iso)/(sqrt(T_Alpha1)); - if( Arg > 1.) - { Arg = 1.; } - theta_Alpha1 = acos(Arg); - phi_Alpha1 = 2.*Pi*G4UniformRand(); - } - - // Now Start With Z-Axis and then go to incoming neutron frame ? - // G4ThreeVector MomDir_ZAxis = G4ThreeVector(0.,0.,1.); - G4ThreeVector MomDir_ZAxis = MomDir_Int; - G4ThreeVector MomDir_C12Star = GenMomDir(MomDir_ZAxis,theta_C12Star,phi_C12Star); - - MomDir_Alpha1 = GenMomDir(MomDir_C12Star,theta_Alpha1,phi_Alpha1); - - // Be8* Kinematics --- Particle decayed into the other alphas - // Angles in frame of scattered C12* - - G4double T_Be8Star = T_C12Star + Available_Eng - T_Alpha1; // Remaining Eng - - G4double theta_Be8Star = 0.; - G4double phi_Be8Star = phi_Alpha1+Pi; - - if(T_Be8Star > 1.e-5) - { - // 0.5773503 = sqrt(Malpha/MC12) - // 0.8164966 = sqrt(M8Be/MC12) - G4double Arg = (0.8164966*sqrt(T_C12Star) - (0.5773503*sqrt(Available_Eng)*cos_theta_iso))/(sqrt(T_Be8Star)); - if( Arg > 1.) - { Arg = 1.; } - theta_Be8Star = acos(Arg); - } - - G4ThreeVector MomDir_Be8Star = GenMomDir(MomDir_C12Star,theta_Be8Star,phi_Be8Star); - - // Now Decay 8Be g.s. into 2 Alphas - // Q_value = 0.092*MeV - - G4double Q_valueBe8 = 0.092*MeV; - Available_Eng = KinEng_Int+Q_value+Q_valueBe8-T_N-T_Alpha1-T_Be8Star; // Changed 23 Apr 2008 - BTR - - if(Available_Eng < 0.) - {Available_Eng = 0.;} - - cos_theta_iso = 1.-(2.*G4UniformRand()); - - // 0.5 = MA2/Be8 - - G4double T_Alpha2 = 0.5*(T_Be8Star+Available_Eng) + - (sqrt(Available_Eng*T_Be8Star))*cos_theta_iso; - if(T_Alpha2 < 0.) - {T_Alpha2 = 1e-9;} - - G4double theta_Alpha2 = 0.; - G4double phi_Alpha2 = 0.; - - if(T_Alpha2 > 1.e-5) - { - // 0.7071068 = sqrt(Malpha/MBe8) - - G4double Arg = (0.7071068*(sqrt(T_Be8Star) + sqrt(Available_Eng)*cos_theta_iso))/(sqrt(T_Alpha2)); - if( Arg > 1.) - { Arg = 1.; } - theta_Alpha2 = acos(Arg); - phi_Alpha2 = 2.*Pi*G4UniformRand(); - } - - MomDir_Alpha2 = GenMomDir(MomDir_Be8Star,theta_Alpha2,phi_Alpha2); - - // Alpha3 emitted in frame of Be8 - - G4double T_Alpha3 = T_Be8Star + Available_Eng - T_Alpha2; - if(T_Alpha3 < 0.) - {T_Alpha3 = 1e-9;} - - G4double theta_Alpha3 = 0.; - G4double phi_Alpha3 = phi_Alpha2+Pi; - - if(T_Alpha3 > 1.e-5) - { - // 0.7071068 = sqrt(Malpha/MBe8) - - G4double Arg = (0.7071068*(sqrt(T_Be8Star) - sqrt(Available_Eng)*cos_theta_iso))/(sqrt(T_Alpha3)); - if( Arg > 1.) - { Arg = 1.; } - theta_Alpha3 = acos(Arg); - } - - MomDir_Alpha3 = GenMomDir(MomDir_Be8Star,theta_Alpha3,phi_Alpha3); - -// Generate a Secondary Neutron - G4DynamicParticle* theSecNeutron = new G4DynamicParticle; - G4ParticleDefinition* theSecNDefinition = G4Neutron::Neutron(); - theSecNeutron->SetDefinition(theSecNDefinition); - theSecNeutron->SetKineticEnergy(T_N); - theSecNeutron->SetMomentumDirection(MomDir_N); - -// Generate a Secondary Alpha1 - G4DynamicParticle* theSecAlpha1 = new G4DynamicParticle; - G4ParticleDefinition* theSecA1Definition = G4Alpha::Alpha(); - theSecAlpha1->SetDefinition(theSecA1Definition); - theSecAlpha1->SetKineticEnergy(T_Alpha1); - theSecAlpha1->SetMomentumDirection(MomDir_Alpha1); - -// Generate a Secondary Alpha2 - G4DynamicParticle* theSecAlpha2 = new G4DynamicParticle; - G4ParticleDefinition* theSecA2Definition = G4Alpha::Alpha(); - theSecAlpha2->SetDefinition(theSecA2Definition); - theSecAlpha2->SetKineticEnergy(T_Alpha2); - theSecAlpha2->SetMomentumDirection(MomDir_Alpha2); - -// Generate a Secondary Alpha3 - G4DynamicParticle* theSecAlpha3 = new G4DynamicParticle; - G4ParticleDefinition* theSecA3Definition = G4Alpha::Alpha(); - theSecAlpha3->SetDefinition(theSecA3Definition); - theSecAlpha3->SetKineticEnergy(T_Alpha3); - theSecAlpha3->SetMomentumDirection(MomDir_Alpha3); - - + } + else if (ReactionName == "N_C12_A_Be9") { + // Copied from MENATE + // Reaction can not occur if incoming neutron energy is below 6.176 MeV + // Q Value = - 5.701 MeV + + // Uses formula for C12 recoil to calculate direction of 9Be + + G4ThreeVector MomDir_Alpha; + G4ThreeVector MomDir_Be9; + + G4double Q_value = -5.701 * MeV; + // 0.9230769 = Mass_C12/(Mass_N+Mass_C12) - converts to CM frame energy + G4double Available_Eng = 0.9230769 * KinEng_Int + Q_value; + + if (Available_Eng <= 0.) { + Available_Eng = 0.; + } + + // the alpha + + G4double cos_theta_iso = 1. - (2. * G4UniformRand()); + // zwk + if (fwrdANGLES) + cos_theta_iso = pow(G4UniformRand(), 1. / 4.0); + + // 0.0236686 = Malpha*MassN/(MassC12+MassN)^2 + // 0.6923077 = MBe9/(MassN+MassC12) + // 0.2560155 = 2.*sqrt(Mn*MBe9*Malpha/(MassC12+MassN)^3) + + G4double T_Alpha = 0.0236686 * KinEng_Int + 0.6923077 * Available_Eng + + (0.2560155 * sqrt(KinEng_Int * Available_Eng)) * cos_theta_iso; + + G4double theta_Alpha = 0.; + G4double phi_Alpha = 0.; + + if (T_Alpha > 1.e-5) { + // 0.1538462 = sqrt(Malpha*Mn)/(Mn+Mc12) + // 0.8320503 = sqrt(MBe9/(MassC12+MassN)) + + G4double Arg = (0.1538462 * sqrt(KinEng_Int) + 0.8320503 * sqrt(Available_Eng) * cos_theta_iso) / (sqrt(T_Alpha)); + + if (Arg > 1.) { + Arg = 1.; + } + + theta_Alpha = acos(Arg); + phi_Alpha = 2. * Pi * G4UniformRand(); + } + + MomDir_Alpha = GenMomDir(MomDir_Int, theta_Alpha, phi_Alpha); + + // Be9 - Need to check kinematics - maybe not right - 18 Apr 2008, BTR + + G4double T_Be9 = KinEng_Int + Q_value - T_Alpha; + G4double theta_Be9 = Pi - theta_Alpha; + G4double phi_Be9 = Pi + phi_Alpha; + + MomDir_Be9 = GenMomDir(MomDir_Int, theta_Be9, phi_Be9); + + // Generate a Secondary Alpha + G4DynamicParticle* theSecAlpha = new G4DynamicParticle; + G4ParticleDefinition* theSecAlphaDefinition = G4Alpha::Alpha(); + theSecAlpha->SetDefinition(theSecAlphaDefinition); + theSecAlpha->SetKineticEnergy(T_Alpha); + theSecAlpha->SetMomentumDirection(MomDir_Alpha); + + // Generate a Secondary Be9 + G4DynamicParticle* theSecBe9 = new G4DynamicParticle; + // GetIon() Method works whether particle exists in physicslist or not. + // Arguements are GetIon(Charge,Mass,ExcitationEng) + G4ParticleDefinition* theSecBe9Definition = G4IonTable::GetIonTable()->GetIon(4, 9, 0.); + theSecBe9->SetDefinition(theSecBe9Definition); + theSecBe9->SetKineticEnergy(T_Be9); + theSecBe9->SetMomentumDirection(MomDir_Be9); + // Kill the Parent Neutron ----------------------- - aParticleChange.ProposeTrackStatus(fStopAndKill); - aParticleChange.ProposeEnergy(0.); - aParticleChange.ProposePosition(thePosition); - - // Set final tracks in motion! - G4Track* theNTrack = new G4Track(theSecNeutron,GlobalTime,thePosition); - theNTrack->SetTouchableHandle(theTouchable); - G4Track* theA1Track = new G4Track(theSecAlpha1,GlobalTime,thePosition); - theA1Track->SetTouchableHandle(theTouchable); - G4Track* theA2Track = new G4Track(theSecAlpha2,GlobalTime,thePosition); - theA2Track->SetTouchableHandle(theTouchable); - G4Track* theA3Track = new G4Track(theSecAlpha3,GlobalTime,thePosition); - theA3Track->SetTouchableHandle(theTouchable); - - aParticleChange.SetNumberOfSecondaries(4); - aParticleChange.AddSecondary(theNTrack); - aParticleChange.AddSecondary(theA1Track); - aParticleChange.AddSecondary(theA2Track); - aParticleChange.AddSecondary(theA3Track); - - /* - G4double T_A_Sum = T_Alpha1+T_Alpha2+T_Alpha3; - - G4cout << "n, n'3alpha event! " << G4endl; - G4cout << "T_N = " << T_N << G4endl; - G4cout << "A1 = " << T_Alpha1 << " ,A2 = " << T_Alpha2 << " , A3 = " << T_Alpha3 << ", A_Sum = " << T_A_Sum << G4endl; - G4cout << "Total Eng Final State : " << T_A_Sum+T_N << " , Eng_Int-Qvalue = " << KinEng_Int-7.275+0.092 << G4endl; - */ - // G4cout << "Made it to the end ! " << G4endl; - } - else if(ReactionName == "N_Fe_elastic") - { - G4double theta_N = 0.; - G4double phi_N = 0.; - - G4double T_N = 0.; -// G4double T_Feel = 0.; - G4ThreeVector MomDir_N; - G4ThreeVector MomDir_Fe; - - /* - //Just going to use isotropic distribution in CM - //However good consider using C12 elastic scattering, may be similar - G4double cos_sq_theta = G4UniformRand(); - - // Calls diffractive angular distribution as in DEMONS - //G4double cos_theta_cm = NC12_DIFF(KinEng_Int); - // Convert according to Knoll - //G4double cos_theta_lab = sqrt((1.-cos_theta_cm)/2.); - //G4double cos_sq_theta = pow(cos_theta_lab,2); - - // .070177 =4*Mfe*Mn/(Mfe+Mn)^2 - T_Feel = 0.07017*KinEng_Int*cos_sq_theta; - - T_N = KinEng_Int - T_Feel; - - if(T_N > 1.e-5) - { - G4double arg = (sqrt(KinEng_Int)-sqrt(12.*T_Feel*cos_sq_theta))/sqrt(T_N); - if(arg > 1.) - {arg = 1.;} - theta_N = acos(arg); - phi_N = 2.*Pi*G4UniformRand(); - } - - MomDir_N = GenMomDir(MomDir_Int,theta_N,phi_N); - - // Carbon angles - G4double theta_Fe = acos(sqrt(cos_sq_theta)); - G4double phi_Fe = phi_N+Pi; - - MomDir_Fe = GenMomDir(MomDir_Int,theta_Fe,phi_Fe); - */ - - - double cos_theta_cm = FeElastic_AngDist(KinEng_Int); // cosine of cm_angle - if(cos_theta_cm > 1) cos_theta_cm = 1; - double theta_cm = acos(cos_theta_cm); // of neutron - - // Following Knoll, calculate energy for proton first - double cos_theta_lab_Fe = sqrt((1.-cos_theta_cm)/2.); - double theta_lab_Fe = acos(cos_theta_lab_Fe); - double phi_Fe = 2.*Pi*G4UniformRand(); - - double T_Fe = KinEng_Int*pow(cos_theta_lab_Fe,2)*4*56/pow(57.,2.); - - MomDir_Fe = GenMomDir(MomDir_Int,theta_lab_Fe,phi_Fe); - - // scattered neutron ---------------- - // angles changed from cm to lab as in Marian and Young - theta_N = atan(sin(theta_cm)/(cos_theta_cm+(1/56)) ); - phi_N = phi_Fe+Pi; - - T_N = KinEng_Int - T_Fe; - - MomDir_N = GenMomDir(MomDir_Int,theta_N,phi_N); - - // Generate a Secondary Neutron - G4DynamicParticle* theSecNeutron = new G4DynamicParticle; - G4ParticleDefinition* theSecNeutronDefinition = G4Neutron::Neutron(); - theSecNeutron->SetDefinition(theSecNeutronDefinition); - theSecNeutron->SetKineticEnergy(T_N); - theSecNeutron->SetMomentumDirection(MomDir_N); - - // This is where you would generate the recoil Fe nucleus - //However for our purpose (Fe is only in sweeper) we don't - //need to keep track. - //G4DynamicParticle* theSecC12 = new G4DynamicParticle; - // GetIon() Method works whether particle exists in physicslist or not. - // Arguements are GetIon(Charge,Mass,ExcitationEng) - //G4ParticleDefinition* theSecC12Definition = G4IonTable::GetIonTable()->GetIon(6,12,0.); - //theSecC12->SetDefinition(theSecC12Definition); - //theSecC12->SetKineticEnergy(T_C12el); - //theSecC12->SetMomentumDirection(MomDir_C12); - - // Kill the Parent Neutron ----------------------- - aParticleChange.ProposeTrackStatus(fStopAndKill); - aParticleChange.ProposeEnergy(0.); - aParticleChange.ProposePosition(thePosition); - - // Set final tracks in motion! - G4Track* theNTrack = new G4Track(theSecNeutron,GlobalTime,thePosition); - theNTrack->SetTouchableHandle(theTouchable); - //G4Track* theC12Track = new G4Track(theSecC12,GlobalTime,thePosition); - //theC12Track->SetTouchableHandle(theTouchable); - - aParticleChange.SetNumberOfSecondaries(1); - aParticleChange.AddSecondary(theNTrack); - //aParticleChange.AddSecondary(theC12Track); - - // G4cout << "Made it to the end ! " << G4endl; - //G4cout << "Finished Elastic Scatter of Fe" << G4endl; - } - else if(ReactionName == "N_Fe_nonelastic") - { - - //For our purposes we are going to treat the non-elastic Fe interactions as absorption of the neutrons - //the idea is that after the interaction the neutron would be slowed and may not make it into the timing gate - //furthermore we don't have enought information (beyond the cross sections) to know how to handle the - //non-elastic processes. - - - // Kill the Parent Neutron ----------------------- - aParticleChange.ProposeTrackStatus(fStopAndKill); - aParticleChange.ProposeEnergy(0.); - aParticleChange.ProposePosition(thePosition); - - aParticleChange.SetNumberOfSecondaries(0); - //aParticleChange.AddSecondary(theNTrack); - //aParticleChange.AddSecondary(theC12Track); - - // G4cout << "Made it to the end ! " << G4endl; - //G4cout << "Finished Fe Non-Elastic Process" << G4endl; - } - else if(ReactionName == "N_Al_elastic") - { - - G4double theta_N = 0.; - G4double phi_N = 0.; - - G4double T_N = 0.; -// G4double T_Feel = 0.; - G4ThreeVector MomDir_N; - G4ThreeVector MomDir_Al; - - /* - //Just going to use isotropic distribution in CM - //However good consider using C12 elastic scattering, may be similar - G4double cos_sq_theta = G4UniformRand(); - - // Calls diffractive angular distribution as in DEMONS - //G4double cos_theta_cm = NC12_DIFF(KinEng_Int); - // Convert according to Knoll - //G4double cos_theta_lab = sqrt((1.-cos_theta_cm)/2.); - //G4double cos_sq_theta = pow(cos_theta_lab,2); - - // .070177 =4*Mfe*Mn/(Mfe+Mn)^2 - T_Feel = 0.07017*KinEng_Int*cos_sq_theta; - - T_N = KinEng_Int - T_Feel; - - if(T_N > 1.e-5) - { - G4double arg = (sqrt(KinEng_Int)-sqrt(12.*T_Feel*cos_sq_theta))/sqrt(T_N); - if(arg > 1.) - {arg = 1.;} - theta_N = acos(arg); - phi_N = 2.*Pi*G4UniformRand(); - } - - MomDir_N = GenMomDir(MomDir_Int,theta_N,phi_N); - - // Carbon angles - G4double theta_Fe = acos(sqrt(cos_sq_theta)); - G4double phi_Fe = phi_N+Pi; - - MomDir_Fe = GenMomDir(MomDir_Int,theta_Fe,phi_Fe); - */ - - - double cos_theta_cm = AlElastic_AngDist(KinEng_Int); // cosine of cm_angle - if(cos_theta_cm > 1) cos_theta_cm = 1; - double theta_cm = acos(cos_theta_cm); // of neutron - - // Following Knoll, calculate energy for proton first - double cos_theta_lab_Al = sqrt((1.-cos_theta_cm)/2.); - double theta_lab_Al = acos(cos_theta_lab_Al); - double phi_Al = 2.*Pi*G4UniformRand(); - - double T_Al = KinEng_Int*pow(cos_theta_lab_Al,2)*4*27/pow(28.,2); - - //G4cout << "Al theta: " << cos_theta_cm << " " << theta_cm << " " << cos_theta_lab_Al << " " << theta_lab_Al << G4endl; - //G4cout << "Al KE: " << T_Al/MeV << " Init_N KE: " << KinEng_Int/MeV << G4endl; - - MomDir_Al = GenMomDir(MomDir_Int,theta_lab_Al,phi_Al); - - // scattered neutron ---------------- - // angles changed from cm to lab as in Marian and Young - theta_N = atan(sin(theta_cm)/(cos_theta_cm+(1/27)) ); - phi_N = phi_Al+Pi; - - T_N = KinEng_Int - T_Al; - - MomDir_N = GenMomDir(MomDir_Int,theta_N,phi_N); - - // Generate a Secondary Neutron - G4DynamicParticle* theSecNeutron = new G4DynamicParticle; - G4ParticleDefinition* theSecNeutronDefinition = G4Neutron::Neutron(); - theSecNeutron->SetDefinition(theSecNeutronDefinition); - theSecNeutron->SetKineticEnergy(T_N); - theSecNeutron->SetMomentumDirection(MomDir_N); - - // This is where you would generate the recoil Fe nucleus - //However for our purpose (Fe is only in sweeper) we don't - //need to keep track. - //G4DynamicParticle* theSecC12 = new G4DynamicParticle; - // GetIon() Method works whether particle exists in physicslist or not. - // Arguements are GetIon(Charge,Mass,ExcitationEng) - //G4ParticleDefinition* theSecC12Definition = G4IonTable::GetIonTable()->GetIon(6,12,0.); - //theSecC12->SetDefinition(theSecC12Definition); - //theSecC12->SetKineticEnergy(T_C12el); - //theSecC12->SetMomentumDirection(MomDir_C12); - - // Kill the Parent Neutron ----------------------- - aParticleChange.ProposeTrackStatus(fStopAndKill); - aParticleChange.ProposeEnergy(0.); - aParticleChange.ProposePosition(thePosition); - - // Set final tracks in motion! - G4Track* theNTrack = new G4Track(theSecNeutron,GlobalTime,thePosition); - theNTrack->SetTouchableHandle(theTouchable); - //G4Track* theC12Track = new G4Track(theSecC12,GlobalTime,thePosition); - //theC12Track->SetTouchableHandle(theTouchable); - - aParticleChange.SetNumberOfSecondaries(1); - aParticleChange.AddSecondary(theNTrack); - //aParticleChange.AddSecondary(theC12Track); - - // G4cout << "Made it to the end ! " << G4endl; - //G4cout << "Finished Elastic Scatter of Fe" << G4endl; - } - else if(ReactionName == "N_Al_nonelastic") - { - - //For our purposes we are going to treat the non-elastic Fe interactions as absorption of the neutrons - //the idea is that after the interaction the neutron would be slowed and may not make it into the timing gate - //furthermore we don't have enought information (beyond the cross sections) to know how to handle the - //non-elastic processes. - - - // Kill the Parent Neutron ----------------------- - aParticleChange.ProposeTrackStatus(fStopAndKill); - aParticleChange.ProposeEnergy(0.); - aParticleChange.ProposePosition(thePosition); - - aParticleChange.SetNumberOfSecondaries(0); - //aParticleChange.AddSecondary(theNTrack); - //aParticleChange.AddSecondary(theC12Track); - - // G4cout << "Made it to the end ! " << G4endl; - //G4cout << "Finished Fe Non-Elastic Process" << G4endl; - } + aParticleChange.ProposeTrackStatus(fStopAndKill); + aParticleChange.ProposeEnergy(0.); + aParticleChange.ProposePosition(thePosition); + + // Set final tracks in motion! + G4Track* theAlphaTrack = new G4Track(theSecAlpha, GlobalTime, thePosition); + theAlphaTrack->SetTouchableHandle(theTouchable); + G4Track* theBe9Track = new G4Track(theSecBe9, GlobalTime, thePosition); + theBe9Track->SetTouchableHandle(theTouchable); + + aParticleChange.SetNumberOfSecondaries(2); + aParticleChange.AddSecondary(theAlphaTrack); + aParticleChange.AddSecondary(theBe9Track); + + /* + //---Test Momentum Conservation---- + G4cout << "\n\n------------------"<< G4endl; + + //incoming neutron + G4DynamicParticle *p1 = (G4DynamicParticle*) aTrack.GetDynamicParticle(); + G4ThreeVector vec1 = p1->GetMomentum(); + G4cout << "p1, px: " << vec1.x()/MeV << " py: " << vec1.y()/MeV << " pz: " << vec1.z()/MeV << " mag: " << + vec1.mag()/MeV << G4endl; G4cout << " Total Mom: " << p1 ->GetTotalMomentum()/MeV << " TotalE: " << + p1->GetTotalEnergy()/MeV << " KE: " << p1->GetKineticEnergy()/MeV << G4endl; + + + G4DynamicParticle *p2 = (G4DynamicParticle*) theAlphaTrack->GetDynamicParticle(); + G4ThreeVector vec2 = p2->GetMomentum(); + G4cout << "p2, px: " << vec2.x()/MeV << " py: " << vec2.y()/MeV << " pz: " << vec2.z()/MeV << " mag: " << + vec2.mag()/MeV << G4endl; G4cout << " Total Mom: " << p2->GetTotalMomentum()/MeV << " TotalE: " << + p2->GetTotalEnergy()/MeV << " KE: " << p2->GetKineticEnergy()/MeV << G4endl; + + G4DynamicParticle *p3 = (G4DynamicParticle*) theBe9Track->GetDynamicParticle(); + G4ThreeVector vec3 = p3->GetMomentum(); + G4cout << "p3, px: " << vec3.x()/MeV << " py: " << vec3.y()/MeV << " pz: " << vec3.z()/MeV << " mag: " << + vec3.mag()/MeV << G4endl; G4cout << " Total Mom: " << p3->GetTotalMomentum()/MeV << " TotalE: " << + p3->GetTotalEnergy()/MeV << " KE: " << p3->GetKineticEnergy()/MeV << G4endl; + //----------- + */ + + // G4cout << "Made it to the end ! " << G4endl; + } + else if (ReactionName == "N_C12_P_B12") { + // Charge exchange Reaction copied from MENATE + G4double Q_value = -12.587 * MeV; + + G4ThreeVector MomDir_P; + G4ThreeVector MomDir_B12; + + G4double Available_Eng = 0.9230769 * KinEng_Int + Q_value; + + if (Available_Eng < 0.) { + Available_Eng = 0.; + } + + // the proton + + G4double cos_theta_iso = 1. - (2. * G4UniformRand()); + // zwk + if (fwrdANGLES) + cos_theta_iso = pow(G4UniformRand(), 1. / 4.0); + + // 1/169. = Mp*Mn/(Mn+MC12)^2 + // .9230769 = MB12/(Mn+MC12) + // .1478106 = 2*sqrt(Mn*MB12*Mp/(Mc12+Mn)^3) + + G4double T_P = + KinEng_Int / 169. + 0.9230769 * Available_Eng + (0.1478106 * sqrt(KinEng_Int * Available_Eng)) * cos_theta_iso; + + G4double theta_P = 0.; + G4double phi_P = 0.; + + if (T_P > 1.e-5) { + // 1/13. = sqrt(Mp*Mn)/(Mn+Mc) + // 0.9607689 = sqrt(MB12/(Mn+MC12)) + + G4double Arg = (sqrt(KinEng_Int) / 13. + 0.9607689 * sqrt(Available_Eng) * cos_theta_iso) / (sqrt(T_P)); + if (Arg > 1.) { + Arg = 1.; + } + theta_P = acos(Arg); + phi_P = 2. * Pi * G4UniformRand(); + } + + MomDir_P = GenMomDir(MomDir_Int, theta_P, phi_P); + + // B12 - Need to check kinematics - maybe not right - 18 Apr 2008, BTR + + G4double T_B12 = KinEng_Int + Q_value - T_P; + G4double theta_B12 = Pi - theta_P; + G4double phi_B12 = Pi + phi_P; + + MomDir_B12 = GenMomDir(MomDir_Int, theta_B12, phi_B12); + + // Generate a Secondary Proton + G4DynamicParticle* theSecProton = new G4DynamicParticle; + G4ParticleDefinition* theSecPDefinition = G4Proton::Proton(); + theSecProton->SetDefinition(theSecPDefinition); + theSecProton->SetKineticEnergy(T_P); + theSecProton->SetMomentumDirection(MomDir_P); + + // Generate a Secondary B12 + G4DynamicParticle* theSecB12 = new G4DynamicParticle; + // GetIon() Method works whether particle exists in physicslist or not. + // Arguements are GetIon(Charge,Mass,ExcitationEng) + G4ParticleDefinition* theSecB12Definition = G4IonTable::GetIonTable()->GetIon(5, 12, 0.); + theSecB12->SetDefinition(theSecB12Definition); + theSecB12->SetKineticEnergy(T_B12); + theSecB12->SetMomentumDirection(MomDir_B12); + + // Kill the Parent Neutron ----------------------- + aParticleChange.ProposeTrackStatus(fStopAndKill); + aParticleChange.ProposeEnergy(0.); + aParticleChange.ProposePosition(thePosition); + + // Set final tracks in motion! + G4Track* thePTrack = new G4Track(theSecProton, GlobalTime, thePosition); + thePTrack->SetTouchableHandle(theTouchable); + G4Track* theB12Track = new G4Track(theSecB12, GlobalTime, thePosition); + theB12Track->SetTouchableHandle(theTouchable); + + aParticleChange.SetNumberOfSecondaries(2); + aParticleChange.AddSecondary(thePTrack); + aParticleChange.AddSecondary(theB12Track); + + // G4cout << "Made it to the end ! " << G4endl; + } + else if (ReactionName == "N_C12_NNP_B11") { + // Reaction copied from MENATE + // Treated as : + // n + 12C ---> 12C* + n' + // 12C* ---> 11B + p + + G4double Q_value = -15.956 * MeV; + + G4ThreeVector MomDir_N; + G4ThreeVector MomDir_P; + G4ThreeVector MomDir_B11; + + // Scattered neutron (n') + G4double Available_Eng = 0.9230769 * KinEng_Int + Q_value; + + if (Available_Eng < 0.) { + Available_Eng = 1.e-3; + } + + G4double Eng_Evap1 = Evaporate_Eng(AMass_Material, Available_Eng); + + G4double cos_theta_iso = 1. - 2. * G4UniformRand(); + // zwk + if (fwrdANGLES) + cos_theta_iso = pow(G4UniformRand(), 1. / 4.0); + + // 1/169. = (Mn/(Mn+Mc))^2 + // 0.1538462 = 2Mn/(Mn+Mc) + + G4double T_N = KinEng_Int / 169. + Eng_Evap1 + (0.1538462 * sqrt(KinEng_Int * Eng_Evap1)) * cos_theta_iso; + + G4double theta_N = 0.; + G4double phi_N = 0.; + + if (T_N > 1.e-5) { + // 1/13. = Mn/(Mn+Mc) + + G4double Arg = (sqrt(KinEng_Int) / 13. + (sqrt(Eng_Evap1) * cos_theta_iso)) / (sqrt(T_N)); + if (Arg > 1.) { + Arg = 1.; + } + theta_N = acos(Arg); + phi_N = 2. * Pi * G4UniformRand(); + // G4cout << "12C(n,np)11B angle of neutron: " << theta_N*180/3.14 << G4endl; + } + + MomDir_N = GenMomDir(MomDir_Int, theta_N, phi_N); + + // Scattered 12C* + // 1/13. = Mn(Mc+Mn) + // 1.0833333 = (Mc+Mn)/Mc + + G4double T_C12Star = KinEng_Int / 13. + 1.0833333 * Eng_Evap1 - T_N; + + G4double theta_C12Star = 0.; + G4double phi_C12Star = phi_N + Pi; + + if (T_C12Star > 1.e-5) { + // 0.2664694 = sqrt(Mn*Mc)/(Mn+Mc) + // 0.2886751 = sqrt(Mn/Mc) + G4double Arg = (0.2664694 * sqrt(KinEng_Int) - (0.2886751 * sqrt(Eng_Evap1) * cos_theta_iso)) / (sqrt(T_C12Star)); + if (Arg > 1.) { + Arg = 1.; + } + theta_C12Star = acos(Arg); + } + + // Now the proton is emitted in the frame of the scattered C12* + // At the end, the angles are put back into the frame of the original neutron + + Available_Eng = KinEng_Int + Q_value - T_N - T_C12Star; + + if (Available_Eng < 0.) { + Available_Eng = 0.; + } + + cos_theta_iso = 1. - (2. * G4UniformRand()); + + // 1/12. = Mp/MC12 + // .9166667 = MB11/MC12 + // .5527708 = 2*sqrt(MB11*Mp)/Mc + + G4double T_P = + T_C12Star / 12. + 0.9166667 * Available_Eng + (0.5527708 * sqrt(Available_Eng * T_C12Star)) * cos_theta_iso; + + G4double theta_C12_P = 0.; + G4double phi_C12_P = 0.; + + if (T_P > 1.e-5) { + // 0.2886751 = sqrt(Mp/Mc) + // 0.9574271 = sqrt((MB11)/(MC12)) + + G4double Arg = (0.2886751 * sqrt(T_C12Star) + 0.9574271 * sqrt(Available_Eng) * cos_theta_iso) / (sqrt(T_P)); + if (Arg > 1.) { + Arg = 1.; + } + theta_C12_P = acos(Arg); + phi_C12_P = 2. * Pi * G4UniformRand(); + } + + // Now Start With Z-Axis and then go to incoming neutron frame ? + // G4ThreeVector MomDir_ZAxis = G4ThreeVector(0.,0.,1.); + + G4ThreeVector MomDir_ZAxis = MomDir_Int; + G4ThreeVector MomDir_C12Star = GenMomDir(MomDir_ZAxis, theta_C12Star, phi_C12Star); + + MomDir_P = GenMomDir(MomDir_C12Star, theta_C12_P, phi_C12_P); + + // B11 - Need to check kinematics - maybe not right - 18 Apr 2008, BTR + + G4double T_B11 = KinEng_Int + Q_value - T_N - T_P; // Remaining Eng + if (T_B11 < 0.) { + T_B11 = 1e-9; + } + + G4double theta_B11 = Pi - theta_C12_P; + G4double phi_B11 = Pi + phi_C12_P; + + MomDir_B11 = GenMomDir(MomDir_Int, theta_B11, phi_B11); + + // Generate a Secondary Neutron + G4DynamicParticle* theSecNeutron = new G4DynamicParticle; + G4ParticleDefinition* theSecNDefinition = G4Neutron::Neutron(); + theSecNeutron->SetDefinition(theSecNDefinition); + theSecNeutron->SetKineticEnergy(T_N); + theSecNeutron->SetMomentumDirection(MomDir_N); + + // Generate a Secondary Proton + G4DynamicParticle* theSecProton = new G4DynamicParticle; + G4ParticleDefinition* theSecPDefinition = G4Proton::Proton(); + theSecProton->SetDefinition(theSecPDefinition); + theSecProton->SetKineticEnergy(T_P); + theSecProton->SetMomentumDirection(MomDir_P); + + // Generate a Secondary B11 + G4DynamicParticle* theSecB11 = new G4DynamicParticle; + // GetIon() Method works whether particle exists in physicslist or not. + // Arguements are GetIon(Charge,Mass,ExcitationEng) + G4ParticleDefinition* theSecB11Definition = G4IonTable::GetIonTable()->GetIon(5, 11, 0.); + theSecB11->SetDefinition(theSecB11Definition); + theSecB11->SetKineticEnergy(T_B11); + theSecB11->SetMomentumDirection(MomDir_B11); + + // Kill the Parent Neutron ----------------------- + aParticleChange.ProposeTrackStatus(fStopAndKill); + aParticleChange.ProposeEnergy(0.); + aParticleChange.ProposePosition(thePosition); + + // Set final tracks in motion! + G4Track* theNTrack = new G4Track(theSecNeutron, GlobalTime, thePosition); + theNTrack->SetTouchableHandle(theTouchable); + G4Track* thePTrack = new G4Track(theSecProton, GlobalTime, thePosition); + thePTrack->SetTouchableHandle(theTouchable); + G4Track* theB11Track = new G4Track(theSecB11, GlobalTime, thePosition); + theB11Track->SetTouchableHandle(theTouchable); + + aParticleChange.SetNumberOfSecondaries(3); + aParticleChange.AddSecondary(theNTrack); + aParticleChange.AddSecondary(thePTrack); + aParticleChange.AddSecondary(theB11Track); + + // G4cout << "Made it to the end ! " << G4endl; + } + else if (ReactionName == "N_C12_N2N_C11") { + // Reaction copied from MENATE + // Treated as : + // n + 12C ---> 12C* + n' + // 12C* ---> 11C + n + + G4double Q_value = -18.721 * MeV; + + G4ThreeVector MomDir_N1; + G4ThreeVector MomDir_N2; + G4ThreeVector MomDir_C11; + + // Scattered neutron (n') + G4double Available_Eng = 0.9230769 * KinEng_Int + Q_value; + + if (Available_Eng < 0.) { + Available_Eng = 1.e-3; + } + + G4double Eng_Evap1 = Evaporate_Eng(AMass_Material, Available_Eng); + + G4double cos_theta_iso = 1. - (2. * G4UniformRand()); + // zwk + if (fwrdANGLES) + cos_theta_iso = pow(G4UniformRand(), 1. / 4.0); + + // 1/169. = (Mn/(Mn+Mc))^2 + // 0.1538462 = 2Mn/(Mn+Mc) + + G4double T_N1 = KinEng_Int / 169. + Eng_Evap1 + (0.1538462 * sqrt(KinEng_Int * Eng_Evap1)) * cos_theta_iso; + + G4double theta_N1 = 0.; + G4double phi_N1 = 0.; + + if (T_N1 > 1.e-5) { + // 1/13. = Mn/(Mn+Mc) + + G4double Arg = (sqrt(KinEng_Int) / 13. + (sqrt(Eng_Evap1) * cos_theta_iso)) / (sqrt(T_N1)); + if (Arg > 1.) { + Arg = 1.; + } + theta_N1 = acos(Arg); + phi_N1 = 2. * Pi * G4UniformRand(); + } + + MomDir_N1 = GenMomDir(MomDir_Int, theta_N1, phi_N1); + + // Scattered 12C* + // 1/13. = Mn(Mc+Mn) + // 1.0833333 = (Mc+Mn)/Mc + + G4double T_C12Star = KinEng_Int / 13. + 1.0833333 * Eng_Evap1 - T_N1; + + G4double theta_C12Star = 0.; + G4double phi_C12Star = phi_N1 + Pi; + + if (T_C12Star > 1.e-5) { + // 0.2664694 = sqrt(Mn*Mc)/(Mn+Mc) + // 0.2886751 = sqrt(Mn/Mc) + G4double Arg = (0.2664694 * sqrt(KinEng_Int) - (0.2886751 * sqrt(Eng_Evap1) * cos_theta_iso)) / (sqrt(T_C12Star)); + if (Arg > 1.) { + Arg = 1.; + } + theta_C12Star = acos(Arg); + } + + // Now neutron2 is emitted in the frame of the scattered C12* + // At the end, the angles are put back into the frame of the original neutron + + Available_Eng = KinEng_Int + Q_value - T_N1 - T_C12Star; + + if (Available_Eng < 0.) { + Available_Eng = 1.e-3; + } + + G4double Eng_Evap2 = Evaporate_Eng(AMass_Material, Available_Eng); + + cos_theta_iso = 1. - (2. * G4UniformRand()); + + // .5773503 = 2*sqrt(Mn/Mc) + + G4double T_N2 = T_C12Star / 12. + Eng_Evap2 + (0.5773503 * sqrt(T_C12Star * Eng_Evap2)) * cos_theta_iso; + + G4double theta_C12_N2 = acos(cos_theta_iso); + G4double phi_C12_N2 = 2. * Pi * G4UniformRand(); + + // Now Start With Z-Axis and then go to incoming neutron frame ? + // G4ThreeVector MomDir_ZAxis = G4ThreeVector(0.,0.,1.); + + G4ThreeVector MomDir_ZAxis = MomDir_Int; + G4ThreeVector MomDir_C12Star = GenMomDir(MomDir_ZAxis, theta_C12Star, phi_C12Star); + + MomDir_N2 = GenMomDir(MomDir_C12Star, theta_C12_N2, phi_C12_N2); + + // C11 - Need to check kinematics - maybe not right - 18 Apr 2008, BTR + + G4double T_C11 = KinEng_Int + Q_value - T_N1 - T_N2; // Remaining Eng + if (T_C11 <= 0.) { + T_C11 = 1e-9; + } + + G4double theta_C11 = Pi - theta_C12_N2; + G4double phi_C11 = Pi + phi_C12_N2; + + MomDir_C11 = GenMomDir(MomDir_Int, theta_C11, phi_C11); + + // Generate a Secondary Neutron1 + G4DynamicParticle* theSecNeutron1 = new G4DynamicParticle; + G4ParticleDefinition* theSecN1Definition = G4Neutron::Neutron(); + theSecNeutron1->SetDefinition(theSecN1Definition); + theSecNeutron1->SetKineticEnergy(T_N1); + theSecNeutron1->SetMomentumDirection(MomDir_N1); + + // Generate a Secondary Neutron2 + G4DynamicParticle* theSecNeutron2 = new G4DynamicParticle; + G4ParticleDefinition* theSecN2Definition = G4Neutron::Neutron(); + theSecNeutron2->SetDefinition(theSecN2Definition); + theSecNeutron2->SetKineticEnergy(T_N2); + theSecNeutron2->SetMomentumDirection(MomDir_N2); + + // Generate a Secondary C11 + G4DynamicParticle* theSecC11 = new G4DynamicParticle; + // GetIon() Method works whether particle exists in physicslist or not. + // Arguements are GetIon(Charge,Mass,ExcitationEng) + G4ParticleDefinition* theSecC11Definition = G4IonTable::GetIonTable()->GetIon(6, 11, 0.); + theSecC11->SetDefinition(theSecC11Definition); + theSecC11->SetKineticEnergy(T_C11); + theSecC11->SetMomentumDirection(MomDir_C11); + + // Kill the Parent Neutron ----------------------- + aParticleChange.ProposeTrackStatus(fStopAndKill); + aParticleChange.ProposeEnergy(0.); + aParticleChange.ProposePosition(thePosition); + + // Set final tracks in motion! + G4Track* theN1Track = new G4Track(theSecNeutron1, GlobalTime, thePosition); + theN1Track->SetTouchableHandle(theTouchable); + G4Track* theN2Track = new G4Track(theSecNeutron2, GlobalTime, thePosition); + theN2Track->SetTouchableHandle(theTouchable); + G4Track* theC11Track = new G4Track(theSecC11, GlobalTime, thePosition); + theC11Track->SetTouchableHandle(theTouchable); + + aParticleChange.SetNumberOfSecondaries(3); + aParticleChange.AddSecondary(theN1Track); + aParticleChange.AddSecondary(theN2Track); + aParticleChange.AddSecondary(theC11Track); + + /* + G4double T_N_Sum = T_N1+T_N2; + G4cout << "n, 2n C11 event! " << G4endl; + G4cout << "T_N1 = " << T_N1 << "T_N2 = " << T_N2 << " , T_Sum = " << T_N_Sum << G4endl; + G4cout << "Total Eng Final State : " << T_N_Sum+T_C11 << " , Eng_Int+Qvalue = " << KinEng_Int+Q_value << G4endl; + */ + // G4cout << "Made it to the end ! " << G4endl; + } + else if (ReactionName == "N_C12_NN3Alpha") { + // Reaction copied from MENATE + // Treated as : + // n + 12C ---> 12C* + n' + // 12C* ---> 8Be + alpha1 + // 8Be* ---> alpha2+alpha3 + + G4double Q_value = -7.275 * MeV; + + G4ThreeVector MomDir_N; + G4ThreeVector MomDir_Alpha1; + G4ThreeVector MomDir_Alpha2; + G4ThreeVector MomDir_Alpha3; + + // Scattered neutron (n') + G4double Available_Eng = 0.9230769 * KinEng_Int + Q_value; + + if (Available_Eng < 0.) { + Available_Eng = 1.e-3; + } + + G4double Eng_Evap1 = Evaporate_Eng(AMass_Material, Available_Eng); + + G4double cos_theta_iso = 1. - (2. * G4UniformRand()); + // zwk + if (fwrdANGLES) + cos_theta_iso = pow(G4UniformRand(), 1. / 4.0); + + // 1/169. = (Mn/(Mn+Mc))^2 + // 0.1538462 = 2Mn/(Mn+Mc) + + G4double T_N = KinEng_Int / 169. + Eng_Evap1 + (0.1538462 * sqrt(KinEng_Int * Eng_Evap1)) * cos_theta_iso; + + G4double theta_N = 0.; + G4double phi_N = 0.; + + if (T_N > 1.e-5) { + // 1/13. = Mn/(Mn+Mc) + + G4double Arg = (sqrt(KinEng_Int) / 13. + (sqrt(Eng_Evap1) * cos_theta_iso)) / (sqrt(T_N)); + if (Arg > 1.) { + Arg = 1.; + } + theta_N = acos(Arg); + phi_N = 2. * Pi * G4UniformRand(); + } + + MomDir_N = GenMomDir(MomDir_Int, theta_N, phi_N); + + // Scattered 12C* + // 1/13. = Mn(Mc+Mn) + // 1.0833333 = (Mc+Mn)/Mc + + G4double T_C12Star = KinEng_Int / 13. + 1.0833333 * Eng_Evap1 - T_N; + + G4double theta_C12Star = 0.; + G4double phi_C12Star = phi_N + Pi; + + if (T_C12Star > 1.e-5) { + // 0.2664694 = sqrt(Mn*Mc)/(Mn+Mc) + // 0.2886751 = sqrt(Mn/Mc) + G4double Arg = (0.2664694 * sqrt(KinEng_Int) - (0.2886751 * sqrt(Eng_Evap1) * cos_theta_iso)) / (sqrt(T_C12Star)); + if (Arg > 1.) { + Arg = 1.; + } + theta_C12Star = acos(Arg); + } + + // Now Alpha1 is emitted in the frame of the scattered C12* + // At the end, the angles are put back into the frame of the original neutron + + Available_Eng = (KinEng_Int + Q_value - T_N - T_C12Star) * G4UniformRand(); + + if (Available_Eng < 0.) { + Available_Eng = 0.; + } + + cos_theta_iso = 1. - (2. * G4UniformRand()); + + // 1./3. = MA1/MC12 + // 0.6666667 = MBe8/MC12 + // 0.9428090 = 2*sqrt(Malpha*M8Be)/Mc12) + + G4double T_Alpha1 = + T_C12Star / 3. + 0.6666667 * Available_Eng + (0.9428090 * sqrt(Available_Eng * T_C12Star)) * cos_theta_iso; + + G4double theta_Alpha1 = 0.; + G4double phi_Alpha1 = 0.; + + if (T_Alpha1 > 1.e-5) { + // 0.5773503 = sqrt(Malpha/MC12) + // 0.8164966 = sqrt((MBe8)/(MC12)) + + G4double Arg = (0.5773503 * sqrt(T_C12Star) + 0.8164966 * sqrt(Available_Eng) * cos_theta_iso) / (sqrt(T_Alpha1)); + if (Arg > 1.) { + Arg = 1.; + } + theta_Alpha1 = acos(Arg); + phi_Alpha1 = 2. * Pi * G4UniformRand(); + } + + // Now Start With Z-Axis and then go to incoming neutron frame ? + // G4ThreeVector MomDir_ZAxis = G4ThreeVector(0.,0.,1.); + G4ThreeVector MomDir_ZAxis = MomDir_Int; + G4ThreeVector MomDir_C12Star = GenMomDir(MomDir_ZAxis, theta_C12Star, phi_C12Star); + + MomDir_Alpha1 = GenMomDir(MomDir_C12Star, theta_Alpha1, phi_Alpha1); + + // Be8* Kinematics --- Particle decayed into the other alphas + // Angles in frame of scattered C12* + + G4double T_Be8Star = T_C12Star + Available_Eng - T_Alpha1; // Remaining Eng + + G4double theta_Be8Star = 0.; + G4double phi_Be8Star = phi_Alpha1 + Pi; + + if (T_Be8Star > 1.e-5) { + // 0.5773503 = sqrt(Malpha/MC12) + // 0.8164966 = sqrt(M8Be/MC12) + G4double Arg = + (0.8164966 * sqrt(T_C12Star) - (0.5773503 * sqrt(Available_Eng) * cos_theta_iso)) / (sqrt(T_Be8Star)); + if (Arg > 1.) { + Arg = 1.; + } + theta_Be8Star = acos(Arg); + } + + G4ThreeVector MomDir_Be8Star = GenMomDir(MomDir_C12Star, theta_Be8Star, phi_Be8Star); + + // Now Decay 8Be g.s. into 2 Alphas + // Q_value = 0.092*MeV + + G4double Q_valueBe8 = 0.092 * MeV; + Available_Eng = KinEng_Int + Q_value + Q_valueBe8 - T_N - T_Alpha1 - T_Be8Star; // Changed 23 Apr 2008 - BTR + + if (Available_Eng < 0.) { + Available_Eng = 0.; + } + + cos_theta_iso = 1. - (2. * G4UniformRand()); + + // 0.5 = MA2/Be8 + + G4double T_Alpha2 = 0.5 * (T_Be8Star + Available_Eng) + (sqrt(Available_Eng * T_Be8Star)) * cos_theta_iso; + if (T_Alpha2 < 0.) { + T_Alpha2 = 1e-9; + } + + G4double theta_Alpha2 = 0.; + G4double phi_Alpha2 = 0.; + + if (T_Alpha2 > 1.e-5) { + // 0.7071068 = sqrt(Malpha/MBe8) + + G4double Arg = (0.7071068 * (sqrt(T_Be8Star) + sqrt(Available_Eng) * cos_theta_iso)) / (sqrt(T_Alpha2)); + if (Arg > 1.) { + Arg = 1.; + } + theta_Alpha2 = acos(Arg); + phi_Alpha2 = 2. * Pi * G4UniformRand(); + } + + MomDir_Alpha2 = GenMomDir(MomDir_Be8Star, theta_Alpha2, phi_Alpha2); + + // Alpha3 emitted in frame of Be8 + + G4double T_Alpha3 = T_Be8Star + Available_Eng - T_Alpha2; + if (T_Alpha3 < 0.) { + T_Alpha3 = 1e-9; + } + + G4double theta_Alpha3 = 0.; + G4double phi_Alpha3 = phi_Alpha2 + Pi; + + if (T_Alpha3 > 1.e-5) { + // 0.7071068 = sqrt(Malpha/MBe8) + + G4double Arg = (0.7071068 * (sqrt(T_Be8Star) - sqrt(Available_Eng) * cos_theta_iso)) / (sqrt(T_Alpha3)); + if (Arg > 1.) { + Arg = 1.; + } + theta_Alpha3 = acos(Arg); + } + + MomDir_Alpha3 = GenMomDir(MomDir_Be8Star, theta_Alpha3, phi_Alpha3); + + // Generate a Secondary Neutron + G4DynamicParticle* theSecNeutron = new G4DynamicParticle; + G4ParticleDefinition* theSecNDefinition = G4Neutron::Neutron(); + theSecNeutron->SetDefinition(theSecNDefinition); + theSecNeutron->SetKineticEnergy(T_N); + theSecNeutron->SetMomentumDirection(MomDir_N); + + // Generate a Secondary Alpha1 + G4DynamicParticle* theSecAlpha1 = new G4DynamicParticle; + G4ParticleDefinition* theSecA1Definition = G4Alpha::Alpha(); + theSecAlpha1->SetDefinition(theSecA1Definition); + theSecAlpha1->SetKineticEnergy(T_Alpha1); + theSecAlpha1->SetMomentumDirection(MomDir_Alpha1); + + // Generate a Secondary Alpha2 + G4DynamicParticle* theSecAlpha2 = new G4DynamicParticle; + G4ParticleDefinition* theSecA2Definition = G4Alpha::Alpha(); + theSecAlpha2->SetDefinition(theSecA2Definition); + theSecAlpha2->SetKineticEnergy(T_Alpha2); + theSecAlpha2->SetMomentumDirection(MomDir_Alpha2); + + // Generate a Secondary Alpha3 + G4DynamicParticle* theSecAlpha3 = new G4DynamicParticle; + G4ParticleDefinition* theSecA3Definition = G4Alpha::Alpha(); + theSecAlpha3->SetDefinition(theSecA3Definition); + theSecAlpha3->SetKineticEnergy(T_Alpha3); + theSecAlpha3->SetMomentumDirection(MomDir_Alpha3); + + // Kill the Parent Neutron ----------------------- + aParticleChange.ProposeTrackStatus(fStopAndKill); + aParticleChange.ProposeEnergy(0.); + aParticleChange.ProposePosition(thePosition); + + // Set final tracks in motion! + G4Track* theNTrack = new G4Track(theSecNeutron, GlobalTime, thePosition); + theNTrack->SetTouchableHandle(theTouchable); + G4Track* theA1Track = new G4Track(theSecAlpha1, GlobalTime, thePosition); + theA1Track->SetTouchableHandle(theTouchable); + G4Track* theA2Track = new G4Track(theSecAlpha2, GlobalTime, thePosition); + theA2Track->SetTouchableHandle(theTouchable); + G4Track* theA3Track = new G4Track(theSecAlpha3, GlobalTime, thePosition); + theA3Track->SetTouchableHandle(theTouchable); + + aParticleChange.SetNumberOfSecondaries(4); + aParticleChange.AddSecondary(theNTrack); + aParticleChange.AddSecondary(theA1Track); + aParticleChange.AddSecondary(theA2Track); + aParticleChange.AddSecondary(theA3Track); + + /* + G4double T_A_Sum = T_Alpha1+T_Alpha2+T_Alpha3; + + G4cout << "n, n'3alpha event! " << G4endl; + G4cout << "T_N = " << T_N << G4endl; + G4cout << "A1 = " << T_Alpha1 << " ,A2 = " << T_Alpha2 << " , A3 = " << T_Alpha3 << ", A_Sum = " << T_A_Sum << + G4endl; G4cout << "Total Eng Final State : " << T_A_Sum+T_N << " , Eng_Int-Qvalue = " << KinEng_Int-7.275+0.092 << + G4endl; + */ + // G4cout << "Made it to the end ! " << G4endl; + } + else if (ReactionName == "N_Fe_elastic") { + G4double theta_N = 0.; + G4double phi_N = 0.; + + G4double T_N = 0.; + // G4double T_Feel = 0.; + G4ThreeVector MomDir_N; + G4ThreeVector MomDir_Fe; + + /* + //Just going to use isotropic distribution in CM + //However good consider using C12 elastic scattering, may be similar + G4double cos_sq_theta = G4UniformRand(); + + // Calls diffractive angular distribution as in DEMONS + //G4double cos_theta_cm = NC12_DIFF(KinEng_Int); + // Convert according to Knoll + //G4double cos_theta_lab = sqrt((1.-cos_theta_cm)/2.); + //G4double cos_sq_theta = pow(cos_theta_lab,2); + + // .070177 =4*Mfe*Mn/(Mfe+Mn)^2 + T_Feel = 0.07017*KinEng_Int*cos_sq_theta; + + T_N = KinEng_Int - T_Feel; + + if(T_N > 1.e-5) + { + G4double arg = (sqrt(KinEng_Int)-sqrt(12.*T_Feel*cos_sq_theta))/sqrt(T_N); + if(arg > 1.) + {arg = 1.;} + theta_N = acos(arg); + phi_N = 2.*Pi*G4UniformRand(); + } + + MomDir_N = GenMomDir(MomDir_Int,theta_N,phi_N); + + // Carbon angles + G4double theta_Fe = acos(sqrt(cos_sq_theta)); + G4double phi_Fe = phi_N+Pi; + + MomDir_Fe = GenMomDir(MomDir_Int,theta_Fe,phi_Fe); + */ + + double cos_theta_cm = FeElastic_AngDist(KinEng_Int); // cosine of cm_angle + if (cos_theta_cm > 1) + cos_theta_cm = 1; + double theta_cm = acos(cos_theta_cm); // of neutron + + // Following Knoll, calculate energy for proton first + double cos_theta_lab_Fe = sqrt((1. - cos_theta_cm) / 2.); + double theta_lab_Fe = acos(cos_theta_lab_Fe); + double phi_Fe = 2. * Pi * G4UniformRand(); + + double T_Fe = KinEng_Int * pow(cos_theta_lab_Fe, 2) * 4 * 56 / pow(57., 2.); + + MomDir_Fe = GenMomDir(MomDir_Int, theta_lab_Fe, phi_Fe); + + // scattered neutron ---------------- + // angles changed from cm to lab as in Marian and Young + theta_N = atan(sin(theta_cm) / (cos_theta_cm + (1 / 56))); + phi_N = phi_Fe + Pi; + + T_N = KinEng_Int - T_Fe; + + MomDir_N = GenMomDir(MomDir_Int, theta_N, phi_N); + + // Generate a Secondary Neutron + G4DynamicParticle* theSecNeutron = new G4DynamicParticle; + G4ParticleDefinition* theSecNeutronDefinition = G4Neutron::Neutron(); + theSecNeutron->SetDefinition(theSecNeutronDefinition); + theSecNeutron->SetKineticEnergy(T_N); + theSecNeutron->SetMomentumDirection(MomDir_N); + + // This is where you would generate the recoil Fe nucleus + // However for our purpose (Fe is only in sweeper) we don't + // need to keep track. + // G4DynamicParticle* theSecC12 = new G4DynamicParticle; + // GetIon() Method works whether particle exists in physicslist or not. + // Arguements are GetIon(Charge,Mass,ExcitationEng) + // G4ParticleDefinition* theSecC12Definition = G4IonTable::GetIonTable()->GetIon(6,12,0.); + // theSecC12->SetDefinition(theSecC12Definition); + // theSecC12->SetKineticEnergy(T_C12el); + // theSecC12->SetMomentumDirection(MomDir_C12); + + // Kill the Parent Neutron ----------------------- + aParticleChange.ProposeTrackStatus(fStopAndKill); + aParticleChange.ProposeEnergy(0.); + aParticleChange.ProposePosition(thePosition); + + // Set final tracks in motion! + G4Track* theNTrack = new G4Track(theSecNeutron, GlobalTime, thePosition); + theNTrack->SetTouchableHandle(theTouchable); + // G4Track* theC12Track = new G4Track(theSecC12,GlobalTime,thePosition); + // theC12Track->SetTouchableHandle(theTouchable); + + aParticleChange.SetNumberOfSecondaries(1); + aParticleChange.AddSecondary(theNTrack); + // aParticleChange.AddSecondary(theC12Track); + + // G4cout << "Made it to the end ! " << G4endl; + // G4cout << "Finished Elastic Scatter of Fe" << G4endl; + } + else if (ReactionName == "N_Fe_nonelastic") { + + // For our purposes we are going to treat the non-elastic Fe interactions as absorption of the neutrons + // the idea is that after the interaction the neutron would be slowed and may not make it into the timing gate + // furthermore we don't have enought information (beyond the cross sections) to know how to handle the + // non-elastic processes. + + // Kill the Parent Neutron ----------------------- + aParticleChange.ProposeTrackStatus(fStopAndKill); + aParticleChange.ProposeEnergy(0.); + aParticleChange.ProposePosition(thePosition); + + aParticleChange.SetNumberOfSecondaries(0); + // aParticleChange.AddSecondary(theNTrack); + // aParticleChange.AddSecondary(theC12Track); + + // G4cout << "Made it to the end ! " << G4endl; + // G4cout << "Finished Fe Non-Elastic Process" << G4endl; + } + else if (ReactionName == "N_Al_elastic") { + + G4double theta_N = 0.; + G4double phi_N = 0.; + + G4double T_N = 0.; + // G4double T_Feel = 0.; + G4ThreeVector MomDir_N; + G4ThreeVector MomDir_Al; + + /* + //Just going to use isotropic distribution in CM + //However good consider using C12 elastic scattering, may be similar + G4double cos_sq_theta = G4UniformRand(); + + // Calls diffractive angular distribution as in DEMONS + //G4double cos_theta_cm = NC12_DIFF(KinEng_Int); + // Convert according to Knoll + //G4double cos_theta_lab = sqrt((1.-cos_theta_cm)/2.); + //G4double cos_sq_theta = pow(cos_theta_lab,2); + + // .070177 =4*Mfe*Mn/(Mfe+Mn)^2 + T_Feel = 0.07017*KinEng_Int*cos_sq_theta; + + T_N = KinEng_Int - T_Feel; + + if(T_N > 1.e-5) + { + G4double arg = (sqrt(KinEng_Int)-sqrt(12.*T_Feel*cos_sq_theta))/sqrt(T_N); + if(arg > 1.) + {arg = 1.;} + theta_N = acos(arg); + phi_N = 2.*Pi*G4UniformRand(); + } + + MomDir_N = GenMomDir(MomDir_Int,theta_N,phi_N); + + // Carbon angles + G4double theta_Fe = acos(sqrt(cos_sq_theta)); + G4double phi_Fe = phi_N+Pi; + + MomDir_Fe = GenMomDir(MomDir_Int,theta_Fe,phi_Fe); + */ + + double cos_theta_cm = AlElastic_AngDist(KinEng_Int); // cosine of cm_angle + if (cos_theta_cm > 1) + cos_theta_cm = 1; + double theta_cm = acos(cos_theta_cm); // of neutron + + // Following Knoll, calculate energy for proton first + double cos_theta_lab_Al = sqrt((1. - cos_theta_cm) / 2.); + double theta_lab_Al = acos(cos_theta_lab_Al); + double phi_Al = 2. * Pi * G4UniformRand(); + + double T_Al = KinEng_Int * pow(cos_theta_lab_Al, 2) * 4 * 27 / pow(28., 2); + + // G4cout << "Al theta: " << cos_theta_cm << " " << theta_cm << " " << cos_theta_lab_Al << " " << theta_lab_Al << + // G4endl; G4cout << "Al KE: " << T_Al/MeV << " Init_N KE: " << KinEng_Int/MeV << G4endl; + + MomDir_Al = GenMomDir(MomDir_Int, theta_lab_Al, phi_Al); + + // scattered neutron ---------------- + // angles changed from cm to lab as in Marian and Young + theta_N = atan(sin(theta_cm) / (cos_theta_cm + (1 / 27))); + phi_N = phi_Al + Pi; + + T_N = KinEng_Int - T_Al; + + MomDir_N = GenMomDir(MomDir_Int, theta_N, phi_N); + + // Generate a Secondary Neutron + G4DynamicParticle* theSecNeutron = new G4DynamicParticle; + G4ParticleDefinition* theSecNeutronDefinition = G4Neutron::Neutron(); + theSecNeutron->SetDefinition(theSecNeutronDefinition); + theSecNeutron->SetKineticEnergy(T_N); + theSecNeutron->SetMomentumDirection(MomDir_N); + + // This is where you would generate the recoil Fe nucleus + // However for our purpose (Fe is only in sweeper) we don't + // need to keep track. + // G4DynamicParticle* theSecC12 = new G4DynamicParticle; + // GetIon() Method works whether particle exists in physicslist or not. + // Arguements are GetIon(Charge,Mass,ExcitationEng) + // G4ParticleDefinition* theSecC12Definition = G4IonTable::GetIonTable()->GetIon(6,12,0.); + // theSecC12->SetDefinition(theSecC12Definition); + // theSecC12->SetKineticEnergy(T_C12el); + // theSecC12->SetMomentumDirection(MomDir_C12); + + // Kill the Parent Neutron ----------------------- + aParticleChange.ProposeTrackStatus(fStopAndKill); + aParticleChange.ProposeEnergy(0.); + aParticleChange.ProposePosition(thePosition); + + // Set final tracks in motion! + G4Track* theNTrack = new G4Track(theSecNeutron, GlobalTime, thePosition); + theNTrack->SetTouchableHandle(theTouchable); + // G4Track* theC12Track = new G4Track(theSecC12,GlobalTime,thePosition); + // theC12Track->SetTouchableHandle(theTouchable); + + aParticleChange.SetNumberOfSecondaries(1); + aParticleChange.AddSecondary(theNTrack); + // aParticleChange.AddSecondary(theC12Track); + + // G4cout << "Made it to the end ! " << G4endl; + // G4cout << "Finished Elastic Scatter of Fe" << G4endl; + } + else if (ReactionName == "N_Al_nonelastic") { + + // For our purposes we are going to treat the non-elastic Fe interactions as absorption of the neutrons + // the idea is that after the interaction the neutron would be slowed and may not make it into the timing gate + // furthermore we don't have enought information (beyond the cross sections) to know how to handle the + // non-elastic processes. + + // Kill the Parent Neutron ----------------------- + aParticleChange.ProposeTrackStatus(fStopAndKill); + aParticleChange.ProposeEnergy(0.); + aParticleChange.ProposePosition(thePosition); + + aParticleChange.SetNumberOfSecondaries(0); + // aParticleChange.AddSecondary(theNTrack); + // aParticleChange.AddSecondary(theC12Track); + + // G4cout << "Made it to the end ! " << G4endl; + // G4cout << "Finished Fe Non-Elastic Process" << G4endl; + } - return pParticleChange; + return pParticleChange; } diff --git a/NPSimulation/Scorers/CMakeLists.txt b/NPSimulation/Scorers/CMakeLists.txt index 8b616543f785535f89c41c19059bcdf52a6c0c9c..6d6e2df09dc0ce1d62d054122ee5d8dd2e64901e 100644 --- a/NPSimulation/Scorers/CMakeLists.txt +++ b/NPSimulation/Scorers/CMakeLists.txt @@ -1,2 +1,2 @@ -add_library(NPSScorers SHARED CylinderTPCScorers.cc DriftChamberScorers.cc NPSHitsMap.hh CalorimeterScorers.cc InteractionScorers.cc DSSDScorers.cc SiliconScorers.cc PhotoDiodeScorers.cc ObsoleteGeneralScorers.cc DriftElectronScorers.cc TPCScorers.cc MDMScorer.cc NeutronDetectorScorers.cc ProcessScorers.cc) +add_library(NPSScorers SHARED CylinderTPCScorers.cc DriftChamberScorers.cc NPSHitsMap.hh CalorimeterScorers.cc InteractionScorers.cc DSSDScorers.cc SiliconScorers.cc PhotoDiodeScorers.cc ObsoleteGeneralScorers.cc DriftElectronScorers.cc TPCScorers.cc MDMScorer.cc NeutronDetectorScorers.cc ProcessScorers.cc PlasticBar.cc) target_link_libraries(NPSScorers ${ROOT_LIBRARIES} ${Geant4_LIBRARIES} ${NPLib_LIBRARIES} -lNPInitialConditions -lNPInteractionCoordinates) diff --git a/NPSimulation/Scorers/DSSDScorers.cc b/NPSimulation/Scorers/DSSDScorers.cc index 0e085c023b39ee000e03f0fc431f86af6546b403..f89ec91d0d296c6ff648602c82a9caeca20dcc32 100644 --- a/NPSimulation/Scorers/DSSDScorers.cc +++ b/NPSimulation/Scorers/DSSDScorers.cc @@ -21,22 +21,23 @@ *****************************************************************************/ #include "DSSDScorers.hh" #include "G4UnitsTable.hh" -using namespace DSSDScorers ; -vector<DSSDData>::iterator DSSDDataVector::find(const unsigned int& index){ - for(vector<DSSDData>::iterator it= m_Data.begin() ; it !=m_Data.end() ; it++){ - if((*it).GetIndex()==index) +using namespace DSSDScorers; +vector<DSSDData>::iterator DSSDDataVector::find(const unsigned int& index) { + for (vector<DSSDData>::iterator it = m_Data.begin(); it != m_Data.end(); it++) { + if ((*it).GetIndex() == index) return it; } return m_Data.end(); } - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -PS_Images::PS_Images(G4String name, string imageFront,string imageBack,double scalingFront, double scalingBack, double centerOffsetX,double centerOffsetY,unsigned int ignoreValue, G4int depth) :G4VPrimitiveScorer(name, depth){ - m_ImageFront = new NPL::Image(imageFront,scalingFront,scalingFront); - m_ImageBack = new NPL::Image(imageBack,scalingBack,scalingBack); +PS_Images::PS_Images(G4String name, string imageFront, string imageBack, double scalingFront, double scalingBack, + double centerOffsetX, double centerOffsetY, unsigned int ignoreValue, G4int depth) + : G4VPrimitiveScorer(name, depth) { + m_ImageFront = new NPL::Image(imageFront, scalingFront, scalingFront); + m_ImageBack = new NPL::Image(imageBack, scalingBack, scalingBack); m_ScalingFront = scalingFront; - m_ScalingBack = scalingBack; + m_ScalingBack = scalingBack; m_CenterOffsetX = centerOffsetX; m_CenterOffsetY = centerOffsetY; m_IgnoreValue = ignoreValue; @@ -44,210 +45,199 @@ PS_Images::PS_Images(G4String name, string imageFront,string imageBack,double sc } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -G4bool PS_Images::ProcessHits(G4Step* aStep, G4TouchableHistory*){ +G4bool PS_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(); + t_Position = aStep->GetPreStepPoint()->GetPosition(); // transforming the position to the local volume - 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()); + 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()); // If front and back are in inactive part of the wafer, // nothing is added to the unordered_map - if(t_PixelFront == m_IgnoreValue && t_PixelBack == m_IgnoreValue) + if (t_PixelFront == m_IgnoreValue && t_PixelBack == m_IgnoreValue) return FALSE; - // Check if the particle has interact before, if yes, add up the energies. - vector<DSSDData>::iterator it; - - it= m_HitFront.find(DSSDData::CalculateIndex(t_PixelFront,t_DetectorNbr)); - if(it!=m_HitFront.end()){ + vector<DSSDData>::iterator it; + + it = m_HitFront.find(DSSDData::CalculateIndex(t_PixelFront, t_DetectorNbr)); + if (it != m_HitFront.end()) { it->Add(t_Energy); } - else{ - m_HitFront.Set(t_Energy,t_Time,t_PixelFront,t_DetectorNbr); + else { + m_HitFront.Set(t_Energy, t_Time, t_PixelFront, t_DetectorNbr); } // Check if the particle has interact before, if yes, add up the energies. - it= m_HitBack.find(DSSDData::CalculateIndex(t_PixelBack,t_DetectorNbr)); - if(it!=m_HitBack.end()){ + it = m_HitBack.find(DSSDData::CalculateIndex(t_PixelBack, t_DetectorNbr)); + if (it != m_HitBack.end()) { it->Add(t_Energy); } - else{ - m_HitBack.Set(t_Energy,t_Time,t_PixelBack,t_DetectorNbr); + else { + m_HitBack.Set(t_Energy, t_Time, t_PixelBack, t_DetectorNbr); } return TRUE; - } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void PS_Images::Initialize(G4HCofThisEvent*){ - clear(); -} +void PS_Images::Initialize(G4HCofThisEvent*) { clear(); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void PS_Images::EndOfEvent(G4HCofThisEvent*){ -} +void PS_Images::EndOfEvent(G4HCofThisEvent*) {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void PS_Images::clear(){ +void PS_Images::clear() { m_HitFront.clear(); m_HitBack.clear(); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void PS_Images::GetARGBFront(unsigned int& i,unsigned int& a,unsigned int& r,unsigned int& g,unsigned int& b){ +void PS_Images::GetARGBFront(unsigned int& i, unsigned int& a, unsigned int& r, unsigned int& g, unsigned int& b) { unsigned int Info = m_HitFront[i]->GetStrip(); - a = (Info>>24)&0xff; - r = (Info>>16)&0xff; - g = (Info>>8)&0xff; - b = (Info>>0)&0xff; + a = (Info >> 24) & 0xff; + r = (Info >> 16) & 0xff; + g = (Info >> 8) & 0xff; + b = (Info >> 0) & 0xff; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void PS_Images::GetARGBBack(unsigned int& i,unsigned int& a,unsigned int& r,unsigned int& g,unsigned int& b){ +void PS_Images::GetARGBBack(unsigned int& i, unsigned int& a, unsigned int& r, unsigned int& g, unsigned int& b) { unsigned int Info = m_HitBack[i]->GetStrip(); - a = (Info>>24)&0xff; - r = (Info>>16)&0xff; - g = (Info>>8)&0xff; - b = (Info>>0)&0xff; + a = (Info >> 24) & 0xff; + r = (Info >> 16) & 0xff; + g = (Info >> 8) & 0xff; + b = (Info >> 0) & 0xff; } - //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -PS_Rectangle::PS_Rectangle(G4String name,G4int Level, G4double StripPlaneLength, G4double StripPlaneWidth, G4int NumberOfStripLength,G4int NumberOfStripWidth,G4int depth,G4String axis) - :G4VPrimitiveScorer(name, depth){ - m_StripPlaneLength = StripPlaneLength; - m_StripPlaneWidth = StripPlaneWidth; - m_NumberOfStripLength = NumberOfStripLength; - m_NumberOfStripWidth = NumberOfStripWidth; - m_StripPitchLength = m_StripPlaneLength / m_NumberOfStripLength; - m_StripPitchWidth = m_StripPlaneWidth / m_NumberOfStripWidth; - m_Level = Level; - if(axis=="xy") - m_Axis=ps_xy; - else if(axis=="yz") - m_Axis=ps_yz; - else if(axis=="xz") - m_Axis=ps_xz; - - - } +PS_Rectangle::PS_Rectangle(G4String name, G4int Level, G4double StripPlaneLength, G4double StripPlaneWidth, + G4int NumberOfStripLength, G4int NumberOfStripWidth, G4int depth, G4String axis) + : G4VPrimitiveScorer(name, depth) { + m_StripPlaneLength = StripPlaneLength; + m_StripPlaneWidth = StripPlaneWidth; + m_NumberOfStripLength = NumberOfStripLength; + m_NumberOfStripWidth = NumberOfStripWidth; + m_StripPitchLength = m_StripPlaneLength / m_NumberOfStripLength; + m_StripPitchWidth = m_StripPlaneWidth / m_NumberOfStripWidth; + m_Level = Level; + if (axis == "xy") + m_Axis = ps_xy; + else if (axis == "yz") + m_Axis = ps_yz; + else if (axis == "xz") + m_Axis = ps_xz; +} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -PS_Rectangle::~PS_Rectangle(){ -} +PS_Rectangle::~PS_Rectangle() {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -G4bool PS_Rectangle::ProcessHits(G4Step* aStep, G4TouchableHistory*){ +G4bool PS_Rectangle::ProcessHits(G4Step* aStep, G4TouchableHistory*) { // contain Energy Time, DetNbr, StripFront and StripBack - t_Energy = aStep->GetTotalEnergyDeposit(); - t_Time = aStep->GetPreStepPoint()->GetGlobalTime(); + t_Energy = aStep->GetTotalEnergyDeposit(); + t_Time = aStep->GetPreStepPoint()->GetGlobalTime(); t_DetectorNumber = aStep->GetPreStepPoint()->GetTouchableHandle()->GetCopyNumber(m_Level); - t_Position = aStep->GetPreStepPoint()->GetPosition(); + t_Position = aStep->GetPreStepPoint()->GetPosition(); - t_Position = aStep->GetPreStepPoint()->GetTouchableHandle()->GetHistory()->GetTopTransform().TransformPoint(t_Position); + t_Position = + aStep->GetPreStepPoint()->GetTouchableHandle()->GetHistory()->GetTopTransform().TransformPoint(t_Position); - if(m_Axis==ps_xy){ - t_StripLengthNumber = (int)((t_Position.x() + m_StripPlaneLength / 2.) / m_StripPitchLength ) + 1 ; - t_StripWidthNumber = (int)((t_Position.y() + m_StripPlaneWidth / 2.) / m_StripPitchWidth ) + 1 ; + if (m_Axis == ps_xy) { + t_StripLengthNumber = (int)((t_Position.x() + m_StripPlaneLength / 2.) / m_StripPitchLength) + 1; + t_StripWidthNumber = (int)((t_Position.y() + m_StripPlaneWidth / 2.) / m_StripPitchWidth) + 1; } - else if(m_Axis==ps_yz){ - t_StripLengthNumber = (int)((t_Position.y() + m_StripPlaneLength / 2.) / m_StripPitchLength ) + 1 ; - t_StripWidthNumber = (int)((t_Position.z() + m_StripPlaneWidth / 2.) / m_StripPitchWidth ) + 1 ; + else if (m_Axis == ps_yz) { + t_StripLengthNumber = (int)((t_Position.y() + m_StripPlaneLength / 2.) / m_StripPitchLength) + 1; + t_StripWidthNumber = (int)((t_Position.z() + m_StripPlaneWidth / 2.) / m_StripPitchWidth) + 1; } - else if(m_Axis==ps_xz){ - t_StripLengthNumber = (int)((t_Position.x() + m_StripPlaneLength / 2.) / m_StripPitchLength ) + 1 ; - t_StripWidthNumber = (int)((t_Position.z() + m_StripPlaneWidth / 2.) / m_StripPitchWidth ) + 1 ; + else if (m_Axis == ps_xz) { + t_StripLengthNumber = (int)((t_Position.x() + m_StripPlaneLength / 2.) / m_StripPitchLength) + 1; + t_StripWidthNumber = (int)((t_Position.z() + m_StripPlaneWidth / 2.) / m_StripPitchWidth) + 1; } - //Rare case where particle is close to edge of silicon plan - if (t_StripLengthNumber > m_NumberOfStripLength) t_StripLengthNumber = m_NumberOfStripLength; - if (t_StripWidthNumber > m_NumberOfStripWidth) t_StripWidthNumber = m_NumberOfStripWidth; + // Rare case where particle is close to edge of silicon plan + if (t_StripLengthNumber > m_NumberOfStripLength) + t_StripLengthNumber = m_NumberOfStripLength; + if (t_StripWidthNumber > m_NumberOfStripWidth) + t_StripWidthNumber = m_NumberOfStripWidth; // Check if the particle has interact before, if yes, add up the energies. vector<DSSDData>::iterator it; // Length - it = m_HitLength.find(DSSDData::CalculateIndex(t_StripLengthNumber,t_DetectorNumber)); - if(it!=m_HitLength.end()){ + it = m_HitLength.find(DSSDData::CalculateIndex(t_StripLengthNumber, t_DetectorNumber)); + if (it != m_HitLength.end()) { it->Add(t_Energy); } else - m_HitLength.Set(t_Energy,t_Time,t_StripLengthNumber,t_DetectorNumber); + m_HitLength.Set(t_Energy, t_Time, t_StripLengthNumber, t_DetectorNumber); // Width - it = m_HitWidth.find(DSSDData::CalculateIndex(t_StripWidthNumber,t_DetectorNumber)); - if(it!=m_HitWidth.end()){ + it = m_HitWidth.find(DSSDData::CalculateIndex(t_StripWidthNumber, t_DetectorNumber)); + if (it != m_HitWidth.end()) { it->Add(t_Energy); } else - m_HitWidth.Set(t_Energy,t_Time,t_StripWidthNumber,t_DetectorNumber); + m_HitWidth.Set(t_Energy, t_Time, t_StripWidthNumber, t_DetectorNumber); - -return TRUE; + return TRUE; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void PS_Rectangle::Initialize(G4HCofThisEvent*){ - clear(); -} +void PS_Rectangle::Initialize(G4HCofThisEvent*) { clear(); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void PS_Rectangle::EndOfEvent(G4HCofThisEvent*){ -} +void PS_Rectangle::EndOfEvent(G4HCofThisEvent*) {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void PS_Rectangle::clear(){ +void PS_Rectangle::clear() { m_HitLength.clear(); m_HitWidth.clear(); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void PS_Rectangle::DrawAll(){ - -} +void PS_Rectangle::DrawAll() {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void PS_Rectangle::PrintAll(){ -} +void PS_Rectangle::PrintAll() {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -PS_Annular::PS_Annular(G4String name,G4int Level, G4double StripPlaneInnerRadius, G4double StripPlaneOuterRadius, G4double PhiStart,G4double PhiStop, G4int NumberOfStripRing,G4int NumberOfStripSector,G4int NumberOfQuadrant,G4int depth) - :G4VPrimitiveScorer(name, depth){ - - m_StripPlaneInnerRadius = StripPlaneInnerRadius; - m_StripPlaneOuterRadius = StripPlaneOuterRadius; - m_PhiStart = PhiStart; - m_PhiStop = PhiStop; - m_NumberOfStripRing = NumberOfStripRing; - m_NumberOfStripSector = NumberOfStripSector; - m_NumberOfStripQuadrant = NumberOfQuadrant; - m_StripPitchRing = (m_StripPlaneOuterRadius-m_StripPlaneInnerRadius)/m_NumberOfStripRing; - m_StripPitchSector = (m_PhiStop-m_PhiStart)/m_NumberOfStripSector; - m_StripPitchQuadrant = (m_PhiStop-m_PhiStart)/m_NumberOfStripQuadrant; - m_Level = Level; +PS_Annular::PS_Annular(G4String name, G4int Level, G4double StripPlaneInnerRadius, G4double StripPlaneOuterRadius, + G4double PhiStart, G4double PhiStop, G4int NumberOfStripRing, G4int NumberOfStripSector, + G4int NumberOfQuadrant, G4int depth) + : G4VPrimitiveScorer(name, depth) { - m_uz = G4ThreeVector(0,0,1); - } + m_StripPlaneInnerRadius = StripPlaneInnerRadius; + m_StripPlaneOuterRadius = StripPlaneOuterRadius; + m_PhiStart = PhiStart; + m_PhiStop = PhiStop; + m_NumberOfStripRing = NumberOfStripRing; + m_NumberOfStripSector = NumberOfStripSector; + m_NumberOfStripQuadrant = NumberOfQuadrant; + m_StripPitchRing = (m_StripPlaneOuterRadius - m_StripPlaneInnerRadius) / m_NumberOfStripRing; + m_StripPitchSector = (m_PhiStop - m_PhiStart) / m_NumberOfStripSector; + m_StripPitchQuadrant = (m_PhiStop - m_PhiStart) / m_NumberOfStripQuadrant; + m_Level = Level; -//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -PS_Annular::~PS_Annular(){ + m_uz = G4ThreeVector(0, 0, 1); } +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +PS_Annular::~PS_Annular() {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -G4bool PS_Annular::ProcessHits(G4Step* aStep, G4TouchableHistory*){ +G4bool PS_Annular::ProcessHits(G4Step* aStep, G4TouchableHistory*) { t_Energy = aStep->GetTotalEnergyDeposit(); t_Time = aStep->GetPreStepPoint()->GetGlobalTime(); @@ -255,166 +245,170 @@ G4bool PS_Annular::ProcessHits(G4Step* aStep, G4TouchableHistory*){ t_DetectorNumber = aStep->GetPreStepPoint()->GetTouchableHandle()->GetCopyNumber(m_Level); t_Position = aStep->GetPreStepPoint()->GetPosition(); - //Transform into local coordinates - t_Position = aStep->GetPreStepPoint()->GetTouchableHandle()->GetHistory()->GetTopTransform().TransformPoint(t_Position); - t_StripRingNumber = (int) ((t_Position.rho() - m_StripPlaneInnerRadius) / m_StripPitchRing ) + 1 ; + // Transform into local coordinates + t_Position = + aStep->GetPreStepPoint()->GetTouchableHandle()->GetHistory()->GetTopTransform().TransformPoint(t_Position); + t_StripRingNumber = (int)((t_Position.rho() - m_StripPlaneInnerRadius) / m_StripPitchRing) + 1; // phi() from G4-CLHEP method return azimuth between [-pi;pi] // we need it in [0;2pi] to calculate sector nbr in [1,NSectors] // only add 360 if the value is negative - double phi = (t_Position.phi()<0)? t_Position.phi()+2*pi : t_Position.phi() ; + double phi = (t_Position.phi() < 0) ? t_Position.phi() + 2 * pi : t_Position.phi(); // factor out the extra 360 degrees before strip/quad calculation - t_StripSectorNumber = (int) ( fmod((phi - m_PhiStart),2*pi) / m_StripPitchSector ) + 1 ; - t_StripQuadrantNumber = (int) ( fmod((phi - m_PhiStart),2*pi) / m_StripPitchQuadrant) + 1 ; + t_StripSectorNumber = (int)(fmod((phi - m_PhiStart), 2 * pi) / m_StripPitchSector) + 1; + t_StripQuadrantNumber = (int)(fmod((phi - m_PhiStart), 2 * pi) / m_StripPitchQuadrant) + 1; - //Rare case where particle is close to edge of silicon plan - if (t_StripRingNumber > m_NumberOfStripRing) t_StripRingNumber = m_NumberOfStripRing; - if (t_StripSectorNumber > m_NumberOfStripSector) t_StripSectorNumber = m_NumberOfStripSector; - if (t_StripQuadrantNumber > m_NumberOfStripQuadrant) t_StripQuadrantNumber = m_NumberOfStripQuadrant; + // Rare case where particle is close to edge of silicon plan + if (t_StripRingNumber > m_NumberOfStripRing) + t_StripRingNumber = m_NumberOfStripRing; + if (t_StripSectorNumber > m_NumberOfStripSector) + t_StripSectorNumber = m_NumberOfStripSector; + if (t_StripQuadrantNumber > m_NumberOfStripQuadrant) + t_StripQuadrantNumber = m_NumberOfStripQuadrant; vector<DSSDData>::iterator it; // Ring - it = m_HitRing.find(DSSDData::CalculateIndex(t_StripRingNumber,t_DetectorNumber)); - if(it!=m_HitRing.end()){ + it = m_HitRing.find(DSSDData::CalculateIndex(t_StripRingNumber, t_DetectorNumber)); + if (it != m_HitRing.end()) { it->Add(t_Energy); } else - m_HitRing.Set(t_Energy,t_Time,t_StripRingNumber,t_DetectorNumber); + m_HitRing.Set(t_Energy, t_Time, t_StripRingNumber, t_DetectorNumber); - //Sector - it = m_HitSector.find(DSSDData::CalculateIndex(t_StripSectorNumber,t_DetectorNumber)); - if(it!=m_HitSector.end()){ + // Sector + it = m_HitSector.find(DSSDData::CalculateIndex(t_StripSectorNumber, t_DetectorNumber)); + if (it != m_HitSector.end()) { it->Add(t_Energy); } else - m_HitSector.Set(t_Energy,t_Time,t_StripSectorNumber,t_DetectorNumber); + m_HitSector.Set(t_Energy, t_Time, t_StripSectorNumber, t_DetectorNumber); - //Quadrant - it = m_HitQuadrant.find(DSSDData::CalculateIndex(t_StripQuadrantNumber,t_DetectorNumber)); - if(it!=m_HitQuadrant.end()){ + // Quadrant + it = m_HitQuadrant.find(DSSDData::CalculateIndex(t_StripQuadrantNumber, t_DetectorNumber)); + if (it != m_HitQuadrant.end()) { it->Add(t_Energy); } else - m_HitQuadrant.Set(t_Energy,t_Time,t_StripQuadrantNumber,t_DetectorNumber); + m_HitQuadrant.Set(t_Energy, t_Time, t_StripQuadrantNumber, t_DetectorNumber); return TRUE; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void PS_Annular::Initialize(G4HCofThisEvent*){ - clear(); -} +void PS_Annular::Initialize(G4HCofThisEvent*) { clear(); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void PS_Annular::EndOfEvent(G4HCofThisEvent*){ -} +void PS_Annular::EndOfEvent(G4HCofThisEvent*) {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void PS_Annular::clear(){ +void PS_Annular::clear() { m_HitRing.clear(); m_HitSector.clear(); m_HitQuadrant.clear(); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void PS_Annular::DrawAll(){ - -} +void PS_Annular::DrawAll() {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void PS_Annular::PrintAll(){ -} +void PS_Annular::PrintAll() {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -PS_Resistive::PS_Resistive(G4String name,G4int Level, G4double StripPlaneLength, G4double StripPlaneWidth, G4int NumberOfStripWidth,G4int depth) - :G4VPrimitiveScorer(name, depth){ - m_StripPlaneLength = StripPlaneLength; - m_StripPlaneWidth = StripPlaneWidth; - m_NumberOfStripWidth = NumberOfStripWidth; - m_StripPitchWidth = m_StripPlaneWidth / m_NumberOfStripWidth; - m_Level = Level; - - t_Position = G4ThreeVector(-1000,-1000,-1000); - t_DetectorNumber = -1; - t_StripWidthNumber = -1; - } +PS_Resistive::PS_Resistive(G4String name, G4String dir, G4int Level, G4double StripPlaneLength, + G4double StripPlaneWidth, G4int NumberOfStripWidth, G4int depth) + : G4VPrimitiveScorer(name, depth) { + m_StripPlaneLength = StripPlaneLength; + m_StripPlaneWidth = StripPlaneWidth; + m_NumberOfStripWidth = NumberOfStripWidth; + m_StripPitchWidth = m_StripPlaneWidth / m_NumberOfStripWidth; + m_Level = Level; + m_dir = dir; -//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -PS_Resistive::~PS_Resistive(){ + t_Position = G4ThreeVector(-1000, -1000, -1000); + t_DetectorNumber = -1; + t_StripWidthNumber = -1; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -G4bool PS_Resistive::ProcessHits(G4Step* aStep, G4TouchableHistory*){ +PS_Resistive::~PS_Resistive() {} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +G4bool PS_Resistive::ProcessHits(G4Step* aStep, G4TouchableHistory*) { // contain Energy Total, E1, E2, Time, DetNbr, and StripWidth - t_Energy = aStep->GetTotalEnergyDeposit(); + t_Energy = aStep->GetTotalEnergyDeposit(); t_Time = aStep->GetPreStepPoint()->GetGlobalTime(); - + t_DetectorNumber = aStep->GetPreStepPoint()->GetTouchableHandle()->GetCopyNumber(m_Level); t_Position = aStep->GetPreStepPoint()->GetPosition(); - t_Position = aStep->GetPreStepPoint()->GetTouchableHandle()->GetHistory()->GetTopTransform().TransformPoint(t_Position); + t_Position = + aStep->GetPreStepPoint()->GetTouchableHandle()->GetHistory()->GetTopTransform().TransformPoint(t_Position); - t_StripWidthNumber = (int)((t_Position.x() + m_StripPlaneWidth / 2.) / m_StripPitchWidth ) + 1 ; + t_StripWidthNumber = (int)((t_Position.x() + m_StripPlaneWidth / 2.) / m_StripPitchWidth) + 1; // The energy is divided in two depending on the position // position along the resistive strip - double P = (t_Position.z())/(0.5*m_StripPlaneLength); - // Energy - t_EnergyUp = aStep->GetTotalEnergyDeposit()*(1+P)*0.5; - t_EnergyDown = t_Energy-t_EnergyUp; + double P; + if (m_dir == "x") + P = (t_Position.x()) / (0.5 * m_StripPlaneLength); + else if (m_dir == "y") + P = (t_Position.y()) / (0.5 * m_StripPlaneLength); + else if (m_dir == "z") + P = (t_Position.z()) / (0.5 * m_StripPlaneLength); + else { + std::cout << "Error : Resistive strip DSSD scorer direction incorrect, should be x,y, or z " << std::endl; + exit(1); + } - //Rare case where particle is close to edge of silicon plan - if (t_StripWidthNumber > m_NumberOfStripWidth) t_StripWidthNumber = m_NumberOfStripWidth; + // Energy + t_EnergyUp = aStep->GetTotalEnergyDeposit() * (1 + P) * 0.5; + t_EnergyDown = t_Energy - t_EnergyUp; + // Rare case where particle is close to edge of silicon plan + if (t_StripWidthNumber > m_NumberOfStripWidth) + t_StripWidthNumber = m_NumberOfStripWidth; // Up vector<DSSDData>::iterator it; - it = m_HitUp.find(DSSDData::CalculateIndex(t_DetectorNumber,t_StripWidthNumber)); - if(it!=m_HitUp.end()) + it = m_HitUp.find(DSSDData::CalculateIndex(t_StripWidthNumber, t_DetectorNumber)); + if (it != m_HitUp.end()) { it->Add(t_EnergyUp); - else - m_HitUp.Set(t_EnergyUp,t_Time,t_StripWidthNumber,t_DetectorNumber); - + } + else { + m_HitUp.Set(t_EnergyUp, t_Time, t_StripWidthNumber, t_DetectorNumber); + } // Down - it = m_HitDown.find(DSSDData::CalculateIndex(t_DetectorNumber,t_StripWidthNumber)); - if(it!=m_HitDown.end()) + it = m_HitDown.find(DSSDData::CalculateIndex(t_StripWidthNumber, t_DetectorNumber)); + if (it != m_HitDown.end()) it->Add(t_EnergyDown); else - m_HitDown.Set(t_EnergyDown,t_Time,t_StripWidthNumber,t_DetectorNumber); - - // Back - it = m_HitBack.find(DSSDData::CalculateIndex(t_DetectorNumber,t_StripWidthNumber)); - if(it!=m_HitBack.end()) + m_HitDown.Set(t_EnergyDown, t_Time, t_StripWidthNumber, t_DetectorNumber); + + // Back + it = m_HitBack.find(DSSDData::CalculateIndex(t_StripWidthNumber, t_DetectorNumber)); + if (it != m_HitBack.end()) it->Add(t_Energy); else - m_HitBack.Set(t_Energy,t_Time,1,t_DetectorNumber); - - - + m_HitBack.Set(t_Energy, t_Time, 1, t_DetectorNumber); + return TRUE; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void PS_Resistive::Initialize(G4HCofThisEvent* ){ - clear(); -} +void PS_Resistive::Initialize(G4HCofThisEvent*) { clear(); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void PS_Resistive::EndOfEvent(G4HCofThisEvent*){ -} +void PS_Resistive::EndOfEvent(G4HCofThisEvent*) {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void PS_Resistive::clear(){ +void PS_Resistive::clear() { m_HitUp.clear(); m_HitDown.clear(); m_HitBack.clear(); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void PS_Resistive::DrawAll(){ - -} +void PS_Resistive::DrawAll() {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -void PS_Resistive::PrintAll(){ -} +void PS_Resistive::PrintAll() {} diff --git a/NPSimulation/Scorers/DSSDScorers.hh b/NPSimulation/Scorers/DSSDScorers.hh index 326c334b3769d0fe9f98328127d86365f530d9dd..c1c4f3a1f823852d0c76fcf5aa60dae49163d15d 100644 --- a/NPSimulation/Scorers/DSSDScorers.hh +++ b/NPSimulation/Scorers/DSSDScorers.hh @@ -25,332 +25,335 @@ *Only one scorer is needed for a detector * *****************************************************************************/ #include "G4VPrimitiveScorer.hh" -#include "NPSHitsMap.hh" #include "NPImage.h" +#include "NPSHitsMap.hh" #include <unordered_map> using namespace std; using namespace CLHEP; namespace DSSDScorers { // Hold data for DSSD hit - class DSSDData{ - public: - DSSDData(){}; - DSSDData(const double& Energy, const double& Time, const unsigned int& Strip, const unsigned int& Detector){ - m_Energy=Energy; - m_Time=Time; - m_Strip=Strip; - m_Detector=Detector; - m_Index = CalculateIndex(m_Strip,m_Detector); - } - - ~DSSDData(){}; - - private: - unsigned int m_Index; - double m_Energy; - double m_Time; - unsigned int m_Strip; - unsigned int m_Detector; - - public : // Modifier - inline void Set(const double& Energy, const double& Time, const unsigned int& Strip, const unsigned int& Detector){ - m_Energy=Energy; - m_Time=Time; - m_Strip=Strip; - m_Detector=Detector; - m_Index = CalculateIndex(m_Strip,m_Detector); - } - - inline void Add(const double& Energy) {m_Energy+=Energy;}; - - public: // Accessor - inline unsigned int GetIndex() const {return m_Index;}; - inline double GetEnergy() const {return m_Energy;}; - inline double GetTime() const {return m_Time;}; - inline unsigned int GetStrip() const {return m_Strip;}; - inline unsigned int GetDetector() const {return m_Detector;}; - - public: - static unsigned int CalculateIndex(const unsigned int& Strip,const unsigned int& Detector) {return Detector*1e6+Strip;} - + class DSSDData { + public: + DSSDData(){}; + DSSDData(const double& Energy, const double& Time, const unsigned int& Strip, const unsigned int& Detector) { + m_Energy = Energy; + m_Time = Time; + m_Strip = Strip; + m_Detector = Detector; + m_Index = CalculateIndex(m_Strip, m_Detector); + } + + ~DSSDData(){}; + + private: + unsigned int m_Index; + double m_Energy; + double m_Time; + unsigned int m_Strip; + unsigned int m_Detector; + + public: // Modifier + inline void Set(const double& Energy, const double& Time, const unsigned int& Strip, const unsigned int& Detector) { + m_Energy = Energy; + m_Time = Time; + m_Strip = Strip; + m_Detector = Detector; + m_Index = CalculateIndex(m_Strip, m_Detector); + } + + inline void Add(const double& Energy) { m_Energy += Energy; }; + + public: // Accessor + inline unsigned int GetIndex() const { return m_Index; }; + inline double GetEnergy() const { return m_Energy; }; + inline double GetTime() const { return m_Time; }; + inline unsigned int GetStrip() const { return m_Strip; }; + inline unsigned int GetDetector() const { return m_Detector; }; + + public: + static unsigned int CalculateIndex(const unsigned int& Strip, const unsigned int& Detector) { + return Detector * 1e6 + Strip; + } }; // Manage a vector of DSSD hit - class DSSDDataVector{ - public: - DSSDDataVector(){}; - ~DSSDDataVector(){}; - - private: - vector<DSSDData> m_Data; - - public: - vector<DSSDData>::iterator find(const unsigned int& index) ; - inline void clear(){m_Data.clear();} ; - inline vector<DSSDData>::iterator end() {return m_Data.end();}; - inline vector<DSSDData>::iterator begin() {return m_Data.begin();}; - inline unsigned int size() {return m_Data.size();}; - inline void Add(const unsigned int& index,const double& Energy) {find(index)->Add(Energy);}; - inline void Set(const double& Energy, const double& Time, const unsigned int& Strip, const unsigned int& Detector) {m_Data.push_back(DSSDData(Energy,Time,Strip,Detector));}; - DSSDData* operator[](const unsigned int& i){return &m_Data[i];}; + class DSSDDataVector { + public: + DSSDDataVector(){}; + ~DSSDDataVector(){}; + + private: + vector<DSSDData> m_Data; + + public: + vector<DSSDData>::iterator find(const unsigned int& index); + inline void clear() { m_Data.clear(); }; + inline vector<DSSDData>::iterator end() { return m_Data.end(); }; + inline vector<DSSDData>::iterator begin() { return m_Data.begin(); }; + inline unsigned int size() { return m_Data.size(); }; + inline void Add(const unsigned int& index, const double& Energy) { find(index)->Add(Energy); }; + inline void Set(const double& Energy, const double& Time, const unsigned int& Strip, const unsigned int& Detector) { + m_Data.push_back(DSSDData(Energy, Time, Strip, Detector)); + }; + DSSDData* operator[](const unsigned int& i) { return &m_Data[i]; }; }; //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... - class PS_Images : public G4VPrimitiveScorer{ - - public: // with description - PS_Images(G4String name, string imageFront,string imageBack,double scalingFront, double scalingBack, double centerOffsetX,double centerOffsetY,unsigned int ignoreValue, G4int depth=0); - ~PS_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 - DSSDDataVector m_HitFront; - DSSDDataVector m_HitBack; - - private: // Needed for intermediate calculation (avoid multiple instantiation in Processing Hit) - G4ThreeVector t_Position; - double t_Energy; - double t_Time; - unsigned int t_DetectorNbr; - unsigned int t_PixelFront; - unsigned int t_PixelBack; - - public: // information accessor - inline unsigned int GetFrontMult() {return m_HitFront.size();}; - inline unsigned int GetStripFront(const unsigned int& i){return m_HitFront[i]->GetStrip();}; - inline unsigned int GetDetectorFront(const unsigned int& i){return m_HitFront[i]->GetDetector();}; - inline double GetEnergyFront(const unsigned int& i){return m_HitFront[i]->GetEnergy();}; - inline double GetTimeFront(const unsigned int& i){return m_HitFront[i]->GetTime();}; - inline unsigned int GetBackMult() {return m_HitBack.size();}; - inline unsigned int GetStripBack(const unsigned int& i){return m_HitBack[i]->GetStrip();}; - inline unsigned int GetDetectorBack(const unsigned int& i){return m_HitBack[i]->GetDetector();}; - inline double GetEnergyBack(const unsigned int& i){return m_HitBack[i]->GetEnergy();}; - inline double GetTimeBack(const unsigned int& i){return m_HitBack[i]->GetTime();}; - - void GetARGBFront(unsigned int& i,unsigned int& a,unsigned int& r,unsigned int& g,unsigned int& b); - void GetARGBBack(unsigned int& i,unsigned int& a,unsigned int& r,unsigned int& g,unsigned int& b); + class PS_Images : public G4VPrimitiveScorer { + + public: // with description + PS_Images(G4String name, string imageFront, string imageBack, double scalingFront, double scalingBack, + double centerOffsetX, double centerOffsetY, unsigned int ignoreValue, G4int depth = 0); + ~PS_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 + DSSDDataVector m_HitFront; + DSSDDataVector m_HitBack; + + private: // Needed for intermediate calculation (avoid multiple instantiation in Processing Hit) + G4ThreeVector t_Position; + double t_Energy; + double t_Time; + unsigned int t_DetectorNbr; + unsigned int t_PixelFront; + unsigned int t_PixelBack; + + public: // information accessor + inline unsigned int GetFrontMult() { return m_HitFront.size(); }; + inline unsigned int GetStripFront(const unsigned int& i) { return m_HitFront[i]->GetStrip(); }; + inline unsigned int GetDetectorFront(const unsigned int& i) { return m_HitFront[i]->GetDetector(); }; + inline double GetEnergyFront(const unsigned int& i) { return m_HitFront[i]->GetEnergy(); }; + inline double GetTimeFront(const unsigned int& i) { return m_HitFront[i]->GetTime(); }; + inline unsigned int GetBackMult() { return m_HitBack.size(); }; + inline unsigned int GetStripBack(const unsigned int& i) { return m_HitBack[i]->GetStrip(); }; + inline unsigned int GetDetectorBack(const unsigned int& i) { return m_HitBack[i]->GetDetector(); }; + inline double GetEnergyBack(const unsigned int& i) { return m_HitBack[i]->GetEnergy(); }; + inline double GetTimeBack(const unsigned int& i) { return m_HitBack[i]->GetTime(); }; + + void GetARGBFront(unsigned int& i, unsigned int& a, unsigned int& r, unsigned int& g, unsigned int& b); + void GetARGBBack(unsigned int& i, unsigned int& a, unsigned int& r, unsigned int& g, unsigned int& b); }; //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... - class PS_Rectangle : public G4VPrimitiveScorer{ - - public: // with description - PS_Rectangle(G4String name, G4int Level, G4double StripPlaneLength, G4double StripPlaneWidth, G4int NumberOfStripLength,G4int NumberOfStripWidth,G4int depth=0,G4String axis="xy"); - ~PS_Rectangle(); - - private: - enum psAxis{ps_xy,ps_yz,ps_xz}; - psAxis m_Axis; - - 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 - double m_StripPlaneLength; - double m_StripPlaneWidth; - unsigned int m_NumberOfStripLength; - unsigned int m_NumberOfStripWidth; - double m_StripPitchLength; - double m_StripPitchWidth; - // Level at which to find the copy number linked to the detector number - int m_Level; - - private: // inherited from G4VPrimitiveScorer - DSSDDataVector m_HitLength; - DSSDDataVector m_HitWidth; - private: // Needed for intermediate calculation (avoid multiple instantiation in Processing Hit) - G4ThreeVector t_Position; - double t_Energy; - double t_Time; - unsigned int t_DetectorNumber; - unsigned int t_StripLengthNumber; - unsigned int t_StripWidthNumber; - - public: - inline unsigned int GetLengthMult() {return m_HitLength.size();}; - inline unsigned int GetStripLength(const unsigned int& i){return m_HitLength[i]->GetStrip();}; - inline unsigned int GetDetectorLength(const unsigned int& i){return m_HitLength[i]->GetDetector();}; - inline double GetEnergyLength(const unsigned int& i){return m_HitLength[i]->GetEnergy();}; - inline double GetTimeLength(const unsigned int& i){return m_HitLength[i]->GetTime();}; - inline unsigned int GetWidthMult() {return m_HitWidth.size();}; - inline unsigned int GetStripWidth(const unsigned int& i){return m_HitWidth[i]->GetStrip();}; - inline unsigned int GetDetectorWidth(const unsigned int& i){return m_HitWidth[i]->GetDetector();}; - inline double GetEnergyWidth(const unsigned int& i){return m_HitWidth[i]->GetEnergy();}; - inline double GetTimeWidth(const unsigned int& i){return m_HitWidth[i]->GetTime();}; - - - public: - static unsigned int CalculateIndex(const unsigned int& Strip,const unsigned int& Detector) {return Detector*1e6+Strip;} - - + class PS_Rectangle : public G4VPrimitiveScorer { + + public: // with description + PS_Rectangle(G4String name, G4int Level, G4double StripPlaneLength, G4double StripPlaneWidth, + G4int NumberOfStripLength, G4int NumberOfStripWidth, G4int depth = 0, G4String axis = "xy"); + ~PS_Rectangle(); + + private: + enum psAxis { ps_xy, ps_yz, ps_xz }; + psAxis m_Axis; + + 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 + double m_StripPlaneLength; + double m_StripPlaneWidth; + unsigned int m_NumberOfStripLength; + unsigned int m_NumberOfStripWidth; + double m_StripPitchLength; + double m_StripPitchWidth; + // Level at which to find the copy number linked to the detector number + int m_Level; + + private: // inherited from G4VPrimitiveScorer + DSSDDataVector m_HitLength; + DSSDDataVector m_HitWidth; + + private: // Needed for intermediate calculation (avoid multiple instantiation in Processing Hit) + G4ThreeVector t_Position; + double t_Energy; + double t_Time; + unsigned int t_DetectorNumber; + unsigned int t_StripLengthNumber; + unsigned int t_StripWidthNumber; + + public: + inline unsigned int GetLengthMult() { return m_HitLength.size(); }; + inline unsigned int GetStripLength(const unsigned int& i) { return m_HitLength[i]->GetStrip(); }; + inline unsigned int GetDetectorLength(const unsigned int& i) { return m_HitLength[i]->GetDetector(); }; + inline double GetEnergyLength(const unsigned int& i) { return m_HitLength[i]->GetEnergy(); }; + inline double GetTimeLength(const unsigned int& i) { return m_HitLength[i]->GetTime(); }; + inline unsigned int GetWidthMult() { return m_HitWidth.size(); }; + inline unsigned int GetStripWidth(const unsigned int& i) { return m_HitWidth[i]->GetStrip(); }; + inline unsigned int GetDetectorWidth(const unsigned int& i) { return m_HitWidth[i]->GetDetector(); }; + inline double GetEnergyWidth(const unsigned int& i) { return m_HitWidth[i]->GetEnergy(); }; + inline double GetTimeWidth(const unsigned int& i) { return m_HitWidth[i]->GetTime(); }; + + public: + static unsigned int CalculateIndex(const unsigned int& Strip, const unsigned int& Detector) { + return Detector * 1e6 + Strip; + } }; //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... - class PS_Annular : public G4VPrimitiveScorer{ - - public: // with description - PS_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_Annular(); - - 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 - double m_StripPlaneInnerRadius; - double m_StripPlaneOuterRadius; - double m_PhiStart; - double m_PhiStop; - unsigned int m_NumberOfStripRing; - unsigned int m_NumberOfStripSector; - unsigned int m_NumberOfStripQuadrant; - double m_StripPitchRing; - double m_StripPitchSector; - double m_StripPitchQuadrant; - string m_Axis; - // Level at which to find the copy number linked to the detector number - int m_Level; - - - private: // inherited from G4VPrimitiveScorer - DSSDDataVector m_HitRing; - DSSDDataVector m_HitSector; - DSSDDataVector m_HitQuadrant; - - - private: // Needed for intermediate calculation (avoid multiple instantiation in Processing Hit) - G4ThreeVector t_Position; - double t_Energy; - double t_Time; - unsigned int t_DetectorNumber; - unsigned int t_StripRingNumber; - unsigned int t_StripSectorNumber; - unsigned int t_StripQuadrantNumber; - - public: - inline unsigned int GetRingMult() {return m_HitRing.size();}; - inline unsigned int GetStripRing(const unsigned int& i){return m_HitRing[i]->GetStrip();}; - inline unsigned int GetDetectorRing(const unsigned int& i){return m_HitRing[i]->GetDetector();}; - inline double GetEnergyRing(const unsigned int& i){return m_HitRing[i]->GetEnergy();}; - inline double GetTimeRing(const unsigned int& i){return m_HitRing[i]->GetTime();}; - inline unsigned int GetSectorMult() {return m_HitSector.size();}; - inline unsigned int GetStripSector(const unsigned int& i){return m_HitSector[i]->GetStrip();}; - inline unsigned int GetDetectorSector(const unsigned int& i){return m_HitSector[i]->GetDetector();}; - inline double GetEnergySector(const unsigned int& i){return m_HitSector[i]->GetEnergy();}; - inline double GetTimeSector(const unsigned int& i){return m_HitSector[i]->GetTime();}; - inline unsigned int GetQuadrantMult() {return m_HitQuadrant.size();}; - inline unsigned int GetStripQuadrant(const unsigned int& i){return m_HitQuadrant[i]->GetStrip();}; - inline unsigned int GetDetectorQuadrant(const unsigned int& i){return m_HitQuadrant[i]->GetDetector();}; - inline double GetEnergyQuadrant(const unsigned int& i){return m_HitQuadrant[i]->GetEnergy();}; - inline double GetTimeQuadrant(const unsigned int& i){return m_HitQuadrant[i]->GetTime();}; - - private: // Needed for intermediate calculation (avoid multiple instantiation in Processing Hit) - G4ThreeVector m_uz ; - - public: - static unsigned int CalculateIndex(const unsigned int& Strip,const unsigned int& Detector) {return Detector*1e6+Strip;} - - + class PS_Annular : public G4VPrimitiveScorer { + + public: // with description + PS_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_Annular(); + + 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 + double m_StripPlaneInnerRadius; + double m_StripPlaneOuterRadius; + double m_PhiStart; + double m_PhiStop; + unsigned int m_NumberOfStripRing; + unsigned int m_NumberOfStripSector; + unsigned int m_NumberOfStripQuadrant; + double m_StripPitchRing; + double m_StripPitchSector; + double m_StripPitchQuadrant; + string m_Axis; + // Level at which to find the copy number linked to the detector number + int m_Level; + + private: // inherited from G4VPrimitiveScorer + DSSDDataVector m_HitRing; + DSSDDataVector m_HitSector; + DSSDDataVector m_HitQuadrant; + + private: // Needed for intermediate calculation (avoid multiple instantiation in Processing Hit) + G4ThreeVector t_Position; + double t_Energy; + double t_Time; + unsigned int t_DetectorNumber; + unsigned int t_StripRingNumber; + unsigned int t_StripSectorNumber; + unsigned int t_StripQuadrantNumber; + + public: + inline unsigned int GetRingMult() { return m_HitRing.size(); }; + inline unsigned int GetStripRing(const unsigned int& i) { return m_HitRing[i]->GetStrip(); }; + inline unsigned int GetDetectorRing(const unsigned int& i) { return m_HitRing[i]->GetDetector(); }; + inline double GetEnergyRing(const unsigned int& i) { return m_HitRing[i]->GetEnergy(); }; + inline double GetTimeRing(const unsigned int& i) { return m_HitRing[i]->GetTime(); }; + inline unsigned int GetSectorMult() { return m_HitSector.size(); }; + inline unsigned int GetStripSector(const unsigned int& i) { return m_HitSector[i]->GetStrip(); }; + inline unsigned int GetDetectorSector(const unsigned int& i) { return m_HitSector[i]->GetDetector(); }; + inline double GetEnergySector(const unsigned int& i) { return m_HitSector[i]->GetEnergy(); }; + inline double GetTimeSector(const unsigned int& i) { return m_HitSector[i]->GetTime(); }; + inline unsigned int GetQuadrantMult() { return m_HitQuadrant.size(); }; + inline unsigned int GetStripQuadrant(const unsigned int& i) { return m_HitQuadrant[i]->GetStrip(); }; + inline unsigned int GetDetectorQuadrant(const unsigned int& i) { return m_HitQuadrant[i]->GetDetector(); }; + inline double GetEnergyQuadrant(const unsigned int& i) { return m_HitQuadrant[i]->GetEnergy(); }; + inline double GetTimeQuadrant(const unsigned int& i) { return m_HitQuadrant[i]->GetTime(); }; + + private: // Needed for intermediate calculation (avoid multiple instantiation in Processing Hit) + G4ThreeVector m_uz; + + public: + static unsigned int CalculateIndex(const unsigned int& Strip, const unsigned int& Detector) { + return Detector * 1e6 + Strip; + } }; //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... - class PS_Resistive : public G4VPrimitiveScorer{ - - public: // with description - PS_Resistive(G4String name, G4int Level, - G4double StripPlaneLength, G4double StripPlaneWidth, - G4int NumberOfStripWidth,G4int depth=0); - - ~PS_Resistive(); - - 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 - double m_StripPlaneLength; - double m_StripPlaneWidth; - unsigned int m_NumberOfStripWidth; - double m_StripPitchWidth; - // Level at which to find the copy number linked to the detector number - G4int m_Level; - - private: - // Up and Down are each extremities of the resistive strip - DSSDDataVector m_HitUp; - DSSDDataVector m_HitDown; - DSSDDataVector m_HitBack; - - private: // Needed for intermediate calculation (avoid multiple instantiation in Processing Hit) - G4ThreeVector t_Position; - double t_Energy; - double t_EnergyUp; - double t_EnergyDown; - double t_Time; - unsigned int t_DetectorNumber; - unsigned int t_StripWidthNumber; - public: - inline unsigned int GetUpMult() {return m_HitUp.size();}; - inline unsigned int GetStripUp(const unsigned int& i){return m_HitUp[i]->GetStrip();}; - inline unsigned int GetDetectorUp(const unsigned int& i){return m_HitUp[i]->GetDetector();}; - inline double GetEnergyUp(const unsigned int& i){return m_HitUp[i]->GetEnergy();}; - inline double GetTimeUp(const unsigned int& i){return m_HitUp[i]->GetTime();}; - inline unsigned int GetDownMult() {return m_HitDown.size();}; - inline unsigned int GetStripDown(const unsigned int& i){return m_HitDown[i]->GetStrip();}; - inline unsigned int GetDetectorDown(const unsigned int& i){return m_HitDown[i]->GetDetector();}; - inline double GetEnergyDown(const unsigned int& i){return m_HitDown[i]->GetEnergy();}; - inline double GetTimeDown(const unsigned int& i){return m_HitDown[i]->GetTime();}; - inline unsigned int GetBackMult() {return m_HitBack.size();}; - inline unsigned int GetStripBack(const unsigned int& i){return m_HitBack[i]->GetStrip();}; - inline unsigned int GetDetectorBack(const unsigned int& i){return m_HitBack[i]->GetDetector();}; - inline double GetEnergyBack(const unsigned int& i){return m_HitBack[i]->GetEnergy();}; - inline double GetTimeBack(const unsigned int& i){return m_HitBack[i]->GetTime();}; - - + class PS_Resistive : public G4VPrimitiveScorer { + + public: // with description + PS_Resistive(G4String name, G4String dir, G4int Level, G4double StripPlaneLength, G4double StripPlaneWidth, + G4int NumberOfStripWidth, G4int depth = 0); + + ~PS_Resistive(); + + 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 + double m_StripPlaneLength; + double m_StripPlaneWidth; + unsigned int m_NumberOfStripWidth; + double m_StripPitchWidth; + G4String m_dir; + // Level at which to find the copy number linked to the detector number + G4int m_Level; + + private: + // Up and Down are each extremities of the resistive strip + DSSDDataVector m_HitUp; + DSSDDataVector m_HitDown; + DSSDDataVector m_HitBack; + + private: // Needed for intermediate calculation (avoid multiple instantiation in Processing Hit) + G4ThreeVector t_Position; + double t_Energy; + double t_EnergyUp; + double t_EnergyDown; + double t_Time; + unsigned int t_DetectorNumber; + unsigned int t_StripWidthNumber; + + public: + inline unsigned int GetUpMult() { return m_HitUp.size(); }; + inline unsigned int GetStripUp(const unsigned int& i) { return m_HitUp[i]->GetStrip(); }; + inline unsigned int GetDetectorUp(const unsigned int& i) { return m_HitUp[i]->GetDetector(); }; + inline double GetEnergyUp(const unsigned int& i) { return m_HitUp[i]->GetEnergy(); }; + inline double GetTimeUp(const unsigned int& i) { return m_HitUp[i]->GetTime(); }; + inline unsigned int GetDownMult() { return m_HitDown.size(); }; + inline unsigned int GetStripDown(const unsigned int& i) { return m_HitDown[i]->GetStrip(); }; + inline unsigned int GetDetectorDown(const unsigned int& i) { return m_HitDown[i]->GetDetector(); }; + inline double GetEnergyDown(const unsigned int& i) { return m_HitDown[i]->GetEnergy(); }; + inline double GetTimeDown(const unsigned int& i) { return m_HitDown[i]->GetTime(); }; + inline unsigned int GetBackMult() { return m_HitBack.size(); }; + inline unsigned int GetStripBack(const unsigned int& i) { return m_HitBack[i]->GetStrip(); }; + inline unsigned int GetDetectorBack(const unsigned int& i) { return m_HitBack[i]->GetDetector(); }; + inline double GetEnergyBack(const unsigned int& i) { return m_HitBack[i]->GetEnergy(); }; + inline double GetTimeBack(const unsigned int& i) { return m_HitBack[i]->GetTime(); }; }; -} - +} // namespace DSSDScorers #endif diff --git a/NPSimulation/Scorers/PlasticBar.cc b/NPSimulation/Scorers/PlasticBar.cc new file mode 100644 index 0000000000000000000000000000000000000000..a81634f1b425c03e808f28ea629913d220bcf3c5 --- /dev/null +++ b/NPSimulation/Scorers/PlasticBar.cc @@ -0,0 +1,106 @@ +/***************************************************************************** + * Copyright (C) 2009-2016 this file is part of the NPTool Project * + * * + * For the licensing terms see $NPTOOL/Licence/NPTool_Licence * + * For the list of contributors see $NPTOOL/Licence/Contributors * + *****************************************************************************/ + +/***************************************************************************** + * Original Author: Adrien MATTA contact address: matta@lpccaen.in2p3.fr * + * * + * Creation Date : February 2013 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * File old the scorer specific to the Sharc Detector * + * * + *---------------------------------------------------------------------------* + * Comment: * + * This new type of scorer is aim to become the standard for DSSD,SSSD and * + * PAD detector (any Silicon Detector) * + *****************************************************************************/ +#include "PlasticBar.hh" +#include "G4UnitsTable.hh" +using namespace PlasticBar; + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +unsigned int +PlasticBarData::CalculateIndex(const vector<unsigned int>& level) { + + unsigned int size = level.size(); + unsigned int result = 0; + unsigned int multiplier = 1; + for (unsigned int i = 0; i < size; i++) { + result += level[i] * multiplier; + multiplier *= 1000; + } + return result; +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +vector<PlasticBarData>::iterator +PlasticBarDataVector::find(const unsigned int& index) { + for (vector<PlasticBarData>::iterator it = m_Data.begin(); + it != m_Data.end(); it++) { + if ((*it).GetIndex() == index) + return it; + } + return m_Data.end(); +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +PS_PlasticBar::PS_PlasticBar(G4String name, vector<G4int> NestingLevel, + G4int depth) + : G4VPrimitiveScorer(name, depth) { + m_NestingLevel = NestingLevel; +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +PS_PlasticBar::~PS_PlasticBar() {} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +G4bool PS_PlasticBar::ProcessHits(G4Step* aStep, G4TouchableHistory*) { + G4String particlename + = aStep->GetTrack()->GetParticleDefinition()->GetParticleName(); + cout << particlename << " has left "; + // Contain Energy, Time + as many copy number as nested volume + unsigned int mysize = m_NestingLevel.size(); + t_Energy = aStep->GetTotalEnergyDeposit(); + cout << t_Energy << " MeV"; + t_Time = aStep->GetPreStepPoint()->GetGlobalTime(); + cout << " after " << t_Time << " ms" << endl; + t_Level.clear(); + for (unsigned int i = 0; i < mysize; i++) { + t_Level.push_back( + aStep->GetPreStepPoint()->GetTouchableHandle()->GetCopyNumber( + m_NestingLevel[i])); + } + // Check if the particle has interact before, if yes, add up the energies. + vector<PlasticBarData>::iterator it; + it = m_Data.find(PlasticBarData::CalculateIndex(t_Level)); + if (it != m_Data.end()) { + it->Add(t_Energy); + } else { + m_Data.Set(t_Energy, t_Time, t_Level); + } + return TRUE; +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +void PS_PlasticBar::Initialize(G4HCofThisEvent*) { clear(); } + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +void PS_PlasticBar::EndOfEvent(G4HCofThisEvent*) {} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +void PS_PlasticBar::clear() { + m_Data.clear(); + t_Level.clear(); +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +void PS_PlasticBar::DrawAll() {} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +void PS_PlasticBar::PrintAll() {} +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... diff --git a/NPSimulation/Scorers/PlasticBar.hh b/NPSimulation/Scorers/PlasticBar.hh new file mode 100644 index 0000000000000000000000000000000000000000..0e8a6d29d22384eada715c81e2d694ac3986cada --- /dev/null +++ b/NPSimulation/Scorers/PlasticBar.hh @@ -0,0 +1,125 @@ +#ifndef PlasticBar_h +#define PlasticBar_h 1 +/***************************************************************************** + * Copyright (C) 2009-2016 this file is part of the NPTool Project * + * * + * For the licensing terms see $NPTOOL/Licence/NPTool_Licence * + * For the list of contributors see $NPTOOL/Licence/Contributors * + *****************************************************************************/ + +/***************************************************************************** + * Original Author: Adrien MATTA contact address: matta@lpccaen.in2p3.fr * + * * + * Creation Date : February 2013 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * File old the scorer specific to the Silicon Detector * + * * + *---------------------------------------------------------------------------* + * Comment: * + * This new style of scorer is aim to become the standard way of doing scorer* + * in NPTool. * + *The index is build using the TrackID, Detector Number and Strip Number. * + *The scorer Hold Energy and time together * + *Only one scorer is needed for a detector * + *****************************************************************************/ +#include "G4VPrimitiveScorer.hh" +#include "NPSHitsMap.hh" +//#include "NPSecondaries.hh" + +#include <map> +using namespace std; +using namespace CLHEP; + +namespace PlasticBar { + // Hold One hit info + class PlasticBarData{ + public: + PlasticBarData(const double& Energy,const double& Time,const vector<unsigned int>& Nesting){ + m_Index=CalculateIndex(Nesting); + m_Level=Nesting; + m_Energy=Energy; + m_Time=Time; + }; + ~PlasticBarData(){}; + + private: + unsigned int m_Index; + vector<unsigned int> m_Level; + double m_Energy; + double m_Time; + + public: + static unsigned int CalculateIndex(const vector<unsigned int>& Nesting); + + public: + inline unsigned int GetIndex() const {return m_Index;} + inline vector<unsigned int> GetLevel() const {return m_Level;}; + inline double GetEnergy() const {return m_Energy;}; + inline double GetTime() const {return m_Time;}; + + public: + void Add(const double& Energy) {m_Energy+=Energy;}; + }; + + // Manage a vector of DSSD hit + class PlasticBarDataVector{ + public: + PlasticBarDataVector(){}; + ~PlasticBarDataVector(){}; + + private: + vector<PlasticBarData> m_Data; + + public: + vector<PlasticBarData>::iterator find(const unsigned int& index) ; + inline void clear(){m_Data.clear();} ; + inline vector<PlasticBarData>::iterator end() {return m_Data.end();}; + inline vector<PlasticBarData>::iterator begin() {return m_Data.begin();}; + inline unsigned int size() {return m_Data.size();}; + inline void Add(const unsigned int& index,const double& Energy) {find(index)->Add(Energy);}; + inline void Set(const double& Energy, const double& Time, const vector<unsigned int>& Nesting) {m_Data.push_back(PlasticBarData(Energy,Time,Nesting));}; + PlasticBarData* operator[](const unsigned int& i){return &m_Data[i];}; + }; + + + //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + class PS_PlasticBar : public G4VPrimitiveScorer{ + + public: // with description + PS_PlasticBar(G4String name, vector<G4int> NestingLevel,G4int depth=0); + ~PS_PlasticBar(); + + + protected: // with description + G4bool ProcessHits(G4Step*, G4TouchableHistory*); + + public: + void Initialize(G4HCofThisEvent*); + void EndOfEvent(G4HCofThisEvent*); + void clear(); + void DrawAll(); + void PrintAll(); + + private: // How much level of volume nesting should be considered + // Give the list of the nesting level at which the copy number should be return. + // 0 is the lowest level possible (the actual volume copy number in which the interaction happen) + vector<G4int> m_NestingLevel; + + private: + PlasticBarDataVector m_Data; + double t_Energy; + double t_Time; + vector<unsigned int> t_Level; + double t_ParticleMultiplicity; + public: + inline unsigned int GetMult() {return m_Data.size();}; + inline double GetEnergy(const unsigned int& i) {return m_Data[i]->GetEnergy();}; + inline double GetTime(const unsigned int& i) {return m_Data[i]->GetTime();}; + inline vector<unsigned int> GetLevel(const unsigned int& i) {return m_Data[i]->GetLevel();}; + }; +} + + +#endif diff --git a/Projects/ChiNu/chinu.detector b/Projects/ChiNu/chinu.detector index 353a27b8deda499d09f370dd33bf197928ee061e..152b2dd9c346903cae81b13c8691653676de823f 100644 --- a/Projects/ChiNu/chinu.detector +++ b/Projects/ChiNu/chinu.detector @@ -14,7 +14,7 @@ ChiNu LeadShield= 1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%FissionChamber -% POS= 0 0 0 mm -% GasMaterial= CF4 -% Pressure= 1 bar +FissionChamber + POS= 0 0 0 mm + GasMaterial= CF4 + Pressure= 1 bar diff --git a/Projects/Iss/.ls_return b/Projects/Iss/.ls_return new file mode 100644 index 0000000000000000000000000000000000000000..aa6c634f22bc6e0bb687ed477595b86959c53aa8 --- /dev/null +++ b/Projects/Iss/.ls_return @@ -0,0 +1 @@ +../../Outputs/Simulation/SimulatedTree.root diff --git a/Projects/Iss/Analysis.cxx b/Projects/Iss/Analysis.cxx new file mode 100644 index 0000000000000000000000000000000000000000..1a85242879beba4beee701d49008a59459a20638 --- /dev/null +++ b/Projects/Iss/Analysis.cxx @@ -0,0 +1,501 @@ +/***************************************************************************** + * Copyright (C) 2009-2019 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: M Labiche contact address: marc.labiche@stfc.ac.uk * + * * + * Creation Date : july 2019 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * Class describing the property of an Analysis object * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ + +#include<iostream> +using namespace std; +#include"Analysis.h" +#include"NPAnalysisFactory.h" +#include"NPDetectorManager.h" +#include"NPOptionManager.h" +#include"NPFunction.h" +#include"RootOutput.h" +#include"RootInput.h" +#include"NPPhysicalConstants.h" + + +//////////////////////////////////////////////////////////////////////////////// +Analysis::Analysis(){ +} +//////////////////////////////////////////////////////////////////////////////// +Analysis::~Analysis(){ +} + +//////////////////////////////////////////////////////////////////////////////// +void Analysis::Init(){ + Iss = (TIssPhysics*) m_DetectorManager->GetDetector("ISSDet"); + + + myInit= new TInitialConditions(); + myIntCoord= new TInteractionCoordinates(); + + InitOutputBranch(); + InitInputBranch(); + + + Bfield= Iss->GetNominalMField() ; + cout << "Nominal Magnetic field= " << Bfield << " milli(?) Tesla" << endl; + Bfield=Bfield*1000.; + cout << "Nominal Magnetic field= " << Bfield << " Tesla" << endl; + + //LightCD2 = EnergyLoss("Deuteron_CD2.G4table","G4Table",100 ); + //LightCD2 = EnergyLoss("He3_CD2.G4table","G4Table",100 ); + LightCD2 = EnergyLoss("proton_CD2.G4table","G4Table",100); + //LightAl = EnergyLoss("proton_Al.G4table","G4Table",100); + //LightSi = EnergyLoss("proton_Si.G4table","G4Table",100); + //BeamCD2 = EnergyLoss("Sn132_CD2.G4table","G4Table",100); + BeamCD2 = EnergyLoss("Mg28_CD2.G4table","G4Table",100); + //BeamCD2 = EnergyLoss("Ce146_CD2.G4table","G4Table",100); + //BeamCD2 = EnergyLoss("Rn212_CD2.G4table","G4Table",100); + //BeamCD2 = EnergyLoss("Pb190_CD2.G4table","G4Table",100); + //BeamCD2 = EnergyLoss("Sn108_CD2.G4table","G4Table",100); + //BeamCD2 = EnergyLoss("Ne17_CD2.G4table","G4Table",100); + //BeamCD2 = EnergyLoss("Hg206_CD2.G4table","G4Table",100); + + myReaction = new NPL::Reaction(); + myReaction->ReadConfigurationFile(NPOptionManager::getInstance()->GetReactionFile()); + + TargetThickness = m_DetectorManager->GetTargetThickness(); // * by micrometer to convert in mm + cout << "Target Thickness = " << TargetThickness << " mm" << endl; + + + OriginalBeamEnergy = myReaction->GetBeamEnergy(); + cout << "Beam Energy before target= " << OriginalBeamEnergy << " MeV" << endl; + + + pCharge= myReaction->GetNucleus3()->GetZ(); + + //double pAtomWeight= myReaction->GetNucleus3()->GetA(); + //double pMassExcess= myReaction->GetNucleus3()->GetMassExcess(); + //pMass= (pAtomWeight*amu_c2 + pMassExcess/1000)/amu_c2; + //cout << "Mass of light particle= " << pMass << endl; + //pMass= (myReaction->GetNucleus3().Mass())/amu_c2; + //pMass=1.00782503207; // MeV/c2 - for 132Sn(d,p) + //pMass=2.0141017778; // MeV/c2 - for 224Ra(d,d) + //pMass=12*931.49; // MeV/c2 - for 224Ra(C,C) + pMass1= (myReaction->GetNucleus1()->Mass())/amu_c2; // HI beam + pMass2= (myReaction->GetNucleus2()->Mass())/amu_c2; // tgt + pMass3= (myReaction->GetNucleus3()->Mass())/amu_c2; // light ejectile + pMass4= (myReaction->GetNucleus4()->Mass())/amu_c2; // beam-like + + + cout << "Charge of light particle= " << pCharge << endl; + cout << "Atomic Mass unit= " << amu_c2 << endl; + cout << "Mass of light particle= " << myReaction->GetNucleus3()->Mass() << endl; + cout << "Mass of light particle= " << pMass3 << " amu" << endl; + cout << "Mass of proj= " << pMass1 << " amu" << endl; + cout << "Mass of targ= " << pMass2 << " amu" << endl; + cout << "Mass of heavy particle= " << pMass4 << " amu" << endl; + cout << "Reaction QValue= " << myReaction->GetQValue() << " MeV" <<endl; + + + Rand = new TRandom3(); + DetectorNumber = 0 ; + ThetaNormalTarget = 0 ; + + ThetaIssSurface = 0; + X_Iss = 0 ; + Y_Iss = 0 ; + Z_Iss = 0 ; + Si_E_Iss = 0 ; + E_Iss = 0; + Si_X_Iss = 0; + Si_Y_Iss = 0; + + double BeamEnergy = BeamCD2.Slow(OriginalBeamEnergy,TargetThickness*0.5,0); + myReaction->SetBeamEnergy(BeamEnergy); + cout << "Beam energy set at " << BeamEnergy << " MeV" << endl; +} + +//////////////////////////////////////////////////////////////////////////////// +void Analysis::TreatEvent(){ + // Reinitiate calculated variable + ReInitValue(); + + double XTarget = -1001; + double YTarget = -1001; + + TVector3 BeamDirection = TVector3(0,0,1); + + double BeamEnergy = BeamCD2.Slow(OriginalBeamEnergy,TargetThickness/2,0); + myReaction->SetBeamEnergy(BeamEnergy); // set the new beam energy taking into account the beam energy loss in target befor reaction + + double Theta_extrap=0. ; + double ThetaDet =0. ; + //double ExcitationE=0. ; double ExcitationE_extrap=0. ; + + + TVector3 Pos; // for Iss + + + XTarget=myInit->GetIncidentPositionX(); + YTarget=myInit->GetIncidentPositionY(); + + + //if(Iss->Strip_E.size()>0)cout << "multiplicity= " << Iss->Strip_E.size()<< endl; + + + //////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////// + //////////////////////////// LOOP on ISS ////////////////// + if(Iss->Strip_E.size()>=1){ + + + /************************************************/ + // Part 1 : Interaction position in detector + + if(XTarget>-1000 && YTarget>-1000){ // XTarget and YTarget can be known experimentaly only if there are beam tracker detectors !!! + + //Pos = Iss->GetPositionOfInteraction(0,1); // Lab Position of the light particle interaction in the Si Detector for Iss (random inside the pixel) + + + Pos = Iss->GetPositionOfInteraction(0,0); // Lab Position of the light particle interaction in the Si Detector for Iss (center of pixel) + + + X_meas = Pos(0)/mm; + Y_meas = Pos(1)/mm; + Z_meas = Pos(2)/mm; + + //Z_Iss = myIntCoord->GetDetectedPositionZ(0); + + } + + else{ + BeamDirection = TVector3(-1000,-1000,-1000); + } + + /************************************************/ + + /************************************************/ + // Part 2 : Impact Energy + Energy = ISS_EDep = 0; + //Energy = Iss->GetEnergyDeposit(); + if(Iss->Strip_E[0]>0){ + Energy = Iss->Strip_E[0]; + } + + ISS_DetId= Iss->DetectorNumber[0]; // Assuming Multiplicity 1 + + // Detector intrinsic energy resolution + //ISS_EDep = Energy; // resolution already taken into account in simulation output for Is !! + //ISS_EDep = Rand->Gaus(Energy, 0.070/2.35); // 70 keV sigma resolution for Iss !! + ISS_EDep = Rand->Gaus(Energy, 0.060/2.35); // 60 keV sigma resolution for Iss !! + //ISS_EDep = Rand->Gaus(Energy, 0.020/2.35); // 20 keV sigma resolution for Iss !! + //ISS_EDep = Rand->Gaus(Energy, 0.040/2.35); // 40 keV sigma resolution for Iss !! + //ISS_EDep = Rand->Gaus(Energy, 0.080/2.35); // 80 keV sigma resolution for Iss !! + //ISS_EDep = Rand->Gaus(Energy, 0.10/2.35); // 100 keV sigma resolution for Iss !! + + ISS_Time= Iss->Strip_T[0]; + + /************************************************/ + + /************************************************/ + + // Part 3 for Iss: Z and theta extrapolation + ZonBeamAxis(Pos,ISS_EDep,pCharge,pMass3,Bfield,&Z_extrap,&ThetaDet,&Theta_extrap,&Nb_Iter); + if(Theta_extrap>=0){ // Todo: check in ZonBeamAxis why sometime nothing is returned for Theta_extrap !! + //cout << "Theta_extrap:" << Theta_extrap << endl; + + ThetaLab=Theta_extrap; // in degrees + + // Target Correction (ELab= EDep + Energy loss in target given ThetaLab ) + ISS_ELab = ISS_EDep; // without target correction + //cout << "ELab1=" << ELab <<endl; + //cout << "ThetaLab:" << ThetaLab << endl; + + ISS_ELab = LightCD2.EvaluateInitialEnergy( ISS_ELab ,TargetThickness/2., ThetaLab*deg); // with target correction but neglecting angular straggling in target + + + /************************************************/ + + /************************************************/ + // Part 4 : Excitation Energy Calculation + Ex = myReaction -> ReconstructRelativistic( ISS_ELab , ThetaLab*deg ); + + /************************************************/ + + /************************************************/ + // Part 5 : Theta CM Calculation + ThetaCM = myReaction -> EnergyLabToThetaCM( ISS_ELab , ThetaLab*deg )/deg; + + /************************************************/ + // Part 6 : Qvalue + + // !!!! Reaction dependent parameters for QValue !!!! : + + // initialisation: + //parA=1.0076 ; // (MeV) For132Sn(d,p) at 10 MeV/u (independent of B) + //parB=-9.9247 ; // For132Sn(d,p) at 10 MeV/u (independant on B) + //parC=-.1041 ; // (cm) For132Sn(d,p) at 10 MeV/u and B=1.5 T + + //parC=-.139 ; // (cm) For132Sn(d,p) at 10 MeV/u and B=2 T + //parC=-.2086 ; // (cm) For132Sn(d,p) at 10 MeV/u and B=3 T + + //parA=1.0089 ; // (MeV) For 224Ra(d,d) at 4 MeV/u + //parB=0.0001 ; // For 224Ra(d,d) at 4 MeV/u + //parC=-.1061 ; // (cm) For 224Ra(d,p) at 4 MeV/u + // parA= 1.0536 ; // (MeV) For 224Ra(C,C) at 4.5 MeV/u + // parB= 0.0008 ; // For 224Ra(C,C) at 4.5 MeV/u + // parC= -0.5628 ; // (cm) For 224Ra(C,C) at 4.5 MeV/u + + /* Calculating parA, parb, and parC : */ + double Vcm; + double Vbeam; + double gbeam; + //cout << "%%%%%% " << endl; + + Vcm= sqrt((2*myReaction->GetBeamEnergy()*(pMass1*amu_c2))) / ((pMass1+pMass2)*amu_c2) ; // in unit of c & non relativistic + Vbeam = sqrt(2*myReaction->GetBeamEnergy()/(pMass1*amu_c2)); // in unit of c - non relativist + //cout << "Vbeam=" <<Vbeam << endl; + //cout << "Vcm=" <<Vcm << endl; + + //cout << Vcm << " " << Vbeam << endl; + parA= (pMass3+pMass4)/pMass4; + //parB= (parA*((pMass3/2.)*amu_c2)*pow(Vcm,2) - ((pMass1+pMass2)/pMass2)*((pMass1/2.)*amu_c2)*(pow(Vbeam-Vcm,2))); + parB= parA*((pMass3/2.)*amu_c2)*pow(Vcm,2) - myReaction->GetBeamEnergy()*(pMass2/(pMass1+pMass2)); + parC=-(parA * pMass3 *amu_c2* Vcm) / ((c_light/(cm/s)) *2*pi*pMass3*1.660539e-27/(Bfield*pCharge*1.60218e-19)) ; + //parC=-(parA * pMass3 *amu_c2* Vcm) / ((c_light/(cm/s)) *54.6667e-9) ; + + /* Calculating Q value non relativistic*/ + QValue= parA*ISS_ELab + parB + parC*(Z_extrap/cm); // Peter's parameters (Z_extrap/cm to transform Z_extrap from mm to cm) + //if(Iss->GetTimeDetected()<31)cout << "Qv= " << parA*ELab + parB + parC*(Z_extrap/cm) << endl; + //QValue= QValue + 6.44808e-05*(Z_extrap)-0.00985694; // Peter's parameters (Z_extrap/cm to transform Z_extrap from mm to cm) + //cout << "QValue=" << QValue << endl; + + // or using relativistic reconstruction of Ex: + QValueR= ((pMass1+pMass2)-(pMass3+pMass4))*amu_c2 + Ex; + + /* Calculating maximum distance to beam axis*/ + MaxDAxis(ISS_ELab,pCharge,pMass3,Bfield,&Daxis); + } + + }//end loop Iss + + + +} + + +//////////////////////////////////////////////////////////////////////////////// +void Analysis::End(){ + cout << "Ebeam half way through Target= " << BeamEnergy << endl; + cout << "Tcycl= " << 65.6*( int(pMass3+0.5)/(pCharge*Bfield)) << "ns" << endl; + cout << "Tcycl= " << 2*pi*pMass3*1.660539e-27/(Bfield*pCharge*1.60218e-19) << "s" << endl; + cout << "pMass1= " <<pMass1 << " pMass4=" << pMass4 << endl; + cout << "pMass2= " <<pMass2 << " pMass3=" << pMass3 << endl; + cout << "parA= " <<parA << endl; + cout << "parB= " <<parB << endl; + cout << "parC= " <<parC << endl; + +} +//////////////////////////////////////////////////////////////////////////////// +void Analysis::InitOutputBranch() { + RootOutput::getInstance()->GetTree()->Branch("ISS_EDep",&ISS_EDep,"ISS_EDep/D"); + RootOutput::getInstance()->GetTree()->Branch("ISS_ELab",&ISS_ELab,"ISS_ELab/D"); + RootOutput::getInstance()->GetTree()->Branch("ISS_DetId",&ISS_DetId,"ISS_DetId/I"); + RootOutput::getInstance()->GetTree()->Branch("ISS_Time",&ISS_Time,"ISS_Time/D"); + RootOutput::getInstance()->GetTree()->Branch("Z_Iss",&Z_extrap,"Z_Iss/D"); // projected to beam axis +// RootOutput::getInstance()->GetTree()->Branch("Zextrap",&Z_extrap,"Z_extrap/D"); // projected to beam axis + + RootOutput::getInstance()->GetTree()->Branch("Ex",&Ex,"Ex/D"); + RootOutput::getInstance()->GetTree()->Branch("Qv",&QValue,"QValue/D"); + RootOutput::getInstance()->GetTree()->Branch("QvR",&QValueR,"QValueR/D"); + RootOutput::getInstance()->GetTree()->Branch("ThetaLab",&ThetaLab,"ThetaLab/D"); + RootOutput::getInstance()->GetTree()->Branch("ThetaCM",&ThetaCM,"ThetaCM/D"); + RootOutput::getInstance()->GetTree()->Branch("Xmeas",&X_meas,"X_meas/D"); // measured + RootOutput::getInstance()->GetTree()->Branch("Ymeas",&Y_meas,"Y_meas/D"); // measured + RootOutput::getInstance()->GetTree()->Branch("Zmeas",&Z_meas,"Z_meas/D"); // measured + RootOutput::getInstance()->GetTree()->Branch("NbIter",&Nb_Iter,"Nb_Iter/I"); // + RootOutput::getInstance()->GetTree()->Branch("Daxis",&Daxis,"Daxis/D"); // + +} + +//////////////////////////////////////////////////////////////////////////////// +void Analysis::InitInputBranch(){ + //RootInput:: getInstance()->GetChain()->SetBranchAddress("InitialConditions",&myInit ); + //RootInput:: getInstance()->GetChain()->SetBranchAddress("InteractionCoordinates",&myIntCoord ); +} + +//////////////////////////////////////////////////////////////////////////////// +void Analysis::ReInitValue(){ + ISS_ELab = -100; + ISS_EDep = -100; + ISS_DetId = -10; + ISS_Time = -10; + Z_Iss= -1000; + Ex= -100; + QValue = -10 ; + QValue = -10 ; + ThetaLab = -100; + ThetaCM = -100; + X_meas = -1000; + Y_meas = -1000; + Z_meas = -1000; + Z_extrap = -1000; + Nb_Iter = -10; + Daxis = -0.0001; + + + E_S1=S1ELab=-100; + Time_S1=-100; + Sector_S1=-10; + Ring_S1=-10; + + //S1E=-100; + S1Ring=-10; + S1Sector=-10; + S1Time=-10; +} + +//////////////////////////////////////////////////////////////////////////////// +void Analysis::ZonBeamAxis (TVector3 A, double nrj , int q, double Mp, double B, double *Z_extrap, double *ThetaDet, double *Theta_extrap, int *Nb_Iter) +{ + // double Z = acos( (A.Dot(B)) / (A.Mag()*B.Mag()) ); + double Zinit,Zf1, Zf2; + double Zeta_est=0; // = Theta lab of emitted particle + double Rho_max=0; + double Rprim, alpha; + double DeltaZ1,DeltaZ2; + int Nb_iteration; + //cout << "############################################################"<< endl; + //cout << "nrj=" << nrj << " q=" << q << " Mp=" << Mp << " B=" << B << endl; + + Zf1=Zinit= A(2)/m; // change Zdet from mm to m + //cout << "Zf1=" << Zf1 << endl; + + Rprim=sqrt(pow(A(0),2)+pow(A(1),2))/m; // from mm to m + //cout << "x=" << A(0) << "mm" << " y=" << A(1) << "mm"<< endl; + //cout << "Rprim=" << Rprim << "m"<< endl; + + Zeta_est= acos((Zf1*q*B)/(0.9046*sqrt(nrj*Mp))); + //cout << "cos_Zeta_est=" << (Zf1*q*B)/(0.9046*sqrt(nrj*Mp)) << " Zeta_est=" << Zeta_est*180/3.14159 << "deg"<< endl; + + *ThetaDet=Zeta_est/deg; // first estimation of Theta + + //cout << "ThetaDet=" << Zeta_est/deg << "deg"<< endl; + + Rho_max=0.2879*sqrt(nrj*Mp)*(sin(Zeta_est))/(q*B); + //cout << " Rho_max=" << Rho_max << endl; + + alpha=2*asin(Rprim/Rho_max); + //cout << " alpha=" << alpha*180/3.14152 << "deg" << endl; + + DeltaZ1=Zf1*alpha/(twopi); + //cout << " DeltaZ1= " << DeltaZ1 << endl; + + Zf2=DeltaZ1+Zf1; + //cout << " Zf2= " << Zf2 << endl; + + Nb_iteration=1; + +// Let's iterate: + + DeltaZ2=DeltaZ1; // initialisation of DeltaZ2 + + //while( sqrt((Zf2-Zf1)*(Zf2-Zf1)) > 0.000005 && DeltaZ1*DeltaZ2>0 ) // we itirate until we get a precision better than 0.005 mm OR until DeltaZ change sign (<=> to alpha changing sign). + while( sqrt(pow((Zf2-Zf1),2))*m > 0.00005 ) // we itirate until we get a precision better than 0.00005 mm + { + Zf1=Zf2; + + Zeta_est= acos((Zf1*q*B)/(0.9046*sqrt(nrj*Mp))); // estimating the new theta lab + //cout << "cos_Zeta_est=" << (Zf1*q*B)/(0.9046*sqrt(nrj*Mp)) << " theta_est=" << Zeta_est*180/3.14159 << "deg" << endl; + + Rho_max=0.2879*sqrt(nrj*Mp)*(sin(Zeta_est))/(q*B); // estimating the new Rho_max + //cout << " Rho_max=" << Rho_max << endl; + + //alpha=alpha-2*asin(Rprim/Rho_max); // estimating the new alpha + alpha=2*asin(Rprim/Rho_max); // estimating the new alpha with the new Rho_max + //cout << " alpha=" << alpha*180/3.14159 << " deg" << endl; + + //DeltaZ2=Zf1*alpha/(2*3.14159); + DeltaZ2=Zinit*alpha/(twopi); + //cout << " DeltaZ2= " << DeltaZ2 << endl; + + //Zf2=DeltaZ2 + Zf1; + Zf2=DeltaZ2 + Zinit; // estimating the new Zf2 + //cout << " New Zf2= " << Zf2 << endl; + + + Nb_iteration++; + } + + //cout << "Nb_iteration= " << Nb_iteration<< endl; + + *Z_extrap=Zf2*m; // retuns in mm + *Theta_extrap=Zeta_est/deg; // returns Theta_extrap in deg + *Nb_Iter=Nb_iteration; + return; // returning a value in mm +} + + +//////////////////////////////////////////////////////////////////////////////// +// To calculate the maximum distance to axis +void Analysis::MaxDAxis (double nrj , int q, double Mp, double B, double *D) +{ + double Vt; // transversal velocity + double Rc; // rayon de courbure + double Result; // + + + //cout << " q= " << q << endl; + //cout << " Mp= " << Mp << endl; + + Vt= sqrt(2*nrj/(Mp*amu_c2))*c_light; // in m/s + + Rc= Mp*1.660539e-27*Vt/(q*1.60218e-19*B); // in m + + //cout << "nrj=" << nrj << endl; + //cout << "Vt=" << Vt << endl; + //cout << "q=" << q << endl; + //cout << "B=" << B << endl; + //cout << "Rc=" << Rc << endl; + + Result= 2.*Rc*100.; // * by 100. to convert in cm + + //cout << "Result=" << Result << endl; + + *D = Result; + return; +} + + + +//////////////////////////////////////////////////////////////////////////////// +// Construct Method to be pass to the AnalysisFactory // +//////////////////////////////////////////////////////////////////////////////// +NPL::VAnalysis* Analysis::Construct(){ + return (NPL::VAnalysis*) new Analysis(); +} + +//////////////////////////////////////////////////////////////////////////////// +// Registering the construct method to the factory // +//////////////////////////////////////////////////////////////////////////////// +extern "C"{ +class proxy{ + public: + proxy(){ + NPL::AnalysisFactory::getInstance()->SetConstructor(Analysis::Construct); + } +}; + +proxy p; +} + diff --git a/Projects/Iss/Analysis.h b/Projects/Iss/Analysis.h new file mode 100644 index 0000000000000000000000000000000000000000..a2a46910fabf870445d5ce6cb2f5de63c896d69b --- /dev/null +++ b/Projects/Iss/Analysis.h @@ -0,0 +1,124 @@ +#ifndef Analysis_h +#define Analysis_h +/***************************************************************************** + * Copyright (C) 2009-2019 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: M Labiche contact address: marc.labiche@stfc.ac.uk * + * * + * Creation Date : july 2019 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * Class describing the property of an Analysis object * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ +#include"NPVAnalysis.h" +#include"NPEnergyLoss.h" +#include"NPReaction.h" +#include"RootOutput.h" +#include"RootInput.h" + +#include "TInitialConditions.h" +#include "TInteractionCoordinates.h" +#include <TRandom3.h> +#include <TVector3.h> +#include <TMath.h> + +#include "TIssPhysics.h" +//#include"TAnnularS1Physics.h" + +class Analysis: public NPL::VAnalysis{ + public: + Analysis(); + ~Analysis(); + + public: + void Init(); + void TreatEvent(); + void End(); + + void InitOutputBranch(); + void InitInputBranch(); + void ReInitValue(); + static NPL::VAnalysis* Construct(); + + //void ZonBeamAxis (TVector3 A, double E, int q, double M, double B, double*, double*, double*) ; + void ZonBeamAxis (TVector3 A, double E, int q, double M, double B, double*, double*, double*, int*) ; + + void MaxDAxis (double E, int q, double M, double B, double*) ; + + private: + double Ex, QValue, QValueR, X_meas, Y_meas, Z_meas, Z_extrap, Daxis; + double ISS_ELab; // initial energy of particle detected in ISS, after target nrj loss correction. + double ThetaLab; + double ThetaCM; + + double ISS_EDep; // energy deposited in ISS + double ISS_Time; + int ISS_DetId; + + double S1_EDep; + double S1_Time; + int S1_RingId, S1_SectId; + + int Nb_Iter; + NPL::Reaction* myReaction; + + double BeamEnergy; + double parA,parB,parC; + + + + // Energy loss table: the G4Table are generated by the simulation + EnergyLoss LightCD2; + //EnergyLoss LightAl; + //EnergyLoss LightSi; + EnergyLoss BeamCD2; + TVector3 BeamImpact; + + double TargetThickness ; + // Beam Energy + double OriginalBeamEnergy ; // AMEV + // Light ejectile Charge and Mass + int pCharge; + double pMass1, pMass2, pMass3, pMass4; + + // Nominal magnetic field + double Bfield; + // intermediate variable + TRandom3 *Rand ; + int DetectorNumber ; + double ThetaNormalTarget; + + + double Energy, Energy_S1 ; + + double ThetaIssSurface ; + double X_Iss ; + double Y_Iss ; + double Z_Iss ; + double Si_E_Iss ; + double E_Iss ; + double Si_X_Iss ; + double Si_Y_Iss ; + + double S1ELab, S1Time; + double E_S1,Time_S1; + int Ring_S1,Sector_S1; + int S1Ring, S1Sector; + + TInitialConditions* myInit ; + TInteractionCoordinates* myIntCoord ; + TIssPhysics* Iss; +// TAnnularS1Physics* S1; +}; +#endif diff --git a/Projects/Iss/CMakeLists.txt b/Projects/Iss/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..22c74affdfc45019bdda2594f8439c52d4ab97ec --- /dev/null +++ b/Projects/Iss/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required (VERSION 2.8) +# Setting the policy to match Cmake version +cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}) +# include the default NPAnalysis cmake file +include("../../NPLib/ressources/CMake/NPAnalysis.cmake") diff --git a/Projects/Iss/RunToTreat.txt b/Projects/Iss/RunToTreat.txt new file mode 100644 index 0000000000000000000000000000000000000000..e9e25937b5bc55fcae0c5444cc967452ad7a0438 --- /dev/null +++ b/Projects/Iss/RunToTreat.txt @@ -0,0 +1,4 @@ +TTreeName + SimulatedTree +RootFileName +../../Outputs/Simulation/myResult.root diff --git a/Projects/Iss/configs/ConfigAnnularS1.dat b/Projects/Iss/configs/ConfigAnnularS1.dat new file mode 100644 index 0000000000000000000000000000000000000000..21930ff70030a0635e3863744c72e3942f17c452 --- /dev/null +++ b/Projects/Iss/configs/ConfigAnnularS1.dat @@ -0,0 +1,6 @@ +%%%%%%%%%%%%%%% +ConfigAnnularS1 +MAX_STRIP_MULTIPLICITY 2 +STRIP_ENERGY_MATCHING_SIGMA 0.06 +STRIP_ENERGY_MATCHING_NUMBER_OF_SIGMA 3 +% diff --git a/Projects/Iss/configs/ConfigIss.dat b/Projects/Iss/configs/ConfigIss.dat new file mode 100644 index 0000000000000000000000000000000000000000..59c228e19e967232fd9d724e482ea2994c14d0d1 --- /dev/null +++ b/Projects/Iss/configs/ConfigIss.dat @@ -0,0 +1,5 @@ +ConfigIss +MAX_STRIP_MULTIPLICITY 10 +STRIP_ENERGY_MATCHING_SIGMA 6 +STRIP_ENERGY_MATCHING_NUMBER_OF_SIGMA 3 + diff --git a/Projects/Iss/defaultRunToTreat.txt b/Projects/Iss/defaultRunToTreat.txt new file mode 100644 index 0000000000000000000000000000000000000000..a2a8edc552d2f159e50e340222b54e2d7adbeb53 --- /dev/null +++ b/Projects/Iss/defaultRunToTreat.txt @@ -0,0 +1,4 @@ +TTreeName + SimulatedTree +RootFileName +../../Outputs/Simulation/SimulatedTree.root diff --git a/Projects/Nebula/8Hp2p.reaction b/Projects/Nebula/8Hp2p.reaction deleted file mode 100755 index c90a099b52e7923d715e00ef8dcad3fd00d3a5b8..0000000000000000000000000000000000000000 --- a/Projects/Nebula/8Hp2p.reaction +++ /dev/null @@ -1,28 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -Beam - Particle= 8He - Energy= 2000 MeV - SigmaEnergy= 100 MeV - SigmaThetaX= 1 deg - SigmaPhiY= 1 deg - SigmaX= 5 mm - SigmaY= 5 mm - MeanThetaX= 0 deg - MeanPhiY= 0 deg - MeanX= 0 mm - MeanY= 0 mm - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -QFSReaction - Beam= 8He - Target= 1H - Scattered= 1H - KnockedOut= 1H - Heavy= 7H - ExcitationEnergyBeam= 0.0 MeV - ExcitationEnergyHeavy= 3.6800 MeV - MomentumSigma= 50.0 - ShootHeavy= 1 - ShootLight= 1 - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/Projects/Nebula/Nebula.detector b/Projects/Nebula/Nebula.detector index bac1199e6a78636a5aacab60a7e097aa72842d1f..bed889732401a0802694eeb598743fa6b3ebca77 100644 --- a/Projects/Nebula/Nebula.detector +++ b/Projects/Nebula/Nebula.detector @@ -1,53 +1,53 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Target - THICKNESS= 10 micrometer - RADIUS= 20 mm - MATERIAL= CD2 + THICKNESS= 0.49 cm + RADIUS= 28 mm + MATERIAL= Vacuum ANGLE= 0 deg - X= 0 mm + X= 3.5 cm Y= 0 mm - Z= -4000 mm + Z= 0 mm +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% NEBULA - POS= 0 0 5 m - NumberOfModule= 30 + POS= 0 0 12 m + NumberOfModule= 15 Veto= 1 Frame= 1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% NEBULA - POS= 0 0 5.15 m - NumberOfModule= 30 + POS= 0 0 12.15 m + NumberOfModule= 15 Veto= 0 Frame= 0 -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% NEBULA - POS= 0 0 10 m + POS= 0 0 16 m NumberOfModule= 30 Veto= 1 Frame= 1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% NEBULA - POS= 0 0 10.15 m + POS= 0 0 16.15 m NumberOfModule= 30 Veto= 0 Frame= 0 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% NEBULA - POS= 0 0 3 m - NumberOfModule= 15 + POS= 0 0 18 m + NumberOfModule= 30 Veto= 1 Frame= 1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% NEBULA - POS= 0 0 3.15 m - NumberOfModule= 15 + POS= 0 0 18.15 m + NumberOfModule= 30 Veto= 0 Frame= 0 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %Samurai % POS= 0 0 0 mm @@ -78,4 +78,4 @@ NEBULA % %InvertY= 1 % %InvertD= 1 -% + diff --git a/Projects/Nebula/PhysicsListOption.txt b/Projects/Nebula/PhysicsListOption.txt new file mode 100644 index 0000000000000000000000000000000000000000..2a32a3b1722a1ec55d040d6e46faf8b513c453a0 --- /dev/null +++ b/Projects/Nebula/PhysicsListOption.txt @@ -0,0 +1,11 @@ +EmPhysicsList Option4 +DefaultCutOff 1 +IonBinaryCascadePhysics 0 +NPIonInelasticPhysics 0 +EmExtraPhysics 0 +HadronElasticPhysics 0 +StoppingPhysics 0 +OpticalPhysics 0 +HadronPhysicsINCLXX 0 +HadronPhysicsQGSP_BIC_HP 1 +Decay 0 diff --git a/Projects/Nebula/SimpleNeutrons.reaction b/Projects/Nebula/SimpleNeutrons.reaction new file mode 100755 index 0000000000000000000000000000000000000000..6f5aea35fb4485aedc285ab8ba581ecc955b4c9a --- /dev/null +++ b/Projects/Nebula/SimpleNeutrons.reaction @@ -0,0 +1,14 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +Beam + Particle= n + Energy= 196 MeV + SigmaEnergy= 0.5 MeV + SigmaThetaX= 0.01 deg + SigmaPhiY= 0.01 deg + SigmaX= 0.5 mm + SigmaY= 0.5 mm + MeanThetaX= 0 deg + MeanPhiY= 0 deg + MeanX= 3.5 cm + MeanY= 0 mm + ZEmission= -1000 mm diff --git a/Projects/Nebula/flat.txt b/Projects/Nebula/flat.txt new file mode 100644 index 0000000000000000000000000000000000000000..09b15128730aecce2f1126bf7937af827eba3712 --- /dev/null +++ b/Projects/Nebula/flat.txt @@ -0,0 +1,3 @@ +0 1 +90 1 +180 1 diff --git a/Projects/S034/PhysicsListOption.txt b/Projects/S034/PhysicsListOption.txt index 3b244f7098f03939f28c0a9ad8c90b78e028205a..5a8ee25ad212625d67b030883117e7229e89d61f 100644 --- a/Projects/S034/PhysicsListOption.txt +++ b/Projects/S034/PhysicsListOption.txt @@ -1,5 +1,5 @@ EmPhysicsList Option4 -DefaultCutOff 1 +DefaultCutOff 10 IonBinaryCascadePhysics 0 NPIonInelasticPhysics 0 EmExtraPhysics 0 diff --git a/Projects/Sofia/macro/ShowResultSimu.C b/Projects/Sofia/macro/ShowResultSimu.C index bcd54d4841a611eaa0463d0a1873a7343efffbea..320e26a79ba59ed5610baa458a64684344045385 100644 --- a/Projects/Sofia/macro/ShowResultSimu.C +++ b/Projects/Sofia/macro/ShowResultSimu.C @@ -4,16 +4,26 @@ TChain* chain=NULL; void LoadRootFile(){ chain = new TChain("SimulatedTree"); - chain->Add("../../../Outputs/Simulation/sofia_simu_1.root"); - chain->Add("../../../Outputs/Simulation/sofia_simu_2.root"); - chain->Add("../../../Outputs/Simulation/sofia_simu_3.root"); - chain->Add("../../../Outputs/Simulation/sofia_simu_4.root"); - chain->Add("../../../Outputs/Simulation/sofia_simu_5.root"); - chain->Add("../../../Outputs/Simulation/sofia_simu_6.root"); - chain->Add("../../../Outputs/Simulation/sofia_simu_7.root"); - chain->Add("../../../Outputs/Simulation/sofia_simu_8.root"); - chain->Add("../../../Outputs/Simulation/sofia_simu_9.root"); - chain->Add("../../../Outputs/Simulation/sofia_simu_10.root"); + chain->Add("../../../Outputs/Simulation/sofia_simu_glad_1.root"); + chain->Add("../../../Outputs/Simulation/sofia_simu_glad_2.root"); + chain->Add("../../../Outputs/Simulation/sofia_simu_glad_3.root"); + chain->Add("../../../Outputs/Simulation/sofia_simu_glad_4.root"); + chain->Add("../../../Outputs/Simulation/sofia_simu_glad_5.root"); + chain->Add("../../../Outputs/Simulation/sofia_simu_glad_6.root"); + chain->Add("../../../Outputs/Simulation/sofia_simu_glad_7.root"); + chain->Add("../../../Outputs/Simulation/sofia_simu_glad_8.root"); + chain->Add("../../../Outputs/Simulation/sofia_simu_glad_9.root"); + chain->Add("../../../Outputs/Simulation/sofia_simu_glad_10.root"); + chain->Add("../../../Outputs/Simulation/sofia_simu_glad_11.root"); + chain->Add("../../../Outputs/Simulation/sofia_simu_glad_12.root"); + chain->Add("../../../Outputs/Simulation/sofia_simu_glad_13.root"); + chain->Add("../../../Outputs/Simulation/sofia_simu_glad_14.root"); + chain->Add("../../../Outputs/Simulation/sofia_simu_glad_15.root"); + chain->Add("../../../Outputs/Simulation/sofia_simu_glad_16.root"); + chain->Add("../../../Outputs/Simulation/sofia_simu_glad_17.root"); + chain->Add("../../../Outputs/Simulation/sofia_simu_glad_18.root"); + chain->Add("../../../Outputs/Simulation/sofia_simu_glad_19.root"); + chain->Add("../../../Outputs/Simulation/sofia_simu_glad_20.root"); } ////////////////////////////////////////////////////////////////// @@ -21,13 +31,13 @@ void ShowResultSimu() { LoadRootFile(); - chain->Draw("fDetected_Position_Y:fDetected_Position_X>>hpos(500,-1900,-900,500,-350,350)","fTOF_Energy@.size()>0","colz"); + chain->Draw("fDetected_Position_Y:fDetected_Position_X>>hpos(200,-2100,-1100,200,-350,350)","fTOF_Energy@.size()==2","colz"); TH2F* hpos = (TH2F*)gDirectory->FindObjectAny("hpos"); chain->Draw("fFC_Fragment_Z>>h1(35,30,65)"); TH1F* h1 = (TH1F*)gDirectory->FindObjectAny("h1"); - chain->Draw("fDetected_Z>>h2(35,30,65)","fTOF_Energy@.size()>0"); + chain->Draw("fDetected_Z>>h2(35,30,65)","fTOF_Energy@.size()==2"); TH1F* h2 = (TH1F*)gDirectory->FindObjectAny("h2"); h1->Sumw2(); diff --git a/Projects/Sofia/sofia.detector b/Projects/Sofia/sofia.detector index d25435a8935a11c1edc05a767af382188a329f43..7cc1d3e5d5692e869e575bb6ca3fbf0ff97cf7e0 100644 --- a/Projects/Sofia/sofia.detector +++ b/Projects/Sofia/sofia.detector @@ -1,7 +1,7 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Target THICKNESS= 2 mm - RADIUS= 50 mm + RADIUS= 100 mm MATERIAL= Pb ANGLE= 0 deg X= 0 mm @@ -9,21 +9,21 @@ Target Z= 0 m %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SofTofW - R= 4 m - THETA= -20 deg + R= 5 m + THETA= -18 deg PHI= 0 deg Build_GLAD= 1 GLAD_TiltAngle= 14 deg - GLAD_DistanceFromTarget= 3.05 m - Build_MagneticField= 1 - GLAD_MagField= 1.70 T - Build_VacuumPipe= 0 + GLAD_DistanceFromTarget= 3.3 m + Build_MagneticField= 1 + GLAD_MagField= 1.80 T + Build_VacuumPipe= 1 VacuumPipeX= 0 cm VacuumPipeY= 0 cm VacuumPipeZ= 0.9 m %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%SofTwim - R= 1.85 m +SofTwim + R= 2.00 m THETA= 0 PHI= 0 TwimGas= MixTwinMusic diff --git a/Projects/Strasse/PhysicsListOption.txt b/Projects/Strasse/PhysicsListOption.txt index ff38d11c7d6361c44a8d00159a7a5543a22c25cd..495166f434c7f2377d07f89ba844aa37411514a3 100644 --- a/Projects/Strasse/PhysicsListOption.txt +++ b/Projects/Strasse/PhysicsListOption.txt @@ -1,5 +1,5 @@ EmPhysicsList Option4 -DefaultCutOff 1000000 +DefaultCutOff 1000 IonBinaryCascadePhysics 0 NPIonInelasticPhysics 0 EmExtraPhysics 0 diff --git a/Projects/Strasse/geometry/catana_only.detector b/Projects/Strasse/geometry/catana_only.detector index dcbfc9e5d7d5921feed64ff03c9e4773f54945d3..3445cbaa5f6c5d1c840552158ed62601a78739d9 100644 --- a/Projects/Strasse/geometry/catana_only.detector +++ b/Projects/Strasse/geometry/catana_only.detector @@ -11,7 +11,7 @@ Target %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%1 Catana CSV - Path= geometry/Catana.csv + Path= geometry/CATANA_nptool_sim.csv Pos= 0 0 100 mm Rshift= 100 micrometer diff --git a/Projects/Strasse/geometry/strasse_CAD.detector b/Projects/Strasse/geometry/strasse_CAD.detector index 28aeff76d5271140d06d0f94644b3379f047dbc0..8e917df8dce733c15ca9602739d556a3e86b85e2 100644 --- a/Projects/Strasse/geometry/strasse_CAD.detector +++ b/Projects/Strasse/geometry/strasse_CAD.detector @@ -87,15 +87,15 @@ Strasse Outer Ref= 0 0 0 mm %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%Strasse InactiveMaterial -% Chamber= ./geometry/STRASSE_Chamber.stl -% Stars= ./geometry/STRASSE_StarSupports.stl -% Base= ./geometry/STRASSE_Base.stl -% Blades= ./geometry/STRASSE_Blades.stl +Strasse InactiveMaterial + Chamber= ./geometry/STRASSE_Chamber.stl + Stars= ./geometry/STRASSE_StarSupports.stl + Base= ./geometry/STRASSE_Base.stl + Blades= ./geometry/STRASSE_Blades.stl %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%1 -%Catana CSV -% Path= geometry/Catana.csv -% Pos= 0 0 100 mm -% Rshift= 100 micrometer +Catana CSV + Path= geometry/Catana.csv + Pos= 0 0 100 mm + Rshift= 100 micrometer diff --git a/Projects/Strasse/geometry/strasse_July2021.detector b/Projects/Strasse/geometry/strasse_July2021.detector index aa02386b2bb1003f5c2b8cf8b27c428ec3679a74..fe5d254cab330be48c3590d05d4efe38e43201ef 100644 --- a/Projects/Strasse/geometry/strasse_July2021.detector +++ b/Projects/Strasse/geometry/strasse_July2021.detector @@ -93,9 +93,9 @@ Strasse Outer % Base= ./geometry/STRASSE_Base.stl % Blades= ./geometry/STRASSE_Blades.stl %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%1 -%Catana CSV -% Path= geometry/Catana.csv -% Pos= 0 0 100 mm -% Rshift= 100 micrometer +Catana CSV + Path= geometry/Catana.csv + Pos= 0 0 100 mm + Rshift= 100 micrometer diff --git a/Projects/Strasse/reaction/C12_p2p.reaction b/Projects/Strasse/reaction/C12_p2p.reaction index 6e9e34a8c5d1516c079679d86afe9762a2addba7..35905b5ae139d39012956b1fb02a46a3be533851 100755 --- a/Projects/Strasse/reaction/C12_p2p.reaction +++ b/Projects/Strasse/reaction/C12_p2p.reaction @@ -11,7 +11,7 @@ Beam MeanPhiY= 0 deg MeanX= 0 mm MeanY= 0 mm - + ZEmission= 0mm %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% QFSReaction Beam= 12C @@ -20,7 +20,7 @@ QFSReaction KnockedOut= 1H Heavy= 11B ExcitationEnergyBeam= 0.0 MeV - ExcitationEnergyHeavy= 0.0 MeV + ExcitationEnergyHeavy= 1.0 MeV MomentumSigma= 50.0 ShootHeavy= 1 ShootLight= 1 diff --git a/Projects/Strasse/reaction/Ca54.source b/Projects/Strasse/reaction/Ca54.source index e757578611cfe7910f9b98c157b5bb3c0b798994..d5bfa4982e64b2902a23f00caed141bce71117df 100755 --- a/Projects/Strasse/reaction/Ca54.source +++ b/Projects/Strasse/reaction/Ca54.source @@ -12,6 +12,7 @@ Beam MeanX= 0 mm MeanY= 0 mm ExcitationEnergy= 3680 keV + ZEmmission= 0 mm %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LevelData 54Ca Path= reaction/54Ca.dat diff --git a/Projects/SuperX3/Analysis.cxx b/Projects/SuperX3/Analysis.cxx new file mode 100644 index 0000000000000000000000000000000000000000..555fb577148408c98dc62e95ae30c45c93d69752 --- /dev/null +++ b/Projects/SuperX3/Analysis.cxx @@ -0,0 +1,83 @@ +/***************************************************************************** + * Copyright (C) 2009-2014 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: a.matta@surrey.ac.uk * + * * + * Creation Date : july 2020 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * Class describing the property of an Analysis object * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ +#include <iostream> +using namespace std; +#include "Analysis.h" +#include "NPAnalysisFactory.h" +#include "NPDetectorManager.h" +#include "NPFunction.h" +#include "NPOptionManager.h" +#include "NPPhysicalConstants.h" +#include "TRandom3.h" + +//////////////////////////////////////////////////////////////////////////////// +Analysis::Analysis() {} +//////////////////////////////////////////////////////////////////////////////// +Analysis::~Analysis() {} + +//////////////////////////////////////////////////////////////////////////////// +void Analysis::Init() { + RC = new TReactionConditions; + + InitOutputBranch(); + InitInputBranch(); + + SuperX3 = (TSuperX3Physics*)m_DetectorManager->GetDetector("SuperX3"); +} + +//////////////////////////////////////////////////////////////////////////////// +void Analysis::TreatEvent() { + // Reinitiate calculated variable + ReInitValue(); +} + +//////////////////////////////////////////////////////////////////////////////// +void Analysis::End() {} +//////////////////////////////////////////////////////////////////////////////// +void Analysis::InitOutputBranch() { + // RootOutput::getInstance()->GetTree()->Branch("Ex",&Ex,"Ex/D"); +} + +//////////////////////////////////////////////////////////////////////////////// +void Analysis::InitInputBranch() { RootInput::getInstance()->GetChain()->SetBranchAddress("ReactionConditions", &RC); } +//////////////////////////////////////////////////////////////////////////////// +void Analysis::ReInitValue() { + // Ex=-1000; +} + +//////////////////////////////////////////////////////////////////////////////// +// Construct Method to be pass to the AnalysisFactory // +//////////////////////////////////////////////////////////////////////////////// +NPL::VAnalysis* Analysis::Construct() { return (NPL::VAnalysis*)new Analysis(); } + +//////////////////////////////////////////////////////////////////////////////// +// Registering the construct method to the factory // +//////////////////////////////////////////////////////////////////////////////// +extern "C" { +class proxy { + public: + proxy() { NPL::AnalysisFactory::getInstance()->SetConstructor(Analysis::Construct); } +}; + +proxy p; +} + diff --git a/Projects/SuperX3/Analysis.h b/Projects/SuperX3/Analysis.h new file mode 100644 index 0000000000000000000000000000000000000000..3e244d1839603f963e418dc75f0a261d6950cfe5 --- /dev/null +++ b/Projects/SuperX3/Analysis.h @@ -0,0 +1,52 @@ +#ifndef Analysis_h +#define Analysis_h +/***************************************************************************** + * Copyright (C) 2009-2014 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: a.matta@surrey.ac.uk * + * * + * Creation Date : march 2025 * + * Last update : * + *---------------------------------------------------------------------------* + * Decription: * + * Class describing the property of an Analysis object * + * * + *---------------------------------------------------------------------------* + * Comment: * + * * + * * + *****************************************************************************/ +#include "NPEnergyLoss.h" +#include "NPVAnalysis.h" +#include "RootInput.h" +#include "RootOutput.h" +#include "TReactionConditions.h" +#include "TSuperX3Physics.h" +#include <TLorentzVector.h> +#include <TMath.h> +#include <TRandom3.h> +#include <TVector3.h> + +class Analysis : public NPL::VAnalysis { + public: + Analysis(); + ~Analysis(); + + public: + void Init(); + void TreatEvent(); + void End(); + void InitOutputBranch(); + void InitInputBranch(); + void ReInitValue(); + static NPL::VAnalysis* Construct(); + + private: + TSuperX3Physics* SuperX3; +}; +#endif diff --git a/Projects/SuperX3/CMakeLists.txt b/Projects/SuperX3/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..22c74affdfc45019bdda2594f8439c52d4ab97ec --- /dev/null +++ b/Projects/SuperX3/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required (VERSION 2.8) +# Setting the policy to match Cmake version +cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}) +# include the default NPAnalysis cmake file +include("../../NPLib/ressources/CMake/NPAnalysis.cmake") diff --git a/Projects/SuperX3/SX3_20cm.detector b/Projects/SuperX3/SX3_20cm.detector new file mode 100644 index 0000000000000000000000000000000000000000..4f2220b2614313e5572389f3ed3ddffd1aa0e953 --- /dev/null +++ b/Projects/SuperX3/SX3_20cm.detector @@ -0,0 +1,26 @@ +%%%%%%% +Target + THICKNESS= 0.1 micrometer + ANGLE= 0 deg + RADIUS= 15 mm + MATERIAL= CD2 + X= 0 mm + Y= 0 mm + Z= -20 cm + NbSlices= 10 + +%%%%%%% Alias Phi +% will create a new block for each value of Phi +Alias Phi + Action= Copy + Value= 0 15 30 45 60 75 90 105 120 135 150 165 180 195 210 225 240 255 270 285 300 315 330 345 + +%%%%%%% Detector 1 %%%%%%% +SuperX3 + THETA= 90 deg + PHI= @Phi deg + R= 198.4 mm + BETA= 0 0 0 deg + VIS= all + + diff --git a/Projects/SuperX3/SuperX3.detector b/Projects/SuperX3/SuperX3.detector new file mode 100644 index 0000000000000000000000000000000000000000..2614df266abc6d876006012e8f187168083e61f1 --- /dev/null +++ b/Projects/SuperX3/SuperX3.detector @@ -0,0 +1,20 @@ +%%%%%%% +Target + THICKNESS= 0.1 micrometer + ANGLE= 0 deg + RADIUS= 15 mm + MATERIAL= CD2 + X= 0 mm + Y= 0 mm + Z= 0 mm + NbSlices= 10 + +%%%%%%% Detector 1 %%%%%%% +SuperX3 + THETA= 0 deg + PHI= 0 deg + R= 150 mm + BETA= 0 0 0 + VIS= all + + diff --git a/Projects/SuperX3/energy_loss/.gitignore b/Projects/SuperX3/energy_loss/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/Projects/SuperX3/project.config b/Projects/SuperX3/project.config new file mode 100644 index 0000000000000000000000000000000000000000..756657e983ead01f2e9d5e3445837c9b0e696b37 --- /dev/null +++ b/Projects/SuperX3/project.config @@ -0,0 +1,5 @@ +Project SuperX3 + AnalysisOutput= ./root/analysis + SimulationOutput= ./root/simulation + EnergyLoss= ./energy_loss + diff --git a/Projects/SuperX3/root/analysis/.gitignore b/Projects/SuperX3/root/analysis/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/Projects/SuperX3/root/simulation/.gitignore b/Projects/SuperX3/root/simulation/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/Projects/e793s/Analysis.cxx b/Projects/e793s/Analysis.cxx index 63c6c17517cc0762a858765aadb41fb5b26a05a9..0f8ab929b7c59268a856a923ae3266a4e93e9592 100755 --- a/Projects/e793s/Analysis.cxx +++ b/Projects/e793s/Analysis.cxx @@ -45,21 +45,25 @@ Analysis::~Analysis(){ void Analysis::Init() { /////////////////////////////////////////////////////////////////////////////// -// isPhaseSpace=true; - isPhaseSpace=true; - -// if(NPOptionManager::getInstance()->HasDefinition("simulation")){ + if(NPOptionManager::getInstance()->HasDefinition("Sim")){ cout << " == == == == SIMULATION == == == ==" << endl; -// isSim=true; -// } else { + isSim=true; + isPhaseSpace=false; + } else if (NPOptionManager::getInstance()->HasDefinition("Exp")) { cout << " == == == == EXPERIMENT == == == ==" << endl; - isSim=false; -// } + isSim=false; + isPhaseSpace=false; + } else { + cout << " == == == == PHASE SPACE == == == ==" << endl; + isSim=false; + isPhaseSpace=true; + } agata_zShift=51*mm; //BrhoRef=0.65; if(isSim && !isPhaseSpace){ +//cout << "here_InIsSimLoop" << endl; Initial = new TInitialConditions(); ReactionConditions = new TReactionConditions(); RootInput::getInstance()->GetChain()->SetBranchAddress("InitialConditions",&Initial); @@ -99,15 +103,11 @@ void Analysis::Init() { // get reaction information reaction.ReadConfigurationFile(NPOptionManager::getInstance()->GetReactionFile()); - //reaction = new NPL::Reaction("47K(d,p)48K@355"); OriginalBeamEnergy = reaction.GetBeamEnergy(); - //OriginalBeamEnergy = reaction->GetBeamEnergy(); reaction.Print(); //TESTING PARSER - //reaction->Print(); //TESTING PARSER // get beam position from .reaction file Beam = (NPL::Beam*) reaction.GetParticle1(); - //Beam = (NPL::Beam*) reaction->GetParticle1(); XBeam = Beam->GetMeanX(); YBeam = Beam->GetMeanY(); @@ -125,9 +125,7 @@ void Analysis::Init() { // energy losses string light = NPL::ChangeNameToG4Standard(reaction.GetParticle3()->GetName()); - //string light = NPL::ChangeNameToG4Standard(reaction->GetParticle3()->GetName()); string beam = NPL::ChangeNameToG4Standard(reaction.GetParticle1()->GetName()); - //string beam = NPL::ChangeNameToG4Standard(reaction->GetParticle1()->GetName()); LightTarget = NPL::EnergyLoss(light+"_"+TargetMaterial+".G4table","G4Table",100 ); LightAl = NPL::EnergyLoss(light+"_Al.G4table" ,"G4Table",100); LightSi = NPL::EnergyLoss(light+"_Si.G4table" ,"G4Table",100); @@ -135,7 +133,6 @@ void Analysis::Init() { FinalBeamEnergy = BeamTargetELoss.Slow(OriginalBeamEnergy, 0.5*TargetThickness, 0); reaction.SetBeamEnergy(FinalBeamEnergy); - //reaction->SetBeamEnergy(FinalBeamEnergy); cout << "Beam energy at mid-target: " << FinalBeamEnergy << endl; @@ -164,14 +161,10 @@ void Analysis::Init() { //nbHits=0; //count=0; AHeavy=reaction.GetParticle4()->GetA(); - //AHeavy=reaction->GetParticle4()->GetA(); ALight=reaction.GetParticle3()->GetA(); - //ALight=reaction->GetParticle3()->GetA(); MHeavy=reaction.GetParticle4()->Mass(); - //MHeavy=reaction->GetParticle4()->Mass(); MLight=reaction.GetParticle3()->Mass(); - //MLight=reaction->GetParticle3()->Mass(); - bool writetoscreen=true; + //bool writetoscreen=true; for(int i=0;i<GATCONF_SIZE;i++){ // loop over the bits GATCONF_Counter[i] = 0 ; @@ -179,14 +172,14 @@ void Analysis::Init() { // ThetaCM_detected->Sumw2(); // ThetaLab_detected->Sumw2(); +//cout << "here_endInit" << endl; } //////////////////////////////////////////////////////////////////////////////// void Analysis::TreatEvent(){ - // Reinitiate calculated variable +//cout << "here_TreatEvent" << endl; ReInitValue(); - if(isSim && !isPhaseSpace){ ThetaCM_emmitted->Fill(ReactionConditions->GetThetaCM()); ThetaLab_emmitted->Fill(ReactionConditions->GetTheta(0)); @@ -209,18 +202,15 @@ void Analysis::TreatEvent(){ TVector3 BeamDirection(0.,0.,1.); BeamImpact = TVector3(XBeam,YBeam,m_DetectorManager->GetTargetZ()); - ParticleMult=M2->Si_E.size();////+MG->DSSD_E.size(); - - //ParticleMult=M2->Si_E.size(); - // FinalBeamEnergy=BeamCD2.Slow(OriginalBeamEnergy,0.5*TargetThickness,BeamDirection.Angle(TVector(0,0,1))); - //reaction.SetBeamEnergy(FinalBeamEnergy); - - + //ParticleMult=M2->Si_E.size();////+MG->DSSD_E.size(); + ParticleMult=M2->Si_E.size()+MG->DSSD_E.size(); +//cout << "here_BeforeMustLoop" << endl; //////////////////////////////////////////////////////////////////////////// //////////////////////////////// LOOP on MUST2 //////////////////////////// //////////////////////////////////////////////////////////////////////////// unsigned int sizeM2 = M2->Si_E.size(); for(unsigned int countMust2 = 0; countMust2 < sizeM2; countMust2++){ +//cout << "here_InMustLoop" << endl; /************************************************/ // Part 0 : Get the useful Data @@ -264,9 +254,9 @@ void Analysis::TreatEvent(){ if(CsI_E_M2>0 ){ // The energy in CsI is calculate form dE/dx Table because Energy = CsI_E_M2; - if(!isSim){ - Energy = LightAl.EvaluateInitialEnergy(Energy, 0.4*micrometer, ThetaM2Surface); - } + //if(!isSim){ + Energy = LightAl.EvaluateInitialEnergy(Energy, 0.4*micrometer, ThetaM2Surface); + //} Energy+=Si_E_M2; } else @@ -274,19 +264,12 @@ void Analysis::TreatEvent(){ RawEnergy.push_back(Energy); - /* - cout << M2->TelescopeNumber[0] << " " - << M2->GetTelescopeNormal(countMust2).X() << " " - << M2->GetTelescopeNormal(countMust2).Y() << " " - << M2->GetTelescopeNormal(countMust2).Z() << endl; - */ - - if(!isSim){ +// if(!isSim){ // Evaluate energy using the thickness elab_tmp = LightAl.EvaluateInitialEnergy(Energy, 0.4*micrometer, ThetaM2Surface); // Target Correction elab_tmp = LightTarget.EvaluateInitialEnergy(elab_tmp, 0.5*TargetThickness, ThetaNormalTarget); - } else {elab_tmp = Energy;} +// } else {elab_tmp = Energy;} ELab.push_back(elab_tmp); @@ -295,7 +278,6 @@ void Analysis::TreatEvent(){ /************************************************/ // Part 3 : Excitation Energy Calculation Ex.push_back(reaction.ReconstructRelativistic(elab_tmp,thetalab_tmp)); - //Ex.push_back(reaction->ReconstructRelativistic(elab_tmp,thetalab_tmp)); Ecm.push_back(Energy*(AHeavy+ALight)/(4*AHeavy*cos(thetalab_tmp)*cos(thetalab_tmp))); /************************************************/ @@ -303,14 +285,14 @@ void Analysis::TreatEvent(){ // Part 4 : Theta CM Calculation ThetaCM.push_back(reaction.EnergyLabToThetaCM(elab_tmp, thetalab_tmp)/deg); - //ThetaCM.push_back(reaction->EnergyLabToThetaCM(elab_tmp, thetalab_tmp)/deg); /************************************************/ ThetaLab.push_back(thetalab_tmp/deg); PhiLab.push_back(philab_tmp/deg); +//cout << "here_EndMustLoop" << endl; } - +//cout << "here_BeforeMugastLoop" << endl; //////////////////////////////////////////////////////////////////////////// //////////////////////////////// LOOP on MUGAST //////////////////////////// //////////////////////////////////////////////////////////////////////////// @@ -354,11 +336,6 @@ void Analysis::TreatEvent(){ ThetaMGSurface = HitDirection.Angle( MG -> GetTelescopeNormal(countMugast) ); ThetaNormalTarget = HitDirection.Angle( TVector3(0.0,0.0,1.0) ) ; -//cout << MG->TelescopeNumber[0] << "\t" -// << "\t" << MG->GetTelescopeNormal(countMugast).X() -// << "\t" << MG->GetTelescopeNormal(countMugast).Y() -// << "\t" << MG->GetTelescopeNormal(countMugast).Z() << endl; - // Part 2 : Impact Energy Energy = elab_tmp = 0; Energy = MG->GetEnergyDeposit(countMugast); @@ -373,22 +350,34 @@ void Analysis::TreatEvent(){ elab_tmp, //particle energy after leaving target TargetThickness*0.5, //distance passed through target ThetaNormalTarget); //angle of exit from target - } else {elab_tmp = Energy;} + } else { //TESTING DIFFERENT ENERGY LOSSES IN SIMULATION + elab_tmp = Energy; //so I can add and remove sections + //elab_tmp = LightSi.EvaluateInitialEnergy( + // elab_tmp, //particle energy after Si + // 0.5*500.*micrometer, //thickness of Si + // ThetaMGSurface); //angle of impingement + //elab_tmp = LightAl.EvaluateInitialEnergy( + // elab_tmp, //particle energy after Al + // 0.4*micrometer, //thickness of Al + // ThetaMGSurface); //angle of impingement + elab_tmp = LightTarget.EvaluateInitialEnergy( + elab_tmp, //particle energy after leaving target + TargetThickness*0.5, //distance passed through target + ThetaNormalTarget); //angle of exit from target + } ELab.push_back(elab_tmp); // Part 3 : Excitation Energy Calculation - if(!isSim){ + //if(!isSim){ //TESTING!!!! Ex.push_back(reaction.ReconstructRelativistic(elab_tmp,thetalab_tmp)); - //Ex.push_back(reaction->ReconstructRelativistic(elab_tmp,thetalab_tmp)); Ecm.push_back(elab_tmp*(AHeavy+ALight)/(4*AHeavy*cos(thetalab_tmp)*cos(thetalab_tmp))); - } + //} // Part 4 : Theta CM Calculation ThetaLab.push_back(thetalab_tmp/deg); PhiLab.push_back(philab_tmp/deg); ThetaCM.push_back(reaction.EnergyLabToThetaCM(elab_tmp, thetalab_tmp)/deg); - //ThetaCM.push_back(reaction->EnergyLabToThetaCM(elab_tmp, thetalab_tmp)/deg); if(sizeMG==1){ MG_T = MG->DSSD_T[0]; @@ -688,14 +677,18 @@ void Analysis::End(){ for(int i=0; i<5; i++){HistList->Add(SolidAngle_CM_MMX[i]);} for(int i=0; i<5; i++){HistList->Add(SolidAngle_Lab_MMX[i]);} - auto HistoFile = new TFile("SolidAngle_HistFile_15Feb.root","RECREATE"); + auto HistoFile = new TFile("~/Programs/nptool/Projects/e793s/SolidAngle_HistFile_New.root","RECREATE"); HistList->Write(); HistoFile->Close(); + + + cout << "!!! MAKE SURE YOU RENAME THE SOLID ANGLE FILE! !!!" << endl; } } //////////////////////////////////////////////////////////////////////////////// void Analysis::InitOutputBranch(){ +//cout << "here_InitOutput" << endl; //RootOutput::getInstance()->GetTree()->Branch("Ex",&Ex,"Ex/D"); RootOutput::getInstance()->GetTree()->Branch("Ex",&Ex); //RootOutput::getInstance()->GetTree()->Branch("EDC",&EDC,"EDC/D"); @@ -721,11 +714,11 @@ void Analysis::InitOutputBranch(){ RootOutput::getInstance()->GetTree()->Branch("Y",&Y); RootOutput::getInstance()->GetTree()->Branch("Z",&Z); RootOutput::getInstance()->GetTree()->Branch("dE",&dE,"dE/D"); -//// RootOutput::getInstance()->GetTree()->Branch("MG_T",MG_T); -//// RootOutput::getInstance()->GetTree()->Branch("MG_E",MG_E); -//// RootOutput::getInstance()->GetTree()->Branch("MG_X",MG_X); -//// RootOutput::getInstance()->GetTree()->Branch("MG_Y",MG_Y); -//// RootOutput::getInstance()->GetTree()->Branch("MG_D",MG_D); + RootOutput::getInstance()->GetTree()->Branch("MG_T",MG_T); + RootOutput::getInstance()->GetTree()->Branch("MG_E",MG_E); + RootOutput::getInstance()->GetTree()->Branch("MG_X",MG_X); + RootOutput::getInstance()->GetTree()->Branch("MG_Y",MG_Y); + RootOutput::getInstance()->GetTree()->Branch("MG_D",MG_D); // Vamos RootOutput::getInstance()->GetTree()->Branch("LTS",<S,"LTS/l"); @@ -822,6 +815,8 @@ void Analysis::InitOutputBranch(){ //////////////////////////////////////////////////////////////////////////////// void Analysis::InitInputBranch(){ + +//cout << "here_InitInput" << endl; SetBranchStatus(); // RootInput:: getInstance()->GetChain()->SetBranchAddress("GATCONF",&vGATCONF); // @@ -892,6 +887,7 @@ void Analysis::InitInputBranch(){ //////////////////////////////////////////////////////////////////////////////// void Analysis::SetBranchStatus(){ +//cout << "here_SetBranchStatus" << endl; // Set Branch status RootInput::getInstance()->GetChain()->SetBranchStatus("LTS",true); /* RootInput::getInstance()->GetChain()->SetBranchStatus("T_FPMW_CATS1",true); @@ -955,6 +951,7 @@ void Analysis::SetBranchStatus(){ //////////////////////////////////////////////////////////////////////////////// void Analysis::ReInitValue(){ +//cout << "here_ReInit" << endl; Ex.clear(); Ecm.clear(); AddBack_EDC.clear(); diff --git a/Projects/e793s/Reaction/47Kdd_Sim.reaction b/Projects/e793s/Reaction/47Kdd_Sim.reaction new file mode 100755 index 0000000000000000000000000000000000000000..abe498fe3ce9a992b1d93fce34c6be819366e848 --- /dev/null +++ b/Projects/e793s/Reaction/47Kdd_Sim.reaction @@ -0,0 +1,34 @@ +%%%%%%%%%%%%%%%%%%%%%% E793S %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +Beam + Particle= 47K + ExcitationEnergy= 0 MeV + %%-- 7.54789 MeV/u after CATS --%% + Energy= 354.75 MeV + SigmaEnergy= 0. MeV + SigmaThetaX= 0.0 deg + SigmaPhiY= 0.0 deg + SigmaX= 2.0 millimeter + SigmaY= 2.0 millimeter + MeanThetaX= 0 deg + MeanPhiY= 0 deg + MeanX= -3.9164 millimeter + MeanY= +0.0550 millimeter + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +TwoBodyReaction + Beam= 47K + Target= 2H + Light= 2H + Heavy= 47K + + ExcitationEnergyLight= 0.0 MeV + ExcitationEnergyHeavy= 0.0 MeV + + LabCrossSectionPath= flat.txt CSR + + HalfOpenAngleMin = 0 deg + HalfOpenAngleMax = 180 deg + + ShootLight= 1 + ShootHeavy= 0 diff --git a/Projects/e793s/Reaction/47Kdp_07Sep.reaction b/Projects/e793s/Reaction/47Kdp_07Sep.reaction new file mode 100755 index 0000000000000000000000000000000000000000..cac09fdce81a2b21b243f70144e02706f3ff096e --- /dev/null +++ b/Projects/e793s/Reaction/47Kdp_07Sep.reaction @@ -0,0 +1,28 @@ +%%%%%%%%%%%%%%%%%%%%%% E793S %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +Beam + Particle= 47K + ExcitationEnergy= 0 MeV + %%-- 7.54789 MeV/u after CATS --%% + Energy= 354.75 MeV + SigmaEnergy= 0. MeV + SigmaThetaX= 0.0 deg + SigmaPhiY= 0.0 deg + SigmaX= 2.0 millimeter + SigmaY= 2.0 millimeter + MeanThetaX= 0 deg + MeanPhiY= 0 deg + MeanX= -3.9164 millimeter + MeanY= +0.0550 millimeter + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +TwoBodyReaction + Beam= 47K + Target= 2H + Light= 1H + Heavy= 48K + ExcitationEnergyLight= 0.0 MeV + ExcitationEnergyHeavy= 0.0 MeV + CrossSectionPath= flat.txt CSR + ShootLight= 1 + ShootHeavy= 0 diff --git a/Projects/e793s/Reaction/47Kdp_08Nov.reaction b/Projects/e793s/Reaction/47Kdp_08Nov.reaction new file mode 100755 index 0000000000000000000000000000000000000000..cac09fdce81a2b21b243f70144e02706f3ff096e --- /dev/null +++ b/Projects/e793s/Reaction/47Kdp_08Nov.reaction @@ -0,0 +1,28 @@ +%%%%%%%%%%%%%%%%%%%%%% E793S %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +Beam + Particle= 47K + ExcitationEnergy= 0 MeV + %%-- 7.54789 MeV/u after CATS --%% + Energy= 354.75 MeV + SigmaEnergy= 0. MeV + SigmaThetaX= 0.0 deg + SigmaPhiY= 0.0 deg + SigmaX= 2.0 millimeter + SigmaY= 2.0 millimeter + MeanThetaX= 0 deg + MeanPhiY= 0 deg + MeanX= -3.9164 millimeter + MeanY= +0.0550 millimeter + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +TwoBodyReaction + Beam= 47K + Target= 2H + Light= 1H + Heavy= 48K + ExcitationEnergyLight= 0.0 MeV + ExcitationEnergyHeavy= 0.0 MeV + CrossSectionPath= flat.txt CSR + ShootLight= 1 + ShootHeavy= 0 diff --git a/Projects/e793s/Reaction/47Kdp_13Oct_wildTry.reaction b/Projects/e793s/Reaction/47Kdp_13Oct_wildTry.reaction new file mode 100755 index 0000000000000000000000000000000000000000..68d261f5e3b51016010699067a0c77f8e170cf73 --- /dev/null +++ b/Projects/e793s/Reaction/47Kdp_13Oct_wildTry.reaction @@ -0,0 +1,30 @@ +%%%%%%%%%%%%%%%%%%%%%% E793S %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +Beam + Particle= 47K + ExcitationEnergy= 0 MeV + %%-- 7.54789 MeV/u after CATS --%% + Energy= 354.75 MeV + SigmaEnergy= 0. MeV + SigmaThetaX= 0.0 deg + SigmaPhiY= 0.0 deg + SigmaX= 2.0 millimeter + SigmaY= 2.0 millimeter + MeanThetaX= 0 deg + MeanPhiY= 0 deg + %MeanX= -5.0026 millimeter + %MeanY= +1.1414 millimeter + MeanX= -5.4468 millimeter + MeanY= -0.8500 millimeter + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +TwoBodyReaction + Beam= 47K + Target= 2H + Light= 1H + Heavy= 48K + ExcitationEnergyLight= 0.0 MeV + ExcitationEnergyHeavy= 0.0 MeV + CrossSectionPath= flat.txt CSR + ShootLight= 1 + ShootHeavy= 0 diff --git a/Projects/e793s/Reaction/47Kdp_PhaseSpace.reaction b/Projects/e793s/Reaction/47Kdp_PhaseSpace.reaction index 118fe932c5c68ec081c252dc1e7c758ae9c39648..503fc60bece4420f9c710a160cb2093039939fe8 100755 --- a/Projects/e793s/Reaction/47Kdp_PhaseSpace.reaction +++ b/Projects/e793s/Reaction/47Kdp_PhaseSpace.reaction @@ -3,16 +3,16 @@ Beam Particle= 47K ExcitationEnergy= 0 MeV - Energy= 362 MeV + Energy= 354.75 MeV SigmaEnergy= 0. MeV SigmaThetaX= 0.0 deg SigmaPhiY= 0.0 deg - SigmaX= 2 mm - SigmaY= 2 mm + SigmaX= 2.0 mm + SigmaY= 2.0 mm MeanThetaX= 0 deg MeanPhiY= 0 deg - MeanX= 0 mm - MeanY= 0 mm + MeanX= -3.9164 millimeter + MeanY= +0.0550 millimeter %EnergyProfilePath= %XThetaXProfilePath= %YPhiYProfilePath= diff --git a/Projects/e793s/Reaction/47Kdp_PhaseSpace360keV.reaction b/Projects/e793s/Reaction/47Kdp_PhaseSpace360keV.reaction new file mode 100644 index 0000000000000000000000000000000000000000..b9a5ca5387934fd5d94a9fc07d8583385e9b62ee --- /dev/null +++ b/Projects/e793s/Reaction/47Kdp_PhaseSpace360keV.reaction @@ -0,0 +1,26 @@ +%%%%%%%%%%%%%%%%%%%%%% E793S %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +Beam + Particle= 47K + ExcitationEnergy= 0 MeV + Energy= 354.75 MeV + SigmaEnergy= 0. MeV + SigmaThetaX= 0.0 deg + SigmaPhiY= 0.0 deg + SigmaX= 2.0 mm + SigmaY= 2.0 mm + MeanThetaX= 0 deg + MeanPhiY= 0 deg + MeanX= -3.9164 millimeter + MeanY= +0.0550 millimeter + %EnergyProfilePath= + %XThetaXProfilePath= + %YPhiYProfilePath= + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +PhaseSpace + Beam= 47K + Target= 2H + Daughters= 1H 47K n + ExcitationEnergies= 0 0.360 0 MeV + Fermi= 1 diff --git a/Projects/e793s/Reaction/47Kdp_PhaseSpacePlusReaction.reaction b/Projects/e793s/Reaction/47Kdp_PhaseSpacePlusReaction.reaction new file mode 100755 index 0000000000000000000000000000000000000000..35e96e14c99736598f771239c6ea330f6cfff546 --- /dev/null +++ b/Projects/e793s/Reaction/47Kdp_PhaseSpacePlusReaction.reaction @@ -0,0 +1,38 @@ +%%%%%%%%%%%%%%%%%%%%%% E793S %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +Beam + Particle= 47K + ExcitationEnergy= 0 MeV + Energy= 354.75 MeV + SigmaEnergy= 0. MeV + SigmaThetaX= 0.0 deg + SigmaPhiY= 0.0 deg + SigmaX= 2.0 mm + SigmaY= 2.0 mm + MeanThetaX= 0 deg + MeanPhiY= 0 deg + MeanX= -3.9164 millimeter + MeanY= +0.0550 millimeter + %EnergyProfilePath= + %XThetaXProfilePath= + %YPhiYProfilePath= + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +TwoBodyReaction + Beam= 47K + Target= 2H + Light= 1H + Heavy= 48K + ExcitationEnergyLight= 0.0 MeV + ExcitationEnergyHeavy= 0.0 MeV + CrossSectionPath= flat.txt CSR + ShootLight= 1 + ShootHeavy= 0 + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +PhaseSpace + Beam= 47K + Target= 2H + Daughters= 1H 47K n + ExcitationEnergies= 0 0 0 MeV + Fermi= 1 diff --git a/Projects/e793s/Reaction/47Kdp_Sim.reaction b/Projects/e793s/Reaction/47Kdp_Sim.reaction index f3f1ac774900ccec92351d6ebea8bcbb9018befd..66ddc05585be46be5d0b222c6cd34968a2169289 100755 --- a/Projects/e793s/Reaction/47Kdp_Sim.reaction +++ b/Projects/e793s/Reaction/47Kdp_Sim.reaction @@ -3,28 +3,32 @@ Beam Particle= 47K ExcitationEnergy= 0 MeV - Energy= 362 MeV + %%-- 7.54789 MeV/u after CATS --%% + Energy= 354.75 MeV SigmaEnergy= 0. MeV SigmaThetaX= 0.0 deg SigmaPhiY= 0.0 deg - SigmaX= 2 mm - SigmaY= 2 mm + SigmaX= 2.0 millimeter + SigmaY= 2.0 millimeter MeanThetaX= 0 deg MeanPhiY= 0 deg - MeanX= 0 mm - MeanY= 0 mm - %EnergyProfilePath= - %XThetaXProfilePath= - %YPhiYProfilePath= + MeanX= -3.9164 millimeter + MeanY= +0.0550 millimeter %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% TwoBodyReaction - Beam= 47K - Target= 2H - Light= 1H - Heavy= 48K + Beam=47K + Target=2H + Light=1H + Heavy=48K + ExcitationEnergyLight= 0.0 MeV ExcitationEnergyHeavy= 0.0 MeV - CrossSectionPath= flat.txt CSR + + LabCrossSectionPath= flat.txt CSR + + HalfOpenAngleMin = 0 deg + HalfOpenAngleMax = 180 deg + ShootLight= 1 ShootHeavy= 0 diff --git a/Projects/e793s/Reaction/47Kdp_Sim_0000MeV.reaction b/Projects/e793s/Reaction/47Kdp_Sim_0000MeV.reaction new file mode 100644 index 0000000000000000000000000000000000000000..dbcd778f5e38067cabac50db58720d469f946f50 --- /dev/null +++ b/Projects/e793s/Reaction/47Kdp_Sim_0000MeV.reaction @@ -0,0 +1,34 @@ +%%%%%%%%%%%%%%%%%%%%%% E793S %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +Beam + Particle= 47K + ExcitationEnergy= 0 MeV + %%-- 7.54789 MeV/u after CATS --%% + Energy= 354.75 MeV + SigmaEnergy= 0. MeV + SigmaThetaX= 0.0 deg + SigmaPhiY= 0.0 deg + SigmaX= 2.0 millimeter + SigmaY= 2.0 millimeter + MeanThetaX= 0 deg + MeanPhiY= 0 deg + MeanX= -3.9164 millimeter + MeanY= +0.0550 millimeter + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +TwoBodyReaction + Beam=47K + Target=2H + Light=1H + Heavy=48K + + ExcitationEnergyLight= 0.0 MeV + ExcitationEnergyHeavy= 0.0 MeV + + LabCrossSectionPath= flat.txt CSR + + HalfOpenAngleMin = 0 deg + HalfOpenAngleMax = 180 deg + + ShootLight= 1 + ShootHeavy= 1 diff --git a/Projects/e793s/Reaction/47Kdp_Sim_0143MeV.reaction b/Projects/e793s/Reaction/47Kdp_Sim_0143MeV.reaction new file mode 100644 index 0000000000000000000000000000000000000000..756eb1a7dc2bca4a466d43eb693332705e25e2f8 --- /dev/null +++ b/Projects/e793s/Reaction/47Kdp_Sim_0143MeV.reaction @@ -0,0 +1,34 @@ +%%%%%%%%%%%%%%%%%%%%%% E793S %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +Beam + Particle= 47K + ExcitationEnergy= 0 MeV + %%-- 7.54789 MeV/u after CATS --%% + Energy= 354.75 MeV + SigmaEnergy= 0. MeV + SigmaThetaX= 0.0 deg + SigmaPhiY= 0.0 deg + SigmaX= 2.0 millimeter + SigmaY= 2.0 millimeter + MeanThetaX= 0 deg + MeanPhiY= 0 deg + MeanX= -3.9164 millimeter + MeanY= +0.0550 millimeter + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +TwoBodyReaction + Beam=47K + Target=2H + Light=1H + Heavy=48K + + ExcitationEnergyLight= 0.0 MeV + ExcitationEnergyHeavy= 0.143 MeV + + LabCrossSectionPath= 47Kdp48K_0143_p32_Full.txt CSR + + %HalfOpenAngleMin = 0 deg + %HalfOpenAngleMax = 180 deg + + ShootLight= 1 + ShootHeavy= 0 diff --git a/Projects/e793s/Reaction/47Kdp_Sim_0968MeV.reaction b/Projects/e793s/Reaction/47Kdp_Sim_0968MeV.reaction new file mode 100644 index 0000000000000000000000000000000000000000..06d2bafbbd9424059fc52c5d5ca3a62ee5357e1a --- /dev/null +++ b/Projects/e793s/Reaction/47Kdp_Sim_0968MeV.reaction @@ -0,0 +1,34 @@ +%%%%%%%%%%%%%%%%%%%%%% E793S %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +Beam + Particle= 47K + ExcitationEnergy= 0 MeV + %%-- 7.54789 MeV/u after CATS --%% + Energy= 354.75 MeV + SigmaEnergy= 0. MeV + SigmaThetaX= 0.0 deg + SigmaPhiY= 0.0 deg + SigmaX= 2.0 millimeter + SigmaY= 2.0 millimeter + MeanThetaX= 0 deg + MeanPhiY= 0 deg + MeanX= -3.9164 millimeter + MeanY= +0.0550 millimeter + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +TwoBodyReaction + Beam=47K + Target=2H + Light=1H + Heavy=48K + + ExcitationEnergyLight= 0.0 MeV + ExcitationEnergyHeavy= 0.968 MeV + + LabCrossSectionPath= 47Kdp48K_0968_p12_Full.txt CSR + + HalfOpenAngleMin = 0 deg + HalfOpenAngleMax = 180 deg + + ShootLight= 1 + ShootHeavy= 0 diff --git a/Projects/e793s/Reaction/47Kdp_Sim_3605MeV.reaction b/Projects/e793s/Reaction/47Kdp_Sim_3605MeV.reaction new file mode 100644 index 0000000000000000000000000000000000000000..7f55a187a3b408616e613e758348467a347309a6 --- /dev/null +++ b/Projects/e793s/Reaction/47Kdp_Sim_3605MeV.reaction @@ -0,0 +1,34 @@ +%%%%%%%%%%%%%%%%%%%%%% E793S %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +Beam + Particle= 47K + ExcitationEnergy= 0 MeV + %%-- 7.54789 MeV/u after CATS --%% + Energy= 354.75 MeV + SigmaEnergy= 0. MeV + SigmaThetaX= 0.0 deg + SigmaPhiY= 0.0 deg + SigmaX= 2.0 millimeter + SigmaY= 2.0 millimeter + MeanThetaX= 0 deg + MeanPhiY= 0 deg + MeanX= -3.9164 millimeter + MeanY= +0.0550 millimeter + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +TwoBodyReaction + Beam=47K + Target=2H + Light=1H + Heavy=48K + + ExcitationEnergyLight= 0.0 MeV + ExcitationEnergyHeavy= 3.605 MeV + + LabCrossSectionPath= 47Kdp48K_3605_f52_Full.txt CSR + + HalfOpenAngleMin = 0 deg + HalfOpenAngleMax = 180 deg + + ShootLight= 1 + ShootHeavy= 0 diff --git a/Projects/e793s/Reaction/47Kdp_Sim_3605MeV_Flat.reaction b/Projects/e793s/Reaction/47Kdp_Sim_3605MeV_Flat.reaction new file mode 100644 index 0000000000000000000000000000000000000000..d68962aa3d377e2ed868fe0f912742115d2bf8ee --- /dev/null +++ b/Projects/e793s/Reaction/47Kdp_Sim_3605MeV_Flat.reaction @@ -0,0 +1,34 @@ +%%%%%%%%%%%%%%%%%%%%%% E793S %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +Beam + Particle= 47K + ExcitationEnergy= 0 MeV + %%-- 7.54789 MeV/u after CATS --%% + Energy= 354.75 MeV + SigmaEnergy= 0. MeV + SigmaThetaX= 0.0 deg + SigmaPhiY= 0.0 deg + SigmaX= 2.0 millimeter + SigmaY= 2.0 millimeter + MeanThetaX= 0 deg + MeanPhiY= 0 deg + MeanX= -3.9164 millimeter + MeanY= +0.0550 millimeter + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +TwoBodyReaction + Beam=47K + Target=2H + Light=1H + Heavy=48K + + ExcitationEnergyLight= 0.0 MeV + ExcitationEnergyHeavy= 3.605 MeV + + LabCrossSectionPath= flat.txt CSR + + HalfOpenAngleMin = 0 deg + HalfOpenAngleMax = 180 deg + + ShootLight= 1 + ShootHeavy= 0 diff --git a/Projects/e793s/Reaction/47Kdp_Sim_4055MeV.reaction b/Projects/e793s/Reaction/47Kdp_Sim_4055MeV.reaction new file mode 100644 index 0000000000000000000000000000000000000000..e8bf3d65fed8078609bf58a69fc00e6af58e06a8 --- /dev/null +++ b/Projects/e793s/Reaction/47Kdp_Sim_4055MeV.reaction @@ -0,0 +1,34 @@ +%%%%%%%%%%%%%%%%%%%%%% E793S %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +Beam + Particle= 47K + ExcitationEnergy= 0 MeV + %%-- 7.54789 MeV/u after CATS --%% + Energy= 354.75 MeV + SigmaEnergy= 0. MeV + SigmaThetaX= 0.0 deg + SigmaPhiY= 0.0 deg + SigmaX= 2.0 millimeter + SigmaY= 2.0 millimeter + MeanThetaX= 0 deg + MeanPhiY= 0 deg + MeanX= -3.9164 millimeter + MeanY= +0.0550 millimeter + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +TwoBodyReaction + Beam=47K + Target=2H + Light=1H + Heavy=48K + + ExcitationEnergyLight= 0.0 MeV + ExcitationEnergyHeavy= 4.055 MeV + + LabCrossSectionPath= 47Kdp48K_3605_f52_Full.txt CSR + + HalfOpenAngleMin = 0 deg + HalfOpenAngleMax = 180 deg + + ShootLight= 1 + ShootHeavy= 0 diff --git a/Projects/e793s/Reaction/47Kdp_Sim_Flat2000MeV.reaction b/Projects/e793s/Reaction/47Kdp_Sim_Flat2000MeV.reaction new file mode 100644 index 0000000000000000000000000000000000000000..33d160c8e6e7e8547ed0062fd0bd31f1be09a2ae --- /dev/null +++ b/Projects/e793s/Reaction/47Kdp_Sim_Flat2000MeV.reaction @@ -0,0 +1,34 @@ +%%%%%%%%%%%%%%%%%%%%%% E793S %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +Beam + Particle= 47K + ExcitationEnergy= 0 MeV + %%-- 7.54789 MeV/u after CATS --%% + Energy= 354.75 MeV + SigmaEnergy= 0. MeV + SigmaThetaX= 0.0 deg + SigmaPhiY= 0.0 deg + SigmaX= 2.0 millimeter + SigmaY= 2.0 millimeter + MeanThetaX= 0 deg + MeanPhiY= 0 deg + MeanX= -3.9164 millimeter + MeanY= +0.0550 millimeter + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +TwoBodyReaction + Beam=47K + Target=2H + Light=1H + Heavy=48K + + ExcitationEnergyLight= 0.0 MeV + ExcitationEnergyHeavy= 2.000 MeV + + LabCrossSectionPath= flat.txt CSR + + HalfOpenAngleMin = 0 deg + HalfOpenAngleMax = 180 deg + + ShootLight= 1 + ShootHeavy= 0 diff --git a/Projects/e793s/Reaction/47Kdp_Sim_Flat2500MeV.reaction b/Projects/e793s/Reaction/47Kdp_Sim_Flat2500MeV.reaction new file mode 100644 index 0000000000000000000000000000000000000000..bcbb3fb69b9381693838a3c8941fdc324b93b43c --- /dev/null +++ b/Projects/e793s/Reaction/47Kdp_Sim_Flat2500MeV.reaction @@ -0,0 +1,34 @@ +%%%%%%%%%%%%%%%%%%%%%% E793S %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +Beam + Particle= 47K + ExcitationEnergy= 0 MeV + %%-- 7.54789 MeV/u after CATS --%% + Energy= 354.75 MeV + SigmaEnergy= 0. MeV + SigmaThetaX= 0.0 deg + SigmaPhiY= 0.0 deg + SigmaX= 2.0 millimeter + SigmaY= 2.0 millimeter + MeanThetaX= 0 deg + MeanPhiY= 0 deg + MeanX= -3.9164 millimeter + MeanY= +0.0550 millimeter + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +TwoBodyReaction + Beam=47K + Target=2H + Light=1H + Heavy=48K + + ExcitationEnergyLight= 0.0 MeV + ExcitationEnergyHeavy= 2.500 MeV + + LabCrossSectionPath= flat.txt CSR + + HalfOpenAngleMin = 0 deg + HalfOpenAngleMax = 180 deg + + ShootLight= 1 + ShootHeavy= 0 diff --git a/Projects/e793s/Reaction/47Kdp_Sim_Flat3000MeV.reaction b/Projects/e793s/Reaction/47Kdp_Sim_Flat3000MeV.reaction new file mode 100644 index 0000000000000000000000000000000000000000..b237c673ac85902243dd01caacad7a57c6531e27 --- /dev/null +++ b/Projects/e793s/Reaction/47Kdp_Sim_Flat3000MeV.reaction @@ -0,0 +1,34 @@ +%%%%%%%%%%%%%%%%%%%%%% E793S %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +Beam + Particle= 47K + ExcitationEnergy= 0 MeV + %%-- 7.54789 MeV/u after CATS --%% + Energy= 354.75 MeV + SigmaEnergy= 0. MeV + SigmaThetaX= 0.0 deg + SigmaPhiY= 0.0 deg + SigmaX= 2.0 millimeter + SigmaY= 2.0 millimeter + MeanThetaX= 0 deg + MeanPhiY= 0 deg + MeanX= -3.9164 millimeter + MeanY= +0.0550 millimeter + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +TwoBodyReaction + Beam=47K + Target=2H + Light=1H + Heavy=48K + + ExcitationEnergyLight= 0.0 MeV + ExcitationEnergyHeavy= 3.000 MeV + + LabCrossSectionPath= flat.txt CSR + + HalfOpenAngleMin = 0 deg + HalfOpenAngleMax = 180 deg + + ShootLight= 1 + ShootHeavy= 0 diff --git a/Projects/e793s/Reaction/47Kdp_Sim_Flat3400MeV.reaction b/Projects/e793s/Reaction/47Kdp_Sim_Flat3400MeV.reaction new file mode 100644 index 0000000000000000000000000000000000000000..b45ae0ccff4b4d674fadf56e30edc10994785343 --- /dev/null +++ b/Projects/e793s/Reaction/47Kdp_Sim_Flat3400MeV.reaction @@ -0,0 +1,34 @@ +%%%%%%%%%%%%%%%%%%%%%% E793S %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +Beam + Particle= 47K + ExcitationEnergy= 0 MeV + %%-- 7.54789 MeV/u after CATS --%% + Energy= 354.75 MeV + SigmaEnergy= 0. MeV + SigmaThetaX= 0.0 deg + SigmaPhiY= 0.0 deg + SigmaX= 2.0 millimeter + SigmaY= 2.0 millimeter + MeanThetaX= 0 deg + MeanPhiY= 0 deg + MeanX= -3.9164 millimeter + MeanY= +0.0550 millimeter + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +TwoBodyReaction + Beam=47K + Target=2H + Light=1H + Heavy=48K + + ExcitationEnergyLight= 0.0 MeV + ExcitationEnergyHeavy= 3.400 MeV + + LabCrossSectionPath= flat.txt CSR + + HalfOpenAngleMin = 0 deg + HalfOpenAngleMax = 180 deg + + ShootLight= 1 + ShootHeavy= 0 diff --git a/Projects/e793s/Reaction/47Kdp_Sim_Flat3500MeV.reaction b/Projects/e793s/Reaction/47Kdp_Sim_Flat3500MeV.reaction new file mode 100644 index 0000000000000000000000000000000000000000..e11fca32d7d5d67d21e487b8b47a0ac17eb754ec --- /dev/null +++ b/Projects/e793s/Reaction/47Kdp_Sim_Flat3500MeV.reaction @@ -0,0 +1,34 @@ +%%%%%%%%%%%%%%%%%%%%%% E793S %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +Beam + Particle= 47K + ExcitationEnergy= 0 MeV + %%-- 7.54789 MeV/u after CATS --%% + Energy= 354.75 MeV + SigmaEnergy= 0. MeV + SigmaThetaX= 0.0 deg + SigmaPhiY= 0.0 deg + SigmaX= 2.0 millimeter + SigmaY= 2.0 millimeter + MeanThetaX= 0 deg + MeanPhiY= 0 deg + MeanX= -3.9164 millimeter + MeanY= +0.0550 millimeter + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +TwoBodyReaction + Beam=47K + Target=2H + Light=1H + Heavy=48K + + ExcitationEnergyLight= 0.0 MeV + ExcitationEnergyHeavy= 3.500 MeV + + LabCrossSectionPath= flat.txt CSR + + HalfOpenAngleMin = 0 deg + HalfOpenAngleMax = 180 deg + + ShootLight= 1 + ShootHeavy= 0 diff --git a/Projects/e793s/Reaction/47Kdp_x0y0.reaction b/Projects/e793s/Reaction/47Kdp_x0y0.reaction new file mode 100755 index 0000000000000000000000000000000000000000..75f5a6628d79a01613554eb4cc19ab1f788aa5a5 --- /dev/null +++ b/Projects/e793s/Reaction/47Kdp_x0y0.reaction @@ -0,0 +1,28 @@ +%%%%%%%%%%%%%%%%%%%%%% E793S %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +Beam + Particle= 47K + ExcitationEnergy= 0 MeV + %%-- 7.54789 MeV/u after CATS --%% + Energy= 354.75 MeV + SigmaEnergy= 0. MeV + SigmaThetaX= 0.0 deg + SigmaPhiY= 0.0 deg + SigmaX= 2.0 millimeter + SigmaY= 2.0 millimeter + MeanThetaX= 0 deg + MeanPhiY= 0 deg + MeanX= +0.00 millimeter + MeanY= +0.00 millimeter + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +TwoBodyReaction + Beam= 47K + Target= 2H + Light= 1H + Heavy= 48K + ExcitationEnergyLight= 0.0 MeV + ExcitationEnergyHeavy= 0.0 MeV + CrossSectionPath= flat.txt CSR + ShootLight= 1 + ShootHeavy= 0 diff --git a/Projects/e793s/Reaction/47Kdt_08Nov.reaction b/Projects/e793s/Reaction/47Kdt_08Nov.reaction new file mode 100755 index 0000000000000000000000000000000000000000..9d15172600b0bd4ba52ee6bb527170182cd4dfe1 --- /dev/null +++ b/Projects/e793s/Reaction/47Kdt_08Nov.reaction @@ -0,0 +1,28 @@ +%%%%%%%%%%%%%%%%%%%%%% E793S %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +Beam + Particle= 47K + ExcitationEnergy= 0 MeV + %%-- 7.54789 MeV/u after CATS --%% + Energy= 354.75 MeV + SigmaEnergy= 0. MeV + SigmaThetaX= 0.0 deg + SigmaPhiY= 0.0 deg + SigmaX= 2.0 millimeter + SigmaY= 2.0 millimeter + MeanThetaX= 0 deg + MeanPhiY= 0 deg + MeanX= -3.9164 millimeter + MeanY= +0.0550 millimeter + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +TwoBodyReaction + Beam= 47K + Target= 2H + Light= 3H + Heavy= 46K + ExcitationEnergyLight= 0.0 MeV + ExcitationEnergyHeavy= 0.0 MeV + CrossSectionPath= flat.txt CSR + ShootLight= 1 + ShootHeavy= 0 diff --git a/Projects/e793s/configs/ConfigMugast.dat b/Projects/e793s/configs/ConfigMugast.dat index db0c1889238d943e901981ee9eaea2fe589a6372..4f23355a7664046a71c839adaddffd9a1b4b11dc 100755 --- a/Projects/e793s/configs/ConfigMugast.dat +++ b/Projects/e793s/configs/ConfigMugast.dat @@ -2,14 +2,10 @@ ConfigMugast TAKE_E_Y= 1 TAKE_T_Y= 1 -#Dead X strips DISABLE_CHANNEL_X= 2 4 - DISABLE_CHANNEL_X= 3 7 DISABLE_CHANNEL_X= 3 5 - DISABLE_CHANNEL_X= 4 31 - DISABLE_CHANNEL_X= 5 61 DISABLE_CHANNEL_X= 5 24 DISABLE_CHANNEL_X= 5 32 @@ -23,7 +19,6 @@ ConfigMugast DISABLE_CHANNEL_X= 5 73 DISABLE_CHANNEL_X= 5 71 DISABLE_CHANNEL_X= 5 72 - DISABLE_CHANNEL_X= 7 9 DISABLE_CHANNEL_X= 7 77 DISABLE_CHANNEL_X= 7 75 @@ -37,7 +32,6 @@ ConfigMugast DISABLE_CHANNEL_X= 7 68 DISABLE_CHANNEL_X= 7 65 -#Dead Y strips DISABLE_CHANNEL_Y= 1 85 DISABLE_CHANNEL_Y= 1 31 DISABLE_CHANNEL_Y= 1 36 @@ -52,13 +46,10 @@ ConfigMugast DISABLE_CHANNEL_Y= 1 26 DISABLE_CHANNEL_Y= 1 13 DISABLE_CHANNEL_Y= 1 15 - DISABLE_CHANNEL_Y= 2 39 DISABLE_CHANNEL_Y= 2 16 DISABLE_CHANNEL_Y= 2 62 - DISABLE_CHANNEL_Y= 3 11 - DISABLE_CHANNEL_Y= 4 100 DISABLE_CHANNEL_Y= 4 90 DISABLE_CHANNEL_Y= 4 102 @@ -74,7 +65,6 @@ ConfigMugast DISABLE_CHANNEL_Y= 4 4 DISABLE_CHANNEL_Y= 4 2 DISABLE_CHANNEL_Y= 4 55 - DISABLE_CHANNEL_Y= 5 120 DISABLE_CHANNEL_Y= 5 122 DISABLE_CHANNEL_Y= 5 113 @@ -86,7 +76,6 @@ ConfigMugast DISABLE_CHANNEL_Y= 5 38 DISABLE_CHANNEL_Y= 5 36 DISABLE_CHANNEL_Y= 5 4 - DISABLE_CHANNEL_Y= 7 126 DISABLE_CHANNEL_Y= 7 103 DISABLE_CHANNEL_Y= 7 128 @@ -105,8 +94,9 @@ ConfigMugast DISABLE_CHANNEL_Y= 7 57 MAX_STRIP_MULTIPLICITY= 10 - STRIP_ENERGY_MATCHING= 0.2 MeV + STRIP_ENERGY_MATCHING= 0.06 MeV DSSD_X_E_RAW_THRESHOLD= 8250 DSSD_Y_E_RAW_THRESHOLD= 8100 - DSSD_X_E_THRESHOLD= 1 MeV - DSSD_Y_E_THRESHOLD= 1 MeV + DSSD_X_E_THRESHOLD= 1 + DSSD_Y_E_THRESHOLD= 1 + diff --git a/Projects/e793s/configs/ConfigMust2.dat b/Projects/e793s/configs/ConfigMust2.dat index e117fa5f8a896ed8e1b0d6b0eec551dde21f2d33..beee75509e8a157ba1c76de44ccb71e3bb664191 100755 --- a/Projects/e793s/configs/ConfigMust2.dat +++ b/Projects/e793s/configs/ConfigMust2.dat @@ -2,38 +2,177 @@ ConfigMust2 MAX_STRIP_MULTIPLICITY 100 STRIP_ENERGY_MATCHING_NUMBER_OF_SIGMA 1 STRIP_ENERGY_MATCHING_SIGMA 0.2 - % Disabling dead strips + + + %%%%%%%%%%%%%%%% Disabling dead strips %%%%%%%%%%%%%%%% + + %MM1 X + DISABLE_CHANNEL MM1STRX2 DISABLE_CHANNEL MM1STRX3 + DISABLE_CHANNEL MM1STRX4 + DISABLE_CHANNEL MM1STRX12 + DISABLE_CHANNEL MM1STRX47 DISABLE_CHANNEL MM1STRX48 + DISABLE_CHANNEL MM1STRX49 + DISABLE_CHANNEL MM1STRX57 + DISABLE_CHANNEL MM1STRX64 + DISABLE_CHANNEL MM1STRX99 + DISABLE_CHANNEL MM1STRX128 + %MM1 Y + DISABLE_CHANNEL MM1STRY0 + DISABLE_CHANNEL MM1STRY1 + DISABLE_CHANNEL MM1STRY2 + DISABLE_CHANNEL MM1STRY22 + DISABLE_CHANNEL MM1STRY24 + DISABLE_CHANNEL MM1STRY26 + DISABLE_CHANNEL MM1STRY27 + DISABLE_CHANNEL MM1STRY31 + DISABLE_CHANNEL MM1STRY33 + DISABLE_CHANNEL MM1STRY35 + DISABLE_CHANNEL MM1STRY36 + DISABLE_CHANNEL MM1STRY37 + DISABLE_CHANNEL MM1STRY39 + DISABLE_CHANNEL MM1STRY46 + DISABLE_CHANNEL MM1STRY85 + DISABLE_CHANNEL MM1STRY94 DISABLE_CHANNEL MM1STRY105 + DISABLE_CHANNEL MM1STRY111 + DISABLE_CHANNEL MM1STRY114 DISABLE_CHANNEL MM1STRY119 DISABLE_CHANNEL MM1STRY123 DISABLE_CHANNEL MM1STRY126 - DISABLE_CHANNEL MM2STRX7 + %MM2 X DISABLE_CHANNEL MM2STRX12 + DISABLE_CHANNEL MM2STRX43 DISABLE_CHANNEL MM2STRX44 - DISABLE_CHANNEL MM2STRX68 + DISABLE_CHANNEL MM2STRX45 + DISABLE_CHANNEL MM2STRX64 DISABLE_CHANNEL MM2STRX111 DISABLE_CHANNEL MM2STRX121 DISABLE_CHANNEL MM2STRX126 + DISABLE_CHANNEL MM2STRX127 + DISABLE_CHANNEL MM2STRX128 + %MM2 Y + DISABLE_CHANNEL MM2STRY0 DISABLE_CHANNEL MM2STRY1 DISABLE_CHANNEL MM2STRY2 DISABLE_CHANNEL MM2STRY3 DISABLE_CHANNEL MM2STRY4 + DISABLE_CHANNEL MM2STRY16 DISABLE_CHANNEL MM2STRY19 DISABLE_CHANNEL MM2STRY20 DISABLE_CHANNEL MM2STRY24 DISABLE_CHANNEL MM2STRY25 DISABLE_CHANNEL MM2STRY26 + DISABLE_CHANNEL MM2STRY107 DISABLE_CHANNEL MM2STRY108 - DISABLE_CHANNEL MM2STRY108 + DISABLE_CHANNEL MM2STRY109 + DISABLE_CHANNEL MM2STRY123 + DISABLE_CHANNEL MM2STRY124 -%keep filling this in........ + %MM3 X + DISABLE_CHANNEL MM3STRX5 + DISABLE_CHANNEL MM3STRX7 + DISABLE_CHANNEL MM3STRX10 + DISABLE_CHANNEL MM3STRX11 + DISABLE_CHANNEL MM3STRX12 + DISABLE_CHANNEL MM3STRX13 + DISABLE_CHANNEL MM3STRX82 + DISABLE_CHANNEL MM3STRX83 + DISABLE_CHANNEL MM3STRX84 + DISABLE_CHANNEL MM3STRX127 + DISABLE_CHANNEL MM3STRX128 + %MM3 Y + DISABLE_CHANNEL MM3STRY11 + DISABLE_CHANNEL MM3STRY29 + DISABLE_CHANNEL MM3STRY98 + DISABLE_CHANNEL MM3STRY99 + DISABLE_CHANNEL MM3STRY100 + DISABLE_CHANNEL MM3STRY101 + DISABLE_CHANNEL MM3STRY123 + DISABLE_CHANNEL MM3STRY125 + DISABLE_CHANNEL MM3STRY126 + DISABLE_CHANNEL MM3STRY127 + + %MM4 X + DISABLE_CHANNEL MM4STRX12 + DISABLE_CHANNEL MM4STRX31 + DISABLE_CHANNEL MM4STRX64 + DISABLE_CHANNEL MM4STRX95 + DISABLE_CHANNEL MM4STRX127 + DISABLE_CHANNEL MM4STRX128 + + %MM4 Y + DISABLE_CHANNEL MM4STRY2 + DISABLE_CHANNEL MM4STRY4 + DISABLE_CHANNEL MM4STRY22 + DISABLE_CHANNEL MM4STRY36 + DISABLE_CHANNEL MM4STRY38 + DISABLE_CHANNEL MM4STRY39 + DISABLE_CHANNEL MM4STRY54 + DISABLE_CHANNEL MM4STRY55 + DISABLE_CHANNEL MM4STRY56 + DISABLE_CHANNEL MM4STRY59 + DISABLE_CHANNEL MM4STRY64 + DISABLE_CHANNEL MM4STRY65 + DISABLE_CHANNEL MM4STRY66 + DISABLE_CHANNEL MM4STRY75 + DISABLE_CHANNEL MM4STRY76 + DISABLE_CHANNEL MM4STRY77 + DISABLE_CHANNEL MM4STRY78 + DISABLE_CHANNEL MM4STRY90 + DISABLE_CHANNEL MM4STRY91 + DISABLE_CHANNEL MM4STRY92 + DISABLE_CHANNEL MM4STRY97 + DISABLE_CHANNEL MM4STRY98 + DISABLE_CHANNEL MM4STRY99 + DISABLE_CHANNEL MM4STRY100 + DISABLE_CHANNEL MM4STRY102 + DISABLE_CHANNEL MM4STRY105 + DISABLE_CHANNEL MM4STRY117 + + %MM5 X + DISABLE_CHANNEL MM5STRX11 + DISABLE_CHANNEL MM5STRX12 + DISABLE_CHANNEL MM5STRX61 + DISABLE_CHANNEL MM5STRX64 + DISABLE_CHANNEL MM5STRX71 + DISABLE_CHANNEL MM5STRX72 + DISABLE_CHANNEL MM5STRX73 + DISABLE_CHANNEL MM5STRX76 + DISABLE_CHANNEL MM5STRX94 + DISABLE_CHANNEL MM5STRX100 + DISABLE_CHANNEL MM5STRX101 + DISABLE_CHANNEL MM5STRX102 + DISABLE_CHANNEL MM5STRX103 + + %MM5 Y + DISABLE_CHANNEL MM5STRY0 + DISABLE_CHANNEL MM5STRY1 + DISABLE_CHANNEL MM5STRY25 + DISABLE_CHANNEL MM5STRY26 + DISABLE_CHANNEL MM5STRY27 + DISABLE_CHANNEL MM5STRY28 + DISABLE_CHANNEL MM5STRY29 + DISABLE_CHANNEL MM5STRY30 + DISABLE_CHANNEL MM5STRY36 + DISABLE_CHANNEL MM5STRY38 + DISABLE_CHANNEL MM5STRY95 + DISABLE_CHANNEL MM5STRY96 + DISABLE_CHANNEL MM5STRY97 + DISABLE_CHANNEL MM5STRY105 + DISABLE_CHANNEL MM5STRY107 + DISABLE_CHANNEL MM5STRY109 + DISABLE_CHANNEL MM5STRY111 + DISABLE_CHANNEL MM5STRY113 + DISABLE_CHANNEL MM5STRY122 + DISABLE_CHANNEL MM5STRY127 + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SI_X_E_RAW_THRESHOLD 8200 SI_Y_E_RAW_THRESHOLD 8180 diff --git a/Projects/e793s/exp.sh b/Projects/e793s/exp.sh new file mode 100755 index 0000000000000000000000000000000000000000..263ee445adae3059accc1316e8a6ab05e4fed0ca --- /dev/null +++ b/Projects/e793s/exp.sh @@ -0,0 +1,6 @@ +#!/bin/bash +cd ~/Programs/nptool/Projects/e793s; +cmake ./; +make -j6; +#npanalysis --definition Exp -R RunToTreat_PartII.txt -E Reaction/47Kdp_08Nov.reaction -D Detector/mugast_08Nov.detector -C Calibration.txt -O $1; +npanalysis --definition Exp -R RunToTreat_PartI.txt -E Reaction/47Kdp_08Nov.reaction -D Detector/mugast_18May22_TestingThickerTarget.detector -C Calibration.txt -O $1; diff --git a/Projects/e793s/macro/BeamSpot/EventReader.C b/Projects/e793s/macro/BeamSpot/EventReader.C index e88744fa2f50f862a79e5a54e26c2ac42f84cd6c..227da085011d85ff770880f3b38105eb5477bc3c 100755 --- a/Projects/e793s/macro/BeamSpot/EventReader.C +++ b/Projects/e793s/macro/BeamSpot/EventReader.C @@ -20,7 +20,8 @@ using namespace std; void EventReader(){ // Read ROOT file and pull the tree - auto DataFile = new TFile("../../../../Outputs/Analysis/47K_Full_02June.root", "READ"); + //auto DataFile = new TFile("../../../../Outputs/Analysis/47K_Full_08July.root", "READ"); + auto DataFile = new TFile("../../../../Outputs/Analysis/47Kdp_11Apr22_PartII.root", "READ"); auto PhysTree = (TTree*) DataFile->FindObjectAny("PhysicsTree"); // Initilise the Mugast branch @@ -28,7 +29,7 @@ void EventReader(){ // Initilise access variables for PhysTree static double T_MUGAST_VAMOS; - static vector<double> *X, *Y, *Z, *RawEnergy, *AddBack_EDC; + static vector<double> *X, *Y, *Z, *RawEnergy, *AddBack_EDC, *ThetaLab; // Pull PhysTree branches auto Energy_Branch = PhysTree->GetBranch("RawEnergy"); @@ -37,6 +38,7 @@ void EventReader(){ auto Y_Branch = PhysTree->GetBranch("Y"); auto Z_Branch = PhysTree->GetBranch("Z"); auto MugVam_Branch = PhysTree->GetBranch("T_MUGAST_VAMOS"); + auto ThetaLab_Branch = PhysTree->GetBranch("ThetaLab"); // Set Mugast branch address PhysTree->SetBranchAddress("Mugast",&Mugast); @@ -48,6 +50,7 @@ void EventReader(){ Y_Branch->SetAddress(&Y); Z_Branch->SetAddress(&Z); MugVam_Branch->SetAddress(&T_MUGAST_VAMOS); + ThetaLab_Branch->SetAddress(&ThetaLab); // Build loop variables unsigned int numEntries = PhysTree->GetEntries(); @@ -55,7 +58,8 @@ void EventReader(){ // Open output file ofstream outfile; - outfile.open("./XYZE_Full_02June.txt"); + //outfile.open("./XYZE_ShiftMG3_Sep08_GateOn0143.txt"); + outfile.open("./XYZE_GateOn1838_11Apr22_PtII.txt"); // Loop on entries for(unsigned int i=0; i<numEntries; i++){ @@ -66,25 +70,28 @@ void EventReader(){ for(int m=0; m<multiplicity; m++){ // Gate on Timing - if(abs(T_MUGAST_VAMOS-2777)<600){ + if(abs(T_MUGAST_VAMOS-2700)<400){ int gammaMultip = AddBack_EDC->size(); // cout << "GAMMA MULT " << gammaMultip << endl; - // gamma stuff (fails otherwise??) - //if(gammaMultip!=0){ - if(gammaMultip==1){ - //for(int g; g<gammaMultip; g++){ + //if(ThetaLab->at(m) <= 130. && ThetaLab->at(m) >= 100.){ + + // gamma stuff (fails otherwise??) + //if(gammaMultip!=0){ + if(gammaMultip>=1){ + //for(int g; g<gammaMultip; g++){ - // Gate on E_Gamma - if(abs(AddBack_EDC->at(0)-0.143) < 0.005){ - outfile << Mugast->TelescopeNumber.at(m) << " " << - X->at(m) << " " << - Y->at(m) << " " << - Z->at(m) << " " << - RawEnergy->at(m) << endl; - }//if 0.143 - //}//for g - }//if gamma + // Gate on E_Gamma + if(abs(AddBack_EDC->at(0)-1.838) < 0.005){ + outfile << Mugast->TelescopeNumber.at(m) << " " << + X->at(m) << " " << + Y->at(m) << " " << + Z->at(m) << " " << + RawEnergy->at(m) << endl; + }//if 0.143 + //}//for g + }//if gamma + //}//if theta (new!! testing!!! }//if timing }//for m }//for i diff --git a/Projects/e793s/macro/BeamSpot/MinimizeBeamSpot.cxx b/Projects/e793s/macro/BeamSpot/MinimizeBeamSpot.cxx index fad6a4824b6f8f8d93676bc3c190e2ea1b20d123..35521abf090b546c16505c657753b93c9e7cc6e3 100755 --- a/Projects/e793s/macro/BeamSpot/MinimizeBeamSpot.cxx +++ b/Projects/e793s/macro/BeamSpot/MinimizeBeamSpot.cxx @@ -22,22 +22,24 @@ double devE(const double * parameter) { h5 -> Reset(); h7 -> Reset(); hT -> Reset(); + hEL -> Reset(); //Now that initial range is wide, crop to single peak if(refE==0.143){ - h->SetAxisRange(-1.0, +1.0, "X"); - h1->SetAxisRange(-1.0, +1.0, "X"); - h2->SetAxisRange(-1.0, +1.0, "X"); - h3->SetAxisRange(-1.0, +1.0, "X"); - h4->SetAxisRange(-1.0, +1.0, "X"); - h5->SetAxisRange(-1.0, +1.0, "X"); - h7->SetAxisRange(-1.0, +1.0, "X"); + h->SetAxisRange( -1.0, +2.6, "X"); + h1->SetAxisRange(-1.0, +2.6, "X"); + h2->SetAxisRange(-1.0, +2.6, "X"); + h3->SetAxisRange(-1.0, +2.6, "X"); + h4->SetAxisRange(-1.0, +2.6, "X"); + h5->SetAxisRange(-1.0, +2.6, "X"); + h7->SetAxisRange(-1.0, +2.6, "X"); } //Initilize results array // 7 => Sum in 0 and them MG's in 1-6 - // 5 => Mean, MeanErr, StdDev, StdDevErr, Chi2/NDF - double FitResultMatrix[7][5]; + // 7 => Mean, MeanErr, StdDev, StdDevErr, Chi2/NDF, + // Mean2, StdDev2, Mean3, StdDev3 + double FitResultMatrix[7][9]; //Loop over events for (unsigned int i = 0; i < size; i++) { @@ -59,7 +61,7 @@ double devE(const double * parameter) { double ThetaTarget = dir.Angle(TVector3(0.0, 0.0, 1.0)); double ThetaMugast = dir.Angle(MugastNormal); double Energy = energy[i]; - +//cout << "@ angle " << ThetaTarget/deg << " " << Energy << " -> "; //Energy loss in Al Energy = Al.EvaluateInitialEnergy( Energy, //energy Al @@ -67,17 +69,21 @@ double devE(const double * parameter) { ThetaMugast //angle impinging on MUGAST ); +//cout << Energy << " -> "; //Energy loss in target Energy = CD2.EvaluateInitialEnergy( Energy, //energy after leaving target 0.5 * parameter[3] * micrometer, //pass through half target ThetaTarget //angle leaving target ); - + +//cout << Energy << endl; //Final value of Ex double Ex = reaction.ReconstructRelativistic(Energy, ThetaTarget); - //Fill histograms with + //Fill histograms with +//if(ThetaTarget/deg<130.){ // TESTING +//if(ThetaTarget/deg>130.){ // TESTING if(allButMG3){ if(detnum[i]!=3){ h -> Fill(Ex); @@ -86,8 +92,10 @@ double devE(const double * parameter) { } else { h -> Fill(Ex); } +//} DetectorSwitch(detnum[i], Ex); hT -> Fill(ThetaTarget/deg,Ex); + hEL -> Fill(ThetaTarget/deg,Energy-energy[i]);//ELoss in target and Al } //Initilise, Draw & Fit histograms @@ -98,14 +106,18 @@ double devE(const double * parameter) { /*** Minimize by one peak ***/ /**/ - double multiplier = 0.80; //0.08; + double multiplier = 0.05; //0.08; double metric = abs(FitResultMatrix[mgSelect][0]-refE) + abs(multiplier*FitResultMatrix[mgSelect][2]); + //double metric = abs(FitResultMatrix[mgSelect][0]-0.143) + abs(multiplier*FitResultMatrix[mgSelect][2]) + abs(FitResultMatrix[mgSelect][5]-1.410) + abs(multiplier*FitResultMatrix[mgSelect][6]); + //double metric = abs(FitResultMatrix[mgSelect][0]-0.143) + abs(multiplier*FitResultMatrix[mgSelect][2]) + abs(FitResultMatrix[mgSelect][5]-1.410) + abs(multiplier*FitResultMatrix[mgSelect][6])+ abs(FitResultMatrix[mgSelect][7]-1.980) + abs(multiplier*FitResultMatrix[mgSelect][8]) ; + //double metric = abs(FitResultMatrix[mgSelect][7]-1.981) + abs(multiplier*FitResultMatrix[mgSelect][8]); ; + /**/ /*** Minimize by all peaks ***/ /** //double multiplier = 0.125; - double multiplier = 0.005; + double multiplier = 0.05; double metric = (1.0/6.0)*abs(FitResultMatrix[1][0]-refE) + (1.0/6.0)*abs(FitResultMatrix[2][0]-refE) @@ -113,13 +125,13 @@ double devE(const double * parameter) { + (1.0/6.0)*abs(FitResultMatrix[4][0]-refE) + (1.0/6.0)*abs(FitResultMatrix[5][0]-refE) + (1.0/6.0)*abs(FitResultMatrix[6][0]-refE) - + 1.0*abs(FitResultMatrix[0][0]-refE) - //+ multiplier*FitResultMatrix[1][2] - //+ multiplier*FitResultMatrix[2][2] - //+ multiplier*FitResultMatrix[3][2] - //+ multiplier*FitResultMatrix[4][2] - //+ multiplier*FitResultMatrix[5][2] - //+ multiplier*FitResultMatrix[6][2] + //+ 1.0*abs(FitResultMatrix[0][0]-refE) + + multiplier*FitResultMatrix[1][2] + + multiplier*FitResultMatrix[2][2] + + multiplier*FitResultMatrix[3][2] + + multiplier*FitResultMatrix[4][2] + + multiplier*FitResultMatrix[5][2] + + multiplier*FitResultMatrix[6][2] ; **/ @@ -139,17 +151,11 @@ double devE(const double * parameter) { return metric; } -//////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void MinimizeBeamSpot() { - ////filename = "XYZE_ShiftMG3_GateOn1838.txt"; - //filename = "XYZE_GateOn1838.txt"; - //refE = 1.981; // the energy of the selected states - - ////filename = "XYZE_ShiftMG3_GateOn0143.txt"; - filename = "XYZE_GateOn0143.txt"; - refE = 0.143; // the energy of the selected states + //filename = "XYZE_GateOn1838_11Apr22.txt"; refE = 1.981; // the energy of the selected states + filename = "XYZE_GateOn0143_11Apr22.txt"; refE = 0.143; // the energy of the selected states //Read data in @@ -193,7 +199,34 @@ void MinimizeBeamSpot() { //Start with beam (0,0,0) and 4.76um 0.5mg/c2 target double parameter[4] = { //0.0, 0.0, 0.0, 4.76 - -3.9164, +0.0550, 1.0151, 1.1883 + //-3.9164, +0.0550, 1.3958, 1.3008 + + //-3.9164, +0.0550, +1.0, +2.4 + //-3.9164, +0.0550, +0.681611, +2.256769 + //-3.9164, +0.0550, +0.786721, +2.113878 + + //-3.9164, 0.0550, 0.5, 2.6 + //-3.9164, 0.0550, +0.146952, +2.517784 + + //-4.675715, +0.143686, +0.115426, +2.586484 + //-4.636827, -0.206620, +0.115426, +2.586484 + + + //-4., +1.0, +0.115426, +2.586484 + //-5.088554, +1.476001, +0.342552, +2.586484 + //-5.088554, +1.476001, +0.236014, +2.523850 + //-3.989139, 0.99116, 0.115426, 2.586484 + //-3.989139, +0.991160, +0.587660, +2.586484 + + //-3.989139, +0.991160, +0.587660, +2.586484 + //-3.9164, +0.0550, 0.0, 2.6 + //-3.9164, +0.0550, 0.0, +2.838327 + //-3.912110, +0.083580, +0.000000, +2.838327 + //-3.912110, +0.083580, +0.000000, +2.6 + //-3.9164, +0.0550, +0.0, 2.3 + //-3.9164, +0.0550, +0.0, +2.591512 + -5.334864, -0.698900, +0.0, +2.591512 + }; //Don't draw iterations of minimizer @@ -211,20 +244,23 @@ void MinimizeBeamSpot() { minim -> SetMaxFunctionCalls(100000000); // used by Minuit and Minuit2 minim -> SetMaxIterations(100000000); // used by GSL minim -> SetPrintLevel(3); - minim -> SetPrecision(1e-08); + minim -> SetPrecision(1e-06); //Set minimizer function minim -> SetFunction(func); //Assign variable limits - minim -> SetLimitedVariable(0, "X", parameter[0], 0.10, -8.0, -0.0); - //minim -> SetFixedVariable(0, "X", parameter[0]); - minim -> SetLimitedVariable(1, "Y", parameter[1], 0.10, -6.0, +6.0); - //minim -> SetFixedVariable(1, "Y", parameter[1]); - minim -> SetLimitedVariable(2, "Z", parameter[2], 0.05, -1.50, +1.50); - //minim -> SetFixedVariable(2, "Z", parameter[2]); - minim -> SetLimitedVariable(3, "T", parameter[3], 0.05, +1.0, +1.4); // ELASTICS VALUE = 1.2(2) - //minim -> SetFixedVariable(3, "T", parameter[3]); + //minim -> SetLimitedVariable(0, "X", parameter[0], 0.10, -8.0, -0.0); + minim -> SetFixedVariable(0, "X", parameter[0]); + //minim -> SetLimitedVariable(1, "Y", parameter[1], 0.10, -6.0, +6.0); + minim -> SetFixedVariable(1, "Y", parameter[1]); + //minim -> SetLimitedVariable(2, "Z", parameter[2], 0.05, 0.90, +1.10); + //minim -> SetLimitedVariable(2, "Z", parameter[2], 0.10, -2.00, +2.00); + minim -> SetFixedVariable(2, "Z", parameter[2]); + //minim -> SetLimitedVariable(3, "T", parameter[3], 0.05, +0.9, +1.5); // ELASTICS, 1.2(3) + //minim -> SetLimitedVariable(3, "T", parameter[3], 0.05, +2.05, +3.25); // ELASTICS, 2.65(59) + minim -> SetFixedVariable(3, "T", parameter[3]); + //Don't draw iterations of minimizer flagDraw = 0; diff --git a/Projects/e793s/macro/BeamSpot/MinimizeBeamSpot.h b/Projects/e793s/macro/BeamSpot/MinimizeBeamSpot.h index 43af2c4d82ea1a70594990150554b14cf3217b2f..4fef196796bed609af46879d7d0807ba12522d75 100755 --- a/Projects/e793s/macro/BeamSpot/MinimizeBeamSpot.h +++ b/Projects/e793s/macro/BeamSpot/MinimizeBeamSpot.h @@ -32,14 +32,42 @@ int writeCount = 0; //Histograms string filename; double refE; // the energy of the selected states -static auto h = new TH1D("h","All MG#'s", 40,-1.0,3.0); -static auto h1 = new TH1D("h1","Individual MG#'s", 40,-1.0,3.0); -static auto h2 = new TH1D("h2","h2", 40,-1.0,3.0); -static auto h3 = new TH1D("h3","h3", 40,-1.0,3.0); -static auto h4 = new TH1D("h4","h4", 40,-1.0,3.0); -static auto h5 = new TH1D("h5","h5", 40,-1.0,3.0); -static auto h7 = new TH1D("h7","h7", 40,-1.0,3.0); -static auto hT = new TH2F("hT","hT", 20,100.,160.,20,-0.1,0.4); +static auto h = new TH1D("h","All MG#'s", 200,-1.0,3.0); +static auto h1 = new TH1D("h1","Individual MG#'s", 80,-1.0,3.0); +static auto h2 = new TH1D("h2","h2", 80,-1.0,3.0); +static auto h3 = new TH1D("h3","h3", 80,-1.0,3.0); +static auto h4 = new TH1D("h4","h4", 80,-1.0,3.0); +static auto h5 = new TH1D("h5","h5", 80,-1.0,3.0); +static auto h7 = new TH1D("h7","h7", 80,-1.0,3.0); +static auto hT = new TH2F("hT","hT", 60,100.,160.,80,-1.0,3.0); +static auto hEL = new TH2F("hEL","hEL", 60,100.,160.,2000,0.0,0.1); + + + + +Double_t f_full(Double_t *x, Double_t *par) { + float xx = x[0]; + double result, norm; + // Flat background + //result = par[0]; + result = 0; + // Add N peaks + for(int pk=0; pk<3; pk++){ + result += (par[3+(pk*3)]/(par[1+(pk*3)]*sqrt(2*pi))) + * exp(-0.5*pow((xx-par[2+(pk*3)])/par[1+(pk*3)],2)); + } + return result; +} + +Double_t f_one(Double_t *x, Double_t *par) { + float xx = x[0]; + double result, norm; + result = (par[3]/(par[1]*sqrt(2*pi))) + * exp(-0.5*pow((xx-par[2])/par[1],2)); + return result; +} + +//static auto hT = new TH2F("hT","hT", 20,100.,160.,20,-1.0,1.0); //////////////////////////////////////////////////////////////////////////////// void LoadFile(){ // Open XYZE gamma-gated file @@ -68,16 +96,22 @@ void LoadFile(){ } //////////////////////////////////////////////////////////////////////////////// void FillMatrix(double* matrix, TFitResultPtr fit){ - matrix[0] = fit->Parameter(1); //Mean - matrix[1] = fit->ParError(1); - matrix[2] = fit->Parameter(2); //StdDev - matrix[3] = fit->ParError(2); + matrix[0] = fit->Parameter(2); //Mean + matrix[1] = fit->ParError(2); + matrix[2] = fit->Parameter(1); //StdDev + matrix[3] = fit->ParError(1); matrix[4] = fit->Chi2()/fit->Ndf(); //Chi2/NDF + matrix[5] = fit->Parameter(5);//(8); //Mean2 + matrix[6] = fit->Parameter(4);//(7); //StdDev2 + matrix[7] = fit->Parameter(8);//(8); //Mean2 + matrix[8] = fit->Parameter(7);//(7); //StdDev2 if(flagDraw){ cout << "\n Mean = " << matrix[0] << " +/- " << matrix[1] << endl; cout << " StdDev = " << matrix[2] << " +/- " << matrix[3] << endl; cout << " Chi2/NDF = " << matrix[4] << endl; + cout << " Mean2 = " << matrix[5] << " StdDev2 = " << matrix[6] << endl; + cout << " Mean3 = " << matrix[7] << " StdDev2 = " << matrix[8] << endl; } } //////////////////////////////////////////////////////////////////////////////// @@ -152,6 +186,14 @@ void WriteToCout(double* result, double thick, double metric){ << result[4] << " Metric: " << metric + << " Mean2: " + << result[5] + << " StdDev2: " + << result[6] + << " Mean3: " + << result[7] + << " StdDev3: " + << result[8] << endl; } //////////////////////////////////////////////////////////////////////////////// @@ -194,22 +236,52 @@ void DrawOneHistogram(TH1D* hist, int mg, int colour, int fill, double *FitResul const char* settings; if (drawFit){ - settings = "WQS"; + settings = "RBWQS"; } else { - settings = "WQSN"; + settings = "RBWQSN"; } +/* + //TFitResultPtr fit; + //if(abs(refE-0.143)<0.05){ + TF1 *full = new TF1("fitThreePeaks", f_full, -1.0, +2.6, (int) 1+(3*3)); + for(int i=0; i<3; i++) { + full->SetParameter((i*3)+1,0.14); + full->SetParameter((i*3)+3,1e3); + } + full->SetParameter((0*3)+2,0.143); + full->SetParameter((1*3)+2,1.410); + full->SetParameter((2*3)+2,1.981); + //fit = hist->Fit(full, settings, "", -1.0, +2.6); + TFitResultPtr fit = hist->Fit(full, settings, "", -1.0, +2.6); + //} else { + // TF1 *one = new TF1("fitOne", f_one, -1.0, +2.6, (int) 1+(3*3)); + // one->SetParameter(1,0.14); + // one->SetParameter(3,1e3); + // one->SetParameter(2,refE); + // fit = hist->Fit(one, settings, "", -1.0, +2.6); + //} +*/ + TF1 *full = new TF1("fitThreePeaks", f_full, -1.0, +2.6, (int) 1+(3*3)); + for(int i=0; i<3; i++) { + full->SetParameter((i*3)+1,0.14); + full->SetParameter((i*3)+3,1e3); + } + full->SetParameter((0*3)+2,0.143); + full->SetParameter((1*3)+2,1.410); + full->SetParameter((2*3)+2,1.981); - TFitResultPtr fit = hist->Fit("gaus",settings); //N=stop drawing, Q=stop writing + TFitResultPtr fit = hist->Fit(full, settings, "", -1.0, +2.6); FillMatrix(FitResultMatrixMG,fit); } //////////////////////////////////////////////////////////////////////////////// -void InitiliseCanvas(double FitResultMatrix[7][5]){ +void InitiliseCanvas(double FitResultMatrix[7][9]){ //Canvas setup TCanvas *canv = new TCanvas("canv","Ex Histograms",20,20,1600,800); gStyle->SetOptStat(0); //canv->Divide(2,1,0.005,0.005,0); - canv->Divide(3,1,0.005,0.005,0); + //canv->Divide(3,1,0.005,0.005,0); + canv->Divide(2,2,0.005,0.005,0); canv->cd(1)->SetLeftMargin(0.15); canv->cd(1)->SetBottomMargin(0.15); gPad->SetTickx(); @@ -218,11 +290,14 @@ void InitiliseCanvas(double FitResultMatrix[7][5]){ canv->cd(2)->SetBottomMargin(0.15); gPad->SetTickx(); gPad->SetTicky(); - canv->cd(3)->SetLeftMargin(0.15); canv->cd(3)->SetBottomMargin(0.15); gPad->SetTickx(); gPad->SetTicky(); + canv->cd(4)->SetLeftMargin(0.15); + canv->cd(4)->SetBottomMargin(0.15); + gPad->SetTickx(); + gPad->SetTicky(); //Histogram setup - Individual canv->cd(1); @@ -249,13 +324,14 @@ void InitiliseCanvas(double FitResultMatrix[7][5]){ line->Draw(); //Format legend - auto legend = new TLegend(0.15,0.7,0.35,0.9); - legend->AddEntry(h1,"MUGAST 1","f"); - legend->AddEntry(h2,"MUGAST 2","f"); - legend->AddEntry(h3,"MUGAST 3","f"); - legend->AddEntry(h4,"MUGAST 4","f"); - legend->AddEntry(h5,"MUGAST 5","f"); - legend->AddEntry(h7,"MUGAST 7","f"); + auto legend = new TLegend(0.15,0.7,0.45,0.9); + legend->AddEntry(h1,"MG #1","f"); + legend->AddEntry(h2,"MG #2","f"); + legend->AddEntry(h3,"MG #3","f"); + legend->AddEntry(h4,"MG #4","f"); + legend->AddEntry(h5,"MG #5","f"); + legend->AddEntry(h7,"MG #7","f"); + //legend->SetTextSize(20); legend->Draw(); //Histogram setup - Sum @@ -278,10 +354,16 @@ void InitiliseCanvas(double FitResultMatrix[7][5]){ hT->Draw("colz"); canv->Update(); TLine *l0143 = new TLine(100., 0.143, 160., 0.143); + TLine *l1981 = new TLine(100., 1.981, 160., 1.981); l0143->SetLineStyle(kDashed); l0143->SetLineColor(kRed); l0143->Draw("same"); + canv->cd(4); + hEL->GetXaxis()->SetTitle("Theta (degrees)"); + hEL->GetYaxis()->SetTitle("Energy loss in Target + Al [MeV]"); + hEL->Draw(); + //Refresh gPad->Update(); diff --git a/Projects/e793s/macro/CS2.h b/Projects/e793s/macro/CS2.h index 271d5cd9c0df3d16741d22319120c5bbd878397d..4608b0578473ec44320cdb6134988495c90e3e9a 100644 --- a/Projects/e793s/macro/CS2.h +++ b/Projects/e793s/macro/CS2.h @@ -21,6 +21,10 @@ bool loud = 0; /* Scale method toggle */ bool scaleTogether = 1; +/* String for image */ +string orbitalname; +string orbital; + //////////////////////////////////////////////////////////////////////////////// void CS(){ /* Overload function */ @@ -42,14 +46,41 @@ void CS(){ //////////////////////////////////////////////////////////////////////////////// void CS(double Energy, double Spin, double spdf, double angmom){ - /* BASIC RUN: CS(0.143,2,1,1.5,1) */ - - // p3/5 -> spdf = 1, angmom = 1.5 + // p3/2 -> spdf = 1, angmom = 1.5 // J0 is incident spin, which is 47K g.s. therefore J0 = 1/2 double J0 = 0.5; double ElasticNorm = 5.8, ElasticNormErr = 1.3; // DeuteronNorm in elastics, 5.8 +- 1.3 + + orbitalname.clear(); + orbital.clear(); + if(spdf==1){ + if(angmom==0.5){ + orbitalname="p_{1/2}"; + orbital="p12"; + } else if (angmom==1.5){ + orbitalname="p_{3/2}"; + orbital="p32"; + } else { + orbitalname="?????"; + orbital="???"; + } + } else if (spdf==3){ + if(angmom==2.5){ + orbitalname="f_{5/2}"; + orbital="f52"; + } else if (angmom==3.5) { + orbitalname="f_{7/2}"; + orbital="f72"; + } else { + orbitalname="?????"; + orbital="???"; + } + } else { + orbitalname="?????"; + orbital="???"; + } + /* Reduce by factor of 10,000 */ - /* WHY DOES THIS WORK???????*/ ElasticNorm /= 10000.; ElasticNormErr /= 10000.; double nodes; @@ -91,12 +122,13 @@ void CS(double Energy, double Spin, double spdf, double angmom){ } /* Solid Angle (from simulation) */ -// auto file = new TFile("../SolidAngle_HistFile_06Dec_47Kdp.root"); - auto file = new TFile("../SolidAngle_HistFile_15Feb_47Kdp.root"); + //auto file = new TFile("../SolidAngle_HistFile_15Feb_47Kdp.root"); + auto file = new TFile("../SolidAngle_HistFile_17May22_47Kdp_0143.root"); + //auto file = new TFile("../SolidAngle_HistFile_06May_WideStripMatching_LargeRun.root"); TH1F* SolidAngle = (TH1F*) file->FindObjectAny("SolidAngle_Lab_MG"); TCanvas* c_SolidAngle = new TCanvas("c_SolidAngle","c_SolidAngle",1000,1000); SolidAngle->Draw(); - // canvas deleted after Area/SA calculation + /* (canvas deleted after Area/SA calculation) */ /* Area of experimental peaks */ TCanvas* c_PeakArea = new TCanvas("c_PeakArea","c_PeakArea",1000,1000); @@ -194,9 +226,14 @@ void CS(double Energy, double Spin, double spdf, double angmom){ //&(anglewidth[0]), &(AoSAerr[0]) ); 0, &(expDCSerr[0]) ); gdSdO->SetTitle("Differential Cross Section"); - gdSdO->GetXaxis()->SetTitle("ThetaLab [deg]"); + gdSdO->GetXaxis()->SetTitle("#theta_{lab} [deg]"); + gdSdO->GetXaxis()->SetTitleOffset(1.2); + gdSdO->GetXaxis()->SetTitleSize(0.04); gdSdO->GetYaxis()->SetTitle("d#sigma/d#Omega [mb/msr]"); + gdSdO->GetYaxis()->SetTitleOffset(1.2); + gdSdO->GetYaxis()->SetTitleSize(0.04); gdSdO->Draw(); + c_dSdO->Update(); /* TWOFNR diff. cross section, in mb/msr */ TCanvas* c_TWOFNR = new TCanvas("c_TWOFNR","c_TWOFNR",1000,1000); @@ -228,22 +265,85 @@ void CS(double Energy, double Spin, double spdf, double angmom){ /* Using Chi2 minimizaiton */ cout << "USING CHI2 MINIMIZAITON..." << endl; TCanvas* c_Chi2Min = new TCanvas("c_Chi2Min","c_Chi2Min",1000,1000); - c_Chi2Min->SetLogy(); + gStyle->SetPadLeftMargin(0.12); + gStyle->SetPadRightMargin(0.03); + //c_Chi2Min->SetLogy(); + + TPad *pad1 = new TPad("pad1","pad1",0,0.25,1,1); + TPad *pad2 = new TPad("pad2","pad2",0,0,1,0.25); + pad1->SetTopMargin(0.1); + pad1->SetBottomMargin(0.00001); + pad1->SetBorderMode(0); + pad1->SetLogy(); + pad1->SetTickx(); + pad1->SetTicky(); + pad2->SetTopMargin(0.00001); + pad2->SetBottomMargin(0.3); + pad2->SetBorderMode(0); + pad2->SetTickx(); + pad2->SetTicky(); + pad1->Draw(); + pad2->Draw(); + pad1->cd(); + TGraph* Final = FindNormalisation(TheoryDiffCross,gdSdO); gdSdO->SetLineColor(kRed); gdSdO->SetMarkerColor(kRed); gdSdO->SetMarkerStyle(21); - /* Construct title string */ + /* Construct file name string */ + /**/ ostringstream tempstream; + /**/ if(means[indexE]<1.0){tempstream << 0;} + /**/ tempstream << (int) (means[indexE]*1000); + /**/ tempstream << "_" << orbital; + /**/ tempstream << "_spin" << Spin; + /**/ string tempstr = tempstream.str(); + /* Construct hist title string */ /**/ ostringstream textstream; /**/ textstream << std::fixed << setprecision(3); - /**/ textstream << "Peak " << means[indexE]; - /**/ string tempstr = textstream.str(); - /**/ textstream << ": S = " << globalS + /**/ textstream << " " << means[indexE]; + /**/ textstream << " MeV, "; + /**/ textstream << orbitalname; + /**/ textstream << ", spin " << (int)Spin; + /**/ textstream << " --> S = " << globalS /**/ << " +- " << globalSerr; /**/ string textstring = textstream.str(); + gdSdO->SetTitle(textstring.c_str()); + gdSdO->GetYaxis()->SetTitleOffset(1.3); + gdSdO->GetYaxis()->SetTitleSize(0.042); + gdSdO->GetXaxis()->SetRangeUser(103.,157.); gdSdO->Draw("AP"); Final->Draw("SAME"); + + + pad2->cd(); + TGraphErrors* gResid = new TGraphErrors(*gdSdO); + for(int n=0; n < gResid->GetN(); n++){ + double x = gdSdO->GetPointX(n); + double residual = gdSdO->GetPointY(n) - Final->Eval(x); + gResid->SetPoint(n,x,residual); + gResid->SetPointError(n,0,gdSdO->GetErrorY(n)); + } + TLine* markzero = new TLine(103.,0.,157.,0.); + gResid->SetTitle(""); + gResid->GetXaxis()->SetRangeUser(103.,157.); + gResid->GetYaxis()->SetTitle("Residuals"); + gResid->GetYaxis()->SetTitleSize(0.15); + gResid->GetYaxis()->SetTitleOffset(0.36); + gResid->GetYaxis()->SetLabelSize(0.08); + gResid->GetYaxis()->SetNdivisions(305); + gResid->GetXaxis()->SetTitleSize(0.15); + gResid->GetXaxis()->SetTitleOffset(0.8); + gResid->GetXaxis()->SetLabelSize(0.1); + gResid->GetXaxis()->SetTickLength(0.1); + gResid->Draw(); + markzero->SetLineStyle(2); + markzero->Draw("same"); + + //pad1->cd(); + //TText* orb = new TText(0.5,0.2,"TESTING!!!!!!!!!!!");//orbitalname.c_str()); + //orb->Draw("SAME"); + string savestring1 = "./CS2_Figures/"+tempstr+".root"; string savestring2 = "./CS2_Figures/"+tempstr+".pdf"; c_Chi2Min->SaveAs(savestring1.c_str()); @@ -260,9 +360,10 @@ vector<vector<double>> GetExpDiffCross(double Energy){ vector<vector<double>> OnePeak_AllGates; int numbins = 10; double x[numbins], y[numbins]; - TList* list = new TList(); + //TList* list = new TList(); /* Determine scaling factor for PhaseSpace */ + TCanvas* c_ExSubPSpace = new TCanvas("c_ExSubPSpace","c_ExSubPSpace",1000,1000); double trackScale = 0.0; if(scaleTogether){ TH1F* baseEx = PullThetaLabHist(0,105.,5.); @@ -271,32 +372,44 @@ vector<vector<double>> GetExpDiffCross(double Energy){ TH1F* addEx = PullThetaLabHist(i,105.,5.); baseEx->Add(addEx,1.); TH1F* addPS = PullPhaseSpaceHist(i,105.,5.); basePS->Add(addPS,1.); } + /* Subtract flat background equal to smallest bin in range */ - TH1F* baseExCopy = baseEx; - baseExCopy->GetXaxis()->SetRange(baseExCopy->FindBin(-1.),baseExCopy->FindBin(7.9)); - double minValueInRange = baseExCopy->GetBinContent(baseEx->GetMinimumBin()); + baseEx->GetXaxis()->SetRange(baseEx->FindBin(-1.),baseEx->FindBin(1.)); + double minValueInRange = baseEx->GetBinContent(baseEx->GetMinimumBin()); + baseEx->GetXaxis()->UnZoom(); cout << "Subtracting background of " << minValueInRange << endl; for(int b=1; b<baseEx->GetNbinsX() ; b++){ baseEx->SetBinContent(b,baseEx->GetBinContent(b)-minValueInRange); } + /* Begin scaling within range, track changes */ - basePS->Scale(0.01); - trackScale = 0.01; + basePS->Scale(0.1); + trackScale = 0.1; int numbinsScale = baseEx->GetNbinsX(); - int nbinlow = basePS->FindBin(2.); int nbinhigh = basePS->FindBin(7.5); - //for(int b=1; b<numbinsScale; b++){ + int nbinlow = basePS->FindBin(4.); int nbinhigh = basePS->FindBin(8.0); for(int b=nbinlow; b<nbinhigh; b++){ - while(basePS->GetBinContent(b) > baseEx->GetBinContent(b)){ - basePS->Scale(0.99999); - trackScale *= 0.99999; + if(baseEx->GetBinContent(b) > 0.0 && basePS->GetBinContent(b) > baseEx->GetBinContent(b)){ + while(basePS->GetBinContent(b) > baseEx->GetBinContent(b)){ + basePS->Scale(0.99999); + trackScale *= 0.99999; + } } } baseEx->Add(basePS,-1.); - baseEx->SetName("AllAngles"); - list->Add(baseEx); - cout << " !!!!!!!!!!!!!!!FINAL SCALING = " << trackScale << endl; + baseEx->SetName("ExSubPSpace"); + baseEx->SetTitle("ExSubPSpace"); + baseEx->Draw(); + cout << "PhaseSpace -> ExpData scaling = " << trackScale << endl; } + /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */ + /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */ + // TEMPORARY!!! REMOVE LAST THREE BINS ON HIGH ENERGY STATES!!! + if(means[indexE] > 3.0){numbins-=3;} + /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */ + /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */ + + for(int i=0; i<numbins;i++){ double bin = 5.; double min = 105. + (i*bin); @@ -320,6 +433,7 @@ vector<vector<double>> GetExpDiffCross(double Energy){ gate->Add(pspace,-trackScale); } /* ... or seperately for each angular bin */ + /* NOTE THAT THIS DOES NOT ACCOUNT FOR FLAT BACKGROUND */ else { if(pspace->Integral() > 50.){ // Non-garbage histogram pspace->Scale(0.01); @@ -342,6 +456,18 @@ vector<vector<double>> GetExpDiffCross(double Energy){ } } + /* Subtract flat background equal to smallest bin in range */ + /* ????? */ + /* + gate->GetXaxis()->SetRange(gate->FindBin(-1.),gate->FindBin(1.)); + double minValueInRange = gate->GetBinContent(gate->GetMinimumBin()); + gate->GetXaxis()->UnZoom(); + cout << "Subtracting background of " << minValueInRange << endl; + for(int b=1; b<gate->GetNbinsX() ; b++){ + gate->SetBinContent(b,gate->GetBinContent(b)-minValueInRange); + } + */ + /* Retrieve array containing all fits, for one angle gate. * * Specific peak of interest selected from the vector by * * global variable indexE */ @@ -378,6 +504,7 @@ vector<vector<double>> GetExpDiffCross(double Energy){ //////////////////////////////////////////////////////////////////////////////// TH1F* PullThetaLabHist(int i, double minTheta, double gatesize){ + //TFile* file = new TFile("GateThetaLabHistograms.root","READ"); TFile* file = new TFile("GateThetaLabHistograms_ReadMe.root","READ"); string histname = "cThetaLabGate_" + to_string((int) (minTheta+(i*gatesize))) + "-" @@ -431,11 +558,33 @@ void Scale(TGraph* g , TGraphErrors* ex){ } //////////////////////////////////////////////////////////////////////////////// +//TGraph* TWOFNR(double E, double J0, double J, double n, double l, double j, const char* model){ TGraph* TWOFNR(double E, double J0, double J, double n, double l, double j){ /* This function mved between directories in order to run TWOFNR in proper * * location. This is, weirdly, the least tempremental way of doing this. */ cout << "========================================================" << endl; + int johnson, tandyval; + cout << "Using Johnson-Soper ..."; johnson=5; tandyval=0; + //cout << "Using Johnson-Tandy 1 ..."; johnson=6; tandyval=1; + //cout << "Using Johnson-Tandy 2 ..."; johnson=6; tandyval=2; + //cout << "Using Johnson-Tandy 3 ..."; johnson=6; tandyval=3; + //cout << "Using Johnson-Tandy 4 ..."; johnson=6; tandyval=4; + + int modelA,modelB; +// switch (model):{ +// case 'K': case 'k':{ +// cout << " ... Koning-Delaroche." << endl; modelA=6; modelB=4; +// } +// case 'C': case 'c':{ + cout << " ... and Chapel-Hill." << endl; modelA=2; modelB=2; +// } +// case 'B': case 'b':{ +// cout << " ... Bechetti-Greenlees." << endl; modelA=1; modelB=1; +// } +// } + + char origDirchar[200]; getcwd(origDirchar,200); string origDir{origDirchar}; @@ -472,12 +621,15 @@ TGraph* TWOFNR(double E, double J0, double J, double n, double l, double j){ Front_Input << 1 << std::endl; Front_Input << J0 << std::endl; Front_Input << 1 << std::endl; - Front_Input << 5 << std::endl; + Front_Input << johnson << std::endl; + if(johnson==6){//JTandy selected, give version + Front_Input << tandyval << std::endl; + } Front_Input << 1 << std::endl; Front_Input << J << std::endl; Front_Input << 1 << std::endl; - Front_Input << 6 << std::endl; - Front_Input << 4 << std::endl; + Front_Input << modelA << std::endl; + Front_Input << modelB << std::endl; Front_Input << 1 << std::endl; Front_Input << 1 << std::endl; Front_Input << 1 << std::endl; @@ -538,17 +690,22 @@ TGraph* TWOFNR(double E, double J0, double J, double n, double l, double j){ //////////////////////////////////////////////////////////////////////////////// double Chi2(TGraph* theory, TGraphErrors* exper){ - double Chi2 = 0 ; - double chi; + double Chi2 = 0; + double chi = 0; + + //cout << setprecision(8); //for(int i = 1 ; i < exper->GetN() ; i++){ for(int i = 0 ; i < exper->GetN() ; i++){ - if(exper->Eval(anglecentres[i])>1.0e-10){ //0){ - chi=(exper->Eval(anglecentres[i])-theory->Eval(anglecentres[i]) ) / (exper->GetErrorY(i)); + if(exper->GetPointY(i)>1.0e-8){ //0){ + //chi=(exper->Eval(anglecentres[i])-theory->Eval(anglecentres[i]) ) / (exper->GetErrorY(i)); + chi=(exper->GetPointY(i) - theory->Eval(anglecentres[i]) ) / (exper->GetErrorY(i)); + //cout << "COMPARE::::: " << exper->Eval(anglecentres[i]) << " TO " << exper->GetPointY(i) << endl; Chi2 +=chi*chi; } } if(loud){cout << "Chi2 = " << Chi2 << endl;} return Chi2; + //cout << setprecision(3); } //////////////////////////////////////////////////////////////////////////////// @@ -589,10 +746,10 @@ TGraph* FindNormalisation(TGraph* theory, TGraphErrors* experiment){ // Set range of parameter(??) double* parameter = new double[mysize]; for(unsigned int i = 0 ; i < mysize ; i++){ - parameter[i] = 0.5; + parameter[i] = 0.8; char name[4]; sprintf(name,"S%d",i+1); - min->SetLimitedVariable(i,name,parameter[i],0.1,0,10000); + min->SetLimitedVariable(i,name,parameter[i],0.01,0,10); } @@ -616,7 +773,20 @@ TGraph* FindNormalisation(TGraph* theory, TGraphErrors* experiment){ TGraph* g = new TGraph(); double* X = theory->GetX(); double* Y = theory->GetY(); + if(loud){ + cout << setprecision(8); + cout << "Start: X[0] = " << theory->GetPointX(4) << " Y[0] = " << theory->GetPointY(4) << endl; + cout << "multip by " << xs[0] << endl; + } + for(int i=0; i<theory->GetN(); i++){ g->SetPoint(g->GetN(),X[i],xs[0]*Y[i]); } + //for(int i=0; i<theory->GetN(); i++){ g->SetPoint(i,X[i],xs[0]*Y[i]); } + + if(loud){ + cout << "End: X[0] = " << g->GetPointX(4) << " Y[0] = " << g->GetPointY(4) << endl; + cout << setprecision(3); + } + return g; } diff --git a/Projects/e793s/macro/DrawPlots.C b/Projects/e793s/macro/DrawPlots.C deleted file mode 100755 index 1d6375a6f8812147848fea1b73ce8aef7686d3ba..0000000000000000000000000000000000000000 --- a/Projects/e793s/macro/DrawPlots.C +++ /dev/null @@ -1,751 +0,0 @@ -#include "GausFit.h" -#include "KnownPeakFitter.h" -#include "DrawPlots.h" - -#include "CS2.h" -#include "ThreeBodyBreakup.h" -#include "ThreeBodyBreakup_FitPhaseSpace.h" -/* USE THIS SPACE TO TEST NEW FEATURES */ - -void thickness(){ - - std::ifstream infile("thicknessTheory4.txt"); - - // THEORY ------------------------------------- - double x, pCH, dHSS, pBG, pPer, dKD, d79D, dPer, dLH, dBel; - vector<double> vx, vpCH, vdHSS, vpBG, vpPer, vdKD, vd79D, vdPer, vdLH, vdBel; - int count = 0; - - while (infile >> x >> pCH >> dHSS >> pBG >> pPer >> dKD >> d79D >> dPer >> dLH >> dBel) - { - vx.push_back(x); - vpBG.push_back(pBG); - vdHSS.push_back(dHSS); - vpCH.push_back(pCH); - vpPer.push_back(pPer); - vdKD.push_back(dKD); - vd79D.push_back(d79D); - vdPer.push_back(dPer); - vdLH.push_back(dLH); - vdBel.push_back(dBel); - - count++; - } - // -------------------------------------------- - - // EXPERIMENT --------------------------------- - -double expDx[20]= {22.5 , -23.5 , -24.5 , -25.5 , -26.5 , -27.5 , -28.5 , -29.5 , -30.5 , -31.5 , -32.5 , -33.5 , -34.5 , -35.5 , -36.5 , -37.5 , -38.5 , -39.5 , -40.5 , -41.5 }; - -double expDy[20]={ -0.595726876922256 , -0.543213473232366 , -0.494283286886849 , -0.421774881771817 , -0.341156378590349 , -0.307099360773692 , -0.262569839264486 , -0.232682384534885 , -0.216888228577843 , -0.23470124429325 , -0.240399882846714 , -0.228134082861555 , -0.32920533438895 , -0.296543336595945 , -0.367649491313769 , -0.413065289661424 , -0.437192259660495 , -0.440938347607344 , -0.378811580496408 , -0.404394227640296 }; - - - -double expDyErr[20]={ -0.028324914039265 , -0.0218144191759532 , -0.0142504076860264 , -0.0146454365657758 , -0.0088989334482194 , -0.00824524006184739 , -0.0108064634609478 , -0.0111948065344291 , -0.00904509721171868 , -0.0119548919107791 , -0.0180227167275249 , -0.0201388245171666 , -0.0213346009360056 , -0.0193056550679402 , -0.0155440903197556 , -0.0136119544115286 , -0.0204840651640718 , -0.0248743996273666 , -0.023151640426499 , -0.0183223089693594 }; - - - - - - -double expDyErr2[20]={0.5, - 0.5, - 0.5, - 0.5, - 0.5, - 0.5, - 0.5, - 0.5, - 0.5, - 0.5, - 0.5, - 0.5, - 0.5, - 0.5, - 0.5, - 0.5, - 0.5, - 0.5, - 0.5, - 0.5}; - -double expPx[15]={31.5 , -32.5 , -33.5 , -34.5 , -35.5 , -36.5 , -37.5 , -38.5 , -39.5 , -40.5 , -41.5 , -42.5 , -43.5 , -44.5 , -45.5 }; - -double expPy[15]={ -0.927940963711002 , -0.886373091269099 , -0.997232654140559 , -0.850828825193078 , -0.975515571786442 , -0.799588217203809 , -0.816607420458171 , -0.982225026964146 , -0.888146409552698 , -0.901367241759583 , -1.07321471789101 , -1.0011298892341 , -0.966230221622026 , -1.1926071484492 , -0.865315617070875 }; - - - - - -double expPyErr[15]={ -0.0990008372934202 , -0.14013781860333 , -0.0725936416502272 , -0.066957912885687 , -0.0518874166956934 , -0.0314030147725784 , -0.0396294675991484 , -0.0474887746673471 , -0.0504518388646933 , -0.0432543357898785 , -0.0509856961378907 , -0.0376160621523655 , -0.043968910197424 , -0.0649913895880728 , -0.0576066735490418 }; - - - - - - - -double expPyErr2[15]={0.5, - 0.5, - 0.5, - 0.5, - 0.5, - 0.5, - 0.5, - 0.5, - 0.5, - 0.5, - 0.5, - 0.5, - 0.5, - 0.5, - 0.5}; - - - - - /* double expDx[16] = {22.8659168020674, - 24.4932387071222, - 25.4884605201683, - 26.4478963605459, - 27.8768790582849, - 30.0521503123866, - 31.6308395766488, - 32.4198704973062, - - 34.0083546157897, - 35.4165962236503, - 36.4835938795446, - 37.5238982330089, - 38.5397371697557, - 39.5330583015003, - 40.5055760670275, - 41.3}; - - double expDy[16] = {9.52350198819289, - 5.64694896708287, - 3.57621524475264, - 2.22306813461932, - 1.84242236351724, - 0.839564977947224, - 0.533641048642503, - 0.811298146594814, - 0.452491201918824, - 0.628258484221101, - 0.700018256426215, - 0.598634895567586, - 0.510176367468261, - 0.457345826343762, - 0.341874900915227, - 0.41491476578731}; - - double expPx[9] = {30.6251132222237, - 32.9493281027741, - 34.6378972639558, - 37.6049166106808, - 39.1281033807373, - 41.0541710577087, - 43.6797461320023, - 43.5133105051628, - 45.6589118858263}; - - double expPy[9] = {15.4053624168101, - 10.0326697910848, - 11.2010890871452, - 6.28484827873840, - 5.93048525466625, - 5.18590383783819, - 4.93601112583176, - 3.77917031974004, - 6.32306635135636}; - */ - // -------------------------------------------- - - //cout << vx.front() << " to " << vx.back() << " count " << count << endl; - - TCanvas *canvThick = new TCanvas("canvThick","canvThick",1000,1000); - canvThick->SetLogy(); - - int HSS = 10, Perey = 4, BGreen = 1; - - - TGraph* gp1 = new TGraph(vx.size(), &vx[0], &vpBG[0]); - gp1->GetXaxis()->SetLimits(10.,80.); - gp1->SetLineColor(kRed); - gp1->SetLineStyle(BGreen); - gp1->SetLineWidth(2); - gp1->SetTitle("(p,p) Bechetti-Greenlees"); - - TGraph* gp2 = new TGraph(vx.size(), &vx[0], &vpCH[0]); - gp2->GetXaxis()->SetLimits(10.,80.); - gp2->SetLineColor(kRed); - gp2->SetLineStyle(Perey); - gp2->SetLineWidth(2); - gp2->SetTitle("(p,p) Chapel-Hill"); - - TGraph* gp3 = new TGraph(vx.size(), &vx[0], &vpPer[0]); - gp3->GetXaxis()->SetLimits(10.,80.); - gp3->SetLineColor(kRed); - gp3->SetLineStyle(HSS); - gp3->SetLineWidth(2); - gp3->SetTitle("(p,p) Perey"); - - TGraph* gd1 = new TGraph(vx.size(), &vx[0], &vdHSS[0]); - gd1->GetXaxis()->SetLimits(10.,80.); - gd1->SetLineColor(kBlue); - gd1->SetLineStyle(HSS); - gd1->SetLineWidth(2); - gd1->SetTitle("(d,d) HSS"); - - TGraph* gd2 = new TGraph(vx.size(), &vx[0], &vdKD[0]); - gd2->GetXaxis()->SetLimits(10.,80.); - gd2->SetLineColor(kBlue); - gd2->SetLineStyle(1); - gd2->SetLineWidth(2); - gd2->SetTitle("(d,d) Koning-Delaroche"); - - TGraph* gd3 = new TGraph(vx.size(), &vx[0], &vd79D[0]); - gd3->GetXaxis()->SetLimits(10.,80.); - gd3->SetLineColor(kBlue); - gd3->SetLineStyle(6); - gd3->SetLineWidth(2); - gd3->SetTitle("(d,d) 79DCV"); - - TGraph* gd4 = new TGraph(vx.size(), &vx[0], &vdPer[0]); - gd4->GetXaxis()->SetLimits(10.,80.); - gd4->SetLineColor(kBlue); - gd4->SetLineStyle(Perey); - gd4->SetLineWidth(2); - gd4->SetTitle("(d,d) Perey"); - - TGraph* gd5 = new TGraph(vx.size(), &vx[0], &vdLH[0]); - gd5->GetXaxis()->SetLimits(10.,80.); - gd5->SetLineColor(kBlue); - gd5->SetLineStyle(2); - gd5->SetLineWidth(2); - gd5->SetTitle("(d,d) Lohr-Haeberli"); - - TGraph* gd6 = new TGraph(vx.size(), &vx[0], &vdBel[0]); - gd6->GetXaxis()->SetLimits(10.,80.); - gd6->SetLineColor(kBlue); - gd6->SetLineStyle(9); - gd6->SetLineWidth(2); - gd6->SetTitle("(d,d) Belote 48Ca"); - - TGraphErrors* expP = new TGraphErrors( 15, expPx, expPy, expPyErr2, expPyErr); - expP->SetTitle("(p,p) Experiment"); - //expP->SetMarkerStyle(22); - TGraphErrors* expD = new TGraphErrors(20, expDx, expDy, expDyErr2, expDyErr); - expD->SetTitle("(d,d) Experiment"); - //expD->SetMarkerStyle(20); - - TMultiGraph* mg = new TMultiGraph(); - mg->Add(gp1); - mg->Add(gp2); - mg->Add(gp3); - mg->Add(gd1); - mg->Add(gd2); - mg->Add(gd3); - mg->Add(gd4); - mg->Add(gd5); - mg->Add(gd6); - //mg->GetXaxis()->SetTitle("{#theta}_{CM}"); - //mg->GetYaxis()->SetTitle("Elastic counts [mb/sr]"); - mg->Draw("AC"); - mg->GetXaxis()->SetTitle("#theta_{CM} [deg]"); - mg->GetYaxis()->SetTitle("Ratio #sigma/#sigma_{Rutherford}"); - expP->Draw("same*"); - expD->Draw("same*"); - - canvThick->BuildLegend(); - -} - -void temptemp(){ - -chain->Draw("T_MUGAST_VAMOS>>hist(500,0,10000)","",""); - -} - -void tempRunMe(double gamma, double width){ - - string gating = "abs(T_MUGAST_VAMOS-2777)<600 && abs(AddBack_EDC-" - + to_string(gamma) - + ")<" - + to_string(width); - - TFile *File22 = new TFile("../../../Outputs/Analysis/47K_Full_05Aug_MinWithNoMG3.root","READ"); - TTree* Tree22 = (TTree*) File22->Get("PhysicsTree"); - - Tree22->Draw("Ex>>Ex22(120,-1,5)",gating.c_str(),""); - TH1F* Ex22 = (TH1F*) gDirectory->Get("Ex22"); - - //TFile *File30 = new TFile("../../../Outputs/Analysis/47K_Full_22July.root","READ"); - TFile *File30 = new TFile("../../../Outputs/Analysis/47K_Full_09Aug_retest05NoMG3.root","READ"); - TTree* Tree30 = (TTree*) File30->Get("PhysicsTree"); - - Tree30->Draw("Ex>>Ex30(120,-1,5)",gating.c_str(),""); - TH1F* Ex30 = (TH1F*) gDirectory->Get("Ex30"); - - Ex22->SetLineColor(kRed); - Ex22->Draw(); - Ex30->SetLineColor(kBlue); - Ex30->Draw("same"); - -} - -void ExThetaAnalysis(double gamma, double width, int version){ -// int version; -// bool running = 1; - -// cout << "Constructing Ex:ThetaLab..." << endl; - - - string gating = "abs(T_MUGAST_VAMOS-2777)<600 && Mugast.TelescopeNumber>0 && Mugast.TelescopeNumber<8 && abs(AddBack_EDC-" - + to_string(gamma) + ") < " + to_string(width); - - TCanvas *diagnoseTheta2 = new TCanvas("diagnoseTheta2","diagnoseTheta2",1000,1000); - chain->Draw( - "Ex:ThetaLab>>thetaHist(60,100,160,120,-1,5)", - //"abs(T_MUGAST_VAMOS-2777)<600 && Mugast.TelescopeNumber>0 && Mugast.TelescopeNumber<8", - gating.c_str(), - "colz"); - TH2F* thetaHist = (TH2F*) gDirectory->Get("thetaHist"); - - -// while(running){ -// cout << "Overlay projections (1) or candle plots (2)?" << endl; -// cin >> version; - cout << "Processing..." << endl; - if(version==1){ - thetaHist->ProjectionY("tpy1",06.,15.); - TH1F* tpy1 = (TH1F*) gDirectory->Get("tpy1"); - thetaHist->ProjectionY("tpy2",16.,25.); - TH1F* tpy2 = (TH1F*) gDirectory->Get("tpy2"); - thetaHist->ProjectionY("tpy3",26.,35.); - TH1F* tpy3 = (TH1F*) gDirectory->Get("tpy3"); - thetaHist->ProjectionY("tpy4",36.,45.); - TH1F* tpy4 = (TH1F*) gDirectory->Get("tpy4"); - thetaHist->ProjectionY("tpy5",46.,55.); - TH1F* tpy5 = (TH1F*) gDirectory->Get("tpy5"); - - tpy1->SetLineColor(kRed); - tpy2->SetLineColor(kOrange); - tpy3->SetLineColor(kGreen); - tpy4->SetLineColor(kBlue); - tpy5->SetLineColor(kViolet); - - tpy1->Rebin(2); - tpy2->Rebin(2); - tpy3->Rebin(2); - tpy4->Rebin(2); - tpy5->Rebin(2); - - tpy1->Draw(); - tpy2->Draw("same"); - tpy3->Draw("same"); - tpy4->Draw("same"); - tpy5->Draw("same"); - }else if (version==2){ - thetaHist->GetXaxis()->SetRangeUser(105.,155.); - thetaHist->RebinX(5); - thetaHist->GetXaxis()->SetRangeUser(105.,155.); - thetaHist->Draw("candlex6"); - - }//else{running=0;} -// } - -} - -void ForPoster_DiffCrossSec(){ - ifstream infile("DiffCrossSecInputfile.txt"); - vector<double> theta, p32, p32Pos, p32Neg, f72, f72Pos, f72Neg, zero; - - double a, b, c, d, e, f, g; - while(infile){ - infile >> a >> b >> c >> d >> e >> f >> g; - - theta.push_back(a); - zero.push_back(0.0); - - p32.push_back(b); - p32Pos.push_back(c); - p32Neg.push_back(d); - - f72.push_back(e); - f72Pos.push_back(f); - f72Neg.push_back(g); - } - - TGraph *graphp32 = new TGraph(theta.size(), &theta[0], &p32[0]); - TGraph *graphf72 = new TGraph(theta.size(), &theta[0], &f72[0]); - - int num = theta.size(); - - TGraphAsymmErrors *graphp32error - = new TGraphAsymmErrors(num, &theta[0], &p32[0], &zero[0], &zero[0], &p32Neg[0], &p32Pos[0]); - - TGraphAsymmErrors *graphf72error - = new TGraphAsymmErrors(num, &theta[0], &f72[0], &zero[0], &zero[0], &f72Neg[0], &f72Pos[0]); - - - graphp32->SetFillColor(kRed); - graphp32->SetFillStyle(3005); - graphf72->SetFillColor(kBlue); - graphf72->SetFillStyle(3005); - - graphp32->Draw(); - graphf72->Draw("same"); - graphp32error->Draw("same"); - graphf72error->Draw("same"); - -/* - TMultiGraph *mg = new TMultiGraph(); - mg->Add(graphp32); - mg->Add(graphf72); - mg->Add(graphp32error); - mg->Add(graphf72error); - mg->Draw(); -*/ - - -} - -/* MAIN FUNCTION */ - -void DrawPlots(){ - gStyle->SetOptStat("nemMrRi"); - LoadChainNP(); - - cout << "==========================================" << endl; - cout << "========== AVAILABLE FUNCTIONS ===========" << endl; - cout << " 2D Matrices " << endl; - cout << "\t- Draw_2DParticleGamma() "<< endl; - cout << "\t- Load_2DParticleGamma() "<< endl; - cout << "\t- Draw_2DGammaGamma() "<< endl; - cout << ""<< endl; - cout << " Ungated histograms " << endl; - cout << "\t- Draw_1DParticle() "<< endl; - cout << "\t- Load_1DParticle() "<< endl; - cout << "\t- Draw_1DParticle_MUST2() "<< endl; - cout << "\t- Draw_1DGamma() "<< endl; - cout << "\t- Draw_1DGamma_MG() "<< endl; - cout << "\t- Draw_1DGamma_MM() "<< endl; - cout << ""<< endl; - cout << " Gated histograms " << endl; - cout << "\t- GateParticle_SeeGamma(particle, width) "<< endl; - cout << "\t- GateGamma_SeeParticle(gamma, width) "<< endl; - cout << "\t- GateGamma_SeeGamma(gamma, width) "<< endl; - cout << ""<< endl; - cout << " Gated histograms w/ background selection" << endl; - cout << "\t- GateParticle_SeeGamma_WithBG(particle, width, bgrnd) "<< endl; - cout << "\t- GateGamma_SeeParticle_WithBG(gamma, width, bgrnd) "<< endl; - cout << "\t- GateGamma_SeeGamma_WithBG(gamma, width, bgrnd) "<< endl; - cout << ""<< endl; - cout << " Specific functions" << endl; - cout << "\t- CompareExsAt4MeV() "<< endl; - cout << "\t- CompareSimExp() "<< endl; - cout << "\t- MugastMisalignment() "<< endl; - cout << "\t- ExPhiLab() "<< endl; - cout << "\t- ExThetaLab() "<< endl; - cout << "\t- ELabThetaLab() "<< endl; - cout << "\t- MM5_ELabThetaLab() "<< endl; - cout << "\t- MM5_ExThetaLab() "<< endl; - cout << ""<< endl; - cout << " Analysis functions" << endl; - cout << "\t- FitKnownPeaks(histogram) "<< endl; - cout << "\t- AGATA_efficiency(double Energy_kev) "<< endl; - cout << "\t- CorrectForAGATAEffic(TH1F* hist) "<< endl; - cout << "\t- CS(stateEnergy, stateSpin, orbital_l, orbital_j, nodes) "<< endl; - cout << "\t---- 0.143, p3/2 = CS(0.143, 2, 1, 1.5) "<< endl; - cout << "\t---- 0.279, p3/2 = CS(0.279, 2, 1, 1.5) "<< endl; - cout << "\t---- 0.728, f7/2 = CS(0.728, 3, 3, 3.5) "<< endl; - cout << "\t---- 0.968, p1/2 = CS(0.968, 0, 1, 0.5) "<< endl; - cout << "\t---- 1.410, p3/2 = CS(1.410, 2, 1, 1.5) "<< endl; - cout << "\t---- 1.981, p3/2 = CS(1.981, 2, 1, 1.5) "<< endl; - cout << "\t---- 2.410, p3/2 = CS(2.410, 2, 1, 1.5) "<< endl; - cout << "\t---- 3.2 , f7/2 = CS(3.2 , 3, 3, 3.5) "<< endl; - cout << "\t---- 3.6 , f5/2 = CS(3.6 , 3, 3, 2.5) "<< endl; - cout << "\t---- 3.8 , f5/2 = CS(3.8 , 3, 3, 2.5) "<< endl; - cout << "\t---- 4.1 , f5/2 = CS(4.1 , 3, 3, 2.5) "<< endl; - cout << "\t---- 4.4 , f5/2 = CS(4.4 , 3, 3, 2.5) "<< endl; - cout << ""<< endl; - cout << "==========================================" << endl; - - -/* ORIGINAL - DO NOT EDIT - TCanvas *cG = new TCanvas("cG","cG",1000,1000); - chain->Draw("Ex>>hcG(200,-3,7)",""); - chain->Draw("Ex>>hcG2(200,-3,7)","abs(T_MUGAST_VAMOS-2777)<600","same"); - TH1F* hcG = (TH1F*) gDirectory->Get("hcG"); - hcG->GetXaxis()->SetTitle("E_{x} [MeV]"); - hcG->GetYaxis()->SetTitle("Counts / (50 keV)"); - hcG->SetLineColor(kBlack); - TH1F* hcG2 = (TH1F*) gDirectory->Get("hcG2"); - hcG2->SetLineColor(kRed); -*/ - - /* ORIGINAL 4-PLOT KINEMATIC SCREEN */ -/* - TCanvas *c0 = new TCanvas("c0", "Kinematics", 1000, 1000); - c0->Divide(2,2); - c0->cd(1); - gPad->SetLogz(); - chain->Draw("ELab:ThetaLab>>hKine(200,0,180,600,0,12)","abs(T_MUGAST_VAMOS-2777)<600","col"); - TH2F* hKine = (TH2F*) gDirectory->Get("hKine"); - hKine->GetXaxis()->SetTitle("#theta_{lab} [deg]"); - hKine->GetYaxis()->SetTitle("E_{lab} [MeV]"); - plot_kine(Kdp, 0, kBlack, 2, 9); - plot_kine(Kdp, 2, kRed, 2, 9); - plot_kine(Kdp, 4, kBlue, 2, 9); - plot_kine(Kdd, 0, kGreen+2, 2, 9); - plot_kine(Kpp, 0, kYellow, 2, 9); - plot_kine(Kdt, 0, kMagenta, 2, 9); - plot_kine(K12C12C, 4, kCyan, 2, 9); - plot_kine(Tidp, 4, 42, 2, 9); - plot_kine(Tidt, 4, 42, 2, 9); - plot_kine(Tidd, 4, 42, 2, 9); - plot_kine(Ti12C12C, 4, 42, 2, 9); - - c0->cd(2); - chain->Draw("Ex>>hEx(300,-3,7)","abs(T_MUGAST_VAMOS-2777)<600"); - TH1F* hEx = (TH1F*) gDirectory->Get("hEx"); - hEx->GetXaxis()->SetTitle("E_{x} [MeV]"); - hEx->GetYaxis()->SetTitle("Counts / (100 keV)"); - hEx->SetLineColor(kBlack); - chain->Draw("Ex>>hEx_gateNoG(300,-3,7)","abs(T_MUGAST_VAMOS-2777)<600 && AddBack_EDC@.size()==0","same"); - chain->Draw("Ex>>hEx_gate(300,-3,7)","abs(T_MUGAST_VAMOS-2777)<600 && abs(AddBack_EDC-0.143)< 0.01","same"); - TH1F* hEx_gate = (TH1F*) gDirectory->Get("hEx_gate"); - hEx_gate->SetLineColor(kRed); - auto AGATA_eff = new TF1("AGATA_eff","TMath::Exp([0]+[1]*TMath::Log(x)+[2]*pow(TMath::Log(x),2.0)+[3]*pow(TMath::Log(x),3.0)+[4]*pow(TMath::Log(x),4.0))",100,5000); - AGATA_eff->SetParameter(0,-7.84071e+00); - AGATA_eff->SetParameter(1, 6.44921e+00); - AGATA_eff->SetParameter(2, -1.42899e+00); - AGATA_eff->SetParameter(3, 1.37921e-01); - AGATA_eff->SetParameter(4, -5.23947e-03); - - //TH1F* hEx_gate_scaled = (TH1F*) hEx_gate->Clone("hEx_gate_scaled"); - hEx_gate->Scale(1./(AGATA_eff->Eval(143)*0.01)); - hEx_gate->Draw("histsame"); - c0->Update(); - double ymax = gPad->GetUymax(); - plot_state(0, ymax, kBlack, 2, 9); - plot_state(2, ymax, kRed, 2, 9); - plot_state(3.8, ymax, kBlue, 2, 9); - plot_state(4.644, ymax, kGreen+2, 2, 1); - TLatex latex; - latex.SetTextAlign(13); - latex.SetTextSize(0.035); - latex.SetTextAngle(90); - latex.SetTextColor(kGreen+2); - latex.DrawLatex(4.8,0.6*ymax,"S_{n} = 4.64 MeV"); - - TLegend *legend = new TLegend(0.7,0.7,0.9,0.9); - - c0->cd(3); - chain->Draw("AddBack_EDC:Ex>>hEgEx(300,-1,7,5000,0,5)","abs(T_MUGAST_VAMOS-2777)<600","col"); -*/ - -/* - chain->Draw("AddBack_EDC:Ex>>hEgEx(150,0,6,1000,0,5)","abs(T_MUGAST_VAMOS-2777)<600 && Mugast.TelescopeNumber==5","col"); - TH2F* hEgEx = (TH2F*) gDirectory->Get("hEgEx"); - hEgEx->SetTitle("MUGAST#5 only"); - hEgEx->GetXaxis()->SetTitle("E_{x} [MeV]"); - hEgEx->GetYaxis()->SetTitle("E_{#gamma} [MeV]"); - TLine *line = new TLine(0,0,6,6); - line->SetLineWidth(2); - line->SetLineColor(kRed); - line->Draw(); -*/ - -/* - c0->cd(4); - chain->Draw("AddBack_EDC>>hEg(4000,0,4)","abs(T_MUGAST_VAMOS-2777)<600"); - TH1F* hEg = (TH1F*) gDirectory->Get("hEg"); - hEg->GetXaxis()->SetTitle("E_{#gamma} [MeV]"); - hEg->GetYaxis()->SetTitle("Counts / (1 keV)"); - hEg->SetLineColor(kBlack); - c0->Update(); - ymax = gPad->GetUymax(); - //plot_state(0.143, ymax, kMagenta, 2, 9); - //plot_state(0.279, ymax, kCyan, 2, 9); - //plot_state(1.863, ymax, kOrange, 2, 9); -*/ - -/* - TCanvas *gammaspec = new TCanvas("gammaSpec", "gammaSpec", 1000, 1000); - chain->Draw("AddBack_EDC>>hEg(4000,0,4)","abs(T_MUGAST_VAMOS-2777)<600"); - TH1F* hEg = (TH1F*) gDirectory->Get("hEg"); - hEg->GetXaxis()->SetTitle("E_{#gamma} [MeV]"); - hEg->GetYaxis()->SetTitle("Counts / (1 keV)"); - hEg->SetLineColor(kBlack); - //c0->Update(); - //ymax = gPad->GetUymax(); - //plot_state(0.143, ymax, kMagenta, 2, 9); - //plot_state(0.279, ymax, kCyan, 2, 9); - //plot_state(1.863, ymax, kOrange, 2, 9); -*/ - -/* - TCanvas *c1 = new TCanvas("c1", "Egamma, gated on Ex", 1000, 1000); - c1->Divide(2,2); - c1->cd(1); - chain->Draw("AddBack_EDC>>hEg_0p143(800,0,4)","abs(T_MUGAST_VAMOS-2777)<600 && abs(Ex-0.143)<0.1"); - TH1F* hEg_0p143 = (TH1F*) gDirectory->Get("hEg_0p143"); - hEg_0p143->GetXaxis()->SetTitle("E_{#gamma} [MeV]"); - hEg_0p143->GetYaxis()->SetTitle("Counts / (5 keV)"); - hEg_0p143->SetLineColor(kBlack); - - c1->cd(2); - chain->Draw("AddBack_EDC>>hEg_1p275(800,0,4)","abs(T_MUGAST_VAMOS-2777)<600 && abs(Ex-1.275)<0.1"); - TH1F* hEg_1p275 = (TH1F*) gDirectory->Get("hEg_1p275"); - hEg_1p275->GetXaxis()->SetTitle("E_{#gamma} [MeV]"); - hEg_1p275->GetYaxis()->SetTitle("Counts / (5 keV)"); - hEg_1p275->SetLineColor(kBlack); - - c1->cd(3); - chain->Draw("AddBack_EDC>>hEg_1p822(800,0,4)","abs(T_MUGAST_VAMOS-2777)<600 && abs(Ex-1.822)<0.1"); - TH1F* hEg_1p822 = (TH1F*) gDirectory->Get("hEg_1p822"); - hEg_1p822->GetXaxis()->SetTitle("E_{#gamma} [MeV]"); - hEg_1p822->GetYaxis()->SetTitle("Counts / (5 keV)"); - hEg_1p822->SetLineColor(kBlack); - - c1->cd(4); - chain->Draw("AddBack_EDC>>hEg_3p609(800,0,4)","abs(T_MUGAST_VAMOS-2777)<600 && abs(Ex-3.609)<0.1"); - TH1F* hEg_3p609 = (TH1F*) gDirectory->Get("hEg_3p609"); - hEg_3p609->GetXaxis()->SetTitle("E_{#gamma} [MeV]"); - hEg_3p609->GetYaxis()->SetTitle("Counts / (5 keV)"); - hEg_3p609->SetLineColor(kBlack); - -*/ - -/* - auto gr = K.GetKinematicLine3(); - gr->SetLineColor(kAzure+7); - gr->SetLineWidth(3); - gr->Draw("ac"); - K.SetExcitationHeavy(4); - gr = K.GetKinematicLine3(); - gr->SetLineColor(kAzure+7); - gr->SetLineWidth(2); - gr->SetLineStyle(1); - gr->Draw("c"); - - AddTiStates(0); - AddTiStates(0.969); - AddTiStates(2.2292); - AddTiStates(2.419); - AddTiStates(3.223); - AddTiStates(3.332); - AddTiStates(3.622); - AddTiStates(4.388); - AddTiStates(4.458); - AddTiStates(4.719); - AddTiStates(4.852); - AddTiStates(5.151); -*/ - -} diff --git a/Projects/e793s/macro/DrawPlots.h b/Projects/e793s/macro/DrawPlots.h index 5f63730f28020b9a870c088ed7f32eb86b617f64..8106fb61de1bf7c081152caa123552e5a6a6daf0 100755 --- a/Projects/e793s/macro/DrawPlots.h +++ b/Projects/e793s/macro/DrawPlots.h @@ -8,6 +8,9 @@ using namespace std; TChain* chain=NULL ; char cond[1000]; +NPL::Reaction Cadp("47Ca(d,p)48Ca@355"); +NPL::Reaction Scdp("47Sc(d,p)48Sc@355"); + NPL::Reaction Kdp("47K(d,p)48K@355"); NPL::Reaction Kdt("47K(d,t)46K@355"); NPL::Reaction Kdd("47K(d,d)47K@355"); @@ -19,6 +22,11 @@ NPL::Reaction Tidd("47Ti(d,d)47Ti@355"); NPL::Reaction Ti12C12C("47Ti(12C,12C)47Ti@355"); void KnownLines_Ex(bool isVertical, double rangemin, double rangemax, Style_t lType, Color_t lColour); +void AddGammaLinesMG(TH1F* hist, double particle, double ymax); +void AddPlacedGammasMG(TH1F* hist, double ymax); + +double tCentre; +double tRange; /* BASE FUNCTIONS */ TF1* f_efficAGATA(){ @@ -37,15 +45,26 @@ TChain* Chain(std::string TreeName, std::vector<std::string>& file, bool EventLi return chain; } -void LoadChainNP(){ +void LoadChain47Kdp(){ vector<string> files; - files.push_back("../../../Outputs/Analysis/47Kdp_08Nov_PartI.root"); - files.push_back("../../../Outputs/Analysis/47Kdp_08Nov_PartII.root"); + //files.push_back("../../../Outputs/Analysis/47Kdp_08Nov_PartI.root"); + //files.push_back("../../../Outputs/Analysis/47Kdp_08Nov_PartII.root"); + + //files.push_back("../../../Outputs/Analysis/47Kdp_08Apr_PartI.root"); + //files.push_back("../../../Outputs/Analysis/47Kdp_08Apr_PartII.root"); -// files.push_back("../../../Outputs/Analysis/47Kdp_17Feb_AGATA_RotateBYpi.root"); + /* With thresholds, strip mathcing, and bad strips out */ + files.push_back("../../../Outputs/Analysis/47Kdp_11Apr22_PartI.root"); + files.push_back("../../../Outputs/Analysis/47Kdp_11Apr22_PartII.root"); -// files.push_back("../../../Outputs/Analysis/47Kdp_19Feb_AGATA_RotateBXYZ.root"); + chain = Chain("PhysicsTree",files,true); +} + +void LoadChain47Kdt(){ + vector<string> files; + files.push_back("../../../Outputs/Analysis/47Kdt_13May22_PartI.root"); + files.push_back("../../../Outputs/Analysis/47Kdt_13May22_PartII.root"); chain = Chain("PhysicsTree",files,true); } @@ -111,12 +130,15 @@ void DrawParticleStates(TCanvas* canvas){ TLine *l3800 = new TLine(3.792, 0.0, 3.792, max); l3800->SetLineStyle(kDotted); l3800->Draw("same"); + TLine *l3870 = new TLine(3.876, 0.0, 3.876, max); + l3870->SetLineStyle(kDotted); + l3870->Draw("same"); TLine *l4100 = new TLine(4.1, 0.0, 4.1, max); l4100->SetLineStyle(kDotted); l4100->Draw("same"); - TLine *l4400 = new TLine(4.4, 0.0, 4.4, max); - l4400->SetLineStyle(kDotted); - l4400->Draw("same"); + TLine *l4510 = new TLine(4.51, 0.0, 4.51, max); + l4510->SetLineStyle(kDotted); + l4510->Draw("same"); } void plot_kine(NPL::Reaction r, double Ex,Color_t c,int w, int s){ @@ -147,59 +169,76 @@ void AddTiStates(double E){ /* DRAWING FUNCTIONS */ +string timegate; /* defined by choice of dp or dt */ +string det_gate; /* defined by choice of dp or dt */ +//string mg_gate = "Mugast.TelescopeNumber>0 && Mugast.TelescopeNumber<8"; +//string mm_gate = "MUST2.TelescopeNumber>0"; +//string mm_lt5_gate = "MUST2.TelescopeNumber<5"; +//string mm_eq5_gate = "MUST2.TelescopeNumber==5"; +string exclBmDcy = "abs(AGATA_GammaE-2.013)>0.004 && abs(AGATA_GammaE-0.511)>0.003 && abs(AGATA_GammaE-0.564)>0.004 && abs(AGATA_GammaE-0.586)>0.003"; + void Draw_1DGamma(){ + string gate = timegate; TCanvas *cEg = new TCanvas("cEg","cEg",1000,1000); gStyle->SetOptStat(0); - chain->Draw("AddBack_EDC>>Eg(5000,0,5)","abs(T_MUGAST_VAMOS-2777)<600"); + chain->Draw("AddBack_EDC>>Eg(5000,0,5)",gate.c_str(),""); TH1F* Eg = (TH1F*) gDirectory->Get("Eg"); Eg->GetXaxis()->SetTitle("E_{#gamma} [MeV]"); Eg->GetYaxis()->SetTitle("Counts / 0.001 MeV"); } void Load_1DGamma(){ - TH1F *hEg = new TH1F("hEg","Loaded 1D Gamma Spectrum",200,-1,9); + TH1F *hEg = new TH1F("hEg","Loaded 1D Gamma Spectrum",600,-15,15); TFile *file = new TFile("LoadHistograms/Load_1DGamma.root","READ"); hEg = (TH1F*)file->Get("Eg"); hEg->Draw(); } -void Draw_1DGamma_MG(){ +void Draw_1DGamma_DetGate(){ + string gate = timegate + + " && " + det_gate + + " && " + exclBmDcy; + TCanvas *cEg = new TCanvas("cEg","cEg",1000,1000); gStyle->SetOptStat(0); - chain->Draw("AddBack_EDC>>Eg(5000,0,5)","abs(T_MUGAST_VAMOS-2777)<600 && Mugast.TelescopeNumber>0 && Mugast.TelescopeNumber<8"); + chain->Draw("AddBack_EDC>>Eg(5000,0,5)",gate.c_str(),""); TH1F* Eg = (TH1F*) gDirectory->Get("Eg"); Eg->GetXaxis()->SetTitle("E_{#gamma} [MeV]"); Eg->GetYaxis()->SetTitle("Counts / 0.001 MeV"); } void Load_1DGamma_MG(){ - TH1F *hEgMG = new TH1F("hEg","Loaded 1D Gamma Spectrum, MG gated",200,-1,9); + TCanvas *cEg = new TCanvas("cEg","cEg",1000,1000); + TH1F *hEgMG = new TH1F("hEg","Loaded 1D Gamma Spectrum, MG gated",600,-15,15); TFile *file = new TFile("LoadHistograms/Load_1DGamma_MG.root","READ"); hEgMG = (TH1F*)file->Get("Eg"); hEgMG->Draw(); } -void Draw_1DGamma_MM(){ - TCanvas *cEg = new TCanvas("cEg","cEg",1000,1000); - gStyle->SetOptStat(0); - chain->Draw("AddBack_EDC>>Eg(5000,0,5)","abs(T_MUGAST_VAMOS-2777)<600 && MUST2.TelescopeNumber>0 && MUST2.TelescopeNumber<5"); - TH1F* Eg = (TH1F*) gDirectory->Get("Eg"); - Eg->GetXaxis()->SetTitle("E_{#gamma} [MeV]"); - Eg->GetYaxis()->SetTitle("Counts / 0.001 MeV"); -} - void Load_1DParticle(){ - TH1F *hEx = new TH1F("hEx","Loaded 1D Particle Spectrum",200,-1,9); + TCanvas *cEg = new TCanvas("cEg","cEg",1000,1000); + TH1F *hEx = new TH1F("hEx","Loaded 1D Particle Spectrum",600,-15,15); TFile *file = new TFile("LoadHistograms/Load_1DParticle.root","READ"); hEx = (TH1F*)file->Get("Ep"); hEx->Draw(); } +void Load_1DParticle_SubPhaseSpace(){ + TCanvas *cEg = new TCanvas("cEg","cEg",1000,1000); + TH1F *hSub = new TH1F("hSubtracted", + "Loaded 1D Particle Spectrum, Phase Space & Flat BG Subtracted (10May)",600,-15,15); + TFile *file = new TFile("LoadHistograms/Load_1DParticle_SubPhaseSpace.root","READ"); + hSub = (TH1F*)file->Get("ExSubPSpace"); + hSub->Draw(); +} + void Draw_1DParticle(){ + string gate = timegate + + " && " + det_gate + + " && Ex@.size()==1"; + TCanvas *cEx = new TCanvas("cEx","cEx",1000,1000); - chain->Draw("Ex>>Ep(200,-1,9)", - "abs(T_MUGAST_VAMOS-2777)<600 && Mugast.TelescopeNumber>0 && Mugast.TelescopeNumber<8", - ""); + chain->Draw("Ex>>Ep(600,-15,15)", gate.c_str(),""); TH1F* Ep = (TH1F*) gDirectory->Get("Ep"); // Ep->SetTitle("Ex"); Ep->GetXaxis()->SetTitle("Ex [MeV]"); @@ -208,29 +247,21 @@ void Draw_1DParticle(){ DrawParticleStates(cEx); } -void Draw_1DParticleMUST2(){ - TCanvas *cEx = new TCanvas("cEx","cEx",1000,1000); - chain->Draw("Ex>>Ep(200,-1,9)", - "abs(T_MUGAST_VAMOS-2777)<600 && MUST2.TelescopeNumber>0 && MUST2.TelescopeNumber<4", - ""); - TH1F* Ep = (TH1F*) gDirectory->Get("Ep"); -// Ep->SetTitle("Ex"); - Ep->GetXaxis()->SetTitle("Ex [MeV]"); - Ep->GetYaxis()->SetTitle("Counts / 0.05 MeV"); -} - void Load_2DParticleGamma(){ - TH2F *hExEg = new TH2F("hExEg","Loaded 2D Particle-Gamma",200,-1,9,2500,0,5); + TCanvas *cExEg = new TCanvas("cExEg","cExEg",1000,1000); + TH2F *hExEg = new TH2F("hExEg","Loaded 2D Particle-Gamma",600,-15,15,2500,0,5); TFile *file = new TFile("LoadHistograms/Load_2DParticleGamma.root","READ"); hExEg = (TH2F*)file->Get("ExEg"); hExEg->Draw("colz"); } void Draw_2DParticleGamma(){ + string gate = timegate + + " && " + det_gate + + " && Ex@.size()==1"; + TCanvas *cExEg = new TCanvas("cExEg","cExEg",1000,1000); - chain->Draw("AddBack_EDC:Ex>>ExEg(200,-1,9,2500,0,5)", - "abs(T_MUGAST_VAMOS-2777)<600 && Mugast.TelescopeNumber>0 && Mugast.TelescopeNumber<8", - "colz"); + chain->Draw("AddBack_EDC:Ex>>ExEg(600,-15,15,2500,0,5)", gate.c_str(), "colz"); TH1F* ExEg = (TH1F*) gDirectory->Get("ExEg"); ExEg->SetTitle("Ex-Egamma"); ExEg->GetXaxis()->SetTitle("Ex [MeV]"); @@ -241,18 +272,19 @@ void Draw_2DParticleGamma(){ } void Load_2DGammaGamma(){ - TH2F *hEgEg = new TH2F("hEgEg","Loaded 2D Gamma-Gamma",200,-1,9,2500,0,5); + TCanvas *cEgEg = new TCanvas("cEgEg","cEgEg",1000,1000); + TH2F *hEgEg = new TH2F("hEgEg","Loaded 2D Gamma-Gamma",600,-15,15,2500,0,5); TFile *file = new TFile("LoadHistograms/Load_2DGammaGamma.root","READ"); hEgEg = (TH2F*)file->Get("gg"); hEgEg->SetName("hEgEg"); hEgEg->Draw("colz"); } -void Draw_2DGammaGamma(){ +void Draw_2DGammaGamma_ExcludeBeam(){ TCanvas *cEgEg = new TCanvas("cEgEg","cEgEg",1000,1000); - chain->Draw("AddBack_EDC:AddBack_EDC2>>EgEg(999,0.005,5,999,0.005,5)","","colz"); + chain->Draw("AddBack_EDC:AddBack_EDC2>>EgEg(999,0.005,5,999,0.005,5)","abs(AGATA_GammaE-2.013)>0.004 && abs(AGATA_GammaE-0.511)>0.003 && abs(AGATA_GammaE-0.564)>0.004 && abs(AGATA_GammaE-0.586)>0.003","colz"); TH1F* EgEg = (TH1F*) gDirectory->Get("EgEg"); - chain->Draw("AddBack_EDC2:AddBack_EDC>>EgEg2(999,0.005,5,999,0.005,5)","","colz"); + chain->Draw("AddBack_EDC2:AddBack_EDC>>EgEg2(999,0.005,5,999,0.005,5)","abs(AGATA_GammaE-2.013)>0.004 && abs(AGATA_GammaE-0.511)>0.003 && abs(AGATA_GammaE-0.564)>0.004 && abs(AGATA_GammaE-0.586)>0.003","colz"); TH1F* EgEg2 = (TH1F*) gDirectory->Get("EgEg2"); EgEg->Add(EgEg2,1); EgEg->SetTitle("Egamma-Egamma"); @@ -281,10 +313,11 @@ void gg(){ */ void Draw_2DGammaGamma_TimeGated(){ + string gate = timegate; TCanvas *cEgEg = new TCanvas("cEgEg","cEgEg",1000,1000); - chain->Draw("AddBack_EDC:AddBack_EDC2>>EgEg(999,0.005,5,999,0.005,5)","abs(T_MUGAST_VAMOS-2777)<600","colz"); + chain->Draw("AddBack_EDC:AddBack_EDC2>>EgEg(999,0.005,5,999,0.005,5)",gate.c_str(),"colz"); TH1F* EgEg = (TH1F*) gDirectory->Get("EgEg"); - chain->Draw("AddBack_EDC2:AddBack_EDC>>EgEg2(999,0.005,5,999,0.005,5)","abs(T_MUGAST_VAMOS-2777)<600","colz"); + chain->Draw("AddBack_EDC2:AddBack_EDC>>EgEg2(999,0.005,5,999,0.005,5)",gate.c_str(),"colz"); TH1F* EgEg2 = (TH1F*) gDirectory->Get("EgEg2"); EgEg->Add(EgEg2,1); EgEg->SetTitle("Egamma-Egamma"); @@ -298,23 +331,14 @@ void Draw_2DGammaGamma_TimeGated(){ } void GateGamma_SeeParticle(double gamma, double width, double binsize){ - string gating = "abs(T_MUGAST_VAMOS-2777)<600 && Mugast.TelescopeNumber>0 && Mugast.TelescopeNumber<8 && abs(AddBack_EDC-" - //string gating = "abs(T_MUGAST_VAMOS-2777)<600 && Mugast.TelescopeNumber!=3 && abs(AddBack_EDC-" + string gating = timegate + "&&" + det_gate + " && Ex@.size()==1 && abs(AddBack_EDC-" + to_string(gamma) + ")<" + to_string(width); -/* -cout << " NO MG3 IN THIS ONE!!!!!!!!!!!!!!!!!!!!!!!!!" << endl; -cout << " NO MG3 IN THIS ONE!!!!!!!!!!!!!!!!!!!!!!!!!" << endl; -cout << " NO MG3 IN THIS ONE!!!!!!!!!!!!!!!!!!!!!!!!!" << endl; -cout << " NO MG3 IN THIS ONE!!!!!!!!!!!!!!!!!!!!!!!!!" << endl; -cout << " NO MG3 IN THIS ONE!!!!!!!!!!!!!!!!!!!!!!!!!" << endl; -cout << " NO MG3 IN THIS ONE!!!!!!!!!!!!!!!!!!!!!!!!!" << endl; -*/ string title = to_string(gamma-width)+" < Eg < "+to_string(gamma+width); string ytitle = "Counts / " + to_string(binsize) + " MeV"; - string draw = "Ex>>ExGate(" + to_string(10.0/binsize) + ",-1,9)"; + string draw = "Ex>>ExGate(" + to_string(30.0/binsize) + ",-15,15)"; TCanvas *cEx_Gate = new TCanvas("cEx_Gate","cEx_Gate",1000,1000); //chain->Draw("Ex>>ExGate(60,-1,5)",gating.c_str(),"colz"); @@ -328,11 +352,11 @@ cout << " NO MG3 IN THIS ONE!!!!!!!!!!!!!!!!!!!!!!!!!" << endl; } void GateGamma_SeeParticle_WithBG(double gamma, double width, double bg){ - string gating = "abs(T_MUGAST_VAMOS-2777)<600 && Mugast.TelescopeNumber>0 && Mugast.TelescopeNumber<8 && abs(AddBack_EDC-" + string gating = timegate + "&&" + det_gate + " && Ex@.size()==1 && abs(AddBack_EDC-" + to_string(gamma) + ")<" + to_string(width); - string bggate = "abs(T_MUGAST_VAMOS-2777)<600 && Mugast.TelescopeNumber>0 && Mugast.TelescopeNumber<8 && abs(AddBack_EDC-" + string bggate = timegate + "&&" + det_gate + " && Ex@.size()==1 && abs(AddBack_EDC-" + to_string(bg) + ")<" + to_string(width); @@ -341,7 +365,7 @@ void GateGamma_SeeParticle_WithBG(double gamma, double width, double bg){ + " BG: "+to_string(bg-width)+" to "+to_string(bg+width)+"."; TCanvas *cEx_Gate = new TCanvas("cEx_Gate","cEx_Gate",1000,1000); - chain->Draw("Ex>>ExGate(100,-1,9)",gating.c_str(),""); + chain->Draw("Ex>>ExGate(600,-15,15)",gating.c_str(),""); //chain->Draw("Ex>>ExGate(120,-1,5)",gating.c_str(),""); TH1F* ExGate = (TH1F*) gDirectory->Get("ExGate"); ExGate->GetXaxis()->SetTitle("Ex [MeV]"); @@ -352,7 +376,7 @@ void GateGamma_SeeParticle_WithBG(double gamma, double width, double bg){ ExGate->SetFillStyle(3154); ExGate->SetTitle(title.c_str()); - chain->Draw("Ex>>ExBG(100,-1,9)",bggate.c_str(),"same"); + chain->Draw("Ex>>ExBG(600,-15,15)",bggate.c_str(),"same"); //chain->Draw("Ex>>ExBG(120,-1,5)",bggate.c_str(),"same"); TH1F* ExBG = (TH1F*) gDirectory->Get("ExBG"); ExBG->SetLineColor(kRed); @@ -363,11 +387,11 @@ void GateGamma_SeeParticle_WithBG(double gamma, double width, double bg){ } void GateGamma_SeeParticle_WithBG(double gamma, double width, double bg, double widthbg){ - string gating = "abs(T_MUGAST_VAMOS-2777)<600 && Mugast.TelescopeNumber>0 && Mugast.TelescopeNumber<8 && abs(AddBack_EDC-" + string gating = timegate + "&&" + det_gate + " && Ex@.size()==1 && abs(AddBack_EDC-" + to_string(gamma) + ")<" + to_string(width); - string bggate = "abs(T_MUGAST_VAMOS-2777)<600 && Mugast.TelescopeNumber>0 && Mugast.TelescopeNumber<8 && abs(AddBack_EDC-" + string bggate = timegate + "&&" + det_gate + " && Ex@.size()==1 && abs(AddBack_EDC-" + to_string(bg) + ")<" + to_string(widthbg); @@ -378,7 +402,7 @@ void GateGamma_SeeParticle_WithBG(double gamma, double width, double bg, double + " BG: "+to_string(bg-width)+" to "+to_string(bg+width)+"."; TCanvas *cEx_Gate = new TCanvas("cEx_Gate","cEx_Gate",1000,1000); - chain->Draw("Ex>>ExGate(100,-1,9)",gating.c_str(),""); + chain->Draw("Ex>>ExGate(600,-15,15)",gating.c_str(),""); //chain->Draw("Ex>>ExGate(120,-1,5)",gating.c_str(),""); TH1F* ExGate = (TH1F*) gDirectory->Get("ExGate"); ExGate->GetXaxis()->SetTitle("Ex [MeV]"); @@ -389,7 +413,7 @@ void GateGamma_SeeParticle_WithBG(double gamma, double width, double bg, double ExGate->SetFillStyle(3154); ExGate->SetTitle(title.c_str()); - chain->Draw("Ex>>ExBG(100,-1,9)",bggate.c_str(),"same"); + chain->Draw("Ex>>ExBG(600,-15,15)",bggate.c_str(),"same"); //chain->Draw("Ex>>ExBG(120,-1,5)",bggate.c_str(),"same"); TH1F* ExBG = (TH1F*) gDirectory->Get("ExBG"); ExBG->Scale(ratio); @@ -401,10 +425,12 @@ void GateGamma_SeeParticle_WithBG(double gamma, double width, double bg, double DrawParticleStates(cEx_Gate); } -void GateParticle_SeeGamma(double particle, double width){ + + +void GateParticle_SeeGamma(double particle, double width){ gStyle->SetOptStat("nemMrRi"); - string gating = "abs(T_MUGAST_VAMOS-2777)<600 && Mugast.TelescopeNumber<8 && Mugast.TelescopeNumber>0 && abs(Ex-" + string gating = timegate + "&&" + det_gate + " && Ex@.size()==1 && abs(Ex-" + to_string(particle) + ")<" + to_string(width); @@ -423,39 +449,27 @@ void GateParticle_SeeGamma(double particle, double width){ cEg_Gate->Update(); TLine *limit = new TLine(particle, 0.0, particle, cEg_Gate->GetUymax()); limit->SetLineColor(kRed); - TLine *sub0143 = new TLine(particle-0.143, 0.0, particle-0.143, cEg_Gate->GetUymax()); - sub0143->SetLineColor(kBlack); sub0143->SetLineStyle(kDotted); - TLine *sub0279 = new TLine(particle-0.279, 0.0, particle-0.279, cEg_Gate->GetUymax()); - sub0279->SetLineColor(kBlack); sub0279->SetLineStyle(kDotted); - TLine *sub0728 = new TLine(particle-0.728, 0.0, particle-0.728, cEg_Gate->GetUymax()); - sub0728->SetLineColor(kBlack); sub0728->SetLineStyle(kDotted); - - TLine *g0143 = new TLine(0.143, 0.0, 0.143, cEg_Gate->GetUymax()); - g0143->SetLineColor(kBlack); g0143->SetLineStyle(kDotted); - TLine *g0279 = new TLine(0.279, 0.0, 0.279, cEg_Gate->GetUymax()); - g0279->SetLineColor(kBlack); g0279->SetLineStyle(kDotted); - TLine *g0449 = new TLine(0.449, 0.0, 0.449, cEg_Gate->GetUymax()); - g0449->SetLineColor(kBlack); g0449->SetLineStyle(kDotted); EgGate->Draw(); limit->Draw(); - sub0143->Draw(); - sub0279->Draw(); - sub0728->Draw(); + AddGammaLinesMG(EgGate, particle, cEg_Gate->GetUymax()); + } -void GateParticle_SeeGamma_WithBG(double particle, double width, double bg){ - string gating = "abs(T_MUGAST_VAMOS-2777)<600 && abs(Ex-" +void GateParticle_SeeGamma_WithBG(double particle, double width, double bg, double width2){ + string gating = timegate + "&&" + det_gate + " && Ex@.size()==1 && abs(Ex-" + to_string(particle) + ")<" + to_string(width); - string bggate = "abs(T_MUGAST_VAMOS-2777)<600 && abs(Ex-" + string bggate = timegate + "&&" + det_gate + " && Ex@.size()==1 && abs(Ex-" + to_string(bg) + ")<" - + to_string(width); + + to_string(width2); + + double ratio = width/width2; string title = "Gate: "+to_string(particle-width)+" to "+to_string(particle+width)+"." - + " BG: "+to_string(bg-width)+" to "+to_string(bg+width)+"."; + + " BG: "+to_string(bg-width2)+" to "+to_string(bg+width2)+"."; TCanvas *cEg_Gate = new TCanvas("cEg_Gate","cEg_Gate",1000,1000); chain->Draw("AddBack_EDC>>EgGate(1000,0,10)",gating.c_str(),""); @@ -471,156 +485,148 @@ void GateParticle_SeeGamma_WithBG(double particle, double width, double bg){ chain->Draw("AddBack_EDC>>EgBG(1000,0,10)",bggate.c_str(),"same"); TH1F* EgBG = (TH1F*) gDirectory->Get("EgBG"); + EgBG->Scale(ratio); EgBG->SetTitle(title.c_str()); EgBG->SetLineColor(kRed); EgBG->SetFillColor(kRed); EgBG->SetFillStyle(3345); } - -void GateGamma_SeeGamma(double gamma, double width){ - string gating = "abs(AddBack_EDC2-" + +/* +void GateGamma_SeeGamma_ExcludeBeamDecay(double gamma, double width){ + string gating + = "abs(AGATA_GammaE-2.013)>0.004 && abs(AGATA_GammaE-0.511)>0.003 && abs(AGATA_GammaE-0.564)>0.004 && abs(AGATA_GammaE-0.586)>0.003 && abs(AddBack_EDC2-" + to_string(gamma) + ")<" + to_string(width); - string gating2 = "abs(AddBack_EDC-" + string gating2 + = "abs(AGATA_GammaE-2.013)>0.004 && abs(AGATA_GammaE-0.511)>0.003 && abs(AGATA_GammaE-0.564)>0.004 && abs(AGATA_GammaE-0.586)>0.003 && abs(AddBack_EDC-" + to_string(gamma) + ")<" + to_string(width); - string title = to_string(gamma-width) + " < Eg < " + to_string(gamma+width); - + string title = to_string(gamma-width) + " < Eg < " + to_string(gamma+width); TCanvas *cEx_Gate = new TCanvas("cggGate","cggGate",1000,1000); - //chain->Draw("AddBack_EDC>>ggGate(990,0.05,5)",gating.c_str(),""); + chain->Draw("AddBack_EDC>>ggGate(999,0.005,5)",gating.c_str(),""); TH1F* ggGate = (TH1F*) gDirectory->Get("ggGate"); ggGate->GetXaxis()->SetTitle("Eg [MeV]"); ggGate->GetYaxis()->SetTitle("Counts / 0.005 MeV"); ggGate->SetTitle(title.c_str()); - //chain->Draw("AddBack_EDC2>>ggGate2(990,0.05,5)",gating2.c_str(),""); chain->Draw("AddBack_EDC2>>ggGate2(999,0.005,5)",gating2.c_str(),""); TH1F* ggGate2 = (TH1F*) gDirectory->Get("ggGate2"); ggGate->Add(ggGate2,1); ggGate->Draw(); } - -void GateGamma_SeeGamma_WithBG(double gamma, double width, double bg){ -/**/ - string gating = "abs(AddBack_EDC2-" +*/ + +void GateGamma_SeeGamma(double gamma, double width){ + string gating = "abs(AGATA_GammaE-2.013)>0.004 && abs(AGATA_GammaE-0.511)>0.003 && abs(AGATA_GammaE-0.564)>0.004 && abs(AGATA_GammaE-0.586)>0.00 && abs(AddBack_EDC2-" + to_string(gamma) + ")<" + to_string(width); - string bggate = "abs(AddBack_EDC2-" - + to_string(bg) - + ")<" - + to_string(width); - string gating2 = "abs(AddBack_EDC-" + string gating2 = "abs(AGATA_GammaE-2.013)>0.004 && abs(AGATA_GammaE-0.511)>0.003 && abs(AGATA_GammaE-0.564)>0.004 && abs(AGATA_GammaE-0.586)>0.00 && abs(AddBack_EDC-" + to_string(gamma) + ")<" + to_string(width); - string bggate2 = "abs(AddBack_EDC-" - + to_string(bg) - + ")<" - + to_string(width); -TCanvas *cggGate = new TCanvas("cggGate","cggGate",1000,1000); + string title = to_string(gamma-width) + " < Eg < " + to_string(gamma+width); + TCanvas *cEx_Gate = new TCanvas("cggGate","cggGate",1000,1000); + chain->Draw("AddBack_EDC>>ggGate(999,0.005,5)",gating.c_str(),""); TH1F* ggGate = (TH1F*) gDirectory->Get("ggGate"); + ggGate->GetXaxis()->SetTitle("Eg [MeV]"); + ggGate->GetYaxis()->SetTitle("Counts / 0.005 MeV"); + ggGate->SetTitle(title.c_str()); + chain->Draw("AddBack_EDC2>>ggGate2(999,0.005,5)",gating2.c_str(),""); TH1F* ggGate2 = (TH1F*) gDirectory->Get("ggGate2"); ggGate->Add(ggGate2,1); - ggGate->GetXaxis()->SetTitle("Eg [MeV]"); - ggGate->GetYaxis()->SetTitle("Counts / 0.05 MeV"); - ggGate->SetLineColor(kGreen); - ggGate->SetFillColor(kGreen); - ggGate->SetFillStyle(3154); - - chain->Draw("AddBack_EDC>>ggBG(999,0.005,5)",bggate.c_str(),""); - TH1F* ggBG = (TH1F*) gDirectory->Get("ggBG"); - chain->Draw("AddBack_EDC2>>ggBG2(999,0.005,5)",bggate2.c_str(),""); - TH1F* ggBG2 = (TH1F*) gDirectory->Get("ggBG2"); - ggBG->Add(ggBG2,1); - ggBG->SetLineColor(kRed); - ggBG->SetFillColor(kRed); - ggBG->SetFillStyle(3345); - ggGate->Draw(); - ggBG->Draw("same"); -/**/ +} -/* - string gating = "abs(AddBack_EDC2-" +void GateGamma_SeeGamma_TimeGate(double gamma, double width){ + string gating = timegate + " && abs(AddBack_EDC2-" + to_string(gamma) + ")<" + to_string(width); - string gating2 = "abs(AddBack_EDC-" + string gating2 = timegate + " && abs(AddBack_EDC-" + to_string(gamma) + ")<" + to_string(width); - string title = to_string(gamma-width)+" < Eg < "+to_string(gamma+width); + string title = to_string(gamma-width) + " < Eg < " + to_string(gamma+width); TCanvas *cEx_Gate = new TCanvas("cggGate","cggGate",1000,1000); - //chain->Draw("AddBack_EDC>>ggGate(990,0.05,5)",gating.c_str(),""); chain->Draw("AddBack_EDC>>ggGate(999,0.005,5)",gating.c_str(),""); TH1F* ggGate = (TH1F*) gDirectory->Get("ggGate"); ggGate->GetXaxis()->SetTitle("Eg [MeV]"); ggGate->GetYaxis()->SetTitle("Counts / 0.005 MeV"); ggGate->SetTitle(title.c_str()); - //chain->Draw("AddBack_EDC2>>ggGate2(990,0.05,5)",gating2.c_str(),""); chain->Draw("AddBack_EDC2>>ggGate2(999,0.005,5)",gating2.c_str(),""); TH1F* ggGate2 = (TH1F*) gDirectory->Get("ggGate2"); ggGate->Add(ggGate2,1); - ggGate->SetLineColor(kGreen); - ggGate->SetFillColor(kGreen); - ggGate->SetFillStyle(3154); -// ggGate->Draw(); + ggGate->Draw(); +} - string bggating = "abs(AddBack_EDC2-" - + to_string(bg) +void GateGamma_SeeGamma_WithBG(double gamma, double width, double bg, double width2){ + string gating = "abs(AddBack_EDC2-" + + to_string(gamma) + ")<" + to_string(width); - string bggating2 = "abs(AddBack_EDC-" + string bggate = "abs(AddBack_EDC2-" + to_string(bg) + ")<" + + to_string(width2); + string gating2 = "abs(AddBack_EDC-" + + to_string(gamma) + + ")<" + to_string(width); + string bggate2 = "abs(AddBack_EDC-" + + to_string(bg) + + ")<" + + to_string(width2); - //string title = to_string(bg-width)+" < Eg < "+to_string(gamma+width); + double ratio = width/width2; - //TCanvas *cEx_Gate = new TCanvas("cggGate","cggGate",1000,1000); - //chain->Draw("AddBack_EDC>>ggGate(990,0.05,5)",gating.c_str(),""); - chain->Draw("AddBack_EDC>>ggbgGate(999,0.005,5)",bggating.c_str(),""); - TH1F* ggbgGate = (TH1F*) gDirectory->Get("ggbgGate"); - //ggbgGate->GetXaxis()->SetTitle("Eg [MeV]"); - //ggbgGate->GetYaxis()->SetTitle("Counts / 0.005 MeV"); - //ggbgGate->SetTitle(title.c_str()); - - //chain->Draw("AddBack_EDC2>>ggGate2(990,0.05,5)",gating2.c_str(),""); - chain->Draw("AddBack_EDC2>>ggbgGate2(999,0.005,5)",bggating2.c_str(),""); - TH1F* ggbgGate2 = (TH1F*) gDirectory->Get("ggbgGate2"); - ggbgGate->Add(ggbgGate2,1); - ggbgGate->SetLineColor(kRed); - ggbgGate->SetFillColor(kRed); - ggbgGate->SetFillStyle(3345); - - ggGate->Draw(); - ggbgGate->Draw("same"); + TCanvas *cggGate = new TCanvas("cggGate","cggGate",1000,1000); + chain->Draw("AddBack_EDC>>ggGate(999,0.005,5)",gating.c_str(),""); + TH1F* ggGate = (TH1F*) gDirectory->Get("ggGate"); + chain->Draw("AddBack_EDC2>>ggGate2(999,0.005,5)",gating2.c_str(),""); + TH1F* ggGate2 = (TH1F*) gDirectory->Get("ggGate2"); + ggGate->Add(ggGate2,1); + ggGate->GetXaxis()->SetTitle("Eg [MeV]"); + ggGate->GetYaxis()->SetTitle("Counts / 0.05 MeV"); + ggGate->SetLineColor(kGreen); + ggGate->SetFillColor(kGreen); + ggGate->SetFillStyle(3154); -*/ + chain->Draw("AddBack_EDC>>ggBG(999,0.005,5)",bggate.c_str(),""); + TH1F* ggBG = (TH1F*) gDirectory->Get("ggBG"); + chain->Draw("AddBack_EDC2>>ggBG2(999,0.005,5)",bggate2.c_str(),""); + TH1F* ggBG2 = (TH1F*) gDirectory->Get("ggBG2"); + ggBG->Add(ggBG2,1); + ggBG->Scale(ratio); + ggBG->SetLineColor(kRed); + ggBG->SetFillColor(kRed); + ggBG->SetFillStyle(3345); + ggGate->Draw(); + ggBG->Draw("same"); } void CompareExsAt4MeV(){ TCanvas *cExCompare = new TCanvas("cExCompare","cExCompare",1000,1000); chain->Draw("AddBack_EDC>>gate3p0(1000,0,10)", - "abs(T_MUGAST_VAMOS-2777)<600 && abs(Ex-3.0)<0.1","same"); + "abs(T_MUGAST_VAMOS-2700)<400 && abs(Ex-3.0)<0.1","same"); chain->Draw("AddBack_EDC>>gate3p5(1000,0,10)", - "abs(T_MUGAST_VAMOS-2777)<600 && abs(Ex-3.5)<0.1","same"); + "abs(T_MUGAST_VAMOS-2700)<400 && abs(Ex-3.5)<0.1","same"); chain->Draw("AddBack_EDC>>gate3p9(1000,0,10)", - "abs(T_MUGAST_VAMOS-2777)<600 && abs(Ex-3.9)<0.1","same"); + "abs(T_MUGAST_VAMOS-2700)<400 && abs(Ex-3.9)<0.1","same"); chain->Draw("AddBack_EDC>>gate4p3(1000,0,10)", - "abs(T_MUGAST_VAMOS-2777)<600 && abs(Ex-4.3)<0.1","same"); + "abs(T_MUGAST_VAMOS-2700)<400 && abs(Ex-4.3)<0.1","same"); TH1F* gate3p0 = (TH1F*) gDirectory->Get("gate3p0"); gate3p0->GetXaxis()->SetTitle("Egamma [MeV]"); @@ -648,7 +654,7 @@ void CompareSimExp(){ TCanvas *cSimExp = new TCanvas("cSimExp","cSimExp",1000,1000); gStyle->SetOptStat(0); - chain->Draw("Ex>>hexp(100,-1,9)","abs(T_MUGAST_VAMOS-2777)<600",""); + chain->Draw("Ex>>hexp(600,-15,15)","abs(T_MUGAST_VAMOS-2700)<400",""); TH1F* hexp = (TH1F*) gDirectory->Get("hexp"); hexp->SetTitle("Comparing Simulation to Experiment"); hexp->GetXaxis()->SetTitle("Ex [MeV]"); @@ -659,7 +665,7 @@ void CompareSimExp(){ //TFile* simfile = new TFile("../../../Outputs/Analysis/SimTest_Jun22_TWOFNR_p32.root", "READ"); TTree* simtree = (TTree*) simfile->FindObjectAny("PhysicsTree"); - simtree->Draw("Ex>>hsimMGp32(100,-1,9)", + simtree->Draw("Ex>>hsimMGp32(600,-15,15)", "Mugast.TelescopeNumber>0 && Mugast.TelescopeNumber<8","same"); TH1F* hsimMGp32 = (TH1F*) gDirectory->Get("hsimMGp32"); hsimMGp32->SetLineColor(kBlue); @@ -721,15 +727,69 @@ void CompareSimExp(){ */ } +void ForPoster_DiffCrossSec(){ + ifstream infile("DiffCrossSecInputfile.txt"); + vector<double> theta, p32, p32Pos, p32Neg, f72, f72Pos, f72Neg, zero; + + double a, b, c, d, e, f, g; + while(infile){ + infile >> a >> b >> c >> d >> e >> f >> g; + + theta.push_back(a); + zero.push_back(0.0); + + p32.push_back(b); + p32Pos.push_back(c); + p32Neg.push_back(d); + + f72.push_back(e); + f72Pos.push_back(f); + f72Neg.push_back(g); + } + + TGraph *graphp32 = new TGraph(theta.size(), &theta[0], &p32[0]); + TGraph *graphf72 = new TGraph(theta.size(), &theta[0], &f72[0]); + + int num = theta.size(); + + TGraphAsymmErrors *graphp32error + = new TGraphAsymmErrors(num, &theta[0], &p32[0], &zero[0], &zero[0], &p32Neg[0], &p32Pos[0]); + + TGraphAsymmErrors *graphf72error + = new TGraphAsymmErrors(num, &theta[0], &f72[0], &zero[0], &zero[0], &f72Neg[0], &f72Pos[0]); + + + graphp32->SetFillColor(kRed); + graphp32->SetFillStyle(3005); + graphf72->SetFillColor(kBlue); + graphf72->SetFillStyle(3005); + + graphp32->Draw(); + graphf72->Draw("same"); + graphp32error->Draw("same"); + graphf72error->Draw("same"); + +/* + TMultiGraph *mg = new TMultiGraph(); + mg->Add(graphp32); + mg->Add(graphf72); + mg->Add(graphp32error); + mg->Add(graphf72error); + mg->Draw(); +*/ + + +} + void MugastMisalignment(){ TCanvas *cMisaligned = new TCanvas("cMisaligned","cMisaligned",1000,1000); gStyle->SetOptStat(0); - chain->Draw("Ex>>hcG_T1(120,-1,5)","abs(T_MUGAST_VAMOS-2777)<600 && Mugast.TelescopeNumber==1",""); - chain->Draw("Ex>>hcG_T2(120,-1,5)","abs(T_MUGAST_VAMOS-2777)<600 && Mugast.TelescopeNumber==2","same"); - chain->Draw("Ex>>hcG_T3(120,-1,5)","abs(T_MUGAST_VAMOS-2777)<600 && Mugast.TelescopeNumber==3","same"); - chain->Draw("Ex>>hcG_T4(120,-1,5)","abs(T_MUGAST_VAMOS-2777)<600 && Mugast.TelescopeNumber==4","same"); - chain->Draw("Ex>>hcG_T5(120,-1,5)","abs(T_MUGAST_VAMOS-2777)<600 && Mugast.TelescopeNumber==5","same"); - chain->Draw("Ex>>hcG_T7(120,-1,5)","abs(T_MUGAST_VAMOS-2777)<600 && Mugast.TelescopeNumber==7","same"); + chain->Draw("Ex>>hcG_T1(120,-1,5)","abs(T_MUGAST_VAMOS-2700)<400 && Mugast.TelescopeNumber==1",""); + chain->Draw("Ex>>hcG_T2(120,-1,5)","abs(T_MUGAST_VAMOS-2700)<400 && Mugast.TelescopeNumber==2","same"); + chain->Draw("Ex>>hcG_T3(120,-1,5)","abs(T_MUGAST_VAMOS-2700)<400 && Mugast.TelescopeNumber==3","same"); + chain->Draw("Ex>>hcG_T4(120,-1,5)","abs(T_MUGAST_VAMOS-2700)<400 && Mugast.TelescopeNumber==4","same"); + chain->Draw("Ex>>hcG_T5(120,-1,5)","abs(T_MUGAST_VAMOS-2700)<400 && Mugast.TelescopeNumber==5","same"); + chain->Draw("Ex>>hcG_T7(120,-1,5)","abs(T_MUGAST_VAMOS-2700)<400 && Mugast.TelescopeNumber==7","same"); TH1F* hcG_T1 = (TH1F*) gDirectory->Get("hcG_T1"); hcG_T1->SetTitle("Misalignment of MUGAST telescopes"); hcG_T1->GetXaxis()->SetTitle("E_{x} [MeV]"); @@ -780,7 +840,7 @@ void MugastMisalignment(double gamma, double width){ TCanvas *cMisaligned = new TCanvas("cMisaligned","cMisaligned",1000,1000); gStyle->SetOptStat(0); - string base = "abs(T_MUGAST_VAMOS-2777)<600 && abs(AddBack_EDC-" + to_string(gamma) + string base = "abs(T_MUGAST_VAMOS-2700)<400 && abs(AddBack_EDC-" + to_string(gamma) + ")<" + to_string(width) + " && Mugast.TelescopeNumber=="; string str1 = base + "1"; string str2 = base + "2"; @@ -845,7 +905,7 @@ void ExPhiLab(){ TCanvas *diagnosePhi = new TCanvas("diagnosePhi","diagnosePhi",1000,1000); chain->Draw( "Ex:PhiLab>>phiHist(180,-180,180,120,-1,5)", - "abs(T_MUGAST_VAMOS-2777)<600 && Mugast.TelescopeNumber>0 && Mugast.TelescopeNumber<8", + "abs(T_MUGAST_VAMOS-2700)<400 && Mugast.TelescopeNumber>0 && Mugast.TelescopeNumber<8", "colz"); TH1F* phiHist = (TH1F*) gDirectory->Get("phiHist"); phiHist->GetXaxis()->SetTitle("Phi (degrees)"); @@ -889,7 +949,7 @@ void ExPhiLab_ForPoster(){ diagnosePhi->cd(1); chain->Draw( "Ex:PhiLab>>phiHist(180,-180,180,40,-1,+1)", - "abs(T_MUGAST_VAMOS-2777)<600 && Mugast.TelescopeNumber>0 && Mugast.TelescopeNumber<8", + "abs(T_MUGAST_VAMOS-2700)<400 && Mugast.TelescopeNumber>0 && Mugast.TelescopeNumber<8", "colz"); TH1F* phiHist = (TH1F*) gDirectory->Get("phiHist"); phiHist->GetXaxis()->SetTitle("#Phi_{Lab} [deg]"); @@ -904,7 +964,7 @@ void ExPhiLab_ForPoster(){ TTree* tree = (TTree*) file->FindObjectAny("PhysicsTree"); diagnosePhi->cd(2); tree->Draw("Ex:PhiLab>>phiHist2(180,-180,180,40,-1,+1)", - "abs(T_MUGAST_VAMOS-2777)<600 && Mugast.TelescopeNumber>0 && Mugast.TelescopeNumber<8", + "abs(T_MUGAST_VAMOS-2700)<400 && Mugast.TelescopeNumber>0 && Mugast.TelescopeNumber<8", "colz"); TH1F* phiHist2 = (TH1F*) gDirectory->Get("phiHist2"); @@ -917,19 +977,21 @@ void ExPhiLab_ForPoster(){ void ExThetaLab(){ TCanvas *diagnoseTheta = new TCanvas("diagnoseTheta","diagnoseTheta",1000,1000); chain->Draw( - "Ex:ThetaLab>>thetaHist(60,100,160,100,-1,9)", - "abs(T_MUGAST_VAMOS-2777)<600 && Mugast.TelescopeNumber>0 && Mugast.TelescopeNumber<8", + "Ex:ThetaLab>>thetaHist(120,100,160,180,-1,8)", + "abs(T_MUGAST_VAMOS-2700)<400 && Mugast.TelescopeNumber>0 && Mugast.TelescopeNumber<8", "colz"); TH1F* thetaHist = (TH1F*) gDirectory->Get("thetaHist"); - thetaHist->GetXaxis()->SetTitle("Theta (degrees)"); + thetaHist->GetXaxis()->SetTitle("#theta_{lab} [deg]"); thetaHist->GetYaxis()->SetTitle("Ex [MeV]"); thetaHist->SetTitle("Theta dependance testing"); diagnoseTheta->Update(); + TLine *l0000 = new TLine(100., 0.000, 160., 0.000); l0000->SetLineStyle(kDashed); l0000->SetLineColor(kRed); l0000->Draw(); + /* TLine *l0143 = new TLine(100., 0.143, 160., 0.143); l0143->SetLineStyle(kDashed); l0143->SetLineColor(kRed); @@ -958,12 +1020,17 @@ void ExThetaLab(){ l3600->SetLineStyle(kDotted); l3600->SetLineColor(kRed); l3600->Draw("same"); + */ + TLine *Sn = new TLine(100., 4.644, 160., 4.644); + Sn->SetLineStyle(kDashed); + Sn->SetLineColor(kRed); + Sn->Draw(); } void ExThetaLab(double gamma, double width){ TCanvas *diagnoseTheta = new TCanvas("diagnoseTheta","diagnoseTheta",1000,1000); - string gating = "abs(T_MUGAST_VAMOS-2777)<600 && Mugast.TelescopeNumber>0 && Mugast.TelescopeNumber<8 && abs(AddBack_EDC-" + string gating = "abs(T_MUGAST_VAMOS-2700)<400 && Mugast.TelescopeNumber>0 && Mugast.TelescopeNumber<8 && abs(AddBack_EDC-" + to_string(gamma) + ") < " + to_string(width); chain->Draw("Ex:ThetaLab>>thetaHist(60,100,160,100,-1,9)", gating.c_str(), "colz"); @@ -1015,14 +1082,17 @@ void ExThetaLab(double gamma, double width){ void ELabThetaLab(){ TCanvas *cELabTLaab = new TCanvas("cELabTLab","cELabTLab",1000,1000); gStyle->SetOptStat(0); - chain->Draw("ELab:ThetaLab>>hKine(360,0,180,450,0,7)","abs(T_MUGAST_VAMOS-2777)<600","col"); + chain->Draw("ELab:ThetaLab>>hKine(360,0,180,500,0,10)","abs(T_MUGAST_VAMOS-2700)<400","col"); TH2F* hKine = (TH2F*) gDirectory->Get("hKine"); hKine->SetTitle(""); hKine->GetXaxis()->SetTitle("#theta_{lab} [deg]"); hKine->GetYaxis()->SetTitle("E_{lab} [MeV]"); + plot_kine(Kdt, 0.000, kBlack, 2, 1); + plot_kine(Kdp, 0.000, kBlack, 2, 1); plot_kine(Kdp, 4.644, kBlack, 2, 1); + /** plot_kine(Kdp, 0.143, kRed, 1, 2); plot_kine(Kdp, 0.968, kRed, 1, 2); plot_kine(Kdp, 1.410, kRed, 1, 2); @@ -1030,34 +1100,37 @@ void ELabThetaLab(){ plot_kine(Kdp, 2.410, kRed, 1, 2); plot_kine(Kdp, 2.907, kRed, 1, 2); plot_kine(Kdp, 3.600, kRed, 1, 2); - plot_kine(Kdp, 3.792, kRed, 1, 2); - - plot_kine(Kdd, 0.000, kGreen+2, 2, 9); - plot_kine(Kpp, 0.000, kYellow, 2, 9); - - plot_kine(Tidp, 0.000, kBlack, 2, 1); - plot_kine(Tidp, 5.652, kBlack, 2, 6); //strongest populated state according to PDBarnes(1965) - - plot_kine(K12C12C, 0.000, kBlack, 2, 1); + plot_kine(Kdp, 3.8 , kRed, 1, 2); + plot_kine(Kdp, 4.3 , kRed, 1, 2); + plot_kine(Kdp, 4.507, kRed, 1, 2); + **/ + + plot_kine(Kdd, 0.000, kBlack, 2, 9); + plot_kine(Kpp, 0.000, kBlack, 2, 9); + + plot_kine(Cadp, 0.000, kRed, 2, 1); + plot_kine(Tidp, 0.000, kBlue, 2, 1); + plot_kine(Scdp, 0.000, kGreen, 2, 1); + //plot_kine(Tidp, 5.652, kBlack, 2, 6); //strongest populated state according to PDBarnes(1965) } void XYMust2(){ TCanvas *cXYMust2 = new TCanvas("cXYMM","cXYMM",1000,1000); chain->Draw("Y:X>>hXYMust2(300,-150,+150,300,-150,+150)", - "abs(T_MUGAST_VAMOS-2777)<600 && MUST2.TelescopeNumber>0 && MUST2.TelescopeNumber<5", + "abs(T_MUGAST_VAMOS-2700)<400 && MUST2.TelescopeNumber>0 && MUST2.TelescopeNumber<5", "colz"); } void XYMugast(){ TCanvas *cXYMugast = new TCanvas("cXYMG","cXYMG",1000,1000); chain->Draw("Y:X>>hXYMugast(150,-150,+150, 150,-150,+150)", - "abs(T_MUGAST_VAMOS-2777)<600 && Mugast.TelescopeNumber>0 && Mugast.TelescopeNumber<8", + "abs(T_MUGAST_VAMOS-2700)<400 && Mugast.TelescopeNumber>0 && Mugast.TelescopeNumber<8", "colz"); } void MM5_ELabThetaLab(){ chain->Draw("ELab:ThetaLab>>hMM5_el(180,50,95,700,0,7)", - "abs(T_MUGAST_VAMOS-2777)<600 && MUST2.TelescopeNumber==5", + "abs(T_MUGAST_VAMOS-2700)<400 && MUST2.TelescopeNumber==5", "colz"); TH2F* hMM5_el = (TH2F*) gDirectory->Get("hMM5_el"); hMM5_el->GetXaxis()->SetTitle("Theta Lab"); @@ -1069,7 +1142,7 @@ void MM5_ELabThetaLab(){ void MM5_RawEThetaLab(){ chain->Draw("RawEnergy:ThetaLab>>hMM5_el(90,50,95,700,0,7)", - "abs(T_MUGAST_VAMOS-2777)<600 && MUST2.TelescopeNumber==5", + "abs(T_MUGAST_VAMOS-2700)<400 && MUST2.TelescopeNumber==5", "colz"); //plot_kine(Kdd, 0, kGreen+2, 2, 9); @@ -1078,10 +1151,430 @@ void MM5_RawEThetaLab(){ void MM5_ExThetaLab(){ chain->Draw("Ex:ThetaLab>>hMM5_ex(180,0,180,400,0,20)", - "abs(T_MUGAST_VAMOS-2777)<600 && Must2.TelescopeNumber==5", + "abs(T_MUGAST_VAMOS-2700)<400 && Must2.TelescopeNumber==5", "colz"); } + +void thickness(){ + + std::ifstream infile("thicknessTheory4.txt"); + + // THEORY ------------------------------------- + double x, pCH, dHSS, pBG, pPer, dKD, d79D, dPer, dLH, dBel; + vector<double> vx, vpCH, vdHSS, vpBG, vpPer, vdKD, vd79D, vdPer, vdLH, vdBel; + int count = 0; + + while (infile >> x >> pCH >> dHSS >> pBG >> pPer >> dKD >> d79D >> dPer >> dLH >> dBel) + { + vx.push_back(x); + vpBG.push_back(pBG); + vdHSS.push_back(dHSS); + vpCH.push_back(pCH); + vpPer.push_back(pPer); + vdKD.push_back(dKD); + vd79D.push_back(d79D); + vdPer.push_back(dPer); + vdLH.push_back(dLH); + vdBel.push_back(dBel); + + count++; + } + // -------------------------------------------- + + // EXPERIMENT --------------------------------- + +double expDx[20]= {22.5 , +23.5 , +24.5 , +25.5 , +26.5 , +27.5 , +28.5 , +29.5 , +30.5 , +31.5 , +32.5 , +33.5 , +34.5 , +35.5 , +36.5 , +37.5 , +38.5 , +39.5 , +40.5 , +41.5 }; + +double expDy[20]={ +0.595726876922256 , +0.543213473232366 , +0.494283286886849 , +0.421774881771817 , +0.341156378590349 , +0.307099360773692 , +0.262569839264486 , +0.232682384534885 , +0.216888228577843 , +0.23470124429325 , +0.240399882846714 , +0.228134082861555 , +0.32920533438895 , +0.296543336595945 , +0.367649491313769 , +0.413065289661424 , +0.437192259660495 , +0.440938347607344 , +0.378811580496408 , +0.404394227640296 }; + + + +double expDyErr[20]={ +0.028324914039265 , +0.0218144191759532 , +0.0142504076860264 , +0.0146454365657758 , +0.0088989334482194 , +0.00824524006184739 , +0.0108064634609478 , +0.0111948065344291 , +0.00904509721171868 , +0.0119548919107791 , +0.0180227167275249 , +0.0201388245171666 , +0.0213346009360056 , +0.0193056550679402 , +0.0155440903197556 , +0.0136119544115286 , +0.0204840651640718 , +0.0248743996273666 , +0.023151640426499 , +0.0183223089693594 }; + +double expDyErr2[20]={0.5, + 0.5, + 0.5, + 0.5, + 0.5, + 0.5, + 0.5, + 0.5, + 0.5, + 0.5, + 0.5, + 0.5, + 0.5, + 0.5, + 0.5, + 0.5, + 0.5, + 0.5, + 0.5, + 0.5}; + +double expPx[15]={31.5 , +32.5 , +33.5 , +34.5 , +35.5 , +36.5 , +37.5 , +38.5 , +39.5 , +40.5 , +41.5 , +42.5 , +43.5 , +44.5 , +45.5 }; + +double expPy[15]={ +0.927940963711002 , +0.886373091269099 , +0.997232654140559 , +0.850828825193078 , +0.975515571786442 , +0.799588217203809 , +0.816607420458171 , +0.982225026964146 , +0.888146409552698 , +0.901367241759583 , +1.07321471789101 , +1.0011298892341 , +0.966230221622026 , +1.1926071484492 , +0.865315617070875 }; + + + + + +double expPyErr[15]={ +0.0990008372934202 , +0.14013781860333 , +0.0725936416502272 , +0.066957912885687 , +0.0518874166956934 , +0.0314030147725784 , +0.0396294675991484 , +0.0474887746673471 , +0.0504518388646933 , +0.0432543357898785 , +0.0509856961378907 , +0.0376160621523655 , +0.043968910197424 , +0.0649913895880728 , +0.0576066735490418 }; + + + + + + + +double expPyErr2[15]={0.5, + 0.5, + 0.5, + 0.5, + 0.5, + 0.5, + 0.5, + 0.5, + 0.5, + 0.5, + 0.5, + 0.5, + 0.5, + 0.5, + 0.5}; + + + + + /* double expDx[16] = {22.8659168020674, + 24.4932387071222, + 25.4884605201683, + 26.4478963605459, + 27.8768790582849, + 30.0521503123866, + 31.6308395766488, + 32.4198704973062, + + 34.0083546157897, + 35.4165962236503, + 36.4835938795446, + 37.5238982330089, + 38.5397371697557, + 39.5330583015003, + 40.5055760670275, + 41.3}; + + double expDy[16] = {9.52350198819289, + 5.64694896708287, + 3.57621524475264, + 2.22306813461932, + 1.84242236351724, + 0.839564977947224, + 0.533641048642503, + 0.811298146594814, + 0.452491201918824, + 0.628258484221101, + 0.700018256426215, + 0.598634895567586, + 0.510176367468261, + 0.457345826343762, + 0.341874900915227, + 0.41491476578731}; + + double expPx[9] = {30.6251132222237, + 32.9493281027741, + 34.6378972639558, + 37.6049166106808, + 39.1281033807373, + 41.0541710577087, + 43.6797461320023, + 43.5133105051628, + 45.6589118858263}; + + double expPy[9] = {15.4053624168101, + 10.0326697910848, + 11.2010890871452, + 6.28484827873840, + 5.93048525466625, + 5.18590383783819, + 4.93601112583176, + 3.77917031974004, + 6.32306635135636}; + */ + // -------------------------------------------- + + //cout << vx.front() << " to " << vx.back() << " count " << count << endl; + + TCanvas *canvThick = new TCanvas("canvThick","canvThick",1000,1000); + canvThick->SetLogy(); + + int HSS = 10, Perey = 4, BGreen = 1; + + + TGraph* gp1 = new TGraph(vx.size(), &vx[0], &vpBG[0]); + gp1->GetXaxis()->SetLimits(10.,80.); + gp1->SetLineColor(kRed); + gp1->SetLineStyle(BGreen); + gp1->SetLineWidth(2); + gp1->SetTitle("(p,p) Bechetti-Greenlees"); + + TGraph* gp2 = new TGraph(vx.size(), &vx[0], &vpCH[0]); + gp2->GetXaxis()->SetLimits(10.,80.); + gp2->SetLineColor(kRed); + gp2->SetLineStyle(Perey); + gp2->SetLineWidth(2); + gp2->SetTitle("(p,p) Chapel-Hill"); + + TGraph* gp3 = new TGraph(vx.size(), &vx[0], &vpPer[0]); + gp3->GetXaxis()->SetLimits(10.,80.); + gp3->SetLineColor(kRed); + gp3->SetLineStyle(HSS); + gp3->SetLineWidth(2); + gp3->SetTitle("(p,p) Perey"); + + TGraph* gd1 = new TGraph(vx.size(), &vx[0], &vdHSS[0]); + gd1->GetXaxis()->SetLimits(10.,80.); + gd1->SetLineColor(kBlue); + gd1->SetLineStyle(HSS); + gd1->SetLineWidth(2); + gd1->SetTitle("(d,d) HSS"); + + TGraph* gd2 = new TGraph(vx.size(), &vx[0], &vdKD[0]); + gd2->GetXaxis()->SetLimits(10.,80.); + gd2->SetLineColor(kBlue); + gd2->SetLineStyle(1); + gd2->SetLineWidth(2); + gd2->SetTitle("(d,d) Koning-Delaroche"); + + TGraph* gd3 = new TGraph(vx.size(), &vx[0], &vd79D[0]); + gd3->GetXaxis()->SetLimits(10.,80.); + gd3->SetLineColor(kBlue); + gd3->SetLineStyle(6); + gd3->SetLineWidth(2); + gd3->SetTitle("(d,d) 79DCV"); + + TGraph* gd4 = new TGraph(vx.size(), &vx[0], &vdPer[0]); + gd4->GetXaxis()->SetLimits(10.,80.); + gd4->SetLineColor(kBlue); + gd4->SetLineStyle(Perey); + gd4->SetLineWidth(2); + gd4->SetTitle("(d,d) Perey"); + + TGraph* gd5 = new TGraph(vx.size(), &vx[0], &vdLH[0]); + gd5->GetXaxis()->SetLimits(10.,80.); + gd5->SetLineColor(kBlue); + gd5->SetLineStyle(2); + gd5->SetLineWidth(2); + gd5->SetTitle("(d,d) Lohr-Haeberli"); + + TGraph* gd6 = new TGraph(vx.size(), &vx[0], &vdBel[0]); + gd6->GetXaxis()->SetLimits(10.,80.); + gd6->SetLineColor(kBlue); + gd6->SetLineStyle(9); + gd6->SetLineWidth(2); + gd6->SetTitle("(d,d) Belote 48Ca"); + + TGraphErrors* expP = new TGraphErrors( 15, expPx, expPy, expPyErr2, expPyErr); + expP->SetTitle("(p,p) Experiment"); + //expP->SetMarkerStyle(22); + TGraphErrors* expD = new TGraphErrors(20, expDx, expDy, expDyErr2, expDyErr); + expD->SetTitle("(d,d) Experiment"); + //expD->SetMarkerStyle(20); + + TMultiGraph* mg = new TMultiGraph(); + mg->Add(gp1); + mg->Add(gp2); + mg->Add(gp3); + mg->Add(gd1); + mg->Add(gd2); + mg->Add(gd3); + mg->Add(gd4); + mg->Add(gd5); + mg->Add(gd6); + //mg->GetXaxis()->SetTitle("{#theta}_{CM}"); + //mg->GetYaxis()->SetTitle("Elastic counts [mb/sr]"); + mg->Draw("AC"); + mg->GetXaxis()->SetTitle("#theta_{CM} [deg]"); + mg->GetYaxis()->SetTitle("Ratio #sigma/#sigma_{Rutherford}"); + expP->Draw("same*"); + expD->Draw("same*"); + + canvThick->BuildLegend(); + +} + +void ExThetaAnalysis(double gamma, double width, int version){ +// int version; +// bool running = 1; + +// cout << "Constructing Ex:ThetaLab..." << endl; + + + string gating = "abs(T_MUGAST_VAMOS-2777)<600 && Mugast.TelescopeNumber>0 && Mugast.TelescopeNumber<8 && abs(AddBack_EDC-" + + to_string(gamma) + ") < " + to_string(width); + + TCanvas *diagnoseTheta2 = new TCanvas("diagnoseTheta2","diagnoseTheta2",1000,1000); + chain->Draw( + "Ex:ThetaLab>>thetaHist(60,100,160,120,-1,5)", + //"abs(T_MUGAST_VAMOS-2777)<600 && Mugast.TelescopeNumber>0 && Mugast.TelescopeNumber<8", + gating.c_str(), + "colz"); + TH2F* thetaHist = (TH2F*) gDirectory->Get("thetaHist"); + + +// while(running){ +// cout << "Overlay projections (1) or candle plots (2)?" << endl; +// cin >> version; + cout << "Processing..." << endl; + if(version==1){ + thetaHist->ProjectionY("tpy1",06.,15.); + TH1F* tpy1 = (TH1F*) gDirectory->Get("tpy1"); + thetaHist->ProjectionY("tpy2",16.,25.); + TH1F* tpy2 = (TH1F*) gDirectory->Get("tpy2"); + thetaHist->ProjectionY("tpy3",26.,35.); + TH1F* tpy3 = (TH1F*) gDirectory->Get("tpy3"); + thetaHist->ProjectionY("tpy4",36.,45.); + TH1F* tpy4 = (TH1F*) gDirectory->Get("tpy4"); + thetaHist->ProjectionY("tpy5",46.,55.); + TH1F* tpy5 = (TH1F*) gDirectory->Get("tpy5"); + + tpy1->SetLineColor(kRed); + tpy2->SetLineColor(kOrange); + tpy3->SetLineColor(kGreen); + tpy4->SetLineColor(kBlue); + tpy5->SetLineColor(kViolet); + + tpy1->Rebin(2); + tpy2->Rebin(2); + tpy3->Rebin(2); + tpy4->Rebin(2); + tpy5->Rebin(2); + + tpy1->Draw(); + tpy2->Draw("same"); + tpy3->Draw("same"); + tpy4->Draw("same"); + tpy5->Draw("same"); + }else if (version==2){ + thetaHist->GetXaxis()->SetRangeUser(105.,155.); + thetaHist->RebinX(5); + thetaHist->GetXaxis()->SetRangeUser(105.,155.); + thetaHist->Draw("candlex6"); + + }//else{running=0;} +// } + +} + + + + + void ExMugast_ForPoster(){ TCanvas *forPoster = new TCanvas("forPoster","forPoster",1000,1000); @@ -1089,10 +1582,10 @@ void ExMugast_ForPoster(){ forPoster->Divide(1,2); forPoster->cd(1); - chain->Draw("Ex>>hcG_T1(120,-1,5)","abs(T_MUGAST_VAMOS-2777)<600 && Mugast.TelescopeNumber==1","same"); - chain->Draw("Ex>>hcG_T2(120,-1,5)","abs(T_MUGAST_VAMOS-2777)<600 && Mugast.TelescopeNumber==2","same"); - chain->Draw("Ex>>hcG_T5(120,-1,5)","abs(T_MUGAST_VAMOS-2777)<600 && Mugast.TelescopeNumber==5","same"); - chain->Draw("Ex>>hcG_T7(120,-1,5)","abs(T_MUGAST_VAMOS-2777)<600 && Mugast.TelescopeNumber==7","same"); + chain->Draw("Ex>>hcG_T1(120,-1,5)","abs(T_MUGAST_VAMOS-2700)<400 && Mugast.TelescopeNumber==1","same"); + chain->Draw("Ex>>hcG_T2(120,-1,5)","abs(T_MUGAST_VAMOS-2700)<400 && Mugast.TelescopeNumber==2","same"); + chain->Draw("Ex>>hcG_T5(120,-1,5)","abs(T_MUGAST_VAMOS-2700)<400 && Mugast.TelescopeNumber==5","same"); + chain->Draw("Ex>>hcG_T7(120,-1,5)","abs(T_MUGAST_VAMOS-2700)<400 && Mugast.TelescopeNumber==7","same"); TH1F* hcG_T1 = (TH1F*) gDirectory->Get("hcG_T1"); hcG_T1->GetXaxis()->SetRangeUser(-1.0,+1.0); TH1F* hcG_T2 = (TH1F*) gDirectory->Get("hcG_T2"); @@ -1137,10 +1630,10 @@ void ExMugast_ForPoster(){ forPoster->cd(2); - tree->Draw("Ex>>h_T1(120,-1,5)","abs(T_MUGAST_VAMOS-2777)<600 && Mugast.TelescopeNumber==1","same"); - tree->Draw("Ex>>h_T2(120,-1,5)","abs(T_MUGAST_VAMOS-2777)<600 && Mugast.TelescopeNumber==2","same"); - tree->Draw("Ex>>h_T5(120,-1,5)","abs(T_MUGAST_VAMOS-2777)<600 && Mugast.TelescopeNumber==5","same"); - tree->Draw("Ex>>h_T7(120,-1,5)","abs(T_MUGAST_VAMOS-2777)<600 && Mugast.TelescopeNumber==7","same"); + tree->Draw("Ex>>h_T1(120,-1,5)","abs(T_MUGAST_VAMOS-2700)<400 && Mugast.TelescopeNumber==1","same"); + tree->Draw("Ex>>h_T2(120,-1,5)","abs(T_MUGAST_VAMOS-2700)<400 && Mugast.TelescopeNumber==2","same"); + tree->Draw("Ex>>h_T5(120,-1,5)","abs(T_MUGAST_VAMOS-2700)<400 && Mugast.TelescopeNumber==5","same"); + tree->Draw("Ex>>h_T7(120,-1,5)","abs(T_MUGAST_VAMOS-2700)<400 && Mugast.TelescopeNumber==7","same"); TH1F* h_T1 = (TH1F*) gDirectory->Get("h_T1"); h_T1->GetXaxis()->SetRangeUser(-1.0,+1.0); TH1F* h_T2 = (TH1F*) gDirectory->Get("h_T2"); @@ -1192,7 +1685,7 @@ void AGATA_efficiency(double Energy_keV){ } void ElasticsGate(double EMin, double EMax){ - string gates = "abs(T_MUGAST_VAMOS-2777)<600 && MUST2.TelescopeNumber==5 && ELab > " + string gates = "abs(T_MUGAST_VAMOS-2700)<400 && MUST2.TelescopeNumber==5 && ELab > " + to_string(EMin) + " && ELab < " + to_string(EMax); @@ -1201,7 +1694,7 @@ void ElasticsGate(double EMin, double EMax){ } void GateThetaCM(double minTheta, double maxTheta, double binsize){ - string gating = "abs(T_MUGAST_VAMOS-2777)<600 && Mugast.TelescopeNumber>0 && Mugast.TelescopeNumber<8 && ThetaCM > " + string gating = "abs(T_MUGAST_VAMOS-2700)<400 && Mugast.TelescopeNumber>0 && Mugast.TelescopeNumber<8 && ThetaCM > " + to_string(minTheta) + " && ThetaCM < " + to_string(maxTheta); @@ -1221,7 +1714,7 @@ void GateThetaCM(double minTheta, double maxTheta, double binsize){ } void GateThetaLab(double minTheta, double maxTheta, double binsize){ - string gating = "abs(T_MUGAST_VAMOS-2777)<600 && Mugast.TelescopeNumber>0 && Mugast.TelescopeNumber<8 && ThetaLab > " + string gating = "abs(T_MUGAST_VAMOS-2700)<400 && Mugast.TelescopeNumber>0 && Mugast.TelescopeNumber<8 && ThetaLab > " + to_string(minTheta) + " && ThetaLab < " + to_string(maxTheta); @@ -1240,8 +1733,40 @@ void GateThetaLab(double minTheta, double maxTheta, double binsize){ DrawParticleStates(cEx_ThetaLabGate); } +void GateThetaLab_AllOverlaid(){ + double binsize = 0.1; + string basegate = "abs(T_MUGAST_VAMOS-2700)<400 && Mugast.TelescopeNumber>0 && Mugast.TelescopeNumber<8 && "; + //+ to_string(minTheta) + //+ " && ThetaLab < " + //+ to_string(maxTheta); + + string ytitle = "Counts / " + to_string(binsize) + " MeV"; + string draw = "Ex>>Ex_ThetaLabGate(" + to_string(10.0/binsize) + ",-1,9)"; + + TCanvas *cThetaLabGates = new TCanvas("cThetaLabGates","cThetaLabGates",1000,1000); + + /* 105 to 110 */ + + for(int i=0; i<9;i++){ + int min = 105+(i*5); + int max = 110+(i*5); + + + string gate = basegate + "ThetaLab > " + to_string(min) + " && ThetaLab < " + to_string(max); + string histname = "Gate" + to_string(min) + "to" + to_string(max); + string draw = "Ex>>" + histname + "(600,-15,15)"; + + + chain->Draw(draw.c_str(),gate.c_str(),"same"); + TH1F* hist = (TH1F*) gDirectory->Get(histname.c_str()); + hist->SetLineColor(i+1); + + } + +} + void GateThetaLab_MultiWrite(double startTheta, double finishTheta, int numGates, double binsize){ - string core = "abs(T_MUGAST_VAMOS-2777)<600 && Mugast.TelescopeNumber>0 && Mugast.TelescopeNumber<8 && ThetaLab > "; + string core = "abs(T_MUGAST_VAMOS-2700)<400 && Mugast.TelescopeNumber>0 && Mugast.TelescopeNumber<8 && ThetaLab > "; string ytitle = "Counts / " + to_string(binsize) + " MeV"; double gatesize = (finishTheta-startTheta)/numGates; TList* list = new TList(); @@ -1254,7 +1779,7 @@ void GateThetaLab_MultiWrite(double startTheta, double finishTheta, int numGates + " && ThetaLab < " + to_string(minTheta+gatesize); string histname = "cThetaLabGate_" + to_string((int) minTheta) + "-" + to_string((int) (minTheta+gatesize)); - string draw = "Ex>>" + histname + "(" + to_string(10.0/binsize) + ",-1,9)"; + string draw = "Ex>>" + histname + "(" + to_string(30.0/binsize) + ",-15,15)"; TCanvas *cEx_ThetaLabGate = new TCanvas(histname.c_str(),histname.c_str(),1000,1000); chain->Draw(draw.c_str(),gating.c_str(),"colz"); @@ -1290,7 +1815,7 @@ void GatePhaseSpaceByThetaLab_MultiWrite(double startTheta, double finishTheta, + to_string(minTheta+gatesize) + ")"; string histname = "cPSpaceThetaLabGate_" + to_string((int) minTheta) + "-" + to_string((int) (minTheta+gatesize)); - string draw = "Ex>>" + histname + "(" + to_string(10.0/binsize) + ",-1,9)"; + string draw = "Ex>>" + histname + "(" + to_string(30.0/binsize) + ",-15,15)"; TCanvas *cPSpace_ThetaLabGate = new TCanvas(histname.c_str(),histname.c_str(),1000,1000); PSTree->Draw(draw.c_str(),gating.c_str(),"colz"); @@ -1308,6 +1833,47 @@ void GatePhaseSpaceByThetaLab_MultiWrite(double startTheta, double finishTheta, file->ls(); } +void GammaSub_NoDoppler(){ + TCanvas *cGammaSubNoDopp = new TCanvas("cGammaSubNoDopp","cGammaSubNoDopp",1000,1000); + chain->Draw("AGATA_GammaE>>hNoDoppler(5000,0,5)","abs(T_MUGAST_VAMOS-7000)<3000",""); + TH1F* hNoDoppler = (TH1F*) gDirectory->Get("hNoDoppler"); + hNoDoppler->SetTitle("AGATA, Timing gate 4k-10k, no doppler"); +} + +void GammaSub_WithDoppler(){ + TCanvas *cGammaSubWithDopp = new TCanvas("cGammaSubWithDopp","cGammaSubWithDopp",1000,1000); + chain->Draw("AddBack_EDC>>hWithDoppler(5000,0,5)","abs(T_MUGAST_VAMOS-7000)<3000",""); + TH1F* hWithDoppler = (TH1F*) gDirectory->Get("hWithDoppler"); + hWithDoppler->SetTitle("AGATA, Timing gate 4k-10k, with doppler"); +} + +/* +void GammaSub_Subbed(){ + TCanvas *cGammaSub = new TCanvas("cGammaSub","cGammaSub",1000,1000); + chain->Draw("AddBack_EDC>>Eg_Sub(5000,0,5)","abs(T_MUGAST_VAMOS-2700)<400",""); + TH1F* Eg_Sub = (TH1F*) gDirectory->Get("Eg_Sub"); + chain->Draw("AddBack_EDC>>Eg_True(5000,0,5)","abs(T_MUGAST_VAMOS-2700)<400",""); + TH1F* Eg_True = (TH1F*) gDirectory->Get("Eg_True"); + //chain->Draw("AddBack_EDC>>Eg_False(5000,0,5)","abs(T_MUGAST_VAMOS-1250)<850 || abs(T_MUGAST_VAMOS-4650)<850"); + chain->Draw("AddBack_EDC>>Eg_False(5000,0,5)", + "abs(T_MUGAST_VAMOS-4050)<250 || abs(T_MUGAST_VAMOS-4900)<200 || abs(T_MUGAST_VAMOS-650)<250 || abs(T_MUGAST_VAMOS-1550)<250"); + TH1F* Eg_False = (TH1F*) gDirectory->Get("Eg_False"); + + double scale = (400.*2.)/(500.+400.+500.+500.); + Eg_False->Scale(scale); + Eg_Sub->Add(Eg_False,-1); + Eg_Sub->Draw(); +} +*/ + +void GammaSub_Actual_ExcludeBeamDecay(){ + TCanvas *cGammaSub = new TCanvas("cGammaSub","cGammaSub",1000,1000); + chain->Draw("AddBack_EDC>>Eg(5000,0,5)", + "abs(T_MUGAST_VAMOS-2700)<400 && abs(AGATA_GammaE-2.013)>0.004 && abs(AGATA_GammaE-0.511)>0.003 && abs(AGATA_GammaE-0.564)>0.004 && abs(AGATA_GammaE-0.586)>0.003"); + TH1F* Eg = (TH1F*) gDirectory->Get("Eg"); + Eg->Draw(); +} + /* void gg(){ @@ -1348,33 +1914,24 @@ void gg(){ */ void ggLoad(TTree* chain, TH2F* h){ + // Initilise the Mugast branch auto Mugast = new TMugastPhysics(); // Initilise access variables for chain -// static double T_MUGAST_VAMOS; - static vector<double> //*X, *Y, *Z, *RawEnergy, - *AddBack_EDC; - + static double T_MUGAST_VAMOS; + static vector<double> *AddBack_EDC, *AGATA_GammaE; + // Pull chain branches -// auto Energy_Branch = chain->GetBranch("RawEnergy"); auto Gamma_Branch = chain->GetBranch("AddBack_EDC"); -// auto X_Branch = chain->GetBranch("X"); -// auto Y_Branch = chain->GetBranch("Y"); -// auto Z_Branch = chain->GetBranch("Z"); -// auto MugVam_Branch = chain->GetBranch("T_MUGAST_VAMOS"); - - // Set Mugast branch address -// chain->SetBranchAddress("Mugast",&Mugast); - + auto RawGamma_Branch = chain->GetBranch("AGATA_GammaE"); + auto MugVam_Branch = chain->GetBranch("T_MUGAST_VAMOS"); + // Set chain variable addresses -// Energy_Branch->SetAddress(&RawEnergy); Gamma_Branch->SetAddress(&AddBack_EDC); -// X_Branch->SetAddress(&X); -// Y_Branch->SetAddress(&Y); -// Z_Branch->SetAddress(&Z); -// MugVam_Branch->SetAddress(&T_MUGAST_VAMOS); - + RawGamma_Branch->SetAddress(&AGATA_GammaE); + MugVam_Branch->SetAddress(&T_MUGAST_VAMOS); + // Build loop variables unsigned int numEntries = chain->GetEntries(); unsigned int multiplicity = 0; @@ -1382,31 +1939,37 @@ void ggLoad(TTree* chain, TH2F* h){ // Loop on entries for(unsigned int i=0; i<numEntries; i++){ chain->GetEntry(i); - - // Gate on Timing -// if(abs(T_MUGAST_VAMOS-2777)<600){ + if(abs(T_MUGAST_VAMOS-2700)<400){ int gammaMultip = AddBack_EDC->size(); + //no muliplicity 1 if(gammaMultip>=1){ - double e1,e2; + //loop through events for(unsigned int s=0 ; s<gammaMultip-1 ; s++){ - e1=AddBack_EDC->at(s) ; e2 = AddBack_EDC->at(s+1); - // Folding of the matrix, always fill big first - if(e1>e2){ - h->Fill(e1,e2); - } - else{ - h->Fill(e2,e1); + //remove beam decay gammas + if(abs(AGATA_GammaE->at(s)-2.013)>0.004 && abs(AGATA_GammaE->at(s)-0.511)>0.003 + && abs(AGATA_GammaE->at(s)-0.564)>0.004 && abs(AGATA_GammaE->at(s)-0.586)>0.003){ + e1=AddBack_EDC->at(s); e2 = AddBack_EDC->at(s+1); + // Folding of the matrix, always fill big first + if(e1>e2){ + h->Fill(e1,e2); + } + else{ + h->Fill(e2,e1); + } } } }//if gamma + }//timing }//for i } //void gggLoad(TTree* chain, TH3F* h){ void gggLoad(TTree* chain, THnSparseF* h){ - // Initilise the Mugast branch + +cout << "THIS IS OLD!!!! UPDATE WITH THE BEAM EXCLUSION!!!" << endl; + // Initilise the Mugast branch auto Mugast = new TMugastPhysics(); // Initilise access variables for chain @@ -1446,7 +2009,7 @@ void gggLoad(TTree* chain, THnSparseF* h){ // for(int m=0; m<multiplicity; m++){ // Gate on Timing -// if(abs(T_MUGAST_VAMOS-2777)<600){ +// if(abs(T_MUGAST_VAMOS-2700)<400){ int gammaMultip = AddBack_EDC->size(); if(gammaMultip>=2){ double e1,e2,e3; @@ -1487,21 +2050,20 @@ void gggLoad(TTree* chain, THnSparseF* h){ void gg(){ + cout << "LOADING FILES: 47Kdp_11Apr22_PartI & II" << endl; + auto h=new TH2F("gg","gg",1000,0,10,1000,0,10); - auto DataFile = new TFile("../../../Outputs/Analysis/47Kdp_08Nov_PartI.root", "READ"); + auto DataFile = new TFile("../../../Outputs/Analysis/47Kdp_11Apr22_PartI.root", "READ"); auto chain = (TTree*) DataFile->FindObjectAny("PhysicsTree"); - ggLoad(chain, h); auto h2=new TH2F("gg","gg",1000,0,10,1000,0,10); - auto DataFile2 = new TFile("../../../Outputs/Analysis/47Kdp_08Nov_PartII.root", "READ"); + auto DataFile2 = new TFile("../../../Outputs/Analysis/47Kdp_11Apr22_PartII.root", "READ"); auto chain2 = (TTree*) DataFile->FindObjectAny("PhysicsTree"); - ggLoad(chain2, h2); h->Add(h2,1); - h->Add(h2,1); TFile* file = new TFile("GGMatrix.root","RECREATE"); h->Write(); file->Close(); @@ -1578,3 +2140,50 @@ void ggGater(TH2F* h, double E, double gate){ } + + + +void Figure_Eg_MG(){ + + chain->Draw("AddBack_EDC>>Eg(5000,0,5)","abs(T_MUGAST_VAMOS-2700)<400 && Mugast.TelescopeNumber>0 && Mugast.TelescopeNumber<8"); + TH1F* Eg = (TH1F*) gDirectory->Get("Eg"); + Eg->GetXaxis()->SetTitle("E_{#gamma} [MeV]"); + Eg->GetYaxis()->SetTitle("Counts / 0.001 MeV"); + Eg->SetTitle("#gamma-ray spectrum, requiring MUGAST upstream coincidence"); + + TH1F* Eg2 = (TH1F*) Eg->Clone(); + Eg2->SetTitle(""); + + TCanvas* canv = new TCanvas("canv","canv",1000,1000); + gStyle->SetPadLeftMargin(0.10); + gStyle->SetPadRightMargin(0.03); + gStyle->SetOptStat(0); + + + TPad *pad1 = new TPad("pad1","pad1",0,0.5,1,1); + TPad *pad2 = new TPad("pad2","pad2",0,0,1,0.5); + pad1->SetTopMargin(0.08); + pad1->SetBottomMargin(0.08); + pad1->SetBorderMode(0); + pad2->SetTopMargin(0.08); + pad2->SetBottomMargin(0.08); + pad2->SetBorderMode(0); + pad1->Draw(); + pad2->Draw(); + pad1->cd(); + + Eg->GetXaxis()->SetRangeUser(0.,2.); + Eg->Draw(); + + + pad2->cd(); + + + Eg2->Rebin(2); + Eg2->GetYaxis()->SetTitle("Counts / 0.001 MeV"); + Eg2->GetXaxis()->SetRangeUser(2.,4.5); + Eg2->Draw(); + + +} + diff --git a/Projects/e793s/macro/GausFit.h b/Projects/e793s/macro/GausFit.h index 22bb207c0388c9842ccda0afda3b2ee09627e9c0..252ef56f84fe5adaede0245d942d45b6f2ef17be 100755 --- a/Projects/e793s/macro/GausFit.h +++ b/Projects/e793s/macro/GausFit.h @@ -598,7 +598,7 @@ void SingleGaus(TH1F* hist, bool isGamma){ if(isGamma){ areaSet = 1000.; areaMax = 10000.; meanRange = 0.005; - sigSet = 0.001; sigMin = 0.0005; sigMax = 0.005; + sigSet = 0.001; sigMin = 0.0005; sigMax = 0.015; bgMax = 1000.; } else { areaSet = 100.; areaMax = 1000.; meanRange = 1.0; diff --git a/Projects/e793s/macro/KnownPeakFitter.h b/Projects/e793s/macro/KnownPeakFitter.h index 881775a1d6e4dd51ce528f931440bc8d1114aacb..9cfc1427d4e097163cbb289e082dbf0435229554 100644 --- a/Projects/e793s/macro/KnownPeakFitter.h +++ b/Projects/e793s/macro/KnownPeakFitter.h @@ -3,7 +3,7 @@ #include <cmath> #include "stdlib.h" -const int numPeaks = 15; +const int numPeaks = 16;//15; array<double,numPeaks> means = { 0.000, 0.143, 0.279, @@ -11,16 +11,48 @@ array<double,numPeaks> means = { 0.000, 0.968, 1.410, 1.981, - 2.410, + 2.412, 2.910, - 3.2, + 3.246, 3.605, - 3.87,//3.792, - 4.04,//4.1, - 4.4, - 5.24 + 3.797,//Split in two? + 3.876,//Split in two? + 4.055,//4.1, + 4.38, + 4.51//, + //5.24 }; +array<double,27> knowngammas = { 0.143, + 0.279, + 0.449, + 0.968, + 1.130, + 1.410, + 1.267, + //0.575, + 1.013, + 1.838, + 1.981, + 1.000, + 2.412, + 2.767, + 2.518, + 3.325, + 2.878, + 3.605, + 2.839, + 2.734, + 3.522, + 3.076, + 3.875, + 0.834, + 3.325, + 3.77, + 4.037, + 4.364 + }; + /* Double_t f_bg(Double_t *x, Double_t *par){ // Flat bg [0] + semicircle [1]*sqrt(6.183^2 - (x-10.829)^2) @@ -113,9 +145,9 @@ vector<vector<double>> FitKnownPeaks_RtrnArry(TH1F* hist){ full->SetParLimits((i*3)+3,0.0,1e5); } //full->SetParameter(0,30.); - full->SetParLimits(0,0.,40.); /* FOR TOTAL SPECTRUM FITTING */ - //full->SetParLimits(0,0.,10.); /* FOR ANGLE GATED FITTING */ - //full->FixParameter(0,0.); + //full->SetParLimits(0,0.,40.); /* FOR TOTAL SPECTRUM FITTING */ + full->SetParLimits(0,0.,10.); /* FOR ANGLE GATED FITTING */ + //full->SetParLimits(0,0.,1.); /* FOR ANGLE GATED FITTING WITH BG SUBTRACTED */ //full->FixParameter(9,0.); //?? // Specific limits diff --git a/Projects/e793s/macro/Plots_47Kdp.C b/Projects/e793s/macro/Plots_47Kdp.C new file mode 100644 index 0000000000000000000000000000000000000000..7508c206b093f945b37809d4cd1fc8770900b605 --- /dev/null +++ b/Projects/e793s/macro/Plots_47Kdp.C @@ -0,0 +1,65 @@ +#include "GausFit.h" +#include "KnownPeakFitter.h" +#include "DrawPlots.h" + +#include "CS2.h" +#include "ThreeBodyBreakup.h" +#include "ThreeBodyBreakup_FitPhaseSpace.h" + + +void AddGammaLinesMG(TH1F* hist, double particle, double ymax){ + string base = "sub "; + + for(int i=1; i<means.size();i++){ + string name = base + to_string(means.at(i)); + TLine *line = new TLine(particle-means.at(i), 0.0, particle-means.at(i), ymax); + line->SetLineColor(kBlack); line->SetLineStyle(kDotted); + line->Draw(); + TText *text = new TText((1.-(means.at(i)/particle))*particle,0.8*ymax,name.c_str()); + text->SetTextAngle(90); + //text->SetTextSize(40); + text->Draw(); + } +} + +void AddPlacedGammasMG(TH1F* hist, double ymax){ + hist->Draw(); + for(int i=0; i<knowngammas.size();i++){ + TLine *line = new TLine(knowngammas.at(i), 0.0, knowngammas.at(i), ymax); + line->SetLineColor(kBlack); line->SetLineStyle(kDotted); + line->Draw(); + } +} + +/* MAIN FUNCTION */ + +void Plots_47Kdp(){ + + LoadChain47Kdp(); + gStyle->SetOptStat("nemMrRi"); + + tCentre = 2700; tRange = 400; + timegate = "abs(T_MUGAST_VAMOS-" + to_string(tCentre) + ")<" + to_string(tRange); + det_gate = "Mugast.TelescopeNumber>0 && Mugast.TelescopeNumber<8"; + + cout << "==============================================" << endl; + cout << "=============== (d,p) reaction ===============" << endl; + cout << "==============================================" << endl; + cout << ""<< endl; + cout << "- CS(stateE, stateSp, orb_l, orb_j, nodes) "<< endl; + cout << "---- 0.143, p3/2 = CS(0.143, 2, 1, 1.5) "<< endl; + cout << "---- 0.279, p3/2 = CS(0.279, 2, 1, 1.5) "<< endl; + cout << "---- 0.728, f7/2 = CS(0.728, 3, 3, 3.5) "<< endl; + cout << "---- 0.968, p1/2 = CS(0.968, 0, 1, 0.5) "<< endl; + cout << "---- 1.410, p3/2 = CS(1.410, 2, 1, 1.5) "<< endl; + cout << "---- 1.981, p3/2 = CS(1.981, 2, 1, 1.5) "<< endl; + cout << "---- 2.410, p3/2 = CS(2.410, 0, 1, 0.5) "<< endl; + cout << "---- 3.2 , f7/2 = CS(3.2 , 3, 3, 3.5) "<< endl; + cout << "---- 3.6 , f5/2 = CS(3.6 , 3, 3, 2.5) "<< endl; + cout << "---- 3.8 , f5/2 = CS(3.8 , 3, 3, 2.5) "<< endl; + cout << "---- 4.1 , f5/2 = CS(4.1 , 3, 3, 2.5) "<< endl; + cout << "---- 4.4 , f5/2 = CS(4.4 , 3, 3, 2.5) "<< endl; + cout << ""<< endl; + cout << "==============================================" << endl; + +} diff --git a/Projects/e793s/macro/Plots_47Kdt.C b/Projects/e793s/macro/Plots_47Kdt.C new file mode 100644 index 0000000000000000000000000000000000000000..0fb0215d1160e95bc38af80399a2ad9b88ce130a --- /dev/null +++ b/Projects/e793s/macro/Plots_47Kdt.C @@ -0,0 +1,24 @@ +#include "GausFit.h" +//#include "KnownPeakFitter.h" +#include "DrawPlots.h" + +//#include "CS2.h" +//#include "ThreeBodyBreakup.h" +//#include "ThreeBodyBreakup_FitPhaseSpace.h" + +/* MAIN FUNCTION */ + +void Plots_47Kdt(){ + + LoadChain47Kdt(); + gStyle->SetOptStat("nemMrRi"); + + tCentre = 2750; tRange = 350; + timegate = "abs(T_MUGAST_VAMOS-" + to_string(tCentre) + ")<" + to_string(tRange); + det_gate = "MUST2.TelescopeNumber>0 && MUST2.TelescopeNumber<5"; + + cout << "==============================================" << endl; + cout << "=============== (d,t) reaction ===============" << endl; + cout << "==============================================" << endl; + +} diff --git a/Projects/e793s/sim.sh b/Projects/e793s/sim.sh new file mode 100755 index 0000000000000000000000000000000000000000..674af7ba43cafb3443018d05100fa34a62a25ff8 --- /dev/null +++ b/Projects/e793s/sim.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +rfile='./Reaction/47Kdp_Sim_0143MeV.reaction' +#rfile='./Reaction/47Kdp_Sim_0968MeV.reaction' +#rfile='./Reaction/47Kdp_Sim_3605MeV.reaction' + +#rfile='./Reaction/47Kdp_Sim_3605MeV_Flat.reaction' +#rfile='./Reaction/47Kdp_Sim.reaction' +#rfile='./Reaction/IsotropicProtons.reaction' +#rfile='./Reaction/47Kdp_Sim_Flat3500MeV.reaction' + +cd ~/Programs/nptool/Projects/e793s; +cmake ./; +make -j6; + +directory=' /home/charlottepaxman/Programs/nptool/Outputs/Simulation/' +dotroot='.root' +dash='-' + +for x in 1 2 3 4 5 +do + outname=$1$dash$x + npsimulation -D ./Detector/mugast_08Nov.detector -E $rfile -B ./runsimulation.mac -O $outname; + + filename=$directory$1$dash$x$dotroot + +done + +sim='Sim_' +outfile=$sim$1 + +echo "TTreeName" > RunToTreat_AutoGenerated.txt +echo " SimulatedTree" >> RunToTreat_AutoGenerated.txt +echo "RootFileName" >> RunToTreat_AutoGenerated.txt + +for x in 1 2 3 4 5 +do + filename=$directory$1$dash$x$dotroot + echo $filename >> RunToTreat_AutoGenerated.txt +done + +npanalysis --definition Sim -R RunToTreat_AutoGenerated.txt -E $rfile -D Detector/mugast_08Nov.detector -O $outfile; diff --git a/Projects/s455/Analysis.cxx b/Projects/s455/Analysis.cxx index 07fd371ecde3f332e45b8c2b0390babc1798f944..73467378c0001fb4c7d5e212630f29249d414aa6 100644 --- a/Projects/s455/Analysis.cxx +++ b/Projects/s455/Analysis.cxx @@ -6,13 +6,13 @@ *****************************************************************************/ /***************************************************************************** - * Original Author: P. Morfouace contact address: pierre.morfouace2@cea.fr * + * Original Author: P. Morfouace contact address: pierre.morfouace@cea.fr * * * * Creation Date : June 2021 * * Last update : * *---------------------------------------------------------------------------* * Decription: * - * This class describe Sofia analysis project * + * This class describe Sofia analysis project * * * *---------------------------------------------------------------------------* * Comment: * @@ -27,6 +27,38 @@ using namespace std; #include"NPDetectorManager.h" #include"NPPhysicalConstants.h" #include"NPGlobalSystemOfUnits.h" + + +//////////////////////////////////////////////////////////////////////////////// +struct TofPair +{ + double x = -1000; + double y = -1000; + double tof = -1000; + double velocity = -1; + double beta = -1; + double theta_in = -10; + double theta_out = -10; + int plastic = -1; + // + int isLorR = -1; + // *** isLorR = 1 -> Left + // *** isLorR = 2 -> Right + // + int isUorD = -1; + // *** isUorD = 1 -> Up + // *** isUorD = 2 -> Down + int section = -1; + double Esec = -1; + double DT = -100; + double x2twim = -1000; + double x2 = -1000; + double x3 = -1000; + double x3lab = 0; + double z3lab = 0; +}; + + //////////////////////////////////////////////////////////////////////////////// Analysis::Analysis(){ } @@ -44,6 +76,7 @@ void Analysis::Init(){ SofTofW= (TSofTofWPhysics*) m_DetectorManager->GetDetector("SofTofW"); SofAt= (TSofAtPhysics*) m_DetectorManager->GetDetector("SofAt"); SofMwpc= (TSofMwpcPhysics*) m_DetectorManager->GetDetector("SofMwpc"); + m_GladField = new GladFieldMap(); InitParameter(); InitOutputBranch(); @@ -66,6 +99,42 @@ void Analysis::TreatEvent(){ SofTofW->BuildPhysicalEvent(); FissionFragmentAnalysis(); + //BeamFragmentAnalysis(); + } +} + +//////////////////////////////////////////////////////////////////////////////// +void Analysis::BeamFragmentAnalysis(){ + unsigned int softofw_size = SofTofW->PlasticNbr.size(); + + double L_CC = 8.45; + TofPair TofHit; + if(softofw_size==1){ + TofHit.plastic = SofTofW->PlasticNbr[0]; + TofHit.x = SofTofW->CalPosX[0]; + TofHit.y = SofTofW->CalPosY[0]; + TofHit.tof = SofTofW->CalTof[0]; + TofHit.velocity = L_CC/TofHit.tof; + TofHit.beta = TofHit.velocity * m/ns / NPUNITS::c_light; + + double Brho = 9.62543 + 0.0076642*TofHit.x; + double Lfactor = 9.17/L_CC; + double Beta = TofHit.beta*Lfactor; + double Gamma1 = 1. / sqrt(1 - Beta * Beta); + + double AoQ = Brho / (3.10761 * Beta * Gamma1); + + SofFF->SetTOF(TofHit.tof); + SofFF->SetTofPosX(TofHit.x); + SofFF->SetTofPosY(TofHit.y); + SofFF->SetPlastic(TofHit.plastic); + + SofFF->SetBeta(Beta); + SofFF->SetGamma(Gamma1); + SofFF->SetAoQ(AoQ); + SofFF->SetBrho(Brho); + + } } @@ -74,14 +143,6 @@ void Analysis::FissionFragmentAnalysis(){ unsigned int softofw_size = SofTofW->PlasticNbr.size(); unsigned int softwim_size = SofTwim->SectionNbr.size(); - double TOF_CC[2]; - double Plastic[2]; - double Plastic_left = -1; - double Plastic_right = -1; - double TOF_left = -1; - double TOF_right = -1; - double TOF_up = -1; - double TOF_down = -1; double E1 = -1; double E2 = -1; double E3 = -1; @@ -90,15 +151,11 @@ void Analysis::FissionFragmentAnalysis(){ double DT2 = -1000; double DT3 = -1000; double DT4 = -1000; + double Theta1 = -1000; + double Theta2 = -1000; + double Theta3 = -1000; + double Theta4 = -1000; double L_CC = 8.45; - double Beta_left = -1; - double Beta_right = -1; - double Beta_up = -1; - double Beta_down = -1; - double Beta1 = -1; - double Beta2 = -1; - double Beta3 = -1; - double Beta4 = -1; double Beta_norm = 0.745; double Gamma1 = -1; double Gamma2 = -1; @@ -116,25 +173,34 @@ void Analysis::FissionFragmentAnalysis(){ int iZ1 = -1; int iZ2 = -1; int iZsum = -1; - double ThetaIn1 = -1000; - double ThetaIn2 = -1000; - - for(int i = 0; i<2; i++){ - TOF_CC[i] = -1; - Plastic[i] = -1; - } - vector<double> PosY; - vector<double> PosX; + TofPair TofHit[2]; if(softofw_size==2){ for(unsigned int i=0; i<softofw_size; i++){ - TOF_CC[i] = SofTofW->CalTof[i]; - Plastic[i] = SofTofW->PlasticNbr[i]; - PosX.push_back(SofTofW->CalPosX[i]); - PosY.push_back(SofTofW->CalPosY[i]); + TofHit[i].plastic = SofTofW->PlasticNbr[i]; + TofHit[i].x = SofTofW->CalPosX[i]; + TofHit[i].y = SofTofW->CalPosY[i]; + TofHit[i].tof = SofTofW->CalTof[i]; + TofHit[i].velocity = L_CC/TofHit[i].tof; + TofHit[i].beta = TofHit[i].velocity * m/ns / NPUNITS::c_light; + } - SofFF->SetTofPosX(SofTofW->CalPosX[i]); - SofFF->SetTofPosY(SofTofW->CalPosY[i]); + if(TofHit[0].x>TofHit[1].x){ + TofHit[0].isLorR = 1; + TofHit[1].isLorR = 2; + } + else if(TofHit[0].x<TofHit[1].x){ + TofHit[0].isLorR = 2; + TofHit[1].isLorR = 1; + } + + if(TofHit[0].y>TofHit[1].y){ + TofHit[0].isUorD = 1; + TofHit[1].isUorD = 2; + } + else if(TofHit[0].y<TofHit[1].y){ + TofHit[0].isUorD = 2; + TofHit[1].isUorD = 1; } } @@ -145,46 +211,75 @@ void Analysis::FissionFragmentAnalysis(){ vector<double> Y2; vector<double> Y3; for(unsigned int i=0; i<SofMwpc->DetectorNbr.size(); i++){ + // *** MWPC1 *** // if(SofMwpc->DetectorNbr[i]==2){ - SofFF->SetPosX1(SofMwpc->PositionX1[i]); - SofFF->SetPosY1(SofMwpc->PositionY[i]); + if(SofMwpc->PositionX1[i]!=-1000){ + X1.push_back(SofMwpc->PositionX1[i]); + } + if(SofMwpc->PositionX2[i]!=-1000){ + X1.push_back(SofMwpc->PositionX2[i]); + } + if(SofMwpc->PositionY[i]!=-1000){ + Y1.push_back(SofMwpc->PositionY[i]); + } } + // *** MWPC2 *** // if(SofMwpc->DetectorNbr[i]==3){ - SofFF->SetPosX2(SofMwpc->PositionX1[i]); - SofFF->SetPosY2(SofMwpc->PositionY[i]); + if(SofMwpc->PositionX1[i]!=-1000){ + X2.push_back(SofMwpc->PositionX1[i]); + } + if(SofMwpc->PositionX2[i]!=-1000){ + X2.push_back(SofMwpc->PositionX2[i]); + } + if(SofMwpc->PositionY[i]!=-1000){ + Y2.push_back(SofMwpc->PositionY[i]); + } } - if(SofMwpc->DetectorNbr[i]==4){ - X3.push_back(SofMwpc->PositionX1[i]); - Y3.push_back(SofMwpc->PositionY[i]); - SofFF->SetPosX3(SofMwpc->PositionX1[i]); - SofFF->SetPosY3(SofMwpc->PositionY[i]); + // *** MWPC3 *** // + if(SofMwpc->DetectorNbr[i]==4){ + if(SofMwpc->PositionX1[i]!=-1000) + X3.push_back(SofMwpc->PositionX1[i]); + + if(SofMwpc->PositionY[i]!=-1000) + Y3.push_back(SofMwpc->PositionY[i]); } } + - vector<double> good_posx; - vector<double> good_posy; - for(unsigned int i=0; i<PosX.size(); i++){ - double tofx = PosX[i]; - double tofy = PosY[i]; - for(unsigned int k=0; k<X3.size(); k++){ + for(unsigned int i=0; i<2; i++){ + double tofx = TofHit[i].x; + + for(unsigned int k=0; k<X3.size(); k++){ double posx = X3[k]; - if(abs(posx-tofx) < 100){ - good_posx.push_back(posx); - good_posy.push_back(tofy); + if(abs(tofx-posx) < 150){ + if(abs(tofx-posx)<abs(tofx-TofHit[i].x3)) + TofHit[i].x3 = posx; } } } + int ileft=0; + int iright=0; + if(TofHit[0].x3>TofHit[1].x3){ + ileft = 0; + iright = 1; + } + else{ + ileft = 1; + iright = 0; + } + if(X2.size()==2){ + if(X2[0]>X2[1]){ + TofHit[ileft].x2 = X2[0]; + TofHit[iright].x2 = X2[1]; + } + else if(X2[0]<X2[1]){ + TofHit[ileft].x2 = X2[1]; + TofHit[iright].x2 = X2[0]; + } + } - /*if(good_posx.size()==2 && good_posy.size()==2){ - SofFF->SetTofPosX(good_posx[0]); - SofFF->SetTofPosX(good_posx[1]); - - SofFF->SetTofPosY(good_posy[0]); - SofFF->SetTofPosY(good_posy[1]); - }*/ - int mult1 = SofTwim->mult1; int mult2 = SofTwim->mult2; @@ -202,18 +297,22 @@ void Analysis::FissionFragmentAnalysis(){ if(sec==1){ E1 = SofTwim->EnergySection[i]; DT1 = SofTwim->DriftTime[i]; + Theta1 = SofTwim->Theta[i]; } if(sec==2){ E2 = SofTwim->EnergySection[i]; DT2 = SofTwim->DriftTime[i]; + Theta2 = SofTwim->Theta[i]; } if(sec==3){ E3 = SofTwim->EnergySection[i]; DT3 = SofTwim->DriftTime[i]; + Theta3 = SofTwim->Theta[i]; } if(sec==4){ E4 = SofTwim->EnergySection[i]; DT4 = SofTwim->DriftTime[i]; + Theta4 = SofTwim->Theta[i]; } } @@ -237,122 +336,259 @@ void Analysis::FissionFragmentAnalysis(){ if(E4>0) E4 = E4/16; - if(Plastic[0]<Plastic[1]){ - Plastic_left = Plastic[0]; - Plastic_right = Plastic[1]; - TOF_left = TOF_CC[0]; - TOF_right = TOF_CC[1]; - } - if(Plastic[0]>Plastic[1]){ - Plastic_left = Plastic[1]; - Plastic_right = Plastic[0]; - TOF_left = TOF_CC[1]; - TOF_right = TOF_CC[0]; - } - if(PosY.size()==2){ - if(PosY[0]>PosY[1]){ - TOF_up = TOF_CC[0]; - TOF_down = TOF_CC[1]; + // *** case 1 *** // + if(E1!=-1 && E2!=-1){ + if(TofHit[0].isUorD==1 && TofHit[1].isUorD==2){ + TofHit[0].Esec = E2; + TofHit[1].Esec = E1; + + TofHit[0].theta_in = Theta2; + TofHit[1].theta_in = Theta1; + + TofHit[0].DT = DT2; + TofHit[1].DT = DT1; + + TofHit[0].section = 2; + TofHit[1].section = 1; } - if(PosY[0]<PosY[1]){ - TOF_up = TOF_CC[1]; - TOF_down = TOF_CC[0]; + if(TofHit[0].isUorD==2 && TofHit[1].isUorD==1){ + TofHit[0].Esec = E1; + TofHit[1].Esec = E2; + + TofHit[0].theta_in = Theta1; + TofHit[1].theta_in = Theta2; + + TofHit[0].DT = DT1; + TofHit[1].DT = DT2; + + TofHit[0].section = 1; + TofHit[1].section = 2; } } - double velocity_left = L_CC/TOF_left; - double velocity_right = L_CC/TOF_right; - Beta_left = velocity_left * m/ns / NPUNITS::c_light; - Beta_right = velocity_right * m/ns / NPUNITS::c_light; - - double velocity_down = L_CC/TOF_down; - double velocity_up = L_CC/TOF_up; - Beta_down = velocity_down * m/ns / NPUNITS::c_light; - Beta_up = velocity_up * m/ns / NPUNITS::c_light; - - if(E1!=-1 && E2!=-1){ - Beta1 = Beta_down; - Beta2 = Beta_up; - } + // *** case 2 *** // if(E1!=-1 && E3!=-1){ - Beta1 = Beta_down; - Beta3 = Beta_up; + if(TofHit[0].isUorD==1 && TofHit[1].isUorD==2){ + TofHit[0].Esec = E3; + TofHit[1].Esec = E1; + + TofHit[0].theta_in = Theta3; + TofHit[1].theta_in = Theta1; + + TofHit[0].DT = DT3; + TofHit[1].DT = DT1; + + TofHit[0].section = 3; + TofHit[1].section = 1; + } + if(TofHit[0].isUorD==2 && TofHit[1].isUorD==1){ + TofHit[0].Esec = E1; + TofHit[1].Esec = E3; + + TofHit[0].DT = DT1; + TofHit[1].DT = DT3; + + TofHit[0].theta_in = Theta1; + TofHit[1].theta_in = Theta3; + + TofHit[0].section = 1; + TofHit[1].section = 3; + } } + + // *** case 3 *** // if(E1!=-1 && E4!=-1){ - Beta1 = Beta_left; - Beta4 = Beta_right; + if(TofHit[0].isLorR==1 && TofHit[1].isLorR==2){ + TofHit[0].Esec = E1; + TofHit[1].Esec = E4; + + TofHit[0].theta_in = Theta1; + TofHit[1].theta_in = Theta4; + + TofHit[0].DT = DT1; + TofHit[1].DT = DT4; + + TofHit[0].section = 1; + TofHit[1].section = 4; + } + if(TofHit[0].isLorR==2 && TofHit[1].isLorR==1){ + TofHit[0].Esec = E4; + TofHit[1].Esec = E1; + + TofHit[0].theta_in = Theta4; + TofHit[1].theta_in = Theta1; + + TofHit[0].DT = DT4; + TofHit[1].DT = DT1; + + TofHit[0].section = 4; + TofHit[1].section = 1; + } } + + // *** case 4 *** // if(E2!=-1 && E3!=-1){ - Beta2 = Beta_left; - Beta3 = Beta_right; + if(TofHit[0].isLorR==1 && TofHit[1].isLorR==2){ + TofHit[0].Esec = E2; + TofHit[1].Esec = E3; + + TofHit[0].theta_in = Theta2; + TofHit[1].theta_in = Theta3; + + TofHit[0].DT = DT2; + TofHit[1].DT = DT3; + + TofHit[0].section = 2; + TofHit[1].section = 3; + } + if(TofHit[0].isLorR==2 && TofHit[1].isLorR==1){ + TofHit[0].Esec = E3; + TofHit[1].Esec = E2; + + TofHit[0].theta_in = Theta3; + TofHit[1].theta_in = Theta2; + + TofHit[0].DT = DT3; + TofHit[1].DT = DT2; + + TofHit[0].section = 3; + TofHit[1].section = 2; + } } + + // *** case 5 *** // if(E2!=-1 && E4!=-1){ - Beta2 = Beta_up; - Beta4 = Beta_down; + if(TofHit[0].isUorD==1 && TofHit[1].isUorD==2){ + TofHit[0].Esec = E2; + TofHit[1].Esec = E4; + + TofHit[0].theta_in = Theta2; + TofHit[1].theta_in = Theta4; + + TofHit[0].DT = DT2; + TofHit[1].DT = DT4; + + TofHit[0].section = 2; + TofHit[1].section = 4; + } + if(TofHit[0].isUorD==2 && TofHit[1].isUorD==1){ + TofHit[0].Esec = E4; + TofHit[1].Esec = E2; + + TofHit[0].theta_in = Theta4; + TofHit[1].theta_in = Theta2; + + TofHit[0].DT = DT4; + TofHit[1].DT = DT2; + + TofHit[0].section = 4; + TofHit[1].section = 2; + } } + + // *** case 6 *** // if(E3!=-1 && E4!=-1){ - Beta3 = Beta_up; - Beta4 = Beta_down; + if(TofHit[0].isUorD==1 && TofHit[1].isUorD==2){ + TofHit[0].Esec = E3; + TofHit[1].Esec = E4; + + TofHit[0].theta_in = Theta3; + TofHit[1].theta_in = Theta4; + + TofHit[0].DT = DT3; + TofHit[1].DT = DT4; + + TofHit[0].section = 3; + TofHit[1].section = 4; + } + if(TofHit[0].isUorD==2 && TofHit[1].isUorD==1){ + TofHit[0].Esec = E4; + TofHit[1].Esec = E3; + + TofHit[0].theta_in = Theta4; + TofHit[1].theta_in = Theta3; + + TofHit[0].DT = DT4; + TofHit[1].DT = DT3; + + TofHit[0].section = 4; + TofHit[1].section = 3; + } } - if(Beta1!=-1 && E1>0){ - E1 = E1 / fcorr_z_beta[0]->Eval(Beta1) * fcorr_z_beta[0]->Eval(Beta_norm); - E1 = E1 / fcorr_z_dt[0]->Eval(DT1) * fcorr_z_dt[0]->Eval(55); - } - if(Beta2!=-1 && E2>0){ - E2 = E2 / fcorr_z_beta[1]->Eval(Beta2) * fcorr_z_beta[1]->Eval(Beta_norm); - E2 = E2 / fcorr_z_dt[1]->Eval(DT2) * fcorr_z_dt[1]->Eval(55); - } - if(Beta3!=-1 && E3>0){ - E3 = E3 / fcorr_z_beta[2]->Eval(Beta3) * fcorr_z_beta[2]->Eval(Beta_norm); - E3 = E3 / fcorr_z_dt[2]->Eval(DT3) * fcorr_z_dt[2]->Eval(-55); - } - if(Beta4!=-1 && E4>0){ - E4 = E4 / fcorr_z_beta[3]->Eval(Beta4) * fcorr_z_beta[3]->Eval(Beta_norm); - E4 = E4 / fcorr_z_dt[3]->Eval(DT4) * fcorr_z_dt[3]->Eval(-55); - } + // *** spline correction *** // + for(int i=0; i<2; i++){ + int section = TofHit[i].section; + /*double drift_time; + if(section==1) drift_time = DT1; + if(section==2) drift_time = DT2; + if(section==3) drift_time = DT3; + if(section==4) drift_time = DT4;*/ - // Z calibration // - if(E1>0 && E2>0 && E3==-1 && E4==-1){ - Z1 = E1; - Z2 = E2; - Beta_Z1 = Beta1; - Beta_Z2 = Beta2; - } - if(E1>0 && E2==-1 && E3>0 && E4==-1){ - Z1 = E1; - Z2 = E3; - Beta_Z1 = Beta1; - Beta_Z2 = Beta3; - } - if(E1>0 && E2==-1 && E3==-1 && E4>0){ - Z1 = E1; - Z2 = E4; - Beta_Z1 = Beta1; - Beta_Z2 = Beta4; - } - if(E1==-1 && E2>0 && E3>0 && E4==-1){ - Z1 = E2; - Z2 = E3; - Beta_Z1 = Beta2; - Beta_Z2 = Beta3; - } - if(E1==-1 && E2>0 && E3==-1 && E4>0){ - Z1 = E2; - Z2 = E4; - Beta_Z1 = Beta2; - Beta_Z2 = Beta4; + double DT_eval; + if(section<3) DT_eval=55; + if(section>2) DT_eval=-55; + if(section>0){ + TofHit[i].Esec = TofHit[i].Esec / fcorr_z_beta[section-1]->Eval(TofHit[i].beta) * fcorr_z_beta[section-1]->Eval(Beta_norm); + + TofHit[i].Esec = TofHit[i].Esec / fcorr_z_dt[section-1]->Eval(TofHit[i].DT) * fcorr_z_dt[section-1]->Eval(DT_eval); + } } - if(E1==-1 && E2==-1 && E3>0 && E4>0){ - Z1 = E3; - Z2 = E4; - Beta_Z1 = Beta3; - Beta_Z2 = Beta4; + + + // *** Calculation Theta_out *** // + double Theta0 = 20.*deg; + double XA; + double ZA = 2328.; + double XC; + double ZG = 4434.; + double ZC; + double XMW3 = -1436.; + double ZMW3 = 8380; + double ZMW2 = 2576; + double X3lab = 0; + double Z3lab = 0;; + double Tilt = 14.*deg; + TVector3 vOut; + TVector3 vZ = TVector3(0,0,1); + TVector3 vC; + TVector3 InitPos[2]; + TVector3 InitDir[2]; + TVector3 FinalPos[2]; + for(int i=0; i<2; i++){ + XA = TofHit[i].DT; + XC = (XA+(ZG-ZA)*tan(TofHit[i].theta_in)) / (1-tan(Tilt)*tan(TofHit[i].theta_in)); + ZC = ZG + XC*tan(Tilt); + + X3lab = TofHit[i].x3*cos(Theta0) + XMW3; + Z3lab = TofHit[i].x3*sin(Theta0) + ZMW3; + TofHit[i].x3lab = X3lab; + TofHit[i].z3lab = Z3lab; + + InitPos[i] = TVector3(XA,0,ZA); + InitDir[i] = TVector3(sin(TofHit[i].theta_in),0,cos(TofHit[i].theta_in)); + FinalPos[i] = TVector3(X3lab,0,Z3lab); + + vC = TVector3(XC,0,ZC); + vOut = TVector3(X3lab-XC,0,Z3lab-ZC); + + double PathLength = vC.Mag() + vOut.Mag() + 74.; + PathLength = PathLength/1000.; + double angle = vZ.Angle(vOut); + + TofHit[i].velocity = PathLength/TofHit[i].tof; + TofHit[i].beta = TofHit[i].velocity * m/ns / NPUNITS::c_light; + TofHit[i].theta_out = angle; + TofHit[i].x2twim = XA + (ZMW2-ZA)*tan(TofHit[i].theta_in); } + Z1 = TofHit[0].Esec; + Z2 = TofHit[1].Esec; + + if(Z1>0 && Z2>0){ Z1 = fZff_p0 + fZff_p1*Z1 + fZff_p2*Z1*Z1; Z2 = fZff_p0 + fZff_p1*Z2 + fZff_p2*Z2*Z2; @@ -367,6 +603,30 @@ void Analysis::FissionFragmentAnalysis(){ iZsum = iZ1 + iZ2; } + double MagB = 2185*2.2/3584; + double Bx = 0; + double By = MagB/1000.; + double Bz = 0; + TVector3 B = TVector3(Bx,By,Bz); + double Leff = 2.067; + /*double rho1 = Leff/abs(2*sin(0.5*(TofHit[0].theta_out-TofHit[0].theta_in))*cos(Tilt-0.5*(TofHit[0].theta_out-TofHit[0].theta_in))); + double rho2 = Leff/abs(2*sin(0.5*(TofHit[1].theta_out-TofHit[1].theta_in))*cos(Tilt-0.5*(TofHit[1].theta_out-TofHit[1].theta_in))); + double Brho1 = MagB*rho1; + double Brho2 = MagB*rho2;*/ + + m_GladField->SetBfield(B); + m_GladField->SetZGlad(4.434*m); + m_GladField->SetLeff(2.067*m); + m_GladField->SetGladTiltAngle(14.*deg); + m_GladField->SetCentralTheta(20.*deg); + m_GladField->SetX_MWPC3(-1.436*m); + m_GladField->SetZ_MWPC3(8.380*m); + + double Brho1 = m_GladField->FindBrho(InitPos[0], InitDir[0], FinalPos[0]); + double Brho2 = m_GladField->FindBrho(InitPos[1], InitDir[1], FinalPos[1]); + + Beta_Z1 = TofHit[0].beta; + Beta_Z2 = TofHit[1].beta; Gamma1 = 1. / sqrt(1 - Beta_Z1 * Beta_Z1); Gamma2 = 1. / sqrt(1 - Beta_Z2 * Beta_Z2); @@ -377,8 +637,28 @@ void Analysis::FissionFragmentAnalysis(){ A2 = AoQ2 * iZ2; // *** Filling the Fission Fragment Tree *** // - SofFF->SetTOF(TOF_left); - SofFF->SetTOF(TOF_right); + SofFF->SetTOF(TofHit[0].tof); + SofFF->SetTOF(TofHit[1].tof); + SofFF->SetTofPosX(TofHit[0].x); + SofFF->SetTofPosX(TofHit[1].x); + SofFF->SetTofPosY(TofHit[0].y); + SofFF->SetTofPosY(TofHit[1].y); + SofFF->SetPlastic(TofHit[0].plastic); + SofFF->SetPlastic(TofHit[1].plastic); + + SofFF->SetPosX1(TofHit[0].x2twim); + SofFF->SetPosX1(TofHit[1].x2twim); + SofFF->SetPosX2(TofHit[0].x2); + SofFF->SetPosX2(TofHit[1].x2); + SofFF->SetPosX3(TofHit[0].x3lab); + SofFF->SetPosX3(TofHit[1].x3lab); + + SofFF->SetThetaIn(TofHit[0].theta_in); + SofFF->SetThetaIn(TofHit[1].theta_in); + SofFF->SetThetaOut(TofHit[0].theta_out); + SofFF->SetThetaOut(TofHit[1].theta_out); + + SofFF->SetBeta(Beta_Z1); SofFF->SetBeta(Beta_Z2); SofFF->SetGamma(Gamma1); @@ -388,19 +668,20 @@ void Analysis::FissionFragmentAnalysis(){ SofFF->SetZ(Z1); SofFF->SetZ(Z2); SofFF->SetAoQ(AoQ1); - SofFF->SetAoQ(AoQ1); + SofFF->SetAoQ(AoQ2); SofFF->SetA(A1); SofFF->SetA(A2); SofFF->SetBrho(Brho1); SofFF->SetBrho(Brho2); - SofFF->SetDT(DT1); - SofFF->SetDT(DT2); - SofFF->SetDT(DT3); - SofFF->SetDT(DT4); + SofFF->SetDT(TofHit[0].DT); + SofFF->SetDT(TofHit[1].DT); + SofFF->SetSection(TofHit[0].section); + SofFF->SetSection(TofHit[1].section); + SofFF->SetZsum(Zsum); - SofFF->SetIntZsum(iZsum); + SofFF->SetiZsum(iZsum); } } } @@ -452,6 +733,7 @@ void Analysis::BeamAnalysis(){ double Y_p1 = 12.362; Zbeam = Zbeam/(Y_p0 + Y_p1*YCC)*Y_p0; + // Z calibration // Zbeam = fZbeam_p0 + fZbeam_p1*Zbeam + fZbeam_p2*Zbeam*Zbeam; Zbeam = sqrt(Zbeam); @@ -524,11 +806,15 @@ void Analysis::InitParameter(){ fDCC = -10000; fK_LS2 = -30e-8; - fRunID = 12; + fBrho0 = 12.3255; + fRunID = 5; // Beam parameter // fZBeta_p0 = 1; fZBeta_p1 = 0; + fZbeam_p0 = 1651.57; + fZbeam_p1 = 0.0876127; + fZbeam_p2 = 4.02563e-6; // FF parameter // fZff_p0 = 2.80063; @@ -646,8 +932,11 @@ void Analysis::InitParameter(){ fZbeam_p0 = 186.892; fZbeam_p1 = 0.20739; fZbeam_p2 = 1.61797e-6; - } + if(fRunID==15){ + fBrho0 = 12.3352; + } + } //////////////////////////////////////////////////////////////////////////////// diff --git a/Projects/s455/Analysis.h b/Projects/s455/Analysis.h index db6b3ce1afe7f6f6a28e31bb7bbaa4e5dffc95da..7b54a0a4bbee29741c9b8141cff2593316d958b0 100644 --- a/Projects/s455/Analysis.h +++ b/Projects/s455/Analysis.h @@ -8,13 +8,13 @@ *****************************************************************************/ /***************************************************************************** - * Original Author: Pierre Morfouace contact address: pierre.morfouace@cea.fr * - * * - * Creation Date : 06/2021 * + * Original Author: P. Morfouace contact address: pierre.morfouace@cea.fr * + * * + * Creation Date : 06/2021 * * Last update : * *---------------------------------------------------------------------------* * Decription: * - * This class describe Sofia analysis project * + * This class describe Sofia analysis project * * * *---------------------------------------------------------------------------* * Comment: * @@ -35,6 +35,7 @@ #include"TSofMwpcPhysics.h" #include"TSofBeamID.h" #include"TSofFissionFragment.h" +#include "GladFieldMap.h" class Analysis: public NPL::VAnalysis{ public: @@ -50,6 +51,7 @@ class Analysis: public NPL::VAnalysis{ void ReInitValue(); void BeamAnalysis(); void FissionFragmentAnalysis(); + void BeamFragmentAnalysis(); static NPL::VAnalysis* Construct(); @@ -65,6 +67,7 @@ class Analysis: public NPL::VAnalysis{ TSofTofWPhysics* SofTofW; TSofBeamID* SofBeamID; TSofFissionFragment* SofFF; + GladFieldMap* m_GladField; int RunID; private: diff --git a/Projects/s455/RunToTreat.txt b/Projects/s455/RunToTreat.txt index 9c7e8b6b60cedc31fc59528a06318122575a34aa..12d77532d9964444403acbbceb4915ee3267c735 100644 --- a/Projects/s455/RunToTreat.txt +++ b/Projects/s455/RunToTreat.txt @@ -2,6 +2,9 @@ TTreeName RawTree RootFileName + %/media/sofia/s455/raw/run_raw_0367.root + %/media/sofia/s455/raw/run_raw_0368.root + %/media/sofia/s455/raw/run_raw_0369.root %/media/sofia/s455/raw/run_raw_0419.root %/media/sofia/s455/raw/run_raw_0422.root @@ -46,14 +49,14 @@ RootFileName %/media/sofia/s455/raw/run_raw_0399.root %% 189Pb - %/media/pierre/proton/raw/run_raw_0400.root + %/media/sofia/s455/raw/run_raw_0400.root %% 182Hg - /media/pierre/proton/raw/run_raw_0401.root + %/media/sofia/s455/raw/run_raw_0401.root %% 187Pb %/media/sofia/s455/raw/run_raw_0402.root - %/media/sofia/s455/raw/run_raw_0403.root + /media/sofia/s455/raw/run_raw_0403.root %% 184Hg %/media/sofia/s455/raw/run_raw_0404.root diff --git a/Projects/s455/calibration/SofSci/SofSci_physics.cal b/Projects/s455/calibration/SofSci/SofSci_physics.cal index 8778ee911a3131c0216c0cc52ad439b9029ffaff..b5d5734487c506da72a4aeca02535cd84b096df9 100644 --- a/Projects/s455/calibration/SofSci/SofSci_physics.cal +++ b/Projects/s455/calibration/SofSci/SofSci_physics.cal @@ -1,4 +1,4 @@ -SofSci_TOF2INV_V -8.0515 0.00737389 +SofSci_TOF2INV_V -8.04267 0.00737389 SofSci_LENGTH_S2 135.614 -SofSci_DET1_POSPAR 45.0 80.0 +SofSci_DET1_POSPAR 90 54.6 SofSci_DET2_POSPAR 943.287 86.652 diff --git a/Projects/s455/calibration/SofTrim/SofTrim_SectionAlign.cal b/Projects/s455/calibration/SofTrim/SofTrim_SectionAlign.cal index 37d3efaaa6803eb42745b0b186822b5f6513519a..80e81ae3897bce71419200ca0b7240f56bc754df 100644 --- a/Projects/s455/calibration/SofTrim/SofTrim_SectionAlign.cal +++ b/Projects/s455/calibration/SofTrim/SofTrim_SectionAlign.cal @@ -1,3 +1,3 @@ -SofTrim_SEC1_ALIGN -457.863 1.03809 +SofTrim_SEC1_ALIGN 14.3427 1.02007 SofTrim_SEC2_ALIGN 0 1 -SofTrim_SEC3_ALIGN -2599.29 1.18757 +SofTrim_SEC3_ALIGN -2905.47 1.2027 diff --git a/Projects/s455/calibration/SofTrim/spline/spline_section_angle_26062021.root b/Projects/s455/calibration/SofTrim/spline/spline_section_angle_26062021.root new file mode 100644 index 0000000000000000000000000000000000000000..d246cb81becf321f2c03df5e9da6fdb51e9eefe2 Binary files /dev/null and b/Projects/s455/calibration/SofTrim/spline/spline_section_angle_26062021.root differ diff --git a/Projects/s455/calibration/SofTrim/spline/spline_section_dt_26062021.root b/Projects/s455/calibration/SofTrim/spline/spline_section_dt_26062021.root new file mode 100644 index 0000000000000000000000000000000000000000..18385be0794ccf796409baf33ecd092ca8e3a903 Binary files /dev/null and b/Projects/s455/calibration/SofTrim/spline/spline_section_dt_26062021.root differ diff --git a/Projects/s455/calibration/SofTwim/SofTwim_Time.cal b/Projects/s455/calibration/SofTwim/SofTwim_Time.cal index bcb33e7b46c5441c975d672e7f73691cb98550e8..fad7b8f79823ee358cde7a9b7cf08040b8d95f26 100644 --- a/Projects/s455/calibration/SofTwim/SofTwim_Time.cal +++ b/Projects/s455/calibration/SofTwim/SofTwim_Time.cal @@ -1,70 +1,70 @@ -SofTwim_SEC1_ANODE1_TIME 130 -0.0060 -SofTwim_SEC1_ANODE2_TIME 130 -0.0060 -SofTwim_SEC1_ANODE3_TIME 130 -0.0060 -SofTwim_SEC1_ANODE4_TIME 130 -0.0060 -SofTwim_SEC1_ANODE5_TIME 130 -0.0060 -SofTwim_SEC1_ANODE6_TIME 130 -0.0060 -SofTwim_SEC1_ANODE7_TIME 130 -0.0060 -SofTwim_SEC1_ANODE8_TIME 130 -0.0060 -SofTwim_SEC1_ANODE9_TIME 130 -0.0060 -SofTwim_SEC1_ANODE10_TIME 130 -0.0060 -SofTwim_SEC1_ANODE11_TIME 130 -0.0060 -SofTwim_SEC1_ANODE12_TIME 130 -0.0060 -SofTwim_SEC1_ANODE13_TIME 130 -0.0060 -SofTwim_SEC1_ANODE14_TIME 130 -0.0060 -SofTwim_SEC1_ANODE15_TIME 130 -0.0060 -SofTwim_SEC1_ANODE16_TIME 130 -0.0060 +SofTwim_SEC1_ANODE1_TIME 140 -0.0067 +SofTwim_SEC1_ANODE2_TIME 140 -0.0067 +SofTwim_SEC1_ANODE3_TIME 140 -0.0067 +SofTwim_SEC1_ANODE4_TIME 140 -0.0067 +SofTwim_SEC1_ANODE5_TIME 140 -0.0067 +SofTwim_SEC1_ANODE6_TIME 140 -0.0067 +SofTwim_SEC1_ANODE7_TIME 140 -0.0067 +SofTwim_SEC1_ANODE8_TIME 140 -0.0067 +SofTwim_SEC1_ANODE9_TIME 140 -0.0067 +SofTwim_SEC1_ANODE10_TIME 140 -0.0067 +SofTwim_SEC1_ANODE11_TIME 140 -0.0067 +SofTwim_SEC1_ANODE12_TIME 140 -0.0067 +SofTwim_SEC1_ANODE13_TIME 140 -0.0067 +SofTwim_SEC1_ANODE14_TIME 140 -0.0067 +SofTwim_SEC1_ANODE15_TIME 140 -0.0067 +SofTwim_SEC1_ANODE16_TIME 140 -0.0067 -SofTwim_SEC2_ANODE1_TIME 130 -0.0060 -SofTwim_SEC2_ANODE2_TIME 130 -0.0060 -SofTwim_SEC2_ANODE3_TIME 130 -0.0060 -SofTwim_SEC2_ANODE4_TIME 130 -0.0060 -SofTwim_SEC2_ANODE5_TIME 130 -0.0060 -SofTwim_SEC2_ANODE6_TIME 130 -0.0060 -SofTwim_SEC2_ANODE7_TIME 130 -0.0060 -SofTwim_SEC2_ANODE8_TIME 130 -0.0060 -SofTwim_SEC2_ANODE9_TIME 130 -0.0060 -SofTwim_SEC2_ANODE10_TIME 130 -0.0060 -SofTwim_SEC2_ANODE11_TIME 130 -0.0060 -SofTwim_SEC2_ANODE12_TIME 130 -0.0060 -SofTwim_SEC2_ANODE13_TIME 130 -0.0060 -SofTwim_SEC2_ANODE14_TIME 130 -0.0060 -SofTwim_SEC2_ANODE15_TIME 130 -0.0060 -SofTwim_SEC2_ANODE16_TIME 130 -0.0060 +SofTwim_SEC2_ANODE1_TIME 140 -0.0067 +SofTwim_SEC2_ANODE2_TIME 140 -0.0067 +SofTwim_SEC2_ANODE3_TIME 140 -0.0067 +SofTwim_SEC2_ANODE4_TIME 140 -0.0067 +SofTwim_SEC2_ANODE5_TIME 140 -0.0067 +SofTwim_SEC2_ANODE6_TIME 140 -0.0067 +SofTwim_SEC2_ANODE7_TIME 140 -0.0067 +SofTwim_SEC2_ANODE8_TIME 140 -0.0067 +SofTwim_SEC2_ANODE9_TIME 140 -0.0067 +SofTwim_SEC2_ANODE10_TIME 140 -0.0067 +SofTwim_SEC2_ANODE11_TIME 140 -0.0067 +SofTwim_SEC2_ANODE12_TIME 140 -0.0067 +SofTwim_SEC2_ANODE13_TIME 140 -0.0067 +SofTwim_SEC2_ANODE14_TIME 140 -0.0067 +SofTwim_SEC2_ANODE15_TIME 140 -0.0067 +SofTwim_SEC2_ANODE16_TIME 140 -0.0067 -SofTwim_SEC3_ANODE1_TIME -130 0.0060 -SofTwim_SEC3_ANODE2_TIME -130 0.0060 -SofTwim_SEC3_ANODE3_TIME -130 0.0060 -SofTwim_SEC3_ANODE4_TIME -130 0.0060 -SofTwim_SEC3_ANODE5_TIME -130 0.0060 -SofTwim_SEC3_ANODE6_TIME -130 0.0060 -SofTwim_SEC3_ANODE7_TIME -130 0.0060 -SofTwim_SEC3_ANODE8_TIME -130 0.0060 -SofTwim_SEC3_ANODE9_TIME -130 0.0060 -SofTwim_SEC3_ANODE10_TIME -130 0.0060 -SofTwim_SEC3_ANODE11_TIME -130 0.0060 -SofTwim_SEC3_ANODE12_TIME -130 0.0060 -SofTwim_SEC3_ANODE13_TIME -130 0.0060 -SofTwim_SEC3_ANODE14_TIME -130 0.0060 -SofTwim_SEC3_ANODE15_TIME -130 0.0060 -SofTwim_SEC3_ANODE16_TIME -130 0.0060 +SofTwim_SEC3_ANODE1_TIME -140 0.0067 +SofTwim_SEC3_ANODE2_TIME -140 0.0067 +SofTwim_SEC3_ANODE3_TIME -140 0.0067 +SofTwim_SEC3_ANODE4_TIME -140 0.0067 +SofTwim_SEC3_ANODE5_TIME -140 0.0067 +SofTwim_SEC3_ANODE6_TIME -140 0.0067 +SofTwim_SEC3_ANODE7_TIME -140 0.0067 +SofTwim_SEC3_ANODE8_TIME -140 0.0067 +SofTwim_SEC3_ANODE9_TIME -140 0.0067 +SofTwim_SEC3_ANODE10_TIME -140 0.0067 +SofTwim_SEC3_ANODE11_TIME -140 0.0067 +SofTwim_SEC3_ANODE12_TIME -140 0.0067 +SofTwim_SEC3_ANODE13_TIME -140 0.0067 +SofTwim_SEC3_ANODE14_TIME -140 0.0067 +SofTwim_SEC3_ANODE15_TIME -140 0.0067 +SofTwim_SEC3_ANODE16_TIME -140 0.0067 -SofTwim_SEC4_ANODE1_TIME -130 0.0060 -SofTwim_SEC4_ANODE2_TIME -130 0.0060 -SofTwim_SEC4_ANODE3_TIME -130 0.0060 -SofTwim_SEC4_ANODE4_TIME -130 0.0060 -SofTwim_SEC4_ANODE5_TIME -130 0.0060 -SofTwim_SEC4_ANODE6_TIME -130 0.0060 -SofTwim_SEC4_ANODE7_TIME -130 0.0060 -SofTwim_SEC4_ANODE8_TIME -130 0.0060 -SofTwim_SEC4_ANODE9_TIME -130 0.0060 -SofTwim_SEC4_ANODE10_TIME -130 0.0060 -SofTwim_SEC4_ANODE11_TIME -130 0.0060 -SofTwim_SEC4_ANODE12_TIME -130 0.0060 -SofTwim_SEC4_ANODE13_TIME -130 0.0060 -SofTwim_SEC4_ANODE14_TIME -130 0.0060 -SofTwim_SEC4_ANODE15_TIME -130 0.0060 -SofTwim_SEC4_ANODE16_TIME -130 0.0060 +SofTwim_SEC4_ANODE1_TIME -140 0.0067 +SofTwim_SEC4_ANODE2_TIME -140 0.0067 +SofTwim_SEC4_ANODE3_TIME -140 0.0067 +SofTwim_SEC4_ANODE4_TIME -140 0.0067 +SofTwim_SEC4_ANODE5_TIME -140 0.0067 +SofTwim_SEC4_ANODE6_TIME -140 0.0067 +SofTwim_SEC4_ANODE7_TIME -140 0.0067 +SofTwim_SEC4_ANODE8_TIME -140 0.0067 +SofTwim_SEC4_ANODE9_TIME -140 0.0067 +SofTwim_SEC4_ANODE10_TIME -140 0.0067 +SofTwim_SEC4_ANODE11_TIME -140 0.0067 +SofTwim_SEC4_ANODE12_TIME -140 0.0067 +SofTwim_SEC4_ANODE13_TIME -140 0.0067 +SofTwim_SEC4_ANODE14_TIME -140 0.0067 +SofTwim_SEC4_ANODE15_TIME -140 0.0067 +SofTwim_SEC4_ANODE16_TIME -140 0.0067