Difference: WorkBookFWLiteExamples35X (1 vs. 6)

Revision 62010-04-27 - RogerWolf

Line: 1 to 1
 
META TOPICPARENT name="WorkBook"

3.5.3 Examples of FW Lite Macros

Line: 17 to 17
  For brevity the latest version is linked to the top of the page here.
Changed:
<
<
We also need to create a PAT-tuple (described in detail in WorkBookPATTuple):
>
>
We also need to create a PAT-tuple (described in detail in WorkBookPATTupleCreationExercise):
 
scram b -j 4

Revision 52010-04-27 - RogerWolf

Line: 1 to 1
 
META TOPICPARENT name="WorkBook"

3.5.3 Examples of FW Lite Macros

Line: 17 to 17
  For brevity the latest version is linked to the top of the page here.
Changed:
<
<
We also need to create a PAT-tuple (described in detail in WorkBookPAT):
>
>
We also need to create a PAT-tuple (described in detail in WorkBookPATTuple):
 
scram b -j 4

Revision 42010-03-29 - SalvatoreRRappoccio

Line: 1 to 1
 
META TOPICPARENT name="WorkBook"

3.5.3 Examples of FW Lite Macros

Line: 13 to 13
  In this page you will find working examples of FW Lite macros that can be used as starting points for your own analysis.
Changed:
<
<
To use this tutorial you must use the release described here. We also need to create a PAT-tuple (described in detail in WorkBookPAT):
>
>
To use this tutorial you must follow the procedure described here.

For brevity the latest version is linked to the top of the page here.

We also need to create a PAT-tuple (described in detail in WorkBookPAT):

 
Changed:
<
<
cmsenv cvs co PhysicsTools/PatAlgos/test/patLayer1_fromAOD_full_cfg.py scram b
>
>
scram b -j 4
 cmsRun PhysicsTools/PatAlgos/test/patLayer1_fromAOD_full_cfg.py

From there, we will have a file "PATLayer1_Output.fromAOD_full.root" to run over.

Changed:
<
<
The tutorials that follow are contained in PhysicsTools/PatExamples so we will now check out this module.

addpkg PhysicsTools/PatExamples V00-02-04
cmsenv
scram b
>
>
The tutorials that follow are contained in PhysicsTools/PatExamples.
 

Contents

Line: 91 to 87
  These correspond to the number of events that pass the muon pt, and MET cuts, respectively. This can be made as complicated as one desires and automatically keeps track of cut flows.
Changed:
<
<

Example 4: Accessing Conditions Database

>
>

Example 4: Realistic Example With First Data

This example will build upon the technology developed in the previous ones to create a full-functional analysis on first data and minbias MC. For further details on the events and event selections that follow, please see the following link:

To do this exercise, it will first be necessary to create a new PAT-tuple of the Minimum bias Monte Carlo:

cmsRun PhysicsTools/PatExamples/test/patLayer1_fromRECO_7TeV_firstdata_mc_cfg.py

Now, create a PAT-tuple of the Minimum Bias 7 TeV data:

Coming soon!!!

cmsRun PhysicsTools/PatExamples/test/patLayer1_fromRECO_7TeV_firstdata_cfg.py

We can then analyze the events using the analysis macro here. The configuration to run this example is found here.

This will perform a dijet selection on the events in question, and plot some jet ID variables. At the end of this FWLite job, you should see

Calo jet selection
     0 :            Calo Cuts        624
     1 :        Calo Kin Cuts         26
     2 :       Calo Delta Phi         14
     3 :          Calo Jet ID         12
     4 :              PF Cuts        off
     5 :          PF Kin Cuts        off
     6 :         PF Delta Phi        off
     7 :            PF Jet ID        off
PF jet selection
     0 :            Calo Cuts        off
     1 :        Calo Kin Cuts        off
     2 :       Calo Delta Phi        off
     3 :          Calo Jet ID        off
     4 :              PF Cuts        624
     5 :          PF Kin Cuts         57
     6 :         PF Delta Phi         25
     7 :            PF Jet ID         20

There should be histograms in the file "jetPlots.root".

Congratulations! You're commissioning!

Example 5: Accessing Conditions Database

  Coming soon!
Changed:
<
<

Example 5: Access to Runs, LuminosityBlocks, and their products

>
>

Example 6: Access to Runs, LuminosityBlocks, and their products

  This macro is a demonstration of the various ways to get at luminosity block and run information.

Revision 32010-03-08 - SalvatoreRRappoccio

Line: 1 to 1
 
META TOPICPARENT name="WorkBook"

3.5.3 Examples of FW Lite Macros

Line: 39 to 39
 

Example 1: the Bare Bones -- Plot PAT objects

Changed:
<
<
The first example of plotting using FWLite will be to plot PAT objects. The source for this can be found here. To run this example, type:
>
>
The first example of plotting using FWLite will be to plot PAT objects. The source for this can be found here. To run this example, type:
 
rehash
Line: 50 to 50
 

Example 2: Using python configuration

