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 (const std::string fileName, const bool phase1=false)
 

Private Member Functions

std::string myprint (const PixelGeomDetUnit *pxUnit)
 

Private Attributes

std::string fileName_
 
bool phase1_
 

Detailed Description

Definition at line 14 of file SiPixelFedCablingMapBuilder.h.

Constructor & Destructor Documentation

SiPixelFedCablingMapBuilder::SiPixelFedCablingMapBuilder ( const std::string  fileName,
const bool  phase1 = false 
)

Definition at line 33 of file SiPixelFedCablingMapBuilder.cc.

35  : fileName_(fileName) //, phase1_(phase1) not used anymore
36 {}

Member Function Documentation

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

Definition at line 189 of file SiPixelFedCablingMapBuilder.cc.

References 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().

189  {
190  std::ostringstream str;
191  const PixelTopology& tpl = pxUnit->specificTopology();
193  GlobalPoint global;
194 
195  local = LocalPoint(0, 0, 0);
196  global = (*pxUnit).toGlobal(local);
197  // phi measured from Y axis
198  float phi = 180 * atan2(global.x(), global.y()) / M_PI;
199  if (phi > 180.)
200  phi = phi - 360;
201  float r = global.perp();
202  float z = global.z();
203  str << " POSITION: "
204  << " r=" << r << " phi=" << phi << " z=" << z;
205  str << " (rows,coll:" << tpl.nrows() << "," << tpl.ncolumns() << ")";
206  str << endl;
207  local = LocalPoint(0, 0, 0);
208  str << local << "global: " << (*pxUnit).toGlobal(local) << endl;
209  local = LocalPoint(1, 0, 0);
210  str << local << "global: " << (*pxUnit).toGlobal(local) << endl;
211  local = LocalPoint(0, 1, 0);
212  str << local << "global: " << (*pxUnit).toGlobal(local) << endl;
213  local = LocalPoint(0, 0, 1);
214  str << local << "global: " << (*pxUnit).toGlobal(local) << endl;
215 
216  return str.str();
217 }
virtual int nrows() const =0
Point3DBase< Scalar, LocalTag > LocalPoint
Definition: Definitions.h:32
T perp() const
Definition: PV3DBase.h:72
T y() const
Definition: PV3DBase.h:63
T z() const
Definition: PV3DBase.h:64
#define M_PI
virtual const PixelTopology & specificTopology() const
Returns a reference to the pixel proxy topology.
virtual int ncolumns() const =0
#define str(s)
T x() const
Definition: PV3DBase.h:62
SiPixelFedCablingTree * SiPixelFedCablingMapBuilder::produce ( const edm::EventSetup setup)

Definition at line 38 of file SiPixelFedCablingMapBuilder.cc.

References SiPixelFedCablingTree::addItem(), ctfWithMaterialTrackMCMatch_cfi::associator, TrackerGeometry::dets(), PixelToFEDAssociate::CablingRocId::fedId, fileName_, GeomDet::geographicalId(), edm::EventSetup::get(), TrackerGeometry::isThere(), PixelToFEDAssociate::CablingRocId::linkId, FEDNumbering::MAXSiPixelFEDID, FEDNumbering::MAXSiPixeluTCAFEDID, FEDNumbering::MINSiPixelFEDID, FEDNumbering::MINSiPixeluTCAFEDID, PixelToFEDAssociate::DetectorRocId::module, PixelModuleName::name(), dataset::name, GeomDetEnumerators::P1PXB, GeomDetEnumerators::P1PXEC, phase1_, edm::ESHandle< T >::product(), DetId::rawId(), mps_fire::result, PixelToFEDAssociate::DetectorRocId::rocDetId, PixelToFEDAssociate::CablingRocId::rocLinkId, DetId::subdetId(), groupFilesInBlocks::tt, units(), PixelToFEDAssociate::version(), and jets_cff::version.

Referenced by JSONExport.JsonExport::export(), HTMLExport.HTMLExport::export(), and HTMLExport.HTMLExportStatic::export().

