CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_13_patch3/src/RecoBTag/ImpactParameterLearning/plugins/TrackProbabilityXMLtoDB.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:    TrackProbabilityXMLtoDB
00004 // Class:      TrackProbabilityXMLtoDB
00005 // 
00013 //
00014 // Original Author:  Andrea Rizzi
00015 //         Created:  Wed Apr 12 11:12:49 CEST 2006
00016 // $Id: TrackProbabilityXMLtoDB.cc,v 1.3 2010/02/25 00:32:04 wmtan Exp $
00017 //
00018 //
00019 
00020 
00021 
00022 
00023 // system include files
00024 #include <memory>
00025 #include <string>
00026 #include <iostream>
00027 using namespace std;
00028 
00029 // user include files
00030 #include "FWCore/Framework/interface/Frameworkfwd.h"
00031 #include "FWCore/Framework/interface/EDAnalyzer.h"
00032 #include "FWCore/Framework/interface/Event.h"
00033 #include "FWCore/Framework/interface/MakerMacros.h"
00034 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00035 #include "FWCore/Utilities/interface/InputTag.h"
00036 
00037 #include "DataFormats/Math/interface/Vector3D.h"
00038 #include "DataFormats/Common/interface/Ref.h"
00039 #include "DataFormats/JetReco/interface/Jet.h"
00040 #include "DataFormats/JetReco/interface/CaloJet.h"
00041 #include "DataFormats/TrackReco/interface/Track.h"
00042 #include "DataFormats/BTauReco/interface/JetTracksAssociation.h"
00043 
00044 //#include "RecoBTag/TrackProbability/interface/TrackClassFilterCategory.h"
00045 
00046 #include "TrackingTools/Records/interface/TransientTrackRecord.h"
00047 #include "TrackingTools/TransientTrack/interface/TransientTrackBuilder.h"
00048 //#include "TrackProbabilityCalibratedHistogram.h"
00049 
00050 #include "RecoBTag/BTagTools/interface/SignedTransverseImpactParameter.h"
00051 #include "RecoBTag/BTagTools/interface/SignedImpactParameter3D.h"
00052 #include "RecoBTag/BTagTools/interface/SignedDecayLength3D.h"
00053 
00054 //CondFormats
00055 #include "CondFormats/BTauObjects/interface/TrackProbabilityCalibration.h"
00056 
00057 #include "FWCore/Framework/interface/IOVSyncValue.h"
00058 #include "FWCore/ServiceRegistry/interface/Service.h"
00059 #include "CondCore/DBOutputService/interface/PoolDBOutputService.h"
00060 // Math
00061 #include "Math/GenVector/VectorUtil.h"
00062 #include "Math/GenVector/PxPyPzE4D.h"
00063 
00064 #include "RecoBTag/XMLCalibration/interface/AlgorithmCalibration.h"
00065 #include "RecoBTag/XMLCalibration/interface/CalibratedHistogramXML.h"
00066 #include "RecoBTag/TrackProbability/interface/TrackClassFilterCategory.h"
00067 
00068 //#include "TH1F.h"
00069 //#include "TFile.h"
00070 
00071 
00072 #include <fstream>
00073 #include <iostream>
00074 
00075 using namespace reco;
00076 
00077 //
00078 // class decleration
00079 //
00080 
00081 class TrackProbabilityXMLtoDB : public edm::EDAnalyzer {
00082    public:
00083       explicit TrackProbabilityXMLtoDB(const edm::ParameterSet&);
00084 
00085     virtual void endJob()
00086     {
00087               edm::Service<cond::service::PoolDBOutputService> mydbservice;
00088               if( !mydbservice.isAvailable() ) return;
00089               
00090           edm::FileInPath f2d("RecoBTag/TrackProbability/data/2DHisto.xml");
00091           edm::FileInPath f3d("RecoBTag/TrackProbability/data/3DHisto.xml");
00092           AlgorithmCalibration<TrackClassFilterCategory, CalibratedHistogramXML>*  calibrationOld=     new AlgorithmCalibration<TrackClassFilterCategory,CalibratedHistogramXML>((f3d.fullPath()).c_str());
00093           AlgorithmCalibration<TrackClassFilterCategory, CalibratedHistogramXML>* calibration2dOld=       new AlgorithmCalibration<TrackClassFilterCategory,CalibratedHistogramXML>((f2d.fullPath()).c_str());
00094 
00095           vector<pair<TrackClassFilterCategory, CalibratedHistogramXML> > data = calibrationOld->categoriesWithData();
00096           vector<pair<TrackClassFilterCategory, CalibratedHistogramXML> > data2d = calibration2dOld->categoriesWithData();
00097           TrackProbabilityCalibration * calibration= new TrackProbabilityCalibration();
00098           TrackProbabilityCalibration * calibration2d= new TrackProbabilityCalibration();
00099           for(int i = 0 ; i < data.size();i++)
00100           {
00101             TrackProbabilityCalibration::Entry entry;
00102             entry.category=data[i].first.categoryData();
00103             entry.histogram=data[i].second;
00104             calibration->data.push_back(entry);   
00105           }
00106           for(int i = 0 ; i < data2d.size();i++)
00107           {
00108             TrackProbabilityCalibration::Entry entry;
00109             entry.category=data2d[i].first.categoryData();
00110             entry.histogram=data2d[i].second;
00111             calibration2d->data.push_back(entry);   
00112           }
00113 
00114 
00115          mydbservice->createNewIOV<TrackProbabilityCalibration>(calibration,  mydbservice->endOfTime(),"BTagTrackProbability3DRcd");    
00116 
00117          mydbservice->createNewIOV<TrackProbabilityCalibration>(calibration2d,  mydbservice->endOfTime(),"BTagTrackProbability2DRcd");   
00118                
00119 
00120     }    
00121       ~TrackProbabilityXMLtoDB() 
00122     {
00123     }
00124 
00125 
00126 
00127       virtual void analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup);
00128 
00129    private:
00130     int count;
00131 int ntracks;
00132     int  m_cutPixelHits;
00133     int  m_cutTotalHits;
00134     double  m_cutMaxTIP;
00135     double  m_cutMinPt;
00136     double  m_cutMaxDecayLen;
00137     double  m_cutMaxChiSquared;
00138     double  m_cutMaxLIP;
00139     double m_cutMaxDistToAxis;
00140     double m_cutMinProb;
00141 
00142      edm::InputTag m_assoc;
00143      edm::InputTag m_jets;
00144      edm::InputTag m_primaryVertexProducer;
00145 };
00146 
00147 //
00148 // constructors and destructor
00149 //
00150 TrackProbabilityXMLtoDB::TrackProbabilityXMLtoDB(const edm::ParameterSet& parameters)
00151 {
00152 }
00153 
00154 void
00155 TrackProbabilityXMLtoDB::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
00156 {
00157 }
00158 
00159 //define this as a plug-in
00160 
00161 DEFINE_FWK_MODULE(TrackProbabilityXMLtoDB);