00001
00002 #ifndef XAODMISSINGET_VERSIONS_MISSINGETASSOCIATION_v1_H
00003 #define XAODMISSINGET_VERSIONS_MISSINGETASSOCIATION_v1_H
00004
00005 #include "AthContainers/AuxElement.h"
00006
00007 #include "xAODBase/IParticle.h"
00008 #include "xAODBase/IParticleContainer.h"
00009
00010 #include "xAODMissingET/versions/MissingETCompositionBase.h"
00011 #include "xAODMissingET/versions/MissingET_v1.h"
00012
00013 #include <vector>
00014 #include <set>
00015
00016 namespace xAOD
00017 {
00019 class MissingETAssociation_v1 : public SG::AuxElement
00020 {
00021 public:
00022
00023 static bool testPolicy(unsigned int type, MissingETBase::UsageHandler::Policy p);
00024
00026 class ConstVec
00027 {
00028 public:
00029 ConstVec();
00030 ConstVec(double cpx,double cpy,double cpz,double ce,double sumpt);
00031 ConstVec(const IParticle& ipar);
00032
00033 ~ConstVec();
00036 double cpx() const;
00037 double cpy() const;
00038 double cpz() const;
00039 double cpt() const;
00040 double ce() const;
00041 double sumpt() const;
00045 void setCpx(double px);
00046 void setCpy(double py);
00047 void setCpz(double pz);
00048 void setCe (double e);
00049 void setSumpt (double sumpt);
00053 double& cpx();
00054 double& cpy();
00055 double& cpz();
00056 double& ce();
00057 double& sumpt();
00058 ConstVec& operator+=(const ConstVec& cvec);
00059 ConstVec& operator-=(const ConstVec& cvec);
00060 ConstVec& operator*=(double scale);
00061 ConstVec& operator/=(double scale);
00065 bool operator==(const ConstVec& cvec) const;
00066 bool operator!=(const ConstVec& cvec) const;
00068 private:
00071 double m_cpx;
00072 double m_cpy;
00073 double m_cpz;
00074 double m_ce;
00075 double m_sumpt;
00077 };
00078
00079 explicit MissingETAssociation_v1(bool createStore=false);
00080 MissingETAssociation_v1(const Jet* pjet, bool isMisc=false);
00081 MissingETAssociation_v1(const MissingETAssociation_v1& assocDescr);
00082 MissingETAssociation_v1& operator=(const MissingETAssociation_v1& assocDescr);
00083 virtual ~MissingETAssociation_v1();
00090 bool setRefJet(const Jet* pJet);
00092 bool setRefJet(const JetContainer* pJetCont,size_t pJetIdx);
00098 bool addObject(const IParticle* pPart,const std::vector<const IParticle*>& constlist);
00105 const std::vector<double>& calpx() const;
00106 double calpx(const IParticle* pPart) const;
00107 double calpx(size_t keyIdx) const;
00108
00109 bool setCalPx(const std::vector<double>& calpxvec);
00110 bool setCalPx(size_t keyIdx,double calpx);
00111
00112 const std::vector<double>& calpy() const;
00113 double calpy(size_t keyIdx) const;
00114
00115 bool setCalPy(const std::vector<double>& calpyvec);
00116 bool setCalPy(size_t keyIdx,double calpy);
00117
00118 const std::vector<double>& calpz() const;
00119 double calpz(size_t keyIdx) const;
00120
00121 bool setCalPz(const std::vector<double>& calpzvec);
00122 bool setCalPz(size_t keyIdx,double calpz);
00123
00124 const std::vector<double>& cale() const;
00125 double cale(size_t keyIdx) const;
00126
00127 bool setCalE(const std::vector<double>& calevec);
00128 bool setCalE(size_t keyIdx,double cale);
00129
00130 const std::vector<double>& calsumpt() const;
00131 double calsumpt(size_t keyIdx) const;
00132
00133 bool setCalSumpt(const std::vector<double>& calsumptvec);
00134 bool setCalSumpt(size_t keyIdx,double calsumpt);
00135
00136 const std::vector<MissingETBase::Types::bitmask_t>& calkey() const;
00137 MissingETBase::Types::bitmask_t calkey(size_t keyIdx) const;
00138
00139 bool setCalKey(const std::vector<MissingETBase::Types::bitmask_t>& calkeyvec);
00140 bool setCalKey(size_t keyIdx,MissingETBase::Types::bitmask_t calkey);
00141
00142 bool setCalVec(size_t keyIdx,const ConstVec& cvec=ConstVec());
00143 bool setCalVec(size_t keyIdx,double calpx,double calpy,double calpz,double ce,double sumpt);
00144
00145 bool addCalVec(MissingETBase::Types::bitmask_t key,double calpx,double calpy,double calpz,double cale,double sumpt);
00146
00147 bool clearCalVecs();
00148
00150 const std::vector<double>& trkpx() const;
00151 double trkpx(size_t keyIdx) const;
00152
00153 bool setTrkPx(const std::vector<double>& trkpxvec);
00154 bool setTrkPx(size_t keyIdx,double trkpx);
00155
00156 const std::vector<double>& trkpy() const;
00157 double trkpy(size_t keyIdx) const;
00158
00159 bool setTrkPy(const std::vector<double>& trkpyvec);
00160 bool setTrkPy(size_t keyIdx,double trkpy);
00161
00162 const std::vector<double>& trkpz() const;
00163 double trkpz(size_t keyIdx) const;
00164
00165 bool setTrkPz(const std::vector<double>& trkpzvec);
00166 bool setTrkPz(size_t keyIdx,double trkpz);
00167
00168 const std::vector<double>& trke() const;
00169 double trke(size_t keyIdx) const;
00170
00171 bool setTrkE(const std::vector<double>& trkevec);
00172 bool setTrkE(size_t keyIdx,double trke);
00173
00174 const std::vector<double>& trksumpt() const;
00175 double trksumpt(size_t keyIdx) const;
00176
00177 bool setTrkSumpt(const std::vector<double>& trksumptvec);
00178 bool setTrkSumpt(size_t keyIdx,double trksumpt);
00179
00180 const std::vector<MissingETBase::Types::bitmask_t>& trkkey() const;
00181 MissingETBase::Types::bitmask_t trkkey(size_t keyIdx) const;
00182
00183 bool setTrkKey(const std::vector<MissingETBase::Types::bitmask_t>& trkkeyvec);
00184 bool setTrkKey(size_t keyIdx,MissingETBase::Types::bitmask_t trkkey);
00185
00186 bool setTrkVec(size_t keyIdx,const ConstVec& cvec=ConstVec());
00187 bool setTrkVec(size_t keyIdx,double trkpx,double trkpy,double trkpz,double trke,double sumpt);
00188
00189 bool addTrkVec(MissingETBase::Types::bitmask_t key,double trkpx,double trkpy,double trkpz,double ce,double sumpt);
00190
00191 bool clearTrkVecs();
00192
00194 double jettrkpx() const;
00195 double jettrkpy() const;
00196 double jettrkpz() const;
00197 double jettrke() const;
00198 double jettrksumpt() const;
00199
00200 void setJetTrkPx(double px);
00201 void setJetTrkPy(double py);
00202 void setJetTrkPz(double pz);
00203 void setJetTrkE(double e);
00204 void setJetTrkSumpt(double sumpt);
00205 void setJetTrkVec(const ConstVec& cvec=ConstVec());
00206 void setJetTrkVec(double px,double py,double pz,double ce,double sumpt);
00207
00208 const MissingETBase::Types::jetlink_t& jetLink() const;
00209 bool setJetLink(const MissingETBase::Types::jetlink_t& jetLnk);
00210 const MissingETBase::Types::objlink_vector_t& objectLinks() const;
00211 bool setObjectLinks(const MissingETBase::Types::objlink_vector_t& objLnks);
00213
00214 const std::vector<std::vector<size_t> >& overlapIndices() const;
00215 std::vector<size_t> overlapIndices(const IParticle* pPart) const;
00216 std::vector<size_t> overlapIndices(size_t objIdx) const;
00217
00218 const std::vector<std::vector<unsigned char> >& overlapTypes() const;
00219 std::vector<unsigned char> overlapTypes(const IParticle* pPart) const;
00220 std::vector<unsigned char> overlapTypes(size_t objIdx) const;
00221
00222 void clearOverlaps();
00223 bool setOverlaps(const std::vector<std::vector<size_t> >& overlapIndices,
00224 const std::vector<std::vector<unsigned char> >& overlapTypes);
00225 bool setOverlaps(const IParticle* pPart,const std::vector<size_t>& overlapIndices,
00226 const std::vector<unsigned char>& overlapTypes);
00227 bool setOverlaps(size_t objIdx,const std::vector<size_t>& overlapIndices,
00228 const std::vector<unsigned char>& overlapTypes);
00229 void setOverrideMom(std::map<const IParticle*,ConstVec> pOverride);
00230 std::map<const IParticle*,ConstVec> overrideMom();
00231 void addOverrideMom(std::map<const IParticle*,ConstVec> &pOverride);
00239 bool removeContrib(const IParticle* pPart);
00240 bool removeContrib(size_t objIdx);
00241 bool removeContrib();
00242 bool resetContrib(const IParticle* pPart);
00243 bool resetContrib(size_t objIdx);
00244 bool resetContrib();
00245 void resetCache();
00250 const Jet* refJet() const;
00251 const JetContainer* refJetContainer() const;
00252 size_t refJetIndex() const;
00253 std::vector<const IParticle*> objects() const;
00254 std::vector<const IParticle*> objects(std::vector<ConstVec>& calVecs,std::vector<ConstVec>& trkVecs) const;
00255 std::vector<const IParticle*> objects(const std::vector<double>*& calpxPtr,
00256 const std::vector<double>*& calpyPtr,
00257 const std::vector<double>*& calpzPtr,
00258 const std::vector<double>*& calePtr,
00259 const std::vector<double>*& calsumptPtr,
00260 const std::vector<double>*& trkpxPtr,
00261 const std::vector<double>*& trkpyPtr,
00262 const std::vector<double>*& trkpzPtr,
00263 const std::vector<double>*& trkePtr,
00264 const std::vector<double>*& trksumptPtr) const;
00265 ConstVec calVec(const IParticle* pPart) const;
00266 ConstVec calVec(size_t keyIdx) const;
00267 ConstVec trkVec(const IParticle* pPart) const;
00268 ConstVec trkVec(size_t keyIdx) const;
00269 ConstVec jetTrkVec() const;
00273 void setObjSelectionFlag(size_t objIdx, bool status) const;
00274 void setObjSelectionFlag(const IParticle* pPart, bool status) const;
00275 void resetObjSelectionFlags() const;
00277 bool objSelected(size_t objIdx) const;
00278 bool objSelected(const IParticle* pPart) const;
00280 bool addOverlap(const IParticle* pPart,size_t index, unsigned char type);
00281 bool addOverlap(size_t objIdx,size_t index, unsigned char type);
00283 bool identifyOverlaps();
00284 bool identifyOverlaps(size_t objIdx);
00285 bool identifyOverlaps(const IParticle* pPart);
00287 bool hasOverlaps(size_t objIdx,MissingETBase::UsageHandler::Policy p=MissingETBase::UsageHandler::OnlyCluster) const;
00289 bool hasOverlaps(const IParticle* pPart,
00290 MissingETBase::UsageHandler::Policy p=MissingETBase::UsageHandler::OnlyCluster) const;
00293 bool hasAlternateConstVec() const;
00294 xAOD::JetFourMom_t getAlternateConstVec() const;
00295
00296 ConstVec overlapCalVec() const;
00297 ConstVec overlapTrkVec() const;
00299 bool containsSignal(const IParticle* pSig) const;
00300 bool containsPhysics(const IParticle* pPhys) const;
00301 bool checkUsage(const IParticle* pSig,MissingETBase::UsageHandler::Policy p) const;
00302 bool isMisc() const;
00324 size_t findIndex(const IParticle* pPart) const;
00326 size_t findCalIndex(MissingETBase::Types::bitmask_t mask) const;
00327 size_t findTrkIndex(MissingETBase::Types::bitmask_t mask) const;
00328
00336 void updateLinks();
00338 void updateJetLink();
00339 size_t size() const;
00340 size_t sizeCal() const;
00341 size_t sizeTrk() const;
00343 bool empty() const;
00351 bool operator==(const MissingETAssociation_v1& contrib) const;
00352 bool operator!=(const MissingETAssociation_v1& contrib) const;
00355 protected:
00357 void createPrivateStore();
00358
00365 MissingETBase::Types::objlink_vector_t& f_objectLinks();
00366 MissingETBase::Types::jetlink_t& f_jetLink();
00367
00368 std::vector<double>& f_calpx();
00369 std::vector<double>& f_calpy();
00370 std::vector<double>& f_calpz();
00371 std::vector<double>& f_cale();
00372 std::vector<double>& f_calsumpt();
00373 std::vector<MissingETBase::Types::bitmask_t>& f_calkey();
00374
00375 std::vector<double>& f_trkpx();
00376 std::vector<double>& f_trkpy();
00377 std::vector<double>& f_trkpz();
00378 std::vector<double>& f_trke();
00379 std::vector<double>& f_trksumpt();
00380 std::vector<MissingETBase::Types::bitmask_t>& f_trkkey();
00381
00382 double& f_jettrkpx();
00383 double& f_jettrkpy();
00384 double& f_jettrkpz();
00385 double& f_jettrke();
00386 double& f_jettrksumpt();
00387
00388 char& f_isMisc();
00389
00390 std::vector<std::vector<size_t> >& f_overlapIndices();
00391 std::vector<std::vector<unsigned char> >& f_overlapTypes();
00399 bool f_removeContrib(size_t objIdx);
00400 void copyData(const MissingETAssociation_v1& assocDescr);
00413 template<class POBJ,class LINK> void f_setObject(const POBJ* pObj,LINK& elemLink);
00414 template<class LINK> bool f_setLink(LINK& elemLink);
00419 void initCache();
00423 mutable std::vector<std::vector<ElementLink<IParticleContainer> > > m_objConstLinks;
00425 mutable MissingETBase::Types::bitmask_t m_useObjectFlags;
00426
00427 mutable std::vector<const IParticle*> m_contribObjects;
00428
00430 private:
00431 mutable std::map<const IParticle*,ConstVec> m_override;
00434 mutable const IParticle* m_lastObjectPointer;
00435 mutable size_t m_lastObjectIndex;
00438 static size_t m_objConstLinkReserve;
00439 static size_t m_contribObjReserve;
00440
00441 };
00442 }
00443
00444 namespace MissingETBase
00445 {
00446 namespace Types
00447 {
00448 typedef xAOD::MissingETAssociation_v1::ConstVec constvec_t;
00449 typedef std::vector<constvec_t> constvec_vector_t;
00450 }
00451 }
00452
00457 MissingETBase::Types::constvec_t operator+(const MissingETBase::Types::constvec_t& v0,const MissingETBase::Types::constvec_t& v2);
00459 MissingETBase::Types::constvec_t operator-(const MissingETBase::Types::constvec_t& v0,const MissingETBase::Types::constvec_t& v2);
00461 MissingETBase::Types::constvec_t operator*(const MissingETBase::Types::constvec_t& cvec,double scale);
00463 MissingETBase::Types::constvec_t operator*(double scale,const MissingETBase::Types::constvec_t& cvec);
00465 MissingETBase::Types::constvec_t operator/(const MissingETBase::Types::constvec_t& cvec,double scale);
00467 #include "xAODMissingET/versions/MissingETAssociation_v1.icc"
00468 #endif