CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_6/src/RecoRomanPot/RecoFP420/src/FP420RecoMain.cc

Go to the documentation of this file.
00001 
00002 // File: FP420RecoMain.cc
00003 // Date: 12.2006
00004 // Description: FP420RecoMain for FP420
00005 // Modifications: 
00007 #include <vector>
00008 #include <iostream>
00009 #include "FWCore/ParameterSet/interface/FileInPath.h"
00010 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00011 
00012 #include "RecoRomanPot/RecoFP420/interface/FP420RecoMain.h"
00013 
00014 #include "DataFormats/FP420Cluster/interface/TrackFP420.h"
00015 #include "DataFormats/FP420Cluster/interface/TrackCollectionFP420.h"
00016 #include "DataFormats/FP420Cluster/interface/RecoFP420.h"
00017 #include "DataFormats/FP420Cluster/interface/RecoCollectionFP420.h"
00018 #include "RecoRomanPot/RecoFP420/interface/RecoProducerFP420.h"
00019 
00020 #include "CLHEP/Vector/LorentzVector.h"
00021 #include "CLHEP/Random/RandFlat.h"
00022 #include <math.h>
00023 
00024 using namespace std;
00025 
00026 
00027 FP420RecoMain::FP420RecoMain(const edm::ParameterSet& conf):conf_(conf)  { 
00028   
00029   verbosity   = conf_.getUntrackedParameter<int>("VerbosityLevel");
00030   m_rpp420_f     = conf_.getParameter<double>("RP420f");//mm
00031   m_rpp420_b     = conf_.getParameter<double>("RP420b");//mm
00032   m_zreff          = conf_.getParameter<double>("zreff");//mm
00033   m_zrefb          = conf_.getParameter<double>("zrefb");//mm
00034   dn0                = conf_.getParameter<int>("NumberFP420Detectors");
00035   
00036   if (verbosity > 0) {
00037     std::cout << "FP420RecoMain constructor::" << std::endl;
00038     std::cout << "m_rpp420_f=" << m_rpp420_f << " m_rpp420_b=" << m_rpp420_b << std::endl;
00039     std::cout << "m_zreff=" << m_zreff << " m_zrefb=" <<  m_zrefb<< std::endl;
00040   }
00041     
00042   double eee1=11.;
00043   double eee2=12.;
00044 //  zinibeg_ = (eee1-eee2)/2.;
00045   zinibeg_ = 0.;
00046 //
00047     if (verbosity > 1) {
00048       std::cout << "FP420RecoMain constructor::" << std::endl;
00049       std::cout << " eee1=" << eee1 << " eee2=" << eee2 << " zinibeg =" << zinibeg_ << std::endl;
00050     }
00052       finderParameters_ = new RecoProducerFP420(conf_);
00053 }
00054 
00055 FP420RecoMain::~FP420RecoMain() {
00056   if ( finderParameters_ != 0 ) {
00057     delete finderParameters_;
00058   }
00059 }
00060 
00061 
00062 
00063 void FP420RecoMain::run(edm::Handle<TrackCollectionFP420> &input, std::auto_ptr<RecoCollectionFP420> &toutput, double VtxX, double VtxY, double VtxZ)  
00064 {
00065   // initialization
00066   bool first = true;
00067   //  finderParameters_->clear();
00068   // finderParameters_->setIP( 0., 0., 0. );
00069   std::vector<TrackFP420> rhits;
00070   int restracks = 10;// max # tracks
00071   rhits.reserve(restracks); 
00072   rhits.clear();
00073   
00074   // loop over detunits:
00075   for (int number_detunits=1; number_detunits<dn0; number_detunits++) {
00076     unsigned int StID = number_detunits;
00077     std::vector<RecoFP420> rcollector;
00078     int restracks = 10;// max # tracks
00079     rcollector.reserve(restracks); 
00080     rcollector.clear();
00081     
00083     std::vector<TrackFP420> collector;
00084     collector.clear();
00085     TrackCollectionFP420::Range outputRange;
00086     unsigned int StIDTrack = 1111;
00087     double  z420    = m_rpp420_f;
00088     double  zref1   = m_zreff;
00089     double  zinibeg = zinibeg_;
00090     double  VtxXcur = VtxX;
00091     double  VtxYcur = VtxY;
00092     double  VtxZcur = VtxZ;
00093     if(StID==2)  {
00094       StIDTrack = 2222;
00095       z420    = -m_rpp420_b;
00096       zref1   = -m_zrefb;
00097       zinibeg = -zinibeg_;
00098       //  VtxXcur = -VtxX;
00099       // VtxYcur = -VtxY;
00100       // VtxZcur = -VtxZ;
00101     }
00102     double z1 = z420+zinibeg-VtxZcur;
00103     double z2 = z420+zinibeg+zref1-VtxZcur;
00104     if (verbosity > 1) {
00105       std::cout << "FP420RecoMain: StIDTrack=" << StIDTrack << std::endl;
00106     }
00107     outputRange = input->get(StIDTrack);
00108     //
00109     // fill output in collector vector (for may be sorting? or other checks)
00110     //
00111     TrackCollectionFP420::ContainerIterator sort_begin = outputRange.first;
00112     TrackCollectionFP420::ContainerIterator sort_end = outputRange.second;
00113     //
00114     for ( ;sort_begin != sort_end; ++sort_begin ) {
00115       collector.push_back(*sort_begin);
00116     } // for  sort_begin
00117     if (verbosity > 1) {
00118       std::cout << "FP420RecoMain: track collector.size=" << collector.size() << std::endl;
00119     }
00120     std::vector<TrackFP420>::const_iterator simHitIter = collector.begin();
00121     std::vector<TrackFP420>::const_iterator simHitIterEnd = collector.end();
00122     for (;simHitIter != simHitIterEnd; ++simHitIter) {
00123       const TrackFP420 itrack = *simHitIter;
00124       double x1 = (    itrack.bx()*z1 + (itrack.ax()-VtxXcur)       )*1000.;//um
00125       double y1 = (    itrack.by()*z1 + (itrack.ay()-VtxYcur)       )*1000.;//um
00126       double x2 = (    itrack.bx()*z2 + (itrack.ax()-VtxXcur)    )*1000.;//um
00127       double y2 = (    itrack.by()*z2 + (itrack.ay()-VtxYcur)    )*1000.;//um
00129         if (verbosity == -49) {
00130           std::cout << "==================================================================== " << std::endl;
00131           std::cout << "FP420RecoMain: StID= " << StID << std::endl;
00132           std::cout << "input coord. in mm:  z1= " <<  z1  << std::endl;
00133           std::cout << "input coord. in mm:  z2= " <<  z2  << std::endl;
00134           std::cout << "input:  itrack.bx()= " <<  itrack.bx()  << std::endl;
00135           std::cout << "input:  itrack.ax()= " <<  itrack.ax()  << std::endl;
00136           std::cout << "input:  itrack.by()= " <<  itrack.by()  << std::endl;
00137           std::cout << "input:  itrack.ay()= " <<  itrack.ay()  << std::endl;
00138 
00139           std::cout << "input: in um X1noVtx= " <<  (itrack.bx()*(z420+zinibeg)+itrack.ax())*1000.  << std::endl;
00140           std::cout << "input: in um Y1noVtx= " <<  (itrack.by()*(z420+zinibeg)+itrack.ay())*1000.  << std::endl;
00141           std::cout << "input: in um X2noVtx= " <<  (itrack.bx()*(z420+zinibeg+zref1)+itrack.ax())*1000.  << std::endl;
00142           std::cout << "input: in um Y2noVtx= " <<  (itrack.by()*(z420+zinibeg+zref1)+itrack.ay())*1000.  << std::endl;
00143 
00144 
00145           std::cout << "input:  in mm VtxXcur= " << VtxXcur   << std::endl;
00146           std::cout << "input:  in mm VtxYcur= " << VtxYcur   << std::endl;
00147           std::cout << "input:  in mm VtxZcur= " << VtxZcur   << std::endl;
00148           std::cout << "input coord. in um:  x1= " <<  x1  << std::endl;
00149           std::cout << "input coord. in um:  y1= " <<  y1  << std::endl;
00150           std::cout << "input coord. in um:  x2= " <<  x2  << std::endl;
00151           std::cout << "input coord. in um:  y2= " <<  y2  << std::endl;
00152         }
00153         double zz1=fabs(z1);
00154         double zz2=fabs(z2);
00155         rcollector = finderParameters_->reconstruct(StID, x1,y1,x2,y2,zz1,zz2); // x1,y1,x2,y2 input coord. in um; z1, z2 in mm
00156     }
00158     
00159     
00160     
00161     if (verbosity > 1) {
00162       std::cout << "FP420RecoMain: track rcollector.size=" << rcollector.size() << std::endl;
00163     }
00164     if (rcollector.size()>0){
00165       RecoCollectionFP420::Range rinputRange;
00166       rinputRange.first = rcollector.begin();
00167       rinputRange.second = rcollector.end();
00168       
00169       if ( first ) {
00170         // use it only if RecoCollectionFP420 is the RecoCollection of one event, otherwise, do not use (loose 1st cl. of 1st event only)
00171         first = false;
00172         unsigned int StID0 = 0;
00173         toutput->put(rinputRange,StID0); // !!! put into adress 0 for detID which will not be used never
00174         if (verbosity > 1) {
00175           std::cout << "FP420RecoMain: put(rinputRange,StID0)" << std::endl;
00176         }
00177       } //if ( first ) 
00178       
00179       // !!! put                                        !!! put
00180       toutput->put(rinputRange,StID);
00181       if (verbosity > 1) {
00182         std::cout << "FP420RecoMain: put(rinputRange,StID)" << std::endl;
00183       }
00184       
00185     } // if rcollector.size
00186     
00187   }// for loop over detunits
00188   
00189 
00190 
00191 
00192 
00193 
00194   if (verbosity > 1) {
00195     //     check of access to the zcollector:
00196     for (int number_detunits=1; number_detunits<dn0; number_detunits++) {
00197       int StID = number_detunits;
00198       if (verbosity > 1) {
00199         std::cout <<" ===" << std::endl;
00200         std::cout <<" ===" << std::endl;
00201         std::cout << "FP420RecoMain:   re-new  StID= " <<  StID << std::endl;
00202       }
00203       std::vector<RecoFP420> zcollector;
00204       zcollector.clear();
00205       RecoCollectionFP420::Range zoutputRange;
00206       zoutputRange = toutput->get(StID);
00207       // fill output in zcollector vector (for may be sorting? or other checks)
00208       RecoCollectionFP420::ContainerIterator sort_begin = zoutputRange.first;
00209       RecoCollectionFP420::ContainerIterator sort_end = zoutputRange.second;
00210       for ( ;sort_begin != sort_end; ++sort_begin ) {
00211         zcollector.push_back(*sort_begin);
00212       } // for
00213       std::cout <<"=======FP420RecoMain:check of re-new zcollector size = " << zcollector.size() << std::endl;
00214       std::cout <<" ===" << std::endl;
00215       std::cout <<" ===" << std::endl;
00216       std::vector<RecoFP420>::const_iterator simHitIter = zcollector.begin();
00217       std::vector<RecoFP420>::const_iterator simHitIterEnd = zcollector.end();
00218       // loop in recoess
00219       for (;simHitIter != simHitIterEnd; ++simHitIter) {
00220         const RecoFP420 itrack = *simHitIter;
00221         //double e0, double x0, double y0, double tx0, double ty0, double q20, int direction     
00222         std::cout << "FP420RecoMain:check: direction = " << itrack.direction() << std::endl;
00223         std::cout << "  e0 = " << itrack.e0() << "  q20 = " << itrack.q20() << std::endl;
00224         std::cout << "  tx0 = " << itrack.tx0() << "  ty0 = " << itrack.ty0() << std::endl;
00225         std::cout << " x0= " << itrack.x0() << " y0= " << itrack.y0() << std::endl;
00226         std::cout <<" ===" << std::endl;
00227         std::cout <<" ===" << std::endl;
00228         std::cout <<" =======================" << std::endl;
00229       }
00230     }
00231     
00232     //==================================
00233     
00234     //     end of check of access to the strip collection
00235     std::cout <<"=======            FP420RecoMain:                    end of check     " << std::endl;
00236     
00237   }//if (verbos
00238   
00239 
00240 
00241 
00242 
00243 
00244 
00245 }