ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitAna/TreeMod/src/Analysis.cc
(Generate patch)

Comparing UserCode/MitAna/TreeMod/src/Analysis.cc (file contents):
Revision 1.22 by loizides, Thu Dec 11 15:29:09 2008 UTC vs.
Revision 1.38 by bendavid, Sun Jan 24 21:00:19 2010 UTC

# Line 1 | Line 1
1   // $Id$
2  
3   #include "MitAna/TreeMod/interface/Analysis.h"
4 + #include <memory>
5   #include <Riostream.h>
6   #include <TFile.h>
7   #include <TList.h>
# Line 11 | Line 12
12   #include <TProof.h>
13   #include <TROOT.h>
14   #include <TBrowser.h>
15 + #include <TTreeCacheUnzip.h>
16   #include "MitAna/DataUtil/interface/Debug.h"
17   #include "MitAna/DataTree/interface/Names.h"
18   #include "MitAna/TAM/interface/TAMVirtualLoader.h"
# Line 31 | Line 33 | Analysis::Analysis(Bool_t useproof) :
33    fUseProof(useproof),
34    fUseHLT(kTRUE),
35    fHierarchy(kTRUE),
36 <  fDoProxy(kTRUE),
36 >  fDoProxy(kFALSE),
37 >  fDoObjTabClean(kTRUE),
38 >  fParallel(kFALSE),
39    fState(kPristine),
40    fNFriends(0),
41    fList(new TList),
# Line 43 | Line 47 | Analysis::Analysis(Bool_t useproof) :
47    fChain(0),
48    fSet(0),
49    fDeleteList(new TList),
50 <  fTreeName(Names::gkEvtTreeName),
47 <  fCompLevel(2),
50 >  fCompLevel(7),
51    fProof(0),
52 <  fDoNEvents(TChain::kBigNumber)
52 >  fDoNEvents(TChain::kBigNumber),
53 >  fSkipNEvents(0),
54 >  fPrintScale(1),
55 >  fCacheSize(-1),
56 >  fTreeName(Names::gkEvtTreeName),
57 >  fEvtHdrName(Names::gkEvtHeaderBrn),
58 >  fRunTreeName(Names::gkRunTreeName),
59 >  fRunInfoName(Names::gkRunInfoBrn),
60 >  fAllEvtHdrBrn(Names::gkAllEvtHeaderBrn),
61 >  fLATreeName(Names::gkLATreeName),
62 >  fLAHdrName(Names::gkLAHeaderBrn),
63 >  fHLTTreeName(Names::gkHltTreeName),
64 >  fAllEvtTreeName(Names::gkAllEvtTreeName),
65 >  fHLTObjsName(Names::gkHltObjBrn)
66   {
67    // Default constructor.
68  
# Line 72 | Line 88 | Analysis::~Analysis()
88    delete fDeleteList;
89    delete fSelector;
90    delete fSuperMods;
91 <  fOutput    = 0;   // owned by TAM
91 >  fOutput = 0;   // owned by TAM
92  
93    delete fProof;
94   }
# Line 188 | Line 204 | Bool_t Analysis::AddFiles(const char *pn
204    ifstream in;
205    in.open(pname);
206    if (!in) {
207 <    Error("AddFiles", "Can not open file with name %s", pname);
207 >    Error("AddFiles", "Cannot open file with name %s", pname);
208      return kFALSE;
209    }
210  
# Line 196 | Line 212 | Bool_t Analysis::AddFiles(const char *pn
212    while (in) {
213      TString line;
214      line.ReadLine(in);
199    cout << line << endl;
215      if (!line.EndsWith(".root"))
216        continue;
202    cout << line << endl;
217  
218      if (!AddFile(line)) {
219        Error("AddFiles", "Error adding file with name %s", line.Data());
# Line 281 | Line 295 | void Analysis::FileInputFromEnv()
295  
296    if ((catalog.IsNull() || book.IsNull() || dataset.IsNull()) && files.IsNull()) {
297        Warning("FileInputFromEnv", "Called to get file info from environment, but did not get"
298 <              " consistent set of variables:\n\tMIT_CATALOG=%s\n\tMIT_BOOK=%s,\n\t"
298 >              " consistent set of variables:\n\tMIT_CATALOG=%s\n\tMIT_BOOK=%s\n\t"
299                "MIT_DATASET=%s\n\tMIT_FILESETS=%s\n\tMIT_FILES=%s\n",
300                catalog.Data(), book.Data(), dataset.Data(), filesets.Data(), files.Data());
301        return;
302    }
303  
290
304    if (!files.IsNull()) { // add local files
305      Info("FileInputFromEnv", "Got from environment:\n"
306           "\n\tMIT_FILES=%s\n", files.Data());
# Line 305 | Line 318 | void Analysis::FileInputFromEnv()
318    }
319  
320    Info("FileInputFromEnv", "Got from environment:\n"
321 <       "\tMIT_CATALOG=%s\n\tMIT_BOOK=%s,\n\tMIT_DATASET=%s\n\tMIT_FILESETS=%s\n",
321 >       "\tMIT_CATALOG=%s\n\tMIT_BOOK=%s\n\tMIT_DATASET=%s\n\tMIT_FILESETS=%s\n",
322         catalog.Data(), book.Data(), dataset.Data(), filesets.Data());
323  
324    Catalog cat(catalog);
325 <  TString tok(";");
326 <  TObjArray *arr = filesets.Tokenize(tok);
327 <  if (arr) {
315 <    for (Int_t i=0; i<arr->GetEntries(); ++i) {
316 <      TObjString *fileset = dynamic_cast<TObjString*>(arr->At(i));
317 <      if (!fileset) continue;
318 <      Dataset *d = cat.FindDataset(book, dataset, fileset->String());
319 <      if (!d)
320 <        continue;
325 >  if (filesets.IsNull()) {
326 >    Dataset *d = cat.FindDataset(book, dataset);
327 >    if (d) {
328        AddDataset(d);
329        delete d;
330      }
331 <    delete arr;
331 >  } else {
332 >    TString tok(";");
333 >    TObjArray *arr = filesets.Tokenize(tok);
334 >    if (arr) {
335 >      for (Int_t i=0; i<arr->GetEntries(); ++i) {
336 >        TObjString *fileset = dynamic_cast<TObjString*>(arr->At(i));
337 >        if (!fileset) continue;
338 >        Dataset *d = cat.FindDataset(book, dataset, fileset->String());
339 >        if (!d)
340 >          continue;
341 >        AddDataset(d);
342 >        delete d;
343 >      }
344 >      delete arr;
345 >    }
346    }
347   }
348  
# Line 365 | Line 386 | Bool_t Analysis::Init()
386    fSet   = new TDSet("TTree",fTreeName);
387  
388    for (Int_t i=0; i<fNFriends; ++i) {
368
389      TList *l = dynamic_cast<TList*>(fList->At(i));
390      if (!l) {
391        Fatal("Init", "List %d not found!", i);
# Line 377 | Line 397 | Bool_t Analysis::Init()
397        while (TObjString *obj = dynamic_cast<TObjString*>(next())) {
398          fChain->Add(obj->GetName());
399          fSet->Add(obj->GetName());
400 +        if (fCacheSize<0 && obj->GetString().Contains("/castor/"))
401 +          fCacheSize = 64*1024*1024;
402        }
381
403      } else {
383
404        TChain *chain = new TChain(fTreeName);
405        TDSet *set    = new TDSet("TTree",fTreeName);
406  
# Line 388 | Line 408 | Bool_t Analysis::Init()
408        while (TObjString *obj = dynamic_cast<TObjString*>(next())) {
409          chain->Add(obj->GetName());
410          set->Add(obj->GetName());
411 +        if (fCacheSize<0 && obj->GetString().Contains("/castor/"))
412 +          fCacheSize = 64*1024*1024;
413        }
414  
415        TString alias("TAMTREE_"); // aliases currently not used
# Line 399 | Line 421 | Bool_t Analysis::Init()
421        fDeleteList->Add(chain);
422        fDeleteList->Add(set);
423      }
402
424    }
425  
426 +  if (fParallel)
427 +    TTreeCacheUnzip::SetParallelUnzip(TTreeCacheUnzip::kEnable);
428 +
429 +  if (fCacheSize>=0)
430 +    fChain->SetCacheSize(fCacheSize);
431 +
432    // create our customized loader plugin for TAM
433    TreeLoader *bl = new TreeLoader;
434    fLoaders->Add(bl);
# Line 409 | Line 436 | Bool_t Analysis::Init()
436  
437    // create our ana framework module
438    AnaFwkMod *anamod = new AnaFwkMod;
439 +  anamod->SetSkipNEvents(fSkipNEvents);
440 +  anamod->SetPrintScale(fPrintScale);
441    fDeleteList->Add(anamod);
442  
443    // create our HLT framework module
444    HLTFwkMod *hltmod = 0;
445    if (fUseHLT) {
446      hltmod = new HLTFwkMod;
447 +    hltmod->SetHLTObjsName(GetHLTObjsName());
448 +    hltmod->SetHLTTreeName(GetHLTTreeName());
449      fDeleteList->Add(hltmod);
450    }
451  
# Line 437 | Line 468 | Bool_t Analysis::Init()
468    } else {
469  
470      // when not running Proof, we must make a selector
471 <    fSelector = new Selector;
472 <    fSelector->SetDoProxy(fDoProxy);
473 <
474 <    fSelector->AddInput(anamod);
471 >    Selector *sel = new Selector;
472 >    sel->SetDoProxy(fDoProxy);
473 >    sel->SetDoObjTabClean(fDoObjTabClean);
474 >    sel->SetDoRunInfo(kTRUE);
475 >    sel->SetAllEvtHdrBrn(GetAllEvtHdrBrn());
476 >    sel->SetAllEvtTreeName(GetAllEvtTreeName());
477 >    sel->SetEvtHdrName(GetEvtHdrName());
478 >    sel->SetLAHdrName(GetLAHdrName());
479 >    sel->SetLATreeName(GetLATreeName());
480 >    sel->SetRunInfoName(GetRunInfoName());
481 >    sel->SetRunTreeName(GetRunTreeName());
482 >    sel->AddInput(anamod);
483 >    fSelector = sel;
484  
485      if (hltmod)
486        fSelector->AddInput(hltmod);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines