30 std::vector<std::pair<std::string,std::string>> hnames =
APVGain::monHnames(VChargeHisto,doChargeMonitorPerPlane,
"");
31 for (
unsigned int i=0;
i<hnames.size();
i++){
72 #ifdef ExtendedCALIBTree 125 APV->isMasked = SiStripQuality_->
IsApvBad(APV->DetId,APV->APVId);
128 float newPreviousGain = gainHandle->
getApvGain(APV->APVId,gainHandle->
getRange(APV->DetId, 1),1);
129 if(APV->PreviousGain!=1 and newPreviousGain!=APV->PreviousGain)
edm::LogWarning(
"SiStripGainPCLWorker")<<
"WARNING: ParticleGain in the global tag changed\n";
130 APV->PreviousGain = newPreviousGain;
132 float newPreviousGainTick = gainHandle->
getApvGain(APV->APVId,gainHandle->
getRange(APV->DetId, 0),0);
133 if(APV->PreviousGainTick!=1 and newPreviousGainTick!=APV->PreviousGainTick){
134 edm::LogWarning(
"SiStripGainPCLWorker")<<
"WARNING: TickMarkGain in the global tag changed\n"<< std::endl
135 <<
" APV->SubDet: "<< APV->SubDet <<
" APV->APVId:" << APV->APVId << std::endl
136 <<
" APV->PreviousGainTick: "<<APV->PreviousGainTick<<
" newPreviousGainTick: "<<newPreviousGainTick<<std::endl;
138 APV->PreviousGainTick = newPreviousGainTick;
150 unsigned int eventnumber = iEvent.
id().
event();
153 edm::LogInfo(
"SiStripGainsPCLWorker") <<
"Processing run " << runnumber
154 <<
" and event " << eventnumber
170 auto trackchi2ndof = handle01.
product();
174 auto trackp = handle02.
product();
178 auto tracketa = handle03.
product();
182 auto trackhitsvalid = handle04.
product();
186 auto trackalgo = handle05.
product();
191 auto trackindex = handle06.
product();
195 auto rawid = handle07.
product();
199 auto firststrip = handle08.
product();
203 auto nstrips = handle09.
product();
207 auto saturation = handle10.
product();
211 auto overlapping = handle11.
product();
215 auto farfromedge = handle12.
product();
225 #ifdef ExtendedCALIBTree 228 auto chargeoverpath = handle15.
product();
237 auto gainused = handle17.
product();
241 auto gainusedTick = handle18.
product();
244 LogDebug(
"SiStripGainsPCLWorker") <<
elem.first <<
" - " <<
elem.second.m_string <<
" " <<
elem.second.m_subdetectorId <<
" " <<
elem.second.m_subdetectorSide <<
" " <<
elem.second.m_subdetectorPlane << std::endl;
251 unsigned int FirstAmplitude=0;
252 for(
unsigned int i=0;
i<
charge->size();
i++){
254 FirstAmplitude+=(*nstrips)[
i];
255 int TI = (*trackindex)[
i];
265 std::shared_ptr<stAPVGain>
APV = histograms.
APVsColl.at(((*rawid)[
i]<<4) | ((*firststrip)[
i]/128));
267 if(APV->SubDet>2 && (*farfromedge)[
i] ==
false )
continue;
268 if(APV->SubDet>2 && (*overlapping)[
i] ==
true )
continue;
270 if(APV->SubDet>2 && (*nstrips )[
i] >
MaxNrStrips )
continue;
274 bool Saturation =
false;
275 for(
unsigned int s=0;
s<(*nstrips)[
i];
s++){
276 int StripCharge = (*amplitude)[FirstAmplitude-(*nstrips)[
i]+
s];
280 if(StripCharge>1024){
283 }
else if(StripCharge>254){
287 Charge += StripCharge;
290 }
else if(APV->SubDet>2){
291 Charge = (*charge)[
i];
293 Charge = (*charge)[
i]/265.0;
296 double ClusterChargeOverPath = ( (double) Charge )/(*path)[
i] ;
298 if(
Validation) {ClusterChargeOverPath/=(*gainused)[
i];}
303 if(APV->SubDet<=2)
continue;
306 histograms.
Charge_Vs_Index[elepos].fill(APV->Index,ClusterChargeOverPath);
311 <<
" APV->PreviousGain " << APV->PreviousGain
312 <<
" APV->CalibGain " << APV->CalibGain
313 <<
" APV->DetId "<< APV->DetId
314 <<
" APV->Index "<< APV->Index
315 <<
" Charge "<< Charge
316 <<
" Path "<< (*path)[
i]
317 <<
" ClusterChargeOverPath "<< ClusterChargeOverPath
326 for(
unsigned int s=0;
s<(*nstrips)[
i];
s++){
327 int StripCharge = (*amplitude)[FirstAmplitude-(*nstrips)[
i]+
s];
328 if(StripCharge>1024) StripCharge = 255;
329 else if(StripCharge>254) StripCharge = 254;
330 mCharge1 += StripCharge;
331 mCharge2 += StripCharge;
332 mCharge3 += StripCharge;
333 mCharge4 += StripCharge;
336 mCharge2 *= (*gainused)[
i];
337 mCharge3 *= (*gainusedTick)[
i];
338 mCharge4 *= ( (*gainused)[
i] * (*gainusedTick)[
i]);
341 LogDebug(
"SiStripGainsPCLWorker") <<
" full charge "<< mCharge1
342 <<
" remove G2 "<< mCharge2
343 <<
" remove G1 "<< mCharge3
344 <<
" remove G1*G2 "<< mCharge4
349 for(
auto m : indices) histograms.
Charge_1[elepos][
m].fill(( (
double) mCharge1 )/(*
path)[i]);
350 for(
auto m : indices) histograms.
Charge_2[elepos][
m].fill(( (
double) mCharge2 )/(*
path)[i]);
351 for(
auto m : indices) histograms.
Charge_3[elepos][
m].fill(( (
double) mCharge3 )/(*
path)[i]);
352 for(
auto m : indices) histograms.
Charge_4[elepos][
m].fill(( (
double) mCharge4 )/(*
path)[i]);
368 }
else if(APV->Eta>0){
394 auto const &
Det = bareTkGeomPtr->
dets();
396 edm::LogInfo(
"SiStripGainsPCLWorker") <<
" Resetting APV struct"<<std::endl;
398 unsigned int Index=0;
400 for(
unsigned int i=0;
i<
Det.size();
i++){
409 if(!DetUnit)
continue;
412 unsigned int NAPV = Topo.
nstrips()/128;
414 for(
unsigned int j=0;j<NAPV;j++){
415 auto APV = std::make_shared<stAPVGain>();
424 APV->FitWidthErr = -1;
428 APV->PreviousGain = 1;
429 APV->PreviousGainTick = 1;
430 APV->x = DetUnit->position().basicVector().x();
431 APV->y = DetUnit->position().basicVector().y();
432 APV->z = DetUnit->position().basicVector().z();
433 APV->Eta = DetUnit->position().basicVector().eta();
434 APV->Phi = DetUnit->position().basicVector().phi();
435 APV->R = DetUnit->position().basicVector().transverse();
436 APV->Thickness = DetUnit->surface().bounds().thickness();
438 APV->isMasked =
false;
448 for(
unsigned int i=0;
i<
Det.size();
i++){
453 if(!DetUnit)
continue;
456 unsigned int NROCRow = Topo.
nrows()/(80.);
457 unsigned int NROCCol = Topo.
ncolumns()/(52.);
459 for(
unsigned int j=0;j<NROCRow;j++){
460 for(
unsigned int i=0;
i<NROCCol;
i++){
462 auto APV = std::make_shared<stAPVGain>();
466 APV->APVId = (j<<3 |
i);
471 APV->FitWidthErr = -1;
474 APV->PreviousGain = 1;
475 APV->PreviousGainTick = 1;
476 APV->x = DetUnit->position().basicVector().x();
477 APV->y = DetUnit->position().basicVector().y();
478 APV->z = DetUnit->position().basicVector().z();
479 APV->Eta = DetUnit->position().basicVector().eta();
480 APV->Phi = DetUnit->position().basicVector().phi();
481 APV->R = DetUnit->position().basicVector().transverse();
482 APV->Thickness = DetUnit->surface().bounds().thickness();
483 APV->isMasked =
false;
520 edm::LogInfo(
"SiStripGainsPCLWorker") <<
"Setting " << dqm_dir <<
" in DQM and booking histograms for tag " 526 if(!stag.empty() && stag[0]!=
'_') stag.insert(0,1,
'_');
558 std::vector<float> binXarray;
561 binXarray.push_back( (
float)
a );
564 std::array<float,688> binYarray;
566 double p1 = 0.002113;
567 double p2 = 69.01576;
569 for(
int b=0;
b<687;
b++) {
571 if(y<=902.) y = y + 2.;
572 else y = ( p0 -
log(
exp(p0-p1*y) - p2*p1)) / p1;
574 binYarray[687] = 4000.;
576 histograms.
Charge_1[elepos].clear();
577 histograms.
Charge_2[elepos].clear();
578 histograms.
Charge_3[elepos].clear();
579 histograms.
Charge_4[elepos].clear();
610 for (
unsigned int i=0;
i<hnames.size();
i++){
612 histograms.
Charge_1[elepos].push_back(ibooker.
book1DD( htag.c_str(), (hnames[
i]).
second.c_str(), 100 , 0. , 1000. ));
616 for (
unsigned int i=0;
i<hnames.size();
i++){
618 histograms.
Charge_2[elepos].push_back(ibooker.
book1DD( htag.c_str(), (hnames[
i]).
second.c_str(), 100 , 0. , 1000. ));
622 for (
unsigned int i=0;
i<hnames.size();
i++){
624 histograms.
Charge_3[elepos].push_back(ibooker.
book1DD( htag.c_str(), (hnames[
i]).
second.c_str(), 100 , 0. , 1000. ));
628 for (
unsigned int i=0;
i<hnames.size();
i++){
630 histograms.
Charge_4[elepos].push_back(ibooker.
book1DD( htag.c_str(), (hnames[
i]).
second.c_str(), 100 , 0. , 1000. ));
ConcurrentMonitorElement book1DD(Args &&...args)
bool IsApvBad(const uint32_t &detid, const short &apvNb) const
edm::EDGetTokenT< std::vector< double > > gainused_token_
EventNumber_t event() const
T getUntrackedParameter(std::string const &, T const &) const
virtual int nrows() const =0
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_
std::array< std::vector< ConcurrentMonitorElement >, 7 > Charge_1
std::vector< ConcurrentMonitorElement > Charge_Vs_PathlengthTECM2
size_t getNumberOfTags() const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
edm::EDGetTokenT< std::vector< float > > trackp_token_
SiStripGainsPCLWorker(const edm::ParameterSet &)
constexpr uint32_t rawId() const
get the raw id
int subdetectorPlane(uint32_t, const TrackerTopology *)
std::vector< ConcurrentMonitorElement > Charge_Vs_PathlengthTECP2
def setup(process, global_tag, zero_tesla=False)
std::string m_calibrationMode
std::vector< ConcurrentMonitorElement > Charge_Vs_PathlengthTIDM
std::array< std::vector< ConcurrentMonitorElement >, 7 > Charge_2
edm::EDGetTokenT< std::vector< unsigned int > > trackhitsvalid_token_
edm::EDGetTokenT< std::vector< unsigned short > > firststrip_token_
std::array< std::vector< ConcurrentMonitorElement >, 7 > Charge_3
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< ConcurrentMonitorElement > Charge_Vs_Index
void dqmBeginRun(edm::Run const &, edm::EventSetup const &, APVGain::APVGainHistograms &) const override
void addDefault(ParameterSetDescription const &psetDescription)
std::atomic< unsigned int > NPixelDets
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
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_
std::vector< ConcurrentMonitorElement > Charge_Vs_PathlengthTIB
void setCurrentFolder(const std::string &fullpath)
T const * product() const
std::vector< ConcurrentMonitorElement > Charge_Vs_PathlengthTECP1
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
std::vector< ConcurrentMonitorElement > Charge_Vs_PathlengthTOB
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_
std::vector< ConcurrentMonitorElement > Charge_Vs_PathlengthTECM1
virtual int ncolumns() const =0
ConcurrentMonitorElement book2S(Args &&...args)
int statCollectionFromMode(const char *tag) const
edm::EDGetTokenT< std::vector< double > > chargeoverpath_token_
edm::EDGetTokenT< std::vector< int > > trackalgo_token_
edm::EDGetTokenT< std::vector< double > > localdiry_token_
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_
T const * product() const
int subdetectorId(uint32_t)
std::array< std::vector< ConcurrentMonitorElement >, 7 > Charge_4
std::vector< ConcurrentMonitorElement > Charge_Vs_PathlengthTIDP
void bookHistograms(DQMStore::ConcurrentBooker &, edm::Run const &, edm::EventSetup const &, APVGain::APVGainHistograms &) const override
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_