From 39b76a7ea28dfc43889d89ad396230b5fc3d4245 Mon Sep 17 00:00:00 2001 From: Norbert Herrmann <n.herrmann@physi.uni-heidelberg.de> Date: Wed, 6 Jul 2022 10:44:52 +0200 Subject: [PATCH] [mCBM 21-22] Changes to reco, ana and plotting macros from NH version + fixes Includes fix to licence headers in reco, ana and plotting macros from NH version 1. Name collision with pl_eff_XY.C ```macro/beamtime/pl_Eff_XY.C <= renamed to pl_Eff_XY_1.C by FLorian one year ago``` 2. Beamtime folder ``` macro/beamtime/kine.C <= New file + HEADER macro/beamtime/pl_cmp_2D.C <= New file + HEADER macro/beamtime/shift_hst.C <= New file + HEADER ``` 3. mCBM 2021 folder ``` macro/beamtime/mcbm2021/MonitorTof.C <= + HEADER macro/beamtime/mcbm2021/ana_trks_eval.C <= -doxygen in HEADER macro/beamtime/mcbm2021/ini_AnaTestbeam.C <= New file -doxygen HEADER + HEADER macro/beamtime/mcbm2021/ini_Clusterizer.C <= New file + HEADER macro/beamtime/mcbm2021/pl_all_2D.C <= -doxygen HEADER + HEADER macro/beamtime/mcbm2021/pl_all_CluRateRatio.C <= New file -doxygen HEADER + HEADER macro/beamtime/mcbm2021/pl_all_Sel2D.C <= -doxygen HEADER + HEADER ``` --- macro/beamtime/fit_yPos.C | 4 +- macro/beamtime/kine.C | 13 + macro/beamtime/load_hst.C | 4 + macro/beamtime/mcbm2021/MonitorTof.C | 13 +- macro/beamtime/mcbm2021/MonitorTof.sh | 24 + macro/beamtime/mcbm2021/align_tof.sh | 214 ++++++ macro/beamtime/mcbm2021/ana_digi_cal.C | 22 +- macro/beamtime/mcbm2021/ana_digi_cal_all.C | 353 ++------- macro/beamtime/mcbm2021/ana_digi_cal_evt.C | 239 ++++++ macro/beamtime/mcbm2021/ana_trks.C | 530 ++----------- macro/beamtime/mcbm2021/ana_trks_eval.C | 722 +++--------------- macro/beamtime/mcbm2021/calib_batch.sh | 13 +- macro/beamtime/mcbm2021/check_timing_any.C | 2 +- macro/beamtime/mcbm2021/clu_cal_all.sh | 215 ++++++ macro/beamtime/mcbm2021/dis_digi.C | 649 +--------------- .../mcbm2021/dis_reco_mcbm_digievent.C | 462 +++++++++++ macro/beamtime/mcbm2021/dis_trks.C | 8 +- macro/beamtime/mcbm2021/eval_raw.C | 13 +- macro/beamtime/mcbm2021/eval_raw.sh | 136 ++++ macro/beamtime/mcbm2021/eval_tracks.sh | 27 +- macro/beamtime/mcbm2021/gen_hits.sh | 40 +- macro/beamtime/mcbm2021/ini_AnaTestbeam.C | 455 +++++++++++ macro/beamtime/mcbm2021/ini_Clusterizer.C | 262 +++++++ macro/beamtime/mcbm2021/ini_trks.C | 62 +- macro/beamtime/mcbm2021/init_cal_all.sh | 31 +- macro/beamtime/mcbm2021/iter_tracks.sh | 46 +- macro/beamtime/mcbm2021/pl_all_2D.C | 19 +- macro/beamtime/mcbm2021/pl_all_Cal2D.C | 113 +++ macro/beamtime/mcbm2021/pl_all_CluRate.C | 7 +- macro/beamtime/mcbm2021/pl_all_CluRateRatio.C | 248 ++++++ macro/beamtime/mcbm2021/pl_all_DTLastHits.C | 7 +- macro/beamtime/mcbm2021/pl_all_DigiCor.C | 16 +- macro/beamtime/mcbm2021/pl_all_DigiDTLD.C | 11 +- macro/beamtime/mcbm2021/pl_all_DigiMul.C | 11 +- macro/beamtime/mcbm2021/pl_all_DigiTot.C | 11 +- macro/beamtime/mcbm2021/pl_all_Sel2D.C | 18 +- macro/beamtime/mcbm2021/pl_all_Track2D.C | 17 +- .../mcbm2021/run_reco_mcbm_digievent.C | 434 +++++++++++ macro/beamtime/mcbm2021/run_reco_mcbm_nh.C | 322 ++++++++ macro/beamtime/mcbm2021/scan_raw.sh | 5 +- macro/beamtime/mcbm2021/trk_cal_digi.sh | 64 +- macro/beamtime/pl_Dut_Vel.C | 1 + macro/beamtime/pl_Eff_TIR.C | 4 +- macro/beamtime/pl_Eff_TIS.C | 51 +- macro/beamtime/pl_TIR.C | 1 - macro/beamtime/pl_TIS.C | 9 +- macro/beamtime/pl_Track2D.C | 1 - macro/beamtime/pl_XY_trk.C | 4 +- macro/beamtime/pl_all_CluRate.C | 9 +- macro/beamtime/pl_all_CluRateRatio.C | 45 +- macro/beamtime/pl_all_CluSizeDTLastHits.C | 11 +- macro/beamtime/pl_all_DTLastHits.C | 10 +- macro/beamtime/pl_all_TOffDTLastHits.C | 10 +- macro/beamtime/pl_all_TotDTLastHits.C | 11 +- macro/beamtime/pl_calib_trk.C | 2 +- macro/beamtime/pl_cmp_2D.C | 73 ++ macro/beamtime/pl_over_cor.C | 12 +- macro/beamtime/pl_over_trk.C | 495 ++++++------ macro/beamtime/pl_pull_trk.C | 343 +++++---- macro/beamtime/pl_raw_evt.C | 45 +- macro/beamtime/pl_trk_Walk.C | 1 - macro/beamtime/pl_vert_trk.C | 1 - macro/beamtime/shift_hst.C | 72 ++ 63 files changed, 4414 insertions(+), 2659 deletions(-) create mode 100644 macro/beamtime/kine.C create mode 100755 macro/beamtime/mcbm2021/MonitorTof.sh create mode 100755 macro/beamtime/mcbm2021/align_tof.sh create mode 100644 macro/beamtime/mcbm2021/ana_digi_cal_evt.C create mode 100755 macro/beamtime/mcbm2021/clu_cal_all.sh create mode 100644 macro/beamtime/mcbm2021/dis_reco_mcbm_digievent.C create mode 100755 macro/beamtime/mcbm2021/eval_raw.sh create mode 100644 macro/beamtime/mcbm2021/ini_AnaTestbeam.C create mode 100644 macro/beamtime/mcbm2021/ini_Clusterizer.C create mode 100644 macro/beamtime/mcbm2021/pl_all_Cal2D.C create mode 100644 macro/beamtime/mcbm2021/pl_all_CluRateRatio.C create mode 100644 macro/beamtime/mcbm2021/run_reco_mcbm_digievent.C create mode 100644 macro/beamtime/mcbm2021/run_reco_mcbm_nh.C create mode 100644 macro/beamtime/pl_cmp_2D.C create mode 100644 macro/beamtime/shift_hst.C diff --git a/macro/beamtime/fit_yPos.C b/macro/beamtime/fit_yPos.C index 4807e4c3c7..d68652f067 100644 --- a/macro/beamtime/fit_yPos.C +++ b/macro/beamtime/fit_yPos.C @@ -49,8 +49,8 @@ void fit_yPos(Int_t SmT = 0, Int_t iSm = 0, Int_t iRpc = 0, Double_t dLini = 0.) h2y = h2->ProjectionY(); h2y->Draw(); cout << " Fit with ybox " << h2y->GetName() << endl; - fit_ybox((const char*) (h2y->GetName())); - if (0) { //NULL != gMinuit ) { + fit_ybox((const char*) (h2y->GetName()), dLini); + if (1) { //NULL != gMinuit ) { cout << "Minuit ended with " << gMinuit->fCstatu << endl; } diff --git a/macro/beamtime/kine.C b/macro/beamtime/kine.C new file mode 100644 index 0000000000..5504d070c9 --- /dev/null +++ b/macro/beamtime/kine.C @@ -0,0 +1,13 @@ +/* Copyright (C) 2022 PI-UHd, GSI + SPDX-License-Identifier: GPL-3.0-only + Authors: Norbert Herrmann [committer] */ + +void kine(Double_t plab = 10) +{ + Double_t m = 0.931; + Double_t E1 = TMath::Sqrt(plab * plab + m * m); + Double_t E2 = m; + Double_t T1 = E1 - m; + Double_t Sqs = TMath::Sqrt(2 * m * m + 2 * E1 * m); + cout << "p: " << plab << ", T: " << T1 << ", sqrt(s) " << Sqs << endl; +} diff --git a/macro/beamtime/load_hst.C b/macro/beamtime/load_hst.C index 29c7d807c4..ffdf2ff8ff 100644 --- a/macro/beamtime/load_hst.C +++ b/macro/beamtime/load_hst.C @@ -6,6 +6,10 @@ void load_hst(TString cstr = "hst/default.hst.root") { // Read histogramms from the file TFile* fHist = TFile::Open(cstr, "READ"); + if (NULL == fHist) { + cout << " File " << cstr.Data() << " not existing " << endl; + return; + } TIter next(fHist->GetListOfKeys()); gROOT->cd(); diff --git a/macro/beamtime/mcbm2021/MonitorTof.C b/macro/beamtime/mcbm2021/MonitorTof.C index 2a291266c7..2746f8a494 100644 --- a/macro/beamtime/mcbm2021/MonitorTof.C +++ b/macro/beamtime/mcbm2021/MonitorTof.C @@ -1,3 +1,7 @@ +/* Copyright (C) 2020 Facility for Antiproton and Ion Research in Europe, Darmstadt + SPDX-License-Identifier: GPL-3.0-only + Authors: Pierre-Alain Loizeau [committer], Florian Uhlig, Norbert Herrmann */ + /** @file MonitorTof.C ** @author Florian Uhlig <f.uhlig@gsi.de> ** @date 20.06.2016 @@ -14,10 +18,10 @@ FairRunOnline* run = NULL; /// FIXME: Disable clang formatting to keep easy parameters overview /* clang-format off */ void MonitorTof(TString inFile = "", - TString sHostname = "localhost", + TString sHostname = "node8", Int_t iServerRefreshRate = 100, - Int_t iServerHttpPort = 8080, - UInt_t nrEvents = 0, + Int_t iServerHttpPort = 8060, + UInt_t nrEvents = 100, Bool_t bIgnoreCriticalErrors = kTRUE, Int_t iGdpbIndex = -1, TString sHistoFile = "data/HistosMonitorTof.root") @@ -43,7 +47,7 @@ void MonitorTof(TString inFile = "", TString paramDir = srcDir + "/macro/beamtime/mcbm2021/"; //TString paramDir = "/scratch/cbmroot_macro/macro/beamtime/mcbm2020/"; - TString paramFileTof = paramDir + "mTofPar.par"; + TString paramFileTof = paramDir + "mTofCriPar.par"; TObjString* parTofFileName = new TObjString(paramFileTof); parFileList->Add(parTofFileName); @@ -86,6 +90,7 @@ void MonitorTof(TString inFile = "", iServerHttpPort); // refresh each 100 events /// To avoid the server sucking all Histos from gROOT when no output file is used /// ===> Need to explicitely add the canvases to the server in the task! + run->GetHttpServer()->GetSniffer()->SetScanGlobalDir(kFALSE); run->SetAutoFinish(kFALSE); diff --git a/macro/beamtime/mcbm2021/MonitorTof.sh b/macro/beamtime/mcbm2021/MonitorTof.sh new file mode 100755 index 0000000000..95e142f598 --- /dev/null +++ b/macro/beamtime/mcbm2021/MonitorTof.sh @@ -0,0 +1,24 @@ +#!/bin/bash +# Copyright (C) 2021 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt +# SPDX-License-Identifier: GPL-3.0-only + +# shell script to apply clusterizer calibrations +#SBATCH -J MonitorTof +#SBATCH -D /lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2021 +#SBATCH --time=48:00:00 +#SBATCH --mem=4000 +#SBATCH --partition=long + +CTL_FILE=/tmp/MonitorTofRunning +touch $CTL_FILE +chmod a+w $CTL_FILE + +#define paths +# here for cbmin006 +source /home/shared/herrmann/cbmroot/build/config.sh +cd /home/shared/herrmann/cbmroot/macro/beamtime/mcbm2021 + +while [ -e $CTL_FILE ]; do + root -l 'MonitorTof.C("","localhost",100,8080,200)' &> MonitorTof.log + #sleep 180 +done diff --git a/macro/beamtime/mcbm2021/align_tof.sh b/macro/beamtime/mcbm2021/align_tof.sh new file mode 100755 index 0000000000..bc5431f288 --- /dev/null +++ b/macro/beamtime/mcbm2021/align_tof.sh @@ -0,0 +1,214 @@ +#!/bin/bash +# @file align_tof.sh +# @copyright Copyright (C) 2021 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt +# * @license SPDX-License-Identifier: GPL-3.0-only +# * @authors Norbert Herrmann [orginator] **/ + +# shell script to iterate tracklet calibration histograms +#SBATCH -J align +#SBATCH -D /lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2021 +#SBATCH --time=8:00:00 +##SBATCH --time=6-00:00:00 +#SBATCH --mem=4000 +##SBATCH --partition=long + +X=$((${SLURM_ARRAY_TASK_ID} - 0)) +XXX=$(printf "%03d" "$X") + +cRun=$1 +iTraSetup=$2 + +#which file should be analyzed ? +cSet=$3 +if [[ $cSet = "" ]]; then + cSet="000014500_500" + #cSet="900041500_901" + #cSet="900041500_500" +fi + +# extract iCalSet from cSet +i1=0 +while [ "${cSet:$i1:1}" = "0" ]; do +(( i1 += 1 )) +done +i2=0 +while [ "${cSet:$i2:1}" != "_" ] && [ $i2 -lt ${#cSet} ]; do +(( i2 += 1 )) +done +(( i2 -= i1 )) +iCalSet=${cSet:$i1:$i2} +echo got i1=$i1, i2=$i2, iCalSet=$iCalSet from $cSet + +cCalId=$4; +if [[ $cCalId = "" ]]; then + cCalId=$cRun; +fi + +cCalIdset=$5; +if [[ $cCalIdset = "" ]]; then + cCalIdset=${cSet:1:9}; +fi + +iTrkPar=$6 +if [[ $iTrkPar = "" ]]; then + #iTrkPar=0 # beam + #iTrkPar=1 # beam in limited acceptance (test counter in 2-stack) + iTrkPar=2 # cosmics + #iTrkPar=3 # July2021 acceptance of CRI -mTOF +fi + +nEvt=$7 +if [[ $nEvt = "" ]]; then + nEvt=2000000 # default event number +fi + +iMc=0 +McId=${cRun:0:4} +if [ "$McId" = "mcbm" ]; then + echo processing MC simulation + iMc=1 +fi + +iSel=$8 +if [[ $iSel = "" ]]; then + iSel=12002 +fi +iSel2=-1 + +dTOffScal=$9 +if [[ $dTOffScal = "" ]]; then + dTOffScal=1. +fi + + +dDTres=200000 +dDTRMSres=200000 +iter=0; + +if [ -e /lustre/cbm ]; then +source /lustre/cbm/users/nh/CBM/cbmroot/trunk/build/config.sh -a +wdir=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2021 +outdir=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2021/${cRun} +else +wdir=`pwd` +outdir=${wdir}/${cRun} +fi + +# frange2 limits chi2 +fRange2=9. +TRange2Limit=4. + +#frange1 limits DT spectrum range +fRange1=5. +TRange1Limit=2.5 +dDeadtime=50 + +if [ ! -e ${cRun} ]; then + mkdir $cRun +fi +cd ${cRun} +cp ../.rootrc . +cp ../rootlogon.C . + +# clean directory for start from scratch +#rm -v ${cRun}_tofFindTracks.hst.root +rm -v TCalib.res + +if [[ $iter > 0 ]]; then + cp -v ${cRun}_tofFindTracks.hst${iter}.root ${cRun}_tofFindTracks.hst.root +fi + +nEvtMax=0 +(( nEvtMax = nEvt*10 )) + +while [[ $dDTres > 0 ]]; do + +nEvt=`echo "scale=0;$nEvt * 1./1." | bc` +#nEvt=`echo "scale=0;$nEvt * 1.1/1." | bc` + +if [ $nEvt -gt $nEvtMax ]; then + nEvt=$nEvtMax +fi + +fRange2=`echo "$fRange2 * 0.9" | bc` +compare_TRange2=`echo "$fRange2 < $TRange2Limit" | bc` +if [[ $compare_TRange2 > 0 ]]; then + fRange2=$TRange2Limit +fi + +fRange1=`echo "$fRange1 * 0.9" | bc` +compare_TRange=`echo "$fRange1 < $TRange1Limit" | bc` +if [[ $compare_TRange > 0 ]]; then +fRange1=$TRange1Limit +fi + +# correction modes: 2 - TOff from Tt, 3 - Pull t, 4 - x, 5 - y, 6 - z, >10 - Pull t of individual stations +#for iCal in 3 2 10 11 12 13 14 15 4 5; do +#for iCal in 3 2 4 5; do +#for iCal in 3 2 4; do +#for iCal in 3 2 ; do +#for iCal in 3 80 81; do +for iCal in 3 ; do +#for iCal in 3 5; do +#for iCal in 4 3 ; do # cosmic + nIt=1 + if [ $iter -eq 0 ] && [ $iMc -eq 1 ]; then + echo skip iCal $iCal for MC calibration + iCal=5 + fi + while [[ $nIt > 0 ]]; do + ((iter += 1)) + root -b -q '../ana_trks.C('$nEvt','$iSel','$iCal',"'$cRun'","'$cSet'",'$iSel2','$iTraSetup','$fRange1','$fRange2','$dDeadtime',"'$cCalId'",1,0,'$iCalSet',1,'$iTrkPar','$dTOffScal','$iMc')' + cp -v tofFindTracks.hst.root ${cRun}_tofFindTracks.hst.root + cp -v tofFindTracks.hst.root ${cRun}_tofFindTracks.hst${iter}.root + cp -v tofAnaTestBeam.hst.root ${cRun}_TrkAnaTestBeam.hst.root + dTOffScal=1. + ((nIt -= 1)) + done +done + +iTres=`cat TCalib.res` +if [[ $iTres = 0 ]]; then + echo All tracks lost, stop at iter = $iter + return +fi + +((TRMSres=$iTres%10000)) +((iTres -= TRMSres )) +((Tres = iTres / 10000)) + +if [[ $Tres = 0 ]]; then + Tres=1 +fi +dTdif=`echo "$dDTres - $Tres" | bc` +compare_result=`echo "$Tres < $dDTres" | bc` + +dTRMSdif=`echo "$dDTRMSres - $TRMSres" | bc` +compare_RMS=`echo "$TRMSres < $dDTRMSres" | bc` + +echo `date`: iter=$iter got TOff = $Tres, compare to $dDTres, dTdif = $dTdif, result = $compare_result, TRMS = $TRMSres, old $dDTRMSres, dif = $dTRMSdif, result = $compare_RMS + +((compare_result += $compare_RMS)) +echo result_summary: $compare_result + +if [[ $compare_result > 0 ]]; then + if [[ $Tres = 0 ]]; then + Tres=1 + fi + dDTres=$Tres + dDTRMSres=$TRMSres +else + dDTres=0 + rm ../${cRun}_tofFindTracks.hst.root + cp -v tofFindTracks.hst.root ../${cRun}_tofFindTracks.hst.root + cp -v tofFindTracks.hst.root ./${cRun}_${cSet}._${iTraSetup}_tofFindTracks.hst.root # keep a copy + rm ../${cRun}_TrkAnaTestBeam.hst.root + cp -v tofAnaTestBeam.hst.root ../${cRun}_TrkAnaTestBeam.hst.root +fi + +done + +cd .. +#mv -v slurm-${SLURM_ARRAY_JOB_ID}_${SLURM_ARRAY_TASK_ID}.out ${outdir}/IterTrack_${cRun}_${cSet}.out +mv -v slurm-${SLURM_JOB_ID}.out ${outdir}/AlignTof_${cRun}_${cSet}_${iTraSetup}_${iTrkPar}.out + diff --git a/macro/beamtime/mcbm2021/ana_digi_cal.C b/macro/beamtime/mcbm2021/ana_digi_cal.C index 556a7242b4..1964eeaac3 100644 --- a/macro/beamtime/mcbm2021/ana_digi_cal.C +++ b/macro/beamtime/mcbm2021/ana_digi_cal.C @@ -8,6 +8,7 @@ void ana_digi_cal(Int_t nEvents = 10000000, Int_t calMode = 53, Int_t calSel = 0 { Int_t iVerbose = 1; Int_t iBugCor = 0; + Int_t iFirstEvent = 0; //Specify log level (INFO, DEBUG, DEBUG1, ...) //TString logLevel = "FATAL"; //TString logLevel = "ERROR"; @@ -26,8 +27,8 @@ void ana_digi_cal(Int_t nEvents = 10000000, Int_t calMode = 53, Int_t calSel = 0 cout << "workdir = "<< workDir.Data() << endl; return; */ - TString paramDir = workDir + "/macro/beamtime/mcbm2021/"; - //TString paramDir = "./"; + //TString paramDir = workDir + "/macro/beamtime/mcbm2021/"; + TString paramDir = "./"; TString ParFile = paramDir + "data/" + cFileId + ".params.root"; TString InputFile = paramDir + "data/" + cFileId + ".root"; // TString InputFile = "./data/" + cFileId + ".root"; @@ -47,6 +48,7 @@ void ana_digi_cal(Int_t nEvents = 10000000, Int_t calMode = 53, Int_t calSel = 0 if (iRun < 690) TofGeo = "v20a_mcbm"; else { if (iRun < 1112) { TofGeo = "v21a_mcbm"; } + if (iRun < 1400) { TofGeo = "v21b_mcbm"; } else { if (iRun < 1400) { TofGeo = "v21b_mcbm"; } else { @@ -57,6 +59,14 @@ void ana_digi_cal(Int_t nEvents = 10000000, Int_t calMode = 53, Int_t calSel = 0 cout << "Geometry version " << TofGeo << endl; + if (nEvents > -1) { + if (iRun > 10000) { + iFirstEvent = 2000000; // late start of Buc ... + if (iRun > 1050) iFirstEvent = 10000000; + nEvents += iFirstEvent; + } + } + // TObjString *tofDigiFile = new TObjString(workDir + "/parameters/tof/tof_" + TofGeo + ".digi.par"); // TOF digi file // parFileList->Add(tofDigiFile); @@ -106,14 +116,15 @@ void ana_digi_cal(Int_t nEvents = 10000000, Int_t calMode = 53, Int_t calSel = 0 tofClust->SetChannelDeadtime(dDeadtime); // artificial deadtime in ns tofClust->SetEnableAvWalk(kFALSE); //tofClust->SetEnableMatchPosScaling(kFALSE); // turn off projection to nominal target - tofClust->SetYFitMin(1.E4); + tofClust->SetYFitMin(1.E3); tofClust->SetToDAv(0.04); // tofClust->SetTimePeriod(25600.); // ignore coarse time // tofClust->SetCorMode(iBugCor); // correct missing hits - //tofClust->SetIdMode(0); // calibrate on counter level + //tofClust->SetIdMode(0); // calibrate on counter level tofClust->SetIdMode(1); // calibrate on module level // tofClust->SetDeadStrips(15,23); // declare dead strip for T0M3,Rpc0,Strip 23 //tofClust->SetDeadStrips(25,16); // declare non-existant diamond strip (#5) dead + tofClust->SetMemoryTime(1000000.); // internal storage time of hits in ns Int_t calSelRead = calSel; if (calSel < 0) calSelRead = 0; @@ -223,6 +234,7 @@ void ana_digi_cal(Int_t nEvents = 10000000, Int_t calMode = 53, Int_t calSel = 0 case 72: case 73: tofClust->SetTRefDifMax(2.5); // in ns + tofClust->SetTRefDifMax(10.); // in ns tofClust->PosYMaxScal(0.9); //in % of length break; case 82: @@ -346,7 +358,7 @@ void ana_digi_cal(Int_t nEvents = 10000000, Int_t calMode = 53, Int_t calSel = 0 // ----- Intialise and run -------------------------------------------- run->Init(); cout << "Starting run" << endl; - run->Run(0, nEvents); + run->Run(iFirstEvent, nEvents); //tofClust->Finish(); // ------------------------------------------------------------------------ // default display diff --git a/macro/beamtime/mcbm2021/ana_digi_cal_all.C b/macro/beamtime/mcbm2021/ana_digi_cal_all.C index a0c1603d5c..fcdcd06876 100644 --- a/macro/beamtime/mcbm2021/ana_digi_cal_all.C +++ b/macro/beamtime/mcbm2021/ana_digi_cal_all.C @@ -2,12 +2,14 @@ SPDX-License-Identifier: GPL-3.0-only Authors: Florian Uhlig [committer] */ -void ana_digi_cal_all(Int_t nEvents = 10000000, Int_t calMode = 53, Int_t calSel = 0, Int_t calSm = 900, +void ana_digi_cal_all(Int_t nEvents = 10000000, Int_t calMode = 93, Int_t calSel = 0, Int_t calSm = 900, Int_t RefSel = 1, TString cFileId = "Test", Int_t iCalSet = 910601600, Bool_t bOut = 0, Int_t iSel2 = 0, Double_t dDeadtime = 50, TString cCalId = "XXX", Int_t iPlot = 1) { Int_t iVerbose = 1; Int_t iBugCor = 0; + Int_t iFirstEvent = 0; + //Specify log level (INFO, DEBUG, DEBUG1, ...) //TString logLevel = "FATAL"; //TString logLevel = "ERROR"; @@ -30,7 +32,7 @@ void ana_digi_cal_all(Int_t nEvents = 10000000, Int_t calMode = 53, Int_t calSel TString paramDir = workDir + "/macro/beamtime/mcbm2021/"; //TString paramDir = "./"; TString ParFile = paramDir + "data/" + cFileId + ".params.root"; - TString InputFile = paramDir + "data/" + cFileId + ".root"; + TString InputFile = paramDir + "RawDataIn/" + cFileId + ".root"; // TString InputFile = "./data/" + cFileId + ".root"; TString OutputFile = paramDir + "data/TofHits_" + cFileId + Form("_%09d_%03d_%02.0f_Cal", iCalSet, iSel2, dDeadtime) + cCalId + ".out.root"; @@ -42,26 +44,42 @@ void ana_digi_cal_all(Int_t nEvents = 10000000, Int_t calMode = 53, Int_t calSel TString FId = cFileId; Int_t iNLen = FId.First("."); + if (iNLen <= 0) iNLen = FId.Length(); TString cRun(FId(0, iNLen)); Int_t iRun = cRun.Atoi(); + cout << "FileId " << cFileId << ", Run " << iRun << endl; TString TofGeo = ""; if (iRun < 690) TofGeo = "v20a_mcbm"; else { if (iRun < 1112) { TofGeo = "v21a_mcbm"; } - else { if (iRun < 1400) { TofGeo = "v21b_mcbm"; } else { - TofGeo = "v21d_mcbm"; - } + if (iRun < 1400) { TofGeo = "v21b_mcbm"; } + else { + if (iRun < 2000) { TofGeo = "v21d_mcbm"; } + else { + if (iRun < 2150) { TofGeo = "v21e_mcbm"; } + else { + if (iRun < 2176) { TofGeo = "v21f_mcbm"; } + else { + TofGeo = "v21g_mcbm"; + } + } + } + } } } - cout << "Geometry version " << TofGeo << endl; - // TObjString *tofDigiFile = new TObjString(workDir + "/parameters/tof/tof_" + TofGeo + ".digi.par"); // TOF digi file - // parFileList->Add(tofDigiFile); + if (nEvents > -1) { + if (iRun > 10000) { + iFirstEvent = 2000000; // late start of Buc ... + if (iRun > 1050) iFirstEvent = 10000000; + nEvents += iFirstEvent; + } + } + - // TObjString tofDigiBdfFile = new TObjString( paramDir + "/tof." + FPar + "digibdf.par"); TObjString* tofDigiBdfFile = new TObjString(workDir + "/parameters/tof/tof_" + TofGeo + ".digibdf.par"); parFileList->Add(tofDigiBdfFile); @@ -82,247 +100,16 @@ void ana_digi_cal_all(Int_t nEvents = 10000000, Int_t calMode = 53, Int_t calSel // ----- Reconstruction run ------------------------------------------- FairRunAna* run = new FairRunAna(); - run->SetInputFile(InputFile.Data()); - //run->AddFriend(InputFile.Data()); - // run->SetOutputFile(OutputFile); - //run->SetSink( new FairRootFileSink( OutputFile.Data() ) ); + FairFileSource* fFileSource = new FairFileSource(InputFile.Data()); + run->SetSource(fFileSource); run->SetUserOutputFileName(OutputFile.Data()); run->SetSink(new FairRootFileSink(run->GetUserOutputFileName())); - CbmTofEventClusterizer* tofClust = new CbmTofEventClusterizer("TOF Event Clusterizer", iVerbose, bOut); - - tofClust->SetCalMode(calMode); - tofClust->SetCalSel(calSel); - tofClust->SetCaldXdYMax(3.); // geometrical matching window in cm - tofClust->SetCalCluMulMax(5.); // Max Counter Cluster Multiplicity for filling calib histos - tofClust->SetCalRpc(calSm); // select detector for calibration update - tofClust->SetTRefId(RefSel); // reference trigger for offset calculation - tofClust->SetTotMax(20.); // Tot upper limit for walk corection - tofClust->SetTotMin(0.); //(12000.); // Tot lower limit for walk correction - tofClust->SetTotPreRange(5.); // effective lower Tot limit in ns from peak position - tofClust->SetTotMean(5.); // Tot calibration target value in ns - tofClust->SetMaxTimeDist(1.0); // default cluster range in ns - //tofClust->SetMaxTimeDist(0.); //Deb// default cluster range in ns - tofClust->SetDelTofMax(5.); // acceptance range for cluster distance in ns (!) - tofClust->SetSel2MulMax(3); // limit Multiplicity in 2nd selector - tofClust->SetChannelDeadtime(dDeadtime); // artificial deadtime in ns - tofClust->SetEnableAvWalk(kFALSE); - //tofClust->SetEnableMatchPosScaling(kFALSE); // turn off projection to nominal target - tofClust->SetYFitMin(1.E3); - tofClust->SetToDAv(0.04); - // tofClust->SetTimePeriod(25600.); // ignore coarse time - // tofClust->SetCorMode(iBugCor); // correct missing hits - //tofClust->SetIdMode(0); // calibrate on counter level - tofClust->SetIdMode(1); // calibrate on module level - // tofClust->SetDeadStrips(15,23); // declare dead strip for T0M3,Rpc0,Strip 23 - //tofClust->SetDeadStrips(25,16); // declare non-existant diamond strip (#5) dead - - Int_t calSelRead = calSel; - if (calSel < 0) calSelRead = 0; - TString cFname = Form("%s_set%09d_%02d_%01dtofClust.hst.root", cFileId.Data(), iCalSet, calMode, calSelRead); - if (cCalId != "XXX") - cFname = Form("%s_set%09d_%02d_%01dtofClust.hst.root", cCalId.Data(), iCalSet, calMode, calSelRead); - tofClust->SetCalParFileName(cFname); - TString cOutFname = Form("tofClust_%s_set%09d.hst.root", cFileId.Data(), iCalSet); - tofClust->SetOutHstFileName(cOutFname); - - TString cAnaFile = Form("%s_%09d%03d_tofAna.hst.root", cFileId.Data(), iCalSet, iSel2); - - switch (calMode) { - case -1: // initial check of raw data - tofClust->SetTotMax(256.); // range in bin number - tofClust->SetTotPreRange(256.); - //tofClust->SetTotMin(1.); - tofClust->SetTRefDifMax(26000.); // in ns - tofClust->PosYMaxScal(10000.); // in % of length - tofClust->SetMaxTimeDist(0.); // no cluster building - //tofClust->SetTimePeriod(25600.); // inspect coarse time - break; - case 0: // initial calibration - tofClust->SetTotMax(256.); // range in bin number - tofClust->SetTotPreRange(256.); - //tofClust->SetTotMin(1.); - tofClust->SetTRefDifMax(1000.); // in ns - tofClust->PosYMaxScal(10.); // in % of length - tofClust->SetMaxTimeDist(0.); // no cluster building - break; - case 1: // save offsets, update walks, for diamonds - tofClust->SetTotMax(256.); // range in bin number - tofClust->SetTotPreRange(256.); - tofClust->SetTRefDifMax(6.25); // in ns - //tofClust->SetTimePeriod(6.25); // inspect coarse time - tofClust->PosYMaxScal(10.); // in % of length - break; - case 11: - tofClust->SetTRefDifMax(5.); // in ns - tofClust->PosYMaxScal(3.0); // in % of length - break; - case 21: - tofClust->SetTRefDifMax(3.0); // in ns - tofClust->PosYMaxScal(2.0); // in % of length - break; - case 31: - tofClust->SetTRefDifMax(3.); // in ns - tofClust->PosYMaxScal(1.); // in % of length - break; - case 41: - tofClust->SetTRefDifMax(2.0); // in ns - tofClust->PosYMaxScal(0.9); // in % of length - break; - case 51: - tofClust->SetTRefDifMax(2.0); // in ns - tofClust->PosYMaxScal(0.8); // in % of length - break; - case 61: - tofClust->SetTRefDifMax(1.5); // in ns - tofClust->PosYMaxScal(0.75); // in % of length - break; - case 71: - tofClust->SetTRefDifMax(0.8); // in ns - tofClust->PosYMaxScal(0.6); // in % of length - break; - - case 2: // time difference calibration - tofClust->SetTRefDifMax(300.); // in ns - tofClust->PosYMaxScal(1000.); //in % of length - break; - - case 3: // time offsets - tofClust->SetTRefDifMax(200.); // in ns - tofClust->PosYMaxScal(100.); //in % of length - tofClust->SetMaxTimeDist(0.); // no cluster building - break; - case 12: - case 13: - tofClust->SetTRefDifMax(100.); // in ns - tofClust->PosYMaxScal(10.); //in % of length - break; - case 22: - case 23: - tofClust->SetTRefDifMax(50.); // in ns - tofClust->PosYMaxScal(5.); //in % of length - break; - case 32: - case 33: - tofClust->SetTRefDifMax(25.); // in ns - tofClust->PosYMaxScal(4.); //in % of length - break; - case 42: - case 43: - tofClust->SetTRefDifMax(12.); // in ns - tofClust->PosYMaxScal(2.); //in % of length - break; - case 52: - case 53: - tofClust->SetTRefDifMax(10.); // in ns - tofClust->PosYMaxScal(1.5); //in % of length - break; - case 62: - case 63: - tofClust->SetTRefDifMax(10.); // in ns - tofClust->PosYMaxScal(1.); //in % of length - break; - case 72: - case 73: - tofClust->SetTRefDifMax(10.); // in ns - tofClust->PosYMaxScal(0.9); //in % of length - break; - case 82: - case 83: - tofClust->SetTRefDifMax(10.); // in ns - tofClust->PosYMaxScal(0.8); //in % of length - break; - case 92: - case 93: - tofClust->SetTRefDifMax(10.); // in ns - tofClust->PosYMaxScal(0.75); //in % of length - break; - - case 4: // velocity dependence (DelTOF) - case 14: - tofClust->SetTRefDifMax(25.); // in ns - tofClust->PosYMaxScal(2.0); //in % of length - break; - case 24: - tofClust->SetTRefDifMax(5.); // in ns - tofClust->PosYMaxScal(1.5); //in % of length - break; - case 34: - tofClust->SetTRefDifMax(5.); // in ns - tofClust->PosYMaxScal(1.2); //in % of length - break; - case 44: - tofClust->SetTRefDifMax(3.5); // in ns - tofClust->PosYMaxScal(1.0); //in % of length - break; - case 54: - tofClust->SetTRefDifMax(3.0); // in ns - tofClust->PosYMaxScal(0.9); //in % of length - break; - case 64: - tofClust->SetTRefDifMax(2.5); // in ns - tofClust->PosYMaxScal(0.8); //in % of length - break; - case 74: - tofClust->SetTRefDifMax(2.0); // in ns - tofClust->PosYMaxScal(0.7); //in % of length - break; - default: cout << "<E> Calib mode not implemented! stop execution of script" << endl; return; - } - - Int_t iBRef = iCalSet % 1000; - Int_t iSet = (iCalSet - iBRef) / 1000; - Int_t iRSel = 0; - Int_t iRSelTyp = 0; - Int_t iRSelSm = 0; - Int_t iRSelRpc = 0; - iRSel = iBRef; // use diamond - - Int_t iRSelin = iRSel; - iRSelRpc = iRSel % 10; - iRSelTyp = (iRSel - iRSelRpc) / 10; - iRSelSm = iRSelTyp % 10; - iRSelTyp = (iRSelTyp - iRSelSm) / 10; - - tofClust->SetBeamRefId(iRSelTyp); // define Beam reference counter - tofClust->SetBeamRefSm(iRSelSm); - tofClust->SetBeamRefDet(iRSelRpc); - tofClust->SetBeamAddRefMul(-1); - tofClust->SetBeamRefMulMax(3); - - Int_t iSel2in = iSel2; - Int_t iSel2Rpc = iSel2 % 10; - iSel2 = (iSel2 - iSel2Rpc) / 10; - Int_t iSel2Sm = iSel2 % 10; - iSel2 = (iSel2 - iSel2Sm) / 10; - - tofClust->SetSel2Id(iSel2); - tofClust->SetSel2Sm(iSel2Sm); - tofClust->SetSel2Rpc(iSel2Rpc); - - Int_t iRef = iSet % 1000; - Int_t iDut = (iSet - iRef) / 1000; - Int_t iDutRpc = iDut % 10; - iDut = (iDut - iDutRpc) / 10; - Int_t iDutSm = iDut % 10; - iDut = (iDut - iDutSm) / 10; - - tofClust->SetDutId(iDut); - tofClust->SetDutSm(iDutSm); - tofClust->SetDutRpc(iDutRpc); - - Int_t iRefRpc = iRef % 10; - iRef = (iRef - iRefRpc) / 10; - Int_t iRefSm = iRef % 10; - iRef = (iRef - iRefSm) / 10; - - tofClust->SetSelId(iRef); - tofClust->SetSelSm(iRefSm); - tofClust->SetSelRpc(iRefRpc); - - run->AddTask(tofClust); - - cout << "Run with iRSel = " << iRSel << ", iSel2 = " << iSel2in << endl; + gROOT->LoadMacro("ini_Clusterizer.C"); + Char_t* cCmd = Form("ini_Clusterizer(%d,%d,%d,%d,\"%s\",%d,%d,%d,%f,\"%s\")", calMode, calSel, calSm, RefSel, + cFileId.Data(), iCalSet, (Int_t) bOut, iSel2, dDeadtime, cCalId.Data()); + cout << "<I> " << cCmd << endl; + gInterpreter->ProcessLine(cCmd); // ----- Parameter database -------------------------------------------- @@ -347,17 +134,18 @@ void ana_digi_cal_all(Int_t nEvents = 10000000, Int_t calMode = 53, Int_t calSel // ----- Intialise and run -------------------------------------------- run->Init(); cout << "Starting run" << endl; - run->Run(0, nEvents); + run->Run(iFirstEvent, nEvents); + //tofClust->Finish(); // ------------------------------------------------------------------------ // default display - /* - TString Display_Status = "pl_over_Mat04D4best.C"; - TString Display_Funct = "pl_over_Mat04D4best()"; - gROOT->LoadMacro(Display_Status); - */ + gROOT->LoadMacro("save_hst.C"); + TString FSave = Form("save_hst(\"CluStatus%d_%d_Cal_%s.hst.root\")", iCalSet, iSel2, cCalId.Data()); + gInterpreter->ProcessLine(FSave.Data()); + + //if(calMode%10 >7) return; gROOT->LoadMacro("fit_ybox.h"); gROOT->LoadMacro("pl_all_CluMul.C"); @@ -371,71 +159,38 @@ void ana_digi_cal_all(Int_t nEvents = 10000000, Int_t calMode = 53, Int_t calSel gROOT->LoadMacro("pl_over_MatD4sel.C"); gROOT->LoadMacro("pl_all_Sel2D.C"); gROOT->LoadMacro("pl_all_2D.C"); + gROOT->LoadMacro("pl_all_Cal2D.C"); if (iPlot) { - switch (iSet) { + switch (calMode % 10) { + case 9: + for (Int_t iOpt = 0; iOpt < 7; iOpt++) { + gInterpreter->ProcessLine(Form("pl_all_Cal2D(%d)", iOpt)); + } + break; + default: - for (Int_t iOpt = 0; iOpt < 8; iOpt++) { + for (Int_t iOpt = 0; iOpt < 7; iOpt++) { for (Int_t iSel = 0; iSel < 2; iSel++) { gInterpreter->ProcessLine(Form("pl_all_Sel2D(%d,%d)", iOpt, iSel)); } } - for (Int_t iOpt = 0; iOpt < 12; iOpt++) { + for (Int_t iOpt = 6; iOpt < 10; iOpt++) { gInterpreter->ProcessLine(Form("pl_all_2D(%d)", iOpt)); } - /* - gInterpreter->ProcessLine("pl_over_clu(0,0,0)"); - gInterpreter->ProcessLine("pl_over_clu(0,0,1)"); - gInterpreter->ProcessLine("pl_over_clu(0,0,2)"); - gInterpreter->ProcessLine("pl_over_clu(0,0,3)"); - gInterpreter->ProcessLine("pl_over_clu(0,0,4)"); - gInterpreter->ProcessLine("pl_over_clu(0,1,0)"); - gInterpreter->ProcessLine("pl_over_clu(0,1,1)"); - gInterpreter->ProcessLine("pl_over_clu(0,1,2)"); - gInterpreter->ProcessLine("pl_over_clu(0,1,3)"); - gInterpreter->ProcessLine("pl_over_clu(0,1,4)"); - gInterpreter->ProcessLine("pl_over_clu(0,2,0)"); - gInterpreter->ProcessLine("pl_over_clu(0,2,1)"); - gInterpreter->ProcessLine("pl_over_clu(0,2,2)"); - gInterpreter->ProcessLine("pl_over_clu(0,2,3)"); - gInterpreter->ProcessLine("pl_over_clu(0,2,4)"); - gInterpreter->ProcessLine("pl_over_clu(0,3,0)"); - gInterpreter->ProcessLine("pl_over_clu(0,3,1)"); - gInterpreter->ProcessLine("pl_over_clu(0,3,2)"); - gInterpreter->ProcessLine("pl_over_clu(0,3,3)"); - gInterpreter->ProcessLine("pl_over_clu(0,3,4)"); - gInterpreter->ProcessLine("pl_over_clu(0,4,0)"); - gInterpreter->ProcessLine("pl_over_clu(0,4,1)"); - gInterpreter->ProcessLine("pl_over_clu(0,4,2)"); - gInterpreter->ProcessLine("pl_over_clu(0,4,3)"); - gInterpreter->ProcessLine("pl_over_clu(0,4,4)"); - - gInterpreter->ProcessLine("pl_over_clu(5,0,0)"); - gInterpreter->ProcessLine("pl_over_cluSel(0,5,0,0)"); - gInterpreter->ProcessLine("pl_over_cluSel(1,5,0,0)"); - - for(Int_t iSm=0; iSm<3; iSm++) - for (Int_t iRpc=0; iRpc<5; iRpc++) - for (Int_t iSel=0; iSel<2; iSel++){ - gInterpreter->ProcessLine(Form("pl_over_cluSel(%d,0,%d,%d)",iSel,iSm,iRpc)); - gInterpreter->ProcessLine(Form("pl_over_Walk2(%d,0,%d,%d)",iSel,iSm,iRpc)); - } - */ + + /* gInterpreter->ProcessLine("pl_all_CluMul()"); gInterpreter->ProcessLine("pl_all_CluRate()"); gInterpreter->ProcessLine("pl_all_CluRate(5,1)"); gInterpreter->ProcessLine("pl_all_CluPosEvol()"); gInterpreter->ProcessLine("pl_all_CluTimeEvol()"); gInterpreter->ProcessLine("pl_all_dTSel()"); - - // gInterpreter->ProcessLine("pl_over_MatD4sel()"); - // gInterpreter->ProcessLine(Display_Funct.Data()); + */ break; ; } } - TString FSave = Form("save_hst(\"CluStatus%d_%d_Cal_%s.hst.root\")", iCalSet, iSel2in, cCalId.Data()); - gInterpreter->ProcessLine(FSave.Data()); } diff --git a/macro/beamtime/mcbm2021/ana_digi_cal_evt.C b/macro/beamtime/mcbm2021/ana_digi_cal_evt.C new file mode 100644 index 0000000000..376400fded --- /dev/null +++ b/macro/beamtime/mcbm2021/ana_digi_cal_evt.C @@ -0,0 +1,239 @@ +/* Copyright (C) 2021 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt + SPDX-License-Identifier: GPL-3.0-only + Authors: Florian Uhlig [committer] */ + +void ana_digi_cal_evt(Int_t nEvents = 10000000, Int_t calMode = 93, Int_t calSel = 0, Int_t calSm = 900, + Int_t RefSel = 1, TString cFileId = "2038", Int_t iCalSet = 910601600, Bool_t bOut = 0, + Int_t iSel2 = 0, Double_t dDeadtime = 50, TString cCalId = "XXX", Int_t iPlot = 1) +{ + Int_t iVerbose = 1; + Int_t iBugCor = 0; + Int_t iFirstEvent = 0; + + //Specify log level (INFO, DEBUG, DEBUG1, ...) + //TString logLevel = "FATAL"; + //TString logLevel = "ERROR"; + TString logLevel = "INFO"; + //TString logLevel = "DEBUG"; + //TString logLevel = "DEBUG1"; + //TString logLevel = "DEBUG2"; + //TString logLevel = "DEBUG3"; + FairLogger::GetLogger(); + gLogger->SetLogScreenLevel(logLevel); + gLogger->SetLogVerbosityLevel("VERYHIGH"); + //gLogger->SetLogVerbosityLevel("MEDIUM"); + + TString workDir = gSystem->Getenv("VMCWORKDIR"); + /* + TString workDir = (TString)gInterpreter->ProcessLine(".! pwd"); + cout << "workdir = "<< workDir.Data() << endl; + return; + */ + TString paramDir = workDir + "/macro/beamtime/mcbm2021/"; + //TString paramDir = "./"; + TString ParFile = paramDir + "data/" + cFileId + ".params.root"; + TString InputFile = paramDir + "RawDataIn/" + cFileId + ".digievents.root"; + // TString InputFile = "./data/" + cFileId + ".root"; + TString OutputFile = paramDir + "data/TofHits_" + cFileId + Form("_%09d_%03d_%02.0f_Cal", iCalSet, iSel2, dDeadtime) + + cCalId + ".out.root"; + + TString shcmd = "rm -v " + ParFile; + gSystem->Exec(shcmd.Data()); + + TList* parFileList = new TList(); + + TString FId = cFileId; + Int_t iNLen = FId.First("."); + if (iNLen <= 0) iNLen = FId.Length(); + TString cRun(FId(0, iNLen)); + Int_t iRun = cRun.Atoi(); + cout << "FileId " << cFileId << ", Run " << iRun << endl; + TString TofGeo = ""; + if (iRun < 690) TofGeo = "v20a_mcbm"; + else { + if (iRun < 1112) { TofGeo = "v21a_mcbm"; } + if (iRun < 1400) { TofGeo = "v21b_mcbm"; } + else { + if (iRun < 1400) { TofGeo = "v21b_mcbm"; } + else { + if (iRun < 2000) { TofGeo = "v21d_mcbm"; } + else { + if (iRun < 2100) { TofGeo = "v21e_mcbm"; } + else { + TofGeo = "v21f_mcbm"; + } + } + } + } + } + cout << "Geometry version " << TofGeo << endl; + + if (nEvents > -1) { + if (iRun > 10000) { + iFirstEvent = 2000000; // late start of Buc ... + if (iRun > 1050) iFirstEvent = 10000000; + nEvents += iFirstEvent; + } + } + + + TObjString* tofDigiBdfFile = new TObjString(workDir + "/parameters/tof/tof_" + TofGeo + ".digibdf.par"); + parFileList->Add(tofDigiBdfFile); + + TString geoDir = gSystem->Getenv("VMCWORKDIR"); + TString geoFile = geoDir + "/geometry/tof/geofile_tof_" + TofGeo + ".root"; + TFile* fgeo = new TFile(geoFile); + TGeoManager* geoMan = (TGeoManager*) fgeo->Get("FAIRGeom"); + if (NULL == geoMan) { + cout << "<E> FAIRGeom not found in geoFile" << endl; + return; + } + + if (0) { + TGeoVolume* master = geoMan->GetTopVolume(); + master->SetVisContainers(1); + master->Draw("ogl"); + } + + // ----- Reconstruction run ------------------------------------------- + FairRunAna* run = new FairRunAna(); + FairFileSource* fFileSource = new FairFileSource(InputFile.Data()); + run->SetSource(fFileSource); + run->SetUserOutputFileName(OutputFile.Data()); + run->SetSink(new FairRootFileSink(run->GetUserOutputFileName())); + + // ---- Make Reco Events ---------------------------------------------- + // ---- This is required if the input is in DigiEvent format + auto makeEvents = std::make_unique<CbmTaskMakeRecoEvents>(); + //LOG(info) << "-I- Adding task " << makeEvents->GetName(); + run->AddTask(makeEvents.release()); + // ------------------------------------------------------------------------ + + gROOT->LoadMacro("ini_Clusterizer.C"); + Char_t* cCmd = Form("ini_Clusterizer(%d,%d,%d,%d,\"%s\",%d,%d,%d,%f,\"%s\")", calMode, calSel, calSm, RefSel, + cFileId.Data(), iCalSet, (Int_t) bOut, iSel2, dDeadtime, cCalId.Data()); + cout << "<I> " << cCmd << endl; + gInterpreter->ProcessLine(cCmd); + + // ----- Parameter database -------------------------------------------- + + FairRuntimeDb* rtdb = run->GetRuntimeDb(); + Bool_t kParameterMerged = kTRUE; + FairParRootFileIo* parIo2 = new FairParRootFileIo(kParameterMerged); + parIo2->open(ParFile.Data(), "UPDATE"); + parIo2->print(); + rtdb->setFirstInput(parIo2); + + FairParAsciiFileIo* parIo1 = new FairParAsciiFileIo(); + parIo1->open(parFileList, "in"); + parIo1->print(); + rtdb->setSecondInput(parIo1); + rtdb->print(); + rtdb->printParamContexts(); + + // FairParRootFileIo* parInput1 = new FairParRootFileIo(); + // parInput1->open(ParFile.Data()); + // rtdb->setFirstInput(parInput1); + + // ----- Intialise and run -------------------------------------------- + run->Init(); + cout << "Starting run" << endl; + run->Run(iFirstEvent, nEvents); + + //tofClust->Finish(); + // ------------------------------------------------------------------------ + // default display + + + gROOT->LoadMacro("save_hst.C"); + TString FSave = Form("save_hst(\"CluStatus%d_%d_Cal_%s.hst.root\")", iCalSet, iSel2, cCalId.Data()); + gInterpreter->ProcessLine(FSave.Data()); + + //if(calMode%10 >7) return; + + gROOT->LoadMacro("fit_ybox.h"); + gROOT->LoadMacro("pl_all_CluMul.C"); + gROOT->LoadMacro("pl_all_CluRate.C"); + gROOT->LoadMacro("pl_all_CluPosEvol.C"); + gROOT->LoadMacro("pl_all_CluTimeEvol.C"); + gROOT->LoadMacro("pl_over_cluSel.C"); + gROOT->LoadMacro("pl_over_clu.C"); + gROOT->LoadMacro("pl_over_Walk2.C"); + gROOT->LoadMacro("pl_all_dTSel.C"); + gROOT->LoadMacro("pl_over_MatD4sel.C"); + gROOT->LoadMacro("pl_all_Sel2D.C"); + gROOT->LoadMacro("pl_all_2D.C"); + gROOT->LoadMacro("pl_all_Cal2D.C"); + + if (iPlot) { + + switch (calMode % 10) { + case 9: + for (Int_t iOpt = 0; iOpt < 7; iOpt++) { + gInterpreter->ProcessLine(Form("pl_all_Cal2D(%d)", iOpt)); + } + break; + + default: + for (Int_t iOpt = 0; iOpt < 8; iOpt++) { + for (Int_t iSel = 0; iSel < 2; iSel++) { + gInterpreter->ProcessLine(Form("pl_all_Sel2D(%d,%d)", iOpt, iSel)); + } + } + + for (Int_t iOpt = 0; iOpt < 12; iOpt++) { + gInterpreter->ProcessLine(Form("pl_all_2D(%d)", iOpt)); + } + + /* + gInterpreter->ProcessLine("pl_over_clu(0,0,0)"); + gInterpreter->ProcessLine("pl_over_clu(0,0,1)"); + gInterpreter->ProcessLine("pl_over_clu(0,0,2)"); + gInterpreter->ProcessLine("pl_over_clu(0,0,3)"); + gInterpreter->ProcessLine("pl_over_clu(0,0,4)"); + gInterpreter->ProcessLine("pl_over_clu(0,1,0)"); + gInterpreter->ProcessLine("pl_over_clu(0,1,1)"); + gInterpreter->ProcessLine("pl_over_clu(0,1,2)"); + gInterpreter->ProcessLine("pl_over_clu(0,1,3)"); + gInterpreter->ProcessLine("pl_over_clu(0,1,4)"); + gInterpreter->ProcessLine("pl_over_clu(0,2,0)"); + gInterpreter->ProcessLine("pl_over_clu(0,2,1)"); + gInterpreter->ProcessLine("pl_over_clu(0,2,2)"); + gInterpreter->ProcessLine("pl_over_clu(0,2,3)"); + gInterpreter->ProcessLine("pl_over_clu(0,2,4)"); + gInterpreter->ProcessLine("pl_over_clu(0,3,0)"); + gInterpreter->ProcessLine("pl_over_clu(0,3,1)"); + gInterpreter->ProcessLine("pl_over_clu(0,3,2)"); + gInterpreter->ProcessLine("pl_over_clu(0,3,3)"); + gInterpreter->ProcessLine("pl_over_clu(0,3,4)"); + gInterpreter->ProcessLine("pl_over_clu(0,4,0)"); + gInterpreter->ProcessLine("pl_over_clu(0,4,1)"); + gInterpreter->ProcessLine("pl_over_clu(0,4,2)"); + gInterpreter->ProcessLine("pl_over_clu(0,4,3)"); + gInterpreter->ProcessLine("pl_over_clu(0,4,4)"); + + gInterpreter->ProcessLine("pl_over_clu(5,0,0)"); + gInterpreter->ProcessLine("pl_over_cluSel(0,5,0,0)"); + gInterpreter->ProcessLine("pl_over_cluSel(1,5,0,0)"); + + for(Int_t iSm=0; iSm<3; iSm++) + for (Int_t iRpc=0; iRpc<5; iRpc++) + for (Int_t iSel=0; iSel<2; iSel++){ + gInterpreter->ProcessLine(Form("pl_over_cluSel(%d,0,%d,%d)",iSel,iSm,iRpc)); + gInterpreter->ProcessLine(Form("pl_over_Walk2(%d,0,%d,%d)",iSel,iSm,iRpc)); + } + gInterpreter->ProcessLine("pl_all_CluMul()"); + gInterpreter->ProcessLine("pl_all_CluRate()"); + gInterpreter->ProcessLine("pl_all_CluRate(5,1)"); + gInterpreter->ProcessLine("pl_all_CluPosEvol()"); + gInterpreter->ProcessLine("pl_all_CluTimeEvol()"); + gInterpreter->ProcessLine("pl_all_dTSel()"); + */ + + // gInterpreter->ProcessLine("pl_over_MatD4sel()"); + // gInterpreter->ProcessLine(Display_Funct.Data()); + break; + ; + } + } +} diff --git a/macro/beamtime/mcbm2021/ana_trks.C b/macro/beamtime/mcbm2021/ana_trks.C index 83f7a54222..761058713b 100644 --- a/macro/beamtime/mcbm2021/ana_trks.C +++ b/macro/beamtime/mcbm2021/ana_trks.C @@ -5,9 +5,12 @@ void ana_trks(Int_t nEvents = 10000, Int_t iSel = 1, Int_t iGenCor = 1, TString cFileId = "48.50.7.1", TString cSet = "000010020", Int_t iSel2 = 20, Int_t iTrackingSetup = 2, Double_t dScalFac = 1., Double_t dChi2Lim2 = 500., Double_t dDeadtime = 50, TString cCalId = "", Int_t iAnaCor = 1, - Bool_t bUseSigCalib = kFALSE, Int_t iCalSet = 30040500, Int_t iCalOpt = 1, Int_t iMc = 0) + Bool_t bUseSigCalib = kFALSE, Int_t iCalSet = 30040500, Int_t iCalOpt = 1, Int_t iTrkPar = 0, + Double_t dTOffScal = 1., Int_t iMc = 0) { Int_t iVerbose = 1; + Int_t iFirstEvent = 0; + if (cCalId == "") cCalId = cFileId; TString FId = cFileId; Int_t iNLen = FId.First("."); @@ -26,7 +29,7 @@ void ana_trks(Int_t nEvents = 10000, Int_t iSel = 1, Int_t iGenCor = 1, TString //TString paramDir = "."; TString ParFile = paramDir + "/data/" + cFileId.Data() + ".params.root"; - TString InputFile = paramDir + "/data/" + cFileId.Data() + ".root"; + TString InputFile = paramDir + "/data/" + cFileId.Data() + ".digievents.root"; TString InputDigiFile = paramDir + "/data/TofHits_" + cFileId.Data() + Form("_%s_%02.0f_Cal", cSet.Data(), dDeadtime) + cCalId + ".out.root"; if (iMc == 1) { @@ -58,11 +61,30 @@ void ana_trks(Int_t nEvents = 10000, Int_t iSel = 1, Int_t iGenCor = 1, TString else { if (iRun < 1400) { TofGeo = "v21b_mcbm"; } else { - TofGeo = "v21d_mcbm"; + if (iRun < 2050) { TofGeo = "v21d_mcbm"; } + else { + if (iRun < 2150) { TofGeo = "v21e_mcbm"; } + else { + if (iRun < 2176) { TofGeo = "v21f_mcbm"; } + else { + TofGeo = "v21g_mcbm"; + } + } + } } } } + if (iRun > 100000) { + iFirstEvent = 2000000; // due to late start of Buc ... + nEvents += iFirstEvent; + } + + if (iRun > 10000) { + iFirstEvent = 2000000; // due to late start of Buc ... + nEvents += iFirstEvent; + } + TObjString* tofDigiBdfFile = new TObjString(workDir + "/parameters/tof/tof_" + TofGeo + ".digibdf.par"); parFileList->Add(tofDigiBdfFile); @@ -94,7 +116,9 @@ void ana_trks(Int_t nEvents = 10000, Int_t iSel = 1, Int_t iGenCor = 1, TString //run->SetInputFile(InputFile.Data()); //run->AddFriend(InputDigiFile.Data()); - run->SetInputFile(InputDigiFile.Data()); + //run->SetInputFile(InputDigiFile.Data()); + FairFileSource* fFileSource = new FairFileSource(InputDigiFile.Data()); + run->SetSource(fFileSource); //run->AddFriend(InputFile.Data()); //run->SetOutputFile(OutputFile); run->SetUserOutputFileName(OutputFile.Data()); @@ -140,487 +164,21 @@ void ana_trks(Int_t nEvents = 10000, Int_t iSel = 1, Int_t iGenCor = 1, TString // ========================================================================= // === Tracking === // ========================================================================= + gROOT->LoadMacro("ini_trks.C"); + Char_t* cCmd = Form("ini_trks(%d,%d,%d,%6.2f,%8.1f,\"%s\",%d,%d,%d,%f)", iSel, iTrackingSetup, iGenCor, dScalFac, + dChi2Lim2, cCalId.Data(), (Int_t) bUseSigCalib, iCalOpt, iTrkPar, dTOffScal); + cout << "<I> " << cCmd << endl; + gInterpreter->ProcessLine(cCmd); - CbmTofTrackFinder* tofTrackFinder = new CbmTofTrackFinderNN(); - tofTrackFinder->SetMaxTofTimeDifference(0.2); // in ns/cm - Int_t TrackerPar = 0; - switch (TrackerPar) { - case 0: // for full mTof setup - tofTrackFinder->SetTxLIM(0.3); // max slope dx/dz - tofTrackFinder->SetTyLIM(0.3); // max dev from mean slope dy/dz - tofTrackFinder->SetTxMean(0.); // mean slope dy/dz - tofTrackFinder->SetTyMean(0.); // mean slope dy/dz - break; - case 1: // for double stack test counters - tofTrackFinder->SetTxMean(0.21); // mean slope dy/dz - tofTrackFinder->SetTyMean(0.18); // mean slope dy/dz - tofTrackFinder->SetTxLIM(0.15); // max slope dx/dz - tofTrackFinder->SetTyLIM(0.18); // max dev from mean slope dy/dz - break; - } - - CbmTofTrackFitter* tofTrackFitter = new CbmTofTrackFitterKF(0, 211); - TFitter* MyFit = new TFitter(1); // initialize Minuit - tofTrackFinder->SetFitter(tofTrackFitter); - CbmTofFindTracks* tofFindTracks = new CbmTofFindTracks("TOF Track Finder"); - tofFindTracks->UseFinder(tofTrackFinder); - tofFindTracks->UseFitter(tofTrackFitter); - tofFindTracks->SetCalOpt(iCalOpt); // 1 - update offsets, 2 - update walk, 0 - bypass - tofFindTracks->SetCorMode(iGenCor); // valid options: 0,1,2,3,4,5,6, 10 - 19 - //tofFindTracks->SetTtTarg(0.065); // target value for Mar2020 triple stack -> betapeak ~ 0.95 - //tofFindTracks->SetTtTarg(0.0605); // target value for Mar2020 triple stack -> betapeak ~ 0.95 - //tofFindTracks->SetTtTarg(0.058); // target value for Mar2020 double stack - //tofFindTracks->SetTtTarg(0.055); // target value Nov2019 (triple stack run 831) - //tofFindTracks->SetTtTarg(0.048); // target value Nov2019 (double stack run 714) - //tofFindTracks->SetTtTarg(0.047); // target value Mar2020, after T0 fix (full run 600) - tofFindTracks->SetTtTarg(0.042); // target value Mar2021, after T0 fix (double stack run 1058) - //tofFindTracks->SetTtTarg(0.038); // target value Mar2021, after T0 fix (double stack run 1051) - //tofFindTracks->SetTtTarg(0.035); // target value for inverse velocity, > 0.033 ns/cm! - tofFindTracks->SetCalParFileName(cTrkFile); // Tracker parameter value file name - tofFindTracks->SetBeamCounter(5, 0, 0); // default beam counter - tofFindTracks->SetR0Lim(20.); - tofFindTracks->SetStationMaxHMul(30); // Max Hit Multiplicity in any used station - - - tofFindTracks->SetT0MAX(dScalFac); // in ns - tofFindTracks->SetSIGT(0.08); // default in ns - tofFindTracks->SetSIGX(0.3); // default in cm - tofFindTracks->SetSIGY(0.45); // default in cm - tofFindTracks->SetSIGZ(0.05); // default in cm - tofFindTracks->SetUseSigCalib(bUseSigCalib); // ignore resolutions in CalPar file - tofTrackFinder->SetSIGLIM(dChi2Lim2 * 2.); // matching window in multiples of chi2 - tofTrackFinder->SetChiMaxAccept(dChi2Lim2); // max tracklet chi2 - - Int_t iMinNofHits = -1; - Int_t iNStations = 0; - Int_t iNReqStations = 3; - - switch (iTrackingSetup) { - case 0: // bypass mode - iMinNofHits = -1; - iNStations = 1; - tofFindTracks->SetStation(0, 5, 0, 0); // Diamond - break; - - case 1: // for calibration mode of full setup - { - Double_t dTsig = dScalFac * 0.03; - tofFindTracks->SetSIGT(dTsig); // allow for variable deviations in ns - } - iMinNofHits = 3; - iNStations = 32; - iNReqStations = 4; - tofFindTracks->SetStation(0, 5, 0, 0); - tofFindTracks->SetStation(1, 0, 2, 2); - tofFindTracks->SetStation(2, 0, 1, 2); - tofFindTracks->SetStation(3, 0, 0, 2); - tofFindTracks->SetStation(4, 0, 2, 1); - tofFindTracks->SetStation(5, 0, 1, 1); - tofFindTracks->SetStation(6, 0, 0, 1); - tofFindTracks->SetStation(7, 0, 2, 3); - tofFindTracks->SetStation(8, 0, 1, 3); - tofFindTracks->SetStation(9, 0, 0, 3); - tofFindTracks->SetStation(10, 0, 2, 0); - tofFindTracks->SetStation(11, 0, 1, 0); - tofFindTracks->SetStation(12, 0, 0, 0); - tofFindTracks->SetStation(13, 0, 2, 4); - tofFindTracks->SetStation(14, 0, 1, 4); - tofFindTracks->SetStation(15, 0, 0, 4); - tofFindTracks->SetStation(16, 0, 4, 0); - tofFindTracks->SetStation(17, 0, 3, 0); - tofFindTracks->SetStation(18, 0, 4, 1); - tofFindTracks->SetStation(19, 0, 3, 1); - tofFindTracks->SetStation(20, 0, 4, 2); - tofFindTracks->SetStation(21, 0, 3, 2); - tofFindTracks->SetStation(22, 0, 4, 3); - tofFindTracks->SetStation(23, 0, 3, 3); - tofFindTracks->SetStation(24, 0, 4, 4); - tofFindTracks->SetStation(25, 0, 3, 4); - tofFindTracks->SetStation(26, 9, 0, 0); - tofFindTracks->SetStation(27, 9, 1, 0); - tofFindTracks->SetStation(28, 9, 0, 1); - tofFindTracks->SetStation(29, 9, 1, 1); - tofFindTracks->SetStation(30, 6, 0, 0); - tofFindTracks->SetStation(31, 6, 0, 1); - break; - - case 11: // for calibration mode of 2-stack & test counters - iMinNofHits = 4; - iNStations = 9; - iNReqStations = 5; - tofFindTracks->SetStation(0, 0, 4, 1); - tofFindTracks->SetStation(1, 9, 0, 0); - tofFindTracks->SetStation(2, 9, 1, 0); - tofFindTracks->SetStation(3, 9, 0, 1); - tofFindTracks->SetStation(4, 9, 1, 1); - tofFindTracks->SetStation(5, 0, 3, 1); - tofFindTracks->SetStation(6, 0, 4, 0); - tofFindTracks->SetStation(7, 0, 3, 2); - tofFindTracks->SetStation(8, 5, 0, 0); - break; - - case 2: - iMinNofHits = 3; - iNStations = 28; - iNReqStations = 4; - tofFindTracks->SetStation(0, 0, 2, 2); - tofFindTracks->SetStation(1, 0, 0, 2); - tofFindTracks->SetStation(2, 0, 1, 2); - tofFindTracks->SetStation(3, 0, 2, 1); - tofFindTracks->SetStation(4, 0, 0, 1); - tofFindTracks->SetStation(5, 0, 1, 1); - tofFindTracks->SetStation(6, 0, 2, 3); - tofFindTracks->SetStation(7, 0, 0, 3); - tofFindTracks->SetStation(8, 0, 1, 3); - tofFindTracks->SetStation(9, 0, 2, 0); - tofFindTracks->SetStation(10, 0, 0, 0); - tofFindTracks->SetStation(11, 0, 1, 0); - tofFindTracks->SetStation(12, 0, 2, 4); - tofFindTracks->SetStation(13, 0, 0, 4); - tofFindTracks->SetStation(14, 0, 1, 4); - tofFindTracks->SetStation(15, 0, 4, 0); - tofFindTracks->SetStation(16, 0, 3, 0); - tofFindTracks->SetStation(17, 0, 4, 1); - tofFindTracks->SetStation(18, 0, 3, 1); - tofFindTracks->SetStation(19, 0, 4, 2); - tofFindTracks->SetStation(20, 0, 3, 2); - tofFindTracks->SetStation(21, 0, 4, 3); - tofFindTracks->SetStation(22, 0, 3, 3); - tofFindTracks->SetStation(23, 0, 4, 4); - tofFindTracks->SetStation(24, 0, 3, 4); - tofFindTracks->SetStation(25, 9, 0, 0); - tofFindTracks->SetStation(26, 9, 0, 1); - tofFindTracks->SetStation(27, 5, 0, 0); - break; - - case 3: - iMinNofHits = 3; - iNStations = 16; - iNReqStations = 4; - tofFindTracks->SetStation(0, 5, 0, 0); - tofFindTracks->SetStation(1, 0, 2, 2); - tofFindTracks->SetStation(2, 0, 1, 2); - tofFindTracks->SetStation(3, 0, 0, 2); - - tofFindTracks->SetStation(4, 0, 2, 1); - tofFindTracks->SetStation(5, 0, 1, 1); - tofFindTracks->SetStation(6, 0, 0, 1); - - tofFindTracks->SetStation(7, 0, 2, 3); - tofFindTracks->SetStation(8, 0, 1, 3); - tofFindTracks->SetStation(9, 0, 0, 3); - - tofFindTracks->SetStation(10, 0, 2, 0); - tofFindTracks->SetStation(11, 0, 1, 0); - tofFindTracks->SetStation(12, 0, 0, 0); - - tofFindTracks->SetStation(13, 0, 2, 4); - tofFindTracks->SetStation(14, 0, 1, 4); - tofFindTracks->SetStation(15, 0, 0, 4); - - /* - tofFindTracks->SetStation(16, 0, 3, 2); - tofFindTracks->SetStation(17, 0, 4, 2); - tofFindTracks->SetStation(18, 0, 3, 1); - tofFindTracks->SetStation(19, 0, 4, 1); - tofFindTracks->SetStation(20, 0, 3, 3); - tofFindTracks->SetStation(21, 0, 4, 3); - tofFindTracks->SetStation(22, 0, 3, 0); - tofFindTracks->SetStation(23, 0, 4, 0); - tofFindTracks->SetStation(24, 0, 3, 4); - tofFindTracks->SetStation(25, 0, 4, 4); - */ - break; - - case 4: // for USTC evaluation (dut=910,911) - iMinNofHits = 4; - iNStations = 6; - iNReqStations = 6; - tofFindTracks->SetStation(0, 0, 4, 1); - tofFindTracks->SetStation(1, 0, 3, 1); - tofFindTracks->SetStation(2, 9, 0, 1); - tofFindTracks->SetStation(3, 9, 0, 0); - tofFindTracks->SetStation(4, 5, 0, 0); - tofFindTracks->SetStation(5, iDut, iDutSm, iDutRpc); - break; - - case 14: - iMinNofHits = 3; - iNStations = 15; - iNReqStations = 4; - tofFindTracks->SetStation(0, 0, 2, 2); - tofFindTracks->SetStation(1, 0, 1, 2); - tofFindTracks->SetStation(2, 0, 0, 2); - tofFindTracks->SetStation(0, 0, 2, 1); - tofFindTracks->SetStation(1, 0, 1, 1); - tofFindTracks->SetStation(2, 0, 0, 1); - tofFindTracks->SetStation(0, 0, 2, 0); - tofFindTracks->SetStation(1, 0, 1, 0); - tofFindTracks->SetStation(2, 0, 0, 0); - tofFindTracks->SetStation(0, 0, 2, 3); - tofFindTracks->SetStation(1, 0, 1, 3); - tofFindTracks->SetStation(2, 0, 0, 3); - tofFindTracks->SetStation(0, 0, 2, 4); - tofFindTracks->SetStation(1, 0, 1, 4); - tofFindTracks->SetStation(2, 0, 0, 4); - break; - - case 5: // for calibration of 2-stack and add-on counters (STAR2, BUC) - iMinNofHits = 3; - iNStations = 7; - iNReqStations = 4; - tofFindTracks->SetStation(6, 0, 4, 1); - tofFindTracks->SetStation(1, 6, 0, 1); - tofFindTracks->SetStation(2, 9, 0, 0); - tofFindTracks->SetStation(3, 9, 0, 1); - tofFindTracks->SetStation(4, 6, 0, 0); - tofFindTracks->SetStation(5, 0, 3, 1); - tofFindTracks->SetStation(0, 5, 0, 0); - break; - - case 6: // for double stack USTC counter evaluation - iMinNofHits = 5; - iNStations = 6; - iNReqStations = 6; - tofFindTracks->SetStation(0, 5, 0, 0); - tofFindTracks->SetStation(1, 6, 0, 1); - tofFindTracks->SetStation(2, 0, 4, 1); - tofFindTracks->SetStation(3, 6, 0, 0); - tofFindTracks->SetStation(4, 0, 3, 1); - tofFindTracks->SetStation(5, iDut, iDutSm, iDutRpc); - break; - - case 7: // for double stack USTC counter evaluation - iMinNofHits = 3; - iNStations = 4; - iNReqStations = 4; - tofFindTracks->SetStation(0, 0, 4, 1); - tofFindTracks->SetStation(1, 6, 0, 1); - tofFindTracks->SetStation(2, 6, 0, 0); - tofFindTracks->SetStation(3, iDut, iDutSm, iDutRpc); - break; - - case 8: // evaluation of add-on counters (BUC) - iMinNofHits = 5; - iNStations = 6; - iNReqStations = 6; - tofFindTracks->SetStation(0, 5, 0, 0); - tofFindTracks->SetStation(1, 9, 0, 1); - tofFindTracks->SetStation(2, 0, 4, 1); - tofFindTracks->SetStation(3, 9, 0, 0); - tofFindTracks->SetStation(4, 0, 3, 1); - tofFindTracks->SetStation(5, iDut, iDutSm, iDutRpc); - break; - - case 9: // calibration of Star2 - iMinNofHits = 4; - iNStations = 5; - iNReqStations = 5; - tofFindTracks->SetStation(0, 5, 0, 0); - tofFindTracks->SetStation(2, 9, 0, 1); - tofFindTracks->SetStation(1, 0, 4, 1); - tofFindTracks->SetStation(3, 9, 0, 0); - tofFindTracks->SetStation(4, 0, 3, 1); - break; - - case 10: - iMinNofHits = 3; - iNStations = 4; - iNReqStations = 4; - tofFindTracks->SetStation(0, 5, 0, 0); - tofFindTracks->SetStation(3, 0, 1, 2); - tofFindTracks->SetStation(2, 0, 0, 2); - tofFindTracks->SetStation(1, 0, 2, 2); - break; - - default: - cout << "Tracking setup " << iTrackingSetup << " not implemented " << endl; - return; - ; - } - tofFindTracks->SetMinNofHits(iMinNofHits); - tofFindTracks->SetNStations(iNStations); - tofFindTracks->SetNReqStations(iNReqStations); - tofFindTracks->PrintSetup(); - run->AddTask(tofFindTracks); + CbmTofFindTracks* tofFindTracks = CbmTofFindTracks::Instance(); + Int_t iNStations = tofFindTracks->GetNStations(); // ========================================================================= // === Analysis === // ========================================================================= - CbmTofAnaTestbeam* tofAnaTestbeam = new CbmTofAnaTestbeam("TOF TestBeam Analysis", iVerbose); - tofAnaTestbeam->SetCorMode(iAnaCor); // 1 - DTD4, 2 - X4, 3 - Y4, 4 - Texp - tofAnaTestbeam->SetHitDistMin(30.); // initialization - tofAnaTestbeam->SetEnableMatchPosScaling(kTRUE); - tofAnaTestbeam->SetSpillDuration(3.); - if (iMc == 1) { - tofAnaTestbeam->SetSpillDuration(0.); - tofAnaTestbeam->SetSpillBreak(0.); - } - //CbmTofAnaTestbeam defaults - tofAnaTestbeam->SetR0LimFit(20.); // limit distance of fitted track to nominal vertex - tofAnaTestbeam->SetDXMean(0.); - tofAnaTestbeam->SetDYMean(0.); - tofAnaTestbeam->SetDTMean(0.); // in ns - tofAnaTestbeam->SetDXWidth(0.5); - tofAnaTestbeam->SetDYWidth(1.0); - tofAnaTestbeam->SetDTWidth(0.1); // in ns - tofAnaTestbeam->SetCalParFileName(cAnaFile); - Double_t dScalFacA = 0.9; // dScalFac is used for tracking - tofAnaTestbeam->SetPosY4Sel(0.5 * dScalFacA); // Y Position selection in fraction of strip length - tofAnaTestbeam->SetDTDia(0.); // Time difference to additional diamond - tofAnaTestbeam->SetMul0Max(20); // Max Multiplicity in dut - tofAnaTestbeam->SetMul4Max(30); // Max Multiplicity in Ref - RPC - tofAnaTestbeam->SetMulDMax(3); // Max Multiplicity in Diamond / BeamRef - tofAnaTestbeam->SetTOffD4(14.); // initialization - tofAnaTestbeam->SetDTD4MAX(6.); // initialization of Max time difference Ref - BRef - - //tofAnaTestbeam->SetTShift(-28000.);// initialization - tofAnaTestbeam->SetPosYS2Sel(0.55); // Y Position selection in fraction of strip length - tofAnaTestbeam->SetChS2Sel(0.); // Center of channel selection window - tofAnaTestbeam->SetDChS2Sel(100.); // Width of channel selection window - tofAnaTestbeam->SetSel2TOff(0.); // Shift Sel2 time peak to 0 - tofAnaTestbeam->SetChi2Lim(5.); // initialization of Chi2 selection limit - tofAnaTestbeam->SetChi2Lim2(3.); // initialization of Chi2 selection limit for Mref-Sel2 pair - tofAnaTestbeam->SetDutDX(15.); // limit inspection of tracklets to selected region - tofAnaTestbeam->SetDutDY(15.); // limit inspection of tracklets to selected region - tofAnaTestbeam->SetSIGLIM(3.); // max matching chi2 - tofAnaTestbeam->SetSIGT(0.08); // in ns - tofAnaTestbeam->SetSIGX(0.3); // in cm - tofAnaTestbeam->SetSIGY(0.6); // in cm - - Int_t iRSel = 500; - Int_t iRSelTyp = 5; - Int_t iRSelSm = 0; - Int_t iRSelRpc = 0; - /* - Int_t iRSel=31; - Int_t iRSelTyp=0; - Int_t iRSelSm=3; - Int_t iRSelRpc=1; - */ - - Int_t iRSelin = iRSel; - - - tofAnaTestbeam->SetBeamRefSmType(iRSelTyp); // common reaction reference - tofAnaTestbeam->SetBeamRefSmId(iRSelSm); - tofAnaTestbeam->SetBeamRefRpc(iRSelRpc); - - if (iSel2 >= -1) { - tofAnaTestbeam->SetMrpcSel2(iSel2); // initialization of second selector Mrpc Type - tofAnaTestbeam->SetMrpcSel2Sm(iSel2Sm); // initialization of second selector Mrpc SmId - tofAnaTestbeam->SetMrpcSel2Rpc(iSel2Rpc); // initialization of second selector Mrpc RpcId - } - - cout << "AnaTestbeam init for Dut " << iDut << iDutSm << iDutRpc << ", Ref " << iRef << iRefSm << iRefRpc << endl; - - tofAnaTestbeam->SetDut(iDut); // Device under test - tofAnaTestbeam->SetDutSm(iDutSm); // Device under test - tofAnaTestbeam->SetDutRpc(iDutRpc); // Device under test - tofAnaTestbeam->SetMrpcRef(iRef); // Reference RPC - tofAnaTestbeam->SetMrpcRefSm(iRefSm); // Reference RPC - tofAnaTestbeam->SetMrpcRefRpc(iRefRpc); // Reference RPC - - cout << "dispatch iSel = " << iSel << ", iSel2in = " << iSel2in << ", iRSelin = " << iRSelin << ", iRSel = " << iRSel - << endl; - - if (1) { - switch (iSel) { - - case 10: - switch (iRSelin) { - case 500: - tofAnaTestbeam->SetTShift(2.5); // Shift DTD4 to 0 - tofAnaTestbeam->SetTOffD4(18.); // Shift DTD4 to physical value - switch (iSel2in) { - case 20: - tofAnaTestbeam->SetSel2TOff(0.); // Shift Sel2 time peak to 0 - break; - default:; - } - break; - default:; - } - break; - - case 700040: - case 900040: - case 901040: - switch (iRSelin) { - case 500: - tofAnaTestbeam->SetTShift(0.3); // Shift DTD4 to 0 - tofAnaTestbeam->SetTOffD4(18.); // Shift DTD4 to physical value - - switch (iSel2in) { - case 30: - tofAnaTestbeam->SetSel2TOff(-0.3); // Shift Sel2 time peak to 0 - break; - case 31: - tofAnaTestbeam->SetSel2TOff(-0.41); // Shift Sel2 time peak to 0 - break; - - default:; - } - break; - default:; - } - break; - - case 700041: - case 900041: - case 901041: - switch (iRSelin) { - case 500: - tofAnaTestbeam->SetTShift(0.8); // Shift DTD4 to 0 - tofAnaTestbeam->SetTOffD4(11.); // Shift DTD4 to physical value - - switch (iSel2in) { - case 30: - tofAnaTestbeam->SetSel2TOff(-0.3); // Shift Sel2 time peak to 0 - break; - case 31: - tofAnaTestbeam->SetSel2TOff(0.); // Shift Sel2 time peak to 0 - break; - case 600: - tofAnaTestbeam->SetSel2TOff(-0.2); // Shift Sel2 time peak to 0 - break; - - default:; - } - break; - default:; - } - break; - - case 600041: - case 601041: - switch (iRSelin) { - case 500: - tofAnaTestbeam->SetTShift(5.3); // Shift DTD4 to 0 - tofAnaTestbeam->SetTOffD4(11.); // Shift DTD4 to physical value - - switch (iSel2in) { - case 33: - tofAnaTestbeam->SetSel2TOff(-0.55); // Shift Sel2 time peak to 0 - break; - - default:; - } - break; - default:; - } - break; - - default: - cout << "Better to define analysis setup! Running with default offset " - "parameter... " - << endl; - // return; - } // end of different subsets - - cout << " Initialize TSHIFT to " << tofAnaTestbeam->GetTShift() << endl; - //run->AddTask(tofAnaTestbeam); - } + gROOT->LoadMacro("ini_AnaTestbeam.C"); + cCmd = Form("ini_AnaTestbeam(%d,\"%s\",%d,%6.2f,%d,%d)", iSel, cFileId.Data(), iSel2, 0.9, iAnaCor, iMc); + //gInterpreter->ProcessLine(cCmd); // ----- Parameter database -------------------------------------------- FairRuntimeDb* rtdb = run->GetRuntimeDb(); @@ -644,7 +202,7 @@ void ana_trks(Int_t nEvents = 10000, Int_t iSel = 1, Int_t iGenCor = 1, TString // ----- Intialise and run -------------------------------------------- run->Init(); cout << "Starting run" << endl; - run->Run(0, nEvents); + run->Run(iFirstEvent, nEvents); //run->Run(nEvents-1, nEvents); //debugging single events for memory leak // ------------------------------------------------------------------------ @@ -678,10 +236,13 @@ void ana_trks(Int_t nEvents = 10000, Int_t iSel = 1, Int_t iGenCor = 1, TString gROOT->LoadMacro("pl_Eff_TIS.C"); gROOT->LoadMacro("pl_Dut_Res.C"); gROOT->LoadMacro("pl_Dut_Vel.C"); + gROOT->LoadMacro("pl_cal_doublets.C"); TString SaveToHstFile = "save_hst(\"" + cHstFile + "\")"; gInterpreter->ProcessLine(SaveToHstFile); + //return; + //gInterpreter->ProcessLine("pl_over_MatD4sel()"); //gInterpreter->ProcessLine("pl_TIS()"); //gInterpreter->ProcessLine("pl_TIR()"); @@ -708,4 +269,11 @@ void ana_trks(Int_t nEvents = 10000, Int_t iSel = 1, Int_t iGenCor = 1, TString gInterpreter->ProcessLine(Pull3); TString Pull4 = (TString)(Form("pl_pull_trk(%d,%d,1)", iNStations, 4)); gInterpreter->ProcessLine(Pull4); + + for (int i = 0; i < 0; i++) { + TString Cal1 = (TString)(Form("pl_cal_doublets(%d,%d,%d)", i, i + 5, i + 10)); + gInterpreter->ProcessLine(Cal1); + TString Cal2 = (TString)(Form("pl_cal_doublets(%d,%d,%d)", i, i + 5, i + 25)); + gInterpreter->ProcessLine(Cal2); + } } diff --git a/macro/beamtime/mcbm2021/ana_trks_eval.C b/macro/beamtime/mcbm2021/ana_trks_eval.C index b8e78e2089..00d3a017c1 100644 --- a/macro/beamtime/mcbm2021/ana_trks_eval.C +++ b/macro/beamtime/mcbm2021/ana_trks_eval.C @@ -1,11 +1,12 @@ /* Copyright (C) 2021 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt SPDX-License-Identifier: GPL-3.0-only - Authors: Florian Uhlig [committer] */ + Authors: Norbert Herrmann [committer] */ void ana_trks_eval(Int_t nEvents = 10000, Int_t iSel = 1, Int_t iGenCor = 1, TString cFileId = "48.50.7.1", TString cSet = "000010020", Int_t iSel2 = 20, Int_t iTrackingSetup = 2, Double_t dScalFac = 1., Double_t dChi2Lim2 = 500., Double_t dDeadtime = 50, TString cCalId = "", Int_t iAnaCor = 1, - Bool_t bUseSigCalib = kFALSE, Int_t iCalSet = 30040500, Int_t iCalOpt = 1, Int_t iMc = 0) + Bool_t bUseSigCalib = kFALSE, Int_t iCalSet = 30040500, Int_t iCalOpt = 1, Int_t iTrkPar = 0, + Int_t iMc = 0) { Int_t iVerbose = 1; if (cCalId == "") cCalId = cFileId; @@ -100,9 +101,11 @@ void ana_trks_eval(Int_t nEvents = 10000, Int_t iSel = 1, Int_t iGenCor = 1, TSt //run->SetInputFile(InputFile.Data()); //run->AddFriend(InputDigiFile.Data()); - run->SetInputFile(InputDigiFile.Data()); + //run->SetInputFile(InputDigiFile.Data()); //run->AddFriend(InputTrklFile.Data()); //run->SetInputFile(InputTrklFile.Data()); + FairFileSource* fFileSource = new FairFileSource(InputDigiFile.Data()); + run->SetSource(fFileSource); run->SetUserOutputFileName(OutputFile.Data()); run->SetSink(new FairRootFileSink(run->GetUserOutputFileName())); @@ -147,617 +150,114 @@ void ana_trks_eval(Int_t nEvents = 10000, Int_t iSel = 1, Int_t iGenCor = 1, TSt // ========================================================================= // === Tracking === // ========================================================================= + gROOT->LoadMacro("ini_trks.C"); + Char_t* cCmd = Form("ini_trks(%d,%d,%d,%6.2f,%8.1f,\"%s\",%d,%d,%d)", iSel, iTrackingSetup, iGenCor, dScalFac, + dChi2Lim2, cCalId.Data(), (Int_t) bUseSigCalib, iCalOpt, iTrkPar); + gInterpreter->ProcessLine(cCmd); - CbmTofTrackFinder* tofTrackFinder = new CbmTofTrackFinderNN(); - tofTrackFinder->SetMaxTofTimeDifference(0.2); // in ns/cm - Int_t TrackerPar = 0; - switch (TrackerPar) { - case 0: // for full mTof setup - tofTrackFinder->SetTxLIM(0.3); // max slope dx/dz - tofTrackFinder->SetTyLIM(0.3); // max dev from mean slope dy/dz - tofTrackFinder->SetTxMean(0.); // mean slope dy/dz - tofTrackFinder->SetTyMean(0.); // mean slope dy/dz - break; - case 1: // for double stack test counters - tofTrackFinder->SetTxMean(0.21); // mean slope dy/dz - tofTrackFinder->SetTyMean(0.18); // mean slope dy/dz - tofTrackFinder->SetTxLIM(0.15); // max slope dx/dz - tofTrackFinder->SetTyLIM(0.18); // max dev from mean slope dy/dz - break; - } + CbmTofFindTracks* tofFindTracks = CbmTofFindTracks::Instance(); + Int_t iNStations = tofFindTracks->GetNStations(); - CbmTofTrackFitter* tofTrackFitter = new CbmTofTrackFitterKF(0, 211); - TFitter* MyFit = new TFitter(1); // initialize Minuit - tofTrackFinder->SetFitter(tofTrackFitter); - CbmTofFindTracks* tofFindTracks = new CbmTofFindTracks("TOF Track Finder"); - tofFindTracks->UseFinder(tofTrackFinder); - tofFindTracks->UseFitter(tofTrackFitter); - tofFindTracks->SetCalOpt(iCalOpt); // 1 - update offsets, 2 - update walk, 0 - bypass - tofFindTracks->SetCorMode(iGenCor); // valid options: 0,1,2,3,4,5,6, 10 - 19 - tofFindTracks->SetTtTarg(0.047); // target value for Mar2021 double stack - // 0.0605); // target value for Mar2020 triple stack -> betapeak ~ 0.95 - //tofFindTracks->SetTtTarg(0.062); // target value for Mar2020 triple stack -> betapeak ~ 0.95 - //tofFindTracks->SetTtTarg(0.058); // target value for Mar2020 double stack - //tofFindTracks->SetTtTarg(0.051); // target value Nov2019 - //tofFindTracks->SetTtTarg(0.035); // target value for inverse velocity, > 0.033 ns/cm! - tofFindTracks->SetCalParFileName(cTrkFile); // Tracker parameter value file name - tofFindTracks->SetBeamCounter(5, 0, 0); // default beam counter - tofFindTracks->SetR0Lim(20.); - tofFindTracks->SetStationMaxHMul(30); // Max Hit Multiplicity in any used station - - tofFindTracks->SetT0MAX(dScalFac); // in ns - tofFindTracks->SetSIGT(0.08); // default in ns - tofFindTracks->SetSIGX(0.3); // default in cm - tofFindTracks->SetSIGY(0.45); // default in cm - tofFindTracks->SetSIGZ(0.05); // default in cm - tofFindTracks->SetUseSigCalib(bUseSigCalib); // ignore resolutions in CalPar file - tofTrackFinder->SetSIGLIM(dChi2Lim2 * 2.); // matching window in multiples of chi2 - tofTrackFinder->SetChiMaxAccept(dChi2Lim2); // max tracklet chi2 - tofTrackFinder->SetSIGLIMMOD(5.); // max deviation for last hit - - Int_t iMinNofHits = -1; - Int_t iNStations = 0; - Int_t iNReqStations = 3; - - switch (iTrackingSetup) { - case 0: // bypass mode - iMinNofHits = -1; - iNStations = 1; - tofFindTracks->SetStation(0, 5, 0, 0); // Diamond - break; - - case 1: // for calibration mode of full setup - { - Double_t dTsig = dScalFac * 0.03; - tofFindTracks->SetSIGT(dTsig); // allow for variable deviations in ns - } - iMinNofHits = 3; - iNStations = 30; - iNReqStations = 4; - tofFindTracks->SetStation(0, 5, 0, 0); - tofFindTracks->SetStation(1, 0, 2, 2); - tofFindTracks->SetStation(2, 0, 1, 2); - tofFindTracks->SetStation(3, 0, 0, 2); - tofFindTracks->SetStation(4, 0, 2, 1); - tofFindTracks->SetStation(5, 0, 1, 1); - tofFindTracks->SetStation(6, 0, 0, 1); - tofFindTracks->SetStation(7, 0, 2, 3); - tofFindTracks->SetStation(8, 0, 1, 3); - tofFindTracks->SetStation(9, 0, 0, 3); - tofFindTracks->SetStation(10, 0, 2, 0); - tofFindTracks->SetStation(11, 0, 1, 0); - tofFindTracks->SetStation(12, 0, 0, 0); - tofFindTracks->SetStation(13, 0, 2, 4); - tofFindTracks->SetStation(14, 0, 1, 4); - tofFindTracks->SetStation(15, 0, 0, 4); - tofFindTracks->SetStation(16, 0, 4, 0); - tofFindTracks->SetStation(17, 0, 3, 0); - tofFindTracks->SetStation(18, 0, 4, 1); - tofFindTracks->SetStation(19, 0, 3, 1); - tofFindTracks->SetStation(20, 0, 4, 2); - tofFindTracks->SetStation(21, 0, 3, 2); - tofFindTracks->SetStation(22, 0, 4, 3); - tofFindTracks->SetStation(23, 0, 3, 3); - tofFindTracks->SetStation(24, 0, 4, 4); - tofFindTracks->SetStation(25, 0, 3, 4); - tofFindTracks->SetStation(26, 9, 0, 0); - tofFindTracks->SetStation(27, 9, 1, 0); - tofFindTracks->SetStation(28, 9, 0, 1); - tofFindTracks->SetStation(29, 9, 1, 1); - //tofFindTracks->SetStation(28, 6, 0, 0); - //tofFindTracks->SetStation(29, 6, 0, 1); - break; - - case 11: // for calibration mode of 2-stack & test counters - iMinNofHits = 4; - iNStations = 9; - iNReqStations = 5; - tofFindTracks->SetStation(0, 5, 0, 0); - tofFindTracks->SetStation(1, 0, 4, 1); - tofFindTracks->SetStation(2, 0, 3, 1); - tofFindTracks->SetStation(3, 0, 4, 0); - tofFindTracks->SetStation(4, 0, 3, 2); - tofFindTracks->SetStation(5, 9, 0, 0); - tofFindTracks->SetStation(6, 9, 1, 0); - tofFindTracks->SetStation(7, 9, 0, 1); - tofFindTracks->SetStation(8, 9, 1, 1); - break; - - case 2: - iMinNofHits = 3; - iNStations = 28; - iNReqStations = 4; - tofFindTracks->SetStation(0, 0, 2, 2); - tofFindTracks->SetStation(1, 0, 0, 2); - tofFindTracks->SetStation(2, 0, 1, 2); - tofFindTracks->SetStation(3, 0, 2, 1); - tofFindTracks->SetStation(4, 0, 0, 1); - tofFindTracks->SetStation(5, 0, 1, 1); - tofFindTracks->SetStation(6, 0, 2, 3); - tofFindTracks->SetStation(7, 0, 0, 3); - tofFindTracks->SetStation(8, 0, 1, 3); - tofFindTracks->SetStation(9, 0, 2, 0); - tofFindTracks->SetStation(10, 0, 0, 0); - tofFindTracks->SetStation(11, 0, 1, 0); - tofFindTracks->SetStation(12, 0, 2, 4); - tofFindTracks->SetStation(13, 0, 0, 4); - tofFindTracks->SetStation(14, 0, 1, 4); - tofFindTracks->SetStation(15, 0, 4, 0); - tofFindTracks->SetStation(16, 0, 3, 0); - tofFindTracks->SetStation(17, 0, 4, 1); - tofFindTracks->SetStation(18, 0, 3, 1); - tofFindTracks->SetStation(19, 0, 4, 2); - tofFindTracks->SetStation(20, 0, 3, 2); - tofFindTracks->SetStation(21, 0, 4, 3); - tofFindTracks->SetStation(22, 0, 3, 3); - tofFindTracks->SetStation(23, 0, 4, 4); - tofFindTracks->SetStation(24, 0, 3, 4); - tofFindTracks->SetStation(25, 9, 0, 0); - tofFindTracks->SetStation(26, 9, 0, 1); - tofFindTracks->SetStation(27, 5, 0, 0); - break; - - case 3: - iMinNofHits = 3; - iNStations = 16; - iNReqStations = 4; - tofFindTracks->SetStation(0, 5, 0, 0); - tofFindTracks->SetStation(1, 0, 2, 2); - tofFindTracks->SetStation(2, 0, 1, 2); - tofFindTracks->SetStation(3, 0, 0, 2); - - tofFindTracks->SetStation(4, 0, 2, 1); - tofFindTracks->SetStation(5, 0, 1, 1); - tofFindTracks->SetStation(6, 0, 0, 1); - - tofFindTracks->SetStation(7, 0, 2, 3); - tofFindTracks->SetStation(8, 0, 1, 3); - tofFindTracks->SetStation(9, 0, 0, 3); - - tofFindTracks->SetStation(10, 0, 2, 0); - tofFindTracks->SetStation(11, 0, 1, 0); - tofFindTracks->SetStation(12, 0, 0, 0); - - tofFindTracks->SetStation(13, 0, 2, 4); - tofFindTracks->SetStation(14, 0, 1, 4); - tofFindTracks->SetStation(15, 0, 0, 4); - - /* - tofFindTracks->SetStation(16, 0, 3, 2); - tofFindTracks->SetStation(17, 0, 4, 2); - tofFindTracks->SetStation(18, 0, 3, 1); - tofFindTracks->SetStation(19, 0, 4, 1); - tofFindTracks->SetStation(20, 0, 3, 3); - tofFindTracks->SetStation(21, 0, 4, 3); - tofFindTracks->SetStation(22, 0, 3, 0); - tofFindTracks->SetStation(23, 0, 4, 0); - tofFindTracks->SetStation(24, 0, 3, 4); - tofFindTracks->SetStation(25, 0, 4, 4); - */ - break; - - case 4: // for USTC evaluation (dut=910,911) - iMinNofHits = 4; - iNStations = 6; - iNReqStations = 6; - tofFindTracks->SetStation(0, 0, 4, 1); - tofFindTracks->SetStation(1, 0, 3, 1); - tofFindTracks->SetStation(2, 9, 0, 1); - tofFindTracks->SetStation(3, 9, 0, 0); - tofFindTracks->SetStation(4, 5, 0, 0); - tofFindTracks->SetStation(5, iDut, iDutSm, iDutRpc); - break; - - case 14: - iMinNofHits = 3; - iNStations = 15; - iNReqStations = 4; - tofFindTracks->SetStation(0, 0, 2, 2); - tofFindTracks->SetStation(1, 0, 1, 2); - tofFindTracks->SetStation(2, 0, 0, 2); - tofFindTracks->SetStation(0, 0, 2, 1); - tofFindTracks->SetStation(1, 0, 1, 1); - tofFindTracks->SetStation(2, 0, 0, 1); - tofFindTracks->SetStation(0, 0, 2, 0); - tofFindTracks->SetStation(1, 0, 1, 0); - tofFindTracks->SetStation(2, 0, 0, 0); - tofFindTracks->SetStation(0, 0, 2, 3); - tofFindTracks->SetStation(1, 0, 1, 3); - tofFindTracks->SetStation(2, 0, 0, 3); - tofFindTracks->SetStation(0, 0, 2, 4); - tofFindTracks->SetStation(1, 0, 1, 4); - tofFindTracks->SetStation(2, 0, 0, 4); - break; - - case 5: // for calibration of 2-stack and add-on counters (STAR2, BUC) - iMinNofHits = 3; - iNStations = 7; - iNReqStations = 4; - tofFindTracks->SetStation(6, 0, 4, 1); - tofFindTracks->SetStation(1, 6, 0, 1); - tofFindTracks->SetStation(2, 9, 0, 0); - tofFindTracks->SetStation(3, 9, 0, 1); - tofFindTracks->SetStation(4, 6, 0, 0); - tofFindTracks->SetStation(5, 0, 3, 1); - tofFindTracks->SetStation(0, 5, 0, 0); - break; - - case 6: // for double stack TSHU counter (900,901) evaluation - iMinNofHits = 5; - iNStations = 6; - iNReqStations = 6; - tofFindTracks->SetStation(0, 0, 4, 1); - tofFindTracks->SetStation(1, 0, 3, 1); - tofFindTracks->SetStation(2, 9, 1, 1); - tofFindTracks->SetStation(3, 9, 1, 0); - tofFindTracks->SetStation(4, 5, 0, 0); - tofFindTracks->SetStation(5, iDut, iDutSm, iDutRpc); - break; - - case 7: // for double stack USTC counter evaluation - iMinNofHits = 3; - iNStations = 4; - iNReqStations = 4; - tofFindTracks->SetStation(0, 0, 4, 1); - tofFindTracks->SetStation(1, 6, 0, 1); - tofFindTracks->SetStation(2, 6, 0, 0); - tofFindTracks->SetStation(3, iDut, iDutSm, iDutRpc); - break; - - case 8: // evaluation of add-on counters (BUC) - iMinNofHits = 5; - iNStations = 6; - iNReqStations = 6; - tofFindTracks->SetStation(0, 5, 0, 0); - tofFindTracks->SetStation(1, 9, 0, 1); - tofFindTracks->SetStation(2, 0, 4, 1); - tofFindTracks->SetStation(3, 9, 0, 0); - tofFindTracks->SetStation(4, 0, 3, 1); - tofFindTracks->SetStation(5, iDut, iDutSm, iDutRpc); - break; - - case 9: // calibration of Star2 - iMinNofHits = 4; - iNStations = 5; - iNReqStations = 5; - tofFindTracks->SetStation(0, 5, 0, 0); - tofFindTracks->SetStation(2, 9, 0, 1); - tofFindTracks->SetStation(1, 0, 4, 1); - tofFindTracks->SetStation(3, 9, 0, 0); - tofFindTracks->SetStation(4, 0, 3, 1); - break; - - case 10: - iMinNofHits = 3; - iNStations = 4; - iNReqStations = 4; - tofFindTracks->SetStation(0, 5, 0, 0); - tofFindTracks->SetStation(3, 0, 1, 2); - tofFindTracks->SetStation(2, 0, 0, 2); - tofFindTracks->SetStation(1, 0, 2, 2); - break; - - default: - cout << "Tracking setup " << iTrackingSetup << " not implemented " << endl; - return; - ; - } - tofFindTracks->SetMinNofHits(iMinNofHits); - tofFindTracks->SetNStations(iNStations); - tofFindTracks->SetNReqStations(iNReqStations); - tofFindTracks->PrintSetup(); - run->AddTask(tofFindTracks); // ========================================================================= // === Analysis === // ========================================================================= - CbmTofAnaTestbeam* tofAnaTestbeam = new CbmTofAnaTestbeam("TOF TestBeam Analysis", iVerbose); - tofAnaTestbeam->SetCorMode(iAnaCor); // 1 - DTD4, 2 - X4, 3 - Y4, 4 - Texp - tofAnaTestbeam->SetHitDistMin(30.); // initialization - tofAnaTestbeam->SetEnableMatchPosScaling(kTRUE); - tofAnaTestbeam->SetSpillDuration(3.); - if (iMc == 1) { - tofAnaTestbeam->SetSpillDuration(0.); - tofAnaTestbeam->SetSpillBreak(0.); - } - //CbmTofAnaTestbeam defaults - tofAnaTestbeam->SetR0LimFit(20.); // limit distance of fitted track to nominal vertex - tofAnaTestbeam->SetStartSpillTime(0.); - - tofAnaTestbeam->SetDXMean(0.); - tofAnaTestbeam->SetDYMean(0.); - tofAnaTestbeam->SetDTMean(0.); // in ns - tofAnaTestbeam->SetDXWidth(0.5); - tofAnaTestbeam->SetDYWidth(0.8); - tofAnaTestbeam->SetDTWidth(0.08); // in ns - tofAnaTestbeam->SetCalParFileName(cAnaFile); - Double_t dScalFacA = 0.9; // dScalFac is used for tracking - tofAnaTestbeam->SetPosY4Sel(0.5 * dScalFacA); // Y Position selection in fraction of strip length - tofAnaTestbeam->SetDTDia(0.); // Time difference to additional diamond - tofAnaTestbeam->SetMul0Max(20); // Max Multiplicity in dut - tofAnaTestbeam->SetMul4Max(30); // Max Multiplicity in Ref - RPC - tofAnaTestbeam->SetMulDMax(3); // Max Multiplicity in Diamond / BeamRef - tofAnaTestbeam->SetTOffD4(14.); // initialization - tofAnaTestbeam->SetDTD4MAX(6.); // initialization of Max time difference Ref - BRef - - //tofAnaTestbeam->SetTShift(-28000.);// initialization - tofAnaTestbeam->SetPosYS2Sel(0.55); // Y Position selection in fraction of strip length - tofAnaTestbeam->SetChS2Sel(0.); // Center of channel selection window - tofAnaTestbeam->SetDChS2Sel(100.); // Width of channel selection window - tofAnaTestbeam->SetSel2TOff(0.); // Shift Sel2 time peak to 0 - tofAnaTestbeam->SetChi2Lim(5.); // initialization of Chi2 selection limit - tofAnaTestbeam->SetChi2Lim2(3.); // initialization of Chi2 selection limit for Mref-Sel2 pair - tofAnaTestbeam->SetDutDX(15.); // limit inspection of tracklets to selected region - tofAnaTestbeam->SetDutDY(15.); // limit inspection of tracklets to selected region - tofAnaTestbeam->SetSIGLIM(3.); // max matching chi2 - tofAnaTestbeam->SetSIGT(0.08); // in ns - tofAnaTestbeam->SetSIGX(0.3); // in cm - tofAnaTestbeam->SetSIGY(0.6); // in cm - - Int_t iRSel = 500; - Int_t iRSelTyp = 5; - Int_t iRSelSm = 0; - Int_t iRSelRpc = 0; - /* - Int_t iRSel=31; - Int_t iRSelTyp=0; - Int_t iRSelSm=3; - Int_t iRSelRpc=1; - */ - - Int_t iRSelin = iRSel; - - - tofAnaTestbeam->SetBeamRefSmType(iRSelTyp); // common reaction reference - tofAnaTestbeam->SetBeamRefSmId(iRSelSm); - tofAnaTestbeam->SetBeamRefRpc(iRSelRpc); - - if (iSel2 >= -1) { - tofAnaTestbeam->SetMrpcSel2(iSel2); // initialization of second selector Mrpc Type - tofAnaTestbeam->SetMrpcSel2Sm(iSel2Sm); // initialization of second selector Mrpc SmId - tofAnaTestbeam->SetMrpcSel2Rpc(iSel2Rpc); // initialization of second selector Mrpc RpcId - } - - cout << "AnaTestbeam init for Dut " << iDut << iDutSm << iDutRpc << ", Ref " << iRef << iRefSm << iRefRpc << endl; - - tofAnaTestbeam->SetDut(iDut); // Device under test - tofAnaTestbeam->SetDutSm(iDutSm); // Device under test - tofAnaTestbeam->SetDutRpc(iDutRpc); // Device under test - tofAnaTestbeam->SetMrpcRef(iRef); // Reference RPC - tofAnaTestbeam->SetMrpcRefSm(iRefSm); // Reference RPC - tofAnaTestbeam->SetMrpcRefRpc(iRefRpc); // Reference RPC - - cout << "dispatch iSel = " << iSel << ", iSel2in = " << iSel2in << ", iRSelin = " << iRSelin << ", iRSel = " << iRSel - << endl; - - if (1) { - switch (iSel) { - - case 10: - switch (iRSelin) { - case 500: - tofAnaTestbeam->SetTShift(2.5); // Shift DTD4 to 0 - tofAnaTestbeam->SetTOffD4(18.); // Shift DTD4 to physical value - switch (iSel2in) { - case 20: - tofAnaTestbeam->SetSel2TOff(0.); // Shift Sel2 time peak to 0 - break; - default:; - } - break; - default:; - } - break; - - case 700040: - case 900040: - case 901040: - switch (iRSelin) { - case 500: - tofAnaTestbeam->SetTShift(0.3); // Shift DTD4 to 0 - tofAnaTestbeam->SetTOffD4(18.); // Shift DTD4 to physical value - - switch (iSel2in) { - case 30: - tofAnaTestbeam->SetSel2TOff(-0.3); // Shift Sel2 time peak to 0 - break; - case 31: - tofAnaTestbeam->SetSel2TOff(-0.41); // Shift Sel2 time peak to 0 - break; - - default:; - } - break; - default:; - } - break; - - case 700041: - case 900041: - case 901041: - case 910041: - case 911041: - switch (iRSelin) { - case 500: - if (iMc == 0) { // data - tofAnaTestbeam->SetTShift(2.); // Shift DTD4 to 0 - tofAnaTestbeam->SetTOffD4(15.); // Shift DTD4 to physical value - } - else { // MC - tofAnaTestbeam->SetTShift(-2.); // Shift DTD4 to 0 - tofAnaTestbeam->SetTOffD4(15.); // Shift DTD4 to physical value - } - switch (iSel2in) { - case 30: - tofAnaTestbeam->SetSel2TOff(-0.3); // Shift Sel2 time peak to 0 - break; - case 31: - if (iMc == 0) { - switch (iRun) { - case 727: - case 726: - case 723: - case 721: - tofAnaTestbeam->SetTShift(6.5); // Shift DTD4 to 0 - tofAnaTestbeam->SetSel2TOff(0.6); // Shift Sel2 time peak to 0 - break; - case 1051: - case 1058: - tofAnaTestbeam->SetTShift(-3.); // Shift DTD4 to 0 - tofAnaTestbeam->SetSel2TOff(0.); // Shift Sel2 time peak to 0 - break; - case 717: - default: // 714 - //tofAnaTestbeam->SetSel2TOff(-1.3); // Shift Sel2 time peak to 0 - tofAnaTestbeam->SetSel2TOff(-0.5); // Shift Sel2 time peak to 0 - } - } - else { // MC - tofAnaTestbeam->SetSel2TOff(-1.3); // Shift Sel2 time peak to 0 - } - break; - case 600: - tofAnaTestbeam->SetSel2TOff(-0.2); // Shift Sel2 time peak to 0 - break; - - default:; - } - break; - default:; - } - break; - - case 600041: - case 601041: - switch (iRSelin) { - case 500: - tofAnaTestbeam->SetTShift(5.3); // Shift DTD4 to 0 - tofAnaTestbeam->SetTOffD4(11.); // Shift DTD4 to physical value - - switch (iSel2in) { - case 33: - tofAnaTestbeam->SetSel2TOff(-0.55); // Shift Sel2 time peak to 0 - break; - - default:; - } - break; - default:; - } - break; - - case 12022: - switch (iRSelin) { - case 500: - tofAnaTestbeam->SetTShift(3.); // Shift DTD4 to 0 - tofAnaTestbeam->SetTOffD4(15.); // Shift DTD4 to physical value - - switch (iSel2in) { - case 2: - tofAnaTestbeam->SetSel2TOff(0.25); // Shift Sel2 time peak to 0 - break; - - default:; - } - break; - default:; - } - break; - - default: - cout << "Better to define analysis setup! Running with default offset " - "parameter... " - << endl; - // return; - } // end of different subsets - - cout << " Initialize TSHIFT to " << tofAnaTestbeam->GetTShift() << endl; - run->AddTask(tofAnaTestbeam); - } - - // ----- Parameter database -------------------------------------------- - FairRuntimeDb* rtdb = run->GetRuntimeDb(); - Bool_t kParameterMerged = kTRUE; - FairParRootFileIo* parIo2 = new FairParRootFileIo(kParameterMerged); - parIo2->open(ParFile.Data(), "UPDATE"); - parIo2->print(); - rtdb->setFirstInput(parIo2); - - FairParAsciiFileIo* parIo1 = new FairParAsciiFileIo(); - parIo1->open(parFileList, "in"); - parIo1->print(); - rtdb->setSecondInput(parIo1); - rtdb->print(); - rtdb->printParamContexts(); - - // FairParRootFileIo* parInput1 = new FairParRootFileIo(); - // parInput1->open(ParFile.Data()); - // rtdb->setFirstInput(parInput1); - - // ----- Intialise and run -------------------------------------------- - run->Init(); - cout << "Starting run" << endl; - run->Run(0, nEvents); - //run->Run(nEvents-1, nEvents); //debugging single events for memory leak - // ------------------------------------------------------------------------ - TString SaveToHstFile = "save_hst(\"" + cHstFile + "\")"; - gROOT->LoadMacro("save_hst.C"); - gInterpreter->ProcessLine(SaveToHstFile); - - // default displays, plot results - - TString Display_Status = "pl_over_Mat04D4best.C"; - TString Display_Funct; - if (iGenCor < 0) { Display_Funct = "pl_over_Mat04D4best(1)"; } - else { - Display_Funct = "pl_over_Mat04D4best(0)"; - } - gROOT->LoadMacro(Display_Status); - - cout << "Exec " << Display_Funct.Data() << endl; - gInterpreter->ProcessLine(Display_Funct); - - gROOT->LoadMacro("pl_over_MatD4sel.C"); - gROOT->LoadMacro("pl_eff_XY.C"); - gROOT->LoadMacro("pl_over_trk.C"); - gROOT->LoadMacro("pl_calib_trk.C"); - gROOT->LoadMacro("pl_XY_trk.C"); - gROOT->LoadMacro("pl_vert_trk.C"); - gROOT->LoadMacro("pl_pull_trk.C"); - gROOT->LoadMacro("pl_all_Track2D.C"); - gROOT->LoadMacro("pl_TIS.C"); - gROOT->LoadMacro("pl_TIR.C"); - gROOT->LoadMacro("pl_Eff_XY.C"); - gROOT->LoadMacro("pl_Eff_DTLH.C"); - gROOT->LoadMacro("pl_Eff_TIS.C"); - gROOT->LoadMacro("pl_Dut_Res.C"); - gROOT->LoadMacro("pl_Dut_Vel.C"); - - cout << "Plotting for Dut " << iDut << iDutSm << iDutRpc << ", Ref " << iRef << iRefSm << iRefRpc << endl; - - gInterpreter->ProcessLine("pl_over_MatD4sel()"); - gInterpreter->ProcessLine("pl_TIS()"); - gInterpreter->ProcessLine("pl_TIR()"); - gInterpreter->ProcessLine(Form("pl_Dut_Vel(\"%d%d%d\")", iDut, iDutSm, iDutRpc)); - gInterpreter->ProcessLine("pl_eff_XY()"); - gInterpreter->ProcessLine("pl_calib_trk()"); - gInterpreter->ProcessLine("pl_vert_trk()"); - - gInterpreter->ProcessLine("pl_all_Track2D(1)"); - gInterpreter->ProcessLine("pl_all_Track2D(2)"); - gInterpreter->ProcessLine("pl_all_Track2D(4)"); - - TString over_trk = "pl_over_trk(" + (TString)(Form("%d", iNStations)) + ")"; - gInterpreter->ProcessLine(over_trk); - - TString XY_trk = "pl_XY_trk(" + (TString)(Form("%d", iNStations)) + ")"; - gInterpreter->ProcessLine(XY_trk); - - TString Pull0 = (TString)(Form("pl_pull_trk(%d,%d,1)", iNStations, 0)); - gInterpreter->ProcessLine(Pull0); - TString Pull1 = (TString)(Form("pl_pull_trk(%d,%d,1)", iNStations, 1)); - gInterpreter->ProcessLine(Pull1); - TString Pull3 = (TString)(Form("pl_pull_trk(%d,%d,1)", iNStations, 3)); - gInterpreter->ProcessLine(Pull3); - TString Pull4 = (TString)(Form("pl_pull_trk(%d,%d,1)", iNStations, 4)); - gInterpreter->ProcessLine(Pull4); + gROOT->LoadMacro("ini_AnaTestbeam.C"); + case 1051: + case 1058: + tofAnaTestbeam->SetTShift(-3.); // Shift DTD4 to 0 + tofAnaTestbeam->SetSel2TOff(0.); // Shift Sel2 time peak to 0 + break; + + Int_t iRSel = iCalSet % 1000; + cCmd = + Form("ini_AnaTestbeam(%d,\"%s\",%d,%d,%5.2f,%d,%d)", iSel, cFileId.Data(), iSel2in, iRSel, 0.9, iAnaCor, iMc); + LOG(info) << cCmd; + gInterpreter->ProcessLine(cCmd); + + // ----- Parameter database -------------------------------------------- + FairRuntimeDb* rtdb = run->GetRuntimeDb(); + Bool_t kParameterMerged = kTRUE; + FairParRootFileIo* parIo2 = new FairParRootFileIo(kParameterMerged); + parIo2->open(ParFile.Data(), "UPDATE"); + parIo2->print(); + rtdb->setFirstInput(parIo2); + + FairParAsciiFileIo* parIo1 = new FairParAsciiFileIo(); + parIo1->open(parFileList, "in"); + parIo1->print(); + rtdb->setSecondInput(parIo1); + rtdb->print(); + rtdb->printParamContexts(); + + // FairParRootFileIo* parInput1 = new FairParRootFileIo(); + // parInput1->open(ParFile.Data()); + // rtdb->setFirstInput(parInput1); + + // ----- Intialise and run -------------------------------------------- + run->Init(); + cout << "Starting run" << endl; + run->Run(0, nEvents); + //run->Run(nEvents-1, nEvents); //debugging single events for memory leak + // ------------------------------------------------------------------------ + TString SaveToHstFile = "save_hst(\"" + cHstFile + "\")"; + gROOT->LoadMacro("save_hst.C"); + gInterpreter->ProcessLine(SaveToHstFile); + + // default displays, plot results + + TString Display_Status = "pl_over_Mat04D4best.C"; + TString Display_Funct; + if (iGenCor < 0) { Display_Funct = "pl_over_Mat04D4best(1)"; } + else { + Display_Funct = "pl_over_Mat04D4best(0)"; + } + gROOT->LoadMacro(Display_Status); + + cout << "Exec " << Display_Funct.Data() << endl; + gInterpreter->ProcessLine(Display_Funct); + + gROOT->LoadMacro("pl_over_MatD4sel.C"); + gROOT->LoadMacro("pl_eff_XY.C"); + gROOT->LoadMacro("pl_over_trk.C"); + gROOT->LoadMacro("pl_calib_trk.C"); + gROOT->LoadMacro("pl_XY_trk.C"); + gROOT->LoadMacro("pl_vert_trk.C"); + gROOT->LoadMacro("pl_pull_trk.C"); + gROOT->LoadMacro("pl_all_Track2D.C"); + gROOT->LoadMacro("pl_TIS.C"); + gROOT->LoadMacro("pl_TIR.C"); + gROOT->LoadMacro("pl_Eff_XY.C"); + gROOT->LoadMacro("pl_Eff_DTLH.C"); + gROOT->LoadMacro("pl_Eff_TIS.C"); + gROOT->LoadMacro("pl_Dut_Res.C"); + gROOT->LoadMacro("pl_Dut_Vel.C"); + + cout << "Plotting for Dut " << iDut << iDutSm << iDutRpc << ", Ref " << iRef << iRefSm << iRefRpc << endl; + + gInterpreter->ProcessLine("pl_over_MatD4sel()"); + gInterpreter->ProcessLine("pl_TIS()"); + gInterpreter->ProcessLine("pl_TIR()"); + gInterpreter->ProcessLine(Form("pl_Dut_Vel(\"%d%d%d\")", iDut, iDutSm, iDutRpc)); + gInterpreter->ProcessLine("pl_eff_XY()"); + gInterpreter->ProcessLine("pl_calib_trk()"); + gInterpreter->ProcessLine("pl_vert_trk()"); + + gInterpreter->ProcessLine("pl_all_Track2D(1)"); + gInterpreter->ProcessLine("pl_all_Track2D(2)"); + gInterpreter->ProcessLine("pl_all_Track2D(4)"); + + TString over_trk = "pl_over_trk(" + (TString)(Form("%d", iNStations)) + ")"; + gInterpreter->ProcessLine(over_trk); + + TString XY_trk = "pl_XY_trk(" + (TString)(Form("%d", iNStations)) + ")"; + gInterpreter->ProcessLine(XY_trk); + + TString Pull0 = (TString)(Form("pl_pull_trk(%d,%d,1)", iNStations, 0)); + gInterpreter->ProcessLine(Pull0); + TString Pull1 = (TString)(Form("pl_pull_trk(%d,%d,1)", iNStations, 1)); + gInterpreter->ProcessLine(Pull1); + TString Pull3 = (TString)(Form("pl_pull_trk(%d,%d,1)", iNStations, 3)); + gInterpreter->ProcessLine(Pull3); + TString Pull4 = (TString)(Form("pl_pull_trk(%d,%d,1)", iNStations, 4)); + gInterpreter->ProcessLine(Pull4); } diff --git a/macro/beamtime/mcbm2021/calib_batch.sh b/macro/beamtime/mcbm2021/calib_batch.sh index 27bf77c46a..2608407fdd 100755 --- a/macro/beamtime/mcbm2021/calib_batch.sh +++ b/macro/beamtime/mcbm2021/calib_batch.sh @@ -64,8 +64,8 @@ Deadtime=50 echo define root execution environment at I=$I for Run $RunId Mode $RunIdMode -if [ -e /lustre/nyx ]; then -source /lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/build6/config.sh +if [ -e /lustre ]; then +source /lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/build/config.sh wdir=/lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2021 outdir=/lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2021/${RunId} else @@ -75,8 +75,8 @@ fi mkdir ${outdir} cd ${wdir} -echo execute: ./init_cal_all.sh ${RunIdMode} ${CalSet} ${Deadtime} -source ./init_cal_all.sh ${RunIdMode} ${CalSet} ${Deadtime} +echo execute: ./init_cal_all.sh ${RunIdMode} ${CalSet} ${Sel2} +source ./init_cal_all.sh ${RunIdMode} ${CalSet} ${Sel2} #echo execute: ./init_calib_star.sh ${RunIdMode} ${CalSet} ${Deadtime} #source ./init_calib_star.sh ${RunIdMode} ${CalSet} ${Deadtime} @@ -85,7 +85,8 @@ cd ${wdir} #source ./iter_calib.sh ${RunIdMode} ${CalSet} ${Sel2} ${Deadtime} cd ${wdir} -echo execute: ./gen_hits.sh ${RunIdMode} ${CalSet} ${Sel2} ${Deadtime} -source ./gen_hits.sh ${RunIdMode} ${CalSet} ${Sel2} ${Deadtime} +Nevt=20000000 +echo execute: ./gen_hits.sh ${RunIdMode} ${CalSet} ${Sel2} ${Deadtime} $Nevt +source ./gen_hits.sh ${RunIdMode} ${CalSet} ${Sel2} ${Deadtime} $Nevt mv -v slurm-${SLURM_ARRAY_JOB_ID}_${SLURM_ARRAY_TASK_ID}.out ${outdir}/Calib_${RunIdMode}_${CalSet}_${Sel2}.out diff --git a/macro/beamtime/mcbm2021/check_timing_any.C b/macro/beamtime/mcbm2021/check_timing_any.C index 8bf151df0f..a4a2ac9f3b 100644 --- a/macro/beamtime/mcbm2021/check_timing_any.C +++ b/macro/beamtime/mcbm2021/check_timing_any.C @@ -71,7 +71,7 @@ void check_timing_any(TString fileName, UInt_t uRunId = 0, Int_t nEvents = 0, TS timeChecker->AddCheckDetector(ECbmModuleId::kTrd, "Trd"); timeChecker->RemoveCheckDetector(ECbmModuleId::kTof); //timeChecker->AddCheckDetector(ECbmModuleId::kTof, "Tof", -150000, 150000, 320*150); - timeChecker->AddCheckDetector(ECbmModuleId::kTof, "Tof", -2000, 2000, 320 * 2); + timeChecker->AddCheckDetector(ECbmModuleId::kTof, "Tof", -2000, 2000, 320*2); */ /// Add detectors not in default list diff --git a/macro/beamtime/mcbm2021/clu_cal_all.sh b/macro/beamtime/mcbm2021/clu_cal_all.sh new file mode 100755 index 0000000000..c9ab361178 --- /dev/null +++ b/macro/beamtime/mcbm2021/clu_cal_all.sh @@ -0,0 +1,215 @@ +#!/bin/bash +# Copyright (C) 2021 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt +# SPDX-License-Identifier: GPL-3.0-only +# First commited by Florian Uhlig + +# shell script to initialize clusterizer calibrations +#SBATCH -J calall +#SBATCH -D /lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2021 +##SBATCH -D $VMCWORKDIR/macro/beamtime/mcbm2021 +#SBATCH --time=8:00:00 +##SBATCH --time=6-00:00:00 +#SBATCH --mem=2000 +##SBATCH --partition=long + +cRun=$1 +iCalSet=$2 +iRestart=$3 +iUseLast=$4 +iSel2=$5 + +if [[ $iRestart = "" ]]; then + iRestart=19 +fi + +if [[ $iUseLast = "" ]]; then + iUseLast=1 +fi + +if [[ $iSel2 = "" ]]; then + iSel2=-1 +fi + +echo 'Initialize clu calibration for run '$cRun', CalSet '$iCalSet', start from '$iRestart', UseLast '$iUseLast', Sel2 '$iSel2 + +((iTmp = $iCalSet )) +((iBRef = $iTmp % 1000)) +((iTmp = $iTmp - $iBRef)) +((iSet = $iTmp / 1000)) +((iMRef = $iTmp % 1000000)) +((iMRef = $iMRef / 1000)) +((iTmp = $iTmp - $iMRef)) +((iDut = $iTmp / 1000000)) +echo Calib setup is ${iCalSet}, iSet=$iSet, iDut=$iDut, iMRef=$iMRef, iBRef=$iBRef +cCalSet=$iCalSet +if (( iCalSet<100000000 )); then +cCalSet="0"$iCalSet +fi +if (( iCalSet<10000000 )); then +cCalSet="00"$iCalSet +fi +if (( iCalSet<1000000 )); then +cCalSet="000"$iCalSet +fi +if (( iCalSet<100000 )); then +cCalSet="0000"$iCalSet +fi +echo cCalSet = $cCalSet +#iSet=0 +#lastOpt='' +nEvi0=200000 # start value +nEvi1=20000 # increment + +if [ -e /lustre ]; then +source /lustre/cbm/users/nh/CBM/cbmroot/trunk/build/config.sh -a +wdir=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2021 +outdir=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2021/${cRun} +else +wdir=`pwd` +outdir=${wdir}/${cRun} +fi +mkdir ${outdir} + +cd ${wdir} +mkdir ${cRun} +cp rootlogon.C ${cRun} +cp .rootrc ${cRun} +cd ${cRun} + +# Global variables, for for-loops +#iRestart=0 +#iRestart=1 # use copied calibration file with walk corrections +#iRestart=25 +#iRestart=29 +echo "Build option list with Dut $iDut, Ref $iMRef, BRef $iBRef" +iStep=0 +iStepLast=0 +iCalSel0=0 +iCalSel1=1 +#iCalSel0=-3 #0 +#iCalSel1=-4 #1 +# ************************** Starting while Loop ***************************** # +(( nEvi = nEvi0 + 10*nEvi1 )) +optList="" +optList=`echo " $nEvi,95,1,$iMRef,0 "`$optList +icalmod=3 +iDutIn=$iDut + +#for icallev in 9 9 8 8 8 8 7 7 7 7 6 5 4 4 3 3 1 +#for icallev in 9 9 8 8 7 6 5 4 3 1 +for icallev in 9 8 7 7 6 5 4 3 2 1 +do + (( nEvi = nEvi0 + (icallev-1)*nEvi1 )) + if [ ${icallev} -ge 7 ] && [ $iCalSel0 -eq 0 ]; then + iCalSel0=-2 # take corrections from cluster deviations + iDut=-1 # signal apply corrections to all counters + echo add step for minimizing cluster deviations + else # restore original settings + iCalSel0=0 + iDut=$iDutIn + fi + if [ ${icallev} -ge 8 ] ; then + icalmod=5 + else + if [ ${icallev} -gt 2 ] ; then + icalmod=9 + else + icalmod=3 + fi + fi + optList=`echo " $nEvi,$icallev$icalmod,$iCalSel0,$iDut,0 "`$optList + if [ $iMRef -ne 14 ]; then + if [ $iCalSel0 -ge 0 ]; then + optList=`echo " $nEvi,$icallev$icalmod,$iCalSel1,$iMRef,0 "`$optList + fi + else + for iMod in 40 10 + do + if [ $iMod -ne $iDut ]; then + optList=`echo " $nEvi,$icallev$icalmod,$iCalSel1,$iMod,0 "`$optList + fi + done + fi + if [ $icallev -lt 7 ] && [ $icalmod -lt 8 ]; then + optList=`echo " $nEvi,$icallev$icalmod,$iCalSel0,$iBRef,30 "`$optList + optList=`echo " $nEvi,$icallev$icalmod,$iCalSel1,$iBRef,30 "`$optList + else +# optList=`echo " $nEvi,$icallev$icalmod,-2,2,0 "`$optList + echo skip add options + fi +done + optList=`echo " $nEvi,0,0,$iBRef,30 "`$optList # start Init1 + echo optList: $optList + +# exit 0; + +for inOpt in $optList +do + echo step ${iStep} with option $inOpt + ((iStepLast = ${iStep})) + ((iStep += 1)) + + mkdir Init${iStep} + cp rootlogon.C Init${iStep} + cp .rootrc Init${iStep} + cd Init${iStep} + + if [[ ${lastOpt:+1} ]] ; then + # echo last round was done with $lastOpt, extract 2. and 3. word + i1=`expr index $inOpt , ` + i2=($i1+3) + #echo `expr index $inOpt , ` = $i1 + cMode=${inOpt:$i1:2} + cSel=${inOpt:$i2:1} + echo next iteration: cMode=$cMode, cSel=$cSel + if [[ ${cSel} = "-" ]];then + cSel=${inOpt:$i2:2} + echo cSel=$cSel + cSel="0" + fi + #copy calibration files + if [ $iStep -eq $iRestart ] && [ $iUseLast -gt 0 ]; then + echo clu_cal: Start with last calibration file 93_1 in `pwd` + if [ ! -e ../${cRun}_set${cCalSet}_93_1tofClust.hst.root ]; then + echo clu_cal: valid calibration file not existing, exiting ... + exit 1 + fi + cp -v ../${cRun}_set${cCalSet}_93_1tofClust.hst.root tofClust_${cRun}_set${cCalSet}.hst.root + fi + if (($iStep > $iRestart)) ; then + cp -v ../Init${iStepLast}/tofClust_${cRun}_set${cCalSet}.hst.root ${cRun}_set${cCalSet}_${cMode}_${cSel}tofClust.hst.root + fi + fi + + lastOpt=$inOpt + # generate new calibration file + if (($iStep > $iRestart)) ; then + root -b -q '../../ana_digi_cal_evt.C('$inOpt',"'${cRun}'",'${iCalSet}',0,'${iSel2}')' + #root -b -q '../../ana_digi_cal_all.C('$inOpt',"'${cRun}'",'${iCalSet}',0,'${iSel2}')' + echo files after root execution, check for New_${cRun}_set${cCalSet}_${cMode}_${cSel}tofClust.hst.root + #ls -rtl + + if [ -e New_${cRun}_set${cCalSet}_${cMode}_${cSel}tofClust.hst.root ]; then + ls -l New_${cRun}_set${cCalSet}_${cMode}_${cSel}tofClust.hst.root + cp -v New_${cRun}_set${cCalSet}_${cMode}_${cSel}tofClust.hst.root tofClust_${cRun}_set${cCalSet}.hst.root + fi + cp -v tofClust_${cRun}_set${cCalSet}.hst.root ../${cRun}_set${cCalSet}_${cMode}_${cSel}tofClust.hst.root + cp *pdf ../ + #./screenshot.sh + cd .. + rm ../${cRun}_set${cCalSet}_${cMode}_${cSel}tofClust.hst.root + ln -s ./${cRun}/${cRun}_set${cCalSet}_${cMode}_${cSel}tofClust.hst.root ../${cRun}_set${cCalSet}_${cMode}_${cSel}tofClust.hst.root + echo Init step $iStep with mode ${cMode}, option $inOpt finished + else + cd .. + echo Init step $iStep with mode ${cMode}, option $inOpt skipped + fi +done +cd ${wdir} +echo clu_cal: Update default calibration file +cp -v ./${cRun}/${cRun}_set${cCalSet}_${cMode}_${cSel}tofClust.hst.root ./${cRun}/${cRun}_set${cCalSet}_93_1tofClust.hst.root +echo clu_cal: generate top level default calibration file link +if [ ! -e ./${cRun}_set${cCalSet}_93_1tofClust.hst.root ]; then + ln -s ./${cRun}/${cRun}_set${cCalSet}_93_1tofClust.hst.root ./${cRun}_set${cCalSet}_93_1tofClust.hst.root +fi +mv -v slurm-${SLURM_JOB_ID}.out ${outdir}/CluCalAll_${cRun}_${cCalSet}.out diff --git a/macro/beamtime/mcbm2021/dis_digi.C b/macro/beamtime/mcbm2021/dis_digi.C index 29b451dfa6..9959fd0129 100644 --- a/macro/beamtime/mcbm2021/dis_digi.C +++ b/macro/beamtime/mcbm2021/dis_digi.C @@ -5,9 +5,9 @@ void dis_digi(Int_t nEvents = 100, Int_t calMode = 93, Int_t calSel = 1, Int_t calSm = 0, Int_t RefSel = 1, TString cFileId = "68.50.7.1", Int_t iCalSet = 10500, Bool_t bOut = 0, Int_t iSel2 = 20, Double_t dDeadtime = 50, Int_t iGenCor = 1, Int_t iTrackingSetup = 1, Double_t dScalFac = 5., - Double_t dChi2Lim2 = 10., TString cCalId = "XXX", Bool_t bUseSigCalib = kFALSE, Int_t iCalOpt = 1) + Double_t dChi2Lim2 = 10., TString cCalId = "XXX", Bool_t bUseSigCalib = kFALSE, Int_t iCalOpt = 1, + Int_t iTrkPar = 3) { - Int_t iVerbose = 1; if (cCalId == "") cCalId = cFileId; TString FId = cFileId; @@ -19,8 +19,8 @@ void dis_digi(Int_t nEvents = 100, Int_t calMode = 93, Int_t calSel = 1, Int_t c //Specify log level (INFO, DEBUG, DEBUG1, ...) //TString logLevel = "FATAL"; //TString logLevel = "ERROR"; - TString logLevel = "INFO"; - //TString logLevel = "DEBUG"; + //TString logLevel = "INFO"; + TString logLevel = "DEBUG"; //TString logLevel = "DEBUG1"; //TString logLevel = "DEBUG2"; //TString logLevel = "DEBUG3"; @@ -28,6 +28,7 @@ void dis_digi(Int_t nEvents = 100, Int_t calMode = 93, Int_t calSel = 1, Int_t c gLogger->SetLogScreenLevel(logLevel); //gLogger->SetLogScreenLevel("DEBUG"); gLogger->SetLogVerbosityLevel("MEDIUM"); + //gLogger->SetLogVerbosityLevel("VERYHIGH"); TString workDir = gSystem->Getenv("VMCWORKDIR"); /* @@ -36,7 +37,8 @@ void dis_digi(Int_t nEvents = 100, Int_t calMode = 93, Int_t calSel = 1, Int_t c return; */ // TString paramDir = workDir + "/macro/beamtime/mcbm2019/"; - TString paramDir = "./"; + //TString paramDir = "./"; + TString paramDir = "/home/nh/LUSTRE/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2021/"; TString ParFile = paramDir + "data/" + cFileId + ".params.root"; TString InputFile = paramDir + "data/" + cFileId + ".root"; TString OutputFile = paramDir + "data/disdigi_" + cFileId + Form("_%09d%03d", iCalSet, iSel2) + ".out.root"; @@ -49,20 +51,31 @@ void dis_digi(Int_t nEvents = 100, Int_t calMode = 93, Int_t calSel = 1, Int_t c TString shcmd = "rm -v " + ParFile; gSystem->Exec(shcmd.Data()); + TString TofGeo; Int_t iGeo = 0; //iMc; if (iGeo == 0) { if (iRun < 690) TofGeo = "v20a_mcbm"; else { if (iRun < 1112) { TofGeo = "v21a_mcbm"; } - else { if (iRun < 1400) { TofGeo = "v21b_mcbm"; } else { - TofGeo = "v21d_mcbm"; - } + if (iRun < 1400) { TofGeo = "v21b_mcbm"; } + else { + if (iRun < 2000) { TofGeo = "v21d_mcbm"; } + else { + if (iRun < 2100) { TofGeo = "v21e_mcbm"; } + else { + if (iRun < 2176) { TofGeo = "v21f_mcbm"; } + else { + TofGeo = "v21g_mcbm"; + } + } + } + } } } - cout << "Geometry version " << TofGeo << endl; + /* TObjString* tofDigiFile = new TObjString( workDir + "/parameters/tof/tof_" + TofGeo + ".digi.par"); // TOF digi file @@ -128,537 +141,40 @@ void dis_digi(Int_t nEvents = 100, Int_t calMode = 93, Int_t calSel = 1, Int_t c // ----- Reconstruction run ------------------------------------------- FairRunAna* run = new FairRunAna(); - run->SetInputFile(InputFile.Data()); - //run->SetOutputFile(OutputFile); + FairFileSource* fFileSource = new FairFileSource(InputFile.Data()); + run->SetSource(fFileSource); run->SetUserOutputFileName(OutputFile.Data()); run->SetSink(new FairRootFileSink(run->GetUserOutputFileName())); - CbmTofEventClusterizer* tofClust = new CbmTofEventClusterizer("TOF Event Clusterizer", iVerbose, bOut); - - tofClust->SetCalMode(calMode); - tofClust->SetCalSel(calSel); - tofClust->SetCaldXdYMax(50.); // geometrical matching window in cm - tofClust->SetCalCluMulMax(4.); // Max Counter Cluster Multiplicity for filling calib histos - tofClust->SetCalRpc(calSm); // select detector for calibration update - tofClust->SetTRefId(RefSel); // reference trigger for offset calculation - tofClust->SetTotMax(20.); // Tot upper limit for walk corection - tofClust->SetTotMin(0.01); //(12000.); // Tot lower limit for walk correction - tofClust->SetTotPreRange(2.); // effective lower Tot limit in ns from peak position - tofClust->SetTotMean(2.); // Tot calibration target value in ns - tofClust->SetMaxTimeDist(1.0); // default cluster range in ns - //tofClust->SetMaxTimeDist(0.); //Deb// default cluster range in ns - tofClust->SetDelTofMax(60.); // acceptance range for cluster correlation in cm (!) - tofClust->SetSel2MulMax(4); // limit Multiplicity in 2nd selector - tofClust->SetChannelDeadtime(dDeadtime); // artificial deadtime in ns - tofClust->SetEnableAvWalk(kTRUE); - tofClust->SetYFitMin(1.E4); - //tofClust->SetTimePeriod(6.25); // ignore coarse time - //tofClust->SetCorMode(2); // correct missing hits - - Int_t calSelRead = calSel; - if (calSel < 0) calSelRead = 0; - TString cFname = Form("%s_set%09d_%02d_%01dtofClust.hst.root", cFileId.Data(), iCalSet, calMode, calSelRead); - tofClust->SetCalParFileName(cFname); - TString cOutFname = Form("tofClust_%s_set%09d.hst.root", cFileId.Data(), iCalSet); - tofClust->SetOutHstFileName(cOutFname); - - TString cAnaFile = Form("%s_%09d%03d_tofAna.hst.root", cFileId.Data(), iCalSet, iSel2); - - switch (calMode) { - case -1: // initial calibration - tofClust->SetTotMax(256.); // range in bin number - tofClust->SetTotPreRange(256.); - //tofClust->SetTotMin(1.); - tofClust->SetTRefDifMax(50000.); // in ns - tofClust->PosYMaxScal(10000.); // in % of length - tofClust->SetMaxTimeDist(0.); // no cluster building - //tofClust->SetTimePeriod(0.); // inspect coarse time - break; - case 0: // initial calibration - tofClust->SetTotMax(256.); // range in bin number - tofClust->SetTotPreRange(256.); - //tofClust->SetTotMin(1.); - tofClust->SetTRefDifMax(50.); // in ns - tofClust->PosYMaxScal(10.); // in % of length - tofClust->SetMaxTimeDist(0.); // no cluster building - //tofClust->SetTimePeriod(0.); // inspect coarse time - break; - case 1: // save offsets, update walks, for diamonds - tofClust->SetTotMax(256.); // range in bin number - tofClust->SetTotPreRange(256.); - tofClust->SetTRefDifMax(6.25); // in ns - //tofClust->SetTimePeriod(6.25); // inspect coarse time - tofClust->PosYMaxScal(10.); // in % of length - break; - case 11: - tofClust->SetTRefDifMax(5.); // in ns - tofClust->PosYMaxScal(3.0); // in % of length - break; - case 21: - tofClust->SetTRefDifMax(2.5); // in ns - tofClust->PosYMaxScal(2.0); // in % of length - break; - case 31: - tofClust->SetTRefDifMax(2.); // in ns - tofClust->PosYMaxScal(1.5); // in % of length - break; - case 41: - tofClust->SetTRefDifMax(1.); // in ns - tofClust->PosYMaxScal(0.8); // in % of length - break; - case 51: - tofClust->SetTRefDifMax(0.7); // in ns - tofClust->PosYMaxScal(0.7); // in % of length - break; - case 61: - tofClust->SetTRefDifMax(0.5); // in ns - tofClust->PosYMaxScal(0.7); // in % of length - break; - case 71: - tofClust->SetTRefDifMax(0.4); // in ns - tofClust->PosYMaxScal(0.6); // in % of length - break; - - case 2: // time difference calibration - tofClust->SetTRefDifMax(300.); // in ns - tofClust->PosYMaxScal(1000.); //in % of length - break; + gROOT->LoadMacro("ini_Clusterizer.C"); + Char_t* cCmd = Form("ini_Clusterizer(%d,%d,%d,%d,\"%s\",%d,%d,%d,%f,\"%s\")", calMode, calSel, calSm, RefSel, + cFileId.Data(), iCalSet, (Int_t) bOut, iSel2, dDeadtime, cCalId.Data()); + cout << "<I> " << cCmd << endl; + gInterpreter->ProcessLine(cCmd); - case 3: // time offsets - tofClust->SetTRefDifMax(200.); // in ns - tofClust->PosYMaxScal(100.); //in % of length - tofClust->SetMaxTimeDist(0.); // no cluster building - break; - case 12: - case 13: - tofClust->SetTRefDifMax(100.); // in ns - tofClust->PosYMaxScal(50.); //in % of length - break; - case 22: - case 23: - tofClust->SetTRefDifMax(50.); // in ns - tofClust->PosYMaxScal(20.); //in % of length - break; - case 32: - case 33: - tofClust->SetTRefDifMax(25.); // in ns - tofClust->PosYMaxScal(10.); //in % of length - break; - case 42: - case 43: - tofClust->SetTRefDifMax(12.); // in ns - tofClust->PosYMaxScal(5.); //in % of length - break; - case 52: - case 53: - tofClust->SetTRefDifMax(5.); // in ns - tofClust->PosYMaxScal(3.); //in % of length - break; - case 62: - case 63: - tofClust->SetTRefDifMax(3.); // in ns - tofClust->PosYMaxScal(2.); //in % of length - break; - case 72: - case 73: - tofClust->SetTRefDifMax(2.); // in ns - tofClust->PosYMaxScal(1.5); //in % of length - break; - case 82: - case 83: - tofClust->SetTRefDifMax(1.); // in ns - tofClust->PosYMaxScal(1.0); //in % of length - break; - case 92: - case 93: - tofClust->SetTRefDifMax(0.6); // in ns - tofClust->PosYMaxScal(1.0); //in % of length - break; - - case 4: // velocity dependence (DelTOF) - tofClust->SetTRefDifMax(6.); // in ns - tofClust->PosYMaxScal(1.5); //in % of length - break; - case 14: - tofClust->SetTRefDifMax(5.); // in ns - tofClust->PosYMaxScal(1.); //in % of length - break; - case 24: - tofClust->SetTRefDifMax(3.); // in ns - tofClust->PosYMaxScal(1.0); //in % of length - break; - case 34: - tofClust->SetTRefDifMax(2.); // in ns - tofClust->PosYMaxScal(1.0); //in % of length - break; - case 44: - tofClust->SetTRefDifMax(1.); // in ns - tofClust->PosYMaxScal(1.0); //in % of length - break; - case 54: - tofClust->SetTRefDifMax(0.7); // in ns - tofClust->PosYMaxScal(0.7); //in % of length - break; - case 64: - tofClust->SetTRefDifMax(0.5); // in ns - tofClust->PosYMaxScal(0.7); //in % of length - break; - default: cout << "<E> Calib mode not implemented! stop execution of script" << endl; return; - } - - run->AddTask(tofClust); + CbmTofEventClusterizer* tofClust = new CbmTofEventClusterizer("TOF Event Clusterizer", iVerbose, bOut); // ========================================================================= // === Tracking === // ========================================================================= + gROOT->LoadMacro("ini_trks.C"); + cCmd = Form("ini_trks(%d,%d,%d,%6.2f,%8.1f,\"%s\",%d,%d,%d)", iCalSet, iTrackingSetup, iGenCor, dScalFac, dChi2Lim2, + cCalId.Data(), (Int_t) bUseSigCalib, iCalOpt, iTrkPar); + gInterpreter->ProcessLine(cCmd); - CbmTofTrackFinder* tofTrackFinder = new CbmTofTrackFinderNN(); - tofTrackFinder->SetMaxTofTimeDifference(0.4); // in ns/cm - Int_t TrackerPar = 0; - switch (TrackerPar) { - case 0: // for full mTof setup - tofTrackFinder->SetTxLIM(0.3); // max slope dx/dz - tofTrackFinder->SetTyLIM(0.3); // max dev from mean slope dy/dz - tofTrackFinder->SetTxMean(0.); // mean slope dy/dz - tofTrackFinder->SetTyMean(0.); // mean slope dy/dz - break; - case 1: // for double stack test counters - tofTrackFinder->SetTxMean(0.21); // mean slope dy/dz - tofTrackFinder->SetTyMean(0.18); // mean slope dy/dz - tofTrackFinder->SetTxLIM(0.15); // max slope dx/dz - tofTrackFinder->SetTyLIM(0.18); // max dev from mean slope dy/dz - break; - } - - CbmTofTrackFitter* tofTrackFitter = new CbmTofTrackFitterKF(0, 211); - TFitter* MyFit = new TFitter(1); // initialize Minuit - tofTrackFinder->SetFitter(tofTrackFitter); - CbmTofFindTracks* tofFindTracks = new CbmTofFindTracks("TOF Track Finder"); - tofFindTracks->UseFinder(tofTrackFinder); - tofFindTracks->UseFitter(tofTrackFitter); - tofFindTracks->SetCalOpt(iCalOpt); // 1 - update offsets, 2 - update walk, 0 - bypass - tofFindTracks->SetCorMode(iGenCor); // valid options: 0,1,2,3,4,5,6, 10 - 19 - tofFindTracks->SetTtTarg(0.057); // target value for inverse velocity, > 0.033 ns/cm! - //tofFindTracks->SetTtTarg(0.035); // target value for inverse velocity, > 0.033 ns/cm! - tofFindTracks->SetCalParFileName(cTrkFile); // Tracker parameter value file name - tofFindTracks->SetBeamCounter(5, 0, 0); // default beam counter - tofFindTracks->SetR0Lim(100.); - - tofFindTracks->SetStationMaxHMul(30); // Max Hit Multiplicity in any used station - - tofFindTracks->SetT0MAX(dScalFac); // in ns - tofFindTracks->SetSIGT(0.08); // default in ns - tofFindTracks->SetSIGX(0.3); // default in cm - tofFindTracks->SetSIGY(0.6); // default in cm - tofFindTracks->SetSIGZ(0.05); // default in cm - tofFindTracks->SetUseSigCalib(bUseSigCalib); // ignore resolutions in CalPar file - tofTrackFinder->SetSIGLIM(dChi2Lim2 * 2.); // matching window in multiples of chi2 - tofTrackFinder->SetChiMaxAccept(dChi2Lim2); // max tracklet chi2 - - - Int_t iMinNofHits = -1; - Int_t iNStations = 0; - Int_t iNReqStations = 3; - - switch (iTrackingSetup) { - case 0: // bypass mode - iMinNofHits = -1; - iNStations = 1; - tofFindTracks->SetStation(0, 5, 0, 0); // Diamond - break; - - case 1: // for calibration mode of full setup - { - Double_t dTsig = dScalFac * 0.03; - tofFindTracks->SetSIGT(dTsig); // allow for variable deviations in ns - } - iMinNofHits = 3; - iNStations = 30; - iNReqStations = 4; - tofFindTracks->SetStation(0, 5, 0, 0); - tofFindTracks->SetStation(1, 0, 2, 2); - tofFindTracks->SetStation(2, 0, 1, 2); - tofFindTracks->SetStation(3, 0, 0, 2); - tofFindTracks->SetStation(4, 0, 2, 1); - tofFindTracks->SetStation(5, 0, 1, 1); - tofFindTracks->SetStation(6, 0, 0, 1); - tofFindTracks->SetStation(7, 0, 2, 3); - tofFindTracks->SetStation(8, 0, 1, 3); - tofFindTracks->SetStation(9, 0, 0, 3); - tofFindTracks->SetStation(10, 0, 2, 0); - tofFindTracks->SetStation(11, 0, 1, 0); - tofFindTracks->SetStation(12, 0, 0, 0); - tofFindTracks->SetStation(13, 0, 2, 4); - tofFindTracks->SetStation(14, 0, 1, 4); - tofFindTracks->SetStation(15, 0, 0, 4); - tofFindTracks->SetStation(16, 0, 4, 0); - tofFindTracks->SetStation(17, 0, 3, 0); - tofFindTracks->SetStation(18, 0, 4, 1); - tofFindTracks->SetStation(19, 0, 3, 1); - tofFindTracks->SetStation(20, 0, 4, 2); - tofFindTracks->SetStation(21, 0, 3, 2); - tofFindTracks->SetStation(22, 0, 4, 3); - tofFindTracks->SetStation(23, 0, 3, 3); - tofFindTracks->SetStation(24, 0, 4, 4); - tofFindTracks->SetStation(25, 0, 3, 4); - tofFindTracks->SetStation(26, 9, 0, 0); - tofFindTracks->SetStation(27, 9, 1, 0); - tofFindTracks->SetStation(28, 9, 0, 1); - tofFindTracks->SetStation(29, 9, 1, 1); - //tofFindTracks->SetStation(28, 6, 0, 0); - //tofFindTracks->SetStation(29, 6, 0, 1); - break; - - case 11: // for calibration mode of 2-stack & test counters - iMinNofHits = 4; - iNStations = 9; - iNReqStations = 5; - tofFindTracks->SetStation(0, 5, 0, 0); - tofFindTracks->SetStation(1, 0, 4, 1); - tofFindTracks->SetStation(2, 0, 3, 1); - tofFindTracks->SetStation(3, 0, 4, 0); - tofFindTracks->SetStation(4, 0, 3, 2); - tofFindTracks->SetStation(5, 9, 0, 0); - tofFindTracks->SetStation(6, 9, 1, 0); - tofFindTracks->SetStation(7, 9, 0, 1); - tofFindTracks->SetStation(8, 9, 1, 1); - break; - - case 2: - iMinNofHits = 3; - iNStations = 14; - iNReqStations = 5; - tofFindTracks->SetStation(0, 5, 0, 0); - tofFindTracks->SetStation(1, 0, 4, 1); - tofFindTracks->SetStation(2, 0, 3, 1); - tofFindTracks->SetStation(3, 0, 4, 0); - tofFindTracks->SetStation(4, 0, 3, 0); - tofFindTracks->SetStation(5, 0, 4, 2); - tofFindTracks->SetStation(6, 0, 3, 2); - tofFindTracks->SetStation(7, 0, 4, 3); - tofFindTracks->SetStation(8, 0, 3, 3); - tofFindTracks->SetStation(9, 0, 4, 4); - tofFindTracks->SetStation(10, 0, 3, 4); - tofFindTracks->SetStation(11, 9, 0, 0); - tofFindTracks->SetStation(12, 9, 0, 1); - tofFindTracks->SetStation(13, 7, 0, 0); - break; - - case 3: - iMinNofHits = 3; - iNStations = 16; - iNReqStations = 4; - - tofFindTracks->SetStation(0, 0, 2, 2); - tofFindTracks->SetStation(1, 0, 1, 2); - tofFindTracks->SetStation(2, 0, 0, 2); - - tofFindTracks->SetStation(3, 0, 2, 1); - tofFindTracks->SetStation(4, 0, 1, 1); - tofFindTracks->SetStation(5, 0, 0, 1); - - tofFindTracks->SetStation(6, 0, 2, 3); - tofFindTracks->SetStation(7, 0, 1, 3); - tofFindTracks->SetStation(8, 0, 0, 3); - - tofFindTracks->SetStation(9, 0, 2, 0); - tofFindTracks->SetStation(10, 0, 1, 0); - tofFindTracks->SetStation(11, 0, 0, 0); - - tofFindTracks->SetStation(12, 0, 2, 4); - tofFindTracks->SetStation(13, 0, 1, 4); - tofFindTracks->SetStation(14, 0, 0, 4); - - tofFindTracks->SetStation(15, 5, 0, 0); - /* - tofFindTracks->SetStation(16, 0, 3, 2); - tofFindTracks->SetStation(17, 0, 4, 2); - tofFindTracks->SetStation(18, 0, 3, 1); - tofFindTracks->SetStation(19, 0, 4, 1); - tofFindTracks->SetStation(20, 0, 3, 3); - tofFindTracks->SetStation(21, 0, 4, 3); - tofFindTracks->SetStation(22, 0, 3, 0); - tofFindTracks->SetStation(23, 0, 4, 0); - tofFindTracks->SetStation(24, 0, 3, 4); - tofFindTracks->SetStation(25, 0, 4, 4); - */ - break; - - case 4: - iMinNofHits = 3; - iNStations = 4; - iNReqStations = 4; - tofFindTracks->SetStation(0, 5, 0, 0); - tofFindTracks->SetStation(1, 0, 4, 1); - tofFindTracks->SetStation(2, 0, 3, 1); - tofFindTracks->SetStation(3, iDut, iDutSm, iDutRpc); - break; - - case 5: // for calibration of 2-stack and add-on counters (STAR2, BUC) - iMinNofHits = 3; - iNStations = 5; - iNReqStations = 4; - tofFindTracks->SetStation(0, 5, 0, 0); - tofFindTracks->SetStation(1, 0, 4, 1); - tofFindTracks->SetStation(2, 0, 3, 1); - tofFindTracks->SetStation(3, 9, 0, 0); - tofFindTracks->SetStation(4, 9, 0, 1); - break; - - case 6: - iMinNofHits = 3; - iNStations = 4; - iNReqStations = 4; - tofFindTracks->SetStation(0, 5, 0, 0); - tofFindTracks->SetStation(1, 0, 4, 1); - tofFindTracks->SetStation(2, 0, 3, 1); - tofFindTracks->SetStation(3, iDut, iDutSm, iDutRpc); - // tofFindTracks->SetStation(3, 9, 0, 0); - // tofFindTracks->SetStation(3, 9, 0, 1); - // tofFindTracks->SetStation(3, 7, 0, 0); - break; - - case 7: // for calibration of 2-stack and add-on counters (BUC) - iMinNofHits = 4; - iNStations = 5; - iNReqStations = 5; - tofFindTracks->SetStation(0, 5, 0, 0); - tofFindTracks->SetStation(1, 0, 4, 3); - tofFindTracks->SetStation(2, 0, 3, 3); - tofFindTracks->SetStation(3, 6, 0, 0); - tofFindTracks->SetStation(4, 6, 0, 1); - break; - - case 8: // evaluation of add-on counters (BUC) - iMinNofHits = 3; - iNStations = 4; - iNReqStations = 4; - tofFindTracks->SetStation(0, 5, 0, 0); - tofFindTracks->SetStation(1, 0, 4, 3); - tofFindTracks->SetStation(2, 0, 3, 3); - tofFindTracks->SetStation(3, iDut, iDutSm, iDutRpc); - break; - - case 10: - iMinNofHits = 3; - iNStations = 4; - iNReqStations = 4; - tofFindTracks->SetStation(0, 5, 0, 0); - tofFindTracks->SetStation(1, 0, 1, 2); - tofFindTracks->SetStation(2, 0, 0, 2); - tofFindTracks->SetStation(3, 0, 2, 2); - - default: - cout << "Tracking setup " << iTrackingSetup << " not implemented " << endl; - return; - ; - } - tofFindTracks->SetMinNofHits(iMinNofHits); - tofFindTracks->SetNStations(iNStations); - tofFindTracks->SetNReqStations(iNReqStations); - tofFindTracks->PrintSetup(); - run->AddTask(tofFindTracks); + CbmTofFindTracks* tofFindTracks = CbmTofFindTracks::Instance(); + Int_t iNStations = tofFindTracks->GetNStations(); // ========================================================================= // === Analysis === // ========================================================================= + /* + gROOT->LoadMacro("ini_AnaTestbeam.C"); + cCmd=Form("ini_AnaTestbeam(%d,\"%s\",%d,%6.2f,%d,%d)", + iCalSel, cFileId.Data(), iSel2, 0.9, iAnaCor, iMc); + */ + //gInterpreter->ProcessLine(cCmd); - CbmTofAnaTestbeam* tofAnaTestbeam = new CbmTofAnaTestbeam("TOF TestBeam Analysis", iVerbose); - - //CbmTofAnaTestbeam defaults - tofAnaTestbeam->SetReqTrg(0); // 0 - no selection - tofAnaTestbeam->SetDXMean(0.); - tofAnaTestbeam->SetDYMean(0.); - tofAnaTestbeam->SetDTMean(0.); // in ps - tofAnaTestbeam->SetDXWidth(0.4); - tofAnaTestbeam->SetDYWidth(0.4); - tofAnaTestbeam->SetDTWidth(80.); // in ps - tofAnaTestbeam->SetCalParFileName(cAnaFile); - tofAnaTestbeam->SetPosY4Sel(0.5); // Y Position selection in fraction of strip length - tofAnaTestbeam->SetDTDia(0.); // Time difference to additional diamond - tofAnaTestbeam->SetCorMode(RefSel); // 1 - DTD4, 2 - X4 - tofAnaTestbeam->SetMul0Max(30); // Max Multiplicity in dut - tofAnaTestbeam->SetMul4Max(30); // Max Multiplicity in Ref - RPC - tofAnaTestbeam->SetMulDMax(10); // Max Multiplicity in Diamond - tofAnaTestbeam->SetHitDistMin(30.); // initialization - tofAnaTestbeam->SetEnableMatchPosScaling(kTRUE); - - tofAnaTestbeam->SetPosYS2Sel(0.5); // Y Position selection in fraction of strip length - tofAnaTestbeam->SetChS2Sel(0.); // Center of channel selection window - tofAnaTestbeam->SetDChS2Sel(100.); // Width of channel selection window - tofAnaTestbeam->SetTShift(0.); // Shift DTD4 to 0 - tofAnaTestbeam->SetSel2TOff(0.); // Shift Sel2 time peak to 0 - tofAnaTestbeam->SetTOffD4(13.); // Shift DTD4 to physical value - - tofAnaTestbeam->SetBeamRefSmType(iRSelTyp); // common reaction reference - tofAnaTestbeam->SetBeamRefSmId(iRSelSm); - tofAnaTestbeam->SetBeamRefRpc(iRSelRpc); - - if (iSel2 > -1) { - tofClust->SetSel2Id(iSel2); - tofClust->SetSel2Sm(iSel2Sm); - tofClust->SetSel2Rpc(iSel2Rpc); - - tofAnaTestbeam->SetMrpcSel2(iSel2); // initialization of second selector Mrpc Type - tofAnaTestbeam->SetMrpcSel2Sm(iSel2Sm); // initialization of second selector Mrpc SmId - tofAnaTestbeam->SetMrpcSel2Rpc(iSel2Rpc); // initialization of second selector Mrpc RpcId - } - - tofClust->SetDutId(iDut); - tofClust->SetDutSm(iDutSm); - tofClust->SetDutRpc(iDutRpc); - - tofClust->SetSelId(iRef); - tofClust->SetSelSm(iRefSm); - tofClust->SetSelRpc(iRefRpc); - - tofAnaTestbeam->SetDut(iDut); // Device under test - tofAnaTestbeam->SetDutSm(iDutSm); // Device under test - tofAnaTestbeam->SetDutRpc(iDutRpc); // Device under test - tofAnaTestbeam->SetMrpcRef(iRef); // Reference RPC - tofAnaTestbeam->SetMrpcRefSm(iRefSm); // Reference RPC - tofAnaTestbeam->SetMrpcRefRpc(iRefRpc); // Reference RPC - - tofAnaTestbeam->SetChi2Lim(10.); // initialization of Chi2 selection limit - cout << "Run with iRSel = " << iRSel << ", iSel2 = " << iSel2in << endl; - - if (0) switch (iSet) { - case 0: // upper part of setup: P2 - P5 - case 3: // upper part of setup: P2 - P5 - case 34: // upper part of setup: P2 - P5 - case 400300: - switch (iRSel) { - case 4: - tofAnaTestbeam->SetTShift(0.); // Shift DTD4 to 0 - tofAnaTestbeam->SetTOffD4(16.); // Shift DTD4 to physical value - tofAnaTestbeam->SetSel2TOff(0.); // Shift Sel2 time peak to 0 - break; - - case 5: - tofAnaTestbeam->SetTShift(-3.); // Shift DTD4 to 0 - tofAnaTestbeam->SetTOffD4(16.); // Shift DTD4 to physical value - tofAnaTestbeam->SetSel2TOff(0.); // Shift Sel2 time peak to 0 - break; - - case 9: - tofAnaTestbeam->SetChi2Lim(100.); // initialization of Chi2 selection limit - tofAnaTestbeam->SetMulDMax(3); // Max Multiplicity in BeamRef // Diamond - tofAnaTestbeam->SetTShift(0.1); // Shift DTD4 to 0 - tofAnaTestbeam->SetTOffD4(16.); // Shift DTD4 to physical value - tofAnaTestbeam->SetSel2TOff(0.5); // Shift Sel2 time peak to 0 - break; - - default:; - } - - default: - cout << "<E> detector setup " << iSet << " unknown, stop!" << endl; - return; - ; - } // end of different subsets - - run->AddTask(tofAnaTestbeam); - // ========================================================================= /* CbmTofOnlineDisplay* display = new CbmTofOnlineDisplay(); display->SetUpdateInterval(1000); @@ -757,85 +273,4 @@ void dis_digi(Int_t nEvents = 100, Int_t calMode = 93, Int_t calSel = 1, Int_t c gEve->GetDefaultGLViewer()->RequestDraw(); } } - - // ----- Intialise and run -------------------------------------------- - // run->Init(); - // cout << "Starting run" << endl; - // run->Run(0, nEvents); - // ------------------------------------------------------------------------ - // default display - /* - TString Display_Status = "pl_over_Mat04D4best.C"; - TString Display_Funct = "pl_over_Mat04D4best()"; - gROOT->LoadMacro(Display_Status); - - gROOT->LoadMacro("fit_ybox.h"); - gROOT->LoadMacro("pl_all_CluMul.C"); - gROOT->LoadMacro("pl_all_CluRate.C"); - gROOT->LoadMacro("pl_over_cluSel.C"); - gROOT->LoadMacro("pl_over_clu.C"); - gROOT->LoadMacro("pl_all_dTSel.C"); - gROOT->LoadMacro("pl_over_MatD4sel.C"); - gROOT->LoadMacro("save_hst.C"); - - switch(iSet){ - default: - case 0: - case 3: - case 49: - case 79: - case 34: - case 94: - case 37: - case 97: - case 39: - case 99: - case 93: - case 300400: - case 400300: - case 910900: - case 300900: - case 400900: - case 901900: - case 921920: - case 300921: - case 920921: - case 920300: - case 921300: - - gInterpreter->ProcessLine("pl_over_clu(6)"); - gInterpreter->ProcessLine("pl_over_clu(6,0,1)"); - gInterpreter->ProcessLine("pl_over_clu(9,0,0)"); - gInterpreter->ProcessLine("pl_over_clu(9,0,1)"); - gInterpreter->ProcessLine("pl_over_clu(9,1,0)"); - gInterpreter->ProcessLine("pl_over_clu(9,1,1)"); - gInterpreter->ProcessLine("pl_over_clu(9,2,0)"); - gInterpreter->ProcessLine("pl_over_clu(9,2,1)"); - gInterpreter->ProcessLine("pl_over_cluSel(0,6,0,0)"); - gInterpreter->ProcessLine("pl_over_cluSel(0,6,0,1)"); - gInterpreter->ProcessLine("pl_over_cluSel(0,9,0,0)"); - gInterpreter->ProcessLine("pl_over_cluSel(0,9,0,1)"); - gInterpreter->ProcessLine("pl_over_cluSel(0,9,1,0)"); - gInterpreter->ProcessLine("pl_over_cluSel(0,9,1,1)"); - gInterpreter->ProcessLine("pl_over_cluSel(0,9,2,0)"); - gInterpreter->ProcessLine("pl_over_cluSel(0,9,2,1)"); - gInterpreter->ProcessLine("pl_over_cluSel(1,6,0,0)"); - gInterpreter->ProcessLine("pl_over_cluSel(1,6,0,1)"); - gInterpreter->ProcessLine("pl_over_cluSel(1,9,0,0)"); - gInterpreter->ProcessLine("pl_over_cluSel(1,9,0,1)"); - gInterpreter->ProcessLine("pl_over_cluSel(1,9,1,0)"); - gInterpreter->ProcessLine("pl_over_cluSel(1,9,1,1)"); - gInterpreter->ProcessLine("pl_over_cluSel(1,9,2,0)"); - gInterpreter->ProcessLine("pl_over_cluSel(1,9,2,1)"); - gInterpreter->ProcessLine("pl_all_CluMul()"); - gInterpreter->ProcessLine("pl_all_CluRate()"); - gInterpreter->ProcessLine("pl_all_dTSel()"); - TString FSave=Form("save_hst(\"cosdev-status%d_%d_Cal_%s.hst.root\")",iCalSet,iSel2in,cCalId.Data()); - gInterpreter->ProcessLine(FSave.Data()); - //gInterpreter->ProcessLine("pl_over_MatD4sel()"); - break; - ; - } - gInterpreter->ProcessLine(Display_Funct); - */ } diff --git a/macro/beamtime/mcbm2021/dis_reco_mcbm_digievent.C b/macro/beamtime/mcbm2021/dis_reco_mcbm_digievent.C new file mode 100644 index 0000000000..4e7e8b1bcd --- /dev/null +++ b/macro/beamtime/mcbm2021/dis_reco_mcbm_digievent.C @@ -0,0 +1,462 @@ +/* Copyright (C) 2020-2021 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt + SPDX-License-Identifier: GPL-3.0-only + Authors: Volker Friese [committer], Dominik Smith */ + +/** @file run_reco.C + ** @author Volker Friese <v.friese@gsi.de> + ** @since 14 November 2020 + **/ + + +// --- Includes needed for IDE +#include <RtypesCore.h> +#if !defined(__CLING__) +#include "CbmBuildEventsFromTracksReal.h" +#include "CbmBuildEventsIdeal.h" +#include "CbmBuildEventsQa.h" +#include "CbmDefs.h" +#include "CbmFindPrimaryVertex.h" +#include "CbmKF.h" +#include "CbmL1.h" +#include "CbmL1StsTrackFinder.h" +#include "CbmLitFindGlobalTracks.h" +#include "CbmMCDataManager.h" +#include "CbmMatchRecoToMC.h" +#include "CbmMuchFindHitsGem.h" +#include "CbmMvdClusterfinder.h" +#include "CbmMvdHitfinder.h" +#include "CbmPVFinderKF.h" +#include "CbmPrimaryVertexFinder.h" +#include "CbmPsdHitProducer.h" +#include "CbmRecoSts.h" +#include "CbmRichHitProducer.h" +#include "CbmRichReconstruction.h" +#include "CbmSetup.h" +#include "CbmStsFindTracks.h" +#include "CbmStsFindTracksEvents.h" +#include "CbmStsTrackFinder.h" +#include "CbmTaskBuildRawEvents.h" +#include "CbmTofSimpClusterizer.h" +#include "CbmTrdClusterFinder.h" +#include "CbmTrdHitProducer.h" + +#include <FairFileSource.h> +#include <FairMonitor.h> +#include <FairParAsciiFileIo.h> +#include <FairParRootFileIo.h> +#include <FairRunAna.h> +#include <FairRuntimeDb.h> +#include <FairSystemInfo.h> + +#include <TStopwatch.h> +#endif + + +/** @brief Macro for CBM reconstruction + ** @author Volker Friese <v.friese@gsi.de> + ** @since 14 November 2020 + ** @param input Name of input file (w/o extension .raw.root) + ** @param nTimeSlices Number of time-slices to process + ** @param firstTimeSlice First time-slice (entry) to be processed + ** @param output Name of output file (w/o extension .rec.root) + ** @param sEvBuildRaw Option for raw event building + ** @param setup Name of predefined geometry setup + ** @param paramFile Parameter ROOT file (w/o extension .par.root) + ** @param debugWithMC Option to provide the trackfinder with MC information + ** + ** This macro performs event-by-event reconstruction from from the digis in DigiEvents. + ** It can be used for real data after unpacking, triggering and event building or + ** for simulated data after triggering and event building with macro/reco/reco_digi.C. + ** + ** The file names must be specified without extensions. The convention is + ** that the raw (input) file is [input].raw.root. ThecalMode output file + ** will be [input].rec.root if not specified by the user. The parameter file + ** has the extension .par.root. It is assumed to be [input].par.root if + ** not specified by the user. + ** + ** If no argument is specified, the input will be set to "test". This allows + ** to execute the macro chain (run_tra_file.C, run_digi.C and run_reco.C) + ** from the ROOT prompt without user intervention. + ** + **/ +void dis_reco_mcbm_digievent(TString input = "", Int_t nTimeSlices = 1, Int_t firstTimeSlice = 0, TString output = "", + TString setup = "mcbm_beam_2021_07_surveyed", TString paramFile = "reco_mcbm_params_") +{ + + // ======================================================================== + // Adjust this part according to your requirements + + // --- Logger settings ---------------------------------------------------- + TString logLevel = "DEBUG"; + TString logVerbosity = "VERYHIGH"; + // ------------------------------------------------------------------------ + + // ----- Environment -------------------------------------------------- + TString myName = "run_reco_digievent"; // this macro's name for screen output + TString srcDir = gSystem->Getenv("VMCWORKDIR"); // top source directory + // ------------------------------------------------------------------------ + + TString DataPath = "./data/"; + //TString DataPath = "/home/nh/LUSTRE/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2021/data/"; + + // ----- In- and output file names ------------------------------------ + if (input.IsNull()) input = "1588"; + TString rawFile = DataPath + input + ".digievents.root"; + if (output.IsNull()) output = input; + TString outFile = DataPath + "dis_reco_mcbm_event_" + output + ".root"; + TString monFile = DataPath + output + ".moni_reco.root"; + if (paramFile.IsNull()) paramFile = input; + TString parFile = DataPath + paramFile + output + ".root"; + std::cout << "Inputfile " << rawFile << std::endl; + std::cout << "Outfile " << outFile << std::endl; + std::cout << "Parfile " << parFile << std::endl; + + TString shcmd = "rm -v " + parFile; + gSystem->Exec(shcmd.Data()); + + // ----- Load the geometry setup ------------------------------------- + std::cout << std::endl; + std::cout << "-I- " << myName << ": Loading setup " << setup << std::endl; + CbmSetup* geo = CbmSetup::Instance(); + geo->LoadSetup(setup); + + if (kTRUE) { // get geometry including TGeoManager + TString TofGeo = "v21d_mcbm"; + TString geoDir = gSystem->Getenv("VMCWORKDIR"); + TString geoFile = geoDir + "/geometry/tof/geofile_tof_" + TofGeo + ".root"; + TFile* fgeo = new TFile(geoFile); + TGeoManager* geoMan = (TGeoManager*) fgeo->Get("FAIRGeom"); + if (NULL == geoMan) { + cout << "<E> FAIRGeom not found in geoFile" << endl; + return; + } + } + // ------------------------------------------------------------------------ + + // ----- Some global switches ----------------------------------------- + Bool_t useMvd = kFALSE; // geo->IsActive(ECbmModuleId::kMvd); + Bool_t useSts = kFALSE; // geo->IsActive(ECbmModuleId::kSts); + Bool_t useRich = kFALSE; // geo->IsActive(ECbmModuleId::kRich); + Bool_t useMuch = kFALSE; // geo->IsActive(ECbmModuleId::kMuch); + Bool_t useTrd = kFALSE; // geo->IsActive(ECbmModuleId::kTrd); + Bool_t useTof = geo->IsActive(ECbmModuleId::kTof); + Bool_t usePsd = kFALSE; // geo->IsActive(ECbmModuleId::kPsd); + // ------------------------------------------------------------------------ + + + // ----- Parameter files as input to the runtime database ------------- + std::cout << std::endl; + std::cout << "-I- " << myName << ": Defining parameter files " << std::endl; + TList* parFileList = new TList(); + TString geoTag; + + // - TRD digitisation parameters + if (CbmSetup::Instance()->GetGeoTag(ECbmModuleId::kTrd, geoTag)) { + const Char_t* npar[4] = {"asic", "digi", "gas", "gain"}; + TObjString* trdParFile(NULL); + for (Int_t i(0); i < 4; i++) { + trdParFile = new TObjString(srcDir + "/parameters/trd/trd_" + geoTag + "." + npar[i] + ".par"); + parFileList->Add(trdParFile); + std::cout << "-I- " << myName << ": Using parameter file " << trdParFile->GetString() << std::endl; + } + } + + // - TOF digitisation parameters + if (CbmSetup::Instance()->GetGeoTag(ECbmModuleId::kTof, geoTag)) { + TObjString* tofBdfFile = new TObjString(srcDir + "/parameters/tof/tof_" + geoTag + ".digibdf.par"); + parFileList->Add(tofBdfFile); + std::cout << "-I- " << myName << ": Using parameter file " << tofBdfFile->GetString() << std::endl; + } + // ------------------------------------------------------------------------ + + // In general, the following parts need not be touched + // ======================================================================== + + + // ----- Timer -------------------------------------------------------- + TStopwatch timer; + timer.Start(); + // ------------------------------------------------------------------------ + + + // ----- FairRunAna --------------------------------------------------- + FairRunAna* run = new FairRunAna(); + FairFileSource* inputSource = new FairFileSource(rawFile); + run->SetSource(inputSource); + run->SetOutputFile(outFile); + run->SetGenerateRunInfo(kTRUE); + FairMonitor::GetMonitor()->EnableMonitor(kTRUE, monFile); + // ------------------------------------------------------------------------ + + + // ----- Logger settings ---------------------------------------------- + FairLogger::GetLogger()->SetLogScreenLevel(logLevel.Data()); + FairLogger::GetLogger()->SetLogVerbosityLevel(logVerbosity.Data()); + // ------------------------------------------------------------------------ + + + // ---- Make Reco Events ---------------------------------------------- + // ---- This is required if the input is in DigiEvent format + auto makeEvents = std::make_unique<CbmTaskMakeRecoEvents>(); + LOG(info) << "-I- " << myName << ": Adding task " << makeEvents->GetName(); + run->AddTask(makeEvents.release()); + // ------------------------------------------------------------------------ + + + // ----- Local reconstruction in STS ---------------------------------- + if (useSts) { + //auto recoSts = std::make_unique<CbmRecoSts>(kCbmRecoEvent); + //std::cout << "-I- " << myName << ": Adding task " << recoSts->GetName(); + + CbmRecoSts* recoSts = new CbmRecoSts(); + recoSts->SetMode(kCbmRecoEvent); + + recoSts->SetTimeCutDigisAbs(20.0); // cluster finder: time cut in ns + recoSts->SetTimeCutClustersAbs(20.0); // hit finder: time cut in ns + + // Sensor params + CbmStsParSensor sensor6cm(CbmStsSensorClass::kDssdStereo); + sensor6cm.SetPar(0, 6.2092); // Extension in x + sensor6cm.SetPar(1, 6.2); // Extension in y + sensor6cm.SetPar(2, 0.03); // Extension in z + sensor6cm.SetPar(3, 5.9692); // Active size in y + sensor6cm.SetPar(4, 1024.); // Number of strips front side + sensor6cm.SetPar(5, 1024.); // Number of strips back side + sensor6cm.SetPar(6, 0.0058); // Strip pitch front side + sensor6cm.SetPar(7, 0.0058); // Strip pitch back side + sensor6cm.SetPar(8, 0.0); // Stereo angle front side + sensor6cm.SetPar(9, 7.5); // Stereo angle back side + + CbmStsParSensor sensor12cm(sensor6cm); // copy all parameters, change then only the y size + sensor12cm.SetPar(1, 12.4); // Extension in y + sensor12cm.SetPar(3, 12.1692); // Active size in y + + // --- Addresses for sensors + // --- They are defined in each station as sensor 1, module 1, halfladderD (2), ladder 1 + // Int_t GetAddress(UInt_t unit = 0, UInt_t ladder = 0, UInt_t halfladder = 0, UInt_t module = 0, UInt_t sensor = 0, + // UInt_t side = 0, UInt_t version = kCurrentVersion); + + Int_t stsAddress01 = CbmStsAddress::GetAddress(0, 0, 1, 0, 0, 0); // U0 L0 M0 6 cm + Int_t stsAddress02 = CbmStsAddress::GetAddress(0, 0, 1, 1, 0, 0); // U0 L0 M1 6 cm + Int_t stsAddress03 = CbmStsAddress::GetAddress(0, 1, 1, 0, 0, 0); // U0 L1 M0 6 cm + Int_t stsAddress04 = CbmStsAddress::GetAddress(0, 1, 1, 1, 0, 0); // U0 L1 M1 6 cm + Int_t stsAddress05 = CbmStsAddress::GetAddress(1, 0, 1, 0, 0, 0); // U1 L0 M0 6 cm + Int_t stsAddress06 = CbmStsAddress::GetAddress(1, 0, 1, 1, 0, 0); // U1 L0 M1 12 cm + Int_t stsAddress07 = CbmStsAddress::GetAddress(1, 1, 1, 0, 0, 0); // U1 L1 M0 6 cm + Int_t stsAddress08 = CbmStsAddress::GetAddress(1, 1, 1, 1, 0, 0); // U1 L1 M1 12 cm + Int_t stsAddress09 = CbmStsAddress::GetAddress(1, 2, 1, 0, 0, 0); // U1 L2 M0 6 cm + Int_t stsAddress10 = CbmStsAddress::GetAddress(1, 2, 1, 1, 0, 0); // U1 L2 M1 6 cm + Int_t stsAddress11 = CbmStsAddress::GetAddress(1, 2, 1, 2, 0, 0); // U1 L2 M2 6 cm + + + std::cout << "STS address01 " << std::dec << stsAddress01 << " " << std::hex << stsAddress01 << std::endl; + std::cout << "STS address02 " << std::dec << stsAddress02 << " " << std::hex << stsAddress02 << std::endl; + std::cout << "STS address03 " << std::dec << stsAddress03 << " " << std::hex << stsAddress03 << std::endl; + std::cout << "STS address04 " << std::dec << stsAddress04 << " " << std::hex << stsAddress04 << std::endl; + std::cout << "STS address05 " << std::dec << stsAddress05 << " " << std::hex << stsAddress05 << std::endl; + std::cout << "STS address06 " << std::dec << stsAddress06 << " " << std::hex << stsAddress06 << std::endl; + std::cout << "STS address07 " << std::dec << stsAddress07 << " " << std::hex << stsAddress07 << std::endl; + std::cout << "STS address08 " << std::dec << stsAddress08 << " " << std::hex << stsAddress08 << std::endl; + std::cout << "STS address09 " << std::dec << stsAddress09 << " " << std::hex << stsAddress09 << std::endl; + std::cout << "STS address10 " << std::dec << stsAddress10 << " " << std::hex << stsAddress10 << std::endl; + std::cout << "STS address11 " << std::dec << stsAddress11 << " " << std::hex << stsAddress11 << std::endl; + + // --- Now we can define the sensor parameter set and tell recoSts to use it + auto sensorParSet = new CbmStsParSetSensor("CbmStsParSetSensor", "STS sensor parameters" + "mcbm2021"); + sensorParSet->SetParSensor(stsAddress01, sensor6cm); + sensorParSet->SetParSensor(stsAddress02, sensor6cm); + sensorParSet->SetParSensor(stsAddress03, sensor6cm); + sensorParSet->SetParSensor(stsAddress04, sensor6cm); + sensorParSet->SetParSensor(stsAddress05, sensor6cm); + sensorParSet->SetParSensor(stsAddress06, sensor12cm); + sensorParSet->SetParSensor(stsAddress07, sensor6cm); + sensorParSet->SetParSensor(stsAddress08, sensor12cm); + sensorParSet->SetParSensor(stsAddress09, sensor6cm); + sensorParSet->SetParSensor(stsAddress10, sensor6cm); + sensorParSet->SetParSensor(stsAddress11, sensor6cm); + + recoSts->UseSensorParSet(sensorParSet); + + // ASIC params: #ADC channels, dyn. range, threshold, time resol., dead time, + // noise RMS, zero-threshold crossing rate + auto parAsic = new CbmStsParAsic(128, 32, 75000., 3000., 5., 800., 1000., 3.9789e-3); + + // Module params: number of channels, number of channels per ASIC + auto parMod = new CbmStsParModule(2048, 128); + parMod->SetAllAsics(*parAsic); + recoSts->UseModulePar(parMod); + + // Sensor conditions: full depletion voltage, bias voltage, temperature, + // coupling capacitance, inter-strip capacitance + auto sensorCond = new CbmStsParSensorCond(70., 140., 268., 17.5, 1.); + recoSts->UseSensorCond(sensorCond); + + + run->AddTask(recoSts); + //run->AddTask(recoSts.release()); + std::cout << "-I- : Added task " << recoSts->GetName() << std::endl; + } + // ------------------------------------------------------------------------ + + // ----- Local reconstruction in TOF ---------------------------------- + + if (useTof) { + /* + auto recoTof = std::make_unique<CbmRecoTof>(kCbmRecoEvent); + std::cout << "-I- " << myName << ": Adding task " << recoTof->GetName(); + run->AddTask(recoTof.release()); + */ + // ========================================================================= + // === Tof Hit Building === + // ========================================================================= + gROOT->LoadMacro("ini_Clusterizer.C"); + int calMode = 93; + int calSel = 1; + int calSm = 1; + int RefSel = 1; + TString cFileId = "1588.50.6.0.2"; + int iCalSet = 12002002; + bool bOut = kFALSE; + int iSel2 = -1; + double dDeadtime = 50.; + TString cCalId = "1588.50.6.0.2"; + Char_t* cCmd = Form("ini_Clusterizer(%d,%d,%d,%d,\"%s\",%d,%d,%d,%f,\"%s\")", calMode, calSel, calSm, RefSel, + cFileId.Data(), iCalSet, (Int_t) bOut, iSel2, dDeadtime, cCalId.Data()); + cout << "<I> " << cCmd << endl; + gInterpreter->ProcessLine(cCmd); + + // ========================================================================= + // === Tof Tracking === + // ========================================================================= + int iSel = 12022; + int iTrackingSetup = 3; + int iGenCor = 3; + double dScalFac = 2.; + double dChi2Lim2 = 5.; + bool bUseSigCalib = kFALSE; + int iCalOpt = 1; + int iTrkPar = 3; + gROOT->LoadMacro("ini_trks.C"); + cCmd = Form("ini_trks(%d,%d,%d,%6.2f,%8.1f,\"%s\",%d,%d,%d)", iSel, iTrackingSetup, iGenCor, dScalFac, dChi2Lim2, + cCalId.Data(), (Int_t) bUseSigCalib, iCalOpt, iTrkPar); + cout << "<I> " << cCmd << endl; + gInterpreter->ProcessLine(cCmd); + + CbmTofFindTracks* tofFindTracks = CbmTofFindTracks::Instance(); + Int_t iNStations = tofFindTracks->GetNStations(); + } + + // ------------------------------------------------------------------------ + + + // ----- Parameter database -------------------------------------------- + std::cout << std::endl << std::endl; + std::cout << "-I- " << myName << ": Set runtime DB" << std::endl; + FairRuntimeDb* rtdb = run->GetRuntimeDb(); + FairParRootFileIo* parIo1 = new FairParRootFileIo(); + FairParAsciiFileIo* parIo2 = new FairParAsciiFileIo(); + parIo1->open(parFile.Data(), "UPDATE"); + rtdb->setFirstInput(parIo1); + if (!parFileList->IsEmpty()) { + parIo2->open(parFileList, "in"); + rtdb->setSecondInput(parIo2); + } + // ------------------------------------------------------------------------ + + + // ----- Run initialisation ------------------------------------------- + //std::cout << std::endl; + //std::cout << "-I- " << myName << ": Initialise run" << std::endl; + //run->Init(); + //rtdb->setOutput(parIo1); + //rtdb->saveOutput(); + //rtdb->print(); + // ------------------------------------------------------------------------ + + + // ----- Start run ---------------------------------------------------- + std::cout << std::endl << std::endl; + std::cout << "-I- " << myName << ": Starting run" << std::endl; + //run->Run(firstTimeSlice, nTimeSlices); + // ------------------------------------------------------------------------ + + FairEventManager* fMan = new FairEventManager(); + + CbmEvDisTracks* Tracks = new CbmEvDisTracks("Tof Tracks", 1, kFALSE, + kTRUE); //name, verbosity, RnrChildren points, RnrChildren track + // CbmEvDisTracks *Tracks = new CbmEvDisTracks("Tof Tracks",1); + fMan->AddTask(Tracks); + CbmPixelHitSetDraw* TofUHits = new CbmPixelHitSetDraw("TofUHit", kRed, kOpenCross); + fMan->AddTask(TofUHits); + CbmPointSetArrayDraw* TofHits = + new CbmPointSetArrayDraw("TofHit", 1, 1, 4, + kTRUE); //name, colorMode, markerMode, verbosity, RnrChildren + // CbmPixelHitSetDraw *TofHits = new CbmPixelHitSetDraw ("TofHit", kRed, kOpenCircle, 4);// kFullSquare); + fMan->AddTask(TofHits); + + TGeoVolume* top = gGeoManager->GetTopVolume(); + gGeoManager->SetVisOption(1); + gGeoManager->SetVisLevel(5); + TObjArray* allvolumes = gGeoManager->GetListOfVolumes(); + //cout<<"GeoVolumes " << gGeoManager->GetListOfVolumes()->GetEntries()<<endl; + for (Int_t i = 0; i < allvolumes->GetEntries(); i++) { + TGeoVolume* vol = (TGeoVolume*) allvolumes->At(i); + TString name = vol->GetName(); + // cout << " GeoVolume "<<i<<" Name: "<< name << endl; + vol->SetTransparency(90); + } + // gGeoManager->SetVisLevel(3); + // top->SetTransparency(80); + // top->Draw("ogl"); + + // fMan->Init(1,4,10000); + fMan->Init(1, 5); + + cout << "customize TEveManager gEve " << gEve << endl; + gEve->GetDefaultGLViewer()->SetClearColor(kYellow - 10); + TGLViewer* v = gEve->GetDefaultGLViewer(); + TGLAnnotation* ann = new TGLAnnotation(v, input, 0.01, 0.98); + ann->SetTextSize(0.03); // % of window diagonal + ann->SetTextColor(4); + // gEve->TEveProjectionAxes()->SetDrawOrigin(kTRUE); + { // from readCurrentCamera(const char* fname) + TGLCamera& c = gEve->GetDefaultGLViewer()->CurrentCamera(); + const char* fname = "Cam.sav"; + TFile* f = TFile::Open(fname, "READ"); + if (!f) return; + if (f->GetKey(c.ClassName())) { + f->GetKey(c.ClassName())->Read(&c); + c.IncTimeStamp(); + gEve->GetDefaultGLViewer()->RequestDraw(); + } + } + + // ----- Finish ------------------------------------------------------- + timer.Stop(); + FairMonitor::GetMonitor()->Print(); + Double_t rtime = timer.RealTime(); + Double_t ctime = timer.CpuTime(); + std::cout << std::endl << std::endl; + std::cout << "Macro finished successfully." << std::endl; + std::cout << "Output file is " << outFile << std::endl; + std::cout << "Parameter file is " << parFile << std::endl; + std::cout << "Real time " << rtime << " s, CPU time " << ctime << " s" << std::endl; + FairSystemInfo sysInfo; + Float_t maxMemory = sysInfo.GetMaxMemory(); + std::cout << "<DartMeasurement name=\"MaxMemory\" type=\"numeric/double\">"; + std::cout << maxMemory; + std::cout << "</DartMeasurement>" << std::endl; + Float_t cpuUsage = ctime / rtime; + std::cout << "<DartMeasurement name=\"CpuLoad\" type=\"numeric/double\">"; + std::cout << cpuUsage; + std::cout << "</DartMeasurement>" << std::endl; + // ------------------------------------------------------------------------ + + + // ----- This is to prevent a malloc error when exiting ROOT ---------- + // The source of the error is unknown. Related to TGeoManager. + //RemoveGeoManager(); + // ------------------------------------------------------------------------ + +} // End of main macro function diff --git a/macro/beamtime/mcbm2021/dis_trks.C b/macro/beamtime/mcbm2021/dis_trks.C index 753b5e447f..44727970b5 100644 --- a/macro/beamtime/mcbm2021/dis_trks.C +++ b/macro/beamtime/mcbm2021/dis_trks.C @@ -112,9 +112,11 @@ void dis_trks(Int_t nEvents = 10, Int_t iSel = 1, Int_t iGenCor = 1, TString cFi //run->SetInputFile(InputFile.Data()); //run->AddFriend(InputDigiFile.Data()); - run->SetInputFile(InputDigiFile.Data()); - //run->AddFriend(InputFile.Data()); - run->SetOutputFile(OutputFile); + FairFileSource* fFileSource = new FairFileSource(InputFile.Data()); + fFileSource->AddFriend(InputDigiFile.Data()); + run->SetSource(fFileSource); + run->SetUserOutputFileName(OutputFile.Data()); + run->SetSink(new FairRootFileSink(run->GetUserOutputFileName())); FairLogger::GetLogger()->SetLogScreenLevel(logLevel.Data()); // FairLogger::GetLogger()->SetLogVerbosityLevel("MEDIUM"); diff --git a/macro/beamtime/mcbm2021/eval_raw.C b/macro/beamtime/mcbm2021/eval_raw.C index 6b3cc5b92c..1888509b80 100644 --- a/macro/beamtime/mcbm2021/eval_raw.C +++ b/macro/beamtime/mcbm2021/eval_raw.C @@ -56,7 +56,16 @@ void eval_raw(Int_t nEvents = 10000000, Int_t calMode = 33, Int_t calSel = 1, In else { if (iRun < 1400) { TofGeo = "v21b_mcbm"; } else { - TofGeo = "v21d_mcbm"; + if (iRun < 2050) { TofGeo = "v21d_mcbm"; } + else { + if (iRun < 2150) { TofGeo = "v21e_mcbm"; } + else { + if (iRun < 2176) { TofGeo = "v21f_mcbm"; } + else { + TofGeo = "v21g_mcbm"; + } + } + } } } } @@ -93,7 +102,6 @@ void eval_raw(Int_t nEvents = 10000000, Int_t calMode = 33, Int_t calSel = 1, In master->Draw("ogl"); } - Int_t iRef = iSel % 1000; Int_t iDut = (iSel - iRef) / 1000; Int_t iDutRpc = iDut % 10; @@ -112,7 +120,6 @@ void eval_raw(Int_t nEvents = 10000000, Int_t calMode = 33, Int_t calSel = 1, In iSel2 = (iSel2 - iSel2Sm) / 10; Int_t iRSelin = iCalSet % 1000; - // ----- Reconstruction run ------------------------------------------- FairRunAna* run = new FairRunAna(); //run->SetInputFile(InputFile.Data()); diff --git a/macro/beamtime/mcbm2021/eval_raw.sh b/macro/beamtime/mcbm2021/eval_raw.sh new file mode 100755 index 0000000000..a19d616a17 --- /dev/null +++ b/macro/beamtime/mcbm2021/eval_raw.sh @@ -0,0 +1,136 @@ +#!/bin/bash +# Copyright (C) 2021 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt +# SPDX-License-Identifier: GPL-3.0-only +# First commited by Florian Uhlig + +# shell script to apply clusterizer calibrations +#SBATCH -J EvalRaw +#SBATCH -D /lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2021 +#SBATCH --time=48:00:00 +#SBATCH --mem=4000 +#SBATCH --partition=long +cRun=$1 + +iCalSet=$2 +((iTmp = $iCalSet )) +((iBRef = $iTmp % 1000)) +((iTmp = $iTmp - $iBRef)) +((iSet = $iTmp / 1000)) +((iRef = $iTmp % 1000000)) +((iRef = $iRef / 1000)) +((iTmp = $iTmp - $iRef)) +((iDut = $iTmp / 1000000)) + +iSel2=$3 + +cCalSet=$iCalSet +if (( iCalSet<100000000 )); then +cCalSet="0"$iCalSet +fi +if (( iCalSet<10000000 )); then +cCalSet="00"$iCalSet +fi +if (( iCalSet<1000000 )); then +cCalSet="000"$iCalSet +fi +if (( iCalSet<100000 )); then +cCalSet="0000"$iCalSet +fi +echo cCalSet = $cCalSet + +Deadtime=$4 +if [[ ${Deadtime} = "" ]]; then +Deadtime=50. +fi + +Nevt=$5 +if [[ ${Nevt} = "" ]]; then + echo use all events + Nevt=-1 +fi + +CalIdMode=$6 +if [[ ${CalIdMode} = "" ]]; then + echo use native calibration file + CalIdMode=${cRun} + CalFile=${cRun}_set${cCalSet}_93_1tofClust.hst.root +else + CalFile=${CalIdMode}_set${cCalSet}_93_1tofClust.hst.root + RunFile=${cRun}_set${cCalSet}_93_1tofClust.hst.root + rm ${RunFile} + ln -s ${CalFile} ${RunFile} + echo use calibrations from ${CalFile} +fi + +#CalIdSet=$7 +#if [[ ${CalIdSet} = "" ]]; then +# echo use native calibration file +# CalIdSet=$cCalSet +#else +# CalFile=${CalIdMode}_set${CalIdSet}_93_1tofClust.hst.root +#fi +#CalId=${CalIdMode}_set${CalIdSet} +CalId=${CalIdMode} + +# fixed parameter, TODO: make them input variables +iSel=$7 +if [[ $iSel = "" ]]; then + iSel=900041 +fi + +iTrackingSetup=$8 +if [[ $iTrackingSetup = "" ]]; then +#iTrackingSetup=42 # for Jun2021 + iTrackingSetup=4 # for May2021 +fi + +iSel22=$9 +if [[ $iSel22 = "" ]]; then + iSel22=31 +fi + +echo eval_raw for $cRun with iDut=$iDut, iRef=$iRef, iSet=$iCalSet, iSel2=$iSel2, iBRef=$iBRef, Deadtime=$Deadtime, CalId=$CalId, CalFile=$CalFile +echo eval_raw scan $Nevt events for iSel=$iSel, iSel22=$iSel22, iTrackingSetup=$iTrackingSetup + +if [ -e /lustre/cbm ]; then +source /lustre/cbm/users/nh/CBM/cbmroot/trunk/build/config.sh -a +wdir=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2021 +outdir=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2021/${cRun} +else +wdir=`pwd` +outdir=${wdir}/${cRun} +fi + +cd $wdir +mkdir $cRun +cd $cRun +cp ../.rootrc . +cp ../rootlogon.C . +cp -v ../${CalFile} . +FindTracksFile=./${CalId}_tofFindTracks.hst.root +if [ ! -e $FindTracksFile ]; then + echo link FindTracksFile to $FindTracksFile + ln -s -v ../${CalId}_tofFindTracks.hst.root $FindTracksFile +fi + +AnaCalFile=./${cRun}_TrkAnaTestBeam.hst.root +rm $AnaCalFile +if [ -e $AnaCalFile ]; then + echo AnaCalFile $AnaCalFile existing, check! + exit 0 +else + echo link AnaCalFile to $AnaCalFile + ln -s -v ../$CalId/Ana_${cCalSet}_${iBRef}_${iSel}_${iSel22}_${iTrackingSetup}/${CalId}_TrkAnaTestBeam.hst.root $AnaCalFile +fi + +#Int_t iPlot = 0, +#Int_t iSel = 910041, Int_t iSel22=31, Int_t iTrackingSetup=10, Int_t iGenCor=1, Double_t dScalFac=1, +#Double_t dChi2Lim2=3., Bool_t bUseSigCalib=kFALSE, Int_t iCalOpt=1, Int_t iAnaCor=1, Int_t iTrkPar=0, Int_t iMc=0 + +root -b -q '../eval_raw.C('$Nevt',93,1,'$iRef',1,"'$cRun'",'$iCalSet',1,'$iSel2','$Deadtime',"'$CalId'",'$iSel','$iSel22','$iTrackingSetup') ' + +rm -v ./$AnaCalFile +rm -v ./$FindTracksFile +cd .. + +mv -v slurm-${SLURM_JOB_ID}.out ${outdir}/EvalRaw_${cRun}_${iCalSet}_${iSel2}_${CalIdMode}_${iSel}_${iSel22}_${iTrackingSetup}.out diff --git a/macro/beamtime/mcbm2021/eval_tracks.sh b/macro/beamtime/mcbm2021/eval_tracks.sh index 36e40e3660..7c44c2f992 100755 --- a/macro/beamtime/mcbm2021/eval_tracks.sh +++ b/macro/beamtime/mcbm2021/eval_tracks.sh @@ -52,8 +52,19 @@ if [[ ${cCalRef} = "" ]]; then echo use default CalSet $cCalRef fi -dDTres=10000000 -nEvt=2000000 +cSingleShot=$9 +if [[ ${cSingleShot} = "S" ]]; then + dDTres=0 + nEvt=-1 +else + dDTres=10000000 + nEvt=1000000 +fi + +iTrkPar=${10} +if [[ ${iTrkPar} = "" ]]; then + iTrkPar=0 +fi cSel2=$iSel2; if [[ $iSel2 < 100 ]]; then @@ -69,9 +80,11 @@ if [ "$McId" = "mcbm" ]; then echo processing MC simulation iMc=1 fi + +echo iTrkPar = $iTrkPar if [ -e /lustre/cbm ]; then -source /lustre/cbm/users/nh/CBM/cbmroot/trunk/build/config.sh +source /lustre/cbm/users/nh/CBM/cbmroot/trunk/build/config.sh -a wdir=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2021 outdir=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2021/${cRun} else @@ -115,10 +128,11 @@ while [[ $dDTres > 0 ]]; do for iCal in 1 2 3 5 6 7 8 1 do - -root -b -q '../../ana_trks_eval.C('$nEvt','$iSel',-1,"'$cRun'","'$cSet'",'$iSel2','$iTraSetup','$fRange1','$fRange2','$dDeadtime',"'$cCalId'",'$iCal',0,'$iCalSet',0,'$iMc')' +echo execute root -b -q '../../ana_trks_eval.C('$nEvt','$iSel',-1,"'$cRun'","'$cSet'",'$iSel2','$iTraSetup','$fRange1','$fRange2','$dDeadtime',"'$cCalId'",'$iCal',0,'$iCalSet','$iTrkPar','$iMc')' +root -b -q '../../ana_trks_eval.C('$nEvt','$iSel',-1,"'$cRun'","'$cSet'",'$iSel2','$iTraSetup','$fRange1','$fRange2','$dDeadtime',"'$cCalId'",'$iCal',0,'$iCalSet','$iTrkPar','$iMc')' mv -v tofAnaTestBeam.hst.root ${cRun}_TrkAnaTestBeam.hst.root rm all_* +rm core* if (! (test -f Test.res)); then echo no resolution file available: exit @@ -143,8 +157,9 @@ done # final action -> scan full statistics iCal=1 -root -b -q '../../ana_trks_eval.C(-1,'$iSel',-1,"'$cRun'","'$cSet'",'$iSel2','$iTraSetup','$fRange1','$fRange2','$dDeadtime',"'$cCalId'",'$iCal',0,'$iCalSet',1,'$iMc')' +root -b -q '../../ana_trks_eval.C(-1,'$iSel',-1,"'$cRun'","'$cSet'",'$iSel2','$iTraSetup','$fRange1','$fRange2','$dDeadtime',"'$cCalId'",'$iCal',0,'$iCalSet','$iTrkPar','$iMc')' rm all_* +rm core* cd ../.. #mv -v slurm-${SLURM_ARRAY_JOB_ID}_${SLURM_ARRAY_TASK_ID}.out ${outdir}/IterTrack_${cRun}_${cSet}.out diff --git a/macro/beamtime/mcbm2021/gen_hits.sh b/macro/beamtime/mcbm2021/gen_hits.sh index 86689f1861..6f0b3d8240 100755 --- a/macro/beamtime/mcbm2021/gen_hits.sh +++ b/macro/beamtime/mcbm2021/gen_hits.sh @@ -43,7 +43,13 @@ if [[ ${Deadtime} = "" ]]; then Deadtime=50. fi -CalIdMode=$5 +Nevt=$5 +if [[ ${Nevt} = "" ]]; then + echo use all events + Nevt=-1 +fi + +CalIdMode=$6 if [[ ${CalIdMode} = "" ]]; then echo use native calibration file CalIdMode=${cRun} @@ -51,29 +57,26 @@ if [[ ${CalIdMode} = "" ]]; then else CalFile=${CalIdMode}_set${cCalSet}_93_1tofClust.hst.root RunFile=${cRun}_set${cCalSet}_93_1tofClust.hst.root -# rm ${RunFile} -# ln -s ${CalFile} ${RunFile} + rm ${RunFile} + ln -s ${CalIdMode}/${CalFile} ${RunFile} echo use calibrations from ${CalFile} fi -CalIdSet=$6 -if [[ ${CalIdSet} = "" ]]; then - echo use native calibration file - CalIdSet=$cCalSet -else - CalFile=${CalIdMode}_set${CalIdSet}_93_1tofClust.hst.root -fi +#CalIdSet=$7 +#if [[ ${CalIdSet} = "" ]]; then +# echo use native calibration file +# CalIdSet=$cCalSet +#else +# CalFile=${CalIdMode}_set${CalIdSet}_93_1tofClust.hst.root +#fi +#CalId=${CalIdMode}_set${CalIdSet} +CalId=${CalIdMode} -Nevt=$7 -if [[ ${Nevt} = "" ]]; then - echo use all events - Nevt=500000 -fi -echo gen_hits for $cRun with iDut=$iDut, iRef=$iRef, iSet=$iCalSet, iSel2=$iSel2, iBRef=$iBRef, Deadtime=$Deadtime, CalFile=$CalFile +echo gen_hits for $cRun with iDut=$iDut, iRef=$iRef, iSet=$iCalSet, iSel2=$iSel2, iBRef=$iBRef, Deadtime=$Deadtime, CalId=$CalId, CalFile=$CalFile if [ -e /lustre/cbm ]; then -source /lustre/cbm/users/nh/CBM/cbmroot/trunk/build/config.sh +source /lustre/cbm/users/nh/CBM/cbmroot/trunk/build/config.sh -a wdir=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2021 outdir=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2021/${cRun} else @@ -87,8 +90,9 @@ cd $cRun cp ../.rootrc . cp ../rootlogon.C . cp -v ../${CalFile} . +#root -b -q '../ana_digi_cal_evt.C('$Nevt',93,1,'$iRef',1,"'$cRun'",'$iCalSet',1,'$iSel2','$Deadtime',"'$CalId'") ' +root -b -q '../ana_digi_cal_all.C('$Nevt',93,1,'$iRef',1,"'$cRun'",'$iCalSet',1,'$iSel2','$Deadtime',"'$CalId'") ' #root -b -q '../ana_digi_cal.C(100000,93,1,'$iRef',1,"'$cRun'",'$iCalSet',1,'$iSel2','$Deadtime',"'$CalIdMode'") ' -root -b -q '../ana_digi_cal_all.C('$Nevt',93,1,'$iRef',1,"'$cRun'",'$iCalSet',1,'$iSel2','$Deadtime',"'$CalIdMode'") ' #root -b -q '../ana_digi_cos.C(-1,93,1,'$iRef',1,"'$cRun'",'$iCalSet',1,'$iSel2','$Deadtime',"'$CalIdMode'") ' #root -b -q '../ana_digi_star.C(-1,93,1,'$iRef',1,"'$cRun'",'$iCalSet',1,'$iSel2','$Deadtime',"'$CalIdMode'") ' diff --git a/macro/beamtime/mcbm2021/ini_AnaTestbeam.C b/macro/beamtime/mcbm2021/ini_AnaTestbeam.C new file mode 100644 index 0000000000..93ee1c6314 --- /dev/null +++ b/macro/beamtime/mcbm2021/ini_AnaTestbeam.C @@ -0,0 +1,455 @@ +/* Copyright (C) 2021-2022 PI-UHd, GSI + SPDX-License-Identifier: GPL-3.0-only + Authors: Norbert Herrmann [committer] */ + +void ini_AnaTestbeam(Int_t iSel = 910041, TString cFileId = "1255.50.3.0", Int_t iSel2 = 31, Int_t iRSel = 500, + Double_t dScalFac = 0.9, Int_t iAnaCor = 1, Int_t iMc = 0) +{ + Int_t iVerbose = 1; + TString cAnaFile = Form("%s_TrkAnaTestBeam.hst.root", cFileId.Data()); + + if (cFileId == "") { + cout << "<E> No action without cFileId!" << endl; + return; + } + TString FId = cFileId; + Int_t iNLen = FId.First("."); + TString cRun(FId(0, iNLen)); + Int_t iRun = cRun.Atoi(); + // ----- Local selection variables ------------------------------------------- + Int_t iRef = iSel % 1000; + Int_t iDut = (iSel - iRef) / 1000; + Int_t iDutRpc = iDut % 10; + iDut = (iDut - iDutRpc) / 10; + Int_t iDutSm = iDut % 10; + iDut = (iDut - iDutSm) / 10; + Int_t iRefRpc = iRef % 10; + iRef = (iRef - iRefRpc) / 10; + Int_t iRefSm = iRef % 10; + iRef = (iRef - iRefSm) / 10; + + Int_t iSel2in = iSel2; + Int_t iSel2Rpc = iSel2 % 10; + iSel2 = (iSel2 - iSel2Rpc) / 10; + Int_t iSel2Sm = iSel2 % 10; + iSel2 = (iSel2 - iSel2Sm) / 10; + + //Int_t iRSel = 500; + + Int_t iRSelin = iRSel; + Int_t iRSelRpc = iRSel % 10; + Int_t iRSelSm = ((iRSel - iRSelRpc) / 10) % 10; + Int_t iRSelTyp = iRSel / 100; + + cout << "Beam reference RSel " << iRSelin << ", TSR " << iRSelTyp << iRSelSm << iRSelRpc << endl; + + // ========================================================================= + // === Analysis === + // ========================================================================= + CbmTofAnaTestbeam* tofAnaTestbeam = new CbmTofAnaTestbeam("TOF TestBeam Analysis", iVerbose); + tofAnaTestbeam->SetCorMode(iAnaCor); // 1 - DTD4, 2 - X4, 3 - Y4, 4 - Texp + tofAnaTestbeam->SetHitDistMin(30.); // initialization + tofAnaTestbeam->SetEnableMatchPosScaling(kTRUE); + tofAnaTestbeam->SetSpillDuration(3.); + if (iMc == 1) { + tofAnaTestbeam->SetSpillDuration(0.); + tofAnaTestbeam->SetSpillBreak(0.); + } + //CbmTofAnaTestbeam defaults + tofAnaTestbeam->SetR0LimFit(50.); // limit distance of fitted track to nominal vertex + tofAnaTestbeam->SetStartSpillTime(0.); + + tofAnaTestbeam->SetDXMean(0.); + tofAnaTestbeam->SetDYMean(0.); + tofAnaTestbeam->SetDTMean(0.); // in ns + tofAnaTestbeam->SetDXWidth(0.5); + tofAnaTestbeam->SetDYWidth(0.8); + tofAnaTestbeam->SetDTWidth(0.08); // in ns + tofAnaTestbeam->SetCalParFileName(cAnaFile); + tofAnaTestbeam->SetPosY4Sel(0.5 * dScalFac); // Y Position selection in fraction of strip length + tofAnaTestbeam->SetDTDia(0.); // Time difference to additional diamond + tofAnaTestbeam->SetMul0Max(20); // Max Multiplicity in dut + tofAnaTestbeam->SetMul4Max(30); // Max Multiplicity in Ref - RPC + tofAnaTestbeam->SetMulDMax(3); // Max Multiplicity in Diamond / BeamRef + tofAnaTestbeam->SetTOffD4(14.); // initialization + tofAnaTestbeam->SetDTD4MAX(2.); // 6.); // initialization of Max time difference Ref - BRef + + //tofAnaTestbeam->SetTShift(-28000.);// initialization + tofAnaTestbeam->SetPosYS2Sel(0.55); // Y Position selection in fraction of strip length + tofAnaTestbeam->SetChS2Sel(0.); // Center of channel selection window + tofAnaTestbeam->SetDChS2Sel(100.); // Width of channel selection window + tofAnaTestbeam->SetSel2TOff(0.); // Shift Sel2 time peak to 0 + tofAnaTestbeam->SetChi2Lim(5.); // initialization of Chi2 selection limit + tofAnaTestbeam->SetChi2Lim2(3.); // initialization of Chi2 selection limit for Mref-Sel2 pair + tofAnaTestbeam->SetDutDX(15.); // limit inspection of tracklets to selected region + tofAnaTestbeam->SetDutDY(15.); // limit inspection of tracklets to selected region + tofAnaTestbeam->SetSIGLIM(3.); // max matching chi2 + tofAnaTestbeam->SetSIGT(0.08); // in ns + tofAnaTestbeam->SetSIGX(0.3); // in cm + tofAnaTestbeam->SetSIGY(0.6); // in cm + + tofAnaTestbeam->SetBeamRefSmType(iRSelTyp); // common reaction reference + tofAnaTestbeam->SetBeamRefSmId(iRSelSm); + tofAnaTestbeam->SetBeamRefRpc(iRSelRpc); + + if (iSel2 >= -1) { + tofAnaTestbeam->SetMrpcSel2(iSel2); // initialization of second selector Mrpc Type + tofAnaTestbeam->SetMrpcSel2Sm(iSel2Sm); // initialization of second selector Mrpc SmId + tofAnaTestbeam->SetMrpcSel2Rpc(iSel2Rpc); // initialization of second selector Mrpc RpcId + } + + cout << "<I> AnaTestbeam init for Dut " << iDut << iDutSm << iDutRpc << ", Ref " << iRef << iRefSm << iRefRpc << endl; + + tofAnaTestbeam->SetDut(iDut); // Device under test + tofAnaTestbeam->SetDutSm(iDutSm); // Device under test + tofAnaTestbeam->SetDutRpc(iDutRpc); // Device under test + tofAnaTestbeam->SetMrpcRef(iRef); // Reference RPC + tofAnaTestbeam->SetMrpcRefSm(iRefSm); // Reference RPC + tofAnaTestbeam->SetMrpcRefRpc(iRefRpc); // Reference RPC + + cout << "<I> dispatch iSel = " << iSel << ", iSel2in = " << iSel2in << ", iRSelin = " << iRSelin + << ", iRSel = " << iRSel << endl; + + if (1) { + switch (iSel) { + + case 10: + switch (iRSelin) { + case 500: + tofAnaTestbeam->SetTShift(2.5); // Shift DTD4 to 0 + tofAnaTestbeam->SetTOffD4(18.); // Shift DTD4 to physical value + switch (iSel2in) { + case 20: + tofAnaTestbeam->SetSel2TOff(0.); // Shift Sel2 time peak to 0 + break; + default:; + } + break; + default:; + } + break; + + case 700040: + case 900040: + case 901040: + switch (iRSelin) { + case 500: + tofAnaTestbeam->SetTShift(0.3); // Shift DTD4 to 0 + tofAnaTestbeam->SetTOffD4(18.); // Shift DTD4 to physical value + + switch (iSel2in) { + case 30: + tofAnaTestbeam->SetSel2TOff(-0.3); // Shift Sel2 time peak to 0 + break; + case 31: + tofAnaTestbeam->SetSel2TOff(-0.41); // Shift Sel2 time peak to 0 + break; + + default:; + } + break; + default:; + } + break; + + case 700041: + case 900041: + case 901041: + case 910041: + case 911041: + switch (iRSelin) { + case 500: + if (iMc == 0) { // data + //tofAnaTestbeam->SetTShift(7.); // Shift DTD4 to 0 + tofAnaTestbeam->SetTShift(-1.); // Shift DTD4 to 0 + tofAnaTestbeam->SetTOffD4(14.); // Shift DTD4 to physical value + } + else { // MC + tofAnaTestbeam->SetTShift(-2.); // Shift DTD4 to 0 + tofAnaTestbeam->SetTOffD4(15.); // Shift DTD4 to physical value + } + switch (iSel2in) { + case 30: + tofAnaTestbeam->SetSel2TOff(-0.3); // Shift Sel2 time peak to 0 + break; + + case 910: + case 911: + case 31: + if (iMc == 0) { + switch (iRun) { + case 727: + case 726: + case 723: + case 721: + tofAnaTestbeam->SetTShift(6.5); // Shift DTD4 to 0 + tofAnaTestbeam->SetSel2TOff(0.6); // Shift Sel2 time peak to 0 + break; + case 1044: + case 1051: + case 1058: + tofAnaTestbeam->SetTShift(-3.); // Shift DTD4 to 0 + tofAnaTestbeam->SetSel2TOff(0.); // Shift Sel2 time peak to 0 + break; + + case 1255: + case 1258: + tofAnaTestbeam->SetSel2TOff(0.3); // Shift Sel2 time peak to 0 + break; + + case 1256: + case 1259: + case 1260: + case 1262: + case 1263: + tofAnaTestbeam->SetSel2TOff(0.); // Shift Sel2 time peak to 0 + break; + + case 1266: + case 1267: + case 1268: + case 1269: + case 1270: + case 1271: + case 1273: + case 1274: + case 1276: + case 1277: + case 1278: + case 1279: + case 1280: + case 1281: + case 1282: + case 1283: + case 1284: + //tofAnaTestbeam->SetSel2TOff(-5.3); // Shift Sel2 time peak to 0 + tofAnaTestbeam->SetSel2TOff(0.4); // Shift Sel2 time peak to 0 + break; + + case 1275: + tofAnaTestbeam->SetSel2TOff(0.15); // Shift Sel2 time peak to 0 + break; + + case 717: + default: // 714 + //tofAnaTestbeam->SetSel2TOff(-1.3); // Shift Sel2 time peak to 0 + tofAnaTestbeam->SetSel2TOff(-0.5); // Shift Sel2 time peak to 0 + } + } + else { // MC + tofAnaTestbeam->SetSel2TOff(-1.3); // Shift Sel2 time peak to 0 + } + break; + case 600: + tofAnaTestbeam->SetSel2TOff(-0.2); // Shift Sel2 time peak to 0 + break; + + default:; + } + break; + + case 901: // June 2021 + switch (iSel2in) { + case 31: + tofAnaTestbeam->SetSel2TOff(0.); // Shift Sel2 time peak to 0 + break; + } + + default:; + } + break; + + case 600041: + case 601041: + switch (iRSelin) { + case 500: + tofAnaTestbeam->SetTShift(5.3); // Shift DTD4 to 0 + tofAnaTestbeam->SetTOffD4(11.); // Shift DTD4 to physical value + + switch (iSel2in) { + case 33: + tofAnaTestbeam->SetSel2TOff(-0.55); // Shift Sel2 time peak to 0 + break; + + default:; + } + break; + + case 901: + switch (iSel2in) { + case 900: + tofAnaTestbeam->SetSel2TOff(0.); // Shift Sel2 time peak to 0 + break; + + default:; + } + break; + default:; + } + break; + + case 600043: + case 601043: + switch (iRSelin) { + case 500: + tofAnaTestbeam->SetTShift(0.); // Shift DTD4 to 0 + tofAnaTestbeam->SetTOffD4(11.); // Shift DTD4 to physical value + + switch (iSel2in) { + case 33: + tofAnaTestbeam->SetSel2TOff(0.); // Shift Sel2 time peak to 0 + break; + + default:; + } + break; + default:; + } + break; + + case 900600: + case 901600: + switch (iRSelin) { + case 900: + case 901: + tofAnaTestbeam->SetTShift(0.); // Shift DTD4 to 0 + tofAnaTestbeam->SetTOffD4(11.); // Shift DTD4 to physical value + switch (iSel2in) { + case 31: + tofAnaTestbeam->SetSel2TOff(0.); // Shift Sel2 time peak to 0 + break; + case 41: + tofAnaTestbeam->SetSel2TOff(0.); // Shift Sel2 time peak to 0 + break; + default:; + } + break; + default:; + } + break; + + case 12022: + switch (iRSelin) { + case 500: + tofAnaTestbeam->SetTShift(3.); // Shift DTD4 to 0 + tofAnaTestbeam->SetTOffD4(15.); // Shift DTD4 to physical value + + switch (iSel2in) { + case 2: + tofAnaTestbeam->SetSel2TOff(0.25); // Shift Sel2 time peak to 0 + break; + + default:; + } + break; + default:; + } + break; + + case 911910: + case 900910: + case 901910: + case 31910: + case 41910: + switch (iRSelin) { + case 500: + tofAnaTestbeam->SetTShift(0.); // Shift DTD4 to 0 + tofAnaTestbeam->SetTOffD4(10.); // Shift DTD4 to physical value + + switch (iSel2in) { + case 31: + tofAnaTestbeam->SetSel2TOff(0.); // Shift Sel2 time peak to 0 + break; + + case 41: + tofAnaTestbeam->SetSel2TOff(0.); // Shift Sel2 time peak to 0 + break; + + default:; tofAnaTestbeam->SetSel2TOff(0.); // Shift Sel2 time peak to 0 + } + break; + default:; + } + break; + + case 910911: + case 900911: + case 901911: + case 31911: + case 41911: + switch (iRSelin) { + case 500: + tofAnaTestbeam->SetTShift(0.); // Shift DTD4 to 0 + tofAnaTestbeam->SetTOffD4(11.); // Shift DTD4 to physical value + switch (iSel2in) { + case 31: + tofAnaTestbeam->SetSel2TOff(0.); // Shift Sel2 time peak to 0 + break; + case 41: + tofAnaTestbeam->SetSel2TOff(0.); // Shift Sel2 time peak to 0 + break; + default:; + } + break; + default:; + } + break; + + case 202042: + switch (iRSelin) { + case 500: + tofAnaTestbeam->SetTShift(0.); // Shift DTD4 to 0 + tofAnaTestbeam->SetTOffD4(11.); // Shift DTD4 to physical value + switch (iSel2in) { + case 12: + tofAnaTestbeam->SetSel2TOff(0.); // Shift Sel2 time peak to 0 + break; + case 2: + tofAnaTestbeam->SetSel2TOff(0.); // Shift Sel2 time peak to 0 + break; + default:; + } + break; + default:; + } + break; + + case 10000: + case 11001: + case 12002: + case 13003: + case 14004: + case 202002: + case 202012: + case 202022: + case 22002: + tofAnaTestbeam->SetTOffD4(11.); // Shift DTD4 to physical value + switch (iRSelin) { + case 11: + case 22: + tofAnaTestbeam->SetTShift(0.); // Shift DTD4 to 0 + switch (iSel2in) { + case 22: + tofAnaTestbeam->SetSel2TOff(0.); // Shift Sel2 time peak to 0 + break; + case 2: + tofAnaTestbeam->SetSel2TOff(0.); // Shift Sel2 time peak to 0 + break; + default:; + } + break; + default:; + } + break; + + default: + cout << "Setup " << iSel + << " unknown, better to define analysis setup! Running with default offset parameter... " << endl; + // return; + } // end of different subsets + + cout << "<I> Initialize TSHIFT to " << tofAnaTestbeam->GetTShift() << endl; + FairRunAna* run = FairRunAna::Instance(); + if (NULL != run) run->AddTask(tofAnaTestbeam); + } +} diff --git a/macro/beamtime/mcbm2021/ini_Clusterizer.C b/macro/beamtime/mcbm2021/ini_Clusterizer.C new file mode 100644 index 0000000000..33c93c44d1 --- /dev/null +++ b/macro/beamtime/mcbm2021/ini_Clusterizer.C @@ -0,0 +1,262 @@ +/* Copyright (C) 2022 PI-UHd, GSI + SPDX-License-Identifier: GPL-3.0-only + Authors: Norbert Herrmann [committer] */ + +void ini_Clusterizer(Int_t calMode = 53, Int_t calSel = 0, Int_t calSm = 900, Int_t RefSel = 1, + TString cFileId = "Test", Int_t iCalSet = 910601600, Bool_t bOut = 0, Int_t iSel2 = 0, + Double_t dDeadtime = 50, TString cCalId = "XXX") +{ + Int_t iVerbose = 1; + CbmTofEventClusterizer* tofClust = new CbmTofEventClusterizer("TOF Event Clusterizer", iVerbose, bOut); + cout << "Instantiate CbmTofEventClusterizer " << endl; + tofClust->SetCalMode(calMode); + tofClust->SetCalSel(calSel); + tofClust->SetCaldXdYMax(3000.); // geometrical matching window in cm + tofClust->SetCalCluMulMax(3.); // Max Counter Cluster Multiplicity for filling calib histos + tofClust->SetCalRpc(calSm); // select detector for calibration update + tofClust->SetTRefId(RefSel); // reference trigger for offset calculation + tofClust->SetTotMax(20.); // Tot upper limit for walk corection + tofClust->SetTotMin(0.); //(12000.); // Tot lower limit for walk correction + tofClust->SetTotPreRange(5.); // effective lower Tot limit in ns from peak position + tofClust->SetTotMean(5.); // Tot calibration target value in ns + tofClust->SetMaxTimeDist(0.5); // default cluster range in ns + //tofClust->SetMaxTimeDist(0.); //Deb// default cluster range in ns + tofClust->SetDelTofMax(50.); // acceptance range for cluster distance in ns (!) + tofClust->SetSel2MulMax(3); // limit Multiplicity in 2nd selector + tofClust->SetChannelDeadtime(dDeadtime); // artificial deadtime in ns + tofClust->SetEnableAvWalk(kFALSE); + //tofClust->SetEnableMatchPosScaling(kFALSE); // turn off projection to nominal target + tofClust->SetYFitMin(1.E3); + tofClust->SetToDAv(0.04); + // tofClust->SetTimePeriod(25600.); // ignore coarse time + // tofClust->SetCorMode(iBugCor); // correct missing hits + //tofClust->SetIdMode(0); // calibrate on counter level + tofClust->SetIdMode(1); // calibrate on module level + // tofClust->SetDeadStrips(15,23); // declare dead strip for T0M3,Rpc0,Strip 23 + //tofClust->SetDeadStrips(25,16); // declare non-existant diamond strip (#5) dead + + Int_t calSelRead = calSel; + if (calSel < 0) calSelRead = 1; // get default calibration + TString cFname = Form("%s_set%09d_%02d_%01dtofClust.hst.root", cFileId.Data(), iCalSet, calMode, calSelRead); + if (cCalId != "XXX") + cFname = Form("%s_set%09d_%02d_%01dtofClust.hst.root", cCalId.Data(), iCalSet, calMode, calSelRead); + tofClust->SetCalParFileName(cFname); + TString cOutFname = Form("tofClust_%s_set%09d.hst.root", cFileId.Data(), iCalSet); + tofClust->SetOutHstFileName(cOutFname); + + TString cAnaFile = Form("%s_%09d%03d_tofAna.hst.root", cFileId.Data(), iCalSet, iSel2); + + switch (calMode) { + case -1: // initial check of raw data + tofClust->SetTotMax(256.); // range in bin number + tofClust->SetTotPreRange(256.); + //tofClust->SetTotMin(1.); + tofClust->SetTRefDifMax(26000.); // in ns + tofClust->PosYMaxScal(10000.); // in % of length + tofClust->SetMaxTimeDist(0.); // no cluster building + //tofClust->SetTimePeriod(25600.); // inspect coarse time + break; + case 0: // initial calibration + tofClust->SetTotMax(256.); // range in bin number + tofClust->SetTotPreRange(256.); + //tofClust->SetTotMin(1.); + tofClust->SetTRefDifMax(1000.); // in ns + tofClust->PosYMaxScal(10.); // in % of length + tofClust->SetMaxTimeDist(0.); // no cluster building + break; + case 1: // save offsets, update walks, for diamonds + tofClust->SetTotMax(256.); // range in bin number + tofClust->SetTotPreRange(256.); + tofClust->SetTRefDifMax(6.25); // in ns + //tofClust->SetTimePeriod(6.25); // inspect coarse time + tofClust->PosYMaxScal(10.); // in % of length + break; + case 11: + tofClust->SetTRefDifMax(5.); // in ns + tofClust->PosYMaxScal(3.0); // in % of length + break; + case 21: + tofClust->SetTRefDifMax(3.0); // in ns + tofClust->PosYMaxScal(2.0); // in % of length + break; + case 31: + tofClust->SetTRefDifMax(3.); // in ns + tofClust->PosYMaxScal(1.); // in % of length + break; + case 41: + tofClust->SetTRefDifMax(2.0); // in ns + tofClust->PosYMaxScal(0.9); // in % of length + break; + case 51: + tofClust->SetTRefDifMax(2.0); // in ns + tofClust->PosYMaxScal(0.8); // in % of length + break; + case 61: + tofClust->SetTRefDifMax(1.5); // in ns + tofClust->PosYMaxScal(0.75); // in % of length + break; + case 71: + tofClust->SetTRefDifMax(0.8); // in ns + tofClust->PosYMaxScal(0.6); // in % of length + break; + + case 2: // time difference calibration + tofClust->SetTRefDifMax(300.); // in ns + tofClust->PosYMaxScal(1000.); //in % of length + break; + + case 3: // time offsets + tofClust->SetTRefDifMax(200.); // in ns + tofClust->PosYMaxScal(100.); //in % of length + tofClust->SetMaxTimeDist(0.); // no cluster building + break; + case 12: + case 13: + tofClust->SetTRefDifMax(100.); // in ns + tofClust->PosYMaxScal(10.); //in % of length + break; + case 22: + case 23: + tofClust->SetTRefDifMax(50.); // in ns + tofClust->PosYMaxScal(5.); //in % of length + break; + case 32: + case 33: + tofClust->SetTRefDifMax(25.); // in ns + tofClust->PosYMaxScal(4.); //in % of length + break; + case 42: + case 43: + tofClust->SetTRefDifMax(12.); // in ns + tofClust->PosYMaxScal(2.); //in % of length + break; + case 52: + case 53: + tofClust->SetTRefDifMax(10.); // in ns + tofClust->PosYMaxScal(1.5); //in % of length + break; + case 62: + case 63: + tofClust->SetTRefDifMax(10.); // in ns + tofClust->PosYMaxScal(1.); //in % of length + break; + case 72: + case 73: + case 75: + tofClust->SetTRefDifMax(10.); // in ns + tofClust->PosYMaxScal(0.9); //in % of length + break; + case 82: + case 83: + case 85: + tofClust->SetTRefDifMax(10.); // in ns + tofClust->PosYMaxScal(0.8); //in % of length + break; + case 92: + case 93: + case 95: + tofClust->SetTRefDifMax(10.); // in ns + tofClust->PosYMaxScal(0.75); //in % of length + break; + + case 4: // velocity dependence (DelTOF) + case 14: + tofClust->SetTRefDifMax(25.); // in ns + tofClust->PosYMaxScal(2.0); //in % of length + break; + case 24: + tofClust->SetTRefDifMax(5.); // in ns + tofClust->PosYMaxScal(1.5); //in % of length + break; + case 34: + tofClust->SetTRefDifMax(5.); // in ns + tofClust->PosYMaxScal(1.2); //in % of length + break; + case 44: + tofClust->SetTRefDifMax(3.5); // in ns + tofClust->PosYMaxScal(1.0); //in % of length + break; + case 54: + tofClust->SetTRefDifMax(3.0); // in ns + tofClust->PosYMaxScal(0.9); //in % of length + break; + case 64: + tofClust->SetTRefDifMax(2.5); // in ns + tofClust->PosYMaxScal(0.8); //in % of length + break; + case 74: + tofClust->SetTRefDifMax(2.0); // in ns + tofClust->PosYMaxScal(0.7); //in % of length + break; + case 19: + case 29: + case 39: + case 49: + case 59: + case 69: + case 79: + case 89: + case 99: + tofClust->SetTRefDifMax(20.0); // in ns + tofClust->PosYMaxScal(2.); //in % of length + break; + default: cout << "<E> Calib mode not implemented! stop execution of script" << endl; return; + } + + Int_t iBRef = iCalSet % 1000; + Int_t iSet = (iCalSet - iBRef) / 1000; + Int_t iRSel = 0; + Int_t iRSelTyp = 0; + Int_t iRSelSm = 0; + Int_t iRSelRpc = 0; + iRSel = iBRef; // use diamond + + Int_t iRSelin = iRSel; + iRSelRpc = iRSel % 10; + iRSelTyp = (iRSel - iRSelRpc) / 10; + iRSelSm = iRSelTyp % 10; + iRSelTyp = (iRSelTyp - iRSelSm) / 10; + + tofClust->SetBeamRefId(iRSelTyp); // define Beam reference counter + tofClust->SetBeamRefSm(iRSelSm); + tofClust->SetBeamRefDet(iRSelRpc); + tofClust->SetBeamAddRefMul(-1); + tofClust->SetBeamRefMulMax(3); + + Int_t iSel2in = iSel2; + if (iSel2in > -1) { + Int_t iSel2Rpc = iSel2 % 10; + iSel2 = (iSel2 - iSel2Rpc) / 10; + Int_t iSel2Sm = iSel2 % 10; + iSel2 = (iSel2 - iSel2Sm) / 10; + + tofClust->SetSel2Id(iSel2); + tofClust->SetSel2Sm(iSel2Sm); + tofClust->SetSel2Rpc(iSel2Rpc); + } + + Int_t iRef = iSet % 1000; + Int_t iDut = (iSet - iRef) / 1000; + Int_t iDutRpc = iDut % 10; + iDut = (iDut - iDutRpc) / 10; + Int_t iDutSm = iDut % 10; + iDut = (iDut - iDutSm) / 10; + + tofClust->SetDutId(iDut); + tofClust->SetDutSm(iDutSm); + tofClust->SetDutRpc(iDutRpc); + + Int_t iRefRpc = iRef % 10; + iRef = (iRef - iRefRpc) / 10; + Int_t iRefSm = iRef % 10; + iRef = (iRef - iRefSm) / 10; + + tofClust->SetSelId(iRef); + tofClust->SetSelSm(iRefSm); + tofClust->SetSelRpc(iRefRpc); + + FairRunAna* run = FairRunAna::Instance(); + if (NULL != run) run->AddTask(tofClust); + + cout << "Clusterizer Run with iRSel = " << iRSel << ", iSel2 = " << iSel2in << endl; +} diff --git a/macro/beamtime/mcbm2021/ini_trks.C b/macro/beamtime/mcbm2021/ini_trks.C index 555543c3fe..32e4611cd8 100644 --- a/macro/beamtime/mcbm2021/ini_trks.C +++ b/macro/beamtime/mcbm2021/ini_trks.C @@ -4,7 +4,7 @@ void ini_trks(Int_t iSel = 910041, Int_t iTrackingSetup = 4, Int_t iGenCor = 1, Double_t dScalFac = 1., Double_t dChi2Lim2 = 500., TString cCalId = "", Bool_t bUseSigCalib = kFALSE, Int_t iCalOpt = 1, - Int_t iTrkPar = 2) + Int_t iTrkPar = 2, Double_t dTOffScal = 1.) { if (cCalId == "") { cout << "<E> No action without cCalId!" << endl; @@ -42,7 +42,8 @@ void ini_trks(Int_t iSel = 910041, Int_t iTrackingSetup = 4, Int_t iGenCor = 1, tofFindTracks->SetCalOpt(iCalOpt); // 1 - update offsets, 2 - update walk, 0 - bypass tofFindTracks->SetCorMode(iGenCor); // valid options: 0,1,2,3,4,5,6, 10 - 19 //tofFindTracks->SetTtTarg(0.047); // target value for Mar2021 double stack, v21b - tofFindTracks->SetTtTarg(0.035); // target value for Jun2021 double stack, v21c, v21d + tofFindTracks->SetTtTarg(0.035); // target value for Jun2021 double stack, v21c, v21d,v21e,v21f + tofFindTracks->SetTOffScal(dTOffScal); // modifier of existing offset values // 0.0605); // target value for Mar2020 triple stack -> betapeak ~ 0.95 //tofFindTracks->SetTtTarg(0.062); // target value for Mar2020 triple stack -> betapeak ~ 0.95 //tofFindTracks->SetTtTarg(0.058); // target value for Mar2020 double stack @@ -65,12 +66,14 @@ void ini_trks(Int_t iSel = 910041, Int_t iTrackingSetup = 4, Int_t iGenCor = 1, cout << "<I> Tracker Parameter Set: " << iTrkPar << endl; switch (iTrkPar) { - case 0: // for full mTof setup - tofTrackFinder->SetTxMean(0.); // mean slope dy/dz + case 0: // for full mTof setup at 12.5 deg + tofTrackFinder->SetTxMean(-0.2); // mean slope dy/dz tofTrackFinder->SetTyMean(0.); // mean slope dy/dz - tofTrackFinder->SetTxLIM(0.3); // max slope dx/dz - tofTrackFinder->SetTyLIM(0.3); // max dev from mean slope dy/dz + tofTrackFinder->SetTxLIM(0.4); // max slope dx/dz + tofTrackFinder->SetTyLIM(0.4); // max dev from mean slope dy/dz tofFindTracks->SetBeamCounter(5, 0, 0); // default beam counter + tofFindTracks->SetR0Lim(30.); + tofFindTracks->SetEvNhitMax(40); // avoid wasting time break; case 1: // for double stack test counters tofTrackFinder->SetTxMean(0.); // mean slope dy/dz @@ -97,6 +100,16 @@ void ini_trks(Int_t iSel = 910041, Int_t iTrackingSetup = 4, Int_t iGenCor = 1, tofFindTracks->SetTtMin(-100.); // allow negative velocities with respect to z-axis tofFindTracks->SetR0Lim(30.); // allow for large extrapolation errors break; + case 4: // for Mar2022-CRI + tofTrackFinder->SetTxMean(0.); // mean slope dy/dz + tofTrackFinder->SetTyMean(0.); // mean slope dy/dz + tofTrackFinder->SetTxLIM(0.2); // max slope dx/dz + tofTrackFinder->SetTyLIM(0.4); // max dev from mean slope dy/dz + //tofTrackFinder->SetAddVertex(kTRUE); // add virtual vertex + tofFindTracks->SetTtTarg(0.033); // target value for mCBM Cosmic2021 triple stack, v21d, run 1588 + tofFindTracks->SetTtMin(0.); // allow negative velocities with respect to z-axis + tofFindTracks->SetR0Lim(20.); // allow for large extrapolation errors + break; } Int_t iMinNofHits = -1; @@ -110,14 +123,14 @@ void ini_trks(Int_t iSel = 910041, Int_t iTrackingSetup = 4, Int_t iGenCor = 1, tofFindTracks->SetStation(0, 5, 0, 0); // Diamond break; - case 1: // for calibration mode of full setup + case 1: // for calibration mode of full mTof setup { Double_t dTsig = dScalFac * 0.03; tofFindTracks->SetSIGT(dTsig); // allow for variable deviations in ns } - iMinNofHits = 3; - iNStations = 30; - iNReqStations = 4; + iMinNofHits = 4; + iNStations = 39; + iNReqStations = 5; tofFindTracks->SetStation(0, 5, 0, 0); tofFindTracks->SetStation(1, 0, 2, 2); tofFindTracks->SetStation(2, 0, 1, 2); @@ -145,22 +158,24 @@ void ini_trks(Int_t iSel = 910041, Int_t iTrackingSetup = 4, Int_t iGenCor = 1, tofFindTracks->SetStation(24, 0, 4, 4); tofFindTracks->SetStation(25, 0, 3, 4); tofFindTracks->SetStation(26, 9, 0, 0); - tofFindTracks->SetStation(27, 9, 1, 0); + tofFindTracks->SetStation(27, 7, 0, 0); tofFindTracks->SetStation(28, 9, 0, 1); - tofFindTracks->SetStation(29, 9, 1, 1); - //tofFindTracks->SetStation(28, 6, 0, 0); - //tofFindTracks->SetStation(29, 6, 0, 1); + tofFindTracks->SetStation(29, 7, 0, 1); + tofFindTracks->SetStation(30, 6, 0, 0); + tofFindTracks->SetStation(31, 6, 0, 1); + tofFindTracks->SetStation(32, 2, 0, 0); + tofFindTracks->SetStation(33, 2, 0, 1); + tofFindTracks->SetStation(34, 2, 0, 2); + tofFindTracks->SetStation(35, 2, 0, 3); + tofFindTracks->SetStation(36, 2, 0, 4); + tofFindTracks->SetStation(37, 8, 0, 0); + tofFindTracks->SetStation(38, 8, 1, 0); break; case 10: // for calibration mode of full setup - { - Double_t dTsig = dScalFac * 0.03; - tofFindTracks->SetSIGT(dTsig); // allow for variable deviations in ns - } iMinNofHits = 3; - iNStations = 37; + iNStations = 39; iNReqStations = 4; - tofFindTracks->SetStation(36, 5, 0, 0); tofFindTracks->SetStation(0, 0, 2, 2); tofFindTracks->SetStation(1, 0, 1, 2); tofFindTracks->SetStation(2, 0, 0, 2); @@ -187,9 +202,9 @@ void ini_trks(Int_t iSel = 910041, Int_t iTrackingSetup = 4, Int_t iGenCor = 1, tofFindTracks->SetStation(23, 0, 4, 4); tofFindTracks->SetStation(24, 0, 3, 4); tofFindTracks->SetStation(25, 9, 0, 0); - tofFindTracks->SetStation(26, 9, 1, 0); + tofFindTracks->SetStation(26, 7, 0, 0); tofFindTracks->SetStation(27, 9, 0, 1); - tofFindTracks->SetStation(28, 9, 1, 1); + tofFindTracks->SetStation(28, 7, 0, 1); tofFindTracks->SetStation(29, 6, 0, 0); tofFindTracks->SetStation(30, 6, 0, 1); tofFindTracks->SetStation(31, 2, 0, 0); @@ -197,6 +212,9 @@ void ini_trks(Int_t iSel = 910041, Int_t iTrackingSetup = 4, Int_t iGenCor = 1, tofFindTracks->SetStation(33, 2, 0, 2); tofFindTracks->SetStation(34, 2, 0, 3); tofFindTracks->SetStation(35, 2, 0, 4); + tofFindTracks->SetStation(36, 8, 0, 0); + tofFindTracks->SetStation(37, 8, 1, 0); + tofFindTracks->SetStation(38, 5, 0, 0); break; case 11: // for calibration mode of 2-stack & test counters diff --git a/macro/beamtime/mcbm2021/init_cal_all.sh b/macro/beamtime/mcbm2021/init_cal_all.sh index 5b6ab2825c..ae8d78848e 100755 --- a/macro/beamtime/mcbm2021/init_cal_all.sh +++ b/macro/beamtime/mcbm2021/init_cal_all.sh @@ -38,13 +38,29 @@ if (( iCalSet<100000 )); then cCalSet="0000"$iCalSet fi echo cCalSet = $cCalSet + +iSel2=$3 +if [[ $iSel2 = "" ]]; then + iSel2=$iBRef +fi +iRestart=$4 +if [[ $iRestart = "" ]]; then + iRestart=1 # use copied calibration file with walk corrections +fi + + +iRestart=$4 +if [[ $iRestart = "" ]]; then + iRestart=1 # use copied calibration file with walk corrections +fi + #iSet=0 #lastOpt='' -nEvi0=100000 # start value965311965311 +nEvi0=1000000 # start value nEvi1=100000 # increment if [ -e /lustre ]; then -source /lustre/cbm/users/nh/CBM/cbmroot/trunk/build/config.sh +source /lustre/cbm/users/nh/CBM/cbmroot/trunk/build/config.sh -a wdir=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2021 outdir=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2021/${cRun} else @@ -61,7 +77,8 @@ cd ${cRun} # Global variables, for for-loops #iRestart=0 -iRestart=1 # use copied calibration file with walk corrections +#iRestart=1 # use copied calibration file with walk corrections +#iRestart=29 #iRestart=37 iStep=0 iStepLast=0 @@ -89,14 +106,14 @@ do done fi if [ $icallev -lt 7 ]; then - optList=`echo " $nEvi,$icallev$icalmod,$iCalSel0,$iBRef,50 "`$optList - optList=`echo " $nEvi,$icallev$icalmod,$iCalSel1,$iBRef,50 "`$optList + optList=`echo " $nEvi,$icallev$icalmod,$iCalSel0,$iBRef,30 "`$optList + optList=`echo " $nEvi,$icallev$icalmod,$iCalSel1,$iBRef,30 "`$optList else # optList=`echo " $nEvi,$icallev$icalmod,-2,2,0 "`$optList echo skip add options fi done - optList=`echo " $nEvi,0,0,$iBRef,50 "`$optList # start Init1 + optList=`echo " $nEvi,0,0,$iBRef,30 "`$optList # start Init1 echo optList: $optList for inOpt in $optList @@ -132,7 +149,7 @@ do lastOpt=$inOpt # generate new calibration file if (($iStep > $iRestart)) ; then - root -b -q '../../ana_digi_cal_all.C('$inOpt',"'${cRun}'",'${iCalSet}',0,'${iBRef}') ' + root -b -q '../../ana_digi_cal_all.C('$inOpt',"'${cRun}'",'${iCalSet}',0,'${iSel2}') ' cp -v tofClust_${cRun}_set${cCalSet}.hst.root ../${cRun}_set${cCalSet}_${cMode}_${cSel}tofClust.hst.root cp *pdf ../ diff --git a/macro/beamtime/mcbm2021/iter_tracks.sh b/macro/beamtime/mcbm2021/iter_tracks.sh index c3b35ef420..a63f85e3f4 100755 --- a/macro/beamtime/mcbm2021/iter_tracks.sh +++ b/macro/beamtime/mcbm2021/iter_tracks.sh @@ -43,6 +43,19 @@ if [[ $cCalId = "" ]]; then cCalId=$cRun; fi +cCalIdset=$5; +if [[ $cCalIdset = "" ]]; then + cCalIdset=${cSet:1:9}; +fi + +iTrkPar=$6 +if [[ $iTrkPar = "" ]]; then + #iTrkPar=0 # beam + #iTrkPar=1 # beam in limited acceptance (test counter in 2-stack) + iTrkPar=2 # cosmics + #iTrkPar=3 # July2021 acceptance of CRI -mTOF +fi + iMc=0 McId=${cRun:0:4} if [ "$McId" = "mcbm" ]; then @@ -50,17 +63,23 @@ if [ "$McId" = "mcbm" ]; then iMc=1 fi + # what should be done ? -iDut=900; iRef=41; iSel2=31 +#iDut=900; iRef=41; iSel2=31 +iDut=12; iRef=2; iSel2=2 # CRI setup, run 1588, July 2021 ((iSel=$iDut*1000+$iRef)) +iTrkPar=0 # beam +iTrkPar=1 # beam in limited acceptance (test counter in 2-stack) +#iTrkPar=2 # cosmics +nEvt=1000000 + -nEvt=100000 dDTres=2000 dDTRMSres=2000 iter=0; if [ -e /lustre/cbm ]; then -source /lustre/cbm/users/nh/CBM/cbmroot/trunk/build/config.sh +source /lustre/cbm/users/nh/CBM/cbmroot/trunk/build/config.sh -a wdir=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2021 outdir=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2021/${cRun} else @@ -73,7 +92,7 @@ fRange2=8. TRange2Limit=3.5 #frange1 limits DT spectrum range -fRange1=2. +fRange1=6. TRange1Limit=1.5 dDeadtime=50 @@ -85,7 +104,7 @@ cp ../.rootrc . cp ../rootlogon.C . # clean directory for start from scratch -rm -v ${cRun}_tofFindTracks.hst.root +#rm -v ${cRun}_tofFindTracks.hst.root rm -v TCalib.res if [[ $iter > 0 ]]; then @@ -108,7 +127,7 @@ fi #if((${fRange2}<$Range2Limit));then # ((fRange2=$Range2Limit)) #fi -fRange2=`echo "$fRange2 * 0.8" | bc` +fRange2=`echo "$fRange2 * 0.9" | bc` compare_TRange2=`echo "$fRange2 < $TRange2Limit" | bc` if [[ $compare_TRange2 > 0 ]]; then fRange2=$TRange2Limit @@ -119,7 +138,7 @@ fi #if((${fRange1}<1));then # ((fRange1=1)) #fi -fRange1=`echo "$fRange1 * 0.8" | bc` +fRange1=`echo "$fRange1 * 0.9" | bc` compare_TRange=`echo "$fRange1 < $TRange1Limit" | bc` if [[ $compare_TRange > 0 ]]; then fRange1=$TRange1Limit @@ -127,10 +146,11 @@ fi # correction modes: 2 - TOff from Tt, 3 - Pull t, 4 - x, 5 - y, 6 - z, >10 - Pull t of individual stations #for iCal in 3 2 10 11 12 13 14 15 4 5; do -for iCal in 2 3 4 5; do -#for iCal in 3 2 4; do +#for iCal in 3 4 5; do +for iCal in 3 2 4; do #for iCal in 3 2 ; do -#for iCal in 2 ; do +#for iCal in 3 ; do +#for iCal in 4 3 ; do # cosmic nIt=1 if [ $iter -eq 0 ] && [ $iMc -eq 1 ]; then echo skip iCal $iCal for MC calibration @@ -138,7 +158,7 @@ for iCal in 2 3 4 5; do fi while [[ $nIt > 0 ]]; do ((iter += 1)) - root -b -q '../ana_trks.C('$nEvt','$iSel','$iCal',"'$cRun'","'$cSet'",'$iSel2','$iTraSetup','$fRange1','$fRange2','$dDeadtime',"'$cCalId'",1,1,'$iCalSet',1,'$iMc')' + root -b -q '../ana_trks.C('$nEvt','$iSel','$iCal',"'$cRun'","'$cSet'",'$iSel2','$iTraSetup','$fRange1','$fRange2','$dDeadtime',"'$cCalId'",1,1,'$iCalSet',1,'$iTrkPar','$iMc')' cp -v tofFindTracks.hst.root ${cRun}_tofFindTracks.hst.root cp -v tofFindTracks.hst.root ${cRun}_tofFindTracks.hst${iter}.root cp -v tofAnaTestBeam.hst.root ${cRun}_TrkAnaTestBeam.hst.root @@ -152,9 +172,9 @@ if [[ $iTres = 0 ]]; then return fi -((TRMSres=$iTres%1000)) +((TRMSres=$iTres%10000)) ((iTres -= TRMSres )) -((Tres = iTres / 1000)) +((Tres = iTres / 10000)) if [[ $Tres = 0 ]]; then Tres=1 diff --git a/macro/beamtime/mcbm2021/pl_all_2D.C b/macro/beamtime/mcbm2021/pl_all_2D.C index ae799a4522..64b06faf78 100644 --- a/macro/beamtime/mcbm2021/pl_all_2D.C +++ b/macro/beamtime/mcbm2021/pl_all_2D.C @@ -1,14 +1,14 @@ /* Copyright (C) 2021 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt SPDX-License-Identifier: GPL-3.0-only - Authors: Florian Uhlig [committer] */ + Authors: Norbert Herrmann [committer] */ -void pl_all_2D(Int_t iOpt = 0, Int_t iNSt = 4) +void pl_all_2D(Int_t iOpt = 0, Int_t iNSt = 7) { // TCanvas *can = new TCanvas("can22","can22"); // can->Divide(2,2); // TCanvas *can = new TCanvas("can","can",48,55,700,900); - TCanvas* can = new TCanvas("can", "can", 48, 56, 900, 900); - can->Divide(5, 7, 0.01, 0.01); + TCanvas* can = new TCanvas("can", "can", 48, 56, 900, 1000); + can->Divide(5, 8, 0.01, 0.01); // can->Divide(2,2,0,0); Float_t lsize = 0.07; @@ -22,9 +22,9 @@ void pl_all_2D(Int_t iOpt = 0, Int_t iNSt = 4) TH2* h; TH2* h2; - const Int_t iType[6] = {0, 9, 6, 5, 7, 8}; - const Int_t iSmNum[6] = {5, 2, 1, 1, 1, 1}; - const Int_t iRpcNum[6] = {5, 2, 2, 1, 1, 8}; + const Int_t iType[7] = {0, 2, 9, 7, 6, 5, 8}; + const Int_t iSmNum[7] = {5, 1, 1, 1, 1, 1, 2}; + const Int_t iRpcNum[7] = {5, 5, 2, 2, 2, 1, 1}; TString cOpt; switch (iOpt) { @@ -40,6 +40,8 @@ void pl_all_2D(Int_t iOpt = 0, Int_t iNSt = 4) case 9: cOpt = "DelTOff"; break; case 10: cOpt = "DelMatPos"; break; case 11: cOpt = "DelMatTOff"; break; + case 12: cOpt = "rate"; break; + case 13: cOpt = "GloPos"; break; default:; } @@ -58,13 +60,14 @@ void pl_all_2D(Int_t iOpt = 0, Int_t iNSt = 4) TString hname = Form("cl_SmT%01d_sm%03d_rpc%03d_%s", iType[iSt], iSm, iRp, cOpt.Data()); h = (TH2*) gROOT->FindObjectAny(hname); if (h != NULL) { + cout << h->GetName() << " has " << h->GetEntries() << " entries " << endl; if (iOpt == 4 || iOpt == 5) { gPad->SetLogz(); } h->Draw("colz"); + if (iOpt == 7) { h->ProfileX()->Draw("same"); } } else { cout << "Histogram " << hname << " not existing. " << endl; } - if (iRp == 10) break; } } } diff --git a/macro/beamtime/mcbm2021/pl_all_Cal2D.C b/macro/beamtime/mcbm2021/pl_all_Cal2D.C new file mode 100644 index 0000000000..a5078d935a --- /dev/null +++ b/macro/beamtime/mcbm2021/pl_all_Cal2D.C @@ -0,0 +1,113 @@ +/* Copyright (C) 2021 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt + SPDX-License-Identifier: GPL-3.0-only + Authors: Florian Uhlig [committer] */ +void pl_all_Cal2D(Int_t iOpt = 1, Int_t iNSt = 7) +{ + // TCanvas *can = new TCanvas("can22","can22"); + // can->Divide(2,2); + // TCanvas *can = new TCanvas("can","can",48,55,700,900); + TCanvas* can = new TCanvas("can", "can", 48, 56, 900, 1100); + can->Divide(5, 8, 0.01, 0.01); + // can->Divide(2,2,0,0); + Float_t lsize = 0.07; + + gPad->SetFillColor(0); + gStyle->SetPalette(1); + gStyle->SetLabelSize(lsize); + + //gStyle->SetOptStat(kTRUE); + //gROOT->cd(); + //gROOT->SetDirLevel(2); + + TH2* h; + TH2* h2; + const Int_t iType[7] = {0, 2, 9, 7, 6, 5, 8}; + const Int_t iSmNum[7] = {5, 1, 1, 1, 1, 1, 2}; + const Int_t iRpcNum[7] = {5, 5, 2, 2, 2, 1, 1}; + + TString cOpt; + + switch (iOpt) { + case 0: cOpt = "Position"; break; + case 1: cOpt = "Pos"; break; + case 2: cOpt = "TOff"; break; + case 3: cOpt = "Tot"; break; + case 4: cOpt = "AvWalk"; break; + case 5: cOpt = "Walk"; break; + case 6: cOpt = "TofOff"; break; + case 7: cOpt = "Trms"; break; + case 8: cOpt = "DelPos"; break; + case 9: cOpt = "DelTOff"; break; + case 10: cOpt = "DelMatPos"; break; + case 11: cOpt = "DelMatTOff"; break; + default:; + } + + Int_t iDet = 0; + Double_t dAvMean = 0.; + Double_t dAvRMS = 0.; + Int_t iCanv = 0; + + for (Int_t iSt = 0; iSt < iNSt; iSt++) { + // cout << "plot station "<<iSt<<" with "<< iSmNum[iSt] <<" modules of "<<iRpcNum[iSt]<<" Rpcs each"<<endl; + for (Int_t iSm = 0; iSm < iSmNum[iSt]; iSm++) { + //cout << "plot module at station "<<iSt<<" with "<< iSmNum[iSt] <<" modules of "<<iRpcNum[iSt]<<" Rpcs each"<<endl; + for (Int_t iRp = 0; iRp < iRpcNum[iSt]; iRp++) { + //cout << "plot rpc at station "<<iSt<<" with "<< iSmNum[iSt] <<" modules of "<<iRpcNum[iSt]<<" Rpcs each"<<endl; + can->cd(iCanv + 1); + iCanv++; + gROOT->cd(); + TString hname = ""; + Int_t iCol = 1; + switch (iOpt) { + case 4: + for (Int_t iSide = 0; iSide < 2; iSide++) + for (Int_t iCh = 0; iCh < 32; iCh++) { + hname = Form("cal_SmT%01d_sm%03d_rpc%03d_Ch%03d_S%d_%s", iType[iSt], iSm, iRp, iCh, iSide, cOpt.Data()); + h = (TH2*) gROOT->FindObjectAny(hname); + if (h != NULL) { + TProfile* hProf = h->ProfileX(Form("%s_pfx%d%d", hname.Data(), iCh, iSide)); + hProf->SetLineColor(iCol); + hProf->SetLineStyle(1); + hProf->SetMarkerColor(iCol); + hProf->SetMarkerStyle(24 + iSide); + iCol++; + if (iCh == 0) iCol = 1; + if (iCh == 0 && iSide == 0) { + hProf->SetMaximum(0.4); + hProf->SetMinimum(-0.4); + hProf->GetXaxis()->SetRangeUser(0., 10.); + hProf->Draw("LP"); + } + else { + hProf->Draw("LPsame"); + } + } + } + break; + default: + hname = Form("cal_SmT%01d_sm%03d_rpc%03d_%s", iType[iSt], iSm, iRp, cOpt.Data()); + h = (TH2*) gROOT->FindObjectAny(hname); + if (h != NULL) { + if (iOpt == 2 || iOpt == 2) { gPad->SetLogz(); } + h->Draw("colz"); + h->ProfileX()->Draw("same"); + iDet++; + dAvMean += h->ProfileX()->GetMean(2); + dAvRMS += h->ProfileX()->GetRMS(2); + cout << "TrackQA " << cOpt.Data() << " for TSR " << iType[iSt] << iSm << iRp << ": Off " + << h->ProfileX()->GetMean(2) << ", RMS " << h->ProfileX()->GetRMS(2) << endl; + } + } + } + } + } + dAvMean /= (Double_t) iDet; + dAvRMS /= (Double_t) iDet; + cout << "TrackQA " << cOpt.Data() << ": AvOff " << dAvMean << ", AvRMS " << dAvRMS << endl; + dAvMean = TMath::Abs(dAvMean); + gROOT->ProcessLine(Form(".! echo %d > %sAvOff.res", (Int_t)(dAvMean * 1.E4), cOpt.Data())); + gROOT->ProcessLine(Form(".! echo %d > %sAvRMS.res", (Int_t)(dAvRMS * 1.E4), cOpt.Data())); + + can->SaveAs(Form("pl_all_Cal_%s.pdf", cOpt.Data())); +} diff --git a/macro/beamtime/mcbm2021/pl_all_CluRate.C b/macro/beamtime/mcbm2021/pl_all_CluRate.C index 312bfe4611..0a430671fd 100644 --- a/macro/beamtime/mcbm2021/pl_all_CluRate.C +++ b/macro/beamtime/mcbm2021/pl_all_CluRate.C @@ -2,7 +2,7 @@ SPDX-License-Identifier: GPL-3.0-only Authors: Florian Uhlig [committer] */ -void pl_all_CluRate(Int_t iNSt = 4, Int_t iOpt = 0, Double_t Tstart = 0., Double_t Tend = 800., Int_t iMode = 0) +void pl_all_CluRate(Int_t iNSt = 3, Int_t iOpt = 0, Double_t Tstart = 0., Double_t Tend = 800., Int_t iMode = 0) { // TCanvas *can = new TCanvas("can22","can22"); // can->Divide(2,2); @@ -11,6 +11,7 @@ void pl_all_CluRate(Int_t iNSt = 4, Int_t iOpt = 0, Double_t Tstart = 0., Double switch (iMode) { case 0: switch (iNSt) { + case 3: can->Divide(5, 7, 0.01, 0.01); break; case 6: can->Divide(5, 7, 0.01, 0.01); break; case 5: can->Divide(5, 6, 0.01, 0.01); break; default: can->Divide(5, 6, 0.01, 0.01); break; @@ -39,9 +40,9 @@ void pl_all_CluRate(Int_t iNSt = 4, Int_t iOpt = 0, Double_t Tstart = 0., Double TH1* h; TH2* h2; - const Int_t iType[6] = {0, 9, 5, 6, 7, 8}; + const Int_t iType[6] = {0, 2, 9, 6, 7, 8}; const Int_t iSmNum[6] = {5, 1, 1, 1, 1, 1}; - const Int_t iRpcNum[6] = {5, 2, 1, 2, 1, 8}; + const Int_t iRpcNum[6] = {5, 5, 2, 2, 1, 8}; Int_t iCanv = 0; Int_t iCol = 0; diff --git a/macro/beamtime/mcbm2021/pl_all_CluRateRatio.C b/macro/beamtime/mcbm2021/pl_all_CluRateRatio.C new file mode 100644 index 0000000000..53efc0b5c3 --- /dev/null +++ b/macro/beamtime/mcbm2021/pl_all_CluRateRatio.C @@ -0,0 +1,248 @@ +/* Copyright (C) 2020-2022 PI-UHd, GSI + SPDX-License-Identifier: GPL-3.0-only + Authors: Norbert Herrmann [committer] */ + +void pl_all_CluRateRatio(Int_t iRef = 500, Int_t iNSt = 3, Double_t Tstart = 0., Double_t Tend = 800., Int_t iMode = 0, + Int_t iOpt = 0, Double_t Ymax = 5E3, Double_t THR = 1.E5) +{ + // TCanvas *can = new TCanvas("can22","can22"); + // can->Divide(2,2); + // TCanvas *can = new TCanvas("can","can",48,55,700,900); + TCanvas* can = new TCanvas("can", "can", 48, 56, 900, 900); + + + can->Divide(1, 2, 0.01, 0.01); + + Float_t lsize = 0.06; + + gPad->SetFillColor(0); + gStyle->SetPalette(1); + gStyle->SetLabelSize(lsize); + + //gStyle->SetOptStat(kTRUE); + //gROOT->cd(); + //gROOT->SetDirLevel(2); + gStyle->SetPadLeftMargin(0.2); + gStyle->SetTitleOffset(1.3, "y"); + gStyle->SetOptStat(0); + + TH1* h; + TH1* hRef; + TH1* hRat; + TH1* hDis; + TH2* h2; + + const Int_t iTSR[11] = {500, 41, 31, 900, 901, 700, 701, 600, 601, 33, 43}; // March 2022 + const Double_t dArea[11] = {1., 864., 864., 864., 864., 1664., 1664., 172.8, 172.8, 864., 864.}; // March 2022 + + //const Int_t iTSR[11] = {500, 2, 12, 1, 11, 3, 11, 0, 10, 4, 14}; // July 2021 + //const Int_t iTSR[11] = {500, 41, 31, 900, 901, 910, 911, 600, 601, 33, 43}; // May 2021 + //const Int_t iPlot[11] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; + const Int_t iPlot[11] = {0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; + + //const Double_t dArea[11] = {1., 864., 864., 864., 756., 852., 852., 172.8, 172.8, 864., 864.}; // May + //const Double_t dArea[11] = {1., 432., 432., 432., 432., 426., 426., 172.8, 172.8, 432., 432.}; // Jul + const Double_t dDist[11] = {1., 353., 532.5, 386., 416., 416., 445., 478., 485., 353., 543.}; + + Int_t iCanv = 0; + // if (h!=NULL) h->Delete(); + TString hname; + gROOT->LoadMacro("shift_hst.C"); + + can->cd(1); + + Int_t iRp = iRef % 10; + Int_t iSmType = (iRef - iRp) / 10; + Int_t iSm = iSmType % 10; + iSmType = (iSmType - iSm) / 10; + Int_t IndRef = 0; + for (IndRef = 0; IndRef < 11; IndRef++) + if (iTSR[IndRef] == iRef) break; + cout << "Reference counter " << iRef << " found at index " << IndRef << endl; + + gROOT->cd(); + switch (iMode) { + case 0: hname = Form("cl_SmT%01d_sm%03d_rpc%03d_rate", iSmType, iSm, iRp); break; + case 1: hname = Form("cl_SmT%01d_sm%03d_rpc%03d_rate10s", iSmType, iSm, iRp); break; + case 2: hname = Form("cl_SmT%01d_sm%03d_rpc%03d_digirate", iSmType, iSm, iRp); break; + } + h = (TH1*) gROOT->FindObjectAny(hname); + if (h != NULL) { + hRef = (TH1*) h->Clone(); + switch (iOpt) { + case 10: + case 0: //rate + hRef->Add(h, hRef, 0., 1.); + // hRef->SetMaximum(1.E5); + gPad->SetLogy(); + break; + case 1: //rate/area + { + hRef->Add(h, hRef, 0., 1. / dArea[IndRef]); + hRef->SetMaximum(Ymax); + hRef->GetYaxis()->SetTitle("Flux (Hz/cm^{2})"); + //ScaleXaxis(hRef,ScaleX); //shift to align times + TH1* hRefFlux = (TH1*) hRef; //->Clone(); + cout << "New RefFlux histo: " << hRefFlux->GetName() << endl; + hRefFlux->SetName("hRefFlux"); + } break; + case 2: //flux=rate/area*dist**2 + hRef->Add(h, hRef, 0., dDist[IndRef] * dDist[IndRef] / dArea[IndRef]); + break; + } + hRef->GetXaxis()->SetRangeUser(Tstart, Tend); + hRef->Draw("histE"); + hRef->Sumw2(); + Double_t RateMax = hRef->GetMaximum(); + TH1F* hRefRate = + new TH1F("hRefRate", Form("Rate distribution; %s", hRef->GetYaxis()->GetTitle()), 100, 0., RateMax); + for (Int_t iBin = hRef->FindBin(Tstart); iBin < hRef->FindBin(Tend); iBin++) + hRefRate->Fill(hRef->GetBinContent(iBin)); + //hRefRate->Sumw2(); + Double_t RateAv = hRefRate->GetMean(1); + Double_t RateRMS = hRefRate->GetStdDev(1); + cout << "Reference counter average rate " << RateAv << ", RMS " << RateRMS << endl; + gStyle->SetOptStat(1111); + TCanvas* can2 = new TCanvas("can2", "can2", 1400, 56, 500, 500); + can2->cd(1); + hRefRate->Draw("histE"); + hRefRate->UseCurrentStyle(); + gPad->Update(); + } + + can->cd(1); + Int_t iCol = 0; + for (Int_t iSt = 0; iSt < iNSt; iSt++) { + iCol++; + if (iCol == 5 || iCol == 10) iCol++; // skip yellow + if (iPlot[iSt] == 0) continue; + + iRp = iTSR[iSt] % 10; + iSmType = (iTSR[iSt] - iRp) / 10; + iSm = iSmType % 10; + iSmType = (iSmType - iSm) / 10; + + gROOT->cd(); + switch (iMode) { + case 0: hname = Form("cl_SmT%01d_sm%03d_rpc%03d_rate", iSmType, iSm, iRp); break; + case 1: hname = Form("cl_SmT%01d_sm%03d_rpc%03d_rate10s", iSmType, iSm, iRp); break; + case 2: hname = Form("cl_SmT%01d_sm%03d_rpc%03d_digirate", iSmType, iSm, iRp); break; + } + h = (TH1*) gROOT->FindObjectAny(hname); + if (h != NULL) { + hDis = (TH1*) h->Clone(); + hDis->SetName(Form("hDis_%d", iTSR[iSt])); + switch (iOpt) { + case 10: + case 0: //rate + hDis->Add(h, hDis, 0., 1.); + break; + case 1: //rate/area + { + cout << "Scale station " << iSt << " by " << 1. / dArea[iSt] << endl; + hDis->Add(h, hDis, 0., 1. / dArea[iSt]); + hDis->GetYaxis()->SetTitle("Flux (Hz/cm^{2})"); + //ScaleXaxis(hDis,ScaleX); // shift in x - direction, need shift_hst.C to be loaded + TH1* hFlux = (TH1*) hDis->Clone(); + hFlux->SetName(Form("hFlux_%d", iTSR[iSt])); + } break; + case 2: //flux=rate/area*dist**2 + hDis->Add(h, hDis, 0., dDist[iSt] * dDist[iSt] / dArea[iSt]); + break; + } + + hDis->Draw("samehistE"); + hDis->SetLineColor(iCol); + //h->UseCurrentStyle(); + //gPad->SetLogy(); + } + else { + cout << "Histogram " << hname << " not existing. " << endl; + } + } + + // determine and plot ratios + can->cd(2); + iCol = 0; + Bool_t bIniPlot = kFALSE; + TLegend* leg = new TLegend(0.25, 0.7, 0.35, 0.95); + leg->SetTextSize(0.03); + for (Int_t iSt = 0; iSt < iNSt; iSt++) { + iCol++; + if (iCol == 5 || iCol == 10) iCol++; // skip yellow + if (iPlot[iSt] == 0) continue; + iRp = iTSR[iSt] % 10; + iSmType = (iTSR[iSt] - iRp) / 10; + iSm = iSmType % 10; + iSmType = (iSmType - iSm) / 10; + + gROOT->cd(); + switch (iMode) { + case 0: hname = Form("cl_SmT%01d_sm%03d_rpc%03d_rate", iSmType, iSm, iRp); break; + case 1: hname = Form("cl_SmT%01d_sm%03d_rpc%03d_rate10s", iSmType, iSm, iRp); break; + case 2: hname = Form("cl_SmT%01d_sm%03d_rpc%03d_digirate", iSmType, iSm, iRp); break; + } + h = (TH1*) gROOT->FindObjectAny(hname); + if (h != NULL) { + hRat = (TH1*) h->Clone(); + h->Sumw2(); + hRat->SetName(Form("hRat_%d", iTSR[iSt])); + hRat->SetTitle("ratio"); + hRat->GetYaxis()->SetTitle("ratio"); + leg->AddEntry(hRat, Form("%d", iTSR[iSt]), "l"); + switch (iOpt) { + case 0: //rate + hRat->Divide(h, hRef, 1., 1., "B"); + break; + case 1: //rate/area + h = (TH1*) gROOT->FindObjectAny(Form("hFlux_%d", iTSR[iSt])); + hRef = (TH1*) gROOT->FindObjectAny(Form("hRefFlux")); + hRat->Divide(h, hRef, 1., 1., "B"); + //hRat->Divide(h, hRef, 1. / dArea[iSt], 1. / dArea[IndRef], "B"); + break; + case 2: //flux=rate/area*dist**2 + hRat->Divide(h, hRef, dDist[iSt] * dDist[iSt] / dArea[iSt], dDist[IndRef] * dDist[IndRef] / dArea[IndRef], + "B"); + break; + case 10: { + Double_t dVal = 0.; + Double_t dErr = 0.; + for (Int_t iBin = 0; iBin < h->GetNbinsX(); iBin++) { + if (iBin < 100) + cout << "h " << h->GetName() << " bin " << iBin << ", cts " << hRef->GetBinContent(iBin + 1) << ", val " + << dVal << endl; + if (hRef->GetBinContent(iBin + 1) > THR) { + dVal = h->GetBinContent(iBin + 1) / hRef->GetBinContent(iBin + 1); + dErr = TMath::Sqrt(TMath::Power(h->GetBinContent(iBin + 1), -0.5) + + TMath::Power(hRef->GetBinContent(iBin + 1), -0.5)) + * dVal; + } + else { + dErr = 0.; + } + hRat->SetBinContent(iBin + 1, dVal); + hRat->SetBinError(iBin + 1, dErr); + } + } break; + } + if (!bIniPlot) { + bIniPlot = kTRUE; + hRat->SetMinimum(1.E-2); + hRat->SetMaximum(2.); + hRat->Draw("L E"); + hRat->GetXaxis()->SetRangeUser(Tstart, Tend); + } + else + hRat->Draw("L E SAME"); + + hRat->SetLineColor(iCol); + //h->UseCurrentStyle(); + //gPad->SetLogy(); + } + else { + cout << "Histogram " << hname << " not existing. " << endl; + } + leg->Draw(); + } + can->SaveAs(Form("pl_all_CluRateRatio.pdf")); +} diff --git a/macro/beamtime/mcbm2021/pl_all_DTLastHits.C b/macro/beamtime/mcbm2021/pl_all_DTLastHits.C index 1cd579cd90..e32090f089 100644 --- a/macro/beamtime/mcbm2021/pl_all_DTLastHits.C +++ b/macro/beamtime/mcbm2021/pl_all_DTLastHits.C @@ -22,10 +22,9 @@ void pl_all_DTLastHits(Int_t iNSt = 6, Double_t Tstart = 1., Double_t Tend = 100 TH1* h; TH2* h2; - const Int_t iType[6] = {0, 9, 7, 5, 6, 8}; - const Int_t iSmNum[6] = {5, 1, 1, 1, 1, 0}; - const Int_t iRpcNum[6] = {5, 2, 1, 1, 2, 8}; - + const Int_t iType[6] = {0, 2, 9, 6, 5, 8}; + const Int_t iSmNum[6] = {5, 1, 2, 1, 1, 0}; + const Int_t iRpcNum[6] = {5, 5, 2, 2, 1, 8}; Int_t iCanv = 0; // if (h!=NULL) h->Delete(); diff --git a/macro/beamtime/mcbm2021/pl_all_DigiCor.C b/macro/beamtime/mcbm2021/pl_all_DigiCor.C index c9194d5edc..7cd9344588 100644 --- a/macro/beamtime/mcbm2021/pl_all_DigiCor.C +++ b/macro/beamtime/mcbm2021/pl_all_DigiCor.C @@ -1,8 +1,8 @@ -/* Copyright (C) 2021 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt +/* Copyright (C) 2016-2018 PI-UHd, GSI SPDX-License-Identifier: GPL-3.0-only - Authors: Florian Uhlig [committer] */ + Authors: Norbert Herrmann [committer] */ -void pl_all_DigiCor(Int_t iNDet = 4) +void pl_all_DigiCor(Int_t iNDet = 7) { // TCanvas *can = new TCanvas("can22","can22"); // can->Divide(2,2); @@ -10,7 +10,7 @@ void pl_all_DigiCor(Int_t iNDet = 4) //TCanvas *can = new TCanvas("can","can",48,56,900,700); //can->Divide(4,4,0.01,0.01); // can->Divide(2,3,0.01,0.01); - can->Divide(5, 7, 0.01, 0.01); + can->Divide(5, 8, 0.01, 0.01); Float_t lsize = 0.07; gPad->SetFillColor(0); @@ -23,9 +23,9 @@ void pl_all_DigiCor(Int_t iNDet = 4) TH1* h; TH2* h2; - const Int_t iType[6] = {0, 9, 6, 5, 7, 8}; - const Int_t iSmNum[6] = {5, 2, 1, 1, 1, 1}; - const Int_t iRpcNum[6] = {5, 2, 2, 1, 2, 8}; + const Int_t iType[7] = {0, 2, 9, 7, 6, 5, 8}; + const Int_t iSmNum[7] = {5, 1, 1, 1, 1, 1, 2}; + const Int_t iRpcNum[7] = {5, 5, 2, 2, 2, 1, 1}; Int_t iCanv = 0; // if (h!=NULL) h->Delete(); @@ -40,7 +40,7 @@ void pl_all_DigiCor(Int_t iNDet = 4) h2 = (TH2*) gROOT->FindObjectAny(hname); if (h2 != NULL) { h2->Draw("colz"); - // gPad->SetLogy(); + gPad->SetLogz(); } else { cout << "Histogram " << hname << " not existing. " << endl; diff --git a/macro/beamtime/mcbm2021/pl_all_DigiDTLD.C b/macro/beamtime/mcbm2021/pl_all_DigiDTLD.C index c4b4343332..24b930f157 100644 --- a/macro/beamtime/mcbm2021/pl_all_DigiDTLD.C +++ b/macro/beamtime/mcbm2021/pl_all_DigiDTLD.C @@ -2,7 +2,7 @@ SPDX-License-Identifier: GPL-3.0-only Authors: Florian Uhlig [committer] */ -void pl_all_DigiDTLD(Int_t iNDet = 4, Double_t dDTthr = 2., Int_t iOpt = 0) +void pl_all_DigiDTLD(Int_t iNDet = 7, Double_t dDTthr = 2., Int_t iOpt = 0) { // TCanvas *can = new TCanvas("can22","can22"); // can->Divide(2,2); @@ -10,7 +10,7 @@ void pl_all_DigiDTLD(Int_t iNDet = 4, Double_t dDTthr = 2., Int_t iOpt = 0) //TCanvas *can = new TCanvas("can","can",48,56,900,700); //can->Divide(4,4,0.01,0.01); // can->Divide(2,3,0.01,0.01); - can->Divide(5, 7, 0.01, 0.01); + can->Divide(5, 8, 0.01, 0.01); Float_t lsize = 0.07; gPad->SetFillColor(0); @@ -25,10 +25,9 @@ void pl_all_DigiDTLD(Int_t iNDet = 4, Double_t dDTthr = 2., Int_t iOpt = 0) TH2* h2; TH1* hTime; TString hnameT; - - const Int_t iType[6] = {0, 9, 6, 5, 7, 8}; - const Int_t iSmNum[6] = {5, 2, 1, 1, 1, 1}; - const Int_t iRpcNum[6] = {5, 2, 2, 1, 1, 8}; + const Int_t iType[7] = {0, 2, 9, 7, 6, 5, 8}; + const Int_t iSmNum[7] = {5, 1, 1, 1, 1, 1, 2}; + const Int_t iRpcNum[7] = {5, 5, 2, 2, 2, 1, 1}; Double_t dTime = 0.; Int_t iCanv = 0; diff --git a/macro/beamtime/mcbm2021/pl_all_DigiMul.C b/macro/beamtime/mcbm2021/pl_all_DigiMul.C index 6be075ee2c..18ddcbbd80 100644 --- a/macro/beamtime/mcbm2021/pl_all_DigiMul.C +++ b/macro/beamtime/mcbm2021/pl_all_DigiMul.C @@ -2,7 +2,7 @@ SPDX-License-Identifier: GPL-3.0-only Authors: Florian Uhlig [committer] */ -void pl_all_DigiMul(Int_t iNDet = 4, Double_t dDTthr = 2., Int_t iOpt = 0) +void pl_all_DigiMul(Int_t iNDet = 7, Double_t dDTthr = 2., Int_t iOpt = 0) { // TCanvas *can = new TCanvas("can22","can22"); // can->Divide(2,2); @@ -10,7 +10,7 @@ void pl_all_DigiMul(Int_t iNDet = 4, Double_t dDTthr = 2., Int_t iOpt = 0) //TCanvas *can = new TCanvas("can","can",48,56,900,700); //can->Divide(4,4,0.01,0.01); // can->Divide(2,3,0.01,0.01); - can->Divide(5, 7, 0.01, 0.01); + can->Divide(5, 8, 0.01, 0.01); Float_t lsize = 0.07; gPad->SetFillColor(0); @@ -25,10 +25,9 @@ void pl_all_DigiMul(Int_t iNDet = 4, Double_t dDTthr = 2., Int_t iOpt = 0) TH2* h2; TH1* hTime; TString hnameT; - - const Int_t iType[6] = {0, 9, 6, 5, 7, 8}; - const Int_t iSmNum[6] = {5, 2, 1, 1, 1, 1}; - const Int_t iRpcNum[6] = {5, 2, 2, 1, 1, 8}; + const Int_t iType[7] = {0, 2, 9, 7, 6, 5, 8}; + const Int_t iSmNum[7] = {5, 1, 1, 1, 1, 1, 2}; + const Int_t iRpcNum[7] = {5, 5, 2, 2, 2, 1, 1}; Double_t dTime = 0.; Int_t iCanv = 0; diff --git a/macro/beamtime/mcbm2021/pl_all_DigiTot.C b/macro/beamtime/mcbm2021/pl_all_DigiTot.C index 0291daf019..034c67f540 100644 --- a/macro/beamtime/mcbm2021/pl_all_DigiTot.C +++ b/macro/beamtime/mcbm2021/pl_all_DigiTot.C @@ -2,7 +2,7 @@ SPDX-License-Identifier: GPL-3.0-only Authors: Florian Uhlig [committer] */ -void pl_all_DigiTot(Int_t iNDet = 4) +void pl_all_DigiTot(Int_t iNDet = 7) { // TCanvas *can = new TCanvas("can22","can22"); // can->Divide(2,2); @@ -10,7 +10,7 @@ void pl_all_DigiTot(Int_t iNDet = 4) //TCanvas *can = new TCanvas("can","can",48,56,900,700); //can->Divide(4,4,0.01,0.01); // can->Divide(2,3,0.01,0.01); - can->Divide(5, 7, 0.01, 0.01); + can->Divide(5, 8, 0.01, 0.01); Float_t lsize = 0.07; gPad->SetFillColor(0); @@ -23,9 +23,10 @@ void pl_all_DigiTot(Int_t iNDet = 4) TH1* h; TH2* h2; - Int_t iType[6] = {0, 9, 6, 5, 9, 8}; - Int_t iNumSm[6] = {5, 2, 1, 1, 3, 2}; - Int_t iNumRpc[6] = {5, 2, 2, 1, 2, 1}; + const Int_t iType[7] = {0, 2, 9, 7, 6, 5, 8}; + const Int_t iSmNum[7] = {5, 1, 1, 1, 1, 1, 2}; + const Int_t iRpcNum[7] = {5, 5, 2, 2, 2, 1, 1}; + Int_t iCanv = 0; // if (h!=NULL) h->Delete(); diff --git a/macro/beamtime/mcbm2021/pl_all_Sel2D.C b/macro/beamtime/mcbm2021/pl_all_Sel2D.C index 59f66fef94..8849e83f6f 100644 --- a/macro/beamtime/mcbm2021/pl_all_Sel2D.C +++ b/macro/beamtime/mcbm2021/pl_all_Sel2D.C @@ -1,14 +1,14 @@ -/* Copyright (C) 2021 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt +/* Copyright (C) 2021-2022 PI-UHd, GSI SPDX-License-Identifier: GPL-3.0-only - Authors: Florian Uhlig [committer] */ + Authors: Norbert Herrmann [committer] */ -void pl_all_Sel2D(Int_t iOpt = 0, Int_t iSel = 0, Int_t iOpt2 = 0, Int_t iNSt = 4) +void pl_all_Sel2D(Int_t iOpt = 0, Int_t iSel = 0, Int_t iOpt2 = 0, Int_t iNSt = 7) { // TCanvas *can = new TCanvas("can22","can22"); // can->Divide(2,2); // TCanvas *can = new TCanvas("can","can",48,55,700,900); TCanvas* can = new TCanvas("can", "can", 48, 56, 900, 900); - can->Divide(5, 7, 0.01, 0.01); + can->Divide(5, 8, 0.01, 0.01); // can->Divide(2,2,0,0); Float_t lsize = 0.07; @@ -23,9 +23,10 @@ void pl_all_Sel2D(Int_t iOpt = 0, Int_t iSel = 0, Int_t iOpt2 = 0, Int_t iNSt = TH1* hp; TH2* h; TH2* h2; - const Int_t iType[6] = {0, 9, 6, 5, 6, 8}; - const Int_t iSmNum[6] = {5, 2, 1, 1, 1, 1}; - const Int_t iRpcNum[6] = {5, 2, 2, 1, 2, 8}; + const Int_t iType[7] = {0, 2, 9, 7, 6, 5, 8}; + const Int_t iSmNum[7] = {5, 1, 1, 1, 1, 1, 2}; + const Int_t iRpcNum[7] = {5, 5, 2, 2, 2, 1, 1}; + TString cOpt; switch (iOpt) { @@ -37,6 +38,7 @@ void pl_all_Sel2D(Int_t iOpt = 0, Int_t iSel = 0, Int_t iOpt2 = 0, Int_t iNSt = case 5: cOpt = "DelTof"; break; case 6: cOpt = "dXdY"; break; case 7: cOpt = "TofOff"; break; + case 7: cOpt = "QASY"; break; default:; } @@ -61,7 +63,7 @@ void pl_all_Sel2D(Int_t iOpt = 0, Int_t iSel = 0, Int_t iOpt2 = 0, Int_t iNSt = h = (TH2*) gROOT->FindObjectAny(hname); if (h != NULL) { h->Draw("colz"); - gPad->SetLogz(); + //gPad->SetLogz(); if (iOpt2 > 0) switch (iOpt) { case 6: { diff --git a/macro/beamtime/mcbm2021/pl_all_Track2D.C b/macro/beamtime/mcbm2021/pl_all_Track2D.C index 863083b5ac..771017114d 100644 --- a/macro/beamtime/mcbm2021/pl_all_Track2D.C +++ b/macro/beamtime/mcbm2021/pl_all_Track2D.C @@ -1,14 +1,13 @@ /* Copyright (C) 2021 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt SPDX-License-Identifier: GPL-3.0-only Authors: Florian Uhlig [committer] */ - -void pl_all_Track2D(Int_t iOpt = 1, Int_t iNSt = 4) +void pl_all_Track2D(Int_t iOpt = 1, Int_t iNSt = 7) { // TCanvas *can = new TCanvas("can22","can22"); // can->Divide(2,2); // TCanvas *can = new TCanvas("can","can",48,55,700,900); - TCanvas* can = new TCanvas("can", "can", 48, 56, 900, 900); - can->Divide(5, 7, 0.01, 0.01); + TCanvas* can = new TCanvas("can", "can", 48, 56, 900, 1100); + can->Divide(5, 8, 0.01, 0.01); // can->Divide(2,2,0,0); Float_t lsize = 0.07; @@ -22,9 +21,9 @@ void pl_all_Track2D(Int_t iOpt = 1, Int_t iNSt = 4) TH2* h; TH2* h2; - const Int_t iType[6] = {0, 9, 6, 5, 7, 8}; - const Int_t iSmNum[6] = {5, 2, 1, 1, 1, 1}; - const Int_t iRpcNum[6] = {5, 2, 2, 1, 1, 8}; + const Int_t iType[7] = {0, 2, 9, 7, 6, 5, 8}; + const Int_t iSmNum[7] = {5, 1, 1, 1, 1, 1, 2}; + const Int_t iRpcNum[7] = {5, 5, 2, 2, 1, 1, 1}; TString cOpt; switch (iOpt) { @@ -33,7 +32,7 @@ void pl_all_Track2D(Int_t iOpt = 1, Int_t iNSt = 4) case 2: cOpt = "TOff"; break; case 3: cOpt = "Tot"; break; case 4: cOpt = "Walk"; break; - case 5: cOpt = "Walk"; break; + case 5: cOpt = "TofOff"; break; case 6: cOpt = "Mul"; break; case 7: cOpt = "Trms"; break; case 8: cOpt = "DelPos"; break; @@ -95,8 +94,10 @@ void pl_all_Track2D(Int_t iOpt = 1, Int_t iNSt = 4) iDet++; dAvMean += h->ProfileX()->GetMean(2); dAvRMS += h->ProfileX()->GetRMS(2); + /* cout << "TrackQA " << cOpt.Data() << " for TSR " << iType[iSt] << iSm << iRp << ": Off " << h->ProfileX()->GetMean(2) << ", RMS " << h->ProfileX()->GetRMS(2) << endl; + */ } } } diff --git a/macro/beamtime/mcbm2021/run_reco_mcbm_digievent.C b/macro/beamtime/mcbm2021/run_reco_mcbm_digievent.C new file mode 100644 index 0000000000..663807f1db --- /dev/null +++ b/macro/beamtime/mcbm2021/run_reco_mcbm_digievent.C @@ -0,0 +1,434 @@ +/* Copyright (C) 2020-2021 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt + SPDX-License-Identifier: GPL-3.0-only + Authors: Volker Friese [committer], Dominik Smith */ + +/** @file run_reco.C + ** @author Volker Friese <v.friese@gsi.de> + ** @since 14 November 2020 + **/ + + +// --- Includes needed for IDE +#include <RtypesCore.h> +#if !defined(__CLING__) +#include "CbmBuildEventsFromTracksReal.h" +#include "CbmBuildEventsIdeal.h" +#include "CbmBuildEventsQa.h" +#include "CbmDefs.h" +#include "CbmFindPrimaryVertex.h" +#include "CbmKF.h" +#include "CbmL1.h" +#include "CbmL1StsTrackFinder.h" +#include "CbmLitFindGlobalTracks.h" +#include "CbmMCDataManager.h" +#include "CbmMatchRecoToMC.h" +#include "CbmMuchFindHitsGem.h" +#include "CbmMvdClusterfinder.h" +#include "CbmMvdHitfinder.h" +#include "CbmPVFinderKF.h" +#include "CbmPrimaryVertexFinder.h" +#include "CbmPsdHitProducer.h" +#include "CbmRecoSts.h" +#include "CbmRichHitProducer.h" +#include "CbmRichReconstruction.h" +#include "CbmSetup.h" +#include "CbmStsFindTracks.h" +#include "CbmStsFindTracksEvents.h" +#include "CbmStsTrackFinder.h" +#include "CbmTaskBuildRawEvents.h" +#include "CbmTofSimpClusterizer.h" +#include "CbmTrdClusterFinder.h" +#include "CbmTrdHitProducer.h" + +#include <FairFileSource.h> +#include <FairMonitor.h> +#include <FairParAsciiFileIo.h> +#include <FairParRootFileIo.h> +#include <FairRunAna.h> +#include <FairRuntimeDb.h> +#include <FairSystemInfo.h> + +#include <TStopwatch.h> +#endif + + +/** @brief Macro for CBM reconstruction + ** @author Volker Friese <v.friese@gsi.de> + ** @since 14 November 2020 + ** @param input Name of input file (w/o extension .raw.root) + ** @param nTimeSlices Number of time-slices to process + ** @param firstTimeSlice First time-slice (entry) to be processed + ** @param output Name of output file (w/o extension .rec.root) + ** @param sEvBuildRaw Option for raw event building + ** @param setup Name of predefined geometry setup + ** @param paramFile Parameter ROOT file (w/o extension .par.root) + ** @param debugWithMC Option to provide the trackfinder with MC information + ** + ** This macro performs event-by-event reconstruction from from the digis in DigiEvents. + ** It can be used for real data after unpacking, triggering and event building or + ** for simulated data after triggering and event building with macro/reco/reco_digi.C. + ** + ** The file names must be specified without extensions. The convention is + ** that the raw (input) file is [input].raw.root. ThecalMode output file + ** will be [input].rec.root if not specified by the user. The parameter file + ** has the extension .par.root. It is assumed to be [input].par.root if + ** not specified by the user. + ** + ** If no argument is specified, the input will be set to "test". This allows + ** to execute the macro chain (run_tra_file.C, run_digi.C and run_reco.C) + ** from the ROOT prompt without user intervention. + ** + **/ +void run_reco_mcbm_digievent(TString input = "", Int_t nTimeSlices = -1, Int_t firstTimeSlice = 0, TString output = "", + TString setup = "mcbm_beam_2021_09", TString paramFile = "reco_mcbm_params_") +{ + + // ======================================================================== + // Adjust this part according to your requirements + + // --- Logger settings ---------------------------------------------------- + TString logLevel = "INFO"; + TString logVerbosity = "VERYHIGH"; + // ------------------------------------------------------------------------ + + // ----- Environment -------------------------------------------------- + TString myName = "run_reco_digievent"; // this macro's name for screen output + TString srcDir = gSystem->Getenv("VMCWORKDIR"); // top source directory + // ------------------------------------------------------------------------ + if (input.IsNull()) input = "1588"; + TString runId = input(0, 4); + int iRunId = runId.Atoi(); + + TString DataPath = "./data/"; + //TString DataPath = "/home/nh/LUSTRE/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2021/data/"; + // extract run number + + int iEvtParSet = 0; // event definition parameter + switch (iEvtParSet) { + case 0: break; + default:; + } + + // ----- In- and output file names ------------------------------------ + TString rawFile = DataPath + input + ".digievents.root"; + if (output.IsNull()) output = input; + TString outFile = DataPath + output + Form(".ep%02d", iEvtParSet) + ".reco_event.root"; + TString monFile = DataPath + output + Form(".ep%02d", iEvtParSet) + ".moni_reco.root"; + if (paramFile.IsNull()) paramFile = input; + TString parFile = DataPath + paramFile + output + Form(".ep%02d", iEvtParSet) + ".root"; + std::cout << "Inputfile " << rawFile << std::endl; + std::cout << "Outfile " << outFile << std::endl; + std::cout << "Parfile " << parFile << std::endl; + + TString shcmd = "rm -v " + parFile; + gSystem->Exec(shcmd.Data()); + + // ----- Load the geometry setup ------------------------------------- + std::cout << std::endl; + std::cout << "-I- " << myName << ": Loading setup " << setup << std::endl; + CbmSetup* geo = CbmSetup::Instance(); + geo->LoadSetup(setup); + + if (kTRUE) { // get geometry including TGeoManager + TString TofGeo; + if (iRunId < 2106) { + TofGeo = "v21e_mcbm"; // e for carbon, f for iron, run#>2120 + } + else { + TofGeo = "v21f_mcbm"; // e for carbon, f for iron, run#>2120 + } + TString geoDir = gSystem->Getenv("VMCWORKDIR"); + TString geoFile = geoDir + "/geometry/tof/geofile_tof_" + TofGeo + ".root"; + LOG(info) << "geoFile for run " << iRunId << ": " << geoFile; + + TFile* fgeo = new TFile(geoFile); + TGeoManager* geoMan = (TGeoManager*) fgeo->Get("FAIRGeom"); + if (NULL == geoMan) { + cout << "<E> FAIRGeom not found in geoFile" << endl; + return; + } + } + // ------------------------------------------------------------------------ + + // ----- Some global switches ----------------------------------------- + Bool_t useMvd = kFALSE; // geo->IsActive(ECbmModuleId::kMvd); + Bool_t useSts = kFALSE; // geo->IsActive(ECbmModuleId::kSts); + Bool_t useRich = kFALSE; // geo->IsActive(ECbmModuleId::kRich); + Bool_t useMuch = kFALSE; // geo->IsActive(ECbmModuleId::kMuch); + Bool_t useTrd = kFALSE; // geo->IsActive(ECbmModuleId::kTrd); + Bool_t useTof = geo->IsActive(ECbmModuleId::kTof); + Bool_t usePsd = kFALSE; // geo->IsActive(ECbmModuleId::kPsd); + // ------------------------------------------------------------------------ + + // ----- Parameter files as input to the runtime database ------------- + std::cout << std::endl; + std::cout << "-I- " << myName << ": Defining parameter files " << std::endl; + TList* parFileList = new TList(); + TString geoTag; + + // - TRD digitisation parameters + if (CbmSetup::Instance()->GetGeoTag(ECbmModuleId::kTrd, geoTag)) { + const Char_t* npar[4] = {"asic", "digi", "gas", "gain"}; + TObjString* trdParFile(NULL); + for (Int_t i(0); i < 4; i++) { + trdParFile = new TObjString(srcDir + "/parameters/trd/trd_" + geoTag + "." + npar[i] + ".par"); + parFileList->Add(trdParFile); + std::cout << "-I- " << myName << ": Using parameter file " << trdParFile->GetString() << std::endl; + } + } + + // - TOF digitisation parameters + if (CbmSetup::Instance()->GetGeoTag(ECbmModuleId::kTof, geoTag)) { + TObjString* tofBdfFile = new TObjString(srcDir + "/parameters/tof/tof_" + geoTag + ".digibdf.par"); + parFileList->Add(tofBdfFile); + std::cout << "-I- " << myName << ": Using parameter file " << tofBdfFile->GetString() << std::endl; + } + // ------------------------------------------------------------------------ + + // In general, the following parts need not be touched + // ======================================================================== + + + // ----- Timer -------------------------------------------------------- + TStopwatch timer; + timer.Start(); + // ------------------------------------------------------------------------ + + + // ----- FairRunAna --------------------------------------------------- + FairRunAna* run = new FairRunAna(); + FairFileSource* inputSource = new FairFileSource(rawFile); + run->SetSource(inputSource); + run->SetOutputFile(outFile); + run->SetGenerateRunInfo(kTRUE); + FairMonitor::GetMonitor()->EnableMonitor(kTRUE, monFile); + // ------------------------------------------------------------------------ + + + // ----- Logger settings ---------------------------------------------- + FairLogger::GetLogger()->SetLogScreenLevel(logLevel.Data()); + FairLogger::GetLogger()->SetLogVerbosityLevel(logVerbosity.Data()); + // ------------------------------------------------------------------------ + + + // ---- Make Reco Events ---------------------------------------------- + // ---- This is required if the input is in DigiEvent format + auto makeEvents = std::make_unique<CbmTaskMakeRecoEvents>(); + LOG(info) << "-I- " << myName << ": Adding task " << makeEvents->GetName(); + run->AddTask(makeEvents.release()); + // ------------------------------------------------------------------------ + + + // ----- Local reconstruction in STS ---------------------------------- + if (useSts) { + //auto recoSts = std::make_unique<CbmRecoSts>(kCbmRecoEvent); + //std::cout << "-I- " << myName << ": Adding task " << recoSts->GetName(); + + CbmRecoSts* recoSts = new CbmRecoSts(); + recoSts->SetMode(kCbmRecoEvent); + + recoSts->SetTimeCutDigisAbs(20.0); // cluster finder: time cut in ns + recoSts->SetTimeCutClustersAbs(20.0); // hit finder: time cut in ns + + // Sensor params + CbmStsParSensor sensor6cm(CbmStsSensorClass::kDssdStereo); + sensor6cm.SetPar(0, 6.2092); // Extension in x + sensor6cm.SetPar(1, 6.2); // Extension in y + sensor6cm.SetPar(2, 0.03); // Extension in z + sensor6cm.SetPar(3, 5.9692); // Active size in y + sensor6cm.SetPar(4, 1024.); // Number of strips front side + sensor6cm.SetPar(5, 1024.); // Number of strips back side + sensor6cm.SetPar(6, 0.0058); // Strip pitch front side + sensor6cm.SetPar(7, 0.0058); // Strip pitch back side + sensor6cm.SetPar(8, 0.0); // Stereo angle front side + sensor6cm.SetPar(9, 7.5); // Stereo angle back side + + CbmStsParSensor sensor12cm(sensor6cm); // copy all parameters, change then only the y size + sensor12cm.SetPar(1, 12.4); // Extension in y + sensor12cm.SetPar(3, 12.1692); // Active size in y + + // --- Addresses for sensors + // --- They are defined in each station as sensor 1, module 1, halfladderD (2), ladder 1 + // Int_t GetAddress(UInt_t unit = 0, UInt_t ladder = 0, UInt_t halfladder = 0, UInt_t module = 0, UInt_t sensor = 0, + // UInt_t side = 0, UInt_t version = kCurrentVersion); + + Int_t stsAddress01 = CbmStsAddress::GetAddress(0, 0, 1, 0, 0, 0); // U0 L0 M0 6 cm + Int_t stsAddress02 = CbmStsAddress::GetAddress(0, 0, 1, 1, 0, 0); // U0 L0 M1 6 cm + Int_t stsAddress03 = CbmStsAddress::GetAddress(0, 1, 1, 0, 0, 0); // U0 L1 M0 6 cm + Int_t stsAddress04 = CbmStsAddress::GetAddress(0, 1, 1, 1, 0, 0); // U0 L1 M1 6 cm + Int_t stsAddress05 = CbmStsAddress::GetAddress(1, 0, 1, 0, 0, 0); // U1 L0 M0 6 cm + Int_t stsAddress06 = CbmStsAddress::GetAddress(1, 0, 1, 1, 0, 0); // U1 L0 M1 12 cm + Int_t stsAddress07 = CbmStsAddress::GetAddress(1, 1, 1, 0, 0, 0); // U1 L1 M0 6 cm + Int_t stsAddress08 = CbmStsAddress::GetAddress(1, 1, 1, 1, 0, 0); // U1 L1 M1 12 cm + Int_t stsAddress09 = CbmStsAddress::GetAddress(1, 2, 1, 0, 0, 0); // U1 L2 M0 6 cm + Int_t stsAddress10 = CbmStsAddress::GetAddress(1, 2, 1, 1, 0, 0); // U1 L2 M1 6 cm + Int_t stsAddress11 = CbmStsAddress::GetAddress(1, 2, 1, 2, 0, 0); // U1 L2 M2 6 cm + + + std::cout << "STS address01 " << std::dec << stsAddress01 << " " << std::hex << stsAddress01 << std::endl; + std::cout << "STS address02 " << std::dec << stsAddress02 << " " << std::hex << stsAddress02 << std::endl; + std::cout << "STS address03 " << std::dec << stsAddress03 << " " << std::hex << stsAddress03 << std::endl; + std::cout << "STS address04 " << std::dec << stsAddress04 << " " << std::hex << stsAddress04 << std::endl; + std::cout << "STS address05 " << std::dec << stsAddress05 << " " << std::hex << stsAddress05 << std::endl; + std::cout << "STS address06 " << std::dec << stsAddress06 << " " << std::hex << stsAddress06 << std::endl; + std::cout << "STS address07 " << std::dec << stsAddress07 << " " << std::hex << stsAddress07 << std::endl; + std::cout << "STS address08 " << std::dec << stsAddress08 << " " << std::hex << stsAddress08 << std::endl; + std::cout << "STS address09 " << std::dec << stsAddress09 << " " << std::hex << stsAddress09 << std::endl; + std::cout << "STS address10 " << std::dec << stsAddress10 << " " << std::hex << stsAddress10 << std::endl; + std::cout << "STS address11 " << std::dec << stsAddress11 << " " << std::hex << stsAddress11 << std::endl; + + // --- Now we can define the sensor parameter set and tell recoSts to use it + auto sensorParSet = new CbmStsParSetSensor("CbmStsParSetSensor", "STS sensor parameters" + "mcbm2021"); + sensorParSet->SetParSensor(stsAddress01, sensor6cm); + sensorParSet->SetParSensor(stsAddress02, sensor6cm); + sensorParSet->SetParSensor(stsAddress03, sensor6cm); + sensorParSet->SetParSensor(stsAddress04, sensor6cm); + sensorParSet->SetParSensor(stsAddress05, sensor6cm); + sensorParSet->SetParSensor(stsAddress06, sensor12cm); + sensorParSet->SetParSensor(stsAddress07, sensor6cm); + sensorParSet->SetParSensor(stsAddress08, sensor12cm); + sensorParSet->SetParSensor(stsAddress09, sensor6cm); + sensorParSet->SetParSensor(stsAddress10, sensor6cm); + sensorParSet->SetParSensor(stsAddress11, sensor6cm); + + recoSts->UseSensorParSet(sensorParSet); + + // ASIC params: #ADC channels, dyn. range, threshold, time resol., dead time, + // noise RMS, zero-threshold crossing rate + auto parAsic = new CbmStsParAsic(128, 32, 75000., 3000., 5., 800., 1000., 3.9789e-3); + + // Module params: number of channels, number of channels per ASIC + auto parMod = new CbmStsParModule(2048, 128); + parMod->SetAllAsics(*parAsic); + recoSts->UseModulePar(parMod); + + // Sensor conditions: full depletion voltage, bias voltage, temperature, + // coupling capacitance, inter-strip capacitance + auto sensorCond = new CbmStsParSensorCond(70., 140., 268., 17.5, 1.); + recoSts->UseSensorCond(sensorCond); + + + run->AddTask(recoSts); + //run->AddTask(recoSts.release()); + std::cout << "-I- : Added task " << recoSts->GetName() << std::endl; + } + // ------------------------------------------------------------------------ + + // ----- Local reconstruction in TOF ---------------------------------- + + if (useTof) { + /* + auto recoTof = std::make_unique<CbmRecoTof>(kCbmRecoEvent); + std::cout << "-I- " << myName << ": Adding task " << recoTof->GetName(); + run->AddTask(recoTof.release()); + */ + // ========================================================================= + // === Tof Hit Building === + // ========================================================================= + gROOT->LoadMacro("ini_Clusterizer.C"); + int calMode = 93; + int calSel = 1; + int calSm = 1; + int RefSel = 1; + TString cFileId = "1588.50.6.0.2"; + int iCalSet = 12002002; + bool bOut = kFALSE; + int iSel2 = -1; + double dDeadtime = 50.; + TString cCalId = "1588.50.6.0.2"; + Char_t* cCmd = Form("ini_Clusterizer(%d,%d,%d,%d,\"%s\",%d,%d,%d,%f,\"%s\")", calMode, calSel, calSm, RefSel, + cFileId.Data(), iCalSet, (Int_t) bOut, iSel2, dDeadtime, cCalId.Data()); + cout << "<I> " << cCmd << endl; + gInterpreter->ProcessLine(cCmd); + + // ========================================================================= + // === Tof Tracking === + // ========================================================================= + /* + int iSel=12002; + int iTrackingSetup=13; + int iGenCor=3; + double dScalFac=2.; + double dChi2Lim2=5.; + bool bUseSigCalib=kFALSE; + int iCalOpt=1; + int iTrkPar=3; + gROOT->LoadMacro("ini_trks.C"); + cCmd = Form("ini_trks(%d,%d,%d,%6.2f,%8.1f,\"%s\",%d,%d,%d)", iSel, iTrackingSetup, iGenCor, dScalFac, + dChi2Lim2, cCalId.Data(), (Int_t) bUseSigCalib, iCalOpt, iTrkPar); + cout << "<I> " << cCmd << endl; + gInterpreter->ProcessLine(cCmd); + + CbmTofFindTracks* tofFindTracks = CbmTofFindTracks::Instance(); + Int_t iNStations = tofFindTracks->GetNStations(); + */ + } + + // ------------------------------------------------------------------------ + + + // ----- Parameter database -------------------------------------------- + std::cout << std::endl << std::endl; + std::cout << "-I- " << myName << ": Set runtime DB" << std::endl; + FairRuntimeDb* rtdb = run->GetRuntimeDb(); + FairParRootFileIo* parIo1 = new FairParRootFileIo(); + FairParAsciiFileIo* parIo2 = new FairParAsciiFileIo(); + parIo1->open(parFile.Data(), "UPDATE"); + rtdb->setFirstInput(parIo1); + if (!parFileList->IsEmpty()) { + parIo2->open(parFileList, "in"); + rtdb->setSecondInput(parIo2); + } + // ------------------------------------------------------------------------ + + + // ----- Run initialisation ------------------------------------------- + std::cout << std::endl; + std::cout << "-I- " << myName << ": Initialise run" << std::endl; + run->Init(); + rtdb->setOutput(parIo1); + rtdb->saveOutput(); + rtdb->print(); + // ------------------------------------------------------------------------ + + + // ----- Start run ---------------------------------------------------- + std::cout << std::endl << std::endl; + std::cout << "-I- " << myName << ": Starting run" << std::endl; + run->Run(firstTimeSlice, nTimeSlices); + // ------------------------------------------------------------------------ + + // ----- Finish ------------------------------------------------------- + gROOT->LoadMacro("save_hst.C"); + TString cHstFile = "reco_mcbm_digievent." + input + ".hst.root"; + TString SaveToHstFile = "save_hst(\"" + cHstFile + "\")"; + gInterpreter->ProcessLine(SaveToHstFile); + + timer.Stop(); + FairMonitor::GetMonitor()->Print(); + Double_t rtime = timer.RealTime(); + Double_t ctime = timer.CpuTime(); + std::cout << std::endl << std::endl; + std::cout << "Macro finished successfully." << std::endl; + std::cout << "Output file is " << outFile << std::endl; + std::cout << "Parameter file is " << parFile << std::endl; + std::cout << "Real time " << rtime << " s, CPU time " << ctime << " s" << std::endl; + FairSystemInfo sysInfo; + Float_t maxMemory = sysInfo.GetMaxMemory(); + std::cout << "<DartMeasurement name=\"MaxMemory\" type=\"numeric/double\">"; + std::cout << maxMemory; + std::cout << "</DartMeasurement>" << std::endl; + Float_t cpuUsage = ctime / rtime; + std::cout << "<DartMeasurement name=\"CpuLoad\" type=\"numeric/double\">"; + std::cout << cpuUsage; + std::cout << "</DartMeasurement>" << std::endl; + // ------------------------------------------------------------------------ + + + // ----- This is to prevent a malloc error when exiting ROOT ---------- + // The source of the error is unknown. Related to TGeoManager. + //RemoveGeoManager(); + // ------------------------------------------------------------------------ + +} // End of main macro function diff --git a/macro/beamtime/mcbm2021/run_reco_mcbm_nh.C b/macro/beamtime/mcbm2021/run_reco_mcbm_nh.C new file mode 100644 index 0000000000..9154ba5301 --- /dev/null +++ b/macro/beamtime/mcbm2021/run_reco_mcbm_nh.C @@ -0,0 +1,322 @@ +/* Copyright (C) 2020-2021 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt + SPDX-License-Identifier: GPL-3.0-only + Authors: Volker Friese [committer], Dominik Smith */ + +/** @file run_reco.C + ** @author Volker Friese <v.friese@gsi.de> + ** @since 14 November 2020 + **/ + + +// --- Includes needed for IDE +#include <RtypesCore.h> +#if !defined(__CLING__) +#include "CbmBuildEventsFromTracksReal.h" +#include "CbmBuildEventsIdeal.h" +#include "CbmBuildEventsQa.h" +#include "CbmDefs.h" +#include "CbmEvbuildRawTask.h" +#include "CbmFindPrimaryVertex.h" +#include "CbmKF.h" +#include "CbmL1.h" +#include "CbmL1StsTrackFinder.h" +#include "CbmLitFindGlobalTracks.h" +#include "CbmMCDataManager.h" +#include "CbmMatchRecoToMC.h" +#include "CbmMuchFindHitsGem.h" +#include "CbmMvdClusterfinder.h" +#include "CbmMvdHitfinder.h" +#include "CbmPVFinderKF.h" +#include "CbmPrimaryVertexFinder.h" +#include "CbmPsdHitProducer.h" +#include "CbmRecoSts.h" +#include "CbmRichHitProducer.h" +#include "CbmRichReconstruction.h" +#include "CbmSetup.h" +#include "CbmStsFindTracks.h" +#include "CbmStsFindTracksEvents.h" +#include "CbmStsTrackFinder.h" +#include "CbmTaskBuildRawEvents.h" +#include "CbmTofSimpClusterizer.h" +#include "CbmTrdClusterFinder.h" +#include "CbmTrdHitProducer.h" + +#include <FairFileSource.h> +#include <FairMonitor.h> +#include <FairParAsciiFileIo.h> +#include <FairParRootFileIo.h> +#include <FairRunAna.h> +#include <FairRuntimeDb.h> +#include <FairSystemInfo.h> + +#include <TStopwatch.h> +#endif + + +/** @brief Macro for CBM reconstruction + ** @author Volker Friese <v.friese@gsi.de> + ** @since 14 November 2020 + ** @param input Name of input file (w/o extension .raw.root) + ** @param nTimeSlices Number of time-slices to process + ** @param firstTimeSlice First time-slice (entry) to be processed + ** @param output Name of output file (w/o extension .rec.root) + ** @param sEvBuildRaw Option for raw event building + ** @param setup Name of predefined geometry setup + ** @param paramFile Parameter ROOT file (w/o extension .par.root) + ** @param useMC Option to provide the trackfinder with MC information + ** + ** This macro performs from the digis in a time-slice. It can be used + ** for simulated data (result of run_digi.C) or real data after unpacking. + ** + ** The macro covers both time-based reconstruction and event-based + ** reconstruction using raw events build from digis. This can be selected + ** by the forth argument. If left empty, no raw event builder will be + ** employed and reconstruction will be time-based. The option "Ideal" + ** selects the ideal raw event builder, which associates digis to events + ** based on the MC truth. The option "Real" selects a real raw event builder + ** (latest version, for older versions use "Real2018" or "Real2019"). + ** + ** + ** The file names must be specified without extensions. The convention is + ** that the raw (input) file is [input].raw.root. The output file + ** will be [input].rec.root if not specified by the user. The parameter file + ** has the extension .par.root. It is assumed to be [input].par.root if + ** not specified by the user. + ** + ** If no argument is specified, the input will be set to "test". This allows + ** to execute the macro chain (run_tra_file.C, run_digi.C and run_reco.C) + ** from the ROOT prompt without user intervention. + ** + **/ +void run_reco_mcbm_nh(TString input = "data/1588_node8_1_0000", Int_t nTimeSlices = 1000, Int_t firstTimeSlice = 0, + TString output = "", TString sEvBuildRaw = "Real", TString setup = "mcbm_beam_2021_03", + TString paramFile = "", Bool_t useMC = false) +{ + + // ======================================================================== + // Adjust this part according to your requirements + + // --- Logger settings ---------------------------------------------------- + TString logLevel = "info"; + TString logVerbosity = "LOW"; + // ------------------------------------------------------------------------ + + // ----- Environment -------------------------------------------------- + TString myName = "run_reco"; // this macro's name for screen output + TString srcDir = gSystem->Getenv("VMCWORKDIR"); // top source directory + // ------------------------------------------------------------------------ + + + // ----- In- and output file names ------------------------------------ + if (input.IsNull()) input = "test"; + TString rawFile = input + ".digi.root"; + TString traFile = input + ".tra.root"; + if (output.IsNull()) output = input; + TString outFile = output + ".reco.root"; + TString monFile = output + ".moni_reco.root"; + if (paramFile.IsNull()) paramFile = input; + TString parFile = paramFile + ".par.root"; + std::cout << "Inputfile " << rawFile << std::endl; + std::cout << "Outfile " << outFile << std::endl; + std::cout << "Parfile " << parFile << std::endl; + + TString shcmd = "rm -v " + parFile; + gSystem->Exec(shcmd.Data()); + + // ----- Load the geometry setup ------------------------------------- + std::cout << std::endl; + std::cout << "-I- " << myName << ": Loading setup " << setup << std::endl; + CbmSetup* geo = CbmSetup::Instance(); + geo->LoadSetup(setup); + // ------------------------------------------------------------------------ + + + // ----- Some global switches ----------------------------------------- + Bool_t eventBased = !sEvBuildRaw.IsNull(); + Bool_t useMvd = geo->IsActive(ECbmModuleId::kMvd); + Bool_t useSts = geo->IsActive(ECbmModuleId::kSts); + Bool_t useRich = geo->IsActive(ECbmModuleId::kRich); + Bool_t useMuch = geo->IsActive(ECbmModuleId::kMuch); + Bool_t useTrd = geo->IsActive(ECbmModuleId::kTrd); + Bool_t useTof = geo->IsActive(ECbmModuleId::kTof); + Bool_t usePsd = geo->IsActive(ECbmModuleId::kPsd); + + useMvd = kFALSE; + useMuch = kFALSE; + useRich = kFALSE; + useTrd = kFALSE; + useTof = kFALSE; + usePsd = kFALSE; + // ------------------------------------------------------------------------ + + + // ----- Parameter files as input to the runtime database ------------- + std::cout << std::endl; + std::cout << "-I- " << myName << ": Defining parameter files " << std::endl; + TList* parFileList = new TList(); + TString geoTag; + + // - TRD digitisation parameters + if (CbmSetup::Instance()->GetGeoTag(ECbmModuleId::kTrd, geoTag)) { + const Char_t* npar[4] = {"asic", "digi", "gas", "gain"}; + TObjString* trdParFile(NULL); + for (Int_t i(0); i < 4; i++) { + trdParFile = new TObjString(srcDir + "/parameters/trd/trd_" + geoTag + "." + npar[i] + ".par"); + parFileList->Add(trdParFile); + std::cout << "-I- " << myName << ": Using parameter file " << trdParFile->GetString() << std::endl; + } + } + + // - TOF digitisation parameters + if (CbmSetup::Instance()->GetGeoTag(ECbmModuleId::kTof, geoTag)) { + TObjString* tofBdfFile = new TObjString(srcDir + "/parameters/tof/tof_" + geoTag + ".digibdf.par"); + parFileList->Add(tofBdfFile); + std::cout << "-I- " << myName << ": Using parameter file " << tofBdfFile->GetString() << std::endl; + } + // ------------------------------------------------------------------------ + + // In general, the following parts need not be touched + // ======================================================================== + + + // ----- Timer -------------------------------------------------------- + TStopwatch timer; + timer.Start(); + // ------------------------------------------------------------------------ + + + // ----- FairRunAna --------------------------------------------------- + FairRunAna* run = new FairRunAna(); + FairFileSource* inputSource = new FairFileSource(rawFile); + if (useMC) { inputSource->AddFriend(traFile); } + run->SetSource(inputSource); + run->SetOutputFile(outFile); + run->SetGenerateRunInfo(kTRUE); + FairMonitor::GetMonitor()->EnableMonitor(kTRUE, monFile); + // ------------------------------------------------------------------------ + + // ----- MCDataManager ----------------------------------- + if (useMC) { + CbmMCDataManager* mcManager = new CbmMCDataManager("MCDataManager", 0); + mcManager->AddFile(traFile); + run->AddTask(mcManager); + } + // ------------------------------------------------------------------------ + + // ----- Logger settings ---------------------------------------------- + FairLogger::GetLogger()->SetLogScreenLevel(logLevel.Data()); + FairLogger::GetLogger()->SetLogVerbosityLevel(logVerbosity.Data()); + // ------------------------------------------------------------------------ + + + // ----- Raw event building from digis -------------------------------- + if (eventBased) { + if (sEvBuildRaw.EqualTo("Ideal", TString::ECaseCompare::kIgnoreCase)) { + FairTask* evBuildRaw = new CbmBuildEventsIdeal(); + run->AddTask(evBuildRaw); + std::cout << "-I- " << myName << ": Added task " << evBuildRaw->GetName() << std::endl; + eventBased = kTRUE; + } //? Ideal raw event building + else if (sEvBuildRaw.EqualTo("Real", TString::ECaseCompare::kIgnoreCase)) { + CbmEvbuildRawTask* evBuildRaw = new CbmEvbuildRawTask(); + + //Choose between NoOverlap, MergeOverlap, AllowOverlap + evBuildRaw->SetEventOverlapMode(EOverlapModeRaw::AllowOverlap); + + // Remove detectors where digis not found + if (!useRich) evBuildRaw->RemoveDetector(kRawEventBuilderDetRich); + if (!useMuch) evBuildRaw->RemoveDetector(kRawEventBuilderDetMuch); + if (!usePsd) evBuildRaw->RemoveDetector(kRawEventBuilderDetPsd); + if (!useTof) evBuildRaw->RemoveDetector(kRawEventBuilderDetTof); + if (!useTrd) evBuildRaw->RemoveDetector(kRawEventBuilderDetTrd); + if (!useSts) { + std::cerr << "-E- " << myName << ": Sts must be present for raw event " + << "building using ``Real2019'' option. Terminating macro." << std::endl; + return; + } + // Set STS as reference detector + evBuildRaw->SetReferenceDetector(kRawEventBuilderDetTof); + evBuildRaw->SetTsParameters(0.0, 1.e7, 0.0); + + // Use CbmMuchDigi instead of CbmMuchBeamtimeDigi + // evBuildRaw->ChangeMuchBeamtimeDigiFlag(kFALSE); + + //evBuildRaw->SetTriggerMinNumber(ECbmModuleId::kSts, 1000); + evBuildRaw->SetTriggerMinNumber(ECbmModuleId::kTof, 10); + evBuildRaw->SetTriggerWindow(ECbmModuleId::kTof, -5, 50); + //evBuildRaw->SetTriggerMaxNumber(ECbmModuleId::kSts, -1); + evBuildRaw->SetTriggerWindow(ECbmModuleId::kSts, -500, 500); + + run->AddTask(evBuildRaw); + std::cout << "-I- " << myName << ": Added task " << evBuildRaw->GetName() << std::endl; + eventBased = kTRUE; + } //? Real raw event building + else { + std::cerr << "-E- " << myName << ": Unknown option " << sEvBuildRaw + << " for raw event building! Terminating macro execution." << std::endl; + return; + } + } //? event-based reco + // ------------------------------------------------------------------------ + + + // ----- Parameter database -------------------------------------------- + std::cout << std::endl << std::endl; + std::cout << "-I- " << myName << ": Set runtime DB" << std::endl; + FairRuntimeDb* rtdb = run->GetRuntimeDb(); + FairParRootFileIo* parIo1 = new FairParRootFileIo(); + FairParAsciiFileIo* parIo2 = new FairParAsciiFileIo(); + parIo1->open(parFile.Data(), "UPDATE"); + rtdb->setFirstInput(parIo1); + if (!parFileList->IsEmpty()) { + parIo2->open(parFileList, "in"); + rtdb->setSecondInput(parIo2); + } + // ------------------------------------------------------------------------ + + + // ----- Run initialisation ------------------------------------------- + std::cout << std::endl; + std::cout << "-I- " << myName << ": Initialise run" << std::endl; + run->Init(); + rtdb->setOutput(parIo1); + rtdb->saveOutput(); + rtdb->print(); + // ------------------------------------------------------------------------ + + + // ----- Start run ---------------------------------------------------- + std::cout << std::endl << std::endl; + std::cout << "-I- " << myName << ": Starting run" << std::endl; + run->Run(firstTimeSlice, nTimeSlices); + // ------------------------------------------------------------------------ + + + // ----- Finish ------------------------------------------------------- + timer.Stop(); + FairMonitor::GetMonitor()->Print(); + Double_t rtime = timer.RealTime(); + Double_t ctime = timer.CpuTime(); + std::cout << std::endl << std::endl; + std::cout << "Macro finished successfully." << std::endl; + std::cout << "Output file is " << outFile << std::endl; + std::cout << "Parameter file is " << parFile << std::endl; + std::cout << "Real time " << rtime << " s, CPU time " << ctime << " s" << std::endl; + FairSystemInfo sysInfo; + Float_t maxMemory = sysInfo.GetMaxMemory(); + std::cout << "<DartMeasurement name=\"MaxMemory\" type=\"numeric/double\">"; + std::cout << maxMemory; + std::cout << "</DartMeasurement>" << std::endl; + Float_t cpuUsage = ctime / rtime; + std::cout << "<DartMeasurement name=\"CpuLoad\" type=\"numeric/double\">"; + std::cout << cpuUsage; + std::cout << "</DartMeasurement>" << std::endl; + // ------------------------------------------------------------------------ + + + // ----- This is to prevent a malloc error when exiting ROOT ---------- + // The source of the error is unknown. Related to TGeoManager. + //RemoveGeoManager(); + // ------------------------------------------------------------------------ + +} // End of main macro function diff --git a/macro/beamtime/mcbm2021/scan_raw.sh b/macro/beamtime/mcbm2021/scan_raw.sh index 6a9d6a9e5d..8c3130a345 100755 --- a/macro/beamtime/mcbm2021/scan_raw.sh +++ b/macro/beamtime/mcbm2021/scan_raw.sh @@ -9,10 +9,13 @@ #SBATCH --time=48:00:00 #SBATCH --mem=2000 #SBATCH --partition=long + +echo scan_raw for run $1 , CalSet $2 + cRun=$1 iCalSet=$2 -if [[ "$iCalset" = "" ]]; then +if [[ "$iCalSet" = "" ]]; then iCalSet=31041500 fi diff --git a/macro/beamtime/mcbm2021/trk_cal_digi.sh b/macro/beamtime/mcbm2021/trk_cal_digi.sh index 47051a276a..df015976c8 100755 --- a/macro/beamtime/mcbm2021/trk_cal_digi.sh +++ b/macro/beamtime/mcbm2021/trk_cal_digi.sh @@ -32,6 +32,9 @@ fi if (( iSel2<10 )); then cSel2="00"$iSel2 fi +if (( iSel2<0 )); then +cSel2="-01" +fi cCalSet=$iCalSet if (( iCalSet<100000000 )); then @@ -76,7 +79,16 @@ if [[ $iTraSetup = "" ]]; then iTraSetup=1 fi -CalIdSet=$8 +iTrkPar=$8 +if [[ $iTrkPar = "" ]]; then +# fixed parameters, to be edited if necessary +#iTrkPar=0 # full 2021 setup +#iTrkPar=1 # for double stack analysis +iTrkPar=2 # for mcbm cosmic +#iTrkPar=3 # for CRI data ul 2021 +fi + +CalIdSet=$9 if [[ ${CalIdSet} = "" ]]; then echo use native calibration file CalIdSet=$cCalSet @@ -84,10 +96,10 @@ else CalFile=${CalIdMode}_set${CalIdSet}_93_1tofClust.hst.root fi -echo trk_cal_digi for $cRun with iDut=$iDut, iRef=$iRef, iSet=$iCalSet, iSel2=$iSel2, iBRef=$iBRef, Deadtime=$Deadtime, CalFile=$CalFile +echo trk_cal_digi for $cRun with iDut=$iDut, iRef=$iRef, iSet=$iCalSet, iSel2=$iSel2, iBRef=$iBRef, Deadtime=$Deadtime, CalFile=$CalFile, TrkPar=$iTrkPar if [ -e /lustre/cbm ]; then -source /lustre/cbm/users/nh/CBM/cbmroot/trunk/build/config.sh +source /lustre/cbm/users/nh/CBM/cbmroot/trunk/build/config.sh -a wdir=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2021 outdir=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2021/${cRun} else @@ -107,7 +119,7 @@ echo Execute in `pwd` at shell level $iShLev: ./trk_cal_digi.sh $1 $2 $3 $4 $5 $ if [[ $iShLev = "" ]]; then iShLev=0 - nEvt=200000 + nEvt=500000 dDTres=100000 dDTRMSres=100000 dL0DTRMSres=100000 @@ -127,10 +139,10 @@ nEvtMax=0 #frange1 limits DT spectrum range fRange1=1.5 # frange2 limits chi2 -fRange2=5.0 -TRange2Limit=3.5 +fRange2=6.0 # 9. +TRange2Limit=4.0 # 2. -iSel=900041 +iSel=12022 iGenCor=3 cCalSet2=${cCalSet}_$cSel2 @@ -158,25 +170,32 @@ while [[ $dDTres -gt 0 ]]; do fi iCalAct=$iCalOpt - echo Enter while loop with Iter $iIter, CalAct $iCalAct in dir `pwd` + echo Enter while loop with Iter $iIter, CalAct $iCalAct, CalOpt $iCalOpt in dir `pwd` while [[ $iCalAct -gt 0 ]]; do cd $wdir/$cRun echo Current loop with Iter $iIter, CalAct $iCalAct and CalOpt $iCalOpt if [[ $iCalOpt = 1 ]] || [[ $iCalAct -gt 1 ]]; then - root -b -q '../ana_digi_cal_all.C('$nEvt',93,1,'$iRef',1,"'$cRun'",'$iCalSet',1,'$iSel2','$Deadtime',"'$CalIdMode'") ' + if [[ $iCalOpt > 1 ]]; then + echo Execute ./clu_cal_all.sh $cRun $iCalSet # update local calibration + cd $wdir + ./clu_cal_all.sh $cRun $iCalSet # update local calibration + cd $wdir/$cRun + fi + root -b -q '../ana_digi_cal_all.C('$nEvt',93,-2,-1,1,"'$cRun'",'$iCalSet',1,'$iSel2','$Deadtime',"'$CalIdMode'")' # update calibration parameter file, will only be active in next iteration - if [[ $iIter = -10 ]] && [[ $iCalOpt = 1 ]]; then # exploratory option when iIter set to 0 - echo Update Calibration file from ana_digi_cal + if [[ $iIter -gt -1 ]] && [[ $iCalOpt = 1 ]]; then # exploratory option when iIter set to 0 + echo Update Calibration file from ana_digi_cal with Cluster corrections at Iter $iIter cp -v tofClust_${cRun}_set${cCalSet}.hst.root ../${cRun}_set${cCalSet}_93_1tofClust.hst.root - echo 20000 > TOffAvOff.res - echo 20000 > TOffAvRMS.res - else - root -b -q '../ana_trks.C('$nEvt','$iSel','$iGenCor',"'$cRun'","'$cCalSet2'",'$iSel2','$iTraSetup','$fRange1','$fRange2','$Deadtime',"'$CalIdMode'",1,1,'$iCalSet','$iCalAct')' - #root -l 'ana_trksi.C(-1,10,1,"385.50.5.0","000014500_020",20,1,1.90,7.60,50,"385.50.5.0",1,1)' - #exit 0 # for debugging - cp -v New_${CalFile} ${CalFile} + root -b -q '../ana_digi_cal_all.C('$nEvt',93,-2,-1,1,"'$cRun'",'$iCalSet',1,'$iSel2','$Deadtime',"'$CalIdMode'")' + #echo 20000 > TOffAvOff.res + #echo 20000 > TOffAvRMS.res fi + root -b -q '../ana_trks.C('$nEvt','$iSel','$iGenCor',"'$cRun'","'$cCalSet2'",'$iSel2','$iTraSetup','$fRange1','$fRange2','$Deadtime',"'$CalIdMode'",1,1,'$iCalSet','$iCalAct','$iTrkPar')' + #root -l 'ana_trksi.C(-1,10,1,"385.50.5.0","000014500_020",20,1,1.90,7.60,50,"385.50.5.0",1,1)' + #exit 0 # for debugging + cp -v New_${CalFile} ${CalFile} + (( iIter += 1 )) else cd $wdir @@ -185,8 +204,8 @@ while [[ $dDTres -gt 0 ]]; do dLDTRMSres=$dDTRMSres iLCalOpt=$iCalOpt echo Store $iIter limits $dLDTres, $dLDTRMSres - echo exec in `pwd` at iter $iIter, level $iShLev: trk_cal_digi $1 $2 $3 $4 $5 1 $7 - trk_cal_digi $1 $2 $3 $4 $5 1 $7 + echo exec in `pwd` at iter $iIter, level $iShLev: trk_cal_digi $1 $2 $3 $Deadtime $CalIdMode 1 $7 $8 + trk_cal_digi $1 $2 $3 $Deadtime $CalIdMode 1 $7 $8 # restore old status dL0DTRMSres=$dDTRMSres dLDTRMSres=50000 # prepare for next round @@ -217,7 +236,7 @@ while [[ $dDTres -gt 0 ]]; do dTRMSdif=`echo "$dDTRMSres - $TRMSres" | bc` compare_RMS=`echo "$TRMSres < $dDTRMSres" | bc` - echo At iter=$iter, ShLev=$iShLev got TOff = $Tres, compare to $dDTres, dTdif = $dTdif, result = $compare_result, TRMS = $TRMSres, old $dDTRMSres, dif = $dTRMSdif, result = $compare_RMS + echo `date`: at iter=$iter, ShLev=$iShLev got TOff = $Tres, compare to $dDTres, dTdif = $dTdif, result = $compare_result, TRMS = $TRMSres, old $dDTRMSres, dif = $dTRMSdif, result = $compare_RMS ((compare_result += $compare_RMS)) echo CMPR result_summary: $compare_result @@ -260,3 +279,6 @@ fi } #end of function body trk_cal_digi $1 $2 $3 $4 $5 $6 $7 $8 + +cd $wdir +mv -v slurm-${SLURM_JOB_ID}.out ${outdir}/TrkCal_${cRun}_${iCalSet}_${iTraSetup}_${iTrkPar}.out diff --git a/macro/beamtime/pl_Dut_Vel.C b/macro/beamtime/pl_Dut_Vel.C index 3fd48b34dd..b85f2137bf 100644 --- a/macro/beamtime/pl_Dut_Vel.C +++ b/macro/beamtime/pl_Dut_Vel.C @@ -56,6 +56,7 @@ void pl_Dut_Vel(const char* cDut = "900", Double_t dEffMin = 0.7, Double_t Tstar auto graph = pEffVel->GetPaintedGraph(); graph->GetXaxis()->SetRangeUser(Tstart, Tend); graph->SetMinimum(dEffMin); + graph->SetMaximum(1.02); gPad->Update(); diff --git a/macro/beamtime/pl_Eff_TIR.C b/macro/beamtime/pl_Eff_TIR.C index ef2410a25f..1f7b97622e 100644 --- a/macro/beamtime/pl_Eff_TIR.C +++ b/macro/beamtime/pl_Eff_TIR.C @@ -8,7 +8,7 @@ void pl_Eff_TIR(Int_t iDut = 900, Double_t dEffMin = 0., Double_t dEffMax = 1., gROOT->LoadMacro("pl_Datime.C"); // TCanvas *can = new TCanvas("can22","can22"); // can->Divide(2,2); - TCanvas* can = new TCanvas("can", "can", 48, 55, 700, 600); + TCanvas* can = new TCanvas("can", "can", 48, 55, 900, 800); can->Divide(1, 3); gPad->SetFillColor(0); @@ -51,6 +51,7 @@ void pl_Eff_TIR(Int_t iDut = 900, Double_t dEffMin = 0., Double_t dEffMax = 1., } else { cout << hname << " not found" << endl; + return; } can->cd(1); @@ -83,6 +84,7 @@ void pl_Eff_TIR(Int_t iDut = 900, Double_t dEffMin = 0., Double_t dEffMax = 1., h1m->SetLineColor(kRed); gPad->SetLogy(); h1all->GetXaxis()->SetRangeUser(TIRmin, TIRmax); + h1all->GetXaxis()->SetTitle("Time (s)"); gPad->Update(); can->cd(3); diff --git a/macro/beamtime/pl_Eff_TIS.C b/macro/beamtime/pl_Eff_TIS.C index 4657c6d94b..51798710f3 100644 --- a/macro/beamtime/pl_Eff_TIS.C +++ b/macro/beamtime/pl_Eff_TIS.C @@ -23,8 +23,11 @@ void pl_Eff_TIS(Int_t iDut = 910, Double_t dEffMin = 0.5, Double_t dEffMax = 1., TH1* h1f; TH1* h1m; TH1* h1all; + TH2* h2; TH2* h2f; TH2* h2m; + TH2* h2all; + // if (hPla!=NULL) hPla->Delete(); TString hname = ""; TProfile* h2pfx = NULL; @@ -35,24 +38,22 @@ void pl_Eff_TIS(Int_t iDut = 910, Double_t dEffMin = 0.5, Double_t dEffMax = 1., gROOT->cd(); hname = Form("hDutTIS_Found_%d", iDut); cout << " Look for histo " << hname << endl; - h1 = (TH1*) gROOT->FindObjectAny(hname); - if (h1 != NULL) { - h1->Draw(); - gPad->SetLogy(); - h1f = (TH1*) h1->Clone(); - Nfound = h1f->GetEntries(); + h2 = (TH2*) gROOT->FindObjectAny(hname); + if (h2 != NULL) { + h2->Draw("colz"); + //gPad->SetLogy(); + h2f = (TH2*) h2->Clone(); + Nfound = h2f->GetEntries(); } else { cout << hname << " not found" << endl; } hname = Form("hDutTIS_Missed_%d", iDut); - h1 = (TH1*) gROOT->FindObjectAny(hname); - if (h1 != NULL) { - h1m = (TH1*) h1->Clone(); - Nmissed = h1m->GetEntries(); - h1m->Draw("same"); - h1m->SetLineColor(2); + h2 = (TH2*) gROOT->FindObjectAny(hname); + if (h2 != NULL) { + h2m = (TH2*) h2->Clone(); + Nmissed = h2m->GetEntries(); } else { cout << hname << " not found" << endl; @@ -60,17 +61,31 @@ void pl_Eff_TIS(Int_t iDut = 910, Double_t dEffMin = 0.5, Double_t dEffMax = 1., can->cd(2); - h1m->Draw(); - h1f->Draw("same"); + h2m->Draw("colz"); + //h1f->Draw("same"); can->cd(3); - h1all = (TH1*) h1f->Clone("hDutTIS_all"); - h1all->Add(h1m, h1f, 1., 1.); + h2all = (TH2*) h2f->Clone("hDutTIS_all"); + h2all->Add(h2m, h2f, 1., 1.); + h2all->Draw("colz"); - TEfficiency* pEffDut = new TEfficiency(*h1f, *h1all); + /* + TEfficiency* pEffDut = new TEfficiency(*h2f, *h2all); pEffDut->SetTitle("Efficiency of DUT"); pEffDut->SetName("hDutTIS_eff"); + pEffDut->Draw("colz"); + gPad->Update(); +*/ + + can->cd(4); + h1all = h2all->ProjectionX(); + h1f = h2f->ProjectionX(); + h1m = h2m->ProjectionX(); + + TEfficiency* pEffDut = new TEfficiency(*h1f, *h1all); + pEffDut->SetTitle("Efficiency of DUT"); + pEffDut->SetName("hDutTIS_eff1D"); pEffDut->Draw("AP"); gPad->Update(); @@ -87,6 +102,8 @@ void pl_Eff_TIS(Int_t iDut = 910, Double_t dEffMin = 0.5, Double_t dEffMax = 1., gPad->SetGridx(); gPad->SetGridy(); + return; + can->cd(4); hname = Form("hDutDTLH_TIS_%d", iDut); h2f = (TH2*) gROOT->FindObjectAny(hname); diff --git a/macro/beamtime/pl_TIR.C b/macro/beamtime/pl_TIR.C index a1a1df0d2b..30905127cd 100644 --- a/macro/beamtime/pl_TIR.C +++ b/macro/beamtime/pl_TIR.C @@ -1,7 +1,6 @@ /* Copyright (C) 2020 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt SPDX-License-Identifier: GPL-3.0-only Authors: Florian Uhlig [committer] */ - void pl_TIR(Double_t Tstart = 0., Double_t Tend = 1000., Double_t dFracMin = 0.0, Double_t dFracMax = 1.05, TString sysinfo = "") { diff --git a/macro/beamtime/pl_TIS.C b/macro/beamtime/pl_TIS.C index c712a6296d..ae54252aef 100644 --- a/macro/beamtime/pl_TIS.C +++ b/macro/beamtime/pl_TIS.C @@ -1,10 +1,8 @@ /* Copyright (C) 2017-2018 PI-UHd, GSI SPDX-License-Identifier: GPL-3.0-only Authors: Norbert Herrmann [committer] */ - -void pl_TIS(TString sysinfo = "", Double_t dFracMax = 0.1) +void pl_TIS(Double_t dEffMin = 0.1, Double_t dEffMax = 1.01, TString sysinfo = "") { - gROOT->LoadMacro(((TString) gSystem->Getenv("VMCWORKDIR") + "/macro/beamtime/pl_Datime.C").Data()); // TCanvas *can = new TCanvas("can22","can22"); // can->Divide(2,2); TCanvas* can = new TCanvas("can", "can", 48, 55, 450, 600); @@ -104,6 +102,8 @@ void pl_TIS(TString sysinfo = "", Double_t dFracMax = 0.1) pEffSel->Draw("AP"); gPad->Update(); auto graph = pEffSel->GetPaintedGraph(); + graph->SetMinimum(dEffMin); + graph->SetMaximum(dEffMax); graph->GetXaxis()->SetRangeUser(0., 10.); gPad->Update(); /* @@ -131,7 +131,10 @@ void pl_TIS(TString sysinfo = "", Double_t dFracMax = 0.1) pEffDut->Draw("AP"); // gPad->SetLogy(); gPad->Update(); + auto gEffDut = pEffDut->GetPaintedGraph(); + gEffDut->SetMinimum(dEffMin); + gEffDut->SetMaximum(dEffMax); gEffDut->GetXaxis()->SetRangeUser(0., 10.); gPad->Update(); diff --git a/macro/beamtime/pl_Track2D.C b/macro/beamtime/pl_Track2D.C index aba69f491c..8b86be6156 100644 --- a/macro/beamtime/pl_Track2D.C +++ b/macro/beamtime/pl_Track2D.C @@ -1,7 +1,6 @@ /* Copyright (C) 2020 PI-UHd, GSI SPDX-License-Identifier: GPL-3.0-only Authors: Norbert Herrmann [committer] */ - void pl_Track2D(Int_t iOpt = 1, Int_t iCounterId = 22, Int_t iStrip = -1, Double_t TotMax = 10.) { // TCanvas *can = new TCanvas("can22","can22"); diff --git a/macro/beamtime/pl_XY_trk.C b/macro/beamtime/pl_XY_trk.C index 1ec32bec7a..6098212876 100644 --- a/macro/beamtime/pl_XY_trk.C +++ b/macro/beamtime/pl_XY_trk.C @@ -1,8 +1,7 @@ /* Copyright (C) 2017-2020 PI-UHd, GSI SPDX-License-Identifier: GPL-3.0-only Authors: Norbert Herrmann [committer] */ - -void pl_XY_trk(Int_t NSt = 4, Double_t MinEff = 0.5, Double_t dThr = 0.1) +void pl_XY_trk(Int_t NSt = 4, Double_t MinEff = 0.5, Double_t dThr = 0.1, int iOpt = 0) { // TCanvas *can = new TCanvas("can22","can22"); // can->Divide(2,2); @@ -34,6 +33,7 @@ void pl_XY_trk(Int_t NSt = 4, Double_t MinEff = 0.5, Double_t dThr = 0.1) can->cd(iCan++); gROOT->cd(); hname = Form("hXY_AllStations_%d", iSt); + if (iOpt == 1) hname = Form("hXY_AllFitStations_%d", iSt); h2 = (TH2*) gROOT->FindObjectAny(hname); if (h2 != NULL) { h2->Draw("colz"); diff --git a/macro/beamtime/pl_all_CluRate.C b/macro/beamtime/pl_all_CluRate.C index b6c5a24d70..fcf72c566c 100644 --- a/macro/beamtime/pl_all_CluRate.C +++ b/macro/beamtime/pl_all_CluRate.C @@ -2,13 +2,14 @@ SPDX-License-Identifier: GPL-3.0-only Authors: Norbert Herrmann [committer] */ -void pl_all_CluRate(Int_t iNSt = 6, Double_t Tstart = 0., Double_t Tend = 800.) +void pl_all_CluRate(Int_t iNSt = 3, Double_t Tstart = 0., Double_t Tend = 800.) { // TCanvas *can = new TCanvas("can22","can22"); // can->Divide(2,2); // TCanvas *can = new TCanvas("can","can",48,55,700,900); TCanvas* can = new TCanvas("can", "can", 48, 56, 900, 900); switch (iNSt) { + case 3: can->Divide(5, 6, 0.01, 0.01); break; case 6: can->Divide(4, 4, 0.01, 0.01); break; case 5: can->Divide(3, 4, 0.01, 0.01); break; } @@ -27,9 +28,9 @@ void pl_all_CluRate(Int_t iNSt = 6, Double_t Tstart = 0., Double_t Tend = 800.) TH1* h; TH2* h2; - const Int_t iType[6] = {5, 4, 6, 2, 9, 8}; - const Int_t iSmNum[6] = {3, 1, 1, 2, 3, 3}; - const Int_t iRpcNum[6] = {1, 1, 2, 1, 2, 1}; + const Int_t iType[6] = {0, 2, 9, 2, 9, 8}; + const Int_t iSmNum[6] = {5, 1, 1, 2, 3, 3}; + const Int_t iRpcNum[6] = {5, 5, 2, 1, 2, 1}; Int_t iCanv = 0; // if (h!=NULL) h->Delete(); diff --git a/macro/beamtime/pl_all_CluRateRatio.C b/macro/beamtime/pl_all_CluRateRatio.C index 3e12f6707a..ed833c177b 100644 --- a/macro/beamtime/pl_all_CluRateRatio.C +++ b/macro/beamtime/pl_all_CluRateRatio.C @@ -3,14 +3,13 @@ Authors: Florian Uhlig [committer] */ void pl_all_CluRateRatio(Int_t iRef = 500, Int_t iNSt = 3, Double_t Tstart = 0., Double_t Tend = 800., Int_t iMode = 0, - Int_t iOpt = 0, Double_t THR = 1.E5) + Int_t iOpt = 0, Double_t THR = 1.E5, Double_t Ymax = 5E3) { // TCanvas *can = new TCanvas("can22","can22"); // can->Divide(2,2); // TCanvas *can = new TCanvas("can","can",48,55,700,900); TCanvas* can = new TCanvas("can", "can", 48, 56, 900, 900); - can->Divide(1, 2, 0.01, 0.01); Float_t lsize = 0.06; @@ -31,13 +30,18 @@ void pl_all_CluRateRatio(Int_t iRef = 500, Int_t iNSt = 3, Double_t Tstart = 0., TH1* hRat; TH1* hDis; TH2* h2; - const Int_t iTSR[11] = {500, 41, 31, 900, 901, 910, 911, 600, 601, 800, 801}; - const Double_t dArea[11] = {1., 18., 44.0, 896., 896., 896., 896., 280., 280., 32., 4.}; - const Double_t dDist[11] = {1., 353., 532.5, 386., 416., 416., 445., 478., 485., 517., 543.}; + const Int_t iTSR[11] = {500, 2, 12, 1, 11, 3, 11, 4, 14, 5, 15}; + //const Int_t iTSR[11] = {500, 41, 31, 900, 901, 910, 911, 600, 601, 33, 43}; + //const Int_t iPlot[11] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; + const Int_t iPlot[11] = {0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1}; + + const Double_t dArea[11] = {1., 864., 864., 864., 756., 852., 852., 280., 280., 864., 864.}; + const Double_t dDist[11] = {1., 353., 532.5, 386., 416., 416., 445., 478., 485., 353., 543.}; Int_t iCanv = 0; // if (h!=NULL) h->Delete(); TString hname; + gROOT->LoadMacro("shift_hst.C"); can->cd(1); @@ -67,9 +71,14 @@ void pl_all_CluRateRatio(Int_t iRef = 500, Int_t iNSt = 3, Double_t Tstart = 0., gPad->SetLogy(); break; case 1: //rate/area + { hRef->Add(h, hRef, 0., 1. / dArea[IndRef]); - hRef->SetMaximum(1.E3); - break; + hRef->SetMaximum(Ymax); + hRef->GetYaxis()->SetTitle("Flux (Hz/cm^{2})"); + //ScaleXaxis(hRef,ScaleX); //shift to align times + TH1* hREfFlux = (TH1*) hRef->Clone(); + hREfFlux->SetName("hRefFlux"); + } break; case 2: //flux=rate/area*dist**2 hRef->Add(h, hRef, 0., dDist[IndRef] * dDist[IndRef] / dArea[IndRef]); break; @@ -87,7 +96,7 @@ void pl_all_CluRateRatio(Int_t iRef = 500, Int_t iNSt = 3, Double_t Tstart = 0., Double_t RateRMS = hRefRate->GetStdDev(1); cout << "Reference counter average rate " << RateAv << ", RMS " << RateRMS << endl; gStyle->SetOptStat(1111); - TCanvas* can2 = new TCanvas("can2", "can2", 700, 56, 500, 500); + TCanvas* can2 = new TCanvas("can2", "can2", 1400, 56, 500, 500); can2->cd(1); hRefRate->Draw("histE"); hRefRate->UseCurrentStyle(); @@ -97,6 +106,7 @@ void pl_all_CluRateRatio(Int_t iRef = 500, Int_t iNSt = 3, Double_t Tstart = 0., can->cd(1); Int_t iCol = 1; for (Int_t iSt = 0; iSt < iNSt; iSt++) { + if (iPlot[iSt] == 0) continue; iRp = iTSR[iSt] % 10; iSmType = (iTSR[iSt] - iRp) / 10; iSm = iSmType % 10; @@ -118,9 +128,14 @@ void pl_all_CluRateRatio(Int_t iRef = 500, Int_t iNSt = 3, Double_t Tstart = 0., hDis->Add(h, hDis, 0., 1.); break; case 1: //rate/area + { cout << "Scale station " << iSt << " by " << 1. / dArea[iSt] << endl; hDis->Add(h, hDis, 0., 1. / dArea[iSt]); - break; + hDis->GetYaxis()->SetTitle("Flux (Hz/cm^{2})"); + //ScaleXaxis(hDis,ScaleX); // shift in x - direction, need shift_hst.C to be loaded + TH1* hFlux = (TH1*) hDis->Clone(); + hFlux->SetName(Form("hFlux_%d", iTSR[iSt])); + } break; case 2: //flux=rate/area*dist**2 hDis->Add(h, hDis, 0., dDist[iSt] * dDist[iSt] / dArea[iSt]); break; @@ -128,7 +143,7 @@ void pl_all_CluRateRatio(Int_t iRef = 500, Int_t iNSt = 3, Double_t Tstart = 0., hDis->Draw("samehistE"); hDis->SetLineColor(iCol++); - if (iCol == 5) iCol++; // skip yellow + if (iCol == 5 || iCol == 10) iCol++; // skip yellow //h->UseCurrentStyle(); //gPad->SetLogy(); } @@ -142,6 +157,7 @@ void pl_all_CluRateRatio(Int_t iRef = 500, Int_t iNSt = 3, Double_t Tstart = 0., TLegend* leg = new TLegend(0.25, 0.7, 0.35, 0.95); leg->SetTextSize(0.03); for (Int_t iSt = 0; iSt < iNSt; iSt++) { + if (iPlot[iSt] == 0) continue; iRp = iTSR[iSt] % 10; iSmType = (iTSR[iSt] - iRp) / 10; iSm = iSmType % 10; @@ -166,7 +182,10 @@ void pl_all_CluRateRatio(Int_t iRef = 500, Int_t iNSt = 3, Double_t Tstart = 0., hRat->Divide(h, hRef, 1., 1., "B"); break; case 1: //rate/area - hRat->Divide(h, hRef, 1. / dArea[iSt], 1. / dArea[IndRef], "B"); + h = (TH1*) gROOT->FindObjectAny(Form("hFlux_%d", iTSR[iSt])); + hRef = (TH1*) gROOT->FindObjectAny(Form("hRefFlux")); + hRat->Divide(h, hRef, 1., 1., "B"); + //hRat->Divide(h, hRef, 1. / dArea[iSt], 1. / dArea[IndRef], "B"); break; case 2: //flux=rate/area*dist**2 hRat->Divide(h, hRef, dDist[iSt] * dDist[iSt] / dArea[iSt], dDist[IndRef] * dDist[IndRef] / dArea[IndRef], @@ -203,7 +222,7 @@ void pl_all_CluRateRatio(Int_t iRef = 500, Int_t iNSt = 3, Double_t Tstart = 0., hRat->Draw("L E SAME"); hRat->SetLineColor(iCol++); - if (iCol == 5) iCol++; // skip yellow + if (iCol == 5 || iCol == 10) iCol++; // skip yellow //h->UseCurrentStyle(); //gPad->SetLogy(); @@ -213,5 +232,5 @@ void pl_all_CluRateRatio(Int_t iRef = 500, Int_t iNSt = 3, Double_t Tstart = 0., } leg->Draw(); } - can->SaveAs(Form("pl_all_CluRate.pdf")); + can->SaveAs(Form("pl_all_CluRateRatio.pdf")); } diff --git a/macro/beamtime/pl_all_CluSizeDTLastHits.C b/macro/beamtime/pl_all_CluSizeDTLastHits.C index d7890855e9..d759dfebcb 100644 --- a/macro/beamtime/pl_all_CluSizeDTLastHits.C +++ b/macro/beamtime/pl_all_CluSizeDTLastHits.C @@ -2,13 +2,13 @@ SPDX-License-Identifier: GPL-3.0-only Authors: Norbert Herrmann [committer] */ -void pl_all_CluSizeDTLastHits(Int_t iNSt = 6, Int_t iSel = 0, Double_t Tstart = 1., Double_t Tend = 100.) +void pl_all_CluSizeDTLastHits(Int_t iNSt = 5, Int_t iSel = 0, Double_t Tstart = 1., Double_t Tend = 100.) { // TCanvas *can = new TCanvas("can22","can22"); // can->Divide(2,2); // TCanvas *can = new TCanvas("can","can",48,55,700,900); TCanvas* can = new TCanvas("can", "can", 48, 56, 900, 900); - can->Divide(4, 4, 0.01, 0.01); + can->Divide(5, 8, 0.01, 0.01); // can->Divide(2,2,0,0); Float_t lsize = 0.07; @@ -22,10 +22,9 @@ void pl_all_CluSizeDTLastHits(Int_t iNSt = 6, Int_t iSel = 0, Double_t Tstart = TH2* h; TH2* h2; - const Int_t iType[6] = {5, 4, 6, 2, 9, 8}; - const Int_t iSmNum[6] = {1, 1, 1, 2, 3, 3}; - const Int_t iRpcNum[6] = {1, 1, 2, 1, 2, 1}; - + const Int_t iType[6] = {0, 2, 9, 6, 5, 8}; + const Int_t iSmNum[6] = {5, 1, 2, 1, 1, 0}; + const Int_t iRpcNum[6] = {5, 5, 2, 2, 1, 8}; Int_t iCanv = 0; // if (h!=NULL) h->Delete(); diff --git a/macro/beamtime/pl_all_DTLastHits.C b/macro/beamtime/pl_all_DTLastHits.C index e6e5817445..86c1d345e2 100644 --- a/macro/beamtime/pl_all_DTLastHits.C +++ b/macro/beamtime/pl_all_DTLastHits.C @@ -2,13 +2,13 @@ SPDX-License-Identifier: GPL-3.0-only Authors: Norbert Herrmann [committer] */ -void pl_all_DTLastHits(Int_t iNSt = 6, Double_t Tstart = 1., Double_t Tend = 1000.) +void pl_all_DTLastHits(Int_t iNSt = 5, Double_t Tstart = 1., Double_t Tend = 1000.) { // TCanvas *can = new TCanvas("can22","can22"); // can->Divide(2,2); // TCanvas *can = new TCanvas("can","can",48,55,700,900); TCanvas* can = new TCanvas("can", "can", 48, 56, 900, 900); - can->Divide(4, 4, 0.01, 0.01); + can->Divide(5, 8, 0.01, 0.01); // can->Divide(2,2,0,0); Float_t lsize = 0.07; @@ -22,9 +22,9 @@ void pl_all_DTLastHits(Int_t iNSt = 6, Double_t Tstart = 1., Double_t Tend = 100 TH1* h; TH2* h2; - const Int_t iType[6] = {5, 4, 6, 2, 9, 8}; - const Int_t iSmNum[6] = {1, 1, 1, 2, 3, 3}; - const Int_t iRpcNum[6] = {1, 1, 2, 1, 2, 1}; + const Int_t iType[6] = {0, 2, 9, 6, 5, 8}; + const Int_t iSmNum[6] = {5, 1, 2, 1, 1, 0}; + const Int_t iRpcNum[6] = {5, 5, 2, 2, 1, 8}; Int_t iCanv = 0; // if (h!=NULL) h->Delete(); diff --git a/macro/beamtime/pl_all_TOffDTLastHits.C b/macro/beamtime/pl_all_TOffDTLastHits.C index e744b23526..a8466b3cc0 100644 --- a/macro/beamtime/pl_all_TOffDTLastHits.C +++ b/macro/beamtime/pl_all_TOffDTLastHits.C @@ -2,13 +2,13 @@ SPDX-License-Identifier: GPL-3.0-only Authors: Norbert Herrmann [committer] */ -void pl_all_TOffDTLastHits(Int_t iNSt = 6, Int_t iSel = 0, Double_t Tstart = 1., Double_t Tend = 100.) +void pl_all_TOffDTLastHits(Int_t iNSt = 5, Int_t iSel = 0, Double_t Tstart = 1., Double_t Tend = 100.) { // TCanvas *can = new TCanvas("can22","can22"); // can->Divide(2,2); // TCanvas *can = new TCanvas("can","can",48,55,700,900); TCanvas* can = new TCanvas("can", "can", 48, 56, 900, 900); - can->Divide(4, 4, 0.01, 0.01); + can->Divide(5, 8, 0.01, 0.01); // can->Divide(2,2,0,0); Float_t lsize = 0.07; @@ -22,9 +22,9 @@ void pl_all_TOffDTLastHits(Int_t iNSt = 6, Int_t iSel = 0, Double_t Tstart = 1., TH2* h; TH2* h2; - const Int_t iType[6] = {5, 4, 6, 2, 9, 8}; - const Int_t iSmNum[6] = {1, 1, 1, 2, 3, 3}; - const Int_t iRpcNum[6] = {1, 1, 2, 1, 2, 1}; + const Int_t iType[6] = {0, 2, 9, 6, 5, 8}; + const Int_t iSmNum[6] = {5, 1, 2, 1, 1, 0}; + const Int_t iRpcNum[6] = {5, 5, 2, 2, 1, 8}; Int_t iCanv = 0; // if (h!=NULL) h->Delete(); diff --git a/macro/beamtime/pl_all_TotDTLastHits.C b/macro/beamtime/pl_all_TotDTLastHits.C index 89431d1995..ce5663afbd 100644 --- a/macro/beamtime/pl_all_TotDTLastHits.C +++ b/macro/beamtime/pl_all_TotDTLastHits.C @@ -2,13 +2,13 @@ SPDX-License-Identifier: GPL-3.0-only Authors: Norbert Herrmann [committer] */ -void pl_all_TotDTLastHits(Int_t iNSt = 6, Int_t iSel = 0, Double_t Tstart = 1., Double_t Tend = 100.) +void pl_all_TotDTLastHits(Int_t iNSt = 5, Int_t iSel = 0, Double_t Tstart = 1., Double_t Tend = 100.) { // TCanvas *can = new TCanvas("can22","can22"); // can->Divide(2,2); // TCanvas *can = new TCanvas("can","can",48,55,700,900); TCanvas* can = new TCanvas("can", "can", 48, 56, 900, 900); - can->Divide(4, 4, 0.01, 0.01); + can->Divide(5, 8, 0.01, 0.01); // can->Divide(2,2,0,0); Float_t lsize = 0.07; @@ -22,10 +22,9 @@ void pl_all_TotDTLastHits(Int_t iNSt = 6, Int_t iSel = 0, Double_t Tstart = 1., TH2* h; TH2* h2; - const Int_t iType[6] = {5, 4, 6, 2, 9, 8}; - const Int_t iSmNum[6] = {1, 1, 1, 2, 3, 3}; - const Int_t iRpcNum[6] = {1, 1, 2, 1, 2, 1}; - + const Int_t iType[6] = {0, 2, 9, 6, 5, 8}; + const Int_t iSmNum[6] = {5, 1, 2, 1, 1, 0}; + const Int_t iRpcNum[6] = {5, 5, 2, 2, 1, 8}; Int_t iCanv = 0; // if (h!=NULL) h->Delete(); diff --git a/macro/beamtime/pl_calib_trk.C b/macro/beamtime/pl_calib_trk.C index 66d3ea55b0..513749d318 100644 --- a/macro/beamtime/pl_calib_trk.C +++ b/macro/beamtime/pl_calib_trk.C @@ -209,7 +209,7 @@ void pl_calib_trk() dTOff = TMath::Abs(dTOff); - Int_t iTOff = ((Int_t)(dTOff * 1000.) * 1000) + (Int_t)(dTRMS * 1000.); + Int_t iTOff = ((Int_t)(dTOff * 1000.) * 10000) + (Int_t)(dTRMS * 1000.); cout << " dTOff = " << dTOff << ", dRMS = " << dTRMS << " -> iTOff = " << iTOff << endl; gROOT->ProcessLine(Form(".! echo %d > TCalib.res", iTOff)); diff --git a/macro/beamtime/pl_cmp_2D.C b/macro/beamtime/pl_cmp_2D.C new file mode 100644 index 0000000000..b4f7e12af5 --- /dev/null +++ b/macro/beamtime/pl_cmp_2D.C @@ -0,0 +1,73 @@ +/* Copyright (C) 2022 PI-UHd, GSI + SPDX-License-Identifier: GPL-3.0-only + Authors: Norbert Herrmann [committer] */ + +void pl_cmp_2D(TString hname = "cl_SmT0_sm003_rpc001_Tot", Int_t iOpt = 1, + TString fName1 = "1091.50.0.0/CluStatus42042042_-1_Cal_1044.50.4.0_set031041500.hst.root", + TString fName2 = "1111.50.0.0/CluStatus42042042_-1_Cal_1044.50.4.0_set031041500.hst.root") +{ + //plot initialisation + TCanvas* can = new TCanvas("can", "can", 50, 50, 686, 686); + can->Divide(1, 1, 0.01, 0.01); + gPad->SetFillColor(0); + gStyle->SetPalette(1); + gStyle->SetOptStat(kTRUE); + gStyle->SetOptStat(" "); + gStyle->SetOptStat(10); + //cout << "gStyle label size: "<< gStyle->GetLabelSize() << endl; + + // file opening + + TFile* f1 = new TFile(fName1.Data()); + TH2* h21 = (TH2*) f1->Get(hname.Data())->Clone(); + + TFile* f2 = new TFile(fName2.Data()); + TH2* h22 = (TH2*) f2->Get(hname.Data())->Clone(); + // f2->Close(); + gDirectory->cd(); + // cout << Form("h21 %p, h22 %p",h21,h22)<<endl; + + TH1* h1; + TH1* h2; + + switch (iOpt % 10) { + case 0: // x-projection + h1 = (TH1*) h21->Clone(); + h2 = (TH1*) h22->Clone(); + ; + break; + + case 10: + case 1: // y- projections + h1 = (TH1*) h21->ProjectionY(Form("%s_py1", h21->GetName())); + h2 = (TH1*) h22->ProjectionY(Form("%s_py2", h22->GetName())); + break; + + case 2: // x-projection with box fit + ; + break; + + default: cout << "Option " << iOpt << " not available " << endl; return; + } + + can->cd(1); + + h1->Draw(""); + h1->SetLineColor(kRed); + h2->SetLineColor(kBlue); + Double_t N1 = h1->GetEntries(); + Double_t N2 = h2->GetEntries(); + TH1* h1s = (TH1*) h1->Clone(); + cout << "Scale " << h1s->GetName() << " by " << N2 / N1 << endl; + h1s->Scale(N2 / N1); + h2->SetMaximum(TMath::Max(h1s->GetMaximum(), h2->GetMaximum()) * 1.2); + h2->Draw("he"); + h1s->Draw("samehe"); + + TLegend* leg = new TLegend(0.2, 0.82, 0.85, 0.9); + leg->SetTextSize(0.015); + leg->AddEntry(h1s, fName1, "l"); + leg->AddEntry(h2, fName2, "l"); + leg->Draw(); + if (iOpt > 9) { gPad->SetLogy(); } +} diff --git a/macro/beamtime/pl_over_cor.C b/macro/beamtime/pl_over_cor.C index 7f10fb8270..6ef6af3d71 100644 --- a/macro/beamtime/pl_over_cor.C +++ b/macro/beamtime/pl_over_cor.C @@ -7,7 +7,7 @@ void pl_over_cor(Int_t SmT = 9, Int_t iSm = 0, Int_t iRpc = 0, Double_t yRange = // TCanvas *can = new TCanvas("can22","can22"); // can->Divide(2,2); TCanvas* can = new TCanvas("can", "can", 50, 0, 800, 800); - can->Divide(3, 3); + can->Divide(2, 3); gPad->SetFillColor(0); gStyle->SetPalette(1); @@ -61,7 +61,8 @@ void pl_over_cor(Int_t SmT = 9, Int_t iSm = 0, Int_t iRpc = 0, Double_t yRange = cout << hname << " not found" << endl; } - can->cd(4); + + can->cd(5); // gROOT->cd(); for (Int_t iCh = 0; iCh < iNch; iCh++) { hname = Form("Cor_SmT%d_sm%03d_rpc%03d_Ch%03d_S0_Walk_px", SmT, iSm, iRpc, iCh); @@ -84,7 +85,7 @@ void pl_over_cor(Int_t SmT = 9, Int_t iSm = 0, Int_t iRpc = 0, Double_t yRange = } } - can->cd(5); + can->cd(6); for (Int_t iCh = 0; iCh < iNch; iCh++) { hname = Form("Cor_SmT%d_sm%03d_rpc%03d_Ch%03d_S1_Walk_px", SmT, iSm, iRpc, iCh); h2 = (TH2*) gDirectory->FindObjectAny(hname); @@ -105,7 +106,7 @@ void pl_over_cor(Int_t SmT = 9, Int_t iSm = 0, Int_t iRpc = 0, Double_t yRange = } } - can->cd(6); + can->cd(4); // gROOT->cd(); // TString hname=Form("cl_SmT%d_sm%03d_rpc%03d_Mul",SmT,iSm,iRpc); hname = Form("cl_CorSmT%d_sm%03d_rpc%03d_Tot_Off", SmT, iSm, iRpc); @@ -118,7 +119,7 @@ void pl_over_cor(Int_t SmT = 9, Int_t iSm = 0, Int_t iRpc = 0, Double_t yRange = cout << hname << " not found" << endl; } - can->cd(7); + can->cd(4); Int_t iNSel = 2; for (Int_t iTr = 0; iTr < iNSel; iTr++) { hname = Form("cl_CorSmT%d_sm%03d_rpc%03d_Sel%02d_DelTof", SmT, iSm, iRpc, iTr); @@ -139,4 +140,5 @@ void pl_over_cor(Int_t SmT = 9, Int_t iSm = 0, Int_t iRpc = 0, Double_t yRange = cout << hname << " not found" << endl; } } + can->SaveAs(Form("pl_over_cor_%01d_%01d_%01d.pdf", SmT, iSm, iRpc)); } diff --git a/macro/beamtime/pl_over_trk.C b/macro/beamtime/pl_over_trk.C index d94e4afb55..1e9ad07951 100644 --- a/macro/beamtime/pl_over_trk.C +++ b/macro/beamtime/pl_over_trk.C @@ -1,218 +1,243 @@ /* Copyright (C) 2017-2021 PI-UHd, GSI SPDX-License-Identifier: GPL-3.0-only Authors: Norbert Herrmann [committer] */ +void pl_over_trk(Int_t NSt = 4) +{ + // TCanvas *can = new TCanvas("can22","can22"); + // can->Divide(2,2); + TCanvas* can = new TCanvas("can", "can", 50, 0, 800, 800); + can->Divide(4, 4); -// TCanvas *can = new TCanvas("can22","can22"); -// can->Divide(2,2); -TCanvas* can = new TCanvas("can", "can", 50, 0, 800, 800); -can->Divide(4, 4); + gPad->SetFillColor(0); + gStyle->SetPalette(1); + gStyle->SetOptStat(kTRUE); -gPad->SetFillColor(0); -gStyle->SetPalette(1); -gStyle->SetOptStat(kTRUE); + gROOT->cd(); + gROOT->SetDirLevel(1); -gROOT->cd(); -gROOT->SetDirLevel(1); + TH1* h; + TH1* h1; + TH2* h2; + TH1* hAll; + // if (h!=NULL) h->Delete(); + TString hname = ""; + gStyle->SetPalette(kRainBow, 0); + int iPal = TColor::GetColorPalette(1); + Int_t iCol = iPal; + int iDcol = 255 / NSt; -TH1* h; -TH1* h1; -TH2* h2; -TH1* hAll; -// if (h!=NULL) h->Delete(); -TString hname = ""; -Int_t iCol = 1; + can->cd(1); + gROOT->cd(); + hname = Form("hTrklMulNhits"); + h2 = (TH2*) gROOT->FindObjectAny(hname); + if (h2 != NULL) { + h2->Draw("colz"); + gPad->SetLogz(); + } + else { + cout << hname << " not found" << endl; + } -can->cd(1); -gROOT->cd(); -hname = Form("hTrklMulNhits"); -h2 = (TH2*) gROOT->FindObjectAny(hname); -if (h2 != NULL) { - h2->Draw("colz"); - gPad->SetLogz(); -} -else { - cout << hname << " not found" << endl; -} + can->cd(2); + gROOT->cd(); + hname = Form("hTrklHMul"); + h2 = (TH2*) gROOT->FindObjectAny(hname); + if (h2 != NULL) { + h2->Draw("colz"); + gPad->SetLogz(); + } + else { + cout << hname << " not found" << endl; + } -can->cd(2); -gROOT->cd(); -hname = Form("hTrklHMul"); -h2 = (TH2*) gROOT->FindObjectAny(hname); -if (h2 != NULL) { - h2->Draw("colz"); - gPad->SetLogz(); -} -else { - cout << hname << " not found" << endl; -} + can->cd(3); + gROOT->cd(); + hname = Form("hTrklChi2"); + h2 = (TH2*) gROOT->FindObjectAny(hname); + if (h2 != NULL) { + h2->Draw("colz"); + gPad->SetLogz(); + } + else { + cout << hname << " not found" << endl; + } -can->cd(3); -gROOT->cd(); -hname = Form("hTrklChi2"); -h2 = (TH2*) gROOT->FindObjectAny(hname); -if (h2 != NULL) { - h2->Draw("colz"); - gPad->SetLogz(); -} -else { - cout << hname << " not found" << endl; -} + can->cd(4); + gROOT->cd(); + hname = Form("hTrklMulMaxMax-1"); + h2 = (TH2*) gROOT->FindObjectAny(hname); + if (h2 != NULL) { + h2->Draw("colz"); + gPad->SetLogz(); + } + else { + cout << hname << " not found" << endl; + } -can->cd(4); -gROOT->cd(); -hname = Form("hTrklMulMaxMax-1"); -h2 = (TH2*) gROOT->FindObjectAny(hname); -if (h2 != NULL) { - h2->Draw("colz"); - gPad->SetLogz(); -} -else { - cout << hname << " not found" << endl; -} + can->cd(5); + gROOT->cd(); + iCol = iPal; + double dMax = 0.; + for (Int_t iSt = 0; iSt < NSt; iSt++) { + hname = Form("hPullX_Station_%d", iSt); + h1 = (TH1*) gROOT->FindObjectAny(hname); + if (h1 != NULL) { dMax = TMath::Max(dMax, h1->GetMaximum()); } + } + for (Int_t iSt = 0; iSt < NSt; iSt++) { + hname = Form("hPullX_Station_%d", iSt); + h1 = (TH1*) gROOT->FindObjectAny(hname); + if (h1 != NULL) { + if (iSt == 0) { + if (dMax != 0.) h1->SetMaximum(dMax * 1.1); + h1->Draw(""); + h1->SetMinimum(0.5); + gPad->SetLogy(); + } + else { + h1->Draw("same"); + } + if (iCol == 5 || iCol == 10) iCol += iDcol; + h1->SetLineColor(iCol); + iCol += iDcol; + } + } -can->cd(5); -gROOT->cd(); -iCol = 1; -for (Int_t iSt = 0; iSt < NSt; iSt++) { - hname = Form("hPullX_Station_%d", iSt); - h1 = (TH1*) gROOT->FindObjectAny(hname); - if (h1 != NULL) { - if (iSt == 0) { - h1->Draw(""); - h1->SetMinimum(0.5); - gPad->SetLogy(); + can->cd(6); + gROOT->cd(); + + iCol = iPal + 1; + dMax = 0; + for (Int_t iSt = 0; iSt < NSt; iSt++) { + hname = Form("hPullY_Station_%d", iSt); + h1 = (TH1*) gROOT->FindObjectAny(hname); + if (h1 != NULL) { dMax = TMath::Max(dMax, h1->GetMaximum()); } + } + for (Int_t iSt = 0; iSt < NSt; iSt++) { + hname = Form("hPullY_Station_%d", iSt); + h1 = (TH1*) gROOT->FindObjectAny(hname); + if (h1 != NULL) { + if (iSt == 0) { + if (dMax != 0.) h1->SetMaximum(dMax * 1.1); + h1->SetMinimum(0.5); + h1->Draw(""); + gPad->SetLogy(); + } + else { + h1->Draw("same"); + } + if (iCol == 5 || iCol == 10) iCol++; + h1->SetLineColor(iCol); + iCol += iDcol; } - else { - h1->Draw("same"); + } + + can->cd(7); + gROOT->cd(); + iCol = iPal + 1; + dMax = 0; + for (Int_t iSt = 0; iSt < NSt; iSt++) { + hname = Form("hPullZ_Station_%d", iSt); + h1 = (TH1*) gROOT->FindObjectAny(hname); + if (h1 != NULL) { dMax = TMath::Max(dMax, h1->GetMaximum()); } + } + for (Int_t iSt = 0; iSt < NSt; iSt++) { + hname = Form("hPullZ_Station_%d", iSt); + h1 = (TH1*) gROOT->FindObjectAny(hname); + if (h1 != NULL) { + if (iSt == 0) { + if (dMax != 0.) h1->SetMaximum(dMax * 1.1); + h1->SetMinimum(0.5); + h1->Draw(""); + gPad->SetLogy(); + } + else { + h1->Draw("same"); + } + if (iCol == 5 || iCol == 10) iCol++; + h1->SetLineColor(iCol); + iCol += iDcol; } - if (iCol == 5 || iCol == 10) iCol++; - h1->SetLineColor(iCol++); + } + + can->cd(8); + gROOT->cd(); + iCol = iPal + 1; + dMax = 0; + for (Int_t iSt = 0; iSt < NSt; iSt++) { + hname = Form("hPullT_Station_%d", iSt); + h1 = (TH1*) gROOT->FindObjectAny(hname); + if (h1 != NULL) { dMax = TMath::Max(dMax, h1->GetMaximum()); } + } + for (Int_t iSt = 0; iSt < NSt; iSt++) { + hname = Form("hPullT_Station_%d", iSt); + h1 = (TH1*) gROOT->FindObjectAny(hname); + if (h1 != NULL) { + if (iSt == 0) { + if (dMax != 0.) h1->SetMaximum(dMax * 1.1); + h1->SetMinimum(0.5); + h1->Draw(""); + gPad->SetLogy(); + } + else { + h1->Draw("same"); + } + if (iCol == 5 || iCol == 10) iCol++; + h1->SetLineColor(iCol); + iCol += iDcol; + } + } + + can->cd(9); + gROOT->cd(); + hname = Form("hTrklXY0_0"); + h2 = (TH2*) gROOT->FindObjectAny(hname); + if (h2 != NULL) { + h2->Draw("colz"); + gPad->SetLogz(); } else { cout << hname << " not found" << endl; } -} -can->cd(6); -gROOT->cd(); -iCol = 1; -for (Int_t iSt = 0; iSt < NSt; iSt++) { - hname = Form("hPullY_Station_%d", iSt); - h1 = (TH1*) gROOT->FindObjectAny(hname); - if (h1 != NULL) { - if (iSt == 0) { - h1->Draw(""); - h1->SetMinimum(0.5); - gPad->SetLogy(); - } - else { - h1->Draw("same"); - } - if (iCol == 5 || iCol == 10) iCol++; - h1->SetLineColor(iCol++); + can->cd(10); + gROOT->cd(); + hname = Form("hTrklXY0_1"); + h2 = (TH2*) gROOT->FindObjectAny(hname); + if (h2 != NULL) { + h2->Draw("colz"); + gPad->SetLogz(); } else { cout << hname << " not found" << endl; } -} -can->cd(7); -gROOT->cd(); -iCol = 1; -for (Int_t iSt = 0; iSt < NSt; iSt++) { - hname = Form("hPullZ_Station_%d", iSt); - h1 = (TH1*) gROOT->FindObjectAny(hname); - if (h1 != NULL) { - if (iSt == 0) { - h1->Draw(""); - h1->SetMinimum(0.5); - gPad->SetLogy(); - } - else { - h1->Draw("same"); - } - if (iCol == 5 || iCol == 10) iCol++; - h1->SetLineColor(iCol++); + can->cd(11); + gROOT->cd(); + hname = Form("hTrklTxHMul"); + h2 = (TH2*) gROOT->FindObjectAny(hname); + if (h2 != NULL) { + h2->Draw("colz"); + gPad->SetLogz(); } else { cout << hname << " not found" << endl; } -} -can->cd(8); -gROOT->cd(); -iCol = 1; -for (Int_t iSt = 0; iSt < NSt; iSt++) { - hname = Form("hPullT_Station_%d", iSt); - h1 = (TH1*) gROOT->FindObjectAny(hname); - if (h1 != NULL) { - if (iSt == 0) { - h1->Draw(""); - h1->SetMinimum(0.5); - gPad->SetLogy(); - } - else { - h1->Draw("same"); - } - if (iCol == 5 || iCol == 10) iCol++; - h1->SetLineColor(iCol++); + can->cd(12); + gROOT->cd(); + hname = Form("hTrklTyHMul"); + h2 = (TH2*) gROOT->FindObjectAny(hname); + if (h2 != NULL) { + h2->Draw("colz"); + gPad->SetLogz(); } else { cout << hname << " not found" << endl; } -} -can->cd(9); -gROOT->cd(); -hname = Form("hTrklXY0_0"); -h2 = (TH2*) gROOT->FindObjectAny(hname); -if (h2 != NULL) { - h2->Draw("colz"); - gPad->SetLogz(); -} -else { - cout << hname << " not found" << endl; -} - -can->cd(10); -gROOT->cd(); -hname = Form("hTrklXY0_1"); -h2 = (TH2*) gROOT->FindObjectAny(hname); -if (h2 != NULL) { - h2->Draw("colz"); - gPad->SetLogz(); -} -else { - cout << hname << " not found" << endl; -} - -can->cd(11); -gROOT->cd(); -hname = Form("hTrklTxHMul"); -h2 = (TH2*) gROOT->FindObjectAny(hname); -if (h2 != NULL) { - h2->Draw("colz"); - gPad->SetLogz(); -} -else { - cout << hname << " not found" << endl; -} - -can->cd(12); -gROOT->cd(); -hname = Form("hTrklTyHMul"); -h2 = (TH2*) gROOT->FindObjectAny(hname); -if (h2 != NULL) { - h2->Draw("colz"); - gPad->SetLogz(); -} -else { - cout << hname << " not found" << endl; -} - -can->cd(13); -gROOT->cd(); -/************* + can->cd(13); + gROOT->cd(); + /************* hname = Form("hTrklTtHMul"); h2 = (TH2*) gROOT->FindObjectAny(hname); if (h2 != NULL) { @@ -222,63 +247,63 @@ gROOT->cd(); cout << hname << " not found" << endl; } */ -hname = Form("hCalDX0"); -h1 = (TH1*) gROOT->FindObjectAny(hname); -if (h1 != NULL) { - hname = Form("hCalDY0"); - TH1* h1y = (TH1*) gROOT->FindObjectAny(hname); + hname = Form("hCalDX0"); + h1 = (TH1*) gROOT->FindObjectAny(hname); + if (h1 != NULL) { + hname = Form("hCalDY0"); + TH1* h1y = (TH1*) gROOT->FindObjectAny(hname); - Double_t dYmax = TMath::Max(h1->GetMaximum(), h1y->GetMaximum()); - dYmax *= 1.1; - h1->SetMaximum(dYmax); + Double_t dYmax = TMath::Max(h1->GetMaximum(), h1y->GetMaximum()); + dYmax *= 1.1; + h1->SetMaximum(dYmax); - h1->Draw(""); - gPad->SetLogy(); + h1->Draw(""); + gPad->SetLogy(); - h1y->SetLineColor(2); - h1y->Draw("same"); -} -else { - cout << hname << " not found" << endl; -} + h1y->SetLineColor(2); + h1y->Draw("same"); + } + else { + cout << hname << " not found" << endl; + } -can->cd(14); -gROOT->cd(); -hname = Form("hAllHitsStation"); -h1 = (TH1*) gROOT->FindObjectAny(hname); -if (h1 != NULL) { - h1->Draw(""); - h1->SetMinimum(0.1 * h1->GetMaximum()); - gPad->SetLogy(); - hAll = (TH1*) h1->Clone(); -} -else { - cout << hname << " not found" << endl; -} -hname = Form("hUsedHitsStation"); -h1 = (TH1*) gROOT->FindObjectAny(hname); -if (h1 != NULL) { - h1->Draw("same"); - h1->SetLineColor(2); - TH1* hEff = (TH1*) h1->Clone(); - hEff->Divide(h1, hAll, 1., 1., "B"); + can->cd(14); + gROOT->cd(); + hname = Form("hAllHitsStation"); + h1 = (TH1*) gROOT->FindObjectAny(hname); + if (h1 != NULL) { + h1->Draw(""); + h1->SetMinimum(0.1 * h1->GetMaximum()); + gPad->SetLogy(); + hAll = (TH1*) h1->Clone(); + } + else { + cout << hname << " not found" << endl; + } + hname = Form("hUsedHitsStation"); + h1 = (TH1*) gROOT->FindObjectAny(hname); + if (h1 != NULL) { + h1->Draw("same"); + h1->SetLineColor(2); + TH1* hEff = (TH1*) h1->Clone(); + hEff->Divide(h1, hAll, 1., 1., "B"); - can->cd(15); - hEff->Draw(); -} -else { - cout << hname << " not found" << endl; -} -can->cd(16); -gROOT->cd(); -hname = Form("hTrklVelHMul"); -h2 = (TH2*) gROOT->FindObjectAny(hname); -if (h2 != NULL) { - h2->Draw("colz"); - gPad->SetLogz(); -} -else { - cout << hname << " not found" << endl; -} -can->SaveAs("pl_over_trk.pdf"); + can->cd(15); + hEff->Draw(); + } + else { + cout << hname << " not found" << endl; + } + can->cd(16); + gROOT->cd(); + hname = Form("hTrklVelHMul"); + h2 = (TH2*) gROOT->FindObjectAny(hname); + if (h2 != NULL) { + h2->Draw("colz"); + gPad->SetLogz(); + } + else { + cout << hname << " not found" << endl; + } + can->SaveAs("pl_over_trk.pdf"); } diff --git a/macro/beamtime/pl_pull_trk.C b/macro/beamtime/pl_pull_trk.C index 99ed8836cf..4b3fead1b3 100644 --- a/macro/beamtime/pl_pull_trk.C +++ b/macro/beamtime/pl_pull_trk.C @@ -1,184 +1,199 @@ /* Copyright (C) 2017-2021 PI-UHd, GSI SPDX-License-Identifier: GPL-3.0-only Authors: Norbert Herrmann [committer] */ +void pl_pull_trk(Int_t NSt = 8, Int_t iVar = 0, Int_t iFit = 0, Int_t iDrop = -1) +{ + // TCanvas *can = new TCanvas("can22","can22"); + // can->Divide(2,2); + TCanvas* can = new TCanvas("can", "can", 50, 0, 800, 800); + switch (NSt) { + case 7: can->Divide(3, 4); break; + case 6: + case 5: + case 4: can->Divide(3, 3); break; + case 9: can->Divide(3, 4); break; + case 16: + case 17: + case 18: can->Divide(5, 4); break; + case 20: can->Divide(5, 5); break; + case 30: + case 31: + case 32: can->Divide(5, 7); break; + case 36: + case 37: + case 39: can->Divide(6, 7); break; + default: can->Divide(4, 4); ; + } + gPad->SetFillColor(0); + gStyle->SetPalette(1); + gStyle->SetOptStat(kTRUE); + gStyle->SetOptFit(kTRUE); -// TCanvas *can = new TCanvas("can22","can22"); -// can->Divide(2,2); -TCanvas* can = new TCanvas("can", "can", 50, 0, 800, 800); -switch (NSt) { - case 7: can->Divide(3, 4); break; - case 6: - case 5: - case 4: can->Divide(3, 3); break; - case 9: can->Divide(3, 4); break; - case 18: can->Divide(4, 5); break; - default: can->Divide(4, 4); ; -} -gPad->SetFillColor(0); -gStyle->SetPalette(1); -gStyle->SetOptStat(kTRUE); -gStyle->SetOptFit(kTRUE); - -gROOT->cd(); -gROOT->SetDirLevel(1); - -TH1* h; -TH1* h1; -TH2* h2; + gROOT->cd(); + gROOT->SetDirLevel(1); -const Int_t MSt = 30; -Double_t vSt[MSt]; -Double_t vMean[MSt]; -Double_t vSig[MSt]; -Double_t vRes[MSt]; -Double_t vStErr[MSt]; -Double_t vMeanErr[MSt]; -Double_t vSigErr[MSt]; -Double_t vResErr[MSt]; -// if (h!=NULL) h->Delete(); -Int_t iCan = 1; -Int_t iIndSt = 0; -TString var; -Double_t Nall; + TH1* h; + TH1* h1; + TH2* h2; -switch (iVar) { - case 0: var = "X"; break; - case 1: var = "Y"; break; - case 2: var = "Z"; break; - case 3: var = "T"; break; - case 4: var = "TB"; break; -} -for (Int_t iSt = 0; iSt < NSt; iSt++) { - can->cd(iCan++); - gROOT->cd(); - TString hname = Form("hPull%s_Station_%d", var.Data(), iSt); - h1 = (TH1*) gROOT->FindObjectAny(hname); - if (h1 != NULL) { - h1->Draw(""); - Nall = h1->GetEntries(); - gPad->SetLogy(); - gPad->SetGridx(); - if (iFit > 0) { - //Double_t dFMean = h1->GetMean(); - Double_t dFMean = h1->GetBinCenter(h1->GetMaximumBin()); - Double_t dFLim = 2.0 * h1->GetRMS(); - Double_t dBinSize = h1->GetBinWidth(1); - dFLim = TMath::Max(dFLim, 5. * dBinSize); - TFitResultPtr fRes = h1->Fit("gaus", "SQM", "", dFMean - dFLim, dFMean + dFLim); - //cout << " fRes = "<< fRes <<endl; - if (-1 == fRes) continue; - if (iDrop == iSt) { // drop station from deconvolution - continue; + const Int_t MSt = 50; + Double_t vSt[MSt]; + Double_t vMean[MSt]; + Double_t vSig[MSt]; + Double_t vRes[MSt]; + Double_t vStErr[MSt]; + Double_t vMeanErr[MSt]; + Double_t vSigErr[MSt]; + Double_t vResErr[MSt]; + // if (h!=NULL) h->Delete(); + Int_t iCan = 1; + Int_t iIndSt = 0; + TString var; + Double_t Nall; + TString hbase = "hPull"; + switch (iVar) { + case 0: var = "X"; break; + case 1: var = "Y"; break; + case 2: var = "Z"; break; + case 3: var = "T"; break; + case 4: var = "TB"; break; + case 5: + var = "TrefRms"; + hbase = "h"; + break; + } + for (Int_t iSt = 0; iSt < NSt; iSt++) { + can->cd(iCan++); + gROOT->cd(); + TString hname = Form("%s%s_Station_%d", hbase.Data(), var.Data(), iSt); + h1 = (TH1*) gROOT->FindObjectAny(hname); + if (h1 != NULL) { + Nall = h1->GetEntries(); + if (Nall == 0) h1->SetMaximum(1.E6); + h1->Draw(""); + gPad->SetLogy(); + gPad->SetGridx(); + if (iFit > 0) { + //Double_t dFMean = h1->GetMean(); + Double_t dFMean = h1->GetBinCenter(h1->GetMaximumBin()); + Double_t dFLim = 2.0 * h1->GetRMS(); + Double_t dBinSize = h1->GetBinWidth(1); + dFLim = TMath::Max(dFLim, 5. * dBinSize); + TFitResultPtr fRes = h1->Fit("gaus", "SQM", "", dFMean - dFLim, dFMean + dFLim); + //cout << " fRes = "<< fRes <<endl; + if (-1 == fRes) continue; + if (iDrop == iSt) { // drop station from deconvolution + continue; + } + cout << "Add " << iSt << " as station index " << iIndSt << endl; + vSt[iIndSt] = iSt; + vMean[iIndSt] = fRes->Parameter(1); + vSig[iIndSt] = fRes->Parameter(2); + vStErr[iIndSt] = 0.; + vMeanErr[iIndSt] = fRes->ParError(1); + vSigErr[iIndSt] = fRes->ParError(2); + //vSig[iIndSt]=TMath::Max(20.,vSig[iSt]); + iIndSt++; } - cout << "Add " << iSt << " as station index " << iIndSt << endl; - vSt[iIndSt] = iSt; - vMean[iIndSt] = fRes->Parameter(1); - vSig[iIndSt] = fRes->Parameter(2); - vStErr[iIndSt] = 0.; - vMeanErr[iIndSt] = fRes->ParError(1); - vSigErr[iIndSt] = fRes->ParError(2); - //vSig[iIndSt]=TMath::Max(20.,vSig[iSt]); - iIndSt++; + } + else { + cout << hname << " not found" << endl; } } - else { - cout << hname << " not found" << endl; + if (0 == iFit) return; + cout << "Process " << iIndSt << " fit values " << endl; + can->cd(iCan++); + Double_t dLMargin = 0.35; + Double_t dTitOffset = 1.8; + gPad->SetLeftMargin(dLMargin); + TGraphErrors* grm = new TGraphErrors(iIndSt, vSt, vMean, vStErr, vMeanErr); + grm->SetTitle("Mean"); + grm->GetXaxis()->SetTitle("Station number"); + switch (iVar) { + case 0: + case 1: + case 2: grm->GetYaxis()->SetTitle("mean deviation (cm)"); break; + default: grm->GetYaxis()->SetTitle("mean deviation (ns)"); } -} -if (0 == iFit) return; -cout << "Process " << iIndSt << " fit values " << endl; -can->cd(iCan++); -Double_t dLMargin = 0.35; -Double_t dTitOffset = 1.8; -gPad->SetLeftMargin(dLMargin); -TGraphErrors* grm = new TGraphErrors(iIndSt, vSt, vMean, vStErr, vMeanErr); -grm->SetTitle("Mean"); -grm->GetXaxis()->SetTitle("Station number"); -switch (iVar) { - case 0: - case 1: - case 2: grm->GetYaxis()->SetTitle("mean deviation (cm)"); break; - default: grm->GetYaxis()->SetTitle("mean deviation (ns)"); -} -grm->GetYaxis()->SetTitleOffset(dTitOffset); -grm->GetXaxis()->SetLimits(-0.5, NSt - 0.5); -grm->SetMarkerStyle(24); -grm->Draw("APLE"); + grm->GetYaxis()->SetTitleOffset(dTitOffset); + grm->GetXaxis()->SetLimits(-0.5, NSt - 0.5); + grm->SetMarkerStyle(24); + grm->Draw("APLE"); -can->cd(iCan++); -gPad->SetLeftMargin(dLMargin); -TGraphErrors* grs = new TGraphErrors(iIndSt, vSt, vSig, vStErr, vSigErr); -grs->SetTitle("Gaussian width"); -grs->GetXaxis()->SetTitle("Station number"); -switch (iVar) { - case 0: - case 1: - case 2: grs->GetYaxis()->SetTitle("Gaussian sigma (cm)"); break; - default: grs->GetYaxis()->SetTitle("Gaussian sigma (ns)"); -} -grs->GetYaxis()->SetTitleOffset(dTitOffset); -grs->GetXaxis()->SetLimits(-0.5, NSt - 0.5); -grs->SetMarkerStyle(24); -grs->Draw("APLE"); + can->cd(iCan++); + gPad->SetLeftMargin(dLMargin); + TGraphErrors* grs = new TGraphErrors(iIndSt, vSt, vSig, vStErr, vSigErr); + grs->SetTitle("Gaussian width"); + grs->GetXaxis()->SetTitle("Station number"); + switch (iVar) { + case 0: + case 1: + case 2: grs->GetYaxis()->SetTitle("Gaussian sigma (cm)"); break; + default: grs->GetYaxis()->SetTitle("Gaussian sigma (ns)"); + } + grs->GetYaxis()->SetTitleOffset(dTitOffset); + grs->GetXaxis()->SetLimits(-0.5, NSt - 0.5); + grs->SetMarkerStyle(24); + grs->Draw("APLE"); -can->cd(iCan++); -gPad->SetLeftMargin(dLMargin); -Double_t val = (iIndSt - 1) * (iIndSt - 1); -TMatrixD a(iIndSt, iIndSt); -for (Int_t i = 0; i < iIndSt; i++) - for (Int_t j = 0; j < iIndSt; j++) { - if (i == j) { a[i][j] = 1; } - else { - a[i][j] = 1. / val; + can->cd(iCan++); + gPad->SetLeftMargin(dLMargin); + Double_t val = (iIndSt - 1) * (iIndSt - 1); + TMatrixD a(iIndSt, iIndSt); + for (Int_t i = 0; i < iIndSt; i++) + for (Int_t j = 0; j < iIndSt; j++) { + if (i == j) { a[i][j] = 1; } + else { + a[i][j] = 1. / val; + } } - } -a.Draw("colz"); -a.Print(); + //a.Draw("colz"); + //a.Print(); -// can->cd(iCan++); -TMatrixD ainv = a; -ainv.Invert(); -ainv.Draw("colz"); -ainv.Print(); -TMatrixD aSig(iIndSt, 1); -for (Int_t i = 0; i < iIndSt; i++) - aSig[i][0] = vSig[i] * vSig[i]; + // can->cd(iCan++); + TMatrixD ainv = a; + ainv.Invert(); + //ainv.Draw("colz"); + //ainv.Print(); + TMatrixD aSig(iIndSt, 1); + for (Int_t i = 0; i < iIndSt; i++) + aSig[i][0] = vSig[i] * vSig[i]; -cout << "Measured gaussian widths: " << endl; -aSig.Print(); -TMatrixD xRes = ainv * aSig; -cout << "Resolution of counters: " << endl; -xRes.Print(); + //cout << "Measured gaussian widths: " << endl; + //aSig.Print(); + TMatrixD xRes = ainv * aSig; + //cout << "Resolution of counters: " << endl; + //xRes.Print(); -//can->cd(iCan++); -for (Int_t i = 0; i < iIndSt; i++) { - vRes[i] = TMath::Sqrt(TMath::Abs(xRes[i][0])); - vResErr[i] = vSigErr[i]; -} -TGraphErrors* grr = new TGraphErrors(iIndSt, vSt, vRes, vStErr, vResErr); -grr->SetTitle("Final resolution"); -grr->GetXaxis()->SetTitle("Station number"); -switch (iVar) { - case 0: - case 1: - case 2: grr->GetYaxis()->SetTitle("resolution (cm)"); break; - default: grr->GetYaxis()->SetTitle("resolution (ns)"); -} -grr->GetYaxis()->SetTitleOffset(dTitOffset); -grr->GetXaxis()->SetLimits(-0.5, NSt - 0.5); -//grr->GetXaxis()->SetRangeUser(-0.5,NSt-0.5); -grr->SetMarkerStyle(24); -grr->Draw("APLE"); + //can->cd(iCan++); + for (Int_t i = 0; i < iIndSt; i++) { + vRes[i] = TMath::Sqrt(TMath::Abs(xRes[i][0])); + vResErr[i] = vSigErr[i]; + } + TGraphErrors* grr = new TGraphErrors(iIndSt, vSt, vRes, vStErr, vResErr); + grr->SetTitle("Final resolution"); + grr->GetXaxis()->SetTitle("Station number"); + switch (iVar) { + case 0: + case 1: + case 2: grr->GetYaxis()->SetTitle("resolution (cm)"); break; + default: grr->GetYaxis()->SetTitle("resolution (ns)"); + } + grr->GetYaxis()->SetTitleOffset(dTitOffset); + grr->GetXaxis()->SetLimits(-0.5, NSt - 0.5); + //grr->GetXaxis()->SetRangeUser(-0.5,NSt-0.5); + grr->SetMarkerStyle(24); + grr->Draw("APLE"); -for (Int_t i = 0; i < iIndSt; i++) - cout << Form("GMean %6.3f +/- %6.5f, GSig: %6.3f +/- %6.5f => ResC %d: %6.3f ", vMean[i], vMeanErr[i], vSig[i], - vSigErr[i], i, vRes[i]) - << endl; + for (Int_t i = 0; i < iIndSt; i++) + cout << Form("GMean %6.3f +/- %6.5f, GSig: %6.3f +/- %6.5f => ResC %d: %6.3f ", vMean[i], vMeanErr[i], vSig[i], + vSigErr[i], i, vRes[i]) + << endl; -cout << "Res-summary " << iVar << ": Nall, sigs = " << Nall; -for (Int_t i = 0; i < iIndSt; i++) - cout << Form(", %7.4f", vRes[i]); -cout << endl; + cout << "Res-summary " << iVar << ": Nall, sigs = " << Nall; + for (Int_t i = 0; i < iIndSt; i++) + cout << Form(", %7.4f", vRes[i]); + cout << endl; -can->SaveAs(Form("pl_pull_trk_%s%02d.pdf", var.Data(), NSt)); + can->SaveAs(Form("pl_pull_trk_%s%02d.pdf", var.Data(), NSt)); } diff --git a/macro/beamtime/pl_raw_evt.C b/macro/beamtime/pl_raw_evt.C index 23e5f3b069..c648c1551c 100644 --- a/macro/beamtime/pl_raw_evt.C +++ b/macro/beamtime/pl_raw_evt.C @@ -7,27 +7,33 @@ void pl_raw_evt() // TCanvas *can = new TCanvas("can22","can22"); // can->Divide(2,2); // TCanvas *can = new TCanvas("can","can",48,55,700,900); - TCanvas* can = new TCanvas("can", "can", 48, 56, 900, 900); - can->Divide(2, 3, 0.01, 0.01); + TCanvas* can = new TCanvas("can", "can", 48, 56, 800, 800); + can->Divide(2, 2, 0.01, 0.01); // can->Divide(4,4,0.01,0.01); // can->Divide(2,2,0,0); - Float_t lsize = 0.09; + Float_t lsize = 0.01; gPad->SetFillColor(0); gStyle->SetPalette(1); - gStyle->SetLabelSize(lsize); + gStyle->SetLabelSize(lsize, "x"); + gStyle->SetLabelSize(lsize, "y"); + gStyle->SetTitleSize(lsize, "x"); + gStyle->SetTitleSize(lsize, "y"); //gStyle->SetStatY(0.5); //gStyle->SetStatX(0.5); - gStyle->SetStatW(0.5); + gStyle->SetStatW(0.2); gStyle->SetStatH(0.3); gStyle->SetOptStat(kTRUE); gStyle->SetOptStat(11); + gStyle->UseCurrentStyle(); + //gROOT->cd(); //gROOT->SetDirLevel(2); TH1* h; + TH1* h1; TH2* h2; TString hname; @@ -38,34 +44,29 @@ void pl_raw_evt() gPad->SetLogy(); can->cd(2); - hname = Form("hPulMul"); + hname = Form("hEvDigiMul"); h = (TH1*) gROOT->FindObjectAny(hname); + h->GetXaxis()->SetRangeUser(0, 3000); h->Draw(); gPad->SetLogy(); can->cd(3); - hname = Form("hPulserTimesRaw"); - h2 = (TH2*) gROOT->FindObjectAny(hname); - h2->Draw("colz"); + hname = Form("hDigiTdif"); + h1 = (TH1*) gROOT->FindObjectAny(hname); + h1->Draw(""); gPad->SetLogz(); can->cd(4); - hname = Form("hPulserTimesCor"); - h2 = (TH2*) gROOT->FindObjectAny(hname); - h2->Draw("colz"); + hname = Form("hEvRateIn"); + h1 = (TH1*) gROOT->FindObjectAny(hname); + h1->Draw(""); gPad->SetLogz(); - - can->cd(5); - hname = Form("hDigiTimesRaw"); - h2 = (TH2*) gROOT->FindObjectAny(hname); - h2->Draw("colz"); + hname = Form("hEvRateOut"); + h1 = (TH1*) gROOT->FindObjectAny(hname); + h1->SetLineColor(2); + h1->Draw("same"); gPad->SetLogz(); - can->cd(6); - hname = Form("hDigiTimesCor"); - h2 = (TH2*) gROOT->FindObjectAny(hname); - h2->Draw("colz"); - gPad->SetLogz(); can->SaveAs(Form("pl_raw_evt.pdf")); } diff --git a/macro/beamtime/pl_trk_Walk.C b/macro/beamtime/pl_trk_Walk.C index b83d432341..f61cb47868 100644 --- a/macro/beamtime/pl_trk_Walk.C +++ b/macro/beamtime/pl_trk_Walk.C @@ -1,7 +1,6 @@ /* Copyright (C) 2020 PI-UHd, GSI SPDX-License-Identifier: GPL-3.0-only Authors: Norbert Herrmann [committer] */ - void pl_trk_Walk(Int_t iId = 900, Int_t iOpt = 1, Double_t dMax = 0.) { // TCanvas *can = new TCanvas("can22","can22"); diff --git a/macro/beamtime/pl_vert_trk.C b/macro/beamtime/pl_vert_trk.C index 393730582c..b7b8ae0335 100644 --- a/macro/beamtime/pl_vert_trk.C +++ b/macro/beamtime/pl_vert_trk.C @@ -1,7 +1,6 @@ /* Copyright (C) 2020 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt SPDX-License-Identifier: GPL-3.0-only Authors: Florian Uhlig [committer], Norbert Herrmann */ - void pl_vert_trk(Double_t dFitWidth = 0.) { // TCanvas *can = new TCanvas("can22","can22"); diff --git a/macro/beamtime/shift_hst.C b/macro/beamtime/shift_hst.C new file mode 100644 index 0000000000..778308c1c6 --- /dev/null +++ b/macro/beamtime/shift_hst.C @@ -0,0 +1,72 @@ +/* Copyright (C) 2022 PI-UHd, GSI + SPDX-License-Identifier: GPL-3.0-only + Authors: Norbert Herrmann [committer] */ + +#include "TArrayD.h" +#include "TAxis.h" +#include "TH1.h" + +Double_t ScaleX(Double_t x) +{ + Double_t v; + v = x - 1.6; // "linear scaling" function example + return v; +} + +Double_t ScaleY(Double_t y) +{ + Double_t v; + v = 20 * y + 200; // "linear scaling" function example + return v; +} + +Double_t ScaleZ(Double_t z) +{ + Double_t v; + v = 30 * z + 300; // "linear scaling" function example + return v; +} + +void ScaleAxis(TAxis* a, Double_t (*Scale)(Double_t)) +{ + if (!a) return; // just a precaution + if (a->GetXbins()->GetSize()) { + // an axis with variable bins + // note: bins must remain in increasing order, hence the "Scale" + // function must be strictly (monotonically) increasing + TArrayD X(*(a->GetXbins())); + for (Int_t i = 0; i < X.GetSize(); i++) + X[i] = Scale(X[i]); + a->Set((X.GetSize() - 1), X.GetArray()); // new Xbins + } + else { + // an axis with fix bins + // note: we modify Xmin and Xmax only, hence the "Scale" function + // must be linear (and Xmax must remain greater than Xmin) + a->Set(a->GetNbins(), + Scale(a->GetXmin()), // new Xmin + Scale(a->GetXmax())); // new Xmax + } + return; +} + +void ScaleXaxis(TH1* h, Double_t (*Scale)(Double_t)) +{ + if (!h) return; // just a precaution + ScaleAxis(h->GetXaxis(), Scale); + return; +} + +void ScaleYaxis(TH1* h, Double_t (*Scale)(Double_t)) +{ + if (!h) return; // just a precaution + ScaleAxis(h->GetYaxis(), Scale); + return; +} + +void ScaleZaxis(TH1* h, Double_t (*Scale)(Double_t)) +{ + if (!h) return; // just a precaution + ScaleAxis(h->GetZaxis(), Scale); + return; +} -- GitLab