Muon Reconstruction Tutorial Tiesheng Dai, Steven Goldfarb Dec. 18-19, 2008 at Boston Univ. US Muon...

27
Muon Reconstruction Tutorial Tiesheng Dai, Steven Goldfarb Dec. 18-19, 2008 at Boston Univ. US Muon Alignment and Calibration Software Workshop 1.Find raw data; 2.Use ATHENA for muon reconstruction; 3.Look calibration NTUPLEs.

Transcript of Muon Reconstruction Tutorial Tiesheng Dai, Steven Goldfarb Dec. 18-19, 2008 at Boston Univ. US Muon...

Muon Reconstruction Tutorial

Tiesheng Dai, Steven GoldfarbDec. 18-19, 2008at Boston Univ.

US Muon Alignment and Calibration Software Workshop

1.Find raw data; 2.Use ATHENA for muon reconstruction;3.Look calibration NTUPLEs.

Find Raw Data

• CERN online: /castor/cern.ch/grid/atlas/DAQ/2008, /castor/cern.ch/grid/atlas/DAQ/M7 for May, June and early July 2008 data

• CERN offline, where raw data are organized as /castor/cern.ch/grid/atlas/atlasdatadisk/data08_X/Y (X = 1beammag, calib, cos, cosmag, cvalid and idcomm, Y = RAW for raw data, AOD, ESD, CBNT, TAG … for reco.). nsls, rfdir and rfcp to list and copy CASTOR file.

• AGLT2, Muon Data (MDT+CSC+TGC+RPC+TRIG) only: /pnfs/aglt2.org/data/daits/mdaq/ (all files on DISK), ls and dir to list DCACHE file and dccp for copy file.

• BNL, Muon Data only and only single run 91060 at DCACHE: /pnfs/usatlas.bnl.gov/u06/daits/mdaq/.

• BU, Muon Data only and only single run 91060 at NFS: /data4/bu/daits/mdaq/

• Get more information about raw data and run at http://atlas-runquery.cern.ch/

Using DQ2 to Find Raw Data

• CERN : /afs/cern.ch/atlas/offline/external/GRID/ddm/DQ2Clients/setup.[c]sh

• AGLT2 : $LCG_ENV/grid_env.[c]sh and $DQ2_ENV/setup.[c]sh

• BNL : /afs/usatlas.bnl.gov/lcg/current/etc/profile.d/grid_env.[c]sh and /afs/usatlas.bnl.gov/Grid/Don-Quijote/DQ2Clients/setup.[c]sh, define GLOBAL variable DQ2_LOCAL_SITE_ID as BNL-OSG2_DATATAPE

• BU : Please talk to manager for details if needed.

Setup DQ2

