CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes
PPSAlignmentHarvester Class Reference
Inheritance diagram for PPSAlignmentHarvester:
DQMEDHarvester edm::one::EDProducer< edm::EndLuminosityBlockProducer, edm::EndRunProducer, edm::EndProcessBlockProducer, edm::one::WatchLuminosityBlocks, edm::one::WatchRuns, edm::one::SharedResources, edm::Accumulator > edm::one::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 PPSAlignmentHarvester (const edm::ParameterSet &iConfig)
 
- Public Member Functions inherited from DQMEDHarvester
void accumulate (edm::Event const &ev, edm::EventSetup const &es) final
 
void beginJob () override
 
void beginLuminosityBlock (edm::LuminosityBlock const &lumi, edm::EventSetup const &) final
 
void beginRun (edm::Run const &run, edm::EventSetup const &) override
 
virtual void dqmAnalyze (DQMStore::IBooker &, DQMStore::IGetter &, edm::Event const &, edm::EventSetup const &)
 
 DQMEDHarvester ()
 
 DQMEDHarvester (edm::ParameterSet const &iConfig)
 
virtual void dqmEndLuminosityBlock (DQMStore::IBooker &, DQMStore::IGetter &, edm::LuminosityBlock const &, edm::EventSetup const &)
 
void endLuminosityBlock (edm::LuminosityBlock const &, edm::EventSetup const &) final
 
void endLuminosityBlockProduce (edm::LuminosityBlock &lumi, edm::EventSetup const &es) final
 
void endProcessBlockProduce (edm::ProcessBlock &) final
 
void endRun (edm::Run const &, edm::EventSetup const &) override
 
void endRunProduce (edm::Run &run, edm::EventSetup const &es) final
 
 ~DQMEDHarvester () override=default
 
- Public Member Functions inherited from edm::one::EDProducer< edm::EndLuminosityBlockProducer, edm::EndRunProducer, edm::EndProcessBlockProducer, edm::one::WatchLuminosityBlocks, edm::one::WatchRuns, edm::one::SharedResources, edm::Accumulator >
 EDProducer ()=default
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
- Public Member Functions inherited from edm::one::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () const
 
 ~EDProducerBase () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
std::vector< bool > const & recordProvenanceList () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
TypeLabelList const & typeLabelList () const
 used by the fwk to register the list of products of this module More...
 
 ~ProducerBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

TGraphErrors * buildGraphFromMonitorElements (DQMStore::IGetter &iGetter, const RPConfig &rpd, const std::vector< MonitorElement * > &mes, unsigned int fitProfileMinBinEntries, unsigned int fitProfileMinNReasonable)
 
TGraphErrors * buildGraphFromVector (const std::vector< PointErrors > &pv)
 
TGraphErrors * buildModeGraph (DQMStore::IBooker &iBooker, MonitorElement *h2_y_vs_x, const PPSAlignmentConfig &cfg, const RPConfig &rpd)
 
void doMatch (DQMStore::IBooker &iBooker, const PPSAlignmentConfig &cfg, const RPConfig &rpd, TGraphErrors *g_ref, TGraphErrors *g_test, const SelectionRange &range_ref, double sh_min, double sh_max, double &sh_best, double &sh_best_unc)
 
void dqmEndJob (DQMStore::IBooker &iBooker, DQMStore::IGetter &iGetter) override
 
void dqmEndRun (DQMStore::IBooker &iBooker, DQMStore::IGetter &iGetter, edm::Run const &iRun, edm::EventSetup const &iSetup) override
 
void xAlignment (DQMStore::IBooker &iBooker, DQMStore::IGetter &iGetter, const PPSAlignmentConfig &cfg, const PPSAlignmentConfig &cfg_ref, int seqPos)
 
void xAlignmentRelative (DQMStore::IBooker &iBooker, DQMStore::IGetter &iGetter, const PPSAlignmentConfig &cfg, int seqPos)
 
void yAlignment (DQMStore::IBooker &iBooker, DQMStore::IGetter &iGetter, const PPSAlignmentConfig &cfg, int seqPos)
 

Static Private Member Functions

static double findMax (TF1 *ff_fit)
 
static int fitProfile (TProfile *p, double x_mean, double x_rms, unsigned int fitProfileMinBinEntries, unsigned int fitProfileMinNReasonable, double &sl, double &sl_unc)
 
static TH1D * getTH1DFromTGraphErrors (TGraphErrors *graph, std::string title="", std::string labels="", int n=-1, double binWidth=-1., double min=-1.)
 

Private Attributes

const bool debug_
 
TFile * debugFile_
 
edm::ESGetToken< PPSAlignmentConfig, PPSAlignmentConfigRcdesTokenReference_
 
edm::ESGetToken< PPSAlignmentConfig, PPSAlignmentConfigRcdesTokenTest_
 
const std::string folder_
 
std::ofstream resultsFile_
 
std::map< unsigned int, double > sh_x_map
 

Additional Inherited Members

- Public Types inherited from DQMEDHarvester
typedef dqm::harvesting::DQMStore DQMStore
 
typedef dqm::harvesting::MonitorElement MonitorElement
 
- Public Types inherited from edm::one::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex > >
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::one::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ProducerBase
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 declare what type of product will make and with which optional label More...
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<BranchType B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<Transition B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
- Protected Attributes inherited from DQMEDHarvester
DQMStoredqmstore_
 
edm::GetterOfProducts< DQMTokenjobmegetter_
 
edm::EDPutTokenT< DQMTokenjobToken_
 
edm::GetterOfProducts< DQMTokenlumimegetter_
 
edm::EDPutTokenT< DQMTokenlumiToken_
 
edm::GetterOfProducts< DQMTokenrunmegetter_
 
edm::EDPutTokenT< DQMTokenrunToken_
 

Detailed Description

Definition at line 50 of file PPSAlignmentHarvester.cc.

Constructor & Destructor Documentation

◆ PPSAlignmentHarvester()

PPSAlignmentHarvester::PPSAlignmentHarvester ( const edm::ParameterSet iConfig)

Definition at line 829 of file PPSAlignmentHarvester.cc.

830  : esTokenTest_(
831  esConsumes<PPSAlignmentConfig, PPSAlignmentConfigRcd, edm::Transition::EndRun>(edm::ESInputTag("", ""))),
832  esTokenReference_(esConsumes<PPSAlignmentConfig, PPSAlignmentConfigRcd, edm::Transition::EndRun>(
833  edm::ESInputTag("", "reference"))),
834  folder_(iConfig.getParameter<std::string>("folder")),
835  debug_(iConfig.getParameter<bool>("debug")) {}

Member Function Documentation

◆ buildGraphFromMonitorElements()

TGraphErrors * PPSAlignmentHarvester::buildGraphFromMonitorElements ( DQMStore::IGetter iGetter,
const RPConfig rpd,
const std::vector< MonitorElement * > &  mes,
unsigned int  fitProfileMinBinEntries,
unsigned int  fitProfileMinNReasonable 
)
private

Definition at line 177 of file PPSAlignmentHarvester.cc.

