Logo Coherent WaveBurst  
Reference Guide
Logo
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
cwb_setchunk.C
Go to the documentation of this file.
1 // adds a new chunk (chunk of data id) leaf to the selected entries in the merged wave root file
2 
3 {
4  int estat;
5  Long_t id,size,flags,mt;
6  char cmd[1024];
7 
9 
11  if(gSystem->Getenv("CWB_MERGE_LABEL")==NULL) {
12  cout << "cwb_setchunk Error : environment CWB_MERGE_LABEL is not defined!!!" << endl;exit(1);
13  } else {
14  cwb_merge_label=TString(gSystem->Getenv("CWB_MERGE_LABEL"));
15  }
16 
17  // check if label has the correct format (M#)
18  if(cwb_merge_label[0]!='M') {
19  cout << endl;
20  cout << "cwb_setchunk Error : label " << cwb_merge_label.Data() << " has bad format (M#)" << endl;
21  cout << "Only merge label can be used for cwb_setchunk" << endl << endl;exit(1);
22  } else {
23  TString lcheck=cwb_merge_label;
24  lcheck.Remove(0,1);
25  if(!lcheck.IsDigit()) {
26  cout << endl;
27  cout << "cwb_setchunk Error : label " << cwb_merge_label.Data() << " has bad format (M#)" << endl;
28  cout << "Only merge label can be used for cwb_setchunk" << endl << endl;exit(1);
29  }
30  }
31 
32  // get chunk num
34  if(gSystem->Getenv("CWB_SETCHUNK_ID")==NULL) {
35  cout << endl << "cwb_setchunk Error : environment CWB_SETCHUNK_ID is not defined!!!" << endl << endl;
36  gSystem->Exit(1);
37  } else {
38  if(TString(gSystem->Getenv("CWB_SETCHUNK_ID")).IsDigit()) {
39  cwb_setchunk_id=TString(gSystem->Getenv("CWB_SETCHUNK_ID")).Atoi();
40  } else {
41  cout << endl << "cwb_setchunk Error : environment CWB_SETCHUNK_ID is not a positive integer number!!!" << endl << endl;
42  gSystem->Exit(1);
43  }
44  }
45  if(cwb_setchunk_id<1) {
46  cout << endl << "cwb_setchunk Error : environment CWB_SETCHUNK_ID is not an integer number >0 !!!" << endl << endl;
47  gSystem->Exit(1);
48  }
49 
50  // create input wave root wave file name
51  char iwfname[1024];
52  sprintf(iwfname,"wave_%s.%s.root",data_label,cwb_merge_label.Data());
53 
54  // create output wave root cuts file name
55  TString owfname = mdir+"/"+iwfname;
56  char schunk[32];sprintf(schunk,"chunk%d",cwb_setchunk_id);
57  owfname.ReplaceAll(".root",TString(".K_")+schunk+".root");
58 
59  // apply setChunk to the wave file
60  CWB::Toolbox::setChunk(iwfname,mdir,mdir,"waveburst",cwb_setchunk_id);
61 
62  if(simulation==0) {
63 
64  // create input wave root live file name
65  char iwfname[1024];
66  sprintf(iwfname,"live_%s.%s.root",data_label,cwb_merge_label.Data());
67 
68  // create output wave root cuts file name
69  TString owfname = mdir+"/"+iwfname;
70  char schunk[32];sprintf(schunk,"chunk%d",cwb_setchunk_id);
71  owfname.ReplaceAll(".root",TString(".K_")+schunk+".root");
72 
73  // apply setChunk to the wave file
74  CWB::Toolbox::setChunk(iwfname,mdir,mdir,"liveTime",cwb_setchunk_id);
75 
76  } else {
77 
78  // create input wave root mdc file name
79  char iwfname[1024];
80  sprintf(iwfname,"mdc_%s.%s.root",data_label,cwb_merge_label.Data());
81 
82  // create output wave root cuts file name
83  TString owfname = mdir+"/"+iwfname;
84  char schunk[32];sprintf(schunk,"chunk%d",cwb_setchunk_id);
85  owfname.ReplaceAll(".root",TString(".K_")+schunk+".root");
86 
87  // apply setChunk to the wave file
88  CWB::Toolbox::setChunk(iwfname,mdir,mdir,"mdc",cwb_setchunk_id);
89 
90  }
91 
92  // create a merge*.lst file name & run selection cuts
93  vector<int> jobList;
94  char ilstfname[1024];
95  sprintf(ilstfname,"merge_%s.%s.lst",data_label,cwb_merge_label.Data());
97  olstfname.ReplaceAll("wave_","merge_");
98  olstfname.ReplaceAll(".root",".lst");
99  olstfname.Remove(0,olstfname.Last('/')+1); // strip path
100  cout << olstfname << endl;
101  estat = gSystem->GetPathInfo(mdir+"/"+ilstfname,&id,&size,&flags,&mt);
102  if (estat==0) {
103  sprintf(cmd,"cd %s;ln -sf %s %s",mdir.Data(),ilstfname,olstfname.Data());
104  cout << cmd << endl;
105  gSystem->Exec(cmd);
106  }
107 
108  exit(0);
109 }
TString("c")
char ilstfname[1024]
Definition: cwb_setchunk.C:94
Long_t flags
Definition: cwb_setchunk.C:3
int cwb_setchunk_id
Definition: cwb_setchunk.C:33
TString mdir
Definition: cwb_setchunk.C:8
char data_label[512]
Definition: test_config1.C:160
Long_t size
Definition: cwb_setchunk.C:3
exit(0)
static int setChunk(TString ifName, TString idir, TString odir, TString trname, int chunk)
Definition: Toolbox.cc:3194
vector< int > jobList
Definition: cwb_setchunk.C:93
char merge_dir[512]
Definition: test_config1.C:147
char schunk[32]
Definition: cwb_setchunk.C:56
TString olstfname
Definition: cwb_setchunk.C:96
TString cwb_merge_label
Definition: cwb_setchunk.C:10
char cmd[1024]
Definition: cwb_setchunk.C:6
Long_t mt
Definition: cwb_setchunk.C:3
int estat
simulation
Definition: cwb_eced.C:9
sprintf(iwfname,"wave_%s.%s.root", data_label, cwb_merge_label.Data())
Long_t id
Definition: cwb_setchunk.C:3
TString owfname
Definition: cwb_setchunk.C:55