CMS 3D CMS Logo

CSCTFTrackBuilder.cc

Go to the documentation of this file.
00001 #include <L1Trigger/CSCTrackFinder/src/CSCTFTrackBuilder.h>
00002 
00003 #include <FWCore/MessageLogger/interface/MessageLogger.h>
00004 
00005 #include <DataFormats/MuonDetId/interface/CSCDetId.h>
00006 #include <DataFormats/MuonDetId/interface/CSCTriggerNumbering.h>
00007 #include <DataFormats/L1DTTrackFinder/interface/L1MuDTChambPhContainer.h>
00008 
00009 #include <DataFormats/L1CSCTrackFinder/interface/CSCTriggerContainer.h>
00010 #include <L1Trigger/CSCTrackFinder/interface/CSCTFSectorProcessor.h>
00011 
00012 #include "CondFormats/L1TObjects/interface/L1MuCSCTFConfiguration.h"
00013 #include "CondFormats/DataRecord/interface/L1MuCSCTFConfigurationRcd.h"
00014 #include "FWCore/Framework/interface/ESHandle.h"
00015 #include <sstream>
00016 #include <stdlib.h>
00017 
00018 CSCTFTrackBuilder::CSCTFTrackBuilder(const edm::ParameterSet& pset, bool TMB07,
00019                                      const L1MuTriggerScales* scales,
00020                                      const L1MuTriggerPtScale* ptScale ){
00021   my_dtrc = new CSCTFDTReceiver();
00022 
00023   for(int e = CSCDetId::minEndcapId(); e <= CSCDetId::maxEndcapId(); ++e)
00024     {
00025       for(int s = CSCTriggerNumbering::minTriggerSectorId();
00026           s <= CSCTriggerNumbering::maxTriggerSectorId(); ++s)
00027         {
00028           // All SPs work with the same configuration (impossible to make it more exclusive in this framework)
00029           my_SPs[e-1][s-1] = new CSCTFSectorProcessor(e, s, pset, TMB07,
00030                                                       scales, ptScale);
00031         }
00032     }
00033 }
00034 
00035 void CSCTFTrackBuilder::initialize(const edm::EventSetup& c){
00036  //my_dtrc->initialize(c);
00037         for(int e = CSCDetId::minEndcapId(); e <= CSCDetId::maxEndcapId(); ++e)
00038         {
00039                 for(int s = CSCTriggerNumbering::minTriggerSectorId(); s <= CSCTriggerNumbering::maxTriggerSectorId(); ++s)
00040                 {
00041                         my_SPs[e-1][s-1]->initialize(c);
00042                 }
00043         }
00044 }
00045 
00046 CSCTFTrackBuilder::~CSCTFTrackBuilder()
00047 {
00048   delete my_dtrc;
00049   my_dtrc = NULL;
00050 
00051   for(int e = CSCDetId::minEndcapId(); e <= CSCDetId::maxEndcapId(); ++e)
00052     {
00053       for(int s = CSCTriggerNumbering::minTriggerSectorId();
00054           s <= CSCTriggerNumbering::maxTriggerSectorId(); ++s)
00055         {
00056           delete my_SPs[e-1][s-1];
00057           my_SPs[e-1][s-1] = NULL;
00058         }
00059     }
00060 }
00061 
00062 void CSCTFTrackBuilder::buildTracks(const CSCCorrelatedLCTDigiCollection* lcts, const L1MuDTChambPhContainer* dttrig,
00063                                     L1CSCTrackCollection* trkcoll, CSCTriggerContainer<csctf::TrackStub>* stubs_to_dt)
00064 {
00065   std::vector<csc::L1Track> trks;
00066   CSCTriggerContainer<csctf::TrackStub> stub_list;
00067 
00068   CSCCorrelatedLCTDigiCollection::DigiRangeIterator Citer;
00069 
00070   for(Citer = lcts->begin(); Citer != lcts->end(); Citer++)
00071     {
00072       CSCCorrelatedLCTDigiCollection::const_iterator Diter = (*Citer).second.first;
00073       CSCCorrelatedLCTDigiCollection::const_iterator Dend = (*Citer).second.second;
00074 
00075           for(; Diter != Dend; Diter++)
00076         {
00077           csctf::TrackStub theStub((*Diter),(*Citer).first);
00078           stub_list.push_back(theStub);
00079         }
00080     }
00081 
00082   // Now we append the track stubs the the DT Sector Collector
00083   // after processing from the DT Receiver.
00084 
00085   CSCTriggerContainer<csctf::TrackStub> dtstubs = my_dtrc->process(dttrig);
00086   stub_list.push_many(dtstubs);
00087 
00088   // run each sector processor in the TF
00089   for(int e = CSCDetId::minEndcapId(); e <= CSCDetId::maxEndcapId(); ++e)
00090   {
00091       for(int s = CSCTriggerNumbering::minTriggerSectorId();
00092         s <= CSCTriggerNumbering::maxTriggerSectorId(); ++s)
00093       {
00094          CSCTriggerContainer<csctf::TrackStub> current_e_s = stub_list.get(e, s);
00095          if(my_SPs[e-1][s-1]->run(current_e_s))
00096          {
00097            std::vector<csc::L1Track> theTracks = my_SPs[e-1][s-1]->tracks().get();
00098            trks.insert(trks.end(), theTracks.begin(), theTracks.end());
00099          }
00100          stubs_to_dt->push_many(my_SPs[e-1][s-1]->dtStubs()); // send stubs whether or not we find a track!!!
00101       }
00102   }
00103 
00104   // Now to combine tracks with their track stubs and send them off.
00105   trkcoll->resize(trks.size());
00106   std::vector<csc::L1Track>::const_iterator titr = trks.begin();
00107   L1CSCTrackCollection::iterator tcitr = trkcoll->begin();
00108 
00109   for(; titr != trks.end(); titr++)
00110     {
00111       tcitr->first = (*titr);
00112       std::vector<csctf::TrackStub> possible_stubs = my_SPs[titr->endcap()-1][titr->sector()-1]->filteredStubs();
00113       std::vector<csctf::TrackStub>::const_iterator tkstbs = possible_stubs.begin();
00114 
00115       int me1ID = titr->me1ID();
00116       int me2ID = titr->me2ID();
00117       int me3ID = titr->me3ID();
00118       int me4ID = titr->me4ID();
00119       int mb1ID = titr->mb1ID();
00120 
00121       for(; tkstbs != possible_stubs.end(); tkstbs++)
00122         {
00123           switch(tkstbs->station())
00124             {
00125             case 1:
00126               if((tkstbs->getMPCLink()
00127                   +(3*(CSCTriggerNumbering::triggerSubSectorFromLabels(CSCDetId(tkstbs->getDetId().rawId())) - 1))) == me1ID && me1ID != 0)
00128                 {
00129                   tcitr->second.insertDigi(CSCDetId(tkstbs->getDetId().rawId()), *(tkstbs->getDigi()));
00130                 }
00131               break;
00132             case 2:
00133               if(tkstbs->getMPCLink() == me2ID && me2ID != 0)
00134                 {
00135                   tcitr->second.insertDigi(CSCDetId(tkstbs->getDetId().rawId()), *(tkstbs->getDigi()));
00136                 }
00137               break;
00138             case 3:
00139               if(tkstbs->getMPCLink() == me3ID && me3ID != 0)
00140                 {
00141                   tcitr->second.insertDigi(CSCDetId(tkstbs->getDetId().rawId()), *(tkstbs->getDigi()));
00142                 }
00143               break;
00144             case 4:
00145               if(tkstbs->getMPCLink() == me4ID && me4ID != 0)
00146                 {
00147                   tcitr->second.insertDigi(CSCDetId(tkstbs->getDetId().rawId()), *(tkstbs->getDigi()));
00148                 }
00149               break;
00150             case 5:
00151               if(tkstbs->getMPCLink() == mb1ID && mb1ID != 0)
00152               {
00154               }
00155               break;
00156             default:
00157               edm::LogWarning("CSCTFTrackBuilder::buildTracks()") << "SERIOUS ERROR: STATION " << tkstbs->station() << " NOT IN RANGE [1,5]\n";
00158             };
00159         }
00160       tcitr++; // increment to next track in the collection
00161     }
00162 
00163 }
00164 

Generated on Tue Jun 9 17:39:42 2009 for CMSSW by  doxygen 1.5.4