NCFS-Pack
A generic (astro)particle physics analysis framework
 
Loading...
Searching...
No Matches
IcePandel.cxx
Go to the documentation of this file.
1
17
19
159
160#include "IcePandel.h"
161#include "Riostream.h"
162
163// Global pointer to the instance of this object
165
166// TFitter/Minuit interface to IcePandel::FitFCN
167 void IcePandelFCN(Int_t& npar,Double_t* gin,Double_t& f,Double_t* u,Int_t flag)
168 {
169 if (gIcePandel) gIcePandel->FitFCN(npar,gin,f,u,flag);
170 }
171
172ClassImp(IcePandel); // Class implementation to enable ROOT I/O
173
175IcePandel::IcePandel(const char* name,const char* title) : IceRecoBase(name,title)
176{
182
183 fPrint=-2;
184 fHits=0;
185 fFitter=0;
186 fTkfit=0;
187 fFitstats=0;
188
189 SetCleaned(1,"A");
190 SetCleaned(0,"I");
191 SetCleaned(0,"IC");
192 SetCleaned(0,"DC");
193
194 SetMinAhits(0,"A");
195 SetMinAhits(0,"I");
196 SetMinAhits(0,"IC");
197 SetMinAhits(0,"DC");
198
199 SetMinAmods(7,"A");
200 SetMinAmods(7,"I");
201 SetMinAmods(7,"IC");
202 SetMinAmods(7,"DC");
203
204 SetScatteringLength(33.3,"A");
205 SetScatteringLength(30,"UD");
206 SetScatteringLength(5,"DL");
207 SetScatteringLength(40,"LD");
208
209 SetAbsorptionLength(50,"A");
210 SetAbsorptionLength(100,"UD");
211 SetAbsorptionLength(10,"DL");
212 SetAbsorptionLength(150,"LD");
213
214 SetTimeJitter(10,"A");
215 SetTimeJitter(5,"IC");
216 SetTimeJitter(5,"DC");
217
218 SetVgroupUsage(1,"A");
219 SetVgroupUsage(1,"IC");
220 SetVgroupUsage(1,"I");
221 SetVgroupUsage(1,"DC");
222
223 SelectHits(1);
224 SetPenalty(0);
225
226 // Set the global pointer to this instance
227 gIcePandel=this;
228}
229
231{
237
238 if (fHits)
239 {
240 delete fHits;
241 fHits=0;
242 }
243 if (fFitter)
244 {
245 delete fFitter;
246 fFitter=0;
247 }
248 if (fTkfit)
249 {
250 delete fTkfit;
251 fTkfit=0;
252 }
253 if (fFitstats)
254 {
255 delete fFitstats;
256 fFitstats=0;
257 }
258}
259
261{
272
273 fPrint=level;
274}
275
276void IcePandel::SelectHits(Int_t mode)
277{
293
294 if (mode>=0 && mode<=2)
295 {
296 fSelhits=mode;
297 fParams.AddNamedSlot("Selhits");
298 fParams.SetSignal(fSelhits,"Selhits");
299 }
300}
301
302void IcePandel::SetPenalty(Float_t val)
303{
313
314 fPenalty=val;
315 fParams.AddNamedSlot("Penalty");
316 fParams.SetSignal(fPenalty,"Penalty");
317}
318
319void IcePandel::Exec(Option_t* opt)
320{
326
327 // Obtain a pointer to the parent NcJob of this reconstruction task
328 TString name=opt;
329 NcJob* parent=(NcJob*)(gROOT->GetListOfTasks()->FindObject(name.Data()));
330
331 if (!parent) return;
332
333 // Obtain a pointer to the IceCube event data structure
334 fEvt=(IceEvent*)parent->GetObject("IceEvent");
335 if (!fEvt) return;
336
337 // Only process accepted events
338 NcDevice* seldev=(NcDevice*)fEvt->GetDevice("NcEventSelector");
339 if (seldev)
340 {
341 if (seldev->GetSignal("Select") < 0.1) return;
342 }
343
344 // Provide a name for the fParams device in the event
345 fParams.SetNameTitle("IcePandel","IcePandel processor parameters");
346
347 // Add the fParams device to the IceEvent structure
348 fEvt->AddDevice(fParams);
349
350 Int_t nclasses=fUseNames->GetEntries(); // Number of first guess classes to be processed
351 Int_t ntkmax=0; // Max. number of tracks for a certain class
352 TObjString* strx=0;
353 TString str;
354
355 // Printout information on used tracks (if any) at first startup of the processor task
356 if (fFirst)
357 {
358 if (!fUseNames)
359 {
360 cout << " *IcePandel* No input tracks have been specified." << endl;
361 cout << " *** No IcePandel processing will be performed ***." << endl;
362 fFirst=0;
363 return;
364 }
365 cout << " *IcePandel* First guess selections to be processed (-1=all)." << endl;
366 for (Int_t i=0; i<nclasses; i++)
367 {
368 strx=(TObjString*)fUseNames->At(i);
369 if (!strx) continue;
370 str=strx->GetString();
371 ntkmax=fUseNtk->At(i);
372 cout << " Maximally " << ntkmax << " track(s) per event for procedure : " << str.Data() << endl;
373 }
374 cout << " *IcePandel* Hit selection mode : " << fSelhits << endl;
375 cout << " *IcePandel* Penalty value for minimiser : " << fPenalty << " dB." << endl;
376 cout << endl;
377
378 fPsistats.SetStoreMode(1);
379
380 fFirst=0;
381 }
382
383 const Double_t pi=acos(-1.);
384 const Double_t e=exp(1.);
385
386 // Initialisation of the minimisation processor
387 Double_t arglist[100];
388 if (!fFitter) fFitter=new TFitter();
389
390 // The number of reconstructed tracks already present in the event
391 Int_t ntkreco=fEvt->GetNtracks(1);
392
393 if (!fHits)
394 {
395 fHits=new TObjArray();
396 }
397 else
398 {
399 fHits->Clear();
400 }
401
402 // Initialise the basis for the fitted track(s)
403 if (!fTkfit) fTkfit=new NcTrack();
404 if (fTrackname=="") fTrackname=ClassName();
405 TString tracktitle;
406
407 // If selected, use all the good quality hits (except IceTop) of the complete event
408 if (fSelhits==0)
409 {
410 TObjArray* hits=fEvt->GetHits("IceGOM");
411 if (!hits) return;
412 tracktitle=" Pandel fit result using all event hits";
413 for (Int_t ih=0; ih<hits->GetEntries(); ih++)
414 {
415 NcSignal* sx=(NcSignal*)hits->At(ih);
416 if (!sx) continue;
417 NcDevice* om=sx->GetDevice();
418 if (!om) continue;
419 if (om->InheritsFrom("IceTDOM")) continue;
420 if (fCleanI || (om->InheritsFrom("IceAOM") && fCleanA) || (om->InheritsFrom("IceICDOM") && fCleanIC) ||
421 (om->InheritsFrom("IceDCDOM") && fCleanDC))
422 {
423 if (sx->GetDeadValue("ADC") || sx->GetDeadValue("LE") || sx->GetDeadValue("TOT")) continue;
424 }
425 fHits->Add(sx);
426 }
427 }
428
429 // Track by track processing of the selected first guess classes
430 Float_t vec[3];
431 Float_t err[3];
432 Nc3Vector p;
433 NcPosition pos;
434 if (!fFitstats)
435 {
436 fFitstats=new NcSignal();
437 fFitstats->SetNameTitle("Fitstats","TFitter stats for Pandel fit");
438 fFitstats->SetSlotName("IERFIT",1);
439 fFitstats->SetSlotName("FCN",2);
440 fFitstats->SetSlotName("EDM",3);
441 fFitstats->SetSlotName("NVARS",4);
442 fFitstats->SetSlotName("IERERR",5);
443 fFitstats->SetSlotName("PsiSum",6);
444 fFitstats->SetSlotName("PsiMedian",7);
445 fFitstats->SetSlotName("PsiSpread",8);
446 fFitstats->SetSlotName("PsiMean",9);
447 fFitstats->SetSlotName("PsiSigma",10);
448 }
449 Float_t x,y,z,theta,phi,t0;
450 Double_t amin,edm,errdef; // Minimisation stats
451 Int_t ierfit,iererr,nvpar,nparx; // Minimisation stats
452 Int_t ntk=0;
453 Int_t nsig=0;
454 NcTrack* track=0;
455 Int_t nam=0;
456 Int_t nah=0;
457 Int_t amanda,inice,icecube,deepcore; // Detector system indicators of associated hits
458 TString trackname;
459 TString newname;
460 TObjArray mytracks; // Temp. storage for the extracted tracks per class
461 for (Int_t iclass=0; iclass<nclasses; iclass++) // Loop over first guess classes
462 {
463 strx=(TObjString*)fUseNames->At(iclass);
464 if (!strx) continue;
465 str=strx->GetString();
466 ntkmax=fUseNtk->At(iclass);
467 TObjArray* tracks=fEvt->GetTracks(str);
468 ntk=0;
469 if (tracks) ntk=tracks->GetEntries();
470 if (ntkmax>0 && ntk>ntkmax) ntk=ntkmax;
471
472 // Store track pointers in private array to prevent overwriting of TObjArray
473 mytracks.Clear();
474 for (Int_t i=0; i<ntk; i++)
475 {
476 mytracks.Add(tracks->At(i));
477 }
478
479 for (Int_t jtk=0; jtk<ntk; jtk++) // Loop over tracks of a certain class
480 {
481 track=(NcTrack*)mytracks.At(jtk);
482 if (!track) continue;
483
484 // The name of the first guess track without the intial "Ice"
485 trackname=track->GetName();
486 trackname.ReplaceAll("Ice","");
487
488 amanda=0;
489 inice=0;
490 icecube=0;
491 deepcore=0;
492
493 if (fSelhits==1) tracktitle=" Pandel fit result for assoc.";
494 if (fSelhits==2) tracktitle=" Pandel fit result for full";
495
496 NcPosition* r0=track->GetReferencePoint();
497 if (!r0) continue;
498
499 NcTimestamp* tt0=r0->GetTimestamp();
500
501 // Selection of hits to be used in the fitting procedure
502 if (fSelhits==1 || fSelhits==2)
503 {
504 fHits->Clear();
505 nsig=track->GetNsignals();
506 for (Int_t is=1; is<=nsig; is++)
507 {
508 NcSignal* sx=track->GetSignal(is);
509 if (!sx) continue;
510 NcDevice* om=sx->GetDevice();
511 if (!om->InheritsFrom("IceGOM")) continue;
512 if (fCleanI && (sx->GetDeadValue("ADC") || sx->GetDeadValue("LE") || sx->GetDeadValue("TOT"))) continue;
513 if (om->InheritsFrom("IceAOM"))
514 {
515 if (fCleanA && (sx->GetDeadValue("ADC") || sx->GetDeadValue("LE") || sx->GetDeadValue("TOT"))) continue;
516 amanda=1;
517 }
518 if (om->InheritsFrom("IceICDOM"))
519 {
520 if (fCleanIC && (sx->GetDeadValue("ADC") || sx->GetDeadValue("LE") || sx->GetDeadValue("TOT"))) continue;
521 icecube=1;
522 }
523 if (om->InheritsFrom("IceDCDOM"))
524 {
525 if (fCleanDC && (sx->GetDeadValue("ADC") || sx->GetDeadValue("LE") || sx->GetDeadValue("TOT"))) continue;
526 deepcore=1;
527 }
528 // Only use the associated hits
529 if (fSelhits==1) fHits->Add(sx);
530 }
531
532 inice=icecube*deepcore;
533
534 // Determine the corresponding track title suffix and hits to be used in case of fSelhits==2
535 TObjArray* hits=0;
536 if (amanda && !icecube && !deepcore) // Only Amanda hit usage
537 {
538 hits=fEvt->GetHits("IceAOM");
539 tracktitle+=" Amanda hits";
540 }
541 if (inice) // InIce hit usage
542 {
543 hits=fEvt->GetHits("IceIDOM");
544 tracktitle+=" InIce hits";
545 }
546 if (icecube && !deepcore) // Only standard IceCube hit usage
547 {
548 hits=fEvt->GetHits("IceICDOM");
549 tracktitle+=" standard IceCube hits";
550 }
551 if (deepcore && !icecube) // Only DeepCore hit usage
552 {
553 hits=fEvt->GetHits("IceDCDOM");
554 tracktitle+=" DeepCore hits";
555 }
556
557 if (fSelhits==2)
558 {
559 if (!hits) return;
560 for (Int_t is2=0; is2<hits->GetEntries(); is2++)
561 {
562 NcSignal* sx=(NcSignal*)hits->At(is2);
563 if (!sx) continue;
564 NcDevice* om=sx->GetDevice();
565 if (!om) continue;
566 if (om->InheritsFrom("IceTDOM")) continue;
567 if (fCleanI || (om->InheritsFrom("IceAOM") && fCleanA) || (om->InheritsFrom("IceICDOM") && fCleanIC) ||
568 (om->InheritsFrom("IceDCDOM") && fCleanDC))
569 {
570 if (sx->GetDeadValue("ADC") || sx->GetDeadValue("LE") || sx->GetDeadValue("TOT")) continue;
571 }
572 fHits->Add(sx);
573 }
574 }
575 }
576
577 // Require sufficient hits to produce a resulting track from the fitting procedure
578 nah=fHits->GetEntries();
579 nam=fEvt->GetNdevices("IceGOM",fHits);
580 if (!amanda && !icecube && !deepcore) // Complete event hit usage
581 {
582 if (nah<fMinahitsA || nah<fMinahitsI || nah<fMinahitsIC || nah<fMinahitsDC) continue;
583 if (nam<fMinamodsA || nam<fMinamodsI || nam<fMinamodsIC || nam<fMinamodsDC) continue;
584 }
585 if (amanda && !icecube && !deepcore) // Only Amanda hit usage
586 {
587 if (nah<fMinahitsA) continue;
588 if (nam<fMinamodsA) continue;
589 }
590 if (inice) // InIce hit usage
591 {
592 if (nah<fMinahitsI) continue;
593 if (nam<fMinamodsI) continue;
594 }
595 if (icecube && !deepcore) // Only standard IceCube hit usage
596 {
597 if (nah<fMinahitsIC) continue;
598 if (nam<fMinamodsIC) continue;
599 }
600 if (deepcore && !icecube) // Only DeepCore hit usage
601 {
602 if (nah<fMinahitsDC) continue;
603 if (nam<fMinamodsDC) continue;
604 }
605
606 r0->GetVector(vec,"car");
607 r0->GetErrors(err,"car");
608
609 x=vec[0];
610 y=vec[1];
611 z=vec[2];
612
613 p=track->Get3Momentum();
614 p.GetVector(vec,"sph");
615
616 theta=vec[1];
617 phi=vec[2];
618
619 t0=fEvt->GetDifference(tt0,"ns");
620
621 // Process this first guess track with its associated hits
622 fFitter->Clear();
623
624 // Set user selected TFitter printout level
625 arglist[0]=fPrint;
626 if (fPrint==-2) arglist[0]=-1;
627 fFitter->ExecuteCommand("SET PRINT",arglist,1);
628 if (fPrint==-2) fFitter->ExecuteCommand("SET NOWARNINGS",arglist,0);
629
630 fFitter->SetFitMethod("loglikelihood");
631
632 // Define errors to represent 1 sigma for this likelihood scale
633 arglist[0]=5.*log10(e);
634 fFitter->ExecuteCommand("SET ERRORDEF",arglist,1);
635
636 fFitter->SetParameter(0,"r0x",x,0.1,0,0);
637 fFitter->SetParameter(1,"r0y",y,0.1,0,0);
638 fFitter->SetParameter(2,"r0z",z,0.1,0,0);
639 fFitter->SetParameter(3,"theta",theta,0.001,0,pi);
640 fFitter->SetParameter(4,"phi",phi,0.001,0,2.*pi);
641 fFitter->SetParameter(5,"t0",t0,1.,0,32000);
642
643 fFitter->SetFCN(IcePandelFCN);
644
645 fTkfit->Reset();
646
647 arglist[0]=0;
648 ierfit=fFitter->ExecuteCommand("SIMPLEX",arglist,0);
649
650 fFitter->GetStats(amin,edm,errdef,nvpar,nparx);
651
652 fFitstats->Reset();
653 fFitstats->SetSignal(ierfit,1);
654 fFitstats->SetSignal(amin,2);
655 fFitstats->SetSignal(edm,3);
656 fFitstats->SetSignal(nvpar,4);
657
658 fFitstats->SetSignal(fPsistats.GetSum(1),6);
659 fFitstats->SetSignal(fPsistats.GetMedian(1),7);
660 fFitstats->SetSignal(fPsistats.GetSpread(1),8);
661 fFitstats->SetSignal(fPsistats.GetMean(1),9);
662 fFitstats->SetSignal(fPsistats.GetSigma(1),10);
663
664 iererr=fFitter->ExecuteCommand("HESSE",arglist,0);
665 fFitstats->SetSignal(iererr,5);
666
667 // Resulting parameters after minimisation and error calculation
668 vec[0]=fFitter->GetParameter(0);
669 vec[1]=fFitter->GetParameter(1);
670 vec[2]=fFitter->GetParameter(2);
671 err[0]=fFitter->GetParError(0);
672 err[1]=fFitter->GetParError(1);
673 err[2]=fFitter->GetParError(2);
674 pos.SetPosition(vec,"car");
675 pos.SetPositionErrors(err,"car");
676
677 vec[0]=1.;
678 vec[1]=fFitter->GetParameter(3);
679 vec[2]=fFitter->GetParameter(4);
680 err[0]=0.;
681 err[1]=fFitter->GetParError(3);
682 err[2]=fFitter->GetParError(4);
683 p.SetVector(vec,"sph");
684 p.SetErrors(err,"sph");
685
686 t0=fFitter->GetParameter(5);
687 NcTimestamp t0fit((NcTimestamp)(*fEvt));
688 t0fit.Add(0,0,int(t0));
689
690 // Enter the fit result as a track in the event structure
691 ntkreco++;
692 fTkfit->SetId(ntkreco);
693
694 fEvt->AddTrack(fTkfit);
695 NcTrack* trk=fEvt->GetIdTrack(ntkreco);
696 if (!trk) continue;
697
698 trk->SetCharge(fCharge);
699 pos.SetTimestamp(t0fit);
700 trk->SetTimestamp(t0fit);
701 trk->SetReferencePoint(pos);
702 trk->Set3Momentum(p);
704 // Link all the hits used for the fit to the newly created track (and vice versa)
705 for (Int_t ihit=0; ihit<fHits->GetEntries(); ihit++)
706 {
707 NcSignal* sx=(NcSignal*)fHits->At(ihit);
708 if (sx) trk->AddSignal(*sx,1);
709 }
710 // Give the newly created track the proper name
711 newname=fTrackname;
712 if (newname=="") newname=ClassName();
713 newname+="4";
714 newname+=trackname;
715 trk->SetNameTitle(newname.Data(),tracktitle.Data());
716 // Link this newly created track as a hypothesis to the parent first guess track
717 track->SetHypCopy(0);
718 track->AddTrackHypothesis(*trk);
719 } // End loop over tracks
720 } // End loop over first guess classes
721
722}
723
724void IcePandel::FitFCN(Int_t&,Double_t*,Double_t& f,Double_t* x,Int_t)
725{
734
735 const Float_t c=0.299792458; // Light speed in vacuum in meters per ns
736 const Float_t npice=1.31768387; // Phase refractive index (c/v_phase) of ice
737 const Float_t ngice=1.35075806; // Group refractive index (c/v_group) of ice
738 const Float_t thetac=acos(1./npice);// Cherenkov angle (in radians)
739 const Float_t cice=c/ngice; // Light speed in ice in meters per ns
740 const Float_t tau=557;
741 const Double_t pi=acos(-1.);
742
743 f=0;
744
745 // The new r0 and p vectors and t0 from the minimisation
746 Float_t vec[3];
747
748 NcPosition r0;
749 vec[0]=x[0];
750 vec[1]=x[1];
751 vec[2]=x[2];
752 r0.SetPosition(vec,"car");
753
754 Nc3Vector p;
755 vec[0]=1;
756 vec[1]=x[3];
757 vec[2]=x[4];
758 p.SetVector(vec,"sph");
759
760 Float_t t0=x[5];
761
762 // Construct a track with the new values from the minimisation
763 fTkfit->SetReferencePoint(r0);
764 fTkfit->Set3Momentum(p);
765
766 Int_t nhits=fHits->GetEntries();
767
768 NcPosition rhit;
769 Nc3Vector r12;
770 Float_t d,dist,thit,tgeo,proj;
771 Float_t alphac;
772 Float_t zhit,lambda,labs;
773 Double_t sigma ; // PMT time jitter in ns (set per (D)OM)
774 Double_t tres,ksi,rho,eta,pandel;
775 Double_t cpandel1,cpandel2,cpandel3,cpandel;
776 Double_t z,k,alpha,beta,phi,n1,n2,n3,u; // Function parameters for regions 3 and 4
777 Int_t ier;
778 Double_t psihit=0;
779 fPsistats.Reset();
780 for (Int_t i=0; i<nhits; i++)
781 {
782 NcSignal* sx=(NcSignal*)fHits->At(i);
783 if (!sx) continue;
784 IceGOM* omx=(IceGOM*)sx->GetDevice();
785 if (!omx) continue;
786
787 // Angular reduction of complement of thetac due to v_phase and v_group difference
788 alphac=0;
789 if (omx->InheritsFrom("IceAOM"))
790 {
791 if (fVgroupA) alphac=atan((1.-npice/ngice)/sqrt(npice*npice-1.));
792 sigma=fTsigmaA;
793 }
794 if (omx->InheritsFrom("IceICDOM"))
795 {
796 if (fVgroupIC || fVgroupI) alphac=atan((1.-npice/ngice)/sqrt(npice*npice-1.));
797 sigma=fTsigmaIC;
798 }
799 if (omx->InheritsFrom("IceDCDOM"))
800 {
801 if (fVgroupDC || fVgroupI) alphac=atan((1.-npice/ngice)/sqrt(npice*npice-1.));
802 sigma=fTsigmaDC;
803 }
804
805 // The hit position dependent scattering and absorption length
806 if (omx->InheritsFrom("IceAOM")) // Amanda reconstruction
807 {
808 lambda=fLambdaA;
809 labs=fLabsA;
810 }
811 else // IceCube reconstruction
812 {
813 lambda=fLambdaDL; // The ice at the Dust Layer
814 labs=fLabsDL;
815 zhit=omx->GetX(3,"car");
816 if (zhit>-50) // The Ice in the Upper Detector above the dustlayer
817 {
818 lambda=fLambdaUD;
819 labs=fLabsUD;
820 }
821 if (zhit<-150) // Clearest Ice in the Lower Detector under the dustlayer
822 {
823 lambda=fLambdaLD;
824 labs=fLabsLD;
825 }
826 }
827
828 rhit=omx->GetPosition();
829 d=fTkfit->GetDistance(rhit);
830 ksi=d/(sin(thetac)*lambda);
831 r12=rhit-r0;
832 proj=p.Dot(r12);
833 dist=fabs(proj)+d/tan(pi/2.-thetac-alphac);
834 if (proj<0) dist=-dist;
835 tgeo=t0+dist/c;
836 thit=sx->GetSignal("LE",7);
837 tres=thit-tgeo;
838
839 // The Convoluted Pandel function evaluation
840 // For definitions of functions and validity regions, see the
841 // CPandel writeup of O. Fadiran, G. Japaridze and N. van Eijndhoven
842
843 // Move points which are outside the validity rectangle in the (tres,ksi) space
844 // to the edge of the validity rectangle and signal the use of the penalty
845 ier=0;
846 if (tres<-25.*sigma)
847 {
848 tres=-25.*sigma;
849 ier=1;
850 }
851 if (tres>3500)
852 {
853 tres=3500;
854 ier=1;
855 }
856 if (ksi>50)
857 {
858 ksi=50;
859 ier=1;
860 }
861
862 rho=((1./tau)+(cice/labs));
863 eta=(rho*sigma)-(tres/sigma);
864
865 if (ksi<=0) // The zero distance (ksi=0) axis
866 {
867 cpandel=exp(-tres*tres/(2.*sigma*sigma))/(sigma*sqrt(2.*pi));
868 }
869 else if (ksi<=5 && tres>=-5.*sigma && tres<=30.*sigma) // The exact expression in region 1
870 {
871 cpandel1=pow(rho,ksi)*pow(sigma,ksi-1.)*exp(-tres*tres/(2.*sigma*sigma))/pow(2.,0.5*(1.+ksi));
872 cpandel2=ROOT::Math::conf_hyperg(ksi/2.,0.5,eta*eta/2.)/TMath::Gamma((ksi+1.)/2.);
873 cpandel3=sqrt(2.)*eta*ROOT::Math::conf_hyperg((ksi+1.)/2.,1.5,eta*eta/2.)/TMath::Gamma(ksi/2.);
874
875 cpandel=cpandel1*(cpandel2-cpandel3);
876 }
877 else if (ksi<=1 && tres>30.*sigma && tres<=3500) // Approximation in region 2
878 {
879 pandel=pow(rho,ksi)*pow(tres,(ksi-1.))*exp(-rho*tres)/TMath::Gamma(ksi);
880
881 cpandel=exp(rho*rho*sigma*sigma/2.)*pandel;
882 }
883 else if (ksi<=1 && tres<-5.*sigma && tres>=-25.*sigma) // Approximation in region 5
884 {
885 cpandel=pow(rho*sigma,ksi)*pow(eta,-ksi)*exp(-tres*tres/(2.*sigma*sigma))/(sigma*sqrt(2.*pi));
886 }
887 else if (ksi<=50 && eta<=0 && tres<=3500) // Approximation in region 3
888 {
889 z=-eta/sqrt(4.*ksi-2.);
890 k=0.5*(z*sqrt(1.+z*z)+log(z+sqrt(1.+z*z)));
891 alpha=-tres*tres/(2.*sigma*sigma)+eta*eta/4.-ksi/2.+0.25+k*(2.*ksi-1.);
892 alpha+=-log(1.+z*z)/4.-ksi*log(2.)/2.+(ksi-1.)*log(2.*ksi-1.)/2.+ksi*log(rho)+(ksi-1.)*log(sigma);
893 beta=0.5*(z/sqrt(1.+z*z)-1.);
894 n1=beta*(20.*beta*beta+30.*beta+9.)/12.;
895 n2=pow(beta,2.)*(6160.*pow(beta,4.)+18480.*pow(beta,3.)+19404.*pow(beta,2.)+8028.*beta+945.)/288.;
896 n3=27227200.*pow(beta,6.)+122522400.*pow(beta,5.)+220540320.*pow(beta,4.);
897 n3+=200166120.*pow(beta,3.)+94064328.*pow(beta,2.)+20546550.*beta+1403325.;
898 n3*=pow(beta,3.)/51840.;
899 phi=1.-n1/(2.*ksi-1.)+n2/pow(2.*ksi-1.,2.)-n3/pow(2.*ksi-1.,3.);
900 cpandel=exp(alpha)*phi/TMath::Gamma(ksi);
901 }
902 else if (ksi<=50 && eta>=0 && tres>=-25.*sigma) // Approximation in region 4
903 {
904 z=eta/sqrt(4.*ksi-2.);
905 k=0.5*(z*sqrt(1.+z*z)+log(z+sqrt(1.+z*z)));
906 u=exp(ksi/2.-0.25)*pow(2.*ksi-1.,-ksi/2.)*pow(2.,(ksi-1.)/2.);
907 beta=0.5*(z/sqrt(1.+z*z)-1.);
908 n1=beta*(20.*beta*beta+30.*beta+9.)/12.;
909 n2=pow(beta,2.)*(6160.*pow(beta,4.)+18480.*pow(beta,3.)+19404.*pow(beta,2.)+8028.*beta+945.)/288.;
910 n3=27227200.*pow(beta,6.)+122522400.*pow(beta,5.)+220540320.*pow(beta,4.);
911 n3+=200166120.*pow(beta,3.)+94064328.*pow(beta,2.)+20546550.*beta+1403325.;
912 n3*=pow(beta,3.)/51840.;
913 phi=1.+n1/(2.*ksi-1.)+n2/pow(2.*ksi-1.,2.)+n3/pow(2.*ksi-1.,3.);
914 cpandel=pow(rho,ksi)*pow(sigma,ksi-1.)*exp(-pow(tres,2.)/(2.*pow(sigma,2.))+pow(eta,2.)/4.)/sqrt(2.*pi);
915 cpandel*=u*phi*exp(-k*(2.*ksi-1.))*pow(1.+z*z,-0.25);
916 }
917 else // (tres,ksi) outside validity rectangle
918 {
919 ier=1;
920 cout << " *IcePandel::FitFCN* Outside rectangle. We should never get here." << endl;
921 }
922
923 // Use 10*log10 expression to obtain intuitive dB scale
924 // Omit (small) negative values which are possible due to computer accuracy
925 psihit=0;
926 if (cpandel>0) psihit=-10.*log10(cpandel);
927
928 // Penalty in dB for (tres,ksi) points outside the validity rectangle
929 if (ier) psihit+=fPenalty;
930
931 // Update the psi statistics for this hit
932 fPsistats.Enter(float(psihit));
933 f+=psihit;
934 }
935}
936
void IcePandelFCN(Int_t &npar, Double_t *gin, Double_t &f, Double_t *u, Int_t flag)
ClassImp(IcePandel)
IcePandel * gIcePandel
Handling of IceCube event data.
Definition IceEvent.h:20
Signal (Hit) handling of a generic IceCube Optical Module (GOM).
Definition IceGOM.h:12
IceRecoBase derived TTask processor to perform Convoluted Pandel fitting.
Definition IcePandel.h:18
void SetPenalty(Float_t val)
void SetPrintLevel(Int_t level)
virtual ~IcePandel()
Int_t fSelhits
Definition IcePandel.h:30
void FitFCN(Int_t &, Double_t *, Double_t &, Double_t *, Int_t)
virtual void Exec(Option_t *opt)
Int_t fPrint
Definition IcePandel.h:29
TFitter * fFitter
Definition IcePandel.h:32
void SelectHits(Int_t mode=1)
NcSample fPsistats
Definition IcePandel.h:36
Float_t fPenalty
Definition IcePandel.h:33
NcTrack * fTkfit
Definition IcePandel.h:34
NcSignal * fFitstats
Definition IcePandel.h:35
IcePandel(const char *name="IcePandel", const char *title="Gauss convoluted Pandel fitting")
TObjArray * fHits
Definition IcePandel.h:31
Float_t fLambdaLD
Definition IceRecoBase.h:84
Int_t fMinahitsI
Definition IceRecoBase.h:69
void SetScatteringLength(Float_t lambda, TString s)
IceRecoBase(const char *name="IceRecoBase", const char *title="Base class for IceCube reconstruction tasks")
Int_t fMinamodsI
Definition IceRecoBase.h:73
void SetCleaned(Int_t flag, TString s)
Int_t fMinahitsIC
Definition IceRecoBase.h:70
Int_t fMinamodsA
Definition IceRecoBase.h:72
void SetAbsorptionLength(Float_t lambda, TString s)
void SetVgroupUsage(Int_t flag, TString s)
Int_t fCleanI
Definition IceRecoBase.h:45
Int_t fCleanIC
Definition IceRecoBase.h:46
Int_t fMinahitsDC
Definition IceRecoBase.h:71
Int_t fVgroupI
Definition IceRecoBase.h:93
Float_t fLabsA
Definition IceRecoBase.h:85
Int_t fVgroupDC
Definition IceRecoBase.h:95
void SetMinAmods(Int_t nmin, TString s)
TArrayI * fUseNtk
Definition IceRecoBase.h:99
Int_t fCleanDC
Definition IceRecoBase.h:47
Float_t fLabsLD
Definition IceRecoBase.h:88
Float_t fLabsUD
Definition IceRecoBase.h:86
Float_t fLambdaDL
Definition IceRecoBase.h:83
Int_t fCleanA
Definition IceRecoBase.h:44
Float_t fTsigmaIC
Definition IceRecoBase.h:90
TString fTrackname
Definition IceRecoBase.h:96
NcDevice fParams
Float_t fCharge
Definition IceRecoBase.h:97
void SetMinAhits(Int_t nmin, TString s)
Int_t fVgroupA
Definition IceRecoBase.h:92
Int_t fMinamodsIC
Definition IceRecoBase.h:74
Float_t fTsigmaDC
Definition IceRecoBase.h:91
Float_t fLabsDL
Definition IceRecoBase.h:87
Float_t fLambdaA
Definition IceRecoBase.h:81
Float_t fTsigmaA
Definition IceRecoBase.h:89
Int_t fVgroupIC
Definition IceRecoBase.h:94
Int_t fMinamodsDC
Definition IceRecoBase.h:75
TObjArray * fUseNames
Definition IceRecoBase.h:98
Int_t fMinahitsA
Definition IceRecoBase.h:68
IceEvent * fEvt
Definition IceRecoBase.h:43
Float_t fLambdaUD
Definition IceRecoBase.h:82
void SetTimeJitter(Float_t sigma, TString s)
Handling of 3-vectors in various reference frames.
Definition Nc3Vector.h:15
Double_t GetX(Int_t i, TString f, TString u="rad")
void GetErrors(Double_t *e, TString f, TString u="rad") const
void SetVector(Double_t *v, TString f, TString u="rad")
void SetErrors(Double_t *e, TString f, TString u="rad")
Double_t Dot(Nc3Vector &q)
void GetVector(Double_t *v, TString f, TString u="rad") const
Int_t GetDeadValue(Int_t j=1) const
Signal (Hit) handling of a generic device.
Definition NcDevice.h:14
Base class for top level job in a task based procedure.
Definition NcJob.h:18
TObject * GetObject(const char *classname) const
Definition NcJob.cxx:456
Handling of positions (with timestamps) in various reference frames.
Definition NcPosition.h:18
void GetPosition(Double_t *r, TString f, TString u="rad", Float_t s=-1) const
void SetPositionErrors(Double_t *e, TString f, TString u="rad")
void SetPosition(Double_t *r, TString f, TString u="rad")
NcTimestamp * GetTimestamp()
void SetTimestamp(NcTimestamp &t)
Generic handling of (extrapolated) detector signals.
Definition NcSignal.h:23
NcDevice * GetDevice() const
virtual Float_t GetSignal(Int_t j=1, Int_t mode=0) const
Definition NcSignal.cxx:651
Handling of timestamps for (astro)particle physics research.
Definition NcTimestamp.h:20
void Add(Int_t d, Int_t s, Int_t ns, Int_t ps=0)
Handling of the attributes of a reconstructed particle track.
Definition NcTrack.h:19
void SetCharge(Float_t q)
Definition NcTrack.cxx:444
void AddTrackHypothesis(NcTrack &t)
Definition NcTrack.cxx:1269
void SetReferencePoint(NcPosition &p)
Definition NcTrack.cxx:1469
NcSignal * GetSignal(Int_t j) const
Definition NcTrack.cxx:1017
Int_t GetNsignals() const
Definition NcTrack.cxx:970
void AddSignal(NcSignal &s, Int_t mode=0)
Definition NcTrack.cxx:886
void Set3Momentum(Nc3Vector &p)
Definition NcTrack.cxx:401
void SetFitDetails(TObject *obj)
Definition NcTrack.cxx:1922
NcPosition * GetReferencePoint()
Definition NcTrack.cxx:1485
Nc3Vector Get3Momentum(Float_t scale=-1) const
Definition NcTrack.cxx:652
void SetHypCopy(Int_t flag)
Definition NcTrack.cxx:1209
void SetTimestamp(NcTimestamp &t)
Definition NcTrack.cxx:1973