Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions RecoDataProducts/inc/CaloCluster.hh
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ namespace mu2e {
};

using CaloClusterCollection = std::vector<mu2e::CaloCluster>;
using CaloClusterPtrCollection = std::vector<art::Ptr<mu2e::CaloCluster>>;
}

#endif
3 changes: 2 additions & 1 deletion RecoDataProducts/inc/CaloTrigSeed.hh
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ namespace mu2e {
};


typedef std::vector<mu2e::CaloTrigSeed> CaloTrigSeedCollection;
using CaloTrigSeedCollection = std::vector<mu2e::CaloTrigSeed>;
using CaloTrigSeedPtrCollection = std::vector<art::Ptr<mu2e::CaloTrigSeed>>;
}

#endif
3 changes: 2 additions & 1 deletion RecoDataProducts/inc/CosmicTrackSeed.hh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ namespace mu2e {
std::vector<TrkStrawHitSeed> const& trkstrawhits() const { return _trkstrawhits;}
std::vector<TrkStrawHitSeed> _trkstrawhits; //vector of associated trkstrawhits
};
typedef std::vector<mu2e::CosmicTrackSeed> CosmicTrackSeedCollection;
using CosmicTrackSeedCollection = std::vector<mu2e::CosmicTrackSeed>;
using CosmicTrackSeedPtrCollection = std::vector<art::Ptr<mu2e::CosmicTrackSeed>>;
}

#endif /* RecoDataProducts_CosmicTrackSeed_hh */
3 changes: 3 additions & 0 deletions RecoDataProducts/src/classes_def.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<class name="art::Ptr<mu2e::CosmicTrackSeed>"/>
<class name="std::vector<art::Ptr<mu2e::CosmicTrackSeed> >"/>
<class name="art::Wrapper<mu2e::CosmicTrackSeedCollection>"/>
<class name="art::Wrapper<mu2e::CosmicTrackSeedPtrCollection>"/>

<!-- ********* calorimeter ********* -->
<class name="mu2e::CaloDigi"/>
Expand Down Expand Up @@ -62,12 +63,14 @@
<class name="mu2e::CaloClusterCollection"/>
<class name="art::Ptr<mu2e::CaloCluster>"/>
<class name="art::Wrapper<mu2e::CaloClusterCollection>"/>
<class name="art::Wrapper<mu2e::CaloClusterPtrCollection>"/>

<class name="mu2e::CaloTrigSeed"/>
<class name="std::vector<art::Ptr<mu2e::CaloTrigSeed> >"/>
<class name="mu2e::CaloTrigSeedCollection"/>
<class name="art::Ptr<mu2e::CaloTrigSeed>"/>
<class name="art::Wrapper<mu2e::CaloTrigSeedCollection>"/>
<class name="art::Wrapper<mu2e::CaloTrigSeedPtrCollection>"/>

