12 #define NUM_SECTORS 12
16 #include "L1Trigger/CSCTrackFinder/test/src/RefTrack.h"
37 using namespace L1TMuon;
44 produces<l1t::RegionalMuonCandBxCollection >(
"EMTF");
45 produces< l1t::EMTFTrackCollection >(
"EMTF");
46 produces< l1t::EMTFHitCollection >(
"EMTF");
47 produces< l1t::EMTFTrackExtraCollection >(
"EMTF");
48 produces< l1t::EMTFHitExtraCollection >(
"EMTF");
70 std::vector<TriggerPrimitive> tester;
80 std::vector<TriggerPrimitive>
out;
82 auto chamber = MDC->begin();
83 auto chend = MDC->end();
84 for( ; chamber != chend; ++chamber ) {
85 auto digi = (*chamber).second.first;
86 auto dend = (*chamber).second.second;
87 for( ; digi != dend; ++digi ) {
94 OutputHits->push_back( thisHit );
95 if ( ((thisHit.
Ring() != 1 || thisHit.
Station() == 1) && (thisHit.
Chamber() % 6 == 2)) ||
99 OutputHits->push_back( neighborHit );
114 auto tp = out.cbegin();
115 auto tpend = out.cend();
117 for( ; tp != tpend; ++tp ) {
118 if(tp->subsystem() == 1)
122 tester.push_back(*tp);
132 for(
int SectIndex=0;SectIndex<
NUM_SECTORS;SectIndex++){
141 std::vector<ConvertedHit> ConvHits = primConv_.convert(tester,SectIndex);
142 CHits[SectIndex] = ConvHits;
145 for (uint iCHit = 0; iCHit < ConvHits.size(); iCHit++) {
148 for (uint iHit = 0; iHit < OutputHits->size(); iHit++) {
149 if ( ConvHits.at(iCHit).Station() == OutputHits->at(iHit).Station() &&
150 ( ConvHits.at(iCHit).Id() == OutputHits->at(iHit).CSC_ID() ||
151 ConvHits.at(iCHit).Id() == ( (OutputHits->at(iHit).Ring() != 4)
152 ? OutputHits->at(iHit).CSC_ID()
153 : OutputHits->at(iHit).CSC_ID() + 9 ) ) &&
154 ConvHits.at(iCHit).Wire() == OutputHits->at(iHit).Wire() &&
155 ConvHits.at(iCHit).Strip() == OutputHits->at(iHit).Strip() &&
156 ConvHits.at(iCHit).BX() - 6 == OutputHits->at(iHit).BX() &&
157 ConvHits.at(iCHit).IsNeighbor() == OutputHits->at(iHit).Neighbor() ) {
159 OutputHits->at(iHit).set_neighbor ( ConvHits.at(iCHit).IsNeighbor());
160 OutputHits->at(iHit).set_sector_index( ConvHits.at(iCHit).SectorIndex() );
161 OutputHits->at(iHit).set_zone_hit ( ConvHits.at(iCHit).Zhit() );
162 OutputHits->at(iHit).set_phi_hit ( ConvHits.at(iCHit).Ph_hit() );
163 OutputHits->at(iHit).set_phi_z_val ( ConvHits.at(iCHit).Phzvl() );
164 OutputHits->at(iHit).set_phi_loc_int ( ConvHits.at(iCHit).Phi() );
165 OutputHits->at(iHit).set_theta_int ( ConvHits.at(iCHit).Theta() );
167 OutputHits->at(iHit).SetZoneContribution ( ConvHits.at(iCHit).ZoneContribution() );
168 OutputHits->at(iHit).set_phi_loc_deg (
l1t::calc_phi_loc_deg( OutputHits->at(iHit).Phi_loc_int() ) );
169 OutputHits->at(iHit).set_phi_loc_rad (
l1t::calc_phi_loc_rad( OutputHits->at(iHit).Phi_loc_int() ) );
170 OutputHits->at(iHit).set_phi_glob_deg (
l1t::calc_phi_glob_deg_hit( OutputHits->at(iHit).Phi_loc_deg(), OutputHits->at(iHit).Sector_index() ) );
171 OutputHits->at(iHit).set_phi_glob_rad (
l1t::calc_phi_glob_rad_hit( OutputHits->at(iHit).Phi_loc_rad(), OutputHits->at(iHit).Sector_index() ) );
176 OutHits->push_back( OutputHits->at(iHit).CreateEMTFHit() );
221 std::vector<std::vector<ConvertedHit>> GroupedHits =
GroupBX(ConvHits);
228 std::vector<ZonesOutput> Zout =
Zones(GroupedHits);
237 std::vector<PatternOutput> Pout =
Patterns(Zout);
258 MO[SectIndex] = Mout;
265 std::vector<std::vector<DeltaOutput>> Dout =
CalcDeltas(Mout);
274 PTracks[SectIndex] = Bout;
285 std::vector<BTrack> AllTracks;
289 for(
int j=0;
j<36;
j++){
292 if(PTemp[
j/3][
j%3].
phi)
293 AllTracks.push_back(PTemp[
j/3][
j%3]);
304 std::vector<l1t::RegionalMuonCand> tester1;
305 std::vector<std::pair<int,l1t::RegionalMuonCand>> holder;
307 for(
unsigned int fbest=0;fbest<AllTracks.size();fbest++){
309 if(AllTracks[fbest].
phi){
313 tempTrack.
phi = AllTracks[fbest].phi;
314 tempTrack.
theta = AllTracks[fbest].theta;
315 tempTrack.
rank = AllTracks[fbest].winner.Rank();
316 tempTrack.
deltas = AllTracks[fbest].deltas;
317 std::vector<int> ps, ts;
322 thisTrack.
set_rank ( AllTracks[fbest].winner.Rank() );
324 int tempStraightness = 0;
325 int tempRank = thisTrack.
Rank();
327 tempStraightness |= 4;
329 tempStraightness |= 2;
331 tempStraightness |= 1;
337 int me1address = 0, me2address = 0, CombAddress = 0, mode_uncorr = 0;
338 int ebx = 20, sebx = 20;
339 int phis[4] = {-99,-99,-99,-99};
341 for(std::vector<ConvertedHit>::iterator
A = AllTracks[fbest].AHits.begin();
A != AllTracks[fbest].AHits.end();
A++){
343 if(
A->Phi() != -999){
348 for (uint iHit = 0; iHit < OutputHits->size(); iHit++) {
349 if (
A->TP().detId<
CSCDetId>().
station() == OutputHits->at(iHit).Station() and
350 A->TP().getCSCData().cscID == OutputHits->at(iHit).CSC_ID() and
351 A->Wire() == OutputHits->at(iHit).Wire() and
352 A->Strip() == OutputHits->at(iHit).Strip() and
353 A->TP().getCSCData().bx - 6 == OutputHits->at(iHit).BX() ) {
354 thisHit = OutputHits->at(iHit);
366 int id =
A->TP().getCSCData().cscID;
367 int trknm =
A->TP().getCSCData().trknmb;
369 phis[station-1] =
A->Phi();
372 if(
A->TP().getCSCData().bx < ebx){
374 ebx =
A->TP().getCSCData().bx;
376 else if(
A->TP().getCSCData().bx < sebx){
377 sebx =
A->TP().getCSCData().bx;
381 ps.push_back(
A->Phi());
382 ts.push_back(
A->Theta());
384 sector =
A->SectorIndex();
388 case 1: mode_uncorr |= 8;
break;
389 case 2: mode_uncorr |= 4;
break;
390 case 3: mode_uncorr |= 2;
break;
391 case 4: mode_uncorr |= 1;
break;
392 default: mode_uncorr |= 0;
399 if(station == 1 &&
id > 3 &&
id < 7){
402 if(
A->TP().detId<
CSCDetId>().chamber()%6 > 2)
407 me1address += 3*(sub - 1);
409 me1address |= trknm-1;
413 if(station == 2 &&
id > 3){
417 me2address = me2address<<1;
418 me2address |= trknm-1;
428 if(tempTrack.
rank & 32)
430 if(tempTrack.
rank & 8)
432 if(tempTrack.
rank & 2)
434 if(tempTrack.
rank & 1)
445 unsigned long xmlpt_address = ptAssignment_.calculateAddress(tempTrack, es, mode);
446 float xmlpt = ptAssignment_.calculatePt(xmlpt_address);
448 tempTrack.
pt = xmlpt*1.4;
451 CombAddress = (me2address<<4) | me1address;
456 charge,mode,CombAddress,sector);
472 thisTrack.
set_pt ( xmlpt*1.4 );
475 thisTrack.
set_charge ( (charge == 1) ? -1 : 1 );
493 std::pair<int,l1t::RegionalMuonCand> outPair(ebx,outCand);
495 if(!ME13 && fabs(eta) > 1.1) {
507 holder.push_back(outPair);
510 OutputTracks->push_back( thisTrack );
515 OutputCands->setBXRange(-2,2);
517 for(
int sect=0;sect<12;sect++){
519 for(
unsigned int h=0;
h<holder.size();
h++){
521 int bx = holder[
h].first - 6;
522 int sector = holder[
h].second.processor();
523 if(holder[
h].
second.trackFinderType() == 3)
527 OutputCands->push_back(bx,holder[
h].
second);
535 ev.
put( OutputCands,
"EMTF");
536 ev.
put( OutputHits,
"EMTF");
537 ev.
put( OutputTracks,
"EMTF");
std::vector< EMTFHitExtra > EMTFHitExtraCollection
void set_pt_GMT(int bits)
T getParameter(std::string const &) const
void set_neighbor(int bits)
void set_phi_GMT(int bits)
float Phi_loc_rad() const
SortingOutput SortSect(PatternOutput Pout)
void set_quality(int bits)
void set_phi_loc_int(int bits)
void set_sector(int bits)
L1TMuonEndCapTrackProducer(const PSet &)
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
float calc_phi_glob_rad_hit(float loc, int sect_ind)
float Phi_loc_deg() const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
float calc_phi_loc_rad(int bits)
float calc_theta_deg_from_int(int _theta_int)
#define DEFINE_FWK_MODULE(type)
void set_charge_GMT(int bits)
void set_charge(int bits)
Geom::Theta< T > theta() const
void setType(unsigned type)
MatchingOutput PhiMatching(SortingOutput Sout)
std::vector< int > thetas
void set_pt_LUT_addr(unsigned long bits)
int calc_sector_GMT(int _sector)
std::vector< PatternOutput > Patterns(std::vector< ZonesOutput > Zones)
U second(std::pair< T, U > const &p)
const int hwQual() const
Get quality code.
int calc_sector_from_index(int index)
void addStub(const TriggerPrimitive &stub)
void ImportPtLUT(int _mode, unsigned long _address)
float calc_phi_loc_deg(int bits)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
float calc_eta_from_theta_rad(float _theta_rad)
std::vector< EMTFHit > EMTFHitCollection
void set_sector_index(int bits)
void produce(edm::Event &, const edm::EventSetup &)
l1t::RegionalMuonCand MakeRegionalCand(float pt, int phi, int theta, int sign, int mode, int trackaddress, int sector)
std::vector< std::vector< int > > deltas
const int hwEta() const
Get compressed eta (returned int * 0.010875 = eta)
const int hwPhi() const
Get compressed local phi (returned int * 2*pi/576 = local phi in rad)
int getCharge(int phi1, int phi2, int phi3, int phi4, int mode)
float calc_theta_rad_from_int(int _theta_int)
void set_phi_glob_rad(float val)
void set_eta_GMT(int bits)
void ImportCSCDetId(const CSCDetId &_detId)
unsigned long Pt_LUT_addr() const
float calc_phi_glob_rad(float loc, int sect)
void set_endcap(int bits)
Geom::Phi< T > phi() const
float calc_phi_glob_deg_hit(float loc, int sect_ind)
void set_phi_loc_rad(float val)
std::vector< BTrack > BestTracks(std::vector< std::vector< DeltaOutput >> Dout)
const int hwPt() const
Get compressed pT (returned int * 0.5 = pT (GeV))
void set_sector_GMT(int bits)
std::vector< std::vector< DeltaOutput > > CalcDeltas(MatchingOutput Mout)
std::vector< EMTFTrack > EMTFTrackCollection
PatternOutput DeleteDuplicatePatterns(std::vector< PatternOutput > Pout)
int phi
TEMPORARY ADDITION by G. Brown ///.
std::vector< std::vector< ConvertedHit > > GroupBX(std::vector< ConvertedHit > ConvHits)
float calc_phi_glob_deg(float loc, int sect)
std::vector< EMTFTrackExtra > EMTFTrackExtraCollection
void set_phi_loc_deg(float val)
std::vector< ZonesOutput > Zones(std::vector< std::vector< ConvertedHit >> Hits)
void set_phi_glob_deg(float val)