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 | Private Attributes
SiPixelLorentzAnglePCLHarvester Class Reference

#include <CalibTracker/SiPixelLorentzAngle/src/SiPixelLorentzAnglePCLHarvester.cc>

Inheritance diagram for SiPixelLorentzAnglePCLHarvester:
DQMEDHarvester edm::one::EDProducer< T > edm::one::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

void beginRun (const edm::Run &, const edm::EventSetup &) override
 
 SiPixelLorentzAnglePCLHarvester (const edm::ParameterSet &)
 
 ~SiPixelLorentzAnglePCLHarvester () 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< 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 &)
 
- 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
 
void findMean (MonitorElement *h_drift_depth_adc_slice_, int i, int i_ring)
 
SiPixelLAHarvest::fitResults fitAndStore (std::shared_ptr< SiPixelLorentzAngle > theLA, int i_idx, int i_lay, int i_mod)
 

Private Attributes

const SiPixelLorentzAnglecurrentLorentzAngle
 
const std::string dqmDir_
 
std::unique_ptr< TF1 > f1
 
const double fitChi2Cut_
 
edm::ESGetToken
< TrackerGeometry,
TrackerDigiGeometryRecord
geomEsToken_
 
SiPixelLorentzAngleCalibrationHistograms hists
 
const MagneticFieldmagField
 
edm::ESGetToken< MagneticField,
IdealMagneticFieldRecord
magneticFieldToken_
 
const int minHitsCut_
 
std::vector< std::string > newmodulelist_
 
const std::string recordName_
 
edm::ESGetToken
< SiPixelLorentzAngle,
SiPixelLorentzAngleRcd
siPixelLAEsToken_
 
std::unique_ptr< TrackerTopologytheTrackerTopology
 
edm::ESGetToken
< TrackerTopology,
TrackerTopologyRcd
topoEsTokenBR_
 
edm::ESGetToken
< TrackerTopology,
TrackerTopologyRcd
topoEsTokenER_
 
float width_
 

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

Description: reads the intermediate ALCAPROMPT DQMIO-like dataset and performs the fitting of the SiPixel Lorentz Angle in the Prompt Calibration Loop Implementation: Reads the 2D histograms of the drift vs depth created by SiPixelLorentzAnglePCLWorker modules and generates 1D profiles which are then fit with a 5th order polinomial. The extracted value of the tan(theta_L)/B are stored in an output sqlite file which is then uploaded to the conditions database

Definition at line 78 of file SiPixelLorentzAnglePCLHarvester.cc.

Constructor & Destructor Documentation

SiPixelLorentzAnglePCLHarvester::SiPixelLorentzAnglePCLHarvester ( const edm::ParameterSet iConfig)

Definition at line 113 of file SiPixelLorentzAnglePCLHarvester.cc.

References edm::Service< T >::isAvailable().

114  : geomEsToken_(esConsumes<edm::Transition::BeginRun>()),
115  topoEsTokenBR_(esConsumes<edm::Transition::BeginRun>()),
116  topoEsTokenER_(esConsumes<edm::Transition::EndRun>()),
117  siPixelLAEsToken_(esConsumes<edm::Transition::BeginRun>()),
118  magneticFieldToken_(esConsumes<edm::Transition::BeginRun>()),
119  newmodulelist_(iConfig.getParameter<std::vector<std::string>>("newmodulelist")),
120  dqmDir_(iConfig.getParameter<std::string>("dqmDir")),
121  fitChi2Cut_(iConfig.getParameter<double>("fitChi2Cut")),
122  minHitsCut_(iConfig.getParameter<int>("minHitsCut")),
123  recordName_(iConfig.getParameter<std::string>("record")) {
124  // first ensure DB output service is available
126  if (!poolDbService.isAvailable())
127  throw cms::Exception("SiPixelLorentzAnglePCLHarvester") << "PoolDBService required";
128 }
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > topoEsTokenBR_
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > topoEsTokenER_
edm::ESGetToken< SiPixelLorentzAngle, SiPixelLorentzAngleRcd > siPixelLAEsToken_
bool isAvailable() const
Definition: Service.h:40
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > geomEsToken_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magneticFieldToken_
SiPixelLorentzAnglePCLHarvester::~SiPixelLorentzAnglePCLHarvester ( )
overridedefault

Member Function Documentation

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

Definition at line 131 of file SiPixelLorentzAnglePCLHarvester.cc.

References PixelEndcapName::bladeName(), Surface::bounds(), SiPixelLorentzAngleCalibrationHistograms::BPixnewDetIds_, SiPixelLorentzAngleCalibrationHistograms::BPixnewLayer_, SiPixelLorentzAngleCalibrationHistograms::BPixnewModule_, SiPixelLorentzAngleCalibrationHistograms::BPixnewmodulename_, submitPVResolutionJobs::count, currentLorentzAngle, SiPixelLorentzAngleCalibrationHistograms::detIdsList, TrackerGeometry::detsPXB(), PixelEndcapName::diskName(), spr::find(), SiPixelLorentzAngleCalibrationHistograms::FPixnewBlade_, SiPixelLorentzAngleCalibrationHistograms::FPixnewDetIds_, SiPixelLorentzAngleCalibrationHistograms::FPixnewDisk_, SiPixelLorentzAngleCalibrationHistograms::FPixnewmodulename_, GeomDet::geographicalId(), relativeConstraints::geom, geomEsToken_, edm::EventSetup::getData(), PixelBarrelName::getDetId(), PixelEndcapName::getDetId(), PixelTopologyMap::getPXBLadders(), PixelTopologyMap::getPXBModules(), hists, mps_fire::i, gpuClustering::id, phase1PixelTopology::layer, PixelBarrelName::layerName(), LogDebug, magField, magneticFieldToken_, callgraph::module, PixelBarrelName::moduleName(), newmodulelist_, SiPixelLorentzAngleCalibrationHistograms::nLadders_, SiPixelLorentzAngleCalibrationHistograms::nlay, SiPixelLorentzAngleCalibrationHistograms::nModules_, TrackerGeometry::numberOfLayers(), PixelSubdetector::PixelBarrel, TrackerTopology::pxbLayer(), TrackerTopology::pxbModule(), DetId::rawId(), siPixelLAEsToken_, GeomDet::surface(), Bounds::thickness(), topoEsTokenBR_, parallelization::uint(), and width_.

131  {
132  // geometry
133  const TrackerGeometry* geom = &iSetup.getData(geomEsToken_);
134  const TrackerTopology* tTopo = &iSetup.getData(topoEsTokenBR_);
135 
138 
139  PixelTopologyMap map = PixelTopologyMap(geom, tTopo);
141  hists.nModules_.resize(hists.nlay);
142  hists.nLadders_.resize(hists.nlay);
143  for (int i = 0; i < hists.nlay; i++) {
144  hists.nModules_[i] = map.getPXBModules(i + 1);
145  hists.nLadders_[i] = map.getPXBLadders(i + 1);
146  }
147 
148  // list of modules already filled, then return (we already entered here)
149  if (!hists.BPixnewDetIds_.empty() || !hists.FPixnewDetIds_.empty())
150  return;
151 
152  if (!newmodulelist_.empty()) {
153  for (auto const& modulename : newmodulelist_) {
154  if (modulename.find("BPix_") != std::string::npos) {
155  PixelBarrelName bn(modulename, true);
156  const auto& detId = bn.getDetId(tTopo);
157  hists.BPixnewmodulename_.push_back(modulename);
158  hists.BPixnewDetIds_.push_back(detId.rawId());
159  hists.BPixnewModule_.push_back(bn.moduleName());
160  hists.BPixnewLayer_.push_back(bn.layerName());
161  } else if (modulename.find("FPix_") != std::string::npos) {
162  PixelEndcapName en(modulename, true);
163  const auto& detId = en.getDetId(tTopo);
164  hists.FPixnewmodulename_.push_back(modulename);
165  hists.FPixnewDetIds_.push_back(detId.rawId());
166  hists.FPixnewDisk_.push_back(en.diskName());
167  hists.FPixnewBlade_.push_back(en.bladeName());
168  }
169  }
170  }
171 
172  uint count = 0;
173  for (const auto& id : hists.BPixnewDetIds_) {
174  LogDebug("SiPixelLorentzAnglePCLHarvester") << id;
175  count++;
176  }
177  LogDebug("SiPixelLorentzAnglePCLHarvester") << "Stored a total of " << count << " new detIds.";
178 
179  // list of modules already filled, return (we already entered here)
180  if (!hists.detIdsList.empty())
181  return;
182 
183  std::vector<uint32_t> treatedIndices;
184 
185  for (auto det : geom->detsPXB()) {
186  const PixelGeomDetUnit* pixelDet = dynamic_cast<const PixelGeomDetUnit*>(det);
187  width_ = pixelDet->surface().bounds().thickness();
188  const auto& layer = tTopo->pxbLayer(pixelDet->geographicalId());
189  const auto& module = tTopo->pxbModule(pixelDet->geographicalId());
190  int i_index = module + (layer - 1) * hists.nModules_[layer - 1];
191 
192  uint32_t rawId = pixelDet->geographicalId().rawId();
193 
194  // if the detId is already accounted for in the special class, do not attach it
195  if (std::find(hists.BPixnewDetIds_.begin(), hists.BPixnewDetIds_.end(), rawId) != hists.BPixnewDetIds_.end())
196  continue;
197 
198  if (std::find(treatedIndices.begin(), treatedIndices.end(), i_index) != treatedIndices.end()) {
199  hists.detIdsList.at(i_index).push_back(rawId);
200  } else {
201  hists.detIdsList.insert(std::pair<uint32_t, std::vector<uint32_t>>(i_index, {rawId}));
202  treatedIndices.push_back(i_index);
203  }
204  }
205 
206  count = 0;
207  for (const auto& i : treatedIndices) {
208  for (const auto& id : hists.detIdsList.at(i)) {
209  LogDebug("SiPixelLorentzAnglePCLHarvester") << id;
210  count++;
211  };
212  }
213  LogDebug("SiPixelLorentzAnglePCLHarvester") << "Stored a total of " << count << " detIds.";
214 }
uint16_t *__restrict__ id
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > topoEsTokenBR_
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
const Bounds & bounds() const
Definition: Surface.h:87
unsigned int pxbModule(const DetId &id) const
SiPixelLorentzAngleCalibrationHistograms hists
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
unsigned int numberOfLayers(int subdet) const
constexpr std::array< uint8_t, layerIndexSize > layer
virtual float thickness() const =0
bool getData(T &iHolder) const
Definition: EventSetup.h:128
edm::ESGetToken< SiPixelLorentzAngle, SiPixelLorentzAngleRcd > siPixelLAEsToken_
const unsigned getPXBModules(unsigned int lay) const
std::unordered_map< uint32_t, std::vector< uint32_t > > detIdsList
const DetContainer & detsPXB() const
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > geomEsToken_
DetId geographicalId() const
The label of this GeomDet.
Definition: GeomDet.h:64
unsigned int pxbLayer(const DetId &id) const
const unsigned getPXBLadders(unsigned int lay) const
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magneticFieldToken_
tuple module
Definition: callgraph.py:69
#define LogDebug(id)
void SiPixelLorentzAnglePCLHarvester::dqmEndJob ( DQMStore::IBooker iBooker,
DQMStore::IGetter iGetter 
)
overrideprivatevirtual

Implements DQMEDHarvester.

Definition at line 224 of file SiPixelLorentzAnglePCLHarvester.cc.

References newFWLiteAna::bin, dqm::implementation::IBooker::book1D(), dqm::implementation::IBooker::book2D(), SiPixelLorentzAngleCalibrationHistograms::BPixnewDetIds_, SiPixelLorentzAngleCalibrationHistograms::BPixnewLayer_, SiPixelLorentzAngleCalibrationHistograms::BPixnewModule_, SiPixelLorentzAngleCalibrationHistograms::BPixnewmodulename_, dqm::implementation::NavigatorBase::cd(), currentLorentzAngle, cond::service::PoolDBOutputService::currentTime(), dqmDir_, cppFunctionSkipper::exception, validate-o2o-wbm::f, dqm::impl::MonitorElement::Fill(), findMean(), fitAndStore(), diffTreeTool::format(), dqm::implementation::IGetter::get(), SiPixelLorentzAngle::getLorentzAngle(), SiPixelLorentzAngle::getLorentzAngles(), dqm::impl::MonitorElement::getNbinsX(), dqm::impl::MonitorElement::getTH1(), SiPixelLorentzAngleCalibrationHistograms::h2_byLayerDiff_, SiPixelLorentzAngleCalibrationHistograms::h2_byLayerLA_, SiPixelLorentzAngleCalibrationHistograms::h_bySectChi2_, SiPixelLorentzAngleCalibrationHistograms::h_bySectDeltaLA_, SiPixelLorentzAngleCalibrationHistograms::h_bySectLA_, SiPixelLorentzAngleCalibrationHistograms::h_bySectMeasLA_, SiPixelLorentzAngleCalibrationHistograms::h_bySectOccupancy_, SiPixelLorentzAngleCalibrationHistograms::h_bySectRejectLA_, SiPixelLorentzAngleCalibrationHistograms::h_bySectSetLA_, SiPixelLorentzAngleCalibrationHistograms::h_drift_depth_, SiPixelLorentzAngleCalibrationHistograms::h_drift_depth_adc2_, SiPixelLorentzAngleCalibrationHistograms::h_drift_depth_adc_, SiPixelLorentzAngleCalibrationHistograms::h_drift_depth_noadc_, SiPixelLorentzAngleCalibrationHistograms::h_mean_, hists, mps_fire::i, if(), edm::Service< T >::isAvailable(), dqmiolumiharvest::j, PVValHelper::ladder, phase1PixelTopology::layer, callgraph::module, SiPixelLorentzAngleCalibrationHistograms::nLadders_, SiPixelLorentzAngleCalibrationHistograms::nlay, SiPixelLorentzAngleCalibrationHistograms::nModules_, PixelSubdetector::PixelBarrel, recordName_, dqm::impl::MonitorElement::setBinLabel(), dqm::implementation::NavigatorBase::setCurrentFolder(), AlCaHLTBitMon_QueryRunRegistry::string, DetId::subdetId(), theTrackerTopology, HcalDetIdTransform::transform(), relativeConstraints::value, cms::Exception::what(), and cond::service::PoolDBOutputService::writeOneIOV().

