CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
EnergyLossProducer Class Reference

#include <EnergyLossProducer.h>

Inheritance diagram for EnergyLossProducer:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

Public Member Functions

 EnergyLossProducer (const edm::ParameterSet &ps)
 
virtual void produce (edm::Event &ev, const edm::EventSetup &es)
 
 ~EnergyLossProducer ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

Private Member Functions

void beginRun (edm::Run &run, const edm::EventSetup &es)
 
void endJob ()
 

Private Attributes

TH2F * hnor
 
double pixelToStripExponent
 
double pixelToStripMultiplier
 
TFile * resultFile
 
const TrackerGeometrytheTracker
 
std::string trackProducer
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 

Detailed Description

Definition at line 15 of file EnergyLossProducer.h.

Constructor & Destructor Documentation

EnergyLossProducer::EnergyLossProducer ( const edm::ParameterSet ps)
explicit

Definition at line 26 of file EnergyLossProducer.cc.

References edm::ParameterSet::getParameter(), resultFile, and trackProducer.

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 }
T getParameter(std::string const &) const
EnergyLossProducer::~EnergyLossProducer ( )

Definition at line 40 of file EnergyLossProducer.cc.

41 {
42 }

Member Function Documentation

void EnergyLossProducer::beginRun ( edm::Run run,
const edm::EventSetup es 
)
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 45 of file EnergyLossProducer.cc.

References edm::EventSetup::get(), hnor, create_public_lumi_plots::log, edm::ESHandle< class >::product(), theTracker, and patCandidatesForDimuonsSequences_cff::tracker.

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 }
const TrackerGeometry * theTracker
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
void EnergyLossProducer::endJob ( void  )
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 64 of file EnergyLossProducer.cc.

References hnor, and resultFile.

65 {
66  resultFile->cd();
67 
68  hnor->Write();
69 
70  resultFile->Close();
71 }
void EnergyLossProducer::produce ( edm::Event ev,
const edm::EventSetup es 
)
virtual

Implements edm::EDProducer.

Definition at line 74 of file EnergyLossProducer.cc.

References EnergyLossPlain::estimate(), edm::helper::Filler< Map >::fill(), first, edm::Event::getByLabel(), hnor, edm::helper::Filler< Map >::insert(), j, create_public_lumi_plots::log, LogTrace, pixelToStripExponent, pixelToStripMultiplier, edm::Handle< T >::product(), edm::Event::put(), edm::second(), theTracker, and trackProducer.

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 }
const TrackerGeometry * theTracker
U second(std::pair< T, U > const &p)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
int j
Definition: DBlmapReader.cc:9
bool first
Definition: L1TdeRCT.cc:94
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
#define LogTrace(id)
T const * product() const
Definition: Handle.h:74

Member Data Documentation

TH2F* EnergyLossProducer::hnor
private

Definition at line 31 of file EnergyLossProducer.h.

Referenced by beginRun(), endJob(), and produce().

double EnergyLossProducer::pixelToStripExponent
private

Definition at line 27 of file EnergyLossProducer.h.

Referenced by produce().

double EnergyLossProducer::pixelToStripMultiplier
private

Definition at line 27 of file EnergyLossProducer.h.

Referenced by produce().

TFile* EnergyLossProducer::resultFile
private

Definition at line 30 of file EnergyLossProducer.h.

Referenced by endJob(), and EnergyLossProducer().

const TrackerGeometry* EnergyLossProducer::theTracker
private

Definition at line 28 of file EnergyLossProducer.h.

Referenced by beginRun(), and produce().

std::string EnergyLossProducer::trackProducer
private

Definition at line 26 of file EnergyLossProducer.h.

Referenced by EnergyLossProducer(), and produce().