//_______________________________________________________________________ Int_t ProcFileElements::Merge(TCollection *li) { // Merge this object with those in the list // Return number of elements added if (!li) return -1; if (li->GetSize() <= 0) return 0; Int_t nadd = 0; TIter nxo(li); ProcFileElements *pfe = 0; while ((pfe = (ProcFileElements *) nxo())) { if (strcmp(GetName(), pfe->GetName())) Warning("Merge", "merging objects of different name! ('%s' != '%s')", GetName(), pfe->GetName()); TIter nxe(pfe->GetListOfElements()); ProcFileElements::ProcFileElement *e = 0; while ((e = (ProcFileElements::ProcFileElement *)nxe())) { Int_t rc = Add(e->fFirst, e->fLast); if (rc == 1) nadd++; } } // Done return nadd; }
//_______________________________________________________________________ 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("-------------------------------------------------------------"); }
//_____________________________________________________________________________ Bool_t ProofSimple::Process(Long64_t entry) { // The Process() function is called for each entry in the tree (or possibly // keyed object in the case of PROOF) to be processed. The entry argument // specifies which entry in the currently loaded tree is to be processed. // It can be passed to either ProofSimple::GetEntry() or TBranch::GetEntry() // to read either all or the required parts of the data. When processing // keyed objects with PROOF, the object is already loaded and is available // via the fObject pointer. // // This function should contain the "body" of the analysis. It can contain // simple or elaborate selection criteria, run algorithms on the data // of the event and typically fill histograms. // // The processing can be stopped by calling Abort(). // // Use fStatus to set the return value of TTree::Process(). // // The return value is currently not used. for (Int_t i=0; i < fNhist; i++) { if (fRandom && fHist[i]) { Double_t x = fRandom->Gaus(0.,1.); fHist[i]->Fill(x); } } for (Int_t i=0; i < fNhist3; i++) { if (fRandom && fHist3[i]) { Double_t x = fRandom->Gaus(0.,1.); fHist3[i]->Fill(x,x,x); } } if (fHLab && fRandom) { TSortedList sortl; Float_t rr[10]; fRandom->RndmArray(10, rr); for (Int_t i=0; i < 10; i++) { sortl.Add(new TParameter<Int_t>(TString::Format("%f",rr[i]), i)); } TIter nxe(&sortl); TParameter<Int_t> *pi = 0; while ((pi = (TParameter<Int_t> *) nxe())) { fHLab->Fill(TString::Format("hl%d", pi->GetVal()), pi->GetVal()); } } if (fNtp) FillNtuple(entry); return kTRUE; }
//_______________________________________________________________________ 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; }
//_______________________________________________________________________ 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; }