ATLAS Offline Software
Loading...
Searching...
No Matches
ExtractCondensedIBLhits.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3*/
4
12
14#include <iostream>
15
16
17unsigned int shiftRight(unsigned int &number, const int shifting){
18 return number >> shifting;
19}
20
21// overload shiftRight function to take into account that the TOT is integer instead of unsigned int
22int shiftRight(int &number, const int shifting){
23 return number >> shifting;
24}
25
26
27
28unsigned int divideHits ( unsigned int &sourceWord, const unsigned int startBit, const unsigned int endBit){
29 unsigned int targetWord = shiftRight (sourceWord, startBit);
30 // cout << "source Word: " << std::hex << sourceWord << "\t"<< std::dec << "start bit: "<< startBit << "\t"<< "end bit: " << endBit << "\t";
31 int length = endBit - startBit + 1;
32 // std::cout << "length: " << length;
33 unsigned int mask = 0;
34 switch (length)
35 {
36 case 7: mask = 0x7F; // mask for the column bits in the hitword
37 break;
38 case 8: mask = 0xFF; // mask for the tot bits in the hitword
39 break;
40 case 9: mask = 0x1FF; // mask for the row bits in the hitword
41 break;
42 }
43 if (mask == 0) {
44 std::cout << "error: length of the info is not correct " << std::endl;
45 }
46 targetWord &= mask;
47 //std::cout << " => after shifting & masking: " << std::hex << targetWord<< std::dec << std::endl;
48
49 return targetWord;
50}
51
52// overload the divideHits functions becaused the TOT is an int rather than an unsigned int
53int divideHits ( int &sourceWord, const unsigned int startBit, const unsigned int endBit){
54 int targetWord = shiftRight (sourceWord, startBit);
55 // cout << "source Word: " <<hex << sourceWord << "\t"<< dec << "start bit: "<< startBit << "\t"<< "end bit: " << endBit << "\t";
56 int length = endBit - startBit + 1;
57 // std::cout << "length: " << length;
58 unsigned int mask = 0;
59 switch (length)
60 {
61 case 8: mask = 0xFF; // mask for the tot bits in the hitword
62 break;
63 case 4: mask = 0xF; // mask for the row bits in the hitword
64 break;
65 }
66 if (mask == 0) {
67 std::cout << "error: length of the info is not correct " << std::endl;
68 }
69 targetWord &= mask;
70 //std::cout << " => after shifting & masking: " << std::hex << targetWord<< std::dec << std::endl;
71
72 return targetWord;
73}
unsigned int shiftRight(unsigned int &number, const int shifting)
unsigned int divideHits(unsigned int &sourceWord, const unsigned int startBit, const unsigned int endBit)
Push bits from a sourceWord to a target word, returns true if successful.
Header file for utility functions shiftRight and DivideHITS.
double length(const pvec &v)
std::string number(const double &d, const std::string &s)
Definition utils.cxx:186