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::FlashResAna Class Reference
Inheritance diagram for icarus::FlashResAna:

Public Member Functions

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

Private Member Functions

unsigned int GetMaxChan (vector< double > const &pes)
 

Private Attributes

art::InputTag fGenLabel
 
art::InputTag fPhotLabel
 
art::InputTag fFlashLabel0
 
art::InputTag fFlashLabel1
 
art::InputTag fFlashLabel2
 
art::InputTag fFlashLabel3
 
art::InputTag fHitLabel
 
map< int, art::InputTag > fFlashLabels
 
TTree * fTree
 
int fNFlash
 
bool fCC
 
double fFlashPE
 
int fFlashTPC
 
double fFlashWidth [4]
 
int fMaxChan
 
double fMaxPE
 
double fNuE
 
double fNuXYZT [4]
 
double fFlashXYZT [4]
 
double fFlashXYZTMin [4]
 
double fFlashXYZTMax [4]
 
double fDelta [4]
 
double fDeltaPmt
 
bool fInFrame
 
int fNPmtFlash
 
double fHitXYZT [4]
 
double fHitDist
 
double fHitTof
 
int fNHit
 
double fHitPE
 
double fTPhot
 
TH1F * fDeltaTFlash
 
geo::GeometryCore const * fGeometryService
 pointer to Geometry provider More...
 

Detailed Description

Definition at line 50 of file FlashResAna_module.cc.

Constructor & Destructor Documentation

icarus::FlashResAna::FlashResAna ( fhicl::ParameterSet const &  p)
explicit

Definition at line 110 of file FlashResAna_module.cc.

111  : EDAnalyzer{p},
112  fGenLabel(p.get<art::InputTag>("GenLabel","generator")),
113  fPhotLabel(p.get<art::InputTag>("PhotLabel","largeant")),
114  fFlashLabel0(p.get<art::InputTag>("FlashLabel0","opflashTPC0")),
115  fFlashLabel1(p.get<art::InputTag>("FlashLabel1","opflashTPC1")),
116  fFlashLabel2(p.get<art::InputTag>("FlashLabel2","opflashTPC2")),
117  fFlashLabel3(p.get<art::InputTag>("FlashLabel3","opflashTPC3")),
118  fHitLabel(p.get<art::InputTag>("HitLabel","ophit"))
119 {
124 
125  art::ServiceHandle<art::TFileService> tfs;
126 
127  fTree = tfs->make<TTree>("anatree","OpFlash resolution");
128  fTree->Branch("nFlash", &fNFlash, "nFlash/I");
129  fTree->Branch("nuE", &fNuE, "nuE/D");
130  fTree->Branch("cc", &fCC, "cc/O");
131  fTree->Branch("nuXYZT", fNuXYZT, "nuXYZT[4]/D");
132  fTree->Branch("flashXYZT", fFlashXYZT, "flashXYZT[4]/D");
133  fTree->Branch("flashXYZTMin", fFlashXYZTMin, "flashXYZTMin[4]/D");
134  fTree->Branch("flashXYZTMax", fFlashXYZTMax, "flashXYZTMax[4]/D");
135  fTree->Branch("flashWidth",fFlashWidth,"flashWidth[4]/D");
136  fTree->Branch("flashPE", &fFlashPE, "flashPE/D");
137  fTree->Branch("flashTPC", &fFlashTPC, "flashTPC/I");
138  fTree->Branch("maxChan", &fMaxChan, "maxChan/i");
139  fTree->Branch("maxPE", &fMaxPE, "maxPE/D");
140  fTree->Branch("delta", fDelta, "delta[4]/D");
141  fTree->Branch("inFrame", &fInFrame, "inFrame/O");
142  fTree->Branch("deltaPmt", &fDeltaPmt, "deltaPmt/D");
143  fTree->Branch("nPmtFlash", &fNPmtFlash,"nPmtFlash/I");
144  fTree->Branch("hitXYZT", fHitXYZT, "hittXYZT[4]/D");
145  fTree->Branch("hitDist", &fHitDist, "hitDist/D");
146  fTree->Branch("hitTof", &fHitTof, "hitTof/D");
147  fTree->Branch("nHit", &fNHit, "nHit/I");
148  fTree->Branch("hitPE", &fHitPE, "hitPE/D");
149  fTree->Branch("tPhot", &fTPhot, "tPhot/D");
150 
151  fDeltaTFlash = tfs->make<TH1F>("dtflash","delay between flashes;#Delta t [ns];",25000,0,500000);
152 
153  fGeometryService = lar::providerFrom<geo::Geometry>();
154 
155 }
geo::GeometryCore const * fGeometryService
pointer to Geometry provider
art::InputTag fFlashLabel1
pdgs p
Definition: selectors.fcl:22
art::InputTag fFlashLabel0
map< int, art::InputTag > fFlashLabels
art::InputTag fFlashLabel3
art::InputTag fFlashLabel2
art::ServiceHandle< art::TFileService > tfs
icarus::FlashResAna::FlashResAna ( FlashResAna const &  )
delete
icarus::FlashResAna::FlashResAna ( FlashResAna &&  )
delete