181  {
182  TGraphErrors *g = new TGraphErrors();
183 
184  for (auto *me : mes) {
185  if (me->getName() == "h_y") // find "h_y"
186  {
187  // retrieve parent directory
188  std::string parentPath = me->getPathname();
189  size_t parentPos = parentPath.substr(0, parentPath.size() - 1).find_last_of('/') + 1;
190  std::string parentName = parentPath.substr(parentPos);
191  size_t d = parentName.find('-');
192  const double xMin = std::stod(parentName.substr(0, d));
193  const double xMax = std::stod(parentName.substr(d + 1));
194 
195  TH1D *h_y = me->getTH1D();
196 
197  // collect "p_y_diffFN_vs_y" corresponding to found "h_y"
198  auto *p_y_diffFN_vs_y_monitor = iGetter.get(parentPath + "p_y_diffFN_vs_y");
199  if (p_y_diffFN_vs_y_monitor == nullptr) {
200  edm::LogWarning("PPS") << "[x_alignment] could not find p_y_diffFN_vs_y in: " << parentPath;
201  continue;
202  }
203  TProfile *p_y_diffFN_vs_y = p_y_diffFN_vs_y_monitor->getTProfile();
204 
205  double y_cen = h_y->GetMean();
206  double y_width = h_y->GetRMS();
207 
208  y_cen += rpd.y_cen_add_;
209  y_width *= rpd.y_width_mult_;
210 
211  double sl = 0., sl_unc = 0.;
212  int fr =
213  fitProfile(p_y_diffFN_vs_y, y_cen, y_width, fitProfileMinBinEntries, fitProfileMinNReasonable, sl, sl_unc);
214  if (fr != 0)
215  continue;
216 
217  if (debug_)
218  p_y_diffFN_vs_y->Write(parentName.c_str());
219 
220  int idx = g->GetN();
221  g->SetPoint(idx, (xMax + xMin) / 2., sl);
222  g->SetPointError(idx, (xMax - xMin) / 2., sl_unc);
223  }
224  }
225  g->Sort();
226 
227  return g;
228 }

References ztail::d, debug_, fitProfile(), g, dqm::implementation::IGetter::get(), heavyIonCSV_trainingSettings::idx, hlt_dqm_clientPB-live_cfg::me, AlCaHLTBitMon_QueryRunRegistry::string, multiplicitycorr_cfi::xMax, photonAnalyzer_cfi::xMin, RPConfig::y_cen_add_, and RPConfig::y_width_mult_.

Referenced by xAlignment().

◆ buildGraphFromVector()

TGraphErrors * PPSAlignmentHarvester::buildGraphFromVector ( const std::vector< PointErrors > &  pv)
private

Definition at line 163 of file PPSAlignmentHarvester.cc.

163  {
164  TGraphErrors *g = new TGraphErrors();
165 
166  for (unsigned int i = 0; i < pv.size(); i++) {
167  const auto &p = pv[i];
168  g->SetPoint(i, p.x_, p.y_);
169  g->SetPointError(i, p.ex_, p.ey_);
170  }
171  g->Sort();
172 
173  return g;
174 }

References g, mps_fire::i, AlCaHLTBitMon_ParallelJobs::p, and MetAnalyzer::pv().

Referenced by xAlignment().

◆ buildModeGraph()

TGraphErrors * PPSAlignmentHarvester::buildModeGraph ( DQMStore::IBooker iBooker,
MonitorElement h2_y_vs_x,
const PPSAlignmentConfig cfg,
const RPConfig rpd 
)
private

Definition at line 600 of file PPSAlignmentHarvester.cc.

603  {
604  TDirectory *d_top = nullptr;
605  if (debug_)
606  d_top = gDirectory;
607 
608  TF1 *ff_fit = new TF1("ff_fit", "[0] * exp(-(x-[1])*(x-[1])/2./[2]/[2]) + [3] + [4]*x");
609 
610  TGraphErrors *g_y_mode_vs_x = new TGraphErrors();
611 
612  int h_n = h2_y_vs_x->getNbinsX();
613  double diff = h2_y_vs_x->getTH2D()->GetXaxis()->GetBinWidth(1) / 2.;
614  auto h_mode = iBooker.book1DD("mode",
615  ";x (mm); mode of y (mm)",
616  h_n,
617  h2_y_vs_x->getTH2D()->GetXaxis()->GetBinCenter(1) - diff,
618  h2_y_vs_x->getTH2D()->GetXaxis()->GetBinCenter(h_n) + diff);
619 
620  for (int bix = 1; bix <= h_n; bix++) {
621  const double x = h2_y_vs_x->getTH2D()->GetXaxis()->GetBinCenter(bix);
622  const double x_unc = h2_y_vs_x->getTH2D()->GetXaxis()->GetBinWidth(bix) / 2.;
623 
624  char buf[100];
625  sprintf(buf, "h_y_x=%.3f", x);
626  TH1D *h_y = h2_y_vs_x->getTH2D()->ProjectionY(buf, bix, bix);
627 
628  if (h_y->GetEntries() < cfg.multSelProjYMinEntries())
629  continue;
630 
631  if (debug_) {
632  sprintf(buf, "x=%.3f", x);
633  gDirectory = d_top->mkdir(buf);
634  }
635 
636  double conMax = -1.;
637  double conMax_x = 0.;
638  for (int biy = 1; biy < h_y->GetNbinsX(); biy++) {
639  if (h_y->GetBinContent(biy) > conMax) {
640  conMax = h_y->GetBinContent(biy);
641  conMax_x = h_y->GetBinCenter(biy);
642  }
643  }
644 
645  ff_fit->SetParameters(conMax, conMax_x, h_y->GetRMS() * 0.75, 0., 0.);
646  ff_fit->FixParameter(4, 0.);
647 
648  double xMin = rpd.x_min_fit_mode_, xMax = rpd.x_max_fit_mode_;
649  h_y->Fit(ff_fit, "Q", "", xMin, xMax);
650 
651  ff_fit->ReleaseParameter(4);
652  double w = std::min(4., 2. * ff_fit->GetParameter(2));
653  xMin = ff_fit->GetParameter(1) - w;
654  xMax = std::min(rpd.y_max_fit_mode_, ff_fit->GetParameter(1) + w);
655 
656  h_y->Fit(ff_fit, "Q", "", xMin, xMax);
657 
658  if (debug_)
659  h_y->Write("h_y");
660 
661  double y_mode = findMax(ff_fit);
662  const double y_mode_fit_unc = ff_fit->GetParameter(2) / 10;
663  const double y_mode_sys_unc = cfg.y_mode_sys_unc();
664  double y_mode_unc = std::sqrt(y_mode_fit_unc * y_mode_fit_unc + y_mode_sys_unc * y_mode_sys_unc);
665 
666  const double chiSqThreshold = cfg.chiSqThreshold();
667 
668  const bool valid =
669  !(std::fabs(y_mode_unc) > cfg.y_mode_unc_max_valid() || std::fabs(y_mode) > cfg.y_mode_max_valid() ||
670  ff_fit->GetChisquare() / ff_fit->GetNDF() > chiSqThreshold);
671 
672  if (debug_) {
673  TGraph *g_data = new TGraph();
674  g_data->SetPoint(0, y_mode, y_mode_unc);
675  g_data->SetPoint(1, ff_fit->GetChisquare(), ff_fit->GetNDF());
676  g_data->SetPoint(2, valid, 0.);
677  g_data->Write("g_data");
678  }
679 
680  if (!valid)
681  continue;
682 
683  int idx = g_y_mode_vs_x->GetN();
684  g_y_mode_vs_x->SetPoint(idx, x, y_mode);
685  g_y_mode_vs_x->SetPointError(idx, x_unc, y_mode_unc);
686 
687  h_mode->Fill(x, y_mode);
688  h_mode->setBinError(bix, y_mode_unc);
689  }
690 
691  return g_y_mode_vs_x;
692 }

References dqm::implementation::IBooker::book1DD(), visDQMUpload::buf, looper::cfg, debug_, change_name::diff, findMax(), dqm::impl::MonitorElement::getNbinsX(), dqm::legacy::MonitorElement::getTH2D(), heavyIonCSV_trainingSettings::idx, min(), mathSSE::sqrt(), tools::TF1, RunInfoPI::valid, w, x, RPConfig::x_max_fit_mode_, RPConfig::x_min_fit_mode_, multiplicitycorr_cfi::xMax, photonAnalyzer_cfi::xMin, and RPConfig::y_max_fit_mode_.

Referenced by yAlignment().

◆ doMatch()

void PPSAlignmentHarvester::doMatch ( DQMStore::IBooker iBooker,
const PPSAlignmentConfig cfg,
const RPConfig rpd,
TGraphErrors *  g_ref,
TGraphErrors *  g_test,
const SelectionRange range_ref,
double  sh_min,
double  sh_max,
double &  sh_best,
double &  sh_best_unc 
)
private

Definition at line 231 of file PPSAlignmentHarvester.cc.

240  {
241  const auto range_test = cfg.alignment_x_meth_o_ranges().at(rpd.id_);
242 
243  // print config
244  edm::LogInfo("PPS") << std::fixed << std::setprecision(3) << "[x_alignment] "
245  << "ref: x_min = " << range_ref.x_min_ << ", x_max = " << range_ref.x_max_ << "\n"
246  << "test: x_min = " << range_test.x_min_ << ", x_max = " << range_test.x_max_;
247 
248  // make spline from g_ref
249  TSpline3 *s_ref = new TSpline3("s_ref", g_ref->GetX(), g_ref->GetY(), g_ref->GetN());
250 
251  // book match-quality graphs
252  TGraph *g_n_points = new TGraph();
253  g_n_points->SetName("g_n_points");
254  g_n_points->SetTitle(";sh;N");
255  TGraph *g_chi_sq = new TGraph();
256  g_chi_sq->SetName("g_chi_sq");
257  g_chi_sq->SetTitle(";sh;S2");
258  TGraph *g_chi_sq_norm = new TGraph();
259  g_chi_sq_norm->SetName("g_chi_sq_norm");
260  g_chi_sq_norm->SetTitle(";sh;S2 / N");
261 
262  // optimalisation variables
263  double S2_norm_best = 1E100;
264 
265  for (double sh = sh_min; sh <= sh_max; sh += cfg.x_ali_sh_step()) {
266  // calculate chi^2
267  int n_points = 0;
268  double S2 = 0.;
269 
270  for (int i = 0; i < g_test->GetN(); ++i) {
271  const double x_test = g_test->GetX()[i];
272  const double y_test = g_test->GetY()[i];
273  const double y_test_unc = g_test->GetErrorY(i);
274 
275  const double x_ref = x_test + sh;
276 
277  if (x_ref < range_ref.x_min_ || x_ref > range_ref.x_max_ || x_test < range_test.x_min_ ||
278  x_test > range_test.x_max_)
279  continue;
280 
281  const double y_ref = s_ref->Eval(x_ref);
282 
283  int js = -1, jg = -1;
284  double xs = -1E100, xg = +1E100;
285  for (int j = 0; j < g_ref->GetN(); ++j) {
286  const double x = g_ref->GetX()[j];
287  if (x < x_ref && x > xs) {
288  xs = x;
289  js = j;
290  }
291  if (x > x_ref && x < xg) {
292  xg = x;
293  jg = j;
294  }
295  }
296  if (jg == -1)
297  jg = js;
298 
299  const double y_ref_unc = (g_ref->GetErrorY(js) + g_ref->GetErrorY(jg)) / 2.;
300 
301  n_points++;
302  const double S2_inc = pow(y_test - y_ref, 2.) / (y_ref_unc * y_ref_unc + y_test_unc * y_test_unc);
303  S2 += S2_inc;
304  }
305 
306  // update best result
307  double S2_norm = S2 / n_points;
308 
309  if (S2_norm < S2_norm_best) {
310  S2_norm_best = S2_norm;
311  sh_best = sh;
312  }
313 
314  // fill in graphs
315  int idx = g_n_points->GetN();
316  g_n_points->SetPoint(idx, sh, n_points);
317  g_chi_sq->SetPoint(idx, sh, S2);
318  g_chi_sq_norm->SetPoint(idx, sh, S2_norm);
319  }
320 
321  TF1 *ff_pol2 = new TF1("ff_pol2", "[0] + [1]*x + [2]*x*x");
322 
323  // determine uncertainty
324  double fit_range = cfg.methOUncFitRange();
325  g_chi_sq->Fit(ff_pol2, "Q", "", sh_best - fit_range, sh_best + fit_range);
326  sh_best_unc = 1. / sqrt(ff_pol2->GetParameter(2));
327 
328  // print results
329  edm::LogInfo("PPS") << std::fixed << std::setprecision(3) << "[x_alignment] "
330  << "sh_best = (" << sh_best << " +- " << sh_best_unc << ") mm";
331 
332  TGraphErrors *g_test_shifted = new TGraphErrors(*g_test);
333  for (int i = 0; i < g_test_shifted->GetN(); ++i) {
334  g_test_shifted->GetX()[i] += sh_best;
335  }
336 
337  iBooker.book1DD(
338  "h_test_shifted",
340  g_test_shifted, "test_shifted", ";x (mm);S", rpd.x_slice_n_, rpd.x_slice_w_, rpd.x_slice_min_ + sh_best));
341 
342  if (debug_) {
343  // save graphs
344  g_n_points->Write();
345  g_chi_sq->Write();
346  g_chi_sq_norm->Write();
347  g_test_shifted->SetTitle(";x (mm);S");
348  g_test_shifted->Write("g_test_shifted");
349 
350  // save results
351  TGraph *g_results = new TGraph();
352  g_results->SetName("g_results");
353  g_results->SetPoint(0, sh_best, sh_best_unc);
354  g_results->SetPoint(1, range_ref.x_min_, range_ref.x_max_);
355  g_results->SetPoint(2, range_test.x_min_, range_test.x_max_);
356  g_results->Write();
357 
358  // save debug canvas
359  TCanvas *c_cmp = new TCanvas("c_cmp");
360  g_ref->SetLineColor(1);
361  g_ref->SetName("g_ref");
362  g_ref->Draw("apl");
363 
364  g_test->SetLineColor(4);
365  g_test->SetName("g_test");
366  g_test->Draw("pl");
367 
368  g_test_shifted->SetLineColor(2);
369  g_test_shifted->SetName("g_test_shifted");
370 
371  g_test_shifted->Draw("pl");
372  c_cmp->Write();
373 
374  delete c_cmp;
375  }
376 
377  // clean up
378  delete s_ref;
379 }

References dqm::implementation::IBooker::book1DD(), looper::cfg, debug_, alignBH_cfg::fixed, getTH1DFromTGraphErrors(), mps_fire::i, RPConfig::id_, heavyIonCSV_trainingSettings::idx, dqmiolumiharvest::j, funct::pow(), mathSSE::sqrt(), tools::TF1, x, SelectionRange::x_max_, SelectionRange::x_min_, RPConfig::x_slice_min_, RPConfig::x_slice_n_, and RPConfig::x_slice_w_.

Referenced by xAlignment().

◆ dqmEndJob()

void PPSAlignmentHarvester::dqmEndJob ( DQMStore::IBooker iBooker,
DQMStore::IGetter iGetter 
)
overrideprivatevirtual

Implements DQMEDHarvester.

Definition at line 837 of file PPSAlignmentHarvester.cc.

837 {}

◆ dqmEndRun()

void PPSAlignmentHarvester::dqmEndRun ( DQMStore::IBooker iBooker,
DQMStore::IGetter iGetter,
edm::Run const &  iRun,
edm::EventSetup const &  iSetup 
)
overrideprivatevirtual

Reimplemented from DQMEDHarvester.

Definition at line 839 of file PPSAlignmentHarvester.cc.

842  {
843  const auto &cfg = iSetup.getData(esTokenTest_);
844 
845  const auto &cfg_ref = iSetup.getData(esTokenReference_);
846 
847  if (debug_)
848  debugFile_ = new TFile("debug_harvester.root", "recreate");
849 
850  if (!cfg.resultsDir().empty())
851  resultsFile_.open(cfg.resultsDir(), std::ios::out | std::ios::trunc);
852 
853  // setting default sh_x values from config
854  for (const auto &sd : {cfg.sectorConfig45(), cfg.sectorConfig56()}) {
855  for (const auto &rpd : {sd.rp_N_, sd.rp_F_}) {
856  edm::LogInfo("PPS") << "[harvester] " << std::fixed << std::setprecision(3) << "Setting sh_x of " << rpd.name_
857  << " to " << rpd.sh_x_;
858  sh_x_map[rpd.id_] = rpd.sh_x_;
859  }
860  }
861 
862  for (unsigned int i = 0; i < cfg.sequence().size(); i++) {
863  if (cfg.sequence()[i] == "x_alignment")
864  xAlignment(iBooker, iGetter, cfg, cfg_ref, i);
865  else if (cfg.sequence()[i] == "x_alignment_relative")
866  xAlignmentRelative(iBooker, iGetter, cfg, i);
867  else if (cfg.sequence()[i] == "y_alignment")
868  yAlignment(iBooker, iGetter, cfg, i);
869  else
870  edm::LogError("PPS") << "[harvester] " << cfg.sequence()[i] << " is a wrong method name.";
871  }
872 
873  if (debug_)
874  delete debugFile_;
875 
876  if (resultsFile_.is_open())
877  resultsFile_.close();
878 }

References looper::cfg, debug_, debugFile_, esTokenReference_, esTokenTest_, alignBH_cfg::fixed, edm::EventSetup::getData(), mps_fire::i, MillePedeFileConverter_cfg::out, resultsFile_, sd, sh_x_map, pileupReCalc_HLTpaths::trunc, xAlignment(), xAlignmentRelative(), and yAlignment().

◆ findMax()

double PPSAlignmentHarvester::findMax ( TF1 *  ff_fit)
staticprivate

Definition at line 579 of file PPSAlignmentHarvester.cc.

579  {
580  const double mu = ff_fit->GetParameter(1);
581  const double si = ff_fit->GetParameter(2);
582 
583  // unreasonable fit?
584  if (si > 25. || std::fabs(mu) > 100.)
585  return 1E100;
586 
587  double xMax = 1E100;
588  double yMax = -1E100;
589  for (double x = mu - si; x <= mu + si; x += 0.001) {
590  double y = ff_fit->Eval(x);
591  if (y > yMax) {
592  xMax = x;
593  yMax = y;
594  }
595  }
596 
597  return xMax;
598 }

References amptDefaultParameters_cff::mu, x, multiplicitycorr_cfi::xMax, y, and multiplicitycorr_cfi::yMax.

Referenced by buildModeGraph().

◆ fitProfile()

int PPSAlignmentHarvester::fitProfile ( TProfile *  p,
double  x_mean,
double  x_rms,
unsigned int  fitProfileMinBinEntries,
unsigned int  fitProfileMinNReasonable,
double &  sl,
double &  sl_unc 
)
staticprivate

Definition at line 129 of file PPSAlignmentHarvester.cc.

135  {
136  unsigned int n_reasonable = 0;
137  for (int bi = 1; bi <= p->GetNbinsX(); bi++) {
138  if (p->GetBinEntries(bi) < fitProfileMinBinEntries) {
139  p->SetBinContent(bi, 0.);
140  p->SetBinError(bi, 0.);
141  } else {
142  n_reasonable++;
143  }
144  }
145 
146  if (n_reasonable < fitProfileMinNReasonable)
147  return 1;
148 
149  double xMin = x_mean - x_rms, xMax = x_mean + x_rms;
150 
151  TF1 *ff_pol1 = new TF1("ff_pol1", "[0] + [1]*x");
152 
153  ff_pol1->SetParameter(0., 0.);
154  p->Fit(ff_pol1, "Q", "", xMin, xMax);
155 
156  sl = ff_pol1->GetParameter(1);
157  sl_unc = ff_pol1->GetParError(1);
158 
159  return 0;
160 }

Referenced by buildGraphFromMonitorElements().

◆ getTH1DFromTGraphErrors()

TH1D * PPSAlignmentHarvester::getTH1DFromTGraphErrors ( TGraphErrors *  graph,
std::string  title = "",
std::string  labels = "",
int  n = -1,
double  binWidth = -1.,
double  min = -1. 
)
staticprivate

Definition at line 804 of file PPSAlignmentHarvester.cc.

805  {
806  TH1D *hist;
807  if (n == 0) {
808  hist = new TH1D(title.c_str(), labels.c_str(), 0, -10., 10.);
809  } else if (n == 1) {
810  hist = new TH1D(title.c_str(), labels.c_str(), 1, graph->GetPointX(0) - 5., graph->GetPointX(0) + 5.);
811  } else {
812  n = n == -1 ? graph->GetN() : n;
813  binWidth = binWidth == -1 ? graph->GetPointX(1) - graph->GetPointX(0) : binWidth;
814  double diff = binWidth / 2.;
815  min = min == -1 ? graph->GetPointX(0) - diff : min;
816  double max = min + n * binWidth;
817  hist = new TH1D(title.c_str(), labels.c_str(), n, min, max);
818  }
819 
820  for (int i = 0; i < graph->GetN(); i++) {
821  double x, y;
822  graph->GetPoint(i, x, y);
823  hist->Fill(x, y);
824  hist->SetBinError(hist->GetXaxis()->FindBin(x), graph->GetErrorY(i));
825  }
826  return hist;
827 }

References change_name::diff, compare::hist, mps_fire::i, SummaryClient_cfi::labels, SiStripPI::max, min(), dqmiodumpmetadata::n, runGCPTkAlMap::title, x, and y.

Referenced by doMatch(), and xAlignment().

◆ xAlignment()

void PPSAlignmentHarvester::xAlignment ( DQMStore::IBooker iBooker,
DQMStore::IGetter iGetter,
const PPSAlignmentConfig cfg,
const PPSAlignmentConfig cfg_ref,
int  seqPos 
)
private

Definition at line 382 of file PPSAlignmentHarvester.cc.

