CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EnergyLossProducer.cc
Go to the documentation of this file.
1 #include "EnergyLossProducer.h"
2 
8 
11 
13 
16 
17 //#include "DataFormats/TrackReco/interface/TrackDeDxHits.h"
18 //#include "DataFormats/TrackReco/interface/TrackDeDxEstimate.h"
20 
21 #include "TROOT.h"
22 #include "TFile.h"
23 #include "TH2F.h"
24 
25 /*****************************************************************************/
27 {
28  trackProducer = ps.getParameter<std::string>("trackProducer");
29 // pixelToStripMultiplier = ps.getParameter<double>("pixelToStripMultiplier");
30 // pixelToStripExponent = ps.getParameter<double>("pixelToStripExponent");
31 
32  produces<reco::DeDxDataValueMap>("energyLossPixHits");
33  produces<reco::DeDxDataValueMap>("energyLossStrHits");
34  produces<reco::DeDxDataValueMap>("energyLossAllHits");
35 
36  resultFile = new TFile("energyLoss.root","recreate");
37 }
38 
39 /*****************************************************************************/
41 {
42 }
43 
44 /*****************************************************************************/
46 {
47  // Get tracker geometry
49  es.get<TrackerDigiGeometryRecord>().get(tracker);
50  theTracker = tracker.product();
51 
52  std::vector<double> ldeBins;
53  static float ldeMin = log(1);
54  static float ldeMax = log(100);
55  static float ldeWidth = (ldeMax - ldeMin)/250;
56  for(double lde = ldeMin; lde < ldeMax + ldeWidth/2; lde += ldeWidth)
57  ldeBins.push_back(lde);
58 
59  hnor = new TH2F("hnor","hnor", ldeBins.size()-1, &ldeBins[0],
60  ldeBins.size()-1, &ldeBins[0]);
61 }
62 
63 /*****************************************************************************/
65 {
66  resultFile->cd();
67 
68  hnor->Write();
69 
70  resultFile->Close();
71 }
72 
73 /*****************************************************************************/
75 {
77  ev.getByLabel(trackProducer, trackHandle);
78 
79  std::auto_ptr<reco::DeDxDataValueMap> outputPix (new reco::DeDxDataValueMap);
80  std::auto_ptr<reco::DeDxDataValueMap> outputStr (new reco::DeDxDataValueMap);
81  std::auto_ptr<reco::DeDxDataValueMap> outputAll (new reco::DeDxDataValueMap);
82 
83  reco::DeDxDataValueMap::Filler fillerPix(*outputPix);
84  reco::DeDxDataValueMap::Filler fillerStr(*outputStr);
85  reco::DeDxDataValueMap::Filler fillerAll(*outputAll);
86 
87  LogTrace("MinBiasTracking")
88  << "[EnergyLossProducer]";
89 
90  // Get trajectory collection
92  ev.getByLabel(trackProducer, trajeHandle);
93  const std::vector<Trajectory> & trajeCollection =
94  *(trajeHandle.product());
95 
96  // Plain estimator
99 
100  std::vector<reco::DeDxData> estimatePix;
101  std::vector<reco::DeDxData> estimateStr;
102  std::vector<reco::DeDxData> estimateAll;
103 
104  // Take all trajectories
105  int j = 0;
106  for(std::vector<Trajectory>::const_iterator traje = trajeCollection.begin();
107  traje!= trajeCollection.end();
108  traje++, j++)
109  {
110  // Estimate (nhits,dE/dx)
111  std::vector<std::pair<int,double> > arithmeticMean, weightedMean;
112  theEloss.estimate(&(*traje), arithmeticMean, weightedMean);
113 
114  // Set values
115  estimatePix.push_back(reco::DeDxData(weightedMean[0].second, 0,
116  weightedMean[0].first));
117  estimateStr.push_back(reco::DeDxData(weightedMean[1].second, 0,
118  weightedMean[1].first));
119  estimateAll.push_back(reco::DeDxData(weightedMean[2].second, 0,
120  weightedMean[2].first));
121 
122  // Prepare conversion matrix
123  if(weightedMean[0].first >= 3 &&
124  weightedMean[1].first >= 3)
125  hnor->Fill(log(weightedMean[0].second),
126  log(weightedMean[1].second));
127  }
128 
129  fillerPix.insert(trackHandle, estimatePix.begin(), estimatePix.end());
130  fillerStr.insert(trackHandle, estimateStr.begin(), estimateStr.end());
131  fillerAll.insert(trackHandle, estimateAll.begin(), estimateAll.end());
132 
133  fillerPix.fill();
134  fillerStr.fill();
135  fillerAll.fill();
136 
137  // Put back result to event
138  ev.put(outputPix, "energyLossPixHits");
139  ev.put(outputStr, "energyLossStrHits");
140  ev.put(outputAll, "energyLossAllHits");
141 }
T getParameter(std::string const &) const
void insert(const H &h, I begin, I end)
Definition: ValueMap.h:52
virtual void produce(edm::Event &ev, const edm::EventSetup &es)
const TrackerGeometry * theTracker
EnergyLossProducer(const edm::ParameterSet &ps)
int estimate(const Trajectory *trajectory, std::vector< std::pair< int, double > > &arithmeticMean, std::vector< std::pair< int, double > > &truncatedMean)
U second(std::pair< T, U > const &p)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:84
int j
Definition: DBlmapReader.cc:9
bool first
Definition: L1TdeRCT.cc:79
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:359
#define LogTrace(id)
Log< T >::type log(const T &t)
Definition: Log.h:22
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
T const * product() const
Definition: Handle.h:74
void beginRun(edm::Run &run, const edm::EventSetup &es)
Definition: Run.h:31