CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Private Member Functions | Private Attributes
SiPixelFedCablingMapBuilder Class Reference

#include <SiPixelFedCablingMapBuilder.h>

Classes

struct  FedSpec
 

Public Member Functions

SiPixelFedCablingTreeproduce (const edm::EventSetup &setup)
 
 SiPixelFedCablingMapBuilder (edm::ConsumesCollector &&iCC, const std::string fileName, const bool phase1=false)
 

Private Member Functions

std::string myprint (const PixelGeomDetUnit *pxUnit)
 

Private Attributes

std::string fileName_
 
bool phase1_
 
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecordtrackerGeomToken_
 
edm::ESGetToken< TrackerTopology, TrackerTopologyRcdtrackerTopoToken_
 

Detailed Description

Definition at line 17 of file SiPixelFedCablingMapBuilder.h.

Constructor & Destructor Documentation

◆ SiPixelFedCablingMapBuilder()

SiPixelFedCablingMapBuilder::SiPixelFedCablingMapBuilder ( edm::ConsumesCollector &&  iCC,
const std::string  fileName,
const bool  phase1 = false 
)

Member Function Documentation

◆ myprint()

std::string SiPixelFedCablingMapBuilder::myprint ( const PixelGeomDetUnit pxUnit)
private

Definition at line 186 of file SiPixelFedCablingMapBuilder.cc.

References Matriplex::atan2(), DTRecHitClients_cfi::local, M_PI, PixelTopology::ncolumns(), PixelTopology::nrows(), PV3DBase< T, PVType, FrameType >::perp(), phi, alignCSCRings::r, PixelGeomDetUnit::specificTopology(), str, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), z, and PV3DBase< T, PVType, FrameType >::z().

186  {
187  std::ostringstream str;
188  const PixelTopology& tpl = pxUnit->specificTopology();
190  GlobalPoint global;
191 
192  local = LocalPoint(0, 0, 0);
193  global = (*pxUnit).toGlobal(local);
194  // phi measured from Y axis
195  float phi = 180 * atan2(global.x(), global.y()) / M_PI;
196  if (phi > 180.)
197  phi = phi - 360;
198  float r = global.perp();
199  float z = global.z();
200  str << " POSITION: "
201  << " r=" << r << " phi=" << phi << " z=" << z;
202  str << " (rows,coll:" << tpl.nrows() << "," << tpl.ncolumns() << ")";
203  str << endl;
204  local = LocalPoint(0, 0, 0);
205  str << local << "global: " << (*pxUnit).toGlobal(local) << endl;
206  local = LocalPoint(1, 0, 0);
207  str << local << "global: " << (*pxUnit).toGlobal(local) << endl;
208  local = LocalPoint(0, 1, 0);
209  str << local << "global: " << (*pxUnit).toGlobal(local) << endl;
210  local = LocalPoint(0, 0, 1);
211  str << local << "global: " << (*pxUnit).toGlobal(local) << endl;
212 
213  return str.str();
214 }
T perp() const
Definition: PV3DBase.h:69
Point3DBase< Scalar, LocalTag > LocalPoint
Definition: Definitions.h:30
virtual int ncolumns() const =0
T z() const
Definition: PV3DBase.h:61
virtual int nrows() const =0
T x() const
Definition: PV3DBase.h:59
T y() const
Definition: PV3DBase.h:60
#define M_PI
virtual const PixelTopology & specificTopology() const
Returns a reference to the pixel proxy topology.
#define str(s)
MPlex< T, D1, D2, N > atan2(const MPlex< T, D1, D2, N > &y, const MPlex< T, D1, D2, N > &x)
Definition: Matriplex.h:648

◆ produce()

SiPixelFedCablingTree * SiPixelFedCablingMapBuilder::produce ( const edm::EventSetup setup)

Definition at line 39 of file SiPixelFedCablingMapBuilder.cc.

References LCToCPAssociation_cfi::associator, TrackerGeometry::dets(), PixelToFEDAssociate::CablingRocId::fedId, L1TStage2BMTF_cff::fedIds, fileName_, GeomDet::geographicalId(), TrackerGeometry::isThere(), ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, PixelToFEDAssociate::CablingRocId::linkId, FEDNumbering::MAXSiPixelFEDID, FEDNumbering::MAXSiPixeluTCAFEDID, FEDNumbering::MINSiPixelFEDID, FEDNumbering::MINSiPixeluTCAFEDID, PixelToFEDAssociate::DetectorRocId::module, mergeVDriftHistosByStation::name, GeomDetEnumerators::P1PXB, GeomDetEnumerators::P1PXEC, phase1_, edm::ESHandle< T >::product(), DetId::rawId(), mps_fire::result, PixelMapPlotter::roc, PixelToFEDAssociate::DetectorRocId::rocDetId, PixelToFEDAssociate::CablingRocId::rocLinkId, singleTopDQM_cfi::setup, DetId::subdetId(), trackerGeomToken_, trackerTopoToken_, units(), PixelToFEDAssociate::version(), and relval_steps::version.

