# Presentation: 576419

## E605/772/789/866 Analysis Package

- RECOVR (PRHIST)

- HMACHI
*initialize HBOOK*

- PRHIST
- histo’s

- CRUNCH
- RDREC
- goto lrtype

- READTP

- EVENTS
- skip spill?
- GETEV
- TRIGSEL
- UNPACK3
- FORMCHK
- ANALR
- S4COR
- TRACK
- FULLFIT
- HODOEFF
- TIMANA
- TRKDEF
-  DIMUSE
- EVFLAG
- PRANA
- PTUBEFF
- PIX
- DSTEVNT

- CNTNT

- EOSPIL
- BOREOS

- BORUN
- NEWRUN
- SURVEY, CERRUN, SORTAB, BOREOS

- TRACK
- DCTRIPS
- DCTRAX
- WCTRAX
- CHEFFIC
- TRKMON

- EORUN

- COMENT

- ANALR
- PTRUPK
- HODANA
- TUBANA
- QKADC
- TRIGANA
- PCHITS
- DCHITS

- UNPACK
- TRIG
- COREG
- TDC
- KADCAQ
- CWUPLI
- CEUPLI
- DSTUPK
- HDSTAT
- PCSTAT
- DCSTAT

- TUBES
- HODOS

- FINI

- COMMAND(igo)
*ffread cmds*

- ANALY(3,0)
- PRHIST

- INIT
- YINIT, HLIMIT
*zero ptrs*
*init subrout*

- ANALY(4,0)
- HISTDO

- 1/8/2009

- MJL - E866/E789/E772

## open stdout

- call INIT
- book hists, ntuples
- init constants
- book cuts
- init FARM
- open IO

- call COMAND
- get commands
- e.g. #evts to analyze, tweek values, etc.

- call CRUNCH
- analyze various logical records

- call FINI
- sum FARM
- print stats
- close ntuple

- write hrfile & print hists

- stop FARM

- ANALY

- EVENTS

- make sure run & spill are selected for analysis

- get event from buffer

- unpack etm & get run# & spill#

- new run or spill?

- trigsel
- cut on trigger

- fastana
- (farm only)

- call:
- FORMCHK
- ANALR(UNPACK)
- FASTSI
- TRACK
- CALORIM
- SORTRK
- DIMUSE
- PIX
- SIPIX

- save event data

- read BOR or EOS data from rasputin file

- call BOR or EOSPIL to process it

- restore event data

- on farm1 pack event (~20) into buffer & send out to class2 nodes

- write event that passes all cuts to DST

- yes

- no

- 1/8/2009

- MJL - E866/E789/E772

## DIMUSE

- set up for certain PID cut (or none)

- loop over JACTRAKS

- get PID as desired  (e.g. from mubits and/or calorimeter), if no PID cut track

- momentum cut
- 5 < pyz < 1000 GeV

- cut sta-1 #planes 4

- get runshft bmx0,bmy0
- (from fastsi or dst)

- swim thru SM123 to tgt (PBSWIM), cut track if error

- call sitrax
- cut track if no silicon y-uv track

- pick best y-uv sitrax
- cut track unless only one

- count # h,mu,e tracks

- make fast imp. par cut on hh if desired

- require at least 2 trks or 2  trks, etc.

- loop over pairs of trks

- optionally require pair satisfy PID for tbits that are on

- make loose ztgt cut (<8.5”)

- require certain #hits in silicon trk (6)

- unlike-sign pair?

- determine DCA

- calc. zvtx & imp par based on y-uv fit

- make vertex cuts

- make imp par cuts

- get cal. energies

- reswim to vertex point (optional)

- construct physical quantities – mass, xF, etc.

- fill hists & ntuples

- like-sign

- 1/8/2009

- MJL - E866/E789/E772

## Brief Summary of E866/NuSea Analysis Software - MJL 10/24/08 

- ============================================================
-  code is maintained in CMZ
-  last ran on HP-UX around 2000
-  unclear how to get out of CMZ now?
-  a CAR file is an ascii transcription of a CMZ file
-  I have e866v13.car and mc866v11+.car
-  cmzlogon.kumac - file loaded when CMZ starts
-  reads user.cmz (code changed from standard) and e866v13.cmz (standard code) –
-  sets various switches, e.g. "select hp" - define compiler switches for Unix type
-  newlib - creates library, uses "cflib -p" - link - uses external script ("l866") to make executable
-  similar scheme for simulation code
-  its own cmzlogon.kumac
-  reads mc866v11+.cmz and user.cmz