<!-- ********* straws ********* -->
<class name="mu2e::StrawHit"/>
Expand Down
52 changes: 29 additions & 23 deletions Trigger/src/MergeTriggerInfo_module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
#include "Offline/RecoDataProducts/inc/KalSeed.hh"
#include "Offline/RecoDataProducts/inc/HelixSeed.hh"
#include "Offline/RecoDataProducts/inc/TimeCluster.hh"
#include "Offline/RecoDataProducts/inc/CaloCluster.hh"
#include "Offline/RecoDataProducts/inc/CaloTrigSeed.hh"
#include "Offline/RecoDataProducts/inc/CosmicTrackSeed.hh"
// C++
#include <vector>
#include <memory>
Expand All @@ -28,8 +31,8 @@ namespace mu2e {
using Name = fhicl::Name;
using Comment = fhicl::Comment;
struct Config {
fhicl::Atom<int> debug { Name("debugLevel"), Comment("Debug Level"), 0};
fhicl::Atom<int> doDeepCopy{ Name("doDeepCopy") , Comment("Ntupleing mode"), 0};
fhicl::Atom<int> debug { Name("debugLevel"), Comment("Debug Level"), 0};
fhicl::Atom<int> doDeepCopy{ Name("doDeepCopy"), Comment("Produce cloned object collections"), 0};
};

using Parameters = art::EDProducer::Table<Config>;
Expand All @@ -42,22 +45,28 @@ namespace mu2e {

MergeTriggerInfo::MergeTriggerInfo(const Parameters& config) :
art::EDProducer{config},
_debug (config().debug()),
_debug (config().debug()),
_doDeepCopy(config().doDeepCopy())
{
produces<TriggerInfoCollection> ();
produces<TriggerInfoCollection>();
if (_doDeepCopy == 1){
produces<KalSeedCollection>();
produces<HelixSeedCollection>();
produces<TimeClusterCollection>();
produces<KalSeedCollection >();
produces<HelixSeedCollection >();
produces<TimeClusterCollection >();
produces<CaloClusterCollection >();
produces<CaloTrigSeedCollection >();
produces<CosmicTrackSeedCollection>();
}
}

void MergeTriggerInfo::produce(art::Event& event) {
std::unique_ptr<TriggerInfoCollection> tiCol(new TriggerInfoCollection);
std::unique_ptr<KalSeedCollection> ksCol(new KalSeedCollection);
std::unique_ptr<HelixSeedCollection> hsCol(new HelixSeedCollection);
std::unique_ptr<TimeClusterCollection> tcCol(new TimeClusterCollection);
std::unique_ptr<TriggerInfoCollection> tiCol(new TriggerInfoCollection);
std::unique_ptr<KalSeedCollection> ksCol((_doDeepCopy) ? new KalSeedCollection : nullptr);
std::unique_ptr<HelixSeedCollection> hsCol((_doDeepCopy) ? new HelixSeedCollection : nullptr);
std::unique_ptr<TimeClusterCollection> tcCol((_doDeepCopy) ? new TimeClusterCollection : nullptr);
std::unique_ptr<CaloClusterCollection> ccCol((_doDeepCopy) ? new CaloClusterCollection : nullptr);
std::unique_ptr<CaloTrigSeedCollection> ctCol((_doDeepCopy) ? new CaloTrigSeedCollection : nullptr);
std::unique_ptr<CosmicTrackSeedCollection> csCol((_doDeepCopy) ? new CosmicTrackSeedCollection : nullptr);

std::vector<art::Handle<TriggerInfo> > list_of_triggerInfo = event.getMany<TriggerInfo>();

Expand All @@ -71,18 +80,12 @@ namespace mu2e {
std::cout << "["<<moduleDescription().moduleLabel() << "] helices, tracks: "<< trigInfo.tracks().size() << " " << trigInfo.helixes().size() << std::endl;
}
if (_doDeepCopy == 1){
for (auto trkPtr: trigInfo.tracks()){
KalSeed trk(*trkPtr.get());
ksCol->push_back(trk);
}
for (auto hsPtr : trigInfo.helixes()){
HelixSeed hs(*hsPtr.get());
hsCol->push_back(hs);
}
for (auto tcPtr : trigInfo.hitClusters()){
TimeCluster tc(*tcPtr.get());
tcCol->push_back(tc);
}
for(auto ptr : trigInfo.tracks ()) ksCol->push_back(*(ptr.get()));
for(auto ptr : trigInfo.helixes ()) hsCol->push_back(*(ptr.get()));
for(auto ptr : trigInfo.hitClusters ()) tcCol->push_back(*(ptr.get()));
for(auto ptr : trigInfo.caloClusters ()) ccCol->push_back(*(ptr.get()));
for(auto ptr : trigInfo.caloTrigSeeds()) ctCol->push_back(*(ptr.get()));
for(auto ptr : trigInfo.cosmics ()) csCol->push_back(*(ptr.get()));
}
tiCol->push_back(trigInfo);
}
Expand All @@ -92,6 +95,9 @@ namespace mu2e {
event.put(std::move(ksCol));
event.put(std::move(hsCol));
event.put(std::move(tcCol));
event.put(std::move(ccCol));
event.put(std::move(ctCol));
event.put(std::move(csCol));
}
}
}
Expand Down
57 changes: 43 additions & 14 deletions Trigger/src/TriggerInfoToCollections_module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
#include "Offline/RecoDataProducts/inc/KalSeed.hh"
#include "Offline/RecoDataProducts/inc/HelixSeed.hh"
#include "Offline/RecoDataProducts/inc/TimeCluster.hh"
#include "Offline/RecoDataProducts/inc/CaloCluster.hh"
#include "Offline/RecoDataProducts/inc/CaloTrigSeed.hh"
#include "Offline/RecoDataProducts/inc/CosmicTrackSeed.hh"

// C++
#include <vector>
Expand All @@ -37,9 +40,12 @@ namespace mu2e {
void produce(art::Event& evt) override;

void fillContainers(const TriggerInfo& info,
KalSeedPtrCollection& trkCol,
HelixSeedPtrCollection& hlxCol,
TimeClusterPtrCollection& tclCol);
KalSeedPtrCollection& trkCol,
HelixSeedPtrCollection& hlxCol,
TimeClusterPtrCollection& tclCol,
CaloClusterPtrCollection& cclCol,
CaloTrigSeedPtrCollection& ctsCol,
CosmicTrackSeedPtrCollection& csmCol);

