Babar logo
HEPIC E,S & H Databases PDG HEP preprints
Organization Detector Computing Physics Documentation
Personnel Glossary Sitemap Search Hypernews
Unwrap page!
Det. Search
Who's who?
Intern. region
Vertex Tracker
Drift chamber
Run Coordination
Contact Experts
Shift Takers Info
Operations Manual
Electronic Logbook
Ops Hypernews
Shift Signup
Check this page for HTML 4.01 Transitional compliance with the
W3C Validator
(More checks...)

Useful software for EMC commissioner

  1. How to reproduce OEP monitoring plots
  2. How to reproduce OPR monitoring plots
  3. Other useful things
Note that this page assumes a certain familiarity with the BaBar software, namely being able to set up test releases, and use tcl files to configure jobs.

Anything in green is a command which you should type in. Other significant things, such as the names of packages, modules, files or directories are written in red . Lines of code to be changed or written are in blue.

How to reproduce OEP monitoring plots (EmcOepDiag)

The OEP monitoring plots that the EMC expert shifter looks at (found here) are produced from hbook files made by the module EmcOepDiag, which is in the package EmcOepMon. Hbook files for each run are produced by the FastMonitoring running in IR2, and these can be found in the directory:
(only visible from machines on the IR-2subnet, such as bbr-dev101).
[NB: some good instructions on how to update reference plots for the DQM shifter can be found here.]

The postscript files which the EMC shifter sees are produced by a cron-job running over these hbook files with a kumac:

If you want to produce these plots yourself, or make similar plots based on this code, you can run over the XTC file yourself using the application EmcMyReadXtc.
* First, stage the xtc file:
tcstage 00[run number]-001
the xtc file (or a link to it) will then appear in the directory
called babar-00[run number]-001.xtc
* Next, from a recent-ish test release, check out the package EmcOepMon (the tag from the release should be fine).
* Compile and link the executable EmcMyReadXtc

gmake lib EmcOepMon.EmcMyReadXtc

* in the tcl file EmcOepMon/EmcMyReadXtc.tcl comment out the line
module disable EmcOepDiag
* you can also edit the name of the output hbook file from this tcl file.
* run the executable using the following command:

EmcMyReadXtc -f [location-of-XTC-file] -n [number_of_events] ../EmcOepMon/EmcMyReadXtc.tcl

* NOTE by default EmcMyReadXtc uses hbook 'record length' 8190, so in PAW you need to open with
h/file 1 [hbookfilename] 8190
* In this hbook file, there should be a directory called EMCOEPDIAG where you can find lots of useful plots.
* alternatively you can just use the kumac emcmoni.kumac which is also in the >EmcOepMon package to make the standard set of OEP plots:
PAW> exe emcmoni [name-of-hbook-file-minus-the".hbook"]

How to reproduce OPR monitoring plots (EmcOprQAHist)

The OPR monitoring plots that the EMC Data Quality Expert checks are automatically produced by the Elf reconstruction software running on the OPR farms and are located here.
Note that there are 2 stages to OPR processing - PC (Prompt Calibration), which only runs over a small fraction of events in each run, determines calibration constants. ER (Event Reconstruction) runs over all the events and makes the CM2 collections.

