Skip to content

Commit

Permalink
Merge pull request #20103 from rmanzoni/master_fixBS
Browse files Browse the repository at this point in the history
fix for Beam Spot txt file mess-up
  • Loading branch information
cmsbuild committed Aug 12, 2017
2 parents 56f2f72 + 7ef3a00 commit 4f352f5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ void AlcaBeamSpotHarvester::endRun(const edm::Run& iRun, const edm::EventSetup&)
// cond::ExportIOVUtilities utilities;

std::string outTxt = Form("%s_Run%d.txt", outTxtFileName_.c_str(), iRun.id().run());
std::ofstream outFile;
outFile.open(outTxt.c_str());

if(poolDbService.isAvailable() ) {
for(AlcaBeamSpotManager::bsMap_iterator it=beamSpotMap.begin(); it!=beamSpotMap.end();it++){
Expand Down Expand Up @@ -146,7 +148,7 @@ void AlcaBeamSpotHarvester::endRun(const edm::Run& iRun, const edm::EventSetup&)
//poolDbService->createNewIOV<BeamSpotObjects>(aBeamSpot, poolDbService->currentTime(), poolDbService->endOfTime(),"BeamSpotObjectsRcd");
poolDbService->writeOne<BeamSpotObjects>(aBeamSpot, thisIOV, outputrecordName_);
if (dumpTxt_ && beamSpotOutputBase_ == "lumibased"){
beamspot::dumpBeamSpotTxt(outTxt, false, currentBS);
beamspot::dumpBeamSpotTxt(outFile, currentBS);
}
}
else {
Expand All @@ -155,7 +157,7 @@ void AlcaBeamSpotHarvester::endRun(const edm::Run& iRun, const edm::EventSetup&)
//poolDbService->appendSinceTime<BeamSpotObjects>(aBeamSpot, poolDbService->currentTime(),"BeamSpotObjectsRcd");
poolDbService->writeOne<BeamSpotObjects>(aBeamSpot, thisIOV, outputrecordName_);
if (dumpTxt_ && beamSpotOutputBase_ == "lumibased"){
beamspot::dumpBeamSpotTxt(outTxt, true, currentBS);
beamspot::dumpBeamSpotTxt(outFile, currentBS);
}
}

Expand Down Expand Up @@ -187,6 +189,9 @@ void AlcaBeamSpotHarvester::endRun(const edm::Run& iRun, const edm::EventSetup&)


}

outFile.close();

}

//--------------------------------------------------------------------------------------------------
Expand Down
14 changes: 3 additions & 11 deletions RecoVertex/BeamSpotProducer/interface/BeamSpotWrite2Txt.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,8 @@ namespace beamspot {
std::time_t reftime[2] ;
};

void dumpBeamSpotTxt(std::string const& fileName, bool append, BeamSpotContainer const& bsContainer){

std::ofstream outFile;

if (!append)
outFile.open(fileName.c_str());
else
outFile.open(fileName.c_str(), std::ios::app);

void dumpBeamSpotTxt(std::ofstream & outFile, BeamSpotContainer const& bsContainer){

outFile << "Runnumber " << bsContainer.run << std::endl;
outFile << "BeginTimeOfFit " << bsContainer.beginTimeOfFit << " " << bsContainer.reftime[0] << std::endl;
outFile << "EndTimeOfFit " << bsContainer.endTimeOfFit << " " << bsContainer.reftime[1] << std::endl;
Expand All @@ -51,8 +44,7 @@ namespace beamspot {
outFile << "EmittanceX " << bsContainer.beamspot.emittanceX() << std::endl;
outFile << "EmittanceY " << bsContainer.beamspot.emittanceY() << std::endl;
outFile << "BetaStar " << bsContainer.beamspot.betaStar() << std::endl;

outFile.close();

}

} // end namespace beamspot
Expand Down
4 changes: 2 additions & 2 deletions RecoVertex/BeamSpotProducer/src/BeamFitter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@ void BeamFitter::dumpTxtFile(std::string & fileName, bool append){
currentBS.endLumiOfFit = fendLumiOfFit ;
std::copy(freftime, freftime+2, currentBS.reftime);

beamspot::dumpBeamSpotTxt(fileName, append, currentBS);
beamspot::dumpBeamSpotTxt(outFile, currentBS);

//write here Pv info for DIP only: This added only if append is false, which happen for DIP only :)
if(!append){
Expand All @@ -697,7 +697,7 @@ void BeamFitter::dumpTxtFile(std::string & fileName, bool append){
outFile << "nPV "<< (int)ForDIPPV_[6] << std::endl;
}//writeDIPPVInfo_
}//else end here

outFile.close();
}

Expand Down

0 comments on commit 4f352f5

Please sign in to comment.