130 for(
unsigned int pulserLevel=0; pulserLevel < 64; pulserLevel++)
138 const std::vector<Identifier> & ids =
m_idHelperSvc->cscIdHelper().idVector();
142 for(
const auto & thisChamberId:ids)
144 std::vector<Identifier> stripVect;
145 m_idHelperSvc->cscIdHelper().idChannels(thisChamberId,stripVect);
149 for(
const auto & thisStripId:stripVect)
152 m_idHelperSvc->cscIdHelper().get_channel_hash(thisStripId,stripHash);
162 char orientation = (
m_idHelperSvc->cscIdHelper().measuresPhi(
id) ?
'Y':
'X');
164 int stationName =
m_idHelperSvc->cscIdHelper().stationName(
id);
165 int stationPhi =
m_idHelperSvc->cscIdHelper().stationPhi(
id);
166 int stationEta =
m_idHelperSvc->cscIdHelper().stationEta(
id);
170 char bitName[200], titleSeed[500];
172 sprintf(bitName,
"bitHist%d",(
int)stripHash);
173 sprintf(titleSeed,
"Bit histogram for eta %d, sector %d, layer %d%c strip %d",
174 stationEta,(2*stationPhi+50 - stationName),wireLayer,orientation,stripNumber);
177 hist->GetXaxis()->SetTitle(
"Bit");
178 hist->GetYaxis()->SetTitle(
"Counts");
188 for(
unsigned int chanItr =0; chanItr <=
m_maxStripHash; chanItr++)
201 in >> buff >> buff >> buff >> buff >> buff ;
207 in >> stripHash >> buff >> buff >> ped >> noise;
208 ATH_MSG_INFO(stripHash <<
"\t" << ped <<
"\t" << noise);
209 if( stripHash < 0 || (
unsigned int) stripHash >
m_maxStripHash ) {
211 ATH_MSG_FATAL(
"The hash "<< (
int) stripHash <<
" is out of range for the Ped-Vector - Crashing!");
212 return StatusCode::FAILURE;
239 return StatusCode::SUCCESS;
304 MsgStream mLog( msgSvc(), name() );
313 StatusCode sc_read =
evtStore()->retrieve(fullRDO,
"CSCRDO");
314 if (sc_read != StatusCode::SUCCESS)
317 return StatusCode::FAILURE;
327 for(
const auto rod:*fullRDO)
332 uint16_t pulsedWireLayer = rod->calLayer();
334 int pulserLevel = rod->calAmplitude();
338 ATH_MSG_INFO(
"New pulser level found. (" << pulserLevel <<
").");
340 std::map<int,TProfile*>::iterator alreadyExistingProfile =
m_ampProfs.find(pulserLevel);
342 if(alreadyExistingProfile ==
m_ampProfs.end())
346 std::stringstream name, title;
347 name <<
"ampProf_" << pulserLevel;
365 unsigned int samplingPhase = rod->samplingPhase();
366 uint8_t samplingPeriod = rod->rate();
372 for(
const auto cluster: *rod)
376 int numStrips = cluster->width();
377 int samplesPerStrip = (cluster->samples()).size()/numStrips;
381 for(
int stripItr = 0; stripItr <numStrips; stripItr++)
385 m_idHelperSvc->cscIdHelper().get_channel_hash(stripId, cscChannelHashId);
390 int stripHash = cscChannelHashId;
393 int chamberLayer =
m_idHelperSvc->cscIdHelper().chamberLayer(stripId);
399 return StatusCode::FAILURE;
402 int currentWireLayer =
m_idHelperSvc->cscIdHelper().wireLayer(stripId) - 1;
403 if( currentWireLayer < 0 || currentWireLayer > 3)
405 ATH_MSG_FATAL(
"Problem in getting wire layer! - Current value is "
406 <<
m_idHelperSvc->cscIdHelper().wireLayer(stripId) <<
" while only values between 1-4 are allowed.");
407 return StatusCode::FAILURE;
409 bool isThisLayerPulsed = (pulsedWireLayer >> currentWireLayer)&0x1;
410 if(isThisLayerPulsed)
413 std::vector<uint16_t> samples;
414 cluster->samples(stripItr,samplesPerStrip,samples);
428 else ATH_MSG_ERROR(
"Failed at getting pedestal from COOL for hash " << stripHash);
430 return StatusCode::RECOVERABLE;
439 else ATH_MSG_ERROR(
"Failed at getting noise from COOL for hash " << stripHash);
441 return StatusCode::FAILURE;
447 double peakAmp{}, peakTime{};
452 std::vector<float> floatSamples;
453 for(
const auto & thisSample:samples){
454 floatSamples.push_back(thisSample-ped);
463 success =
m_cscCalibTool->findCharge((
float)samplingPeriod, samplingPhase,floatSamples,peakAmp,peakTime);
469 double adcSamples[4];
470 for(
int i = 0; i < 4; i++) adcSamples[i] = samples[i] -ped;
471 double fitResult[3],fitErrors[3],
chi2;
472 double width = samplingPeriod == 50 ? 7.2:14.4;
476 peakAmp = fitResult[0];
477 peakTime = fitResult[1] - (samplingPhase ? 25 : 0);
495 ATH_MSG_WARNING(
"Pulsed layer " << pulsedWireLayer<<
", Samples: " << samples[0] <<
", " << samples[1] <<
", " << samples[2] <<
", " << samples[3]);
512 return StatusCode::SUCCESS;
524 unsigned int numCalibPoints =
m_ampProfs.size();
525 ATH_MSG_INFO(
"There are " << numCalibPoints <<
" pulser levels to evaluate.");
529 float chargeMax = 530.88;
531 int crossTalkCnt = 0;
533 for(
unsigned int stripHash = 0 ;stripHash <=
m_maxStripHash; stripHash++)
546 int chamberLayer =
m_idHelperSvc->cscIdHelper().chamberLayer(
id);
547 char orientation = (
m_idHelperSvc->cscIdHelper().measuresPhi(
id) ?
'Y':
'X');
552 int stationName =
m_idHelperSvc->cscIdHelper().stationName(
id);
553 int stationPhi =
m_idHelperSvc->cscIdHelper().stationPhi(
id);
554 int stationEta =
m_idHelperSvc->cscIdHelper().stationEta(
id);
575 if(orientation !=
'X')
579 bool foundMin(
false);
587 TGraphErrors * calGraph =
new TGraphErrors(numCalibPoints);
588 char calName[20],titleSeed[500];
589 sprintf(calName,
"calGraph%u",stripHash);
590 sprintf(titleSeed,
"Calgraph for eta %d, sector %d, layer %d%c, strip %d",stationEta,(2*stationPhi+50 - stationName),wireLayer,orientation, stripNumber);
591 calGraph->SetName(calName);
593 calGraph->SetTitle(title.c_str());
594 calGraph->GetYaxis()->SetTitle(
"ADC counts");
595 calGraph->GetXaxis()->SetTitle(
"Attenuation (-db)");
599 bool isGoodStrip =
false;
605 for(
const auto & [pulserLevel, pAmplitudeProfile] :
m_ampProfs)
607 if(!pAmplitudeProfile){
609 return StatusCode::FAILURE;
614 if(pAmplitudeProfile->GetBinEntries(stripHash+1))
622 float adcValue = pAmplitudeProfile->GetBinContent(stripHash+1);
623 float adcError = pAmplitudeProfile->GetBinError(stripHash+1);
630 if(adcError != adcError)
638 attenValue = 300*std::pow(10,db/20);
642 ATH_MSG_DEBUG(
"\tStoring at db of " << db <<
" with attenValue " << attenValue <<
" from pulser level of " << pulserLevel <<
" and adcValue " << adcValue);
648 thisDrop = lastVal - adcValue;
650 <<
"\tlastVal = " << lastVal
651 <<
";lastDrop " << lastDrop <<
"; thisDrop " << thisDrop);
655 fitMinX = attenValue;
665 if(attenValue > fitMaxX)
666 fitMaxX = attenValue;
668 calGraph->SetPoint(calPointItr,attenValue,adcValue);
669 calGraph->SetPointError(calPointItr,0.01,adcError);
675 if(!foundMin && isGoodStrip){
683 ATH_MSG_INFO(
"we have a good stripHash at " << stripHash);
687 float slope, slopeError, intercept, interceptError, chiSquared;
692 TF1 myFunc(
"myFunction",
m_calFitFunc.c_str(), fitMinX, fitMaxX);
693 myFunc.SetLineColor(kRed);
696 myFunc.SetParameters(0,5);
697 slope = myFunc.GetParameter(1);
698 slopeError = myFunc.GetParError(1);
699 intercept = myFunc.GetParameter(0);
700 interceptError = myFunc.GetParError(0);
701 chiSquared = myFunc.GetChisquare();
702 ndf = myFunc.GetNDF();
706 myFunc.SetParameters(0.1,2000);
708 fitRet = calGraph->Fit(&myFunc,
"RV");
710 slope = myFunc.GetParameter(1)/chargeMax;
711 slopeError = myFunc.GetParError(1);
712 intercept = myFunc.GetParameter(0);
713 interceptError = myFunc.GetParError(0);
714 chiSquared = myFunc.GetChisquare();
715 ndf = myFunc.GetNDF();
719 if(std::abs(slope) < 0.00001 || slope == -999)
725 invertedSlope = 1/slope;
727 ATH_MSG_ERROR(
"Inserting calgraph in for hash " << stripHash);
730 ATH_MSG_DEBUG(
"StripHash: " << stripHash <<
"; slope: " <<slope
731 <<
"; intercept: " << intercept
732 <<
"; chi^2/ndf: " << chiSquared <<
"/" << ndf);
743 if(crossTalkCnt == 23)
749 ATH_MSG_INFO(
"Completed calculating parameters for each strip");
750 return StatusCode::SUCCESS;
This class saves the "context" of an expanded identifier (ExpandedIdentifier) for compact or hash ver...