CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC2/src/RecoRomanPot/RecoFP420/src/FP420TrackMain.cc

Go to the documentation of this file.
00001 
00002 // File: FP420TrackMain.cc
00003 // Date: 12.2006
00004 // Description: FP420TrackMain for FP420
00005 // Modifications: 
00007 #include <vector>
00008 #include <iostream>
00009 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00010 
00011 #include "RecoRomanPot/RecoFP420/interface/FP420TrackMain.h"
00012 #include "DataFormats/FP420Cluster/interface/ClusterFP420.h"
00013 #include "DataFormats/FP420Cluster/interface/TrackFP420.h"
00014 #include "RecoRomanPot/RecoFP420/interface/TrackProducerFP420.h"
00015 
00016 #include "CLHEP/Random/RandFlat.h"
00017 
00018 using namespace std;
00019 
00020 //#define mytrackdebug0
00021 
00022 //FP420TrackMain::FP420TrackMain(){ 
00023 FP420TrackMain::FP420TrackMain(const edm::ParameterSet& conf):conf_(conf)  { 
00024   
00025   verbosity   = conf_.getUntrackedParameter<int>("VerbosityLevel");
00026   trackMode_  =  conf_.getParameter<std::string>("TrackModeFP420");
00027   dn0   = conf_.getParameter<int>("NumberFP420Detectors");
00028   sn0_ = conf_.getParameter<int>("NumberFP420Stations");
00029   pn0_ = conf_.getParameter<int>("NumberFP420SPlanes");
00030   rn0_ = 7;
00031   xytype_ = conf_.getParameter<int>("NumberFP420SPTypes");
00032   z420_           = conf_.getParameter<double>("z420");
00033   zD2_            = conf_.getParameter<double>("zD2");
00034   zD3_            = conf_.getParameter<double>("zD3");
00035   dXX_ = conf_.getParameter<double>("dXXFP420");
00036   dYY_ = conf_.getParameter<double>("dYYFP420");
00037   chiCutX_ = conf_.getParameter<double>("chiCutX420");
00038   chiCutY_ = conf_.getParameter<double>("chiCutY420");
00039   
00040   if (verbosity > 0) {
00041     std::cout << "FP420TrackMain constructor::" << std::endl;
00042     std::cout << "sn0=" << sn0_ << " pn0=" << pn0_ << " xytype=" << xytype_ << std::endl;
00043     std::cout << "trackMode = " << trackMode_ << std::endl;
00044     std::cout << "dXX=" << dXX_ << " dYY=" << dYY_ << std::endl;
00045     std::cout << "chiCutX=" << chiCutX_ << " chiCutY=" << chiCutY_ << std::endl;
00046   }
00048     // zD2_ = 1000.;  // dist between centers of 1st and 2nd stations
00049     // zD3_ = 8000.;  // dist between centers of 1st and 3rd stations
00050     
00051   UseHalfPitchShiftInX_= true;
00052   UseHalfPitchShiftInXW_= true;
00053   UseHalfPitchShiftInY_= true;
00054   UseHalfPitchShiftInYW_= true;
00055 
00056   pitchX_= 0.050;
00057   pitchY_= 0.050;// 
00058   pitchXW_= 0.400;
00059   pitchYW_= 0.400;// 
00060 
00061   XsensorSize_=8.0;
00062   YsensorSize_=7.2;
00063 
00064 //
00065   zBlade_ = 5.00;
00066   gapBlade_ = 1.6;
00067   double gapSupplane = 1.6;
00068   ZSiPlane_=2*zBlade_+gapBlade_+gapSupplane;
00069   
00070   double ZKapton = 0.1;
00071   ZSiStep_=ZSiPlane_+ZKapton;
00072   
00073   double ZBoundDet = 0.020;
00074   double ZSiElectr = 0.250;
00075   double ZCeramDet = 0.500;
00076 
00077   double eee1=11.;
00078   double eee2=12.;
00079   zinibeg_ = (eee1-eee2)/2.;
00080 //
00081   ZSiDet_ = 0.250;
00082 //
00083   ZGapLDet_= zBlade_/2-(ZSiDet_+ZSiElectr+ZBoundDet+ZCeramDet/2);
00084 //
00085     if (verbosity > 1) {
00086       std::cout << "FP420TrackMain constructor::" << std::endl;
00087       std::cout << " zD2=" << zD2_ << " zD3=" << zD3_ << " zinibeg =" << zinibeg_ << std::endl;
00088       std::cout << " UseHalfPitchShiftInX=" << UseHalfPitchShiftInX_ << " UseHalfPitchShiftInY=" << UseHalfPitchShiftInY_ << std::endl;
00089       std::cout << " UseHalfPitchShiftInXW=" << UseHalfPitchShiftInXW_ << " UseHalfPitchShiftInYW=" << UseHalfPitchShiftInYW_ << std::endl;
00090       std::cout << " pitchX=" << pitchX_ << " pitchY=" << pitchY_ << std::endl;
00091       std::cout << " pitchXW=" << pitchXW_ << " pitchYW=" << pitchYW_ << std::endl;
00092       std::cout << " zBlade_=" << zBlade_ << " gapBlade_=" << gapBlade_ << std::endl;
00093       std::cout << " ZKapton=" << ZKapton << " ZBoundDet=" << ZBoundDet << std::endl;
00094       std::cout << " ZSiElectr=" << ZSiElectr << " ZCeramDet=" << ZCeramDet << std::endl;
00095       std::cout << " ZSiDet=" << ZSiDet_ << " gapSupplane=" << gapSupplane << std::endl;
00096     }
00098 
00099 
00100 
00101       if ( trackMode_ == "TrackProducerSophisticatedFP420" ) {
00102   
00103   
00104   //trackMode_ == "TrackProducerVar1FP420" ||
00105   //trackMode_ == "TrackProducerVar2FP420" ||
00106 
00107      // if ( trackMode_ == "TrackProducerMaxAmplitudeFP420" ||
00108 //         trackMode_ == "TrackProducerMaxAmplitude2FP420"  ||
00109 //         trackMode_ == "TrackProducerSophisticatedFP420"  ||
00110 //         trackMode_ == "TrackProducer3DFP420" )  {
00111 
00112         finderParameters_ = new TrackProducerFP420(sn0_, pn0_, rn0_, xytype_, z420_, zD2_, zD3_,
00113                                                    pitchX_, pitchY_,
00114                                                    pitchXW_, pitchYW_,
00115                                                    ZGapLDet_, ZSiStep_,
00116                                                    ZSiPlane_, ZSiDet_,zBlade_,gapBlade_,
00117                                                    UseHalfPitchShiftInX_, UseHalfPitchShiftInY_,
00118                                                    UseHalfPitchShiftInXW_, UseHalfPitchShiftInYW_,
00119                                                    dXX_,dYY_,chiCutX_,chiCutY_,zinibeg_,verbosity,
00120                                                    XsensorSize_,YsensorSize_);
00121         validTrackerizer_ = true;
00122       } 
00123       else {
00124         std::cout << "ERROR:FP420TrackMain: No valid finder selected" << std::endl;
00125         validTrackerizer_ = false;
00126       }
00127 }
00128 
00129 FP420TrackMain::~FP420TrackMain() {
00130   if ( finderParameters_ != 0 ) {
00131     delete finderParameters_;
00132   }
00133 }
00134 
00135 
00136 
00137 void FP420TrackMain::run(edm::Handle<ClusterCollectionFP420> &input, std::auto_ptr<TrackCollectionFP420> &toutput )
00138 {
00139   
00140   if ( validTrackerizer_ ) {
00141     
00142     int number_detunits          = 0;
00143     int number_localelectroderechits = 0;
00144     /*
00145       for (int sector=1; sector<sn0_; sector++) {
00146       for (int zmodule=1; zmodule<pn0_; zmodule++) {
00147       for (int zside=1; zside<rn0_; zside++) {
00148       int sScale = 2*(pn0-1);
00149       //      int index = FP420NumberingScheme::packFP420Index(det, zside, sector, zmodule);
00150       // intindex is a continues numbering of FP420
00151       int zScale=2;  unsigned int detID = sScale*(sector - 1)+zScale*(zmodule - 1)+zside;
00152       ClusterMap.clear();
00153       ClusterCollectionFP420::Range clusterRange;
00154       clusterRange = input.get(detID);
00155       ClusterCollectionFP420::ContainerIterator clusterRangeIteratorBegin = clusterRange.first;
00156       ClusterCollectionFP420::ContainerIterator clusterRangeIteratorEnd   = clusterRange.second;
00157       for ( ;sort_begin != sort_end; ++sort_begin ) {
00158       ClusterMap.push_back(*sort_begin);
00159       } // for
00160       
00161       }//for
00162       }//for
00163       }//for
00164     */
00165     // get vector of detunit ids
00166     //    const std::vector<unsigned int> detIDs = input->detIDs();
00167     
00168     // to be used in put (besause of 0 in track collection for: 1) 1st track and 2) case of no track)
00169     // ignore 0, but to save info for 1st track record it second time on place 1   .
00170     
00171     bool first = true;
00172     // loop over detunits
00173     for (int det=1; det<dn0; det++) {
00174       ++number_detunits;
00175       int StID = 1111;
00176       if(det==2) StID = 2222;
00177       std::vector<TrackFP420> collector;
00178       //            std::vector<TrackFP420> collector;
00179       collector.clear();
00180       
00181       // if ( trackMode_ == "TrackProducerMaxAmplitudeFP420") {
00182       //         collector = finderParameters_->trackFinderMaxAmplitude(input); //std::vector<TrackFP420> collector;
00183       // }// if ( trackMode
00184       // else if (trackMode_ == "TrackProducerMaxAmplitude2FP420" ) {
00185       //         collector = finderParameters_->trackFinderMaxAmplitude2(input); //
00186       //  }// if ( trackMode
00187       /*
00188         else if (trackMode_ == "TrackProducerVar1FP420" ) {
00189         collector = finderParameters_->trackFinderVar1(input); //
00190         }// if ( trackMode
00191         else if (trackMode_ == "TrackProducerVar2FP420" ) {
00192         collector = finderParameters_->trackFinderVar2(input); //
00193         }// if ( trackMode
00194       */
00195       if (trackMode_ == "TrackProducerSophisticatedFP420" ) {
00196         collector = finderParameters_->trackFinderSophisticated(input,det); //
00197       }// if ( trackMode
00198       
00199       
00200       //  else if (trackMode_ == "TrackProducer3DFP420" ) {
00201       //         collector = finderParameters_->trackFinder3D(input); //
00202       // }// if ( trackMode
00203       
00204       if (collector.size()>0){
00205         TrackCollectionFP420::Range inputRange;
00206         inputRange.first = collector.begin();
00207         inputRange.second = collector.end();
00208         
00209         if ( first ) {
00210           // use it only if TrackCollectionFP420 is the TrackCollection of one event, otherwise, do not use (loose 1st cl. of 1st event only)
00211           first = false;
00212           unsigned int StID0 = 0;
00213           toutput->put(inputRange,StID0); // !!! put into adress 0 for detID which will not be used never
00214         } //if ( first ) 
00215         
00216         // !!! put                                        !!! put
00217         toutput->put(inputRange,StID);
00218         
00219         number_localelectroderechits += collector.size();
00220       } // if collector.size
00221     }//for det loop
00222     
00223     
00224     if (verbosity > 0) {
00225       std::cout << "FP420TrackMain: execution in mode " << trackMode_ << " generating " << number_localelectroderechits << " tracks in  " << number_detunits << " detectors" << std::endl; 
00226     }
00227     
00228     
00229     if (verbosity ==-29) {
00230       //     check of access to the collector:
00231       // loop over detunits
00232       for (int det=1; det<dn0; det++) {
00233         int StID = 1111;
00234         if(det==2) StID = 2222;
00235         std::vector<TrackFP420> collector;
00236         collector.clear();
00237         TrackCollectionFP420::Range outputRange;
00238         outputRange = toutput->get(StID);
00239         // fill output in collector vector (for may be sorting? or other checks)
00240         TrackCollectionFP420::ContainerIterator sort_begin = outputRange.first;
00241         TrackCollectionFP420::ContainerIterator sort_end = outputRange.second;
00242         for ( ;sort_begin != sort_end; ++sort_begin ) {
00243           collector.push_back(*sort_begin);
00244         } // for
00245         std::cout <<" ===" << std::endl;
00246         std::cout <<" ===" << std::endl;
00247         std::cout <<"=======FP420TrackMain:check size = " << collector.size() << "  det = " << det << std::endl;
00248         std::cout <<" ===" << std::endl;
00249         std::cout <<" ===" << std::endl;
00250         vector<TrackFP420>::const_iterator simHitIter = collector.begin();
00251         vector<TrackFP420>::const_iterator simHitIterEnd = collector.end();
00252         // loop in #tracks
00253         for (;simHitIter != simHitIterEnd; ++simHitIter) {
00254           const TrackFP420 itrack = *simHitIter;
00255           
00256           std::cout << "FP420TrackMain:check: nclusterx = " << itrack.nclusterx() << "  nclustery = " << itrack.nclustery() << std::endl;
00257           std::cout << "  ax = " << itrack.ax() << "  bx = " << itrack.bx() << std::endl;
00258           std::cout << "  ay = " << itrack.ay() << "  by = " << itrack.by() << std::endl;
00259           std::cout << " chi2x= " << itrack.chi2x() << " chi2y= " << itrack.chi2y() << std::endl;
00260           std::cout <<" ===" << std::endl;
00261           std::cout <<" ===" << std::endl;
00262           std::cout <<" =======================" << std::endl;
00263         }
00264         
00265         //==================================
00266         
00267         //     end of check of access to the strip collection
00268         std::cout <<"=======            FP420TrackMain:                    end of check     " << std::endl;
00269         
00270       }//for det
00271     }// if verbosity
00272     
00273     
00274     
00275     
00276   }// if ( validTrackerizer_
00277   
00278   
00279   
00280 }