Go to the documentation of this file.00001
00007 #include "RecoMuon/MuonSeedGenerator/src/RPCSeedLayerFinder.h"
00008
00009 using namespace std;
00010 using namespace edm;
00011
00012
00013 RPCSeedLayerFinder::RPCSeedLayerFinder() {
00014
00015
00016 LayersinRPC.clear();
00017 isConfigured = false;
00018 isInputset = false;
00019 isOutputset = false;
00020 }
00021
00022 RPCSeedLayerFinder::~RPCSeedLayerFinder() {
00023
00024 }
00025
00026 void RPCSeedLayerFinder::configure(const edm::ParameterSet& iConfig) {
00027
00028
00029 isCosmic = iConfig.getParameter<bool>("isCosmic");
00030 isMixBarrelwithEndcap = iConfig.getParameter<bool>("isMixBarrelwithEndcap");
00031 RangeofLayersinBarrel = iConfig.getParameter< std::vector<unsigned int> >("RangeofLayersinBarrel");
00032 RangeofLayersinEndcap = iConfig.getParameter< std::vector<unsigned int> >("RangeofLayersinEndcap");
00033 isSpecialLayers = iConfig.getParameter<bool>("isSpecialLayers");
00034 LayersinBarrel = iConfig.getParameter< std::vector<unsigned int> >("LayersinBarrel");
00035 LayersinEndcap = iConfig.getParameter< std::vector<unsigned int> >("LayersinEndcap");
00036 constrainedLayersinBarrel = iConfig.getParameter< std::vector<unsigned int> >("constrainedLayersinBarrel");
00037
00038
00039 isConfigured = true;
00040 }
00041
00042 void RPCSeedLayerFinder::setInput(MuonRecHitContainer (&recHitsRPC)[RPCLayerNumber]) {
00043
00044 for(unsigned int i = 0; i < RPCLayerNumber; i++)
00045 recHitsinLayers[i] = recHitsRPC[i].size();
00046
00047
00048 isInputset = true;
00049 }
00050
00051 void RPCSeedLayerFinder::unsetInput() {
00052
00053 isInputset = false;
00054 }
00055
00056 void RPCSeedLayerFinder::setOutput(RPCSeedrecHitFinder* Ref = NULL, RPCCosmicSeedrecHitFinder* CosmicRef = NULL) {
00057
00058 RPCrecHitFinderRef = Ref;
00059 RPCCosmicrecHitFinderRef = CosmicRef;
00060 isOutputset = true;
00061 }
00062
00063 void RPCSeedLayerFinder::fill() {
00064
00065
00066 if(isConfigured == false || isInputset == false || isOutputset == false) {
00067 cout << "RPCSeedLayerFinder needs to be configured and set IO before running RPCSeedLayerFinder::fillLayers()" << endl;
00068 return;
00069 }
00070
00071
00072 LayersinRPC.clear();
00073
00074
00075 if(isCosmic == true) {
00076 if(RPCCosmicrecHitFinderRef != NULL)
00077 fillCosmicLayers();
00078 else
00079 cout << "RPCCosmicrecHitFinderRef not set" << endl;
00080 }
00081 else {
00082 if(RPCrecHitFinderRef != NULL)
00083 fillLayers();
00084 else
00085 cout << "RPCrecHitFinderRef not set" << endl;
00086 }
00087 }
00088
00089 void RPCSeedLayerFinder::fillLayers() {
00090
00091 if(isSpecialLayers == false && isMixBarrelwithEndcap == false) {
00092 for(std::vector<unsigned int>::iterator NumberofLayersinBarrel = RangeofLayersinBarrel.begin(); NumberofLayersinBarrel != RangeofLayersinBarrel.end(); NumberofLayersinBarrel++) {
00093
00094 unsigned int NumberofLayers = *NumberofLayersinBarrel;
00095 if(NumberofLayers < 1 || NumberofLayers > BarrelLayerNumber)
00096 continue;
00097 int type = 0;
00098 LayersinRPC.clear();
00099 SpecialLayers(-1, NumberofLayers, type);
00100 LayersinRPC.clear();
00101 }
00102
00103 for(std::vector<unsigned int>::iterator NumberofLayersinEndcap = RangeofLayersinEndcap.begin(); NumberofLayersinEndcap != RangeofLayersinEndcap.end(); NumberofLayersinEndcap++) {
00104 unsigned int NumberofLayers = *NumberofLayersinEndcap;
00105 if(NumberofLayers < 1 || NumberofLayers > EachEndcapLayerNumber)
00106 continue;
00107 int type = 1;
00108
00109 LayersinRPC.clear();
00110 SpecialLayers(BarrelLayerNumber-1, NumberofLayers, type);
00111 LayersinRPC.clear();
00112
00113 LayersinRPC.clear();
00114 SpecialLayers(BarrelLayerNumber+EachEndcapLayerNumber-1, NumberofLayers, type);
00115 LayersinRPC.clear();
00116 }
00117 }
00118
00119 if(isSpecialLayers == true && isMixBarrelwithEndcap == false) {
00120
00121 bool EnoughforBarrel = true;
00122 unsigned int i = 0;
00123 LayersinRPC.clear();
00124 for(std::vector<unsigned int>::iterator it = LayersinBarrel.begin(); it != LayersinBarrel.end(); it++, i++) {
00125 if((*it) != 0 && i < BarrelLayerNumber) {
00126 if(recHitsinLayers[i] != 0)
00127 LayersinRPC.push_back(i);
00128 else {
00129 cout << "Not recHits in special Barrel layer " << i << endl;
00130 EnoughforBarrel = false;
00131 }
00132 }
00133 }
00134 if(EnoughforBarrel && (LayersinRPC.size() != 0)) {
00135
00136 RPCrecHitFinderRef->setLayers(LayersinRPC);
00137 RPCrecHitFinderRef->fillrecHits();
00138 }
00139 LayersinRPC.clear();
00140
00141
00142 bool EnoughforEndcap = true;
00143
00144
00145 i = BarrelLayerNumber;
00146 EnoughforEndcap = true;
00147 LayersinRPC.clear();
00148 for(std::vector<unsigned int>::iterator it = LayersinEndcap.begin(); it != LayersinEndcap.end(); it++, i++) {
00149 if((*it) != 0 && i < (BarrelLayerNumber+EachEndcapLayerNumber)) {
00150 if(recHitsinLayers[i] != 0)
00151 LayersinRPC.push_back(i);
00152 else {
00153 cout << "Not recHits in special Endcap " << (i - BarrelLayerNumber) << endl;
00154 EnoughforEndcap = false;
00155 }
00156 }
00157 }
00158 if(EnoughforEndcap && (LayersinRPC.size() != 0)) {
00159
00160 RPCrecHitFinderRef->setLayers(LayersinRPC);
00161 RPCrecHitFinderRef->fillrecHits();
00162 }
00163 LayersinRPC.clear();
00164
00165
00166 i = BarrelLayerNumber;
00167 EnoughforEndcap = true;
00168 LayersinRPC.clear();
00169 for(std::vector<unsigned int>::iterator it = LayersinEndcap.begin(); it != LayersinEndcap.end(); it++, i++) {
00170 if((*it) != 0 && i >= (BarrelLayerNumber+EachEndcapLayerNumber) && i < (BarrelLayerNumber+EachEndcapLayerNumber*2)) {
00171 if(recHitsinLayers[i] != 0)
00172 LayersinRPC.push_back(i);
00173 else {
00174 cout << "Not recHits in special Endcap " << i << endl;
00175 EnoughforEndcap = false;
00176 }
00177 }
00178 }
00179 if(EnoughforEndcap && (LayersinRPC.size() != 0)) {
00180
00181 RPCrecHitFinderRef->setLayers(LayersinRPC);
00182 RPCrecHitFinderRef->fillrecHits();
00183 }
00184 LayersinRPC.clear();
00185 }
00186
00187 if(isMixBarrelwithEndcap == true) {
00188 cout <<" Mix is not ready for non-cosmic case" << endl;
00189 LayersinRPC.clear();
00190 }
00191 }
00192
00193 void RPCSeedLayerFinder::fillCosmicLayers() {
00194
00195
00196 if(isSpecialLayers == true && isMixBarrelwithEndcap == false) {
00197
00198
00199 unsigned int i = 0;
00200 LayersinRPC.clear();
00201 for(std::vector<unsigned int>::iterator it = LayersinBarrel.begin(); it != LayersinBarrel.end(); it++, i++) {
00202 if((*it) != 0 && i < BarrelLayerNumber)
00203 if(recHitsinLayers[i] != 0)
00204 LayersinRPC.push_back(i);
00205 }
00206 if(LayersinRPC.size() != 0) {
00207
00208 RPCCosmicrecHitFinderRef->setLayers(LayersinRPC);
00209 RPCCosmicrecHitFinderRef->fillrecHits();
00210 }
00211 LayersinRPC.clear();
00212
00213
00214
00215
00216 i = BarrelLayerNumber;
00217 LayersinRPC.clear();
00218 for(std::vector<unsigned int>::iterator it = LayersinEndcap.begin(); it != LayersinEndcap.end(); it++, i++) {
00219 if((*it) != 0 && i < (BarrelLayerNumber+EachEndcapLayerNumber))
00220 if(recHitsinLayers[i] != 0)
00221 LayersinRPC.push_back(i);
00222 }
00223 if(LayersinRPC.size() != 0) {
00224
00225 RPCCosmicrecHitFinderRef->setLayers(LayersinRPC);
00226 RPCCosmicrecHitFinderRef->fillrecHits();
00227 }
00228 LayersinRPC.clear();
00229
00230
00231 i = BarrelLayerNumber;
00232 LayersinRPC.clear();
00233 for(std::vector<unsigned int>::iterator it = LayersinEndcap.begin(); it != LayersinEndcap.end(); it++, i++) {
00234 if((*it) != 0 && i >= (BarrelLayerNumber+EachEndcapLayerNumber) && i < (BarrelLayerNumber+EachEndcapLayerNumber*2))
00235 if(recHitsinLayers[i] != 0)
00236 LayersinRPC.push_back(i);
00237 }
00238 if(LayersinRPC.size() != 0) {
00239
00240 RPCCosmicrecHitFinderRef->setLayers(LayersinRPC);
00241 RPCCosmicrecHitFinderRef->fillrecHits();
00242 }
00243 LayersinRPC.clear();
00244 }
00245
00246 if(isSpecialLayers == true && isMixBarrelwithEndcap == true) {
00247
00248
00249 unsigned int i = 0;
00250 LayersinRPC.clear();
00251 for(std::vector<unsigned int>::iterator it = LayersinBarrel.begin(); it != LayersinBarrel.end(); it++, i++) {
00252 if((*it) != 0 && i < BarrelLayerNumber)
00253 if(recHitsinLayers[i] != 0)
00254 LayersinRPC.push_back(i);
00255 }
00256 i = BarrelLayerNumber;
00257 for(std::vector<unsigned int>::iterator it = LayersinEndcap.begin(); it != LayersinEndcap.end(); it++, i++) {
00258 if((*it) != 0 && i < (BarrelLayerNumber+EachEndcapLayerNumber*2))
00259 if(recHitsinLayers[i] != 0)
00260 LayersinRPC.push_back(i);
00261 }
00262
00263 if(LayersinRPC.size() != 0) {
00264
00265 RPCCosmicrecHitFinderRef->setLayers(LayersinRPC);
00266 RPCCosmicrecHitFinderRef->fillrecHits();
00267 }
00268 LayersinRPC.clear();
00269 }
00270
00271 if(isSpecialLayers == false) {
00272 cout << "Not ready for not SpecialLayers for Cosmic case" << endl;
00273 LayersinRPC.clear();
00274 }
00275 }
00276
00277 void RPCSeedLayerFinder::SpecialLayers(int last, unsigned int NumberofLayers, int type) {
00278
00279
00280
00281
00282 if(type == 0) {
00283 if(NumberofLayers > BarrelLayerNumber) {
00284 cout << "NumberofLayers larger than max layers in barrel" << endl;
00285 return;
00286 }
00287 for(unsigned int i = (last+1); i <= (BarrelLayerNumber-NumberofLayers+LayersinRPC.size()); i++) {
00288 if(recHitsinLayers[i] != 0) {
00289 LayersinRPC.push_back(i);
00290 last = i;
00291 if(LayersinRPC.size() < NumberofLayers)
00292 SpecialLayers(last, NumberofLayers, type);
00293 else {
00294 if(checkConstrain()) {
00295 cout << "Find special barrel layers: ";
00296 for(unsigned int k = 0; k < NumberofLayers; k++)
00297 cout << LayersinRPC[k] <<" ";
00298 cout << endl;
00299
00300 RPCrecHitFinderRef->setLayers(LayersinRPC);
00301 RPCrecHitFinderRef->fillrecHits();
00302 }
00303 else
00304 cout << "The layers don't contain all layers in constrain" << endl;
00305 }
00306 LayersinRPC.pop_back();
00307 }
00308 }
00309 }
00310
00311
00312 if(type == 1) {
00313 if(NumberofLayers > EachEndcapLayerNumber) {
00314 cout << "NumberofLayers larger than max layers in endcap" << endl;
00315 return;
00316 }
00317 if(last < (BarrelLayerNumber+EachEndcapLayerNumber-1) || (last == (BarrelLayerNumber+EachEndcapLayerNumber-1) && LayersinRPC.size() != 0)) {
00318
00319 for(unsigned int i = (last+1); i <= (BarrelLayerNumber+EachEndcapLayerNumber-NumberofLayers+LayersinRPC.size()); i++) {
00320 if(recHitsinLayers[i] != 0) {
00321 LayersinRPC.push_back(i);
00322 last = i;
00323 if(LayersinRPC.size() < NumberofLayers)
00324 SpecialLayers(last, NumberofLayers, type);
00325 else {
00326 cout << "Find special -Z endcap layers: ";
00327 for(unsigned int k = 0; k < NumberofLayers; k++)
00328 cout << LayersinRPC[k] <<" ";
00329 cout << endl;
00330
00331 RPCrecHitFinderRef->setLayers(LayersinRPC);
00332 RPCrecHitFinderRef->fillrecHits();
00333 }
00334 LayersinRPC.pop_back();
00335 }
00336 }
00337 }
00338 else
00339 {
00340
00341 for(unsigned int i = (last+1); i <= (BarrelLayerNumber+EachEndcapLayerNumber*2-NumberofLayers+LayersinRPC.size()); i++) {
00342 if(recHitsinLayers[i] != 0) {
00343 LayersinRPC.push_back(i);
00344 last = i;
00345 if(LayersinRPC.size() < NumberofLayers)
00346 SpecialLayers(last, NumberofLayers, type);
00347 else {
00348 cout << "Find special +Z endcap layers: ";
00349 for(unsigned int k = 0; k < NumberofLayers; k++)
00350 cout << LayersinRPC[k] <<" ";
00351 cout << endl;
00352
00353 RPCrecHitFinderRef->setLayers(LayersinRPC);
00354 RPCrecHitFinderRef->fillrecHits();
00355 }
00356 LayersinRPC.pop_back();
00357 }
00358 }
00359 }
00360 }
00361 }
00362
00363 bool RPCSeedLayerFinder::checkConstrain() {
00364
00365 bool pass = true;
00366 std::vector<unsigned int> fitConstrain = constrainedLayersinBarrel;
00367 for(unsigned int i = 0; i < LayersinRPC.size(); i++)
00368 fitConstrain[LayersinRPC[i]] = 0;
00369 for(unsigned int i = 0; i < BarrelLayerNumber; i++)
00370 if(fitConstrain[i] != 0)
00371 pass = false;
00372 return pass;
00373 }