Exemplo n.º 1
0
    def process(self, eventoffset):
        from GaudiPython.Bindings import AppMgr
        appMgr = AppMgr()
        if eventoffset == 0:
            from Escher.Utils import printsequence
            printsequence(appMgr)
        # ugly: change the algorithm after initialization. otherwise it doesn't work for 'reused' applications.
        #numeventsPerProc  = opts.numevents / opts.numprocs + 1
        #numeventsThisProc = numeventsPerProc
        #if eventoffset is opts.numprocs - 1:
        #   numeventsThisProc -= opts.numprocs * numeventsPerProc - opts.numevents
        #appMgr.evtSel().FirstEvent = eventoffset * numeventsPerProc
        #appMgr.evtSel().reinitialize()
        #appMgr.run(numeventsThisProc)
        appMgr.algorithm(prescalername).Offset = eventoffset
        appMgr.algorithm(prescalername).Interval = opts.numprocs
        appMgr.run(opts.numevents)

        #evt = appMgr.evtsvc()
        #while 0 < 1:>
        # check if there are still valid events
        # if evt['Rec/Header'] == None : break
        det = appMgr.detsvc()
        alignderivatives = det['AlignDerivativeData']
        #self.output['derivatives'] = copy.deepcopy(alignderivatives)
        if alignderivatives: self.output['derivatives'].add(alignderivatives)
        otmonodata = det['OTMonoLayerAlignData']
        if otmonodata:
            self.output['otmonodata'].add(otmonodata)

        histsvc = appMgr.histsvc()
        self.output['histograms'].collect(histsvc)
Exemplo n.º 2
0
    def finalize(self):
        print "INFO: finalize"
        # dump the histograms to a file
        self.output['histograms'].dump(opts.histofile)

        numAlignEvents = self.output['derivatives'].equations().numEvents()
        print 'INFO: number of events in derivatives: ', self.output[
            'derivatives'].equations().numEvents()
        if numAlignEvents > 0:
            # write the derivative file
            if len(opts.derivativefile) > 0:
                self.output['derivatives'].equations().writeToFile(
                    derivativefile)

            from GaudiPython.Bindings import AppMgr
            appMgr = AppMgr()
            # we want to reinitialize, but we don't want to initialize all
            # the reco algorithms, so we add just the alignment sequence:
            appMgr.setAlgorithms(['GaudiSequencer/AlignSequence'])
            appMgr.configure()
            appMgr.initialize()
            # update the geometry
            # updatetool = appMgr.toolsvc().create( typ = "Al::AlignUpdateTool", name = "ToolSvc.AlignUpdateTool", interface = "IAlignUpdateTool" )
            updatetool = appMgr.toolsvc().create(
                "Al::AlignUpdateTool", interface="Al::IAlignUpdateTool")
            updatetool.process(self.output['derivatives'].equations(),
                               opts.iter, 1)
            # call the xml writer tool
            writertool = appMgr.toolsvc().create(
                "WriteMultiAlignmentConditionsTool",
                interface="IWriteAlignmentConditionsTool")
            writertool.write()
            # now call finalize to write the conditions. there must be a better way.
            det = appMgr.detsvc()
            if self.output['otmonodata'] and det['OTMonoLayerAlignData']:
                det['OTMonoLayerAlignData'].add(self.output['otmonodata'])

            appMgr.finalize()
            # finally create a database layer
            import os
            os.system(
                "copy_files_to_db.py -c sqlite_file:Alignment.db{0} -s xml".
                format(condtag))