224  {
225  // go in the right directory
226  iGetter.cd();
227  iGetter.setCurrentFolder(dqmDir_);
228 
229  // fetch the 2D histograms
230  for (int i_layer = 1; i_layer <= hists.nlay; i_layer++) {
231  const auto& prefix_ = fmt::sprintf("%s/BPix/BPixLayer%i", dqmDir_, i_layer);
232  for (int i_module = 1; i_module <= hists.nModules_[i_layer - 1]; i_module++) {
233  int i_index = i_module + (i_layer - 1) * hists.nModules_[i_layer - 1];
234 
235  hists.h_drift_depth_[i_index] =
236  iGetter.get(fmt::format("{}/h_drift_depth_layer{}_module{}", prefix_, i_layer, i_module));
237 
238  if (hists.h_drift_depth_[i_index] == nullptr) {
239  edm::LogError("SiPixelLorentzAnglePCLHarvester::dqmEndJob")
240  << "Failed to retrieve electron drift over depth for layer " << i_layer << ", module " << i_module << ".";
241  continue;
242  }
243 
244  hists.h_drift_depth_adc_[i_index] =
245  iGetter.get(fmt::format("{}/h_drift_depth_adc_layer{}_module{}", prefix_, i_layer, i_module));
246 
247  hists.h_drift_depth_adc2_[i_index] =
248  iGetter.get(fmt::format("{}/h_drift_depth_adc2_layer{}_module{}", prefix_, i_layer, i_module));
249 
250  hists.h_drift_depth_noadc_[i_index] =
251  iGetter.get(fmt::format("{}/h_drift_depth_noadc_layer{}_module{}", prefix_, i_layer, i_module));
252 
253  hists.h_mean_[i_index] = iGetter.get(fmt::format("{}/h_mean_layer{}_module{}", dqmDir_, i_layer, i_module));
254 
255  hists.h_drift_depth_[i_index]->divide(
256  hists.h_drift_depth_adc_[i_index], hists.h_drift_depth_noadc_[i_index], 1., 1., "");
257  }
258  }
259 
260  // fetch the new modules 2D histograms
261  for (int i = 0; i < (int)hists.BPixnewDetIds_.size(); i++) {
262  int new_index = i + 1 + hists.nModules_[hists.nlay - 1] + (hists.nlay - 1) * hists.nModules_[hists.nlay - 1];
263 
264  hists.h_drift_depth_[new_index] = iGetter.get(
265  fmt::format("{}/h_BPixnew_drift_depth_{}", dqmDir_ + "/BPix/NewModules", hists.BPixnewmodulename_[i]));
266 
267  if (hists.h_drift_depth_[new_index] == nullptr) {
268  edm::LogError("SiPixelLorentzAnglePCLHarvester")
269  << "Failed to retrieve electron drift over depth for new module " << hists.BPixnewmodulename_[i] << ".";
270  continue;
271  }
272 
273  hists.h_drift_depth_adc_[new_index] = iGetter.get(
274  fmt::format("{}/h_BPixnew_drift_depth_adc_{}", dqmDir_ + "/BPix/NewModules", hists.BPixnewmodulename_[i]));
275 
276  hists.h_drift_depth_adc2_[new_index] = iGetter.get(
277  fmt::format("{}/h_BPixnew_drift_depth_adc2_{}", dqmDir_ + "/BPix/NewModules", hists.BPixnewmodulename_[i]));
278 
279  hists.h_drift_depth_noadc_[new_index] = iGetter.get(
280  fmt::format("{}/h_BPixnew_drift_depth_noadc_{}", dqmDir_ + "/BPix/NewModules", hists.BPixnewmodulename_[i]));
281 
282  hists.h_mean_[new_index] = iGetter.get(fmt::format("{}/h_BPixnew_mean_{}", dqmDir_, hists.BPixnewmodulename_[i]));
283 
284  hists.h_drift_depth_[new_index]->divide(
285  hists.h_drift_depth_adc_[new_index], hists.h_drift_depth_noadc_[new_index], 1., 1., "");
286  }
287 
288  hists.h_bySectOccupancy_ = iGetter.get(fmt::format("{}/h_bySectorOccupancy", dqmDir_ + "/SectorMonitoring"));
289  if (hists.h_bySectOccupancy_ == nullptr) {
290  edm::LogError("SiPixelLorentzAnglePCLHarvester") << "Failed to retrieve the hit on track occupancy.";
291  return;
292  }
293 
294  int hist_drift_;
295  int hist_depth_;
296  double min_drift_;
297  double max_drift_;
298 
299  if (hists.h_drift_depth_adc_[1] != nullptr) {
300  hist_drift_ = hists.h_drift_depth_adc_[1]->getNbinsX();
301  hist_depth_ = hists.h_drift_depth_adc_[1]->getNbinsY();
302  min_drift_ = hists.h_drift_depth_adc_[1]->getAxisMin(1);
303  max_drift_ = hists.h_drift_depth_adc_[1]->getAxisMax(1);
304  } else {
305  hist_drift_ = 100;
306  hist_depth_ = 50;
307  min_drift_ = -500.;
308  max_drift_ = 500.;
309  }
310 
311  iBooker.setCurrentFolder(fmt::format("{}Harvesting", dqmDir_));
312  MonitorElement* h_drift_depth_adc_slice_ =
313  iBooker.book1D("h_drift_depth_adc_slice", "slice of adc histogram", hist_drift_, min_drift_, max_drift_);
314 
315  // book histogram of differences
316  MonitorElement* h_diffLA = iBooker.book1D(
317  "h_diffLA", "difference in #mu_{H}; #Delta #mu_{H}/#mu_{H} (old-new)/old [%];n. modules", 100, -150, 150);
318 
319  // retrieve the number of bins from the other monitoring histogram
320  const auto& maxSect = hists.h_bySectOccupancy_->getNbinsX();
321  const double lo = -0.5;
322  const double hi = maxSect - 0.5;
323 
324  // this will be booked in the Harvesting folder
325  iBooker.setCurrentFolder(fmt::format("{}Harvesting/SectorMonitoring", dqmDir_));
326  std::string repText = "%s tan#theta_{LA}/B by sector;pixel sector;%s tan(#theta_{LA})/B [1/T]";
328  iBooker.book1D("h_LAbySector_Measured", fmt::sprintf(repText, "measured", "measured"), maxSect, lo, hi);
330  iBooker.book1D("h_LAbySector_Accepted", fmt::sprintf(repText, "accepted", "accepted"), maxSect, lo, hi);
332  iBooker.book1D("h_LAbySector_Rejected", fmt::sprintf(repText, "rejected", "rejected"), maxSect, lo, hi);
333  hists.h_bySectLA_ = iBooker.book1D("h_LAbySector", fmt::sprintf(repText, "payload", "payload"), maxSect, lo, hi);
335  iBooker.book1D("h_deltaLAbySector", fmt::sprintf(repText, "#Delta", "#Delta"), maxSect, lo, hi);
337  iBooker.book1D("h_bySectorChi2", "Fit #chi^{2}/ndf by sector;pixel sector; fit #chi^{2}/ndf", maxSect, lo, hi);
338 
339  // copy the bin labels from the occupancy histogram
340  for (int bin = 1; bin <= maxSect; bin++) {
341  const auto& binName = hists.h_bySectOccupancy_->getTH1()->GetXaxis()->GetBinLabel(bin);
343  hists.h_bySectSetLA_->setBinLabel(bin, binName);
345  hists.h_bySectLA_->setBinLabel(bin, binName);
347  hists.h_bySectChi2_->setBinLabel(bin, binName);
348  }
349 
350  // this will be booked in the Harvesting folder
351  iBooker.setCurrentFolder(fmt::format("{}Harvesting/LorentzAngleMaps", dqmDir_));
352  for (int i = 0; i < hists.nlay; i++) {
353  std::string repName = "h2_byLayerLA_%i";
354  std::string repText = "BPix Layer %i tan#theta_{LA}/B;module number;ladder number;tan#theta_{LA}/B [1/T]";
355 
356  hists.h2_byLayerLA_.emplace_back(iBooker.book2D(fmt::sprintf(repName, i + 1),
357  fmt::sprintf(repText, i + 1),
358  hists.nModules_[i],
359  0.5,
360  hists.nModules_[i] + 0.5,
361  hists.nLadders_[i],
362  0.5,
363  hists.nLadders_[i] + 0.5));
364 
365  repName = "h2_byLayerDiff_%i";
366  repText = "BPix Layer %i #Delta#mu_{H}/#mu_{H};module number;ladder number;#Delta#mu_{H}/#mu_{H} [%%]";
367  hists.h2_byLayerDiff_.emplace_back(iBooker.book2D(fmt::sprintf(repName, i + 1),
368  fmt::sprintf(repText, i + 1),
369  hists.nModules_[i],
370  0.5,
371  hists.nModules_[i] + 0.5,
372  hists.nLadders_[i],
373  0.5,
374  hists.nLadders_[i] + 0.5));
375  }
376 
377  // clang-format off
378  edm::LogPrint("LorentzAngle") << "module" << "\t" << "layer" << "\t"
379  << "offset" << "\t" << "e0" << "\t"
380  << "slope" << "\t" << "e1" << "\t"
381  << "rel.err" << "\t" << "pull" << "\t"
382  << "p2" << "\t" << "e2" << "\t"
383  << "p3" << "\t" << "e3" << "\t"
384  << "p4" << "\t" << "e4" << "\t"
385  << "p5" << "\t" << "e5" << "\t"
386  << "chi2" << "\t" << "prob" << "\t"
387  << "newDetId" << "\t" << "tan(LA)" << "\t"
388  << "Error(LA)" ;
389  // clang-format on
390 
391  // payload to be written out
392  std::shared_ptr<SiPixelLorentzAngle> LorentzAngle = std::make_shared<SiPixelLorentzAngle>();
393 
394  // fill the map of simulation values
395  double p1_simul_newmodule = 0.294044;
396  double p1_simul[hists.nlay + 1][hists.nModules_[hists.nlay - 1]];
397  for (int i_layer = 1; i_layer <= hists.nlay; i_layer++) {
398  for (int i_module = 1; i_module <= hists.nModules_[i_layer - 1]; i_module++) {
399  if (i_layer == 1)
400  p1_simul[i_layer - 1][i_module - 1] = 0.436848;
401  else if (i_layer == 2)
402  p1_simul[i_layer - 1][i_module - 1] = 0.25802;
403  else if (i_layer == 3 && i_module <= 4)
404  p1_simul[i_layer - 1][i_module - 1] = 0.29374;
405  else if (i_layer == 3 && i_module >= 5)
406  p1_simul[i_layer - 1][i_module - 1] = 0.31084;
407  else if (i_layer == 4 && i_module <= 4)
408  p1_simul[i_layer - 1][i_module - 1] = 0.29944;
409  else
410  p1_simul[i_layer - 1][i_module - 1] = 0.31426;
411  }
412  }
413  // fictitious n-th layer to store the values of new modules
414  for (int i_module = 1; i_module <= hists.nModules_[hists.nlay - 1]; i_module++) {
415  p1_simul[hists.nlay][i_module - 1] = p1_simul_newmodule;
416  }
417 
418  // loop over "new" BPix modules
419  for (int j = 0; j < (int)hists.BPixnewDetIds_.size(); j++) {
420  //uint32_t rawId = hists.BPixnewDetIds_[j];
421  int new_index = j + 1 + hists.nModules_[hists.nlay - 1] + (hists.nlay - 1) * hists.nModules_[hists.nlay - 1];
422  if (hists.h_drift_depth_adc_[new_index] == nullptr)
423  continue;
424  for (int i = 1; i <= hist_depth_; i++) {
425  findMean(h_drift_depth_adc_slice_, i, new_index);
426  }
427 
428  // fit the distributions and store the LA in the payload
429  const auto& res = fitAndStore(LorentzAngle, new_index, hists.BPixnewLayer_[j], hists.BPixnewModule_[j]);
430 
431  edm::LogPrint("SiPixelLorentzAngle") << std::setprecision(4) << hists.BPixnewModule_[j] << "\t"
432  << hists.BPixnewLayer_[j] << "\t" << res.p0 << "\t" << res.e0 << "\t" << res.p1
433  << std::setprecision(3) << "\t" << res.e1 << "\t" << res.e1 / res.p1 * 100.
434  << "\t" << (res.p1 - p1_simul[hists.nlay][0]) / res.e1 << "\t" << res.p2
435  << "\t" << res.e2 << "\t" << res.p3 << "\t" << res.e3 << "\t" << res.p4 << "\t"
436  << res.e4 << "\t" << res.p5 << "\t" << res.e5 << "\t" << res.chi2 << "\t"
437  << res.prob << "\t" << hists.BPixnewDetIds_[j] << "\t" << res.tan_LA << "\t"
438  << res.error_LA;
439  } // loop on BPix new modules
440 
441  //loop over modules and layers to fit the lorentz angle
442  for (int i_layer = 1; i_layer <= hists.nlay; i_layer++) {
443  for (int i_module = 1; i_module <= hists.nModules_[i_layer - 1]; i_module++) {
444  int i_index = i_module + (i_layer - 1) * hists.nModules_[i_layer - 1];
445  if (hists.h_drift_depth_adc_[i_index] == nullptr)
446  continue;
447  //loop over bins in depth (z-local-coordinate) (in order to fit slices)
448  for (int i = 1; i <= hist_depth_; i++) {
449  findMean(h_drift_depth_adc_slice_, i, i_index);
450  } // end loop over bins in depth
451 
452  // fit the distributions and store the LA in the payload
453  const auto& res = fitAndStore(LorentzAngle, i_index, i_layer, i_module);
454 
455  edm::LogPrint("SiPixelLorentzAngle")
456  << std::setprecision(4) << i_module << "\t" << i_layer << "\t" << res.p0 << "\t" << res.e0 << "\t" << res.p1
457  << std::setprecision(3) << "\t" << res.e1 << "\t" << res.e1 / res.p1 * 100. << "\t"
458  << (res.p1 - p1_simul[i_layer - 1][i_module - 1]) / res.e1 << "\t" << res.p2 << "\t" << res.e2 << "\t"
459  << res.p3 << "\t" << res.e3 << "\t" << res.p4 << "\t" << res.e4 << "\t" << res.p5 << "\t" << res.e5 << "\t"
460  << res.chi2 << "\t" << res.prob << "\t"
461  << "null"
462  << "\t" << res.tan_LA << "\t" << res.error_LA;
463  }
464  } // end loop over modules and layers
465 
466  // fill the rest of DetIds not filled above (for the moment FPix)
467  const auto& currentLAMap = currentLorentzAngle->getLorentzAngles();
468  const auto& newLAMap = LorentzAngle->getLorentzAngles();
469  std::vector<unsigned int> currentLADets;
470  std::vector<unsigned int> newLADets;
471 
472  std::transform(currentLAMap.begin(),
473  currentLAMap.end(),
474  std::back_inserter(currentLADets),
475  [](const std::map<unsigned int, float>::value_type& pair) { return pair.first; });
476 
477  std::transform(newLAMap.begin(),
478  newLAMap.end(),
479  std::back_inserter(newLADets),
480  [](const std::map<unsigned int, float>::value_type& pair) { return pair.first; });
481 
482  std::vector<unsigned int> notCommon;
483  std::set_symmetric_difference(
484  currentLADets.begin(), currentLADets.end(), newLADets.begin(), newLADets.end(), std::back_inserter(notCommon));
485 
486  for (const auto& id : notCommon) {
487  float fPixLorentzAnglePerTesla_ = currentLorentzAngle->getLorentzAngle(id);
488  if (!LorentzAngle->putLorentzAngle(id, fPixLorentzAnglePerTesla_)) {
489  edm::LogError("SiPixelLorentzAnglePCLHarvester")
490  << "[SiPixelLorentzAnglePCLHarvester::dqmEndJob] filling rest of payload: detid already exists";
491  }
492  }
493 
494  for (const auto& id : newLADets) {
495  float deltaMuHoverMuH = (currentLorentzAngle->getLorentzAngle(id) - LorentzAngle->getLorentzAngle(id)) /
497  h_diffLA->Fill(deltaMuHoverMuH * 100.f);
498  }
499 
500  // fill the 2D output Lorentz Angle maps
501  for (const auto& [id, value] : LorentzAngle->getLorentzAngles()) {
502  DetId ID = DetId(id);
504  const auto& layer = theTrackerTopology->pxbLayer(id);
505  const auto& ladder = theTrackerTopology->pxbLadder(id);
506  const auto& module = theTrackerTopology->pxbModule(id);
507  hists.h2_byLayerLA_[layer - 1]->setBinContent(module, ladder, value);
508 
509  float deltaMuHoverMuH =
511  hists.h2_byLayerDiff_[layer - 1]->setBinContent(module, ladder, deltaMuHoverMuH * 100.f);
512  }
513  }
514 
515  // fill the DB object record
517  if (mydbservice.isAvailable()) {
518  try {
519  mydbservice->writeOneIOV(*LorentzAngle, mydbservice->currentTime(), recordName_);
520  } catch (const cond::Exception& er) {
521  edm::LogError("SiPixelLorentzAngleDB") << er.what();
522  } catch (const std::exception& er) {
523  edm::LogError("SiPixelLorentzAngleDB") << "caught std::exception " << er.what();
524  }
525  } else {
526  edm::LogError("SiPixelLorentzAngleDB") << "Service is unavailable";
527  }
528 }
std::vector< dqm::reco::MonitorElement * > h2_byLayerLA_
const std::map< unsigned int, float > & getLorentzAngles() const
Base exception class for the object to relational access.
Definition: Exception.h:11
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
uint32_t ID
Definition: Definitions.h:24
void findMean(MonitorElement *h_drift_depth_adc_slice_, int i, int i_ring)
SiPixelLAHarvest::fitResults fitAndStore(std::shared_ptr< SiPixelLorentzAngle > theLA, int i_idx, int i_lay, int i_mod)
SiPixelLorentzAngleCalibrationHistograms hists
Log< level::Error, false > LogError
constexpr std::array< uint8_t, layerIndexSize > layer
void Fill(long long x)
virtual int getNbinsX() const
get # of bins in X-axis
if(conf_.getParameter< bool >("UseStripCablingDB"))
virtual MonitorElement * get(std::string const &fullpath) const
Definition: DQMStore.cc:673
bool isAvailable() const
Definition: Service.h:40
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:48
char const * what() const noexceptoverride
Definition: Exception.cc:103
Hash writeOneIOV(const T &payload, Time_t time, const std::string &recordName)
std::unique_ptr< TrackerTopology > theTrackerTopology
virtual void setBinLabel(int bin, const std::string &label, int axis=1)
set bin label for x, y or z axis (axis=1, 2, 3 respectively)
Log< level::Warning, true > LogPrint
Definition: DetId.h:17
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
Definition: DQMStore.h:177
float getLorentzAngle(const uint32_t &) const
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
std::vector< dqm::reco::MonitorElement * > h2_byLayerDiff_
tuple module
Definition: callgraph.py:69
unsigned transform(const HcalDetId &id, unsigned transformCode)
void SiPixelLorentzAnglePCLHarvester::endRun ( const edm::Run run,
const edm::EventSetup isetup 
)
overrideprivate

