CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
AlcaBeamSpotHarvester.cc
Go to the documentation of this file.
1 
2 /*
3  * See header file for a description of this class.
4  *
5  * \author L. Uplegger F. Yumiceva - Fermilab
6  */
7 
20 
22 
26 //#include "CondCore/Utilities/bin/cmscond_export_iov.cpp"
27 //#include "CondCore/Utilities/interface/Utilities.h"
28 // #include "FWCore/MessageLogger/interface/JobReport.h"
29 
30 #include <iostream>
31 
32 using namespace edm;
33 using namespace reco;
34 //using namespace std;
35 
36 //--------------------------------------------------------------------------------------------------
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  theAlcaBeamSpotManager_(iConfig, consumesCollector()) {
43 }
44 
45 //--------------------------------------------------------------------------------------------------
47 
48 //--------------------------------------------------------------------------------------------------
50 
51 //--------------------------------------------------------------------------------------------------
53 
54 //--------------------------------------------------------------------------------------------------
56 // edm::LogInfo("AlcaBeamSpotHarvester")
57 // << "Lumi: " << iEvent.luminosityBlock()
58 // << " Time: " << iEvent.time().unixTime()
59 // << std::endl;
60 }
61 
62 //--------------------------------------------------------------------------------------------------
65 }
66 
67 //--------------------------------------------------------------------------------------------------
70  std::map<edm::LuminosityBlockNumber_t,reco::BeamSpot> beamSpotMap = theAlcaBeamSpotManager_.getPayloads();
72 // cond::ExportIOVUtilities utilities;
73  if(poolDbService.isAvailable() ) {
74  for(AlcaBeamSpotManager::bsMap_iterator it=beamSpotMap.begin(); it!=beamSpotMap.end();it++){
75  BeamSpotObjects *aBeamSpot = new BeamSpotObjects();
76  aBeamSpot->SetType(it->second.type());
77  aBeamSpot->SetPosition(it->second.x0(),it->second.y0(),it->second.z0());
78  if(sigmaZValue_ == -1){
79  aBeamSpot->SetSigmaZ(it->second.sigmaZ());
80  }
81  else{
82  aBeamSpot->SetSigmaZ(sigmaZValue_);
83  }
84  aBeamSpot->Setdxdz(it->second.dxdz());
85  aBeamSpot->Setdydz(it->second.dydz());
86  aBeamSpot->SetBeamWidthX(it->second.BeamWidthX());
87  aBeamSpot->SetBeamWidthY(it->second.BeamWidthY());
88  aBeamSpot->SetEmittanceX(it->second.emittanceX());
89  aBeamSpot->SetEmittanceY(it->second.emittanceY());
90  aBeamSpot->SetBetaStar(it->second.betaStar() );
91 
92  for (int i=0; i<7; ++i) {
93  for (int j=0; j<7; ++j) {
94  aBeamSpot->SetCovariance(i,j,it->second.covariance(i,j));
95  }
96  }
97 
98  if(sigmaZValue_ > 0){
99  aBeamSpot->SetCovariance(3,3,0.000025);
100  }
101 
102  cond::Time_t thisIOV = 1;
103 
104 
105 
106  // run based
107  if (beamSpotOutputBase_ == "runbased" ) {
108  thisIOV = (cond::Time_t) iRun.id().run();
109  }
110  // lumi based
111  else if (beamSpotOutputBase_ == "lumibased" ) {
112  edm::LuminosityBlockID lu(iRun.id().run(),it->first);
113  thisIOV = (cond::Time_t)(lu.value());
114  }
115  if (poolDbService->isNewTagRequest(outputrecordName_) ) {
116  edm::LogInfo("AlcaBeamSpotHarvester")
117  << "new tag requested" << std::endl;
118  //poolDbService->createNewIOV<BeamSpotObjects>(aBeamSpot, poolDbService->beginOfTime(),poolDbService->endOfTime(),"BeamSpotObjectsRcd");
119 
120  //poolDbService->createNewIOV<BeamSpotObjects>(aBeamSpot, poolDbService->currentTime(), poolDbService->endOfTime(),"BeamSpotObjectsRcd");
121  poolDbService->writeOne<BeamSpotObjects>(aBeamSpot, thisIOV, outputrecordName_);
122  }
123  else {
124  edm::LogInfo("AlcaBeamSpotHarvester")
125  << "no new tag requested, appending IOV" << std::endl;
126  //poolDbService->appendSinceTime<BeamSpotObjects>(aBeamSpot, poolDbService->currentTime(),"BeamSpotObjectsRcd");
127  poolDbService->writeOne<BeamSpotObjects>(aBeamSpot, thisIOV, outputrecordName_);
128  }
129 
130 
131 
132 
133 /*
134  int argc = 15;
135  const char* argv[] = {"endRun"
136  ,"-d","sqlite_file:combined.db"
137  ,"-s","sqlite_file:testbs2.db"
138  ,"-l","sqlite_file:log.db"
139  ,"-i","TestLSBasedBS"
140  ,"-t","TestLSBasedBS"
141  ,"-b","1"
142  ,"-e","10"
143  };
144 
145  edm::LogInfo("AlcaBeamSpotHarvester")
146  << "Running utilities!"
147  << utilities.run(argc,(char**)argv);
148  edm::LogInfo("AlcaBeamSpotHarvester")
149  << "Run utilities!"
150  << std::endl;
151 */
152  }
153 
154 
155 
156 
157  }
158 }
159 
160 //--------------------------------------------------------------------------------------------------
162 
163 //--------------------------------------------------------------------------------------------------
166 }
167 
168 
int i
Definition: DBlmapReader.cc:9
RunID const & id() const
Definition: RunBase.h:39
RunNumber_t run() const
Definition: RunID.h:39
virtual void endLuminosityBlock(const edm::LuminosityBlock &, const edm::EventSetup &)
virtual void beginRun(const edm::Run &, const edm::EventSetup &)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
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
virtual void beginJob(void)
AlcaBeamSpotHarvester(const edm::ParameterSet &)
Constructor.
const std::map< edm::LuminosityBlockNumber_t, reco::BeamSpot > & getPayloads(void)
int iEvent
Definition: GenABIO.cc:230
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
int j
Definition: DBlmapReader.cc:9
virtual void endRun(const edm::Run &, const edm::EventSetup &)
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
virtual void beginLuminosityBlock(const edm::LuminosityBlock &, const edm::EventSetup &)
void readLumi(const edm::LuminosityBlock &)
void SetType(int type)
set beam type
virtual ~AlcaBeamSpotHarvester()
Destructor.
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_
Definition: Run.h:43
virtual void analyze(const edm::Event &, const edm::EventSetup &)
void SetPosition(double x, double y, double z)
set XYZ position