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.43 by paus, Tue Mar 29 01:35:08 2011 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 82 | Line 98 | Bool_t Analysis::AddDataset(const Datase
98   {
99    // Add a full dataset to the analysis.
100  
101 <  Bool_t status = true;
101 >  Bool_t status = kTRUE;
102  
103    for (UInt_t i=0; i<dataset->NFiles(); ++i)
104 <    status = (status && AddFile(dataset->FileUrl(i)));
104 >    status = (status && AddFile((dataset->FileUrl(i)).Data()));
105  
106    return status;
107   }
# Line 101 | Line 117 | Bool_t Analysis::AddFile(const char *pna
117      return kFALSE;
118    }
119  
120 +  ////================================================================================================
121 +  //// Please do not ask me why I need to do this but I have to?! (CP - Oct02, 2010)
122 +  //char   fileName[4096];
123 +  //strcpy(fileName,pname);
124 +  ////================================================================================================
125 +
126    TString pnamestr(pname);
127 +
128    if (pnamestr.IsNull())
129      return kFALSE;
130  
# Line 158 | Line 181 | void Analysis::AddFile(const char *pname
181      return;
182    }
183    
184 <  if (!IsValidName(pname)) return;
184 >  if (! IsValidName(pname))
185 >    return;
186  
187 <  l->Add(new TObjString(pname));
187 >  TString theFile(pname);
188 >  if ( theFile.BeginsWith("castor:") )
189 >    theFile.ReplaceAll("castor:","root://castorcms/");
190 >  if ( theFile.BeginsWith("/castor/"))
191 >    theFile.Prepend("root://castorcms/");
192 >  printf("Adding file with path: %s\n",theFile.Data());
193 >  l->Add(new TObjString(theFile.Data()));
194  
195    MDB(kAnalysis, 2)
196      Info("AddFile", "Added %s to list of files.", pname);
# Line 188 | Line 218 | Bool_t Analysis::AddFiles(const char *pn
218    ifstream in;
219    in.open(pname);
220    if (!in) {
221 <    Error("AddFiles", "Can not open file with name %s", pname);
221 >    Error("AddFiles", "Cannot open file with name %s", pname);
222      return kFALSE;
223    }
224  
# Line 196 | Line 226 | Bool_t Analysis::AddFiles(const char *pn
226    while (in) {
227      TString line;
228      line.ReadLine(in);
199    cout << line << endl;
229      if (!line.EndsWith(".root"))
230        continue;
202    cout << line << endl;
231  
232      if (!AddFile(line)) {
233        Error("AddFiles", "Error adding file with name %s", line.Data());
# Line 273 | Line 301 | void Analysis::FileInputFromEnv()
301   {
302    // Attempt to get list of filesets/files from environment.
303  
304 <  TString catalog(gSystem->Getenv("MIT_CATALOG"));
305 <  TString book(gSystem->Getenv("MIT_BOOK"));
306 <  TString dataset(gSystem->Getenv("MIT_DATASET"));
304 >  TString catalog (gSystem->Getenv("MIT_CATALOG"));
305 >  TString book    (gSystem->Getenv("MIT_BOOK"));
306 >  TString dataset (gSystem->Getenv("MIT_DATASET"));
307    TString filesets(gSystem->Getenv("MIT_FILESETS"));
308 <  TString files(gSystem->Getenv("MIT_FILES"));
308 >  TString files   (gSystem->Getenv("MIT_FILES"));
309  
310    if ((catalog.IsNull() || book.IsNull() || dataset.IsNull()) && files.IsNull()) {
311        Warning("FileInputFromEnv", "Called to get file info from environment, but did not get"
# Line 287 | Line 315 | void Analysis::FileInputFromEnv()
315        return;
316    }
317  
290
318    if (!files.IsNull()) { // add local files
319      Info("FileInputFromEnv", "Got from environment:\n"
320           "\n\tMIT_FILES=%s\n", files.Data());
# Line 309 | Line 336 | void Analysis::FileInputFromEnv()
336         catalog.Data(), book.Data(), dataset.Data(), filesets.Data());
337  
338    Catalog cat(catalog);
339 <  TString tok(";");
340 <  TObjArray *arr = filesets.Tokenize(tok);
341 <  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;
339 >  if (filesets.IsNull()) {
340 >    Dataset *d = cat.FindDataset(book, dataset);
341 >    if (d) {
342        AddDataset(d);
343        delete d;
344      }
345 <    delete arr;
345 >  } else {
346 >    TString tok(";");
347 >    TObjArray *arr = filesets.Tokenize(tok);
348 >    if (arr) {
349 >      for (Int_t i=0; i<arr->GetEntries(); ++i) {
350 >        TObjString *fileset = dynamic_cast<TObjString*>(arr->At(i));
351 >        if (!fileset) continue;
352 >        Dataset *d = cat.FindDataset(book, dataset, fileset->String());
353 >        if (!d)
354 >          continue;
355 >        AddDataset(d);
356 >        delete d;
357 >      }
358 >      delete arr;
359 >    }
360    }
361   }
362  
# Line 365 | Line 400 | Bool_t Analysis::Init()
400    fSet   = new TDSet("TTree",fTreeName);
401  
402    for (Int_t i=0; i<fNFriends; ++i) {
368
403      TList *l = dynamic_cast<TList*>(fList->At(i));
404      if (!l) {
405        Fatal("Init", "List %d not found!", i);
# Line 377 | Line 411 | Bool_t Analysis::Init()
411        while (TObjString *obj = dynamic_cast<TObjString*>(next())) {
412          fChain->Add(obj->GetName());
413          fSet->Add(obj->GetName());
414 +        if (fCacheSize<0 && obj->GetString().Contains("/castor/"))
415 +          fCacheSize = 64*1024*1024;
416        }
381
417      } else {
383
418        TChain *chain = new TChain(fTreeName);
419        TDSet *set    = new TDSet("TTree",fTreeName);
420  
# Line 388 | Line 422 | Bool_t Analysis::Init()
422        while (TObjString *obj = dynamic_cast<TObjString*>(next())) {
423          chain->Add(obj->GetName());
424          set->Add(obj->GetName());
425 +        if (fCacheSize<0 && obj->GetString().Contains("/castor/"))
426 +          fCacheSize = 64*1024*1024;
427        }
428  
429        TString alias("TAMTREE_"); // aliases currently not used
# Line 399 | Line 435 | Bool_t Analysis::Init()
435        fDeleteList->Add(chain);
436        fDeleteList->Add(set);
437      }
402
438    }
439  
440 +  if (fParallel)
441 +    TTreeCacheUnzip::SetParallelUnzip(TTreeCacheUnzip::kEnable);
442 +
443 +  //if (fCacheSize>=0)
444 +  //  fChain->SetCacheSize(fCacheSize);    
445 +
446    // create our customized loader plugin for TAM
447    TreeLoader *bl = new TreeLoader;
448    fLoaders->Add(bl);
# Line 409 | Line 450 | Bool_t Analysis::Init()
450  
451    // create our ana framework module
452    AnaFwkMod *anamod = new AnaFwkMod;
453 +  anamod->SetSkipNEvents(fSkipNEvents);
454 +  anamod->SetPrintScale(fPrintScale);
455    fDeleteList->Add(anamod);
456  
457    // create our HLT framework module
458    HLTFwkMod *hltmod = 0;
459    if (fUseHLT) {
460      hltmod = new HLTFwkMod;
461 +    hltmod->SetHLTObjsName(GetHLTObjsName());
462 +    hltmod->SetHLTTreeName(GetHLTTreeName());
463      fDeleteList->Add(hltmod);
464    }
465  
# Line 437 | Line 482 | Bool_t Analysis::Init()
482    } else {
483  
484      // when not running Proof, we must make a selector
485 <    fSelector = new Selector;
486 <    fSelector->SetDoProxy(fDoProxy);
487 <
488 <    fSelector->AddInput(anamod);
485 >    Selector *sel = new Selector;
486 >    sel->SetCacheSize(fCacheSize);  
487 >    sel->SetDoProxy(fDoProxy);
488 >    sel->SetDoObjTabClean(fDoObjTabClean);
489 >    sel->SetDoRunInfo(kTRUE);
490 >    sel->SetAllEvtHdrBrn(GetAllEvtHdrBrn());
491 >    sel->SetAllEvtTreeName(GetAllEvtTreeName());
492 >    sel->SetEvtHdrName(GetEvtHdrName());
493 >    sel->SetLAHdrName(GetLAHdrName());
494 >    sel->SetLATreeName(GetLATreeName());
495 >    sel->SetRunInfoName(GetRunInfoName());
496 >    sel->SetRunTreeName(GetRunTreeName());
497 >    sel->AddInput(anamod);
498 >    fSelector = sel;
499  
500      if (hltmod)
501        fSelector->AddInput(hltmod);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines