9 bool trackIdHitPairLess(
const std::pair<unsigned int, const PSimHit*>&
a,
const std::pair<unsigned int, const PSimHit*>&
b) {
10 return a.first < b.first;
18 for(
const auto& simHitToken: simHitTokens) {
22 for(
const auto& simHit: *hsimhits) {
29 std::tuple<std::unique_ptr<edm::ValueMap<unsigned int>>,
30 std::unique_ptr<edm::ValueMap<unsigned int>>,
31 std::unique_ptr<edm::ValueMap<unsigned int>>>
39 std::vector<unsigned int> valuesLayers(tps.size(), 0);
40 std::vector<unsigned int> valuesPixelLayers(tps.size(), 0);
41 std::vector<unsigned int> valuesStripMonoAndStereoLayers(tps.size(), 0);
42 for(
size_t iTP=0; iTP<tps.size(); ++iTP) {
49 bool hasHit[maxSubdet][maxLayer];
50 bool hasPixel[maxSubdet][maxLayer];
51 bool hasMono[maxSubdet][maxLayer];
52 bool hasStereo[maxSubdet][maxLayer];
53 memset(hasHit, 0,
sizeof(hasHit));
54 memset(hasPixel, 0,
sizeof(hasPixel));
55 memset(hasMono, 0,
sizeof(hasMono));
56 memset(hasStereo, 0,
sizeof(hasStereo));
60 auto range = std::equal_range(
trackIdToHitPtr_.begin(),
trackIdToHitPtr_.end(), std::pair<unsigned int, const PSimHit *>(simTrack.trackId(),
nullptr), trackIdHitPairLess);
61 if(range.first == range.second)
continue;
63 auto iHitPtr = range.first;
64 int processType = iHitPtr->second->processType();
67 for(; iHitPtr != range.second; ++iHitPtr) {
68 const PSimHit& simHit = *(iHitPtr->second);
77 bool isStripStereo =
false;
78 bool isStripMono =
false;
86 isStripMono = tTopo.
tibIsRPhi(newDetector);
90 isStripMono = tTopo.
tidIsRPhi(newDetector);
94 isStripMono = tTopo.
tobIsRPhi(newDetector);
98 isStripMono = tTopo.
tecIsRPhi(newDetector);
103 const auto subdet = newDetector.
subdetId();
104 const auto layer = tTopo.
layer( newDetector );
106 hasHit[subdet][layer] =
true;
107 if(isPixel) hasPixel[subdet][layer] =
isPixel;
108 else if(isStripMono) hasMono[subdet][layer] = isStripMono;
109 else if(isStripStereo) hasStereo[subdet][layer] = isStripStereo;
115 unsigned int nLayers = 0;
118 for(
unsigned int i=0;
i<maxSubdet; ++
i) {
119 for(
unsigned int j=0;
j<maxLayer; ++
j) {
120 nLayers += hasHit[
i][
j];
121 nPixelLayers += hasPixel[
i][
j];
122 nStripMonoAndStereoLayers += (hasMono[
i][
j] && hasStereo[
i][
j]);
126 valuesLayers[iTP] = nLayers;
131 auto ret0 = std::make_unique<edm::ValueMap<unsigned int>>();
134 filler.
insert(htps, valuesLayers.begin(), valuesLayers.end());
137 auto ret1 = std::make_unique<edm::ValueMap<unsigned int>>();
140 filler.
insert(htps, valuesPixelLayers.begin(), valuesPixelLayers.end());
143 auto ret2 = std::make_unique<edm::ValueMap<unsigned int>>();
146 filler.
insert(htps, valuesStripMonoAndStereoLayers.begin(), valuesStripMonoAndStereoLayers.end());
const std::vector< SimTrack > & g4Tracks() const
std::vector< TrackingParticle > TrackingParticleCollection
bool tobIsStereo(const DetId &id) const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
int pdgId() const
PDG ID.
void insert(const H &h, I begin, I end)
bool tobIsRPhi(const DetId &id) const
bool tidIsStereo(const DetId &id) const
bool tecIsStereo(const DetId &id) const
bool tibIsRPhi(const DetId &id) const
EncodedEventId eventId() const
int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
bool tecIsRPhi(const DetId &id) const
std::vector< std::pair< unsigned int, const PSimHit * > > trackIdToHitPtr_
bool tidIsRPhi(const DetId &id) const
TrackingParticleNumberOfLayers(const edm::Event &iEvent, const std::vector< edm::EDGetTokenT< std::vector< PSimHit > > > &simHitTokens)
bool tibIsStereo(const DetId &id) const
unsigned short processType() const
unsigned int layer(const DetId &id) const
EncodedEventId eventId() const
Signal source, crossing number.
std::tuple< std::unique_ptr< edm::ValueMap< unsigned int > >, std::unique_ptr< edm::ValueMap< unsigned int > >, std::unique_ptr< edm::ValueMap< unsigned int > > > calculate(const edm::Handle< TrackingParticleCollection > &tps, const edm::EventSetup &iSetup) const
bool isPixel(HitType hitType)
Monte Carlo truth information used for tracking validation.
unsigned int detUnitId() const