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);
386 int stripHash = cscChannelHashId;
389 int chamberLayer =
m_idHelperSvc->cscIdHelper().chamberLayer(stripId);
395 return StatusCode::FAILURE;
398 int currentWireLayer =
m_idHelperSvc->cscIdHelper().wireLayer(stripId) - 1;
399 if( currentWireLayer < 0 || currentWireLayer > 3)
401 ATH_MSG_FATAL(
"Problem in getting wire layer! - Current value is "
402 <<
m_idHelperSvc->cscIdHelper().wireLayer(stripId) <<
" while only values between 1-4 are allowed.");
403 return StatusCode::FAILURE;
405 bool isThisLayerPulsed = (pulsedWireLayer >> currentWireLayer)&0x1;
406 if(isThisLayerPulsed)
409 std::vector<uint16_t> samples;
410 cluster->samples(stripItr,samplesPerStrip,samples);
424 else ATH_MSG_ERROR(
"Failed at getting pedestal from COOL for hash " << stripHash);
426 return StatusCode::RECOVERABLE;
435 else ATH_MSG_ERROR(
"Failed at getting noise from COOL for hash " << stripHash);
437 return StatusCode::FAILURE;
443 double peakAmp{}, peakTime{};
448 std::vector<float> floatSamples;
449 for(
const auto & thisSample:samples){
451 floatSamples.push_back(thisSample-ped);
460 success =
m_cscCalibTool->findCharge((
float)samplingPeriod, samplingPhase,floatSamples,peakAmp,peakTime);
466 double adcSamples[4];
467 for(
int i = 0; i < 4; i++) adcSamples[i] = samples[i] -ped;
468 double fitResult[3],fitErrors[3],
chi2;
469 double width = samplingPeriod == 50 ? 7.2:14.4;
473 peakAmp = fitResult[0];
474 peakTime = fitResult[1] - (samplingPhase ? 25 : 0);
492 ATH_MSG_WARNING(
"Pulsed layer " << pulsedWireLayer<<
", Samples: " << samples[0] <<
", " << samples[1] <<
", " << samples[2] <<
", " << samples[3]);
509 return StatusCode::SUCCESS;
521 unsigned int numCalibPoints =
m_ampProfs.size();
522 ATH_MSG_INFO(
"There are " << numCalibPoints <<
" pulser levels to evaluate.");
526 float chargeMax = 530.88;
528 int crossTalkCnt = 0;
530 for(
unsigned int stripHash = 0 ;stripHash <=
m_maxStripHash; stripHash++)
543 int chamberLayer =
m_idHelperSvc->cscIdHelper().chamberLayer(
id);
544 char orientation = (
m_idHelperSvc->cscIdHelper().measuresPhi(
id) ?
'Y':
'X');
549 int stationName =
m_idHelperSvc->cscIdHelper().stationName(
id);
550 int stationPhi =
m_idHelperSvc->cscIdHelper().stationPhi(
id);
551 int stationEta =
m_idHelperSvc->cscIdHelper().stationEta(
id);
572 if(orientation !=
'X')
576 bool foundMin(
false);
584 TGraphErrors * calGraph =
new TGraphErrors(numCalibPoints);
585 char calName[20],titleSeed[500];
586 sprintf(calName,
"calGraph%u",stripHash);
587 sprintf(titleSeed,
"Calgraph for eta %d, sector %d, layer %d%c, strip %d",stationEta,(2*stationPhi+50 - stationName),wireLayer,orientation, stripNumber);
588 calGraph->SetName(calName);
590 calGraph->SetTitle(title.c_str());
591 calGraph->GetYaxis()->SetTitle(
"ADC counts");
592 calGraph->GetXaxis()->SetTitle(
"Attenuation (-db)");
596 bool isGoodStrip =
false;
602 for(
const auto & [pulserLevel, pAmplitudeProfile] :
m_ampProfs)
604 if(!pAmplitudeProfile){
606 return StatusCode::FAILURE;
611 if(pAmplitudeProfile->GetBinEntries(stripHash+1))
619 float adcValue = pAmplitudeProfile->GetBinContent(stripHash+1);
620 float adcError = pAmplitudeProfile->GetBinError(stripHash+1);
627 if(adcError != adcError)
635 attenValue = 300*std::pow(10,db/20);
639 ATH_MSG_DEBUG(
"\tStoring at db of " << db <<
" with attenValue " << attenValue <<
" from pulser level of " << pulserLevel <<
" and adcValue " << adcValue);
645 thisDrop = lastVal - adcValue;
647 <<
"\tlastVal = " << lastVal
648 <<
";lastDrop " << lastDrop <<
"; thisDrop " << thisDrop);
652 fitMinX = attenValue;
662 if(attenValue > fitMaxX)
663 fitMaxX = attenValue;
665 calGraph->SetPoint(calPointItr,attenValue,adcValue);
666 calGraph->SetPointError(calPointItr,0.01,adcError);
672 if(!foundMin && isGoodStrip){
680 ATH_MSG_INFO(
"we have a good stripHash at " << stripHash);
684 float slope, slopeError, intercept, interceptError, chiSquared;
689 TF1 myFunc(
"myFunction",
m_calFitFunc.c_str(), fitMinX, fitMaxX);
690 myFunc.SetLineColor(kRed);
693 myFunc.SetParameters(0,5);
694 slope = myFunc.GetParameter(1);
695 slopeError = myFunc.GetParError(1);
696 intercept = myFunc.GetParameter(0);
697 interceptError = myFunc.GetParError(0);
698 chiSquared = myFunc.GetChisquare();
699 ndf = myFunc.GetNDF();
703 myFunc.SetParameters(0.1,2000);
705 fitRet = calGraph->Fit(&myFunc,
"RV");
707 slope = myFunc.GetParameter(1)/chargeMax;
708 slopeError = myFunc.GetParError(1);
709 intercept = myFunc.GetParameter(0);
710 interceptError = myFunc.GetParError(0);
711 chiSquared = myFunc.GetChisquare();
712 ndf = myFunc.GetNDF();
716 if(std::abs(slope) < 0.00001 || slope == -999)
722 invertedSlope = 1/slope;
724 ATH_MSG_ERROR(
"Inserting calgraph in for hash " << stripHash);
727 ATH_MSG_DEBUG(
"StripHash: " << stripHash <<
"; slope: " <<slope
728 <<
"; intercept: " << intercept
729 <<
"; chi^2/ndf: " << chiSquared <<
"/" << ndf);
740 if(crossTalkCnt == 23)
746 ATH_MSG_INFO(
"Completed calculating parameters for each strip");
747 return StatusCode::SUCCESS;
This class saves the "context" of an expanded identifier (ExpandedIdentifier) for compact or hash ver...