All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Member Functions | Private Attributes | List of all members
icarus::PhotBackground Class Reference
Inheritance diagram for icarus::PhotBackground:

Public Member Functions

 PhotBackground (fhicl::ParameterSet const &p)
 
 PhotBackground (PhotBackground const &)=delete
 
 PhotBackground (PhotBackground &&)=delete
 
PhotBackgroundoperator= (PhotBackground const &)=delete
 
PhotBackgroundoperator= (PhotBackground &&)=delete
 
void analyze (art::Event const &e) override
 

Private Member Functions

int EnteredLar (const TLorentzVector &v, bool &iv, bool &fv)
 

Private Attributes

crt::CRTBackTracker bt
 
crt::CRTCommonUtilsfCrtutils
 
geo::GeometryCore const * fGeometryService = lar::providerFrom<geo::Geometry>()
 pointer to Geometry provider More...
 
geo::CryostatGeo const & cryo0 = fGeometryService->Cryostat(0)
 
geo::CryostatGeo const & cryo1 = fGeometryService->Cryostat(1)
 
geo::TPCGeo const & tpc00 = cryo0.TPC(0)
 
geo::TPCGeo const & tpc01 = cryo0.TPC(1)
 
geo::TPCGeo const & tpc10 = cryo1.TPC(0)
 
geo::TPCGeo const & tpc11 = cryo1.TPC(1)
 
TTree * fTree
 
int fIcode
 end process code [-1->do not use; 0-> pair prod; 1-> compton] More...
 
double fStartPos [4]
 photon start x,y,z,t [cm/ns] More...
 
double fEndPos [4]
 photon end x,y,z,t [cm/ns] More...
 
double fStartE
 photon start energy [GeV] More...
 
double fEndE
 photon end energy [GeV] More...
 
int fStartReg
 region where photon was produced More...
 
int fEndReg
 region where photon interacted More...
 
bool fPhotIV
 
bool fPhotAV
 
vector< int > fMuRegs
 
bool fMuIV
 
bool fMuAV
 
bool fMuTag
 
int fMuNHit
 
vector< vector< double > > fMuHitPos
 
vector< double > fMuHitDx
 
vector< double > fMuHitDt
 

Detailed Description

Definition at line 50 of file PhotBackground_module.cc.

Constructor & Destructor Documentation

PhotBackground::PhotBackground ( fhicl::ParameterSet const &  p)
explicit

Definition at line 103 of file PhotBackground_module.cc.

104  : EDAnalyzer{p},
105  bt(p.get<fhicl::ParameterSet>("CRTBackTrack")),
106  fCrtutils(new crt::CRTCommonUtils())
107 {
108  art::ServiceHandle<art::TFileService> tfs;
109 
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);
128 }
vector< vector< double > > fMuHitPos
double fEndPos[4]
photon end x,y,z,t [cm/ns]
pdgs p
Definition: selectors.fcl:22
double fStartPos[4]
photon start x,y,z,t [cm/ns]
int fStartReg
region where photon was produced
int fIcode
end process code [-1-&gt;do not use; 0-&gt; pair prod; 1-&gt; compton]
double fStartE
photon start energy [GeV]
art::ServiceHandle< art::TFileService > tfs
crt::CRTCommonUtils * fCrtutils
double fEndE
photon end energy [GeV]
int fEndReg
region where photon interacted
icarus::PhotBackground::PhotBackground ( PhotBackground const &  )
delete
icarus::PhotBackground::PhotBackground ( PhotBackground &&  )
delete

Member Function Documentation

void PhotBackground::analyze ( art::Event const &  e)
override

Definition at line 130 of file PhotBackground_module.cc.

