37 static char ts[] =
"yyyy.mn.dd hh:mm:ss zzz ";
40 strftime(ts,
sizeof(ts),
"%Y.%m.%d %H:%M:%S GMT",ptm);
93 ftree_ =
new TTree(
"mytree",
"mytree");
129 ftreeFit_ =
new TTree(
"fitResults",
"fitResults");
167 h1ntrks =
new TH1F(
"h1ntrks",
"number of tracks per event",50,0,50);
168 h1vz_event =
new TH1F(
"h1vz_event",
"track Vz", 50, -30, 30 );
169 h1cutFlow =
new TH1F(
"h1cutFlow",
"Cut flow table of track selection", 9, 0, 9);
170 h1cutFlow->GetXaxis()->SetBinLabel(1,
"No cut");
171 h1cutFlow->GetXaxis()->SetBinLabel(2,
"Traker hits");
172 h1cutFlow->GetXaxis()->SetBinLabel(3,
"Pixel hits");
173 h1cutFlow->GetXaxis()->SetBinLabel(4,
"norm. #chi^{2}");
174 h1cutFlow->GetXaxis()->SetBinLabel(5,
"algo");
175 h1cutFlow->GetXaxis()->SetBinLabel(6,
"quality");
176 h1cutFlow->GetXaxis()->SetBinLabel(7,
"d_{0}");
177 h1cutFlow->GetXaxis()->SetBinLabel(8,
"z_{0}");
178 h1cutFlow->GetXaxis()->SetBinLabel(9,
"p_{T}");
185 fPVTree_ =
new TTree(
"PrimaryVertices",
"PrimaryVertices");
229 const std::time_t ftmptime = ftimestamp >> 32;
258 if ( iEvent.
getByLabel(
"offlineBeamSpot",recoBeamSpotHandle) )
259 refBS = recoBeamSpotHandle.
product();
267 for ( reco::TrackCollection::const_iterator track = tracks->begin();
268 track != tracks->end();
292 fphi0 = track->phi();
306 for (
int i=0;
i<5; ++
i) {
307 for (
int j=0;
j<5; ++
j) {
308 fcov[
i][
j] = track->covariance(
i,
j);
342 for (
size_t ipv=0; ipv != pv.
size(); ++ipv ) {
344 if (! pv[ipv].isFake() )
fpvValid =
true;
346 if ( ipv==0 && !pv[0].isFake() ) {
fpvx = pv[0].x();
fpvy = pv[0].y();
fpvz = pv[0].z(); }
372 edm::LogInfo(
"BeamFitter") <<
"Selected track quality = " << track->qualityMask()
373 <<
"; track algorithm = " << track->algoName() <<
"= TrackAlgorithm: " << track->algo() << std::endl;
392 averageZ = averageZ/(float)(
fBSvector.size());
394 for( std::vector<BSTrkParameters>::const_iterator iparam =
fBSvector.begin(); iparam !=
fBSvector.end(); ++iparam) {
396 eventZ += fabs( iparam->z0() - averageZ );
412 bool pv_fit_ok =
false;
465 for (
int j = 0 ;
j < 7 ; ++
j) {
466 for(
int k =
j ;
k < 7 ; ++
k) {
471 if (pv_fit_ok && fit_ok ) {
489 if (pv_fit_ok && fit_ok) {
492 else if(!pv_fit_ok && fit_ok){
495 else if(pv_fit_ok && !fit_ok){
498 else if(!pv_fit_ok && !fit_ok){
508 return fit_ok && pv_fit_ok;
520 edm::LogWarning(
"BeamFitter") <<
"No event read! No Fitting!" << std::endl;
528 edm::LogInfo(
"BeamFitter") <<
"Calculating beam spot..." << std::endl
571 edm::LogInfo(
"BeamFitter") <<
"Not enough good tracks selected! No beam fit!" << std::endl;
591 bool widthfit_ok =
false;
595 edm::LogInfo(
"BeamFitter") <<
"Calculating beam spot positions('d0-phi0' method) and width using llh Fit"<< std::endl
606 myalgo->
SetFitType(std::string(
"likelihood"));
620 edm::LogWarning(
"BeamFitter") <<
"Not enough good tracks selected! No beam fit!" << std::endl;
627 outFile.open(fileName.c_str(),std::ios::app);
628 outFile<<
"-------------------------------------------------------------------------------------------------------------------------------------------------------------"<<std::endl;
629 outFile<<
"Beam width(in cm) from Log-likelihood fit (Here we assume a symmetric beam(SigmaX=SigmaY)!)"<<std::endl;
630 outFile<<
" "<<std::endl;
641 sprintf(index,
"%s%i",
"_Run",
frun );
648 outFile.open(fileName.c_str());
650 outFile.open(fileName.c_str(),std::ios::app);
654 for (std::map<int,reco::BeamSpot>::const_iterator abspot =
fbspotPVMap.begin(); abspot!=
fbspotPVMap.end(); ++abspot) {
656 int bx = abspot->first;
658 outFile <<
"Runnumber " <<
frun <<
" bx " << bx << std::endl;
662 outFile <<
"Type " << beamspottmp.
type() << std::endl;
663 outFile <<
"X0 " << beamspottmp.
x0() << std::endl;
664 outFile <<
"Y0 " << beamspottmp.
y0() << std::endl;
665 outFile <<
"Z0 " << beamspottmp.
z0() << std::endl;
666 outFile <<
"sigmaZ0 " << beamspottmp.
sigmaZ() << std::endl;
667 outFile <<
"dxdz " << beamspottmp.
dxdz() << std::endl;
668 outFile <<
"dydz " << beamspottmp.
dydz() << std::endl;
669 outFile <<
"BeamWidthX " << beamspottmp.
BeamWidthX() << std::endl;
670 outFile <<
"BeamWidthY " << beamspottmp.
BeamWidthY() << std::endl;
671 for (
int i = 0;
i<6; ++
i) {
672 outFile <<
"Cov("<<
i<<
",j) ";
673 for (
int j=0;
j<7; ++
j) {
676 outFile << std::endl;
678 outFile <<
"Cov(6,j) 0 0 0 0 0 0 " << beamspottmp.
covariance(6,6) << std::endl;
680 outFile <<
"EmittanceX " << beamspottmp.
emittanceX() << std::endl;
681 outFile <<
"EmittanceY " << beamspottmp.
emittanceY() << std::endl;
682 outFile <<
"BetaStar " << beamspottmp.
betaStar() << std::endl;
687 outFile <<
"Runnumber " <<
frun << std::endl;
706 for (
int i = 0;
i<6; ++
i) {
707 outFile <<
"Cov("<<
i<<
",j) ";
708 for (
int j=0;
j<7; ++
j) {
711 outFile << std::endl;
726 outFile <<
"events "<< (int)
ForDIPPV_[0] << std::endl;
727 outFile <<
"meanPV "<<
ForDIPPV_[1] << std::endl;
728 outFile <<
"meanErrPV "<<
ForDIPPV_[2] << std::endl;
729 outFile <<
"rmsPV "<<
ForDIPPV_[3] << std::endl;
730 outFile <<
"rmsErrPV "<<
ForDIPPV_[4] << std::endl;
731 outFile <<
"maxPV "<< (int)
ForDIPPV_[5] << std::endl;
732 outFile <<
"nPV "<< (int)
ForDIPPV_[6] << std::endl;
758 for (
int i = 0;
i<7; ++
i) {
759 for (
int j=0;
j<7; ++
j) {
765 std::cout <<
"poolDBService available"<<std::endl;
767 std::cout <<
"new tag requested" << std::endl;
769 "BeamSpotObjectsRcd" );
772 std::cout <<
"no new tag requested" << std::endl;
774 "BeamSpotObjectsRcd" );
786 std::cout <<
" d0-phi Iterative:" << std::endl;
792 std::cout <<
"\n Now run tests of the different fits\n";
795 std::string fit_type =
"chi2";
800 std::cout <<
" z Chi2 Fit ONLY:" << std::endl;
801 std::cout << beam_fit_z_chi2 << std::endl;
804 fit_type =
"combined";
809 std::cout <<
" z Log-Likelihood Fit ONLY:" << std::endl;
817 std::cout <<
" d0-phi0 Fit ONLY:" << std::endl;
842 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_
edm::InputTag vertexLabel_
double sigmaZ0Error() const
error on sigma z
void setTree(TTree *tree)
int stripTIBLayersWithMeasurement() 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_
int pixelLayersWithMeasurement() const
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
const char * formatBTime(const std::time_t &)
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 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)
edm::InputTag tracksLabel_
int stripTIDLayersWithMeasurement() const
int trackerLayersWithMeasurement() const
cond::Time_t beginOfTime() const
std::vector< reco::TrackBase::TrackAlgorithm > algorithm_
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
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
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_
TimeValue_t value() const
std::string outputDIPTxt_
static TrackQuality qualityByName(const std::string &name)
void dumpTxtFile(std::string &, bool)
std::vector< float > ForDIPPV_
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
T const * product() const
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
reco::BeamSpot getBeamSpot()
void SetConvergence(double val)
reco::BeamSpot Fit_d0phi()
bool IsFitPerBunchCrossing()
edm::Timestamp time() const
Power< A, B >::type pow(const A &a, const B &b)
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)