Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-02-08 06:28:10

0001 // -*- C++ -*-
0002 //
0003 // Package:    TrackProbabilityXMLtoDB
0004 // Class:      TrackProbabilityXMLtoDB
0005 //
0006 /**\class TrackProbabilityXMLtoDB TrackProbabilityXMLtoDB.cc RecoBTag/TrackProbabilityXMLtoDB/src/TrackProbabilityXMLtoDB.cc
0007 
0008  Description: <one line class summary>
0009 
0010  Implementation:
0011      <Notes on implementation>
0012 */
0013 //
0014 // Original Author:  Andrea Rizzi
0015 //         Created:  Wed Apr 12 11:12:49 CEST 2006
0016 //
0017 //
0018 
0019 // system include files
0020 #include <memory>
0021 #include <string>
0022 #include <iostream>
0023 using namespace std;
0024 
0025 // user include files
0026 #include "FWCore/Framework/interface/Frameworkfwd.h"
0027 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0028 #include "FWCore/Framework/interface/Event.h"
0029 #include "FWCore/Framework/interface/MakerMacros.h"
0030 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0031 #include "FWCore/Utilities/interface/InputTag.h"
0032 
0033 #include "DataFormats/Math/interface/Vector3D.h"
0034 #include "DataFormats/Common/interface/Ref.h"
0035 #include "DataFormats/JetReco/interface/Jet.h"
0036 #include "DataFormats/JetReco/interface/CaloJet.h"
0037 #include "DataFormats/JetReco/interface/JetTracksAssociation.h"
0038 #include "DataFormats/TrackReco/interface/Track.h"
0039 
0040 //#include "RecoBTag/TrackProbability/interface/TrackClassFilterCategory.h"
0041 
0042 #include "TrackingTools/Records/interface/TransientTrackRecord.h"
0043 #include "TrackingTools/TransientTrack/interface/TransientTrackBuilder.h"
0044 //#include "TrackProbabilityCalibratedHistogram.h"
0045 
0046 #include "RecoBTag/BTagTools/interface/SignedTransverseImpactParameter.h"
0047 #include "RecoBTag/BTagTools/interface/SignedImpactParameter3D.h"
0048 #include "RecoBTag/BTagTools/interface/SignedDecayLength3D.h"
0049 
0050 //CondFormats
0051 #include "CondFormats/BTauObjects/interface/TrackProbabilityCalibration.h"
0052 
0053 #include "FWCore/Framework/interface/IOVSyncValue.h"
0054 #include "FWCore/ServiceRegistry/interface/Service.h"
0055 #include "CondCore/DBOutputService/interface/PoolDBOutputService.h"
0056 // Math
0057 #include "Math/GenVector/VectorUtil.h"
0058 #include "Math/GenVector/PxPyPzE4D.h"
0059 
0060 #include "RecoBTag/XMLCalibration/interface/AlgorithmCalibration.h"
0061 #include "RecoBTag/XMLCalibration/interface/CalibratedHistogramXML.h"
0062 #include "RecoBTag/TrackProbability/interface/TrackClassFilterCategory.h"
0063 
0064 //#include "TH1F.h"
0065 //#include "TFile.h"
0066 
0067 #include <fstream>
0068 #include <iostream>
0069 
0070 using namespace reco;
0071 
0072 //
0073 // class decleration
0074 //
0075 
0076 class TrackProbabilityXMLtoDB : public edm::one::EDAnalyzer<> {
0077 public:
0078   explicit TrackProbabilityXMLtoDB(const edm::ParameterSet&);
0079 
0080   virtual void endJob() {
0081     edm::Service<cond::service::PoolDBOutputService> mydbservice;
0082     if (!mydbservice.isAvailable())
0083       return;
0084 
0085     edm::FileInPath f2d("RecoBTag/TrackProbability/data/2DHisto.xml");
0086     edm::FileInPath f3d("RecoBTag/TrackProbability/data/3DHisto.xml");
0087     AlgorithmCalibration<TrackClassFilterCategory, CalibratedHistogramXML>* calibrationOld =
0088         new AlgorithmCalibration<TrackClassFilterCategory, CalibratedHistogramXML>((f3d.fullPath()).c_str());
0089     AlgorithmCalibration<TrackClassFilterCategory, CalibratedHistogramXML>* calibration2dOld =
0090         new AlgorithmCalibration<TrackClassFilterCategory, CalibratedHistogramXML>((f2d.fullPath()).c_str());
0091 
0092     vector<pair<TrackClassFilterCategory, CalibratedHistogramXML> > data = calibrationOld->categoriesWithData();
0093     vector<pair<TrackClassFilterCategory, CalibratedHistogramXML> > data2d = calibration2dOld->categoriesWithData();
0094     TrackProbabilityCalibration calibration;
0095     TrackProbabilityCalibration calibration2d;
0096     for (int i = 0; i < data.size(); i++) {
0097       TrackProbabilityCalibration::Entry entry;
0098       entry.category = data[i].first.categoryData();
0099       entry.histogram = data[i].second;
0100       calibration.data.push_back(entry);
0101     }
0102     for (int i = 0; i < data2d.size(); i++) {
0103       TrackProbabilityCalibration::Entry entry;
0104       entry.category = data2d[i].first.categoryData();
0105       entry.histogram = data2d[i].second;
0106       calibration2d.data.push_back(entry);
0107     }
0108 
0109     mydbservice->createOneIOV(calibration, mydbservice->endOfTime(), "BTagTrackProbability3DRcd");
0110 
0111     mydbservice->createOneIOV(calibration2d, mydbservice->endOfTime(), "BTagTrackProbability2DRcd");
0112   }
0113   ~TrackProbabilityXMLtoDB() {}
0114 
0115   virtual void analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup);
0116 
0117 private:
0118   int count;
0119   int ntracks;
0120   int m_cutPixelHits;
0121   int m_cutTotalHits;
0122   double m_cutMaxTIP;
0123   double m_cutMinPt;
0124   double m_cutMaxDecayLen;
0125   double m_cutMaxChiSquared;
0126   double m_cutMaxLIP;
0127   double m_cutMaxDistToAxis;
0128   double m_cutMinProb;
0129 
0130   edm::InputTag m_assoc;
0131   edm::InputTag m_jets;
0132   edm::InputTag m_primaryVertexProducer;
0133 };
0134 
0135 //
0136 // constructors and destructor
0137 //
0138 TrackProbabilityXMLtoDB::TrackProbabilityXMLtoDB(const edm::ParameterSet& parameters) {}
0139 
0140 void TrackProbabilityXMLtoDB::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {}
0141 
0142 //define this as a plug-in
0143 DEFINE_FWK_MODULE(TrackProbabilityXMLtoDB);