Logo coherent WaveBurst  
Library 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 /*
2 # Copyright (C) 2019 Gabriele Vedovato
3 #
4 # This program is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation, either version 3 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17 
18 
19 // adds a new chunk (chunk of data id) leaf to the selected entries in the merged wave root file
20 
21 {
22  int estat;
23  Long_t id,size,flags,mt;
24  char cmd[1024];
25 
27 
29  if(gSystem->Getenv("CWB_MERGE_LABEL")==NULL) {
30  cout << "cwb_setchunk Error : environment CWB_MERGE_LABEL is not defined!!!" << endl;exit(1);
31  } else {
32  cwb_merge_label=TString(gSystem->Getenv("CWB_MERGE_LABEL"));
33  }
34 
35  // check if label has the correct format (M#)
36  if(cwb_merge_label[0]!='M') {
37  cout << endl;
38  cout << "cwb_setchunk Error : label " << cwb_merge_label.Data() << " has bad format (M#)" << endl;
39  cout << "Only merge label can be used for cwb_setchunk" << endl << endl;exit(1);
40  } else {
41  TString lcheck=cwb_merge_label;
42  lcheck.Remove(0,1);
43  if(!lcheck.IsDigit()) {
44  cout << endl;
45  cout << "cwb_setchunk Error : label " << cwb_merge_label.Data() << " has bad format (M#)" << endl;
46  cout << "Only merge label can be used for cwb_setchunk" << endl << endl;exit(1);
47  }
48  }
49 
50  // get chunk num
52  if(gSystem->Getenv("CWB_SETCHUNK_ID")==NULL) {
53  cout << endl << "cwb_setchunk Error : environment CWB_SETCHUNK_ID is not defined!!!" << endl << endl;
54  gSystem->Exit(1);
55  } else {
56  if(TString(gSystem->Getenv("CWB_SETCHUNK_ID")).IsDigit()) {
57  cwb_setchunk_id=TString(gSystem->Getenv("CWB_SETCHUNK_ID")).Atoi();
58  } else {
59  cout << endl << "cwb_setchunk Error : environment CWB_SETCHUNK_ID is not a positive integer number!!!" << endl << endl;
60  gSystem->Exit(1);
61  }
62  }
63  if(cwb_setchunk_id<1) {
64  cout << endl << "cwb_setchunk Error : environment CWB_SETCHUNK_ID is not an integer number >0 !!!" << endl << endl;
65  gSystem->Exit(1);
66  }
67 
68  // create input wave root wave file name
69  char iwfname[1024];
70  sprintf(iwfname,"wave_%s.%s.root",data_label,cwb_merge_label.Data());
71 
72  // create output wave root cuts file name
73  TString owfname = mdir+"/"+iwfname;
74  char schunk[32];sprintf(schunk,"chunk%d",cwb_setchunk_id);
75  owfname.ReplaceAll(".root",TString(".K_")+schunk+".root");
76 
77  // apply setChunk to the wave file
78  CWB::Toolbox::setChunk(iwfname,mdir,mdir,"waveburst",cwb_setchunk_id);
79 
80  if(simulation==0) {
81 
82  // create input wave root live file name
83  char iwfname[1024];
84  sprintf(iwfname,"live_%s.%s.root",data_label,cwb_merge_label.Data());
85 
86  // create output wave root cuts file name
87  TString owfname = mdir+"/"+iwfname;
88  char schunk[32];sprintf(schunk,"chunk%d",cwb_setchunk_id);
89  owfname.ReplaceAll(".root",TString(".K_")+schunk+".root");
90 
91  // apply setChunk to the wave file
92  CWB::Toolbox::setChunk(iwfname,mdir,mdir,"liveTime",cwb_setchunk_id);
93 
94  } else {
95 
96  // create input wave root mdc file name
97  char iwfname[1024];
98  sprintf(iwfname,"mdc_%s.%s.root",data_label,cwb_merge_label.Data());
99 
100  // create output wave root cuts file name
101  TString owfname = mdir+"/"+iwfname;
102  char schunk[32];sprintf(schunk,"chunk%d",cwb_setchunk_id);
103  owfname.ReplaceAll(".root",TString(".K_")+schunk+".root");
104 
105  // apply setChunk to the wave file
106  CWB::Toolbox::setChunk(iwfname,mdir,mdir,"mdc",cwb_setchunk_id);
107 
108  }
109 
110  // create a merge*.lst file name & run selection cuts
111  vector<int> jobList;
112  char ilstfname[1024];
113  sprintf(ilstfname,"merge_%s.%s.lst",data_label,cwb_merge_label.Data());
115  olstfname.ReplaceAll("wave_","merge_");
116  olstfname.ReplaceAll(".root",".lst");
117  olstfname.Remove(0,olstfname.Last('/')+1); // strip path
118  cout << olstfname << endl;
119  estat = gSystem->GetPathInfo(mdir+"/"+ilstfname,&id,&size,&flags,&mt);
120  if (estat==0) {
121  sprintf(cmd,"cd %s;ln -sf %s %s",mdir.Data(),ilstfname,olstfname.Data());
122  cout << cmd << endl;
123  gSystem->Exec(cmd);
124  }
125 
126  exit(0);
127 }
TString("c")
char ilstfname[1024]
Definition: cwb_setchunk.C:112
Long_t flags
Definition: cwb_setchunk.C:21
int cwb_setchunk_id
Definition: cwb_setchunk.C:51
TString mdir
Definition: cwb_setchunk.C:26
char data_label[512]
Definition: test_config1.C:160
Long_t size
Definition: cwb_setchunk.C:21
exit(0)
static int setChunk(TString ifName, TString idir, TString odir, TString trname, int chunk)
Definition: Toolbox.cc:3214
vector< int > jobList
Definition: cwb_setchunk.C:111
char merge_dir[512]
Definition: test_config1.C:147
char schunk[32]
Definition: cwb_setchunk.C:74
TString olstfname
Definition: cwb_setchunk.C:114
TString cwb_merge_label
Definition: cwb_setchunk.C:28
char cmd[1024]
Definition: cwb_setchunk.C:24
Long_t mt
Definition: cwb_setchunk.C:21
int estat
simulation
Definition: cwb_eced.C:26
sprintf(iwfname,"wave_%s.%s.root", data_label, cwb_merge_label.Data())
Long_t id
Definition: cwb_setchunk.C:21
TString owfname
Definition: cwb_setchunk.C:73