CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
SiStripLorentzAnglePCLHarvester Class Reference

#include <CalibTracker/SiStripLorentzAngle/plugins/SiStripLorentzAnglePCLHarvester.cc>

Inheritance diagram for SiStripLorentzAnglePCLHarvester:
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

void beginRun (const edm::Run &, const edm::EventSetup &) override
 
 SiStripLorentzAnglePCLHarvester (const edm::ParameterSet &)
 
 ~SiStripLorentzAnglePCLHarvester () override=default
 
- 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 &)
 
virtual void dqmEndRun (DQMStore::IBooker &, DQMStore::IGetter &, edm::Run 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
 
 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
 
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 const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > 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
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &)
 
- 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

void dqmEndJob (DQMStore::IBooker &, DQMStore::IGetter &) override
 
void endRun (const edm::Run &, const edm::EventSetup &) override
 
std::string getStem (const std::string &histoName, bool isFolder)
 

Private Attributes

const SiStripLorentzAnglecurrentLorentzAngle_
 
const bool debug_
 
const std::string dqmDir_
 
const std::vector< double > fitRange_
 
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecordgeomEsToken_
 
SiStripLorentzAngleCalibrationHistograms hists_
 
SiStripLorentzAngleCalibrationHistograms iHists_
 
const edm::ESGetToken< SiStripLatency, SiStripLatencyRcdlatencyToken_
 
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecordmagneticFieldToken_
 
bool mismatchedBField_
 
bool mismatchedLatency_
 
const std::string recordName_
 
const edm::ESGetToken< SiStripLorentzAngle, SiStripLorentzAngleDepRcdsiStripLAEsToken_
 
std::pair< double, double > theFitRange_ {0., 0.}
 
float theMagField_ {0.f}
 
std::unique_ptr< TrackerTopologytheTrackerTopology_
 
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcdtopoEsTokenBR_
 
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcdtopoEsTokenER_
 

Static Private Attributes

static constexpr float teslaToInverseGeV_ = 2.99792458e-3f
 

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
template<typename T >
using BranchAliasSetterT = ProductRegistryHelper::BranchAliasSetterT< T >
 
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
template<Transition Tr = Transition::Event>
auto produces (std::string instanceName) noexcept
 declare what type of product will make and with which optional label More...
 
