Posts Tagged ‘lhcb’

Converting DST to MDF

Friday, July 11th, 2008

Here is a options file that converts a DST to MDF. Most of it is form Markus Frank.

#pragma print off
#include "$STDOPTS/LHCbApplication.opts"
#include "$STDOPTS/DstDicts.opts"
#include "$STDOPTS/DC06Conditions.opts"
#pragma print on

ApplicationMgr.EvtMax =  10000;
EventSelector.PrintFreq = 100;
ApplicationMgr.OutputLevel = 10;

ApplicationMgr.HistogramPersistency = "ROOT";
HistogramPersistencySvc.OutputFile = "Moore_minbias.root";

ApplicationMgr.ExtSvc +=  [ "ToolSvc" , "AuditorSvc" ] ;
ApplicationMgr.AuditAlgorithms = 1;
AuditorSvc.Auditors +=  [ "TimingAuditor/TIMER" ] ;
MessageSvc.Format = "% F%40W%S%7W%R%T %0W%M";
ToolSvc.SequencerTimerTool.OutputLevel = 4;

EventPersistencySvc.CnvServices += { "LHCb::RawDataCnvSvc" };
ApplicationMgr.OutStream += { "LHCb::MDFWriter/Writer_2" };
Writer_2.Connection       = "file:///local_home/snies/DC06_L0_v1_lumi2.mdf";
Writer_2.Compress         = 0;
Writer_2.ChecksumType     = 1;
Writer_2.GenerateMD5      = true;

EventSelector.Input   = {
  "DATAFILE='PFN:/local_home/snies/DC06_L0_v1_lumi2.raw' TYP='POOL_ROOTTREE' OPT='READ'"
};

After doing this you might be interested into this little bash script (also by Markus Frank) that prints out the banks stored in the MDF. This way you can make sure your MDF is fine:


#!/bin/bash

