CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ClusterSummary.cc
Go to the documentation of this file.
3 
5  : userContent(nullptr), genericVariablesTmp_(6, std::vector<double>(100,0) )
6 {
7 }
8 
10 {
11  delete userContent.load();
12  userContent = nullptr;
13 }
14 
15 // swap function
17 {
18  other.userContent.exchange(
19  userContent.exchange(other.userContent.load(std::memory_order_acquire), std::memory_order_acq_rel),
20  std::memory_order_acq_rel);
22  std::swap(modules_, other.modules_);
25 }
26 
27 // copy ctor
29  : userContent(nullptr), iterator_(src.iterator_), modules_(src.modules_),
30  genericVariables_(src.genericVariables_),
31  genericVariablesTmp_(src.genericVariablesTmp_)
32 {
33 }
34 
35 // copy assingment operator
37 {
38  ClusterSummary temp(rhs);
39  temp.swap(*this);
40  return *this;
41 }
42 
43 // move ctor
45  : ClusterSummary()
46 {
47  other.swap(*this);
48 }
49 
51 
52  int placeInModsVector = -1;
53 
54  int cnt = 0;
55  int pixelcnt = 0;
56  for(std::vector<int>::const_iterator it = modules_.begin(); it != modules_.end(); ++it) {
57  /*
58  if ( mod == (*it) ) {
59  placeInModsVector = cnt;
60  break;
61  }
62  else ++cnt;
63  */
64 
65  int mod_tmp = *it;
66  while (mod_tmp > 9 ){
67  mod_tmp /= 10;
68  }
69 
70  if ( mod_tmp < 5 ){
71 
72  if ( mod == (*it) ) {
73  placeInModsVector = cnt;
74  break;
75  }
76  else ++cnt;
77  }
78  else{
79  if ( mod == (*it) ) {
80  placeInModsVector = pixelcnt;
81  break;
82  }
83  else ++pixelcnt;
84  }
85  }
86 
87  if (placeInModsVector == -1){
88 
89  edm::LogWarning("NoModule") << "No information for requested module "<<mod<<". Please check in the Provinence Infomation for proper modules.";
90 
91  return -1;
92 
93  }
94 
95  return placeInModsVector;
96 
97 }
98 
100 
102 
103  for (unsigned int i = 0; i < (*userContent.load(std::memory_order_acquire)).size(); ++i){
105  }
106 }
107 
108 // Setter and Getter for the User Content. You can also return the size and what is stored in the UserContent
109 void ClusterSummary::SetUserContent(const std::vector<std::string>& Content) const
110 {
111  if(!userContent.load(std::memory_order_acquire)) {
112  auto ptr = new std::vector<std::string>;
113  for(auto i=Content.begin(); i!=Content.end(); ++i) {
114  ptr->push_back(*i);
115  }
116  //atomically try to swap this to become mItemsById
117  std::vector<std::string>* expect = nullptr;
118  bool exchanged = userContent.compare_exchange_strong(expect, ptr, std::memory_order_acq_rel);
119  if(!exchanged) {
120  delete ptr;
121  }
122  }
123 }
124 std::vector<std::string> ClusterSummary::GetUserContent()
125 {
126  return (*userContent.load(std::memory_order_acquire));
127 }
129 {
130  return (*userContent.load(std::memory_order_acquire)).size();
131 }
133  std::cout << "Saving info for " ;
134  for (unsigned int i = 0; i < (*userContent.load(std::memory_order_acquire)).size(); ++i) {
135  std::cout << (*userContent.load(std::memory_order_acquire)).at(i) << " " ;
136  }
137  std::cout << std::endl;
138 }
139 
141 
142  int placeInUserVector = -1;
143 
144 
145  int cnt = 0;
146  auto obj = (*userContent.load(std::memory_order_acquire));
147  for(auto it=obj.begin(); it!=obj.end(); ++it) {
148 
149  if ( var == (*it) ) {
150  placeInUserVector = cnt;
151  break;
152  }
153  else ++cnt;
154 
155  }
156 
157 
158  /*
159  if ( var == "cHits" )
160  placeInUserVector = NMODULES;
161  else if (var == "cSize" )
162  placeInUserVector = CLUSTERSIZE;
163  else if (var == "cCharge" )
164  placeInUserVector = CLUSTERCHARGE;
165  else if (var == "pHits" )
166  placeInUserVector = NMODULESPIXELS;
167  else if (var == "pSize" )
168  placeInUserVector = CLUSTERSIZEPIXELS;
169  else if (var == "pCharge" )
170  placeInUserVector = CLUSTERCHARGEPIXELS;
171  else
172  placeInUserVector = -1;
173  */
174  if (placeInUserVector == -1){
175  std::ostringstream err;
176  err<<"No information for requested var "<<var<<". Please check if you have chosen a proper variable.";
177 
178  throw cms::Exception( "Missing Variable", err.str());
179  }
180 
181  return placeInUserVector;
182 
183 }
184 
185 
186 
187 std::vector<std::string> ClusterSummary::DecodeProvInfo(std::string ProvInfo) const {
188 
189  std::vector<std::string> v_moduleTypes;
190 
191  std::string mod = ProvInfo;
193  std::string::size_type j = mod.find(',');
194 
195  if ( j == std::string::npos ){
196  v_moduleTypes.push_back(mod);
197  }
198  else{
199 
200  while (j != std::string::npos) {
201  v_moduleTypes.push_back(mod.substr(i, j-i));
202  i = ++j;
203  j = mod.find(',', j);
204  if (j == std::string::npos)
205  v_moduleTypes.push_back(mod.substr(i, mod.length( )));
206  }
207 
208  }
209 
210  return v_moduleTypes;
211 
212 }
213 
214 
215 
217 
218  // true if the module mod is among the selected modules.
219  int isselected = 0;
220  int enumVal = 99999;
221 
222  SiStripDetId subdet(DetId);
223  int subdetid = subdet.subDetector();
224 
226 
227  if(result != std::string::npos) {
228 
229  /****
230  Check to the layers in the modules
231  ****/
232 
233  std::string modStr = geosearch; //Convert to string to use needed methods
234  size_t pos = modStr.find("_", 0); //find the '_'
235  std::string Mod = modStr.substr(0, pos); //find the module
236  std::string Layer = modStr.substr(pos+1, modStr.length()); //find the Layer
237 
238  std::stringstream ss(Layer);
239  int layer_id = 0;
240 
241  ss >> layer_id;
242 
243  if (SiStripDetId::TIB == subdetid && Mod == "TIB"){
244 
245  TIBDetId tib(DetId);
246  int layer = tib.layer();
247  if (layer_id == layer){
248 
249  if (layer_id == 1) enumVal = ClusterSummary::TIB_1;
250  else if (layer_id == 2) enumVal = ClusterSummary::TIB_2;
251  else if (layer_id == 3) enumVal = ClusterSummary::TIB_3;
252  else if (layer_id == 4) enumVal = ClusterSummary::TIB_4;
253 
254  isselected = 1;
255  }
256  }
257 
258  else if (SiStripDetId::TOB == subdetid && Mod == "TOB"){
259 
260  TOBDetId tob(DetId);
261  int layer = tob.layer();
262  if (layer_id == layer){
263 
264  if (layer_id == 1) enumVal = ClusterSummary::TOB_1;
265  else if (layer_id == 2) enumVal = ClusterSummary::TOB_2;
266  else if (layer_id == 3) enumVal = ClusterSummary::TOB_3;
267  else if (layer_id == 4) enumVal = ClusterSummary::TOB_4;
268  else if (layer_id == 5) enumVal = ClusterSummary::TOB_5;
269  else if (layer_id == 6) enumVal = ClusterSummary::TOB_6;
270 
271  isselected = 1;
272  }
273  }
274 
275  else if (SiStripDetId::TEC == subdetid && Mod == "TECM"){
276 
277  TECDetId tec(DetId);
278  int side = (tec.isZMinusSide())?-1:1;
279  int layerwheel = tec.wheel();
280 
281  if (layer_id == layerwheel && side == -1){
282 
283  if (layer_id == 1) enumVal = ClusterSummary::TECM_1;
284  else if (layer_id == 2) enumVal = ClusterSummary::TECM_2;
285  else if (layer_id == 3) enumVal = ClusterSummary::TECM_3;
286  else if (layer_id == 4) enumVal = ClusterSummary::TECM_4;
287  else if (layer_id == 5) enumVal = ClusterSummary::TECM_5;
288  else if (layer_id == 6) enumVal = ClusterSummary::TECM_6;
289  else if (layer_id == 7) enumVal = ClusterSummary::TECM_7;
290  else if (layer_id == 8) enumVal = ClusterSummary::TECM_8;
291  else if (layer_id == 9) enumVal = ClusterSummary::TECM_9;
292 
293  isselected = 1;
294  }
295  }
296 
297  else if (SiStripDetId::TEC == subdetid && Mod == "TECP"){
298 
299  TECDetId tec(DetId);
300  int side = (tec.isZMinusSide())?-1:1;
301  int layerwheel = tec.wheel();
302 
303  if (layer_id == layerwheel && side == 1){
304 
305  if (layer_id == 1) enumVal = ClusterSummary::TECP_1;
306  else if (layer_id == 2) enumVal = ClusterSummary::TECP_2;
307  else if (layer_id == 3) enumVal = ClusterSummary::TECP_3;
308  else if (layer_id == 4) enumVal = ClusterSummary::TECP_4;
309  else if (layer_id == 5) enumVal = ClusterSummary::TECP_5;
310  else if (layer_id == 6) enumVal = ClusterSummary::TECP_6;
311  else if (layer_id == 7) enumVal = ClusterSummary::TECP_7;
312  else if (layer_id == 8) enumVal = ClusterSummary::TECP_8;
313  else if (layer_id == 9) enumVal = ClusterSummary::TECP_9;
314 
315  isselected = 1;
316  }
317  }
318 
319  // TEC minus ring
320  else if (SiStripDetId::TEC == subdetid && Mod == "TECMR"){
321 
322  TECDetId tec(DetId);
323  int side = (tec.isZMinusSide())?-1:1;
324  int ring = tec.ringNumber();
325 
326  if (layer_id == ring && side == -1){
327 
328  if (layer_id == 1) enumVal = ClusterSummary::TECMR_1;
329  else if (layer_id == 2) enumVal = ClusterSummary::TECMR_2;
330  else if (layer_id == 3) enumVal = ClusterSummary::TECMR_3;
331  else if (layer_id == 4) enumVal = ClusterSummary::TECMR_4;
332  else if (layer_id == 5) enumVal = ClusterSummary::TECMR_5;
333  else if (layer_id == 6) enumVal = ClusterSummary::TECMR_6;
334  else if (layer_id == 7) enumVal = ClusterSummary::TECMR_7;
335 
336  isselected = 1;
337  }
338  }
339 
340  // TEC plus ring
341  else if (SiStripDetId::TEC == subdetid && Mod == "TECPR"){
342 
343  TECDetId tec(DetId);
344  int side = (tec.isZMinusSide())?-1:1;
345  int ring = tec.ringNumber();
346  if (layer_id == ring && side == 1){
347 
348  if (layer_id == 1) enumVal = ClusterSummary::TECPR_1;
349  else if (layer_id == 2) enumVal = ClusterSummary::TECPR_2;
350  else if (layer_id == 3) enumVal = ClusterSummary::TECPR_3;
351  else if (layer_id == 4) enumVal = ClusterSummary::TECPR_4;
352  else if (layer_id == 5) enumVal = ClusterSummary::TECPR_5;
353  else if (layer_id == 6) enumVal = ClusterSummary::TECPR_6;
354  else if (layer_id == 7) enumVal = ClusterSummary::TECPR_7;
355 
356  isselected = 1;
357  }
358  }
359 
360  else if (SiStripDetId::TID == subdetid && Mod == "TIDM"){
361 
362  TIDDetId tid(DetId);
363  int side = (tid.isZMinusSide())?-1:1;
364  int layerwheel = tid.wheel();
365 
366  if (layer_id == layerwheel && side == -1){
367 
368  if (layer_id == 1) enumVal = ClusterSummary::TIDM_1;
369  else if (layer_id == 2) enumVal = ClusterSummary::TIDM_2;
370  else if (layer_id == 3) enumVal = ClusterSummary::TIDM_3;
371 
372  isselected = 1;
373  }
374  }
375 
376  else if (SiStripDetId::TID == subdetid && Mod == "TIDP"){
377 
378  TIDDetId tid(DetId);
379  int side = (tid.isZMinusSide())?-1:1;
380  int layerwheel = tid.wheel();
381 
382  if (layer_id == layerwheel && side == 1){
383 
384  if (layer_id == 1) enumVal = ClusterSummary::TIDP_1;
385  else if (layer_id == 2) enumVal = ClusterSummary::TIDP_2;
386  else if (layer_id == 3) enumVal = ClusterSummary::TIDP_3;
387 
388  isselected = 1;
389  }
390  }
391 
392  // TID minus ring
393  else if (SiStripDetId::TID == subdetid && Mod == "TIDMR"){
394  TIDDetId tid(DetId);
395  int side = (tid.isZMinusSide())?-1:1;
396  int ring = tid.ringNumber();
397  if (layer_id == ring && side == -1){
398 
399  if (layer_id == 1) enumVal = ClusterSummary::TIDMR_1;
400  else if (layer_id == 2) enumVal = ClusterSummary::TIDMR_2;
401  else if (layer_id == 3) enumVal = ClusterSummary::TIDMR_3;
402 
403  isselected = 1;
404  }
405  }
406 
407  // TID plus ring
408  else if (SiStripDetId::TID == subdetid && Mod == "TIDPR"){
409  TIDDetId tid(DetId);
410  int side = (tid.isZMinusSide())?-1:1;
411  int ring = tid.ringNumber();
412 
413  if (layer_id == ring && side == 1){
414 
415  if (layer_id == 1) enumVal = ClusterSummary::TIDPR_1;
416  else if (layer_id == 2) enumVal = ClusterSummary::TIDPR_2;
417  else if (layer_id == 3) enumVal = ClusterSummary::TIDPR_3;
418 
419  isselected = 1;
420  }
421  }
422  }
423 
424  /****
425  Check the top and bottom for the TEC and TID
426  ****/
427 
428  else if( SiStripDetId::TEC == subdetid && geosearch.compare("TECM")==0 ) {
429 
430  TECDetId tec(DetId);
431  int side = (tec.isZMinusSide())?-1:1;
432 
433  if (side == -1){
434  isselected = 1;
435  enumVal = ClusterSummary::TECM;
436  }
437  }
438 
439  else if( SiStripDetId::TEC == subdetid && geosearch.compare("TECP")==0 ) {
440 
441  TECDetId tec(DetId);
442  int side = (tec.isZMinusSide())?-1:1;
443 
444  if (side == 1){
445  isselected = 1;
446  enumVal = ClusterSummary::TECP;
447  }
448  }
449 
450 
451  else if( SiStripDetId::TID == subdetid && geosearch.compare("TIDM")==0 ) {
452 
453  TIDDetId tid(DetId);
454  int side = (tid.isZMinusSide())?-1:1;
455 
456  if (side == -1){
457  isselected = 1;
458  enumVal = ClusterSummary::TIDM;
459  }
460  }
461 
462 
463  else if( SiStripDetId::TID == subdetid && geosearch.compare("TIDP")==0 ) {
464 
465  TIDDetId tid(DetId);
466  int side = (tid.isZMinusSide())?-1:1;
467 
468  if (side == 1){
469  isselected = 1;
470  enumVal = ClusterSummary::TIDP;
471  }
472  }
473 
474  /****
475  Check the full TOB, TIB, TID, TEC modules
476  ****/
477 
478  else if( SiStripDetId::TIB == subdetid && geosearch.compare("TIB")==0 ) {
479  isselected = 1;
480  enumVal = ClusterSummary::TIB;
481  }
482  else if( SiStripDetId::TID == subdetid && geosearch.compare("TID")==0 ) {
483  isselected = 1;
484  enumVal = ClusterSummary::TID;
485  }
486  else if( SiStripDetId::TOB == subdetid && geosearch.compare("TOB")==0) {
487  isselected = 1;
488  enumVal = ClusterSummary::TOB;
489  }
490  else if( SiStripDetId::TEC == subdetid && geosearch.compare("TEC")==0) {
491  isselected = 1;
492  enumVal = ClusterSummary::TEC;
493  }
494  else if( geosearch.compare("TRACKER")==0) {
495  isselected = 1;
496  enumVal = ClusterSummary::TRACKER;
497  }
498 
499 
500  return std::make_pair(isselected, enumVal);
501 }
502 
503 
504 
505 
506 
507 
508 
509 
511 
512  // true if the module mod is among the selected modules.
513  int isselected = 0;
514  int enumVal = 99999;
515 
516  DetId detId = DetId(detid); // Get the Detid object
517  unsigned int detType=detId.det(); // det type, pixel=1
518  unsigned int subdetid=detId.subdetId(); //subdetector type, barrel=1, foward=2
519 
520  if(detType!=1) return std::make_pair(0,99999); // look only at pixels
521 
522  std::string::size_type result = geosearch.find("_");
523 
524  if(result != std::string::npos) {
525 
526  std::string modStr = geosearch; //Convert to string to use needed methods
527  size_t pos = modStr.find("_", 0); //find the '_'
528  std::string Mod = modStr.substr(0, pos); //find the module
529  std::string Layer = modStr.substr(pos+1, modStr.length()); //find the Layer
530 
531  std::stringstream ss(Layer);
532  int layer_id = 0;
533 
534  ss >> layer_id;
535 
536  /****
537  Check the Layers of the Barrel
538  ****/
539 
540  if (subdetid == 1 && Mod == "BPIX"){
541 
542  PXBDetId pdetId = PXBDetId(detid);
543  // Barell layer = 1,2,3
544  int layer=pdetId.layer();
545 
546  if (layer_id == layer){
547 
548  if (layer_id == 1) enumVal = ClusterSummary::BPIX_1;
549  else if (layer_id == 2) enumVal = ClusterSummary::BPIX_2;
550  else if (layer_id == 3) enumVal = ClusterSummary::BPIX_3;
551 
552  isselected = 1;
553  }
554  }
555 
556  /****
557  Check the Disk of the endcaps
558  ****/
559  else if (subdetid == 2 && Mod == "FPIX"){
560 
561  PXFDetId pdetId = PXFDetId(detid);
562  int disk=pdetId.disk(); //1,2,3
563 
564  if (layer_id == disk){
565 
566  if (disk == 1) enumVal = ClusterSummary::FPIX_1;
567  else if (disk == 2) enumVal = ClusterSummary::FPIX_2;
568  else if (disk == 3) enumVal = ClusterSummary::FPIX_3;
569 
570  isselected = 1;
571 
572  }
573  }
574 
575  /****
576  Check the sides of each Disk of the endcaps
577  ****/
578 
579  else if (subdetid == 2 && Mod == "FPIXM"){
580 
581  PXFDetId pdetId = PXFDetId(detid);
582  int side=pdetId.side(); //size=1 for -z, 2 for +z
583  int disk=pdetId.disk(); //1,2,3
584 
585  if (layer_id == disk && side == 1 ){
586 
587  if (disk == 1) enumVal = ClusterSummary::FPIXM_1;
588  else if (disk == 2) enumVal = ClusterSummary::FPIXM_2;
589  else if (disk == 3) enumVal = ClusterSummary::FPIXM_3;
590 
591  isselected = 1;
592 
593  }
594  }
595 
596  else if (subdetid == 2 && Mod == "FPIXP"){
597 
598  PXFDetId pdetId = PXFDetId(detid);
599  int side=pdetId.side(); //size=1 for -z, 2 for +z
600  int disk=pdetId.disk(); //1,2,3
601 
602  if (layer_id == disk && side == 2){
603 
604  if (disk == 1) enumVal = ClusterSummary::FPIXP_1;
605  else if (disk == 2) enumVal = ClusterSummary::FPIXP_2;
606  else if (disk == 3) enumVal = ClusterSummary::FPIXP_3;
607 
608  isselected = 1;
609 
610  }
611  }
612  }
613 
614  /****
615  Check the top and bottom of the endcaps
616  ****/
617 
618  else if( subdetid == 2 && geosearch.compare("FPIXM")==0 ) {
619 
620  PXFDetId pdetId = PXFDetId(detid);
621  int side=pdetId.side(); //size=1 for -z, 2 for +z
622 
623  if (side == 1){
624  isselected = 1;
625  enumVal = ClusterSummary::FPIXM;
626  }
627  }
628 
629  else if( subdetid == 2 && geosearch.compare("FPIXP")==0 ) {
630 
631  PXFDetId pdetId = PXFDetId(detid);
632  int side=pdetId.side(); //size=1 for -z, 2 for +z
633 
634  if (side == 2){
635  isselected = 1;
636  enumVal = ClusterSummary::FPIXP;
637  }
638  }
639 
640 
641  /****
642  Check the full Barrel and Endcaps
643  ****/
644 
645  else if(subdetid == 1 && geosearch.compare("BPIX")==0 ) {
646  isselected = 1;
647  enumVal = ClusterSummary::BPIX;
648  }
649  else if(subdetid == 2 && geosearch.compare("FPIX")==0 ) {
650  isselected = 1;
651  enumVal = ClusterSummary::FPIX;
652  }
653  else if( geosearch.compare("PIXEL")==0) {
654  isselected = 1;
655  enumVal = ClusterSummary::PIXEL;
656  }
657 
658 
659  return std::make_pair(isselected, enumVal);
660 }
661 
663  geosearch = gs;
664 }
665 
std::vector< std::string > DecodeProvInfo(std::string ProvInfo) const
int i
Definition: DBlmapReader.cc:9
unsigned int layer() const
layer id
Definition: TOBDetId.h:39
std::atomic< std::vector< std::string > * > userContent
virtual std::pair< int, int > IsPixelSelected(int DetId)
#define nullptr
std::vector< int > modules_
unsigned int ringNumber() const
Definition: TIDDetId.h:97
std::vector< std::vector< double > > genericVariablesTmp_
uint16_t size_type
void SetUserContent(const std::vector< std::string > &Content) const
unsigned int layer() const
layer id
Definition: PXBDetId.h:35
SeedingLayerSetsHits::SeedingLayer Layer
Definition: LayerTriplets.h:14
double Mod(double phi)
autoexplaining
bool isZMinusSide() const
Definition: TECDetId.h:86
std::vector< std::vector< double > > genericVariables_
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
tuple result
Definition: query.py:137
virtual std::pair< int, int > IsStripSelected(int DetId)
int j
Definition: DBlmapReader.cc:9
#define end
Definition: vmac.h:37
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
unsigned int disk() const
disk id
Definition: PXFDetId.h:43
int GetVariableLocation(std::string var) const
void swap(ClusterSummary &other)
std::vector< std::string > GetUserContent()
Detector identifier class for the strip tracker.
Definition: SiStripDetId.h:17
SubDetector subDetector() const
Definition: SiStripDetId.h:114
Definition: DetId.h:18
bool isZMinusSide() const
Definition: TIDDetId.h:81
void PrepairGenericVariable()
unsigned int wheel() const
wheel id
Definition: TECDetId.h:52
unsigned int layer() const
layer id
Definition: TIBDetId.h:41
unsigned int ringNumber() const
Definition: TECDetId.h:98
#define begin
Definition: vmac.h:30
ClusterSummary & operator=(const ClusterSummary &rhs)
unsigned int side() const
positive or negative id
Definition: PXFDetId.h:38
tuple cout
Definition: gather_cfg.py:121
void GetUserContentInfo() const
Detector det() const
get the detector field from this detid
Definition: DetId.h:35
int GetModuleLocation(int mod) const
T mod(const T &a, const T &b)
Definition: ecalDccMap.h:4
tuple size
Write out results.
std::vector< int > iterator_
unsigned int wheel() const
wheel id
Definition: TIDDetId.h:50
list at
Definition: asciidump.py:428