19 #include <fmt/printf.h>
204 notInPCL_(iConfig.getParameter<bool>(
"notInPCL")),
205 filename_(iConfig.getParameter<std::
string>(
"fileName")),
206 newmodulelist_(iConfig.getParameter<std::
vector<std::
string>>(
"newmodulelist")),
207 ptmin_(iConfig.getParameter<double>(
"ptMin")),
208 normChi2Max_(iConfig.getParameter<double>(
"normChi2Max")),
209 clustSizeYMin_(iConfig.getParameter<std::
vector<int>>(
"clustSizeYMin")),
210 clustSizeXMax_(iConfig.getParameter<int>(
"clustSizeXMax")),
211 residualMax_(iConfig.getParameter<double>(
"residualMax")),
212 clustChargeMaxPerLength_(iConfig.getParameter<double>(
"clustChargeMaxPerLength")),
213 hist_depth_(iConfig.getParameter<int>(
"binsDepth")),
214 hist_drift_(iConfig.getParameter<int>(
"binsDrift")),
230 std::make_unique<TTree>(
"SiPixelLorentzAngleTreeBarrel_",
"SiPixel LorentzAngle tree barrel", bufsize);
231 SiPixelLorentzAngleTreeBarrel_->Branch(
"run", &
run_,
"run/I", bufsize);
232 SiPixelLorentzAngleTreeBarrel_->Branch(
"event", &
event_,
"event/l", bufsize);
233 SiPixelLorentzAngleTreeBarrel_->Branch(
"lumiblock", &
lumiblock_,
"lumiblock/I", bufsize);
234 SiPixelLorentzAngleTreeBarrel_->Branch(
"bx", &
bx_,
"bx/I", bufsize);
235 SiPixelLorentzAngleTreeBarrel_->Branch(
"orbit", &
orbit_,
"orbit/I", bufsize);
236 SiPixelLorentzAngleTreeBarrel_->Branch(
"module", &
module_,
"module/I", bufsize);
237 SiPixelLorentzAngleTreeBarrel_->Branch(
"ladder", &
ladder_,
"ladder/I", bufsize);
238 SiPixelLorentzAngleTreeBarrel_->Branch(
"layer", &
layer_,
"layer/I", bufsize);
239 SiPixelLorentzAngleTreeBarrel_->Branch(
"isflipped", &
isflipped_,
"isflipped/I", bufsize);
240 SiPixelLorentzAngleTreeBarrel_->Branch(
"pt", &
pt_,
"pt/F", bufsize);
241 SiPixelLorentzAngleTreeBarrel_->Branch(
"eta", &
eta_,
"eta/F", bufsize);
242 SiPixelLorentzAngleTreeBarrel_->Branch(
"phi", &
phi_,
"phi/F", bufsize);
243 SiPixelLorentzAngleTreeBarrel_->Branch(
"chi2", &
chi2_,
"chi2/D", bufsize);
244 SiPixelLorentzAngleTreeBarrel_->Branch(
"ndof", &
ndof_,
"ndof/D", bufsize);
245 SiPixelLorentzAngleTreeBarrel_->Branch(
"trackhit", &
trackhit_,
"x/F:y/F:alpha/D:beta/D:gamma_/D", bufsize);
246 SiPixelLorentzAngleTreeBarrel_->Branch(
"npix", &
pixinfo_.
npix,
"npix/I", bufsize);
247 SiPixelLorentzAngleTreeBarrel_->Branch(
"rowpix",
pixinfo_.
row,
"row[npix]/F", bufsize);
248 SiPixelLorentzAngleTreeBarrel_->Branch(
"colpix",
pixinfo_.
col,
"col[npix]/F", bufsize);
249 SiPixelLorentzAngleTreeBarrel_->Branch(
"adc",
pixinfo_.
adc,
"adc[npix]/F", bufsize);
250 SiPixelLorentzAngleTreeBarrel_->Branch(
"xpix",
pixinfo_.
x,
"x[npix]/F", bufsize);
251 SiPixelLorentzAngleTreeBarrel_->Branch(
"ypix",
pixinfo_.
y,
"y[npix]/F", bufsize);
253 SiPixelLorentzAngleTreeBarrel_->Branch(
256 "x/F:y/F:charge/F:size_x/I:size_y/I:maxPixelCol/I:maxPixelRow:minPixelCol/I:minPixelRow/I",
258 SiPixelLorentzAngleTreeBarrel_->Branch(
"rechit", &
rechit_,
"x/F:y/F", bufsize);
259 SiPixelLorentzAngleTreeBarrel_->Branch(
"rechit_corr", &
rechitCorr_,
"x/F:y/F", bufsize);
260 SiPixelLorentzAngleTreeBarrel_->Branch(
"trackhitcorr_x", &
trackhitCorrX_,
"trackhitcorr_x/F", bufsize);
261 SiPixelLorentzAngleTreeBarrel_->Branch(
"trackhitcorr_y", &
trackhitCorrY_,
"trackhitcorr_y/F", bufsize);
262 SiPixelLorentzAngleTreeBarrel_->Branch(
"qScale", &
qScale_,
"qScale/F", bufsize);
263 SiPixelLorentzAngleTreeBarrel_->Branch(
"rQmQt", &
rQmQt_,
"rQmQt/F", bufsize);
267 std::make_unique<TTree>(
"SiPixelLorentzAngleTreeForward_",
"SiPixel LorentzAngle tree forward", bufsize);
294 "x/F:y/F:charge/F:size_x/I:size_y/I:maxPixelCol/I:maxPixelRow:minPixelCol/I:minPixelRow/I",
312 static constexpr
float cmToum = 10000.;
339 if (!trajTrackCollectionHandle->empty()) {
341 it != trajTrackCollectionHandle->end();
347 std::vector<TrajectoryMeasurement> tmColl = traj.
measurements();
362 bool pixeltrack =
false;
365 for (
const auto& itTraj : tmColl) {
366 if (!itTraj.updatedState().isValid())
369 if (!recHit->isValid() || recHit->geographicalId().det() !=
DetId::Tracker)
371 unsigned int subDetID = (recHit->geographicalId().subdetId());
380 DetId detIdObj = recHit->geographicalId();
387 float ypitch_ = topol->
pitch().second;
432 if (trackdirection.
z() == 0)
442 float cotalpha = trackdirection.
x() / trackdirection.
z();
443 float cotbeta = trackdirection.
y() / trackdirection.
z();
445 if (fabs(cotbeta) <= cotbeta_min)
447 double drdz =
sqrt(1. + cotalpha * cotalpha + cotbeta * cotbeta);
450 auto detId = detIdObj.
rawId();
451 int DetId_index = -1;
463 float locBx = (cotbeta < 0.) ? -1 : 1.;
464 float locBz = (cotalpha < 0.) ? -locBx : locBx;
467 theTemplate.
interpolate(TemplID, cotalpha, cotbeta, locBz, locBx);
488 bool large_pix =
false;
492 colpos % 52 == 0 || colpos % 52 == 51) {
501 double hypitch_ = ypitch_ / 2.;
518 if (ylim2 < ypixhigh)
523 if (ylim1 < ypixhigh)
526 float ypixavg = 0.5 * (ypixlow + ypixhigh);
529 float dy = (ypixavg - ylim1) * cmToum;
533 if (isNewMod ==
false) {
542 int i_index_merge = i_index + 1;
549 int i_index_merge = i_index - 1;
569 DetId detIdObj = recHit->geographicalId();
615 if (trackdirection.
z() == 0)
624 float cotalpha = trackdirection.
x() / trackdirection.
z();
625 float cotbeta = trackdirection.
y() / trackdirection.
z();
627 auto detId = detIdObj.
rawId();
633 float locBx = (cotbeta < 0.) ? -1 : 1.;
634 float locBz = (cotalpha < 0.) ? -locBx : locBx;
637 theTemplate.
interpolate(TemplID, cotalpha, cotbeta, locBz, locBx);
672 <<
"Templates not filled correctly. Check the sqlite file. Using SiPixelTemplateDBObject version "
673 << (*templateDBobject_).version();
691 if (modulename.find(
"BPix_") != std::string::npos) {
693 const auto& detId = bn.
getDetId(tTopo);
698 }
else if (modulename.find(
"FPix_") != std::string::npos) {
700 const auto& detId = en.
getDetId(tTopo);
718 "h_bySectorOccupancy",
"hit occupancy by sector;pixel sector;hits on track", maxSect, -0.5, maxSect - 0.5);
721 static constexpr
double min_depth_ = -100.;
722 static constexpr
double max_depth_ = 400.;
723 static constexpr
double min_drift_ = -500.;
724 static constexpr
double max_drift_ = 500.;
729 for (
int i_layer = 1; i_layer <=
iHists.
nlay; i_layer++) {
730 for (
int i_module = 1; i_module <=
iHists.
nModules_[i_layer - 1]; i_module++) {
731 unsigned int i_index = i_module + (i_layer - 1) *
iHists.
nModules_[i_layer - 1];
732 std::string binName = fmt::sprintf(
"BPix Layer%i Module %i", i_layer, i_module);
733 LogDebug(
"SiPixelLorentzAnglePCLWorker") <<
" i_index: " << i_index <<
" bin name: " << binName
734 <<
" (i_layer: " << i_layer <<
" i_module:" << i_module <<
")";
738 sprintf(name,
"h_mean_layer%i_module%i", i_layer, i_module);
740 "average drift vs depth layer%i module%i; production depth [#mum]; #LTdrift#GT [#mum]",
749 "average drift vs depth %s; production depth [#mum]; #LTdrift#GT [#mum]",
760 for (
int i_layer = 1; i_layer <=
iHists.
nlay; i_layer++) {
762 for (
int i_module = 1; i_module <=
iHists.
nModules_[i_layer - 1]; i_module++) {
763 unsigned int i_index = i_module + (i_layer - 1) *
iHists.
nModules_[i_layer - 1];
765 sprintf(name,
"h_drift_depth_adc_layer%i_module%i", i_layer, i_module);
766 sprintf(title,
"depth vs drift (ADC) layer%i module%i; drift [#mum]; production depth [#mum]", i_layer, i_module);
770 sprintf(name,
"h_drift_depth_adc2_layer%i_module%i", i_layer, i_module);
772 title,
"depth vs drift (ADC^{2}) layer%i module%i; drift [#mum]; production depth [#mum]", i_layer, i_module);
776 sprintf(name,
"h_drift_depth_noadc_layer%i_module%i", i_layer, i_module);
778 title,
"depth vs drift (no ADC) layer%i module%i; drift [#mum]; production depth [#mum]", i_layer, i_module);
782 sprintf(name,
"h_drift_depth_layer%i_module%i", i_layer, i_module);
783 sprintf(title,
"depth vs drift layer%i module%i; drift [#mum]; production depth [#mum]", i_layer, i_module);
802 "depth vs drift (ADC^{2}) %s; drift [#mum]; production depth [#mum]",
809 "depth vs drift (no ADC)%s; drift [#mum]; production depth [#mum]",
842 const std::vector<SiPixelCluster::Pixel>& pixvector = LocPix.
pixels();
844 for (std::vector<SiPixelCluster::Pixel>::const_iterator itPix = pixvector.begin(); itPix != pixvector.end();
846 pixinfo.
row[pixinfo.
npix] = itPix->x;
847 pixinfo.
col[pixinfo.
npix] = itPix->y;
848 pixinfo.
adc[pixinfo.
npix] = itPix->adc;
850 pixinfo.
x[pixinfo.
npix] = lp.
x();
851 pixinfo.
y[pixinfo.
npix] = lp.
y();
864 std::pair<float, float> pixels_track = topol->
pixel(trackposition, localTrackAngles);
865 std::pair<float, float> pixels_rechit = topol->
pixel(recHitPix->
localPosition(), localTrackAngles);
871 std::pair<LocalPoint, LocalPoint> lps = std::make_pair(lp_track, lp_rechit);
878 desc.
setComment(
"Worker module of the SiPixel Lorentz Angle PCL monitoring workflow");
879 desc.
add<
std::string>(
"folder",
"AlCaReco/SiPixelLorentzAngle")->setComment(
"directory of PCL Worker output");
880 desc.
add<
bool>(
"notInPCL",
false)->setComment(
"create TTree (true) or not (false)");
881 desc.
add<
std::string>(
"fileName",
"testrun.root")->setComment(
"name of the TTree file if notInPCL = true");
882 desc.
add<std::vector<std::string>>(
"newmodulelist", {})->setComment(
"the list of DetIds for new sensors");
884 desc.
add<
double>(
"ptMin", 3.)->
setComment(
"minimum pt on tracks");
885 desc.
add<
double>(
"normChi2Max", 2.)->
setComment(
"maximum reduced chi squared");
886 desc.
add<std::vector<int>>(
"clustSizeYMin", {4, 4, 3, 2})
887 ->setComment(
"minimum cluster size on Y axis for all Barrel Layers");
888 desc.
add<
int>(
"clustSizeXMax", 5)->setComment(
"maximum cluster size on X axis");
889 desc.
add<
double>(
"residualMax", 0.005)->
setComment(
"maximum residual");
890 desc.
add<
double>(
"clustChargeMaxPerLength", 50000)
891 ->setComment(
"maximum cluster charge per unit length of pixel depth (z)");
892 desc.
add<
int>(
"binsDepth", 50)->setComment(
"# bins for electron production depth axis");
893 desc.
add<
int>(
"binsDrift", 100)->setComment(
"# bins for electron drift axis");
dqm::reco::MonitorElement * h_trackPt_
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
std::vector< int > BPixnewModule_
EventNumber_t event() const
void setComment(std::string const &value)
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
void dqmBeginRun(edm::Run const &, edm::EventSetup const &) override
~SiPixelLorentzAnglePCLWorker() override=default
std::vector< SiPixelTemplateStore > thePixelTemp_
virtual std::pair< float, float > pixel(const LocalPoint &p) const =0
bool interpolate(int id, float cotalpha, float cotbeta, float locBz, float locBx)
virtual LocalPoint localPosition(const MeasurementPoint &) const =0
const LocalTrajectoryParameters & localParameters() const
virtual void setCurrentFolder(std::string const &fullpath)
int moduleName() const
module id (index in z)
friend struct const_iterator
bool getByToken(EDGetToken token, Handle< PROD > &result) const
short getTemplateID(const uint32_t &detid) const
std::vector< std::string > FPixnewmodulename_
#define DEFINE_FWK_MODULE(type)
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > topoPerEventEsToken_
unsigned int pxfDisk(const DetId &id) const
LocalVector localDirection() const
LocalPoint localPosition() const
LocalVector drift(const StripGeomDetUnit *, const MagneticField &, const SiStripLorentzAngle &)
unsigned int pxbLadder(const DetId &id) const
constexpr uint32_t rawId() const
get the raw id
int bunchCrossing() const
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > geomPerEventEsToken_
edm::LuminosityBlockNumber_t luminosityBlock() const
double phi() const
azimuthal angle of momentum vector
const Bounds & bounds() const
unsigned int pxbModule(const DetId &id) const
const std::pair< LocalPoint, LocalPoint > surface_deformation(const PixelTopology *topol, TrajectoryStateOnSurface &tsos, const SiPixelRecHit *recHitPix) const
edm::ESWatcher< SiPixelTemplateDBObjectESProducerRcd > watchSiPixelTemplateRcd_
std::vector< int > nModules_
Log< level::Error, false > LogError
MonitorMap h_drift_depth_
float r_qMeas_qTrue()
ratio of measured to true cluster charge
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
const Plane & surface() const
The nominal surface of the GeomDet.
std::vector< int > clustSizeYMin_
std::vector< int > FPixnewDetIds_
unsigned int numberOfLayers(int subdet) const
std::vector< unsigned int > BPixnewDetIds_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
MonitorMap h_drift_depth_noadc_
virtual float thickness() const =0
bool getData(T &iHolder) const
int bladeName() const
blade id
DataContainer const & measurements() const
void setComment(std::string const &value)
float qscale()
charge scaling factor
dqm::reco::MonitorElement * h_trackEta_
Measurement2DPoint MeasurementPoint
Measurement points are two-dimensional by default.
double eta() const
pseudorapidity of momentum vector
const SiPixelTemplateDBObject * templateDBobject_
std::shared_ptr< TrackingRecHit const > ConstRecHitPointer
const unsigned getPXBModules(unsigned int lay) const
double clustChargeMaxPerLength_
double pt() const
track transverse momentum
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > topoEsToken_
std::unique_ptr< TTree > SiPixelLorentzAngleTreeBarrel_
Tan< T >::type tan(const T &t)
std::vector< std::string > newmodulelist_
dqm::reco::MonitorElement * h_bySectOccupancy_
ModuleType getDetectorType(DetId) const
SiPixelLorentzAnglePCLWorker(const edm::ParameterSet &)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
virtual void setBinLabel(int bin, const std::string &label, int axis=1)
set bin label for x, y or z axis (axis=1, 2, 3 respectively)
const TrackerGeomDet * idToDet(DetId) const override
PXFDetId getDetId()
return DetId
unsigned int pxfModule(const DetId &id) const
unsigned int pxbLayer(const DetId &id) const
int ndof(bool bon=true) const
dqm::reco::MonitorElement * h_trackPhi_
dqm::reco::MonitorElement * h_tracks_
ClusterRef cluster() const
SiPixelLorentzAngleCalibrationHistograms iHists
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > geomEsToken_
virtual const PixelTopology & specificTopology() const
Returns a reference to the pixel proxy topology.
int layerName() const
layer id
T getParameter(std::string const &) const
MonitorMap h_drift_depth_adc_
std::vector< int > FPixnewBlade_
MonitorMap h_drift_depth_adc2_
bool check(const edm::EventSetup &iSetup)
static bool pushfile(int filenum, std::vector< SiPixelTemplateStore > &pixelTemp, std::string dir="CalibTracker/SiPixelESProducers/data/")
edm::ESGetToken< SiPixelTemplateDBObject, SiPixelTemplateDBObjectESProducerRcd > siPixelTemplateEsToken_
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Pixel cluster – collection of neighboring pixels above threshold.
LocalPoint localPosition() const override
edm::EDGetTokenT< TrajTrackAssociationCollection > t_trajTrack
unsigned int pxfSide(const DetId &id) const
std::vector< std::string > BPixnewmodulename_
int diskName() const
disk id
std::vector< int > FPixnewDisk_
virtual std::pair< float, float > pitch() const =0
std::vector< int > BPixnewLayer_
Log< level::Warning, false > LogWarning
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
static constexpr float cmToum
std::unique_ptr< TFile > hFile_
dqm::reco::MonitorElement * h_trackChi2_
PXBDetId getDetId()
return the DetId
unsigned int pxfPanel(const DetId &id) const
unsigned int pxfBlade(const DetId &id) const
void dqmEndRun(edm::Run const &, edm::EventSetup const &)
const std::vector< Pixel > pixels() const
void analyze(edm::Event const &, edm::EventSetup const &) override
const Pixinfo fillPix(const SiPixelCluster &LocPix, const PixelTopology *topol) const
std::unique_ptr< TTree > SiPixelLorentzAngleTreeForward_
Point3DBase< float, LocalTag > Local3DPoint