modified ClassDetGeo.h, now support many array + recoil sets

This commit is contained in:
Ryan Tang 2024-04-01 19:24:47 -04:00
parent 806a7124a4
commit 4f0b24f342
2 changed files with 94 additions and 69 deletions

View File

@ -25,7 +25,7 @@ struct Array{
double eSigma; /// intrinsic energy resolution MeV double eSigma; /// intrinsic energy resolution MeV
double zSigma; /// intrinsic position resolution mm double zSigma; /// intrinsic position resolution mm
bool detFaceOut; ///detector_facing_Out_or_In bool detFaceOut; ///detector_facing_Out_or_In
std::vector<double> pos; /// near position in meter std::vector<double> pos; /// realtive position in meter
int nDet, mDet; /// nDet = number of different pos, mDet, number of same pos int nDet, mDet; /// nDet = number of different pos, mDet, number of same pos
std::vector<double> detPos; ///absolute position of detector std::vector<double> detPos; ///absolute position of detector
@ -46,7 +46,10 @@ struct Array{
zMax = TMath::Max(detPos.front(), detPos.back()) + (firstPos > 0 ? detLength : 0); zMax = TMath::Max(detPos.front(), detPos.back()) + (firstPos > 0 ? detLength : 0);
} }
void PrintArray() const{ void Print() const{
printf("------------------------------- Array\n");
for(int i = 0; i < nDet ; i++){ for(int i = 0; i < nDet ; i++){
if( firstPos > 0 ){ if( firstPos > 0 ){
printf("%d, %8.2f mm - %8.2f mm \n", i, detPos[i], detPos[i] + detLength); printf("%d, %8.2f mm - %8.2f mm \n", i, detPos[i], detPos[i] + detLength);
@ -65,6 +68,38 @@ struct Array{
}; };
struct Auxillary{
//========== recoil
double detPos; //
double outerRadius;
double innerRadius;
bool isCoincident;
double detPos1 = 0; // virtual recoil
double detPos2 = 0; // virtual recoil
//========== enum
double elumPos1 = 0;
double elumPos2 = 0;
void Print() const {
printf("------------------------------- Auxillary\n");
printf(" Recoil detector pos: %8.2f mm, radius: %6.2f - %6.2f mm \n", detPos, innerRadius, outerRadius);
if( elumPos1 != 0 || elumPos2 != 0 || detPos1 != 0 || detPos2 != 0){
printf("=================================== Virtual Detectors\n");
if( elumPos1 != 0 ) printf(" Elum 1 pos.: %f mm \n", elumPos1);
if( elumPos2 != 0 ) printf(" Elum 2 pos.: %f mm \n", elumPos2);
if( detPos1 != 0 ) printf(" Recoil 1 pos.: %f mm \n", detPos1);
if( detPos2 != 0 ) printf(" Recoil 2 pos.: %f mm \n", detPos2);
printf("=====================================================\n");
}
}
};
class DetGeo { class DetGeo {
public: public:
@ -75,28 +110,20 @@ public:
double Bfield; /// T double Bfield; /// T
int BfieldSign ; /// sign of B-field int BfieldSign ; /// sign of B-field
double BfieldTheta; /// rad, 0 = z-axis, pi/2 = y axis, pi = -z axis
double bore; /// bore , mm double bore; /// bore , mm
double recoilPos; /// recoil, downstream
double recoilInnerRadius; /// radius recoil inner
double recoilOuterRadius; /// radius recoil outter
double recoilPos1, recoilPos2; /// imaginary recoils short numSet; /// number of array and aux
double elumPos1, elumPos2; /// imaginary elum, only sensitive to light recoil double zMin, zMax; /// total range span of all arrays
//===================1st array
Array array[2];
double zMin, zMax; /// range of detectors
bool isCoincidentWithRecoil;
bool LoadDetectorGeo(TString fileName, bool verbose = true); bool LoadDetectorGeo(TString fileName, bool verbose = true);
bool LoadDetectorGeo(TMacro * macro, bool verbose = true); bool LoadDetectorGeo(TMacro * macro, bool verbose = true);
void PrintWithoutArray() ; //=================== array
void Print( bool printAll = true) ; std::vector<Array> array;
std::vector<Auxillary> aux;
void Print( bool printAll = false) ;
private: private:
@ -129,7 +156,7 @@ inline bool DetGeo::LoadDetectorGeo(TMacro * macro, bool verbose){
TList * haha = macro->GetListOfLines(); TList * haha = macro->GetListOfLines();
int numLine = (haha)->GetSize(); int numLine = (haha)->GetSize();
for( int i = 0; i < 2 ; i++) array[i].pos.clear(); // for( int i = 0; i < 2 ; i++) array[i].pos.clear();
int detFlag = 0; int detFlag = 0;
int detLine = 0; int detLine = 0;
@ -156,31 +183,38 @@ inline bool DetGeo::LoadDetectorGeo(TMacro * macro, bool verbose){
Bfield = atof(str[0].c_str()); Bfield = atof(str[0].c_str());
BfieldSign = Bfield > 0 ? 1: -1; BfieldSign = Bfield > 0 ? 1: -1;
} }
if ( detLine == 1 ) BfieldTheta = atof(str[0].c_str()); if ( detLine == 1 ) bore = atof(str[0].c_str());
if ( detLine == 2 ) bore = atof(str[0].c_str()); if ( detLine == 2 ) {
if ( detLine == 3 ) recoilPos = atof(str[0].c_str()); numSet = atoi(str[0].c_str());
if ( detLine == 4 ) recoilInnerRadius = atof(str[0].c_str()); for( int i = 0; i < numSet; i++){
if ( detLine == 5 ) recoilOuterRadius = atof(str[0].c_str()); array.push_back(Array());
if ( detLine == 6 ) isCoincidentWithRecoil = str[0] == "false" ? false: true; aux.push_back(Auxillary());
if ( detLine == 7 ) recoilPos1 = atof(str[0].c_str()); }
if ( detLine == 8 ) recoilPos2 = atof(str[0].c_str()); }
if ( detLine == 9 ) elumPos1 = atof(str[0].c_str());
if ( detLine == 10 ) elumPos2 = atof(str[0].c_str());
} }
if( detFlag > 0){ if( detFlag > 0){
unsigned short ID = detFlag - 1; unsigned short ID = detFlag - 1;
if ( detLine == 0 ) array[ID].enable = str[0] == "true" ? true : false; if ( detLine == 0 ) array[ID].enable = str[0] == "true" ? true : false;
if ( detLine == 1 ) array[ID].detPerpDist = atof(str[0].c_str()); if ( detLine == 1 ) aux[ID].detPos = atof(str[0].c_str());
if ( detLine == 2 ) array[ID].detWidth = atof(str[0].c_str()); if ( detLine == 2 ) aux[ID].innerRadius = atof(str[0].c_str());
if ( detLine == 3 ) array[ID].detLength = atof(str[0].c_str()); if ( detLine == 3 ) aux[ID].outerRadius = atof(str[0].c_str());
if ( detLine == 4 ) array[ID].blocker = atof(str[0].c_str()); if ( detLine == 4 ) aux[ID].isCoincident = str[0] == "true" ? true : false;
if ( detLine == 5 ) array[ID].firstPos = atof(str[0].c_str()); if ( detLine == 5 ) aux[ID].detPos1 = atof(str[0].c_str());
if ( detLine == 6 ) array[ID].eSigma = atof(str[0].c_str()); if ( detLine == 6 ) aux[ID].detPos2 = atof(str[0].c_str());
if ( detLine == 7 ) array[ID].zSigma = atof(str[0].c_str()); if ( detLine == 7 ) aux[ID].elumPos1 = atof(str[0].c_str());
if ( detLine == 8 ) array[ID].detFaceOut = str[0] == "Out" ? true : false; if ( detLine == 8 ) aux[ID].elumPos2 = atof(str[0].c_str());
if ( detLine == 9 ) array[ID].mDet = atoi(str[0].c_str()); if ( detLine == 9 ) array[ID].detPerpDist = atof(str[0].c_str());
if ( detLine >= 10 ) array[ID].pos.push_back(atof(str[0].c_str())); if ( detLine == 10 ) array[ID].detWidth = atof(str[0].c_str());
if ( detLine == 11 ) array[ID].detLength = atof(str[0].c_str());
if ( detLine == 12 ) array[ID].blocker = atof(str[0].c_str());
if ( detLine == 13 ) array[ID].firstPos = atof(str[0].c_str());
if ( detLine == 14 ) array[ID].eSigma = atof(str[0].c_str());
if ( detLine == 15 ) array[ID].zSigma = atof(str[0].c_str());
if ( detLine == 16 ) array[ID].detFaceOut = str[0] == "Out" ? true : false;
if ( detLine == 17 ) array[ID].mDet = atoi(str[0].c_str());
if ( detLine >= 18 ) array[ID].pos.push_back(atof(str[0].c_str()));
} }
detLine ++; detLine ++;
@ -205,37 +239,21 @@ inline bool DetGeo::LoadDetectorGeo(TMacro * macro, bool verbose){
} }
inline void DetGeo::PrintWithoutArray(){
printf("=====================================================\n");
printf(" B-field: %8.2f T, %s\n", Bfield, Bfield > 0 ? "out of plan" : "into plan");
printf(" B-field Theta : %6.2f deg \n", BfieldTheta);
if( BfieldTheta != 0.0 ) printf(" +---- field angle != 0 is not supported!!! \n");
printf(" Recoil detector pos: %8.2f mm, radius: %6.2f - %6.2f mm \n", recoilPos, recoilInnerRadius, recoilOuterRadius);
if( elumPos1 != 0 || elumPos2 != 0 || recoilPos1 != 0 || recoilPos2 != 0){
printf("=================================== Auxillary/Imaginary Detectors\n");
}
if( elumPos1 != 0 ) printf(" Elum 1 pos.: %f mm \n", elumPos1);
if( elumPos2 != 0 ) printf(" Elum 2 pos.: %f mm \n", elumPos2);
if( recoilPos1 != 0 ) printf(" Recoil 1 pos.: %f mm \n", recoilPos1);
if( recoilPos2 != 0 ) printf(" Recoil 2 pos.: %f mm \n", recoilPos2);
printf("=====================================================\n");
}
inline void DetGeo::Print(bool printAll){ inline void DetGeo::Print(bool printAll){
PrintWithoutArray(); printf("#####################################################\n");
printf(" B-field : %8.2f T, %s\n", Bfield, Bfield > 0 ? "out of plan" : "into plan");
for( int i = 0; i < 2 ; i++){ printf(" Bore : %8.2f mm\n", bore);
printf(" No. of det. Set. : %u \n", numSet);
for( int i = 0; i < numSet ; i++){
printf("================================= %d-th Detector Info (%s)\n", i, array[i].enable ? "enabled" : "disabled");
if( printAll || array[i].enable ) { if( printAll || array[i].enable ) {
printf("-----------------------------------%d-th Detector Position \n", i); array[i].Print();
array[i].PrintArray(); aux[i].Print();
} }
} }
printf("=====================================================\n"); printf("#####################################################\n");
} }

View File

@ -1,8 +1,10 @@
-3.00 //Bfield_[T] -3.00 //Bfield_[T]
0.00 //Bfield_direction_to_z-axis_[deg]_should_not_use
462.5 //bore_[mm] 462.5 //bore_[mm]
2 //number_of_array+recoil
#===============1st_Array + Recoil
true ////is_this_array_exist_or_use_for_Simulation
1000 //recoil_position_+_for_downstream_[mm] 1000 //recoil_position_+_for_downstream_[mm]
10.0 //inner_radius_of_recoil_detector_[mm] 10.0 //inner_radius_of_recoil_detector_[mm]
40.2 //outter_radius_of_recoil_detector_[mm] 40.2 //outter_radius_of_recoil_detector_[mm]
@ -11,9 +13,6 @@ false //is_coincident_with_recoil
0 //Recoil_2_position_[mm] 0 //Recoil_2_position_[mm]
0.00 //Elum_1_position_[mm]_(just_another_recoil_detector_but_for_light_recoil) 0.00 //Elum_1_position_[mm]_(just_another_recoil_detector_but_for_light_recoil)
0.00 //Elum_2_position_[mm]_when_Elum=0_disable_tree_branch 0.00 //Elum_2_position_[mm]_when_Elum=0_disable_tree_branch
#===============1st_Array
true ////is_this_array_exist_or_use_for_Simulation
11.5 //distance_from_axis_[mm] 11.5 //distance_from_axis_[mm]
10.0 //width_of_detector_[mm] 10.0 //width_of_detector_[mm]
50 //length_of_detector_[mm] 50 //length_of_detector_[mm]
@ -30,8 +29,16 @@ Out //detector_facing_Out_or_In
235.8 //5th_det 235.8 //5th_det
294.0 294.0
#===============2nd_Array #===============2nd_Array + Recoil
true //is_this_array_exist_or_use_for_Simulation false //is_this_array_exist_or_use_for_Simulation
1000 //recoil_position_+_for_downstream_[mm]
10.0 //inner_radius_of_recoil_detector_[mm]
40.2 //outter_radius_of_recoil_detector_[mm]
false //is_coincident_with_recoil
0 //Recoil_1_position_[mm]_when_0_disable_tree_branch
0 //Recoil_2_position_[mm]
0.00 //Elum_1_position_[mm]_(just_another_recoil_detector_but_for_light_recoil)
0.00 //Elum_2_position_[mm]_when_Elum=0_disable_tree_branch
11.5 //distance_from_axis_[mm] 11.5 //distance_from_axis_[mm]
10.0 //width_of_detector_[mm] 10.0 //width_of_detector_[mm]
50 //length_of_detector_[mm] 50 //length_of_detector_[mm]