CMS 3D CMS Logo

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

#include <AlcaBeamSpotHarvester.h>

Inheritance diagram for AlcaBeamSpotHarvester:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

 AlcaBeamSpotHarvester (const edm::ParameterSet &)
 Constructor. More...
 
void analyze (const edm::Event &, const edm::EventSetup &) override
 
void beginJob (void) override
 
void beginLuminosityBlock (const edm::LuminosityBlock &, const edm::EventSetup &) override
 
void beginRun (const edm::Run &, const edm::EventSetup &) override
 
void endJob (void) override
 
void endLuminosityBlock (const edm::LuminosityBlock &, const edm::EventSetup &) override
 
void endRun (const edm::Run &, const edm::EventSetup &) override
 
 ~AlcaBeamSpotHarvester () override
 Destructor. More...
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
 ~EDAnalyzer () 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 &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
ESProxyIndex const * esGetTokenIndices (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::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
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::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (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)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 

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 39 of file AlcaBeamSpotHarvester.cc.

40  : beamSpotOutputBase_(iConfig.getParameter<ParameterSet>("AlcaBeamSpotHarvesterParameters")
41  .getUntrackedParameter<std::string>("BeamSpotOutputBase")),
42  outputrecordName_(iConfig.getParameter<ParameterSet>("AlcaBeamSpotHarvesterParameters")
43  .getUntrackedParameter<std::string>("outputRecordName", "BeamSpotObjectsRcd")),
44  sigmaZValue_(iConfig.getParameter<ParameterSet>("AlcaBeamSpotHarvesterParameters")
45  .getUntrackedParameter<double>("SigmaZValue")),
46  sigmaZCut_(iConfig.getParameter<ParameterSet>("AlcaBeamSpotHarvesterParameters")
47  .getUntrackedParameter<double>("SigmaZCut")),
48  dumpTxt_(
49  iConfig.getParameter<ParameterSet>("AlcaBeamSpotHarvesterParameters").getUntrackedParameter<bool>("DumpTxt")),
50  outTxtFileName_(iConfig.getParameter<ParameterSet>("AlcaBeamSpotHarvesterParameters")
51  .getUntrackedParameter<std::string>("TxtFileName")),

◆ ~AlcaBeamSpotHarvester()

AlcaBeamSpotHarvester::~AlcaBeamSpotHarvester ( )
override

Destructor.

Definition at line 55 of file AlcaBeamSpotHarvester.cc.

55 {}

Member Function Documentation

◆ analyze()

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

Implements edm::EDAnalyzer.

Definition at line 64 of file AlcaBeamSpotHarvester.cc.

64  {
65  // edm::LogInfo("AlcaBeamSpotHarvester")
66  // << "Lumi: " << iEvent.luminosityBlock()
67  // << " Time: " << iEvent.time().unixTime()
68  // << std::endl;
69 }

◆ beginJob()

void AlcaBeamSpotHarvester::beginJob ( void  )
overridevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 58 of file AlcaBeamSpotHarvester.cc.

58 {}

◆ beginLuminosityBlock()

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

Reimplemented from edm::EDAnalyzer.

Definition at line 196 of file AlcaBeamSpotHarvester.cc.

196 {}

◆ beginRun()

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

Reimplemented from edm::EDAnalyzer.

Definition at line 72 of file AlcaBeamSpotHarvester.cc.

References AlcaBeamSpotManager::reset(), and theAlcaBeamSpotManager_.

◆ endJob()

void AlcaBeamSpotHarvester::endJob ( void  )
overridevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 61 of file AlcaBeamSpotHarvester.cc.

61 {}

Referenced by o2olib.O2ORunMgr::executeJob().

◆ endLuminosityBlock()

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

◆ endRun()

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

Reimplemented from edm::EDAnalyzer.

Definition at line 75 of file AlcaBeamSpotHarvester.cc.

75  {
77  std::map<edm::LuminosityBlockNumber_t, std::pair<edm::Timestamp, reco::BeamSpot>> beamSpotMap =
80  // cond::ExportIOVUtilities utilities;
81 
82  std::string outTxt = Form("%s_Run%d.txt", outTxtFileName_.c_str(), iRun.id().run());
83  std::ofstream outFile;
84  outFile.open(outTxt.c_str(), std::ios::app);
85 
86  if (poolDbService.isAvailable()) {
87  for (AlcaBeamSpotManager::bsMap_iterator it = beamSpotMap.begin(); it != beamSpotMap.end(); it++) {
88  BeamSpotObjects *aBeamSpot = new BeamSpotObjects();
89  aBeamSpot->SetType(it->second.second.type());
90  aBeamSpot->SetPosition(it->second.second.x0(), it->second.second.y0(), it->second.second.z0());
91  if (sigmaZValue_ == -1) {
92  aBeamSpot->SetSigmaZ(it->second.second.sigmaZ());
93  } else {
94  aBeamSpot->SetSigmaZ(sigmaZValue_);
95  }
96  aBeamSpot->Setdxdz(it->second.second.dxdz());
97  aBeamSpot->Setdydz(it->second.second.dydz());
98  aBeamSpot->SetBeamWidthX(it->second.second.BeamWidthX());
99  aBeamSpot->SetBeamWidthY(it->second.second.BeamWidthY());
100  aBeamSpot->SetEmittanceX(it->second.second.emittanceX());
101  aBeamSpot->SetEmittanceY(it->second.second.emittanceY());
102  aBeamSpot->SetBetaStar(it->second.second.betaStar());
103 
104  for (int i = 0; i < 7; ++i) {
105  for (int j = 0; j < 7; ++j) {
106  aBeamSpot->SetCovariance(i, j, it->second.second.covariance(i, j));
107  }
108  }
109 
110  if (sigmaZValue_ > 0) {
111  aBeamSpot->SetCovariance(3, 3, 0.000025);
112  }
113 
114  cond::Time_t thisIOV = 1;
115 
116  beamspot::BeamSpotContainer currentBS;
117 
118  // run based
119  if (beamSpotOutputBase_ == "runbased") {
120  thisIOV = (cond::Time_t)iRun.id().run();
121  }
122  // lumi based
123  else if (beamSpotOutputBase_ == "lumibased") {
124  edm::LuminosityBlockID lu(iRun.id().run(), it->first);
125  thisIOV = (cond::Time_t)(lu.value());
126 
127  currentBS.beamspot = it->second.second;
128  currentBS.run = iRun.id().run();
129  currentBS.beginLumiOfFit = it->first;
130  currentBS.endLumiOfFit = it->first; // endLumi = initLumi
131 
132  std::time_t lumi_t_begin = it->second.first.unixTime();
133  std::time_t lumi_t_end = it->second.first.unixTime(); // begin time == end time
134  strftime(
135  currentBS.beginTimeOfFit, sizeof currentBS.beginTimeOfFit, "%Y.%m.%d %H:%M:%S GMT", gmtime(&lumi_t_begin));
136  strftime(currentBS.endTimeOfFit, sizeof currentBS.endTimeOfFit, "%Y.%m.%d %H:%M:%S GMT", gmtime(&lumi_t_end));
137 
138  currentBS.reftime[0] = lumi_t_begin;
139  currentBS.reftime[1] = lumi_t_end;
140  }
141  if (poolDbService->isNewTagRequest(outputrecordName_)) {
142  edm::LogInfo("AlcaBeamSpotHarvester") << "new tag requested" << std::endl;
143  // poolDbService->createNewIOV<BeamSpotObjects>(aBeamSpot,
144  // poolDbService->beginOfTime(),poolDbService->endOfTime(),"BeamSpotObjectsRcd");
145  // poolDbService->createNewIOV<BeamSpotObjects>(aBeamSpot,
146  // poolDbService->currentTime(),
147  // poolDbService->endOfTime(),"BeamSpotObjectsRcd");
148  poolDbService->writeOne<BeamSpotObjects>(aBeamSpot, thisIOV, outputrecordName_);
149  if (dumpTxt_ && beamSpotOutputBase_ == "lumibased") {
151 
153  if (jr.isAvailable()) {
154  std::map<std::string, std::string> jrInfo;
155  jrInfo["Source"] = std::string("AlcaHarvesting");
156  jrInfo["FileClass"] = std::string("ALCATXT");
157  jr->reportAnalysisFile(outTxt, jrInfo);
158  }
159  }
160  } else {
161  edm::LogInfo("AlcaBeamSpotHarvester") << "no new tag requested, appending IOV" << std::endl;
162  // poolDbService->appendSinceTime<BeamSpotObjects>(aBeamSpot,
163  // poolDbService->currentTime(),"BeamSpotObjectsRcd");
164  poolDbService->writeOne<BeamSpotObjects>(aBeamSpot, thisIOV, outputrecordName_);
165  if (dumpTxt_ && beamSpotOutputBase_ == "lumibased") {
167  }
168  }
169 
170  /*
171  int argc = 15;
172  const char* argv[] = {"endRun"
173  ,"-d","sqlite_file:combined.db"
174  ,"-s","sqlite_file:testbs2.db"
175  ,"-l","sqlite_file:log.db"
176  ,"-i","TestLSBasedBS"
177  ,"-t","TestLSBasedBS"
178  ,"-b","1"
179  ,"-e","10"
180  };
181 
182  edm::LogInfo("AlcaBeamSpotHarvester")
183  << "Running utilities!"
184  << utilities.run(argc,(char**)argv);
185  edm::LogInfo("AlcaBeamSpotHarvester")
186  << "Run utilities!"
187  << std::endl;
188  */
189  }
190  }
191 
192  outFile.close();
193 }

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::writeOne().

Member Data Documentation

◆ beamSpotOutputBase_

std::string AlcaBeamSpotHarvester::beamSpotOutputBase_
private

Definition at line 36 of file AlcaBeamSpotHarvester.h.

Referenced by endRun().

◆ dumpTxt_

bool AlcaBeamSpotHarvester::dumpTxt_
private

Definition at line 40 of file AlcaBeamSpotHarvester.h.

Referenced by endRun().

◆ outputrecordName_

std::string AlcaBeamSpotHarvester::outputrecordName_
private

Definition at line 37 of file AlcaBeamSpotHarvester.h.

Referenced by endRun().

◆ outTxtFileName_

std::string AlcaBeamSpotHarvester::outTxtFileName_
private

Definition at line 41 of file AlcaBeamSpotHarvester.h.

Referenced by endRun().

◆ sigmaZCut_

double AlcaBeamSpotHarvester::sigmaZCut_
private

Definition at line 39 of file AlcaBeamSpotHarvester.h.

◆ sigmaZValue_

double AlcaBeamSpotHarvester::sigmaZValue_
private

Definition at line 38 of file AlcaBeamSpotHarvester.h.

Referenced by endRun().

◆ theAlcaBeamSpotManager_

AlcaBeamSpotManager AlcaBeamSpotHarvester::theAlcaBeamSpotManager_
private

Definition at line 43 of file AlcaBeamSpotHarvester.h.

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

beamspot::BeamSpotContainer::endTimeOfFit
char endTimeOfFit[32]
Definition: BeamSpotWrite2Txt.h:14
mps_fire.i
i
Definition: mps_fire.py:355
AlcaBeamSpotHarvester::beamSpotOutputBase_
std::string beamSpotOutputBase_
Definition: AlcaBeamSpotHarvester.h:36
BeamSpotObjects::SetBetaStar
void SetBetaStar(double val)
set beta star
Definition: BeamSpotObjects.h:64
AlcaBeamSpotHarvester::dumpTxt_
bool dumpTxt_
Definition: AlcaBeamSpotHarvester.h:40
edm::RunID::run
RunNumber_t run() const
Definition: RunID.h:36
AlcaBeamSpotManager::reset
void reset(void)
Definition: AlcaBeamSpotManager.cc:42
edm::JobReport::reportAnalysisFile
void reportAnalysisFile(std::string const &fileName, std::map< std::string, std::string > const &fileData)
Definition: JobReport.cc:473
edm::LogInfo
Definition: MessageLogger.h:254
edm::EDConsumerBase::consumesCollector
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
Definition: EDConsumerBase.cc:71
BeamSpotObjects::SetBeamWidthY
void SetBeamWidthY(double val)
set average transverse beam width Y
Definition: BeamSpotObjects.h:50
beamspot::BeamSpotContainer::reftime
std::time_t reftime[2]
Definition: BeamSpotWrite2Txt.h:17
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
edm::Service::isAvailable
bool isAvailable() const
Definition: Service.h:40
beamspot::BeamSpotContainer::beginLumiOfFit
int beginLumiOfFit
Definition: BeamSpotWrite2Txt.h:15
AlcaBeamSpotHarvester::outputrecordName_
std::string outputrecordName_
Definition: AlcaBeamSpotHarvester.h:37
BeamSpotObjects::SetSigmaZ
void SetSigmaZ(double val)
set sigma Z, RMS bunch length
Definition: BeamSpotObjects.h:42
AlcaBeamSpotManager::createWeightedPayloads
void createWeightedPayloads(void)
Definition: AlcaBeamSpotManager.cc:62
AlcaBeamSpotManager::readLumi
void readLumi(const edm::LuminosityBlock &)
Definition: AlcaBeamSpotManager.cc:44
beamspot::BeamSpotContainer::beamspot
reco::BeamSpot beamspot
Definition: BeamSpotWrite2Txt.h:11
beamspot::BeamSpotContainer::endLumiOfFit
int endLumiOfFit
Definition: BeamSpotWrite2Txt.h:16
beamspot::dumpBeamSpotTxt
void dumpBeamSpotTxt(std::ofstream &outFile, BeamSpotContainer const &bsContainer)
Definition: BeamSpotWrite2Txt.h:20
BeamSpotObjects::SetEmittanceY
void SetEmittanceY(double val)
set emittance
Definition: BeamSpotObjects.h:62
AlcaBeamSpotManager::getPayloads
const std::map< edm::LuminosityBlockNumber_t, std::pair< edm::Timestamp, reco::BeamSpot > > & getPayloads(void)
Definition: AlcaBeamSpotManager.h:27
AlcaBeamSpotHarvester::theAlcaBeamSpotManager_
AlcaBeamSpotManager theAlcaBeamSpotManager_
Definition: AlcaBeamSpotHarvester.h:43
edm::LuminosityBlockID
Definition: LuminosityBlockID.h:31
AlcaBeamSpotHarvester::sigmaZValue_
double sigmaZValue_
Definition: AlcaBeamSpotHarvester.h:38
BeamSpotObjects::SetPosition
void SetPosition(double x, double y, double z)
set XYZ position
Definition: BeamSpotObjects.h:36
L1TdeCSCTF_cfi.outFile
outFile
Definition: L1TdeCSCTF_cfi.py:5
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
es_hardcode_cfi.iLumi
iLumi
Definition: es_hardcode_cfi.py:206
BeamSpotObjects::SetType
void SetType(int type)
set beam type
Definition: BeamSpotObjects.h:58
edm::ParameterSet
Definition: ParameterSet.h:36
BeamSpotObjects::SetEmittanceX
void SetEmittanceX(double val)
set emittance
Definition: BeamSpotObjects.h:60
BeamSpotObjects::SetCovariance
void SetCovariance(int i, int j, double val)
set i,j element of the full covariance matrix 7x7
Definition: BeamSpotObjects.h:56
cond::Time_t
unsigned long long Time_t
Definition: Time.h:14
edm::Service< cond::service::PoolDBOutputService >
BeamSpotObjects
Definition: BeamSpotObjects.h:20
beamspot::BeamSpotContainer::run
int run
Definition: BeamSpotWrite2Txt.h:12
BeamSpotObjects::Setdxdz
void Setdxdz(double val)
set dxdz slope, crossing angle
Definition: BeamSpotObjects.h:44
AlcaBeamSpotManager::bsMap_iterator
std::map< edm::LuminosityBlockNumber_t, std::pair< edm::Timestamp, reco::BeamSpot > >::iterator bsMap_iterator
Definition: AlcaBeamSpotManager.h:31
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
cond::service::PoolDBOutputService::writeOne
Hash writeOne(const T *payload, Time_t time, const std::string &recordName)
Definition: PoolDBOutputService.h:57
BeamSpotObjects::SetBeamWidthX
void SetBeamWidthX(double val)
set average transverse beam width X
Definition: BeamSpotObjects.h:48
cond::service::PoolDBOutputService::isNewTagRequest
bool isNewTagRequest(const std::string &recordName)
Definition: PoolDBOutputService.cc:100
AlcaBeamSpotHarvester::outTxtFileName_
std::string outTxtFileName_
Definition: AlcaBeamSpotHarvester.h:41
beamspot::BeamSpotContainer::beginTimeOfFit
char beginTimeOfFit[32]
Definition: BeamSpotWrite2Txt.h:13
AlcaBeamSpotHarvester::sigmaZCut_
double sigmaZCut_
Definition: AlcaBeamSpotHarvester.h:39
beamspot::BeamSpotContainer
Definition: BeamSpotWrite2Txt.h:10
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
BeamSpotObjects::Setdydz
void Setdydz(double val)
set dydz slope, crossing angle in XZ
Definition: BeamSpotObjects.h:46
edm::RunBase::id
RunID const & id() const
Definition: RunBase.h:39