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 const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
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
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
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
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
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 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)
 

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

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

Destructor.

Definition at line 50 of file AlcaBeamSpotHarvester.cc.

50 {}

Member Function Documentation

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

Definition at line 59 of file AlcaBeamSpotHarvester.cc.

59  {
60 // edm::LogInfo("AlcaBeamSpotHarvester")
61 // << "Lumi: " << iEvent.luminosityBlock()
62 // << " Time: " << iEvent.time().unixTime()
63 // << std::endl;
64 }
void AlcaBeamSpotHarvester::beginJob ( void  )
overridevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 53 of file AlcaBeamSpotHarvester.cc.

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

Definition at line 198 of file AlcaBeamSpotHarvester.cc.

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

Definition at line 67 of file AlcaBeamSpotHarvester.cc.

References AlcaBeamSpotManager::reset(), and theAlcaBeamSpotManager_.

67  {
69 }
AlcaBeamSpotManager theAlcaBeamSpotManager_
void AlcaBeamSpotHarvester::endJob ( void  )
overridevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 56 of file AlcaBeamSpotHarvester.cc.

Referenced by o2olib.O2ORunMgr::executeJob().

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

Definition at line 201 of file AlcaBeamSpotHarvester.cc.

References DEFINE_FWK_MODULE, AlcaBeamSpotManager::readLumi(), and theAlcaBeamSpotManager_.

201  {
203 }
void readLumi(const edm::LuminosityBlock &)
AlcaBeamSpotManager theAlcaBeamSpotManager_
void AlcaBeamSpotHarvester::endRun ( const edm::Run iRun,
const edm::EventSetup  
)
override

Definition at line 72 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(), GetRecoTauVFromDQM_MC_cff::outFile, outputrecordName_, outTxtFileName_, beamspot::BeamSpotContainer::reftime, edm::JobReport::reportAnalysisFile(), beamspot::BeamSpotContainer::run, edm::RunID::run(), edm::second(), 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().