Member Function Documentation

void icarus::FlashResAna::analyze ( art::Event const &  e)
override

Definition at line 157 of file FlashResAna_module.cc.

158 {
159  //initialize for each event
160  fNFlash = 0;
161  fCC = false;
162  fFlashPE = 0.;
163  fFlashTPC = -1;
164  fMaxChan = -1;
165  fMaxPE = 0.;
166  fNuE = 0.;
167  fDeltaPmt = 0.;
168  fInFrame = false;;
169  fNPmtFlash= -1;
170  double dt = DBL_MAX;
171  geo::CryostatGeo const& cryo0 = fGeometryService->Cryostat(0);
172 
173  for(size_t i=0; i<4; i++) {
174  fNuXYZT[i] = dt;
175  fFlashXYZT[i] = dt;
176  fFlashXYZTMin[i] = dt;
177  fFlashXYZTMax[i] = dt;
178  fFlashWidth[i] = dt;
179  fDelta[i] = dt;
180  }
181 
182 
183  //neutrino truth
184  auto const& mctruths = //vector of MCTruths from GENIE
185  *e.getValidHandle<vector<simb::MCTruth>>(fGenLabel);
186 
187  auto const& nu = mctruths[0].GetNeutrino();
188  fNuE = nu.Nu().E();
189  if(nu.CCNC()==0)
190  fCC = true;
191 
192  const TLorentzVector nuxyzt = nu.Nu().Position(0);
193  fNuXYZT[0] = nuxyzt.X();
194  fNuXYZT[1] = nuxyzt.Y();
195  fNuXYZT[2] = nuxyzt.Z();
196  fNuXYZT[3] = nuxyzt.T();
197 
198  //SimPhot
199  art::Handle< std::vector<sim::SimPhotons>> photHandle;
200  std::vector< art::Ptr<sim::SimPhotons> > photList;
201  if( e.getByLabel(fPhotLabel, photHandle) )
202  art::fill_ptr_vector(photList, photHandle);
203 
204  double tphotmin = DBL_MAX;
205  for(auto const& phot : photList){
206  for(size_t i=0; i<phot->size(); i++) {
207  if ((phot->at(i)).Time < tphotmin)
208  tphotmin = (phot->at(i)).Time;
209  }
210  }
211  fTPhot = tphotmin;
212 
213  //OpFlash
214  map<int,art::Handle< std::vector<recob::OpFlash> > > flashHandles;
215  map<int,vector< art::Ptr<recob::OpFlash> >> flashLists;
216  if( e.getByLabel(fFlashLabel0,flashHandles[0]) )
217  art::fill_ptr_vector(flashLists[0], flashHandles[0]);
218  if( e.getByLabel(fFlashLabel1,flashHandles[1]) )
219  art::fill_ptr_vector(flashLists[1], flashHandles[1]);
220  if( e.getByLabel(fFlashLabel2,flashHandles[2]) )
221  art::fill_ptr_vector(flashLists[2], flashHandles[2]);
222  if( e.getByLabel(fFlashLabel3,flashHandles[3]) )
223  art::fill_ptr_vector(flashLists[3], flashHandles[3]);
224 
225  for(auto flashList : flashLists) {
226 
227  int tpc = flashList.first;
228  size_t nflashtpc = flashList.second.size();
229  if(nflashtpc==0) continue;
230  fNFlash += nflashtpc;
231 
232  std::sort(flashList.second.begin(),flashList.second.end(),
233  [](art::Ptr<recob::OpFlash> f1, art::Ptr<recob::OpFlash> f2)
234  {return f1->Time()<f2->Time();}
235  );
236 
237  art::FindManyP<recob::OpHit> findManyHits(
238  flashHandles[tpc], e, fFlashLabels[tpc]);
239 
240  //auto const& flash0 = flashList.second[0];
241  for(size_t iflash=0; iflash < nflashtpc; iflash++) {
242  auto const& flash0 = flashList.second[iflash]; //) {
243  if(abs(fNuXYZT[3]-flash0->Time()*1.0e3)<abs(dt)) {
244  dt = flash0->Time()*1.0e3 - fNuXYZT[3];
245  fFlashXYZT[0] = 0.;
246  fFlashXYZT[1] = flash0->YCenter();
247  fFlashXYZT[2] = flash0->ZCenter();
248  fFlashXYZT[3] = flash0->Time()*1.0e3;
249  fFlashWidth[0] = 0.;
250  fFlashWidth[1] = flash0->YWidth();
251  fFlashWidth[2] = flash0->ZWidth();
252  fFlashWidth[3] = flash0->TimeWidth();
253  fFlashPE = flash0->TotalPE();
254  fFlashTPC = tpc;
255  auto const& pes= flash0->PEs();
256  fNPmtFlash = pes.size();
257  fMaxChan = GetMaxChan(pes);
258  fMaxPE = flash0->PE(fMaxChan);
259  fInFrame = flash0->InBeamFrame();
260  for(size_t i=0; i<4; i++)
261  fDelta[i] = fFlashXYZT[i] - fNuXYZT[i];
262 
263  double tPmtMax=-DBL_MAX, tPmtMin=DBL_MAX;
264  vector<art::Ptr<recob::OpHit>> hits = findManyHits.at(iflash);
265  for(auto const& hit : hits) {
266  if(hit->OpChannel() == fMaxChan){
267  fDeltaPmt = hit->PeakTime()*1.0e3 - fNuXYZT[3];
268  }
269  if(hit->PeakTime()<tPmtMin){
270  tPmtMin = hit->PeakTime();
271  geo::OpDetGeo const& opDet = cryo0.OpDet(hit->OpChannel());
272  double pos[3];
273  opDet.GetCenter(pos);
274  for(int i=0; i<3; i++) fFlashXYZTMin[i] = pos[i];
275  fFlashXYZTMin[3] = tPmtMin;
276  }
277  if(hit->PeakTime()>tPmtMax){
278  tPmtMax = hit->PeakTime();
279  geo::OpDetGeo const& opDet = cryo0.OpDet(hit->OpChannel());
280  double pos[3];
281  opDet.GetCenter(pos);
282  for(int i=0; i<3; i++) fFlashXYZTMax[i] = pos[i];
283  fFlashXYZTMax[3] = tPmtMax;
284  }
285  }
286  }
287  }
288 
289  if(nflashtpc>1)
290  for(size_t i=0; i<nflashtpc-1; i++) {
291  auto const& flash = flashList.second.at(i);
292  auto const& flashnext = flashList.second.at(i+1);
293  fDeltaTFlash->Fill((flashnext->Time()-flash->Time())*1.0e3);
294  }
295  }//for flash lists
296 
297  //OpHits
298  art::Handle< std::vector<recob::OpHit> > opHitHandle;
299  std::vector< art::Ptr<recob::OpHit> > opHitList;
300 
301  if( e.getByLabel(fHitLabel,opHitHandle) ) {
302 
303  art::fill_ptr_vector(opHitList, opHitHandle);
304  fNHit = opHitList.size();
305  if(fNHit==0){
306  std::cout << "empty OpHit vector!" << std::endl;
307  for(int i=0; i<4; i++) fHitXYZT[i] = DBL_MAX;
308  fHitDist = DBL_MAX;
309  fHitTof = DBL_MAX;
310  fHitPE = DBL_MAX;
311  }
312 
313  else{
314  std::sort(opHitList.begin(),opHitList.end(),
315  [](art::Ptr<recob::OpHit> h1, art::Ptr<recob::OpHit> h2)
316  {return h1->PeakTime()<h2->PeakTime();}
317  );
318  if(opHitList.size()>1 && opHitList[0]->PeakTime()>opHitList.back()->PeakTime())
319  std::cout << "OpHits time sort failed!" << std::endl;
320 
321  geo::OpDetGeo const& opDet = cryo0.OpDet(opHitList[0]->OpChannel());
322  double pos[3];
323  opDet.GetCenter(pos);
324  for(int i=0; i<3; i++) fHitXYZT[i] = pos[i];
325  fHitXYZT[3] = opHitList[0]->PeakTime()*1.0e3; //time in ns
326  fHitDist = 0.;
327  for(int i=0; i<3; i++)
328  fHitDist+=pow(fHitXYZT[i]-fNuXYZT[i],2);
329  fHitDist = sqrt(fHitDist);
330  fHitTof = fHitXYZT[3] - fNuXYZT[3];
331  fHitPE = opHitList[0]->PE();
332  }
333  }
334  else{
335  std::cout << "no OpHit handle found!" << std::endl;
336  }
337 
338  fTree->Fill();
339 
340 }
geo::GeometryCore const * fGeometryService
pointer to Geometry provider
art::InputTag fFlashLabel1
art::InputTag fFlashLabel0
void GetCenter(double *xyz, double localz=0.0) const
Definition: OpDetGeo.cxx:40
process_name hit
Definition: cheaterreco.fcl:51
Geometry information for a single cryostat.
Definition: CryostatGeo.h:43
T abs(T value)
map< int, art::InputTag > fFlashLabels
art::InputTag fFlashLabel3
const OpDetGeo & OpDet(unsigned int iopdet) const
Return the iopdet&#39;th optical detector in the cryostat.
CryostatGeo const & Cryostat(geo::CryostatID const &cryoid) const
Returns the specified cryostat.
do i e
unsigned int GetMaxChan(vector< double > const &pes)
art::InputTag fFlashLabel2
BEGIN_PROLOG SN nu
BEGIN_PROLOG could also be cout
unsigned int icarus::FlashResAna::GetMaxChan ( vector< double > const &  pes)
private

Definition at line 342 of file FlashResAna_module.cc.

342  {
343 
344  size_t imax = 0;
345  double max = 0.;
346  for(size_t i=0; i<pes.size(); i++){
347  if(pes[i]>max) {
348  max = pes[i];
349  imax = i;
350  }
351  }
352 
353  return imax;
354 }
FlashResAna& icarus::FlashResAna::operator= ( FlashResAna const &  )
delete
FlashResAna& icarus::FlashResAna::operator= ( FlashResAna &&  )
delete

Member Data Documentation

bool icarus::FlashResAna::fCC
private

Definition at line 79 of file FlashResAna_module.cc.

double icarus::FlashResAna::fDelta[4]
private

Definition at line 90 of file FlashResAna_module.cc.

double icarus::FlashResAna::fDeltaPmt
private

Definition at line 91 of file FlashResAna_module.cc.

TH1F* icarus::FlashResAna::fDeltaTFlash
private

Definition at line 101 of file FlashResAna_module.cc.

art::InputTag icarus::FlashResAna::fFlashLabel0
private

Definition at line 69 of file FlashResAna_module.cc.

art::InputTag icarus::FlashResAna::fFlashLabel1
private

Definition at line 70 of file FlashResAna_module.cc.

art::InputTag icarus::FlashResAna::fFlashLabel2
private

