ATLAS Offline Software
FolderTypes.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
3 */
4 #include "FolderTypes.h"
5 #include "GaudiKernel/IClassIDSvc.h"
6 #include "IOVDbStringFunctions.h"
7 #include "CoolKernel/IRecordSpecification.h"
9 #include <vector>
10 
11 namespace IOVDbNamespace{
12 
13 
14 
16  determineFolderType(const std::string & folderDescription, const std::string & spec, const std::vector<cool::ChannelId> & chans){
17  //If you find a coracool tag, it is unambiguously a coracool folder
18  if (folderDescription.find("<coracool>") != std::string::npos) return CoraCool;
19  const std::string typeName = parseTypename(folderDescription);
20  //if the type is CondAttrListVec, and yet it is not a CoraCool, it must be a CoolVector
21  if (typeName=="CondAttrListVec") return CoolVector;
22  //check if the payload spec is compatible with a pool ref/pool ref collection
23  if (poolCompatible(spec)){
24  const auto nchans = chans.size();
25  const bool onlyOneSpecialChannel = ((nchans == 1) and (chans[0] == 0));
26  return onlyOneSpecialChannel ? PoolRef : PoolRefColl;
27  }
28  if (typeName == "CondAttrListCollection") return AttrListColl;
29  //defaults to AttrList
30  return AttrList;
31  }
32 
33  //determine folder type from DB folder ptr
35  determineFolderType(const cool::IFolderPtr & pFolder, IClassIDSvc* /*clidsvc*/){
36  const auto & folderDescription = pFolder->description();
37  //If you find a coracool tag, it is unambiguously a coracool folder
38  if (folderDescription.find("<coracool>") != std::string::npos) return CoraCool;
39  const std::string typeName = parseTypename(folderDescription);
40  //if the type is CondAttrListVec, and yet it is not a CoraCool, it must be a CoolVector
41  if (typeName=="CondAttrListVec") return CoolVector;
42  //check if the payload spec is compatible with a pool ref/pool ref collection
43  if (poolCompatible(pFolder->payloadSpecification())){
44  const auto & chans=pFolder->listChannels();
45  const auto nchans = chans.size();
46  const bool onlyOneSpecialChannel = ((nchans == 1) and (chans[0] == 0));
47  return onlyOneSpecialChannel ? PoolRef : PoolRefColl;
48  }
49  if (typeName == "CondAttrListCollection") return AttrListColl;
50  //defaults to AttrList
51  return AttrList;
52  }
53 
54  //determine folder type from CondAttrListCollection ptr
57  FolderType ftype(AttrList);
58  //has a single magic channel?
59  if (pAttrListColl->size()==1 && pAttrListColl->begin()->first==0xFFFF) {
60  if (poolCompatible (pAttrListColl)) return PoolRef;
61  return AttrList;
62  } else {
63  ftype=AttrListColl;
64  if ( pAttrListColl->size()>0) {
65  if (poolCompatible(pAttrListColl)) return PoolRefColl;
66  }
67  }
68  return ftype;
69  }
70 
71  //determine folder type from CondAttrListCollection
74  FolderType ftype(AttrList);
75  //has a single magic channel?
76  if (attrListColl.size()==1 && attrListColl.begin()->first==0xFFFF) {
77  if (poolCompatible (attrListColl)) return PoolRef;
78  return AttrList;
79  } else {
80  ftype=AttrListColl;
81  if ( attrListColl.size()>0) {
82  if (poolCompatible(attrListColl)) return PoolRefColl;
83  }
84  }
85  return ftype;
86  }
87 
89  determineFolderType(const coral::AttributeSpecification& spec){
91  if (spec.name()=="PoolRef" && spec.typeName()=="string") result = PoolRef;
92  return result;
93  }
94 
95  bool
96  poolCompatible(const cool::IRecordSpecification& rspec){
97  return (rspec.exists("PoolRef") && rspec[0].name()=="PoolRef" &&
98  rspec[0].storageType()==cool::StorageType::String4k);
99  }
100 
101  bool
102  poolCompatible(const std::string & specString){
103  return (specString.find("PoolRef:String4k") != std::string::npos || specString.find("PoolRef: String4k") != std::string::npos ||
104  specString.find("PoolRef : String4k") != std::string::npos);
105  }
106 
107  bool
108  poolCompatible(const CondAttrListCollection * pAttrListColl){
109  const coral::AttributeList& payload1=pAttrListColl->begin()->second;
110  const coral::AttributeSpecification& spec=payload1[0].specification();
111  return (spec.name()=="PoolRef" && spec.typeName()=="string");
112  }
113 
114  bool
115  poolCompatible(const CondAttrListCollection & attrListColl){
116  const coral::AttributeList& payload1=attrListColl.begin()->second;
117  const coral::AttributeSpecification& spec=payload1[0].specification();
118  return (spec.name()=="PoolRef" && spec.typeName()=="string");
119  }
120 
121  std::string
123  static const std::vector<std::string> names{"AttrList", "AttrListColl", "PoolRef",
124  "PoolRefColl", "CoraCool", "CoolVector", "JSON"};
125  if (f==UNKNOWN) return "Unknown";
126  return names[f];
127  }
128 
129 }
130 
python.CaloRecoConfig.f
f
Definition: CaloRecoConfig.py:127
get_generator_info.result
result
Definition: get_generator_info.py:21
CondAttrListCollection.h
This file defines the class for a collection of AttributeLists where each one is associated with a ch...
CaloCondBlobAlgs_fillNoiseFromASCII.spec
spec
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:47
IOVDbNamespace::UNKNOWN
@ UNKNOWN
Definition: FolderTypes.h:27
CondAttrListCollection::begin
const_iterator begin() const
Access to Chan/AttributeList pairs via iterators.
Definition: CondAttrListCollection.h:309
IOVDbNamespace::PoolRefColl
@ PoolRefColl
Definition: FolderTypes.h:31
IOVDbNamespace::PoolRef
@ PoolRef
Definition: FolderTypes.h:30
python.PyKernel.AttributeList
AttributeList
Definition: PyKernel.py:36
CondAttrListCollection
This class is a collection of AttributeLists where each one is associated with a channel number....
Definition: CondAttrListCollection.h:52
IOVDbStringFunctions.h
python.subdetectors.mmg.names
names
Definition: mmg.py:8
IOVDbNamespace::CoolVector
@ CoolVector
Definition: FolderTypes.h:33
IOVDbNamespace::CoraCool
@ CoraCool
Definition: FolderTypes.h:32
IOVDbNamespace::AttrListColl
@ AttrListColl
Definition: FolderTypes.h:29
IOVDbNamespace::parseTypename
std::string parseTypename(const std::string &description)
Extract the typename from a folder description.
Definition: IOVDbStringFunctions.cxx:70
CondAttrListCollection::size
size_type size() const
number of Chan/AttributeList pairs
Definition: CondAttrListCollection.h:322
IOVDbNamespace::poolCompatible
bool poolCompatible(const cool::IRecordSpecification &rspec)
Is the folder type compatible with Pool storage type?
Definition: FolderTypes.cxx:96
IOVDbNamespace::AttrList
@ AttrList
Definition: FolderTypes.h:28
FolderTypes.h
ReadCalibFromCool.typeName
typeName
Definition: ReadCalibFromCool.py:477
IOVDbNamespace::folderTypeName
std::string folderTypeName(const FolderType f)
Give a string name for the folder type.
Definition: FolderTypes.cxx:122
IOVDbNamespace::determineFolderType
FolderType determineFolderType(const std::string &folderDescription, const std::string &spec, const std::vector< cool::ChannelId > &chans)
Determine folder type with optional check using clid service to check clid matches typename.
Definition: FolderTypes.cxx:16
python.LArCondContChannels.chans
list chans
Definition: LArCondContChannels.py:638
IOVDbNamespace::FolderType
FolderType
Definition: FolderTypes.h:26
IOVDbNamespace
Definition: Base64Codec.cxx:16