CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 }
std::string mapName() const
read and store full content
Definition: DTRangeT0.cc:130
int wheelId
Definition: DTRangeT0.h:44
const_iterator end() const
Definition: DTRangeT0.cc:128
tuple chan
lumi = TPaveText(lowX+0.38, lowY+0.061, lowX+0.45, lowY+0.161, &quot;NDC&quot;) lumi.SetBorderSize( 0 ) lumi...
int get(int wheelId, int stationId, int sectorId, int slId, int &t0min, int &t0max) const
Definition: DTRangeT0.cc:53
std::string dataVersion
Definition: DTRangeT0.h:108
const std::string & version() const
access version
Definition: DTRangeT0.cc:79
int find(ElementKey fKey, ElementKey lKey, typename DTBufferTreeTrait< Content >::outputTypeOfConstFind &cont) const
U second(std::pair< T, U > const &p)
std::vector< std::pair< DTRangeT0Id, DTRangeT0Data > >::const_iterator const_iterator
Access methods to data.
Definition: DTRangeT0.h:101
std::vector< std::pair< DTRangeT0Id, DTRangeT0Data > > dataList
Definition: DTRangeT0.h:110
tuple key
prepare the HTCondor submission files and eventually submit them
void initialize()
Definition: DTRangeT0.cc:136
~DTRangeT0()
Definition: DTRangeT0.cc:44
void clear()
reset content
Definition: DTRangeT0.cc:83
int sectorId
Definition: DTRangeT0.h:46
const_iterator begin() const
Definition: DTRangeT0.cc:126
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
int insert(ElementKey fKey, ElementKey lKey, Content cont)
int set(int wheelId, int stationId, int sectorId, int slId, int t0min, int t0max)
Definition: DTRangeT0.cc:89
DTBufferTree< int, int > * dBuf
Definition: DTRangeT0.h:112
int stationId
Definition: DTRangeT0.h:45