Need GRID Certificate (obtain at http://www.doegrids.org/) Obtain an ATLAS voms-enabled proxy by voms-proxy-init -voms atlas

https://twiki.cern.ch/twiki/bin/view/Atlas/WorkBookDQ2

List dataset:dq2-ls –f data08_cos.00091060.physics_TGCwBeam.daq.RAW.o4Copy dataset:dq2-get data08_cos.00091060.physics_TGCwBeam.daq.RAW.o4Warning: Need lots of space to copy RAW data and takes time!

Support

All scripts used in this tutorial are supported for CERN Tier0, BNL Tier1, AGLT2 and BU Tier2/3.

• AGLT2 : ssh -Y myusername@AssignedNodeForYou OR ssh -Y [email protected] (X=1,2,3)

• CERN : ssh -Y [email protected] OR your CERN workstation with AFS supported.

• BNL : ssh -Y [email protected], then rterm -i

• BU : ssh -Y [email protected]

Login

You are encouraged to use CERN or BNL for tutorial. At BU Tier2, no package checkout (= not possible to make change).

Install ATHENA Muon Reconstruction

Install and checkout Muon Calibration Ntuple Package for later usage~daits/public/scripts/installProdMuonRec 14.5.0.1 -checkout MuonSpectrometer/MuonCalib/MuonCalibNtuple

Installed Folders

• cmthome : requirement file and initial setup scripts;• MuonSpectrometer : contain checkout packages;• InstallArea : contain libraries and links for user/checout

packages;• data08list : contain 2008 data file lists;• runCtrl : control datacard and full setup script;• job : Scripts to process data.

By default, ATHENA distribution kit from production team is used at Tier centers (option –KITDIR to point wanted kit location). If required AtlasProduction release is not installed on ATHENA kit, corresponding release will be installed under AtlasProduction in installation area (example on slide 10). Normally, one will see:

Processing Cosmic Ray Data

Process cosmic ray under installation area:mkdir test; cd test; ../job/run_using_local_disk ! 10will get CalibrationNtuple.root and muon NTUPLE ntuple.root

Two scripts to process data under fold job. run_using_default : read data file directly from its stored area, where CERN read from CASTOR, BNL and AGLT2 read from DCACHE, settings are default no writing ESD.run_using_local_disk : copy data files from CASTOR or DCACHE to local area (/tmp/username), where using DCACHE or CASTOR is demonstrated. Both script accept data input and number events to be processed as shown:

Good to Know Details forMuon Reconstruction

Installationfor example do by yourself(Script InstallProdMuonRec)

InstallProdMuonRec (1)

• Find out the installation side to locate ATHENA distribution kits and define proper environment and used commands;

• Under cmthome, create requirement file

Using ATHENA kit

ATHENA kit location

User install area

K Server for CVS checkout

• Setup cmt and do cmt config to make general setup scripts inside cmthome.

InstallProdMuonRec (2)

• Kill left over process from pacman, and do clean up;• If AtlasProduction release is installed both from user

and ATHENA kit, user installation will be used;• Obtain AFS token (KERBERS 4) if necessary.

• If package AtlasProduction is not in ATHENA distribution kit for the release, will use pacman to install it. For example, using private kit at AGLT2:

~/public/scripts/installProdMuonRec 14.5.0.1 -kitdir /afs/atlas.umich.edu/athena/

Install package AtlasProudction in installation area under AtlasProduction

CVSROOT and CMT command

• CERN :gserver:isscvs.cern.ch:/local/reps/atlas, cmt• BNL /afs/usatlas.bnl.gov/software/cvs, bnl_cmt• AGLT2 :kserver:atlas-sw.cern.ch:/atlascvs, cmt• BU Tier2 :kserver:atlas-sw.cern.ch:/atlascvs, cmt

AFS token (KERBERS 4) need to be obtained by using kinit -4 [email protected]

In case no AFS support for computers outside CERN, one could use ssh method (not recommended) : http://www.triumf.info/wiki/atlas-triumf/index.php/Set_up_CVS_accessWARNING: you will not get AFS token for your CERN login without password, you need to modify .ssh/config to enable password when login to CERN nodes with AFS home directory (could be painful).

AFS Token

InstallProdMuonRec (3)

• Checkout packages and compile them

• Find out packages need to be checked out and its tag. If user gives package without tag, latest tag in the release will be used.

Need proper ATHENA setup to try following things, do as following:1) /bin/sh if you are using csh/tcsh or you do not know your login

shell2) Go to your installation area3) source ./runctrl/setup.sh and get AFS token if necessary.

cmt show versions MuonSpectrometer/MuonReconstruction/MuonRecExamplegives used package tag in release from ATHENA kit and user installation.

cmt co –r MuonRecExample-01-01-20 MuonSpectrometer/MuonReconstruction/MuonRecExamplechecks out package (use bnl_cmt at BNL Tier1 please). To compile, do as following:1) Go to your installation area. Do: unset CMTPATH; source cmthome/setup.sh –tag=32,14.5.02) cd MuonSpectrometer/MuonReconstruction/MuonRecExample/cmt; source setup.sh; gmake

• Compile packages required by user.

InstallProdMuonRec (4)

• Get MuonDataRec_myTopOptions.py and modify it to use right input data file and turn off ESD writing.

• Generate run scripts for cosmic ray data processing.

• Find data file lists and link it.• Generate setup script accordingly, following is setup

script where package AtlasProduction is in ATHENA kit.

Processing Data By Yourself

• Make sure you are not using csh/tcsh, otherwise do /bin/sh (or if you do not know your login shell);