386  {
387  TDirectory *xAliDir = nullptr;
388  if (debug_)
389  xAliDir = debugFile_->mkdir((std::to_string(seqPos + 1) + ": x alignment").c_str());
390 
391  // prepare results
393 
394  for (const auto &sdp : {std::make_pair(cfg.sectorConfig45(), cfg_ref.sectorConfig45()),
395  std::make_pair(cfg.sectorConfig56(), cfg_ref.sectorConfig56())}) {
396  const auto &sd = sdp.first;
397  for (const auto &rpdp : {std::make_pair(sd.rp_F_, sdp.second.rp_F_), std::make_pair(sd.rp_N_, sdp.second.rp_N_)}) {
398  const auto &rpd = rpdp.first;
399 
400  auto mes_test = iGetter.getAllContents(folder_ + "/worker/" + sd.name_ + "/near_far/x slices, " + rpd.position_);
401  if (mes_test.empty()) {
402  edm::LogWarning("PPS") << "[x_alignment] " << rpd.name_ << ": could not load mes_test";
403  continue;
404  }
405 
406  TDirectory *rpDir = nullptr;
407  if (debug_)
408  rpDir = xAliDir->mkdir(rpd.name_.c_str());
409 
410  auto vec_ref = cfg_ref.matchingReferencePoints().at(rpd.id_);
411  if (vec_ref.empty()) {
412  edm::LogInfo("PPS") << "[x_alignment] " << rpd.name_ << ": reference points vector is empty";
413  continue;
414  }
415 
416  TGraphErrors *g_ref = buildGraphFromVector(vec_ref);
417 
418  if (debug_)
419  gDirectory = rpDir->mkdir("fits_test");
420  TGraphErrors *g_test = buildGraphFromMonitorElements(
421  iGetter, rpd, mes_test, cfg.fitProfileMinBinEntries(), cfg.fitProfileMinNReasonable());
422 
423  // require minimal number of points
424  if (g_ref->GetN() < (int)cfg.methOGraphMinN() || g_test->GetN() < (int)cfg.methOGraphMinN()) {
425  edm::LogWarning("PPS") << "[x_alignment] " << rpd.name_ << ": insufficient data, skipping (g_ref "
426  << g_ref->GetN() << "/" << cfg.methOGraphMinN() << ", g_test " << g_test->GetN() << "/"
427  << cfg.methOGraphMinN() << ")";
428  continue;
429  }
430 
431  iBooker.setCurrentFolder(folder_ + "/harvester/x alignment/" + rpd.name_);
432  iBooker.book1DD(
433  "h_ref",
435  g_ref, "ref", ";x (mm);S", rpdp.second.x_slice_n_, rpdp.second.x_slice_w_, rpdp.second.x_slice_min_));
436  iBooker.book1DD(
437  "h_test",
438  getTH1DFromTGraphErrors(g_test, "test", ";x (mm);S", rpd.x_slice_n_, rpd.x_slice_w_, rpd.x_slice_min_));
439 
440  if (debug_) {
441  gDirectory = rpDir;
442  g_ref->SetTitle(";x (mm);S");
443  g_ref->Write("g_ref");
444  g_test->SetTitle(";x (mm);S");
445  g_test->Write("g_test");
446  }
447 
448  const auto &shiftRange = cfg_ref.matchingShiftRanges().at(rpd.id_);
449  double sh = 0., sh_unc = 0.;
450  doMatch(iBooker,
451  cfg,
452  rpd,
453  g_ref,
454  g_test,
455  cfg_ref.alignment_x_meth_o_ranges().at(rpd.id_),
456  shiftRange.x_min_,
457  shiftRange.x_max_,
458  sh,
459  sh_unc);
460 
461  CTPPSRPAlignmentCorrectionData rpResult(sh, sh_unc, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.);
462  results.setRPCorrection(rpd.id_, rpResult);
463  edm::LogInfo("PPS") << std::fixed << std::setprecision(3) << "[x_alignment] "
464  << "Setting sh_x of " << rpd.name_ << " to " << sh;
465  sh_x_map[rpd.id_] = sh;
466  }
467  }
468 
469  edm::LogInfo("PPS") << seqPos + 1 << ": x_alignment:\n" << results;
470 
471  if (resultsFile_.is_open())
472  resultsFile_ << seqPos + 1 << ": x_alignment:\n" << results << "\n\n";
473 }

References PPSAlignmentConfig::alignment_x_meth_o_ranges(), dqm::implementation::IBooker::book1DD(), buildGraphFromMonitorElements(), buildGraphFromVector(), looper::cfg, debug_, debugFile_, doMatch(), alignBH_cfg::fixed, folder_, dqm::implementation::IGetter::getAllContents(), getTH1DFromTGraphErrors(), createfilelist::int, PPSAlignmentConfig::matchingReferencePoints(), PPSAlignmentConfig::matchingShiftRanges(), bookConverter::results, resultsFile_, sd, PPSAlignmentConfig::sectorConfig45(), PPSAlignmentConfig::sectorConfig56(), dqm::implementation::NavigatorBase::setCurrentFolder(), and sh_x_map.

Referenced by dqmEndRun().

◆ xAlignmentRelative()

void PPSAlignmentHarvester::xAlignmentRelative ( DQMStore::IBooker iBooker,
DQMStore::IGetter iGetter,
const PPSAlignmentConfig cfg,
int  seqPos 
)
private

Definition at line 477 of file PPSAlignmentHarvester.cc.