131 {
132  // Define a "handle" to point to a vector of MCParticle objects.
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;
137 
138  //true CRT hits
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;
142 
143  if( e.getByLabel("crttruehit",trueHitHandle) )
144  art::fill_ptr_vector(trueHitList,trueHitHandle);
145 
146  for(auto const& particle : *particleHandle) {
147 
148  if(abs(particle.PdgCode())==13){
149  idToMu[particle.TrackId()] = &particle;
150  }
151 
152  else if(particle.PdgCode()==22 && particle.Process()=="muBrems")
153  photList.push_back(&particle);
154 
155  else
156  continue;
157  }//for MCParticles
158 
159  for(auto const& hit : trueHitList){
160  for(const int id: bt.AllTrueIds(e,*hit)) {
161  if(idToMu.find(id)==idToMu.end())
162  continue;
163  muToTrueHits[id].push_back(hit);
164  }//for trackIDs
165  }//for CRTTrueHits
166 
167  for(auto const& phot : photList) {
168 
169  const TLorentzVector& positionStart = phot->Position();
170  const TLorentzVector& positionEnd = phot->EndPosition();
171 
172  fPhotIV = false;
173  fPhotAV = false;
174  fEndReg = EnteredLar(positionEnd, fPhotIV, fPhotAV);
175  if(fEndReg==-1)
176  continue;
177  bool iv = false, av = false;
178  fStartReg = EnteredLar(positionStart, iv, av);
179 
180  for(size_t i=0; i<4; i++) {
181  fStartPos[i] = positionStart[i];
182  fEndPos[i] = positionEnd[i];
183  }
184  fStartE = phot->E();
185  fEndE = phot->E(phot->NumberTrajectoryPoints()-2);
186 
187  fIcode = -1;
188  string endprocess = phot->EndProcess();
189  if(endprocess=="conv") fIcode = 0; //pair prod
190  else if(endprocess=="compt") fIcode = 1; //compton scatter
191  else if(endprocess=="phot") fIcode = 2; //photoelectric
192  else std::cout << "uknown end process: " << endprocess << std::endl;
193 
194 
195 
196  if(idToMu.find(phot->Mother())==idToMu.end())
197  throw cet::exception("PhotBackground") <<
198  "no match muon found for mubrems photons" << std::endl;
199 
200  fMuIV = false;
201  fMuAV = false;
202  fMuTag = false;
203  fMuNHit = 0;
204  fMuRegs.clear();
205  fMuHitPos.clear();
206  fMuHitDx.clear();
207  fMuHitDt.clear();
208 
209  if(muToTrueHits.find(phot->Mother())!=muToTrueHits.end()){
210  fMuTag = true;
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};
214  fMuHitPos.push_back(xyzt);
215  double l = 0.;
216  for(int j=0; j<3; j++) l+=pow(xyzt[j]-fEndPos[j],2);
217  fMuHitDx.push_back(sqrt(l));
218  fMuHitDt.push_back((double)hit->ts0_ns-1.6e6-fEndPos[3]);
219  string reg = hit->tagger;
220  //fMuRegType.push_back(fCrtutils->GetRegTypeFromRegName(reg));
221  fMuRegs.push_back(fCrtutils->AuxDetRegionNameToNum(reg));
222  }
223  }
224 
225  for(size_t i=0; i<idToMu[phot->Mother()]->NumberTrajectoryPoints(); i++){
226 
227  const TLorentzVector& position = idToMu[phot->Mother()]->Position(i);
228  fMuRegs.push_back(EnteredLar(position, fMuIV, fMuAV));
229 
230  }//for traj pts
231 
232  std::sort(fMuRegs.begin(),fMuRegs.end());
233  fMuRegs.resize(std::distance(fMuRegs.begin(),std::unique(fMuRegs.begin(),fMuRegs.end())));
234 
235  fTree->Fill();
236 
237  }//for photons
238 
239 }//end analyze
vector< vector< double > > fMuHitPos
double fEndPos[4]
photon end x,y,z,t [cm/ns]
int EnteredLar(const TLorentzVector &v, bool &iv, bool &fv)
double fStartPos[4]
photon start x,y,z,t [cm/ns]
process_name hit
Definition: cheaterreco.fcl:51
int fStartReg
region where photon was produced
T abs(T value)
double distance(geo::Point_t const &point, CathodeDesc_t const &cathode)
Returns the distance of a point from the cathode.
int fIcode
end process code [-1-&gt;do not use; 0-&gt; pair prod; 1-&gt; compton]
do i e
std::vector< int > AllTrueIds(const art::Event &event, const CRTData &data)
double fStartE
photon start energy [GeV]
crt::CRTCommonUtils * fCrtutils
BEGIN_PROLOG could also be cout
double fEndE
photon end energy [GeV]
int fEndReg
region where photon interacted
int PhotBackground::EnteredLar ( const TLorentzVector &  v,
bool &  iv,
bool &  fv 
)
private

Definition at line 241 of file PhotBackground_module.cc.

