110 std::vector<std::string>::const_iterator it =
dqm_tag_.begin();
147 std::vector<std::pair<std::string, std::string>> hnames =
149 for (
unsigned int i = 0;
i < hnames.size();
i++) {
156 auto loc =
APVloc(thick,
id, side, plane,
s);
188 gainToken_ = esConsumes<edm::Transition::BeginRun>();
203 if (!gainHandle.isValid()) {
204 edm::LogError(
"SiStripGainPCLWorker") <<
"gainHandle is not valid\n";
210 for (
unsigned int a = 0;
a <
histograms.APVsCollOrdered.size();
a++) {
216 APV->isMasked = SiStripQuality_->IsApvBad(
APV->DetId,
APV->APVId);
218 if (gainHandle->getNumberOfTags() != 2) {
219 edm::LogError(
"SiStripGainPCLWorker") <<
"NUMBER OF GAIN TAG IS EXPECTED TO BE 2\n";
223 float newPreviousGain = gainHandle->getApvGain(
APV->APVId, gainHandle->getRange(
APV->DetId, 1), 1);
224 if (
APV->PreviousGain != 1 and newPreviousGain !=
APV->PreviousGain)
225 edm::LogWarning(
"SiStripGainPCLWorker") <<
"WARNING: ParticleGain in the global tag changed\n";
226 APV->PreviousGain = newPreviousGain;
228 float newPreviousGainTick = gainHandle->getApvGain(
APV->APVId, gainHandle->getRange(
APV->DetId, 0), 0);
229 if (
APV->PreviousGainTick != 1 and newPreviousGainTick !=
APV->PreviousGainTick) {
231 <<
"WARNING: TickMarkGain in the global tag changed\n" 233 <<
" APV->SubDet: " <<
APV->SubDet <<
" APV->APVId:" <<
APV->APVId << std::endl
234 <<
" APV->PreviousGainTick: " <<
APV->PreviousGainTick <<
" newPreviousGainTick: " << newPreviousGainTick
237 APV->PreviousGainTick = newPreviousGainTick;
250 LogDebug(
"SiStripGainsCalibTreeWorker")
251 << elem.first <<
" - " << elem.second.m_string <<
" " << elem.second.m_subdetectorId <<
" " 252 << elem.second.m_subdetectorSide <<
" " << elem.second.m_subdetectorPlane << std::endl;
258 unsigned int eventnumber = 0;
260 #ifdef ExtendedCALIBTree 261 const std::vector<bool>* TrigTech =
nullptr;
262 const std::vector<double>* chargeoverpath =
nullptr;
265 const std::vector<double>* trackchi2ndof =
nullptr;
266 const std::vector<float>* trackp =
nullptr;
267 const std::vector<float>* trackpt =
nullptr;
268 const std::vector<double>* tracketa =
nullptr;
269 const std::vector<double>* trackphi =
nullptr;
270 const std::vector<unsigned int>* trackhitsvalid =
nullptr;
271 const std::vector<int>* trackalgo =
nullptr;
273 const std::vector<int>* trackindex =
nullptr;
274 const std::vector<unsigned int>* rawid =
nullptr;
275 const std::vector<double>* localdirx =
nullptr;
276 const std::vector<double>* localdiry =
nullptr;
277 const std::vector<double>* localdirz =
nullptr;
278 const std::vector<unsigned short>* firststrip =
nullptr;
279 const std::vector<unsigned short>* nstrips =
nullptr;
280 const std::vector<bool>*
saturation =
nullptr;
281 const std::vector<bool>* overlapping =
nullptr;
282 const std::vector<bool>* farfromedge =
nullptr;
283 const std::vector<unsigned int>*
charge =
nullptr;
284 const std::vector<double>*
path =
nullptr;
285 const std::vector<unsigned char>*
amplitude =
nullptr;
286 const std::vector<double>* gainused =
nullptr;
287 const std::vector<double>* gainusedTick =
nullptr;
291 tree.Add(ctFn.c_str());
296 #ifdef ExtendedCALIBTree 326 const auto nEntries =
tree.GetEntries();
327 printf(
"Progressing Bar :0%% 20%% 40%% 60%% 80%% 100%%\n");
328 printf(
"Looping on the Tree :");
329 const auto treeProgStep =
std::max(nEntries / 50, Long64_t(1));
330 for (Long64_t
i{0};
i != nEntries; ++
i) {
331 if ((
i % treeProgStep) == 0) {
337 unsigned int FirstAmplitude = 0;
338 for (
unsigned int i = 0;
i <
charge->size();
i++) {
339 FirstAmplitude += (*nstrips)[
i];
340 int TI = (*trackindex)[
i];
362 if (
APV->SubDet > 2 && (*farfromedge)[
i] ==
false)
364 if (
APV->SubDet > 2 && (*overlapping)[
i] ==
true)
373 bool Saturation =
false;
374 for (
unsigned int s = 0;
s < (*nstrips)[
i];
s++) {
375 int StripCharge = (*amplitude)[FirstAmplitude - (*nstrips)[
i] +
s];
377 StripCharge = (
int)(StripCharge * (
APV->PreviousGain /
APV->CalibGain));
379 StripCharge = (
int)(StripCharge /
APV->CalibGain);
381 StripCharge = (
int)(StripCharge *
APV->PreviousGain);
383 if (StripCharge > 1024) {
386 }
else if (StripCharge > 254) {
394 }
else if (
APV->SubDet > 2) {
400 double ClusterChargeOverPath = ((double)
Charge) / (*path)[
i];
401 if (
APV->SubDet > 2) {
403 ClusterChargeOverPath /= (*gainused)[
i];
406 ClusterChargeOverPath *= (*gainused)[
i];
411 if (
APV->SubDet <= 2)
415 histograms.Charge_Vs_Index[elepos]->Fill(
APV->Index, ClusterChargeOverPath);
416 LogDebug(
"SiStripGainsCalibTreeWorker")
419 <<
" APV->PreviousGain " <<
APV->PreviousGain <<
" APV->CalibGain " <<
APV->CalibGain <<
" APV->DetId " 420 <<
APV->DetId <<
" APV->Index " <<
APV->Index <<
" Charge " <<
Charge <<
" Path " << (*path)[
i]
421 <<
" ClusterChargeOverPath " << ClusterChargeOverPath << std::endl;
428 if (
APV->SubDet > 2) {
429 for (
unsigned int s = 0;
s < (*nstrips)[
i];
s++) {
430 int StripCharge = (*amplitude)[FirstAmplitude - (*nstrips)[
i] +
s];
431 if (StripCharge > 1024)
433 else if (StripCharge > 254)
435 mCharge1 += StripCharge;
436 mCharge2 += StripCharge;
437 mCharge3 += StripCharge;
438 mCharge4 += StripCharge;
441 mCharge2 *= (*gainused)[
i];
442 mCharge3 *= (*gainusedTick)[
i];
443 mCharge4 *= ((*gainused)[
i] * (*gainusedTick)[
i]);
446 LogDebug(
"SiStripGainsCalibTreeWorker")
447 <<
" full charge " << mCharge1 <<
" remove G2 " << mCharge2 <<
" remove G1 " << mCharge3 <<
" remove G1*G2 " 448 << mCharge4 << std::endl;
471 else if (
APV->Eta > 0) {
477 if (
APV->Thickness < 0.04) {
480 else if (
APV->Thickness > 0.04) {
483 }
else if (
APV->Eta > 0) {
484 if (
APV->Thickness < 0.04) {
487 else if (
APV->Thickness > 0.04) {
510 auto const&
Det = bareTkGeomPtr->
dets();
512 edm::LogInfo(
"SiStripGainsCalibTreeWorker") <<
" Resetting APV struct" << std::endl;
514 unsigned int Index = 0;
516 for (
unsigned int i = 0;
i <
Det.size();
i++) {
527 unsigned int NAPV = Topo.
nstrips() / 128;
529 for (
unsigned int j = 0;
j < NAPV;
j++) {
530 auto APV = std::make_shared<stAPVGain>();
539 APV->FitWidthErr = -1;
543 APV->PreviousGain = 1;
544 APV->PreviousGainTick = 1;
545 APV->x = DetUnit->position().basicVector().x();
546 APV->y = DetUnit->position().basicVector().y();
547 APV->z = DetUnit->position().basicVector().z();
548 APV->Eta = DetUnit->position().basicVector().eta();
549 APV->Phi = DetUnit->position().basicVector().phi();
550 APV->R = DetUnit->position().basicVector().transverse();
551 APV->Thickness = DetUnit->surface().bounds().thickness();
553 APV->isMasked =
false;
563 for (
unsigned int i = 0;
i <
Det.size();
573 unsigned int NROCRow = Topo.
nrows() / (80.);
574 unsigned int NROCCol = Topo.
ncolumns() / (52.);
576 for (
unsigned int j = 0;
j < NROCRow;
j++) {
577 for (
unsigned int i = 0;
i < NROCCol;
i++) {
578 auto APV = std::make_shared<stAPVGain>();
582 APV->APVId = (
j << 3 |
i);
587 APV->FitWidthErr = -1;
590 APV->PreviousGain = 1;
591 APV->PreviousGainTick = 1;
592 APV->x = DetUnit->position().basicVector().x();
593 APV->y = DetUnit->position().basicVector().y();
594 APV->z = DetUnit->position().basicVector().z();
595 APV->Eta = DetUnit->position().basicVector().eta();
596 APV->Phi = DetUnit->position().basicVector().phi();
597 APV->R = DetUnit->position().basicVector().transverse();
598 APV->Thickness = DetUnit->surface().bounds().thickness();
599 APV->isMasked =
false;
631 <<
"Setting " << dqm_dir <<
" in DQM and booking histograms for tag " <<
tag << std::endl;
636 if (!stag.empty() && stag[0] !=
'_')
637 stag.insert(0, 1,
'_');
669 std::vector<float> binXarray;
672 binXarray.push_back((
float)
a);
675 std::array<float, 688> binYarray;
677 double p1 = 0.002113;
678 double p2 = 69.01576;
680 for (
int b = 0;
b < 687;
b++) {
687 binYarray[687] = 4000.;
697 ibooker.
book2S(cvi.c_str(), cvi.c_str(),
histograms.NStripAPVs, &binXarray[0], 687, binYarray.data()));
699 it =
histograms.Charge_Vs_PathlengthTIB.begin();
700 histograms.Charge_Vs_PathlengthTIB.insert(it + elepos,
701 ibooker.
book2S(cvpTIB.c_str(), cvpTIB.c_str(), 20, 0.3, 1.3, 250, 0, 2000));
703 it =
histograms.Charge_Vs_PathlengthTOB.begin();
704 histograms.Charge_Vs_PathlengthTOB.insert(it + elepos,
705 ibooker.
book2S(cvpTOB.c_str(), cvpTOB.c_str(), 20, 0.3, 1.3, 250, 0, 2000));
707 it =
histograms.Charge_Vs_PathlengthTIDP.begin();
709 it + elepos, ibooker.
book2S(cvpTIDP.c_str(), cvpTIDP.c_str(), 20, 0.3, 1.3, 250, 0, 2000));
711 it =
histograms.Charge_Vs_PathlengthTIDM.begin();
713 it + elepos, ibooker.
book2S(cvpTIDM.c_str(), cvpTIDM.c_str(), 20, 0.3, 1.3, 250, 0, 2000));
715 it =
histograms.Charge_Vs_PathlengthTECP1.begin();
717 it + elepos, ibooker.
book2S(cvpTECP1.c_str(), cvpTECP1.c_str(), 20, 0.3, 1.3, 250, 0, 2000));
719 it =
histograms.Charge_Vs_PathlengthTECP2.begin();
721 it + elepos, ibooker.
book2S(cvpTECP2.c_str(), cvpTECP2.c_str(), 20, 0.3, 1.3, 250, 0, 2000));
723 it =
histograms.Charge_Vs_PathlengthTECM1.begin();
725 it + elepos, ibooker.
book2S(cvpTECM1.c_str(), cvpTECM1.c_str(), 20, 0.3, 1.3, 250, 0, 2000));
727 it =
histograms.Charge_Vs_PathlengthTECM2.begin();
729 it + elepos, ibooker.
book2S(cvpTECM2.c_str(), cvpTECM2.c_str(), 20, 0.3, 1.3, 250, 0, 2000));
731 std::vector<std::pair<std::string, std::string>> hnames =
733 for (
unsigned int i = 0;
i < hnames.size();
i++) {
739 for (
unsigned int i = 0;
i < hnames.size();
i++) {
745 for (
unsigned int i = 0;
i < hnames.size();
i++) {
751 for (
unsigned int i = 0;
i < hnames.size();
i++) {
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
std::string m_calibrationMode
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &, APVGain::APVGainHistograms &) const override
static constexpr auto TEC
virtual int nstrips() const =0
void dqmAnalyze(edm::Event const &, edm::EventSetup const &, APVGain::APVGainHistograms const &) const override
std::vector< unsigned int > FetchIndices(std::map< unsigned int, APVloc >, uint32_t, const TrackerTopology *topo=nullptr)
bool doChargeMonitorPerPlane
std::vector< std::string > dqm_tag_
edm::ESGetToken< SiStripGain, SiStripGainRcd > gainToken_
MonitorElement * book2S(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
std::vector< std::string > VChargeHisto
virtual void setCurrentFolder(std::string const &fullpath)
virtual int ncolumns() const =0
#define DEFINE_FWK_MODULE(type)
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > tkGeomTokenBR_
std::map< unsigned int, APVloc > theTopologyMap
virtual int nrows() const =0
int subdetectorPlane(uint32_t, const TrackerTopology *)
double MaxTrackChiOverNdf
const DetContainer & dets() const override
Returm a vector of all GeomDet (including all GeomDetUnits)
unsigned int MinTrackHits
Log< level::Error, false > LogError
edm::ESGetToken< SiStripQuality, SiStripQualityRcd > qualityToken_
SiStripGainsCalibTreeWorker(const edm::ParameterSet &)
T getUntrackedParameter(std::string const &, T const &) const
U second(std::pair< T, U > const &p)
MonitorElement * book1DD(TString const &name, TString const &title, int nchX, double lowX, double highX, FUNC onbooking=NOOP())
int statCollectionFromMode(const char *tag) const
void addDefault(ParameterSetDescription const &psetDescription)
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > tkGeomToken_
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
void dqmBeginRun(edm::Run const &, edm::EventSetup const &, APVGain::APVGainHistograms &) const override
bool getData(T &iHolder) const
static constexpr auto TOB
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > tTopoToken_
Log< level::Info, false > LogInfo
static constexpr auto TIB
std::vector< std::string > calibTreeFileNames_
constexpr uint32_t rawId() const
get the raw id
std::string calibTreeName_
int subdetectorSide(uint32_t, const TrackerTopology *)
Log< level::Warning, false > LogWarning
std::vector< std::pair< std::string, std::string > > monHnames(std::vector< std::string >, bool, const char *tag)
void checkBookAPVColls(const TrackerGeometry *bareTkGeomPtr, APVGain::APVGainHistograms &histograms) const
static constexpr auto TID
int subdetectorId(uint32_t)