8 #ifndef _LinkAssociations_
9 #define _LinkAssociations_
26 inline bool SortByROCID(
const T*
const &obj1,
const T*
const &obj2)
28 return obj1->rocid < obj2->rocid;
35 inline bool SortByModule(
const T*
const &obj1,
const T*
const &obj2)
37 if(obj1->rocid < obj2->rocid)
return true;
38 if(obj1->rocid > obj2->rocid)
return false;
39 return obj1->slot < obj2->slot;
48 if(obj1->rocid < obj2->rocid )
return true;
49 if(obj1->rocid > obj2->rocid )
return false;
50 if(obj1->slot < obj2->slot )
return true;
51 if(obj1->slot > obj2->slot )
return false;
52 return obj1->channel < obj2->channel;
61 if(obj1->rocid < obj2->rocid )
return true;
62 if(obj1->rocid > obj2->rocid )
return false;
63 if(obj1->slot < obj2->slot )
return true;
64 if(obj1->slot > obj2->slot )
return false;
65 if(obj1->channel < obj2->channel )
return true;
66 if(obj1->channel > obj2->channel )
return false;
67 return obj1->pulse_number < obj2->pulse_number;
84 template<
class T,
class U>
86 {
MatchConfigF(a, b, [](T *a, U *b){b->AddAssociatedObject(a);}); }
89 template<
class T,
class U>
91 {
MatchConfigF(a, b, [](T *a, U *b){b->AddAssociatedObject(a); b->nsamples_integral = a->NSA_NSB; b->nsamples_pedestal = a->NPED;}); }
94 template<
class T,
class U>
96 {
MatchModuleF(a, b, [](T *a, U *b){b->AddAssociatedObject(a);}); }
99 template<
class T,
class U>
101 {
MatchModuleF(a, b, [](T *a, U *b){b->AddAssociatedObject(a); b->nsamples_integral = a->NSA+a->NSB; b->nsamples_pedestal = a->NPED;}); }
104 template<
class T,
class U>
106 {
MatchChannelF(a, b, [](T *a, U *b){b->AddAssociatedObject(a); a->AddAssociatedObject(b);}); }
109 template<
class T,
class U>
111 {
MatchPulseF(a, b, [](T *a, U *b){b->AddAssociatedObject(a);}); }
114 template<
class T,
class U>
116 {
MatchPulseF(a, b, [](T *a, U *b){b->AddAssociatedObject(a); b->pedestal = a->pedestal;}); }
119 template<
class T,
class U>
121 {
MatchPulseF(a, b, [](T *a, U *b){b->pedestal = a->pedestal;}); }
127 template<
class T,
class U,
typename F>
131 uint32_t slot_mask = 1 << bptr->slot;
133 if(aptr->rocid!=bptr->rocid)
continue;
134 if(aptr->slot_mask & slot_mask){
144 template<
class T,
class U,
typename F>
149 if(aptr->rocid != bptr->rocid)
continue;
150 if(aptr->slot != bptr->slot )
continue;
159 template<
class T,
class U,
typename F>
164 if(aptr->rocid != bptr->rocid )
continue;
165 if(aptr->slot != bptr->slot )
continue;
166 if(aptr->channel!= bptr->channel)
continue;
175 template<
class T,
class U,
typename F>
180 if(aptr->rocid != bptr->rocid )
continue;
181 if(aptr->slot != bptr->slot )
continue;
182 if(aptr->channel != bptr->channel )
continue;
183 if(aptr->pulse_number != bptr->pulse_number)
continue;
204 template<
class T,
class U,
typename F>
216 if(b.empty())
return;
217 if(a.empty())
return;
219 for(uint32_t i=0, j=0; i<b.size(); ){
221 uint32_t rocid = b[i]->rocid;
226 for(; iend<b.size(); iend++){
227 if(b[iend]->rocid != rocid)
break;
232 for(; j<a.size(); j++){
233 if( a[j]->rocid >= rocid )
break;
235 if(j>=a.size())
break;
236 if( a[j]->rocid > rocid )
continue;
240 for(; jend<a.size(); jend++){
241 if(a[jend]->rocid != rocid)
break;
246 for(uint32_t ii=istart; ii<iend; ii++){
247 uint32_t slot_mask = 1 << b[ii]->slot;
249 for(uint32_t jj=jstart; jj<jend; jj++){
250 if(a[jj]->slot_mask & slot_mask){
257 if( i>=b.size() )
break;
258 if( j>=a.size() )
break;
265 template<
class T,
class U,
typename F>
276 if(b.empty())
return;
277 if(a.empty())
return;
279 for(uint32_t i=0, j=0; i<b.size(); ){
281 uint32_t rocid = b[i]->rocid;
282 uint32_t slot = b[i]->slot;
287 for(; iend<b.size(); iend++){
288 if(b[iend]->rocid != rocid)
break;
289 if(b[iend]->slot != slot )
break;
294 for(; j<a.size(); j++){
295 if( a[j]->rocid > rocid )
break;
296 if( a[j]->rocid == rocid ){
297 if( a[j]->slot >= slot )
break;
300 if(j>=a.size())
break;
302 if( a[j]->rocid > rocid )
continue;
303 if( a[j]->slot > slot )
continue;
307 for(; jend<a.size(); jend++){
308 if(a[jend]->rocid != rocid)
break;
309 if(a[jend]->slot != slot )
break;
314 for(uint32_t ii=istart; ii<iend; ii++){
315 for(uint32_t jj=jstart; jj<jend; jj++){
321 if( i>=b.size() )
break;
322 if( j>=a.size() )
break;
329 template<
class T,
class U,
typename F>
340 if(b.empty())
return;
341 if(a.empty())
return;
343 for(uint32_t i=0, j=0; i<b.size(); ){
345 uint32_t rocid = b[i]->rocid;
346 uint32_t slot = b[i]->slot;
347 uint32_t channel = b[i]->channel;
352 for(; iend<b.size(); iend++){
353 if(b[iend]->rocid != rocid )
break;
354 if(b[iend]->slot != slot )
break;
355 if(b[iend]->channel != channel )
break;
360 for(; j<a.size(); j++){
361 if( a[j]->rocid > rocid )
break;
362 if( a[j]->rocid == rocid ){
363 if( a[j]->slot > slot )
break;
364 if( a[j]->slot == slot ){
365 if( a[j]->channel >= channel )
break;
369 if(j>=a.size())
break;
371 if( a[j]->rocid > rocid )
continue;
372 if( a[j]->slot > slot )
continue;
373 if( a[j]->channel > channel )
continue;
377 for(; jend<a.size(); jend++){
378 if(a[jend]->rocid != rocid )
break;
379 if(a[jend]->slot != slot )
break;
380 if(a[jend]->channel != channel )
break;
385 for(uint32_t ii=istart; ii<iend; ii++){
386 for(uint32_t jj=jstart; jj<jend; jj++){
392 if( i>=b.size() )
break;
393 if( j>=a.size() )
break;
400 template<
class T,
class U,
typename F>
412 if(b.empty())
return;
413 if(a.empty())
return;
415 for(uint32_t i=0, j=0; i<b.size(); ){
417 uint32_t rocid = b[i]->rocid;
418 uint32_t slot = b[i]->slot;
419 uint32_t channel = b[i]->channel;
420 uint32_t pulse_number = b[i]->pulse_number;
425 for(; iend<b.size(); iend++){
426 if(b[iend]->rocid != rocid )
break;
427 if(b[iend]->slot != slot )
break;
428 if(b[iend]->channel != channel )
break;
429 if(b[iend]->pulse_number != pulse_number )
break;
434 for(; j<a.size(); j++){
435 if( a[j]->rocid > rocid )
break;
436 if( a[j]->rocid == rocid ){
437 if( a[j]->slot > slot )
break;
438 if( a[j]->slot == slot ){
439 if( a[j]->channel > channel )
break;
440 if( a[j]->channel == channel ){
441 if( a[j]->pulse_number >= pulse_number )
break;
446 if(j>=a.size())
break;
448 if( a[j]->rocid > rocid )
continue;
449 if( a[j]->slot > slot )
continue;
450 if( a[j]->channel > channel )
continue;
451 if( a[j]->pulse_number > pulse_number )
continue;
455 for(; jend<a.size(); jend++){
456 if(a[jend]->rocid != rocid )
break;
457 if(a[jend]->slot != slot )
break;
458 if(a[jend]->channel != channel )
break;
459 if(a[jend]->pulse_number != pulse_number )
break;
464 for(uint32_t ii=istart; ii<iend; ii++){
465 for(uint32_t jj=jstart; jj<jend; jj++){
471 if( i>=b.size() )
break;
472 if( j>=a.size() )
break;
476 #endif // _LinkAssociations_
void MatchConfig(vector< T * > &a, vector< U * > &b, F func)
void LinkChannel(vector< T * > &a, vector< U * > &b)
void PulsePedCopy(vector< T * > &a, vector< U * > &b)
void LinkConfigSamplesCopy(vector< T * > &a, vector< U * > &b)
void MatchPulse(vector< T * > &a, vector< U * > &b, F func)
void LinkModuleBORSamplesCopy(vector< T * > &a, vector< U * > &b)
void MatchPulseF(vector< T * > &a, vector< U * > &b, F func)
void LinkConfig(vector< T * > &a, vector< U * > &b)
void LinkPulse(vector< T * > &a, vector< U * > &b)
bool SortByChannel(const T *const &obj1, const T *const &obj2)
void MatchChannel(vector< T * > &a, vector< U * > &b, F func)
void MatchConfigF(vector< T * > &a, vector< U * > &b, F func)
bool SortByPulseNumber(const T *const &obj1, const T *const &obj2)
void LinkPulsePedCopy(vector< T * > &a, vector< U * > &b)
bool SortByModule(const T *const &obj1, const T *const &obj2)
double func(double *x, double *par)
void MatchModule(vector< T * > &a, vector< U * > &b, F func)
bool SortByROCID(const T *const &obj1, const T *const &obj2)
void MatchChannelF(vector< T * > &a, vector< U * > &b, F func)
void LinkModule(vector< T * > &a, vector< U * > &b)
void MatchModuleF(vector< T * > &a, vector< U * > &b, F func)