418 for (
int ivtxSample=0; ivtxSample!= (int)
vtxSample_.size(); ++ivtxSample) {
427 std::cout <<
"Some problem occurred with the particle data table. This may not work !." <<std::endl;
436 std::cout <<
"no HepMCProduct found"<< std::endl;
440 std::cout <<
"generator HepMCProduct found"<< std::endl;
455 std::vector<simPrimaryVertex> simpv;
461 h[
"nsimvtx"+isuffix]->Fill(simpv.size());
463 for(std::vector<simPrimaryVertex>::iterator vsim=simpv.begin();
464 vsim!=simpv.end(); vsim++){
468 h[
"nbsimtksinvtx"+isuffix]->Fill(vsim->nGenTrk);
469 h[
"xsim"+isuffix]->Fill(vsim->x*
simUnit_);
470 h[
"ysim"+isuffix]->Fill(vsim->y*
simUnit_);
471 h[
"zsim"+isuffix]->Fill(vsim->z*
simUnit_);
472 nsimtrk+=vsim->nGenTrk;
475 for(reco::VertexCollection::const_iterator vrec=recVtxs->begin();
476 vrec!=recVtxs->end(); ++vrec){
479 if( ((vsim->recVtx) && (fabs(vsim->recVtx->position().z()-vsim->z)>fabs(vrec->z()-vsim->z)))
482 vsim->recVtx=&(*vrec);
486 h[
"nsimtrk"+isuffix]->Fill(
float(nsimtrk));
492 if(
verbose_){
std::cout <<
"primary matched " << vsim->x <<
" " << vsim->y <<
" " << vsim->z << std:: endl;}
494 h[
"resx"+isuffix]->Fill( vsim->recVtx->x()-vsim->x*
simUnit_ );
495 h[
"resy"+isuffix]->Fill( vsim->recVtx->y()-vsim->y*
simUnit_ );
496 h[
"resz"+isuffix]->Fill( vsim->recVtx->z()-vsim->z*
simUnit_ );
497 h[
"pullx"+isuffix]->Fill( (vsim->recVtx->x()-vsim->x*
simUnit_)/vsim->recVtx->xError() );
498 h[
"pully"+isuffix]->Fill( (vsim->recVtx->y()-vsim->y*
simUnit_)/vsim->recVtx->yError() );
499 h[
"pullz"+isuffix]->Fill( (vsim->recVtx->z()-vsim->z*
simUnit_)/vsim->recVtx->zError() );
500 h[
"eff"+isuffix]->Fill( 1.);
502 if (vsim->recVtx==&(*recVtxs->begin())){
503 h[
"efftag"+isuffix]->Fill( 1.);
505 h[
"efftag"+isuffix]->Fill( 0.);
508 h[
"effvseta"+isuffix]->Fill(vsim->ptot.pseudoRapidity(),1.);
509 h[
"effvsptsq"+isuffix]->Fill(vsim->ptsq,1.);
510 h[
"effvsntrk"+isuffix]->Fill(vsim->nGenTrk,1.);
511 h[
"effvsnrectrk"+isuffix]->Fill(recTrks->size(),1.);
512 h[
"effvsz"+isuffix]->Fill(vsim->z*
simUnit_,1.);
516 if(
verbose_){
std::cout <<
"primary not found " << vsim->x <<
" " << vsim->y <<
" " << vsim->z <<
" nGenTrk=" << vsim->nGenTrk << std::endl;}
518 h[
"eff"+isuffix]->Fill( 0.);
519 if(simpv.size()==1){
h[
"efftag"+isuffix]->Fill( 0.); }
520 h[
"effvseta"+isuffix]->Fill(vsim->ptot.pseudoRapidity(),0.);
521 h[
"effvsptsq"+isuffix]->Fill(vsim->ptsq,0.);
522 h[
"effvsntrk"+isuffix]->Fill(
float(vsim->nGenTrk),0.);
523 h[
"effvsnrectrk"+isuffix]->Fill(recTrks->size(),0.);
524 h[
"effvsz"+isuffix]->Fill(vsim->z*
simUnit_,0.);
531 if (recVtxs->size()>0 && simpv.size()>0){
532 Double_t dz=(*recVtxs->begin()).
z() - (*simpv.begin()).
z*
simUnit_;
533 h[
"zdistancetag"+isuffix]->Fill(dz);
534 if( fabs(dz)<0.0500){
535 h[
"puritytag"+isuffix]->Fill(1.);
538 h[
"puritytag"+isuffix]->Fill(0.);
547 h[
"nrecvtx"+isuffix]->Fill(recVtxs->size());
548 h[
"nrectrk"+isuffix]->Fill(recTrks->size());
549 h[
"nbvtx"+isuffix]->Fill(recVtxs->size()*1.);
550 if((recVtxs->size()==0)||recVtxs->begin()->isFake()) {
h[
"nrectrk0vtx"+isuffix]->Fill(recTrks->size());}
552 for(reco::VertexCollection::const_iterator
v=recVtxs->begin();
553 v!=recVtxs->end(); ++
v){
555 if(
v->isFake())
continue;
559 t!=
v->tracks_end();
t++) {
561 if ( (**t).charge() < -1 || (**t).charge() > 1 ) {
562 h[
"tklinks"+isuffix]->Fill(0.);
565 h[
"tklinks"+isuffix]->Fill(1.);
571 h[
"tklinks"+isuffix]->Fill(0.);
574 h[
"nbtksinvtx"+isuffix]->Fill(
v->tracksSize());
575 h[
"vtxchi2"+isuffix]->Fill(
v->chi2());
576 h[
"vtxndf"+isuffix]->Fill(
v->ndof());
578 h[
"xrec"+isuffix]->Fill(
v->position().x());
579 h[
"yrec"+isuffix]->Fill(
v->position().y());
580 h[
"zrec"+isuffix]->Fill(
v->position().z());
581 if (
v==recVtxs->begin()){
582 h[
"xrectag"+isuffix]->Fill(
v->position().x());
583 h[
"yrectag"+isuffix]->Fill(
v->position().y());
584 h[
"zrectag"+isuffix]->Fill(
v->position().z());
587 bool problem =
false;
588 h[
"nans"+isuffix]->Fill(1.,
isnan(
v->position().x())*1.);
589 h[
"nans"+isuffix]->Fill(2.,
isnan(
v->position().y())*1.);
590 h[
"nans"+isuffix]->Fill(3.,
isnan(
v->position().z())*1.);
593 for (
int i = 0;
i != 3;
i++) {
594 for (
int j =
i;
j != 3;
j++) {
596 h[
"nans"+isuffix]->Fill(index*1.,
isnan(
v->covariance(
i,
j))*1.);
597 if (
isnan(
v->covariance(
i,
j))) problem =
true;
599 if (
j ==
i &&
v->covariance(
i,
j) < 0) {
600 h[
"nans"+isuffix]->Fill(index*1., 1.);
612 t!=
v->tracks_end();
t++) {
613 std::cout <<
"Track " << itk++ << std::endl;
615 for (
int i = 0;
i != 5;
i++) {
616 for (
int j = 0;
j != 5;
j++) {
617 data[i2] = (**t).covariance(
i,
j);
618 std::cout << std:: scientific << data[i2] <<
" ";
624 = gsl_matrix_view_array (data, 5, 5);
626 gsl_vector *eval = gsl_vector_alloc (5);
627 gsl_matrix *evec = gsl_matrix_alloc (5, 5);
629 gsl_eigen_symmv_workspace *
w =
630 gsl_eigen_symmv_alloc (5);
632 gsl_eigen_symmv (&m.matrix, eval, evec, w);
634 gsl_eigen_symmv_free (w);
636 gsl_eigen_symmv_sort (eval, evec,
637 GSL_EIGEN_SORT_ABS_ASC);
642 for (i = 0; i < 5; i++) {
644 = gsl_vector_get (eval, i);
648 printf (
"eigenvalue = %g\n", eval_i);
std::vector< simPrimaryVertex > getSimPVs(const edm::Handle< edm::HepMCProduct > evtMC, std::string suffix)
std::map< std::string, TDirectory * > hdir
void getData(T &iHolder) const
edm::ESHandle< ParticleDataTable > pdt
std::vector< std::string > vtxSample_
std::string recoTrackProducer_
float ChiSquaredProbability(double chiSquared, double nrDOF)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
std::map< std::string, TH1 * > h
void printRecVtxs(const edm::Handle< reco::VertexCollection > recVtxs)
char data[epos_bytes_allocation]
std::vector< TrackBaseRef >::const_iterator trackRef_iterator
The iteratator for the vector<TrackRef>
std::vector< std::string > suffixSample_
bool matchVertex(const simPrimaryVertex &vsim, const reco::Vertex &vrec)