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.23 by loizides, Thu Dec 11 15:53:26 2008 UTC vs.
Revision 1.40 by bendavid, Mon May 10 16:16:39 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 160 | Line 176 | void Analysis::AddFile(const char *pname
176    
177    if (!IsValidName(pname)) return;
178  
179 <  l->Add(new TObjString(pname));
179 >  TString theFile(pname);
180 >  if ( theFile.BeginsWith("castor:") )
181 >    theFile.ReplaceAll("castor:","root://castorcms/");
182 >  if ( theFile.BeginsWith("/castor/"))
183 >    theFile.Prepend("root://castorcms/");
184 >  printf("Adding file with path: %s\n",theFile.Data());
185 >  l->Add(new TObjString(theFile));
186  
187    MDB(kAnalysis, 2)
188      Info("AddFile", "Added %s to list of files.", pname);
# Line 188 | Line 210 | Bool_t Analysis::AddFiles(const char *pn
210    ifstream in;
211    in.open(pname);
212    if (!in) {
213 <    Error("AddFiles", "Can not open file with name %s", pname);
213 >    Error("AddFiles", "Cannot open file with name %s", pname);
214      return kFALSE;
215    }
216  
# Line 196 | Line 218 | Bool_t Analysis::AddFiles(const char *pn
218    while (in) {
219      TString line;
220      line.ReadLine(in);
199    cout << line << endl;
221      if (!line.EndsWith(".root"))
222        continue;
202    cout << line << endl;
223  
224      if (!AddFile(line)) {
225        Error("AddFiles", "Error adding file with name %s", line.Data());
# Line 287 | Line 307 | void Analysis::FileInputFromEnv()
307        return;
308    }
309  
290
310    if (!files.IsNull()) { // add local files
311      Info("FileInputFromEnv", "Got from environment:\n"
312           "\n\tMIT_FILES=%s\n", files.Data());
# Line 309 | Line 328 | void Analysis::FileInputFromEnv()
328         catalog.Data(), book.Data(), dataset.Data(), filesets.Data());
329  
330    Catalog cat(catalog);
331 <  TString tok(";");
332 <  TObjArray *arr = filesets.Tokenize(tok);
333 <  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;
331 >  if (filesets.IsNull()) {
332 >    Dataset *d = cat.FindDataset(book, dataset);
333 >    if (d) {
334        AddDataset(d);
335        delete d;
336      }
337 <    delete arr;
337 >  } else {
338 >    TString tok(";");
339 >    TObjArray *arr = filesets.Tokenize(tok);
340 >    if (arr) {
341 >      for (Int_t i=0; i<arr->GetEntries(); ++i) {
342 >        TObjString *fileset = dynamic_cast<TObjString*>(arr->At(i));
343 >        if (!fileset) continue;
344 >        Dataset *d = cat.FindDataset(book, dataset, fileset->String());
345 >        if (!d)
346 >          continue;
347 >        AddDataset(d);
348 >        delete d;
349 >      }
350 >      delete arr;
351 >    }
352    }
353   }
354  
# Line 365 | Line 392 | Bool_t Analysis::Init()
392    fSet   = new TDSet("TTree",fTreeName);
393  
394    for (Int_t i=0; i<fNFriends; ++i) {
368
395      TList *l = dynamic_cast<TList*>(fList->At(i));
396      if (!l) {
397        Fatal("Init", "List %d not found!", i);
# Line 377 | Line 403 | Bool_t Analysis::Init()
403        while (TObjString *obj = dynamic_cast<TObjString*>(next())) {
404          fChain->Add(obj->GetName());
405          fSet->Add(obj->GetName());
406 +        if (fCacheSize<0 && obj->GetString().Contains("/castor/"))
407 +          fCacheSize = 64*1024*1024;
408        }
381
409      } else {
383
410        TChain *chain = new TChain(fTreeName);
411        TDSet *set    = new TDSet("TTree",fTreeName);
412  
# Line 388 | Line 414 | Bool_t Analysis::Init()
414        while (TObjString *obj = dynamic_cast<TObjString*>(next())) {
415          chain->Add(obj->GetName());
416          set->Add(obj->GetName());
417 +        if (fCacheSize<0 && obj->GetString().Contains("/castor/"))
418 +          fCacheSize = 64*1024*1024;
419        }
420  
421        TString alias("TAMTREE_"); // aliases currently not used
# Line 399 | Line 427 | Bool_t Analysis::Init()
427        fDeleteList->Add(chain);
428        fDeleteList->Add(set);
429      }
402
430    }
431  
432 +  if (fParallel)
433 +    TTreeCacheUnzip::SetParallelUnzip(TTreeCacheUnzip::kEnable);
434 +
435 +  if (fCacheSize>=0)
436 +    fChain->SetCacheSize(fCacheSize);
437 +
438    // create our customized loader plugin for TAM
439    TreeLoader *bl = new TreeLoader;
440    fLoaders->Add(bl);
# Line 409 | Line 442 | Bool_t Analysis::Init()
442  
443    // create our ana framework module
444    AnaFwkMod *anamod = new AnaFwkMod;
445 +  anamod->SetSkipNEvents(fSkipNEvents);
446 +  anamod->SetPrintScale(fPrintScale);
447    fDeleteList->Add(anamod);
448  
449    // create our HLT framework module
450    HLTFwkMod *hltmod = 0;
451    if (fUseHLT) {
452      hltmod = new HLTFwkMod;
453 +    hltmod->SetHLTObjsName(GetHLTObjsName());
454 +    hltmod->SetHLTTreeName(GetHLTTreeName());
455      fDeleteList->Add(hltmod);
456    }
457  
# Line 437 | Line 474 | Bool_t Analysis::Init()
474    } else {
475  
476      // when not running Proof, we must make a selector
477 <    fSelector = new Selector;
478 <    fSelector->SetDoProxy(fDoProxy);
479 <
480 <    fSelector->AddInput(anamod);
477 >    Selector *sel = new Selector;
478 >    sel->SetDoProxy(fDoProxy);
479 >    sel->SetDoObjTabClean(fDoObjTabClean);
480 >    sel->SetDoRunInfo(kTRUE);
481 >    sel->SetAllEvtHdrBrn(GetAllEvtHdrBrn());
482 >    sel->SetAllEvtTreeName(GetAllEvtTreeName());
483 >    sel->SetEvtHdrName(GetEvtHdrName());
484 >    sel->SetLAHdrName(GetLAHdrName());
485 >    sel->SetLATreeName(GetLATreeName());
486 >    sel->SetRunInfoName(GetRunInfoName());
487 >    sel->SetRunTreeName(GetRunTreeName());
488 >    sel->AddInput(anamod);
489 >    fSelector = sel;
490  
491      if (hltmod)
492        fSelector->AddInput(hltmod);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines