CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes
PPSAlignmentHarvester Class Reference
Inheritance diagram for PPSAlignmentHarvester:
DQMEDHarvester edm::one::EDProducer< T > edm::one::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 PPSAlignmentHarvester (const edm::ParameterSet &iConfig)
 
 ~PPSAlignmentHarvester () override
 
- 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 (edm::ParameterSet const &iConfig)
 
 DQMEDHarvester ()
 
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< T >
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
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
 
const EDProduceroperator= (const EDProducer &)=delete
 
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
 
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)
 
 ~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 const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
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::array< std::vector< ModuleDescription const * > *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::one::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Member Functions

std::unique_ptr< TGraphErrors > buildGraphFromMonitorElements (DQMStore::IGetter &iGetter, const PPSAlignmentConfiguration::RPConfig &rpc, const std::vector< MonitorElement * > &mes, unsigned int fitProfileMinBinEntries, unsigned int fitProfileMinNReasonable)
 
std::unique_ptr< TGraphErrors > buildGraphFromVector (const std::vector< PPSAlignmentConfiguration::PointErrors > &pv)
 
TH1D * buildModeGraph (DQMStore::IBooker &iBooker, MonitorElement *h2_y_vs_x, const PPSAlignmentConfiguration &cfg, const PPSAlignmentConfiguration::RPConfig &rpc)
 
void doMatch (DQMStore::IBooker &iBooker, const PPSAlignmentConfiguration &cfg, const PPSAlignmentConfiguration::RPConfig &rpc, TGraphErrors *g_ref, TGraphErrors *g_test, const PPSAlignmentConfiguration::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 PPSAlignmentConfiguration &cfg, const PPSAlignmentConfiguration &cfg_ref, int seqPos)
 
void xAlignmentRelative (DQMStore::IBooker &iBooker, DQMStore::IGetter &iGetter, const PPSAlignmentConfiguration &cfg, int seqPos)
 