Definition at line 217 of file SiPixelLorentzAnglePCLHarvester.cc.

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

217  {
218  if (!theTrackerTopology) {
219  theTrackerTopology = std::make_unique<TrackerTopology>(isetup.getData(topoEsTokenER_));
220  }
221 }
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > topoEsTokenER_
bool getData(T &iHolder) const
Definition: EventSetup.h:128
std::unique_ptr< TrackerTopology > theTrackerTopology
void SiPixelLorentzAnglePCLHarvester::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 694 of file SiPixelLorentzAnglePCLHarvester.cc.

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

694  {
696  desc.setComment("Harvester module of the SiPixel Lorentz Angle PCL monitoring workflow");
697  desc.add<std::vector<std::string>>("newmodulelist", {})->setComment("the list of DetIds for new sensors");
698  desc.add<std::string>("dqmDir", "AlCaReco/SiPixelLorentzAngle")->setComment("the directory of PCL Worker output");
699  desc.add<double>("fitChi2Cut", 20.)->setComment("cut on fit chi2/ndof to accept measurement");
700  desc.add<int>("minHitsCut", 10000)->setComment("cut on minimum number of on-track hits to accept measurement");
701  desc.add<std::string>("record", "SiPixelLorentzAngleRcd")->setComment("target DB record");
702  descriptions.addWithDefaultLabel(desc);
703 }
void setComment(std::string const &value)
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
void setComment(std::string const &value)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void SiPixelLorentzAnglePCLHarvester::findMean ( MonitorElement h_drift_depth_adc_slice_,
int  i,
int  i_ring 
)
private

