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.27 by loizides, Mon Mar 2 12:35:29 2009 UTC vs.
Revision 1.45 by ceballos, Sat Sep 29 11:26:40 2012 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 33 | Line 35 | Analysis::Analysis(Bool_t useproof) :
35    fHierarchy(kTRUE),
36    fDoProxy(kFALSE),
37    fDoObjTabClean(kTRUE),
38 +  fParallel(kFALSE),
39    fState(kPristine),
40    fNFriends(0),
41    fList(new TList),
# Line 44 | Line 47 | Analysis::Analysis(Bool_t useproof) :
47    fChain(0),
48    fSet(0),
49    fDeleteList(new TList),
50 <  fTreeName(Names::gkEvtTreeName),
48 <  fCompLevel(2),
50 >  fCompLevel(7),
51    fProof(0),
52    fDoNEvents(TChain::kBigNumber),
53 <  fCacheSize(134217728)
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 74 | 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 84 | 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 103 | 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 160 | 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:","rfio:");
190 >  //if ( theFile.BeginsWith("/castor/"))
191 >  //  theFile.ReplaceAll("/castor/","rfio:/castor/");
192 >  if ( theFile.BeginsWith("castor:") )
193 >    theFile.ReplaceAll("castor:","root://castorcms/");
194 >  if ( theFile.BeginsWith("/castor/"))
195 >    theFile.Prepend("root://castorcms/");
196 >  printf("Adding file with path: %s\n",theFile.Data());
197 >  l->Add(new TObjString(theFile.Data()));
198  
199    MDB(kAnalysis, 2)
200      Info("AddFile", "Added %s to list of files.", pname);
# Line 190 | Line 222 | Bool_t Analysis::AddFiles(const char *pn
222    ifstream in;
223    in.open(pname);
224    if (!in) {
225 <    Error("AddFiles", "Can not open file with name %s", pname);
225 >    Error("AddFiles", "Cannot open file with name %s", pname);
226      return kFALSE;
227    }
228  
# Line 198 | Line 230 | Bool_t Analysis::AddFiles(const char *pn
230    while (in) {
231      TString line;
232      line.ReadLine(in);
201    cout << line << endl;
233      if (!line.EndsWith(".root"))
234        continue;
204    cout << line << endl;
235  
236      if (!AddFile(line)) {
237        Error("AddFiles", "Error adding file with name %s", line.Data());
# Line 275 | Line 305 | void Analysis::FileInputFromEnv()
305   {
306    // Attempt to get list of filesets/files from environment.
307  
308 <  TString catalog(gSystem->Getenv("MIT_CATALOG"));
309 <  TString book(gSystem->Getenv("MIT_BOOK"));
310 <  TString dataset(gSystem->Getenv("MIT_DATASET"));
308 >  TString catalog (gSystem->Getenv("MIT_CATALOG"));
309 >  TString book    (gSystem->Getenv("MIT_BOOK"));
310 >  TString dataset (gSystem->Getenv("MIT_DATASET"));
311    TString filesets(gSystem->Getenv("MIT_FILESETS"));
312 <  TString files(gSystem->Getenv("MIT_FILES"));
312 >  TString files   (gSystem->Getenv("MIT_FILES"));
313  
314    if ((catalog.IsNull() || book.IsNull() || dataset.IsNull()) && files.IsNull()) {
315        Warning("FileInputFromEnv", "Called to get file info from environment, but did not get"
# Line 372 | Line 402 | Bool_t Analysis::Init()
402  
403    fChain = new TChain(fTreeName);
404    fSet   = new TDSet("TTree",fTreeName);
375  
376  fChain->SetCacheSize(fCacheSize);
405  
406    for (Int_t i=0; i<fNFriends; ++i) {
379
407      TList *l = dynamic_cast<TList*>(fList->At(i));
408      if (!l) {
409        Fatal("Init", "List %d not found!", i);
# Line 388 | Line 415 | Bool_t Analysis::Init()
415        while (TObjString *obj = dynamic_cast<TObjString*>(next())) {
416          fChain->Add(obj->GetName());
417          fSet->Add(obj->GetName());
418 +        if (fCacheSize<0 && obj->GetString().Contains("/castor/"))
419 +          fCacheSize = 64*1024*1024;
420        }
392
421      } else {
394
422        TChain *chain = new TChain(fTreeName);
423        TDSet *set    = new TDSet("TTree",fTreeName);
424  
# Line 399 | Line 426 | Bool_t Analysis::Init()
426        while (TObjString *obj = dynamic_cast<TObjString*>(next())) {
427          chain->Add(obj->GetName());
428          set->Add(obj->GetName());
429 +        if (fCacheSize<0 && obj->GetString().Contains("/castor/"))
430 +          fCacheSize = 64*1024*1024;
431        }
432  
433        TString alias("TAMTREE_"); // aliases currently not used
# Line 410 | Line 439 | Bool_t Analysis::Init()
439        fDeleteList->Add(chain);
440        fDeleteList->Add(set);
441      }
413
442    }
443  
444 +  if (fParallel)
445 +    TTreeCacheUnzip::SetParallelUnzip(TTreeCacheUnzip::kEnable);
446 +
447 +  //if (fCacheSize>=0)
448 +  //  fChain->SetCacheSize(fCacheSize);    
449 +
450    // create our customized loader plugin for TAM
451    TreeLoader *bl = new TreeLoader;
452    fLoaders->Add(bl);
# Line 420 | Line 454 | Bool_t Analysis::Init()
454  
455    // create our ana framework module
456    AnaFwkMod *anamod = new AnaFwkMod;
457 +  anamod->SetSkipNEvents(fSkipNEvents);
458 +  anamod->SetPrintScale(fPrintScale);
459    fDeleteList->Add(anamod);
460  
461    // create our HLT framework module
462    HLTFwkMod *hltmod = 0;
463    if (fUseHLT) {
464      hltmod = new HLTFwkMod;
465 +    hltmod->SetHLTObjsName(GetHLTObjsName());
466 +    hltmod->SetHLTTreeName(GetHLTTreeName());
467      fDeleteList->Add(hltmod);
468    }
469  
# Line 448 | Line 486 | Bool_t Analysis::Init()
486    } else {
487  
488      // when not running Proof, we must make a selector
489 <    fSelector = new Selector;
490 <    fSelector->SetDoProxy(fDoProxy);
491 <    fSelector->SetDoObjTabClean(fDoObjTabClean);
492 <
493 <    fSelector->AddInput(anamod);
489 >    Selector *sel = new Selector;
490 >    sel->SetCacheSize(fCacheSize);  
491 >    sel->SetDoProxy(fDoProxy);
492 >    sel->SetDoObjTabClean(fDoObjTabClean);
493 >    sel->SetDoRunInfo(kTRUE);
494 >    sel->SetAllEvtHdrBrn(GetAllEvtHdrBrn());
495 >    sel->SetAllEvtTreeName(GetAllEvtTreeName());
496 >    sel->SetEvtHdrName(GetEvtHdrName());
497 >    sel->SetLAHdrName(GetLAHdrName());
498 >    sel->SetLATreeName(GetLATreeName());
499 >    sel->SetRunInfoName(GetRunInfoName());
500 >    sel->SetRunTreeName(GetRunTreeName());
501 >    sel->AddInput(anamod);
502 >    fSelector = sel;
503  
504      if (hltmod)
505        fSelector->AddInput(hltmod);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines