NCFS-Pack
A generic (astro)particle physics analysis framework
 
Loading...
Searching...
No Matches
IceRoot.cxx
Go to the documentation of this file.
1
17
19
88
89#include "IceRoot.h"
90#include "Riostream.h"
91
92ClassImp(IceRoot); // Class implementation to enable ROOT I/O
93
94IceRoot::IceRoot(const char* name,const char* title) : NcJob(name,title)
95{
102
103 fSplit=0;
104 fBsize=32000;
105 fMaxevt=-1;
106 fPrintfreq=1;
107 fInfiles=0;
108 fOutfile=0;
109 fCalfile=0;
110 fJEBTDaq=0;
111}
112
114{
120
121 if (fInfiles)
122 {
123 delete fInfiles;
124 fInfiles=0;
125 }
126
127 if (fCalfile)
128 {
129 delete fCalfile;
130 fCalfile=0;
131 }
132}
133
135{
143
144 fMaxevt=n;
145}
146
148{
155
156 if (f>=0) fPrintfreq=f;
157}
158
159void IceRoot::SetSplitLevel(Int_t split)
160{
167
168 if (split>=0) fSplit=split;
169}
170
171void IceRoot::SetBufferSize(Int_t bsize)
172{
179
180 if (bsize>=0) fBsize=bsize;
181}
182
183void IceRoot::SetInputFile(TString name)
184{
190
191 if (!fInfiles)
192 {
193 fInfiles=new TObjArray();
194 fInfiles->SetOwner();
195 }
196 fInfiles->Clear();
197
198 TObjString* s=new TObjString();
199 s->SetString(name);
200 fInfiles->Add(s);
201}
202
203void IceRoot::AddInputFile(TString name)
204{
210
211 if (!fInfiles)
212 {
213 fInfiles=new TObjArray();
214 fInfiles->SetOwner();
215 }
216
217 TObjString* s=new TObjString();
218 s->SetString(name);
219 fInfiles->Add(s);
220}
221
222void IceRoot::SetOutputFile(TFile* ofile)
223{
229
230 if (fOutfile) delete fOutfile;
231 fOutfile=ofile;
232}
233
234void IceRoot::SetOutputFile(TString name)
235{
241
242 if (fOutfile) delete fOutfile;
243 fOutfile=new TFile(name.Data(),"RECREATE","Simple Root data in IceEvent structure");
244}
245
247{
253
254 return fOutfile;
255}
256
257void IceRoot::SetCalibFile(TString name)
258{
266
267 if (fCalfile) delete fCalfile;
268 fCalfile=new TFile(name.Data());
269
270 if(fCalfile){
271 fJEBTDaq=(NcObjMatrix*)fCalfile->Get("JEBTDaq-OMDBASE");
272 }
273 if(!fJEBTDaq){
274 cout << "*IceRoot* Warning: no calibration available for TWR. TWR waveforms cannot be processed." << endl;
275 }
276
277}
278
280{
288
289 fJEBTDaq=omdb;
290 if(!fJEBTDaq){
291 cout << "*IceRoot* Warning: no calibration available for TWR. TWR waveforms cannot be processed." << endl;
292 }
293
294}
295
296void IceRoot::Exec(Option_t* opt)
297{
318
319 if (!fInfiles)
320 {
321 cout << " *IceRoot Exec* No data input file(s) specified." << endl;
322 return;
323 }
324
325 Int_t ninfiles=fInfiles->GetEntries();
326 if (!ninfiles)
327 {
328 cout << " *IceRoot Exec* No data input file(s) specified." << endl;
329 return;
330 }
331
332 // Warning in case no calibration DB is specified
333 if(!fJEBTDaq){
334 cout << "*IceRoot* Warning: no calibration available for TWR. TWR waveforms cannot be processed." << endl;
335 }
336
337 // Create output tree if necessary
338 TTree* otree=0;
339 if (fOutfile)
340 {
341 otree=new TTree("T","Simple Root data converted to IceEvent structures");
342 otree->SetDirectory(fOutfile);
343 }
344
345 // Create IceEvent structure
346 IceEvent* evt=new IceEvent();
347 evt->SetTrackCopy(1);
348 evt->SetDevCopy(1);
349
350 // Branch in the tree for the event structure
351 if (otree) otree->Branch("IceEvent","IceEvent",&evt,fBsize,fSplit);
352
353 // Initialise the job working environment
354 SetMainObject(evt);
355
356 // Some output for the user's convenience
357 TString inputfile;
358 cout << " ***" << endl;
359 cout << " *** Start processing of job " << GetName() << " ***" << endl;
360 cout << " ***" << endl;
361 for (Int_t i=0; i<ninfiles; i++)
362 {
363 TObjString* sx=(TObjString*)fInfiles->At(i);
364 if (!sx) continue;
365 inputfile=sx->GetString();
366 cout << " Simple Root data input file : " << inputfile.Data() << endl;
367 }
368 cout << " Maximum number of events to be processed : " << fMaxevt << endl;
369 cout << " Print frequency : " << fPrintfreq << endl;
370 if (fOutfile)
371 {
372 cout << " ROOT output file : " << fOutfile->GetName() << endl;
373 cout << " Output characteristics : splitlevel = " << fSplit << " buffersize = " << fBsize << endl;
374 }
375
377
378 // Set DAQ device info
379 NcDevice daq;
380 daq.SetNameTitle("Daq","Daq system used");
381
382 // Trigger device
383 NcDevice trig;
384 trig.SetNameTitle("Trigger","Amanda/IceCube event triggers");
385 NcSignal s;
386 Char_t trigname[100];
387
388 // MC info device
389 NcDevice mcinfo;
390 mcinfo.SetNameTitle("MCInfo","The MC production info");
391
392 // Variables in the simple ROOT tree
393 Int_t pretrig=0;
394 Int_t trignr=0;
395 Double_t* trigtime=0;
396 Double_t* triglength=0;
397 Char_t trigsourceID[100][100];
398 Char_t trigtypeID[100][100];
399 Char_t trigsubtypeID[100][100];
400 Double_t* mcweightitemvalue=0;
401 Char_t mcweightitemname[100][100];
402 Int_t eventtimemjd=0;
403 Int_t eventtimemjds=0;
404 Int_t eventtimemjdns=0;
405 Int_t eventid=0;
406 Int_t runid=0;
407 Int_t String=0;
408 Int_t OM=0;
409 Short_t waveformtype=0; // 1 = TWR, 2 = non-merged ATWD (not supported), 3 = InIce merged ATWD, 4 = InIce FADC, 5 = IceTop merged ATWD, 6 = IceTop FADC
410 Short_t twreventnr=0;
411 UInt_t baseline=0;
412 Int_t numberbinstwr=0;
413 Int_t startbin=0;
414 UInt_t* twrwaveform=0;
415 Int_t numberbinswaveform=0;
416 Double_t starttimewaveform=0;
417 Double_t binwidth=0;
418 Short_t source=0; // 0 = ATWD, 10 = FADC, 20 = TWR elec, 30 = TWR opt, 40 = etc
419 Double_t* waveform=0;
420 Int_t ntracks=0;
421 Double_t paraboloidsigmaA=999;
422 Double_t paraboloidsigmaI=999;
423 Double_t rloglA=999;
424 Double_t rloglI=999;
425 Double_t* trackx=0;
426 Double_t* tracky=0;
427 Double_t* trackz=0;
428 Double_t* trackzenith=0;
429 Double_t* trackazimuth=0;
430 Double_t* trackenergy=0;
431 Char_t tracktype[1000][100];
432
433 // Some other variables
434 Int_t nevt=0;
435 Int_t lastevent=0;
436 Int_t omid=0;
437 Double_t starttime=0;
438 Int_t extstop=0;
439 Float_t twrtime=10240; // Number of bins in TWR
440 Int_t twrbuffer=0;
441 TPRegexp suffix("_[0-9]+$"); // suffix appended to track name by Walnut
442
443 TString hname;
444 TH1F histo;
445 IceAOM aom;
446 IceIDOM idom;
447 IceTDOM tdom;
448 IceGOM* om=0;
449 IceGOM* calom=0;
450 NcTrack t;
451 Double_t vec[3];
452 NcPosition r;
453 Nc3Vector p;
454 NcSample sample;
455
456 Float_t pi=acos(-1.);
457
458 TFile* input=0;
459
460 Double_t* twreventtimes=0;
461 Int_t nrtwrevents=0;
462 Int_t* twreventorder=0;
463
464 // Get global TWR time offsets from DB
465 Float_t globalt0=0;
466 Float_t twri3offset=0;
467 if(fJEBTDaq){
468 for(Int_t row=1; row<=fJEBTDaq->GetMaxRow(); row++){
469 calom=(IceGOM*)fJEBTDaq->GetObject(row,1);
470 if(calom){
471 globalt0=calom->GetSignal("GLOBALT0");
472 twri3offset=calom->GetSignal("TWRI3OFFSET");
473 break;
474 }
475 }
476 }
477
478 for (Int_t ifile=0; ifile<ninfiles; ifile++)
479 {
480 TObjString* sx=(TObjString*)fInfiles->At(ifile);
481 if (!sx) continue;
482
483 inputfile=sx->GetString();
484 if (inputfile=="") continue;
485
486 // Open the simple Root data input file
487 input=TFile::Open(inputfile);
488
489 if (!input)
490 {
491 cout << " *IceRoot Exec* No input file found with name : " << inputfile.Data() << endl;
492 continue;
493 }
494
495 // Get simple Root tree
496 fTree=(TTree*)input->Get("T");
497
498 fTree->SetBranchAddress("pretrig",&pretrig);
499 fTree->SetBranchAddress("trignr",&trignr);
500 fTree->SetBranchAddress("eventtimemjd",&eventtimemjd);
501 fTree->SetBranchAddress("eventtimemjds",&eventtimemjds);
502 fTree->SetBranchAddress("eventtimemjdns",&eventtimemjdns);
503 fTree->SetBranchAddress("eventid",&eventid);
504 fTree->SetBranchAddress("runid",&runid);
505 fTree->SetBranchAddress("String",&String);
506 fTree->SetBranchAddress("OM",&OM);
507 fTree->SetBranchAddress("waveformtype",&waveformtype);
508 fTree->SetBranchAddress("twreventnr",&twreventnr);
509 fTree->SetBranchAddress("baseline",&baseline);
510 fTree->SetBranchAddress("numberbinstwr",&numberbinstwr);
511 fTree->SetBranchAddress("startbin",&startbin);
512 fTree->SetBranchAddress("numberbinswaveform",&numberbinswaveform);
513 fTree->SetBranchAddress("starttimewaveform",&starttimewaveform);
514 if(fTree->GetBranch("binwidth")) fTree->SetBranchAddress("binwidth",&binwidth);
515 fTree->SetBranchAddress("source",&source);
516 fTree->SetBranchAddress("ntracks",&ntracks);
517
518 Int_t ntrig=(Int_t)fTree->GetLeaf("trignr")->GetMaximum();
519 trigtime=new Double_t[ntrig+1];
520 fTree->SetBranchAddress("trigtime",trigtime);
521 triglength=new Double_t[ntrig+1];
522 fTree->SetBranchAddress("triglength",triglength);
523 fTree->SetBranchAddress("trigsourceID",trigsourceID);
524 fTree->SetBranchAddress("trigtypeID",trigtypeID);
525 fTree->SetBranchAddress("trigsubtypeID",trigsubtypeID);
526
527 Int_t nmcinfo=(Int_t)fTree->GetLeaf("Nmcinfo")->GetMaximum();
528 mcweightitemvalue=new Double_t[nmcinfo+1];
529 fTree->SetBranchAddress("mcweightitemvalue",mcweightitemvalue);
530 fTree->SetBranchAddress("mcweightitemname",mcweightitemname);
531
532 Int_t nmaxbinstwr=(Int_t)fTree->GetLeaf("numberbinstwr")->GetMaximum();
533 twrwaveform=new UInt_t[nmaxbinstwr+1];
534 fTree->SetBranchAddress("twrwaveform",twrwaveform);
535
536 Int_t nmaxbinswaveform=(Int_t)fTree->GetLeaf("numberbinswaveform")->GetMaximum();
537 waveform=new Double_t[nmaxbinswaveform+1];
538 fTree->SetBranchAddress("waveform",waveform);
539
540 fTree->SetBranchAddress("paraboloidsigmaA",&paraboloidsigmaA);
541 fTree->SetBranchAddress("paraboloidsigmaI",&paraboloidsigmaI);
542 fTree->SetBranchAddress("rloglA",&rloglA);
543 fTree->SetBranchAddress("rloglI",&rloglI);
544
545 Int_t nmaxtracks=(Int_t)fTree->GetLeaf("ntracks")->GetMaximum();
546 trackx=new Double_t[nmaxtracks];
547 tracky=new Double_t[nmaxtracks];
548 trackz=new Double_t[nmaxtracks];
549 trackzenith=new Double_t[nmaxtracks];
550 trackazimuth=new Double_t[nmaxtracks];
551 trackenergy=new Double_t[nmaxtracks];
552 fTree->SetBranchAddress("trackx",trackx);
553 fTree->SetBranchAddress("tracky",tracky);
554 fTree->SetBranchAddress("trackz",trackz);
555 fTree->SetBranchAddress("trackzenith",trackzenith);
556 fTree->SetBranchAddress("trackazimuth",trackazimuth);
557 fTree->SetBranchAddress("trackenergy",trackenergy);
558 fTree->SetBranchAddress("tracktype",tracktype);
559
560 // Prepare for loop over entries
561 lastevent=0;
562
563 // Loop over waveforms in input tree
564 for(Int_t ientry=0; ientry<fTree->GetEntries(); ientry++)
565 {
566 fTree->GetEntry(ientry);
567 // If new event
568 if(eventid!=lastevent)
569 {
570 // Write old event to tree (if it contains data)
571 if(evt->GetDevices("IceGOM"))
572 {
573 // Invoke all available sub-tasks (if any) and write event to tree
574 CleanTasks();
575 ExecuteTasks(opt);
576 if(otree) otree->Fill();
577 if (fPrintfreq) { if (!(nevt%fPrintfreq)) evt->HeaderData(); }
578 // Update event counter
579 nevt++;
580 if (fMaxevt>-1 && nevt>=fMaxevt)
581 {
582 evt->Reset();
583 break;
584 }
585 }
586
587 // Start new event
588 evt->Reset();
589 evt->SetRunNumber(runid);
590 evt->SetEventNumber(eventid);
591 evt->SetMJD(eventtimemjd,eventtimemjds,eventtimemjdns,0);
592
593 // Daq: JEB for 2007 and later, TWR for 2006 and earlier
594 daq.Reset(1);
595 if(evt->GetDate()/10000 >= 2007){
596 daq.AddNamedSlot("JEB");
597 daq.SetSignal(1,"JEB");
598 }
599 else {
600 daq.AddNamedSlot("TWR");
601 daq.SetSignal(1,"TWR");
602 }
603 evt->AddDevice(daq);
604
605 // Loop over all the tracks and add them to the current event
606 Int_t nrecotracks=0;
607 Int_t nmctracks=0;
608 for (Int_t itrack=0; itrack<ntracks; itrack++)
609 {
610 t.Reset();
611
612 TString tracktypestring(tracktype[itrack]);
613 // Monte Carlo track
614 if(tracktypestring.Index("MC")>=0 || tracktypestring.Index("nu_mu")>=0){
615 nmctracks++;
616 t.SetId(-nmctracks);
617 }
618 // Reco track
619 if(tracktypestring.Index("MC")<0 && tracktypestring.Index("nu_mu")<0){
620 nrecotracks++;
621 t.SetId(nrecotracks);
622 }
623 // Track ID and name
624 Int_t suffixpos=tracktypestring.Index(suffix);
625 if(suffixpos>0){
626 tracktypestring.Remove(suffixpos,tracktypestring.Length()-suffixpos);
627 }
628 t.SetName(tracktypestring);
629 t.SetTitle(tracktypestring);
630
631 // Beginpoint of the track
632 vec[0]=trackx[itrack];
633 vec[1]=tracky[itrack];
634 vec[2]=trackz[itrack];
635 r.SetPosition(vec,"car");
636 t.SetBeginPoint(r);
637
638 // Momentum in GeV/c
639 vec[0]=trackenergy[itrack];
640 if(vec[0]==0 || vec[0]!=vec[0]) vec[0]=1; // Energy unknown: set default value of 1 GeV
641 vec[1]=pi-trackzenith[itrack];
642 vec[2]=trackazimuth[itrack]+pi;
643 if(vec[2]>=2*pi) vec[2]-=2*pi;
644 p.SetVector(vec,"sph");
645 t.Set3Momentum(p);
646
647 if(tracktypestring.Index("paraboloidA")>=0){
648 t.SetCharge(paraboloidsigmaA);
649 }else if(tracktypestring.Index("paraboloidI")>=0){
650 t.SetCharge(paraboloidsigmaI);
651 }
652 if(tracktypestring.Index("gulliverA")>=0){
653 t.SetCharge(rloglA);
654 }else if(tracktypestring.Index("gulliverI")>=0){
655 t.SetCharge(rloglI);
656 }
657
658 // Check for unreconstructed tracks (NaN values) and reset track if necessary
659 if(trackx[itrack]!=trackx[itrack] || tracky[itrack]!=tracky[itrack] || trackz[itrack]!=trackz[itrack] ||
660 trackzenith[itrack]!=trackzenith[itrack] || trackazimuth[itrack]!=trackazimuth[itrack]){
661 t.Reset();
662 } else {
663 // Add track to event
664 evt->AddTrack(t);
665 }
666 }
667
668 // Store trigger information
669 if (twreventtimes) delete[] twreventtimes;
670 twreventtimes=new Double_t[trignr];
671 if (twreventorder) delete[] twreventorder;
672 twreventorder=new Int_t[trignr];
673 nrtwrevents=0;
674 trig.Reset(1);
675 // Loop over triggers
676 for(Int_t itr=0; itr<trignr; itr++){
677 // For TWR events:
678 if(TString(trigsourceID[itr])=="AMANDA_TWR_DAQ"){
679 // Add global time offset if there are no MC tracks (i.e. if the data are real data)
680 if(!nmctracks) trigtime[itr]-=globalt0+twri3offset;
681 // Check if this trigger belongs to a new event
682 Int_t newevent=1;
683 for(Int_t itwrevent=0; itwrevent<nrtwrevents; itwrevent++){
684 if(fabs(trigtime[itr]-twreventtimes[itwrevent])<1500){
685 newevent=0;
686 break;
687 }
688 }
689 // Add new TWR event time
690 if(newevent){
691 twreventtimes[nrtwrevents]=trigtime[itr];
692 nrtwrevents++;
693 }
694 }
695
696 // Add this trigger to trigger device
697 s.Reset(1);
698 sprintf(trigname,"%s/%s",trigsourceID[itr],trigtypeID[itr]);
699 s.SetName(trigname);
700 s.SetSlotName("trig_pulse_le",1);
701 s.SetSignal(trigtime[itr],1);
702 s.SetSlotName("trig_pulse_tot",2);
703 s.SetSignal(triglength[itr],2);
704 trig.AddHit(s);
705 } // End of loop over triggers
706
707 TMath::Sort(nrtwrevents,twreventtimes,twreventorder,0);
708
709 // Add main trigger unless it is already present
710 // TODO: select most appropriate trigger as artificial "main"
711 // For now: select first trigger in event
712 if(!trig.GetHit("main")){
713 s.Reset(1);
714 s.SetName("main");
715 s.SetSlotName("trig_pulse_le",1);
716 s.SetSignal(trigtime[0],1);
717 s.SetSlotName("trig_pulse_tot",2);
718 s.SetSignal(triglength[0],2);
719 trig.AddHit(s);
720 }
721 evt->AddDevice(trig);
722
723 //Going to store the MCInfo in the device in case there is any
724 if(nmcinfo>0){
725 mcinfo.Reset(1);
726 for(Int_t imcinfo=0; imcinfo<nmcinfo; imcinfo++){
727 TString mcweightitemnamestring(mcweightitemname[imcinfo]);
728 mcinfo.AddNamedSlot(mcweightitemname[imcinfo]);
729 mcinfo.SetSignal(mcweightitemvalue[imcinfo], mcweightitemname[imcinfo]);
730 if(mcweightitemnamestring.Index("OneWeight")>=0) evt->SetWeight(mcweightitemvalue[imcinfo]);
731 }
732 evt->AddDevice(mcinfo);
733 }
734
735 // Remember event nr
736 lastevent=eventid;
737 }
738
739 if(waveformtype==1){
740 // Amanda module
741 omid=aom.GetOMId(String,OM);
742 if(omid==681) continue; // Skip OM 681, which should never give data: avoid all risk of confusion
743 om=(IceGOM*)evt->GetIdDevice(omid);
744 if (!om)
745 {
746 aom.Reset(1);
747 aom.SetUniqueID(omid);
748 evt->AddDevice(aom);
749 om=(IceGOM*)evt->GetIdDevice(omid);
750 }
751 if (!om) continue;
752 }
753
754 else if(waveformtype==2) {
755 // Non-merged waveforms not supported
756 cout << "IceRoot::Exec: Non-merged ATWD waveforms not supported in this module." << endl;
757 continue;
758 }
759
760 else if(waveformtype==3 || waveformtype==4) {
761 // InIce module
762 omid=idom.GetOMId(String,OM);
763 om=(IceGOM*)evt->GetIdDevice(omid);
764 if (!om)
765 {
766 idom.Reset(1);
767 idom.SetUniqueID(omid);
768 evt->AddDevice(idom);
769 om=(IceGOM*)evt->GetIdDevice(omid);
770 }
771 if (!om) continue;
772 }
773
774 else if(waveformtype==5 || waveformtype==6) {
775 // IceTop module
776 omid=tdom.GetOMId(String,OM);
777 om=(IceGOM*)evt->GetIdDevice(omid);
778 if (!om)
779 {
780 tdom.Reset(1);
781 tdom.SetUniqueID(omid);
782 evt->AddDevice(tdom);
783 om=(IceGOM*)evt->GetIdDevice(omid);
784 }
785 if (!om) continue;
786 }
787
788 else {
789 cout << "IceRoot::Exec: Unknown waveform type " << waveformtype << endl;
790 continue;
791 }
792
793 // Fill the waveform histogram with this fragment
794 // TWR waveform
795 if(waveformtype==1){
796 if(numberbinstwr>0 && twreventnr<nrtwrevents){
797 histo.Reset();
798 // Store baseline info
799 hname="BASELINE-WF";
800 hname+=om->GetNwaveforms()+1;
801 om->AddNamedSlot(hname);
802 om->SetSignal(baseline,hname);
803 // Waveform name
804 hname="OM";
805 hname+=omid;
806 hname+="-WF";
807 hname+=om->GetNwaveforms()+1;
808 hname+="-TWR";
809 histo.SetName(hname.Data());
810 // Add waveform
811 calom=0;
812 if(fJEBTDaq) calom=(IceGOM*)fJEBTDaq->GetObject(omid,1);
813 if(!calom){
814 cout << "IceRoot: No calibration info for OM " << omid << ", skipping this waveform" << endl;
815 continue;
816 }
817 binwidth=calom->GetSignal("BINSIZE");
818 if(binwidth<=0){
819 cout << "IceRoot: Zero bin width for OM " << omid << ", skipping this waveform" << endl;
820 continue;
821 }
822 twrbuffer=(Int_t)(twrtime/binwidth);
823 extstop=(Int_t)calom->GetSignal("EXTSTOP");
824 starttime=twreventtimes[twreventorder[twreventnr]]+binwidth*(startbin-twrbuffer+extstop);
825 histo.SetBins(numberbinstwr,starttime,starttime+numberbinstwr*binwidth);
826 for (Int_t jbin=1; jbin<=numberbinstwr; jbin++)
827 {
828 histo.SetBinContent(jbin,(Float_t)baseline-(Float_t)twrwaveform[jbin-1]);
829 }
830 om->SetWaveform(&histo,om->GetNwaveforms()+1);
831 } else {
832 cout << "IceRoot::Exec: waveformtype=1, but numberbinstwr=0 or nrtwrevents=0." << endl;
833 }
834 }
835
836 // Separate waveforms from DOM launch
837 else if(waveformtype==2){
838 // Non-merged waveforms not supported
839 cout << "IceRoot::Exec: Non-merged ATWD waveform found. You should never get to here anyway." << endl;
840 continue;
841 }
842
843 // Merged ATWD waveform
844 else if(waveformtype==3 || waveformtype==5){
845 if(numberbinswaveform>0){
846 histo.Reset();
847 hname="OM";
848 hname+=omid;
849 hname+="-WF";
850 hname+=om->GetNwaveforms()+1;
851 hname+="-ATWD";
852 histo.SetName(hname.Data());
853 starttime=starttimewaveform;
854 histo.SetBins(numberbinswaveform,starttime,starttime+numberbinswaveform*binwidth);
855 sample.Reset();
856 for (Int_t jbin=1; jbin<=numberbinswaveform; jbin++)
857 {
858 histo.SetBinContent(jbin,waveform[jbin-1]);
859 }
860 hname="BASELINE-WF";
861 hname+=om->GetNwaveforms()+1;
862 om->AddNamedSlot(hname);
863 om->SetSignal(sample.GetMedian(&histo,2),hname);
864 om->SetSignalError(sample.GetSpread(&histo,2),hname);
865 om->SetWaveform(&histo,om->GetNwaveforms()+1);
866 } else {
867 cout << "IceRoot::Exec: waveformtype=" << waveformtype << ", but numberbinswaveform=0." << endl;
868 }
869 }
870
871 // FADC waveform
872 else if(waveformtype==4 || waveformtype==6){
873 if(numberbinswaveform>0){
874 histo.Reset();
875 hname="OM";
876 hname+=omid;
877 hname+="-WF";
878 hname+=om->GetNwaveforms()+1;
879 hname+="-FADC";
880 histo.SetName(hname.Data());
881 starttime=starttimewaveform;
882 histo.SetBins(numberbinswaveform,starttime,starttime+numberbinswaveform*binwidth);
883 for (Int_t jbin=1; jbin<=numberbinswaveform; jbin++)
884 {
885 histo.SetBinContent(jbin,waveform[jbin-1]);
886 }
887 om->SetWaveform(&histo,om->GetNwaveforms()+1);
888 } else {
889 cout << "IceRoot::Exec: waveformtype=" << waveformtype << ", but numberbinswaveform=0." << endl;
890 }
891 }
892
893 // Unknown waveform type
894 else {
895 cout << "IceRoot::Exec: Unknown waveform type " << waveformtype << endl;
896 continue;
897 }
898
899 } // End of loop over waveforms in input tree
900
901 // Write last event to tree
902 if(evt->GetDevices("IceGOM"))
903 {
904 CleanTasks();
905 ExecuteTasks(opt);
906 if (otree) otree->Fill();
907 if (fPrintfreq) { if (!(nevt%fPrintfreq)) evt->HeaderData(); }
908 // Update event counter
909 nevt++;
910 }
911
912 // Reset event
913 evt->Reset();
914
915 // Close input file
916 input->Close();
917
918 // Clean up
919 if (trigtime) delete[] trigtime;
920 if (triglength) delete[] triglength;
921 if (mcweightitemvalue) delete[] mcweightitemvalue;
922 if (twrwaveform) delete[] twrwaveform;
923 if (waveform) delete[] waveform;
924 if (trackx) delete[] trackx;
925 if (tracky) delete[] tracky;
926 if (trackz) delete[] trackz;
927 if (trackzenith) delete[] trackzenith;
928 if (trackazimuth) delete[] trackazimuth;
929 if (trackenergy) delete[] trackenergy;
930 if (twreventtimes)
931 {
932 delete[] twreventtimes;
933 twreventtimes=0;
934 }
935 if (twreventorder)
936 {
937 delete[] twreventorder;
938 twreventorder=0;
939 }
940
941 // Stop looping over input files if max. nr. of events is reached
942 if (fMaxevt>-1 && nevt>=fMaxevt)
943 {
944 break;
945 }
946
947 } // End of input file loop
948
949 // Flush possible memory resident data to the output file
950 if (fOutfile) fOutfile->Write();
951
952 // Remove the IceEvent object from the environment
953 // and delete it as well
954 if (evt)
955 {
956 RemoveObject(evt);
957 delete evt;
958 }
959}
960
ClassImp(IceRoot)
Signal (Hit) handling of a generic Amanda Optical Module (AOM).
Definition IceAOM.h:12
Handling of IceCube event data.
Definition IceEvent.h:20
virtual void Reset()
Definition IceEvent.cxx:326
Signal (Hit) handling of a generic IceCube Optical Module (GOM).
Definition IceGOM.h:12
Int_t GetOMId(Int_t string, Int_t level) const
Definition IceGOM.cxx:266
Signal (Hit) handling of a generic IceCube In-ice Digital Optical Module (IDOM).
Definition IceIDOM.h:12
Job for conversion of simple Root data into IceEvent data structures.
Definition IceRoot.h:29
void SetOMdbase(NcObjMatrix *omdb)
Definition IceRoot.cxx:279
Int_t fPrintfreq
Definition IceRoot.h:50
void SetOutputFile(TFile *ofile)
Definition IceRoot.cxx:222
TFile * GetOutputFile()
Definition IceRoot.cxx:246
TFile * fOutfile
Definition IceRoot.h:52
void SetBufferSize(Int_t bsize)
Definition IceRoot.cxx:171
void SetCalibFile(TString name)
Definition IceRoot.cxx:257
Int_t fSplit
Definition IceRoot.h:47
virtual ~IceRoot()
Definition IceRoot.cxx:113
IceRoot(const char *name="IceRoot", const char *title="")
Definition IceRoot.cxx:94
Int_t fMaxevt
Definition IceRoot.h:49
void AddInputFile(TString name)
Definition IceRoot.cxx:203
TTree * fTree
Definition IceRoot.h:55
Int_t fBsize
Definition IceRoot.h:48
void SetPrintFreq(Int_t f)
Definition IceRoot.cxx:147
virtual void Exec(Option_t *opt)
Definition IceRoot.cxx:296
NcObjMatrix * fJEBTDaq
Definition IceRoot.h:54
void SetMaxEvents(Int_t n)
Definition IceRoot.cxx:134
void SetSplitLevel(Int_t split)
Definition IceRoot.cxx:159
void SetInputFile(TString name)
Definition IceRoot.cxx:183
TFile * fCalfile
Definition IceRoot.h:53
TObjArray * fInfiles
Definition IceRoot.h:51
Signal (Hit) handling of an IceTop Digital Optical Module (TDOM).
Definition IceTDOM.h:12
Handling of 3-vectors in various reference frames.
Definition Nc3Vector.h:15
void SetVector(Double_t *v, TString f, TString u="rad")
void AddNamedSlot(TString s)
void SetSlotName(TString s, Int_t j=1)
Signal (Hit) handling of a generic device.
Definition NcDevice.h:14
void AddHit(NcSignal &s)
Definition NcDevice.cxx:336
NcSignal * GetHit(Int_t j) const
Definition NcDevice.cxx:489
virtual void Reset(Int_t mode=0)
Definition NcDevice.cxx:222
NcDevice * GetIdDevice(Int_t id, TObjArray *devs=0) const
Definition NcEvent.cxx:1451
void AddDevice(NcDevice &d)
Definition NcEvent.cxx:1210
void SetEventNumber(Int_t evt)
Definition NcEvent.cxx:573
virtual void HeaderData()
Definition NcEvent.cxx:996
void SetDevCopy(Int_t j)
Definition NcEvent.cxx:1313
void SetWeight(Double_t weight)
Definition NcEvent.cxx:584
TObjArray * GetDevices(TString classname, TObjArray *devices=0)
Definition NcEvent.cxx:1656
void SetRunNumber(Int_t run)
Definition NcEvent.cxx:562
void SetTrackCopy(Int_t j)
Definition NcJet.cxx:1413
void AddTrack(NcTrack &t)
Definition NcJet.cxx:313
void SetMainObject(TObject *obj)
Definition NcJob.cxx:305
void RemoveObject(TObject *obj)
Definition NcJob.cxx:384
NcJob(const char *name="NcJob", const char *title="")
Definition NcJob.cxx:139
void ListEnvironment()
Definition NcJob.cxx:205
Handling of a matrix structure of objects.
Definition NcObjMatrix.h:13
Handling of positions (with timestamps) in various reference frames.
Definition NcPosition.h:18
void SetPosition(Double_t *r, TString f, TString u="rad")
Sampling and statistics tools for various multi-dimensional data samples.
Definition NcSample.h:28
Double_t GetMedian(Int_t i)
void Reset()
Definition NcSample.cxx:255
Double_t GetSpread(Int_t i, Int_t model=0, Double_t vref=0)
Generic handling of (extrapolated) detector signals.
Definition NcSignal.h:23
Int_t GetNwaveforms() const
virtual void Reset(Int_t mode=0)
Definition NcSignal.cxx:334
virtual void SetSignal(Double_t sig, Int_t j=1)
Definition NcSignal.cxx:516
void SetWaveform(TH1F *waveform, Int_t j=1)
virtual Float_t GetSignal(Int_t j=1, Int_t mode=0) const
Definition NcSignal.cxx:651
virtual void SetSignalError(Double_t dsig, Int_t j=1)
Definition NcSignal.cxx:845
void SetMJD(Int_t mjd, Int_t sec, Int_t ns, Int_t ps=0, TString utc="U", Int_t leap=0, Double_t dut=0)
Handling of the attributes of a reconstructed particle track.
Definition NcTrack.h:19
void SetCharge(Float_t q)
Definition NcTrack.cxx:444
void SetBeginPoint(NcPosition &p)
Definition NcTrack.cxx:1423
void Set3Momentum(Nc3Vector &p)
Definition NcTrack.cxx:401
virtual void Reset()
Definition NcTrack.cxx:321
void SetId(Int_t id)
Definition NcTrack.cxx:1772