19 #include "dk2nu/tree/dk2nu.h" 20 #include "dk2nu/tree/NuChoice.h" 22 #include "DAQChannelMap/DAQChannelMap.h" 32 #include "Utilities/AssociationUtil.h" 61 fFirstCollection (pset.
get<
std::
string >(
"FirstGenCollection",
"")),
62 fSecondCollection (pset.
get<
std::
string >(
"SecondCollection",
"")),
63 fFirstColIsMCNu (!pset.
get< bool >(
"IsFirstCollectionCosmic")),
64 fSecondColIsMCNu (!pset.
get< bool >(
"IsSecondCollectionCosmic")),
65 fMergeDk2Nu (pset.
get< bool >(
"MergeDk2Nu")),
66 fSecondaryModeOffset (pset.
get<
int >(
"SecondaryModeOffset",0))
68 if(fFirstCollection==
"" && fSecondCollection==
""){
70 <<
"Neither collection is specified to merge from. Abort." 74 if(!fFirstColIsMCNu && !fSecondColIsMCNu){
76 <<
"No MC Collections to merge. Abort." 81 produces< sumdata::POTSum, art::InSubRun >();
82 produces< sumdata::SpillData >();
83 produces< std::vector<simb::MCTruth> >();
84 produces< std::vector<simb::MCFlux> >();
85 produces< std::vector<simb::GTruth> >();
86 produces< std::vector<bsim::Dk2Nu> >();
87 produces< std::vector<bsim::NuChoice> >();
88 produces< art::Assns<simb::MCTruth, simb::MCFlux> >();
89 produces< art::Assns<simb::MCTruth, simb::GTruth> >();
93 MergeGenCollections::~MergeGenCollections()
101 std::unique_ptr< std::vector<simb::MCTruth> > truthcol (
new std::vector<simb::MCTruth >);
102 std::unique_ptr< std::vector<simb::MCFlux> > fluxcol (
new std::vector<simb::MCFlux >);
103 std::unique_ptr< std::vector<simb::GTruth> > gtruthcol(
new std::vector<simb::GTruth >);
104 std::unique_ptr< std::vector<bsim::Dk2Nu> > dk2nucol (
new std::vector<bsim::Dk2Nu >);
105 std::unique_ptr< std::vector<bsim::NuChoice> > nuccol (
new std::vector<bsim::NuChoice>);
114 if(fFirstCollection!=
""){
119 if(spill.
isValid()) *spillcol = *spill;
129 if(fFirstColIsMCNu) {
139 for(
unsigned int i = 0;
i < mclist->size(); ++
i){
141 truthcol->push_back(truth);
144 if(i < fllist->
size() && i < glist->
size()){
147 fluxcol ->push_back(flux);
148 gtruthcol->push_back(gtruth);
151 util::CreateAssn(*
this, evt, *truthcol, *gtruthcol, *gassns, gtruthcol->
size()-1, gtruthcol->size());
153 if(i < dklist->
size() && i < nulist->size()){
155 dk2nucol->push_back(dk2nu);
157 nuccol ->push_back(nuc);
167 if(fSecondCollection!=
""){
175 if(fSecondColIsMCNu) {
182 for(
unsigned int i = 0;
i < mc2list->size(); ++
i){
185 if(fSecondaryModeOffset){
197 nu2.
Mode() + fSecondaryModeOffset,
201 nu2.
X(), nu2.
Y(),nu2.
QSqr() );
202 truthcol->push_back(truth);
206 truthcol->push_back(tru2);
210 if(fSecondColIsMCNu) {
211 if(i < fl2list->
size() && i < g2list->
size()){
214 gtruthcol->push_back(gtruth);
215 fluxcol->push_back(flux);
218 util::CreateAssn(*
this, evt, *truthcol, *gtruthcol, *gassns, gtruthcol->
size()-1, gtruthcol->size());
220 if(i < dk2list->
size() && i < nu2list->size()){
222 dk2nucol->push_back(dk2nu);
224 nuccol ->push_back(nuc);
231 evt.
put(std::move(spillcol));
232 evt.
put(std::move(truthcol));
233 evt.
put(std::move(fluxcol));
234 evt.
put(std::move(gtruthcol));
235 evt.
put(std::move(dk2nucol));
236 evt.
put(std::move(nuccol));
237 evt.
put(std::move(assns));
238 evt.
put(std::move(gassns));
246 if(fFirstColIsMCNu) {
250 if(pots.
isValid()) *potcol = *pots;
252 else if(fSecondColIsMCNu) {
254 <<
"Ignoring second-collection POTSum, using only first";
256 sr.
put(std::move(potcol));
static bool CreateAssn(art::EDProducer const &prod, art::Event &evt, std::vector< T > &a, art::Ptr< U > b, art::Assns< T, U > &assn, size_t indx=UINT_MAX, std::string const &instance=std::string())
Create a 1 to 1 association between a new product and one already in the event.
const simb::MCNeutrino & GetNeutrino() const
Merge generation collections MCTruth/MCFlux/GTruth/Dk2Nu/NuChoice.
void SetOrigin(simb::Origin_t origin)
int fSecondaryModeOffset
Merge Dk2Nu/NuChoice objects?
simb::Origin_t Origin() const
std::string fSecondCollection
MCTruth label for main collection.
bool fFirstColIsMCNu
Process label for the second collection.
void SetNeutrino(int CCNC, int mode, int interactionType, int target, int nucleon, int quark, double w, double x, double y, double qsqr)
DEFINE_ART_MODULE(TestTMapFile)
void Add(simb::MCParticle &part)
object containing MC flux information
ProductID put(std::unique_ptr< PROD > &&product)
int InteractionType() const
std::string fFirstCollection
const simb::MCParticle & GetParticle(int i) const
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
ProductID put(std::unique_ptr< PROD > &&)
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
Event generator information.
Event generator information.