Go to the documentation of this file.00001 #include "EnergyLossProducer.h"
00002
00003 #include "FWCore/Framework/interface/Event.h"
00004 #include "FWCore/Framework/interface/EventSetup.h"
00005 #include "FWCore/Framework/interface/ESHandle.h"
00006 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00007 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00008
00009 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
00010 #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
00011
00012 #include "QCDAnalysis/ChargedHadronSpectra/interface/EnergyLossPlain.h"
00013
00014 #include "DataFormats/TrackReco/interface/Track.h"
00015 #include "DataFormats/TrackReco/interface/TrackFwd.h"
00016
00017
00018
00019 #include "DataFormats/TrackReco/interface/DeDxData.h"
00020
00021 #include "TROOT.h"
00022 #include "TFile.h"
00023 #include "TH2F.h"
00024
00025
00026 EnergyLossProducer::EnergyLossProducer(const edm::ParameterSet& ps)
00027 {
00028 trackProducer = ps.getParameter<std::string>("trackProducer");
00029
00030
00031
00032 produces<reco::DeDxDataValueMap>("energyLossPixHits");
00033 produces<reco::DeDxDataValueMap>("energyLossStrHits");
00034 produces<reco::DeDxDataValueMap>("energyLossAllHits");
00035
00036 resultFile = new TFile("energyLoss.root","recreate");
00037 }
00038
00039
00040 EnergyLossProducer::~EnergyLossProducer()
00041 {
00042 }
00043
00044
00045 void EnergyLossProducer::beginRun(edm::Run & run, const edm::EventSetup& es)
00046 {
00047
00048 edm::ESHandle<TrackerGeometry> tracker;
00049 es.get<TrackerDigiGeometryRecord>().get(tracker);
00050 theTracker = tracker.product();
00051
00052 std::vector<double> ldeBins;
00053 static float ldeMin = log(1);
00054 static float ldeMax = log(100);
00055 static float ldeWidth = (ldeMax - ldeMin)/250;
00056 for(double lde = ldeMin; lde < ldeMax + ldeWidth/2; lde += ldeWidth)
00057 ldeBins.push_back(lde);
00058
00059 hnor = new TH2F("hnor","hnor", ldeBins.size()-1, &ldeBins[0],
00060 ldeBins.size()-1, &ldeBins[0]);
00061 }
00062
00063
00064 void EnergyLossProducer::endJob()
00065 {
00066 resultFile->cd();
00067
00068 hnor->Write();
00069
00070 resultFile->Close();
00071 }
00072
00073
00074 void EnergyLossProducer::produce(edm::Event& ev, const edm::EventSetup& es)
00075 {
00076 edm::Handle<reco::TrackCollection> trackHandle;
00077 ev.getByLabel(trackProducer, trackHandle);
00078
00079 std::auto_ptr<reco::DeDxDataValueMap> outputPix (new reco::DeDxDataValueMap);
00080 std::auto_ptr<reco::DeDxDataValueMap> outputStr (new reco::DeDxDataValueMap);
00081 std::auto_ptr<reco::DeDxDataValueMap> outputAll (new reco::DeDxDataValueMap);
00082
00083 reco::DeDxDataValueMap::Filler fillerPix(*outputPix);
00084 reco::DeDxDataValueMap::Filler fillerStr(*outputStr);
00085 reco::DeDxDataValueMap::Filler fillerAll(*outputAll);
00086
00087 LogTrace("MinBiasTracking")
00088 << "[EnergyLossProducer]";
00089
00090
00091 edm::Handle<std::vector<Trajectory> > trajeHandle;
00092 ev.getByLabel(trackProducer, trajeHandle);
00093 const std::vector<Trajectory> & trajeCollection =
00094 *(trajeHandle.product());
00095
00096
00097 EnergyLossPlain theEloss(theTracker, pixelToStripMultiplier,
00098 pixelToStripExponent);
00099
00100 std::vector<reco::DeDxData> estimatePix;
00101 std::vector<reco::DeDxData> estimateStr;
00102 std::vector<reco::DeDxData> estimateAll;
00103
00104
00105 int j = 0;
00106 for(std::vector<Trajectory>::const_iterator traje = trajeCollection.begin();
00107 traje!= trajeCollection.end();
00108 traje++, j++)
00109 {
00110
00111 std::vector<std::pair<int,double> > arithmeticMean, weightedMean;
00112 theEloss.estimate(&(*traje), arithmeticMean, weightedMean);
00113
00114
00115 estimatePix.push_back(reco::DeDxData(weightedMean[0].second, 0,
00116 weightedMean[0].first));
00117 estimateStr.push_back(reco::DeDxData(weightedMean[1].second, 0,
00118 weightedMean[1].first));
00119 estimateAll.push_back(reco::DeDxData(weightedMean[2].second, 0,
00120 weightedMean[2].first));
00121
00122
00123 if(weightedMean[0].first >= 3 &&
00124 weightedMean[1].first >= 3)
00125 hnor->Fill(log(weightedMean[0].second),
00126 log(weightedMean[1].second));
00127 }
00128
00129 fillerPix.insert(trackHandle, estimatePix.begin(), estimatePix.end());
00130 fillerStr.insert(trackHandle, estimateStr.begin(), estimateStr.end());
00131 fillerAll.insert(trackHandle, estimateAll.begin(), estimateAll.end());
00132
00133 fillerPix.fill();
00134 fillerStr.fill();
00135 fillerAll.fill();
00136
00137
00138 ev.put(outputPix, "energyLossPixHits");
00139 ev.put(outputStr, "energyLossStrHits");
00140 ev.put(outputAll, "energyLossAllHits");
00141 }