CMS 3D CMS Logo

DTRangeT0.cc
Go to the documentation of this file.
1 /*
2  * See header file for a description of this class.
3  *
4  * \author Paolo Ronchese INFN Padova
5  *
6  */
7 
8 //----------------------
9 // This Class' Header --
10 //----------------------
12 
13 //-------------------------------
14 // Collaborating Class Headers --
15 //-------------------------------
17 
18 //---------------
19 // C++ Headers --
20 //---------------
21 #include <iostream>
22 #include <sstream>
23 
24 //-------------------
25 // Initializations --
26 //-------------------
27 
28 //----------------
29 // Constructors --
30 //----------------
31 DTRangeT0::DTRangeT0() : dataVersion(" "), dBuf(new DTBufferTree<int, int>) { dataList.reserve(1000); }
32 
33 DTRangeT0::DTRangeT0(const std::string& version) : dataVersion(version), dBuf(new DTBufferTree<int, int>) {
34  dataList.reserve(1000);
35 }
36 
37 DTRangeT0Id::DTRangeT0Id() : wheelId(0), stationId(0), sectorId(0), slId(0) {}
38 
39 DTRangeT0Data::DTRangeT0Data() : t0min(0), t0max(0) {}
40 
41 //--------------
42 // Destructor --
43 //--------------
45 
47 
49 
50 //--------------
51 // Operations --
52 //--------------
53 int DTRangeT0::get(int wheelId, int stationId, int sectorId, int slId, int& t0min, int& t0max) const {
54  t0min = t0max = 0;
55 
56  std::vector<int> chanKey;
57  chanKey.reserve(4);
58  chanKey.push_back(wheelId);
59  chanKey.push_back(stationId);
60  chanKey.push_back(sectorId);
61  chanKey.push_back(slId);
62  int ientry;
63  //Guarantee const correctness for thread-safety
64  const DTBufferTree<int, int>* constDBuf = dBuf;
65  int searchStatus = constDBuf->find(chanKey.begin(), chanKey.end(), ientry);
66  if (!searchStatus) {
67  const DTRangeT0Data& data(dataList[ientry].second);
68  t0min = data.t0min;
69  t0max = data.t0max;
70  }
71 
72  return searchStatus;
73 }
74 
75 int DTRangeT0::get(const DTSuperLayerId& id, int& t0min, int& t0max) const {
76  return get(id.wheel(), id.station(), id.sector(), id.superLayer(), t0min, t0max);
77 }
78 
79 const std::string& DTRangeT0::version() const { return dataVersion; }
80 
82 
84  dataList.clear();
85  initialize();
86  return;
87 }
88 
89 int DTRangeT0::set(int wheelId, int stationId, int sectorId, int slId, int t0min, int t0max) {
90  std::vector<int> chanKey;
91  chanKey.reserve(4);
92  chanKey.push_back(wheelId);
93  chanKey.push_back(stationId);
94  chanKey.push_back(sectorId);
95  chanKey.push_back(slId);
96  int ientry;
97  int searchStatus = dBuf->find(chanKey.begin(), chanKey.end(), ientry);
98 
99  if (!searchStatus) {
100  DTRangeT0Data& data(dataList[ientry].second);
101  data.t0min = t0min;
102  data.t0max = t0max;
103  return -1;
104  } else {
106  key.wheelId = wheelId;
107  key.stationId = stationId;
108  key.sectorId = sectorId;
109  key.slId = slId;
111  data.t0min = t0min;
112  data.t0max = t0max;
113  ientry = dataList.size();
114  dataList.push_back(std::pair<DTRangeT0Id, DTRangeT0Data>(key, data));
115  dBuf->insert(chanKey.begin(), chanKey.end(), ientry);
116  return 0;
117  }
118 
119  return 99;
120 }
121 
122 int DTRangeT0::set(const DTSuperLayerId& id, int t0min, int t0max) {
123  return set(id.wheel(), id.station(), id.sector(), id.superLayer(), t0min, t0max);
124 }
125 
127 
129 
131  std::stringstream name;
132  name << dataVersion << "_map_RangeT0" << this;
133  return name.str();
134 }
135 
137  dBuf->clear();
138 
139  int entryNum = 0;
140  int entryMax = dataList.size();
141  std::vector<int> chanKey;
142  chanKey.reserve(4);
143  while (entryNum < entryMax) {
144  const DTRangeT0Id& chan = dataList[entryNum].first;
145 
146  chanKey.clear();
147  chanKey.push_back(chan.wheelId);
148  chanKey.push_back(chan.stationId);
149  chanKey.push_back(chan.sectorId);
150  chanKey.push_back(chan.slId);
151  dBuf->insert(chanKey.begin(), chanKey.end(), entryNum++);
152  }
153  return;
154 }
DTSuperLayerId
Definition: DTSuperLayerId.h:12
DTRangeT0::mapName
std::string mapName() const
read and store full content
Definition: DTRangeT0.cc:130
DTRangeT0::DTRangeT0
DTRangeT0()
Definition: DTRangeT0.cc:31
DTRangeT0::version
const std::string & version() const
access version
Definition: DTRangeT0.cc:79
DTRangeT0.h
relativeConstraints.station
station
Definition: relativeConstraints.py:67
DTBufferTree::clear
void clear()
edm::second
U second(std::pair< T, U > const &p)
Definition: ParameterSet.cc:222
DTRangeT0Id::~DTRangeT0Id
~DTRangeT0Id()
Definition: DTRangeT0.cc:46
DTRangeT0Data::~DTRangeT0Data
~DTRangeT0Data()
Definition: DTRangeT0.cc:48
DTRangeT0Data
Definition: DTRangeT0.h:52
DTRangeT0Data::DTRangeT0Data
DTRangeT0Data()
Definition: DTRangeT0.cc:39
DTRangeT0Id
Definition: DTRangeT0.h:39
DTBufferTree::insert
int insert(ElementKey fKey, ElementKey lKey, Content cont)
DTRangeT0::set
int set(int wheelId, int stationId, int sectorId, int slId, int t0min, int t0max)
Definition: DTRangeT0.cc:89
DTRangeT0::dataList
std::vector< std::pair< DTRangeT0Id, DTRangeT0Data > > dataList
Definition: DTRangeT0.h:111
DTRangeT0::end
const_iterator end() const
Definition: DTRangeT0.cc:128
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
DTBufferTree.h
DTRangeT0::get
int get(int wheelId, int stationId, int sectorId, int slId, int &t0min, int &t0max) const
Definition: DTRangeT0.cc:53
DTRangeT0::~DTRangeT0
~DTRangeT0()
Definition: DTRangeT0.cc:44
DTRangeT0::const_iterator
std::vector< std::pair< DTRangeT0Id, DTRangeT0Data > >::const_iterator const_iterator
Access methods to data.
Definition: DTRangeT0.h:99
makeMuonMisalignmentScenario.wheel
wheel
Definition: makeMuonMisalignmentScenario.py:319
createfilelist.int
int
Definition: createfilelist.py:10
DTBufferTree
Definition: DTBufferTree.h:42
DTRangeT0Id::DTRangeT0Id
DTRangeT0Id()
Definition: DTRangeT0.cc:37
officialStyle.chan
chan
lumi = TPaveText(lowX+0.38, lowY+0.061, lowX+0.45, lowY+0.161, "NDC") lumi.SetBorderSize( 0 ) lumi....
Definition: officialStyle.py:106
DTRangeT0::begin
const_iterator begin() const
Definition: DTRangeT0.cc:126
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
DTRangeT0::dataVersion
std::string dataVersion
Definition: DTRangeT0.h:109
DTRangeT0::clear
void clear()
reset content
Definition: DTRangeT0.cc:83
DTBufferTree::find
int find(ElementKey fKey, ElementKey lKey, typename DTBufferTreeTrait< Content >::outputTypeOfConstFind &cont) const
crabWrapper.key
key
Definition: crabWrapper.py:19
BeamSplash_cfg.version
version
Definition: BeamSplash_cfg.py:45
DTRangeT0::dBuf
DTBufferTree< int, int > * dBuf
Definition: DTRangeT0.h:113
DTRangeT0::initialize
void initialize()
Definition: DTRangeT0.cc:136