1 #include "AliAnalysisMuMuCutCombination.h"
5 * \ingroup pwg-muon-mumu
7 * \class AliAnalysisMuMuCutCombination
9 * A cut combination is the real cut class that is used in the sub-analysis. It is composed
10 * of one or several AliAnalysisMuMuCutElement.
12 * Unlike the cut elements, it can be of several types at the same time (i.e. it can
13 * be an event cutter and a track cutter for instance). The work is done in the
18 #include "AliAnalysisMuMuCutElement.h"
20 #include "Riostream.h"
21 #include "AliInputEventHandler.h"
24 ClassImp(AliAnalysisMuMuCutCombination)
26 //_____________________________________________________________________________
27 AliAnalysisMuMuCutCombination::AliAnalysisMuMuCutCombination()
28 : TObject(), fCuts(0x0), fName(""),
29 fIsEventCutter(kFALSE), fIsEventHandlerCutter(kFALSE),
30 fIsTrackCutter(kFALSE), fIsTrackPairCutter(kFALSE),
31 fIsTriggerClassCutter(kFALSE)
36 //_____________________________________________________________________________
37 AliAnalysisMuMuCutCombination::~AliAnalysisMuMuCutCombination()
43 //_____________________________________________________________________________
44 void AliAnalysisMuMuCutCombination::Add(AliAnalysisMuMuCutElement* ce)
46 /** Add a cut element to this combination, if the cut is not void and
47 * not already part of the combination
50 if (!ce || !ce->IsValid()) return;
54 fCuts = new TObjArray;
55 fCuts->SetOwner(kFALSE);
56 fIsEventCutter = ce->IsEventCutter();
57 fIsEventHandlerCutter = ce->IsEventHandlerCutter();
58 fIsTrackCutter = ce->IsTrackCutter();
59 fIsTrackPairCutter = ce->IsTrackPairCutter();
60 fIsTriggerClassCutter = ce->IsTriggerClassCutter();
63 if (!fCuts->FindObject(ce))
66 fName += ce->GetName();
68 fIsEventCutter = fIsEventCutter || ce->IsEventCutter();
69 fIsEventHandlerCutter = fIsEventHandlerCutter || ce->IsEventHandlerCutter();
70 fIsTrackCutter = fIsTrackCutter || ce->IsTrackCutter();
71 fIsTrackPairCutter = fIsTrackPairCutter || ce->IsTrackPairCutter();
72 fIsTriggerClassCutter = fIsTriggerClassCutter || ce->IsTriggerClassCutter();
78 if ( IsTrackPairCutter() )
80 if ( fName[0] == 's' )
84 else if ( fName[0] == 'p')
95 else if ( IsTrackCutter() )
110 //_____________________________________________________________________________
111 Bool_t AliAnalysisMuMuCutCombination::IsEqual(const TObject* obj) const
113 /// Whether or not we are the same cut combination as obj
115 if ( obj->IsA() != AliAnalysisMuMuCutCombination::Class() )
120 const AliAnalysisMuMuCutCombination* other = static_cast<const AliAnalysisMuMuCutCombination*>(obj);
122 if ( IsEventCutter() != other->IsEventCutter() ) return kFALSE;
123 if ( IsTrackCutter() != other->IsTrackCutter() ) return kFALSE;
124 if ( IsTrackPairCutter() != other->IsTrackPairCutter() ) return kFALSE;
125 if ( IsTriggerClassCutter() != other->IsTriggerClassCutter() ) return kFALSE;
127 if ( !fCuts && !other->fCuts ) return kTRUE;
129 // no cuts, nothing to check further...
131 if ( ( fCuts && !other->fCuts ) || ( !fCuts && other->fCuts ) ) return kFALSE;
133 if ( fCuts->GetEntries() != other->fCuts->GetEntries() ) return kFALSE;
135 // ok, looks similar so far, now have compute the set of cuts in common
136 // (whatever the order) to see if they really are the same combination or not
141 for ( Int_t i = 0; i <= fCuts->GetLast(); ++i )
143 AliAnalysisMuMuCutElement* thisCuti = static_cast<AliAnalysisMuMuCutElement*>(fCuts->At(i));
145 if ( other->fCuts->FindObject(thisCuti) )
151 for ( Int_t i = 0; i <= fCuts->GetLast(); ++i )
153 AliAnalysisMuMuCutElement* otherCuti = static_cast<AliAnalysisMuMuCutElement*>(other->fCuts->At(i));
155 if ( fCuts->FindObject(otherCuti) )
161 return (n1in2==n2in1 && n1in2==fCuts->GetLast()+1);
164 //_____________________________________________________________________________
165 Bool_t AliAnalysisMuMuCutCombination::Pass(const AliInputEventHandler& eventHandler) const
167 /// Whether or not the event handler is passing the cut
169 if (!fCuts) return kFALSE;
171 AliAnalysisMuMuCutElement* ce;
173 const AliVEvent* event = eventHandler.GetEvent();
175 Bool_t passEvent(kTRUE);
176 Bool_t passEventHandler(kTRUE);
178 while ( ( ce = static_cast<AliAnalysisMuMuCutElement*>(next()) ) )
180 if ( ce->IsEventCutter() && !ce->Pass(*event) )
185 if ( ce->IsEventHandlerCutter() && !ce->Pass(eventHandler) )
187 passEventHandler = kFALSE;
191 if ( IsEventCutter() && IsEventHandlerCutter() )
193 return passEvent && passEventHandler;
196 if ( IsEventHandlerCutter() )
198 return passEventHandler;
201 if ( IsEventCutter() )
210 //_____________________________________________________________________________
211 Bool_t AliAnalysisMuMuCutCombination::Pass(const AliVParticle& particle) const
213 /// Whether or not the particle is passing the cut
215 if (!fCuts) return kFALSE;
217 AliAnalysisMuMuCutElement* ce;
219 while ( ( ce = static_cast<AliAnalysisMuMuCutElement*>(next()) ) )
221 if (ce->IsTrackCutter() && !ce->Pass(particle))
230 //_____________________________________________________________________________
231 Bool_t AliAnalysisMuMuCutCombination::Pass(const AliVParticle& p1, const AliVParticle& p2) const
233 /// Whether or not the particle pair is passing the cut
235 if (!fCuts) return kFALSE;
237 AliAnalysisMuMuCutElement* ce;
239 while ( ( ce = static_cast<AliAnalysisMuMuCutElement*>(next()) ) )
241 if (ce->IsTrackPairCutter() && !ce->Pass(p1,p2))
250 //_____________________________________________________________________________
251 Bool_t AliAnalysisMuMuCutCombination::Pass(const TString& firedTriggerClasses,
252 TString& acceptedTriggerClasses,
253 UInt_t L0, UInt_t L1, UInt_t L2) const
255 /** Whether or not the firedTriggerClasses pass the cut.
256 * \param firedTriggerClasses (input) list of fired trigger classes (separated by space)
257 * \param acceptedTriggerClasses (output) list of accepted classes
258 * \param L0 (input, optional) level 0 trigger mask
259 * \param L1 (input, optional) level 1 trigger mask
260 * \param L2 (input, optional) level 2 trigger mask
263 if (!fCuts) return kFALSE;
265 AliAnalysisMuMuCutElement* ce;
268 // contrary to the other cut types, here we make a full loop on all
269 // the cuts, as we need to give each cut a chance to update the acceptedTriggerClasses
272 acceptedTriggerClasses = "";
274 while ( ( ce = static_cast<AliAnalysisMuMuCutElement*>(next()) ) )
278 if (ce->IsTriggerClassCutter() && ce->Pass(firedTriggerClasses,tmp,L0,L1,L2))
280 acceptedTriggerClasses += tmp;
281 acceptedTriggerClasses += " ";
289 //_____________________________________________________________________________
290 void AliAnalysisMuMuCutCombination::Print(Option_t* space) const
292 /// Printout of the cut combination
293 std::cout << Form("%s(%p) [",GetName(),this);
294 if ( IsEventCutter() ) std::cout << " E";
295 if ( IsEventHandlerCutter() ) std::cout << " EH";
296 if ( IsTrackCutter() ) std::cout << " T";
297 if ( IsTrackPairCutter() ) std::cout << " TP";
298 if ( IsTriggerClassCutter() ) std::cout << " TC";
299 std::cout << " ]" << std::endl;
302 AliAnalysisMuMuCutElement* ce;
304 while ( ( ce = static_cast<AliAnalysisMuMuCutElement*>(next()) ) )