CMS 3D CMS Logo

SiPixelLorentzAngle Class Reference

Class to determine the lorentz angle in the barrel pixel detector returns a txt file with the fit for every of the 8 rings in the 3 layers. More...

#include <CalibTracker/SiPixelLorentzAngle/interface/SiPixelLorentzAngle.h>

Inheritance diagram for SiPixelLorentzAngle:

edm::EDAnalyzer

List of all members.

Public Member Functions

virtual void analyze (const edm::Event &e, const edm::EventSetup &c)
virtual void beginJob (const edm::EventSetup &c)
virtual void endJob ()
const float & getLorentzAngle (const uint32_t &) const
const std::map< unsigned int,
float > & 
getLorentzAngles () const
void putLorentsAngles (std::map< unsigned int, float > &LA)
bool putLorentzAngle (const uint32_t &, float &)
 SiPixelLorentzAngle ()
 SiPixelLorentzAngle (const edm::ParameterSet &conf)
 ~SiPixelLorentzAngle ()
virtual ~SiPixelLorentzAngle ()

Private Member Functions

void fillPix (const SiPixelCluster &LocPix, const RectangularPixelTopology *topol)
void findMean (int i, int i_ring)

Private Attributes

std::map< int, TH2F * > _h_drift_depth_
std::map< int, TH2F * > _h_drift_depth_adc2_
std::map< int, TH2F * > _h_drift_depth_adc_
std::map< int, TH2F * > _h_drift_depth_noadc_
std::map< int, TH1F * > _h_mean_
TrackLocalAngleanglefinder_
double chi2_
struct SiPixelLorentzAngle::Clust clust_
edm::ParameterSet conf_
float eta_
int event_
int event_counter_
int eventcounter_
int eventnumber_
int events_needed_
std::string filename_
std::string filenameFit_
TH2F * h_cluster_shape_
TH2F * h_cluster_shape_adc_
TH2F * h_cluster_shape_adc_rot_
TH2F * h_cluster_shape_noadc_
TH2F * h_cluster_shape_noadc_rot_
TH2F * h_cluster_shape_rot_
TH1F * h_drift_depth_adc_slice_
TFile * hFile_
int hist_depth_
int hist_drift_
int hist_x_
int hist_y_
int hits_layer1_module7_
int isflipped_
int ladder_
int layer_
std::map< unsigned int, float > m_LA
const MagneticFieldmagfield
double max_depth_
double max_drift_
double max_x_
double max_y_
double min_depth_
double min_drift_
double min_x_
double min_y_
int module_
double ndof_
int ntracks
float phi_
struct SiPixelLorentzAngle::Pixinfo pixinfo_
float pt_
double ptmin_
struct SiPixelLorentzAngle::Rechit rechit_
const
TransientTrackingRecHitBuilder
RHBuilder
int run_
bool seed_plus_
bool simData_
struct SiPixelLorentzAngle::Simhit simhit_
TTree * SiPixelLorentzAngleTree_
Chi2MeasurementEstimatortheEstimator
const KFTrajectoryFittertheFitter
PropagatorWithMaterialthePropagator
PropagatorWithMaterialthePropagatorOp
const KFTrajectorySmoothertheSmoother
KFUpdatortheUpdator
int trackcounter_
const TrackerGeometrytracker
TrackLocalAngle::Trackhit trackhit_
TrajectoryStateTransform tsTransform
double width_

Static Private Attributes

static const int maxpix = 100

Classes

struct  Clust
struct  Pixinfo
struct  Rechit
struct  Simhit


Detailed Description

Class to determine the lorentz angle in the barrel pixel detector returns a txt file with the fit for every of the 8 rings in the 3 layers.

Definition at line 46 of file SiPixelLorentzAngle.h.


Constructor & Destructor Documentation

SiPixelLorentzAngle::SiPixelLorentzAngle ( const edm::ParameterSet conf  )  [explicit]

Definition at line 33 of file SiPixelLorentzAngle.cc.

References anglefinder_, event_counter_, hist_x_, hist_y_, hits_layer1_module7_, max_depth_, max_drift_, max_x_, max_y_, min_depth_, min_drift_, min_x_, min_y_, and width_.

00033                                                                     : 
00034                 conf_(conf), filename_(conf.getParameter<std::string>("fileName")), filenameFit_(conf.getParameter<std::string>("fileNameFit")),hist_depth_(conf.getParameter<int>("binsDepth")), hist_drift_(conf.getParameter<int>("binsDrift")), ptmin_(conf.getParameter<double>("ptMin")), simData_(conf.getParameter<bool>("simData"))
00035 {
00036         anglefinder_=new  TrackLocalAngle(conf);
00037         hist_x_ = 50;
00038         hist_y_ = 100;
00039         min_x_ = -500.;
00040         max_x_ = 500.;
00041         min_y_ = -1500.;
00042         max_y_ = 500.;
00043         width_ = 0.0285;
00044         min_depth_ = -100.;
00045         max_depth_ = 400.;
00046         min_drift_ = -200.;
00047         max_drift_ = 400.;
00048         event_counter_ = 0;
00049         hits_layer1_module7_ = 0;
00050 }

SiPixelLorentzAngle::~SiPixelLorentzAngle (  )  [virtual]

Definition at line 53 of file SiPixelLorentzAngle.cc.

00053 {  }  

SiPixelLorentzAngle::SiPixelLorentzAngle (  )  [inline]

Definition at line 14 of file SiPixelLorentzAngle.h.

00014 {};

SiPixelLorentzAngle::~SiPixelLorentzAngle (  )  [inline]

Definition at line 15 of file SiPixelLorentzAngle.h.

00015 {};


Member Function Documentation

void SiPixelLorentzAngle::analyze ( const edm::Event e,
const edm::EventSetup c 
) [virtual]

Implements edm::EDAnalyzer.

Definition at line 121 of file SiPixelLorentzAngle.cc.

