Commit 4e9b751c authored by Hendrik Jansen's avatar Hendrik Jansen Committed by Graeme Stewart
Browse files

tag BCM_BackgroundAlgs-00-00-03 (BCM_BackgroundAlgs-00-00-03)

parent 0b07407d
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
// BcmCollisionTime.h
//
#ifndef BcmCollisionTimeAlg_H
#define BcmCollisionTimeAlg_H
#include <string>
// Gaudi includes
#include "GaudiKernel/Algorithm.h"
#include "GaudiKernel/ToolHandle.h"
#include "StoreGate/StoreGateSvc.h"
class StoreGateSvc;
class BcmCollisionTimeAlg : public Algorithm {
public:
//Gaudi style constructor and execution methods
/** Standard Athena-Algorithm Constructor */
BcmCollisionTimeAlg(const std::string& name, ISvcLocator* pSvcLocator);
/** Default Destructor */
~BcmCollisionTimeAlg();
/** standard Athena-Algorithm method */
StatusCode initialize();
/** standard Athena-Algorithm method */
StatusCode execute();
/** standard Athena-Algorithm method */
StatusCode finalize();
private:
//---------------------------------------------------
// Member variables
//---------------------------------------------------
/** The StoreGate Service */
//StoreGateSvc* m_sgSvc;
StoreGateSvc* m_storeGate;
//int m_nevt;
//ToolHandle<ICaloNoiseTool> m_noiseTool;
//bool m_isMC;
//bool m_iterCut;
float m_timeCut;
//int m_minCells;
//std::string m_cellsContName;
//const DataHandle<CaloIdManager> m_caloIdMgr;
//const CaloCell_ID* m_calo_id;
};
class deltat_data{
public:
deltat_data();
deltat_data( unsigned int channel, unsigned int bcid, unsigned int position );
// private:
unsigned int m_channel;
unsigned int m_bcid;
unsigned int m_position;
//bool operator<(const deltat_data &data);
// deltat_data min(const deltat_data &data);
};
inline deltat_data::deltat_data()
: m_channel(99), m_bcid(99), m_position(99) {}
inline deltat_data::deltat_data( unsigned int channel, unsigned int bcid, unsigned int position )
: m_channel(channel), m_bcid(bcid), m_position(position) {}
#endif
(i__main__
LogFile
p0
(dp1
S'_installed_files'
p2
(dp3
S'../../../../../../../../../atlas/software/releases/16.6.3/GAUDI/v21r9p3a/GaudiPolicy/cmt/fragments/__init__.py'
p4
S'../../../../InstallArea/python/BCM_BackgroundAlgs/__init__.py'
p5
sS'../../InnerDetector/InDetRecAlgs/BCM_BackgroundAlgs/genConf/BCM_BackgroundAlgs'
p6
(dp7
S'../../../InnerDetector/InDetRecAlgs/BCM_BackgroundAlgs/genConf/BCM_BackgroundAlgs/BCM_BackgroundAlgsConf.py'
p8
S'../../../../InstallArea/python/BCM_BackgroundAlgs/BCM_BackgroundAlgsConf.py'
p9
sS'../../../InnerDetector/InDetRecAlgs/BCM_BackgroundAlgs/genConf/BCM_BackgroundAlgs/BCM_BackgroundAlgs_confDb.py'
p10
S'../../../../InstallArea/python/BCM_BackgroundAlgs/BCM_BackgroundAlgs_confDb.py'
p11
ssS'../../../InnerDetector/InDetRecAlgs/BCM_BackgroundAlgs/i686-slc5-gcc43-opt/libBCM_BackgroundAlgs.so'
p12
S'../../../../InstallArea/i686-slc5-gcc43-opt/lib/libBCM_BackgroundAlgs.so'
p13
sS'../../../../../../../../../atlas/offline/external/GAUDI/v21r9p3a/GaudiPolicy/cmt/fragments/__init__.py'
p14
S'../../../../InstallArea/python/BCM_BackgroundAlgs/__init__.py'
p15
ssb.
\ No newline at end of file
package BCM_BackgroundAlgs
author Hendrik Jansen <jansen@cern.ch>
use AtlasPolicy AtlasPolicy-01-*
use StoreGate StoreGate-02-* Control
use GaudiInterface GaudiInterface-01-* External
private
use BCM_CollisionTime BCM_CollisionTime-* InnerDetector/InDetRecEvent
use InDetBCM_RawData InDetBCM_RawData-* InnerDetector/InDetRawEvent
use Identifier Identifier-00-* DetectorDescription
library BCM_BackgroundAlgs *.cxx -s=components *.cxx
apply_pattern component_library
apply_pattern declare_joboptions files="*.txt *.py"
apply_pattern declare_python_modules files="*.py"
# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
#--------------------------------------------------------------------------------------------------
# options
#--------------------------------------------------------------------------------------------------
doRunOnGrid=False
#doGRL=True
#myGRL='data10_7TeV.periodAllYear.xml'
#--------------------------------------------------------------------------------------------------
from GaudiKernel.GaudiHandles import *
from GaudiKernel.Proxy.Configurable import *
import AthenaPoolCnvSvc.ReadAthenaPool
from AthenaCommon.AppMgr import ServiceMgr
from AthenaCommon.AppMgr import ToolSvc
#ServiceMgr.MessageSvc.defaultLimit = 9999999
#from AthenaCommon.AlgSequence import AlgSequence, AthSequencer
from AthenaCommon.AlgSequence import AlgSequence
topSequence = AlgSequence()
# see details at https://svnweb.cern.ch/trac/atlasoff/browser/DataQuality/GoodRunsListsUser/trunk/share/GoodRunsListsUser_default_data.py#L13
#seq = AthSequencer("AthFilterSeq")
from AthenaCommon.AthenaCommonFlags import athenaCommonFlags
import glob
#--------------------------------------------------------------------------------------------------
if not doRunOnGrid:
#addPath = '/afs/cern.ch/user/r/rkwee/scratch0/Insitu15/run/grid/'
#athenaCommonFlags.FilesInput = []
#include('/afs/cern.ch/user/r/rkwee/scratch0/jO/inputESDs.py')
athenaCommonFlags.FilesInput = [
'/home/bcm_data/data10_7TeV.00158548.physics_MinBias.recon.ESD.f273/data10_7TeV.00158548.physics_MinBias.recon.ESD.f273._lb0200._0001.1'
]
nEvents = -1
else:
athenaCommonFlags.FilesInput = glob.glob("*ESD*")
#addPath = ''
nEvents = -1
ServiceMgr.EventSelector.InputCollections=athenaCommonFlags.FilesInput()
#--------------------------------------------------------------------------------------------------
ServiceMgr.EventSelector.SkipEvents = 0
theApp.EvtMax = nEvents
#--------------------------------------------------------------------------------------------------
from RecExConfig.RecFlags import rec
rec.AutoConfiguration=['everything']
from RecExConfig.InputFilePeeker import inputFileSummary
from AthenaCommon.GlobalFlags import globalflags
iKeys = inputFileSummary.keys()
print 'content of inputFileSummary'
for k in iKeys:
if 0:
print k,':',inputFileSummary[k]
if inputFileSummary['evt_type'][0] == 'IS_DATA' :
globalflags.DataSource = 'data'
if inputFileSummary['evt_type'][0] == 'IS_SIMULATION' :
globalflags.DataSource = 'geant4'
globalflags.DetDescrVersion = inputFileSummary['geometry']
#--------------------------------------------------------------
# build rootfile name
runnumber = str(inputFileSummary['run_number'][0])
streamName = inputFileSummary['stream_tags'][0]['stream_type'] + '_' + inputFileSummary['stream_tags'][0]['stream_name']
rootfilename = 'bcm_bkgword'
#--------------------------------------------------------------
# set up all detector description description
include ("RecExCond/AllDet_detDescr.py")
include('TrkDetDescrSvc/AtlasTrackingGeometrySvc.py')
#--------------------------------------------------------------------------------------------------
# Trigger
#--------------------------------------------------------------------------------------------------
#from TrigDecisionTool.TrigDecisionToolConf import Trig__TrigDecisionTool
#tdt = Trig__TrigDecisionTool("TrigDecisionTool")
#ToolSvc += tdt
#tdt.OutputLevel = INFO
#ToolSvc.TrigDecisionTool.Navigation.OutputLevel = INFO
#
#from TriggerJobOpts.TriggerConfigGetter import TriggerConfigGetter
#cfg = TriggerConfigGetter('ReadPool')
# Athena output level
# (2=DEBUG, 3=INFO, 4=WARNING, 5=ERROR, 6=FATAL)"
ServiceMgr.MessageSvc.OutputLevel = 3
#--------------------------------------------------------------------------------------------------
# GRL
#--------------------------------------------------------------------------------------------------
#if doGRL:
# # from twiki: https://twiki.cern.ch/twiki/bin/viewauth/Atlas/GoodRunsListsTutorial
#
# from GoodRunsLists.GoodRunsListsConf import *
# ToolSvc += GoodRunsListSelectorTool()
# GoodRunsListSelectorTool.GoodRunsListVec = [ addPath+'grls/'+myGRL ]
# GoodRunsListSelectorTool.OutputLevel = DEBUG
#
# from GoodRunsListsUser.GoodRunsListsUserConf import *
# seq += GRLTriggerSelectorAlg('GRLTriggerAlg1')
# #seq.GRLTriggerAlg1.GoodRunsListArray = [ myGRL.rstrip('.xml') ]
# seq.GRLTriggerAlg1.GoodRunsListArray = [ 'minbias_goodLumi_7TeV' ]
#
#-------------------------------------------------------------------------------------------------
# BcmBkgWordSeq seetings
#--------------------------------------------------------------------------------------------------
from BCM_BackgroundAlgs.BCM_BackgroundAlgsConf import BcmCollisionTimeAlg
#BcmBkgWordSeq = BcmBkgWordAlg( "BcmBkgWordSeq" )
#BcmBkgWordSeq.OutputLevel = DEBUG
#like this one could steer DeclarePropertiy
#MbTriggerPerf.doWriteToDB = False
#MbTriggerPerf.DatabaseFile = "./Matrix_"+rootfilename+".root"
#MbTriggerPerf.ContainerName = ""
#MbTriggerPerf.TrigChainName = "mb"
#.................................................................................................
# Add this algorithm to the sequence
topSequence += BcmCollisionTimeAlg( "BCM_BackgroundAlgs" )
topSequence.BCM_BackgroundAlgs.OutputLevel = INFO
#---------------------------------------------------------------------------------------------
# setup TTree registration Service
# save ROOT histograms
from GaudiSvc.GaudiSvcConf import THistSvc
ServiceMgr += THistSvc()
ServiceMgr.THistSvc.Output = ["AANT DATAFILE='"+rootfilename+".root' OPT='RECREATE'"]
#---------------------------------------------------------------------------------------------
# Set output level threshold (DEBUG, INFO, WARNING, ERROR, FATAL)
# May also be set algorithm by algorithm
#--------------------------------------------------------------------------------------------
# topSequence.example.OutputLevel = INFO
MessageSvc.debugLimit = 10000
MessageSvc.infoLimit = 1000
MessageSvc.warningLimit = 1000
#---------------------------------------------------------------------------------------------
# Event related parameters
#---------------------------------------------------------------------------------------------
include.block ('BCM_BackgroundAlgs/BCM_BackgroundAlgs_jobOptions.py')
from BCM_BackgroundAlgs.BCM_BackgroundAlgsConf import BcmCollisionTimeAlg
BcmCollisionTimeAlg=BcmCollisionTimeAlg()
topSequence+=BcmCollisionTimeAlg
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#include "BCM_BackgroundAlgs/BcmCollisionTimeAlg.h"
#include "BCM_CollisionTime/BcmCollisionTime.h"
#include "GaudiKernel/Property.h"
#include "GaudiKernel/MsgStream.h"
#include "StoreGate/StoreGateSvc.h"
#include "Identifier/Identifier.h"
#include "InDetBCM_RawData/BCM_RDO_Container.h"
//Constructor
BcmCollisionTimeAlg:: BcmCollisionTimeAlg(const std::string& name, ISvcLocator* pSvcLocator):
Algorithm(name,pSvcLocator)
{
//declareProperty("cellContainerName",m_cellsContName);
//m_nevt=0;
m_timeCut = 6.25;
}
//__________________________________________________________________________
//Destructor
BcmCollisionTimeAlg::~BcmCollisionTimeAlg()
{
MsgStream log( messageService(), name() ) ;
log << MSG::DEBUG << "BcmCollisionTimeAlg destructor called" << endreq;
}
//__________________________________________________________________________
StatusCode BcmCollisionTimeAlg::initialize()
{
MsgStream log( messageService(), name() );
log << MSG::INFO <<"BcmCollisionTimeAlg initialize()" << endreq;
// Get the StoreGateSvc
if (service("StoreGateSvc", m_storeGate).isFailure()) {
log << MSG::ALWAYS << "No StoreGate!!!!!!!" << endreq;
return StatusCode::FAILURE;
}
StoreGateSvc* detStore;
StatusCode sc = service ( "DetectorStore" , detStore ) ;
if (sc.isFailure()) {
log << MSG::ERROR << " cannot find detector store " << endreq;
return StatusCode::FAILURE;
}
//m_nevt=0;
return StatusCode::SUCCESS;
}
//__________________________________________________________________________
StatusCode BcmCollisionTimeAlg::finalize()
{
MsgStream log( messageService(), name() );
log << MSG::DEBUG <<"BcmCollisionTimeAlg finalize()" << endreq;
return StatusCode::SUCCESS;
}
//__________________________________________________________________________
StatusCode BcmCollisionTimeAlg::execute()
{
//.............................................
MsgStream log( messageService(), name() );
log << MSG::DEBUG << "BcmCollisionTimeAlg execute()" << endreq;
//declare variables here
//unsigned int bcmLGHit=0;
//unsigned int bcmHGHit=0;
std::vector<float> deltaT;
unsigned int multiLG = 0;
unsigned int multiHG = 0;
//bool IsCol = false;
//bool IsBkg = false;
std::vector<deltat_data> deltaTdataA_HG;
std::vector<deltat_data> deltaTdataC_HG;
const BCM_RDO_Container *m_bcmRDO=0;
if (StatusCode::SUCCESS!=m_storeGate->retrieve(m_bcmRDO,"BCM_RDOs")) {
log << MSG::WARNING << "Cannot find BCM RDO! " << endreq;
} else {
int num_collect = m_bcmRDO->size();
if ( num_collect != 16 ){
log << MSG::WARNING << " Number of collections: " << num_collect << endreq;
}
BCM_RDO_Container::const_iterator chan_itr = m_bcmRDO->begin();
BCM_RDO_Container::const_iterator chan_itr_end = m_bcmRDO->end();
int channelID=0;
for (; chan_itr != chan_itr_end; chan_itr++) {
channelID = (*chan_itr)->getChannel();
//std::cout << " ChannelID: " << channelID << std::endl;
// Loop over all BCM hits in this collection
BCM_RDO_Collection::const_iterator bcm_itr = (*chan_itr)->begin();
BCM_RDO_Collection::const_iterator bcm_itr_end = (*chan_itr)->end();
for (; bcm_itr != bcm_itr_end; bcm_itr++) {
if ((*bcm_itr)->getPulse1Width() != 0 && (*bcm_itr)->getLVL1A()==18) {
//std::cout << "Found hit at LVL1A18! " << std::endl;
/// PLEASE TAG THE EVENT!!!
if (channelID <8) multiLG++;
else multiHG++;
deltat_data hit(channelID,(*bcm_itr)->getLVL1A(),(*bcm_itr)->getPulse1Position());
//std::cout << "channel,LVL1A,pos" << channelID << " " << (*bcm_itr)->getLVL1A() << " " << (*bcm_itr)->getPulse1Position() << std::endl;
if (channelID >7 && channelID < 12) deltaTdataA_HG.push_back(hit);
if (channelID >11 ) deltaTdataC_HG.push_back(hit);
if ((*bcm_itr)->getPulse2Width() != 0) {
//std::cout << "Found hit2! " << std::endl;
if (channelID <8) multiLG++;
else multiHG++;
deltat_data hit2(channelID,(*bcm_itr)->getLVL1A(),(*bcm_itr)->getPulse2Position());
//std::cout << "channel,LVL1A,pos" << channelID << " " << (*bcm_itr)->getLVL1A() << " " << (*bcm_itr)->getPulse2Position() << std::endl;
if (channelID >7 && channelID < 12) deltaTdataA_HG.push_back(hit2);
if (channelID >11 && (*bcm_itr)->getPulse2Width() != 0 ) deltaTdataC_HG.push_back(hit2);
}
}
} // end of loop over raw data
} // end of loop over collections
// calculate deltaTs from deltatdata now
for(unsigned int i=0; i < deltaTdataA_HG.size(); i++){
for(unsigned int j=0; j < deltaTdataC_HG.size(); j++){
if((deltaTdataA_HG.at(i)).m_bcid == (deltaTdataC_HG.at(j)).m_bcid){
//std::cout << "time diff in bins: " << ((int)(deltaTdataA_HG.at(i)).m_position - (int)(deltaTdataC_HG.at(j)).m_position) << std::endl;
float deltaTtime = ((float)(deltaTdataA_HG.at(i)).m_position - (float)(deltaTdataC_HG.at(j)).m_position)/64*25;
//std::cout << "delta t: " << deltaTtime << std::endl;
deltaT.push_back(deltaTtime);
}
}
}
// now set bits
//std::cout << "set bits: " << std::endl;
//for (unsigned int i=0; i< deltaT.size(); i++){
// if( fabs(deltaT.at(i)) < m_timeCut ) IsCol = true;
// else IsBkg = true;
//}
}
//std::cout << " multiLG, multiHG, IsCol, IsBkg " << multiLG << " " << multiHG << " " << IsCol << " " << IsBkg << std::endl;
//std::cout << " multiLG, multiHG " << multiLG << " " << multiHG << std::endl;
//fill object here
//BcmBkgWord * bbw = new BcmBkgWord(multiLG,multiHG,IsCol,IsBkg,deltaT);
BcmCollisionTime * bbw = new BcmCollisionTime(multiLG,multiHG,deltaT);
if (m_storeGate->record(bbw,"BcmCollisionTime").isFailure()) {
log << MSG::WARNING << " Cannot record BcmCollisionTime " << endreq;
}
return StatusCode::SUCCESS;
}
#include "BCM_BackgroundAlgs/BcmCollisionTimeAlg.h"
#include "GaudiKernel/DeclareFactoryEntries.h"
DECLARE_ALGORITHM_FACTORY( BcmCollisionTimeAlg )
DECLARE_FACTORY_ENTRIES(BCM_BackgroundAlgs) {
DECLARE_ALGORITHM( BcmCollisionTimeAlg )
}
#include "GaudiKernel/LoadFactoryEntries.h"
LOAD_FACTORY_ENTRIES(BCM_BackgroundAlgs)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment