Public Member Functions | Private Attributes | List of all members
AnalysisExample::MuonOccupancy Class Reference
Inheritance diagram for AnalysisExample::MuonOccupancy:
art::EDAnalyzer art::detail::Analyzer art::detail::LegacyModule art::Observer art::ModuleBase

Public Member Functions

 MuonOccupancy (fhicl::ParameterSet const &pset)
 
virtual ~MuonOccupancy ()
 
void beginJob ()
 
void beginRun (const art::Run &run)
 
void reconfigure (fhicl::ParameterSet const &pset)
 
void analyze (const art::Event &evt)
 
- Public Member Functions inherited from art::EDAnalyzer
 EDAnalyzer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 EDAnalyzer (Table< Config > const &config)
 
std::string workerType () const
 
- Public Member Functions inherited from art::detail::Analyzer
virtual ~Analyzer () noexcept
 
 Analyzer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 Analyzer (Table< Config > const &config)
 
void doBeginJob ()
 
void doEndJob ()
 
void doRespondToOpenInputFile (FileBlock const &fb)
 
void doRespondToCloseInputFile (FileBlock const &fb)
 
void doRespondToOpenOutputFiles (FileBlock const &fb)
 
void doRespondToCloseOutputFiles (FileBlock const &fb)
 
bool doBeginRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doEndRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doBeginSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEndSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEvent (EventPrincipal &ep, ModuleContext const &mc, std::atomic< std::size_t > &counts_run, std::atomic< std::size_t > &counts_passed, std::atomic< std::size_t > &counts_failed)
 
- Public Member Functions inherited from art::Observer
 ~Observer () noexcept
 
 Observer (Observer const &)=delete
 
 Observer (Observer &&)=delete
 
Observeroperator= (Observer const &)=delete
 
Observeroperator= (Observer &&)=delete
 
void registerProducts (ProductDescriptions &, ModuleDescription const &)
 
void fillDescriptions (ModuleDescription const &)
 
std::string const & processName () const
 
bool wantAllEvents () const
 
bool wantEvent (Event const &e)
 
fhicl::ParameterSetID selectorConfig () const
 
Handle< TriggerResultsgetTriggerResults (Event const &e) const
 
- Public Member Functions inherited from art::ModuleBase
virtual ~ModuleBase () noexcept
 
 ModuleBase ()
 
ModuleDescription const & moduleDescription () const
 
void setModuleDescription (ModuleDescription const &)
 
std::array< std::vector< ProductInfo >, NumBranchTypes > const & getConsumables () const
 
void sortConsumables (std::string const &current_process_name)
 
template<typename T , BranchType BT>
ViewToken< T > consumesView (InputTag const &tag)
 
template<typename T , BranchType BT>
ViewToken< T > mayConsumeView (InputTag const &tag)
 

Private Attributes

std::string fSimulationProducerLabel
 
std::string fRawDigitLabel
 
int fSelectedPDG
 
std::ofstream outfile
 
TH1D * fPositionHist
 
TH1D * fMomentumHist
 
TH1D * fTrackLengthHist
 
TH1D * hit_counter_occupancy
 
TH1D * trigger_occupancy
 
TTree * fSimulationNtuple
 
int fEvent
 
int fRun
 
int fSubRun
 
int fPDG
 
int fTrackID
 
double fStartXYZT [4]
 
double fEndXYZT [4]
 
double fStartPE [4]
 
double fEndPE [4]
 
unsigned int fUChanMin
 
unsigned int fUChanMax
 
unsigned int fVChanMin
 
unsigned int fVChanMax
 
unsigned int fZ0ChanMin
 
unsigned int fZ0ChanMax
 
unsigned int fZ1ChanMin
 
unsigned int fZ1ChanMax
 
unsigned int fNofAPA
 
unsigned int fChansPerAPA
 
std::vector< TH1I * > fChanU
 
std::vector< TH1I * > fChanV
 
std::vector< TH1I * > fChanZ0
 
std::vector< TH1I * > fChanZ1
 
geo::MuonCounter35Algmuon_counter
 
int counters_loaded = -1
 
std::vector< std::vector< double > > countergeometry
 
art::ServiceHandle< geo::GeometryfGeom
 

Additional Inherited Members

- Public Types inherited from art::EDAnalyzer
using WorkerType = WorkerT< EDAnalyzer >
 
using ModuleType = EDAnalyzer
 
- Protected Member Functions inherited from art::Observer
 Observer (fhicl::ParameterSet const &config)
 
 Observer (std::vector< std::string > const &paths, fhicl::ParameterSet const &config)
 
detail::ProcessAndEventSelectorsprocessAndEventSelectors ()
 
