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 45 of file SiStripLorentzAnglePCLHarvester.cc.

Constructor & Destructor Documentation

◆ SiStripLorentzAnglePCLHarvester()

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

Definition at line 87 of file SiStripLorentzAnglePCLHarvester.cc.

88  : geomEsToken_(esConsumes<edm::Transition::BeginRun>()),
89  topoEsTokenBR_(esConsumes<edm::Transition::BeginRun>()),
90  topoEsTokenER_(esConsumes<edm::Transition::EndRun>()),
91  latencyToken_(esConsumes<edm::Transition::BeginRun>()),
92  siStripLAEsToken_(esConsumes<edm::Transition::BeginRun>()),
93  magneticFieldToken_(esConsumes<edm::Transition::BeginRun>()),
94  mismatchedBField_{false},
95  mismatchedLatency_{false},
96  debug_(iConfig.getParameter<bool>("debugMode")),
97  dqmDir_(iConfig.getParameter<std::string>("dqmDir")),
98  fitRange_(iConfig.getParameter<std::vector<double>>("fitRange")),
99  recordName_(iConfig.getParameter<std::string>("record")) {
100  // initialize the fit range
101  if (fitRange_.size() == 2) {
102  theFitRange_.first = fitRange_[0];
103  theFitRange_.second = fitRange_[1];
104  } else {
105  throw cms::Exception("SiStripLorentzAnglePCLHarvester") << "Too many fit range parameters specified";
106  }
107 
108  // first ensure DB output service is available
110  if (!poolDbService.isAvailable())
111  throw cms::Exception("SiStripLorentzAnglePCLHarvester") << "PoolDBService required";
112 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
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 115 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_.

115  {
116  // geometry
117  const TrackerGeometry* geom = &iSetup.getData(geomEsToken_);
118  const TrackerTopology* tTopo = &iSetup.getData(topoEsTokenBR_);
119 
120  const MagneticField* magField = &iSetup.getData(magneticFieldToken_);
122 
123  // B-field value
124  // inverseBzAtOriginInGeV() returns the inverse of field z component for this map in GeV
125  // for the conversion please consult https://github.com/cms-sw/cmssw/blob/master/MagneticField/Engine/src/MagneticField.cc#L17
126  // theInverseBzAtOriginInGeV = 1.f / (at0z * 2.99792458e-3f);
127  // ==> at0z = 1.f / (theInverseBzAtOriginInGeV * 2.99792458e-3f)
128 
130 
131  if (iHists_.bfield_.empty()) {
133  } else {
135  mismatchedBField_ = true;
136  }
137  }
138 
139  const SiStripLatency* apvlat = &iSetup.getData(latencyToken_);
140  if (iHists_.apvmode_.empty()) {
142  } else {
144  mismatchedLatency_ = true;
145  }
146  }
147 
148  auto dets = geom->detsTIB();
149  dets.insert(dets.end(), geom->detsTID().begin(), geom->detsTID().end());
150  dets.insert(dets.end(), geom->detsTOB().begin(), geom->detsTOB().end());
151  dets.insert(dets.end(), geom->detsTEC().begin(), geom->detsTEC().end());
152 
153  for (auto det : dets) {
154  auto detid = det->geographicalId().rawId();
155  const StripGeomDetUnit* stripDet = dynamic_cast<const StripGeomDetUnit*>(geom->idToDet(det->geographicalId()));
156  if (stripDet) {
159  }
160  }
161 }
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 171 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().

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

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

164  {
165  if (!theTrackerTopology_) {
166  theTrackerTopology_ = std::make_unique<TrackerTopology>(isetup.getData(topoEsTokenER_));
167  }
168 }
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 344 of file SiStripLorentzAnglePCLHarvester.cc.

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

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

◆ getStem()

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

Definition at line 321 of file SiStripLorentzAnglePCLHarvester.cc.

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

Referenced by dqmEndJob().

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

Member Data Documentation

◆ currentLorentzAngle_

const SiStripLorentzAngle* SiStripLorentzAnglePCLHarvester::currentLorentzAngle_
private

Definition at line 82 of file SiStripLorentzAnglePCLHarvester.cc.

Referenced by beginRun().

◆ debug_

const bool SiStripLorentzAnglePCLHarvester::debug_
private

Definition at line 70 of file SiStripLorentzAnglePCLHarvester.cc.

Referenced by dqmEndJob().

◆ dqmDir_

const std::string SiStripLorentzAnglePCLHarvester::dqmDir_
private

Definition at line 73 of file SiStripLorentzAnglePCLHarvester.cc.

Referenced by dqmEndJob().

◆ fitRange_

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

Definition at line 74 of file SiStripLorentzAnglePCLHarvester.cc.

◆ geomEsToken_

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

Definition at line 59 of file SiStripLorentzAnglePCLHarvester.cc.

Referenced by beginRun().

◆ hists_

SiStripLorentzAngleCalibrationHistograms SiStripLorentzAnglePCLHarvester::hists_
private

Definition at line 81 of file SiStripLorentzAnglePCLHarvester.cc.

◆ iHists_

SiStripLorentzAngleCalibrationHistograms SiStripLorentzAnglePCLHarvester::iHists_
private

Definition at line 71 of file SiStripLorentzAnglePCLHarvester.cc.

Referenced by beginRun(), and dqmEndJob().

◆ latencyToken_

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

Definition at line 61 of file SiStripLorentzAnglePCLHarvester.cc.

Referenced by beginRun().

◆ magneticFieldToken_

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

Definition at line 63 of file SiStripLorentzAnglePCLHarvester.cc.

Referenced by beginRun().

◆ mismatchedBField_

bool SiStripLorentzAnglePCLHarvester::mismatchedBField_
private

Definition at line 67 of file SiStripLorentzAnglePCLHarvester.cc.

Referenced by beginRun(), and dqmEndJob().

◆ mismatchedLatency_

bool SiStripLorentzAnglePCLHarvester::mismatchedLatency_
private

Definition at line 68 of file SiStripLorentzAnglePCLHarvester.cc.

Referenced by beginRun(), and dqmEndJob().

◆ recordName_

const std::string SiStripLorentzAnglePCLHarvester::recordName_
private

Definition at line 75 of file SiStripLorentzAnglePCLHarvester.cc.

Referenced by dqmEndJob().

◆ siStripLAEsToken_

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

Definition at line 62 of file SiStripLorentzAnglePCLHarvester.cc.

Referenced by beginRun().

◆ teslaToInverseGeV_

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

Definition at line 78 of file SiStripLorentzAnglePCLHarvester.cc.

Referenced by beginRun().

◆ theFitRange_

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

Definition at line 79 of file SiStripLorentzAnglePCLHarvester.cc.

Referenced by dqmEndJob().

◆ theMagField_

float SiStripLorentzAnglePCLHarvester::theMagField_ {0.f}
private

Definition at line 76 of file SiStripLorentzAnglePCLHarvester.cc.

Referenced by beginRun(), and dqmEndJob().

◆ theTrackerTopology_

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

Definition at line 83 of file SiStripLorentzAnglePCLHarvester.cc.

Referenced by endRun().

◆ topoEsTokenBR_

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

Definition at line 60 of file SiStripLorentzAnglePCLHarvester.cc.

Referenced by beginRun().

◆ topoEsTokenER_

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

Definition at line 60 of file SiStripLorentzAnglePCLHarvester.cc.

Referenced by endRun().