72  {
74  std::map<edm::LuminosityBlockNumber_t,std::pair<edm::Timestamp,reco::BeamSpot>> beamSpotMap = theAlcaBeamSpotManager_.getPayloads();
76 // cond::ExportIOVUtilities utilities;
77 
78  std::string outTxt = Form("%s_Run%d.txt", outTxtFileName_.c_str(), iRun.id().run());
79  std::ofstream outFile;
80  outFile.open(outTxt.c_str(),std::ios::app);
81 
82  if(poolDbService.isAvailable() ) {
83  for(AlcaBeamSpotManager::bsMap_iterator it=beamSpotMap.begin(); it!=beamSpotMap.end();it++){
84  BeamSpotObjects *aBeamSpot = new BeamSpotObjects();
85  aBeamSpot->SetType(it->second.second.type());
86  aBeamSpot->SetPosition(it->second.second.x0(),it->second.second.y0(),it->second.second.z0());
87  if(sigmaZValue_ == -1){
88  aBeamSpot->SetSigmaZ(it->second.second.sigmaZ());
89  }
90  else{
91  aBeamSpot->SetSigmaZ(sigmaZValue_);
92  }
93  aBeamSpot->Setdxdz(it->second.second.dxdz());
94  aBeamSpot->Setdydz(it->second.second.dydz());
95  aBeamSpot->SetBeamWidthX(it->second.second.BeamWidthX());
96  aBeamSpot->SetBeamWidthY(it->second.second.BeamWidthY());
97  aBeamSpot->SetEmittanceX(it->second.second.emittanceX());
98  aBeamSpot->SetEmittanceY(it->second.second.emittanceY());
99  aBeamSpot->SetBetaStar(it->second.second.betaStar() );
100 
101  for (int i=0; i<7; ++i) {
102  for (int j=0; j<7; ++j) {
103  aBeamSpot->SetCovariance(i,j,it->second.second.covariance(i,j));
104  }
105  }
106 
107  if(sigmaZValue_ > 0){
108  aBeamSpot->SetCovariance(3,3,0.000025);
109  }
110 
111  cond::Time_t thisIOV = 1;
112 
113  beamspot::BeamSpotContainer currentBS;
114 
115 
116  // run based
117  if (beamSpotOutputBase_ == "runbased" ) {
118  thisIOV = (cond::Time_t) iRun.id().run();
119  }
120  // lumi based
121  else if (beamSpotOutputBase_ == "lumibased" ) {
122  edm::LuminosityBlockID lu(iRun.id().run(),it->first);
123  thisIOV = (cond::Time_t)(lu.value());
124 
125  currentBS.beamspot = it -> second.second;
126  currentBS.run = iRun.id().run() ;
127  currentBS.beginLumiOfFit = it->first;
128  currentBS.endLumiOfFit = it->first; // endLumi = initLumi
129 
130  std::time_t lumi_t_begin = it -> second.first.unixTime();
131  std::time_t lumi_t_end = it -> second.first.unixTime(); // begin time == end time
132  strftime(currentBS.beginTimeOfFit, sizeof currentBS.beginTimeOfFit, "%Y.%m.%d %H:%M:%S GMT", gmtime(&lumi_t_begin));
133  strftime(currentBS.endTimeOfFit, sizeof currentBS.endTimeOfFit, "%Y.%m.%d %H:%M:%S GMT", gmtime(&lumi_t_end));
134 
135  currentBS.reftime[0] = lumi_t_begin;
136  currentBS.reftime[1] = lumi_t_end;
137 
138  }
139  if (poolDbService->isNewTagRequest(outputrecordName_) ) {
140  edm::LogInfo("AlcaBeamSpotHarvester")
141  << "new tag requested" << std::endl;
142  //poolDbService->createNewIOV<BeamSpotObjects>(aBeamSpot, poolDbService->beginOfTime(),poolDbService->endOfTime(),"BeamSpotObjectsRcd");
143  //poolDbService->createNewIOV<BeamSpotObjects>(aBeamSpot, poolDbService->currentTime(), poolDbService->endOfTime(),"BeamSpotObjectsRcd");
144  poolDbService->writeOne<BeamSpotObjects>(aBeamSpot, thisIOV, outputrecordName_);
145  if (dumpTxt_ && beamSpotOutputBase_ == "lumibased"){
146  beamspot::dumpBeamSpotTxt(outFile, currentBS);
147 
149  if (jr.isAvailable()) {
150  std::map<std::string, std::string> jrInfo;
151  jrInfo["Source"] = std::string("AlcaHarvesting");
152  jrInfo["FileClass"] = std::string("ALCATXT");
153  jr->reportAnalysisFile(outTxt, jrInfo);
154  }
155 
156  }
157  }
158  else {
159  edm::LogInfo("AlcaBeamSpotHarvester")
160  << "no new tag requested, appending IOV" << std::endl;
161  //poolDbService->appendSinceTime<BeamSpotObjects>(aBeamSpot, poolDbService->currentTime(),"BeamSpotObjectsRcd");
162  poolDbService->writeOne<BeamSpotObjects>(aBeamSpot, thisIOV, outputrecordName_);
163  if (dumpTxt_ && beamSpotOutputBase_ == "lumibased"){
164  beamspot::dumpBeamSpotTxt(outFile, currentBS);
165  }
166  }
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 
193  outFile.close();
194 
195 }
RunID const & id() const
Definition: RunBase.h:39
RunNumber_t run() const
Definition: RunID.h:39
void SetSigmaZ(double val)
set sigma Z, RMS bunch length
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
std::map< edm::LuminosityBlockNumber_t, std::pair< edm::Timestamp, reco::BeamSpot > >::iterator bsMap_iterator
U second(std::pair< T, U > const &p)
unsigned long long Time_t
Definition: Time.h:16
bool isNewTagRequest(const std::string &recordName)
void SetEmittanceX(double val)
set emittance
bool isAvailable() const
Definition: Service.h:46
void writeOne(T *payload, Time_t time, const std::string &recordName, bool withlogging=false)
void Setdxdz(double val)
set dxdz slope, crossing angle
void SetBetaStar(double val)
set beta star
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:507
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 37 of file AlcaBeamSpotHarvester.h.

Referenced by endRun().

bool AlcaBeamSpotHarvester::dumpTxt_
private

Definition at line 41 of file AlcaBeamSpotHarvester.h.

Referenced by endRun().

std::string AlcaBeamSpotHarvester::outputrecordName_
private

Definition at line 38 of file AlcaBeamSpotHarvester.h.

Referenced by endRun().

std::string AlcaBeamSpotHarvester::outTxtFileName_
private

Definition at line 42 of file AlcaBeamSpotHarvester.h.

Referenced by endRun().

double AlcaBeamSpotHarvester::sigmaZCut_
private

Definition at line 40 of file AlcaBeamSpotHarvester.h.

double AlcaBeamSpotHarvester::sigmaZValue_
private

Definition at line 39 of file AlcaBeamSpotHarvester.h.

Referenced by endRun().

AlcaBeamSpotManager AlcaBeamSpotHarvester::theAlcaBeamSpotManager_
private

Definition at line 44 of file AlcaBeamSpotHarvester.h.

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