1 /*******************************************************************************
2 * Copyright(c) 2003, IceCube Experiment at the South Pole. All rights reserved.
4 * Author: The IceCube RALICE-based Offline Project.
5 * Contributors are mentioned in the code where appropriate.
7 * Permission to use, copy, modify and distribute this software and its
8 * documentation strictly for non-commercial purposes is hereby granted
9 * without fee, provided that the above copyright notice appears in all
10 * copies and that both the copyright notice and this permission notice
11 * appear in the supporting documentation.
12 * The authors make no claims about the suitability of this software for
13 * any purpose. It is provided "as is" without express or implied warranty.
14 *******************************************************************************/
18 ///////////////////////////////////////////////////////////////////////////
20 // TTask derived class to perform a linefit track reconstruction.
22 // In case an event has been rejected by an AliEventSelector (based) processor,
23 // this task (and its sub-tasks) is not executed.
25 // The procedure is based on the method described in the Amanda publication
26 // in Nuclear Instruments and Methods A524 (2004) 179-180.
27 // To prevent waisting CPU time in trying to reconstruct (high-energy) cascade
28 // events, or to select specifically reconstruction of low multiplicity events,
29 // the user may invoke the memberfunctions SetMaxModA() and SetMinModA.
30 // This allows selection of events for processing with a certain maximum
31 // and/or minimum number of good Amanda OMs firing.
32 // By default the minimum and maximum are set to 0 and 999, respectively,
33 // in the constructor, which implies no multiplicity selection.
34 // The maximum number of good hits per Amanda OM to be used for the reconstruction
35 // can be specified via the memberfunction SetMaxHitsA().
36 // By default all good hits of each Amanda OM are used but the user may want
37 // to restrict this number to the first n hits of each Amanda OM to account
38 // for possible noise and/or afterpulse signals that are not recognised by the
39 // hit cleaning procedure.
41 // Information about the actual parameter settings can be found in the event
42 // structure itself via the device named "IceLinefit".
44 // The reconstructed track is stored in the IceEvent structure with as
45 // default "IceLinefit" as the name of the track.
46 // This track name identifier can be modified by the user via the
47 // SetTrackName() memberfunction. This will allow unique identification
48 // of tracks which are produced when re-processing existing data with
49 // different criteria.
50 // The track 3-momentum is set to the reconstructed velocity, normalised
51 // to 1 GeV. The mass and charge of the track are left 0.
52 // The r0 and t0 can be obtained from the reference point of the track,
53 // whereas the t0 ia also available from the track timestamp .
54 // By default the charge of the produced tracks is set to 0, since
55 // no distinction can be made between positive or negative tracks.
56 // However, the user can define the track charge by invokation
57 // of the memberfunction SetCharge().
58 // This facility may be used to distinguish tracks produced by the
59 // various reconstruction algorithms in a (3D) colour display
60 // (see the class AliHelix for further details).
61 // The value of beta=v/c for the reconstructed velocity is available
62 // from the fitdetails as stored for the reconstructed track.
64 // For further details the user is referred to NIM A524 (2004) 169.
66 // Note : This algorithm works best on data which has been calibrated
67 // (IceCalibrate), cross talk corrected (IceXtalk) and cleaned
68 // from noise hits etc. (IceCleanHits).
70 //--- Author: Nick van Eijndhoven 10-mar-2006 Utrecht University
71 //- Modified: NvE $Date$ Utrecht University
72 ///////////////////////////////////////////////////////////////////////////
74 #include "IceLinefit.h"
75 #include "Riostream.h"
77 ClassImp(IceLinefit) // Class implementation to enable ROOT I/O
79 IceLinefit::IceLinefit(const char* name,const char* title) : TTask(name,title)
81 // Default constructor.
85 fTrackname="IceLinefit";
88 ///////////////////////////////////////////////////////////////////////////
89 IceLinefit::~IceLinefit()
91 // Default destructor.
93 ///////////////////////////////////////////////////////////////////////////
94 void IceLinefit::SetMaxModA(Int_t nmax)
96 // Set the maximum number of good Amanda modules that may have fired
97 // in order to process this event.
98 // This allows suppression of processing (high-energy) cascade events
99 // with this linefit tracking to prevent waisting cpu time for cases
100 // in which tracking doesn't make sense anyhow.
101 // Furthermore it allows selection of low multiplicity events for processing.
102 // By default the maximum number of Amanda modules is set to 999 in the ctor,
103 // which implies no selection on maximum module multiplicity.
104 // See also the memberfunction SetMinModA().
107 ///////////////////////////////////////////////////////////////////////////
108 void IceLinefit::SetMinModA(Int_t nmin)
110 // Set the minimum number of good Amanda modules that must have fired
111 // in order to process this event.
112 // This allows selection of a minimal multiplicity for events to be processed.
113 // By default the minimum number of Amanda modules is set to 0 in the ctor,
114 // which implies no selection on minimum module multiplicity.
115 // See also the memberfunction SetMaxModA().
118 ///////////////////////////////////////////////////////////////////////////
119 void IceLinefit::SetMaxHitsA(Int_t nmax)
121 // Set the maximum number of good hits per Amanda module to be processed.
124 // nmax = 0 : No maximum limit set; all good hits will be processed
125 // < 0 : No hits will be processed
127 // In case the user selects a maximum number of good hits per module, all the
128 // hits of each module will be ordered w.r.t. increasing hit time (LE).
129 // This allows selection of processing e.g. only the first good hits etc...
130 // By default the maximum number of hits per Amanda modules is set to 0 in the ctor,
131 // which implies just processing all good hits without any maximum limit.
134 ///////////////////////////////////////////////////////////////////////////
135 void IceLinefit::SetTrackName(TString s)
137 // Set (alternative) name identifier for the produced first guess tracks.
138 // This allows unique identification of (newly) produced linefit tracks
139 // in case of re-processing of existing data with different criteria.
140 // By default the produced first guess tracks have the name "IceLinefit"
141 // which is set in the constructor of this class.
144 ///////////////////////////////////////////////////////////////////////////
145 void IceLinefit::SetCharge(Float_t charge)
147 // Set user defined charge for the produced first guess tracks.
148 // This allows identification of these tracks on color displays.
149 // By default the produced first guess tracks have charge=0
150 // which is set in the constructor of this class.
153 ///////////////////////////////////////////////////////////////////////////
154 void IceLinefit::Exec(Option_t* opt)
156 // Implementation of the linefit reconstruction.
159 AliJob* parent=(AliJob*)(gROOT->GetListOfTasks()->FindObject(name.Data()));
163 IceEvent* evt=(IceEvent*)parent->GetObject("IceEvent");
166 // Only process accepted events
167 AliDevice* seldev=(AliDevice*)evt->GetDevice("AliEventSelector");
170 if (seldev->GetSignal("Select") < 0.1) return;
173 // Enter the reco parameters as a device in the event
175 params.SetNameTitle("IceLinefit","IceLinefit reco parameters");
176 params.SetSlotName("MaxmodA",1);
177 params.SetSlotName("MinmodA",2);
178 params.SetSlotName("MaxhitsA",3);
180 params.SetSignal(fMaxmodA,1);
181 params.SetSignal(fMinmodA,2);
182 params.SetSignal(fMaxhitsA,3);
184 evt->AddDevice(params);
186 if (fMaxhitsA<0) return;
188 // Fetch all fired Amanda OMs for this event
189 TObjArray* aoms=evt->GetDevices("IceAOM");
191 Int_t naoms=aoms->GetEntries();
194 // Check for the minimum and/or maximum number of good fired Amanda OMs
196 for (Int_t iom=0; iom<naoms; iom++)
198 IceGOM* omx=(IceGOM*)aoms->At(iom);
200 if (omx->GetDeadValue("ADC") || omx->GetDeadValue("LE") || omx->GetDeadValue("TOT")) continue;
203 if (ngood<fMinmodA || ngood>fMaxmodA) return;
205 const Float_t c=0.299792; // Light speed in vacuum in meters per ns
211 Float_t sumt=0,sumt2=0;
216 // Loop over all OMs and hits to determine the linefit parameters.
217 // Also all the used hits are recorded for association with the track.
218 for (Int_t iom=0; iom<naoms; iom++)
220 IceGOM* omx=(IceGOM*)aoms->At(iom);
222 if (omx->GetDeadValue("LE")) continue;
223 rom=(Ali3Vector)omx->GetPosition();
224 // Use the specified good hits of this OM
226 if (fMaxhitsA>0 && omx->GetNhits()>fMaxhitsA) ordered=omx->SortHits("LE",1,0,7);
228 for (Int_t ih=1; ih<=omx->GetNhits(); ih++)
232 if (nh>=fMaxhitsA) break;
233 sx=(AliSignal*)ordered->At(ih-1);
240 if (sx->GetDeadValue("ADC") || sx->GetDeadValue("LE") || sx->GetDeadValue("TOT")) continue;
242 thit=sx->GetSignal("LE",7);
249 // Record this hit for association with the track
255 Int_t nused=hits.GetEntries();
267 Float_t dum=sumt2-(sumt*sumt);
270 Float_t beta=v.GetNorm()/c;
272 fitstats.SetNameTitle("Fitstats","Fit stats for IceLinefit");
273 fitstats.SetSlotName("Beta",1);
274 fitstats.SetSignal(beta,1);
281 t.SetNameTitle(fTrackname.Data(),"IceLinefit linefit track");
282 t.SetCharge(fCharge);
284 AliTrack* trk=evt->GetTrack(evt->GetNtracks());
287 trk->SetId(evt->GetNtracks(1)+1);
291 v.GetVector(vec,"sph");
293 p.SetVector(vec,"sph");
297 r0.SetTimestamp((AliTimestamp&)*evt);
298 AliTimestamp* t0=r0.GetTimestamp();
299 t0->Add(0,0,(int)sumt);
301 trk->Set3Momentum(p);
302 trk->SetReferencePoint(r0);
303 trk->SetTimestamp(*t0);
304 trk->SetFitDetails(fitstats);
306 // Link the used hits to the track (and vice versa)
307 for (Int_t i=0; i<nused; i++)
309 sx=(AliSignal*)hits.At(i);
310 if (sx) sx->AddTrack(*trk);
313 ///////////////////////////////////////////////////////////////////////////