Definition at line 531 of file SiPixelLorentzAnglePCLHarvester.cc.

References relativeConstraints::error, dqm::impl::MonitorElement::getMean(), dqm::impl::MonitorElement::getNbinsX(), dqm::impl::MonitorElement::getRMS(), SiPixelLorentzAngleCalibrationHistograms::h_drift_depth_, SiPixelLorentzAngleCalibrationHistograms::h_drift_depth_adc2_, SiPixelLorentzAngleCalibrationHistograms::h_drift_depth_adc_, SiPixelLorentzAngleCalibrationHistograms::h_drift_depth_noadc_, SiPixelLorentzAngleCalibrationHistograms::h_mean_, hists, dqmiolumiharvest::j, SiStripPI::mean, dqm::impl::MonitorElement::Reset(), dqm::impl::MonitorElement::setBinContent(), dqm::impl::MonitorElement::setBinError(), and mathSSE::sqrt().

Referenced by dqmEndJob().

531  {
532  double nentries = 0;
533  h_drift_depth_adc_slice_->Reset();
534  int hist_drift_ = h_drift_depth_adc_slice_->getNbinsX();
535 
536  // determine sigma and sigma^2 of the adc counts and average adc counts
537  //loop over bins in drift width
538  for (int j = 1; j <= hist_drift_; j++) {
539  if (hists.h_drift_depth_noadc_[i_ring]->getBinContent(j, i) >= 1) {
540  double adc_error2 = (hists.h_drift_depth_adc2_[i_ring]->getBinContent(j, i) -
541  hists.h_drift_depth_adc_[i_ring]->getBinContent(j, i) *
542  hists.h_drift_depth_adc_[i_ring]->getBinContent(j, i) /
543  hists.h_drift_depth_noadc_[i_ring]->getBinContent(j, i)) /
544  hists.h_drift_depth_noadc_[i_ring]->getBinContent(j, i);
545 
546  hists.h_drift_depth_adc_[i_ring]->setBinError(j, i, sqrt(adc_error2));
547  double error2 = adc_error2 / (hists.h_drift_depth_noadc_[i_ring]->getBinContent(j, i) - 1.);
548  hists.h_drift_depth_[i_ring]->setBinError(j, i, sqrt(error2));
549  } else {
550  hists.h_drift_depth_[i_ring]->setBinError(j, i, 0);
551  hists.h_drift_depth_adc_[i_ring]->setBinError(j, i, 0);
552  }
553  h_drift_depth_adc_slice_->setBinContent(j, hists.h_drift_depth_adc_[i_ring]->getBinContent(j, i));
554  h_drift_depth_adc_slice_->setBinError(j, hists.h_drift_depth_adc_[i_ring]->getBinError(j, i));
555  nentries += hists.h_drift_depth_noadc_[i_ring]->getBinContent(j, i);
556  } // end loop over bins in drift width
557 
558  double mean = h_drift_depth_adc_slice_->getMean(1);
559  double error = 0;
560  if (nentries != 0) {
561  error = h_drift_depth_adc_slice_->getRMS(1) / std::sqrt(nentries);
562  }
563  hists.h_mean_[i_ring]->setBinContent(i, mean);
564  hists.h_mean_[i_ring]->setBinError(i, error);
565 }
SiPixelLorentzAngleCalibrationHistograms hists
virtual void Reset()
Remove all data from the ME, keept the empty histogram with all its settings.
virtual int getNbinsX() const
get # of bins in X-axis
T sqrt(T t)
Definition: SSEVec.h:19
virtual double getMean(int axis=1) const
get mean value of histogram along x, y or z axis (axis=1, 2, 3 respectively)
virtual void setBinContent(int binx, double content)
set content of bin (1-D)
virtual double getRMS(int axis=1) const
get RMS of histogram along x, y or z axis (axis=1, 2, 3 respectively)
virtual void setBinError(int binx, double error)
set uncertainty on content of bin (1-D)
SiPixelLAHarvest::fitResults SiPixelLorentzAnglePCLHarvester::fitAndStore ( std::shared_ptr< SiPixelLorentzAngle theLA,
int  i_idx,
int  i_lay,
int  i_mod 
)
private