480  {
481  TDirectory *xAliRelDir = nullptr;
482  if (debug_)
483  xAliRelDir = debugFile_->mkdir((std::to_string(seqPos + 1) + ": x_alignment_relative").c_str());
484 
485  // prepare results
487  CTPPSRPAlignmentCorrectionsData results_sl_fix;
488 
489  TF1 *ff = new TF1("ff", "[0] + [1]*(x - [2])");
490  TF1 *ff_sl_fix = new TF1("ff_sl_fix", "[0] + [1]*(x - [2])");
491 
492  // processing
493  for (const auto &sd : {cfg.sectorConfig45(), cfg.sectorConfig56()}) {
494  TDirectory *sectorDir = nullptr;
495  if (debug_) {
496  sectorDir = xAliRelDir->mkdir(sd.name_.c_str());
497  gDirectory = sectorDir;
498  }
499 
500  auto *p_x_diffFN_vs_x_N_monitor = iGetter.get(folder_ + "/worker/" + sd.name_ + "/near_far/p_x_diffFN_vs_x_N");
501  if (p_x_diffFN_vs_x_N_monitor == nullptr) {
502  edm::LogWarning("PPS") << "[x_alignment_relative] " << sd.name_ << ": cannot load data, skipping";
503  continue;
504  }
505  TProfile *p_x_diffFN_vs_x_N = p_x_diffFN_vs_x_N_monitor->getTProfile();
506 
507  if (p_x_diffFN_vs_x_N->GetEntries() < cfg.nearFarMinEntries()) {
508  edm::LogWarning("PPS") << "[x_alignment_relative] " << sd.name_ << ": insufficient data, skipping (near_far "
509  << p_x_diffFN_vs_x_N->GetEntries() << "/" << cfg.nearFarMinEntries() << ")";
510  continue;
511  }
512 
513  const double xMin = cfg.alignment_x_relative_ranges().at(sd.rp_N_.id_).x_min_;
514  const double xMax = cfg.alignment_x_relative_ranges().at(sd.rp_N_.id_).x_max_;
515 
516  const double sh_x_N = sh_x_map[sd.rp_N_.id_];
517  double slope = sd.slope_;
518 
519  ff->SetParameters(0., slope, 0.);
520  ff->FixParameter(2, -sh_x_N);
521  ff->SetLineColor(2);
522  p_x_diffFN_vs_x_N->Fit(ff, "Q", "", xMin, xMax);
523 
524  const double a = ff->GetParameter(1), a_unc = ff->GetParError(1);
525  const double b = ff->GetParameter(0), b_unc = ff->GetParError(0);
526 
527  edm::LogInfo("PPS") << "[x_alignment_relative] " << sd.name_ << ":\n"
528  << std::fixed << std::setprecision(3) << " x_min = " << xMin << ", x_max = " << xMax << "\n"
529  << " sh_x_N = " << sh_x_N << ", slope (fix) = " << slope << ", slope (fitted) = " << a;
530 
531  CTPPSRPAlignmentCorrectionData rpResult_N(+b / 2., b_unc / 2., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.);
532  results.setRPCorrection(sd.rp_N_.id_, rpResult_N);
533  CTPPSRPAlignmentCorrectionData rpResult_F(-b / 2., b_unc / 2., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.);
534  results.setRPCorrection(sd.rp_F_.id_, rpResult_F);
535 
536  ff_sl_fix->SetParameters(0., slope, 0.);
537  ff_sl_fix->FixParameter(1, slope);
538  ff_sl_fix->FixParameter(2, -sh_x_N);
539  ff_sl_fix->SetLineColor(4);
540  p_x_diffFN_vs_x_N->Fit(ff_sl_fix, "Q+", "", xMin, xMax);
541 
542  const double b_fs = ff_sl_fix->GetParameter(0), b_fs_unc = ff_sl_fix->GetParError(0);
543 
544  CTPPSRPAlignmentCorrectionData rpResult_sl_fix_N(+b_fs / 2., b_fs_unc / 2., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.);
545  results_sl_fix.setRPCorrection(sd.rp_N_.id_, rpResult_sl_fix_N);
546  CTPPSRPAlignmentCorrectionData rpResult_sl_fix_F(-b_fs / 2., b_fs_unc / 2., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.);
547  results_sl_fix.setRPCorrection(sd.rp_F_.id_, rpResult_sl_fix_F);
548 
549  edm::LogInfo("PPS") << "[x_alignment_relative] " << std::fixed << std::setprecision(3)
550  << "ff: " << ff->GetParameter(0) << " + " << ff->GetParameter(1) << " * (x - "
551  << ff->GetParameter(2) << "), ff_sl_fix: " << ff_sl_fix->GetParameter(0) << " + "
552  << ff_sl_fix->GetParameter(1) << " * (x - " << ff_sl_fix->GetParameter(2) << ")";
553 
554  if (debug_) {
555  p_x_diffFN_vs_x_N->Write("p_x_diffFN_vs_x_N");
556 
557  TGraph *g_results = new TGraph();
558  g_results->SetPoint(0, sh_x_N, 0.);
559  g_results->SetPoint(1, a, a_unc);
560  g_results->SetPoint(2, b, b_unc);
561  g_results->SetPoint(3, b_fs, b_fs_unc);
562  g_results->Write("g_results");
563  }
564  }
565 
566  // write results
567  edm::LogInfo("PPS") << seqPos + 1 << ": x_alignment_relative:\n"
568  << results << seqPos + 1 << ": x_alignment_relative_sl_fix:\n"
569  << results_sl_fix;
570 
571  if (resultsFile_.is_open()) {
572  resultsFile_ << seqPos + 1 << ": x_alignment_relative:\n" << results << "\n";
573  resultsFile_ << seqPos + 1 << ": x_alignment_relative_sl_fix:\n" << results_sl_fix << "\n\n";
574  }
575 }

References a, b, looper::cfg, debug_, debugFile_, alignCSCRings::ff, alignBH_cfg::fixed, folder_, dqm::implementation::IGetter::get(), bookConverter::results, resultsFile_, sd, CTPPSRPAlignmentCorrectionsData::setRPCorrection(), sh_x_map, slope, tools::TF1, multiplicitycorr_cfi::xMax, and photonAnalyzer_cfi::xMin.

Referenced by dqmEndRun().

◆ yAlignment()

void PPSAlignmentHarvester::yAlignment ( DQMStore::IBooker iBooker,
DQMStore::IGetter iGetter,
const PPSAlignmentConfig cfg,
int  seqPos 
)
private

Definition at line 694 of file PPSAlignmentHarvester.cc.

697  {
698  TDirectory *yAliDir = nullptr;
699  if (debug_)
700  yAliDir = debugFile_->mkdir((std::to_string(seqPos + 1) + ": y_alignment").c_str());
701 
702  // prepare results
704  CTPPSRPAlignmentCorrectionsData results_sl_fix;
705 
706  TF1 *ff = new TF1("ff", "[0] + [1]*(x - [2])");
707  TF1 *ff_sl_fix = new TF1("ff_sl_fix", "[0] + [1]*(x - [2])");
708 
709  // processing
710  for (const auto &sd : {cfg.sectorConfig45(), cfg.sectorConfig56()}) {
711  for (const auto &rpd : {sd.rp_F_, sd.rp_N_}) {
712  TDirectory *rpDir = nullptr;
713  if (debug_) {
714  rpDir = yAliDir->mkdir(rpd.name_.c_str());
715  gDirectory = rpDir->mkdir("x");
716  }
717 
718  auto *h2_y_vs_x =
719  iGetter.get(folder_ + "/worker/" + sd.name_ + "/multiplicity selection/" + rpd.name_ + "/h2_y_vs_x");
720 
721  if (h2_y_vs_x == nullptr) {
722  edm::LogWarning("PPS") << "[y_alignment] " << rpd.name_ << ": cannot load data, skipping";
723  continue;
724  }
725 
726  iBooker.setCurrentFolder(folder_ + "/harvester/y alignment/" + rpd.name_);
727  auto *g_y_cen_vs_x = buildModeGraph(iBooker, h2_y_vs_x, cfg, rpd);
728 
729  if ((unsigned int)g_y_cen_vs_x->GetN() < cfg.modeGraphMinN()) {
730  edm::LogWarning("PPS") << "[y_alignment] " << rpd.name_ << ": insufficient data, skipping (mode graph "
731  << g_y_cen_vs_x->GetN() << "/" << cfg.modeGraphMinN() << ")";
732  continue;
733  }
734 
735  const double xMin = cfg.alignment_y_ranges().at(rpd.id_).x_min_;
736  const double xMax = cfg.alignment_y_ranges().at(rpd.id_).x_max_;
737 
738  const double sh_x = sh_x_map[rpd.id_];
739  double slope = rpd.slope_;
740 
741  ff->SetParameters(0., 0., 0.);
742  ff->FixParameter(2, -sh_x);
743  ff->SetLineColor(2);
744  g_y_cen_vs_x->Fit(ff, "Q", "", xMin, xMax);
745 
746  const double a = ff->GetParameter(1), a_unc = ff->GetParError(1);
747  const double b = ff->GetParameter(0), b_unc = ff->GetParError(0);
748 
749  edm::LogInfo("PPS") << "[y_alignment] " << rpd.name_ << ":\n"
750  << std::fixed << std::setprecision(3) << " x_min = " << xMin << ", x_max = " << xMax
751  << "\n"
752  << " sh_x = " << sh_x << ", slope (fix) = " << slope << ", slope (fitted) = " << a;
753 
754  CTPPSRPAlignmentCorrectionData rpResult(0., 0., b, b_unc, 0., 0., 0., 0., 0., 0., 0., 0.);
755  results.setRPCorrection(rpd.id_, rpResult);
756 
757  ff_sl_fix->SetParameters(0., 0., 0.);
758  ff_sl_fix->FixParameter(1, slope);
759  ff_sl_fix->FixParameter(2, -sh_x);
760  ff_sl_fix->SetLineColor(4);
761  g_y_cen_vs_x->Fit(ff_sl_fix, "Q+", "", xMin, xMax);
762 
763  const double b_fs = ff_sl_fix->GetParameter(0), b_fs_unc = ff_sl_fix->GetParError(0);
764 
765  CTPPSRPAlignmentCorrectionData rpResult_sl_fix(0., 0., b_fs, b_fs_unc, 0., 0., 0., 0., 0., 0., 0., 0.);
766  results_sl_fix.setRPCorrection(rpd.id_, rpResult_sl_fix);
767 
768  edm::LogInfo("PPS") << "[y_alignment] " << std::fixed << std::setprecision(3) << "ff: " << ff->GetParameter(0)
769  << " + " << ff->GetParameter(1) << " * (x - " << ff->GetParameter(2)
770  << "), ff_sl_fix: " << ff_sl_fix->GetParameter(0) << " + " << ff_sl_fix->GetParameter(1)
771  << " * (x - " << ff_sl_fix->GetParameter(2) << ")";
772 
773  if (debug_) {
774  gDirectory = rpDir;
775 
776  g_y_cen_vs_x->SetTitle(";x (mm); mode of y (mm)");
777  g_y_cen_vs_x->Write("g_y_cen_vs_x");
778 
779  TGraph *g_results = new TGraph();
780  g_results->SetPoint(0, sh_x, 0.);
781  g_results->SetPoint(1, a, a_unc);
782  g_results->SetPoint(2, b, b_unc);
783  g_results->SetPoint(3, b_fs, b_fs_unc);
784  g_results->Write("g_results");
785  }
786  }
787  }
788 
789  // write results
790  edm::LogInfo("PPS") << seqPos + 1 << ": y_alignment:\n"
791  << results << seqPos + 1 << ": y_alignment_sl_fix:\n"
792  << results_sl_fix;
793 
794  if (resultsFile_.is_open()) {
795  resultsFile_ << seqPos + 1 << ": y_alignment:\n" << results << "\n";
796  resultsFile_ << seqPos + 1 << ": y_alignment_sl_fix:\n" << results_sl_fix << "\n\n";
797  }
798 }