• Go to your favour location;• source yourInstallationArea/runCtrl/setup.sh• cp yourInstallationArea/runCtrl/MuonDataRec_myTopOptions.py .• Modify MuonDataRec_myTopOptions.py as you need.• athena.py –s MuonDataRec_myTopOptions.py

Want to know more about CASTOR at CERN, visit web page: https://twiki.cern.ch/twiki/bin/view/Atlas/WorkBookCastor

Want to know more about DCACHE at BNL and AGLT2, visit web pages: https://www.racf.bnl.gov/Facility/dcache/ and https://hep.pa.msu.edu/twiki/bin/view/AGLT2/DCacheNotes

Examples

Existing Controls

MuonDataRec_myTopOptions.py• ESD output flag : rec.doWriteESD = False• MDT segment T0 fit : muonRecFlags.doSegmentT0Fit = False• Alignment correction :

muonRecFlags.useAlignmentCorrections = True• Detector Control, such as CSC (run 91897 with CSC) :

muonRecFlags.doCSCs=False• Data inputs, following is how to read multiple data files:

athenaCommonFlags.BSRDOInput.set_Value_and_Lock([ ‘FILE1’, ‘FILE2’, ‘FILE3’, …, ‘FILEN’ ])

MuonRecFlags.py has more controls, change with care, it is under MuonSpectrometer/MuonReconstruction/MuonRecExample/python/

Rest examples, modified code can be found at ~daits/public/demo_for_14.5.0.1/

New Flag and Use SQLLite DB

Use SQLLite DB to obtain MDT calibration constants (useful for calibration constant validation using data) in MuonReadCalib.py at MuonSpectrometer/MuonReconstruction/MuonRecExample/python/

Add flag useMDTCalibSQLLite in MuonRecFlags.py at MuonSpectrometer/MuonReconstruction/MuonRecExample/python/

Add following lines after flag useAlignmentCorrection defination to introduce flag useMDTCalibSQLLite

change

Note: Must turn on flag and get sqllite.db from Ed Diehl and link from run area

Add Things to Calibration NTUPLE

1. Modify MuonEventNtupleBranch.h at MuonSpectrometer/MuonCalib/MuonCalibNtuple/MuonCalibNtuple/ Add newline “int dummyForTest;” before line “int eventNumber;”

