13 std::vector<RecHitProcessor::CppfItem>& CppfVec1,
15 const int MaxClusterSize
25 std::map <std::pair<int, int>,
int> chamber_repetitions;
26 chamber_repetitions.clear();
28 for ( TrackingGeometry::DetContainer::const_iterator iDet = rpcGeom->
dets().begin(); iDet < rpcGeom->
dets().end(); iDet++ ) {
31 if (dynamic_cast<const RPCChamber*>( *iDet ) ==
nullptr )
continue;
33 auto chamb =
dynamic_cast<const RPCChamber*
>( *iDet );
35 std::vector<const RPCRoll*> rolls = (chamb->rolls());
38 for(
auto& iRoll : rolls){
44 typedef std::pair<RPCRecHitCollection::const_iterator, RPCRecHitCollection::const_iterator> rangeRecHits;
45 rangeRecHits recHitCollection = recHits->get(rpcId);
51 int rawId = rpcId.
rawId();
54 int Bx = rechit_it->BunchX();
55 int isValid = rechit_it->isValid();
56 int firststrip = rechit_it->firstClusterStrip();
57 int clustersize = rechit_it->clusterSize();
66 int rechitstrip = firststrip;
70 if (clustersize % 2 == 0) medium = 0.5*(clustersize);
71 else medium = 0.5*(clustersize-1);
72 rechitstrip += medium;
75 if(clustersize > MaxClusterSize)
continue;
85 (ring == 1 && station > 1) ? nsub = 3 : nsub = 6;
90 if ((global_phi > 15.) && (global_phi <= 16.3)) {
94 else if ((global_phi > 16.3) && (global_phi <= 53.)) {
98 else if ((global_phi > 53.) && (global_phi <= 75.)) {
103 else if ((global_phi > 75.) && (global_phi <= 76.3)) {
107 else if ((global_phi > 76.3) && (global_phi <= 113.)) {
111 else if ((global_phi > 113.) && (global_phi <= 135.)) {
117 else if ((global_phi > 135.) && (global_phi <= 136.3)) {
121 else if ((global_phi > 136.3) && (global_phi <= 173.)) {
125 else if ((global_phi > 173.) && (global_phi <= 180.)) {
130 else if ((global_phi < -165.) && (global_phi >= -180.)) {
135 else if ((global_phi > -165.) && (global_phi <= -163.7)) {
139 else if ((global_phi > -163.7) && (global_phi <= -127.)) {
143 else if ((global_phi > -127.) && (global_phi <= -105.)) {
148 else if ((global_phi > -105.) && (global_phi <= -103.7)) {
152 else if ((global_phi > -103.7) && (global_phi <= -67.)) {
156 else if ((global_phi > -67.) && (global_phi <= -45.)) {
161 else if ((global_phi > -45.) && (global_phi <= -43.7)) {
165 else if ((global_phi > -43.7) && (global_phi <= -7.)) {
169 else if ((global_phi > -7.) && (global_phi <= 15.)) {
180 double EMTFLink1 = 0.;
181 double EMTFLink2 = 0.;
183 std::vector<RecHitProcessor::CppfItem>::iterator cppf1;
184 std::vector<RecHitProcessor::CppfItem>::iterator cppf;
185 for(cppf1 = CppfVec1.begin(); cppf1 != CppfVec1.end(); cppf1++){
190 if(((*cppf1).rawId == rawId) && ((*cppf1).strip == rechitstrip)){
192 int old_strip = (*cppf1).strip;
196 if(cppf1 != CppfVec1.begin())
197 before = (*(cppf1-2)).
strip;
199 else if (cppf1 == CppfVec1.begin())
200 before = (*cppf1).strip;
202 if(cppf1 != CppfVec1.end())
203 after = (*(cppf1+2)).
strip;
205 else if (cppf1 == CppfVec1.end())
206 after = (*cppf1).strip;
210 if(clustersize == 2){
213 if(before < after) cppf=(cppf1-1);
214 else if (before > after) cppf=(cppf1+1);
216 else if(firststrip > 1){
217 if(before < after) cppf=(cppf1+1);
218 else if (before > after) cppf=(cppf1-1);
223 std::pair<int, int> temporal;
224 temporal = std::make_pair (station, chamberID);
227 std::map<std::pair<int, int>,
int>::iterator it;
228 it = chamber_repetitions.find(temporal);
232 if(it == chamber_repetitions.end()){
233 chamber_repetitions[temporal] = 1;
235 else if((it != chamber_repetitions.end()) && (chamber_repetitions[temporal] == 1)){
236 chamber_repetitions[temporal] = 2;
238 else if((it != chamber_repetitions.end()) && (chamber_repetitions[temporal] == 2)){
249 std::shared_ptr<l1t::CPPFDigi> MainVariables1(
new l1t::CPPFDigi(rpcId, Bx , (*cppf).int_phi, (*cppf).int_theta, isValid, (*cppf).lb, (*cppf).halfchannel, EMTFsector1, EMTFLink1, old_strip, clustersize, global_phi, global_theta));
250 std::shared_ptr<l1t::CPPFDigi> MainVariables2(
new l1t::CPPFDigi(rpcId, Bx , (*cppf).int_phi, (*cppf).int_theta, isValid, (*cppf).lb, (*cppf).halfchannel, EMTFsector2, EMTFLink2, old_strip, clustersize, global_phi, global_theta));
252 if ((EMTFsector1 > 0) && (EMTFsector2 == 0)){
253 cppfDigis.push_back(*MainVariables1.get());
255 else if ((EMTFsector1 > 0) && (EMTFsector2 > 0)){
256 cppfDigis.push_back(*MainVariables1.get());
257 cppfDigis.push_back(*MainVariables2.get());
259 else if ((EMTFsector1 == 0) && (EMTFsector2 == 0)) {
266 std::shared_ptr<l1t::CPPFDigi> MainVariables1(
new l1t::CPPFDigi(rpcId, Bx , (*cppf).int_phi, (*cppf).int_theta, isValid, (*cppf).lb, (*cppf).halfchannel, EMTFsector1, EMTFLink1, old_strip, clustersize, global_phi, global_theta));
267 std::shared_ptr<l1t::CPPFDigi> MainVariables2(
new l1t::CPPFDigi(rpcId, Bx , (*cppf).int_phi, (*cppf).int_theta, isValid, (*cppf).lb, (*cppf).halfchannel, EMTFsector2, EMTFLink2, old_strip, clustersize, global_phi, global_theta));
268 if ((EMTFsector1 > 0) && (EMTFsector2 == 0)){
269 cppfDigis.push_back(*MainVariables1.get());
271 else if ((EMTFsector1 > 0) && (EMTFsector2 > 0)){
272 cppfDigis.push_back(*MainVariables1.get());
273 cppfDigis.push_back(*MainVariables2.get());
275 else if ((EMTFsector1 == 0) && (EMTFsector2 == 0)) {
304 std::map <std::pair<int, int>,
int> chamber_repetitions;
305 chamber_repetitions.clear();
307 for ( TrackingGeometry::DetContainer::const_iterator iDet = rpcGeom->
dets().begin(); iDet < rpcGeom->
dets().end(); iDet++ ) {
310 if (dynamic_cast<const RPCChamber*>( *iDet ) ==
nullptr )
continue;
312 auto chamb =
dynamic_cast<const RPCChamber*
>( *iDet );
313 std::vector<const RPCRoll*> rolls = (chamb->rolls());
316 for(
auto& iRoll : rolls){
320 typedef std::pair<RPCRecHitCollection::const_iterator, RPCRecHitCollection::const_iterator> rangeRecHits;
321 rangeRecHits recHitCollection = recHits->get(rpcId);
329 int region = rpcId.
region();
330 int Bx = rechit_it->BunchX();
331 int isValid = rechit_it->isValid();
332 int firststrip = rechit_it->firstClusterStrip();
333 int clustersize = rechit_it->clusterSize();
344 int int_theta = (region == -1 ? 180. * 32. / 36.5 : 0.)
345 + (
float)region * global_theta * 32. / 36.5
349 if(global_theta < 8.5) int_theta = 0;
350 if(global_theta > 45.) int_theta = 31;
352 else if(region == -1) {
353 if(global_theta < 135.) int_theta = 31;
354 if(global_theta > 171.5) int_theta = 0;
358 (ring == 1 && station > 1) ? nsub = 3 : nsub = 6;
362 double local_phi = 0.;
367 if ((global_phi > 15.) && (global_phi <= 16.3)) {
368 local_phi = global_phi-15.;
372 else if ((global_phi > 16.3) && (global_phi <= 53.)) {
373 local_phi = global_phi-15.;
377 else if ((global_phi > 53.) && (global_phi <= 75.)) {
378 local_phi = global_phi-15.;
383 else if ((global_phi > 75.) && (global_phi <= 76.3)) {
384 local_phi = global_phi-15.;
388 else if ((global_phi > 76.3) && (global_phi <= 113.)) {
389 local_phi = global_phi-75.;
393 else if ((global_phi > 113.) && (global_phi <= 135.)) {
394 local_phi = global_phi-75.;
400 else if ((global_phi > 135.) && (global_phi <= 136.3)) {
401 local_phi = global_phi-75.;
405 else if ((global_phi > 136.3) && (global_phi <= 173.)) {
406 local_phi = global_phi-135.;
410 else if ((global_phi > 173.) && (global_phi <= 180.)) {
411 local_phi = global_phi-135.;
416 else if ((global_phi < -165.) && (global_phi >= -180.)) {
417 local_phi = global_phi+225.;
422 else if ((global_phi > -165.) && (global_phi <= -163.7)) {
423 local_phi = global_phi+225.;
427 else if ((global_phi > -163.7) && (global_phi <= -127.)) {
428 local_phi = global_phi+165.;
432 else if ((global_phi > -127.) && (global_phi <= -105.)) {
433 local_phi = global_phi+165.;
438 else if ((global_phi > -105.) && (global_phi <= -103.7)) {
439 local_phi = global_phi+165.;
443 else if ((global_phi > -103.7) && (global_phi <= -67.)) {
444 local_phi = global_phi+105.;
448 else if ((global_phi > -67.) && (global_phi <= -45.)) {
449 local_phi = global_phi+105.;
454 else if ((global_phi > -45.) && (global_phi <= -43.7)) {
455 local_phi = global_phi+105.;
459 else if ((global_phi > -43.7) && (global_phi <= -7.)) {
460 local_phi = global_phi+45.;
464 else if ((global_phi > -7.) && (global_phi <= 15.)) {
465 local_phi = global_phi+45.;
470 int int_phi =
int((local_phi + 22.0 )*15. + .5);
472 double EMTFLink1 = 0.;
473 double EMTFLink2 = 0.;
475 double halfchannel = 0.;
478 if (isValid == 0) int_phi = 2047;
480 assert(0 <= int_phi && int_phi < 1250);
481 assert(0 <= int_theta && int_theta < 32);
484 std::pair<int, int> temporal;
485 temporal = std::make_pair (station, chamberID);
488 std::map<std::pair<int, int>,
int>::iterator it;
489 it = chamber_repetitions.find(temporal);
491 if(it == chamber_repetitions.end()){
492 chamber_repetitions[temporal] = 1;
494 else if((it != chamber_repetitions.end()) && (chamber_repetitions[temporal] == 1)){
495 chamber_repetitions[temporal] = 2;
497 else if((it != chamber_repetitions.end()) && (chamber_repetitions[temporal] == 2)){
501 std::shared_ptr<l1t::CPPFDigi> MainVariables1(
new l1t::CPPFDigi(rpcId, Bx , int_phi, int_theta, isValid, lb, halfchannel, EMTFsector1, EMTFLink1, firststrip, clustersize, global_phi, global_theta));
502 std::shared_ptr<l1t::CPPFDigi> MainVariables2(
new l1t::CPPFDigi(rpcId, Bx , int_phi, int_theta, isValid, lb, halfchannel, EMTFsector2, EMTFLink2, firststrip, clustersize, global_phi, global_theta));
503 if(int_theta == 31)
continue;
504 if ((EMTFsector1 > 0) && (EMTFsector2 == 0)){
505 cppfDigis.push_back(*MainVariables1.get());
507 if ((EMTFsector1 > 0) && (EMTFsector2 > 0)){
508 cppfDigis.push_back(*MainVariables1.get());
509 cppfDigis.push_back(*MainVariables2.get());
511 if ((EMTFsector1 == 0) && (EMTFsector2 == 0)){
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Geom::Phi< T > phi() const
const Plane & surface() const
The nominal surface of the GeomDet.
Geom::Theta< T > theta() const
uint32_t rawId() const
get the raw id
CSCDetId chamberID(const CSCDetId &cscDetId)
takes layer ID, converts to chamber ID, switching ME1A to ME11
void processLook(const edm::Event &iEvent, const edm::EventSetup &iSetup, const edm::EDGetToken &recHitToken, std::vector< RecHitProcessor::CppfItem > &CppfVec1, l1t::CPPFDigiCollection &cppfDigis, const int MaxClusterSize) const
const DetContainer & dets() const override
Returm a vector of all GeomDet (including all GeomDetUnits)
void process(const edm::Event &iEvent, const edm::EventSetup &iSetup, const edm::EDGetToken &recHitToken, l1t::CPPFDigiCollection &cppfDigis) const
int sector() const
Sector id: the group of chambers at same phi (and increasing r)
int subsector() const
SubSector id : some sectors are divided along the phi direction in subsectors (from 1 to 4 in Barrel...
double rad_to_deg(double rad)
std::vector< CPPFDigi > CPPFDigiCollection
const RPCRoll * roll(RPCDetId id) const
Return a roll given its id.
int region() const
Region id: 0 for Barrel, +/-1 For +/- Endcap.