Skip to content

Commit

Permalink
CMAkeList now use C17 and compile test_DisplayReco.cpp, reconstructio…
Browse files Browse the repository at this point in the history
…nNLLmethod.cpp fixwd to use mm with TGeoEdepSimGeometry
  • Loading branch information
antoniogioiosa committed Sep 19, 2024
1 parent 2d6c198 commit 2da4c70
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 55 deletions.
5 changes: 4 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
project(SandReco LANGUAGES CXX VERSION 01.00.00)

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_PLATFORM_INDEPENDENT_CODE ON)
Expand Down Expand Up @@ -82,6 +82,9 @@ target_link_libraries(ReconstructNLLmethod Struct Utils SANDRecoUtils)
# add_executable(test_reconstructNLL tests/test_reconstructionNLL.cpp)
# target_link_libraries(test_reconstructNLL Struct Utils SANDRecoUtils)
# ----
# Creates DisplayReco executable for testing.
add_executable(test_DisplayReco tests/test_DisplayReco.cpp)
target_link_libraries(test_DisplayReco Struct Utils)

# Creates Analyze executable.
add_executable(Analyze src/analysis.cpp)
Expand Down
24 changes: 12 additions & 12 deletions src/reconstructionNLLmethod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,14 +242,14 @@ std::string GetVolumeFromCoordinates(std::string units, double x, double y, doub
std::cout<<"GEO not initialized in "<<__FILE__<<" "<<__LINE__<<"\n";
throw "";
}
if(units == "mm"){ // convert to cm
x = x * 0.1;
y = y * 0.1;
z = z * 0.1;
}else if(units == "m"){ // convert to cm
x = x * 100.;
y = y * 100.;
z = z * 100.;
if(units == "cm"){ // convert to mm
x = x * 10.;
y = y * 10.;
z = z * 10.;
}else if(units == "m"){ // convert to mm
x = x * 1000.;
y = y * 1000.;
z = z * 1000.;
}

auto navigator = geo->GetCurrentNavigator();
Expand All @@ -275,9 +275,9 @@ bool IsInFiducialVolume(std::string units, double x, double y, double z){
if(units == "m"){ // convert to mm
x = x*1e3; y = y*1e3; z = z*1e3;
}else if(units == "cm"){ // convert to mm
x = x*1e2; y = y*1e2; z = z*1e2;
x = x*1e1; y = y*1e1; z = z*1e1;
}else{}
// std::cout << "volName : "<< volName_ << "\n";
std::cout << "volName : "<< volName_ << "\n";
if(volName_.Contains("Frame")){
return false;
}else if(volName_.Contains("_A")){ // one of 2 supermod A
Expand Down Expand Up @@ -1167,8 +1167,8 @@ int main(int argc, char* argv[]){
TTree* tEdep = (TTree*)fEDep.Get("EDepSimEvents");

LOG("I","Open TGeoManager from edepsim file");
// geo = (TGeoManager*)fEDep.Get("EDepSimGeometry");
geo = TGeoManager::Import("/storage/gpfs_data/neutrino/users/gi/dunendggd/SAND_opt3_DRIFT1.root");
geo = (TGeoManager*)fEDep.Get("EDepSimGeometry");
//geo = TGeoManager::Import("/storage/gpfs_data/neutrino/users/gi/dunendggd/SAND_opt3_DRIFT1.root");

TTree* tDigit = (TTree*)fDigit.Get("tDigit");

Expand Down
93 changes: 51 additions & 42 deletions tests/test_DisplayReco.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ TCanvas* cev = 0;
TCanvas* cpr = 0;

std::vector<dg_cell>* vec_cell = new std::vector<dg_cell>;
std::vector<dg_tube>* vec_tube = new std::vector<dg_tube>;
std::vector<dg_wire>* vec_wire = new std::vector<dg_wire>;
std::vector<track>* vec_tr = new std::vector<track>;
std::vector<cluster>* vec_cl = new std::vector<cluster>;
Expand All @@ -119,24 +118,28 @@ const char* path_endcapL_template =

const char* path_GRAIN =
"volWorld_PV_1/rockBox_lv_PV_0/volDetEnclosure_PV_0/volSAND_PV_0/"
"MagIntVol_volume_PV_0/sand_inner_volume_PV_0/GRAIN_lv_PV_0/"
"GRAIN_Ext_vessel_outer_layer_lv_PV_0/"
"GRAIN_Honeycomb_layer_lv_PV_0/GRAIN_Ext_vessel_inner_layer_lv_PV_0/"
"GRAIN_gap_between_vessels_lv_PV_0/"
"GRAIN_inner_vessel_lv_PV_0/GRAIN_LAr_lv_PV_0";

const char* path_GRIAN =
"volWorld_PV_1/rockBox_lv_PV_0/volDetEnclosure_PV_0/volSAND_PV_0/"
"MagIntVol_volume_PV_0/sand_inner_volume_PV_0/GRAIN_lv_PV_0/"
"GRAIN_Ext_vessel_outer_layer_lv_PV_0/"
"GRAIN_Honeycomb_layer_lv_PV_0/GRAIN_Ext_vessel_inner_layer_lv_PV_0/"
"GRAIN_gap_between_vessels_lv_PV_0/"
"GRAIN_inner_vessel_lv_PV_0/GRIAN_LAr_lv_PV_0";
"MagIntVol_volume_PV_0/sand_inner_volume_PV_0/GRAIN_lv_PV_0/";

// const char* path_GRAIN =
// "volWorld_PV_1/rockBox_lv_PV_0/volDetEnclosure_PV_0/volSAND_PV_0/"
// "MagIntVol_volume_PV_0/sand_inner_volume_PV_0/GRAIN_lv_PV_0/"
// "GRAIN_Ext_vessel_outer_layer_lv_PV_0/"
// "GRAIN_Honeycomb_layer_lv_PV_0/GRAIN_Ext_vessel_inner_layer_lv_PV_0/"
// "GRAIN_gap_between_vessels_lv_PV_0/"
// "GRAIN_inner_vessel_lv_PV_0/GRAIN_LAr_lv_PV_0";

// const char* path_GRIAN =
// "volWorld_PV_1/rockBox_lv_PV_0/volDetEnclosure_PV_0/volSAND_PV_0/"
// "MagIntVol_volume_PV_0/sand_inner_volume_PV_0/GRAIN_lv_PV_0/"
// "GRAIN_Ext_vessel_outer_layer_lv_PV_0/"
// "GRAIN_Honeycomb_layer_lv_PV_0/GRAIN_Ext_vessel_inner_layer_lv_PV_0/"
// "GRAIN_gap_between_vessels_lv_PV_0/"
// "GRAIN_inner_vessel_lv_PV_0/GRIAN_LAr_lv_PV_0";

const char* barrel_mod_vol_name = "ECAL_lv_PV";
const char* endcap_mod_vol_name = "ECAL_end_lv_PV";
const char* GRAIN_vol_name = "GRAIN_LAr_lv_PV";
const char* GRIAN_vol_name = "GRIAN_LAr_lv_PV";
//const char* GRIAN_vol_name = "GRIAN_LAr_lv_PV";

} // namespace display

Expand Down Expand Up @@ -171,14 +174,8 @@ void init()
if (tEvent) tEvent->SetBranchAddress("event", &evt);

if (tDigit) tEdep->AddFriend(tDigit);
//if (tDigit) tDigit->SetBranchAddress("dg_cell", &vec_cell);
if(geo->FindVolumeFast("STTtracker_PV")){
//stt based digitization
if (tDigit) tDigit->SetBranchAddress("dg_tube", &vec_tube);
}else{
//drift based digitization
if (tDigit) tDigit->SetBranchAddress("dg_wire", &vec_wire);
}
if (tDigit) tDigit->SetBranchAddress("dg_cell", &vec_cell);
if (tDigit) tDigit->SetBranchAddress("dg_wire", &vec_wire);

if (tReco) tEdep->AddFriend(tReco);
if (tReco) tReco->SetBranchAddress("track", &vec_tr);
Expand Down Expand Up @@ -281,7 +278,9 @@ void init()
for (int k = 0; k < nCel; k++) {

int index = i * (nLay * nCel) + j * (nCel) + k;
int id = k + 100 * j + 1000 * i;
// detID == 2 for barrel as in KLOE
int id = sand_reco::ecal::decoder::EncodeID(2, i, j, k);
//int id = k + 100 * j + 1000 * i;

int local_index = j * nCel + k;

Expand Down Expand Up @@ -341,7 +340,10 @@ void init()

for (int j = 0; j < nLay_ec; j++) {
for (int k = 0; k < nCel_ec; k++) {
int id = k + 100 * j + 1000 * 30;
// detID == 3 for right endcap as in KLOE
// modID == 30
int id = sand_reco::ecal::decoder::EncodeID(3, 30, j, k);
//int id = k + 100 * j + 1000 * 30;

calocell[id].id = id;

Expand Down Expand Up @@ -385,7 +387,10 @@ void init()

for (int j = 0; j < nLay_ec; j++) {
for (int k = 0; k < nCel_ec; k++) {
int id = k + 100 * j + 1000 * 40;
// detID == 1 for left endcap as in KLOE
// modID == 40
int id = sand_reco::ecal::decoder::EncodeID(1, 40, j, k);
//int id = k + 100 * j + 1000 * 40;

calocell[id].id = id;

Expand Down Expand Up @@ -427,15 +432,17 @@ void init()
}

TGeoVolume* GRAIN_vol = geo->FindVolumeFast(GRAIN_vol_name);
if(!GRAIN_vol) GRAIN_vol = geo->FindVolumeFast(GRIAN_vol_name);
// if(!GRAIN_vol) GRAIN_vol = geo->FindVolumeFast(GRIAN_vol_name);

TGeoEltu* grain = (TGeoEltu*)GRAIN_vol->GetShape();

GRAIN_dz = grain->GetRmin();
GRAIN_dy = grain->GetRmax();
GRAIN_dx = grain->GetDz();

if(geo->cd(path_GRAIN) == kFALSE) geo->cd(path_GRIAN);
geo->cd(path_GRAIN);

// if(geo->cd(path_GRAIN) == kFALSE) geo->cd(path_GRIAN);

dummyLoc[0] = 0.;
dummyLoc[1] = 0.;
Expand Down Expand Up @@ -534,8 +541,8 @@ void showEde(int index, int frame1, int frame2, bool over)
same = "same";
t->GetEntry(index);

//for (auto det : {"Straw", "EMCalSci", "LArHit","DriftVolume"}) {
for (auto det : {"EMCalSci", "LArHit","DriftVolume"}) {
for (auto det : {"Straw", "EMCalSci", "LArHit","DriftVolume"}) {
//for (auto det : {"EMCalSci", "LArHit","DriftVolume"}) {
for (auto& h : ev->SegmentDetectors[det]) {
TLine* lzx =
new TLine(h.Start.Z(), h.Start.X(), h.Stop.Z(), h.Stop.X());
Expand Down Expand Up @@ -624,17 +631,17 @@ void show(int index)
}

if (showdig) {
for (unsigned int i = 0; i < vec_tube->size(); i++) {
if (vec_tube->at(i).hor) {
TMarker* m = new TMarker(vec_tube->at(i).z, vec_tube->at(i).y, 6);
cev->cd(1);
m->Draw();
} else {
TMarker* m = new TMarker(vec_tube->at(i).z, vec_tube->at(i).x, 6);
cev->cd(2);
m->Draw();
}
}
// for (unsigned int i = 0; i < vec_tube->size(); i++) {
// if (vec_tube->at(i).hor) {
// TMarker* m = new TMarker(vec_tube->at(i).z, vec_tube->at(i).y, 6);
// cev->cd(1);
// m->Draw();
// } else {
// TMarker* m = new TMarker(vec_tube->at(i).z, vec_tube->at(i).x, 6);
// cev->cd(2);
// m->Draw();
// }
// }

for (unsigned int i = 0; i < vec_wire->size(); i++) {
if (vec_wire->at(i).hor) {
Expand All @@ -654,7 +661,9 @@ void show(int index)
TGraph* gr = new TGraph(4, calocell[id].Z, calocell[id].Y);

gr->SetFillColor(kBlack);
if (id < 25000)
// barrel cell should be between 200000 and 300000
if (id >= 200000 && id < 300000)
//if (id < 25000)
cev->cd(1);
else
cev->cd(2);
Expand Down

0 comments on commit 2da4c70

Please sign in to comment.