Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
DD4hep
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cepc
externals
mirroring
DD4hep
Commits
ee362648
Commit
ee362648
authored
9 years ago
by
Markus Frank
Browse files
Options
Downloads
Patches
Plain Diff
Helper class to select Subdetectors
parent
846f2194
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
DDCore/include/DD4hep/DetectorSelector.h
+84
-0
84 additions, 0 deletions
DDCore/include/DD4hep/DetectorSelector.h
DDCore/src/DetectorSelector.cpp
+70
-0
70 additions, 0 deletions
DDCore/src/DetectorSelector.cpp
with
154 additions
and
0 deletions
DDCore/include/DD4hep/DetectorSelector.h
0 → 100644
+
84
−
0
View file @
ee362648
// $Id$
//==========================================================================
// AIDA Detector description implementation for LCD
//--------------------------------------------------------------------------
// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
// All rights reserved.
//
// For the licensing terms see $DD4hepINSTALL/LICENSE.
// For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
//
// Author : M.Frank
//
//==========================================================================
#ifndef DD4HEP_DETECTORSELECTOR_H
#define DD4HEP_DETECTORSELECTOR_H
// Framework include files
#include
"DD4hep/LCDD.h"
/// Namespace for the AIDA detector description toolkit
namespace
DD4hep
{
/// Namespace for the geometry part of the AIDA detector description toolkit
namespace
Geometry
{
/// View on LCDD to select detectors according to certain criteria
/**
* Usage:
*
* LCDD& lcd = ....;
* DetectorSelector selector(lcdd);
* DetectorSelector::Result r = selector.detectors("tracker");
*
* or multiple types:
* r = selector.detectors("tracker", "calorimeter");
*
* or selections using DetElement flags (DetElement::typeFlag)
* r = selector.detectors(0x15, 0xFF0);
*
* \author M.Frank
* \version 1.0
*/
class
DetectorSelector
{
public:
/// Result set definition
typedef
std
::
vector
<
DetElement
>
Result
;
/// Reference to main detector description object
LCDD
&
lcdd
;
public:
/// Default constructor
DetectorSelector
(
LCDD
&
_lcdd
)
:
lcdd
(
_lcdd
)
{}
/// Default destructor
~
DetectorSelector
()
{}
/// Access a set of subdetectors according to the sensitive type.
/**
Please note:
- The sensitive type of a detector is set in the 'detector constructor'.
- Not sensitive detector structures have the name 'passive'
- Compounds (ie. nested detectors) are of type 'compound'
*/
const
Result
&
detectors
(
const
std
::
string
&
type
);
/// Access a set of subdetectors according to several sensitive types.
Result
detectors
(
const
std
::
string
&
type1
,
const
std
::
string
&
type2
,
const
std
::
string
&
type3
=
""
,
const
std
::
string
&
type4
=
""
,
const
std
::
string
&
type5
=
""
);
/** return a vector with all detectors that have all the type properties in
* includeFlag set but none of the properties given in excludeFlag
*/
Result
detectors
(
unsigned
int
includeFlag
,
unsigned
int
excludeFlag
=
0
)
const
;
};
}
/* End namespace Geometry */
}
/* End namespace DD4hep */
#endif
/* DD4HEP_DETECTORSELECTOR_H */
This diff is collapsed.
Click to expand it.
DDCore/src/DetectorSelector.cpp
0 → 100644
+
70
−
0
View file @
ee362648
// $Id$
//==========================================================================
// AIDA Detector description implementation for LCD
//--------------------------------------------------------------------------
// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
// All rights reserved.
//
// For the licensing terms see $DD4hepINSTALL/LICENSE.
// For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
//
// Author : M.Frank
//
//==========================================================================
// Framework include files
#include
"DD4hep/DetectorSelector.h"
#include
"DD4hep/LCDD.h"
using
namespace
std
;
using
namespace
DD4hep
::
Geometry
;
/// Access a set of subdetectors according to the sensitive type.
const
DetectorSelector
::
Result
&
DetectorSelector
::
detectors
(
const
string
&
type
)
{
return
lcdd
.
detectors
(
type
);
}
/// Access a set of subdetectors according to several sensitive types.
DetectorSelector
::
Result
DetectorSelector
::
detectors
(
const
string
&
type1
,
const
string
&
type2
,
const
string
&
type3
,
const
string
&
type4
,
const
string
&
type5
)
{
const
string
*
types
[]
=
{
&
type1
,
&
type2
,
&
type3
,
&
type4
,
&
type5
};
Result
result
;
for
(
size_t
i
=
0
;
i
<
sizeof
(
types
)
/
sizeof
(
types
[
0
]);
++
i
)
{
try
{
if
(
!
types
[
i
]
->
empty
()
)
{
const
vector
<
DetElement
>&
v
=
lcdd
.
detectors
(
*
(
types
[
i
]));
result
.
insert
(
result
.
end
(),
v
.
begin
(),
v
.
end
());
}
}
catch
(...)
{}
}
return
result
;
}
/** return a vector with all detectors that have all the type properties in
* includeFlag set but none of the properties given in excludeFlag
*/
DetectorSelector
::
Result
DetectorSelector
::
detectors
(
unsigned
int
includeFlag
,
unsigned
int
excludeFlag
)
const
{
Result
result
;
const
LCDD
::
HandleMap
&
entries
=
lcdd
.
detectors
();
result
.
reserve
(
entries
.
size
()
)
;
lcdd
.
detectors
(
""
);
// Just to ensure the geometry is closed....
for
(
LCDD
::
HandleMap
::
const_iterator
i
=
entries
.
begin
();
i
!=
entries
.
end
();
++
i
)
{
DetElement
det
((
*
i
).
second
);
if
(
det
.
parent
().
isValid
()
)
{
// Exclude 'world'
//fixme: what to do with compounds - add their daughters ?
// ...
if
(
(
det
.
typeFlag
()
&
includeFlag
)
==
includeFlag
&&
(
det
.
typeFlag
()
&
excludeFlag
)
==
0
)
result
.
push_back
(
det
)
;
}
}
return
result
;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment