30 std::vector<std::pair<std::string,std::string>> hnames =
APVGain::monHnames(VChargeHisto,doChargeMonitorPerPlane,
"");
31 for (
unsigned int i=0;
i<hnames.size();
i++){
123 APV->isMasked = SiStripQuality_->
IsApvBad(APV->DetId,APV->APVId);
126 float newPreviousGain = gainHandle->
getApvGain(APV->APVId,gainHandle->
getRange(APV->DetId, 1),1);
127 if(APV->PreviousGain!=1 and newPreviousGain!=APV->PreviousGain)
edm::LogWarning(
"SiStripGainPCLWorker")<<
"WARNING: ParticleGain in the global tag changed\n";
128 APV->PreviousGain = newPreviousGain;
130 float newPreviousGainTick = gainHandle->
getApvGain(APV->APVId,gainHandle->
getRange(APV->DetId, 0),0);
131 if(APV->PreviousGainTick!=1 and newPreviousGainTick!=APV->PreviousGainTick){
132 edm::LogWarning(
"SiStripGainPCLWorker")<<
"WARNING: TickMarkGain in the global tag changed\n"<< std::endl
133 <<
" APV->SubDet: "<< APV->SubDet <<
" APV->APVId:" << APV->APVId << std::endl
134 <<
" APV->PreviousGainTick: "<<APV->PreviousGainTick<<
" newPreviousGainTick: "<<newPreviousGainTick<<std::endl;
136 APV->PreviousGainTick = newPreviousGainTick;
148 unsigned int eventnumber = iEvent.
id().
event();
151 edm::LogInfo(
"SiStripGainsPCLWorker") <<
"Processing run " << runnumber
152 <<
" and event " << eventnumber
168 auto trackchi2ndof = handle01.
product();
172 auto trackp = handle02.
product();
176 auto tracketa = handle03.
product();
180 auto trackhitsvalid = handle04.
product();
184 auto trackalgo = handle05.
product();
189 auto trackindex = handle06.
product();
193 auto rawid = handle07.
product();
197 auto firststrip = handle08.
product();
201 auto nstrips = handle09.
product();
205 auto saturation = handle10.
product();
209 auto overlapping = handle11.
product();
213 auto farfromedge = handle12.
product();
225 auto chargeoverpath = handle15.
product();
233 auto gainused = handle17.
product();
237 auto gainusedTick = handle18.
product();
240 LogDebug(
"SiStripGainsPCLWorker") <<
elem.first <<
" - " <<
elem.second.m_string <<
" " <<
elem.second.m_subdetectorId <<
" " <<
elem.second.m_subdetectorSide <<
" " <<
elem.second.m_subdetectorPlane << std::endl;
247 unsigned int FirstAmplitude=0;
248 for(
unsigned int i=0;
i<chargeoverpath->size();
i++){
250 FirstAmplitude+=(*nstrips)[
i];
251 int TI = (*trackindex)[
i];
261 std::shared_ptr<stAPVGain>
APV = histograms.
APVsColl.at(((*rawid)[
i]<<4) | ((*firststrip)[
i]/128));
263 if(APV->SubDet>2 && (*farfromedge)[
i] ==
false )
continue;
264 if(APV->SubDet>2 && (*overlapping)[
i] ==
true )
continue;
266 if(APV->SubDet>2 && (*nstrips )[
i] >
MaxNrStrips )
continue;
270 bool Saturation =
false;
271 for(
unsigned int s=0;
s<(*nstrips)[
i];
s++){
272 int StripCharge = (*amplitude)[FirstAmplitude-(*nstrips)[
i]+
s];
276 if(StripCharge>1024){
279 }
else if(StripCharge>254){
283 Charge += StripCharge;
286 }
else if(APV->SubDet>2){
287 Charge = (*charge)[
i];
289 Charge = (*charge)[
i]/265.0;
292 double ClusterChargeOverPath = ( (double) Charge )/(*path)[
i] ;
294 if(
Validation) {ClusterChargeOverPath/=(*gainused)[
i];}
299 if(APV->SubDet<=2)
continue;
302 histograms.
Charge_Vs_Index[elepos].fill(APV->Index,ClusterChargeOverPath);
307 <<
" APV->PreviousGain " << APV->PreviousGain
308 <<
" APV->CalibGain " << APV->CalibGain
309 <<
" APV->DetId "<< APV->DetId
310 <<
" APV->Index "<< APV->Index
311 <<
" Charge "<< Charge
312 <<
" Path "<< (*path)[
i]
313 <<
" ClusterChargeOverPath "<< ClusterChargeOverPath
322 for(
unsigned int s=0;
s<(*nstrips)[
i];
s++){
323 int StripCharge = (*amplitude)[FirstAmplitude-(*nstrips)[
i]+
s];
324 if(StripCharge>1024) StripCharge = 255;
325 else if(StripCharge>254) StripCharge = 254;
326 mCharge1 += StripCharge;
327 mCharge2 += StripCharge;
328 mCharge3 += StripCharge;
329 mCharge4 += StripCharge;
332 mCharge2 *= (*gainused)[
i];
333 mCharge3 *= (*gainusedTick)[
i];
334 mCharge4 *= ( (*gainused)[
i] * (*gainusedTick)[
i]);
337 LogDebug(
"SiStripGainsPCLWorker") <<
" full charge "<< mCharge1
338 <<
" remove G2 "<< mCharge2
339 <<
" remove G1 "<< mCharge3
340 <<
" remove G1*G2 "<< mCharge4
345 for(
auto m : indices) histograms.
Charge_1[elepos][
m].fill(( (
double) mCharge1 )/(*
path)[i]);
346 for(
auto m : indices) histograms.
Charge_2[elepos][
m].fill(( (
double) mCharge2 )/(*
path)[i]);
347 for(
auto m : indices) histograms.
Charge_3[elepos][
m].fill(( (
double) mCharge3 )/(*
path)[i]);
348 for(
auto m : indices) histograms.
Charge_4[elepos][
m].fill(( (
double) mCharge4 )/(*
path)[i]);
364 }
else if(APV->Eta>0){
390 auto const &
Det = bareTkGeomPtr->
dets();
392 edm::LogInfo(
"SiStripGainsPCLWorker") <<
" Resetting APV struct"<<std::endl;
394 unsigned int Index=0;
396 for(
unsigned int i=0;
i<
Det.size();
i++){
405 if(!DetUnit)
continue;
408 unsigned int NAPV = Topo.
nstrips()/128;
410 for(
unsigned int j=0;j<NAPV;j++){
411 auto APV = std::make_shared<stAPVGain>();
420 APV->FitWidthErr = -1;
424 APV->PreviousGain = 1;
425 APV->PreviousGainTick = 1;
426 APV->x = DetUnit->position().basicVector().x();
427 APV->y = DetUnit->position().basicVector().y();
428 APV->z = DetUnit->position().basicVector().z();
429 APV->Eta = DetUnit->position().basicVector().eta();
430 APV->Phi = DetUnit->position().basicVector().phi();
431 APV->R = DetUnit->position().basicVector().transverse();
432 APV->Thickness = DetUnit->surface().bounds().thickness();
434 APV->isMasked =
false;
444 for(
unsigned int i=0;
i<
Det.size();
i++){
449 if(!DetUnit)
continue;
452 unsigned int NROCRow = Topo.
nrows()/(80.);
453 unsigned int NROCCol = Topo.
ncolumns()/(52.);
455 for(
unsigned int j=0;j<NROCRow;j++){
456 for(
unsigned int i=0;
i<NROCCol;
i++){
458 auto APV = std::make_shared<stAPVGain>();
462 APV->APVId = (j<<3 |
i);
467 APV->FitWidthErr = -1;
470 APV->PreviousGain = 1;
471 APV->PreviousGainTick = 1;
472 APV->x = DetUnit->position().basicVector().x();
473 APV->y = DetUnit->position().basicVector().y();
474 APV->z = DetUnit->position().basicVector().z();
475 APV->Eta = DetUnit->position().basicVector().eta();
476 APV->Phi = DetUnit->position().basicVector().phi();
477 APV->R = DetUnit->position().basicVector().transverse();
478 APV->Thickness = DetUnit->surface().bounds().thickness();
479 APV->isMasked =
false;
516 edm::LogInfo(
"SiStripGainsPCLWorker") <<
"Setting " << dqm_dir <<
" in DQM and booking histograms for tag " 522 if(!stag.empty() && stag[0]!=
'_') stag.insert(0,1,
'_');
554 std::vector<float> binXarray;
557 binXarray.push_back( (
float)
a );
560 std::array<float,688> binYarray;
562 double p1 = 0.002113;
563 double p2 = 69.01576;
565 for(
int b=0;
b<687;
b++) {
567 if(y<=902.) y = y + 2.;
568 else y = ( p0 -
log(
exp(p0-p1*y) - p2*p1)) / p1;
570 binYarray[687] = 4000.;
572 histograms.
Charge_1[elepos].clear();
573 histograms.
Charge_2[elepos].clear();
574 histograms.
Charge_3[elepos].clear();
575 histograms.
Charge_4[elepos].clear();
606 for (
unsigned int i=0;
i<hnames.size();
i++){
608 histograms.
Charge_1[elepos].push_back(ibooker.
book1DD( htag.c_str(), (hnames[
i]).
second.c_str(), 100 , 0. , 1000. ));
612 for (
unsigned int i=0;
i<hnames.size();
i++){
614 histograms.
Charge_2[elepos].push_back(ibooker.
book1DD( htag.c_str(), (hnames[
i]).
second.c_str(), 100 , 0. , 1000. ));
618 for (
unsigned int i=0;
i<hnames.size();
i++){
620 histograms.
Charge_3[elepos].push_back(ibooker.
book1DD( htag.c_str(), (hnames[
i]).
second.c_str(), 100 , 0. , 1000. ));
624 for (
unsigned int i=0;
i<hnames.size();
i++){
626 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 &)
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
uint32_t rawId() const
get the raw id
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
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
int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
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_