NCFS-Pack
A generic (astro)particle physics analysis framework
 
Loading...
Searching...
No Matches
IceLinefit.cxx
Go to the documentation of this file.
1
17
19
133
134#include "IceLinefit.h"
135#include "Riostream.h"
136
137ClassImp(IceLinefit); // Class implementation to enable ROOT I/O
138
140IceLinefit::IceLinefit(const char* name,const char* title) : IceRecoBase(name,title)
141{
147
148 SetCleaned(0,"A");
149 SetCleaned(0,"I");
150 SetCleaned(0,"IC");
151 SetCleaned(0,"DC");
152
153 SetMaxMod(999999,"A");
154 SetMaxMod(999999,"I");
155 SetMaxMod(999999,"IC");
156 SetMaxMod(999999,"DC");
157
158 SetMinMod(0,"A");
159 SetMinMod(0,"I");
160 SetMinMod(0,"IC");
161 SetMinMod(0,"DC");
162
163 SetMaxHits(0,"A");
164 SetMaxHits(0,"I");
165 SetMaxHits(-1,"IC");
166 SetMaxHits(-1,"DC");
167
168 SetMinAhits(0,"A");
169 SetMinAhits(0,"I");
170 SetMinAhits(0,"IC");
171 SetMinAhits(0,"DC");
172
173 SetMinAmods(0,"A");
174 SetMinAmods(0,"I");
175 SetMinAmods(0,"IC");
176 SetMinAmods(0,"DC");
177
178 SetSLChitUsage(0,"I");
179 SetSLChitUsage(0,"IC");
180 SetSLChitUsage(0,"DC");
181
182 SetFlipAngles(-999,999);
183}
184
193
194void IceLinefit::Exec(Option_t* opt)
195{
201
202 // Obtain a pointer to the parent NcJob of this reconstruction task
203 TString name=opt;
204 NcJob* parent=(NcJob*)(gROOT->GetListOfTasks()->FindObject(name.Data()));
205
206 if (!parent) return;
207
208 // Obtain a pointer to the IceCube event data structure
209 fEvt=(IceEvent*)parent->GetObject("IceEvent");
210 if (!fEvt) return;
211
212 // Only process accepted events
213 NcDevice* seldev=(NcDevice*)fEvt->GetDevice("NcEventSelector");
214 if (seldev)
215 {
216 if (seldev->GetSignal("Select") < 0.1) return;
217 }
218
219 // Provide a name for the fParams device in the event
220 if (!fUseNames) // Linefit procedure on complete event
221 {
222 fParams.SetNameTitle("IceLinefit","IceLinefit complete event reco parameters");
223 }
224 else // Linefit procedure on track associated hits
225 {
226 fParams.SetNameTitle("IceLinefit4Track","IceLinefit track based reco parameters");
227 }
228
229 // Add the fParams device to the IceEvent structure
230 fEvt->AddDevice(fParams);
231
232 // Printout information on used tracks (if any) at first startup of the processor task
233 if (fUseNames && fFirst)
234 {
235 Int_t nclasses=0;
236 if (fUseNames) nclasses=fUseNames->GetEntries(); // Number of first guess classes to be processed
237 Int_t ntkmax=0; // Max. number of tracks for a certain class
238 TObjString* strx=0;
239 TString str;
240 cout << " *IceLinefit* First guess selections to be processed (-1=all)." << endl;
241 for (Int_t i=0; i<nclasses; i++)
242 {
243 strx=(TObjString*)fUseNames->At(i);
244 if (!strx) continue;
245 str=strx->GetString();
246 ntkmax=fUseNtk->At(i);
247 cout << " Maximally " << ntkmax << " track(s) per event for procedure : " << str.Data() << endl;
248 }
249 cout << endl;
250
251 fFirst=0;
252 }
253
254 // Perform linefit reconstruction for the various (associated) hits
255
256 if (!fUseNames) // Linefit procedure on complete event
257 {
258 Amanda();
259 InIce();
260 IceCube();
261 DeepCore();
262 }
263 else // Linefit procedure on track associated hits
264 {
265 Tracks();
266 }
267}
268
270{
277
278 if (fMaxhitsA<0) return 0;
279
280 // Fetch all fired Amanda OMs for this event
281 TObjArray* aoms=fEvt->GetDevices("IceAOM");
282
283 // Perform the reconstruction
285
286 if (!trk) return 0;
287
288 // Give the reconstructed track the proper name and title
289 TString name=fTrackname;
290 if (name=="") name=ClassName();
291 name+="A";
292 TString title=ClassName();
293 title+=" Amanda track";
294 trk->SetNameTitle(name.Data(),title.Data());
295
296 return 1;
297}
298
300{
307
308 if (fMaxhitsI<0) return 0;
309
310 // Fetch all fired InIce DOMs for this event
311 TObjArray* doms=fEvt->GetDevices("IceIDOM");
312
313 // Perform the reconstruction
315
316 if (!trk) return 0;
317
318 // Give the reconstructed track the proper name and title
319 TString name=fTrackname;
320 if (name=="") name=ClassName();
321 name+="I";
322 TString title=ClassName();
323 title+=" InIce track";
324 trk->SetNameTitle(name.Data(),title.Data());
325
326 return 1;
327}
328
330{
337
338 if (fMaxhitsIC<0) return 0;
339
340 // Fetch all fired standard IceCube InIce DOMs for this event
341 TObjArray* doms=fEvt->GetDevices("IceICDOM");
342
343 // Perform the reconstruction
345
346 if (!trk) return 0;
347
348 // Give the reconstructed track the proper name and title
349 TString name=fTrackname;
350 if (name=="") name=ClassName();
351 name+="IC";
352 TString title=ClassName();
353 title+=" Standard IceCube InIce track";
354 trk->SetNameTitle(name.Data(),title.Data());
355
356 return 1;
357}
358
360{
367
368 if (fMaxhitsDC<0) return 0;
369
370 // Fetch all fired DeepCore DOMs for this event
371 TObjArray* doms=fEvt->GetDevices("IceDCDOM");
372
373 // Perform the reconstruction
375
376 if (!trk) return 0;
377
378 // Give the reconstructed track the proper name and title
379 TString name=fTrackname;
380 if (name=="") name=ClassName();
381 name+="DC";
382 TString title=ClassName();
383 title+=" DeepCore track";
384 trk->SetNameTitle(name.Data(),title.Data());
385
386 return 1;
387}
388
390{
397
398 if (!fUseNames) return 0;
399
400 Int_t nclasses=fUseNames->GetEntries(); // Number of first guess classes to be processed
401 Int_t ntkmax=0; // Max. number of tracks for a certain class
402 TObjString* strx=0;
403 TString str;
404
405 // Track by track processing of the selected first guess classes
406 Int_t ntk=0;
407 NcTrack* track=0;
408 TObjArray* hits=0;
409 Int_t trkflag=0;
410 TString trackname;
411 TString newname;
412 TObjArray mytracks; // Temp. storage for the extracted tracks per class
413 for (Int_t iclass=0; iclass<nclasses; iclass++) // Loop over first guess classes
414 {
415 strx=(TObjString*)fUseNames->At(iclass);
416 if (!strx) continue;
417 str=strx->GetString();
418 ntkmax=fUseNtk->At(iclass);
419 TObjArray* tracks=fEvt->GetTracks(str);
420 ntk=0;
421 if (tracks) ntk=tracks->GetEntries();
422 if (ntkmax>0 && ntk>ntkmax) ntk=ntkmax;
423
424 // Store track pointers in private array to prevent overwriting of TObjArray
425 mytracks.Clear();
426 for (Int_t i=0; i<ntk; i++)
427 {
428 mytracks.Add(tracks->At(i));
429 }
430
431 for (Int_t jtk=0; jtk<ntk; jtk++) // Loop over tracks of a certain class
432 {
433 track=(NcTrack*)mytracks.At(jtk);
434 if (!track) continue;
435
436 // The name of the first guess track without the intial "Ice"
437 trackname=track->GetName();
438 trackname.ReplaceAll("Ice","");
439
440 // Retrieval of the associated hits to be used in the reconstruction procedure
441 hits=track->GetSignals("IceGOM",2);
442
443 // Perform the reconstruction for this track
444 NcTrack* trk=Reconstruct(hits,0,0,0,0,fMinahitsI,fMinamodsI,1);
445
446 if (!trk) continue;
447
448 // Give the reconstructed track the proper name and title
449 trkflag=1;
450 newname=fTrackname;
451 if (newname=="") newname=ClassName();
452 newname+="4";
453 newname+=trackname;
454 trk->SetNameTitle(newname.Data(),"Linefit reco for all assoc. hits");
455 // Link this newly created track as a hypothesis to the parent first guess track
456 track->SetHypCopy(0);
457 track->AddTrackHypothesis(*trk);
458 } // End of loop over the tracks of the current first guess class
459 } // End of loop over first guess classes
460
461 return trkflag;
462}
463
464NcTrack* IceLinefit::Reconstruct(TObjArray* arr,Int_t cln,Int_t minmod,Int_t maxmod,Int_t maxhits,Int_t minahits,Int_t minamods,Int_t slc)
465{
471
472 if (maxhits<0) return 0;
473
474 if (!arr) return 0;
475 Int_t narr=arr->GetEntries();
476 if (narr<=0) return 0;
477
478 if (!fUseNames) // Complete event reco via provided array of (D)OMs
479 {
480 // Check for the minimum and/or maximum number of good fired DOMs
481 Int_t ngood=0;
482 for (Int_t iarr=0; iarr<narr; iarr++)
483 {
484 IceGOM* omx=(IceGOM*)arr->At(iarr);
485 if (!omx) continue;
486 if (omx->GetDeadValue("ADC") || omx->GetDeadValue("LE") || omx->GetDeadValue("TOT")) continue;
487 ngood++;
488 }
489 if (ngood<minmod || ngood>maxmod) return 0;
490 }
491
492 const Float_t c=0.299792; // Light speed in vacuum in meters per ns
493
494 IceGOM* omx=0;
495 NcSignal* sx=0;
496 Nc3Vector rom,sumr;
497 Nc3Vector rt,sumrt;
498 Float_t thit;
499 Float_t sumt=0,sumt2=0;
500 TObjArray hits;
501 TObjArray* ordered=0;
502 Int_t nhitloop=0;
503 Int_t nh;
504
505 // Loop over all DOMs and/or hits to determine the linefit parameters.
506 // Also all the used hits are recorded for association with newly created reco track.
507 for (Int_t iarr=0; iarr<narr; iarr++)
508 {
509 if (!fUseNames) // Complete event reco via provided array of (D)OMs
510 {
511 omx=(IceGOM*)arr->At(iarr);
512 if (!omx) continue;
513 if (omx->GetDeadValue("ADC") || omx->GetDeadValue("LE") || omx->GetDeadValue("TOT")) continue;
514 // Use the specified good hits of this (D)OM
515 ordered=0;
516 if (maxhits>0 && omx->GetNhits()>maxhits)
517 {
518 if (omx->InheritsFrom("IceAOM")) ordered=omx->SortHits("LE",1,0,7);
519 if (omx->InheritsFrom("IceDOM")) ordered=omx->SortHits("ADC",-1,0,7);
520 }
521 nhitloop=omx->GetNhits();
522 }
523 else // Track based reco via provided array of associated hits
524 {
525 nhitloop=1;
526 }
527
528 // Loop over all the hits of the current (D)OM.
529 // In case an associated hit array was provided, only a single pass is made.
530 nh=0;
531 for (Int_t ih=1; ih<=nhitloop; ih++)
532 {
533 if (ordered) // Only take the first "maxhits" ordered hits for this (D)OM
534 {
535 if (nh>=maxhits) break;
536 sx=(NcSignal*)ordered->At(ih-1);
537 }
538 else // Take all available hits
539 {
540 if (!fUseNames) // Obtain the hits from the provided (D)OMs
541 {
542 sx=omx->GetHit(ih);
543 }
544 else // Obtain the hits directly from the provided array
545 {
546 sx=(NcSignal*)arr->At(iarr);
547 omx=(IceGOM*)sx->GetDevice();
548 }
549 }
550
551 if (!omx || !sx) continue;
552
553 if (cln && (sx->GetDeadValue("ADC") || sx->GetDeadValue("LE") || sx->GetDeadValue("TOT"))) continue;
554 if (!slc && sx->GetSignal("SLC")) continue;
555
556 thit=sx->GetSignal("LE",7);
557 rom=(Nc3Vector)omx->GetPosition();
558 rt=rom*thit;
559 sumr+=rom;
560 sumrt+=rt;
561 sumt+=thit;
562 sumt2+=thit*thit;
563
564 // Record this hit for association with the track
565 hits.Add(sx);
566 nh++;
567 }
568 }
569
570 Int_t nused=hits.GetEntries();
571 if (!nused || nused<minahits) return 0;
572
573 Int_t nasmods=fEvt->GetNdevices("IceGOM",&hits);
574 if (nasmods<minamods) return 0;
575
576 sumr/=float(nused);
577 sumrt/=float(nused);
578 sumt/=float(nused);
579 sumt2/=float(nused);
580
581 Nc3Vector v;
582 Nc3Vector temp;
583 temp=sumr*sumt;
584 v=sumrt-temp;
585 Float_t dum=sumt2-(sumt*sumt);
586 if (dum) v/=dum;
587
588 Float_t beta=v.GetNorm()/c;
589 NcSignal fitstats;
590 fitstats.SetNameTitle("Fitstats","Fit stats for IceLinefit");
591 fitstats.AddNamedSlot("Beta");
592 fitstats.SetSignal(beta,"Beta");
593
594 Nc3Vector r;
595 temp=v*sumt;
596 r=sumr-temp;
597
598 NcTrack t;
600 fEvt->AddTrack(t);
601 NcTrack* trk=fEvt->GetTrack(fEvt->GetNtracks());
602 if (!trk) return 0;
603
604 trk->SetId(fEvt->GetNtracks(1)+1);
605
606 Nc3Vector p;
607 Float_t vec[3];
608 v.GetVector(vec,"sph");
609 vec[0]=1;
610 p.SetVector(vec,"sph");
611
612 NcPosition r0;
613 r0.SetPosition(r);
615 NcTimestamp* t0=r0.GetTimestamp();
616 t0->Add(0,0,(int)sumt);
617
618 trk->Set3Momentum(p);
619 trk->SetReferencePoint(r0);
620 trk->SetTimestamp(*t0);
621 trk->SetFitDetails(fitstats);
622
623 // Link the used hits to the track (and vice versa)
624 for (Int_t i=0; i<nused; i++)
625 {
626 sx=(NcSignal*)hits.At(i);
627 if (sx) sx->AddTrack(*trk);
628 }
629
630 // Check whether the track direction should be flipped
631 FlipTrack(trk);
632
633 return trk;
634}
635
ClassImp(IceLinefit)
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 linefit reconstruction.
Definition IceLinefit.h:12
Int_t DeepCore()
Int_t Amanda()
Int_t IceCube()
virtual void Exec(Option_t *opt)
virtual ~IceLinefit()
Int_t Tracks()
NcTrack * Reconstruct(TObjArray *doms, Int_t cln, Int_t minmod, Int_t maxmod, Int_t maxhits, Int_t minahits, Int_t minamods, Int_t slc)
IceLinefit(const char *name="IceLinefit", const char *title="Linefit reconstruction")
Int_t InIce()
Int_t fMinahitsI
Definition IceRecoBase.h:69
IceRecoBase(const char *name="IceRecoBase", const char *title="Base class for IceCube reconstruction tasks")
Int_t fMinamodsI
Definition IceRecoBase.h:73
void SetSLChitUsage(Int_t flag, TString s)
void SetCleaned(Int_t flag, TString s)
Int_t fMinahitsIC
Definition IceRecoBase.h:70
Int_t fMinamodsA
Definition IceRecoBase.h:72
Int_t fCleanI
Definition IceRecoBase.h:45
Int_t fCleanIC
Definition IceRecoBase.h:46
Int_t fMinahitsDC
Definition IceRecoBase.h:71
void SetMinAmods(Int_t nmin, TString s)
Int_t fMaxmodA
Definition IceRecoBase.h:48
TArrayI * fUseNtk
Definition IceRecoBase.h:99
Int_t fCleanDC
Definition IceRecoBase.h:47
Int_t fMinmodDC
Definition IceRecoBase.h:55
void SetMinMod(Int_t nmin, TString s)
Int_t fCleanA
Definition IceRecoBase.h:44
Int_t fMaxmodIC
Definition IceRecoBase.h:50
Int_t fMaxhitsDC
Definition IceRecoBase.h:59
Int_t fMinmodI
Definition IceRecoBase.h:53
void SetMaxMod(Int_t nmax, TString s)
Int_t fMaxmodI
Definition IceRecoBase.h:49
Int_t fMaxhitsIC
Definition IceRecoBase.h:58
void SetMaxHits(Int_t nmax, TString s)
TString fTrackname
Definition IceRecoBase.h:96
NcDevice fParams
Float_t fCharge
Definition IceRecoBase.h:97
void SetMinAhits(Int_t nmin, TString s)
Int_t fMaxmodDC
Definition IceRecoBase.h:51
Int_t fMinamodsIC
Definition IceRecoBase.h:74
virtual void FlipTrack(NcTrack *t) const
void SetFlipAngles(Float_t thetatrk, Float_t thetahits)
Int_t fMinmodIC
Definition IceRecoBase.h:54
Int_t fMaxhitsA
Definition IceRecoBase.h:56
Int_t fMinamodsDC
Definition IceRecoBase.h:75
TObjArray * fUseNames
Definition IceRecoBase.h:98
Int_t fMinahitsA
Definition IceRecoBase.h:68
Int_t fMaxhitsI
Definition IceRecoBase.h:57
IceEvent * fEvt
Definition IceRecoBase.h:43
Int_t fMinmodA
Definition IceRecoBase.h:52
Handling of 3-vectors in various reference frames.
Definition Nc3Vector.h:15
void SetVector(Double_t *v, TString f, TString u="rad")
void GetVector(Double_t *v, TString f, TString u="rad") const
Double_t GetNorm()
void AddNamedSlot(TString s)
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
TObjArray * SortHits(TString name, Int_t mode=-1, TObjArray *hits=0, Int_t mcal=1, Int_t deadcheck=1, TObjArray *ordered=0)
Definition NcDevice.cxx:984
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 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
virtual void SetSignal(Double_t sig, Int_t j=1)
Definition NcSignal.cxx:516
NcDevice * GetDevice() const
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)
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
void Set3Momentum(Nc3Vector &p)
Definition NcTrack.cxx:401
void SetFitDetails(TObject *obj)
Definition NcTrack.cxx:1922
TObjArray * GetSignals(const char *classname, Int_t par=0, TObjArray *signals=0)
Definition NcTrack.cxx:1046
void SetHypCopy(Int_t flag)
Definition NcTrack.cxx:1209
void SetId(Int_t id)
Definition NcTrack.cxx:1772
void SetTimestamp(NcTimestamp &t)
Definition NcTrack.cxx:1973