NCFS-Pack
A generic (astro)particle physics analysis framework
 
Loading...
Searching...
No Matches
IceF2k.cxx
Go to the documentation of this file.
1
17
19
147
148#include "IceF2k.h"
149#include "Riostream.h"
150
151ClassImp(IceF2k); // Class implementation to enable ROOT I/O
152
153IceF2k::IceF2k(const char* name,const char* title) : NcJob(name,title)
154{
161
162 fSplit=0;
163 fBsize=32000;
164 fMaxevt=-1;
165 fPrintfreq=1;
166 fInfiles=0;
167 fOutfile=0;
168
169 fPdg=0;
170 fOmdb=0;
171 fFitdefs=0;
172 fTrigdefs=0;
173 fToffset=0;
174 fMctoffset=0;
175 fMctracks=3;
176 fCompTWR=0;
177}
178
180{
186
187 if (fInfiles)
188 {
189 delete fInfiles;
190 fInfiles=0;
191 }
192
193 if (fPdg)
194 {
195 delete fPdg;
196 fPdg=0;
197 }
198
199 if (fOmdb)
200 {
201 delete fOmdb;
202 fOmdb=0;
203 }
204
205 if (fFitdefs)
206 {
207 delete fFitdefs;
208 fFitdefs=0;
209 }
210
211 if (fTrigdefs)
212 {
213 delete fTrigdefs;
214 fTrigdefs=0;
215 }
216}
217
219{
227
228 fMaxevt=n;
229}
230
232{
239
240 if (f>=0) fPrintfreq=f;
241}
242
243void IceF2k::SetSplitLevel(Int_t split)
244{
251
252 if (split>=0) fSplit=split;
253}
254
255void IceF2k::SetBufferSize(Int_t bsize)
256{
263
264 if (bsize>=0) fBsize=bsize;
265}
266
267void IceF2k::SetMcToffset(Float_t toffset)
268{
276
277 fMctoffset=toffset;
278}
279
281{
294
295 if (mode<0 || mode >3) return;
296 fMctracks=mode;
297}
298
300{
311
312 if (mode<0 || mode >1) return;
313 fCompTWR=mode;
314}
315
316void IceF2k::SetInputFile(TString name)
317{
329
330 if (fInfiles) delete fInfiles;
331
332 fInfiles=new TObjArray();
333 fInfiles->SetOwner();
334
335 TObjString* s=new TObjString();
336 s->SetString(name);
337 fInfiles->Add(s);
338}
339
340void IceF2k::AddInputFile(TString name)
341{
347
348 if (!fInfiles)
349 {
350 fInfiles=new TObjArray();
351 fInfiles->SetOwner();
352 }
353
354 TObjString* s=new TObjString();
355 s->SetString(name);
356 fInfiles->Add(s);
357}
358
359void IceF2k::SetOutputFile(TFile* ofile)
360{
366
367 if (fOutfile) delete fOutfile;
368 fOutfile=ofile;
369}
370
371void IceF2k::SetOutputFile(TString name)
372{
378
379 if (fOutfile) delete fOutfile;
380 fOutfile=new TFile(name.Data(),"RECREATE","F2K data in IceEvent structure");
381}
382
384{
390
391 return fOutfile;
392}
393
394TDatabasePDG* IceF2k::GetPDG()
395{
401
402 return fPdg;
403}
404
406{
412
413 return fOmdb;
414}
415
417{
423
424 return fFitdefs;
425}
426
428{
434
435 return fTrigdefs;
436}
437
438void IceF2k::Exec(Option_t* opt)
439{
460
461 if (!fInfiles)
462 {
463 cout << " *IceF2k Exec* No data input file(s) specified." << endl;
464 return;
465 }
466
467 Int_t ninfiles=fInfiles->GetEntries();
468 if (!ninfiles)
469 {
470 cout << " *IceF2k Exec* No data input file(s) specified." << endl;
471 return;
472 }
473
474 TTree* otree=0;
475 if (fOutfile)
476 {
477 otree=new TTree("T","F2K Data converted to IceEvent structures");
478 otree->SetDirectory(fOutfile);
479 }
480
481 IceEvent* evt=new IceEvent();
482 evt->SetTrackCopy(1);
483 evt->SetDevCopy(1);
484
485 // Branch in the tree for the event structure
486 if (otree) otree->Branch("IceEvent","IceEvent",&evt,fBsize,fSplit);
487
488 // Create the particle database and extend it with some F2000 specific definitions
489 if (!fPdg) fPdg=new TDatabasePDG();
490 Double_t me=fPdg->GetParticle(11)->Mass();
491 fPdg->AddParticle("brems" ,"brems" ,0,1,0,0,"none",10001001,0,0);
492 fPdg->AddParticle("deltae" ,"deltae" ,me,1,0,-3,"Lepton",10001002,0,0);
493 fPdg->AddParticle("pairprod","pairprod",0,1,0,0,"none",10001003,0,0);
494 fPdg->AddParticle("nucl_int","nucl_Int",0,1,0,0,"none",10001004,0,0);
495 fPdg->AddParticle("mu_pair" ,"mu_pair" ,0,1,0,0,"none",10001005,0,0);
496 fPdg->AddParticle("hadrons" ,"hadrons" ,0,1,0,0,"none",10001006,0,0);
497 fPdg->AddParticle("fiberlaser","fiberlaser",0,1,0,0,"none",10002100,0,0);
498 fPdg->AddParticle("n2laser" ,"n2laser" ,0,1,0,0,"none",10002101,0,0);
499 fPdg->AddParticle("yaglaser" ,"yaglaser" ,0,1,0,0,"none",10002201,0,0);
500 fPdg->AddParticle("z_primary","z_primary",0,1,0,0,"none",10003000,0,0);
501 fPdg->AddParticle("a_primary","a_primary",0,1,0,0,"none",10003500,0,0);
502
503 // Storage of the used parameters in the IceF2k device
504 NcDevice params;
505 params.SetNameTitle("IceF2k","IceF2k processor parameters");
506 params.SetSlotName("Toffset",1);
507 params.SetSlotName("Mctoffset",2);
508 params.SetSlotName("Mctracks",3);
509
510 // Initialise the job working environment
511 SetMainObject(evt);
512 if (fOutfile)
513 {
515 AddObject(otree);
516 }
517
518 TString inputfile;
519
520 cout << " ***" << endl;
521 cout << " *** Start processing of job " << GetName() << " ***" << endl;
522 cout << " ***" << endl;
523 for (Int_t i=0; i<ninfiles; i++)
524 {
525 TObjString* sx=(TObjString*)fInfiles->At(i);
526 if (!sx) continue;
527 inputfile=sx->GetString();
528 cout << " F2K input file : " << inputfile.Data() << endl;
529 }
530 cout << " Maximum number of events to be processed : " << fMaxevt << endl;
531 cout << " Print frequency : " << fPrintfreq << endl;
532 if (fOutfile)
533 {
534 cout << " ROOT output file : " << fOutfile->GetName() << endl;
535 cout << " Output characteristics : splitlevel = " << fSplit << " buffersize = " << fBsize << endl;
536 }
537 cout << " TWR input compression level : " << fCompTWR << endl;
538
540
541 // Set DAQ device info
542 NcDevice daq;
543 daq.SetName("Daq");
544 daq.SetSlotName("Muon",1);
545 daq.SetSignal(1,1);
546
547 Int_t nevt=0;
548 Int_t evtsel=0;
549 for (Int_t ifile=0; ifile<ninfiles; ifile++)
550 {
551 TObjString* sx=(TObjString*)fInfiles->At(ifile);
552 if (!sx) continue;
553
554 inputfile=sx->GetString();
555 if (inputfile=="") continue;
556
557 // Open the input file in the default ascii format (autodetection) for reading
558 fInput=rdmc_mcopen(inputfile.Data(),"r",RDMC_DEFAULT_ASCII_F);
559
560 if (!fInput)
561 {
562 cout << " *IceF2k Exec* No input file found with name : " << inputfile.Data() << endl;
563 continue;
564 }
565
566 // Initialise the event structure
567 rdmc_init_mevt(&fEvent);
568
569 // Read the file header information
570 rdmc_rarr(fInput,&fHeader);
571
572 // Fill the database with geometry, calib. etc... parameters
573 // for all the devices
574 FillOMdbase();
575
576 // Set the fit definitions according to the F2000 header info
577 SetFitdefs();
578
579 // Set the trigger definitions according to the F2000 header info
580 SetTrigdefs();
581
582 while (!rdmc_revt(fInput,&fHeader,&fEvent))
583 {
584 if (fMaxevt>-1 && nevt>=fMaxevt) break;
585
586 // Reset the complete Event structure
587 evt->Reset();
588
589 evt->SetRunNumber(fEvent.nrun);
590 evt->SetEventNumber(fEvent.enr);
591 evt->SetMJD(fEvent.mjd,fEvent.secs,fEvent.nsecs);
592
593 evt->AddDevice(daq);
594
595 // Take trigger offset into account which might have been
596 // introduced during the filtering process.
597 // For simulated data this will be treated separately in PutMcTracks().
598 fToffset=fEvent.t_offset;
599
600 PutTrigger();
601
602 PutMcTracks();
603
605
606 PutHits();
607
608 // Enter the IceF2k processor parameters into the event structure
609 params.SetSignal(fToffset,1);
610 params.SetSignal(fMctoffset,2);
611 params.SetSignal(fMctracks,3);
612 evt->AddDevice(params);
613
614 // Invoke all available sub-tasks (if any)
615 CleanTasks();
616 ExecuteTasks(opt);
617
618 if (fPrintfreq)
619 {
620 if (!(nevt%fPrintfreq)) evt->HeaderData();
621 }
622
623 // Write the complete structure to the output Tree for accepted events
624 evtsel=1;
625 NcDevice* seldev=(NcDevice*)evt->GetDevice("NcEventSelector");
626 if (seldev)
627 {
628 if (seldev->GetSignal("Select") < 0.1) evtsel=-1;
629 }
630 if (otree && evtsel==1) otree->Fill();
631
632 // Update event counter
633 nevt++;
634 }
635 if (fMaxevt>-1 && nevt>=fMaxevt) break;
636 }
637
638 // Flush possible memory resident data to the output file
639 if (fOutfile) fOutfile->Write();
640
641 // Remove the IceEvent object from the environment
642 // and delete it as well
643 if (evt)
644 {
645 RemoveObject(evt);
646 delete evt;
647 }
648}
649
651{
658
659 if (fHeader.nch<=0)
660 {
661 if (fOmdb)
662 {
663 delete fOmdb;
664 fOmdb=0;
665 }
666 return;
667 }
668
669 Int_t adccal=fHeader.is_calib.adc;
670 Int_t tdccal=fHeader.is_calib.tdc;
671 Int_t totcal=fHeader.is_calib.tot;
672
673 TF1 fadccal("fadccal","(x-[1])*[0]");
674 TF1 fadcdecal("fadcdecal","(x/[0])+[1]");
675 fadccal.SetParName(0,"BETA-ADC");
676 fadccal.SetParName(1,"PED-ADC");
677 fadcdecal.SetParName(0,"BETA-ADC");
678 fadcdecal.SetParName(1,"PED-ADC");
679
680 TF1 ftdccal("ftdccal","(x*[0])-[1]-([0]-1.)*32767.-[2]/sqrt([3])");
681 TF1 ftdcdecal("ftdcdecal","(x+([0]-1.)*32767.+[1]+[2]/sqrt([3]))/[0]");
682 ftdccal.SetParName(0,"BETA-TDC");
683 ftdccal.SetParName(1,"T0");
684 ftdccal.SetParName(2,"ALPHA-TDC");
685 ftdccal.SetParName(3,"ADC-SLEW");
686 ftdcdecal.SetParName(0,"BETA-TDC");
687 ftdcdecal.SetParName(1,"T0");
688 ftdcdecal.SetParName(2,"ALPHA-TDC");
689 ftdcdecal.SetParName(3,"ADC-SLEW");
690
691 TF1 ftotcal("ftotcal","x*[0]");
692 TF1 ftotdecal("ftotdecal","x/[0]");
693 ftotcal.SetParName(0,"BETA-TOT");
694 ftotdecal.SetParName(0,"BETA-TOT");
695
696 if (fOmdb)
697 {
698 fOmdb->Reset();
699 }
700 else
701 {
702 fOmdb=new NcObjMatrix();
703 fOmdb->SetNameTitle("OMDBASE","The OM geometry, calib. etc... database");
704 fOmdb->SetOwner();
705 }
706
707 IceAOM* dev=0;
708 Double_t pos[3]={0,0,0};
709 for (Int_t i=0; i<fHeader.nch; i++)
710 {
711 dev=new IceAOM();
712 dev->SetUniqueID(i+1);
713 // Slots to hold the various (de)calibration functions
714 dev->SetSlotName("ADC",1);
715 dev->SetSlotName("LE",2);
716 dev->SetSlotName("TOT",3);
717 // Slots to hold hardware parameters
718 dev->SetSlotName("TYPE",4);
719 dev->SetSlotName("ORIENT",5);
720 dev->SetSlotName("THRESH",6);
721 dev->SetSlotName("SENSIT",7);
722 dev->SetSlotName("READOUT",8); // 0=unknown 1=electrical 2=optical 3=digital
723
724 pos[0]=fHeader.x[i];
725 pos[1]=fHeader.y[i];
726 pos[2]=fHeader.z[i];
727 dev->SetPosition(pos,"car");
728
729 fadccal.SetParameter(0,fHeader.cal[i].beta_a);
730 fadccal.SetParameter(1,fHeader.cal[i].ped);
731 fadcdecal.SetParameter(0,fHeader.cal[i].beta_a);
732 if (!fHeader.cal[i].beta_a) fadcdecal.SetParameter(0,1);
733 fadcdecal.SetParameter(1,fHeader.cal[i].ped);
734
735 ftdccal.SetParameter(0,fHeader.cal[i].beta_t);
736 ftdccal.SetParameter(1,fHeader.cal[i].t_0);
737 ftdccal.SetParameter(2,fHeader.cal[i].alpha_t);
738 ftdccal.SetParameter(3,1.e20);
739 ftdcdecal.SetParameter(0,fHeader.cal[i].beta_t);
740 if (!fHeader.cal[i].beta_t) ftdcdecal.SetParameter(0,1);
741 ftdcdecal.SetParameter(1,fHeader.cal[i].t_0);
742 ftdcdecal.SetParameter(2,fHeader.cal[i].alpha_t);
743 ftdcdecal.SetParameter(3,1.e20);
744
745 ftotcal.SetParameter(0,fHeader.cal[i].beta_tot);
746 ftotdecal.SetParameter(0,fHeader.cal[i].beta_tot);
747 if (!fHeader.cal[i].beta_tot) ftotdecal.SetParameter(0,1);
748
749 if (adccal)
750 {
751 dev->SetDecalFunction(&fadcdecal,1);
752 }
753 else
754 {
755 dev->SetCalFunction(&fadccal,1);
756 }
757
758 if (tdccal)
759 {
760 dev->SetDecalFunction(&ftdcdecal,2);
761 }
762 else
763 {
764 dev->SetCalFunction(&ftdccal,2);
765 }
766
767 if (totcal)
768 {
769 dev->SetDecalFunction(&ftotdecal,3);
770 }
771 else
772 {
773 dev->SetCalFunction(&ftotcal,3);
774 }
775
776 dev->SetSignal(fHeader.type[i],4);
777 dev->SetSignal((Float_t)fHeader.costh[i],5);
778 dev->SetSignal(fHeader.thresh[i],6);
779 dev->SetSignal(fHeader.sensit[i],7);
780 dev->SetSignal(0.,8);
781
782 fOmdb->EnterObject(i+1,1,dev);
783 }
784}
785
787{
827
828 if (fHeader.n_fit<=0)
829 {
830 if (fFitdefs)
831 {
832 delete fFitdefs;
833 fFitdefs=0;
834 }
835 return;
836 }
837
838 if (fFitdefs)
839 {
840 fFitdefs->Reset(1);
841 }
842 else
843 {
844 fFitdefs=new NcDevice();
845 }
846
847 fFitdefs->SetName("FitDefinitions");
848 fFitdefs->SetHitCopy (1);
849
850 NcSignal s;
851 s.Reset();
852
853 for (Int_t i=0; i<fHeader.n_fit; i++)
854 {
855 s.SetUniqueID(fHeader.def_fit[i].id);
856 s.SetName(TString(fHeader.def_fit[i].tag));
857
858 for (Int_t j=0; j<fHeader.def_fit[i].nwords; j++)
859 {
860 s.SetSlotName(TString(fHeader.def_fit[i].words[j]),j+1);
861 s.SetSignal(0,j+1);
862 }
863
864 fFitdefs->AddHit(s);
865 s.Reset(1);
866 }
867}
868
870{
910
911 if (fHeader.n_trigger<=0)
912 {
913 if (fTrigdefs)
914 {
915 delete fTrigdefs;
916 fTrigdefs=0;
917 }
918 return;
919 }
920
921 if (fTrigdefs)
922 {
923 fTrigdefs->Reset(1);
924 }
925 else
926 {
927 fTrigdefs=new NcDevice();
928 }
929
930 fTrigdefs->SetName("TrigDefinitions");
931 fTrigdefs->SetHitCopy (1);
932
933 NcSignal s;
934 s.Reset();
935
936 for (Int_t i=0; i<fHeader.n_trigger; i++)
937 {
938 s.SetUniqueID(fHeader.def_trig[i].id);
939 s.SetName(TString(fHeader.def_trig[i].tag));
940
941 for (Int_t j=0; j<fHeader.def_trig[i].nwords; j++)
942 {
943 s.SetSlotName(TString(fHeader.def_trig[i].words[j]),j+1);
944 s.SetSignal(0,j+1);
945 }
946
947 fTrigdefs->AddHit(s);
948 s.Reset(1);
949 }
950}
951
953{
961
963 if (!evt || fEvent.ntrack<=0) return;
964
965 // User defined trigger offset in case of simulated data.
966 // The offset in the F2K file is meant to put the primary interaction
967 // well ahead of the detector trigger.
968 // See the introductory docs of this IceF2k class for further details.
970
971 if (!fMctracks) return;
972
973 // Loop over all the tracks and add them to the current event
974 NcTrack t;
975 Double_t vec[3];
976 NcPosition r;
977 Nc3Vector p;
978 Int_t tid=0;
979 Int_t idpdg=0;
980 Int_t idf2k=0;
981 for (Int_t i=0; i<fEvent.ntrack; i++)
982 {
983 t.Reset ();
984
985 // Beginpoint of the track
986 vec[0]=fEvent.gen[i].x;
987 vec[1]=fEvent.gen[i].y;
988 vec[2]=fEvent.gen[i].z;
989 r.SetPosition(vec,"car");
990 t.SetBeginPoint(r);
991
992 // Endpoint of the track
993 vec[0]+=fEvent.gen[i].length*fEvent.gen[i].px;
994 vec[1]+=fEvent.gen[i].length*fEvent.gen[i].py;
995 vec[2]+=fEvent.gen[i].length*fEvent.gen[i].pz;
996 r.SetPosition(vec,"car");
997 t.SetEndPoint(r);
998
999 // Momentum in GeV/c
1000 vec[0]=fEvent.gen[i].e*fEvent.gen[i].px*1e-3;
1001 vec[1]=fEvent.gen[i].e*fEvent.gen[i].py*1e-3;
1002 vec[2]=fEvent.gen[i].e*fEvent.gen[i].pz*1e-3;
1003 p.SetVector (vec,"car");
1004 t.Set3Momentum(p);
1005
1006 // MC tracks are indicated by negative track id's
1007 tid=fEvent.gen[i].tag;
1008 t.SetId(-abs(tid));
1009
1010 idf2k=fEvent.gen[i].id;
1011 idpdg=0;
1012 if (idf2k>1000)
1013 {
1014 idpdg=idf2k+10000000;
1015 }
1016 else if (idf2k <= 48)
1017 {
1018 idpdg=fPdg->ConvertGeant3ToPdg(idf2k);
1019 }
1020 else
1021 {
1022 if (idf2k==201) idpdg=12;
1023 if (idf2k==202) idpdg=14;
1024 if (idf2k==203) idpdg=16;
1025 if (idf2k==204) idpdg=-12;
1026 if (idf2k==205) idpdg=-14;
1027 if (idf2k==206) idpdg=-16;
1028 }
1029
1030 // Check for the user selected MC track storage
1031 if (fMctracks==1) // Store only muon and muon-neutrino tracks
1032 {
1033 if (abs(idpdg)!=13 && abs(idpdg)!=14) continue;
1034 }
1035 else if (fMctracks==2) // Store all lepton tracks
1036 {
1037 if (abs(idpdg)<11 || abs(idpdg)>16) continue;
1038 }
1039
1040 t.SetParticleCode(idpdg);
1041 t.SetName(fPdg->GetParticle(idpdg)->GetName());
1042 t.SetTitle("MC track");
1043 t.SetMass(fPdg->GetParticle(idpdg)->Mass());
1044 t.SetCharge(fPdg->GetParticle(idpdg)->Charge()/3.);
1045
1046 evt->AddTrack(t);
1047 }
1048
1049 // Create the pointers to each particle's parent particle.
1050 Int_t txid=0;
1051 Int_t parid=0;
1052 for (Int_t itk=1; itk<=evt->GetNtracks (); itk++)
1053 {
1054 NcTrack* tx=evt->GetTrack(itk);
1055
1056 if (!tx) continue;
1057
1058 txid=tx->GetId();
1059
1060 parid=-1;
1061 for (Int_t j=0; j<fEvent.ntrack; j++)
1062 {
1063 tid=fEvent.gen[j].tag;
1064 if (-abs(tid) == txid) parid=fEvent.gen[j].parent;
1065 }
1066
1067 if (parid<0) continue;
1068
1069 NcTrack* tpar=evt->GetIdTrack(-abs(parid));
1070
1071 if (!tpar) continue;
1072
1073 tx->SetParentTrack(tpar);
1074 }
1075}
1076
1078{
1086
1088 if (!evt || fEvent.nfit<=0) return;
1089
1090 // Loop over all the tracks and add them to the current event
1091 NcTrack t;
1092 Double_t vec[3];
1093 NcPosition r;
1094 Nc3Vector p;
1095 Int_t tid=0;
1096 Int_t idpdg=0;
1097 Int_t idf2k=0;
1098 for (Int_t i=0; i<fEvent.nfit; i++)
1099 {
1100 t.Reset ();
1101
1102 // Beginpoint of the track
1103 vec[0]=fEvent.rec[i].x;
1104 vec[1]=fEvent.rec[i].y;
1105 vec[2]=fEvent.rec[i].z;
1106 r.SetPosition(vec,"car");
1107 t.SetBeginPoint(r);
1108
1109 // Endpoint of the track
1110 vec[0]+=fEvent.rec[i].length*fEvent.rec[i].px;
1111 vec[1]+=fEvent.rec[i].length*fEvent.rec[i].py;
1112 vec[2]+=fEvent.rec[i].length*fEvent.rec[i].pz;
1113 r.SetPosition(vec,"car");
1114 t.SetEndPoint(r);
1115
1116 // Momentum in GeV/c
1117 if (fEvent.rec[i].e > 0)
1118 {
1119 vec[0]=fEvent.rec[i].e*fEvent.rec[i].px*1e-3;
1120 vec[1]=fEvent.rec[i].e*fEvent.rec[i].py*1e-3;
1121 vec[2]=fEvent.rec[i].e*fEvent.rec[i].pz*1e-3;
1122 }
1123 else // Give the track a nominal momentum of 1 GeV/c
1124 {
1125 vec[0]=fEvent.rec[i].px;
1126 vec[1]=fEvent.rec[i].py;
1127 vec[2]=fEvent.rec[i].pz;
1128 }
1129 p.SetVector (vec,"car");
1130 t.Set3Momentum(p);
1131
1132 // Use the fit number as track id
1133 tid=fEvent.rec[i].tag;
1134 t.SetId(abs(tid));
1135
1136 idf2k=fEvent.rec[i].id;
1137 idpdg=0;
1138 if (idf2k>1000)
1139 {
1140 idpdg=idf2k+10000000;
1141 }
1142 else if (idf2k <= 48)
1143 {
1144 idpdg=fPdg->ConvertGeant3ToPdg(idf2k);
1145 }
1146 else
1147 {
1148 if (idf2k==201) idpdg=12;
1149 if (idf2k==202) idpdg=14;
1150 if (idf2k==203) idpdg=16;
1151 if (idf2k==204) idpdg=-12;
1152 if (idf2k==205) idpdg=-14;
1153 if (idf2k==206) idpdg=-16;
1154 }
1155
1156 t.SetParticleCode(idpdg);
1157 t.SetNameTitle("Sieglinde","RECO track");
1158 t.SetMass(fPdg->GetParticle(idpdg)->Mass());
1159 t.SetCharge(fPdg->GetParticle(idpdg)->Charge()/3.);
1160
1161 // Retrieve the various fit parameters for this track
1162 NcSignal* fitdata=fFitdefs->GetIdHit(i);
1163 for (Int_t jval=0; jval<fEvent.fresult[i].nval; jval++)
1164 {
1165 fitdata->SetSignal(fEvent.fresult[i].val[jval],jval+1);
1166 }
1167
1168 // Store the various fit parameters for this track
1169 t.SetFitDetails(fitdata);
1170
1171 // Store the various reco tracks as track hypotheses.
1172 // A copy of the first reco track is entered as a new track instance
1173 // into the event and all reco tracks (incl. the first one) are
1174 // stored as hypotheses linked to this new reco track.
1175 if (i==0)
1176 {
1177 evt->AddTrack(t);
1178 NcTrack* tx=evt->GetTrack(evt->GetNtracks());
1179 Int_t nrec=evt->GetNtracks(1);
1180 tx->SetId(nrec+1);
1181 }
1182 NcTrack* tx=evt->GetTrack(evt->GetNtracks());
1183 if (tx) tx->AddTrackHypothesis(t);
1184 }
1185}
1186
1188{
1195
1197 if (!evt) return;
1198
1199 // Loop over all the hits and add them to the current event
1200 IceAOM om;
1201 NcSignal s;
1202 s.SetSlotName("ADC",1);
1203 s.SetSlotName("LE",2);
1204 s.SetSlotName("TOT",3);
1205 Int_t chan=0;
1206 Int_t maxchan=800;
1207 if (fOmdb) maxchan=fHeader.nch;
1208 IceAOM* omx=0;
1209 NcSignal* sx=0;
1210 Int_t tid=0;
1211 NcTrack* tx=0;
1212 Float_t adc=0;
1213 Float_t adcfirst=0; // Adc value of the first hit of an OM
1214 for (Int_t i=0; i<fEvent.nhits; i++)
1215 {
1216 chan=fEvent.h[i].ch+1;
1217 if (chan>maxchan) continue; // Channels 9001, 9002 etc are trigger channels
1218
1219 // Get corresponding device from the current event structure
1220 omx=(IceAOM*)evt->GetIdDevice(chan);
1221 if (!omx)
1222 {
1223 if (fOmdb)
1224 {
1225 omx=(IceAOM*)fOmdb->GetObject(chan,1);
1226 evt->AddDevice(omx);
1227 }
1228 else
1229 {
1230 om.Reset(1);
1231 om.SetUniqueID(chan);
1232 evt->AddDevice(om);
1233 }
1234 omx=(IceAOM*)evt->GetIdDevice(chan);
1235 }
1236
1237 if (!omx) continue;
1238
1239 adc=fEvent.h[i].amp;
1240
1241 // Multiple hits in the same OM with the same ADC value
1242 // are indicated by "*" in the F2K file.
1243 // This corresponds to a value of -2 in the data structure.
1244 if (int(adc) == -2)
1245 {
1246 adc=adcfirst;
1247 }
1248 else
1249 {
1250 adcfirst=adc;
1251 }
1252 s.Reset();
1253 s.SetUniqueID(fEvent.h[i].id);
1254 s.SetSignal(adc,1);
1255 s.SetSignal((fEvent.h[i].t-fToffset),2);
1256 s.SetSignal(fEvent.h[i].tot,3);
1257
1258 omx->AddHit(s);
1259
1260 sx=omx->GetHit(omx->GetNhits());
1261 if (!sx) continue;
1262
1263 // ADC dependent TDC (de)calibration function for this hit
1264 TF1* fcal=omx->GetCalFunction("LE");
1265 TF1* fdecal=omx->GetDecalFunction("LE");
1266 if (fcal) sx->SetCalFunction(fcal,2);
1267 if (fdecal) sx->SetDecalFunction(fdecal,2);
1268 fcal=sx->GetCalFunction(2);
1269 fdecal=sx->GetDecalFunction(2);
1270 adc=sx->GetSignal(1,-4);
1271 if (adc>0)
1272 {
1273 if (fcal) fcal->SetParameter(3,adc);
1274 if (fdecal) fdecal->SetParameter(3,adc);
1275 }
1276 else
1277 {
1278 if (fcal) fcal->SetParameter(3,1.e20);
1279 if (fdecal) fdecal->SetParameter(3,1.e20);
1280 }
1281
1282 // Bi-directional link between this hit and the track that caused the ADC value.
1283 // This F2K info is probably only present for MC tracks.
1284 tid=fEvent.h[i].ma;
1285 if (tid > 0)
1286 {
1287 tx=evt->GetIdTrack(tid); // Reco tracks
1288 if (!tx) tx=evt->GetIdTrack(-tid); // MC tracks
1289 if (tx) sx->AddTrack(*tx);
1290 }
1291 else
1292 {
1293 if (tid == -2) sx->SetNameTitle("N","Noise");
1294 if (tid == -3) sx->SetNameTitle("A","Afterpulse");
1295 }
1296 }
1297
1298 // Loop over all the waveforms and add the histo(s) to the corresponding OM's
1299 TH1F histo;
1300 Int_t nbins=0;
1301 Float_t xlow=0;
1302 Float_t xup=0;
1303 TString hname;
1304 Float_t amp=0; // Amplitude sampler for compressed waveforms
1305 for (Int_t iwf=0; iwf<fEvent.nwf; iwf++)
1306 {
1307 chan=fEvent.wf[iwf].om;
1308 if (chan<=0 || chan>maxchan) continue; // Skip trigger channels
1309
1310 // Get corresponding device from the current event structure
1311 omx=(IceAOM*)evt->GetIdDevice(chan);
1312 if (!omx)
1313 {
1314 if (fOmdb)
1315 {
1316 omx=(IceAOM*)fOmdb->GetObject(chan,1);
1317 evt->AddDevice(omx);
1318 }
1319 else
1320 {
1321 om.Reset(1);
1322 om.SetUniqueID(chan);
1323 evt->AddDevice(om);
1324 }
1325 omx=(IceAOM*)evt->GetIdDevice(chan);
1326 }
1327
1328 if (!omx) continue;
1329
1330 hname="BASELINE-WF";
1331 hname+=omx->GetNwaveforms()+1;
1332 omx->AddNamedSlot(hname);
1333 omx->SetSignal(fEvent.wf[iwf].baseline,hname);
1334
1335 // Fill the waveform histogram
1336 hname="OM";
1337 hname+=chan;
1338 hname+="-WF";
1339 hname+=omx->GetNwaveforms()+1;
1340
1341 histo.Reset();
1342 histo.SetName(hname.Data());
1343 nbins=fEvent.wf[iwf].ndigi;
1344 xlow=fEvent.wf[iwf].t_start;
1345 xup=xlow+float(nbins)*fEvent.wf[iwf].t_bin;
1346 histo.SetBins(nbins,xlow,xup);
1347
1348 for (Int_t jbin=1; jbin<=fEvent.wf[iwf].ndigi; jbin++)
1349 {
1350 if (!fCompTWR) // Uncompressed waveform input
1351 {
1352 histo.SetBinContent(jbin,fEvent.wf[iwf].baseline-fEvent.wf[iwf].digi[jbin-1]);
1353 }
1354 else // Compressed waveform input
1355 {
1356 if (jbin==1) amp=fEvent.wf[iwf].digi[0];
1357 if (jbin==2) amp=fEvent.wf[iwf].digi[1]-histo.GetBinContent(1);
1358 if (jbin>2) amp=fEvent.wf[iwf].digi[jbin-1]-2.*histo.GetBinContent(jbin-1)+histo.GetBinContent(jbin-2);
1359 histo.SetBinContent(jbin,-amp);
1360 }
1361 }
1362
1363 omx->SetWaveform(&histo,omx->GetNwaveforms()+1);
1364 }
1365
1366 // Set bi-directional links between hits and reco track hypotheses.
1367 // Note : Reco tracks are recognised by their positive id.
1368 Int_t hid=0;
1369 TObjArray* rectracks=evt->GetTracks(1);
1370 for (Int_t jtk=0; jtk<rectracks->GetEntries(); jtk++)
1371 {
1372 tx=(NcTrack*)rectracks->At(jtk);
1373 if (!tx) continue;
1374
1375 for (Int_t jhyp=1; jhyp<=tx->GetNhypotheses(); jhyp++)
1376 {
1377 NcTrack* hypx=tx->GetTrackHypothesis(jhyp);
1378 if (!hypx) continue;
1379
1380 // Loop over all combinations of F2K fits and used OM hits
1381 for (Int_t k=0; k<fEvent.nfit_uses; k++)
1382 {
1383 if (fEvent.fit_uses[k].useid != hypx->GetId()) continue;
1384 hid=fEvent.fit_uses[k].hitid;
1385 sx=evt->GetIdHit(hid,"IceAOM");
1386 if (sx) sx->AddTrack(*hypx);
1387 }
1388 }
1389 }
1390}
1391
1393{
1399
1400 if (!fTrigdefs) return;
1401
1403 if (!evt || fEvent.ntrig<=0) return;
1404
1405 NcDevice trig;
1406 trig.SetNameTitle("Trigger","Amanda/IceCube event triggers");
1407 NcSignal s;
1408 TString trigname;
1409 TString slotname;
1410 Int_t id=0;
1411 Int_t nval=0;
1412 for (Int_t i=0; i<fEvent.ntrig; i++)
1413 {
1414 id=fEvent.ptrig[i].id;
1415 nval=fEvent.ptrig[i].nval;
1416 if (!nval) continue;
1417 NcSignal* tdef=fTrigdefs->GetIdHit(id+1);
1418 if (!tdef) continue;
1419 trigname=tdef->GetName();
1420 s.Reset(1);
1421 s.SetName(trigname);
1422 s.SetUniqueID(id+1);
1423 for (Int_t jval=0; jval<fEvent.ptrig[i].nval; jval++)
1424 {
1425 slotname=tdef->GetSlotName(jval+1);
1426 s.SetSlotName(slotname,jval+1);
1427 s.SetSignal(fEvent.ptrig[i].val[jval],jval+1);
1428 }
1429 trig.AddHit(s);
1430 }
1431
1432 // Store the trigger data into the IceEvent structure
1433 evt->AddDevice(trig);
1434}
1435
ClassImp(IceF2k)
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
Job for conversion of F2K data into IceEvent physics event structures.
Definition IceF2k.h:25
void SelectMcTracks(Int_t mode)
Definition IceF2k.cxx:280
Int_t fMaxevt
Definition IceF2k.h:50
Int_t fSplit
Definition IceF2k.h:48
void SetMcToffset(Float_t toffset)
Definition IceF2k.cxx:267
NcObjMatrix * GetOMdbase()
Definition IceF2k.cxx:405
Int_t fPrintfreq
Definition IceF2k.h:51
NcDevice * GetFitdefs()
Definition IceF2k.cxx:416
void PutRecoTracks()
Definition IceF2k.cxx:1077
TFile * GetOutputFile()
Definition IceF2k.cxx:383
IceF2k(const char *name="IceF2k", const char *title="")
Definition IceF2k.cxx:153
void AddInputFile(TString name)
Definition IceF2k.cxx:340
NcDevice * GetTrigdefs()
Definition IceF2k.cxx:427
mcfile * fInput
! Structure holding the input file characteristics
Definition IceF2k.h:72
virtual ~IceF2k()
Definition IceF2k.cxx:179
void FillOMdbase()
Definition IceF2k.cxx:650
void SetInputFile(TString name)
Definition IceF2k.cxx:316
TFile * fOutfile
Definition IceF2k.h:53
void SetOutputFile(TFile *ofile)
Definition IceF2k.cxx:359
NcDevice * fFitdefs
Definition IceF2k.h:57
Int_t fCompTWR
Definition IceF2k.h:62
void SetMaxEvents(Int_t n)
Definition IceF2k.cxx:218
void PutHits()
Definition IceF2k.cxx:1187
Array fHeader
! Structure holding the file header info
Definition IceF2k.h:73
void PutMcTracks()
Definition IceF2k.cxx:952
TDatabasePDG * GetPDG()
Definition IceF2k.cxx:394
void SetFitdefs()
Definition IceF2k.cxx:786
void SetTrigdefs()
Definition IceF2k.cxx:869
virtual void Exec(Option_t *opt)
Definition IceF2k.cxx:438
TDatabasePDG * fPdg
Definition IceF2k.h:55
NcObjMatrix * fOmdb
Definition IceF2k.h:56
void SetBufferSize(Int_t bsize)
Definition IceF2k.cxx:255
Float_t fToffset
Definition IceF2k.h:59
Float_t fMctoffset
Definition IceF2k.h:60
TObjArray * fInfiles
Definition IceF2k.h:52
void PutTrigger()
Definition IceF2k.cxx:1392
NcDevice * fTrigdefs
Definition IceF2k.h:58
Int_t fMctracks
Definition IceF2k.h:61
void SetSplitLevel(Int_t split)
Definition IceF2k.cxx:243
mevt fEvent
! Structure holding the actual event data (hits, tracks, etc...)
Definition IceF2k.h:74
Int_t fBsize
Definition IceF2k.h:49
void SetPrintFreq(Int_t f)
Definition IceF2k.cxx:231
void SetCompressedTWR(Int_t mode)
Definition IceF2k.cxx:299
Handling of 3-vectors in various reference frames.
Definition Nc3Vector.h:15
void SetVector(Double_t *v, TString f, TString u="rad")
TString GetSlotName(Int_t j=1) const
void SetCalFunction(TF1 *f, Int_t j=1)
void AddNamedSlot(TString s)
void SetDecalFunction(TF1 *f, Int_t j=1)
void SetSlotName(TString s, Int_t j=1)
TF1 * GetCalFunction(Int_t j=1) const
TF1 * GetDecalFunction(Int_t j=1) const
Signal (Hit) handling of a generic device.
Definition NcDevice.h:14
void AddHit(NcSignal &s)
Definition NcDevice.cxx:336
Int_t GetNhits() const
Definition NcDevice.cxx:437
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
NcSignal * GetIdHit(Int_t id, TString classname)
Definition NcEvent.cxx:1837
NcDevice * GetDevice(Int_t i) const
Definition NcEvent.cxx:1380
void SetRunNumber(Int_t run)
Definition NcEvent.cxx:562
TObjArray * GetTracks(Int_t idmode=0, Int_t chmode=2, Int_t pcode=0, TObjArray *tracks=0)
Definition NcJet.cxx:792
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
NcTrack * GetIdTrack(Int_t id) const
Definition NcJet.cxx:773
void SetTrackCopy(Int_t j)
Definition NcJet.cxx:1413
void AddTrack(NcTrack &t)
Definition NcJet.cxx:313
TObject * GetMainObject() const
Definition NcJob.cxx:294
void SetMainObject(TObject *obj)
Definition NcJob.cxx:305
void AddObject(TObject *obj)
Definition NcJob.cxx:320
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")
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
void AddTrack(NcTrack &t, Int_t mode=1)
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
NcTrack * GetTrackHypothesis(Int_t j=0) const
Definition NcTrack.cxx:1376
void SetCharge(Float_t q)
Definition NcTrack.cxx:444
void SetBeginPoint(NcPosition &p)
Definition NcTrack.cxx:1423
void AddTrackHypothesis(NcTrack &t)
Definition NcTrack.cxx:1269
void SetEndPoint(NcPosition &p)
Definition NcTrack.cxx:1446
void SetMass(Double_t m, Double_t dm=0)
Definition NcTrack.cxx:430
Int_t GetId() const
Definition NcTrack.cxx:1783
void SetParticleCode(Int_t code)
Definition NcTrack.cxx:1856
void Set3Momentum(Nc3Vector &p)
Definition NcTrack.cxx:401
void SetFitDetails(TObject *obj)
Definition NcTrack.cxx:1922
Int_t GetNhypotheses() const
Definition NcTrack.cxx:1363
virtual void Reset()
Definition NcTrack.cxx:321
void SetId(Int_t id)
Definition NcTrack.cxx:1772
void SetParentTrack(NcTrack *t)
Definition NcTrack.cxx:1878