CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_6/src/Validation/RecoTrack/plugins/SiStripTrackingRecHitsValid.cc

Go to the documentation of this file.
00001 // File: SiStripTrackingRecHitsValid.cc
00002 // // Author:  Arnaud Gay.
00003 // Creation Date:  July 2006.
00004 //
00005 //--------------------------------------------
00006 
00007 #include <memory>
00008 #include <string>
00009 #include <iostream>
00010 #include <TMath.h>
00011 #include "Validation/RecoTrack/interface/SiStripTrackingRecHitsValid.h"
00012 
00013 #include "DataFormats/TrajectorySeed/interface/TrajectorySeedCollection.h"
00014 #include "FWCore/Framework/interface/ESHandle.h"
00015 #include "DataFormats/GeometryVector/interface/GlobalVector.h"
00016 
00017 #include "DataFormats/GeometryVector/interface/LocalVector.h"
00018 
00019 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
00020 #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
00021 #include "TrackingTools/Records/interface/TransientRecHitRecord.h"
00022 #include "Geometry/TrackerGeometryBuilder/interface/GluedGeomDet.h"
00023 
00024 #include "DataFormats/TrackReco/interface/Track.h"
00025 #include "DataFormats/TrackReco/interface/TrackExtra.h"
00026 #include "DataFormats/TrackerRecHit2D/interface/SiStripMatchedRecHit2D.h"
00027 #include "DataFormats/DetId/interface/DetId.h" 
00028 #include "DataFormats/SiStripDetId/interface/StripSubdetector.h" 
00029 #include "DataFormats/SiStripDetId/interface/TECDetId.h" 
00030 #include "DataFormats/SiStripDetId/interface/TIBDetId.h" 
00031 #include "DataFormats/SiStripDetId/interface/TIDDetId.h"
00032 #include "DataFormats/SiStripDetId/interface/TOBDetId.h" 
00033 
00034 #include "DataFormats/GeometryVector/interface/LocalPoint.h"
00035 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
00036 
00037 #include "RecoLocalTracker/SiStripRecHitConverter/interface/StripCPE.h"
00038 
00039 using namespace std;
00040 
00041 // ROOT
00042 #include "TROOT.h"
00043 #include "TFile.h"
00044 #include "TTree.h"
00045 #include "TBranch.h"
00046 #include "TH1.h"
00047 #include "TH2.h"
00048 class TFile;
00049 
00050 SiStripTrackingRecHitsValid::SiStripTrackingRecHitsValid(const edm::ParameterSet& ps):dbe_(0)
00051 {
00052 
00053   conf_ = ps;
00054 
00055   // slices
00056 
00057   //Read config file
00058   //MTCCtrack_ = ps.getParameter<bool>("MTCCtrack");
00059   outputFile_ = ps.getUntrackedParameter<string>("outputFile", "striptrackingrechitshisto.root");
00060   //src_ = ps.getUntrackedParameter<std::string>( "src" );
00061   //builderName_ = ps.getParameter<std::string>("TTRHBuilder");   
00062 
00063   // Book histograms
00064   dbe_ = edm::Service<DQMStore>().operator->();
00065   //  dbe_->showDirStructure();
00066 
00067   dbe_->setCurrentFolder("Tracking/TrackingRecHits/Strip/ALL");
00068 
00069   Char_t histo[200];
00070 
00071   sprintf(histo,"Errx_LF");
00072   meErrxLF = dbe_->book1D(histo,"RecHit err(x) Local Frame coord.",100,0,0.005);  
00073   //  const float Entries1 = meErrxLF->getEntries();
00074 
00075   sprintf(histo,"Errx_MF");
00076   meErrxMF = dbe_->book1D(histo,"RecHit err(x) Meas. Frame coord.",100,0,0.5);  
00077 
00078   sprintf(histo,"Res_LF");
00079   meResLF = dbe_->book1D(histo,"RecHit Residual",100,-0.02,+0.02);  
00080 
00081   sprintf(histo,"Res_MF");
00082   meResMF = dbe_->book1D(histo,"RecHit Residual",100,-2,+2);  
00083 
00084   sprintf(histo,"Pull_LF");
00085   mePullLF = dbe_->book1D(histo,"Pull",100,-5.,5.);  
00086 
00087   sprintf(histo,"Pull_MF");
00088   mePullMF = dbe_->book1D(histo,"Pull",100,-5.,5.);  
00089 
00090   sprintf(histo,"Category");
00091   meCategory = dbe_->book1D(histo,"Cluster Category",10,0.,10.);  
00092 
00093   sprintf(histo,"Trackwidth");
00094   meTrackwidth = dbe_->book1D(histo,"Track width",100,0.,4.);  
00095 
00096   sprintf(histo,"Expectedwidth");
00097   meExpectedwidth = dbe_->book1D(histo,"Expected width",10,0.,10.);  
00098 
00099   sprintf(histo,"Clusterwidth");
00100   meClusterwidth = dbe_->book1D(histo,"Cluster width",10,0.,10.);  
00101 
00102   sprintf(histo,"Trackanglealpha");
00103   meTrackanglealpha = dbe_->book1D(histo,"Track angle alpha",100,-100.,100.);  
00104 
00105   sprintf(histo,"Trackanglebeta");
00106   meTrackanglebeta = dbe_->book1D(histo,"Track angle beta",100,-100.,100.);  
00107 
00108   sprintf(histo,"ErrxMFTrackwidthProfile_WClus1");
00109   meErrxMFTrackwidthProfileWClus1 = dbe_->bookProfile(histo,"Resolution Track width Profile", 12, 0., 4.,100, 0.,2.,"s");
00110 
00111   sprintf(histo,"ErrxMFTrackwidthProfile_WClus2");
00112   meErrxMFTrackwidthProfileWClus2 = dbe_->bookProfile(histo,"Resolution Track width Profile", 12, 0., 4.,100, 0.,2.,"");
00113 
00114   sprintf(histo,"ErrxMFTrackwidthProfile_WClus3");
00115   meErrxMFTrackwidthProfileWClus3 = dbe_->bookProfile(histo,"Resolution Track width Profile", 12, 0., 4.,100, 0.,2.,"s");
00116 
00117   sprintf(histo,"ErrxMFTrackwidthProfile_WClus4");
00118   meErrxMFTrackwidthProfileWClus4 = dbe_->bookProfile(histo,"Resolution Track width Profile", 12, 0., 4.,100, 0.,2.,"s");
00119 
00120   sprintf(histo,"ResMFTrackwidthProfile_WClus1");
00121   meResMFTrackwidthProfileWClus1 = dbe_->bookProfile(histo,"Resolution Track width Profile", 12, 0., 4.,100, 0.,2.,"s");
00122 
00123   sprintf(histo,"ResMFTrackwidthProfile_WClus2");
00124   meResMFTrackwidthProfileWClus2 = dbe_->bookProfile(histo,"Resolution Track width Profile", 12, 0., 4.,100, 0.,2.,"");
00125   sprintf(histo,"ResMFTrackwidthProfile_WClus21");
00126   meResMFTrackwidthProfileWClus21 = dbe_->bookProfile(histo,"Resolution Track width Profile", 12, 0., 4.,100, -2.,2.,"");
00127   sprintf(histo,"ResMFTrackwidthProfile_WClus22");
00128   meResMFTrackwidthProfileWClus22 = dbe_->bookProfile(histo,"Resolution Track width Profile", 12, 0., 4.,100, -5.,5.,"");
00129   sprintf(histo,"ResMFTrackwidthProfile_WClus23");
00130   meResMFTrackwidthProfileWClus23 = dbe_->bookProfile(histo,"Resolution Track width Profile", 12, 0., 4.,100, -0.5,0.5,"");
00131   //sprintf(histo,"ResMFTrackwidthProfile_WClus2");
00132   //meResMFTrackwidthProfileWClus22 = dbe_->bookProfile(histo,"Resolution Track width Profile", 12, 0., 4., 0.,2.,"s");
00133 
00134   sprintf(histo,"ResMFTrackwidthProfile_WClus3");
00135   meResMFTrackwidthProfileWClus3 = dbe_->bookProfile(histo,"Resolution Track width Profile", 12, 0., 4.,100, 0.,2.,"s");
00136 
00137   sprintf(histo,"ResMFTrackwidthProfile_WClus4");
00138   meResMFTrackwidthProfileWClus4 = dbe_->bookProfile(histo,"Resolution Track width Profile", 12, 0., 4.,100, 0.,2.,"s");
00139 
00140   sprintf(histo,"ErrxMFTrackwidthProfile");
00141   meErrxMFTrackwidthProfile = dbe_->bookProfile(histo,"Resolution Track width Profile", 12, 0., 4.,100, 0.,2.,"s");
00142 
00143   sprintf(histo,"ErrxMFTrackwidthProfile_Category1");
00144   meErrxMFTrackwidthProfileCategory1 = dbe_->bookProfile(histo,"Resolution Track width Profile Category1", 12, 0., 4.,100, -2.,2.,"s");
00145   sprintf(histo,"ErrxMFTrackwidthProfile_Category2");
00146   meErrxMFTrackwidthProfileCategory2 = dbe_->bookProfile(histo,"Resolution Track width Profile Category2", 12, 0., 4.,100, -2.,2.,"s");
00147 
00148   sprintf(histo,"ErrxMFTrackwidthProfile_Category3");
00149   meErrxMFTrackwidthProfileCategory3 = dbe_->bookProfile(histo,"Resolution Track width Profile Category3", 12, 0., 4.,100, -2.,2.,"s");
00150 
00151   sprintf(histo,"ErrxMFTrackwidthProfile_Category4");
00152   meErrxMFTrackwidthProfileCategory4 = dbe_->bookProfile(histo,"Resolution Track width Profile Category4", 12, 0., 4.,100, -2.,2.,"s");
00153 
00154   sprintf(histo,"ErrxMFClusterwidthProfile_Category1");
00155    meErrxMFClusterwidthProfileCategory1= dbe_->bookProfile(histo,"Resolution Cluster width Profile Category1", 100, 0., 10.,100, -2.,2.,"s");
00156 
00157   sprintf(histo,"ErrxMFAngleProfile");
00158   meErrxMFAngleProfile = dbe_->bookProfile(histo,"Resolution Angle Profile", 100, 0., 60.,100, 0.,2.,"s");
00159 
00160   dbe_->setCurrentFolder("Tracking/TrackingRecHits/Strip/TIB");
00161   //one histo per Layer rphi hits
00162   for(int i = 0 ;i<4 ; i++) {
00163     Char_t histo[200];
00164     sprintf(histo,"Nstp_rphi_layer%dtib",i+1);
00165     meNstpRphiTIB[i] = dbe_->book1D(histo,"RecHit Cluster Size",20,0.5,20.5);  
00166     sprintf(histo,"Adc_rphi_layer%dtib",i+1);
00167     meAdcRphiTIB[i] = dbe_->book1D(histo,"RecHit Cluster Charge",100,0.,300.);  
00168     sprintf(histo,"Posx_rphi_layer%dtib",i+1);
00169     mePosxRphiTIB[i] = dbe_->book1D(histo,"RecHit x coord.",100,-6.0,+6.0);  
00170 
00171     sprintf(histo,"Errx_LF_rphi_layer%dtib",i+1);
00172     meErrxLFRphiTIB[i] = dbe_->book1D(histo,"RecHit err(x) Local Frame coord.",100,0,0.005);  
00173     sprintf(histo,"Errx_MF_rphi_layer%dtib",i+1);
00174     meErrxMFRphiTIB[i] = dbe_->book1D(histo,"RecHit err(x) Meas. Frame coord.",100,0,0.5);  
00175 
00176     sprintf(histo,"Res_LF_rphi_layer%dtib",i+1);
00177     meResLFRphiTIB[i] = dbe_->book1D(histo,"RecHit Residual",100,-0.02,+0.02);  
00178     sprintf(histo,"Res_MF_rphi_layer%dtib",i+1);
00179     meResMFRphiTIB[i] = dbe_->book1D(histo,"RecHit Residual",100,-2,+2);  
00180 
00181     sprintf(histo,"Pull_LF_rphi_layer%dtib",i+1);
00182     mePullLFRphiTIB[i] = dbe_->book1D(histo,"Pull",100,-5.,5.);  
00183     sprintf(histo,"Pull_MF_rphi_layer%dtib",i+1);
00184     mePullMFRphiTIB[i] = dbe_->book1D(histo,"Pull",100,-5.,5.);  
00185 
00186     sprintf(histo,"Trackangle_rphi_layer%dtib",i+1);
00187     meTrackangleRphiTIB[i] = dbe_->book1D(histo,"Track angle",100,-20.,20.);  
00188 
00189     sprintf(histo,"Trackanglebeta_rphi_layer%dtib",i+1);
00190     meTrackanglebetaRphiTIB[i] = dbe_->book1D(histo,"Track angle beta",100,-20.,20.);  
00191 
00192     sprintf(histo,"Trackangle2_rphi_layer%dtib",i+1);
00193     meTrackangle2RphiTIB[i] = dbe_->book1D(histo,"Track angle",100,-20.,20.);  
00194 
00195     sprintf(histo,"PullTrackangleProfile_rphi_layer%dtib",i+1);
00196     mePullTrackangleProfileRphiTIB[i] = dbe_->bookProfile(histo,"Pull Track angle Profile", 100, -20., 20.,100, -2.,2.,"s");
00197 
00198     sprintf(histo,"Trackwidth_rphi_layer%dtib",i+1);
00199     meTrackwidthRphiTIB[i] = dbe_->book1D(histo,"Track width",100,0.,1.);  
00200 
00201     sprintf(histo,"Expectedwidth_rphi_layer%dtib",i+1);
00202     meExpectedwidthRphiTIB[i] = dbe_->book1D(histo,"Expected width",10,0.,10.);  
00203 
00204     sprintf(histo,"Clusterwidth_rphi_layer%dtib",i+1);
00205     meClusterwidthRphiTIB[i] = dbe_->book1D(histo,"Cluster width",10,0.,10.);  
00206 
00207     sprintf(histo,"Category_rphi_layer%dtib",i+1);
00208     meCategoryRphiTIB[i] = dbe_->book1D(histo,"Cluster Category",10,0.,10.);  
00209 
00210     sprintf(histo,"PullTrackwidthProfile_rphi_layer%dtib",i+1);
00211     mePullTrackwidthProfileRphiTIB[i] = dbe_->bookProfile(histo,"Pull Track width Profile", 100, 0., 1.,100, -2.,2.,"s");
00212 
00213     sprintf(histo,"PullTrackwidthProfile_Category1_rphi_layer%dtib",i+1);
00214     mePullTrackwidthProfileCategory1RphiTIB[i] = dbe_->bookProfile(histo,"Pull Track width Profile Category1", 100, 0., 1.,100, -2.,2.,"s");
00215 
00216     sprintf(histo,"PullTrackwidthProfile_Category2_rphi_layer%dtib",i+1);
00217     mePullTrackwidthProfileCategory2RphiTIB[i] = dbe_->bookProfile(histo,"Pull Track width Profile Category2", 100, 0., 1.,100, -2.,2.,"s");
00218     
00219     sprintf(histo,"PullTrackwidthProfile_Category3_rphi_layer%dtib",i+1);
00220     mePullTrackwidthProfileCategory3RphiTIB[i] = dbe_->bookProfile(histo,"Pull Track width Profile Category3", 100, 0., 1.,100, -2.,2.,"s");
00221     
00222     sprintf(histo,"PullTrackwidthProfile_Category4_rphi_layer%dtib",i+1);
00223     mePullTrackwidthProfileCategory4RphiTIB[i] = dbe_->bookProfile(histo,"Pull Track width Profile Category4", 100, 0., 1.,100, -2.,2.,"s");
00224     
00225     sprintf(histo,"ErrxMFTrackwidthProfile_rphi_layer%dtib",i+1);
00226     meErrxMFTrackwidthProfileRphiTIB[i] = dbe_->bookProfile(histo,"Resolution Track width Profile", 12, 0., 4.,100, -2.,2.,"s");
00227 
00228 
00229     sprintf(histo,"ErrxMFTrackwidthProfile_WClus1_rphi_layer%dtib",i+1);
00230     meErrxMFTrackwidthProfileWclus1RphiTIB[i] = dbe_->bookProfile(histo,"Resolution Track width Profile Wclus1", 12, 0., 4.,100, -2.,2.,"s");
00231 
00232     sprintf(histo,"ErrxMFTrackwidthProfile_WClus2_rphi_layer%dtib",i+1);
00233     meErrxMFTrackwidthProfileWclus2RphiTIB[i] = dbe_->bookProfile(histo,"Resolution Track width Profile Wclus1", 12, 0., 4.,100, -2.,2.,"s");
00234 
00235     sprintf(histo,"ErrxMFTrackwidthProfile_WClus3_rphi_layer%dtib",i+1);
00236     meErrxMFTrackwidthProfileWclus3RphiTIB[i] = dbe_->bookProfile(histo,"Resolution Track width Profile Wclus1", 12, 0., 4.,100, -2.,2.,"s");
00237 
00238     sprintf(histo,"ErrxMFTrackwidthProfile_WClus4_rphi_layer%dtib",i+1);
00239     meErrxMFTrackwidthProfileWclus4RphiTIB[i] = dbe_->bookProfile(histo,"Resolution Track width Profile Wclus1", 12, 0., 4.,100, -2.,2.,"s");
00240 
00241     sprintf(histo,"ResMFTrackwidthProfile_WClus1_rphi_layer%dtib",i+1);
00242     meResMFTrackwidthProfileWclus1RphiTIB[i] = dbe_->bookProfile(histo,"Residue Track width Profile Wclus1", 12, 0., 4.,100, -2.,2.,"s");
00243     sprintf(histo,"ResMFTrackwidthProfile_WClus2_rphi_layer%dtib",i+1);
00244     meResMFTrackwidthProfileWclus2RphiTIB[i] = dbe_->bookProfile(histo,"Residue Track width Profile Wclus1", 12, 0., 4.,100, -2.,2.,"s");
00245 
00246     sprintf(histo,"ResMFTrackwidthProfile_WClus3_rphi_layer%dtib",i+1);
00247     meResMFTrackwidthProfileWclus3RphiTIB[i] = dbe_->bookProfile(histo,"Residue Track width Profile Wclus1", 12, 0., 4.,100, -2.,2.,"s");
00248 
00249     sprintf(histo,"ResMFTrackwidthProfile_WClus4_rphi_layer%dtib",i+1);
00250     meResMFTrackwidthProfileWclus4RphiTIB[i] = dbe_->bookProfile(histo,"Residue Track width Profile Wclus1", 12, 0., 4.,100, -2.,2.,"s");
00251 
00252 
00253 
00254     sprintf(histo,"ErrxMFTrackwidthProfile_Category1_rphi_layer%dtib",i+1);
00255     meErrxMFTrackwidthProfileCategory1RphiTIB[i] = dbe_->bookProfile(histo,"Resolution Track width Profile Category1", 12, 0., 4.,100, -2.,2.,"s");
00256 
00257     sprintf(histo,"ErrxMFTrackwidthProfile_Category2_rphi_layer%dtib",i+1);
00258     meErrxMFTrackwidthProfileCategory2RphiTIB[i] = dbe_->bookProfile(histo,"Resolution Track width Profile Category2", 12, 0., 4.,100, -2.,2.,"s");
00259 
00260     sprintf(histo,"ErrxMFTrackwidthProfile_Category3_rphi_layer%dtib",i+1);
00261     meErrxMFTrackwidthProfileCategory3RphiTIB[i] = dbe_->bookProfile(histo,"Resolution Track width Profile Category3", 12, 0., 4.,100, -2.,2.,"s");
00262 
00263     sprintf(histo,"ErrxMFTrackwidthProfile_Category4_rphi_layer%dtib",i+1);
00264     meErrxMFTrackwidthProfileCategory4RphiTIB[i] = dbe_->bookProfile(histo,"Resolution Track width Profile Category4", 12, 0., 4.,100, -2.,2.,"s");
00265 
00266     sprintf(histo,"ErrxMFAngleProfile_rphi_layer%dtib",i+1);
00267     meErrxMFAngleProfileRphiTIB[i] = dbe_->bookProfile(histo,"Resolution Angle Profile", 100, 0., 1.,100, -2.,2.,"s");
00268 
00269     sprintf(histo,"ErrxMFClusterwidthProfile_Category1_rphi_layer%dtib",i+1);
00270     meErrxMFClusterwidthProfileCategory1RphiTIB[i] = dbe_->bookProfile(histo,"Resolution Cluster width Profile Category1", 100, 0., 10.,100, -2.,2.,"s");
00271     
00272   }
00273 
00274   //one histo per Layer stereo and matched hits
00275   for(int i = 0 ;i<2 ; i++) {
00276     Char_t histo[200];
00277     sprintf(histo,"Nstp_sas_layer%dtib",i+1);
00278     meNstpSasTIB[i] = dbe_->book1D(histo,"RecHit Cluster Size",20,0.5,20.5);  
00279     sprintf(histo,"Adc_sas_layer%dtib",i+1);
00280     meAdcSasTIB[i] = dbe_->book1D(histo,"RecHit Cluster Charge",100,0.,300.);  
00281     sprintf(histo,"Posx_sas_layer%dtib",i+1);
00282     mePosxSasTIB[i] = dbe_->book1D(histo,"RecHit x coord.",100,-6.0,+6.0);  
00283 
00284     sprintf(histo,"Errx_LF_sas_layer%dtib",i+1);
00285     meErrxLFSasTIB[i] = dbe_->book1D(histo,"RecHit err(x) coord.",100,0.,0.005);  
00286     sprintf(histo,"Errx_MF_sas_layer%dtib",i+1);
00287     meErrxMFSasTIB[i] = dbe_->book1D(histo,"RecHit err(x) coord.",100,0.,0.5);  
00288 
00289     sprintf(histo,"Res_LF_sas_layer%dtib",i+1);
00290     meResLFSasTIB[i] = dbe_->book1D(histo,"RecHit Residual",100,-0.02,+0.02);  
00291     sprintf(histo,"Res_MF_sas_layer%dtib",i+1);
00292     meResMFSasTIB[i] = dbe_->book1D(histo,"RecHit Residual",100,-2,+2);  
00293 
00294     sprintf(histo,"Pull_LF_sas_layer%dtib",i+1);
00295     mePullLFSasTIB[i] = dbe_->book1D(histo,"Pull",100,-4.,4.);  
00296     sprintf(histo,"Pull_MF_sas_layer%dtib",i+1);
00297     mePullMFSasTIB[i] = dbe_->book1D(histo,"Pull",100,-4.,4.);  
00298 
00299     sprintf(histo,"Trackangle_sas_layer%dtib",i+1);
00300     meTrackangleSasTIB[i] = dbe_->book1D(histo,"Track angle",100,-40.,40.);  
00301 
00302     sprintf(histo,"Trackanglebeta_sas_layer%dtib",i+1);
00303     meTrackanglebetaSasTIB[i] = dbe_->book1D(histo,"Track angle beta",100,-40.,40.);  
00304 
00305     sprintf(histo,"PullTrackangleProfile_sas_layer%dtib",i+1);
00306     mePullTrackangleProfileSasTIB[i] = dbe_->bookProfile(histo,"Pull Track angle Profile",  100, -40., 40.,100,-4.,4.,"s");
00307 
00308     sprintf(histo,"Trackwidth_sas_layer%dtib",i+1);
00309     meTrackwidthSasTIB[i] = dbe_->book1D(histo,"Track width",100,0.,1.);  
00310 
00311     sprintf(histo,"Expectedwidth_sas_layer%dtib",i+1);
00312     meExpectedwidthSasTIB[i] = dbe_->book1D(histo,"Expected width",10,0.,10.);  
00313 
00314     sprintf(histo,"Clusterwidth_sas_layer%dtib",i+1);
00315     meClusterwidthSasTIB[i] = dbe_->book1D(histo,"Cluster width",10,0.,10.);  
00316 
00317     sprintf(histo,"Category_sas_layer%dtib",i+1);
00318     meCategorySasTIB[i] = dbe_->book1D(histo,"Cluster Category",10,0.,10.);  
00319 
00320     sprintf(histo,"PullTrackwidthProfile_sas_layer%dtib",i+1);
00321     mePullTrackwidthProfileSasTIB[i] = dbe_->bookProfile(histo,"Pull Track width Profile", 100, 0., 1.,100, -2.,2.,"s");
00322 
00323     sprintf(histo,"PullTrackwidthProfile_Category1_sas_layer%dtib",i+1);
00324     mePullTrackwidthProfileCategory1SasTIB[i] = dbe_->bookProfile(histo,"Pull Track width Profile Category1", 100, 0., 1.,100, -2.,2.,"s");
00325 
00326     sprintf(histo,"PullTrackwidthProfile_Category2_sas_layer%dtib",i+1);
00327     mePullTrackwidthProfileCategory2SasTIB[i] = dbe_->bookProfile(histo,"Pull Track width Profile Category2", 100, 0., 1.,100, -2.,2.,"s");
00328     
00329     sprintf(histo,"PullTrackwidthProfile_Category3_sas_layer%dtib",i+1);
00330     mePullTrackwidthProfileCategory3SasTIB[i] = dbe_->bookProfile(histo,"Pull Track width Profile Category3", 100, 0., 1.,100, -2.,2.,"s");
00331     
00332     sprintf(histo,"PullTrackwidthProfile_Category4_sas_layer%dtib",i+1);
00333     mePullTrackwidthProfileCategory4SasTIB[i] = dbe_->bookProfile(histo,"Pull Track width Profile Category4", 100, 0., 1.,100, -2.,2.,"s");
00334 
00335     sprintf(histo,"ErrxMFTrackwidthProfile_sas_layer%dtib",i+1);
00336     meErrxMFTrackwidthProfileSasTIB[i] = dbe_->bookProfile(histo,"Resolution Track width Profile", 12,0.,4.,100, -2.,2.,"s");
00337 
00338     sprintf(histo,"ErrxMFTrackwidthProfile_Category1_sas_layer%dtib",i+1);
00339     meErrxMFTrackwidthProfileCategory1SasTIB[i] = dbe_->bookProfile(histo,"Resolution Track width Profile Category1", 12,0.,4.,100, -2.,2.,"s");
00340     sprintf(histo,"ErrxMFTrackwidthProfile_Category2_sas_layer%dtib",i+1);
00341     meErrxMFTrackwidthProfileCategory2SasTIB[i] = dbe_->bookProfile(histo,"Resolution Track width Profile Category2", 12,0.,4.,100, -2.,2.,"s");
00342     sprintf(histo,"ErrxMFTrackwidthProfile_Category3_sas_layer%dtib",i+1);
00343     meErrxMFTrackwidthProfileCategory3SasTIB[i] = dbe_->bookProfile(histo,"Resolution Track width Profile Category3", 12,0.,4.,100, -2.,2.,"s");
00344     sprintf(histo,"ErrxMFTrackwidthProfile_Category4_sas_layer%dtib",i+1);
00345     meErrxMFTrackwidthProfileCategory4SasTIB[i] = dbe_->bookProfile(histo,"Resolution Track width Profile Category4", 12,0.,4.,100, -2.,2.,"s");
00346 
00347     sprintf(histo,"ErrxMFAngleProfile_sas_layer%dtib",i+1);
00348     meErrxMFAngleProfileSasTIB[i] = dbe_->bookProfile(histo,"Resolution Angle Profile", 100, 0., 1.,100, -2.,2.,"s");
00349 
00350     sprintf(histo,"ErrxMFClusterwidthProfile_Category1_sas_layer%dtib",i+1);
00351     meErrxMFClusterwidthProfileCategory1SasTIB[i] = dbe_->bookProfile(histo,"Resolution Cluster width Profile Category1", 100, 0., 10.,100, -2.,2.,"s");
00352     
00353 
00354 
00355     sprintf(histo,"Posx_matched_layer%dtib",i+1);
00356     mePosxMatchedTIB[i] = dbe_->book1D(histo,"RecHit x coord.",100,-6.0, +6.0);  
00357     sprintf(histo,"Posy_matched_layer%dtib",i+1);
00358     mePosyMatchedTIB[i] = dbe_->book1D(histo,"RecHit y coord.",100,-6.0, +6.0);  
00359     sprintf(histo,"Errx_matched_layer%dtib",i+1);
00360     meErrxMatchedTIB[i] = dbe_->book1D(histo,"RecHit err(x) coord.",100,0., 0.05);  
00361     sprintf(histo,"Erry_matched_layer%dtib",i+1);
00362     meErryMatchedTIB[i] = dbe_->book1D(histo,"RecHit err(y) coord.",100,0., 0.05);  
00363     sprintf(histo,"Resx_matched_layer%dtib",i+1);
00364     meResxMatchedTIB[i] = dbe_->book1D(histo,"RecHit Res(x) coord.",100,-0.02, +0.02);  
00365     sprintf(histo,"Resy_matched_layer%dtib",i+1);
00366     meResyMatchedTIB[i] = dbe_->book1D(histo,"RecHit Res(y) coord.",100,-1., +1.);  
00367     sprintf(histo,"Pullx_matched_layer%dtib",i+1);
00368     mePullxMatchedTIB[i] = dbe_->book1D(histo,"Pull",100,-5.,5.);  
00369     sprintf(histo,"Pully_matched_layer%dtib",i+1);
00370     mePullyMatchedTIB[i] = dbe_->book1D(histo,"Pull",100,-5.,5.);  
00371   }
00372 
00373   dbe_->setCurrentFolder("Tracking/TrackingRecHits/Strip/TOB");
00374   //one histo per Layer rphi hits
00375   for(int i = 0 ;i<6 ; i++) {
00376     Char_t histo[200];
00377     sprintf(histo,"Nstp_rphi_layer%dtob",i+1);
00378     meNstpRphiTOB[i] = dbe_->book1D(histo,"RecHit Cluster Size",20,0.5,20.5);  
00379     sprintf(histo,"Adc_rphi_layer%dtob",i+1);
00380     meAdcRphiTOB[i] = dbe_->book1D(histo,"RecHit Cluster Charge",100,0.,300.);  
00381     sprintf(histo,"Posx_rphi_layer%dtob",i+1);
00382     mePosxRphiTOB[i] = dbe_->book1D(histo,"RecHit x coord.",100,-6.0,+6.0);  
00383 
00384     sprintf(histo,"Errx_LF_rphi_layer%dtob",i+1);
00385     meErrxLFRphiTOB[i] = dbe_->book1D(histo,"RecHit err(x) coord.",100,0,0.01);  
00386     sprintf(histo,"Errx_MF_rphi_layer%dtob",i+1);
00387     meErrxMFRphiTOB[i] = dbe_->book1D(histo,"RecHit err(x) coord.",100,0,0.5);  
00388 
00389     sprintf(histo,"Res_LF_rphi_layer%dtob",i+1);
00390     meResLFRphiTOB[i] = dbe_->book1D(histo,"RecHit Residual",100,-0.02,+0.02);  
00391     sprintf(histo,"Res_MF_rphi_layer%dtob",i+1);
00392     meResMFRphiTOB[i] = dbe_->book1D(histo,"RecHit Residual",100,-2,2);  
00393 
00394     sprintf(histo,"Pull_LF_rphi_layer%dtob",i+1);
00395     mePullLFRphiTOB[i] = dbe_->book1D(histo,"Pull",100,-5.,5.);  
00396     sprintf(histo,"Pull_MF_rphi_layer%dtob",i+1);
00397     mePullMFRphiTOB[i] = dbe_->book1D(histo,"Pull",100,-5.,5.);  
00398 
00399     sprintf(histo,"Trackangle_rphi_layer%dtob",i+1);
00400     meTrackangleRphiTOB[i] = dbe_->book1D(histo,"Track angle",100,-20.,20.);  
00401 
00402     sprintf(histo,"Trackanglebeta_rphi_layer%dtob",i+1);
00403     meTrackanglebetaRphiTOB[i] = dbe_->book1D(histo,"Track angle beta",100,-20.,20.);  
00404 
00405     sprintf(histo,"PullTrackangleProfile_rphi_layer%dtob",i+1);
00406     mePullTrackangleProfileRphiTOB[i] = dbe_->bookProfile(histo,"Pull Track angle Profile",  100, -20., 20.,100,-5.,5.,"s");
00407 
00408     sprintf(histo,"Trackwidth_rphi_layer%dtob",i+1);
00409     meTrackwidthRphiTOB[i] = dbe_->book1D(histo,"Track width",100,0.,4.);  
00410 
00411     sprintf(histo,"Expectedwidth_rphi_layer%dtob",i+1);
00412     meExpectedwidthRphiTOB[i] = dbe_->book1D(histo,"Expected width",10,0.,10.);  
00413 
00414     sprintf(histo,"Clusterwidth_rphi_layer%dtob",i+1);
00415     meClusterwidthRphiTOB[i] = dbe_->book1D(histo,"Cluster width",10,0.,10.);  
00416 
00417     sprintf(histo,"Category_rphi_layer%dtob",i+1);
00418     meCategoryRphiTOB[i] = dbe_->book1D(histo,"Cluster Category",10,0.,10.);  
00419 
00420     sprintf(histo,"PullTrackwidthProfile_rphi_layer%dtob",i+1);
00421     mePullTrackwidthProfileRphiTOB[i] = dbe_->bookProfile(histo,"Pull Track width Profile", 100, 0., 1.,100, -2.,2.,"s");
00422 
00423     sprintf(histo,"PullTrackwidthProfile_Category1_rphi_layer%dtob",i+1);
00424     mePullTrackwidthProfileCategory1RphiTOB[i] = dbe_->bookProfile(histo,"Pull Track width Profile Category1", 100, 0., 1.,100, -2.,2.,"s");
00425 
00426     sprintf(histo,"PullTrackwidthProfile_Category2_rphi_layer%dtob",i+1);
00427     mePullTrackwidthProfileCategory2RphiTOB[i] = dbe_->bookProfile(histo,"Pull Track width Profile Category2", 100, 0., 1.,100, -2.,2.,"s");
00428     
00429     sprintf(histo,"PullTrackwidthProfile_Category3_rphi_layer%dtob",i+1);
00430     mePullTrackwidthProfileCategory3RphiTOB[i] = dbe_->bookProfile(histo,"Pull Track width Profile Category3", 100, 0., 1.,100, -2.,2.,"s");
00431     
00432     sprintf(histo,"PullTrackwidthProfile_Category4_rphi_layer%dtob",i+1);
00433     mePullTrackwidthProfileCategory4RphiTOB[i] = dbe_->bookProfile(histo,"Pull Track width Profile Category4", 100, 0., 1.,100, -2.,2.,"s");
00434 
00435     sprintf(histo,"ErrxMFTrackwidthProfile_rphi_layer%dtob",i+1);
00436     meErrxMFTrackwidthProfileRphiTOB[i] = dbe_->bookProfile(histo,"Resolution Track width Profile", 12,0.,4.,100, -2.,2.,"s");
00437 
00438     sprintf(histo,"ErrxMFTrackwidthProfile_WClus1_rphi_layer%dtob",i+1);
00439     meErrxMFTrackwidthProfileWclus1RphiTOB[i] = dbe_->bookProfile(histo,"Resolution Track width Profile Wclus1", 12, 0., 4.,100, -2.,2.,"s");
00440 
00441     sprintf(histo,"ErrxMFTrackwidthProfile_WClus2_rphi_layer%dtob",i+1);
00442     meErrxMFTrackwidthProfileWclus2RphiTOB[i] = dbe_->bookProfile(histo,"Resolution Track width Profile Wclus1", 12, 0., 4.,100, -2.,2.,"s");
00443 
00444     sprintf(histo,"ErrxMFTrackwidthProfile_WClus3_rphi_layer%dtob",i+1);
00445     meErrxMFTrackwidthProfileWclus3RphiTOB[i] = dbe_->bookProfile(histo,"Resolution Track width Profile Wclus1", 12, 0., 4.,100, -2.,2.,"s");
00446 
00447     sprintf(histo,"ErrxMFTrackwidthProfile_WClus4_rphi_layer%dtob",i+1);
00448     meErrxMFTrackwidthProfileWclus4RphiTOB[i] = dbe_->bookProfile(histo,"Resolution Track width Profile Wclus1", 12, 0., 4.,100, -2.,2.,"s");
00449 
00450     sprintf(histo,"ResMFTrackwidthProfile_WClus1_rphi_layer%dtob",i+1);
00451     meResMFTrackwidthProfileWclus1RphiTOB[i] = dbe_->bookProfile(histo,"Residue Track width Profile Wclus1", 12, 0., 4.,100, -2.,2.,"s");
00452     sprintf(histo,"ResMFTrackwidthProfile_WClus2_rphi_layer%dtob",i+1);
00453     meResMFTrackwidthProfileWclus2RphiTOB[i] = dbe_->bookProfile(histo,"Residue Track width Profile Wclus1", 12, 0., 4.,100, -2.,2.,"s");
00454 
00455     sprintf(histo,"ResMFTrackwidthProfile_WClus3_rphi_layer%dtob",i+1);
00456     meResMFTrackwidthProfileWclus3RphiTOB[i] = dbe_->bookProfile(histo,"Residue Track width Profile Wclus1", 12, 0., 4.,100, -2.,2.,"s");
00457 
00458     sprintf(histo,"ResMFTrackwidthProfile_WClus4_rphi_layer%dtob",i+1);
00459     meResMFTrackwidthProfileWclus4RphiTOB[i] = dbe_->bookProfile(histo,"Residue Track width Profile Wclus1", 12, 0., 4.,100, -2.,2.,"s");
00460 
00461 
00462 
00463     sprintf(histo,"ErrxMFTrackwidthProfile_Category1_rphi_layer%dtob",i+1);
00464     meErrxMFTrackwidthProfileCategory1RphiTOB[i] = dbe_->bookProfile(histo,"Resolution Track width Profile Category1", 12,0.,4.,100, -2.,2.,"s");
00465 
00466     sprintf(histo,"ErrxMFTrackwidthProfile_Category2_rphi_layer%dtob",i+1);
00467     meErrxMFTrackwidthProfileCategory2RphiTOB[i] = dbe_->bookProfile(histo,"Resolution Track width Profile Category2", 12,0.,4.,100, -2.,2.,"s");
00468 
00469     sprintf(histo,"ErrxMFTrackwidthProfile_Category3_rphi_layer%dtob",i+1);
00470     meErrxMFTrackwidthProfileCategory3RphiTOB[i] = dbe_->bookProfile(histo,"Resolution Track width Profile Category3", 12,0.,4.,100, -2.,2.,"s");
00471 
00472     sprintf(histo,"ErrxMFTrackwidthProfile_Category4_rphi_layer%dtob",i+1);
00473     meErrxMFTrackwidthProfileCategory4RphiTOB[i] = dbe_->bookProfile(histo,"Resolution Track width Profile Category4", 12,0.,4.,100, -2.,2.,"s");
00474 
00475     sprintf(histo,"ErrxMFAngleProfile_rphi_layer%dtob",i+1);
00476     meErrxMFAngleProfileRphiTOB[i] = dbe_->bookProfile(histo,"Resolution Angle Profile", 100, 0., 1.,100, -2.,2.,"s");
00477 
00478     sprintf(histo,"ErrxMFClusterwidthProfile_Category1_rphi_layer%dtob",i+1);
00479     meErrxMFClusterwidthProfileCategory1RphiTOB[i] = dbe_->bookProfile(histo,"Resolution Cluster width Profile Category1", 100, 0., 10.,100, -2.,2.,"s");
00480     
00481   }
00482 
00483   //one histo per Layer stereo and matched hits
00484   for(int i = 0 ;i<2 ; i++) {
00485     Char_t histo[200];
00486     sprintf(histo,"Nstp_sas_layer%dtob",i+1);
00487     meNstpSasTOB[i] = dbe_->book1D(histo,"RecHit Cluster Size",20,0.5,20.5);  
00488     sprintf(histo,"Adc_sas_layer%dtob",i+1);
00489     meAdcSasTOB[i] = dbe_->book1D(histo,"RecHit Cluster Charge",100,0.,300.);  
00490     sprintf(histo,"Posx_sas_layer%dtob",i+1);
00491     mePosxSasTOB[i] = dbe_->book1D(histo,"RecHit x coord.",100,-6.0,+6.0);  
00492 
00493     sprintf(histo,"Errx_LF_sas_layer%dtob",i+1);
00494     meErrxLFSasTOB[i] = dbe_->book1D(histo,"RecHit err(x) coord.",100,0.,0.01);  
00495     sprintf(histo,"Errx_MF_sas_layer%dtob",i+1);
00496     meErrxMFSasTOB[i] = dbe_->book1D(histo,"RecHit err(x) coord.",100,0.,0.5);  
00497 
00498     sprintf(histo,"Res_LF_sas_layer%dtob",i+1);
00499     meResLFSasTOB[i] = dbe_->book1D(histo,"RecHit Residual",100,-0.02,+0.02);  
00500     sprintf(histo,"Res_MF_sas_layer%dtob",i+1);
00501     meResMFSasTOB[i] = dbe_->book1D(histo,"RecHit Residual",100,-2,2);  
00502 
00503     sprintf(histo,"Pull_LF_sas_layer%dtob",i+1);
00504     mePullLFSasTOB[i] = dbe_->book1D(histo,"Pull",100,-5.,5.);  
00505     sprintf(histo,"Pull_MF_sas_layer%dtob",i+1);
00506     mePullMFSasTOB[i] = dbe_->book1D(histo,"Pull",100,-5.,5.);  
00507 
00508     sprintf(histo,"Trackangle_sas_layer%dtob",i+1);
00509     meTrackangleSasTOB[i] = dbe_->book1D(histo,"Track angle",100,-25.,25.);  
00510 
00511     sprintf(histo,"Trackanglebeta_sas_layer%dtob",i+1);
00512     meTrackanglebetaSasTOB[i] = dbe_->book1D(histo,"Track angle beta",100,-25.,25.);  
00513 
00514     sprintf(histo,"PullTrackangleProfile_sas_layer%dtob",i+1);
00515     mePullTrackangleProfileSasTOB[i] = dbe_->bookProfile(histo,"Pull Track angle Profile", 100, -25., 25. ,100 , -5., 5.,"s");
00516 
00517     sprintf(histo,"Trackwidth_sas_layer%dtob",i+1);
00518     meTrackwidthSasTOB[i] = dbe_->book1D(histo,"Track width",100,0.,1.);  
00519 
00520     sprintf(histo,"Expectedwidth_sas_layer%dtob",i+1);
00521     meExpectedwidthSasTOB[i] = dbe_->book1D(histo,"Expected width",10,0.,10.);  
00522 
00523     sprintf(histo,"Clusterwidth_sas_layer%dtob",i+1);
00524     meClusterwidthSasTOB[i] = dbe_->book1D(histo,"Cluster width",10,0.,10.);  
00525 
00526     sprintf(histo,"Category_sas_layer%dtob",i+1);
00527     meCategorySasTOB[i] = dbe_->book1D(histo,"Cluster Category",10,0.,10.);  
00528 
00529     sprintf(histo,"PullTrackwidthProfile_sas_layer%dtob",i+1);
00530     mePullTrackwidthProfileSasTOB[i] = dbe_->bookProfile(histo,"Pull Track width Profile", 100, 0., 1.,100, -2.,2.,"s");
00531 
00532     sprintf(histo,"PullTrackwidthProfile_Category1_sas_layer%dtob",i+1);
00533     mePullTrackwidthProfileCategory1SasTOB[i] = dbe_->bookProfile(histo,"Pull Track width Profile Category1", 100, 0., 1.,100, -2.,2.,"s");
00534 
00535     sprintf(histo,"PullTrackwidthProfile_Category2_sas_layer%dtob",i+1);
00536     mePullTrackwidthProfileCategory2SasTOB[i] = dbe_->bookProfile(histo,"Pull Track width Profile Category2", 100, 0., 1.,100, -2.,2.,"s");
00537     
00538     sprintf(histo,"PullTrackwidthProfile_Category3_sas_layer%dtob",i+1);
00539     mePullTrackwidthProfileCategory3SasTOB[i] = dbe_->bookProfile(histo,"Pull Track width Profile Category3", 100, 0., 1.,100, -2.,2.,"s");
00540     
00541     sprintf(histo,"PullTrackwidthProfile_Category4_sas_layer%dtob",i+1);
00542     mePullTrackwidthProfileCategory4SasTOB[i] = dbe_->bookProfile(histo,"Pull Track width Profile Category4", 100, 0., 1.,100, -2.,2.,"s");
00543 
00544     sprintf(histo,"ErrxMFTrackwidthProfile_sas_layer%dtob",i+1);
00545     meErrxMFTrackwidthProfileSasTOB[i] = dbe_->bookProfile(histo,"Resolution Track width Profile", 12,0.,4.,100, -2.,2.,"s");
00546 
00547     sprintf(histo,"ErrxMFTrackwidthProfile_Category1_sas_layer%dtob",i+1);
00548     meErrxMFTrackwidthProfileCategory1SasTOB[i] = dbe_->bookProfile(histo,"Resolution Track width Profile Category1", 12,0.,4.,100, -2.,2.,"s");
00549     sprintf(histo,"ErrxMFTrackwidthProfile_Category2_sas_layer%dtob",i+1);
00550     meErrxMFTrackwidthProfileCategory2SasTOB[i] = dbe_->bookProfile(histo,"Resolution Track width Profile Category2", 12,0.,4.,100, -2.,2.,"s");
00551     sprintf(histo,"ErrxMFTrackwidthProfile_Category3_sas_layer%dtob",i+1);
00552     meErrxMFTrackwidthProfileCategory3SasTOB[i] = dbe_->bookProfile(histo,"Resolution Track width Profile Category3", 12,0.,4.,100, -2.,2.,"s");
00553     sprintf(histo,"ErrxMFTrackwidthProfile_Category4_sas_layer%dtob",i+1);
00554     meErrxMFTrackwidthProfileCategory4SasTOB[i] = dbe_->bookProfile(histo,"Resolution Track width Profile Category4", 12,0.,4.,100, -2.,2.,"s");
00555 
00556     sprintf(histo,"ErrxMFAngleProfile_sas_layer%dtob",i+1);
00557     meErrxMFAngleProfileSasTOB[i] = dbe_->bookProfile(histo,"Resolution Angle Profile", 100, 0., 1.,100, -2.,2.,"s");
00558 
00559      sprintf(histo,"ErrxMFClusterwidthProfile_Category1_sas_layer%dtob",i+1);
00560     meErrxMFClusterwidthProfileCategory1SasTOB[i] = dbe_->bookProfile(histo,"Resolution Cluster width Profile Category1", 100, 0., 10.,100, -2.,2.,"s");
00561     
00562    sprintf(histo,"Posx_matched_layer%dtob",i+1);
00563     mePosxMatchedTOB[i] = dbe_->book1D(histo,"RecHit x coord.",100,-6.0, +6.0);  
00564     sprintf(histo,"Posy_matched_layer%dtob",i+1);
00565     mePosyMatchedTOB[i] = dbe_->book1D(histo,"RecHit y coord.",100,-6.0, +6.0);  
00566     sprintf(histo,"Errx_matched_layer%dtob",i+1);
00567     meErrxMatchedTOB[i] = dbe_->book1D(histo,"RecHit err(x) coord.",100,0., 0.05);  
00568     sprintf(histo,"Erry_matched_layer%dtob",i+1);
00569     meErryMatchedTOB[i] = dbe_->book1D(histo,"RecHit err(y) coord.",100,0., 0.05);  
00570     sprintf(histo,"Resx_matched_layer%dtob",i+1);
00571     meResxMatchedTOB[i] = dbe_->book1D(histo,"RecHit Res(x) coord.",100,-0.02, +0.02);  
00572     sprintf(histo,"Resy_matched_layer%dtob",i+1);
00573     meResyMatchedTOB[i] = dbe_->book1D(histo,"RecHit Res(y) coord.",100,-1., +1.);  
00574     sprintf(histo,"Pullx_matched_layer%dtob",i+1);
00575     mePullxMatchedTOB[i] = dbe_->book1D(histo,"Pull",100,-5.,5.);  
00576     sprintf(histo,"Pully_matched_layer%dtob",i+1);
00577     mePullyMatchedTOB[i] = dbe_->book1D(histo,"Pull",100,-5.,5.);  
00578   }
00579 
00580   dbe_->setCurrentFolder("Tracking/TrackingRecHits/Strip/TID");
00581   //one histo per Ring rphi hits: 3 rings, 6 disks, 2 inner rings are glued 
00582   for(int i = 0 ;i<3 ; i++) {
00583     Char_t histo[200];
00584     sprintf(histo,"Nstp_rphi_layer%dtid",i+1);
00585     meNstpRphiTID[i] = dbe_->book1D(histo,"RecHit Cluster Size",20,0.5,20.5);  
00586     sprintf(histo,"Adc_rphi_layer%dtid",i+1);
00587     meAdcRphiTID[i] = dbe_->book1D(histo,"RecHit Cluster Charge",100,0.,300.);  
00588     sprintf(histo,"Posx_rphi_layer%dtid",i+1);
00589     mePosxRphiTID[i] = dbe_->book1D(histo,"RecHit x coord.",100,-6.0,+6.0);  
00590     sprintf(histo,"Errx_LF_rphi_layer%dtid",i+1);
00591     meErrxLFRphiTID[i] = dbe_->book1D(histo,"RecHit err(x) coord.",100,0,0.5);  
00592     sprintf(histo,"Errx_MF_rphi_layer%dtid",i+1);
00593     meErrxMFRphiTID[i] = dbe_->book1D(histo,"RecHit err(x) coord.",100,0,0.5);  
00594     sprintf(histo,"Res_LF_rphi_layer%dtid",i+1);
00595     meResLFRphiTID[i] = dbe_->book1D(histo,"RecHit Residual",100,-0.5,+0.5);  
00596     sprintf(histo,"Res_MF_rphi_layer%dtid",i+1);
00597     meResMFRphiTID[i] = dbe_->book1D(histo,"RecHit Residual",100,-2,2);  
00598     sprintf(histo,"Pull_LF_rphi_layer%dtid",i+1);
00599     mePullLFRphiTID[i] = dbe_->book1D(histo,"Pull",100,-5.,5.);  
00600     sprintf(histo,"Pull_MF_rphi_layer%dtid",i+1);
00601     mePullMFRphiTID[i] = dbe_->book1D(histo,"Pull",100,-5.,5.);  
00602     sprintf(histo,"Trackangle_rphi_layer%dtid",i+1);
00603     meTrackangleRphiTID[i] = dbe_->book1D(histo,"Track angle",100,-20.,20.);  
00604 
00605     sprintf(histo,"Trackanglebeta_rphi_layer%dtid",i+1);
00606     meTrackanglebetaRphiTID[i] = dbe_->book1D(histo,"Track angle beta",100,-20.,20.);  
00607 
00608     sprintf(histo,"PullTrackangleProfile_rphi_layer%dtid",i+1);
00609     mePullTrackangleProfileRphiTID[i] = dbe_->bookProfile(histo,"Pull Track angle Profile", 100, -20., 20.,100, -5., 5.,"s");
00610 
00611     sprintf(histo,"Trackwidth_rphi_layer%dtid",i+1);
00612     meTrackwidthRphiTID[i] = dbe_->book1D(histo,"Track width",100,0.,1.);  
00613 
00614     sprintf(histo,"Expectedwidth_rphi_layer%dtid",i+1);
00615     meExpectedwidthRphiTID[i] = dbe_->book1D(histo,"Expected width",10,0.,10.);  
00616 
00617     sprintf(histo,"Clusterwidth_rphi_layer%dtid",i+1);
00618     meClusterwidthRphiTID[i] = dbe_->book1D(histo,"Cluster width",10,0.,10.);  
00619 
00620     sprintf(histo,"Category_rphi_layer%dtid",i+1);
00621     meCategoryRphiTID[i] = dbe_->book1D(histo,"Cluster Category",10,0.,10.);  
00622 
00623     sprintf(histo,"PullTrackwidthProfile_rphi_layer%dtid",i+1);
00624     mePullTrackwidthProfileRphiTID[i] = dbe_->bookProfile(histo,"Pull Track width Profile", 100, 0., 1.,100, -2.,2.,"s");
00625 
00626     sprintf(histo,"PullTrackwidthProfile_Category1_rphi_layer%dtid",i+1);
00627     mePullTrackwidthProfileCategory1RphiTID[i] = dbe_->bookProfile(histo,"Pull Track width Profile Category1", 100, 0., 1.,100, -2.,2.,"s");
00628 
00629     sprintf(histo,"PullTrackwidthProfile_Category2_rphi_layer%dtid",i+1);
00630     mePullTrackwidthProfileCategory2RphiTID[i] = dbe_->bookProfile(histo,"Pull Track width Profile Category2", 100, 0., 1.,100, -2.,2.,"s");
00631     
00632     sprintf(histo,"PullTrackwidthProfile_Category3_rphi_layer%dtid",i+1);
00633     mePullTrackwidthProfileCategory3RphiTID[i] = dbe_->bookProfile(histo,"Pull Track width Profile Category3", 100, 0., 1.,100, -2.,2.,"s");
00634     
00635     sprintf(histo,"PullTrackwidthProfile_Category4_rphi_layer%dtid",i+1);
00636     mePullTrackwidthProfileCategory4RphiTID[i] = dbe_->bookProfile(histo,"Pull Track width Profile Category4", 100, 0., 1.,100, -2.,2.,"s");
00637 
00638     sprintf(histo,"ErrxMFTrackwidthProfile_rphi_layer%dtid",i+1);
00639     meErrxMFTrackwidthProfileRphiTID[i] = dbe_->bookProfile(histo,"Resolution Track width Profile", 12,0.,4.,100, -2.,2.,"s");
00640 
00641     sprintf(histo,"ErrxMFTrackwidthProfile_Category1_rphi_layer%dtid",i+1);
00642     meErrxMFTrackwidthProfileCategory1RphiTID[i] = dbe_->bookProfile(histo,"Resolution Track width Profile Category1", 12,0.,4.,100, -2.,2.,"s");
00643     sprintf(histo,"ErrxMFTrackwidthProfile_Category2_rphi_layer%dtid",i+1);
00644     meErrxMFTrackwidthProfileCategory2RphiTID[i] = dbe_->bookProfile(histo,"Resolution Track width Profile Category2", 12,0.,4.,100, -2.,2.,"s");
00645     sprintf(histo,"ErrxMFTrackwidthProfile_Category3_rphi_layer%dtid",i+1);
00646     meErrxMFTrackwidthProfileCategory3RphiTID[i] = dbe_->bookProfile(histo,"Resolution Track width Profile Category3", 12,0.,4.,100, -2.,2.,"s");
00647     sprintf(histo,"ErrxMFTrackwidthProfile_Category4_rphi_layer%dtid",i+1);
00648     meErrxMFTrackwidthProfileCategory4RphiTID[i] = dbe_->bookProfile(histo,"Resolution Track width Profile Category4", 12,0.,4.,100, -2.,2.,"s");
00649 
00650     sprintf(histo,"ErrxMFAngleProfile_rphi_layer%dtid",i+1);
00651     meErrxMFAngleProfileRphiTID[i] = dbe_->bookProfile(histo,"Resolution Angle Profile", 100, 0., 1.,100, -2.,2.,"s");
00652 
00653     sprintf(histo,"ErrxMFClusterwidthProfile_Category1_rphi_layer%dtid",i+1);
00654     meErrxMFClusterwidthProfileCategory1RphiTID[i] = dbe_->bookProfile(histo,"Resolution Cluster width Profile Category1", 100, 0., 10.,100, -2.,2.,"s");
00655     
00656   }
00657 
00658   //one histo per Ring stereo and matched hits
00659   for(int i = 0 ;i<2 ; i++) {
00660     Char_t histo[200];
00661     sprintf(histo,"Nstp_sas_layer%dtid",i+1);
00662     meNstpSasTID[i] = dbe_->book1D(histo,"RecHit Cluster Size",20,0.5,20.5);  
00663     sprintf(histo,"Adc_sas_layer%dtid",i+1);
00664     meAdcSasTID[i] = dbe_->book1D(histo,"RecHit Cluster Charge",100,0.,300.);  
00665     sprintf(histo,"Posx_sas_layer%dtid",i+1);
00666     mePosxSasTID[i] = dbe_->book1D(histo,"RecHit x coord.",100,-6.0,+6.0);  
00667     sprintf(histo,"Errx_LF_sas_layer%dtid",i+1);
00668     meErrxLFSasTID[i] = dbe_->book1D(histo,"RecHit err(x) coord.",100,0.,0.5);  
00669     sprintf(histo,"Errx_MF_sas_layer%dtid",i+1);
00670     meErrxMFSasTID[i] = dbe_->book1D(histo,"RecHit err(x) coord.",100,0.,0.5);  
00671     sprintf(histo,"Res_LF_sas_layer%dtid",i+1);
00672     meResLFSasTID[i] = dbe_->book1D(histo,"RecHit Residual",100,-0.5,+0.5);  
00673     sprintf(histo,"Res_MF_sas_layer%dtid",i+1);
00674     meResMFSasTID[i] = dbe_->book1D(histo,"RecHit Residual",100,-2,2);  
00675     sprintf(histo,"Pull_LF_sas_layer%dtid",i+1);
00676     mePullLFSasTID[i] = dbe_->book1D(histo,"Pull",100,-5.,5.);  
00677     sprintf(histo,"Pull_MF_sas_layer%dtid",i+1);
00678     mePullMFSasTID[i] = dbe_->book1D(histo,"Pull",100,-5.,5.);  
00679     sprintf(histo,"Trackangle_sas_layer%dtid",i+1);
00680     meTrackangleSasTID[i] = dbe_->book1D(histo,"Track angle",100,-20.,20.);  
00681    sprintf(histo,"Trackanglebeta_sas_layer%dtid",i+1);
00682     meTrackanglebetaSasTID[i] = dbe_->book1D(histo,"Track angle beta",100,-20.,20.);  
00683 
00684     sprintf(histo,"PullTrackangleProfile_sas_layer%dtid",i+1);
00685     mePullTrackangleProfileSasTID[i] = dbe_->bookProfile(histo,"Pull Track angle Profile", 100, -20., 20.,100, -5., 5.,"s");
00686 
00687     sprintf(histo,"Trackwidth_sas_layer%dtid",i+1);
00688     meTrackwidthSasTID[i] = dbe_->book1D(histo,"Track width",100,0.,1.);  
00689 
00690     sprintf(histo,"Expectedwidth_sas_layer%dtid",i+1);
00691     meExpectedwidthSasTID[i] = dbe_->book1D(histo,"Expected width",10,0.,10.);  
00692 
00693     sprintf(histo,"Clusterwidth_sas_layer%dtid",i+1);
00694     meClusterwidthSasTID[i] = dbe_->book1D(histo,"Cluster width",10,0.,10.);  
00695 
00696     sprintf(histo,"Category_sas_layer%dtid",i+1);
00697     meCategorySasTID[i] = dbe_->book1D(histo,"Cluster Category",10,0.,10.);  
00698 
00699     sprintf(histo,"PullTrackwidthProfile_sas_layer%dtid",i+1);
00700     mePullTrackwidthProfileSasTID[i] = dbe_->bookProfile(histo,"Pull Track width Profile", 100, 0., 1.,100, -2.,2.,"s");
00701 
00702     sprintf(histo,"PullTrackwidthProfile_Category1_sas_layer%dtid",i+1);
00703     mePullTrackwidthProfileCategory1SasTID[i] = dbe_->bookProfile(histo,"Pull Track width Profile Category1", 100, 0., 1.,100, -2.,2.,"s");
00704 
00705     sprintf(histo,"PullTrackwidthProfile_Category2_sas_layer%dtid",i+1);
00706     mePullTrackwidthProfileCategory2SasTID[i] = dbe_->bookProfile(histo,"Pull Track width Profile Category2", 100, 0., 1.,100, -2.,2.,"s");
00707     
00708     sprintf(histo,"PullTrackwidthProfile_Category3_sas_layer%dtid",i+1);
00709     mePullTrackwidthProfileCategory3SasTID[i] = dbe_->bookProfile(histo,"Pull Track width Profile Category3", 100, 0., 1.,100, -2.,2.,"s");
00710     
00711     sprintf(histo,"PullTrackwidthProfile_Category4_sas_layer%dtid",i+1);
00712     mePullTrackwidthProfileCategory4SasTID[i] = dbe_->bookProfile(histo,"Pull Track width Profile Category4", 100, 0., 1.,100, -2.,2.,"s");
00713 
00714     sprintf(histo,"ErrxMFTrackwidthProfile_sas_layer%dtid",i+1);
00715     meErrxMFTrackwidthProfileSasTID[i] = dbe_->bookProfile(histo,"Resolution Track width Profile", 12,0.,4.,100, -2.,2.,"s");
00716 
00717     sprintf(histo,"ErrxMFTrackwidthProfile_Category1_sas_layer%dtid",i+1);
00718     meErrxMFTrackwidthProfileCategory1SasTID[i] = dbe_->bookProfile(histo,"Resolution Track width Profile Category1", 12,0.,4.,100, -2.,2.,"s");
00719     sprintf(histo,"ErrxMFTrackwidthProfile_Category2_sas_layer%dtid",i+1);
00720     meErrxMFTrackwidthProfileCategory2SasTID[i] = dbe_->bookProfile(histo,"Resolution Track width Profile Category2", 12,0.,4.,100, -2.,2.,"s");
00721     sprintf(histo,"ErrxMFTrackwidthProfile_Category3_sas_layer%dtid",i+1);
00722     meErrxMFTrackwidthProfileCategory3SasTID[i] = dbe_->bookProfile(histo,"Resolution Track width Profile Category3", 12,0.,4.,100, -2.,2.,"s");
00723     sprintf(histo,"ErrxMFTrackwidthProfile_Category4_sas_layer%dtid",i+1);
00724     meErrxMFTrackwidthProfileCategory4SasTID[i] = dbe_->bookProfile(histo,"Resolution Track width Profile Category4", 12,0.,4.,100, -2.,2.,"s");
00725 
00726     sprintf(histo,"ErrxMFAngleProfile_sas_layer%dtid",i+1);
00727     meErrxMFAngleProfileSasTID[i] = dbe_->bookProfile(histo,"Resolution Angle Profile", 100, 0., 1.,100, -2.,2.,"s");
00728 
00729      sprintf(histo,"ErrxMFClusterwidthProfile_Category1_sas_layer%dtid",i+1);
00730     meErrxMFClusterwidthProfileCategory1SasTID[i] = dbe_->bookProfile(histo,"Resolution Cluster width Profile Category1", 100, 0., 10.,100, -2.,2.,"s");
00731     
00732    sprintf(histo,"Posx_matched_layer%dtid",i+1);
00733     mePosxMatchedTID[i] = dbe_->book1D(histo,"RecHit x coord.",100,-6.0, +6.0);  
00734     sprintf(histo,"Posy_matched_layer%dtid",i+1);
00735     mePosyMatchedTID[i] = dbe_->book1D(histo,"RecHit y coord.",100,-6.0, +6.0);  
00736     sprintf(histo,"Errx_matched_layer%dtid",i+1);
00737     meErrxMatchedTID[i] = dbe_->book1D(histo,"RecHit err(x) coord.",100,0., 0.02);  
00738     sprintf(histo,"Erry_matched_layer%dtid",i+1);
00739     meErryMatchedTID[i] = dbe_->book1D(histo,"RecHit err(y) coord.",100,0., 0.1);  
00740     sprintf(histo,"Resx_matched_layer%dtid",i+1);
00741     meResxMatchedTID[i] = dbe_->book1D(histo,"RecHit Res(x) coord.",100,-0.2, +0.2);  
00742     sprintf(histo,"Resy_matched_layer%dtid",i+1);
00743     meResyMatchedTID[i] = dbe_->book1D(histo,"RecHit Res(y) coord.",100,-1., +1.);  
00744     sprintf(histo,"Pullx_matched_layer%dtid",i+1);
00745     mePullxMatchedTID[i] = dbe_->book1D(histo,"Pull",100,-5.,5.);  
00746     sprintf(histo,"Pully_matched_layer%dtid",i+1);
00747     mePullyMatchedTID[i] = dbe_->book1D(histo,"Pull",100,-5.,5.);  
00748   }
00749 
00750   dbe_->setCurrentFolder("Tracking/TrackingRecHits/Strip/TEC");
00751   //one histo per Ring rphi hits: 7 rings, 18 disks. Innermost 3 rings are same as TID above.  
00752   for(int i = 0 ;i<7 ; i++) {
00753     Char_t histo[200];
00754     sprintf(histo,"Nstp_rphi_layer%dtec",i+1);
00755     meNstpRphiTEC[i] = dbe_->book1D(histo,"RecHit Cluster Size",20,0.5,20.5);  
00756     sprintf(histo,"Adc_rphi_layer%dtec",i+1);
00757     meAdcRphiTEC[i] = dbe_->book1D(histo,"RecHit Cluster Charge",100,0.,300.);  
00758     sprintf(histo,"Posx_rphi_layer%dtec",i+1);
00759     mePosxRphiTEC[i] = dbe_->book1D(histo,"RecHit x coord.",100,-6.0,+6.0);  
00760 
00761     sprintf(histo,"Errx_LF_rphi_layer%dtec",i+1);
00762     meErrxLFRphiTEC[i] = dbe_->book1D(histo,"RecHit err(x) coord.",100,0,0.5);  
00763     sprintf(histo,"Errx_MF_rphi_layer%dtec",i+1);
00764     meErrxMFRphiTEC[i] = dbe_->book1D(histo,"RecHit err(x) coord.",100,0,0.5);  
00765 
00766     sprintf(histo,"Res_LF_rphi_layer%dtec",i+1);
00767     meResLFRphiTEC[i] = dbe_->book1D(histo,"RecHit Residual",100,-0.5,+0.5);  
00768     sprintf(histo,"Res_MF_rphi_layer%dtec",i+1);
00769     meResMFRphiTEC[i] = dbe_->book1D(histo,"RecHit Residual",100,-2,2);  
00770 
00771     sprintf(histo,"Pull_LF_rphi_layer%dtec",i+1);
00772     mePullLFRphiTEC[i] = dbe_->book1D(histo,"Pull",100,-5.,5.);  
00773     sprintf(histo,"Pull_MF_rphi_layer%dtec",i+1);
00774     mePullMFRphiTEC[i] = dbe_->book1D(histo,"Pull",100,-5.,5.);  
00775 
00776     sprintf(histo,"Trackangle_rphi_layer%dtec",i+1);
00777     meTrackangleRphiTEC[i] = dbe_->book1D(histo,"Track angle",100,-10.,10.);  
00778 
00779     sprintf(histo,"Trackanglebeta_rphi_layer%dtec",i+1);
00780     meTrackanglebetaRphiTEC[i] = dbe_->book1D(histo,"Track angle beta",100,-10.,10.);  
00781 
00782     sprintf(histo,"PullTrackangleProfile_rphi_layer%dtec",i+1);
00783     mePullTrackangleProfileRphiTEC[i] = dbe_->bookProfile(histo,"Pull Track angle Profile", 100, -10., 10.,100, -5., 5.,"s");
00784 
00785     sprintf(histo,"Trackwidth_rphi_layer%dtec",i+1);
00786     meTrackwidthRphiTEC[i] = dbe_->book1D(histo,"Track width",100,0.,1.);  
00787 
00788     sprintf(histo,"Expectedwidth_rphi_layer%dtec",i+1);
00789     meExpectedwidthRphiTEC[i] = dbe_->book1D(histo,"Expected width",10,0.,10.);  
00790 
00791     sprintf(histo,"Clusterwidth_rphi_layer%dtec",i+1);
00792     meClusterwidthRphiTEC[i] = dbe_->book1D(histo,"Cluster width",10,0.,10.);  
00793 
00794     sprintf(histo,"Category_rphi_layer%dtec",i+1);
00795     meCategoryRphiTEC[i] = dbe_->book1D(histo,"Cluster Category",10,0.,10.);  
00796 
00797     sprintf(histo,"PullTrackwidthProfile_rphi_layer%dtec",i+1);
00798     mePullTrackwidthProfileRphiTEC[i] = dbe_->bookProfile(histo,"Pull Track width Profile", 100, 0., 1.,100, -2.,2.,"s");
00799 
00800     sprintf(histo,"PullTrackwidthProfile_Category1_rphi_layer%dtec",i+1);
00801     mePullTrackwidthProfileCategory1RphiTEC[i] = dbe_->bookProfile(histo,"Pull Track width Profile Category1", 100, 0., 1.,100, -2.,2.,"s");
00802 
00803     sprintf(histo,"PullTrackwidthProfile_Category2_rphi_layer%dtec",i+1);
00804     mePullTrackwidthProfileCategory2RphiTEC[i] = dbe_->bookProfile(histo,"Pull Track width Profile Category2", 100, 0., 1.,100, -2.,2.,"s");
00805     
00806     sprintf(histo,"PullTrackwidthProfile_Category3_rphi_layer%dtec",i+1);
00807     mePullTrackwidthProfileCategory3RphiTEC[i] = dbe_->bookProfile(histo,"Pull Track width Profile Category3", 100, 0., 1.,100, -2.,2.,"s");
00808     
00809     sprintf(histo,"PullTrackwidthProfile_Category4_rphi_layer%dtec",i+1);
00810     mePullTrackwidthProfileCategory4RphiTEC[i] = dbe_->bookProfile(histo,"Pull Track width Profile Category4", 100, 0., 1.,100, -2.,2.,"s");
00811     
00812     sprintf(histo,"ErrxMFTrackwidthProfile_rphi_layer%dtec",i+1);
00813     meErrxMFTrackwidthProfileRphiTEC[i] = dbe_->bookProfile(histo,"Resolution Track width Profile", 12,0.,4.,100, -2.,2.,"s");
00814 
00815     sprintf(histo,"ErrxMFTrackwidthProfile_Category1_rphi_layer%dtec",i+1);
00816     meErrxMFTrackwidthProfileCategory1RphiTEC[i] = dbe_->bookProfile(histo,"Resolution Track width Profile Category1", 12,0.,4.,100, -2.,2.,"s");
00817     sprintf(histo,"ErrxMFTrackwidthProfile_Category2_rphi_layer%dtec",i+1);
00818     meErrxMFTrackwidthProfileCategory2RphiTEC[i] = dbe_->bookProfile(histo,"Resolution Track width Profile Category2", 12,0.,4.,100, -2.,2.,"s");
00819     sprintf(histo,"ErrxMFTrackwidthProfile_Category3_rphi_layer%dtec",i+1);
00820     meErrxMFTrackwidthProfileCategory3RphiTEC[i] = dbe_->bookProfile(histo,"Resolution Track width Profile Category3", 12,0.,4.,100, -2.,2.,"s");
00821     sprintf(histo,"ErrxMFTrackwidthProfile_Category4_rphi_layer%dtec",i+1);
00822     meErrxMFTrackwidthProfileCategory4RphiTEC[i] = dbe_->bookProfile(histo,"Resolution Track width Profile Category4", 12,0.,4.,100, -2.,2.,"s");
00823 
00824     sprintf(histo,"ErrxMFAngleProfile_rphi_layer%dtec",i+1);
00825     meErrxMFAngleProfileRphiTEC[i] = dbe_->bookProfile(histo,"Resolution Angle Profile", 100, 0., 1.,100, -2.,2.,"s");
00826 
00827     sprintf(histo,"ErrxMFClusterwidthProfile_Category1_rphi_layer%dtec",i+1);
00828     meErrxMFClusterwidthProfileCategory1RphiTEC[i] = dbe_->bookProfile(histo,"Resolution Cluster width Profile Category1", 100, 0., 10.,100, -2.,2.,"s");
00829     
00830   }
00831 
00832   //one histo per Layer stereo and matched hits: rings 1,2,5 are double sided
00833   for(int i = 0 ;i<5 ; i++) {
00834     if(i == 0 || i == 1 || i == 4) {
00835       Char_t histo[200];
00836       sprintf(histo,"Nstp_sas_layer%dtec",i+1);
00837       meNstpSasTEC[i] = dbe_->book1D(histo,"RecHit Cluster Size",20,0.5,20.5);  
00838       sprintf(histo,"Adc_sas_layer%dtec",i+1);
00839       meAdcSasTEC[i] = dbe_->book1D(histo,"RecHit Cluster Charge",100,0.,300.);  
00840       sprintf(histo,"Posx_sas_layer%dtec",i+1);
00841       mePosxSasTEC[i] = dbe_->book1D(histo,"RecHit x coord.",100,-6.0,+6.0);  
00842       sprintf(histo,"Errx_LF_sas_layer%dtec",i+1);
00843       meErrxLFSasTEC[i] = dbe_->book1D(histo,"RecHit err(x) coord.",100,0.,0.5);  
00844       sprintf(histo,"Errx_MF_sas_layer%dtec",i+1);
00845       meErrxMFSasTEC[i] = dbe_->book1D(histo,"RecHit err(x) coord.",100,0.,0.5);  
00846       sprintf(histo,"Res_LF_sas_layer%dtec",i+1);
00847       meResLFSasTEC[i] = dbe_->book1D(histo,"RecHit Residual",100,-0.5,+0.5);  
00848       sprintf(histo,"Res_MF_sas_layer%dtec",i+1);
00849       meResMFSasTEC[i] = dbe_->book1D(histo,"RecHit Residual",100,-2,+2);  
00850       sprintf(histo,"Pull_LF_sas_layer%dtec",i+1);
00851       mePullLFSasTEC[i] = dbe_->book1D(histo,"Pull",100,-5.,5.);
00852       sprintf(histo,"Pull_MF_sas_layer%dtec",i+1);
00853       mePullMFSasTEC[i] = dbe_->book1D(histo,"Pull",100,-5.,5.);
00854       sprintf(histo,"Trackangle_sas_layer%dtec",i+1);
00855       meTrackangleSasTEC[i] = dbe_->book1D(histo,"Track angle",100,-10.,10.);
00856       sprintf(histo,"Trackanglebeta_sas_layer%dtec",i+1);
00857       meTrackanglebetaSasTEC[i] = dbe_->book1D(histo,"Track angle beta",100,-10.,10.);
00858 
00859       sprintf(histo,"PullTrackangleProfile_sas_layer%dtec",i+1);
00860       mePullTrackangleProfileSasTEC[i] = dbe_->bookProfile(histo,"Pull Track angle Profile", 100, -10., 10.,100, -5., 5.,"s");
00861      
00862       sprintf(histo,"Trackwidth_sas_layer%dtec",i+1);
00863       meTrackwidthSasTEC[i] = dbe_->book1D(histo,"Track width",100,0.,1.);  
00864 
00865       sprintf(histo,"Expectedwidth_sas_layer%dtec",i+1);
00866       meExpectedwidthSasTEC[i] = dbe_->book1D(histo,"Expected width",10,0.,10.);  
00867 
00868       sprintf(histo,"Clusterwidth_sas_layer%dtec",i+1);
00869       meClusterwidthSasTEC[i] = dbe_->book1D(histo,"Cluster width",10,0.,10.);  
00870 
00871       sprintf(histo,"Category_sas_layer%dtec",i+1);
00872       meCategorySasTEC[i] = dbe_->book1D(histo,"Cluster Category",10,0.,10.);  
00873 
00874       sprintf(histo,"PullTrackwidthProfile_sas_layer%dtec",i+1);
00875       mePullTrackwidthProfileSasTEC[i] = dbe_->bookProfile(histo,"Pull Track width Profile", 100, 0., 1.,100, -2.,2.,"s");
00876 
00877       sprintf(histo,"PullTrackwidthProfile_Category1_sas_layer%dtec",i+1);
00878       mePullTrackwidthProfileCategory1SasTEC[i] = dbe_->bookProfile(histo,"Pull Track width Profile Category1", 100, 0., 1.,100, -2.,2.,"s");
00879 
00880       sprintf(histo,"PullTrackwidthProfile_Category2_sas_layer%dtec",i+1);
00881       mePullTrackwidthProfileCategory2SasTEC[i] = dbe_->bookProfile(histo,"Pull Track width Profile Category2", 100, 0., 1.,100, -2.,2.,"s");
00882     
00883       sprintf(histo,"PullTrackwidthProfile_Category3_sas_layer%dtec",i+1);
00884       mePullTrackwidthProfileCategory3SasTEC[i] = dbe_->bookProfile(histo,"Pull Track width Profile Category3", 100, 0., 1.,100, -2.,2.,"s");
00885     
00886       sprintf(histo,"PullTrackwidthProfile_Category4_sas_layer%dtec",i+1);
00887       mePullTrackwidthProfileCategory4SasTEC[i] = dbe_->bookProfile(histo,"Pull Track width Profile Category4", 100, 0., 1.,100, -2.,2.,"s");
00888 
00889     sprintf(histo,"ErrxMFTrackwidthProfile_sas_layer%dtec",i+1);
00890     meErrxMFTrackwidthProfileSasTEC[i] = dbe_->bookProfile(histo,"Resolution Track width Profile", 12,0.,4.,100, -2.,2.,"s");
00891 
00892     sprintf(histo,"ErrxMFTrackwidthProfile_Category1_sas_layer%dtec",i+1);
00893     meErrxMFTrackwidthProfileCategory1SasTEC[i] = dbe_->bookProfile(histo,"Resolution Track width Profile Category1", 12,0.,4.,100, -2.,2.,"s");
00894     sprintf(histo,"ErrxMFTrackwidthProfile_Category2_sas_layer%dtec",i+1);
00895     meErrxMFTrackwidthProfileCategory2SasTEC[i] = dbe_->bookProfile(histo,"Resolution Track width Profile Category2", 12,0.,4.,100, -2.,2.,"s");
00896     sprintf(histo,"ErrxMFTrackwidthProfile_Category3_sas_layer%dtec",i+1);
00897     meErrxMFTrackwidthProfileCategory3SasTEC[i] = dbe_->bookProfile(histo,"Resolution Track width Profile Category3", 12,0.,4.,100, -2.,2.,"s");
00898     sprintf(histo,"ErrxMFTrackwidthProfile_Category4_sas_layer%dtec",i+1);
00899     meErrxMFTrackwidthProfileCategory4SasTEC[i] = dbe_->bookProfile(histo,"Resolution Track width Profile Category4", 12,0.,4.,100, -2.,2.,"s");
00900 
00901     sprintf(histo,"ErrxMFAngleProfile_sas_layer%dtec",i+1);
00902     meErrxMFAngleProfileSasTEC[i] = dbe_->bookProfile(histo,"Resolution Angle Profile", 100, 0., 1.,100, -2.,2.,"s");
00903 
00904     sprintf(histo,"ErrxMFClusterwidthProfile_Category1_sas_layer%dtec",i+1);
00905     meErrxMFClusterwidthProfileCategory1SasTEC[i] = dbe_->bookProfile(histo,"Resolution Cluster width Profile Category1", 100, 0., 10.,100, -2.,2.,"s");
00906     
00907     sprintf(histo,"Posx_matched_layer%dtec",i+1);
00908     mePosxMatchedTEC[i] = dbe_->book1D(histo,"RecHit x coord.",100,-6.0, +6.0);  
00909     sprintf(histo,"Posy_matched_layer%dtec",i+1);
00910     mePosyMatchedTEC[i] = dbe_->book1D(histo,"RecHit y coord.",100,-8.0, +8.0);  
00911     sprintf(histo,"Errx_matched_layer%dtec",i+1);
00912     meErrxMatchedTEC[i] = dbe_->book1D(histo,"RecHit err(x) coord.",100,0., 0.02);  
00913     sprintf(histo,"Erry_matched_layer%dtec",i+1);
00914     meErryMatchedTEC[i] = dbe_->book1D(histo,"RecHit err(y) coord.",100,0., 0.1);  
00915     sprintf(histo,"Resx_matched_layer%dtec",i+1);
00916     meResxMatchedTEC[i] = dbe_->book1D(histo,"RecHit Res(x) coord.",100,-0.2, +0.2);  
00917     sprintf(histo,"Resy_matched_layer%dtec",i+1);
00918     meResyMatchedTEC[i] = dbe_->book1D(histo,"RecHit Res(y) coord.",100,-1., +1.);  
00919     sprintf(histo,"Pullx_matched_layer%dtec",i+1);
00920     mePullxMatchedTEC[i] = dbe_->book1D(histo,"Pull",100,-5.,5.);  
00921     sprintf(histo,"Pully_matched_layer%dtec",i+1);
00922     mePullyMatchedTEC[i] = dbe_->book1D(histo,"Pull",100,-5.,5.);  
00923     }
00924   }
00925 
00926 
00927 }
00928 
00929 void SiStripTrackingRecHitsValid::endJob() {
00930 
00931   /*  
00932   dbe_->setCurrentFolder("Tracking/TrackingRecHits/Strip/ALL");
00933   
00934   PullvsTrackwidth->FitSlicesY();
00935   ErrxMFvsTrackwidth->FitSlicesY();
00936   PullvsExpectedwidth->FitSlicesY();
00937   PullvsClusterwidth->FitSlicesY();
00938   PullvsTrackangle->FitSlicesY();
00939   PullvsTrackanglebeta->FitSlicesY();
00940 
00941   PullvsTrackwidthTIB->FitSlicesY();
00942   PullvsExpectedwidthTIB->FitSlicesY();
00943   PullvsClusterwidthTIB->FitSlicesY();
00944   PullvsTrackangleTIB->FitSlicesY();
00945   PullvsTrackanglebetaTIB->FitSlicesY();
00946 
00947   PullvsTrackwidthTOB->FitSlicesY();
00948   PullvsExpectedwidthTOB->FitSlicesY();
00949   PullvsClusterwidthTOB->FitSlicesY();
00950   PullvsTrackangleTOB->FitSlicesY();
00951   PullvsTrackanglebetaTOB->FitSlicesY();
00952 
00953   PullvsTrackwidthTID->FitSlicesY();
00954   PullvsExpectedwidthTID->FitSlicesY();
00955   PullvsClusterwidthTID->FitSlicesY();
00956   PullvsTrackangleTID->FitSlicesY();
00957   PullvsTrackanglebetaTID->FitSlicesY();
00958 
00959   PullvsTrackwidthTEC->FitSlicesY();
00960   PullvsExpectedwidthTEC->FitSlicesY();
00961   PullvsClusterwidthTEC->FitSlicesY();
00962   PullvsTrackangleTEC->FitSlicesY();
00963   PullvsTrackanglebetaTEC->FitSlicesY();
00964 
00965   //int aaa = Pullvstrackwidth_1->GetEntries();ErrxMFvsTrackwidth
00966 
00967   TH1D *PullvsTrackwidth_2 = (TH1D*)gDirectory->Get("PullvsTrackwidth_2");
00968   TH1D *PullvsExpectedwidth_2 = (TH1D*)gDirectory->Get("PullvsExpectedwidth_2");
00969   TH1D *PullvsClusterwidth_2 = (TH1D*)gDirectory->Get("PullvsClusterwidth_2");
00970   TH1D *PullvsTrackangle_2 = (TH1D*)gDirectory->Get("PullvsTrackangle_2");
00971   TH1D *PullvsTrackanglebeta_2 = (TH1D*)gDirectory->Get("PullvsTrackanglebeta_2");
00972 
00973   TH1D *PullvsTrackwidthTIB_2 = (TH1D*)gDirectory->Get("PullvsTrackwidthTIB_2");
00974   TH1D *PullvsExpectedwidthTIB_2 = (TH1D*)gDirectory->Get("PullvsExpectedwidthTIB_2");
00975   TH1D *PullvsClusterwidthTIB_2 = (TH1D*)gDirectory->Get("PullvsClusterwidthTIB_2");
00976   TH1D *PullvsTrackangleTIB_2 = (TH1D*)gDirectory->Get("PullvsTrackangleTIB_2");
00977   TH1D *PullvsTrackanglebetaTIB_2 = (TH1D*)gDirectory->Get("PullvsTrackanglebetaTIB_2");
00978 
00979   TH1D *PullvsTrackwidthTOB_2 = (TH1D*)gDirectory->Get("PullvsTrackwidthTOB_2");
00980   TH1D *PullvsExpectedwidthTOB_2 = (TH1D*)gDirectory->Get("PullvsExpectedwidthTOB_2");
00981   TH1D *PullvsClusterwidthTOB_2 = (TH1D*)gDirectory->Get("PullvsClusterwidthTOB_2");
00982   TH1D *PullvsTrackangleTOB_2 = (TH1D*)gDirectory->Get("PullvsTrackangleTOB_2");
00983   TH1D *PullvsTrackanglebetaTOB_2 = (TH1D*)gDirectory->Get("PullvsTrackanglebetaTOB_2");
00984 
00985   TH1D *PullvsTrackwidthTID_2 = (TH1D*)gDirectory->Get("PullvsTrackwidthTID_2");
00986   TH1D *PullvsExpectedwidthTID_2 = (TH1D*)gDirectory->Get("PullvsExpectedwidthTID_2");
00987   TH1D *PullvsClusterwidthTID_2 = (TH1D*)gDirectory->Get("PullvsClusterwidthTID_2");
00988   TH1D *PullvsTrackangleTID_2 = (TH1D*)gDirectory->Get("PullvsTrackangleTID_2");
00989   TH1D *PullvsTrackanglebetaTID_2 = (TH1D*)gDirectory->Get("PullvsTrackanglebetaTID_2");
00990 
00991   TH1D *PullvsTrackwidthTEC_2 = (TH1D*)gDirectory->Get("PullvsTrackwidthTEC_2");
00992   TH1D *PullvsExpectedwidthTEC_2 = (TH1D*)gDirectory->Get("PullvsExpectedwidthTEC_2");
00993   TH1D *PullvsClusterwidthTEC_2 = (TH1D*)gDirectory->Get("PullvsClusterwidthTEC_2");
00994   TH1D *PullvsTrackangleTEC_2 = (TH1D*)gDirectory->Get("PullvsTrackangleTEC_2");
00995   TH1D *PullvsTrackanglebetaTEC_2 = (TH1D*)gDirectory->Get("PullvsTrackanglebetaTEC_2");
00996 
00997   //cout<<"h2_1->GetEntries() = "<<PullvsTrackwidth_1->GetEntries()<<endl;
00998   //cout<<"ddbb1"<<endl;
00999   unsigned int NBINSPullvsTrackwidth =PullvsTrackwidth_2->GetNbinsX();
01000   unsigned int NBINSPullvsClusterwidth = PullvsClusterwidth_2->GetNbinsX();
01001   unsigned int NBINSPullvsExpectedwidth = PullvsExpectedwidth_2->GetNbinsX();
01002   //cout<<"ddbb2"<<endl;
01003   unsigned int NBINSPullvsTrackangle = PullvsTrackangle_2->GetNbinsX();
01004   unsigned int NBINSPullvsTrackanglebeta = PullvsTrackanglebeta_2->GetNbinsX();
01005   //cout<<"ddbb3"<<endl;
01006 
01007   PullRMSvsTrackwidth = dbe_->book1D("PullRMSvsTrackwidth", "PullRMSvsTrackwidth",NBINSPullvsTrackwidth ,0.,4.);
01008   PullRMSvsClusterwidth = dbe_->book1D("PullRMSvsClusterwidth", "PullRMSvsClusterwidth",NBINSPullvsClusterwidth ,0.5,8.5);
01009   PullRMSvsExpectedwidth = dbe_->book1D("PullRMSvsExpectedwidth", "PullRMSvsExpectedwidth",NBINSPullvsExpectedwidth ,0.5,4.5);
01010   PullRMSvsTrackangle = dbe_->book1D("PullRMSvsTrackangle", "PullRMSvsTrackangle",NBINSPullvsTrackangle ,0.,90.);
01011   PullRMSvsTrackanglebeta = dbe_->book1D("PullRMSvsTrackanglebeta", "PullRMSvsTrackanglebeta",NBINSPullvsTrackanglebeta ,0.,90.);
01012 
01013   PullRMSvsTrackwidthTIB = dbe_->book1D("PullRMSvsTrackwidthTIB", "PullRMSvsTrackwidthTIB",NBINSPullvsTrackwidth ,0.,4.);
01014   PullRMSvsClusterwidthTIB = dbe_->book1D("PullRMSvsClusterwidthTIB", "PullRMSvsClusterwidthTIB",NBINSPullvsClusterwidth ,0.5,8.5);
01015   PullRMSvsExpectedwidthTIB = dbe_->book1D("PullRMSvsExpectedwidthTIB", "PullRMSvsExpectedwidthTIB",NBINSPullvsExpectedwidth ,0.5,4.5);
01016   PullRMSvsTrackangleTIB = dbe_->book1D("PullRMSvsTrackangleTIB", "PullRMSvsTrackangleTIB",NBINSPullvsTrackangle ,0.,90.);
01017   PullRMSvsTrackanglebetaTIB = dbe_->book1D("PullRMSvsTrackanglebetaTIB", "PullRMSvsTrackanglebetaTIB",NBINSPullvsTrackanglebeta ,0.,90.);
01018 
01019   PullRMSvsTrackwidthTOB = dbe_->book1D("PullRMSvsTrackwidthTOB", "PullRMSvsTrackwidthTOB",NBINSPullvsTrackwidth ,0.,4.);
01020   PullRMSvsClusterwidthTOB = dbe_->book1D("PullRMSvsClusterwidthTOB", "PullRMSvsClusterwidthTOB",NBINSPullvsClusterwidth ,0.5,8.5);
01021   PullRMSvsExpectedwidthTOB = dbe_->book1D("PullRMSvsExpectedwidthTOB", "PullRMSvsExpectedwidthTOB",NBINSPullvsExpectedwidth ,0.5,4.5);
01022   PullRMSvsTrackangleTOB = dbe_->book1D("PullRMSvsTrackangleTOB", "PullRMSvsTrackangleTOB",NBINSPullvsTrackangle ,0.,90.);
01023   PullRMSvsTrackanglebetaTOB = dbe_->book1D("PullRMSvsTrackanglebetaTOB", "PullRMSvsTrackanglebetaTOB",NBINSPullvsTrackanglebeta ,0.,90.);
01024 
01025   PullRMSvsTrackwidthTID = dbe_->book1D("PullRMSvsTrackwidthTID", "PullRMSvsTrackwidthTID",NBINSPullvsTrackwidth ,0.,4.);
01026   PullRMSvsClusterwidthTID = dbe_->book1D("PullRMSvsClusterwidthTID", "PullRMSvsClusterwidthTID",NBINSPullvsClusterwidth ,0.5,8.5);
01027   PullRMSvsExpectedwidthTID = dbe_->book1D("PullRMSvsExpectedwidthTID", "PullRMSvsExpectedwidthTID",NBINSPullvsExpectedwidth ,0.5,4.5);
01028   PullRMSvsTrackangleTID = dbe_->book1D("PullRMSvsTrackangleTID", "PullRMSvsTrackangleTID",NBINSPullvsTrackangle ,0.,90.);
01029   PullRMSvsTrackanglebetaTID = dbe_->book1D("PullRMSvsTrackanglebetaTID", "PullRMSvsTrackanglebetaTID",NBINSPullvsTrackanglebeta ,0.,90.);
01030 
01031   PullRMSvsTrackwidthTEC = dbe_->book1D("PullRMSvsTrackwidthTEC", "PullRMSvsTrackwidthTEC",NBINSPullvsTrackwidth ,0.,4.);
01032   PullRMSvsClusterwidthTEC = dbe_->book1D("PullRMSvsClusterwidthTEC", "PullRMSvsClusterwidthTEC",NBINSPullvsClusterwidth ,0.5,8.5);
01033   PullRMSvsExpectedwidthTEC = dbe_->book1D("PullRMSvsExpectedwidthTEC", "PullRMSvsExpectedwidthTEC",NBINSPullvsExpectedwidth ,0.5,4.5);
01034   PullRMSvsTrackangleTEC = dbe_->book1D("PullRMSvsTrackangleTEC", "PullRMSvsTrackangleTEC",NBINSPullvsTrackangle ,0.,90.);
01035   PullRMSvsTrackanglebetaTEC = dbe_->book1D("PullRMSvsTrackanglebetaTEC", "PullRMSvsTrackanglebetaTEC",NBINSPullvsTrackanglebeta ,0.,90.);
01036 
01037   //cout<<"ddbb5"<<endl;
01038   for(unsigned int i = 0; i !=NBINSPullvsTrackwidth ; ++i){
01039     PullRMSvsTrackwidth->setBinContent(i,PullvsTrackwidth_2 ->GetBinContent(i));
01040     PullRMSvsTrackwidth->setBinError(i,PullvsTrackwidth_2 ->GetBinError(i));
01041     PullRMSvsTrackwidthTIB->setBinContent(i,PullvsTrackwidthTIB_2 ->GetBinContent(i));
01042     PullRMSvsTrackwidthTIB->setBinError(i,PullvsTrackwidthTIB_2 ->GetBinError(i));
01043     PullRMSvsTrackwidthTOB->setBinContent(i,PullvsTrackwidthTOB_2 ->GetBinContent(i));
01044     PullRMSvsTrackwidthTOB->setBinError(i,PullvsTrackwidthTOB_2 ->GetBinError(i));
01045     PullRMSvsTrackwidthTID->setBinContent(i,PullvsTrackwidthTID_2 ->GetBinContent(i));
01046     PullRMSvsTrackwidthTID->setBinError(i,PullvsTrackwidthTID_2 ->GetBinError(i));
01047     PullRMSvsTrackwidthTEC->setBinContent(i,PullvsTrackwidthTEC_2 ->GetBinContent(i));
01048     PullRMSvsTrackwidthTEC->setBinError(i,PullvsTrackwidthTEC_2 ->GetBinError(i));
01049   }
01050   //cout<<"ddbb6"<<endl;
01051   for(unsigned int i = 0; i != NBINSPullvsClusterwidth; ++i){
01052     PullRMSvsClusterwidth->setBinContent(i,PullvsClusterwidth_2 ->GetBinContent(i));
01053     PullRMSvsClusterwidth->setBinError(i,PullvsClusterwidth_2 ->GetBinError(i));
01054     PullRMSvsClusterwidthTIB->setBinContent(i,PullvsClusterwidthTIB_2 ->GetBinContent(i));
01055     PullRMSvsClusterwidthTIB->setBinError(i,PullvsClusterwidthTIB_2 ->GetBinError(i));
01056     PullRMSvsClusterwidthTOB->setBinContent(i,PullvsClusterwidthTOB_2 ->GetBinContent(i));
01057     PullRMSvsClusterwidthTOB->setBinError(i,PullvsClusterwidthTOB_2 ->GetBinError(i));
01058     PullRMSvsClusterwidthTID->setBinContent(i,PullvsClusterwidthTID_2 ->GetBinContent(i));
01059     PullRMSvsClusterwidthTID->setBinError(i,PullvsClusterwidthTID_2 ->GetBinError(i));
01060     PullRMSvsClusterwidthTEC->setBinContent(i,PullvsClusterwidthTEC_2 ->GetBinContent(i));
01061     PullRMSvsClusterwidthTEC->setBinError(i,PullvsClusterwidthTEC_2 ->GetBinError(i));
01062   }
01063   //cout<<"ddbb7"<<endl;
01064   for(unsigned int i = 0; i != NBINSPullvsExpectedwidth; ++i){
01065     PullRMSvsExpectedwidth->setBinContent(i,PullvsExpectedwidth_2 ->GetBinContent(i));
01066     PullRMSvsExpectedwidth->setBinError(i,PullvsExpectedwidth_2 ->GetBinError(i));
01067     PullRMSvsExpectedwidthTIB->setBinContent(i,PullvsExpectedwidthTIB_2 ->GetBinContent(i));
01068     PullRMSvsExpectedwidthTIB->setBinError(i,PullvsExpectedwidthTIB_2 ->GetBinError(i));
01069     PullRMSvsExpectedwidthTOB->setBinContent(i,PullvsExpectedwidthTOB_2 ->GetBinContent(i));
01070     PullRMSvsExpectedwidthTOB->setBinError(i,PullvsExpectedwidthTOB_2 ->GetBinError(i));
01071     PullRMSvsExpectedwidthTID->setBinContent(i,PullvsExpectedwidthTID_2 ->GetBinContent(i));
01072     PullRMSvsExpectedwidthTID->setBinError(i,PullvsExpectedwidthTID_2 ->GetBinError(i));
01073     PullRMSvsExpectedwidthTEC->setBinContent(i,PullvsExpectedwidthTEC_2 ->GetBinContent(i));
01074     PullRMSvsExpectedwidthTEC->setBinError(i,PullvsExpectedwidthTEC_2 ->GetBinError(i));
01075   }
01076   //cout<<"ddbb8"<<endl;
01077   for(unsigned int i = 0; i != NBINSPullvsTrackangle; ++i){
01078     PullRMSvsTrackangle->setBinContent(i,PullvsTrackangle_2 ->GetBinContent(i));
01079     PullRMSvsTrackangle->setBinError(i,PullvsTrackangle_2 ->GetBinError(i));
01080     PullRMSvsTrackangleTIB->setBinContent(i,PullvsTrackangleTIB_2 ->GetBinContent(i));
01081     PullRMSvsTrackangleTIB->setBinError(i,PullvsTrackangleTIB_2 ->GetBinError(i));
01082     PullRMSvsTrackangleTOB->setBinContent(i,PullvsTrackangleTOB_2 ->GetBinContent(i));
01083     PullRMSvsTrackangleTOB->setBinError(i,PullvsTrackangleTOB_2 ->GetBinError(i));
01084     PullRMSvsTrackangleTID->setBinContent(i,PullvsTrackangleTID_2 ->GetBinContent(i));
01085     PullRMSvsTrackangleTID->setBinError(i,PullvsTrackangleTID_2 ->GetBinError(i));
01086     PullRMSvsTrackangleTEC->setBinContent(i,PullvsTrackangleTEC_2 ->GetBinContent(i));
01087     PullRMSvsTrackangleTEC->setBinError(i,PullvsTrackangleTEC_2 ->GetBinError(i));
01088   }
01089   //cout<<"ddbb9"<<endl;
01090   for(unsigned int i = 0; i !=NBINSPullvsTrackanglebeta ; ++i){
01091     PullRMSvsTrackanglebeta->setBinContent(i,PullvsTrackanglebeta_2 ->GetBinContent(i));
01092     PullRMSvsTrackanglebeta->setBinError(i,PullvsTrackanglebeta_2 ->GetBinError(i));
01093     PullRMSvsTrackanglebetaTIB->setBinContent(i,PullvsTrackanglebetaTIB_2 ->GetBinContent(i));
01094     PullRMSvsTrackanglebetaTIB->setBinError(i,PullvsTrackanglebetaTIB_2 ->GetBinError(i));
01095     PullRMSvsTrackanglebetaTOB->setBinContent(i,PullvsTrackanglebetaTOB_2 ->GetBinContent(i));
01096     PullRMSvsTrackanglebetaTOB->setBinError(i,PullvsTrackanglebetaTOB_2 ->GetBinError(i));
01097     PullRMSvsTrackanglebetaTID->setBinContent(i,PullvsTrackanglebetaTID_2 ->GetBinContent(i));
01098     PullRMSvsTrackanglebetaTID->setBinError(i,PullvsTrackanglebetaTID_2 ->GetBinError(i));
01099     PullRMSvsTrackanglebetaTEC->setBinContent(i,PullvsTrackanglebetaTEC_2 ->GetBinContent(i));
01100     PullRMSvsTrackanglebetaTEC->setBinError(i,PullvsTrackanglebetaTEC_2 ->GetBinError(i));
01101   }  
01102 */  
01103 
01104 
01105   
01106   /*
01107   dbe_->setCurrentFolder("Tracking/TrackingRecHits/Strip/ALL");
01108   unsigned int NBINS = meErrxMFTrackwidthProfile->getNbinsX();
01109   float Entries = meErrxMFTrackwidthProfile->getEntries();
01110   cout<<"Entries = "<<Entries<<endl;
01111   cout<<"NBINS = "<<NBINS<<endl;
01112   NBINS=100;
01113   new_1D = dbe_->book1D("my_name", "my_title", NBINS,0.,5.);
01114   for(unsigned int i = 0; i != NBINS; ++i){
01115     cout<<"i,   getBinError(i) = "<<i<<";"<<meErrxMFTrackwidthProfile ->getBinError(i)<<endl;
01116    new_1D->setBinContent(i,meErrxMFTrackwidthProfile ->getBinError(i));
01117   }
01118   */
01119 
01120   /*
01121     myFile->cd();
01122 
01123     PositionSHx->Write();
01124     Diff->Write();
01125     SecondStrip->Write();
01126     ErrxMF->Write();
01127     ErrxMFvsTrackwidth->Write();
01128     ResMFvsTrackwidth->Write();
01129     ResMFvsTrackwidthWClus1->Write();
01130     ResMFvsTrackwidthWClus1Wexp1->Write();
01131     ResMFvsTrackwidthWClus1Wexp2->Write();
01132     ResMFvsTrackwidthWClus1Wexp3->Write();
01133     ResMFvsTrackwidthWClus1Wexp4->Write();
01134     ResMFvsTrackwidthWClus2->Write();
01135     ResMFvsTrackwidthWClus2Wexp1->Write();
01136     ResMFvsTrackwidthWClus2Wexp2->Write();
01137     ResMFvsTrackwidthWClus2Wexp3->Write();
01138     ResMFvsTrackwidthWClus2Wexp4->Write();
01139     ResMFvsTrackwidthWClus3->Write();
01140     ResMFvsTrackwidthWClus3Wexp1->Write();
01141     ResMFvsTrackwidthWClus3Wexp2->Write();
01142     ResMFvsTrackwidthWClus3Wexp3->Write();
01143     ResMFvsTrackwidthWClus3Wexp4->Write();
01144     ResMFvsTrackwidthWClus4->Write();
01145     ResMFvsTrackwidthWClus4Wexp1->Write();
01146     ResMFvsTrackwidthWClus4Wexp2->Write();
01147     ResMFvsTrackwidthWClus4Wexp3->Write();
01148     ResMFvsTrackwidthWClus4Wexp4->Write();
01149     ErrxMFvsTrackwidthWClus1->Write();
01150     ErrxMFvsTrackwidthWClus2->Write();
01151     ErrxMFvsTrackwidthWClus3->Write();
01152     ErrxMFvsTrackwidthWClus4->Write();
01153 
01154     ResMFvsTrackwidthCategory2->Write();
01155     ResMFvsTrackwidthCategory3->Write();
01156     ResMFvsTrackwidthCategory4->Write();
01157 
01158     ErrxMFvsTrackwidthCategory2->Write();
01159     ErrxMFvsTrackwidthCategory3->Write();
01160     ErrxMFvsTrackwidthCategory4->Write();
01161 
01162     //    ErrxMFvsTrackwidth_1->Write();
01163     //ErrxMFvsTrackwidth_2->Write();
01164 
01165     PullvsTrackwidth->Write();
01166     //PullvsTrackwidth_1 ->Write();
01167     //PullvsTrackwidth_2 ->Write();
01168     PullvsExpectedwidth->Write();
01169     PullvsExpectedwidth_1 ->Write();
01170     PullvsExpectedwidth_2 ->Write();
01171     PullvsClusterwidth->Write();
01172     PullvsClusterwidth_1 ->Write();
01173     PullvsClusterwidth_2 ->Write();
01174     PullvsTrackangle->Write();
01175     PullvsTrackangle_1 ->Write();
01176     PullvsTrackangle_2 ->Write();
01177     PullvsTrackanglebeta->Write();
01178     PullvsTrackanglebeta_1 ->Write();
01179     PullvsTrackanglebeta_2 ->Write();
01180     myFile->Close();
01181   */
01182 
01183 
01184   if ( outputFile_.size() != 0 && dbe_ ) dbe_->save(outputFile_);
01185 }
01186 
01187 // Virtual destructor needed.
01188 SiStripTrackingRecHitsValid::~SiStripTrackingRecHitsValid() {  
01189 
01190 }  
01191 
01192 // Functions that gets called by framework every event
01193 void SiStripTrackingRecHitsValid::analyze(const edm::Event& e, const edm::EventSetup& es)
01194 {
01195   
01196   // EventID e.id() ;
01197 
01198   //  float diff=0;
01199   //float positionshx = 0;
01200   //int secondstrip = 0;
01201 
01202   int isrechitrphi     = 0;
01203   int isrechitsas      = 0;
01204   int isrechitmatched  = 0;
01205 
01206   float anglealpha=0;
01207   float anglebeta=0;
01208   float Wtrack;
01209   int Wexp;
01210   int clusterWidth;
01211   DetId detid;
01212   uint32_t myid;
01213 
01214   LocalPoint position;
01215   LocalError error;
01216   MeasurementPoint Mposition;
01217   MeasurementError Merror;
01218 
01219   int clusiz=0;
01220   int totcharge=0;
01221 
01222 
01223   float mindist = 999999;
01224   float dist;
01225   std::vector<PSimHit> matched;
01226   
01227   TrackerHitAssociator associate(e, conf_);
01228   PSimHit closest;
01229 
01230   
01231 
01232   edm::ESHandle<TrackerGeometry> pDD;
01233   es.get<TrackerDigiGeometryRecord> ().get (pDD);
01234   const TrackerGeometry &tracker(*pDD);
01235 
01236   const TrackerGeometry * tracker2;
01237   edm::ESHandle<TrackerGeometry> estracker;
01238   es.get<TrackerDigiGeometryRecord>().get(estracker);
01239   tracker2=&(* estracker);
01240 
01241   edm::ESHandle<MagneticField> magfield;
01242   //iRecord.getRecord<IdealMagneticFieldRecord>().get(magfield );
01243   es.get<IdealMagneticFieldRecord>().get(magfield );
01244   //  magfield_  = magfield;
01245   //const magfield_
01246   const MagneticField & magfield_ (*magfield);
01247   magfield2_ = &magfield_;
01248 
01249 
01250   edm::ESHandle<StripClusterParameterEstimator> stripcpe;
01251   es.get<TkStripCPERecord>().get("SimpleStripCPE",stripcpe);
01252 
01253     //
01254 
01255 
01256   // Mangano's
01257 
01258   edm::Handle<vector<Trajectory> > trajCollectionHandle;
01259   e.getByLabel(conf_.getParameter<string>("trajectoryInput"),trajCollectionHandle);
01260 
01261   edm::LogVerbatim("TrajectoryAnalyzer") << "trajColl->size(): " << trajCollectionHandle->size() ;
01262 
01263   //cout<<"trajColl->size() = "<<trajCollectionHandle->size()<<endl;
01264   
01265   for(vector<Trajectory>::const_iterator it = trajCollectionHandle->begin(); it!=trajCollectionHandle->end();it++){
01266      
01267     edm::LogVerbatim("TrajectoryAnalyzer") << "this traj has " << it->foundHits() << " valid hits"  << " , "
01268                                             << "isValid: " << it->isValid() ;
01269 
01270     vector<TrajectoryMeasurement> tmColl = it->measurements();
01271     for(vector<TrajectoryMeasurement>::const_iterator itTraj = tmColl.begin(); itTraj!=tmColl.end(); itTraj++){
01272       if(! itTraj->updatedState().isValid()) continue;
01273            
01274 //        edm::LogVerbatim("TrajectoryAnalyzer") << "tm number: " << (itTraj - tmColl.begin()) + 1<< " , "
01275 //        << "tm.backwardState.pt: " << itTraj->backwardPredictedState().globalMomentum().perp() << " , "
01276 //        << "tm.forwardState.pt:  " << itTraj->forwardPredictedState().globalMomentum().perp() << " , "
01277 //        << "tm.updatedState.pt:  " << itTraj->updatedState().globalMomentum().perp()  << " , "
01278 //        << "tm.globalPos.perp: "   << itTraj->updatedState().globalPosition().perp() ;       
01279        
01280                if ( itTraj->updatedState().globalMomentum().perp() < 1.) continue;
01281                
01282       TrajectoryStateOnSurface tsos=itTraj->updatedState();
01283       LocalVector trackdirection=tsos.localDirection();
01284 
01285       DetId  detid2 = itTraj->recHit()->geographicalId();
01286 
01287       const TransientTrackingRecHit::ConstRecHitPointer thit2=itTraj->recHit();
01288       const SiStripMatchedRecHit2D* matchedhit=dynamic_cast<const SiStripMatchedRecHit2D*>((*thit2).hit());
01289       const SiStripRecHit2D* hit2d=dynamic_cast<const SiStripRecHit2D*>((*thit2).hit());
01290       const SiStripRecHit1D* hit1d=dynamic_cast<const SiStripRecHit1D*>((*thit2).hit());
01291       //if(matchedhit) cout<<"manganomatchedhit"<<endl;
01292       //if(hit) cout<<"manganosimplehit"<<endl;
01293       //if (hit && matchedhit) cout<<"manganosimpleandmatchedhit"<<endl;
01294       const TrackingRecHit *thit = (*thit2).hit();
01295             
01296       detid = (thit)->geographicalId();
01297       myid=((thit)->geographicalId()).rawId();
01298 
01299       StripSubdetector StripSubdet = (StripSubdetector) detid;
01300 
01301       isrechitmatched  = 0;
01302       
01303       if(matchedhit){
01304 
01305         isrechitmatched = 1;
01306  
01307         position = (thit)->localPosition();
01308         //  Mposition = topol.measurementPosition(position);
01309         error = (thit)->localPositionError();
01310         //  Merror = topol.measurementError(position,error);
01311         rechitmatchedx = position.x();
01312         rechitmatchedy = position.y();
01313         rechitmatchedz = position.z();
01314         rechitmatchederrxx = error.xx();
01315         rechitmatchederrxy = error.xy();
01316         rechitmatchederryy = error.yy();
01317 
01318         //Association of the rechit to the simhit
01319         mindist = 999999;
01320         float distx, disty;
01321         std::pair<LocalPoint,LocalVector> closestPair;
01322         matched.clear();
01323         matched = associate.associateHit(*matchedhit);
01324         if(!matched.empty()){
01325           //project simhit;
01326           const GluedGeomDet* gluedDet = (const GluedGeomDet*)tracker.idToDet(matchedhit->geographicalId());
01327           const StripGeomDetUnit* partnerstripdet =(StripGeomDetUnit*) gluedDet->stereoDet();
01328           std::pair<LocalPoint,LocalVector> hitPair;
01329           for(vector<PSimHit>::const_iterator m=matched.begin(); m<matched.end(); m++){
01330             //project simhit;
01331             hitPair= projectHit((*m),partnerstripdet,gluedDet->surface());
01332             distx = fabs(rechitmatchedx - hitPair.first.x());
01333             disty = fabs(rechitmatchedy - hitPair.first.y());
01334             dist = distx*distx+disty*disty;
01335             if(sqrt(dist)<mindist){
01336               mindist = dist;
01337               closestPair = hitPair;
01338             }
01339           }
01340           rechitmatchedresx = rechitmatchedx - closestPair.first.x();
01341           rechitmatchedresy = rechitmatchedy - closestPair.first.y();
01342           rechitmatchedpullx = ((thit)->localPosition().x() - (closestPair.first.x()))/sqrt(error.xx());
01343           rechitmatchedpully = ((thit)->localPosition().y() - (closestPair.first.y()))/sqrt(error.yy());
01344         }
01345       }
01346  
01347       //Filling Histograms for Matched hits
01348 
01349       if(isrechitmatched){
01350 
01351         if (detid.subdetId() == int(StripSubdetector::TIB)){
01352           TIBDetId tibid(myid);
01353           int Tibisrechitmatched = isrechitmatched;
01354           int ilay = tibid.layer() - 1; //for histogram filling
01355           if(Tibisrechitmatched>0){
01356             mePosxMatchedTIB[ilay]->Fill(rechitmatchedx);
01357             meErrxMatchedTIB[ilay]->Fill(sqrt(rechitmatchederrxx));
01358             meErryMatchedTIB[ilay]->Fill(sqrt(rechitmatchederryy));
01359             meResxMatchedTIB[ilay]->Fill(rechitmatchedresx);
01360             meResyMatchedTIB[ilay]->Fill(rechitmatchedresy);
01361             mePullxMatchedTIB[ilay]->Fill(rechitmatchedpullx);
01362             mePullyMatchedTIB[ilay]->Fill(rechitmatchedpully);
01363 
01364           }
01365         }
01366               
01367         if (detid.subdetId() == int(StripSubdetector::TOB)){
01368           TOBDetId tobid(myid);
01369           int Tobisrechitmatched = isrechitmatched;
01370           int ilay = tobid.layer() - 1; //for histogram filling
01371           if(Tobisrechitmatched>0){
01372             mePosxMatchedTOB[ilay]->Fill(rechitmatchedx);
01373             mePosyMatchedTOB[ilay]->Fill(rechitmatchedy);
01374             meErrxMatchedTOB[ilay]->Fill(sqrt(rechitmatchederrxx));
01375             meErryMatchedTOB[ilay]->Fill(sqrt(rechitmatchederryy));
01376             meResxMatchedTOB[ilay]->Fill(rechitmatchedresx);
01377             meResyMatchedTOB[ilay]->Fill(rechitmatchedresy);
01378             mePullxMatchedTOB[ilay]->Fill(rechitmatchedpullx);
01379             mePullyMatchedTOB[ilay]->Fill(rechitmatchedpully);
01380           }
01381         }
01382         if (detid.subdetId() == int(StripSubdetector::TID)){
01383           TIDDetId tidid(myid);
01384           int Tidisrechitmatched = isrechitmatched;
01385           int ilay = tidid.ring() - 1; //for histogram filling
01386           if(Tidisrechitmatched>0){
01387             mePosxMatchedTID[ilay]->Fill(rechitmatchedx);
01388             mePosyMatchedTID[ilay]->Fill(rechitmatchedy);
01389             meErrxMatchedTID[ilay]->Fill(sqrt(rechitmatchederrxx));
01390             meErryMatchedTID[ilay]->Fill(sqrt(rechitmatchederryy));
01391             meResxMatchedTID[ilay]->Fill(rechitmatchedresx);
01392             meResyMatchedTID[ilay]->Fill(rechitmatchedresy);
01393             mePullxMatchedTID[ilay]->Fill(rechitmatchedpullx);
01394             mePullyMatchedTID[ilay]->Fill(rechitmatchedpully);
01395           }
01396         }
01397         if (detid.subdetId() == int(StripSubdetector::TEC)){
01398           TECDetId tecid(myid);
01399           int Tecisrechitmatched = isrechitmatched;
01400           int ilay = tecid.ring() - 1; //for histogram filling
01401           if(Tecisrechitmatched>0){
01402             mePosxMatchedTEC[ilay]->Fill(rechitmatchedx);
01403             mePosyMatchedTEC[ilay]->Fill(rechitmatchedy);
01404             meErrxMatchedTEC[ilay]->Fill(sqrt(rechitmatchederrxx));
01405             meErryMatchedTEC[ilay]->Fill(sqrt(rechitmatchederryy));
01406             meResxMatchedTEC[ilay]->Fill(rechitmatchedresx);
01407             meResyMatchedTEC[ilay]->Fill(rechitmatchedresy);
01408             mePullxMatchedTEC[ilay]->Fill(rechitmatchedpullx);
01409             mePullyMatchedTEC[ilay]->Fill(rechitmatchedpully);
01410           }
01411         }
01412               
01413       }
01414       
01415               
01417       // simple hits from matched hits
01419       // Reset variables
01420       
01421       isrechitrphi    = 0;
01422       isrechitsas     = 0;
01423       rechitrphix =0;
01424       rechitrphierrxLF =0;
01425       rechitrphierrxMF =0;
01426       rechitrphiy =0;
01427       rechitrphiz =0;
01428       rechitsasx =0;
01429       rechitsaserrxLF =0;
01430       rechitsaserrxMF =0;
01431       rechitsasy =0;
01432       rechitsasz =0;
01433       clusizrphi =0;
01434       clusizsas =0;
01435       cluchgrphi =0;
01436       cluchgsas =0;
01437       rechitrphiresLF=-999.;
01438       rechitrphiresMF=-999.;
01439       rechitrphipullLF=-999.;
01440       rechitrphipullMF=-999.;
01441       rechitrphitrackangle =0;
01442       rechitrphitrackanglebeta =0;
01443       rechitrphitrackangle2 =0;
01444       rechitrphitrackwidth =0;
01445       rechitrphiexpectedwidth =0;
01446       rechitrphicategory =0;
01447       rechitrphithickness = 0.;
01448       rechitsasresLF=-999.;
01449       rechitsasresMF=-999.;
01450       rechitsaspullLF=-999.;
01451       rechitsaspullMF=-999.;
01452       rechitsastrackangle =0;
01453       rechitsastrackanglebeta =0;
01454       rechitsasthickness = 0;
01455 
01456       GluedGeomDet * gdet;
01457       const GeomDetUnit * monodet;
01458       const SiStripRecHit2D *monohit;
01459       const StripGeomDetUnit * stripdet;
01460 
01461       if (matchedhit)
01462         {
01463           auto hm =matchedhit->monoHit();
01464           monohit=&hm;
01465           //      const GeomDetUnit * monodet=gdet->monoDet();
01466           gdet=(GluedGeomDet *)tracker2->idToDet(matchedhit->geographicalId());
01467           monodet=gdet->monoDet();
01468           GlobalVector gtrkdir=gdet->toGlobal(trackdirection);
01469           LocalVector monotkdir=monodet->toLocal(gtrkdir);
01470           //      const GeomDetUnit *  det = tracker.idToDetUnit(detid);
01471           //stripdet=(const StripGeomDetUnit*)(gdet);
01472           stripdet=(const StripGeomDetUnit*)(monodet);
01473           //      const StripTopology &topol2=(const StripTopology&)stripdet->topology();
01474 
01475           if(monotkdir.z()!=0){
01476             anglealpha = atan(monotkdir.x()/monotkdir.z())*180/TMath::Pi();
01477             anglebeta = atan(monotkdir.y()/monotkdir.z())*180/TMath::Pi();
01478           }
01479           
01480           if(monohit){
01481 
01482             const StripTopology &topol=(const StripTopology&)stripdet->topology();
01483 
01484             position = monohit->localPosition();
01485             error = monohit->localPositionError();
01486             Mposition = topol.measurementPosition(position);
01487             Merror = topol.measurementError(position,error);
01488 
01489             LocalVector drift = stripcpe->driftDirection(stripdet);
01490             float thickness=stripdet->surface().bounds().thickness();
01491             rechitrphithickness = thickness;
01492 
01493             //cout<<"thickness = "<<thickness<<endl;
01494             float pitch = topol.localPitch(position);
01495             //cout<<"Valid:pitch = "<<pitch<<endl;
01496             float tanalpha = tan(anglealpha/57.3);
01497             //cout<<"Valid:tanalpha = "<<tanalpha<<endl;
01498             float tanalphaL = drift.x()/drift.z();
01499             //float tanalphaLbis = driftbis.x()/driftbis.z();
01500             //float tanalphaLter = driftter.x()/driftter.z();
01501             //cout<<"Validmonofrommatched:drift.x() = "<<drift.x()<<endl;
01502             //cout<<"Valid:drift.x() = "<<drift.x()<<endl;
01503             //cout<<"Valid:driftbis.x() = "<<driftbis.x()<<endl;
01504             //cout<<"Valid:driftter.x() = "<<driftter.x()<<endl;
01505             //cout<<"Valid:driftter.z() = "<<driftter.z()<<endl;
01506             //cout<<"Valid:tanalphaL = "<<tanalphaL<<endl;
01507             Wtrack = fabs((thickness/pitch)*tanalpha - (thickness/pitch)*tanalphaL);
01508             //cout<<"Valid1:Wtrack = "<<Wtrack<<endl;
01509             float SLorentz = 0.5*(thickness/pitch)*tanalphaL;
01510             //int nstrips = topol.nstrips(); 
01511             //clusterWidth = cluster->amplitudes().size();
01512             int Sp = int(position.x()/pitch+SLorentz+0.5*Wtrack);
01513             int Sm = int(position.x()/pitch+SLorentz-0.5*Wtrack);
01514             Wexp = 1+Sp-Sm;
01515             //cout<<"DebugLine22"<<endl;
01516 
01517             isrechitrphi = 1;
01518             //cout<<"DebugLine23"<<endl;
01519             //          const edm::Ref<edm::DetSetVector<SiStripCluster>, SiStripCluster, edm::refhelper::FindForDetSetVector<SiStripCluster> > cluster=hit->cluster();
01520             SiStripRecHit2D::ClusterRef cluster=monohit->cluster();
01521             //SiStripRecHit1D::ClusterRef cluster=monohit->cluster();
01522             clusiz=0;
01523             totcharge=0;
01524             clusiz = cluster->amplitudes().size();
01525             //      cout<<"clusiz = "<<clusiz<<endl;
01526             const std::vector<uint8_t> amplitudes=cluster->amplitudes();
01527             for(size_t ia=0; ia<amplitudes.size();ia++){
01528               totcharge+=amplitudes[ia];
01529             }
01530             rechitrphix = position.x();
01531             rechitrphiy = position.y();
01532             rechitrphiz = position.z();
01533             rechitrphierrxLF = error.xx();
01534             rechitrphierrxMF = Merror.uu();
01535             //      cout<<"rechitrphierrxMF from Matched hit= "<<sqrt(rechitrphierrxMF)<<endl;
01536             clusizrphi = clusiz;
01537             cluchgrphi = totcharge;
01538 
01539             //Association of the rechit to the simhit
01540             mindist = 999999;
01541             matched.clear();  
01542             //          matched = associate.associateHit(*hit);
01543             matched = associate.associateHit(*monohit);
01544             if(!matched.empty()){
01545               //                  cout << "\t\t\tmatched  " << matched.size() << endl;
01546               //              cout<<"associatesimplehit"<<endl;
01547               for(vector<PSimHit>::const_iterator m=matched.begin(); m<matched.end(); m++){
01548                 dist = abs((monohit)->localPosition().x() - (*m).localPosition().x());
01549                 if(dist<mindist){
01550                   mindist = dist;
01551                   closest = (*m);
01552                 }
01553                 rechitrphiresLF = rechitrphix - closest.localPosition().x();
01554                 rechitrphiresMF = Mposition.x() - (topol.measurementPosition(closest.localPosition())).x();
01555                 rechitrphipullLF =  rechitrphiresLF/sqrt(rechitrphierrxLF);
01556                 rechitrphipullMF = rechitrphiresMF/sqrt(rechitrphierrxMF);
01557                 //cout<<"rechitrphiresMF == "<<rechitrphiresMF<<endl;
01558                 //cout<<"rechitrphierrxMF == "<<rechitrphierrxMF<<endl;
01559                 //cout<<"rechitrphierrxLF == "<<rechitrphierrxLF<<endl;
01560                 //cout<<"rechitrphipullMF == "<<rechitrphipullMF<<endl;
01561 
01562               }
01563             }
01564             rechitrphitrackangle = anglealpha;
01565             rechitrphitrackanglebeta = anglebeta;
01566             //rechitrphitrackangle = tanalphaL;
01567             //cout<<"Wtrack = "<<Wtrack<<endl;
01568             rechitrphitrackwidth = Wtrack;
01569             rechitrphiexpectedwidth = Wexp;
01570             clusterWidth = clusiz;
01571             unsigned int iopt;
01572             if (clusterWidth > Wexp + 2) {
01573               iopt = 1;
01574             } else if (Wexp == 1) {
01575               iopt = 2;
01576             } else if (clusterWidth <= Wexp) {
01577               iopt = 3;
01578             } else {
01579               iopt = 4;
01580             }
01581             rechitrphicategory = iopt;
01582           }
01583            
01584           auto s =matchedhit->stereoHit();
01585           const SiStripRecHit2D *stereohit=&s;
01586           const GeomDetUnit * stereodet=gdet->stereoDet(); 
01587           //      GlobalVector 
01588           gtrkdir=gdet->toGlobal(trackdirection);
01589           LocalVector stereotkdir=stereodet->toLocal(gtrkdir);
01590           if(stereotkdir.z()!=0){
01591             anglealpha = atan(stereotkdir.x()/stereotkdir.z())*180/TMath::Pi();
01592             anglebeta = atan(stereotkdir.y()/stereotkdir.z())*180/TMath::Pi();
01593           }
01594           
01595           if (stereohit)
01596             {
01597               //              cout<<"stereohit from matched hit"<<endl;
01598               isrechitsas = 1;
01599               SiStripRecHit2D::ClusterRef cluster=stereohit->cluster();
01600             
01601               //              const GeomDetUnit *  det = tracker.idToDetUnit(detid2);
01602               const StripGeomDetUnit * stripdet=(const StripGeomDetUnit*)(stereodet);
01603               const StripTopology &topol=(const StripTopology&)stripdet->topology();
01604 
01605               position = stereohit->localPosition();
01606               //  Mposition = topol.measurementPosition(position);
01607               error = stereohit->localPositionError();
01608               Mposition = topol.measurementPosition(position);
01609               Merror = topol.measurementError(position,error);
01610 
01611               //LocalVector drift= driftDirection(stripdet);
01612               LocalVector drift = stripcpe->driftDirection(stripdet);
01613               float thickness=stripdet->surface().bounds().thickness();
01614               rechitsasthickness = thickness;
01615               //cout<<"thickness = "<<thickness<<endl;
01616               float pitch = topol.localPitch(position);
01617               //cout<<"Valid:pitch = "<<pitch<<endl;
01618               float tanalpha = tan(anglealpha/57.3);
01619               //cout<<"Valid:tanalpha = "<<tanalpha<<endl;
01620               float tanalphaL = drift.x()/drift.z();
01621               //cout<<"Validstereofrommatched:drift.x() = "<<drift.x()<<endl;
01622               //cout<<"Valid:drift.z() = "<<drift.z()<<endl;
01623               //cout<<"Valid:tanalphaL = "<<tanalphaL<<endl;
01624               Wtrack = fabs((thickness/pitch)*tanalpha - (thickness/pitch)*tanalphaL);
01625               //cout<<"Valid:Wtrack = "<<Wtrack<<endl;
01626               float SLorentz = 0.5*(thickness/pitch)*tanalphaL;
01627               //int nstrips = topol.nstrips(); 
01628               int Sp = int(position.x()/pitch+SLorentz+0.5*Wtrack);
01629               int Sm = int(position.x()/pitch+SLorentz-0.5*Wtrack);
01630               Wexp = 1+Sp-Sm;
01631 
01632 
01633               clusiz=0;
01634               totcharge=0;
01635               clusiz = cluster->amplitudes().size();
01636               const std::vector<uint8_t> amplitudes=cluster->amplitudes();
01637               for(size_t ia=0; ia<amplitudes.size();ia++){
01638                 totcharge+=amplitudes[ia];
01639               }
01640               rechitsasx = position.x();
01641               rechitsasy = position.y();
01642               rechitsasz = position.z();
01643               rechitsaserrxLF = error.xx();
01644               //              cout<<"rechitsaserrxLF = "<<rechitsaserrxLF<<endl;
01645               rechitsaserrxMF = Merror.uu();
01646               //              cout<<"rechitsaserrxMF from Matched hit = "<<sqrt(rechitsaserrxMF)<<endl;
01647               clusizsas = clusiz;
01648               cluchgsas = totcharge;
01649 
01650               //Association of the rechit to the simhit
01651               mindist = 999999;
01652               matched.clear();  
01653               matched = associate.associateHit(*stereohit);
01654               if(!matched.empty()){
01655                 //                cout << "\t\t\tmatched  " << matched.size() << endl;
01656                 for(vector<PSimHit>::const_iterator m=matched.begin(); m<matched.end(); m++){
01657                   dist = abs((stereohit)->localPosition().x() - (*m).localPosition().x());
01658                   if(dist<mindist){
01659                     mindist = dist;
01660                     closest = (*m);
01661                   }
01662 
01663                   rechitsasresLF = rechitsasx - closest.localPosition().x();
01664                   rechitsasresMF = Mposition.x() - (topol.measurementPosition(closest.localPosition())).x();
01665                   rechitsaspullLF = rechitsasresLF/sqrt(rechitsaserrxLF);
01666                   rechitsaspullMF = rechitsasresMF/sqrt(rechitsaserrxMF);
01667                   
01668 //                cout<<"rechitsasresMF == "<<rechitsasresMF<<endl;
01669 //                cout<<"rechitsaserrxMF == "<<rechitsaserrxMF<<endl;
01670 //                cout<<"rechitsaserrxLF == "<<rechitsaserrxLF<<endl;
01671 //                cout<<"rechitsaspullMF == "<<rechitsaspullMF<<endl;
01672                   
01673                 }
01674               }
01675               rechitsastrackangle = anglealpha;
01676               rechitsastrackanglebeta = anglebeta;
01677               rechitsastrackwidth = Wtrack;
01678               rechitsasexpectedwidth = Wexp;
01679 
01680               clusterWidth = clusiz;
01681               unsigned int iopt;
01682               if (clusterWidth > Wexp + 2) {
01683                 iopt = 1;
01684               } else if (Wexp == 1) {
01685                 iopt = 2;
01686               } else if (clusterWidth <= Wexp) {
01687                 iopt = 3;
01688               } else {
01689                 iopt = 4;
01690               }
01691               rechitsascategory = iopt;
01692             }
01693         }
01694 
01695 
01696       // A VIRER !!!!!!!!!!!!!!!!!!!!
01697 
01698       //    isrechitrphi = 0;
01699       //isrechitsas = 0;
01700       
01701       
01702       if(hit1d){
01703         // simple hits are mono or stereo
01704         //      cout<<"simple hit"<<endl;
01705         if (StripSubdet.stereo() == 0){
01706           isrechitrphi = 1;
01707           //      cout<<"simple hit mono"<<endl;
01708 
01709           const GeomDetUnit *  det = tracker.idToDetUnit(detid2);
01710           const StripGeomDetUnit * stripdet=(const StripGeomDetUnit*)(det);
01711           const StripTopology &topol=(const StripTopology&)stripdet->topology();
01712 
01713           float anglealpha = atan(trackdirection.x()/trackdirection.z())*180/TMath::Pi();
01714           float anglebeta = atan(trackdirection.y()/trackdirection.z())*180/TMath::Pi();
01715 
01716           //SiStripRecHit2D::ClusterRef cluster=hit->cluster();
01717           SiStripRecHit1D::ClusterRef cluster=hit1d->cluster();
01718 
01719           position = thit->localPosition();
01720           error = thit->localPositionError();
01721           Mposition = topol.measurementPosition(position);
01722           Merror = topol.measurementError(position,error);
01723 
01724           LocalVector drift = stripcpe->driftDirection(stripdet);
01725           float thickness=stripdet->surface().bounds().thickness();
01726           rechitrphithickness = thickness;
01727           //cout<<"Valid:thickness = "<<thickness<<endl;
01728           float pitch = topol.localPitch(position);
01729           //cout<<"Valid:pitch = "<<pitch<<endl;
01730           float tanalpha = tan(anglealpha/57.3);
01731           //cout<<"Valid:tanalpha = "<<tanalpha<<endl;
01732           float tanalphaL = drift.x()/drift.z();
01733           //cout<<"Valid:tanalphaL = "<<tanalphaL<<endl;
01734           //      float tanalphaLcpe = driftcpe.x()/driftcpe.z();
01735           //cout<<"Valid:tanalphaLcpe = "<<tanalphaLcpe<<endl;
01736           //cout<<"Validmono:drift.x() = "<<drift.x()<<endl;
01737           //cout<<"Valid:drift.z() = "<<drift.z()<<endl;
01738           //cout<<"Valid:tanalphaL = "<<tanalphaL<<endl;
01739           Wtrack = fabs((thickness/pitch)*tanalpha - (thickness/pitch)*tanalphaL);
01740           //       fabs((thickness/pitch)*tanalpha - (thickness/pitch)*tanalphaL);
01741           //cout<<"Valid2:Wtrack = "<<Wtrack<<endl;
01742           float SLorentz = 0.5*(thickness/pitch)*tanalphaL;
01743           //int nstrips = topol.nstrips(); 
01744           int Sp = int(position.x()/pitch+SLorentz+0.5*Wtrack);
01745           int Sm = int(position.x()/pitch+SLorentz-0.5*Wtrack);
01746           Wexp = 1+Sp-Sm;
01747 
01748           clusiz=0;
01749           totcharge=0;
01750           clusiz = cluster->amplitudes().size();
01751           //cout<<"cluster->firstStrip() = "<<cluster->firstStrip()<<endl;
01752           const std::vector<uint8_t> amplitudes=cluster->amplitudes();
01753           for(size_t ia=0; ia<amplitudes.size();ia++){
01754             totcharge+=amplitudes[ia];
01755           }
01756           rechitrphix = position.x();
01757           rechitrphiy = position.y();
01758           rechitrphiz = position.z();
01759           rechitrphierrx = error.xx();
01760           rechitrphierrxLF = error.xx();
01761           rechitrphierrxMF = Merror.uu();
01762           //cout<<"rechitrphierrxMF simple hit= "<<sqrt(rechitrphierrxMF)<<endl;
01763           clusizrphi = clusiz;
01764           //cout<<"clusizrphi = "<<clusiz<<endl;
01765           cluchgrphi = totcharge;
01766 
01767           //Association of the rechit to the simhit
01768           mindist = 999999;
01769           matched.clear();  
01770           matched = associate.associateHit(*hit1d);
01771           if(!matched.empty()){
01772             //            cout << "\t\t\tmatched  " << matched.size() << endl;
01773             for(vector<PSimHit>::const_iterator m=matched.begin(); m<matched.end(); m++){
01774               dist = abs((hit1d)->localPosition().x() - (*m).localPosition().x());
01775               if(dist<mindist){
01776                 mindist = dist;
01777                 closest = (*m);
01778               }
01779               rechitrphiresLF = rechitrphix - closest.localPosition().x();
01780               rechitrphiresMF = Mposition.x() - (topol.measurementPosition(closest.localPosition())).x();
01781               rechitrphipullLF = (thit->localPosition().x() - (closest).localPosition().x())/sqrt(error.xx());
01782               rechitrphipullMF = rechitrphiresMF/sqrt(rechitrphierrxMF);
01783             }
01784           }
01785           rechitrphitrackangle = anglealpha;
01786           rechitrphitrackanglebeta = anglebeta;
01787           rechitrphitrackwidth = Wtrack;
01788           rechitrphiexpectedwidth = Wexp;
01789 
01790           clusterWidth = clusiz;
01791           unsigned int iopt;
01792           if (clusterWidth > Wexp + 2) {
01793             iopt = 1;
01794           } else if (Wexp == 1) {
01795             iopt = 2;
01796           } else if (clusterWidth <= Wexp) {
01797             iopt = 3;
01798           } else {
01799             iopt = 4;
01800           }
01801           rechitrphicategory = iopt;
01802           
01803 //        if (rechitrphiexpectedwidth == 1 && clusterWidth == 3) {
01804 //        //if ( clusterWidth == 3) {
01805 //          cout<<"TRUE"<<endl;
01806 //          cout<<"TestClus2:Position SH = "<<(closest).localPosition().x()<<" , "<<(topol.measurementPosition(closest.localPosition())).x()<<endl;
01807 //          cout<<"TestClus2:Position RH = "<<thit->localPosition().x()<<" ,"<<Mposition.x()<<endl;
01808 //          cout<<"TestClus2:residue = "<<rechitrphiresMF<<endl;
01809 //          short firstStrip = cluster->firstStrip();
01810 //          short lastStrip = firstStrip + clusterWidth - 1;
01811 //          cout<<"TestClus2:firstStrip = "<<firstStrip<<endl;
01812 //          cout<<"TestClus2:lastStrip = "<<lastStrip<<endl;
01813 //          cout<<"TestClus2:detid = "<<detid.subdetId()<<endl;
01814 //          for(size_t ia=0; ia<amplitudes.size();ia++){
01815 //            cout<<"ia, TestClus2:charge= "<<ia<<" , "<<amplitudes[ia]<<endl;
01816 //          }
01817 //          cout<<"TestClus2:Trackwidth = "<<Wtrack<<endl;
01818 //        }
01819           
01820         
01821           //cout<<"rechitrphicategory = "<<rechitrphicategory<<endl;
01822 
01823           //      if ((detid.subdetId() == int(StripSubdetector::TID)) || (detid.subdetId() == int(StripSubdetector::TEC))) {
01824             //if ((detid.subdetId() == int(StripSubdetector::TIB))) {
01825            
01826 //          if (clusterWidth ==2 && Wexp == 1 && Wtrack<0.1) {
01827 //            cout<<"TestClus:begin"<<endl;
01828 //            LocalVector  drift2 = drift * fabs(thickness/drift.z());       
01829 //            LocalPoint result2=LocalPoint(position.x()-drift2.x()/2,position.y()-drift2.y()/2,0);
01830 //            MeasurementPoint mpoint=topol.measurementPosition(result2);
01831 //            cout<<"TestClus:Position SH = "<<(closest).localPosition().x()<<" , "<<(topol.measurementPosition(closest.localPosition())).x()<<endl;
01832 //            cout<<"TestClus:Position RH = "<<thit->localPosition().x()<<" ,"<<Mposition.x()<<endl;
01833 //            cout<<"TestClus:Position RH no drift= "<<thit->localPosition().x() - drift2.x()/2<<" , "<<mpoint.x()<<endl;
01834 //            cout<<"TestClus:Drift= "<<drift.x()<<endl;
01835 //            cout<<"TestClus:residue = "<<rechitrphiresMF<<endl;
01836 //            for(size_t ia=0; ia<amplitudes.size();ia++){
01837 //              cout<<"ia, TestClus:charge= "<<ia<<" , "<<amplitudes[ia]<<endl;
01838 //            }
01839 //            cout<<"TestClus:Trackwidth = "<<Wtrack<<endl;
01840 //            short firstStrip = cluster->firstStrip();
01841 //            short lastStrip = firstStrip + clusterWidth - 1;
01842 //            cout<<"TestClus:firstStrip = "<<firstStrip<<endl;
01843 //            cout<<"TestClus:lastStrip = "<<lastStrip<<endl;
01844 //            cout<<"TestClus:detid = "<<detid.subdetId()<<endl;
01845 //            int nstrips = topol.nstrips(); 
01846 //            cout<<"TestClus:nstrips = "<<nstrips<<endl;
01847 //            cout<<"TestClus:anglealpha = "<<anglealpha<<endl;
01848 //            cout<<"TestClus:end"<<endl;
01849 //            positionshx = (topol.measurementPosition(closest.localPosition())).x();
01850 
01851 //            if ((positionshx - int(positionshx)) > 0.5) {
01852 //              if (lastStrip > int(positionshx)) secondstrip = 1;
01853 //              if (lastStrip = int(positionshx)) secondstrip = -1;
01854 //            }
01855 //            if ((positionshx - int(positionshx)) < 0.5) {
01856 //              if (lastStrip > int(positionshx)) secondstrip = -1;
01857 //              if (lastStrip = int(positionshx)) secondstrip = 1;
01858 //            }
01859 
01860 //          }
01861 
01862             //}
01863           
01864 //        cout<<"int() = "<<int((topol.measurementPosition(closest.localPosition())).x())<<endl;
01865 //        diff = int((topol.measurementPosition(closest.localPosition())).x()) -topol.measurementPosition(closest.localPosition()).x();
01866 //        cout<<"diff = "<<diff<<endl;
01867 //        if (clusterWidth ==2 && Wexp == 1 && Wtrack<1) {
01868 //          if ((abs(1 + diff) <0.2) || (abs(diff) <0.2)) {
01869 //            //              isrechitrphi = 0;
01870 //            cout<<"vire"<<endl;
01871 //          }
01872 //        }
01873 //        positionshx = (topol.measurementPosition(closest.localPosition())).x();
01874 
01875 
01876         }
01877 
01878         if (StripSubdet.stereo() == 1){
01879 
01880           //cout<<"simple hit stereo"<<endl;
01881           isrechitsas = 1;
01882 
01883           const GeomDetUnit *  det = tracker.idToDetUnit(detid2);
01884           const StripGeomDetUnit * stripdet=(const StripGeomDetUnit*)(det);
01885           const StripTopology &topol=(const StripTopology&)stripdet->topology();
01886 
01887           float anglealpha = atan(trackdirection.x()/trackdirection.z())*180/TMath::Pi();
01888           float anglebeta = atan(trackdirection.y()/trackdirection.z())*180/TMath::Pi();
01889 
01890           //SiStripRecHit2D::ClusterRef cluster=hit->cluster();
01891           SiStripRecHit1D::ClusterRef cluster=hit1d->cluster();
01892 
01893 
01894           position = thit->localPosition();
01895           error = thit->localPositionError();
01896           Mposition = topol.measurementPosition(position);
01897           Merror = topol.measurementError(position,error);
01898 
01899           //      LocalVector drift= driftDirection(stripdet);
01900           LocalVector drift = stripcpe->driftDirection(stripdet);
01901           float thickness=stripdet->surface().bounds().thickness();
01902           rechitsasthickness = thickness;
01903           //cout<<"thickness = "<<thickness<<endl;
01904           float pitch = topol.localPitch(position);
01905           //cout<<"Valid:pitch = "<<pitch<<endl;
01906           float tanalpha = tan(anglealpha/57.3);
01907           //cout<<"Valid:tanalpha = "<<tanalpha<<endl;
01908           float tanalphaL = drift.x()/drift.z();
01909           //cout<<"Validstereo:drift.x() = "<<drift.x()<<endl;
01910           //cout<<"Valid:drift.z() = "<<drift.z()<<endl;
01911           //cout<<"Valid:tanalphaL = "<<tanalphaL<<endl;
01912           Wtrack = fabs((thickness/pitch)*tanalpha - (thickness/pitch)*tanalphaL);
01913           //cout<<"Valid:Wtrack = "<<Wtrack<<endl;
01914           float SLorentz = 0.5*(thickness/pitch)*tanalphaL;
01915           //int nstrips = topol.nstrips(); 
01916           int Sp = int(position.x()/pitch+SLorentz+0.5*Wtrack);
01917           int Sm = int(position.x()/pitch+SLorentz-0.5*Wtrack);
01918           Wexp = 1+Sp-Sm;
01919 
01920           clusiz=0;
01921           totcharge=0;
01922           clusiz = cluster->amplitudes().size();
01923           const std::vector<uint8_t> amplitudes=cluster->amplitudes();
01924           for(size_t ia=0; ia<amplitudes.size();ia++){
01925             totcharge+=amplitudes[ia];
01926           }
01927           rechitsasx = position.x();
01928           rechitsasy = position.y();
01929           rechitsasz = position.z();
01930           rechitsaserrxLF = error.xx();
01931           //cout<<"rechitsaserrxLF = "<<rechitsaserrxLF<<endl;
01932           rechitsaserrxMF = Merror.uu();
01933           //cout<<"rechitsaserrxMF simple hit= "<<sqrt(rechitsaserrxMF)<<endl;
01934           clusizsas = clusiz;
01935           cluchgsas = totcharge;
01936 
01937           //Association of the rechit to the simhit
01938           mindist = 999999;
01939           matched.clear();  
01940           matched = associate.associateHit(*hit1d);
01941           if(!matched.empty()){
01942             //            cout << "\t\t\tmatched  " << matched.size() << endl;
01943             for(vector<PSimHit>::const_iterator m=matched.begin(); m<matched.end(); m++){
01944               dist = abs((hit1d)->localPosition().x() - (*m).localPosition().x());
01945               if(dist<mindist){
01946                 mindist = dist;
01947                 closest = (*m);
01948               }
01949 
01950               rechitsasresLF = rechitsasx - closest.localPosition().x();
01951               rechitsasresMF = Mposition.x() - (topol.measurementPosition(closest.localPosition())).x();
01952               rechitsaspullLF = (thit->localPosition().x() - (closest).localPosition().x())/sqrt(error.xx());
01953               rechitsaspullMF = rechitsasresMF/sqrt(rechitsaserrxMF);
01954 
01955             }
01956           }
01957           rechitsastrackangle = anglealpha;
01958           rechitsastrackanglebeta = anglebeta;
01959           rechitsastrackwidth = Wtrack;
01960           rechitsasexpectedwidth = Wexp;
01961 
01962           clusterWidth = clusiz;
01963           unsigned int iopt;
01964           if (clusterWidth > Wexp + 2) {
01965             iopt = 1;
01966           } else if (Wexp == 1) {
01967             iopt = 2;
01968           } else if (clusterWidth <= Wexp) {
01969             iopt = 3;
01970           } else {
01971             iopt = 4;
01972           }
01973           rechitsascategory = iopt;
01974         }
01975         //isrechitsas = 0;
01976       }
01977 
01978 
01979       if(hit2d){
01980         // simple hits are mono or stereo
01981         //      cout<<"simple hit"<<endl;
01982         if (StripSubdet.stereo() == 0){
01983           isrechitrphi = 1;
01984           //      cout<<"simple hit mono"<<endl;
01985 
01986           const GeomDetUnit *  det = tracker.idToDetUnit(detid2);
01987           const StripGeomDetUnit * stripdet=(const StripGeomDetUnit*)(det);
01988           const StripTopology &topol=(const StripTopology&)stripdet->topology();
01989 
01990           float anglealpha = atan(trackdirection.x()/trackdirection.z())*180/TMath::Pi();
01991           float anglebeta = atan(trackdirection.y()/trackdirection.z())*180/TMath::Pi();
01992 
01993           SiStripRecHit2D::ClusterRef cluster=hit2d->cluster();
01994 
01995           position = thit->localPosition();
01996           error = thit->localPositionError();
01997           Mposition = topol.measurementPosition(position);
01998           Merror = topol.measurementError(position,error);
01999 
02000           LocalVector drift = stripcpe->driftDirection(stripdet);
02001           float thickness=stripdet->surface().bounds().thickness();
02002           rechitrphithickness = thickness;
02003           //cout<<"Valid:thickness = "<<thickness<<endl;
02004           float pitch = topol.localPitch(position);
02005           //cout<<"Valid:pitch = "<<pitch<<endl;
02006           float tanalpha = tan(anglealpha/57.3);
02007           //cout<<"Valid:tanalpha = "<<tanalpha<<endl;
02008           float tanalphaL = drift.x()/drift.z();
02009           //cout<<"Valid:tanalphaL = "<<tanalphaL<<endl;
02010           //      float tanalphaLcpe = driftcpe.x()/driftcpe.z();
02011           //cout<<"Valid:tanalphaLcpe = "<<tanalphaLcpe<<endl;
02012           //cout<<"Validmono:drift.x() = "<<drift.x()<<endl;
02013           //cout<<"Valid:drift.z() = "<<drift.z()<<endl;
02014           //cout<<"Valid:tanalphaL = "<<tanalphaL<<endl;
02015           Wtrack = fabs((thickness/pitch)*tanalpha - (thickness/pitch)*tanalphaL);
02016           //       fabs((thickness/pitch)*tanalpha - (thickness/pitch)*tanalphaL);
02017           //cout<<"Valid2:Wtrack = "<<Wtrack<<endl;
02018           float SLorentz = 0.5*(thickness/pitch)*tanalphaL;
02019           //int nstrips = topol.nstrips(); 
02020           int Sp = int(position.x()/pitch+SLorentz+0.5*Wtrack);
02021           int Sm = int(position.x()/pitch+SLorentz-0.5*Wtrack);
02022           Wexp = 1+Sp-Sm;
02023 
02024           clusiz=0;
02025           totcharge=0;
02026           clusiz = cluster->amplitudes().size();
02027           //cout<<"cluster->firstStrip() = "<<cluster->firstStrip()<<endl;
02028           const std::vector<uint8_t> amplitudes=cluster->amplitudes();
02029           for(size_t ia=0; ia<amplitudes.size();ia++){
02030             totcharge+=amplitudes[ia];
02031           }
02032           rechitrphix = position.x();
02033           rechitrphiy = position.y();
02034           rechitrphiz = position.z();
02035           rechitrphierrx = error.xx();
02036           rechitrphierrxLF = error.xx();
02037           rechitrphierrxMF = Merror.uu();
02038           //cout<<"rechitrphierrxMF simple hit= "<<sqrt(rechitrphierrxMF)<<endl;
02039           clusizrphi = clusiz;
02040           //cout<<"clusizrphi = "<<clusiz<<endl;
02041           cluchgrphi = totcharge;
02042 
02043           //Association of the rechit to the simhit
02044           mindist = 999999;
02045           matched.clear();  
02046           matched = associate.associateHit(*hit2d);
02047           if(!matched.empty()){
02048             //            cout << "\t\t\tmatched  " << matched.size() << endl;
02049             for(vector<PSimHit>::const_iterator m=matched.begin(); m<matched.end(); m++){
02050               dist = abs((hit2d)->localPosition().x() - (*m).localPosition().x());
02051               if(dist<mindist){
02052                 mindist = dist;
02053                 closest = (*m);
02054               }
02055               rechitrphiresLF = rechitrphix - closest.localPosition().x();
02056               rechitrphiresMF = Mposition.x() - (topol.measurementPosition(closest.localPosition())).x();
02057               rechitrphipullLF = (thit->localPosition().x() - (closest).localPosition().x())/sqrt(error.xx());
02058               rechitrphipullMF = rechitrphiresMF/sqrt(rechitrphierrxMF);
02059             }
02060           }
02061           rechitrphitrackangle = anglealpha;
02062           rechitrphitrackanglebeta = anglebeta;
02063           rechitrphitrackwidth = Wtrack;
02064           rechitrphiexpectedwidth = Wexp;
02065 
02066           clusterWidth = clusiz;
02067           unsigned int iopt;
02068           if (clusterWidth > Wexp + 2) {
02069             iopt = 1;
02070           } else if (Wexp == 1) {
02071             iopt = 2;
02072           } else if (clusterWidth <= Wexp) {
02073             iopt = 3;
02074           } else {
02075             iopt = 4;
02076           }
02077           rechitrphicategory = iopt;
02078           
02079 //        if (rechitrphiexpectedwidth == 1 && clusterWidth == 3) {
02080 //        //if ( clusterWidth == 3) {
02081 //          cout<<"TRUE"<<endl;
02082 //          cout<<"TestClus2:Position SH = "<<(closest).localPosition().x()<<" , "<<(topol.measurementPosition(closest.localPosition())).x()<<endl;
02083 //          cout<<"TestClus2:Position RH = "<<thit->localPosition().x()<<" ,"<<Mposition.x()<<endl;
02084 //          cout<<"TestClus2:residue = "<<rechitrphiresMF<<endl;
02085 //          short firstStrip = cluster->firstStrip();
02086 //          short lastStrip = firstStrip + clusterWidth - 1;
02087 //          cout<<"TestClus2:firstStrip = "<<firstStrip<<endl;
02088 //          cout<<"TestClus2:lastStrip = "<<lastStrip<<endl;
02089 //          cout<<"TestClus2:detid = "<<detid.subdetId()<<endl;
02090 //          for(size_t ia=0; ia<amplitudes.size();ia++){
02091 //            cout<<"ia, TestClus2:charge= "<<ia<<" , "<<amplitudes[ia]<<endl;
02092 //          }
02093 //          cout<<"TestClus2:Trackwidth = "<<Wtrack<<endl;
02094 //        }
02095           
02096         
02097           //cout<<"rechitrphicategory = "<<rechitrphicategory<<endl;
02098 
02099           //      if ((detid.subdetId() == int(StripSubdetector::TID)) || (detid.subdetId() == int(StripSubdetector::TEC))) {
02100             //if ((detid.subdetId() == int(StripSubdetector::TIB))) {
02101            
02102 //          if (clusterWidth ==2 && Wexp == 1 && Wtrack<0.1) {
02103 //            cout<<"TestClus:begin"<<endl;
02104 //            LocalVector  drift2 = drift * fabs(thickness/drift.z());       
02105 //            LocalPoint result2=LocalPoint(position.x()-drift2.x()/2,position.y()-drift2.y()/2,0);
02106 //            MeasurementPoint mpoint=topol.measurementPosition(result2);
02107 //            cout<<"TestClus:Position SH = "<<(closest).localPosition().x()<<" , "<<(topol.measurementPosition(closest.localPosition())).x()<<endl;
02108 //            cout<<"TestClus:Position RH = "<<thit->localPosition().x()<<" ,"<<Mposition.x()<<endl;
02109 //            cout<<"TestClus:Position RH no drift= "<<thit->localPosition().x() - drift2.x()/2<<" , "<<mpoint.x()<<endl;
02110 //            cout<<"TestClus:Drift= "<<drift.x()<<endl;
02111 //            cout<<"TestClus:residue = "<<rechitrphiresMF<<endl;
02112 //            for(size_t ia=0; ia<amplitudes.size();ia++){
02113 //              cout<<"ia, TestClus:charge= "<<ia<<" , "<<amplitudes[ia]<<endl;
02114 //            }
02115 //            cout<<"TestClus:Trackwidth = "<<Wtrack<<endl;
02116 //            short firstStrip = cluster->firstStrip();
02117 //            short lastStrip = firstStrip + clusterWidth - 1;
02118 //            cout<<"TestClus:firstStrip = "<<firstStrip<<endl;
02119 //            cout<<"TestClus:lastStrip = "<<lastStrip<<endl;
02120 //            cout<<"TestClus:detid = "<<detid.subdetId()<<endl;
02121 //            int nstrips = topol.nstrips(); 
02122 //            cout<<"TestClus:nstrips = "<<nstrips<<endl;
02123 //            cout<<"TestClus:anglealpha = "<<anglealpha<<endl;
02124 //            cout<<"TestClus:end"<<endl;
02125 //            positionshx = (topol.measurementPosition(closest.localPosition())).x();
02126 
02127 //            if ((positionshx - int(positionshx)) > 0.5) {
02128 //              if (lastStrip > int(positionshx)) secondstrip = 1;
02129 //              if (lastStrip = int(positionshx)) secondstrip = -1;
02130 //            }
02131 //            if ((positionshx - int(positionshx)) < 0.5) {
02132 //              if (lastStrip > int(positionshx)) secondstrip = -1;
02133 //              if (lastStrip = int(positionshx)) secondstrip = 1;
02134 //            }
02135 
02136 //          }
02137 
02138             //}
02139           
02140 //        cout<<"int() = "<<int((topol.measurementPosition(closest.localPosition())).x())<<endl;
02141 //        diff = int((topol.measurementPosition(closest.localPosition())).x()) -topol.measurementPosition(closest.localPosition()).x();
02142 //        cout<<"diff = "<<diff<<endl;
02143 //        if (clusterWidth ==2 && Wexp == 1 && Wtrack<1) {
02144 //          if ((abs(1 + diff) <0.2) || (abs(diff) <0.2)) {
02145 //            //              isrechitrphi = 0;
02146 //            cout<<"vire"<<endl;
02147 //          }
02148 //        }
02149 //        positionshx = (topol.measurementPosition(closest.localPosition())).x();
02150 
02151 
02152         }
02153 
02154         if (StripSubdet.stereo() == 1){
02155 
02156           //cout<<"simple hit stereo"<<endl;
02157           isrechitsas = 1;
02158 
02159           const GeomDetUnit *  det = tracker.idToDetUnit(detid2);
02160           const StripGeomDetUnit * stripdet=(const StripGeomDetUnit*)(det);
02161           const StripTopology &topol=(const StripTopology&)stripdet->topology();
02162 
02163           float anglealpha = atan(trackdirection.x()/trackdirection.z())*180/TMath::Pi();
02164           float anglebeta = atan(trackdirection.y()/trackdirection.z())*180/TMath::Pi();
02165 
02166           SiStripRecHit2D::ClusterRef cluster=hit2d->cluster();
02167 
02168 
02169           position = thit->localPosition();
02170           error = thit->localPositionError();
02171           Mposition = topol.measurementPosition(position);
02172           Merror = topol.measurementError(position,error);
02173 
02174           //      LocalVector drift= driftDirection(stripdet);
02175           LocalVector drift = stripcpe->driftDirection(stripdet);
02176           float thickness=stripdet->surface().bounds().thickness();
02177           rechitsasthickness = thickness;
02178           //cout<<"thickness = "<<thickness<<endl;
02179           float pitch = topol.localPitch(position);
02180           //cout<<"Valid:pitch = "<<pitch<<endl;
02181           float tanalpha = tan(anglealpha/57.3);
02182           //cout<<"Valid:tanalpha = "<<tanalpha<<endl;
02183           float tanalphaL = drift.x()/drift.z();
02184           //cout<<"Validstereo:drift.x() = "<<drift.x()<<endl;
02185           //cout<<"Valid:drift.z() = "<<drift.z()<<endl;
02186           //cout<<"Valid:tanalphaL = "<<tanalphaL<<endl;
02187           Wtrack = fabs((thickness/pitch)*tanalpha - (thickness/pitch)*tanalphaL);
02188           //cout<<"Valid:Wtrack = "<<Wtrack<<endl;
02189           float SLorentz = 0.5*(thickness/pitch)*tanalphaL;
02190           //int nstrips = topol.nstrips(); 
02191           int Sp = int(position.x()/pitch+SLorentz+0.5*Wtrack);
02192           int Sm = int(position.x()/pitch+SLorentz-0.5*Wtrack);
02193           Wexp = 1+Sp-Sm;
02194 
02195           clusiz=0;
02196           totcharge=0;
02197           clusiz = cluster->amplitudes().size();
02198           const std::vector<uint8_t> amplitudes=cluster->amplitudes();
02199           for(size_t ia=0; ia<amplitudes.size();ia++){
02200             totcharge+=amplitudes[ia];
02201           }
02202           rechitsasx = position.x();
02203           rechitsasy = position.y();
02204           rechitsasz = position.z();
02205           rechitsaserrxLF = error.xx();
02206           //cout<<"rechitsaserrxLF = "<<rechitsaserrxLF<<endl;
02207           rechitsaserrxMF = Merror.uu();
02208           //cout<<"rechitsaserrxMF simple hit= "<<sqrt(rechitsaserrxMF)<<endl;
02209           clusizsas = clusiz;
02210           cluchgsas = totcharge;
02211 
02212           //Association of the rechit to the simhit
02213           mindist = 999999;
02214           matched.clear();  
02215           matched = associate.associateHit(*hit2d);
02216           if(!matched.empty()){
02217             //            cout << "\t\t\tmatched  " << matched.size() << endl;
02218             for(vector<PSimHit>::const_iterator m=matched.begin(); m<matched.end(); m++){
02219               dist = abs((hit2d)->localPosition().x() - (*m).localPosition().x());
02220               if(dist<mindist){
02221                 mindist = dist;
02222                 closest = (*m);
02223               }
02224 
02225               rechitsasresLF = rechitsasx - closest.localPosition().x();
02226               rechitsasresMF = Mposition.x() - (topol.measurementPosition(closest.localPosition())).x();
02227               rechitsaspullLF = (thit->localPosition().x() - (closest).localPosition().x())/sqrt(error.xx());
02228               rechitsaspullMF = rechitsasresMF/sqrt(rechitsaserrxMF);
02229 
02230             }
02231           }
02232           rechitsastrackangle = anglealpha;
02233           rechitsastrackanglebeta = anglebeta;
02234           rechitsastrackwidth = Wtrack;
02235           rechitsasexpectedwidth = Wexp;
02236 
02237           clusterWidth = clusiz;
02238           unsigned int iopt;
02239           if (clusterWidth > Wexp + 2) {
02240             iopt = 1;
02241           } else if (Wexp == 1) {
02242             iopt = 2;
02243           } else if (clusterWidth <= Wexp) {
02244             iopt = 3;
02245           } else {
02246             iopt = 4;
02247           }
02248           rechitsascategory = iopt;
02249         }
02250         //isrechitsas = 0;
02251 
02252       }
02253 
02254       //Filling Histograms for simple hits
02255       //cout<<"isrechitrphi,isrechitsas = "<<isrechitrphi<<","<<isrechitsas<<endl;
02256 
02257       float CutThickness=0.04;
02258       CutThickness=0.;
02259 
02260       if(isrechitrphi>0 || isrechitsas>0){
02261 
02262         
02263         if (isrechitrphi>0) {
02264           
02265           //cout<<"rechitrphitrackwidth,rechitrphipullMF = "<<rechitrphitrackwidth<<" "<<rechitrphipullMF<<endl;
02266           /*
02267           if (rechitrphithickness > CutThickness)
02268             {
02269                       PullvsTrackwidth->Fill(rechitrphitrackwidth,rechitrphipullMF);
02270                       
02271               if (clusizrphi ==2 && rechitrphiexpectedwidth == 1 && rechitrphitrackwidth<0.1) {
02272                 //Diff->Fill(-diff);
02273 
02274                 //              if ((detid.subdetId() == int(StripSubdetector::TID)) || (detid.subdetId() == int(StripSubdetector::TEC))) {
02275                 //SecondStrip->Fill(secondstrip);
02276                 //              }
02277               }
02278               //              Diff->Fill(-diff);
02279               
02280               //PositionSHx->Fill(positionshx);
02281 
02282               //    ErrxMF->Fill(sqrt(rechitrphierrxMF));
02283               //cout<<"ICI1:rechitrphitrackwidth = "<<rechitrphitrackwidth<<endl;
02284               //ErrxMFvsTrackwidth->Fill(rechitrphitrackwidth,sqrt(rechitrphierrxMF));
02285               ResMFvsTrackwidth->Fill(rechitrphitrackwidth,rechitrphiresMF);
02286               
02287               PullvsClusterwidth->Fill(clusizrphi,rechitrphipullMF);
02288               PullvsExpectedwidth->Fill(rechitrphiexpectedwidth,rechitrphipullMF);
02289               PullvsTrackangle->Fill(rechitrphitrackangle,rechitrphipullMF);
02290               PullvsTrackanglebeta->Fill(rechitrphitrackanglebeta,rechitrphipullMF);
02291              
02292             }
02293           */
02294           
02295           meCategory->Fill(rechitrphicategory);
02296           meTrackwidth->Fill(rechitrphitrackwidth);
02297           meExpectedwidth->Fill(rechitrphiexpectedwidth);
02298           meClusterwidth->Fill(clusizrphi);
02299           meTrackanglealpha->Fill(rechitrphitrackangle);
02300           meTrackanglebeta->Fill(rechitrphitrackanglebeta);
02301 
02302           meErrxMFAngleProfile->Fill(rechitrphitrackangle,sqrt(rechitrphierrxMF));
02303           meErrxMFTrackwidthProfile->Fill(rechitrphitrackwidth,sqrt(rechitrphierrxMF));
02304 
02305           if (clusizrphi == 1) {
02306             meErrxMFTrackwidthProfileWClus1->Fill(rechitrphitrackwidth,sqrt(rechitrphierrxMF));
02307             meResMFTrackwidthProfileWClus1->Fill(rechitrphitrackwidth,rechitrphiresMF);
02308             if (rechitrphithickness > CutThickness)
02309               {
02310                 //if ((detid.subdetId() == int(StripSubdetector::TIB)) || (detid.subdetId() == int(StripSubdetector::TOB)))
02311                 //{
02312                 /*
02313                 ResMFvsTrackwidthWClus1->Fill(rechitrphitrackwidth,rechitrphiresMF);
02314                     if (rechitrphiexpectedwidth==1) ResMFvsTrackwidthWClus1Wexp1->Fill(rechitrphitrackwidth,rechitrphiresMF);
02315                     if (rechitrphiexpectedwidth==2) ResMFvsTrackwidthWClus1Wexp2->Fill(rechitrphitrackwidth,rechitrphiresMF);
02316                     if (rechitrphiexpectedwidth==3) ResMFvsTrackwidthWClus1Wexp3->Fill(rechitrphitrackwidth,rechitrphiresMF);
02317                     if (rechitrphiexpectedwidth==4) ResMFvsTrackwidthWClus1Wexp4->Fill(rechitrphitrackwidth,rechitrphiresMF);
02318                     ErrxMFvsTrackwidthWClus1->Fill(rechitrphitrackwidth,sqrt(rechitrphierrxMF));
02319                 */
02320                     //}
02321               }
02322           }
02323           if (clusizrphi == 2) {
02324             meErrxMFTrackwidthProfileWClus2->Fill(rechitrphitrackwidth,sqrt(rechitrphierrxMF));
02325             meResMFTrackwidthProfileWClus2->Fill(rechitrphitrackwidth,rechitrphiresMF);
02326             meResMFTrackwidthProfileWClus21->Fill(rechitrphitrackwidth,rechitrphiresMF);
02327             meResMFTrackwidthProfileWClus22->Fill(rechitrphitrackwidth,rechitrphiresMF);
02328             meResMFTrackwidthProfileWClus23->Fill(rechitrphitrackwidth,rechitrphiresMF);
02329             if (rechitrphithickness > CutThickness)
02330               {
02331                 //              if ((detid.subdetId() == int(StripSubdetector::TIB)) || (detid.subdetId() == int(StripSubdetector::TOB)))
02332                 //{
02333                 if ((detid.subdetId() == int(StripSubdetector::TID)) || (detid.subdetId() == int(StripSubdetector::TEC))){
02334                   /*    ResMFvsTrackwidthWClus2->Fill(rechitrphitrackwidth,rechitrphiresMF);
02335                 if (rechitrphiexpectedwidth==1) ResMFvsTrackwidthWClus2Wexp1->Fill(rechitrphitrackwidth,rechitrphiresMF);
02336                 if (rechitrphiexpectedwidth==2) ResMFvsTrackwidthWClus2Wexp2->Fill(rechitrphitrackwidth,rechitrphiresMF);
02337                 if (rechitrphiexpectedwidth==3) ResMFvsTrackwidthWClus2Wexp3->Fill(rechitrphitrackwidth,rechitrphiresMF);
02338                 if (rechitrphiexpectedwidth==4) ResMFvsTrackwidthWClus2Wexp4->Fill(rechitrphitrackwidth,rechitrphiresMF);*/
02339                 }
02340                 //          meResMFTrackwidthProfileWClus22->Fill(rechitrphitrackwidth,rechitrphiresMF);
02341                 //cout<<"ICI2:rechitrphitrackwidth = "<<rechitrphitrackwidth<<endl;
02342 
02343                 //ErrxMFvsTrackwidthWClus2->Fill(rechitrphitrackwidth,sqrt(rechitrphierrxMF));
02344                     // }
02345               }
02346           }
02347           if (clusizrphi == 3) {
02348             meErrxMFTrackwidthProfileWClus3->Fill(rechitrphitrackwidth,sqrt(rechitrphierrxMF));
02349             meResMFTrackwidthProfileWClus3->Fill(rechitrphitrackwidth,rechitrphiresMF);
02350             if (rechitrphithickness > CutThickness)
02351               {
02352                 //if ((detid.subdetId() == int(StripSubdetector::TIB)) || (detid.subdetId() == int(StripSubdetector::TOB)))
02353                 //{
02354                 /*
02355                 ResMFvsTrackwidthWClus3->Fill(rechitrphitrackwidth,rechitrphiresMF);
02356                 if (rechitrphiexpectedwidth==1) ResMFvsTrackwidthWClus3Wexp1->Fill(rechitrphitrackwidth,rechitrphiresMF);
02357                 if (rechitrphiexpectedwidth==2) ResMFvsTrackwidthWClus3Wexp2->Fill(rechitrphitrackwidth,rechitrphiresMF);
02358                 if (rechitrphiexpectedwidth==3) ResMFvsTrackwidthWClus3Wexp3->Fill(rechitrphitrackwidth,rechitrphiresMF);
02359                 if (rechitrphiexpectedwidth==4) ResMFvsTrackwidthWClus3Wexp4->Fill(rechitrphitrackwidth,rechitrphiresMF);
02360                 ErrxMFvsTrackwidthWClus3->Fill(rechitrphitrackwidth,sqrt(rechitrphierrxMF));
02361                 */
02362                 //  }
02363               }
02364           }
02365           if (clusizrphi == 4) {
02366             meErrxMFTrackwidthProfileWClus4->Fill(rechitrphitrackwidth,sqrt(rechitrphierrxMF));
02367             meResMFTrackwidthProfileWClus4->Fill(rechitrphitrackwidth,rechitrphiresMF);
02368             if (rechitrphithickness > CutThickness)
02369               {
02370                 //if ((detid.subdetId() == int(StripSubdetector::TIB)) || (detid.subdetId() == int(StripSubdetector::TOB)))
02371                 //{
02372                 /*      ResMFvsTrackwidthWClus4->Fill(rechitrphitrackwidth,rechitrphiresMF);
02373                 if (rechitrphiexpectedwidth==1) ResMFvsTrackwidthWClus4Wexp1->Fill(rechitrphitrackwidth,rechitrphiresMF);
02374                 if (rechitrphiexpectedwidth==2) ResMFvsTrackwidthWClus4Wexp2->Fill(rechitrphitrackwidth,rechitrphiresMF);
02375                 if (rechitrphiexpectedwidth==3) ResMFvsTrackwidthWClus4Wexp3->Fill(rechitrphitrackwidth,rechitrphiresMF);
02376                 if (rechitrphiexpectedwidth==4) ResMFvsTrackwidthWClus4Wexp4->Fill(rechitrphitrackwidth,rechitrphiresMF);
02377                 ErrxMFvsTrackwidthWClus4->Fill(rechitrphitrackwidth,sqrt(rechitrphierrxMF));*/
02378                     //}
02379               }
02380           }
02381           
02382           if (rechitrphicategory == 1) {
02383             meErrxMFTrackwidthProfileCategory1->Fill(rechitrphitrackwidth,sqrt(rechitrphierrxMF));
02384             meErrxMFClusterwidthProfileCategory1->Fill(clusizrphi,sqrt(rechitrphierrxMF));
02385           }
02386           if (rechitrphicategory == 2) {
02387             meErrxMFTrackwidthProfileCategory2->Fill(rechitrphitrackwidth,sqrt(rechitrphierrxMF));
02388             //ResMFvsTrackwidthCategory2->Fill(rechitrphitrackwidth,rechitrphiresMF);
02389             //  ErrxMFvsTrackwidthCategory2->Fill(rechitrphitrackwidth,sqrt(rechitrphierrxMF));
02390           }
02391           if (rechitrphicategory == 3) {
02392             meErrxMFTrackwidthProfileCategory3->Fill(rechitrphitrackwidth,sqrt(rechitrphierrxMF));
02393             //ResMFvsTrackwidthCategory3->Fill(rechitrphitrackwidth,rechitrphiresMF);
02394             //ErrxMFvsTrackwidthCategory3->Fill(rechitrphitrackwidth,sqrt(rechitrphierrxMF));
02395           }
02396           if (rechitrphicategory == 4) {
02397             meErrxMFTrackwidthProfileCategory4->Fill(rechitrphitrackwidth,sqrt(rechitrphierrxMF));
02398             //ResMFvsTrackwidthCategory4->Fill(rechitrphitrackwidth,rechitrphiresMF);
02399             //ErrxMFvsTrackwidthCategory4->Fill(rechitrphitrackwidth,sqrt(rechitrphierrxMF));
02400           }
02401           //const unsigned int NBINS = meErrxMFTrackwidthProfile->getNbinsX();
02402           //cout<<"NBINS2 = "<<NBINS<<endl;
02403           
02404           meErrxMF->Fill(sqrt(rechitrphierrxMF));
02405           //const unsigned int NBINS3 = meErrxMF->getNbinsX();
02406           //cout<<"NBINS3 = "<<NBINS<<endl;
02407           meErrxLF->Fill(sqrt(rechitrphierrxLF));
02408           meResMF->Fill(rechitrphiresMF);
02409           meResLF->Fill(rechitrphiresLF);
02410           mePullMF->Fill(rechitrphipullMF);
02411           mePullLF->Fill(rechitrphipullLF);
02412           
02413         }
02414 
02415         if (isrechitsas>0) {
02416           
02417           if (rechitsasthickness > CutThickness)
02418             {
02419               /*
02420                       PullvsTrackwidth->Fill(rechitsastrackwidth,rechitsaspullMF);
02421                       //cout<<"rechitsaserrxMF"<<rechitsaserrxMF<<endl;
02422                       // ErrxMF->Fill(sqrt(rechitsaserrxMF));
02423               ErrxMFvsTrackwidth->Fill(rechitsastrackwidth,sqrt(rechitsaserrxMF));
02424               ResMFvsTrackwidth->Fill(rechitsastrackwidth,rechitsasresMF);
02425 
02426               
02427               PullvsClusterwidth->Fill(clusizsas,rechitsaspullMF);
02428               PullvsExpectedwidth->Fill(rechitsasexpectedwidth,rechitsaspullMF);
02429               PullvsTrackangle->Fill(rechitsastrackangle,rechitsaspullMF);
02430               PullvsTrackanglebeta->Fill(rechitsastrackanglebeta,rechitsaspullMF);
02431               */
02432             }
02433           
02434           
02435           meCategory->Fill(rechitsascategory);
02436           meTrackwidth->Fill(rechitsastrackwidth);
02437           meExpectedwidth->Fill(rechitsasexpectedwidth);
02438           meClusterwidth->Fill(clusizsas);
02439           meTrackanglealpha->Fill(rechitsastrackangle);
02440           meTrackanglebeta->Fill(rechitsastrackanglebeta);
02441           
02442           meErrxMFAngleProfile->Fill(rechitsastrackangle,sqrt(rechitsaserrxMF));
02443           meErrxMFTrackwidthProfile->Fill(rechitsastrackwidth,sqrt(rechitsaserrxMF));
02444           
02445           if (clusizsas == 1) {
02446             meErrxMFTrackwidthProfileWClus1->Fill(rechitsastrackwidth,sqrt(rechitsaserrxMF));
02447             meResMFTrackwidthProfileWClus1->Fill(rechitsastrackwidth,rechitsasresMF);
02448             if (rechitsasthickness > CutThickness)
02449               {
02450                 //if ((detid.subdetId() == int(StripSubdetector::TIB)) || (detid.subdetId() == int(StripSubdetector::TOB)))
02451                 //{
02452                 /*  
02453                 ResMFvsTrackwidthWClus1->Fill(rechitsastrackwidth,rechitsasresMF);
02454                 if (rechitsasexpectedwidth==1) ResMFvsTrackwidthWClus1Wexp1->Fill(rechitsastrackwidth,rechitsasresMF);
02455                 if (rechitsasexpectedwidth==2) ResMFvsTrackwidthWClus1Wexp2->Fill(rechitsastrackwidth,rechitsasresMF);
02456                 if (rechitsasexpectedwidth==3) ResMFvsTrackwidthWClus1Wexp3->Fill(rechitsastrackwidth,rechitsasresMF);
02457                 if (rechitsasexpectedwidth==4) ResMFvsTrackwidthWClus1Wexp4->Fill(rechitsastrackwidth,rechitsasresMF);
02458                 ErrxMFvsTrackwidthWClus1->Fill(rechitsastrackwidth,sqrt(rechitsaserrxMF));
02459                 */
02460                        //}
02461               }
02462           }
02463           
02464           if (clusizsas == 2) {
02465             meErrxMFTrackwidthProfileWClus2->Fill(rechitsastrackwidth,sqrt(rechitsaserrxMF));
02466             meResMFTrackwidthProfileWClus2->Fill(rechitsastrackwidth,rechitsasresMF);
02467             if (rechitsasthickness > CutThickness)
02468               {
02469                 //              if ((detid.subdetId() == int(StripSubdetector::TIB)) || (detid.subdetId() == int(StripSubdetector::TOB)))
02470                 //{
02471                 /*
02472                 ResMFvsTrackwidthWClus2->Fill(rechitsastrackwidth,rechitsasresMF);
02473                 if (rechitsasexpectedwidth==1) ResMFvsTrackwidthWClus2Wexp1->Fill(rechitsastrackwidth,rechitsasresMF);
02474                 if (rechitsasexpectedwidth==2) ResMFvsTrackwidthWClus2Wexp2->Fill(rechitsastrackwidth,rechitsasresMF);
02475                 if (rechitsasexpectedwidth==3) ResMFvsTrackwidthWClus2Wexp3->Fill(rechitsastrackwidth,rechitsasresMF);
02476                 if (rechitsasexpectedwidth==4) ResMFvsTrackwidthWClus2Wexp4->Fill(rechitsastrackwidth,rechitsasresMF);
02477                 ErrxMFvsTrackwidthWClus2->Fill(rechitsastrackwidth,sqrt(rechitsaserrxMF));
02478                 */
02479                     //}
02480               }
02481           }
02482           if (clusizsas == 3) {
02483             meErrxMFTrackwidthProfileWClus3->Fill(rechitsastrackwidth,sqrt(rechitsaserrxMF));
02484             meResMFTrackwidthProfileWClus3->Fill(rechitsastrackwidth,rechitsasresMF);
02485             if (rechitsasthickness > CutThickness)
02486               {
02487                 //if ((detid.subdetId() == int(StripSubdetector::TIB)) || (detid.subdetId() == int(StripSubdetector::TOB)))
02488                 // {
02489                 /*
02490                 ResMFvsTrackwidthWClus3->Fill(rechitsastrackwidth,rechitsasresMF);
02491                 if (rechitsasexpectedwidth==1) ResMFvsTrackwidthWClus3Wexp1->Fill(rechitsastrackwidth,rechitsasresMF);
02492                 if (rechitsasexpectedwidth==2) ResMFvsTrackwidthWClus3Wexp2->Fill(rechitsastrackwidth,rechitsasresMF);
02493                 if (rechitsasexpectedwidth==3) ResMFvsTrackwidthWClus3Wexp3->Fill(rechitsastrackwidth,rechitsasresMF);
02494                 if (rechitsasexpectedwidth==4) ResMFvsTrackwidthWClus3Wexp4->Fill(rechitsastrackwidth,rechitsasresMF);
02495                 ErrxMFvsTrackwidthWClus3->Fill(rechitsastrackwidth,sqrt(rechitsaserrxMF));
02496                 */
02497                 //}
02498               }
02499           }
02500           if (clusizsas == 4) {
02501             meErrxMFTrackwidthProfileWClus4->Fill(rechitsastrackwidth,sqrt(rechitsaserrxMF));
02502             meResMFTrackwidthProfileWClus4->Fill(rechitsastrackwidth,rechitsasresMF);
02503             if (rechitsasthickness > CutThickness)
02504               {
02505                 //if ((detid.subdetId() == int(StripSubdetector::TIB)) || (detid.subdetId() == int(StripSubdetector::TOB)))
02506                 //{
02507                 /*
02508                 ResMFvsTrackwidthWClus4->Fill(rechitsastrackwidth,rechitsasresMF);
02509                 if (rechitsasexpectedwidth==1) ResMFvsTrackwidthWClus4Wexp1->Fill(rechitsastrackwidth,rechitsasresMF);
02510                 if (rechitsasexpectedwidth==2) ResMFvsTrackwidthWClus4Wexp2->Fill(rechitsastrackwidth,rechitsasresMF);
02511                 if (rechitsasexpectedwidth==3) ResMFvsTrackwidthWClus4Wexp3->Fill(rechitsastrackwidth,rechitsasresMF);
02512                 if (rechitsasexpectedwidth==4) ResMFvsTrackwidthWClus4Wexp4->Fill(rechitsastrackwidth,rechitsasresMF);
02513                 ErrxMFvsTrackwidthWClus4->Fill(rechitsastrackwidth,sqrt(rechitsaserrxMF));
02514                 */
02515                     // }
02516               }
02517           }
02518           if (rechitsascategory == 1) {
02519             meErrxMFTrackwidthProfileCategory1->Fill(rechitsastrackwidth,sqrt(rechitsaserrxMF));
02520             meErrxMFClusterwidthProfileCategory1->Fill(clusizsas,sqrt(rechitsaserrxMF));
02521           }
02522           if (rechitsascategory == 2) {
02523             meErrxMFTrackwidthProfileCategory2->Fill(rechitsastrackwidth,sqrt(rechitsaserrxMF));
02524             //ResMFvsTrackwidthCategory2->Fill(rechitsastrackwidth,rechitsasresMF);
02525             //ErrxMFvsTrackwidthCategory2->Fill(rechitsastrackwidth,sqrt(rechitsaserrxMF));
02526           }
02527           if (rechitsascategory == 3) {
02528             meErrxMFTrackwidthProfileCategory3->Fill(rechitsastrackwidth,sqrt(rechitsaserrxMF));
02529             //ResMFvsTrackwidthCategory3->Fill(rechitsastrackwidth,rechitsasresMF);
02530             //ErrxMFvsTrackwidthCategory3->Fill(rechitsastrackwidth,sqrt(rechitsaserrxMF));
02531           }
02532           if (rechitsascategory == 4) {
02533             meErrxMFTrackwidthProfileCategory4->Fill(rechitsastrackwidth,sqrt(rechitsaserrxMF));
02534             //ResMFvsTrackwidthCategory4->Fill(rechitsastrackwidth,rechitsasresMF);
02535             //ErrxMFvsTrackwidthCategory4->Fill(rechitsastrackwidth,sqrt(rechitsaserrxMF));
02536           }
02537           
02538           meErrxMF->Fill(sqrt(rechitsaserrxMF));
02539           meErrxLF->Fill(sqrt(rechitsaserrxLF));
02540           meResMF->Fill(rechitsasresMF);
02541           meResLF->Fill(rechitsasresLF);
02542           mePullMF->Fill(rechitsaspullMF);
02543           mePullLF->Fill(rechitsaspullLF);
02544            
02545         }
02546 
02547         
02548         if (detid.subdetId() == int(StripSubdetector::TIB)){
02549           TIBDetId tibid(myid);
02550           int Tibisrechitrphi    = isrechitrphi;
02551           int Tibisrechitsas     = isrechitsas;
02552           //cout<<"Tibisrechitrphi,Tibisrechitsas = "<<Tibisrechitrphi<<" "<<Tibisrechitsas<<endl;
02553           int ilay = tibid.layer() - 1; //for histogram filling
02554           //cout<<"ilay1 = "<<ilay<<endl;
02555           if(Tibisrechitrphi!=0){
02556             if (rechitrphithickness > CutThickness)
02557               {
02558                 /*PullvsTrackwidthTIB->Fill(rechitrphitrackwidth,rechitrphipullMF);
02559                 PullvsClusterwidthTIB->Fill(clusizrphi,rechitrphipullMF);
02560                 PullvsExpectedwidthTIB->Fill(rechitrphiexpectedwidth,rechitrphipullMF);
02561                 PullvsTrackangleTIB->Fill(rechitrphitrackangle,rechitrphipullMF);
02562                 PullvsTrackanglebetaTIB->Fill(rechitrphitrackanglebeta,rechitrphipullMF);*/
02563               }
02564             //cout<<"TIB:rechitrphitrackwidth,rechitrphipullMF = "<<rechitrphitrackwidth<<" "<<rechitrphipullMF<<endl;
02565             //cout<<"ilay2 = "<<ilay<<endl;
02566             //cout<<"je suis la RPHI"<<endl;
02567             meNstpRphiTIB[ilay]->Fill(clusizrphi);
02568             meAdcRphiTIB[ilay]->Fill(cluchgrphi);
02569             mePosxRphiTIB[ilay]->Fill(rechitrphix);
02570             meErrxLFRphiTIB[ilay]->Fill(sqrt(rechitrphierrxLF));
02571             meErrxMFRphiTIB[ilay]->Fill(sqrt(rechitrphierrxMF));
02572             meResLFRphiTIB[ilay]->Fill(rechitrphiresLF);
02573             meResMFRphiTIB[ilay]->Fill(rechitrphiresMF);
02574             mePullLFRphiTIB[ilay]->Fill(rechitrphipullLF);
02575             mePullMFRphiTIB[ilay]->Fill(rechitrphipullMF);
02576             meTrackangleRphiTIB[ilay]->Fill(rechitrphitrackangle);
02577             mePullTrackangleProfileRphiTIB[ilay]->Fill(rechitrphitrackangle,rechitrphipullMF);
02578             mePullTrackwidthProfileRphiTIB[ilay]->Fill(rechitrphitrackwidth,rechitrphipullMF);
02579             if (clusizrphi == 1) {
02580               meErrxMFTrackwidthProfileWclus1RphiTIB[ilay]->Fill(rechitrphitrackwidth,sqrt(rechitrphierrxMF));
02581               meResMFTrackwidthProfileWclus1RphiTIB[ilay]->Fill(rechitrphitrackwidth,rechitrphiresMF);
02582             }
02583             if (clusizrphi == 2) {
02584               meErrxMFTrackwidthProfileWclus2RphiTIB[ilay]->Fill(rechitrphitrackwidth,sqrt(rechitrphierrxMF));
02585               meResMFTrackwidthProfileWclus2RphiTIB[ilay]->Fill(rechitrphitrackwidth,rechitrphiresMF);
02586             }
02587             if (clusizrphi == 3) {
02588               meErrxMFTrackwidthProfileWclus3RphiTIB[ilay]->Fill(rechitrphitrackwidth,sqrt(rechitrphierrxMF));
02589               meResMFTrackwidthProfileWclus3RphiTIB[ilay]->Fill(rechitrphitrackwidth,rechitrphiresMF);
02590             }
02591             if (clusizrphi == 4) {
02592               meErrxMFTrackwidthProfileWclus4RphiTIB[ilay]->Fill(rechitrphitrackwidth,sqrt(rechitrphierrxMF));
02593               meResMFTrackwidthProfileWclus4RphiTIB[ilay]->Fill(rechitrphitrackwidth,rechitrphiresMF);
02594             }
02595 
02596 
02597             if (rechitrphicategory == 1) {
02598               mePullTrackwidthProfileCategory1RphiTIB[ilay]->Fill(rechitrphitrackwidth,rechitrphipullMF);
02599               meErrxMFTrackwidthProfileCategory1RphiTIB[ilay]->Fill(rechitrphitrackwidth,sqrt(rechitrphierrxMF));
02600               meErrxMFClusterwidthProfileCategory1RphiTIB[ilay]->Fill(clusizrphi,sqrt(rechitrphierrxMF));
02601             }
02602             if (rechitrphicategory == 2) {
02603               mePullTrackwidthProfileCategory2RphiTIB[ilay]->Fill(rechitrphitrackwidth,rechitrphipullMF);
02604               meErrxMFTrackwidthProfileCategory2RphiTIB[ilay]->Fill(rechitrphitrackwidth,sqrt(rechitrphierrxMF));
02605             }
02606             if (rechitrphicategory == 3) {
02607               mePullTrackwidthProfileCategory3RphiTIB[ilay]->Fill(rechitrphitrackwidth,rechitrphipullMF);
02608               meErrxMFTrackwidthProfileCategory3RphiTIB[ilay]->Fill(rechitrphitrackwidth,sqrt(rechitrphierrxMF));
02609             }
02610             if (rechitrphicategory == 4) {
02611               mePullTrackwidthProfileCategory4RphiTIB[ilay]->Fill(rechitrphitrackwidth,rechitrphipullMF);
02612               meErrxMFTrackwidthProfileCategory4RphiTIB[ilay]->Fill(rechitrphitrackwidth,sqrt(rechitrphierrxMF));
02613             }
02614             meTrackwidthRphiTIB[ilay]->Fill(rechitrphitrackwidth);
02615             meExpectedwidthRphiTIB[ilay]->Fill(rechitrphiexpectedwidth);
02616             meClusterwidthRphiTIB[ilay]->Fill(clusizrphi);
02617             meCategoryRphiTIB[ilay]->Fill(rechitrphicategory);
02618             meErrxMFTrackwidthProfileRphiTIB[ilay]->Fill(rechitrphitrackwidth,sqrt(rechitrphierrxMF));
02619             meErrxMFAngleProfileRphiTIB[ilay]->Fill(rechitrphitrackangle,sqrt(rechitrphierrxMF));
02620           }
02621           if(Tibisrechitsas!=0){
02622             if (rechitsasthickness > CutThickness)
02623               {
02624                 /*      PullvsTrackwidthTIB->Fill(rechitsastrackwidth,rechitsaspullMF);
02625                 PullvsClusterwidthTIB->Fill(clusizsas,rechitsaspullMF);
02626                 PullvsExpectedwidthTIB->Fill(rechitsasexpectedwidth,rechitsaspullMF);
02627                 PullvsTrackangleTIB->Fill(rechitsastrackangle,rechitsaspullMF);
02628                 PullvsTrackanglebetaTIB->Fill(rechitsastrackanglebeta,rechitsaspullMF);*/
02629               }
02630             meNstpSasTIB[ilay]->Fill(clusizsas);
02631             meAdcSasTIB[ilay]->Fill(cluchgsas);
02632             mePosxSasTIB[ilay]->Fill(rechitsasx);
02633             meErrxLFSasTIB[ilay]->Fill(sqrt(rechitsaserrxLF));
02634             meResLFSasTIB[ilay]->Fill(rechitsasresLF);
02635             mePullLFSasTIB[ilay]->Fill(rechitsaspullLF);
02636             meErrxMFSasTIB[ilay]->Fill(sqrt(rechitsaserrxMF));
02637             meResMFSasTIB[ilay]->Fill(rechitsasresMF);
02638             mePullMFSasTIB[ilay]->Fill(rechitsaspullMF);
02639             meTrackangleSasTIB[ilay]->Fill(rechitsastrackangle);
02640             mePullTrackangleProfileSasTIB[ilay]->Fill(rechitsastrackangle,rechitsaspullMF);
02641             mePullTrackwidthProfileSasTIB[ilay]->Fill(rechitsastrackwidth,rechitsaspullMF);
02642             if (rechitsascategory == 1) {
02643               mePullTrackwidthProfileCategory1SasTIB[ilay]->Fill(rechitsastrackwidth,rechitsaspullMF);
02644               meErrxMFTrackwidthProfileCategory1SasTIB[ilay]->Fill(rechitsastrackwidth,sqrt(rechitsaserrxMF));
02645               meErrxMFClusterwidthProfileCategory1SasTIB[ilay]->Fill(clusizsas,sqrt(rechitsaserrxMF));
02646             }
02647             if (rechitsascategory == 2) {
02648               mePullTrackwidthProfileCategory2SasTIB[ilay]->Fill(rechitsastrackwidth,rechitsaspullMF);
02649               meErrxMFTrackwidthProfileCategory2SasTIB[ilay]->Fill(rechitsastrackwidth,sqrt(rechitsaserrxMF));
02650             }
02651             if (rechitsascategory == 3) {
02652               mePullTrackwidthProfileCategory3SasTIB[ilay]->Fill(rechitsastrackwidth,rechitsaspullMF);
02653               meErrxMFTrackwidthProfileCategory3SasTIB[ilay]->Fill(rechitsastrackwidth,sqrt(rechitsaserrxMF));
02654             }
02655             if (rechitsascategory == 4) {
02656               mePullTrackwidthProfileCategory4SasTIB[ilay]->Fill(rechitsastrackwidth,rechitsaspullMF);
02657               meErrxMFTrackwidthProfileCategory4SasTIB[ilay]->Fill(rechitsastrackwidth,sqrt(rechitsaserrxMF));
02658             }
02659             meTrackwidthSasTIB[ilay]->Fill(rechitsastrackwidth);
02660             meExpectedwidthSasTIB[ilay]->Fill(rechitsasexpectedwidth);
02661             meClusterwidthSasTIB[ilay]->Fill(clusizsas);
02662             meCategorySasTIB[ilay]->Fill(rechitsascategory);
02663             meErrxMFTrackwidthProfileSasTIB[ilay]->Fill(rechitsastrackwidth,sqrt(rechitsaserrxMF));
02664             meErrxMFAngleProfileSasTIB[ilay]->Fill(rechitsastrackangle,rechitsaserrxMF);
02665           }
02666         }
02667         
02668         if (detid.subdetId() == int(StripSubdetector::TOB)){
02669           TOBDetId tobid(myid);
02670           int Tobisrechitrphi    = isrechitrphi;
02671           int Tobisrechitsas     = isrechitsas;
02672           int ilay = tobid.layer() - 1; //for histogram filling
02673           if(Tobisrechitrphi!=0){
02674             if (rechitrphithickness > CutThickness)
02675               {
02676                 /*PullvsTrackwidthTOB->Fill(rechitrphitrackwidth,rechitrphipullMF);
02677                 PullvsClusterwidthTOB->Fill(clusizrphi,rechitrphipullMF);
02678                 PullvsExpectedwidthTOB->Fill(rechitrphiexpectedwidth,rechitrphipullMF);
02679                 PullvsTrackangleTOB->Fill(rechitrphitrackangle,rechitrphipullMF);
02680                 PullvsTrackanglebetaTOB->Fill(rechitrphitrackanglebeta,rechitrphipullMF);*/
02681               }
02682             //cout<<"TOB:rechitrphitrackwidth,rechitrphipullMF = "<<rechitrphitrackwidth<<" "<<rechitrphipullMF<<endl;
02683             meNstpRphiTOB[ilay]->Fill(clusizrphi);
02684             meAdcRphiTOB[ilay]->Fill(cluchgrphi);
02685             mePosxRphiTOB[ilay]->Fill(rechitrphix);
02686             meErrxLFRphiTOB[ilay]->Fill(sqrt(rechitrphierrxLF));
02687             meResLFRphiTOB[ilay]->Fill(rechitrphiresLF);
02688             mePullLFRphiTOB[ilay]->Fill(rechitrphipullLF);
02689             meErrxMFRphiTOB[ilay]->Fill(sqrt(rechitrphierrxMF));
02690             meResMFRphiTOB[ilay]->Fill(rechitrphiresMF);
02691             mePullMFRphiTOB[ilay]->Fill(rechitrphipullMF);
02692             meTrackangleRphiTOB[ilay]->Fill(rechitrphitrackangle);
02693             mePullTrackangleProfileRphiTOB[ilay]->Fill(rechitrphitrackangle,rechitrphipullMF);
02694             mePullTrackwidthProfileRphiTOB[ilay]->Fill(rechitrphitrackwidth,rechitrphipullMF);
02695 
02696             if (clusizrphi == 1) {
02697               meErrxMFTrackwidthProfileWclus1RphiTOB[ilay]->Fill(rechitrphitrackwidth,sqrt(rechitrphierrxMF));
02698               meResMFTrackwidthProfileWclus1RphiTOB[ilay]->Fill(rechitrphitrackwidth,rechitrphiresMF);
02699             }
02700             if (clusizrphi == 2) {
02701               meErrxMFTrackwidthProfileWclus2RphiTOB[ilay]->Fill(rechitrphitrackwidth,sqrt(rechitrphierrxMF));
02702               meResMFTrackwidthProfileWclus2RphiTOB[ilay]->Fill(rechitrphitrackwidth,rechitrphiresMF);
02703             }
02704             if (clusizrphi == 3) {
02705               meErrxMFTrackwidthProfileWclus3RphiTOB[ilay]->Fill(rechitrphitrackwidth,sqrt(rechitrphierrxMF));
02706               meResMFTrackwidthProfileWclus3RphiTOB[ilay]->Fill(rechitrphitrackwidth,rechitrphiresMF);
02707             }
02708             if (clusizrphi == 4) {
02709               meErrxMFTrackwidthProfileWclus4RphiTOB[ilay]->Fill(rechitrphitrackwidth,sqrt(rechitrphierrxMF));
02710               meResMFTrackwidthProfileWclus4RphiTOB[ilay]->Fill(rechitrphitrackwidth,rechitrphiresMF);
02711             }
02712 
02713 
02714             if (rechitrphicategory == 1) {
02715               mePullTrackwidthProfileCategory1RphiTOB[ilay]->Fill(rechitrphitrackwidth,rechitrphipullMF);
02716               meErrxMFTrackwidthProfileCategory1RphiTOB[ilay]->Fill(rechitrphitrackwidth,sqrt(rechitrphierrxMF));
02717               meErrxMFClusterwidthProfileCategory1RphiTOB[ilay]->Fill(clusizrphi,sqrt(rechitrphierrxMF));
02718             }
02719             if (rechitrphicategory == 2) {
02720               mePullTrackwidthProfileCategory2RphiTOB[ilay]->Fill(rechitrphitrackwidth,rechitrphipullMF);
02721               meErrxMFTrackwidthProfileCategory2RphiTOB[ilay]->Fill(rechitrphitrackwidth,sqrt(rechitrphierrxMF));
02722             }
02723             if (rechitrphicategory == 3) {
02724               mePullTrackwidthProfileCategory3RphiTOB[ilay]->Fill(rechitrphitrackwidth,rechitrphipullMF);
02725               meErrxMFTrackwidthProfileCategory3RphiTOB[ilay]->Fill(rechitrphitrackwidth,sqrt(rechitrphierrxMF));
02726             }
02727             if (rechitrphicategory == 4) {
02728               mePullTrackwidthProfileCategory4RphiTOB[ilay]->Fill(rechitrphitrackwidth,rechitrphipullMF);
02729               meErrxMFTrackwidthProfileCategory4RphiTOB[ilay]->Fill(rechitrphitrackwidth,sqrt(rechitrphierrxMF));
02730             }
02731             meTrackwidthRphiTOB[ilay]->Fill(rechitrphitrackwidth);
02732             meExpectedwidthRphiTOB[ilay]->Fill(rechitrphiexpectedwidth);
02733             meClusterwidthRphiTOB[ilay]->Fill(clusizrphi);
02734             meCategoryRphiTOB[ilay]->Fill(rechitrphicategory);
02735             meErrxMFTrackwidthProfileRphiTOB[ilay]->Fill(rechitrphitrackwidth,sqrt(rechitrphierrxMF));
02736             meErrxMFAngleProfileRphiTOB[ilay]->Fill(rechitrphitrackangle,sqrt(rechitrphierrxMF));
02737           } 
02738           if(Tobisrechitsas!=0){
02739             if (rechitsasthickness > CutThickness)
02740               {/*
02741                 PullvsTrackwidthTOB->Fill(rechitsastrackwidth,rechitsaspullMF);
02742                 PullvsClusterwidthTOB->Fill(clusizsas,rechitsaspullMF);
02743                 PullvsExpectedwidthTOB->Fill(rechitsasexpectedwidth,rechitsaspullMF);
02744                 PullvsTrackangleTOB->Fill(rechitsastrackangle,rechitsaspullMF);
02745                 PullvsTrackanglebetaTOB->Fill(rechitsastrackanglebeta,rechitsaspullMF);
02746                */
02747               }
02748             meNstpSasTOB[ilay]->Fill(clusizsas);
02749             meAdcSasTOB[ilay]->Fill(cluchgsas);
02750             mePosxSasTOB[ilay]->Fill(rechitsasx);
02751             meErrxLFSasTOB[ilay]->Fill(sqrt(rechitsaserrxLF));
02752             meResLFSasTOB[ilay]->Fill(rechitsasresLF);
02753             mePullLFSasTOB[ilay]->Fill(rechitsaspullLF);
02754             meErrxMFSasTOB[ilay]->Fill(sqrt(rechitsaserrxMF));
02755             meResMFSasTOB[ilay]->Fill(rechitsasresMF);
02756             mePullMFSasTOB[ilay]->Fill(rechitsaspullMF);
02757             meTrackangleSasTOB[ilay]->Fill(rechitsastrackangle);
02758             mePullTrackangleProfileSasTOB[ilay]->Fill(rechitsastrackangle,rechitsaspullMF);
02759             mePullTrackwidthProfileSasTOB[ilay]->Fill(rechitsastrackwidth,rechitsaspullMF);
02760             if (rechitsascategory == 1) {
02761               mePullTrackwidthProfileCategory1SasTOB[ilay]->Fill(rechitsastrackwidth,rechitsaspullMF);
02762               meErrxMFTrackwidthProfileCategory1SasTOB[ilay]->Fill(rechitsastrackwidth,sqrt(rechitsaserrxMF));
02763               meErrxMFClusterwidthProfileCategory1SasTOB[ilay]->Fill(clusizsas,sqrt(rechitsaserrxMF));
02764             }
02765             if (rechitsascategory == 2) {
02766               mePullTrackwidthProfileCategory2SasTOB[ilay]->Fill(rechitsastrackwidth,rechitsaspullMF);
02767               meErrxMFTrackwidthProfileCategory2SasTOB[ilay]->Fill(rechitsastrackwidth,sqrt(rechitsaserrxMF));
02768             }
02769             if (rechitsascategory == 3) {
02770               mePullTrackwidthProfileCategory3SasTOB[ilay]->Fill(rechitsastrackwidth,rechitsaspullMF);
02771               meErrxMFTrackwidthProfileCategory3SasTOB[ilay]->Fill(rechitsastrackwidth,sqrt(rechitsaserrxMF));
02772             }
02773             if (rechitsascategory == 4) {
02774               mePullTrackwidthProfileCategory4SasTOB[ilay]->Fill(rechitsastrackwidth,rechitsaspullMF);
02775               meErrxMFTrackwidthProfileCategory4SasTOB[ilay]->Fill(rechitsastrackwidth,sqrt(rechitsaserrxMF));
02776             }
02777             meTrackwidthSasTOB[ilay]->Fill(rechitsastrackwidth);
02778             meExpectedwidthSasTOB[ilay]->Fill(rechitsasexpectedwidth);
02779             meClusterwidthSasTOB[ilay]->Fill(clusizsas);
02780             meCategorySasTOB[ilay]->Fill(rechitsascategory);
02781             meErrxMFTrackwidthProfileSasTOB[ilay]->Fill(rechitsastrackwidth,sqrt(rechitsaserrxMF));
02782             meErrxMFAngleProfileSasTOB[ilay]->Fill(rechitsastrackangle,rechitsaserrxMF);
02783           }
02784         }
02785         
02786         if (detid.subdetId() == int(StripSubdetector::TID)){
02787           TIDDetId tidid(myid);
02788           int Tidisrechitrphi    = isrechitrphi;
02789           int Tidisrechitsas     = isrechitsas;
02790           int ilay = tidid.ring() - 1; //for histogram filling
02791           if(Tidisrechitrphi!=0){
02792             if (rechitrphithickness > CutThickness)
02793               {
02794                 /*PullvsTrackwidthTID->Fill(rechitrphitrackwidth,rechitrphipullMF);
02795                 PullvsClusterwidthTID->Fill(clusizrphi,rechitrphipullMF);
02796                 PullvsExpectedwidthTID->Fill(rechitrphiexpectedwidth,rechitrphipullMF);
02797                 PullvsTrackangleTID->Fill(rechitrphitrackangle,rechitrphipullMF);
02798                 PullvsTrackanglebetaTID->Fill(rechitrphitrackanglebeta,rechitrphipullMF);*/
02799               }
02800             //cout<<"TID:rechitrphitrackwidth,rechitrphipullMF = "<<rechitrphitrackwidth<<" "<<rechitrphipullMF<<endl;
02801             meNstpRphiTID[ilay]->Fill(clusizrphi);
02802             meAdcRphiTID[ilay]->Fill(cluchgrphi);
02803             mePosxRphiTID[ilay]->Fill(rechitrphix);
02804             meErrxLFRphiTID[ilay]->Fill(sqrt(rechitrphierrxLF));
02805             meResLFRphiTID[ilay]->Fill(rechitrphiresLF);
02806             mePullLFRphiTID[ilay]->Fill(rechitrphipullLF);
02807             meErrxMFRphiTID[ilay]->Fill(sqrt(rechitrphierrxMF));
02808             meResMFRphiTID[ilay]->Fill(rechitrphiresMF);
02809             mePullMFRphiTID[ilay]->Fill(rechitrphipullMF);
02810             meTrackangleRphiTID[ilay]->Fill(rechitrphitrackangle);
02811             mePullTrackangleProfileRphiTID[ilay]->Fill(rechitrphitrackangle,rechitrphipullMF);
02812             mePullTrackwidthProfileRphiTID[ilay]->Fill(rechitrphitrackwidth,rechitrphipullMF);
02813             if (rechitrphicategory == 1) {
02814               mePullTrackwidthProfileCategory1RphiTID[ilay]->Fill(rechitrphitrackwidth,rechitrphipullMF);
02815               meErrxMFTrackwidthProfileCategory1RphiTID[ilay]->Fill(rechitrphitrackwidth,sqrt(rechitrphierrxMF));
02816               meErrxMFClusterwidthProfileCategory1RphiTID[ilay]->Fill(clusizrphi,sqrt(rechitrphierrxMF));
02817             }
02818             if (rechitrphicategory == 2) {
02819               mePullTrackwidthProfileCategory2RphiTID[ilay]->Fill(rechitrphitrackwidth,rechitrphipullMF);
02820               meErrxMFTrackwidthProfileCategory2RphiTID[ilay]->Fill(rechitrphitrackwidth,sqrt(rechitrphierrxMF));
02821             }
02822             if (rechitrphicategory == 3) {
02823               mePullTrackwidthProfileCategory3RphiTID[ilay]->Fill(rechitrphitrackwidth,rechitrphipullMF);
02824               meErrxMFTrackwidthProfileCategory3RphiTID[ilay]->Fill(rechitrphitrackwidth,sqrt(rechitrphierrxMF));
02825             }
02826             if (rechitrphicategory == 4) {
02827               mePullTrackwidthProfileCategory4RphiTID[ilay]->Fill(rechitrphitrackwidth,rechitrphipullMF);
02828               meErrxMFTrackwidthProfileCategory4RphiTID[ilay]->Fill(rechitrphitrackwidth,sqrt(rechitrphierrxMF));
02829             }
02830             meTrackwidthRphiTID[ilay]->Fill(rechitrphitrackwidth);
02831             meExpectedwidthRphiTID[ilay]->Fill(rechitrphiexpectedwidth);
02832             meClusterwidthRphiTID[ilay]->Fill(clusizrphi);
02833             meCategoryRphiTID[ilay]->Fill(rechitrphicategory);
02834             meErrxMFTrackwidthProfileRphiTID[ilay]->Fill(rechitrphitrackwidth,sqrt(rechitrphierrxMF));
02835             meErrxMFAngleProfileRphiTID[ilay]->Fill(rechitrphitrackangle,sqrt(rechitrphierrxMF));
02836           } 
02837           if(Tidisrechitsas!=0){
02838             if (rechitsasthickness > CutThickness)
02839               {
02840                 /*PullvsTrackwidthTID->Fill(rechitsastrackwidth,rechitsaspullMF);
02841                 PullvsClusterwidthTID->Fill(clusizsas,rechitsaspullMF);
02842                 PullvsExpectedwidthTID->Fill(rechitsasexpectedwidth,rechitsaspullMF);
02843                 PullvsTrackangleTID->Fill(rechitsastrackangle,rechitsaspullMF);
02844                 PullvsTrackanglebetaTID->Fill(rechitsastrackanglebeta,rechitsaspullMF);*/
02845               }
02846             meNstpSasTID[ilay]->Fill(clusizsas);
02847             meAdcSasTID[ilay]->Fill(cluchgsas);
02848             mePosxSasTID[ilay]->Fill(rechitsasx);
02849             meErrxLFSasTID[ilay]->Fill(sqrt(rechitsaserrxLF));
02850             meResLFSasTID[ilay]->Fill(rechitsasresLF);
02851             mePullLFSasTID[ilay]->Fill(rechitsaspullLF);
02852             meErrxMFSasTID[ilay]->Fill(sqrt(rechitsaserrxMF));
02853             meResMFSasTID[ilay]->Fill(rechitsasresMF);
02854             mePullMFSasTID[ilay]->Fill(rechitsaspullMF);
02855             meTrackangleSasTID[ilay]->Fill(rechitsastrackangle);
02856             mePullTrackangleProfileSasTID[ilay]->Fill(rechitsastrackangle,rechitsaspullMF);
02857             mePullTrackwidthProfileSasTID[ilay]->Fill(rechitsastrackwidth,rechitsaspullMF);
02858             if (rechitsascategory == 1) {
02859               mePullTrackwidthProfileCategory1SasTID[ilay]->Fill(rechitsastrackwidth,rechitsaspullMF);
02860               meErrxMFTrackwidthProfileCategory1SasTID[ilay]->Fill(rechitsastrackwidth,sqrt(rechitsaserrxMF));
02861               meErrxMFClusterwidthProfileCategory1SasTID[ilay]->Fill(clusizsas,sqrt(rechitsaserrxMF));
02862             }
02863             if (rechitsascategory == 2) {
02864               mePullTrackwidthProfileCategory2SasTID[ilay]->Fill(rechitsastrackwidth,rechitsaspullMF);
02865               meErrxMFTrackwidthProfileCategory2SasTID[ilay]->Fill(rechitsastrackwidth,sqrt(rechitsaserrxMF));
02866             }
02867             if (rechitsascategory == 3) {
02868               mePullTrackwidthProfileCategory3SasTID[ilay]->Fill(rechitsastrackwidth,rechitsaspullMF);
02869               meErrxMFTrackwidthProfileCategory3SasTID[ilay]->Fill(rechitsastrackwidth,sqrt(rechitsaserrxMF));
02870             }
02871             if (rechitsascategory == 4) {
02872               mePullTrackwidthProfileCategory4SasTID[ilay]->Fill(rechitsastrackwidth,rechitsaspullMF);
02873               meErrxMFTrackwidthProfileCategory4SasTID[ilay]->Fill(rechitsastrackwidth,sqrt(rechitsaserrxMF));
02874             }
02875             meTrackwidthSasTID[ilay]->Fill(rechitsastrackwidth);
02876             meExpectedwidthSasTID[ilay]->Fill(rechitsasexpectedwidth);
02877             meClusterwidthSasTID[ilay]->Fill(clusizsas);
02878             meCategorySasTID[ilay]->Fill(rechitsascategory);
02879             meErrxMFTrackwidthProfileSasTID[ilay]->Fill(rechitsastrackwidth,sqrt(rechitsaserrxMF));
02880             meErrxMFAngleProfileSasTID[ilay]->Fill(rechitsastrackangle,rechitsaserrxMF);
02881           }
02882         }
02883               
02884         if (detid.subdetId() == int(StripSubdetector::TEC)){
02885           TECDetId tecid(myid);
02886           int Tecisrechitrphi    = isrechitrphi;
02887           int Tecisrechitsas     = isrechitsas;
02888           int ilay = tecid.ring() - 1; //for histogram filling
02889           if(Tecisrechitrphi!=0){
02890             if (rechitrphithickness > CutThickness)
02891               {
02892                 /*PullvsTrackwidthTEC->Fill(rechitrphitrackwidth,rechitrphipullMF);
02893                 PullvsClusterwidthTEC->Fill(clusizrphi,rechitrphipullMF);
02894                 PullvsExpectedwidthTEC->Fill(rechitrphiexpectedwidth,rechitrphipullMF);
02895                 PullvsTrackangleTEC->Fill(rechitrphitrackangle,rechitrphipullMF);
02896                 PullvsTrackanglebetaTEC->Fill(rechitrphitrackanglebeta,rechitrphipullMF);*/
02897               }
02898             //cout<<"TEC:rechitrphitrackwidth,rechitrphipullMF = "<<rechitrphitrackwidth<<" "<<rechitrphipullMF<<endl;
02899             meNstpRphiTEC[ilay]->Fill(clusizrphi);
02900             meAdcRphiTEC[ilay]->Fill(cluchgrphi);
02901             mePosxRphiTEC[ilay]->Fill(rechitrphix);
02902             meErrxLFRphiTEC[ilay]->Fill(sqrt(rechitrphierrxLF));
02903             meResLFRphiTEC[ilay]->Fill(rechitrphiresLF);
02904             mePullLFRphiTEC[ilay]->Fill(rechitrphipullLF);
02905             meErrxMFRphiTEC[ilay]->Fill(sqrt(rechitrphierrxMF));
02906             meResMFRphiTEC[ilay]->Fill(rechitrphiresMF);
02907             mePullMFRphiTEC[ilay]->Fill(rechitrphipullMF);
02908             meTrackangleRphiTEC[ilay]->Fill(rechitrphitrackangle);
02909             mePullTrackangleProfileRphiTEC[ilay]->Fill(rechitrphitrackangle,rechitrphipullMF);
02910             mePullTrackwidthProfileRphiTEC[ilay]->Fill(rechitrphitrackwidth,rechitrphipullMF);
02911             if (rechitrphicategory == 1) {
02912               mePullTrackwidthProfileCategory1RphiTEC[ilay]->Fill(rechitrphitrackwidth,rechitrphipullMF);
02913               meErrxMFTrackwidthProfileCategory1RphiTEC[ilay]->Fill(rechitrphitrackwidth,sqrt(rechitrphierrxMF));
02914               meErrxMFClusterwidthProfileCategory1RphiTEC[ilay]->Fill(clusizrphi,sqrt(rechitrphierrxMF));
02915             }
02916             if (rechitrphicategory == 2) {
02917               mePullTrackwidthProfileCategory2RphiTEC[ilay]->Fill(rechitrphitrackwidth,rechitrphipullMF);
02918               meErrxMFTrackwidthProfileCategory2RphiTEC[ilay]->Fill(rechitrphitrackwidth,sqrt(rechitrphierrxMF));
02919             }
02920             if (rechitrphicategory == 3) {
02921               mePullTrackwidthProfileCategory3RphiTEC[ilay]->Fill(rechitrphitrackwidth,rechitrphipullMF);
02922               meErrxMFTrackwidthProfileCategory3RphiTEC[ilay]->Fill(rechitrphitrackwidth,sqrt(rechitrphierrxMF));
02923             }
02924             if (rechitrphicategory == 4) {
02925               mePullTrackwidthProfileCategory4RphiTEC[ilay]->Fill(rechitrphitrackwidth,rechitrphipullMF);
02926               meErrxMFTrackwidthProfileCategory4RphiTEC[ilay]->Fill(rechitrphitrackwidth,sqrt(rechitrphierrxMF));
02927             }
02928             meTrackwidthRphiTEC[ilay]->Fill(rechitrphitrackwidth);
02929             meExpectedwidthRphiTEC[ilay]->Fill(rechitrphiexpectedwidth);
02930             meClusterwidthRphiTEC[ilay]->Fill(clusizrphi);
02931             meCategoryRphiTEC[ilay]->Fill(rechitrphicategory);
02932             meErrxMFTrackwidthProfileRphiTEC[ilay]->Fill(rechitrphitrackwidth,sqrt(rechitrphierrxMF));
02933             meErrxMFAngleProfileRphiTEC[ilay]->Fill(rechitrphitrackangle,sqrt(rechitrphierrxMF));
02934           } 
02935           if(Tecisrechitsas!=0){
02936             if (rechitsasthickness > CutThickness)
02937               {
02938                 /*PullvsTrackwidthTEC->Fill(rechitsastrackwidth,rechitsaspullMF);
02939                 PullvsClusterwidthTEC->Fill(clusizsas,rechitsaspullMF);
02940                 PullvsExpectedwidthTEC->Fill(rechitsasexpectedwidth,rechitsaspullMF);
02941                 PullvsTrackangleTEC->Fill(rechitsastrackangle,rechitsaspullMF);
02942                 PullvsTrackanglebetaTEC->Fill(rechitsastrackanglebeta,rechitsaspullMF);*/
02943               }
02944             meNstpSasTEC[ilay]->Fill(clusizsas);
02945             meAdcSasTEC[ilay]->Fill(cluchgsas);
02946             mePosxSasTEC[ilay]->Fill(rechitsasx);
02947             meErrxLFSasTEC[ilay]->Fill(sqrt(rechitsaserrxLF));
02948             meResLFSasTEC[ilay]->Fill(rechitsasresLF);
02949             mePullLFSasTEC[ilay]->Fill(rechitsaspullLF);
02950             meErrxMFSasTEC[ilay]->Fill(sqrt(rechitsaserrxMF));
02951             meResMFSasTEC[ilay]->Fill(rechitsasresMF);
02952             mePullMFSasTEC[ilay]->Fill(rechitsaspullMF);
02953             meTrackangleSasTEC[ilay]->Fill(rechitsastrackangle);
02954             mePullTrackangleProfileSasTEC[ilay]->Fill(rechitsastrackangle,rechitsaspullMF);
02955             mePullTrackwidthProfileSasTEC[ilay]->Fill(rechitsastrackwidth,rechitsaspullMF);
02956             if (rechitsascategory == 1) {
02957               mePullTrackwidthProfileCategory1SasTEC[ilay]->Fill(rechitsastrackwidth,rechitsaspullMF);
02958               meErrxMFTrackwidthProfileCategory1SasTEC[ilay]->Fill(rechitsastrackwidth,sqrt(rechitsaserrxMF));
02959               meErrxMFClusterwidthProfileCategory1SasTEC[ilay]->Fill(clusizsas,sqrt(rechitsaserrxMF));
02960             }
02961             if (rechitsascategory == 2) {
02962               mePullTrackwidthProfileCategory2SasTEC[ilay]->Fill(rechitsastrackwidth,rechitsaspullMF);
02963               meErrxMFTrackwidthProfileCategory2SasTEC[ilay]->Fill(rechitsastrackwidth,sqrt(rechitsaserrxMF));
02964             }
02965             if (rechitsascategory == 3) {
02966               mePullTrackwidthProfileCategory3SasTEC[ilay]->Fill(rechitsastrackwidth,rechitsaspullMF);
02967               meErrxMFTrackwidthProfileCategory3SasTEC[ilay]->Fill(rechitsastrackwidth,sqrt(rechitsaserrxMF));
02968             }
02969             if (rechitsascategory == 4) {
02970               mePullTrackwidthProfileCategory4SasTEC[ilay]->Fill(rechitsastrackwidth,rechitsaspullMF);
02971               meErrxMFTrackwidthProfileCategory4SasTEC[ilay]->Fill(rechitsastrackwidth,sqrt(rechitsaserrxMF));
02972             }
02973             meTrackwidthSasTEC[ilay]->Fill(rechitsastrackwidth);
02974             meExpectedwidthSasTEC[ilay]->Fill(rechitsasexpectedwidth);
02975             meClusterwidthSasTEC[ilay]->Fill(clusizsas);
02976             meCategorySasTEC[ilay]->Fill(rechitsascategory);
02977             meErrxMFTrackwidthProfileSasTEC[ilay]->Fill(rechitsastrackwidth,sqrt(rechitsaserrxMF));
02978             meErrxMFAngleProfileSasTEC[ilay]->Fill(rechitsastrackangle,rechitsaserrxMF);
02979           }
02980         
02981         }
02982         
02983       } //simplehits
02984       //cout<<"DebugLine301"<<endl;
02985       
02986     }
02987     //cout<<"DebugLine302"<<endl;
02988     
02989   }
02990   //cout<<"DebugLine303"<<endl;
02991 
02992 }
02993 
02994 
02995 
02996   //needed by to do the residual for matched hits
02997 std::pair<LocalPoint,LocalVector> SiStripTrackingRecHitsValid::projectHit( const PSimHit& hit, const StripGeomDetUnit* stripDet, const BoundPlane& plane) 
02998 {
02999   //  const StripGeomDetUnit* stripDet = dynamic_cast<const StripGeomDetUnit*>(hit.det());
03000   //if (stripDet == 0) throw MeasurementDetException("HitMatcher hit is not on StripGeomDetUnit");
03001   
03002   const StripTopology& topol = stripDet->specificTopology();
03003   GlobalPoint globalpos= stripDet->surface().toGlobal(hit.localPosition());
03004   LocalPoint localHit = plane.toLocal(globalpos);
03005   //track direction
03006   LocalVector locdir=hit.localDirection();
03007   //rotate track in new frame
03008   
03009   GlobalVector globaldir= stripDet->surface().toGlobal(locdir);
03010   LocalVector dir=plane.toLocal(globaldir);
03011   float scale = -localHit.z() / dir.z();
03012   
03013   LocalPoint projectedPos = localHit + scale*dir;
03014   
03015   //  std::cout << "projectedPos " << projectedPos << std::endl;
03016   
03017   float selfAngle = topol.stripAngle( topol.strip( hit.localPosition()));
03018   
03019   LocalVector stripDir( sin(selfAngle), cos(selfAngle), 0); // vector along strip in hit frame
03020   
03021   LocalVector localStripDir( plane.toLocal(stripDet->surface().toGlobal( stripDir)));
03022   
03023   return std::pair<LocalPoint,LocalVector>( projectedPos, localStripDir);
03024 }