Go to the documentation of this file.00001 #include <iostream>
00002 #include <sstream>
00003 #include <istream>
00004 #include <fstream>
00005 #include <iomanip>
00006 #include <stdlib.h>
00007 #include <string.h>
00008
00009 #include "HLTrigger/HLTanalyzers/interface/RECOVertex.h"
00010 #include "HLTMessages.h"
00011
00012 static const size_t kMaxVrt = 50;
00013
00014 RECOVertex::RECOVertex() {
00015
00016
00017 _Debug=false;
00018
00019 NVrtx = 0;
00020 VertexCand_x = new float[kMaxVrt];
00021 VertexCand_y = new float[kMaxVrt];
00022 VertexCand_z = new float[kMaxVrt];
00023 VertexCand_tracks = new int[kMaxVrt];
00024 VertexCand_chi2 = new float[kMaxVrt];
00025 VertexCand_ndof = new float[kMaxVrt];
00026
00027 }
00028
00029 RECOVertex::~RECOVertex() {
00030
00031 }
00032
00033 void RECOVertex::clear()
00034 {
00035 NVrtx = 0;
00036 std::memset(VertexCand_x, '\0', kMaxVrt * sizeof(float));
00037 std::memset(VertexCand_y, '\0', kMaxVrt * sizeof(float));
00038 std::memset(VertexCand_z, '\0', kMaxVrt * sizeof(float));
00039 std::memset(VertexCand_tracks, '\0', kMaxVrt * sizeof(int));
00040 std::memset(VertexCand_chi2, '\0', kMaxVrt * sizeof(float));
00041 std::memset(VertexCand_ndof, '\0', kMaxVrt * sizeof(float));
00042 }
00043
00044
00045 void RECOVertex::setup(const edm::ParameterSet& pSet, TTree* HltTree, std::string vertexType) {
00046
00047 edm::ParameterSet myHltParams = pSet.getParameter<edm::ParameterSet>("RunParameters") ;
00048 std::vector<std::string> parameterNames = myHltParams.getParameterNames() ;
00049
00050 for ( std::vector<std::string>::iterator iParam = parameterNames.begin();
00051 iParam != parameterNames.end(); iParam++ ){
00052 if ( (*iParam) == "Debug" ) _Debug = myHltParams.getParameter<bool>( *iParam );
00053 }
00054
00055 TString br_recoNVrt = "recoNVrt";
00056 br_recoNVrt.Append(vertexType);
00057 HltTree->Branch(br_recoNVrt, & NVrtx, "NVrtx/I");
00058
00059 TString br_recoVrtX = "recoVrtX";
00060 br_recoVrtX.Append(vertexType);
00061 HltTree->Branch(br_recoVrtX, VertexCand_x, "recoVrtX[NVrtx]/F");
00062
00063 TString br_recoVrtY = "recoVrtY";
00064 br_recoVrtY.Append(vertexType);
00065 HltTree->Branch(br_recoVrtY, VertexCand_y, "recoVrtY[NVrtx]/F");
00066
00067 TString br_recoVrtZ = "recoVrtZ";
00068 br_recoVrtZ.Append(vertexType);
00069 HltTree->Branch(br_recoVrtZ, VertexCand_z, "recoVrtZ[NVrtx]/F");
00070
00071 TString br_recoVrtNtrk = "recoVrtNtrk";
00072 br_recoVrtNtrk.Append(vertexType);
00073 HltTree->Branch(br_recoVrtNtrk, VertexCand_tracks, "recoVrtNtrk[NVrtx]/I");
00074
00075 TString br_recoVrtChi2 = "recoVrtChi2";
00076 br_recoVrtChi2.Append(vertexType);
00077 HltTree->Branch(br_recoVrtChi2, VertexCand_chi2, "recoVrtChi2[NVrtx]/F");
00078
00079 TString br_recoVrtNdof = "recoVrtNdof";
00080 br_recoVrtNdof.Append(vertexType);
00081 HltTree->Branch(br_recoVrtNdof, VertexCand_ndof, "recoVrtNdof[NVrtx]/F");
00082
00083
00084
00085 }
00086
00087
00088 void RECOVertex::analyze(edm::Handle<reco::VertexCollection> recoVertexs, TTree* HltTree) {
00089
00090
00091 clear();
00092
00093 if ( recoVertexs.isValid() ) {
00094 const reco::VertexCollection* vertexs = recoVertexs.product();
00095 reco::VertexCollection::const_iterator vertex_i;
00096
00097 size_t size = std::min(kMaxVrt, size_t(vertexs->size()) );
00098 NVrtx= size;
00099
00100 int nVertexCand=0;
00101 if (_Debug) std::cout << "Found " << vertexs->size() << " vertices" << std::endl;
00102 for (vertex_i = vertexs->begin(); vertex_i != vertexs->end(); vertex_i++){
00103 if (nVertexCand>=NVrtx) break;
00104 VertexCand_x[nVertexCand] = vertex_i->x();
00105 VertexCand_y[nVertexCand] = vertex_i->y();
00106 VertexCand_z[nVertexCand] = vertex_i->z();
00107 VertexCand_tracks[nVertexCand] = vertex_i->tracksSize();
00108 VertexCand_chi2[nVertexCand] = vertex_i->chi2();
00109 VertexCand_ndof[nVertexCand] = vertex_i->ndof();
00110 if (_Debug) {
00111 std::cout << "RECOVertex -- VX, VY VZ = "
00112 << VertexCand_x[nVertexCand] << " "
00113 << VertexCand_y[nVertexCand] << " "
00114 << VertexCand_z[nVertexCand]
00115 << std::endl;
00116 std::cout << "RECOVertex -- Ntracks, Chi2/Dof = "
00117 << VertexCand_tracks[nVertexCand] << " "
00118 << VertexCand_chi2[nVertexCand] << " / " << VertexCand_ndof[nVertexCand]
00119 << std::endl;
00120 }
00121 nVertexCand++;
00122
00123 }
00124 }
00125 }
00126