45 #include "TObjString.h"
46 #include "TObjArray.h"
48 #include "TProfile2D.h"
83 void endJob()
override;
85 void readVertices(
double& minx,
double& maxx,
double& miny,
double& maxy);
87 void prepareStripNames();
88 void preparePixelNames();
96 void fillStripRemap();
128 TH2Poly* trackerMap{
nullptr};
144 edm::LogError(
"TrackerRemapper") <<
"<GENERIC> not found... Aborting...\n";
148 typename T::const_iterator it;
149 for (it = input->begin(); it != input->end(); ++it) {
150 auto id =
DetId(it->detId());
151 trackerMap->Fill(TString::Format(
"%ld", (
long)
id.rawId()), it->size());
160 analyzeRechits(iEvent, t);
169 m_opMode(iConfig.getParameter<int>(
"opMode")),
170 m_analyzeMode(iConfig.getParameter<int>(
"analyzeMode")) {
171 usesResource(
"TFileService");
204 edm::LogError(
"LogicError") <<
"Unrecognized analyze mode!" << std::endl;
207 throw cms::Exception(
"TrackerRemapper") <<
"Unrecognized operations mode!" << std::endl;
220 m_stripBaseDir +
"TIB/layer_2/" + m_stripDesiredHistogram +
"_TIB_L2;1";
222 m_stripBaseDir +
"TIB/layer_3/" + m_stripDesiredHistogram +
"_TIB_L3;1";
224 m_stripBaseDir +
"TIB/layer_4/" + m_stripDesiredHistogram +
"_TIB_L4;1";
227 m_stripBaseDir +
"TID/MINUS/wheel_1/" + m_stripDesiredHistogram +
"_TIDM_D1;1";
229 m_stripBaseDir +
"TID/MINUS/wheel_2/" + m_stripDesiredHistogram +
"_TIDM_D2;1";
231 m_stripBaseDir +
"TID/MINUS/wheel_3/" + m_stripDesiredHistogram +
"_TIDM_D3;1";
233 m_stripBaseDir +
"TID/PLUS/wheel_1/" + m_stripDesiredHistogram +
"_TIDP_D1;1";
235 m_stripBaseDir +
"TID/PLUS/wheel_2/" + m_stripDesiredHistogram +
"_TIDP_D2;1";
237 m_stripBaseDir +
"TID/PLUS/wheel_3/" + m_stripDesiredHistogram +
"_TIDP_D3;1";
240 m_stripBaseDir +
"TOB/layer_1/" + m_stripDesiredHistogram +
"_TOB_L1;1";
242 m_stripBaseDir +
"TOB/layer_2/" + m_stripDesiredHistogram +
"_TOB_L2;1";
244 m_stripBaseDir +
"TOB/layer_3/" + m_stripDesiredHistogram +
"_TOB_L3;1";
246 m_stripBaseDir +
"TOB/layer_4/" + m_stripDesiredHistogram +
"_TOB_L4;1";
248 m_stripBaseDir +
"TOB/layer_5/" + m_stripDesiredHistogram +
"_TOB_L5;1";
250 m_stripBaseDir +
"TOB/layer_6/" + m_stripDesiredHistogram +
"_TOB_L6;1";
253 m_stripBaseDir +
"TEC/MINUS/wheel_1/" + m_stripDesiredHistogram +
"_TECM_W1;1";
255 m_stripBaseDir +
"TEC/MINUS/wheel_2/" + m_stripDesiredHistogram +
"_TECM_W2;1";
257 m_stripBaseDir +
"TEC/MINUS/wheel_3/" + m_stripDesiredHistogram +
"_TECM_W3;1";
259 m_stripBaseDir +
"TEC/MINUS/wheel_4/" + m_stripDesiredHistogram +
"_TECM_W4;1";
261 m_stripBaseDir +
"TEC/MINUS/wheel_5/" + m_stripDesiredHistogram +
"_TECM_W5;1";
263 m_stripBaseDir +
"TEC/MINUS/wheel_6/" + m_stripDesiredHistogram +
"_TECM_W6;1";
265 m_stripBaseDir +
"TEC/MINUS/wheel_7/" + m_stripDesiredHistogram +
"_TECM_W7;1";
267 m_stripBaseDir +
"TEC/MINUS/wheel_8/" + m_stripDesiredHistogram +
"_TECM_W8;1";
269 m_stripBaseDir +
"TEC/MINUS/wheel_9/" + m_stripDesiredHistogram +
"_TECM_W9;1";
272 m_stripBaseDir +
"TEC/PLUS/wheel_1/" + m_stripDesiredHistogram +
"_TECP_W1;1";
274 m_stripBaseDir +
"TEC/PLUS/wheel_2/" + m_stripDesiredHistogram +
"_TECP_W2;1";
276 m_stripBaseDir +
"TEC/PLUS/wheel_3/" + m_stripDesiredHistogram +
"_TECP_W3;1";
278 m_stripBaseDir +
"TEC/PLUS/wheel_4/" + m_stripDesiredHistogram +
"_TECP_W4;1";
280 m_stripBaseDir +
"TEC/PLUS/wheel_5/" + m_stripDesiredHistogram +
"_TECP_W5;1";
282 m_stripBaseDir +
"TEC/PLUS/wheel_6/" + m_stripDesiredHistogram +
"_TECP_W6;1";
284 m_stripBaseDir +
"TEC/PLUS/wheel_7/" + m_stripDesiredHistogram +
"_TECP_W7;1";
286 m_stripBaseDir +
"TEC/PLUS/wheel_8/" + m_stripDesiredHistogram +
"_TECP_W8;1";
288 m_stripBaseDir +
"TEC/PLUS/wheel_9/" + m_stripDesiredHistogram +
"_TECP_W9;1";
298 m_pixelBaseDir +
"PXBarrel/" + m_pixelDesiredHistogramBarrel +
"_PXLayer_2;1";
300 m_pixelBaseDir +
"PXBarrel/" + m_pixelDesiredHistogramBarrel +
"_PXLayer_3;1";
302 m_pixelBaseDir +
"PXBarrel/" + m_pixelDesiredHistogramBarrel +
"_PXLayer_4;1";
307 m_pixelBaseDir +
"PXForward/" + m_pixelDesiredHistogramDisk +
"_PXRing_2;1";
327 case AnalyzeData::RECHITS:
330 case AnalyzeData::DIGIS:
333 case AnalyzeData::CLUSTERS:
337 edm::LogError(
"LogicError") <<
"Unrecognized Analyze mode!" << std::endl;
353 LogInfo(
"Analyzer") <<
"reco::TrackCollection not found... Aborting...\n";
357 for (
auto const&
track : *tracks) {
358 auto recHitsBegin =
track.recHitsBegin();
359 for (
unsigned i = 0;
i <
track.recHitsSize(); ++
i) {
360 auto recHit = *(recHitsBegin +
i);
361 if (!recHit->isValid())
364 DetId id = recHit->geographicalId();
372 trackerMap->Fill(TString::Format(
"%ld", (
long)
id.rawId()), 1);
382 double minx = 0xFFFFFF, maxx = -0xFFFFFF, miny = 0xFFFFFF, maxy = -0xFFFFFFF;
385 TObject* ghostObj =
fs->
make<TH2Poly>(
"ghost",
"ghost", -1, 1, -1, 1);
406 for (
auto pair :
m_bins) {
427 throw cms::Exception(
"TrackerRemapper") <<
"Error Reading File" << std::endl;
434 std::getline(in, line);
438 TObjArray*
array =
string.Tokenize(
" ");
441 for (
int i = 0;
i < array->GetEntries(); ++
i) {
443 detid =
static_cast<TObjString*
>(array->At(
i))->String().Atoll();
453 x[ix] =
static_cast<TObjString*
>(array->At(
i))->String().Atof();
462 y[iy] =
static_cast<TObjString*
>(array->At(
i))->String().Atof();
478 m_bins[detid] =
new TGraph(ix, x, y);
479 m_bins[detid]->SetName(TString::Format(
"%ld", detid));
480 m_bins[detid]->SetTitle(TString::Format(
"Module ID=%ld", detid));
495 for (
int layer = TkLayerMap::TkLayerEnum::TIB_L1;
layer <= TkLayerMap::TkLayerEnum::TECP_W9; ++
layer) {
505 for (
unsigned binx = 1; binx <= (unsigned)nchX; ++binx) {
506 for (
unsigned biny = 1; biny <= (unsigned)nchY; ++biny) {
511 double val = histHandle->GetBinContent(binx, biny);
515 trackerMap->Fill(TString::Format(
"%ld", rawid), val);
521 rootFileHandle->Close();
530 if (!rootFileHandle) {
537 rootFileHandle->Close();
548 for (
auto&
i : pxb) {
552 long rawid =
id.
rawId();
557 int signedOnlineModule = module - 4;
558 if (signedOnlineModule <= 0)
559 --signedOnlineModule;
562 int onlineShell = pixelBarrelName.
shell();
564 int signedOnlineLadder = ((onlineShell & 1) ? -pixelBarrelName.
ladderName() : pixelBarrelName.
ladderName());
566 const TProfile2D* histHandle = (TProfile2D*)rootFileHandle->Get(
m_pixelHistnameMap[layer].c_str());
568 unsigned nx = histHandle->GetNbinsX();
569 unsigned ny = histHandle->GetNbinsY();
571 unsigned binX = signedOnlineModule + ((nx + 1) >> 1);
572 unsigned binY = (signedOnlineLadder) + ((ny + 1) >> 1);
574 double val = histHandle->GetBinContent(binX, binY);
576 trackerMap->Fill(TString::Format(
"%ld", rawid), val);
588 for (
auto&
i : pxf) {
593 int side = tt->
side(
id);
594 int disk = tt->
layer(
id);
596 long rawid =
id.rawId();
600 unsigned layer = pixelEndcapName.
ringName() - 1 + PixelLayerEnum::PXF_R1;
601 const TProfile2D* histHandle = (TProfile2D*)rootFileHandle->Get(
m_pixelHistnameMap[layer].c_str());
604 unsigned nx = histHandle->GetNbinsX();
605 unsigned ny = histHandle->GetNbinsY();
607 int onlineBlade = pixelEndcapName.
bladeName();
608 bool isInnerOnlineBlade = !(pixelEndcapName.
halfCylinder() & 1);
610 int signedOnlineBlade = (isInnerOnlineBlade) ? onlineBlade : -onlineBlade;
611 int signedDisk = (side == 2) ? disk : -disk;
612 int pannel = pixelEndcapName.
pannelName() - 1;
614 unsigned binX = signedDisk + ((nx + 1) >> 1);
615 unsigned binY = (signedOnlineBlade * 2) + (ny >> 1);
617 double val = histHandle->GetBinContent(binX, binY + pannel);
619 trackerMap->Fill(TString::Format(
"%ld", rawid), val);
633 "Creates TH2Poly Strip Tracker maps by either analyzing the event or remapping exising DQM historams");
643 ->
setComment(
"1=Rechits, 2=Digis, 3=Clusters");
void setComment(std::string const &value)
ParameterDescriptionNode * ifValue(ParameterDescription< T > const &switchParameter, std::unique_ptr< ParameterDescriptionCases< T >> cases)
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
std::string m_stripBaseDir
edm::EDGetTokenT< reco::TrackCollection > rechitSrcToken
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventIDconst &, edm::Timestampconst & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
std::string m_stripRemapFile
bool getByToken(EDGetToken token, Handle< PROD > &result) const
edm::EDGetTokenT< edmNew::DetSetVector< SiStripCluster > > clusterSrcToken
#define DEFINE_FWK_MODULE(type)
std::string m_pixelRemapFile
void analyzeGeneric(const edm::Event &iEvent, const edm::EDGetTokenT< T > &src)
constexpr uint32_t rawId() const
get the raw id
unsigned int side(const DetId &id) const
std::map< unsigned, std::string > m_stripHistnameMap
TrackerRemapper(const edm::ParameterSet &)
unsigned int pxbModule(const DetId &id) const
T * make(const Args &...args) const
make new ROOT object
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > topoToken_
auto const & tracks
cannot be loose
Log< level::Error, false > LogError
static constexpr TimeType INVALID
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > geomToken_
std::map< unsigned, std::string > m_pixelHistnameMap
example_stream void analyze(const edm::Event &, const edm::EventSetup &) override
constexpr std::array< uint8_t, layerIndexSize > layer
static std::string const input
bool getData(T &iHolder) const
std::vector< const GeomDet * > DetContainer
int bladeName() const
blade id
void setComment(std::string const &value)
void fillEndcapRemap(TFile *rootFileHandle, const TrackerGeometry *theTrackerGeometry, const TrackerTopology *tt)
TDirectory * getBareDirectory(const std::string &subdir="") const
std::string m_pixelDesiredHistogramDisk
const DetContainer & detsPXB() const
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
DetId geographicalId() const
The label of this GeomDet.
std::string m_stripDesiredHistogram
void fillPixelRemap(const TrackerGeometry *theTrackerGeometry, const TrackerTopology *tt)
~TrackerRemapper() override
ParameterDescriptionBase * add(U const &iLabel, T const &value)
const TkDetMap * m_tkdetmap
edm::EDGetTokenT< edmNew::DetSetVector< SiStripDigi > > digiSrcToken
unsigned int pxbLayer(const DetId &id) const
Log< level::Info, false > LogInfo
void getComponents(int layer, int &nchX, double &lowX, double &highX, int &nchY, double &lowY, double &highY) const
int ladderName() const
ladder id (index in phi)
const edm::ParameterSet & iConfig
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
const edm::ESGetToken< TkDetMap, TrackerTopologyRcd > tkDetMapToken_
void analyzeRechits(const edm::Event &iEvent, const edm::EDGetTokenT< reco::TrackCollection > &src)
void fillBarrelRemap(TFile *rootFileHandle, const TrackerGeometry *theTrackerGeometry, const TrackerTopology *tt)
T getParameter(std::string const &) const
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
edm::Service< TFileService > fs
unsigned int layer(const DetId &id) const
void analyze(const edm::Event &, const edm::EventSetup &) override
int pannelName() const
pannel id
const DetContainer & detsPXF() const
bool isPixel(HitType hitType)
DetId getDetFromBin(int layer, int ix, int iy) const
void readVertices(double &minx, double &maxx, double &miny, double &maxy)
std::map< unsigned, std::string > m_analyzeModeNameMap
int ringName() const
ring Id
std::map< long, TGraph * > m_bins
HalfCylinder halfCylinder() const
std::string m_pixelDesiredHistogramBarrel
std::string m_pixelBaseDir
std::vector< unsigned > m_detIdVector