2020#include " FWCore/Utilities/interface/TimeOfDay.h"
2121#include " FWCore/Utilities/interface/WrappedClassName.h"
2222
23- #include " TTree.h"
2423#include " TBranchElement.h"
2524#include " TObjArray.h"
2625#include " RVersion.h"
@@ -122,38 +121,6 @@ namespace edm::rntuple_temp {
122121 int basketSize)
123122 : productDescription_(bd), token_(token), product_(nullptr ), splitLevel_(splitLevel), basketSize_(basketSize) {}
124123
125- RNTupleTempOutputModule::OutputItem::Sorter::Sorter (TTree* tree) : treeMap_(new std::map<std::string, int >) {
126- // Fill a map mapping branch names to an index specifying the order in the tree.
127- if (tree != nullptr ) {
128- TObjArray* branches = tree->GetListOfBranches ();
129- for (int i = 0 ; i < branches->GetEntries (); ++i) {
130- TBranchElement* br = (TBranchElement*)branches->At (i);
131- treeMap_->insert (std::make_pair (std::string (br->GetName ()), i));
132- }
133- }
134- }
135-
136- bool RNTupleTempOutputModule::OutputItem::Sorter::operator ()(OutputItem const & lh, OutputItem const & rh) const {
137- // Provides a comparison for sorting branches according to the index values in treeMap_.
138- // Branches not found are always put at the end (i.e. not found > found).
139- if (treeMap_->empty ())
140- return lh < rh;
141- std::string const & lstring = lh.productDescription_ ->branchName ();
142- std::string const & rstring = rh.productDescription_ ->branchName ();
143- std::map<std::string, int >::const_iterator lit = treeMap_->find (lstring);
144- std::map<std::string, int >::const_iterator rit = treeMap_->find (rstring);
145- bool lfound = (lit != treeMap_->end ());
146- bool rfound = (rit != treeMap_->end ());
147- if (lfound && rfound) {
148- return lit->second < rit->second ;
149- } else if (lfound) {
150- return true ;
151- } else if (rfound) {
152- return false ;
153- }
154- return lh < rh;
155- }
156-
157124 namespace {
158125 std::regex convertBranchExpression (std::string const & iGlobBranchExpression) {
159126 std::string tmp (iGlobBranchExpression);
@@ -182,28 +149,9 @@ namespace edm::rntuple_temp {
182149
183150 void RNTupleTempOutputModule::fillSelectedItemList (BranchType branchType,
184151 std::string const & processName,
185- TTree* theInputTree,
186152 OutputItemList& outputItemList) {
187153 SelectedProducts const & keptVector = keptProducts ()[branchType];
188154
189- if (branchType != InProcess) {
190- AuxItem& auxItem = auxItems_[branchType];
191-
192- auto basketSize = (InEvent == branchType) ? eventAuxBasketSize_ : basketSize_;
193-
194- // Fill AuxItem
195- if (theInputTree != nullptr && !overrideInputFileSplitLevels_) {
196- TBranch* auxBranch = theInputTree->GetBranch (BranchTypeToAuxiliaryBranchName (branchType).c_str ());
197- if (auxBranch) {
198- auxItem.basketSize_ = auxBranch->GetBasketSize ();
199- } else {
200- auxItem.basketSize_ = basketSize;
201- }
202- } else {
203- auxItem.basketSize_ = basketSize;
204- }
205- }
206-
207155 // Fill outputItemList with an entry for each branch.
208156 for (auto const & kept : keptVector) {
209157 int splitLevel = ProductDescription::invalidSplitLevel;
@@ -213,46 +161,8 @@ namespace edm::rntuple_temp {
213161 if (branchType == InProcess && processName != prod.processName ()) {
214162 continue ;
215163 }
216- TBranch* theBranch = ((!prod.produced () && theInputTree != nullptr && !overrideInputFileSplitLevels_)
217- ? theInputTree->GetBranch (prod.branchName ().c_str ())
218- : nullptr );
219-
220- if (theBranch != nullptr ) {
221- splitLevel = theBranch->GetSplitLevel ();
222- basketSize = theBranch->GetBasketSize ();
223- } else {
224- auto wp = prod.wrappedType ().getClass ()->GetAttributeMap ();
225- auto wpSplitLevel = ProductDescription::invalidSplitLevel;
226- if (wp && wp->HasKey (" splitLevel" )) {
227- wpSplitLevel = strtol (wp->GetPropertyAsString (" splitLevel" ), nullptr , 0 );
228- if (wpSplitLevel < 0 ) {
229- throw cms::Exception (" IllegalSplitLevel" ) << " ' An illegal ROOT split level of " << wpSplitLevel
230- << " is specified for class " << prod.wrappedName () << " .'\n " ;
231- }
232- wpSplitLevel += 1 ; // Compensate for wrapper
233- }
234- splitLevel = (wpSplitLevel == ProductDescription::invalidSplitLevel ? splitLevel_ : wpSplitLevel);
235- for (auto const & b : specialSplitLevelForBranches_) {
236- if (b.match (prod.branchName ())) {
237- splitLevel = b.splitLevel_ ;
238- }
239- }
240- auto wpBasketSize = ProductDescription::invalidBasketSize;
241- if (wp && wp->HasKey (" basketSize" )) {
242- wpBasketSize = strtol (wp->GetPropertyAsString (" basketSize" ), nullptr , 0 );
243- if (wpBasketSize <= 0 ) {
244- throw cms::Exception (" IllegalBasketSize" ) << " ' An illegal ROOT basket size of " << wpBasketSize
245- << " is specified for class " << prod.wrappedName () << " '.\n " ;
246- }
247- }
248- basketSize = (wpBasketSize == ProductDescription::invalidBasketSize ? basketSize_ : wpBasketSize);
249- }
250164 outputItemList.emplace_back (&prod, kept.second , splitLevel, basketSize);
251165 }
252-
253- // Sort outputItemList to allow fast copying.
254- // The branches in outputItemList must be in the same order as in the input tree, with all new branches at the end.
255- sort_all (outputItemList, OutputItem::Sorter (theInputTree));
256166 }
257167
258168 void RNTupleTempOutputModule::beginInputFile (FileBlock const & fb) {
@@ -281,24 +191,21 @@ namespace edm::rntuple_temp {
281191 std::vector<std::string> const & processesWithProcessBlockProducts =
282192 outputProcessBlockHelper ().processesWithProcessBlockProducts ();
283193 unsigned int numberOfProcessesWithProcessBlockProducts = processesWithProcessBlockProducts.size ();
284- unsigned int numberOfTTrees = numberOfRunLumiEventProductTrees + numberOfProcessesWithProcessBlockProducts;
285- selectedOutputItemList_.resize (numberOfTTrees );
194+ unsigned int numberOfTRNTuples = numberOfRunLumiEventProductTrees + numberOfProcessesWithProcessBlockProducts;
195+ selectedOutputItemList_.resize (numberOfTRNTuples );
286196
287197 for (unsigned int i = InEvent; i < NumBranchTypes; ++i) {
288198 BranchType branchType = static_cast <BranchType>(i);
289199 if (branchType != InProcess) {
290200 std::string processName;
291- TTree* theInputTree =
292- (branchType == InEvent ? fb.tree () : (branchType == InLumi ? fb.lumiTree () : fb.runTree ()));
293201 OutputItemList& outputItemList = selectedOutputItemList_[branchType];
294- fillSelectedItemList (branchType, processName, theInputTree, outputItemList);
202+ fillSelectedItemList (branchType, processName, outputItemList);
295203 } else {
296204 // Handle output items in ProcessBlocks
297- for (unsigned int k = InProcess; k < numberOfTTrees ; ++k) {
205+ for (unsigned int k = InProcess; k < numberOfTRNTuples ; ++k) {
298206 OutputItemList& outputItemList = selectedOutputItemList_[k];
299207 std::string const & processName = processesWithProcessBlockProducts[k - InProcess];
300- TTree* theInputTree = fb.processBlockTree (processName);
301- fillSelectedItemList (branchType, processName, theInputTree, outputItemList);
208+ fillSelectedItemList (branchType, processName, outputItemList);
302209 }
303210 }
304211 }
@@ -345,7 +252,6 @@ namespace edm::rntuple_temp {
345252 }
346253
347254 void RNTupleTempOutputModule::reallyCloseFile () {
348- writeEventAuxiliary ();
349255 fillDependencyGraph ();
350256 branchParents_.clear ();
351257 startEndFile ();
@@ -366,7 +272,6 @@ namespace edm::rntuple_temp {
366272
367273 void RNTupleTempOutputModule::writeParameterSetRegistry () { rootOutputFile_->writeParameterSetRegistry (); }
368274 void RNTupleTempOutputModule::writeParentageRegistry () { rootOutputFile_->writeParentageRegistry (); }
369- void RNTupleTempOutputModule::writeEventAuxiliary () { rootOutputFile_->writeEventAuxiliary (); }
370275 void RNTupleTempOutputModule::finishEndFile () {
371276 rootOutputFile_->finishEndFile ();
372277 rootOutputFile_ = nullptr ;
@@ -490,19 +395,13 @@ namespace edm::rntuple_temp {
490395 desc.addUntracked <int >(" basketSize" , 16384 )->setComment (" Default ROOT basket size in output file." );
491396 desc.addUntracked <int >(" eventAuxiliaryBasketSize" , 16384 )
492397 ->setComment (" Default ROOT basket size in output file for EventAuxiliary branch." );
493- desc.addUntracked <int >(" eventAutoFlushCompressedSize" , 20 * 1024 * 1024 )
494- ->setComment (
495- " Set ROOT auto flush stored data size (in bytes) for event TTree. The value sets how large the compressed "
496- " buffer is allowed to get. The uncompressed buffer can be quite a bit larger than this depending on the "
497- " average compression ratio. The value of -1 just uses ROOT's default value. The value of 0 turns off this "
498- " feature. A value of -N changes the behavior to flush after every Nth event." );
398+ desc.addUntracked <int >(" eventAutoFlushCompressedSize" , 20 * 1024 * 1024 )->setComment (" Not used by RNTuple" );
499399 desc.addUntracked <int >(" splitLevel" , 99 )->setComment (" Default ROOT branch split level in output file." );
500400 desc.addUntracked <std::string>(" sortBaskets" , std::string (" sortbasketsbyoffset" ))
501401 ->setComment (
502402 " Legal values: 'sortbasketsbyoffset', 'sortbasketsbybranch', 'sortbasketsbyentry'.\n "
503403 " Used by ROOT when fast copying. Affects performance." );
504- desc.addUntracked <int >(" treeMaxVirtualSize" , -1 )
505- ->setComment (" Size of ROOT TTree TBasket cache. Affects performance." );
404+ desc.addUntracked <int >(" treeMaxVirtualSize" , -1 )->setComment (" Not used by RNTuple." );
506405 desc.addUntracked <bool >(" fastCloning" , false )->setComment (" Not used by RNTuple" );
507406 desc.addUntracked (" mergeJob" , false )
508407 ->setComment (
0 commit comments