CMS 3D CMS Logo

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

#include <AlcaBeamSpotHarvester.h>

Inheritance diagram for AlcaBeamSpotHarvester:
edm::one::EDAnalyzer< edm::one::WatchRuns, edm::one::WatchLuminosityBlocks > edm::one::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

 AlcaBeamSpotHarvester (const edm::ParameterSet &)
 Constructor. More...
 
void analyze (const edm::Event &, const edm::EventSetup &) override
 
void beginLuminosityBlock (const edm::LuminosityBlock &, const edm::EventSetup &) override
 
void beginRun (const edm::Run &, const edm::EventSetup &) override
 
void endLuminosityBlock (const edm::LuminosityBlock &, const edm::EventSetup &) override
 
void endRun (const edm::Run &, const edm::EventSetup &) override
 
 ~AlcaBeamSpotHarvester () override=default
 Destructor. More...
 
- Public Member Functions inherited from edm::one::EDAnalyzer< edm::one::WatchRuns, edm::one::WatchLuminosityBlocks >
 EDAnalyzer ()=default
 
 EDAnalyzer (const EDAnalyzer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
const EDAnalyzeroperator= (const EDAnalyzer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
- Public Member Functions inherited from edm::one::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () const
 
 ~EDAnalyzerBase () 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)
 

Private Attributes

std::string beamSpotOutputBase_
 
bool dumpTxt_
 
std::string outputrecordName_
 
std::string outTxtFileName_
 
double sigmaZCut_
 
double sigmaZValue_
 
AlcaBeamSpotManager theAlcaBeamSpotManager_
 

Additional Inherited Members

- Public Types inherited from edm::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::one::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- 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)
 

Detailed Description

No description available.

Author
L. Uplegger F. Yumiceva - Fermilab

Definition at line 16 of file AlcaBeamSpotHarvester.h.

Constructor & Destructor Documentation

◆ AlcaBeamSpotHarvester()

AlcaBeamSpotHarvester::AlcaBeamSpotHarvester ( const edm::ParameterSet iConfig)

Constructor.

Definition at line 38 of file AlcaBeamSpotHarvester.cc.

39  : beamSpotOutputBase_(iConfig.getParameter<ParameterSet>("AlcaBeamSpotHarvesterParameters")
40  .getUntrackedParameter<std::string>("BeamSpotOutputBase")),
41  outputrecordName_(iConfig.getParameter<ParameterSet>("AlcaBeamSpotHarvesterParameters")
42  .getUntrackedParameter<std::string>("outputRecordName", "BeamSpotObjectsRcd")),
43  sigmaZValue_(iConfig.getParameter<ParameterSet>("AlcaBeamSpotHarvesterParameters")
44  .getUntrackedParameter<double>("SigmaZValue")),
45  sigmaZCut_(iConfig.getParameter<ParameterSet>("AlcaBeamSpotHarvesterParameters")
46  .getUntrackedParameter<double>("SigmaZCut")),
47  dumpTxt_(
48  iConfig.getParameter<ParameterSet>("AlcaBeamSpotHarvesterParameters").getUntrackedParameter<bool>("DumpTxt")),
49  outTxtFileName_(iConfig.getParameter<ParameterSet>("AlcaBeamSpotHarvesterParameters")
50  .getUntrackedParameter<std::string>("TxtFileName")),
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
T getUntrackedParameter(std::string const &, T const &) const
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
AlcaBeamSpotManager theAlcaBeamSpotManager_

◆ ~AlcaBeamSpotHarvester()

AlcaBeamSpotHarvester::~AlcaBeamSpotHarvester ( )
overridedefault

Destructor.

Member Function Documentation

◆ analyze()

void AlcaBeamSpotHarvester::analyze ( const edm::Event iEvent,
const edm::EventSetup  
)
overridevirtual

Implements edm::one::EDAnalyzerBase.

Definition at line 54 of file AlcaBeamSpotHarvester.cc.

54  {
55  // edm::LogInfo("AlcaBeamSpotHarvester")
56  // << "Lumi: " << iEvent.luminosityBlock()
57  // << " Time: " << iEvent.time().unixTime()
58  // << std::endl;
59 }

◆ beginLuminosityBlock()

void AlcaBeamSpotHarvester::beginLuminosityBlock ( const edm::LuminosityBlock ,
const edm::EventSetup  
)
override

Definition at line 179 of file AlcaBeamSpotHarvester.cc.

179 {}

◆ beginRun()

void AlcaBeamSpotHarvester::beginRun ( const edm::Run ,
const edm::EventSetup  
)
override

◆ endLuminosityBlock()

void AlcaBeamSpotHarvester::endLuminosityBlock ( const edm::LuminosityBlock iLumi,
const edm::EventSetup  
)
override

Definition at line 182 of file AlcaBeamSpotHarvester.cc.

References AlcaBeamSpotManager::readLumi(), and theAlcaBeamSpotManager_.

182  {
184 }
void readLumi(const edm::LuminosityBlock &)
AlcaBeamSpotManager theAlcaBeamSpotManager_

◆ endRun()

void AlcaBeamSpotHarvester::endRun ( const edm::Run iRun,
const edm::EventSetup  
)
override

Definition at line 65 of file AlcaBeamSpotHarvester.cc.

References beamspot::BeamSpotContainer::beamspot, beamSpotOutputBase_, beamspot::BeamSpotContainer::beginLumiOfFit, beamspot::BeamSpotContainer::beginTimeOfFit, AlcaBeamSpotManager::createWeightedPayloads(), beamspot::dumpBeamSpotTxt(), dumpTxt_, beamspot::BeamSpotContainer::endLumiOfFit, beamspot::BeamSpotContainer::endTimeOfFit, AlcaBeamSpotManager::getPayloads(), mps_fire::i, edm::RunBase::id(), edm::Service< T >::isAvailable(), cond::service::PoolDBOutputService::isNewTagRequest(), dqmiolumiharvest::j, L1TdeCSCTF_cfi::outFile, outputrecordName_, outTxtFileName_, beamspot::BeamSpotContainer::reftime, edm::JobReport::reportAnalysisFile(), beamspot::BeamSpotContainer::run, edm::RunID::run(), BeamSpotObjects::setBeamWidthX(), BeamSpotObjects::setBeamWidthY(), BeamSpotObjects::setBetaStar(), BeamSpotObjects::setCovariance(), BeamSpotObjects::setdxdz(), BeamSpotObjects::setdydz(), BeamSpotObjects::setEmittanceX(), BeamSpotObjects::setEmittanceY(), BeamSpotObjects::setPosition(), BeamSpotObjects::setSigmaZ(), BeamSpotObjects::setType(), sigmaZValue_, AlCaHLTBitMon_QueryRunRegistry::string, theAlcaBeamSpotManager_, and cond::service::PoolDBOutputService::writeOneIOV().

