some more work towards MusrRoot

This commit is contained in:
2012-03-07 09:50:57 +00:00
parent 5d7eec9b78
commit fb5c5541f1
2 changed files with 67 additions and 20 deletions

View File

@ -16,27 +16,29 @@
<xs:complexType name="musrRoot">
<xs:sequence>
<xs:element name="histos" type="histosFolder"/>
<xs:element ref="histos"/>
<xs:element name="RunHeader" type="runHeaderFolder"/>
<xs:any processContents="skip" minOccurs="0" maxOccurs="unbounded"/> <!-- here can go any additional stuff you like -->
</xs:sequence>
</xs:complexType>
<xs:complexType name="histosFolder">
<xs:element name="histos">
<xs:annotation>
<xs:documentation>
The histos folder is containing potentially various subfolders.
At least one subfolder, called DecayAnaModule, which holds the
muSR decay histograms, must be present.
At least two subfolders, called DecayAnaModule, and SlowControlAnaModule,
which holds the muSR decay histograms, must be present.
</xs:documentation>
</xs:annotation>
<xs:sequence>
<xs:element name="DecayAnaModule" type="decayHistoData"/>
<xs:element name="SlowControlAnaModule" type="slowControlHistoData"/>
<xs:any processContents="skip" minOccurs="0" maxOccurs="unbounded"/> <!-- here can go any additional stuff you like -->
</xs:sequence>
</xs:complexType>
<xs:complexType>
<xs:sequence>
<xs:element name="DecayAnaModule" type="decayHistoData"/>
<xs:element name="SCAnaModule" type="slowControlHistoData"/>
<xs:any processContents="skip" minOccurs="0" maxOccurs="unbounded"/> <!-- here can go any additional stuff you like -->
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:complexType name="decayHistoData">
<xs:sequence>
@ -53,7 +55,7 @@
<xs:simpleType name="histoName">
<xs:restriction base="xs:string">
<xs:pattern value="hDecay([0-9]){3}"/> <!-- this means hDecayXXX, where XXX are 3 digits -->
<xs:pattern value="hDecay([0-9]){4}"/> <!-- this means hDecayXXX, where XXX are 3 digits -->
</xs:restriction>
</xs:simpleType>
@ -71,17 +73,11 @@
<xs:complexType name="slowControlHistoEntry">
<xs:sequence>
<xs:element name="SlowControlName" type="slowControlName"/>
<xs:element name="SlowControlName" type="xs:string"/>
<xs:element name="SlowControlType" type="slowControlType"/>
</xs:sequence>
</xs:complexType>
<xs:simpleType name="slowControlName">
<xs:restriction base="xs:string">
<xs:pattern value="h(\S)+"/> <!-- this means 'h' followed by one or more characters without space, e.g. 'hTemperature1', but NOT 'hTemp 1'-->
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="slowControlType">
<xs:restriction base="xs:string">
<xs:pattern value="TH1F"/>

View File

@ -47,6 +47,14 @@ void root2xml(const char *filename, const char *xmlFilename)
xml_data.push_back("</MusrRoot>");
// the sort_histo_folders is needed since XML-Schema is not flexible enough to handle
// histos -|
// |- DecayAnaModule
// ... (any other analyzer module sub-folder
// |- SCAnaModule
// Hence SCAnaModule has artificially moved up, just to follow DecayAnaModule
sort_histo_folders();
ofstream fout(xmlFilename);
for (UInt_t i=0; i<xml_data.size(); i++)
@ -54,6 +62,49 @@ void root2xml(const char *filename, const char *xmlFilename)
fout.close();
}
void sort_histo_folders()
{
vector<string> temp_xml_data;
// first make a copy of the original xml_data
for (unsigned int i=0; i<xml_data.size(); i++)
temp_xml_data.push_back(xml_data[i]);
// remove SCAnaModule from temp_xml_data
unsigned int start = 0, end = 0;
for (unsigned int i=0; i<temp_xml_data.size(); i++) {
if (temp_xml_data[i].find("<SCAnaModule>") != string::npos)
start = i;
if (temp_xml_data[i].find("</SCAnaModule>") != string::npos)
end = i+1;
}
if ((start > 0) && (end > 0))
temp_xml_data.erase(temp_xml_data.begin()+start, temp_xml_data.begin()+end);
else // no SCAnaModule present, hence nothing to be done
return;
// insert SCAnaModule just after DecayAnaModule
// 1st find end of DecayAnaModule
unsigned int pos = 0;
for (unsigned int i=0; i<temp_xml_data.size(); i++) {
if (temp_xml_data[i].find("</DecayAnaModule>") != string::npos) {
pos = i+1;
break;
}
}
if (pos == 0) // something is wrong, hence to not do anything
return;
temp_xml_data.insert(temp_xml_data.begin()+pos, xml_data.begin()+start, xml_data.begin()+end);
// copy temp_xml_data back into xml_data
xml_data.clear();
for (unsigned int i=0; i<temp_xml_data.size(); i++)
xml_data.push_back(temp_xml_data[i]);
// clean up
temp_xml_data.clear();
}
void dumpFolder(TFolder *folder, UInt_t offset)
{
TString offsetStr="";