template<Transition B>
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)
 
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 ()
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
template<Transition Tr = Transition::Event>
auto produces () noexcept
 
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< Bconsumes (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 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 ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
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

Description: reads the intermediate ALCAPROMPT DQMIO-like dataset and performs the fitting of the SiStrip Lorentz Angle in the Prompt Calibration Loop

Definition at line 46 of file SiStripLorentzAnglePCLHarvester.cc.

Constructor & Destructor Documentation

◆ SiStripLorentzAnglePCLHarvester()

SiStripLorentzAnglePCLHarvester::SiStripLorentzAnglePCLHarvester ( const edm::ParameterSet iConfig)

Definition at line 88 of file SiStripLorentzAnglePCLHarvester.cc.

89  : geomEsToken_(esConsumes<edm::Transition::BeginRun>()),
90  topoEsTokenBR_(esConsumes<edm::Transition::BeginRun>()),
91  topoEsTokenER_(esConsumes<edm::Transition::EndRun>()),
92  latencyToken_(esConsumes<edm::Transition::BeginRun>()),
93  siStripLAEsToken_(esConsumes<edm::Transition::BeginRun>()),
94  magneticFieldToken_(esConsumes<edm::Transition::BeginRun>()),
95  mismatchedBField_{false},
96  mismatchedLatency_{false},
97  debug_(iConfig.getParameter<bool>("debugMode")),
98  dqmDir_(iConfig.getParameter<std::string>("dqmDir")),
99  fitRange_(iConfig.getParameter<std::vector<double>>("fitRange")),
100  recordName_(iConfig.getParameter<std::string>("record")) {
101  // initialize the fit range
102  if (fitRange_.size() == 2) {
103  theFitRange_.first = fitRange_[0];
104  theFitRange_.second = fitRange_[1];
105  } else {
106  throw cms::Exception("SiStripLorentzAnglePCLHarvester") << "Too many fit range parameters specified";
107  }
108 
109  // first ensure DB output service is available
111  if (!poolDbService.isAvailable())
112  throw cms::Exception("SiStripLorentzAnglePCLHarvester") << "PoolDBService required";
113 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > geomEsToken_
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > topoEsTokenBR_
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magneticFieldToken_
bool isAvailable() const
Definition: Service.h:40
const edm::ESGetToken< SiStripLorentzAngle, SiStripLorentzAngleDepRcd > siStripLAEsToken_
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > topoEsTokenER_
const edm::ESGetToken< SiStripLatency, SiStripLatencyRcd > latencyToken_

◆ ~SiStripLorentzAnglePCLHarvester()

SiStripLorentzAnglePCLHarvester::~SiStripLorentzAnglePCLHarvester ( )
overridedefault

Member Function Documentation

◆ beginRun()

void SiStripLorentzAnglePCLHarvester::beginRun ( const edm::Run iRun,
const edm::EventSetup iSetup 
)
override

Definition at line 116 of file SiStripLorentzAnglePCLHarvester.cc.

References SiStripLorentzAngleCalibrationHistograms::apvmode_, siStripLACalibration::apvModeAsString(), SiStripLorentzAngleCalibrationHistograms::bfield_, currentLorentzAngle_, siStripLACalibration::fieldAsString(), relativeConstraints::geom, geomEsToken_, edm::EventSetup::getData(), SiStripLorentzAngle::getLorentzAngle(), iHists_, MagneticField::inverseBzAtOriginInGeV(), SiStripLorentzAngleCalibrationHistograms::la_db_, latencyToken_, magneticFieldToken_, mismatchedBField_, mismatchedLatency_, siStripLACalibration::moduleLocationType(), SiStripLorentzAngleCalibrationHistograms::moduleLocationType_, siStripLAEsToken_, teslaToInverseGeV_, theMagField_, and topoEsTokenBR_.

116  {
117  // geometry
118  const TrackerGeometry* geom = &iSetup.getData(geomEsToken_);
119  const TrackerTopology* tTopo = &iSetup.getData(topoEsTokenBR_);
120 
121  const MagneticField* magField = &iSetup.getData(magneticFieldToken_);
123 
124  // B-field value
125  // inverseBzAtOriginInGeV() returns the inverse of field z component for this map in GeV
126  // for the conversion please consult https://github.com/cms-sw/cmssw/blob/master/MagneticField/Engine/src/MagneticField.cc#L17
127  // theInverseBzAtOriginInGeV = 1.f / (at0z * 2.99792458e-3f);
128  // ==> at0z = 1.f / (theInverseBzAtOriginInGeV * 2.99792458e-3f)
129 
131 
132  if (iHists_.bfield_.empty()) {
134  } else {
136  mismatchedBField_ = true;
137  }
138  }
139 
140  const SiStripLatency* apvlat = &iSetup.getData(latencyToken_);
141  if (iHists_.apvmode_.empty()) {
143  } else {
145  mismatchedLatency_ = true;
146  }
147  }
148 
149  auto dets = geom->detsTIB();
150  dets.insert(dets.end(), geom->detsTID().begin(), geom->detsTID().end());
151  dets.insert(dets.end(), geom->detsTOB().begin(), geom->detsTOB().end());
152  dets.insert(dets.end(), geom->detsTEC().begin(), geom->detsTEC().end());
153 
154  for (auto det : dets) {
155  auto detid = det->geographicalId().rawId();
156  const StripGeomDetUnit* stripDet = dynamic_cast<const StripGeomDetUnit*>(geom->idToDet(det->geographicalId()));
157  if (stripDet) {
160  }
161  }
162 }
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > geomEsToken_
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
float inverseBzAtOriginInGeV() const
The inverse of field z component for this map in GeV.
Definition: MagneticField.h:52
SiStripLorentzAngleCalibrationHistograms iHists_
const std::string fieldAsString(const float &inputField)
const std::string apvModeAsString(const SiStripLatency *latency)
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > topoEsTokenBR_
float getLorentzAngle(const uint32_t &) const
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magneticFieldToken_
const SiStripLorentzAngle * currentLorentzAngle_
std::string moduleLocationType(const uint32_t &mod, const TrackerTopology *tTopo)
const edm::ESGetToken< SiStripLorentzAngle, SiStripLorentzAngleDepRcd > siStripLAEsToken_
const edm::ESGetToken< SiStripLatency, SiStripLatencyRcd > latencyToken_

