-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7b8d6f8
commit c9c907a
Showing
6 changed files
with
1,257 additions
and
0 deletions.
There are no files selected for viewing
177 changes: 177 additions & 0 deletions
177
DQM/SiPixelPhase1Analyzer/interface/SiPixelPhase1Analyzer.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,177 @@ | ||
#ifndef SiPixelPhase1Analyzer__H_ | ||
#define SiPixelPhase1Analyzer__H_ | ||
|
||
/**\class SiPixelPhase1Analyzer SiPixelPhase1Analyzer.cc EJTerm/SiPixelPhase1Analyzer/plugins/SiPixelPhase1Analyzer.cc | ||
Description: [one line class summary] | ||
Implementation: | ||
[Notes on implementation] | ||
*/ | ||
// | ||
// Original Author: Pawel Jurgielewicz | ||
// Created: Tue, 21 Feb 2017 09:42:19 GMT | ||
// | ||
// | ||
|
||
// system include files | ||
#include <memory> | ||
|
||
// #include <iostream> | ||
#include <fstream> | ||
#include <string> | ||
|
||
#include <algorithm> | ||
|
||
#include <vector> | ||
#include <map> | ||
|
||
|
||
// user include files | ||
#include "DQM/SiPixelPhase1Analyzer/interface/mat4.h" | ||
|
||
#include "FWCore/Framework/interface/Frameworkfwd.h" | ||
#include "FWCore/Framework/interface/one/EDAnalyzer.h" | ||
|
||
#include "FWCore/Framework/interface/Event.h" | ||
#include "FWCore/Framework/interface/MakerMacros.h" | ||
|
||
#include "FWCore/ParameterSet/interface/ParameterSet.h" | ||
|
||
#include "FWCore/Framework/interface/ESHandle.h" | ||
|
||
#include "FWCore/MessageLogger/interface/MessageLogger.h" | ||
|
||
#include "Geometry/Records/interface/TrackerDigiGeometryRecord.h" | ||
#include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h" | ||
#include "Geometry/TrackerGeometryBuilder/interface/PixelGeomDetUnit.h" | ||
#include "Geometry/CommonTopologies/interface/PixelTopology.h" | ||
|
||
#include "DataFormats/SiPixelDetId/interface/PXBDetId.h" | ||
#include "DataFormats/SiPixelDetId/interface/PXFDetId.h" | ||
#include "DataFormats/SiPixelDetId/interface/PixelEndcapName.h" | ||
#include "DataFormats/SiPixelDetId/interface/PixelBarrelName.h" | ||
#include "DataFormats/TrackerCommon/interface/TrackerTopology.h" | ||
#include "DataFormats/TrackReco/interface/Track.h" | ||
#include "DataFormats/TrackReco/interface/TrackFwd.h" | ||
#include "DataFormats/GeometrySurface/interface/RectangularPlaneBounds.h" | ||
#include "DataFormats/GeometrySurface/interface/TrapezoidalPlaneBounds.h" | ||
#include "DataFormats/TrackerRecHit2D/interface/SiPixelRecHitCollection.h" | ||
#include "RecoTracker/TkDetLayers/src/DiskSectorBounds.h" | ||
|
||
#include "FWCore/ServiceRegistry/interface/Service.h" | ||
#include "CommonTools/UtilAlgos/interface/TFileService.h" | ||
|
||
#include "TH2.h" | ||
#include "TProfile2D.h" | ||
#include "TH2Poly.h" | ||
#include "TGraph.h" | ||
|
||
#define CODE_FORWARD(s, d, b) ((unsigned short)((b << 8) + (d << 4) + s)) | ||
|
||
// #define DEBUG_MODE | ||
|
||
// | ||
// class declaration | ||
// | ||
|
||
// If the analyzer does not use TFileService, please remove | ||
// the template argument to the base class so the class inherits | ||
// from edm::one::EDAnalyzer<> and also remove the line from | ||
// constructor "usesResource("TFileService");" | ||
// This will improve performance in multithreaded jobs. | ||
|
||
using namespace std; | ||
using namespace edm; | ||
|
||
enum OperationMode {MODE_ANALYZE = 0, MODE_REMAP = 1}; | ||
|
||
class SiPixelPhase1Analyzer : public edm::one::EDAnalyzer<edm::one::SharedResources> { | ||
public: | ||
explicit SiPixelPhase1Analyzer(const edm::ParameterSet&); | ||
~SiPixelPhase1Analyzer(); | ||
|
||
static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); | ||
|
||
private: | ||
virtual void beginJob() override; | ||
virtual void analyze(const edm::Event&, const edm::EventSetup&) override; | ||
virtual void endJob() override; | ||
|
||
void BookHistograms(); | ||
|
||
void BookBarrelHistograms(TDirectory* currentDir, const string& currentHistoName); | ||
void BookForwardHistograms(TDirectory* currentDir, const string& currentHistoName); | ||
|
||
void BookBins(ESHandle < TrackerGeometry >& theTrackerGeometry, const TrackerTopology* tt); | ||
void BookBarrelBins(ESHandle < TrackerGeometry >& theTrackerGeometry, const TrackerTopology* tt); | ||
void BookForwardBins(ESHandle < TrackerGeometry >& theTrackerGeometry, const TrackerTopology* tt); | ||
|
||
void SaveDetectorVertices(const TrackerTopology* tt); | ||
|
||
void FillBins(edm::Handle<reco::TrackCollection> *tracks, ESHandle < TrackerGeometry >& theTrackerGeometry, const TrackerTopology* tt); | ||
|
||
void FillBarrelBinsAnalyze(ESHandle < TrackerGeometry >& theTrackerGeometry, const TrackerTopology* tt, unsigned rawId, const GlobalPoint& globalPoint); | ||
void FillForwardBinsAnalyze(ESHandle < TrackerGeometry >& theTrackerGeometry, const TrackerTopology* tt, unsigned rawId, const GlobalPoint& globalPoint); | ||
|
||
void FillBarrelBinsRemap(ESHandle < TrackerGeometry >& theTrackerGeometry, const TrackerTopology* tt); | ||
void FillForwardBinsRemap(ESHandle < TrackerGeometry >& theTrackerGeometry, const TrackerTopology* tt); | ||
|
||
// ----------member data --------------------------- | ||
OperationMode opMode; | ||
|
||
edm::EDGetTokenT<reco::TrackCollection> tracksToken; | ||
|
||
string debugFileName; | ||
std::ofstream debugFile; | ||
|
||
edm::Service < TFileService > fs; | ||
|
||
bool firstEvent; | ||
|
||
map<uint32_t, TGraph*> bins, binsSummary; | ||
|
||
map< string, vector<TH2Poly*> > th2PolyBarrel; | ||
map< string, TH2Poly* > th2PolyBarrelSummary; | ||
|
||
#ifdef DEBUG_MODE | ||
map< string, vector<TH2*> >th2PolyBarrelDebug; | ||
#endif | ||
|
||
map< string, vector<TH2Poly*> > pxfTh2PolyForward; | ||
map< string, TH2Poly* > pxfTh2PolyForwardSummary; | ||
|
||
#ifdef DEBUG_MODE | ||
map< string, vector<TH2*> > pxfTh2PolyForwardDebug; | ||
#endif | ||
|
||
mat4 orthoProjectionMatrix; | ||
|
||
struct complementaryElements | ||
{ | ||
mat4 mat[2]; | ||
unsigned rawId[2]; | ||
}; | ||
// used to hold information about elements': ids & matrices which are of the same side, disk and barrel but different panel | ||
// to build trapezoidal ring elements | ||
map<unsigned short, complementaryElements> mapOfComplementaryElements; | ||
|
||
//Input root file handle; | ||
TFile *rootFileHandle; | ||
|
||
// read input histograms | ||
vector<unsigned> isBarrelSource; | ||
vector<string> analazedRootFileName; | ||
vector<string> pathToHistograms; | ||
vector<string> baseHistogramName; | ||
|
||
// temporal functionality | ||
void SaveDetectorData(bool isBarrel, unsigned rawId, int shell_hc, int layer_disk, int ladder_blade) | ||
{ | ||
static std::ofstream file("det.data", std::ofstream::out); | ||
|
||
file << isBarrel << "\t" << rawId << "\t" << shell_hc << "\t" << layer_disk << "\t" << ladder_blade << endl; | ||
} | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
#ifndef MAT4__H_ | ||
#define MAT4__H_ | ||
|
||
// helper class for matrix operations | ||
// - 4 rows | ||
// - 3 columns | ||
// in math operations behaves like 4x4 matrix with 4th row equal to: [0, 0, 0, 1] | ||
// ! it's just the minimum implementation ! | ||
class mat4 | ||
{ | ||
public: | ||
|
||
float data[12]; | ||
|
||
mat4() {} | ||
|
||
mat4(float r00, float r10, float r20, | ||
float r01, float r11, float r21, | ||
float r02, float r12, float r22, | ||
float x, float y, float z) | ||
{ | ||
data[0] = r00; | ||
data[1] = r10; | ||
data[2] = r20; | ||
|
||
data[3] = r01; | ||
data[4] = r11; | ||
data[5] = r21; | ||
|
||
data[6] = r02; | ||
data[7] = r12; | ||
data[8] = r22; | ||
|
||
data[9] = x; | ||
data[10] = y; | ||
data[11] = z; | ||
} | ||
|
||
mat4(const mat4& mat) | ||
{ | ||
for (unsigned i = 0; i < 12; ++i) data[i] = mat[i]; | ||
} | ||
|
||
mat4& operator&(const mat4& mat) | ||
{ | ||
if (this != &mat) | ||
{ | ||
for (unsigned i = 0; i < 12; ++i) data[i] = mat[i]; | ||
} | ||
return *this; | ||
} | ||
|
||
mat4 operator+(const mat4& mat) const | ||
{ | ||
mat4 tmp; | ||
for (unsigned i = 0; i < 12; ++i) tmp[i] = (*this)[i] + mat[i]; | ||
|
||
return tmp; | ||
} | ||
|
||
mat4 operator*(float s) const | ||
{ | ||
mat4 tmp; | ||
for (unsigned i = 0; i < 12; ++i) tmp[i] = (*this)[i] * s; | ||
|
||
return tmp; | ||
} | ||
|
||
float& operator[](unsigned i) | ||
{ | ||
return data[i]; | ||
} | ||
|
||
float operator[](unsigned i) const | ||
{ | ||
return data[i]; | ||
} | ||
|
||
void MulVec(const float* vecIn, float* vecOut) | ||
{ | ||
for (unsigned i = 0; i < 3; ++i) | ||
{ | ||
float temp = 0; | ||
for (unsigned j = 0; j < 3; ++j) | ||
{ | ||
temp += data[3 * j + i] * vecIn[j]; | ||
} | ||
vecOut[i] = temp + data[9 + i]; | ||
} | ||
} | ||
void BuildOrthographicMatrix(float left, float right, | ||
float top, float bottom, | ||
float near, float far) | ||
{ | ||
float rmli = 1.0f / (right - left); | ||
float rpl = right + left; | ||
|
||
float tmbi = 1.0f / (top - bottom); | ||
float tpb = top + bottom; | ||
|
||
float fmni = 1.0f / (far - near); | ||
float fpn = far + near; | ||
|
||
data[0] = 2.0f * rmli; | ||
data[1] = 0.0f; | ||
data[2] = 0.0f; | ||
|
||
data[3] = 0.0f; | ||
data[4] = 2.0f * tmbi; | ||
data[5] = 0.0f; | ||
|
||
data[6] = 0.0f; | ||
data[7] = 0.0f; | ||
data[8] = -2.0f * fmni; | ||
|
||
data[9] = -rpl * rmli; | ||
data[10] = -tpb * tmbi; | ||
data[11] = -fpn * fmni; | ||
} | ||
|
||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<use name="FWCore/Framework"/> | ||
<use name="FWCore/PluginManager"/> | ||
<use name="FWCore/ParameterSet"/> | ||
|
||
< use name="Geometry/Records"/> | ||
< use name="Geometry/TrackerGeometryBuilder"/> | ||
< use name="Geometry/CommonTopologies"/> | ||
|
||
< use name="CommonTools/UtilAlgos"/> | ||
< use name="DataFormats/GeometrySurface"/> | ||
< use name="RecoTracker/TkDetLayers"/> | ||
|
||
< use name="DataFormats/TrackerCommon"/> | ||
< use name="DataFormats/TrackerRecHit2D"/> | ||
< use name="DataFormats/TrackReco"/> | ||
|
||
<flags EDM_PLUGIN="1"/> |
Oops, something went wrong.