00001 #include <map>
00002 #include <string>
00003 #include <cmath>
00004 #include <Math/Functions.h>
00005 #include <Math/SVector.h>
00006 #include <Math/SMatrix.h>
00007 #include "TH1F.h"
00008 #include "TH1D.h"
00009 #include "TH2D.h"
00010 #include "TMath.h"
00011 #include "DataFormats/BTauReco/interface/SecondaryVertexTagInfo.h"
00012
00013 #include "FWCore/Framework/interface/Frameworkfwd.h"
00014 #include "FWCore/Framework/interface/EDAnalyzer.h"
00015 #include "FWCore/Framework/interface/MakerMacros.h"
00016 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00017 #include "FWCore/ServiceRegistry/interface/Service.h"
00018 #include "DQMServices/Core/interface/DQMStore.h"
00019 #include "DQMServices/Core/interface/MonitorElement.h"
00020
00021 #include "SimTracker/TrackHistory/interface/VertexClassifierByProxy.h"
00022 #include "CommonTools/Statistics/interface/ChiSquaredProbability.h"
00023 #include "DataFormats/Math/interface/Vector.h"
00024 #include "TROOT.h"
00025 #include "Math/VectorUtil.h"
00026 #include <TVector3.h>
00027 #include <Math/GenVector/PxPyPzE4D.h>
00028 #include <Math/GenVector/PxPyPzM4D.h>
00029 #include "DataFormats/Math/interface/LorentzVector.h"
00030
00031
00032
00033 using namespace reco;
00034 using namespace std;
00035 using namespace edm;
00036
00037 class recoBSVTagInfoValidationAnalyzer : public edm::EDAnalyzer
00038 {
00039
00040 public:
00041
00042 explicit recoBSVTagInfoValidationAnalyzer(const edm::ParameterSet&);
00043
00044 private:
00045
00046 virtual void analyze(const edm::Event&, const edm::EventSetup&);
00047 virtual void endJob() ;
00048
00049
00050 VertexClassifierByProxy<reco::SecondaryVertexTagInfoCollection> classifier_;
00051
00052 Int_t numberVertexClassifier_;
00053 edm::InputTag trackingTruth_;
00054 edm::InputTag svTagInfoProducer_;
00055
00056 DQMStore * dqmStore_;
00057 std::string dqmLabel;
00058
00059 Int_t n_event;
00060 Int_t rs_total_nall ;
00061 Int_t rs_total_nsv ;
00062 Int_t rs_total_nbv ;
00063 Int_t rs_total_nbsv ;
00064 Int_t rs_total_ncv ;
00065 Int_t rs_total_nlv ;
00066 Int_t total_nfake ;
00067
00068 Int_t sr_total_nall ;
00069 Int_t sr_total_nsv ;
00070 Int_t sr_total_nbv ;
00071 Int_t sr_total_nbsv ;
00072 Int_t sr_total_ncv ;
00073 Int_t sr_total_nlv ;
00074 Int_t total_nmiss ;
00075
00076
00077
00078 void bookRecoToSim(std::string const &);
00079 void bookSimToReco(std::string const &);
00080
00081
00082 void fillRecoToSim(std::string const &, reco::Vertex const &, TrackingVertexRef const &);
00083 void fillSimToReco(std::string const &, reco::VertexBaseRef const &, TrackingVertexRef const &);
00084
00085
00086 std::map<std::string, MonitorElement *> HistIndex_;
00087
00088 };
00089
00090
00091 recoBSVTagInfoValidationAnalyzer::recoBSVTagInfoValidationAnalyzer(const edm::ParameterSet& config) : classifier_(config)
00092 {
00093
00094 n_event = 0;
00095 rs_total_nall = 0;
00096 rs_total_nsv = 0;
00097 rs_total_nbv = 0;
00098 rs_total_nbsv = 0;
00099 rs_total_ncv = 0;
00100 rs_total_nlv = 0;
00101 total_nfake = 0;
00102
00103 sr_total_nall = 0;
00104 sr_total_nsv = 0;
00105 sr_total_nbv = 0;
00106 sr_total_nbsv = 0;
00107 sr_total_ncv = 0;
00108 sr_total_nlv = 0;
00109 total_nmiss = 0;
00110
00111
00112 dqmStore_ = edm::Service<DQMStore>().operator->();
00113 dqmLabel = "SVValidation/";
00114 dqmStore_->setCurrentFolder(dqmLabel);
00115
00116
00117
00118 svTagInfoProducer_ = config.getUntrackedParameter<edm::InputTag> ( "svTagInfoProducer" );
00119
00120
00121 trackingTruth_ = config.getUntrackedParameter<edm::InputTag> ( "trackingTruth" );
00122
00123
00124 numberVertexClassifier_ = VertexCategories::Unknown+1;
00125
00126
00127 HistIndex_["VertexClassifier"] = dqmStore_->book1D(
00128 "VertexClassifier",
00129 "Frequency for the different track categories",
00130 numberVertexClassifier_,
00131 -0.5,
00132 numberVertexClassifier_ - 0.5
00133 );
00134
00135
00136 HistIndex_["rs_All_MatchQuality"]= dqmStore_->book1D( "rs_All_MatchQuality", "Quality of Match", 51, -0.01, 1.01 );
00137 HistIndex_["rs_All_FlightDistance2d"]= dqmStore_->book1D( "rs_All_FlightDistance2d", "Transverse flight distance [cm]", 100, 0, 5 );
00138 HistIndex_["rs_SecondaryVertex_FlightDistance2d"]= dqmStore_->book1D( "rs_SecondaryVertex_FlightDistance2d", "Transverse flight distance [cm]", 100, 0, 5 );
00139 HistIndex_["rs_BSV_FlightDistance2d"]= dqmStore_->book1D( "rs_BSV_FlightDistance2d", "Transverse flight distance [cm]", 100, 0, 5 );
00140 HistIndex_["rs_BWeakDecay_FlightDistance2d"]= dqmStore_->book1D( "rs_BWeakDecay_FlightDistance2d", "Transverse flight distance [cm]", 100, 0, 5 );
00141 HistIndex_["rs_CWeakDecay_FlightDistance2d"]= dqmStore_->book1D( "rs_CWeakDecay_FlightDistance2d", "Transverse flight distance [cm]", 100, 0, 5 );
00142 HistIndex_["rs_Light_FlightDistance2d"]= dqmStore_->book1D( "rs_Light_FlightDistance2d", "Transverse flight distance [cm]", 100, 0, 5 );
00143
00144 HistIndex_["rs_All_nRecVtx"]= dqmStore_->book1D( "rs_All_nRecVtx", "Number of Vertices per event", 11, -0.5, 10.5 );
00145 HistIndex_["rs_SecondaryVertex_nRecVtx"]= dqmStore_->book1D( "rs_SecondaryVertex_nRecVtx", "Number of Vertices per event", 11, -0.5, 10.5 );
00146 HistIndex_["rs_BSV_nRecVtx"]= dqmStore_->book1D( "rs_BSV_nRecVtx", "Number of Vertices per event", 11, -0.5, 10.5 );
00147 HistIndex_["rs_BWeakDecay_nRecVtx"]= dqmStore_->book1D( "rs_BWeakDecay_nRecVtx", "Number of Vertices per event", 11, -0.5, 10.5 );
00148 HistIndex_["rs_CWeakDecay_nRecVtx"]= dqmStore_->book1D( "rs_CWeakDecay_nRecVtx", "Number of Vertices per event", 11, -0.5, 10.5 );
00149 HistIndex_["rs_Light_nRecVtx"]= dqmStore_->book1D( "rs_Light_nRecVtx", "Number of Vertices per event", 11, -0.5, 10.5 );
00150
00151
00152
00153 HistIndex_["sr_All_MatchQuality"]= dqmStore_->book1D( "sr_All_MatchQuality", "Quality of Match", 51, -0.01, 1.01 );
00154 HistIndex_["sr_All_nRecVtx"]= dqmStore_->book1D( "sr_All_nRecVtx", "Number of Vertices per event", 11, -0.5, 10.5 );
00155 HistIndex_["sr_SecondaryVertex_nRecVtx"]= dqmStore_->book1D( "sr_SecondaryVertex_nRecVtx", "Number of Vertices per event", 11, -0.5, 10.5 );
00156 HistIndex_["sr_BSV_nRecVtx"]= dqmStore_->book1D( "sr_BSV_nRecVtx", "Number of Vertices per event", 11, -0.5, 10.5 );
00157 HistIndex_["sr_BWeakDecay_nRecVtx"]= dqmStore_->book1D( "sr_BWeakDecay_nRecVtx", "Number of Vertices per event", 11, -0.5, 10.5 );
00158 HistIndex_["sr_CWeakDecay_nRecVtx"]= dqmStore_->book1D( "sr_CWeakDecay_nRecVtx", "Number of Vertices per event", 11, -0.5, 10.5 );
00159 HistIndex_["sr_Light_nRecVtx"]= dqmStore_->book1D( "sr_Light_nRecVtx", "Number of Vertices per event", 11, -0.5, 10.5 );
00160
00161
00162
00163 for (Int_t i = 0; i < numberVertexClassifier_; ++i)
00164 HistIndex_["VertexClassifier"]->getTH1F()->GetXaxis()->SetBinLabel(i+1, VertexCategories::Names[i]);
00165
00166
00167 bookRecoToSim("rs_All");
00168 bookRecoToSim("rs_SecondaryVertex");
00169 bookRecoToSim("rs_BSV");
00170 bookRecoToSim("rs_BWeakDecay");
00171 bookRecoToSim("rs_CWeakDecay");
00172 bookRecoToSim("rs_Light");
00173
00174 bookSimToReco("sr_All");
00175 bookSimToReco("sr_SecondaryVertex");
00176 bookSimToReco("sr_BSV");
00177 bookSimToReco("sr_BWeakDecay");
00178 bookSimToReco("sr_CWeakDecay");
00179 bookSimToReco("sr_Light");
00180 }
00181
00182
00183 void recoBSVTagInfoValidationAnalyzer::analyze(const edm::Event& event, const edm::EventSetup& setup)
00184 {
00185 ++n_event;
00186
00187 std::cout << "*** Analyzing " << event.id() << " n_event = " << n_event << std::endl << std::endl;
00188
00189
00190 classifier_.newEvent(event, setup);
00191
00192
00193
00194 edm::Handle<reco::SecondaryVertexTagInfoCollection> svTagInfoCollection;
00195 event.getByLabel(svTagInfoProducer_, svTagInfoCollection);
00196
00197
00198 VertexHistory const & tracer = classifier_.history();
00199
00200 cout << "* Event " << n_event << " ; svTagInfoCollection->size() = " << svTagInfoCollection->size() << endl;
00201
00202 int rs_nall = 0;
00203 int rs_nsv = 0;
00204 int rs_nbv = 0;
00205 int rs_nbsv = 0;
00206 int rs_ncv = 0;
00207 int rs_nlv = 0;
00208 int nfake = 0;
00209
00210 int sr_nall = 0;
00211 int sr_nsv = 0;
00212 int sr_nbv = 0;
00213 int sr_nbsv = 0;
00214 int sr_ncv = 0;
00215 int sr_nlv = 0;
00216 int nmiss = 0;
00217
00218
00219 for (std::size_t index = 0; index < svTagInfoCollection->size(); ++index){
00220
00221 reco::SecondaryVertexTagInfoRef svTagInfo(svTagInfoCollection, index);
00222
00223
00224 for ( std::size_t vindex = 0; vindex < svTagInfo->nVertices(); ++vindex ){
00225
00226
00227
00228 classifier_.evaluate(svTagInfo, vindex);
00229
00230
00231 double rs_quality = tracer.quality();
00232
00233
00234 for (Int_t i = 0; i != numberVertexClassifier_; ++i) {
00235
00236 if ( classifier_.is( (VertexCategories::Category) i ) ) {
00237
00238 HistIndex_["VertexClassifier"]->Fill(i);
00239 }
00240 }
00241 if ( !classifier_.is(VertexCategories::Fake) ) {
00242
00243 HistIndex_["rs_All_MatchQuality"]->Fill( rs_quality );
00244 fillRecoToSim("rs_All", svTagInfo->secondaryVertex(vindex), tracer.simVertex());
00245 HistIndex_["rs_All_FlightDistance2d"]->Fill( svTagInfo->flightDistance( vindex, true ).value() );
00246 rs_nall++;
00247
00248 if ( classifier_.is(VertexCategories::SecondaryVertex) ) {
00249
00250 fillRecoToSim("rs_SecondaryVertex", svTagInfo->secondaryVertex(vindex), tracer.simVertex());
00251 HistIndex_["rs_SecondaryVertex_FlightDistance2d"]->Fill( svTagInfo->flightDistance( vindex, true ).value() );
00252 rs_nsv++;
00253 }
00254
00255 if ( classifier_.is(VertexCategories::BWeakDecay) ) {
00256
00257 fillRecoToSim("rs_BWeakDecay", svTagInfo->secondaryVertex(vindex), tracer.simVertex());
00258 HistIndex_["rs_BWeakDecay_FlightDistance2d"]->Fill( svTagInfo->flightDistance( vindex, true ).value() );
00259 rs_nbv++;
00260
00261 if ( classifier_.is(VertexCategories::SecondaryVertex) ) {
00262
00263 fillRecoToSim("rs_BSV", svTagInfo->secondaryVertex(vindex), tracer.simVertex());
00264 HistIndex_["rs_BSV_FlightDistance2d"]->Fill( svTagInfo->flightDistance( vindex, true ).value() );
00265 rs_nbsv++;
00266
00267 }
00268 }
00269
00270 else if ( classifier_.is(VertexCategories::CWeakDecay) ) {
00271
00272 fillRecoToSim("rs_CWeakDecay", svTagInfo->secondaryVertex(vindex), tracer.simVertex());
00273 HistIndex_["rs_CWeakDecay_FlightDistance2d"]->Fill( svTagInfo->flightDistance( vindex, true ).value() );
00274 rs_ncv++;
00275
00276 }
00277 else {
00278
00279 fillRecoToSim("rs_Light", svTagInfo->secondaryVertex(vindex), tracer.simVertex());
00280 HistIndex_["rs_Light_FlightDistance2d"]->Fill( svTagInfo->flightDistance( vindex, true ).value() );
00281 rs_nlv++;
00282 }
00283 }
00284
00285 else {
00286 cout << " VertexCategories::Fake!!" << endl;
00287 nfake++;
00288 }
00289
00290
00291 }
00292
00293 }
00294
00295 HistIndex_["rs_All_nRecVtx"]->Fill( rs_nall );
00296 HistIndex_["rs_SecondaryVertex_nRecVtx"]->Fill( rs_nsv );
00297 HistIndex_["rs_BWeakDecay_nRecVtx"]->Fill( rs_nbv );
00298 HistIndex_["rs_BSV_nRecVtx"]->Fill( rs_nbsv );
00299 HistIndex_["rs_CWeakDecay_nRecVtx"]->Fill( rs_ncv );
00300 HistIndex_["rs_Light_nRecVtx"]->Fill( rs_nlv );
00301 cout << endl;
00302
00303
00304
00305
00306
00307 edm::Handle<TrackingVertexCollection> TVCollection;
00308 event.getByLabel(trackingTruth_, TVCollection);
00309
00310
00311 for (std::size_t index = 0; index < TVCollection->size(); ++index){
00312
00313 TrackingVertexRef trackingVertex(TVCollection, index);
00314
00315 classifier_.evaluate(trackingVertex);
00316
00317 double sr_quality = tracer.quality();
00318
00319 if ( classifier_.is(VertexCategories::Reconstructed) ) {
00320
00321 HistIndex_["sr_All_MatchQuality"]->Fill( sr_quality );
00322 fillSimToReco("sr_All", tracer.recoVertex(), trackingVertex);
00323 sr_nall++;
00324
00325 if ( classifier_.is(VertexCategories::SecondaryVertex) ) {
00326
00327 fillSimToReco("sr_SecondaryVertex", tracer.recoVertex(), trackingVertex);
00328 sr_nsv++;
00329 }
00330
00331 if ( classifier_.is(VertexCategories::BWeakDecay) ) {
00332
00333 fillSimToReco("sr_BWeakDecay", tracer.recoVertex(), trackingVertex);
00334 sr_nbv++;
00335
00336 if ( classifier_.is(VertexCategories::SecondaryVertex) ) {
00337
00338 fillSimToReco("sr_BSV", tracer.recoVertex(), trackingVertex);
00339 sr_nbsv++;
00340 }
00341
00342 }
00343
00344 else if ( classifier_.is(VertexCategories::CWeakDecay) ) {
00345
00346 fillSimToReco("sr_CWeakDecay", tracer.recoVertex(), trackingVertex);
00347 sr_ncv++;
00348 }
00349
00350 else {
00351
00352 fillSimToReco("sr_Light", tracer.recoVertex(), trackingVertex);
00353 sr_nlv++;
00354 }
00355
00356 }
00357 else {
00358
00359 nmiss++;
00360 }
00361
00362 }
00363
00364 HistIndex_["sr_All_nRecVtx"]->Fill( sr_nall );
00365 HistIndex_["sr_SecondaryVertex_nRecVtx"]->Fill( sr_nsv );
00366 HistIndex_["sr_BWeakDecay_nRecVtx"]->Fill( sr_nbv );
00367 HistIndex_["sr_BSV_nRecVtx"]->Fill( sr_nbsv );
00368 HistIndex_["sr_CWeakDecay_nRecVtx"]->Fill( sr_ncv );
00369 HistIndex_["sr_Light_nRecVtx"]->Fill( rs_nlv );
00370
00371 rs_total_nall += rs_nall;
00372 rs_total_nsv += rs_nsv;
00373 rs_total_nbv += rs_nbv;
00374 rs_total_nbsv += rs_nbsv;
00375 rs_total_ncv += rs_ncv ;
00376 rs_total_nlv += rs_nlv;
00377 total_nfake += nfake;
00378
00379 sr_total_nall += sr_nall;
00380 sr_total_nsv += sr_nsv;
00381 sr_total_nbv += sr_nbv;
00382 sr_total_nbsv += sr_nbsv;
00383 sr_total_ncv += sr_ncv;
00384 sr_total_nlv += sr_nlv;
00385 total_nmiss += nmiss;
00386
00387
00388 }
00389
00390
00391 void recoBSVTagInfoValidationAnalyzer::bookRecoToSim(std::string const & prefix){
00392
00393
00394 std::string name = prefix + "_Pullx";
00395 HistIndex_[name] = dqmStore_->book1D(name.c_str(), name.c_str(), 100, -10., 10.);
00396 name = prefix + "_Pully";
00397 HistIndex_[name] = dqmStore_->book1D(name.c_str(), name.c_str(), 100, -10., 10.);
00398 name = prefix + "_Pullz";
00399 HistIndex_[name] = dqmStore_->book1D(name.c_str(), name.c_str(), 100, -10., 10.);
00400
00401 name = prefix + "_Resx";
00402 HistIndex_[name] = dqmStore_->book1D(name.c_str(), name.c_str(), 100, -0.05, 0.05);
00403 name = prefix + "_Resy";
00404 HistIndex_[name] = dqmStore_->book1D(name.c_str(), name.c_str(), 100, -0.05, 0.05);
00405 name = prefix + "_Resz";
00406 HistIndex_[name] = dqmStore_->book1D(name.c_str(), name.c_str(), 100, -0.05, 0.05);
00407
00408 name = prefix + "_Chi2Norm";
00409 HistIndex_[name] = dqmStore_->book1D(name.c_str(), name.c_str(), 100, 0, 10.);
00410 name = prefix + "_Chi2Prob";
00411 HistIndex_[name] = dqmStore_->book1D(name.c_str(), name.c_str(), 100, 0., 1.);
00412
00413 name = prefix + "_nRecTrks";
00414 HistIndex_[name] = dqmStore_->book1D(name.c_str(), name.c_str(), 501, -0.5, 500.5);
00415
00416 name = prefix + "_AverageTrackWeight";
00417 HistIndex_[name] = dqmStore_->book1D(name.c_str(), name.c_str(), 100, -0.1, 1.1);
00418
00419 name = prefix + "_Mass";
00420 HistIndex_[name] = dqmStore_->book1D(name.c_str(), name.c_str(), 65, 0., 6.5);
00421
00422 name = prefix + "_RecPt";
00423 HistIndex_[name] = dqmStore_->book1D(name.c_str(), name.c_str(), 2000, 0., 1000.);
00424
00425 name = prefix + "_RecEta";
00426 HistIndex_[name] = dqmStore_->book1D(name.c_str(), name.c_str(), 200, -3., 3.);
00427
00428 name = prefix + "_RecCharge";
00429 HistIndex_[name] = dqmStore_->book1D(name.c_str(), name.c_str(), 21, -0.5, 20.5);
00430
00431 name = prefix + "_RecTrackPt";
00432 HistIndex_[name] = dqmStore_->book1D(name.c_str(), name.c_str(), 2000, 0., 1000.);
00433
00434 name = prefix + "_RecTrackEta";
00435 HistIndex_[name] = dqmStore_->book1D(name.c_str(), name.c_str(), 200, -3., 3.);
00436
00437 name = prefix + "_nSimTrks";
00438 HistIndex_[name] = dqmStore_->book1D(name.c_str(), name.c_str(), 501, -0.5, 500.5);
00439
00440 name = prefix + "_SimPt";
00441 HistIndex_[name] = dqmStore_->book1D(name.c_str(), name.c_str(), 2000, 0., 1000.);
00442
00443 name = prefix + "_SimEta";
00444 HistIndex_[name] = dqmStore_->book1D(name.c_str(), name.c_str(), 200, -3., 3.);
00445
00446 name = prefix + "_SimCharge";
00447 HistIndex_[name] = dqmStore_->book1D(name.c_str(), name.c_str(), 21, -0.5, 20.5);
00448
00449 name = prefix + "_SimTrackPt";
00450 HistIndex_[name] = dqmStore_->book1D(name.c_str(), name.c_str(), 500, 0., 500.);
00451
00452 name = prefix + "_SimTrackEta";
00453 HistIndex_[name] = dqmStore_->book1D(name.c_str(), name.c_str(), 200, -3., 3.);
00454
00455
00456 }
00457
00458
00459 void recoBSVTagInfoValidationAnalyzer::bookSimToReco(std::string const & prefix){
00460
00461
00462 std::string name = prefix + "_Pullx";
00463 HistIndex_[name] = dqmStore_->book1D(name.c_str(), name.c_str(), 100, -10., 10.);
00464 name = prefix + "_Pully";
00465 HistIndex_[name] = dqmStore_->book1D(name.c_str(), name.c_str(), 100, -10., 10.);
00466 name = prefix + "_Pullz";
00467 HistIndex_[name] = dqmStore_->book1D(name.c_str(), name.c_str(), 100, -10., 10.);
00468
00469 name = prefix + "_Resx";
00470 HistIndex_[name] = dqmStore_->book1D(name.c_str(), name.c_str(), 100, -0.05, 0.05);
00471 name = prefix + "_Resy";
00472 HistIndex_[name] = dqmStore_->book1D(name.c_str(), name.c_str(), 100, -0.05, 0.05);
00473 name = prefix + "_Resz";
00474 HistIndex_[name] = dqmStore_->book1D(name.c_str(), name.c_str(), 100, -0.05, 0.05);
00475
00476 name = prefix + "_Chi2Norm";
00477 HistIndex_[name] = dqmStore_->book1D(name.c_str(), name.c_str(), 100, 0, 10.);
00478 name = prefix + "_Chi2Prob";
00479 HistIndex_[name] = dqmStore_->book1D(name.c_str(), name.c_str(), 100, 0., 1.);
00480
00481 name = prefix + "_nRecTrks";
00482 HistIndex_[name] = dqmStore_->book1D(name.c_str(), name.c_str(), 501, -0.5, 500.5);
00483
00484 name = prefix + "_AverageTrackWeight";
00485 HistIndex_[name] = dqmStore_->book1D(name.c_str(), name.c_str(), 100, -0.1, 1.1);
00486
00487 name = prefix + "_Mass";
00488 HistIndex_[name] = dqmStore_->book1D(name.c_str(), name.c_str(), 65, 0., 6.5);
00489
00490 name = prefix + "_RecPt";
00491 HistIndex_[name] = dqmStore_->book1D(name.c_str(), name.c_str(), 2000, 0., 1000.);
00492
00493 name = prefix + "_RecEta";
00494 HistIndex_[name] = dqmStore_->book1D(name.c_str(), name.c_str(), 200, -3., 3.);
00495
00496 name = prefix + "_RecCharge";
00497 HistIndex_[name] = dqmStore_->book1D(name.c_str(), name.c_str(), 21, -0.5, 20.5);
00498
00499 name = prefix + "_RecTrackPt";
00500 HistIndex_[name] = dqmStore_->book1D(name.c_str(), name.c_str(), 2000, 0., 1000.);
00501
00502 name = prefix + "_RecTrackEta";
00503 HistIndex_[name] = dqmStore_->book1D(name.c_str(), name.c_str(), 200, -3., 3.);
00504
00505 name = prefix + "_nSimTrks";
00506 HistIndex_[name] = dqmStore_->book1D(name.c_str(), name.c_str(), 501, -0.5, 500.5);
00507
00508 name = prefix + "_SimPt";
00509 HistIndex_[name] = dqmStore_->book1D(name.c_str(), name.c_str(), 2000, 0., 1000.);
00510
00511 name = prefix + "_SimEta";
00512 HistIndex_[name] = dqmStore_->book1D(name.c_str(), name.c_str(), 200, -3., 3.);
00513
00514 name = prefix + "_SimCharge";
00515 HistIndex_[name] = dqmStore_->book1D(name.c_str(), name.c_str(), 21, -0.5, 20.5);
00516
00517 name = prefix + "_SimTrackPt";
00518 HistIndex_[name] = dqmStore_->book1D(name.c_str(), name.c_str(), 500, 0., 500.);
00519
00520 name = prefix + "_SimTrackEta";
00521 HistIndex_[name] = dqmStore_->book1D(name.c_str(), name.c_str(), 200, -3., 3.);
00522
00523
00524 }
00525
00526
00527 void recoBSVTagInfoValidationAnalyzer::fillRecoToSim(std::string const & prefix, reco::Vertex const & vertex, TrackingVertexRef const & simVertex)
00528 {
00529
00530 double pullx = (vertex.x() - simVertex->position().x())/vertex.xError();
00531 double pully = (vertex.y() - simVertex->position().y())/vertex.yError();
00532 double pullz = (vertex.z() - simVertex->position().z())/vertex.zError();
00533
00534 double resx = vertex.x() - simVertex->position().x();
00535 double resy = vertex.y() - simVertex->position().y();
00536 double resz = vertex.z() - simVertex->position().z();
00537
00538 double chi2norm = vertex.normalizedChi2();
00539 double chi2prob = ChiSquaredProbability( vertex.chi2(), vertex.ndof() );
00540
00541 double sum_weight = 0.;
00542 double weight = 0.;
00543 double tracksize = vertex.tracksSize();
00544 math::XYZVector momentum;
00545 math::XYZTLorentzVector sum;
00546 int charge = 0;
00547 double thePiMass = 0.13957;
00548 for ( reco::Vertex::trackRef_iterator recDaughter = vertex.tracks_begin() ; recDaughter != vertex.tracks_end(); ++recDaughter) {
00549
00550 ROOT::Math::LorentzVector<ROOT::Math::PxPyPzM4D<double> > vec;
00551
00552 vec.SetPx( (**recDaughter).px() );
00553 vec.SetPy( (**recDaughter).py() );
00554 vec.SetPz( (**recDaughter).pz() );
00555 vec.SetM(thePiMass);
00556
00557 sum += vec;
00558
00559 weight = vertex.trackWeight(*recDaughter);
00560 sum_weight += weight;
00561
00562 math::XYZVector p;
00563 p = (**recDaughter).momentum();
00564 momentum += p;
00565
00566 charge += (*recDaughter)->charge();
00567
00568 HistIndex_[prefix + "_RecTrackPt"]->Fill( (*recDaughter)->pt() );
00569 HistIndex_[prefix + "_RecTrackEta"]->Fill( (*recDaughter)->eta() );
00570 }
00571
00572
00573 double mass = sum.M();
00574 double pt = sqrt( momentum.Perp2() );
00575 double eta = momentum.Eta();
00576
00577 math::XYZVector simmomentum;
00578 int simcharge = 0;
00579 for ( TrackingVertex::tp_iterator simDaughter = simVertex->daughterTracks_begin(); simDaughter != simVertex->daughterTracks_end(); ++simDaughter ){
00580
00581 math::XYZVector p;
00582 p = (**simDaughter).momentum();
00583 simmomentum += p;
00584
00585 simcharge += (*simDaughter)->charge();
00586
00587 HistIndex_[prefix + "_SimTrackPt"]->Fill( (*simDaughter)->pt() );
00588 HistIndex_[prefix + "_SimTrackEta"]->Fill( (*simDaughter)->eta() );
00589 }
00590
00591 double simpt = sqrt( simmomentum.Perp2() );
00592 double simeta = simmomentum.Eta();
00593
00594
00595
00596 HistIndex_[prefix + "_nRecTrks"]->Fill( vertex.tracksSize() );
00597 HistIndex_[prefix + "_nSimTrks"]->Fill( simVertex->nDaughterTracks() );
00598 HistIndex_[prefix + "_Pullx"]->Fill(pullx);
00599 HistIndex_[prefix + "_Pully"]->Fill(pully);
00600 HistIndex_[prefix + "_Pullz"]->Fill(pullz);
00601 HistIndex_[prefix + "_Resx"]->Fill(resx);
00602 HistIndex_[prefix + "_Resy"]->Fill(resy);
00603 HistIndex_[prefix + "_Resz"]->Fill(resz);
00604 HistIndex_[prefix + "_AverageTrackWeight"]->Fill( sum_weight/tracksize );
00605 HistIndex_[prefix + "_Chi2Norm"]->Fill(chi2norm);
00606 HistIndex_[prefix + "_Chi2Prob"]->Fill(chi2prob);
00607 HistIndex_[prefix + "_RecPt"]->Fill(pt);
00608 HistIndex_[prefix + "_RecEta"]->Fill(eta);
00609 HistIndex_[prefix + "_RecCharge"]->Fill(charge);
00610 HistIndex_[prefix + "_Mass"]->Fill(mass);
00611 HistIndex_[prefix + "_SimPt"]->Fill(simpt);
00612 HistIndex_[prefix + "_SimEta"]->Fill(simeta);
00613 HistIndex_[prefix + "_SimCharge"]->Fill(simcharge);
00614 }
00615
00616
00617 void recoBSVTagInfoValidationAnalyzer::fillSimToReco(std::string const & prefix, reco::VertexBaseRef const & vertex, TrackingVertexRef const & simVertex)
00618 {
00619
00620 double pullx = (vertex->x() - simVertex->position().x())/vertex->xError();
00621 double pully = (vertex->y() - simVertex->position().y())/vertex->yError();
00622 double pullz = (vertex->z() - simVertex->position().z())/vertex->zError();
00623
00624 double resx = vertex->x() - simVertex->position().x();
00625 double resy = vertex->y() - simVertex->position().y();
00626 double resz = vertex->z() - simVertex->position().z();
00627
00628 double chi2norm = vertex->normalizedChi2();
00629 double chi2prob = ChiSquaredProbability(vertex->chi2(), vertex->ndof());
00630
00631 double sum_weight = 0.;
00632 double weight = 0.;
00633 double tracksize = vertex->tracksSize();
00634 math::XYZVector momentum;
00635 math::XYZTLorentzVector sum;
00636 int charge = 0;
00637 double thePiMass = 0.13957;
00638 for ( reco::Vertex::trackRef_iterator recDaughter = vertex->tracks_begin() ; recDaughter != vertex->tracks_end(); ++recDaughter ) {
00639
00640 ROOT::Math::LorentzVector<ROOT::Math::PxPyPzM4D<double> > vec;
00641
00642 vec.SetPx( (**recDaughter).px() );
00643 vec.SetPy( (**recDaughter).py() );
00644 vec.SetPz( (**recDaughter).pz() );
00645 vec.SetM(thePiMass);
00646
00647 sum += vec;
00648
00649 weight = vertex->trackWeight(*recDaughter);
00650 sum_weight += weight;
00651
00652 math::XYZVector p;
00653 p = (**recDaughter).momentum();
00654 momentum += p;
00655
00656 charge += (*recDaughter)->charge();
00657
00658 HistIndex_[prefix + "_RecTrackPt"]->Fill( (*recDaughter)->pt() );
00659 HistIndex_[prefix + "_RecTrackEta"]->Fill( (*recDaughter)->eta() );
00660
00661 }
00662
00663
00664 double mass = sum.M();
00665 double pt = sqrt( momentum.Perp2() );
00666 double eta = momentum.Eta();
00667
00668 math::XYZVector simmomentum;
00669 int simcharge = 0;
00670 for ( TrackingVertex::tp_iterator simDaughter = simVertex->daughterTracks_begin(); simDaughter != simVertex->daughterTracks_end(); ++simDaughter ){
00671
00672 math::XYZVector p;
00673 p = (**simDaughter).momentum();
00674 simmomentum += p;
00675
00676 simcharge += (*simDaughter)->charge();
00677
00678 HistIndex_[prefix + "_SimTrackPt"]->Fill( (*simDaughter)->pt() );
00679 HistIndex_[prefix + "_SimTrackEta"]->Fill( (*simDaughter)->eta() );
00680 }
00681
00682 double simpt = sqrt( simmomentum.Perp2() );
00683 double simeta = simmomentum.Eta();
00684
00685
00686
00687 HistIndex_[prefix + "_nRecTrks"]->Fill( vertex->tracksSize() );
00688 HistIndex_[prefix + "_nSimTrks"]->Fill( simVertex->nDaughterTracks() );
00689 HistIndex_[prefix + "_Pullx"]->Fill(pullx);
00690 HistIndex_[prefix + "_Pully"]->Fill(pully);
00691 HistIndex_[prefix + "_Pullz"]->Fill(pullz);
00692 HistIndex_[prefix + "_Resx"]->Fill(resx);
00693 HistIndex_[prefix + "_Resy"]->Fill(resy);
00694 HistIndex_[prefix + "_Resz"]->Fill(resz);
00695 HistIndex_[prefix + "_AverageTrackWeight"]->Fill( sum_weight/tracksize );
00696 HistIndex_[prefix + "_Chi2Norm"]->Fill(chi2norm);
00697 HistIndex_[prefix + "_Chi2Prob"]->Fill(chi2prob);
00698 HistIndex_[prefix + "_RecPt"]->Fill(pt);
00699 HistIndex_[prefix + "_RecEta"]->Fill(eta);
00700 HistIndex_[prefix + "_RecCharge"]->Fill(charge);
00701 HistIndex_[prefix + "_Mass"]->Fill(mass);
00702 HistIndex_[prefix + "_SimPt"]->Fill(simpt);
00703 HistIndex_[prefix + "_SimEta"]->Fill(simeta);
00704 HistIndex_[prefix + "_SimCharge"]->Fill(simcharge);
00705
00706 }
00707
00708
00709 void
00710 recoBSVTagInfoValidationAnalyzer::endJob() {
00711
00712 std::cout << std::endl;
00713 std::cout << " ====== Total Number of analyzed events: " << n_event << " ====== " << std::endl;
00714 std::cout << " ====== Total Number of R2S All: " << rs_total_nall << " ====== " << std::endl;
00715 std::cout << " ====== Total Number of R2S SecondaryVertex: " << rs_total_nsv << " ====== " << std::endl;
00716 std::cout << " ====== Total Number of R2S BWeakDecay: " << rs_total_nbv << " ====== " << std::endl;
00717 std::cout << " ====== Total Number of R2S BWeakDecay::SecondaryVertex: " << rs_total_nbsv << " ====== " << std::endl;
00718 std::cout << " ====== Total Number of R2S CWeakDecay: " << rs_total_ncv << " ====== " << std::endl;
00719 std::cout << " ====== Total Number of R2S Light: " << rs_total_nlv << " ====== " << std::endl;
00720 std::cout << std::endl;
00721 std::cout << " ====== Total Number of S2R All: " << sr_total_nall << " ====== " << std::endl;
00722 std::cout << " ====== Total Number of S2R SecondaryVertex: " << sr_total_nsv << " ====== " << std::endl;
00723 std::cout << " ====== Total Number of S2R BWeakDecay: " << sr_total_nbv << " ====== " << std::endl;
00724 std::cout << " ====== Total Number of S2R BWeakDecay::SecondaryVertex: " << sr_total_nbsv << " ====== " << std::endl;
00725 std::cout << " ====== Total Number of S2R CWeakDecay: " << sr_total_ncv << " ====== " << std::endl;
00726 std::cout << " ====== Total Number of S2R Light: " << sr_total_nlv << " ====== " << std::endl;
00727 std::cout << std::endl;
00728 std::cout << " ====== Total Number of Fake Vertices: " << total_nfake << " ====== " << std::endl;
00729
00730 }
00731
00732 DEFINE_FWK_MODULE(recoBSVTagInfoValidationAnalyzer);