◆ dqmEndJob()

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

Implements DQMEDHarvester.

Definition at line 172 of file SiStripLorentzAnglePCLHarvester.cc.

References funct::abs(), SiStripLorentzAngleCalibrationHistograms::apvmode_, SiStripLorentzAngleCalibrationHistograms::bfield_, dqm::implementation::IBooker::bookProfile(), dqm::implementation::NavigatorBase::cd(), cond::service::PoolDBOutputService::currentTime(), debug_, dqmDir_, cppFunctionSkipper::exception, Exception, siStripLACalibration::fitFunction(), dqm-mbProfile::format, dqm::implementation::IGetter::get(), getStem(), SiStripLorentzAngleCalibrationHistograms::h2_, LaserClient_cfi::high, trackingPlots::hp, iHists_, edm::Service< T >::isAvailable(), MainPageGenerator::l, SiStripLorentzAngleCalibrationHistograms::la_db_, hgcalTBTopologyTester_cfi::layers, LogDebug, LaserClient_cfi::low, DiMuonMassBiasClient_cfi::MEtoHarvest, mismatchedBField_, mismatchedLatency_, SiStripLorentzAngleCalibrationHistograms::modtypes_, edm::one::EDProducerBase::moduleDescription(), SiStripLorentzAngleCalibrationHistograms::moduleLocationType_, EcalCalibMonitorClient_cfi::moduleName, SiStripLorentzAngleCalibrationHistograms::nlayers_, SiStripLorentzAngleCalibrationHistograms::p_, recordName_, dqm::implementation::NavigatorBase::setCurrentFolder(), AlCaHLTBitMon_QueryRunRegistry::string, submitPVValidationJobs::t, theFitRange_, theMagField_, cms::Exception::what(), and cond::service::PoolDBOutputService::writeOneIOV().