// Check if a given Ptr is already included in a vector of Ptrs
template <typename T> bool included(const art::Ptr<T>& ptr, const std::vector<art::Ptr<T>>& vec) {
Expand All @@ -59,16 +65,22 @@ namespace mu2e {
, _tag(config().tag())
, _debug(config().debug())
{
produces<KalSeedPtrCollection >();
produces<HelixSeedPtrCollection >();
produces<TimeClusterPtrCollection>();
produces<KalSeedPtrCollection >();
produces<HelixSeedPtrCollection >();
produces<TimeClusterPtrCollection >();
produces<CaloClusterPtrCollection >();
produces<CaloTrigSeedPtrCollection >();
produces<CosmicTrackSeedPtrCollection>();
}

// Fill the output Ptr collections from a TriggerInfo object
void TriggerInfoToCollections::fillContainers(const TriggerInfo& info,
KalSeedPtrCollection& trkCol,
HelixSeedPtrCollection& hlxCol,
TimeClusterPtrCollection& tclCol) {
KalSeedPtrCollection& trkCol,
HelixSeedPtrCollection& hlxCol,
TimeClusterPtrCollection& tclCol,
CaloClusterPtrCollection& cclCol,
CaloTrigSeedPtrCollection& ctsCol,
CosmicTrackSeedPtrCollection& csmCol) {
// Add each trigger info object content to the output collections if not already included
for(auto ptr : info.tracks()) {
if(!included(ptr, trkCol)) trkCol.push_back(ptr);
Expand All @@ -79,12 +91,24 @@ namespace mu2e {
for(auto ptr : info.hitClusters()) {
if(!included(ptr, tclCol)) tclCol.push_back(ptr);
}
for(auto ptr : info.caloClusters()) {
if(!included(ptr, cclCol)) cclCol.push_back(ptr);
}
for(auto ptr : info.caloTrigSeeds()) {
if(!included(ptr, ctsCol)) ctsCol.push_back(ptr);
}
for(auto ptr : info.cosmics()) {
if(!included(ptr, csmCol)) csmCol.push_back(ptr);
}
}

void TriggerInfoToCollections::produce(art::Event& event) {
std::unique_ptr<KalSeedPtrCollection > trkCol(new KalSeedPtrCollection );
std::unique_ptr<HelixSeedPtrCollection > hlxCol(new HelixSeedPtrCollection );
std::unique_ptr<TimeClusterPtrCollection> tclCol(new TimeClusterPtrCollection);
std::unique_ptr<KalSeedPtrCollection > trkCol(new KalSeedPtrCollection );
std::unique_ptr<HelixSeedPtrCollection > hlxCol(new HelixSeedPtrCollection );
std::unique_ptr<TimeClusterPtrCollection > tclCol(new TimeClusterPtrCollection );
std::unique_ptr<CaloClusterPtrCollection > cclCol(new CaloClusterPtrCollection );
std::unique_ptr<CaloTrigSeedPtrCollection > ctsCol(new CaloTrigSeedPtrCollection );
std::unique_ptr<CosmicTrackSeedPtrCollection> csmCol(new CosmicTrackSeedPtrCollection);
art::Handle<TriggerInfoCollection> info_coll_handle; // output from MergeTriggerInfo
art::Handle<TriggerInfo> info_handle; // output from a single trigger filter instance

Expand All @@ -93,7 +117,8 @@ namespace mu2e {

// fill the output Ptr collections with the trigger info collections
for(const auto& info : *infos) {
fillContainers(info, *trkCol, *hlxCol, *tclCol);
fillContainers(info, *trkCol, *hlxCol, *tclCol,
*cclCol, *ctsCol, *csmCol);
}

// report information if requested
Expand All @@ -102,7 +127,8 @@ namespace mu2e {
__func__, moduleDescription().moduleLabel().c_str(), infos->size(), trkCol->size(), hlxCol->size(), tclCol->size());
}
} else if(event.getByLabel(_tag, info_handle)) { // check for a single TriggerInfo object by this label
fillContainers(*info_handle.product(), *trkCol, *hlxCol, *tclCol);
fillContainers(*info_handle.product(), *trkCol, *hlxCol, *tclCol,
*cclCol, *ctsCol, *csmCol);

// report information if requested
if(_debug > 1 || (_debug > 0 && !trkCol->empty())) {
Expand All @@ -120,6 +146,9 @@ namespace mu2e {
event.put(std::move(trkCol));
event.put(std::move(hlxCol));
event.put(std::move(tclCol));
event.put(std::move(cclCol));
event.put(std::move(ctsCol));
event.put(std::move(csmCol));
}
}
DEFINE_ART_MODULE(mu2e::TriggerInfoToCollections)