NanoSliceOrder.cpp
Go to the documentation of this file.
1 /*
2  * File: NanoSliceOrder.cpp
3  * Author: denis
4  *
5  * Created on February 13, 2012, 4:04 PM
6  */
7 
8 #ifdef NOVACMAKE
10 #else
11 #include "MockDataDAQ/NanoSliceOrder.h"
12 #endif
13 
14 #include <iostream>
15 
16 #define BITFIELDGET(block, mask, shift) (((mask_t(block) )& mask) >> (shift))
17 #define BITFIELDSET(block, data, mask, shift) block = (((block) & ~mask)| ((mask_t(data) << shift ) & mask))
18 
19 namespace mcdatadaq{
20 
21 
22 NanoSliceOrder* NanoSliceOrder::finstanceID = NULL;
23 
24 //------------------------------------------------------------------------------
26  if(finstanceID == NULL){ // Check if there is an instance active
27  finstanceID = new NanoSliceOrder(); // If there is not, make a new one
28  }
29  return finstanceID;
30 }
31 
32 
33 //------------------------------------------------------------------------------
35 
36  /// Calculating shifts
42 
43  print();
44 }
45 
46 //------------------------------------------------------------------------------
48 
49 //------------------------------------------------------------------------------
51 
52  mask_t floating_digit = 1;
53 
54  for(shift_t idigit = 0; idigit < 64; idigit++){
55  if(mask & floating_digit) return idigit;
56  floating_digit <<= 1;
57  }// end of loop over digits
58 
59  return 0;
60 }
61 
62 //------------------------------------------------------------------------------
64  const shift_t shift,
65  const mask_t mask) const {
66  mask_t out_number = 0;
67  BITFIELDSET(out_number, number, shift, mask);
68 
69  return out_number;
70 }
71 
72 //------------------------------------------------------------------------------
76  const daqchannelmap::pixel_t pixel,
77  const feb_timestamp time) const
78 {
79  mask_t weight = 0;
80 
81  BITFIELDSET(weight, time , mask_time, shift_time);
82  BITFIELDSET(weight, diblock, mask_diblock, shift_diblock);
83  BITFIELDSET(weight, dcm , mask_dcm, shift_dcm);
84  BITFIELDSET(weight, feb , mask_feb, shift_feb);
85  BITFIELDSET(weight, pixel , mask_pixel, shift_pixel);
86 
87  return weight;
88 }
89 
90 //------------------------------------------------------------------------------
91 bool NanoSliceOrder::print() const {
92 
93  std::cout<<"shifts "<<shift_diblock;
94  std::cout<<" "<<shift_dcm;
95  std::cout<<" "<<shift_feb;
96  std::cout<<" "<<shift_time;
97  std::cout<<" "<<shift_pixel<<"\n";
98 
99  return true;
100 }
101 
102 //------------------------------------------------------------------------------
103 bool NanoSliceOrder::print(const mask_t number) const {
104 
105 
109  const daqchannelmap::pixel_t pixel = BITFIELDGET(number, mask_pixel , shift_pixel);
111 
112  std::cout<<std::hex<<number<<"x";
113  std::cout<<std::dec;
114  std::cout<<" diblock="<<diblock;
115  std::cout<<" dcm="<<dcm;
116  std::cout<<" feb="<<feb;
117  std::cout<<" pixel="<<pixel;
118  std::cout<<" time="<<time<<std::endl;
119 
120  return true;
121 }
122 
123 }// end of namespace
uint32_t shift_t
unsigned long long mask_t
diblock
print "ROW IS " print row
Definition: geo2elec.py:31
static NanoSliceOrder * finstanceID
Instance pointer for singleton class.
static const mask_t mask_feb
const Var weight
uint32_t pixel_t
Type for physical pixel on APD.
static NanoSliceOrder * getInstance()
Method to obtain the class instance.
static const mask_t mask_diblock
Internal masks which define the nanoslice order.
#define BITFIELDGET(block, mask, shift)
#define BITFIELDSET(block, data, mask, shift)
Something conflicts with RandomNumberGenerator. Keep DAQSimulator.h include below Art Framework inclu...
static const mask_t mask_pixel
uint32_t feb_t
Type for DCM link port. Counts from 0.
mask_t calculateOrderingWeight(const daqchannelmap::diblock_t, const daqchannelmap::dcm_id_t, const daqchannelmap::feb_t, const daqchannelmap::pixel_t, const feb_timestamp) const
shift_t shift_diblock
Corresponding shifts.
static const mask_t mask_time
mask_t getNumberWithShiftsAndMask(const uint32_t number, const shift_t shift, const mask_t mask) const
Calculate the weight using mask and shift for a given number.
OStream cout
Definition: OStream.cxx:6
uint32_t dcm_id_t
Type for DCM number, counts from 1.
static const mask_t mask_dcm
bool print() const
Printing shifts and masks.
uint32_t diblock_t
Type for diblocks and blocks.
shift_t calculateShiftFromMask(const mask_t mask) const
uint32_t feb_timestamp