- Standard reconstructed electron objects appear in a root TBrowser as:

The GSF tracks associated to the electrons are in the collections:
The SuperClusters associated to the electrons are in the collections:

Configuration file

The code that will be run is the GsfElectronMCAnalyzer class. It will read the GsfElectrons produced by the module pixelMatchGsfElectrons.

Check out the package RecoEgamma/Examples from the CVS repository, i.e. in a project area based on a 2_1_x release, type:

addpkg  RecoEgamma/Examples

Go into the test directory of RecoEgamma/Examples and examine the file GsfElectronMCAnalyzer_cfg.py in RecoEgamma/Examples/test.

The maxEvents parameter is set to -1, which means that all events in the input file will be processed.

After a part introducing the MessageLogger(to trigger the way informative output will be given by the job), the next part specifies the input files, in this case a release validation sample of ZEE decay. Any sample containing GsfElectrons generated with CMSSW_2_1_X can be used here. Such samples can be found using DBS. In order to read in a local root file, use the syntax in the commented line.

    source = PoolSource { 
   untracked vstring fileNames = {

Next, a module gsfElectronAnalysis is defined:

    module gsfElectronAnalysis= GsfElectronMCAnalyzer { 
    string outputFile = "gsfElectronHistos.root"         
   InputTag electronCollection = pixelMatchGsfElectrons
   InputTag mcTruthCollection = source
   // efficiency cuts
   double MaxPt = 100.
   double MaxAbsEta = 2.5
   double DeltaR = 0.05
   // histos limits and binning

The module is an instance of the class GsfElectronMCAnalyzer. It takes several input parameters:

  • The electronCollection and mcTruthCollection parameters specify the input CMS.GsfElectron collection and McTruth collection.
  • MaxPt, MaxAbsEta and DeltaR are parameters to define the matching of the reconstructed electrons to Monte Carlo truth used to determine efficiencies and resolutions (see here).

Note that you can find the complete list of collections made by the egamma producers in SWGuideDataFormatRecoEcal and SWGuideDataFormatRecoEgamma.

The path is simply the module we have defined:

  path p = {gsfElectronAnalysis}

Example Analysis Code

Now go to the src directory of RecoEgamma/Examples and open the implementation of the class GsfElectronMCAnalyzer.cc. The class is an example of an EDAnalyzer (inherits from edm::EDAnalyzer). The code loops over both the reconstructed and MC electrons in the input file events. The analyze method is called once for each event:

void GsfElectronMCAnalyzer::analyze(const edm::Event& e, const edm::EventSetup& iSetup)

The first step is to retrieve the electrons from the event. electronCollection_ correspond to what we defined in the gsfElectronAnalysis module in the config file:

  edm::Handle<GsfElectronCollection> gsfElectrons;

Next the code loops over the electrons and fills quantities to histograms. Note that in addition to a range of variables characterizing the electron, the associated GsfTrack and SuperCluster objects can be simply accessed through the gsfTrack() and superCluster() methods of the CMS.GsfElectron.

Comparing with MC truth

Monte Carlo truth information can be read from event as follows:

  edm::Handle<edm::HepMCProduct> hepMC;
  const HepMC::GenEvent *myGenEvent = hepMC->GetEvent();

The code loops over MC electrons, requiring them to be primary, or for the parent to be a Z, Zprime or W boson:

  for ( HepMC::GenEvent::particle_const_iterator mcIter=myGenEvent->particles_begin(); mcIter != myGenEvent->particles_end(); mcIter++ ) {

    // select electrons
    if ( (*mcIter)->pdg_id() == 11 || (*mcIter)->pdg_id() == -11 ){       

      // single primary electrons or electrons from Zs or Ws
      HepMC::GenParticle* mother = 0;
      if ( (*mcIter)->production_vertex() )  {
       if ( (*mcIter)->production_vertex()->particles_begin(HepMC::parents) != 
            mother = *((*mcIter)->production_vertex()->particles_begin(HepMC::parents));
      if ( ((mother == 0) || ((mother != 0) && (mother->pdg_id() == 23))
                     || ((mother != 0) && (mother->pdg_id() == 32))
                     || ((mother != 0) && (fabs(mother->pdg_id()) == 24)))) {       

The best matching reconstructed electron to each MC electron is identified and histograms are filled for RECO electrons matched to MC electrons, requiring deltaR<0.05 (specified by the DeltaR parameter in GsfElectronMCAnalyzer.cfg) and the same charge. Matching to MC electrons (and hence determination of efficiency and resolution) is only performed for MC electron |eta|<MaxAbsEta and pt<MaxPt, where MaxAbsEta and MaxPt are specified in GsfElectronMCAnalyzer.cfg, with default values 2.5 and 50GeV, respectively.

Run the analysis

To run the analyzer, go to the RecoEgamma/Examples directory and type:

  cmsRun GsfElectronMCAnalyzer.cfg (or GsfElectronMCAnalyzer_cfg.py).

Two of the histograms filled in this example are shown below (Note: The MaxPt parameter in GsfElectronMCAnalyzer.cfg was set to 100 to make these plots):

Access to ClusterShape

In 210, ClusterShape objects are not stored persistently any more by the superclustering, therefore there is no access via the electron class. You should use the classes EcalClusterTools or EcalClusterLazyTools to get the cluster shapes.

-- UrsulaBerthon - 04 Jul 2008

Edit | Attach | Watch | Print version | History: r9 < r8 < r7 < r6 < r5 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r9 - 2009-03-03 - MatteoSani
    • Cern Search Icon Cern Search
    • TWiki Search Icon TWiki Search
    • Google Search Icon Google Search

    CMSPublic All webs login

This site is powered by the TWiki collaboration platform Powered by PerlCopyright & 2008-2019 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback