CMS 3D CMS Logo

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

Generated on Tue Jun 9 17:44:55 2009 for CMSSW by  doxygen 1.5.4