CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10_patch1/src/CalibTracker/SiStripLorentzAngle/src/LA_Filler.cc

Go to the documentation of this file.
00001 #include "CalibTracker/SiStripLorentzAngle/interface/LA_Filler_Fitter.h"
00002 #include "CalibTracker/SiStripCommon/interface/TTREE_FOREACH_ENTRY.hh"
00003 
00004 #include <cmath>
00005 #include <boost/lexical_cast.hpp>
00006 
00007 void LA_Filler_Fitter::
00008 fill(TTree* tree, Book& book) const {
00009   TTREE_FOREACH_ENTRY(tree) {
00010     TFE_MAX(maxEvents_);
00011     TFE_PRINTSTATUS;
00012     std::vector<unsigned> PLEAF( tsostrackmulti , tree );
00013     std::vector<unsigned> PLEAF( clusterdetid , tree );
00014     std::vector<unsigned> PLEAF( clusterwidth , tree );
00015     std::vector<float>    PLEAF( clustervariance , tree );
00016     std::vector<float>    PLEAF( tsosdriftx , tree );
00017     std::vector<float>    PLEAF( tsosdriftz , tree );
00018     std::vector<float>    PLEAF( tsoslocaltheta , tree );
00019     std::vector<float>    PLEAF( tsoslocalphi , tree );
00020     std::vector<float>    PLEAF( tsosglobalZofunitlocalY , tree );
00021 
00022     const unsigned N(clusterdetid.size());
00023     std::vector<float> BdotY(N,0); if(!ensembleBins_) { std::vector<float> PLEAF( tsosBdotY , tree ); swap(BdotY, tsosBdotY); }
00024     std::vector<float> localy(N,0); if(localYbin_) { std::vector<float> PLEAF( tsoslocaly , tree ); swap(localy, tsoslocaly);}
00025     std::vector<unsigned> seedstrip(N,0); if(stripsPerBin_) { std::vector<unsigned> PLEAF( clusterseedstrip , tree ); swap(seedstrip, clusterseedstrip);}
00026 
00027     for(unsigned i=0; i<N ; i++) {
00028 
00029       const SiStripDetId detid(clusterdetid[i]);
00030       if( tsostrackmulti[i] != 1 || ( detid.subDetector()!=SiStripDetId::TIB && 
00031                                       detid.subDetector()!=SiStripDetId::TOB)    )  continue;
00032 
00033       const int sign = tsosglobalZofunitlocalY[i] < 0 ? -1 : 1;
00034       const float tthetaL = sign * tsosdriftx[i] / tsosdriftz[i];
00035       const float tthetaT = sign * tan(tsoslocaltheta[i]) * cos(tsoslocalphi[i]);
00036   
00037       fill_one_cluster( book, 
00038                         granularity(detid, tthetaL, TFE_index, localy[i], seedstrip[i]%128),
00039                         clusterwidth[i], clustervariance[i], tthetaL, tthetaT, fabs(BdotY[i]) );
00040     }
00041   }
00042 }
00043 
00044 void LA_Filler_Fitter::
00045 fill_one_cluster( Book& book, 
00046                   const poly<std::string>& gran,
00047                   const unsigned width, const float variance, const float tthetaL, const float tthetaT,  const float BdotY ) const 
00048 {
00049   book.fill( tthetaL,                   gran+"_reconstruction", 360,-1.0,1.0 );
00050   book.fill( tthetaT-tthetaL,           gran+ allAndOne(width), 360,-1.0,1.0 );
00051   book.fill( tthetaT-tthetaL, variance, gran+  varWidth(width), 360,-1.0,1.0 );
00052   if(methods_ & WIDTH) book.fill( tthetaT, width, gran+method(WIDTH), 81,-0.6,0.6 );
00053   if(!ensembleBins_) {
00054     book.fill( BdotY, gran+"_field", 101,1,5);
00055     book.fill( width, gran+"_width", 10,0,10);
00056   }
00057 }
00058 
00059 poly<std::string> LA_Filler_Fitter::
00060 allAndOne(const unsigned width) const 
00061 { poly<std::string> a1("_all"); if(width==1) a1*="_w1"; return a1;}
00062 
00063 poly<std::string> LA_Filler_Fitter::
00064 varWidth(const unsigned width) const { 
00065   poly<std::string> vw; vw++; 
00066   if(width==2 && methods_ & (AVGV2|RMSV2) ) vw*=method(AVGV2,0);
00067   if(width==3 && methods_ & (AVGV3|RMSV3) ) vw*=method(AVGV3,0);
00068   return vw;
00069 }
00070 
00071 poly<std::string> LA_Filler_Fitter::
00072 granularity(const SiStripDetId detid, const float tthetaL, const Long64_t TFE_index, const float localy, const unsigned apvstrip) const {
00073   poly<std::string> gran;
00074   gran += subdetLabel(detid);
00075   if(byLayer_)  gran *= layerLabel(detid);
00076   if(byModule_) gran *= moduleLabel(detid);
00077   if(localYbin_) gran += (localy < 0 ? "_yM":"_yP") + boost::lexical_cast<std::string>(abs((int)(localy/localYbin_+(localy<0?-1:0))));
00078   if(stripsPerBin_) gran += "_strip"+boost::lexical_cast<std::string>((unsigned)((0.5+((apvstrip/64)?(127-apvstrip):apvstrip)/stripsPerBin_)*stripsPerBin_) );
00079   if(ensembleBins_) {
00080     gran+= "_ensembleBin"+boost::lexical_cast<std::string>((int)(ensembleBins_*(tthetaL-ensembleLow_)/(ensembleUp_-ensembleLow_)));
00081     gran+= "";
00082     if(ensembleSize_) gran*= "_sample"+boost::lexical_cast<std::string>(TFE_index % ensembleSize_);
00083   }
00084   return gran;
00085 }
00086 
00087 std::string LA_Filler_Fitter::
00088 subdetLabel(const SiStripDetId detid) { return detid.subDetector()==SiStripDetId::TOB? "TOB" : "TIB";}
00089 std::string LA_Filler_Fitter::
00090 moduleLabel(const SiStripDetId detid) { return subdetLabel(detid) + "_module"+boost::lexical_cast<std::string>(detid());}
00091 std::string LA_Filler_Fitter::
00092 layerLabel(const SiStripDetId detid) {
00093   unsigned layer = detid.subDetector() == SiStripDetId::TOB ? TOBDetId(detid()).layer() : TIBDetId(detid()).layer();
00094   return subdetLabel(detid)+"_layer"+boost::lexical_cast<std::string>(layer)+(detid.stereo()?"s":"a");
00095 }