135 for(
unsigned int pulserLevel=0; pulserLevel < 64; pulserLevel++)
143 const std::vector<Identifier> & ids =
m_idHelperSvc->cscIdHelper().idVector();
147 for(
const auto & thisChamberId:ids)
149 std::vector<Identifier> stripVect;
150 m_idHelperSvc->cscIdHelper().idChannels(thisChamberId,stripVect);
154 for(
const auto & thisStripId:stripVect)
157 m_idHelperSvc->cscIdHelper().get_channel_hash(thisStripId,stripHash);
167 char orientation = (
m_idHelperSvc->cscIdHelper().measuresPhi(
id) ?
'Y':
'X');
169 int stationName =
m_idHelperSvc->cscIdHelper().stationName(
id);
170 int stationPhi =
m_idHelperSvc->cscIdHelper().stationPhi(
id);
171 int stationEta =
m_idHelperSvc->cscIdHelper().stationEta(
id);
175 char bitName[200], titleSeed[500];
177 sprintf(bitName,
"bitHist%d",(
int)stripHash);
178 sprintf(titleSeed,
"Bit histogram for eta %d, sector %d, layer %d%c strip %d",
179 stationEta,(2*stationPhi+50 - stationName),wireLayer,orientation,stripNumber);
182 hist->GetXaxis()->SetTitle(
"Bit");
183 hist->GetYaxis()->SetTitle(
"Counts");
193 for(
unsigned int chanItr =0; chanItr <=
m_maxStripHash; chanItr++)
206 in >> buff >> buff >> buff >> buff >> buff ;
212 in >> stripHash >> buff >> buff >> ped >> noise;
213 ATH_MSG_INFO(stripHash <<
"\t" << ped <<
"\t" << noise);
214 if( stripHash < 0 || (
unsigned int) stripHash >
m_maxStripHash ) {
216 ATH_MSG_FATAL(
"The hash "<< (
int) stripHash <<
" is out of range for the Ped-Vector - Crashing!");
217 return StatusCode::FAILURE;
244 return StatusCode::SUCCESS;
309 MsgStream mLog( msgSvc(), name() );
318 StatusCode sc_read =
evtStore()->retrieve(fullRDO,
"CSCRDO");
319 if (sc_read != StatusCode::SUCCESS)
322 return StatusCode::FAILURE;
332 for(
const auto rod:*fullRDO)
337 uint16_t pulsedWireLayer = rod->calLayer();
339 int pulserLevel = rod->calAmplitude();
343 ATH_MSG_INFO(
"New pulser level found. (" << pulserLevel <<
").");
345 std::map<int,TProfile*>::iterator alreadyExistingProfile =
m_ampProfs->find(pulserLevel);
347 if(alreadyExistingProfile ==
m_ampProfs->end())
351 std::stringstream name, title;
352 name <<
"ampProf_" << pulserLevel;
370 unsigned int samplingPhase = rod->samplingPhase();
371 uint8_t samplingPeriod = rod->rate();
377 for(
const auto cluster: *rod)
381 int numStrips = cluster->width();
382 int samplesPerStrip = (cluster->samples()).size()/numStrips;
386 for(
int stripItr = 0; stripItr <numStrips; stripItr++)
390 m_idHelperSvc->cscIdHelper().get_channel_hash(stripId, cscChannelHashId);
391 int stripHash = cscChannelHashId;
394 int chamberLayer =
m_idHelperSvc->cscIdHelper().chamberLayer(stripId);
400 return StatusCode::FAILURE;
403 int currentWireLayer =
m_idHelperSvc->cscIdHelper().wireLayer(stripId) - 1;
404 if( currentWireLayer < 0 || currentWireLayer > 3)
406 ATH_MSG_FATAL(
"Problem in getting wire layer! - Current value is "
407 <<
m_idHelperSvc->cscIdHelper().wireLayer(stripId) <<
" while only values between 1-4 are allowed.");
408 return StatusCode::FAILURE;
410 bool isThisLayerPulsed = (pulsedWireLayer >> currentWireLayer)&0x1;
411 if(isThisLayerPulsed)
414 std::vector<uint16_t> samples;
415 cluster->samples(stripItr,samplesPerStrip,samples);
429 else ATH_MSG_ERROR(
"Failed at getting pedestal from COOL for hash " << stripHash);
431 return StatusCode::RECOVERABLE;
440 else ATH_MSG_ERROR(
"Failed at getting noise from COOL for hash " << stripHash);
442 return StatusCode::FAILURE;
448 double peakAmp{}, peakTime{};
453 std::vector<float> floatSamples;
454 for(
const auto & thisSample:samples){
456 floatSamples.push_back(thisSample-ped);
465 success =
m_cscCalibTool->findCharge((
float)samplingPeriod, samplingPhase,floatSamples,peakAmp,peakTime);
471 double adcSamples[4];
472 for(
int i = 0; i < 4; i++) adcSamples[i] = samples[i] -ped;
473 double fitResult[3],fitErrors[3],
chi2;
474 double width = samplingPeriod == 50 ? 7.2:14.4;
478 peakAmp = fitResult[0];
479 peakTime = fitResult[1] - (samplingPhase ? 25 : 0);
497 ATH_MSG_WARNING(
"Pulsed layer " << pulsedWireLayer<<
", Samples: " << samples[0] <<
", " << samples[1] <<
", " << samples[2] <<
", " << samples[3]);
514 return StatusCode::SUCCESS;
528 return StatusCode::FAILURE;
530 unsigned int numCalibPoints =
m_ampProfs->size();
531 ATH_MSG_INFO(
"There are " << numCalibPoints <<
" pulser levels to evaluate.");
535 float chargeMax = 530.88;
537 int crossTalkCnt = 0;
539 for(
unsigned int stripHash = 0 ;stripHash <=
m_maxStripHash; stripHash++)
552 int chamberLayer =
m_idHelperSvc->cscIdHelper().chamberLayer(
id);
553 char orientation = (
m_idHelperSvc->cscIdHelper().measuresPhi(
id) ?
'Y':
'X');
558 int stationName =
m_idHelperSvc->cscIdHelper().stationName(
id);
559 int stationPhi =
m_idHelperSvc->cscIdHelper().stationPhi(
id);
560 int stationEta =
m_idHelperSvc->cscIdHelper().stationEta(
id);
581 if(orientation !=
'X')
585 bool foundMin(
false);
593 TGraphErrors * calGraph =
new TGraphErrors(numCalibPoints);
594 char calName[20],titleSeed[500];
595 sprintf(calName,
"calGraph%u",stripHash);
596 sprintf(titleSeed,
"Calgraph for eta %d, sector %d, layer %d%c, strip %d",stationEta,(2*stationPhi+50 - stationName),wireLayer,orientation, stripNumber);
597 calGraph->SetName(calName);
599 calGraph->SetTitle(title.c_str());
600 calGraph->GetYaxis()->SetTitle(
"ADC counts");
601 calGraph->GetXaxis()->SetTitle(
"Attenuation (-db)");
605 bool isGoodStrip =
false;
611 for(
const auto & [pulserLevel, pAmplitudeProfile] : *
m_ampProfs)
613 if(!pAmplitudeProfile){
615 return StatusCode::FAILURE;
620 if(pAmplitudeProfile->GetBinEntries(stripHash+1))
628 float adcValue = pAmplitudeProfile->GetBinContent(stripHash+1);
629 float adcError = pAmplitudeProfile->GetBinError(stripHash+1);
636 if(adcError != adcError)
644 attenValue = 300*std::pow(10,db/20);
648 ATH_MSG_DEBUG(
"\tStoring at db of " << db <<
" with attenValue " << attenValue <<
" from pulser level of " << pulserLevel <<
" and adcValue " << adcValue);
654 thisDrop = lastVal - adcValue;
656 <<
"\tlastVal = " << lastVal
657 <<
";lastDrop " << lastDrop <<
"; thisDrop " << thisDrop);
661 fitMinX = attenValue;
671 if(attenValue > fitMaxX)
672 fitMaxX = attenValue;
674 calGraph->SetPoint(calPointItr,attenValue,adcValue);
675 calGraph->SetPointError(calPointItr,0.01,adcError);
681 if(!foundMin && isGoodStrip){
689 ATH_MSG_INFO(
"we have a good stripHash at " << stripHash);
693 float slope, slopeError, intercept, interceptError, chiSquared;
698 TF1 myFunc(
"myFunction",
m_calFitFunc.c_str(), fitMinX, fitMaxX);
699 myFunc.SetLineColor(kRed);
702 myFunc.SetParameters(0,5);
703 slope = myFunc.GetParameter(1);
704 slopeError = myFunc.GetParError(1);
705 intercept = myFunc.GetParameter(0);
706 interceptError = myFunc.GetParError(0);
707 chiSquared = myFunc.GetChisquare();
708 ndf = myFunc.GetNDF();
712 myFunc.SetParameters(0.1,2000);
714 fitRet = calGraph->Fit(&myFunc,
"RV");
716 slope = myFunc.GetParameter(1)/chargeMax;
717 slopeError = myFunc.GetParError(1);
718 intercept = myFunc.GetParameter(0);
719 interceptError = myFunc.GetParError(0);
720 chiSquared = myFunc.GetChisquare();
721 ndf = myFunc.GetNDF();
725 if(std::abs(slope) < 0.00001 || slope == -999)
731 invertedSlope = 1/slope;
733 ATH_MSG_ERROR(
"Inserting calgraph in for hash " << stripHash);
734 (*m_calGraphs)[stripHash] = calGraph;
736 ATH_MSG_DEBUG(
"StripHash: " << stripHash <<
"; slope: " <<slope
737 <<
"; intercept: " << intercept
738 <<
"; chi^2/ndf: " << chiSquared <<
"/" << ndf);
744 (*m_fitReturns)[stripHash] = fitRet;
749 if(crossTalkCnt == 23)
755 ATH_MSG_INFO(
"Completed calculating parameters for each strip");
756 return StatusCode::SUCCESS;
This class saves the "context" of an expanded identifier (ExpandedIdentifier) for compact or hash ver...