- Protected Member Functions inherited from art::ModuleBase
ConsumesCollectorconsumesCollector ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > consumes (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > mayConsume (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 

Detailed Description

Definition at line 61 of file MuonOccupancy_module.cc.

Constructor & Destructor Documentation

AnalysisExample::MuonOccupancy::MuonOccupancy ( fhicl::ParameterSet const &  pset)
explicit

Definition at line 146 of file MuonOccupancy_module.cc.

147  : EDAnalyzer(parameterSet){
148 
149  // read in the parameters from the .fcl file
150  this->reconfigure(parameterSet);
151  }
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.h:27
void reconfigure(fhicl::ParameterSet const &pset)
AnalysisExample::MuonOccupancy::~MuonOccupancy ( )
virtual

Definition at line 156 of file MuonOccupancy_module.cc.

156 {}

Member Function Documentation

void AnalysisExample::MuonOccupancy::analyze ( const art::Event evt)

Definition at line 382 of file MuonOccupancy_module.cc.

382  {
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  }
const ADCvector_t & ADCs() const
Reference to the compressed ADC count vector.
Definition: RawDigit.h:210
art::ServiceHandle< geo::Geometry > fGeom
ULong64_t Samples() const
Number of samples in the uncompressed ADC data.
Definition: RawDigit.h:213
Planes which measure V.
Definition: geo_types.h:126
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.
Planes which measure Z direction.
Definition: geo_types.h:128
static QStrList * l
Definition: config.cpp:1044
Planes which measure U.
Definition: geo_types.h:125
unsigned int uint32_t
Definition: stdint.h:126
geo::MuonCounter35Alg * muon_counter
View_t View(geo::PlaneID const &pid) const
Returns the view (wire orientation) on the channels of specified TPC plane.
Detector simulation of raw signals on wires.
raw::Compress_t Compression() const
Compression algorithm used to store the ADC counts.
Definition: RawDigit.h:216
static int testTrackInAllCounters(int trackID, TVector3 trackpoint, TVector3 trackvector, std::vector< std::vector< double > > &geometry, std::vector< std::vector< double > > &hitcounters)
std::vector< std::vector< double > > countergeometry
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Definition: Ptr.h:291
void Uncompress(const std::vector< short > &adc, std::vector< short > &uncompressed, raw::Compress_t compress)
Uncompresses a raw data buffer.
Definition: raw.cxx:755
QTextStream & endl(QTextStream &s)
void AnalysisExample::MuonOccupancy::beginJob ( )
virtual

Reimplemented from art::EDAnalyzer.

Definition at line 174 of file MuonOccupancy_module.cc.

174  {
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  }
static QCString name
Definition: declinfo.cpp:673
geo::Length_t CryostatHalfHeight(geo::CryostatID const &cid) const
Returns the height of the cryostat (y direction)
art::ServiceHandle< geo::Geometry > fGeom
Planes which measure V.
Definition: geo_types.h:126
std::vector< geo::WireID > ChannelToWire(raw::ChannelID_t const channel) const
Returns a list of wires connected to the specified TPC channel.
Planes which measure Z direction.
Definition: geo_types.h:128
unsigned int Ncryostats() const
Returns the number of cryostats in the detector.
static int loadMuonCounterGeometry(char *filename, std::vector< std::vector< double > > &geometry)
unsigned int Nchannels() const
Returns the number of TPC readout channels in the detector.
Planes which measure U.
Definition: geo_types.h:125
geo::MuonCounter35Alg * muon_counter
View_t View(geo::PlaneID const &pid) const
Returns the view (wire orientation) on the channels of specified TPC plane.
unsigned int NTPC(unsigned int cstat=0) const
Returns the total number of TPCs in the specified cryostat.
geo::Length_t CryostatHalfWidth(geo::CryostatID const &cid) const
Returns the half width of the cryostat (x direction)
geo::Length_t CryostatLength(geo::CryostatID const &cid) const
Returns the length of the cryostat (z direction)
std::vector< std::vector< double > > countergeometry
QTextStream & endl(QTextStream &s)
void AnalysisExample::MuonOccupancy::beginRun ( const art::Run run)

Definition at line 375 of file MuonOccupancy_module.cc.

375  {
376 
377  }
void AnalysisExample::MuonOccupancy::reconfigure ( fhicl::ParameterSet const &  pset)

Definition at line 161 of file MuonOccupancy_module.cc.

161  {
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  }
std::string string
Definition: nybbler.cc:12
p
Definition: test.py:223

Member Data Documentation

std::vector< std::vector<double> > AnalysisExample::MuonOccupancy::countergeometry
private

Definition at line 136 of file MuonOccupancy_module.cc.

int AnalysisExample::MuonOccupancy::counters_loaded = -1
private

Definition at line 135 of file MuonOccupancy_module.cc.

unsigned int AnalysisExample::MuonOccupancy::fChansPerAPA
private

Definition at line 126 of file MuonOccupancy_module.cc.

std::vector<TH1I*> AnalysisExample::MuonOccupancy::fChanU
private

Definition at line 128 of file MuonOccupancy_module.cc.

std::vector<TH1I*> AnalysisExample::MuonOccupancy::fChanV
private

Definition at line 129 of file MuonOccupancy_module.cc.

std::vector<TH1I*> AnalysisExample::MuonOccupancy::fChanZ0
private

Definition at line 130 of file MuonOccupancy_module.cc.

std::vector<TH1I*> AnalysisExample::MuonOccupancy::fChanZ1
private

Definition at line 131 of file MuonOccupancy_module.cc.

double AnalysisExample::MuonOccupancy::fEndPE[4]
private

Definition at line 113 of file MuonOccupancy_module.cc.

double AnalysisExample::MuonOccupancy::fEndXYZT[4]
private

Definition at line 111 of file MuonOccupancy_module.cc.

int AnalysisExample::MuonOccupancy::fEvent
private

Definition at line 104 of file MuonOccupancy_module.cc.

art::ServiceHandle<geo::Geometry> AnalysisExample::MuonOccupancy::fGeom
private

Definition at line 139 of file MuonOccupancy_module.cc.

TH1D* AnalysisExample::MuonOccupancy::fMomentumHist
private

Definition at line 96 of file MuonOccupancy_module.cc.

unsigned int AnalysisExample::MuonOccupancy::fNofAPA
private

Definition at line 125 of file MuonOccupancy_module.cc.

int AnalysisExample::MuonOccupancy::fPDG
private

Definition at line 107 of file MuonOccupancy_module.cc.

TH1D* AnalysisExample::MuonOccupancy::fPositionHist
private

Definition at line 95 of file MuonOccupancy_module.cc.

std::string AnalysisExample::MuonOccupancy::fRawDigitLabel
private

Definition at line 86 of file MuonOccupancy_module.cc.

int AnalysisExample::MuonOccupancy::fRun
private

Definition at line 105 of file MuonOccupancy_module.cc.

int AnalysisExample::MuonOccupancy::fSelectedPDG
private

Definition at line 87 of file MuonOccupancy_module.cc.

TTree* AnalysisExample::MuonOccupancy::fSimulationNtuple
private

Definition at line 101 of file MuonOccupancy_module.cc.

std::string AnalysisExample::MuonOccupancy::fSimulationProducerLabel
private

Definition at line 85 of file MuonOccupancy_module.cc.

double AnalysisExample::MuonOccupancy::fStartPE[4]
private

Definition at line 112 of file MuonOccupancy_module.cc.

double AnalysisExample::MuonOccupancy::fStartXYZT[4]
private

Definition at line 110 of file MuonOccupancy_module.cc.

int AnalysisExample::MuonOccupancy::fSubRun
private

Definition at line 106 of file MuonOccupancy_module.cc.

int AnalysisExample::MuonOccupancy::fTrackID
private

Definition at line 108 of file MuonOccupancy_module.cc.

TH1D* AnalysisExample::MuonOccupancy::fTrackLengthHist
private

Definition at line 97 of file MuonOccupancy_module.cc.

unsigned int AnalysisExample::MuonOccupancy::fUChanMax
private

Definition at line 117 of file MuonOccupancy_module.cc.

unsigned int AnalysisExample::MuonOccupancy::fUChanMin
private

Definition at line 116 of file MuonOccupancy_module.cc.

unsigned int AnalysisExample::MuonOccupancy::fVChanMax
private

Definition at line 119 of file MuonOccupancy_module.cc.

unsigned int AnalysisExample::MuonOccupancy::fVChanMin
private

Definition at line 118 of file MuonOccupancy_module.cc.

unsigned int AnalysisExample::MuonOccupancy::fZ0ChanMax
private

Definition at line 121 of file MuonOccupancy_module.cc.

unsigned int AnalysisExample::MuonOccupancy::fZ0ChanMin
private

Definition at line 120 of file MuonOccupancy_module.cc.

unsigned int AnalysisExample::MuonOccupancy::fZ1ChanMax
private

Definition at line 123 of file MuonOccupancy_module.cc.

unsigned int AnalysisExample::MuonOccupancy::fZ1ChanMin
private

Definition at line 122 of file MuonOccupancy_module.cc.

TH1D* AnalysisExample::MuonOccupancy::hit_counter_occupancy
private

Definition at line 98 of file MuonOccupancy_module.cc.

geo::MuonCounter35Alg* AnalysisExample::MuonOccupancy::muon_counter
private

Definition at line 134 of file MuonOccupancy_module.cc.

std::ofstream AnalysisExample::MuonOccupancy::outfile
private

Definition at line 90 of file MuonOccupancy_module.cc.

TH1D* AnalysisExample::MuonOccupancy::trigger_occupancy
private

Definition at line 99 of file MuonOccupancy_module.cc.


The documentation for this class was generated from the following file: