29 char ts[] =
"yyyy.mn.dd hh:mm:ss zzz ";
30 char* fbeginTime = ts;
31 strftime(fbeginTime,
sizeof(ts),
"%Y.%m.%d %H:%M:%S GMT",gmtime(&
freftime[0]));
34 strftime(fendTime,
sizeof(ts),
"%Y.%m.%d %H:%M:%S GMT",gmtime(&
freftime[1]));
85 ftree_ =
new TTree(
"mytree",
"mytree");
121 ftreeFit_ =
new TTree(
"fitResults",
"fitResults");
159 h1ntrks =
new TH1F(
"h1ntrks",
"number of tracks per event",50,0,50);
160 h1vz_event =
new TH1F(
"h1vz_event",
"track Vz", 50, -30, 30 );
161 h1cutFlow =
new TH1F(
"h1cutFlow",
"Cut flow table of track selection", 9, 0, 9);
162 h1cutFlow->GetXaxis()->SetBinLabel(1,
"No cut");
163 h1cutFlow->GetXaxis()->SetBinLabel(2,
"Traker hits");
164 h1cutFlow->GetXaxis()->SetBinLabel(3,
"Pixel hits");
165 h1cutFlow->GetXaxis()->SetBinLabel(4,
"norm. #chi^{2}");
166 h1cutFlow->GetXaxis()->SetBinLabel(5,
"algo");
167 h1cutFlow->GetXaxis()->SetBinLabel(6,
"quality");
168 h1cutFlow->GetXaxis()->SetBinLabel(7,
"d_{0}");
169 h1cutFlow->GetXaxis()->SetBinLabel(8,
"z_{0}");
170 h1cutFlow->GetXaxis()->SetBinLabel(9,
"p_{T}");
177 fPVTree_ =
new TTree(
"PrimaryVertices",
"PrimaryVertices");
221 const std::time_t ftmptime = ftimestamp >> 32;
251 refBS = recoBeamSpotHandle.
product();
259 for (reco::TrackCollection::const_iterator
track = tracks->begin();
294 for (
int i=0;
i<5; ++
i) {
295 for (
int j=0; j<5; ++j) {
330 for (
size_t ipv=0; ipv != pv.
size(); ++ipv ) {
332 if (! pv[ipv].isFake() )
fpvValid =
true;
334 if ( ipv==0 && !pv[0].isFake() ) {
fpvx = pv[0].x();
fpvy = pv[0].y();
fpvz = pv[0].z(); }
360 edm::LogInfo(
"BeamFitter") <<
"Selected track quality = " <<
track->qualityMask()
361 <<
"; track algorithm = " <<
track->algoName() <<
"= TrackAlgorithm: " <<
track->algo() << std::endl;
382 for( std::vector<BSTrkParameters>::const_iterator iparam =
fBSvector.begin(); iparam !=
fBSvector.end(); ++iparam) {
384 eventZ += fabs( iparam->z0() - averageZ );
400 bool pv_fit_ok =
false;
453 for (
int j = 0 ; j < 7 ; ++j) {
454 for(
int k = j ;
k < 7 ; ++
k) {
459 if (pv_fit_ok && fit_ok ) {
477 if (pv_fit_ok && fit_ok) {
480 else if(!pv_fit_ok && fit_ok){
483 else if(pv_fit_ok && !fit_ok){
486 else if(!pv_fit_ok && !fit_ok){
496 return fit_ok && pv_fit_ok;
508 edm::LogWarning(
"BeamFitter") <<
"No event read! No Fitting!" << std::endl;
516 edm::LogInfo(
"BeamFitter") <<
"Calculating beam spot..." << std::endl
559 edm::LogInfo(
"BeamFitter") <<
"Not enough good tracks selected! No beam fit!" << std::endl;
579 bool widthfit_ok =
false;
583 edm::LogInfo(
"BeamFitter") <<
"Calculating beam spot positions('d0-phi0' method) and width using llh Fit"<< std::endl
608 edm::LogWarning(
"BeamFitter") <<
"Not enough good tracks selected! No beam fit!" << std::endl;
615 outFile.open(fileName.c_str(),std::ios::app);
616 outFile<<
"-------------------------------------------------------------------------------------------------------------------------------------------------------------"<<std::endl;
617 outFile<<
"Beam width(in cm) from Log-likelihood fit (Here we assume a symmetric beam(SigmaX=SigmaY)!)"<<std::endl;
618 outFile<<
" "<<std::endl;
629 sprintf(index,
"%s%i",
"_Run",
frun );
636 outFile.open(fileName.c_str());
638 outFile.open(fileName.c_str(),std::ios::app);
642 for (std::map<int,reco::BeamSpot>::const_iterator abspot =
fbspotPVMap.begin(); abspot!=
fbspotPVMap.end(); ++abspot) {
644 int bx = abspot->first;
646 outFile <<
"Runnumber " <<
frun <<
" bx " << bx << std::endl;
650 outFile <<
"Type " << beamspottmp.
type() << std::endl;
651 outFile <<
"X0 " << beamspottmp.
x0() << std::endl;
652 outFile <<
"Y0 " << beamspottmp.
y0() << std::endl;
653 outFile <<
"Z0 " << beamspottmp.
z0() << std::endl;
654 outFile <<
"sigmaZ0 " << beamspottmp.
sigmaZ() << std::endl;
655 outFile <<
"dxdz " << beamspottmp.
dxdz() << std::endl;
656 outFile <<
"dydz " << beamspottmp.
dydz() << std::endl;
657 outFile <<
"BeamWidthX " << beamspottmp.
BeamWidthX() << std::endl;
658 outFile <<
"BeamWidthY " << beamspottmp.
BeamWidthY() << std::endl;
659 for (
int i = 0;
i<6; ++
i) {
660 outFile <<
"Cov("<<
i<<
",j) ";
661 for (
int j=0; j<7; ++j) {
662 outFile << beamspottmp.
covariance(i,j) <<
" ";
664 outFile << std::endl;
666 outFile <<
"Cov(6,j) 0 0 0 0 0 0 " << beamspottmp.
covariance(6,6) << std::endl;
668 outFile <<
"EmittanceX " << beamspottmp.
emittanceX() << std::endl;
669 outFile <<
"EmittanceY " << beamspottmp.
emittanceY() << std::endl;
670 outFile <<
"BetaStar " << beamspottmp.
betaStar() << std::endl;
675 outFile <<
"Runnumber " <<
frun << std::endl;
694 for (
int i = 0;
i<6; ++
i) {
695 outFile <<
"Cov("<<
i<<
",j) ";
696 for (
int j=0; j<7; ++j) {
699 outFile << std::endl;
715 outFile <<
"meanPV "<<
ForDIPPV_[1] << std::endl;
716 outFile <<
"meanErrPV "<<
ForDIPPV_[2] << std::endl;
717 outFile <<
"rmsPV "<<
ForDIPPV_[3] << std::endl;
718 outFile <<
"rmsErrPV "<<
ForDIPPV_[4] << std::endl;
746 for (
int i = 0;
i<7; ++
i) {
747 for (
int j=0; j<7; ++j) {
753 std::cout <<
"poolDBService available"<<std::endl;
755 std::cout <<
"new tag requested" << std::endl;
757 "BeamSpotObjectsRcd" );
760 std::cout <<
"no new tag requested" << std::endl;
762 "BeamSpotObjectsRcd" );
774 std::cout <<
" d0-phi Iterative:" << std::endl;
780 std::cout <<
"\n Now run tests of the different fits\n";
788 std::cout <<
" z Chi2 Fit ONLY:" << std::endl;
789 std::cout << beam_fit_z_chi2 << std::endl;
792 fit_type =
"combined";
797 std::cout <<
" z Log-Likelihood Fit ONLY:" << std::endl;
805 std::cout <<
" d0-phi0 Fit ONLY:" << std::endl;
830 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_
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)