ATLAS Offline Software
Loading...
Searching...
No Matches
LArTT_Selector.icc
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include "LArRecConditions/LArRoIMap.h"
6#include "LArRawUtils/LArTT_Sampling.h"
7
8// Implementation of const_iterator
9
10// constructor
11
12template <class CONTAINER >
13LArTT_Selector<CONTAINER>::const_iterator::const_iterator
14(const VEC_ITPAIR* v)
15{
16 m_vec_itpair = v;
17 m_pair_it = v->begin() ;
18 if(m_pair_it != v->end()){
19 m_obj_it = (*m_pair_it).first ;
20 m_obj_it_end = (*m_pair_it).second ;
21 }
22
23 return;
24}
25
26// constructor for end iterator
27template <class CONTAINER >
28LArTT_Selector<CONTAINER>::const_iterator::const_iterator
29(const VEC_ITPAIR* v, const ITPAIR_IT& it)
30{
31 m_vec_itpair = v;
32 m_pair_it = it ;
33
34 return;
35}
36
37template <class CONTAINER >
38LArTT_Selector<CONTAINER>::const_iterator::const_iterator
39()
40{
41 m_vec_itpair = NULL ;
42 return;
43}
44
45
46// ++ operator
47template <class CONTAINER >
48typename LArTT_Selector<CONTAINER>::const_iterator&
49LArTT_Selector<CONTAINER>::const_iterator:: operator ++ ()
50{
51 ++m_obj_it;
52 if(m_obj_it == m_obj_it_end) {
53 // end of this RoI, get next RoI
54 ++m_pair_it;
55 if(m_pair_it != m_vec_itpair->end() )
56 {
57 m_obj_it = (*m_pair_it).first;
58 m_obj_it_end = (*m_pair_it).second;
59 }
60 }
61
62 return *this;
63}
64
65
66// ++ operator
67template <class CONTAINER >
68typename LArTT_Selector<CONTAINER>::const_iterator
69LArTT_Selector<CONTAINER>::const_iterator:: operator ++ (int )
70{
71 const_iterator tmp = *this;
72 ++tmp;
73 return tmp;
74}
75
76
77// != operator
78template <class CONTAINER >
79bool
80LArTT_Selector<CONTAINER>::const_iterator:: operator !=
81 ( const LArTT_Selector<CONTAINER>::const_iterator & it ) const
82{
83 // compare m_pair_it first because for end, m_pair_it is end.
84 if(it.m_pair_it == it.m_vec_itpair->end() )
85 { return m_pair_it != it.m_pair_it ;
86 } else
87 return
88 m_pair_it != it.m_pair_it ||
89 m_obj_it != it.m_obj_it ||
90 m_obj_it_end != it.m_obj_it_end ||
91 m_vec_itpair != it.m_vec_itpair ;
92
93}
94
95// == operator
96template <class CONTAINER >
97bool
98LArTT_Selector<CONTAINER>::const_iterator:: operator ==
99 ( const LArTT_Selector<CONTAINER>::const_iterator & it ) const
100{
101 // compare m_map_it first because for end, m_map_it is end.
102
103 // if m_pair_it is end, only compare the pair iterator
104 if(m_pair_it == m_vec_itpair->end() )
105 return m_pair_it == it.m_pair_it ;
106
107 return
108 m_pair_it == it.m_pair_it &&
109 m_obj_it == it.m_obj_it &&
110 m_obj_it_end == it.m_obj_it_end &&
111 m_vec_itpair == it.m_vec_itpair ;
112}
113
114
115// == operator
116template <class CONTAINER >
117const typename LArTT_Selector<CONTAINER>::OBJECT *
118LArTT_Selector<CONTAINER>::const_iterator:: operator * ()
119{
120 return *m_obj_it;
121}
122/*************** Implementation of LArTT_Selector<CONTAINER>
123*
124*/
125
126// Constructor
127template <class CONTAINER >
128LArTT_Selector<CONTAINER> ::LArTT_Selector ( const LArRoIMap* m,
129 const CONTAINER* c ):
130m_roiMap(m),
131m_container(c)
132{
133
134}
135
136
137// set methods
138template <class CONTAINER >
139void LArTT_Selector<CONTAINER> :: setMap(const LArRoIMap* m) {
140 m_roiMap = m;
141}
142
143
144template <class CONTAINER >
145void LArTT_Selector<CONTAINER>::setContainer(const CONTAINER* c) {
146 m_container = c;
147}
148
149
150template <class CONTAINER >
151//void LArTT_Selector<CONTAINER> :: setRoIs( const VEC_TT_ID& ids,
152// int sam)
153void LArTT_Selector<CONTAINER> :: setRoIs ( const VEC_TT_ID& ids)
154{
155
156 // clean it up.
157 if(m_vecItPair.size() > 0 ) {
158 m_vecItPair.erase(m_vecItPair.begin(), m_vecItPair.end());
159 }
160
161 TT_ID_IT it = ids.begin();
162 TT_ID_IT it_end = ids.end() ;
163
164 // cout <<" Number of TTs "<<ids.size()<<endl;
165
166 for(; it!=it_end; ++it){
167 //
168 const TT_ID& rId = (*it);
169// LArTT_Sampling ttSam(rId,sam);
170// unsigned int combId = ttSam.combinedId();
171// std::vector<COLL_ID> cIDs =
172// m_roiMap->collectionID( combId );
173
174 unsigned int combId= (unsigned int) rId ;
175 const std::vector<COLL_ID>& cIDs =
176 m_roiMap->collectionID( combId );
177 COLL_ID_IT cId_it = cIDs.begin();
178 COLL_ID_IT cId_it_end = cIDs.end();
179 // cout<< " Number of Collections for this RoI"<<cIDs.size()<<endl;
180 for(; cId_it!=cId_it_end;++cId_it){
181 const COLL_ID& cId = (*cId_it);
182 // cout<< " Collections id "<<cId.id()<<endl;
183 COLL_IT coll_it = m_container->find(cId);
184 if(coll_it!=m_container->end()){
185 // Collection exist
186 const COLLECTION* coll = (*coll_it);
187 OBJ_IT b;
188 OBJ_IT e;
189 coll->getTT(combId,b,e);
190 if(b!=e){
191 m_vecItPair.push_back(ITPAIR(b,e) ) ;
192 }
193 // else
194 // cout <<" Nothing in this Collections "<<endl;
195 }
196 }
197 }
198
199
200}
201
202
203/*
204template <class CONTAINER >
205void LArTT_Selector<CONTAINER> :: setRoIs( const VEC_TT_SAM_ID& ids )
206{
207
208 // clean it up.
209 if(m_vecItPair.size() > 0 ) {
210 m_vecItPair.erase(m_vecItPair.begin(), m_vecItPair.end());
211 }
212
213 TT_SAM_ID_IT it = ids.begin();
214 TT_SAM_ID_IT it_end = ids.end() ;
215
216 // cout <<" Number of TTs "<<ids.size()<<endl;
217
218 for(; it!=it_end; ++it){
219 //
220 const TT_SAM_ID& rId = (*it);
221
222 std::vector<COLL_ID> cIDs =
223 m_roiMap->collectionID( rId );
224 COLL_ID_IT cId_it = cIDs.begin();
225 COLL_ID_IT cId_it_end = cIDs.end();
226 // cout<< " Number of Collections for this RoI"<<cIDs.size()<<endl;
227 for(; cId_it!=cId_it_end;++cId_it){
228 const COLL_ID& cId = (*cId_it);
229 // cout<< " Collections id "<<cId.id()<<endl;
230 COLL_IT coll_it = m_container->find(cId);
231 if(coll_it!=m_container->end()){
232 // Collection exist
233 const COLLECTION* coll = (*coll_it);
234 OBJ_IT b;
235 OBJ_IT e;
236 coll->getTT(rId,b,e);
237 if(b!=e){
238 m_vecItPair.push_back(ITPAIR(b,e) ) ;
239 }
240 // else
241 // cout <<" Nothing in this Collections "<<endl;
242 }
243 }
244 }
245
246
247}
248
249*/
250
251
252template <class CONTAINER >
253typename LArTT_Selector<CONTAINER>::const_iterator
254 LArTT_Selector<CONTAINER> ::begin() const
255{
256 return const_iterator(&m_vecItPair);
257}
258
259template <class CONTAINER >
260typename LArTT_Selector<CONTAINER>::const_iterator
261 LArTT_Selector<CONTAINER> ::end() const
262{
263 return const_iterator(&m_vecItPair, m_vecItPair.end() );
264}