172  {
173  if (mismatchedBField_) {
174  throw cms::Exception("SiStripLorentzAnglePCLHarvester") << "Trying to harvest runs with different B-field values!";
175  }
176 
177  if (mismatchedLatency_) {
178  throw cms::Exception("SiStripLorentzAnglePCLHarvester") << "Trying to harvest runs with diffent APV modes!";
179  }
180 
181  // go in the right directory
182  iGetter.cd();
183  std::string bvalue = (iHists_.bfield_ == "3.8") ? "B-ON" : "B-OFF";
184  std::string folderToHarvest = fmt::format("{}/{}_{}", dqmDir_, bvalue, iHists_.apvmode_);
185  edm::LogPrint(moduleDescription().moduleName()) << "Harvesting in " << folderToHarvest;
186  iGetter.setCurrentFolder(folderToHarvest);
187 
188  // fill in the module types
189  iHists_.nlayers_["TIB"] = 4;
190  iHists_.nlayers_["TOB"] = 6;
191  iHists_.modtypes_.push_back("s");
192  iHists_.modtypes_.push_back("a");
193 
194  std::vector<std::string> MEtoHarvest = {"tanthcosphtrk_nstrip",
195  "thetatrk_nstrip",
196  "tanthcosphtrk_var2",
197  "tanthcosphtrk_var3",
198  "thcosphtrk_var2",
199  "thcosphtrk_var3"};
200 
201  // prepare the histograms to be harvested
202  for (auto& layers : iHists_.nlayers_) {
203  std::string subdet = layers.first;
204  for (int l = 1; l <= layers.second; ++l) {
205  for (auto& t : iHists_.modtypes_) {
206  // do not fill stereo where there aren't
207  if (l > 2 && t == "s")
208  continue;
209  std::string locationtype = Form("%s_L%d%s", subdet.c_str(), l, t.c_str());
210  for (const auto& toHarvest : MEtoHarvest) {
211  const char* address = Form(
212  "%s/%s/L%d/%s_%s", folderToHarvest.c_str(), subdet.c_str(), l, locationtype.c_str(), toHarvest.c_str());
213 
214  LogDebug(moduleDescription().moduleName()) << "harvesting at: " << address << std::endl;
215 
216  iHists_.h2_[Form("%s_%s", locationtype.c_str(), toHarvest.c_str())] = iGetter.get(address);
217  if (iHists_.h2_[Form("%s_%s", locationtype.c_str(), toHarvest.c_str())] == nullptr) {
219  << "could not retrieve: " << Form("%s_%s", locationtype.c_str(), toHarvest.c_str());
220  }
221  }
222  }
223  }
224  }
225 
226  // prepare the profiles
227  for (const auto& ME : iHists_.h2_) {
228  if (!ME.second)
229  continue;
230  TProfile* hp = (TProfile*)ME.second->getTH2F()->ProfileX();
231  iBooker.setCurrentFolder(folderToHarvest + "/" + getStem(ME.first, /* isFolder = */ true));
232  iHists_.p_[hp->GetName()] = iBooker.bookProfile(hp->GetName(), hp);
233  iHists_.p_[hp->GetName()]->setAxisTitle(ME.second->getAxisTitle(2), 2);
234  delete hp;
235  }
236 
237  if (iHists_.p_.empty()) {
238  edm::LogError(moduleDescription().moduleName()) << "None of the input histograms could be retrieved. Aborting";
239  return;
240  }
241 
242  std::map<std::string, std::pair<double, double>> LAMap_;
243 
244  // do the fits
245  for (const auto& prof : iHists_.p_) {
246  //fit only this type of profile
247  if ((prof.first).find("thetatrk_nstrip") != std::string::npos) {
248  // Create the TF1 function
249 
250  // fitting range (take full axis by default)
251  double low = prof.second->getAxisMin(1);
252  double high = prof.second->getAxisMax(1);
253  if (theFitRange_.first > theFitRange_.second) {
254  low = theFitRange_.first;
255  high = theFitRange_.second;
256  }
257 
258  TF1* fitFunc = new TF1("fitFunc", siStripLACalibration::fitFunction, low, high, 3);
259 
260  // Fit the function to the data
261  prof.second->getTProfile()->Fit(fitFunc, "F"); // "F" option performs a least-squares fit
262 
263  // Get the fit results
264  Double_t a_fit = fitFunc->GetParameter(0);
265  Double_t thetaL_fit = fitFunc->GetParameter(1);
266  Double_t b_fit = fitFunc->GetParameter(2);
267 
268  Double_t a_fitError = fitFunc->GetParError(0);
269  Double_t thetaL_fitError = fitFunc->GetParError(1);
270  Double_t b_fitError = fitFunc->GetParError(2);
271 
272  if (debug_) {
274  << prof.first << " fit result: "
275  << " a=" << a_fit << " +/ " << a_fitError << " theta_L=" << thetaL_fit << " +/- " << thetaL_fitError
276  << " b=" << b_fit << " +/- " << b_fitError;
277  }
278 
279  LAMap_[getStem(prof.first, /* isFolder = */ false)] = std::make_pair(thetaL_fit, thetaL_fitError);
280  }
281  }
282 
283  if (debug_) {
284  for (const auto& element : LAMap_) {
286  << element.first << " thetaLA = " << element.second.first << "+/-" << element.second.second;
287  }
288  }
289 
290  // now prepare the output LA
291  std::shared_ptr<SiStripLorentzAngle> OutLorentzAngle = std::make_shared<SiStripLorentzAngle>();
292 
293  for (const auto& loc : iHists_.moduleLocationType_) {
294  if (debug_) {
295  edm::LogInfo(moduleDescription().moduleName()) << "modId: " << loc.first << " " << loc.second;
296  }
297 
298  if (!(loc.second).empty()) {
299  OutLorentzAngle->putLorentzAngle(loc.first, std::abs(LAMap_[loc.second].first / theMagField_));
300  } else {
301  OutLorentzAngle->putLorentzAngle(loc.first, iHists_.la_db_[loc.first]);
302  }
303  }
304 
306  if (mydbservice.isAvailable()) {
307  try {
308  mydbservice->writeOneIOV(*OutLorentzAngle, mydbservice->currentTime(), recordName_);
309  } catch (const cond::Exception& er) {
310  edm::LogError("SiStripLorentzAngleDB") << er.what();
311  } catch (const std::exception& er) {
312  edm::LogError("SiStripLorentzAngleDB") << "caught std::exception " << er.what();
313  }
314  } else {
315  edm::LogError("SiStripLorentzAngleDB") << "Service is unavailable";
316  }
317 }
Base exception class for the object to relational access.
Definition: Exception.h:11
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:36
ModuleDescription const & moduleDescription() const
double fitFunction(double *x, double *par)
Log< level::Error, false > LogError
Definition: ME.h:11
std::map< std::string, dqm::reco::MonitorElement * > p_
SiStripLorentzAngleCalibrationHistograms iHists_
std::map< std::string, dqm::reco::MonitorElement * > h2_
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:399
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
Hash writeOneIOV(const T &payload, Time_t time, const std::string &recordName)
Log< level::Warning, true > LogPrint
Log< level::Info, false > LogInfo
std::string getStem(const std::string &histoName, bool isFolder)
virtual MonitorElement * get(std::string const &fullpath) const
Definition: DQMStore.cc:712
bool isAvailable() const
Definition: Service.h:40
char const * what() const noexcept override
Definition: Exception.cc:107
#define LogDebug(id)

