MergeTBDaqCollections_module.cc
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////
2 // \file MergeTBDaqCollections_module.cc
3 // \brief Merge TB DAQ collections.
4 // At this step collection from primary and secondary files are merged under the same label.
5 // Check location in detector to determine if you want to add raw digits from primary (FEBv4) or secondary (FEBv5) files.
6 // Copy v4 trigger.
7 // Copied structure of MergeDaqCollection_modlule.cc
8 // FEBv5s are in planes 16, 17, 48, 49.
9 // \author tlackey@indiana.edu
10 ///////////////////////////////////////////////////////////////////////////
11 
12 #include <math.h>
13 #include <string>
14 
18 #include "fhiclcpp/ParameterSet.h"
22 
24 #include "RawData/RawDigit.h"
25 #include "RawData/RawTrigger.h"
26 
27 #include "Utilities/AssociationUtil.h"
28 
29 ///group hits according to time and space
31 
33  public:
34  explicit MergeTBDaqCollections(fhicl::ParameterSet const &pset);
35  virtual ~MergeTBDaqCollections();
36 
37  void produce(art::Event& evt);
38 
39  protected:
40  // internal methods
41 
42  // configuration settings
43  std::string fFirstDaqCollection; /// Label on the FEBv4 collection
44  std::string fSecondDaqCollection; /// Label on the FEBv5 collection
45 
46  std::string fInstanceLabel; /// Instance label
47  };
48 
49 
50  //----------------------------------------------------------------------
52  fFirstDaqCollection (pset.get< std::string >("FirstDaqCollection")),
53  fSecondDaqCollection (pset.get< std::string >("SecondDaqCollection")),
54  fInstanceLabel (pset.get< std::string >("InstanceLabel"))
55  {
56  produces< std::vector<rawdata::RawDigit> >(fInstanceLabel);
57  produces< std::vector<rawdata::RawTrigger> >(fInstanceLabel);
58  }
59 
60  //----------------------------------------------------------------------
61  MergeTBDaqCollections::~MergeTBDaqCollections()
62  {
63  }
64 
65  //----------------------------------------------------------------------
66  void MergeTBDaqCollections::produce(art::Event& evt)
67  {
69 
70  std::unique_ptr< std::vector<rawdata::RawDigit> > digitcol (new std::vector<rawdata::RawDigit>);
71  std::unique_ptr< std::vector<rawdata::RawTrigger> > triggercol (new std::vector<rawdata::RawTrigger>);
72 
74  evt.getByLabel(fFirstDaqCollection, digitv4list);
75 
77  evt.getByLabel(fSecondDaqCollection, digitv5list);
78 
79 
80  // First Collection Digits
81  for(unsigned int i = 0; i < digitv4list->size(); ++i){
82  rawdata::RawDigit digit ((*digitv4list)[i]);
83  const uint32_t dcm = cmap->Map()->getDCM(digit.DaqChannel());
84  if ( dcm!=3 ) {
85  digitcol->push_back(digit);
86  }
87  }
88 
89  // Second Collection Digits
90  for(unsigned int i = 0; i < digitv5list->size(); ++i){
91  rawdata::RawDigit digit ((*digitv5list)[i]);
92  const uint32_t dcm = cmap->Map()->getDCM(digit.DaqChannel());
93  if ( dcm==3 ) {
94  digitcol->push_back(digit);
95  }
96  }
97 
98  // Just copy v4 trigger into event. Needed in this file to rename with correct module label.
100  evt.getByLabel(fFirstDaqCollection, triggerlist);
101  for (unsigned int i = 0; i < triggerlist->size(); ++i) {
102  rawdata::RawTrigger trigger ((*triggerlist)[i]);
103  triggercol->push_back(trigger);
104  }
105 
106  // put the collections in the event
107  evt.put(std::move(digitcol), fInstanceLabel);
108  evt.put(std::move(triggercol), fInstanceLabel);
109 
110  }
111 
113 } // end namespace MergeTBDaqCollections
114 /////////////////////////////////////////////////////////////////////////
std::string fSecondDaqCollection
Label on the FEBv4 collection.
group hits according to time and space
const daqchannelmap::DAQChannelMap * Map() const
Definition: CMap.h:57
DEFINE_ART_MODULE(TestTMapFile)
ProductID put(std::unique_ptr< PROD > &&product)
Definition: Event.h:102
uint32_t DaqChannel() const
Definition: RawDigit.h:85
int evt
std::string fInstanceLabel
Label on the FEBv5 collection.
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
dcm_id_t getDCM(dchan daqchan) const
Decode the dcm ID from a dchan.
enum BeamMode string