runit()
{
cat >/tmp/${USER}/ReadMDF.opts <<END-OF-OPTS
ApplicationMgr.TopAlg                =
{"StoreExplorerAlg","LHCb::RawEventTestDump/Dump"};
ApplicationMgr.EvtMax                = 100000;
ApplicationMgr.HistogramPersistency  = "NONE";
Dump.CheckData                       = 1;
Dump.CheckData                       = 0;
Dump.DumpData                        = 1;
Dump.FullDump                        = 1;
Dump.OutputLevel                     = 1;
StoreExplorerAlg.Load                = 1;
StoreExplorerAlg.PrintFreq           = 100;
EventDataSvc.RootCLID                = 1;
EventDataSvc.EnableFaultHandler      = true;
EventPersistencySvc.CnvServices      = {"LHCb::RawDataCnvSvc"};
EventSelector.PrintFreq              = 100;
EventSelector.Input                  = {"DATA='PFN:file://${1}'
SVC='LHCb::MDFSelector'"};
StoreExplorerAlg.OutputLevel         = 1;
END-OF-OPTS

echo $LD_LIBRARY_PATH;
cat /tmp/${USER}/ReadMDF.opts;

$ONLINEKERNELROOT/$CMTCONFIG/gentest.exe libGaudiKernel.so GaudiMain /tmp/${USER}/ReadMDF.opts | more;
}

runit $*

recreate L0Banks for LHCb HLT

Friday, July 11th, 2008

To recreate L0 Banks for LHCb HLT to you can use this skript (stole most of it from Hans). It uses bankKiller and EventNodeKiller to clean the old L0Banks and recreates them. At the end it checks for all channel decisions involving muons or hadrons and writes out the events that had any such decision.


#  strip rawdata from a dst, and replace L0DU bank with proper bank
#  Checks for channeldesicions and writes only mu/had triggers

from Gaudi.Configuration import *

importOptions('$STDOPTS/LHCbApplication.opts')   # import old opts file
importOptions('$STDOPTS/DstDicts.opts')          # import old opts file
importOptions('$DDDBROOT/options/DC06.opts')     # import old opts file

# L0 configuration
importOptions('$L0MUONROOT/options/l0muonAlg.opts') # import old opts file
importOptions('$L0DUROOT/options/L0DUConfig.opts')  # import old opts file

#castor cards for mbias L0-stripped events from bookkeeping
#importOptions('/afs/cern.ch/user/d/dijkstra/python/l0-run/mb1-1.opts') # import old opts file
importOptions('$MOOREROOT/options/DC06_L0_v1_lumi2.opts')

# Gaudi.Configuration.Configurables is a ConfFacade - Object
# it is created upon first import of Gaudi.Configuration
# LHCbAlgs.LHCbAlgsConf.EventNodeKiller  /software/releases/LHCB/LHCB_v23r7/InstallArea/python/LHCbAlgs
# L0Calo.L0CaloConf.L0CaloAlg            /software/releases/LBCOM/LBCOM_v6r18/InstallArea/python/L0Calo
# L0Muon.L0MuonConf.L0MuonAlg            /software/releases/LBCOM/LBCOM_v6r18/InstallArea/python/L0Muon
# PuVeto.PuVetoConf.PuVetoAlg            /software/releases/LBCOM/LBCOM_v6r18/InstallArea/python/PuVeto
# L0DU.L0DUConf.L0DUAlg                  /software/releases/LBCOM/LBCOM_v6r18/InstallArea/python/L0DU
# DAQEvent.DAQEventConf.bankKiller       /software/releases/LHCB/LHCB_v23r7/InstallArea/python/DAQEvent
from Configurables import EventNodeKiller,L0CaloAlg,L0MuonAlg,PuVetoAlg,L0DUAlg,bankKiller

RemoveL0Banks = bankKiller('RemoveL0Banks')
RemoveL0Banks.BankTypes =["L0DU", "L0Calo", "L0Muon"]
L0 = GaudiSequencer('L0')

#-----------------------------------------------------
# Run the whole L0 sequence including the L0Processors
#-----------------------------------------------------
L0.Members += [ "bankKiller/RemoveL0Banks"
               ,"L0CaloAlg/L0Calo"
               ,"L0MuonAlg/L0Muon"
               ,"PuVetoAlg/L0PuVeto"
               ,"L0DUAlg/L0DU"
               ,"EventNodeKiller/EventNodeKiller"
]
L0DU = L0DUAlg('L0DU')
L0DU.StoreInBuffer   = True

rawwriter  = OutputStream('RawWriter', Preload = False,
  ItemList = ["/Event#1","/Event/DAQ#1","/Event/DAQ/RawEvent#1","/Event/DAQ/ODIN#1"],
  Output   = "DATAFILE='/local_home/snies/DC06_L0_v1_lumi2_MuonHadron.dst' TYP='POOL_ROOTTREE' OPT='REC' ")
appConf    = ApplicationMgr( OutputLevel = INFO, AppName = 'L0DUextract')
appConf.OutStream = [rawwriter]
appConf.ExtSvc += ['DataOnDemandSvc']
DataOnDemandSvc().Algorithms += ["DATA='/Event/Trig/L0/L0DUReport' TYPE='GaudiSequencer/L0'"]
#appConf.TopAlg    = ['GaudiSequencer/L0']

EventNodeKiller().Nodes    = ["Rec", "MC", "Raw", "Gen", "Link", "pSim" , "Prev", "PrevPrev", "Next"]
EventSelector().PrintFreq  = 50

import GaudiPython
#from gaudigadgets import *

appMgr = GaudiPython.AppMgr()
sel    = appMgr.evtsel()  #Event Selector (could be used to specify input files)
evt    = appMgr.evtsvc()  #Get event service for later use to access the transient event store

appMgr.algorithm('RawWriter').Enable = False  # stop automatic execution of RawWriter

nevent=0  # loop variable
l0acc=0   # number of L0 accepted events

appMgr.run(1) #step one event
while nevent < 100000:
  nevent = nevent + 1 # increase loop variable
  appMgr.run(1)       # read one event

  if evt['Rec/Header'] == None : break  # probably end of input

  # check L0
  L0dir = evt['Trig/L0/L0DUReport']  # get a container
  # get channel decisions
  Hadron = L0dir.channelDecisionByName('Hadron')
  Muon   = L0dir.channelDecisionByName('Muon')
  DiMuon = L0dir.channelDecisionByName('DiMuon')
  MuonNoGlob = L0dir.channelDecisionByName('MuonNoGlob')

  if Hadron or Muon or DiMuon or MuonNoGlob:
    l0acc = l0acc + 1        # count as L0 accepted event
    rc = appMgr.algorithm('RawWriter').execute() # output the L0 accepted event
    # rc probably a return code ? should be checked ?

print 'L0 accepted',l0acc,' in ',nevent,' events.'
print 'Read/Wrote ',nevent,l0acc

Sherpa Event Generator, Part 1

Wednesday, July 2nd, 2008

We currently update the LHCb interface to the event generator Sherpa, called LbSherpa, to Sherpa’s latest version 1.1.1. In that effort we had to learn some of the details on how to set up the Sherpa Framework properly:

ATOOLS::exh
Sherpa uses it’s ATOOLS::Exception_Handler in a singleton fashion to handle Exceptions. It makes use of this instance throughout the framework by providing the pointer ATOOLS::exh. It has to be initialized by calling ATOOLS::exh->init(). You can see an example of it’s use at Sherpa’s Main.C:

# /SHERPA/Run/Main.C lines 12 and following
using namespace SHERPA;

#ifdef F77_MAIN
extern "C" int F77_MAIN(int argc,char* argv[])
#else
int main(int argc,char* argv[])
#endif
{
  ATOOLS::exh->Init();

This calls Init() as defined in Exception_Handler.C:

# file /ATOOLS/Org/Exception_Handler.C lines 28-30
using namespace ATOOLS;

ATOOLS::Exception_Handler *ATOOLS::exh(NULL);

# file /ATOOLS/Org/Exception_Handler.C lines 38-45
void Exception_Handler::Init()
{
  static bool init(false);
  if (!init) {
    exh = new Exception_Handler();
    init=true;
  }
}

ATOOLS::msg
The use of Sherpa’s Message system for printing output and errors is handled by it’s Message class in a similar fashion through the pointer ATOOLS::msg. But you probably shouldn’t use it directly but rather by the macros defined in Message.h:

# file /ATOOLS/Org/Message.H lines 189-200
#define msg_LevelIsEvents() ATOOLS::msg->LevelIsEvents()
#define msg_LevelIsInfo() ATOOLS::msg->LevelIsInfo()
#define msg_LevelIsTracking() ATOOLS::msg->LevelIsTracking()
#define msg_LevelIsDebugging() ATOOLS::msg->LevelIsDebugging()

#define msg_Error() ATOOLS::msg->Error()
#define msg_Out() ATOOLS::msg->Out()
#define msg_LogFile() ATOOLS::msg->LogFile()
#define msg_Events() if (msg_LevelIsEvents()) ATOOLS::msg->Out()
#define msg_Info() if (msg_LevelIsInfo()) ATOOLS::msg->Out()
#define msg_Tracking() if (msg_LevelIsTracking()) ATOOLS::msg->Out()
#define msg_Debugging() if (msg_LevelIsDebugging()) ATOOLS::msg->Out()

ATOOLS::msg also has to be initalized:

# file /ATOOLS/Org/Message.H lines 8-10
namespace ATOOLS {
  Message *msg(new Message());
}

# file /ATOOLS/Org/Message.H lines 116-123
void Message::Init(const int level,const std::string &logfile)
{
  m_level = level;
  if (m_level&16) {
    InitLogFile(logfile);
    Out()<<"Initialize output module Message. Level "<<m_level<<std::endl;
  }
}

There will be more parts as we learn more about Sherpa’s inner workings.