65  {
67  std::map<edm::LuminosityBlockNumber_t, std::pair<edm::Timestamp, reco::BeamSpot>> beamSpotMap =
70  // cond::ExportIOVUtilities utilities;
71 
72  std::string outTxt = Form("%s_Run%d.txt", outTxtFileName_.c_str(), iRun.id().run());
73  std::ofstream outFile;
74  outFile.open(outTxt.c_str(), std::ios::app);
75 
76  if (poolDbService.isAvailable()) {
77  for (AlcaBeamSpotManager::bsMap_iterator it = beamSpotMap.begin(); it != beamSpotMap.end(); it++) {
78  BeamSpotObjects aBeamSpot;
79  aBeamSpot.setType(it->second.second.type());
80  aBeamSpot.setPosition(it->second.second.x0(), it->second.second.y0(), it->second.second.z0());
81  if (sigmaZValue_ == -1) {
82  aBeamSpot.setSigmaZ(it->second.second.sigmaZ());
83  } else {
84  aBeamSpot.setSigmaZ(sigmaZValue_);
85  }
86  aBeamSpot.setdxdz(it->second.second.dxdz());
87  aBeamSpot.setdydz(it->second.second.dydz());
88  aBeamSpot.setBeamWidthX(it->second.second.BeamWidthX());
89  aBeamSpot.setBeamWidthY(it->second.second.BeamWidthY());
90  aBeamSpot.setEmittanceX(it->second.second.emittanceX());
91  aBeamSpot.setEmittanceY(it->second.second.emittanceY());
92  aBeamSpot.setBetaStar(it->second.second.betaStar());
93 
94  for (int i = 0; i < 7; ++i) {
95  for (int j = 0; j < 7; ++j) {
96  aBeamSpot.setCovariance(i, j, it->second.second.covariance(i, j));
97  }
98  }
99 
100  if (sigmaZValue_ > 0) {
101  aBeamSpot.setCovariance(3, 3, 0.000025);
102  }
103 
104  cond::Time_t thisIOV = 1;
105 
106  beamspot::BeamSpotContainer currentBS;
107 
108  // run based
109  if (beamSpotOutputBase_ == "runbased") {
110  thisIOV = (cond::Time_t)iRun.id().run();
111  }
112  // lumi based
113  else if (beamSpotOutputBase_ == "lumibased") {
114  edm::LuminosityBlockID lu(iRun.id().run(), it->first);
115  thisIOV = (cond::Time_t)(lu.value());
116 
117  currentBS.beamspot = it->second.second;
118  currentBS.run = iRun.id().run();
119  currentBS.beginLumiOfFit = it->first;
120  currentBS.endLumiOfFit = it->first; // endLumi = initLumi
121 
122  std::time_t lumi_t_begin = it->second.first.unixTime();
123  std::time_t lumi_t_end = it->second.first.unixTime(); // begin time == end time
124  strftime(
125  currentBS.beginTimeOfFit, sizeof currentBS.beginTimeOfFit, "%Y.%m.%d %H:%M:%S GMT", gmtime(&lumi_t_begin));
126  strftime(currentBS.endTimeOfFit, sizeof currentBS.endTimeOfFit, "%Y.%m.%d %H:%M:%S GMT", gmtime(&lumi_t_end));
127 
128  currentBS.reftime[0] = lumi_t_begin;
129  currentBS.reftime[1] = lumi_t_end;
130  }
131  if (poolDbService->isNewTagRequest(outputrecordName_)) {
132  edm::LogInfo("AlcaBeamSpotHarvester") << "new tag requested" << std::endl;
133  poolDbService->writeOneIOV<BeamSpotObjects>(aBeamSpot, thisIOV, outputrecordName_);
134  if (dumpTxt_ && beamSpotOutputBase_ == "lumibased") {
136 
138  if (jr.isAvailable()) {
139  std::map<std::string, std::string> jrInfo;
140  jrInfo["Source"] = std::string("AlcaHarvesting");
141  jrInfo["FileClass"] = std::string("ALCATXT");
142  jr->reportAnalysisFile(outTxt, jrInfo);
143  }
144  }
145  } else {
146  edm::LogInfo("AlcaBeamSpotHarvester") << "no new tag requested, appending IOV" << std::endl;
147  poolDbService->writeOneIOV<BeamSpotObjects>(aBeamSpot, thisIOV, outputrecordName_);
148  if (dumpTxt_ && beamSpotOutputBase_ == "lumibased") {
150  }
151  }
152 
153  /*
154  int argc = 15;
155  const char* argv[] = {"endRun"
156  ,"-d","sqlite_file:combined.db"
157  ,"-s","sqlite_file:testbs2.db"
158  ,"-l","sqlite_file:log.db"
159  ,"-i","TestLSBasedBS"
160  ,"-t","TestLSBasedBS"
161  ,"-b","1"
162  ,"-e","10"
163  };
164 
165  edm::LogInfo("AlcaBeamSpotHarvester")
166  << "Running utilities!"
167  << utilities.run(argc,(char**)argv);
168  edm::LogInfo("AlcaBeamSpotHarvester")
169  << "Run utilities!"
170  << std::endl;
171  */
172  }
173  }
174 
175  outFile.close();
176 }
void setCovariance(int i, int j, double val)
set i,j element of the full covariance matrix 7x7
void setEmittanceY(double val)
set emittance
void setBetaStar(double val)
set beta star
std::map< edm::LuminosityBlockNumber_t, std::pair< edm::Timestamp, reco::BeamSpot > >::iterator bsMap_iterator
void setType(int type)
set beam type
void setEmittanceX(double val)
set emittance
unsigned long long Time_t
Definition: Time.h:14
bool isNewTagRequest(const std::string &recordName)
void setdydz(double val)
set dydz slope, crossing angle in XZ
Hash writeOneIOV(const T &payload, Time_t time, const std::string &recordName)
void setdxdz(double val)
set dxdz slope, crossing angle
RunID const & id() const
Definition: RunBase.h:39
Log< level::Info, false > LogInfo
void setSigmaZ(double val)
set sigma Z, RMS bunch length
AlcaBeamSpotManager theAlcaBeamSpotManager_
void reportAnalysisFile(std::string const &fileName, std::map< std::string, std::string > const &fileData)
Definition: JobReport.cc:509
void setPosition(double x, double y, double z)
set XYZ position
void setBeamWidthX(double val)
set average transverse beam width X
bool isAvailable() const
Definition: Service.h:40
void dumpBeamSpotTxt(std::ofstream &outFile, BeamSpotContainer const &bsContainer)
void setBeamWidthY(double val)
set average transverse beam width Y
RunNumber_t run() const
Definition: RunID.h:26
const std::map< edm::LuminosityBlockNumber_t, std::pair< edm::Timestamp, reco::BeamSpot > > & getPayloads(void)

Member Data Documentation

◆ beamSpotOutputBase_

std::string AlcaBeamSpotHarvester::beamSpotOutputBase_
private

Definition at line 34 of file AlcaBeamSpotHarvester.h.

Referenced by endRun().

◆ dumpTxt_

bool AlcaBeamSpotHarvester::dumpTxt_
private

Definition at line 38 of file AlcaBeamSpotHarvester.h.

Referenced by endRun().

◆ outputrecordName_

std::string AlcaBeamSpotHarvester::outputrecordName_
private

Definition at line 35 of file AlcaBeamSpotHarvester.h.

Referenced by endRun().

◆ outTxtFileName_

std::string AlcaBeamSpotHarvester::outTxtFileName_
private

Definition at line 39 of file AlcaBeamSpotHarvester.h.

Referenced by endRun().

◆ sigmaZCut_

double AlcaBeamSpotHarvester::sigmaZCut_
private

Definition at line 37 of file AlcaBeamSpotHarvester.h.

◆ sigmaZValue_

double AlcaBeamSpotHarvester::sigmaZValue_
private

Definition at line 36 of file AlcaBeamSpotHarvester.h.

Referenced by endRun().

◆ theAlcaBeamSpotManager_

AlcaBeamSpotManager AlcaBeamSpotHarvester::theAlcaBeamSpotManager_
private

Definition at line 41 of file AlcaBeamSpotHarvester.h.

Referenced by beginRun(), endLuminosityBlock(), and endRun().