#include #include #include #include #include #include "rcpicker.h" #include "rcfitter_rdf.h" TString xrootdbase("root://nod26.phys.uconn.edu"); TString xrootdpath("/Gluex/beamline/diamonds"); TString resultspath("INVALID"); TString runperiod("cls-12-2021"); void run_cropping(const char *prefix, Int_t seq); void run_normalize(const char *prefix, Int_t seq); void set_xrootdbase(const char *str) { xrootdbase = str; } void set_rootpath(const char *str) { xrootdpath = str; } void set_resultspath(const char *str) { resultspath = str; } void set_runperiod(const char *str) { runperiod = str; } void run_rcfitter(const char *prefix, Int_t seq, Long64_t count=-1, Long64_t start=0) { // NOTE: count now defaults to -1 (meaning "all entries") rather than // the old sentinel value 9999999999999, matching what RunRcFitter's // Range() logic expects. If you call this with an explicit huge // count elsewhere, pass -1 instead to get full-range/parallel behavior. if (resultspath == "INVALID") { std::cout << "Please set resultspath for this run, then try again." << std::endl << " example: set_resultspath(\"chess-5-2013/results\");" << std::endl; return; } TString xrootdurl; xrootdurl.Form("%s/%s/%s/%s_%3.3d_rocking_curves.root", xrootdbase.Data(),xrootdpath.Data(), resultspath.Data(),prefix,seq); std::cout << xrootdurl << std::endl; // PROOF is gone -- RunRcFitter reads directly from the xrootd URL in // this single process, using RDataFrame's implicit multithreading // instead of distributed PROOF workers. No more per-worker xrootd // port setup (xrdport_update()) is needed either, since there's only // one process now, reading through the normal xrootd client path. std::vector results = RunRcFitter(xrootdurl.Data(), start, count); TString resultsFile; resultsFile.Form("%s_%3.3d_results.root",prefix,seq); TFile *rFile = new TFile(resultsFile,"RECREATE"); for (auto &h : results) { h.Write(); } rFile->Close(); delete rFile; run_cropping(prefix, seq); run_normalize(prefix, seq); } void run_cropping(const char *prefix, Int_t seq) { TString xrootdurl; xrootdurl.Form("%s/%s/%s/%s_%3.3d_rocking_curves.root", xrootdbase.Data(),xrootdpath.Data(), resultspath.Data(),prefix,seq); TString logfile; logfile.Form("%s/%s/%s",runperiod.Data(),prefix,prefix); rcpicker rcp(prefix, seq, xrootdurl, logfile); TString resultsFile; resultsFile.Form("%s_%3.3d_results.root",prefix,seq); std::cout << resultsFile << std::endl; TFile *rFile = new TFile(resultsFile,"UPDATE"); TH2D *hbase = (TH2D*)rFile->Get("hbase"); TH2D *hamp = (TH2D*)rFile->Get("hamp"); TH2D *hmu = (TH2D*)rFile->Get("hmu"); TH2D *hsigma = (TH2D*)rFile->Get("hsigma"); TH2D *hmean = (TH2D*)rFile->Get("hmean"); TH2D *hrms = (TH2D*)rFile->Get("hrms"); TH2D *hmax = (TH2D*)rFile->Get("hmax"); TH2D *hpeak = (TH2D*)rFile->Get("hpeak"); int ixmin=0, ixmax=0; int iymin=0, iymax=0; if (hmax) { rcp.Crop(hmax, &ixmin, &ixmax, &iymin, &iymax)->Write(); std::cout << "updated hmax with ixmin,ixmax,iymin,iymax=" << ixmin << "," << ixmax << "," << iymin << "," << iymax << std::endl; } if (hmean) rcp.Crop(hmean, &ixmin, &ixmax, &iymin, &iymax)->Write(); if (hrms) rcp.Crop(hrms, &ixmin, &ixmax, &iymin, &iymax)->Write(); if (hpeak) rcp.Crop(hpeak, &ixmin, &ixmax, &iymin, &iymax)->Write(); if (hamp) rcp.Crop(hamp, &ixmin, &ixmax, &iymin, &iymax)->Write(); if (hmu) rcp.Crop(hmu, &ixmin, &ixmax, &iymin, &iymax)->Write(); if (hsigma) rcp.Crop(hsigma, &ixmin, &ixmax, &iymin, &iymax)->Write(); if (hbase) rcp.Crop(hbase, &ixmin, &ixmax, &iymin, &iymax)->Write(); rFile->Close(); } void run_normalize(const char *prefix, Int_t seq) { TString xrootdurl; xrootdurl.Form("%s/%s/%s/%s_%3.3d_rocking_curves.root", xrootdbase.Data(),xrootdpath.Data(), resultspath.Data(),prefix,seq); TString logfile; logfile.Form("%s/%s/%s",runperiod.Data(),prefix,prefix); rcpicker rcp(prefix, seq, xrootdurl, logfile); TString resultsFile; resultsFile.Form("%s_%3.3d_results.root",prefix,seq); TFile *rFile = new TFile(resultsFile,"UPDATE"); TH2D *hbase = (TH2D*)rFile->Get("hbase"); TH2D *hamp = (TH2D*)rFile->Get("hamp"); TH2D *hmu = (TH2D*)rFile->Get("hmu"); TH2D *hsigma = (TH2D*)rFile->Get("hsigma"); TH2D *hmean = (TH2D*)rFile->Get("hmean"); TH2D *hrms = (TH2D*)rFile->Get("hrms"); TH2D *hmax = (TH2D*)rFile->Get("hmax"); TH2D *hpeak = (TH2D*)rFile->Get("hpeak"); rcp.Normalize(hbase, hamp, hmu, hsigma, hmean, hrms, hmax, hpeak); TH1D *rcurve = (TH1D*)gROOT->FindObject("rcurve"); hbase->Write(); hamp->Write(); hmu->Write(); hsigma->Write(); hmean->Write(); hrms->Write(); hmax->Write(); hpeak->Write(); rcurve->Write(); rFile->Close(); }