Skip to content
Snippets Groups Projects
Commit 1118c95e authored by Jan Kotanski's avatar Jan Kotanski Committed by Graeme Stewart
Browse files

adding new converters for McEventCollection_p5 (GeneratorObjectsAthenaPool-00-08-00)

parent e3207d1b
No related branches found
No related tags found
No related merge requests found
package GeneratorObjectsAthenaPool
author Georgios Stavropoulos <George.Stavropoulos@cern.ch>
author Sebastien Binet <binet@cern.ch>
use AtlasPolicy AtlasPolicy-*
use AtlasReflex AtlasReflex-* External
use DataModel DataModel-* Control
use AtlasSealCLHEP AtlasSealCLHEP-* Database -no_auto_imports
use AthenaPoolUtilities AthenaPoolUtilities-* Database/AthenaPOOL
use AtlasHepMC AtlasHepMC-* External
use GeneratorObjects GeneratorObjects-* Generators
use GeneratorObjectsTPCnv GeneratorObjectsTPCnv-* Generators
branches src share
# apply_pattern declare_runtime
apply_pattern declare_joboptions files="*.py"
#
# Create the list of files for which we want to generate a POOL converter
macro genObjAthenaPoolCnv ""
macro_append genObjAthenaPoolCnv "-s=${GeneratorObjects_root}/GeneratorObjects"
macro_append genObjAthenaPoolCnv " HijingEventParams.h"
macro_append genObjAthenaPoolCnv " McEventCollection.h"
apply_pattern poolcnv files=$(genObjAthenaPoolCnv)
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
/**
@mainpage GeneratorObjectsAthenaPool Package
The package which defines POOL converters for general Monte-Carlo classes.
@authors Sebastien Binet, Georgios Stavropoulos, Davide Costanzo
@section GeneratorObjectsAthenaPoolIntro Introduction
The MonteCarlo classes (e.g. @c HepMC::GenEvent ) are stored on disk through the so-called POOL persistification technology which insulates client code (Athena) from technology details and provides transparent switch of different storage backends (ROOT, MySQL,...)
This package provides the needed boilerplate code to use the T/P converters provided by the GeneratorObjectsTPCnv package (see twiki page about Transient/Persistent separation: https://twiki.cern.ch/twiki/bin/view/Atlas/TransientPersistentSeparation) and make them available to the GAUDI framework.
@section GeneratorObjectsAthenaPoolSeeAlso See also
You may also be interested in having a look at the GeneratorObjectsTPCnv package which defines and provides various T/P converters for the MonteCarlo classes.
@htmlinclude used_packages.html
@include requirements
*/
###############################################################
#
# Job options file
#
#==============================================================
#--------------------------------------------------------------
# Event related parameters
#--------------------------------------------------------------
theApp.EvtMax = 5
#--------------------------------------------------------------
# Load POOL support
#--------------------------------------------------------------
import AthenaPoolCnvSvc.ReadAthenaPool
svcMgr.EventSelector.InputCollections = ["mc.event.pool"]
#--------------------------------------------------------------
# Private Application Configuration options
#--------------------------------------------------------------
# Load "user algorithm"
#top algorithms to be run, and the libraries that house them
from AthenaCommon.AlgSequence import AlgSequence
job = AlgSequence()
job += CfgMgr.DumpMC("DumpMC")
#--------------------------------------------------------------
# Output options
#--------------------------------------------------------------
import AthenaPoolCnvSvc.WriteAthenaPool
job += CfgMgr.AthenaOutputStream(
"OutStream",
WritingTool = "AthenaPoolOutputStreamTool"
)
job.OutStream.ItemList += [
"EventInfo#*",
"McEventCollection#*"
]
job.OutStream.OutputFile = "reaccessed.mc.event.pool"
#--------------------------------------------------------------
# Set output level threshold (2=DEBUG, 3=INFO, 4=WARNING, 5=ERROR, 6=FATAL )
#--------------------------------------------------------------
svcMgr.MessageSvc.OutputLevel = 2
#==============================================================
#
# End of job options file
#
###############################################################
###############################################################
#
# Job options file
#
#==============================================================
#--------------------------------------------------------------
# General Application Configuration options
#--------------------------------------------------------------
import AthenaCommon.AtlasUnixGeneratorJob
import AthenaCommon.Constants as Lvl
from AthenaCommon.AppMgr import ServiceMgr as svcMgr
from AthenaCommon.AppMgr import theApp
#--------------------------------------------------------------
# Private Application Configuration options
#--------------------------------------------------------------
from AthenaCommon.AlgSequence import AlgSequence
job = AlgSequence()
## generator algorithm
job += CfgMgr.Pythia()
## algorithm to dump GenEvent's content on screen
job += CfgMgr.DumpMC()
svcMgr.MessageSvc.OutputLevel = Lvl.DEBUG
#--------------------------------------------------------------
# Event related parameters
#--------------------------------------------------------------
svcMgr += CfgMgr.AtRndmGenSvc()
svcMgr.AtRndmGenSvc.Seeds = [
"PYTHIA 4789899 989240512", "PYTHIA_INIT 820021 2347532"
]
Pythia = job.Pythia
Pythia.PythiaCommand = ["pysubs msel 13","pysubs ckin 3 18.","pypars mstp 43 2"]
# Number of events to be processed (default is 10)
theApp.EvtMax = 5
#---------------------------------------------------------------
# Pool Persistency
#---------------------------------------------------------------
import AthenaPoolCnvSvc.WriteAthenaPool
job += CfgMgr.AthenaOutputStream(
"OutStream",
WritingTool = "AthenaPoolOutputStreamTool"
)
job.OutStream.ItemList += [
"EventInfo#*",
"McEventCollection#*"
]
job.OutStream.OutputFile = "mc.event.pool"
#==============================================================
#
# End of job options file
#
###############################################################
///////////////////////// -*- C++ -*- /////////////////////////////
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
// McEventCollectionCnv.cxx
// Implementation file for class McEventCollectionCnv
// Author: S.Binet<binet@cern.ch>
///////////////////////////////////////////////////////////////////
// STL includes
// Framework includes
#include "GaudiKernel/MsgStream.h"
// GeneratorObjectsTPCnv includes
#include "GeneratorObjectsTPCnv/McEventCollectionCnv_p1.h"
#include "GeneratorObjectsTPCnv/McEventCollectionCnv_p2.h"
#include "GeneratorObjectsTPCnv/McEventCollectionCnv_p3.h"
#include "GeneratorObjectsTPCnv/McEventCollectionCnv_p4.h"
#include "GeneratorObjectsTPCnv/McEventCollectionCnv_p5.h"
// GeneratorObjectsAthenaPool includes
#include "McEventCollectionCnv.h"
///////////////////////////////////////////////////////////////////
/// Public methods:
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
/// Const methods:
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
// Protected methods:
///////////////////////////////////////////////////////////////////
McEventCollection_PERS*
McEventCollectionCnv::createPersistent( McEventCollection* transCont )
{
MsgStream msg( msgSvc(), "McEventCollectionCnv" );
McEventCollectionCnv_p5 cnv;
McEventCollection_PERS *persObj = cnv.createPersistent( transCont, msg );
msg << MSG::DEBUG << "::createPersistent [Success]" << endreq;
return persObj;
}
McEventCollection* McEventCollectionCnv::createTransient()
{
MsgStream msg( msgSvc(), "McEventCollectionConverter" );
McEventCollection *transObj = 0;
static pool::Guid tr_guid("6DE62B45-7C72-4539-92F2-3A8E739A4AC3");
static pool::Guid p1_guid("BF93438C-D1D3-4F1C-8850-EB690AB7C416");
static pool::Guid p2_guid("851BB1D2-1964-4B0A-B83A-6BD596CFB5E2");
static pool::Guid p3_guid("6FC41599-64D6-4DB9-973E-9493166F6291");
static pool::Guid p4_guid("C517102A-94DE-407C-B07F-09BD81F6172E");
static pool::Guid p5_guid("D52391A4-F951-46BF-A0D5-E407698D2917");
// Hook to disable datapool if we are doing pileup
bool isPileup(false);
if(serviceLocator()->existsService("PileUpEventLoopMgr")) {
isPileup=true;
msg << MSG::DEBUG << "Pile run, disable datapool for McEventCollection " << endreq;
}
if ( compareClassGuid(tr_guid) ) {
// regular object from before the T/P separation
return poolReadObject<McEventCollection>();
} else if ( compareClassGuid(p1_guid) ) {
// using auto_ptr ensures deletion of the persistent object
std::auto_ptr<McEventCollection_p1> persObj( poolReadObject<McEventCollection_p1>() );
McEventCollectionCnv_p1 cnv;
transObj = cnv.createTransient( persObj.get(), msg );
} else if ( compareClassGuid(p2_guid) ) {
// using auto_ptr ensures deletion of the persistent object
std::auto_ptr<McEventCollection_p2> persObj( poolReadObject<McEventCollection_p2>() );
McEventCollectionCnv_p2 cnv;
transObj = cnv.createTransient( persObj.get(), msg );
} else if ( compareClassGuid(p3_guid) ) {
// using auto_ptr ensures deletion of the persistent object
std::auto_ptr<McEventCollection_p3> persObj( poolReadObject<McEventCollection_p3>() );
McEventCollectionCnv_p3 cnv;
transObj = cnv.createTransient( persObj.get(), msg );
} else if ( compareClassGuid(p4_guid) ) {
// using auto_ptr ensures deletion of the persistent object
std::auto_ptr<McEventCollection_p4> persObj( poolReadObject<McEventCollection_p4>() );
McEventCollectionCnv_p4 cnv;
if(isPileup) cnv.setPileup();
transObj = cnv.createTransient( persObj.get(), msg );
} else if ( compareClassGuid(p5_guid) ) {
// using auto_ptr ensures deletion of the persistent object
std::auto_ptr<McEventCollection_p5> persObj( poolReadObject<McEventCollection_p5>() );
McEventCollectionCnv_p5 cnv;
if(isPileup) cnv.setPileup();
transObj = cnv.createTransient( persObj.get(), msg );
} else {
throw std::runtime_error("Unsupported persistent version of McEventCollection");
}
return transObj;
}
///////////////////////// -*- C++ -*- /////////////////////////////
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
// McEventCollectionCnv.h
// Header file for class McEventCollectionCnv
// Author: S.Binet<binet@cern.ch>
///////////////////////////////////////////////////////////////////
#ifndef GENERATOROBJECTSATHENAPOOL_MCEVENTCOLLECTIONCNV_H
#define GENERATOROBJECTSATHENAPOOL_MCEVENTCOLLECTIONCNV_H
// STL includes
// HepMC / CLHEP includes
#include "GeneratorObjects/McEventCollection.h"
// AthenaPoolCnvSvc includes
#include "AthenaPoolCnvSvc/T_AthenaPoolCustomCnv.h"
// GeneratorObjectsTPCnv includes
#include "GeneratorObjectsTPCnv/McEventCollection_p5.h"
// Forward declaration
// the latest persistent representation type of DataCollection:
typedef McEventCollection_p5 McEventCollection_PERS;
class McEventCollectionCnv: public T_AthenaPoolCustomCnv<
McEventCollection,
McEventCollection_PERS
>
{
// make the factory for this converter our friend
friend class CnvFactory<McEventCollectionCnv>;
///////////////////////////////////////////////////////////////////
// Protected methods:
///////////////////////////////////////////////////////////////////
protected:
/** Create the converter from the service locator
*/
McEventCollectionCnv(ISvcLocator* svcloc);
/** Build the persistent representation from the transient one.
*/
virtual McEventCollection_PERS*
createPersistent( McEventCollection* transCont );
/** Build the transient representation from a persistent one
*/
virtual McEventCollection* createTransient();
};
///////////////////////////////////////////////////////////////////
/// Inline methods:
///////////////////////////////////////////////////////////////////
inline McEventCollectionCnv::McEventCollectionCnv( ISvcLocator* svcLocator ) :
T_AthenaPoolCustomCnv<McEventCollection, McEventCollection_PERS>(svcLocator)
{}
#endif //> GENERATOROBJECTSATHENAPOOL_MCEVENTCOLLECTIONCNV_H
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment