CMSSW General Tools Tutorial

CMSSW Full Framework

Automatic ED Scripts

To have access to the FW Skeleton makers, do:

addpkg FWCore/Skeletons

Having a look in that directory, do

 ls FWCore/Skeletons/scripts/

We see the output is

CVS/       mkedanlzr*   mkedlpr*   mkesprod*  mkrecord*  mkTemplates/  SkelParser.pm*
mkdatapkg*  mkedfltr*   mkedprod*  mkevhyp*   mkskel*    mktsel*

The ones you will be using the most are mkedanlz (make EDAnalyzer), mkedprod (make EDProducer), and mkedfltr (make EDFilter). So let's pick one as an example. We'll make an EDAnalyzer with the following commands:

mkdir Analysis
cd Analysis/
../FWCore/Skeletons/scripts/mkedanlzr MuonAnalyzer

The output of this is:

  I: using skeleton: ../FWCore/Skeletons/scripts/mkTemplates/EDAnalyzer/BuildFile.temp 
  I: authors name is: "Salvatore Rappoccio", determined by the output finger cmnd 
  I: creating file: MuonAnalyzer/BuildFile 
  I: using skeleton: ../FWCore/Skeletons/scripts/mkTemplates/EDAnalyzer/edanalyzer.cc 
  I: authors name is: "Salvatore Rappoccio", determined by command line 
  I: creating file: MuonAnalyzer/src/MuonAnalyzer.cc 
  I: using skeleton: ../FWCore/Skeletons/scripts/mkTemplates/EDAnalyzer/CfiFile.cfi 
  I: authors name is: "Salvatore Rappoccio", determined by command line 
  I: creating file: MuonAnalyzer/data/muonanalyzer.cfi 
  I: using skeleton: ../FWCore/Skeletons/scripts/mkTemplates/EDAnalyzer/ConfFile.cfg 
  I: authors name is: "Salvatore Rappoccio", determined by command line 
  I: creating file:  MuonAnalyzer/muonanalyzer.cfg 

Now we do

cd MuonAnalyzer/
ls *

And the output is

cmslpc07:> ls *
BuildFile  muonanalyzer.cfg

data:
muonanalyzer.cfi

doc:

interface:

src:
MuonAnalyzer.cc

test:

The file muonanalyzer.cfg is the driver for the example, and looks like this:

process Demo =  {
  
source = PoolSource 
{ 
     # replace 'myfile.root' with the source file you want to use
     untracked vstring fileNames = {"file:myfile.root"} 
}

#keep the logging output to a nice level
service = MessageLogger {}

module demo = MuonAnalyzer { 
}


path p = {demo} 

}

This will input something from PoolSource, and will create a skeleton for your analyzer module MuonAnalyzer. You can fill things in here as you go along.

The cc file looks like:

// -*- C++ -*-
//
// Package:    MuonAnalyzer
// Class:      MuonAnalyzer
// 
/**\class MuonAnalyzer MuonAnalyzer.cc Analysis/MuonAnalyzer/src/MuonAnalyzer.cc

 Description: <one line class summary>

 Implementation:
     <Notes on implementation>
*/
//
// Original Author:  "Salvatore Rappoccio"
//         Created:  Thu Jun 19 10:26:23 CDT 2008
// $Id: SalvatoreRappoccioCMSSWTutorialJune08.txt,v 1.4 2008/06/19 20:44:55 SalvatoreRRappoccio Exp $
//
//


// system include files
#include <memory>

// user include files
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/EDAnalyzer.h"

#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/MakerMacros.h"

#include "FWCore/ParameterSet/interface/ParameterSet.h"
//
// class decleration
//

class MuonAnalyzer : public edm::EDAnalyzer {
   public:
      explicit MuonAnalyzer(const edm::ParameterSet&);
      ~MuonAnalyzer();


   private:
      virtual void beginJob(const edm::EventSetup&) ;
      virtual void analyze(const edm::Event&, const edm::EventSetup&);
      virtual void endJob() ;

      // ----------member data ---------------------------
};

//
// constants, enums and typedefs
//

//
// static data member definitions
//

//
// constructors and destructor
//
MuonAnalyzer::MuonAnalyzer(const edm::ParameterSet& iConfig)

{
   //now do what ever initialization is needed

}


MuonAnalyzer::~MuonAnalyzer()
{
 
   // do anything here that needs to be done at desctruction time
   // (e.g. close files, deallocate resources etc.)

}


//
// member functions
//

// ------------ method called to for each event  ------------
void
MuonAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
{
   using namespace edm;



#ifdef THIS_IS_AN_EVENT_EXAMPLE
   Handle<ExampleData> pIn;
   iEvent.getByLabel("example",pIn);
#endif
   
#ifdef THIS_IS_AN_EVENTSETUP_EXAMPLE
   ESHandle<SetupData> pSetup;
   iSetup.get<SetupRecord>().get(pSetup);
#endif
}


// ------------ method called once each job just before starting event loop  ------------
void 
MuonAnalyzer::beginJob(const edm::EventSetup&)
{
}

// ------------ method called once each job just after ending the event loop  ------------
void 
MuonAnalyzer::endJob() {
}

//define this as a plug-in
DEFINE_FWK_MODULE(MuonAnalyzer);

Your code will go into the "analyze" method, and you can do whatever you'd like in there, but you cannot write any output.

We'll be looking at some specific examples of the various flavors you'll be using now.

EDAnalyzers

http://cmslxr.fnal.gov/lxr/source/PhysicsTools/PatAlgos/test/VerySimplePATAnalysis.cc?v=CMSSW_1_6_12

EDProducers

http://cmslxr.fnal.gov/lxr/source/RecoJets/JetProducers/src/BaseJetProducer.h?v=CMSSW_1_6_12

http://cmslxr.fnal.gov/lxr/source/RecoJets/JetProducers/src/BaseJetProducer.cc?v=CMSSW_1_6_12

http://cmssw.cvs.cern.ch/cgi-bin/cmssw.cgi/UserCode/srappocc/src/Analysis/BoostedTop/src/BoostedTopProducer.cc?revision=1.4&view=markup

EDFilters

http://cmslxr.fnal.gov/lxr/source/ElectroWeakAnalysis/ZMuMu/plugins/ZToMuMuFilter.cc?v=CMSSW_1_6_12

http://cmssw.cvs.cern.ch/cgi-bin/cmssw.cgi/UserCode/srappocc/src/Analysis/BTagFilter/interface/BTagFilter.h?revision=1.1&view=markup

Candidate Utilities

http://cmslxr.fnal.gov/lxr/source/PhysicsTools/StarterKit/test/CompositeKitDemo_lljj.cfg?v=CMSSW_1_6_12

http://cmslxr.fnal.gov/lxr/source/PhysicsTools/RecoAlgos/plugins/EtMinCaloJetSelector.cc?v=CMSSW_1_6_12

FWLite

https://twiki.cern.ch/twiki/bin/view/CMS/SWGuideEDMWithRoot

DBS Browser

http://cmsdbs.cern.ch/DBS2_discovery/_navigator?userMode=user

LXR

http://cmslxr.fnal.gov/lxr/

CVS Browser

http://cmssw.cvs.cern.ch/cgi-bin/cmssw.cgi/CMSSW/

PhEDEx

http://cmsdoc.cern.ch/cms/aprom/phedex/

CMSTC

https://cmstags.cern.ch/cgi-bin/CmsTC/CmsTCLogin

SCRAM

Full doucmentation is here but it is a bit old:

https://twiki.cern.ch/twiki/bin/view/CMS/SWGuideScram

The command line documentation is good:

<lpcdt023.fnal.gov> scram help
*************************************************************************
SCRAM HELP ------------- Recognised Commands
*************************************************************************

         scram version
         scram arch
         scram runtime
         scram list
         scram db
         scram urlget
         scram project
         scram setup
         scram tool
         scram build
         scram install
         scram remove

Help on individual commands is available through

        scram <command> --help


Options:
--------
--help                       : Show this help page.                             
--verbose <class>            : Activate the verbose function on the specified class or list of classes.
--debug                      : Activate the verbose function on all SCRAM classes.

--arch <architecture>        : Set the architecture ID to that specified.       
--noreturn                   : Pause after command execution rather than just exiting.


<lpcdt023.fnal.gov> scram project --help
*********************************************************************************
SCRAM HELP ------------ project
*********************************************************************************
Description:

        Set up a new project development area or update an existing one. A new area will appear in the
        current working directory by default.

Usage:
        scram project [-l] [-d <area>] [-n <dir>] [-f <tools.conf>] <projecturl> [<projectversion>]

        scram project --update [<projectversion>]

Options:

<projecturl>:
        The URL of a SCRAM bootstrap file.

<projectversion>:
        Only for use with a database label.

-d <area>:
        Indicate a project installation area into which the new
        project area should appear. Default is the current working
        directory.

-n <dir>:
        Specify the name of the SCRAM development area you wish to
        create.


Currently supported URL types are:

database label  Labels can be assigned to installed releases of projects for easy
access (See "scram install" command). If you specify a label you must also specify
a project version. This command is normally used to create cloned developer areas.

-b <file>       A bootstrap file on an accessible file system. This command would
be used to create a project area from scratch on a laptop.

