11 #include "art/Framework/Core/EDAnalyzer.h" 
   12 #include "art/Framework/Core/ModuleMacros.h" 
   13 #include "art/Framework/Principal/Event.h" 
   14 #include "art/Framework/Principal/Handle.h" 
   15 #include "art/Framework/Principal/Run.h" 
   16 #include "art/Framework/Principal/SubRun.h" 
   17 #include "canvas/Utilities/InputTag.h" 
   18 #include "fhiclcpp/ParameterSet.h" 
   19 #include "messagefacility/MessageLogger/MessageLogger.h" 
   20 #include "art_root_io/TFileService.h" 
   23 #include "nusimdata/SimulationBase/MCParticle.h" 
   45 using namespace icarus;
 
   63   void analyze(art::Event 
const& 
e) 
override;
 
   67     int EnteredLar(
const TLorentzVector& v, 
bool& iv, 
bool& fv);
 
  105     bt(p.get<fhicl::ParameterSet>(
"CRTBackTrack")),
 
  108     art::ServiceHandle<art::TFileService> 
tfs;
 
  110     fTree = tfs->make<TTree>(
"anatree",
"analysis tree for photon backgrounds");
 
  111     fTree->Branch(
"icode",    &fIcode,   
"icode/I");
 
  112     fTree->Branch(
"startpos", fStartPos, 
"startpos[4]/D");
 
  113     fTree->Branch(
"endpos",   fEndPos,   
"endpos[4]/D");
 
  114     fTree->Branch(
"starte",   &fStartE,  
"starte/D");
 
  115     fTree->Branch(
"ende",     &fEndE,    
"ende/D");
 
  116     fTree->Branch(
"startreg", &fStartReg,
"startreg/I");
 
  117     fTree->Branch(
"endreg",   &fEndReg,  
"endreg/I");
 
  118     fTree->Branch(
"photav",   &fPhotAV,    
"photav/O");
 
  119     fTree->Branch(
"photiv",   &fPhotIV,    
"photiv/O");
 
  120     fTree->Branch(
"regs",     &fMuRegs);
 
  121     fTree->Branch(
"muav",     &fMuAV,    
"muav/O");
 
  122     fTree->Branch(
"muiv",     &fMuIV,    
"muiv/O");
 
  123     fTree->Branch(
"mutag",    &fMuTag,   
"mutag/O");
 
  124     fTree->Branch(
"nhit",     &fMuNHit,  
"nhit/I");
 
  125     fTree->Branch(
"hitpos",   &fMuHitPos);
 
  126     fTree->Branch(
"dx",       &fMuHitDx);
 
  127     fTree->Branch(
"dt",       &fMuHitDt);
 
  133     art::Handle< vector<simb::MCParticle> > particleHandle;
 
  134     e.getByLabel(
"largeant", particleHandle);
 
  135     map<int,const simb::MCParticle*> idToMu;
 
  136     vector<const simb::MCParticle*> photList;
 
  139     art::Handle< vector<sbn::crt::CRTHit> > trueHitHandle;
 
  140     vector< art::Ptr<sbn::crt::CRTHit> > trueHitList;
 
  141     map<int,vector<art::Ptr<sbn::crt::CRTHit>>> muToTrueHits;
 
  143     if( e.getByLabel(
"crttruehit",trueHitHandle) ) 
 
  144         art::fill_ptr_vector(trueHitList,trueHitHandle);
 
  146     for(
auto const& particle : *particleHandle) {
 
  148         if(
abs(particle.PdgCode())==13){
 
  149             idToMu[particle.TrackId()] = &particle;
 
  152         else if(particle.PdgCode()==22 && particle.Process()==
"muBrems")
 
  153             photList.push_back(&particle);
 
  159     for(
auto const& 
hit : trueHitList){
 
  161             if(idToMu.find(
id)==idToMu.end())
 
  163             muToTrueHits[id].push_back(
hit);
 
  167     for(
auto const& phot : photList) {
 
  169         const TLorentzVector& positionStart = phot->Position();
 
  170         const TLorentzVector& positionEnd   = phot->EndPosition();
 
  177         bool iv = 
false, av = 
false;
 
  180         for(
size_t i=0; i<4; i++) {
 
  185         fEndE   = phot->E(phot->NumberTrajectoryPoints()-2); 
 
  188         string endprocess = phot->EndProcess();
 
  189         if(endprocess==
"conv") 
fIcode = 0; 
 
  190         else if(endprocess==
"compt") 
fIcode = 1; 
 
  191         else if(endprocess==
"phot") 
fIcode = 2;  
 
  192         else std::cout << 
"uknown end process: " << endprocess << std::endl;    
 
  196         if(idToMu.find(phot->Mother())==idToMu.end())
 
  197             throw cet::exception(
"PhotBackground") <<
 
  198                   "no match muon found for mubrems photons" << std::endl;
 
  209         if(muToTrueHits.find(phot->Mother())!=muToTrueHits.end()){
 
  211             fMuNHit=muToTrueHits[phot->Mother()].size();
 
  212             for(
auto const& 
hit : muToTrueHits[phot->Mother()]){
 
  213                 vector<double> xyzt = {
hit->x_pos,
hit->y_pos,
hit->z_pos,(double)
hit->ts0_ns};
 
  216                 for(
int j=0; j<3; j++) l+=pow(xyzt[j]-
fEndPos[j],2);
 
  219                 string reg = 
hit->tagger;
 
  225         for(
size_t i=0; i<idToMu[phot->Mother()]->NumberTrajectoryPoints(); i++){
 
  227             const TLorentzVector& position = idToMu[phot->Mother()]->Position(i);
 
  243     double pos[3] = {v.X(),v.Y(),v.Z()};
 
process_name opflashCryo1 flashfilter analyze
 
vector< vector< double > > fMuHitPos
 
Utilities related to art service access. 
 
double fEndPos[4]
photon end x,y,z,t [cm/ns] 
 
int EnteredLar(const TLorentzVector &v, bool &iv, bool &fv)
 
geo::CryostatGeo const & cryo1
 
Geometry information for a single TPC. 
 
double fStartPos[4]
photon start x,y,z,t [cm/ns] 
 
vector< double > fMuHitDt
 
int fStartReg
region where photon was produced 
 
Geometry information for a single cryostat. 
 
int AuxDetRegionNameToNum(string reg)
 
auto vector(Vector const &v)
Returns a manipulator which will print the specified array. 
 
Access the description of detector geometry. 
 
double distance(geo::Point_t const &point, CathodeDesc_t const &cathode)
Returns the distance of a point from the cathode. 
 
geo::TPCGeo const & tpc00
 
geo::TPCGeo const & tpc01
 
geo::TPCGeo const & tpc11
 
int fIcode
end process code [-1->do not use; 0-> pair prod; 1-> compton] 
 
geo::TPCGeo const & tpc10
 
Description of geometry of one entire detector. 
 
geo::CryostatGeo const & cryo0
 
PhotBackground(fhicl::ParameterSet const &p)
 
std::vector< int > AllTrueIds(const art::Event &event, const CRTData &data)
 
double fStartE
photon start energy [GeV] 
 
art::ServiceHandle< art::TFileService > tfs
 
crt::CRTCommonUtils * fCrtutils
 
void analyze(art::Event const &e) override
 
vector< double > fMuHitDx
 
bool ContainsPosition(geo::Point_t const &point, double wiggle=1.0) const 
Returns whether this volume contains the specified point. 
 
art framework interface to geometry description 
 
BEGIN_PROLOG could also be cout
 
double fEndE
photon end energy [GeV] 
 
int fEndReg
region where photon interacted