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 m_minBX = pset.getParameter<int>("MinBX");
00022 m_maxBX = pset.getParameter<int>("MaxBX");
00023
00024 for(int e = CSCDetId::minEndcapId(); e <= CSCDetId::maxEndcapId(); ++e)
00025 {
00026 for(int s = CSCTriggerNumbering::minTriggerSectorId();
00027 s <= CSCTriggerNumbering::maxTriggerSectorId(); ++s)
00028 {
00029
00030 my_SPs[e-1][s-1] = new CSCTFSectorProcessor(e, s, pset, TMB07,
00031 scales, ptScale);
00032 }
00033 }
00034 }
00035
00036 void CSCTFTrackBuilder::initialize(const edm::EventSetup& c){
00037
00038 for(int e = CSCDetId::minEndcapId(); e <= CSCDetId::maxEndcapId(); ++e)
00039 {
00040 for(int s = CSCTriggerNumbering::minTriggerSectorId(); s <= CSCTriggerNumbering::maxTriggerSectorId(); ++s)
00041 {
00042 my_SPs[e-1][s-1]->initialize(c);
00043 }
00044 }
00045 }
00046
00047 CSCTFTrackBuilder::~CSCTFTrackBuilder()
00048 {
00049 for(int e = CSCDetId::minEndcapId(); e <= CSCDetId::maxEndcapId(); ++e)
00050 {
00051 for(int s = CSCTriggerNumbering::minTriggerSectorId();
00052 s <= CSCTriggerNumbering::maxTriggerSectorId(); ++s)
00053 {
00054 delete my_SPs[e-1][s-1];
00055 my_SPs[e-1][s-1] = NULL;
00056 }
00057 }
00058 }
00059
00060 void CSCTFTrackBuilder::buildTracks(const CSCCorrelatedLCTDigiCollection* lcts,
00061 const CSCTriggerContainer<csctf::TrackStub>* dtstubss,
00062 L1CSCTrackCollection* trkcoll, CSCTriggerContainer<csctf::TrackStub>* stubs_to_dt)
00063 {
00064 std::vector<csc::L1Track> trks;
00065 CSCTriggerContainer<csctf::TrackStub> stub_list;
00066
00067 CSCCorrelatedLCTDigiCollection::DigiRangeIterator Citer;
00068
00069 for(Citer = lcts->begin(); Citer != lcts->end(); Citer++)
00070 {
00071 CSCCorrelatedLCTDigiCollection::const_iterator Diter = (*Citer).second.first;
00072 CSCCorrelatedLCTDigiCollection::const_iterator Dend = (*Citer).second.second;
00073
00074 for(; Diter != Dend; Diter++)
00075 {
00076 csctf::TrackStub theStub((*Diter),(*Citer).first);
00077 stub_list.push_back(theStub);
00078 }
00079 }
00080
00081
00082
00083
00084
00085
00086 stub_list.push_many(*dtstubss);
00087
00088
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());
00101 }
00102 }
00103
00104
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 int me1delay = titr->me1Tbin();
00121 int me2delay = titr->me2Tbin();
00122 int me3delay = titr->me3Tbin();
00123 int me4delay = titr->me4Tbin();
00124 int mb1delay = titr->mb1Tbin();
00125
00126
00127
00128 std::map< int, std::list<int> > timeline;
00129 if( me1ID ) timeline[me1delay].push_back(1);
00130 if( me2ID ) timeline[me2delay].push_back(2);
00131 if( me3ID ) timeline[me3delay].push_back(3);
00132 if( me4ID ) timeline[me4delay].push_back(4);
00133 int earliest_tbin=0, second_earliest_tbin=0;
00134 for(int bx=7; bx>=0; bx--){
00135 std::list<int>::const_iterator iter = timeline[bx].begin();
00136 while( iter != timeline[bx].end() ){
00137 if( earliest_tbin==0 ) earliest_tbin=bx;
00138 else if( second_earliest_tbin==0 ) second_earliest_tbin=bx;
00139 iter++;
00140 }
00141 }
00142
00143
00144 int shift = (m_maxBX + m_minBX)/2 - m_minBX + m_minBX;
00145 int me1Tbin = titr->bx() - me1delay + second_earliest_tbin + shift;
00146 int me2Tbin = titr->bx() - me2delay + second_earliest_tbin + shift;
00147 int me3Tbin = titr->bx() - me3delay + second_earliest_tbin + shift;
00148 int me4Tbin = titr->bx() - me4delay + second_earliest_tbin + shift;
00149 int mb1Tbin = titr->bx() - mb1delay + second_earliest_tbin + shift;
00150
00151 for(; tkstbs != possible_stubs.end(); tkstbs++)
00152 {
00153 switch(tkstbs->station())
00154 {
00155 case 1:
00156 if((tkstbs->getMPCLink()
00157 +(3*(CSCTriggerNumbering::triggerSubSectorFromLabels(CSCDetId(tkstbs->getDetId().rawId())) - 1))) == me1ID && me1ID != 0 && me1Tbin == tkstbs->BX() )
00158 {
00159 tcitr->second.insertDigi(CSCDetId(tkstbs->getDetId().rawId()), *(tkstbs->getDigi()));
00160 }
00161 break;
00162 case 2:
00163 if(tkstbs->getMPCLink() == me2ID && me2ID != 0 && me2Tbin == tkstbs->BX() )
00164 {
00165 tcitr->second.insertDigi(CSCDetId(tkstbs->getDetId().rawId()), *(tkstbs->getDigi()));
00166 }
00167 break;
00168 case 3:
00169 if(tkstbs->getMPCLink() == me3ID && me3ID != 0 && me3Tbin == tkstbs->BX() )
00170 {
00171 tcitr->second.insertDigi(CSCDetId(tkstbs->getDetId().rawId()), *(tkstbs->getDigi()));
00172 }
00173 break;
00174 case 4:
00175 if(tkstbs->getMPCLink() == me4ID && me4ID != 0 && me4Tbin == tkstbs->BX() )
00176 {
00177 tcitr->second.insertDigi(CSCDetId(tkstbs->getDetId().rawId()), *(tkstbs->getDigi()));
00178 }
00179 break;
00180 case 5:
00181 if(tkstbs->getMPCLink() == mb1ID && mb1ID != 0 && mb1Tbin == tkstbs->BX() )
00182 {
00184 }
00185 break;
00186 default:
00187 edm::LogWarning("CSCTFTrackBuilder::buildTracks()") << "SERIOUS ERROR: STATION " << tkstbs->station() << " NOT IN RANGE [1,5]\n";
00188 };
00189 }
00190 tcitr++;
00191 }
00192
00193 }
00194