Definition at line 71 of file FlashResAna_module.cc.

art::InputTag icarus::FlashResAna::fFlashLabel3
private

Definition at line 72 of file FlashResAna_module.cc.

map<int,art::InputTag> icarus::FlashResAna::fFlashLabels
private

Definition at line 75 of file FlashResAna_module.cc.

double icarus::FlashResAna::fFlashPE
private

Definition at line 80 of file FlashResAna_module.cc.

int icarus::FlashResAna::fFlashTPC
private

Definition at line 81 of file FlashResAna_module.cc.

double icarus::FlashResAna::fFlashWidth[4]
private

Definition at line 82 of file FlashResAna_module.cc.

double icarus::FlashResAna::fFlashXYZT[4]
private

Definition at line 87 of file FlashResAna_module.cc.

double icarus::FlashResAna::fFlashXYZTMax[4]
private

Definition at line 89 of file FlashResAna_module.cc.

double icarus::FlashResAna::fFlashXYZTMin[4]
private

Definition at line 88 of file FlashResAna_module.cc.

art::InputTag icarus::FlashResAna::fGenLabel
private

Definition at line 67 of file FlashResAna_module.cc.

geo::GeometryCore const* icarus::FlashResAna::fGeometryService
private

pointer to Geometry provider

Definition at line 105 of file FlashResAna_module.cc.

double icarus::FlashResAna::fHitDist
private

Definition at line 95 of file FlashResAna_module.cc.

art::InputTag icarus::FlashResAna::fHitLabel
private

Definition at line 73 of file FlashResAna_module.cc.

double icarus::FlashResAna::fHitPE
private

Definition at line 98 of file FlashResAna_module.cc.

double icarus::FlashResAna::fHitTof
private

Definition at line 96 of file FlashResAna_module.cc.

double icarus::FlashResAna::fHitXYZT[4]
private

Definition at line 94 of file FlashResAna_module.cc.

bool icarus::FlashResAna::fInFrame
private

Definition at line 92 of file FlashResAna_module.cc.

int icarus::FlashResAna::fMaxChan
private

Definition at line 83 of file FlashResAna_module.cc.

double icarus::FlashResAna::fMaxPE
private

Definition at line 84 of file FlashResAna_module.cc.

int icarus::FlashResAna::fNFlash
private

Definition at line 78 of file FlashResAna_module.cc.

int icarus::FlashResAna::fNHit
private

Definition at line 97 of file FlashResAna_module.cc.

int icarus::FlashResAna::fNPmtFlash
private

Definition at line 93 of file FlashResAna_module.cc.

double icarus::FlashResAna::fNuE
private

Definition at line 85 of file FlashResAna_module.cc.

double icarus::FlashResAna::fNuXYZT[4]
private

Definition at line 86 of file FlashResAna_module.cc.

art::InputTag icarus::FlashResAna::fPhotLabel
private

Definition at line 68 of file FlashResAna_module.cc.

double icarus::FlashResAna::fTPhot
private

Definition at line 99 of file FlashResAna_module.cc.

TTree* icarus::FlashResAna::fTree
private

Definition at line 77 of file FlashResAna_module.cc.


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