From 0788324cd9755ac02fd662846f2205e09938803d Mon Sep 17 00:00:00 2001 From: Kodai Okawa Date: Mon, 7 Mar 2022 00:07:17 +0900 Subject: [PATCH 1/9] [mod] yaml file setting --- include/TCordferBranchManager.hh | 23 +++++++++- main.cpp | 42 ++++-------------- recipe/recipe_si26a.yml | 20 ++++++++- src/CommandlineReader.cpp | 4 +- src/TCordferBranchManager.cpp | 75 +++++++++++++++++++++++++++++++- 5 files changed, 124 insertions(+), 40 deletions(-) diff --git a/include/TCordferBranchManager.hh b/include/TCordferBranchManager.hh index 39af4da..006aa87 100644 --- a/include/TCordferBranchManager.hh +++ b/include/TCordferBranchManager.hh @@ -41,6 +41,10 @@ class TCordferBranchManager vector< vector > mpos; //for mssd + bool rawdata = false; + bool mapdata = false; + bool calibration = false; + //for temporary bool rmapflag = false; bool mapflag = false; @@ -59,28 +63,43 @@ class TCordferBranchManager void Readyaml(TString yamlfile); void CreateRootFile(){ rootfile = new TFile(root_name.Data(), "recreate"); } + + void CreateTree(); void CreateRawTree(); void CreateMapTree(); void CreateCalibTree(); + + void CreateBranch(); void CreateRawBranch(); void CreateMapBranch(); void CreateCalibBranch(); - void CreateRawMapping(); + void CreateMapping(); + void CreateRawMapping(); + void CreateMapMapping(); void CreateCalibMapping(); + + void GiveValue(Int_t geo, Int_t ch, Int_t val); void GiveRawValue(Int_t geo, Int_t ch, Int_t val); void GiveMapValue(Int_t geo, Int_t ch, Int_t val); void GiveCalibValue(Int_t geo, Int_t ch, Int_t val); void GiveWaitCalibValue(); + + void Fill(); void RawFill(){ tree->Fill(); } void MapFill(){ mtree->Fill(); } void CalibFill() { ctree->Fill(); } + + void ClearAll(); void ClearRawAll(); void ClearMapAll(); void ClearCalibAll(); + + void DataWrite(); void RawDataWrite(){ tree->Write(); } - void DataWrite(){ mtree->Write(); } + void MapDataWrite(){ mtree->Write(); } void CalibDataWrite(){ ctree->Write(); } + void FileClose(); void DEBUG_PRINT(); diff --git a/main.cpp b/main.cpp index 2d8f117..b01e90b 100644 --- a/main.cpp +++ b/main.cpp @@ -14,17 +14,6 @@ using namespace std; Int_t main(Int_t argc, Char_t **argv) { - //map tree is require to make calibration tree - bool rawdata = true; - bool mapdata = true; - bool calibration = true; - - if(mapdata == false && calibration == true){ - cout << "ERROR: calibration tree require to use map tree" << endl; - cout << "\tCHANGE mapdata = true" << endl; - return 0; - } - bool print_progress = true; //prepare recipe.yml (assume that execute in build directory) TString yamlfile = "../recipe/recipe_si26a.yml"; @@ -37,19 +26,14 @@ Int_t main(Int_t argc, Char_t **argv) TCordferBranchManager *branch_manager = new TCordferBranchManager(filename[0], filename[1]); branch_manager->Readyaml(yamlfile); branch_manager->CreateRootFile(); - if(rawdata){ branch_manager->CreateRawTree(); } - if(mapdata){ branch_manager->CreateMapTree(); } - if(calibration){ branch_manager->CreateCalibTree(); } + branch_manager->CreateTree(); //prepare branch - if(rawdata){ branch_manager->CreateRawBranch(); } - if(mapdata){ branch_manager->CreateMapBranch(); } - if(calibration){ branch_manager->CreateCalibBranch(); } + branch_manager->CreateBranch(); //map segment_id and branch - if(rawdata){ branch_manager->CreateRawMapping(); } - if(mapdata){ branch_manager->CreateMapping(); } - if(calibration){ branch_manager->CreateCalibMapping(); } + branch_manager->CreateMapping(); + cout << "test" << endl; //start to decode using anaroot TArtEventStore *estore = new TArtEventStore(); @@ -59,9 +43,7 @@ Int_t main(Int_t argc, Char_t **argv) Int_t evtn = 0; while(estore->GetNextEvent()){ - if(rawdata){ branch_manager->ClearRawAll(); } - if(mapdata){ branch_manager->ClearMapAll(); } - if(calibration){ branch_manager->ClearCalibAll(); } + branch_manager->ClearAll(); //eventloop for(Int_t i=0; iGetNumSeg(); i++){ @@ -74,26 +56,20 @@ Int_t main(Int_t argc, Char_t **argv) Int_t ch = d->GetCh(); Int_t val = d->GetVal(); - if(rawdata){ branch_manager->GiveRawValue(geo, ch, val); } - if(mapdata){ branch_manager->GiveMapValue(geo, ch, val); } - if(calibration){ branch_manager->GiveCalibValue(geo, ch, val); } + branch_manager->GiveValue(geo, ch, val); } } // for process of MUX - if(calibration){ branch_manager->GiveWaitCalibValue(); } + branch_manager->GiveWaitCalibValue(); - if(rawdata){ branch_manager->RawFill(); } - if(mapdata){ branch_manager->MapFill(); } - if(calibration){ branch_manager->CalibFill(); } + branch_manager->Fill(); estore->ClearData(); if(print_progress && evtn%10000 == 0) { cout << "reading..." << evtn << endl; } evtn++; } - if(rawdata){ branch_manager->RawDataWrite(); } - if(mapdata){ branch_manager->DataWrite(); } - if(calibration){ branch_manager->CalibDataWrite(); } + branch_manager->DataWrite(); branch_manager->FileClose(); return 0; diff --git a/recipe/recipe_si26a.yml b/recipe/recipe_si26a.yml index 12b9c3d..f3e0ec7 100644 --- a/recipe/recipe_si26a.yml +++ b/recipe/recipe_si26a.yml @@ -1,30 +1,43 @@ -#tree information +# tree information (in_use: on or off) +# in_use: "on" or "off" raw_tree: name: "tree" description: "raw data tree" + in_use: on map_tree: name: "mtree" description: "mapping data tree" + in_use: on calib_tree: name: "ctree" description: "calibrate data tree" + in_use: on -#mapfile and calibration file information + +# mapfile and calibration file information +# format +# 1: one data in one law +# 2: two data (ADC and TDC) in one law +# 3: PPAC data +# 5: five data (MUX data) in one law map_setup: - name: coin mapfile: "../map/si26a/coin.map" + format: 1 calibfile: energy: "" timing: "../calibration/si26a/coin_t.prm" - name: dssd mapfile: "../map/si26a/dssd.map" + format: 2 calibfile: energy: "../calibration/si26a/dssd.prm" timing: "../calibration/si26a/dssd_t.prm" - name: mssd mapfile: "../map/si26a/mssd.map" + format: 5 calibfile: energy: "../calibration/si26a/mssd.prm" timing: "../calibration/si26a/mssd_t.prm" @@ -32,17 +45,20 @@ map_setup: - name: ppac mapfile: "../map/si26a/ppac.map" + format: 3 calibfile: general: "../calibration/si26a/ppac.prm" - name: rf mapfile: "../map/si26a/rf.map" + format: 1 calibfile: energy: "" timing: "../calibration/si26a/rf_t.prm" - name: ssd mapfile: "../map/si26a/ssd.map" + format: 2 calibfile: energy: "../calibration/si26a/ssd.prm" timing: "../calibration/si26a/ssd_t.prm" diff --git a/src/CommandlineReader.cpp b/src/CommandlineReader.cpp index 07b2792..a252bac 100644 --- a/src/CommandlineReader.cpp +++ b/src/CommandlineReader.cpp @@ -60,8 +60,8 @@ array CheckCommandLine(Int_t argc, Char_t **argv) exit(0); } - cout << "\tinput file name : " << finname << endl; - cout << "\toutput file name : " << foutname << endl; + cout << "-- input file name : " << finname << endl; + cout << "-- output file name : " << foutname << endl; return {finname, foutname}; } diff --git a/src/TCordferBranchManager.cpp b/src/TCordferBranchManager.cpp index d4be300..f37a108 100644 --- a/src/TCordferBranchManager.cpp +++ b/src/TCordferBranchManager.cpp @@ -28,6 +28,33 @@ void TCordferBranchManager::Readyaml(TString yamlfile){ exit(0); } recipe = YAML::LoadFile(yamlfile.Data()); + cout << "-- yaml file: " << yamlfile << endl; + + if(recipe["raw_tree"]["in_use"].as() == "on"){ + rawdata=true; + cout << "\t-- raw_tree in use" << endl; + } + if(recipe["map_tree"]["in_use"].as() == "on"){ + mapdata=true; + cout << "\t-- map_tree in use" << endl; + } + if(recipe["calib_tree"]["in_use"].as() == "on"){ + calibration=true; + cout << "\t-- calib_tree in use" << endl; + } + + if(mapdata == false && calibration == true){ + cout << "ERROR: calibration tree require to use map tree" << endl; + cout << "\tCHANGE recipe in yaml file" << endl; + exit(0); + } +} + + +void TCordferBranchManager::CreateTree(){ + if(rawdata){ CreateRawTree(); } + if(mapdata){ CreateMapTree(); } + if(calibration){ CreateCalibTree(); } } @@ -55,6 +82,13 @@ void TCordferBranchManager::CreateCalibTree(){ } +void TCordferBranchManager::CreateBranch(){ + if(rawdata){ CreateRawBranch(); } + if(mapdata){ CreateMapBranch(); } + if(calibration){ CreateCalibBranch(); } +} + + void TCordferBranchManager::CreateRawBranch(){ YAML::Node setup = recipe["setup"].as(); for(Int_t i=0; i(); for(Int_t i=0; igeo; @@ -195,7 +237,7 @@ void TCordferBranchManager::CreateRawMapping(){ } -void TCordferBranchManager::CreateMapping(){ +void TCordferBranchManager::CreateMapMapping(){ for(Int_t i=0; isize; j++){ Int_t seg = mbranch[i]->segment_id[j]*1000 + mbranch[i]->channel[j]; @@ -320,6 +362,13 @@ void TCordferBranchManager::CreateCalibMapping(){ } +void TCordferBranchManager::GiveValue(Int_t geo, Int_t ch, Int_t val){ + if(rawdata){ GiveRawValue(geo, ch, val); } + if(mapdata){ GiveMapValue(geo, ch, val); } + if(calibration){ GiveCalibValue(geo, ch, val); } +} + + void TCordferBranchManager::GiveRawValue(Int_t geo, Int_t ch, Int_t val){ //if not register segment auto itr = mapping.find(geo); @@ -433,6 +482,8 @@ void TCordferBranchManager::GiveCalibValue(Int_t geo, Int_t ch, Int_t val){ void TCordferBranchManager::GiveWaitCalibValue(){ + if(calibration == false){ return; } + for(Int_t i=0; imux_status1==true){ GiveCalibValue(cbranch[i]->geo_tmp1, cbranch[i]->ch_tmp1, cbranch[i]->val_tmp1); } if(cbranch[i]->mux_status2==true){ GiveCalibValue(cbranch[i]->geo_tmp2, cbranch[i]->ch_tmp2, cbranch[i]->val_tmp2); } @@ -440,6 +491,20 @@ void TCordferBranchManager::GiveWaitCalibValue(){ } +void TCordferBranchManager::Fill(){ + if(rawdata){ RawFill(); } + if(mapdata){ MapFill(); } + if(calibration){ CalibFill(); } +} + + +void TCordferBranchManager::ClearAll(){ + if(rawdata){ ClearRawAll(); } + if(mapdata){ ClearMapAll(); } + if(calibration){ ClearCalibAll(); } +} + + void TCordferBranchManager::ClearRawAll(){ for(Int_t i=0; iGetBranchName() == "mhtdc"){ @@ -498,6 +563,14 @@ void TCordferBranchManager::ClearCalibAll(){ } } + +void TCordferBranchManager::DataWrite(){ + if(rawdata){ RawDataWrite(); } + if(mapdata){ MapDataWrite(); } + if(calibration){ CalibDataWrite(); } +} + + void TCordferBranchManager::FileClose(){ rootfile->Close(); for(Int_t i=0; i Date: Mon, 7 Mar 2022 22:37:38 +0900 Subject: [PATCH 2/9] [mod] recipe --- doc/mapfile.md | 6 ++++++ include/TCordferRawBranch.hh | 10 ++++++++-- recipe/recipe_si26a.yml | 13 ++++++++++++- src/TCordferBranchManager.cpp | 11 ++++++----- 4 files changed, 32 insertions(+), 8 deletions(-) diff --git a/doc/mapfile.md b/doc/mapfile.md index a46f87d..3a8266f 100644 --- a/doc/mapfile.md +++ b/doc/mapfile.md @@ -1,2 +1,8 @@ # mapfile setting these mapfile was created for the ANAPAW. I copied from ANAPAW source. + +## raw data +detector id is set to: +* 6: ADC +* 7: TDC +* 10: multi hit TDC diff --git a/include/TCordferRawBranch.hh b/include/TCordferRawBranch.hh index b8472b8..298758d 100644 --- a/include/TCordferRawBranch.hh +++ b/include/TCordferRawBranch.hh @@ -15,18 +15,24 @@ class TCordferRawBranch public: TCordferRawBranch(){} - TCordferRawBranch(TString bname, Int_t bsize){ + TCordferRawBranch(TString bname, Int_t segment_id, Int_t bsize, Int_t det_id){ name = bname; + geo = segment_id; size = bsize; + detector_id = det_id; + MemorySet(); } - TCordferRawBranch(TString bname, Int_t bsize, Int_t bnhit){ + TCordferRawBranch(TString bname, Int_t segment_id, Int_t bsize, Int_t det_id, Int_t bnhit){ name = bname; + geo = segment_id; size = bsize; + detector_id = det_id; nhit = bnhit; } ~TCordferRawBranch(){} Int_t size; + Int_t detector_id; Int_t nhit; Int_t geo; Int_t *bra_val; diff --git a/recipe/recipe_si26a.yml b/recipe/recipe_si26a.yml index f3e0ec7..733ea31 100644 --- a/recipe/recipe_si26a.yml +++ b/recipe/recipe_si26a.yml @@ -64,34 +64,45 @@ map_setup: timing: "../calibration/si26a/ssd_t.prm" -#for rawdata tree +# for rawdata tree +# detector_id +# 6: ADC +# 7: TDC +# 10: multihit TDC setup: - segment_no.: 1 name: adc1 + detector_id: 6 channel: 32 - segment_no.: 2 name: adc2 + detector_id: 6 channel: 32 - segment_no.: 6 name: madc1 + detector_id: 6 channel: 32 - segment_no.: 7 name: madc2 + detector_id: 6 channel: 32 - segment_no.: 11 name: tdc1 + detector_id: 7 channel: 32 - segment_no.: 12 name: tdc2 + detector_id: 7 channel: 32 - segment_no.: 16 name: mhtdc + detector_id: 10 branches: - name: mhtdc channel: 64 diff --git a/src/TCordferBranchManager.cpp b/src/TCordferBranchManager.cpp index f37a108..1d3ec71 100644 --- a/src/TCordferBranchManager.cpp +++ b/src/TCordferBranchManager.cpp @@ -94,12 +94,13 @@ void TCordferBranchManager::CreateRawBranch(){ for(Int_t i=0; i(); TString bname = setup[i]["name"].as(); - if(bname != "mhtdc"){ + 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, nch); - raw_branch->Setgeo(seg_id); - raw_branch->MemorySet(); + TCordferRawBranch *raw_branch = new TCordferRawBranch(bname, seg_id, nch, det_id); TString brancharray; brancharray.Form("%s[%d]/I", bname.Data(), raw_branch->size); @@ -111,7 +112,7 @@ void TCordferBranchManager::CreateRawBranch(){ 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, nch, nhit); + TCordferRawBranch *mhtdc_branch = new TCordferRawBranch(mhtdc_name, seg_id, nch, det_id, nhit); mhtdc_branch->Setgeo(seg_id); mhtdc_branch->TwoDimMemorySet(); -- GitLab From e6013c0e389a504f2d40396c63039b3dfac45f74 Mon Sep 17 00:00:00 2001 From: Kodai Okawa Date: Tue, 8 Mar 2022 01:11:08 +0900 Subject: [PATCH 3/9] [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 From 9af043891b8cdc91e4fed8127dea30cf02d4edbb Mon Sep 17 00:00:00 2001 From: kodaiokawa Date: Tue, 8 Mar 2022 19:37:32 +0900 Subject: [PATCH 4/9] [mod] map data --- include/TCordferBranchManager.hh | 15 +++++++++--- src/TCordferBranchManager.cpp | 39 +++++++++++++++++++++----------- 2 files changed, 38 insertions(+), 16 deletions(-) diff --git a/include/TCordferBranchManager.hh b/include/TCordferBranchManager.hh index e06c132..ee5ca72 100644 --- a/include/TCordferBranchManager.hh +++ b/include/TCordferBranchManager.hh @@ -34,8 +34,9 @@ class TCordferBranchManager vector branch; vector mbranch; vector cbranch; - Int_t rmapping[100] = {-1}; //max segment_id(geo) number - unordered_map mmapping; + Int_t rmapping[100] = {-1}; //segment_id(geo) -> branch index + //unordered_map mmapping; + Int_t mmapping[100][100] = {{-1}}; // [segment_id][ch] -> branch index unordered_map cmapping; unordered_map muxmapping; @@ -47,7 +48,7 @@ class TCordferBranchManager //for temporary bool rmapflag = false; - bool mapflag = false; + bool mmapflag = false; bool cmapflag = false; public: @@ -73,6 +74,14 @@ class TCordferBranchManager void CreateRawBranch(); void CreateMapBranch(); void CreateCalibBranch(); + Int_t MakeBranchChannelIndex(Int_t bra_id, Int_t ch_id){ + return bra_id*100 + ch_id; + } + array GetBranchChannelIndex(Int_t index){ + Int_t j = index % 100; + Int_t i = (index - j)/100; + return {i, j}; + } void CreateMapping(); void CreateRawMapping(); diff --git a/src/TCordferBranchManager.cpp b/src/TCordferBranchManager.cpp index 177dadc..4d4bf42 100644 --- a/src/TCordferBranchManager.cpp +++ b/src/TCordferBranchManager.cpp @@ -231,9 +231,10 @@ void TCordferBranchManager::CreateRawMapping(){ void TCordferBranchManager::CreateMapMapping(){ for(Int_t i=0; isize; j++){ - Int_t seg = mbranch[i]->segment_id[j]*1000 + mbranch[i]->channel[j]; - Int_t index = i*1000 + j; - mmapping[seg] = index; + mmapping[mbranch[i]->segment_id[j]][mbranch[i]->channel[j]] = MakeBranchChannelIndex(i, j); + //Int_t seg = mbranch[i]->segment_id[j]*1000 + mbranch[i]->channel[j]; + //Int_t index = i*1000 + j; + //mmapping[seg] = index; } } } @@ -362,6 +363,7 @@ 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 if(index < 0){ if(rmapflag == false){ @@ -382,21 +384,32 @@ void TCordferBranchManager::GiveRawValue(Int_t geo, Int_t ch, Int_t val){ void TCordferBranchManager::GiveMapValue(Int_t geo, Int_t ch, Int_t val){ - Int_t seg = geo*1000 + ch; - - //if not register segment - auto itr = mmapping.find(seg); - if(itr == mmapping.end()){ - if(mapflag == false){ + //Int_t seg = geo*1000 + ch; + + ////if not register segment + //auto itr = mmapping.find(seg); + //if(itr == mmapping.end()){ + // if(mapflag == false){ + // cout << "WARNING: mmapping is not completed" << endl; + // } + // mapflag=true; + // return; + //} + Int_t index = mmapping[geo][ch]; + if(index < 0){ + if(mmapflag == false){ cout << "WARNING: mmapping is not completed" << endl; } - mapflag=true; + mmapflag=true; return; } - Int_t index = mmapping[seg]; - Int_t j = index % 1000; - Int_t i = (index - j)/1000; + array index = GetBranchChannelIndex(index); + Int_t i = index[0]; + Int_t j = index[1]; + //Int_t index = mmapping[seg]; + //Int_t j = index % 1000; + //Int_t i = (index - j)/1000; mbranch[i]->bra_val[j] = val; } -- GitLab From c1849d1f17be64442f6568c3973b50bcf2c83ffe Mon Sep 17 00:00:00 2001 From: Kodai Okawa Date: Wed, 9 Mar 2022 00:03:19 +0900 Subject: [PATCH 5/9] [mod] raw and map data --- include/TCordferBranchManager.hh | 5 ++-- include/TCordferMapBranch.hh | 2 ++ include/TCordferRawBranch.hh | 2 ++ recipe/recipe_si26a.yml | 2 +- src/TCordferBranchManager.cpp | 40 ++++++++++++++------------------ src/TCordferMapBranch.cpp | 4 ++++ src/TCordferRawBranch.cpp | 13 +++++++++++ 7 files changed, 41 insertions(+), 27 deletions(-) diff --git a/include/TCordferBranchManager.hh b/include/TCordferBranchManager.hh index ee5ca72..aa79f76 100644 --- a/include/TCordferBranchManager.hh +++ b/include/TCordferBranchManager.hh @@ -34,9 +34,8 @@ class TCordferBranchManager vector branch; vector mbranch; vector cbranch; - Int_t rmapping[100] = {-1}; //segment_id(geo) -> branch index - //unordered_map mmapping; - Int_t mmapping[100][100] = {{-1}}; // [segment_id][ch] -> branch index + Int_t rmapping[100]; //segment_id(geo) -> branch index + Int_t mmapping[100][100]; // [segment_id][ch] -> branch index unordered_map cmapping; unordered_map muxmapping; diff --git a/include/TCordferMapBranch.hh b/include/TCordferMapBranch.hh index bd87a4a..939ac92 100644 --- a/include/TCordferMapBranch.hh +++ b/include/TCordferMapBranch.hh @@ -33,6 +33,8 @@ class TCordferMapBranch void MemorySet(){ bra_val = new Int_t[size]; } void FreeMemory(){ delete[] bra_val; } void SetMapInfo(vector seg, vector ch); + + void Clear(); }; #endif diff --git a/include/TCordferRawBranch.hh b/include/TCordferRawBranch.hh index 0ac44f1..be71892 100644 --- a/include/TCordferRawBranch.hh +++ b/include/TCordferRawBranch.hh @@ -47,6 +47,8 @@ class TCordferRawBranch void TwoDimMemorySet(); void FreeMemory(){ delete[] bra_val; } void FreeTwoDimMemory(); + + void Clear(); }; #endif diff --git a/recipe/recipe_si26a.yml b/recipe/recipe_si26a.yml index dd87ba8..a0202d1 100644 --- a/recipe/recipe_si26a.yml +++ b/recipe/recipe_si26a.yml @@ -7,7 +7,7 @@ raw_tree: map_tree: name: "mtree" description: "mapping data tree" - in_use: off + in_use: on calib_tree: name: "ctree" description: "calibrate data tree" diff --git a/src/TCordferBranchManager.cpp b/src/TCordferBranchManager.cpp index 4d4bf42..cc807dd 100644 --- a/src/TCordferBranchManager.cpp +++ b/src/TCordferBranchManager.cpp @@ -221,6 +221,7 @@ void TCordferBranchManager::CreateMapping(){ void TCordferBranchManager::CreateRawMapping(){ + memset(rmapping, -1, sizeof(rmapping)); for(Int_t i=0; igeo; rmapping[seg] = i; @@ -229,12 +230,13 @@ void TCordferBranchManager::CreateRawMapping(){ void TCordferBranchManager::CreateMapMapping(){ + Int_t m = sizeof(mmapping) / sizeof(mmapping[0]); + Int_t n = sizeof(mmapping[0]) / sizeof(mmapping[0][0]); + memset(mmapping, -1, sizeof(mmapping[0][0])*m*n); + for(Int_t i=0; isize; j++){ mmapping[mbranch[i]->segment_id[j]][mbranch[i]->channel[j]] = MakeBranchChannelIndex(i, j); - //Int_t seg = mbranch[i]->segment_id[j]*1000 + mbranch[i]->channel[j]; - //Int_t index = i*1000 + j; - //mmapping[seg] = index; } } } @@ -384,17 +386,6 @@ void TCordferBranchManager::GiveRawValue(Int_t geo, Int_t ch, Int_t val){ void TCordferBranchManager::GiveMapValue(Int_t geo, Int_t ch, Int_t val){ - //Int_t seg = geo*1000 + ch; - - ////if not register segment - //auto itr = mmapping.find(seg); - //if(itr == mmapping.end()){ - // if(mapflag == false){ - // cout << "WARNING: mmapping is not completed" << endl; - // } - // mapflag=true; - // return; - //} Int_t index = mmapping[geo][ch]; if(index < 0){ if(mmapflag == false){ @@ -404,12 +395,9 @@ void TCordferBranchManager::GiveMapValue(Int_t geo, Int_t ch, Int_t val){ return; } - array index = GetBranchChannelIndex(index); - Int_t i = index[0]; - Int_t j = index[1]; - //Int_t index = mmapping[seg]; - //Int_t j = index % 1000; - //Int_t i = (index - j)/1000; + array index_array = GetBranchChannelIndex(index); + Int_t i = index_array[0]; + Int_t j = index_array[1]; mbranch[i]->bra_val[j] = val; } @@ -509,13 +497,15 @@ void TCordferBranchManager::ClearAll(){ void TCordferBranchManager::ClearRawAll(){ for(Int_t i=0; iGetBranchName() == "mhtdc"){ + //branch[i]->Clear(); + + if(branch[i]->detector_id == 10){ for(Int_t j=0; jsize; j++){ for(Int_t k=0; knhit; k++){ branch[i]->mhtdc_val[j][k] = -500; } } - }else if(branch[i]->GetBranchName() == "mhtdc_nhit"){ + }else if(branch[i]->detector_id == 0){ for(Int_t j=0; jsize; j++){ branch[i]->bra_val[j] = 0; } @@ -530,6 +520,7 @@ void TCordferBranchManager::ClearRawAll(){ void TCordferBranchManager::ClearMapAll(){ for(Int_t i=0; iClear(); for(Int_t j=0; jsize; j++){ mbranch[i]->bra_val[j] = -500; } @@ -576,15 +567,18 @@ void TCordferBranchManager::DataWrite(){ void TCordferBranchManager::FileClose(){ rootfile->Close(); for(Int_t i=0; iGetBranchName() == "mhtdc"){ + if(branch[i]->detector_id == 10){ branch[i]->FreeTwoDimMemory(); }else{ branch[i]->FreeMemory(); } } + for(Int_t i=0; iFreeMemory(); } + + //for cbranch } // for debug diff --git a/src/TCordferMapBranch.cpp b/src/TCordferMapBranch.cpp index 56644da..f0d9fe2 100644 --- a/src/TCordferMapBranch.cpp +++ b/src/TCordferMapBranch.cpp @@ -1,5 +1,6 @@ #include #include +#include #include @@ -13,3 +14,6 @@ void TCordferMapBranch::SetMapInfo(vector seg, vector ch){ copy(ch.begin(), ch.end(), back_inserter(channel)); } +void TCordferMapBranch::Clear(){ + memset(bra_val, -500, sizeof(bra_val)); +} diff --git a/src/TCordferRawBranch.cpp b/src/TCordferRawBranch.cpp index 3547555..937e9c5 100644 --- a/src/TCordferRawBranch.cpp +++ b/src/TCordferRawBranch.cpp @@ -22,3 +22,16 @@ void TCordferRawBranch::FreeTwoDimMemory(){ delete[] mhtdc_val; } + +void TCordferRawBranch::Clear(){ + if(detector_id == 10){ + Int_t m = sizeof(mhtdc_val) / sizeof(mhtdc_val[0]); + Int_t n = sizeof(mhtdc_val[0]) / sizeof(mhtdc_val[0][0]); + memset(mhtdc_val, -500, sizeof(mhtdc_val[0][0])*m*n); + } + else if(detector_id == 0){ + memset(bra_val, 0, sizeof(bra_val)); + }else{ + memset(bra_val, -500, sizeof(bra_val)); + } +} -- GitLab From 18fe332569633ebf175d58051c4e6e1f1e9b423a Mon Sep 17 00:00:00 2001 From: kodaiokawa Date: Wed, 9 Mar 2022 22:13:09 +0900 Subject: [PATCH 6/9] [mod] raw and map tree --- include/TCordferRawBranch.hh | 2 ++ src/TCordferBranchManager.cpp | 53 ++++++++++++++++++----------------- src/TCordferMapBranch.cpp | 5 +++- src/TCordferRawBranch.cpp | 49 +++++++++++++++++++++++++++----- 4 files changed, 75 insertions(+), 34 deletions(-) diff --git a/include/TCordferRawBranch.hh b/include/TCordferRawBranch.hh index be71892..12d873a 100644 --- a/include/TCordferRawBranch.hh +++ b/include/TCordferRawBranch.hh @@ -48,7 +48,9 @@ class TCordferRawBranch void FreeMemory(){ delete[] bra_val; } void FreeTwoDimMemory(); + //bool SetValue(Int_t ch, Int_t val); //return flag of mhtdc of others void Clear(); + void Free(); }; #endif diff --git a/src/TCordferBranchManager.cpp b/src/TCordferBranchManager.cpp index cc807dd..17aa168 100644 --- a/src/TCordferBranchManager.cpp +++ b/src/TCordferBranchManager.cpp @@ -497,33 +497,33 @@ void TCordferBranchManager::ClearAll(){ void TCordferBranchManager::ClearRawAll(){ for(Int_t i=0; iClear(); - - if(branch[i]->detector_id == 10){ - for(Int_t j=0; jsize; j++){ - for(Int_t k=0; knhit; k++){ - branch[i]->mhtdc_val[j][k] = -500; - } - } - }else if(branch[i]->detector_id == 0){ - for(Int_t j=0; jsize; j++){ - branch[i]->bra_val[j] = 0; - } - }else{ - for(Int_t j=0; jsize; j++){ - branch[i]->bra_val[j] = -500; - } - } + branch[i]->Clear(); + + //if(branch[i]->detector_id == 10){ + // for(Int_t j=0; jsize; j++){ + // for(Int_t k=0; knhit; k++){ + // branch[i]->mhtdc_val[j][k] = -500; + // } + // } + //}else if(branch[i]->detector_id == 0){ + // for(Int_t j=0; jsize; j++){ + // branch[i]->bra_val[j] = 0; + // } + //}else{ + // for(Int_t j=0; jsize; j++){ + // branch[i]->bra_val[j] = -500; + // } + //} } } void TCordferBranchManager::ClearMapAll(){ for(Int_t i=0; iClear(); - for(Int_t j=0; jsize; j++){ - mbranch[i]->bra_val[j] = -500; - } + mbranch[i]->Clear(); + //for(Int_t j=0; jsize; j++){ + // mbranch[i]->bra_val[j] = -500; + //} } } @@ -567,11 +567,12 @@ void TCordferBranchManager::DataWrite(){ void TCordferBranchManager::FileClose(){ rootfile->Close(); for(Int_t i=0; idetector_id == 10){ - branch[i]->FreeTwoDimMemory(); - }else{ - branch[i]->FreeMemory(); - } + branch[i]->FreeAll(); + //if(branch[i]->detector_id == 10){ + // branch[i]->FreeTwoDimMemory(); + //}else{ + // branch[i]->FreeMemory(); + //} } for(Int_t i=0; i seg, vector ch){ } void TCordferMapBranch::Clear(){ - memset(bra_val, -500, sizeof(bra_val)); + //memset(bra_val, -500, sizeof(bra_val)); + for(Int_t j=0; jdetector_id == 10){ + branch[i]->FreeTwoDimMemory(); + }else{ + branch[i]->FreeMemory(); + } } + } -- GitLab From fac41f4adf24828437e514e99c54be43877e3852 Mon Sep 17 00:00:00 2001 From: kodaiokawa Date: Wed, 9 Mar 2022 22:15:26 +0900 Subject: [PATCH 7/9] [mod] raw branch --- include/TCordferRawBranch.hh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/TCordferRawBranch.hh b/include/TCordferRawBranch.hh index 12d873a..a1a3db5 100644 --- a/include/TCordferRawBranch.hh +++ b/include/TCordferRawBranch.hh @@ -50,7 +50,7 @@ class TCordferRawBranch //bool SetValue(Int_t ch, Int_t val); //return flag of mhtdc of others void Clear(); - void Free(); + void FreeAll(); }; #endif -- GitLab From 465285d7c18327a741ae2132012332ac47a81173 Mon Sep 17 00:00:00 2001 From: Kodai Okawa Date: Thu, 10 Mar 2022 01:30:28 +0900 Subject: [PATCH 8/9] [add] some check macro --- .gitignore | 1 + macro/mpos_2dim.C | 12 +++++ macro/raw_mpos_check.C | 91 +++++++++++++++++++++++++++++++++++ src/TCordferBranchManager.cpp | 24 --------- src/TCordferRawBranch.cpp | 11 ++--- 5 files changed, 108 insertions(+), 31 deletions(-) create mode 100644 macro/mpos_2dim.C create mode 100644 macro/raw_mpos_check.C diff --git a/.gitignore b/.gitignore index faaef28..35bedde 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ anaroot/ build/ rootfiles/ +figure/ *.ridf *.root diff --git a/macro/mpos_2dim.C b/macro/mpos_2dim.C new file mode 100644 index 0000000..77f668e --- /dev/null +++ b/macro/mpos_2dim.C @@ -0,0 +1,12 @@ +{ + gStyle->SetOptLogz(1); + + TFile *fin = new TFile("../rootfiles/old_rootfiles/alpha307_308.root", "read"); + TTree *tree = (TTree*)fin->Get("tree"); + + TCanvas *c1 = new TCanvas("c1","c1"); + //tree->Draw("madc2[23]:madc2[21]>>(100, 0, 2000, 100, 1550, 1950)","","colz"); + tree->Draw("madc2[21]>>(100, 0, 2000)"); + + //c1->Print("../figure/twodim_mpos2.png"); +} diff --git a/macro/raw_mpos_check.C b/macro/raw_mpos_check.C new file mode 100644 index 0000000..f5e19e5 --- /dev/null +++ b/macro/raw_mpos_check.C @@ -0,0 +1,91 @@ +// ********FOR Si26a************** +// +// --RUN INFORMATION +// run307 alpha calibration Tel1-3 dE1&2, Tel4-5 dE2 +// run308 the same condition +// +// --MUX INFORMATION +// driver for MUX2-1 is missing -> use MUX3-1 +// +// --CHANNEL INFORMATION OF MUX +// madc2[0]-[3] : MUX1-1 +// madc2[4]-[7] : MUX1-2 +// madc2[8]-[11] : MUX2-1 +// madc2[12]-[15]: MUX2-2 +// madc2[16]-[19]: MUX3-1 +// madc2[20]-[23]: MUX3-2 + +{ + gStyle->SetOptLogy(1); + + //for run307 and 308 + TFile *fin = new TFile("../rootfiles/old_rootfiles/alpha307_308.root", "read"); + TTree *tree = (TTree*)fin->Get("tree"); + //TChain *chain = new TChain("tree", "chain"); + //chain->Add("../rootfiles/old_rootfiles/calib0307.root"); + //chain->Add("../rootfiles/old_rootfiles/calib0308.root"); + + Int_t mux[32]; + tree->SetBranchAddress("madc2", mux); + + + //TH1I *hist1 = new TH1I("hist1","mux1-1p1",400,350,750); + //TH1I *hist2 = new TH1I("hist2","mux1-2p1",400,650,1050); + //TH1I *hist3 = new TH1I("hist3","mux2-1p1",400,800,1200); + //TH1I *hist4 = new TH1I("hist4","mux2-2p1",400,1250,1650); + //TH1I *hist5 = new TH1I("hist5","mux3-1p1",400,1350,1750); + //TH1I *hist6 = new TH1I("hist6","mux3-2p1",400,1550,1950); + TH1I *hist1 = new TH1I("hist1","mux1-1p2",400,350,750); + TH1I *hist2 = new TH1I("hist2","mux1-2p2",400,650,1050); + TH1I *hist3 = new TH1I("hist3","mux2-1p2",400,800,1200); + TH1I *hist4 = new TH1I("hist4","mux2-2p2",400,1250,1650); + TH1I *hist5 = new TH1I("hist5","mux3-1p2",400,1350,1750); + TH1I *hist6 = new TH1I("hist6","mux3-2p2",400,1550,1950); + + const Int_t N = tree->GetEntries(); + const Int_t start_ent = 0; + const Int_t end_ent = 1000000; + if(end_ent > N){ + cout << "Value Miss!" << endl; + } + + for(Int_t ientry=start_ent; ientryGetEntry(ientry); + + hist1->Fill(mux[3]); + hist2->Fill(mux[7]); + hist3->Fill(mux[19]); + hist4->Fill(mux[15]); + hist5->Fill(mux[19]); + hist6->Fill(mux[23]); + } + + + TCanvas *c1 = new TCanvas("c1", "c1", 800, 1000); + c1->Divide(2, 3); + c1->cd(1); + hist1->Draw(); + //tree->Draw("madc2[2]>>MUX1_1p1(400,350,750)", "Row<100"); //MUX1-1 pos1 + + c1->cd(2); + hist2->Draw(); + //tree->Draw("madc2[6]>>MUX1_2p1(400,650,1050)"); //MUX1-2 pos1 + + c1->cd(3); + hist3->Draw(); + //tree->Draw("madc2[18]>>MUX2_1p1(400,800,1200)"); //MUX2-1 pos1 + + c1->cd(4); + hist4->Draw(); + //tree->Draw("madc2[14]>>MUX2_2p1(400,1250,1650)"); //MUX2-2 pos1 + + c1->cd(5); + hist5->Draw(); + //tree->Draw("madc2[18]>>MUX3_1p1(400,1350,1750)"); //MUX3-1 pos1 + + c1->cd(6); + hist6->Draw(); + //tree->Draw("madc2[22]>>MUX3_2p1(400,1550,1950)"); //MUX3-2 pos1 + + c1->Print("../figure/alpha_mpos2.png"); +} diff --git a/src/TCordferBranchManager.cpp b/src/TCordferBranchManager.cpp index 17aa168..2f273e8 100644 --- a/src/TCordferBranchManager.cpp +++ b/src/TCordferBranchManager.cpp @@ -498,22 +498,6 @@ void TCordferBranchManager::ClearAll(){ void TCordferBranchManager::ClearRawAll(){ for(Int_t i=0; iClear(); - - //if(branch[i]->detector_id == 10){ - // for(Int_t j=0; jsize; j++){ - // for(Int_t k=0; knhit; k++){ - // branch[i]->mhtdc_val[j][k] = -500; - // } - // } - //}else if(branch[i]->detector_id == 0){ - // for(Int_t j=0; jsize; j++){ - // branch[i]->bra_val[j] = 0; - // } - //}else{ - // for(Int_t j=0; jsize; j++){ - // branch[i]->bra_val[j] = -500; - // } - //} } } @@ -521,9 +505,6 @@ void TCordferBranchManager::ClearRawAll(){ void TCordferBranchManager::ClearMapAll(){ for(Int_t i=0; iClear(); - //for(Int_t j=0; jsize; j++){ - // mbranch[i]->bra_val[j] = -500; - //} } } @@ -568,11 +549,6 @@ void TCordferBranchManager::FileClose(){ rootfile->Close(); for(Int_t i=0; iFreeAll(); - //if(branch[i]->detector_id == 10){ - // branch[i]->FreeTwoDimMemory(); - //}else{ - // branch[i]->FreeMemory(); - //} } for(Int_t i=0; idetector_id == 10){ - branch[i]->FreeTwoDimMemory(); - }else{ - branch[i]->FreeMemory(); - } + if(detector_id == 10){ + FreeTwoDimMemory(); + }else{ + FreeMemory(); } - } -- GitLab From 4e78e0e5342936332e1ea1420a73dcc5213ec05d Mon Sep 17 00:00:00 2001 From: Kodai Okawa Date: Wed, 16 Mar 2022 23:29:05 +0900 Subject: [PATCH 9/9] [mod] calibration tree --- include/TCordferBranchManager.hh | 8 +- include/TCordferCalibBranch.hh | 32 ++-- include/TCordferMapBranch.hh | 4 +- macro/mpos_2dim.C | 21 ++- main.cpp | 2 - recipe/recipe_si26a.yml | 25 +-- src/TCordferBranchManager.cpp | 314 +++++++++++++------------------ src/TCordferCalibBranch.cpp | 112 +++++++++++ 8 files changed, 297 insertions(+), 221 deletions(-) diff --git a/include/TCordferBranchManager.hh b/include/TCordferBranchManager.hh index aa79f76..2630a79 100644 --- a/include/TCordferBranchManager.hh +++ b/include/TCordferBranchManager.hh @@ -36,16 +36,15 @@ class TCordferBranchManager vector cbranch; Int_t rmapping[100]; //segment_id(geo) -> branch index Int_t mmapping[100][100]; // [segment_id][ch] -> branch index - unordered_map cmapping; - unordered_map muxmapping; + Int_t cmapping[100][100]; + Int_t muxmapping[100][100]; - vector< vector > mpos; //for mssd + vector< vector > mpos; //for position parameter of MUX (mssd) bool rawdata = false; bool mapdata = false; bool calibration = false; - //for temporary bool rmapflag = false; bool mmapflag = false; bool cmapflag = false; @@ -91,7 +90,6 @@ class TCordferBranchManager void GiveRawValue(Int_t geo, Int_t ch, Int_t val); void GiveMapValue(Int_t geo, Int_t ch, Int_t val); void GiveCalibValue(Int_t geo, Int_t ch, Int_t val); - void GiveWaitCalibValue(); void Fill(); void RawFill(){ tree->Fill(); } diff --git a/include/TCordferCalibBranch.hh b/include/TCordferCalibBranch.hh index 23f3455..a471ce7 100644 --- a/include/TCordferCalibBranch.hh +++ b/include/TCordferCalibBranch.hh @@ -3,6 +3,7 @@ #include #include +#include #include @@ -15,12 +16,14 @@ class TCordferCalibBranch public: TCordferCalibBranch(){} - TCordferCalibBranch(TString bname){ + TCordferCalibBranch(TString bname, Int_t det_id){ name = bname; + detector_id = det_id; } ~TCordferCalibBranch(){} bool adc; + Int_t detector_id; Int_t geo; Int_t ch; Int_t calib_dim; @@ -36,31 +39,24 @@ class TCordferCalibBranch bool mux_pos2; bool mux1_junk; bool mux2_junk; - Int_t mux_ch1; - Int_t mux_ch2; - Int_t geo_tmp1; - Int_t geo_tmp2; - Int_t ch_tmp1; - Int_t ch_tmp2; Int_t val_tmp1; Int_t val_tmp2; + Int_t pval_tmp1; + Int_t pval_tmp2; vector mpos1_prm; vector mpos2_prm; TString GetBranchName(){ return name; } - void SetGeometrytmp1(Int_t geo, Int_t ch, Int_t val){ - geo_tmp1 = geo; - ch_tmp1 = ch; - val_tmp1 = val; - } - void SetGeometrytmp2(Int_t geo, Int_t ch, Int_t val){ - geo_tmp2 = geo; - ch_tmp2 = ch; - val_tmp2 = val; - } - void CopyCalibInfo(Int_t dim, vector param); + + Int_t GetCalibStatus(Int_t val, Int_t mux_id); + Int_t GetAddBranchIndex(Int_t mux_id); + void SetCalibValue(Int_t val); + + Double_t GetCalibValue(Int_t val, vector params); + + void Clear(); }; #endif diff --git a/include/TCordferMapBranch.hh b/include/TCordferMapBranch.hh index 939ac92..732417c 100644 --- a/include/TCordferMapBranch.hh +++ b/include/TCordferMapBranch.hh @@ -15,14 +15,16 @@ class TCordferMapBranch public: TCordferMapBranch(){} - TCordferMapBranch(TString bname, Int_t bsize){ + TCordferMapBranch(TString bname, Int_t det_id, Int_t bsize){ name = bname; + detector_id = det_id; size = bsize; MemorySet(); } ~TCordferMapBranch(){} bool adc; + Int_t detector_id; Int_t size; Int_t *bra_val; vector segment_id; diff --git a/macro/mpos_2dim.C b/macro/mpos_2dim.C index 77f668e..e35039a 100644 --- a/macro/mpos_2dim.C +++ b/macro/mpos_2dim.C @@ -1,3 +1,20 @@ +// ********FOR Si26a************** +// +// --RUN INFORMATION +// run307 alpha calibration Tel1-3 dE1&2, Tel4-5 dE2 +// run308 the same condition +// +// --MUX INFORMATION +// driver for MUX2-1 is missing -> use MUX3-1 +// +// --CHANNEL INFORMATION OF MUX +// madc2[0]-[3] : MUX1-1 +// madc2[4]-[7] : MUX1-2 +// madc2[8]-[11] : MUX2-1 +// madc2[12]-[15]: MUX2-2 +// madc2[16]-[19]: MUX3-1 +// madc2[20]-[23]: MUX3-2 + { gStyle->SetOptLogz(1); @@ -6,7 +23,9 @@ TCanvas *c1 = new TCanvas("c1","c1"); //tree->Draw("madc2[23]:madc2[21]>>(100, 0, 2000, 100, 1550, 1950)","","colz"); - tree->Draw("madc2[21]>>(100, 0, 2000)"); + //tree->Draw("madc2[3]:madc2[2]>>(175, 350, 700, 175, 350, 750)","","colz"); + tree->Draw("madc2[3]:madc2[2]>>(175, 350, 750, 400, 0, 800)","","colz"); + //tree->Draw("madc2[21]>>(100, 0, 2000)"); //c1->Print("../figure/twodim_mpos2.png"); } diff --git a/main.cpp b/main.cpp index 0e8e10c..b256ada 100644 --- a/main.cpp +++ b/main.cpp @@ -58,8 +58,6 @@ Int_t main(Int_t argc, Char_t **argv) branch_manager->GiveValue(geo, ch, val); } } - // for process of MUX - branch_manager->GiveWaitCalibValue(); branch_manager->Fill(); diff --git a/recipe/recipe_si26a.yml b/recipe/recipe_si26a.yml index a0202d1..14067c9 100644 --- a/recipe/recipe_si26a.yml +++ b/recipe/recipe_si26a.yml @@ -11,33 +11,34 @@ map_tree: calib_tree: name: "ctree" description: "calibrate data tree" - in_use: off + in_use: on # mapfile and calibration file information -# format -# 1: one data in one law -# 2: two data (ADC and TDC) in one law -# 3: PPAC data -# 5: five data (MUX data) in one law +# det_flag +# 1: coincidence +# 2: rf +# 3: PPAC +# 4: ssd (dssd) +# 5: MUX (MUX) map_setup: - name: coin mapfile: "../map/si26a/coin.map" - format: 1 + det_flag: 1 calibfile: energy: "" timing: "../calibration/si26a/coin_t.prm" - name: dssd mapfile: "../map/si26a/dssd.map" - format: 2 + det_flag: 4 calibfile: energy: "../calibration/si26a/dssd.prm" timing: "../calibration/si26a/dssd_t.prm" - name: mssd mapfile: "../map/si26a/mssd.map" - format: 5 + det_flag: 5 calibfile: energy: "../calibration/si26a/mssd.prm" timing: "../calibration/si26a/mssd_t.prm" @@ -45,20 +46,20 @@ map_setup: - name: ppac mapfile: "../map/si26a/ppac.map" - format: 3 + det_flag: 3 calibfile: general: "../calibration/si26a/ppac.prm" - name: rf mapfile: "../map/si26a/rf.map" - format: 1 + det_flag: 2 calibfile: energy: "" timing: "../calibration/si26a/rf_t.prm" - name: ssd mapfile: "../map/si26a/ssd.map" - format: 2 + det_flag: 4 calibfile: energy: "../calibration/si26a/ssd.prm" timing: "../calibration/si26a/ssd_t.prm" diff --git a/src/TCordferBranchManager.cpp b/src/TCordferBranchManager.cpp index 2f273e8..d96cc99 100644 --- a/src/TCordferBranchManager.cpp +++ b/src/TCordferBranchManager.cpp @@ -16,7 +16,6 @@ #include #include "TCordferBranchManager.hh" -#include "CalibrationManager.hh" using namespace std; @@ -138,11 +137,12 @@ void TCordferBranchManager::CreateMapBranch(){ YAML::Node map_setup = recipe["map_setup"].as(); for(Int_t i=0; i(); + Int_t det_id = map_setup[i]["det_flag"].as(); 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()); + TCordferMapBranch *map_branch = new TCordferMapBranch(bname, det_id, mfile->segment_id[j].size()); map_branch->SetMapInfo(mfile->segment_id[j], mfile->channel[j]); TString brancharray; @@ -159,11 +159,13 @@ void TCordferBranchManager::CreateCalibBranch(){ YAML::Node map_setup = recipe["map_setup"].as(); for(Int_t i=0; i(); + Int_t det_id = map_setup[i]["det_flag"].as(); //************** - if(det_name == "ppac"){ continue; } + if(det_id == 3){ continue; } //for PPAC //************** + //default (except of PPAC) TString cname[2]; cname[0] = map_setup[i]["calibfile"]["energy"].as(); cname[1] = map_setup[i]["calibfile"]["timing"].as(); @@ -180,7 +182,7 @@ void TCordferBranchManager::CreateCalibBranch(){ CalibParamReader *cfile = new CalibParamReader(det_name, cname[j]); for(Int_t k=0; kbranch_name.size(); k++){ TString bname = cfile->branch_name[k]; - TCordferCalibBranch *calib_branch = new TCordferCalibBranch(bname); + TCordferCalibBranch *calib_branch = new TCordferCalibBranch(bname, det_id); calib_branch->CopyCalibInfo(cfile->dim, cfile->parameters[k]); TString brancharray; @@ -196,7 +198,7 @@ void TCordferBranchManager::CreateCalibBranch(){ cbranch.push_back(calib_branch); } } - if(det_name == "mssd"){ + if(det_id == 5){ //for parameter reader of MUX position (mssd) TString pos_name = map_setup[i]["calibfile"]["position"].as(); FileStat_t info; if(gSystem->GetPathInfo(pos_name.Data(), info) != 0){ @@ -243,113 +245,137 @@ void TCordferBranchManager::CreateMapMapping(){ void TCordferBranchManager::CreateCalibMapping(){ - Int_t mssd_tune = 0; + Int_t m = sizeof(cmapping) / sizeof(cmapping[0]); + Int_t n = sizeof(cmapping[0]) / sizeof(cmapping[0][0]); + memset(cmapping, -1, sizeof(cmapping[0][0])*m*n); + + Int_t M = sizeof(muxmapping) / sizeof(muxmapping[0]); + Int_t N = sizeof(muxmapping[0]) / sizeof(muxmapping[0][0]); + memset(muxmapping, -1, sizeof(muxmapping[0][0])*M*N); + + Int_t coin_num = 0; + Int_t rf_num = 0; + Int_t mssd_num = 0; + Int_t mux_num = 0; + Int_t mux_t_num = 0; + for(Int_t i=0; iGetBranchName().Data()); - //for rf data - if(cbranch_name.find("RF1") != string::npos){ - for(Int_t j=0; jGetBranchName().Data()); - if(mbranch_name.find("RF") != string::npos || mbranch_name.find("rf") != string::npos){ - cbranch[i]->geo = mbranch[j]->segment_id[0]; - cbranch[i]->ch = mbranch[j]->channel[0]; - } - } - }else if(cbranch_name.find("RF2") != string::npos){ + //for coin data + if(cbranch[i]->detector_id == 1){ + Int_t coin_tmp = coin_num; for(Int_t j=0; jGetBranchName().Data()); - if(mbranch_name.find("RF") != string::npos || mbranch_name.find("rf") != string::npos){ - cbranch[i]->geo = mbranch[j]->segment_id[1]; - cbranch[i]->ch = mbranch[j]->channel[1]; + if(mbranch[j]->detector_id == 1){ + if(coin_tmp > 0){ + coin_tmp--; + continue; + }else{ + cbranch[i]->geo = mbranch[j]->segment_id[0]; + cbranch[i]->ch = mbranch[j]->channel[0]; + coin_num++; + break; + } } } } - //for coin data - else if(cbranch_name.find("coin") != string::npos){ + //for rf data + if(cbranch[i]->detector_id == 2){ + Int_t rf_index; for(Int_t j=0; jGetBranchName().Data()); - if(cbranch_name == mbranch_name){ - cbranch[i]->geo = mbranch[j]->segment_id[0]; - cbranch[i]->ch = mbranch[j]->channel[0]; - } + if(mbranch[j]->detector_id == 2){ rf_index = j; } } - } - - //for mssd - else if(cbranch_name.find("mssd") != string::npos && cbranch_name.substr(0, 2) != "t_"){ - mssd_tune++; - if(mssd_tune%16 == 1){ - Int_t mux_id = mssd_tune/16; - cbranch[i]->mpos1_prm = mpos[2*mux_id]; - cbranch[i]->mpos2_prm = mpos[2*mux_id + 1]; - - Int_t seg0, seg1, seg2, seg3; - - for(Int_t j=0; jGetBranchName().Data()); - if(cbranch_name.find(mbranch_name) != string::npos){ - seg0 = mbranch[j]->segment_id[0]*1000 + mbranch[j]->channel[0]; - cmapping[seg0] = i; - muxmapping[seg0] = 1; - - seg1 = mbranch[j]->segment_id[1]*1000 + mbranch[j]->channel[1]; - cmapping[seg1] = i; - muxmapping[seg1] = 2; - - seg2 = mbranch[j]->segment_id[2]*1000 + mbranch[j]->channel[2]; - cmapping[seg2] = i; - muxmapping[seg2] = 3; - - seg3 = mbranch[j]->segment_id[3]*1000 + mbranch[j]->channel[3]; - cmapping[seg2] = i; - muxmapping[seg2] = 4; - } - } - //cout << i << " " << cbranch_name << " " << seg0 << ", " << seg1 << ", " << seg2 << ", " << seg3 << endl; - continue; + if(rf_num == 0){ + cbranch[i]->geo = mbranch[rf_index]->segment_id[0]; + cbranch[i]->ch = mbranch[rf_index]->channel[0]; + rf_num++; + }else if(rf_num == 1){ + cbranch[i]->geo = mbranch[rf_index]->segment_id[1]; + cbranch[i]->ch = mbranch[rf_index]->channel[1]; + rf_num++; }else{ - //cout << i << " " << cbranch_name << endl; - continue; - } - }else if(cbranch_name.find("mssd") != string::npos && cbranch_name.substr(0, 2) == "t_"){ - for(Int_t j=0; jGetBranchName().Data()); - if(cbranch_name.find(mbranch_name) != string::npos){ - cbranch[i]->geo = mbranch[j]->segment_id[4]; - cbranch[i]->ch = mbranch[j]->channel[4]; - } + cout << "WARNING: format of mapfile of rf is differenet" << endl; } } //for ppac - //else if(){} + //if(cbranch[i]->detector_id == 3){} + //for dssd, ssd data - else{ - bool tdc_flag = false; - if(cbranch_name.substr(0, 2) == "t_"){ - cbranch_name.erase(0, 2); - tdc_flag = true; - } - for(Int_t j=0; jGetBranchName().Data()); - if(cbranch_name == mbranch_name){ - if(tdc_flag){ - cbranch[i]->geo = mbranch[j]->segment_id[1]; - cbranch[i]->ch = mbranch[j]->channel[1]; - }else{ - cbranch[i]->geo = mbranch[j]->segment_id[0]; - cbranch[i]->ch = mbranch[j]->channel[0]; + if(cbranch[i]->detector_id == 4){ + continue; + } + //else{ + // bool tdc_flag = false; + // if(cbranch_name.substr(0, 2) == "t_"){ + // cbranch_name.erase(0, 2); + // tdc_flag = true; + // } + // for(Int_t j=0; jGetBranchName().Data()); + // if(cbranch_name == mbranch_name){ + // if(tdc_flag){ + // cbranch[i]->geo = mbranch[j]->segment_id[1]; + // cbranch[i]->ch = mbranch[j]->channel[1]; + // }else{ + // cbranch[i]->geo = mbranch[j]->segment_id[0]; + // cbranch[i]->ch = mbranch[j]->channel[0]; + // } + // } + // } + //} + + + //for mssd + if(cbranch[i]->detector_id == 5){ + if(cbranch[i]->adc == true){ + mssd_num++; + if(mssd_num%16 == 1){ + Int_t mux_id = mssd_num/16; + cbranch[i]->mpos1_prm = mpos[2*mux_id]; + cbranch[i]->mpos2_prm = mpos[2*mux_id + 1]; + + Int_t mux_tmp = mux_num; + for(Int_t j=0; jdetector_id == 5){ + if(mux_tmp > 0){ + mux_tmp--; + continue; + }else{ + //cout << cbranch[i]->GetBranchName() << " " << mbranch[j]->GetBranchName() << endl; + for(Int_t k=0; k<4; k++){ + cmapping[mbranch[j]->segment_id[k]][mbranch[j]->channel[k]] = i; + muxmapping[mbranch[j]->segment_id[k]][mbranch[j]->channel[k]] = k + 1; + } + mux_num++; + break; + } + } + } + } + }else if(cbranch[i]->adc == false){ + Int_t mux_t_tmp = mux_t_num; + for(Int_t j=0; jdetector_id == 5){ + if(mux_t_tmp > 0){ + mux_t_tmp--; + continue; + }else{ + //cout << cbranch[i]->GetBranchName() << " " << mbranch[j]->GetBranchName() << endl; + cmapping[mbranch[j]->segment_id[4]][mbranch[j]->channel[4]] = i; + + mux_t_num++; + break; + } } } + } + continue; } - Int_t seg = cbranch[i]->geo*1000 + cbranch[i]->ch; - Int_t index = i; - cmapping[seg] = index; + cmapping[cbranch[i]->geo][cbranch[i]->ch] = i; //cout << i << " " << cbranch_name << " " << seg << endl; } @@ -389,7 +415,7 @@ void TCordferBranchManager::GiveMapValue(Int_t geo, Int_t ch, Int_t val){ Int_t index = mmapping[geo][ch]; if(index < 0){ if(mmapflag == false){ - cout << "WARNING: mmapping is not completed" << endl; + cout << "-- WARNING: mmapping is not completed" << endl; } mmapflag=true; return; @@ -404,79 +430,25 @@ void TCordferBranchManager::GiveMapValue(Int_t geo, Int_t ch, Int_t val){ void TCordferBranchManager::GiveCalibValue(Int_t geo, Int_t ch, Int_t val){ - Int_t seg = geo*1000 + ch; - - //if not register segment - auto itr = cmapping.find(seg); - if(itr == cmapping.end()){ + Int_t index = cmapping[geo][ch]; + Int_t mux_id = muxmapping[geo][ch]; + if(index < 0){ if(cmapflag == false){ - cout << "WARNING: cmapping is not completed" << endl; + cout << "-- WARNING: cmapping is not completed" << endl; } cmapflag=true; return; } - Int_t index = cmapping[seg]; - string cbranch_name = string(cbranch[index]->GetBranchName().Data()); - - //for mssd energy calibration - if(cbranch_name.find("mssd") != string::npos && cbranch_name.substr(0, 2) != "t_"){ - Int_t mux_sig = muxmapping[seg]; - if(mux_sig==1 && cbranch[index]->mux_pos1==false){ - cbranch[index]->SetGeometrytmp1(geo, ch, val); - cbranch[index]->mux_status1=true; - - }else if(mux_sig==1 && cbranch[index]->mux_pos1==true){ - if(cbranch[index]->mux1_junk == true){ return; } - Int_t add_ch = cbranch[index]->mux_ch1; - cbranch[index + add_ch]->cbra_val = GetCalibValue(val, cbranch[index+add_ch]->calib_param); - - }else if(mux_sig==2 && cbranch[index]->mux_pos2==false){ - cbranch[index]->SetGeometrytmp2(geo, ch, val); - cbranch[index]->mux_status2=true; - - }else if(mux_sig==2 && cbranch[index]->mux_pos2==true){ - if(cbranch[index]->mux2_junk == true){ return; } - Int_t add_ch = cbranch[index]->mux_ch2; - cbranch[index + add_ch]->cbra_val = GetCalibValue(val, cbranch[index+add_ch]->calib_param); - - }else if(mux_sig==3){ - cbranch[index]->mux_pos1 = true; - for(Int_t i=0; i<16; i++){ - if(cbranch[index]->mpos1_prm[i] < val && cbranch[index]->mpos1_prm[i+1] > val){ - cbranch[index]->mux_ch1 = i; - } - } - if(cbranch[index]->mux_ch1 < 0){ cbranch[index]->mux1_junk = true; } - - }else if(mux_sig==4){ - cbranch[index]->mux_pos2 = true; - for(Int_t i=0; i<16; i++){ - if(cbranch[index]->mpos2_prm[i] < val && cbranch[index]->mpos2_prm[i+1] > val){ - cbranch[index]->mux_ch2 = i; - } - } - if(cbranch[index]->mux_ch2 < 0){ cbranch[index]->mux2_junk = true; } - } - - //for others - }else{ - if(cbranch[index]->adc){ - cbranch[index]->cbra_val = GetCalibValue(val, cbranch[index]->calib_param); - }else{ - cbranch[index]->cbra_tval[cbranch[index]->count_hit] = GetCalibValue(val, cbranch[index]->calib_param); - cbranch[index]->count_hit++; - } - } -} - - -void TCordferBranchManager::GiveWaitCalibValue(){ - if(calibration == false){ return; } - - for(Int_t i=0; imux_status1==true){ GiveCalibValue(cbranch[i]->geo_tmp1, cbranch[i]->ch_tmp1, cbranch[i]->val_tmp1); } - if(cbranch[i]->mux_status2==true){ GiveCalibValue(cbranch[i]->geo_tmp2, cbranch[i]->ch_tmp2, cbranch[i]->val_tmp2); } + //calib_status + // 0->not mux, 1->first mux signal, other -> "val" buffer + Int_t calib_status = cbranch[index]->GetCalibStatus(val, mux_id); + if(calib_status == 1){ return; } + else if(calib_status == 0){ cbranch[index]->SetCalibValue(val); } + else{ + Int_t add_ch = cbranch[index]->GetAddBranchIndex(mux_id); // for MUX (default = 0) + if(add_ch == -1){ return; } + cbranch[index + add_ch]->SetCalibValue(calib_status); } } @@ -511,29 +483,7 @@ void TCordferBranchManager::ClearMapAll(){ void TCordferBranchManager::ClearCalibAll(){ for(Int_t i=0; imux_status1=false; - cbranch[i]->mux_status2=false; - cbranch[i]->mux_pos1=false; - cbranch[i]->mux_pos2=false; - cbranch[i]->mux1_junk=false; - cbranch[i]->mux2_junk=false; - cbranch[i]->mux_ch1=-99; - cbranch[i]->mux_ch2=-99; - cbranch[i]->geo_tmp1=-99; - cbranch[i]->geo_tmp2=-99; - cbranch[i]->ch_tmp1=-99; - cbranch[i]->ch_tmp2=-99; - cbranch[i]->val_tmp1=-99; - cbranch[i]->val_tmp2=-99; - - if(cbranch[i]->adc){ - cbranch[i]->cbra_val = -500.5; - }else{ - for(Int_t j=0; j<12; j++){ - cbranch[i]->cbra_tval[j] = -500.5; - } - cbranch[i]->count_hit = 0; - } + cbranch[i]->Clear(); } } diff --git a/src/TCordferCalibBranch.cpp b/src/TCordferCalibBranch.cpp index 649b641..4f4bb97 100644 --- a/src/TCordferCalibBranch.cpp +++ b/src/TCordferCalibBranch.cpp @@ -1,5 +1,7 @@ #include #include +#include +#include #include @@ -17,3 +19,113 @@ void TCordferCalibBranch::CopyCalibInfo(Int_t dim, vector param){ } } + +Int_t TCordferCalibBranch::GetCalibStatus(Int_t val, Int_t mux_id){ + if(detector_id == 5){ + if(adc == true){ + if(mux_id == 1 && mux_pos1 == false){ + mux_status1 = true; + val_tmp1 = val; + return 1; + } + + else if(mux_id == 1 && mux_pos2 == true){ + return val; + } + + else if(mux_id == 2 && mux_pos2 == false){ + mux_status2 = true; + val_tmp2 = val; + return 1; + } + + else if(mux_id == 2 && mux_pos2 == true){ + return val; + } + + else if(mux_id == 3 && mux_status1 == false){ + pval_tmp1 = val; + mux_pos1 = true; + return 1; + } + + else if(mux_id == 3 && mux_status1 == true){ + pval_tmp1 = val; + return val_tmp1; + } + + else if(mux_id == 4 && mux_status2 == false){ + pval_tmp2 = val; + mux_pos2 = true; + return 1; + } + + else if(mux_id == 4 && mux_status2 == true){ + pval_tmp2 = val; + return val_tmp2; + } + + //else{ return val; } + + }else{ return 0; } + }else{ return 0; } + return 0; +} + + +Int_t TCordferCalibBranch::GetAddBranchIndex(Int_t mux_id){ + Int_t add_ch = -1; + if(mux_id == 1 || mux_id == 3){ + for(Int_t i=0; i<16; i++){ + if(mpos1_prm[i] < pval_tmp1 && mpos1_prm[i+1] > pval_tmp1){ + add_ch = i; + } + } + + }else if(mux_id == 2 || mux_id == 4){ + for(Int_t i=0; i<16; i++){ + if(mpos2_prm[i] < pval_tmp2 && mpos2_prm[i+1] > pval_tmp2){ + add_ch = i; + } + } + } + return add_ch; +} + + +void TCordferCalibBranch::SetCalibValue(Int_t val){ + if(adc == true){ + cbra_val = GetCalibValue(val, calib_param); + } + else if(adc == false){ + cbra_tval[count_hit] = GetCalibValue(val, calib_param); + count_hit++; + } +} + + +Double_t TCordferCalibBranch::GetCalibValue(Int_t val, vector params){ + Double_t tmp = 0.0; + for(Int_t i=0; i