29 std::vector<std::pair<std::string, std::string>> hnames =
31 for (
unsigned int i = 0;
i < hnames.size();
i++) {
37 auto loc =
APVloc(
id, side, plane, s);
65 consumes<std::vector<unsigned short>>(
edm::InputTag(label, CalibPrefix_ +
"firststrip" + CalibSuffix_));
72 #ifdef ExtendedCALIBTree 74 consumes<std::vector<double>>(
edm::InputTag(label, CalibPrefix_ +
"chargeoverpath" + CalibSuffix_));
77 consumes<std::vector<unsigned char>>(
edm::InputTag(label, CalibPrefix_ +
"amplitude" + CalibSuffix_));
80 consumes<std::vector<double>>(
edm::InputTag(label, CalibPrefix_ +
"gainusedTick" + CalibSuffix_));
99 consumes<std::vector<unsigned int>>(
edm::InputTag(label, TrackPrefix_ +
"hitsvalid" + TrackSuffix_));
108 static constexpr float defaultGainTick = 690. / 640.;
119 edm::LogError(
"SiStripGainPCLWorker") <<
"gainHandle is not valid\n";
132 APV->isMasked = SiStripQuality_->
IsApvBad(APV->DetId, APV->APVId);
135 edm::LogError(
"SiStripGainPCLWorker") <<
"NUMBER OF GAIN TAG IS EXPECTED TO BE 2\n";
139 float newPreviousGain = gainHandle->
getApvGain(APV->APVId, gainHandle->
getRange(APV->DetId, 1), 1);
140 if (APV->PreviousGain != 1 and newPreviousGain != APV->PreviousGain)
141 edm::LogWarning(
"SiStripGainPCLWorker") <<
"WARNING: ParticleGain in the global tag changed\n";
142 APV->PreviousGain = newPreviousGain;
144 float newPreviousGainTick =
145 APV->isMasked ? defaultGainTick : gainHandle->
getApvGain(APV->APVId, gainHandle->
getRange(APV->DetId, 0), 0);
146 if (APV->PreviousGainTick != 1 and newPreviousGainTick != APV->PreviousGainTick) {
148 <<
"WARNING: TickMarkGain in the global tag changed\n" 150 <<
" APV->SubDet: " << APV->SubDet <<
" APV->APVId:" << APV->APVId << std::endl
151 <<
" APV->PreviousGainTick: " << APV->PreviousGainTick <<
" newPreviousGainTick: " << newPreviousGainTick
154 APV->PreviousGainTick = newPreviousGainTick;
165 unsigned int eventnumber = iEvent.
id().
event();
168 edm::LogInfo(
"SiStripGainsPCLWorker") <<
"Processing run " << runnumber <<
" and event " << eventnumber << std::endl;
183 auto trackchi2ndof = handle01.
product();
187 auto trackp = handle02.
product();
191 auto tracketa = handle03.
product();
195 auto trackhitsvalid = handle04.
product();
199 auto trackalgo = handle05.
product();
204 auto trackindex = handle06.
product();
208 auto rawid = handle07.
product();
212 auto firststrip = handle08.
product();
216 auto nstrips = handle09.
product();
220 auto saturation = handle10.
product();
224 auto overlapping = handle11.
product();
228 auto farfromedge = handle12.
product();
238 #ifdef ExtendedCALIBTree 241 auto chargeoverpath = handle15.
product();
250 auto gainused = handle17.
product();
254 auto gainusedTick = handle18.
product();
257 LogDebug(
"SiStripGainsPCLWorker") <<
elem.first <<
" - " <<
elem.second.m_string <<
" " 258 <<
elem.second.m_subdetectorId <<
" " <<
elem.second.m_subdetectorSide <<
" " 259 <<
elem.second.m_subdetectorPlane << std::endl;
266 unsigned int FirstAmplitude = 0;
267 for (
unsigned int i = 0;
i <
charge->size();
i++) {
268 FirstAmplitude += (*nstrips)[
i];
269 int TI = (*trackindex)[
i];
286 std::shared_ptr<stAPVGain>
APV = histograms.
APVsColl.at(
291 if (APV->SubDet > 2 && (*farfromedge)[
i] ==
false)
293 if (APV->SubDet > 2 && (*overlapping)[
i] ==
true)
302 bool Saturation =
false;
303 for (
unsigned int s = 0;
s < (*nstrips)[
i];
s++) {
304 int StripCharge = (*amplitude)[FirstAmplitude - (*nstrips)[
i] +
s];
306 StripCharge = (
int)(StripCharge * (APV->PreviousGain / APV->CalibGain));
308 StripCharge = (
int)(StripCharge / APV->CalibGain);
310 StripCharge = (
int)(StripCharge * APV->PreviousGain);
312 if (StripCharge > 1024) {
315 }
else if (StripCharge > 254) {
319 Charge += StripCharge;
323 }
else if (APV->SubDet > 2) {
324 Charge = (*charge)[
i];
326 Charge = (*charge)[
i] / 265.0;
329 double ClusterChargeOverPath = ((double)Charge) / (*path)[
i];
330 if (APV->SubDet > 2) {
332 ClusterChargeOverPath /= (*gainused)[
i];
335 ClusterChargeOverPath *= (*gainused)[
i];
340 if (APV->SubDet <= 2)
344 histograms.
Charge_Vs_Index[elepos]->Fill(APV->Index, ClusterChargeOverPath);
346 <<
" i " <<
i <<
" useCalibration " <<
useCalibration <<
" FirstSetOfConstants " 348 <<
" APV->CalibGain " << APV->CalibGain <<
" APV->DetId " << APV->DetId
349 <<
" APV->Index " << APV->Index <<
" Charge " << Charge <<
" Path " << (*path)[
i]
350 <<
" ClusterChargeOverPath " << ClusterChargeOverPath << std::endl;
357 if (APV->SubDet > 2) {
358 for (
unsigned int s = 0;
s < (*nstrips)[
i];
s++) {
359 int StripCharge = (*amplitude)[FirstAmplitude - (*nstrips)[
i] +
s];
360 if (StripCharge > 1024)
362 else if (StripCharge > 254)
364 mCharge1 += StripCharge;
365 mCharge2 += StripCharge;
366 mCharge3 += StripCharge;
367 mCharge4 += StripCharge;
370 mCharge2 *= (*gainused)[
i];
371 mCharge3 *= (*gainusedTick)[
i];
372 mCharge4 *= ((*gainused)[
i] * (*gainusedTick)[
i]);
375 LogDebug(
"SiStripGainsPCLWorker") <<
" full charge " << mCharge1 <<
" remove G2 " << mCharge2 <<
" remove G1 " 376 << mCharge3 <<
" remove G1*G2 " << mCharge4 << std::endl;
381 histograms.
Charge_1[elepos][
m]->Fill(((
double)mCharge1) / (*
path)[i]);
382 for (
auto m : indices)
383 histograms.
Charge_2[elepos][
m]->Fill(((
double)mCharge2) / (*
path)[i]);
384 for (
auto m : indices)
385 histograms.
Charge_3[elepos][
m]->Fill(((
double)mCharge3) / (*
path)[i]);
386 for (
auto m : indices)
387 histograms.
Charge_4[elepos][
m]->Fill(((
double)mCharge4) / (*
path)[i]);
399 else if (APV->Eta > 0) {
405 if (APV->Thickness < 0.04) {
408 else if (APV->Thickness > 0.04) {
411 }
else if (APV->Eta > 0) {
412 if (APV->Thickness < 0.04) {
415 else if (APV->Thickness > 0.04) {
436 auto const&
Det = bareTkGeomPtr->
dets();
438 edm::LogInfo(
"SiStripGainsPCLWorker") <<
" Resetting APV struct" << std::endl;
440 unsigned int Index = 0;
442 for (
unsigned int i = 0;
i <
Det.size();
i++) {
453 unsigned int NAPV = Topo.
nstrips() / 128;
455 for (
unsigned int j = 0;
j < NAPV;
j++) {
456 auto APV = std::make_shared<stAPVGain>();
465 APV->FitWidthErr = -1;
469 APV->PreviousGain = 1;
470 APV->PreviousGainTick = 1;
471 APV->x = DetUnit->position().basicVector().x();
472 APV->y = DetUnit->position().basicVector().y();
473 APV->z = DetUnit->position().basicVector().z();
474 APV->Eta = DetUnit->position().basicVector().eta();
475 APV->Phi = DetUnit->position().basicVector().phi();
476 APV->R = DetUnit->position().basicVector().transverse();
477 APV->Thickness = DetUnit->surface().bounds().thickness();
479 APV->isMasked =
false;
489 for (
unsigned int i = 0;
i <
Det.size();
499 unsigned int NROCRow = Topo.
nrows() / (80.);
500 unsigned int NROCCol = Topo.
ncolumns() / (52.);
502 for (
unsigned int j = 0;
j < NROCRow;
j++) {
503 for (
unsigned int i = 0;
i < NROCCol;
i++) {
504 auto APV = std::make_shared<stAPVGain>();
508 APV->APVId = (
j << 3 |
i);
513 APV->FitWidthErr = -1;
516 APV->PreviousGain = 1;
517 APV->PreviousGainTick = 1;
518 APV->x = DetUnit->position().basicVector().x();
519 APV->y = DetUnit->position().basicVector().y();
520 APV->z = DetUnit->position().basicVector().z();
521 APV->Eta = DetUnit->position().basicVector().eta();
522 APV->Phi = DetUnit->position().basicVector().phi();
523 APV->R = DetUnit->position().basicVector().transverse();
524 APV->Thickness = DetUnit->surface().bounds().thickness();
525 APV->isMasked =
false;
559 edm::LogInfo(
"SiStripGainsPCLWorker") <<
"Setting " << dqm_dir <<
" in DQM and booking histograms for tag " << tag
565 if (!stag.empty() && stag[0] !=
'_')
566 stag.insert(0, 1,
'_');
598 std::vector<float> binXarray;
601 binXarray.push_back((
float)
a);
604 std::array<float, 688> binYarray;
606 double p1 = 0.002113;
607 double p2 = 69.01576;
609 for (
int b = 0;
b < 687;
b++) {
614 y = (p0 -
log(
exp(p0 - p1 * y) - p2 * p1)) / p1;
616 binYarray[687] = 4000.;
618 histograms.
Charge_1[elepos].clear();
619 histograms.
Charge_2[elepos].clear();
620 histograms.
Charge_3[elepos].clear();
621 histograms.
Charge_4[elepos].clear();
626 ibooker.
book2S(cvi.c_str(), cvi.c_str(), histograms.
NStripAPVs, &binXarray[0], 687, binYarray.data()));
630 ibooker.
book2S(cvpTIB.c_str(), cvpTIB.c_str(), 20, 0.3, 1.3, 250, 0, 2000));
634 ibooker.
book2S(cvpTOB.c_str(), cvpTOB.c_str(), 20, 0.3, 1.3, 250, 0, 2000));
638 it + elepos, ibooker.
book2S(cvpTIDP.c_str(), cvpTIDP.c_str(), 20, 0.3, 1.3, 250, 0, 2000));
642 it + elepos, ibooker.
book2S(cvpTIDM.c_str(), cvpTIDM.c_str(), 20, 0.3, 1.3, 250, 0, 2000));
646 it + elepos, ibooker.
book2S(cvpTECP1.c_str(), cvpTECP1.c_str(), 20, 0.3, 1.3, 250, 0, 2000));
650 it + elepos, ibooker.
book2S(cvpTECP2.c_str(), cvpTECP2.c_str(), 20, 0.3, 1.3, 250, 0, 2000));
654 it + elepos, ibooker.
book2S(cvpTECM1.c_str(), cvpTECM1.c_str(), 20, 0.3, 1.3, 250, 0, 2000));
658 it + elepos, ibooker.
book2S(cvpTECM2.c_str(), cvpTECM2.c_str(), 20, 0.3, 1.3, 250, 0, 2000));
660 std::vector<std::pair<std::string, std::string>> hnames =
662 for (
unsigned int i = 0;
i < hnames.size();
i++) {
664 histograms.
Charge_1[elepos].push_back(ibooker.
book1DD(htag.c_str(), (hnames[
i]).
second.c_str(), 100, 0., 1000.));
668 for (
unsigned int i = 0;
i < hnames.size();
i++) {
670 histograms.
Charge_2[elepos].push_back(ibooker.
book1DD(htag.c_str(), (hnames[
i]).
second.c_str(), 100, 0., 1000.));
674 for (
unsigned int i = 0;
i < hnames.size();
i++) {
676 histograms.
Charge_3[elepos].push_back(ibooker.
book1DD(htag.c_str(), (hnames[
i]).
second.c_str(), 100, 0., 1000.));
680 for (
unsigned int i = 0;
i < hnames.size();
i++) {
682 histograms.
Charge_4[elepos].push_back(ibooker.
book1DD(htag.c_str(), (hnames[
i]).
second.c_str(), 100, 0., 1000.));
bool IsApvBad(const uint32_t &detid, const short &apvNb) const
edm::EDGetTokenT< std::vector< double > > gainused_token_
EventNumber_t event() const
static constexpr auto TEC
T getUntrackedParameter(std::string const &, T const &) const
virtual int nrows() const =0
std::array< std::vector< dqm::reco::MonitorElement * >, 7 > Charge_4
edm::EDGetTokenT< std::vector< double > > localdirz_token_
edm::EDGetTokenT< std::vector< bool > > saturation_token_
edm::EDGetTokenT< std::vector< double > > trackchi2ndof_token_
edm::EDGetTokenT< std::vector< double > > gainusedTick_token_
size_t getNumberOfTags() const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
std::vector< dqm::reco::MonitorElement * > Charge_Vs_Index
MonitorElement * book2S(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
void setCurrentFolder(std::string const &fullpath)
edm::EDGetTokenT< std::vector< float > > trackp_token_
SiStripGainsPCLWorker(const edm::ParameterSet &)
MonitorElement * book1DD(TString const &name, TString const &title, int nchX, double lowX, double highX)
constexpr uint32_t rawId() const
get the raw id
std::vector< dqm::reco::MonitorElement * > Charge_Vs_PathlengthTOB
int subdetectorPlane(uint32_t, const TrackerTopology *)
std::string m_calibrationMode
std::vector< dqm::reco::MonitorElement * > Charge_Vs_PathlengthTIDP
edm::EDGetTokenT< std::vector< unsigned int > > trackhitsvalid_token_
std::vector< dqm::reco::MonitorElement * > Charge_Vs_PathlengthTIDM
edm::EDGetTokenT< std::vector< unsigned short > > firststrip_token_
edm::EDGetTokenT< std::vector< bool > > farfromedge_token_
edm::EDGetTokenT< std::vector< bool > > overlapping_token_
static float getApvGain(const uint16_t &apv, const SiStripApvGain::Range &range)
std::vector< std::string > dqm_tag_
bool doChargeMonitorPerPlane
U second(std::pair< T, U > const &p)
edm::EDGetTokenT< std::vector< unsigned short > > nstrips_token_
edm::EDGetTokenT< std::vector< double > > tracketa_token_
const DetContainer & dets() const override
Returm a vector of all GeomDet (including all GeomDetUnits)
std::vector< dqm::reco::MonitorElement * > Charge_Vs_PathlengthTECP2
void dqmBeginRun(edm::Run const &, edm::EventSetup const &, APVGain::APVGainHistograms &) const override
void addDefault(ParameterSetDescription const &psetDescription)
std::atomic< unsigned int > NPixelDets
std::array< std::vector< dqm::reco::MonitorElement * >, 7 > Charge_3
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
std::atomic< unsigned int > NStripAPVs
std::vector< unsigned int > FetchIndices(std::map< unsigned int, APVloc >, uint32_t, const TrackerTopology *topo=0)
std::map< unsigned int, APVloc > theTopologyMap
static constexpr auto TOB
edm::EDGetTokenT< std::vector< int > > trackindex_token_
edm::EDGetTokenT< std::vector< double > > localdirx_token_
edm::EDGetTokenT< std::vector< unsigned int > > charge_token_
def elem(elemtype, innerHTML='', html_class='', kwargs)
edm::EDGetTokenT< std::vector< double > > trackphi_token_
static constexpr auto TIB
T const * product() const
edm::EDGetTokenT< std::vector< float > > trackpt_token_
virtual int nstrips() const =0
void checkBookAPVColls(const TrackerGeometry *bareTkGeomPtr, APVGain::APVGainHistograms &histograms) const
std::vector< std::shared_ptr< stAPVGain > > APVsCollOrdered
void dqmAnalyze(edm::Event const &, edm::EventSetup const &, APVGain::APVGainHistograms const &) const override
int subdetectorSide(uint32_t, const TrackerTopology *)
std::vector< std::string > VChargeHisto
std::unordered_map< unsigned int, std::shared_ptr< stAPVGain > > APVsColl
double MaxTrackChiOverNdf
edm::EDGetTokenT< std::vector< double > > path_token_
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &, APVGain::APVGainHistograms &) const override
virtual int ncolumns() const =0
std::array< std::vector< dqm::reco::MonitorElement * >, 7 > Charge_1
std::vector< dqm::reco::MonitorElement * > Charge_Vs_PathlengthTECM2
int statCollectionFromMode(const char *tag) const
edm::EDGetTokenT< std::vector< double > > chargeoverpath_token_
edm::EDGetTokenT< std::vector< int > > trackalgo_token_
std::array< std::vector< dqm::reco::MonitorElement * >, 7 > Charge_2
edm::EDGetTokenT< std::vector< double > > localdiry_token_
std::vector< dqm::reco::MonitorElement * > Charge_Vs_PathlengthTECM1
std::vector< std::pair< std::string, std::string > > monHnames(std::vector< std::string >, bool, const char *tag)
unsigned int MinTrackHits
edm::EDGetTokenT< std::vector< unsigned char > > amplitude_token_
static constexpr auto TID
T const * product() const
std::vector< dqm::reco::MonitorElement * > Charge_Vs_PathlengthTIB
int subdetectorId(uint32_t)
std::vector< dqm::reco::MonitorElement * > Charge_Vs_PathlengthTECP1
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
edm::EDGetTokenT< std::vector< unsigned int > > rawid_token_
const SiStripApvGain::Range getRange(uint32_t detID) const
edm::EDGetTokenT< std::vector< bool > > TrigTech_token_