source: trunk/MagicSoft/Mars/mfilter/MFParticleId.cc@ 1454

Last change on this file since 1454 was 1337, checked in by tbretz, 23 years ago
*** empty log message ***
File size: 3.5 KB
Line 
1/* ======================================================================== *\
2!
3! *
4! * This file is part of MARS, the MAGIC Analysis and Reconstruction
5! * Software. It is distributed to you in the hope that it can be a useful
6! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
7! * It is distributed WITHOUT ANY WARRANTY.
8! *
9! * Permission to use, copy, modify and distribute this software and its
10! * documentation for any purpose is hereby granted without fee,
11! * provided that the above copyright notice appear in all copies and
12! * that both that copyright notice and this permission notice appear
13! * in supporting documentation. It is provided "as is" without express
14! * or implied warranty.
15! *
16!
17!
18! Author(s): Thomas Bretz 07/2001 <mailto:tbretz@uni-sw.gwdg.de>
19!
20! Copyright: MAGIC Software Development, 2000-2001
21!
22!
23\* ======================================================================== */
24
25/////////////////////////////////////////////////////////////////////////////
26// //
27// MFParticleId //
28// //
29/////////////////////////////////////////////////////////////////////////////
30
31#include "MFParticleId.h"
32
33#include "MParList.h"
34#include "MLog.h"
35#include "MLogManip.h"
36
37#include "MMcEvt.hxx"
38
39ClassImp(MFParticleId);
40
41
42// --------------------------------------------------------------------------
43//
44MFParticleId::MFParticleId(const char *cname, const char type, const Int_t val,
45 const char *name, const char *title) : fMcEvt(NULL)
46{
47 fContName = cname;
48 Init(type, val, name, title);
49}
50
51// --------------------------------------------------------------------------
52//
53MFParticleId::MFParticleId(const MMcEvt *mcevt, const char type, const Int_t val,
54 const char *name, const char *title) : fMcEvt(mcevt)
55{
56 Init(type, val, name, title);
57}
58
59// --------------------------------------------------------------------------
60//
61void MFParticleId::Init(const char type, const Int_t val,
62 const char *name, const char *title)
63{
64 fName = name ? name : "MFParticleId";
65 fTitle = title ? title : "Filter using monte carlo particle id";
66
67 fFilterType = (type=='=' ? kEEqual : kENotEqual);
68
69 if (type!='=' && type!='!')
70 *fLog << warn << dbginf << "Warning: Neither '=' nor '!' specified... using '>'." << endl;
71
72 fValue = val;
73
74 AddToBranchList(Form("%s.fPartId", (const char*)fContName));
75}
76
77// --------------------------------------------------------------------------
78//
79Bool_t MFParticleId::IsExpressionTrue() const
80{
81 return fResult;
82}
83
84// --------------------------------------------------------------------------
85//
86Bool_t MFParticleId::PreProcess(MParList *pList)
87{
88 if (fMcEvt)
89 return kTRUE;
90
91 fMcEvt = (MMcEvt*)pList->FindObject(fContName);
92 if (fMcEvt)
93 return kTRUE;
94
95 *fLog << err << dbginf << fContName << " [MMcEvt] not found... aborting." << endl;
96 return kFALSE;
97}
98
99// --------------------------------------------------------------------------
100//
101Bool_t MFParticleId::Process()
102{
103 const Int_t id = fMcEvt->GetPartId();
104
105 switch (fFilterType)
106 {
107 case kEEqual:
108 fResult = (id == fValue);
109 return kTRUE;
110 case kENotEqual:
111 fResult = (id != fValue);
112 return kTRUE;
113 }
114
115 *fLog << err << dbginf << "Operation unknown..." << endl;
116 return kFALSE;
117}
118
Note: See TracBrowser for help on using the repository browser.