NCFS-Pack
A generic (astro)particle physics analysis framework
 
Loading...
Searching...
No Matches
IceEvent.cxx
Go to the documentation of this file.
1
17
19
282
283#include "IceEvent.h"
284#include "Riostream.h"
285
286ClassImp(IceEvent); // Class implementation to enable ROOT I/O
287
290{
296
297 fStrings=0;
298}
299
301{
307
308 if (fStrings)
309 {
310 delete fStrings;
311 fStrings=0;
312 }
313}
314
316{
322
323 fStrings=0;
324}
325
327{
333
335
336 if (fStrings)
337 {
338 delete fStrings;
339 fStrings=0;
340 }
341}
342
343Int_t IceEvent::GetNstrings(TString classname)
344{
350
351 // Fetch all fired modules of the specified class for this event
352 TObjArray* mods=GetDevices(classname);
353 if (!mods) return 0;
354 Int_t nmods=mods->GetEntries();
355 if (!nmods) return 0;
356
357 // Check for the string ids of the good fired modules
358 if (!fStrings) fStrings=new TArrayI(200);
359 fStrings->Reset();
360 Int_t idxmax=0;
361 Int_t nstrings=0;
362 Int_t jstring=0;
363 Int_t match=0;
364 for (Int_t imod=0; imod<nmods; imod++)
365 {
366 IceGOM* omx=(IceGOM*)mods->At(imod);
367 if (!omx) continue;
368 if (omx->GetDeadValue("ADC") || omx->GetDeadValue("LE") || omx->GetDeadValue("TOT")) continue;
369
370 // Update the number of fired strings
371 jstring=omx->GetString();
372 match=0;
373 idxmax=nstrings;
374 for (Int_t idx=0; idx<idxmax; idx++)
375 {
376 if (jstring==fStrings->At(idx))
377 {
378 match=1;
379 break;
380 }
381 }
382 if (!match) // String number was not present in array
383 {
384 nstrings++;
385 fStrings->AddAt(jstring,nstrings-1);
386 }
387 }
388
389 return nstrings;
390}
391
392Int_t IceEvent::GetNstrings(NcTrack& t,TString classname)
393{
400
401 // Fetch all associated signals for this track
402 Int_t nh=t.GetNsignals();
403 if (!nh) return 0;
404
405 // Check for the string ids of the associated good fired modules of the specified class
406 if (!fStrings) fStrings=new TArrayI(200);
407 fStrings->Reset();
408 Int_t idxmax=0;
409 Int_t nstrings=0;
410 Int_t jstring=0;
411 Int_t match=0;
412 for (Int_t ih=1; ih<=nh; ih++)
413 {
414 NcSignal* sx=t.GetSignal(ih);
415 if (!sx) continue;
416 NcDevice* dev=sx->GetDevice();
417 if (!dev) continue;
418 if (!(dev->InheritsFrom(classname.Data()))) continue;
419 IceGOM* omx=(IceGOM*)dev;
420
421 // Update the number of fired strings
422 jstring=omx->GetString();
423 match=0;
424 idxmax=nstrings;
425 for (Int_t idx=0; idx<idxmax; idx++)
426 {
427 if (jstring==fStrings->At(idx))
428 {
429 match=1;
430 break;
431 }
432 }
433 if (!match) // String number was not present in array
434 {
435 nstrings++;
436 fStrings->AddAt(jstring,nstrings-1);
437 }
438 }
439
440 return nstrings;
441}
442
443Int_t IceEvent::GetNstrings(NcJet& j,TString classname)
444{
451
452 Int_t ntk=j.GetNtracks();
453 if (!ntk) return 0;
454
455 if (!fStrings) fStrings=new TArrayI(200);
456 fStrings->Reset();
457 Int_t idxmax=0;
458 Int_t nstrings=0;
459 Int_t jstring=0;
460 Int_t match=0;
461 Int_t nh=0;
462 for (Int_t itk=1; itk<=ntk; itk++)
463 {
464 NcTrack* tx=j.GetTrack(itk);
465 if (!tx) continue;
466
467 // Fetch all associated signals for this track
468 nh=tx->GetNsignals();
469 if (!nh) return 0;
470
471 // Check for the string ids of the associated good fired modules of the specified class
472 for (Int_t ih=1; ih<=nh; ih++)
473 {
474 NcSignal* sx=tx->GetSignal(ih);
475 if (!sx) continue;
476 NcDevice* dev=sx->GetDevice();
477 if (!dev) continue;
478 if (!(dev->InheritsFrom(classname.Data()))) continue;
479 IceGOM* omx=(IceGOM*)dev;
480
481 // Update the number of fired strings
482 jstring=omx->GetString();
483 match=0;
484 idxmax=nstrings;
485 for (Int_t idx=0; idx<idxmax; idx++)
486 {
487 if (jstring==fStrings->At(idx))
488 {
489 match=1;
490 break;
491 }
492 }
493 if (!match) // String number was not present in array
494 {
495 nstrings++;
496 fStrings->AddAt(jstring,nstrings-1);
497 }
498 } // End of loop over the track hits
499 } // End of loop over the tracks
500
501 return nstrings;
502}
503
504Int_t IceEvent::GetNmodules(NcTrack& t,TString classname)
505{
512
513 TObjArray* hits=t.GetSignals(classname,1);
514 if (!hits) return 0;
515
516 Int_t nmods=GetNdevices(classname.Data(),hits);
517 return nmods;
518}
519
520Int_t IceEvent::GetNmodules(NcJet& j,TString classname)
521{
528
529 TObjArray* hits=j.GetSignals(classname,1);
530 if (!hits) return 0;
531
532 Int_t nmods=GetNdevices(classname.Data(),hits);
533 return nmods;
534}
535
536Int_t IceEvent::GetStringMax(TString classname,Int_t* id,Float_t* x,Float_t* y)
537{
551
552 // Reset the values of the return arguments
553 if (id) *id=0;
554 if (x) *x=0;
555 if (y) *y=0;
556
557 // Fetch all fired modules of the specified class for this event
558 TObjArray* mods=GetDevices(classname);
559 if (!mods) return 0;
560 Int_t nmods=mods->GetEntries();
561 if (!nmods) return 0;
562
563 // Array for the string ids of the good fired modules
564 if (!fStrings) fStrings=new TArrayI(200);
565 fStrings->Reset();
566
567 Int_t ncount=0;
568 Int_t nmax=0;
569 Int_t idmax=0;
570 Float_t xmax=0;
571 Float_t ymax=0;
572 Float_t scale=0;
573 Int_t jstring=0;
574 for (Int_t imod=0; imod<nmods; imod++)
575 {
576 IceGOM* omx=(IceGOM*)mods->At(imod);
577 if (!omx) continue;
578 if (omx->GetDeadValue("ADC") || omx->GetDeadValue("LE") || omx->GetDeadValue("TOT")) continue;
579
580 // Update the count for the corresponding string
581 jstring=omx->GetString();
582 ncount=fStrings->At(jstring);
583 ncount++;
584 fStrings->AddAt(ncount,jstring);
585 if (ncount>nmax)
586 {
587 idmax=jstring;
588 scale=omx->GetUnitScale();
589 xmax=float(omx->GetX(1,"car"))*scale;
590 ymax=float(omx->GetX(2,"car"))*scale;
591 nmax=ncount;
592 fStrings->AddAt(nmax,0);
593 }
594 }
595
596 if (id) *id=idmax;
597 if (x) *x=xmax;
598 if (y) *y=ymax;
599
600 return nmax;
601}
602
603Float_t IceEvent::GetTriggerTime(TString trigname,TObjArray* arr,Int_t slc,TArrayF* peaks) const
604{
634
635 NcSample times;
636 times.SetStoreMode(1);
637 TString tname;
638 Float_t ttime=0;
639 NcSignal* sx=0;
640 IceGOM* omx=0;
641 TObjArray* oms=0;
642 TObjArray* hits=0;
643 Float_t time=0;
644 Float_t tfirst=999999;
645 Float_t tlast=-999999;
646 Float_t tlow=0;
647 Float_t tup=0;
648 Float_t dtbin=500; // Bin size in ns for peak search histo
649 Int_t nbins=0;
650
651 // Detect from inheritance whether "arr" contains optical modules or hits
652 if (arr)
653 {
654 TObject* obj=arr->At(0);
655 if (obj)
656 {
657 if (obj->InheritsFrom("IceGOM"))
658 {
659 oms=arr;
660 }
661 else
662 {
663 hits=arr;
664 }
665 }
666 }
667
668 if (!arr) // Trigger time derived from trigger data
669 {
670 NcDevice* tdev=(NcDevice*)GetDevice("Trigger");
671 if (!tdev) return 0;
672
673 if (trigname=="Average") // Take median triggertime
674 {
675 for (Int_t itrig=1; itrig<=tdev->GetNhits(); itrig++)
676 {
677 NcSignal* trig=tdev->GetHit(itrig);
678 ttime=0;
679 if (trig)
680 {
681 // Don't take the GLOBAL triggers into account.
682 // They are just there for administrative purposes.
683 tname=trig->GetName();
684 if (tname.Contains("GLOBAL")) continue;
685
686 ttime=trig->GetSignal("trig_pulse_le");
687 times.Enter(ttime);
688 }
689 }
690 ttime=times.GetMedian(1);
691 }
692 else // Take triggertime from the specified trigger
693 {
694 NcSignal* trig=tdev->GetHit(trigname);
695 if (trig) ttime=trig->GetSignal("trig_pulse_le");
696 }
697 }
698
699 if (oms) // Trigger time from array of optical modules via (median of) recorded hit times
700 {
701 for (Int_t iom=0; iom<oms->GetEntries(); iom++)
702 {
703 omx=(IceGOM*)oms->At(iom);
704 if (!omx) continue;
705 for (Int_t ih=1; ih<=omx->GetNhits(); ih++)
706 {
707 sx=omx->GetHit(ih);
708 if (!sx) continue;
709 if (sx->GetDeadValue("LE")) continue;
710
711 ttime=sx->GetSignal("LE",7);
712 if (ttime<tfirst) tfirst=ttime;
713 if (ttime>tlast) tlast=ttime;
714
715 if (!slc && sx->GetSignal("SLC")>0.5) continue;
716
717 times.Enter(ttime);
718 }
719 }
720 ttime=times.GetMedian(1);
721 }
722
723 if (hits) // Trigger time from array of hits via (median of) recorded hit times
724 {
725 for (Int_t ih=0; ih<hits->GetEntries(); ih++)
726 {
727 sx=(NcSignal*)hits->At(ih);
728 if (!sx) continue;
729 if (sx->GetDeadValue("LE")) continue;
730
731 ttime=sx->GetSignal("LE",7);
732 if (ttime<tfirst) tfirst=ttime;
733 if (ttime>tlast) tlast=ttime;
734
735 if (!slc && sx->GetSignal("SLC")>0.5) continue;
736
737 times.Enter(ttime);
738 }
739 ttime=times.GetMedian(1);
740 }
741
742 if (peaks)
743 {
744 peaks->Set(1);
745 peaks->AddAt(ttime,0);
746 }
747
748 Int_t ntimes=times.GetN();
749 if (peaks && tlast>tfirst && ntimes>1)
750 {
751 tlow=tfirst-dtbin;
752 tup=tlast+dtbin;
753 nbins=int((tup-tlow)/dtbin);
754 TH1F thist("thist","hit times",nbins,tlow,tup);
755 for (Int_t it=1; it<=ntimes; it++)
756 {
757 time=times.GetEntry(it,1);
758 thist.Fill(time);
759 }
760// Next line modified because of an incompatible change in ROOT6
761//@@@ TSpectrum spec;
762 NcSpectrum spec;
763 spec.SetDeconIterations(100);
764 Int_t oldlevel=gErrorIgnoreLevel;
765 gErrorIgnoreLevel=kFatal; // Suppress all (TSpectrum c.q. NcSpectrum) error and warning messages
766 Int_t npeaks=spec.Search(&thist,1,"goff",0.3);
767 gErrorIgnoreLevel=oldlevel; // Re-activate previous info level
768 if (npeaks)
769 {
770 peaks->Set(npeaks);
771 Float_t* specarr=spec.GetPositionX();
772 for (Int_t ip=0; ip<npeaks; ip++)
773 {
774 peaks->AddAt(specarr[ip],ip);
775 }
776 }
777 }
778
779 return ttime;
780}
781
782TObject* IceEvent::Clone(const char* name) const
783{
796
797 IceEvent* evt=new IceEvent(*this);
798 if (name)
799 {
800 if (strlen(name)) evt->SetName(name);
801 }
802 return evt;
803}
804
ClassImp(IceEvent)
Handling of IceCube event data.
Definition IceEvent.h:20
Int_t GetNmodules(NcTrack &t, TString classname)
Definition IceEvent.cxx:504
Float_t GetTriggerTime(TString trigname, TObjArray *arr=0, Int_t slc=0, TArrayF *peaks=0) const
Definition IceEvent.cxx:603
virtual TObject * Clone(const char *name="") const
Definition IceEvent.cxx:782
Int_t GetNstrings(TString classname)
Definition IceEvent.cxx:343
virtual void Reset()
Definition IceEvent.cxx:326
TArrayI * fStrings
! Temp. array to hold the string ids of fired modules
Definition IceEvent.h:36
virtual ~IceEvent()
Definition IceEvent.cxx:300
Int_t GetStringMax(TString classname, Int_t *id=0, Float_t *x=0, Float_t *y=0)
Definition IceEvent.cxx:536
Signal (Hit) handling of a generic IceCube Optical Module (GOM).
Definition IceGOM.h:12
Int_t GetString(Int_t id=0) const
Definition IceGOM.cxx:150
Double_t GetX(Int_t i, TString f, TString u="rad")
Int_t GetDeadValue(Int_t j=1) const
Signal (Hit) handling of a generic device.
Definition NcDevice.h:14
Int_t GetNhits() const
Definition NcDevice.cxx:437
NcSignal * GetHit(Int_t j) const
Definition NcDevice.cxx:489
virtual void Reset()
Definition NcEvent.cxx:436
Int_t GetNdevices() const
Definition NcEvent.cxx:1103
NcDevice * GetDevice(Int_t i) const
Definition NcEvent.cxx:1380
TObjArray * GetDevices(TString classname, TObjArray *devices=0)
Definition NcEvent.cxx:1656
Int_t GetNtracks(Int_t idmode=0, Int_t chmode=2, Int_t pcode=0)
Definition NcJet.cxx:564
NcTrack * GetTrack(Int_t i) const
Definition NcJet.cxx:751
NcJet()
Definition NcJet.cxx:121
TObjArray * GetSignals(TString classname, Int_t par=0, TObjArray *signals=0)
Definition NcJet.cxx:1897
Float_t GetUnitScale() const
Sampling and statistics tools for various multi-dimensional data samples.
Definition NcSample.h:28
Int_t GetN() const
Double_t GetMedian(Int_t i)
void Enter(Double_t x)
Definition NcSample.cxx:357
void SetStoreMode(Int_t mode=1, Int_t nmax=0, Int_t i=0)
Double_t GetEntry(Int_t i, Int_t j, Int_t mode=0, Int_t k=0)
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
Facilities for advanced spectral analysis.
Definition NcSpectrum.h:26
virtual Int_t Search(const TH1 *hist, Double_t sigma=2, Option_t *option="", Double_t threshold=0.05)
static void SetDeconIterations(Int_t n=3)
Float_t * GetPositionX() const
Definition NcSpectrum.h:66
Handling of the attributes of a reconstructed particle track.
Definition NcTrack.h:19
NcSignal * GetSignal(Int_t j) const
Definition NcTrack.cxx:1017
Int_t GetNsignals() const
Definition NcTrack.cxx:970
TObjArray * GetSignals(const char *classname, Int_t par=0, TObjArray *signals=0)
Definition NcTrack.cxx:1046