diff --git a/.gitignore b/.gitignore index 289881e34000382340b65de0cba8f9a26419850d..7d39e75652f4a1bf6132bd8db40a1db0234956c2 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ build/ build2/ rootfiles/ figure/ +calibration/ *.ridf *.root *.swp diff --git a/CMakeLists.txt b/CMakeLists.txt index 77ecf9794b57e14a6160beff28ee3e06761eb725..b003df6ec7e570b77ab39fcf7ce6e038ca94235c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -72,3 +72,4 @@ target_link_libraries(${PROJECT_NAME} message("******NOTE: use the command*************") message(" source ../anaroot/setup.sh") message("****************************************") +execute_process(COMMAND cp ../rootmake.sh .) diff --git a/README.md b/README.md index b21508fd348f873b8a15edf5d8d2753c031c7919..1601da3b191b392315fc5126fc2ce1b2a34a0e3e 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ # ridf2root -This convert .ridf to .root file +This convert .ridf to .root file for CRIB experiment ## Environment * ROOT v6.14 (need to set environment variable ROOTSYS) - * (M1 Mac cannot install old version of ROOT (okawa) ) * cmake 3.8 and above -* yaml-cpp +* yaml-cpp 0.6 and above +* gcc-9 * some package(wget, automake autoconf...) * (optionally python and pip pyyaml) @@ -21,39 +21,24 @@ This is a tool to convert ridffile to rootfile using ANAROOT decoder. (https://r ANAROOT is automatically installed by "cmake" in the project directory in order to make it easier to edit decoder file. The part of install of ANAROOT is written in ./CMakeLists.txt. -## Note -* Multihit TDC records all hit in one trigger, but map tree include only one hit event. (last hit) - * raw data tree store all hit and calibration tree also contain all hit - * the format of timing branch of calibration tree are array (like branch[12]) in order to match the format of mhtdc - -* The structure of map tree branches depends on the map file, so now a single branch contains both ADC and TDC data and it is distinguished by channel. - * ex. "name[0]": ADC, "name[1]": TDC - -* When the name contains "-", "/" or " " in mapfile and we use it as branch name, sometimes it is recognized as an operator, so this tool change them to "\_". - -* Calibration tree depends on the map tree. And the name of parameter file is important (cannot name arbitrary) - -* Assume that calibration parameters of two energy output are the same - ## Usage ### Config file -* recipe/**.yml -* map/(expname)/**.map -* calibration/(expname)/**.prm -* main.cpp +* recipe/**.yml [yaml file setting](doc/yamlfile.md) +* map/(expname)/**.map [map file setting](doc/mapfile.md) +* main.cpp [main.cpp setting](doc/main.md) -[yaml file setting](doc/yamlfile.md) -[map file setting](doc/mapfile.md) +### Install -[calibration parameter file setting](doc/calibrationfile.md) +This is cmake based project, library directory is needed to adjust to your environment -[main.cpp setting](doc/main.md) +- ./CMakeList.txt +- ./src/CMakeList.txt -### Install -This is cmake based project, so make build directory and compile in it. + +and make build directory and compile in it. ```console mkdir build @@ -89,5 +74,79 @@ make ``` - - +## Structure of ROOT file + +### for si26a experiment +* tree: raw data tree + +| branch | description | +| ---- | ---- | +| adc1[32] | v785, 32ch | +| adc2[32] | v785, 32ch | +| madc1[32] | MADC, 32ch | +| madc2[32] | MADC, 32ch | +| tdc1[32] | v775, 32ch | +| tdc2[32] | v775, 32ch | +| mhtdc[64][12] | v1190, 62ch, 12hits | + +* mtree: map data tree + +| branch | description | +| ---- | ---- | +| coin_Single |TDC, Single| +| coin_Coin |TDC, Coin| +| coin_Pileup |TDC, Pileup| +| dssd_Tel1_dE1X[16] |ADC, 16ch| +| t_dssd_Tel1_dE1X[16][12] |TDC, 16ch, 12hits| +| dssd_Tel1_dE2Y[16] |ADC, 16ch| +| t_dssd_Tel1_dE2Y[16][12] |TDC, 16ch, 12hits| +| dssd_Tel2_dE2Y[16] |ADC, 16ch| +| t_dssd_Tel2_dE2Y[16] |TDC, 16ch, 12hits| +| dssd_Tel3_dE2Y[16] |ADC, 16ch| +| t_dssd_Tel3_dE2Y[16] |TDC, 16ch, 12hits| +| mssd_1_1[4] |ADC, ene1, ene2, pos1, pos2| +| t_mssd_1_1 |TDC| +| mssd_1_2[4] |ADC, ene1, ene2, pos1, pos2| +| t_mssd_1_2 |TDC| +| mssd_2_1[4] |ADC, ene1, ene2, pos1, pos2| +| t_mssd_2_1 |TDC| +| mssd_2_2[4] |ADC, ene1, ene2, pos1, pos2| +| t_mssd_2_2 |TDC| +| mssd_3_1[4] |ADC, ene1, ene2, pos1, pos2| +| t_mssd_3_1 |TDC| +| mssd_3_2[4] |ADC, ene1, ene2, pos1, pos2| +| t_mssd_3_2 |TDC| +| ppac_F1[5] || +| ppac_F2_F3_B[5][12] || +| ppac_F3_A[5][12] || +| rf_RF[2] || +| ssd_Tel1_E1 || +| t_ssd_Tel1_E1[12] |12hits| +| ssd_Tel1_E2 || +| t_ssd_Tel1_E2[12] |12hits| +| ssd_Tel2_E1 || +| t_ssd_Tel2_E1[12] |12hits| +| ssd_Tel2_E2 || +| t_ssd_Tel2_E2[12] |12hits| +| ssd_Tel3_E1 || +| t_ssd_Tel3_E1[12] |12hits| +| ssd_Tel3_E2 || +| t_ssd_Tel3_E2[12] |12hits| +| ssd_Tel4_E1 || +| t_ssd_Tel4_E1[12] |12hits| +| ssd_Tel4_E2 || +| t_ssd_Tel4_E2[12] |12hits| +| ssd_Tel5_E1 || +| t_ssd_Tel5_E1[12] |12hits| +| ssd_Tel5_E2 || +| t_ssd_Tel5_E2[12] |12hits| +| ssd_Lowgain_1 || +| t_ssd_Lowgain_1[12] |12hits| +| ssd_Lowgain_2 || +| t_ssd_Lowgain_2[12] |12hits| +| ssd_Lowgain_3 || +| t_ssd_Lowgain_3[12] |12hits| +| ssd_Lowgain_4 || +| t_ssd_Lowgain_4[12] |12hits| +| ssd_F2SSD || +| t_ssd_F2SSD[12] |12hits| diff --git a/doc/calibrationfile.md b/doc/calibrationfile.md deleted file mode 100644 index 36f949a6f1d18ff455a6bcc5ec9ef1fa7a8221e6..0000000000000000000000000000000000000000 --- a/doc/calibrationfile.md +++ /dev/null @@ -1,3 +0,0 @@ -# parameter file setting - -calibration tree will be created based on map tree. Since the correspondence between branches and maps is based on name matches, names in parameter file should write carefully. diff --git a/doc/develop_memo.md b/doc/develop_memo.md deleted file mode 100644 index 9c18752024e4879927ff2b9a113750fcf9ab8df0..0000000000000000000000000000000000000000 --- a/doc/develop_memo.md +++ /dev/null @@ -1,33 +0,0 @@ -# develop_memo -PPAC is not developed yet!! - -## in create branch - -#### rawdata -* Separate cases when the name is "mhtdc" and when it is not. - --> if there are multiple mhtdc, it will be error!! - --> Should I change the conditional statement? (TCordferBranchManager->CreateRawBranch, ClearRawAll) - -#### mapdata -I think it is OK - -#### calibdata -* Separate cases according to specific name in yamlfile. - --> I should make rule to name - - -## mapping -unordered_map map[key] = value - -#### rawdata -key = segment_id (=geo) <- "mhtdc_nhit" is set to -1 - -value = branch_index - -#### mapdata - - -#### calibdata diff --git a/doc/main.md b/doc/main.md index 7144cea6e33cf16ad756c605041c4470478bb371..2cd190e1ad8f10f54138f2407d6599e1c57d621a 100644 --- a/doc/main.md +++ b/doc/main.md @@ -1,30 +1,8 @@ # main.cpp ## setting parameter -* bool rawdata - * "true" -> raw data tree will be created -* bool mapdata - * "true" -> map tree will be created -* bool calibration - * "true" -> calibrated tree will be created - * **NOTE**: calibrated tree require map tree, so mapdata = true; and calibration = true; is needed * bool print_progress * "true" -> display the process of data conversion in stdout * TString yamlfile * Set the path to the yaml file in which the settings are written -## content -1. **CheckCommandLine** -> read information written on the command line -2. **Readyaml** -> read specified yaml file -3. **CreateRootFile** -> prepare rootfile -4. **Create__Tree** -> create trees (Raw->tree, Map->mtree, Calib->ctree) -5. **Create__branch** -> create each branches from config file ***(should be improved)*** -6. **Create__Mapping** -> mapping each branch to the id on the DAQ ***(should be improved)*** -7. **TArtEventStore** - * Read and decode ridf file using ANAROOT library -8. **Clear__All** -> initialize value -9. **Give__Value** -> Store decoded values in mapped branches ***(should be improved)*** - * geo: detector, ch: channel, val: recorded value -10. **__Fill** -> store values in the branches in one event -11. **__DataWrite** -> write the created trees to the rootfile -12. **FileClose** -> close the rootfile diff --git a/doc/mapfile.md b/doc/mapfile.md index 3a8266fc333d4ed4a506d7653be6461493c1be6a..05fbf555d9621aa73e73cfc606067948658858d9 100644 --- a/doc/mapfile.md +++ b/doc/mapfile.md @@ -1,8 +1,23 @@ # mapfile setting these mapfile was created for the ANAPAW. I copied from ANAPAW source. -## raw data -detector id is set to: +# Structure of mapfile +[category],[id],[[dev] [fp] [detector] [geo] [ch]], [[dev] [fp] [detector] [geo] [ch]], ; [detector name] + +* category: user select number, to distinguish the +* id: detector_id, +* dev: Number assigned in RIBF, for CRIB, we use 12 +* fp: focal plane, for CRIB, we use only 0 (not distinguish the focal plane in map file) +* detector: detector id (see below) +* geo: geometory id, set in DAQ system (in dat3 PC) +* ch: channel number of each module +* detector_name: for one detector, if there are several ch, line up alongside + + +example) +4, 1, 12 0 6 7 0, 12 0 6 7 1, ; mssd 1-1 + +## detector id * 6: ADC * 7: TDC * 10: multi hit TDC diff --git a/macro/check_compare.C b/macro/check_compare.C new file mode 100644 index 0000000000000000000000000000000000000000..eace2985c8d7a02bbf9970b958be66d644533748 --- /dev/null +++ b/macro/check_compare.C @@ -0,0 +1,236 @@ +{ + TCanvas *c1 = new TCanvas("c1", "c1"); + c1->Divide(1,2); + //PPAC F1 + //for(Int_t i=0; i<5; i++){ + // TString rarray, marray; + // if(i == 4){ rarray.Form("adc1[%d]", 15); } + // else { rarray.Form("adc1[%d]", i); } + // c1->cd(1); + // tree->Draw(rarray.Data()); + // c1->cd(2); + // marray.Form("ppac_F1[%d]", i); + // mtree->Draw(marray.Data()); + // TString out; + // out.Form("./figure/test%d.png", i); + // c1->Print(out.Data()); + //} + + //PPAC F2 + //for(Int_t i=0; i<5; i++){ + // TString rarray, marray; + // if(i == 4){ rarray.Form("mhtdc[%d]", 5); } + // else { rarray.Form("mhtdc[%d]", i+6); } + // c1->cd(1); + // tree->Draw(rarray.Data()); + // c1->cd(2); + // marray.Form("ppac_F2_F3_B[%d]", i); + // mtree->Draw(marray.Data()); + // TString out; + // out.Form("./figure/test%d.png", i); + // c1->Print(out.Data()); + //} + + //PPAC F3 + //for(Int_t i=0; i<5; i++){ + // TString rarray, marray; + // if(i == 4){ rarray.Form("mhtdc[%d]", 0); } + // else { rarray.Form("mhtdc[%d]", i+1); } + // c1->cd(1); + // tree->Draw(rarray.Data()); + // c1->cd(2); + // marray.Form("ppac_F3_A[%d]", i); + // mtree->Draw(marray.Data()); + // TString out; + // out.Form("./figure/test%d.png", i); + // c1->Print(out.Data()); + //} + + //DSSD ADC Tel1 dE2 Y + //for(Int_t i=0; i<16; i++){ + // TString rarray, marray; + // rarray.Form("adc1[%d]", i+16); + // c1->cd(1); + // tree->Draw(rarray.Data()); + // c1->cd(2); + // marray.Form("dssd_Tel1_dE2Y[%d]", i); + // mtree->Draw(marray.Data()); + // TString out; + // out.Form("./figure/test%d.png", i); + // c1->Print(out.Data()); + //} + + //DSSD ADC Tel2 dE2 Y + //for(Int_t i=0; i<16; i++){ + // TString rarray, marray; + // rarray.Form("adc2[%d]", i); + // c1->cd(1); + // tree->Draw(rarray.Data()); + // c1->cd(2); + // marray.Form("dssd_Tel2_dE2Y[%d]", i); + // mtree->Draw(marray.Data()); + // TString out; + // out.Form("./figure/test%d.png", i); + // c1->Print(out.Data()); + //} + + //DSSD ADC Tel3 dE2 Y + //for(Int_t i=0; i<16; i++){ + // TString rarray, marray; + // rarray.Form("adc2[%d]", i+16); + // c1->cd(1); + // tree->Draw(rarray.Data()); + // c1->cd(2); + // marray.Form("dssd_Tel3_dE2Y[%d]", i); + // mtree->Draw(marray.Data()); + // TString out; + // out.Form("./figure/test%d.png", i); + // c1->Print(out.Data()); + //} + + //DSSD ADC Tel1 dE1 X + //for(Int_t i=0; i<16; i++){ + // TString rarray, marray; + // rarray.Form("madc1[%d]", i); + // c1->cd(1); + // tree->Draw(rarray.Data()); + // c1->cd(2); + // marray.Form("dssd_Tel1_dE1X[%d]", i); + // mtree->Draw(marray.Data()); + // TString out; + // out.Form("./figure/test%d.png", i); + // c1->Print(out.Data()); + //} + + //SSD ADC + //for(Int_t i=0; i<10; i++){ + // TString rarray, marray; + // rarray.Form("madc1[%d]", i+16); + // c1->cd(1); + // tree->Draw(rarray.Data()); + // c1->cd(2); + // marray.Form("ssd_Tel%d_E%d", i/2+1, i%2+1); + // mtree->Draw(marray.Data()); + // TString out; + // out.Form("./figure/test%d.png", i); + // c1->Print(out.Data()); + //} + + //MSSD ADC + //for(Int_t i=0; i<24; i++){ + // TString rarray, marray; + // rarray.Form("madc2[%d]", i); + // c1->cd(1); + // tree->Draw(rarray.Data()); + // c1->cd(2); + // marray.Form("mssd_%d_%d[%d]", i/8+1, (i/4)%2+1, i%4); + // mtree->Draw(marray.Data()); + // TString out; + // out.Form("./figure/test%d.png", i); + // c1->Print(out.Data()); + //} + + //ADC others + //for(Int_t i=0; i<5; i++){ + // TString rarray, marray; + // if(i == 4){ + // rarray.Form("adc1[%d]", i); + // }else{ + // rarray.Form("madc1[%d]", i+28); + // } + // c1->cd(1); + // tree->Draw(rarray.Data()); + // c1->cd(2); + // if(i == 4){ + // marray.Form("ssd_F2SSD"); + // }else{ + // marray.Form("ssd_Lowgain_%d", i+1); + // } + // mtree->Draw(marray.Data()); + // TString out; + // out.Form("./figure/test%d.png", i); + // c1->Print(out.Data()); + //} + + //RF COIN TDC + //for(Int_t i=0; i<5; i++){ + // TString rarray, marray; + // if(i < 2){ + // rarray.Form("tdc1[%d]", i); + // }else{ + // rarray.Form("tdc1[%d]", i+11); + // } + // c1->cd(1); + // tree->Draw(rarray.Data()); + // c1->cd(2); + // if(i < 2){ + // marray.Form("rf_RF[%d]", i); + // }else if(i == 2){ + // marray.Form("coin_Single"); + // }else if(i == 3){ + // marray.Form("coin_Coin"); + // }else if(i == 4){ + // marray.Form("coin_Pileup"); + // } + // mtree->Draw(marray.Data()); + // TString out; + // out.Form("./figure/test%d.png", i); + // c1->Print(out.Data()); + //} + + //DSSD TDC Tel2 dE2 Y + //for(Int_t i=0; i<16; i++){ + // TString rarray, marray; + // rarray.Form("tdc1[%d]", i+16); + // c1->cd(1); + // tree->Draw(rarray.Data()); + // c1->cd(2); + // marray.Form("t_dssd_Tel2_dE2Y[%d]", i); + // mtree->Draw(marray.Data()); + // TString out; + // out.Form("./figure/test%d.png", i); + // c1->Print(out.Data()); + //} + + //DSSD TDC Tel3 dE2 Y + //for(Int_t i=0; i<16; i++){ + // TString rarray, marray; + // rarray.Form("tdc2[%d]", i); + // c1->cd(1); + // tree->Draw(rarray.Data()); + // c1->cd(2); + // marray.Form("t_dssd_Tel3_dE2Y[%d]", i); + // mtree->Draw(marray.Data()); + // TString out; + // out.Form("./figure/test%d.png", i); + // c1->Print(out.Data()); + //} + + //DSSD TDC Tel1 dE1 X + //for(Int_t i=0; i<16; i++){ + // TString rarray, marray; + // rarray.Form("mhtdc[%d]", i+32); + // c1->cd(1); + // tree->Draw(rarray.Data()); + // c1->cd(2); + // marray.Form("t_dssd_Tel1_dE1X[%d]", i); + // mtree->Draw(marray.Data()); + // TString out; + // out.Form("./figure/test%d.png", i); + // c1->Print(out.Data()); + //} + + //mhtdc test + for(Int_t i=0; i<12; i++){ + TString rarray, marray; + rarray.Form("mhtdc[32][%d]", i); + c1->cd(1); + tree->Draw(rarray.Data()); + c1->cd(2); + marray.Form("t_dssd_Tel1_dE1X[0][%d]", i); + mtree->Draw(marray.Data()); + TString out; + out.Form("./figure/test%d.png", i); + c1->Print(out.Data()); + } +} diff --git a/main.cpp b/main.cpp index b256ada3d77abd8434ea0f80e1acf9f8031d8716..cedb6eebc1ebc24ae57ae50df88a40be60c367b3 100644 --- a/main.cpp +++ b/main.cpp @@ -14,7 +14,7 @@ using namespace std; Int_t main(Int_t argc, Char_t **argv) { - bool print_progress = true; + bool print_progress = false; //prepare recipe.yml (assume that execute in build directory) TString yamlfile = "../recipe/recipe_si26a.yml"; diff --git a/rootmake.sh b/rootmake.sh new file mode 100755 index 0000000000000000000000000000000000000000..a40f88d785b96a1dbc4c14a41bab9403c37f7fa4 --- /dev/null +++ b/rootmake.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +DATADIR="/Data/si26a" +ROOTDIR="/home/crib/okawa/data/si26a" +for FILE in `ls $DATADIR/*.ridf` +do + DATAFILE=${FILE##*/} + FILENAME=${DATAFILE%.*} + INPUTFILE=${FILE%.*} + echo "in process ${DATAFILE}" + ./ridf2root -i "$INPUTFILE" -o "${ROOTDIR}/${FILENAME}" > ${ROOTDIR}/log/"${FILENAME}.txt" 2> /dev/null +done