241  {
242 
243  double pos[3] = {v.X(),v.Y(),v.Z()};
244  int reg = -1;
245 
246  if(cryo0.ContainsPosition(pos)){
247 
248  if(tpc00.ContainsPosition(pos)) {
249  reg = 5;
250  av = true;
251  iv = false;
252  }
253  else if(tpc01.ContainsPosition(pos)) {
254  reg = 6;
255  av = true;
256  iv = false;
257  }
258  else {
259  reg = 10;
260  if(!av)iv = true;
261  }
262  }
263  else if(cryo1.ContainsPosition(pos)){
264 
265  if(tpc10.ContainsPosition(pos)){
266  reg = 7;
267  av = true;
268  iv = false;
269  }
270  else if(tpc11.ContainsPosition(pos)) {
271  reg = 8;
272  av = true;
273  iv = false;
274  }
275  else {
276  reg = 12;
277  if(!av)iv = true;
278  }
279  }
280 
281  return reg;
282 
283 }
geo::CryostatGeo const & cryo1
geo::CryostatGeo const & cryo0
bool ContainsPosition(geo::Point_t const &point, double wiggle=1.0) const
Returns whether this volume contains the specified point.
PhotBackground& icarus::PhotBackground::operator= ( PhotBackground const &  )
delete
PhotBackground& icarus::PhotBackground::operator= ( PhotBackground &&  )
delete

Member Data Documentation

crt::CRTBackTracker icarus::PhotBackground::bt
private

Definition at line 69 of file PhotBackground_module.cc.

geo::CryostatGeo const& icarus::PhotBackground::cryo0 = fGeometryService->Cryostat(0)
private

Definition at line 73 of file PhotBackground_module.cc.

geo::CryostatGeo const& icarus::PhotBackground::cryo1 = fGeometryService->Cryostat(1)
private

Definition at line 74 of file PhotBackground_module.cc.

crt::CRTCommonUtils* icarus::PhotBackground::fCrtutils
private

Definition at line 70 of file PhotBackground_module.cc.

double icarus::PhotBackground::fEndE
private

photon end energy [GeV]

Definition at line 87 of file PhotBackground_module.cc.

double icarus::PhotBackground::fEndPos[4]
private

photon end x,y,z,t [cm/ns]

Definition at line 85 of file PhotBackground_module.cc.

int icarus::PhotBackground::fEndReg
private

region where photon interacted

Definition at line 89 of file PhotBackground_module.cc.

geo::GeometryCore const* icarus::PhotBackground::fGeometryService = lar::providerFrom<geo::Geometry>()
private

pointer to Geometry provider

Definition at line 72 of file PhotBackground_module.cc.

int icarus::PhotBackground::fIcode
private

end process code [-1->do not use; 0-> pair prod; 1-> compton]

Definition at line 83 of file PhotBackground_module.cc.

bool icarus::PhotBackground::fMuAV
private

Definition at line 94 of file PhotBackground_module.cc.

vector<double> icarus::PhotBackground::fMuHitDt
private

Definition at line 99 of file PhotBackground_module.cc.

vector<double> icarus::PhotBackground::fMuHitDx
private

Definition at line 98 of file PhotBackground_module.cc.

vector<vector<double> > icarus::PhotBackground::fMuHitPos
private

Definition at line 97 of file PhotBackground_module.cc.

bool icarus::PhotBackground::fMuIV
private

Definition at line 93 of file PhotBackground_module.cc.

int icarus::PhotBackground::fMuNHit
private

Definition at line 96 of file PhotBackground_module.cc.

vector<int> icarus::PhotBackground::fMuRegs
private

Definition at line 92 of file PhotBackground_module.cc.

bool icarus::PhotBackground::fMuTag
private

Definition at line 95 of file PhotBackground_module.cc.

bool icarus::PhotBackground::fPhotAV
private

Definition at line 91 of file PhotBackground_module.cc.

bool icarus::PhotBackground::fPhotIV
private

Definition at line 90 of file PhotBackground_module.cc.

double icarus::PhotBackground::fStartE
private

photon start energy [GeV]

Definition at line 86 of file PhotBackground_module.cc.

double icarus::PhotBackground::fStartPos[4]
private

photon start x,y,z,t [cm/ns]

Definition at line 84 of file PhotBackground_module.cc.

int icarus::PhotBackground::fStartReg
private

region where photon was produced

Definition at line 88 of file PhotBackground_module.cc.

TTree* icarus::PhotBackground::fTree
private

Definition at line 82 of file PhotBackground_module.cc.

geo::TPCGeo const& icarus::PhotBackground::tpc00 = cryo0.TPC(0)
private

Definition at line 76 of file PhotBackground_module.cc.

geo::TPCGeo const& icarus::PhotBackground::tpc01 = cryo0.TPC(1)
private

Definition at line 77 of file PhotBackground_module.cc.

geo::TPCGeo const& icarus::PhotBackground::tpc10 = cryo1.TPC(0)
private

Definition at line 78 of file PhotBackground_module.cc.

geo::TPCGeo const& icarus::PhotBackground::tpc11 = cryo1.TPC(1)
private

Definition at line 79 of file PhotBackground_module.cc.


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