Difference between revisions of "MuonCalib Tutorial"

From Atlas Wiki
Jump to navigation Jump to search
 
(55 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
==Muon calibration tutorial==
 
==Muon calibration tutorial==
Welcome to the ''Muon Calibration Page''! After doing this tutorial, you will be able to run Athena, make your ntuples containing segment information and use this ntuple to do Athena-independent analysis.
+
Welcome to the ''Muon Calibration Tutorial Page''! After doing this tutorial, you will be able to run Athena, make your ntuples containing segment information. This ntuple can then be used as input to do analysis with help of the skeleton analysis package provided. This analysis package ''CalibSegmentAnalysis'' relies heavily on the Calibration framework but is Athena independent.
 
 
  
 +
Much information on validation, calibration and alignment can be found at [http://muondoc.home.cern.ch/muondoc/Software/Database/ the MuonSpectrometer homepage].
 
==Introduction==
 
==Introduction==
  
Line 12: Line 12:
 
'''Calibration framework'''
 
'''Calibration framework'''
  
Link to Niels' stuff on calibration.  
+
A clear Wiki page on the Calibration Framework by Domizia and Niels can be found on the [https://uimon.cern.ch/twiki/bin/view/Atlas/MuonCalibrationFramework MuonCalibrationFramework Wiki]. At this site, the Calibration EDM is explained.
  
  
 
'''Why segments?'''
 
'''Why segments?'''
  
Maybe needed to explain the concept of segments.
+
Maybe needed to explain the concept of segments and the calibration EDM, is to be written (work in progress). A starting point of Calibration Segments and its scope in the Reconstruction EDM can be found in a presentation given by Zdenko during the ATLAS Muonweek september-2005 called [http://agenda.cern.ch/fullAgenda.php?ida=a057588 Calibration Segment Ntuple]
  
 +
==Getting started==
 +
In order to get started one should know that this field is prone to many changes over time. Backward compatibility is surely broken since the ntuple format changed a lot in the period of november 2005. The ntuple format is defined by the MuonCalib package (''MuonCalibNtuple''), and the analysis package needs a certain ntuple format to be able to fill the MuonCalib EDM classes offline. In the following sections, recipes will be provided for different kinds of ntuple formats.
  
==Making segment ntuples==
+
To summarize the procedure:
 +
* Choose your ntuple-format and wich version to run in
 +
* Follow the recipes below to make your ntuple, customize jobOption file where needed
 +
* Build the appropriate version of the CalibSegmentAnalysis package (depending on ntuple format)
 +
* Run your analysis, customize the analyse routine where needed
  
'''Setting up ATHENA'''
+
'''Different <font color=red>versions</font> of Ntuple Content'''
  
Making segment ntuples from scratch can be done with Athena running on release 10.5.0 or higher. It is recommended to run at the most recent release, in order to be up-to-date. This section covers working in release 11.0.0 . Since this release is not stalled at NIKHEF yet, it is recommended to work at CERN. If you do not have an ATLAS account yet you can get an account [https://uimon.cern.ch/twiki/bin/view/Atlas/WorkBookGetAccount here].  
+
Currently, there are two different formats of the Calibration Segment Ntuple, described in the following tables:
 +
* [[CalibSegmentNtupleContentA|Calibration Segment Ntuple Content A]]. Information on patterns, segments en Mdt hits. All segments appear twice on the ntuple since a refit-flag is performed during ntuple-writing. This ntuple should be obsolete since release 11.X.0.
 +
* [[CalibSegmentNtupleContentB|Calibration Segment Ntuple Content B]]. Information on patterns, segments and hits of all technologies (Mdt's containing extra calibration information, the other technologies are not yet fully implemented). No extra refit is performed, so no double segments. In addition, truth information and event information (run and event number) is available.
 +
* [[CalibSegmentNtupleContentC|Calibration Segment Ntuple Content C]]. Is non-existent at the moment. It is sure that one will be defined in the future, the difference with Ntuple Content B will be a better description of the other technology hits, and timing information on event-level.
  
* log on to ''lxplus'':
+
'''Which <font color=red>recipe</font> to use to make the Ntuple'''
<tt>ssh <username>@lxplus.cern.ch </tt>
 
* create a work area (here called ''11.0.0'')
 
<tt>mkdir 11.0.0</tt>
 
  
<tt>cd 11.0.0/</tt>
+
The different formats of Ntuples can be produced with different recipes. The following recipes sets up athena and guides you to running the Muon Calibration package. With this running you can proceed to the next section below.
* create a ''requirements'' file which should look like this:
+
* [[CalibSegmentNtupleRecipeA_1050|Recipe for Ntuple A in 10.5.0]] Works out-of-the-box <font color=red> though outdated </font>
<pre>
+
* [[CalibSegmentNtupleRecipeA_1100|Recipe for Ntuple A in 11.0.0]] Works out-of-the-box <font color=red> though outdated </font>
set          CMTSITE          CERN
+
* [[CalibSegmentNtupleRecipeB_1100|Recipe for Ntuple B in 11.0.0]] This recipe requires MuonCalib to be checked out of CVS and to be recompiled. This is a time-costly procedure, but the best available until a newer release is present. <font color=red> RECOMMENDED </font>
 +
* [[CalibSegmentNtupleRecipeB_11X0|Recipe for Ntuple B in 11.X.0]] This release has the new MuonCalib compiled so this should run out-of-the-box.
  
macro        ATLAS_DIST_AREA  "/afs/cern.ch/atlas/software/dist"
+
==A deeper look into the jobOptions==
macro        ATLAS_RELEASE    "11.0.0"
 
  
use          AtlasSettings v* $(ATLAS_DIST_AREA)
+
* For version 10.5.0: a good example of a ''jobOptions'' file that produces segment ntuples is provided in Domizia's public:
 +
<font color = red><tt> cp /afs/cern.ch/user/d/domizia/public/MuonCalib_files/myTopOptions.py .</tt></font>
 +
* For version 11.0.0: a good example of a ''jobOptions'' file that produces segment ntuples is provided in Zdenko's public:
 +
<font color = red><tt> cp /afs/cern.ch/user/z/zvankest/public/MuonCalib_files/myTopOptions.py .</tt></font>
  
path_remove  CMTPATH          ${PWD}
+
* you can customize this jobOption file to your own needs...
path_prepend CMTPATH          ${PWD}
+
<pre>
 +
Change the number of events in the ntuple
 +
Change the tracking software (Moore <-> MuonBoy, and Jochem's cosmic pattern finder package in the future)
 +
Change the muon-sample (note! The file should be present in your PoolFileCatalog):
 +
        in your run directory, add the file to your PoolFileCatalog by calling
 +
              pool_insertFileToCatalog <physical path of your favorite POOL file>
 +
        in your myTopOptions.py, replace the following line
 +
              PoolRDOInput = [ "rfio:/castor/*/*.pool.root" ]
 +
        by
 +
              PoolRDOInput = [ "<POOl file path>" ]
 
</pre>
 
</pre>
* build your CMT environment:
 
<tt>source /afs/cern.ch/sw/contrib/CMT/v1r18p20050501/mgr/setup.(c)sh</tt>
 
  
<tt>cmt config</tt>
+
From the ntuple produced, one can proceed Athena-independent.
  
<tt>source setup.(c)sh -tag=opt</tt>
+
==Segment analysis==
  
* the last command line must be typed in every time you open a new terminal. If you want to fill your ntuple with segments from ATLAS reconstructed muons check out the ''RecExCommon'' package. For other environments (such as CTB etcetera take a closer look at the [https://uimon.cern.ch/twiki/bin/view/Atlas/MuonCalibrationFramework MuonCalibrationFramework] page.
+
'''A little word about the Calibration Event Data Model (EDM)'''
<tt>cmt co Reconstruction/RecExample/RecExCommon</tt>                          (at head) or
 
  
<tt>cmt co -r RecExCommon-version Reconstruction/RecExample/RecExCommon</tt>   for your favorite version
+
The MuonCalibration-framework works with a Calibration EDM, which defines ''the objects'' used in the Calibration. The structure is more or less like this:
 +
* each event contains a certain number of ''Patterns''. Concider these as linked segments, as potential tracks, containing information such as the ''Chi Squared'' of the pattern, the ''track parameters (z0, r0, <math> \vartheta </math>, <math> \varphi </math>, q/p)''. These patterns are described in the class ''MuonCalib::MuonGlobalPattern''. Patterns are built from a number of ''segments''.
  
* build ''RecExCommon''
+
* a segment is described by ''MuonCalib::MuonCalibSegment'', which is basically a line segment which matches the hits stored in the segment. So segments describe the premature track at ''chamber level''. A line is given by a vector and a direction. This information can be found on the segment as well, in two co-ordinate systems: the ''global'' ATLAS co-ordinates and the ''local'' chamber co-ordinates.
<tt>cd Recontruction/RecExample/RecExCommon/RecExCommon-*/cmt </tt>
 
  
<tt>cmt config </tt>
+
* the hits on the segment are implemented as ''MuonCalib::XxxCalibHitBase'' 's with ''Xxx'' the technology which recorded the hits (i.e. Mdt, Tgc, Csc or Rpc). Each hitBase has their own dedicated content relevant for doing calibration; thus RPCs do ''not'' have drifttimes and MDTs do ''not'' provide timemeasurements. They do have common members such as (local en global) position and ''MuonCalib::MuonFixedId'' 's. Since the Calibration EDM classes are Athena-independent, the ''identifiers'' defined for the hit classes are decoupled from the ATLAS data-base (which is Athena-dependent).
  
<tt>source setup.(c)sh </tt>
+
In order to do an analysis on segment level from the ntuple, the content from the ntuple must be casted into the Calibration EDM. This can be done with help of a ''skeleton analysis package''.  
  
<tt>gmake </tt>
+
'''The CalibNtupleAnalysis package'''
  
* go to the ''run'' directory and load some auxilliary stuff:
+
Since there exists two ntuple formats, different versions of the ''CalibNtupleAnalysis package'' exist. Recipes to run the skeleton analysis are given here:
<tt>cd ../run/ </tt>
+
* [[CalibNtupleAnalysis1|CalibNtupleAnalysis-00-00-01]] Capable of processing ntuple format A
 +
* [[CalibNtupleAnalysis2|CalibNtupleAnalysis-00-00-02]] Capable of processing ntuple format B
  
<tt>source ../share/RecExCommon_links.(c)sh </tt>
+
* After a succesfull Run, you will be provided with the following files:
 
 
* now we can run Athena, provided to have the right ''jobOptions'' files. (The following command dumps the messages and writes them to the logfile.)
 
<tt>athena jobOptions.py | tee athena.log </tt>
 
 
 
'''Running on single muons samples'''
 
 
 
* a good example of a ''jobOptions'' file that produces segment ntuples is provided by Domizia:
 
<tt> cp /afs/cern.ch/user/d/domizia/public/MuonCalib_files/myTopOptions.py </tt>
 
 
 
* you can customize this jobOption file to your own needs...
 
 
<pre>
 
<pre>
Change the number of events in the ntuple
+
SegmentAnalysis.root              Containing the Histograms and SegmentDisplays generated by the  
Change the tracking software (Moore <-> MuonBoy)
+
                                  SegmentAnalysis framework. Note that one event may generate over
Change the muon-sample (note! The file should be in your PoolFileCatalog)
+
                                  100 SegmentsDisplays.
 
</pre>
 
</pre>
 
From the ntuple on, we can operate Athena-independent <<whew!!>>.
 
 
==Segment analysis==
 
 
The MuonCalibration-framework works with a Calibration EDM, which defines the objects used in the Calibration. The structure is more or less like this:
 
* each event contains a certain number of ''Patterns''. Concider these as potential tracks, containing information such as the ''Chi Squared'' of the pattern, the ''track parameters (z0, r0, <math>/theta</math>, <math> \phi </math>, q/p)''.
 
 
'''Setting up the analysis package'''
 
* go to your work space at your ATLAS account
 
<tt> cd 11.0.0/ </tt>
 
* get the CalibNtupleAnalysis package (in the future this can be checked out from the release):
 
<tt> cp ~/zvankest/public/CalibNtupleAnalysis.tar </tt>
 
 
<tt> tar -xvf CalibNtupleAnalysis.tar </tt>
 
 
 
 
'''Customizing your favorite analysis'''
 
'''Customizing your favorite analysis'''
  
A skeleton needs some 'meat'...
+
A skeleton needs some 'meat'... Some example routines will be provided:
 +
<pre>
 +
plotATLAS(MuonCalibSegment*)        Plots the hits on the segment in global coordinates. In the example
 +
                                    an extra feature is shown; one can select MDTchambers by stationtype
 +
                                    with a simple call on the MuonFixedId.
 +
dumpSegment(MuonCalibSegment*)      Dumps MdtCalibSegment information. Invaluable for debugging.
 +
refitSegment(MuonCalibSegment)      Refits the MdtCalibSegment with a DCSLFitter provided by the
 +
                                    Calibration framework.
 +
showSegment(MuonCalibSegment*)      Calls a simple eventdisplay in which the hits are drawn as drifcircles
 +
                                    and the segment as line. The displays can be written to a PSfile.
 +
circleResidual(MuonCalibSegment*)    Given the trackparameters and the hits on the segment, this routine
 +
                                    calculates the expected residuals by extrapolating the track in the
 +
                                    local y-z plane in which the driftradii of the hits are circles.
 +
stripResidual(MuonCalibSegment*)    Given the trackparameters and the hits on the segment, this routine
 +
                                    calculates the expected residuals by extrapolating the track in the
 +
                                    local x-y plane in which the RPC strips are the precision coordinates.
 +
</pre>

Latest revision as of 08:34, 5 December 2005

Muon calibration tutorial

Welcome to the Muon Calibration Tutorial Page! After doing this tutorial, you will be able to run Athena, make your ntuples containing segment information. This ntuple can then be used as input to do analysis with help of the skeleton analysis package provided. This analysis package CalibSegmentAnalysis relies heavily on the Calibration framework but is Athena independent.

Much information on validation, calibration and alignment can be found at the MuonSpectrometer homepage.

Introduction

Calibration

General information about the need of calibration in the MuonSpectrometer.


Calibration framework

A clear Wiki page on the Calibration Framework by Domizia and Niels can be found on the MuonCalibrationFramework Wiki. At this site, the Calibration EDM is explained.


Why segments?

Maybe needed to explain the concept of segments and the calibration EDM, is to be written (work in progress). A starting point of Calibration Segments and its scope in the Reconstruction EDM can be found in a presentation given by Zdenko during the ATLAS Muonweek september-2005 called Calibration Segment Ntuple

Getting started

In order to get started one should know that this field is prone to many changes over time. Backward compatibility is surely broken since the ntuple format changed a lot in the period of november 2005. The ntuple format is defined by the MuonCalib package (MuonCalibNtuple), and the analysis package needs a certain ntuple format to be able to fill the MuonCalib EDM classes offline. In the following sections, recipes will be provided for different kinds of ntuple formats.

To summarize the procedure:

  • Choose your ntuple-format and wich version to run in
  • Follow the recipes below to make your ntuple, customize jobOption file where needed
  • Build the appropriate version of the CalibSegmentAnalysis package (depending on ntuple format)
  • Run your analysis, customize the analyse routine where needed

Different versions of Ntuple Content

Currently, there are two different formats of the Calibration Segment Ntuple, described in the following tables:

  • Calibration Segment Ntuple Content A. Information on patterns, segments en Mdt hits. All segments appear twice on the ntuple since a refit-flag is performed during ntuple-writing. This ntuple should be obsolete since release 11.X.0.
  • Calibration Segment Ntuple Content B. Information on patterns, segments and hits of all technologies (Mdt's containing extra calibration information, the other technologies are not yet fully implemented). No extra refit is performed, so no double segments. In addition, truth information and event information (run and event number) is available.
  • Calibration Segment Ntuple Content C. Is non-existent at the moment. It is sure that one will be defined in the future, the difference with Ntuple Content B will be a better description of the other technology hits, and timing information on event-level.

Which recipe to use to make the Ntuple

The different formats of Ntuples can be produced with different recipes. The following recipes sets up athena and guides you to running the Muon Calibration package. With this running you can proceed to the next section below.

A deeper look into the jobOptions

  • For version 10.5.0: a good example of a jobOptions file that produces segment ntuples is provided in Domizia's public:

cp /afs/cern.ch/user/d/domizia/public/MuonCalib_files/myTopOptions.py .

  • For version 11.0.0: a good example of a jobOptions file that produces segment ntuples is provided in Zdenko's public:

cp /afs/cern.ch/user/z/zvankest/public/MuonCalib_files/myTopOptions.py .

  • you can customize this jobOption file to your own needs...
Change the number of events in the ntuple
Change the tracking software (Moore <-> MuonBoy, and Jochem's cosmic pattern finder package in the future)
Change the muon-sample (note! The file should be present in your PoolFileCatalog):
        in your run directory, add the file to your PoolFileCatalog by calling
              pool_insertFileToCatalog <physical path of your favorite POOL file>
        in your myTopOptions.py, replace the following line
              PoolRDOInput = [ "rfio:/castor/*/*.pool.root" ]
        by
              PoolRDOInput = [ "<POOl file path>" ]

From the ntuple produced, one can proceed Athena-independent.

Segment analysis

A little word about the Calibration Event Data Model (EDM)

The MuonCalibration-framework works with a Calibration EDM, which defines the objects used in the Calibration. The structure is more or less like this:

  • each event contains a certain number of Patterns. Concider these as linked segments, as potential tracks, containing information such as the Chi Squared of the pattern, the track parameters (z0, r0, , , q/p). These patterns are described in the class MuonCalib::MuonGlobalPattern. Patterns are built from a number of segments.
  • a segment is described by MuonCalib::MuonCalibSegment, which is basically a line segment which matches the hits stored in the segment. So segments describe the premature track at chamber level. A line is given by a vector and a direction. This information can be found on the segment as well, in two co-ordinate systems: the global ATLAS co-ordinates and the local chamber co-ordinates.
  • the hits on the segment are implemented as MuonCalib::XxxCalibHitBase 's with Xxx the technology which recorded the hits (i.e. Mdt, Tgc, Csc or Rpc). Each hitBase has their own dedicated content relevant for doing calibration; thus RPCs do not have drifttimes and MDTs do not provide timemeasurements. They do have common members such as (local en global) position and MuonCalib::MuonFixedId 's. Since the Calibration EDM classes are Athena-independent, the identifiers defined for the hit classes are decoupled from the ATLAS data-base (which is Athena-dependent).

In order to do an analysis on segment level from the ntuple, the content from the ntuple must be casted into the Calibration EDM. This can be done with help of a skeleton analysis package.

The CalibNtupleAnalysis package

Since there exists two ntuple formats, different versions of the CalibNtupleAnalysis package exist. Recipes to run the skeleton analysis are given here:

  • After a succesfull Run, you will be provided with the following files:
SegmentAnalysis.root               Containing the Histograms and SegmentDisplays generated by the 
                                   SegmentAnalysis framework. Note that one event may generate over
                                   100 SegmentsDisplays.

Customizing your favorite analysis

A skeleton needs some 'meat'... Some example routines will be provided:

plotATLAS(MuonCalibSegment*)         Plots the hits on the segment in global coordinates. In the example
                                    an extra feature is shown; one can select MDTchambers by stationtype
                                    with a simple call on the MuonFixedId.
dumpSegment(MuonCalibSegment*)       Dumps MdtCalibSegment information. Invaluable for debugging.
refitSegment(MuonCalibSegment)       Refits the MdtCalibSegment with a DCSLFitter provided by the 
                                    Calibration framework.
showSegment(MuonCalibSegment*)       Calls a simple eventdisplay in which the hits are drawn as drifcircles
                                    and the segment as line. The displays can be written to a PSfile.
circleResidual(MuonCalibSegment*)    Given the trackparameters and the hits on the segment, this routine
                                    calculates the expected residuals by extrapolating the track in the
                                    local y-z plane in which the driftradii of the hits are circles.
stripResidual(MuonCalibSegment*)     Given the trackparameters and the hits on the segment, this routine
                                    calculates the expected residuals by extrapolating the track in the
                                    local x-y plane in which the RPC strips are the precision coordinates.