38  {
39  // Access geometry
40  edm::LogInfo("read tracker geometry...");
42  setup.get<TrackerDigiGeometryRecord>().get(pDD);
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  setup.get<TrackerTopologyRcd>().get(tTopo);
91  const TrackerTopology* tt = tTopo.product();
92 
93  typedef TrackerGeometry::DetContainer::const_iterator ITG;
94  int npxdets = 0;
95 
96  typedef std::vector<pair<PixelModuleName*, uint32_t> > UNITS;
97  UNITS units;
98 
99  for (ITG it = pDD->dets().begin(); it != pDD->dets().end(); it++) {
100  const PixelGeomDetUnit* pxUnit = dynamic_cast<const PixelGeomDetUnit*>(*it);
101  if (pxUnit == nullptr)
102  continue;
103  npxdets++;
104  DetId geomid = pxUnit->geographicalId();
105  PixelModuleName* name = nullptr;
106  if (1 == geomid.subdetId()) { // bpix
107  name = new PixelBarrelName(geomid, tt, phase1_);
108  } else { // fpix
109  name = new PixelEndcapName(geomid, tt, phase1_);
110  }
111  edm::LogInfo(" NAME: ") << name->name();
112  //cout << " NAME: "<<name->name()<<" "<<geomid.rawId()<<
113  //" "<<myprint(pxUnit)<<endl;
114  units.push_back(std::make_pair(name, geomid.rawId()));
115  }
116 
117  // This produces a simple, unrealistic map, NOT USED ANYMORE
118  // if (theAssociatorName=="PixelToFEDAssociateFromAscii") {
119  // cout <<" HERE PixelToFEDAssociateFromAscii"<<endl;
120  // vector<FedSpec> fedSpecs(fedIds.max()-fedIds.min()+1);
121  // for (int id=fedIds.first; id<=fedIds.second; id++) {
122  // FedSpec fs={ id, vector<PixelModuleName* >(), vector<uint32_t>()};
123  // int idx = id - fedIds.min();
124  // fedSpecs[idx]= fs;
125  // }
126  // for (UNITS::iterator iu=units.begin(); iu != units.end(); iu++) {
127  // PixelModuleName* name = (*iu).first;
128  // uint32_t rawId = (*iu).second;
129  // int fedId = name2fed( *name);
130  // if ( fedIds.inside(fedId) ) {
131  // int idx = fedId - fedIds.min();
132  // fedSpecs[idx].rawids.push_back(rawId);
133  // fedSpecs[idx].names.push_back(name);
134  // } else edm::LogError("SiPixelFedCablingMapBuilder")
135  // <<"problem with numbering! "<<fedId<<" name: " << name->name();
136  // }
137  // edm::LogInfo("tracker geometry read")<<"There are: "<< npxdets<<" pixel detetors";
138  // // construct FEDs
139  // typedef vector<FedSpec>::iterator FI;
140  // for ( FI it = fedSpecs.begin(); it != fedSpecs.end(); it++) {
141  // int fedId = it->fedId;
142  // vector<PixelModuleName* > names = it->names;
143  // vector<uint32_t> units = it->rawids;
144  // if ( names.size() == 0) continue;
145  // PixelFEDCabling fed(fedId);
146  // bool barrel = it->names.front()->isBarrel();
147  // if (barrel) {
148  // PixelFEDCabling::Links links =
149  // PixelBarrelLinkMaker(&fed).links(names,units);
150  // fed.setLinks(links);
151  // result->addFed(fed);
152  // } else {
153  // PixelFEDCabling::Links links =
154  // PixelEndcapLinkMaker(&fed).links(names,units);
155  // fed.setLinks(links);
156  // result->addFed(fed);
157  // }
158  // }
159  // } else { // This is what is really used
160 
162  edm::LogInfo(" HERE PixelToLNKAssociateFromAscii");
163  for (UNITS::iterator iu = units.begin(); iu != units.end(); iu++) {
164  PixelModuleName* name = (*iu).first;
165  detectorRocId.module = name;
166  //for (int rocDetId=0; rocDetId<=16; rocDetId++) {
167  for (int rocDetId = 0; rocDetId < 16; rocDetId++) {
168  detectorRocId.rocDetId = rocDetId;
169  const PixelToFEDAssociate::CablingRocId* cablingRocId = name2fed(detectorRocId);
170  if (cablingRocId) {
171  sipixelobjects::PixelROC roc(iu->second, rocDetId, cablingRocId->rocLinkId);
172  result->addItem(cablingRocId->fedId, cablingRocId->linkId, roc);
173  edm::LogInfo(" ok ") << name->name() << " " << rocDetId << " " << cablingRocId->fedId << " "
174  << cablingRocId->linkId;
175  } else { // did it fail?
176  edm::LogInfo(" failed ") << name->name() << " " << rocDetId;
177  //cout<<" failed "<<name->name()<<" "<<rocDetId<<endl;
178  }
179  }
180  }
181  //}
182 
183  //clear names:
184  for (UNITS::iterator iu = units.begin(); iu != units.end(); iu++)
185  delete iu->first;
186 
187  return result;
188 }
virtual std::string name() const =0
associated name
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:50
virtual std::string version() const =0
version
bool isThere(GeomDetEnumerators::SubDetector subdet) const
const DetContainer & dets() const override
Returm a vector of all GeomDet (including all GeomDetUnits)
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:41
DetId geographicalId() const
The label of this GeomDet.
Definition: GeomDet.h:79
Definition: DetId.h:18
TString units(TString variable, Char_t axis)
T get() const
Definition: EventSetup.h:71
T const * product() const
Definition: ESHandle.h:86
void addItem(unsigned int fedId, unsigned int linkId, const sipixelobjects::PixelROC &roc)

Member Data Documentation

std::string SiPixelFedCablingMapBuilder::fileName_
private

Definition at line 27 of file SiPixelFedCablingMapBuilder.h.

Referenced by produce().

bool SiPixelFedCablingMapBuilder::phase1_
private

Definition at line 29 of file SiPixelFedCablingMapBuilder.h.

Referenced by produce().