9 #ifndef MuonOccupancy_Module 10 #define MuonOccupancy_Module 29 #include "art_root_io/TFileService.h" 31 #include "canvas/Persistency/Common/FindManyP.h" 39 #include "TLorentzVector.h" 178 struct tm * timeinfo;
181 timeinfo = localtime (&rawtime);
184 outfile.open(
"muonoccupancy.log");
186 outfile <<
"MuonOccupancy_module log file, " << asctime(timeinfo) <<
std::endl;
202 outfile <<
" Cryostat " <<
c <<
" [x,y,z] (cm) = ";
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.);
222 trigger_occupancy = tfs->make<TH1D>(
"Trigger occupancy",
";trigger number;",4,1,5);
226 fSimulationNtuple = tfs->make<TTree>(
"MuonOccupancySimulation",
"MuonOccupancySimulation");
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");
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");
249 unsigned int Z0ChMin;
250 unsigned int Z0ChMax;
251 unsigned int Z1ChMin;
252 unsigned int Z1ChMax;
292 outfile <<
"Z1 channel number minimum and maximum: " <<
fZ1ChanMin <<
"," << fZ1ChanMax
296 for(
unsigned int i=0;i<
fNofAPA;i++){
312 title <<
"Hit Channel (Plane U, APA";
314 TempHisto = tfs->make<TH1I>(name.str().c_str(),title.str().c_str(), UChMax - UChMin + 2, UChMin-1, UChMax);
315 fChanU.push_back(TempHisto);
321 title <<
"Hit Channel (Plane V, APA";
323 TempHisto = tfs->make<TH1I>(name.str().c_str(),title.str().c_str(), VChMax - VChMin + 2, VChMin-1, VChMax);
324 fChanV.push_back(TempHisto);
330 title <<
"Hit Channel (Plane Z0, APA";
332 TempHisto = tfs->make<TH1I>(name.str().c_str(),title.str().c_str(), Z0ChMax - Z0ChMin + 2, Z0ChMin-1, Z0ChMax);
339 title <<
"Hit Channel (Plane Z1, APA";
341 TempHisto = tfs->make<TH1I>(name.str().c_str(),title.str().c_str(), Z1ChMax - Z1ChMin + 2, Z1ChMin-1, Z1ChMax);
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");
358 char counterfile[] =
"../Geometry/muoncounters.txt";
385 fEvent =
event.id().event();
398 std::map< int, const simb::MCParticle* > particleMap;
401 for (
auto const& particle : (*particleHandle) )
411 fPDG = particle.PdgCode();
420 size_t numberTrajectoryPoints = particle.NumberTrajectoryPoints();
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);
432 double x_increment = 0.;
433 double z_increment = 0.;
435 TVector3 trackStart(positionStart.X()+x_increment,positionStart.Y(),positionStart.Z()+z_increment);
451 momentumEnd.GetXYZT(
fEndPE );
469 double trackLength = ( positionEnd - positionStart ).Rho();
481 unsigned int counters_hit = 0;
482 std::vector< std::vector<double> > hitcounters;
485 trackStart, momentumStart.Vect(),
488 if(counters_hit != hitcounters.size()){
490 outfile <<
"ERROR: size of hit counters vector is not the same as number of hit counters." 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;
508 for(
unsigned int hc=0; hc<hitcounters.size(); hc++){
512 outfile <<
"Hit counter ID " << hitcounters[hc][0] <<
", flag " 513 << hitcounters[hc][1] <<
", track ID " << hitcounters[hc][2]
514 <<
", intersection point: ";
517 for(
unsigned int nd=3; nd<hitcounters[hc].size(); nd++){
519 outfile << hitcounters[hc][nd] <<
" ";
526 if( 40 <= hitcounters[hc][0] && hitcounters[hc][0] <= 61){
529 if( hitcounters[hc][0] > 61){
532 if (14 <= hitcounters[hc][0] && hitcounters[hc][0] <=19){
535 if ( 34 <= hitcounters[hc][0] && hitcounters[hc][0] <= 39){
538 if (8 <= hitcounters[hc][0] && hitcounters[hc][0] <= 13){
541 if (28 <= hitcounters[hc][0] && hitcounters[hc][0] <= 33){
544 if (hitcounters[hc][0] <= 7){
547 if (20 <= hitcounters[hc][0] && hitcounters[hc][0] <= 27){
553 if (Layer_1_2 && Layer_3_4_5){
556 if (Layer_N_U && Layer_S_L){
559 if (Layer_N_L && Layer_S_U){
562 if (Layer_E && Layer_W){
583 for (
auto const&
channel : (*simChannelHandle) )
595 auto const& timeSlices =
channel.TDCIDEMap();
598 for (
auto const& timeSlice : timeSlices )
608 auto const& energyDeposits = timeSlice.second;
613 for (
auto const& energyDeposit : energyDeposits )
620 if ( energyDeposit.trackID !=
fTrackID ){
646 std::vector< art::Ptr<raw::RawDigit> > Digits;
650 for(
size_t d = 0;
d < Digits.size();
d++){
669 std::vector<short> uncompressed(digit->
Samples());
698 for(
unsigned int l=0;
l<uncompressed.size();
l++) {
700 if(uncompressed.at(
l)!=0){
751 #endif // MuonOccupancy_Module
TH1D * hit_counter_occupancy
Store parameters for running LArG4.
const ADCvector_t & ADCs() const
Reference to the compressed ADC count vector.
geo::Length_t CryostatHalfHeight(geo::CryostatID const &cid) const
Returns the height of the cryostat (y direction)
std::vector< TH1I * > fChanZ1
art::ServiceHandle< geo::Geometry > fGeom
ULong64_t Samples() const
Number of samples in the uncompressed ADC data.
std::string fRawDigitLabel
Declaration of signal hit object.
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.
Definition of basic raw digits.
Planes which measure Z direction.
std::string fSimulationProducerLabel
EDAnalyzer(fhicl::ParameterSet const &pset)
unsigned int Ncryostats() const
Returns the number of cryostats in the detector.
void analyze(const art::Event &evt)
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.
#define DEFINE_ART_MODULE(klass)
Collect all the RawData header files together.
T get(std::string const &key) const
geo::MuonCounter35Alg * muon_counter
std::vector< TH1I * > fChanU
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.
Interface to algorithm class for DUNE 35t muon counters.
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)
unsigned int fChansPerAPA
geo::Length_t CryostatLength(geo::CryostatID const &cid) const
Returns the length of the cryostat (z direction)
std::vector< std::vector< double > > countergeometry
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
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.
std::vector< TH1I * > fChanV
void reconfigure(fhicl::ParameterSet const &pset)
TTree * fSimulationNtuple
QTextStream & endl(QTextStream &s)
Event finding and building.
std::vector< TH1I * > fChanZ0