/[PAMELA software]/DarthVader/TrackerLevel2/src/TrkProcess.cpp
ViewVC logotype

Diff of /DarthVader/TrackerLevel2/src/TrkProcess.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2 by pam-fi, Tue May 30 16:30:37 2006 UTC revision 1.17 by pam-ts, Wed Jun 4 07:57:04 2014 UTC
# Line 11  using namespace std; Line 11  using namespace std;
11  TrkProcess::TrkProcess(){  TrkProcess::TrkProcess(){
12            
13      idrun = 0;      idrun = 0;
14  //    DEBUG = false;  //    dbg_mode.SetNone();
15  //    VERBOSE = false;      get1  = 0;
16      dbg_mode.SetNone();      full1 = 0;
17      get1 = 0;      geth  = 0;
18      get2 = 1;      get2  = 1;
19        gete  = 1;
20        getn  = 1;
21        extAlgID = 202;
22      standalone = false;      standalone = false;
23      frame2 = "root";      frame2 = "root";
24      frame1 = "hbook";      frame1 = "root";
25        frameh = "root";
26        framee = "root";
27      outdir =  gSystem->WorkingDirectory();      outdir =  gSystem->WorkingDirectory();
28      pfolder = "/TrackerFolder";      pfolder = "/TrackerFolder";
29      if      (!frame2.CompareTo("root", TString::kIgnoreCase))  ifroot2 = true;                if      (!frame2.CompareTo("root", TString::kIgnoreCase))  ifroot2 = true;          
# Line 27  TrkProcess::TrkProcess(){ Line 32  TrkProcess::TrkProcess(){
32      if      (!frame1.CompareTo("root", TString::kIgnoreCase))  ifroot1 = true;                if      (!frame1.CompareTo("root", TString::kIgnoreCase))  ifroot1 = true;          
33      else if (!frame1.CompareTo("hbook", TString::kIgnoreCase)) ifroot1 = false;      else if (!frame1.CompareTo("hbook", TString::kIgnoreCase)) ifroot1 = false;
34    
35        if      (!frameh.CompareTo("root", TString::kIgnoreCase))  ifrooth = true;          
36        else if (!frameh.CompareTo("hbook", TString::kIgnoreCase)) ifrooth = false;
37    
38      file1 = "";      file1 = "";
39      file2 = "";      file2 = "";
40            
41      ostatus = 0;      ostatus = 0;
42    
43        npar = 0;
44    
45        nskip = 0;
46    
47        watch = false;
48    
49    //     TrkParams::SetTrackingMode();
50    //     TrkParams::SetPrecisionFactor();
51    //     TrkParams::SetStepMin();  
52        TrkParams::SetMiniDefault();
53        TrkParams::SetPFA();
54  };  };
55                    
56  /**  /**
# Line 43  TrkProcess::TrkProcess(ULong64_t run, TF Line 63  TrkProcess::TrkProcess(ULong64_t run, TF
63      idrun = run;      idrun = run;
64  //    DEBUG = false;  //    DEBUG = false;
65  //    VERBOSE = false;  //    VERBOSE = false;
66      dbg_mode.SetWarning();  //    dbg_mode.SetWarning();
67      get1 = 0;      get1  = 0;
68        full1 = 0;
69      get2 = 1;      get2 = 1;
70        geth = 0;
71        gete = 1;
72        getn = 1;
73        extAlgID = 202;
74      standalone = false;      standalone = false;
75      frame2 = "root";      frame2 = "root";
76      frame1 = "hbook";      frame1 = "root";
77      ifroot1 = false;      frameh = "root";
78      ifroot2 = true;      framee = "root";
79        pfolder = "/TrackerFolder";
80      file1 = "";      file1 = "";
81      if(f2->IsOpen()){      if(f2->IsOpen()){
82          file2  = f2->GetPath();          file2  = f2->GetPath();
 //      TString temp = file2(0,file2.Last(':'));  
 //      outdir = temp(0,temp.Last('/'));  
83          outdir = gSystem->DirName(gSystem->DirName(file2));          outdir = gSystem->DirName(gSystem->DirName(file2));
84  // check if the indicated output directory exists          // check if the indicated output directory exists
85          FileStat_t t;          FileStat_t t;
86          if( gSystem->GetPathInfo(outdir.Data(),t) )throw -12;          if( gSystem->GetPathInfo(outdir.Data(),t) )throw -12;
87      }else{      }else{
88          file2 = "";              file2 = "";    
89          outdir =  gSystem->WorkingDirectory();          outdir =  gSystem->WorkingDirectory();
90      };      };
     pfolder = "/TrackerFolder";  
91    
92      if      (!frame2.CompareTo("root", TString::kIgnoreCase))  ifroot2 = true;                if      (!frame2.CompareTo("root", TString::kIgnoreCase))  ifroot2 = true;          
93      else if (!frame2.CompareTo("hbook", TString::kIgnoreCase)) ifroot2 =false;      else if (!frame2.CompareTo("hbook", TString::kIgnoreCase)) ifroot2 =false;
# Line 72  TrkProcess::TrkProcess(ULong64_t run, TF Line 95  TrkProcess::TrkProcess(ULong64_t run, TF
95      if      (!frame1.CompareTo("root", TString::kIgnoreCase))  ifroot1 = true;                if      (!frame1.CompareTo("root", TString::kIgnoreCase))  ifroot1 = true;          
96      else if (!frame1.CompareTo("hbook", TString::kIgnoreCase)) ifroot1 =false;      else if (!frame1.CompareTo("hbook", TString::kIgnoreCase)) ifroot1 =false;
97    
98        if      (!frameh.CompareTo("root", TString::kIgnoreCase))  ifrooth = true;          
99        else if (!frameh.CompareTo("hbook", TString::kIgnoreCase)) ifrooth =false;
100    
101      ostatus = 0;      ostatus = 0;
102        
103        npar=0;
104                    
105        nskip = 0;
106    
107        watch = false;
108    
109    //     TrkParams::SetTrackingMode();
110    //     TrkParams::SetPrecisionFactor();
111    //     TrkParams::SetStepMin();  
112        TrkParams::SetMiniDefault();
113        TrkParams::SetPFA();
114    
115  };  };
116  /**  /**
117   * Set processing variables according to input custom parameters   * Set processing variables according to input custom parameters
118   */       */    
119  void TrkProcess::HandleCustomPar(int ncustom, char *vcustom[]){  int TrkProcess::HandleCustomPar(int ncustom, char *vcustom[]){
120    
121      for (int i=0; i< ncustom; i++){      for (int i=0; i< ncustom; i++){
122                    
123          cout << "Handling Parameter " << i+1  << " of " << ncustom << ": "  << vcustom[i] << endl;
124    
125            // -----------------------------------------------------//
126            if (!strcmp(vcustom[i], "--simu")){
127                cout << "Setting DarthVader to use Simulated Data\n";
128                TrkParams::SetSimuFlag(kTRUE);
129                continue;
130            }  
131          // -----------------------------------------------------//          // -----------------------------------------------------//
132          if (!strcmp(vcustom[i], "-processFolder")){          if (!strcmp(vcustom[i], "-processFolder")){
133              if (++i >= ncustom) throw -3;              if (++i >= ncustom) throw -3;
# Line 89  void TrkProcess::HandleCustomPar(int ncu Line 135  void TrkProcess::HandleCustomPar(int ncu
135              continue;              continue;
136          }            }  
137          // -----------------------------------------------------//              // -----------------------------------------------------//    
138          if (!strcmp(vcustom[i], "--get1")){          if (!strcmp(vcustom[i], "--get1") || !strcmp(vcustom[i], "--get-level1") ){
139              get1 = 1;              get1  = 1;  
140                full1 = 0;
141                continue;
142            }  
143            // -----------------------------------------------------//    
144            if (!strcmp(vcustom[i], "--get1-full") || !strcmp(vcustom[i], "--get-level1-full") ){
145                get1  = 1;      
146                full1 = 1;
147                continue;
148            }  
149            // -----------------------------------------------------//    
150            if (!strcmp(vcustom[i], "--geth") || !strcmp(vcustom[i], "--get-hough") ){
151                geth = 1;
152              continue;              continue;
153          }            }  
154          // -----------------------------------------------------//              // -----------------------------------------------------//    
155          if (!strcmp(vcustom[i], "--dontget2")){  //      if (!strcmp(vcustom[i], "--dontget2") ||!strcmp(vcustom[i], "--dontget-level2") ){
156              get2 = 0;  //          get2 = 0;
157    //          gete = 0;
158    //          getn = 0;
159    //          continue;
160    //      }  
161            // -----------------------------------------------------//    
162            if (!strcmp(vcustom[i], "--dontgete") ||!strcmp(vcustom[i], "--dontget-exttrack") ){
163                gete = 0;
164                continue;
165            }  
166            // -----------------------------------------------------//    
167            if (!strcmp(vcustom[i], "-extalg")){
168                if (++i >= ncustom) throw -3;
169                gete = 1;      
170                get2 = 1;      
171                extAlgID = atoi(vcustom[i]);
172                continue;
173            }  
174            // -----------------------------------------------------//    
175            if (!strcmp(vcustom[i], "--dontgetn") ||!strcmp(vcustom[i], "--dontget-nuclei") ){
176                getn = 0;
177              continue;              continue;
178          }            }  
179          // -----------------------------------------------------//              // -----------------------------------------------------//    
# Line 110  void TrkProcess::HandleCustomPar(int ncu Line 188  void TrkProcess::HandleCustomPar(int ncu
188              file1 = vcustom[i];              file1 = vcustom[i];
189              continue;              continue;
190          }            }  
191    //      // -----------------------------------------------------//    
192    //      if (!strcmp(vcustom[i], "-frame1")){
193    //          if (++i >= ncustom)throw -3;
194    //          get1 = 1;
195    //          frame1 = vcustom[i];                                                
196    //          continue;
197    //      }  
198    //      // -----------------------------------------------------//    
199    //      if (!strcmp(vcustom[i], "-frame2")){
200    //          if (++i >= ncustom)throw -3;
201    //          get2 = 1;
202    //          frame2 = vcustom[i];
203    //          continue;
204    //      }  
205    //      // -----------------------------------------------------//    
206    //      if (!strcmp(vcustom[i], "-framee")){
207    //          if (++i >= ncustom)throw -3;
208    //          gete = 1;
209    //          framee = vcustom[i];
210    //          continue;
211    //      }  
212          // -----------------------------------------------------//              // -----------------------------------------------------//    
213          if (!strcmp(vcustom[i], "-frame1")){          if (!strcmp(vcustom[i], "-pfa")){
214              if (++i >= ncustom)throw -3;              if (++i >= ncustom)throw -3;
215              get1 = 1;              TrkParams::SetPFA(atoi(vcustom[i]));
216              frame1 = vcustom[i];                                                              continue;
217            }  
218            // -----------------------------------------------------//    
219            if (!strcmp(vcustom[i], "-skip")){
220                if (++i >= ncustom)throw -3;
221                nskip = atoi(vcustom[i]);
222              continue;              continue;
223          }            }  
224          // -----------------------------------------------------//              // -----------------------------------------------------//    
225          if (!strcmp(vcustom[i], "-frame2")){          if ( atoi(vcustom[i]) < 0){
226              if (++i >= ncustom)throw -3;              if (++i >= ncustom)throw -3;
227              get2 = 1;              partype[npar]=-1*atoi(vcustom[i-1]);
228              frame2 = vcustom[i];              parpath[npar]=vcustom[i];
229                npar++;
230              continue;              continue;
231          }            }  
232          // -----------------------------------------------------//              // -----------------------------------------------------//    
233          if (!strcmp(vcustom[i], "--verbose") || !strcmp(vcustom[i], "-v")){          if (!strcmp(vcustom[i], "--verbose") || !strcmp(vcustom[i], "-v")){
234  //          VERBOSE = true;              TrkParams::SetVerboseMode();
235              this->SetVerboseMode();              continue;
236            }
237            // -----------------------------------------------------//    
238            if (!strcmp(vcustom[i], "--warning") || !strcmp(vcustom[i], "-w")){
239                TrkParams::SetWarningMode();
240                continue;
241            }
242            // -----------------------------------------------------//    
243            if (!strcmp(vcustom[i], "--help") || !strcmp(vcustom[i], "-h")){
244                PrintHelp();
245                return 1;
246            }
247            // -----------------------------------------------------//    
248            if (!strcmp(vcustom[i], "--watch") ){
249                watch = true;
250              continue;              continue;
251          }          }
252          // -----------------------------------------------------//              // -----------------------------------------------------//    
253          else if (!strcmp(vcustom[i], "--debug") || !strcmp(vcustom[i], "-d")){          else if (!strcmp(vcustom[i], "--debug") || !strcmp(vcustom[i], "-d")){
254  //          DEBUG = true;              TrkParams::SetDebugMode();
             this->SetDebugMode();  
255              continue;              continue;
256          };          };
257      }        }  
258                        
 //    dbg_.debug   = DEBUG;  
 //    dbg_.verbose = VERBOSE;  
       