39  {
40  // Access geometry
41  edm::LogInfo("read tracker geometry...");
43  edm::LogInfo("tracker geometry read") << "There are: " << pDD->dets().size() << " detectors";
44 
45  // Test new TrackerGeometry features
46  //cout << "Test of TrackerGeometry::isThere";
47  //cout << " is there PixelBarrel: " << pDD->isThere(GeomDetEnumerators::PixelBarrel);
48  //cout << " is there PixelEndcap: " << pDD->isThere(GeomDetEnumerators::PixelEndcap);
49  //cout << " is there P1PXB: " << pDD->isThere(GeomDetEnumerators::P1PXB);
50  //cout << " is there P1PXEC: " << pDD->isThere(GeomDetEnumerators::P1PXEC);
51  //cout << endl;
52 
53  // switch on the phase1
55  phase1_ = true;
56  //cout<<" this is phase1 "<<endl;
57  edm::LogInfo("SiPixelFedCablingMapBuilder") << " pixel phase1 setup ";
58  } else {
59  phase1_ = false;
60  //cout<<" this is phase0 "<<endl;
61  edm::LogInfo("SiPixelFedCablingMapBuilder") << " pixel phase0 setup ";
62  }
63 
64  int MINFEDID = FEDNumbering::MINSiPixelFEDID;
65  int MAXFEDID = FEDNumbering::MAXSiPixelFEDID;
66  if (phase1_) {
67  // bpix 1200-1239, fpix 1240-1255
69  MAXFEDID = FEDNumbering::MAXSiPixeluTCAFEDID; // is actually 1349, might work
70  }
71  TRange<int> fedIds(MINFEDID, MAXFEDID);
72  edm::LogInfo("SiPixelFedCablingMapBuilder") << "pixel fedid range: " << fedIds;
73 
74  // in the constrcuctor init() is called which reads the ascii file and makes
75  // the map roc<->link
76  // what is this junk? Replace by fixed associator.
77  //edm::ESHandle<PixelToFEDAssociate> associator;
78  //setup.get<TrackerDigiGeometryRecord>().get(theAssociatorName,associator);
79  //PixelToFEDAssociate * associator = new PixelToLNKAssociateFromAscii("pixelToLNK.ascii",phase1_);
81 
82  const PixelToFEDAssociate& name2fed = *associator;
83 
84  string version = name2fed.version();
86  edm::LogInfo(" version ") << version << endl;
87 
88  // Access topology
90  const TrackerTopology* tt = tTopo.product();
91 
92  typedef TrackerGeometry::DetContainer::const_iterator ITG;
93 
94  typedef std::vector<pair<PixelModuleName*, uint32_t> > UNITS;
95  UNITS units;
96 
97  for (ITG it = pDD->dets().begin(); it != pDD->dets().end(); it++) {
98  const PixelGeomDetUnit* pxUnit = dynamic_cast<const PixelGeomDetUnit*>(*it);
99  if (pxUnit == nullptr)
100  continue;
101  DetId geomid = pxUnit->geographicalId();
102  PixelModuleName* name = nullptr;
103  if (1 == geomid.subdetId()) { // bpix
104  name = new PixelBarrelName(geomid, tt, phase1_);
105  } else { // fpix
106  name = new PixelEndcapName(geomid, tt, phase1_);
107  }
108  edm::LogInfo(" NAME: ") << name->name();
109  //cout << " NAME: "<<name->name()<<" "<<geomid.rawId()<<
110  //" "<<myprint(pxUnit)<<endl;
111  units.push_back(std::make_pair(name, geomid.rawId()));
112  }
113 
114  // This produces a simple, unrealistic map, NOT USED ANYMORE
115  // if (theAssociatorName=="PixelToFEDAssociateFromAscii") {
116  // cout <<" HERE PixelToFEDAssociateFromAscii"<<endl;
117  // vector<FedSpec> fedSpecs(fedIds.max()-fedIds.min()+1);
118  // for (int id=fedIds.first; id<=fedIds.second; id++) {
119  // FedSpec fs={ id, vector<PixelModuleName* >(), vector<uint32_t>()};
120  // int idx = id - fedIds.min();
121  // fedSpecs[idx]= fs;
122  // }
123  // for (UNITS::iterator iu=units.begin(); iu != units.end(); iu++) {
124  // PixelModuleName* name = (*iu).first;
125  // uint32_t rawId = (*iu).second;
126  // int fedId = name2fed( *name);
127  // if ( fedIds.inside(fedId) ) {
128  // int idx = fedId - fedIds.min();
129  // fedSpecs[idx].rawids.push_back(rawId);
130  // fedSpecs[idx].names.push_back(name);
131  // } else edm::LogError("SiPixelFedCablingMapBuilder")
132  // <<"problem with numbering! "<<fedId<<" name: " << name->name();
133  // }
134  // edm::LogInfo("tracker geometry read")<<"There are: "<< npxdets<<" pixel detetors";
135  // // construct FEDs
136  // typedef vector<FedSpec>::iterator FI;
137  // for ( FI it = fedSpecs.begin(); it != fedSpecs.end(); it++) {
138  // int fedId = it->fedId;
139  // vector<PixelModuleName* > names = it->names;
140  // vector<uint32_t> units = it->rawids;
141  // if ( names.size() == 0) continue;
142  // PixelFEDCabling fed(fedId);
143  // bool barrel = it->names.front()->isBarrel();
144  // if (barrel) {
145  // PixelFEDCabling::Links links =
146  // PixelBarrelLinkMaker(&fed).links(names,units);
147  // fed.setLinks(links);
148  // result->addFed(fed);
149  // } else {
150  // PixelFEDCabling::Links links =
151  // PixelEndcapLinkMaker(&fed).links(names,units);
152  // fed.setLinks(links);
153  // result->addFed(fed);
154  // }
155  // }
156  // } else { // This is what is really used
157 
159  edm::LogInfo(" HERE PixelToLNKAssociateFromAscii");
160  for (UNITS::iterator iu = units.begin(); iu != units.end(); iu++) {
161  PixelModuleName* name = (*iu).first;
162  detectorRocId.module = name;
163  //for (int rocDetId=0; rocDetId<=16; rocDetId++) {
164  for (int rocDetId = 0; rocDetId < 16; rocDetId++) {
165  detectorRocId.rocDetId = rocDetId;
166  const PixelToFEDAssociate::CablingRocId* cablingRocId = name2fed(detectorRocId);
167  if (cablingRocId) {
168  sipixelobjects::PixelROC roc(iu->second, rocDetId, cablingRocId->rocLinkId);
169  result->addItem(cablingRocId->fedId, cablingRocId->linkId, roc);
170  edm::LogInfo(" ok ") << name->name() << " " << rocDetId << " " << cablingRocId->fedId << " "
171  << cablingRocId->linkId;
172  } else { // did it fail?
173  edm::LogInfo(" failed ") << name->name() << " " << rocDetId;
174  //cout<<" failed "<<name->name()<<" "<<rocDetId<<endl;
175  }
176  }
177  }
178  //}
179 
180  //clear names:
181  for (UNITS::iterator iu = units.begin(); iu != units.end(); iu++)
182  delete iu->first;
183 
184  return result;
185 }
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > trackerGeomToken_
const DetContainer & dets() const override
Returm a vector of all GeomDet (including all GeomDetUnits)
virtual std::string version() const =0
version
T const * product() const
Definition: ESHandle.h:86
Definition: TTTypes.h:54
bool isThere(GeomDetEnumerators::SubDetector subdet) const
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:48
DetId geographicalId() const
The label of this GeomDet.
Definition: GeomDet.h:64
Log< level::Info, false > LogInfo
Definition: DetId.h:17
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
TString units(TString variable, Char_t axis)
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > trackerTopoToken_

Member Data Documentation

◆ fileName_

std::string SiPixelFedCablingMapBuilder::fileName_
private

Definition at line 30 of file SiPixelFedCablingMapBuilder.h.

Referenced by produce().

◆ phase1_

bool SiPixelFedCablingMapBuilder::phase1_
private

Definition at line 32 of file SiPixelFedCablingMapBuilder.h.

Referenced by produce().

◆ trackerGeomToken_

edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> SiPixelFedCablingMapBuilder::trackerGeomToken_
private

Definition at line 35 of file SiPixelFedCablingMapBuilder.h.

Referenced by produce(), and SiPixelFedCablingMapBuilder().

◆ trackerTopoToken_

edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> SiPixelFedCablingMapBuilder::trackerTopoToken_
private

Definition at line 34 of file SiPixelFedCablingMapBuilder.h.

Referenced by produce(), and SiPixelFedCablingMapBuilder().