References _h_drift_depth_adc2_, _h_drift_depth_adc_, _h_drift_depth_noadc_, SiPixelLorentzAngle::Pixinfo::adc, TrackLocalAngle::Trackhit::alpha, SiPixelLorentzAngle::Simhit::alpha, anglefinder_, TrackerHitAssociator::associateHit(), TrackLocalAngle::Trackhit::beta, SiPixelLorentzAngle::Simhit::beta, SiPixelLorentzAngle::Clust::charge, chi2_, clust_, SiPixelRecHit::cluster(), SiPixelLorentzAngle::Pixinfo::col, conf_, GenMuonPlsPt100GeV_cfg::cout, lat::endl(), eta_, event_, event_counter_, eventcounter_, eventnumber_, fillPix(), TrackLocalAngle::findPixelParameters(), SiPixelLorentzAngle::Simhit::gamma, TrackLocalAngle::Trackhit::gamma, edm::Event::getByLabel(), edm::ParameterSet::getParameter(), edm::Event::id(), TrackerGeometry::idToDet(), TrackLocalAngle::init(), isflipped_, j, PXBDetId::ladder(), ladder_, PXBDetId::layer(), layer_, BaseSiTrackerRecHit2DLocalPos::localPosition(), LogDebug, SiPixelLorentzAngle::Clust::maxPixelCol, SiPixelLorentzAngle::Clust::maxPixelRow, SiPixelLorentzAngle::Clust::minPixelCol, SiPixelLorentzAngle::Clust::minPixelRow, PXBDetId::module(), module_, ndof_, SiPixelLorentzAngle::Pixinfo::npix, PV3DBase< T, PVType, FrameType >::perp(), phi_, pixinfo_, pt_, ptmin_, rechit_, SiPixelLorentzAngle::Pixinfo::row, run_, simData_, simhit_, SiPixelLorentzAngleTree_, SiPixelLorentzAngle::Clust::size_x, SiPixelLorentzAngle::Clust::size_y, PixelGeomDetUnit::specificTopology(), HLT_VtxMuL3::src, GeomDet::surface(), funct::tan(), tmp1, tmp2, Surface::toGlobal(), tracker, trackhit_, tracks, width_, SiPixelLorentzAngle::Simhit::x, SiPixelLorentzAngle::Pixinfo::x, PV3DBase< T, PVType, FrameType >::x(), SiPixelLorentzAngle::Clust::x, TrackLocalAngle::Trackhit::x, SiPixelLorentzAngle::Rechit::x, x, SiPixelLorentzAngle::Simhit::y, SiPixelLorentzAngle::Pixinfo::y, PV3DBase< T, PVType, FrameType >::y(), SiPixelLorentzAngle::Clust::y, TrackLocalAngle::Trackhit::y, SiPixelLorentzAngle::Rechit::y, and y.