259      if      (!frame2.CompareTo("root", TString::kIgnoreCase))  ifroot2 = true;                if      (!frame2.CompareTo("root", TString::kIgnoreCase))  ifroot2 = true;          
260      else if (!frame2.CompareTo("hbook", TString::kIgnoreCase)) ifroot2 =false;      else if (!frame2.CompareTo("hbook", TString::kIgnoreCase)) ifroot2 =false;
261      else    throw -201;      else    throw -201;
# Line 148  void TrkProcess::HandleCustomPar(int ncu Line 263  void TrkProcess::HandleCustomPar(int ncu
263      if      (!frame1.CompareTo("root", TString::kIgnoreCase))  ifroot1 = true;                if      (!frame1.CompareTo("root", TString::kIgnoreCase))  ifroot1 = true;          
264      else if (!frame1.CompareTo("hbook", TString::kIgnoreCase)) ifroot1 =false;      else if (!frame1.CompareTo("hbook", TString::kIgnoreCase)) ifroot1 =false;
265      else    throw -201;      else    throw -201;
266                
267      if(get1){      if      (!frameh.CompareTo("root", TString::kIgnoreCase))  ifrooth = true;          
268          TString filety;      else if (!frameh.CompareTo("hbook", TString::kIgnoreCase)) ifrooth =false;
269          if      ( ifroot1)  filety=".root";                  else    throw -201;
270          else if (!ifroot1)  filety=".rz";  
271          else    throw -200;      if      (!framee.CompareTo("root", TString::kIgnoreCase))  ifroote = true;          
272  //      file1 = outdir + "/"+ pfolder + "/" + file2(file2.Last('/')+1,file2.Last('.')) + ".Level1" + filety;      else if (!framee.CompareTo("hbook", TString::kIgnoreCase)) ifroote =false;
273  //      cout << p->file1 << endl;      else    throw -201;
 //      TString path = gSystem->DirName(p->file1);  
 //      FileStat_t t;  
 //      // check if processFolder directory exists, and possibly create it  
 //      if( gSystem->GetPathInfo(path.Data(),t) ) {  
 //          if( gSystem->MakeDirectory(path.Data()) == -1)throw -13;  
 //      };  
 //      // if it does, open/create teh putput file  
274    
275      };      if(get1 && !get2)full1=true;
276    
277      ostatus = 0;      ostatus = 0;
278    
279        return 0;
280    
281  };  };
282  /**  /**
283   * \brief Process Level0 event   * \brief Process Level0 event
# Line 178  void TrkProcess::HandleCustomPar(int ncu Line 288  void TrkProcess::HandleCustomPar(int ncu
288  void TrkProcess::ProcessEvent(TrkLevel0 *l0_event){  void TrkProcess::ProcessEvent(TrkLevel0 *l0_event){
289    
290      // fill Level0 common from Level0 object      // fill Level0 common from Level0 object
291      l0_event->GetCommonVar(&level0event_);      l0_event->GetLevel0Struct();
   
292      // process the event Level0->Level1->Level2      // process the event Level0->Level1->Level2
293      int F77err = 0;      int F77err = 0;
294      //      //
295      reductionflight_(&F77err);      reductionflight_(&F77err);
296      if(F77err < 0)throw F77err;      if(F77err < 0)throw F77err;
     else if(F77err > 0 && WarningMode())cout<<" WARNING ("<<F77err<<") - TrkCore - Level1 reduction (CN computation failure, ...)"<<endl;  
297      //      //
298      if(get2) analysisflight_();      if(get2) analysisflight_();
 //    if(F77err < 0)throw F77err;  
 //    else if(F77err > 0 && WarningMode())cout<<" WARNING ("<<F77err<<") - TrkCore - @ Level2 reduction "<<endl;  
299      //      //
300    
301      ostatus = F77err;      ostatus = F77err;
302            
303  };  };
304                                    
305  void TrkProcess::Dump(){  void TrkProcess::Dump(){
306        cout << endl;
307        cout << " |-------------------------------------| "<<endl;
308        cout << "   tracker-processing input-parameters   "<< endl;
309        cout << " |-------------------------------------| "<<endl;
310        cout << "   idRun            " << idrun << endl;
311        cout << "                    (skip " << nskip <<" events)"<< endl;    
312        cout << "   get level1       " << get1 << endl;
313        cout << "   full level1      " << full1 << endl;
314        cout << "   get level2       " << get2 << endl;
315        cout << "   get hough        " << geth << endl;
316        cout << "   get ext.tracking " << gete << endl;
317        if(gete)
318        cout << "   ext.tracking alg " << extAlgID << endl;
319        cout << "   get nuclei       " << getn << endl;
320    //    cout << " frame1           " << frame1 << endl;
321    //    cout << " frame2           " << frame2 << endl;
322    //    cout << " frameh           " << frame2 << endl;
323    //    cout << " file1            " << file1 << endl;
324        cout << "   output file      " << file2 << endl;
325    //    cout << " outdir           " << outdir << endl;
326    //    cout << " process folder   " << pfolder << endl;
327    //    cout << " standalone mode  " << standalone << endl;
328        for(int i=0; i<npar; i++)
329            cout << "   force loading parameters of type "<<partype[i]<<" from <--- "<<parpath[i]<<endl;
330        cout<<endl;
331    
332      cout <<endl<< "Tracker process parameters: "<< endl;  //     cout << " debug mode      warning " << dbg_mode.warning << endl;
333      cout << " idRun           " << idrun << endl;  //     cout << " debug mode      verbose " << dbg_mode.verbose << endl;
334      cout << " get1            " << get1 << endl;  //     cout << " debug mode      debug   " << dbg_mode.debug << endl << endl;
     cout << " get2            " << get2 << endl;  
     cout << " frame1          " << frame1 << endl;  
     cout << " frame2          " << frame2 << endl;  
     cout << " file1           " << file1 << endl;  
     cout << " file2           " << file2 << endl;  
     cout << " outdir          " << outdir << endl;  
     cout << " process folder  " << pfolder << endl;  
     cout << " standalone mode " << standalone << endl;  
     cout << " debug mode      warning " << dbg_mode.warning << endl;  
     cout << " debug mode      verbose " << dbg_mode.verbose << endl;  
     cout << " debug mode      debug   " << dbg_mode.debug << endl << endl;  
335            
336  }  }
337    
338    void TrkProcess::PrintHelp(){
339    
340        printf( "\n\n +TRK [ options ] \n \n");
341    //    printf( "\n --version          : Print tracker software version and exit ");      
342        printf( "Options:");
343        printf( "\n --help, -h                     : Print this help and exit ");  
344    //    printf( "\n -idRun RUN         : ID number of the run to be processed (for reprocessing RUN=0) \n");
345    //    printf( "\n -outDir OUTDIR     : Path where to put the LEVEL2 output                    [default ./ ] ");
346    //    printf( "\n -processFolder DIR   : Directory (relative to OUTDIR) for other output files  [default TrackerFolder/ ] ");
347    //    printf( "\n -processFile FILE  : Name of the LEVEL2 output file                         [default RUN.Level2.root]");
348    //    printf( "\n -processFile1 FILE   : Name of the LEVEL1 output file                         [default RUN.Level1.rz]");
349    //    printf( "\n -frame1 FRAME        : type of output for LEVEL1, root/hbook                  [default hbook ] ");
350    //    printf( "\n -frame2 FRAME        : type of output for LEVEL2, root/hbook                  [default root  ] ");            
351        printf( "\n --get1, --get-level1           : get LEVEL1 output (store only cluster associated to tracks) [default (no LEVEL1 output) ]  ");
352        printf( "\n --get1-full, --get-level1-full : get LEVEL1 output (store all clusters)                      [default (no LEVEL1 output) ]  ");
353        printf( "\n --dontget2, --dontget-level2   : do not get LEVEL2 output                                    [default (get LEVEL2 output)]");
354        printf( "\n --dontgete, --dontget-exttrack : do not get ext.tracking output                              [default (ext.algorythm 202)]");
355        printf( "\n --dontgetn, --dontget-nuclei   : do not get nuclei cleaned tracks                            [default (get nuclei output)]");
356        printf( "\n --extalg ID                    : apply ext.tracking algorythm n.ID                           [default (ID=202) ]  ");
357        printf( "\n --geth,, --get-hough           : get Hough-transform output                                  [default (no Hough-t. output) ]  ");
358        printf( "\n -pfa PFAID                     : type of output for LEVEL2, root/hbook                       [default 14 (COG4)  ] ");          
359        printf( "\n -N PATH                        : load parameter of type N=1,2... from PATH                   [default (from DB)  ] ");  
360        printf( "\n --verbose, -v                  : verbose mode ");      
361        printf( "\n --debug, -d                    : debug mode ");
362        printf( "\n --warning, -w                  : warning mode ");      
363        printf( "\n -skip NEV                      : skip first NEV events from each run ");        
364    //    printf( "\n --standalone, -s   : standalone mode (without RunInfo) ... but it might not work \n");        
365    //    printf( "\n -host HOST         : Name for the host                                      [default mysql://localhost/pamelaprod ]");
366    //    printf( "\n -user USER         : Username for the DB                                    [default anonymous] ");
367    //    printf( "\n -psw  PSW          : Password for the DB                                    [default (none)]\n \n \n");
368        
369    
370    }

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.17

  ViewVC Help
Powered by ViewVC 1.1.23