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 | 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
 
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)
 

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< 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)
 

Detailed Description

No description available.

Author
L. Uplegger F. Yumiceva - Fermilab

Definition at line 16 of file AlcaBeamSpotHarvester.h.

Constructor & Destructor Documentation

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 getUntrackedParameter(std::string const &, T const &) const
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
AlcaBeamSpotManager theAlcaBeamSpotManager_
AlcaBeamSpotHarvester::~AlcaBeamSpotHarvester ( )
overridedefault

Destructor.

Member Function Documentation

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 }
void AlcaBeamSpotHarvester::beginLuminosityBlock ( const edm::LuminosityBlock ,
const edm::EventSetup  
)
override

Definition at line 179 of file AlcaBeamSpotHarvester.cc.

179 {}
void AlcaBeamSpotHarvester::beginRun ( const edm::Run ,
const edm::EventSetup  
)
override
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_
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, produceTPGParameters_beamv6_transparency_spikekill_2016_script::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") {
135  beamspot::dumpBeamSpotTxt(outFile, currentBS);
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") {
149  beamspot::dumpBeamSpotTxt(outFile, currentBS);
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 }
RunID const & id() const
Definition: RunBase.h:39
RunNumber_t run() const
Definition: RunID.h:36
void SetSigmaZ(double val)
set sigma Z, RMS bunch length
std::map< edm::LuminosityBlockNumber_t, std::pair< edm::Timestamp, reco::BeamSpot > >::iterator bsMap_iterator
void SetCovariance(int i, int j, double val)
set i,j element of the full covariance matrix 7x7
void Setdydz(double val)
set dydz slope, crossing angle in XZ
unsigned long long Time_t
Definition: Time.h:14
bool isNewTagRequest(const std::string &recordName)
void SetEmittanceX(double val)
set emittance
bool isAvailable() const
Definition: Service.h:40
Hash writeOneIOV(const T &payload, Time_t time, const std::string &recordName)
void Setdxdz(double val)
set dxdz slope, crossing angle
void SetBetaStar(double val)
set beta star
Log< level::Info, false > LogInfo
void SetType(int type)
set beam type
void SetEmittanceY(double val)
set emittance
void SetBeamWidthX(double val)
set average transverse beam width X
void SetBeamWidthY(double val)
set average transverse beam width Y
AlcaBeamSpotManager theAlcaBeamSpotManager_
void reportAnalysisFile(std::string const &fileName, std::map< std::string, std::string > const &fileData)
Definition: JobReport.cc:473
void dumpBeamSpotTxt(std::ofstream &outFile, BeamSpotContainer const &bsContainer)
const std::map< edm::LuminosityBlockNumber_t, std::pair< edm::Timestamp, reco::BeamSpot > > & getPayloads(void)
void SetPosition(double x, double y, double z)
set XYZ position

Member Data Documentation

std::string AlcaBeamSpotHarvester::beamSpotOutputBase_
private

Definition at line 34 of file AlcaBeamSpotHarvester.h.

Referenced by endRun().

bool AlcaBeamSpotHarvester::dumpTxt_
private

Definition at line 38 of file AlcaBeamSpotHarvester.h.

Referenced by endRun().

std::string AlcaBeamSpotHarvester::outputrecordName_
private

Definition at line 35 of file AlcaBeamSpotHarvester.h.

Referenced by endRun().

std::string AlcaBeamSpotHarvester::outTxtFileName_
private

Definition at line 39 of file AlcaBeamSpotHarvester.h.

Referenced by endRun().

double AlcaBeamSpotHarvester::sigmaZCut_
private

Definition at line 37 of file AlcaBeamSpotHarvester.h.

double AlcaBeamSpotHarvester::sigmaZValue_
private

Definition at line 36 of file AlcaBeamSpotHarvester.h.

Referenced by endRun().

AlcaBeamSpotManager AlcaBeamSpotHarvester::theAlcaBeamSpotManager_
private

Definition at line 41 of file AlcaBeamSpotHarvester.h.

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