Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alignment geometry upgrade 81X #13976

Merged
merged 11 commits into from Apr 26, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
85 changes: 0 additions & 85 deletions Alignment/CommonAlignment/interface/AlignSetup.h

This file was deleted.

71 changes: 0 additions & 71 deletions Alignment/CommonAlignment/interface/AlignableBuilder.h

This file was deleted.

73 changes: 73 additions & 0 deletions Alignment/CommonAlignment/interface/AlignableCompositeBuilder.h
@@ -0,0 +1,73 @@
#ifndef ALIGNMENT_COMMONALIGNMENT_INTERFACE_ALIGNABLECOMPOSITEBUILDER_H_
#define ALIGNMENT_COMMONALIGNMENT_INTERFACE_ALIGNABLECOMPOSITEBUILDER_H_

// Original Author: Max Stark
// Created: Wed, 10 Feb 2016 14:02:51 CET

// alignment
#include "Alignment/CommonAlignment/interface/AlignableMap.h"
#include "Alignment/CommonAlignment/interface/AlignableComposite.h"
#include "Alignment/CommonAlignment/interface/AlignableIndexer.h"
#include "Alignment/CommonAlignment/interface/AlignmentLevel.h"



class AlignableCompositeBuilder {

//========================== PUBLIC METHODS =================================
public: //===================================================================

AlignableCompositeBuilder(const TrackerTopology*, AlignableIndexer&);
virtual ~AlignableCompositeBuilder() {};

/// Add all desired AlignmentLevels for a sub-detector to the builder before
/// calling buildAll(), the order matters!
/// Example for PixelBarrel-RunI geometry:
/// -> PXBModule, PXBLadder, TPBLayer, TPBHalfBarrel, TPBBarrel
void addAlignmentLevel(AlignmentLevel* level);

/// Resets the alignment-levels.
void clearAlignmentLevels();

/// Builds all composite Alignables according to the levels added before via
/// addAlignmentLevel(). The Alignables were built from bottom- to the top-
/// hierarchy, e.g. for PixelBarrel-RunI geometry:
/// - PXBLadder (with PXBModule as children)
/// - TPBLayer (with PXBLadder as children)
/// - TPBHalfBarrel (with TPBLayer as children)
/// - TPBBarrel (with TPBHalfBarrel as children)
/// Returns the number of composite Alignables which were built.
unsigned int buildAll(AlignableMap&);

//========================= PRIVATE METHODS =================================
private: //==================================================================

/// Builds the components for a given level in the hierarchy.
unsigned int buildLevel(unsigned int parentLevel, AlignableMap&,
std::ostringstream&);

/// Calculates the theoretical max. number of components for a given level
/// in the hierarchy.
unsigned int maxNumComponents(unsigned int startLevel) const;

/// Calculates the index of an Alignable within the hierarchy; unique for
/// each component of a given structure-type.
unsigned int getIndexOfStructure(align::ID, unsigned int level) const;

//========================== PRIVATE DATA ===================================
//===========================================================================

// TODO: The AlignableCompositeBuilder is not 'common' as the package
// suggests, because it uses the TrackerTopology. If this class shall
// ever be used to build other kinds of alignables than tracker-
// alignables one has to add/implement something more general than
// the TrackerTopology
const TrackerTopology* trackerTopology;

AlignableIndexer alignableIndexer;

std::vector<AlignmentLevel*> alignmentLevels;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could this become an unique_ptr? (otherwise you need to clean up the memory in this class, as it seems to get ownership of the pointers)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@davidlange6, if I understand the code correctly, the memory is cleaned up here:
https://github.com/vbotta/cmssw/blob/AlignmentGeometryUpgrade_81X/Alignment/TrackerAlignment/src/TrackerAlignmentLevelBuilder.cc#L32-L42

However, using smart pointers should, of course, be preferred. But it should be a shared_ptr in this case, if I am not mistaken.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think, my comment was wrong because the objects deleted in the code referenced by me are vectors of pointers to std::vector<AlignmentLevel*>. Need to check further, how to fix that...

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@davidlange6, my initial comment was right, i.e. the objects get deleted in the destructor of 'TrackerAlignmentLevelBuilder'
Since, @vbotta is currently ill, we would get some delay until she pushed the changes to use smart pointers here. That is, in case of no exception we have no leak, so should we proceed now and update the code in a separate PR?


};

#endif /* ALIGNMENT_COMMONALIGNMENT_INTERFACE_ALIGNABLECOMPOSITEBUILDER_H_ */
4 changes: 2 additions & 2 deletions Alignment/CommonAlignment/interface/AlignableExtras.h
Expand Up @@ -13,8 +13,8 @@
*/

#include "Alignment/CommonAlignment/interface/Alignable.h"
#include "Alignment/CommonAlignment/interface/AlignableMap.h"
#include "Alignment/CommonAlignment/interface/Utilities.h"
#include "Alignment/CommonAlignment/interface/AlignSetup.h"

class AlignableExtras
{
Expand Down Expand Up @@ -49,7 +49,7 @@ class AlignableExtras

private:

AlignSetup<Alignables> alignableLists_; //< kind of map of lists of alignables
AlignableMap alignableLists_; //< kind of map of lists of alignables
Alignables components_; //< list of alignables
};

Expand Down
@@ -1,19 +1,22 @@
#ifndef Alignment_CommonAlignment_Counters_H
#define Alignment_CommonAlignment_Counters_H

/** \class Counters
/** \class AlignableIndexer
*
* Class to store a list of counters.
* Class to store a list of index functions.
*
* A counter is a pointer to a function that returns the number of an
* alignable based on its id.
* The number of an alignable is given by its position within its parent.
* User gets a counter using its structure type via Counters::get(type).
* User gets a counter using its structure type via AlignableIndexer::get(type).
* Each sub-system has its own concrete counter class implementation.
*
* $Date: 2007/10/18 09:41:07 $
* $Revision: 1.2 $
* \author Chung Khim Lae
*
* Last Update: Max Stark
* Date: Wed, 17 Feb 2016 15:39:06 CET
*/

#include <map>
Expand All @@ -27,14 +30,14 @@ namespace align
typedef unsigned int (*Counter)(align::ID, const TrackerTopology*);
}

class Counters
class AlignableIndexer
{
public:

/// Build the counters map.
Counters() {}
AlignableIndexer() {}

virtual ~Counters() {}
virtual ~AlignableIndexer() {}

/// Get a counter based on its structure type.
virtual align::Counter get( align::StructureType ) const;
Expand Down
53 changes: 53 additions & 0 deletions Alignment/CommonAlignment/interface/AlignableMap.h
@@ -0,0 +1,53 @@
#ifndef Alignment_CommonAlignment_AlignSetup_h
#define Alignment_CommonAlignment_AlignSetup_h

/** \class AlignableMap
*
* A helper class to hold Alignables used by modules in alignment.
*
* Alignables are stored in a map<string, Alignables>. Users get Alignables
* by passing the corresponding name through the method get(), if the name
* doesn't exist a new entry will be created. The find()-method also delivers
* Alignables per name, but it does not created new entries and will throw an
* error in case of an unknown name.
*
* $Date: 2008/02/12 18:06:49 $
* $Revision: 1.3 $
* \author Chung Khim Lae
*
* Last Update: Max Stark
* Date: Mon, 22 Feb 2016 19:58:45 CET
*/

#include <map>
#include <sstream>

#include "Alignment/CommonAlignment/interface/Alignable.h"



class AlignableMap
{
typedef typename std::map<std::string, Alignables> Container;

public:

AlignableMap() {};
virtual ~AlignableMap() {};

/// Get an object from map using its name.
/// A new object is default-constructed if the name does not exist.
Alignables& get( const std::string& name = "" );

/// Find and return an object from map using its name.
/// Throw an exception if the name does not exist.
Alignables& find( const std::string& name = "" );

/// Print the name of all stored data
void dump( void ) const;

private:
Container theStore;
};

#endif
10 changes: 10 additions & 0 deletions Alignment/CommonAlignment/interface/AlignableObjectId.h
Expand Up @@ -11,6 +11,16 @@ class AlignableObjectId

public:
AlignableObjectId(){};

/// sets entries-pointer to names of RunI geometry
static void isRunIGeometry();

/// sets entries-pointer to names of PhaseI geometry
static void isPhaseIGeometry();

/// sets entries-pointer to names of PhaseII geometry
static void isPhaseIIGeometry();

/// Convert name to type
align::StructureType nameToType( const std::string &name ) const;

Expand Down