void yAlignment (DQMStore::IBooker &iBooker, DQMStore::IGetter &iGetter, const PPSAlignmentConfiguration &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 std::unique_ptr< TH1D > getTH1DFromTGraphErrors (TGraphErrors *graph, std::string title="", std::string labels="", int n=-1, double binWidth=-1., double min=-1.)
 
static void writeCutPlot (TH2D *h, double a, double c, double si, double n_si, const std::string &label)
 

Private Attributes

const bool debug_
 
std::unique_ptr< TFile > debugFile_
 
edm::ESGetToken
< PPSAlignmentConfiguration,
PPSAlignmentConfigurationRcd
esTokenReference_
 
edm::ESGetToken
< PPSAlignmentConfiguration,
PPSAlignmentConfigurationRcd
esTokenTest_
 
const std::string folder_
 
bool overwriteShX_
 
const std::vector< std::string > sequence_
 
std::map< unsigned int, double > sh_x_map_
 
std::ofstream textResultsFile_
 
const bool writeSQLiteResults_
 
const bool xAliRelFinalSlopeFixed_
 
CTPPSRPAlignmentCorrectionsData xAliRelResults_
 
CTPPSRPAlignmentCorrectionsData xAliRelResultsSlopeFixed_
 
CTPPSRPAlignmentCorrectionsData xAliResults_
 
const bool yAliFinalSlopeFixed_
 
CTPPSRPAlignmentCorrectionsData yAliResults_
 
CTPPSRPAlignmentCorrectionsData yAliResultsSlopeFixed_
 

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
 
- Protected Member Functions inherited from edm::ProducerBase
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
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<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
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...
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
void resetItemsToGetFrom (BranchType iType)
 
- 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 49 of file PPSAlignmentHarvester.cc.

Constructor & Destructor Documentation

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

Definition at line 150 of file PPSAlignmentHarvester.cc.

References debug_, debugFile_, folder_, edm::ParameterSet::getParameter(), mps_fire::i, submitPVResolutionJobs::out, overwriteShX_, sequence_, AlCaHLTBitMon_QueryRunRegistry::string, textResultsFile_, pileupReCalc_HLTpaths::trunc, writeSQLiteResults_, xAliRelFinalSlopeFixed_, and yAliFinalSlopeFixed_.

151  : esTokenTest_(esConsumes<PPSAlignmentConfiguration, PPSAlignmentConfigurationRcd, edm::Transition::EndRun>(
152  edm::ESInputTag("", ""))),
153  esTokenReference_(esConsumes<PPSAlignmentConfiguration, PPSAlignmentConfigurationRcd, edm::Transition::EndRun>(
154  edm::ESInputTag("", "reference"))),
155  folder_(iConfig.getParameter<std::string>("folder")),
156  sequence_(iConfig.getParameter<std::vector<std::string>>("sequence")),
157  overwriteShX_(iConfig.getParameter<bool>("overwrite_sh_x")),
158  writeSQLiteResults_(iConfig.getParameter<bool>("write_sqlite_results")),
159  xAliRelFinalSlopeFixed_(iConfig.getParameter<bool>("x_ali_rel_final_slope_fixed")),
160  yAliFinalSlopeFixed_(iConfig.getParameter<bool>("y_ali_final_slope_fixed")),
161  debug_(iConfig.getParameter<bool>("debug")) {
162  auto textResultsPath = iConfig.getParameter<std::string>("text_results_path");
163  if (!textResultsPath.empty()) {
164  textResultsFile_.open(textResultsPath, std::ios::out | std::ios::trunc);
165  }
166  if (debug_) {
167  debugFile_ = std::make_unique<TFile>("debug_harvester.root", "recreate");
168  }
169 
170  edm::LogInfo("PPS").log([&](auto& li) {
171  li << "[harvester] parameters:\n";
172  li << "* folder: " << folder_ << "\n";
173  li << "* sequence:\n";
174  for (unsigned int i = 0; i < sequence_.size(); i++) {
175  li << " " << i + 1 << ": " << sequence_[i] << "\n";
176  }
177  li << "* overwrite_sh_x: " << std::boolalpha << overwriteShX_ << "\n";
178  li << "* text_results_path: " << textResultsPath << "\n";
179  li << "* write_sqlite_results: " << std::boolalpha << writeSQLiteResults_ << "\n";
180  li << "* x_ali_rel_final_slope_fixed: " << std::boolalpha << xAliRelFinalSlopeFixed_ << "\n";
181  li << "* y_ali_final_slope_fixed: " << std::boolalpha << yAliFinalSlopeFixed_ << "\n";
182  li << "* debug: " << std::boolalpha << debug_;
183  });
184 }
edm::ESGetToken< PPSAlignmentConfiguration, PPSAlignmentConfigurationRcd > esTokenReference_
const std::vector< std::string > sequence_
edm::ESGetToken< PPSAlignmentConfiguration, PPSAlignmentConfigurationRcd > esTokenTest_
std::unique_ptr< TFile > debugFile_
Log< level::Info, false > LogInfo
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
PPSAlignmentHarvester::~PPSAlignmentHarvester ( )
override

Definition at line 186 of file PPSAlignmentHarvester.cc.

References textResultsFile_.

186  {
187  if (textResultsFile_.is_open()) {
188  textResultsFile_.close();
189  }
190 }

Member Function Documentation

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

Definition at line 379 of file PPSAlignmentHarvester.cc.

References ztail::d, debug_, fitProfile(), g, dqm::implementation::IGetter::get(), hlt_dqm_clientPB-live_cfg::me, AlCaHLTBitMon_QueryRunRegistry::string, PPSAlignmentConfiguration::RPConfig::y_cen_add_, and PPSAlignmentConfiguration::RPConfig::y_width_mult_.

Referenced by xAlignment().

384  {
385  auto g = std::make_unique<TGraphErrors>();
386 
387  for (auto* me : mes) {
388  if (me->getName() == "h_y") // find "h_y"
389  {
390  // retrieve parent directory
391  std::string parentPath = me->getPathname();
392  size_t parentPos = parentPath.substr(0, parentPath.size() - 1).find_last_of('/') + 1;
393  std::string parentName = parentPath.substr(parentPos);
394  size_t d = parentName.find('-');
395  const double x_min = std::stod(parentName.substr(0, d));
396  const double x_max = std::stod(parentName.substr(d + 1));
397 
398  TH1D* h_y = me->getTH1D();
399 
400  // collect "p_y_diffFN_vs_y" corresponding to found "h_y"
401  auto* p_y_diffFN_vs_y_monitor = iGetter.get(parentPath + "p_y_diffFN_vs_y");
402  if (p_y_diffFN_vs_y_monitor == nullptr) {
403  edm::LogWarning("PPS") << "[x_alignment] could not find p_y_diffFN_vs_y in: " << parentPath;
404  continue;
405  }
406  TProfile* p_y_diffFN_vs_y = p_y_diffFN_vs_y_monitor->getTProfile();
407 
408  double y_cen = h_y->GetMean();
409  double y_width = h_y->GetRMS();
410 
411  y_cen += rpc.y_cen_add_;
412  y_width *= rpc.y_width_mult_;
413 
414  double sl = 0., sl_unc = 0.;
415  int fr =
416  fitProfile(p_y_diffFN_vs_y, y_cen, y_width, fitProfileMinBinEntries, fitProfileMinNReasonable, sl, sl_unc);
417  if (fr != 0)
418  continue;
419 
420  if (debug_)
421  p_y_diffFN_vs_y->Write(parentName.c_str());
422 
423  int idx = g->GetN();
424  g->SetPoint(idx, (x_max + x_min) / 2., sl);
425  g->SetPointError(idx, (x_max - x_min) / 2., sl_unc);
426  }
427  }
428  g->Sort();
429 
430  return g;
431 }
static int fitProfile(TProfile *p, double x_mean, double x_rms, unsigned int fitProfileMinBinEntries, unsigned int fitProfileMinNReasonable, double &sl, double &sl_unc)
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
tuple d
Definition: ztail.py:151
virtual MonitorElement * get(std::string const &fullpath) const
Definition: DQMStore.cc:673
Log< level::Warning, false > LogWarning
std::unique_ptr< TGraphErrors > PPSAlignmentHarvester::buildGraphFromVector ( const std::vector< PPSAlignmentConfiguration::PointErrors > &  pv)
private

Definition at line 364 of file PPSAlignmentHarvester.cc.

References g, mps_fire::i, and AlCaHLTBitMon_ParallelJobs::p.

Referenced by xAlignment().

365  {
366  auto g = std::make_unique<TGraphErrors>();
367 
368  for (unsigned int i = 0; i < pv.size(); i++) {
369  const auto& p = pv[i];
370  g->SetPoint(i, p.x_, p.y_);
371  g->SetPointError(i, p.ex_, p.ey_);
372  }
373  g->Sort();
374 
375  return g;
376 }
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
TH1D * PPSAlignmentHarvester::buildModeGraph ( DQMStore::IBooker iBooker,
MonitorElement h2_y_vs_x,
const PPSAlignmentConfiguration cfg,
const PPSAlignmentConfiguration::RPConfig rpc 
)
private

Definition at line 806 of file PPSAlignmentHarvester.cc.

References dqm::implementation::IBooker::book1DD(), visDQMUpload::buf, PPSAlignmentConfiguration::chiSqThreshold(), debug_, change_name::diff, findMax(), dqm::impl::MonitorElement::getNbinsX(), dqm::legacy::MonitorElement::getTH2D(), min(), PPSAlignmentConfiguration::multSelProjYMinEntries(), mathSSE::sqrt(), w, x, PPSAlignmentConfiguration::RPConfig::x_max_fit_mode_, PPSAlignmentConfiguration::RPConfig::x_min_fit_mode_, PPSAlignmentConfiguration::RPConfig::y_max_fit_mode_, PPSAlignmentConfiguration::y_mode_max_valid(), PPSAlignmentConfiguration::y_mode_sys_unc(), and PPSAlignmentConfiguration::y_mode_unc_max_valid().

Referenced by yAlignment().

809  {
810  TDirectory* d_top = nullptr;
811  if (debug_)
812  d_top = gDirectory;
813 
814  auto ff_fit = std::make_unique<TF1>("ff_fit", "[0] * exp(-(x-[1])*(x-[1])/2./[2]/[2]) + [3] + [4]*x");
815 
816  int h_n = h2_y_vs_x->getNbinsX();
817  double diff = h2_y_vs_x->getTH2D()->GetXaxis()->GetBinWidth(1) / 2.;
818  auto h_mode = iBooker.book1DD("mode",
819  ";x (mm); mode of y (mm)",
820  h_n,
821  h2_y_vs_x->getTH2D()->GetXaxis()->GetBinCenter(1) - diff,
822  h2_y_vs_x->getTH2D()->GetXaxis()->GetBinCenter(h_n) + diff);
823 
824  for (int bix = 1; bix <= h_n; bix++) {
825  const double x = h2_y_vs_x->getTH2D()->GetXaxis()->GetBinCenter(bix);
826 
827  char buf[100];
828  sprintf(buf, "h_y_x=%.3f", x);
829  TH1D* h_y = h2_y_vs_x->getTH2D()->ProjectionY(buf, bix, bix);
830 
831  if (h_y->GetEntries() < cfg.multSelProjYMinEntries())
832  continue;
833 
834  if (debug_) {
835  sprintf(buf, "x=%.3f", x);
836  gDirectory = d_top->mkdir(buf);
837  }
838 
839  double conMax = -1.;
840  double conMax_x = 0.;
841  for (int biy = 1; biy < h_y->GetNbinsX(); biy++) {
842  if (h_y->GetBinContent(biy) > conMax) {
843  conMax = h_y->GetBinContent(biy);
844  conMax_x = h_y->GetBinCenter(biy);
845  }
846  }
847 
848  ff_fit->SetParameters(conMax, conMax_x, h_y->GetRMS() * 0.75, 0., 0.);
849  ff_fit->FixParameter(4, 0.);
850 
851  double x_min = rpc.x_min_fit_mode_, x_max = rpc.x_max_fit_mode_;
852  h_y->Fit(ff_fit.get(), "Q", "", x_min, x_max);
853 
854  ff_fit->ReleaseParameter(4);
855  double w = std::min(4., 2. * ff_fit->GetParameter(2));
856  x_min = ff_fit->GetParameter(1) - w;
857  x_max = std::min(rpc.y_max_fit_mode_, ff_fit->GetParameter(1) + w);
858 
859  h_y->Fit(ff_fit.get(), "Q", "", x_min, x_max);
860 
861  if (debug_)
862  h_y->Write("h_y");
863 
864  double y_mode = findMax(ff_fit.get());
865  const double y_mode_fit_unc = ff_fit->GetParameter(2) / 10;
866  const double y_mode_sys_unc = cfg.y_mode_sys_unc();
867  double y_mode_unc = std::sqrt(y_mode_fit_unc * y_mode_fit_unc + y_mode_sys_unc * y_mode_sys_unc);
868 
869  const double chiSqThreshold = cfg.chiSqThreshold();
870 
871  const bool valid =
872  !(std::fabs(y_mode_unc) > cfg.y_mode_unc_max_valid() || std::fabs(y_mode) > cfg.y_mode_max_valid() ||
873  ff_fit->GetChisquare() / ff_fit->GetNDF() > chiSqThreshold);
874 
875  if (debug_) {
876  auto g_data = std::make_unique<TGraph>();
877  g_data->SetPoint(0, y_mode, y_mode_unc);
878  g_data->SetPoint(1, ff_fit->GetChisquare(), ff_fit->GetNDF());
879  g_data->SetPoint(2, valid, 0.);
880  g_data->Write("g_data");
881  }
882 
883  if (!valid)
884  continue;
885 
886  h_mode->Fill(x, y_mode);
887  h_mode->setBinError(bix, y_mode_unc);
888  }
889 
890  return h_mode->getTH1D();
891 }
virtual TH2D * getTH2D() const
const double w
Definition: UKUtility.cc:23
unsigned int multSelProjYMinEntries() const
MonitorElement * book1DD(TString const &name, TString const &title, int nchX, double lowX, double highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:155
virtual int getNbinsX() const
get # of bins in X-axis
T sqrt(T t)
Definition: SSEVec.h:19
T min(T a, T b)
Definition: MathUtil.h:58
static double findMax(TF1 *ff_fit)
void PPSAlignmentHarvester::doMatch ( DQMStore::IBooker iBooker,
const PPSAlignmentConfiguration cfg,
const PPSAlignmentConfiguration::RPConfig rpc,
TGraphErrors *  g_ref,
TGraphErrors *  g_test,
const PPSAlignmentConfiguration::SelectionRange range_ref,
double  sh_min,
double  sh_max,
double &  sh_best,
double &  sh_best_unc 
)
private

Definition at line 434 of file PPSAlignmentHarvester.cc.

References PPSAlignmentConfiguration::alignment_x_meth_o_ranges(), dqm::implementation::IBooker::book1DD(), debug_, getTH1DFromTGraphErrors(), mps_fire::i, PPSAlignmentConfiguration::RPConfig::id_, dqmiolumiharvest::j, PPSAlignmentConfiguration::methOUncFitRange(), funct::pow(), mathSSE::sqrt(), x, PPSAlignmentConfiguration::x_ali_sh_step(), PPSAlignmentConfiguration::SelectionRange::x_max_, PPSAlignmentConfiguration::SelectionRange::x_min_, PPSAlignmentConfiguration::RPConfig::x_slice_min_, PPSAlignmentConfiguration::RPConfig::x_slice_n_, and PPSAlignmentConfiguration::RPConfig::x_slice_w_.

Referenced by xAlignment().

443  {
444  const auto range_test = cfg.alignment_x_meth_o_ranges().at(rpc.id_);
445 
446  // print config
447  edm::LogInfo("PPS") << std::fixed << std::setprecision(3) << "[x_alignment] "
448  << "ref: x_min = " << range_ref.x_min_ << ", x_max = " << range_ref.x_max_ << "\n"
449  << "test: x_min = " << range_test.x_min_ << ", x_max = " << range_test.x_max_;
450 
451  // make spline from g_ref
452  auto s_ref = std::make_unique<TSpline3>("s_ref", g_ref->GetX(), g_ref->GetY(), g_ref->GetN());
453 
454  // book match-quality graphs
455  auto g_n_points = std::make_unique<TGraph>();
456  g_n_points->SetName("g_n_points");
457  g_n_points->SetTitle(";sh;N");
458  auto g_chi_sq = std::make_unique<TGraph>();
459  g_chi_sq->SetName("g_chi_sq");
460  g_chi_sq->SetTitle(";sh;S2");
461  auto g_chi_sq_norm = std::make_unique<TGraph>();
462  g_chi_sq_norm->SetName("g_chi_sq_norm");
463  g_chi_sq_norm->SetTitle(";sh;S2 / N");
464 
465  // optimalisation variables
466  double S2_norm_best = 1E100;
467 
468  for (double sh = sh_min; sh <= sh_max; sh += cfg.x_ali_sh_step()) {
469  // calculate chi^2
470  int n_points = 0;
471  double S2 = 0.;
472 
473  for (int i = 0; i < g_test->GetN(); ++i) {
474  const double x_test = g_test->GetX()[i];
475  const double y_test = g_test->GetY()[i];
476  const double y_test_unc = g_test->GetErrorY(i);
477 
478  const double x_ref = x_test + sh;
479 
480  if (x_ref < range_ref.x_min_ || x_ref > range_ref.x_max_ || x_test < range_test.x_min_ ||
481  x_test > range_test.x_max_)
482  continue;
483 
484  const double y_ref = s_ref->Eval(x_ref);
485 
486  int js = -1, jg = -1;
487  double xs = -1E100, xg = +1E100;
488  for (int j = 0; j < g_ref->GetN(); ++j) {
489  const double x = g_ref->GetX()[j];
490  if (x < x_ref && x > xs) {
491  xs = x;
492  js = j;
493  }
494  if (x > x_ref && x < xg) {
495  xg = x;
496  jg = j;
497  }
498  }
499  if (jg == -1)
500  jg = js;
501 
502  const double y_ref_unc = (g_ref->GetErrorY(js) + g_ref->GetErrorY(jg)) / 2.;
503 
504  n_points++;
505  const double S2_inc = pow(y_test - y_ref, 2.) / (y_ref_unc * y_ref_unc + y_test_unc * y_test_unc);
506  S2 += S2_inc;
507  }
508 
509  // update best result
510  double S2_norm = S2 / n_points;
511 
512  if (S2_norm < S2_norm_best) {
513  S2_norm_best = S2_norm;
514  sh_best = sh;
515  }
516 
517  // fill in graphs
518  int idx = g_n_points->GetN();
519  g_n_points->SetPoint(idx, sh, n_points);
520  g_chi_sq->SetPoint(idx, sh, S2);
521  g_chi_sq_norm->SetPoint(idx, sh, S2_norm);
522  }
523 
524  auto ff_pol2 = std::make_unique<TF1>("ff_pol2", "[0] + [1]*x + [2]*x*x");
525 
526  // determine uncertainty
527  double fit_range = cfg.methOUncFitRange();
528  g_chi_sq->Fit(ff_pol2.get(), "Q", "", sh_best - fit_range, sh_best + fit_range);
529  sh_best_unc = 1. / sqrt(ff_pol2->GetParameter(2));
530 
531  // print results
532  edm::LogInfo("PPS") << std::fixed << std::setprecision(3) << "[x_alignment] "
533  << "sh_best = (" << sh_best << " +- " << sh_best_unc << ") mm";
534 
535  auto g_test_shifted = std::make_unique<TGraphErrors>(*g_test);
536  for (int i = 0; i < g_test_shifted->GetN(); ++i) {
537  g_test_shifted->GetX()[i] += sh_best;
538  }
539 
540  std::unique_ptr<TH1D> histPtr = getTH1DFromTGraphErrors(
541  g_test_shifted.get(), "test_shifted", ";x (mm);S", rpc.x_slice_n_, rpc.x_slice_w_, rpc.x_slice_min_ + sh_best);
542  iBooker.book1DD("h_test_shifted", histPtr.get());
543 
544  if (debug_) {
545  // save graphs
546  g_n_points->Write();
547  g_chi_sq->Write();
548  g_chi_sq_norm->Write();
549  g_test_shifted->SetTitle(";x (mm);S");
550  g_test_shifted->Write("g_test_shifted");
551 
552  // save results
553  auto g_results = std::make_unique<TGraph>();
554  g_results->SetName("g_results");
555  g_results->SetPoint(0, sh_best, sh_best_unc);
556  g_results->SetPoint(1, range_ref.x_min_, range_ref.x_max_);
557  g_results->SetPoint(2, range_test.x_min_, range_test.x_max_);
558  g_results->Write();
559 
560  // save debug canvas
561  auto c_cmp = std::make_unique<TCanvas>("c_cmp");
562  g_ref->SetLineColor(1);
563  g_ref->SetName("g_ref");
564  g_ref->Draw("apl");
565 
566  g_test->SetLineColor(4);
567  g_test->SetName("g_test");
568  g_test->Draw("pl");
569 
570  g_test_shifted->SetLineColor(2);
571  g_test_shifted->SetName("g_test_shifted");
572 
573  g_test_shifted->Draw("pl");
574  c_cmp->Write();
575  }
576 }
static std::unique_ptr< TH1D > getTH1DFromTGraphErrors(TGraphErrors *graph, std::string title="", std::string labels="", int n=-1, double binWidth=-1., double min=-1.)
MonitorElement * book1DD(TString const &name, TString const &title, int nchX, double lowX, double highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:155
T sqrt(T t)
Definition: SSEVec.h:19
Log< level::Info, false > LogInfo
const std::map< unsigned int, SelectionRange > & alignment_x_meth_o_ranges() const
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
void PPSAlignmentHarvester::dqmEndJob ( DQMStore::IBooker iBooker,
DQMStore::IGetter iGetter 
)
overrideprivatevirtual

Implements DQMEDHarvester.

Definition at line 207 of file PPSAlignmentHarvester.cc.

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

Reimplemented from DQMEDHarvester.

Definition at line 209 of file PPSAlignmentHarvester.cc.

References CTPPSRPAlignmentCorrectionsData::addCorrections(), CTPPSRPAlignmentCorrectionsData::addRPCorrection(), b, looper::cfg, cond::service::PoolDBOutputService::currentTime(), debug_, debugFile_, esTokenReference_, esTokenTest_, folder_, dqm::implementation::IGetter::get(), edm::EventSetup::getData(), CTPPSRPAlignmentCorrectionsData::getRPCorrection(), CTPPSRPAlignmentCorrectionData::getShX(), mps_fire::i, edm::Service< T >::isAvailable(), omtf::DataWord64::rpc, sequence_, sh_x_map_, textResultsFile_, writeCutPlot(), cond::service::PoolDBOutputService::writeOneIOV(), writeSQLiteResults_, xAlignment(), xAlignmentRelative(), xAliRelFinalSlopeFixed_, xAliRelResults_, xAliRelResultsSlopeFixed_, xAliResults_, yAliFinalSlopeFixed_, yAlignment(), yAliResults_, and yAliResultsSlopeFixed_.

212  {
213  const auto& cfg = iSetup.getData(esTokenTest_);
214 
215  const auto& cfg_ref = iSetup.getData(esTokenReference_);
216 
217  // setting default sh_x values from config
218  for (const auto& sc : {cfg.sectorConfig45(), cfg.sectorConfig56()}) {
219  for (const auto& rpc : {sc.rp_N_, sc.rp_F_}) {
220  sh_x_map_[rpc.id_] = rpc.sh_x_;
221  }
222  }
223  edm::LogInfo("PPS").log([&](auto& li) {
224  li << "[harvester] Setting sh_x from config of:\n";
225  for (const auto& sc : {cfg.sectorConfig45(), cfg.sectorConfig56()}) {
226  for (const auto& rpc : {sc.rp_N_, sc.rp_F_}) {
227  li << " " << rpc.name_ << " to " << std::fixed << std::setprecision(3) << rpc.sh_x_;
228  if (rpc.name_ != "R_2_F")
229  li << "\n";
230  }
231  }
232  });
233 
234  bool doXAli = false, doXAliRel = false, doYAli = false;
235  for (unsigned int i = 0; i < sequence_.size(); i++) {
236  if (sequence_[i] == "x_alignment") {
237  xAlignment(iBooker, iGetter, cfg, cfg_ref, i);
238  doXAli = true;
239  } else if (sequence_[i] == "x_alignment_relative") {
240  xAlignmentRelative(iBooker, iGetter, cfg, i);
241  doXAliRel = true;
242  } else if (sequence_[i] == "y_alignment") {
243  yAlignment(iBooker, iGetter, cfg, i);
244  doYAli = true;
245  } else
246  edm::LogError("PPS") << "[harvester] " << sequence_[i] << " is a wrong method name.";
247  }
248 
249  // merge results from all the specified methods
250  CTPPSRPAlignmentCorrectionsData finalResults;
251  if (doXAli) { // x alignment
252  finalResults.addCorrections(xAliResults_);
253  if (doXAliRel) { // merge with x alignment relative
254  for (const auto& sc : {cfg.sectorConfig45(), cfg.sectorConfig56()}) {
255  // extract shifts
256  double d_x_N = xAliResults_.getRPCorrection(sc.rp_N_.id_).getShX();
257  double d_x_F = xAliResults_.getRPCorrection(sc.rp_F_.id_).getShX();
258 
259  double d_x_rel_N, d_x_rel_F;
261  d_x_rel_N = xAliRelResultsSlopeFixed_.getRPCorrection(sc.rp_N_.id_).getShX();
262  d_x_rel_F = xAliRelResultsSlopeFixed_.getRPCorrection(sc.rp_F_.id_).getShX();
263  } else {
264  d_x_rel_N = xAliRelResults_.getRPCorrection(sc.rp_N_.id_).getShX();
265  d_x_rel_F = xAliRelResults_.getRPCorrection(sc.rp_F_.id_).getShX();
266  }
267 
268  // merge the results
269  double b = d_x_rel_N - d_x_rel_F;
270  double xCorrRel = b + d_x_F - d_x_N;
271 
272  CTPPSRPAlignmentCorrectionData corrRelN(xCorrRel / 2., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.);
273  finalResults.addRPCorrection(sc.rp_N_.id_, corrRelN);
274  CTPPSRPAlignmentCorrectionData corrRelF(-xCorrRel / 2., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.);
275  finalResults.addRPCorrection(sc.rp_F_.id_, corrRelF);
276  }
277  }
278  }
279  if (doYAli) { // y alignment
280  if (yAliFinalSlopeFixed_) {
282  } else {
283  finalResults.addCorrections(yAliResults_);
284  }
285  }
286 
287  // print the text results
288  edm::LogInfo("PPS") << "final merged results:\n" << finalResults;
289 
290  if (textResultsFile_.is_open()) {
291  textResultsFile_ << "final merged results:\n" << finalResults;
292  }
293 
294  // if requested, store the results in a DB object
295  if (writeSQLiteResults_) {
297  if (poolDbService.isAvailable()) {
298  poolDbService->writeOneIOV(finalResults, poolDbService->currentTime(), "CTPPSRPAlignmentCorrectionsDataRcd");
299  } else {
300  edm::LogWarning("PPS") << "Could not store the results in a DB object. PoolDBService not available.";
301  }
302  }
303 
304  // if debug_, save nice-looking cut plots with the worker data in the debug ROOT file
305  if (debug_) {
306  TDirectory* cutsDir = debugFile_->mkdir("cuts");
307  for (const auto& sc : {cfg.sectorConfig45(), cfg.sectorConfig56()}) {
308  TDirectory* sectorDir = cutsDir->mkdir(sc.name_.c_str());
309 
310  gDirectory = sectorDir->mkdir("cut_h");
311  auto* h2_cut_h_bef_monitor = iGetter.get(folder_ + "/worker/" + sc.name_ + "/cuts/cut_h/h2_cut_h_bef");
312  auto* h2_cut_h_aft_monitor = iGetter.get(folder_ + "/worker/" + sc.name_ + "/cuts/cut_h/h2_cut_h_aft");
313  writeCutPlot(
314  h2_cut_h_bef_monitor->getTH2D(), sc.cut_h_a_, sc.cut_h_c_, cfg.n_si(), sc.cut_h_si_, "canvas_before");
315  writeCutPlot(h2_cut_h_aft_monitor->getTH2D(), sc.cut_h_a_, sc.cut_h_c_, cfg.n_si(), sc.cut_h_si_, "canvas_after");
316 
317  gDirectory = sectorDir->mkdir("cut_v");
318  auto* h2_cut_v_bef_monitor = iGetter.get(folder_ + "/worker/" + sc.name_ + "/cuts/cut_v/h2_cut_v_bef");
319  auto* h2_cut_v_aft_monitor = iGetter.get(folder_ + "/worker/" + sc.name_ + "/cuts/cut_v/h2_cut_v_aft");
320  writeCutPlot(
321  h2_cut_v_bef_monitor->getTH2D(), sc.cut_v_a_, sc.cut_v_c_, cfg.n_si(), sc.cut_v_si_, "canvas_before");
322  writeCutPlot(h2_cut_v_aft_monitor->getTH2D(), sc.cut_v_a_, sc.cut_v_c_, cfg.n_si(), sc.cut_v_si_, "canvas_after");
323  }
324  }
325 }
CTPPSRPAlignmentCorrectionData & getRPCorrection(unsigned int id)
returns the correction value from the RP map
tuple cfg
Definition: looper.py:296
std::map< unsigned int, double > sh_x_map_
edm::ESGetToken< PPSAlignmentConfiguration, PPSAlignmentConfigurationRcd > esTokenReference_
CTPPSRPAlignmentCorrectionsData xAliRelResults_
CTPPSRPAlignmentCorrectionsData yAliResults_
Log< level::Error, false > LogError
void yAlignment(DQMStore::IBooker &iBooker, DQMStore::IGetter &iGetter, const PPSAlignmentConfiguration &cfg, int seqPos)
CTPPSRPAlignmentCorrectionsData yAliResultsSlopeFixed_
CTPPSRPAlignmentCorrectionsData xAliResults_
virtual MonitorElement * get(std::string const &fullpath) const
Definition: DQMStore.cc:673
bool isAvailable() const
Definition: Service.h:40
Hash writeOneIOV(const T &payload, Time_t time, const std::string &recordName)
const std::vector< std::string > sequence_
edm::ESGetToken< PPSAlignmentConfiguration, PPSAlignmentConfigurationRcd > esTokenTest_
void addRPCorrection(unsigned int, const CTPPSRPAlignmentCorrectionData &, bool sumErrors=true, bool addSh=true, bool addRot=true)
std::unique_ptr< TFile > debugFile_
static void writeCutPlot(TH2D *h, double a, double c, double si, double n_si, const std::string &label)
void addCorrections(const CTPPSRPAlignmentCorrectionsData &, bool sumErrors=true, bool addSh=true, bool addRot=true)
adds (merges) corrections on top of the current values
Log< level::Info, false > LogInfo
double b
Definition: hdecay.h:118
void xAlignment(DQMStore::IBooker &iBooker, DQMStore::IGetter &iGetter, const PPSAlignmentConfiguration &cfg, const PPSAlignmentConfiguration &cfg_ref, int seqPos)
Container for CTPPS RP alignment corrections. The corrections are stored on two levels - RP and senso...
void xAlignmentRelative(DQMStore::IBooker &iBooker, DQMStore::IGetter &iGetter, const PPSAlignmentConfiguration &cfg, int seqPos)
CTPPSRPAlignmentCorrectionsData xAliRelResultsSlopeFixed_
Log< level::Warning, false > LogWarning
Alignment correction for an element of the CT-PPS detector. Within the geometry description, every sensor (more generally every element) is given its translation and rotation. These two quantities shall be understood in local-to-global coordinate transform. That is, if r_l is a point in local coordinate system and x_g in global, then it holds.
void PPSAlignmentHarvester::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 192 of file PPSAlignmentHarvester.cc.

References edm::ParameterSetDescription::add(), edm::ConfigurationDescriptions::addWithDefaultLabel(), submitPVResolutionJobs::desc, and AlCaHLTBitMon_QueryRunRegistry::string.

192  {
194 
195  desc.add<std::string>("folder", "AlCaReco/PPSAlignment");
196  desc.add<std::vector<std::string>>("sequence", {"x_alignment", "x_alignment_relative", "y_alignment"});
197  desc.add<bool>("overwrite_sh_x", true);
198  desc.add<std::string>("text_results_path", "./alignment_results.txt");
199  desc.add<bool>("write_sqlite_results", false);
200  desc.add<bool>("x_ali_rel_final_slope_fixed", true);
201  desc.add<bool>("y_ali_final_slope_fixed", true);
202  desc.add<bool>("debug", false);
203 
204  descriptions.addWithDefaultLabel(desc);
205 }
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
double PPSAlignmentHarvester::findMax ( TF1 *  ff_fit)
staticprivate

Definition at line 785 of file PPSAlignmentHarvester.cc.

References RPCpg::mu, x, and y.

Referenced by buildModeGraph().

785  {
786  const double mu = ff_fit->GetParameter(1);
787  const double si = ff_fit->GetParameter(2);
788 
789  // unreasonable fit?
790  if (si > 25. || std::fabs(mu) > 100.)
791  return 1E100;
792 
793  double x_max = 1E100;
794  double y_max = -1E100;
795  for (double x = mu - si; x <= mu + si; x += 0.001) {
796  double y = ff_fit->Eval(x);
797  if (y > y_max) {
798  x_max = x;
799  y_max = y;
800  }
801  }
802 
803  return x_max;
804 }
const int mu
Definition: Constants.h:22
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 330 of file PPSAlignmentHarvester.cc.

Referenced by buildGraphFromMonitorElements().

336  {
337  unsigned int n_reasonable = 0;
338  for (int bi = 1; bi <= p->GetNbinsX(); bi++) {
339  if (p->GetBinEntries(bi) < fitProfileMinBinEntries) {
340  p->SetBinContent(bi, 0.);
341  p->SetBinError(bi, 0.);
342  } else {
343  n_reasonable++;
344  }
345  }
346 
347  if (n_reasonable < fitProfileMinNReasonable)
348  return 1;
349 
350  double x_min = x_mean - x_rms, x_max = x_mean + x_rms;
351 
352  auto ff_pol1 = std::make_unique<TF1>("ff_pol1", "[0] + [1]*x");
353 
354  ff_pol1->SetParameter(0., 0.);
355  p->Fit(ff_pol1.get(), "Q", "", x_min, x_max);
356 
357  sl = ff_pol1->GetParameter(1);
358  sl_unc = ff_pol1->GetParError(1);
359 
360  return 0;
361 }
std::unique_ptr< TH1D > PPSAlignmentHarvester::getTH1DFromTGraphErrors ( TGraphErrors *  graph,
std::string  title = "",
std::string  labels = "",
int  n = -1,
double  binWidth = -1.,
double  min = -1. 
)
staticprivate

Definition at line 1026 of file PPSAlignmentHarvester.cc.

References change_name::diff, gpuVertexFinder::hist, mps_fire::i, SiStripPI::max, min(), dqmiodumpmetadata::n, x, and y.

Referenced by doMatch(), and xAlignment().

1027  {
1028  std::unique_ptr<TH1D> hist;
1029  if (n == 0) {
1030  hist = std::make_unique<TH1D>(title.c_str(), labels.c_str(), 0, -10., 10.);
1031  } else if (n == 1) {
1032  hist = std::make_unique<TH1D>(title.c_str(), labels.c_str(), 1, graph->GetPointX(0) - 5., graph->GetPointX(0) + 5.);
1033  } else {
1034  n = n == -1 ? graph->GetN() : n;
1035  binWidth = binWidth == -1 ? graph->GetPointX(1) - graph->GetPointX(0) : binWidth;
1036  double diff = binWidth / 2.;
1037  min = min == -1 ? graph->GetPointX(0) - diff : min;
1038  double max = min + n * binWidth;
1039  hist = std::make_unique<TH1D>(title.c_str(), labels.c_str(), n, min, max);
1040  }
1041 
1042  for (int i = 0; i < graph->GetN(); i++) {
1043  double x, y;
1044  graph->GetPoint(i, x, y);
1045  hist->Fill(x, y);
1046  hist->SetBinError(hist->GetXaxis()->FindBin(x), graph->GetErrorY(i));
1047  }
1048  return hist;
1049 }
T min(T a, T b)
Definition: MathUtil.h:58
__shared__ Hist hist
void PPSAlignmentHarvester::writeCutPlot ( TH2D *  h,
double  a,
double  c,
double  si,
double  n_si,
const std::string &  label 
)
staticprivate

Definition at line 997 of file PPSAlignmentHarvester.cc.

References svgfig::canvas().

Referenced by dqmEndRun().

997  {
998  auto canvas = std::make_unique<TCanvas>();
999  canvas->SetName(label.c_str());
1000  canvas->SetLogz(1);
1001 
1002  h->Draw("colz");
1003 
1004  double x_min = -30.;
1005  double x_max = 30.;
1006 
1007  auto g_up = std::make_unique<TGraph>();
1008  g_up->SetName("g_up");
1009  g_up->SetPoint(0, x_min, -a * x_min - c + n_si * si);
1010  g_up->SetPoint(1, x_max, -a * x_max - c + n_si * si);
1011  g_up->SetLineColor(1);
1012  g_up->Draw("l");
1013 
1014  auto g_down = std::make_unique<TGraph>();
1015  g_down->SetName("g_down");
1016  g_down->SetPoint(0, x_min, -a * x_min - c - n_si * si);
1017  g_down->SetPoint(1, x_max, -a * x_max - c - n_si * si);
1018  g_down->SetLineColor(1);
1019  g_down->Draw("l");
1020 
1021  canvas->Write();
1022 }
const edm::EventSetup & c
def canvas
Definition: svgfig.py:482
char const * label
double a
Definition: hdecay.h:119
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
void PPSAlignmentHarvester::xAlignment ( DQMStore::IBooker iBooker,
DQMStore::IGetter iGetter,
const PPSAlignmentConfiguration cfg,
const PPSAlignmentConfiguration cfg_ref,
int  seqPos 
)
private

Definition at line 579 of file PPSAlignmentHarvester.cc.

References PPSAlignmentConfiguration::alignment_x_meth_o_ranges(), dqm::implementation::IBooker::book1DD(), buildGraphFromMonitorElements(), buildGraphFromVector(), debug_, debugFile_, doMatch(), PPSAlignmentConfiguration::fitProfileMinBinEntries(), PPSAlignmentConfiguration::fitProfileMinNReasonable(), folder_, dqm::implementation::IGetter::getAllContents(), getTH1DFromTGraphErrors(), PPSAlignmentConfiguration::matchingReferencePoints(), PPSAlignmentConfiguration::matchingShiftRanges(), PPSAlignmentConfiguration::methOGraphMinN(), overwriteShX_, omtf::DataWord64::rpc, PPSAlignmentConfiguration::sectorConfig45(), PPSAlignmentConfiguration::sectorConfig56(), dqm::implementation::NavigatorBase::setCurrentFolder(), CTPPSRPAlignmentCorrectionsData::setRPCorrection(), sh_x_map_, textResultsFile_, and xAliResults_.

Referenced by dqmEndRun().

583  {
584  TDirectory* xAliDir = nullptr;
585  if (debug_)
586  xAliDir = debugFile_->mkdir((std::to_string(seqPos + 1) + ": x alignment").c_str());
587 
588  for (const auto& scPair : {std::make_pair(cfg.sectorConfig45(), cfg_ref.sectorConfig45()),
589  std::make_pair(cfg.sectorConfig56(), cfg_ref.sectorConfig56())}) {
590  const auto& sc = scPair.first;
591  const auto& sc_ref = scPair.second;
592 
593  for (const auto& rpcPair : {std::make_pair(sc.rp_F_, sc_ref.rp_F_), std::make_pair(sc.rp_N_, sc_ref.rp_N_)}) {
594  const auto& rpc = rpcPair.first;
595  const auto& rpc_ref = rpcPair.second;
596 
597  auto mes_test = iGetter.getAllContents(folder_ + "/worker/" + sc.name_ + "/near_far/x slices, " + rpc.position_);
598  if (mes_test.empty()) {
599  edm::LogWarning("PPS") << "[x_alignment] " << rpc.name_ << ": could not load mes_test";
600  continue;
601  }
602 
603  TDirectory* rpDir = nullptr;
604  if (debug_)
605  rpDir = xAliDir->mkdir(rpc.name_.c_str());
606 
607  auto vec_ref = cfg_ref.matchingReferencePoints().at(rpc.id_);
608  if (vec_ref.empty()) {
609  edm::LogInfo("PPS") << "[x_alignment] " << rpc.name_ << ": reference points vector is empty";
610  continue;
611  }
612 
613  std::unique_ptr<TGraphErrors> g_ref = buildGraphFromVector(vec_ref);
614 
615  if (debug_)
616  gDirectory = rpDir->mkdir("fits_test");
617  std::unique_ptr<TGraphErrors> g_test = buildGraphFromMonitorElements(
618  iGetter, rpc, mes_test, cfg.fitProfileMinBinEntries(), cfg.fitProfileMinNReasonable());
619 
620  // require minimal number of points
621  if (g_ref->GetN() < (int)cfg.methOGraphMinN() || g_test->GetN() < (int)cfg.methOGraphMinN()) {
622  edm::LogWarning("PPS") << "[x_alignment] " << rpc.name_ << ": insufficient data, skipping (g_ref "
623  << g_ref->GetN() << "/" << cfg.methOGraphMinN() << ", g_test " << g_test->GetN() << "/"
624  << cfg.methOGraphMinN() << ")";
625  continue;
626  }
627 
628  iBooker.setCurrentFolder(folder_ + "/harvester/x alignment/" + rpc.name_);
629 
630  std::unique_ptr<TH1D> histPtr = getTH1DFromTGraphErrors(
631  g_ref.get(), "ref", ";x (mm);S", rpc_ref.x_slice_n_, rpc_ref.x_slice_w_, rpc_ref.x_slice_min_);
632  iBooker.book1DD("h_ref", histPtr.get());
633 
634  histPtr =
635  getTH1DFromTGraphErrors(g_test.get(), "test", ";x (mm);S", rpc.x_slice_n_, rpc.x_slice_w_, rpc.x_slice_min_);
636  iBooker.book1DD("h_test", histPtr.get());
637 
638  if (debug_) {
639  gDirectory = rpDir;
640  g_ref->SetTitle(";x (mm);S");
641  g_ref->Write("g_ref");
642  g_test->SetTitle(";x (mm);S");
643  g_test->Write("g_test");
644  }
645 
646  const auto& shiftRange = cfg.matchingShiftRanges().at(rpc.id_);
647  double sh = 0., sh_unc = 0.;
648 
649  // matching
650  doMatch(iBooker,
651  cfg,
652  rpc,
653  g_ref.get(),
654  g_test.get(),
655  cfg_ref.alignment_x_meth_o_ranges().at(rpc.id_),
656  shiftRange.x_min_,
657  shiftRange.x_max_,
658  sh,
659  sh_unc);
660 
661  // save the results
662  CTPPSRPAlignmentCorrectionData rpResult(sh, sh_unc, 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.);
663  xAliResults_.setRPCorrection(rpc.id_, rpResult);
664  edm::LogInfo("PPS") << std::fixed << std::setprecision(3) << "[x_alignment] "
665  << "Setting sh_x of " << rpc.name_ << " to " << sh;
666 
667  // update the shift
668  if (overwriteShX_) {
669  sh_x_map_[rpc.id_] = sh;
670  }
671  }
672  }
673 
674  edm::LogInfo("PPS") << seqPos + 1 << ": x_alignment:\n" << xAliResults_;
675 
676  if (textResultsFile_.is_open())
677  textResultsFile_ << seqPos + 1 << ": x_alignment:\n" << xAliResults_ << "\n\n";
678 }
std::map< unsigned int, double > sh_x_map_
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
std::unique_ptr< TGraphErrors > buildGraphFromMonitorElements(DQMStore::IGetter &iGetter, const PPSAlignmentConfiguration::RPConfig &rpc, const std::vector< MonitorElement * > &mes, unsigned int fitProfileMinBinEntries, unsigned int fitProfileMinNReasonable)
unsigned int fitProfileMinBinEntries() const
unsigned int methOGraphMinN() const
const std::map< unsigned int, std::vector< PointErrors > > & matchingReferencePoints() const
const SectorConfig & sectorConfig56() const
void setRPCorrection(unsigned int id, const CTPPSRPAlignmentCorrectionData &ac)
sets the alignment correction for the given RP
const std::map< unsigned int, SelectionRange > & matchingShiftRanges() const
virtual std::vector< dqm::harvesting::MonitorElement * > getAllContents(std::string const &path) const
Definition: DQMStore.cc:609
static std::unique_ptr< TH1D > getTH1DFromTGraphErrors(TGraphErrors *graph, std::string title="", std::string labels="", int n=-1, double binWidth=-1., double min=-1.)
std::unique_ptr< TGraphErrors > buildGraphFromVector(const std::vector< PPSAlignmentConfiguration::PointErrors > &pv)
MonitorElement * book1DD(TString const &name, TString const &title, int nchX, double lowX, double highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:155
CTPPSRPAlignmentCorrectionsData xAliResults_
void doMatch(DQMStore::IBooker &iBooker, const PPSAlignmentConfiguration &cfg, const PPSAlignmentConfiguration::RPConfig &rpc, TGraphErrors *g_ref, TGraphErrors *g_test, const PPSAlignmentConfiguration::SelectionRange &range_ref, double sh_min, double sh_max, double &sh_best, double &sh_best_unc)
std::unique_ptr< TFile > debugFile_
Log< level::Info, false > LogInfo
unsigned int fitProfileMinNReasonable() const
const SectorConfig & sectorConfig45() const
Log< level::Warning, false > LogWarning
const std::map< unsigned int, SelectionRange > & alignment_x_meth_o_ranges() const
Alignment correction for an element of the CT-PPS detector. Within the geometry description, every sensor (more generally every element) is given its translation and rotation. These two quantities shall be understood in local-to-global coordinate transform. That is, if r_l is a point in local coordinate system and x_g in global, then it holds.
void PPSAlignmentHarvester::xAlignmentRelative ( DQMStore::IBooker iBooker,
DQMStore::IGetter iGetter,
const PPSAlignmentConfiguration cfg,
int  seqPos 
)
private

Definition at line 682 of file PPSAlignmentHarvester.cc.

References a, PPSAlignmentConfiguration::alignment_x_relative_ranges(), b, dqm::implementation::IBooker::bookProfile(), debug_, debugFile_, alignCSCRings::ff, folder_, dqm::implementation::IGetter::get(), PPSAlignmentConfiguration::nearFarMinEntries(), PPSAlignmentConfiguration::sectorConfig45(), PPSAlignmentConfiguration::sectorConfig56(), dqm::implementation::NavigatorBase::setCurrentFolder(), CTPPSRPAlignmentCorrectionsData::setRPCorrection(), sh_x_map_, slope, textResultsFile_, xAliRelResults_, and xAliRelResultsSlopeFixed_.

Referenced by dqmEndRun().

685  {
686  TDirectory* xAliRelDir = nullptr;
687  if (debug_)
688  xAliRelDir = debugFile_->mkdir((std::to_string(seqPos + 1) + ": x_alignment_relative").c_str());
689 
690  auto ff = std::make_unique<TF1>("ff", "[0] + [1]*(x - [2])");
691  auto ff_sl_fix = std::make_unique<TF1>("ff_sl_fix", "[0] + [1]*(x - [2])");
692 
693  // processing
694  for (const auto& sc : {cfg.sectorConfig45(), cfg.sectorConfig56()}) {
695  TDirectory* sectorDir = nullptr;
696  if (debug_) {
697  sectorDir = xAliRelDir->mkdir(sc.name_.c_str());
698  gDirectory = sectorDir;
699  }
700 
701  auto* p_x_diffFN_vs_x_N_monitor = iGetter.get(folder_ + "/worker/" + sc.name_ + "/near_far/p_x_diffFN_vs_x_N");
702  if (p_x_diffFN_vs_x_N_monitor == nullptr) {
703  edm::LogWarning("PPS") << "[x_alignment_relative] " << sc.name_ << ": cannot load data, skipping";
704  continue;
705  }
706  TProfile* p_x_diffFN_vs_x_N = p_x_diffFN_vs_x_N_monitor->getTProfile();
707 
708  if (p_x_diffFN_vs_x_N->GetEntries() < cfg.nearFarMinEntries()) {
709  edm::LogWarning("PPS") << "[x_alignment_relative] " << sc.name_ << ": insufficient data, skipping (near_far "
710  << p_x_diffFN_vs_x_N->GetEntries() << "/" << cfg.nearFarMinEntries() << ")";
711  continue;
712  }
713 
714  const double x_min = cfg.alignment_x_relative_ranges().at(sc.rp_N_.id_).x_min_;
715  const double x_max = cfg.alignment_x_relative_ranges().at(sc.rp_N_.id_).x_max_;
716 
717  const double sh_x_N = sh_x_map_[sc.rp_N_.id_];
718  double slope = sc.slope_;
719 
720  ff->SetParameters(0., slope, 0.);
721  ff->FixParameter(2, -sh_x_N);
722  ff->SetLineColor(2);
723  p_x_diffFN_vs_x_N->Fit(ff.get(), "Q", "", x_min, x_max);
724 
725  const double a = ff->GetParameter(1), a_unc = ff->GetParError(1);
726  const double b = ff->GetParameter(0), b_unc = ff->GetParError(0);
727 
728  edm::LogInfo("PPS") << "[x_alignment_relative] " << sc.name_ << ":\n"
729  << std::fixed << std::setprecision(3) << " x_min = " << x_min << ", x_max = " << x_max
730  << "\n"
731  << " sh_x_N = " << sh_x_N << ", slope (fix) = " << slope << ", slope (fitted) = " << a;
732 
733  CTPPSRPAlignmentCorrectionData rpResult_N(+b / 2., b_unc / 2., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.);
734  xAliRelResults_.setRPCorrection(sc.rp_N_.id_, rpResult_N);
735  CTPPSRPAlignmentCorrectionData rpResult_F(-b / 2., b_unc / 2., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.);
736  xAliRelResults_.setRPCorrection(sc.rp_F_.id_, rpResult_F);
737 
738  ff_sl_fix->SetParameters(0., slope, 0.);
739  ff_sl_fix->FixParameter(1, slope);
740  ff_sl_fix->FixParameter(2, -sh_x_N);
741  ff_sl_fix->SetLineColor(4);
742  p_x_diffFN_vs_x_N->Fit(ff_sl_fix.get(), "Q+", "", x_min, x_max);
743 
744  const double b_fs = ff_sl_fix->GetParameter(0), b_fs_unc = ff_sl_fix->GetParError(0);
745 
746  CTPPSRPAlignmentCorrectionData rpResult_sl_fix_N(+b_fs / 2., b_fs_unc / 2., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.);
747  xAliRelResultsSlopeFixed_.setRPCorrection(sc.rp_N_.id_, rpResult_sl_fix_N);
748  CTPPSRPAlignmentCorrectionData rpResult_sl_fix_F(-b_fs / 2., b_fs_unc / 2., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.);
749  xAliRelResultsSlopeFixed_.setRPCorrection(sc.rp_F_.id_, rpResult_sl_fix_F);
750 
751  edm::LogInfo("PPS") << "[x_alignment_relative] " << std::fixed << std::setprecision(3)
752  << "ff: " << ff->GetParameter(0) << " + " << ff->GetParameter(1) << " * (x - "
753  << ff->GetParameter(2) << "), ff_sl_fix: " << ff_sl_fix->GetParameter(0) << " + "
754  << ff_sl_fix->GetParameter(1) << " * (x - " << ff_sl_fix->GetParameter(2) << ")";
755 
756  // rebook the diffFN plot in the harvester
757  iBooker.setCurrentFolder(folder_ + "/harvester/x_alignment_relative/" + sc.name_);
758  iBooker.bookProfile("p_x_diffFN_vs_x_N", p_x_diffFN_vs_x_N);
759 
760  if (debug_) {
761  p_x_diffFN_vs_x_N->Write("p_x_diffFN_vs_x_N");
762 
763  auto g_results = std::make_unique<TGraph>();
764  g_results->SetPoint(0, sh_x_N, 0.);
765  g_results->SetPoint(1, a, a_unc);
766  g_results->SetPoint(2, b, b_unc);
767  g_results->SetPoint(3, b_fs, b_fs_unc);
768  g_results->Write("g_results");
769  }
770  }
771 
772  // write results
773  edm::LogInfo("PPS") << seqPos + 1 << ": x_alignment_relative:\n"
774  << xAliRelResults_ << seqPos + 1 << ": x_alignment_relative_sl_fix:\n"
776 
777  if (textResultsFile_.is_open()) {
778  textResultsFile_ << seqPos + 1 << ": x_alignment_relative:\n" << xAliRelResults_ << "\n";
779  textResultsFile_ << seqPos + 1 << ": x_alignment_relative_sl_fix:\n" << xAliRelResultsSlopeFixed_ << "\n\n";
780  }
781 }
std::map< unsigned int, double > sh_x_map_
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
CTPPSRPAlignmentCorrectionsData xAliRelResults_
static const double slope[3]
const SectorConfig & sectorConfig56() const
void setRPCorrection(unsigned int id, const CTPPSRPAlignmentCorrectionData &ac)
sets the alignment correction for the given RP
MonitorElement * bookProfile(TString const &name, TString const &title, int nchX, double lowX, double highX, int, double lowY, double highY, char const *option="s", FUNC onbooking=NOOP())
Definition: DQMStore.h:322
virtual MonitorElement * get(std::string const &fullpath) const
Definition: DQMStore.cc:673
std::unique_ptr< TFile > debugFile_
Log< level::Info, false > LogInfo
unsigned int nearFarMinEntries() const
double b
Definition: hdecay.h:118
const SectorConfig & sectorConfig45() const
double a
Definition: hdecay.h:119
CTPPSRPAlignmentCorrectionsData xAliRelResultsSlopeFixed_
const std::map< unsigned int, SelectionRange > & alignment_x_relative_ranges() const
Log< level::Warning, false > LogWarning
Alignment correction for an element of the CT-PPS detector. Within the geometry description, every sensor (more generally every element) is given its translation and rotation. These two quantities shall be understood in local-to-global coordinate transform. That is, if r_l is a point in local coordinate system and x_g in global, then it holds.
void PPSAlignmentHarvester::yAlignment ( DQMStore::IBooker iBooker,
DQMStore::IGetter iGetter,
const PPSAlignmentConfiguration cfg,
int  seqPos 
)
private

Definition at line 893 of file PPSAlignmentHarvester.cc.

References a, PPSAlignmentConfiguration::alignment_y_ranges(), b, buildModeGraph(), debug_, debugFile_, alignCSCRings::ff, folder_, dqm::implementation::IGetter::get(), PPSAlignmentConfiguration::modeGraphMinN(), omtf::DataWord64::rpc, PPSAlignmentConfiguration::sectorConfig45(), PPSAlignmentConfiguration::sectorConfig56(), dqm::implementation::NavigatorBase::setCurrentFolder(), CTPPSRPAlignmentCorrectionsData::setRPCorrection(), sh_x_map_, slope, textResultsFile_, yAliResults_, and yAliResultsSlopeFixed_.

Referenced by dqmEndRun().

896  {
897  TDirectory* yAliDir = nullptr;
898  if (debug_)
899  yAliDir = debugFile_->mkdir((std::to_string(seqPos + 1) + ": y_alignment").c_str());
900 
901  auto ff = std::make_unique<TF1>("ff", "[0] + [1]*(x - [2])");
902  auto ff_sl_fix = std::make_unique<TF1>("ff_sl_fix", "[0] + [1]*(x - [2])");
903 
904  // processing
905  for (const auto& sc : {cfg.sectorConfig45(), cfg.sectorConfig56()}) {
906  for (const auto& rpc : {sc.rp_F_, sc.rp_N_}) {
907  TDirectory* rpDir = nullptr;
908  if (debug_) {
909  rpDir = yAliDir->mkdir(rpc.name_.c_str());
910  gDirectory = rpDir->mkdir("x");
911  }
912 
913  auto* h2_y_vs_x =
914  iGetter.get(folder_ + "/worker/" + sc.name_ + "/multiplicity selection/" + rpc.name_ + "/h2_y_vs_x");
915 
916  if (h2_y_vs_x == nullptr) {
917  edm::LogWarning("PPS") << "[y_alignment] " << rpc.name_ << ": cannot load data, skipping";
918  continue;
919  }
920 
921  iBooker.setCurrentFolder(folder_ + "/harvester/y alignment/" + rpc.name_);
922  auto* h_y_cen_vs_x = buildModeGraph(iBooker, h2_y_vs_x, cfg, rpc);
923 
924  if ((unsigned int)h_y_cen_vs_x->GetEntries() < cfg.modeGraphMinN()) {
925  edm::LogWarning("PPS") << "[y_alignment] " << rpc.name_ << ": insufficient data, skipping (mode graph "
926  << h_y_cen_vs_x->GetEntries() << "/" << cfg.modeGraphMinN() << ")";
927  continue;
928  }
929 
930  const double x_min = cfg.alignment_y_ranges().at(rpc.id_).x_min_;
931  const double x_max = cfg.alignment_y_ranges().at(rpc.id_).x_max_;
932 
933  const double sh_x = sh_x_map_[rpc.id_];
934  double slope = rpc.slope_;
935 
936  ff->SetParameters(0., 0., 0.);
937  ff->FixParameter(2, -sh_x);
938  ff->SetLineColor(2);
939  h_y_cen_vs_x->Fit(ff.get(), "Q", "", x_min, x_max);
940 
941  const double a = ff->GetParameter(1), a_unc = ff->GetParError(1);
942  const double b = ff->GetParameter(0), b_unc = ff->GetParError(0);
943 
944  edm::LogInfo("PPS") << "[y_alignment] " << rpc.name_ << ":\n"
945  << std::fixed << std::setprecision(3) << " x_min = " << x_min << ", x_max = " << x_max
946  << "\n"
947  << " sh_x = " << sh_x << ", slope (fix) = " << slope << ", slope (fitted) = " << a;
948 
949  CTPPSRPAlignmentCorrectionData rpResult(0., 0., b, b_unc, 0., 0., 0., 0., 0., 0., 0., 0.);
950  yAliResults_.setRPCorrection(rpc.id_, rpResult);
951 
952  ff_sl_fix->SetParameters(0., 0., 0.);
953  ff_sl_fix->FixParameter(1, slope);
954  ff_sl_fix->FixParameter(2, -sh_x);
955  ff_sl_fix->SetLineColor(4);
956  h_y_cen_vs_x->Fit(ff_sl_fix.get(), "Q+", "", x_min, x_max);
957 
958  const double b_fs = ff_sl_fix->GetParameter(0), b_fs_unc = ff_sl_fix->GetParError(0);
959 
960  CTPPSRPAlignmentCorrectionData rpResult_sl_fix(0., 0., b_fs, b_fs_unc, 0., 0., 0., 0., 0., 0., 0., 0.);
961  yAliResultsSlopeFixed_.setRPCorrection(rpc.id_, rpResult_sl_fix);
962 
963  edm::LogInfo("PPS") << "[y_alignment] " << std::fixed << std::setprecision(3) << "ff: " << ff->GetParameter(0)
964  << " + " << ff->GetParameter(1) << " * (x - " << ff->GetParameter(2)
965  << "), ff_sl_fix: " << ff_sl_fix->GetParameter(0) << " + " << ff_sl_fix->GetParameter(1)
966  << " * (x - " << ff_sl_fix->GetParameter(2) << ")";
967 
968  if (debug_) {
969  gDirectory = rpDir;
970 
971  h_y_cen_vs_x->SetTitle(";x (mm); mode of y (mm)");
972  h_y_cen_vs_x->Write("h_y_cen_vs_x");
973 
974  auto g_results = std::make_unique<TGraph>();
975  g_results->SetPoint(0, sh_x, 0.);
976  g_results->SetPoint(1, a, a_unc);
977  g_results->SetPoint(2, b, b_unc);
978  g_results->SetPoint(3, b_fs, b_fs_unc);
979  g_results->Write("g_results");
980  }
981  }
982  }
983 
984  // write results
985  edm::LogInfo("PPS") << seqPos + 1 << ": y_alignment:\n"
986  << yAliResults_ << seqPos + 1 << ": y_alignment_sl_fix:\n"
988 
989  if (textResultsFile_.is_open()) {
990  textResultsFile_ << seqPos + 1 << ": y_alignment:\n" << yAliResults_ << "\n";
991  textResultsFile_ << seqPos + 1 << ": y_alignment_sl_fix:\n" << yAliResultsSlopeFixed_ << "\n\n";
992  }
993 }
std::map< unsigned int, double > sh_x_map_
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
static const double slope[3]
CTPPSRPAlignmentCorrectionsData yAliResults_
const SectorConfig & sectorConfig56() const
void setRPCorrection(unsigned int id, const CTPPSRPAlignmentCorrectionData &ac)
sets the alignment correction for the given RP
const std::map< unsigned int, SelectionRange > & alignment_y_ranges() const
CTPPSRPAlignmentCorrectionsData yAliResultsSlopeFixed_
virtual MonitorElement * get(std::string const &fullpath) const
Definition: DQMStore.cc:673
TH1D * buildModeGraph(DQMStore::IBooker &iBooker, MonitorElement *h2_y_vs_x, const PPSAlignmentConfiguration &cfg, const PPSAlignmentConfiguration::RPConfig &rpc)
std::unique_ptr< TFile > debugFile_
Log< level::Info, false > LogInfo
double b
Definition: hdecay.h:118
const SectorConfig & sectorConfig45() const
double a
Definition: hdecay.h:119
Log< level::Warning, false > LogWarning
Alignment correction for an element of the CT-PPS detector. Within the geometry description, every sensor (more generally every element) is given its translation and rotation. These two quantities shall be understood in local-to-global coordinate transform. That is, if r_l is a point in local coordinate system and x_g in global, then it holds.

Member Data Documentation

const bool PPSAlignmentHarvester::debug_
private
std::unique_ptr<TFile> PPSAlignmentHarvester::debugFile_
private
edm::ESGetToken<PPSAlignmentConfiguration, PPSAlignmentConfigurationRcd> PPSAlignmentHarvester::esTokenReference_
private

Definition at line 124 of file PPSAlignmentHarvester.cc.

Referenced by dqmEndRun().

edm::ESGetToken<PPSAlignmentConfiguration, PPSAlignmentConfigurationRcd> PPSAlignmentHarvester::esTokenTest_
private

Definition at line 123 of file PPSAlignmentHarvester.cc.

Referenced by dqmEndRun().

const std::string PPSAlignmentHarvester::folder_
private
bool PPSAlignmentHarvester::overwriteShX_
private

Definition at line 129 of file PPSAlignmentHarvester.cc.

Referenced by PPSAlignmentHarvester(), and xAlignment().

const std::vector<std::string> PPSAlignmentHarvester::sequence_
private

Definition at line 128 of file PPSAlignmentHarvester.cc.

Referenced by dqmEndRun(), and PPSAlignmentHarvester().

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

Definition at line 94 of file PPSAlignmentHarvester.cc.

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

std::ofstream PPSAlignmentHarvester::textResultsFile_
private
const bool PPSAlignmentHarvester::writeSQLiteResults_
private

Definition at line 130 of file PPSAlignmentHarvester.cc.

Referenced by dqmEndRun(), and PPSAlignmentHarvester().

const bool PPSAlignmentHarvester::xAliRelFinalSlopeFixed_
private

Definition at line 131 of file PPSAlignmentHarvester.cc.

Referenced by dqmEndRun(), and PPSAlignmentHarvester().

CTPPSRPAlignmentCorrectionsData PPSAlignmentHarvester::xAliRelResults_
private

Definition at line 141 of file PPSAlignmentHarvester.cc.

Referenced by dqmEndRun(), and xAlignmentRelative().

CTPPSRPAlignmentCorrectionsData PPSAlignmentHarvester::xAliRelResultsSlopeFixed_
private

Definition at line 142 of file PPSAlignmentHarvester.cc.

Referenced by dqmEndRun(), and xAlignmentRelative().

CTPPSRPAlignmentCorrectionsData PPSAlignmentHarvester::xAliResults_
private

Definition at line 139 of file PPSAlignmentHarvester.cc.

Referenced by dqmEndRun(), and xAlignment().

const bool PPSAlignmentHarvester::yAliFinalSlopeFixed_
private

Definition at line 132 of file PPSAlignmentHarvester.cc.

Referenced by dqmEndRun(), and PPSAlignmentHarvester().

CTPPSRPAlignmentCorrectionsData PPSAlignmentHarvester::yAliResults_
private

Definition at line 144 of file PPSAlignmentHarvester.cc.

Referenced by dqmEndRun(), and yAlignment().

CTPPSRPAlignmentCorrectionsData PPSAlignmentHarvester::yAliResultsSlopeFixed_
private

Definition at line 145 of file PPSAlignmentHarvester.cc.

Referenced by dqmEndRun(), and yAlignment().