The hbook files produced by these jobs can be found in the directory:
and the kumac that is run over these to make the monitoring plots is EmcOprMon.kumac in the EmcOprMon package. (In PAW, just do
h/file 1 [name_of_hbook_file]
exe EmcOprMon

(assuming you are in the EmcOprMon/ directory or have copied the kumac to the directory you are in. Note that there are also a couple of fitting programs fnov.for (for pi0 fits) and pi6.for (for eta fits) that you also need to have in your working directory.)

The plots here are mostly made by the module EmcOprQAHist, in the package EmcOprMon. The trickle injection monitoring plots are made by the module EmcOprTrickleHist .

These modules can be run in a variety of applications, including Elf, which is the full reconstruction code that is run by the PR farms. The executable ElfUserXtcApp is built as part of production releases, so can be run out-of-the-box without even needing to check out the Elf package. You just need a test release with workdir and to have srtpath-ed and done gmake workdir.setup, then you need a "tcl snippet" - something like:

set ElfHbookName example
sourceFoundFile PARENT/Elf/ElfProduction.tcl

call it something like runElf.tcl and put it in your workdir. then stage the xtc file if necessary using

tcstage 00[run-number]-001
and run the job with:
ElfUserXtcApp -n [num events] -s [events to skip] -f /nfs/tcfiles/[xtc filename] runElf.tcl

In the resulting hbook file there should be directories called EMCOPRQAHIST, EMCOPRLERTRICKLE and EMCOPRHERTRICKLE which contain all the plots, or you can look at the standard set of plots by running EmcOprMon/EmcOprMon.kumac

However, if you don't want to run the whole BaBar reconstruction code but just the bits that are necessary to make the EMC QA plots, you could use the application EmcOprReadXtc, which just does the EMC reconstruction and the basic tracking (necessary for track/cluster matching).

To run this, check out the package EmcOpr . (The tag V00-01-13 should work for 14-series releases, while V00-04-01 should work for 16/17/18-series).
Compile and link from the release directory:
gmake lib EmcOpr.EmcOprReadXtc
and run from the workdir with
EmcOprReadXtc -n [num evts] -s [evts to skip] -f [xtc file] ../EmcOprReadXtc.tcl

(If you want to be a bit more clever and "CM2", and especially if you want to run several jobs producing separate output files, it's a good idea to change EmcOprReadXtc.tcl to use FwkCfgVar's for things like the output hbook name, and then run your job using a tcl snippet as detailed above).

If you want to change some plots or add new ones, you need to check out the EmcOprMon package and probably alter EmcOprQAHist. You'll then need to recompile and link whatever application (ElfUserXtcApp or EmcOprReadXtc) you run to produce the plots.

Note that you can also produce the standard set of QA plots from running a Beta job on the CM2 mini, using the application BetaMiniQAApp. Once again, this application is built as part of production releases so if you don't want to alter any of the plots you don't even need to check out the BetaMiniUser package.

Other useful bits of software

To look at raw EMC quantities, lots of useful plots are made by the module EmcOepRaw in the EmcOepMon package. The easiest way to run this module is with the EmcMyReadXtc application described above - you just need to make sure that the line mod disable EmcOepRaw is commented out in the file EmcMyReadXtc.tcl
Again, it should be reasonably straightforward to add new histograms to look for specific things by editing the file (and .hh).

There is a module called EmcOprDamageHist in the EmcOprMon package. By default this is not added into EmcOprMonSequence, but can easily be added in - you need to instantiate the module in (use other modules as an example) and then append it to the sequence in EmcOprMonSequence.tcl. Then you can run ElfUserXtcApp or EmcOprReadXtc as described above.
The purpose of EmcOprDamageHist is to look at specific areas of the calorimeter (defined via theta and phi crystal indices) where some problem is suspected. The energy and time of digis in up to three regions are plotted, and pi0 mass peaks are made for gamma gamma combinations where at least one bump was in the region in question. The three regions can be defined via tcl using the parameters "region1phiMin", "region1phiMax", "region1thetaMin" etc.

Another useful application (an alternative to EmcMyReadXtc is the EmcOepPlayTrks executable in EmcOepSequences. To run this, just check out a recent tag of EmcOepSequences (V00-05-02 should work for 16-series releases) and compile and link with
gmake EmcOepSequences.EmcOepPlayTrks You can alter the name of the output hbook file in EmcOepPlayTrks.tcl, and then run with
EmcOepPlayTrks -n [num_evts] -f [xtc_filename] ../EmcOepSequences/EmcOepPlayTrks
By default, the module EmcOepDiag is run (but note that it puts its histograms in the top-level directory rather than a seperate EMCOEPDIAG directory as it does with EmcMyReadXtc). Various other modules are included in the AppUserBuild of the executable, and can be run by uncommenting or adding lines to EmcOepPlayTrks.tcl.

Nick Barlow
- Valid until modified.