MuonOccupancy_module.cc
Go to the documentation of this file.
1 // Module to create 1D channel occupancy histograms for the DUNE 35t detector
2 // totally copied from Bill's AnalysisExample_module and Seongtae's Rawevd35t_module
3 // Matthew Worcester (BNL) 3/7/14
4 
5 // Added code to check the muon 'track' (as defined by its initial momentum
6 // vector, not reconstruction) to see if it hits any of the muon counters.
7 // MW 5/13/14
8 
9 #ifndef MuonOccupancy_Module
10 #define MuonOccupancy_Module
11 
12 // LArSoft includes
22 #include "lardataobj/RawData/raw.h"
23 
24 // Framework includes
29 #include "art_root_io/TFileService.h"
31 #include "canvas/Persistency/Common/FindManyP.h"
33 #include "fhiclcpp/ParameterSet.h"
34 
35 // ROOT includes.
36 #include "TH1.h"
37 #include "TH2.h"
38 #include "TTree.h"
39 #include "TLorentzVector.h"
40 #include "TVector3.h"
41 #include "TCanvas.h"
42 #include "TPad.h"
43 #include "TFile.h"
44 
45 // C++ Includes
46 #include <map>
47 #include <vector>
48 #include <algorithm>
49 #include <fstream>
50 #include <iostream>
51 #include <string>
52 #include <sstream>
53 #include <cmath>
54 #include <ctime>
55 
56 // DUNE code includes
58 
59 namespace AnalysisExample{
60 
62 
63  public:
64 
65  // constructor and destructor
66  explicit MuonOccupancy(fhicl::ParameterSet const& pset);
67 
68  virtual ~MuonOccupancy();
69 
70  // called once at the beginning of the job
71  void beginJob();
72 
73  // called once at the beginning of each run
74  void beginRun(const art::Run& run);
75 
76  // reads in .fcl file parameters, can be called any time
77  void reconfigure(fhicl::ParameterSet const& pset);
78 
79  // called once per event
80  void analyze(const art::Event& evt);
81 
82  private:
83 
84  // the parameters we'll read from the .fcl file
87  int fSelectedPDG; // PDG code for primary particle
88 
89  // log file
90  std::ofstream outfile;
91 
92  // define the histograms and ntuples
93 
94  // histograms and ntuple for simulated particles
100 
102 
103  // The variables that will go into the n-tuple.
104  int fEvent;
105  int fRun;
106  int fSubRun;
107  int fPDG;
108  int fTrackID;
109 
110  double fStartXYZT[4];
111  double fEndXYZT[4];
112  double fStartPE[4];
113  double fEndPE[4];
114 
115  // variables and histograms for occupancy plots
116  unsigned int fUChanMin;
117  unsigned int fUChanMax;
118  unsigned int fVChanMin;
119  unsigned int fVChanMax;
120  unsigned int fZ0ChanMin;
121  unsigned int fZ0ChanMax;
122  unsigned int fZ1ChanMin;
123  unsigned int fZ1ChanMax;
124 
125  unsigned int fNofAPA;
126  unsigned int fChansPerAPA;
127 
128  std::vector<TH1I*> fChanU;
129  std::vector<TH1I*> fChanV;
130  std::vector<TH1I*> fChanZ0;
131  std::vector<TH1I*> fChanZ1;
132 
133  // muon counter geometry
135  int counters_loaded = -1;
136  std::vector< std::vector<double> > countergeometry;
137 
138  // pointers to services
140 
141  }; // class MuonOccupancy
142 
143  //-----------------------------------------------------------------------
144  // constructor
145 
147  : EDAnalyzer(parameterSet){
148 
149  // read in the parameters from the .fcl file
150  this->reconfigure(parameterSet);
151  }
152 
153  //-----------------------------------------------------------------------
154  // destructor
155 
157 
158  //-----------------------------------------------------------------------
159  // read in the parameters from the .fcl file
160 
162 
163  fSimulationProducerLabel = p.get< std::string >("SimulationLabel");
164  fRawDigitLabel = p.get< std::string >("RawDigitLabel");
165 
166  fSelectedPDG = p.get< int >("PDGcode");
167 
168  return;
169  }
170 
171  //-----------------------------------------------------------------------
172  // executes once at the beginning of the job
173 
175 
176  // get local time
177  time_t rawtime;
178  struct tm * timeinfo;
179 
180  time (&rawtime);
181  timeinfo = localtime (&rawtime);
182 
183  // open a basic log file, will overwrite a pre-existing one
184  outfile.open("muonoccupancy.log");
185 
186  outfile << "MuonOccupancy_module log file, " << asctime(timeinfo) << std::endl;
187 
188  // Access ART's TFileService, which will handle creating and writing
189  // histograms and n-tuples for us.
191 
192  // get the detector size to define the histogram ranges
193  outfile << "Number of cryostats: " << fGeom->Ncryostats() << std::endl;
194 
195  double xrange = 0.; // physical drift axis of cryostat
196  double yrange = 0.; // physical height of cryostat
197  double zrange = 0.; // physical width of cryostat
198 
199  // loop over cryostats
200  for(unsigned int c = 0; c < fGeom->Ncryostats(); ++c){
201 
202  outfile << " Cryostat " << c << " [x,y,z] (cm) = ";
203 
204  xrange = fGeom->CryostatLength(c);
205  outfile << xrange << ", ";
206 
207  yrange = fGeom->CryostatHalfHeight(c);
208  outfile << yrange << ", ";
209 
210  zrange = fGeom->CryostatHalfWidth(c);
211  outfile << zrange << std::endl;
212 
213  }
214 
215  outfile << std::endl;
216 
217  // simulated particle histograms
218  fPositionHist = tfs->make<TH1D>("position",";initial position (cm);", int(xrange), 0., xrange*2);
219  fMomentumHist = tfs->make<TH1D>("momentum",";initial momentum (GeV);", 100, 0., 500.);
220  fTrackLengthHist = tfs->make<TH1D>("length", ";particle track length (cm);", 100, 0., 1000.);
221  hit_counter_occupancy = tfs->make<TH1D>("Hit counter occupancy",";detector number;",104,0,104);
222  trigger_occupancy = tfs->make<TH1D>("Trigger occupancy",";trigger number;",4,1,5);
223 
224  // Define our n-tuples, which are limited forms of ROOT
225  // TTrees. Start with the TTree itself.
226  fSimulationNtuple = tfs->make<TTree>("MuonOccupancySimulation","MuonOccupancySimulation");
227 
228  // Define the branches (columns) of our simulation n-tuple. When
229  // we write a variable, we give the address of the variable to TTree::Branch.
230  fSimulationNtuple->Branch("Event", &fEvent, "Event/I");
231  fSimulationNtuple->Branch("SubRun", &fSubRun, "SubRun/I");
232  fSimulationNtuple->Branch("Run", &fRun, "Run/I");
233  fSimulationNtuple->Branch("TrackID", &fTrackID, "TrackID/I");
234 
235  // When we write arrays, we give the address of the array to
236  // TTree::Branch; in C++ this is simply the array name.
237  fSimulationNtuple->Branch("StartXYZT", fStartXYZT, "StartXYZT[4]/D");
238  fSimulationNtuple->Branch("EndXYZT", fEndXYZT, "EndXYZT[4]/D");
239  fSimulationNtuple->Branch("StartPE", fStartPE, "StartPE[4]/D");
240  fSimulationNtuple->Branch("EndPE", fEndPE, "EndPE[4]/D");
241 
242  // occupancy histogram names and titles
243  std::stringstream name, title;
244 
245  unsigned int UChMin;
246  unsigned int UChMax;
247  unsigned int VChMin;
248  unsigned int VChMax;
249  unsigned int Z0ChMin;
250  unsigned int Z0ChMax;
251  unsigned int Z1ChMin;
252  unsigned int Z1ChMax;
253 
254  TH1I* TempHisto;
255 
256  // loop through the channels and get the U, V, and Z channel numbers
257 
258  // number of APA, assumes that 2 TPC share one APA
260  outfile << "Number of APA: " << fNofAPA << std::endl;
261 
262  // channels per APA, assumes all channels even split among APA
264  outfile << "Number of channels: " << fGeom->Nchannels() << ", " << fChansPerAPA << " per APA" << std::endl;
265 
266  // starting and ending points for the loop
267  // assumes channel list starts with U and ends with Z
268  fUChanMin = 0;
269  fZ1ChanMax = fChansPerAPA - 1;
270 
271  for ( unsigned int c = fUChanMin + 1; c < fZ1ChanMax; c++ ){
272  if ( fGeom->View(c) == geo::kV && fGeom->View(c-1) == geo::kU ){
273  fVChanMin = c;
274  fUChanMax = c - 1;
275  }
276  if ( fGeom->View(c) == geo::kZ && fGeom->View(c-1) == geo::kV ){
277  fZ0ChanMin = c;
278  fVChanMax = c-1;
279  }
280  if ( fGeom->View(c) == geo::kZ && fGeom->ChannelToWire(c)[0].TPC == fGeom->ChannelToWire(c-1)[0].TPC + 1 ){
281  fZ1ChanMin = c;
282  fZ0ChanMax = c-1;
283  }
284  }
285 
286  outfile << "U channel number minimum and maximum: " << fUChanMin << "," << fUChanMax
287  << " (" << fUChanMax-fUChanMin+1 << " total channels)" << std::endl;
288  outfile << "V channel number minimum and maximum: " << fVChanMin << "," << fVChanMax
289  << " (" << fVChanMax-fVChanMin+1 << " total channels)" << std::endl;
290  outfile << "Z0 channel number minimum and maximum: " << fZ0ChanMin << "," << fZ0ChanMax
291  << " (" << fZ0ChanMax-fZ0ChanMin+1 << " total channels)" << std::endl;
292  outfile << "Z1 channel number minimum and maximum: " << fZ1ChanMin << "," << fZ1ChanMax
293  << " (" << fZ1ChanMax-fZ1ChanMin+1 << " total channels)" << std::endl;
294 
295  // create the 1D occupancy histograms for each APA
296  for(unsigned int i=0;i<fNofAPA;i++){
297 
298  UChMin=fUChanMin + i*fChansPerAPA;
299  UChMax=fUChanMax + i*fChansPerAPA;
300  VChMin=fVChanMin + i*fChansPerAPA;
301  VChMax=fVChanMax + i*fChansPerAPA;
302  Z0ChMin=fZ0ChanMin + i*fChansPerAPA;
303  Z0ChMax=fZ0ChanMax + i*fChansPerAPA;
304  Z1ChMin=fZ1ChanMin + i*fChansPerAPA;
305  Z1ChMax=fZ1ChanMax + i*fChansPerAPA;
306 
307  // construct the histograms; TH1 constructors: ("Name", "Title", NxBin, xMin, xMax)
308  name.str("");
309  name << "fChanU";
310  name << i;
311  title.str("");
312  title << "Hit Channel (Plane U, APA";
313  title << i<<")";
314  TempHisto = tfs->make<TH1I>(name.str().c_str(),title.str().c_str(), UChMax - UChMin + 2, UChMin-1, UChMax);
315  fChanU.push_back(TempHisto);
316 
317  name.str("");
318  name << "fChanV";
319  name << i;
320  title.str("");
321  title << "Hit Channel (Plane V, APA";
322  title << i<<")";
323  TempHisto = tfs->make<TH1I>(name.str().c_str(),title.str().c_str(), VChMax - VChMin + 2, VChMin-1, VChMax);
324  fChanV.push_back(TempHisto);
325 
326  name.str("");
327  name << "fChanZ0";
328  name << i;
329  title.str("");
330  title << "Hit Channel (Plane Z0, APA";
331  title <<i<<")";
332  TempHisto = tfs->make<TH1I>(name.str().c_str(),title.str().c_str(), Z0ChMax - Z0ChMin + 2, Z0ChMin-1, Z0ChMax);
333  fChanZ0.push_back(TempHisto);
334 
335  name.str("");
336  name << "fChanZ1";
337  name << i;
338  title.str("");
339  title << "Hit Channel (Plane Z1, APA";
340  title << i<<")";
341  TempHisto = tfs->make<TH1I>(name.str().c_str(),title.str().c_str(), Z1ChMax - Z1ChMin + 2, Z1ChMin-1, Z1ChMax);
342  fChanZ1.push_back(TempHisto);
343 
344  fChanU[i]->SetStats(0); fChanV[i]->SetStats(0);
345  fChanZ0[i]->SetStats(0); fChanZ1[i]->SetStats(0);
346 
347  fChanU[i]->GetXaxis()->SetTitle("Channel number"); fChanU[i]->GetYaxis()->SetTitle("hits");
348  fChanV[i]->GetXaxis()->SetTitle("Channel number"); fChanV[i]->GetYaxis()->SetTitle("hits");
349  fChanZ0[i]->GetXaxis()->SetTitle("Channel number"); fChanZ0[i]->GetYaxis()->SetTitle("hits");
350  fChanZ1[i]->GetXaxis()->SetTitle("Channel number"); fChanZ1[i]->GetYaxis()->SetTitle("hits");
351 
352  } // end loop over APA
353 
354  outfile << std::endl;
355 
356  // load the muon counter positions from a text file
357 
358  char counterfile[] = "../Geometry/muoncounters.txt";
359 
361 
362  if(!counters_loaded){
363 
364  outfile << "ERROR: muon counter geometry failed to load." << std::endl;
365 
366  }
367 
368  outfile << std::endl;
369 
370  }
371 
372  //-----------------------------------------------------------------------
373  // executes once at the beginning of each run
374 
375  void MuonOccupancy::beginRun(const art::Run& /*run*/){
376 
377  }
378 
379  //-----------------------------------------------------------------------
380  // executes once per event
381 
383 
384  // start with the basics
385  fEvent = event.id().event();
386  fRun = event.run();
387  fSubRun = event.subRun();
388 
389  outfile << "Event " << fEvent << ", run " << fRun << ", subrun " << fSubRun << std::endl;
390 
391  // then get the simulated particle information
392 
393  // define the handle as an MCParticle vector and fill it with events from the simulation
395  event.getByLabel(fSimulationProducerLabel, particleHandle);
396 
397  // define a sorted map in which to put the particles
398  std::map< int, const simb::MCParticle* > particleMap;
399 
400  // loop over all the particles, find the primary muon, and get the initial/final positions
401  for ( auto const& particle : (*particleHandle) )
402  {
403  // For the methods you can call to get particle information,
404  // see $NUTOOLS_INC/SimulationBase/MCParticle.h.
405  fTrackID = particle.TrackId();
406 
407  // Add the address of the MCParticle to the map, with the track ID as the key.
408  particleMap[fTrackID] = &particle;
409 
410  // PDG code of every particle in the event.
411  fPDG = particle.PdgCode();
412 
413  // locate the primary muon
414  if ( particle.Process() == "primary" && fPDG == fSelectedPDG )
415  {
416  outfile << "Primary particle PDG: " << fPDG << std::endl;
417 
418  // A particle has a trajectory, consisting of a set of
419  // 4-positions and 4-mommenta.
420  size_t numberTrajectoryPoints = particle.NumberTrajectoryPoints();
421 
422  // For trajectories, as for vectors and arrays, the
423  // first point is #0, not #1.
424  int last = numberTrajectoryPoints - 1;
425  const TLorentzVector& positionStart = particle.Position(0);
426  const TLorentzVector& positionEnd = particle.Position(last);
427  const TLorentzVector& momentumStart = particle.Momentum(0);
428  const TLorentzVector& momentumEnd = particle.Momentum(last);
429 
430  // move the initial position (for muon counter studies)
431 
432  double x_increment = 0.; // 349.666
433  double z_increment = 0.; // 231.065
434 
435  TVector3 trackStart(positionStart.X()+x_increment,positionStart.Y(),positionStart.Z()+z_increment);
436 
437  //std::cout << trackStart[0] << " " << trackStart[1] << " " << trackStart[2] << std::endl;
438 
439  // fill the histogram of the starting position.
440  fPositionHist->Fill( positionStart.P() );
441 
442  // fill the histogram of the starting momentum.
443  fMomentumHist->Fill( momentumStart.P() );
444 
445  // Fill arrays with the 4-values. (Don't be fooled by
446  // the name of the method; it just puts the numbers from
447  // the 4-vector into the array.)
448  positionStart.GetXYZT( fStartXYZT );
449  positionEnd.GetXYZT( fEndXYZT );
450  momentumStart.GetXYZT( fStartPE );
451  momentumEnd.GetXYZT( fEndPE );
452 
453  outfile << "Initial position: " << fStartXYZT[0] << ", " << fStartXYZT[1] << ", "
454  << fStartXYZT[2] << " (cm)" << std::endl;
455  outfile << "Initial time: " << fStartXYZT[3] << " (nsec)" << std::endl;
456 
457  outfile << "Initial momentum: " << fStartPE[0] << ", " << fStartPE[1] << ", "
458  << fStartPE[2] << ", " << fStartPE[3] << " (GeV)" << std::endl;
459 
460  outfile << "Final position: " << fEndXYZT[0] << ", " << fEndXYZT[1] << ", "
461  << fEndXYZT[2] << " (cm)" << std::endl;
462  outfile << "Final time: " << fEndXYZT[3] << " (nsec)" << std::endl;
463 
464  outfile << "Final momentum: " << fEndPE[0] << ", " << fEndPE[1] << ", "
465  << fEndPE[2] << ", " << fEndPE[3] << " (GeV)" << std::endl;
466 
467  // Use a polar-coordinate view of the 4-vectors to
468  // get the track length.
469  double trackLength = ( positionEnd - positionStart ).Rho();
470 
471  // Make a histogram of the track length.
472  fTrackLengthHist->Fill( trackLength );
473 
474  outfile << "Track length: " << trackLength << std::endl;
475 
476  // Check for track intersections with the muon counters.
477 
478  // make sure the muon counter geometry was loaded
479  if(counters_loaded){
480 
481  unsigned int counters_hit = 0;
482  std::vector< std::vector<double> > hitcounters;
483 
485  trackStart, momentumStart.Vect(),
486  countergeometry, hitcounters);
487 
488  if(counters_hit != hitcounters.size()){
489 
490  outfile << "ERROR: size of hit counters vector is not the same as number of hit counters."
491  <<std::endl;
492 
493  }
494 
495  // condition flags for each layer
496  bool Layer_1_2 = false;
497  bool Layer_3_4_5 = false;
498  bool Layer_E = false;
499  bool Layer_W = false;
500  bool Layer_N_U = false;
501  bool Layer_N_L = false;
502  bool Layer_S_U = false;
503  bool Layer_S_L = false;
504 
505  int Trigger= 0;
506 
507  // loop over the hit counters
508  for(unsigned int hc=0; hc<hitcounters.size(); hc++){
509 
510  hit_counter_occupancy->Fill(hitcounters[hc][0]);
511 
512  outfile << "Hit counter ID " << hitcounters[hc][0] << ", flag "
513  << hitcounters[hc][1] << ", track ID " << hitcounters[hc][2]
514  << ", intersection point: ";
515 
516  // loop over the rest of the data for each hit counter
517  for(unsigned int nd=3; nd<hitcounters[hc].size(); nd++){
518 
519  outfile << hitcounters[hc][nd] << " ";
520 
521  }
522 
523  outfile << std::endl;
524 
525  // check which layer is hit
526  if( 40 <= hitcounters[hc][0] && hitcounters[hc][0] <= 61){
527  Layer_1_2 = true;
528  }
529  if( hitcounters[hc][0] > 61){
530  Layer_3_4_5 = true;
531  }
532  if (14 <= hitcounters[hc][0] && hitcounters[hc][0] <=19){
533  Layer_N_U = true;
534  }
535  if ( 34 <= hitcounters[hc][0] && hitcounters[hc][0] <= 39){
536  Layer_S_L = true;
537  }
538  if (8 <= hitcounters[hc][0] && hitcounters[hc][0] <= 13){
539  Layer_N_L = true;
540  }
541  if (28 <= hitcounters[hc][0] && hitcounters[hc][0] <= 33){
542  Layer_S_U = true;
543  }
544  if (hitcounters[hc][0] <= 7){
545  Layer_E = true;
546  }
547  if (20 <= hitcounters[hc][0] && hitcounters[hc][0] <= 27){
548  Layer_W = true;
549  }
550  }
551 
552  // check for a satisfied trigger condition
553  if (Layer_1_2 && Layer_3_4_5){
554  Trigger = 1;
555  }
556  if (Layer_N_U && Layer_S_L){
557  Trigger = 2;
558  }
559  if (Layer_N_L && Layer_S_U){
560  Trigger = 3;
561  }
562  if (Layer_E && Layer_W){
563  Trigger = 4;
564  }
565  trigger_occupancy->Fill(Trigger);
566 
567  if(Trigger != 0)
568  outfile << "Muon trigger satisfied: " << Trigger << std::endl;
569 
570  } // check that the counter data is loaded
571 
572  } // done with primary muon
573 
574  } // end loop over particles
575 
576  //outfile << std::endl;
577 
578  // now define a handle for the simulated channels
580  event.getByLabel(fSimulationProducerLabel, simChannelHandle);
581 
582  // loop over the SimChannel objects in the event.
583  for ( auto const& channel : (*simChannelHandle) )
584  {
585 
586  // Get the numeric ID associated with this channel.
587  //auto channelNumber = channel.Channel();
588 
589  // count the time slices and energy deposits
590  int ntimeslice = 0;
591  int nenergydep = 0;
592 
593  // Each channel has a map inside it that connects
594  // a time slice to energy deposits in the detector
595  auto const& timeSlices = channel.TDCIDEMap();
596 
597  // For every time slice in this channel:
598  for ( auto const& timeSlice : timeSlices )
599  {
600 
601  ntimeslice++;
602 
603  // Each entry in a map is a pair<first,second>.
604  // For the timeSlices map, the 'first' is a time
605  // slice number, which we don't care about in this
606  // example. The 'second' is a vector of IDE
607  // objects.
608  auto const& energyDeposits = timeSlice.second;
609 
610  // Loop over the energy deposits. The type of
611  // 'energyDeposit' will be sim::IDE, which is
612  // defined in SimChannel.h.
613  for ( auto const& energyDeposit : energyDeposits )
614  {
615 
616  nenergydep++;
617 
618  // Check if the track that deposited the
619  // energy matches the track of the particle.
620  if ( energyDeposit.trackID != fTrackID ){
621 
622  //outfile << "Energy deposit track: " << energyDeposit.trackID
623  // << ", track ID: " << fTrackID << std::endl;
624  }
625 
626  } // end loop over energy deposits
627 
628  } // end loop over time slices
629  /*
630  outfile << "simulated channel " << channelNumber << ", type " << fGeom->View(channelNumber)
631  << ", with " << ntimeslice << " time slices and "
632  << nenergydep << " total energy deposits" << std::endl;
633  */
634  } // For each SimChannel
635 
636  //outfile << std::endl;
637 
638  // fill the simulation ntuple
639  fSimulationNtuple->Fill();
640 
641  // now get the objects holding all of the raw data information
643  event.getByLabel(fRawDigitLabel, Raw);
644 
645  // put it in a more easily usable form
646  std::vector< art::Ptr<raw::RawDigit> > Digits;
647  art::fill_ptr_vector(Digits, Raw);
648 
649  // loop through all RawDigits (over entire channels)
650  for(size_t d = 0; d < Digits.size(); d++){
651 
652  //outfile << "start digit loop" << std::endl;
653 
655  digit=Digits.at(d);
656 
657  //outfile << "got digit " << d << std::endl;
658 
659  // get the channel number for this digit
660  uint32_t chan = digit->Channel();
661  //outfile << "got channel " << chan << std::endl;
662 
663  //if(chan != 1061){
664 
665  unsigned int apa = std::floor( chan/fChansPerAPA );
666  //outfile << "got apa " << apa << std::endl;
667 
668  // get a vector to hold the uncompressed raw information
669  std::vector<short> uncompressed(digit->Samples());
670 
671  /*
672  // check that the ADC data is not corrupt
673  if(uncompressed[0] < 0 || uncompressed[1] < 0 || uncompressed[2] < 0)
674  throw cet::exception("MuonOccupancy") << "Bad ADC header, channel " << chan << ", APA " << apa
675  << ", ADC[0] = " << uncompressed[0] <<
676 
677  outfile << d << " (of " << Digits.size() << " digits), channel " << chan
678  << " from APA " << apa << std::endl;
679 
680  outfile << "compressed length " << uncompressed.size() << ", first/last memory address "
681  << &uncompressed[0] << "/" << &uncompressed[uncompressed.size()-1] << std::endl;
682 
683  outfile << "ADC length " << digit->ADCs().size() << ", compression type " << digit->Compression() << std::endl;
684 
685  for(unsigned int i = 0; i < uncompressed.size(); ++i)
686  outfile << "ADC vector at " << i << " = " << uncompressed[i] << std::endl;
687  */
688 
689  raw::Uncompress(digit->ADCs(), uncompressed, digit->Compression());
690 
691  //outfile << "uncompressed length " << uncompressed.size() << ", first/last memory address "
692  // << &uncompressed[0] << "/" << &uncompressed[uncompressed.size()-1] << std::endl;
693 
694  bool hit = false;
695  int nsamples = 0;
696 
697  // check for uncompressed data
698  for(unsigned int l=0;l<uncompressed.size();l++) {
699 
700  if(uncompressed.at(l)!=0){
701 
702  hit = true;
703  nsamples++;
704 
705  } // end check for uncompressed data
706 
707  } // end loop over uncompressed digits
708 
709  // fill the hits
710  if(hit){
711 
712  /*
713  outfile << "raw hit channel: " << chan << ", samples " << nsamples << ", type "
714  << fGeom->View(chan)
715  << " from APA " << apa << ", C2W " << fGeom->ChannelToWire(chan)[0].TPC << std::endl;
716  */
717 
718  if( fGeom->View(chan) == geo::kU ){
719  fChanU[apa]->Fill(chan);
720  }
721  if( fGeom->View(chan) == geo::kV ){
722  fChanV[apa]->Fill(chan);
723  }
724  if ( fGeom->View(chan) == geo::kZ && fGeom->ChannelToWire(chan)[0].TPC % 2 == 0 ){
725  fChanZ0[apa]->Fill(chan);
726  }
727  if ( fGeom->View(chan) == geo::kZ && fGeom->ChannelToWire(chan)[0].TPC % 2 == 1 ){
728  fChanZ1[apa]->Fill(chan);
729  //outfile << "filled" << std::endl;
730  }
731 
732  //outfile << "done filling" << std::endl;
733 
734  } // end check for hit
735 
736  //outfile << "done looping over digits" << std::endl;
737 
738  //}
739 
740  } // end RawDigit loop
741 
742  outfile << std::endl << "End event " << fEvent << std::endl << std::endl;
743 
744  return;
745  }
746 
748 
749 } // namespace AnalysisExample
750 
751 #endif // MuonOccupancy_Module
static QCString name
Definition: declinfo.cpp:673
Store parameters for running LArG4.
const ADCvector_t & ADCs() const
Reference to the compressed ADC count vector.
Definition: RawDigit.h:210
geo::Length_t CryostatHalfHeight(geo::CryostatID const &cid) const
Returns the height of the cryostat (y direction)
art::ServiceHandle< geo::Geometry > fGeom
ULong64_t Samples() const
Number of samples in the uncompressed ADC data.
Definition: RawDigit.h:213
std::string string
Definition: nybbler.cc:12
Planes which measure V.
Definition: geo_types.h:126
Declaration of signal hit object.
ChannelID_t Channel() const
DAQ channel this raw data was read from.
Definition: RawDigit.h:212
std::vector< geo::WireID > ChannelToWire(raw::ChannelID_t const channel) const
Returns a list of wires connected to the specified TPC channel.
Definition of basic raw digits.
Planes which measure Z direction.
Definition: geo_types.h:128
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.h:27
unsigned int Ncryostats() const
Returns the number of cryostats in the detector.
Particle class.
void analyze(const art::Event &evt)
static QStrList * l
Definition: config.cpp:1044
static int loadMuonCounterGeometry(char *filename, std::vector< std::vector< double > > &geometry)
Definition: Run.h:21
unsigned int Nchannels() const
Returns the number of TPC readout channels in the detector.
Planes which measure U.
Definition: geo_types.h:125
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:69
unsigned int uint32_t
Definition: stdint.h:126
Collect all the RawData header files together.
T get(std::string const &key) const
Definition: ParameterSet.h:231
geo::MuonCounter35Alg * muon_counter
Declaration of cluster object.
View_t View(geo::PlaneID const &pid) const
Returns the view (wire orientation) on the channels of specified TPC plane.
Definition of data types for geometry description.
Detector simulation of raw signals on wires.
unsigned int NTPC(unsigned int cstat=0) const
Returns the total number of TPCs in the specified cryostat.
void beginRun(const art::Run &run)
raw::Compress_t Compression() const
Compression algorithm used to store the ADC counts.
Definition: RawDigit.h:216
Interface to algorithm class for DUNE 35t muon counters.
p
Definition: test.py:223
geo::Length_t CryostatHalfWidth(geo::CryostatID const &cid) const
Returns the half width of the cryostat (x direction)
object containing MC truth information necessary for making RawDigits and doing back tracking ...
static int testTrackInAllCounters(int trackID, TVector3 trackpoint, TVector3 trackvector, std::vector< std::vector< double > > &geometry, std::vector< std::vector< double > > &hitcounters)
geo::Length_t CryostatLength(geo::CryostatID const &cid) const
Returns the length of the cryostat (z direction)
std::vector< std::vector< double > > countergeometry
TCEvent evt
Definition: DataStructs.cxx:7
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Definition: Ptr.h:291
MuonOccupancy(fhicl::ParameterSet const &pset)
void Uncompress(const std::vector< short > &adc, std::vector< short > &uncompressed, raw::Compress_t compress)
Uncompresses a raw data buffer.
Definition: raw.cxx:755
void reconfigure(fhicl::ParameterSet const &pset)
QTextStream & endl(QTextStream &s)
Event finding and building.
unsigned int run