00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "TProofChain.h"
00023 #include "TDSet.h"
00024 #include "TList.h"
00025 #include "TProof.h"
00026 #include "TROOT.h"
00027 #include "TEventList.h"
00028 #include "TEntryList.h"
00029
00030 ClassImp(TProofChain)
00031
00032
00033 TProofChain::TProofChain() : TChain()
00034 {
00035
00036
00037 fChain = 0;
00038 fTree = 0;
00039 fSet = 0;
00040 fDirectory = gDirectory;
00041 fDrawFeedback = 0;
00042 ResetBit(kOwnsChain);
00043 }
00044
00045
00046 TProofChain::TProofChain(TChain *chain, Bool_t gettreeheader) : TChain()
00047 {
00048
00049
00050 fChain = chain;
00051 fTree = 0;
00052 fSet = chain ? new TDSet((const TChain &)(*chain)) : 0;
00053 fDirectory = gDirectory;
00054 fDrawFeedback = 0;
00055 if (gProof) {
00056 gProof->AddChain(chain);
00057 ConnectProof();
00058 if (gProof->IsLite()) {
00059 SetBit(kProofLite);
00060 fTree = fChain;
00061 } else {
00062 if (gettreeheader && fSet)
00063 fTree = gProof->GetTreeHeader(fSet);
00064 }
00065 }
00066 ResetBit(kOwnsChain);
00067 }
00068
00069
00070 TProofChain::TProofChain(TDSet *dset, Bool_t gettreeheader) : TChain()
00071 {
00072
00073
00074 fChain = 0;
00075 fTree = 0;
00076 fSet = dset;
00077 fDirectory = gDirectory;
00078 fDrawFeedback = 0;
00079 if (gProof) {
00080 ConnectProof();
00081 if (gettreeheader && dset)
00082 fTree = gProof->GetTreeHeader(dset);
00083 if (gProof->IsLite())
00084 SetBit(kProofLite);
00085 }
00086 if (fTree && fSet) {
00087 fChain = new TChain(fTree->GetName());
00088 TIter nxe(fSet->GetListOfElements());
00089 TDSetElement *e = 0;
00090 while ((e = (TDSetElement *) nxe())) {
00091 fChain->AddFile(e->GetName());
00092 }
00093 SetBit(kOwnsChain);
00094 if (TestBit(kProofLite))
00095 fTree = fChain;
00096 }
00097 }
00098
00099
00100 TProofChain::~TProofChain()
00101 {
00102
00103
00104 if (fChain) {
00105 SafeDelete(fSet);
00106
00107 TIter nxp(gROOT->GetListOfSockets());
00108 TObject *o = 0;
00109 TProof *p = 0;
00110 while ((o = nxp()))
00111 if ((p = dynamic_cast<TProof *>(o)))
00112 p->RemoveChain(fChain);
00113 if (fTree == fChain) fTree = 0;
00114 if (TestBit(kOwnsChain)) {
00115 SafeDelete(fChain);
00116 } else {
00117 fChain = 0;
00118 }
00119 } else {
00120
00121 fSet = 0;
00122 }
00123 SafeDelete(fTree);
00124 fDirectory = 0;
00125
00126 }
00127
00128
00129 void TProofChain::Browse(TBrowser *b)
00130 {
00131
00132
00133
00134 fSet->Browse(b);
00135 }
00136
00137
00138 Long64_t TProofChain::Draw(const char *varexp, const TCut &selection,
00139 Option_t *option, Long64_t nentries, Long64_t firstentry)
00140 {
00141
00142
00143
00144
00145 if (!gProof) {
00146 Error("Draw", "no active PROOF session");
00147 return -1;
00148 }
00149 ConnectProof();
00150
00151 if (fDrawFeedback)
00152 gProof->SetDrawFeedbackOption(fDrawFeedback, option);
00153 fReadEntry = firstentry;
00154
00155
00156 if (fEntryList) {
00157 fSet->SetEntryList(fEntryList);
00158 } else if (fEventList) {
00159 fSet->SetEntryList(fEventList);
00160 }
00161
00162
00163 FillDrawAttributes(gProof);
00164
00165 Long64_t rv = fSet->Draw(varexp, selection, option, nentries, firstentry);
00166 return rv;
00167 }
00168
00169
00170 Long64_t TProofChain::Draw(const char *varexp, const char *selection,
00171 Option_t *option,Long64_t nentries, Long64_t firstentry)
00172 {
00173
00174
00175
00176
00177 if (!gProof) {
00178 Error("Draw", "no active PROOF session");
00179 return -1;
00180 }
00181 ConnectProof();
00182
00183 if (fDrawFeedback)
00184 gProof->SetDrawFeedbackOption(fDrawFeedback, option);
00185 fReadEntry = firstentry;
00186
00187
00188 if (fEntryList) {
00189 fSet->SetEntryList(fEntryList);
00190 } else if (fEventList) {
00191 fSet->SetEntryList(fEventList);
00192 }
00193
00194
00195 FillDrawAttributes(gProof);
00196
00197 Long64_t rv = fSet->Draw(varexp, selection, option, nentries, firstentry);
00198 return rv;
00199 }
00200
00201
00202 void TProofChain::FillDrawAttributes(TProof *p)
00203 {
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217 if (!p || !fChain) {
00218 Error("FillDrawAttributes", "invalid PROOF or mother chain pointers!");
00219 return;
00220 }
00221
00222
00223 p->SetParameter("PROOF_LineColor", (Int_t) fChain->GetLineColor());
00224 p->SetParameter("PROOF_LineStyle", (Int_t) fChain->GetLineStyle());
00225 p->SetParameter("PROOF_LineWidth", (Int_t) fChain->GetLineWidth());
00226
00227
00228 p->SetParameter("PROOF_MarkerColor", (Int_t) fChain->GetMarkerColor());
00229 p->SetParameter("PROOF_MarkerSize", (Int_t) fChain->GetMarkerSize()*1000);
00230 p->SetParameter("PROOF_MarkerStyle", (Int_t) fChain->GetMarkerStyle());
00231
00232
00233 p->SetParameter("PROOF_FillColor", (Int_t) fChain->GetFillColor());
00234 p->SetParameter("PROOF_FillStyle", (Int_t) fChain->GetFillStyle());
00235
00236 if (gDebug > 0) {
00237 Info("FillDrawAttributes","line: color:%d, style:%d, width:%d",
00238 fChain->GetLineColor(), fChain->GetLineStyle(), fChain->GetLineWidth());
00239 Info("FillDrawAttributes","marker: color:%d, style:%d, size:%f",
00240 fChain->GetMarkerColor(), fChain->GetMarkerStyle(), fChain->GetMarkerSize());
00241 Info("FillDrawAttributes","area: color:%d, style:%d",
00242 fChain->GetFillColor(), fChain->GetFillStyle());
00243 }
00244 }
00245
00246
00247 TBranch *TProofChain::FindBranch(const char* branchname)
00248 {
00249
00250
00251
00252 return (fTree ? fTree->FindBranch(branchname) : (TBranch *)0);
00253 }
00254
00255
00256 TLeaf *TProofChain::FindLeaf(const char* searchname)
00257 {
00258
00259
00260
00261 return (fTree ? fTree->FindLeaf(searchname) : (TLeaf *)0);
00262 }
00263
00264
00265 TBranch *TProofChain::GetBranch(const char *name)
00266 {
00267
00268
00269
00270 return (fTree ? fTree->GetBranch(name) : (TBranch *)0);
00271 }
00272
00273
00274 Bool_t TProofChain::GetBranchStatus(const char *branchname) const
00275 {
00276
00277
00278
00279 return (fTree ? fTree->GetBranchStatus(branchname) : kFALSE);
00280 }
00281
00282
00283 TVirtualTreePlayer *TProofChain::GetPlayer()
00284 {
00285
00286
00287
00288 return (fTree ? fTree->GetPlayer() : (TVirtualTreePlayer *)0);
00289 }
00290
00291
00292 Long64_t TProofChain::Process(const char *filename, Option_t *option,
00293 Long64_t nentries, Long64_t firstentry)
00294 {
00295
00296
00297
00298
00299
00300
00301 if (fEntryList) {
00302 fSet->SetEntryList(fEntryList);
00303 } else if (fEventList) {
00304 fSet->SetEntryList(fEventList);
00305 }
00306
00307 return fSet->Process(filename, option, nentries, firstentry);
00308 }
00309
00310
00311 Long64_t TProofChain::Process(TSelector *selector, Option_t *option,
00312 Long64_t nentries, Long64_t firstentry)
00313 {
00314
00315
00316
00317
00318 if (selector || option || nentries || firstentry) { }
00319
00320 Warning("Process", "not implemented");
00321 return -1;
00322 }
00323
00324
00325 void TProofChain::SetDebug(Int_t level, Long64_t min, Long64_t max)
00326 {
00327
00328
00329 TTree::SetDebug(level, min, max);
00330 }
00331
00332
00333 void TProofChain::SetName(const char *name)
00334 {
00335
00336
00337 TTree::SetName(name);
00338 }
00339
00340
00341 Long64_t TProofChain::GetEntries() const
00342 {
00343
00344
00345
00346
00347 if (TestBit(kProofLite)) {
00348 return (fTree ? fTree->GetEntries() : (Long64_t)(-1));
00349 } else {
00350 return (fTree ? fTree->GetMaxEntryLoop() : (Long64_t)(-1));
00351 }
00352 }
00353
00354
00355 Long64_t TProofChain::GetEntries(const char *selection)
00356 {
00357
00358
00359
00360 if (TestBit(kProofLite)) {
00361 return (fTree ? fTree->GetEntries(selection) : (Long64_t)(-1));
00362 } else {
00363 Warning("GetEntries", "GetEntries(selection) not yet implemented");
00364 return ((Long64_t)(-1));
00365 }
00366 }
00367
00368
00369 void TProofChain::Progress(Long64_t total, Long64_t processed)
00370 {
00371
00372
00373 if (gROOT->IsInterrupted() && gProof)
00374 gProof->StopProcess(kTRUE);
00375 if (total) { }
00376
00377 fReadEntry = processed;
00378 }
00379
00380
00381 Long64_t TProofChain::GetReadEntry() const
00382 {
00383
00384
00385 return fReadEntry;
00386 }
00387
00388
00389 void TProofChain::ReleaseProof()
00390 {
00391
00392
00393 if (!gProof)
00394 return;
00395 gProof->Disconnect("Progress(Long64_t,Long64_t)",
00396 this, "Progress(Long64_t,Long64_t)");
00397 if (fDrawFeedback)
00398 gProof->DeleteDrawFeedback(fDrawFeedback);
00399 fDrawFeedback = 0;
00400 }
00401
00402
00403 void TProofChain::ConnectProof()
00404 {
00405
00406
00407
00408 if (gProof && !fDrawFeedback) {
00409 fDrawFeedback = gProof->CreateDrawFeedback();
00410
00411 gProof->Connect("Progress(Long64_t,Long64_t)", "TProofChain",
00412 this, "Progress(Long64_t,Long64_t)");
00413 }
00414 }