Changed:
<
<
The next example will be to use a python configuration to input parameters to our FWLite macro. The source for this can be found here. This is identical to the previous example, except that it now uses the python interpreter to input parameters to the FWLite macro:
>
>
The next example will be to use a python configuration to input parameters to our FWLite macro. The source for this can be found here. This is identical to the previous example, except that it now uses the python interpreter to input parameters to the FWLite macro:
  %SYNTAX{ syntax="cpp"}% // Get the python configuration
Line: 67 to 67
 PatBasicFWLiteAnalyzer_PyConfig PhysicsTools/PatExamples/bin/patBasicFWLiteAnalyzer_PyConfig_fwlite.py
Changed:
<
<
This python configuration is, for the moment, extremely simple for demonstration and can be found here.
>
>
This python configuration is, for the moment, extremely simple for demonstration and can be found here.
 

Example 3: Using Selectors

Line: 75 to 75
  More details about Selectors can be found in SWGuidePATSelectors.
Changed:
<
<
This particular example will create a "simple" W selector that will select events with muons with pt above 20 GeV/c, and MET above 20 GeV/c. The source is found here. To run this, type
>
>
This particular example will create a "simple" W selector that will select events with muons with pt above 20 GeV/c, and MET above 20 GeV/c. The source is found here. To run this, type
 
PatBasicFWLiteAnalyzer_Selector PhysicsTools/PatExamples/bin/patBasicFWLiteAnalyzer_Selector_fwlite.py
Changed:
<
<
The new configuration is slightly more complicated than before and can be found here.
>
>
The new configuration is slightly more complicated than before and can be found here.
  At the end of the job should be a snippet like this:

Revision 22010-03-08 - SalvatoreRRappoccio

Line: 1 to 1
 
META TOPICPARENT name="WorkBook"

3.5.3 Examples of FW Lite Macros

Line: 13 to 13
  In this page you will find working examples of FW Lite macros that can be used as starting points for your own analysis.
Deleted:
<
<
You can also visit FWLite Executable, an introduction to FWLite using executables.
 To use this tutorial you must use the release described here. We also need to create a PAT-tuple (described in detail in WorkBookPAT):
Line: 29 to 27
 The tutorials that follow are contained in PhysicsTools/PatExamples so we will now check out this module.
Changed:
<
<
addpkg PhysicsTools/PatExamples
>
>
addpkg PhysicsTools/PatExamples V00-02-04
 cmsenv scram b
Line: 41 to 39
 

Example 1: the Bare Bones -- Plot PAT objects

Changed:
<
<
The first example of plotting using FWLite will be to plot PAT objects. The source for this can be found here. To run this example, type PatBasicFWLiteAnalyzer at the command line (after compiling as described above).
>
>
The first example of plotting using FWLite will be to plot PAT objects. The source for this can be found here. To run this example, type:

rehash
PatBasicFWLiteAnalyzer

(the "rehash" need only be done once after compilation of a new release).

 

Example 2: Using python configuration

Added:
>
>
The next example will be to use a python configuration to input parameters to our FWLite macro. The source for this can be found here. This is identical to the previous example, except that it now uses the python interpreter to input parameters to the FWLite macro:

<!-- SyntaxHighlightingPlugin -->
// Get the python configuration
  PythonProcessDesc builder(argv[1]);
  edm::ParameterSet const& fwliteParameters = builder.processDesc()->getProcessPSet()->getParameter<edm::ParameterSet>("FWLiteParams");

  // Now get each parameter
  edm::InputTag muonLabel( fwliteParameters.getParameter<edm::InputTag>("muonSrc") );
<!-- end SyntaxHighlightingPlugin -->

The file now takes an additional input argument on the command line, which is the location of the python configuration

PatBasicFWLiteAnalyzer_PyConfig PhysicsTools/PatExamples/bin/patBasicFWLiteAnalyzer_PyConfig_fwlite.py

This python configuration is, for the moment, extremely simple for demonstration and can be found here.

 

Example 3: Using Selectors

Added:
>
>
This example will show some more advanced features of the framework. Here we will be using an EventSelector to make the selection, rather than doing it in the "main loop". This will allow us to keep track of statistics of the event selection.

More details about Selectors can be found in SWGuidePATSelectors.

This particular example will create a "simple" W selector that will select events with muons with pt above 20 GeV/c, and MET above 20 GeV/c. The source is found here. To run this, type

PatBasicFWLiteAnalyzer_Selector PhysicsTools/PatExamples/bin/patBasicFWLiteAnalyzer_Selector_fwlite.py

The new configuration is slightly more complicated than before and can be found here.

At the end of the job should be a snippet like this:

     0 :              Muon Pt         22
     1 :                  MET         86

These correspond to the number of events that pass the muon pt, and MET cuts, respectively. This can be made as complicated as one desires and automatically keeps track of cut flows.

 

Example 4: Accessing Conditions Database

Changed:
<
<

Example 5: Running on real data

>
>
Coming soon!
 
Changed:
<
<

Example 6: Access to Runs, LuminosityBlocks, and their products

>
>

Example 5: Access to Runs, LuminosityBlocks, and their products

  This macro is a demonstration of the various ways to get at luminosity block and run information.
