1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line 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. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
18 ///////////////////////////////////////////////////////////////////////////
19 // Class AliEventSelector
20 // TTask based processor to perform generic event selection.
21 // This class is derived from AliAstrolab in order to also provide event
22 // selection based on space and time matching with external (astrophysical)
23 // objects and phenomena.
25 // After having applied the various selection criteria, this processor
26 // introduces an AliDevice with the name "AliEventSelector" into the event.
27 // This device contains named signal slots to indicate the settings
28 // of the various selection parameters.
29 // One of the slots has the name "Select" and the signal value of this
30 // slot indicates the final selection result.
32 // value : -1 ==> Event rejected
33 // 0 ==> Decision unknown (incomplete selection parameters)
34 // 1 ==> Event selected
36 // Event selection may be performed based on various selection types,
37 // e.g. individual track observables, total event observables or
38 // space and time matching with external objects.
39 // These types can be (de)activated via the SetSelector member function.
41 // The specific selection criteria for each selection type may be
42 // specified via the SetRange memberfunction.
44 // The logic to be used in the selection process with the various criteria
45 // is set via the memberfunction SetLogic.
46 // Obviously, matching of tracks with various external objects is always
47 // performed in logical "or".
49 // For investigation of individual track observables and/or matching with
50 // external objects, the user may define a restricted set of tracks to
51 // be used in the evaluation procedures. The definition of such a restricted
52 // track set is performed via the memberfunction UseTracks.
56 // gSystem->Load("ralice");
58 // AliEventSelector sel;
59 // sel.SetLabPosition(0.5,-90,"deg"); // The South Pole Neutrino Observatory
60 // sel.SetLocalFrame(90,180,90,270,0,0); // Local frame has X-axis to the North
62 // sel.SetSelector("astro");
63 // sel.SetSelector("track");
64 // sel.SetSelector("event");
65 // sel.SetLogic("and");
66 // sel.UseTracks("*");
68 // sel.SetRange("track","p",0.5,1e20); // Require at least 500 MeV/c track momentum
69 // sel.SetRange("event","ntrk","*",1,3); // Only low multiplicity events
71 // // Match with Astrophysical objects within 5 degrees and 10 seconds
74 // sel.SetAstroMatch(da,dt,"from");
76 // // Some observed event to be investigated
78 // evt.SetUT(1989,7,30,8,14,23,738504,0);
80 // Float_t vec[3]={1,23.8,118.65};
82 // r.SetVector(vec,"sph","deg");
85 // t.SetNameTitle("SomeTrack","Just a dummy test track");
86 // r*=-1; // Let track originate from specified location
91 // // Enter some external (astrophysical) reference signals
92 // Float_t alpha=194818.0;
93 // Float_t delta=84400.;
94 // sel.SetSignal(alpha,delta,"B",1950,"M",-1,"Altair");
97 // sel.SetSignal(alpha,delta,"B",1950,"M",-1,"NGP");
100 // sel.SetSignal(alpha,delta,"J",2000,"M",-1,"Sirius");
103 // sel.SetSignal(alpha,delta,"J",2000,"M",-1,"Polaris");
106 // sel.SetSignal(alpha,delta,"J",2000,"M",-1,"Aldebaran");
107 // Float_t l=327.531;
108 // Float_t b=-35.8903;
109 // Float_t pos[3]={1,90.-b,l};
110 // r.SetVector(pos,"sph","deg");
111 // sel.SetUT(1989,7,30,8,14,16,0,0);
112 // sel.SetSignal(&r,"gal","M",0,-1,"GRB890730"); // This matches our track
114 // // List all stored reference objects
115 // sel.ListSignals("equ","T",5);
117 // // Let's see what the event selection makes of it
120 // q.ListEnvironment();
121 // q.ProcessObject(&evt);
123 // AliDevice* evtsel=(AliDevice*)evt.GetDevice("AliEventSelector");
124 // if (evtsel) evtsel->Data();
126 //--- Author: Nick van Eijndhoven 17-sep-2007 Utrecht University
127 //- Modified: NvE $Date$ Utrecht University
128 ///////////////////////////////////////////////////////////////////////////
130 #include "AliEventSelector.h"
131 #include "Riostream.h"
133 ClassImp(AliEventSelector) // Class implementation to enable ROOT I/O
135 AliEventSelector::AliEventSelector(const char* name,const char* title) : AliAstrolab(name,title)
137 // Default constructor.
153 for (Int_t i=0; i<=8; i=i+2)
156 fEventTracks[i+1]=-1;
160 fTrackMomenta[i+1]=-1;
162 fTrackEnergies[i+1]=-1;
164 fEventMomenta[i+1]=-1;
166 fEventEnergies[i+1]=-1;
170 fTrackRapidities[i]=0;
171 fTrackRapidities[i+1]=-1;
176 fTrackMasses[i+1]=-1;
178 fEventMasses[i+1]=-1;
180 fTrackCharges[i+1]=-1;
182 fEventCharges[i+1]=-1;
184 fTrackDevices[i+1]=-1;
186 fEventDevices[i+1]=-1;
193 ///////////////////////////////////////////////////////////////////////////
194 AliEventSelector::~AliEventSelector()
196 // Default destructor.
215 ///////////////////////////////////////////////////////////////////////////
216 AliEventSelector::AliEventSelector(const AliEventSelector& q) : AliAstrolab(q)
222 fParams=new AliDevice(*(q.fParams));
224 fTrackflag=q.fTrackflag;
225 fEventflag=q.fEventflag;
226 fAstroflag=q.fAstroflag;
230 fAstroDir=q.fAstroDir;
232 for (Int_t i=0; i<10; i++)
234 fEventTracks[i]=q.fEventTracks[i];
238 fTrackMomenta[i]=q.fTrackMomenta[i];
239 fTrackEnergies[i]=q.fTrackEnergies[i];
240 fEventMomenta[i]=q.fEventMomenta[i];
241 fEventEnergies[i]=q.fEventEnergies[i];
244 if (i<4) fTrackRapidities[i]=q.fTrackRapidities[i];
248 fTrackMasses[i]=q.fTrackMasses[i];
249 fEventMasses[i]=q.fEventMasses[i];
250 fTrackCharges[i]=q.fTrackCharges[i];
251 fEventCharges[i]=q.fEventCharges[i];
252 fTrackDevices[i]=q.fTrackDevices[i];
253 fEventDevices[i]=q.fEventDevices[i];
256 fTrackDevClass=q.fTrackDevClass;
257 fEventDevClass=q.fEventDevClass;
258 fEventTrkName=q.fEventTrkName;
260 ///////////////////////////////////////////////////////////////////////////
261 void AliEventSelector::SetSelector(TString type,Int_t flag)
263 // Specify the selection types to be used.
264 // The various types my be selected in a cumulative way by specification
265 // of the input argument "type".
266 // The various possibilities are :
268 // type = "track" ==> Selection based on individual track observables (e.g. Pt)
269 // "event" ==> Selection based on total event observables (e.g. Invmass)
270 // "astro" ==> Selection based on correlation with external objects
272 // The specified selection types can be (de)activated via the input
275 // flag = 0 ==> Don't use the specified selection type
276 // 1 ==> Use the specified selection type
278 // For type="astro" the flag>0 value specifies further selections as follows :
280 // flag = 1 ==> Match individual track momentum directions with external (astrophysical) objects
281 // 2 ==> Match event total momentum direction with external (astrophysical) objects
282 // 3 ==> Match event position with external (astrophysical) objects
284 // For further details see memberfunction SetAstroMatch.
286 // The default value is flag=1.
288 // Note : In the default constructor all selection types are de-activated.
290 if (type=="track") fTrackflag=flag;
291 if (type=="event") fEventflag=flag;
292 if (type=="astro") fAstroflag=flag;
294 ///////////////////////////////////////////////////////////////////////////
295 void AliEventSelector::SetLogic(TString type)
297 // Set type of the decision logic.
299 // type = "and" ==> Event selection based on logical "and"
300 // "or" ==> Event selection based on logical "or"
301 // "nand" ==> Event selection based on logical "nand"
302 // "nor" ==> Event selection based on logical "nor"
304 // Note : In the default constructor the decision logic is set to "unknown".
306 if (type=="and") fLogic=1;
307 if (type=="or") fLogic=2;
308 if (type=="nand") fLogic=-1;
309 if (type=="nor") fLogic=-2;
311 ///////////////////////////////////////////////////////////////////////////
312 void AliEventSelector::UseTracks(TString name,Int_t n)
314 // Specification of the track names to be used for the investigation
315 // of individual track observables and matching with external objects.
317 // name : Specifies the track name (e.g. "IceDwalk")
318 // In case name="*" all track names will be accepted.
320 // n : Specifies the max. number of these tracks to be used
322 // Note : n<0 will use all the existing tracks of the specified name
324 // The default is n=-1.
326 // Consecutive invokations of this memberfunction with different names
327 // will result in an incremental effect.
331 // UseTracks("IceDwalk",5);
332 // UseTracks("IceLinefit",2);
333 // UseTracks("Pythia");
335 // This will use the first 5 IceDwalk, the first 2 IceLinefit and all the
336 // Pythia tracks which are encountered in the event structure.
340 fUseNames=new TObjArray();
341 fUseNames->SetOwner();
344 if (!fUseNtk) fUseNtk=new TArrayI();
346 // Check if this classname has already been specified before
348 Int_t nen=fUseNames->GetEntries();
349 for (Int_t i=0; i<nen; i++)
351 TObjString* sx=(TObjString*)fUseNames->At(i);
357 // New name to be added into the storage
358 if (nen >= fUseNames->GetSize()) fUseNames->Expand(nen+1);
359 if (nen >= fUseNtk->GetSize()) fUseNtk->Set(nen+1);
361 TObjString* namex=new TObjString();
362 namex->SetString(name);
363 fUseNames->Add(namex);
364 fUseNtk->AddAt(n,nen);
366 ///////////////////////////////////////////////////////////////////////////
367 void AliEventSelector::SetAstroMatch(Double_t da,Double_t dt,TString dir)
369 // Set the parameters for the matching of reference objects.
371 // da : Maximum angular difference in degrees
372 // dt : Maximum absolute time difference in seconds
373 // dir : "to" ==> Check the location the track (or event) points to
374 // "from" ==> Check the location the track (or event) originates from
379 if (dir=="to") fAstroDir=1;
380 if (dir=="from") fAstroDir=-1;
382 if (!fParams) fParams=new AliDevice();
384 fParams->AddNamedSlot("AstroDa");
385 fParams->AddNamedSlot("AstroDt");
386 fParams->AddNamedSlot("AstroDir");
387 fParams->SetSignal(fAstroDa,"AstroDa");
388 fParams->SetSignal(fAstroDt,"AstroDt");
389 fParams->SetSignal(fAstroDir,"AstroDir");
391 ///////////////////////////////////////////////////////////////////////////
392 void AliEventSelector::SetRange(TString type,TString obs,Double_t low,Double_t up)
394 // Set range for the specified observable.
396 // type : Selection type specifier (e.g. "track" or "event").
397 // obs : Observable specification.
398 // low : Lower bound of acceptance range
399 // up : Upper bound of acceptance range
401 // The various observables that are available for selection criteria are :
403 // obs : "p" ==> Momentum value in GeV/c
404 // "pt" ==> Transverse momentum value in GeV/c
405 // "pl" ==> Longitudinal momentum value in GeV/c
406 // "e" ==> Energy value in GeV
407 // "et" ==> Transverse momentum value in GeV
408 // "el" ==> Longitudinal momentum value in GeV
409 // "m" ==> (Invariant) mass in GeV/c^2
410 // "q" ==> Charge (electron charge is defined as -1)
411 // "y" ==> Rapidity (only for "track")
412 // "eta" ==> Pseudo-rapidity (only for "track")
414 // Note : When up<low the specified observable will not be used for selection.
416 // In the default constructor all observables are de-activated for selection.
418 if (!fParams) fParams=new AliDevice();
420 if (type=="track") // Individual track observables
424 fTrackMomenta[0]=low;
426 fParams->AddNamedSlot("TrackMinP");
427 fParams->AddNamedSlot("TrackMaxP");
428 fParams->SetSignal(low,"TrackMinP");
429 fParams->SetSignal(up,"TrackMaxP");
433 fTrackMomenta[2]=low;
435 fParams->AddNamedSlot("TrackMinPt");
436 fParams->AddNamedSlot("TrackMaxPt");
437 fParams->SetSignal(low,"TrackMinPt");
438 fParams->SetSignal(up,"TrackMaxPt");
442 fTrackMomenta[4]=low;
444 fParams->AddNamedSlot("TrackMinPl");
445 fParams->AddNamedSlot("TrackMaxPl");
446 fParams->SetSignal(low,"TrackMinPl");
447 fParams->SetSignal(up,"TrackMaxPl");
451 fTrackEnergies[0]=low;
452 fTrackEnergies[1]=up;
453 fParams->AddNamedSlot("TrackMinE");
454 fParams->AddNamedSlot("TrackMaxE");
455 fParams->SetSignal(low,"TrackMinE");
456 fParams->SetSignal(up,"TrackMaxE");
460 fTrackEnergies[2]=low;
461 fTrackEnergies[3]=up;
462 fParams->AddNamedSlot("TrackMinEt");
463 fParams->AddNamedSlot("TrackMaxEt");
464 fParams->SetSignal(low,"TrackMinEt");
465 fParams->SetSignal(up,"TrackMaxEt");
469 fTrackEnergies[4]=low;
470 fTrackEnergies[5]=up;
471 fParams->AddNamedSlot("TrackMinEl");
472 fParams->AddNamedSlot("TrackMaxEl");
473 fParams->SetSignal(low,"TrackMinEl");
474 fParams->SetSignal(up,"TrackMaxEl");
480 fParams->AddNamedSlot("TrackMinM");
481 fParams->AddNamedSlot("TrackMaxM");
482 fParams->SetSignal(low,"TrackMinM");
483 fParams->SetSignal(up,"TrackMaxM");
487 fTrackCharges[0]=low;
489 fParams->AddNamedSlot("TrackMinQ");
490 fParams->AddNamedSlot("TrackMaxQ");
491 fParams->SetSignal(low,"TrackMinQ");
492 fParams->SetSignal(up,"TrackMaxQ");
496 fTrackRapidities[0]=low;
497 fTrackRapidities[1]=up;
498 fParams->AddNamedSlot("TrackMinY");
499 fParams->AddNamedSlot("TrackMaxY");
500 fParams->SetSignal(low,"TrackMinY");
501 fParams->SetSignal(up,"TrackMaxY");
505 fTrackRapidities[2]=low;
506 fTrackRapidities[3]=up;
507 fParams->AddNamedSlot("TrackMinEta");
508 fParams->AddNamedSlot("TrackMaxEta");
509 fParams->SetSignal(low,"TrackMinEta");
510 fParams->SetSignal(up,"TrackMaxEta");
514 if (type=="event") // Total event observables
518 fEventMomenta[0]=low;
520 fParams->AddNamedSlot("EventMinP");
521 fParams->AddNamedSlot("EventMaxP");
522 fParams->SetSignal(low,"EventMinP");
523 fParams->SetSignal(up,"EventMaxP");
527 fEventMomenta[2]=low;
529 fParams->AddNamedSlot("EventMinPt");
530 fParams->AddNamedSlot("EventMaxPt");
531 fParams->SetSignal(low,"EventMinPt");
532 fParams->SetSignal(up,"EventMaxPt");
536 fEventMomenta[4]=low;
538 fParams->AddNamedSlot("EventMinPl");
539 fParams->AddNamedSlot("EventMaxPl");
540 fParams->SetSignal(low,"EventMinPl");
541 fParams->SetSignal(up,"EventMaxPl");
545 fEventEnergies[0]=low;
546 fEventEnergies[1]=up;
547 fParams->AddNamedSlot("EventMinE");
548 fParams->AddNamedSlot("EventMaxE");
549 fParams->SetSignal(low,"EventMinE");
550 fParams->SetSignal(up,"EventMaxE");
554 fEventEnergies[2]=low;
555 fEventEnergies[3]=up;
556 fParams->AddNamedSlot("EventMinEt");
557 fParams->AddNamedSlot("EventMaxEt");
558 fParams->SetSignal(low,"EventMinEt");
559 fParams->SetSignal(up,"EventMaxEt");
563 fEventEnergies[4]=low;
564 fEventEnergies[5]=up;
565 fParams->AddNamedSlot("EventMinEl");
566 fParams->AddNamedSlot("EventMaxEl");
567 fParams->SetSignal(low,"EventMinEl");
568 fParams->SetSignal(up,"EventMaxEl");
574 fParams->AddNamedSlot("EventMinM");
575 fParams->AddNamedSlot("EventMaxM");
576 fParams->SetSignal(low,"EventMinM");
577 fParams->SetSignal(up,"EventMaxM");
581 fEventCharges[0]=low;
583 fParams->AddNamedSlot("EventMinQ");
584 fParams->AddNamedSlot("EventMaxQ");
585 fParams->SetSignal(low,"EventMinQ");
586 fParams->SetSignal(up,"EventMaxQ");
590 ///////////////////////////////////////////////////////////////////////////
591 void AliEventSelector::SetRange(TString type,TString obs,TString name,Int_t nlow,Int_t nup)
593 // Set range for the specified observable.
595 // type : Selection type specifier (e.g. "track" or "event").
596 // obs : Observable specification.
597 // name : (Class) name of the objects to be searched for
598 // nlow : Lower bound of acceptance range
599 // nup : Upper bound of acceptance range
601 // The various observables that are available for selection criteria are :
603 // obs : "ndev" ==> Number of associated devices of the specified (derived) class name
604 // "ntrk" ==> Number of tracks with the specified name (name="*" ==> all tracks)
605 // "ntkc" ==> Total number of charged tracks (no name selection)
606 // "ntk0" ==> Total number of neutral tracks (no name selection)
607 // "ntk+" ==> Total number of positive tracks (no name selection)
608 // "ntk-" ==> Total number of negative tracks (no name selection)
610 // Note : For a certain (type,obs) combination only one (class) name can be specified.
612 if (!fParams) fParams=new AliDevice();
614 if (type=="track") // Individual track observables
618 fTrackDevices[0]=nlow;
619 fTrackDevices[1]=nup;
621 fParams->AddNamedSlot("TrackMinNdev");
622 fParams->AddNamedSlot("TrackMaxNdev");
623 fParams->SetSignal(float(nlow),"TrackMinNdev");
624 fParams->SetSignal(float(nup),"TrackMaxNdev");
628 if (type=="event") // Total event observables
632 fEventDevices[0]=nlow;
633 fEventDevices[1]=nup;
635 fParams->AddNamedSlot("EventMinNdev");
636 fParams->AddNamedSlot("EventMaxNdev");
637 fParams->SetSignal(float(nlow),"EventMinNdev");
638 fParams->SetSignal(float(nup),"EventMaxNdev");
642 fEventTracks[0]=nlow;
645 fParams->AddNamedSlot("EventMinNtrk");
646 fParams->AddNamedSlot("EventMaxNtrk");
647 fParams->SetSignal(float(nlow),"EventMinNtrk");
648 fParams->SetSignal(float(nup),"EventMaxNtrk");
652 fEventTracks[2]=nlow;
654 fParams->AddNamedSlot("EventMinNtkc");
655 fParams->AddNamedSlot("EventMaxNtkc");
656 fParams->SetSignal(float(nlow),"EventMinNtkc");
657 fParams->SetSignal(float(nup),"EventMaxNtkc");
661 fEventTracks[4]=nlow;
663 fParams->AddNamedSlot("EventMinNtk0");
664 fParams->AddNamedSlot("EventMaxNtk0");
665 fParams->SetSignal(float(nlow),"EventMinNtk0");
666 fParams->SetSignal(float(nup),"EventMaxNtk0");
670 fEventTracks[6]=nlow;
672 fParams->AddNamedSlot("EventMinNtk+");
673 fParams->AddNamedSlot("EventMaxNtk+");
674 fParams->SetSignal(float(nlow),"EventMinNtk+");
675 fParams->SetSignal(float(nup),"EventMaxNtk+");
679 fEventTracks[8]=nlow;
681 fParams->AddNamedSlot("EventMinNtk-");
682 fParams->AddNamedSlot("EventMaxNtk-");
683 fParams->SetSignal(float(nlow),"EventMinNtk-");
684 fParams->SetSignal(float(nup),"EventMaxNtk-");
688 ///////////////////////////////////////////////////////////////////////////
689 void AliEventSelector::Exec(Option_t* opt)
691 // Implementation of the event selection procedures.
694 AliJob* parent=(AliJob*)(gROOT->GetListOfTasks()->FindObject(name.Data()));
698 fEvt=(AliEvent*)parent->GetObject("AliEvent");
701 Int_t ntkmax=0; // Max. number of tracks for a certain name
702 Int_t nnames=0; // Number of track names to be processed
703 if (fUseNames) nnames=fUseNames->GetEntries();
709 cout << " *AliEventSelector* Selection parameters." << endl;
710 cout << " Selection types in use :";
711 if (fTrackflag) cout << " track";
712 if (fEventflag) cout << " event";
713 if (fAstroflag) cout << " astro";
714 if (!fTrackflag && !fEventflag && !fAstroflag) cout << " none";
716 cout << " Selection logic in use :";
717 if (fLogic==1) cout << " and";
718 if (fLogic==2) cout << " or";
719 if (fLogic==-1) cout << " nand";
720 if (fLogic==-2) cout << " nor";
721 if (!fLogic) cout << " unknown";
723 if (nnames) cout << " Track name selections to be processed (-1=all)." << endl;
724 for (Int_t i=0; i<nnames; i++)
726 strx=(TObjString*)fUseNames->At(i);
728 str=strx->GetString();
729 ntkmax=fUseNtk->At(i);
730 cout << " Maximally " << ntkmax << " track(s) per event of name : " << str.Data() << endl;
737 // Storage of the used parameters in the AliEventSelector device
738 if (!fParams) fParams=new AliDevice();
739 fParams->SetNameTitle("AliEventSelector","AliEventSelector processor parameters");
744 if (fEventflag) Event(); // Check criteria for total event observables
745 if (fTrackflag) Track(0); // Check criteria for total track observables
746 if (fAstroflag) Astro(); // Check for matches with external objects
749 if (fLogic<0) fSelect*=-1; // In case of "nand"/"nor" logic
751 fParams->AddNamedSlot("Logic");
752 fParams->SetSignal(float(fLogic),"Logic");
753 fParams->AddNamedSlot("Eventflag");
754 fParams->SetSignal(float(fEventflag),"Eventflag");
755 fParams->AddNamedSlot("Trackflag");
756 fParams->SetSignal(float(fTrackflag),"Trackflag");
757 fParams->AddNamedSlot("Astroflag");
758 fParams->SetSignal(float(fAstroflag),"Astroflag");
759 fParams->AddNamedSlot("Select");
760 fParams->SetSignal(float(fSelect),"Select");
762 AliDevice* dx=(AliDevice*)fEvt->GetDevice("AliEventSelector");
763 if (dx) fEvt->RemoveDevice(dx);
764 fEvt->AddDevice(fParams);
766 ///////////////////////////////////////////////////////////////////////////
767 void AliEventSelector::Track(Int_t mode)
769 // Check criteria for individual track observables.
770 // This memberfunction serves also the track direction checking
771 // for external (astrophysical) objects.
772 // mode = 0 : Track observables (e.g. P, Pt etc...) are checked
773 // 1 : Track direction is checked w.r.t. external (astrophysical) objects
775 if (abs(fLogic)==1) fSelect=-1; // Selections are made in logical "(n)and"
777 if (fSelect>0) return; // Event is already flagged as select
779 if (!fUseNames) return;
781 if (mode==1 && !fAstroDir) return;
783 Int_t nnames=fUseNames->GetEntries(); // Number of track names to be processed
784 Int_t ntkmax=0; // Max. number of tracks for a certain name
795 for (Int_t i=0; i<nnames; i++) // Loop over selected track names
797 strx=(TObjString*)fUseNames->At(i);
799 str=strx->GetString();
800 ntkmax=fUseNtk->At(i);
803 tracks=fEvt->GetTracks();
807 tracks=fEvt->GetTracks(str);
810 if (tracks) ntk=tracks->GetEntries();
811 if (ntkmax>0 && ntk>ntkmax) ntk=ntkmax;
813 for (Int_t jtk=0; jtk<ntk; jtk++) // Loop over tracks of a certain name
815 track=(AliTrack*)tracks->At(jtk);
816 if (!track) continue;
818 if (!mode) // Check track observables
820 if (fTrackMomenta[1]>fTrackMomenta[0]) // Selection on P
822 if (abs(fLogic)==1) fSelect=-1; // Selections are made in logical "(n)and"
823 val=track->GetMomentum(1);
824 if (val>=fTrackMomenta[0] && val<=fTrackMomenta[1])
827 if (abs(fLogic)==2) return; // Selections are made in logical "(n)or"
830 if (fTrackMomenta[3]>fTrackMomenta[2]) // Selection on Pt
832 if (abs(fLogic)==1) fSelect=-1; // Selections are made in logical "(n)and"
834 if (val>=fTrackMomenta[2] && val<=fTrackMomenta[3])
837 if (abs(fLogic)==2) return; // Selections are made in logical "(n)or"
840 if (fTrackMomenta[5]>fTrackMomenta[4]) // Selection on Pl
842 if (abs(fLogic)==1) fSelect=-1; // Selections are made in logical "(n)and"
844 if (val>=fTrackMomenta[4] && val<=fTrackMomenta[5])
847 if (abs(fLogic)==2) return; // Selections are made in logical "(n)or"
850 if (fTrackEnergies[1]>fTrackEnergies[0]) // Selection on E
852 if (abs(fLogic)==1) fSelect=-1; // Selections are made in logical "(n)and"
853 val=track->GetEnergy(1);
854 if (val>=fTrackEnergies[0] && val<=fTrackEnergies[1])
857 if (abs(fLogic)==2) return; // Selections are made in logical "(n)or"
860 if (fTrackEnergies[3]>fTrackEnergies[2]) // Selection on Et
862 if (abs(fLogic)==1) fSelect=-1; // Selections are made in logical "(n)and"
864 if (val>=fTrackEnergies[2] && val<=fTrackEnergies[3])
867 if (abs(fLogic)==2) return; // Selections are made in logical "(n)or"
870 if (fTrackEnergies[5]>fTrackEnergies[4]) // Selection on El
872 if (abs(fLogic)==1) fSelect=-1; // Selections are made in logical "(n)and"
874 if (val>=fTrackEnergies[4] && val<=fTrackEnergies[5])
877 if (abs(fLogic)==2) return; // Selections are made in logical "(n)or"
880 if (fTrackMasses[1]>fTrackMasses[0]) // Selection on M
882 if (abs(fLogic)==1) fSelect=-1; // Selections are made in logical "(n)and"
883 val=track->GetMass(1);
884 if (val>=fTrackMasses[0] && val<=fTrackMasses[1])
887 if (abs(fLogic)==2) return; // Selections are made in logical "(n)or"
890 if (fTrackCharges[1]>fTrackCharges[0]) // Selection on Q
892 if (abs(fLogic)==1) fSelect=-1; // Selections are made in logical "(n)and"
893 val=track->GetCharge();
894 if (val>=fTrackCharges[0] && val<=fTrackCharges[1])
897 if (abs(fLogic)==2) return; // Selections are made in logical "(n)or"
900 if (fTrackRapidities[1]>fTrackRapidities[0]) // Selection on Y
902 if (abs(fLogic)==1) fSelect=-1; // Selections are made in logical "(n)and"
903 val=track->GetRapidity();
904 if (val>=fTrackRapidities[0] && val<=fTrackRapidities[1])
907 if (abs(fLogic)==2) return; // Selections are made in logical "(n)or"
910 if (fTrackRapidities[3]>fTrackRapidities[2]) // Selection on Eta
912 if (abs(fLogic)==1) fSelect=-1; // Selections are made in logical "(n)and"
913 val=track->GetPseudoRapidity();
914 if (val>=fTrackRapidities[2] && val<=fTrackRapidities[3])
917 if (abs(fLogic)==2) return; // Selections are made in logical "(n)or"
920 if (fTrackDevices[1]>fTrackDevices[0]) // Selection on Ndev
922 if (abs(fLogic)==1) fSelect=-1; // Selections are made in logical "(n)and"
923 ival=track->GetNsignals(fTrackDevClass.Data());
924 if (ival>=fTrackDevices[0] && ival<=fTrackDevices[1])
927 if (abs(fLogic)==2) return; // Selections are made in logical "(n)or"
931 if (mode==1) // Check track direction w.r.t. external (astrophysical) objects
933 p=track->Get3Momentum();
934 if (fAstroDir<0) p*=-1;
935 ts=track->GetTimestamp();
936 if (!ts) ts=(AliTimestamp*)fEvt;
938 SetSignal(&p,"loc","T",ts,0,"Track");
939 TArrayI* arr=MatchRefSignal(fAstroDa,"deg",fAstroDt,"s");
946 } // End of loop over tracks of a certain name
947 } // End of loop over selected track names
949 ///////////////////////////////////////////////////////////////////////////
950 void AliEventSelector::Event()
952 // Check criteria for total event observables.
954 if (abs(fLogic)==1) fSelect=-1; // Selections are made in logical "(n)and"
956 if (fSelect>0) return; // Event is already flagged as select
960 if (fEventMomenta[1]>fEventMomenta[0]) // Selection on P
962 if (abs(fLogic)==1) fSelect=-1; // Selections are made in logical "(n)and"
963 val=fEvt->GetMomentum(1);
964 if (val>=fEventMomenta[0] && val<=fEventMomenta[1])
967 if (abs(fLogic)==2) return; // Selections are made in logical "(n)or"
970 if (fEventMomenta[3]>fEventMomenta[2]) // Selection on Pt
972 if (abs(fLogic)==1) fSelect=-1; // Selections are made in logical "(n)and"
974 if (val>=fEventMomenta[2] && val<=fEventMomenta[3])
977 if (abs(fLogic)==2) return; // Selections are made in logical "(n)or"
980 if (fEventMomenta[5]>fEventMomenta[4]) // Selection on Pl
982 if (abs(fLogic)==1) fSelect=-1; // Selections are made in logical "(n)and"
984 if (val>=fEventMomenta[4] && val<=fEventMomenta[5])
987 if (abs(fLogic)==2) return; // Selections are made in logical "(n)or"
990 if (fEventEnergies[1]>fEventEnergies[0]) // Selection on E
992 if (abs(fLogic)==1) fSelect=-1; // Selections are made in logical "(n)and"
993 val=fEvt->GetEnergy(1);
994 if (val>=fEventEnergies[0] && val<=fEventEnergies[1])
997 if (abs(fLogic)==2) return; // Selections are made in logical "(n)or"
1000 if (fEventEnergies[3]>fEventEnergies[2]) // Selection on Et
1002 if (abs(fLogic)==1) fSelect=-1; // Selections are made in logical "(n)and"
1004 if (val>=fEventEnergies[2] && val<=fEventEnergies[3])
1007 if (abs(fLogic)==2) return; // Selections are made in logical "(n)or"
1010 if (fEventEnergies[5]>fEventEnergies[4]) // Selection on El
1012 if (abs(fLogic)==1) fSelect=-1; // Selections are made in logical "(n)and"
1014 if (val>=fEventEnergies[4] && val<=fEventEnergies[5])
1017 if (abs(fLogic)==2) return; // Selections are made in logical "(n)or"
1020 if (fEventMasses[1]>fEventMasses[0]) // Selection on Minv
1022 if (abs(fLogic)==1) fSelect=-1; // Selections are made in logical "(n)and"
1023 val=fEvt->GetInvmass(1);
1024 if (val>=fEventMasses[0] && val<=fEventMasses[1])
1027 if (abs(fLogic)==2) return; // Selections are made in logical "(n)or"
1030 if (fEventCharges[1]>fEventCharges[0]) // Selection on Q
1032 if (abs(fLogic)==1) fSelect=-1; // Selections are made in logical "(n)and"
1033 val=fEvt->GetCharge();
1034 if (val>=fEventCharges[0] && val<=fEventCharges[1])
1037 if (abs(fLogic)==2) return; // Selections are made in logical "(n)or"
1040 if (fEventDevices[1]>fEventDevices[0]) // Selection on Ndev
1042 if (abs(fLogic)==1) fSelect=-1; // Selections are made in logical "(n)and"
1043 ival=fEvt->GetNdevices(fEventDevClass.Data());
1044 if (ival>=fEventDevices[0] && ival<=fEventDevices[1])
1047 if (abs(fLogic)==2) return; // Selections are made in logical "(n)or"
1050 if (fEventTracks[1]>fEventTracks[0]) // Selection on Ntrk
1052 if (abs(fLogic)==1) fSelect=-1; // Selections are made in logical "(n)and"
1053 if (fEventTrkName=="*")
1055 ival=fEvt->GetNtracks();
1059 ival=fEvt->GetNtracks(fEventTrkName);
1061 if (ival>=fEventTracks[0] && ival<=fEventTracks[1])
1064 if (abs(fLogic)==2) return; // Selections are made in logical "(n)or"
1067 if (fEventTracks[3]>fEventTracks[2]) // Selection on Ntkc
1069 if (abs(fLogic)==1) fSelect=-1; // Selections are made in logical "(n)and"
1070 ival=fEvt->GetNtracks(0,3,0);
1071 if (ival>=fEventTracks[2] && ival<=fEventTracks[3])
1074 if (abs(fLogic)==2) return; // Selections are made in logical "(n)or"
1077 if (fEventTracks[5]>fEventTracks[4]) // Selection on Ntk0
1079 if (abs(fLogic)==1) fSelect=-1; // Selections are made in logical "(n)and"
1080 ival=fEvt->GetNtracks(0,0,0);
1081 if (ival>=fEventTracks[4] && ival<=fEventTracks[5])
1084 if (abs(fLogic)==2) return; // Selections are made in logical "(n)or"
1087 if (fEventTracks[7]>fEventTracks[6]) // Selection on Ntk+
1089 if (abs(fLogic)==1) fSelect=-1; // Selections are made in logical "(n)and"
1090 ival=fEvt->GetNtracks(0,1,0);
1091 if (ival>=fEventTracks[6] && ival<=fEventTracks[7])
1094 if (abs(fLogic)==2) return; // Selections are made in logical "(n)or"
1097 if (fEventTracks[9]>fEventTracks[8]) // Selection on Ntk-
1099 if (abs(fLogic)==1) fSelect=-1; // Selections are made in logical "(n)and"
1100 ival=fEvt->GetNtracks(0,-1,0);
1101 if (ival>=fEventTracks[8] && ival<=fEventTracks[9])
1104 if (abs(fLogic)==2) return; // Selections are made in logical "(n)or"
1108 ///////////////////////////////////////////////////////////////////////////
1109 void AliEventSelector::Astro()
1111 // Check for matches with external objects.
1113 if (abs(fLogic)==1) fSelect=-1; // Selections are made in logical "(n)and"
1115 if (fSelect>0) return; // Event is already flagged as select
1117 // Check track directions w.r.t. external (astrophysical) objects
1124 // Check total event momentum direction w.r.t. external (astrophysical) objects
1128 p=fEvt->Get3Momentum();
1129 if (fAstroDir<0) p*=-1;
1130 SetSignal(&p,"loc","T",(AliTimestamp*)fEvt,0,"Event");
1131 TArrayI* arr=MatchRefSignal(fAstroDa,"deg",fAstroDt,"s");
1132 if (arr && fLogic) fSelect=1;
1136 // Check event position w.r.t. external (astrophysical) objects
1139 SetSignal((Ali3Vector*)fEvt,"loc","T",(AliTimestamp*)fEvt,0,"Event");
1140 TArrayI* arr=MatchRefSignal(fAstroDa,"deg",fAstroDt,"s");
1141 if (arr && fLogic) fSelect=1;
1145 ///////////////////////////////////////////////////////////////////////////
1146 TObject* AliEventSelector::Clone(const char* name) const
1148 // Make a deep copy of the current object and provide the pointer to the copy.
1149 // This memberfunction enables automatic creation of new objects of the
1150 // correct type depending on the object type, a feature which may be very useful
1151 // for containers when adding objects in case the container owns the objects.
1153 AliEventSelector* sel=new AliEventSelector(*this);
1156 if (strlen(name)) sel->SetName(name);
1160 ///////////////////////////////////////////////////////////////////////////