diff --git a/DDCore/src/Evaluator/hash_map.src b/DDCore/src/Evaluator/hash_map.src index 1cbf5f36350edbe67de46624e08c3d729ab599f4..ee1dc2abdaeb3b674a2a1b0481f0996322da744d 100644 --- a/DDCore/src/Evaluator/hash_map.src +++ b/DDCore/src/Evaluator/hash_map.src @@ -28,8 +28,18 @@ template<class K, class T> class hash_map { private: - hash_map(const hash_map& ) {} - hash_map& operator=(const hash_map&) { return *this; } + hash_map(const hash_map& c) + : table(0), cur_size(0), max_size(0), max_load(0), default_value(c.default_value) + { + } + hash_map& operator=(const hash_map& c) { + table = 0; + cur_size = 0; + max_size = 0; + max_load = 0; + default_value = c.default_value; + return *this; + } public: struct Entry { // Hash_map entry std::pair<const K,T> data; diff --git a/DDCore/src/Evaluator/stack.src b/DDCore/src/Evaluator/stack.src index 9dfabd4c3f1be73ba1d4092fa27fe1d8ec483ac8..5a78318824eb70b3ec5a27986607e3d39532d95c 100644 --- a/DDCore/src/Evaluator/stack.src +++ b/DDCore/src/Evaluator/stack.src @@ -22,8 +22,8 @@ private: int k, max_size; T * v; - stack(const stack& ) {} - stack& operator=(const stack&) { return *this; } + stack(const stack& c) : k(0), max_size(0), v(0) {} + stack& operator=(const stack&) { k=0; max_size=0; v=0; return *this; } public: stack() : k(0), max_size(20), v(new T[20]) {} diff --git a/DDCore/src/Evaluator/string.src b/DDCore/src/Evaluator/string.src index 41d382c15e4946080065e314f42fcd102814d67a..a675a99b1de5fdc8a757bd23fb108c8c7fcdf4a8 100644 --- a/DDCore/src/Evaluator/string.src +++ b/DDCore/src/Evaluator/string.src @@ -40,7 +40,10 @@ struct string { } // Copy constructor from string. - string(const string& x) { x.p->n++; p = x.p; } + string(const string& x) { + x.p->n++; + p = x.p; + } // Destructor. ~string() { if (--p->n == 0) { delete [] p->s; delete p; } } diff --git a/DDDetectors/src/CaloFaceBarrel_surfaces.cpp b/DDDetectors/src/CaloFaceBarrel_surfaces.cpp index 252bd34c54a572a1cc5454b1b2a2db102c0e1bc5..59fb56de5566c9fadf54c1bfc37ce6124738e1e4 100644 --- a/DDDetectors/src/CaloFaceBarrel_surfaces.cpp +++ b/DDDetectors/src/CaloFaceBarrel_surfaces.cpp @@ -84,11 +84,10 @@ namespace{ template <> void Installer<UserData>::handle_arguments(int argc, char** argv) { for(int i=0; i<argc; ++i) { - double value(0) ; char* ptr = ::strchr(argv[i],'='); if ( ptr ) { std::string name( argv[i] , ptr ) ; - value = DD4hep::Geometry::_toDouble(++ptr); + double value = DD4hep::Geometry::_toDouble(++ptr); std::cout << "DD4hep_CaloFaceBarrelSurfacePlugin: argument[" << i << "] = " << name << " = " << value << std::endl; diff --git a/DDDetectors/src/CaloFaceEndcap_surfaces.cpp b/DDDetectors/src/CaloFaceEndcap_surfaces.cpp index 6f51161c275c45c0ff17c7fbb7746a4a74f9febd..13fa9c72963ac395790867960553b363aff6d4ce 100644 --- a/DDDetectors/src/CaloFaceEndcap_surfaces.cpp +++ b/DDDetectors/src/CaloFaceEndcap_surfaces.cpp @@ -89,11 +89,10 @@ namespace{ template <> void Installer<UserData>::handle_arguments(int argc, char** argv) { for(int i=0; i<argc; ++i) { - double value(0) ; char* ptr = ::strchr(argv[i],'='); if ( ptr ) { std::string name( argv[i] , ptr ) ; - value = DD4hep::Geometry::_toDouble(++ptr); + double value = DD4hep::Geometry::_toDouble(++ptr); std::cout << "DD4hep_CaloFaceEndcapSurfacePlugin: argument[" << i << "] = " << name << " = " << value << std::endl; diff --git a/DDDetectors/src/EcalBarrel_geo.cpp b/DDDetectors/src/EcalBarrel_geo.cpp index 27e621f7ef326d4d4c1d63c938d42487076b00a2..b1d1e8808793f0858fe25bc408b8422f70d3b4fc 100644 --- a/DDDetectors/src/EcalBarrel_geo.cpp +++ b/DDDetectors/src/EcalBarrel_geo.cpp @@ -49,8 +49,7 @@ static Ref_t create_detector(LCDD& lcdd, xml_h e, SensitiveDetector sens) { sdet.setPlacement(env_phv); DetElement stave_det("stave0",det_id); - double dx = mod_z / std::sin(dphi); // dx per layer - dx = 0; + double dx = 0.0; //mod_z / std::sin(dphi); // dx per layer // Compute the top and bottom face measurements. double trd_x2 = (2 * std::tan(hphi) * outer_r - dx)/2 - tolerance; diff --git a/DDDetectors/src/SiTrackerBarrel_surfaces.cpp b/DDDetectors/src/SiTrackerBarrel_surfaces.cpp index 5d2366c18a0c8356e6550c14426eafc32ccde7aa..f9d566c12447350bc0c6c5d7600c606c57d9ea2e 100644 --- a/DDDetectors/src/SiTrackerBarrel_surfaces.cpp +++ b/DDDetectors/src/SiTrackerBarrel_surfaces.cpp @@ -30,11 +30,10 @@ namespace { namespace{ template <> void Installer<UserData>::handle_arguments(int argc, char** argv) { for(int i=0; i<argc; ++i) { - double value = -1; char* ptr = ::strchr(argv[i],'='); if ( ptr ) { std::string name( argv[i] , ptr ) ; - value = DD4hep::Geometry::_toDouble(++ptr); + double value = DD4hep::Geometry::_toDouble(++ptr); if( name=="dimension" ) data.dimension = value ; std::cout << "DD4hep_SiTrackerBarrelSurfacePlugin: argument[" << i << "] = " << name << " = " << value << std::endl; diff --git a/DDDetectors/src/SurfaceExamplePlugin.cpp b/DDDetectors/src/SurfaceExamplePlugin.cpp index 00c5494cb76c4918e61929812913f4ed4e3bf691..294357c6822bef141dc124a9b32dd83c242f2a0a 100644 --- a/DDDetectors/src/SurfaceExamplePlugin.cpp +++ b/DDDetectors/src/SurfaceExamplePlugin.cpp @@ -16,7 +16,7 @@ // //========================================================================== // Framework include files -namespace { struct UserData { int a,b,c; }; } +namespace { struct UserData { /* int a,b,c; */ }; } #define SURFACEINSTALLER_DATA UserData #define DD4HEP_USE_SURFACEINSTALL_HELPER DD4hep_SurfaceExamplePlugin #include "DD4hep/SurfaceInstaller.h" diff --git a/DDEve/lcio/LCIOEventHandler.cpp b/DDEve/lcio/LCIOEventHandler.cpp index 176ba2b9c5342add8e12529d4e7031a565bb167c..ec259ca8d02c636d9cb0129f9e54fd93b841087c 100644 --- a/DDEve/lcio/LCIOEventHandler.cpp +++ b/DDEve/lcio/LCIOEventHandler.cpp @@ -146,7 +146,6 @@ size_t LCIOEventHandler::collectionLoop(const std::string& collection, DDEvePart /// Open new data file bool LCIOEventHandler::Open(const std::string&, const std::string& name) { - string err; if ( m_hasFile ) m_lcReader->close(); m_hasFile = false; m_hasEvent = false; @@ -166,8 +165,9 @@ bool LCIOEventHandler::NextEvent() { if ( hasFile() ) { m_event = m_lcReader->readNextEvent(); if ( m_event ) { - const std::vector<std::string>* collnames = m_event->getCollectionNames(); - for( std::vector< std::string >::const_iterator i = collnames->begin(); i != collnames->end(); i++){ + typedef std::vector<std::string> _S; + const _S* collnames = m_event->getCollectionNames(); + for( _S::const_iterator i = collnames->begin(); i != collnames->end(); ++i) { LCCollection* c = m_event->getCollection(*i); m_data[c->getTypeName()].push_back(make_pair((*i).c_str(),c->getNumberOfElements())); m_branches[*i] = c; diff --git a/DDG4/examples/initAClick.C b/DDG4/examples/initAClick.C index ed7dde7e3408284c43ca00133b5e944b1da14acd..f439c5e22d88a9ff8bc60915deac985f4793d40f 100644 --- a/DDG4/examples/initAClick.C +++ b/DDG4/examples/initAClick.C @@ -58,13 +58,13 @@ int processMacro(const char* macro, bool end_process) { /// Initialize the ROOT environment to compile and execute a ROOT AClick int initAClick(const char* command=0) { std::string rootsys = make_str(gSystem->Getenv("ROOTSYS")); - std::string g4_base = make_str(gSystem->Getenv("G4INSTALL")); + std::string geant4 = make_str(gSystem->Getenv("G4INSTALL")); std::string dd4hep = make_str(gSystem->Getenv("DD4hepINSTALL")); - std::string libs = (" -L"+rootsys+"/lib"); - std::string inc = " -I"+dd4hep+"/examples/DDG4/examples" + + std::string clhep = make_str(gSystem->Getenv("CLHEP_DIR")); + std::string libs = " -L"+rootsys+"/lib"; + std::string inc = " -I"+dd4hep+"/examples/DDG4/examples" + " -I"+dd4hep + " -I"+dd4hep+"/include" + - " -I"+g4_base+"/include/Geant4" + " -Wno-shadow -g -O0"; if ( ROOT_VERSION_CODE >= ROOT_VERSION(6,0,0) ) libs += " -lCore -lMathCore"; @@ -72,7 +72,15 @@ int initAClick(const char* command=0) { libs += " -lCore -lCint -lMathCore"; libs += " -pthread -lm -ldl -rdynamic"; libs += " -L"+dd4hep+"/lib -lDDCore -lDDG4 -lDDSegmentation"; - libs += (" -L"+g4_base+"/lib -L"+g4_base+"/lib64 -lG4event -lG4tracking -lG4particles"); + if ( !geant4.empty() ) { + inc += " -I"+geant4+"/include/Geant4"; + libs += (" -L"+geant4+"/lib -L"+geant4+"/lib64 -lG4event -lG4tracking -lG4particles"); + } + if ( !clhep.empty() ) { + // A bit unclear how to deal with CLHEP libraries here, + // if CLHEP is not included in Geant4... + inc += " -I"+clhep+"/include"; + } gSystem->AddIncludePath(inc.c_str()); gSystem->AddLinkedLibs(libs.c_str()); std::cout << "+++ Includes: " << gSystem->GetIncludePath() << std::endl; diff --git a/DDG4/lcio/LCIOFileReader.cpp b/DDG4/lcio/LCIOFileReader.cpp index f649b31b8b7bae632343107e03745bae1ca83fbf..bde3a339ca381e5e280b76d661be9034817fa840 100644 --- a/DDG4/lcio/LCIOFileReader.cpp +++ b/DDG4/lcio/LCIOFileReader.cpp @@ -95,7 +95,8 @@ DD4hep::Simulation::LCIOFileReader::readParticleCollection(int event_number, EVE if ( evt ) { *particles = evt->getCollection(LCIO::MCPARTICLE); if ( *particles ) { - printout(INFO,"LCIOFileReader","read collection %s from event %d in run %d ", LCIO::MCPARTICLE, evt->getEventNumber() , evt->getRunNumber() ); + printout(INFO,"LCIOFileReader","read collection %s from event %d in run %d ", + LCIO::MCPARTICLE, evt->getEventNumber(), evt->getRunNumber()); return EVENT_READER_OK; } } diff --git a/DDG4/plugins/Geant4EventReaderHepMC.cpp b/DDG4/plugins/Geant4EventReaderHepMC.cpp index 1b6c347e7ba9efca36a22465b86175b7709208b5..df551e348c3e55db9fb03942c6149860e8ee10f7 100644 --- a/DDG4/plugins/Geant4EventReaderHepMC.cpp +++ b/DDG4/plugins/Geant4EventReaderHepMC.cpp @@ -102,7 +102,8 @@ namespace DD4hep { float alpha_qed; vector<float> weights; vector<long> random; - EventHeader() : id(0), num_vertices(0), signal_process_id(0), signal_process_vertex(0), + EventHeader() : id(0), num_vertices(0), bp1(0), bp2(0), + signal_process_id(0), signal_process_vertex(0), scale(0.0), alpha_qcd(0.0), alpha_qed(0.0), weights(), random() {} }; @@ -378,8 +379,10 @@ int HepMC::read_vertex(EventStream &info, istream& is, istringstream & input) Geant4Vertex* v = new Geant4Vertex(); Geant4Particle* p; - input >> id >> dummy >> v->x >> v->y >> v->z >> v->time - >> num_orphans_in >> num_particles_out >> weights_size; + if ( v ) { + input >> id >> dummy >> v->x >> v->y >> v->z >> v->time + >> num_orphans_in >> num_particles_out >> weights_size; + } if(!input) { delete v; return 0; @@ -437,9 +440,10 @@ int HepMC::read_vertex(EventStream &info, istream& is, istringstream & input) int HepMC::read_event_header(EventStream &info, istringstream & input, EventHeader& header) { // read values into temp variables, then fill GenEvent - int random_states_size = 0, nmpi = -1; + int random_states_size = 0; input >> header.id; if( info.io_type == gen || info.io_type == extascii ) { + int nmpi = -1; input >> nmpi; if( input.fail() ) return 0; //MSF set_mpi( nmpi ); @@ -539,22 +543,25 @@ int HepMC::read_pdf(EventStream &, istringstream & input) { input >> id2 >> x1 >> x2 >> scale >> pdf1 >> pdf2; if ( input.fail() ) return 0; - // check to see if we are at the end of the line - if( !input.eof() ) { - input >> pdf_id1 >> pdf_id2; - } /* cerr << "Reading pdf, but igoring data!" << endl; pdf->set_id1( id1 ); pdf->set_id2( id2 ); - pdf->set_pdf_id1( pdf_id1 ); - pdf->set_pdf_id2( pdf_id2 ); pdf->set_x1( x1 ); pdf->set_x2( x2 ); pdf->set_scalePDF( scale ); pdf->set_pdf1( pdf1 ); pdf->set_pdf2( pdf2 ); */ + // check to see if we are at the end of the line + if( !input.eof() ) { + double pdf_id1=0.0, pdf_id2=0.0; + input >> pdf_id1 >> pdf_id2; + /* + pdf->set_pdf_id1( pdf_id1 ); + pdf->set_pdf_id2( pdf_id2 ); + */ + } return input.fail() ? 0 : 1; } diff --git a/DDG4/plugins/Geant4TrackerWeightedSD.cpp b/DDG4/plugins/Geant4TrackerWeightedSD.cpp index 9f2f70e126fdf222b67cc194e8858a3ff37e75d2..83f872fde6657a76014aabbd452cba374dc2dfd9 100644 --- a/DDG4/plugins/Geant4TrackerWeightedSD.cpp +++ b/DDG4/plugins/Geant4TrackerWeightedSD.cpp @@ -209,13 +209,13 @@ namespace DD4hep { pre.truth.trackID,int(collection->GetSize()), combined,pre.truth.deposit/CLHEP::keV, pos.X()/CLHEP::mm,pos.Y()/CLHEP::mm,pos.Z()/CLHEP::mm, - (hit_flag&Geant4Tracker::Hit::HIT_STARTED_SURFACE ? "SURFACE" : ""), - (hit_flag&Geant4Tracker::Hit::HIT_STARTED_OUTSIDE ? "OUTSIDE" : ""), - (hit_flag&Geant4Tracker::Hit::HIT_STARTED_INSIDE ? "INSIDE " : ""), + ((hit_flag&Geant4Tracker::Hit::HIT_STARTED_SURFACE) ? "SURFACE" : ""), + ((hit_flag&Geant4Tracker::Hit::HIT_STARTED_OUTSIDE) ? "OUTSIDE" : ""), + ((hit_flag&Geant4Tracker::Hit::HIT_STARTED_INSIDE) ? "INSIDE " : ""), dist_in, - (hit_flag&Geant4Tracker::Hit::HIT_ENDED_SURFACE ? "SURFACE" : ""), - (hit_flag&Geant4Tracker::Hit::HIT_ENDED_OUTSIDE ? "OUTSIDE" : ""), - (hit_flag&Geant4Tracker::Hit::HIT_ENDED_INSIDE ? "INSIDE " : ""), + ((hit_flag&Geant4Tracker::Hit::HIT_ENDED_SURFACE) ? "SURFACE" : ""), + ((hit_flag&Geant4Tracker::Hit::HIT_ENDED_OUTSIDE) ? "OUTSIDE" : ""), + ((hit_flag&Geant4Tracker::Hit::HIT_ENDED_INSIDE) ? "INSIDE " : ""), dist_out); collection->add(hit); } diff --git a/cmake/thisdd4hep_package.sh.in b/cmake/thisdd4hep_package.sh.in index d542f37bc01cd77db1c13e05511ae2e78595cc42..6833ca902054675fe799fa3c661b47607d690904 100644 --- a/cmake/thisdd4hep_package.sh.in +++ b/cmake/thisdd4hep_package.sh.in @@ -12,6 +12,9 @@ if [ ! ${DD4hep_DIR} ]; then export DD4hep_DIR=@DD4hep_DIR@; fi; +if [ @CLHEP_DIR@ ]; then + export CLHEP_DIR=@CLHEP_DIR@; +fi; source ${DD4hep_DIR}/bin/thisdd4hep.sh; # dd4hep_parse_this ${BASH_ARGV[0]} @PackageName@;