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]));
86 ftree_ =
new TTree(
"mytree",
"mytree");
122 ftreeFit_ =
new TTree(
"fitResults",
"fitResults");
160 h1ntrks =
new TH1F(
"h1ntrks",
"number of tracks per event",50,0,50);
161 h1vz_event =
new TH1F(
"h1vz_event",
"track Vz", 50, -30, 30 );
162 h1cutFlow =
new TH1F(
"h1cutFlow",
"Cut flow table of track selection", 9, 0, 9);
163 h1cutFlow->GetXaxis()->SetBinLabel(1,
"No cut");
164 h1cutFlow->GetXaxis()->SetBinLabel(2,
"Traker hits");
165 h1cutFlow->GetXaxis()->SetBinLabel(3,
"Pixel hits");
166 h1cutFlow->GetXaxis()->SetBinLabel(4,
"norm. #chi^{2}");
167 h1cutFlow->GetXaxis()->SetBinLabel(5,
"algo");
168 h1cutFlow->GetXaxis()->SetBinLabel(6,
"quality");
169 h1cutFlow->GetXaxis()->SetBinLabel(7,
"d_{0}");
170 h1cutFlow->GetXaxis()->SetBinLabel(8,
"z_{0}");
171 h1cutFlow->GetXaxis()->SetBinLabel(9,
"p_{T}");
178 fPVTree_ =
new TTree(
"PrimaryVertices",
"PrimaryVertices");
222 const std::time_t ftmptime = ftimestamp >> 32;
252 refBS = recoBeamSpotHandle.
product();
260 for (reco::TrackCollection::const_iterator
track = tracks->begin();
295 for (
int i=0;
i<5; ++
i) {
296 for (
int j=0; j<5; ++j) {
331 for (
size_t ipv=0; ipv != pv.
size(); ++ipv ) {
333 if (! pv[ipv].isFake() )
fpvValid =
true;
335 if ( ipv==0 && !pv[0].isFake() ) {
fpvx = pv[0].x();
fpvy = pv[0].y();
fpvz = pv[0].z(); }
361 edm::LogInfo(
"BeamFitter") <<
"Selected track quality = " <<
track->qualityMask()
362 <<
"; track algorithm = " <<
track->algoName() <<
"= TrackAlgorithm: " <<
track->algo() << std::endl;
383 for( std::vector<BSTrkParameters>::const_iterator iparam =
fBSvector.begin(); iparam !=
fBSvector.end(); ++iparam) {
385 eventZ += fabs( iparam->z0() - averageZ );
401 bool pv_fit_ok =
false;
454 for (
int j = 0 ; j < 7 ; ++j) {
455 for(
int k = j ;
k < 7 ; ++
k) {
460 if (pv_fit_ok && fit_ok ) {
478 if (pv_fit_ok && fit_ok) {
481 else if(!pv_fit_ok && fit_ok){
484 else if(pv_fit_ok && !fit_ok){
487 else if(!pv_fit_ok && !fit_ok){
497 return fit_ok && pv_fit_ok;
509 edm::LogWarning(
"BeamFitter") <<
"No event read! No Fitting!" << std::endl;
517 edm::LogInfo(
"BeamFitter") <<
"Calculating beam spot..." << std::endl
560 edm::LogInfo(
"BeamFitter") <<
"Not enough good tracks selected! No beam fit!" << std::endl;
580 bool widthfit_ok =
false;
584 edm::LogInfo(
"BeamFitter") <<
"Calculating beam spot positions('d0-phi0' method) and width using llh Fit"<< std::endl
609 edm::LogWarning(
"BeamFitter") <<
"Not enough good tracks selected! No beam fit!" << std::endl;
616 outFile.open(fileName.c_str(),std::ios::app);
617 outFile<<
"-------------------------------------------------------------------------------------------------------------------------------------------------------------"<<std::endl;
618 outFile<<
"Beam width(in cm) from Log-likelihood fit (Here we assume a symmetric beam(SigmaX=SigmaY)!)"<<std::endl;
619 outFile<<
" "<<std::endl;
630 sprintf(index,
"%s%i",
"_Run",
frun );
637 outFile.open(fileName.c_str());
639 outFile.open(fileName.c_str(),std::ios::app);
643 for (std::map<int,reco::BeamSpot>::const_iterator abspot =
fbspotPVMap.begin(); abspot!=
fbspotPVMap.end(); ++abspot) {
645 int bx = abspot->first;
647 outFile <<
"Runnumber " <<
frun <<
" bx " << bx << std::endl;
651 outFile <<
"Type " << beamspottmp.
type() << std::endl;
652 outFile <<
"X0 " << beamspottmp.
x0() << std::endl;
653 outFile <<
"Y0 " << beamspottmp.
y0() << std::endl;
654 outFile <<
"Z0 " << beamspottmp.
z0() << std::endl;
655 outFile <<
"sigmaZ0 " << beamspottmp.
sigmaZ() << std::endl;
656 outFile <<
"dxdz " << beamspottmp.
dxdz() << std::endl;
657 outFile <<
"dydz " << beamspottmp.
dydz() << std::endl;
658 outFile <<
"BeamWidthX " << beamspottmp.
BeamWidthX() << std::endl;
659 outFile <<
"BeamWidthY " << beamspottmp.
BeamWidthY() << std::endl;
660 for (
int i = 0;
i<6; ++
i) {
661 outFile <<
"Cov("<<
i<<
",j) ";
662 for (
int j=0; j<7; ++j) {
663 outFile << beamspottmp.
covariance(i,j) <<
" ";
665 outFile << std::endl;
667 outFile <<
"Cov(6,j) 0 0 0 0 0 0 " << beamspottmp.
covariance(6,6) << std::endl;
669 outFile <<
"EmittanceX " << beamspottmp.
emittanceX() << std::endl;
670 outFile <<
"EmittanceY " << beamspottmp.
emittanceY() << std::endl;
671 outFile <<
"BetaStar " << beamspottmp.
betaStar() << std::endl;
692 outFile <<
"meanPV "<<
ForDIPPV_[1] << std::endl;
693 outFile <<
"meanErrPV "<<
ForDIPPV_[2] << std::endl;
694 outFile <<
"rmsPV "<<
ForDIPPV_[3] << std::endl;
695 outFile <<
"rmsErrPV "<<
ForDIPPV_[4] << std::endl;
723 for (
int i = 0;
i<7; ++
i) {
724 for (
int j=0; j<7; ++j) {
730 std::cout <<
"poolDBService available"<<std::endl;
732 std::cout <<
"new tag requested" << std::endl;
734 "BeamSpotObjectsRcd" );
737 std::cout <<
"no new tag requested" << std::endl;
739 "BeamSpotObjectsRcd" );
751 std::cout <<
" d0-phi Iterative:" << std::endl;
757 std::cout <<
"\n Now run tests of the different fits\n";
765 std::cout <<
" z Chi2 Fit ONLY:" << std::endl;
766 std::cout << beam_fit_z_chi2 << std::endl;
769 fit_type =
"combined";
774 std::cout <<
" z Log-Likelihood Fit ONLY:" << std::endl;
782 std::cout <<
" d0-phi0 Fit ONLY:" << std::endl;
807 if (
debug_)
std::cout <<
"No good track selected! No beam fit!" << std::endl;
int stripTOBLayersWithMeasurement() const
math::Error< dimension >::type CovarianceMatrix
T getParameter(std::string const &) const
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)
int stripTIBLayersWithMeasurement() const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
double dydzError() const
error on dydz
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
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)
double emittanceX() const
additional information
void setType(BeamType type)
set beam type
reco::BeamSpot fbeamWidthFit
std::vector< BSTrkParameters > fBSvector
double dydz() const
dydz slope
void appendSinceTime(T *payloadObj, cond::Time_t sinceTime, const std::string &recordName, bool withlogging=false)
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
double BeamWidthXError() const
error on beam width X, assume error in X = Y
double z0Error() const
error on z
unsigned long long TimeValue_t
void createNewIOV(T *firstPayloadObj, cond::Time_t firstSinceTime, cond::Time_t firstTillTime, const std::string &recordName, bool withlogging=false)
double dxdz() const
dxdz slope
double x0Error() const
error on x
double y0Error() const
error on y
std::string outputfilename_
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
double BeamWidthY() const
beam width Y
void SetMinimumNTrks(int n)
cond::Time_t endOfTime() const
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)
std::map< int, reco::BeamSpot > fbspotPVMap
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
edm::EDGetTokenT< reco::TrackCollection > tracksToken_
void dumpBeamSpotTxt(std::ofstream &outFile, BeamSpotContainer const &bsContainer)
reco::BeamSpot getBeamSpot()
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)