References a, b, buildModeGraph(), looper::cfg, debug_, debugFile_, alignCSCRings::ff, alignBH_cfg::fixed, folder_, dqm::implementation::IGetter::get(), bookConverter::results, resultsFile_, sd, dqm::implementation::NavigatorBase::setCurrentFolder(), CTPPSRPAlignmentCorrectionsData::setRPCorrection(), sh_x_map, slope, tools::TF1, multiplicitycorr_cfi::xMax, and photonAnalyzer_cfi::xMin.

Referenced by dqmEndRun().

Member Data Documentation

◆ debug_

const bool PPSAlignmentHarvester::debug_
private

◆ debugFile_

TFile* PPSAlignmentHarvester::debugFile_
private

Definition at line 131 of file PPSAlignmentHarvester.cc.

Referenced by dqmEndRun(), xAlignment(), xAlignmentRelative(), and yAlignment().

◆ esTokenReference_

edm::ESGetToken<PPSAlignmentConfig, PPSAlignmentConfigRcd> PPSAlignmentHarvester::esTokenReference_
private

Definition at line 127 of file PPSAlignmentHarvester.cc.

Referenced by dqmEndRun().

◆ esTokenTest_

edm::ESGetToken<PPSAlignmentConfig, PPSAlignmentConfigRcd> PPSAlignmentHarvester::esTokenTest_
private

Definition at line 126 of file PPSAlignmentHarvester.cc.

Referenced by dqmEndRun().

◆ folder_

const std::string PPSAlignmentHarvester::folder_
private

Definition at line 129 of file PPSAlignmentHarvester.cc.

Referenced by xAlignment(), xAlignmentRelative(), and yAlignment().

◆ resultsFile_

std::ofstream PPSAlignmentHarvester::resultsFile_
private

Definition at line 132 of file PPSAlignmentHarvester.cc.

Referenced by dqmEndRun(), xAlignment(), xAlignmentRelative(), and yAlignment().

◆ sh_x_map

std::map<unsigned int, double> PPSAlignmentHarvester::sh_x_map
private

Definition at line 101 of file PPSAlignmentHarvester.cc.

Referenced by dqmEndRun(), xAlignment(), xAlignmentRelative(), and yAlignment().

