ATLAS Offline Software
TileRawDataContainer.icc
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // implementation of TileRawDataContainer
6 
7 #include "GaudiKernel/Bootstrap.h"
8 #include "GaudiKernel/ISvcLocator.h"
9 #include "Identifier/IdentifierHash.h"
10 #include "TileConditions/TileCablingService.h"
11 
12 #include <iostream>
13 #include <sstream>
14 #include <iomanip>
15 
16 template <typename TCOLLECTION>
17 void TileRawDataContainer<TCOLLECTION>::initialize(bool createColl, TYPE type,
18  SG::OwnershipPolicy ownPolicy)
19 {
20  // initialize HashFunc
21  this->m_hashFunc.initialize(TileCablingService::getInstance()->getTileHWID(),type);
22 
23  if (createColl) {
24  int ncoll = this->m_hashFunc.max();
25  for(int i=0; i<ncoll;++i){
26  TileFragHash::ID frag = this->m_hashFunc.identifier(i);
27  TCOLLECTION * coll = new TCOLLECTION(frag,ownPolicy) ;
28  StatusCode sc = this->addCollection(coll,static_cast<IdentifierHash>(i));
29  if (sc.isFailure() ) {
30  ISvcLocator* svcLoc = Gaudi::svcLocator( );
31  IMessageSvc* msgSvc;
32  sc = svcLoc->service( "MessageSvc", msgSvc );
33  if ( sc.isFailure() ) {
34  std::cout << "TileRawDataContainer ERROR Can not retrieve MessageSvc" << std::endl;
35  std::cout << "TileRawDataContainer ERROR Can not create collection for frag 0x" << std::hex << frag
36  << " in container with CLID " << std::dec << this->clID() << std::endl;
37  } else {
38  MsgStream log(msgSvc, "TileRawDataContainer");
39  log << MSG::ERROR <<" Can not create collection for frag 0x" << MSG::hex << frag
40  << " in container with CLID " << MSG::dec << this->clID() << endmsg;
41  }
42  }
43  }
44  }
45 
46  return;
47 }
48 
49 template <typename TCOLLECTION>
50 TileRawDataContainer<TCOLLECTION>::TileRawDataContainer(bool createColl,
51  TYPE type,
52  UNIT unit,
53  SG::OwnershipPolicy ownPolicy)
54  : MyBase(TileCablingService::getInstance()->getTileHWID()->drawer_hash_max())
55  , m_unit(unit)
56  , m_type(type)
57  , m_bsflags(0)
58 {
59  // initialize all the rest
60  initialize(createColl,m_type,ownPolicy);
61  return;
62 }
63 
64 template <typename TCOLLECTION>
65 TileRawDataContainer<TCOLLECTION>::TileRawDataContainer(bool createColl,
66  SG::OwnershipPolicy ownPolicy)
67  : MyBase(TileCablingService::getInstance()->getTileHWID()->drawer_hash_max())
68  , m_unit(TileRawChannelUnit::ADCcounts)
69  , m_type(TileFragHash::Digitizer)
70  , m_bsflags(0)
71 {
72  // initialize all the rest
73  initialize(createColl,m_type,ownPolicy);
74  return;
75 }
76 
77 
78 template <typename TCOLLECTION>
79 void TileRawDataContainer<TCOLLECTION>::print() const
80 {
81  std::cout << (std::string) (*this) << std::endl;
82 }
83 
84 template <typename TCOLLECTION>
85 TileRawDataContainer<TCOLLECTION>::operator std::string() const
86 {
87  std::ostringstream text(std::ostringstream::out);
88 
89  text << whoami();
90  text << " size = " << this->size() << std::endl;
91 
92  std::string result(text.str());
93  std::string newline("\n");
94 
95  TContainer_const_iterator it1 = this->begin();
96  TContainer_const_iterator it2 = this->end();
97 
98  const TCOLLECTION * coll;
99 
100  for(;it1!=it2;++it1){
101  coll = (*it1);
102  result += (std::string) (*coll) + newline;
103  }
104 
105  return result;
106 }