CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SiPixelFedCablingMapBuilder.cc
Go to the documentation of this file.
1 #include <iostream>
2 
9 
10 #include <ostream>
13 
21 
25 
26 #include <bitset>
27 
29 
30 using namespace std;
31 using namespace sipixelobjects;
32 
33 
34 SiPixelFedCablingMapBuilder::SiPixelFedCablingMapBuilder(const string & associatorName) : theAssociatorName(associatorName)
35 { }
36 
37 
39 {
40  FEDNumbering fednum;
41 // TRange<int> fedIds(FEDNumbering::MINSiPixelFEDID, FEDNumbering::MAXSiPixelFEDID);
42  TRange<int> fedIds(0,39);
43  edm::LogInfo("SiPixelFedCablingMapBuilder")<<"pixel fedid range: "<<fedIds;
44 
45 
47  setup.get<TrackerDigiGeometryRecord>().get(theAssociatorName,associator);
48 // PixelToFEDAssociate * associator = new PixelToLNKAssociateFromAscii("pixelToLNK.ascii");
49 
50 
51  const PixelToFEDAssociate & name2fed = *associator;
52 
53  string version = name2fed.version();
55 
56 
57  LogDebug("read tracker geometry...");
59  setup.get<TrackerDigiGeometryRecord>().get( pDD );
60  LogDebug("tracker geometry read")<<"There are: "<< pDD->dets().size() <<" detectors";
61 
62  typedef TrackerGeometry::DetContainer::const_iterator ITG;
63  int npxdets = 0;
64 
65  typedef std::vector<pair<PixelModuleName* , uint32_t> > UNITS;
66  UNITS units;
67 
68  for (ITG it = pDD->dets().begin(); it != pDD->dets().end(); it++){
69  const PixelGeomDetUnit * pxUnit = dynamic_cast<const PixelGeomDetUnit*>(*it);
70  if (pxUnit ==0 ) continue;
71  npxdets++;
72  DetId geomid = pxUnit->geographicalId();
73  PixelModuleName * name = 0;
74  if (1 == geomid.subdetId()) {
75  name = new PixelBarrelName(geomid);
76  } else {
77  name = new PixelEndcapName(geomid);
78 // cout << " NAME: "<<name->name()<<myprint(pxUnit)<<endl;
79  }
80  units.push_back( std::make_pair( name, geomid.rawId() ) );
81  }
82 
83 
84  if (theAssociatorName=="PixelToFEDAssociateFromAscii") {
85  cout <<" HERE PixelToFEDAssociateFromAscii"<<endl;
86  vector<FedSpec> fedSpecs(fedIds.max()-fedIds.min()+1);
87  for (int id=fedIds.first; id<=fedIds.second; id++) {
88  FedSpec fs={ id, vector<PixelModuleName* >(), vector<uint32_t>()};
89  int idx = id - fedIds.min();
90  fedSpecs[idx]= fs;
91  }
92  for (UNITS::iterator iu=units.begin(); iu != units.end(); iu++) {
93  PixelModuleName* name = (*iu).first;
94  uint32_t rawId = (*iu).second;
95  int fedId = name2fed( *name);
96  if ( fedIds.inside(fedId) ) {
97  int idx = fedId - fedIds.min();
98  fedSpecs[idx].rawids.push_back(rawId);
99  fedSpecs[idx].names.push_back(name);
100  } else edm::LogError("SiPixelFedCablingMapBuilder")
101  <<"problem with numbering! "<<fedId<<" name: " << name->name();
102  }
103 
104  LogDebug("tracker geometry read")<<"There are: "<< npxdets<<" pixel detetors";
105  // construct FEDs
106  typedef vector<FedSpec>::iterator FI;
107  for ( FI it = fedSpecs.begin(); it != fedSpecs.end(); it++) {
108  int fedId = it->fedId;
109  vector<PixelModuleName* > names = it->names;
110  vector<uint32_t> units = it->rawids;
111  if ( names.size() == 0) continue;
112  PixelFEDCabling fed(fedId);
113  bool barrel = it->names.front()->isBarrel();
114  if (barrel) {
115  PixelFEDCabling::Links links =
116  PixelBarrelLinkMaker(&fed).links(names,units);
117  fed.setLinks(links);
118  result->addFed(fed);
119  } else {
120  PixelFEDCabling::Links links =
121  PixelEndcapLinkMaker(&fed).links(names,units);
122  fed.setLinks(links);
123  result->addFed(fed);
124  }
125  }
126  } else {
128  cout <<" HERE PixelToLNKAssociateFromAscii"<<endl;
129  for (UNITS::iterator iu=units.begin(); iu != units.end(); iu++) {
130  PixelModuleName * name = (*iu).first;
131  detectorRocId.module = name;
132  for (int rocDetId=0; rocDetId<=16; rocDetId++) {
133  detectorRocId.rocDetId = rocDetId;
134  const PixelToFEDAssociate::CablingRocId * cablingRocId = name2fed(detectorRocId);
135  if (cablingRocId) {
136  sipixelobjects::PixelROC roc( iu->second, rocDetId, cablingRocId->rocLinkId );
137  result->addItem(cablingRocId->fedId, cablingRocId->linkId, roc);
138  }
139  }
140  }
141  }
142 
143  //clear names:
144  for (UNITS::iterator iu=units.begin(); iu != units.end(); iu++) delete iu->first;
145 
146 
147  return result;
148 
149 }
151 {
152  std::ostringstream str;
153  const PixelTopology & tpl = pxUnit->specificTopology();
154  LocalPoint local;
155  GlobalPoint global;
156 
157  local = LocalPoint(0,0,0); global = (*pxUnit).toGlobal(local);
158  // phi measured from Y axis
159  float phi = 180*atan2(global.x(),global.y())/M_PI; if (phi > 180.) phi = phi-360;
160  float r = global.perp();
161  float z = global.z();
162  str <<" POSITION: "<<" r="<<r<<" phi="<<phi<<" z="<<z;
163  str <<" (rows,coll:"<<tpl.nrows()<<","<<tpl.ncolumns()<<")";
164  str <<endl;
165  local = LocalPoint(0,0,0); str <<local<<"global: "<<(*pxUnit).toGlobal(local) <<endl;
166  local = LocalPoint(1,0,0); str <<local<<"global: "<<(*pxUnit).toGlobal(local) <<endl;
167  local = LocalPoint(0,1,0); str <<local<<"global: "<<(*pxUnit).toGlobal(local) <<endl;
168  local = LocalPoint(0,0,1); str <<local<<"global: "<<(*pxUnit).toGlobal(local) <<endl;
169 
170  return str.str();
171 }
#define LogDebug(id)
T perp() const
Definition: PV3DBase.h:72
static const HistoName names[]
SiPixelFedCablingTree * produce(const edm::EventSetup &setup)
virtual int ncolumns() const =0
T y() const
Definition: PV3DBase.h:63
virtual int nrows() const =0
bool inside(const T &value) const
check if object is inside region
Definition: TRange.h:34
Links links(const Names &n, const DetUnits &u) const
float float float z
const T & min() const
lower edge of range
Definition: TRange.h:23
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
virtual std::string version() const =0
version
std::string myprint(const PixelGeomDetUnit *pxUnit)
SiPixelFedCablingMapBuilder(const std::string &associatorName)
virtual std::string name() const =0
associated name
T z() const
Definition: PV3DBase.h:64
tuple result
Definition: query.py:137
DetId geographicalId() const
The label of this GeomDet.
Definition: GeomDet.h:77
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
#define M_PI
Definition: DetId.h:18
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
const T & max() const
upper edge of range
Definition: TRange.h:26
const T & get() const
Definition: EventSetup.h:55
virtual const PixelTopology & specificTopology() const
Returns a reference to the pixel proxy topology.
TString units(TString variable, Char_t axis)
Local3DPoint LocalPoint
Definition: LocalPoint.h:11
void addFed(const PixelFEDCabling &f)
add cabling for one fed
tuple cout
Definition: gather_cfg.py:121
T x() const
Definition: PV3DBase.h:62
void addItem(unsigned int fedId, unsigned int linkId, const sipixelobjects::PixelROC &roc)
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
dictionary UNITS
Definition: asciidump.py:257
Links links(const Names &n, const DetUnits &u) const
Definition: DDAxes.h:10