00001
00002
00003
00004
00005
00006
00007
00008
00009 #include "AtlfastAlgs/GlobalEventDataMaker.h"
00010 #include "AtlfastAlgs/GlobalEventData.h"
00011 #include "AtlfastEvent/MagField.h"
00012
00013 #include "AtlfastEvent/ParticleCodes.h"
00014
00015 #include "AtlfastUtils/HeaderPrinter.h"
00016
00017
00018 #include "GaudiKernel/DataSvc.h"
00019 #include "GaudiKernel/MsgStream.h"
00020 #include <algorithm>
00021
00022 namespace Atlfast {
00023 using std::sort;
00024 using std::unique;
00025
00026
00027
00028 GlobalEventDataMaker::GlobalEventDataMaker (
00029 const std::string& name,
00030 ISvcLocator* pSvcLocator
00031 )
00032 : Algorithm( name, pSvcLocator )
00033 {
00034
00035 m_lumi = 1;
00036 m_fieldOn = true;
00037 m_fieldStrength = -999.9;
00038 m_barrelForwardEta = 3.2;
00039 m_randSeed = 12345;
00040 m_mcLocation = "GEN_EVENT";
00041 m_justHardScatter = true;
00042
00043 m_invisibles.push_back(12);
00044 m_invisibles.push_back(14);
00045 m_invisibles.push_back(16);
00046 m_invisibles.push_back(1000022);
00047
00048
00049
00050 declareProperty( "Luminosity", m_lumi );
00051 declareProperty( "Invisibles", m_invisibles );
00052 declareProperty( "BFieldOn", m_fieldOn ) ;
00053 declareProperty( "BFieldStrength", m_fieldStrength ) ;
00054 declareProperty( "RandomSeed", m_randSeed ) ;
00055 declareProperty( "BarrelForwardEta", m_barrelForwardEta ) ;
00056 declareProperty( "McLocation", m_mcLocation ) ;
00057 declareProperty( "MonopoleIDs", m_monopoleIDs );
00058 declareProperty( "JustHardScatter", m_justHardScatter );
00059
00060 }
00061
00062
00063
00064
00065
00066 GlobalEventDataMaker::~GlobalEventDataMaker() {
00067 MsgStream log( messageService(), name() ) ;
00068 log << MSG::INFO << "destructor, Global Event Data" << endreq;
00069 }
00070
00071
00072
00073
00074
00075 StatusCode GlobalEventDataMaker::initialize()
00076 {
00077 MsgStream log( messageService(), name() ) ;
00078 log << MSG::DEBUG << "Initialising" << endreq;
00079 log << MSG::DEBUG << "Making Invisibles" << endreq;
00080 m_invisibles.push_back(ParticleCodes::NU_E);
00081 m_invisibles.push_back(ParticleCodes::NU_MU);
00082 m_invisibles.push_back(ParticleCodes::NU_TAU);
00083 std::vector<int>::iterator ibe = m_invisibles.begin();
00084 std::vector<int>::iterator originalEnd = m_invisibles.end();
00085 std::vector<int>::iterator ien;
00086 sort(ibe, originalEnd);
00087 ien=unique(ibe, originalEnd);
00088 m_invisibles.erase(ien, originalEnd);
00089
00090
00091 std::vector<int>::iterator mbe = m_monopoleIDs.begin();
00092 std::vector<int>::iterator mOriginalEnd = m_monopoleIDs.end();
00093 std::vector<int>::iterator men;
00094 sort(mbe, mOriginalEnd);
00095 men=unique(mbe, mOriginalEnd);
00096 m_monopoleIDs.erase(men, mOriginalEnd);
00097
00098 if(m_lumi != 1 && m_lumi != 2){
00099 log << MSG::WARNING << "Luminosity set to unknown value: " << m_lumi << endreq;
00100 log << MSG::WARNING << "Luminosity reset to Low-Lumi == 1" << endreq;
00101 m_lumi = 1;
00102 }
00103 log << MSG::DEBUG << "Making Header" << endreq;
00104 HeaderPrinter hp("Atlfast GlobalEventData Maker:", log);
00105 hp.add("Invisibles (Neutrinos hardwired invisible): ", ibe, ien);
00106 hp.add("Luminosity: ", m_lumi);
00107 hp.add("Initial Random Number Seed: ", m_randSeed);
00108 hp.add("B-field On: ", m_fieldOn);
00109 hp.add("B-field Strength: ", m_fieldStrength);
00110 hp.add("Barrel Forward Eta: ", m_barrelForwardEta);
00111 hp.add("McLocation: ", m_mcLocation);
00112 hp.add("Monopole IDs: ", mbe, men);
00113 hp.add("Just Hard Scatter?: ", m_justHardScatter);
00114 hp.print();
00115 log << MSG::DEBUG << "Calling ged instance" << endreq;
00116
00117
00118
00119 GlobalEventData* ged;
00120
00121 try{
00122 ged = GlobalEventData::Instance();
00123 }catch(std::string errMsg){
00124 log << MSG::DEBUG << "Error making a GlobalEventData"<< errMsg <<endreq;
00125 return StatusCode::FAILURE;
00126 }catch(...){
00127 log << MSG::DEBUG << "Unknown Error making a GlobalEventData"<<endreq;
00128 return StatusCode::FAILURE;
00129 }
00130
00131 log << MSG::DEBUG << "Calling ged setValues" << endreq;
00132 ged->setValues(m_lumi,
00133 m_fieldOn,
00134 m_barrelForwardEta,
00135 m_randSeed,
00136 m_invisibles,
00137 m_mcLocation,
00138 m_monopoleIDs,
00139 m_justHardScatter) ;
00140
00141
00142 log << MSG::DEBUG << "Creating MagField singleton" << endreq;
00143 if ( m_fieldStrength == -999.9 ){
00144 if ( m_fieldOn )
00145 MagField::Instance(2.0);
00146 else
00147 MagField::Instance();
00148 } else {
00149 MagField::Instance(m_fieldStrength);
00150 }
00151
00152 log << MSG::DEBUG << "Everything Completed" << endreq;
00153 return StatusCode::SUCCESS ;
00154 }
00155
00156
00157
00158
00159
00160 StatusCode GlobalEventDataMaker::finalize()
00161 {
00162
00163 MsgStream log( messageService(), name() ) ;
00164 log << MSG::INFO << "Finalizing" << endreq;
00165 return StatusCode::SUCCESS ;
00166 }
00167
00168
00169
00170
00171
00172
00173 StatusCode GlobalEventDataMaker::execute( ){
00174
00175 return StatusCode::SUCCESS;
00176 }
00177
00178 }
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195