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 ()
 
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
 
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 &)
 
- 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 37 of file AlcaBeamSpotHarvester.cc.

37  :
38  beamSpotOutputBase_ (iConfig.getParameter<ParameterSet>("AlcaBeamSpotHarvesterParameters").getUntrackedParameter<std::string>("BeamSpotOutputBase")),
39  outputrecordName_ (iConfig.getParameter<ParameterSet>("AlcaBeamSpotHarvesterParameters").getUntrackedParameter<std::string>("outputRecordName", "BeamSpotObjectsRcd")),
40  sigmaZValue_ (iConfig.getParameter<ParameterSet>("AlcaBeamSpotHarvesterParameters").getUntrackedParameter<double>("SigmaZValue")),
41  sigmaZCut_ (iConfig.getParameter<ParameterSet>("AlcaBeamSpotHarvesterParameters").getUntrackedParameter<double>("SigmaZCut")),
42  dumpTxt_ (iConfig.getParameter<ParameterSet>("AlcaBeamSpotHarvesterParameters").getUntrackedParameter<bool>("DumpTxt")),
43  outTxtFileName_ (iConfig.getParameter<ParameterSet>("AlcaBeamSpotHarvesterParameters").getUntrackedParameter<std::string>("TxtFileName")),
45 }
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 48 of file AlcaBeamSpotHarvester.cc.

48 {}

Member Function Documentation

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

Definition at line 57 of file AlcaBeamSpotHarvester.cc.

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

Reimplemented from edm::EDAnalyzer.

Definition at line 51 of file AlcaBeamSpotHarvester.cc.

51 {}
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 65 of file AlcaBeamSpotHarvester.cc.

References AlcaBeamSpotManager::reset(), and theAlcaBeamSpotManager_.

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

Reimplemented from edm::EDAnalyzer.

Definition at line 54 of file AlcaBeamSpotHarvester.cc.

Referenced by o2olib.O2ORunMgr::executeJob().

54 {}
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 70 of file AlcaBeamSpotHarvester.cc.

References beamspot::BeamSpotContainer::beamspot, beamSpotOutputBase_, beamspot::BeamSpotContainer::beginLumiOfFit, beamspot::BeamSpotContainer::beginTimeOfFit, popcon2dropbox::copy(), 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, 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().

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