*and see, http://p25ext.lanl.gov/e906/e906.html*

- 1/8/2009

- MJL - E866/E789/E772

##  l866 - script to link executable 

-  l866 - script to link executable
-  compiles kudef.cdf with Kuip (command definitions for runtime)
-  links to libuser.a (made by CMZ above)
-  links to libtrigger.a (made where?)
-  links to libbufio.a (E866 IO library, only needed to read 8mm tapes?)
-  links to many CernLibs: packlib, grafX11, kernlib, packlib
-  run - script to run program with certain inputs & outputs
-  defines data or dst input file
-  defines dst output, histogram output, ntuple output files
-  defines trigger matrix dat directory
-  trigger matrix file - profile (apertures)
-  SM12 field maps - SM3 field map
-  survey (geometry)
-  runs executable (dimu)
-  with input from "in" file (run time commands)

- 1/8/2009

- MJL - E866/E789/E772

## Cookbook for building and running E866/NuSea Analysis & Simulation Software - MJL - 1 November 2008

- ==========================================================
- see http://p25ext.lanl.gov/e906/e906.html
- analy - analysis
- ----------------
- cd analy/
- mkdir src
- cmz
- newexe
- exit
- nohup nice run >& run.log &
- paw
- hi/fi 1 run.his
- hi/pl 1376(20:100)

- 1/8/2009

- MJL - E866/E789/E772

## notes:

- * newexe uses:
-   - e866v13.cmz (base), user.cmz (fixes)
-   - libbufio, libtrigger & cernlibs
-   - l866 - script to link
- * run analyzes a raw data file:
-   - reads nk3397s.tap (short lxf raw data file)
-   - switches set in cmz: cd switches; vi switch
-     - JACTRACK, ETM on
-     - READDST, RETRACK off

- 1/8/2009

- MJL - E866/E789/E772

## buffio - data io library

- ------------------------
- cd buffio/
- * compile & build as in build.csh
- trigger - trigger library
- -------------------------
- cd trigger/
- cmz
- exe trigger#arc
- exe trigger#library
- swap - to swap bytes of tap or dst file if necessary
- ----------------------------------------------------
- cd swap/
- makefile
- see run

- 1/8/2009

- MJL - E866/E789/E772

## mclxf - simulation

- ------------------
- cd mclxf/
- mkdir src
- cmz
- newexe
- exit
- nohup nice run >& run.log &
- * newexe uses:
-   - mc866b11+.cmz, user.cmz
-   - libbufio, libtrigger & cernlibs
-   - lmc866 - script to link

- 1/8/2009

- MJL - E866/E789/E772

## environment

- -----------
- Scientific Linux 4.7 on a IBM Thinkpad T42p
- Linux slinux_mjl 2.6.9-78.0.1.EL #1 Tue Aug 5 12:35:58 CDT 2008 i686 i686 i386 GNU/Linux
- gcc version 3.4.6 20060404 (Red Hat 3.4.6-10)
- paw - Version 2.14/04      12 January 2004
- cmz - CMZ Code Manager version  1.50/14  (21/01/99)
- directories
- -----------
- analy - analysis
- mclxf - simulation
- buffio - io library
- trigger - trigger library
- dat - various supporting data files (e.g. surveys)
- map - magnet field maps
- swap - byte swapping program for data files (little vs big endian)
- trig - ?trigger files?
- car2cvs - cmz -> cvs program from Atlas (not working yet)
- dedx - VonGinneken dE/dx program and old files

- 1/8/2009

- MJL - E866/E789/E772

## other

- -----
- * to see what libraries you need to link to:
-   -get any small/simple dummy.f file
-   - g77 -v dummy.f
-   - ouput will show what libraries g77 likes to use
-   - put those in your link file
-   - similarly for gfortran (which the CERN libraries used)
- * magnet maps are in a machine/fortran dependent format
-   - use runb,bin.f to read ascii version and convert to binary version on your
-     machine if necessary
- * car files are ascii versions of cmz files

- 1/8/2009

- MJL - E866/E789/E772

##  E789 ANALYSIS NOTE

