CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

EnergyLossProducer Class Reference

#include <EnergyLossProducer.h>

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

List of all members.

Public Member Functions

 EnergyLossProducer (const edm::ParameterSet &ps)
virtual void produce (edm::Event &ev, const edm::EventSetup &es)
 ~EnergyLossProducer ()

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

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.

{
  trackProducer          = ps.getParameter<std::string>("trackProducer");
//  pixelToStripMultiplier = ps.getParameter<double>("pixelToStripMultiplier");
//  pixelToStripExponent   = ps.getParameter<double>("pixelToStripExponent");

  produces<reco::DeDxDataValueMap>("energyLossPixHits");
  produces<reco::DeDxDataValueMap>("energyLossStrHits");
  produces<reco::DeDxDataValueMap>("energyLossAllHits");

  resultFile = new TFile("energyLoss.root","recreate");
}
EnergyLossProducer::~EnergyLossProducer ( )

Definition at line 40 of file EnergyLossProducer.cc.

{
}

Member Function Documentation

void EnergyLossProducer::beginRun ( edm::Run run,
const edm::EventSetup es 
) [private, virtual]

Reimplemented from edm::EDProducer.

Definition at line 45 of file EnergyLossProducer.cc.

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

{
  // Get tracker geometry
  edm::ESHandle<TrackerGeometry> tracker;
  es.get<TrackerDigiGeometryRecord>().get(tracker);
  theTracker = tracker.product();
  
  std::vector<double> ldeBins;
  static float ldeMin   = log(1);
  static float ldeMax   = log(100);
  static float ldeWidth = (ldeMax - ldeMin)/250;
  for(double lde = ldeMin; lde < ldeMax + ldeWidth/2; lde += ldeWidth)
    ldeBins.push_back(lde);

  hnor = new TH2F("hnor","hnor", ldeBins.size()-1, &ldeBins[0],
                                 ldeBins.size()-1, &ldeBins[0]);
}
void EnergyLossProducer::endJob ( void  ) [private, virtual]

Reimplemented from edm::EDProducer.

Definition at line 64 of file EnergyLossProducer.cc.

References hnor, and resultFile.

{
  resultFile->cd();

  hnor->Write();

  resultFile->Close();
}
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, funct::log(), LogTrace, pixelToStripExponent, pixelToStripMultiplier, edm::Handle< T >::product(), edm::Event::put(), edm::second(), theTracker, and trackProducer.

{
  edm::Handle<reco::TrackCollection> trackHandle;
  ev.getByLabel(trackProducer,       trackHandle);

  std::auto_ptr<reco::DeDxDataValueMap> outputPix (new reco::DeDxDataValueMap);
  std::auto_ptr<reco::DeDxDataValueMap> outputStr (new reco::DeDxDataValueMap);
  std::auto_ptr<reco::DeDxDataValueMap> outputAll (new reco::DeDxDataValueMap);

  reco::DeDxDataValueMap::Filler fillerPix(*outputPix);
  reco::DeDxDataValueMap::Filler fillerStr(*outputStr);
  reco::DeDxDataValueMap::Filler fillerAll(*outputAll);

  LogTrace("MinBiasTracking")
    << "[EnergyLossProducer]";

  // Get trajectory collection
  edm::Handle<std::vector<Trajectory> > trajeHandle;
  ev.getByLabel(trackProducer,     trajeHandle);
  const std::vector<Trajectory> & trajeCollection =
                                 *(trajeHandle.product());

  // Plain estimator
  EnergyLossPlain theEloss(theTracker, pixelToStripMultiplier,
                                       pixelToStripExponent);

  std::vector<reco::DeDxData> estimatePix;
  std::vector<reco::DeDxData> estimateStr;
  std::vector<reco::DeDxData> estimateAll;

  // Take all trajectories
  int j = 0;
  for(std::vector<Trajectory>::const_iterator traje = trajeCollection.begin();
                                         traje!= trajeCollection.end();
                                         traje++, j++)
  {
    // Estimate (nhits,dE/dx)
    std::vector<std::pair<int,double> >    arithmeticMean, weightedMean;
    theEloss.estimate(&(*traje), arithmeticMean, weightedMean);

    // Set values
    estimatePix.push_back(reco::DeDxData(weightedMean[0].second, 0,
                                         weightedMean[0].first));
    estimateStr.push_back(reco::DeDxData(weightedMean[1].second, 0,
                                         weightedMean[1].first));
    estimateAll.push_back(reco::DeDxData(weightedMean[2].second, 0,
                                         weightedMean[2].first));

    // Prepare conversion matrix
    if(weightedMean[0].first >= 3 &&
       weightedMean[1].first >= 3)
      hnor->Fill(log(weightedMean[0].second),
                 log(weightedMean[1].second));
  }

  fillerPix.insert(trackHandle, estimatePix.begin(), estimatePix.end());
  fillerStr.insert(trackHandle, estimateStr.begin(), estimateStr.end());
  fillerAll.insert(trackHandle, estimateAll.begin(), estimateAll.end());

  fillerPix.fill();
  fillerStr.fill();
  fillerAll.fill();

  // Put back result to event
  ev.put(outputPix, "energyLossPixHits");
  ev.put(outputStr, "energyLossStrHits");
  ev.put(outputAll, "energyLossAllHits");
}

Member Data Documentation

TH2F* EnergyLossProducer::hnor [private]

Definition at line 31 of file EnergyLossProducer.h.

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

Definition at line 27 of file EnergyLossProducer.h.

Referenced by produce().

Definition at line 27 of file EnergyLossProducer.h.

Referenced by produce().

Definition at line 30 of file EnergyLossProducer.h.

Referenced by endJob(), and EnergyLossProducer().

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().