168{
170
171 LArWaveHelper larWaveHelper;
172
173
174
175
176
177
178
179
180
181
182 ToolHandle<LArPhysWaveTool> larPhysWaveTool("LArPhysWaveTool");
184 if (
sc!=StatusCode::SUCCESS) {
187 }
188
189
190 ToolHandle<LArPhysWaveHECTool> larPhysWaveHECTool("LArPhysWaveHECTool");
192 sc=larPhysWaveHECTool.retrieve();
193 if (
sc!=StatusCode::SUCCESS) {
196 }}
197
198
199
200 const LArOnOffIdMapping*
cabling(
nullptr);
204 if(!cabling) {
206 return StatusCode::FAILURE;
207 }
208 }else{
209 SG::ReadCondHandle<LArOnOffIdMapping> cablingHdl{
m_cablingKey};
211 if(!cabling) {
213 return StatusCode::FAILURE;
214 }
215 }
216
217
218 const ILArCaliPulseParams* larCaliPulseParams = nullptr;
219 const ILArDetCellParams* larDetCellParams = nullptr;
220 const ILArTdrift* larTdrift = nullptr;
221 const ILArPhysCaliTdiff* larPhysCaliTdiff = nullptr;
222
224 sc =
detStore()->retrieve(larCaliPulseParams);
225 if (
sc == StatusCode::FAILURE ) {
228 } else {
229 ATH_MSG_INFO(
"LArCaliPulseParams successfully retrieved" ) ;
230 }
231 }
232
236 if (
sc == StatusCode::FAILURE ) {
239 }else {
240 ATH_MSG_INFO(
"LArDetCellParams successfully retrieved" );
241 }
242 }else{
244 }
245 }
246
249 if (
sc == StatusCode::FAILURE ) {
252 }else {
253 ATH_MSG_INFO(
"LArTdriftComplete successfully retrieved" );
254 }
255 }
256
259 if (
sc == StatusCode::FAILURE ) {
262 }else {
263 ATH_MSG_INFO(
"LArPhysCaliTdiff successfully retrieved" );
264 }
265 }
266
267 const ILArFEBTimeOffset* larFebTshift = nullptr;
270 ATH_MSG_INFO(
"Will use helper class for start time." );
274 }
279 }
281 ATH_MSG_INFO(
"Manually shifting pulses by *layer-dependent* time indexes." );
283 }
285 ATH_MSG_INFO(
"Manually shifting pulses by *FEB* time indexes." );
288 larFebTshift = nullptr;
289 }
290 }
291
292 const LArPhysWaveContainer *fcalPhysWaves=nullptr;
293
296 if (
sc.isFailure() || !fcalPhysWaves) {
299 }else {
300 ATH_MSG_INFO(
"LArPhysWave fro FCAL successfully retrieved" );
301 }
302 }
303
304 int nchannel = 0 ;
305
306
307 std::unique_ptr<LArPhysWaveContainer> larPhysWaveContainer = std::make_unique<LArPhysWaveContainer>();
308
310 if (
sc.isFailure()) {
311 ATH_MSG_ERROR(
"Failed to set groupingType for LArPhysWaveContainer object" );
313 }
314
315 sc=larPhysWaveContainer->initialize();
316 if (
sc.isFailure()) {
317 ATH_MSG_ERROR(
"Failed initialize LArPhysWaveContainer object" );
319 }
320
321
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" );
327 }
328
330 if (
sc.isFailure()) {
331 ATH_MSG_ERROR(
"Failed initialize LArMphysOverMcalComplete object" );
333 }
334
337 f = fopen(
"MphysOverMcali.dat",
"w");
338 if (!f) {
339 ATH_MSG_ERROR(
"Cannot open file `MphysOverMcali.dat' for write");
340 return StatusCode::FAILURE;
341 }
342 fprintf(f,"# Region Layer Eta Phi Gain MphysMcali\n");
343 }
344 FileCloser fcloser (f);
345
346 std::vector<int> nTotal;
347 std::vector<int> noTcali;
348 std::vector<int> noFstep;
349 std::vector<int> noOmega0;
350 std::vector<int> noTaur;
351 std::vector<int> noTdrift;
352 std::vector<int> noTdiff;
353
355 for (
unsigned i=0;
i<maxgain; ++
i ) {
356 nTotal.push_back(0);
357 noTcali.push_back(0);
358 noFstep.push_back(0);
359 noOmega0.push_back(0);
360 noTaur.push_back(0);
361 noTdrift.push_back(0);
362 noTdiff.push_back(0);
363 }
364
366
367 const LArPhysWaveContainer* larIdealPhysWaveContainer=nullptr;
371 }
373
374
375
376 int NPhysWave=0;
377 int NMPMC=0;
378
379 for (
const std::string& key :
m_keyCali) {
380
381
382 const LArCaliWaveContainer* caliWaveContainer;
383 sc =
detStore()->retrieve(caliWaveContainer,key);
384 if (
sc.isFailure()) {
385
386 continue;
387 }
388 if ( caliWaveContainer == nullptr ) {
389 ATH_MSG_INFO(
"LArCaliWaveContainer (key = " << key <<
") is empty" );
390 continue;
391 }
392
393 ATH_MSG_INFO(
"Processing LArCaliWaveContainer from StoreGate, key = " << key );
394
396
397 ATH_MSG_INFO(
"Now processing gain = " << gain <<
" in LArCaliWaveContainer with key = " << key );
398
399
400
402 const_iterator itVec = caliWaveContainer->
begin(gain);
403 const_iterator itVec_e = caliWaveContainer->
end(gain);
404 for (; itVec != itVec_e; ++itVec) {
405
406 for (const LArCaliWave& larCaliWave : *itVec) {
407
409 << std::hex << itVec.channelId().get_identifier32().get_compact() << std::dec);
410 const HWIdentifier chid = itVec.channelId();
411
412
414 try {
415 id =
cabling->cnvToIdentifier(chid);
416 } catch (LArID_Exception & execpt) {
417 ATH_MSG_ERROR(
"LArCabling exception caught for channel 0x" << MSG::hex << chid << MSG::dec
418 << ". Skipping channel." ) ;
419 continue ;
420 }
421
424
425 if ( nchannel < 100 || ( nchannel < 1000 && nchannel%100==0 ) || nchannel%1000==0 )
426 ATH_MSG_INFO(
"Processing calibration waveform number " << nchannel );
427
430 LArPhysWave fcalw;
431 fcalw = fcalPhysWaves->
get(chid,0);
432
433
435 std::vector<double> amp;
436 amp.resize(768, 0.);
437 const std::vector<double>& fvec = fcalw.
getWave();
438 std::copy(fvec.begin(), fvec.end(), amp.begin());
440 larPhysWaveContainer->setPdata(chid,ptmp, gain);
441 } else {
442 larPhysWaveContainer->setPdata(chid,fcalw, gain);
443 }
444
445 continue;
446 }
447
448
450
451
453
454 ATH_MSG_VERBOSE(
"Predicting physics waveform for channel 0x" << MSG::hex << chid << MSG::dec
455 << " (gain = " << gain << " - DAC = " << larCaliWave.getDAC() << ")");
456
457
458 LArCaliWave theLArCaliWave = larCaliWave;
459 ++nchannel;
460
461 if ( !
cabling->isOnlineConnected(chid) ) {
462 ATH_MSG_VERBOSE(
"Unconnected channel 0x" << MSG::hex << chid << MSG::dec
463 << ". Skipping channel.");
464 continue ;
465 }
466
467
468 float Tcali;
469 float Fstep;
470 float Omega0;
471 float Taur;
472 float Tdrift;
473 int Tdiff;
474
475
477 Tcali = larCaliPulseParams->
Tcal(chid,gain) ;
478
483 }
484 Fstep = larCaliPulseParams->
Fstep(chid,gain) ;
489 }
490 } else {
493 }
494
495
497 Omega0 = larDetCellParams->
Omega0(chid,gain) ;
502 }
503 Taur = larDetCellParams->
Taur(chid,gain) ;
508 }
509 } else {
512 }
513
514
516 Tdrift = larTdrift->
Tdrift(chid) ;
519
520
521 if ( layer>=0 && layer<4 )
523 else
524 Tdrift = 475.;
526 }
527 } else {
528 if ( layer>=0 && layer<4 )
530 else
531 Tdrift = 475.;
532 }
533
534
535
536 Tdiff = 0 ;
538 Tdiff = (
int)larPhysCaliTdiff->
Tdiff(chid,gain) ;
541 Tdiff = 0 ;
544 }
545 }
548 Tdiff = larWaveHelper.
getStart(theLArCaliWave) ;
550 }
553 }
556 }
561 }
562 }
563
564
565 float Tshaper = 15. ;
566 float Amplitude = 1. ;
567 LArWFParams wfParams(Tcali,Fstep,Tdrift,Omega0,Taur,Tshaper,Amplitude);
568 wfParams.setFlag( 0 ) ;
569 wfParams.setTdiff(Tdiff);
570
571 ATH_MSG_VERBOSE(
"wfParams: " << Tcali <<
" " <<Fstep<<
" " <<Tdrift<<
" "<<Omega0<<
" "<<Taur<<
" "<<Tdiff<<
" "<<layer<<
" "<<region );
572
573
574
576 double peak = theLArCaliWave.
getSample(larWaveHelper.
getMax(theLArCaliWave));
577 ATH_MSG_VERBOSE(
"Channel 0x" << MSG::hex << chid << MSG::dec <<
" -> Applying normalisation (CaliWave peak = " << peak <<
")");
578 if ( peak <=0 ) {
580 } else {
581 theLArCaliWave = LArCaliWave( (theLArCaliWave*(1./peak)).getWave(),
584 theLArCaliWave.
getDt(),
588 }
589 }
590
591
592
593
594 LArPhysWave larPhysWave;
595 float MphysMcali ;
596
597
598 if(larIdealPhysWaveContainer &&
m_onlineHelper->isHECchannel(chid)) {
599 const LArPhysWave& laridealPhysWave = larIdealPhysWaveContainer ->
get(chid,gain);
601
603
604 sc = larPhysWaveHECTool->makeLArPhysWaveHEC(wfParams,theLArCaliWave,larPhysWave,laridealPhysWave,MphysMcali,chid,gain,
LArWaveFlag);
605
606
607 }
608 else {
610 sc = larPhysWaveTool->makeLArPhysWave(wfParams,theLArCaliWave,region,layer,larPhysWave,MphysMcali);
611 }
612 if (
sc.isFailure()) {
614 continue;
615 }
617
620 if ( region==0 && layer>=0 && layer<4 &&
m_wTriangle2[layer]>0 ) {
621 LArWFParams wfParams2 = wfParams ;
623 LArPhysWave larPhysWave2;
624 float MphysMcali2 ;
625 sc = larPhysWaveTool->makeLArPhysWave(wfParams2,theLArCaliWave,region,layer,larPhysWave2,MphysMcali2);
626 if (
sc.isFailure()) {
627 ATH_MSG_FATAL(
"Cannot predict LArPhysWave for channel 0x" << MSG::hex << chid << MSG::dec <<
"with double triangle." );
628 continue;
629 }
633
635 } else {
636 ATH_MSG_WARNING(
"Double triangle implemented only for EMB, skip channel!" ) ;
637 }
638 }
639
640
641 if ( Tdiff !=0 ) {
642 ATH_MSG_DEBUG(
"Time shift for channel " << (itVec.channelId()).get_compact() <<
" is "
643 << Tdiff <<
" samples (" << Tdiff*larPhysWave.
getDt() <<
" ns)");
644 larPhysWave = LArPhysWave( (larWaveHelper.
translate(larPhysWave,-Tdiff,0)).getWave() ,
647 }
648
649
650 larPhysWaveContainer->setPdata(chid,larPhysWave,gain);
651 NPhysWave++;
652
653
654 if (MphysMcali<=0.) {
656 }
657 ATH_MSG_VERBOSE(
"Channel 0x" << MSG::hex << chid << MSG::dec <<
" -> Mphys/Mcali = " << MphysMcali);
659 NMPMC++;
663 fprintf( f ,
"%2d %2d %3d %3d %2u %8.3f \n", region, layer,
eta,
phi, gain, MphysMcali ) ;
664 }
665
666 }
668 }
670 }
672 }
673
674
675
676 ATH_MSG_INFO(
" Summary : Number of cells with a PhysWave values computed : " << NPhysWave );
677 ATH_MSG_INFO(
" Summary : Number of cells with a MphysOverMcal values computed : " << NMPMC );
678 ATH_MSG_INFO(
" Summary : Number of Barrel PS cells side A or C (connected+unconnected): 3904+ 192 " );
679 ATH_MSG_INFO(
" Summary : Number of Barrel cells side A or C (connected+unconnected): 50944+2304 " );
680 ATH_MSG_INFO(
" Summary : Number of EMEC cells side A or C (connected+unconnected): 31872+3456 " );
681 ATH_MSG_INFO(
" Summary : Number of HEC cells side A or C (connected+unconnected): 2816+ 256 " );
682 ATH_MSG_INFO(
" Summary : Number of FCAL cells side A or C (connected+unconnected): 1762+ 30 " );
683
684 ATH_MSG_DEBUG(
"LArPhysWaveContainer->totalNumberOfConditions() = " << larPhysWaveContainer->totalNumberOfConditions());
686
687
690
693 ATH_MSG_INFO(
"\t" << noTcali[theGain] <<
" / " << nTotal[theGain] <<
" channel(s) missing Tcali" );
694 ATH_MSG_INFO(
"\t" << noFstep[theGain] <<
" / " << nTotal[theGain] <<
" channel(s) missing Fstep" );
695 }
697 ATH_MSG_INFO(
"\t" << noOmega0[theGain] <<
" / " << nTotal[theGain] <<
" channel(s) missing Omega0" );
698 ATH_MSG_INFO(
"\t" << noTaur[theGain] <<
" / " << nTotal[theGain] <<
" channel(s) missing Taur" );
699 }
701 ATH_MSG_INFO(
"\t" << noTdrift[theGain] <<
" / " << nTotal[theGain] <<
" channel(s) missing Tdrift" );
703 ATH_MSG_INFO(
"\t" << noTdiff[theGain] <<
" / " << nTotal[theGain] <<
" channel(s) missing Tdiff" );
704 }
706
707
709 if (
sc.isFailure()) {
711 return StatusCode::FAILURE;
712 }
713
714
716 if (
sc.isFailure()) {
718 return StatusCode::FAILURE;
719 }
720
721
722 ATH_MSG_DEBUG(
"Trying to symlink ILArMphysOverMcal with LArMphysOverMcalComplete...");
724 if (
sc.isFailure()) {
725 ATH_MSG_FATAL(
"Could not symlink ILArMphysOverMcal with LArMphysOverMcalComplete." );
726 return StatusCode::FAILURE;
727 }
728 ATH_MSG_INFO(
"ILArMphysOverMcal symlink with LArMphysOverMcalComplete successfully" ) ;
729
731
732 return StatusCode::SUCCESS;
733}
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define ATH_MSG_VERBOSE(x)
virtual const float & Tcal(const HWIdentifier &id, int gain) const =0
virtual const float & Fstep(const HWIdentifier &id, int gain) const =0
virtual const float & Taur(const HWIdentifier &id, int gain) const =0
virtual const float & Omega0(const HWIdentifier &id, int gain) const =0
virtual float TimeOffset(const HWIdentifier fId) const =0
virtual const float & Tdiff(const HWIdentifier &id, int gain) const =0
virtual const float & Tdrift(const HWIdentifier &id) const =0
value_type get_compact() const
Get the compact id.
Identifier32 get_identifier32() const
Get the 32-bit version Identifier, will be invalid if >32 bits needed.
int getIsPulsedInt() const
isPulsed value
int getDAC() const
DAC value.
ConditionsMap::const_iterator ConstConditionsMapIterator
ConstReference get(const HWIdentifier id, unsigned int gain=0) const
get data with online identifier
ConstConditionsMapIterator begin(unsigned int gain) const
get iterator for all channels for a gain
ConstConditionsMapIterator end(unsigned int gain) const
end of all channels for this gain
void notFoundMsg(const HWIdentifier chid, const int gain, const char *value)
void setTdrift(double tdrift)
const std::vector< int > & getTriggers() const
trigger vector
const std::vector< double > & getErrors() const
error vector
LArWave translate(const LArWave &theWave, int nShift, double baseline=0.) const
unsigned int getMax(const LArWave &theWave) const
return index of maximum sample
unsigned getStart(const LArWave &theWave) const
size_t getSize() const
number of time samples
const double & getSample(const unsigned int i) const
Amplitude per time bin.
const std::vector< double > & getWave() const
Wave parameters.
const double & getDt() const
delta time
unsigned getFlag() const
flag: ...
void setFlag(const unsigned flag)
set flag
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)