Definition at line 568 of file SiPixelLorentzAnglePCLHarvester.cc.

References SiPixelLorentzAngleCalibrationHistograms::BPixnewDetIds_, SiPixelLAHarvest::fitResults::chi2, currentLorentzAngle, SiPixelLorentzAngleCalibrationHistograms::detIdsList, SiPixelLAHarvest::fitResults::e0, SiPixelLAHarvest::fitResults::e1, SiPixelLAHarvest::fitResults::e2, SiPixelLAHarvest::fitResults::e3, SiPixelLAHarvest::fitResults::e4, SiPixelLAHarvest::fitResults::e5, SiPixelLAHarvest::fitResults::error_LA, f1, fitChi2Cut_, dqm::impl::MonitorElement::getBinContent(), SiPixelLorentzAngle::getLorentzAngle(), SiPixelLorentzAngleCalibrationHistograms::h_bySectChi2_, SiPixelLorentzAngleCalibrationHistograms::h_bySectDeltaLA_, SiPixelLorentzAngleCalibrationHistograms::h_bySectLA_, SiPixelLorentzAngleCalibrationHistograms::h_bySectMeasLA_, SiPixelLorentzAngleCalibrationHistograms::h_bySectOccupancy_, SiPixelLorentzAngleCalibrationHistograms::h_bySectRejectLA_, SiPixelLorentzAngleCalibrationHistograms::h_bySectSetLA_, SiPixelLorentzAngleCalibrationHistograms::h_mean_, hists, LogDebug, magField, minHitsCut_, SiPixelLAHarvest::fitResults::ndf, SiPixelLorentzAngleCalibrationHistograms::nlay, SiPixelLorentzAngleCalibrationHistograms::nModules_, MagneticField::nominalValue(), SiPixelLAHarvest::fitResults::p0, SiPixelLAHarvest::fitResults::p1, SiPixelLAHarvest::fitResults::p2, SiPixelLAHarvest::fitResults::p3, SiPixelLAHarvest::fitResults::p4, SiPixelLAHarvest::fitResults::p5, funct::pow(), SiPixelLAHarvest::fitResults::prob, SiPixelLAHarvest::fitResults::redChi2, dqm::impl::MonitorElement::setBinContent(), dqm::impl::MonitorElement::setBinError(), mathSSE::sqrt(), SiPixelLAHarvest::fitResults::tan_LA, and width_.

