forked from alisw/AliRoot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AliExternalInfo.cxx
1630 lines (1429 loc) · 70.5 KB
/
AliExternalInfo.cxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include <fstream>
#include <iostream>
#include <map>
#include <set>
#include <sys/types.h>
#include <sys/stat.h>
#include <ctime>
#include <string>
#include <map>
#include <limits>
#include "TROOT.h"
#include "AliExternalInfo.h"
#include "TObjArray.h"
#include "TString.h"
#include "TWebFile.h"
#include "TSystem.h"
#include "TTree.h"
#include "TFile.h"
#include "TChain.h"
#include "TMath.h"
#include "TStatToolkit.h"
#include "TLeaf.h"
#include "TVirtualIndex.h"
#include "TPRegexp.h"
#include "TError.h"
ClassImp(AliExternalInfo)
using namespace std;
const TString AliExternalInfo::fgkDefaultConfig="$ALICE_ROOT/STAT/Macros/AliExternalInfo.cfg";
AliExternalInfo::AliExternalInfo(TString localStorageDirectory, TString configLocation, Int_t verbose/*, Bool_t copyToLocalStorage*/) :
/*fCopyDataToLocalStorage(copyToLocalStorage),*/
TObject(),
fVerbose(verbose),
fLoadMetadata(kTRUE),
fConfigLocation(configLocation),
fLocalStorageDirectory(localStorageDirectory),
fConfigMap(),
fTree(0x0),
fChain(new TChain()),
fChainMap(),
fMaxCacheSize(-1),
fLogCache(0x0)
{
// use default cache path from Env variable if specified
if (gSystem->Getenv("AliExternalInfoCache")!=NULL){
if (localStorageDirectory.Length()<2) fLocalStorageDirectory=gSystem->Getenv("AliExternalInfoCache");
}
ReadConfig(configLocation, fVerbose);
}
AliExternalInfo::~AliExternalInfo() {}
/// Reads the configuration files. Lines beginning with an '#' are ignored.
///
/// Use the format which is in the config.cfg by default. Adding ressources like the ones already
/// there should work without problems.
/// \param configLocation - semicolon separated configuration list
/// - applied as in CSS
/// \param verbose - verbosity
void AliExternalInfo::ReadConfig( TString configLocation, Int_t verbose){
// Prepend config files on first load
if (fConfigLocation.Length()==0){
// Check if local config exists
if(!gSystem->AccessPathName("AliExternalInfo.cfg")){ // false if file exists
configLocation=AliExternalInfo::fgkDefaultConfig+";AliExternalInfo.cfg;"+configLocation;
} else{
configLocation=AliExternalInfo::fgkDefaultConfig+configLocation;
}
}
TObjArray *configArray = configLocation.Tokenize(";");
fConfigLocation+=configLocation;
fConfigLocation+=";";
Int_t nConfig=configArray->GetEntries();
if (nConfig==0){
::Error("AliExternalInfo::ReadConfig","Invalid configuration description %s",configLocation.Data());
return;
}
for (Int_t iConfig=0; iConfig<nConfig; iConfig++){
TString cName=configArray->At(iConfig)->GetName();
if (cName=="default") cName="$ALICE_ROOT/STAT/Macros/AliExternalInfo.cfg";
if (cName.Length()==0) continue;
TString configFileName=gSystem->ExpandPathName(cName.Data());
if (verbose>0){
::Info("AliExternalInfo::ReadConfig","Path: %s\t%s",cName.Data(), configFileName.Data());
}
if (gSystem->AccessPathName(configFileName)!=0) { // be aware of strange convention for the gSystem->AccessPathName - 0 mean it is OK
::Error("AliExternalInfo::ReadConfig", TString::Format("Could not find config file '%s'", configFileName.Data()));
const TString defaultConfigFileName=gSystem->ExpandPathName(fgkDefaultConfig);
if (defaultConfigFileName!=configFileName) {
::Error("AliExternalInfo::ReadConfig", "Using default config file instead");
configFileName=defaultConfigFileName;
}
}
std::ifstream configFile(configFileName);
if (!configFile.is_open()) {
::Error("AliExternalInfo::ReadConfig", TString::Format("Could not open config file '%s'", configFileName.Data()));
return;
}
//
std::string line;
while (std::getline(configFile, line)){
TString temp_line(line.c_str()); // Use TString for easier handling
if (temp_line.EqualTo("")) continue; // Ignore empty lines
// temp_line = temp_line.Strip(TString::EStripType::kBoth, ' '); // Strip trailing and leading spaces
temp_line = temp_line.Strip(TString::kBoth, ' '); // Strip trailing and leading spaces
if (temp_line.First('#') == 0) continue; // If line starts with a '#' treat is as a comment
TObjArray arrTokens = (*(temp_line.Tokenize(' ')));
const TString key(arrTokens.At(0)->GetName());
const TString value(arrTokens.At(1)->GetName());
fConfigMap[key] = value;
}
}
delete configArray;
return;
}
/// Prints out the config which was read in previously. Useful to check if anything went wrong
void AliExternalInfo::PrintConfig(){
// Loop through the map (Would be much easier in c++11)
::Info("AliExternalInfo::PrintConfig", "User defined resources are\n");
// looping over map with const_iterator
typedef std::map<TString,TString>::const_iterator it_type;
for(it_type iterator = fConfigMap.begin(); iterator != fConfigMap.end(); ++iterator) {
std::cout << iterator->first << " " << iterator->second << "\n";
}
return;
}
/// AliExternalInfo::GetProductionTree(TString period, TString pass)
/// \param period - period ID
/// \param pass - pass ID
/// \return production tree ()
/// * Input data source MonALISA
/// * Production information from MonALISA web interface - querying tags
/// * PPass - https://alimonitor.cern.ch/prod/?t=1&res_path=mif
/// * CPass - https://alimonitor.cern.ch/prod/?t=2&res_path=mif
/// * MC - https://alimonitor.cern.ch/prod/?t=3&res_path=mif
/// * Tags query not fully reliable as syntax was chenging several times
/// * Only reliable information - path column in reulting tree (path to the output data)
/// * Algorithm:
/// * loop over all possible production (Prod, ProdCPassm, ProdMC) for given period
/// * loop over all passes for given production
/// * check presence of output path
/// * save tree in cache file
/*!
Example usage:
\code
AliExternalInfo info;
TTree * prodTree = info.GetProductionTree("LHC17f","pass1");
prodTree->Scan("RunNo:outputdir:jobs_error:jobs_total","","col=10:50:10:10");
TTree * mcProdTree = info.GetProductionTree("LHC17k2","");
mcProdTree->Scan("RunNo:outputdir:jobs_error:jobs_total","","col=10:50:10:10");
\endcode
*/
TTree * AliExternalInfo::GetProductionTree(TString period, TString pass){
TTree *productionTree=NULL;
TPRegexp regexpDir(TString::Format("/%s$",pass.Data()));
for (Int_t productionSource=0; productionSource<3; productionSource++){
TTree * treeProductionAll = NULL;
if (productionSource==0) treeProductionAll = GetTree("MonALISA.ProductionCycle","","");
if (productionSource==1) treeProductionAll = GetTree("MonALISA.ProductionCPass","","");
if (productionSource==2) treeProductionAll = GetTree("MonALISA.ProductionMC","","");
treeProductionAll->SetBranchStatus("*",kFALSE);
treeProductionAll->SetBranchStatus("Tag",kTRUE);
treeProductionAll->SetBranchStatus("ID",kTRUE);
Int_t entriesAll=treeProductionAll->GetEntries();
for (Int_t i=0; i<entriesAll; i++){
treeProductionAll->GetEntry(i);
TString tag=((char*)treeProductionAll->GetLeaf("Tag")->GetValuePointer());
if (tag.Contains(period.Data())==0) continue;
Int_t id = TMath::Nint(treeProductionAll->GetLeaf("ID")->GetValue());
if (fVerbose&0x2) ::Info("GetProductionTree","Check id %d\t%s",id, tag.Data());
TTree * cTree = GetTreeProdCycleByID(TString::Format("%d", id));
if (cTree==NULL) continue;
if (productionSource==2) { // do not check dir for the MC production - different naming convention
productionTree=cTree;
break;
}
cTree->GetEntry(0);
TString dir=((char*)cTree->GetLeaf("outputdir")->GetValuePointer());
if (regexpDir.Match(dir)){
productionTree=cTree;
break;
}
}
delete treeProductionAll;
if (productionTree) { // save file in predefined folder
TString outputPath = CreatePath("MonALISA.Production",period,pass);
if (gSystem->Getenv("AliExternalInfoCache")){
outputPath.Prepend(gSystem->Getenv("AliExternalInfoCache"));
}else{
outputPath.Prepend(".");
}
gSystem->mkdir(outputPath,kTRUE);
outputPath+=fConfigMap["MonALISA.Production.filename"];
TFile *f = TFile::Open(outputPath.Data(),"recreate");
TTree *copyTree = productionTree->CopyTree("");
copyTree->Write(fConfigMap["MonALISA.Production.treename"]);
f->Close();
if (fVerbose&0x1) ::Info("GetProductionTree","Make cache path %s",outputPath.Data());
return productionTree;
}
}
return NULL;
}
/// Sets up all variables according to period, pass and type. Extracts information from the config file
void AliExternalInfo::SetupVariables(TString& internalFilename, TString& internalLocation, Bool_t& resourceIsTree, TString& pathStructure, \
TString& detector, TString& rootFileName, TString& treeName, const TString& type, const TString& period, const TString& pass, TString & indexName){
// Check if resource is a tree in a root file or not
TString lpass=pass;
if (fConfigMap[type + ".nopass"].Contains("true")) lpass="";
pathStructure = CreatePath(type, period, lpass);
// if (fConfigMap.count(type + ".treename") > 0) resourceIsTree = kTRUE;
// else resourceIsTree = kFALSE;
if (type.Contains("MonALISA") == kTRUE) resourceIsTree = kFALSE;
else resourceIsTree = kTRUE;
// To distinguish different detector QA you have to add a <det>_ to the trending.root. Here we check the detector!
if (type.Contains("QA")) {
Int_t firstDotOfType(type.First('.') + 1);
Int_t lastCharOfType(type.Length() - 1);
detector = type(firstDotOfType, lastCharOfType) + "_";
// std::cout << "DETECTOR: " << detector << std::endl;
}
rootFileName = fConfigMap[type + ".filename"];
treeName = fConfigMap[type + ".treename"];
indexName= fConfigMap[type + ".indexname"];
if (indexName.Length()<=0) indexName="run";
// Create the local path where to store the information of the resource
internalLocation += pathStructure;
::Info("AliExternalInfo::SetupVariables", TString::Format("Information will be stored/retrieved in/from %s", internalLocation.Data()));
if (!(period.Last('*') == period.Length() - 1) || !(pass.Last('*') == pass.Length() - 1) || period.Length() == 0){
// std::cout << "mkdir " << internalLocation.Data() << std::endl;
gSystem->mkdir(internalLocation.Data(), kTRUE);
}
// Resulting internal path to the file
if (resourceIsTree) internalFilename = internalLocation + detector + rootFileName; // e.g data/<year>/<period>/<pass>/<det>_trending.root
else internalFilename = internalLocation + rootFileName; // e.g data/<year>/<period>/<pass>/MC.root
return;
};
/// \param type Type of the resource as described in the config file, e.g. QA.TPC, MonALISA.RCT
/// \param period Period, e.g. 'LHC15f'
/// \param pass E.g. 'pass2' or 'passMC'
/// Implements the functionality to download the ressources in the specified storage. If it is not
/// in the form of a tree it creates one. You can use this function or the functions available in
/// the class definition as an abbrevation
/// \return If downloading and creation of tree was successful true, else false
Bool_t AliExternalInfo::Cache(TString type, TString period, TString pass){
::Info("AliExternalInfo::Cache", TString::Format("Caching of %s %s from %s in start path %s", period.Data(), pass.Data(), type.Data(), fLocalStorageDirectory.Data()));
// initialization of local variables
TString internalFilename = ""; // Resulting path to the file
TString internalLocation = fLocalStorageDirectory; // Gets expanded in this function to the right directory
TString externalLocation = "";
Bool_t resourceIsTree = kFALSE;
TString detector = "";
TString rootFileName = "";
TString treeName = "";
TString pathStructure = "";
TString indexName="";
TString oldIndexName= fConfigMap[type + ".indexname"]; // rename index branch to avoid incositencies (bug in ROOT - the same index branch name requeired)
// initialization of external variables
externalLocation = fConfigMap[type + ".location"];
// Setting up all the local variables
SetupVariables(internalFilename, internalLocation, resourceIsTree, pathStructure, detector, rootFileName, treeName, type, period, pass,indexName);
// Checking if resource needs to be downloaded
const Bool_t downloadNeeded = IsDownloadNeeded(internalFilename, type);
TString mifFilePath = ""; // Gets changed in Curl command
if (downloadNeeded == kTRUE){
if (resourceIsTree == kTRUE && externalLocation.Contains("http")) {
externalLocation += pathStructure + rootFileName;
Int_t fstatus=0;
TString command = CurlTree(internalFilename, externalLocation);
std::cout << command << std::endl;
gSystem->Exec(command.Data());
TFile * fcache = TFile::Open(internalFilename);
if (fcache!=NULL && !fcache->IsZombie()) {
fstatus|=1;
delete fcache;
}
if (fstatus==1) {
gSystem->GetFromPipe(Form("touch %s",internalFilename.Data())); // Update the access and modification times of each FILE to the current time
return kTRUE;
}else{
::Error("AliExternalInfo::Cache", "Curl caching failed");
gSystem->GetFromPipe(Form("rm %s",internalFilename.Data()));
return kFALSE;
}
}
// Download resources in the form of .root files in a tree
if (resourceIsTree == kTRUE ) {
externalLocation += pathStructure + rootFileName;
::Info("AliExternalInfo::Cache", TString::Format("Information retrieved from: %s", externalLocation.Data()));
// Check if external location is a http address or locally accessible
// std::cout << externalLocation(0, 4) << std::endl;
TFile *file = TFile::Open(externalLocation);
if (file && !file->IsZombie()) { // Checks if webresource is available
::Info("AliExternalInfo::Cache", "Resource available");
if (file->Cp(internalFilename)) {
::Info("AliExternalInfo::Cache", "Caching with TFile::Cp() successful");
return kTRUE;
} else {
::Error("AliExternalInfo::Cache", "Copying to internal location failed");
return kFALSE;
}
} else {
::Error("AliExternalInfo::Cache", "Resource not available");
return kFALSE;
}
delete file;
}
else {
//Set up external path with period and pass if necessary
if (period != "" && pass != ""){
externalLocation = TString::Format(externalLocation.Data(), period.Data(), pass.Data());
}
else if (period != "" && pass == ""){
externalLocation = TString::Format(externalLocation.Data(), period.Data());
}
TString command = CurlMif(mifFilePath, internalLocation, rootFileName, externalLocation);
std::cout << command << std::endl;
gSystem->Exec(command.Data());
if (oldIndexName.Length()==0){
gSystem->Exec(TString::Format("cat %s | sed -l 1 s/raw_run/run/ | sed -l 1 s/RunNo/run/ > %s",mifFilePath.Data(), (mifFilePath+"RunFix0").Data())); // use standard run number IDS
}else{
gSystem->Exec(TString::Format("cat %s | sed -l 1 s/%s/%s/ > %s",mifFilePath.Data(), oldIndexName.Data(), indexName.Data(), (mifFilePath+"RunFix0").Data())); // use standrad run number IDS
}
gSystem->GetFromPipe(TString::Format("cat %s | sed s_\\\"\\\$_\\\"0_g | sed s_\\\"\\\"_\\\"\\ \\\"_g | sed s_\\\"\\\"_\\\"\\ \\\"_g > %s", (mifFilePath+"RunFix0").Data(), (mifFilePath+"RunFix").Data()).Data());
// Store it in a tree inside a root file
TFile tempfile(internalFilename, "RECREATE");
tempfile.cd();
TTree tree(treeName, treeName);
if ( (tree.ReadFile(mifFilePath+"RunFix", "", '\"')) > 0) {
if (fVerbose>1) ::Info("AliExternalInfo::Cache", "Successfully read in tree");
}
else {
::Error("AliExternalInfo::Cache", "Error while reading tree");
return kFALSE;
}
tree.Write();
tempfile.Close();
if (fVerbose>0) ::Info("AliExternalInfo::Cache", TString::Format("Write tree to file: %s", internalFilename.Data()));
return kTRUE;
}
}
else {// downloadIsNeeded == kFALSE
return kTRUE;
}
}
/// Cache selected production trees. Input production list obtained from MonALISA web interface
/// \param select - selection mask
/// \param reject - rejection mask
/// \param sourceList - list of detectors to cache
/*!
Example usage:
\code
AliExternalInfo::CacheProduction(TPRegexp("LHC17.*"),TPRegexp("cpass0"),"QA.TPC;QA.EVS;QA.TRD;QA.rawTPC;QA.ITS;Logbook;QA.TOF;Logbook.detector");
\endcode
*/
void AliExternalInfo::CacheProduction(TPRegexp select, TPRegexp reject, TString sourceList){
AliExternalInfo info;
TTree* treeProd = info.GetTreeProdCycle();
Int_t entries=treeProd->GetEntries();
TObjArray * detectorArray=sourceList.Tokenize(";");
TString rejpat=reject.GetModifiers();
for (Int_t i=0; i<entries; i++){
treeProd->GetEntry(i);
char * productionTag= (char*)treeProd->GetLeaf("Tag")->GetValuePointer();
if (select.Match(productionTag)==0) continue;
if (!rejpat.EqualTo("") && reject.Match(productionTag)==1) continue;
printf("Caching\t%s\n",productionTag);
TString production(productionTag);
Int_t pos=production.First('_');
if (pos<0) continue;
if (pos>production.Length()-4) continue;
printf("Caching\t%s\n",productionTag);
TString period( production(0,pos));
TString pass(production(pos+1, production.Length()-pos-1));
printf("Caching\t%s\t%s\t%s\n",productionTag,period.Data(),pass.Data());
for (Int_t iDet=0;iDet<detectorArray->GetEntries(); iDet++) {
info.Cache(detectorArray->At(iDet)->GetName(), period.Data(), pass.Data());
}
}
}
/// \param type Type of the resource as described in the config file, e.g. QA.TPC, MonALISA.RCT
/// \param period Period, e.g. 'LHC15f'
/// \param pass E.g. 'pass2' or 'passMC'
/// Returns the tree with the information from the corresponding resource
/// \return TTree* with corresponding resource
TTree* AliExternalInfo::GetTree(TString type, TString period, TString pass, Int_t buildIndex){
TString internalFilename = ""; // Resulting path to the file
TString internalLocation = fLocalStorageDirectory; // Gets expanded in this function to the right directory
TString externalLocation = "";
Bool_t resourceIsTree = kFALSE;
TString detector = "";
TString rootFileName = "";
TString treeName = "";
TString pathStructure = "";
TString indexName="";
TString metadataMacro=fConfigMap[type + ".metadataMacro"];
TTree* tree = 0x0;
// Setting up all the local variables
SetupVariables(internalFilename, internalLocation, resourceIsTree, pathStructure, detector, rootFileName, treeName, type, period, pass,indexName);
//std::cout << "internalFilename: " << internalFilename << " rootFileName: " << rootFileName << std::endl;
if (fVerbose>1) ::Info("AliExternalInfo::GetTree", TString::Format("Caching start internalFileName\t%s\trootFileName\t%s", internalFilename.Data(), rootFileName.Data()).Data());
if (gSystem->AccessPathName(internalFilename.Data()) == kTRUE) {
if (Cache(type, period, pass) == kFALSE) {
::Error("AliExternalInfo::GetTree", TString::Format("Caching failed internalFileName\t%s\trootFileName\t%s", internalFilename.Data(), rootFileName.Data()).Data());
return tree;
}
}else{
Bool_t downloadNeeded = IsDownloadNeeded(internalFilename, type);
if (downloadNeeded){
::Info("AliExternalInfo::GetTree", TString::Format("Caching %s", internalFilename.Data()).Data());
if (Cache(type, period, pass) == kFALSE) {
::Error("AliExternalInfo::GetTree", TString::Format("Caching failed internalFileName\t%s\trootFileName\t%s", internalFilename.Data(), rootFileName.Data()).Data());
return tree;
}
}
}
// Creating and returning the tree from the file
TFile* treefile = new TFile(internalFilename.Data());
// ---| loop over possible tree names |---
TObjArray *arr = treeName.Tokenize(",");
for (Int_t iname=0; iname<arr->GetEntriesFast(); ++iname) {
tree = dynamic_cast<TTree*>( treefile->Get(arr->At(iname)->GetName()) );
if (tree) break;
}
delete arr;
TTreeSRedirector::FixLeafNameBug(tree);
if (tree != 0x0) {
if (fVerbose>1) ::Info("AliExternalInfo::GetTree", TString::Format("Successfully read %s/%s",internalFilename.Data(), tree->GetName()));
if (buildIndex==1) BuildIndex(tree, type);
} else {
//::Error("AliExternalInfo::GetTree", "Error while reading tree: ");
::Error("AliExternalInfo::GetTree", TString::Format("ERROR READING: %s", treeName.Data()));
delete treefile;
}
const TString cacheSize=fConfigMap[type + ".CacheSize"];
Long64_t cache=cacheSize.Atoll();
if (fMaxCacheSize>0) {
if (cache>0) {
cache=TMath::Min(fMaxCacheSize, cache);
} else {
cache=fMaxCacheSize;
}
}
if (cache>0) tree->SetCacheSize(cache);
//
if (fLoadMetadata && metadataMacro.Length()>0){ // rename branch with index if specified in configuration file
if (fVerbose>1) printf("Processing metadata macro:\n gROOT->ProcessLine(.x %s((TTree*)%p,%d);", metadataMacro.Data(),tree, fVerbose);
gROOT->ProcessLine(TString::Format(".x %s((TTree*)%p,%d);",metadataMacro.Data(),tree,fVerbose).Data());
}
return tree;
}
/// \param type Type of the resource as described in the config file, e.g. QA.TPC, MonALISA.RCT
/// \param period Period, e.g. 'LHC15f'
/// \param pass E.g. 'pass2' or 'passMC'
/// \param friendList - semicolomn separated array of "friend" trees attached to the tree
/// Returns the tree with the information from the corresponding resource - trees from the friendList are added as friend trees
/// see example usage
/// \return TTree* with corresponding resource
TTree* AliExternalInfo::GetTree(TString type, TString period, TString pass, TString friendList){
//
/*
Example usage: - loading QA.TPC together with logbook and QA.EVS - visualizing data volume as fuction of interaction rate
TTree * treeTPC = info.GetTree("QA.TPC","LHC15o","pass1","QA.rawTPC;QA.ITS;QA.TPC;QA.TRD;QA.TOF;QA.EVS;Logbook;Logbook.detector:TPC:detector==\"TPC\"");
treeTPC->Draw("Logbook.detector_TPC.bytesInjectedPhysics/Logbook.detector_TPC.eventCountPhysics/1000000:QA.EVS.interactionRate","","*")
*/
TTree * tree = GetTree(type, period,pass);
if (tree==NULL) tree= GetTree(type, period,"");
if (tree==NULL) tree= GetTree(type, "","");
if (tree==NULL){
if (fVerbose&0x2) ::Error("AliExternalInfo::GetTree","Tree %s not valid or empty",type.Data());
return 0;
}
if (fVerbose&0x2) ::Info("AliExternalInfo::GetTree","Tree %s has %d entries",type.Data(),(int)tree->GetEntries());
TString indexName= fConfigMap[type + ".indexname"];
TString oldIndexName= fConfigMap[type + ".oldindexname"];
if (oldIndexName.Length()>0 && tree->FindBranch(oldIndexName.Data())){
tree->FindBranch(oldIndexName.Data())->SetName(indexName.Data());
}
if (indexName.Length()<=0) indexName="run";
Int_t entries = tree->Draw(indexName.Data(),"","goff");
if (entries<=0){
if (fVerbose&0x2) ::Error("AliExternalInfo::GetTree","Friend tree %s not valid or empty",type.Data());
return 0;
}
TObjArray * arrFriendList= friendList.Tokenize(";");
for (Int_t ilist=0; ilist<arrFriendList->GetEntriesFast(); ilist++){
TString fname=arrFriendList->At(ilist)->GetName();
TString conditionName="";
TString condition="";
Int_t nDots = fname.CountChar(':');
// in case there are more than one entry for primary index - secondary key has to be specified
// following syntax is used in this case <treeID>:conditionName:condition
// e.g Logbook.detector:TPC:detector==\"TPC\"
if (nDots!=0 && nDots!=2) continue;
if (nDots==2){
TObjArray * tokenArray = fname.Tokenize(":");
fname=tokenArray->At(0)->GetName();
conditionName=tokenArray->At(1)->GetName();
condition=tokenArray->At(2)->GetName();
delete tokenArray;
}
//
TTree *ftree= GetTree(fname.Data(), period,pass,nDots==0); // Standard build index if not custom selection
if (ftree==NULL || ftree->GetEntries()<=0){
if (fVerbose&0x2) ::Error("AliExternalInfo::GetTree","Friend tree %s not valid or empty",fname.Data());
continue;
}
else if (fVerbose&0x2) ::Info("AliExternalInfo::GetTree","Friend tree %s has %d entries",fname.Data(),(int)ftree->GetEntries());
if (nDots==2){
tree->SetAlias(conditionName.Data(),"(1+0)");
ftree->SetAlias(conditionName.Data(),condition.Data());
ftree->BuildIndex(tree->GetTreeIndex()->GetMajorName(), conditionName.Data());
tree->AddFriend(ftree, (fname+"_"+conditionName).Data());
}else{
tree->AddFriend(ftree, fname.Data());
}
//
ftree->SetTitle(TString::Format("%s.%s",fname.Data(),ftree->GetTitle()).Data());
ftree->SetName(TString::Format("%s.%s",fname.Data(),ftree->GetName()).Data());
//ftree->AddFriend(tree, type.Data());
Int_t fentries = tree->Draw(indexName.Data(),"","goff");
if (fVerbose&0x2) ::Info("AliExternalInfo::GetTree","AddFriend %s+%s - entries=%d", type.Data(), fname.Data(),fentries);
}
return tree;
}
/// \param type Type of the resource as described in the config file, e.g. QA.TPC, MonALISA.RCT
/// \param period Period, e.g. 'LHC15f'. Here you can use wildcards like in 'ls', e.g. 'LHC15*'
/// \param pass E.g. 'pass2' or 'passMC'. Here you can use wildcards like in 'ls', e.g. 'pass*'
/// Returns a chain with the information from the corresponding resources.
/// \return TChain*
TChain* AliExternalInfo::GetChain(TString type, TString period, TString pass, Int_t buildIndex){
// FIXME - here we should also fix Leave name bug
TChain* chain = 0x0;
TString internalFilename = ""; // Resulting path to the file
TString internalLocation = fLocalStorageDirectory; // Gets expanded in this function to the right directory
TString externalLocation = "";
Bool_t resourceIsTree = kFALSE;
TString detector = "";
TString rootFileName = "";
TString treeName = "";
TString pathStructure = "";
TString indexName="";
// Setting up all the local variables
SetupVariables(internalFilename, internalLocation, resourceIsTree, pathStructure, detector, rootFileName, treeName, type, period, pass,indexName);
TString cmd = TString::Format("/bin/ls %s", internalFilename.Data());
// std::cout << "==== cmd: " << cmd << std::endl;
TString files=gSystem->GetFromPipe(cmd.Data());
TObjArray *arrFiles=files.Tokenize("\n");
::Info("AliExternalInfo::GetChain", TString::Format("Files to add to chain: %s", files.Data()));
//function to get tree namee based on type
chain=new TChain(treeName.Data());
// ---| loop over possible tree names |---
TObjArray *arrTreeName = treeName.Tokenize(",");
for (Int_t ifile=0; ifile<arrFiles->GetEntriesFast(); ++ifile) {
for (Int_t itree=0; itree<arrTreeName->GetEntriesFast(); itree++){
TFile *ftemp=TFile::Open(arrFiles->At(ifile)->GetName());
if (ftemp==NULL) continue;
if (ftemp->GetListOfKeys()->FindObject(arrTreeName->At(itree)->GetName())){
chain->AddFile(arrFiles->At(ifile)->GetName(),0, arrTreeName->At(itree)->GetName());
}
delete ftemp;
}
}
const TString cacheSize=fConfigMap[type + ".CacheSize"];
Long64_t cache=cacheSize.Atoll();
if (fMaxCacheSize>0) {
if (cache>0) {
cache=TMath::Min(fMaxCacheSize, cache);
} else {
cache=fMaxCacheSize;
}
}
if (cache>0) chain->SetCacheSize(cache);
AddChain(type, period, pass);
BuildIndex(chain,type);
TString metadataMacro=fConfigMap[type + ".metadataMacro"];
chain->Draw("Entry$","1","goff",1);
if (metadataMacro.Length()>0 && chain->GetTree()) { // rename branch with index if specified in configuration file
if (fVerbose>1) printf("Processing metadata macro:\n gROOT->ProcessLine(.x %s((TTree*)%p,%d);", metadataMacro.Data(),chain->GetTree(), fVerbose);
gROOT->ProcessLine(TString::Format(".x %s((TTree*)%p,%d);",metadataMacro.Data(),chain->GetTree(),fVerbose).Data());
}
delete arrFiles;
delete arrTreeName;
return chain;
};
/// \param type Type of the resource as described in the config file, e.g. QA.TPC, MonALISA.RCT
/// \param period Period, e.g. 'LHC15f'. Here you can use wildcards like in 'ls', e.g. 'LHC15*'
/// \param pass E.g. 'pass2' or 'passMC'. Here you can use wildcards like in 'ls', e.g. 'pass*'
/// Returns a chain with the information from the corresponding resources.
/// \return TChain*
TChain* AliExternalInfo::GetChain(TString type, TString period, TString pass, TString friendList){
TChain *chain = GetChain(type.Data(),period.Data(),pass.Data(),kFALSE);
if (chain==0){
::Error("AliExternalInfo::GetChain", "Invalid tree description %s\t%s\t%s",type.Data(), period.Data(),pass.Data());
}
TObjArray * arrFriendList= friendList.Tokenize(";");
for (Int_t ilist=0; ilist<arrFriendList->GetEntriesFast(); ilist++) {
TString fname=arrFriendList->At(ilist)->GetName();
TString conditionName="";
TString condition="";
Int_t nDots = fname.CountChar(':');
TChain *chainF =NULL;
// in case there are more than one entry for primary index - secondary key has to be specified
// following syntax is used in this case <treeID>:conditionName:condition
// e.g Logbook.detector:TPC:detector==\"TPC\"
if (nDots!=0 && nDots!=2) continue;
if (nDots==2){
TObjArray * tokenArray = fname.Tokenize(":");
fname=tokenArray->At(0)->GetName();
conditionName=tokenArray->At(1)->GetName();
condition=tokenArray->At(2)->GetName();
delete tokenArray;
}
chainF=GetChain(fname.Data(), period.Data(), pass.Data(),kTRUE);
if (chainF){
if (nDots!=2) {
chain->AddFriend(chainF, arrFriendList->At(ilist)->GetName());
}else{
chain->SetAlias(conditionName.Data(),"(1+0)");
chainF->SetAlias(conditionName.Data(),condition.Data());
chainF->BuildIndex(chainF->GetTreeIndex()->GetMajorName(), conditionName.Data());
chain->AddFriend(chainF, (fname+"_"+conditionName).Data());
}
}else{
::Error("AliExternalInfo::GetChain", "Invalid friend tree\t%s\t%s",arrFriendList->At(ilist)->GetName(), friendList.Data());
continue;
}
}
return chain;
}
/// Every tree you create is added to a big tree acting as a friend.
/// You can have access to this tree with the GetFriendsTree() function.
/// @TODO Add 'return false' when adding to the friends tree was not successful
/// \return kTRUE
/// Comment: function should do only Build index - adding freind tree is not sufficently general
///
Bool_t AliExternalInfo::BuildIndex(TTree* tree, TString type){
//
//
//
TString indexName= fConfigMap[type + ".indexname"];
TString oldIndexName= fConfigMap[type + ".oldindexname"];
TString metadataMacro=fConfigMap[type + "metadataMacro"];
//
if (oldIndexName.Length()>0){ // rename branch with index if specified in configuration file
if (tree->GetBranch(oldIndexName.Data())) {
tree->SetAlias(indexName.Data(),oldIndexName.Data());
}
}
if (indexName.Length()<=0) { // set default index name
indexName="run";
if (tree->GetListOfBranches()!=NULL) if (tree->GetListOfBranches()->FindObject("run")) indexName="run";
}
if (indexName.Length()<=0) {
::Error("AliExternalInfo::BuildIndex","Index %s not available for type %s", indexName.Data(), type.Data());
}
if (tree->GetBranch(indexName.Data()) && TString(tree->GetBranch(indexName.Data())->GetTitle()).Contains("/C")){
BuildHashIndex(tree,indexName.Data(),"hashIndex");
}else{
tree->BuildIndex(indexName.Data());
}
TStatToolkit::AddMetadata(tree,"TTree.indexName",indexName.Data());
if (fVerbose&0x2) ::Info("AliExternalInfo::BuildIndex", "TreeName:%s;IndexName:%s",tree->GetName(), indexName.Data());
return kTRUE;
}
/// \param type Type of the resource as described in the config file, e.g. QA.TPC, MonALISA.RCT
/// \param period Period, e.g. 'LHC15f'. Here you can use wildcards like in 'ls', e.g. 'LHC15*'
/// \param pass E.g. 'pass2' or 'passMC'. Here you can use wildcards like in 'ls', e.g. 'pass*'
/// Not fully working. Should automatically add every downloaded file to a huge chain.
Bool_t AliExternalInfo::AddChain(TString type, TString period, TString pass){
// Adds chain of trees and buildsindexs and addfriends it
TString internalFilename = ""; // Resulting path to the file
TString internalLocation = fLocalStorageDirectory; // Gets expanded in this function to the right directory
TString externalLocation = "";
Bool_t resourceIsTree = kFALSE;
TString detector = "";
TString rootFileName = "";
TString treeName = "";
TString pathStructure = "";
TString indexName="";
// Setting up all the local variables
SetupVariables(internalFilename, internalLocation, resourceIsTree, pathStructure, detector, rootFileName, treeName, type, period, pass,indexName);
::Info("AliExternalInfo::AddChain", TString::Format("Add to internal Chain: %s", internalFilename.Data()));
::Info("AliExternalInfo::AddChain", TString::Format("with tree name: %s", treeName.Data()));
fChain->AddFile(internalFilename.Data(), TChain::kBigNumber, treeName);
return kTRUE;
}
/// \param period Period in the form eg LHC15f
/// Generate from eg LHC15f the year 2015
/// \return Year in the form "2015"
const TString AliExternalInfo::GetYearFromPeriod(const TString &period){
TString year(period(3,2));
year = TString::Format("20%s", year.Data());
return year;
}
/// \param type Type of the resource as described in the config file, e.g. QA.TPC, MonALISA.RCT
/// \param period Period, e.g. 'LHC15f'. Here you can use wildcards like in 'ls', e.g. 'LHC15*'
/// \param pass E.g. 'pass2' or 'passMC'. Here you can use wildcards like in 'ls', e.g. 'pass*'
/// Returns a TString containing the complete directory structure where the root
/// file should be stored/loaded from. eg './data/2015/LHC15f/pass2/'
const TString AliExternalInfo::CreatePath(TString type, TString period, TString pass){
// Create the local path from the type, period and pass of the resource
TString internalLocation;
if (period=="sim") return "/sim/";
if (period=="data") return "/data/";
//Check if period is MC and adjust storage hif::erarchy
if (period.Length() == 6 || (period == "" && type != "MonALISA.MC") || type == "MonALISA.ProductionCycleID" || type == "MonALISA.RCT"|| type == "TriggerClasses") { // put everything in the form LHCYYx or with empty period and pass in "data"
internalLocation.Append("/data/");
}
else { // everything which is not in the form "LHCYYx" put in /sim/
internalLocation.Append("/sim/");
}
// std::cout << "Internal save path 1: " << internalLocation << std::endl;
if (period != "" && type != "MonALISA.ProductionCycleID" && type != "QA.rawTPC"){
const TString year = GetYearFromPeriod(period);
internalLocation += year + "/";
// std::cout << "Internal save path 2: " << internalLocation << std::endl;
internalLocation += period + "/";
// std::cout << "Internal save path 3: " << internalLocation << std::endl;
if (pass != ""){
internalLocation += pass + "/";
// std::cout << "Internal save path 4: " << internalLocation << std::endl;
}
}
else if (type == "QA.rawTPC"){ // only needs the year
const TString year = GetYearFromPeriod(period);
internalLocation += year + "/";
}
else if (type == "MonALISA.ProductionCycleID") { // Needed for ProductionCycleIDs
internalLocation += "ID_" + period + "/";
}
return internalLocation;
}
/// \param file Exact location of the file which should be checked
/// \param type Type of the resource as described in the config file, e.g. QA.TPC, MonALISA.RCT
/// Checks if the file is older than the timeout which is specified in the config file of this
/// specific resource type
/// \returns true if download of the resource is needed and false if not
Bool_t AliExternalInfo::IsDownloadNeeded(TString file, TString type){
Int_t timeOut = 0;
timeOut = atoi(fConfigMap[type + ".timeout"]);
// std::cout << "-- Check, if " << file << " is already there" << std::endl;
if (gSystem->AccessPathName(file.Data()) == kTRUE) {
::Info("AliExternalInfo::IsDownloadNeeded", "-- File not found locally --> Caching from remote");
return kTRUE;
}
else {
// std::cout << "---- File already downloaded --> Check if older than timelimit" << std::endl;
struct stat st;
stat(file.Data(), &st);
std::time_t timeNow = std::time(0);
long int timeFileModified = st.st_mtime;
// std::cout << "------ File is " << timeNow - timeFileModified << " seconds old" << std::endl;
if (timeNow - timeFileModified < timeOut) {
::Info("AliExternalInfo::IsDownloadNeeded", TString::Format("-- File is %li s old; NOT older than the set timelimit %d s",timeNow - timeFileModified, timeOut));
return kFALSE; // if file is younger than the set time limit, it will not be downloaded again
}
else {
::Info("AliExternalInfo::IsDownloadNeeded", TString::Format("-- File is %li s old; Older than the set timelimit %d s",timeNow - timeFileModified, timeOut));
return kTRUE;
}
}
}
/// \param mifFilePath Location of the mif-file which is downloaded from Monalisa; Is changed by this function
/// \param internalLocation Directory where the root file is stored
/// \param rootFileName Location of the newly created root file
/// \param externalLocation Location specified in the config file
/// Composes the curl-command in a TString which afterwards then can be executed
/// \return curl-command in a TString
const TString AliExternalInfo::CurlMif(TString& mifFilePath, const TString& internalLocation, TString rootFileName, const TString& externalLocation){
TString command = "";
TString certificate("$HOME/.globus/usercert.pem");
TString privateKey("$HOME/.globus/userkey.pem");
if(!gSystem->AccessPathName(certificate.Data())){
::Error("AliExternalInfo::CurlMif","Grid certificate can not be found in: %s",certificate.Data());
return TString("No Certificate!");
}
if(!gSystem->AccessPathName(privateKey.Data())) {
::Error("AliExternalInfo::CurlMif","Grid private key can not be found in: %s",privateKey.Data());
return TString("No private Key!");
}
// TString internalLocation = internalFilename(0, internalFilename.Last('/') + 1); // path to internal location
// Create path to logfile with same name as the root file
TString logFileName = rootFileName.ReplaceAll(".root", ".log");
logFileName.Prepend(internalLocation);
mifFilePath = rootFileName.ReplaceAll(".log", ".mif");
mifFilePath.Prepend(internalLocation);
command = TString::Format("curl -z %s -k --tlsv1 --cert %s --key %s -o %s 2>%s \"%s\"",
mifFilePath.Data(), certificate.Data(), privateKey.Data(),
mifFilePath.Data(), logFileName.Data(), externalLocation.Data());
if ((fVerbose&0x4)>0) {
::Info("AliExternalInfo::Curl","%s",command.Data());
}
return command;
}
const TString AliExternalInfo::CurlTree(const TString internalFilename, const TString& externalLocation){
TString command = "";
TString certificate("$HOME/.globus/usercert.pem");
TString privateKey("$HOME/.globus/userkey.pem");
if(!gSystem->AccessPathName(certificate.Data())){
::Error("AliExternalInfo::CurlTree","Grid certificate can not be found in: %s",certificate.Data());
return TString("No Certificate!");
}
if(!gSystem->AccessPathName(privateKey.Data())) {
::Error("AliExternalInfo::CurlTree","Grid private key can not be found in: %s",privateKey.Data());
return TString("No private Key!");
}
command = TString::Format("curl -Lk -z %s --tlsv1 --cert %s --key %s -o %s \"%s\"", //-L option required to get files from redirected URL
internalFilename.Data(),certificate.Data(), privateKey.Data(),
internalFilename.Data(), externalLocation.Data());
return command;
}
/// \param period LHC period
/// \param pass calibratio pass
TTree * AliExternalInfo::GetCPassTree(const char * period, const char *pass){
//
// Try to find production information about pass OCDB export
// To find the production description field of the overlal production table is queried
//
// Warnig:
// In some cases mif format internaly used not stable
// Unit consistency test should be part of procedure
//
TTree * treeProdArray=0, *treeProd=0;
AliExternalInfo info;
treeProdArray = GetTreeCPass();
treeProdArray->Scan("ID:Description:Tag",TString::Format("strstr(Tag,\"%s\")&&strstr(Tag,\"%s\")&& strstr(Description,\"merging\")",period,pass).Data(),"col=10:100:100");
// check all candidata production and select one which exports OCDB
Int_t entries= treeProdArray->Draw("ID:Description",TString::Format("strstr(Description,\"%s\")&&strstr(Description,\"%s\")&& strstr(Description,\"merging\")",period,pass).Data(),"goff");
for (Int_t ientry=0; ientry<entries; ientry++){
TTree * treeProd0 = info.GetTreeProdCycleByID(TString::Format("%.0f",treeProdArray->GetV1()[ientry]).Data());
Int_t status = treeProd0->Draw("1","strstr(outputdir,\"OCDB\")==1","goff"); // check presence of the OCDB
if (status==0) {
delete treeProd0;
continue;
}
treeProd=treeProd0;
}
return treeProd;
}
/// Add branch index branch with name chindexName calculated from input string branch chbranchName
/// and make thi branch as a primary index
/// used in order to qury FreindTrees with string keyname (impossible with standard ROOT)
///
/// \param tree - input tree
/// \param chbranchName - branch name with index
/// \param chindexName - name if the index branch
void AliExternalInfo::BuildHashIndex(TTree* tree, const char *chbranchName, const char *chindexName){
//
//
Int_t indexName=0;
char pbranchName[10000];
TBranch *brIndexMC = tree->Branch(chindexName,&indexName,TString::Format("%s/I",chindexName).Data()); // branch to fill
TBranch *branch=tree->GetBranch(chbranchName); // branhc to get string
if (branch!=NULL){
branch->SetAddress(&pbranchName);
}else{
//;
}
Int_t entries= tree->GetEntries();
for (Int_t ientry=0; ientry<entries; ientry++){
branch->GetEntry(ientry);
indexName=TMath::Hash(pbranchName);
brIndexMC->Fill();
}
tree->BuildIndex(chindexName);
brIndexMC->SetAddress(0); // reset pointers to the branches to 0
branch->SetAddress(0); // reset pointers to the branches to 0
}
void AliExternalInfo::PrintConfigSelected(const char *expName, const char *expValue){
//
//
PrintMapSelected(fConfigMap, expName,expValue);
}
void AliExternalInfo::PrintMapSelected(std::map<TString, TString> infoMap, const char *expName, const char *expValue){
//
// This function to move to some util class
// Simple printing of the configuration filtering using Reg. expression
// algorithm consuted with the http://stackoverflow.com/questions/17253690/finding-in-a-std-map-using-regex
// No support in std::map - linear loop also sugested (faster version have to make some assumptions)
//
// More complex filter with logical operation will be written later
// expName - regular expression to selec in tag name
// expValue - regular expression to selec in tag value
//
TPRegexp regExpName(expName);
TPRegexp regExpValue(expValue);
std::map<TString, TString>::iterator it;
for (it=infoMap.begin(); it!=infoMap.end(); ++it){
Bool_t isSelected=kTRUE;
if (regExpName.GetPattern().Length()>0) isSelected&= regExpName.Match(it->first);
if (regExpValue.GetPattern().Length()>0) isSelected&= regExpValue.Match(it->second);
if (isSelected) printf("%s\t%s\n", it->first.Data(), it->second.Data());
}
}
TTree* AliExternalInfo::GetTreeAliVersRD(){
// returns and stores tree ("dumptree") containing the relevant information of real data productions
// for guessing the anchor pass of MC productions
// and chaches the logbooks (and QA trees) which are needed for GetMCAnchPerGuess()
TTree * treeProd = GetTreeProdCycle(); // getting tree with information on real data productions (list, id, tag) - id will be used to get info for each production via GetTreeProdCycleByID(TString::Format("%d",id))