30 char ts[] =
"yyyy.mn.dd hh:mm:ss zzz ";
31 char *fbeginTime = ts;
32 strftime(fbeginTime,
sizeof(ts),
"%Y.%m.%d %H:%M:%S GMT", gmtime(&
freftime[0]));
35 strftime(fendTime,
sizeof(ts),
"%Y.%m.%d %H:%M:%S GMT", gmtime(&
freftime[1]));
75 .getUntrackedParameter<std::vector<std::string> >(
"TrackAlgorithm");
77 .getUntrackedParameter<std::vector<std::string> >(
"TrackQuality");
95 ftree_ =
new TTree(
"mytree",
"mytree");
131 ftreeFit_ =
new TTree(
"fitResults",
"fitResults");
169 h1ntrks =
new TH1F(
"h1ntrks",
"number of tracks per event", 50, 0, 50);
170 h1vz_event =
new TH1F(
"h1vz_event",
"track Vz", 50, -30, 30);
171 h1cutFlow =
new TH1F(
"h1cutFlow",
"Cut flow table of track selection", 9, 0, 9);
172 h1cutFlow->GetXaxis()->SetBinLabel(1,
"No cut");
173 h1cutFlow->GetXaxis()->SetBinLabel(2,
"Traker hits");
174 h1cutFlow->GetXaxis()->SetBinLabel(3,
"Pixel hits");
175 h1cutFlow->GetXaxis()->SetBinLabel(4,
"norm. #chi^{2}");
176 h1cutFlow->GetXaxis()->SetBinLabel(5,
"algo");
177 h1cutFlow->GetXaxis()->SetBinLabel(6,
"quality");
178 h1cutFlow->GetXaxis()->SetBinLabel(7,
"d_{0}");
179 h1cutFlow->GetXaxis()->SetBinLabel(8,
"z_{0}");
180 h1cutFlow->GetXaxis()->SetBinLabel(9,
"p_{T}");
187 fPVTree_ =
new TTree(
"PrimaryVertices",
"PrimaryVertices");
236 beamFitter.
addUntracked<
bool>(
"WriteDIPOnBadFit",
true);
245 beamFitter.
addUntracked<
double>(
"MaximumImpactParameter");
250 beamFitter.
addUntracked<std::vector<std::string> >(
"TrackAlgorithm");
251 beamFitter.
addUntracked<std::vector<std::string> >(
"TrackQuality");
253 beamFitter.
addUntracked<
double>(
"FractionOfFittedTrks");
264 const std::time_t ftmptime = ftimestamp >> 32;
299 refBS = recoBeamSpotHandle.
product();
307 for (reco::TrackCollection::const_iterator
track = tracks->begin();
track != tracks->end(); ++
track) {
342 for (
int i = 0;
i < 5; ++
i) {
343 for (
int j = 0;
j < 5; ++
j) {
354 for (
unsigned int i = 0;
i <
quality_.size(); ++
i) {
376 for (
size_t ipv = 0; ipv != pv.
size(); ++ipv) {
377 if (!pv[ipv].isFake())
380 if (ipv == 0 && !pv[0].isFake()) {
414 edm::LogInfo(
"BeamFitter") <<
"Selected track quality = " <<
track->qualityMask()
415 <<
"; track algorithm = " <<
track->algoName()
416 <<
"= TrackAlgorithm: " <<
track->algo() << std::endl;
435 averageZ = averageZ / (float)(
fBSvector.size());
437 for (std::vector<BSTrkParameters>::const_iterator iparam =
fBSvector.begin(); iparam !=
fBSvector.end(); ++iparam) {
438 eventZ += fabs(iparam->z0() - averageZ);
452 bool pv_fit_ok =
false;
502 for (
int j = 0;
j < 7; ++
j) {
503 for (
int k =
j;
k < 7; ++
k) {
508 if (pv_fit_ok && fit_ok) {
525 if (pv_fit_ok && fit_ok) {
527 }
else if (!pv_fit_ok && fit_ok) {
529 }
else if (pv_fit_ok && !fit_ok) {
531 }
else if (!pv_fit_ok && !fit_ok) {
539 for (
size_t i = 0;
i < 7;
i++)
543 return fit_ok && pv_fit_ok;
553 edm::LogWarning(
"BeamFitter") <<
"No event read! No Fitting!" << std::endl;
560 edm::LogInfo(
"BeamFitter") <<
"Calculating beam spot..." << std::endl
603 edm::LogInfo(
"BeamFitter") <<
"Not enough good tracks selected! No beam fit!" << std::endl;
621 bool widthfit_ok =
false;
624 edm::LogInfo(
"BeamFitter") <<
"Calculating beam spot positions('d0-phi0' method) and width using llh Fit"
651 edm::LogWarning(
"BeamFitter") <<
"Not enough good tracks selected! No beam fit!" << std::endl;
658 outFile.open(fileName.c_str(), std::ios::app);
659 outFile <<
"---------------------------------------------------------------------------------------------------------"
660 "----------------------------------------------------"
662 outFile <<
"Beam width(in cm) from Log-likelihood fit (Here we assume a symmetric beam(SigmaX=SigmaY)!)" << std::endl;
663 outFile <<
" " << std::endl;
674 sprintf(index,
"%s%i",
"_Run",
frun);
681 outFile.open(fileName.c_str());
683 outFile.open(fileName.c_str(), std::ios::app);
686 for (std::map<int, reco::BeamSpot>::const_iterator abspot =
fbspotPVMap.begin(); abspot !=
fbspotPVMap.end();
689 int bx = abspot->first;
691 outFile <<
"Runnumber " <<
frun <<
" bx " << bx << std::endl;
695 outFile <<
"Type " << beamspottmp.
type() << std::endl;
696 outFile <<
"X0 " << beamspottmp.
x0() << std::endl;
697 outFile <<
"Y0 " << beamspottmp.
y0() << std::endl;
698 outFile <<
"Z0 " << beamspottmp.
z0() << std::endl;
699 outFile <<
"sigmaZ0 " << beamspottmp.
sigmaZ() << std::endl;
700 outFile <<
"dxdz " << beamspottmp.
dxdz() << std::endl;
701 outFile <<
"dydz " << beamspottmp.
dydz() << std::endl;
702 outFile <<
"BeamWidthX " << beamspottmp.
BeamWidthX() << std::endl;
703 outFile <<
"BeamWidthY " << beamspottmp.
BeamWidthY() << std::endl;
704 for (
int i = 0;
i < 6; ++
i) {
705 outFile <<
"Cov(" <<
i <<
",j) ";
706 for (
int j = 0;
j < 7; ++
j) {
709 outFile << std::endl;
711 outFile <<
"Cov(6,j) 0 0 0 0 0 0 " << beamspottmp.
covariance(6, 6) << std::endl;
713 outFile <<
"EmittanceX " << beamspottmp.
emittanceX() << std::endl;
714 outFile <<
"EmittanceY " << beamspottmp.
emittanceY() << std::endl;
715 outFile <<
"BetaStar " << beamspottmp.
betaStar() << std::endl;
733 outFile <<
"events " << (int)
ForDIPPV_[0] << std::endl;
734 outFile <<
"meanPV " <<
ForDIPPV_[1] << std::endl;
735 outFile <<
"meanErrPV " <<
ForDIPPV_[2] << std::endl;
736 outFile <<
"rmsPV " <<
ForDIPPV_[3] << std::endl;
737 outFile <<
"rmsErrPV " <<
ForDIPPV_[4] << std::endl;
738 outFile <<
"maxPV " << (int)
ForDIPPV_[5] << std::endl;
739 outFile <<
"nPV " << (int)
ForDIPPV_[6] << std::endl;
765 for (
int i = 0;
i < 7; ++
i) {
766 for (
int j = 0;
j < 7; ++
j) {
772 std::cout <<
"poolDBService available" << std::endl;
774 std::cout <<
"new tag requested" << std::endl;
777 std::cout <<
"no new tag requested" << std::endl;
790 std::cout <<
" d0-phi Iterative:" << std::endl;
796 std::cout <<
"\n Now run tests of the different fits\n";
804 std::cout <<
" z Chi2 Fit ONLY:" << std::endl;
805 std::cout << beam_fit_z_chi2 << std::endl;
808 fit_type =
"combined";
813 std::cout <<
" z Log-Likelihood Fit ONLY:" << std::endl;
821 std::cout <<
" d0-phi0 Fit ONLY:" << std::endl;
845 std::cout <<
"No good track selected! No beam fit!" << std::endl;
int stripTOBLayersWithMeasurement() const
math::Error< dimension >::type CovarianceMatrix
double z0() const
z coordinate
T getUntrackedParameter(std::string const &, T const &) const
std::vector< std::string > trk_Algorithm_
double sigmaZ0Error() const
error on sigma z
void setTree(TTree *tree)
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
int stripTIBLayersWithMeasurement() const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
double dydzError() const
error on dydz
std::map< int, reco::BeamSpot > fbspotPVMap
boost::dynamic_bitset append(const boost::dynamic_bitset<> &bs1, const boost::dynamic_bitset<> &bs2)
this method takes two bitsets bs1 and bs2 and returns result of bs2 appended to the end of bs1 ...
std::map< int, reco::BeamSpot > getBeamSpotMap()
bool runBeamWidthFitter()
void SetSigmaZ(double val)
set sigma Z, RMS bunch length
void SetMaximumZ(double z)
std::vector< Track > TrackCollection
collection of Tracks
std::vector< std::string > trk_Quality_
edm::LuminosityBlockNumber_t luminosityBlock() const
void dumpBWTxtFile(std::string &)
math::XYZPoint Point
point in the space
auto const & tracks
cannot be loose
void SetCovariance(int i, int j, double val)
set i,j element of the full covariance matrix 7x7
int pixelLayersWithMeasurement() const
void SetInputBeamWidth(double val)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
void Setdydz(double val)
set dydz slope, crossing angle in XZ
int trackerLayersWithMeasurement() const
int pixelEndcapLayersWithMeasurement() const
void readEvent(const edm::Event &iEvent)
void createOneIOV(const T &payload, cond::Time_t firstSinceTime, const std::string &recordName)
double emittanceX() const
additional information
void setType(BeamType type)
set beam type
reco::BeamSpot fbeamWidthFit
void appendOneIOV(const T &payload, cond::Time_t sinceTime, const std::string &recordName)
std::vector< BSTrkParameters > fBSvector
double dydz() const
dydz slope
void readEvent(const edm::Event &iEvent)
void setBeamWidthY(double v)
double emittanceY() const
double dxdzError() const
error on dxdz
bool isNewTagRequest(const std::string &recordName)
int stripTIDLayersWithMeasurement() const
cond::Time_t beginOfTime() const
std::vector< reco::TrackBase::TrackAlgorithm > algorithm_
Abs< T >::type abs(const T &t)
double BeamWidthX() const
beam width X
void Setdxdz(double val)
set dxdz slope, crossing angle
double BeamWidthYError() const
error on beam width Y, assume error in X = Y
ParameterDescriptionBase * add(U const &iLabel, T const &value)
double BeamWidthXError() const
error on beam width X, assume error in X = Y
double z0Error() const
error on z
unsigned long long TimeValue_t
double dxdz() const
dxdz slope
double x0Error() const
error on x
double y0Error() const
error on y
std::string outputfilename_
Log< level::Info, false > LogInfo
std::string outputDIPTxt_
static TrackQuality qualityByName(const std::string &name)
void dumpTxtFile(std::string &, bool)
std::vector< float > ForDIPPV_
T const * product() const
reco::BeamSpot Fit_ited0phi()
void SetFitVariable(std::string name)
double sigmaZ() const
sigma z
int stripLayersWithMeasurement() const
int pixelBarrelLayersWithMeasurement() const
T getParameter(std::string const &) const
double BeamWidthY() const
beam width Y
void SetMinimumNTrks(int n)
void SetBeamWidthX(double val)
set average transverse beam width X
void SetBeamWidthY(double val)
set average transverse beam width Y
void Setd0Cut_d0phi(double d0cut)
double covariance(int i, int j) const
(i,j)-th element of error matrix
std::vector< reco::TrackBase::TrackQuality > quality_
cond::Time_t currentTime() const
int stripTECLayersWithMeasurement() const
static TrackAlgorithm algoByName(const std::string &name)
double y0() const
y coordinate
const Point & position() const
position
static void fillDescription(edm::ParameterSetDescription &)
edm::EDGetTokenT< reco::TrackCollection > tracksToken_
void dumpBeamSpotTxt(std::ofstream &outFile, BeamSpotContainer const &bsContainer)
reco::BeamSpot getBeamSpot()
Log< level::Warning, false > LogWarning
void SetConvergence(double val)
reco::BeamSpot Fit_d0phi()
TimeValue_t value() const
bool IsFitPerBunchCrossing()
edm::Timestamp time() const
Power< A, B >::type pow(const A &a, const B &b)
edm::EDGetTokenT< edm::View< reco::Vertex > > vertexToken_
edm::EDGetTokenT< reco::BeamSpot > beamSpotToken_
BeamType type() const
return beam type
void SetPosition(double x, double y, double z)
set XYZ position
double x0() const
x coordinate
void SetFitType(std::string type)