-                  **JACTRACK CONTENTS** - MJL, 13 NOV 1990
-       DST TRACK BANK:                       TRACE BANK:
- ABC(JTRACK(I)+1)=XM3B               ------\   ABC(JTRACK(I)+JTRACE)=TRACFLG
-              +2)=YM3B       		|         JTRACE+1)=XTGT ----\
-              +3)=ZM3B               	|                       +2)=YTGT     |
-              +4)=THETAX1          	|                       +3)=ZTGT     + iterated
-              +5)=THETAY1           	|                       +4)=TANXT    | swim
-              +6)=THETAX2  		|                       +5)=TANYT ---/
-              +7)=THETAY2    		+ 18-plane       +6)=BMX0 ---\ runshft
-              +8)=C.L.       		|   fit                 +7)=BMY0 ---/
-              +9)=NDF        		|                       +8)= MT
-              +10)=CHISQ/NDF 	|                       +9)= MT
-              +11)=PM3       		|                       +10)= MT
-              +12)=QUALITY   		|                       +11)=XTGT ---\
-              +13)=CHBITS    		|                       +12)=YTGT    |
-              +14)=HDBITS 	                  ---/                       +13)=TANXT   |
-              +15)=ID BITS 	                 -----------\              +14)=TANYT   |
-              +16)=QT (total energy)  	         |              +15)=Y@MSCAT |
-              +17)=EM Fraction                               + calor-    +16)=Y@236"  + non-iterated
-              +18)=E1 Fraction                                | imeter    +17)=Y@176"  | swim
-              +19)=OVL (overlapping)                    -/                +18)=Y@104"  |
-              +20)=save for later use                                       +19)=Y@-40" -/
-                                                                                          +20)=DIMASS
-         KINEMATICS:                                         CERENKOV:
- ABC(JTRACK(I)+JKINEM)=PM12      ABC(JTRACK(I)+JCEREN)=CERENKOV-ID
-              +JKINEM+1)=PT                          +1)=CERENKOV-CL
-                     +2)=THTCM                          +2)=#photons match track
-                     +3)=PHI                                 +3)=#photons in event
-                     +4)=???                                 +4)=???

- 1/8/2009

- MJL - E866/E789/E772

## ntuple contents

- C *** SM3 variables ***
- C x3p/n         x of track at sm3 for particle (u/d)
- C y3p/n         y  "   "    "  "   "      "      "
- C z3p/n         z  "   "    "  "   "      "      "
- C tnx3p/n       Tangent of theta x at sm3 (incomming)
- C tny3p/n          "     "   "   y  "  "       "
- C tny3pp/n         "     "   "   y  "  "  (out going)
- C p3p/n         Particle Momenta at sm3 **IN THE YZ PLANE**
- C
- C *** Target variables--Uniterated ***
- C xplus/minus   x intercept of track at target
- C yplus/minus   y      "     "   "    "    "
- C zunin         z of closest approach of tracks near target
- C
- C *** Y values along the way ***
- C y86p/n        y at  86 in
- C y104p/n       "  " 104 in
- C y236p/n       "  " 236 in
- C
- C *** Target variables--Iterated***
- C xt            x position of interaction
- C yt            y     "    "      "
- C zt            z     "    "      "
- C tnxtp/n       Tangent of theta x
- C tnytp/n          "     "   "   y
- C ptgtp/n       Momentum at target **IN THE YZ PLANE**
- C ptxyp/n       transverse momentum at target
- C
- C *** number of  tracks ***
- C mutrak        number of muon tracks in event

- C *** Kinematic dimoun event variables ****
- C pt            Transverse momenta
- C dimom         momenta of the dimuon pair
- C xf, x1, x2    xf, x1, x2
- C am            invariant mass of dimuon pair
- C pphi          Production phi in C-S frame
- C dphi          Decay phi in C-S frame
- C dtheta        Decay Theta in C-S  frame
- C
- C *** Event data ***
- C kevcnt        event number
- C hour          time in hours
- C day           time in days
- C tbin          trigger bits words 2, 3 (numbered from 0)
- C               inputs to the triggers
- C tbraw         trigger bit words 4, 5 (numbered from 0)
- C               raw triggers
- C tbpre         trigger bit words 6, 7 (numbered from 0)
- C               prescaled triggers
- C tbtgt         trigger bit word 11 (numbered from  0)
- C               target position from trigger bits
- C       Note on trigger bits:  The bits are packed into the lower
- C               16 bits of int*4.  In the case of row wise ntuples,
- C               these values are then floated into real*4 values which
- C               are then entered into the ntuple.
- C tbraw_ck      Don K.'s reconstructed tbraw bits
- C rfscal        rfscaler
- C nhodfir       number of hodoscope hits
- C nevlen        raw event length
- C nroad         number of matrix roads
- at station 3 for dump track

