Skip to content
This repository has been archived by the owner on Mar 31, 2019. It is now read-only.

Commit

Permalink
Version 0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
jpivarski committed Apr 19, 2016
1 parent 8200481 commit b20d857
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 44 deletions.
2 changes: 1 addition & 1 deletion root2avro/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

VERSION=0.1
VERSION='"0.2"'

all:
mkdir -p build
Expand Down
54 changes: 29 additions & 25 deletions root2avro/src/root2avro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,27 @@ int main(int argc, char **argv) {
continue;
}

// print out JSON strings (one JSON document per line)
if (mode == std::string("json")) {
if (start != NA && start > currentEntry) {
treeWalker->setEntryInCurrentTree(start - currentEntry);
currentEntry = start;
}
else
treeWalker->setEntryInCurrentTree(0);

do {
if (end != NA && currentEntry >= end)
return 0;

treeWalker->printJSON();
currentEntry += 1;
} while (treeWalker->next());
}

#ifdef AVRO
// print out Avro bytes (with an "Obj" header)
if (mode == std::string("avro")) {
else if (mode == std::string("avro")) {
if (start != NA && start > currentEntry) {
treeWalker->setEntryInCurrentTree(start - currentEntry);
currentEntry = start;
Expand Down Expand Up @@ -291,6 +310,13 @@ int main(int argc, char **argv) {
} while (treeWalker->next());
}

// print the schema and exit
else if (mode == std::string("schema")) {
std::cout << treeWalker->avroSchema() << std::endl;
return 0;
}
#endif // AVRO

// dump data for ScaROOT-Reader
else if (mode == std::string("dump")) {
if (start != NA && start > currentEntry) {
Expand All @@ -313,30 +339,6 @@ int main(int argc, char **argv) {
} while (treeWalker->next());
}

// print out JSON strings (one JSON document per line)
else if (mode == std::string("json")) {
if (start != NA && start > currentEntry) {
treeWalker->setEntryInCurrentTree(start - currentEntry);
currentEntry = start;
}
else
treeWalker->setEntryInCurrentTree(0);

do {
if (end != NA && currentEntry >= end)
return 0;

treeWalker->printJSON();
currentEntry += 1;
} while (treeWalker->next());
}

// print the schema and exit
else if (mode == std::string("schema")) {
std::cout << treeWalker->avroSchema() << std::endl;
return 0;
}

// print the ROOT representation and exit
else if (mode == std::string("repr")) {
std::cout << treeWalker->repr() << std::endl;
Expand All @@ -354,6 +356,8 @@ int main(int argc, char **argv) {
fwrite(&endMarker, sizeof(endMarker), 1, stdout);
}

#ifdef AVRO
treeWalker->closeAvro();
#endif
return 0;
}
2 changes: 1 addition & 1 deletion scaroot-reader/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

<groupId>org.diana-hep</groupId>
<artifactId>scaroot-reader</artifactId>
<version>0.1</version>
<version>0.2</version>
<packaging>jar</packaging>

<licenses>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ package external {
myclasses: Map[String, My[_]] = Map[String, My[_]](),
start: Long = 0L,
end: Long = -1L,
command: String = "./root2avro",
command: String = "root2avro",
environment: Map[String, String] = Map[String, String](),
numberOfTrials: Int = 4) extends Iterator[TYPE] {
if (fileLocations.isEmpty)
Expand Down Expand Up @@ -159,7 +159,7 @@ package external {
myclasses: Map[String, My[_]] = Map[String, My[_]](),
start: Long = 0L,
end: Long = -1L,
command: String = "./root2avro",
command: String = "root2avro",
environment: Map[String, String] = Map[String, String](),
numberOfTrials: Int = 4) =
new RootTreeIterator[TYPE](fileLocations, treeLocation, includes, libs, inferTypes, myclasses, start, end, command, environment, numberOfTrials)
Expand Down
30 changes: 15 additions & 15 deletions scaroot-reader/src/test/scala/test.scala
Original file line number Diff line number Diff line change
Expand Up @@ -505,25 +505,25 @@ class DefaultSuite extends FlatSpec with Matchers {
println(iterator2.next().event.fEventName)
}

"Bacon.root" must "work" in {
val myclasses = Map("Events" -> My[Tree2], "baconhep::TEventInfo" -> My[baconhep.TEventInfo], "baconhep::TGenEventInfo" -> My[baconhep.TGenEventInfo], "baconhep::TGenParticle" -> My[baconhep.TGenParticle], "baconhep::TLHEWeight" -> My[baconhep.TLHEWeight], "baconhep::TElectron" -> My[baconhep.TElectron], "baconhep::TMuon" -> My[baconhep.TMuon], "baconhep::TTau" -> My[baconhep.TTau], "baconhep::TPhoton" -> My[baconhep.TPhoton], "baconhep::TVertex" -> My[baconhep.TVertex], "baconhep::TJet" -> My[baconhep.TJet], "baconhep::TAddJet" -> My[baconhep.TAddJet])
// "Bacon.root" must "work" in {
// val myclasses = Map("Events" -> My[Tree2], "baconhep::TEventInfo" -> My[baconhep.TEventInfo], "baconhep::TGenEventInfo" -> My[baconhep.TGenEventInfo], "baconhep::TGenParticle" -> My[baconhep.TGenParticle], "baconhep::TLHEWeight" -> My[baconhep.TLHEWeight], "baconhep::TElectron" -> My[baconhep.TElectron], "baconhep::TMuon" -> My[baconhep.TMuon], "baconhep::TTau" -> My[baconhep.TTau], "baconhep::TPhoton" -> My[baconhep.TPhoton], "baconhep::TVertex" -> My[baconhep.TVertex], "baconhep::TJet" -> My[baconhep.TJet], "baconhep::TAddJet" -> My[baconhep.TAddJet])

val iterator = RootTreeIterator[Tree2](List("../root2avro/test_Bacon/Output.root"), "Events", inferTypes = true, myclasses = myclasses, end = 10L)
// val iterator = RootTreeIterator[Tree2](List("../root2avro/test_Bacon/Output.root"), "Events", inferTypes = true, myclasses = myclasses, end = 10L)

while (iterator.hasNext) {
val x = iterator.next()
println(x.PV)
println(x.Photon)
}
// while (iterator.hasNext) {
// val x = iterator.next()
// println(x.PV)
// println(x.Photon)
// }

val iterator2 = external.RootTreeIterator[Tree2](List("../root2avro/test_Bacon/Output.root"), "Events", inferTypes = true, myclasses = myclasses, command = "../root2avro/build/root2avro", end = 10L)
// val iterator2 = external.RootTreeIterator[Tree2](List("../root2avro/test_Bacon/Output.root"), "Events", inferTypes = true, myclasses = myclasses, command = "../root2avro/build/root2avro", end = 10L)

while (iterator2.hasNext) {
val x = iterator2.next()
println(x.PV)
println(x.Photon)
}
// while (iterator2.hasNext) {
// val x = iterator2.next()
// println(x.PV)
// println(x.Photon)
// }

}
// }

}

0 comments on commit b20d857

Please sign in to comment.