diff --git a/macro/beamtime/mcbm2020/.gitignore b/macro/beamtime/mcbm2020/.gitignore deleted file mode 100644 index 17f70d58587c3ecaf93818d745c3ba46bd7ab007..0000000000000000000000000000000000000000 --- a/macro/beamtime/mcbm2020/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -all_*.par -*.root -!mcbm_beam_2020_03.geo.root \ No newline at end of file diff --git a/macro/beamtime/mcbm2020/mcbm_build_and_reco.C b/macro/beamtime/mcbm2020/mcbm_build_and_reco.C index 95f0b46f6c713e40cbfd06a049a1b40aacd5a9f1..51d4d12b4c7c2be66cca382f178ea923e329c2fa 100644 --- a/macro/beamtime/mcbm2020/mcbm_build_and_reco.C +++ b/macro/beamtime/mcbm2020/mcbm_build_and_reco.C @@ -10,6 +10,7 @@ void mcbm_build_and_reco(UInt_t uRunId = 28, Int_t nTimeslices = 300, TString outDir = "data/") { + // ======================================================================== // Adjust this part according to your requirements @@ -27,8 +28,10 @@ void mcbm_build_and_reco(UInt_t uRunId = 28, // ----- In- and output file names ------------------------------------ + TString inFile = Form("./data/unp_mcbm_%i.root", uRunId); TString parFileIn = Form("./data/unp_mcbm_params_%i.root", uRunId); + TString geoFile = paramDir + "mcbm2020_reco.geo.root"; // Created in sim. run TString parFileOut = Form("./data/reco_mcbm_evt_win_params_%u.root", uRunId); TString outFile = Form("./data/reco_mcbm_evt_win_%u.root", uRunId); // ------------------------------------------------------------------------ @@ -245,7 +248,212 @@ void mcbm_build_and_reco(UInt_t uRunId = 28, // ----- Local reconstruction in TOF ---------------------------------- // ------------------------------------------------------------------------ + // TOF defaults + Int_t calMode = 93; + Int_t calSel = 1; + Int_t calSm = 0; + Int_t RefSel = 0; + Double_t dDeadtime = 50.; + Int_t iSel2 = 500; + TString TofGeoTag = "v20f_mcbm"; + TString cCalId = "831.50.3.0"; + Int_t iCalSet = 12022500; // calibration settings + + TObjString* tofBdfFile = + new TObjString(parDir + "/tof/tof_" + TofGeoTag + ".digibdf.par"); + parFileList->Add(tofBdfFile); + std::cout << "-I- Using parameter file " << tofBdfFile->GetString() + << std::endl; + CbmTofEventClusterizer* tofCluster = + new CbmTofEventClusterizer("TOF Event Clusterizer", 0, 1); + TString cFname = parDir + "/tof/" + + Form("%s_set%09d_%02d_%01dtofClust.hst.root", + cCalId.Data(), + iCalSet, + calMode, + calSel); + tofCluster->SetCalParFileName(cFname); + tofCluster->SetCalMode(calMode); + tofCluster->SetCalSel(calSel); + tofCluster->PosYMaxScal(0.75); //in % of 2*length + tofCluster->SetChannelDeadtime(dDeadtime); // artificial deadtime in ns + + run->AddTask(tofCluster); + std::cout << "-I- Added task " << tofCluster->GetName() << std::endl; + + // ----- Track reconstruction ------------------------------------------ + Int_t iTrackMode = 2; + switch (iTrackMode) { + case 2: { + Int_t iGenCor = 1; + Double_t dScalFac = 1.; + Double_t dChi2Lim2 = 3.5; + TString cTrkFile = + parDir + "/tof/" + Form("%s_tofFindTracks.hst.root", cCalId.Data()); + Int_t iTrackingSetup = 1; + Int_t iCalOpt = 1; + + CbmTofTrackFinder* tofTrackFinder = new CbmTofTrackFinderNN(); + tofTrackFinder->SetMaxTofTimeDifference(0.2); // in ns/cm + tofTrackFinder->SetTxLIM(0.3); // max slope dx/dz + tofTrackFinder->SetTyLIM(0.3); // max dev from mean slope dy/dz + tofTrackFinder->SetTyMean(0.); // mean slope dy/dz + 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.041); // 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->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( + kFALSE); // 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 + iMinNofHits = 3; + iNStations = 28; + 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, 0, 1); + break; + + case 2: // for geometry check mode of full setup + iMinNofHits = 3; + iNStations = 27; + 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, 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); + break; + + case 3: // for reduced bias tracking of full setup + iMinNofHits = 3; + iNStations = 28; + 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, 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; + } + tofFindTracks->SetMinNofHits(iMinNofHits); + tofFindTracks->SetNStations(iNStations); + tofFindTracks->SetNReqStations(iNReqStations); + //tofFindTracks->PrintSetup(); + run->AddTask(tofFindTracks); + } break; + case 1: { + } + case 0: + default:; + } // ----- Local reconstruction of RICH Hits ------------------------------ CbmRichMCbmHitProducer* hitProdRich = new CbmRichMCbmHitProducer(); @@ -282,6 +490,7 @@ void mcbm_build_and_reco(UInt_t uRunId = 28, parIo2->open(parFileList, "in"); rtdb->setSecondInput(parIo2); parIo3->open(parFileOut.Data(), "RECREATE"); + // ------------------------------------------------------------------------ diff --git a/macro/beamtime/mcbm2020/mcbm_reco.C b/macro/beamtime/mcbm2020/mcbm_reco.C index 4087e633bedb1869853946f2bba0a842b5eba2fd..9f8847891c250e7d57892e17bfb0a9ba5bc8df52 100644 --- a/macro/beamtime/mcbm2020/mcbm_reco.C +++ b/macro/beamtime/mcbm2020/mcbm_reco.C @@ -18,6 +18,7 @@ void mcbm_reco(Int_t runId = 831, Int_t nTimeslices = 0) { TString myName = "mcbm_reco"; // this macro's name for screen output TString srcDir = gSystem->Getenv("VMCWORKDIR"); // top source directory TString paramDir = srcDir + "/macro/beamtime/mcbm2020/"; + TString parDir = srcDir + "/parameters"; // ------------------------------------------------------------------------ @@ -69,8 +70,6 @@ void mcbm_reco(Int_t runId = 831, Int_t nTimeslices = 0) { // ----- Local reconstruction in MUCH --------------------------------- Int_t flag = 1; - TString parDir = - TString(gSystem->Getenv("VMCWORKDIR")) + TString("/parameters"); TString muchDigiFile( parDir + "/much/much_v19c_mcbm_digi_sector.root"); // MUCH digi file CbmMuchFindHitsGem* muchFindHits = @@ -160,7 +159,39 @@ void mcbm_reco(Int_t runId = 831, Int_t nTimeslices = 0) { // ----- Local reconstruction in TOF ---------------------------------- // ------------------------------------------------------------------------ + // TOF defaults + Int_t calMode = 93; + Int_t calSel = 1; + Int_t calSm = 0; + Int_t RefSel = 0; + Double_t dDeadtime = 50.; + Int_t iSel2 = 500; + TString TofGeoTag = "v20f_mcbm"; + TString cCalId = "831.50.3.0"; + Int_t iCalSet = 12022500; // calibration settings + + TObjString* tofBdfFile = + new TObjString(parDir + "/tof/tof_" + TofGeoTag + ".digibdf.par"); + parFileList->Add(tofBdfFile); + std::cout << "-I- Using parameter file " << tofBdfFile->GetString() + << std::endl; + CbmTofEventClusterizer* tofCluster = + new CbmTofEventClusterizer("TOF Event Clusterizer", 0, 1); + TString cFname = parDir + "/tof/" + + Form("%s_set%09d_%02d_%01dtofClust.hst.root", + cCalId.Data(), + iCalSet, + calMode, + calSel); + tofCluster->SetCalParFileName(cFname); + tofCluster->SetCalMode(calMode); + tofCluster->SetCalSel(calSel); + tofCluster->PosYMaxScal(0.75); //in % of 2*length + tofCluster->SetChannelDeadtime(dDeadtime); // artificial deadtime in ns + + run->AddTask(tofCluster); + std::cout << "-I- Added task " << tofCluster->GetName() << std::endl; // ----- Local reconstruction of RICH Hits ------------------------------ CbmRichMCbmHitProducer* hitProdRich = new CbmRichMCbmHitProducer(); @@ -224,7 +255,7 @@ void mcbm_reco(Int_t runId = 831, Int_t nTimeslices = 0) { 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 " << parFileOut << std::endl; + std::cout << "Parameter file is " << parFile << std::endl; std::cout << "Real time " << rtime << " s, CPU time " << ctime << " s" << std::endl; std::cout << std::endl; diff --git a/macro/beamtime/mcbm2020/mtof_reco.C b/macro/beamtime/mcbm2020/mtof_reco.C index a130313784219a2da1d4519362f163dc847e2fa9..4ebc946d1360c7c04f5cfb1c98558359009822a5 100644 --- a/macro/beamtime/mcbm2020/mtof_reco.C +++ b/macro/beamtime/mcbm2020/mtof_reco.C @@ -114,7 +114,7 @@ void mtof_reco(Int_t nEvents = -1, // number of Timeslices run->SetInputFile(rawFile); run->SetOutputFile(recFile); run->SetGenerateRunInfo(kFALSE); - Bool_t hasFairMonitor = kFALSE; //Has_Fair_Monitor(); + Bool_t hasFairMonitor = Has_Fair_Monitor(); if (hasFairMonitor) FairMonitor::GetMonitor()->EnableMonitor(kTRUE); // ------------------------------------------------------------------------ diff --git a/reco/detectors/tof/CbmTofCalibrator.cxx b/reco/detectors/tof/CbmTofCalibrator.cxx index 9ff57c3cca2171d314d099bc34a209d53c43512f..0e7e718c468e62324db6239ee7d775f01b0297b3 100644 --- a/reco/detectors/tof/CbmTofCalibrator.cxx +++ b/reco/detectors/tof/CbmTofCalibrator.cxx @@ -543,7 +543,7 @@ Bool_t CbmTofCalibrator::UpdateCalHist(Int_t iOpt) { Double_t dBinSize = hpPy->GetBinWidth(1); dFLim = TMath::Max(dFLim, 5. * dBinSize); TFitResultPtr fRes = - hpPy->Fit("gaus", "S", "", dFMean - dFLim, dFMean + dFLim); + hpPy->Fit("gaus", "SQM0", "", dFMean - dFLim, dFMean + dFLim); dDp = fRes->Parameter(1); //overwrite mean // Double_t dDpRes = fRes->Parameter(2); if (iSmType == 5) // do not shift beam counter in time @@ -624,11 +624,13 @@ Bool_t CbmTofCalibrator::UpdateCalHist(Int_t iOpt) { } //switch( iOpt) end } - TFile* fCalParFileNew = - new TFile(Form("New_%s", fCalParFile->GetName()), "RECREATE"); - WriteHist(fCalParFileNew); - fCalParFileNew->Close(); - + TString fFile = fCalParFile->GetName(); + if (!fFile.Contains("/")) { + TFile* fCalParFileNew = + new TFile(Form("New_%s", fCalParFile->GetName()), "RECREATE"); + WriteHist(fCalParFileNew); + fCalParFileNew->Close(); + } return kTRUE; } diff --git a/reco/detectors/tof/CbmTofEventClusterizer.cxx b/reco/detectors/tof/CbmTofEventClusterizer.cxx index cc32cc309ddb923b3af06340868527d4730fc0e9..da71d351d7101f8ebad2dc020b0790e92d4454b1 100644 --- a/reco/detectors/tof/CbmTofEventClusterizer.cxx +++ b/reco/detectors/tof/CbmTofEventClusterizer.cxx @@ -420,7 +420,7 @@ void CbmTofEventClusterizer::Exec(Option_t* option) { LOG(debug) << cstr; new ((*fTofDigiMatchCollOut)[iNbHits]) CbmMatch(*mDigiMatch); - + delete mDigiMatch; iNbHits++; } //fTofDigisColl->Delete(); @@ -490,12 +490,13 @@ void CbmTofEventClusterizer::Finish() { // Prevent them from being sucked in by the CbmHadronAnalysis WriteHistograms method // DeleteHistos(); if (fdMemoryTime > 0.) CleanLHMemory(); + delete fDigiPar; } void CbmTofEventClusterizer::Finish(Double_t calMode) { if (fdEvent < 100) return; // don't save histos with insufficient statistics SetCalMode(calMode); - WriteHistos(); + Finish(); } /************************************************************************************/