** Examples **

        scram project XX XX_9_0

        scram project -b ~/myprojects/projecta/config/boot


Use the "-f" flag followed by a valid filename (which MUST end in ".conf") to
allow auto setup to proceed without reading files from a repository (STANDALONE mode).

Use "-l" to see the detail log message when creating a dev area.

An existing developer area for a project can be updated to a more recent version of
the SAME project by running "scram project -update <VERSION>" in the developer area.
If no VERSION is given, the command is considered like a query and will return a list
of project versions which are compatible with the configuration of the current area.

A subsequent invocation of the command with a valid VERSION will then update the area
to that version.

Shahzad gave a useful talk listing new features in the 2_X series of releases:

http://indico.cern.ch/getFile.py/access?contribId=108&sessionId=27&resId=2&materialId=slides&confId=28445

One of the new features is particularly useful at FNAL. Since developer areas can become full of temporary binary files that you don't need daily backups of there is a way to redirect those areas to your user_data area. You can do this by using the "-s" option. Combined with the following scram configuration file from your home area:

<lpcdt023.fnal.gov> cat ~sexton/.scramrc/symlinks
lib:/uscms_data/d1/$(USER)/$(SCRAM_PROJECTNAME)/$(SCRAM_PROJECTVERSION)
tmp:/uscms_data/d1/$(USER)/$(SCRAM_PROJECTNAME)/$(SCRAM_PROJECTVERSION)
bin:/uscms_data/d1/$(USER)/$(SCRAM_PROJECTNAME)/$(SCRAM_PROJECTVERSION)

<lpcdt023.fnal.gov> scram project -s CMSSW CMSSW_2_1_0_pre5
<lpcdt023.fnal.gov> cd CMSSW_2_1_0_pre5/
<lpcdt023.fnal.gov> ls -la
total 480
drwxr-xr-x  12 sexton us_cms 2048 Jun 19 11:39 .
drwxr-xr-x  37 sexton us_cms 8192 Jun 19 11:39 ..
lrwxrwxrwx   1 sexton us_cms   57 Jun 19 11:39 bin -> /uscms_data/d1/sexton/CMSSW/CMSSW_2_1_0_pre5/bin.ONKk9cuL
drwxr-xr-x   4 sexton us_cms 2048 Jun 19 11:39 config
drwxr-xr-x   2 sexton us_cms 2048 Jun 19 11:39 doc
drwxr-xr-x   3 sexton us_cms 2048 Jun 19 11:39 include
lrwxrwxrwx   1 sexton us_cms   57 Jun 19 11:39 lib -> /uscms_data/d1/sexton/CMSSW/CMSSW_2_1_0_pre5/lib.7acl5XIg
drwxr-xr-x   3 sexton us_cms 2048 Jun 19 11:39 logs
drwxr-xr-x   3 sexton us_cms 2048 Jun 19 11:39 module
drwxr-xr-x   2 sexton us_cms 2048 Jun 19 11:39 python
drwxr-xr-x   5 sexton us_cms 2048 Jun 19 11:39 .SCRAM
drwxr-xr-x   5 sexton us_cms 2048 Jun 19 11:39 share
drwxr-xr-x   2 sexton us_cms 2048 Jun 19 11:39 src
drwxr-xr-x   3 sexton us_cms 2048 Jun 19 11:39 test
lrwxrwxrwx   1 sexton us_cms   57 Jun 19 11:39 tmp -> /uscms_data/d1/sexton/CMSSW/CMSSW_2_1_0_pre5/tmp.XpnS1euF

106 lxplus223> cat ~lsexton/.scramrc/symlinks
lib:/tmp/$(USER)/$(SCRAM_PROJECTNAME)/$(SCRAM_PROJECTVERSION)
tmp:/tmp/$(USER)/$(SCRAM_PROJECTNAME)/$(SCRAM_PROJECTVERSION)
bin:/tmp/$(USER)/$(SCRAM_PROJECTNAME)/$(SCRAM_PROJECTVERSION)

<lpcdt023.fnal.gov>

Other random useful commands:

scram build USER_CXXFLAGS=-g

cmsenv: aliased to eval `scramv1 runtime -csh`

addpkg <SubSystem/Package>

kserver_init

totalview: aliased to /afs/fnal/ups/totalview/v8_4/toolworks/totalview.8.4.0-0/bin/totalview

Provenance Dumping

edmProvDump CompositeKitSkim.root

-- SalvatoreRRappoccio - 19 Jun 2008

Edit | Attach | Watch | Print version | History: r4 < r3 < r2 < r1 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r4 - 2008-06-19 - SalvatoreRRappoccio
 
    • Cern Search Icon Cern Search
    • TWiki Search Icon TWiki Search
    • Google Search Icon Google Search

    Main 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