Changed:
<
<
>
>
%SYNTAX{ syntax="cpp"}%
 #if defined(CINT) && defined(MAKECINT) #include "DataFormats/FWLite/interface/Handle.h" #include "DataFormats/FWLite/interface/Event.h"
Line: 103 to 147
  std::cout << "Run " << r.id() <<std::endl; } }
Changed:
<
<
>
>
%ENDSYNTAX%
 

Review status

Revision 12010-03-08 - SalvatoreRRappoccio

Line: 1 to 1
Added:
>
>
META TOPICPARENT name="WorkBook"

3.5.3 Examples of FW Lite Macros

<!-- Enter an integer between 0 (zero) and 5 after the word COMPLETE, below, to indicate how complete the page/topic is; 0 means empty, 1 is for very incomplete, ascending to 5 for complete.  -->
Complete: 2
Detailed Review status

Goals of this page:

In this page you will find working examples of FW Lite macros that can be used as starting points for your own analysis.

You can also visit FWLite Executable, an introduction to FWLite using executables.

To use this tutorial you must use the release described here. We also need to create a PAT-tuple (described in detail in WorkBookPAT):

cmsenv
cvs co PhysicsTools/PatAlgos/test/patLayer1_fromAOD_full_cfg.py
scram b
cmsRun PhysicsTools/PatAlgos/test/patLayer1_fromAOD_full_cfg.py

From there, we will have a file "PATLayer1_Output.fromAOD_full.root" to run over.

The tutorials that follow are contained in PhysicsTools/PatExamples so we will now check out this module.

addpkg PhysicsTools/PatExamples
cmsenv
scram b

Contents

Example 1: the Bare Bones -- Plot PAT objects

The first example of plotting using FWLite will be to plot PAT objects. The source for this can be found here. To run this example, type PatBasicFWLiteAnalyzer at the command line (after compiling as described above).

Example 2: Using python configuration

Example 3: Using Selectors

Example 4: Accessing Conditions Database

Example 5: Running on real data

Example 6: Access to Runs, LuminosityBlocks, and their products

This macro is a demonstration of the various ways to get at luminosity block and run information.

#if !defined(__CINT__) && !defined(__MAKECINT__)
#include "DataFormats/FWLite/interface/Handle.h"
#include "DataFormats/FWLite/interface/Event.h"

#include "DataFormats/FWLite/interface/LuminosityBlock.h"
#include "DataFormats/FWLite/interface/Run.h"
#include "DataFormats/Luminosity/interface/LumiSummary.h"
#endif

#include "TFile.h"


void print_data() {
   TFile file("SomeData.root");

   fwlite::Event ev(&file);
   fwlite::Handle<LumiSummary> summary;

   // We can get run and luminosity blocks from events as well as associated products
   // All this works for ChainEvent and MultiChainEvent as well, not just on one  
   for(ev.toBegin(); !ev.atEnd(); ++ev) {
      // We can get the Luminosity block ID from the event
      std::cout << " Luminosity ID " << ev.getLuminosityBlock().id() << std::endl;
      // or the Run ID from the event
      std::cout <<" Run ID " << ev.getRun().id()<< std::endl;
      // We can get the Run ID from the luminosity block we got from the event
      std::cout << "Run via lumi " << ev.getLuminosityBlock().getRun().id() << std::endl;
      // We can get the integrated luminosity (or any luminosity product) from the event
      summary.getByLabel(ev.getLuminosityBlock(),"lumiProducer");
      std::cout << " Inst.  Luminosity = " << summary->avgInsDelLumi()<<std::endl;
   }

   // We can also loop over luminosity blocks themselves, same as events
   fwlite::LuminosityBlock ls(&file);
   for(ls.toBegin(); !ls.atEnd(); ++ls) {
      summary.getByLabel(ls,"lumiProducer");
      std::cout  << ls.id() << " Inst.  Luminosity = " << summary->avgInsDelLumi() << std::endl;
      // And get the associated run from this lumi
      std::cout << "Run from lumi " << ls.getRun().id() << std::endl;
   }

   // And of course do the same for runs.
   fwlite::Run r(&file);
   for(r.toBegin(); !r.atEnd(); ++r) {
      std::cout << "Run " << r.id() <<std::endl;
   }
}

Review status

<!-- Add your review status in this table structure with 2 columns delineated by three vertical bars. Add comments for editing, reviewing, etc -->

Reviewer/Editor and Date (copy from screen) Comments
YourName - 14 Mar 2006 What you did (e.g., created page, reviewed, edited, added/answered questions or comments, etc.) and/or what you think needs to be done next (e.g., "needs review by ...", "still needs content on subject x", etc.)

<!-- Here the "responsible" is the contact person for maintenance of the page - often initially the page author -->
<!-- The "review" person is the most recent person to carry out a full review of the page  - on this field please include the date in the format shown -->
Responsible: SalvatoreRoccoRappoccio
Last reviewed by: BenediktHegner - 21 Jun 2009

-- SalvatoreRoccoRappoccio - 08-Mar-2010

 
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