diff --git a/DDDigi/README.md b/DDDigi/README.md index 1da2826e8c2ee9dd844cdbac79bd19da2e411c88..598468693a10e19ede90139ea82298bca2250e69 100644 --- a/DDDigi/README.md +++ b/DDDigi/README.md @@ -48,6 +48,21 @@ The parallelization can be configured for each subdetector at each level accordi boundary conditions e.g. given by cross-talk or the data volume arising from the energy deposits of the simulation. +DDDigi Components +================= + +- DigiDDG4ROOT Reader for ROOT files produced with DDG4. + Properties: + `input` vector<string> List of input files to be processed + `tree` string Name of the main data tree. default: `EVENT` + `containers` vector<string> List of containers to be loaded to DDDigi. + If empty => all. + `segment` string Name of the input segment. default: "inputs" + `mask` integer Mask of this input source in the store. default: NO_MASK (0x0) + `rescan` boolean Rescan input sources for continuous execution. default: true + `keep_raw` (true) Keep raw input as opaque objects in the DDDigi store. + +  diff --git a/DDDigi/ddg4/DigiDDG4Input.cpp b/DDDigi/ddg4/DigiDDG4Input.cpp index 5aeb34738ba53947ab553672e55d059b92cc6969..ca56883f364838f96c19260649b3a6f7c50fcc0c 100644 --- a/DDDigi/ddg4/DigiDDG4Input.cpp +++ b/DDDigi/ddg4/DigiDDG4Input.cpp @@ -39,7 +39,6 @@ namespace dd4hep { static constexpr double epsilon = std::numeric_limits<double>::epsilon(); /// Property to generate extra history records - bool m_seperate_history { true }; bool m_keep_raw { false }; mutable TClass* m_trackerHitClass { nullptr }; @@ -79,21 +78,18 @@ namespace dd4hep { DigiDDG4ROOT(const DigiKernel& krnl, const std::string& nam) : DigiROOTInput(krnl, nam) { - declareProperty("seperate_history", m_seperate_history); declareProperty("keep_raw", m_keep_raw); } template <typename T> void conv_hits(DigiContext& context, DataSegment& segment, - const std::string& tag, int mask, const char* name, void* ptr) const + const std::string& tag, Key::mask_type mask, const char* name, void* ptr) const { using wrap_t = std::shared_ptr<sim::Geant4HitData>; - bool sep_history = m_seperate_history; std::size_t len = 0; std::string nam = name; std::vector<wrap_t> geant4_hits; DepositVector out(nam, mask); - DetectorHistory hist(nam+".hist", mask); if ( ptr ) { input_data<T> data(ptr); for(size_t i=0; i < data.items->size(); ++i) { @@ -110,16 +106,11 @@ namespace dd4hep { dep.deposit = p->energyDeposit; dep.position = pos; - history_key.set_mask(Key::mask_type(mask)); + history_key.set_mask(mask); history_key.set_item(out.size()); history_key.set_segment(segment.id); - - if ( sep_history ) { - History entry { }; - entry.hits.emplace_back(history_key, dep.deposit); - add_particle_history(p, history_key, entry); - hist.emplace(cell, std::move(entry)); - } + dep.history.hits.emplace_back(history_key, dep.deposit); + add_particle_history(p, history_key, dep.history); out.emplace(cell, std::move(dep)); if ( m_keep_raw ) { geant4_hits.emplace_back(std::move(raw)); @@ -132,14 +123,10 @@ namespace dd4hep { info("%s++ %-24s Converted %6ld DDG4 %-14s hits to %6ld cell deposits", context.event->id(), name, len, tag.c_str(), out.size()); Key depo_key(out.name, mask); - segment.emplace(depo_key, std::make_any<DepositVector>(std::move(out))); + segment.put(depo_key, std::move(out)); if ( m_keep_raw ) { Key src_key(nam+".ddg4", mask); - segment.emplace(src_key, std::make_any<std::vector<wrap_t>>(std::move(geant4_hits))); - } - if ( sep_history ) { - Key hist_key(hist.name, mask); - segment.emplace(hist_key, std::make_any<DetectorHistory>(std::move(hist))); + segment.emplace_any(src_key, std::make_any<std::vector<wrap_t> >(std::move(geant4_hits))); } } @@ -164,7 +151,6 @@ namespace dd4hep { part.pdgID = p->pdgID; part.charge = p->charge; part.mass = p->mass; - part.history = key.set_item(part_key.item()); key.set_item(out.size()); out.push(key, std::move(part)); @@ -174,10 +160,10 @@ namespace dd4hep { } debug("%s++ Converted %ld DDG4 particles", context.event->id(), out.size()); std::string nam = name; - segment.emplace(part_key, std::make_any<ParticleMapping>(std::move(out))); + segment.put(part_key, std::move(out)); if ( m_keep_raw ) { Key src_key(nam+".ddg4", mask); - segment.emplace(src_key, std::make_any<std::map<Key, wrap_t> >(std::move(source))); + segment.emplace_any(src_key, std::make_any<std::map<Key,wrap_t> >(std::move(source))); } } diff --git a/DDDigi/include/DDDigi/DigiContainerCombine.h b/DDDigi/include/DDDigi/DigiContainerCombine.h index 6343c0ff40bcda0cb700dbb107bd01e0c147fc8f..0ef34ea928e73c988b5e553a250013844827163a 100644 --- a/DDDigi/include/DDDigi/DigiContainerCombine.h +++ b/DDDigi/include/DDDigi/DigiContainerCombine.h @@ -57,7 +57,15 @@ namespace dd4hep { /// Property: mask of the deposit int m_deposit_mask { 0 }; /// Property: Flag to erase already combined containers (not thread-safe!!!) - bool m_erase_combined { false }; + bool m_erase_combined; + /// Property: Flag to indicate to merge + bool m_merge_deposits; + /// Property: Flag to indicate to merge + bool m_merge_response; + /// Property: Flag to indicate to merge + bool m_merge_history; + /// Property: Flag to indicate to merge + bool m_merge_particles; /// Fully qualified keys of all containers to be manipulated std::set<Key::key_type> m_keys { }; diff --git a/DDDigi/include/DDDigi/DigiData.h b/DDDigi/include/DDDigi/DigiData.h index 016f17d65a84477b87978fad0d32275a7944ed09..565e52c692a10187ffa0b0c387bc1da6dbf39634 100644 --- a/DDDigi/include/DDDigi/DigiData.h +++ b/DDDigi/include/DDDigi/DigiData.h @@ -490,6 +490,8 @@ namespace dd4hep { long flag { 0 }; /// Source mask of this deposit Key::mask_type mask { 0 }; + /// Deposit history + History history { }; public: /// Default constructor @@ -855,7 +857,15 @@ namespace dd4hep { /** Locked operations */ /// Emplace data item (locked) - bool emplace(Key key, std::any&& data); + bool emplace_any(Key key, std::any&& data); + + template <typename T> + bool emplace(Key key, T&& data_item) { + key.set_segment(this->id); + data_item.key.set_segment(this->id); + return this->emplace_any(key, std::move(data_item)); + } + /// Move data items other than std::any to the data segment template <typename DATA> bool put(Key key, DATA&& data); /// Remove data item from segment (locked) diff --git a/DDDigi/include/DDDigi/DigiStoreDump.h b/DDDigi/include/DDDigi/DigiStoreDump.h index be581e83791f943047dd8b07b7cc30f133e809d9..5e731935bc71e6a982abec4f92334009a88c801a 100644 --- a/DDDigi/include/DDDigi/DigiStoreDump.h +++ b/DDDigi/include/DDDigi/DigiStoreDump.h @@ -60,12 +60,7 @@ namespace dd4hep { template <typename T> std::string data_header(Key key, const std::string& tag, const T& data) const; template <typename T> records_t dump_history(context_t& context, Key key, const T& container) const; template <typename T> records_t dump_history(context_t& context, Key key, const T& item, std::size_t seq_no) const; - - records_t - dump_deposit_history(context_t& context, Key container_key, const DepositMapping& container) const; - - records_t - dump_deposit_history(context_t& context, Key container_key, const DepositVector& container) const; + template <typename T> records_t dump_deposit_history(context_t& context, Key container_key, const T& container) const; records_t dump_particle_history(context_t& context, Key container_key, const ParticleMapping& container) const; diff --git a/DDDigi/plugins/DigiDepositSmearPositionTrack.cpp b/DDDigi/plugins/DigiDepositSmearPositionTrack.cpp index 0cd9ff32415ab5b0a6e4b650982c634b48b11858..f4746c598e41057083c204f84014d6beda677453 100644 --- a/DDDigi/plugins/DigiDepositSmearPositionTrack.cpp +++ b/DDDigi/plugins/DigiDepositSmearPositionTrack.cpp @@ -24,6 +24,7 @@ /// Namespace for the AIDA detector description toolkit namespace dd4hep { + /// Namespace for the Digitization part of the AIDA detector description toolkit namespace digi { @@ -70,11 +71,7 @@ namespace dd4hep { CellID cell = dep.first; EnergyDeposit& depo = dep.second; auto* ctxt = volMgr.lookupContext(cell); -#ifdef DDDIGI_INPLACE_HISTORY Direction part_momentum = depo.history.average_particle_momentum(ev); -#else - Direction part_momentum = depo.momentum; -#endif Position local_pos = ctxt->worldToLocal(depo.position); Position local_dir = ctxt->worldToLocal(part_momentum).unit(); double cos_u = local_dir.Dot(Position(1,0,0)); diff --git a/DDDigi/plugins/DigiHitHistoryDrop.cpp b/DDDigi/plugins/DigiHitHistoryDrop.cpp index e30bcd61ec185dbf554425d1893f1b867d212902..eca3c87f7e1672bb4e9e531c747a9c70b9164753 100644 --- a/DDDigi/plugins/DigiHitHistoryDrop.cpp +++ b/DDDigi/plugins/DigiHitHistoryDrop.cpp @@ -59,6 +59,17 @@ namespace dd4hep { InstanceCount::increment(this); } + template <typename T> + std::pair<std::size_t, std::size_t> drop_history(T& cont) const { + std::size_t num_drop_hit = 0; + std::size_t num_drop_particle = 0; + for( auto& dep : cont ) { + auto ret = dep.second.history.drop(); + num_drop_hit += ret.first; + num_drop_particle += ret.second; + } + return std::make_pair(num_drop_hit,num_drop_particle); + } std::pair<std::size_t, std::size_t> drop_history(DetectorHistory& cont) const { std::size_t num_drop_hit = 0; std::size_t num_drop_particle = 0; @@ -79,7 +90,17 @@ namespace dd4hep { Key key(i.first); auto im = std::find(m_masks.begin(), m_masks.end(), key.mask()); if( im != m_masks.end() ) { - if( DetectorHistory* h = std::any_cast<DetectorHistory>(&i.second) ) { + if ( DepositMapping* m = std::any_cast<DepositMapping>(&i.second) ) { + auto ret = drop_history(*m); + num_drop_hit += ret.first; + num_drop_particle += ret.second; + } + else if ( DepositVector* v = std::any_cast<DepositVector>(&i.second) ) { + auto ret = drop_history(*v); + num_drop_hit += ret.first; + num_drop_particle += ret.second; + } + else if( DetectorHistory* h = std::any_cast<DetectorHistory>(&i.second) ) { auto [nhit, npart] = drop_history(*h); num_drop_hit += nhit; num_drop_particle += npart; diff --git a/DDDigi/plugins/DigiIPCreate.cpp b/DDDigi/plugins/DigiIPCreate.cpp index e92ba6eb8f08faf09b408db496ad7d5092eef95e..70f973d152fd9da149373b7a38f800add49242f9 100644 --- a/DDDigi/plugins/DigiIPCreate.cpp +++ b/DDDigi/plugins/DigiIPCreate.cpp @@ -27,6 +27,7 @@ namespace dd4hep { Position m_offset_ip; Position m_sigma_ip; mutable Position m_interaction_point; + public: /// Standard constructor DigiIPCreate(const DigiKernel& krnl, const std::string& nam) @@ -36,6 +37,7 @@ namespace dd4hep { declareProperty("sigma_ip", m_sigma_ip); declareProperty("interaction_point", m_interaction_point); } + /// Main functional callback virtual void execute(DigiContext& context) const override final { auto& rndm = context.randomGenerator(); diff --git a/DDDigi/plugins/DigiSegmentDepositPrint.cpp b/DDDigi/plugins/DigiSegmentDepositPrint.cpp index d4e72a230898c99f364d4e98913b1e21e9290dce..ea250f1d6e741c6c6bc56b320e977897bec86ce4 100644 --- a/DDDigi/plugins/DigiSegmentDepositPrint.cpp +++ b/DDDigi/plugins/DigiSegmentDepositPrint.cpp @@ -41,10 +41,8 @@ namespace dd4hep { for( const auto& dep : cont ) { if( predicate(dep) ) { info(fmt, predicate.segmentation->split_id(dep.first), dep.first, -#ifdef DDDIGI_INPLACE_HISTORY dep.second.history.hits.size(), dep.second.history.particles.size(), -#endif dep.second.deposit); } } @@ -55,9 +53,7 @@ namespace dd4hep { char format[256]; ::snprintf(format, sizeof(format), "%s[%s] %s-id: %%d [processor:%d] Cell: %%016lX mask: %016lX " -#ifdef DDDIGI_INPLACE_HISTORY "hist:%%4ld hits %%4ld parts. " -#endif "entries deposit: %%f", context.event->id(), predicate.segmentation->idspec.name(), predicate.segmentation->cname(), @@ -72,6 +68,7 @@ namespace dd4hep { }; } // End namespace digi } // End namespace dd4hep -// Factory definition + +/// Factory definition #include <DDDigi/DigiFactories.h> DECLARE_DIGIACTION_NS(dd4hep::digi,DigiSegmentDepositPrint) diff --git a/DDDigi/plugins/DigiSimpleADCResponse.cpp b/DDDigi/plugins/DigiSimpleADCResponse.cpp index a6adf2c53d8d9c180586fc6ac82cc5aadade6d2b..d4ce388c4e6e00e3379cb3f10a8e99e611e55633 100644 --- a/DDDigi/plugins/DigiSimpleADCResponse.cpp +++ b/DDDigi/plugins/DigiSimpleADCResponse.cpp @@ -62,16 +62,6 @@ namespace dd4hep { response.emplace(cell, {adc_count, ADCValue::address_t(cell)}); } } -#ifdef DDDIGI_INPLACE_HISTORY - std::string history_name = input.name + postfix + m_history_postfix; - DetectorHistory history (history_name, work.output.mask); - for( const auto& dep : input ) { - if ( predicate(dep) ) { - history.insert(dep.first, dep.second.history); - } - } - work.output.data.put(history.key, std::move(history)); -#endif info("%s+++ %-32s %6ld ADC values. Input: %-32s %6ld deposits", tag, response_name.c_str(), response.size(), input.name.c_str(), input.size()); work.environ.output.data.put(response.key, std::move(response)); diff --git a/DDDigi/python/DDDigiDict.C b/DDDigi/python/DDDigiDict.C index 9e314fdf7b06f4971bdfe1e444d0dce63ad437e2..0b2d6f1ca09ec4c2b1a5386877404d6c1a0228d9 100644 --- a/DDDigi/python/DDDigiDict.C +++ b/DDDigi/python/DDDigiDict.C @@ -140,7 +140,7 @@ namespace dd4hep { /// Set DigiAction property static int setProperty(DigiAction* action, const std::string& name, const std::string& value) { init_grammar_types(); - printout(INFO,"setProperty","Setting property: %s.%s = %s", action->name().c_str(), name.c_str(), value.c_str()); + printout(DEBUG,"setProperty","Setting property: %s.%s = %s", action->name().c_str(), name.c_str(), value.c_str()); if ( action->hasProperty(name) ) { action->property(name).str(value); return 1; diff --git a/DDDigi/src/DigiAttenuator.cpp b/DDDigi/src/DigiAttenuator.cpp index cd9c7421a29dff41a1b4b92519866f7332d382b4..a32ec88ff5c490ee229097c2006f511234f90a5a 100644 --- a/DDDigi/src/DigiAttenuator.cpp +++ b/DDDigi/src/DigiAttenuator.cpp @@ -48,6 +48,9 @@ DigiAttenuator::attenuate(T& cont, const predicate_t& predicate) const { for( auto& dep : cont ) { if ( predicate(dep) ) { dep.second.deposit *= m_factor; + auto& e = dep.second.history; + for( auto& h : e.hits ) h.weight *= m_factor; + for( auto& h : e.particles ) h.weight *= m_factor; } } return cont.size(); diff --git a/DDDigi/src/DigiContainerCombine.cpp b/DDDigi/src/DigiContainerCombine.cpp index 700c97c2dc2017de3b8339914f942056592c63df..9608facdd1a2a7ac69ce766456b619a03b084c59 100644 --- a/DDDigi/src/DigiContainerCombine.cpp +++ b/DDDigi/src/DigiContainerCombine.cpp @@ -84,17 +84,39 @@ public: /// Specialized deposit merger: implicitly assume identical item types are mapped sequentially template<typename OUT, typename IN> void merge_depos(OUT& output, IN& input, int thr) { std::size_t cnt = 0; - std::string nam = input.name; - auto mask = input.key.mask(); - if ( combine->m_erase_combined ) + const auto& nam = input.name; + Key::mask_type mask = input.key.mask(); + + if ( combine->m_erase_combined ) { cnt = output.merge(std::move(input)); - else + } + else { cnt = output.insert(input); + } combine->info(this->format, thr, nam.c_str(), mask, cnt, "deposits"); this->cnt_depos += cnt; this->cnt_conts++; } + /// Generic deposit merger: implicitly assume identical item types are mapped sequentially + void merge(const std::string& nam, size_t start, int thr) { + Key key = keys[start]; + DepositVector out(nam, combine->m_deposit_mask); + for( std::size_t j = start; j < keys.size(); ++j ) { + if ( keys[j].item() == key.item() ) { + if ( DepositMapping* m = std::any_cast<DepositMapping>(work[j]) ) + merge_depos(out, *m, thr); + else if ( DepositVector* v = std::any_cast<DepositVector>(work[j]) ) + merge_depos(out, *v, thr); + else + break; + used_keys_insert(keys[j]); + } + } + key.set_mask(combine->m_deposit_mask); + outputs.emplace(key, std::move(out)); + } + /// Merge history records: implicitly assume identical item types are mapped sequentially void merge_hist(const std::string& nam, size_t start, int thr) { std::size_t cnt; @@ -116,6 +138,7 @@ public: key.set_mask(combine->m_deposit_mask); outputs.emplace(key, std::move(out)); } + /// Merge detector rsponse records: implicitly assume identical item types are mapped sequentially void merge_response(const std::string& nam, size_t start, int thr) { std::size_t cnt; @@ -137,6 +160,7 @@ public: key.set_mask(combine->m_deposit_mask); outputs.emplace(key, std::move(out)); } + /// Merge particle objects: implicitly assume identical item types are mapped sequentially void merge_parts(const std::string& nam, size_t start, int thr) { std::size_t cnt; @@ -156,24 +180,7 @@ public: key.set_mask(combine->m_deposit_mask); outputs.emplace(key, std::move(out)); } - /// Generic deposit merger: implicitly assume identical item types are mapped sequentially - void merge(const std::string& nam, size_t start, int thr) { - Key key = keys[start]; - DepositVector out(nam, combine->m_deposit_mask); - for( std::size_t j = start; j < keys.size(); ++j ) { - if ( keys[j].item() == key.item() ) { - if ( DepositMapping* m = std::any_cast<DepositMapping>(work[j]) ) - merge_depos(out, *m, thr); - else if ( DepositVector* v = std::any_cast<DepositVector>(work[j]) ) - merge_depos(out, *v, thr); - else - break; - used_keys_insert(keys[j]); - } - } - key.set_mask(combine->m_deposit_mask); - outputs.emplace(key, std::move(out)); - } + /// Merge single item type void merge_one(Key::itemkey_type itm, int thr) { const std::string& opt = combine->m_output_name_flag; @@ -182,23 +189,23 @@ public: continue; /// Merge deposit mapping if ( DepositMapping* depom = std::any_cast<DepositMapping>(work[i]) ) { - merge(depom->name+opt, i, thr); + if ( combine->m_merge_deposits ) merge(depom->name+opt, i, thr); } /// Merge deposit vector else if ( DepositVector* depov = std::any_cast<DepositVector>(work[i]) ) { - merge(depov->name+opt, i, thr); + if ( combine->m_merge_deposits ) merge(depov->name+opt, i, thr); } /// Merge detector response else if ( DetectorResponse* resp = std::any_cast<DetectorResponse>(work[i]) ) { - merge_response(resp->name+opt, i, thr); + if ( combine->m_merge_response ) merge_response(resp->name+opt, i, thr); } /// Merge response history else if ( DetectorHistory* hist = std::any_cast<DetectorHistory>(work[i]) ) { - merge_hist(hist->name+opt, i, thr); + if ( combine->m_merge_history ) merge_hist(hist->name+opt, i, thr); } /// Merge particle container else if ( ParticleMapping* parts = std::any_cast<ParticleMapping>(work[i]) ) { - merge_parts(parts->name+opt, i, thr); + if ( combine->m_merge_particles ) merge_parts(parts->name+opt, i, thr); } break; } @@ -234,7 +241,11 @@ DigiContainerCombine::DigiContainerCombine(const DigiKernel& krnl, const std::st declareProperty("output_segment", m_output = "deposits"); declareProperty("output_mask", m_deposit_mask); declareProperty("output_name_flag", m_output_name_flag); - declareProperty("erase_combined", m_erase_combined); + declareProperty("erase_combined", m_erase_combined = false); + declareProperty("merge_deposits", m_merge_deposits = true); + declareProperty("merge_response", m_merge_response = true); + declareProperty("merge_history", m_merge_history = true); + declareProperty("merge_particles", m_merge_particles = false); m_kernel.register_initialize(std::bind(&DigiContainerCombine::initialize,this)); InstanceCount::increment(this); } diff --git a/DDDigi/src/DigiData.cpp b/DDDigi/src/DigiData.cpp index 2e90d70e9cc4686f1d3e3fd06aad8b2bda78d893..bf1f99061561d3be1b410600e2636c1ac66dfbcd 100644 --- a/DDDigi/src/DigiData.cpp +++ b/DDDigi/src/DigiData.cpp @@ -155,6 +155,7 @@ void EnergyDeposit::update_deposit_weighted(const EnergyDeposit& upda) { position = pos; momentum = mom; deposit = sum; + history.update(upda.history); } /// Update the deposit using deposit weighting @@ -165,6 +166,7 @@ void EnergyDeposit::update_deposit_weighted(EnergyDeposit&& upda) { position = pos; momentum = mom; deposit = sum; + history.update(upda.history); } /// Merge new deposit map onto existing map @@ -365,7 +367,13 @@ std::size_t DetectorResponse::insert(const DetectorResponse& updates) { /// Merge new deposit map onto existing map (not thread safe!) std::size_t DetectorHistory::merge(DetectorHistory&& updates) { std::size_t len = updates.size(); - data.insert(data.end(), updates.data.begin(), updates.data.end()); + if ( data.empty() ) { + data = std::move(updates.data); + } + else { + for(auto& e : updates.data) + data.emplace(data.end(), std::move(e)); + } return len; } @@ -383,7 +391,7 @@ DataSegment::DataSegment(std::mutex& l, Key::segment_type i) } /// Remove data item from segment -bool DataSegment::emplace(Key key, std::any&& item) { +bool DataSegment::emplace_any(Key key, std::any&& item) { bool has_value = item.has_value(); #if DD4HEP_DDDIGI_DEBUG printout(INFO, "DataSegment", "PUT Key No.%4d: %-32s %016lX -> %04X %04X %08Xld Value:%s %s", @@ -401,8 +409,10 @@ bool DataSegment::emplace(Key key, std::any&& item) { /// Move data items other than std::any to the data segment template <typename DATA> bool DataSegment::put(Key key, DATA&& value) { + key.set_segment(this->id); + value.key.set_segment(this->id); std::any item = std::make_any<DATA>(std::move(value)); - return this->emplace(key, std::move(item)); + return this->emplace_any(key, std::move(item)); } template bool DataSegment::put(Key key, DepositVector&& data); diff --git a/DDDigi/src/DigiInputAction.cpp b/DDDigi/src/DigiInputAction.cpp index 160803e90bce6c7371af1478d71f7e28812e6321..5ea068401b26e870e68c977d98db3b9e54828154 100644 --- a/DDDigi/src/DigiInputAction.cpp +++ b/DDDigi/src/DigiInputAction.cpp @@ -26,10 +26,10 @@ using namespace dd4hep::digi; DigiInputAction::DigiInputAction(const DigiKernel& kernel, const string& nam) : DigiEventAction(kernel, nam) { - declareProperty("input", m_input_sources); - declareProperty("segment", m_input_segment); - declareProperty("mask", m_input_mask); - declareProperty("rescan_inputs", m_input_rescan); + declareProperty("input", m_input_sources); + declareProperty("segment", m_input_segment); + declareProperty("mask", m_input_mask); + declareProperty("rescan", m_input_rescan); InstanceCount::increment(this); } diff --git a/DDDigi/src/DigiStoreDump.cpp b/DDDigi/src/DigiStoreDump.cpp index 37f9e715ccfcee3c961afe50330f488ed1cd5dbe..12fda1b07f027d2d960ed5f3e0cd3264f25ec04a 100644 --- a/DDDigi/src/DigiStoreDump.cpp +++ b/DDDigi/src/DigiStoreDump.cpp @@ -94,13 +94,12 @@ DigiStoreDump::dump_history(DigiContext& context, Key::key_name(history_key).c_str(), history_key.segment(), history_key.mask(), history_key.item(), long(&data.second)); records.emplace_back(line); - line = format("| PDG:%6d Charge:%-2d Mass:%7.2f v:%7.5g %7.5g %7.5g p:%10g %10g %10g %016lX", + line = format("| PDG:%6d Charge:%-2d Mass:%7.2f v:%7.5g %7.5g %7.5g p:%12g %12g %12g %016lX", par.pdgID, int(par.charge), par.mass, vtx.X(), vtx.Y(), vtx.Z(), mom.X(), mom.Y(), mom.Z(), long(&par)); records.emplace_back(line); return records; } -#ifdef DDDIGI_INPLACE_HISTORY template <> std::vector<std::string> DigiStoreDump::dump_history(DigiContext& context, Key container_key, @@ -127,7 +126,7 @@ DigiStoreDump::dump_history(DigiContext& context, Key k = entry.source; str.str(""); str << "| Hit-history[" << i << "]:"; - line = format("%-30s Segment:%04X Mask:%04X Cell:%08X %.8g", + line = format("%-30s Segment:%04X Mask:%04X Cell:%08X Weight:%.8g", str.str().c_str(), k.segment(), k.mask(), k.item(), entry.weight); records.emplace_back(line); line = format("| pos: %7.3f %7.3f %7.3f p: %7.3f %7.3f %7.3f deposit: %7.3f", @@ -151,7 +150,6 @@ DigiStoreDump::dump_history(DigiContext& context, } return records; } -#endif template <> std::vector<std::string> DigiStoreDump::dump_history(DigiContext& context, @@ -179,7 +177,7 @@ DigiStoreDump::dump_history(DigiContext& context, Key k = entry.source; str.str(""); str << "| Hit-history[" << i << "]:"; - line = format("%-30s Segment:%04X Mask:%04X Cell:%08X %.8g", + line = format("%-30s Segment:%04X Mask:%04X Cell:%08X Weight:%.8g", str.str().c_str(), k.segment(), k.mask(), k.item(), entry.weight); records.emplace_back(line); line = format("| pos: %7.3f %7.3f %7.3f p: %7.3f %7.3f %7.3f deposit: %7.3f", @@ -215,35 +213,23 @@ DigiStoreDump::dump_history(DigiContext& context, Key container_key, const T& co return records; } -std::vector<std::string> -DigiStoreDump::dump_deposit_history(DigiContext& /*context*/, Key container_key, const DepositMapping& container) const { +template <typename T> std::vector<std::string> +DigiStoreDump::dump_deposit_history(DigiContext& context, Key container_key, const T& container) const { std::vector<std::string> records; auto line = format("|---- %s", data_header(container_key, "deposits", container).c_str()); records.emplace_back(line); -#ifdef DDDIGI_INPLACE_HISTORY std::size_t count = 0; for( const auto& item : container ) { auto rec = dump_history(context, container_key, item, count++); records.insert(records.end(), rec.begin(), rec.end()); } -#endif return records; } +template std::vector<std::string> +DigiStoreDump::dump_deposit_history(DigiContext& context, Key container_key, const DepositMapping& container) const; -std::vector<std::string> -DigiStoreDump::dump_deposit_history(DigiContext& /*context*/, Key container_key, const DepositVector& container) const { - std::vector<std::string> records; - auto line = format("|---- %s", data_header(container_key, "deposits", container).c_str()); - records.emplace_back(line); -#ifdef DDDIGI_INPLACE_HISTORY - std::size_t count = 0; - for( const auto& item : container ) { - auto rec = dump_history(context, container_key, item, count++); - records.insert(records.end(), rec.begin(), rec.end()); - } -#endif - return records; -} +template std::vector<std::string> +DigiStoreDump::dump_deposit_history(DigiContext& context, Key container_key, const DepositVector& container) const; std::vector<std::string> DigiStoreDump::dump_particle_history(DigiContext& context, Key container_key, const ParticleMapping& container) const { diff --git a/examples/DDDigi/scripts/DigiTest.py b/examples/DDDigi/scripts/DigiTest.py index 2b8c6e7fab1f98920385363c378aa7c654dcf704..ea9c5106d7c2ee910c8afc7f6469bbd689684cbf 100644 --- a/examples/DDDigi/scripts/DigiTest.py +++ b/examples/DDDigi/scripts/DigiTest.py @@ -47,6 +47,12 @@ class Test(dddigi.Digitize): 'MiniTel.run00000006.root', 'MiniTel.run00000007.root', 'MiniTel.run00000008.root'] + if not os.path.exists(self.inputs[0]): + if os.path.exists('DDDigi'): + os.chdir('DDDigi') + if not os.path.exists(self.inputs[0]): + # This will cause: FileNotFoundError: [Errno 2] No such file or directory: 'xxxxx' + open(self.inputs[0]) def segment_action(self, nam, **options): obj = dddigi.Interface.createSegmentAction(self.kernel(), str(nam))