Referenced by dqmEndJob().

569  {
570  // output results
572 
573  // B-field value
574  // nominalValue returns the magnetic field value in kgauss (1T = 10 kgauss)
575  float theMagField = magField->nominalValue() / 10.;
576 
577  double half_width = width_ * 10000 / 2; // pixel half thickness in units of micro meter
578 
579  f1 = std::make_unique<TF1>("f1", "[0] + [1]*x + [2]*x*x + [3]*x*x*x + [4]*x*x*x*x + [5]*x*x*x*x*x", 5., 280.);
580  f1->SetParName(0, "offset");
581  f1->SetParName(1, "tan#theta_{LA}");
582  f1->SetParName(2, "quad term");
583  f1->SetParName(3, "cubic term");
584  f1->SetParName(4, "quartic term");
585  f1->SetParName(5, "quintic term");
586 
587  f1->SetParameter(0, 0);
588  f1->SetParError(0, 0);
589  f1->SetParameter(1, 0.4);
590  f1->SetParError(1, 0);
591  f1->SetParameter(2, 0.0);
592  f1->SetParError(2, 0);
593  f1->SetParameter(3, 0.0);
594  f1->SetParError(3, 0);
595  f1->SetParameter(4, 0.0);
596  f1->SetParError(4, 0);
597  f1->SetParameter(5, 0.0);
598  f1->SetParError(5, 0);
599  f1->SetChisquare(0);
600 
601  hists.h_mean_[i_index]->getTH1()->Fit(f1.get(), "ERQ");
602 
603  res.p0 = f1->GetParameter(0);
604  res.e0 = f1->GetParError(0);
605  res.p1 = f1->GetParameter(1);
606  res.e1 = f1->GetParError(1);
607  res.p2 = f1->GetParameter(2);
608  res.e2 = f1->GetParError(2);
609  res.p3 = f1->GetParameter(3);
610  res.e3 = f1->GetParError(3);
611  res.p4 = f1->GetParameter(4);
612  res.e4 = f1->GetParError(4);
613  res.p5 = f1->GetParameter(5);
614  res.e5 = f1->GetParError(5);
615  res.chi2 = f1->GetChisquare();
616  res.ndf = f1->GetNDF();
617  res.prob = f1->GetProb();
618  res.redChi2 = res.ndf > 0. ? res.chi2 / res.ndf : 0.;
619 
620  double f1_halfwidth = res.p0 + res.p1 * half_width + res.p2 * pow(half_width, 2) + res.p3 * pow(half_width, 3) +
621  res.p4 * pow(half_width, 4) + res.p5 * pow(half_width, 5);
622 
623  double f1_zerowidth = res.p0;
624 
625  // tan_LA = (f1(x = half_width) - f1(x = 0)) / (half_width - 0)
626  res.tan_LA = (f1_halfwidth - f1_zerowidth) / half_width;
627  double errsq_LA =
628  (pow(res.e1, 2) + pow((half_width * res.e2), 2) + pow((half_width * half_width * res.e3), 2) +
629  pow((half_width * half_width * half_width * res.e4), 2) +
630  pow((half_width * half_width * half_width * half_width * res.e5), 2)); // Propagation of uncertainty
631  res.error_LA = sqrt(errsq_LA);
632 
633  hists.h_bySectMeasLA_->setBinContent(i_index, (res.tan_LA / theMagField));
634  hists.h_bySectMeasLA_->setBinError(i_index, (res.error_LA / theMagField));
635  hists.h_bySectChi2_->setBinContent(i_index, res.redChi2);
636 
637  int nentries = hists.h_bySectOccupancy_->getBinContent(i_index); // number of on track hits in that sector
638 
639  bool isNew = (i_index > hists.nlay * hists.nModules_[hists.nlay - 1]);
640  int shiftIdx = i_index - hists.nlay * hists.nModules_[hists.nlay - 1] - 1;
641 
642  LogDebug("SiPixelLorentzAnglePCLHarvester")
643  << " isNew: " << isNew << " i_index: " << i_index << " shift index: " << shiftIdx;
644 
645  const auto& detIdsToFill =
646  isNew ? std::vector<unsigned int>({hists.BPixnewDetIds_[shiftIdx]}) : hists.detIdsList.at(i_index);
647 
648  LogDebug("SiPixelLorentzAnglePCLHarvester")
649  << "index: " << i_index << " i_module: " << i_module << " i_layer: " << i_layer;
650  for (const auto& id : detIdsToFill) {
651  LogDebug("SiPixelLorentzAnglePCLHarvester") << id << ",";
652  }
653 
654  float LorentzAnglePerTesla_;
655  float currentLA = currentLorentzAngle->getLorentzAngle(detIdsToFill.front());
656  // if the fit quality is OK
657  if ((res.redChi2 != 0.) && (res.redChi2 < fitChi2Cut_) && (nentries > minHitsCut_)) {
658  LorentzAnglePerTesla_ = res.tan_LA / theMagField;
659  // fill the LA actually written to payload
660  hists.h_bySectSetLA_->setBinContent(i_index, LorentzAnglePerTesla_);
661  hists.h_bySectRejectLA_->setBinContent(i_index, 0.);
662  hists.h_bySectLA_->setBinContent(i_index, LorentzAnglePerTesla_);
663 
664  const auto& deltaLA = (LorentzAnglePerTesla_ - currentLA);
665  hists.h_bySectDeltaLA_->setBinContent(i_index, deltaLA);
666 
667  for (const auto& id : detIdsToFill) {
668  if (!theLAPayload->putLorentzAngle(id, LorentzAnglePerTesla_)) {
669  edm::LogError("SiPixelLorentzAnglePCLHarvester") << "[SiPixelLorentzAnglePCLHarvester::fitAndStore]: detid ("
670  << i_layer << "," << i_module << ") already exists";
671  }
672  }
673  } else {
674  // just copy the values from the existing payload
675  hists.h_bySectSetLA_->setBinContent(i_index, 0.);
676  hists.h_bySectRejectLA_->setBinContent(i_index, (res.tan_LA / theMagField));
677  hists.h_bySectLA_->setBinContent(i_index, currentLA);
678 
679  hists.h_bySectDeltaLA_->setBinContent(i_index, 0.);
680 
681  for (const auto& id : detIdsToFill) {
682  LorentzAnglePerTesla_ = currentLorentzAngle->getLorentzAngle(id);
683  if (!theLAPayload->putLorentzAngle(id, LorentzAnglePerTesla_)) {
684  edm::LogError("SiPixelLorentzAnglePCLHarvester") << "[SiPixelLorentzAnglePCLHarvester::fitAndStore]: detid ("
685  << i_layer << "," << i_module << ") already exists";
686  }
687  }
688  }
689  // return the struct of fit details
690  return res;
691 }
int nominalValue() const
The nominal field value for this map in kGauss.
Definition: MagneticField.h:49
SiPixelLorentzAngleCalibrationHistograms hists
Log< level::Error, false > LogError
T sqrt(T t)
Definition: SSEVec.h:19
std::unordered_map< uint32_t, std::vector< uint32_t > > detIdsList
virtual double getBinContent(int binx) const
get content of bin (1-D)
virtual void setBinContent(int binx, double content)
set content of bin (1-D)
float getLorentzAngle(const uint32_t &) const
virtual void setBinError(int binx, double error)
set uncertainty on content of bin (1-D)
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
#define LogDebug(id)

