From e6013c0e389a504f2d40396c63039b3dfac45f74 Mon Sep 17 00:00:00 2001 From: Kodai Okawa Date: Tue, 8 Mar 2022 01:11:08 +0900 Subject: [PATCH] [mod] raw tree --- include/{ChannelMap.hh => MapReader.hh} | 21 ++++++++----- include/TCordferBranchManager.hh | 4 +-- include/TCordferMapBranch.hh | 11 +++---- include/TCordferRawBranch.hh | 1 + main.cpp | 1 - recipe/recipe_si26a.yml | 5 ++-- src/CMakeLists.txt | 2 +- src/{ChannelMap.cpp => MapReader.cpp} | 6 ++-- src/TCordferBranchManager.cpp | 40 +++++++++---------------- src/TCordferMapBranch.cpp | 2 +- 10 files changed, 45 insertions(+), 48 deletions(-) rename include/{ChannelMap.hh => MapReader.hh} (59%) rename src/{ChannelMap.cpp => MapReader.cpp} (94%) diff --git a/include/ChannelMap.hh b/include/MapReader.hh similarity index 59% rename from include/ChannelMap.hh rename to include/MapReader.hh index 8e7e701..05c4761 100644 --- a/include/ChannelMap.hh +++ b/include/MapReader.hh @@ -1,27 +1,34 @@ -#ifndef _CHANNELMAP_HH_ -#define _CHANNELMAP_HH_ +#ifndef _MapReader_HH_ +#define _MapReader_HH_ #include #include #include -#include +#include using namespace std; -class ChannelMap +class MapReader { private: TString filename; public: - ChannelMap(){} - ChannelMap(TString in_filename){ + MapReader(){} + MapReader(TString in_filename){ filename = in_filename; + + FileStat_t info; + if(gSystem->GetPathInfo(filename.Data(), info) != 0){ + cerr << "EROOR: in yaml File, '" << filename.Data() << "' does not exist." << endl; + exit(0); + } + ReadMap(); } - ~ChannelMap(){} + ~MapReader(){} Int_t size = 0; vector< vector > segment_id; diff --git a/include/TCordferBranchManager.hh b/include/TCordferBranchManager.hh index 006aa87..e06c132 100644 --- a/include/TCordferBranchManager.hh +++ b/include/TCordferBranchManager.hh @@ -10,7 +10,7 @@ #include #include -#include "ChannelMap.hh" +#include "MapReader.hh" #include "CalibParamReader.hh" #include "TCordferRawBranch.hh" #include "TCordferMapBranch.hh" @@ -34,7 +34,7 @@ class TCordferBranchManager vector branch; vector mbranch; vector cbranch; - unordered_map mapping; + Int_t rmapping[100] = {-1}; //max segment_id(geo) number unordered_map mmapping; unordered_map cmapping; unordered_map muxmapping; diff --git a/include/TCordferMapBranch.hh b/include/TCordferMapBranch.hh index 33475b9..bd87a4a 100644 --- a/include/TCordferMapBranch.hh +++ b/include/TCordferMapBranch.hh @@ -18,20 +18,21 @@ class TCordferMapBranch TCordferMapBranch(TString bname, Int_t bsize){ name = bname; size = bsize; + MemorySet(); } ~TCordferMapBranch(){} bool adc; - Int_t size; //use - Int_t *bra_val; //use - vector segment_id; //use - vector channel; //use + Int_t size; + Int_t *bra_val; + vector segment_id; + vector channel; TString GetBranchName(){ return name; } void MemorySet(){ bra_val = new Int_t[size]; } void FreeMemory(){ delete[] bra_val; } - void CopyMapInfo(vector seg, vector ch); + void SetMapInfo(vector seg, vector ch); }; #endif diff --git a/include/TCordferRawBranch.hh b/include/TCordferRawBranch.hh index 298758d..0ac44f1 100644 --- a/include/TCordferRawBranch.hh +++ b/include/TCordferRawBranch.hh @@ -28,6 +28,7 @@ class TCordferRawBranch size = bsize; detector_id = det_id; nhit = bnhit; + TwoDimMemorySet(); } ~TCordferRawBranch(){} diff --git a/main.cpp b/main.cpp index b01e90b..0e8e10c 100644 --- a/main.cpp +++ b/main.cpp @@ -33,7 +33,6 @@ Int_t main(Int_t argc, Char_t **argv) //map segment_id and branch branch_manager->CreateMapping(); - cout << "test" << endl; //start to decode using anaroot TArtEventStore *estore = new TArtEventStore(); diff --git a/recipe/recipe_si26a.yml b/recipe/recipe_si26a.yml index 733ea31..dd87ba8 100644 --- a/recipe/recipe_si26a.yml +++ b/recipe/recipe_si26a.yml @@ -7,11 +7,11 @@ raw_tree: map_tree: name: "mtree" description: "mapping data tree" - in_use: on + in_use: off calib_tree: name: "ctree" description: "calibrate data tree" - in_use: on + in_use: off # mapfile and calibration file information @@ -109,3 +109,4 @@ setup: maxhit: 12 - name: mhtdc_nhit channel: 64 + diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9281a02..3f3a7f6 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,6 +1,6 @@ add_library(sources SHARED CommandlineReader.cpp - ChannelMap.cpp + MapReader.cpp CalibParamReader.cpp CalibrationManager.cpp TCordferRawBranch.cpp diff --git a/src/ChannelMap.cpp b/src/MapReader.cpp similarity index 94% rename from src/ChannelMap.cpp rename to src/MapReader.cpp index 95ef6d4..3cb65c2 100644 --- a/src/ChannelMap.cpp +++ b/src/MapReader.cpp @@ -6,12 +6,12 @@ #include -#include +#include using namespace std; -void ChannelMap::ReadMap() { +void MapReader::ReadMap() { ifstream fin(filename.Data()); string buf; @@ -64,7 +64,7 @@ void ChannelMap::ReadMap() { } -void ChannelMap::ReadMap(TString in_filename){ +void MapReader::ReadMap(TString in_filename){ SetMapFile(in_filename); ReadMap(); } diff --git a/src/TCordferBranchManager.cpp b/src/TCordferBranchManager.cpp index 1d3ec71..177dadc 100644 --- a/src/TCordferBranchManager.cpp +++ b/src/TCordferBranchManager.cpp @@ -97,8 +97,6 @@ void TCordferBranchManager::CreateRawBranch(){ Int_t det_id = setup[i]["detector_id"].as(); if(det_id != 10){ - //if(bname != "mhtdc"){ - //if(string(bname.Data()).find("mhtdc") == string::npos){ Int_t nch = setup[i]["channel"].as(); TCordferRawBranch *raw_branch = new TCordferRawBranch(bname, seg_id, nch, det_id); @@ -107,14 +105,13 @@ void TCordferBranchManager::CreateRawBranch(){ tree->Branch(bname.Data(), raw_branch->bra_val, brancharray); branch.push_back(raw_branch); + }else{ TString mhtdc_name = setup[i]["branches"][0]["name"].as(); Int_t nch = setup[i]["branches"][0]["channel"].as(); Int_t nhit = setup[i]["branches"][0]["maxhit"].as(); TCordferRawBranch *mhtdc_branch = new TCordferRawBranch(mhtdc_name, seg_id, nch, det_id, nhit); - mhtdc_branch->Setgeo(seg_id); - mhtdc_branch->TwoDimMemorySet(); TString brancharray; brancharray.Form("%s[%d][%d]/I", mhtdc_name.Data(), mhtdc_branch->size, mhtdc_branch->nhit); @@ -122,11 +119,10 @@ void TCordferBranchManager::CreateRawBranch(){ tree->Branch(mhtdc_name.Data(), mhtdc_branch->mhtdc_val, brancharray); branch.push_back(mhtdc_branch); + TString nhit_name = setup[i]["branches"][1]["name"].as(); - Int_t ch = setup[i]["branches"][1]["channel"].as(); - TCordferRawBranch *nhit_branch = new TCordferRawBranch(nhit_name, ch); - nhit_branch->Setgeo(-1); - nhit_branch->MemorySet(); + Int_t nhit_nch = setup[i]["branches"][1]["channel"].as(); + TCordferRawBranch *nhit_branch = new TCordferRawBranch(nhit_name, 0, nhit_nch, 0); //geo, det_id = 0 TString nhitbrancharray; nhitbrancharray.Form("%s[%d]/I", nhit_name.Data(), nhit_branch->size); @@ -143,18 +139,11 @@ void TCordferBranchManager::CreateMapBranch(){ for(Int_t i=0; i(); - FileStat_t info; - if(gSystem->GetPathInfo(mname.Data(), info) != 0){ - cerr << "EROOR: in yaml File, '" << mname.Data() << "' does not exist." << endl; - exit(0); - } - - ChannelMap *mfile = new ChannelMap(mname); + MapReader *mfile = new MapReader(mname); for(Int_t j=0; jdetector_name.size(); j++){ TString bname = mfile->detector_name[j]; TCordferMapBranch *map_branch = new TCordferMapBranch(bname, mfile->segment_id[j].size()); - map_branch->CopyMapInfo(mfile->segment_id[j], mfile->channel[j]); - map_branch->MemorySet(); + map_branch->SetMapInfo(mfile->segment_id[j], mfile->channel[j]); TString brancharray; brancharray.Form("%s[%d]/I", bname.Data(), map_branch->size); @@ -165,6 +154,7 @@ void TCordferBranchManager::CreateMapBranch(){ } } + void TCordferBranchManager::CreateCalibBranch(){ YAML::Node map_setup = recipe["map_setup"].as(); for(Int_t i=0; igeo; - mapping[seg] = i; + rmapping[seg] = i; } } @@ -371,9 +361,9 @@ void TCordferBranchManager::GiveValue(Int_t geo, Int_t ch, Int_t val){ void TCordferBranchManager::GiveRawValue(Int_t geo, Int_t ch, Int_t val){ + Int_t index = rmapping[geo]; //if not register segment - auto itr = mapping.find(geo); - if(itr == mapping.end()){ + if(index < 0){ if(rmapflag == false){ cout << "WARNING: rmapping is not completed" << endl; } @@ -381,12 +371,10 @@ void TCordferBranchManager::GiveRawValue(Int_t geo, Int_t ch, Int_t val){ return; } - Int_t index = mapping[geo]; - - if(branch[index]->GetBranchName() == "mhtdc"){ - Int_t ht_id = branch[mapping[-1]]->bra_val[ch]; + if(branch[index]->detector_id == 10){ + Int_t ht_id = branch[index+1]->bra_val[ch]; branch[index]->mhtdc_val[ch][ht_id] = val; - branch[mapping[-1]]->bra_val[ch] += 1; + branch[index+1]->bra_val[ch] += 1; }else{ branch[index]->bra_val[ch] = val; } @@ -400,7 +388,7 @@ void TCordferBranchManager::GiveMapValue(Int_t geo, Int_t ch, Int_t val){ auto itr = mmapping.find(seg); if(itr == mmapping.end()){ if(mapflag == false){ - cout << "WARNING: mapping is not completed" << endl; + cout << "WARNING: mmapping is not completed" << endl; } mapflag=true; return; diff --git a/src/TCordferMapBranch.cpp b/src/TCordferMapBranch.cpp index 1e8772a..56644da 100644 --- a/src/TCordferMapBranch.cpp +++ b/src/TCordferMapBranch.cpp @@ -8,7 +8,7 @@ using namespace std; -void TCordferMapBranch::CopyMapInfo(vector seg, vector ch){ +void TCordferMapBranch::SetMapInfo(vector seg, vector ch){ copy(seg.begin(), seg.end(), back_inserter(segment_id)); copy(ch.begin(), ch.end(), back_inserter(channel)); } -- GitLab