diff --git a/macro/beamtime/FindPeaks.C b/macro/beamtime/FindPeaks.C new file mode 100644 index 0000000000000000000000000000000000000000..a48b5b52281e733202c13171a6b875add3fa7540 --- /dev/null +++ b/macro/beamtime/FindPeaks.C @@ -0,0 +1,96 @@ +// Illustrates how to find peaks in histograms. +// This script generates a random number of gaussian peaks +// on top of a linear background. +// The position of the peaks is found via TSpectrum and injected +// as initial values of parameters to make a global fit. +// The background is computed and drawn on top of the original histogram. +// +// To execute this example, do +// root > .x peaks.C (generate 10 peaks by default) +// root > .x peaks.C++ (use the compiler) +// root > .x peaks.C++(30) (generates 30 peaks) +// +// To execute only the first part of the script (without fitting) +// specify a negative value for the number of peaks, eg +// root > .x peaks.C(-20) +// +//Author: Rene Brun + +#include "TCanvas.h" +#include "TF1.h" +#include "TH1.h" +#include "TMath.h" +#include "TRandom.h" +#include "TSpectrum.h" +#include "TVirtualFitter.h" + +Int_t npeaks = 30; +Double_t fpeaks(Double_t* x, Double_t* par) { + Double_t result = par[0] + par[1] * x[0]; + for (Int_t p = 0; p < npeaks; p++) { + Double_t norm = par[3 * p + 2]; + Double_t mean = par[3 * p + 3]; + Double_t sigma = par[3 * p + 4]; + result += norm * TMath::Gaus(x[0], mean, sigma); + } + return result; +} + +void FindPeaks(Int_t np = 30, TString hname = "cl_SmT9_sm002_rpc001_rate") { + Double_t par[3000]; + TCanvas* c1 = new TCanvas("c1", "c1", 10, 10, 1000, 900); + c1->Divide(1, 2); + c1->cd(1); + TH1F* h = (TH1F*) gROOT->FindObjectAny(hname); + if (NULL == h) { + cout << " histo " << hname << " not found " << endl; + return; + } + h->Draw(); + TH1F* h2 = (TH1F*) h->Clone("h2"); + //Use TSpectrum to find the peak candidates + TSpectrum* s = new TSpectrum(2 * npeaks); + Int_t nfound = s->Search(h, 2, "", 0.10); + printf("Found %d candidate peaks to fit\n", nfound); + //Estimate background using TSpectrum::Background + TH1* hb = s->Background(h, 20, "same"); + if (hb) c1->Update(); + if (np < 0) return; + + //estimate linear background using a fitting method + c1->cd(2); + TF1* fline = new TF1("fline", "pol1", 0, 1000); + h->Fit("fline", "qn"); + //Loop on all found peaks. Eliminate peaks at the background level + par[0] = fline->GetParameter(0); + par[1] = fline->GetParameter(1); + npeaks = 0; + Double_t* xpeaks = s->GetPositionX(); + for (p = 0; p < nfound; p++) { + Double_t xp = xpeaks[p]; + Int_t bin = h->GetXaxis()->FindBin(xp); + Double_t yp = h->GetBinContent(bin); + if (yp - TMath::Sqrt(yp) < fline->Eval(xp)) continue; + par[3 * npeaks + 2] = yp; + par[3 * npeaks + 3] = xp; + par[3 * npeaks + 4] = 3; + npeaks++; + } + printf("Found %d useful peaks to fit\n", npeaks); + printf("Now fitting: Be patient\n"); + TF1* fit = new TF1("fit", fpeaks, 0, 1000, 2 + 3 * npeaks); + //we may have more than the default 25 parameters + TVirtualFitter::Fitter(h2, 10 + 3 * npeaks); + fit->SetParameters(par); + fit->SetNpx(1000); + h2->Fit("fit"); + + fit->GetParameters(par); + Double_t ypav = 0.; + for (p = 0; p < nfound; p++) { + ypav += par[3 * p + 2]; + } + ypav /= nfound; + cout << "average peak height in " << hname << " from " << nfound + << " peaks: " << ypav << endl; +} diff --git a/macro/beamtime/TutorialFindPeaks.C b/macro/beamtime/TutorialFindPeaks.C new file mode 100644 index 0000000000000000000000000000000000000000..a7371c60b442b4daa621e134c9258892a49c7a68 --- /dev/null +++ b/macro/beamtime/TutorialFindPeaks.C @@ -0,0 +1,97 @@ +// Illustrates how to find peaks in histograms. +// This script generates a random number of gaussian peaks +// on top of a linear background. +// The position of the peaks is found via TSpectrum and injected +// as initial values of parameters to make a global fit. +// The background is computed and drawn on top of the original histogram. +// +// To execute this example, do +// root > .x peaks.C (generate 10 peaks by default) +// root > .x peaks.C++ (use the compiler) +// root > .x peaks.C++(30) (generates 30 peaks) +// +// To execute only the first part of the script (without fitting) +// specify a negative value for the number of peaks, eg +// root > .x peaks.C(-20) +// +//Author: Rene Brun + +#include "TCanvas.h" +#include "TF1.h" +#include "TH1.h" +#include "TMath.h" +#include "TRandom.h" +#include "TSpectrum.h" +#include "TVirtualFitter.h" + +Int_t npeaks = 30; +Double_t fpeaks(Double_t* x, Double_t* par) { + Double_t result = par[0] + par[1] * x[0]; + for (Int_t p = 0; p < npeaks; p++) { + Double_t norm = par[3 * p + 2]; + Double_t mean = par[3 * p + 3]; + Double_t sigma = par[3 * p + 4]; + result += norm * TMath::Gaus(x[0], mean, sigma); + } + return result; +} + +void TutorialFindPeaks(Int_t np = 10) { + npeaks = TMath::Abs(np); + TH1F* h = new TH1F("h", "test", 500, 0, 1000); + //generate n peaks at random + Double_t par[3000]; + par[0] = 0.8; + par[1] = -0.6 / 1000; + Int_t p; + for (p = 0; p < npeaks; p++) { + par[3 * p + 2] = 1; + par[3 * p + 3] = 10 + gRandom->Rndm() * 980; + par[3 * p + 4] = 3 + 2 * gRandom->Rndm(); + } + TF1* f = new TF1("f", fpeaks, 0, 1000, 2 + 3 * npeaks); + f->SetNpx(1000); + f->SetParameters(par); + TCanvas* c1 = new TCanvas("c1", "c1", 10, 10, 1000, 900); + c1->Divide(1, 2); + c1->cd(1); + h->FillRandom("f", 200000); + h->Draw(); + TH1F* h2 = (TH1F*) h->Clone("h2"); + //Use TSpectrum to find the peak candidates + TSpectrum* s = new TSpectrum(2 * npeaks); + Int_t nfound = s->Search(h, 2, "", 0.10); + printf("Found %d candidate peaks to fit\n", nfound); + //Estimate background using TSpectrum::Background + TH1* hb = s->Background(h, 20, "same"); + if (hb) c1->Update(); + if (np < 0) return; + + //estimate linear background using a fitting method + c1->cd(2); + TF1* fline = new TF1("fline", "pol1", 0, 1000); + h->Fit("fline", "qn"); + //Loop on all found peaks. Eliminate peaks at the background level + par[0] = fline->GetParameter(0); + par[1] = fline->GetParameter(1); + npeaks = 0; + Double_t* xpeaks = s->GetPositionX(); + for (p = 0; p < nfound; p++) { + Double_t xp = xpeaks[p]; + Int_t bin = h->GetXaxis()->FindBin(xp); + Double_t yp = h->GetBinContent(bin); + if (yp - TMath::Sqrt(yp) < fline->Eval(xp)) continue; + par[3 * npeaks + 2] = yp; + par[3 * npeaks + 3] = xp; + par[3 * npeaks + 4] = 3; + npeaks++; + } + printf("Found %d useful peaks to fit\n", npeaks); + printf("Now fitting: Be patient\n"); + TF1* fit = new TF1("fit", fpeaks, 0, 1000, 2 + 3 * npeaks); + //we may have more than the default 25 parameters + TVirtualFitter::Fitter(h2, 10 + 3 * npeaks); + fit->SetParameters(par); + fit->SetNpx(1000); + h2->Fit("fit"); +} diff --git a/macro/beamtime/cosy2018/AnalyseTimeCoincidenceBugAllCases2elinks.C b/macro/beamtime/cosy2018/AnalyseTimeCoincidenceBugAllCases2elinks.C index c0c6df76d8232540d4c574961dfd2ea5417bf545..db234b8b512b18049a99bcac6c61702f5e5ecca5 100644 --- a/macro/beamtime/cosy2018/AnalyseTimeCoincidenceBugAllCases2elinks.C +++ b/macro/beamtime/cosy2018/AnalyseTimeCoincidenceBugAllCases2elinks.C @@ -18,7 +18,7 @@ void save_plot_to_pdf(TH1* plot, + TString(Form("_%uch_%uch", uNbChanFixed[uFile], uNbChanScan[uFile])), canv->GetTitle() + TString( - Form(", %u ch, %u ch", uNbChanFixed[uFile], uNbChanScan[uFile]))); + Form(", %u ch, %u ch", uNbChanFixed[uFile], uNbChanScan[uFile]))); gStyle->SetOptStat(0); gStyle->SetPalette(105); plot->GetXaxis()->SetRangeUser(-1000, 996); @@ -44,7 +44,7 @@ void save_plotstack_to_pdf(THStack* plot, + TString(Form("_%uch_%uch", uNbChanFixed[uFile], uNbChanScan[uFile])), canv->GetTitle() + TString( - Form(", %u ch, %u ch", uNbChanFixed[uFile], uNbChanScan[uFile]))); + Form(", %u ch, %u ch", uNbChanFixed[uFile], uNbChanScan[uFile]))); gStyle->SetOptStat(0); gStyle->SetPalette(105); //plot->GetXaxis()->SetRangeUser(-1000, 996); diff --git a/macro/beamtime/cosy2018/AnalyseTimeCoincidenceBugAllCases5elinks.C b/macro/beamtime/cosy2018/AnalyseTimeCoincidenceBugAllCases5elinks.C index 7298a1fe9da9ac37ace20745bafbbb2b06ca00db..4aee241aae4cfbe0f5554480e7f79d6a3c3389c0 100644 --- a/macro/beamtime/cosy2018/AnalyseTimeCoincidenceBugAllCases5elinks.C +++ b/macro/beamtime/cosy2018/AnalyseTimeCoincidenceBugAllCases5elinks.C @@ -18,7 +18,7 @@ void save_plot_to_pdf(TH1* plot, + TString(Form("_%uch_%uch", uNbChanFixed[uFile], uNbChanScan[uFile])), canv->GetTitle() + TString( - Form(", %u ch, %u ch", uNbChanFixed[uFile], uNbChanScan[uFile]))); + Form(", %u ch, %u ch", uNbChanFixed[uFile], uNbChanScan[uFile]))); gStyle->SetOptStat(0); gStyle->SetPalette(105); plot->GetXaxis()->SetRangeUser(-1000, 996); @@ -44,7 +44,7 @@ void save_plotstack_to_pdf(THStack* plot, + TString(Form("_%uch_%uch", uNbChanFixed[uFile], uNbChanScan[uFile])), canv->GetTitle() + TString( - Form(", %u ch, %u ch", uNbChanFixed[uFile], uNbChanScan[uFile]))); + Form(", %u ch, %u ch", uNbChanFixed[uFile], uNbChanScan[uFile]))); gStyle->SetOptStat(0); gStyle->SetPalette(105); //plot->GetXaxis()->SetRangeUser(-1000, 996); diff --git a/macro/beamtime/cosy2018/AnalyseTimeCoincidenceBugAllCasesMoreCond.C b/macro/beamtime/cosy2018/AnalyseTimeCoincidenceBugAllCasesMoreCond.C index 36996a26edaa051120aa12879c50624db6cf1314..f8dd4bde8624aa0dedb2f8305aa85f23ee15f8a1 100644 --- a/macro/beamtime/cosy2018/AnalyseTimeCoincidenceBugAllCasesMoreCond.C +++ b/macro/beamtime/cosy2018/AnalyseTimeCoincidenceBugAllCasesMoreCond.C @@ -18,7 +18,7 @@ void save_plot_to_pdf(TH1* plot, + TString(Form("_%uch_%uch", uNbChanFixed[uFile], uNbChanScan[uFile])), canv->GetTitle() + TString( - Form(", %u ch, %u ch", uNbChanFixed[uFile], uNbChanScan[uFile]))); + Form(", %u ch, %u ch", uNbChanFixed[uFile], uNbChanScan[uFile]))); gStyle->SetOptStat(0); gStyle->SetPalette(105); plot->GetXaxis()->SetRangeUser(-1000, 996); @@ -44,7 +44,7 @@ void save_plotstack_to_pdf(THStack* plot, + TString(Form("_%uch_%uch", uNbChanFixed[uFile], uNbChanScan[uFile])), canv->GetTitle() + TString( - Form(", %u ch, %u ch", uNbChanFixed[uFile], uNbChanScan[uFile]))); + Form(", %u ch, %u ch", uNbChanFixed[uFile], uNbChanScan[uFile]))); gStyle->SetOptStat(0); gStyle->SetPalette(105); //plot->GetXaxis()->SetRangeUser(-1000, 996); diff --git a/macro/beamtime/mcbm2018/ana_trks.C b/macro/beamtime/mcbm2018/ana_trks.C index 08b1e823e14bfd2cd449e955cb0713fa0171a961..955db30d8bbcb7625b2673d4fb0f8fc76b7a3809 100644 --- a/macro/beamtime/mcbm2018/ana_trks.C +++ b/macro/beamtime/mcbm2018/ana_trks.C @@ -35,16 +35,16 @@ void ana_trks(Int_t nEvents = 10000, TString cHstFile = paramDir + Form( - "/hst/%s_%03.0f_%s_%06d_%03d_%03.1f_%03.1f_trk%03d_Cal%s_Ana.hst.root", - cFileId.Data(), - dDeadtime, - cSet.Data(), - iSel, - iSel2, - dScalFac, - dChi2Lim2, - iTrackingSetup, - cCalId.Data()); + "/hst/%s_%03.0f_%s_%06d_%03d_%03.1f_%03.1f_trk%03d_Cal%s_Ana.hst.root", + cFileId.Data(), + dDeadtime, + cSet.Data(), + iSel, + iSel2, + dScalFac, + dChi2Lim2, + iTrackingSetup, + cCalId.Data()); TString cTrkFile = Form("%s_tofFindTracks.hst.root", cCalId.Data()); TString cAnaFile = Form("%s_TrkAnaTestBeam.hst.root", cCalId.Data()); diff --git a/macro/beamtime/mcbm2020/ana_digi_cal.C b/macro/beamtime/mcbm2020/ana_digi_cal.C index 1dc8ea4ef2b62322e3609ca7caac19dd4e65623c..0fb822f75bdb80ac4b83acbb32bb54283c931f81 100644 --- a/macro/beamtime/mcbm2020/ana_digi_cal.C +++ b/macro/beamtime/mcbm2020/ana_digi_cal.C @@ -46,12 +46,11 @@ void ana_digi_cal(Int_t nEvents = 10000000, TList* parFileList = new TList(); TString FId = cFileId; - TString TofGeo = "v19b_mcbm"; + TString TofGeo = "v20b_mcbm"; cout << "Geometry version " << TofGeo << endl; - TObjString* tofDigiFile = new TObjString( - workDir + "/parameters/tof/tof_" + TofGeo + ".digi.par"); // TOF digi file - parFileList->Add(tofDigiFile); + // TObjString *tofDigiFile = new TObjString(workDir + "/parameters/tof/tof_" + TofGeo + ".digi.par"); // TOF digi file + // parFileList->Add(tofDigiFile); // TObjString tofDigiBdfFile = new TObjString( paramDir + "/tof." + FPar + "digibdf.par"); TObjString* tofDigiBdfFile = diff --git a/macro/beamtime/mcbm2020/ana_digi_cal_all.C b/macro/beamtime/mcbm2020/ana_digi_cal_all.C index 3f672f7c09669de9599dd28171f8eed511e09370..bc09ffb9b44cdba1cb6cf77eb330f0eb9924f36a 100644 --- a/macro/beamtime/mcbm2020/ana_digi_cal_all.C +++ b/macro/beamtime/mcbm2020/ana_digi_cal_all.C @@ -22,7 +22,7 @@ void ana_digi_cal_all(Int_t nEvents = 10000000, //TString logLevel = "DEBUG3"; FairLogger::GetLogger(); gLogger->SetLogScreenLevel(logLevel); - gLogger->SetLogVerbosityLevel("MEDIUM"); + gLogger->SetLogVerbosityLevel("VERYHIGH"); TString workDir = gSystem->Getenv("VMCWORKDIR"); /* @@ -46,12 +46,11 @@ void ana_digi_cal_all(Int_t nEvents = 10000000, TList* parFileList = new TList(); TString FId = cFileId; - TString TofGeo = "v20a_mcbm"; + TString TofGeo = "v20b_mcbm"; cout << "Geometry version " << TofGeo << endl; - TObjString* tofDigiFile = new TObjString( - workDir + "/parameters/tof/tof_" + TofGeo + ".digi.par"); // TOF digi file - parFileList->Add(tofDigiFile); + // TObjString *tofDigiFile = new TObjString(workDir + "/parameters/tof/tof_" + TofGeo + ".digi.par"); // TOF digi file + // parFileList->Add(tofDigiFile); // TObjString tofDigiBdfFile = new TObjString( paramDir + "/tof." + FPar + "digibdf.par"); TObjString* tofDigiBdfFile = diff --git a/macro/beamtime/mcbm2020/ana_trks.C b/macro/beamtime/mcbm2020/ana_trks.C index 44b61897cbeb0c7908ecd0b76e566827e0519a6f..16dbc7077f69442774ef538ca067bc6826690e7f 100644 --- a/macro/beamtime/mcbm2020/ana_trks.C +++ b/macro/beamtime/mcbm2020/ana_trks.C @@ -12,9 +12,13 @@ void ana_trks(Int_t nEvents = 10000, Int_t iAnaCor = 1, Bool_t bUseSigCalib = kFALSE, Int_t iCalSet = 30040500, - Int_t iCalOpt = 1) { + Int_t iCalOpt = 1, + Int_t iMc = 0) { Int_t iVerbose = 1; if (cCalId == "") cCalId = cFileId; + TString FId = cFileId; + TString cRun(FId(0, 3)); + Int_t iRun = cRun.Atoi(); // Specify log level (INFO, DEBUG, DEBUG1, ...) //TString logLevel = "FATAL"; //TString logLevel = "ERROR"; @@ -26,27 +30,33 @@ void ana_trks(Int_t nEvents = 10000, TString workDir = gSystem->Getenv("VMCWORKDIR"); TString paramDir = workDir + "/macro/beamtime/mcbm2020"; //TString paramDir = "."; + TString ParFile = paramDir + "/data/" + cFileId.Data() + ".params.root"; TString InputFile = paramDir + "/data/" + cFileId.Data() + ".root"; TString InputDigiFile = paramDir + "/data/digidev_" + cFileId.Data() + Form("_%s_%02.0f_Cal", cSet.Data(), dDeadtime) + cCalId + ".out.root"; + if (iMc == 1) { + InputFile = paramDir + "/data/" + cFileId.Data() + ".raw.root"; + InputDigiFile = paramDir + "/data/" + cFileId.Data() + ".rec.root"; + iRun = 700; + } TString OutputFile = paramDir + "/data/hits_" + cFileId.Data() + Form("_%s_%06d_%03d", cSet.Data(), iSel, iSel2) + ".out.root"; TString cHstFile = paramDir + Form( - "/hst/%s_%03.0f_%s_%06d_%03d_%03.1f_%03.1f_trk%03d_Cal%s_Ana.hst.root", - cFileId.Data(), - dDeadtime, - cSet.Data(), - iSel, - iSel2, - dScalFac, - dChi2Lim2, - iTrackingSetup, - cCalId.Data()); + "/hst/%s_%03.0f_%s_%06d_%03d_%03.1f_%03.1f_trk%03d_Cal%s_Ana.hst.root", + cFileId.Data(), + dDeadtime, + cSet.Data(), + iSel, + iSel2, + dScalFac, + dChi2Lim2, + iTrackingSetup, + cCalId.Data()); TString cTrkFile = Form("%s_tofFindTracks.hst.root", cCalId.Data()); TString cAnaFile = Form("%s_TrkAnaTestBeam.hst.root", cFileId.Data()); @@ -57,27 +67,38 @@ void ana_trks(Int_t nEvents = 10000, TList* parFileList = new TList(); - TString TofGeo = "v19b_mcbm"; //default - - cout << "Geometry version " << TofGeo << endl; - - TObjString* tofDigiFile = new TObjString( - workDir + "/parameters/tof/tof_" + TofGeo + ".digi.par"); // TOF digi file - parFileList->Add(tofDigiFile); - - // TObjString tofDigiBdfFile = paramDir + "/tof.digibdf.par"; - // TObjString tofDigiBdfFile = paramDir + "/tof." + FPar + "digibdf.par"; - TObjString* tofDigiBdfFile = - new TObjString(workDir + "/parameters/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; + Int_t iGeo = 0; //iMc; + if (iGeo == 0) { + TString TofGeo = ""; + if (iRun < 690) + TofGeo = "v20a_mcbm"; + else + TofGeo = "v20b_mcbm"; + cout << "Geometry version " << TofGeo << endl; + + TObjString* tofDigiBdfFile = + new TObjString(workDir + "/parameters/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; + } + } else { + TString setupName = "mcbm_beam_2020_03"; + // ----- Load the geometry setup ------------------------------------- + TString setupFile = + workDir + "/geometry/setup/setup_" + setupName.Data() + ".C"; + TString setupFunct = "setup_"; + setupFunct = setupFunct + setupName + "()"; + std::cout << "-I- Loading macro " << setupFile << std::endl; + gROOT->LoadMacro(setupFile); + gROOT->ProcessLine(setupFunct); + CbmSetup* setup = CbmSetup::Instance(); } // ----- Reconstruction run ------------------------------------------- @@ -89,10 +110,12 @@ void ana_trks(Int_t nEvents = 10000, //run->AddFriend(InputDigiFile.Data()); run->SetInputFile(InputDigiFile.Data()); //run->AddFriend(InputFile.Data()); - run->SetOutputFile(OutputFile); + //run->SetOutputFile(OutputFile); + run->SetUserOutputFileName(OutputFile.Data()); + run->SetSink(new FairRootFileSink(run->GetUserOutputFileName())); FairLogger::GetLogger()->SetLogScreenLevel(logLevel.Data()); - FairLogger::GetLogger()->SetLogVerbosityLevel("MEDIUM"); + FairLogger::GetLogger()->SetLogVerbosityLevel("VERYHIGH"); // ----- Local selection variables ------------------------------------------- @@ -141,8 +164,6 @@ void ana_trks(Int_t nEvents = 10000, // ========================================================================= // === Tracking === // ========================================================================= - CbmStsDigitize* stsDigitize = new CbmStsDigitize(); //necessary for kalman !! - CbmKF* kalman = new CbmKF(); CbmTofTrackFinder* tofTrackFinder = new CbmTofTrackFinderNN(); tofTrackFinder->SetMaxTofTimeDifference(0.2); // in ns/cm @@ -168,11 +189,15 @@ void ana_trks(Int_t nEvents = 10000, CbmTofFindTracks* tofFindTracks = new CbmTofFindTracks("TOF Track Finder"); tofFindTracks->UseFinder(tofTrackFinder); tofFindTracks->UseFitter(tofTrackFitter); - tofFindTracks->SetCalOpt(iCalOpt); // 1 - update offsets + 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.055); // target value for Dec2019 - //tofFindTracks->SetTtTarg(0.051); // target value Nov2019 - //tofFindTracks->SetTtTarg(0.035); // target value for inverse velocity, > 0.033 ns/cm! + tofFindTracks->SetTtTarg( + 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 @@ -190,7 +215,6 @@ void ana_trks(Int_t nEvents = 10000, * 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; @@ -244,37 +268,36 @@ void ana_trks(Int_t nEvents = 10000, case 2: iMinNofHits = 3; - iNStations = 29; - iNReqStations = 3; - tofFindTracks->SetStation(1, 0, 2, 2); + 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, 0, 2); - tofFindTracks->SetStation(4, 0, 2, 1); + tofFindTracks->SetStation(3, 0, 2, 1); + tofFindTracks->SetStation(4, 0, 0, 1); tofFindTracks->SetStation(5, 0, 1, 1); - tofFindTracks->SetStation(6, 0, 0, 1); - tofFindTracks->SetStation(7, 0, 2, 3); + tofFindTracks->SetStation(6, 0, 2, 3); + tofFindTracks->SetStation(7, 0, 0, 3); tofFindTracks->SetStation(8, 0, 1, 3); - tofFindTracks->SetStation(9, 0, 0, 3); - tofFindTracks->SetStation(10, 0, 2, 0); + tofFindTracks->SetStation(9, 0, 2, 0); + tofFindTracks->SetStation(10, 0, 0, 0); tofFindTracks->SetStation(11, 0, 1, 0); - tofFindTracks->SetStation(12, 0, 0, 0); - tofFindTracks->SetStation(13, 0, 2, 4); + tofFindTracks->SetStation(12, 0, 2, 4); + tofFindTracks->SetStation(13, 0, 0, 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); - tofFindTracks->SetStation(28, 6, 0, 0); - tofFindTracks->SetStation(0, 6, 0, 1); + 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: @@ -402,6 +425,7 @@ void ana_trks(Int_t nEvents = 10000, tofFindTracks->SetStation(1, 0, 1, 2); tofFindTracks->SetStation(2, 0, 0, 2); tofFindTracks->SetStation(3, 0, 2, 2); + break; default: cout << "Tracking setup " << iTrackingSetup << " not implemented " @@ -424,6 +448,10 @@ void ana_trks(Int_t nEvents = 10000, 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 @@ -481,7 +509,7 @@ void ana_trks(Int_t nEvents = 10000, tofAnaTestbeam->SetBeamRefSmId(iRSelSm); tofAnaTestbeam->SetBeamRefRpc(iRSelRpc); - if (iSel2 >= 0) { + if (iSel2 >= -1) { tofAnaTestbeam->SetMrpcSel2( iSel2); // initialization of second selector Mrpc Type tofAnaTestbeam->SetMrpcSel2Sm( @@ -490,6 +518,9 @@ void ana_trks(Int_t nEvents = 10000, 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 @@ -499,6 +530,7 @@ void ana_trks(Int_t nEvents = 10000, cout << "dispatch iSel = " << iSel << ", iSel2in = " << iSel2in << ", iRSelin = " << iRSelin << ", iRSel = " << iRSel << endl; + if (1) { switch (iSel) { diff --git a/macro/beamtime/mcbm2020/ana_trks_eval.C b/macro/beamtime/mcbm2020/ana_trks_eval.C index 5e7d0bb7e603c0c36d4af0a63161978b0e8c3d53..8ebdeaafc5e27487a0ac0dc382e2a868d0e56412 100644 --- a/macro/beamtime/mcbm2020/ana_trks_eval.C +++ b/macro/beamtime/mcbm2020/ana_trks_eval.C @@ -12,9 +12,13 @@ void ana_trks_eval(Int_t nEvents = 10000, Int_t iAnaCor = 1, Bool_t bUseSigCalib = kFALSE, Int_t iCalSet = 30040500, - Int_t iCalOpt = 1) { + Int_t iCalOpt = 1, + Int_t iMc = 0) { Int_t iVerbose = 1; if (cCalId == "") cCalId = cFileId; + TString FId = cFileId; + TString cRun(FId(0, 3)); + Int_t iRun = cRun.Atoi(); // Specify log level (INFO, DEBUG, DEBUG1, ...) //TString logLevel = "FATAL"; //TString logLevel = "ERROR"; @@ -23,30 +27,36 @@ void ana_trks_eval(Int_t nEvents = 10000, //TString logLevel = "DEBUG1"; //TString logLevel = "DEBUG2"; //TString logLevel = "DEBUG3"; - TString workDir = gSystem->Getenv("VMCWORKDIR"); - //TString paramDir = workDir + "/macro/beamtime/mcbm2020"; - TString paramDir = "."; + TString workDir = gSystem->Getenv("VMCWORKDIR"); + TString paramDir = workDir + "/macro/beamtime/mcbm2020"; + //TString paramDir = "."; + TString ParFile = paramDir + "/data/" + cFileId.Data() + ".params.root"; TString InputFile = paramDir + "/data/" + cFileId.Data() + ".root"; TString InputDigiFile = paramDir + "/data/digidev_" + cFileId.Data() + Form("_%s_%02.0f_Cal", cSet.Data(), dDeadtime) + cCalId + ".out.root"; + if (iMc == 1) { + InputFile = paramDir + "/data/" + cFileId.Data() + ".raw.root"; + InputDigiFile = paramDir + "/data/" + cFileId.Data() + ".rec.root"; + iRun = 700; + } TString OutputFile = paramDir + "/data/hits_" + cFileId.Data() + Form("_%s_%06d_%03d", cSet.Data(), iSel, iSel2) + ".out.root"; TString cHstFile = paramDir + Form( - "/hst/%s_%03.0f_%s_%06d_%03d_%03.1f_%03.1f_trk%03d_Cal%s_Ana.hst.root", - cFileId.Data(), - dDeadtime, - cSet.Data(), - iSel, - iSel2, - dScalFac, - dChi2Lim2, - iTrackingSetup, - cCalId.Data()); + "/hst/%s_%03.0f_%s_%06d_%03d_%03.1f_%03.1f_trk%03d_Cal%s_Ana.hst.root", + cFileId.Data(), + dDeadtime, + cSet.Data(), + iSel, + iSel2, + dScalFac, + dChi2Lim2, + iTrackingSetup, + cCalId.Data()); TString cTrkFile = Form("%s_tofFindTracks.hst.root", cCalId.Data()); TString cAnaFile = Form("%s_TrkAnaTestBeam.hst.root", cFileId.Data()); @@ -57,27 +67,38 @@ void ana_trks_eval(Int_t nEvents = 10000, TList* parFileList = new TList(); - TString TofGeo = "v19b_mcbm"; //default - - cout << "Geometry version " << TofGeo << endl; - - TObjString* tofDigiFile = new TObjString( - workDir + "/parameters/tof/tof_" + TofGeo + ".digi.par"); // TOF digi file - parFileList->Add(tofDigiFile); - - // TObjString tofDigiBdfFile = paramDir + "/tof.digibdf.par"; - // TObjString tofDigiBdfFile = paramDir + "/tof." + FPar + "digibdf.par"; - TObjString* tofDigiBdfFile = - new TObjString(workDir + "/parameters/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; + Int_t iGeo = 0; + if (iGeo == 0) { + TString TofGeo = ""; + if (iRun < 690) + TofGeo = "v20a_mcbm"; + else + TofGeo = "v20b_mcbm"; + cout << "Geometry version " << TofGeo << endl; + + TObjString* tofDigiBdfFile = + new TObjString(workDir + "/parameters/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; + } + } else { + TString setupName = "mcbm_beam_2020_03"; + // ----- Load the geometry setup ------------------------------------- + TString setupFile = + workDir + "/geometry/setup/setup_" + setupName.Data() + ".C"; + TString setupFunct = "setup_"; + setupFunct = setupFunct + setupName + "()"; + std::cout << "-I- Loading macro " << setupFile << std::endl; + gROOT->LoadMacro(setupFile); + gROOT->ProcessLine(setupFunct); + CbmSetup* setup = CbmSetup::Instance(); } // ----- Reconstruction run ------------------------------------------- @@ -89,10 +110,12 @@ void ana_trks_eval(Int_t nEvents = 10000, //run->AddFriend(InputDigiFile.Data()); run->SetInputFile(InputDigiFile.Data()); //run->AddFriend(InputFile.Data()); - run->SetOutputFile(OutputFile); + //run->SetOutputFile(OutputFile); + run->SetUserOutputFileName(OutputFile.Data()); + run->SetSink(new FairRootFileSink(run->GetUserOutputFileName())); FairLogger::GetLogger()->SetLogScreenLevel(logLevel.Data()); - FairLogger::GetLogger()->SetLogVerbosityLevel("MEDIUM"); + FairLogger::GetLogger()->SetLogVerbosityLevel("VERYHIGH"); // ----- Local selection variables ------------------------------------------- @@ -141,8 +164,6 @@ void ana_trks_eval(Int_t nEvents = 10000, // ========================================================================= // === Tracking === // ========================================================================= - CbmStsDigitize* stsDigitize = new CbmStsDigitize(); //necessary for kalman !! - CbmKF* kalman = new CbmKF(); CbmTofTrackFinder* tofTrackFinder = new CbmTofTrackFinderNN(); tofTrackFinder->SetMaxTofTimeDifference(0.2); // in ns/cm @@ -168,11 +189,15 @@ void ana_trks_eval(Int_t nEvents = 10000, CbmTofFindTracks* tofFindTracks = new CbmTofFindTracks("TOF Track Finder"); tofFindTracks->UseFinder(tofTrackFinder); tofFindTracks->UseFitter(tofTrackFitter); - tofFindTracks->SetCalOpt(iCalOpt); // 1 - update offsets + 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.055); // target value for Dec2019 - //tofFindTracks->SetTtTarg(0.051); // target value Nov2019 - //tofFindTracks->SetTtTarg(0.035); // target value for inverse velocity, > 0.033 ns/cm! + tofFindTracks->SetTtTarg( + 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 @@ -190,7 +215,6 @@ void ana_trks_eval(Int_t nEvents = 10000, * 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; @@ -244,37 +268,36 @@ void ana_trks_eval(Int_t nEvents = 10000, case 2: iMinNofHits = 3; - iNStations = 29; - iNReqStations = 3; - tofFindTracks->SetStation(1, 0, 2, 2); + 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, 0, 2); - tofFindTracks->SetStation(4, 0, 2, 1); + tofFindTracks->SetStation(3, 0, 2, 1); + tofFindTracks->SetStation(4, 0, 0, 1); tofFindTracks->SetStation(5, 0, 1, 1); - tofFindTracks->SetStation(6, 0, 0, 1); - tofFindTracks->SetStation(7, 0, 2, 3); + tofFindTracks->SetStation(6, 0, 2, 3); + tofFindTracks->SetStation(7, 0, 0, 3); tofFindTracks->SetStation(8, 0, 1, 3); - tofFindTracks->SetStation(9, 0, 0, 3); - tofFindTracks->SetStation(10, 0, 2, 0); + tofFindTracks->SetStation(9, 0, 2, 0); + tofFindTracks->SetStation(10, 0, 0, 0); tofFindTracks->SetStation(11, 0, 1, 0); - tofFindTracks->SetStation(12, 0, 0, 0); - tofFindTracks->SetStation(13, 0, 2, 4); + tofFindTracks->SetStation(12, 0, 2, 4); + tofFindTracks->SetStation(13, 0, 0, 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); - tofFindTracks->SetStation(28, 6, 0, 0); - tofFindTracks->SetStation(0, 6, 0, 1); + 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: @@ -326,50 +349,26 @@ void ana_trks_eval(Int_t nEvents = 10000, tofFindTracks->SetStation(3, 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); + iMinNofHits = 4; + iNStations = 5; + iNReqStations = 5; 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, iDut, iDutSm, iDutRpc); break; - case 6: // for double stack USTC counter evaluation - iMinNofHits = 5; - iNStations = 6; - iNReqStations = 6; + case 6: // for double stack USTC counter 900 evaluation + iMinNofHits = 4; + iNStations = 5; + iNReqStations = 5; 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); + tofFindTracks->SetStation(1, 0, 4, 1); + tofFindTracks->SetStation(2, 0, 3, 1); + tofFindTracks->SetStation(3, 9, 0, 1); + tofFindTracks->SetStation(4, iDut, iDutSm, iDutRpc); break; case 7: // for double stack USTC counter evaluation @@ -394,7 +393,37 @@ void ana_trks_eval(Int_t nEvents = 10000, tofFindTracks->SetStation(5, iDut, iDutSm, iDutRpc); break; + case 9: + iMinNofHits = 3; + iNStations = 4; + iNReqStations = 4; + tofFindTracks->SetStation(0, 5, 0, 0); + tofFindTracks->SetStation(1, 0, 2, 1); + tofFindTracks->SetStation(2, 0, 0, 1); + tofFindTracks->SetStation(3, 0, 1, 1); + break; + case 10: + iMinNofHits = 3; + iNStations = 4; + iNReqStations = 4; + tofFindTracks->SetStation(0, 5, 0, 0); + tofFindTracks->SetStation(1, 0, 1, 0); + tofFindTracks->SetStation(2, 0, 0, 0); + tofFindTracks->SetStation(3, 0, 2, 0); + break; + + case 11: + iMinNofHits = 3; + iNStations = 4; + iNReqStations = 4; + tofFindTracks->SetStation(0, 5, 0, 0); + tofFindTracks->SetStation(1, 0, 1, 1); + tofFindTracks->SetStation(2, 0, 0, 1); + tofFindTracks->SetStation(3, 0, 2, 1); + break; + + case 12: iMinNofHits = 3; iNStations = 4; iNReqStations = 4; @@ -402,6 +431,77 @@ void ana_trks_eval(Int_t nEvents = 10000, tofFindTracks->SetStation(1, 0, 1, 2); tofFindTracks->SetStation(2, 0, 0, 2); tofFindTracks->SetStation(3, 0, 2, 2); + break; + + case 13: + iMinNofHits = 3; + iNStations = 4; + iNReqStations = 4; + tofFindTracks->SetStation(0, 5, 0, 0); + tofFindTracks->SetStation(1, 0, 1, 3); + tofFindTracks->SetStation(2, 0, 0, 3); + tofFindTracks->SetStation(3, 0, 2, 3); + break; + + case 14: + iMinNofHits = 3; + iNStations = 4; + iNReqStations = 4; + tofFindTracks->SetStation(0, 5, 0, 0); + tofFindTracks->SetStation(1, 0, 1, 4); + tofFindTracks->SetStation(2, 0, 0, 4); + tofFindTracks->SetStation(3, 0, 2, 4); + break; + + case 20: + iMinNofHits = 3; + iNStations = 4; + iNReqStations = 4; + tofFindTracks->SetStation(0, 0, 2, 0); + tofFindTracks->SetStation(1, 0, 0, 0); + tofFindTracks->SetStation(2, 0, 1, 0); + tofFindTracks->SetStation(0, 5, 0, 0); + break; + + case 21: + iMinNofHits = 3; + iNStations = 4; + iNReqStations = 4; + tofFindTracks->SetStation(0, 0, 2, 1); + tofFindTracks->SetStation(1, 0, 0, 1); + tofFindTracks->SetStation(2, 0, 1, 1); + tofFindTracks->SetStation(0, 5, 0, 0); + break; + + case 22: + iMinNofHits = 3; + iNStations = 4; + iNReqStations = 4; + tofFindTracks->SetStation(0, 0, 2, 2); + tofFindTracks->SetStation(1, 0, 0, 2); + tofFindTracks->SetStation(2, 0, 1, 2); + tofFindTracks->SetStation(0, 5, 0, 0); + break; + + case 23: + iMinNofHits = 3; + iNStations = 4; + iNReqStations = 4; + tofFindTracks->SetStation(0, 0, 2, 3); + tofFindTracks->SetStation(1, 0, 0, 3); + tofFindTracks->SetStation(2, 0, 1, 3); + tofFindTracks->SetStation(0, 5, 0, 0); + break; + + case 24: + iMinNofHits = 3; + iNStations = 4; + iNReqStations = 4; + tofFindTracks->SetStation(0, 0, 2, 4); + tofFindTracks->SetStation(1, 0, 0, 4); + tofFindTracks->SetStation(2, 0, 1, 4); + tofFindTracks->SetStation(0, 5, 0, 0); + break; default: cout << "Tracking setup " << iTrackingSetup << " not implemented " @@ -423,7 +523,11 @@ void ana_trks_eval(Int_t nEvents = 10000, tofAnaTestbeam->SetCorMode(iAnaCor); // 1 - DTD4, 2 - X4, 3 - Y4, 4 - Texp tofAnaTestbeam->SetHitDistMin(30.); // initialization tofAnaTestbeam->SetEnableMatchPosScaling(kTRUE); - tofAnaTestbeam->SetSpillDuration(9.); + 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 @@ -490,6 +594,9 @@ void ana_trks_eval(Int_t nEvents = 10000, 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 @@ -499,6 +606,7 @@ void ana_trks_eval(Int_t nEvents = 10000, cout << "dispatch iSel = " << iSel << ", iSel2in = " << iSel2in << ", iRSelin = " << iRSelin << ", iRSel = " << iRSel << endl; + if (1) { switch (iSel) { @@ -518,9 +626,41 @@ void ana_trks_eval(Int_t nEvents = 10000, } break; - case 700040: - case 900040: - case 901040: + case 10020: + case 11021: + case 12022: + case 13023: + case 14024: + switch (iRSelin) { + case 500: + tofAnaTestbeam->SetTShift(4.8); // Shift DTD4 to 0 + tofAnaTestbeam->SetTOffD4(11.); // Shift DTD4 to physical value + + switch (iSel2in) { + case 0: + tofAnaTestbeam->SetSel2TOff(0.); // Shift Sel2 time peak to 0 + break; + case 1: + tofAnaTestbeam->SetSel2TOff(0.0); // Shift Sel2 time peak to 0 + break; + case 2: + tofAnaTestbeam->SetSel2TOff(0.0); // Shift Sel2 time peak to 0 + break; + case 3: + tofAnaTestbeam->SetSel2TOff(0.0); // Shift Sel2 time peak to 0 + break; + case 4: + tofAnaTestbeam->SetSel2TOff(0.0); // Shift Sel2 time peak to 0 + break; + + default:; + } + break; + default:; + } + break; + + case 30040: switch (iRSelin) { case 500: tofAnaTestbeam->SetTShift(0.3); // Shift DTD4 to 0 @@ -547,15 +687,25 @@ void ana_trks_eval(Int_t nEvents = 10000, case 901041: switch (iRSelin) { case 500: - tofAnaTestbeam->SetTShift(0.8); // Shift DTD4 to 0 - tofAnaTestbeam->SetTOffD4(11.); // Shift DTD4 to physical value - + if (iMc == 0) { + tofAnaTestbeam->SetTShift(4.8); // Shift DTD4 to 0 + tofAnaTestbeam->SetTOffD4(11.); // Shift DTD4 to physical value + } else { // MC + tofAnaTestbeam->SetTShift(-12.); // 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: - tofAnaTestbeam->SetSel2TOff(0.); // Shift Sel2 time peak to 0 + if (iMc == 0) { + tofAnaTestbeam->SetSel2TOff( + 0.05); // 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 @@ -629,19 +779,19 @@ void ana_trks_eval(Int_t nEvents = 10000, gInterpreter->ProcessLine(SaveToHstFile); // default displays, plot results - /* + TString Display_Status = "pl_over_Mat04D4best.C"; TString Display_Funct; - if (iGenCor<0) { + if (iGenCor < 0) { Display_Funct = "pl_over_Mat04D4best(1)"; - }else{ + } else { Display_Funct = "pl_over_Mat04D4best(0)"; } gROOT->LoadMacro(Display_Status); - cout << "Exec "<< Display_Funct.Data()<< endl; + 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"); @@ -656,11 +806,17 @@ void ana_trks_eval(Int_t nEvents = 10000, 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("pl_eff_XY()"); + 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_all_Track2D(1)"); diff --git a/macro/beamtime/mcbm2020/ana_trksi.C b/macro/beamtime/mcbm2020/ana_trksi.C new file mode 100644 index 0000000000000000000000000000000000000000..2572839904d21a00b2a3ebd420c5872d59456246 --- /dev/null +++ b/macro/beamtime/mcbm2020/ana_trksi.C @@ -0,0 +1,683 @@ +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 iVerbose = 1; + if (cCalId == "") cCalId = cFileId; + // 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"; + TString workDir = gSystem->Getenv("VMCWORKDIR"); + //TString paramDir = workDir + "/macro/beamtime/mcbm2020"; + TString paramDir = "."; + TString ParFile = paramDir + "/data/" + cFileId.Data() + ".params.root"; + TString InputFile = paramDir + "/data/" + cFileId.Data() + ".root"; + TString InputDigiFile = paramDir + "/data/digidev_" + cFileId.Data() + + Form("_%s_%02.0f_Cal", cSet.Data(), dDeadtime) + + cCalId + ".out.root"; + TString OutputFile = paramDir + "/data/hits_" + cFileId.Data() + + Form("_%s_%06d_%03d", cSet.Data(), iSel, iSel2) + + ".out.root"; + TString cHstFile = + paramDir + + Form( + "/hst/%s_%03.0f_%s_%06d_%03d_%03.1f_%03.1f_trk%03d_Cal%s_Ana.hst.root", + cFileId.Data(), + dDeadtime, + cSet.Data(), + iSel, + iSel2, + dScalFac, + dChi2Lim2, + iTrackingSetup, + cCalId.Data()); + TString cTrkFile = Form("%s_tofFindTracks.hst.root", cCalId.Data()); + TString cAnaFile = Form("%s_TrkAnaTestBeam.hst.root", cFileId.Data()); + + cout << " InputDigiFile = " << InputDigiFile << endl; + + TString shcmd = "rm -v " + ParFile; + gSystem->Exec(shcmd.Data()); + + TList* parFileList = new TList(); + + TString TofGeo = "v19b_mcbm"; //default + + cout << "Geometry version " << TofGeo << endl; + + TObjString* tofDigiFile = new TObjString( + workDir + "/parameters/tof/tof_" + TofGeo + ".digi.par"); // TOF digi file + parFileList->Add(tofDigiFile); + + // TObjString tofDigiBdfFile = paramDir + "/tof.digibdf.par"; + // TObjString tofDigiBdfFile = paramDir + "/tof." + FPar + "digibdf.par"; + TObjString* tofDigiBdfFile = + new TObjString(workDir + "/parameters/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; + } + + // ----- Reconstruction run ------------------------------------------- + FairRunAna* run = new FairRunAna(); + cout << "InputFile: " << InputFile.Data() << endl; + cout << "InputDigiFile: " << InputDigiFile.Data() << endl; + + //run->SetInputFile(InputFile.Data()); + //run->AddFriend(InputDigiFile.Data()); + run->SetInputFile(InputDigiFile.Data()); + //run->AddFriend(InputFile.Data()); + run->SetOutputFile(OutputFile); + + FairLogger::GetLogger()->SetLogScreenLevel(logLevel.Data()); + FairLogger::GetLogger()->SetLogVerbosityLevel("MEDIUM"); + + // ----- 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 calMode = 93; + Int_t calSel = 1; + Bool_t bOut = kFALSE; + + CbmTofEventClusterizer* tofClust = + new CbmTofEventClusterizer("TOF Event Clusterizer", iVerbose, bOut); + 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); + + // ========================================================================= + // === Tracking === + // ========================================================================= + CbmStsDigitize* stsDigitize = new CbmStsDigitize(); //necessary for kalman !! + CbmKF* kalman = new CbmKF(); + + 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 + tofFindTracks->SetCorMode(iGenCor); // valid options: 0,1,2,3,4,5,6, 10 - 19 + tofFindTracks->SetTtTarg(0.055); // target value for Dec2019 + //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->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 = 30; + iNReqStations = 3; + 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); + tofFindTracks->SetStation(28, 6, 0, 0); + tofFindTracks->SetStation(29, 6, 0, 1); + break; + + case 2: + iMinNofHits = 3; + iNStations = 29; + iNReqStations = 3; + 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); + tofFindTracks->SetStation(28, 6, 0, 0); + tofFindTracks->SetStation(0, 6, 0, 1); + 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 + 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 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 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); + + // ========================================================================= + // === 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.); + //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 >= 0) { + 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 + } + + 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); + } + + // ----- 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"); + + //gInterpreter->ProcessLine("pl_over_MatD4sel()"); + //gInterpreter->ProcessLine("pl_TIS()"); + //gInterpreter->ProcessLine("pl_TIR()"); + //gInterpreter->ProcessLine("pl_eff_XY()"); + gInterpreter->ProcessLine("pl_calib_trk()"); + + gInterpreter->ProcessLine("pl_all_Track2D(1)"); + gInterpreter->ProcessLine("pl_all_Track2D(2)"); + + 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/mcbm2020/dis_trks.C b/macro/beamtime/mcbm2020/dis_trks.C index 9be3758aaad250b2c5f033719e986f01850e7621..cb69f4f126bcf15a54396099b25094f16011ebd2 100644 --- a/macro/beamtime/mcbm2020/dis_trks.C +++ b/macro/beamtime/mcbm2020/dis_trks.C @@ -17,13 +17,14 @@ void dis_trks(Int_t nEvents = 10, //TString logLevel = "FATAL"; //TString logLevel = "ERROR"; //TString logLevel = "INFO"; - //TString logLevel = "DEBUG"; + TString logLevel = "DEBUG"; //TString logLevel = "DEBUG1"; //TString logLevel = "DEBUG2"; - TString logLevel = "DEBUG3"; - //TString workDir = gSystem->Getenv("VMCWORKDIR"); - TString workDir = "../../.."; - TString paramDir = workDir + "/macro/beamtime/mcbm2020"; + //TString logLevel = "DEBUG3"; + TString workDir = gSystem->Getenv("VMCWORKDIR"); + //TString workDir = "../../.."; + //TString paramDir = workDir + "/macro/beamtime/mcbm2020"; + TString paramDir = "./"; TString ParFile = paramDir + "/data/" + cFileId.Data() + ".params.root"; TString InputFile = paramDir + "/data/" + cFileId.Data() + ".root"; TString InputDigiFile = paramDir + "/data/digidev_" + cFileId.Data() @@ -35,16 +36,16 @@ void dis_trks(Int_t nEvents = 10, TString cHstFile = paramDir + Form( - "/hst/%s_%03.0f_%s_%06d_%03d_%03.1f_%03.1f_trk%03d_Cal%s_Dis.hst.root", - cFileId.Data(), - dDeadtime, - cSet.Data(), - iSel, - iSel2, - dScalFac, - dChi2Lim2, - iTrackingSetup, - cCalId.Data()); + "/hst/%s_%03.0f_%s_%06d_%03d_%03.1f_%03.1f_trk%03d_Cal%s_Dis.hst.root", + cFileId.Data(), + dDeadtime, + cSet.Data(), + iSel, + iSel2, + dScalFac, + dChi2Lim2, + iTrackingSetup, + cCalId.Data()); TString cTrkFile = Form("%s_tofFindTracks.hst.root", cCalId.Data()); TString cAnaFile = Form("%s_TrkAnaTestBeam.hst.root", cCalId.Data()); @@ -55,19 +56,20 @@ void dis_trks(Int_t nEvents = 10, TList* parFileList = new TList(); - TString TofGeo = "v20a_mcbm"; //default - + TString TofGeo = "v20b_mcbm"; //default cout << "Geometry version " << TofGeo << endl; - TObjString* tofDigiFile = new TObjString( - workDir + "/parameters/tof/tof_" + TofGeo + ".digi.par"); // TOF digi file - parFileList->Add(tofDigiFile); - - // TObjString tofDigiBdfFile = paramDir + "/tof.digibdf.par"; - // TObjString tofDigiBdfFile = paramDir + "/tof." + FPar + "digibdf.par"; - TObjString* tofDigiBdfFile = - new TObjString(workDir + "/parameters/tof/" + TofGeo + ".digibdf.par"); - parFileList->Add(tofDigiBdfFile); + // ----- Load the geometry setup ------------------------------------- + /* + const char* setupName = "mcbm_beam_2020_03"; + TString setupFile = workDir + "/geometry/setup/setup_" + setupName + ".C"; + TString setupFunct = "setup_"; + setupFunct = setupFunct + setupName + "()"; + std::cout << "-I- mcbm_reco: Loading macro " << setupFile << std::endl; + gROOT->LoadMacro(setupFile); + gROOT->ProcessLine(setupFunct); + CbmSetup* setup = CbmSetup::Instance(); +*/ TString geoDir = gSystem->Getenv("VMCWORKDIR"); TString geoFile = geoDir + "/geometry/tof/geofile_tof_" + TofGeo + ".root"; @@ -78,6 +80,13 @@ void dis_trks(Int_t nEvents = 10, return; } + //TObjString *tofDigiFile = new TObjString(workDir + "/parameters/tof/tof_" + TofGeo + ".digi.par"); // TOF digi file + //parFileList->Add(tofDigiFile); + + TObjString* tofDigiBdfFile = + new TObjString(workDir + "/parameters/tof/" + TofGeo + ".digibdf.par"); + parFileList->Add(tofDigiBdfFile); + // ----- Reconstruction run ------------------------------------------- FairRunAna* run = new FairRunAna(); cout << "InputFile: " << InputFile.Data() << endl; @@ -91,7 +100,7 @@ void dis_trks(Int_t nEvents = 10, FairLogger::GetLogger()->SetLogScreenLevel(logLevel.Data()); // FairLogger::GetLogger()->SetLogVerbosityLevel("MEDIUM"); - FairLogger::GetLogger()->SetLogVerbosityLevel("HIGH"); + FairLogger::GetLogger()->SetLogVerbosityLevel("VERYHIGH"); // ----- Local selection variables ------------------------------------------- @@ -139,9 +148,6 @@ void dis_trks(Int_t nEvents = 10, // ========================================================================= // === Tracking === // ========================================================================= - CbmStsDigitize* stsDigitize = new CbmStsDigitize(); //necessary for kalman !! - CbmKF* kalman = new CbmKF(); - /* CbmTofEventClusterizer* tofClust = new CbmTofEventClusterizer("TOF Event Clusterizer",iVerbose, bOut); tofClust->SetMemoryTime(1000000.); // internal storage time of hits in ns diff --git a/macro/beamtime/mcbm2020/eval_tracks.sh b/macro/beamtime/mcbm2020/eval_tracks.sh index e15082930fb59f52627fbb8b248d8b3b60abe391..6e2052086d0c0b98c616f52127187472ebf978a6 100755 --- a/macro/beamtime/mcbm2020/eval_tracks.sh +++ b/macro/beamtime/mcbm2020/eval_tracks.sh @@ -2,25 +2,38 @@ # shell script to iterate tracklet calibration histograms #SBATCH -J eval_tracks #SBATCH -D /lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2020 -#SBATCH --time=1-00:00:00 -#SBATCH --mem=2000 +#SBATCH --time=6-00:00:00 +#SBATCH --mem=4000 #SBATCH --partition=long X=$((${SLURM_ARRAY_TASK_ID} - 0)) XXX=$(printf "%03d" "$X") cRun=$1 -iDut=$2; -iRef=$3; +iDut=$2 +iRef=$3 iSel2=$4 ((iSel=$iDut*1000+$iRef)) iTraSetup=$5 cSet=$6 if [[ ${cSet} = "" ]]; then - cSet="900041901_901" + cSet="030040500_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 + CalIdMode=$7 if [[ ${CalIdMode} = "" ]]; then echo use native calibration file @@ -30,7 +43,7 @@ else fi dDTres=10000000 -nEvt=100000 +nEvt=100000000 cSel2=$iSel2; if [[ $iSel2 < 100 ]]; then @@ -40,6 +53,13 @@ if [[ $iSel2 < 100 ]]; then fi fi +iMc=0 +McId=${cRun:0:4} +if [ "$McId" = "mcbm" ]; then + echo processing MC simulation + iMc=1 +fi + if [ -e /lustre/cbm ]; then source /lustre/cbm/users/nh/CBM/cbmroot/trunk/build/config.sh wdir=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2020 @@ -50,32 +70,42 @@ outdir=${wdir}/${cRun} fi # frange2 limits chi2 -fRange2=3.5 +fRange2=2.5 #frange1 limits DT spectrum range -fRange1=1.1 +fRange1=0.9 dDeadtime=50 +#./gen_digi.sh 600.100.5.0 30040500 500 50 600.100.5.0 30040500 +#./gen_digi.sh $cRun $iCalSet $iSel2 $Deadtime $CalIdMode CalIdSet +cd $wdir +if [ ! -e ${cRun} ]; then + mkdir $cRun +fi cd ${cRun} -mkdir Ana_${cSet}_${iSel}_${cSel2}_${iTraSetup} +mkdir Ana_${cSet}_${iSel}_${cSel2}_${iTraSetup} cp ../rootlogon.C Ana_${cSet}_${iSel}_${cSel2}_${iTraSetup}/ cp ../.rootrc Ana_${cSet}_${iSel}_${cSel2}_${iTraSetup}/ +digiCalFile=`ls -1 ${cCalId}*93_1*.root` + cd Ana_${cSet}_${iSel}_${cSel2}_${iTraSetup} rm -v *AnaTestBeam.hst.root cp -v ../../${cCalId}_tofFindTracks.hst.root . +echo create symbolic link to digiCalFile $digiCalFile in `pwd` +ln -s ../$digiCalFile ./$digiCalFile 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')' +root -b -q '../../ana_trks_eval.C('$nEvt','$iSel',-1,"'$cRun'","'$cSet'",'$iSel2','$iTraSetup','$fRange1','$fRange2','$dDeadtime',"'$cCalId'",'$iCal',0,'$iCalSet',0,'$iMc')' mv -v tofAnaTestBeam.hst.root ${cRun}_TrkAnaTestBeam.hst.root rm all_* if (! (test -f Test.res)); then -echo no resolution file available: return -return + echo no resolution file available: exit + exit 1 fi done @@ -96,7 +126,7 @@ done # final action -> scan full statistics iCal=1 -root -b -q '../../ana_trks.C(-1,'$iSel',-1,"'$cRun'","'$cSet'",'$iSel2','$iTraSetup','$fRange1','$fRange2','$dDeadtime',"'$cCalId'",'$iCal')' +root -b -q '../../ana_trks_eval.C(-1,'$iSel',-1,"'$cRun'","'$cSet'",'$iSel2','$iTraSetup','$fRange1','$fRange2','$dDeadtime',"'$cCalId'",'$iCal',0,'$iCalSet',0,'$iMc')' rm all_* cd ../.. diff --git a/macro/beamtime/mcbm2020/gen_digi.sh b/macro/beamtime/mcbm2020/gen_digi.sh index e12dd18931a8f421a26a9cb92c0ac10ee41f3b0d..0fbc32c8385c1815804a0b43810217d89119e8ea 100755 --- a/macro/beamtime/mcbm2020/gen_digi.sh +++ b/macro/beamtime/mcbm2020/gen_digi.sh @@ -19,10 +19,6 @@ iCalSet=$2 iSel2=$3 -if((${iSel2}<0));then - ((iBRef=-$iSel2)) -fi - cCalSet=$iCalSet if (( iCalSet<100000000 )); then cCalSet="0"$iCalSet @@ -88,4 +84,4 @@ root -b -q '../ana_digi_cal.C(-1,93,1,'$iRef',1,"'$cRun'",'$iCalSet',1,'$iSel2', cd .. -mv -v slurm-${SLURM_JOB_ID}.out ${outdir}/GenDigi_${cRun}_${iCalSet}_${iSel2}_${iCalIdMode}.out +mv -v slurm-${SLURM_JOB_ID}.out ${outdir}/GenDigi_${cRun}_${iCalSet}_${iSel2}_${CalIdMode}.out diff --git a/macro/beamtime/mcbm2020/iter_tracks.sh b/macro/beamtime/mcbm2020/iter_tracks.sh index dc4439a165255783f357cd0e9f12d86e0d396f1f..dba5ba6a9c26c1c2d0929753d9b3a105060ffcf9 100755 --- a/macro/beamtime/mcbm2020/iter_tracks.sh +++ b/macro/beamtime/mcbm2020/iter_tracks.sh @@ -20,13 +20,33 @@ if [[ $cSet = "" ]]; then #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 +iMc=0 +McId=${cRun:0:4} +if [ "$McId" = "mcbm" ]; then + echo processing MC simulation + iMc=1 +fi + # what should be done ? -iDut=900; iRef=41; iSel2=600 +iDut=900; iRef=41; iSel2=31 ((iSel=$iDut*1000+$iRef)) nEvt=100000 @@ -52,7 +72,9 @@ fRange1=4. TRange1Limit=2. dDeadtime=50 -mkdir ${cRun} +if [ ! -e ${cRun} ]; then + mkdir $cRun +fi cd ${cRun} cp ../.rootrc . cp ../rootlogon.C . @@ -105,9 +127,13 @@ for iCal in 3 4 5; do #for iCal in 3 2 ; do #for iCal in 2 ; do 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,1)' + root -b -q '../ana_trks.C('$nEvt','$iSel','$iCal',"'$cRun'","'$cSet'",'$iSel2','$iTraSetup','$fRange1','$fRange2','$dDeadtime',"'$cCalId'",1,1,'$iCalSet',0,'$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 diff --git a/macro/beamtime/mcbm2020/mrich_reco.C b/macro/beamtime/mcbm2020/mrich_reco.C index 3412c558599bb1f8c29a19c95377c11f2ce491fa..b84160fc03c7d74b15aef4fce2a5243a2e2409da 100644 --- a/macro/beamtime/mcbm2020/mrich_reco.C +++ b/macro/beamtime/mcbm2020/mrich_reco.C @@ -1,9 +1,9 @@ -void mrich_reco( - const string srcfolder = "/lustre/cbm/users/adrian/mcbmbeamtime/cbmsource/" - "macro/beamtime/mcbm2020/data", - const unsigned int runId = 759, // used for the output folder - int nEvents = 1000, - const int taskId = -1) { +void mrich_reco(const string srcfolder = + "/lustre/cbm/users/adrian/mcbmbeamtime/cbmsource/" + "macro/beamtime/mcbm2020/data", + const unsigned int runId = 759, // used for the output folder + int nEvents = 1000, + const int taskId = -1) { const string& parFile = Form("%s/unp_mcbm_params_%d.root", srcfolder.c_str(), runId); const string& digiFile = diff --git a/macro/beamtime/mcbm2020/mtof_reco.C b/macro/beamtime/mcbm2020/mtof_reco.C index 8deb1005e96143271bbad410fc2811d31fb27794..b4795e11a9040e8ffba0658ddeaaa73719c47b6c 100644 --- a/macro/beamtime/mcbm2020/mtof_reco.C +++ b/macro/beamtime/mcbm2020/mtof_reco.C @@ -140,7 +140,6 @@ void mtof_reco(Int_t nEvents = 100, // number of Timeslices // ------------------------------------------------------------------------ // TOF defaults - Int_t calMode = 93; Int_t calSel = 1; Int_t calSm = 0; @@ -154,7 +153,6 @@ void mtof_reco(Int_t nEvents = 100, // number of Timeslices case 1: { CbmTofEventClusterizer* tofCluster = new CbmTofEventClusterizer("TOF Event Clusterizer", 0, 1); - TString cFname = Form("%s_set%09d_%02d_%01dtofClust.hst.root", cCalId.Data(), iCalSet, @@ -243,9 +241,7 @@ void mtof_reco(Int_t nEvents = 100, // number of Timeslices std::cout << "-I- " << myName << ": Added task " << tofCluster->GetName() << std::endl; } break; - default: { - ; - } + default: { ; } } } // ------------------------------------------------------------------------- diff --git a/macro/beamtime/mcbm2020/mtof_reco.sh b/macro/beamtime/mcbm2020/mtof_reco.sh new file mode 100755 index 0000000000000000000000000000000000000000..185650c869c2e5d02e611d27eb38ab61e8b5bcf7 --- /dev/null +++ b/macro/beamtime/mcbm2020/mtof_reco.sh @@ -0,0 +1,53 @@ +#!/bin/bash +# shell script to reconstruct mcbm mtof data +#SBATCH -J mtof_reco +#SBATCH -D /lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2020 +#SBATCH --time=2-24:00:00 +#SBATCH --mem=4000 +#SBATCH --partition=long +cRun=$1 +dataset="data/unp_mcbm_"$cRun + +NTs=$2 +if [[ ${NTs} = "" ]]; then + NTs=20000 +fi + +ReqTofMul=$3 +if [[ ${ReqTofMul} = "" ]]; then + ReqTofMul=0 +fi + +setup=$4 +if [[ ${setup} = "" ]]; then + setup=mcbm_beam_2020_03 +fi + +CalId=$5 +if [[ ${CalId} = "" ]]; then + CalId=759.100.4.0 +fi + +CalSet=$6 +if [[ ${CalSet} = "" ]]; then + CalSet=10020500 +fi + +if [ -e /lustre/cbm ]; then +source /lustre/cbm/users/nh/CBM/cbmroot/trunk/build/config.sh +wdir=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2020 +outdir=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2020/${cRun} +else +wdir=`pwd` +outdir=${wdir}/${cRun} +fi + +cd $wdir +mkdir $cRun +#cd $cRun +#cp ../.rootrc . +#cp ../rootlogon.C . +root -l -b -q 'mtof_reco.C('$NTs',"'$dataset'","'$setup'","'$CalId'",'$CalSet','$ReqTofMul')' +#cd .. + +mv -v slurm-${SLURM_JOB_ID}.out ${outdir}/RecoMtof_${NTs}_${cRun}_${CalId}_${CalSet}.out diff --git a/macro/beamtime/mcbm2020/pl_all_2D.C b/macro/beamtime/mcbm2020/pl_all_2D.C new file mode 100644 index 0000000000000000000000000000000000000000..d2cfc907bdd0d5d9d3c55b335212d9897cb3db6f --- /dev/null +++ b/macro/beamtime/mcbm2020/pl_all_2D.C @@ -0,0 +1,67 @@ +void pl_all_2D(Int_t iOpt = 0, Int_t iNSt = 4) { + // 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, 6, 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[6] = {0, 9, 6, 5, 7, 8}; + const Int_t iSmNum[6] = {5, 1, 1, 1, 1, 1}; + const Int_t iRpcNum[6] = {5, 2, 2, 1, 1, 8}; + TString cOpt; + + switch (iOpt) { + case 0: cOpt = "Size"; break; + case 1: cOpt = "Pos"; break; + case 2: cOpt = "TOff"; break; + case 3: cOpt = "Tot"; break; + case 4: cOpt = "AvWalk"; break; + case 5: cOpt = "AvLnWalk"; break; + case 6: cOpt = "Mul"; 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 iCanv = 0; + // if (h!=NULL) h->Delete(); + + 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 = Form( + "cl_SmT%01d_sm%03d_rpc%03d_%s", iType[iSt], iSm, iRp, cOpt.Data()); + h = (TH2*) gROOT->FindObjectAny(hname); + if (h != NULL) { + if (iOpt == 4 || iOpt == 5) { gPad->SetLogz(); } + h->Draw("colz"); + } else { + cout << "Histogram " << hname << " not existing. " << endl; + } + if (iRp == 10) break; + } + } + } + can->SaveAs(Form("pl_all_%s.pdf", cOpt.Data())); +} diff --git a/macro/beamtime/mcbm2020/pl_all_3D.C b/macro/beamtime/mcbm2020/pl_all_3D.C new file mode 100644 index 0000000000000000000000000000000000000000..b3f87c24d69085a2151db5ce1b6371bd1c944c20 --- /dev/null +++ b/macro/beamtime/mcbm2020/pl_all_3D.C @@ -0,0 +1,61 @@ +void pl_all_3D(Int_t iOpt = 0, Int_t iSel = 0, Int_t iNSt = 4) { + // 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, 6, 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); + + TH3* h; + TH2* h2; + const Int_t iType[6] = {0, 9, 6, 5, 7, 8}; + const Int_t iSmNum[6] = {5, 1, 1, 1, 1, 1}; + const Int_t iRpcNum[6] = {5, 2, 2, 1, 1, 8}; + TString cOpt; + + switch (iOpt) { + case 0: cOpt = "yx"; break; + + case 1:; break; + + default:; + } + + Int_t iCanv = 0; + // if (h!=NULL) h->Delete(); + + 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 = Form("cl_SmT%01d_sm%03d_rpc%03d_Sel%02d_Walk2", + iType[iSt], + iSm, + iRp, + iSel); + h = (TH3*) gROOT->FindObjectAny(hname); + if (h != NULL) { + if (iOpt == 4 || iOpt == 5) { gPad->SetLogz(); } + h->Project3D(cOpt)->Draw("colz"); + } else { + cout << "Histogram " << hname << " not existing. " << endl; + } + } + } + } + can->SaveAs(Form("pl_all_%s.pdf", cOpt.Data())); +} diff --git a/macro/beamtime/mcbm2020/pl_all_CluMul.C b/macro/beamtime/mcbm2020/pl_all_CluMul.C new file mode 100644 index 0000000000000000000000000000000000000000..aac7c6712aed0ca86357848ce7acaa3bde43fbb7 --- /dev/null +++ b/macro/beamtime/mcbm2020/pl_all_CluMul.C @@ -0,0 +1,51 @@ +void pl_all_CluMul(Int_t iNSt = 6, Double_t MulMax = 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(5, 7, 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); + + 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, 1}; + const Int_t iRpcNum[6] = {5, 2, 1, 1, 2, 8}; + + Int_t iCanv = 0; + // if (h!=NULL) h->Delete(); + + 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 = + Form("cl_SmT%01d_sm%03d_rpc%03d_Mul", iType[iSt], iSm, iRp); + h = (TH1*) gROOT->FindObjectAny(hname); + if (h != NULL) { + h->GetXaxis()->SetRange(0., MulMax); + h->Draw(""); + gPad->SetLogy(); + } else { + cout << "Histogram " << hname << " not existing. " << endl; + } + if (iRp == 10) break; + } + } + } + can->SaveAs(Form("pl_all_CluMul.pdf")); +} diff --git a/macro/beamtime/mcbm2020/pl_all_CluPosEvol.C b/macro/beamtime/mcbm2020/pl_all_CluPosEvol.C new file mode 100644 index 0000000000000000000000000000000000000000..70648848a79d9cc7575dce80ef11c18db4400d9a --- /dev/null +++ b/macro/beamtime/mcbm2020/pl_all_CluPosEvol.C @@ -0,0 +1,61 @@ +void pl_all_CluPosEvol(Int_t iNSt = 2, Int_t iTmax = 0) { + // 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, 6, 0.01, 0.01); + // can->Divide(4,4,0.01,0.01); + // can->Divide(2,2,0,0); + Float_t lsize = 0.09; + + gPad->SetFillColor(0); + gStyle->SetPalette(1); + gStyle->SetLabelSize(lsize); + + //gStyle->SetStatY(0.5); + //gStyle->SetStatX(0.5); + gStyle->SetStatW(0.5); + gStyle->SetStatH(0.3); + + gStyle->SetOptStat(kFALSE); + //gROOT->cd(); + //gROOT->SetDirLevel(2); + + TH1* h; + TH2* h2; + const Int_t iType[7] = {0, 5, 6, 2, 9, 8, 1}; + const Int_t iSmNum[7] = {5, 1, 1, 2, 3, 3, 3}; + const Int_t iRpcNum[7] = {5, 1, 2, 1, 2, 1, 3}; + + Int_t iCanv = 0; + // if (h!=NULL) h->Delete(); + + 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; + gROOT->cd(); + TString hname = + Form("cl_SmT%01d_sm%03d_rpc%03d_PosEvol", iType[iSt], iSm, iRp); + h = (TH1*) gROOT->FindObjectAny(hname); + if (h != NULL) { + can->cd(iCanv + 1); + iCanv++; + Double_t dLMargin = 0.35; + Double_t dTitOffset = 1.6; + gPad->SetLeftMargin(dLMargin); + h->UseCurrentStyle(); + h->GetYaxis()->SetTitleOffset(dTitOffset); + if (iTmax > 0) h->GetXaxis()->SetRange(0., iTmax); + h->Draw(""); + //gPad->SetLogy(); + } else { + cout << "Histogram " << hname << " not existing. " << endl; + } + } + } + } + can->SaveAs(Form("pl_all_CluPosEvol.pdf")); +} diff --git a/macro/beamtime/mcbm2020/pl_all_CluRate.C b/macro/beamtime/mcbm2020/pl_all_CluRate.C new file mode 100644 index 0000000000000000000000000000000000000000..cb4168726a5917b3b35d3def60f2d49a837f7617 --- /dev/null +++ b/macro/beamtime/mcbm2020/pl_all_CluRate.C @@ -0,0 +1,101 @@ +void pl_all_CluRate(Int_t iNSt = 4, + 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); + // TCanvas *can = new TCanvas("can","can",48,55,700,900); + TCanvas* can = new TCanvas("can", "can", 48, 56, 900, 900); + switch (iMode) { + case 0: + switch (iNSt) { + 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; + } + break; + case 1: + can->Divide(1, 2, 0.01, 0.01); + ; + break; + } + // can->Divide(2,2,0,0); + 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.4); + gStyle->SetTitleOffset(1.0, "x"); + gStyle->SetTitleOffset(1.2, "y"); + gStyle->SetTitleFontSize(0.03); + + + TH1* h; + TH2* h2; + const Int_t iType[6] = {0, 9, 5, 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}; + + Int_t iCanv = 0; + Int_t iCol = 0; + // if (h!=NULL) h->Delete(); + + 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; + gROOT->cd(); + TString hname = ""; + switch (iOpt) { + case 0: + hname = + Form("cl_SmT%01d_sm%03d_rpc%03d_rate", iType[iSt], iSm, iRp); + break; + case 1: + hname = + Form("cl_SmT%01d_sm%03d_rpc%03d_rate10s", iType[iSt], iSm, iRp); + break; + } + h = (TH1*) gROOT->FindObjectAny(hname); + if (h != NULL) { + h->GetXaxis()->SetRangeUser(Tstart, Tend); + switch (iMode) { + case 0: + can->cd(iCanv + 1); + iCanv++; + h->Draw(""); + //h->UseCurrentStyle(); + gPad->SetLogy(); + break; + case 1: + can->cd(iSt + 1); + if (iSm > 0) continue; + h->UseCurrentStyle(); // set current defaults + h->SetMarkerStyle(20 + iSm); + iCol = iRp + 1; + if (iCol == 5) iCol++; + h->SetLineColor(iCol); + h->SetLineStyle(1); + h->SetMarkerColor(iCol); + if (iSm == 0 && iRp == 0) + h->Draw("LPE"); + else + h->Draw("LPEsame"); + break; + } + } else { + cout << "Histogram " << hname << " not existing. " << endl; + } + } + } + } + can->SaveAs(Form("pl_all_CluRate%d_%d.pdf", iNSt, iOpt)); +} diff --git a/macro/beamtime/mcbm2020/pl_all_CluTimeEvol.C b/macro/beamtime/mcbm2020/pl_all_CluTimeEvol.C new file mode 100644 index 0000000000000000000000000000000000000000..b186b370e8164234bc55d54560d2fcf24f1ddb96 --- /dev/null +++ b/macro/beamtime/mcbm2020/pl_all_CluTimeEvol.C @@ -0,0 +1,61 @@ +void pl_all_CluTimeEvol(Int_t iNSt = 2, Int_t iTmax = 0) { + // 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, 6, 0.01, 0.01); + // can->Divide(4,4,0.01,0.01); + // can->Divide(2,2,0,0); + Float_t lsize = 0.09; + + gPad->SetFillColor(0); + gStyle->SetPalette(1); + gStyle->SetLabelSize(lsize); + + //gStyle->SetStatY(0.5); + //gStyle->SetStatX(0.5); + gStyle->SetStatW(0.5); + gStyle->SetStatH(0.3); + + gStyle->SetOptStat(kFALSE); + //gROOT->cd(); + //gROOT->SetDirLevel(2); + + TH1* h; + TH2* h2; + const Int_t iType[7] = {0, 5, 6, 2, 9, 8, 1}; + const Int_t iSmNum[7] = {5, 1, 1, 2, 3, 3, 3}; + const Int_t iRpcNum[7] = {5, 1, 2, 1, 2, 1, 3}; + + Int_t iCanv = 0; + // if (h!=NULL) h->Delete(); + + 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; + gROOT->cd(); + TString hname = + Form("cl_SmT%01d_sm%03d_rpc%03d_TimeEvol", iType[iSt], iSm, iRp); + h = (TH1*) gROOT->FindObjectAny(hname); + if (h != NULL) { + can->cd(iCanv + 1); + iCanv++; + Double_t dLMargin = 0.35; + Double_t dTitOffset = 1.6; + gPad->SetLeftMargin(dLMargin); + h->UseCurrentStyle(); + h->GetYaxis()->SetTitleOffset(dTitOffset); + if (iTmax > 0) h->GetXaxis()->SetRange(0., iTmax); + h->Draw(""); + //gPad->SetLogy(); + } else { + cout << "Histogram " << hname << " not existing. " << endl; + } + } + } + } + can->SaveAs(Form("pl_all_CluTimeEvol.pdf")); +} diff --git a/macro/beamtime/mcbm2020/pl_all_DTLastHits.C b/macro/beamtime/mcbm2020/pl_all_DTLastHits.C new file mode 100644 index 0000000000000000000000000000000000000000..185f2e59f585c7ce8949fdfc552f8274f9c550b7 --- /dev/null +++ b/macro/beamtime/mcbm2020/pl_all_DTLastHits.C @@ -0,0 +1,54 @@ +void pl_all_DTLastHits(Int_t iNSt = 6, + 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(5, 7, 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); + + 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}; + + + Int_t iCanv = 0; + // if (h!=NULL) h->Delete(); + + 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 = + Form("cl_SmT%01d_sm%03d_rpc%03d_DTLastHits", iType[iSt], iSm, iRp); + h = (TH1*) gROOT->FindObjectAny(hname); + if (h != NULL) { + h->GetXaxis()->SetRange(Tstart, Tend); + h->Draw(""); + gPad->SetLogy(); + } else { + cout << "Histogram " << hname << " not existing. " << endl; + } + if (iRp == 10) break; + } + } + } + can->SaveAs(Form("pl_all_CluRate.pdf")); +} diff --git a/macro/beamtime/mcbm2020/pl_all_DigiCor.C b/macro/beamtime/mcbm2020/pl_all_DigiCor.C new file mode 100644 index 0000000000000000000000000000000000000000..c2e611ea0ad0a0cc29e74b1e6f850c5d27a4cd6f --- /dev/null +++ b/macro/beamtime/mcbm2020/pl_all_DigiCor.C @@ -0,0 +1,47 @@ +void pl_all_DigiCor(Int_t iNDet = 6) { + // TCanvas *can = new TCanvas("can22","can22"); + // can->Divide(2,2); + TCanvas* can = new TCanvas("can", "can", 48, 55, 900, 900); + //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); + Float_t lsize = 0.07; + + gPad->SetFillColor(0); + gStyle->SetPalette(1); + gStyle->SetLabelSize(lsize); + + //gStyle->SetOptStat(kTRUE); + //gROOT->cd(); + //gROOT->SetDirLevel(2); + + 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, 1}; + const Int_t iRpcNum[6] = {5, 2, 1, 1, 2, 8}; + + Int_t iCanv = 0; + // if (h!=NULL) h->Delete(); + + for (Int_t iCh = 0; iCh < iNDet; iCh++) { + for (Int_t iSm = 0; iSm < iSmNum[iCh]; iSm++) { + for (Int_t iRpc = 0; iRpc < iRpcNum[iCh]; iRpc++) { + can->cd(iCanv + 1); + iCanv++; + gROOT->cd(); + TString hname = + Form("cl_SmT%01d_sm%03d_rpc%03d_DigiCor", iType[iCh], iSm, iRpc); + h2 = (TH2*) gROOT->FindObjectAny(hname); + if (h2 != NULL) { + h2->Draw("colz"); + // gPad->SetLogy(); + } else { + cout << "Histogram " << hname << " not existing. " << endl; + } + } + } + } + can->SaveAs(Form("pl_all_DigiCor.pdf")); +} diff --git a/macro/beamtime/mcbm2020/pl_all_DigiDTLD.C b/macro/beamtime/mcbm2020/pl_all_DigiDTLD.C new file mode 100644 index 0000000000000000000000000000000000000000..62f4a53616208da59aa3bfa59f53992c913bb339 --- /dev/null +++ b/macro/beamtime/mcbm2020/pl_all_DigiDTLD.C @@ -0,0 +1,132 @@ +void pl_all_DigiDTLD(Int_t iNDet = 6, Double_t dDTthr = 2., Int_t iOpt = 0) { + // TCanvas *can = new TCanvas("can22","can22"); + // can->Divide(2,2); + TCanvas* can = new TCanvas("can", "can", 48, 55, 900, 900); + //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); + Float_t lsize = 0.07; + + gPad->SetFillColor(0); + gStyle->SetPalette(1); + gStyle->SetLabelSize(lsize); + + //gStyle->SetOptStat(kTRUE); + //gROOT->cd(); + //gROOT->SetDirLevel(2); + + TH1* h; + TH2* h2; + TH1* hTime; + TString hnameT; + + const Int_t iType[6] = {0, 9, 7, 5, 6, 8}; + const Int_t iSmNum[6] = {5, 1, 1, 1, 1, 1}; + const Int_t iRpcNum[6] = {5, 2, 1, 1, 2, 8}; + + Double_t dTime = 0.; + Int_t iCanv = 0; + + Int_t jSmType = 5; + Int_t jSm = 0; + Int_t jRp = 0; + + // if (h!=NULL) h->Delete(); + + for (Int_t iCh = 0; iCh < iNDet; iCh++) { + for (Int_t iSm = 0; iSm < iSmNum[iCh]; iSm++) { + for (Int_t iRpc = 0; iRpc < iRpcNum[iCh]; iRpc++) { + can->cd(iCanv + 1); + iCanv++; + gROOT->cd(); + TString hname = + Form("cl_SmT%01d_sm%03d_rpc%03d_DigiDTLD", iType[iCh], iSm, iRpc); + switch (iOpt) { + case 0:; break; + + case 1: hname = Form("%s_fdead", hname.Data()); break; + + case 2: hname = Form("%s_py", hname.Data()); break; + + case 3: hname = Form("%s_py_dead", hname.Data()); break; + + default:; + } + + h2 = (TH2*) gROOT->FindObjectAny(hname); + TH1D* hx; + TH1D* hy; + TH1D* hy_dead; + Double_t dDeadtimeSum = 0.; + if (h2 != NULL) { + switch (iOpt) { + case 0: + h2->Draw("colz"); + gPad->SetLogz(); + + // Determine time duration an data taking + hnameT = + Form("cl_SmT%01d_sm%03d_rpc%03d_rate", jSmType, jSm, jRp); + hTime = (TH1*) gROOT->FindObjectAny(hnameT); + for (dTime = 0; dTime < hTime->GetNbinsX(); dTime++) + if (hTime->GetBinContent(dTime + 1) == 0) break; + cout << "Normalize for a run duration of " << dTime << " s" + << endl; + + // create result histograms + hx = h2->ProjectionX(Form("%s_fdead", hname.Data())); + hx->GetYaxis()->SetTitle("deadtime fraction"); + hx->Reset(); + hy = h2->ProjectionY(Form("%s_py", hname.Data())); + hy_dead = h2->ProjectionY(Form("%s_py_dead", hname.Data())); + hy_dead->GetYaxis()->SetTitle("deadtime fraction"); + hy_dead->Reset(); + for (Int_t iT = hy->GetNbinsX(); iT > 0; iT--) { + dDeadtimeSum += + hy->GetBinContent(iT) * hy->GetXaxis()->GetBinLowEdge(iT); + Double_t dDeadFrac = dDeadtimeSum / h2->GetNbinsX() / dTime; + hy_dead->SetBinContent(iT, dDeadFrac); + } + + for (Int_t iCh = 0; iCh < h2->GetNbinsX(); iCh++) { + TH1D* hCh = h2->ProjectionY( + Form("%s_%d_py", hname.Data(), iCh), iCh + 1, iCh + 1); + Double_t dAll = hCh->GetEntries(); + Double_t dTAllMean = hCh->GetMean(); + if (dAll > 0) { + Double_t BL = hCh->GetXaxis()->FindBin(dDTthr); + Double_t dLate = hCh->Integral(BL, hCh->GetNbinsX(), ""); + hCh->GetXaxis()->SetRange(BL, hCh->GetNbinsX()); + Double_t dTLateMean = hCh->GetMean(); + //Double_t dLateRatio=dLate*dTLateMean/dAll/dTAllMean; + Double_t dLateRatio = dLate * dTLateMean / dTime; + cout << Form("Long DT fraction for %s, ch %d: %6.3f, dTAll " + "%6.3f, dTLate %6.3f", + hname.Data(), + iCh, + dLateRatio, + dTAllMean, + dTLateMean) + << endl; + hx->SetBinContent(iCh + 1, dLateRatio); + } + } + break; + + case 1: h2->Draw(); break; + + case 2: + case 3: + h2->Draw(); + gPad->SetLogy(); + break; + } + } else { + cout << "Histogram " << hname << " not existing. " << endl; + } + } + } + } + can->SaveAs(Form("pl_all_DigiDTLD.pdf")); +} diff --git a/macro/beamtime/mcbm2020/pl_all_DigiTot.C b/macro/beamtime/mcbm2020/pl_all_DigiTot.C new file mode 100644 index 0000000000000000000000000000000000000000..3acdfea95d7561acc53415b783425d60b71320f3 --- /dev/null +++ b/macro/beamtime/mcbm2020/pl_all_DigiTot.C @@ -0,0 +1,46 @@ +void pl_all_DigiTot(Int_t iNDet = 2) { + // TCanvas *can = new TCanvas("can22","can22"); + // can->Divide(2,2); + TCanvas* can = new TCanvas("can", "can", 48, 55, 900, 900); + //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, 6, 0.01, 0.01); + Float_t lsize = 0.07; + + gPad->SetFillColor(0); + gStyle->SetPalette(1); + gStyle->SetLabelSize(lsize); + + //gStyle->SetOptStat(kTRUE); + //gROOT->cd(); + //gROOT->SetDirLevel(2); + + TH1* h; + TH2* h2; + Int_t iType[6] = {0, 5, 6, 5, 9, 8}; + Int_t iNumSm[6] = {5, 1, 1, 1, 3, 2}; + Int_t iNumRpc[6] = {5, 1, 2, 1, 2, 1}; + Int_t iCanv = 0; + // if (h!=NULL) h->Delete(); + + for (Int_t iCh = 0; iCh < iNDet; iCh++) { + for (Int_t iSm = 0; iSm < iNumSm[iCh]; iSm++) { + for (Int_t iRpc = 0; iRpc < iNumRpc[iCh]; iRpc++) { + can->cd(iCanv + 1); + iCanv++; + gROOT->cd(); + TString hname = + Form("hDigiTot_SmT%01d_sm%03d_rpc%03d", iType[iCh], iSm, iRpc); + h2 = (TH2*) gROOT->FindObjectAny(hname); + if (h2 != NULL) { + h2->Draw("colz"); + // gPad->SetLogy(); + } else { + cout << "Histogram " << hname << " not existing. " << endl; + } + } + } + } + can->SaveAs(Form("pl_all_DigiTot.pdf")); +} diff --git a/macro/beamtime/mcbm2020/pl_all_Sel2D.C b/macro/beamtime/mcbm2020/pl_all_Sel2D.C new file mode 100644 index 0000000000000000000000000000000000000000..d3e303ead376c9f1a6e9dfe5557d8487bd0b6b7c --- /dev/null +++ b/macro/beamtime/mcbm2020/pl_all_Sel2D.C @@ -0,0 +1,114 @@ +void pl_all_Sel2D(Int_t iOpt = 0, + Int_t iSel = 0, + Int_t iOpt2 = 0, + Int_t iNSt = 4) { + // 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, 6, 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); + + TH1* hp; + TH2* h; + TH2* h2; + const Int_t iType[6] = {0, 9, 6, 5, 6, 8}; + const Int_t iSmNum[6] = {5, 1, 1, 1, 1, 1}; + const Int_t iRpcNum[6] = {5, 2, 2, 1, 2, 8}; + TString cOpt; + + switch (iOpt) { + case 0: cOpt = "Size"; break; + case 1: cOpt = "Pos"; break; + case 2: cOpt = "TOff"; break; + case 3: cOpt = "Tot"; break; + case 4: cOpt = "AvWalk"; break; + case 5: cOpt = "DelTof"; break; + case 6: cOpt = "dXdY"; break; + case 7: cOpt = "TofOff"; break; + default:; + } + + Int_t iCanv = 0; + // if (h!=NULL) h->Delete(); + TString FitHName[100]; + Double_t FitIntegral[100]; + Double_t FitMean[100]; + Double_t FitWidth[100]; + Int_t NFit = 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 = Form("cl_SmT%01d_sm%03d_rpc%03d_Sel%02d_%s", + iType[iSt], + iSm, + iRp, + iSel, + cOpt.Data()); + h = (TH2*) gROOT->FindObjectAny(hname); + if (h != NULL) { + h->Draw("colz"); + gPad->SetLogz(); + + if (iOpt2 > 0) switch (iOpt) { + case 6: { + switch (iOpt2) { + case 1: // x-projection + hp = h->ProjectionX(); + hp->Draw(); + break; + case 2: // y-projection + hp = h->ProjectionY(); + hp->Draw(); + break; + } + Double_t dFMean = hp->GetMean(); + Double_t dFLim = 2.5 * hp->GetRMS(); + if (hp->Integral() > 10) { + TFitResultPtr fRes = hp->Fit( + "gaus", "S", "HEsame", dFMean - dFLim, dFMean + dFLim); + FitHName[NFit] = hp->GetName(); + FitIntegral[NFit] = hp->Integral(); + FitMean[NFit] = fRes->Parameter(1); + FitWidth[NFit] = fRes->Parameter(2); + NFit++; + ; + } + } break; // case 6 end + + default:; + } + + } else { + cout << "Histogram " << hname << " not existing. " << endl; + } + if (iRp == 10) break; + } + } + } + if (iOpt2 > 0) { + for (Int_t iFit = 0; iFit < NFit; iFit++) { + cout << "FitRes " << FitHName[iFit] << ", Stat: " << FitIntegral[iFit] + << ", Mean " << FitMean[iFit] << ", Width " << FitWidth[iFit] + << endl; + } + } + + can->SaveAs(Form("pl_all_Sel%d_%s.pdf", iSel, cOpt.Data())); +} diff --git a/macro/beamtime/mcbm2020/pl_all_Track2D.C b/macro/beamtime/mcbm2020/pl_all_Track2D.C new file mode 100644 index 0000000000000000000000000000000000000000..14930756f7b4dcf575d3e4d9decc694db1a8c2ef --- /dev/null +++ b/macro/beamtime/mcbm2020/pl_all_Track2D.C @@ -0,0 +1,85 @@ +void pl_all_Track2D(Int_t iOpt = 1, Int_t iNSt = 4) { + // 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, 6, 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[6] = {0, 9, 6, 5, 7, 8}; + const Int_t iSmNum[6] = {5, 1, 1, 1, 1, 1}; + const Int_t iRpcNum[6] = {5, 2, 2, 1, 1, 8}; + TString cOpt; + + switch (iOpt) { + case 0: cOpt = "Size"; break; + case 1: cOpt = "Pos"; break; + case 2: cOpt = "TOff"; break; + case 3: cOpt = "Tot"; break; + case 4: cOpt = "AvWalk"; break; + case 5: cOpt = "AvLnWalk"; break; + case 6: cOpt = "Mul"; 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 = 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 == 4 || iOpt == 5) { 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; + } else { + cout << "Histogram " << hname << " not existing. " << 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_Track_%s.pdf", cOpt.Data())); +} diff --git a/macro/beamtime/mcbm2020/pl_cmp_CluRate.C b/macro/beamtime/mcbm2020/pl_cmp_CluRate.C new file mode 100644 index 0000000000000000000000000000000000000000..6f2da6ac17eb0095d1732a68062afea898576b13 --- /dev/null +++ b/macro/beamtime/mcbm2020/pl_cmp_CluRate.C @@ -0,0 +1,140 @@ +void pl_cmp_CluRate(Int_t iNSt = 3, + Long_t iSet = 900032500, + Int_t iOpt = 0, + Double_t Tstart = 0., + Double_t Tend = 10., + Int_t iMode = 1) { + // 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,2,0,0); + can->Divide(1, 3, 0.01, 0.01); + Float_t lsize = 0.09; + + gPad->SetFillColor(0); + gStyle->SetPalette(1); + gStyle->SetLabelSize(lsize); + + gStyle->SetOptStat(kFALSE); + //gROOT->cd(); + //gROOT->SetDirLevel(2); + gStyle->SetPadLeftMargin(0.4); + gStyle->SetTitleOffset(1.0, "x"); + gStyle->SetTitleOffset(0.8, "y"); + gStyle->SetTitleFontSize(0.08); + + + TH1* h[iNSt]; + TH1* hrat1[iNSt]; + TH1* hrat2[iNSt]; + + TH2* h2; + Int_t iType[6] = {0, 9, 5, 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}; + Int_t iId_full[iNSt]; + + Int_t iCanv = 0; + Int_t iCol = 0; + // if (h!=NULL) h->Delete(); + TLegend* leg = new TLegend(0.78, 0.6, 0.85, 0.9); + leg->SetTextSize(0.05); + + Long_t iSet_tmp = iSet; + + can->cd(1); + for (Int_t iSt = 0; iSt < iNSt; iSt++) { + gROOT->cd(); + Int_t iId = iSet_tmp % 1000; + iId_full[iSt] = iId; + iSet_tmp = (iSet_tmp - iId) / 1000; + Int_t iRp = iId % 10; + iId -= iRp; + iId /= 10; + Int_t iSm = iId % 10; + iId -= iSm; + iId /= 10; + iType[iSt] = iId; + + TString hname = ""; + switch (iOpt) { + case 0: + hname = Form("cl_SmT%01d_sm%03d_rpc%03d_rate", iType[iSt], iSm, iRp); + break; + case 1: + hname = Form("cl_SmT%01d_sm%03d_rpc%03d_rate10s", iType[iSt], iSm, iRp); + break; + } + h[iSt] = (TH1*) gROOT->FindObjectAny(hname); + if (h[iSt] != NULL) { + h[iSt]->GetXaxis()->SetRangeUser(Tstart, Tend); + cout << "Draw " << iSt << ": " << hname << endl; + leg->AddEntry(h[iSt], Form("%03d", iId_full[iSt]), "p"); + + switch (iMode) { + case 0: + h[iSt]->Draw(""); + //h->UseCurrentStyle(); + gPad->SetLogy(); + break; + case 1: + h[iSt]->UseCurrentStyle(); // set current defaults + h[iSt]->SetMarkerStyle(20 + iSm); + h[iSt]->SetTitle(""); + iCol = iSt + 1; + if (iCol == 5) iCol++; + h[iSt]->SetLineColor(iCol); + h[iSt]->SetLineStyle(1); + h[iSt]->SetMarkerColor(iCol); + if (iSt == 0) + h[iSt]->Draw("LPE"); + else + h[iSt]->Draw("LPEsame"); + break; + } + } else { + cout << "Histogram " << hname << " not existing. " << endl; + } + } + leg->Draw(); + + can->cd(2); + Double_t RatMax = 1.5; + Double_t RatMin = 0.05; + gPad->SetLogy(); + gPad->SetGridx(); + gPad->SetGridy(); + for (Int_t iSt = 1; iSt < iNSt; iSt++) { + hrat1[iSt] = (TH1*) h[iSt]->Clone(); + hrat1[iSt]->Divide(h[iSt], h[0], 1., 1.); + hrat1[iSt]->SetYTitle(Form("Ratio to %03d", iId_full[0])); + hrat1[iSt]->SetMaximum(RatMax); + hrat1[iSt]->SetMinimum(RatMin); + if (iSt == 1) + hrat1[iSt]->Draw("LPE"); + else + hrat1[iSt]->Draw("LPEsame"); + } + + can->cd(3); + RatMax = 2; + RatMin = 0.2; + gPad->SetLogy(); + gPad->SetGridx(); + gPad->SetGridy(); + for (Int_t iSt = 2; iSt < iNSt; iSt++) { + hrat2[iSt] = (TH1*) h[iSt]->Clone(); + hrat2[iSt]->Divide(h[iSt], h[1], 1., 1.); + hrat2[iSt]->SetYTitle(Form("Ratio to %03d", iId_full[1])); + hrat2[iSt]->SetMaximum(RatMax); + hrat2[iSt]->SetMinimum(RatMin); + gPad->SetLogy(); + if (iSt == 2) + hrat2[iSt]->Draw("LPE"); + else + hrat2[iSt]->Draw("LPEsame"); + } + + can->SaveAs(Form("pl_cmp_CluRate%ld_%d.pdf", iSet, iOpt)); +} diff --git a/macro/beamtime/mcbm2020/scan_raw.sh b/macro/beamtime/mcbm2020/scan_raw.sh new file mode 100755 index 0000000000000000000000000000000000000000..607aab4b9988d307bf11984afed4ebba3cad23ff --- /dev/null +++ b/macro/beamtime/mcbm2020/scan_raw.sh @@ -0,0 +1,73 @@ +#!/bin/bash +# shell script to apply clusterizer calibrations +#SBATCH -J scan_raw +#SBATCH -D /lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2020 +#SBATCH --time=48:00:00 +#SBATCH --mem=2000 +#SBATCH --partition=long +cRun=$1 + +iCalSet=$2 +if [[ "$iCalset" = "" ]]; then +iCalSet=40030500 +fi + +((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 +if [[ "$iSel2" = "" ]]; then +iSel2=500 +fi + +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 + +echo scan_raw for $cRun with iDut=$iDut, iRef=$iRef, iSet=$iCalSet, iSel2=$iSel2, iBRef=$iBRef, Deadtime=$Deadtime + +if [ -e /lustre/cbm ]; then +source /lustre/cbm/users/nh/CBM/cbmroot/trunk/build/config.sh +wdir=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2020 +outdir=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2020/${cRun} +else +wdir=`pwd` +outdir=${wdir}/${cRun} +fi + +cd $wdir +mkdir $cRun +cd $cRun +mkdir Raw +cd Raw +cp ../../.rootrc . +cp ../../rootlogon.C . + +root -b -q '../../ana_digi_cal_all.C(-1,0,0,'$iBRef',50,"'$cRun'",'$iCalSet',0,'$iSel2','$Deadtime') ' + + +cd ../.. + +mv -v slurm-${SLURM_JOB_ID}.out ${outdir}/ScanRaw_${cRun}_${iCalSet}_${iSel2}.out diff --git a/macro/beamtime/mcbm2020/trk_cal_digi.sh b/macro/beamtime/mcbm2020/trk_cal_digi.sh index 26bcda8c9000c51309c38f22a674de3a95eadc4c..56240b1c0cebb7b4d7ea42d333f91e44dd5fef2b 100755 --- a/macro/beamtime/mcbm2020/trk_cal_digi.sh +++ b/macro/beamtime/mcbm2020/trk_cal_digi.sh @@ -2,9 +2,9 @@ # shell script to apply clusterizer calibrations #SBATCH -J trk_cal_digi #SBATCH -D /lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2020 -#SBATCH --time=4:00:00 -#SBATCH --mem=2000 -##SBATCH --partition=long +#SBATCH --time=5-24:00:00 +#SBATCH --mem=4000 +#SBATCH --partition=long cRun=$1 iCalSet=$2 @@ -59,7 +59,12 @@ else echo use calibrations from ${CalFile} fi -CalIdSet=$6 +iCalOpt=$6 +if [[ ${iCalOpt} = "" ]]; then + iCalOpt=1 +fi + +CalIdSet=$7 if [[ ${CalIdSet} = "" ]]; then echo use native calibration file CalIdSet=$cCalSet @@ -67,6 +72,8 @@ 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 if [ -e /lustre/cbm ]; then @@ -101,18 +108,18 @@ iTraSetup=1 fRange1=3. # frange2 limits chi2 fRange2=5.0 -TRange2Limit=2. +TRange2Limit=2.5 iSel=10 iGenCor=3 cCalSet2=${cCalSet}_$cSel2 -iCalOpt=1 case $iCalOpt in 1) # TOff ;; 2) # Walk (( nEvt *= 10 )) + (( nEvtMax *= 10 )) ;; esac @@ -123,7 +130,7 @@ while [[ $dDTres > 0 ]]; do nEvt=$nEvtMax 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 @@ -167,13 +174,18 @@ while [[ $dDTres > 0 ]]; do fi dDTres=$Tres dDTRMSres=$TRMSres + (( dDTRMSres -= 10 )) # next attempt should be at least 10ps better for continuation cp -v New_${CalFile} ${CalFile} + cp -v New_${CalFile} ${CalFile}_$iter else dDTres=0 fi (( iter += 1 )) done +# generate full statistics digi file +root -b -q '../ana_digi_cal.C(-1,93,1,'$iRef',1,"'$cRun'",'$iCalSet',1,'$iSel2','$Deadtime',"'$CalIdMode'") ' + cd .. mv -v slurm-${SLURM_JOB_ID}.out ${outdir}/TrkCalDigi_${cRun}_${iCalSet}_${iSel2}_${iCalIdMode}.out diff --git a/macro/beamtime/pl_CosmicHst.C b/macro/beamtime/pl_CosmicHst.C new file mode 100644 index 0000000000000000000000000000000000000000..8d7d942e8b6979e162ebc0c4574828988f05e3e1 --- /dev/null +++ b/macro/beamtime/pl_CosmicHst.C @@ -0,0 +1,225 @@ +void pl_CosmicHst(Int_t iNSt = 10, + Int_t iOpt = 0, + Int_t iSel = 0, + Int_t i1D = 0, + Double_t dYmax = 0.) { + // TCanvas *can = new TCanvas("can22","can22"); + // can->Divide(2,2); + TCanvas* can = new TCanvas("can", "can", 50, 0, 800, 1000); + can->Divide(3, 4); + + gPad->SetFillColor(0); + gStyle->SetPalette(1); + gStyle->SetOptStat(kFALSE); + + gROOT->cd(); + gROOT->SetDirLevel(1); + + TH1* h; + TH1* h1; + TH2* h2; + TH3* h3; + TH3* h3f; + + TString hname; + TString cOpt; + TString c2D; + TString c1D; + TString chopt; + + const Int_t ColMap[10] = {1, 2, 3, 4, 6, 7, 8, 9, 41, 46}; + const Int_t iPadLoc[10] = {2, 11, 5, 8, 1, 4, 7, 3, 6, 9}; + const Int_t SmT[10] = {1, 9, 1, 1, 1, 1, 1, 1, 1, 1}; + const Int_t iSm[10] = {0, 0, 1, 2, 0, 1, 2, 0, 1, 2}; + const Int_t iRpc[10] = {1, 1, 1, 1, 0, 0, 0, 2, 2, 2}; + + for (Int_t iSt = 0; iSt < iNSt; iSt++) { + switch (iOpt) { + case 0: + chopt = "hPullX_Station"; + hname = Form("%s_%d", chopt.Data(), iSt); + break; + case 1: + chopt = "hPullY_Station"; + hname = Form("%s_%d", chopt.Data(), iSt); + break; + case 2: + chopt = "hPullZ_Station"; + hname = Form("%s_%d", chopt.Data(), iSt); + break; + case 3: + chopt = "hPullT_Station"; + hname = Form("%s_%d", chopt.Data(), iSt); + break; + case 4: + chopt = "hPullTB_Station"; + hname = Form("%s_%d", chopt.Data(), iSt); + break; + + case 10: + chopt = "Efficiency"; + hname = Form("%s_%d", chopt.Data(), iSt); + break; + case 11: + chopt = "Total"; + hname = Form("%s_%d", chopt.Data(), iSt); + break; + case 12: + chopt = "Missed"; + hname = Form("%s_%d", chopt.Data(), iSt); + break; + case 13: + chopt = "Acc"; + hname = Form("%s_%d", chopt.Data(), iSt); + break; + case 14: hname = Form("hXY_AllTracks_%d", iSt); break; + + + case 20: + hname = + Form("cl_SmT%d_sm%03d_rpc%03d_Size", SmT[iSt], iSm[iSt], iRpc[iSt]); + break; + case 21: + hname = + Form("cl_SmT%d_sm%03d_rpc%03d_Pos", SmT[iSt], iSm[iSt], iRpc[iSt]); + break; + case 22: + hname = + Form("cl_SmT%d_sm%03d_rpc%03d_Pos_py", SmT[iSt], iSm[iSt], iRpc[iSt]); + break; + case 23: + hname = + Form("cl_SmT%d_sm%03d_rpc%03d_Tot", SmT[iSt], iSm[iSt], iRpc[iSt]); + break; + case 24: + hname = + Form("cl_SmT%d_sm%03d_rpc%03d_AvWalk", SmT[iSt], iSm[iSt], iRpc[iSt]); + break; + case 25: + hname = Form( + "cl_SmT%d_sm%03d_rpc%03d_AvLnWalk", SmT[iSt], iSm[iSt], iRpc[iSt]); + break; + case 26: + hname = + Form("cl_SmT%d_sm%03d_rpc%03d_Mul", SmT[iSt], iSm[iSt], iRpc[iSt]); + break; + case 27: + hname = + Form("cl_SmT%d_sm%03d_rpc%03d_Trms", SmT[iSt], iSm[iSt], iRpc[iSt]); + break; + case 28: + hname = + Form("cl_SmT%d_sm%03d_rpc%03d_DelPos", SmT[iSt], iSm[iSt], iRpc[iSt]); + break; + case 29: + hname = Form( + "cl_SmT%d_sm%03d_rpc%03d_DelTOff", SmT[iSt], iSm[iSt], iRpc[iSt]); + break; + + case 30: + hname = Form("cl_SmT%d_sm%03d_rpc%03d_Sel%02d_Size", + SmT[iSt], + iSm[iSt], + iRpc[iSt], + iSel); + break; + case 31: + hname = Form("cl_SmT%d_sm%03d_rpc%03d_Sel%02d_Pos", + SmT[iSt], + iSm[iSt], + iRpc[iSt], + iSel); + break; + case 32: + hname = Form("cl_SmT%d_sm%03d_rpc%03d_Sel%02d_Pos_py", + SmT[iSt], + iSm[iSt], + iRpc[iSt], + iSel); + break; + case 33: + hname = Form("cl_SmT%d_sm%03d_rpc%03d_Sel%02d_TOff", + SmT[iSt], + iSm[iSt], + iRpc[iSt], + iSel); + break; + case 34: + hname = Form("cl_SmT%d_sm%03d_rpc%03d_Sel%02d_TOff_pfx", + SmT[iSt], + iSm[iSt], + iRpc[iSt], + iSel); + break; + case 35: + hname = Form("cl_SmT%d_sm%03d_rpc%03d_Sel%02d_Tot", + SmT[iSt], + iSm[iSt], + iRpc[iSt], + iSel); + break; + case 36: + hname = Form("cl_SmT%d_sm%03d_rpc%03d_Sel%02d_AvWalk", + SmT[iSt], + iSm[iSt], + iRpc[iSt], + iSel); + break; + case 37: + hname = Form("cl_SmT%d_sm%03d_rpc%03d_Sel%02d_Mul", + SmT[iSt], + iSm[iSt], + iRpc[iSt], + iSel); + break; + case 38: + hname = Form("cl_SmT%d_sm%03d_rpc%03d_Sel%02d_DelTof", + SmT[iSt], + iSm[iSt], + iRpc[iSt], + iSel); + break; + case 39: + hname = Form("cl_SmT%d_sm%03d_rpc%03d_Sel%02d_dXdY", + SmT[iSt], + iSm[iSt], + iRpc[iSt], + iSel); + break; + + case 40: hname = Form("hXY_DX_%d_pyx_pfy", iSt); break; + case 41: hname = Form("hXY_DY_%d_pyx_pfy", iSt); break; + case 42: hname = Form("hXY_DT_%d_pyx_pfy", iSt); break; + case 43: hname = Form("hXY_TOT_%d_pyx_pfy", iSt); break; + case 44: hname = Form("hXY_CSZ_%d_pyx_pfy", iSt); break; + + default: cout << "iOpt mode not implemented " << endl; return; + } + + + can->cd(iPadLoc[iSt]); + h2 = (TH2*) gROOT->FindObjectAny(hname); + if (h2 != NULL) { + switch (i1D) { + case 0: h2->Draw("colz"); break; + case 1: + h2->Draw("colz"); + gPad->SetLogz(); + break; + case 11: h2->Draw(); break; + case 12: + h2->Draw(); + gPad->SetLogy(); + break; + case 13: h2->Draw("same"); break; + } + if (dYmax > 0.) { + h2->SetMinimum(-dYmax); + h2->SetMaximum(dYmax); + } + } else + cout << hname << " not found" << endl; + } + + can->SaveAs("pl_CosmicHst.pdf"); +} diff --git a/macro/beamtime/pl_CosmicHst1.C b/macro/beamtime/pl_CosmicHst1.C new file mode 100644 index 0000000000000000000000000000000000000000..6d7ed4560731c4f54a15ba169a96af6eaf058919 --- /dev/null +++ b/macro/beamtime/pl_CosmicHst1.C @@ -0,0 +1,226 @@ +void pl_CosmicHst1(Int_t iNSt = 6, + Int_t iOpt = 0, + Int_t iSel = 0, + Int_t i1D = 0, + Double_t dYmax = 0.) { + // TCanvas *can = new TCanvas("can22","can22"); + // can->Divide(2,2); + TCanvas* can = new TCanvas("can", "can", 50, 0, 400, 1000); + can->Divide(1, 6); + + gPad->SetFillColor(0); + gStyle->SetPalette(1); + gStyle->SetOptStat(kFALSE); + + gROOT->cd(); + gROOT->SetDirLevel(1); + + TH1* h; + TH1* h1; + TH2* h2; + TH3* h3; + TH3* h3f; + + TString hname; + TString cOpt; + TString c2D; + TString c1D; + TString chopt; + + const Int_t ColMap[10] = {1, 2, 3, 4, 6, 7, 8, 9, 41, 46}; + const Int_t iPadLoc[10] = {1, 6, 3, 2, 4, 5, 7, 3, 6, 9}; + //const Int_t iPadLoc[10]={1,2,3,4,5,6,7,3,6,9}; + const Int_t SmT[10] = {9, 9, 9, 9, 9, 9, 1, 1, 1, 1}; + const Int_t iSm[10] = {0, 0, 1, 1, 2, 2, 2, 0, 1, 2}; + const Int_t iRpc[10] = {0, 1, 0, 1, 0, 1, 0, 2, 2, 2}; + + for (Int_t iSt = 0; iSt < iNSt; iSt++) { + switch (iOpt) { + case 0: + chopt = "hPullX_Station"; + hname = Form("%s_%d", chopt.Data(), iSt); + break; + case 1: + chopt = "hPullY_Station"; + hname = Form("%s_%d", chopt.Data(), iSt); + break; + case 2: + chopt = "hPullZ_Station"; + hname = Form("%s_%d", chopt.Data(), iSt); + break; + case 3: + chopt = "hPullT_Station"; + hname = Form("%s_%d", chopt.Data(), iSt); + break; + case 4: + chopt = "hPullTB_Station"; + hname = Form("%s_%d", chopt.Data(), iSt); + break; + + case 10: + chopt = "Efficiency"; + hname = Form("%s_%d", chopt.Data(), iSt); + break; + case 11: + chopt = "Total"; + hname = Form("%s_%d", chopt.Data(), iSt); + break; + case 12: + chopt = "Missed"; + hname = Form("%s_%d", chopt.Data(), iSt); + break; + case 13: + chopt = "Acc"; + hname = Form("%s_%d", chopt.Data(), iSt); + break; + case 14: hname = Form("hXY_AllTracks_%d", iSt); break; + + + case 20: + hname = + Form("cl_SmT%d_sm%03d_rpc%03d_Size", SmT[iSt], iSm[iSt], iRpc[iSt]); + break; + case 21: + hname = + Form("cl_SmT%d_sm%03d_rpc%03d_Pos", SmT[iSt], iSm[iSt], iRpc[iSt]); + break; + case 22: + hname = + Form("cl_SmT%d_sm%03d_rpc%03d_Pos_py", SmT[iSt], iSm[iSt], iRpc[iSt]); + break; + case 23: + hname = + Form("cl_SmT%d_sm%03d_rpc%03d_Tot", SmT[iSt], iSm[iSt], iRpc[iSt]); + break; + case 24: + hname = + Form("cl_SmT%d_sm%03d_rpc%03d_AvWalk", SmT[iSt], iSm[iSt], iRpc[iSt]); + break; + case 25: + hname = Form( + "cl_SmT%d_sm%03d_rpc%03d_AvLnWalk", SmT[iSt], iSm[iSt], iRpc[iSt]); + break; + case 26: + hname = + Form("cl_SmT%d_sm%03d_rpc%03d_Mul", SmT[iSt], iSm[iSt], iRpc[iSt]); + break; + case 27: + hname = + Form("cl_SmT%d_sm%03d_rpc%03d_Trms", SmT[iSt], iSm[iSt], iRpc[iSt]); + break; + case 28: + hname = + Form("cl_SmT%d_sm%03d_rpc%03d_DelPos", SmT[iSt], iSm[iSt], iRpc[iSt]); + break; + case 29: + hname = Form( + "cl_SmT%d_sm%03d_rpc%03d_DelTOff", SmT[iSt], iSm[iSt], iRpc[iSt]); + break; + + case 30: + hname = Form("cl_SmT%d_sm%03d_rpc%03d_Sel%02d_Size", + SmT[iSt], + iSm[iSt], + iRpc[iSt], + iSel); + break; + case 31: + hname = Form("cl_SmT%d_sm%03d_rpc%03d_Sel%02d_Pos", + SmT[iSt], + iSm[iSt], + iRpc[iSt], + iSel); + break; + case 32: + hname = Form("cl_SmT%d_sm%03d_rpc%03d_Sel%02d_Pos_py", + SmT[iSt], + iSm[iSt], + iRpc[iSt], + iSel); + break; + case 33: + hname = Form("cl_SmT%d_sm%03d_rpc%03d_Sel%02d_TOff", + SmT[iSt], + iSm[iSt], + iRpc[iSt], + iSel); + break; + case 34: + hname = Form("cl_SmT%d_sm%03d_rpc%03d_Sel%02d_TOff_pfx", + SmT[iSt], + iSm[iSt], + iRpc[iSt], + iSel); + break; + case 35: + hname = Form("cl_SmT%d_sm%03d_rpc%03d_Sel%02d_Tot", + SmT[iSt], + iSm[iSt], + iRpc[iSt], + iSel); + break; + case 36: + hname = Form("cl_SmT%d_sm%03d_rpc%03d_Sel%02d_AvWalk", + SmT[iSt], + iSm[iSt], + iRpc[iSt], + iSel); + break; + case 37: + hname = Form("cl_SmT%d_sm%03d_rpc%03d_Sel%02d_Mul", + SmT[iSt], + iSm[iSt], + iRpc[iSt], + iSel); + break; + case 38: + hname = Form("cl_SmT%d_sm%03d_rpc%03d_Sel%02d_DelTof", + SmT[iSt], + iSm[iSt], + iRpc[iSt], + iSel); + break; + case 39: + hname = Form("cl_SmT%d_sm%03d_rpc%03d_Sel%02d_dXdY", + SmT[iSt], + iSm[iSt], + iRpc[iSt], + iSel); + break; + + case 40: hname = Form("hXY_DX_%d_pyx_pfy", iSt); break; + case 41: hname = Form("hXY_DY_%d_pyx_pfy", iSt); break; + case 42: hname = Form("hXY_DT_%d_pyx_pfy", iSt); break; + case 43: hname = Form("hXY_TOT_%d_pyx_pfy", iSt); break; + case 44: hname = Form("hXY_CSZ_%d_pyx_pfy", iSt); break; + + default: cout << "iOpt mode not implemented " << endl; return; + } + + + can->cd(iPadLoc[iSt]); + h2 = (TH2*) gROOT->FindObjectAny(hname); + if (h2 != NULL) { + switch (i1D) { + case 0: h2->Draw("colz"); break; + case 1: + h2->Draw("colz"); + gPad->SetLogz(); + break; + case 11: h2->Draw(); break; + case 12: + h2->Draw(); + gPad->SetLogy(); + break; + case 13: h2->Draw("same"); break; + } + if (dYmax > 0.) { + h2->SetMinimum(-dYmax); + h2->SetMaximum(dYmax); + } + } else + cout << hname << " not found" << endl; + } + + can->SaveAs("pl_CosmicHst1.pdf"); +} diff --git a/macro/beamtime/pl_Dut_DTLH.C b/macro/beamtime/pl_Dut_DTLH.C new file mode 100644 index 0000000000000000000000000000000000000000..47bda97d8dddbe11ca5be599db747f6ddfc4eb6e --- /dev/null +++ b/macro/beamtime/pl_Dut_DTLH.C @@ -0,0 +1,120 @@ +void pl_Dut_DTLH(Int_t iDut = 910, TString sysinfo = "") { + gROOT->LoadMacro("pl_Datime.C"); + // TCanvas *can = new TCanvas("can22","can22"); + // can->Divide(2,2); + TCanvas* can = new TCanvas("can", "can", 48, 55, 700, 700); + can->Divide(2, 4); + + gPad->SetFillColor(0); + gStyle->SetPalette(1); + gStyle->SetOptStat(kTRUE); + + gROOT->cd(); + gROOT->SetDirLevel(1); + // cout << " DirLevel "<< gROOT->GetDirLevel()<< endl; + + TH1* h; + TH1* h1; + TH2* h2; + TH2* h2f; + TH2* h2m; + // if (hPla!=NULL) hPla->Delete(); + TString hname = ""; + TProfile* h2pfx = NULL; + + can->cd(1); + + gROOT->cd(); + hname = Form("hDutDTLH_CluSize_%d", iDut); + cout << " Look for histo " << hname << endl; + h2 = (TH2*) gROOT->FindObjectAny(hname); + if (h2 != NULL) { + h2->Draw("colz"); + h2->ProfileX()->Draw("same"); + Double_t dMeanCluSize = h2->ProjectionY()->GetMean(); + cout << " Mean Cluster size: " << dMeanCluSize << endl; + gPad->SetLogz(); + } else { + cout << hname << " not found" << endl; + } + + can->cd(2); + hname = Form("hDutDTLH_Tot_%d", iDut); + h2 = (TH2*) gROOT->FindObjectAny(hname); + if (h2 != NULL) { + h2->Draw("colz"); + h2->ProfileX()->Draw("same"); + gPad->SetLogz(); + } else { + cout << hname << " not found" << endl; + } + + + can->cd(3); + hname = Form("hDutDTLH_Mul_%d", iDut); + h2 = (TH2*) gROOT->FindObjectAny(hname); + if (h2 != NULL) { + h2->Draw("colz"); + h2->ProfileX()->Draw("same"); + gPad->SetLogz(); + } else { + cout << hname << " not found" << endl; + } + + + can->cd(4); + hname = Form("hDutDTLH_DD_Found_%d", iDut); + h2 = (TH2*) gROOT->FindObjectAny(hname); + if (h2 != NULL) { + h2->Draw("colz"); + h2->ProfileX()->Draw("same"); + gPad->SetLogz(); + } else { + cout << hname << " not found" << endl; + } + + + can->cd(5); + hname = Form("hDutDTLH_DDH_Found_%d", iDut); + h2f = (TH2*) gROOT->FindObjectAny(hname); + if (h2f != NULL) { + h2f->Draw("colz"); + h2f->ProfileX()->Draw("same"); + gPad->SetLogz(); + } else { + cout << hname << " not found" << endl; + } + + can->cd(6); + hname = Form("hDutDTLH_DD_Missed_%d", iDut); + h2m = (TH2*) gROOT->FindObjectAny(hname); + if (h2m != NULL) { + h2m->Draw("colz"); + h2m->ProfileX()->Draw("same"); + gPad->SetLogz(); + } else { + cout << hname << " not found" << endl; + } + + can->cd(7); + hname = Form("hDutDTLH_TIS_%d", iDut); + h2 = (TH2*) gROOT->FindObjectAny(hname); + if (h2m != NULL) { + h2->Draw("colz"); + h2->ProfileX()->Draw("same"); + gPad->SetLogz(); + } else { + cout << hname << " not found" << endl; + } + + can->cd(8); + TH2* DDeff = (TH2*) h2f->Clone("DDeff"); + DDeff->Add(h2f, h2m, 1., 1.); + DDeff->Divide(h2f, DDeff, 1., 1., "B"); + DDeff->Draw("colz"); + + TString FADD = Form("pl_Datime(\"%s\")", sysinfo.Data()); + gInterpreter->ProcessLine(FADD.Data()); + + can->SaveAs(Form("pl_Dut_DTLH_%d.pdf", iDut)); +} diff --git a/macro/beamtime/pl_Dut_Vel.C b/macro/beamtime/pl_Dut_Vel.C new file mode 100644 index 0000000000000000000000000000000000000000..2d865661d05495884694880f9112f25c83f4f9e7 --- /dev/null +++ b/macro/beamtime/pl_Dut_Vel.C @@ -0,0 +1,59 @@ +void pl_Dut_Vel(const char* cDut = "900", + Double_t Tstart = 0., + Double_t Tend = 50., + TString sysinfo = "") { + gROOT->LoadMacro("pl_Datime.C"); + // TCanvas *can = new TCanvas("can22","can22"); + // can->Divide(2,2); + TCanvas* can = new TCanvas("can", "can", 48, 55, 700, 700); + can->Divide(1, 2); + + gPad->SetFillColor(0); + gStyle->SetPalette(1); + gStyle->SetOptStat(kTRUE); + + gROOT->cd(); + gROOT->SetDirLevel(1); + // cout << " DirLevel "<< gROOT->GetDirLevel()<< endl; + + TH1* h1; + TH1* h1_1; + TH1* h1_2; + + TString hname = ""; + + can->cd(1); + + gROOT->cd(); + hname = Form("hDutVel_Found_%s", cDut); + cout << " Look for histo " << hname << endl; + h1_1 = (TH1*) gROOT->FindObjectAny(hname); + if (h1_1 != NULL) { + h1_1->Draw(""); + } else { + cout << hname << " not found" << endl; + } + + hname = Form("hDutVel_Missed_%s", cDut); + h1_2 = (TH1*) gROOT->FindObjectAny(hname); + if (h1_2 != NULL) { + h1_2->Draw("same"); + h1_2->SetLineColor(kRed); + } else { + cout << hname << " not found" << endl; + } + + can->cd(2); + h1 = (TH1*) h1_1->Clone(); + h1->Add(h1_1, h1_2, 1., 1.); + TEfficiency* pEffVel = new TEfficiency(*h1_1, *h1); + pEffVel->SetTitle("Efficiency"); + pEffVel->Draw("AP"); + gPad->Update(); + auto graph = pEffVel->GetPaintedGraph(); + graph->GetXaxis()->SetRangeUser(Tstart, Tend); + gPad->Update(); + + + can->SaveAs(Form("pl_Dut_Vel_%s.pdf", cDut)); +} diff --git a/macro/beamtime/pl_Eff_Chi.C b/macro/beamtime/pl_Eff_Chi.C new file mode 100644 index 0000000000000000000000000000000000000000..49b952e572b4e96f3caafa37dbeb65a8e2275885 --- /dev/null +++ b/macro/beamtime/pl_Eff_Chi.C @@ -0,0 +1,91 @@ +void pl_Eff_Chi(Int_t iDut = 910, + Double_t dEffMin = 0.5, + Double_t dEffMax = 1., + TString sysinfo = "") { + gROOT->LoadMacro("pl_Datime.C"); + // TCanvas *can = new TCanvas("can22","can22"); + // can->Divide(2,2); + TCanvas* can = new TCanvas("can", "can", 48, 55, 700, 700); + can->Divide(2, 2); + + gPad->SetFillColor(0); + gStyle->SetPalette(1); + gStyle->SetOptStat(kTRUE); + + gROOT->cd(); + gROOT->SetDirLevel(1); + // cout << " DirLevel "<< gROOT->GetDirLevel()<< endl; + + TH1* h; + TH1* h1; + TH1* h1f; + TH1* h1m; + TH1* h1all; + TH2* h2; + // if (hPla!=NULL) hPla->Delete(); + TString hname = ""; + TProfile* h2pfx = NULL; + + can->cd(1); + Double_t Nfound = 0.; + Double_t Nmissed = 0.; + gROOT->cd(); + hname = Form("hDutChi_Found_%03d", 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(); + } else { + cout << hname << " not found" << endl; + } + + hname = Form("hDutChi_Missed_%03d", iDut); + h1 = (TH1*) gROOT->FindObjectAny(hname); + if (h1 != NULL) { + h1m = (TH1*) h1->Clone(); + Nmissed = h1m->GetEntries(); + h1m->Draw("same"); + h1m->SetLineColor(2); + } else { + cout << hname << " not found" << endl; + } + + can->cd(2); + + h1m->Draw(); + h1f->Draw("same"); + + can->cd(3); + + h1all = (TH1*) h1f->Clone(); + h1all->Add(h1m, h1f, 1., 1.); + + TEfficiency* pEffDut = new TEfficiency(*h1f, *h1all); + pEffDut->SetTitle("Efficiency of DUT"); + pEffDut->Draw("AP"); + gPad->Update(); + + auto graph = pEffDut->GetPaintedGraph(); + graph->SetMinimum(dEffMin); + graph->SetMaximum(dEffMax); + // graph->GetXaxis()->SetRangeUser(0.,10.); + /* + auto heff = pEffDut->GetPaintedHistogram(); + heff->SetMinimum(dEffMin); + heff->SetMaximum(dEffMax); + */ + gPad->Update(); + gPad->SetGridx(); + gPad->SetGridy(); + + Double_t dEff = Nfound / (Nfound + Nmissed); + cout << "Average efficiency of Dut: " << dEff << endl; + + TString FADD = Form("pl_Datime(\"%s\")", sysinfo.Data()); + gInterpreter->ProcessLine(FADD.Data()); + + can->SaveAs(Form("pl_Eff_Chi_%03d.pdf", iDut)); +} diff --git a/macro/beamtime/pl_Eff_Mul.C b/macro/beamtime/pl_Eff_Mul.C new file mode 100644 index 0000000000000000000000000000000000000000..0353c14490df85858a6b076815a2938a591c47a7 --- /dev/null +++ b/macro/beamtime/pl_Eff_Mul.C @@ -0,0 +1,91 @@ +void pl_Eff_Mul(Int_t iDut = 910, + Double_t dEffMin = 0.5, + Double_t dEffMax = 1., + TString sysinfo = "") { + gROOT->LoadMacro("pl_Datime.C"); + // TCanvas *can = new TCanvas("can22","can22"); + // can->Divide(2,2); + TCanvas* can = new TCanvas("can", "can", 48, 55, 700, 700); + can->Divide(2, 2); + + gPad->SetFillColor(0); + gStyle->SetPalette(1); + gStyle->SetOptStat(kTRUE); + + gROOT->cd(); + gROOT->SetDirLevel(1); + // cout << " DirLevel "<< gROOT->GetDirLevel()<< endl; + + TH1* h; + TH1* h1; + TH1* h1f; + TH1* h1m; + TH1* h1all; + TH2* h2; + // if (hPla!=NULL) hPla->Delete(); + TString hname = ""; + TProfile* h2pfx = NULL; + + can->cd(1); + Double_t Nfound = 0.; + Double_t Nmissed = 0.; + gROOT->cd(); + hname = Form("hDutMul_Found_%03d", 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(); + } else { + cout << hname << " not found" << endl; + } + + hname = Form("hDutMul_Missed_%d", iDut); + h1 = (TH1*) gROOT->FindObjectAny(hname); + if (h1 != NULL) { + h1m = (TH1*) h1->Clone(); + Nmissed = h1m->GetEntries(); + h1m->Draw("same"); + h1m->SetLineColor(2); + } else { + cout << hname << " not found" << endl; + } + + can->cd(2); + + h1m->Draw(); + h1f->Draw("same"); + + can->cd(3); + + h1all = (TH1*) h1f->Clone(); + h1all->Add(h1m, h1f, 1., 1.); + + TEfficiency* pEffDut = new TEfficiency(*h1f, *h1all); + pEffDut->SetTitle("Efficiency of DUT"); + pEffDut->Draw("AP"); + gPad->Update(); + + auto graph = pEffDut->GetPaintedGraph(); + graph->SetMinimum(dEffMin); + graph->SetMaximum(dEffMax); + // graph->GetXaxis()->SetRangeUser(0.,10.); + /* + auto heff = pEffDut->GetPaintedHistogram(); + heff->SetMinimum(dEffMin); + heff->SetMaximum(dEffMax); + */ + gPad->Update(); + gPad->SetGridx(); + gPad->SetGridy(); + + Double_t dEff = Nfound / (Nfound + Nmissed); + cout << "Average efficiency of Dut: " << dEff << endl; + + TString FADD = Form("pl_Datime(\"%s\")", sysinfo.Data()); + gInterpreter->ProcessLine(FADD.Data()); + + can->SaveAs(Form("pl_Eff_Mul_%03d.pdf", iDut)); +} diff --git a/macro/beamtime/pl_Eff_TIR.C b/macro/beamtime/pl_Eff_TIR.C new file mode 100644 index 0000000000000000000000000000000000000000..801c31ffa7b883249029a176d8d9b3d85a224d5d --- /dev/null +++ b/macro/beamtime/pl_Eff_TIR.C @@ -0,0 +1,112 @@ +void pl_Eff_TIR(Int_t iDut = 900, + Double_t dEffMin = 0., + Double_t dEffMax = 1., + Int_t iBl = 0, + Int_t iBh = 8, + Double_t TIRmin = 0., + Double_t TIRmax = 30., + TString sysinfo = "") { + gROOT->LoadMacro("pl_Datime.C"); + // TCanvas *can = new TCanvas("can22","can22"); + // can->Divide(2,2); + TCanvas* can = new TCanvas("can", "can", 48, 55, 450, 600); + can->Divide(1, 3); + + gPad->SetFillColor(0); + gStyle->SetPalette(1); + gStyle->SetOptStat(kTRUE); + + gROOT->cd(); + gROOT->SetDirLevel(1); + // cout << " DirLevel "<< gROOT->GetDirLevel()<< endl; + + TH1* h; + TH1* h1; + TH2* h2; + TH1* h1f; + TH1* h1m; + TH1* h1all; + TH2* h2f; + TH2* h2m; + // if (hPla!=NULL) hPla->Delete(); + TString hname = ""; + TProfile* h2pfx = NULL; + + can->cd(1); + gPad->Divide(2, 1); + gPad->cd(1); + Double_t Nfound = 0.; + Double_t Nmissed = 0.; + gROOT->cd(); + hname = Form("hDutTIR_Found_%03d", iDut); + cout << " Look for histo " << hname << endl; + h2 = (TH2*) gROOT->FindObjectAny(hname); + if (h2 != NULL) { + h2->Draw("colz"); + h2->GetXaxis()->SetRangeUser(TIRmin, TIRmax); + + gPad->SetLogz(); + h2f = (TH2*) h2->Clone(); + Nfound = h2f->GetEntries(); + h1f = (TH1*) h2f->ProjectionX("_px", iBl + 1, iBh + 1); + } else { + cout << hname << " not found" << endl; + } + + can->cd(1); + // gPad->Divide(2,1); + gPad->cd(2); + hname = Form("hDutTIR_Missed_%03d", iDut); + h2 = (TH2*) gROOT->FindObjectAny(hname); + if (h2 != NULL) { + h2m = (TH2*) h2->Clone(); + Nmissed = h2m->GetEntries(); + h2m->Draw("colz"); + h2m->GetXaxis()->SetRangeUser(TIRmin, TIRmax); + + gPad->SetLogz(); + h1m = (TH1*) h2m->ProjectionX("_px", iBl + 1, iBh + 1); + } else { + cout << hname << " not found" << endl; + } + + can->cd(2); + h1all = (TH1*) h1f->Clone("hDutTIR_all"); + h1all->Add(h1m, h1f, 1., 1.); + h1all->SetMinimum(h1all->GetMaximum() * 1.E-4); + h1all->Draw(); + h1all->SetLineColor(kBlack); + h1f->Draw("same"); + h1f->SetLineColor(kBlue); + h1m->Draw("same"); + h1m->SetLineColor(kRed); + gPad->SetLogy(); + h1all->GetXaxis()->SetRangeUser(TIRmin, TIRmax); + gPad->Update(); + + can->cd(3); + + TEfficiency* pEffDut = new TEfficiency(*h1f, *h1all); + pEffDut->SetTitle(Form("Efficiency of DUT, GET4 %d - %d ", iBl, iBh)); + pEffDut->SetName("hDutTIR_eff"); + pEffDut->Draw("AP"); + gPad->Update(); + + auto graph = pEffDut->GetPaintedGraph(); + graph->SetMinimum(dEffMin); + graph->SetMaximum(dEffMax); + graph->GetXaxis()->SetRangeUser(TIRmin, TIRmax); + /* + auto heff = pEffDut->GetPaintedHistogram(); + heff->SetMinimum(dEffMin); + heff->SetMaximum(dEffMax); + */ + gPad->Update(); + gPad->SetGridx(); + gPad->SetGridy(); + + TString FADD = Form("pl_Datime(\"%s\")", sysinfo.Data()); + gInterpreter->ProcessLine(FADD.Data()); + + can->SaveAs(Form("pl_Eff_TIR_%03d.pdf", iDut)); +} diff --git a/macro/beamtime/pl_Eff_XY.C b/macro/beamtime/pl_Eff_XY.C new file mode 100644 index 0000000000000000000000000000000000000000..6628fedaa951a9f8bbf0ccb513df2bf273dace47 --- /dev/null +++ b/macro/beamtime/pl_Eff_XY.C @@ -0,0 +1,104 @@ +void pl_Eff_XY(Int_t iDut = 910, + Double_t dEffMin = 0.5, + Double_t dEffMax = 1., + Double_t dThr = 0.01, + TString sysinfo = "") { + gROOT->LoadMacro("pl_Datime.C"); + // TCanvas *can = new TCanvas("can22","can22"); + // can->Divide(2,2); + TCanvas* can = new TCanvas("can", "can", 48, 55, 700, 700); + can->Divide(2, 2); + + gPad->SetFillColor(0); + gStyle->SetPalette(1); + gStyle->SetOptStat(kTRUE); + + gROOT->cd(); + gROOT->SetDirLevel(1); + // cout << " DirLevel "<< gROOT->GetDirLevel()<< endl; + + TH1* h; + TH1* h1; + TH2* h2f; + TH2* h2acc; + TH2* h2m; + TH2* h2all; + TH2* h2; + // if (hPla!=NULL) hPla->Delete(); + TString hname = ""; + TProfile* h2pfx = NULL; + + can->cd(1); + Double_t Nfound = 0.; + Double_t Nmissed = 0.; + gROOT->cd(); + hname = Form("hDutXY_Found_%03d", iDut); + cout << " Look for histo " << hname << endl; + h2 = (TH2*) gROOT->FindObjectAny(hname); + if (h2 != NULL) { + h2->Draw("colz"); + h2f = (TH2*) h2->Clone(); + h2acc = (TH2*) h2->Clone("Dut acceptance"); + h2acc->Reset(); + Int_t Nbins = h2->GetNbinsX() * h2->GetNbinsY(); + Double_t dMax = dThr * h2->GetMaximum(); + for (Int_t i = 0; i < Nbins; i++) + h2->GetBinContent(i + 1) < dMax ? h2acc->SetBinContent(i + 1, 0.) + : h2acc->SetBinContent(i + 1, 1.); + + } else { + cout << hname << " not found" << endl; + } + + can->cd(2); + hname = Form("hDutXY_Missed_%03d", iDut); + h2 = (TH2*) gROOT->FindObjectAny(hname); + if (h2 != NULL) { + h2m = (TH2*) h2->Clone(); + h2m->Draw("colz"); + } else { + cout << hname << " not found" << endl; + } + + + can->cd(3); + TH2* h2fA = (TH2*) h2f->Clone("hDutXY_FoundAcc"); + h2fA->Multiply(h2fA, h2acc, 1., 1., "B"); + Nfound = h2fA->GetEntries(); + + TH2* h2mA = (TH2*) h2m->Clone("hDutXY_MissedAcc"); + h2mA->Multiply(h2mA, h2acc, 1., 1., "B"); + Nmissed = h2mA->GetEntries(); + + h2all = (TH2*) h2f->Clone("hDutXY_all"); + h2all->Add(h2mA, h2fA, 1., 1.); + + TEfficiency* pEffDut = new TEfficiency(*h2fA, *h2all); + pEffDut->SetTitle("Efficiency of DUT"); + pEffDut->SetName("hDutXY_eff"); + pEffDut->Draw("colz"); + gPad->Update(); + + auto h2Eff = pEffDut->GetPaintedHistogram(); + h2Eff->SetMinimum(dEffMin); + h2Eff->SetMaximum(dEffMax); + + Double_t dEff = Nfound / (Nfound + Nmissed); + cout << Form("Average efficiency of Dut in acceptance: with thr %5.2f: %6.3f", + dThr, + dEff) + << endl; + + can->cd(4); + TPaveLabel* tit = new TPaveLabel( + 0.1, 0.1, 0.9, 0.9, Form(" average efficiency of %03d: %5.3f", iDut, dEff)); + tit->SetFillColor(0); + tit->SetTextFont(52); + tit->SetBorderSize(0); + tit->Draw(); + + TString FADD = Form("pl_Datime(\"%s\")", sysinfo.Data()); + gInterpreter->ProcessLine(FADD.Data()); + + can->SaveAs(Form("pl_Eff_XY_%03d.pdf", iDut)); +} diff --git a/macro/beamtime/pl_EvCluMul.C b/macro/beamtime/pl_EvCluMul.C new file mode 100644 index 0000000000000000000000000000000000000000..5149639a78b489e484c2750fa7d8b820f7e71d34 --- /dev/null +++ b/macro/beamtime/pl_EvCluMul.C @@ -0,0 +1,50 @@ +void pl_EvCluMul(Double_t dTmin = 0., Double_t dTmax = 1800.) { + // 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, 2, 0.01, 0.01); + // can->Divide(4,4,0.01,0.01); + // can->Divide(2,2,0,0); + Float_t lsize = 0.09; + + gPad->SetFillColor(0); + gStyle->SetPalette(1); + gStyle->SetLabelSize(lsize); + + //gStyle->SetStatY(0.5); + //gStyle->SetStatX(0.5); + gStyle->SetStatW(0.5); + gStyle->SetStatH(0.3); + + gStyle->SetOptStat(kFALSE); + //gROOT->cd(); + //gROOT->SetDirLevel(2); + + TH1* h; + TH2* h2; + TString hname; + + can->cd(1); + hname = Form("hEvCluMul"); + h2 = (TH2*) gROOT->FindObjectAny(hname); + h2->Draw("colz"); + gPad->SetLogz(); + h2->GetXaxis()->SetRangeUser(dTmin, dTmax); + + can->cd(2); + TH1* hy = h2->ProjectionY(); + hy->Draw(); + gPad->SetLogy(); + + can->cd(3); + TProfile* hpx = h2->ProfileX(); + hpx->Draw(); + // gPad->SetLogz(); + hpx->GetXaxis()->SetRangeUser(dTmin, dTmax); + + can->cd(4); + + + can->SaveAs(Form("pl_EvCluMul.pdf")); +} diff --git a/macro/beamtime/pl_TIR.C b/macro/beamtime/pl_TIR.C new file mode 100644 index 0000000000000000000000000000000000000000..413e480acbb843d13348da7ca6a0e961737d6318 --- /dev/null +++ b/macro/beamtime/pl_TIR.C @@ -0,0 +1,136 @@ +void pl_TIR(Double_t Tstart = 0., + Double_t Tend = 1000., + Double_t dFracMax = 1.05, + 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, 600, 600); + can->Divide(1, 3); + + gPad->SetFillColor(0); + gStyle->SetPalette(1); + gStyle->SetOptStat(kTRUE); + + gROOT->cd(); + gROOT->SetDirLevel(1); + // cout << " DirLevel "<< gROOT->GetDirLevel()<< endl; + + TH1* h; + TH1* h1; + TH2* h2; + // if (hPla!=NULL) hPla->Delete(); + TString hname = ""; + TProfile* h2pfx = NULL; + + can->cd(1); + gROOT->cd(); + hname = "TIR_all"; + h1 = (TH1*) gROOT->FindObjectAny(hname); + if (h1 != NULL) { + h1->GetXaxis()->SetRangeUser(Tstart, Tend); + h1->Draw(""); + h1->SetLineColor(3); + h1->GetXaxis()->SetTitle("time [s]"); + } else { + cout << hname << " not found" << endl; + } + TH1* hTIR_all = (TH1*) h1->Clone(); + + if (NULL != hTIR_all) { + hTIR_all->SetMinimum(hTIR_all->GetMaximum() / 1.E3); + hTIR_all->Draw(); + } else + return; + + hname = "TIR_sel"; + h1 = (TH1*) gROOT->FindObjectAny(hname); + if (h1 != NULL) { + h1->Draw("same"); + h1->GetXaxis()->SetTitle("time [s]"); + gPad->SetLogy(); + } else { + cout << hname << " not found" << endl; + } + TH1* hTIR_sel = (TH1*) h1->Clone(); + + hname = "TIR_sel1"; + h1 = (TH1*) gROOT->FindObjectAny(hname); + if (h1 != NULL) { + h1->Draw("same"); + h1->SetLineColor(2); + // hTIR_all->SetMinimum( h1->GetMinimum() ); + // gPad->Update(); + } else { + cout << hname << " not found" << endl; + } + TH1* hTIR_sel1 = (TH1*) h1->Clone(); + + hname = "TIR_sel2"; + h1 = (TH1*) gROOT->FindObjectAny(hname); + if (h1 != NULL) { + h1->Draw("same"); + h1->SetLineColor(7); + } else { + cout << hname << " not found" << endl; + } + TH1* hTIR_sel2 = (TH1*) h1->Clone(); + + can->cd(2); + gROOT->cd(); + /* + TH1F *hTIRselfrac = (TH1F *)hTIR_all->Clone(); + hTIRselfrac->SetName("hTIRselfrac"); + hTIRselfrac->SetTitle("MRef - selector probability"); + hTIRselfrac->Divide(hTIR_sel, hTIR_all, 1., 1., "B"); + hTIRselfrac->SetMaximum(dFracMax); + hTIRselfrac->SetMinimum(0.0001); + hTIRselfrac->Draw(); + hTIRselfrac->SetLineColor(hTIR_sel->GetLineColor()); + */ + + TEfficiency* pEffSel = new TEfficiency(*hTIR_sel2, *hTIR_all); + pEffSel->SetTitle("Selector (MRef & Sel2) efficiency"); + pEffSel->Draw("AP"); + gPad->Update(); + auto graph = pEffSel->GetPaintedGraph(); + graph->GetXaxis()->SetRangeUser(Tstart, Tend); + gPad->Update(); + /* + TH1F *hTIRsel1frac = (TH1F *)hTIR_all->Clone(); + hTIRsel1frac->SetName("hTIRsel1frac"); + hTIRsel1frac->SetTitle("Dut & MRef coinicidence probability"); + hTIRsel1frac->Divide(hTIR_sel1, hTIR_all, 1., 1., "B"); + hTIRsel1frac->Draw("same"); + hTIRsel1frac->SetLineColor(hTIR_sel1->GetLineColor()); + */ + // gPad->SetLogy(); + + can->cd(3); + /* + TH1F *hselsel1frac = (TH1F *)hTIR_sel->Clone(); + hselsel1frac->SetName("hselsel1frac"); + hselsel1frac->SetTitle("Relative efficiency of DUT"); + // hselsel1frac->Divide(hTIR_sel1, hTIR_sel, 1., 1., "B"); + hselsel1frac->Divide(hTIR_sel1, hTIR_sel, 1., 1., ""); + hselsel1frac->Draw("E1"); + hselsel1frac->SetLineColor(hTIR_sel1->GetLineColor()); +*/ + TEfficiency* pEffDut = new TEfficiency(*hTIR_sel1, *hTIR_sel2); + pEffDut->SetTitle("Relative efficiency of DUT"); + pEffDut->Draw("AP"); + // gPad->SetLogy(); + gPad->Update(); + auto gEffDut = pEffDut->GetPaintedGraph(); + gEffDut->GetXaxis()->SetRangeUser(Tstart, Tend); + gEffDut->SetMaximum(dFracMax); + + gPad->Update(); + + TString FADD = Form("pl_Datime(\"%s\")", sysinfo.Data()); + if (gROOT->IsBatch()) { gInterpreter->ProcessLine(FADD.Data()); } + + can->SaveAs(Form("pl_TIR.pdf")); +} diff --git a/macro/beamtime/pl_TIS2.C b/macro/beamtime/pl_TIS2.C new file mode 100644 index 0000000000000000000000000000000000000000..e396149d9a2de111ad7118d5be77d3a9c4a95927 --- /dev/null +++ b/macro/beamtime/pl_TIS2.C @@ -0,0 +1,77 @@ +void pl_TIS2(Double_t dTmin = 0., Double_t dTmax = 1., TString sysinfo = "") { + gROOT->LoadMacro("pl_Datime.C"); + // TCanvas *can = new TCanvas("can22","can22"); + // can->Divide(2,2); + TCanvas* can = new TCanvas("can", "can", 48, 55, 750, 600); + can->Divide(2, 3); + + gPad->SetFillColor(0); + gStyle->SetPalette(1); + gStyle->SetOptStat(kTRUE); + + gROOT->cd(); + gROOT->SetDirLevel(1); + // cout << " DirLevel "<< gROOT->GetDirLevel()<< endl; + + TH1* h; + TH1* h1; + TH1 *hhpx, *htpx; + TH2* h2; + // if (hPla!=NULL) hPla->Delete(); + TString hname = ""; + TProfile* hhpfx = NULL; + TProfile* htpfx = NULL; + + can->cd(1); + gROOT->cd(); + hname = "TIS_Nhit"; + h2 = (TH2*) gROOT->FindObjectAny(hname); + if (h2 != NULL) { + h2->Draw("colz"); + gPad->SetLogz(); + hhpx = (TH1*) h2->ProjectionX(); + hhpfx = (TProfile*) h2->ProfileX(); + //h1->SetLineColor(3); + //h1->GetXaxis()->SetTitle("time [s]"); + } else { + cout << hname << " not found" << endl; + } + + can->cd(2); + gROOT->cd(); + hname = "TIS_Ntrk"; + h2 = (TH2*) gROOT->FindObjectAny(hname); + if (h2 != NULL) { + h2->Draw("colz"); + gPad->SetLogz(); + htpx = (TH1*) h2->ProjectionX("htpx", 2, -1); + htpfx = (TProfile*) h2->ProfileX(); + } else { + cout << hname << " not found" << endl; + } + + can->cd(3); + gROOT->cd(); + hhpx->Draw(); + hhpx->GetXaxis()->SetRangeUser(dTmin, dTmax); + + can->cd(4); + gROOT->cd(); + htpx->Draw(); + htpx->GetXaxis()->SetRangeUser(dTmin, dTmax); + + can->cd(5); + gROOT->cd(); + hhpfx->Draw(); + hhpfx->GetXaxis()->SetRangeUser(dTmin, dTmax); + + can->cd(6); + gROOT->cd(); + htpfx->Draw(); + htpfx->GetXaxis()->SetRangeUser(dTmin, dTmax); + + TString FADD = Form("pl_Datime(\"%s\")", sysinfo.Data()); + // gInterpreter->ProcessLine(FADD.Data()); + + can->SaveAs(Form("pl_TIS2.pdf")); +} diff --git a/macro/beamtime/pl_UHit.C b/macro/beamtime/pl_UHit.C new file mode 100644 index 0000000000000000000000000000000000000000..3376eebe64ce0d519efd61211fa75438c9f28271 --- /dev/null +++ b/macro/beamtime/pl_UHit.C @@ -0,0 +1,207 @@ +void pl_UHit(Int_t iNSt = 10, + Int_t iOpt = 0, + Int_t i2D = 0, + Int_t i1D = 0, + Double_t dXmax = 0., + Double_t dXmin = 0.) { + // TCanvas *can = new TCanvas("can22","can22"); + // can->Divide(2,2); + TCanvas* can; + if (dXmax == -1.) { + // gROOT->GetObject("TCanvas::can",can); + can = (TCanvas*) gROOT->FindObject("can"); + if (NULL == can) { + cout << "No pointer to Canvas, return" << endl; + return; + } + } else { + can = new TCanvas("can", "can", 50, 0, 800, 800); + if (iOpt < 100) can->Divide(3, 4); + gPad->SetFillColor(0); + gStyle->SetPalette(1); + gStyle->SetOptStat(kFALSE); + } + gROOT->cd(); + gROOT->SetDirLevel(1); + + TH1* h; + TH2* hn; + TH1* h1; + TH2* h2; + TH3* h3; + TH3* h3f; + + TString hsrc; + TString hname; + TString hnorm; + TString cOpt; + TString c2D; + TString c1D; + + const Int_t ColMap[8] = {1, 2, 3, 4, 6, 7, 8, 9}; + + Double_t NHits = 1.; + Double_t dProb = 0.; + + switch (i2D) { + case 0: c2D = "yx"; break; + case 1: c2D = "zx"; break; + case 2: c2D = "zy"; break; + default: cout << "i2D mode not implemented " << endl; return; + } + + switch (i1D) { + case 0: hsrc = "hUDXDY_DT_"; break; + case 1: hsrc = "hUCDXDY_DT_"; break; + } + + iCan = 1; + can->cd(iCan); + + const Int_t iPadLoc[10] = {2, 11, 5, 8, 1, 4, 7, 3, 6, 9}; + if (iOpt == 0) { + for (Int_t iSt = 0; iSt < iNSt; iSt++) { + can->cd(iPadLoc[iSt]); + hname = Form("%s%d", hsrc.Data(), iSt); + h3f = (TH3*) gROOT->FindObjectAny(hname); + cout << hname.Data() << " with pointer " << h3f << " at iCan = " << iCan + << endl; + if (h3f != NULL) { + h2 = (TH2*) h3f->Project3D(c2D.Data()); + h2->SetTitle(Form("%s", h2->GetName())); + h2->Draw("colz"); + } else + cout << hname << " not found" << endl; + } + } else // 1D projections + { + for (Int_t iSt = 0; iSt < iNSt; iSt++) { + can->cd(iPadLoc[iSt]); + hname = Form("%s%d", hsrc.Data(), iSt); + hnorm = Form("hXY_AllTracks_%d", iSt); + h3f = (TH3*) gROOT->FindObjectAny(hname); + hn = (TH2*) gROOT->FindObjectAny(hnorm); + //cout << hname.Data() <<" with pointer "<<h3f<<" at iCan = "<<iCan<<endl; + if (h3f != NULL) { + switch (iOpt) { + case 1: + h = (TH1*) h3f->Project3DProfile(c2D.Data())->ProfileX(); + break; + case 2: + h = (TH1*) h3f->Project3DProfile(c2D.Data())->ProfileY(); + break; + case 3: break; + + case 10: h = (TH1*) h3f->ProjectionX(); break; + case 11: h = (TH1*) h3f->ProjectionY(); break; + case 12: h = (TH1*) h3f->ProjectionZ(); break; + + case 20: + h = (TH1*) h3f->ProjectionX(); + NHits = hn->Integral(); + dProb = h->Integral() / NHits; + h->Scale(1. / NHits); + break; + case 21: + h = (TH1*) h3f->ProjectionY(); + NHits = hn->Integral(); + dProb = h->Integral() / NHits; + h->Scale(1. / NHits); + break; + case 22: + h = (TH1*) h3f->ProjectionZ(); + NHits = hn->Integral(); + dProb = h->Integral() / NHits; + cout << " Got " << NHits << " normalisation hits from histo " + << hn->GetName() << " => probability = " << dProb << endl; + h->Scale(1. / NHits); + break; + + case 30: + h = (TH1*) h3f->ProjectionX( + Form("%s%s", h3f->GetName(), "_pz_prompt"), 1, 11, 51, 51); + NHits = hn->Integral(); + dProb = h->Integral() / NHits; + h->Scale(1. / NHits); + break; + case 31: + h = (TH1*) h3f->ProjectionY( + Form("%s%s", h3f->GetName(), "_pz_prompt"), 1, 11, 51, 51); + NHits = hn->Integral(); + dProb = h->Integral() / NHits; + h->Scale(1. / NHits); + break; + case 32: + //h = (TH1 *)h3f->ProjectionZ(Form("%s%s",h3f->GetName(),"_pzcen"),6,6,6,6); + h = (TH1*) h3f->ProjectionZ( + Form("%s%s", h3f->GetName(), "_pzcen"), 5, 7, 5, 7); + NHits = hn->Integral(); + dProb = h->Integral() / NHits; + cout << " Got " << NHits << " normalisation hits from histo " + << hn->GetName() << " => probability = " << dProb << endl; + h->Scale(1. / NHits); + break; + case 33: + h = (TH1*) h3f->ProjectionZ( + Form("%s%s", h3f->GetName(), "_pzxl"), 6, 6, 1, 11); + NHits = hn->Integral(); + dProb = h->Integral() / NHits; + cout << " Got " << NHits << " normalisation hits from histo " + << hn->GetName() << " => probability = " << dProb << endl; + h->Scale(1. / NHits); + break; + case 34: + h = (TH1*) h3f->ProjectionZ( + Form("%s%s", h3f->GetName(), "_pzyl"), 1, 11, 6, 6); + NHits = hn->Integral(); + dProb = h->Integral() / NHits; + cout << " Got " << NHits << " normalisation hits from histo " + << hn->GetName() << " => probability = " << dProb << endl; + h->Scale(1. / NHits); + break; + + + default: cout << "Option not available " << endl; return; + } + h->SetTitle(Form("%s", h->GetName())); + // h->SetLineColor(ColMap[iSt]); // to distinguish stations in overlay mode + /* + if(iSt==0) { + h->Draw(); + if (dYmax>0.) { + h->SetMinimum(-dYmax); + h->SetMaximum(dYmax); + } + } + else { + h->Draw("same"); + } + */ + if (dXmax != -1.) { + if (dXmax != 0.) h->GetXaxis()->SetRangeUser(dXmin, dXmax); + h->Draw(); + gPad->SetGridx(); + gPad->SetGridy(); + gPad->SetLogy(); + if (dProb > 0.) { + TPad* newpad = new TPad("newpad", "a transparent pad", 0, 0, 1, 1); + newpad->SetFillStyle(4000); + newpad->Draw(); + newpad->cd(); + TPaveLabel* tit = new TPaveLabel( + 0.2, 0.75, 0.45, 0.9, Form(" prob %5.3f ", dProb)); + tit->SetFillColor(0); + tit->SetTextFont(52); + tit->SetBorderSize(1); + tit->Draw(); + } + } else { + h->Draw("same"); + h->SetLineColor(kRed); + } + } else + cout << hname << " not found" << endl; + } + } + can->SaveAs("pl_UHit.pdf"); +} diff --git a/macro/beamtime/pl_all_CluRateRatio.C b/macro/beamtime/pl_all_CluRateRatio.C new file mode 100644 index 0000000000000000000000000000000000000000..af0a158cd0ea27de8cd8d124b03928405cf1ca49 --- /dev/null +++ b/macro/beamtime/pl_all_CluRateRatio.C @@ -0,0 +1,208 @@ +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) { + // 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, 921, 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.}; + + Int_t iCanv = 0; + // if (h!=NULL) h->Delete(); + TString hname; + + 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; + } + 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(1.E3); + 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(); + //hRef->UseCurrentStyle(); + } + + Int_t iCol = 1; + for (Int_t iSt = 0; iSt < iNSt; iSt++) { + 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; + } + 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]); + 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++); + if (iCol == 5) iCol++; // skip yellow + //h->UseCurrentStyle(); + //gPad->SetLogy(); + } else { + cout << "Histogram " << hname << " not existing. " << endl; + } + } + + can->cd(2); + iCol = 1; + for (Int_t iSt = 0; iSt < iNSt; iSt++) { + 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; + } + 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"); + switch (iOpt) { + case 0: //rate + hRat->Divide(h, hRef, 1., 1., "B"); + break; + case 1: //rate/area + 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 (iSt == 0) { + hRat->SetMinimum(1.E-2); + hRat->Draw("L E"); + hRat->GetXaxis()->SetRangeUser(Tstart, Tend); + } else + hRat->Draw("L E SAME"); + + hRat->SetLineColor(iCol++); + if (iCol == 5) iCol++; // skip yellow + + //h->UseCurrentStyle(); + gPad->SetLogy(); + } else { + cout << "Histogram " << hname << " not existing. " << endl; + } + } + can->SaveAs(Form("pl_all_CluRate.pdf")); +} diff --git a/macro/beamtime/pl_all_Fpar.C b/macro/beamtime/pl_all_Fpar.C new file mode 100644 index 0000000000000000000000000000000000000000..378fd54947c5bed1eea216d59d41f1638f4edb18 --- /dev/null +++ b/macro/beamtime/pl_all_Fpar.C @@ -0,0 +1,43 @@ +void pl_all_Fpar(Int_t iNSt = 6, Int_t iPar = 0) { + // 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); + // 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); + + 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}; + + Int_t iCanv = 0; + // if (h!=NULL) h->Delete(); + + for (Int_t iSt = 0; iSt < iNSt; iSt++) { + cout << "plot station " << iSt << " with " << iSmNum[iSt] << " modules of " + << iRpcNum[iSt] << " Rpcs each" << endl; + can->cd(iCanv + 1); + iCanv++; + gROOT->cd(); + TString hname = Form("cl_SmT%01d_Fpar%01d", iType[iSt], iPar); + h = (TH1*) gROOT->FindObjectAny(hname); + if (h != NULL) { + h->Draw(""); + // gPad->SetLogy(); + } else { + cout << "Histogram " << hname << " not existing. " << endl; + } + } + can->SaveAs(Form("pl_all_Fpar.pdf")); +} diff --git a/macro/beamtime/pl_all_LHTime.C b/macro/beamtime/pl_all_LHTime.C new file mode 100644 index 0000000000000000000000000000000000000000..df957d4ff3c0f29df26d9e9eaeabb88681e38c00 --- /dev/null +++ b/macro/beamtime/pl_all_LHTime.C @@ -0,0 +1,37 @@ +void pl_all_LHTime(Int_t iNDet = 22, + 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(5, 5, 0.01, 0.01); + // can->Divide(2,2,0,0); + Float_t lsize = 0.07; + + gPad->SetFillColor(0); + gStyle->SetPalette(1); + gStyle->SetLabelSize(lsize); + + TH1* h; + TH2* h2; + + Int_t iCanv = 0; + // if (h!=NULL) h->Delete(); + + for (Int_t iDet = 0; iDet < iNDet; iDet++) { + + can->cd(iCanv + 1); + iCanv++; + gROOT->cd(); + TString hname = Form("hLHTime_Det%d", iDet); + h = (TH1*) gROOT->FindObjectAny(hname); + if (h != NULL) { + // h->GetXaxis()->SetRange(Tstart,Tend); + h->Draw("colz"); + } else { + cout << "Histogram " << hname << " not existing. " << endl; + } + } + can->SaveAs(Form("pl_all_CluRate.pdf")); +} diff --git a/macro/beamtime/pl_ana_DTXY.C b/macro/beamtime/pl_ana_DTXY.C new file mode 100644 index 0000000000000000000000000000000000000000..e08645a33bb73de288353dde5543e45f1f5cb233 --- /dev/null +++ b/macro/beamtime/pl_ana_DTXY.C @@ -0,0 +1,109 @@ +void pl_ana_DTXY(Int_t iDut = 901, + Int_t NewNbinsX = 3, + Int_t NewNbinsY = 3, + Int_t iOpt = 0) { + // TCanvas *can = new TCanvas("can22","can22"); + // can->Divide(2,2); + TCanvas* can = new TCanvas("can", "can", 50, 0, 800, 800); + can->Divide(2, 2); + + gPad->SetFillColor(0); + gStyle->SetPalette(1); + gStyle->SetOptStat(kFALSE); + + gROOT->cd(); + gROOT->SetDirLevel(1); + + TH1* h; + TH1* h1; + TH2* h2; + TH3* h3; + + can->cd(1); + gROOT->cd(); + TString hname = Form("hDutXYDT_%d", iDut); + h3f = (TH3*) gROOT->FindObjectAny(hname); + if (h3f != NULL) { + h3f->ProjectionZ()->Draw(); + gPad->SetLogy(); + } else { + cout << hname << " not found" << endl; + } + + //can->cd(2);Nxbins + + Int_t Nxbins = h3f->GetNbinsX(); + Int_t Nybins = h3f->GetNbinsY(); + Int_t Nzbins = h3f->GetNbinsZ(); + + Int_t iDeltaX = Nxbins / NewNbinsX; + Int_t iDeltaY = Nybins / NewNbinsY; + cout << "Nbins: " << Nxbins << "," << Nybins << "," << Nzbins << " -> Dbin" + << iDeltaX << "," << iDeltaY << endl; + + h2n = new TH2D("hTH3FitMean", + "#Deltat Fit Entries; x (cm); y (cm)", + NewNbinsX, + h3f->GetXaxis()->GetXmin(), + h3f->GetXaxis()->GetXmax(), + NewNbinsY, + h3f->GetYaxis()->GetXmin(), + h3f->GetYaxis()->GetXmax()); + h2m = new TH2D("hTH3FitMean", + "#Deltat Fit Mean; x (cm); y (cm)", + NewNbinsX, + h3f->GetXaxis()->GetXmin(), + h3f->GetXaxis()->GetXmax(), + NewNbinsY, + h3f->GetYaxis()->GetXmin(), + h3f->GetYaxis()->GetXmax()); + h2s = new TH2D("hTH3FitSigma", + "#Deltat Fit Sigma; x (cm); y (cm)", + NewNbinsX, + h3f->GetXaxis()->GetXmin(), + h3f->GetXaxis()->GetXmax(), + NewNbinsY, + h3f->GetYaxis()->GetXmin(), + h3f->GetYaxis()->GetXmax()); + + Int_t iCol = 0; + for (Int_t ix = 0; ix < NewNbinsX; ix++) { + for (Int_t iy = 0; iy < NewNbinsY; iy++) { + TH1D* hsel = h3f->ProjectionZ(Form("Deltat_%d_%d", ix, iy), + ix * iDeltaX + 1, + (ix + 1) * iDeltaX + 1, + iy * iDeltaY + 1, + (iy + 1) * iDeltaY + 1); + Double_t dFMean = hsel->GetMean(); + Double_t dFLim = 2.5 * hsel->GetRMS(); + hsel->SetLineColor(iCol++); + if (hsel->Integral() > 10) { + TFitResultPtr fRes = + hsel->Fit("gaus", "S", "HEsame", dFMean - dFLim, dFMean + dFLim); + h2n->SetBinContent(ix + 1, iy + 1, hsel->Integral()); + h2m->SetBinContent(ix + 1, iy + 1, fRes->Parameter(1)); + h2s->SetBinContent(ix + 1, iy + 1, fRes->Parameter(2)); + } + } + } + + can->cd(2); + { + h2n->Draw("colz"); + //gPad->SetLinz(); + gPad->SetMargin(0.23, 0.23, 0.23, 0.23); + } + + can->cd(3); + { + h2m->Draw("colz"); + gPad->SetMargin(0.23, 0.23, 0.23, 0.23); + } + + can->cd(4); + { + h2s->Draw("colz"); + gPad->SetMargin(0.23, 0.23, 0.23, 0.23); + } + can->SaveAs("pl_ana_DTXY.pdf"); +} diff --git a/macro/beamtime/pl_ana_DXXY.C b/macro/beamtime/pl_ana_DXXY.C new file mode 100644 index 0000000000000000000000000000000000000000..97dd59aae07fe6086d04c173f884c5718328fd2a --- /dev/null +++ b/macro/beamtime/pl_ana_DXXY.C @@ -0,0 +1,109 @@ +void pl_ana_DXXY(Int_t iDut = 901, + Int_t NewNbinsX = 4, + Int_t NewNbinsY = 4, + Int_t iOpt = 0) { + // TCanvas *can = new TCanvas("can22","can22"); + // can->Divide(2,2); + TCanvas* can = new TCanvas("can", "can", 50, 0, 800, 800); + can->Divide(2, 2); + + gPad->SetFillColor(0); + gStyle->SetPalette(1); + gStyle->SetOptStat(kFALSE); + + gROOT->cd(); + gROOT->SetDirLevel(1); + + TH1* h; + TH1* h1; + TH2* h2; + TH3* h3; + + can->cd(1); + gROOT->cd(); + TString hname = Form("hDutXYDX_%d", iDut); + h3f = (TH3*) gROOT->FindObjectAny(hname); + if (h3f != NULL) { + h3f->ProjectionZ()->Draw(); + gPad->SetLogy(); + } else { + cout << hname << " not found" << endl; + } + + //can->cd(2);Nxbins + + Int_t Nxbins = h3f->GetNbinsX(); + Int_t Nybins = h3f->GetNbinsY(); + Int_t Nzbins = h3f->GetNbinsZ(); + + Int_t iDeltaX = Nxbins / NewNbinsX; + Int_t iDeltaY = Nybins / NewNbinsY; + cout << "Nbins: " << Nxbins << "," << Nybins << "," << Nzbins << " -> Dbin" + << iDeltaX << "," << iDeltaY << endl; + + h2n = new TH2D("hTH3FitMean", + "#DeltaX Fit Entries; x (cm); y (cm)", + NewNbinsX, + h3f->GetXaxis()->GetXmin(), + h3f->GetXaxis()->GetXmax(), + NewNbinsY, + h3f->GetYaxis()->GetXmin(), + h3f->GetYaxis()->GetXmax()); + h2m = new TH2D("hTH3FitMean", + "#DeltaX Fit Mean; x (cm); y (cm)", + NewNbinsX, + h3f->GetXaxis()->GetXmin(), + h3f->GetXaxis()->GetXmax(), + NewNbinsY, + h3f->GetYaxis()->GetXmin(), + h3f->GetYaxis()->GetXmax()); + h2s = new TH2D("hTH3FitSigma", + "#DeltaX Fit Sigma; x (cm); y (cm)", + NewNbinsX, + h3f->GetXaxis()->GetXmin(), + h3f->GetXaxis()->GetXmax(), + NewNbinsY, + h3f->GetYaxis()->GetXmin(), + h3f->GetYaxis()->GetXmax()); + + Int_t iCol = 0; + for (Int_t ix = 0; ix < NewNbinsX; ix++) { + for (Int_t iy = 0; iy < NewNbinsY; iy++) { + TH1D* hsel = h3f->ProjectionZ(Form("DeltaX_%d_%d", ix, iy), + ix * iDeltaX + 1, + (ix + 1) * iDeltaX + 1, + iy * iDeltaY + 1, + (iy + 1) * iDeltaY + 1); + Double_t dFMean = hsel->GetMean(); + Double_t dFLim = 2.5 * hsel->GetRMS(); + hsel->SetLineColor(iCol++); + if (hsel->Integral() > 10) { + TFitResultPtr fRes = + hsel->Fit("gaus", "S", "HEsame", dFMean - dFLim, dFMean + dFLim); + h2n->SetBinContent(ix + 1, iy + 1, hsel->Integral()); + h2m->SetBinContent(ix + 1, iy + 1, fRes->Parameter(1)); + h2s->SetBinContent(ix + 1, iy + 1, fRes->Parameter(2)); + } + } + } + + can->cd(2); + { + h2n->Draw("colz"); + //gPad->SetLinz(); + gPad->SetMargin(0.23, 0.23, 0.23, 0.23); + } + + can->cd(3); + { + h2m->Draw("colz"); + gPad->SetMargin(0.23, 0.23, 0.23, 0.23); + } + + can->cd(4); + { + h2s->Draw("colz"); + gPad->SetMargin(0.23, 0.23, 0.23, 0.23); + } + can->SaveAs("pl_ana_DXXY.pdf"); +} diff --git a/macro/beamtime/pl_ana_DYXY.C b/macro/beamtime/pl_ana_DYXY.C new file mode 100644 index 0000000000000000000000000000000000000000..51b05a3e3c78c83e91fb0a300ce8976b6b7605ee --- /dev/null +++ b/macro/beamtime/pl_ana_DYXY.C @@ -0,0 +1,109 @@ +void pl_ana_DYXY(Int_t iDut = 901, + Int_t NewNbinsX = 4, + Int_t NewNbinsY = 4, + Int_t iOpt = 0) { + // TCanvas *can = new TCanvas("can22","can22"); + // can->Divide(2,2); + TCanvas* can = new TCanvas("can", "can", 50, 0, 800, 800); + can->Divide(2, 2); + + gPad->SetFillColor(0); + gStyle->SetPalette(1); + gStyle->SetOptStat(kFALSE); + + gROOT->cd(); + gROOT->SetDirLevel(1); + + TH1* h; + TH1* h1; + TH2* h2; + TH3* h3; + + can->cd(1); + gROOT->cd(); + TString hname = Form("hDutXYDY_%d", iDut); + h3f = (TH3*) gROOT->FindObjectAny(hname); + if (h3f != NULL) { + h3f->ProjectionZ()->Draw(); + gPad->SetLogy(); + } else { + cout << hname << " not found" << endl; + } + + //can->cd(2);Nxbins + + Int_t Nxbins = h3f->GetNbinsX(); + Int_t Nybins = h3f->GetNbinsY(); + Int_t Nzbins = h3f->GetNbinsZ(); + + Int_t iDeltaX = Nxbins / NewNbinsX; + Int_t iDeltaY = Nybins / NewNbinsY; + cout << "Nbins: " << Nxbins << "," << Nybins << "," << Nzbins << " -> Dbin" + << iDeltaX << "," << iDeltaY << endl; + + h2n = new TH2D("hTH3FitMean", + "#DeltaY Fit Entries; x (cm); y (cm)", + NewNbinsX, + h3f->GetXaxis()->GetXmin(), + h3f->GetXaxis()->GetXmax(), + NewNbinsY, + h3f->GetYaxis()->GetXmin(), + h3f->GetYaxis()->GetXmax()); + h2m = new TH2D("hTH3FitMean", + "#DeltaY Fit Mean; x (cm); y (cm)", + NewNbinsX, + h3f->GetXaxis()->GetXmin(), + h3f->GetXaxis()->GetXmax(), + NewNbinsY, + h3f->GetYaxis()->GetXmin(), + h3f->GetYaxis()->GetXmax()); + h2s = new TH2D("hTH3FitSigma", + "#DeltaY Fit Sigma; x (cm); y (cm)", + NewNbinsX, + h3f->GetXaxis()->GetXmin(), + h3f->GetXaxis()->GetXmax(), + NewNbinsY, + h3f->GetYaxis()->GetXmin(), + h3f->GetYaxis()->GetXmax()); + + Int_t iCol = 0; + for (Int_t ix = 0; ix < NewNbinsX; ix++) { + for (Int_t iy = 0; iy < NewNbinsY; iy++) { + TH1D* hsel = h3f->ProjectionZ(Form("DeltaY_%d_%d", ix, iy), + ix * iDeltaX + 1, + (ix + 1) * iDeltaX + 1, + iy * iDeltaY + 1, + (iy + 1) * iDeltaY + 1); + Double_t dFMean = hsel->GetMean(); + Double_t dFLim = 2.5 * hsel->GetRMS(); + hsel->SetLineColor(iCol++); + if (hsel->Integral() > 10) { + TFitResultPtr fRes = + hsel->Fit("gaus", "S", "HEsame", dFMean - dFLim, dFMean + dFLim); + h2n->SetBinContent(ix + 1, iy + 1, hsel->Integral()); + h2m->SetBinContent(ix + 1, iy + 1, fRes->Parameter(1)); + h2s->SetBinContent(ix + 1, iy + 1, fRes->Parameter(2)); + } + } + } + + can->cd(2); + { + h2n->Draw("colz"); + //gPad->SetLinz(); + gPad->SetMargin(0.23, 0.23, 0.23, 0.23); + } + + can->cd(3); + { + h2m->Draw("colz"); + gPad->SetMargin(0.23, 0.23, 0.23, 0.23); + } + + can->cd(4); + { + h2s->Draw("colz"); + gPad->SetMargin(0.23, 0.23, 0.23, 0.23); + } + can->SaveAs("pl_ana_DYXY.pdf"); +} diff --git a/macro/beamtime/pl_cmp_1D.C b/macro/beamtime/pl_cmp_1D.C new file mode 100644 index 0000000000000000000000000000000000000000..35bc63abd753f036472f488511adfe2df7c73666 --- /dev/null +++ b/macro/beamtime/pl_cmp_1D.C @@ -0,0 +1,86 @@ +void pl_cmp_1D( + Int_t iOpt = 1, + TString fNameMC = "/home/nh/KRONOS/mc/mcbm/" + "mcbm_beam_2019_03.agau.1.58gev.mbias.reco_hst.root", + TString fNameData = "./hst/" + "159.50.5.1.0_050_010020500_000_002012_022_0.9_2.5_" + "trk001_Cal159.50.5.1.0_Ana.hst.root", + TString hname = "hTrklVelHMul") { + //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(fNameMC.Data()); + TH2* h21 = (TH2*) f1->Get(hname.Data())->Clone(); + + TFile* f2 = new TFile(fNameData.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) { + case 0: // x-projection + ; + break; + + case 10: + case 1: // y- projections + h1 = (TH1*) h21->ProjectionY("_py1"); + h2 = (TH1*) h22->ProjectionY("_py2"); + // cout << Form("h21 %p, h22 %p",h21,h22)<<endl; + // cout << Form("h1 %p, h2 %p",h1,h2)<<endl; + + 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(); + h1s->Scale(N2 / N1); + h2->SetMaximum(TMath::Max(h1s->GetMaximum(), h2->GetMaximum()) * 1.1); + h2->Draw(""); + h1s->Draw("sameHIST"); + + TLegend* leg = new TLegend(0.25, 0.7, 0.5, 0.85); + leg->SetTextSize(0.03); + leg->AddEntry(h1s, "MC", "l"); + leg->AddEntry(h2, "data", "l"); + leg->Draw(); + /* + gPad->SetLogz(); + Float_t newx1=0.2; // left side of stat window + Float_t newx2=0.4; // right side of stat window + Float_t newy1=0.84; // bottom side of stat window + Float_t newy2=0.9; // top side of stat window + TPaveStats *st = (TPaveStats*)h1->GetListOfFunctions()->FindObject("stats"); + if(NULL !=st){ + st->SetX1NDC(newx1); + st->SetX2NDC(newx2); + st->SetY1NDC(newy1); + st->SetY2NDC(newy2); + } + */ +} diff --git a/macro/beamtime/pl_cmp_Eff.C b/macro/beamtime/pl_cmp_Eff.C new file mode 100644 index 0000000000000000000000000000000000000000..d34116bcbf0144ee01ff1fcac24dcbecb25f5af6 --- /dev/null +++ b/macro/beamtime/pl_cmp_Eff.C @@ -0,0 +1,235 @@ +void pl_cmp_Eff( + Int_t iDut = 900, + Int_t iMode = 4, + Double_t dEffMin = 0., + Double_t dEffMax = 1.05, + TString AnaOpt = "DT50_Req0_910911500_921_911921_600_0.5_5.0_trk111_Calr0111_" + "20161210_0646_DT50_Req1" + //TString AnaOpt="DT50_Req0_910911500_921_911921_600_0.5_7.0_trk100_Calr0111_20161210_0646_DT50_Req1" + //TString AnaOpt="DT50_Req0_910911500_921_911921_600_0.5_4.0_trk100_Calr0111_20161210_0646_DT50_Req1" + //TString AnaOpt="DT50_Req0_910911500_921_911921_601_0.5_5.0_trk111_Calr0096_20161209_2047_DT50_Req1" +) { + // input files ... + // const Int_t nF=6; + // Int_t iRun[nF]={96,111,128,148,150,158}; + const Int_t nF = 6; + Int_t iRun[nF] = {600}; + + const Int_t nPar1 = 3; + TString cPar[nPar1] = {"", "_900", "_901"}; + const Int_t nPar2 = 2; + Int_t iPar[nPar2] = {900, 901}; + TString hFileForm = "hst/" + "600.100.-1.0%s_050_030040500_500_%03d041_031_0.9_2.5_" + "trk004_Cal600.100.5.0_Ana.hst.root"; + //TString hFileForm="hst/600.100.-1.0%s_050_030040500_500_%03d041_031_0.9_2.5_trk005_Cal600.100.5.0_Ana.hst.root"; + //TString hFileForm="hst/600.100.-1.0%s_050_030040500_500_%03d041_031_0.9_2.5_trk006_Cal600.100.5.0_Ana.hst.root"; + + //plot initialisation + TCanvas* can = new TCanvas("can", "can", 50, 50, 500, 600); + Int_t nx = 1; + Int_t ny = 2; + can->Divide(nx, ny); //,0,0); + + gPad->SetFillColor(0); + gPad->SetLeftMargin(3.); + gPad->SetRightMargin(3.); + gPad->SetTopMargin(2.); + gPad->SetBottomMargin(3.); + + gStyle->SetPalette(1); + gStyle->SetOptStat(kTRUE); + gStyle->SetOptStat(" "); + gStyle->SetOptStat(10); + gStyle->SetOptStat(kFALSE); + gStyle->SetTitleSize(0.08, "x"); // axis labels + gStyle->SetTitleSize(0.08, "y"); + + cout << "gStyle label size: " << gStyle->GetLabelSize() << endl; + + // file opening + + TFile* f[nF]; + TString hFname[nF]; + TString cLegTxt[nF]; + TString cFname; + TString cRun = ""; + TString cCmd = ""; + ifstream in; + TString inFile; + Int_t iFDut[nF]; + + Int_t FMode = 1; + switch (FMode) { + case 0: + for (Int_t i = 0; i < nF; i++) { + cRun = Form("r%04d*", iRun[i]); + if (AnaOpt.Contains("Cal")) { + cout << "AnaOpt contains explicit calibration " << endl; + cCmd = "ls -1 ./hst/" + cRun + AnaOpt + "_Ana.hst.root > Tmp.out"; + } else { + cout << "AnaOpt does not contains explicit calibration, assume " + "native one " + << endl; + cCmd = "ls -1 ./hst/" + cRun + AnaOpt + "Cal" + cRun + + "_Ana.hst.root > Tmp.out"; + } + //cout << "execute " << cCmd << endl; + gSystem->Exec(cCmd); + // read cCmd result into file name variable + //if(NULL != in) in.close(); + in.open(Form("%sTmp.out", "./")); + in >> inFile; + cout << " inFile = " << inFile << endl; + if (inFile != "") { + cFname = inFile; + //cFname = "./hst/" + cRun + "_" + AnaOpt + "_Ana.hst.root"; + f[i] = new TFile(cFname.Data(), "Read"); + if (f[i] != NULL) + cout << cFname.Data() << " opened at " << f[i] << endl; + } else + f[i] = NULL; + } + case 1: + Int_t i = 0; + for (Int_t iPar1 = 0; iPar1 < nPar1; iPar1++) { + for (Int_t iPar2 = 0; iPar2 < nPar2; iPar2++) { + hFname[i] = Form(hFileForm.Data(), cPar[iPar1].Data(), iPar[iPar2]); + cLegTxt[i] = + Form("Pat %s, \t Dut %d", cPar[iPar1].Data(), iPar[iPar2]); + f[i] = new TFile(hFname[i].Data(), "Read"); + iFDut[i] = iPar[iPar2]; + i++; + } + } + } + gROOT->cd(); + + Int_t ih = 0; + TString cMode; + TString cTitle; + switch (iMode) { + case 0: + cMode = "DTLH"; + cTitle = Form("Time to last hit in DUT %d", iDut); + break; + case 1: + cMode = "Mul"; + cTitle = Form("Hit multiplicity in REF for DUT %d", iDut); + break; + case 2: + cMode = "TIS"; + cTitle = Form("Time in Spill for DUT %d", iDut); + break; + case 3: + cMode = "Chi"; + cTitle = Form("Chi2 of DUT %d", iDut); + break; + + case 4: + cMode = "Vel"; + cTitle = Form("Velocity of DUT"); // %d",iDut); + break; + + default:; + } + TString hname0 = Form("hDut%s_Found_%d", cMode.Data(), iDut); + TString hname1 = Form("hDut%s_Missed_%d", cMode.Data(), iDut); + + TH1* hfound[nF]; + TH1* hmiss[nF]; + TH1* hall[nF]; + TH1* heff[nF]; + + Int_t LCol[6] = {1, 2, 3, 4, 6, 7}; + Int_t LSty[6] = {1, 1, 1, 1, 1, 1}; + Int_t NSmooth = 2; + + can->cd(1); + + //TLegend *leg = new TLegend(0.2,0.6,0.4,0.9); //x1,y1,x2,y2,header + TLegend* leg = new TLegend(0.6, 0.2, 0.8, 0.4); //x1,y1,x2,y2,header + + leg->UseCurrentStyle(); + leg->SetTextSize(0.03); + // leg->SetHeader("TOF setups"); + + TEfficiency* pEffDut[nF]; + + Double_t dYMax = 0.; + for (Int_t iF = 0; iF < nF; iF++) { + cout << " add histos from file " << iF << " with pointer " << f[iF] << endl; + if (NULL == f[iF]) continue; + f[iF]->Print(); + + hname0 = Form("hDut%s_Found_%d", cMode.Data(), iFDut[iF]); + hname1 = Form("hDut%s_Missed_%d", cMode.Data(), iFDut[iF]); + cout << "Get histo " << hname0.Data() << endl; + + hfound[iF] = (TH1*) (f[iF]->Get(hname0))->Clone(); + hmiss[iF] = (TH1*) (f[iF]->Get(hname1))->Clone(); + hall[iF] = (TH1*) hfound[iF]->Clone(); + hall[iF]->Add(hmiss[iF], hfound[iF], 1., 1.); + hfound[iF]->SetTitle(cTitle); + hfound[iF]->SetLineColor(LCol[iF]); + hfound[iF]->SetLineStyle(LSty[iF]); + if (hfound[iF]->GetMaximum() > dYMax) dYMax = hfound[iF]->GetMaximum(); + cout << "dYMax = " << dYMax << endl; + pEffDut[iF] = new TEfficiency(*hfound[iF], *hall[iF]); + pEffDut[iF]->SetTitle(Form("Efficiency of DUT")); // %d",iDut)); + pEffDut[iF]->UseCurrentStyle(); + pEffDut[iF]->SetLineColor(LCol[iF]); + pEffDut[iF]->SetLineStyle(LSty[iF]); + //leg->AddEntry(pEffDut[iF],Form("Run %d",iRun[iF]),"l"); + leg->AddEntry(pEffDut[iF], cLegTxt[iF].Data(), "l"); + } + + //plotting + can->cd(1); + for (Int_t iF = 0; iF < nF; iF++) { + if (NULL == f[iF]) continue; + if (iF == 0) { + hfound[iF]->SetMaximum(dYMax * 1.2); + hfound[iF]->Draw(); + //gPad->SetLogy(); + } else { + cout << "Print "; + hfound[iF]->Print(); + gPad->Update(); + hfound[iF]->Draw("same"); + } + } + + can->cd(2); + for (Int_t iF = 0; iF < nF; iF++) { + if (NULL == f[iF]) continue; + if (iF == 0) { + pEffDut[iF]->Draw("AP"); + gPad->Update(); + auto graph = pEffDut[iF]->GetPaintedGraph(); + graph->SetMinimum(dEffMin); + graph->SetMaximum(dEffMax); + switch (iMode) { + case 0: graph->GetXaxis()->SetRangeUser(0., 10.); break; + default:; + } + gPad->Update(); + gPad->SetGridx(); + gPad->SetGridy(); + } else { + cout << "draw " << pEffDut[iF]->GetTitle() << endl; + pEffDut[iF]->Draw("same"); + } + } + leg->Draw(); + + gROOT->LoadMacro("pl_Datime.C"); + //TString FADD=Form("pl_Datime(\"%s\")",AnaOpt.Data()); + TString FADD = Form("pl_Datime(\"%s\")", hFileForm.Data()); + + gInterpreter->ProcessLine(FADD.Data()); + + can->SaveAs(Form("pl_cmp_Eff_%s_%d.pdf", cMode.Data(), iDut)); + + return; +} diff --git a/macro/beamtime/pl_over_deltof.C b/macro/beamtime/pl_over_deltof.C new file mode 100644 index 0000000000000000000000000000000000000000..827cb77fb79e2000ee56a14d333d7b4404832948 --- /dev/null +++ b/macro/beamtime/pl_over_deltof.C @@ -0,0 +1,44 @@ +void pl_over_deltof(Int_t iSel = 0, Int_t iNDet = 1) { + // TCanvas *can = new TCanvas("can22","can22"); + // can->Divide(2,2); + TCanvas* can = new TCanvas("can", "can", 50, 0, 900, 900); + can->Divide(3, 6); + + gPad->SetFillColor(0); + gStyle->SetPalette(1); + gStyle->SetOptStat(kTRUE); + + gROOT->cd(); + gROOT->SetDirLevel(1); + + TH1* h; + TH2* h2; + Int_t iType[6] = {0, 1, 6, 5, 9, 8}; + Int_t iNumSm[6] = {6, 3, 1, 1, 3, 2}; + Int_t iNumRpc[6] = {3, 3, 2, 1, 2, 1}; + Int_t iCanv = 0; + // if (h!=NULL) h->Delete(); + + + for (Int_t iSm = 0; iSm < iNumSm[0]; iSm++) { + for (Int_t iRpc = 0; iRpc < iNumRpc[0]; iRpc++) { + can->cd(iCanv + 1); + iCanv++; + gROOT->cd(); + TString hname2 = Form( + "cl_SmT%d_sm%03d_rpc%03d_Sel%02d_DelTof", iType[0], iSm, iRpc, iSel); + + h2 = (TH2*) gROOT->FindObjectAny(hname2); + //h2=(TH2 *)gROOT->FindObjectAny(hname); + if (h2 != NULL) { + h2->Draw("colz"); + gPad->SetLogz(); + h2->ProfileX()->Draw("same"); + } else { + cout << "Histogram " << hname2 << " not existing. " << endl; + } + } + } + + can->SaveAs(Form("pl_over_deltof%d.pdf", iSel)); +} diff --git a/macro/beamtime/pl_over_pos.C b/macro/beamtime/pl_over_pos.C new file mode 100644 index 0000000000000000000000000000000000000000..a91c79a28c335a54cd454113b5470e289c6e1eb1 --- /dev/null +++ b/macro/beamtime/pl_over_pos.C @@ -0,0 +1,43 @@ +void pl_over_pos(Int_t iNDet = 1) { + // TCanvas *can = new TCanvas("can22","can22"); + // can->Divide(2,2); + TCanvas* can = new TCanvas("can", "can", 50, 0, 900, 900); + can->Divide(3, 6); + + gPad->SetFillColor(0); + gStyle->SetPalette(1); + gStyle->SetOptStat(kTRUE); + + gROOT->cd(); + gROOT->SetDirLevel(1); + + TH1* h; + TH2* h2; + Int_t iType[6] = {0, 1, 6, 5, 9, 8}; + Int_t iNumSm[6] = {6, 3, 1, 1, 3, 2}; + Int_t iNumRpc[6] = {3, 3, 2, 1, 2, 1}; + Int_t iCanv = 0; + // if (h!=NULL) h->Delete(); + + + for (Int_t iSm = 0; iSm < iNumSm[0]; iSm++) { + for (Int_t iRpc = 0; iRpc < iNumRpc[0]; iRpc++) { + can->cd(iCanv + 1); + iCanv++; + gROOT->cd(); + TString hname2 = Form("cl_SmT%d_sm%03d_rpc%03d_Pos", iType[0], iSm, iRpc); + //TString hname=Form("cl_SmT%01d_sm%03d_rpc%03d_DigiCor",iType[iCh],iSm,iRpc); + h2 = (TH2*) gROOT->FindObjectAny(hname2); + //h2=(TH2 *)gROOT->FindObjectAny(hname); + if (h2 != NULL) { + h2->Draw("colz"); + gPad->SetLogz(); + h2->ProfileX()->Draw("same"); + } else { + cout << "Histogram " << hname2 << " not existing. " << endl; + } + } + } + + can->SaveAs(Form("pl_over_pos.pdf")); +} diff --git a/macro/beamtime/pl_over_toff.C b/macro/beamtime/pl_over_toff.C new file mode 100644 index 0000000000000000000000000000000000000000..974ec7c0cf623339797f18367e7685d88e72a99b --- /dev/null +++ b/macro/beamtime/pl_over_toff.C @@ -0,0 +1,45 @@ +void pl_over_toff(Int_t iSel = 0, Int_t iNDet = 1) { + // TCanvas *can = new TCanvas("can22","can22"); + // can->Divide(2,2); + TCanvas* can = new TCanvas("can", "can", 50, 0, 900, 900); + can->Divide(3, 6); + + gPad->SetFillColor(0); + gStyle->SetPalette(1); + gStyle->SetOptStat(kTRUE); + + gROOT->cd(); + gROOT->SetDirLevel(1); + + TH1* h; + TH2* h2; + Int_t iType[6] = {0, 1, 6, 5, 9, 8}; + Int_t iNumSm[6] = {6, 3, 1, 1, 3, 2}; + Int_t iNumRpc[6] = {3, 3, 2, 1, 2, 1}; + Int_t iCanv = 0; + // if (h!=NULL) h->Delete(); + + + for (Int_t iSm = 0; iSm < iNumSm[0]; iSm++) { + for (Int_t iRpc = 0; iRpc < iNumRpc[0]; iRpc++) { + can->cd(iCanv + 1); + iCanv++; + gROOT->cd(); + TString hname2 = + Form("cl_SmT%d_sm%03d_rpc%03d_Sel%02d_TOff", iType[0], iSm, iRpc, iSel); + //TString hname2=Form("cl_SmT%d_sm%03d_rpc%03d_Pos",iType[0],iSm,iRpc); + //TString hname=Form("cl_SmT%01d_sm%03d_rpc%03d_DigiCor",iType[iCh],iSm,iRpc); + h2 = (TH2*) gROOT->FindObjectAny(hname2); + //h2=(TH2 *)gROOT->FindObjectAny(hname); + if (h2 != NULL) { + h2->Draw("colz"); + gPad->SetLogz(); + h2->ProfileX()->Draw("same"); + } else { + cout << "Histogram " << hname2 << " not existing. " << endl; + } + } + } + + can->SaveAs(Form("pl_over_toff%d.pdf", iSel)); +} diff --git a/macro/beamtime/pl_pull_trk.C b/macro/beamtime/pl_pull_trk.C index 41368e5dcd1f82168a3b98b92614d78bd5fbcd2c..57e4ac4e5c1c3226e66afadc9019a324e1c73ddc 100644 --- a/macro/beamtime/pl_pull_trk.C +++ b/macro/beamtime/pl_pull_trk.C @@ -158,13 +158,13 @@ void pl_pull_trk(Int_t NSt = 8, Int_t iVar = 0, Int_t iFit = 0) { for (Int_t i = 0; i < NSt; 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]) + "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; diff --git a/macro/beamtime/pl_raw_evt.C b/macro/beamtime/pl_raw_evt.C new file mode 100644 index 0000000000000000000000000000000000000000..61a6b0ae785394734d8382941d6e3ffc718d1789 --- /dev/null +++ b/macro/beamtime/pl_raw_evt.C @@ -0,0 +1,66 @@ +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); + // can->Divide(4,4,0.01,0.01); + // can->Divide(2,2,0,0); + Float_t lsize = 0.09; + + gPad->SetFillColor(0); + gStyle->SetPalette(1); + gStyle->SetLabelSize(lsize); + + //gStyle->SetStatY(0.5); + //gStyle->SetStatX(0.5); + gStyle->SetStatW(0.5); + gStyle->SetStatH(0.3); + + gStyle->SetOptStat(kTRUE); + gStyle->SetOptStat(11); + //gROOT->cd(); + //gROOT->SetDirLevel(2); + + TH1* h; + TH2* h2; + TString hname; + + can->cd(1); + hname = Form("hEvDetMul"); + h = (TH1*) gROOT->FindObjectAny(hname); + h->Draw(); + gPad->SetLogy(); + + can->cd(2); + hname = Form("hPulMul"); + h = (TH1*) gROOT->FindObjectAny(hname); + h->Draw(); + gPad->SetLogy(); + + can->cd(3); + hname = Form("hPulserTimesRaw"); + h2 = (TH2*) gROOT->FindObjectAny(hname); + h2->Draw("colz"); + gPad->SetLogz(); + + can->cd(4); + hname = Form("hPulserTimesCor"); + h2 = (TH2*) gROOT->FindObjectAny(hname); + h2->Draw("colz"); + gPad->SetLogz(); + + can->cd(5); + hname = Form("hDigiTimesRaw"); + h2 = (TH2*) gROOT->FindObjectAny(hname); + h2->Draw("colz"); + 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_rel_ratio.C b/macro/beamtime/pl_rel_ratio.C new file mode 100644 index 0000000000000000000000000000000000000000..41654cb031e2655c69606d4abc2c413bd6ef5218 --- /dev/null +++ b/macro/beamtime/pl_rel_ratio.C @@ -0,0 +1,114 @@ + +void set_plot_style() { + const Int_t NRGBs = 5; + const Int_t NCont = 255; + + Double_t stops[NRGBs] = {0.00, 0.34, 0.61, 0.84, 1.00}; + Double_t red[NRGBs] = {0.00, 0.00, 0.87, 1.00, 0.51}; + Double_t green[NRGBs] = {0.00, 0.81, 1.00, 0.20, 0.00}; + Double_t blue[NRGBs] = {0.51, 1.00, 0.12, 0.00, 0.00}; + TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont); + gStyle->SetNumberContours(NCont); + cout << "set_plot_style finished" << endl; +} + +void pl_rel_ratio(TString hname = "hDutDTLH_DD_Found_911", + Int_t iRefBin = 1, + Int_t iDim = 0, + Int_t iDisBin = 0xFF, + Double_t yRange = 1., + Double_t dYShift = 0.1, + Double_t Xmin = 0., + Double_t Xmax = 10.) { + // TCanvas *can = new TCanvas("can22","can22"); + // can->Divide(2,2); + TCanvas* can = new TCanvas("can", "can", 50, 0, 600, 800); + can->Divide(1, 2); + + gPad->SetFillColor(0); + gStyle->SetPalette(1); + set_plot_style(); + gStyle->SetOptStat(kFALSE); + //TExec *ex1 = new TExec("ex1","Pal1();"); + + // gROOT->cd(); + // gROOT->SetDirLevel(1); + + TH1* h; + TH1* h1; + TH2* h2; + TH2* h2C; + // if (h!=NULL) h->Delete(); + Int_t iNBins = 0; + + can->cd(1); + // gROOT->cd(); + gDirectory->pwd(); + h2 = (TH2*) gDirectory->FindObjectAny(hname); + if (h2 != NULL) { + h2->Draw("colz"); + gPad->SetLogz(); + } else { + cout << hname << " not found" << endl; + return; + } + + can->cd(2); + + TH1D* href; + TH1D* hbin; + switch (iDim) { + case 0: + iNBins = h2->GetNbinsX(); + href = + h2->ProjectionX(Form("%sRef", hname.Data()), iRefBin + 1, iRefBin + 1); + href->Scale(1. / href->GetEntries()); + break; + case 1: iNBins = h2->GetNbinsY(); break; + } + href->Draw(); + + for (Int_t iBin = 0; iBin < iNBins; iBin++) { + hbin = + h2->ProjectionX(Form("%sBin%d", hname.Data(), iBin), iBin + 1, iBin + 1); + hbin->Scale(1. / hbin->GetEntries()); + hbin->Divide(hbin, href, 1, 1, "E"); + hbin->SetLineColor(iBin + 1); + if (iBin == 0) { + hbin->Draw("Lhist"); + hbin->SetMinimum(0.); + hbin->SetMaximum(yRange + iNBins * dYShift); + hbin->GetXaxis()->SetRangeUser(Xmin, Xmax); + } else { + Int_t bit = 1; + if (iDisBin & (bit <<= iBin)) hbin->Draw("same Lhist"); + } + // h2->UseCurrentStyle(); + // gPad->SetLogz(); + } + + /* +can->cd(2); + for (Int_t iCh=0; iCh<iNch; iCh++){ + TString hname=Form("Cor_SmT%d_sm%03d_rpc%03d_Ch%03d_S1_Walk_px",SmT,iSm,iRpc,iCh); + h2=(TH2 *)gDirectory->FindObjectAny(hname); + if (h2!=NULL) { + h2->SetLineColor(iCh+1); + if (iCh==0) { + h2->Draw("Lhist"); + h2->SetMinimum(-yRange); + h2->SetMaximum(yRange+iNch*dYShift); + h2->GetXaxis()->SetRangeUser(Xmin,Xmax); + }else{ + h2C=(TH2 *)h2->Clone(); + Int_t iNB=h2C->GetNbinsX(); + for (Int_t iB=0; iB<iNB; iB++){ + h2C->SetBinContent(iB+1,h2C->GetBinContent(iB+1)+dYShift*iCh); + } + h2C->Draw("same Lhist"); + } + // gPad->SetLogz(); + }else { cout << hname << " not found" << endl; } + } + */ +} diff --git a/macro/beamtime/pl_star_DigiCor.C b/macro/beamtime/pl_star_DigiCor.C new file mode 100644 index 0000000000000000000000000000000000000000..a69718223299bf1b5240f4c4a464d80145905e7d --- /dev/null +++ b/macro/beamtime/pl_star_DigiCor.C @@ -0,0 +1,45 @@ +void pl_star_DigiCor(Int_t iNDet = 2) { + // 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, 1200); + can->Divide(3, 4, 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); + + TH1* h; + TH2* h2; + Int_t iType[6] = {1, 9, 6, 5, 9, 8}; + Int_t iNumSm[6] = {3, 1, 1, 1, 3, 2}; + Int_t iNumRpc[6] = {3, 2, 2, 1, 2, 1}; + Int_t iCanv = 0; + // if (h!=NULL) h->Delete(); + + for (Int_t iCh = 0; iCh < iNDet; iCh++) { + for (Int_t iSm = 0; iSm < iNumSm[iCh]; iSm++) { + for (Int_t iRpc = 0; iRpc < iNumRpc[iCh]; iRpc++) { + can->cd(iCanv + 1); + iCanv++; + gROOT->cd(); + TString hname = + Form("cl_SmT%01d_sm%03d_rpc%03d_DigiCor", iType[iCh], iSm, iRpc); + h2 = (TH2*) gROOT->FindObjectAny(hname); + if (h2 != NULL) { + h2->Draw("colz"); + gPad->SetLogz(); + } else { + cout << "Histogram " << hname << " not existing. " << endl; + } + } + } + } + can->SaveAs(Form("pl_all_DigiCor.pdf")); +} diff --git a/macro/beamtime/pl_trk_walk.C b/macro/beamtime/pl_trk_walk.C new file mode 100644 index 0000000000000000000000000000000000000000..ed900234bfe228e0db9ef44a8d5e6386ebb66313 --- /dev/null +++ b/macro/beamtime/pl_trk_walk.C @@ -0,0 +1,38 @@ +void pl_trk_walk(Int_t iType = 0, + Int_t iSm = 0, + Int_t iRpc = 0, + Int_t iSide = 0) { + // TCanvas *can = new TCanvas("can22","can22"); + // can->Divide(2,2); + TCanvas* can = new TCanvas("can", "can", 50, 0, 800, 800); + can->Divide(4, 8); + gPad->SetFillColor(0); + gStyle->SetPalette(1); + gStyle->SetOptStat(kTRUE); + + gROOT->cd(); + gROOT->SetDirLevel(1); + + TH1* h; + TH1* h1; + TH2* h2; + Int_t iCan = 1; + for (Int_t iCh = 0; iCh < 32; iCh++) { + if (iCan == 36) iCan = 1; + can->cd(iCan++); + gROOT->cd(); + TString hname = Form( + "cal_SmT%d_sm%03d_rpc%03d_Ch%03d_S%d_Walk", iType, iSm, iRpc, iCh, iSide); + h2 = (TH2*) gROOT->FindObjectAny(hname); + if (h2 != NULL) { + h2->Draw("colz"); + gPad->SetLogz(); + // gPad->SetGridx(); + // gPad->SetGridy(); + } else { + cout << hname << " not found" << endl; + } + } + + can->SaveAs(Form("pl_trk_walk_%d%d%d_%d.pdf", iType, iSm, iRpc, iSide)); +} diff --git a/macro/beamtime/pl_vert_trk.C b/macro/beamtime/pl_vert_trk.C new file mode 100644 index 0000000000000000000000000000000000000000..fb8685d76441a372c290e2e769bd8571d28ec278 --- /dev/null +++ b/macro/beamtime/pl_vert_trk.C @@ -0,0 +1,117 @@ +void pl_vert_trk() { + // TCanvas *can = new TCanvas("can22","can22"); + // can->Divide(2,2); + TCanvas* can = new TCanvas("can", "can", 50, 0, 800, 800); + can->Divide(3, 4); + + gPad->SetFillColor(0); + gStyle->SetPalette(1); + gStyle->SetOptStat(kTRUE); + + gROOT->cd(); + gROOT->SetDirLevel(1); + + TH1* h; + TH1* h1; + TH2* h2; + // if (h!=NULL) h->Delete(); + + can->cd(1); + gROOT->cd(); + TString hname = Form("hTrklXY0_3"); + 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("hTrklXY0_4"); + 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("hTrklXY0_5"); + 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("hVTXNorm"); + h1 = (TH1*) gROOT->FindObjectAny(hname); + if (h1 != NULL) { + h1->Draw(); + gPad->SetLogy(); + } else { + cout << hname << " not found" << endl; + } + + can->cd(5); + gROOT->cd(); + hname = Form("hVTX_XY0"); + h2 = (TH2*) gROOT->FindObjectAny(hname); + if (h2 != NULL) { + h2->Draw("colz"); + gPad->SetLogz(); + } else { + cout << hname << " not found" << endl; + } + + can->cd(6); + gROOT->cd(); + hname = Form("hVTX_DT0_Norm"); + h2 = (TH2*) gROOT->FindObjectAny(hname); + if (h2 != NULL) { + h2->Draw("colz"); + gPad->SetLogz(); + } else { + cout << hname << " not found" << endl; + } + + can->cd(7); + gROOT->cd(); + hname = Form("hTrklT0Mul"); + h2 = (TH2*) gROOT->FindObjectAny(hname); + if (h2 != NULL) { + h2->Draw("colz"); + gPad->SetLogz(); + } else { + cout << hname << " not found" << endl; + } + + can->cd(8); + gROOT->cd(); + hname = Form("hTrklDT0SmMis"); + 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("hTrklDT0StMis2"); + h2 = (TH2*) gROOT->FindObjectAny(hname); + if (h2 != NULL) { + h2->Draw("colz"); + gPad->SetLogz(); + } else { + cout << hname << " not found" << endl; + } +} diff --git a/macro/mcbm/eventDisplay.C b/macro/mcbm/eventDisplay.C index c2b280fbc7163d3778fffb90756d612897dcba53..d1f6ab2096df90447e271491ea2a6bf99c63ea29 100644 --- a/macro/mcbm/eventDisplay.C +++ b/macro/mcbm/eventDisplay.C @@ -1,53 +1,162 @@ -void eventDisplay(TString dataset = "test") { - TString inFile = dataset + ".tra.root"; - TString parFile = dataset + ".par.root"; - TString outFile = dataset + ".display.root"; +void eventDisplay( + TString cSys="lam", + TString cEbeam="2.5gev", + TString cCentr="-", + Int_t iRun=0, + const char* setup = "sis18_mcbm") +{ + + TString dataDir = "data/"; + + TString InputFile = dataDir + setup + "_" + cSys + "." + cEbeam + "." + cCentr + ".mc." + Form("%05d",iRun) + ".root"; + TString RecoFile = dataDir + setup + "_" + cSys + "." + cEbeam + "." + cCentr + ".eds." + Form("%05d",iRun) + ".root"; + TString ParFile = dataDir + setup + "_" + cSys + "." + cEbeam + "." + cCentr + ".params." + Form("%05d",iRun) + ".root"; // ----- Reconstruction run ------------------------------------------- - FairRunAna* fRun = new FairRunAna(); + FairRunAna *fRun= new FairRunAna(); + + fRun->SetInputFile(InputFile.Data()); + fRun->AddFriend(RecoFile.Data()); + + fRun->SetOutputFile(dataDir + setup + "_test.root"); - FairFileSource* inputSource = new FairFileSource(inFile.Data()); - fRun->SetSource(inputSource); - fRun->SetOutputFile(outFile); + //FairLogger::GetLogger()->SetLogScreenLevel("INFO"); + FairLogger::GetLogger()->SetLogScreenLevel("DEBUG1"); + FairLogger::GetLogger()->SetLogVerbosityLevel("MEDIUM"); - FairRuntimeDb* rtdb = fRun->GetRuntimeDb(); + CbmHadronAnalysis *HadronAna = new CbmHadronAnalysis(); // interpret event + HadronAna->SetRecSec(kTRUE); // enable lambda reconstruction + Int_t parSet=0; + switch(parSet){ + case 0: // with background + HadronAna->SetDistPrimLim(1.2); // Max Tof-Sts trans distance for primaries + HadronAna->SetDistPrimLim2(0.3); // Max Sts-Sts trans distance for primaries + HadronAna->SetDistSecLim2(0.3); // Max Sts-Sts trans distance from TOF direction for secondaries + HadronAna->SetD0ProtLim(0.5); // Min impact parameter for secondary proton + HadronAna->SetOpAngMin(0.1); // Min opening angle for accepting pair + HadronAna->SetDCALim(0.1); // Max DCA for accepting pair + HadronAna->SetVLenMin(5.); // Min Lambda flight path length for accepting pair + HadronAna->SetVLenMax(25.); // Max Lambda flight path length for accepting pair + HadronAna->SetDistTRD(10.); // max accepted distance of Trd Hit from STS-TOF line + HadronAna->SetTRDHmulMin(0.); // min associated Trd Hits to Track candidates + HadronAna->SetNMixedEvents(10); // Number of events to be mixed with + break; + case 1: // signal with background Ni+Ni + HadronAna->SetDistPrimLim(1.); // Max Tof-Sts trans distance for primaries + HadronAna->SetDistPrimLim2(0.3); // Max Sts-Sts trans distance for primaries + HadronAna->SetDistSecLim2(0.3); // Max Sts-Sts trans distance from TOF direction for secondaries + HadronAna->SetD0ProtLim(0.4); // Min impact parameter for secondary proton + HadronAna->SetOpAngMin(0.1); // Min opening angle for accepting pair + HadronAna->SetDCALim(0.1); // Max DCA for accepting pair + HadronAna->SetVLenMin(5.); // Min Lambda flight path length for accepting pair + HadronAna->SetVLenMax(25.); // Max Lambda flight path length for accepting pair + HadronAna->SetDistTRD(10.); // max accepted distance of Trd Hit from STS-TOF line + HadronAna->SetTRDHmulMin(0.); // min associated Trd Hits to Track candidates + HadronAna->SetNMixedEvents(10); // Number of events to be mixed with + break; + case 2: // signal with background Au+Au + HadronAna->SetDistPrimLim(1.); // Max Tof-Sts trans distance for primaries + HadronAna->SetDistPrimLim2(0.3); // Max Sts-Sts trans distance for primaries + HadronAna->SetDistSecLim2(0.3); // Max Sts-Sts trans distance from TOF direction for secondaries + HadronAna->SetD0ProtLim(0.4); // Min impact parameter for secondary proton + HadronAna->SetOpAngMin(0.1); // Min opening angle for accepting pair + HadronAna->SetDCALim(0.1); // Max DCA for accepting pair + HadronAna->SetVLenMin(8.); // Min Lambda flight path length for accepting pair + HadronAna->SetVLenMax(25.); // Max Lambda flight path length for accepting pair + HadronAna->SetDistTRD(10.); // max accepted distance of Trd Hit from STS-TOF line + HadronAna->SetTRDHmulMin(0.); // min associated Trd Hits to Track candidates + HadronAna->SetNMixedEvents(10); // Number of events to be mixed with + break; + case 10: // "0" with TRD Mul 1 + HadronAna->SetDistPrimLim(1.2); // Max Tof-Sts trans distance for primaries + HadronAna->SetDistPrimLim2(0.3); // Max Sts-Sts trans distance for primaries + HadronAna->SetDistSecLim2(0.3); // Max Sts-Sts trans distance from TOF direction for secondaries + HadronAna->SetD0ProtLim(0.5); // Min impact parameter for secondary proton + HadronAna->SetOpAngMin(0.1); // Min opening angle for accepting pair + HadronAna->SetDCALim(0.1); // Max DCA for accepting pair + HadronAna->SetVLenMin(5.); // Min Lambda flight path length for accepting pair + HadronAna->SetVLenMax(25.); // Max Lambda flight path length for accepting pair + HadronAna->SetDistTRD(10.); // max accepted distance of Trd Hit from STS-TOF line + HadronAna->SetTRDHmulMin(1.); // min associated Trd Hits to Track candidates + HadronAna->SetNMixedEvents(10); // Number of events to be mixed with + break; + case 20: // "0" with TRD Mul 2 + HadronAna->SetDistPrimLim(1.2); // Max Tof-Sts trans distance for primaries + HadronAna->SetDistPrimLim2(0.3); // Max Sts-Sts trans distance for primaries + HadronAna->SetDistSecLim2(0.3); // Max Sts-Sts trans distance from TOF direction for secondaries + HadronAna->SetD0ProtLim(0.5); // Min impact parameter for secondary proton + HadronAna->SetOpAngMin(0.1); // Min opening angle for accepting pair + HadronAna->SetDCALim(0.1); // Max DCA for accepting pair + HadronAna->SetVLenMin(5.); // Min Lambda flight path length for accepting pair + HadronAna->SetVLenMax(25.); // Max Lambda flight path length for accepting pair + HadronAna->SetDistTRD(10.); // max accepted distance of Trd Hit from STS-TOF line + HadronAna->SetTRDHmulMin(2.); // min associated Trd Hits to Track candidates + HadronAna->SetNMixedEvents(10); // Number of events to be mixed with + break; + default: + cout << "Cut value set " <<parSet<<" not existing, stop macro "<< endl; + return; + } + + fRun->AddTask(HadronAna); + + FairRuntimeDb* rtdb = fRun->GetRuntimeDb(); FairParRootFileIo* parInput1 = new FairParRootFileIo(); - parInput1->open(parFile.Data()); + parInput1->open(ParFile.Data()); rtdb->setFirstInput(parInput1); - FairEventManager* fMan = new FairEventManager(); - FairMCTracks* Track = new FairMCTracks("Monte-Carlo Tracks"); - - FairMCPointDraw* MvdPoint = - new FairMCPointDraw("MvdPoint", kBlack, kFullSquare); - FairMCPointDraw* StsPoint = - new FairMCPointDraw("StsPoint", kBlue, kFullSquare); - FairMCPointDraw* RichPoint = - new FairMCPointDraw("RichPoint", kOrange, kFullSquare); - FairMCPointDraw* RefPlanePoint = - new FairMCPointDraw("RefPlanePoint", kPink, kFullSquare); - FairMCPointDraw* TrdPoint = - new FairMCPointDraw("MuchPoint", kYellow, kFullSquare); - FairMCPointDraw* MuchPoint = - new FairMCPointDraw("TrdPoint", kCyan, kFullSquare); - FairMCPointDraw* TofPoint = - new FairMCPointDraw("TofPoint", kRed, kFullSquare); - FairMCPointDraw* EcalPoint = - new FairMCPointDraw("EcalPoint", kYellow, kFullSquare); + FairEventManager *fMan = new FairEventManager(); + FairMCTracks *Track = new FairMCTracks ("Monte-Carlo Tracks"); + FairMCPointDraw *MvdPoint = new FairMCPointDraw ("MvdPoint", kBlack, kFullSquare); + FairMCPointDraw *StsPoint = new FairMCPointDraw ("StsPoint", kGreen, kFullSquare); + FairMCPointDraw *MuchPoint = new FairMCPointDraw ("MuchPoint", kOrange, kFullSquare); + FairMCPointDraw *RichPoint = new FairMCPointDraw ("RichPoint", kGreen, kFullSquare); + FairMCPointDraw *TrdPoint = new FairMCPointDraw ("TrdPoint", kBlue, kFullSquare); + FairMCPointDraw *TofPoint = new FairMCPointDraw ("TofPoint", kRed, kFullSquare); + FairMCPointDraw *EcalPoint = new FairMCPointDraw ("EcalPoint", kYellow, kFullSquare); + FairMCPointDraw *RefPlanePoint = new FairMCPointDraw ("RefPlanePoint", kPink, kFullSquare); + fMan->AddTask(Track); - + fMan->AddTask(MvdPoint); fMan->AddTask(StsPoint); - fMan->AddTask(RichPoint); - fMan->AddTask(RefPlanePoint); fMan->AddTask(MuchPoint); + fMan->AddTask(RichPoint); fMan->AddTask(TrdPoint); - fMan->AddTask(TofPoint); - fMan->AddTask(EcalPoint); - + fMan->AddTask(TofPoint); + fMan->AddTask(EcalPoint); + fMan->AddTask(RefPlanePoint); + CbmPixelHitSetDraw *StsHits = new CbmPixelHitSetDraw ("StsHit", kRed, kOpenCircle );// kFullSquare); + fMan->AddTask(StsHits); + CbmPixelHitSetDraw *TrdHits = new CbmPixelHitSetDraw ("TrdHit", kRed, kOpenCircle );// kFullSquare); + fMan->AddTask(TrdHits); + CbmPixelHitSetDraw *TofHits = new CbmPixelHitSetDraw ("TofHit", kRed, kOpenCircle );// kFullSquare); + fMan->AddTask(TofHits); + CbmPixelHitSetDraw *TofUHits = new CbmPixelHitSetDraw ("TofUHit", kRed, kOpenCross ); + fMan->AddTask(TofUHits); + CbmEvDisTracks *Tracks = new CbmEvDisTracks ("Tof Tracks",1); + Tracks->SetVerbose(4); + fMan->AddTask(Tracks); + // fMan->Init(1,4,10000); // fMan->Init(1,5,10000); // make STS visible by default - fMan->Init(1, 6, 10000); + // fMan->Init(1,6,10000); // make MVD visible by default + fMan->Init(1,7,10000); // make MVD visible by default + + cout << "gEve "<< gEve << endl; + gEve->GetDefaultGLViewer()->SetClearColor(kYellow-10); + { // 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(); + } + } } diff --git a/macro/mcbm/eventDisplay_reco.C b/macro/mcbm/eventDisplay_reco.C new file mode 100755 index 0000000000000000000000000000000000000000..23d01941df0b5107122e53a956ebc53309d216bd --- /dev/null +++ b/macro/mcbm/eventDisplay_reco.C @@ -0,0 +1,329 @@ +// -------------------------------------------------------------------------- +// +// Macro for reconstruction of simulated events with standard settings +// +// HitProducers in MVD, RICH, TRD, TOF, ECAL +// Digitizer and HitFinder in STS +// FAST MC for ECAL +// STS track finding and fitting (L1 / KF) +// TRD track finding and fitting (L1 / KF) +// RICH ring finding (ideal) and fitting +// Global track finding (ideal), rich assignment +// Primary vertex finding (ideal) +// Matching of reconstructed and MC tracks in STS, RICH and TRD +// +// V. Friese 24/02/2006 +// Version 04/03/2015 (V. Friese) +// +// -------------------------------------------------------------------------- + +void eventDisplay_reco( + TString cSys="lam", + TString cEbeam="2.5gev", + TString cCentr="-", + Int_t iRun=0, + Int_t parSet=0, + const char* setupName = "sis18_mcbm") +{ + // ----- Environment -------------------------------------------------- + TString myName = "run_reco_nh"; // this macro's name for screen output + TString srcDir = gSystem->Getenv("VMCWORKDIR"); // top source directory + // ======================================================================== + // Adjust this part according to your requirements + + // Verbosity level (0=quiet, 1=event level, 2=track level, 3=debug) + Int_t iVerbose = 0; + + TString outDir = "data/"; + TString inFile = outDir + setupName + "_" + cSys + "." + cEbeam + "." + cCentr + ".mc." + Form("%05d",iRun) + ".root"; // Input file (MC events) + TString parFile = outDir + setupName + "_" + cSys + "." + cEbeam + "." + cCentr + ".params." + Form("%05d",iRun) + ".root"; // Parameter file + TString outFile = outDir + setupName + "_" + cSys + "." + cEbeam + "." + cCentr + ".evt." + Form("%05d",iRun) + ".root"; // Output file + + //FairLogger::GetLogger()->SetLogScreenLevel("WARNING"); + //FairLogger::GetLogger()->SetLogScreenLevel("INFO"); + //FairLogger::GetLogger()->SetLogScreenLevel("DEBUG"); + FairLogger::GetLogger()->SetLogScreenLevel("DEBUG1"); + FairLogger::GetLogger()->SetLogVerbosityLevel("MEDIUM"); + + // ----- Load the geometry setup ------------------------------------- + std::cout << std::endl; + + TString setupFile = srcDir + "/geometry/setup/setup_" + setupName + ".C"; + TString setupFunct = "setup_"; + setupFunct = setupFunct + setupName + "()"; + std::cout << "-I- mcbm_reco: Loading macro " << setupFile << std::endl; + gROOT->LoadMacro(setupFile); + gROOT->ProcessLine(setupFunct); + CbmSetup* setup = CbmSetup::Instance(); + // ------------------------------------------------------------------------ + + + // ----- 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 ( setup->GetGeoTag(kTrd, geoTag) ) { + TObjString* trdFile = new TObjString(srcDir + "/parameters/trd/trd_" + geoTag + ".digi.par"); + parFileList->Add(trdFile); + std::cout << "-I- " << myName << ": Using parameter file " + << trdFile->GetString() << std::endl; + } + + // - TOF digitisation parameters + if ( setup->GetGeoTag(kTof, geoTag) ) { + TObjString* tofFile = new TObjString(srcDir + "/parameters/tof/tof_" + geoTag + ".digi.par"); + parFileList->Add(tofFile); + std::cout << "-I- " << myName << ": Using parameter file " + << tofFile->GetString() << std::endl; + 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(); + // ------------------------------------------------------------------------ + + + // ---- Debug option ------------------------------------------------- + gDebug = 0; + // ------------------------------------------------------------------------ + + + // ----- Input file --------------------------------------------------- + std::cout << std::endl; + std::cout << "-I- " << myName << ": Using input file " << inFile << std::endl; + // ------------------------------------------------------------------------ + + + // ----- FairRunAna --------------------------------------------------- + FairRunAna *run = new FairRunAna(); + run->SetInputFile(inFile); + run->SetOutputFile(outFile); + run->SetGenerateRunInfo(kTRUE); + run->SetGenerateRunInfo(kTRUE); + Bool_t hasFairMonitor = Has_Fair_Monitor(); + if (hasFairMonitor) FairMonitor::GetMonitor()->EnableMonitor(kTRUE); + // ------------------------------------------------------------------------ + + // ----- MC Data Manager ------------------------------------------------ + CbmMCDataManager* mcManager=new CbmMCDataManager("MCManager", 1); + mcManager->AddFile(inFile); + run->AddTask(mcManager); + // ------------------------------------------------------------------------ + + + // ----- Digitisers --------------------------------------------------- + std::cout << std::endl; + TString macroName = gSystem->Getenv("VMCWORKDIR"); + macroName += "/macro/mcbm/modules/digitize.C"; + std::cout << "Loading macro " << macroName << std::endl; + gROOT->LoadMacro(macroName); + gROOT->ProcessLine("digitize()"); + // ------------------------------------------------------------------------ + + + // ----- Reconstruction tasks ----------------------------------------- + std::cout << std::endl; + macroName = srcDir + "/macro/mcbm/modules/reconstruct.C"; + std::cout << "Loading macro " << macroName << std::endl; + gROOT->LoadMacro(macroName); + Bool_t recoSuccess = gROOT->ProcessLine("reconstruct()"); + if ( ! recoSuccess ) { + std::cerr << "-E-" << myName << ": error in executing " << macroName + << std::endl; + return; + } + + // ========================================================================= + // === Matching to Monte-carlo === + // ========================================================================= + CbmMatchRecoToMC* matchTask = new CbmMatchRecoToMC(); + run->AddTask(matchTask); + // Digitizer/custerizer testing + CbmTofHitFinderQa* tofQa = new CbmTofHitFinderQa("TOF QA"); + tofQa->SetHistoFileName("TofQA.root"); + run->AddTask(tofQa); + + + CbmHadronAnalysis *HadronAna = new CbmHadronAnalysis(); // interpret event + HadronAna->SetRecSec(kTRUE); // enable lambda reconstruction + switch(parSet){ + case 0: // with background + HadronAna->SetDistPrimLim(1.2); // Max Tof-Sts trans distance for primaries + HadronAna->SetDistPrimLim2(0.3); // Max Sts-Sts trans distance for primaries + HadronAna->SetDistSecLim2(0.3); // Max Sts-Sts trans distance from TOF direction for secondaries + HadronAna->SetD0ProtLim(0.5); // Min impact parameter for secondary proton + HadronAna->SetOpAngMin(0.1); // Min opening angle for accepting pair + HadronAna->SetDCALim(0.1); // Max DCA for accepting pair + HadronAna->SetVLenMin(5.); // Min Lambda flight path length for accepting pair + HadronAna->SetVLenMax(25.); // Max Lambda flight path length for accepting pair + HadronAna->SetDistTRD(10.); // max accepted distance of Trd Hit from STS-TOF line + HadronAna->SetTRDHmulMin(0.); // min associated Trd Hits to Track candidates + HadronAna->SetNMixedEvents(10); // Number of events to be mixed with + break; + case 1: // signal with background Ni+Ni + HadronAna->SetDistPrimLim(1.); // Max Tof-Sts trans distance for primaries + HadronAna->SetDistPrimLim2(0.3); // Max Sts-Sts trans distance for primaries + HadronAna->SetDistSecLim2(0.3); // Max Sts-Sts trans distance from TOF direction for secondaries + HadronAna->SetD0ProtLim(0.4); // Min impact parameter for secondary proton + HadronAna->SetOpAngMin(0.1); // Min opening angle for accepting pair + HadronAna->SetDCALim(0.1); // Max DCA for accepting pair + HadronAna->SetVLenMin(5.); // Min Lambda flight path length for accepting pair + HadronAna->SetVLenMax(25.); // Max Lambda flight path length for accepting pair + HadronAna->SetDistTRD(10.); // max accepted distance of Trd Hit from STS-TOF line + HadronAna->SetTRDHmulMin(0.); // min associated Trd Hits to Track candidates + HadronAna->SetNMixedEvents(10); // Number of events to be mixed with + break; + case 2: // signal with background Au+Au + HadronAna->SetDistPrimLim(1.); // Max Tof-Sts trans distance for primaries + HadronAna->SetDistPrimLim2(0.3); // Max Sts-Sts trans distance for primaries + HadronAna->SetDistSecLim2(0.3); // Max Sts-Sts trans distance from TOF direction for secondaries + HadronAna->SetD0ProtLim(0.4); // Min impact parameter for secondary proton + HadronAna->SetOpAngMin(0.1); // Min opening angle for accepting pair + HadronAna->SetDCALim(0.1); // Max DCA for accepting pair + HadronAna->SetVLenMin(8.); // Min Lambda flight path length for accepting pair + HadronAna->SetVLenMax(25.); // Max Lambda flight path length for accepting pair + HadronAna->SetDistTRD(10.); // max accepted distance of Trd Hit from STS-TOF line + HadronAna->SetTRDHmulMin(0.); // min associated Trd Hits to Track candidates + HadronAna->SetNMixedEvents(10); // Number of events to be mixed with + break; + case 10: // "0" with TRD Mul 1 + HadronAna->SetDistPrimLim(1.2); // Max Tof-Sts trans distance for primaries + HadronAna->SetDistPrimLim2(0.3); // Max Sts-Sts trans distance for primaries + HadronAna->SetDistSecLim2(0.3); // Max Sts-Sts trans distance from TOF direction for secondaries + HadronAna->SetD0ProtLim(0.5); // Min impact parameter for secondary proton + HadronAna->SetOpAngMin(0.1); // Min opening angle for accepting pair + HadronAna->SetDCALim(0.1); // Max DCA for accepting pair + HadronAna->SetVLenMin(5.); // Min Lambda flight path length for accepting pair + HadronAna->SetVLenMax(25.); // Max Lambda flight path length for accepting pair + HadronAna->SetDistTRD(10.); // max accepted distance of Trd Hit from STS-TOF line + HadronAna->SetTRDHmulMin(1.); // min associated Trd Hits to Track candidates + HadronAna->SetNMixedEvents(10); // Number of events to be mixed with + break; + case 20: // "0" with TRD Mul 2 + HadronAna->SetDistPrimLim(1.2); // Max Tof-Sts trans distance for primaries + HadronAna->SetDistPrimLim2(0.3); // Max Sts-Sts trans distance for primaries + HadronAna->SetDistSecLim2(0.3); // Max Sts-Sts trans distance from TOF direction for secondaries + HadronAna->SetD0ProtLim(0.5); // Min impact parameter for secondary proton + HadronAna->SetOpAngMin(0.1); // Min opening angle for accepting pair + HadronAna->SetDCALim(0.1); // Max DCA for accepting pair + HadronAna->SetVLenMin(5.); // Min Lambda flight path length for accepting pair + HadronAna->SetVLenMax(25.); // Max Lambda flight path length for accepting pair + HadronAna->SetDistTRD(10.); // max accepted distance of Trd Hit from STS-TOF line + HadronAna->SetTRDHmulMin(2.); // min associated Trd Hits to Track candidates + HadronAna->SetNMixedEvents(10); // Number of events to be mixed with + break; + default: + cout << "Cut value set " <<parSet<<" not existing, stop macro "<< endl; + return; + } + run->AddTask(HadronAna); + + // ----- 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()); + parIo2->open(parFileList, "in"); + rtdb->setFirstInput(parIo1); + rtdb->setSecondInput(parIo2); + rtdb->setOutput(parIo1); + rtdb->saveOutput(); + // ------------------------------------------------------------------------ + + FairEventManager *fMan = new FairEventManager(); + FairMCTracks *Track = new FairMCTracks ("Monte-Carlo Tracks"); + + FairMCPointDraw *MvdPoint = new FairMCPointDraw ("MvdPoint", kBlack, kFullSquare); + FairMCPointDraw *StsPoint = new FairMCPointDraw ("StsPoint", kGreen, kFullSquare); + FairMCPointDraw *MuchPoint = new FairMCPointDraw ("MuchPoint", kOrange, kFullSquare); + FairMCPointDraw *RichPoint = new FairMCPointDraw ("RichPoint", kRed, kFullSquare); + FairMCPointDraw *TrdPoint = new FairMCPointDraw ("TrdPoint", kBlue, kFullSquare); + FairMCPointDraw *TofPoint = new FairMCPointDraw ("TofPoint", kGreen, kFullSquare); + FairMCPointDraw *EcalPoint = new FairMCPointDraw ("EcalPoint", kYellow, kFullSquare); + FairMCPointDraw *RefPlanePoint = new FairMCPointDraw ("RefPlanePoint", kPink, kFullSquare); + + fMan->AddTask(Track); + + fMan->AddTask(MvdPoint); + fMan->AddTask(StsPoint); + fMan->AddTask(MuchPoint); + fMan->AddTask(RichPoint); + fMan->AddTask(TrdPoint); + fMan->AddTask(TofPoint); + fMan->AddTask(EcalPoint); + fMan->AddTask(RefPlanePoint); + CbmPixelHitSetDraw *StsHits = new CbmPixelHitSetDraw ("StsHit", kRed, kOpenCircle );// kFullSquare); + fMan->AddTask(StsHits); + CbmPixelHitSetDraw *TrdHits = new CbmPixelHitSetDraw ("TrdHit", kRed, kOpenCircle );// kFullSquare); + fMan->AddTask(TrdHits); + CbmPixelHitSetDraw *TofHits = new CbmPixelHitSetDraw ("TofHit", kRed, kOpenCircle );// kFullSquare); + fMan->AddTask(TofHits); + CbmPixelHitSetDraw *TofUHits = new CbmPixelHitSetDraw ("TofUHit", kRed, kOpenCross ); + fMan->AddTask(TofUHits); + CbmEvDisTracks *Tracks = new CbmEvDisTracks ("Tof Tracks",1); + Tracks->SetVerbose(4); + fMan->AddTask(Tracks); + + // fMan->Init(1,4,10000); + // fMan->Init(1,5,10000); // make STS visible by default + fMan->Init(1,6,10000); // make MVD visible by default + + //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(99); + } + + cout << "gEve "<< gEve << endl; + gEve->GetDefaultGLViewer()->SetClearColor(kYellow-10); + { // 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(); + Double_t rtime = timer.RealTime(); + Double_t ctime = timer.CpuTime(); + cout << endl << endl; + cout << "Macro finished succesfully." << endl; + cout << "Output file is " << outFile << endl; + cout << "Parameter file is " << parFile << endl; + cout << "Real time " << rtime << " s, CPU time " << ctime << " s" << endl; + cout << endl; + // ------------------------------------------------------------------------ + + // delete run; + + cout << " Test passed" << endl; + cout << " All ok " << endl; + RemoveGeoManager(); +} diff --git a/macro/mcbm/geometry/tof/Create_TOF_Geometry_v20b_mcbm.C b/macro/mcbm/geometry/tof/Create_TOF_Geometry_v20b_mcbm.C index 3f4aeebde081d5538660418e2d52bcb00a49bb79..55a962a335a5fb2dd117df8285867e95ae204c52 100644 --- a/macro/mcbm/geometry/tof/Create_TOF_Geometry_v20b_mcbm.C +++ b/macro/mcbm/geometry/tof/Create_TOF_Geometry_v20b_mcbm.C @@ -327,7 +327,7 @@ void Create_TOF_Geometry_v20b_mcbm() { // TGeoTranslation* stand_trans = new TGeoTranslation("", 12., 0., TOF_Z_Front_Stand); // TGeoTranslation* stand_trans = new TGeoTranslation("", 0., 0., TOF_Z_Front_Stand); TGeoRotation* stand_rot = new TGeoRotation(); - stand_rot->RotateY(-2.7); + stand_rot->RotateY(-3.5); //-2.7); TGeoCombiTrans* stand_combi_trans = new TGeoCombiTrans(*stand_trans, *stand_rot); //tof->AddNode(tofstand, 1, stand_combi_trans); diff --git a/macro/mcbm/geometry/tof/Create_TOF_Geometry_v21b_mcbm.C b/macro/mcbm/geometry/tof/Create_TOF_Geometry_v21b_mcbm.C new file mode 100644 index 0000000000000000000000000000000000000000..f5dbc27e9fb865b35bdebfc45fc3c94edd20e833 --- /dev/null +++ b/macro/mcbm/geometry/tof/Create_TOF_Geometry_v21b_mcbm.C @@ -0,0 +1,1460 @@ +/// +/// \file Create_TOF_Geometry_v21b_mcbm.C +/// \brief Generates TOF geometry in Root format. +/// + +// Changelog +// +// 2020-07-20 - v21b - NH - test different MRPC types in STAR2 moodule, replace 901 by 700 +// 2020-04-14 - v20b - NH - swapped double stack layer 2 with STAR2 moodule, buc kept as dummy +// 2020-04-01 - v20a - NH - move mTOF +20 cm in x direction for the Mar 2020 run +// 2019-11-28 - v19b - DE - move mTOF +12 cm in x direction for the Nov 2019 run +// 2019-07-31 - v19a - DE - this TOF March 2019 geometry is also known as v18m +// 2017-11-03 - v18i - DE - shift mTOF to z=298 cm for acceptance matching with mSTS +// 2017-10-06 - v18h - DE - put v18f into vertical position to fit into the mCBM cave +// 2017-07-15 - v18g - DE - swap the z-position of TOF modules: 2 in the front, 3 in the back +// 2017-07-14 - v18f - DE - reduce vertical gap between TOF modules to fix the gap between modules 1-2 and 4-5 +// 2017-05-17 - v18e - DE - rotate electronics away from beam, shift 16 cm away from beam along x-axis +// 2017-05-17 - v18d - DE - change geometry name to v18d + +// in root all sizes are given in cm + +#include "TFile.h" +#include "TGeoCompositeShape.h" +#include "TGeoManager.h" +#include "TGeoMaterial.h" +#include "TGeoMatrix.h" +#include "TGeoMedium.h" +#include "TGeoPgon.h" +#include "TGeoVolume.h" +#include "TList.h" +#include "TMath.h" +#include "TROOT.h" +#include "TString.h" +#include "TSystem.h" + +#include <iostream> + +// Name of geometry version and output file +const TString geoVersion = "tof_v21b_mcbm"; // do not change +const TString geoVersionStand = geoVersion + "Stand"; +// +const TString fileTag = "tof_v21b"; +const TString FileNameSim = fileTag + "_mcbm.geo.root"; +const TString FileNameGeo = fileTag + "_mcbm_geo.root"; +const TString FileNameInfo = fileTag + "_mcbm.geo.info"; + +// TOF_Z_Front corresponds to front cover of outer super module towers +const Float_t TOF_Z_Front_Stand = 247.2; // = z=298 mCBM@SIS18 +const Float_t TOF_Z_Front = 0; // = z=298 mCBM@SIS18 +//const Float_t TOF_Z_Front = 130; // = z=225 mCBM@SIS18 +//const Float_t TOF_Z_Front = 250; // SIS 100 hadron +//const Float_t TOF_Z_Front = 450; // SIS 100 hadron +//const Float_t TOF_Z_Front = 600; // SIS 100 electron +//const Float_t TOF_Z_Front = 650; // SIS 100 muon +//const Float_t TOF_Z_Front = 880; // SIS 300 electron +//const Float_t TOF_Z_Front = 1020; // SIS 300 muon +// +//const Float_t TOF_Z_Front = 951.5; // Wall_Z_Position = 1050 cm + + +// Names of the different used materials which are used to build the modules +// The materials are defined in the global media.geo file +const TString KeepingVolumeMedium = "air"; +const TString BoxVolumeMedium = "aluminium"; +const TString NoActivGasMedium = "RPCgas_noact"; +const TString ActivGasMedium = "RPCgas"; +const TString GlasMedium = "RPCglass"; +const TString ElectronicsMedium = "carbon"; + +// Counters: +// 0 MRPC3a +// 1 MRPC3b +// 2 +// 3 +// 4 Diamond +// +// 6 Buc 2019 +// 7 CERN 20gap +// 8 Ceramic Pad +const Int_t NumberOfDifferentCounterTypes = 9; +const Float_t Glass_X[NumberOfDifferentCounterTypes] = + {32., 52., 32., 32., 0.2, 32., 28.8, 20., 2.4}; +const Float_t Glass_Y[NumberOfDifferentCounterTypes] = + {26.9, 53., 20., 10., 0.2, 10., 6., 20., 2.4}; +const Float_t Glass_Z[NumberOfDifferentCounterTypes] = + {0.1, 0.1, 0.1, 0.1, 0.01, 0.1, 0.1, 0.1, 0.1}; + +const Float_t GasGap_X[NumberOfDifferentCounterTypes] = + {32., 52., 32., 32., 0.2, 32., 28.8, 20., 2.4}; +const Float_t GasGap_Y[NumberOfDifferentCounterTypes] = + {26.9, 53., 20., 10., 0.2, 10., 6., 20., 2.4}; +const Float_t GasGap_Z[NumberOfDifferentCounterTypes] = + {0.025, 0.025, 0.025, 0.025, 0.01, 0.02, 0.02, 0.02, 0.025}; + +const Int_t NumberOfGaps[NumberOfDifferentCounterTypes] = + {8, 8, 8, 8, 1, 8, 10, 20, 4}; +//const Int_t NumberOfGaps[NumberOfDifferentCounterTypes] = {1,1,1,1}; //deb +const Int_t NumberOfReadoutStrips[NumberOfDifferentCounterTypes] = + {32, 32, 32, 32, 8, 32, 32, 20, 1}; +//const Int_t NumberOfReadoutStrips[NumberOfDifferentCounterTypes] = {1,1,1,1}; //deb + +const Float_t SingleStackStartPosition_Z[NumberOfDifferentCounterTypes] = + {-0.6, -0.6, -0.6, -0.6, -0.1, -0.6, -0.6, -0.6, -1.}; + +const Float_t Electronics_X[NumberOfDifferentCounterTypes] = + {34.0, 53.0, 32.0, 32., 0.3, 0.1, 28.8, 20., 0.1}; +const Float_t Electronics_Y[NumberOfDifferentCounterTypes] = + {5.0, 5.0, 1.0, 1., 0.1, 0.1, 1.0, 1.0, 0.1}; +const Float_t Electronics_Z[NumberOfDifferentCounterTypes] = + {0.3, 0.3, 0.3, 0.3, 0.1, 0.1, 0.1, 0.1, 0.1}; + +const Int_t NofModuleTypes = 10; +// 5 Diamond +// 6 Buc +// 7 CERN 20 gap +// 8 Ceramic +// 9 Star2 +// Aluminum box for all module types +const Float_t Module_Size_X[NofModuleTypes] = + {180., 180., 180., 180., 180., 5., 40., 30., 22.5, 100.}; +const Float_t Module_Size_Y[NofModuleTypes] = + {49., 49., 74., 28., 18., 5., 12., 30., 11., 49.}; +const Float_t Module_Over_Y[NofModuleTypes] = + {11.5, 11.5, 11., 4.5, 4.5, 0., 0., 0., 0., 0.}; +const Float_t Module_Size_Z[NofModuleTypes] = + {11., 11., 13., 11., 11., 1., 12., 6., 6.2, 11.2}; +const Float_t Module_Thick_Alu_X_left = 0.1; +const Float_t Module_Thick_Alu_X_right = 1.0; +const Float_t Module_Thick_Alu_Y = 0.1; +const Float_t Module_Thick_Alu_Z = 0.1; + +// Distance to the center of the TOF wall [cm]; +const Float_t Wall_Z_Position = 400.; +const Float_t MeanTheta = 0.; + +//Type of Counter for module + +const Int_t NCounterInModule[NofModuleTypes] = {5, 5, 3, 5, 5, 1, 2, 1, 8, 2}; +const Int_t NCounterMax=8; +const Int_t CounterTypeInModule[NofModuleTypes][NCounterMax] = + {0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 1, 1, 1, 1, 1, 1, 1, 1, + 2, 2, 2, 2, 2, 2, 2, 2, + 3, 3, 3, 3, 3, 3, 3, 3, + 4, 4, 4, 4, 4, 4, 4, 4, + 6, 6, 6, 6, 6, 6, 6, 6, + 7, 7, 7, 7, 7, 7, 7, 7, + 8, 8, 8, 8, 8, 8, 8, 8, + 0, 7, 0, 0, 0, 0, 0, 0 + }; + +// Placement of the counter inside the module +const Float_t CounterXStartPosition[NofModuleTypes] = + {-60.0, -66.0, -56.0, -60.0, -60.0, 0.0, 0., 0., -7., 0.}; +const Float_t CounterXDistance[NofModuleTypes] = + {30.0, 32.0, 51.0, 30.0, 30.0, 0.0, 0., 0., 2., 0.}; +const Float_t CounterYStartPosition[NofModuleTypes] = + {0.0, 0.0, 0.0, 0.0, 0.0, 0., 0., -4., -1.3, 0.}; +const Float_t CounterYDistance[NofModuleTypes] = + {0.0, 0.0, 0.0, 0.0, 0.0, 0., 0., 8., 0., 0.}; +const Float_t CounterZDistance[NofModuleTypes] = + {-2.5, 0.0, 0.0, 2.5, 2.5, 0., 6., 0., 0.1, 4.}; +const Float_t CounterZStartPosition[NofModuleTypes] = + {0.0, 0.0, 0.0, 0.0, 0.0, 0., -3., 0., 0.0, -2.}; +const Float_t CounterRotationAngle[NofModuleTypes] = + {0., 8.7, 7.0, 0., 0., 0., 0., 0., 0., 0.}; + +// Pole (support structure) +const Int_t MaxNumberOfPoles = 20; +Float_t Pole_ZPos[MaxNumberOfPoles]; +Float_t Pole_Col[MaxNumberOfPoles]; +Int_t NumberOfPoles = 0; + +const Float_t Pole_Size_X = 20.; +const Float_t Pole_Size_Y = 300.; +const Float_t Pole_Size_Z = 10.; +const Float_t Pole_Thick_X = 5.; +const Float_t Pole_Thick_Y = 5.; +const Float_t Pole_Thick_Z = 5.; + +// Bars (support structure) +const Float_t Bar_Size_X = 20.; +const Float_t Bar_Size_Y = 20.; +Float_t Bar_Size_Z = 100.; + +const Int_t MaxNumberOfBars = 20; +Float_t Bar_ZPos[MaxNumberOfBars]; +Float_t Bar_XPos[MaxNumberOfBars]; +Int_t NumberOfBars = 0; + +const Float_t ChamberOverlap = 40; +const Float_t DxColl = 158.0; //Module_Size_X-ChamberOverlap; +//const Float_t Pole_Offset=Module_Size_X/2.+Pole_Size_X/2.; +const Float_t Pole_Offset = 90.0 + Pole_Size_X / 2.; + +// Position for module placement +const Float_t Inner_Module_First_Y_Position = 16.; +const Float_t Inner_Module_Last_Y_Position = 480.; +const Float_t Inner_Module_X_Offset = 0.; // centered position in x/y +//const Float_t Inner_Module_X_Offset=18; // shift by 16 cm in x +const Int_t Inner_Module_NTypes = 3; +const Float_t Inner_Module_Types[Inner_Module_NTypes] = {4., 3., 0.}; +//const Float_t Inner_Module_Number[Inner_Module_NTypes] = {2.,2.,6.}; //V13_3a +const Float_t Inner_Module_Number[Inner_Module_NTypes] = {2., 2., 1.}; //V13_3a +//const Float_t Inner_Module_Number[Inner_Module_NTypes] = {0.,0.,0.}; //debugging + +const Float_t InnerSide_Module_X_Offset = 51.; +const Float_t InnerSide_Module_NTypes = 1; +const Float_t InnerSide_Module_Types[Inner_Module_NTypes] = {5.}; +const Float_t InnerSide_Module_Number[Inner_Module_NTypes] = {2.}; //v13_3a +//const Float_t InnerSide_Module_Number[Inner_Module_NTypes] = {0.}; //debug + +const Float_t Outer_Module_First_Y_Position = 0.; +const Float_t Outer_Module_Last_Y_Position = 480.; +const Float_t Outer_Module_X_Offset = 3.; +const Int_t Outer_Module_Col = 4; +const Int_t Outer_Module_NTypes = 2; +const Float_t Outer_Module_Types[Outer_Module_NTypes][Outer_Module_Col] = + {1., 1., 1., 1., 2., 2., 2., 2.}; +const Float_t Outer_Module_Number[Outer_Module_NTypes][Outer_Module_Col] = + {9., 9., 2., 0., 0., 0., 3., 4.}; //V13_3a +//const Float_t Outer_Module_Number[Outer_Module_NTypes][Outer_Module_Col] = {1.,1.,0.,0., 0.,0.,0.,0.};//debug + +const Float_t Star2_First_Z_Position = TOF_Z_Front + 16.5; +const Float_t Star2_Delta_Z_Position = 0.; +const Float_t Star2_First_Y_Position = 32.; // +const Float_t Star2_Delta_Y_Position = 0.; // +const Float_t Star2_rotate_Z = -90.; +const Int_t Star2_NTypes = 1; +const Float_t Star2_Types[Star2_NTypes] = {9.}; +const Float_t Star2_Number[Star2_NTypes] = {1.}; //debugging, V16b +const Float_t Star2_X_Offset[Star2_NTypes] = {51.}; //{62.}; + +const Float_t Buc_First_Z_Position = TOF_Z_Front + 50.; +const Float_t Buc_Delta_Z_Position = 0.; +const Float_t Buc_First_Y_Position = -32.5; // +const Float_t Buc_Delta_Y_Position = 0.; // +const Float_t Buc_rotate_Z = 180.; +const Int_t Buc_NTypes = 1; +const Float_t Buc_Types[Buc_NTypes] = {6.}; +const Float_t Buc_Number[Buc_NTypes] = {1.}; //debugging, V16b +const Float_t Buc_X_Offset[Buc_NTypes] = {53.5}; + +const Int_t Cer_NTypes = 3; +const Float_t Cer_Z_Position[Cer_NTypes] = {(float) (TOF_Z_Front + 13.2), + (float) (TOF_Z_Front + 45.), + (float) (TOF_Z_Front + 45.)}; +const Float_t Cer_X_Position[Cer_NTypes] = {0., 49.8, 49.8}; +const Float_t Cer_Y_Position[Cer_NTypes] = {-1., 5., 5.}; +const Float_t Cer_rotate_Z[Cer_NTypes] = {0., 0., 0.}; +const Float_t Cer_Types[Cer_NTypes] = {5., 8., 8.}; +const Float_t Cer_Number[Cer_NTypes] = {1., 1., 1.}; //V16b + +const Float_t CERN_Z_Position = TOF_Z_Front + 50; // 20 gap +const Float_t CERN_First_Y_Position = 36.; +const Float_t CERN_X_Offset = 46.; //65.5; +const Float_t CERN_rotate_Z = 90.; +const Int_t CERN_NTypes = 1; +const Float_t CERN_Types[CERN_NTypes] = {7.}; // this is the SmType! +const Float_t CERN_Number[CERN_NTypes] = { + 1.}; // evtl. double for split signals + +// some global variables +TGeoManager* gGeoMan = NULL; // Pointer to TGeoManager instance +TGeoVolume* gModules[NofModuleTypes]; // Global storage for module types +TGeoVolume* gCounter[NumberOfDifferentCounterTypes]; +TGeoVolume* gPole; +TGeoVolume* gBar[MaxNumberOfBars]; + +const Float_t Dia_Z_Position = -0.2 - TOF_Z_Front_Stand; +const Float_t Dia_First_Y_Position = 0.; +const Float_t Dia_X_Offset = 0.; +const Float_t Dia_rotate_Z = 0.; +const Int_t Dia_NTypes = 1; +const Float_t Dia_Types[Dia_NTypes] = {5.}; +const Float_t Dia_Number[Dia_NTypes] = {1.}; + +Float_t Last_Size_Y = 0.; +Float_t Last_Over_Y = 0.; + +// Forward declarations +void create_materials_from_media_file(); +TGeoVolume* create_counter(Int_t); +TGeoVolume* create_new_counter(Int_t); +TGeoVolume* create_tof_module(Int_t); +TGeoVolume* create_new_tof_module(Int_t); +TGeoVolume* create_tof_pole(); +TGeoVolume* create_tof_bar(); +void position_tof_poles(Int_t); +void position_tof_bars(Int_t); +void position_inner_tof_modules(Int_t); +void position_side_tof_modules(Int_t); +void position_outer_tof_modules(Int_t); +void position_Dia(Int_t); +void position_Star2(Int_t); +void position_Buc(Int_t); +void position_cer_modules(Int_t); +void position_CERN(Int_t); +void dump_info_file(); + + +void Create_TOF_Geometry_v21b_mcbm() { + + // Load needed material definition from media.geo file + create_materials_from_media_file(); + + // Get the GeoManager for later usage + gGeoMan = (TGeoManager*) gROOT->FindObject("FAIRGeom"); + gGeoMan->SetVisLevel(5); // 2 = super modules + gGeoMan->SetVisOption(0); + + // Create the top volume + /* + TGeoBBox* topbox= new TGeoBBox("", 1000., 1000., 1000.); + TGeoVolume* top = new TGeoVolume("top", topbox, gGeoMan->GetMedium("air")); + gGeoMan->SetTopVolume(top); + */ + + TGeoVolume* top = new TGeoVolumeAssembly("TOP"); + gGeoMan->SetTopVolume(top); + + TGeoRotation* tof_rotation = new TGeoRotation(); + tof_rotation->RotateY(0.); // angle with respect to beam axis + //tof_rotation->RotateZ( 0 ); // electronics on 9 o'clock position = +x + // tof_rotation->RotateZ( 0 ); // electronics on 9 o'clock position = +x + // tof_rotation->RotateZ( 90 ); // electronics on 12 o'clock position (top) + // tof_rotation->RotateZ( 180 ); // electronics on 3 o'clock position = -x + // tof_rotation->RotateZ( 270 ); // electronics on 6 o'clock position (bottom) + + TGeoVolume* tof = new TGeoVolumeAssembly(geoVersion); + // top->AddNode(tof, 1, tof_rotation); + top->AddNode(tof, 1); + + TGeoVolume* tofstand = new TGeoVolumeAssembly(geoVersionStand); + // Mar 2020 run + TGeoTranslation* stand_trans = + new TGeoTranslation("", 0., 0., TOF_Z_Front_Stand); + // Nov 2019 run + // TGeoTranslation* stand_trans = new TGeoTranslation("", 12., 0., TOF_Z_Front_Stand); + // TGeoTranslation* stand_trans = new TGeoTranslation("", 0., 0., TOF_Z_Front_Stand); + TGeoRotation* stand_rot = new TGeoRotation(); + stand_rot->RotateY(-2.7); + TGeoCombiTrans* stand_combi_trans = + new TGeoCombiTrans(*stand_trans, *stand_rot); + //tof->AddNode(tofstand, 1, stand_combi_trans); + tof->AddNode(tofstand, 1); + + for (Int_t counterType = 0; counterType < NumberOfDifferentCounterTypes; + counterType++) { + gCounter[counterType] = create_new_counter(counterType); + } + + for (Int_t moduleType = 0; moduleType < NofModuleTypes; moduleType++) { + gModules[moduleType] = create_new_tof_module(moduleType); + gModules[moduleType]->SetVisContainers(1); + } + + // no pole + // gPole = create_tof_pole(); + + // position_side_tof_modules(1); // keep order !! + // position_inner_tof_modules(2); + position_inner_tof_modules(3); + position_Dia(1); + position_Star2(1); + // position_cer_modules(3); + // position_CERN(1); + position_Buc(1); + + cout << "Outer Types " << Outer_Module_Types[0][0] << ", " + << Outer_Module_Types[1][0] << ", col=1: " << Outer_Module_Types[0][1] + << ", " << Outer_Module_Types[1][1] << endl; + cout << "Outer Number " << Outer_Module_Number[0][0] << ", " + << Outer_Module_Number[1][0] << ", col=1: " << Outer_Module_Number[0][1] + << ", " << Outer_Module_Number[1][1] << endl; + // position_outer_tof_modules(4); + // position_tof_poles(0); + // position_tof_bars(0); + + gGeoMan->CloseGeometry(); + gGeoMan->CheckOverlaps(0.001); + gGeoMan->PrintOverlaps(); + gGeoMan->CheckOverlaps(0.001, "s"); + gGeoMan->PrintOverlaps(); + gGeoMan->Test(); + + tof->Export(FileNameSim); + TFile* geoFile = new TFile(FileNameSim, "UPDATE"); + stand_combi_trans->Write(); + geoFile->Close(); + + /* + TFile* outfile1 = new TFile(FileNameSim,"RECREATE"); + top->Write(); + //gGeoMan->Write(); + outfile1->Close(); +*/ + //tof->RemoveNode((TGeoNode*)tofstand); + //top->AddNode(tof, 1, tof_rotation); + //tof->ReplaceNode((TGeoNode*)tofstand, 0, stand_combi_trans); + /* + CbmTransport run; + run.SetGeoFileName(FileNameGeo); + run.LoadSetup("setup_mcbm_tof_2020"); + run.SetField(new CbmFieldConst()); +*/ + //top->Export(FileNameGeo); + + TFile* outfile2 = new TFile(FileNameGeo, "RECREATE"); + gGeoMan->Write(); + outfile2->Close(); + + dump_info_file(); + + top->SetVisContainers(1); + gGeoMan->SetVisLevel(5); + top->Draw("ogl"); + //top->Draw(); + //gModules[0]->Draw("ogl"); + // gModules[0]->Draw(""); + gModules[0]->SetVisContainers(1); + // gModules[1]->Draw(""); + gModules[1]->SetVisContainers(1); + //gModules[5]->Draw(""); + // top->Raytrace(); +} + +void create_materials_from_media_file() { + // Use the FairRoot geometry interface to load the media which are already defined + FairGeoLoader* geoLoad = new FairGeoLoader("TGeo", "FairGeoLoader"); + FairGeoInterface* geoFace = geoLoad->getGeoInterface(); + TString geoPath = gSystem->Getenv("VMCWORKDIR"); + TString geoFile = geoPath + "/geometry/media.geo"; + geoFace->setMediaFile(geoFile); + geoFace->readMedia(); + + // Read the required media and create them in the GeoManager + FairGeoMedia* geoMedia = geoFace->getMedia(); + FairGeoBuilder* geoBuild = geoLoad->getGeoBuilder(); + + FairGeoMedium* air = geoMedia->getMedium("air"); + FairGeoMedium* aluminium = geoMedia->getMedium("aluminium"); + FairGeoMedium* RPCgas = geoMedia->getMedium("RPCgas"); + FairGeoMedium* RPCgas_noact = geoMedia->getMedium("RPCgas_noact"); + FairGeoMedium* RPCglass = geoMedia->getMedium("RPCglass"); + FairGeoMedium* carbon = geoMedia->getMedium("carbon"); + + // include check if all media are found + + geoBuild->createMedium(air); + geoBuild->createMedium(aluminium); + geoBuild->createMedium(RPCgas); + geoBuild->createMedium(RPCgas_noact); + geoBuild->createMedium(RPCglass); + geoBuild->createMedium(carbon); +} + +TGeoVolume* create_counter(Int_t modType) { + + //glass + Float_t gdx = Glass_X[modType]; + Float_t gdy = Glass_Y[modType]; + Float_t gdz = Glass_Z[modType]; + + //gas gap + Int_t nstrips = NumberOfReadoutStrips[modType]; + Int_t ngaps = NumberOfGaps[modType]; + + + Float_t ggdx = GasGap_X[modType]; + Float_t ggdy = GasGap_Y[modType]; + Float_t ggdz = GasGap_Z[modType]; + Float_t gsdx = ggdx / float(nstrips); + + //single stack + Float_t dzpos = gdz + ggdz; + Float_t startzpos = SingleStackStartPosition_Z[modType]; + + // electronics + //pcb dimensions + Float_t dxe = Electronics_X[modType]; + Float_t dye = Electronics_Y[modType]; + Float_t dze = Electronics_Z[modType]; + Float_t yele = (gdy + 0.1) / 2. + dye / 2.; + + // needed materials + TGeoMedium* glassPlateVolMed = gGeoMan->GetMedium(GlasMedium); + TGeoMedium* noActiveGasVolMed = gGeoMan->GetMedium(NoActivGasMedium); + TGeoMedium* activeGasVolMed = gGeoMan->GetMedium(ActivGasMedium); + TGeoMedium* electronicsVolMed = gGeoMan->GetMedium(ElectronicsMedium); + + // Single glass plate + TGeoBBox* glass_plate = new TGeoBBox("", gdx / 2., gdy / 2., gdz / 2.); + TGeoVolume* glass_plate_vol = + new TGeoVolume("tof_glass", glass_plate, glassPlateVolMed); + glass_plate_vol->SetLineColor( + kMagenta); // set line color for the glass plate + glass_plate_vol->SetTransparency(20); // set transparency for the TOF + TGeoTranslation* glass_plate_trans = new TGeoTranslation("", 0., 0., 0.); + + // Single gas gap + TGeoBBox* gas_gap = new TGeoBBox("", ggdx / 2., ggdy / 2., ggdz / 2.); + //TGeoVolume* gas_gap_vol = + //new TGeoVolume("tof_gas_gap", gas_gap, noActiveGasVolMed); + TGeoVolume* gas_gap_vol = + new TGeoVolume("tof_gas_active", gas_gap, activeGasVolMed); + gas_gap_vol->Divide("Strip", 1, nstrips, -ggdx / 2., 0); + + gas_gap_vol->SetLineColor(kRed); // set line color for the gas gap + gas_gap_vol->SetTransparency(70); // set transparency for the TOF + TGeoTranslation* gas_gap_trans = + new TGeoTranslation("", 0., 0., (gdz + ggdz) / 2.); + + + // Single subdivided active gas gap + /* + TGeoBBox* gas_active = new TGeoBBox("", gsdx/2., ggdy/2., ggdz/2.); + TGeoVolume* gas_active_vol = + new TGeoVolume("tof_gas_active", gas_active, activeGasVolMed); + gas_active_vol->SetLineColor(kBlack); // set line color for the gas gap + gas_active_vol->SetTransparency(70); // set transparency for the TOF + */ + + // Add glass plate, inactive gas gap and active gas gaps to a single stack + TGeoVolume* single_stack = new TGeoVolumeAssembly("single_stack"); + single_stack->AddNode(glass_plate_vol, 0, glass_plate_trans); + single_stack->AddNode(gas_gap_vol, 0, gas_gap_trans); + + /* + for (Int_t l=0; l<nstrips; l++){ + TGeoTranslation* gas_active_trans + = new TGeoTranslation("", -ggdx/2+(l+0.5)*gsdx, 0., 0.); + gas_gap_vol->AddNode(gas_active_vol, l, gas_active_trans); + // single_stack->AddNode(gas_active_vol, l, gas_active_trans); + } + */ + + // Add 8 single stacks + one glass plate at the e09.750nd to a multi stack + TGeoVolume* multi_stack = new TGeoVolumeAssembly("multi_stack"); + Int_t l; + for (l = 0; l < ngaps; l++) { + TGeoTranslation* single_stack_trans = + new TGeoTranslation("", 0., 0., startzpos + l * dzpos); + multi_stack->AddNode(single_stack, l, single_stack_trans); + } + TGeoTranslation* single_glass_back_trans = + new TGeoTranslation("", 0., 0., startzpos + ngaps * dzpos); + multi_stack->AddNode(glass_plate_vol, l, single_glass_back_trans); + + // Add electronics above and below the glass stack to build a complete counter + TGeoVolume* counter = new TGeoVolumeAssembly("counter"); + TGeoTranslation* multi_stack_trans = new TGeoTranslation("", 0., 0., 0.); + counter->AddNode(multi_stack, l, multi_stack_trans); + + TGeoBBox* pcb = new TGeoBBox("", dxe / 2., dye / 2., dze / 2.); + TGeoVolume* pcb_vol = new TGeoVolume("pcb", pcb, electronicsVolMed); + pcb_vol->SetLineColor(kCyan); // set line color for the gas gap + pcb_vol->SetTransparency(10); // set transparency for the TOF + for (Int_t l = 0; l < 2; l++) { + yele *= -1.; + TGeoTranslation* pcb_trans = new TGeoTranslation("", 0., yele, 0.); + counter->AddNode(pcb_vol, l, pcb_trans); + } + + return counter; +} + +TGeoVolume* create_new_counter(Int_t modType) { + + //glass + Float_t gdx = Glass_X[modType]; + Float_t gdy = Glass_Y[modType]; + Float_t gdz = Glass_Z[modType]; + + //gas gap + Int_t nstrips = NumberOfReadoutStrips[modType]; + Int_t ngaps = NumberOfGaps[modType]; + + + Float_t ggdx = GasGap_X[modType]; + Float_t ggdy = GasGap_Y[modType]; + Float_t ggdz = GasGap_Z[modType]; + Float_t gsdx = ggdx / (Float_t)(nstrips); + + // electronics + //pcb dimensions + Float_t dxe = Electronics_X[modType]; + Float_t dye = Electronics_Y[modType]; + Float_t dze = Electronics_Z[modType]; + Float_t yele = gdy / 2. + dye / 2.; + + // counter size (calculate from glas, gap and electronics sizes) + Float_t cdx = TMath::Max(gdx, ggdx); + cdx = TMath::Max(cdx, dxe) + 0.2; + Float_t cdy = TMath::Max(gdy, ggdy) + 2 * dye + 0.2; + Float_t cdz = ngaps * ggdz + (ngaps + 1) * gdz + + 0.2; // ngaps * (gdz+ggdz) + gdz + 0.2; // ok + + //calculate thickness and first position in counter of single stack + Float_t dzpos = gdz + ggdz; + Float_t startzposglas = + -ngaps * (gdz + ggdz) + / 2.; // -cdz/2.+0.1+gdz/2.; // ok // (-cdz+gdz)/2.; // not ok + Float_t startzposgas = + startzposglas + gdz / 2. + ggdz / 2.; // -cdz/2.+0.1+gdz +ggdz/2.; // ok + + + // needed materials + TGeoMedium* glassPlateVolMed = gGeoMan->GetMedium(GlasMedium); + TGeoMedium* noActiveGasVolMed = gGeoMan->GetMedium(NoActivGasMedium); + TGeoMedium* activeGasVolMed = gGeoMan->GetMedium(ActivGasMedium); + TGeoMedium* electronicsVolMed = gGeoMan->GetMedium(ElectronicsMedium); + + + // define counter volume + TGeoBBox* counter_box = new TGeoBBox("", cdx / 2., cdy / 2., cdz / 2.); + TGeoVolume* counter = + new TGeoVolume(Form("counter_%d",modType), counter_box, noActiveGasVolMed); + counter->SetLineColor(kRed); // set line color for the counter + counter->SetTransparency(70); // set transparency for the TOF + + // define single glass plate volume + TGeoBBox* glass_plate = new TGeoBBox("", gdx / 2., gdy / 2., gdz / 2.); + TGeoVolume* glass_plate_vol = + new TGeoVolume("tof_glass", glass_plate, glassPlateVolMed); + glass_plate_vol->SetLineColor( + kMagenta); // set line color for the glass plate + glass_plate_vol->SetTransparency(20); // set transparency for the TOF + // define single gas gap volume + TGeoBBox* gas_gap = new TGeoBBox("", ggdx / 2., ggdy / 2., ggdz / 2.); + TGeoVolume* gas_gap_vol = new TGeoVolume("Gap", gas_gap, activeGasVolMed); + gas_gap_vol->Divide("Cell", 1, nstrips, -ggdx / 2., 0); + gas_gap_vol->SetLineColor(kRed); // set line color for the gas gap + gas_gap_vol->SetTransparency(99); // set transparency for the TOF + + // place 8 gas gaps and 9 glas plates in the counter + for (Int_t igap = 0; igap <= ngaps; igap++) { + // place (ngaps+1) glass plates + Float_t zpos_glas = startzposglas + igap * dzpos; + TGeoTranslation* glass_plate_trans = + new TGeoTranslation("", 0., 0., zpos_glas); + counter->AddNode(glass_plate_vol, igap, glass_plate_trans); + // place ngaps gas gaps + if (igap < ngaps) { + Float_t zpos_gas = startzposgas + igap * dzpos; + TGeoTranslation* gas_gap_trans = + new TGeoTranslation("", 0., 0., zpos_gas); + counter->AddNode(gas_gap_vol, igap, gas_gap_trans); + } + // cout <<"Zpos(Glas): "<< zpos_glas << endl; + // cout <<"Zpos(Gas): "<< zpos_gas << endl; + } + + // create and place the electronics above and below the glas stack + TGeoBBox* pcb = new TGeoBBox("", dxe / 2., dye / 2., dze / 2.); + TGeoVolume* pcb_vol = new TGeoVolume("pcb", pcb, electronicsVolMed); + pcb_vol->SetLineColor(kYellow); // kCyan); // set line color for electronics + pcb_vol->SetTransparency(10); // set transparency for the TOF + for (Int_t l = 0; l < 2; l++) { + yele *= -1.; + TGeoTranslation* pcb_trans = new TGeoTranslation("", 0., yele, 0.); + counter->AddNode(pcb_vol, l, pcb_trans); + } + + + return counter; +} + +TGeoVolume* create_tof_module(Int_t modType) { + Int_t cType = CounterTypeInModule[modType][0]; + Float_t dx = Module_Size_X[modType]; + Float_t dy = Module_Size_Y[modType]; + Float_t dz = Module_Size_Z[modType]; + Float_t width_aluxl = Module_Thick_Alu_X_left; + Float_t width_aluxr = Module_Thick_Alu_X_right; + Float_t width_aluy = Module_Thick_Alu_Y; + Float_t width_aluz = Module_Thick_Alu_Z; + + Float_t shift_gas_box = + (Module_Thick_Alu_X_right - Module_Thick_Alu_X_left) / 2; + + Float_t dxpos = CounterXDistance[modType]; + Float_t startxpos = CounterXStartPosition[modType]; + Float_t dzoff = CounterZDistance[modType]; + Float_t rotangle = CounterRotationAngle[modType]; + + TGeoMedium* boxVolMed = gGeoMan->GetMedium(BoxVolumeMedium); + TGeoMedium* noActiveGasVolMed = gGeoMan->GetMedium(NoActivGasMedium); + + TString moduleName = Form("module_%d", modType); + TGeoVolume* module = new TGeoVolumeAssembly(moduleName); + + TGeoBBox* alu_box = new TGeoBBox("", dx / 2., dy / 2., dz / 2.); + TGeoVolume* alu_box_vol = new TGeoVolume("alu_box", alu_box, boxVolMed); + alu_box_vol->SetLineColor(kGreen); // set line color for the alu box + alu_box_vol->SetTransparency(20); // set transparency for the TOF + TGeoTranslation* alu_box_trans = new TGeoTranslation("", 0., 0., 0.); + module->AddNode(alu_box_vol, 0, alu_box_trans); + + TGeoBBox* gas_box = new TGeoBBox("", + (dx - (width_aluxl + width_aluxr)) / 2., + (dy - 2 * width_aluy) / 2., + (dz - 2 * width_aluz) / 2.); + TGeoVolume* gas_box_vol = + new TGeoVolume("gas_box", gas_box, noActiveGasVolMed); + gas_box_vol->SetLineColor(kYellow); // set line color for the gas box + gas_box_vol->SetTransparency(70); // set transparency for the TOF + TGeoTranslation* gas_box_trans = + new TGeoTranslation("", shift_gas_box, 0., 0.); + alu_box_vol->AddNode(gas_box_vol, 0, gas_box_trans); + + for (Int_t j = 0; j < 5; j++) { //loop over counters (modules) + Float_t zpos; + if (0 == modType) { + zpos = dzoff *= -1; + } else { + zpos = 0.; + } + //cout << "counter z position " << zpos << endl; + TGeoTranslation* counter_trans = + new TGeoTranslation("", startxpos + j * dxpos, 0.0, zpos); + + TGeoRotation* counter_rot = new TGeoRotation(); + counter_rot->RotateY(rotangle); + TGeoCombiTrans* counter_combi_trans = + new TGeoCombiTrans(*counter_trans, *counter_rot); + gas_box_vol->AddNode(gCounter[cType], j, counter_combi_trans); + } + + return module; +} + +TGeoVolume* create_new_tof_module(Int_t modType) { + Int_t cType = CounterTypeInModule[modType][0]; //TBC + Float_t dx = Module_Size_X[modType]; + Float_t dy = Module_Size_Y[modType]; + Float_t dz = Module_Size_Z[modType]; + Float_t width_aluxl = Module_Thick_Alu_X_left; + Float_t width_aluxr = Module_Thick_Alu_X_right; + Float_t width_aluy = Module_Thick_Alu_Y; + Float_t width_aluz = Module_Thick_Alu_Z; + + Float_t shift_gas_box = + (Module_Thick_Alu_X_right - Module_Thick_Alu_X_left) / 2; + + Float_t dxpos = CounterXDistance[modType]; + Float_t startxpos = CounterXStartPosition[modType]; + Float_t dypos = CounterYDistance[modType]; + Float_t startypos = CounterYStartPosition[modType]; + Float_t dzoff = CounterZDistance[modType]; + Float_t rotangle = CounterRotationAngle[modType]; + + TGeoMedium* boxVolMed = gGeoMan->GetMedium(BoxVolumeMedium); + TGeoMedium* noActiveGasVolMed = gGeoMan->GetMedium(NoActivGasMedium); + + TString moduleName = Form("module_%d", modType); + + TGeoBBox* module_box = new TGeoBBox("", dx / 2., dy / 2., dz / 2.); + TGeoVolume* module = new TGeoVolume(moduleName, module_box, boxVolMed); + module->SetLineColor(kGreen); // set line color for the alu box + module->SetTransparency(20); // set transparency for the TOF + + TGeoBBox* gas_box = new TGeoBBox("", + (dx - (width_aluxl + width_aluxr)) / 2., + (dy - 2 * width_aluy) / 2., + (dz - 2 * width_aluz) / 2.); + TGeoVolume* gas_box_vol = + new TGeoVolume("gas_box", gas_box, noActiveGasVolMed); + gas_box_vol->SetLineColor(kBlue); // set line color for the alu box + gas_box_vol->SetTransparency(50); // set transparency for the TOF + TGeoTranslation* gas_box_trans = + new TGeoTranslation("", shift_gas_box, 0., 0.); + module->AddNode(gas_box_vol, 0, gas_box_trans); + + for (Int_t j = 0; j < NCounterInModule[modType]; + j++) { //loop over counters (modules) + //for (Int_t j=0; j< 1; j++){ //loop over counters (modules) + Float_t xpos, ypos, zpos; + if (0 == modType || 3 == modType || 4 == modType || 5 == modType) { + zpos = dzoff *= -1; + } else { + zpos = CounterZStartPosition[modType] + j * dzoff; + } + cout << "place counter " << j << " of type " << CounterTypeInModule[modType][j] + << " in module of type "<<modType << " at z position " << zpos << endl; + xpos = startxpos + j * dxpos; + ypos = startypos + j * dypos; + + TGeoTranslation* counter_trans = new TGeoTranslation("", xpos, ypos, zpos); + + TGeoRotation* counter_rot = new TGeoRotation(); + counter_rot->RotateY(rotangle); + TGeoCombiTrans* counter_combi_trans = + new TGeoCombiTrans(*counter_trans, *counter_rot); + //gas_box_vol->AddNode(gCounter[cType], j, counter_combi_trans); + gas_box_vol->AddNode(gCounter[CounterTypeInModule[modType][j]], j, counter_combi_trans); + } + + return module; +} + + +TGeoVolume* create_tof_pole() { + // needed materials + TGeoMedium* boxVolMed = gGeoMan->GetMedium(BoxVolumeMedium); + TGeoMedium* airVolMed = gGeoMan->GetMedium(KeepingVolumeMedium); + + Float_t dx = Pole_Size_X; + Float_t dy = Pole_Size_Y; + Float_t dz = Pole_Size_Z; + Float_t width_alux = Pole_Thick_X; + Float_t width_aluy = Pole_Thick_Y; + Float_t width_aluz = Pole_Thick_Z; + + TGeoVolume* pole = new TGeoVolumeAssembly("Pole"); + TGeoBBox* pole_alu_box = new TGeoBBox("", dx / 2., dy / 2., dz / 2.); + TGeoVolume* pole_alu_vol = + new TGeoVolume("pole_alu", pole_alu_box, boxVolMed); + pole_alu_vol->SetLineColor(kGreen); // set line color for the alu box + pole_alu_vol->SetTransparency(20); // set transparency for the TOF + TGeoTranslation* pole_alu_trans = new TGeoTranslation("", 0., 0., 0.); + pole->AddNode(pole_alu_vol, 0, pole_alu_trans); + + Float_t air_dx = dx / 2. - width_alux; + Float_t air_dy = dy / 2. - width_aluy; + Float_t air_dz = dz / 2. - width_aluz; + + // cout << "My pole." << endl; + if (air_dx <= 0.) + cout << "ERROR - No air volume in pole X, size: " << air_dx << endl; + if (air_dy <= 0.) + cout << "ERROR - No air volume in pole Y, size: " << air_dy << endl; + if (air_dz <= 0.) + cout << "ERROR - No air volume in pole Z, size: " << air_dz << endl; + + if ((air_dx > 0.) && (air_dy > 0.) + && (air_dz > 0.)) // crate air volume only, if larger than zero + { + TGeoBBox* pole_air_box = new TGeoBBox("", air_dx, air_dy, air_dz); + // TGeoBBox* pole_air_box = new TGeoBBox("", dx/2.-width_alux, dy/2.-width_aluy, dz/2.-width_aluz); + TGeoVolume* pole_air_vol = + new TGeoVolume("pole_air", pole_air_box, airVolMed); + pole_air_vol->SetLineColor(kYellow); // set line color for the alu box + pole_air_vol->SetTransparency(70); // set transparency for the TOF + TGeoTranslation* pole_air_trans = new TGeoTranslation("", 0., 0., 0.); + pole_alu_vol->AddNode(pole_air_vol, 0, pole_air_trans); + } else + cout << "Skipping pole_air_vol, no thickness: " << air_dx << " " << air_dy + << " " << air_dz << endl; + + return pole; +} + +TGeoVolume* create_tof_bar(Float_t dx, Float_t dy, Float_t dz) { + // needed materials + TGeoMedium* boxVolMed = gGeoMan->GetMedium(BoxVolumeMedium); + TGeoMedium* airVolMed = gGeoMan->GetMedium(KeepingVolumeMedium); + + Float_t width_alux = Pole_Thick_X; + Float_t width_aluy = Pole_Thick_Y; + Float_t width_aluz = Pole_Thick_Z; + + TGeoVolume* bar = new TGeoVolumeAssembly("Bar"); + TGeoBBox* bar_alu_box = new TGeoBBox("", dx / 2., dy / 2., dz / 2.); + TGeoVolume* bar_alu_vol = new TGeoVolume("bar_alu", bar_alu_box, boxVolMed); + bar_alu_vol->SetLineColor(kGreen); // set line color for the alu box + bar_alu_vol->SetTransparency(20); // set transparency for the TOF + TGeoTranslation* bar_alu_trans = new TGeoTranslation("", 0., 0., 0.); + bar->AddNode(bar_alu_vol, 0, bar_alu_trans); + + TGeoBBox* bar_air_box = new TGeoBBox( + "", dx / 2. - width_alux, dy / 2. - width_aluy, dz / 2. - width_aluz); + TGeoVolume* bar_air_vol = new TGeoVolume("bar_air", bar_air_box, airVolMed); + bar_air_vol->SetLineColor(kYellow); // set line color for the alu box + bar_air_vol->SetTransparency(70); // set transparency for the TOF + TGeoTranslation* bar_air_trans = new TGeoTranslation("", 0., 0., 0.); + bar_alu_vol->AddNode(bar_air_vol, 0, bar_air_trans); + + return bar; +} + +void position_tof_poles(Int_t modType) { + + TGeoTranslation* pole_trans = NULL; + + Int_t numPoles = 0; + for (Int_t i = 0; i < NumberOfPoles; i++) { + if (i < 2) { + pole_trans = + new TGeoTranslation("", -Pole_Offset + 2.0, 0., Pole_ZPos[i]); + gGeoMan->GetVolume(geoVersionStand)->AddNode(gPole, numPoles, pole_trans); + numPoles++; + } else { + Float_t xPos = Pole_Offset + Pole_Size_X / 2. + Pole_Col[i] * DxColl; + Float_t zPos = Pole_ZPos[i]; + pole_trans = new TGeoTranslation("", xPos, 0., zPos); + gGeoMan->GetVolume(geoVersionStand)->AddNode(gPole, numPoles, pole_trans); + numPoles++; + + pole_trans = new TGeoTranslation("", -xPos, 0., zPos); + gGeoMan->GetVolume(geoVersionStand)->AddNode(gPole, numPoles, pole_trans); + numPoles++; + } + cout << " Position Pole " << numPoles << " at z=" << Pole_ZPos[i] << endl; + } +} + +void position_tof_bars(Int_t modType) { + + TGeoTranslation* bar_trans = NULL; + + Int_t numBars = 0; + Int_t i; + Float_t xPos; + Float_t yPos; + Float_t zPos; + + for (i = 0; i < NumberOfBars; i++) { + + xPos = Bar_XPos[i]; + zPos = Bar_ZPos[i]; + yPos = Pole_Size_Y / 2. + Bar_Size_Y / 2.; + + bar_trans = new TGeoTranslation("", xPos, yPos, zPos); + gGeoMan->GetVolume(geoVersionStand)->AddNode(gBar[i], numBars, bar_trans); + numBars++; + + bar_trans = new TGeoTranslation("", xPos, -yPos, zPos); + gGeoMan->GetVolume(geoVersionStand)->AddNode(gBar[i], numBars, bar_trans); + numBars++; + + bar_trans = new TGeoTranslation("", -xPos, yPos, zPos); + gGeoMan->GetVolume(geoVersionStand)->AddNode(gBar[i], numBars, bar_trans); + numBars++; + + bar_trans = new TGeoTranslation("", -xPos, -yPos, zPos); + gGeoMan->GetVolume(geoVersionStand)->AddNode(gBar[i], numBars, bar_trans); + numBars++; + } + cout << " Position Bar " << numBars << " at z=" << Bar_ZPos[i] << endl; + + // horizontal frame bars + i = NumberOfBars; + NumberOfBars++; + // no bar + // gBar[i]=create_tof_bar(2.*xPos+Pole_Size_X,Bar_Size_Y,Bar_Size_Y); + + zPos = Pole_ZPos[0] + Pole_Size_Z / 2.; + bar_trans = new TGeoTranslation("", 0., yPos, zPos); + gGeoMan->GetVolume(geoVersionStand)->AddNode(gBar[i], numBars, bar_trans); + numBars++; + + bar_trans = new TGeoTranslation("", 0., -yPos, zPos); + gGeoMan->GetVolume(geoVersionStand)->AddNode(gBar[i], numBars, bar_trans); + numBars++; +} + +void position_inner_tof_modules(Int_t modNType) { + TGeoTranslation* module_trans = NULL; + + // Int_t numModules=(Int_t)( (Inner_Module_Last_Y_Position-Inner_Module_First_Y_Position)/Module_Size_Y[modType])+1; + Float_t yPos = Inner_Module_First_Y_Position; + Int_t ii = 0; + Float_t xPos = Inner_Module_X_Offset; + Float_t zPos = Wall_Z_Position; + + Pole_ZPos[NumberOfPoles] = zPos; + Pole_Col[NumberOfPoles] = 0; + NumberOfPoles++; + + Float_t DzPos = 0.; + for (Int_t j = 0; j < modNType; j++) { + if (Module_Size_Z[j] > DzPos) { DzPos = Module_Size_Z[j]; } + } + Pole_ZPos[NumberOfPoles] = zPos + DzPos; + Pole_Col[NumberOfPoles] = 0; + NumberOfPoles++; + + // for (Int_t j=0; j<modNType; j++){ + // for (Int_t j=1; j<modNType; j++){ + Int_t modType; + Int_t modNum; + for (Int_t j = 2; j < modNType; + j++) { // place only M4 type modules (modNType == 2) + //DEDE + modType = Inner_Module_Types[j]; + modNum = 0; + // for(Int_t i=0; i<Inner_Module_Number[j]; i++) { + // for(Int_t i=0; i<1; i++) { // place 1x2 modules in the top and same in the bottom + for (Int_t i = 0; i < 2; + i++) { // place 2x2 modules in the top and same in the bottom + ii++; + cout << "Inner ii " << ii << " Last " << Last_Size_Y << ", " + << Last_Over_Y << endl; + Float_t DeltaY = Module_Size_Y[modType] + Last_Size_Y + - 2. * (Module_Over_Y[modType] + Last_Over_Y); + // DeltaY = 1.5; + cout << "DeltaY " << DeltaY << endl; + yPos += DeltaY; + Last_Size_Y = Module_Size_Y[modType]; + Last_Over_Y = Module_Over_Y[modType]; + cout << "Position Inner Module " << i << " of " << Inner_Module_Number[j] + << " Type " << modType << " at Y = " << yPos + << " Ysize = " << Module_Size_Y[modType] << " DeltaY = " << DeltaY + << endl; + + /// module_trans = new TGeoTranslation("", xPos, yPos, zPos); + /// gGeoMan->GetVolume(geoVersionStand)->AddNode(gModules[modType], modNum, module_trans); + /// modNum++; + /// module_trans = new TGeoTranslation("", xPos, -yPos, zPos); + /// gGeoMan->GetVolume(geoVersionStand)->AddNode(gModules[modType], modNum, module_trans); + /// modNum++; + // // if (ii>0) { + // if (ii>1) { + // module_trans + // = new TGeoTranslation("", xPos, yPos-DeltaY/2, zPos+Module_Size_Z[modType]); + // gGeoMan->GetVolume(geoVersionStand)->AddNode(gModules[modType], modNum, module_trans); + // modNum++; + // module_trans + // = new TGeoTranslation("", xPos, -(yPos-DeltaY/2), zPos+Module_Size_Z[modType]); + // gGeoMan->GetVolume(geoVersionStand)->AddNode(gModules[modType], modNum, module_trans); + // modNum++; + // } + } + } + // module_trans = new TGeoTranslation("", xPos, -49-3, zPos); + + // Mar2019 setup + const Int_t NModules = 5; + xPos = 0.; + yPos = 0.; + zPos = TOF_Z_Front; + const Double_t ModDx[NModules] = {0., 0., 0., 49.8, 49.8}; + //const Double_t ModDx[NModules]= { 1.5, 0., -1.5, 49.8, 55.8}; + const Double_t ModDy[NModules] = {0., 0., 0., 0., 0.}; + const Double_t ModDz[NModules] = {0., 16.5, 34., 0., 34.}; + const Double_t ModAng[NModules] = {-90., -90., -90., -90., -90.0}; + TGeoRotation* module_rot = NULL; + TGeoCombiTrans* module_combi_trans = NULL; + + for (Int_t iMod = 0; iMod < NModules; iMod++) { + module_trans = new TGeoTranslation( + "", xPos + ModDx[iMod], yPos + ModDy[iMod], zPos + ModDz[iMod]); + module_rot = new TGeoRotation(); + module_rot->RotateZ(ModAng[iMod]); + module_combi_trans = new TGeoCombiTrans(*module_trans, *module_rot); + gGeoMan->GetVolume(geoVersionStand) + ->AddNode(gModules[modType], modNum, module_combi_trans); + modNum++; + } + + + /* + module_trans = new TGeoTranslation("", xPos, 0, zPos+16.5); + gGeoMan->GetVolume(geoVersionStand)->AddNode(gModules[modType], modNum, module_trans); + modNum++; + + // module_trans = new TGeoTranslation("", xPos, 49+3, zPos); + module_trans = new TGeoTranslation("", xPos, 0, zPos+16.5+17.5); + gGeoMan->GetVolume(geoVersionStand)->AddNode(gModules[modType], modNum, module_trans); + modNum++; + + // module_trans = new TGeoTranslation("", xPos,-26, zPos+Module_Size_Z[modType]); + module_trans = new TGeoTranslation("", xPos, -49.8, zPos); + gGeoMan->GetVolume(geoVersionStand)->AddNode(gModules[modType], modNum, module_trans); + modNum++; + + // module_trans = new TGeoTranslation("", xPos, 26, zPos+Module_Size_Z[modType]); + module_trans = new TGeoTranslation("", xPos, -49.8, zPos+16.5); + gGeoMan->GetVolume(geoVersionStand)->AddNode(gModules[modType], modNum, module_trans); + modNum++; + */ +} + + +void position_Dia(Int_t modNType) { + TGeoTranslation* module_trans = NULL; + TGeoRotation* module_rot = new TGeoRotation(); + module_rot->RotateZ(Dia_rotate_Z); + TGeoCombiTrans* module_combi_trans = NULL; + + // Int_t numModules=(Int_t)( (Inner_Module_Last_Y_Position-Inner_Module_First_Y_Position)/Module_Size_Y[modType])+1; + Float_t yPos = Dia_First_Y_Position; + Int_t ii = 0; + Float_t xPos = Dia_X_Offset; + Float_t zPos = Dia_Z_Position; + + Int_t modNum = 0; + for (Int_t j = 0; j < modNType; j++) { + Int_t modType = Dia_Types[j]; + for (Int_t i = 0; i < Dia_Number[j]; i++) { + ii++; + module_trans = new TGeoTranslation("", xPos, yPos, zPos); + module_combi_trans = new TGeoCombiTrans(*module_trans, *module_rot); + gGeoMan->GetVolume(geoVersionStand) + ->AddNode(gModules[modType], modNum, module_combi_trans); + modNum++; + } + } +} + +void position_Star2(Int_t modNType) { + TGeoTranslation* module_trans = NULL; + TGeoRotation* module_rot = new TGeoRotation(); + module_rot->RotateZ(Star2_rotate_Z); + TGeoCombiTrans* module_combi_trans = NULL; + + Float_t yPos = Star2_First_Y_Position; + Float_t zPos = Star2_First_Z_Position; + Int_t ii = 0; + + Int_t modNum = 0; + for (Int_t j = 0; j < modNType; j++) { + Int_t modType = Star2_Types[j]; + Float_t xPos = Star2_X_Offset[j]; + for (Int_t i = 0; i < Star2_Number[j]; i++) { + ii++; + module_trans = new TGeoTranslation("", xPos, yPos, zPos); + module_combi_trans = new TGeoCombiTrans(*module_trans, *module_rot); + gGeoMan->GetVolume(geoVersionStand) + ->AddNode(gModules[modType], modNum, module_combi_trans); + modNum++; + yPos += Star2_Delta_Y_Position; + zPos += Star2_Delta_Z_Position; + } + } +} + +void position_Buc(Int_t modNType) { + TGeoTranslation* module_trans = NULL; + TGeoRotation* module_rot = new TGeoRotation(); + module_rot->RotateZ(Buc_rotate_Z); + TGeoCombiTrans* module_combi_trans = NULL; + + Float_t yPos = Buc_First_Y_Position; + Float_t zPos = Buc_First_Z_Position; + Int_t ii = 0; + + Int_t modNum = 0; + for (Int_t j = 0; j < modNType; j++) { + Int_t modType = Buc_Types[j]; + Float_t xPos = Buc_X_Offset[j]; + for (Int_t i = 0; i < Buc_Number[j]; i++) { + ii++; + module_trans = new TGeoTranslation("", xPos, yPos, zPos); + module_combi_trans = new TGeoCombiTrans(*module_trans, *module_rot); + gGeoMan->GetVolume(geoVersionStand) + ->AddNode(gModules[modType], modNum, module_combi_trans); + modNum++; + yPos += Buc_Delta_Y_Position; + zPos += Buc_Delta_Z_Position; + } + } +} + +void position_cer_modules(Int_t modNType) { + Int_t ii = 0; + Int_t modNum = 0; + for (Int_t j = 1; j < modNType; j++) { + Int_t modType = Cer_Types[j]; + Float_t xPos = Cer_X_Position[j]; + Float_t yPos = Cer_Y_Position[j]; + Float_t zPos = Cer_Z_Position[j]; + TGeoTranslation* module_trans = NULL; + TGeoRotation* module_rot = + new TGeoRotation(Form("Cer%d", j), Cer_rotate_Z[j], -MeanTheta, 0.); + // module_rot->RotateZ(Cer_rotate_Z[j]); + TGeoCombiTrans* module_combi_trans = NULL; + + for (Int_t i = 0; i < Cer_Number[j]; i++) { + ii++; + cout << "Position Ceramic Module " << i << " of " << Cer_Number[j] + << " Type " << modType << " at X = " << xPos << ", Y = " << yPos + << ", Z = " << zPos << endl; + // Front staggered module (Top if pair), top + module_trans = new TGeoTranslation("", xPos, yPos, zPos); + module_combi_trans = new TGeoCombiTrans(*module_trans, *module_rot); + gGeoMan->GetVolume(geoVersionStand) + ->AddNode(gModules[modType], modNum, module_combi_trans); + // modNum++; + } + } +} + +void position_CERN(Int_t modNType) { + TGeoTranslation* module_trans = NULL; + TGeoRotation* module_rot = new TGeoRotation(); + module_rot->RotateZ(CERN_rotate_Z); + TGeoCombiTrans* module_combi_trans = NULL; + + // Int_t numModules=(Int_t)( (Inner_Module_Last_Y_Position-Inner_Module_First_Y_Position)/Module_Size_Y[modType])+1; + Float_t yPos = CERN_First_Y_Position; + Int_t ii = 0; + Float_t xPos = CERN_X_Offset; + Float_t zPos = CERN_Z_Position; + + for (Int_t j = 0; j < modNType; j++) { + Int_t modType = CERN_Types[j]; + Int_t modNum = 0; + for (Int_t i = 0; i < CERN_Number[j]; i++) { + ii++; + module_trans = new TGeoTranslation("", xPos, yPos, zPos); + module_combi_trans = new TGeoCombiTrans(*module_trans, *module_rot); + gGeoMan->GetVolume(geoVersionStand) + ->AddNode(gModules[modType], modNum, module_combi_trans); + modNum++; + } + } +} + +void position_side_tof_modules(Int_t modNType) { + TGeoTranslation* module_trans = NULL; + TGeoRotation* module_rot = new TGeoRotation(); + module_rot->RotateZ(180.); + TGeoCombiTrans* module_combi_trans = NULL; + + // Int_t numModules=(Int_t)( (Inner_Module_Last_Y_Position-Inner_Module_First_Y_Position)/Module_Size_Y[modType])+1; + Float_t yPos = 0.; //Inner_Module_First_Y_Position; + Int_t ii = 0; + for (Int_t j = 0; j < modNType; j++) { + Int_t modType = InnerSide_Module_Types[j]; + Int_t modNum = 0; + for (Int_t i = 0; i < InnerSide_Module_Number[j]; i++) { + ii++; + cout << "InnerSide ii " << ii << " Last " << Last_Size_Y << "," + << Last_Over_Y << endl; + Float_t DeltaY = Module_Size_Y[modType] + Last_Size_Y + - 2. * (Module_Over_Y[modType] + Last_Over_Y); + if (ii > 1) { yPos += DeltaY; } + Last_Size_Y = Module_Size_Y[modType]; + Last_Over_Y = Module_Over_Y[modType]; + Float_t xPos = InnerSide_Module_X_Offset; + Float_t zPos = Wall_Z_Position; + cout << "Position InnerSide Module " << i << " of " + << InnerSide_Module_Number[j] << " Type " << modType + << " at Y = " << yPos << " Ysize = " << Module_Size_Y[modType] + << " DeltaY = " << DeltaY << endl; + + module_trans = new TGeoTranslation("", xPos, yPos, zPos); + gGeoMan->GetVolume(geoVersionStand) + ->AddNode(gModules[modType], modNum, module_trans); + modNum++; + + module_trans = new TGeoTranslation("", -xPos, yPos, zPos); + module_combi_trans = new TGeoCombiTrans(*module_trans, *module_rot); + gGeoMan->GetVolume(geoVersionStand) + ->AddNode(gModules[modType], modNum, module_combi_trans); + modNum++; + + if (ii > 1) { + module_trans = new TGeoTranslation("", xPos, -yPos, zPos); + gGeoMan->GetVolume(geoVersionStand) + ->AddNode(gModules[modType], modNum, module_trans); + modNum++; + + module_trans = new TGeoTranslation("", -xPos, -yPos, zPos); + module_combi_trans = new TGeoCombiTrans(*module_trans, *module_rot); + gGeoMan->GetVolume(geoVersionStand) + ->AddNode(gModules[modType], modNum, module_combi_trans); + modNum++; + + module_trans = new TGeoTranslation( + "", xPos, yPos - DeltaY / 2, zPos + Module_Size_Z[modType]); + gGeoMan->GetVolume(geoVersionStand) + ->AddNode(gModules[modType], modNum, module_trans); + modNum++; + + module_trans = new TGeoTranslation( + "", -xPos, yPos - DeltaY / 2, zPos + Module_Size_Z[modType]); + module_combi_trans = new TGeoCombiTrans(*module_trans, *module_rot); + gGeoMan->GetVolume(geoVersionStand) + ->AddNode(gModules[modType], modNum, module_combi_trans); + modNum++; + + module_trans = new TGeoTranslation( + "", xPos, -(yPos - DeltaY / 2), zPos + Module_Size_Z[modType]); + gGeoMan->GetVolume(geoVersionStand) + ->AddNode(gModules[modType], modNum, module_trans); + modNum++; + + module_trans = new TGeoTranslation( + "", -xPos, -(yPos - DeltaY / 2), zPos + Module_Size_Z[modType]); + module_combi_trans = new TGeoCombiTrans(*module_trans, *module_rot); + gGeoMan->GetVolume(geoVersionStand) + ->AddNode(gModules[modType], modNum, module_combi_trans); + modNum++; + } + } + } +} + +void position_outer_tof_modules(Int_t nCol) //modType, Int_t col1, Int_t col2) +{ + TGeoTranslation* module_trans = NULL; + TGeoRotation* module_rot = new TGeoRotation(); + module_rot->RotateZ(180.); + TGeoCombiTrans* module_combi_trans = NULL; + + // Int_t numModules=(Int_t)( (Outer_Module_Last_Y_Position-Outer_Module_First_Y_Position)/Module_Size_Y[modType])+1; + + Int_t modNum[NofModuleTypes]; + for (Int_t k = 0; k < NofModuleTypes; k++) { + modNum[k] = 0; + } + + Float_t zPos = Wall_Z_Position; + for (Int_t j = 0; j < nCol; j++) { + Float_t xPos = Outer_Module_X_Offset + ((j + 1) * DxColl); + Last_Size_Y = 0.; + Last_Over_Y = 0.; + Float_t yPos = 0.; + Int_t ii = 0; + Float_t DzPos = 0.; + for (Int_t k = 0; k < Outer_Module_NTypes; k++) { + Int_t modType = Outer_Module_Types[k][j]; + if (Module_Size_Z[modType] > DzPos) { + if (Outer_Module_Number[k][j] > 0) { DzPos = Module_Size_Z[modType]; } + } + } + + zPos -= 2. * DzPos; //((j+1)*2*Module_Size_Z[modType]); + + Pole_ZPos[NumberOfPoles] = zPos; + Pole_Col[NumberOfPoles] = j + 1; + NumberOfPoles++; + Pole_ZPos[NumberOfPoles] = zPos + DzPos; + Pole_Col[NumberOfPoles] = j + 1; + NumberOfPoles++; + //if (j+1==nCol) { + if (1) { + Pole_ZPos[NumberOfPoles] = Pole_ZPos[0]; + Pole_Col[NumberOfPoles] = j + 1; + NumberOfPoles++; + + Bar_Size_Z = Pole_ZPos[0] - zPos; + gBar[NumberOfBars] = create_tof_bar(Bar_Size_X, Bar_Size_Y, Bar_Size_Z); + Bar_ZPos[NumberOfBars] = zPos + Bar_Size_Z / 2. - Pole_Size_Z / 2.; + Bar_XPos[NumberOfBars] = xPos + Pole_Offset; + NumberOfBars++; + } + + for (Int_t k = 0; k < Outer_Module_NTypes; k++) { + Int_t modType = Outer_Module_Types[k][j]; + Int_t numModules = Outer_Module_Number[k][j]; + + cout << " Outer: position " << numModules << " of type " << modType + << " in col " << j << " at z = " << zPos << ", DzPos = " << DzPos + << endl; + for (Int_t i = 0; i < numModules; i++) { + ii++; + cout << "Outer ii " << ii << " Last " << Last_Size_Y << "," + << Last_Over_Y << endl; + Float_t DeltaY = Module_Size_Y[modType] + Last_Size_Y + - 2. * (Module_Over_Y[modType] + Last_Over_Y); + if (ii > 1) { yPos += DeltaY; } + Last_Size_Y = Module_Size_Y[modType]; + Last_Over_Y = Module_Over_Y[modType]; + cout << "Position Outer Module " << i << " of " + << Outer_Module_Number[k][j] << " Type " << modType << "(#" + << modNum[modType] << ") " + << " at Y = " << yPos << " Ysize = " << Module_Size_Y[modType] + << " DeltaY = " << DeltaY << endl; + + module_trans = new TGeoTranslation("", xPos, yPos, zPos); + gGeoMan->GetVolume(geoVersionStand) + ->AddNode(gModules[modType], modNum[modType], module_trans); + modNum[modType]++; + + module_trans = new TGeoTranslation("", -xPos, yPos, zPos); + module_combi_trans = new TGeoCombiTrans(*module_trans, *module_rot); + gGeoMan->GetVolume(geoVersionStand) + ->AddNode(gModules[modType], modNum[modType], module_combi_trans); + modNum[modType]++; + + if (ii > 1) { + module_trans = new TGeoTranslation("", xPos, -yPos, zPos); + gGeoMan->GetVolume(geoVersionStand) + ->AddNode(gModules[modType], modNum[modType], module_trans); + modNum[modType]++; + module_trans = new TGeoTranslation("", -xPos, -yPos, zPos); + module_combi_trans = new TGeoCombiTrans(*module_trans, *module_rot); + gGeoMan->GetVolume(geoVersionStand) + ->AddNode(gModules[modType], modNum[modType], module_combi_trans); + modNum[modType]++; + + // second layer + module_trans = + new TGeoTranslation("", xPos, yPos - DeltaY / 2., zPos + DzPos); + gGeoMan->GetVolume(geoVersionStand) + ->AddNode(gModules[modType], modNum[modType], module_trans); + modNum[modType]++; + module_trans = + new TGeoTranslation("", -xPos, yPos - DeltaY / 2., zPos + DzPos); + module_combi_trans = new TGeoCombiTrans(*module_trans, *module_rot); + gGeoMan->GetVolume(geoVersionStand) + ->AddNode(gModules[modType], modNum[modType], module_combi_trans); + modNum[modType]++; + + module_trans = + new TGeoTranslation("", xPos, -(yPos - DeltaY / 2.), zPos + DzPos); + gGeoMan->GetVolume(geoVersionStand) + ->AddNode(gModules[modType], modNum[modType], module_trans); + modNum[modType]++; + module_trans = + new TGeoTranslation("", -xPos, -(yPos - DeltaY / 2.), zPos + DzPos); + module_combi_trans = new TGeoCombiTrans(*module_trans, *module_rot); + gGeoMan->GetVolume(geoVersionStand) + ->AddNode(gModules[modType], modNum[modType], module_combi_trans); + modNum[modType]++; + } + } + } + } +} + + +void dump_info_file() { + TDatime datetime; // used to get timestamp + + printf("writing info file: %s\n", FileNameInfo.Data()); + + FILE* ifile; + ifile = fopen(FileNameInfo.Data(), "w"); + + if (ifile == NULL) { + printf("error opening %s\n", FileNameInfo.Data()); + exit(1); + } + + fprintf(ifile, "#\n## %s information file\n#\n\n", geoVersion.Data()); + + fprintf(ifile, "# created %d\n\n", datetime.GetDate()); + + fprintf(ifile, "# TOF setup\n"); + if (TOF_Z_Front == 450) fprintf(ifile, "SIS 100 hadron setup\n"); + if (TOF_Z_Front == 600) fprintf(ifile, "SIS 100 electron\n"); + if (TOF_Z_Front == 650) fprintf(ifile, "SIS 100 muon\n"); + if (TOF_Z_Front == 880) fprintf(ifile, "SIS 300 electron\n"); + if (TOF_Z_Front == 1020) fprintf(ifile, "SIS 300 muon\n"); + fprintf(ifile, "\n"); + + const Float_t TOF_Z_Back = + Wall_Z_Position + 1.5 * Module_Size_Z[0]; // back of TOF wall + + fprintf(ifile, "# envelope\n"); + // Show extension of TRD + fprintf(ifile, "%7.2f cm start of TOF (z)\n", TOF_Z_Front); + fprintf(ifile, "%7.2f cm end of TOF (z)\n", TOF_Z_Back); + fprintf(ifile, "\n"); + + // Layer thickness + fprintf(ifile, "# central tower position\n"); + fprintf(ifile, + "%7.2f cm center of staggered, front RPC cell at x=0\n", + Wall_Z_Position); + fprintf(ifile, "\n"); + + fclose(ifile); +} diff --git a/macro/mcbm/geometry/tof/create_tof_digipar.C b/macro/mcbm/geometry/tof/create_tof_digipar.C index ae00f7c7770af655f56d6da1d713438b1abb6686..a965cefd7777c0f98d6ac664b44c56463ad104f4 100644 --- a/macro/mcbm/geometry/tof/create_tof_digipar.C +++ b/macro/mcbm/geometry/tof/create_tof_digipar.C @@ -57,6 +57,8 @@ void create_tof_digipar(TString fileName = "tof_v16a_1e", Int_t nEvents = 0) { run->SetOutputFile(outFile); run->SetGeomFile(geoFile); FairLogger::GetLogger()->SetLogScreenLevel("DEBUG2"); + FairLogger::GetLogger()->SetLogVerbosityLevel("VERYHIGH"); + // ------------------------------------------------------------------------ FairRuntimeDb* rtdb = run->GetRuntimeDb(); diff --git a/macro/mcbm/mcbm_Ana.C b/macro/mcbm/mcbm_Ana.C index 4f76fdb28cb1e1efaf05b4f714c700d6f5e301ca..f4f8421c61653697a86598fcc4c95996089b36cf 100644 --- a/macro/mcbm/mcbm_Ana.C +++ b/macro/mcbm/mcbm_Ana.C @@ -1,84 +1,194 @@ -void mcbm_Ana(Int_t nEvents = 1000, - TString cSys = "test", - TString cEbeam = "2.5gev", - TString cCentr = "-", - Int_t iRun = 0) { - const Char_t* setup = "sis18_mcbm"; - TString outDir = "data/"; +void mcbm_Ana(Int_t nEvents = 1000, + TString cSys="lam", + TString cEbeam="2.5gev", + TString cCentr="-", + Int_t iRun=0, + Int_t parSet=0, + const char* setupName = "sis18_mcbm_20deg_long") +{ + const Char_t* setup="sis18_mcbm"; + TString outDir = "data/"; - TString InputFile = outDir + setup + "_" + cSys + "." + cEbeam + "." + cCentr - + ".mc." + Form("%05d", iRun) + ".root"; - TString RecoFile = outDir + setup + "_" + cSys + "." + cEbeam + "." + cCentr - + ".eds." + Form("%05d", iRun) + ".root"; - TString ParFile = outDir + setup + "_" + cSys + "." + cEbeam + "." + cCentr - + ".params." + Form("%05d", iRun) + ".root"; + TString InputFile = outDir + setup + "_" + cSys + "." + cEbeam + "." + cCentr + ".mc." + Form("%05d",iRun) + ".root"; + TString RecoFile = outDir + setup + "_" + cSys + "." + cEbeam + "." + cCentr + ".eds." + Form("%05d",iRun) + ".root"; + TString ParFile = outDir + setup + "_" + cSys + "." + cEbeam + "." + cCentr + ".params." + Form("%05d",iRun) + ".root"; FairLogger::GetLogger()->SetLogScreenLevel("INFO"); //FairLogger::GetLogger()->SetLogScreenLevel("DEBUG"); FairLogger::GetLogger()->SetLogVerbosityLevel("MEDIUM"); // ----- Reconstruction run ------------------------------------------- - FairRunAna* fRun = new FairRunAna(); + FairRunAna *fRun= new FairRunAna(); fRun->SetInputFile(InputFile.Data()); fRun->AddFriend(RecoFile.Data()); // ----- Parameter database -------------------------------------------- - FairRuntimeDb* rtdb = fRun->GetRuntimeDb(); + FairRuntimeDb* rtdb = fRun->GetRuntimeDb(); FairParRootFileIo* parInput1 = new FairParRootFileIo(); parInput1->open(ParFile.Data()); rtdb->setFirstInput(parInput1); - //histograms - fRun->SetOutputFile(Form("data/Ana.%s.%s.%s.%05d.root", - cSys.Data(), - cEbeam.Data(), - cCentr.Data(), - iRun)); - TFile* fHist = fRun->GetOutputFile(); + //histograms + fRun->SetOutputFile(Form("data/Ana.%s.%s.%s.%s.cut%d.%05d.root",setupName,cSys.Data(),cEbeam.Data(),cCentr.Data(),parSet,iRun)); + TFile *fHist = fRun->GetOutputFile(); - CbmHadronAnalysis* HadronAna = new CbmHadronAnalysis(); // in hadron - HadronAna->SetBeamMomentum(8.); // beam momentum - //HadronAna->SetBSelMax(8.99); // maximum impact parameter to be analyzed - //HadronAna->SetBSelMin(6.01); // minimum impact parameter to be analyzed - HadronAna->SetDY(0.5); // flow analysis exclusion window - HadronAna->SetRecSec(kTRUE); // enable lambda reconstruction - Int_t parSet = 1; - switch (parSet) { - case 0: // with background - HadronAna->SetDistPrimLim( - 1.2); // Max Tof-Sts trans distance for primaries - HadronAna->SetDistPrimLim2( - 0.3); // Max Sts-Sts trans distance for primaries - HadronAna->SetDistSecLim2( - 0.3); // Max Sts-Sts trans distance from TOF direction for secondaries - HadronAna->SetD0ProtLim( - 0.5); // Min impact parameter for secondary proton - HadronAna->SetOpAngMin(0.1); // Min opening angle for accepting pair - HadronAna->SetDCALim(0.1); // Max DCA for accepting pair - HadronAna->SetVLenMin( - 5.); // Min Lambda flight path length for accepting pair - HadronAna->SetVLenMax( - 25.); // Max Lambda flight path length for accepting pair - HadronAna->SetNMixedEvents(10); // Number of events to be mixed with + CbmHadronAnalysis *HadronAna = new CbmHadronAnalysis(); // in hadron + HadronAna->SetBeamMomentum(8.); // beam momentum + //HadronAna->SetBSelMax(8.99); // maximum impact parameter to be analyzed + //HadronAna->SetBSelMin(6.01); // minimum impact parameter to be analyzed + HadronAna->SetDY(0.5); // flow analysis exclusion window + HadronAna->SetRecSec(kTRUE); // enable lambda reconstruction + + switch(parSet){ + case 0: // with background + HadronAna->SetDistPrimLim(1.2); // Max Tof-Sts trans distance for primaries + HadronAna->SetDistPrimLim2(0.3); // Max Sts-Sts trans distance for primaries + HadronAna->SetDistSecLim2(0.3); // Max Sts-Sts trans distance from TOF direction for secondaries + HadronAna->SetD0ProtLim(0.5); // Min impact parameter for secondary proton + HadronAna->SetOpAngMin(0.1); // Min opening angle for accepting pair + HadronAna->SetDCALim(0.1); // Max DCA for accepting pair + HadronAna->SetVLenMin(5.); // Min Lambda flight path length for accepting pair + HadronAna->SetVLenMax(25.); // Max Lambda flight path length for accepting pair + HadronAna->SetDistTRD(10.); // max accepted distance of Trd Hit from STS-TOF line + HadronAna->SetTRDHmulMin(0.); // min associated Trd Hits to Track candidates + HadronAna->SetNMixedEvents(10); // Number of events to be mixed with break; - case 1: // signal only, debugging - HadronAna->SetDistPrimLim( - 0.5); // Max Tof-Sts trans distance for primaries - HadronAna->SetDistPrimLim2( - 0.3); // Max Sts-Sts trans distance for primaries - HadronAna->SetDistSecLim2( - 0.3); // Max Sts-Sts trans distance from TOF direction for secondaries - HadronAna->SetD0ProtLim( - 0.4); // Min impact parameter for secondary proton - HadronAna->SetOpAngMin(0.1); // Min opening angle for accepting pair - HadronAna->SetDCALim(0.2); // Max DCA for accepting pair - HadronAna->SetVLenMin( - 5.); // Min Lambda flight path length for accepting pair - HadronAna->SetVLenMax( - 25.); // Max Lambda flight path length for accepting pair - HadronAna->SetNMixedEvents(10); // Number of events to be mixed with + case 1: // for signal with background Ni+Ni + HadronAna->SetDistPrimLim(1.); // Max Tof-Sts trans distance for primaries + HadronAna->SetDistPrimLim2(0.3); // Max Sts-Sts trans distance for primaries + HadronAna->SetDistSecLim2(0.3); // Max Sts-Sts trans distance from TOF direction for secondaries + HadronAna->SetD0ProtLim(0.4); // Min impact parameter for secondary proton + HadronAna->SetOpAngMin(0.1); // Min opening angle for accepting pair + HadronAna->SetDCALim(0.1); // Max DCA for accepting pair + HadronAna->SetVLenMin(5.); // Min Lambda flight path length for accepting pair + HadronAna->SetVLenMax(25.); // Max Lambda flight path length for accepting pair + HadronAna->SetDistTRD(10.); // max accepted distance of Trd Hit from STS-TOF line + HadronAna->SetTRDHmulMin(0.); // min associated Trd Hits to Track candidates + HadronAna->SetNMixedEvents(10); // Number of events to be mixed with break; + case 2: // for signal with background Au+Au + HadronAna->SetDistPrimLim(1.); // Max Tof-Sts trans distance for primaries + HadronAna->SetDistPrimLim2(0.3); // Max Sts-Sts trans distance for primaries + HadronAna->SetDistSecLim2(0.3); // Max Sts-Sts trans distance from TOF direction for secondaries + HadronAna->SetD0ProtLim(0.4); // Min impact parameter for secondary proton + HadronAna->SetOpAngMin(0.1); // Min opening angle for accepting pair + HadronAna->SetDCALim(0.1); // Max DCA for accepting pair + HadronAna->SetVLenMin(8.); // Min Lambda flight path length for accepting pair + HadronAna->SetVLenMax(25.); // Max Lambda flight path length for accepting pair + HadronAna->SetDistTRD(10.); // max accepted distance of Trd Hit from STS-TOF line + HadronAna->SetTRDHmulMin(0.); // min associated Trd Hits to Track candidates + HadronAna->SetNMixedEvents(10); // Number of events to be mixed with + break; + + case 3: // syst study around case 1 + HadronAna->SetDistPrimLim(0.8); // Max Tof-Sts trans distance for primaries + HadronAna->SetDistPrimLim2(0.3); // Max Sts-Sts trans distance for primaries + HadronAna->SetDistSecLim2(0.3); // Max Sts-Sts trans distance from TOF direction for secondaries + HadronAna->SetD0ProtLim(0.4); // Min impact parameter for secondary proton + HadronAna->SetOpAngMin(0.1); // Min opening angle for accepting pair + HadronAna->SetDCALim(0.1); // Max DCA for accepting pair + HadronAna->SetVLenMin(5.); // Min Lambda flight path length for accepting pair + HadronAna->SetVLenMax(25.); // Max Lambda flight path length for accepting pair + HadronAna->SetDistTRD(10.); // max accepted distance of Trd Hit from STS-TOF line + HadronAna->SetTRDHmulMin(0.); // min associated Trd Hits to Track candidates + HadronAna->SetNMixedEvents(10); // Number of events to be mixed with + break; + case 4: // syst study around case 1 + HadronAna->SetDistPrimLim(0.9); // Max Tof-Sts trans distance for primaries + HadronAna->SetDistPrimLim2(0.3); // Max Sts-Sts trans distance for primaries + HadronAna->SetDistSecLim2(0.3); // Max Sts-Sts trans distance from TOF direction for secondaries + HadronAna->SetD0ProtLim(0.4); // Min impact parameter for secondary proton + HadronAna->SetOpAngMin(0.1); // Min opening angle for accepting pair + HadronAna->SetDCALim(0.1); // Max DCA for accepting pair + HadronAna->SetVLenMin(5.); // Min Lambda flight path length for accepting pair + HadronAna->SetVLenMax(25.); // Max Lambda flight path length for accepting pair + HadronAna->SetDistTRD(10.); // max accepted distance of Trd Hit from STS-TOF line + HadronAna->SetTRDHmulMin(0.); // min associated Trd Hits to Track candidates + HadronAna->SetNMixedEvents(10); // Number of events to be mixed with + break; + case 5: // syst study around case 1 + HadronAna->SetDistPrimLim(1.1); // Max Tof-Sts trans distance for primaries + HadronAna->SetDistPrimLim2(0.3); // Max Sts-Sts trans distance for primaries + HadronAna->SetDistSecLim2(0.3); // Max Sts-Sts trans distance from TOF direction for secondaries + HadronAna->SetD0ProtLim(0.4); // Min impact parameter for secondary proton + HadronAna->SetOpAngMin(0.1); // Min opening angle for accepting pair + HadronAna->SetDCALim(0.1); // Max DCA for accepting pair + HadronAna->SetVLenMin(5.); // Min Lambda flight path length for accepting pair + HadronAna->SetVLenMax(25.); // Max Lambda flight path length for accepting pair + HadronAna->SetDistTRD(10.); // max accepted distance of Trd Hit from STS-TOF line + HadronAna->SetTRDHmulMin(0.); // min associated Trd Hits to Track candidates + HadronAna->SetNMixedEvents(10); // Number of events to be mixed with + break; + case 6: // syst study around case 1 + HadronAna->SetDistPrimLim(1.2); // Max Tof-Sts trans distance for primaries + HadronAna->SetDistPrimLim2(0.3); // Max Sts-Sts trans distance for primaries + HadronAna->SetDistSecLim2(0.3); // Max Sts-Sts trans distance from TOF direction for secondaries + HadronAna->SetD0ProtLim(0.4); // Min impact parameter for secondary proton + HadronAna->SetOpAngMin(0.1); // Min opening angle for accepting pair + HadronAna->SetDCALim(0.1); // Max DCA for accepting pair + HadronAna->SetVLenMin(5.); // Min Lambda flight path length for accepting pair + HadronAna->SetVLenMax(25.); // Max Lambda flight path length for accepting pair + HadronAna->SetDistTRD(10.); // max accepted distance of Trd Hit from STS-TOF line + HadronAna->SetTRDHmulMin(0.); // min associated Trd Hits to Track candidates + HadronAna->SetNMixedEvents(10); // Number of events to be mixed with + break; + case 7: // syst study around case 1 + HadronAna->SetDistPrimLim(0.7); // Max Tof-Sts trans distance for primaries + HadronAna->SetDistPrimLim2(0.3); // Max Sts-Sts trans distance for primaries + HadronAna->SetDistSecLim2(0.3); // Max Sts-Sts trans distance from TOF direction for secondaries + HadronAna->SetD0ProtLim(0.4); // Min impact parameter for secondary proton + HadronAna->SetOpAngMin(0.1); // Min opening angle for accepting pair + HadronAna->SetDCALim(0.1); // Max DCA for accepting pair + HadronAna->SetVLenMin(5.); // Min Lambda flight path length for accepting pair + HadronAna->SetVLenMax(25.); // Max Lambda flight path length for accepting pair + HadronAna->SetDistTRD(10.); // max accepted distance of Trd Hit from STS-TOF line + HadronAna->SetTRDHmulMin(0.); // min associated Trd Hits to Track candidates + HadronAna->SetNMixedEvents(10); // Number of events to be mixed with + break; + case 8: // syst study around case 1 + HadronAna->SetDistPrimLim(0.6); // Max Tof-Sts trans distance for primaries + HadronAna->SetDistPrimLim2(0.3); // Max Sts-Sts trans distance for primaries + HadronAna->SetDistSecLim2(0.3); // Max Sts-Sts trans distance from TOF direction for secondaries + HadronAna->SetD0ProtLim(0.4); // Min impact parameter for secondary proton + HadronAna->SetOpAngMin(0.1); // Min opening angle for accepting pair + HadronAna->SetDCALim(0.1); // Max DCA for accepting pair + HadronAna->SetVLenMin(5.); // Min Lambda flight path length for accepting pair + HadronAna->SetVLenMax(25.); // Max Lambda flight path length for accepting pair + HadronAna->SetDistTRD(10.); // max accepted distance of Trd Hit from STS-TOF line + HadronAna->SetTRDHmulMin(0.); // min associated Trd Hits to Track candidates + HadronAna->SetNMixedEvents(10); // Number of events to be mixed with + break; + + case 10: // "0" with TRD Mul 1 + HadronAna->SetDistPrimLim(1.2); // Max Tof-Sts trans distance for primaries + HadronAna->SetDistPrimLim2(0.3); // Max Sts-Sts trans distance for primaries + HadronAna->SetDistSecLim2(0.3); // Max Sts-Sts trans distance from TOF direction for secondaries + HadronAna->SetD0ProtLim(0.5); // Min impact parameter for secondary proton + HadronAna->SetOpAngMin(0.1); // Min opening angle for accepting pair + HadronAna->SetDCALim(0.1); // Max DCA for accepting pair + HadronAna->SetVLenMin(5.); // Min Lambda flight path length for accepting pair + HadronAna->SetVLenMax(25.); // Max Lambda flight path length for accepting pair + HadronAna->SetDistTRD(10.); // max accepted distance of Trd Hit from STS-TOF line + HadronAna->SetTRDHmulMin(1.); // min associated Trd Hits to Track candidates + HadronAna->SetNMixedEvents(10); // Number of events to be mixed with + break; + case 20: // "0" with TRD Mul 2 + HadronAna->SetDistPrimLim(1.2); // Max Tof-Sts trans distance for primaries + HadronAna->SetDistPrimLim2(0.3); // Max Sts-Sts trans distance for primaries + HadronAna->SetDistSecLim2(0.3); // Max Sts-Sts trans distance from TOF direction for secondaries + HadronAna->SetD0ProtLim(0.5); // Min impact parameter for secondary proton + HadronAna->SetOpAngMin(0.1); // Min opening angle for accepting pair + HadronAna->SetDCALim(0.1); // Max DCA for accepting pair + HadronAna->SetVLenMin(5.); // Min Lambda flight path length for accepting pair + HadronAna->SetVLenMax(25.); // Max Lambda flight path length for accepting pair + HadronAna->SetDistTRD(10.); // max accepted distance of Trd Hit from STS-TOF line + HadronAna->SetTRDHmulMin(2.); // min associated Trd Hits to Track candidates + HadronAna->SetNMixedEvents(10); // Number of events to be mixed with + break; + default: + cout << "Cut value set " <<parSet<<" not existing, stop macro "<< endl; + return; } fRun->AddTask(HadronAna); @@ -88,11 +198,10 @@ void mcbm_Ana(Int_t nEvents = 1000, fRun->Run(0, nEvents); // ------------------------------------------------------------------------ - // save histos to file - fHist->Write(); +// save histos to file + fHist->Write(); - gROOT->LoadMacro("save_hst.C"); - TString FSave = Form( - "save_hst(\"data/status_%s_%s.%05d.hst.root\")", setup, cSys.Data(), iRun); - //gInterpreter->ProcessLine(FSave.Data()); + gROOT->LoadMacro("save_hst.C"); + TString FSave=Form("save_hst(\"data/status_%s_%s.%05d.hst.root\")",setup,cSys.Data(),iRun); + //gInterpreter->ProcessLine(FSave.Data()); } diff --git a/macro/mcbm/mcbm_digi_nh.C b/macro/mcbm/mcbm_digi_nh.C new file mode 100755 index 0000000000000000000000000000000000000000..c9d29ec2204ef3dd9b420fc5339c5890521fbf2f --- /dev/null +++ b/macro/mcbm/mcbm_digi_nh.C @@ -0,0 +1,128 @@ +/** Macro for detector response simulation (digitisation) + ** + ** The detector response produces a raw data file from the transport + ** data, which serves as input for reconstruction. Raw data will + ** be delivered in time-slice format (one tree entry per time-slice). + ** + ** The first five arguments to the macro call represent the minimal + ** information to be passed to the digitization run. In addition, + ** the mode (time-based as default, or event-by-event) can be specified. + ** By default, already existing output files will not be overwritten + ** to prevent accidental data loss. + ** + ** If the time-slice length is negative, all data will be in one + ** time-slice. + ** + ** For the file names, the following conventions are applied: + ** Input file: [dataSet].tra.root + ** Parameter file: [dataSet].par.root + ** Output file: [dataSet].raw.root + ** If different names are wanted, they have to be specified + ** explicitly in the macro. + ** + ** For further options to modify the run settings, consult + ** the documentation of the CbmDigitization class. + ** + ** @author Volker Friese <v.friese@gsi.de> + ** @date 8 June 2018 + **/ + + +void mcbm_digi_nh( + Int_t nEvents = 100, // Number of events to process + TString RunId = "test", + TString InDir = "./data/", + TString OutDir = "./data/", + TString setup = "mcbm_beam_2021_03", + Bool_t eventMode = kFALSE, // Event-by-event mode + Double_t eventRate = 1.e5, // Interaction rate [1/s] + Double_t timeSliceLength = 1.e4 // Length of time-slice [ns] +) +{ + + // --- Logger settings ---------------------------------------------------- + FairLogger::GetLogger()->SetLogScreenLevel("INFO"); + FairLogger::GetLogger()->SetLogVerbosityLevel("VERYHIGH"); + // ------------------------------------------------------------------------ + + + // ----- Allow overwriting of output file ----------------------------- + Bool_t overwrite = kTRUE; + // ------------------------------------------------------------------------ + + + // ----- File names --------------------------------------------------- + TString inFile = InDir + "/" + RunId + ".tra.root"; + TString parFile = OutDir + "/" + RunId + ".par.root"; + TString outFile = OutDir + "/" + RunId + Form(".%2.1e",eventRate) + ".raw.root"; + TString monFile = OutDir + "/" + RunId + ".raw.moni.root"; + if ( eventMode ) { + outFile = OutDir + "/" + RunId + ".event.raw.root"; + monFile = OutDir + "/" + RunId + ".event.raw.moni.root"; + } + + + // ----- Timer -------------------------------------------------------- + TStopwatch timer; + timer.Start(); + // ------------------------------------------------------------------------ + + + // ----- Digitization run --------------------------------------------- + CbmDigitization run; + + run.AddInput(inFile, eventRate); + run.SetOutputFile(outFile, overwrite); + run.SetMonitorFile(monFile); + run.SetParameterRootFile(parFile); + run.SetTimeSliceLength(timeSliceLength); + run.SetEventMode(eventMode); + run.SetProduceNoise(kFALSE); + run.SetCreateMatches(kFALSE); + + //run.Deactivate(ECbmModuleId::kSts); + run.Deactivate(ECbmModuleId::kRich); + run.Deactivate(ECbmModuleId::kTrd); // deactivate for time based mode ! + run.Deactivate(ECbmModuleId::kMuch); + run.Deactivate(ECbmModuleId::kPsd); + + run.Run(nEvents); + // ------------------------------------------------------------------------ + + + // ----- Finish ------------------------------------------------------- + timer.Stop(); + Double_t rtime = timer.RealTime(); + Double_t ctime = timer.CpuTime(); + std::cout << 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 << std::endl; + // ------------------------------------------------------------------------ + + + // ----- CTest resource monitoring ------------------------------------ + FairSystemInfo sysInfo; + Float_t maxMemory=sysInfo.GetMaxMemory(); + std::cout << "<DartMeasurement name=\"MaxMemory\" type=\"numeric/double\">"; + std::cout << maxMemory; + std::cout << "</DartMeasurement>" << std::endl; + std::cout << "<DartMeasurement name=\"WallTime\" type=\"numeric/double\">"; + std::cout << rtime; + 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; + // ------------------------------------------------------------------------ + + + // ----- Finish ------------------------------------------------------- + std::cout << " Test passed" << std::endl; + std::cout << " All ok " << std::endl; + // ------------------------------------------------------------------------ + + +} // End of macro diff --git a/macro/mcbm/mcbm_display_event.C b/macro/mcbm/mcbm_display_event.C index 5dcb23e365f28bab6cf1c2fce5892d520614a359..12222749b0c1b1b89a5d93bbf2d1cccb6cf8eaab 100644 --- a/macro/mcbm/mcbm_display_event.C +++ b/macro/mcbm/mcbm_display_event.C @@ -13,15 +13,18 @@ // -------------------------------------------------------------------------- -void mcbm_display_event(Int_t nEvents = 3, - TString dataset = "data/test", - const char* setupName = "sis18_mcbm_25deg_long") { +void mcbm_display_event( + Int_t nEvents = 3, + TString dataset ="data/test", + const char* setupName = "sis18_mcbm_25deg_long" +) +{ // ======================================================================== // Adjust this part according to your requirements // --- Logger settings ---------------------------------------------------- - // TString logLevel = "INFO"; - TString logLevel = "DEBUG"; + TString logLevel = "INFO"; + //TString logLevel = "DEBUG"; // TString logVerbosity = "LOW"; TString logVerbosity = "MEDIUM"; // ------------------------------------------------------------------------ @@ -34,19 +37,20 @@ void mcbm_display_event(Int_t nEvents = 3, // ----- File names --------------------------------------------------- + TString inFile = dataset + ".tra.root"; TString rawFile = dataset + ".event.raw.root"; TString parFile = dataset + ".par.root"; TString recFile = dataset + ".dis.root"; // ------------------------------------------------------------------------ - Int_t iTofCluMode = 1; - Int_t iTrackMode = 1; + Int_t iTofCluMode=1; + Int_t iTrackMode=1; // ----- Load the geometry setup ------------------------------------- std::cout << std::endl; - TString setupFile = srcDir + "/geometry/setup/setup_" + setupName + ".C"; + TString setupFile = srcDir + "/geometry/setup/setup_" + setupName + ".C"; TString setupFunct = "setup_"; - setupFunct = setupFunct + setupName + "()"; + setupFunct = setupFunct + setupName + "()"; std::cout << "-I- " << myName << ": Loading macro " << setupFile << std::endl; gROOT->LoadMacro(setupFile); gROOT->ProcessLine(setupFunct); @@ -58,30 +62,27 @@ void mcbm_display_event(Int_t nEvents = 3, // ----- 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(); + TList *parFileList = new TList(); TString geoTag; // - TRD digitisation parameters - if (setup->GetGeoTag(kTrd, geoTag)) { - TObjString* trdFile = - new TObjString(srcDir + "/parameters/trd/trd_" + geoTag + ".digi.par"); - parFileList->Add(trdFile); + if ( setup->GetGeoTag(kTrd, geoTag) ) { + TObjString* trdFile = new TObjString(srcDir + "/parameters/trd/trd_" + geoTag + ".digi.par"); + parFileList->Add(trdFile); std::cout << "-I- " << myName << ": Using parameter file " - << trdFile->GetString() << std::endl; + << trdFile->GetString() << std::endl; } // - TOF digitisation parameters - if (setup->GetGeoTag(kTof, geoTag)) { - TObjString* tofFile = - new TObjString(srcDir + "/parameters/tof/tof_" + geoTag + ".digi.par"); - parFileList->Add(tofFile); + if ( setup->GetGeoTag(kTof, geoTag) ) { + TObjString* tofFile = new TObjString(srcDir + "/parameters/tof/tof_" + geoTag + ".digi.par"); + parFileList->Add(tofFile); std::cout << "-I- " << myName << ": Using parameter file " - << tofFile->GetString() << std::endl; - TObjString* tofBdfFile = - new TObjString(srcDir + "/parameters/tof/tof_" + geoTag + ".digibdf.par"); - parFileList->Add(tofBdfFile); + << tofFile->GetString() << std::endl; + 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; + << tofBdfFile->GetString() << std::endl; } // ------------------------------------------------------------------------ @@ -102,17 +103,17 @@ void mcbm_display_event(Int_t nEvents = 3, // ----- Input file --------------------------------------------------- std::cout << std::endl; - std::cout << "-I- " << myName << ": Using input file " << rawFile - << std::endl; + std::cout << "-I- " << myName << ": Using input file " << rawFile << std::endl; // ------------------------------------------------------------------------ // ----- FairRunAna --------------------------------------------------- - FairRunAna* run = new FairRunAna(); - run->SetInputFile(rawFile); + FairRunAna *run = new FairRunAna(); + run->SetInputFile(inFile); + run->AddFriend(rawFile); run->SetOutputFile(recFile); run->SetGenerateRunInfo(kTRUE); - Bool_t hasFairMonitor = kFALSE; //Has_Fair_Monitor(); + Bool_t hasFairMonitor = kFALSE; //Has_Fair_Monitor(); if (hasFairMonitor) FairMonitor::GetMonitor()->EnableMonitor(kTRUE); // ------------------------------------------------------------------------ @@ -124,138 +125,139 @@ void mcbm_display_event(Int_t nEvents = 3, // ----- Local reconstruction in MVD ---------------------------------- - if (setup->IsActive(kMvd)) { + if ( setup->IsActive(kMvd) ) { CbmMvdClusterfinder* mvdCluster = - new CbmMvdClusterfinder("MVD Cluster Finder", 0, 0); + new CbmMvdClusterfinder("MVD Cluster Finder", 0, 0); run->AddTask(mvdCluster); - std::cout << "-I- " << myName << ": Added task " << mvdCluster->GetName() - << std::endl; + std::cout << "-I- " << myName << ": Added task " + << mvdCluster->GetName() << std::endl; CbmMvdHitfinder* mvdHit = new CbmMvdHitfinder("MVD Hit Finder", 0, 0); mvdHit->UseClusterfinder(kTRUE); run->AddTask(mvdHit); - std::cout << "-I- " << myName << ": Added task " << mvdHit->GetName() - << std::endl; + std::cout << "-I- " << myName << ": Added task " + << mvdHit->GetName() << std::endl; + } // ------------------------------------------------------------------------ // ----- Local reconstruction in STS ---------------------------------- - if (setup->IsActive(kSts)) { + if ( setup->IsActive(kSts) ) { FairTask* stsReco = new CbmStsReco(); run->AddTask(stsReco); std::cout << "-I- : Added task " << stsReco->GetName() << std::endl; + } // ------------------------------------------------------------------------ // ----- Local reconstruction in MUCH --------------------------------- - if (0) { // setup->IsActive(kMuch) ) { - - // --- Parameter file name - TString geoTag; - setup->GetGeoTag(kMuch, geoTag); - Int_t muchFlag = 0; - if (geoTag.Contains("mcbm")) muchFlag = 1; - - TString parFile = gSystem->Getenv("VMCWORKDIR"); - - if (muchFlag) { - std::cout << geoTag << std::endl; - parFile = - parFile + "/parameters/much/much_" + geoTag + "_digi_sector.root"; - std::cout << "Using parameter file " << parFile << std::endl; - } else { - std::cout << geoTag(0, 4) << std::endl; - parFile = - parFile + "/parameters/much/much_" + geoTag(0, 4) + "_digi_sector.root"; - std::cout << "Using parameter file " << parFile << std::endl; - } - + if ( 0 ) { // setup->IsActive(kMuch) ) { + + // --- Parameter file name + TString geoTag; + setup->GetGeoTag(kMuch, geoTag); + Int_t muchFlag=0; + if (geoTag.Contains("mcbm")) muchFlag=1; + + TString parFile = gSystem->Getenv("VMCWORKDIR"); + + if (muchFlag) { + std::cout << geoTag << std::endl; + parFile = parFile + "/parameters/much/much_" + geoTag + + "_digi_sector.root"; + std::cout << "Using parameter file " << parFile << std::endl; + } else { + std::cout << geoTag(0,4) << std::endl; + parFile = parFile + "/parameters/much/much_" + geoTag(0,4) + + "_digi_sector.root"; + std::cout << "Using parameter file " << parFile << std::endl; + } + + + // --- Hit finder for GEMs + FairTask* muchHitGem = new CbmMuchFindHitsGem(parFile.Data(),muchFlag); + run->AddTask(muchHitGem); + std::cout << "-I- " << myName << ": Added task " + << muchHitGem->GetName() << FairLogger::endl; - // --- Hit finder for GEMs - FairTask* muchHitGem = new CbmMuchFindHitsGem(parFile.Data(), muchFlag); - run->AddTask(muchHitGem); - std::cout << "-I- " << myName << ": Added task " << muchHitGem->GetName() - << FairLogger::endl; } // ------------------------------------------------------------------------ // ----- Local reconstruction in TRD ---------------------------------- - if (0) { //setup->IsActive(kTrd) ) { + if ( 0 ) { //setup->IsActive(kTrd) ) { - Double_t triggerThreshold = 0.5e-6; // SIS100 - Bool_t triangularPads = false; // Bucharest triangular pad-plane layout + Double_t triggerThreshold = 0.5e-6; // SIS100 + Bool_t triangularPads = false; // Bucharest triangular pad-plane layout CbmTrdClusterFinder* trdCluster = new CbmTrdClusterFinder(); trdCluster->SetNeighbourEnable(true); trdCluster->SetMinimumChargeTH(triggerThreshold); trdCluster->SetNeighbourEnable(false); trdCluster->SetRowMerger(true); run->AddTask(trdCluster); - std::cout << "-I- " << myName << ": Added task " << trdCluster->GetName() - << std::endl; + std::cout << "-I- " << myName << ": Added task " + << trdCluster->GetName() << std::endl; CbmTrdHitProducer* trdHit = new CbmTrdHitProducer(); run->AddTask(trdHit); - std::cout << "-I- " << myName << ": Added task " << trdHit->GetName() - << std::endl; + std::cout << "-I- " << myName << ": Added task " + << trdHit->GetName() << std::endl; + } // ------------------------------------------------------------------------ // ----- Local reconstruction in TOF ---------------------------------- - if (setup->IsActive(kTof)) { - switch (iTofCluMode) { - case 1: { - CbmTofEventClusterizer* tofCluster = - new CbmTofEventClusterizer("TOF Event Clusterizer", 0, 1); - Int_t calMode = 93; - Int_t calSel = 0; - Int_t calSm = 0; - Int_t RefSel = 0; - Double_t dDeadtime = 50.; - - tofCluster->SetCalMode(calMode); - tofCluster->SetCalSel(calSel); - tofCluster->SetCaldXdYMax(3.); // geometrical matching window in cm - tofCluster->SetCalCluMulMax( - 5.); // Max Counter Cluster Multiplicity for filling calib histos - tofCluster->SetCalRpc(calSm); // select detector for calibration update - tofCluster->SetTRefId( - RefSel); // reference trigger for offset calculation - tofCluster->SetTotMax(20.); // Tot upper limit for walk corection - tofCluster->SetTotMin( - 0.01); //(12000.); // Tot lower limit for walk correction - tofCluster->SetTotPreRange( - 5.); // effective lower Tot limit in ns from peak position - tofCluster->SetTotMean(5.); // Tot calibration target value in ns - tofCluster->SetMaxTimeDist(1.0); // default cluster range in ns - tofCluster->SetDelTofMax( - 5.); // acceptance range for cluster distance in ns (!) - tofCluster->SetSel2MulMax(3); // limit Multiplicity in 2nd selector - tofCluster->SetChannelDeadtime(dDeadtime); // artificial deadtime in ns - tofCluster->SetEnableAvWalk(kFALSE); - //tofCluster->SetEnableMatchPosScaling(kFALSE); // turn off projection to nominal target - tofCluster->SetYFitMin(1.E4); - tofCluster->SetToDAv(0.04); - tofCluster->SetIdMode(1); // calibrate on module level - tofCluster->SetTRefDifMax(2.0); // in ns - tofCluster->PosYMaxScal(0.75); //in % of length - run->AddTask(tofCluster); - std::cout << "-I- " << myName << ": Added task " - << tofCluster->GetName() << std::endl; - } break; - default: { - CbmTofSimpClusterizer* tofCluster = - new CbmTofSimpClusterizer("TOF Simple Clusterizer", 0); - tofCluster->SetOutputBranchPersistent("TofHit", kTRUE); - tofCluster->SetOutputBranchPersistent("TofDigiMatch", kTRUE); - run->AddTask(tofCluster); - std::cout << "-I- " << myName << ": Added task " - << tofCluster->GetName() << std::endl; + if ( setup->IsActive(kTof) ) { + switch(iTofCluMode) { + case 1: + { + CbmTofEventClusterizer* tofCluster = new CbmTofEventClusterizer("TOF Event Clusterizer",0,1); + Int_t calMode=93; + Int_t calSel=0; + Int_t calSm=0; + Int_t RefSel=0; + Double_t dDeadtime=50.; + + tofCluster->SetCalMode(calMode); + tofCluster->SetCalSel(calSel); + tofCluster->SetCaldXdYMax(3.); // geometrical matching window in cm + tofCluster->SetCalCluMulMax(5.); // Max Counter Cluster Multiplicity for filling calib histos + tofCluster->SetCalRpc(calSm); // select detector for calibration update + tofCluster->SetTRefId(RefSel); // reference trigger for offset calculation + tofCluster->SetTotMax(20.); // Tot upper limit for walk corection + tofCluster->SetTotMin(0.01); //(12000.); // Tot lower limit for walk correction + tofCluster->SetTotPreRange(5.); // effective lower Tot limit in ns from peak position + tofCluster->SetTotMean(5.); // Tot calibration target value in ns + tofCluster->SetMaxTimeDist(1.0); // default cluster range in ns + tofCluster->SetDelTofMax(5.); // acceptance range for cluster distance in ns (!) + tofCluster->SetSel2MulMax(3); // limit Multiplicity in 2nd selector + tofCluster->SetChannelDeadtime(dDeadtime); // artificial deadtime in ns + tofCluster->SetEnableAvWalk(kFALSE); + //tofCluster->SetEnableMatchPosScaling(kFALSE); // turn off projection to nominal target + tofCluster->SetYFitMin(1.E4); + tofCluster->SetToDAv(0.04); + tofCluster->SetIdMode(1); // calibrate on module level + tofCluster->SetTRefDifMax(2.0); // in ns + tofCluster->PosYMaxScal(0.75); //in % of length + run->AddTask(tofCluster); + std::cout << "-I- " << myName << ": Added task " + << tofCluster->GetName() << std::endl; + } + break; + default: + { + CbmTofSimpClusterizer* tofCluster + = new CbmTofSimpClusterizer("TOF Simple Clusterizer", 0); + tofCluster->SetOutputBranchPersistent("TofHit", kTRUE); + tofCluster->SetOutputBranchPersistent("TofDigiMatch", kTRUE); + run->AddTask(tofCluster); + std::cout << "-I- " << myName << ": Added task " + << tofCluster->GetName() << std::endl; } } } @@ -265,111 +267,108 @@ void mcbm_display_event(Int_t nEvents = 3, // ----- Track reconstruction ------------------------------------------ Double_t beamWidthX = 0.1; Double_t beamWidthY = 0.1; - switch (iTrackMode) { - case 1: { - Int_t iGenCor = 1; - Double_t dScalFac = 1.; - Double_t dChi2Lim2 = 3.5; - TString cTrkFile = Form("%s_tofFindTracks.hst.root", "MC"); - Int_t iTrackingSetup = 1; - - CbmTofTrackFinder* tofTrackFinder = new CbmTofTrackFinderNN(); - tofTrackFinder->SetMaxTofTimeDifference(0.2); // in ns/cm + switch(iTrackMode) { + case 1: + { + Int_t iGenCor=1; + Double_t dScalFac=1.; + Double_t dChi2Lim2=3.5; + TString cTrkFile=Form("%s_tofFindTracks.hst.root","MC"); + Int_t iTrackingSetup=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->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"); + CbmTofFindTracks* tofFindTracks = new CbmTofFindTracks("TOF Track Finder"); tofFindTracks->UseFinder(tofTrackFinder); tofFindTracks->UseFitter(tofTrackFitter); - tofFindTracks->SetCorMode( - iGenCor); // valid options: 0,1,2,3,4,5,6, 10 - 19 - tofFindTracks->SetTtTarg( - 0.041); // target value for inverse velocity, > 0.033 ns/cm! + tofFindTracks->SetCorMode(iGenCor); // valid options: 0,1,2,3,4,5,6, 10 - 19 + 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 = 39; - iNReqStations = 3; - tofFindTracks->SetStation(0, 5, 0, 0); - tofFindTracks->SetStation(1, 0, 4, 0); - tofFindTracks->SetStation(2, 0, 3, 0); - tofFindTracks->SetStation(3, 0, 4, 1); - tofFindTracks->SetStation(4, 0, 3, 1); - 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); - tofFindTracks->SetStation(14, 6, 0, 0); - tofFindTracks->SetStation(15, 6, 0, 1); - tofFindTracks->SetStation(16, 8, 0, 0); - tofFindTracks->SetStation(17, 8, 0, 1); - tofFindTracks->SetStation(18, 8, 0, 2); - tofFindTracks->SetStation(19, 8, 0, 3); - tofFindTracks->SetStation(20, 8, 0, 4); - tofFindTracks->SetStation(21, 8, 0, 5); - tofFindTracks->SetStation(22, 8, 0, 6); - tofFindTracks->SetStation(23, 8, 0, 7); - tofFindTracks->SetStation(24, 0, 2, 2); - tofFindTracks->SetStation(25, 0, 1, 2); - tofFindTracks->SetStation(26, 0, 0, 2); - tofFindTracks->SetStation(27, 0, 2, 1); - tofFindTracks->SetStation(28, 0, 1, 1); - tofFindTracks->SetStation(29, 0, 0, 1); - tofFindTracks->SetStation(30, 0, 2, 3); - tofFindTracks->SetStation(31, 0, 1, 3); - tofFindTracks->SetStation(32, 0, 0, 3); - tofFindTracks->SetStation(33, 0, 2, 0); - tofFindTracks->SetStation(34, 0, 1, 0); - tofFindTracks->SetStation(35, 0, 0, 0); - tofFindTracks->SetStation(36, 0, 2, 4); - tofFindTracks->SetStation(37, 0, 1, 4); - tofFindTracks->SetStation(38, 0, 0, 4); - break; + 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=39; + iNReqStations=3; + tofFindTracks->SetStation(0, 5, 0, 0); + tofFindTracks->SetStation(1, 0, 4, 0); + tofFindTracks->SetStation(2, 0, 3, 0); + tofFindTracks->SetStation(3, 0, 4, 1); + tofFindTracks->SetStation(4, 0, 3, 1); + 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); + tofFindTracks->SetStation(14, 6, 0, 0); + tofFindTracks->SetStation(15, 6, 0, 1); + tofFindTracks->SetStation(16, 8, 0, 0); + tofFindTracks->SetStation(17, 8, 0, 1); + tofFindTracks->SetStation(18, 8, 0, 2); + tofFindTracks->SetStation(19, 8, 0, 3); + tofFindTracks->SetStation(20, 8, 0, 4); + tofFindTracks->SetStation(21, 8, 0, 5); + tofFindTracks->SetStation(22, 8, 0, 6); + tofFindTracks->SetStation(23, 8, 0, 7); + tofFindTracks->SetStation(24, 0, 2, 2); + tofFindTracks->SetStation(25, 0, 1, 2); + tofFindTracks->SetStation(26, 0, 0, 2); + tofFindTracks->SetStation(27, 0, 2, 1); + tofFindTracks->SetStation(28, 0, 1, 1); + tofFindTracks->SetStation(29, 0, 0, 1); + tofFindTracks->SetStation(30, 0, 2, 3); + tofFindTracks->SetStation(31, 0, 1, 3); + tofFindTracks->SetStation(32, 0, 0, 3); + tofFindTracks->SetStation(33, 0, 2, 0); + tofFindTracks->SetStation(34, 0, 1, 0); + tofFindTracks->SetStation(35, 0, 0, 0); + tofFindTracks->SetStation(36, 0, 2, 4); + tofFindTracks->SetStation(37, 0, 1, 4); + tofFindTracks->SetStation(38, 0, 0, 4); + break; } tofFindTracks->SetMinNofHits(iMinNofHits); tofFindTracks->SetNStations(iNStations); tofFindTracks->SetNReqStations(iNReqStations); tofFindTracks->PrintSetup(); run->AddTask(tofFindTracks); - } break; - default: { - CbmBinnedTrackerTask* trackerTask = - new CbmBinnedTrackerTask(kTRUE, beamWidthX, beamWidthY); + } + break; + default: + { + CbmBinnedTrackerTask* trackerTask = new CbmBinnedTrackerTask(kTRUE, + beamWidthX, + beamWidthY); trackerTask->SetUse(kTrd, kFALSE); run->AddTask(trackerTask); } @@ -380,8 +379,8 @@ void mcbm_display_event(Int_t nEvents = 3, // ----- 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(); + FairRuntimeDb* rtdb = run->GetRuntimeDb(); + FairParRootFileIo* parIo1 = new FairParRootFileIo(); FairParAsciiFileIo* parIo2 = new FairParAsciiFileIo(); parIo1->open(parFile.Data(), "UPDATE"); parIo2->open(parFileList, "in"); @@ -416,25 +415,17 @@ void mcbm_display_event(Int_t nEvents = 3, */ // ------------------------------------------------------------------------ - FairEventManager* fMan = new FairEventManager(); - FairMCTracks* Track = new FairMCTracks("Monte-Carlo Tracks"); - - FairMCPointDraw* MvdPoint = - new FairMCPointDraw("MvdPoint", kBlack, kFullSquare); - FairMCPointDraw* StsPoint = - new FairMCPointDraw("StsPoint", kGreen, kFullSquare); - FairMCPointDraw* MuchPoint = - new FairMCPointDraw("MuchPoint", kOrange, kFullSquare); - FairMCPointDraw* RichPoint = - new FairMCPointDraw("RichPoint", kGreen, kFullSquare); - FairMCPointDraw* TrdPoint = - new FairMCPointDraw("TrdPoint", kBlue, kFullSquare); - FairMCPointDraw* TofPoint = - new FairMCPointDraw("TofPoint", kRed, kFullSquare); - FairMCPointDraw* EcalPoint = - new FairMCPointDraw("EcalPoint", kYellow, kFullSquare); - FairMCPointDraw* RefPlanePoint = - new FairMCPointDraw("RefPlanePoint", kPink, kFullSquare); + FairEventManager *fMan = new FairEventManager(); + FairMCTracks *Track = new FairMCTracks ("Monte-Carlo Tracks"); + + FairMCPointDraw *MvdPoint = new FairMCPointDraw ("MvdPoint", kBlack, kFullSquare); + FairMCPointDraw *StsPoint = new FairMCPointDraw ("StsPoint", kGreen, kFullSquare); + FairMCPointDraw *MuchPoint = new FairMCPointDraw ("MuchPoint", kOrange, kFullSquare); + FairMCPointDraw *RichPoint = new FairMCPointDraw ("RichPoint", kGreen, kFullSquare); + FairMCPointDraw *TrdPoint = new FairMCPointDraw ("TrdPoint", kBlue, kFullSquare); + FairMCPointDraw *TofPoint = new FairMCPointDraw ("TofPoint", kRed, kFullSquare); + FairMCPointDraw *EcalPoint = new FairMCPointDraw ("EcalPoint", kYellow, kFullSquare); + FairMCPointDraw *RefPlanePoint = new FairMCPointDraw ("RefPlanePoint", kPink, kFullSquare); fMan->AddTask(Track); @@ -443,36 +434,33 @@ void mcbm_display_event(Int_t nEvents = 3, fMan->AddTask(MuchPoint); fMan->AddTask(RichPoint); fMan->AddTask(TrdPoint); - fMan->AddTask(TofPoint); - fMan->AddTask(EcalPoint); + fMan->AddTask(TofPoint); + fMan->AddTask(EcalPoint); fMan->AddTask(RefPlanePoint); - CbmPixelHitSetDraw* StsHits = - new CbmPixelHitSetDraw("StsHit", kRed, kOpenCircle); // kFullSquare); - fMan->AddTask(StsHits); - CbmPixelHitSetDraw* TrdHits = - new CbmPixelHitSetDraw("TrdHit", kRed, kOpenCircle); // kFullSquare); - fMan->AddTask(TrdHits); - CbmPixelHitSetDraw* TofHits = - new CbmPixelHitSetDraw("TofHit", kRed, kOpenCircle); // kFullSquare); - fMan->AddTask(TofHits); - CbmPixelHitSetDraw* TofUHits = - new CbmPixelHitSetDraw("TofUHit", kRed, kOpenCross); - fMan->AddTask(TofUHits); - CbmEvDisTracks* Tracks = new CbmEvDisTracks("Tof Tracks", 1); + CbmPixelHitSetDraw *StsHits = new CbmPixelHitSetDraw ("StsHit", kRed, kOpenCircle );// kFullSquare); + fMan->AddTask(StsHits); + CbmPixelHitSetDraw *TrdHits = new CbmPixelHitSetDraw ("TrdHit", kRed, kOpenCircle );// kFullSquare); + fMan->AddTask(TrdHits); + CbmPixelHitSetDraw *TofHits = new CbmPixelHitSetDraw ("TofHit", kRed, kOpenCircle );// kFullSquare); + fMan->AddTask(TofHits); + CbmPixelHitSetDraw *TofUHits = new CbmPixelHitSetDraw ("TofUHit", kRed, kOpenCross ); + fMan->AddTask(TofUHits); + CbmEvDisTracks *Tracks = new CbmEvDisTracks ("Tof Tracks",1); Tracks->SetVerbose(4); fMan->AddTask(Tracks); - fMan->Init(1, 7, 10000); // make MVD visible by default + fMan->Init(1,7,10000); // make MVD visible by default - cout << "gEve " << gEve << endl; - gEve->GetDefaultGLViewer()->SetClearColor(kYellow - 10); - { // from readCurrentCamera(const char* fname) - TGLCamera& c = gEve->GetDefaultGLViewer()->CurrentCamera(); - const char* fname = "Cam.sav"; - TFile* f = TFile::Open(fname, "READ"); - if (!f) return; + cout << "gEve "<< gEve << endl; + gEve->GetDefaultGLViewer()->SetClearColor(kYellow-10); + { // 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(); @@ -488,7 +476,7 @@ void mcbm_display_event(Int_t nEvents = 3, std::cout << "Output file is " << recFile << std::endl; std::cout << "Parameter file is " << parFile << std::endl; std::cout << "Real time " << rtime << " s, CPU time " << ctime << " s" - << std::endl; + << std::endl; std::cout << std::endl; std::cout << " Test passed" << std::endl; std::cout << " All ok " << std::endl; @@ -496,16 +484,16 @@ void mcbm_display_event(Int_t nEvents = 3, // ----- Resource monitoring ------------------------------------------ - if (hasFairMonitor) { // FairRoot Version >= 15.11 + if ( hasFairMonitor ) { // FairRoot Version >= 15.11 // Extract the maximal used memory an add is as Dart measurement // This line is filtered by CTest and the value send to CDash FairSystemInfo sysInfo; - Float_t maxMemory = sysInfo.GetMaxMemory(); + 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; + Float_t cpuUsage=ctime/rtime; std::cout << "<DartMeasurement name=\"CpuLoad\" type=\"numeric/double\">"; std::cout << cpuUsage; std::cout << "</DartMeasurement>" << std::endl; diff --git a/macro/mcbm/mcbm_mc_nh.C b/macro/mcbm/mcbm_mc_nh.C new file mode 100755 index 0000000000000000000000000000000000000000..ddeef148934656ed95e57131b972e865662dd0fa --- /dev/null +++ b/macro/mcbm/mcbm_mc_nh.C @@ -0,0 +1,393 @@ +// -------------------------------------------------------------------------- +// +// Macro for standard transport simulation using UrQMD input and GEANT3 +// Standard CBM setup with MVD, STS, RICH, TRD, TOF and ECAL +// +// V. Friese 22/02/2007 +// +// 2017-03-30 - DE - add mcbm_sim.C to CTests +// 2014-06-30 - DE - available setups from geometry/setup: +// 2014-06-30 - DE - sis100_hadron +// 2014-06-30 - DE - sis100_electron +// 2014-06-30 - DE - sis100_muon +// 2014-06-30 - DE - sis300_electron +// 2014-06-30 - DE - sis300_muon +// +// -------------------------------------------------------------------------- +void mcbm_mc_nh(Int_t nEvents = 2, Int_t iMode=3, + TString cSys="lam", + TString cEbeam="2.5gev", + TString cCentr="-", + Int_t iRun=0, + const char* setupName = "mcbm_beam_2021_04", + //const char* setupName = "sis18_mcbm_20deg_long", + const char* inputFile = "") +{ + + // ======================================================================== + // Adjust this part according to your requirements + +// available input files + TString defaultInputFile = "/input/urqmd.agag.1.65gev.centr.00001.root"; + // TString defaultInputFile = "/input/urqmd.agag.1.65gev.mbias.00001.root"; + // TString defaultInputFile = "/input/urqmd.auau.1.24gev.mbias.00001.root"; + // TString defaultInputFile = "/input/urqmd.niau.1.93gev.centr.00001.root"; + // TString defaultInputFile = "/input/urqmd.niau.1.93gev.mbias.00001.root"; + // TString defaultInputFile = "/input/urqmd.nini.1.93gev.centr.00001.root"; + // TString defaultInputFile = "/input/urqmd.nini.1.93gev.mbias.00001.root"; + // TString defaultInputFile = "/input/urqmd.pau.4.5gev.mbias.00001.root"; + + // ----- Environment -------------------------------------------------- + TString myName = "mcbm_mc"; // this macro's name for screen output + TString srcDir = gSystem->Getenv("VMCWORKDIR"); // top source directory + // ------------------------------------------------------------------------ + + // ----- In- and output file names ------------------------------------ + //TString inFile = srcDir + "/input/urqmd." + cSys + "." + cEbeam + "." + cCentr + "." + Form("%05d",iRun) + ".root"; + TString outDir = "data/"; + //TString outFile = outDir + setupName + "_" + cSys + "." + cEbeam + "." + cCentr + ".mc." + Form("%05d",iRun) + ".root"; + //TString parFile = outDir + setupName + "_" + cSys + "." + cEbeam + "." + cCentr + ".params." + Form("%05d",iRun) + ".root"; + TString outFile = outDir + setupName + "_" + cSys + "." + cEbeam + "." + cCentr + Form("%05d",iRun) + ".tra.root"; + TString parFile = outDir + setupName + "_" + cSys + "." + cEbeam + "." + cCentr + Form("%05d",iRun) + ".par.root"; + TString geoFile = outDir + setupName + "_geofile_full.root"; + if(iRun==0) iRun=1; // for event displays + TString inFile = "/lustre/nyx/cbm/prod/gen/urqmd/" + cSys + "/" + cEbeam + "/" + cCentr + "/urqmd." + cSys + "." + cEbeam + "." + cCentr + "." + Form("%05d",iRun) + ".root"; + // ------------------------------------------------------------------------ + + // --- Logger settings ---------------------------------------------------- + TString logLevel = "WARNING"; + //TString logLevel = "INFO"; + //TString logLevel = "DEBUG"; + TString logVerbosity = "MEDIUM"; + // ------------------------------------------------------------------------ + + // --- Define the target geometry ----------------------------------------- + // + // The target is not part of the setup, since one and the same setup can + // and will be used with different targets. + // The target is constructed as a tube in z direction with the specified + // diameter (in x and y) and thickness (in z). It will be placed at the + // specified position as daughter volume of the volume present there. It is + // in the responsibility of the user that no overlaps or extrusions are + // created by the placement of the target. + // + TString targetElement = "Gold"; + Double_t targetThickness = 0.1; // full thickness in cm + Double_t targetDiameter = 0.5; // diameter in cm + Double_t targetPosX = 0.; // target x position in global c.s. [cm] + Double_t targetPosY = 0.; // target y position in global c.s. [cm] + Double_t targetPosZ = 0.; // target z position in global c.s. [cm] + Double_t targetRotY = 0.; // target rotation angle around the y axis [deg] + Double_t beamRotY = 20.; // the primary beam is at 25 degrees to the left of the mCBM setup + // Double_t beamRotY = 25.; // the primary beam is at 25 degrees to the left of the mCBM setup + // ------------------------------------------------------------------------ + + // --- Define the creation of the primary vertex ------------------------ + // + // By default, the primary vertex point is sampled from a Gaussian + // distribution in both x and y with the specified beam profile width, + // and from a flat distribution in z over the extension of the target. + // By setting the respective flags to kFALSE, the primary vertex will always + // at the (0., 0.) in x and y and in the z centre of the target, respectively. + // + Bool_t smearVertexXY = kTRUE; + Bool_t smearVertexZ = kTRUE; + Double_t beamWidthX = 0.1; // Gaussian sigma of the beam profile in x [cm] + Double_t beamWidthY = 0.1; // Gaussian sigma of the beam profile in y [cm] + // ------------------------------------------------------------------------ + + + + // In general, the following parts need not be touched + // ======================================================================== + + // ----- Timer -------------------------------------------------------- + TStopwatch timer; + timer.Start(); + // ------------------------------------------------------------------------ + + + // ---- Debug option ------------------------------------------------- + gDebug = 0; + // ------------------------------------------------------------------------ + + + // ----- Remove old CTest runtime dependency file --------------------- + //TString depFile = Remove_CTest_Dependency_File(outDir, "mcbm_mc" , setupName); + // ------------------------------------------------------------------------ + + + // ----- Create simulation run ---------------------------------------- + FairRunSim* run = new FairRunSim(); + run->SetName("TGeant3"); // Transport engine + run->SetOutputFile(outFile); // Output file + run->SetGenerateRunInfo(kTRUE); // Create FairRunInfo file + // ------------------------------------------------------------------------ + + + // ----- Logger settings ---------------------------------------------- + FairLogger::GetLogger()->SetLogScreenLevel(logLevel.Data()); + FairLogger::GetLogger()->SetLogVerbosityLevel(logVerbosity.Data()); + // ------------------------------------------------------------------------ + + + // ----- Load the geometry setup ------------------------------------- + std::cout << std::endl; + TString setupFile = srcDir + "/geometry/setup/setup_" + setupName + ".C"; + TString setupFunct = "setup_"; + setupFunct = setupFunct + setupName + "()"; + std::cout << "-I- " << myName << ": Loading macro " << setupFile << std::endl; + gROOT->LoadMacro(setupFile); + gROOT->ProcessLine(setupFunct); + // ------------------------------------------------------------------------ + + + // ----- Input file --------------------------------------------------- + std::cout << std::endl; + TString defaultInput = srcDir + defaultInputFile; + if ( inFile.IsNull() ) { // Not defined in the macro explicitly + if ( strcmp(inputFile, "") == 0 ) { // not given as argument to the macro + inFile = defaultInput; + } + else inFile = inputFile; + } + std::cout << "-I- " << myName << ": Using input file " << inFile << std::endl; + // ------------------------------------------------------------------------ + + + // ----- Create media ------------------------------------------------- + std::cout << std::endl; + std::cout << "-I- " << myName << ": Setting media file" << std::endl; + run->SetMaterials("media.geo"); // Materials + // ------------------------------------------------------------------------ + + + // ----- Create and register modules ---------------------------------- + std::cout << std::endl; + TString macroName = gSystem->Getenv("VMCWORKDIR"); + macroName += "/macro/mcbm/modules/registerSetup.C"; + // macroName += "/macro/run/modules/registerSetup.C"; + std::cout << "Loading macro " << macroName << std::endl; + gROOT->LoadMacro(macroName); + gROOT->ProcessLine("registerSetup()"); + // ------------------------------------------------------------------------ + + + // ----- Create and register the target ------------------------------- + std::cout << std::endl; + std::cout << "-I- " << myName << ": Registering target" << std::endl; + CbmTarget* target = new CbmTarget(targetElement.Data(), + targetThickness, + targetDiameter); + target->SetPosition(targetPosX, targetPosY, targetPosZ); + target->SetRotation(targetRotY); + //target->Print(); + run->AddModule(target); + // ------------------------------------------------------------------------ + + + // ----- Create magnetic field ---------------------------------------- + std::cout << std::endl; + std::cout << "-I- " << myName << ": Registering magnetic field" << std::endl; + CbmFieldMap* magField = CbmSetup::Instance()->CreateFieldMap(); + if ( ! magField ) { + std::cout << "-E- run_sim_new: No valid field!"; + return; + } + run->SetField(magField); + // ------------------------------------------------------------------------ + + + // ----- Create PrimaryGenerator -------------------------------------- + FairPrimaryGenerator* primGen = new FairPrimaryGenerator(); + // --- Uniform distribution of event plane angle + primGen->SetEventPlane(0., 2. * TMath::Pi()); + // --- Get target parameters + /* + Double_t tX = 0.; + Double_t tY = 0.; + Double_t tZ = 0.; + Double_t tDz = 0.; + if ( target ) { + target->GetPosition(tX, tY, tZ); + tDz = target->GetThickness(); + } + primGen->SetTarget(tZ, tDz); + primGen->SetBeam(0., 0., beamWidthX, beamWidthY); + primGen->SmearGausVertexXY(smearVertexXY); + primGen->SmearVertexZ(smearVertexZ); + */ + // + // TODO: Currently, there is no guaranteed consistency of the beam profile + // and the transversal target dimension, i.e., that the sampled primary + // vertex falls into the target volume. This would require changes + // in the FairPrimaryGenerator class. + // ------------------------------------------------------------------------ + + // choose generator / source + if(iMode>0) + { + switch (iMode) { + case 1: + { // (pdg, mul,px, py, pz, vx,vy,vz) + FairParticleGenerator *fPartGen = new FairParticleGenerator (13, 1,0.0,-0.228, 1.5, 0.,0.,0.); //mu- + primGen->AddGenerator(fPartGen); + } + break; + + case 2: + { //(pdg,mul,px, py, pz, vx,vy,vz) + FairParticleGenerator *fPartGen= new FairParticleGenerator(2212, 1,0.0,-0.228, 1.5, 0.,0.,0.); //proton + primGen->AddGenerator(fPartGen); + } + break; + + case 3: + { //(pdg,mul,px, py, pz, vx,vy,vz) + Double_t pz; + sscanf(cEbeam,"%lfgev",&pz); + cout<<"simulate single lambda with pz = "<<pz<<endl; + FairParticleGenerator *fPartGen= new FairParticleGenerator(3122, 1,0.0,0., pz, 0.,0.,0.); //lambda + primGen->AddGenerator(fPartGen); + } + break; + case 4: + { + FairBoxGenerator *fPartGen= new FairBoxGenerator(3122, 1); + fPartGen->SetPtRange(0.,0.); + fPartGen->SetYRange(0.9,2.); + primGen->AddGenerator(fPartGen); + } + break; + + default: + ; + } + } + // Use the CbmUrqmdGenrator which calculates a reaction plane and + // rotate all particles accordingly + else { //if (iMode>0){ + // Use the CbmUnigenGenrator for the input + CbmUnigenGenerator* uniGen = new CbmUnigenGenerator(inFile); + //uniGen->SetEventPlane(0. , 360.); + primGen->AddGenerator(uniGen); + primGen->SetBeamAngle(beamRotY * TMath::Pi()/180.,0,0,0); // set direction of beam to 30 degrees + } + run->SetGenerator(primGen); + // ------------------------------------------------------------------------ + + // // ----- Create Electron gun as alternative ----------------------------- + // FairPrimaryGenerator* primGen = new FairPrimaryGenerator(); + // // Use the FairBoxGenerator which generates a soingle electron + // FairBoxGenerator *eminus = new FairBoxGenerator(); + // eminus->SetPDGType(11); + // eminus->SetMultiplicity(1000); + // // eminus->SetBoxXYZ(32.,-32.,32.,-32.,0.); // shoot at corner of diagonal modules + // // eminus->SetBoxXYZ(0., 0., 0., 0., 0.); // shoot at corner of diagonal modules + // // eminus->SetBoxXYZ(57.,-57., 0., 0.,0.); // shoot at corner of diagonal modules + // // eminus->SetBoxXYZ(-57.,-57., 57., 57.,0.); // shoot at corner of diagonal modules + // eminus->SetBoxXYZ(-180.,-15.,-150.,15.,0.); // shoot at corner of diagonal modules + // eminus->SetPRange(2.,2.); + // eminus->SetPhiRange(0.,360.); + // eminus->SetThetaRange(0.,0.); + // primGen->AddGenerator(eminus); + // + // // primGen->SetBeamAngle(30*TMath::Pi()/180.,0,0,0); // set direction of beam to 30 degrees + // + // fRun->SetGenerator(primGen); + // // ------------------------------------------------------------------------ + + + // Visualisation of trajectories (TGeoManager Only) + // Switch this on if you want to visualise tracks in the event display. + // This is normally switch off, because of the huge files created + // when it is switched on. + + //run->SetStoreTraj(kTRUE); + + // ----- Run initialisation ------------------------------------------- + std::cout << std::endl; + std::cout << "-I- " << myName << ": Initialise run" << std::endl; + run->Init(); + // ------------------------------------------------------------------------ + + +// // Set cuts for storing the trajectories. +// // Switch this on only if trajectories are stored. +// // Choose this cuts according to your needs, but be aware +// // that the file size of the output file depends on these cuts +// +// FairTrajFilter* trajFilter = FairTrajFilter::Instance(); +// if ( trajFilter ) { +// trajFilter->SetStepSizeCut(0.01); // 1 cm +// trajFilter->SetVertexCut(-2000., -2000., 4., 2000., 2000., 100.); +// trajFilter->SetMomentumCutP(10e-3); // p_lab > 10 MeV +// trajFilter->SetEnergyCut(0., 1.02); // 0 < Etot < 1.04 GeV +// trajFilter->SetStorePrimaries(kTRUE); +// trajFilter->SetStoreSecondaries(kTRUE); +// } + + + // ----- Runtime database --------------------------------------------- + std::cout << std::endl << std::endl; + std::cout << "-I- " << myName << ": Set runtime DB" << std::endl; + FairRuntimeDb* rtdb = run->GetRuntimeDb(); + CbmFieldPar* fieldPar = (CbmFieldPar*) rtdb->getContainer("CbmFieldPar"); + fieldPar->SetParameters(magField); + fieldPar->setChanged(); + fieldPar->setInputVersion(run->GetRunId(),1); + Bool_t kParameterMerged = kTRUE; + FairParRootFileIo* parOut = new FairParRootFileIo(kParameterMerged); + parOut->open(parFile.Data()); + rtdb->setOutput(parOut); + rtdb->saveOutput(); + rtdb->print(); + // ------------------------------------------------------------------------ + + + // ----- Start run ---------------------------------------------------- + std::cout << std::endl << std::endl; + std::cout << "-I- " << myName << ": Starting run" << std::endl; + run->Run(nEvents); + // ------------------------------------------------------------------------ + + // ----- Finish ------------------------------------------------------- + run->CreateGeometryFile(geoFile); + timer.Stop(); + 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 << "Geometry file is " << geoFile << std::endl; + std::cout << "Real time " << rtime << " s, CPU time " << ctime + << "s" << std::endl << std::endl; + // ------------------------------------------------------------------------ + + + // ----- Resource monitoring ------------------------------------------ + if ( 0 ) { //Has_Fair_Monitor() ) { // FairRoot Version >= 15.11 + // Extract the maximal used memory an add is as Dart measurement + // This line is filtered by CTest and the value send to CDash + 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; + } + + std::cout << " Test passed" << std::endl; + std::cout << " All ok " << std::endl; + + // Function needed for CTest runtime dependency + // Generate_CTest_Dependency_File(depFile); + // RemoveGeoManager(); + // ------------------------------------------------------------------------ +} + diff --git a/macro/mcbm/mcbm_reco.C b/macro/mcbm/mcbm_reco.C index ad84711606feb7f3cc53e46ff6f019ae8a9c31f2..0d0cd49b31877fee5d40786c2c42c046d08a8a9c 100644 --- a/macro/mcbm/mcbm_reco.C +++ b/macro/mcbm/mcbm_reco.C @@ -18,11 +18,11 @@ // -------------------------------------------------------------------------- -void mcbm_reco(Int_t nEvents = 2, - TString cSys = "nini", - TString cEbeam = "1.93gev", - TString cCentr = "mbias", - Int_t iRun = 1, +void mcbm_reco(Int_t nEvents = 2, + TString cSys="nini", + TString cEbeam="1.93gev", + TString cCentr="mbias", + Int_t iRun=1, const char* setupName = "sis18_mcbm_25deg_long") // const char* setupName = "sis18_mcbm_20deg_long") { @@ -42,29 +42,28 @@ void mcbm_reco(Int_t nEvents = 2, // ----- In- and output file names ------------------------------------ - TString outDir = "data/"; + TString outDir = "data/"; - TString inFile = - outDir + setupName + "_test.tra.root"; // Input file (MC events) - TString parFile = outDir + setupName + "_test.par.root"; // Parameter file - TString outFile = outDir + setupName + "_test.eds.root"; // Output file + TString inFile = outDir + setupName + "_test.tra.root"; // Input file (MC events) + TString parFile = outDir + setupName + "_test.par.root"; // Parameter file + TString outFile = outDir + setupName + "_test.eds.root"; // Output file - // TString inFile = outDir + setupName + "_" + cSys + "." + cEbeam + "." + cCentr + ".mc." + Form("%05d",iRun) + ".root"; // Input file (MC events) - // TString parFile = outDir + setupName + "_" + cSys + "." + cEbeam + "." + cCentr + ".params." + Form("%05d",iRun) + ".root"; // Parameter file - // TString outFile = outDir + setupName + "_" + cSys + "." + cEbeam + "." + cCentr + ".eds." + Form("%05d",iRun) + ".root"; // Output file +// TString inFile = outDir + setupName + "_" + cSys + "." + cEbeam + "." + cCentr + ".mc." + Form("%05d",iRun) + ".root"; // Input file (MC events) +// TString parFile = outDir + setupName + "_" + cSys + "." + cEbeam + "." + cCentr + ".params." + Form("%05d",iRun) + ".root"; // Parameter file +// TString outFile = outDir + setupName + "_" + cSys + "." + cEbeam + "." + cCentr + ".eds." + Form("%05d",iRun) + ".root"; // Output file // ------------------------------------------------------------------------ // ----- Remove old CTest runtime dependency file ---------------------- - TString depFile = Remove_CTest_Dependency_File(outDir, "run_reco", setupName); + // TString depFile = Remove_CTest_Dependency_File(outDir, "run_reco" , setupName); // ------------------------------------------------------------------------ // ----- Load the geometry setup ------------------------------------- std::cout << std::endl; - TString setupFile = srcDir + "/geometry/setup/setup_" + setupName + ".C"; + TString setupFile = srcDir + "/geometry/setup/setup_" + setupName + ".C"; TString setupFunct = "setup_"; - setupFunct = setupFunct + setupName + "()"; + setupFunct = setupFunct + setupName + "()"; std::cout << "-I- " << myName << ": Loading macro " << setupFile << std::endl; gROOT->LoadMacro(setupFile); gROOT->ProcessLine(setupFunct); @@ -75,30 +74,27 @@ void mcbm_reco(Int_t nEvents = 2, // ----- 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(); + TList *parFileList = new TList(); TString geoTag; // - TRD digitisation parameters - if (setup->GetGeoTag(kTrd, geoTag)) { - TObjString* trdFile = - new TObjString(srcDir + "/parameters/trd/trd_" + geoTag + ".digi.par"); - parFileList->Add(trdFile); + if ( setup->GetGeoTag(kTrd, geoTag) ) { + TObjString* trdFile = new TObjString(srcDir + "/parameters/trd/trd_" + geoTag + ".digi.par"); + parFileList->Add(trdFile); std::cout << "-I- " << myName << ": Using parameter file " - << trdFile->GetString() << std::endl; + << trdFile->GetString() << std::endl; } // - TOF digitisation parameters - if (setup->GetGeoTag(kTof, geoTag)) { - TObjString* tofFile = - new TObjString(srcDir + "/parameters/tof/tof_" + geoTag + ".digi.par"); - parFileList->Add(tofFile); + if ( setup->GetGeoTag(kTof, geoTag) ) { + TObjString* tofFile = new TObjString(srcDir + "/parameters/tof/tof_" + geoTag + ".digi.par"); + parFileList->Add(tofFile); std::cout << "-I- " << myName << ": Using parameter file " - << tofFile->GetString() << std::endl; - TObjString* tofBdfFile = - new TObjString(srcDir + "/parameters/tof/tof_" + geoTag + ".digibdf.par"); - parFileList->Add(tofBdfFile); + << tofFile->GetString() << std::endl; + 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; + << tofBdfFile->GetString() << std::endl; } // ------------------------------------------------------------------------ @@ -124,13 +120,13 @@ void mcbm_reco(Int_t nEvents = 2, // ----- FairRunAna --------------------------------------------------- - FairRunAna* run = new FairRunAna(); + FairRunAna *run = new FairRunAna(); run->SetInputFile(inFile); run->SetOutputFile(outFile); run->SetGenerateRunInfo(kTRUE); run->SetGenerateRunInfo(kTRUE); - Bool_t hasFairMonitor = Has_Fair_Monitor(); - if (hasFairMonitor) FairMonitor::GetMonitor()->EnableMonitor(kTRUE); + Bool_t hasFairMonitor = kFALSE; //Has_Fair_Monitor(); + //if (hasFairMonitor) FairMonitor::GetMonitor()->EnableMonitor(kTRUE); // ------------------------------------------------------------------------ @@ -140,7 +136,7 @@ void mcbm_reco(Int_t nEvents = 2, // ------------------------------------------------------------------------ // ----- Mc Data Manager ------------------------------------------------ - CbmMCDataManager* mcManager = new CbmMCDataManager("MCManager", 1); + CbmMCDataManager* mcManager=new CbmMCDataManager("MCManager", 1); mcManager->AddFile(inFile); run->AddTask(mcManager); // ------------------------------------------------------------------------ @@ -161,21 +157,21 @@ void mcbm_reco(Int_t nEvents = 2, std::cout << "Loading macro " << macroName << std::endl; gROOT->LoadMacro(macroName); Bool_t recoSuccess = gROOT->ProcessLine("reconstruct()"); - if (!recoSuccess) { - std::cerr << "-E- " << myName << ": error in executing " << macroName - << std::endl; - return; + if ( ! recoSuccess ) { + std::cerr << "-E- " << myName << ": error in executing " << macroName + << std::endl; + return; } std::cout << "-I- " << myName << ": " << macroName << " executed successfully" - << std::endl; + << std::endl; // ------------------------------------------------------------------------ // ----- 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(); + FairRuntimeDb* rtdb = run->GetRuntimeDb(); + FairParRootFileIo* parIo1 = new FairParRootFileIo(); FairParAsciiFileIo* parIo2 = new FairParAsciiFileIo(); parIo1->open(parFile.Data()); parIo2->open(parFileList, "in"); @@ -210,32 +206,34 @@ void mcbm_reco(Int_t nEvents = 2, 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; + << std::endl; std::cout << std::endl; std::cout << " Test passed" << std::endl; std::cout << " All ok " << std::endl; // ------------------------------------------------------------------------ // ----- Resource monitoring ------------------------------------------ - if (Has_Fair_Monitor()) { // FairRoot Version >= 15.11 + if ( hasFairMonitor ) { // FairRoot Version >= 15.11 // Extract the maximal used memory an add is as Dart measurement // This line is filtered by CTest and the value send to CDash + /* FairSystemInfo sysInfo; - Float_t maxMemory = sysInfo.GetMaxMemory(); + 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; + Float_t cpuUsage=ctime/rtime; std::cout << "<DartMeasurement name=\"CpuLoad\" type=\"numeric/double\">"; std::cout << cpuUsage; std::cout << "</DartMeasurement>" << std::endl; FairMonitor* tempMon = FairMonitor::GetMonitor(); tempMon->Print(); + */ } // Function needed for CTest runtime dependency - Generate_CTest_Dependency_File(depFile); - RemoveGeoManager(); + //Generate_CTest_Dependency_File(depFile); + //RemoveGeoManager(); } diff --git a/macro/mcbm/mcbm_reco_event_tb_nh.C b/macro/mcbm/mcbm_reco_event_tb_nh.C new file mode 100755 index 0000000000000000000000000000000000000000..9b01847a6e2593543c27cbc2d1d8504e73b73dde --- /dev/null +++ b/macro/mcbm/mcbm_reco_event_tb_nh.C @@ -0,0 +1,604 @@ +// -------------------------------------------------------------------------- +// +// Macro for reconstruction of simulated mCBM events with standard settings +// +// Event-by-event reconstruction; requires appropriate digitization before +// (see mcbm_digi.C) +// +// Local reconstruction in MVD, STS, MUCH, TRD and TOF +// Binned tracker for track reconstruction +// +// V. Friese 11.06.2018 +// +// -------------------------------------------------------------------------- + +void mcbm_reco_event_tb_nh( + Int_t nEvents = 10, + TString RunId = "test", + TString InDir = "./data/", + TString OutDir = "./data/", + TString setupName = "mcbm_beam_2021_03", + bool timebased = kTRUE, + Double_t eventRate = 1.e5, // Interaction rate [1/s] + Double_t timeSliceLength = 1.e4, // Length of time-slice [ns] + Double_t Tint=100., + Double_t ReqTofMul=2. +) +{ + // ======================================================================== + // Adjust this part according to your requirements + + // --- Logger settings ---------------------------------------------------- + TString logLevel = "INFO"; + //TString logVerbosity = "VERYHIGH"; + //TString logVerbosity = "HIGH"; + //TString logVerbosity = "MEDIUM"; + TString logVerbosity = "LOW"; + // ------------------------------------------------------------------------ + + + // ----- Environment -------------------------------------------------- + TString myName = "mcbm_reco"; // this macro's name for screen output + TString srcDir = gSystem->Getenv("VMCWORKDIR"); // top source directory + // ------------------------------------------------------------------------ + + + // ----- File names --------------------------------------------------- + //TString TraDir ="../../../../../../uhlig/mcbm_proposal/data"; + TString TraDir = InDir; + TString traFile = TraDir + "/" + RunId + ".tra.root"; + TString dataset = InDir + "/" + RunId; + TString parFile = dataset + ".par.root"; + TString rawFile = dataset + ".event.raw.root"; + TString recFile = OutDir + "/" + RunId + ".rec.root"; + if (timebased) { + rawFile = dataset + Form(".%2.1e",eventRate) + ".raw.root"; + recFile = OutDir + "/" + RunId + Form(".%2.1e.%d.%d",eventRate,(Int_t)Tint,(Int_t)ReqTofMul) + ".rec.root"; + } + + // ------------------------------------------------------------------------ + + Int_t iTofCluMode=1; // 1 - CbmTofEventClusterizer + Int_t iTrackMode=0; + + // ----- Load the geometry setup ------------------------------------- + std::cout << std::endl; + TString setupFile = srcDir + "/geometry/setup/setup_" + setupName + ".C"; + TString setupFunct = "setup_"; + setupFunct = setupFunct + setupName + "()"; + std::cout << "-I- " << myName << ": Loading macro " << setupFile << std::endl; + gROOT->LoadMacro(setupFile); + gROOT->ProcessLine(setupFunct); + CbmSetup* setup = CbmSetup::Instance(); + setup->RemoveModule(ECbmModuleId::kTrd); +// setup->RemoveModule(ECbmModuleId::kTof); +// setup->RemoveModule(ECbmModuleId::kSts); + // ------------------------------------------------------------------------ + + + // ----- 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 ( setup->GetGeoTag(ECbmModuleId::kTrd, geoTag) ) { + TObjString* trdFile = new TObjString(srcDir + "/parameters/trd/trd_" + geoTag + ".digi.par"); + parFileList->Add(trdFile); + std::cout << "-I- " << myName << ": Using parameter file " + << trdFile->GetString() << std::endl; + } + + // - TOF digitisation parameters + if ( setup->GetGeoTag(ECbmModuleId::kTof, geoTag) ) { + TObjString* tofFile = new TObjString(srcDir + "/parameters/tof/tof_" + geoTag + ".digi.par"); + parFileList->Add(tofFile); + std::cout << "-I- " << myName << ": Using parameter file " + << tofFile->GetString() << std::endl; + 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(); + // ------------------------------------------------------------------------ + + + // ---- Debug option ------------------------------------------------- + gDebug = 0; + // ------------------------------------------------------------------------ + + + // ----- Input file --------------------------------------------------- + std::cout << std::endl; + std::cout << "-I- " << myName << ": Using input file " << rawFile << std::endl; + // ------------------------------------------------------------------------ + + + // ----- FairRunAna --------------------------------------------------- + FairRunAna *run = new FairRunAna(); + run->SetInputFile(rawFile); + run->AddFriend(traFile); + run->SetOutputFile(recFile); + run->SetGenerateRunInfo(kFALSE); + Bool_t hasFairMonitor = kFALSE; //Has_Fair_Monitor(); + if (hasFairMonitor) FairMonitor::GetMonitor()->EnableMonitor(kTRUE); + // ------------------------------------------------------------------------ + + + // ----- Logger settings ---------------------------------------------- + FairLogger::GetLogger()->SetLogScreenLevel(logLevel.Data()); + FairLogger::GetLogger()->SetLogVerbosityLevel(logVerbosity.Data()); + // ------------------------------------------------------------------------ + + // ----- MC Data Manager ------------------------------------------------ + //CbmMCDataManager* mcManager=new CbmMCDataManager("MCManager", 1); + //mcManager->AddFile(rawFile); + //run->AddTask(mcManager); + // ------------------------------------------------------------------------ + + CbmMcbm2018EventBuilder* eventBuilder = new CbmMcbm2018EventBuilder(); + // eventBuilder->SetEventBuilderAlgo(EventBuilderAlgo::MaximumTimeGap); + // eventBuilder->SetMaximumTimeGap(100.); + eventBuilder->SetEventBuilderAlgo(EventBuilderAlgo::FixedTimeWindow); + eventBuilder->SetFixedTimeWindow(200.); + eventBuilder->SetTriggerMinNumberT0(0); + eventBuilder->SetTriggerMinNumberSts(0); + eventBuilder->SetTriggerMinNumberMuch(0); + eventBuilder->SetTriggerMinNumberTof(1); + eventBuilder->SetTriggerMinNumberRich(0); + eventBuilder->SetFillHistos(kTRUE); + if (timebased) run->AddTask(eventBuilder); + + // ----- Local reconstruction in MVD ---------------------------------- + if ( setup->IsActive(ECbmModuleId::kMvd) ) { + + CbmMvdClusterfinder* mvdCluster = + new CbmMvdClusterfinder("MVD Cluster Finder", 0, 0); + run->AddTask(mvdCluster); + std::cout << "-I- " << myName << ": Added task " + << mvdCluster->GetName() << std::endl; + + CbmMvdHitfinder* mvdHit = new CbmMvdHitfinder("MVD Hit Finder", 0, 0); + mvdHit->UseClusterfinder(kTRUE); + run->AddTask(mvdHit); + std::cout << "-I- " << myName << ": Added task " + << mvdHit->GetName() << std::endl; + + } + // ------------------------------------------------------------------------ + + + // ----- Local reconstruction in STS ---------------------------------- + if ( setup->IsActive(ECbmModuleId::kSts) ) { + CbmRecoSts* stsReco=NULL; + if (timebased) { + stsReco = new CbmRecoSts(kCbmRecoEvent,kFALSE,kFALSE); +// stsReco = new CbmRecoSts(); + }else { + stsReco = new CbmRecoSts(); + } + if(kFALSE && timebased) { + // ASIC params: #ADC channels, dyn. range, threshold, time resol., dead time, + // noise RMS, zero-threshold crossing rate + auto parAsic = new CbmStsParAsic(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); + stsReco->UseModulePar(parMod); + + // Sensor params + auto sensorPar = new CbmStsParSensor(CbmStsSensorClass::kDssdStereo); + sensorPar->SetPar(0, 6.2092); // Extension in x + sensorPar->SetPar(1, 6.2); // Extension in y + sensorPar->SetPar(2, 0.03); // Extension in z + sensorPar->SetPar(3, 5.9692); // Active size in y + sensorPar->SetPar(4, 1024.); // Number of strips front side + sensorPar->SetPar(5, 1024.); // Number of strips back side + sensorPar->SetPar(6, 0.0058); // Strip pitch front side + sensorPar->SetPar(7, 0.0058); // Strip pitch back side + sensorPar->SetPar(8, 7.5); // Stereo angle front side + sensorPar->SetPar(9, 0.0); // Stereo angle back side + stsReco->UseSensorPar(sensorPar); + + // Sensor conditions: full depletion voltage, bias voltage, temperature, + // coupling capacitance, inter-strip capacitance + auto sensorCond = new CbmStsParSensorCond(70., 140., 268., 17.5, 1.); + stsReco->UseSensorCond(sensorCond); + } + run->AddTask(stsReco); + std::cout << "-I- : Added task " << stsReco->GetName() << std::endl; + + } + // ------------------------------------------------------------------------ + + + // ----- Local reconstruction in MUCH --------------------------------- + if ( setup->IsActive(ECbmModuleId::kMuch) ) { + /* + // --- Parameter file name + TString geoTag; + setup->GetGeoTag(ECbmModuleId::kMuch, geoTag); + Int_t muchFlag=0; + if (geoTag.Contains("mcbm")) muchFlag=1; + + TString parFile = gSystem->Getenv("VMCWORKDIR"); + + if (muchFlag) { + std::cout << geoTag << std::endl; + parFile = parFile + "/parameters/much/much_" + geoTag + + "_digi_sector.root"; + std::cout << "Using parameter file " << parFile << std::endl; + } else { + std::cout << geoTag(0,4) << std::endl; + parFile = parFile + "/parameters/much/much_" + geoTag(0,4) + + "_digi_sector.root"; + std::cout << "Using parameter file " << parFile << std::endl; + } + + + // --- Hit finder for GEMs + FairTask* muchHitGem = new CbmMuchFindHitsGem(parFile.Data(),muchFlag); + run->AddTask(muchHitGem); + std::cout << "-I- " << myName << ": Added task " + << muchHitGem->GetName() << FairLogger::endl; +*/ + } + // ------------------------------------------------------------------------ + + + // ----- Local reconstruction in TRD ---------------------------------- + if ( setup->IsActive(ECbmModuleId::kTrd) && !timebased && kFALSE ) { + + Double_t triggerThreshold = 0.5e-6; // SIS100 + Bool_t triangularPads = false; // Bucharest triangular pad-plane layout + CbmTrdClusterFinder* trdCluster = new CbmTrdClusterFinder(); + trdCluster->SetNeighbourEnable(true); + trdCluster->SetMinimumChargeTH(triggerThreshold); + trdCluster->SetNeighbourEnable(false); + trdCluster->SetRowMerger(true); + run->AddTask(trdCluster); + std::cout << "-I- " << myName << ": Added task " + << trdCluster->GetName() << std::endl; + + CbmTrdHitProducer* trdHit = new CbmTrdHitProducer(); + run->AddTask(trdHit); + std::cout << "-I- " << myName << ": Added task " + << trdHit->GetName() << std::endl; + + } + // ------------------------------------------------------------------------ + // TOF defaults + + Int_t calMode=93; + Int_t calSel=1; + Int_t calSm=0; + Int_t RefSel=0; + Double_t dDeadtime=50.; + Int_t iCalSet=30040500; + Int_t iSel2=500; + TString cCalId="MCdefault"; + + // ----- Local reconstruction in TOF ---------------------------------- + if ( setup->IsActive(ECbmModuleId::kTof) ) { + switch(iTofCluMode) { + case 1: + { + CbmTofEventClusterizer* tofCluster = new CbmTofEventClusterizer("TOF Event Clusterizer",0,1); + + tofCluster->SetCalMode(calMode); + tofCluster->SetCalSel(calSel); + tofCluster->SetCaldXdYMax(3.); // geometrical matching window in cm + tofCluster->SetCalCluMulMax(5.); // Max Counter Cluster Multiplicity for filling calib histos + tofCluster->SetCalRpc(calSm); // select detector for calibration update + tofCluster->SetTRefId(RefSel); // reference trigger for offset calculation + tofCluster->SetTotMax(20.); // Tot upper limit for walk corection + tofCluster->SetTotMin(0.01); //(12000.); // Tot lower limit for walk correction + tofCluster->SetTotPreRange(5.); // effective lower Tot limit in ns from peak position + tofCluster->SetTotMean(5.); // Tot calibration target value in ns + tofCluster->SetMaxTimeDist(0.4); // default cluster range in ns + tofCluster->SetDelTofMax(5.); // acceptance range for cluster distance in ns (!) + tofCluster->SetSel2MulMax(3); // limit Multiplicity in 2nd selector + tofCluster->SetChannelDeadtime(dDeadtime); // artificial deadtime in ns + tofCluster->SetEnableAvWalk(kFALSE); + //tofCluster->SetEnableMatchPosScaling(kFALSE); // turn off projection to nominal target + tofCluster->SetYFitMin(1.E8); + tofCluster->SetToDAv(0.04); + tofCluster->SetIdMode(1); // calibrate on module level + tofCluster->SetTRefDifMax(2.0); // in ns + tofCluster->PosYMaxScal(0.75); //in % of length + TString cOutFname=OutDir + Form("/%s_set%09d_%02d_%01dtofClust.hst.root",RunId.Data(),iCalSet,calMode,calSel); + tofCluster->SetOutHstFileName(cOutFname); + + 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 + if(iSel2==0){ + // iSel2=iBRef; + }else{ + if(iSel2<0) iSel2=-iSel2; + } + + Int_t iRSelin=iRSel; + iRSelRpc=iRSel%10; + iRSelTyp = (iRSel-iRSelRpc)/10; + iRSelSm=iRSelTyp%10; + iRSelTyp = (iRSelTyp-iRSelSm)/10; + + tofCluster->SetBeamRefId(iRSelTyp); // define Beam reference counter + tofCluster->SetBeamRefSm(iRSelSm); + tofCluster->SetBeamRefDet(iRSelRpc); + tofCluster->SetBeamAddRefMul(-1); + tofCluster->SetBeamRefMulMax(3); + + Int_t iSel2in=iSel2; + Int_t iSel2Rpc= iSel2%10; + iSel2=(iSel2-iSel2Rpc)/10; + Int_t iSel2Sm=iSel2%10; + iSel2=(iSel2-iSel2Sm)/10; + if(iSel2 > -1) { + tofCluster->SetSel2Id(iSel2); + tofCluster->SetSel2Sm(iSel2Sm); + tofCluster->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; + + tofCluster->SetDutId(iDut); + tofCluster->SetDutSm(iDutSm); + tofCluster->SetDutRpc(iDutRpc); + + Int_t iRefRpc = iRef%10; + iRef = (iRef - iRefRpc)/10; + Int_t iRefSm = iRef%10; + iRef = (iRef - iRefSm)/10; + + tofCluster->SetSelId(iRef); + tofCluster->SetSelSm(iRefSm); + tofCluster->SetSelRpc(iRefRpc); + + run->AddTask(tofCluster); + std::cout << "-I- " << myName << ": Added task " + << tofCluster->GetName() << std::endl; + } + break; + default: + { + CbmTofSimpClusterizer* tofCluster + = new CbmTofSimpClusterizer("TOF Simple Clusterizer", 0); + tofCluster->SetOutputBranchPersistent("TofHit", kTRUE); + tofCluster->SetOutputBranchPersistent("TofDigiMatch", kTRUE); + run->AddTask(tofCluster); + std::cout << "-I- " << myName << ": Added task " + << tofCluster->GetName() << std::endl; + } + } + } + // ------------------------------------------------------------------------- + + + // ----- Local reconstruction in RICH ---------------------------------- + if ( setup->IsActive(ECbmModuleId::kRich) ) { + /* + CbmRichMCbmHitProducer *richHitProd = new CbmRichMCbmHitProducer(); + //richHitProd->setToTLimits(23.7,30.0); + //richHitProd->applyToTCut(); + //richHitProd->DoRestrictToAcc(); + run->AddTask(richHitProd); + cout << "-I- hitProducer: Added task " << richHitProd->GetName() << endl; + + CbmRichReconstruction* richReco = new CbmRichReconstruction(); + richReco->UseMCbmSetup(); + run->AddTask(richReco); + cout << "-I- richReco: Added task " << richReco->GetName() << endl; +*/ + } + // ------------------------------------------------------------------------- + + + // ----- Track reconstruction ------------------------------------------ + Double_t beamWidthX = 0.1; + Double_t beamWidthY = 0.1; + switch(iTrackMode) { + case 2: + { + Int_t iGenCor=1; + Double_t dScalFac=1.; + Double_t dChi2Lim2=3.5; + TString cTrkFile=Form("%s_tofFindTracks.hst.root","MC"); + Int_t iTrackingSetup=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->SetCorMode(iGenCor); // valid options: 0,1,2,3,4,5,6, 10 - 19 + 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=26; + iNReqStations=3; + 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); + break; + } + tofFindTracks->SetMinNofHits(iMinNofHits); + tofFindTracks->SetNStations(iNStations); + tofFindTracks->SetNReqStations(iNReqStations); + tofFindTracks->PrintSetup(); + run->AddTask(tofFindTracks); + } + break; + case 1: + { + CbmBinnedTrackerTask* trackerTask = new CbmBinnedTrackerTask(kTRUE, + beamWidthX, + beamWidthY); + trackerTask->SetUse(ECbmModuleId::kTrd, kFALSE); + run->AddTask(trackerTask); + } + case 0: + default: + ; + } + // ------------------------------------------------------------------------ + + + // ========================================================================= + // === Your QA === + // ========================================================================= + + //CbmRichMCbmQaReal* mRichQa = new CbmRichMCbmQaReal(); + //mRichQa->SetOutputDir(string(resultDir)); + //run->AddTask(mRichQa); + // ========================================================================= + + + + // ----- 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"); +// parIo2->open(parFileList, "in"); + rtdb->setFirstInput(parIo1); +// rtdb->setSecondInput(parIo2); + // ------------------------------------------------------------------------ + + + // ----- Run initialisation ------------------------------------------- + std::cout << std::endl; + std::cout << "-I- " << myName << ": Initialise run" << std::endl; + run->Init(); + // ------------------------------------------------------------------------ + + + // ----- Database update ---------------------------------------------- + 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(0, nEvents); + // ------------------------------------------------------------------------ + + + // ----- Finish ------------------------------------------------------- + timer.Stop(); + 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 " << recFile << 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; + std::cout << " Test passed" << std::endl; + std::cout << " All ok " << std::endl; + // ------------------------------------------------------------------------ + // save all historgrams + gROOT->LoadMacro("save_hst.C"); + TString FSave=Form("save_hst(\"%s.reco_hst.root\")",dataset.Data()); + gInterpreter->ProcessLine(FSave.Data()); + // ----- Resource monitoring ------------------------------------------ + if ( hasFairMonitor /*Has_Fair_Monitor()*/ ) { // FairRoot Version >= 15.11 + // Extract the maximal used memory an add is as Dart measurement + // This line is filtered by CTest and the value send to CDash + 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; + + FairMonitor* tempMon = FairMonitor::GetMonitor(); + tempMon->Print(); + } + + // RemoveGeoManager(); +} diff --git a/macro/mcbm/mcbm_reco_nh.C b/macro/mcbm/mcbm_reco_nh.C index aeca95eb25640b2aa0bee5e2dd0d9d4932456855..a003d6d89fb40bcbc13c611bb304a713bd266028 100644 --- a/macro/mcbm/mcbm_reco_nh.C +++ b/macro/mcbm/mcbm_reco_nh.C @@ -13,421 +13,156 @@ // Matching of reconstructed and MC tracks in STS, RICH and TRD // // V. Friese 24/02/2006 -// Version 04/03/2015 (V. Friese) +// Version 24/04/2007 (V. Friese) // // -------------------------------------------------------------------------- - -void mcbm_reco_nh(Int_t nEvents = 1000, - TString cSys = "lam", - TString cEbeam = "2.5gev", - TString cCentr = "-", - Int_t iRun = 0, - const char* setup = "sis18_mcbm_20deg_long") { - +void mcbm_reco_nh(Int_t nEvents = 1000, + TString cSys="lam", + TString cEbeam="2.5gev", + TString cCentr="-", + Int_t iRun=0, + const char* setupName = "sis18_mcbm") +{ // ======================================================================== // Adjust this part according to your requirements - // Verbosity level (0=quiet, 1=event level, 2=track level, 3=debug) - Int_t iVerbose = 0; + // ----- Environment -------------------------------------------------- + TString myName = "run_reco_nh"; // this macro's name for screen output + TString srcDir = gSystem->Getenv("VMCWORKDIR"); // top source directory + // ------------------------------------------------------------------------ + + + // ----- In- and output file names ------------------------------------ + TString outDir = "data/"; + TString inFile = outDir + setupName + "_" + cSys + "." + cEbeam + "." + cCentr + ".mc." + Form("%05d",iRun) + ".root"; // Input file (MC events) + TString parFile = outDir + setupName + "_" + cSys + "." + cEbeam + "." + cCentr + ".params." + Form("%05d",iRun) + ".root"; // Parameter file + TString outFile = outDir + setupName + "_" + cSys + "." + cEbeam + "." + cCentr + ".eds." + Form("%05d",iRun) + ".root"; // Output file - TString outDir = "data/"; - TString inFile = outDir + setup + "_" + cSys + "." + cEbeam + "." + cCentr - + ".mc." + Form("%05d", iRun) - + ".root"; // Input file (MC events) - TString parFile = outDir + setup + "_" + cSys + "." + cEbeam + "." + cCentr - + ".params." + Form("%05d", iRun) - + ".root"; // Parameter file - TString outFile = outDir + setup + "_" + cSys + "." + cEbeam + "." + cCentr - + ".eds." + Form("%05d", iRun) + ".root"; // Output file + // ----- Remove old CTest runtime dependency file ---------------------- + TString depFile = Remove_CTest_Dependency_File(outDir, "run_reco" , setupName); FairLogger::GetLogger()->SetLogScreenLevel("WARNING"); //FairLogger::GetLogger()->SetLogScreenLevel("INFO"); - //FairLogger::GetLogger()->SetLogScreenLevel("DEBUG"); + // FairLogger::GetLogger()->SetLogScreenLevel("DEBUG"); + //FairLogger::GetLogger()->SetLogScreenLevel("DEBUG1"); FairLogger::GetLogger()->SetLogVerbosityLevel("MEDIUM"); - // Digitisation files. - // Add TObjectString containing the different file names to - // a TList which is passed as input to the FairParAsciiFileIo. - // The FairParAsciiFileIo will take care to create on the fly - // a concatenated input parameter file which is then used during - // the reconstruction. - TList* parFileList = new TList(); - - TString inDir = gSystem->Getenv("VMCWORKDIR"); - TString paramDir = inDir + "/parameters/"; - - - TString setupFile = inDir + "/geometry/setup/legacy/" + setup + "_setup.C"; - TString setupFunct = setup; - setupFunct += "_setup()"; - gROOT->LoadMacro(setupFile); - gInterpreter->ProcessLine(setupFunct); - - /* // ----- Load the geometry setup ------------------------------------- std::cout << std::endl; - TString setupFile = inDir + "/geometry/setup/setup_" + setup+ ".C"; + TString setupFile = srcDir + "/geometry/setup/setup_" + setupName + ".C"; TString setupFunct = "setup_"; - setupFunct = setupFunct + setup + "()"; - std::cout << "-I- mcbm_reco: Loading macro " << setupFile << std::endl; + setupFunct = setupFunct + setupName + "()"; + std::cout << "-I- " << myName << ": Loading macro " << setupFile << std::endl; gROOT->LoadMacro(setupFile); gROOT->ProcessLine(setupFunct); - */ - - // --- STS digipar file is there only for L1. It is no longer required - // --- for STS digitisation and should be eventually removed. - //TObjString stsDigiFile = paramDir + stsDigi; - //parFileList->Add(&stsDigiFile); - //cout << "macro/run/run_reco.C using: " << stsDigi << endl; - - TObjString* trdDigiFile = new TObjString(paramDir + trdDigi); - parFileList->Add(trdDigiFile); + CbmSetup* setup = CbmSetup::Instance(); + // ------------------------------------------------------------------------ - // TObjString trdDigiFile(paramDir + trdDigi); - // parFileList->Add(&trdDigiFile); - cout << "macro/run/run_reco.C using: " << trdDigi << endl; - TObjString* tofDigiFile = new TObjString(paramDir + tofDigi); - parFileList->Add(tofDigiFile); - cout << "macro/mcbm/mcbm_reco.C using: " << tofDigi << endl; + // ----- 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 ( setup->GetGeoTag(kTrd, geoTag) ) { + TObjString* trdFile = new TObjString(srcDir + "/parameters/trd/trd_" + geoTag + ".digi.par"); + parFileList->Add(trdFile); + std::cout << "-I- " << myName << ": Using parameter file " + << trdFile->GetString() << std::endl; + } - TObjString* tofDigiBdfFile = new TObjString(paramDir + tofDigiBdf); - parFileList->Add(tofDigiBdfFile); - cout << "macro/mcbm/mcbm_reco.C using: " << paramDir << tofDigiBdf << endl; - // TObjString tofDigiFile = paramDir + tofDigi; - // parFileList->Add(&tofDigiFile); + // - TOF digitisation parameters + if ( setup->GetGeoTag(kTof, geoTag) ) { + TObjString* tofFile = new TObjString(srcDir + "/parameters/tof/tof_" + geoTag + ".digi.par"); + parFileList->Add(tofFile); + std::cout << "-I- " << myName << ": Using parameter file " + << tofFile->GetString() << std::endl; + 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(); + // ------------------------------------------------------------------------ + + // ---- Debug option ------------------------------------------------- gDebug = 0; // ------------------------------------------------------------------------ - // ----- Timer -------------------------------------------------------- - TStopwatch timer; - timer.Start(); + // ----- Input file --------------------------------------------------- + std::cout << std::endl; + std::cout << "-I- " << myName << ": Using input file " << inFile << std::endl; // ------------------------------------------------------------------------ - // ----- Reconstruction run ------------------------------------------- - FairRunAna* run = new FairRunAna(); + + // ----- FairRunAna --------------------------------------------------- + FairRunAna *run = new FairRunAna(); run->SetInputFile(inFile); run->SetOutputFile(outFile); + run->SetGenerateRunInfo(kTRUE); + run->SetGenerateRunInfo(kTRUE); + Bool_t hasFairMonitor = Has_Fair_Monitor(); + if (hasFairMonitor) FairMonitor::GetMonitor()->EnableMonitor(kTRUE); // ------------------------------------------------------------------------ - // ----- MC Data Manager ------------------------------------------------ - CbmMCDataManager* mcManager = new CbmMCDataManager("MCManager", 1); + // ----- Mc Data Manager ------------------------------------------------ + CbmMCDataManager* mcManager=new CbmMCDataManager("MCManager", 1); mcManager->AddFile(inFile); run->AddTask(mcManager); // ------------------------------------------------------------------------ - - // ========================================================================= - // === Detector Response Simulation (Digitiser) === - // === (where available) === - // ========================================================================= - - - // ----- MVD Digitiser ------------------------------------------------- - CbmMvdDigitizer* mvdDigitise = - new CbmMvdDigitizer("MVD Digitiser", 0, iVerbose); - //run->AddTask(mvdDigitise); - // ------------------------------------------------------------------------- - - // ----- MVD Clusterfinder --------------------------------------------- - CbmMvdClusterfinder* mvdCluster = - new CbmMvdClusterfinder("MVD Clusterfinder", 0, iVerbose); - //run->AddTask(mvdCluster); - // ------------------------------------------------------------------------- - - - // ----- STS digitizer ------------------------------------------------- - // ----- The parameters of the STS digitizer are set such as to match - // ----- those in the old digitizer. Change them only if you know what you - // ----- are doing. - Double_t dynRange = 40960.; // Dynamic range [e] - Double_t threshold = 4000.; // Digitisation threshold [e] - Int_t nAdc = 4096; // Number of ADC channels (12 bit) - Double_t timeResolution = 5.; // time resolution [ns] - Double_t deadTime = 9999999.; // infinite dead time (integrate entire event) - Double_t noise = 0.; // ENC [e] - Int_t digiModel = 1; // Model: 1 = uniform charge distribution along track - - CbmStsDigitize* stsDigi = new CbmStsDigitize(digiModel); - stsDigi->SetParameters( - dynRange, threshold, nAdc, timeResolution, deadTime, noise); - run->AddTask(stsDigi); - // ------------------------------------------------------------------------- - - - // ========================================================================= - // === MVD local reconstruction === - // ========================================================================= - - // ----- MVD Hit Finder ------------------------------------------------ - CbmMvdHitfinder* mvdHitfinder = - new CbmMvdHitfinder("MVD Hit Finder", 0, iVerbose); - mvdHitfinder->UseClusterfinder(kTRUE); - //run->AddTask(mvdHitfinder); - // ------------------------------------------------------------------------- - - // === End of MVD local reconstruction === - // ========================================================================= - - - // ========================================================================= - // === STS local reconstruction === - // ========================================================================= - - - // ----- STS Cluster Finder -------------------------------------------- - FairTask* stsClusterFinder = new CbmStsFindClusters(); - run->AddTask(stsClusterFinder); - // ------------------------------------------------------------------------- - - - // ----- STS hit finder ------------------------------------------------ - FairTask* stsFindHits = new CbmStsFindHits(); - run->AddTask(stsFindHits); - // ------------------------------------------------------------------------- - - - // ----- STS hit matching ----------------------------------------------- - // FairTask* stsMatchHits = new CbmStsMatchHits(); - // run->AddTask(stsMatchHits); - // ------------------------------------------------------------------------- - - - // --- STS track finding ------------------------------------------------ - CbmKF* kalman = new CbmKF(); - run->AddTask(kalman); - CbmL1* l1 = new CbmL1(); - TString mvdMatBudgetFileName = paramDir + mvdMatBudget; - TString stsMatBudgetFileName = paramDir + stsMatBudget; - // l1->SetStsMaterialBudgetFileName(stsMatBudgetFileName.Data()); - // l1->SetMvdMaterialBudgetFileName(mvdMatBudgetFileName.Data()); - // run->AddTask(l1); - - CbmStsTrackFinder* stsTrackFinder = new CbmL1StsTrackFinder(); - FairTask* stsFindTracks = new CbmStsFindTracks(iVerbose, stsTrackFinder); - // run->AddTask(stsFindTracks); - // ------------------------------------------------------------------------- - - - // --- STS track matching ---------------------------------------------- - // FairTask* stsMatchTracks = new CbmStsMatchTracks(iVerbose); - // run->AddTask(stsMatchTracks); - // ------------------------------------------------------------------------- - - - // --- STS track fitting ----------------------------------------------- - // CbmStsTrackFitter* stsTrackFitter = new CbmStsKFTrackFitter(); - // FairTask* stsFitTracks = new CbmStsFitTracks(stsTrackFitter, iVerbose); - // run->AddTask(stsFitTracks); - // ------------------------------------------------------------------------- - - // === End of STS local reconstruction === - // ========================================================================= - - - // ========================================================================= - // === TRD local reconstruction === - // ========================================================================= - - - CbmTrdRadiator* radiator = new CbmTrdRadiator(kTRUE, "K++"); - FairTask* trdDigi = new CbmTrdDigitizerPRF(radiator); - //run->AddTask(trdDigi); - - Double_t triggerThreshold = 0.5e-6; // SIS100 - Bool_t triangularPads = false; // Bucharest triangular pad-plane layout - CbmTrdClusterFinderFast* trdCluster = new CbmTrdClusterFinderFast(); - trdCluster->SetNeighbourTrigger(true); - trdCluster->SetTriggerThreshold(triggerThreshold); - trdCluster->SetNeighbourRowTrigger(false); - trdCluster->SetPrimaryClusterRowMerger(true); - trdCluster->SetTriangularPads(triangularPads); - //run->AddTask(trdCluster); - - CbmTrdHitProducerCluster* trdHit = new CbmTrdHitProducerCluster(); - trdHit->SetTriangularPads(triangularPads); - //run->AddTask(trdHit); - - /* - Bool_t simpleTR = kTRUE; // use fast and simple version for TR production - CbmTrdRadiator *radiator = new CbmTrdRadiator(simpleTR,"K++"); - //"K++" : micro structured POKALON - //"H++" : PE foam foils - //"G30" : ALICE fibers 30 layers - - Bool_t triangularPads = false;// Bucharest triangular pad-plane layout - //Double_t triggerThreshold = 0.5e-6;//SIS100 - Double_t triggerThreshold = 1.0e-6;//SIS300 - Double_t trdNoiseSigma_keV = 0.1; //default best matching to test beam PRF - - CbmTrdDigitizerPRF* trdDigiPrf = new CbmTrdDigitizerPRF(radiator); - trdDigiPrf->SetTriangularPads(triangularPads); - trdDigiPrf->SetNoiseLevel(trdNoiseSigma_keV); - run->AddTask(trdDigiPrf); - - CbmTrdClusterFinderFast* trdCluster = new CbmTrdClusterFinderFast(); - trdCluster->SetNeighbourTrigger(true); - trdCluster->SetTriggerThreshold(triggerThreshold); - trdCluster->SetNeighbourRowTrigger(false); - trdCluster->SetPrimaryClusterRowMerger(true); - trdCluster->SetTriangularPads(triangularPads); - run->AddTask(trdCluster); - - CbmTrdHitProducerCluster* trdHit = new CbmTrdHitProducerCluster(); - trdHit->SetTriangularPads(triangularPads); -// run->AddTask(trdHit); -*/ - // ------------------------------------------------------------------------- - // === End of TRD local reconstruction === - // ========================================================================= - - - // ========================================================================= - // === TOF local reconstruction === - // ========================================================================= - - CbmTofDigitizerBDF* tofDigi = - new CbmTofDigitizerBDF("TOF Digitizer BDF", iVerbose); - tofDigi->SetOutputBranchPersistent("TofDigi", kTRUE); - tofDigi->SetOutputBranchPersistent("TofDigiMatchPoints", kTRUE); - tofDigi->SetInputFileName(paramDir + "/tof/test_bdf_input.root"); - // tofDigi->SetHistoFileName( digiOutFile ); // Uncomment to save control histograms - run->AddTask(tofDigi); - - CbmTofSimpClusterizer* tofCluster = - new CbmTofSimpClusterizer("TOF Simple Clusterizer", 0); - tofCluster->SetOutputBranchPersistent("TofHit", kTRUE); - tofCluster->SetOutputBranchPersistent("TofDigiMatch", kTRUE); - run->AddTask(tofCluster); - - // ------ TOF hit producer --------------------------------------------- - // CbmTofHitProducerNew* tofHitProd = new CbmTofHitProducerNew("TOF HitProducerNew",iVerbose); - // tofHitProd->SetInitFromAscii(kFALSE); - // run->AddTask(tofHitProd); - // ------------------------------------------------------------------------- - - // === End of TOF local reconstruction === - // ========================================================================= - - - // ========================================================================= - // === Global tracking === - // ========================================================================= - - CbmLitFindGlobalTracks* finder = new CbmLitFindGlobalTracks(); - // Tracking method to be used - // "branch" - branching tracking - // "nn" - nearest neighbor tracking - // "weight" - weighting tracking - finder->SetTrackingType("branch"); - - // Hit-to-track merger method to be used - // "nearest_hit" - assigns nearest hit to the track - finder->SetMergerType("nearest_hit"); - - // run->AddTask(finder); - - // ----- Primary vertex finding --------------------------------------- - - CbmPrimaryVertexFinder* pvFinder = new CbmPVFinderKF(); - CbmFindPrimaryVertex* findVertex = new CbmFindPrimaryVertex(pvFinder); - //run->AddTask(findVertex); - + // ----- Digitisers --------------------------------------------------- + std::cout << std::endl; + TString macroName = gSystem->Getenv("VMCWORKDIR"); + macroName += "/macro/run/modules/digitize.C"; + std::cout << "Loading macro " << macroName << std::endl; + gROOT->LoadMacro(macroName); + gROOT->ProcessLine("digitize()"); // ------------------------------------------------------------------------ - // === End of global tracking === - // ========================================================================= - - // ----------- TRD track Pid Wkn ---------------------- - CbmTrdSetTracksPidWkn* trdSetTracksPidTask = - new CbmTrdSetTracksPidWkn("trdFindTracks", "trdFindTracks"); - // run->AddTask(trdSetTracksPidTask); - // ---------------------------------------------------- - - // ----------- TRD track Pid Ann ---------------------- - CbmTrdSetTracksPidANN* trdSetTracksPidAnnTask = - new CbmTrdSetTracksPidANN("Ann", "Ann"); - // run->AddTask(trdSetTracksPidAnnTask); - // ---------------------------------------------------- - - // ----------- TRD track Pid Like ---------------------- - // Since in the newest version of this method depends on the global - // track the task has to move after the global tracking - // FU 08.02.12 Switch the task off since the input file needed for the new geometry has to be generated first. - // CbmTrdSetTracksPidLike* trdSetTracksPidLikeTask = - // new CbmTrdSetTracksPidLike("Likelihood", "Likelihood"); - // run->AddTask(trdSetTracksPidLikeTask); - // ---------------------------------------------------- - - - // ========================================================================= - // === RICH reconstruction === - // ========================================================================= - - if (richGeom.Length() != 0) // if RICH is defined - { - // ---------------------RICH Hit Producer ---------------------------------- - CbmRichHitProducer* richHitProd = new CbmRichHitProducer(); - run->AddTask(richHitProd); - - /* - CbmRichHitProducer* richHitProd = new CbmRichHitProducer(); - richHitProd->SetDetectorType(4); - richHitProd->SetNofNoiseHits(220); - richHitProd->SetCollectionEfficiency(1.0); - richHitProd->SetSigmaMirror(0.06); - run->AddTask(richHitProd); -*/ - //-------------------------------------------------------------------------- - - //--------------------- RICH Reconstruction ---------------------------------- - CbmRichReconstruction* richReco = new CbmRichReconstruction(); - run->AddTask(richReco); - - // ------------------- RICH Ring matching --------------------------------- - // CbmRichMatchRings* matchRings = new CbmRichMatchRings(); - // run->AddTask(matchRings); - // ------------------------------------------------------------------------- + // ----- Reconstruction tasks ----------------------------------------- + std::cout << std::endl; + macroName = srcDir + "/macro/mcbm/modules/reconstruct.C"; + std::cout << "Loading macro " << macroName << std::endl; + gROOT->LoadMacro(macroName); + Bool_t recoSuccess = gROOT->ProcessLine("reconstruct()"); + if ( ! recoSuccess ) { + std::cerr << "-E-" << myName << ": error in executing " << macroName + << std::endl; + return; } - // === End of RICH local reconstruction === - // ========================================================================= - - - /* - // ========================================================================= - // === ECAL reconstruction === - // ========================================================================= - - // ----- ECAL hit producer ---------------------------------------------- - CbmEcalHitProducerFastMC* ecalHitProd = new CbmEcalHitProducerFastMC( - "ECAL Hitproducer"); - run->AddTask(ecalHitProd); - // ------------------------------------------------------------------------- - - // === End of ECAL reconstruction === - // ========================================================================= - -*/ - + std::cout << "-I-" << myName << ": " << macroName << " excuted successfully" + << std::endl; + // ------------------------------------------------------------------------ // ========================================================================= // === Matching to Monte-carlo === // ========================================================================= - // CbmMatchRecoToMC* matchTask = new CbmMatchRecoToMC(); - // run->AddTask(matchTask); - // === End of matching to Monte-Carlo === - // ========================================================================= - + /* + CbmMatchRecoToMC* matchTask = new CbmMatchRecoToMC(); + run->AddTask(matchTask); + // Digitizer/custerizer testing + CbmTofHitFinderQa* tofQa = new CbmTofHitFinderQa("TOF QA"); + tofQa->SetHistoFileName("TofQA.root"); + run->AddTask(tofQa); + */ // ----- Parameter database -------------------------------------------- - FairRuntimeDb* rtdb = run->GetRuntimeDb(); - FairParRootFileIo* parIo1 = new FairParRootFileIo(); + 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()); parIo2->open(parFileList, "in"); @@ -435,12 +170,19 @@ void mcbm_reco_nh(Int_t nEvents = 1000, rtdb->setSecondInput(parIo2); rtdb->setOutput(parIo1); rtdb->saveOutput(); + rtdb->print(); // ------------------------------------------------------------------------ - // ----- Intialise and run -------------------------------------------- + // ----- Run initialisation ------------------------------------------- + std::cout << std::endl; + std::cout << "-I- " << myName << ": Initialise run" << std::endl; run->Init(); - cout << "Starting run" << endl; + // ------------------------------------------------------------------------ + + // ----- Start run ---------------------------------------------------- + std::cout << std::endl << std::endl; + std::cout << "-I- " << myName << ": Starting run" << std::endl; run->Run(0, nEvents); // ------------------------------------------------------------------------ @@ -448,17 +190,37 @@ void mcbm_reco_nh(Int_t nEvents = 1000, timer.Stop(); Double_t rtime = timer.RealTime(); Double_t ctime = timer.CpuTime(); - cout << endl << endl; - cout << "Macro finished succesfully." << endl; - cout << "Output file is " << outFile << endl; - cout << "Parameter file is " << parFile << endl; - cout << "Real time " << rtime << " s, CPU time " << ctime << " s" << endl; - cout << endl; + std::cout << std::endl << std::endl; + std::cout << "Macro finished succesfully." << 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; + std::cout << std::endl; + std::cout << " Test passed" << std::endl; + std::cout << " All ok " << std::endl; // ------------------------------------------------------------------------ - // delete run; + // ----- Resource monitoring ------------------------------------------ + if ( Has_Fair_Monitor() ) { // FairRoot Version >= 15.11 + // Extract the maximal used memory an add is as Dart measurement + // This line is filtered by CTest and the value send to CDash + 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; + + FairMonitor* tempMon = FairMonitor::GetMonitor(); + tempMon->Print(); + } - cout << " Test passed" << endl; - cout << " All ok " << endl; + // Function needed for CTest runtime dependency + Generate_CTest_Dependency_File(depFile); RemoveGeoManager(); } diff --git a/macro/mcbm/mcbm_transport.C b/macro/mcbm/mcbm_transport.C index 301504135e90646e916df1d3736b42d949a10b5b..ea6107fd13ea9411977157c8f47a5983642159f0 100644 --- a/macro/mcbm/mcbm_transport.C +++ b/macro/mcbm/mcbm_transport.C @@ -14,18 +14,18 @@ void SetTrack(CbmTransport*, Double_t, Int_t, Double_t, Double_t, Double_t); -void mcbm_transport( - Int_t nEvents = 10, - const char* setupName = "mcbm_beam_2020_03", - // const char* setupName = "mcbm_beam_2019_11", - // const char* setupName = "mcbm_beam_2019_03", - // const char* setupName = "sis18_mcbm_25deg_long", - const char* output = "test", - const char* inputFile = "") { - // --- Define the beam angle ---------------------------------------------- +void mcbm_transport(Int_t nEvents = 10, + const char* setupName = "mcbm_beam_2020_03", +// const char* setupName = "mcbm_beam_2019_11", +// const char* setupName = "mcbm_beam_2019_03", +// const char* setupName = "sis18_mcbm_25deg_long", + const char* output = "test", + const char* inputFile = "") +{ + // --- Define the beam angle ---------------------------------------------- Double_t beamRotY = 25.; - // ------------------------------------------------------------------------ - + // ------------------------------------------------------------------------ + // --- Define the target geometry ----------------------------------------- // // The target is not part of the setup, since one and the same setup can @@ -36,21 +36,19 @@ void mcbm_transport( // in the responsibility of the user that no overlaps or extrusions are // created by the placement of the target. // - TString targetElement = "Gold"; - Double_t targetPosX = 0.; // target x position in global c.s. [cm] - Double_t targetPosY = 0.; // target y position in global c.s. [cm] - Double_t targetPosZ = 0.; // target z position in global c.s. [cm] - - // Double_t targetThickness = 0.1; // full thickness in cm - // Double_t targetDiameter = 0.5; // diameter in cm - // Double_t targetRotY = 25.; // target rotation angle around the y axis [deg] - - Double_t targetThickness = - 0.025; // mCBM thin gold target 0.25 mm = 0.025 cm thickness - Double_t targetDiameter = 1.5; // mCBM target width 15 mm = 1.5 cm - // Double_t targetDiameter = 0.1; // set small target for window acceptance plots - Double_t targetRotY = - beamRotY; // target rotation angle around the y axis [deg] + TString targetElement = "Gold"; + Double_t targetPosX = 0.; // target x position in global c.s. [cm] + Double_t targetPosY = 0.; // target y position in global c.s. [cm] + Double_t targetPosZ = 0.; // target z position in global c.s. [cm] + +// Double_t targetThickness = 0.1; // full thickness in cm +// Double_t targetDiameter = 0.5; // diameter in cm +// Double_t targetRotY = 25.; // target rotation angle around the y axis [deg] + + Double_t targetThickness = 0.025; // mCBM thin gold target 0.25 mm = 0.025 cm thickness + Double_t targetDiameter = 1.5; // mCBM target width 15 mm = 1.5 cm +// Double_t targetDiameter = 0.1; // set small target for window acceptance plots + Double_t targetRotY = beamRotY; // target rotation angle around the y axis [deg] // ------------------------------------------------------------------------ // --- Logger settings ---------------------------------------------------- @@ -71,17 +69,21 @@ void mcbm_transport( TString parFile = dataset + ".par.root"; TString geoFile = dataset + ".geo.root"; std::cout << std::endl; - TString defaultInputFile = - srcDir + "/input/urqmd.agag.1.65gev.centr.00001.root"; + TString defaultInputFile = srcDir + "/input/urqmd.agag.1.65gev.centr.00001.root"; TString inFile; - if (strcmp(inputFile, "") == 0) - inFile = defaultInputFile; - else - inFile = inputFile; - std::cout << "-I- " << myName << ": Using input file " << inFile << std::endl; + if( dataset.Contains("lam") ) { + std::cout << "-I- " << myName << ": Generate Lambda " + << std::endl; + } else { + if ( strcmp(inputFile, "") == 0 ) inFile = defaultInputFile; + else inFile = inputFile; + std::cout << "-I- " << myName << ": Using input file " << inFile + << std::endl; + } // ------------------------------------------------------------------------ + // ----- Timer -------------------------------------------------------- TStopwatch timer; timer.Start(); @@ -91,106 +93,101 @@ void mcbm_transport( // --- Transport run ---------------------------------------------------- CbmTransport run; - // DE run.AddInput(new FairParticleGenerator(2212, 1, 0., 0., 1.)); // single proton along beam axis +// DE run.AddInput(new FairParticleGenerator(2212, 1, 0., 0., 1.)); // single proton along beam axis - // ACC // geometrical acceptance - // - // ACC // mSTS station 0 - // ACC SetTrack(&run, beamRotY,-13, -5.9, +5.8, 28.5); - // ACC SetTrack(&run, beamRotY,-13, -5.9, 0.0, 28.5); - // ACC SetTrack(&run, beamRotY,-13, -5.9, -5.8, 28.5); - // ACC // - // ACC SetTrack(&run, beamRotY, 11, 0.0, +5.8, 28.5); - // ACC SetTrack(&run, beamRotY, 11, 0.0, 0.0, 28.5); - // ACC SetTrack(&run, beamRotY, 11, 0.0, -5.8, 28.5); - // ACC // - // ACC SetTrack(&run, beamRotY,-11, +5.9, +5.8, 28.5); - // ACC SetTrack(&run, beamRotY,-11, +5.9, 0.0, 28.5); - // ACC SetTrack(&run, beamRotY,-11, +5.9, -5.8, 28.5); - // - // WIN // x : cos(25.*acos(-1.)/180.) * -4.25 : x = -3.852 cm - // WIN // z : sin(25.*acos(-1.)/180.) * -4.25 + 15.2 + 0.3 : z = 13.704 cm - // WIN // SetTrack(&run, 0, 13, -3.852, 0.0, 13.704); - // WIN SetTrack(&run, 0, 13, -8.0, +5.9, 27.5); - // WIN SetTrack(&run, 0, 13, -8.0, 0.0, 27.5); - // WIN SetTrack(&run, 0, 13, -8.0, -5.9, 27.5); - // WIN // - // WIN // x : cos(25.*acos(-1.)/180.) * -15.75 : x = -14.274 cm - // WIN // z : sin(25.*acos(-1.)/180.) * -15.75 + 15.2 + 0.3 : z = 8.843 cm - // WIN // SetTrack(&run, 0,-13, -14.274, 0.0, 8.843); - // WIN SetTrack(&run, 0, 13, -41.5, +5.9, 27.5); - // WIN SetTrack(&run, 0, 13, -41.5, 0.0, 27.5); - // WIN SetTrack(&run, 0, 13, -41.5, -5.9, 27.5); - // - // ACC // mSTS station 1 - // ACC SetTrack(&run, beamRotY,-13, -8.9, +8.7, 42.5); - // ACC SetTrack(&run, beamRotY,-13, -8.9, 0.0, 42.5); - // ACC SetTrack(&run, beamRotY,-13, -8.9, -8.7, 42.5); - // ACC // - // ACC SetTrack(&run, beamRotY, 11, 0.0, +8.7, 42.5); - // ACC SetTrack(&run, beamRotY, 11, 0.0, 0.0, 42.5); - // ACC SetTrack(&run, beamRotY, 11, 0.0, -8.7, 42.5); - // ACC // - // ACC SetTrack(&run, beamRotY,-11, +8.9, +8.7, 42.5); - // ACC SetTrack(&run, beamRotY,-11, +8.9, 0.0, 42.5); - // ACC SetTrack(&run, beamRotY,-11, +8.9, -8.7, 42.5); - // - // STS // mSTS 201903 active area - // STS SetTrack(&run, beamRotY,-11, -2.1, -5.9, 27.5); - // STS SetTrack(&run, beamRotY,-11, -2.5, -3.0, 27.5); - // STS SetTrack(&run, beamRotY,-11, -2.9, -0.1, 27.5); - // STS SetTrack(&run, beamRotY,-11, -2.9, -3.0, 27.5); - // STS SetTrack(&run, beamRotY,-11, -2.9, -5.9, 27.5); - // STS - // STS SetTrack(&run, beamRotY, 11, -5.1, -5.9, 27.5); - // STS SetTrack(&run, beamRotY, 11, -5.5, -3.0, 27.5); - // STS SetTrack(&run, beamRotY, 11, -5.9, -0.1, 27.5); - // STS SetTrack(&run, beamRotY, 11, -5.9, -3.0, 27.5); - // STS SetTrack(&run, beamRotY, 11, -5.9, -5.9, 27.5); - - // comment the following line to remove target interaction +// ACC // geometrical acceptance +// +// ACC // mSTS station 0 +// ACC SetTrack(&run, beamRotY,-13, -5.9, +5.8, 28.5); +// ACC SetTrack(&run, beamRotY,-13, -5.9, 0.0, 28.5); +// ACC SetTrack(&run, beamRotY,-13, -5.9, -5.8, 28.5); +// ACC // +// ACC SetTrack(&run, beamRotY, 11, 0.0, +5.8, 28.5); +// ACC SetTrack(&run, beamRotY, 11, 0.0, 0.0, 28.5); +// ACC SetTrack(&run, beamRotY, 11, 0.0, -5.8, 28.5); +// ACC // +// ACC SetTrack(&run, beamRotY,-11, +5.9, +5.8, 28.5); +// ACC SetTrack(&run, beamRotY,-11, +5.9, 0.0, 28.5); +// ACC SetTrack(&run, beamRotY,-11, +5.9, -5.8, 28.5); +// +// WIN // x : cos(25.*acos(-1.)/180.) * -4.25 : x = -3.852 cm +// WIN // z : sin(25.*acos(-1.)/180.) * -4.25 + 15.2 + 0.3 : z = 13.704 cm +// WIN // SetTrack(&run, 0, 13, -3.852, 0.0, 13.704); +// WIN SetTrack(&run, 0, 13, -8.0, +5.9, 27.5); +// WIN SetTrack(&run, 0, 13, -8.0, 0.0, 27.5); +// WIN SetTrack(&run, 0, 13, -8.0, -5.9, 27.5); +// WIN // +// WIN // x : cos(25.*acos(-1.)/180.) * -15.75 : x = -14.274 cm +// WIN // z : sin(25.*acos(-1.)/180.) * -15.75 + 15.2 + 0.3 : z = 8.843 cm +// WIN // SetTrack(&run, 0,-13, -14.274, 0.0, 8.843); +// WIN SetTrack(&run, 0, 13, -41.5, +5.9, 27.5); +// WIN SetTrack(&run, 0, 13, -41.5, 0.0, 27.5); +// WIN SetTrack(&run, 0, 13, -41.5, -5.9, 27.5); +// +// ACC // mSTS station 1 +// ACC SetTrack(&run, beamRotY,-13, -8.9, +8.7, 42.5); +// ACC SetTrack(&run, beamRotY,-13, -8.9, 0.0, 42.5); +// ACC SetTrack(&run, beamRotY,-13, -8.9, -8.7, 42.5); +// ACC // +// ACC SetTrack(&run, beamRotY, 11, 0.0, +8.7, 42.5); +// ACC SetTrack(&run, beamRotY, 11, 0.0, 0.0, 42.5); +// ACC SetTrack(&run, beamRotY, 11, 0.0, -8.7, 42.5); +// ACC // +// ACC SetTrack(&run, beamRotY,-11, +8.9, +8.7, 42.5); +// ACC SetTrack(&run, beamRotY,-11, +8.9, 0.0, 42.5); +// ACC SetTrack(&run, beamRotY,-11, +8.9, -8.7, 42.5); +// +// STS // mSTS 201903 active area +// STS SetTrack(&run, beamRotY,-11, -2.1, -5.9, 27.5); +// STS SetTrack(&run, beamRotY,-11, -2.5, -3.0, 27.5); +// STS SetTrack(&run, beamRotY,-11, -2.9, -0.1, 27.5); +// STS SetTrack(&run, beamRotY,-11, -2.9, -3.0, 27.5); +// STS SetTrack(&run, beamRotY,-11, -2.9, -5.9, 27.5); +// STS +// STS SetTrack(&run, beamRotY, 11, -5.1, -5.9, 27.5); +// STS SetTrack(&run, beamRotY, 11, -5.5, -3.0, 27.5); +// STS SetTrack(&run, beamRotY, 11, -5.9, -0.1, 27.5); +// STS SetTrack(&run, beamRotY, 11, -5.9, -3.0, 27.5); +// STS SetTrack(&run, beamRotY, 11, -5.9, -5.9, 27.5); + +// comment the following line to remove target interaction run.AddInput(inFile); run.SetOutFileName(outFile); run.SetParFileName(parFile); run.SetGeoFileName(geoFile); run.LoadSetup(setupName); run.SetField(new CbmFieldConst()); - run.SetTarget(targetElement, - targetThickness, - targetDiameter, - targetPosX, - targetPosY, - targetPosZ, - targetRotY * TMath::DegToRad()); - run.SetBeamPosition(0., 0., 0.1, 0.1); // Beam width 1 mm is assumed + run.SetTarget(targetElement, targetThickness, targetDiameter, + targetPosX, targetPosY, targetPosZ, + targetRotY*TMath::DegToRad()); + run.SetBeamPosition(0., 0., 0.1, 0.1); // Beam width 1 mm is assumed run.SetBeamAngle(beamRotY * TMath::DegToRad(), 0.); //run.StoreTrajectories(); run.Run(nEvents); // ------------------------------------------------------------------------ - + // ----- Finish ------------------------------------------------------- timer.Stop(); 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 << "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 - << std::endl; + std::cout << "Real time " << rtime << " s, CPU time " << ctime + << "s" << std::endl << std::endl; // ------------------------------------------------------------------------ // ----- Resource monitoring ------------------------------------------ FairSystemInfo sysInfo; - Float_t maxMemory = sysInfo.GetMaxMemory(); + 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; + Float_t cpuUsage=ctime/rtime; std::cout << "<DartMeasurement name=\"CpuLoad\" type=\"numeric/double\">"; std::cout << cpuUsage; std::cout << "</DartMeasurement>" << std::endl; @@ -202,17 +199,12 @@ void mcbm_transport( } -void SetTrack(CbmTransport* run, - Double_t beamRotY, - Int_t pdgid, - Double_t x, - Double_t y, - Double_t z) { +void SetTrack(CbmTransport* run, Double_t beamRotY, Int_t pdgid, Double_t x, Double_t y, Double_t z) +{ TVector3 v; - v.SetXYZ(x, y, z); + v.SetXYZ( x, y, z ); v.RotateY(-beamRotY * acos(-1.) / 180.); cout << "X " << v.X() << " Y " << v.Y() << " Z " << v.Z() << endl; - run->AddInput(new FairParticleGenerator( - pdgid, 1, v.X(), v.Y(), v.Z())); // single electron along beam axis + run->AddInput(new FairParticleGenerator( pdgid, 1, v.X(), v.Y(), v.Z() )); // single electron along beam axis } diff --git a/macro/mcbm/mcbm_transport_nh.C b/macro/mcbm/mcbm_transport_nh.C new file mode 100644 index 0000000000000000000000000000000000000000..0e89f198543bcda12f5239dbf75126446c16dc55 --- /dev/null +++ b/macro/mcbm/mcbm_transport_nh.C @@ -0,0 +1,204 @@ +// -------------------------------------------------------------------------- +// +// Macro for standard transport simulation in mCBM using UrQMD input and GEANT3 +// +// V. Friese 15/07/2018 +// +// The output file will be named [output].tra.root. +// A parameter file [output].par.root will be created. +// The geometry (TGeoManager) will be written into [output].geo.root. +// +// Specify the input file by the last argument. If none is specified, +// a default input file distributed with the source code will be used. +// -------------------------------------------------------------------------- +// Includes needed for IDE +#if !defined(__CLING__) +#include "TStopwatch.h" +#include "FairSystemInfo.h" +#include "CbmTransport.h" +#endif + +void SetTrack(CbmTransport*, Double_t, Int_t, Double_t, Double_t, Double_t); + +void mcbm_transport_nh(Int_t nEvents = 10, + const char* setupName = "mcbm_beam_2021_03", +// const char* setupName = "mcbm_beam_2019_11", +// const char* setupName = "mcbm_beam_2019_03", +// const char* setupName = "sis18_mcbm_25deg_long", + const char* output = "data/test", + const char* inputFile = "") +{ + // --- Logger settings ---------------------------------------------------- + FairLogger::GetLogger()->SetLogScreenLevel("WARN"); + FairLogger::GetLogger()->SetLogVerbosityLevel("VERYHIGH"); + // ------------------------------------------------------------------------ + + // ----- Environment -------------------------------------------------- + TString myName = "mcbm_transport"; // this macro's name for screen output + TString srcDir = gSystem->Getenv("VMCWORKDIR"); // top source directory + // ------------------------------------------------------------------------ + + // --- Define the beam angle ---------------------------------------------- + Double_t beamRotY = 25.; + // ------------------------------------------------------------------------ + + // --- Define the target geometry ----------------------------------------- + // + // The target is not part of the setup, since one and the same setup can + // and will be used with different targets. + // The target is constructed as a tube in z direction with the specified + // diameter (in x and y) and thickness (in z). It will be placed at the + // specified position as daughter volume of the volume present there. It is + // in the responsibility of the user that no overlaps or extrusions are + // created by the placement of the target. + // + TString targetElement = "Gold"; + TString Output (output); + if ( ! Output.Contains("auau") ) { + if ( Output.Contains("nini") ) + targetElement = "Nickel"; + else { + if( Output.Contains("lam") ) { + std::cout << "Lambda signal simulation " << std::endl; + } else { + std::cout << "Collision system " << Output << " not known." << std::endl; + exit(1); + } + } +} + /* + if ( system.CompareTo("auau") ) { + if ( ! system.CompareTo("nini") ) { + targetElement = "Nickel"; + } else { + std::cout << "Collision syste " << system << " not known." << std::endl; + exit(1); + } + } + */ + + Double_t targetPosX = 0.; // target x position in global c.s. [cm] + Double_t targetPosY = 0.; // target y position in global c.s. [cm] + Double_t targetPosZ = 0.; // target z position in global c.s. [cm] + +// Double_t targetThickness = 0.1; // full thickness in cm +// Double_t targetDiameter = 0.5; // diameter in cm +// Double_t targetRotY = 25.; // target rotation angle around the y axis [deg] + + Double_t targetThickness = 0.025; // mCBM thin gold target 0.25 mm = 0.025 cm thickness + Double_t targetDiameter = 1.5; // mCBM target width 15 mm = 1.5 cm +// Double_t targetDiameter = 0.1; // set small target for window acceptance plots + Double_t targetRotY = beamRotY; // target rotation angle around the y axis [deg] + // ------------------------------------------------------------------------ + + // ----- In- and output file names ------------------------------------ + TString dataset(output); + TString outFile = dataset + ".tra.root"; + TString parFile = dataset + ".par.root"; + TString geoFile = dataset + ".geo.root"; + std::cout << " dataset: " << dataset << std::endl; + + // cleanup + TString shcmd = "rm -v " + parFile + " " + outFile + " " + geoFile; + gSystem->Exec( shcmd.Data() ); + + TString defaultInputFile = srcDir + "/input/urqmd.agag.1.65gev.centr.00001.root"; + TString inFile; + + CbmTransport run; + + if( dataset.Contains("lam") ) { + //(pdg,mul,px, py, pz, vx,vy,vz) + Double_t pz=2.; + Int_t iL=dataset.Index("gev"); + TString cp=dataset(iL-3,3); // 2 characters only + pz=cp.Atof(); + //std::cout<<"iL = "<<iL<<" "<<cp<<" "<<pz<<std::endl; + //sscanf(cEbeam,"%lfgev",&pz); + std::cout<<"simulate single lambda with pz = "<<pz<<" from " << dataset << std::endl; + //FairParticleGenerator *fPartGen= new FairParticleGenerator(3122, 1,0.0,0., pz, 0.,0.,0.); //lambda + // primGen->AddGenerator(fPartGen); + + SetTrack(&run, beamRotY, 3122, 0.0, 0.0, pz); + std::cout << "-I- " << myName << ": Generate Lambda " << std::endl; + } else { + if ( strcmp(inputFile, "") == 0 ) inFile = defaultInputFile; + else inFile = inputFile; + std::cout << "-I- " << myName << ": Using input file " << inFile + << std::endl; + run.AddInput(inFile); + } + + std::cout << "-I- " << myName << ": Using output file " << outFile + << std::endl; + std::cout << "-I- " << myName << ": Using parameter file " << parFile + << std::endl; + std::cout << "-I- " << myName << ": Using geometry file " << geoFile + << std::endl; + // ------------------------------------------------------------------------ + + // ----- Timer -------------------------------------------------------- + TStopwatch timer; + timer.Start(); + // ------------------------------------------------------------------------ + + + // --- Transport run ---------------------------------------------------- + + run.SetOutFileName(outFile); + run.SetParFileName(parFile); + run.SetGeoFileName(geoFile); + run.LoadSetup(setupName); + run.SetField(new CbmFieldConst()); + run.SetTarget(targetElement, targetThickness, targetDiameter, + targetPosX, targetPosY, targetPosZ, + targetRotY*TMath::DegToRad()); + run.SetBeamPosition(0., 0., 0.1, 0.1); // Beam width 1 mm is assumed + run.SetBeamAngle(beamRotY * TMath::DegToRad(), 0.,0.,0.); + run.SetRandomEventPlane(); + //run.StoreTrajectories(); + run.Run(nEvents); + // ------------------------------------------------------------------------ + + + // ----- Finish ------------------------------------------------------- + timer.Stop(); + 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 << std::endl; + // ------------------------------------------------------------------------ + + + // ----- Resource monitoring ------------------------------------------ + 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; + + + std::cout << " Test passed" << std::endl; + std::cout << " All ok " << std::endl; + // ------------------------------------------------------------------------ +} + + +void SetTrack(CbmTransport* run, Double_t beamRotY, Int_t pdgid, Double_t x, Double_t y, Double_t z) +{ + TVector3 v; + v.SetXYZ( x, y, z ); + v.RotateY(-beamRotY * acos(-1.) / 180.); + cout << "X " << v.X() << " Y " << v.Y() << " Z " << v.Z() << endl; + + run->AddInput(new FairParticleGenerator( pdgid, 1, v.X(), v.Y(), v.Z() )); // single electron along beam axis +} diff --git a/macro/mcbm/pl_lambda.C b/macro/mcbm/pl_lambda.C new file mode 100755 index 0000000000000000000000000000000000000000..50797a37e64bc31d80f2ec3bce4d4eef0f117a83 --- /dev/null +++ b/macro/mcbm/pl_lambda.C @@ -0,0 +1,261 @@ +void pl_lambda(Double_t sf=0.){ + // TCanvas *can = new TCanvas("can22","can22"); + // can->Divide(2,2); + TCanvas *can = new TCanvas("can","can",50,0,900,900); + can->Divide(3,4); + +gPad->SetFillColor(0); +gStyle->SetPalette(1); +gStyle->SetOptStat(kTRUE); +gStyle->SetOptFit(1111); + + gROOT->cd(); + gROOT->SetDirLevel(1); + + TH1 *h; + TH1 *h1; + TH2 *h2; + TH1 *hMinvall; + + // if (h!=NULL) h->Delete(); + +can->cd(1); + gROOT->cd(); + TString hname1=Form("hDperp"); + h1=(TH1 *)gROOT->FindObjectAny(hname1); + if (h1!=NULL) { + h1->Draw(); + //gPad->SetLogz(); + }else { cout << hname1 << " not found -> return" << endl; return;} + +can->cd(2); + gROOT->cd(); + + TString hname2=Form("hDperp2"); + h1=(TH1 *)gROOT->FindObjectAny(hname2); + if (h1!=NULL) { + h1->Draw(); + //gPad->SetLogz(); + } + +can->cd(3); + gROOT->cd(); + TString hname3=Form("hDperpS"); + h1=(TH1 *)gROOT->FindObjectAny(hname3); + if (h1!=NULL) { + h1->Draw(); + //gPad->SetLogz(); + }else { cout << hname3 << " not found" << endl; } + +can->cd(4); + gROOT->cd(); + TString hname4=Form("hD0prim"); + h1=(TH1 *)gROOT->FindObjectAny(hname4); + if (h1!=NULL) { + h1->Draw(); + //gPad->SetLogz(); + }else { cout << hname4 << " not found" << endl; } + +can->cd(7); + gROOT->cd(); + TString hname7=Form("hMinv"); + h1=(TH1 *)gROOT->FindObjectAny(hname7); + if (h1!=NULL) { + h1->Draw(); + h1->SetLineColor(4); + hname7="hMinvall"; + hMinvall=(TH1 *)gROOT->FindObjectAny(hname7); + if(NULL != hMinvall) hMinvall->Delete(); + hMinvall=(TH1 *)h1->Clone(); + hMinvall->SetName("hMinvall"); + hMinvall->SetTitle("hMinvall"); + + hname7="hMIXMinv"; + h=(TH1 *)gROOT->FindObjectAny(hname7); + if(sf==0) { // find proper MIX scaling factor + Double_t NML=1.090; + Double_t NMH=1.097; + Double_t dComb=h1->Integral(h1->FindBin(NML),h1->FindBin(NMH)); + Double_t dMix =h->Integral(h->FindBin(NML),h->FindBin(NMH)); + sf=dComb/dMix; + cout<<"Normalization factor sf = "<<sf<<endl; + } + h->Scale(sf); + h->Draw("same"); + h->SetLineColor(7); + + hname7="hMinvdif"; + TH1 *hMinvdif=(TH1 *)gROOT->FindObjectAny(hname7); + if(NULL != hMinvdif) hMinvdif->Delete(); + hMinvdif=(TH1 *)h1->Clone(); + hMinvdif->Add(h1,h,1.,-1.); + hMinvdif->SetName("hMinvdif"); + hMinvdif->SetTitle("hMinvdif"); + hMinvdif->Draw("same"); + hMinvdif->SetLineColor(3); + //gPad->SetLogz(); + + }else { cout << hname7 << " not found" << endl; } + +can->cd(5); + gROOT->cd(); + TString hname5=Form("hOpAng"); + h1=(TH1 *)gROOT->FindObjectAny(hname5); + if (h1!=NULL) { + h1->Draw(); + gPad->SetLogy(); + hname5="hMIXOpAng"; + h=(TH1 *)gROOT->FindObjectAny(hname5); + h->Draw("same"); + h->Scale(sf); + h->SetLineColor(7); + }else { cout << hname5 << " not found" << endl; } + +can->cd(6); + gROOT->cd(); + TString hname6=Form("hDCA"); + h1=(TH1 *)gROOT->FindObjectAny(hname6); + if (h1!=NULL) { + h1->Draw(); + hname6="hMIXDCA"; + h=(TH1 *)gROOT->FindObjectAny(hname6); + h->Scale(sf); + h->Draw("same"); + h->SetLineColor(7); + gPad->SetLogy(); + }else { cout << hname6 << " not found" << endl; } + +can->cd(8); + gROOT->cd(); + TString hname8=Form("hPathLen"); + h1=(TH1 *)gROOT->FindObjectAny(hname8); + if (h1!=NULL) { + h1->Draw(); + hname8="hMIXPathLen"; + h=(TH1 *)gROOT->FindObjectAny(hname8); + h->Scale(sf); + h->Draw("same"); + h->SetLineColor(7); + hname8="hMCPathLen"; + TH1 *hMC=(TH1 *)gROOT->FindObjectAny(hname8); + hMC->Draw("same"); + hMC->SetLineColor(2); + + hname8="hLdif"; + TH1 *hLdif=(TH1 *)gROOT->FindObjectAny(hname8); + if(NULL != hLdif) hLdif->Delete(); + hLdif=(TH1 *)h1->Clone(); + hLdif->Add(h1,h,1.,-1.); + hLdif->SetName("hLdif"); + hLdif->SetTitle("hLdif"); + hLdif->Draw("same"); + hLdif->SetLineColor(3); + //gPad->SetLogz(); + }else { cout << hname8 << " not found" << endl; } + +can->cd(9); + gROOT->cd(); + TString hname9=Form("hMMom"); + h1=(TH1 *)gROOT->FindObjectAny(hname9); + Double_t dNLamPrim=0; + if (h1!=NULL) { + + hname9="hMCLamMom"; + TH1 *h=(TH1 *)gROOT->FindObjectAny(hname9); + dNLamPrim=h->GetEntries(); + if(h->GetEntries()>0) { + h->SetMinimum(0.1); + h->Draw(); + h1->Draw("same"); + h->SetLineColor(kRed); + }else{ + h1->Draw(); + } + hname9="hMIXMMom"; + h=(TH1 *)gROOT->FindObjectAny(hname9); + h->Draw("same"); + h->Scale(sf); + h->SetLineColor(7); + + hname9="hMomdif"; + TH1 *hMomdif=(TH1 *)gROOT->FindObjectAny(hname9); + if(NULL != hMomdif) hMomdif->Delete(); + hMomdif=(TH1 *)h1->Clone(); + hMomdif->Add(h1,h,1.,-1.); + hMomdif->SetName("hMomdif"); + hMomdif->SetTitle("hMomdif"); + hMomdif->Draw("same"); + hMomdif->SetLineColor(3); + + gPad->SetLogy(); + + }else { cout << hname9 << " not found" << endl; } + +can->cd(10); + TString hname10=Form("hMinvdif"); + h1=(TH1 *)gROOT->FindObjectAny(hname10); + if (h1!=NULL) { + TF1 *fSignal=(TF1 *)gROOT->FindObjectAny("fSignal"); + if(NULL != fSignal) fSignal->Delete(); + fSignal=new TF1("fSignal","gaus",1.090,1.140); + //h1->Fit("gaus","","H",1.1,1.2); + Double_t MMin=1.09; + Double_t MMax=1.142; + Double_t param[3]; + param[0]=h1->GetMaximum(); + param[1]=1.1156; + param[2]=0.01; + fSignal->SetParameters(param); + h1->Fit("fSignal","","",MMin,MMax); + gPad->SetGrid(); + fSignal->GetParameters(param); + Double_t MMEAN=param[1]; + Double_t MSIG =param[2]; + Double_t dFRange=2.5; + MMin=MMEAN-dFRange*MSIG; + MMax=MMEAN+dFRange*MSIG; + cout<<" Fit results: "<<MMEAN<<", "<<MSIG<<", new range: "<<MMin<<" - "<<MMax<<endl; + h1->Fit("fSignal","","",MMin,MMax); + fSignal->GetParameters(param); + MMEAN=param[1]; + MSIG =param[2]; + cout<<" Fit results: "<<MMEAN<<", "<<MSIG<<endl; + Double_t dSignal=h1->Integral(h1->FindBin(MMin),h1->FindBin(MMax)); + Double_t dAll=hMinvall->Integral(hMinvall->FindBin(MMin),hMinvall->FindBin(MMax)); + Double_t dBckgd=dAll-dSignal; + Double_t SoB=dSignal/dBckgd; + Double_t Signif=dSignal/TMath::Sqrt(dAll); + cout << "Integral counts in Signal ["<<MMin<<","<<MMax<<"] "<<h1->Integral(h1->FindBin(MMin),h1->FindBin(MMax))<<endl; + cout << "Integral counts in Signal + Bckgrd[] "<<hMinvall->Integral(hMinvall->FindBin(MMin),hMinvall->FindBin(MMax))<<endl; + cout << "Signal over background: "<<SoB<<endl; + cout << "Significance: "<<Signif<<endl; + cout << "Acc * eff = "<< dSignal/dNLamPrim << endl; + TH2 *h2=(TH2 *)gROOT->FindObjectAny("mul_b_gen"); + if(h2 != NULL) + cout << "Total number of events "<<h2->GetEntries()<<endl; + else + cout << "Total number of input events not available"<<endl; + } + +can->cd(11); + TString hname11=Form("hLdif"); + h1=(TH1 *)gROOT->FindObjectAny(hname11); + if (h1!=NULL) { + h1->Draw(); + // h1->Fit("gaus","","H",1.1,1.2); + } + +can->cd(12); + TString hname12=Form("hMomdif"); + h1=(TH1 *)gROOT->FindObjectAny(hname12); + if (h1!=NULL) { + h1->Draw(); + //h1->Fit("gaus","","H",1.1,1.2); + } + // gStyle->SetOptStat(0); + //can->Update(); + + + can->SaveAs(Form("pl_lambda.pdf")); + +} diff --git a/macro/mcbm/run_mcbm.sh b/macro/mcbm/run_mcbm.sh index 7c7ecff0a3073bea815ad173ab1691a29d976f25..cd2af4ce4add13e2fad9c258bb02c771fd781cb4 100755 --- a/macro/mcbm/run_mcbm.sh +++ b/macro/mcbm/run_mcbm.sh @@ -1,45 +1,118 @@ #!/bin/bash #SBATCH -J run_mcbm -#SBATCH -D /lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/macro/mcbm +#SBATCH -D /lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/mcbm #SBATCH --time=8:00:00 ##SBATCH --mem=2000 ##SBATCH --partition=long +##SBATCH --partition=debug X=$((${SLURM_ARRAY_TASK_ID} - 0)) -XXX=$(printf "%03d" "$X") +if [ $X -eq 0 ]; then +X=1 +fi + +XXX=$(printf "%05d" "$X") +Sys=$1 if [[ ${Sys} = "" ]]; then -Sys="$1" +Sys="nini" fi +Ebeam=$2 if [[ ${Ebeam} = "" ]]; then -Ebeam="$2" +Ebeam="1.93gev" fi +Centr=$3 if [[ ${Centr} = "" ]]; then -Centr="$3" +Centr="mbias" fi -if [[ ${TofGeo} = "" ]]; then -mcbmGeo="$4" +mcbmGeo=$4 +if [[ ${mcbmGeo} = "" ]]; then +mcbmGeo="mcbm_beam_2021_03" fi +cMode=$5 +if [[ ${cMode} = "" ]]; then +cMode="0E0" +fi + +iStep=${cMode:0:1} +iBase=${cMode:1:1} +iCut=${cMode:2:1} + +echo simulate Step $iStep with Base $iBase and cut $iCut -if [[ -e /lustre/nyx ]]; then -source /lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/build6/config.sh +EvtRate=1.e6 # 1/s +TSLength=1.e4 # ns +Tint=100. # ns +ReqTofMul=2 +#NEvt=10 # for debugging +NEvt=100000 # for production -export wdir=/lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/macro/mcbm -export outdir=/lustre/nyx/cbm/users/nh/mc +if [ "$iBase" = "T" ]; then + Timebased=kTRUE +else + Timebased=kFALSE +fi + +if [[ -e /lustre ]]; then + source /lustre/cbm/users/nh/CBM/cbmroot/trunk/build/config.sh + export wdir=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/mcbm + export outdir=/lustre/cbm/users/nh/mc/mcbm2021 + export indir=/lustre/cbm/prod/gen/urqmd +# export extdir=/lustre/cbm/users/uhlig/mcbm_proposal/data + export extdir=$outdir + mcfile=${indir}/${Sys}/${Ebeam}/${Centr}/urqmd.${Sys}.${Ebeam}.${Centr}.${XXX}.root else -export wdir=. -export outdir=./data + export wdir=. + export indir=../../input +# export extdir=../../../../../../uhlig/mcbm_proposal/data + export outdir=./data + export extdir=$outdir + mcfile=${indir}/urqmd.${Sys}.${Ebeam}.${Centr}.${XXX}.root fi cd ${wdir} -root -q -b 'mcbm_mc.C(100000,0,"'${Sys}'","'${Ebeam}'","'${Centr}'",'${X}',"'${mcbmGeo}'")' -root -q -b 'mcbm_reco.C(100000,"'${Sys}'","'${Ebeam}'","'${Centr}'",'${X}',"'${mcbmGeo}'")' +RunId=${mcbmGeo}.${Sys}.${Ebeam}.${Centr}.${XXX} +datfile=$outdir/$RunId + +if [ $iStep -gt 2 ]; then + echo Generate file with MC tracking data + root -q -b 'mcbm_transport_nh.C('$NEvt',"'${mcbmGeo}'","'$datfile'","'$mcfile'")' +# exit +fi + +if [[ "$Timebased" = "kTRUE" ]]; then +## time based mode + echo simulate in time based mode + #cp -v $extdir/${RunId}.*par.root $outdir/ + #root -q -b 'mcbm_digi.C('$NEvt',"'$RunId'","'$extdir'","'$outdir'","'${mcbmGeo}'",kFALSE,'$EvtRate','$TSLength')' + if [ $iStep -gt 1 ]; then + root -q -b 'mcbm_digi_nh.C('$NEvt',"'$RunId'","'$outdir'","'$outdir'","'${mcbmGeo}'",kFALSE,'$EvtRate','$TSLength')' + fi + if [ $iStep -gt 0 ]; then + root -q -b 'mcbm_reco_event_tb_nh.C('$NEvt',"'$RunId'","'$outdir'","'$outdir'","'${mcbmGeo}'",kTRUE,'$EvtRate','$TSLength')' + fi + +else +## event mode + echo simulate in event mode + ##cp -v $extdir/${RunId}.*par.root $outdir/ + ##root -q -b 'mcbm_digi.C('$NEvt',"'$RunId'","'$extdir'","'$outdir'","'${mcbmGeo}'",kTRUE,'$EvtRate','$TSLength')' + if [ $iStep -gt 1 ]; then + root -q -b 'mcbm_digi_nh.C('$NEvt',"'$RunId'","'$outdir'","'$outdir'","'${mcbmGeo}'",kTRUE,'$EvtRate','$TSLength')' + fi + if [ $iStep -gt 0 ]; then + root -q -b 'mcbm_reco_event_tb_nh.C('$NEvt',"'$RunId'","'$outdir'","'$outdir'","'${mcbmGeo}'",kFALSE,'$EvtRate','$TSLength')' + fi + #exit +fi +## analysis +# for input from FLorian, use $extdir as 3. argument +root -q -b 'mcbm_hadron_analysis.C('$NEvt',"'$RunId'","'$outdir'","'$outdir'","'${mcbmGeo}'",'$Timebased','$EvtRate','$TSLength','$Tint','$ReqTofMul','$iCut')' -root -q -b 'mcbm_Ana.C(100000,"'${Sys}'","'${Ebeam}'","'${Centr}'",'${X}')' -mv -v slurm-${SLURM_ARRAY_JOB_ID}_${SLURM_ARRAY_TASK_ID}.out ${outdir}/runSTAR_${Sys}_${Ebeam}_${Centr}_$X.out +mv -v slurm-${SLURM_ARRAY_JOB_ID}_${SLURM_ARRAY_TASK_ID}.out ${outdir}/run_${RunId}.out diff --git a/macro/mcbm/run_mcbm2020.sh b/macro/mcbm/run_mcbm2020.sh new file mode 100755 index 0000000000000000000000000000000000000000..846fca9c0fe9a5dc9c6925882d540bb3058bf4e2 --- /dev/null +++ b/macro/mcbm/run_mcbm2020.sh @@ -0,0 +1,151 @@ +#!/bin/bash +#SBATCH -J run_mcbm +#SBATCH -D /lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/mcbm +#SBATCH --time=8:00:00 +##SBATCH --mem=2000 +##SBATCH --partition=long +##SBATCH --partition=debug + +X=$((${SLURM_ARRAY_TASK_ID} - 0)) +if [ $X -eq 0 ]; then +X=1 +fi + +XXX=$(printf "%05d" "$X") + +Sys=$1 +if [[ ${Sys} = "" ]]; then +Sys="auau" +fi + +Ebeam=$2 +if [[ ${Ebeam} = "" ]]; then +Ebeam="1.24gev" +fi + +Centr=$3 +if [[ ${Centr} = "" ]]; then +Centr="mbias" +fi + +mcbmGeo=$4 +if [[ ${mcbmGeo} = "" ]]; then +mcbmGeo="mcbm_beam_2020_03" +fi + +cMode=$5 +if [[ ${cMode} = "" ]]; then +cMode="0E0" +fi + +iStep=${cMode:0:1} +iBase=${cMode:1:1} +iCut=${cMode:2:1} +iRate=${cMode:3:1} + +case $iRate in + 0) + EvtRate=1.0e+05 + ;; + 1) + EvtRate=1.0e+06 + ;; + 2) + EvtRate=1.0e+07 + ;; + *) + EvtRate=1.0e+05 + ;; +esac + +echo simulate Step $iStep with Base $iBase and cut $iCut at rate $EvtRate + +#EvtRate=1.0e+05 # 1/s +TSLength=1.e4 # ns +Tint=100 # ns +ReqTofMul=2 +#NEvt=100 # for debugging +NEvt=100000 # for production + +if [ "$iBase" = "T" ]; then + Timebased=kTRUE +else + Timebased=kFALSE +fi + +if [[ -e /lustre ]]; then + source /lustre/cbm/users/nh/CBM/cbmroot/trunk/build/config.sh + export wdir=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/mcbm + export outdir=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2020/data + export indir=/lustre/cbm/prod/gen/urqmd + export extdir=/lustre/cbm/users/uhlig/mcbm_proposal/data +else + export wdir=. + export indir=../../input + export extdir=../../../../../../uhlig/mcbm_proposal/data + export outdir=./data +fi + +cd ${wdir} + +mcfile=${indir}/${Sys}/${Ebeam}/${Centr}/urqmd.${Sys}.${Ebeam}.${Centr}.${XXX}.root +RunId=${mcbmGeo}.${Sys}.${Ebeam}.${Centr}.${XXX} +datfile=$outdir/$RunId + +if [ ! -e $outdir ]; then + echo create outdir $outdir + mkdir $outdir +fi + +if [ $iStep -gt 2 ]; then + echo Generate file with MC tracking data + root -q -b 'mcbm_transport.C('$NEvt',"'${mcbmGeo}'","'$datfile'","'$mcfile'")' +# exit +fi + +if [[ "$Timebased" = "kTRUE" ]]; then +## time based mode + echo simulate in time based mode + #cp -v $extdir/${RunId}.*par.root $outdir/ + #root -q -b 'mcbm_digi.C('$NEvt',"'$RunId'","'$extdir'","'$outdir'","'${mcbmGeo}'",kFALSE,'$EvtRate','$TSLength')' + if [ $iStep -gt 1 ]; then + root -q -b 'mcbm_digi.C('$NEvt',"'$RunId'","'$outdir'","'$outdir'","'${mcbmGeo}'",kFALSE,'$EvtRate','$TSLength')' + fi + if [ $iStep -gt 0 ]; then + root -q -b 'mcbm_reco_event_tb.C('$NEvt',"'$RunId'","'$outdir'","'$outdir'","'${mcbmGeo}'",kTRUE,'$EvtRate','$TSLength')' + fi + RunId=$RunId.$EvtRate.$Tint.$ReqTofMul +else +## event mode + echo simulate in event mode + ##cp -v $extdir/${RunId}.*par.root $outdir/ + ##root -q -b 'mcbm_digi.C('$NEvt',"'$RunId'","'$extdir'","'$outdir'","'${mcbmGeo}'",kTRUE,'$EvtRate','$TSLength')' + if [ $iStep -gt 1 ]; then + root -q -b 'mcbm_digi.C('$NEvt',"'$RunId'","'$outdir'","'$outdir'","'${mcbmGeo}'",kTRUE,'$EvtRate','$TSLength')' + fi + if [ $iStep -gt 0 ]; then + root -q -b 'mcbm_reco_event_tb.C('$NEvt',"'$RunId'","'$outdir'","'$outdir'","'${mcbmGeo}'",kFALSE,'$EvtRate','$TSLength')' + fi + #exit +fi + +## analysis +echo Analyze $RunId + +cd $outdir +ln -s mcbm*93_1tofClust.hst.root ../ +cd .. +echo execute analysis in directory `pwd` +#cp ../.rootrc . +#cp ../rootlogon.C . +if [ ! -e data ]; then + mkdir data +fi + +root -l './ana_trks_eval.C('$NEvt',30040,4,"'$RunId'","030040500_500",500,1,3.2,5.2,50,"XXX",1,1,30040500,0,1)' + +# for input from FLorian, use $extdir as 3. argument +#root -q -b 'mcbm_hadron_analysis.C('$NEvt',"'$RunId'","'$outdir'","'$outdir'","'${mcbmGeo}'",'$Timebased','$EvtRate','$TSLength','$Tint','$ReqTofMul','$iCut')' +# tof tracking + +mv -v slurm-${SLURM_ARRAY_JOB_ID}_${SLURM_ARRAY_TASK_ID}.out ${outdir}/run_${RunId}.out diff --git a/macro/mcbm/run_mcbm_evdis.sh b/macro/mcbm/run_mcbm_evdis.sh new file mode 100755 index 0000000000000000000000000000000000000000..96dde1484ae1e44f99707cb029686de87dc6aa09 --- /dev/null +++ b/macro/mcbm/run_mcbm_evdis.sh @@ -0,0 +1,46 @@ +#!/bin/bash +#SBATCH -J run_mcbm +#SBATCH -D /lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/macro/mcbm +#SBATCH --time=8:00:00 +##SBATCH --mem=2000 +##SBATCH --partition=long + +X=$((${SLURM_ARRAY_TASK_ID} - 0)) +X=0 +XXX=$(printf "%03d" "$X") + +if [[ ${Sys} = "" ]]; then +Sys="$1" +fi + +if [[ ${Ebeam} = "" ]]; then +Ebeam="$2" +fi + +if [[ ${Centr} = "" ]]; then +Centr="$3" +fi + +if [[ ${TofGeo} = "" ]]; then +mcbmGeo="$4" +fi + + +if [[ -e /lustre/nyx ]]; then +source /lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/build6/config.sh + +export wdir=/lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/macro/mcbm +export outdir=/lustre/nyx/cbm/users/nh/mc +else +export wdir=. +export outdir=./data +fi + +cd ${wdir} +root -q -b 'mcbm_mc_nh.C(100,0,"'${Sys}'","'${Ebeam}'","'${Centr}'",'${X}',"'${mcbmGeo}'")' + +root -q -b 'mcbm_reco_nh.C(100,"'${Sys}'","'${Ebeam}'","'${Centr}'",'${X}',"'${mcbmGeo}'")' + +root -q -b 'mcbm_Ana.C(100,"'${Sys}'","'${Ebeam}'","'${Centr}'",'${X}')' + +mv -v slurm-${SLURM_ARRAY_JOB_ID}_${SLURM_ARRAY_TASK_ID}.out ${outdir}/run_mCBM_${Sys}_${Ebeam}_${Centr}_$X.out diff --git a/macro/mcbm/run_mcbm_nh.sh b/macro/mcbm/run_mcbm_nh.sh new file mode 100755 index 0000000000000000000000000000000000000000..cd2af4ce4add13e2fad9c258bb02c771fd781cb4 --- /dev/null +++ b/macro/mcbm/run_mcbm_nh.sh @@ -0,0 +1,118 @@ +#!/bin/bash +#SBATCH -J run_mcbm +#SBATCH -D /lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/mcbm +#SBATCH --time=8:00:00 +##SBATCH --mem=2000 +##SBATCH --partition=long +##SBATCH --partition=debug + +X=$((${SLURM_ARRAY_TASK_ID} - 0)) +if [ $X -eq 0 ]; then +X=1 +fi + +XXX=$(printf "%05d" "$X") + +Sys=$1 +if [[ ${Sys} = "" ]]; then +Sys="nini" +fi + +Ebeam=$2 +if [[ ${Ebeam} = "" ]]; then +Ebeam="1.93gev" +fi + +Centr=$3 +if [[ ${Centr} = "" ]]; then +Centr="mbias" +fi + +mcbmGeo=$4 +if [[ ${mcbmGeo} = "" ]]; then +mcbmGeo="mcbm_beam_2021_03" +fi + +cMode=$5 +if [[ ${cMode} = "" ]]; then +cMode="0E0" +fi + +iStep=${cMode:0:1} +iBase=${cMode:1:1} +iCut=${cMode:2:1} + +echo simulate Step $iStep with Base $iBase and cut $iCut + +EvtRate=1.e6 # 1/s +TSLength=1.e4 # ns +Tint=100. # ns +ReqTofMul=2 +#NEvt=10 # for debugging +NEvt=100000 # for production + +if [ "$iBase" = "T" ]; then + Timebased=kTRUE +else + Timebased=kFALSE +fi + +if [[ -e /lustre ]]; then + source /lustre/cbm/users/nh/CBM/cbmroot/trunk/build/config.sh + export wdir=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/mcbm + export outdir=/lustre/cbm/users/nh/mc/mcbm2021 + export indir=/lustre/cbm/prod/gen/urqmd +# export extdir=/lustre/cbm/users/uhlig/mcbm_proposal/data + export extdir=$outdir + mcfile=${indir}/${Sys}/${Ebeam}/${Centr}/urqmd.${Sys}.${Ebeam}.${Centr}.${XXX}.root +else + export wdir=. + export indir=../../input +# export extdir=../../../../../../uhlig/mcbm_proposal/data + export outdir=./data + export extdir=$outdir + mcfile=${indir}/urqmd.${Sys}.${Ebeam}.${Centr}.${XXX}.root +fi + +cd ${wdir} + +RunId=${mcbmGeo}.${Sys}.${Ebeam}.${Centr}.${XXX} +datfile=$outdir/$RunId + +if [ $iStep -gt 2 ]; then + echo Generate file with MC tracking data + root -q -b 'mcbm_transport_nh.C('$NEvt',"'${mcbmGeo}'","'$datfile'","'$mcfile'")' +# exit +fi + +if [[ "$Timebased" = "kTRUE" ]]; then +## time based mode + echo simulate in time based mode + #cp -v $extdir/${RunId}.*par.root $outdir/ + #root -q -b 'mcbm_digi.C('$NEvt',"'$RunId'","'$extdir'","'$outdir'","'${mcbmGeo}'",kFALSE,'$EvtRate','$TSLength')' + if [ $iStep -gt 1 ]; then + root -q -b 'mcbm_digi_nh.C('$NEvt',"'$RunId'","'$outdir'","'$outdir'","'${mcbmGeo}'",kFALSE,'$EvtRate','$TSLength')' + fi + if [ $iStep -gt 0 ]; then + root -q -b 'mcbm_reco_event_tb_nh.C('$NEvt',"'$RunId'","'$outdir'","'$outdir'","'${mcbmGeo}'",kTRUE,'$EvtRate','$TSLength')' + fi + +else +## event mode + echo simulate in event mode + ##cp -v $extdir/${RunId}.*par.root $outdir/ + ##root -q -b 'mcbm_digi.C('$NEvt',"'$RunId'","'$extdir'","'$outdir'","'${mcbmGeo}'",kTRUE,'$EvtRate','$TSLength')' + if [ $iStep -gt 1 ]; then + root -q -b 'mcbm_digi_nh.C('$NEvt',"'$RunId'","'$outdir'","'$outdir'","'${mcbmGeo}'",kTRUE,'$EvtRate','$TSLength')' + fi + if [ $iStep -gt 0 ]; then + root -q -b 'mcbm_reco_event_tb_nh.C('$NEvt',"'$RunId'","'$outdir'","'$outdir'","'${mcbmGeo}'",kFALSE,'$EvtRate','$TSLength')' + fi + #exit +fi +## analysis +# for input from FLorian, use $extdir as 3. argument +root -q -b 'mcbm_hadron_analysis.C('$NEvt',"'$RunId'","'$outdir'","'$outdir'","'${mcbmGeo}'",'$Timebased','$EvtRate','$TSLength','$Tint','$ReqTofMul','$iCut')' + + +mv -v slurm-${SLURM_ARRAY_JOB_ID}_${SLURM_ARRAY_TASK_ID}.out ${outdir}/run_${RunId}.out diff --git a/macro/mcbm/save_hst.C b/macro/mcbm/save_hst.C new file mode 100755 index 0000000000000000000000000000000000000000..34e1d111defcd7badc19ce96ff213b4dde886110 --- /dev/null +++ b/macro/mcbm/save_hst.C @@ -0,0 +1,23 @@ +void save_hst(TString cstr="status.hst.root"){ + + gROOT->cd(); + + cout << "Save all histos from directory "<<gDirectory->GetName()<<" to file "<<cstr.Data()<<endl; + + TIter next(gDirectory->GetList()); + // Write histogramms to the file + TFile *fHist = new TFile(cstr,"RECREATE"); + { + TH1 *h; + TObject* obj; + while( (obj= (TObject*)next()) ){ + if(obj->InheritsFrom(TH1::Class())){ + h = (TH1*)obj; + //cout << "Write histo " << h->GetTitle() << endl; + h->Write(); + } + } + } + //fHist->ls(); + fHist->Close(); +}