Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
import FWCore.ParameterSet.Config as cms

process = cms.Process("TEST")

process.load("FWCore.MessageService.MessageLogger_cfi")
process.MessageLogger.cerr.FwkReport.reportEvery = 1

from FWCore.Modules.modules import EmptySource
process.source = EmptySource()

process.maxEvents.input = 20

# accept one event out of two
from FWCore.Modules.modules import Prescaler
process.filter = Prescaler(
    prescaleFactor = 2,
    prescaleOffset = 0
)

# produce a PathStateToken when run, to indicate that its path is active for the current event
from FWCore.Modules.modules import PathStateCapture
process.pathStateCapture = PathStateCapture()

# try to consume a PathStateToken: if it is found accept the event, otherwise reject it
from FWCore.Modules.modules import PathStateRelease
process.pathStateRelease = PathStateRelease(
    state = 'pathStateCapture'
)

# select one event out of two and record the path's activity
process.captured = cms.Path(
    process.filter +
    process.pathStateCapture
)

# replicate the activity of the original path
process.released = cms.Path(
    process.pathStateRelease
)

# compare the results of the "captured" and "released" paths
from FWCore.Modules.modules import PathStatusFilter
process.compare = PathStatusFilter(
    logicalExpression = '(captured and released) or (not captured and not released)'
)

# schedule the comparison
process.correct = cms.Path(
    process.compare
)

# require that the comparison has been successful for every event
from FWCore.Framework.modules import SewerModule
process.require = SewerModule(
    name = cms.string('require'),
    shouldPass = process.maxEvents.input.value(),
    SelectEvents = dict(
        SelectEvents = 'correct'
    )
)

process.endpath = cms.EndPath(
    process.require
)