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

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

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

revision 1.2 by pam-ts, Wed Jun 4 07:57:03 2014 UTC revision 1.5 by pam-ts, Thu Jul 24 12:39:50 2014 UTC
# Line 24  ExtTrkingAlg::ExtTrkingAlg(Int_t id){ Line 24  ExtTrkingAlg::ExtTrkingAlg(Int_t id){
24    
25    _whichAlg = id;    _whichAlg = id;
26    
   SetDebug(false);  
27    
28      SetDebug(true);
29        
30    if(id == 0){    if(id == 0){
31    //    if(_debug){
32      cout << "ExtTrkingAlg::ExtTrkingAlg("<<id<<")"<<endl;        cout << "ExtTrkingAlg::ExtTrkingAlg("<<id<<")"<<endl;
33      cout << "Creating array of TrkTrack objects "<<endl;  //      cout << "Creating array of TrkTrack objects "<<endl;
34      cout << "WARNING!!! tracking not accurate!! bug not fixed yet... "<<endl;        cout << "WARNING!!! tracking not accurate!! bug not fixed yet... "<<endl;
35        //    }
36      _trkArray = new TClonesArray("TrkTrack");      _trkArray = new TClonesArray("TrkTrack");
37      //      //
38      _sel_nClstrMAX  = 20. ; // selection parameter: maximum number of cluster      _sel_nClstrMAX  = 20. ; // selection parameter: maximum number of cluster
# Line 55  ExtTrkingAlg::ExtTrkingAlg(Int_t id){ Line 55  ExtTrkingAlg::ExtTrkingAlg(Int_t id){
55    }else if ( (id >= 100 && id < 144) ||    }else if ( (id >= 100 && id < 144) ||
56               (id >= 200 && id < 244) ||               (id >= 200 && id < 244) ||
57               false){ //add n calo planes               false){ //add n calo planes
58    //     if(_debug){
59      cout << "ExtTrkingAlg::ExtTrkingAlg("<<id<<")"<<endl;        cout << "ExtTrkingAlg::ExtTrkingAlg("<<id<<")"<<endl;
60      cout << "Creating array of ExtTrack objects "<<endl;  //       cout << "Creating array of ExtTrack objects "<<endl;
61    //     }
62      _trkArray = new TClonesArray("ExtTrack");      _trkArray = new TClonesArray("ExtTrack");
63      //      //
64      _alg_nClFixX   = 3.;     // algorythm parameter: n.hits required on X view      _alg_nClFixX   = 3.;     // algorythm parameter: n.hits required on X view
# Line 70  ExtTrkingAlg::ExtTrkingAlg(Int_t id){ Line 71  ExtTrkingAlg::ExtTrkingAlg(Int_t id){
71      if((int)(id/200)==1)_alg_nViewCal = id - 200;  // algorythm parameter: n.calorimeter planes included      if((int)(id/200)==1)_alg_nViewCal = id - 200;  // algorythm parameter: n.calorimeter planes included
72    
73      //      //
74      _sel_nClstrMAX  = 10. ; // selection parameter: maximum number of cluster      _sel_nClstrMAX  = 15.;//10. ; // selection parameter: maximum number of cluster
75      _sel_nPlaneXMIN = (_alg_nViewCal ? 2 : 3);   // selection parameter: minimum number of hit x-views      _sel_nPlaneXMIN = (_alg_nViewCal ? 2 : 3);   // selection parameter: minimum number of hit x-views
76      _sel_nPlaneYMIN = 2 - (int)(_alg_nViewCal+1)/2 ;   // selection parameter: minimum number of hit y-views      _sel_nPlaneYMIN = 2 - (int)(_alg_nViewCal+1)/2 ;   // selection parameter: minimum number of hit y-views
77    
# Line 95  ExtTrkingAlg::ExtTrkingAlg(Int_t id){ Line 96  ExtTrkingAlg::ExtTrkingAlg(Int_t id){
96      // _extTrack->SetZ(4,ZTRK5);      // _extTrack->SetZ(4,ZTRK5);
97      // _extTrack->SetZ(5,ZTRK6);      // _extTrack->SetZ(5,ZTRK6);
98            
99    
100    
101      _caloStripRoto.clear();      _caloStripRoto.clear();
102      for(int iv=0; iv<_alg_nViewCal; iv++){ //loop over calorimater tracking planes      for(int iv=0; iv<_alg_nViewCal; iv++){ //loop over calorimater tracking planes
103        for(int is=0; is<9; is++){ //loop over calorimeter sensors        for(int is=0; is<9; is++){ //loop over calorimeter sensors
# Line 106  ExtTrkingAlg::ExtTrkingAlg(Int_t id){ Line 109  ExtTrkingAlg::ExtTrkingAlg(Int_t id){
109      //------------------------------------------      //------------------------------------------
110      // read alignment parameters      // read alignment parameters
111      //------------------------------------------      //------------------------------------------
112      cout << "Reading calorimeter alignment parameters"<<endl;      if(_debug) cout << "Reading calorimeter alignment parameters"<<endl;
113      const char *pamca = gSystem->Getenv("PAM_CALIB");      const char *pamca = gSystem->Getenv("PAM_CALIB");
114      TString filep = "/trk-param/align_param_calo-0/CaloAlignParams.txt";      TString filep = "/trk-param/align_param_calo-0/CaloAlignParams.txt";
115      filep.Prepend(pamca);      filep.Prepend(pamca);
116    
117        if(_debug)cout << " --->  "<<filep.Data()<<endl;
118      std::fstream fs;      std::fstream fs;
119      fs.open (filep.Data(), std::fstream::in );      fs.open (filep.Data(), std::fstream::in );
120      do{  
121        if(!fs.is_open()){
122            
123            cout <<" WARNING!!!!!!!!!!!! error opening file "<<filep.Data()<<endl;
124            cout <<" No alignment parameters loaded "<<endl;
125        }
126    //    do{
127        while(fs.is_open() && !fs.eof()){
128    
129          int view,plane,sensor;          int view,plane,sensor;
130          float par[5],err[5];          float par[5],err[5];
131          fs>>view >> plane>> sensor;          fs>>view >> plane>> sensor;
# Line 123  ExtTrkingAlg::ExtTrkingAlg(Int_t id){ Line 136  ExtTrkingAlg::ExtTrkingAlg(Int_t id){
136    
137    
138              int index = (plane*2+1-view)*9 + sensor;              int index = (plane*2+1-view)*9 + sensor;
139              cout<<index<<" >> ";              if(_debug){
140              cout<<view << " "<<plane<<" "<<sensor<<"          ";                cout<<index<<" >> ";
141              for(int i=0; i<5; i++)cout<<setw(10)<<par[i]<<" "<<setw(10)<<err[i]<<" ";                cout<<view << " "<<plane<<" "<<sensor<<"          ";
142              cout<<endl;                for(int i=0; i<5; i++)cout<<setw(10)<<par[i]<<" "<<setw(10)<<err[i]<<" ";
143                  cout<<endl;
144                }
145    
146              _caloStripRoto[index].SetAligParams__fPitch(par[0]);              _caloStripRoto[index].SetAligParams__fPitch(par[0]);
147              _caloStripRoto[index].SetAligParams__shift(par+1);              _caloStripRoto[index].SetAligParams__shift(par+1);
# Line 135  ExtTrkingAlg::ExtTrkingAlg(Int_t id){ Line 150  ExtTrkingAlg::ExtTrkingAlg(Int_t id){
150  //          _caloStripRoto[index].SetView(view);  //          _caloStripRoto[index].SetView(view);
151  //          _caloStripRoto[index].SetPlane(plane);  //          _caloStripRoto[index].SetPlane(plane);
152    
153          }          };
154      }while(!fs.eof());  //    }while(!fs.eof());
155        };
156      fs.close();      fs.close();
157    
158      // -----------------------------------      // -----------------------------------
# Line 156  ExtTrkingAlg::ExtTrkingAlg(Int_t id){ Line 172  ExtTrkingAlg::ExtTrkingAlg(Int_t id){
172    
173      for(int ip =0 ; ip<_extTrack->nplanes; ip++ )_extTrack->SetZ(ip,_zMech[ip]);      for(int ip =0 ; ip<_extTrack->nplanes; ip++ )_extTrack->SetZ(ip,_zMech[ip]);
174    
175      cout <<" Extended-track Z-coordinates: "<<endl;      if ( _debug ){
176      for(int ip =0 ; ip<_extTrack->nplanes; ip++ )cout <<  _extTrack->zm[ip]<<endl;        cout <<" Extended-track Z-coordinates: "<<endl;
177              for(int ip =0 ; ip<_extTrack->nplanes; ip++ )cout <<  _extTrack->zm[ip]<<endl;
178        }
179    }else{    }else{
180            if ( _debug ){
181      cout << "ExtTrkingAlg(Int_t id) -- algorythm id="<<id<<" not valid "<<endl;        cout << "ExtTrkingAlg(Int_t id) -- algorythm id="<<id<<" not valid "<<endl;
182      cout << "--> Track array not created "<<endl;        cout << "--> Track array not created "<<endl;
183        }
184      _sel_nClstrMAX  = 0.;      _sel_nClstrMAX  = 0.;
185      _sel_nPlaneXMIN = 0.;        _sel_nPlaneXMIN = 0.;  
186      _sel_nPlaneYMIN = 0.;        _sel_nPlaneYMIN = 0.;  
# Line 277  TClonesArray* ExtTrkingAlg::GetTrackArra Line 295  TClonesArray* ExtTrkingAlg::GetTrackArra
295   */   */
296  Bool_t ExtTrkingAlg::CheckEvent(){  Bool_t ExtTrkingAlg::CheckEvent(){
297    
298    if(!_trk_l2)return true;    if(!_trk_l1)return false;
299      TrkLevel1 *trkl1 = _trk_l1;//event->GetTrkLevel1();
   TrkLevel2 *trkl2 = _trk_l2;//event->GetTrkLevel2();  
300    int nClstrMAX  = _sel_nClstrMAX; //maximum number of cluster    int nClstrMAX  = _sel_nClstrMAX; //maximum number of cluster
301    int nPlaneXMIN = _sel_nPlaneXMIN;    /////////////////////////////////////////////////////////////////////
302    int nPlaneYMIN = _sel_nPlaneYMIN;    /// dump selection
303      /////////////////////////////////////////////////////////////////////
304      if(_debug){
305        cout << " n.clusters "<<trkl1->nclstr()<<endl;      
306      }  
307      if(trkl1->nclstr() > nClstrMAX) return false;
308    /////////////////////////////////////////////////////////////////////    /////////////////////////////////////////////////////////////////////
309    /// count number of hit planes    /// count number of hit planes
310    /////////////////////////////////////////////////////////////////////    /////////////////////////////////////////////////////////////////////
311      int nPlaneXMIN = _sel_nPlaneXMIN;
312      int nPlaneYMIN = _sel_nPlaneYMIN;
313    int nHitX[] = {0,0,0,0,0,0};    int nHitX[] = {0,0,0,0,0,0};
314    int nHitY[] = {0,0,0,0,0,0};    int nHitY[] = {0,0,0,0,0,0};
315    for(int ix=0; ix<trkl2->nclsx(); ix++)nHitX[trkl2->GetSingletX(ix)->plane-1]++;        for(int ic=0; ic<trkl1->nclstr(); ic++){      
316    for(int iy=0; iy<trkl2->nclsy(); iy++)nHitY[trkl2->GetSingletY(iy)->plane-1]++;        if      (trkl1->GetCluster(ic)->IsX() ) nHitX[trkl1->GetCluster(ic)->GetPlane()-1]++;    
317          else if (trkl1->GetCluster(ic)->IsY() ) nHitY[trkl1->GetCluster(ic)->GetPlane()-1]++;  
318      }
319    /////////////////////////////////////////////////////////////////////    /////////////////////////////////////////////////////////////////////
320    /// set minimum condition 3x+2y    /// set minimum condition 3x+2y
321    /////////////////////////////////////////////////////////////////////    /////////////////////////////////////////////////////////////////////
# Line 297  Bool_t ExtTrkingAlg::CheckEvent(){ Line 323  Bool_t ExtTrkingAlg::CheckEvent(){
323    for(int ip=0; ip<6; ip++)if(nHitX[ip])nPlaneX++;          for(int ip=0; ip<6; ip++)if(nHitX[ip])nPlaneX++;      
324    int nPlaneY=0;    int nPlaneY=0;
325    for(int ip=0; ip<6; ip++)if(nHitY[ip])nPlaneY++;          for(int ip=0; ip<6; ip++)if(nHitY[ip])nPlaneY++;      
326    
327    /////////////////////////////////////////////////////////////////////    /////////////////////////////////////////////////////////////////////
328    /// dump selection    /// dump selection
329    /////////////////////////////////////////////////////////////////////    /////////////////////////////////////////////////////////////////////
330    if(_debug){    if(_debug){
331      cout << " n.tracks "<<trkl2->GetNTracks()<<endl;        cout << " n.x-hit planes  "<<nPlaneX<<endl;
332      cout << " n.x-singles "<<trkl2->nclsx()<<endl;        cout << " n.y-hit planes  "<<nPlaneY<<endl;
333      cout << " n.y-singles "<<trkl2->nclsy()<<endl;    }  
334      cout << " n.x-planes with singles "<<nPlaneX<<endl;    if( nPlaneX<nPlaneXMIN ) return false;
335      cout << " n.y-planes with singles "<<nPlaneY<<endl;    if( nPlaneY<nPlaneYMIN ) return false;
336    }  
337    
338    //   if(!_trk_l2)return true;
339    //   TrkLevel2 *trkl2 = _trk_l2;//event->GetTrkLevel2();
340    //   /////////////////////////////////////////////////////////////////////
341    //   /// dump selection
342    //   /////////////////////////////////////////////////////////////////////
343    //   if(_debug){
344    //     cout << " n.tracks "<<trkl2->GetNTracks()<<endl;
345    //     cout << " n.x-singles "<<trkl2->nclsx()<<endl;
346    //     cout << " n.y-singles "<<trkl2->nclsy()<<endl;
347    //     cout << " n.y-singles "<<trkl2->nclsy()<<endl;
348    //   }
349    //   if(trkl2->nclsy()+trkl2->nclsx() > nClstrMAX) return false;
350    //   /////////////////////////////////////////////////////////////////////
351    //   /// count number of hit planes
352    //   /////////////////////////////////////////////////////////////////////
353    //   int nPlaneXMIN = _sel_nPlaneXMIN;
354    //   int nPlaneYMIN = _sel_nPlaneYMIN;
355    //   int nHitX[] = {0,0,0,0,0,0};
356    //   int nHitY[] = {0,0,0,0,0,0};
357    //   for(int ix=0; ix<trkl2->nclsx(); ix++)nHitX[trkl2->GetSingletX(ix)->plane-1]++;    
358    //   for(int iy=0; iy<trkl2->nclsy(); iy++)nHitY[trkl2->GetSingletY(iy)->plane-1]++;
359    //   /////////////////////////////////////////////////////////////////////
360    //   /// set minimum condition 3x+2y
361    //   /////////////////////////////////////////////////////////////////////
362    //   int nPlaneX=0;
363    //   for(int ip=0; ip<6; ip++)if(nHitX[ip])nPlaneX++;  
364    //   int nPlaneY=0;
365    //   for(int ip=0; ip<6; ip++)if(nHitY[ip])nPlaneY++;  
366    //   /////////////////////////////////////////////////////////////////////
367    //   /// dump selection
368    //   /////////////////////////////////////////////////////////////////////
369    //   if(_debug){
370    //     cout << " n.x-planes with singles "<<nPlaneX<<endl;
371    //     cout << " n.y-planes with singles "<<nPlaneY<<endl;
372    //   }
373    ////////////////////////////////////////////////////////////////////////    ////////////////////////////////////////////////////////////////////////
374    //    //
375    // check condition for retracking    // check condition for retracking
376    //    //
377    ////////////////////////////////////////////////////////////////////////    ////////////////////////////////////////////////////////////////////////
378    if(trkl2->GetNTracks()==0 && nPlaneX<nPlaneXMIN) return false;  //   if(trkl2->GetNTracks()==0 && nPlaneX<nPlaneXMIN) return false;
379    if(trkl2->GetNTracks()==0 && nPlaneY<nPlaneYMIN) return false;  //   if(trkl2->GetNTracks()==0 && nPlaneY<nPlaneYMIN) return false;
   if(trkl2->nclsy()+trkl2->nclsx() > nClstrMAX) return false;  
380    
381    return true;    return true;
382    
# Line 479  void ExtTrkingAlg::ProcessEvent0(Bool_t Line 541  void ExtTrkingAlg::ProcessEvent0(Bool_t
541    }//end iterations    }//end iterations
542        
543    
544    if( trackCandidates[mapIndex].size() > nTrackMAX ){    if( trackCandidates[mapIndex].size() > (uint)nTrackMAX ){ // EM,  warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
545      if(_debug)cout << "n.candidates "<<trackCandidates[mapIndex].size()<<" > "<<nTrackMAX<<endl;      if(_debug)cout << "n.candidates "<<trackCandidates[mapIndex].size()<<" > "<<nTrackMAX<<endl;
546      return;//to many candidates      return;//to many candidates
547    }    }
# Line 491  void ExtTrkingAlg::ProcessEvent0(Bool_t Line 553  void ExtTrkingAlg::ProcessEvent0(Bool_t
553        cout << " >> ";        cout << " >> ";
554        cout << " X: ";        cout << " X: ";
555        for(int ip=0; ip<6; ip++)        for(int ip=0; ip<6; ip++)
556          if(trackCand.GetClusterX_ID(ip)>=0)cout << trackCand.GetClusterX_ID(ip)<<":"<<trackCand.GetSensor(ip)<<"|";          if(trackCand.GetClusterX_ID(ip)>=0)cout << trackCand.GetClusterX_ID(ip)<<":"<<trackCand.GetSensor(ip)<<"|";
557        cout << " Y: ";        cout << " Y: ";
558        for(int ip=0; ip<6; ip++)        for(int ip=0; ip<6; ip++)
559          if(trackCand.GetClusterY_ID(ip)>=0)cout << trackCand.GetClusterY_ID(ip)<<":"<<trackCand.GetSensor(ip)<<"|";              if(trackCand.GetClusterY_ID(ip)>=0)cout << trackCand.GetClusterY_ID(ip)<<":"<<trackCand.GetSensor(ip)<<"|";    
560        cout << endl;        cout << endl;
561      }      }
562    }    }
# Line 1293  bool ExtTrkingAlg::EvaluateClusterPositi Line 1355  bool ExtTrkingAlg::EvaluateClusterPositi
1355    //  int plane = 6 + cluster.view;            //0...21    //  int plane = 6 + cluster.view;            //0...21
1356    int plane = (int)(cluster.view / 2 );    //0...21    int plane = (int)(cluster.view / 2 );    //0...21
1357    int ladder = (int)(cluster.coordPU / 32);//0...2    int ladder = (int)(cluster.coordPU / 32);//0...2
1358    int view = cluster.view;//0...43    //  int view = cluster.view;//0...43    // EM, unused variable
1359    bool isX = (cluster.view)%2;    bool isX = (cluster.view)%2;
1360    bool isY = !isX;    bool isY = !isX;
1361        
# Line 1442  bool ExtTrkingAlg::EvaluateClusterPositi Line 1504  bool ExtTrkingAlg::EvaluateClusterPositi
1504            
1505            int view = cluster.view; //0... 43            int view = cluster.view; //0... 43
1506    
1507            int nW = (int)((view + 1)/2);            //      int nW = (int)((view + 1)/2); // EM, unused variable
1508            float dW = 0.74*factor;//X0            float dW = 0.74*factor;//X0
1509            float dW_cm = 0.26*factor;//cm            float dW_cm = 0.26*factor;//cm
1510            float dSi_cm = 0.; //cm            float dSi_cm = 0.; //cm
# Line 1472  bool ExtTrkingAlg::EvaluateClusterPositi Line 1534  bool ExtTrkingAlg::EvaluateClusterPositi
1534    
1535    }    }
1536    
1537      return true; // EM, warning: no return statement in function returning non-void [-Wreturn-type]
1538  }  }
1539    
1540    
# Line 1762  void ExtTrkingAlg::ProcessEvent1(Bool_t Line 1824  void ExtTrkingAlg::ProcessEvent1(Bool_t
1824    
1825            }            }
1826    
1827            if( trackCandidates[mapIndex].size() > nTrackMAX ){            if( trackCandidates[mapIndex].size() > (uint)nTrackMAX ){ // EM, compilation warning comparison between signed and unsigned
1828              if(_debug)cout << "n.candidates "<<trackCandidates[mapIndex].size()<<" > "<<nTrackMAX<<endl;              if(_debug)cout << "n.candidates "<<trackCandidates[mapIndex].size()<<" > "<<nTrackMAX<<endl;
1829              return;//to many candidates              return;//to many candidates
1830            }            }
# Line 2242  void ExtTrkingAlg::ProcessEvent1(Bool_t Line 2304  void ExtTrkingAlg::ProcessEvent1(Bool_t
2304        // and        // and
2305        // evaluated other track info        // evaluated other track info
2306        // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~          // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  
2307        float VMS[22];VMS[0]=0.;        //      float VMS[22];VMS[0]=0.; // EM, 2245:13: warning: variable ?VMS? set but not used [-Wunused-but-set-variable]
2308        for(int ip=0; ip<NEXTPLANES; ip++){        for(int ip=0; ip<NEXTPLANES; ip++){
2309    
2310          if(!t_track.XGood(ip)&&!t_track.YGood(ip))continue;          if(!t_track.XGood(ip)&&!t_track.YGood(ip))continue;
# Line 2823  void ExtTrkingAlg::ProcessEvent2(Bool_t Line 2885  void ExtTrkingAlg::ProcessEvent2(Bool_t
2885    
2886                        }                        }
2887    
2888                        if( trackCandidates[mapIndex+1].size() > nTrackMAX ){                        if( trackCandidates[mapIndex+1].size() > (uint)nTrackMAX ){ //EM, 2826:50: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
2889                            if(_debug)cout << "n.candidates "<<trackCandidates[mapIndex+1].size()<<" > "<<nTrackMAX<<endl;                            if(_debug)cout << "n.candidates "<<trackCandidates[mapIndex+1].size()<<" > "<<nTrackMAX<<endl;
2890                            return;//to many candidates                            return;//to many candidates
2891                        }                        }
# Line 3292  void ExtTrkingAlg::ProcessEvent2(Bool_t Line 3354  void ExtTrkingAlg::ProcessEvent2(Bool_t
3354                // and                // and
3355                // evaluated other track info                // evaluated other track info
3356                // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~                  // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  
3357                float VMS[22];VMS[0]=0.;                //float VMS[22];VMS[0]=0.;  //EM, 3295:14: warning: variable ?VMS? set but not used [-Wunused-but-set-variable]
3358                for(int ip=0; ip<NEXTPLANES; ip++){                for(int ip=0; ip<NEXTPLANES; ip++){
3359    
3360                    if(!t_track.XGood(ip)&&!t_track.YGood(ip))continue;                    if(!t_track.XGood(ip)&&!t_track.YGood(ip))continue;

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

  ViewVC Help
Powered by ViewVC 1.1.23