diff --git a/datamodel/datamodel/GenVertex.h b/datamodel/datamodel/GenVertex.h index ec1bc3b7..235614b5 100644 --- a/datamodel/datamodel/GenVertex.h +++ b/datamodel/datamodel/GenVertex.h @@ -1,7 +1,7 @@ #ifndef GenVertex_H #define GenVertex_H -// Not sure how it's defined. +// Time coordinate in cm // author: C. Bernet, B. Hegner #include "datamodel/Point.h" @@ -10,7 +10,7 @@ class GenVertex { public: Point Position; //Vertex position in cm - float Ctau; //Not sure how it's defined. + float Ctau; //Time coordinate in cm }; diff --git a/datamodel/datamodel/GenVertexHandle.h b/datamodel/datamodel/GenVertexHandle.h index 33826131..63b2daa9 100644 --- a/datamodel/datamodel/GenVertexHandle.h +++ b/datamodel/datamodel/GenVertexHandle.h @@ -5,7 +5,7 @@ #include -// Not sure how it's defined. +// Time coordinate in cm // author: C. Bernet, B. Hegner //forward declaration of GenVertex container diff --git a/datamodel/datamodel/LinkDef.h b/datamodel/datamodel/LinkDef.h index ff1adcaa..446fb4c2 100644 --- a/datamodel/datamodel/LinkDef.h +++ b/datamodel/datamodel/LinkDef.h @@ -28,14 +28,10 @@ #pragma link C++ class std::vector+; #pragma link C++ class TrackClusterHandle+; #pragma link C++ class TrackClusterCollection+; -#pragma link C++ class ParticleMCAssociation+; -#pragma link C++ class std::vector+; -#pragma link C++ class ParticleMCAssociationHandle+; -#pragma link C++ class ParticleMCAssociationCollection+; -#pragma link C++ class JetParticleAssociation+; -#pragma link C++ class std::vector+; -#pragma link C++ class JetParticleAssociationHandle+; -#pragma link C++ class JetParticleAssociationCollection+; +#pragma link C++ class Jet+; +#pragma link C++ class std::vector+; +#pragma link C++ class JetHandle+; +#pragma link C++ class JetCollection+; #pragma link C++ class MissingEnergy+; #pragma link C++ class std::vector+; #pragma link C++ class MissingEnergyHandle+; @@ -72,6 +68,10 @@ #pragma link C++ class std::vector+; #pragma link C++ class TrackClusterHitsAssociationHandle+; #pragma link C++ class TrackClusterHitsAssociationCollection+; +#pragma link C++ class ParticleMCParticleAssociation+; +#pragma link C++ class std::vector+; +#pragma link C++ class ParticleMCParticleAssociationHandle+; +#pragma link C++ class ParticleMCParticleAssociationCollection+; #pragma link C++ class VertexTrackAssociation+; #pragma link C++ class std::vector+; #pragma link C++ class VertexTrackAssociationHandle+; @@ -88,10 +88,10 @@ #pragma link C++ class std::vector+; #pragma link C++ class GenJetParticleAssociationHandle+; #pragma link C++ class GenJetParticleAssociationCollection+; -#pragma link C++ class Jet+; -#pragma link C++ class std::vector+; -#pragma link C++ class JetHandle+; -#pragma link C++ class JetCollection+; +#pragma link C++ class JetParticleAssociation+; +#pragma link C++ class std::vector+; +#pragma link C++ class JetParticleAssociationHandle+; +#pragma link C++ class JetParticleAssociationCollection+; #pragma link C++ class MET+; #pragma link C++ class std::vector+; #pragma link C++ class METHandle+; diff --git a/datamodel/datamodel/ParticleMCAssociationCollection.h b/datamodel/datamodel/ParticleMCAssociationCollection.h deleted file mode 100644 index 602556df..00000000 --- a/datamodel/datamodel/ParticleMCAssociationCollection.h +++ /dev/null @@ -1,105 +0,0 @@ -//AUTOMATICALLY GENERATED - DO NOT EDIT - -#ifndef ParticleMCAssociationCollection_H -#define ParticleMCAssociationCollection_H - -#include -#include -#include - -// albers specific includes -#include "albers/Registry.h" -#include "albers/CollectionBase.h" - -// datamodel specific includes -#include "datamodel/ParticleMCAssociation.h" -#include "datamodel/ParticleMCAssociationHandle.h" - -typedef std::vector ParticleMCAssociationVector; -typedef std::vector ParticleMCAssociationHandleContainer; - -class ParticleMCAssociationCollectionIterator { - - public: - ParticleMCAssociationCollectionIterator(int index, const ParticleMCAssociationCollection* collection) : m_index(index), m_collection(collection) {} - - bool operator!=(const ParticleMCAssociationCollectionIterator& x) const { - return m_index != x.m_index; //TODO: may not be complete - } - - const ParticleMCAssociationHandle operator*() const; - - const ParticleMCAssociationCollectionIterator& operator++() const { - ++m_index; - return *this; - } - - private: - mutable int m_index; - const ParticleMCAssociationCollection* m_collection; -}; - -/** -A Collection is identified by an ID. -*/ - -class ParticleMCAssociationCollection : public albers::CollectionBase { - -public: - typedef const ParticleMCAssociationCollectionIterator const_iterator; - - ParticleMCAssociationCollection(); -// ParticleMCAssociationCollection(ParticleMCAssociationVector* data, int collectionID); - ~ParticleMCAssociationCollection(){}; - - void clear(); - - /// Append a new object to the collection, and return a Handle to this object. - ParticleMCAssociationHandle create(); - - /// Insert an existing handle into the collection. - /// In this operation, the data pointed by the handle is copied. - ParticleMCAssociationHandle insert(const ParticleMCAssociationHandle& origin); - - /// Returns a Handle to the object at position index in the collection - const ParticleMCAssociationHandle& get(int index) const; - - /// Currently does nothing - void prepareForWrite(const albers::Registry* registry); - void prepareAfterRead(albers::Registry* registry); - void setPODsAddress(const void* address); - - void setID(unsigned ID){m_collectionID = ID;}; - - // support for the iterator protocol - const const_iterator begin() const { - return const_iterator(0, this); - } - const const_iterator end() const { - return const_iterator(m_handles.size(), this); - } - -// std::vector>& referenceCollections(); - - /// returns the address of the pointer to the data buffer - void* _getRawBuffer() { return (void*)&m_data;}; - - /// returns the pointer to the data buffer - std::vector* _getBuffer() { return m_data;}; - - /// returns the collection of Handles - const ParticleMCAssociationHandleContainer& getHandles() { return m_handles; } - - /// print some information - void print() const; - - -private: - unsigned m_collectionID; - ParticleMCAssociationVector* m_data; - ParticleMCAssociationHandleContainer m_handles; - // members to handle 1-to-N-relations - -}; - -#endif \ No newline at end of file diff --git a/datamodel/datamodel/ParticleMCAssociation.h b/datamodel/datamodel/ParticleMCParticleAssociation.h similarity index 71% rename from datamodel/datamodel/ParticleMCAssociation.h rename to datamodel/datamodel/ParticleMCParticleAssociation.h index 4e15b6f4..bf4695ed 100644 --- a/datamodel/datamodel/ParticleMCAssociation.h +++ b/datamodel/datamodel/ParticleMCParticleAssociation.h @@ -1,5 +1,5 @@ -#ifndef ParticleMCAssociation_H -#define ParticleMCAssociation_H +#ifndef ParticleMCParticleAssociation_H +#define ParticleMCParticleAssociation_H // Reference to the Monte-Carlo particle // author: C. Bernet, B. Hegner @@ -8,7 +8,7 @@ #include "datamodel/MCParticleHandle.h" -class ParticleMCAssociation { +class ParticleMCParticleAssociation { public: ParticleHandle Rec; //Reference to the reconstructed particle MCParticleHandle Sim; //Reference to the Monte-Carlo particle diff --git a/datamodel/datamodel/ParticleMCParticleAssociationCollection.h b/datamodel/datamodel/ParticleMCParticleAssociationCollection.h new file mode 100644 index 00000000..8c9f0139 --- /dev/null +++ b/datamodel/datamodel/ParticleMCParticleAssociationCollection.h @@ -0,0 +1,105 @@ +//AUTOMATICALLY GENERATED - DO NOT EDIT + +#ifndef ParticleMCParticleAssociationCollection_H +#define ParticleMCParticleAssociationCollection_H + +#include +#include +#include + +// albers specific includes +#include "albers/Registry.h" +#include "albers/CollectionBase.h" + +// datamodel specific includes +#include "datamodel/ParticleMCParticleAssociation.h" +#include "datamodel/ParticleMCParticleAssociationHandle.h" + +typedef std::vector ParticleMCParticleAssociationVector; +typedef std::vector ParticleMCParticleAssociationHandleContainer; + +class ParticleMCParticleAssociationCollectionIterator { + + public: + ParticleMCParticleAssociationCollectionIterator(int index, const ParticleMCParticleAssociationCollection* collection) : m_index(index), m_collection(collection) {} + + bool operator!=(const ParticleMCParticleAssociationCollectionIterator& x) const { + return m_index != x.m_index; //TODO: may not be complete + } + + const ParticleMCParticleAssociationHandle operator*() const; + + const ParticleMCParticleAssociationCollectionIterator& operator++() const { + ++m_index; + return *this; + } + + private: + mutable int m_index; + const ParticleMCParticleAssociationCollection* m_collection; +}; + +/** +A Collection is identified by an ID. +*/ + +class ParticleMCParticleAssociationCollection : public albers::CollectionBase { + +public: + typedef const ParticleMCParticleAssociationCollectionIterator const_iterator; + + ParticleMCParticleAssociationCollection(); +// ParticleMCParticleAssociationCollection(ParticleMCParticleAssociationVector* data, int collectionID); + ~ParticleMCParticleAssociationCollection(){}; + + void clear(); + + /// Append a new object to the collection, and return a Handle to this object. + ParticleMCParticleAssociationHandle create(); + + /// Insert an existing handle into the collection. + /// In this operation, the data pointed by the handle is copied. + ParticleMCParticleAssociationHandle insert(const ParticleMCParticleAssociationHandle& origin); + + /// Returns a Handle to the object at position index in the collection + const ParticleMCParticleAssociationHandle& get(int index) const; + + /// Currently does nothing + void prepareForWrite(const albers::Registry* registry); + void prepareAfterRead(albers::Registry* registry); + void setPODsAddress(const void* address); + + void setID(unsigned ID){m_collectionID = ID;}; + + // support for the iterator protocol + const const_iterator begin() const { + return const_iterator(0, this); + } + const const_iterator end() const { + return const_iterator(m_handles.size(), this); + } + +// std::vector>& referenceCollections(); + + /// returns the address of the pointer to the data buffer + void* _getRawBuffer() { return (void*)&m_data;}; + + /// returns the pointer to the data buffer + std::vector* _getBuffer() { return m_data;}; + + /// returns the collection of Handles + const ParticleMCParticleAssociationHandleContainer& getHandles() { return m_handles; } + + /// print some information + void print() const; + + +private: + unsigned m_collectionID; + ParticleMCParticleAssociationVector* m_data; + ParticleMCParticleAssociationHandleContainer m_handles; + // members to handle 1-to-N-relations + +}; + +#endif \ No newline at end of file diff --git a/datamodel/datamodel/ParticleMCAssociationHandle.h b/datamodel/datamodel/ParticleMCParticleAssociationHandle.h similarity index 58% rename from datamodel/datamodel/ParticleMCAssociationHandle.h rename to datamodel/datamodel/ParticleMCParticleAssociationHandle.h index aaada1db..ae05574c 100644 --- a/datamodel/datamodel/ParticleMCAssociationHandle.h +++ b/datamodel/datamodel/ParticleMCParticleAssociationHandle.h @@ -1,6 +1,6 @@ -#ifndef ParticleMCAssociationHANDLE_H -#define ParticleMCAssociationHANDLE_H -#include "datamodel/ParticleMCAssociation.h" +#ifndef ParticleMCParticleAssociationHANDLE_H +#define ParticleMCParticleAssociationHANDLE_H +#include "datamodel/ParticleMCParticleAssociation.h" #include "datamodel/ParticleHandle.h" #include "datamodel/MCParticleHandle.h" @@ -9,34 +9,34 @@ // Reference to the Monte-Carlo particle // author: C. Bernet, B. Hegner -//forward declaration of ParticleMCAssociation container -class ParticleMCAssociationCollection; +//forward declaration of ParticleMCParticleAssociation container +class ParticleMCParticleAssociationCollection; namespace albers { class Registry; } -class ParticleMCAssociationHandle { +class ParticleMCParticleAssociationHandle { - friend class ParticleMCAssociationCollection; + friend class ParticleMCParticleAssociationCollection; public: - ParticleMCAssociationHandle() : + ParticleMCParticleAssociationHandle() : m_index(-1), m_containerID(0), m_container(0), m_registry(0) {} - ParticleMCAssociationHandle(const ParticleMCAssociationHandle& other) : + ParticleMCParticleAssociationHandle(const ParticleMCParticleAssociationHandle& other) : m_index(other.m_index), m_containerID(other.m_containerID), m_container(other.m_container), m_registry(other.m_registry) {} -//TODO: Proper syntax to use, but ROOT doesn't handle it: ParticleMCAssociationHandle() = default; +//TODO: Proper syntax to use, but ROOT doesn't handle it: ParticleMCParticleAssociationHandle() = default; @@ -44,10 +44,10 @@ class ParticleMCAssociationHandle { bool isAvailable() const; // returns a const (read-only) reference to the object pointed by the Handle. - const ParticleMCAssociation& read() const {return m_container->at(m_index);} + const ParticleMCParticleAssociation& read() const {return m_container->at(m_index);} // returns a non-const (writeable) reference to the object pointed by the Handle - ParticleMCAssociation& mod() {return m_container->at(m_index);} + ParticleMCParticleAssociation& mod() {return m_container->at(m_index);} void prepareForWrite(const albers::Registry*); // use m_container to set m_containerID properly @@ -58,19 +58,19 @@ class ParticleMCAssociationHandle { int containerID() const {return m_containerID;} /// equality operator (true if both the index and the container ID are equal) - bool operator==(const ParticleMCAssociationHandle& other) const { + bool operator==(const ParticleMCParticleAssociationHandle& other) const { return (m_index==other.m_index) && (other.m_containerID==other.m_containerID); } /// less comparison operator, so that Handles can be e.g. stored in sets. - friend bool operator< (const ParticleMCAssociationHandle& p1, - const ParticleMCAssociationHandle& p2 ); + friend bool operator< (const ParticleMCParticleAssociationHandle& p1, + const ParticleMCParticleAssociationHandle& p2 ); private: - ParticleMCAssociationHandle(int index, unsigned containerID, std::vector* container); + ParticleMCParticleAssociationHandle(int index, unsigned containerID, std::vector* container); int m_index; unsigned m_containerID; - mutable std::vector* m_container; //! transient + mutable std::vector* m_container; //! transient albers::Registry* m_registry; //! transient // bool _retrieveData(); // members to support 1-to-N relations diff --git a/datamodel/src/ParticleMCAssociationCollection.cc b/datamodel/src/ParticleMCAssociationCollection.cc deleted file mode 100644 index 8ab5fe17..00000000 --- a/datamodel/src/ParticleMCAssociationCollection.cc +++ /dev/null @@ -1,73 +0,0 @@ -#include "datamodel/ParticleMCAssociationCollection.h" - -ParticleMCAssociationCollection::ParticleMCAssociationCollection() : m_collectionID(0), m_data(new ParticleMCAssociationVector() ){ -} - -const ParticleMCAssociationHandle& ParticleMCAssociationCollection::get(int index) const{ - return m_handles[index]; -} - -ParticleMCAssociationHandle ParticleMCAssociationCollection::create() { - m_data->emplace_back(ParticleMCAssociation()); - int index = m_data->size()-1; - // std::cout<<"creating handle: "<emplace_back(origin.read()); - int index = m_data->size()-1; - m_handles.emplace_back(ParticleMCAssociationHandle(index,m_collectionID, m_data)); - - return m_handles.back(); -} - -void ParticleMCAssociationCollection::clear(){ - m_data->clear(); - m_handles.clear(); - -} - -void ParticleMCAssociationCollection::prepareForWrite(const albers::Registry* registry){ - for(auto& data : *m_data){ - data.Rec.prepareForWrite(registry); - data.Sim.prepareForWrite(registry); - } -} - -void ParticleMCAssociationCollection::prepareAfterRead(albers::Registry* registry){ - m_handles.clear(); - int index = 0; - // fix. otherwise, m_collectionID == 0.. - m_collectionID = registry->getIDFromPODAddress( _getBuffer() ); - for (auto& data : *m_data){ - data.Rec.prepareAfterRead(registry); -data.Sim.prepareAfterRead(registry); - - m_handles.emplace_back(ParticleMCAssociationHandle(index,m_collectionID, m_data)); - ++index; - } -} - - -void ParticleMCAssociationCollection::setPODsAddress(const void* address){ - m_data = (ParticleMCAssociationVector*)address; -} - - -const ParticleMCAssociationHandle ParticleMCAssociationCollectionIterator::operator* () const { - return m_collection->get(m_index); -} - -//std::vector>& referenceCollections() { -//} - - -void ParticleMCAssociationCollection::print() const { - std::cout<<"collection "<getIDFromPODAddress(m_container); -} - -void ParticleMCAssociationHandle::prepareAfterRead(albers::Registry* registry){ - m_registry = registry; - m_registry->getPODAddressFromID(m_containerID,m_container); -} - - -ParticleMCAssociationHandle::ParticleMCAssociationHandle(int index, unsigned containerID, std::vector* container) : - m_index(index), - m_containerID(containerID), - m_container(container) -{} - - -bool operator< (const ParticleMCAssociationHandle& p1, const ParticleMCAssociationHandle& p2 ) { - if( p1.m_containerID == p2.m_containerID ) { - return p1.m_index < p2.m_index; - } - else { - return p1.m_containerID < p2.m_containerID; - } -} diff --git a/datamodel/src/ParticleMCParticleAssociationCollection.cc b/datamodel/src/ParticleMCParticleAssociationCollection.cc new file mode 100644 index 00000000..3e123854 --- /dev/null +++ b/datamodel/src/ParticleMCParticleAssociationCollection.cc @@ -0,0 +1,73 @@ +#include "datamodel/ParticleMCParticleAssociationCollection.h" + +ParticleMCParticleAssociationCollection::ParticleMCParticleAssociationCollection() : m_collectionID(0), m_data(new ParticleMCParticleAssociationVector() ){ +} + +const ParticleMCParticleAssociationHandle& ParticleMCParticleAssociationCollection::get(int index) const{ + return m_handles[index]; +} + +ParticleMCParticleAssociationHandle ParticleMCParticleAssociationCollection::create() { + m_data->emplace_back(ParticleMCParticleAssociation()); + int index = m_data->size()-1; + // std::cout<<"creating handle: "<emplace_back(origin.read()); + int index = m_data->size()-1; + m_handles.emplace_back(ParticleMCParticleAssociationHandle(index,m_collectionID, m_data)); + + return m_handles.back(); +} + +void ParticleMCParticleAssociationCollection::clear(){ + m_data->clear(); + m_handles.clear(); + +} + +void ParticleMCParticleAssociationCollection::prepareForWrite(const albers::Registry* registry){ + for(auto& data : *m_data){ + data.Rec.prepareForWrite(registry); + data.Sim.prepareForWrite(registry); + } +} + +void ParticleMCParticleAssociationCollection::prepareAfterRead(albers::Registry* registry){ + m_handles.clear(); + int index = 0; + // fix. otherwise, m_collectionID == 0.. + m_collectionID = registry->getIDFromPODAddress( _getBuffer() ); + for (auto& data : *m_data){ + data.Rec.prepareAfterRead(registry); +data.Sim.prepareAfterRead(registry); + + m_handles.emplace_back(ParticleMCParticleAssociationHandle(index,m_collectionID, m_data)); + ++index; + } +} + + +void ParticleMCParticleAssociationCollection::setPODsAddress(const void* address){ + m_data = (ParticleMCParticleAssociationVector*)address; +} + + +const ParticleMCParticleAssociationHandle ParticleMCParticleAssociationCollectionIterator::operator* () const { + return m_collection->get(m_index); +} + +//std::vector>& referenceCollections() { +//} + + +void ParticleMCParticleAssociationCollection::print() const { + std::cout<<"collection "<getIDFromPODAddress(m_container); +} + +void ParticleMCParticleAssociationHandle::prepareAfterRead(albers::Registry* registry){ + m_registry = registry; + m_registry->getPODAddressFromID(m_containerID,m_container); +} + + +ParticleMCParticleAssociationHandle::ParticleMCParticleAssociationHandle(int index, unsigned containerID, std::vector* container) : + m_index(index), + m_containerID(containerID), + m_container(container) +{} + + +bool operator< (const ParticleMCParticleAssociationHandle& p1, const ParticleMCParticleAssociationHandle& p2 ) { + if( p1.m_containerID == p2.m_containerID ) { + return p1.m_index < p2.m_index; + } + else { + return p1.m_containerID < p2.m_containerID; + } +} diff --git a/edm_1.yaml b/edm_1.yaml index d0c4db48..8df7f9ac 100644 --- a/edm_1.yaml +++ b/edm_1.yaml @@ -109,7 +109,7 @@ datatypes : type: MCParticleHandle description: "The daughter." - ParticleMCAssociation: + ParticleMCParticleAssociation: description : "Association between a Particle and a MCParticle, used to keep track of the correspondance between MC and reconstruted particles" author : "C. Bernet, B. Hegner" members : @@ -363,7 +363,7 @@ datatypes : description: "Vertex position in cm" - name: Ctau type: float - description: "Not sure how it's defined." + description: "Time coordinate in cm" VertexTrackAssociation: description: "Association between a track and a vertex, with a weight"