00122 {  
00123         event_counter_++;
00124         if(event_counter_ % 500 == 0) cout << "event number " << event_counter_ << endl;
00125 //      cout << "event number " << event_counter_ << endl;
00126         TrackerHitAssociator* associate;
00127         if(simData_) associate = new TrackerHitAssociator(e); else associate = 0; 
00128         // restet values
00129         module_=-1;
00130         layer_=-1;
00131         ladder_ = -1;
00132         isflipped_ = -1;
00133         pt_ = -999;
00134         eta_ = 999;
00135         phi_ = 999;
00136         pixinfo_.npix = 0;
00137 
00138         run_       = e.id().run();
00139         event_     = e.id().event();
00140         
00141         if(event_ != eventnumber_){
00142                 eventcounter_+=1;
00143                 eventnumber_ = event_;
00144         }
00145   
00146         using namespace edm;
00147         // initialise the new reconstuction of the track (to get position and angles on the pixel)
00148         anglefinder_->init(e,es);
00149         LogDebug("SiPixelLorentzAngle::analyze")<<"Getting tracks";
00150         std::string src=conf_.getParameter<std::string>( "src" );
00151         edm::Handle<reco::TrackCollection> trackCollection;
00152         e.getByLabel(src, trackCollection);
00153         const reco::TrackCollection *tracks=trackCollection.product();
00154         reco::TrackCollection::const_iterator tciter;
00155         // "are there tracks"
00156         if(tracks->size()>0){
00157                 // iterate over tracks
00158                 for(tciter=tracks->begin();tciter!=tracks->end();tciter++){
00159                         pt_ = tciter->pt();
00160 //                      cout << "pt track: " << pt_ << endl;
00161                         if (pt_ < ptmin_) continue;
00162 //                      cout << "ok" << endl;
00163                         eta_ = tciter->momentum().eta();
00164                         phi_ = tciter->momentum().phi();
00165                         chi2_ = tciter->chi2();
00166                         ndof_ = tciter->ndof();
00167                         // reconstuct the track again (to get position and angles on the pixel)
00168                         std::vector<std::pair<SiPixelRecHit*,TrackLocalAngle::Trackhit> > tmptrackhit=anglefinder_->findPixelParameters(*tciter);
00169                         std::vector<std::pair<SiPixelRecHit*,TrackLocalAngle::Trackhit> >::iterator tmpiter;
00170                         std::vector<PSimHit> matched;
00171                         // iterate over track hits
00172                         for(tmpiter=tmptrackhit.begin();tmpiter!=tmptrackhit.end();tmpiter++){
00173                                 DetId detIdObj((tmpiter->first)->geographicalId());
00174                                 unsigned int subid = detIdObj.subdetId();
00175                                 // "Pixel Barrel only"
00176                                 if (subid == 1) {
00177                                         
00178                                         const PixelGeomDetUnit * theGeomDet = dynamic_cast<const PixelGeomDetUnit*> ( tracker->idToDet(detIdObj) );
00179                                         const RectangularPixelTopology * topol = dynamic_cast<const RectangularPixelTopology*>(&(theGeomDet->specificTopology()));
00180                                         
00181                                         PXBDetId pxbdetIdObj(detIdObj);
00182                                         layer_ = pxbdetIdObj.layer();
00183                                         ladder_ = pxbdetIdObj.ladder();
00184                                         module_ = pxbdetIdObj.module();
00185                                   // Flipped modules
00186                                         float tmp1 = theGeomDet->surface().toGlobal(Local3DPoint(0.,0.,0.)).perp();
00187                                         float tmp2 = theGeomDet->surface().toGlobal(Local3DPoint(0.,0.,1.)).perp();
00188                                 if ( tmp2<tmp1 ) isflipped_ = 1;
00189                                         else isflipped_ = 0;
00190 
00191                                         SiPixelRecHit rechit = (*tmpiter->first);
00192                                         SiPixelRecHit::ClusterRef const& cluster = rechit.cluster();                            
00193                                         rechit_.x  = rechit.localPosition().x();
00194                                         rechit_.y  = rechit.localPosition().y();
00195                                         // fill entries in clust_
00196                                         clust_.x = (cluster)->x();
00197                                         clust_.y = (cluster)->y();
00198                                         clust_.charge = (cluster->charge())/1000.;
00199                                         clust_.size_x = cluster->sizeX();
00200                                         clust_.size_y = cluster->sizeY();
00201                                         clust_.maxPixelCol = cluster->maxPixelCol();
00202                                         clust_.maxPixelRow = cluster->maxPixelRow();
00203                                         clust_.minPixelCol = cluster->minPixelCol();
00204                                         clust_.minPixelRow = cluster->minPixelRow();
00205                                         // fill entries in pixinfo_:
00206                                         fillPix(*cluster ,topol);
00207                                         
00208                                         // fill entries in trackhit_:
00209                                         trackhit_=tmpiter->second;      
00210                                         
00211                                         // fill entries in simhit_:     
00212                                         if(simData_){
00213                                                 matched.clear();        
00214                                                 matched = associate->associateHit((*tmpiter->first));   
00215                                                 float dr_start=9999.;
00216                                                 for (std::vector<PSimHit>::iterator isim = matched.begin(); isim != matched.end(); ++isim){
00217                                                         DetId simdetIdObj((*isim).detUnitId());
00218                                                         if (simdetIdObj == detIdObj) {
00219                                                                 float sim_x1 = (*isim).entryPoint().x(); // width (row index, in col direction)
00220                                                                 float sim_y1 = (*isim).entryPoint().y(); // length (col index, in row direction)
00221                                                                 float sim_x2 = (*isim).exitPoint().x();
00222                                                                 float sim_y2 = (*isim).exitPoint().y();
00223                                                                 float sim_xpos = 0.5*(sim_x1+sim_x2);
00224                                                                 float sim_ypos = 0.5*(sim_y1+sim_y2);
00225                                                                 float sim_px = (*isim).momentumAtEntry().x();
00226                                                                 float sim_py = (*isim).momentumAtEntry().y();
00227                                                                 float sim_pz = (*isim).momentumAtEntry().z();
00228                                         
00229                                                                 float dr = (sim_xpos-(rechit.localPosition().x()))*(sim_xpos-rechit.localPosition().x()) +
00230                                                                                 (sim_ypos-rechit.localPosition().y())*(sim_ypos-rechit.localPosition().y());
00231                                                                 if(dr<dr_start) {
00232                                                                         simhit_.x     = sim_xpos;
00233                                                                         simhit_.y     = sim_ypos;
00234                                                                         simhit_.alpha = atan2(sim_pz, sim_px);
00235                                                                         simhit_.beta  = atan2(sim_pz, sim_py);
00236                                                                         simhit_.gamma = atan2(sim_px, sim_py);
00237                                                                         dr_start = dr;
00238                                                                 }
00239                                                         }
00240                                                 } // end of filling simhit_
00241                                         }
00242                                         
00243                                         // is one pixel in cluster a large pixel ? (hit will be excluded)
00244                                         bool large_pix = false;
00245                                         for (int j = 0; j <  pixinfo_.npix; j++){
00246                                                 int colpos = static_cast<int>(pixinfo_.col[j]-0.5);
00247                                                 if (pixinfo_.row[j] == 0.5 || pixinfo_.row[j] == 79.5 || pixinfo_.row[j] == 80.5 || pixinfo_.row[j] == 159.5 || colpos % 52 == 0 || colpos % 52 == 51 ){
00248                                                         large_pix = true;       
00249                                                 }
00250                                         }
00251 
00252                                         // "good hit?"
00253                                         // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
00254                                         // remove cut on number of hits !!!!!!!!!!!!!!!!!!
00255                                         // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
00256 //                                      if( !large_pix && (chi2_/ndof_) < 2. && (cluster->charge())/1000. < 120. && cluster->sizeY() >= 4 && hits_layer1_module7_ < ntracks){
00257 //                                      if( !large_pix && (chi2_/ndof_) < 10. && (cluster->charge())/1000. < 200. && cluster->sizeY() >= 4){
00258                                         if( !large_pix && (chi2_/ndof_) < 2. && (cluster->charge())/1000. < 120. && cluster->sizeY() >= 4){
00259                                                 SiPixelLorentzAngleTree_->Fill();
00260                                                 // iterate over pixels in hit
00261                                                 for (int j = 0; j <  pixinfo_.npix; j++){
00262                                                         // use trackhits
00263                                                         float dx = (pixinfo_.x[j]  - (trackhit_.x - width_/2. / TMath::Tan(trackhit_.alpha))) * 10000.;
00264                                                         float dy = (pixinfo_.y[j]  - (trackhit_.y - width_/2. / TMath::Tan(trackhit_.beta))) * 10000.;
00265                                                         float depth = dy * tan(trackhit_.beta);
00266                                                         float drift = dx - dy * tan(trackhit_.gamma);
00267                                                         _h_drift_depth_adc_[module_ + (layer_ -1) * 8]->Fill(drift, depth, pixinfo_.adc[j]);
00268                                                         _h_drift_depth_adc2_[module_ + (layer_ -1) * 8]->Fill(drift, depth, pixinfo_.adc[j]*pixinfo_.adc[j]);
00269                                                         _h_drift_depth_noadc_[module_ + (layer_ -1) * 8]->Fill(drift, depth);           
00270 //                                                      if( layer_ == 1 && module_==7 && !isflipped_){
00271 //                                                              float dx_rot = dx * TMath::Cos(trackhit_.gamma) + dy * TMath::Sin(trackhit_.gamma);
00272 //                                                              float dy_rot = dy * TMath::Cos(trackhit_.gamma) - dx * TMath::Sin(trackhit_.gamma) ;
00273 //                                                              h_cluster_shape_adc_->Fill(dx, dy, pixinfo_.adc[j]);
00274 //                                                              h_cluster_shape_noadc_->Fill(dx, dy);
00275 //                                                              h_cluster_shape_adc_rot_->Fill(dx_rot, dy_rot, pixinfo_.adc[j]);
00276 //                                                              h_cluster_shape_noadc_rot_->Fill(dx_rot, dy_rot);
00277 //                                                      }                               
00278                                                 } // end iteration over pixels in hit
00279 //                                              if( layer_ == 1 && module_==7) hits_layer1_module7_++;
00280 //                                              if(hits_layer1_module7_ == ntracks) events_needed_ = event_counter_;
00281                                         } // end "good hit?"
00282                                 } // end "Pixel Barrel only"
00283                                 // delete pointer ro rechit created in TrackLocalAngle::findPixelParameters
00284                                 delete tmpiter->first;
00285                         } // end iteration over track hits
00286                 } // end iteration over tracks
00287         } // end of "are there tracks"
00288 }