**ntuple contents**

- 1/8/2009

- MJL - E866/E789/E772

## ntuple contents - continued

- C *** Spill data ***
- C irun          run number
- C kspill        spill number
- C egs           egs
- C sem           sem6 counts
- C semsb         sem6  and not  busy
- C amon          amon
- C amonsb        amon and not busy
- C live          live time (sem6sb/sem6)
- C x134l/r/lr    counts in x134l,r,lr
- C bpmx,y        bpmx,y
- C bpmxi,yi      bpmxi,yi
- C lamb4         Counts in lambda/4
- C duty          Duty factor
- C tbrawh        MJL simple reconstructed tbraw bits
- C tgt           Target position from target position scaler
- C pa1,2,3,4     number of physA1/2/3/4 triggers in spill
- C ic3           ic3
- C ic3sb         ic3sb
- C tfi           tfi
- C tgo           tgo
- C goodsp        1=spill is good, 0=spill is bad
- C likesn        1=analysis done on like sign pairs, 0=opposite sign
- C cbm           beam cerenkov adc for intime bucket
- C cbmsum        beam cerenkov adc sum
- C cbmbavg       beam cerenkov average over outtime buckets
- C

- C *** Monte Carlo data--all quantities are thrown/generated ***
- C amth          thrown mass
- C xfth             "   xf
- C ptth             "   pt
- C [x|y|z]vth       "   vertex location
- C p[x|y|z][1|2]th
- C                   thrown x/y/z momenta of track 1/2
- C p3yz[1|2]th       generated yz momenta of track 1/2 at sm3 (compare
- C                   with p3[p|n])
- C p3[x|y|z][1|2]th  generated x/y/z momenta of track 1/2 before sm3
- C tn3yp[1|2]th      generated yz tangent AFTER sm3 (before can be found
- C                   from p3y1th/p3z1th)
- C [x|y|z]3[1|2]th   generated x/y/z location for track 1/2 at sm3 bend
- C                   plane
- C p[1|2]abs[1..8]th generated absolute momenta for track 1/2 before
- C                   entering absorber section 1-8 (8 is actually just
- C                   after tha absorber)
- C costth            thrown cos(theta)
- C pphith               "   production phi
- C dphith               "   decay phi
- C weight[1|2]       user defined quantaties (weights)

**ntuple contents - continued**

- 1/8/2009

- MJL - E866/E789/E772

## ntuple contents - continued

- C l3bit         level 3 result bits (0-7)
- C               0 - tagging-only mode
- C               1 - abort
- C               2 - special test mode
- C               3 - passed due to prescale
- C               4 - passed mass cut
- C               5 - passed pt cut
- C               6 - passed xf cut
- C               7 - passed other physics cut
- C am_l3t        maximum target mass from level 3
- C pt_l3t        maximum target pt from level 3
- C xf_l3t        maximum target xf from level 3
- C nt_l3t        number of target tracks from level 3
- C am_l3d        maximum dump mass from level 3
- C pt_l3d        maximum dump pt from level 3
- C xf_l3d        maximum dump xf from level 3
- C nt_l3d        number of dump tracks from level 3

- C   tracks 1 & 2 below are those that made the maximum mass
- C p1_l3         momentum of target track 1
- C p2_l3         momentum of target track 2
- C p1_l3d        momentum of dump track 1
- C p2_l3d        momentum of dump track 2
- C ty1_l3        thetay of target track 1
- C ty2_l3        thetay of target track 2
- C ty1_l3d       thetay of dump track 1
- C ty2_l3d       thetay of dump track 2
- C y11_l3        y at station 1 for target track 1
- C y21_l3        y at station 2 for target track 1
- C y31_l3        y at station 3 for target track 1
- C y12_l3        y at station 1 for target track 2
- C y22_l3        y at station 2 for target track 2
- C y32_l3        y at station 3 for target track 2
- C y11_l3d       y at station 1 for dump track 1
- C y21_l3d       y at station 2 for dump track 1
- C y31_l3d       y at station 3 for dump track 1
- C y12_l3d       y at station 1 for dump track 2
- C y22_l3d       y at station 2 for dump track 2
- C y32_l3d       y

**ntuple contents - continued**

- 1/8/2009

- MJL - E866/E789/E772