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 105 static constexpr float defaultGainTick = 690./640.;
126 APV->isMasked = SiStripQuality_->
IsApvBad(APV->DetId,APV->APVId);
129 float newPreviousGain = gainHandle->
getApvGain(APV->APVId,gainHandle->
getRange(APV->DetId, 1),1);
130 if(APV->PreviousGain!=1 and newPreviousGain!=APV->PreviousGain)
edm::LogWarning(
"SiStripGainPCLWorker")<<
"WARNING: ParticleGain in the global tag changed\n";
131 APV->PreviousGain = newPreviousGain;
133 float newPreviousGainTick = APV->isMasked ? defaultGainTick : gainHandle->
getApvGain(APV->APVId,gainHandle->
getRange(APV->DetId, 0),0);
134 if(APV->PreviousGainTick!=1 and newPreviousGainTick!=APV->PreviousGainTick){
135 edm::LogWarning(
"SiStripGainPCLWorker")<<
"WARNING: TickMarkGain in the global tag changed\n"<< std::endl
136 <<
" APV->SubDet: "<< APV->SubDet <<
" APV->APVId:" << APV->APVId << std::endl
137 <<
" APV->PreviousGainTick: "<<APV->PreviousGainTick<<
" newPreviousGainTick: "<<newPreviousGainTick<<std::endl;
139 APV->PreviousGainTick = newPreviousGainTick;
151 unsigned int eventnumber = iEvent.
id().
event();
154 edm::LogInfo(
"SiStripGainsPCLWorker") <<
"Processing run " << runnumber
155 <<
" and event " << eventnumber
171 auto trackchi2ndof = handle01.
product();
175 auto trackp = handle02.
product();
179 auto tracketa = handle03.
product();
183 auto trackhitsvalid = handle04.
product();
187 auto trackalgo = handle05.
product();
192 auto trackindex = handle06.
product();
196 auto rawid = handle07.
product();
200 auto firststrip = handle08.
product();
204 auto nstrips = handle09.
product();
208 auto saturation = handle10.
product();
212 auto overlapping = handle11.
product();
216 auto farfromedge = handle12.
product();
226 #ifdef ExtendedCALIBTree 229 auto chargeoverpath = handle15.
product();
238 auto gainused = handle17.
product();
242 auto gainusedTick = handle18.
product();
245 LogDebug(
"SiStripGainsPCLWorker") <<
elem.first <<
" - " <<
elem.second.m_string <<
" " <<
elem.second.m_subdetectorId <<
" " <<
elem.second.m_subdetectorSide <<
" " <<
elem.second.m_subdetectorPlane << std::endl;
252 unsigned int FirstAmplitude=0;
253 for(
unsigned int i=0;
i<
charge->size();
i++){
255 FirstAmplitude+=(*nstrips)[
i];
256 int TI = (*trackindex)[
i];
266 std::shared_ptr<stAPVGain>
APV = histograms.
APVsColl.at(((*rawid)[
i]<<4) | ((*firststrip)[
i]/128));
268 if(APV->SubDet>2 && (*farfromedge)[
i] ==
false )
continue;
269 if(APV->SubDet>2 && (*overlapping)[
i] ==
true )
continue;
271 if(APV->SubDet>2 && (*nstrips )[
i] >
MaxNrStrips )
continue;
275 bool Saturation =
false;
276 for(
unsigned int s=0;
s<(*nstrips)[
i];
s++){
277 int StripCharge = (*amplitude)[FirstAmplitude-(*nstrips)[
i]+
s];
281 if(StripCharge>1024){
284 }
else if(StripCharge>254){
288 Charge += StripCharge;
291 }
else if(APV->SubDet>2){
292 Charge = (*charge)[
i];
294 Charge = (*charge)[
i]/265.0;
297 double ClusterChargeOverPath = ( (double) Charge )/(*path)[
i] ;
299 if(
Validation) {ClusterChargeOverPath/=(*gainused)[
i];}
304 if(APV->SubDet<=2)
continue;
307 histograms.
Charge_Vs_Index[elepos].fill(APV->Index,ClusterChargeOverPath);
312 <<
" APV->PreviousGain " << APV->PreviousGain
313 <<
" APV->CalibGain " << APV->CalibGain
314 <<
" APV->DetId "<< APV->DetId
315 <<
" APV->Index "<< APV->Index
316 <<
" Charge "<< Charge
317 <<
" Path "<< (*path)[
i]
318 <<
" ClusterChargeOverPath "<< ClusterChargeOverPath
327 for(
unsigned int s=0;
s<(*nstrips)[
i];
s++){
328 int StripCharge = (*amplitude)[FirstAmplitude-(*nstrips)[
i]+
s];
329 if(StripCharge>1024) StripCharge = 255;
330 else if(StripCharge>254) StripCharge = 254;
331 mCharge1 += StripCharge;
332 mCharge2 += StripCharge;
333 mCharge3 += StripCharge;
334 mCharge4 += StripCharge;
337 mCharge2 *= (*gainused)[
i];
338 mCharge3 *= (*gainusedTick)[
i];
339 mCharge4 *= ( (*gainused)[
i] * (*gainusedTick)[
i]);
342 LogDebug(
"SiStripGainsPCLWorker") <<
" full charge "<< mCharge1
343 <<
" remove G2 "<< mCharge2
344 <<
" remove G1 "<< mCharge3
345 <<
" remove G1*G2 "<< mCharge4
350 for(
auto m : indices) histograms.
Charge_1[elepos][
m].fill(( (
double) mCharge1 )/(*
path)[i]);
351 for(
auto m : indices) histograms.
Charge_2[elepos][
m].fill(( (
double) mCharge2 )/(*
path)[i]);
352 for(
auto m : indices) histograms.
Charge_3[elepos][
m].fill(( (
double) mCharge3 )/(*
path)[i]);
353 for(
auto m : indices) histograms.
Charge_4[elepos][
m].fill(( (
double) mCharge4 )/(*
path)[i]);
369 }
else if(APV->Eta>0){
395 auto const &
Det = bareTkGeomPtr->
dets();
397 edm::LogInfo(
"SiStripGainsPCLWorker") <<
" Resetting APV struct"<<std::endl;
399 unsigned int Index=0;
401 for(
unsigned int i=0;
i<
Det.size();
i++){
410 if(!DetUnit)
continue;
413 unsigned int NAPV = Topo.
nstrips()/128;
415 for(
unsigned int j=0;j<NAPV;j++){
416 auto APV = std::make_shared<stAPVGain>();
425 APV->FitWidthErr = -1;
429 APV->PreviousGain = 1;
430 APV->PreviousGainTick = 1;
431 APV->x = DetUnit->position().basicVector().x();
432 APV->y = DetUnit->position().basicVector().y();
433 APV->z = DetUnit->position().basicVector().z();
434 APV->Eta = DetUnit->position().basicVector().eta();
435 APV->Phi = DetUnit->position().basicVector().phi();
436 APV->R = DetUnit->position().basicVector().transverse();
437 APV->Thickness = DetUnit->surface().bounds().thickness();
439 APV->isMasked =
false;
449 for(
unsigned int i=0;
i<
Det.size();
i++){
454 if(!DetUnit)
continue;
457 unsigned int NROCRow = Topo.
nrows()/(80.);
458 unsigned int NROCCol = Topo.
ncolumns()/(52.);
460 for(
unsigned int j=0;j<NROCRow;j++){
461 for(
unsigned int i=0;
i<NROCCol;
i++){
463 auto APV = std::make_shared<stAPVGain>();
467 APV->APVId = (j<<3 |
i);
472 APV->FitWidthErr = -1;
475 APV->PreviousGain = 1;
476 APV->PreviousGainTick = 1;
477 APV->x = DetUnit->position().basicVector().x();
478 APV->y = DetUnit->position().basicVector().y();
479 APV->z = DetUnit->position().basicVector().z();
480 APV->Eta = DetUnit->position().basicVector().eta();
481 APV->Phi = DetUnit->position().basicVector().phi();
482 APV->R = DetUnit->position().basicVector().transverse();
483 APV->Thickness = DetUnit->surface().bounds().thickness();
484 APV->isMasked =
false;
521 edm::LogInfo(
"SiStripGainsPCLWorker") <<
"Setting " << dqm_dir <<
" in DQM and booking histograms for tag " 527 if(!stag.empty() && stag[0]!=
'_') stag.insert(0,1,
'_');
559 std::vector<float> binXarray;
562 binXarray.push_back( (
float)
a );
565 std::array<float,688> binYarray;
567 double p1 = 0.002113;
568 double p2 = 69.01576;
570 for(
int b=0;
b<687;
b++) {
572 if(y<=902.) y = y + 2.;
573 else y = ( p0 -
log(
exp(p0-p1*y) - p2*p1)) / p1;
575 binYarray[687] = 4000.;
577 histograms.
Charge_1[elepos].clear();
578 histograms.
Charge_2[elepos].clear();
579 histograms.
Charge_3[elepos].clear();
580 histograms.
Charge_4[elepos].clear();
611 for (
unsigned int i=0;
i<hnames.size();
i++){
613 histograms.
Charge_1[elepos].push_back(ibooker.
book1DD( htag.c_str(), (hnames[
i]).
second.c_str(), 100 , 0. , 1000. ));
617 for (
unsigned int i=0;
i<hnames.size();
i++){
619 histograms.
Charge_2[elepos].push_back(ibooker.
book1DD( htag.c_str(), (hnames[
i]).
second.c_str(), 100 , 0. , 1000. ));
623 for (
unsigned int i=0;
i<hnames.size();
i++){
625 histograms.
Charge_3[elepos].push_back(ibooker.
book1DD( htag.c_str(), (hnames[
i]).
second.c_str(), 100 , 0. , 1000. ));
629 for (
unsigned int i=0;
i<hnames.size();
i++){
631 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)
void setCurrentFolder(std::string const &fullpath)
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
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_