void SiPixelLorentzAngle::beginJob ( const edm::EventSetup c  )  [virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 55 of file SiPixelLorentzAngle.cc.

References _h_drift_depth_, _h_drift_depth_adc2_, _h_drift_depth_adc_, _h_drift_depth_noadc_, _h_mean_, SiPixelLorentzAngle::Pixinfo::adc, chi2_, clust_, SiPixelLorentzAngle::Pixinfo::col, eta_, event_, eventcounter_, eventnumber_, filename_, edm::EventSetup::get(), h_cluster_shape_, h_cluster_shape_adc_, h_cluster_shape_adc_rot_, h_cluster_shape_noadc_, h_cluster_shape_noadc_rot_, h_cluster_shape_rot_, hFile_, hist_depth_, hist_drift_, hist_x_, hist_y_, isflipped_, ladder_, layer_, max_depth_, max_drift_, max_x_, max_y_, min_depth_, min_drift_, min_x_, min_y_, module_, name, ndof_, SiPixelLorentzAngle::Pixinfo::npix, ntracks, phi_, pixinfo_, pt_, rechit_, SiPixelLorentzAngle::Pixinfo::row, run_, simhit_, SiPixelLorentzAngleTree_, trackcounter_, tracker, trackhit_, SiPixelLorentzAngle::Pixinfo::x, and SiPixelLorentzAngle::Pixinfo::y.

00056 {
00057         ntracks = 200;
00058         hFile_ = new TFile (filename_.c_str(), "RECREATE" );
00059         int bufsize = 64000;
00060         // create tree structure
00061         SiPixelLorentzAngleTree_ = new TTree("SiPixelLorentzAngleTree_","SiPixel LorentzAngle tree", bufsize);
00062         SiPixelLorentzAngleTree_->Branch("run", &run_, "run/I", bufsize);
00063         SiPixelLorentzAngleTree_->Branch("event", &event_, "event/I", bufsize);
00064         SiPixelLorentzAngleTree_->Branch("module", &module_, "module/I", bufsize);
00065         SiPixelLorentzAngleTree_->Branch("ladder", &ladder_, "ladder/I", bufsize);
00066         SiPixelLorentzAngleTree_->Branch("layer", &layer_, "layer/I", bufsize);
00067         SiPixelLorentzAngleTree_->Branch("isflipped", &isflipped_, "isflipped/I", bufsize);
00068         SiPixelLorentzAngleTree_->Branch("pt", &pt_, "pt/F", bufsize);
00069         SiPixelLorentzAngleTree_->Branch("eta", &eta_, "eta/F", bufsize);
00070         SiPixelLorentzAngleTree_->Branch("phi", &phi_, "phi/F", bufsize);
00071         SiPixelLorentzAngleTree_->Branch("chi2", &chi2_, "chi2/D", bufsize);
00072         SiPixelLorentzAngleTree_->Branch("ndof", &ndof_, "ndof/D", bufsize);
00073         SiPixelLorentzAngleTree_->Branch("trackhit", &trackhit_, "x/F:y/F:alpha/D:beta/D:gamma_/D", bufsize);
00074         SiPixelLorentzAngleTree_->Branch("simhit", &simhit_, "x/F:y/F:alpha/D:beta/D:gamma_/D", bufsize);
00075         SiPixelLorentzAngleTree_->Branch("npix", &pixinfo_.npix, "npix/I", bufsize);
00076         SiPixelLorentzAngleTree_->Branch("rowpix", pixinfo_.row, "row[npix]/F", bufsize);
00077         SiPixelLorentzAngleTree_->Branch("colpix", pixinfo_.col, "col[npix]/F", bufsize);
00078         SiPixelLorentzAngleTree_->Branch("adc", pixinfo_.adc, "adc[npix]/F", bufsize);
00079         SiPixelLorentzAngleTree_->Branch("xpix", pixinfo_.x, "x[npix]/F", bufsize);
00080         SiPixelLorentzAngleTree_->Branch("ypix", pixinfo_.y, "y[npix]/F", bufsize);
00081         SiPixelLorentzAngleTree_->Branch("clust", &clust_, "x/F:y/F:charge/F:size_x/I:size_y/I:maxPixelCol/I:maxPixelRow:minPixelCol/I:minPixelRow/I", bufsize);
00082         SiPixelLorentzAngleTree_->Branch("rechit", &rechit_, "x/F:y/F", bufsize);
00083         
00084         
00085         //book histograms
00086         char name[128];
00087         for(int i_module = 1; i_module<=8; i_module++){
00088                 for(int i_layer = 1; i_layer<=3; i_layer++){
00089                         sprintf(name, "h_drift_depth_adc_layer%i_module%i", i_layer, i_module); 
00090                         _h_drift_depth_adc_[i_module + (i_layer -1) * 8] = new TH2F(name,name,hist_drift_ , min_drift_, max_drift_, hist_depth_, min_depth_, max_depth_);
00091                         sprintf(name, "h_drift_depth_adc2_layer%i_module%i", i_layer, i_module); 
00092                         _h_drift_depth_adc2_[i_module + (i_layer -1) * 8] = new TH2F(name,name,hist_drift_ , min_drift_, max_drift_, hist_depth_, min_depth_, max_depth_);
00093                         sprintf(name, "h_drift_depth_noadc_layer%i_module%i", i_layer, i_module); 
00094                         _h_drift_depth_noadc_[i_module + (i_layer -1) * 8] = new TH2F(name,name,hist_drift_ , min_drift_, max_drift_, hist_depth_, min_depth_, max_depth_);
00095                         sprintf(name, "h_drift_depth_layer%i_module%i", i_layer, i_module); 
00096                         _h_drift_depth_[i_module + (i_layer -1) * 8] = new TH2F(name,name,hist_drift_ , min_drift_, max_drift_, hist_depth_, min_depth_, max_depth_);
00097                         sprintf(name, "h_mean_layer%i_module%i", i_layer, i_module); 
00098                         _h_mean_[i_module + (i_layer -1) * 8] = new TH1F(name,name,hist_depth_, min_depth_, max_depth_);
00099                 }
00100         }
00101         
00102         // just for some expaining plots
00103         h_cluster_shape_adc_  = new TH2F("h_cluster_shape_adc","cluster shape with adc weight", hist_x_, min_x_, max_x_, hist_y_, min_y_, max_y_);
00104         h_cluster_shape_noadc_  = new TH2F("h_cluster_shape_noadc","cluster shape without adc weight", hist_x_, min_x_, max_x_, hist_y_, min_y_, max_y_);
00105         h_cluster_shape_  = new TH2F("h_cluster_shape","cluster shape", hist_x_, min_x_, max_x_, hist_y_, min_y_, max_y_);
00106         h_cluster_shape_adc_rot_  = new TH2F("h_cluster_shape_adc_rot","cluster shape with adc weight", hist_x_, min_x_, max_x_, hist_y_, -max_y_, -min_y_);
00107         h_cluster_shape_noadc_rot_  = new TH2F("h_cluster_shape_noadc_rot","cluster shape without adc weight", hist_x_, min_x_, max_x_, hist_y_, -max_y_, -min_y_);
00108         h_cluster_shape_rot_  = new TH2F("h_cluster_shape_rot","cluster shape", hist_x_, min_x_, max_x_, hist_y_, -max_y_, -min_y_);
00109         
00110         eventcounter_ = 0;
00111         eventnumber_ = -1;
00112         trackcounter_ = 0;
00113         
00114         edm::ESHandle<TrackerGeometry> estracker;
00115         c.get<TrackerDigiGeometryRecord>().get(estracker);
00116         tracker=&(* estracker);
00117 }

void SiPixelLorentzAngle::endJob ( void   )  [virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 290 of file SiPixelLorentzAngle.cc.

References _h_drift_depth_, _h_drift_depth_adc2_, _h_drift_depth_adc_, _h_drift_depth_noadc_, _h_mean_, GenMuonPlsPt100GeV_cfg::cout, e1, lat::endl(), event_counter_, f1, filenameFit_, findMean(), h_drift_depth_adc_slice_, hFile_, hist_depth_, hist_drift_, i, max_drift_, min_drift_, and p1.

00291 {
00292         // produce histograms with the average adc counts
00293         for(int i_ring = 1; i_ring<=24; i_ring++){
00294                 _h_drift_depth_[i_ring]->Divide(_h_drift_depth_adc_[i_ring], _h_drift_depth_noadc_[i_ring]);
00295         }
00296         
00297         h_drift_depth_adc_slice_ = new TH1F("h_drift_depth_adc_slice", "slice of adc histogram", hist_drift_ , min_drift_, max_drift_);
00298 
00299         TF1 *f1 = new TF1("f1","[0] + [1]*x",50., 235.); 
00300         f1->SetParName(0,"p0");
00301         f1->SetParName(1,"p1");
00302         f1->SetParameter(0,0);
00303         f1->SetParameter(1,0.4);
00304         ofstream fLorentzFit( filenameFit_.c_str(), ios::trunc );
00305         cout.precision( 4 );
00306         fLorentzFit << "module" << "\t" << "layer" << "\t" << "offset" << "\t" << "error" << "\t" << "slope" << "\t" << "error" << "\t" "rel.err" << "\t" "pull" << "\t" << "chi2" << "\t" << "prob" << endl;
00307         //loop over modlues and layers to fit the lorentz angle
00308         for( int i_layer = 1; i_layer<=3; i_layer++){
00309                 for(int i_module = 1; i_module<=8; i_module++){
00310                         //loop over bins in depth (z-local-coordinate) (in order to fit slices)
00311                         for( int i = 1; i <= hist_depth_; i++){
00312                                 findMean(i, (i_module + (i_layer - 1) * 8));    
00313                         }// end loop over bins in depth 
00314                         _h_mean_[i_module + (i_layer - 1) * 8]->Fit(f1,"ERQ");
00315                         double p0 = f1->GetParameter(0);
00316                         double e0 = f1->GetParError(0);
00317                         double p1 = f1->GetParameter(1);
00318                         double e1 = f1->GetParError(1);
00319                         double chi2 = f1->GetChisquare();
00320                         double prob = f1->GetProb();
00321                         fLorentzFit << setprecision( 4 ) << i_module << "\t" << i_layer << "\t" << p0 << "\t" << e0 << "\t" << p1 << setprecision( 3 ) << "\t" << e1 << "\t" << e1 / p1 *100. << "\t"<< (p1 - 0.424) / e1 << "\t"<< chi2 << "\t" << prob << endl;
00322                 }
00323         } // end loop over modules and layers
00324         fLorentzFit.close(); 
00325         hFile_->cd();
00326         for(int i_module = 1; i_module<=8; i_module++){
00327                 for(int i_layer = 1; i_layer<=3; i_layer++){
00328                         _h_drift_depth_adc_[i_module + (i_layer -1) * 8]->Write();
00329                         _h_drift_depth_adc2_[i_module + (i_layer -1) * 8]->Write();
00330                         _h_drift_depth_noadc_[i_module + (i_layer -1) * 8]->Write();
00331                         _h_drift_depth_[i_module + (i_layer -1) * 8]->Write();
00332                         _h_mean_[i_module + (i_layer -1) * 8]->Write();
00333                 }
00334         }
00335         
00336         hFile_->Write();
00337         hFile_->Close();
00338         cout << "events: " << event_counter_ << endl;
00339 //      cout << "events used for " << ntracks << " tracks: " << events_needed_ << endl;
00340 }

void SiPixelLorentzAngle::fillPix ( const SiPixelCluster LocPix,
const RectangularPixelTopology topol 
) [private]

Definition at line 342 of file SiPixelLorentzAngle.cc.

References SiPixelCluster::Pixel::adc, SiPixelLorentzAngle::Pixinfo::adc, SiPixelLorentzAngle::Pixinfo::col, RectangularPixelTopology::localPosition(), lp, SiPixelLorentzAngle::Pixinfo::npix, SiPixelCluster::pixels(), pixinfo_, SiPixelLorentzAngle::Pixinfo::row, SiPixelCluster::Pixel::x, SiPixelLorentzAngle::Pixinfo::x, PV3DBase< T, PVType, FrameType >::x(), SiPixelCluster::Pixel::y, SiPixelLorentzAngle::Pixinfo::y, and PV3DBase< T, PVType, FrameType >::y().

Referenced by analyze().

00343 {
00344         const std::vector<SiPixelCluster::Pixel>& pixvector = LocPix.pixels();
00345         
00346         for(pixinfo_.npix = 0; pixinfo_.npix < static_cast<int>(pixvector.size()); ++pixinfo_.npix) {
00347                 SiPixelCluster::Pixel holdpix = pixvector[pixinfo_.npix];
00348                 pixinfo_.row[pixinfo_.npix] = holdpix.x;
00349                 pixinfo_.col[pixinfo_.npix] = holdpix.y;
00350                 pixinfo_.adc[pixinfo_.npix] = holdpix.adc;
00351                 LocalPoint lp = topol->localPosition(MeasurementPoint(holdpix.x, holdpix.y));
00352                 pixinfo_.x[pixinfo_.npix] = lp.x();
00353                 pixinfo_.y[pixinfo_.npix]= lp.y();
00354         }
00355 }

void SiPixelLorentzAngle::findMean ( int  i,
int  i_ring 
) [private]

Definition at line 357 of file SiPixelLorentzAngle.cc.

References _h_drift_depth_, _h_drift_depth_adc2_, _h_drift_depth_adc_, _h_drift_depth_noadc_, _h_mean_, error, h_drift_depth_adc_slice_, hist_drift_, j, mean(), and funct::sqrt().

Referenced by endJob().

00358 {
00359         double nentries = 0;
00360         
00361         h_drift_depth_adc_slice_->Reset("ICE");
00362         
00363         // determine sigma and sigma^2 of the adc counts and average adc counts
00364                 //loop over bins in drift width
00365         for( int j = 1; j<= hist_drift_; j++){
00366                 if(_h_drift_depth_noadc_[i_ring]->GetBinContent(j, i) >= 1){
00367                         double adc_error2 = (_h_drift_depth_adc2_[i_ring]->GetBinContent(j,i) - _h_drift_depth_adc_[i_ring]->GetBinContent(j,i)*_h_drift_depth_adc_[i_ring]->GetBinContent(j, i) / _h_drift_depth_noadc_[i_ring]->GetBinContent(j, i)) /  _h_drift_depth_noadc_[i_ring]->GetBinContent(j, i);
00368                         _h_drift_depth_adc_[i_ring]->SetBinError(j, i, sqrt(adc_error2));
00369                         double error2 = adc_error2 / (_h_drift_depth_noadc_[i_ring]->GetBinContent(j,i) - 1.);
00370                         _h_drift_depth_[i_ring]->SetBinError(j,i,sqrt(error2));
00371                 } 
00372                 else{
00373                         _h_drift_depth_[i_ring]->SetBinError(j,i,0);
00374                         _h_drift_depth_adc_[i_ring]->SetBinError(j, i, 0);
00375                 }
00376                 h_drift_depth_adc_slice_->SetBinContent(j, _h_drift_depth_adc_[i_ring]->GetBinContent(j,i));
00377                 h_drift_depth_adc_slice_->SetBinError(j, _h_drift_depth_adc_[i_ring]->GetBinError(j,i));
00378                 nentries += _h_drift_depth_noadc_[i_ring]->GetBinContent(j,i);  
00379         } // end loop over bins in drift width
00380                 
00381         double mean = h_drift_depth_adc_slice_->GetMean(1); 
00382         double error = 0;
00383         if(nentries != 0){
00384                 error = h_drift_depth_adc_slice_->GetRMS(1) / sqrt(nentries);
00385         }
00386                 
00387         _h_mean_[i_ring]->SetBinContent(i, mean);
00388         _h_mean_[i_ring]->SetBinError(i, error);
00389 
00390 }

const float & SiPixelLorentzAngle::getLorentzAngle ( const uint32_t &  detid  )  const

Definition at line 13 of file SiPixelLorentzAngle.cc.

References lat::endl(), and m_LA.

Referenced by PixelCPEBase::computeLorentzShifts(), and PixelCPEBase::driftDirection().

00013                                                                               {
00014   std::map<unsigned int,float>::const_iterator id=m_LA.find(detid);
00015   if(id!=m_LA.end()) return id->second;
00016   else {
00017     edm::LogError("SiPixelLorentzAngle") << "SiPixelLorentzAngle for DetID " << detid << " is not stored" << std::endl; 
00018   }
00019   return 0;
00020 }

const std::map<unsigned int,float>& SiPixelLorentzAngle::getLorentzAngles (  )  const [inline]

Definition at line 18 of file SiPixelLorentzAngle.h.

References m_LA.

00018 {return m_LA;}

void SiPixelLorentzAngle::putLorentsAngles ( std::map< unsigned int, float > &  LA  )  [inline]

Definition at line 17 of file SiPixelLorentzAngle.h.

References m_LA.

00017 {m_LA=LA;}   

bool SiPixelLorentzAngle::putLorentzAngle ( const uint32_t &  detid,
float &  value 
)

Definition at line 4 of file SiPixelLorentzAngle.cc.

References lat::endl(), and m_LA.

Referenced by SiPixelLorentzAngleDB::beginJob(), and SiPixelFakeLorentzAngleESSource::produce().

00004                                                                             {
00005   std::map<unsigned int,float>::const_iterator id=m_LA.find(detid);
00006   if(id!=m_LA.end()){
00007     edm::LogError("SiPixelLorentzAngle") << "SiPixelLorentzAngle for DetID " << detid << " is already stored. Skippig this put" << std::endl;
00008     return false;
00009   }
00010   else m_LA[detid]=value;
00011   return true;
00012 }


Member Data Documentation

std::map<int, TH2F*> SiPixelLorentzAngle::_h_drift_depth_ [private]

Definition at line 147 of file SiPixelLorentzAngle.h.

Referenced by beginJob(), endJob(), and findMean().

std::map<int, TH2F*> SiPixelLorentzAngle::_h_drift_depth_adc2_ [private]

Definition at line 145 of file SiPixelLorentzAngle.h.

Referenced by analyze(), beginJob(), endJob(), and findMean().

std::map<int, TH2F*> SiPixelLorentzAngle::_h_drift_depth_adc_ [private]

Definition at line 144 of file SiPixelLorentzAngle.h.

Referenced by analyze(), beginJob(), endJob(), and findMean().

std::map<int, TH2F*> SiPixelLorentzAngle::_h_drift_depth_noadc_ [private]

Definition at line 146 of file SiPixelLorentzAngle.h.

Referenced by analyze(), beginJob(), endJob(), and findMean().

std::map<int, TH1F*> SiPixelLorentzAngle::_h_mean_ [private]

Definition at line 149 of file SiPixelLorentzAngle.h.

Referenced by beginJob(), endJob(), and findMean().

TrackLocalAngle* SiPixelLorentzAngle::anglefinder_ [private]

Definition at line 66 of file SiPixelLorentzAngle.h.

Referenced by analyze(), and SiPixelLorentzAngle().

double SiPixelLorentzAngle::chi2_ [private]

Definition at line 77 of file SiPixelLorentzAngle.h.

Referenced by analyze(), and beginJob().

struct SiPixelLorentzAngle::Clust SiPixelLorentzAngle::clust_ [private]

Referenced by analyze(), and beginJob().

edm::ParameterSet SiPixelLorentzAngle::conf_ [private]

Definition at line 62 of file SiPixelLorentzAngle.h.

Referenced by analyze().

float SiPixelLorentzAngle::eta_ [private]

Definition at line 75 of file SiPixelLorentzAngle.h.

Referenced by analyze(), and beginJob().

int SiPixelLorentzAngle::event_ [private]

Definition at line 69 of file SiPixelLorentzAngle.h.

Referenced by analyze(), and beginJob().

int SiPixelLorentzAngle::event_counter_ [private]

Definition at line 65 of file SiPixelLorentzAngle.h.

Referenced by analyze(), endJob(), and SiPixelLorentzAngle().

int SiPixelLorentzAngle::eventcounter_ [private]

Definition at line 79 of file SiPixelLorentzAngle.h.

Referenced by analyze(), and beginJob().

int SiPixelLorentzAngle::eventnumber_ [private]

Definition at line 79 of file SiPixelLorentzAngle.h.

Referenced by analyze(), and beginJob().

int SiPixelLorentzAngle::events_needed_ [private]

Definition at line 170 of file SiPixelLorentzAngle.h.

std::string SiPixelLorentzAngle::filename_ [private]

Definition at line 63 of file SiPixelLorentzAngle.h.

Referenced by beginJob().

std::string SiPixelLorentzAngle::filenameFit_ [private]

Definition at line 64 of file SiPixelLorentzAngle.h.

Referenced by endJob().

TH2F* SiPixelLorentzAngle::h_cluster_shape_ [private]

Definition at line 152 of file SiPixelLorentzAngle.h.

Referenced by beginJob().

TH2F* SiPixelLorentzAngle::h_cluster_shape_adc_ [private]

Definition at line 150 of file SiPixelLorentzAngle.h.

Referenced by beginJob().

TH2F* SiPixelLorentzAngle::h_cluster_shape_adc_rot_ [private]

Definition at line 153 of file SiPixelLorentzAngle.h.

Referenced by beginJob().

TH2F* SiPixelLorentzAngle::h_cluster_shape_noadc_ [private]

Definition at line 151 of file SiPixelLorentzAngle.h.

Referenced by beginJob().

TH2F* SiPixelLorentzAngle::h_cluster_shape_noadc_rot_ [private]

Definition at line 154 of file SiPixelLorentzAngle.h.

Referenced by beginJob().

TH2F* SiPixelLorentzAngle::h_cluster_shape_rot_ [private]

Definition at line 155 of file SiPixelLorentzAngle.h.

Referenced by beginJob().

TH1F* SiPixelLorentzAngle::h_drift_depth_adc_slice_ [private]

Definition at line 148 of file SiPixelLorentzAngle.h.

Referenced by endJob(), and findMean().

TFile* SiPixelLorentzAngle::hFile_ [private]

Definition at line 123 of file SiPixelLorentzAngle.h.

Referenced by beginJob(), and endJob().

int SiPixelLorentzAngle::hist_depth_ [private]

Definition at line 137 of file SiPixelLorentzAngle.h.

Referenced by beginJob(), and endJob().

int SiPixelLorentzAngle::hist_drift_ [private]

Definition at line 138 of file SiPixelLorentzAngle.h.

Referenced by beginJob(), endJob(), and findMean().

int SiPixelLorentzAngle::hist_x_ [private]

Definition at line 126 of file SiPixelLorentzAngle.h.

Referenced by beginJob(), and SiPixelLorentzAngle().

int SiPixelLorentzAngle::hist_y_ [private]

Definition at line 127 of file SiPixelLorentzAngle.h.

Referenced by beginJob(), and SiPixelLorentzAngle().

int SiPixelLorentzAngle::hits_layer1_module7_ [private]

Definition at line 169 of file SiPixelLorentzAngle.h.

Referenced by SiPixelLorentzAngle().

int SiPixelLorentzAngle::isflipped_ [private]

Definition at line 73 of file SiPixelLorentzAngle.h.

Referenced by analyze(), and beginJob().

int SiPixelLorentzAngle::ladder_ [private]

Definition at line 71 of file SiPixelLorentzAngle.h.

Referenced by analyze(), and beginJob().

int SiPixelLorentzAngle::layer_ [private]

Definition at line 72 of file SiPixelLorentzAngle.h.

Referenced by analyze(), and beginJob().

std::map<unsigned int,float> SiPixelLorentzAngle::m_LA [private]

Definition at line 25 of file SiPixelLorentzAngle.h.

Referenced by getLorentzAngle(), getLorentzAngles(), putLorentsAngles(), and putLorentzAngle().

const MagneticField* SiPixelLorentzAngle::magfield [private]

Definition at line 166 of file SiPixelLorentzAngle.h.

double SiPixelLorentzAngle::max_depth_ [private]

Definition at line 134 of file SiPixelLorentzAngle.h.

Referenced by beginJob(), and SiPixelLorentzAngle().

double SiPixelLorentzAngle::max_drift_ [private]

Definition at line 136 of file SiPixelLorentzAngle.h.

Referenced by beginJob(), endJob(), and SiPixelLorentzAngle().

double SiPixelLorentzAngle::max_x_ [private]

Definition at line 129 of file SiPixelLorentzAngle.h.

Referenced by beginJob(), and SiPixelLorentzAngle().

double SiPixelLorentzAngle::max_y_ [private]

Definition at line 131 of file SiPixelLorentzAngle.h.

Referenced by beginJob(), and SiPixelLorentzAngle().

const int SiPixelLorentzAngle::maxpix = 100 [static, private]

Definition at line 85 of file SiPixelLorentzAngle.h.

double SiPixelLorentzAngle::min_depth_ [private]

Definition at line 133 of file SiPixelLorentzAngle.h.

Referenced by beginJob(), and SiPixelLorentzAngle().

double SiPixelLorentzAngle::min_drift_ [private]

Definition at line 135 of file SiPixelLorentzAngle.h.

Referenced by beginJob(), endJob(), and SiPixelLorentzAngle().

double SiPixelLorentzAngle::min_x_ [private]

Definition at line 128 of file SiPixelLorentzAngle.h.

Referenced by beginJob(), and SiPixelLorentzAngle().

double SiPixelLorentzAngle::min_y_ [private]

Definition at line 130 of file SiPixelLorentzAngle.h.

Referenced by beginJob(), and SiPixelLorentzAngle().

int SiPixelLorentzAngle::module_ [private]

Definition at line 70 of file SiPixelLorentzAngle.h.

Referenced by analyze(), and beginJob().

double SiPixelLorentzAngle::ndof_ [private]

Definition at line 78 of file SiPixelLorentzAngle.h.

Referenced by analyze(), and beginJob().

int SiPixelLorentzAngle::ntracks [private]

Definition at line 171 of file SiPixelLorentzAngle.h.

Referenced by beginJob().

float SiPixelLorentzAngle::phi_ [private]

Definition at line 76 of file SiPixelLorentzAngle.h.

Referenced by analyze(), and beginJob().

struct SiPixelLorentzAngle::Pixinfo SiPixelLorentzAngle::pixinfo_ [private]

Referenced by analyze(), beginJob(), and fillPix().

float SiPixelLorentzAngle::pt_ [private]

Definition at line 74 of file SiPixelLorentzAngle.h.

Referenced by analyze(), and beginJob().

double SiPixelLorentzAngle::ptmin_ [private]

Definition at line 80 of file SiPixelLorentzAngle.h.

Referenced by analyze().

struct SiPixelLorentzAngle::Rechit SiPixelLorentzAngle::rechit_ [private]

Referenced by analyze(), and beginJob().

const TransientTrackingRecHitBuilder* SiPixelLorentzAngle::RHBuilder [private]

Definition at line 162 of file SiPixelLorentzAngle.h.

int SiPixelLorentzAngle::run_ [private]

Definition at line 68 of file SiPixelLorentzAngle.h.

Referenced by analyze(), and beginJob().

bool SiPixelLorentzAngle::seed_plus_ [private]

Definition at line 157 of file SiPixelLorentzAngle.h.

bool SiPixelLorentzAngle::simData_ [private]

Definition at line 81 of file SiPixelLorentzAngle.h.

Referenced by analyze().

struct SiPixelLorentzAngle::Simhit SiPixelLorentzAngle::simhit_ [private]

Referenced by analyze(), and beginJob().

TTree* SiPixelLorentzAngle::SiPixelLorentzAngleTree_ [private]

Definition at line 124 of file SiPixelLorentzAngle.h.

Referenced by analyze(), and beginJob().

Chi2MeasurementEstimator* SiPixelLorentzAngle::theEstimator [private]

Definition at line 161 of file SiPixelLorentzAngle.h.

const KFTrajectoryFitter* SiPixelLorentzAngle::theFitter [private]

Definition at line 164 of file SiPixelLorentzAngle.h.

PropagatorWithMaterial* SiPixelLorentzAngle::thePropagator [private]

Definition at line 158 of file SiPixelLorentzAngle.h.

PropagatorWithMaterial* SiPixelLorentzAngle::thePropagatorOp [private]

Definition at line 159 of file SiPixelLorentzAngle.h.

const KFTrajectorySmoother* SiPixelLorentzAngle::theSmoother [private]

Definition at line 163 of file SiPixelLorentzAngle.h.

KFUpdator* SiPixelLorentzAngle::theUpdator [private]

Definition at line 160 of file SiPixelLorentzAngle.h.

int SiPixelLorentzAngle::trackcounter_ [private]

Definition at line 79 of file SiPixelLorentzAngle.h.

Referenced by beginJob().

const TrackerGeometry* SiPixelLorentzAngle::tracker [private]

Definition at line 165 of file SiPixelLorentzAngle.h.

Referenced by analyze(), and beginJob().

TrackLocalAngle::Trackhit SiPixelLorentzAngle::trackhit_ [private]

Definition at line 83 of file SiPixelLorentzAngle.h.

Referenced by analyze(), and beginJob().

TrajectoryStateTransform SiPixelLorentzAngle::tsTransform [private]

Definition at line 167 of file SiPixelLorentzAngle.h.

double SiPixelLorentzAngle::width_ [private]

Definition at line 132 of file SiPixelLorentzAngle.h.

Referenced by analyze(), and SiPixelLorentzAngle().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:32:01 2009 for CMSSW by  doxygen 1.5.4