Example #1
0
//_______________________________________________________________________
void ProcFileElements::Print(Option_t *) const
{
   // Print info about this processed file

   Printf("--- ProcFileElements ----------------------------------------");
   Printf(" File: %s", fName.Data());
   Printf(" # proc elements: %d", fElements ? fElements->GetSize() : 0);
   TIter nxe(fElements);
   ProcFileElements::ProcFileElement *e = 0;
   while ((e = (ProcFileElements::ProcFileElement *)nxe())) { e->Print(); }
   Printf(" Raw overall range: [%lld, %lld]", fFirst, fLast);
   Printf("-------------------------------------------------------------");
}
Example #2
0
//_______________________________________________________________________
Int_t ProcFileElements::Add(Long64_t fst, Long64_t lst)
{
   // Add a new element to the list 
   // Return 1 if a new element has been added, 0 if it has been merged
   // with an existing one, -1 in case of error

   if (!fElements) fElements = new TSortedList;
   if (!fElements) {
      Error("Add", "could not create internal list!");
      return -1;
   }
   
   // Create (tempoarry element)
   ProcFileElements::ProcFileElement *ne =
      new ProcFileElements::ProcFileElement(fst, lst);

   // Check if if it is adjacent or overalapping with an existing one
   TIter nxe(fElements);
   ProcFileElements::ProcFileElement *e = 0;
   while ((e = (ProcFileElements::ProcFileElement *)nxe())) {
      if (e->MergeElement(ne) == 0) break;
   }
   
   Int_t rc = 0;
   // Remove and re-add the merged element to sort correctly its possibly new position
   if (e) {
      fElements->Remove(e);
      fElements->Add(e);
      SafeDelete(ne);
   } else {
      // Add the new element
      fElements->Add(ne);
      rc = 1;
   }

   // New overall ranges
   if (fElements) {
      if ((e = (ProcFileElements::ProcFileElement *) fElements->First())) fFirst = e->fFirst;
      if ((e = (ProcFileElements::ProcFileElement *) fElements->Last())) fLast = e->fLast;
   }
   
   // Done
   return rc;
}
Example #3
0
//_______________________________________________________________________
Int_t ProcFileElements::Add(Long64_t fst, Long64_t lst)
{
   // Add a new element to the list
   // Return 1 if a new element has been added, 0 if it has been merged
   // with an existing one, -1 in case of error

   if (!fElements) fElements = new TSortedList;
   if (!fElements) {
      Error("Add", "could not create internal list!");
      return -1;
   }

   // Create (temporary element)
   ProcFileElements::ProcFileElement *ne =
      new ProcFileElements::ProcFileElement(fst, lst);

   // Check if if it is adjacent or overlapping with an existing one
   TIter nxe(fElements);
   ProcFileElements::ProcFileElement *e = 0;
   while ((e = (ProcFileElements::ProcFileElement *)nxe())) {
      if (e->MergeElement(ne) == 0) break;
   }

   Int_t rc = 0;
   // Remove and re-add the merged element to sort correctly its possibly new position
   if (e) {
      fElements->Remove(e);
      fElements->Add(e);
      SafeDelete(ne);
   } else {
      // Add the new element
      fElements->Add(ne);
      rc = 1;
   }

   // Make sure that all what can be merged is merged (because of the order, some elements
   // which could be merged are not merged, making the determination of fFirst and fLast below
   // to give incorrect values)

   ProcFileElements::ProcFileElement *ep = 0, *en = 0;
   TObjLink *olp = fElements->FirstLink(), *oln = 0;
   while (olp && (ep = (ProcFileElements::ProcFileElement *) olp->GetObject())) {
      oln = olp->Next();
      while (oln) {
         if ((en = (ProcFileElements::ProcFileElement *) oln->GetObject())) {
            if (ep->MergeElement(en) == 0) {
               fElements->Remove(en);
               delete en;
            }
         }
         oln = oln->Next();
      }
      olp = olp->Next();
   }

   // New overall ranges
   if ((e = (ProcFileElements::ProcFileElement *) fElements->First())) fFirst = e->fFirst;
   if ((e = (ProcFileElements::ProcFileElement *) fElements->Last())) fLast = e->fLast;

   // Done
   return rc;
}