SummaryClient_cfi.labels
labels
Definition: SummaryClient_cfi.py:61
change_name.diff
diff
Definition: change_name.py:13
RPConfig::x_slice_min_
double x_slice_min_
Definition: PPSAlignmentConfig.h:56
PPSAlignmentHarvester::doMatch
void doMatch(DQMStore::IBooker &iBooker, const PPSAlignmentConfig &cfg, const RPConfig &rpd, TGraphErrors *g_ref, TGraphErrors *g_test, const SelectionRange &range_ref, double sh_min, double sh_max, double &sh_best, double &sh_best_unc)
Definition: PPSAlignmentHarvester.cc:231
DDAxes::y
alignBH_cfg.fixed
fixed
Definition: alignBH_cfg.py:54
runGCPTkAlMap.title
string title
Definition: runGCPTkAlMap.py:94
mps_fire.i
i
Definition: mps_fire.py:428
edm::ESInputTag
Definition: ESInputTag.h:87
PPSAlignmentConfig::sectorConfig45
const SectorConfig & sectorConfig45() const
Definition: PPSAlignmentConfig.cc:26
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
PPSAlignmentConfig::sectorConfig56
const SectorConfig & sectorConfig56() const
Definition: PPSAlignmentConfig.cc:27
amptDefaultParameters_cff.mu
mu
Definition: amptDefaultParameters_cff.py:16
min
T min(T a, T b)
Definition: MathUtil.h:58
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
PPSAlignmentHarvester::folder_
const std::string folder_
Definition: PPSAlignmentHarvester.cc:129
PPSAlignmentHarvester::xAlignmentRelative
void xAlignmentRelative(DQMStore::IBooker &iBooker, DQMStore::IGetter &iGetter, const PPSAlignmentConfig &cfg, int seqPos)
Definition: PPSAlignmentHarvester.cc:477
RPConfig::x_slice_w_
double x_slice_w_
Definition: PPSAlignmentConfig.h:56
PPSAlignmentHarvester::findMax
static double findMax(TF1 *ff_fit)
Definition: PPSAlignmentHarvester.cc:579
dqm::implementation::NavigatorBase::setCurrentFolder
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
PPSAlignmentConfig::alignment_x_meth_o_ranges
const std::map< unsigned int, SelectionRange > & alignment_x_meth_o_ranges() const
Definition: PPSAlignmentConfig.cc:46
bookConverter.results
results
Definition: bookConverter.py:144
CTPPSRPAlignmentCorrectionsData::setRPCorrection
void setRPCorrection(unsigned int id, const CTPPSRPAlignmentCorrectionData &ac)
sets the alignment correction for the given RP
Definition: CTPPSRPAlignmentCorrectionsData.cc:67
PPSAlignmentHarvester::resultsFile_
std::ofstream resultsFile_
Definition: PPSAlignmentHarvester.cc:132
SelectionRange::x_min_
double x_min_
Definition: PPSAlignmentConfig.h:35
RPConfig::x_min_fit_mode_
double x_min_fit_mode_
Definition: PPSAlignmentConfig.h:50
DDAxes::x
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
dqm::implementation::IGetter::getAllContents
virtual std::vector< dqm::harvesting::MonitorElement * > getAllContents(std::string const &path) const
Definition: DQMStore.cc:609
tools.TF1
TF1
Definition: tools.py:23
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
heavyIonCSV_trainingSettings.idx
idx
Definition: heavyIonCSV_trainingSettings.py:5
PPSAlignmentConfig::matchingShiftRanges
const std::map< unsigned int, SelectionRange > & matchingShiftRanges() const
Definition: PPSAlignmentConfig.cc:42
photonAnalyzer_cfi.xMin
xMin
Definition: photonAnalyzer_cfi.py:82
RPConfig::y_cen_add_
double y_cen_add_
Definition: PPSAlignmentConfig.h:52
compare.hist
hist
Definition: compare.py:376
PPSAlignmentHarvester::getTH1DFromTGraphErrors
static TH1D * getTH1DFromTGraphErrors(TGraphErrors *graph, std::string title="", std::string labels="", int n=-1, double binWidth=-1., double min=-1.)
Definition: PPSAlignmentHarvester.cc:804
alignCSCRings.ff
ff
Definition: alignCSCRings.py:148
PPSAlignmentHarvester::xAlignment
void xAlignment(DQMStore::IBooker &iBooker, DQMStore::IGetter &iGetter, const PPSAlignmentConfig &cfg, const PPSAlignmentConfig &cfg_ref, int seqPos)
Definition: PPSAlignmentHarvester.cc:382
w
const double w
Definition: UKUtility.cc:23
PPSAlignmentHarvester::buildModeGraph
TGraphErrors * buildModeGraph(DQMStore::IBooker &iBooker, MonitorElement *h2_y_vs_x, const PPSAlignmentConfig &cfg, const RPConfig &rpd)
Definition: PPSAlignmentHarvester.cc:600
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
RPConfig::x_slice_n_
int x_slice_n_
Definition: PPSAlignmentConfig.h:55
multiplicitycorr_cfi.yMax
yMax
Definition: multiplicitycorr_cfi.py:6
b
double b
Definition: hdecay.h:118
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
PPSAlignmentHarvester::buildGraphFromMonitorElements
TGraphErrors * buildGraphFromMonitorElements(DQMStore::IGetter &iGetter, const RPConfig &rpd, const std::vector< MonitorElement * > &mes, unsigned int fitProfileMinBinEntries, unsigned int fitProfileMinNReasonable)
Definition: PPSAlignmentHarvester.cc:177
dqm::implementation::IBooker::book1DD
MonitorElement * book1DD(TString const &name, TString const &title, int nchX, double lowX, double highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:155
RPConfig::x_max_fit_mode_
double x_max_fit_mode_
Definition: PPSAlignmentConfig.h:50
PPSAlignmentHarvester::debug_
const bool debug_
Definition: PPSAlignmentHarvester.cc:130
a
double a
Definition: hdecay.h:119
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
PPSAlignmentHarvester::sh_x_map
std::map< unsigned int, double > sh_x_map
Definition: PPSAlignmentHarvester.cc:101
dqm::legacy::MonitorElement::getTH2D
virtual TH2D * getTH2D() const
Definition: MonitorElement.h:498
RPConfig::y_max_fit_mode_
double y_max_fit_mode_
Definition: PPSAlignmentConfig.h:51
RPConfig::id_
unsigned int id_
Definition: PPSAlignmentConfig.h:45
createfilelist.int
int
Definition: createfilelist.py:10
MetAnalyzer.pv
def pv(vc)
Definition: MetAnalyzer.py:7
SelectionRange::x_max_
double x_max_
Definition: PPSAlignmentConfig.h:36
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
PPSAlignmentHarvester::yAlignment
void yAlignment(DQMStore::IBooker &iBooker, DQMStore::IGetter &iGetter, const PPSAlignmentConfig &cfg, int seqPos)
Definition: PPSAlignmentHarvester.cc:694
visDQMUpload.buf
buf
Definition: visDQMUpload.py:154
PPSAlignmentHarvester::debugFile_
TFile * debugFile_
Definition: PPSAlignmentHarvester.cc:131
looper.cfg
cfg
Definition: looper.py:297
PPSAlignmentConfig::matchingReferencePoints
const std::map< unsigned int, std::vector< PointErrors > > & matchingReferencePoints() const
Definition: PPSAlignmentConfig.cc:39
RPConfig::y_width_mult_
double y_width_mult_
Definition: PPSAlignmentConfig.h:53
dqm::impl::MonitorElement::getNbinsX
virtual int getNbinsX() const
get # of bins in X-axis
Definition: MonitorElement.cc:574
PPSAlignmentHarvester::fitProfile
static int fitProfile(TProfile *p, double x_mean, double x_rms, unsigned int fitProfileMinBinEntries, unsigned int fitProfileMinNReasonable, double &sl, double &sl_unc)
Definition: PPSAlignmentHarvester.cc:129
dqm::implementation::IGetter::get
virtual MonitorElement * get(std::string const &fullpath) const
Definition: DQMStore.cc:651
CTPPSRPAlignmentCorrectionsData
Container for CTPPS RP alignment corrections. The corrections are stored on two levels - RP and senso...
Definition: CTPPSRPAlignmentCorrectionsData.h:24
multiplicitycorr_cfi.xMax
xMax
Definition: multiplicitycorr_cfi.py:5
PPSAlignmentHarvester::esTokenReference_
edm::ESGetToken< PPSAlignmentConfig, PPSAlignmentConfigRcd > esTokenReference_
Definition: PPSAlignmentHarvester.cc:127
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
PPSAlignmentHarvester::buildGraphFromVector
TGraphErrors * buildGraphFromVector(const std::vector< PointErrors > &pv)
Definition: PPSAlignmentHarvester.cc:163
sd
double sd
Definition: CascadeWrapper.h:113
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
funct::pow
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
ztail.d
d
Definition: ztail.py:151
CTPPSRPAlignmentCorrectionData
Alignment correction for an element of the CT-PPS detector. Within the geometry description,...
Definition: CTPPSRPAlignmentCorrectionData.h:58
RunInfoPI::valid
Definition: RunInfoPayloadInspectoHelper.h:16
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
hlt_dqm_clientPB-live_cfg.me
me
Definition: hlt_dqm_clientPB-live_cfg.py:61
slope
static const double slope[3]
Definition: CastorTimeSlew.cc:6
PPSAlignmentHarvester::esTokenTest_
edm::ESGetToken< PPSAlignmentConfig, PPSAlignmentConfigRcd > esTokenTest_
Definition: PPSAlignmentHarvester.cc:126
pileupReCalc_HLTpaths.trunc
trunc
Definition: pileupReCalc_HLTpaths.py:144
g
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
Definition: Activities.doc:4