◆ endRun()

void SiStripLorentzAnglePCLHarvester::endRun ( const edm::Run run,
const edm::EventSetup isetup 
)
overrideprivate

Definition at line 165 of file SiStripLorentzAnglePCLHarvester.cc.

References edm::EventSetup::getData(), theTrackerTopology_, and topoEsTokenER_.

165  {
166  if (!theTrackerTopology_) {
167  theTrackerTopology_ = std::make_unique<TrackerTopology>(isetup.getData(topoEsTokenER_));
168  }
169 }
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
std::unique_ptr< TrackerTopology > theTrackerTopology_
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > topoEsTokenER_

◆ fillDescriptions()

void SiStripLorentzAnglePCLHarvester::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 343 of file SiStripLorentzAnglePCLHarvester.cc.

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

343  {
345  desc.setComment("Harvester module of the SiStrip Lorentz Angle PCL monitoring workflow");
346  desc.add<bool>("debugMode", false)->setComment("determines if it's in debug mode");
347  desc.add<std::string>("dqmDir", "AlCaReco/SiStripLorentzAngle")->setComment("the directory of PCL Worker output");
348  desc.add<std::vector<double>>("fitRange", {0., 0.})->setComment("range of depths to perform the LA fit");
349  desc.add<std::string>("record", "SiStripLorentzAngleRcd")->setComment("target DB record");
350  descriptions.addWithDefaultLabel(desc);
351 }
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)

◆ getStem()

std::string SiStripLorentzAnglePCLHarvester::getStem ( const std::string &  histoName,
bool  isFolder 
)
private

Definition at line 320 of file SiStripLorentzAnglePCLHarvester.cc.

References HltBtagPostValidation_cff::histoName, convertSQLitetoXML_cfg::output, AlCaHLTBitMon_QueryRunRegistry::string, and unpackBuffers-CaloStage2::token.

Referenced by dqmEndJob().

320  {
321  std::vector<std::string> tokens;
322 
324  // Create a string stream from the input string
325  std::istringstream iss(histoName);
326 
328  while (std::getline(iss, token, '_')) {
329  // Add each token to the vector
330  tokens.push_back(token);
331  }
332 
333  if (isFolder) {
334  output = tokens[0] + "/" + tokens[1];
335  output.pop_back();
336  } else {
337  output = tokens[0] + "_" + tokens[1];
338  }
339  return output;
340 }

Member Data Documentation

◆ currentLorentzAngle_

const SiStripLorentzAngle* SiStripLorentzAnglePCLHarvester::currentLorentzAngle_
private

Definition at line 83 of file SiStripLorentzAnglePCLHarvester.cc.

Referenced by beginRun().

◆ debug_

const bool SiStripLorentzAnglePCLHarvester::debug_
private

Definition at line 71 of file SiStripLorentzAnglePCLHarvester.cc.

Referenced by dqmEndJob().

◆ dqmDir_

const std::string SiStripLorentzAnglePCLHarvester::dqmDir_
private

Definition at line 74 of file SiStripLorentzAnglePCLHarvester.cc.

Referenced by dqmEndJob().

◆ fitRange_

const std::vector<double> SiStripLorentzAnglePCLHarvester::fitRange_
private

Definition at line 75 of file SiStripLorentzAnglePCLHarvester.cc.

◆ geomEsToken_

const edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> SiStripLorentzAnglePCLHarvester::geomEsToken_
private

Definition at line 60 of file SiStripLorentzAnglePCLHarvester.cc.

Referenced by beginRun().

◆ hists_

SiStripLorentzAngleCalibrationHistograms SiStripLorentzAnglePCLHarvester::hists_
private

Definition at line 82 of file SiStripLorentzAnglePCLHarvester.cc.

◆ iHists_

SiStripLorentzAngleCalibrationHistograms SiStripLorentzAnglePCLHarvester::iHists_
private

Definition at line 72 of file SiStripLorentzAnglePCLHarvester.cc.

Referenced by beginRun(), and dqmEndJob().

◆ latencyToken_

const edm::ESGetToken<SiStripLatency, SiStripLatencyRcd> SiStripLorentzAnglePCLHarvester::latencyToken_
private

Definition at line 62 of file SiStripLorentzAnglePCLHarvester.cc.

Referenced by beginRun().

◆ magneticFieldToken_

const edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> SiStripLorentzAnglePCLHarvester::magneticFieldToken_
private

Definition at line 64 of file SiStripLorentzAnglePCLHarvester.cc.

Referenced by beginRun().

◆ mismatchedBField_

bool SiStripLorentzAnglePCLHarvester::mismatchedBField_
private

Definition at line 68 of file SiStripLorentzAnglePCLHarvester.cc.

Referenced by beginRun(), and dqmEndJob().

◆ mismatchedLatency_

bool SiStripLorentzAnglePCLHarvester::mismatchedLatency_
private

Definition at line 69 of file SiStripLorentzAnglePCLHarvester.cc.

Referenced by beginRun(), and dqmEndJob().

◆ recordName_

const std::string SiStripLorentzAnglePCLHarvester::recordName_
private

Definition at line 76 of file SiStripLorentzAnglePCLHarvester.cc.

Referenced by dqmEndJob().

◆ siStripLAEsToken_

const edm::ESGetToken<SiStripLorentzAngle, SiStripLorentzAngleDepRcd> SiStripLorentzAnglePCLHarvester::siStripLAEsToken_
private

Definition at line 63 of file SiStripLorentzAnglePCLHarvester.cc.

Referenced by beginRun().

◆ teslaToInverseGeV_

constexpr float SiStripLorentzAnglePCLHarvester::teslaToInverseGeV_ = 2.99792458e-3f
staticprivate

Definition at line 79 of file SiStripLorentzAnglePCLHarvester.cc.

Referenced by beginRun().

◆ theFitRange_

std::pair<double, double> SiStripLorentzAnglePCLHarvester::theFitRange_ {0., 0.}
private

Definition at line 80 of file SiStripLorentzAnglePCLHarvester.cc.

Referenced by dqmEndJob().

◆ theMagField_

float SiStripLorentzAnglePCLHarvester::theMagField_ {0.f}
private

Definition at line 77 of file SiStripLorentzAnglePCLHarvester.cc.

Referenced by beginRun(), and dqmEndJob().

◆ theTrackerTopology_

std::unique_ptr<TrackerTopology> SiStripLorentzAnglePCLHarvester::theTrackerTopology_
private

Definition at line 84 of file SiStripLorentzAnglePCLHarvester.cc.

Referenced by endRun().

◆ topoEsTokenBR_

const edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> SiStripLorentzAnglePCLHarvester::topoEsTokenBR_
private

Definition at line 61 of file SiStripLorentzAnglePCLHarvester.cc.

Referenced by beginRun().

◆ topoEsTokenER_

const edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> SiStripLorentzAnglePCLHarvester::topoEsTokenER_
private

Definition at line 61 of file SiStripLorentzAnglePCLHarvester.cc.

Referenced by endRun().