CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_8_patch3/src/CalibTracker/SiStripCommon/plugins/ShallowClustersProducer.cc

Go to the documentation of this file.
00001 #include "CalibTracker/SiStripCommon/interface/ShallowClustersProducer.h"
00002 
00003 #include "FWCore/Framework/interface/Event.h"
00004 #include "FWCore/Framework/interface/ESHandle.h"
00005 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00006 #include "RecoLocalTracker/SiStripClusterizer/interface/SiStripClusterInfo.h"
00007 #include "DataFormats/SiStripDigi/interface/SiStripProcessedRawDigi.h"
00008 #include "DataFormats/Common/interface/DetSetVectorNew.h"
00009 #include "DataFormats/SiStripDetId/interface/TECDetId.h"
00010 #include "DataFormats/SiStripDetId/interface/TIBDetId.h"
00011 #include "DataFormats/SiStripDetId/interface/TIDDetId.h"
00012 #include "DataFormats/SiStripDetId/interface/TOBDetId.h"
00013 #include "boost/foreach.hpp"
00014 
00015 ShallowClustersProducer::ShallowClustersProducer(const edm::ParameterSet& iConfig) 
00016   : theClustersLabel(iConfig.getParameter<edm::InputTag>("Clusters")),
00017     Prefix(iConfig.getParameter<std::string>("Prefix") )
00018 {
00019   produces <std::vector<unsigned> >    ( Prefix + "number"       );
00020   produces <std::vector<unsigned> >    ( Prefix + "width"        );
00021   produces <std::vector<float> >       ( Prefix + "variance"     );
00022   produces <std::vector<float> >       ( Prefix + "barystrip"    );
00023   produces <std::vector<float> >       ( Prefix + "middlestrip"  );
00024   produces <std::vector<unsigned> >    ( Prefix + "charge"       );
00025   produces <std::vector<float> >       ( Prefix + "noise"        );
00026   produces <std::vector<float> >       ( Prefix + "ston"         );
00027   produces <std::vector<unsigned> >    ( Prefix + "seedstrip"    );
00028   produces <std::vector<unsigned> >    ( Prefix + "seedindex"    );
00029   produces <std::vector<unsigned> >    ( Prefix + "seedcharge"   );
00030   produces <std::vector<float> >       ( Prefix + "seednoise"    );
00031   produces <std::vector<float> >       ( Prefix + "seedgain"     );
00032   produces <std::vector<unsigned> >    ( Prefix + "qualityisbad" );
00033 
00034   produces <std::vector<float> >       ( Prefix + "rawchargeC"   );
00035   produces <std::vector<float> >       ( Prefix + "rawchargeL"   );
00036   produces <std::vector<float> >       ( Prefix + "rawchargeR"   );
00037   produces <std::vector<float> >       ( Prefix + "rawchargeLL"   );
00038   produces <std::vector<float> >       ( Prefix + "rawchargeRR"   );
00039   produces <std::vector<float> >       ( Prefix + "eta"          );
00040   produces <std::vector<float> >       ( Prefix + "foldedeta"    );
00041   produces <std::vector<float> >       ( Prefix + "etaX"         );
00042   produces <std::vector<float> >       ( Prefix + "etaasymm"     );
00043   produces <std::vector<float> >       ( Prefix + "outsideasymm");
00044   produces <std::vector<float> >       ( Prefix + "neweta");
00045   produces <std::vector<float> >       ( Prefix + "newetaerr");
00046   
00047   produces <std::vector<unsigned> >    ( Prefix + "detid"         );
00048   produces <std::vector<int> >         ( Prefix + "subdetid"      );
00049   produces <std::vector<int> >         ( Prefix + "module"        );
00050   produces <std::vector<int> >         ( Prefix + "side"          );
00051   produces <std::vector<int> >         ( Prefix + "layerwheel"    );
00052   produces <std::vector<int> >         ( Prefix + "stringringrod" );
00053   produces <std::vector<int> >         ( Prefix + "petal"         );
00054   produces <std::vector<int> >         ( Prefix + "stereo"        );
00055 
00056 }
00057 
00058 void ShallowClustersProducer::
00059 produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
00060   std::auto_ptr<std::vector<unsigned> >       number       ( new std::vector<unsigned>(7,0) );
00061   std::auto_ptr<std::vector<unsigned> >       width        ( new std::vector<unsigned>() );
00062   std::auto_ptr<std::vector<float> >          variance     ( new std::vector<float>() );
00063   std::auto_ptr<std::vector<float> >          barystrip    ( new std::vector<float>() );
00064   std::auto_ptr<std::vector<float> >          middlestrip  ( new std::vector<float>() );
00065   std::auto_ptr<std::vector<unsigned> >       charge       ( new std::vector<unsigned>() );
00066   std::auto_ptr<std::vector<float> >          noise        ( new std::vector<float>() );
00067   std::auto_ptr<std::vector<float> >          ston         ( new std::vector<float>() );
00068   std::auto_ptr<std::vector<unsigned> >       seedstrip    ( new std::vector<unsigned>() );
00069   std::auto_ptr<std::vector<unsigned> >       seedindex    ( new std::vector<unsigned>() );
00070   std::auto_ptr<std::vector<unsigned> >       seedcharge   ( new std::vector<unsigned>() );
00071   std::auto_ptr<std::vector<float> >          seednoise    ( new std::vector<float>() );
00072   std::auto_ptr<std::vector<float> >          seedgain     ( new std::vector<float>() );
00073   std::auto_ptr<std::vector<unsigned> >       qualityisbad ( new std::vector<unsigned>() );
00074 
00075   std::auto_ptr<std::vector<float> >          rawchargeC   ( new std::vector<float>() );
00076   std::auto_ptr<std::vector<float> >          rawchargeL   ( new std::vector<float>() );
00077   std::auto_ptr<std::vector<float> >          rawchargeR   ( new std::vector<float>() );
00078   std::auto_ptr<std::vector<float> >          rawchargeLL  ( new std::vector<float>() );
00079   std::auto_ptr<std::vector<float> >          rawchargeRR  ( new std::vector<float>() );
00080   std::auto_ptr<std::vector<float> >          etaX         ( new std::vector<float>() );
00081   std::auto_ptr<std::vector<float> >          eta          ( new std::vector<float>() );
00082   std::auto_ptr<std::vector<float> >          foldedeta    ( new std::vector<float>() );
00083   std::auto_ptr<std::vector<float> >          etaasymm     ( new std::vector<float>() );
00084   std::auto_ptr<std::vector<float> >          outsideasymm ( new std::vector<float>() );
00085   std::auto_ptr<std::vector<float> >          neweta       ( new std::vector<float>() );
00086   std::auto_ptr<std::vector<float> >          newetaerr    ( new std::vector<float>() );
00087   
00088   std::auto_ptr<std::vector<unsigned> >       detid          ( new std::vector<unsigned>() );
00089   std::auto_ptr<std::vector<int> >            subdetid       ( new std::vector<int>() );
00090   std::auto_ptr<std::vector<int> >            side           ( new std::vector<int>() );
00091   std::auto_ptr<std::vector<int> >            module         ( new std::vector<int>() );
00092   std::auto_ptr<std::vector<int> >            layerwheel     ( new std::vector<int>() );
00093   std::auto_ptr<std::vector<int> >            stringringrod  ( new std::vector<int>() );
00094   std::auto_ptr<std::vector<int> >            petal          ( new std::vector<int>() );
00095   std::auto_ptr<std::vector<int> >            stereo         ( new std::vector<int>());
00096 
00097   edm::Handle<edmNew::DetSetVector<SiStripCluster> > clusters;
00098   iEvent.getByLabel(theClustersLabel, clusters);
00099   
00100   edm::Handle<edm::DetSetVector<SiStripProcessedRawDigi> > rawProcessedDigis;
00101   iEvent.getByLabel("siStripProcessedRawDigis", "", rawProcessedDigis);
00102  
00103   edmNew::DetSetVector<SiStripCluster>::const_iterator itClusters=clusters->begin();
00104   for(;itClusters!=clusters->end();++itClusters){
00105     uint32_t id = itClusters->id();
00106     const moduleVars moduleV(id);
00107     for(edmNew::DetSet<SiStripCluster>::const_iterator cluster=itClusters->begin(); cluster!=itClusters->end();++cluster){
00108       
00109       const SiStripClusterInfo info(*cluster, iSetup, id);
00110       const NearDigis digis = rawProcessedDigis.isValid() ? NearDigis(info, *rawProcessedDigis) : NearDigis(info);
00111 
00112       (number->at(0))++;
00113       (number->at(moduleV.subdetid))++;
00114       width->push_back(        cluster->amplitudes().size()                              );
00115       barystrip->push_back(    cluster->barycenter()                                     );
00116       variance->push_back(     info.variance()                                         );
00117       middlestrip->push_back(  info.firstStrip() + info.width()/2.0                    );
00118       charge->push_back(       info.charge()                                           );
00119       noise->push_back(        info.noiseRescaledByGain()                              );
00120       ston->push_back(         info.signalOverNoise()                                  );
00121       seedstrip->push_back(    info.maxStrip()                                         );
00122       seedindex->push_back(    info.maxIndex()                                         );
00123       seedcharge->push_back(   info.maxCharge()                                        );
00124       seednoise->push_back(    info.stripNoisesRescaledByGain().at(info.maxIndex())   );
00125       seedgain->push_back(     info.stripGains().at(info.maxIndex())                  );
00126       qualityisbad->push_back( info.IsAnythingBad()                                    );
00127 
00128       rawchargeC->push_back(   digis.max            );
00129       rawchargeL->push_back(   digis.left           );
00130       rawchargeR->push_back(   digis.right          );
00131       rawchargeLL->push_back(  digis.Lleft          );
00132       rawchargeRR->push_back(  digis.Rright         );
00133       etaX->push_back(         digis.etaX()         );
00134       eta->push_back(          digis.eta()          );
00135       etaasymm->push_back(     digis.etaasymm()     );
00136       outsideasymm->push_back( digis.outsideasymm() );
00137       neweta->push_back(       (digis.last-digis.first)/info.charge() );
00138       newetaerr->push_back(    (sqrt(digis.last+digis.first))/pow(info.charge(),1.5) );
00139 
00140       detid->push_back(            id                 );                
00141       subdetid->push_back(         moduleV.subdetid      );          
00142       side->push_back(             moduleV.side          );                  
00143       module->push_back(           moduleV.module        );              
00144       layerwheel->push_back(       moduleV.layerwheel    );      
00145       stringringrod->push_back(    moduleV.stringringrod );
00146       petal->push_back(            moduleV.petal         );                
00147       stereo->push_back(           moduleV.stereo        );              
00148     }
00149   }
00150 
00151   iEvent.put( number,       Prefix + "number"       );
00152   iEvent.put( width,        Prefix + "width"        );
00153   iEvent.put( variance,     Prefix + "variance"     );
00154   iEvent.put( barystrip,    Prefix + "barystrip"    );
00155   iEvent.put( middlestrip,  Prefix + "middlestrip"  );
00156   iEvent.put( charge,       Prefix + "charge"       );
00157   iEvent.put( noise,        Prefix + "noise"        );
00158   iEvent.put( ston,         Prefix + "ston"         );
00159   iEvent.put( seedstrip,    Prefix + "seedstrip"    );
00160   iEvent.put( seedindex,    Prefix + "seedindex"    );
00161   iEvent.put( seedcharge,   Prefix + "seedcharge"   );
00162   iEvent.put( seednoise,    Prefix + "seednoise"    );
00163   iEvent.put( seedgain,     Prefix + "seedgain"     );
00164   iEvent.put( qualityisbad, Prefix + "qualityisbad" );
00165 
00166   iEvent.put( rawchargeC,   Prefix + "rawchargeC"   );
00167   iEvent.put( rawchargeL,   Prefix + "rawchargeL"   );
00168   iEvent.put( rawchargeR,   Prefix + "rawchargeR"   );
00169   iEvent.put( rawchargeLL,  Prefix + "rawchargeLL"  );
00170   iEvent.put( rawchargeRR,  Prefix + "rawchargeRR"  );
00171   iEvent.put( etaX,         Prefix + "etaX"         );
00172   iEvent.put( eta,          Prefix + "eta"          );
00173   iEvent.put( foldedeta,    Prefix + "foldedeta"    );
00174   iEvent.put( etaasymm,     Prefix + "etaasymm"     );
00175   iEvent.put( outsideasymm, Prefix + "outsideasymm" );
00176   iEvent.put( neweta,       Prefix + "neweta"       );
00177   iEvent.put( newetaerr,    Prefix + "newetaerr"    );
00178 
00179   iEvent.put( detid,         Prefix + "detid"         );
00180   iEvent.put( subdetid,      Prefix + "subdetid"      );
00181   iEvent.put( module,        Prefix + "module"        );
00182   iEvent.put( side,          Prefix + "side"          );
00183   iEvent.put( layerwheel,    Prefix + "layerwheel"    );
00184   iEvent.put( stringringrod, Prefix + "stringringrod" );
00185   iEvent.put( petal,         Prefix + "petal"         );
00186   iEvent.put( stereo,        Prefix + "stereo"        );
00187 
00188 }
00189 
00190 ShallowClustersProducer::NearDigis::
00191 NearDigis(const SiStripClusterInfo& info) {
00192   max =  info.maxCharge();
00193   left =           info.maxIndex()    > uint16_t(0)                ? info.stripCharges().at(info.maxIndex()-1)      : 0 ;
00194   Lleft =          info.maxIndex()    > uint16_t(1)                ? info.stripCharges().at(info.maxIndex()-2)      : 0 ;
00195   right=  unsigned(info.maxIndex()+1) < info.stripCharges().size() ? info.stripCharges().at(info.maxIndex()+1)      : 0 ;
00196   Rright= unsigned(info.maxIndex()+2) < info.stripCharges().size() ? info.stripCharges().at(info.maxIndex()+2)      : 0 ;
00197   first = info.stripCharges().at(0);
00198   last =  info.stripCharges().at(info.width()-1);
00199 }
00200 
00201 ShallowClustersProducer::NearDigis::
00202 NearDigis(const SiStripClusterInfo& info, const edm::DetSetVector<SiStripProcessedRawDigi>& rawProcessedDigis) {
00203   edm::DetSetVector<SiStripProcessedRawDigi>::const_iterator digiframe = rawProcessedDigis.find(info.detId());
00204   if( digiframe != rawProcessedDigis.end()) {
00205     max =                                                            digiframe->data.at(info.maxStrip()).adc()       ;
00206     left =            info.maxStrip()    > uint16_t(0)             ? digiframe->data.at(info.maxStrip()-1).adc() : 0 ;
00207     Lleft =           info.maxStrip()    > uint16_t(1)             ? digiframe->data.at(info.maxStrip()-2).adc() : 0 ;
00208     right =  unsigned(info.maxStrip()+1) < digiframe->data.size()  ? digiframe->data.at(info.maxStrip()+1).adc() : 0 ;
00209     Rright = unsigned(info.maxStrip()+2) < digiframe->data.size()  ? digiframe->data.at(info.maxStrip()+2).adc() : 0 ;
00210     first = digiframe->data.at(info.firstStrip()).adc();
00211     last = digiframe->data.at(info.firstStrip()+info.width() - 1).adc();
00212   } else {
00213     *this = NearDigis(info);
00214   }
00215 }
00216 
00217 ShallowClustersProducer::moduleVars::
00218 moduleVars(uint32_t detid) {
00219   SiStripDetId subdet(detid);
00220   subdetid = subdet.subDetector();
00221   if( SiStripDetId::TIB == subdetid ) {
00222     TIBDetId tib(detid);
00223     module        = tib.module(); 
00224     side          = (tib.isZMinusSide())?-1:1;  
00225     layerwheel    = tib.layer(); 
00226     stringringrod = tib.stringNumber(); 
00227     stereo        = tib.isStereo() ? 1 : 0;
00228   } else
00229   if( SiStripDetId::TID == subdetid ) {
00230     TIDDetId tid(detid);
00231     module        = tid.moduleNumber(); 
00232     side          = (tid.isZMinusSide())?-1:1;  
00233     layerwheel    = tid.wheel(); 
00234     stringringrod = tid.ringNumber(); 
00235     stereo        = tid.isStereo() ? 1 : 0;
00236   } else
00237   if( SiStripDetId::TOB == subdetid ) {
00238     TOBDetId tob(detid);
00239     module        = tob.module(); 
00240     side          = (tob.isZMinusSide())?-1:1;  
00241     layerwheel    = tob.layer(); 
00242     stringringrod = tob.rodNumber(); 
00243     stereo        = tob.isStereo() ? 1 : 0;
00244   } else
00245   if( SiStripDetId::TEC == subdetid ) {
00246     TECDetId tec(detid);
00247     module        = tec.module(); 
00248     side          = (tec.isZMinusSide())?-1:1;  
00249     layerwheel    = tec.wheel(); 
00250     stringringrod = tec.ringNumber(); 
00251     petal         = tec.petalNumber(); 
00252     stereo        = tec.isStereo() ? 1 : 0;
00253   } else {
00254     module = 0;
00255     side = 0;
00256     layerwheel=-1;
00257     stringringrod = -1;
00258     petal=-1;
00259   }
00260 }