7 #include "GaudiKernel/ToolHandle.h"
50 m_groupingType(
"FeedThrough")
82 double default_Tdrift[4] = { 420 , 475 , 475 , 475 } ;
83 for (
unsigned i=0;
i<4;
i++)
m_Tdrift.push_back(default_Tdrift[
i]);
86 double default_Tdrift2[4] = { 1200. , 1200. , 1200. , 1200. } ;
87 for (
unsigned i=0;
i<4;
i++)
m_Tdrift2.push_back(default_Tdrift2[
i]);
90 double default_wTriangle2[4] = { 0.01 , 0.01 , 0.01 , 0.01 } ;
105 unsigned int default_TshiftLayer[4] = { 0 , 0 , 0 , 0 } ;
121 ATH_MSG_INFO(
"Using standard triangular ionization pulse" ) ;
123 ATH_MSG_INFO(
"Using refined ionization pulse (double triangle)" ) ;
151 return StatusCode::SUCCESS ;
158 explicit FileCloser (FILE* the_f):
f (the_f) {}
159 ~FileCloser() {
if (
f) fclose(
f); }
162 FileCloser (
const FileCloser&) =
delete;
163 FileCloser& operator= (
const FileCloser&) =
delete;
182 ToolHandle<LArPhysWaveTool> larPhysWaveTool(
"LArPhysWaveTool");
184 if (
sc!=StatusCode::SUCCESS) {
190 ToolHandle<LArPhysWaveHECTool> larPhysWaveHECTool(
"LArPhysWaveHECTool");
192 sc=larPhysWaveHECTool.retrieve();
193 if (
sc!=StatusCode::SUCCESS) {
206 return StatusCode::FAILURE;
213 return StatusCode::FAILURE;
224 sc =
detStore()->retrieve(larCaliPulseParams);
225 if (
sc == StatusCode::FAILURE ) {
229 ATH_MSG_INFO(
"LArCaliPulseParams successfully retrieved" ) ;
236 if (
sc == StatusCode::FAILURE ) {
240 ATH_MSG_INFO(
"LArDetCellParams successfully retrieved" );
249 if (
sc == StatusCode::FAILURE ) {
253 ATH_MSG_INFO(
"LArTdriftComplete successfully retrieved" );
259 if (
sc == StatusCode::FAILURE ) {
263 ATH_MSG_INFO(
"LArPhysCaliTdiff successfully retrieved" );
270 ATH_MSG_INFO(
"Will use helper class for start time." );
281 ATH_MSG_INFO(
"Manually shifting pulses by *layer-dependent* time indexes." );
285 ATH_MSG_INFO(
"Manually shifting pulses by *FEB* time indexes." );
288 larFebTshift =
nullptr;
296 if (
sc.isFailure() || !fcalPhysWaves) {
300 ATH_MSG_INFO(
"LArPhysCaliTdiff successfully retrieved" );
307 std::unique_ptr<LArPhysWaveContainer> larPhysWaveContainer = std::make_unique<LArPhysWaveContainer>();
310 if (
sc.isFailure()) {
311 ATH_MSG_ERROR(
"Failed to set groupingType for LArPhysWaveContainer object" );
316 if (
sc.isFailure()) {
317 ATH_MSG_ERROR(
"Failed initialize LArPhysWaveContainer object" );
322 std::unique_ptr<LArMphysOverMcalComplete>
MphysOverMcalComplete = std::make_unique<LArMphysOverMcalComplete>();
324 if (
sc.isFailure()) {
325 ATH_MSG_ERROR(
"Failed to set groupingType for LArMphysOverMcalComplete object" );
330 if (
sc.isFailure()) {
331 ATH_MSG_ERROR(
"Failed initialize LArMphysOverMcalComplete object" );
337 f = fopen(
"MphysOverMcali.dat",
"w");
338 fprintf(
f,
"# Region Layer Eta Phi Gain MphysMcali\n");
340 FileCloser fcloser (
f);
342 std::vector<int> nTotal;
343 std::vector<int> noTcali;
344 std::vector<int> noFstep;
345 std::vector<int> noOmega0;
346 std::vector<int> noTaur;
347 std::vector<int> noTdrift;
348 std::vector<int> noTdiff;
351 for (
unsigned i=0;
i<maxgain; ++
i ) {
353 noTcali.push_back(0);
354 noFstep.push_back(0);
355 noOmega0.push_back(0);
357 noTdrift.push_back(0);
358 noTdiff.push_back(0);
380 if (
sc.isFailure()) {
384 if ( caliWaveContainer ==
nullptr ) {
389 ATH_MSG_INFO(
"Processing LArCaliWaveContainer from StoreGate, key = " <<
key );
393 ATH_MSG_INFO(
"Now processing gain = " <<
gain <<
" in LArCaliWaveContainer with key = " <<
key );
398 const_iterator itVec = caliWaveContainer->
begin(
gain);
399 const_iterator itVec_e = caliWaveContainer->
end(
gain);
400 for (; itVec != itVec_e; ++itVec) {
405 << std::hex << itVec.channelId().get_identifier32().get_compact() << std::dec);
411 id =
cabling->cnvToIdentifier(chid);
413 ATH_MSG_ERROR(
"LArCabling exception caught for channel 0x" << MSG::hex << chid << MSG::dec
414 <<
". Skipping channel." ) ;
421 if ( nchannel < 100 || ( nchannel < 1000 && nchannel%100==0 ) || nchannel%1000==0 )
422 ATH_MSG_INFO(
"Processing calibration waveform number " << nchannel );
432 default :
ATH_MSG_ERROR(
"Wrong layer for FCAL SC: "<<
layer<<
" skipping channel 0x"<< MSG::hex << chid << MSG::dec);
continue;
445 ATH_MSG_VERBOSE(
"Predicting physics waveform for channel 0x" << MSG::hex << chid << MSG::dec
446 <<
" (gain = " <<
gain <<
" - DAC = " << larCaliWave.getDAC() <<
")");
452 if ( !
cabling->isOnlineConnected(chid) ) {
453 ATH_MSG_VERBOSE(
"Unconnected channel 0x" << MSG::hex << chid << MSG::dec
454 <<
". Skipping channel.");
468 Tcali = larCaliPulseParams->
Tcal(chid,
gain) ;
475 Fstep = larCaliPulseParams->
Fstep(chid,
gain) ;
488 Omega0 = larDetCellParams->
Omega0(chid,
gain) ;
494 Taur = larDetCellParams->
Taur(chid,
gain) ;
507 Tdrift = larTdrift->
Tdrift(chid) ;
539 Tdiff = larWaveHelper.
getStart(theLArCaliWave) ;
556 float Tshaper = 15. ;
557 float Amplitude = 1. ;
558 LArWFParams wfParams(Tcali,Fstep,Tdrift,Omega0,Taur,Tshaper,Amplitude);
562 ATH_MSG_VERBOSE(
"wfParams: " << Tcali <<
" " <<Fstep<<
" " <<Tdrift<<
" "<<Omega0<<
" "<<Taur<<
" "<<Tdiff<<
" "<<
layer<<
" "<<region );
567 double peak = theLArCaliWave.
getSample(larWaveHelper.
getMax(theLArCaliWave));
568 ATH_MSG_VERBOSE(
"Channel 0x" << MSG::hex << chid << MSG::dec <<
" -> Applying normalisation (CaliWave peak = " << peak <<
")");
572 theLArCaliWave =
LArCaliWave( (theLArCaliWave*(1./peak)).getWave(),
575 theLArCaliWave.
getDt(),
595 sc = larPhysWaveHECTool->makeLArPhysWaveHEC(wfParams,theLArCaliWave,larPhysWave,laridealPhysWave,MphysMcali,chid,
gain,
LArWaveFlag);
601 sc = larPhysWaveTool->makeLArPhysWave(wfParams,theLArCaliWave,region,
layer,larPhysWave,MphysMcali);
603 if (
sc.isFailure()) {
616 sc = larPhysWaveTool->makeLArPhysWave(wfParams2,theLArCaliWave,region,
layer,larPhysWave2,MphysMcali2);
617 if (
sc.isFailure()) {
618 ATH_MSG_FATAL(
"Cannot predict LArPhysWave for channel 0x" << MSG::hex << chid << MSG::dec <<
"with double triangle." );
627 ATH_MSG_WARNING(
"Double triangle implemented only for EMB, skip channel!" ) ;
633 ATH_MSG_DEBUG(
"Time shift for channel " << (itVec.channelId()).get_compact() <<
" is "
634 << Tdiff <<
" samples (" << Tdiff*larPhysWave.
getDt() <<
" ns)");
645 if (MphysMcali<=0.) {
648 ATH_MSG_VERBOSE(
"Channel 0x" << MSG::hex << chid << MSG::dec <<
" -> Mphys/Mcali = " << MphysMcali);
654 fprintf(
f ,
"%2d %2d %3d %3d %2u %8.3f \n", region,
layer,
eta,
phi,
gain, MphysMcali ) ;
667 ATH_MSG_INFO(
" Summary : Number of cells with a PhysWave values computed : " << NPhysWave );
668 ATH_MSG_INFO(
" Summary : Number of cells with a MphysOverMcal values computed : " << NMPMC );
669 ATH_MSG_INFO(
" Summary : Number of Barrel PS cells side A or C (connected+unconnected): 3904+ 192 " );
670 ATH_MSG_INFO(
" Summary : Number of Barrel cells side A or C (connected+unconnected): 50944+2304 " );
671 ATH_MSG_INFO(
" Summary : Number of EMEC cells side A or C (connected+unconnected): 31872+3456 " );
672 ATH_MSG_INFO(
" Summary : Number of HEC cells side A or C (connected+unconnected): 2816+ 256 " );
673 ATH_MSG_INFO(
" Summary : Number of FCAL cells side A or C (connected+unconnected): 1762+ 30 " );
684 ATH_MSG_INFO(
"\t" << noTcali[theGain] <<
" / " << nTotal[theGain] <<
" channel(s) missing Tcali" );
685 ATH_MSG_INFO(
"\t" << noFstep[theGain] <<
" / " << nTotal[theGain] <<
" channel(s) missing Fstep" );
688 ATH_MSG_INFO(
"\t" << noOmega0[theGain] <<
" / " << nTotal[theGain] <<
" channel(s) missing Omega0" );
689 ATH_MSG_INFO(
"\t" << noTaur[theGain] <<
" / " << nTotal[theGain] <<
" channel(s) missing Taur" );
692 ATH_MSG_INFO(
"\t" << noTdrift[theGain] <<
" / " << nTotal[theGain] <<
" channel(s) missing Tdrift" );
694 ATH_MSG_INFO(
"\t" << noTdiff[theGain] <<
" / " << nTotal[theGain] <<
" channel(s) missing Tdiff" );
700 if (
sc.isFailure()) {
702 return StatusCode::FAILURE;
707 if (
sc.isFailure()) {
709 return StatusCode::FAILURE;
713 ATH_MSG_DEBUG(
"Trying to symlink ILArMphysOverMcal with LArMphysOverMcalComplete...");
715 if (
sc.isFailure()) {
716 ATH_MSG_FATAL(
"Could not symlink ILArMphysOverMcal with LArMphysOverMcalComplete." );
717 return StatusCode::FAILURE;
719 ATH_MSG_INFO(
"ILArMphysOverMcal symlink with LArMphysOverMcalComplete successfully" ) ;
723 return StatusCode::SUCCESS;
732 <<
", gain = " <<
gain <<
". Will use jobO setting." ) ;
737 const std::string badChanStatus=packer.
stringStatus(bc);
740 <<
", gain = " <<
gain <<
" BC status=[" << badChanStatus <<
"]. Will use jobO setting." );