Member Data Documentation

const SiPixelLorentzAngle* SiPixelLorentzAnglePCLHarvester::currentLorentzAngle
private

Definition at line 107 of file SiPixelLorentzAnglePCLHarvester.cc.

Referenced by beginRun(), dqmEndJob(), and fitAndStore().

const std::string SiPixelLorentzAnglePCLHarvester::dqmDir_
private

Definition at line 99 of file SiPixelLorentzAnglePCLHarvester.cc.

Referenced by dqmEndJob().

std::unique_ptr<TF1> SiPixelLorentzAnglePCLHarvester::f1
private

Definition at line 103 of file SiPixelLorentzAnglePCLHarvester.cc.

Referenced by fitAndStore().

const double SiPixelLorentzAnglePCLHarvester::fitChi2Cut_
private

Definition at line 100 of file SiPixelLorentzAnglePCLHarvester.cc.

Referenced by fitAndStore().

edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> SiPixelLorentzAnglePCLHarvester::geomEsToken_
private

Definition at line 93 of file SiPixelLorentzAnglePCLHarvester.cc.

Referenced by beginRun().

SiPixelLorentzAngleCalibrationHistograms SiPixelLorentzAnglePCLHarvester::hists
private
const MagneticField* SiPixelLorentzAnglePCLHarvester::magField
private

Definition at line 108 of file SiPixelLorentzAnglePCLHarvester.cc.

Referenced by beginRun(), and fitAndStore().

edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> SiPixelLorentzAnglePCLHarvester::magneticFieldToken_
private

Definition at line 96 of file SiPixelLorentzAnglePCLHarvester.cc.

Referenced by beginRun().

const int SiPixelLorentzAnglePCLHarvester::minHitsCut_
private

Definition at line 101 of file SiPixelLorentzAnglePCLHarvester.cc.

Referenced by fitAndStore().

std::vector<std::string> SiPixelLorentzAnglePCLHarvester::newmodulelist_
private

Definition at line 98 of file SiPixelLorentzAnglePCLHarvester.cc.

Referenced by beginRun().

const std::string SiPixelLorentzAnglePCLHarvester::recordName_
private

Definition at line 102 of file SiPixelLorentzAnglePCLHarvester.cc.

Referenced by dqmEndJob().

edm::ESGetToken<SiPixelLorentzAngle, SiPixelLorentzAngleRcd> SiPixelLorentzAnglePCLHarvester::siPixelLAEsToken_
private

Definition at line 95 of file SiPixelLorentzAnglePCLHarvester.cc.

Referenced by beginRun().

std::unique_ptr<TrackerTopology> SiPixelLorentzAnglePCLHarvester::theTrackerTopology
private

Definition at line 109 of file SiPixelLorentzAnglePCLHarvester.cc.

Referenced by dqmEndJob(), and endRun().

edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> SiPixelLorentzAnglePCLHarvester::topoEsTokenBR_
private

Definition at line 94 of file SiPixelLorentzAnglePCLHarvester.cc.

Referenced by beginRun().

edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> SiPixelLorentzAnglePCLHarvester::topoEsTokenER_
private

Definition at line 94 of file SiPixelLorentzAnglePCLHarvester.cc.

Referenced by endRun().

float SiPixelLorentzAnglePCLHarvester::width_
private

Definition at line 104 of file SiPixelLorentzAnglePCLHarvester.cc.

Referenced by beginRun(), and fitAndStore().