2. Modify MuonEventNtupleBranch.h at MuonSpectrometer/MuonCalib/MuonCalibNtuple/src/ Add newline “branchCreator.createBranch( tree, "dummyForTest" , &dummyForTest, "/I“ );” before line “branchCreator.createBranch( tree, "eventNumber" , &eventNumber, "/I" );” Add newline “dummyForTest = 1;” before line “runNumber = eventInfo.runNumber();”

3. Compile (option –checkout no to ignore get AFS token): ~daits/public/scripts/installProdMuonRec 14.5.0.1 -checkout no -compile MuonSpectrometer/MuonCalib/MuonCalibNtuple

4. RUN : mkdir test; cd test; ../job/run_using_local_disk

5. Look calibration ntuple ~/public/scripts/generate_cppfile_for_calibNtuple CalibrationNtuple.root mytest more mytest.h:

WARNING: Be careful in changing include file, may has effect on other package

Got it!

Muon Calibration and AA Ntuple• Only MUON calibration NTUPLE will be produced officially in

production, where MUON (AA) NTUPLE is not the case. It is recommended that MUON calibration NTUPLEs are used for analysis.

• Recently, MOORE tracking are added into MUON calibration NTUPLE., where Muonboy tracking is not in 14.5.0.1 but has been put in. Segments from Muonboy are still not available but will be so in the near future.

Useful Documents1. Muon calibration ntuple documents :

https://twiki.cern.ch/twiki/bin/view/Atlas/MuonCalibNtuple2. Muon Spectrometer Nomenclature :

https://hep.pa.msu.edu/twiki/pub/AGLT2/MuonReco/MS_Naming.ppt3. Muon (AA) NTUPLE for raw data :

https://twiki.cern.ch/twiki/bin/view/Atlas/MuonCommRawDataAna4. Muon (AA) NTUPLE for MOORE tracking :

https://twiki.cern.ch/twiki/bin/view/Atlas/MooreNtuple5. MUON (AA) NTUPLE for Muonboy tracking :

http://atlas-samusog.web.cern.ch/atlas-samusog/muonboy/DocNtuples/CBNT_Muon.html

Start to Work on Calibration NTUPLEUse mytest as ROOT C++ filename as example for this talk

Generate mytest.h and mytest.C : Pickup your favor location, for

instance anal at installation area mkdir anal; cd anal

root -lTFile *my = new TFile(“../test/calibrationNtuple.root")my->ls()my->cd("PatternNtupleMaker")Segments->MakeClass(“mytest").q

~daits/public/scripts/generate_cppfile_for_calibNtuple ../test/CalibrationNtuple.root mytest

Modify mytest.h to include more ntuple files by replacing procedure mytest::mytest(TTree *tree) by :

or simply copy ~daits/public/muon_calib_ntup_demo/mytest.h

Simple Code for Calibration NTUPLE

Modify mytest.C ( cp ~daits/public/muon_calib_ntup_demo/mytest.C . )

Open new root file for output

Book histograms

Filling histograms

Write plots to root file

Make plot

Process Calibration NTUPLE

~daits/public/scripts/run_cppfile mytest one gets picture All_plots.pdf and root output file mytest.root

root -l.L mytest.Cmytest pp.Loop().q

Useful Tools for Calibration Ntuple

Many tools to look calibration NTUPLEs, if you want to use those tools, talk to MUON calibration people. For instance Ed Diehl has provided ROOT muonfixedid class to find a hit belongs to which MUON station. In muon calibration NTUPLE, hit ID is muonfixedid where detector type, station, eta and phi are coded as single number. To understand hit ID, one needs to decode it. Existing ROOT muonfixedid class does for you, get it from : ~daits/public/scripts/muonfixedid.h

~daits/public/scripts/checknt.sh to check and merge calibration NTUPLE (from Ed Diehl).

……

For Muon AA NTUPLEUse mytest as ROOT C++ filename as example for this talk

Similar procedure to look muon AA ntuple, generate mytest.h and mytest.C

root -lTFile *my = new TFile(“../test/ntuple.root")my->ls()CollectionTree->MakeClass(“mytest").q

~daits/public/scripts/generate_cppfile_for_muonNtuple ../test/ntuple.root mytest

Modify mytest.h and mytest.C, for simple example for ATHENA 14.5.0.1 one can get them from ~daits/public/muon_AA_ntup_demo/, to chain files, use TChain *f = new TChain("CollectionTree");

To process NTUPLES ~daits/public/scripts/run_cppfile mytest

WARNING: NTUPLE could be different from different ATHENA version

Contacts for Help

1. Muon software general issue : Rosy Nikolaidou, Stephane Willocq, Ed Moyse and Kevin Black;

2. MOORE reconstruction : Niels Van Eldik or Stephane Willocq3. Muonboy reconstruction : Saclay group [email protected]. General DB issue : Vakho Tsulaia or Emil Obreshkov 5. MDT COOL DB : Monica Verducci 6. MDT Calibration DB : Domizia Orestano 7. Calibration ntuple and software : Felix Rauscher and Edward Diehl8. MDT Alignment : Christoph Amelung 9. MDT Alignment software : Robert Harrington10.TGC : Masaya ISHINO 11.CSC : Woochun Park 12.RPC : Gabriele Chodini

Tiesheng Dai and Steven Goldfarb are also happy to answer questions.

Summary• Scripts are provided to do muon reconstruction from raw data,

where 4 sites (CERN Tier0, BNL Tier1, AGLT2 and BU Tier2) are supported;

• With single script installProdMuonRec, user will be able to install ATHENA, checkout packages, and compile packages after modifications. Also raw data file lists are given! Installed scripts run_using_default and run_using_local_disk allow user to process RAW data to produce muon calibration and AA ntuple;

• Examples to add user modifications to ATHENA are given;• Scripts generate_cppfile_from_calibNtuple and run_cppfile help

user to start muon calibration ntuple analysis and process ntuples.• Scripts generate_cppfile_from_muonNtuple and run_cppfile help

user to start muon AA ntuple analysis and process ntuples.

Wish the tutorial helps for your muon works and analysis

Finally

Merry Christmas and Happy New Year