3434#include " TTree.h"
3535#include " art_root_io/TFileService.h"
3636
37- namespace mu2e
38- {
39- class CaloDataAnalyzer : public art ::EDAnalyzer
40- {
37+ namespace mu2e {
38+ class CaloDataAnalyzer : public art ::EDAnalyzer {
4139 public:
4240 // clang-format off
4341 struct Config {
@@ -139,8 +137,7 @@ mu2e::CaloDataAnalyzer::CaloDataAnalyzer(const art::EDAnalyzer::Table<Config>& c
139137 , data_type_(config().data_type())
140138 , caloDAQUtil_(" CaloDigiFromFragments" )
141139 , maxEventNum_(config().maxEventNum())
142- , fillEmptyEvents_(config().fillEmptyEvents())
143- {
140+ , fillEmptyEvents_(config().fillEmptyEvents()) {
144141 art::ServiceHandle<art::TFileService> tfs;
145142
146143 h1_t0 = tfs->make <TH1D>(" h1_t0" , " t0 distribution;t0" , 2000 , 0 , 20000 );
@@ -212,8 +209,7 @@ mu2e::CaloDataAnalyzer::CaloDataAnalyzer(const art::EDAnalyzer::Table<Config>& c
212209 total_failedhits = 0 ;
213210}
214211
215- void mu2e::CaloDataAnalyzer::analyze (art::Event const & event)
216- {
212+ void mu2e::CaloDataAnalyzer::analyze (art::Event const & event) {
217213 art::EventNumber_t eventNumber = event.event ();
218214 // TLOG(TLVL_INFO) << "mu2e::CaloDataAnalyzer::analyzer eventNumber= " <<
219215 // (int)eventNumber << std::endl;
@@ -247,12 +243,10 @@ void mu2e::CaloDataAnalyzer::analyze(art::Event const& event)
247243 caloFragmentsTag_);
248244
249245 TLOG (TLVL_DEBUG + 6 ) << " Iterating through " << caloDecoderColl->size () << " DTCs\n " ;
250- for (auto caloDTC : *caloDecoderColl)
251- {
246+ for (auto caloDTC : *caloDecoderColl) {
252247 processCaloData (caloDTC);
253248 }
254- if (fillEmptyEvents_ || t_nhits > 0 )
255- {
249+ if (fillEmptyEvents_ || t_nhits > 0 ) {
256250 tree->Fill (); // Only fill if we have at least 1 hit
257251 }
258252 total_events++;
@@ -264,8 +258,7 @@ void mu2e::CaloDataAnalyzer::analyze(art::Event const& event)
264258 TLOG (TLVL_DEBUG + 6 ) << " [CaloDataAnalyzer::analyzer] found " << t_nhits
265259 << " calo hits in event " << (int )eventNumber;
266260
267- if (nCaloEvents == 0 )
268- {
261+ if (nCaloEvents == 0 ) {
269262 TLOG (TLVL_WARNING)
270263 << " [CaloDataAnalyzer::analyzer] found no calo subevents in event "
271264 << (int )eventNumber << " !" ;
@@ -276,8 +269,7 @@ void mu2e::CaloDataAnalyzer::analyze(art::Event const& event)
276269}
277270
278271void mu2e::CaloDataAnalyzer::processCaloData (
279- mu2e::CalorimeterDataDecoder const & caloDecoder)
280- {
272+ mu2e::CalorimeterDataDecoder const & caloDecoder) {
281273 auto & this_subevent = caloDecoder.event_ ;
282274 long int thisDTCEWT = this_subevent.GetEventWindowTag ().GetEventWindowTag (true );
283275 t_currentDTCEventWindow = thisDTCEWT;
@@ -289,55 +281,46 @@ void mu2e::CaloDataAnalyzer::processCaloData(
289281 uint nROCs = caloDecoder.block_count ();
290282 TLOG (TLVL_DEBUG + 6 ) << " Iterating through " << nROCs << " data blocks (ROCs)\n " ;
291283 std::vector<int > roc_hits;
292- for (uint iroc = 0 ; iroc < nROCs; iroc++)
293- {
284+ for (uint iroc = 0 ; iroc < nROCs; iroc++) {
294285 long int thisROCEWT =
295286 dataBlocks[iroc].GetHeader ().get ()->GetEventWindowTag ().GetEventWindowTag (
296287 true );
297288 g_eventEWT->AddPoint (this_eventNumber, thisROCEWT);
298- if (data_type_ == 0 )
299- { // ///// STANDARD HITS ///////
289+ if (data_type_ == 0 ) { // ///// STANDARD HITS ///////
300290
301291 auto caloHits = caloDecoder.GetCalorimeterHitData (iroc);
302292 uint nHits = caloHits->size ();
303293 roc_hits.push_back (nHits);
304- for (uint ihit = 0 ; ihit < nHits; ihit++)
305- {
294+ for (uint ihit = 0 ; ihit < nHits; ihit++) {
306295 mu2e::CalorimeterDataDecoder::CalorimeterHitDataPacket hit =
307296 caloHits->at (ihit).first ;
308297 std::vector<uint16_t > hit_waveform = caloHits->at (ihit).second ;
309- if (hit_waveform.size () == 0 )
310- {
298+ if (hit_waveform.size () == 0 ) {
311299 TLOG (TLVL_WARNING)
312300 << " [CaloDataAnalyzer::analyzer] found empty waveform! DTC "
313301 << dtcID << " ROC " << iroc << " hit " << ihit << " BoardID "
314302 << hit.BoardID << " ChannelNumber " << hit.ChannelNumber ;
315303 }
316304 nCaloHits++;
317305 }
318- }
319- else if (data_type_ == 1 )
320- { // ///// DEBUG HITS ///////
306+ } else if (data_type_ == 1 ) { // ///// DEBUG HITS ///////
321307 auto caloHits = caloDecoder.GetCalorimeterHitTestData (iroc);
322308 // auto caloHits = caloDecoder.GetCalorimeterHitTestDataNoPointer(iroc);
323309 uint nHits = caloHits->size ();
324310 roc_hits.push_back (nHits);
325311
326312 total_hits += nHits;
327- for (uint ihit = 0 ; ihit < nHits; ihit++)
328- {
313+ for (uint ihit = 0 ; ihit < nHits; ihit++) {
329314 mu2e::CalorimeterDataDecoder::CalorimeterHitTestDataPacket hit =
330315 caloHits->at (ihit).first ;
331316 std::vector<uint16_t > hit_waveform = caloHits->at (ihit).second ;
332317
333318 // Check that the hit is good
334319 auto errorCode = caloDAQUtil_.isHitGood (caloHits->at (ihit));
335- if (errorCode)
336- {
320+ if (errorCode) {
337321 event_failedhits++;
338322 total_failedhits++;
339- if (verbosity_ > 0 )
340- {
323+ if (verbosity_ > 0 ) {
341324 std::cout << " [CaloDataAnalyzer] BAD calo hit! DTC: " << dtcID
342325 << " , ROC: " << iroc << " , hit number: " << ihit
343326 << " [failure code: " << errorCode << " ]" << std::endl;
@@ -357,8 +340,7 @@ void mu2e::CaloDataAnalyzer::processCaloData(
357340 h1_maxIndex->Fill (hit.IndexOfMaxDigitizerSample );
358341 h1_nSamples->Fill (hit.NumberOfSamples );
359342
360- for (uint wfi = 0 ; wfi < hit_waveform.size (); wfi++)
361- {
343+ for (uint wfi = 0 ; wfi < hit_waveform.size (); wfi++) {
362344 h2_waveforms->Fill (wfi, hit_waveform[wfi]);
363345 }
364346
@@ -376,21 +358,17 @@ void mu2e::CaloDataAnalyzer::processCaloData(
376358 t_peakval[t_nhits - 1 ] = hit_waveform[hit.IndexOfMaxDigitizerSample ];
377359 t_nofsamples[t_nhits - 1 ] = hit.NumberOfSamples ;
378360 t_firstsample[t_nhits - 1 ] = t_nsamples;
379- for (auto adc : hit_waveform)
380- {
361+ for (auto adc : hit_waveform) {
381362 t_ADC[t_nsamples] = adc;
382363 t_nsamples++;
383364 }
384365 t_ADC_hit->push_back (hit_waveform);
385366 }
386- }
387- else if (data_type_ == 2 )
388- { // ///// COUNTERS ///////
367+ } else if (data_type_ == 2 ) { // ///// COUNTERS ///////
389368 auto caloHits = caloDecoder.GetCalorimeterCountersData (iroc);
390369 uint nHits = caloHits->size ();
391370 roc_hits.push_back (nHits);
392- for (uint ihit = 0 ; ihit < nHits; ihit++)
393- {
371+ for (uint ihit = 0 ; ihit < nHits; ihit++) {
394372 mu2e::CalorimeterDataDecoder::CalorimeterCountersDataPacket hit =
395373 caloHits->at (ihit).first ;
396374 std::vector<uint32_t > hit_counters = caloHits->at (ihit).second ;
@@ -400,8 +378,7 @@ void mu2e::CaloDataAnalyzer::processCaloData(
400378 tH_linkID = iroc;
401379 tH_nofsamples = hit.numberOfCounters ;
402380 tH_ADC->clear ();
403- for (auto adc : hit_counters)
404- {
381+ for (auto adc : hit_counters) {
405382 tH_ADC->push_back (adc);
406383 }
407384 treeHits->Fill ();
@@ -411,8 +388,7 @@ void mu2e::CaloDataAnalyzer::processCaloData(
411388 } // loop over ROCs
412389}
413390
414- void mu2e::CaloDataAnalyzer::endJob ()
415- {
391+ void mu2e::CaloDataAnalyzer::endJob () {
416392 std::cout << " \n ----- [CaloDataAnalyzer] Decoding errors summary ----- "
417393 << std::endl;
418394 std::cout << " Total events: " << total_events << " \n " ;
0 commit comments