19 #include "art_root_io/TFileService.h" 23 #include "lbne-raw-data/Overlays/TpcMilliSliceFragment.hh" 24 #include "artdaq-core/Data/Fragment.hh" 120 loginfo <<
"====================================" <<
"\n" 121 <<
"Making Histograms" <<
"\n" 122 <<
"====================================" <<
"\n";
126 auto const* detprop = lar::providerFrom<detinfo::DetectorPropertiesService>();
128 const double samplingRate = detprop->SamplingRate();
129 const unsinged
int millisliceSize = 5e6;
130 const unsigned int maxNumTicksPerEvent = millisliceSize / samplingRate;
142 loginfo <<
"Making Number of Hits per TPC Histograms\n";
145 std::ostringstream histName;
146 histName <<
"hist_num_hits_tpc_" << tpc;
148 std::ostringstream histTitle;
149 histTitle <<
"Number of hits per event TPC " << tpc <<
";Log_{10}(Number of hits);Number of events";
151 const unsigned int numPlanes = geom->
Nplanes(tpc);
152 unsigned int totalNumWires = 0;
153 for(
unsigned int plane=0;plane<numPlanes;plane++){
154 unsigned int numWires = geom->
Nwires(plane, tpc);
155 totalNumWires += numWires;
158 unsigned int maxNumHits = totalNumWires * maxNumTicksPerEvent;
162 int binHigh = TMath::Log10(maxNumHits);
163 TH1I* tempHist = tfs->make<TH1I>(histName.str().c_str(), histTitle.str().c_str(), numBins, binLow, binHigh);
165 loginfo <<
"histName: " << histName.str() <<
"\n";
169 <<
"Making Number of ticks / wire / event / TPC Histograms\n";
171 for(
size_t tpc = 0; tpc < fHistNumTicksPerEvent.size(); tpc++){
172 std::ostringstream histName;
173 histName <<
"hist_num_ticks_per_event_tpc_" << tpc;
175 std::ostringstream histTitle;
176 histTitle <<
"Number of ticks / wire / event in TPC " << tpc <<
";Number of ticks;Number of events";
180 int binHigh = maxNumTicksPerEvent;
181 TH1I* tempHist = tfs->make<TH1I>(histName.str().c_str(), histTitle.str().c_str(), numBins, binLow, binHigh);
182 fHistNumTicksPerEvent.at(tpc) = tempHist;
183 loginfo <<
"histName: " << histName.str() <<
"\n";
187 <<
"Making Number of ticks / wire / event pair / TPC Histograms\n";
189 for(
size_t tpc = 0; tpc < fHistNumTicksPerEventPair.size(); tpc++){
190 std::ostringstream histName;
191 histName <<
"hist_num_ticks_per_event_pair_tpc_" << tpc;
193 std::ostringstream histTitle;
194 histTitle <<
"Number of ticks / wire / event pair in TPC " << tpc <<
";Number of ticks;Number of event pairs";
198 int binHigh = maxNumTicksPerEvent;
199 TH1I* tempHist = tfs->make<TH1I>(histName.str().c_str(), histTitle.str().c_str(), numBins, binLow, binHigh);
200 fHistNumTicksPerEventPair.at(tpc) = tempHist;
201 loginfo <<
"histName: " << histName.str() <<
"\n";
205 <<
"Making Number of ticks / wire / event vs last / TPC Histograms\n";
207 for(
size_t tpc = 0; tpc < fHistNumTicksPerEventVsLast.size(); tpc++){
208 std::ostringstream histName;
209 histName <<
"hist_num_ticks_per_event_vs_last_tpc_" << tpc;
211 std::ostringstream histTitle;
212 histTitle <<
"Number of ticks / wire / event vs last event in TPC " << tpc <<
";Number of ticks;Number of ticks (last)";
216 int binHigh = maxNumTicksPerEvent;
217 TH2I* tempHist = tfs->make<TH2I>(histName.str().c_str(), histTitle.str().c_str(), numBins, binLow, binHigh, numBins, binLow, binHigh);
218 fHistNumTicksPerEventVsLast.at(tpc) = tempHist;
219 loginfo <<
"histName: " << histName.str() <<
"\n";
222 loginfo <<
"====================================" <<
"\n" 223 <<
"Finished Making Histograms" <<
"\n" 224 <<
"====================================" <<
"\n";
234 mf::LogInfo(
"TPCHits") <<
"====================================" <<
"\n" 235 <<
"Parameter Set" <<
"\n" 236 <<
"====================================" <<
"\n" 238 <<
"fRawDigitsTag: " << fRawDigitsTag <<
"\n" 239 <<
"fPrintRawDigitTimingInfo: " << fPrintRawDigitTimingInfo <<
"\n" 240 <<
"fPrintTpcFragTimingInfo: " << fPrintTpcFragTimingInfo <<
"\n" 241 <<
"====================================" <<
"\n";
250 bool retVal = e.
getByLabel(
"daq:TPC", rawFragments);
252 mf::LogInfo(
"TPCHits::printTpcFragTimingInfo") <<
"Getting TPC Frag SUCCESS: " << tpcFragTag <<
std::endl;
257 try { rawFragments->size(); }
259 mf::LogError(
"TPCHits::printTpcFragTimingInfo") <<
"WARNING: Issue with rawFragments for TPC hits" <<
std::endl;
263 for(
size_t fragIndex = 0; fragIndex < rawFragments->size(); fragIndex++){
264 const artdaq::Fragment &singleFragment = rawFragments->at(fragIndex);
265 lbne::TpcMilliSliceFragment msf(singleFragment);
266 auto nMicroSlices = msf.microSliceCount();
268 mf::LogInfo(
"TPCHits::printTpcFragTimingInfo") <<
"fragIndex: " << fragIndex
269 <<
" fragmentID: " << singleFragment.fragmentID()
270 <<
" ms counter: " << nMicroSlices
284 mf::LogInfo(
"TPCHits::printRawDigitTimingInfo") <<
"EventID: " << eventID
285 <<
" time: " << timestamp.
value()
286 <<
" EventNum: " <<
event 290 mf::LogInfo(
"TPCHits::printRawDigitTimingInfo") <<
"ERROR - negative delta timestamp of eventnum" <<
std::endl;
307 std::vector<unsigned int> thisNumHits(geom->
NTPC());
320 try { hitHandle->size(); }
326 if(!hitHandle.isValid()){
328 <<
", SubRun: " << e.subRun()
329 <<
", Event: " << e.event()
345 try { digitHandle->size(); }
353 <<
", SubRun: " << e.subRun()
354 <<
", Event: " << e.event()
360 std::vector<art::Ptr<recob::Hit> > hitlist;
365 for (
size_t tpchit_index = 0; tpchit_index<hitlist.size(); ++tpchit_index){
366 geo::WireID wireid = hitlist[tpchit_index]->WireID();
367 thisNumHits.at(wireid.
TPC)++;
373 if(thisNumHits.at(tpc)==0)
376 tempHist->Fill(TMath::Log10(thisNumHits.at(tpc)));
379 size_t numDigitChans = digitHandle->size();
386 for(
size_t rdIter=0;rdIter<numDigitChans;rdIter++){
389 auto numSamples = digitVec->
Samples();
392 if(wids.at(0).Plane !=2 )
continue;
394 fNumTicksTPC.at(wids.at(0).TPC)+=numSamples;
416 unsigned int numTicks = fNumTicksTPC.at(tpc);
427 if(numChans==0)
continue;
429 tempHist->Fill(numTicks/numChans);
433 tempHist->Fill((numTicksLastEvent+numTicks)/numChans);
436 tempHist2D->Fill(numTicks/numChans, numTicksLastEvent/numChans);
449 std::ostringstream os;
451 os <<
"====================================" <<
"\n" 453 <<
"====================================" <<
"\n";
457 os <<
"====================================" <<
"\n";
std::vector< TH1I * > fHistNumTicksPerEventPair
EventNumber_t event() const
ULong64_t Samples() const
Number of samples in the uncompressed ADC data.
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
std::vector< TH2I * > fHistNumTicksPerEventVsLast
Declaration of signal hit object.
void analyze(art::Event const &e) override
ChannelID_t Channel() const
DAQ channel this raw data was read from.
std::vector< geo::WireID > ChannelToWire(raw::ChannelID_t const channel) const
Returns a list of wires connected to the specified TPC channel.
std::vector< TH1I * > fHistNumHitsPerTPC
Definition of basic raw digits.
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
EDAnalyzer(fhicl::ParameterSet const &pset)
std::vector< unsigned int > fNumChansTPCTwoEvents
constexpr TimeValue_t value() const
unsigned int Nwires(unsigned int p, unsigned int tpc=0, unsigned int cstat=0) const
Returns the total number of wires in the specified plane.
void printTpcFragTimingInfo(art::Event const &e)
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
unsigned int Nplanes(unsigned int tpc=0, unsigned int cstat=0) const
Returns the total number of wire planes in the specified TPC.
#define DEFINE_ART_MODULE(klass)
void reconfigure(fhicl::ParameterSet const &p)
TPCHits & operator=(TPCHits const &)=delete
void printRawDigitTimingInfo(art::Event const &e)
T get(std::string const &key) const
std::vector< unsigned int > fNumTicksTPC
std::vector< TH1I * > fHistNumTicksPerEvent
bool fPrintRawDigitTimingInfo
std::vector< unsigned int > fNumTicksTPCTwoEvents
bool fPrintTpcFragTimingInfo
std::vector< unsigned int > fNumChansTPC
std::vector< unsigned int > fNumChansTPCLastEvent
unsigned int NTPC(unsigned int cstat=0) const
Returns the total number of TPCs in the specified cryostat.
std::vector< unsigned int > fNumTicksTPCLastEvent
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
IDNumber_t< Level::Event > EventNumber_t
art::Timestamp fTimestampLast
art::InputTag fRawDigitsTag
TPCHits(fhicl::ParameterSet const &p)
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
TPCID_t TPC
Index of the TPC within its cryostat.
std::vector< unsigned int > fTotalNumHitsPerTPC
art::EventNumber_t fEventLast
cet::coded_exception< error, detail::translate > exception
QTextStream & endl(QTextStream &s)
Event finding and building.
art::EventID fEventIDLast