AlignHists Class Reference

#include <AlignHists.h>

List of all members.

Public Member Functions

 AlignHists (int nplanes, int nmdlperplane, const char *histname=0)
 AlignHists (const char *filename)
virtual ~AlignHists ()
void ApplyTrack (PlaneView::PlaneView_t the_view, std::vector< int > &strip, std::vector< int > &plane, std::vector< int > &mdl, std::vector< double > &resid)
void IncrementIteration ()
void ReadHists (const char *filename)
void LoadFromFile (const char *histfilename)
TH2D * GetResidHist (int view, int iter)
TH2D * GetResidSqrHist (int view, int iter)
TH2D * GetNumberOfTracksHist (int view)

Private Member Functions

 AlignHists (const AlignHists &rhs)
AlignHistsoperator= (const AlignHists &rhs)

Private Attributes

TH2D * fResidHist [2][20]
TH2D * fResidSqrHist [2][20]
TH2D * fNumberOfTracks [2]
TH2D * fNumberOfTracksStrips [2]
int fIteration
const char * fHistName

Detailed Description

Definition at line 25 of file AlignHists.h.


Constructor & Destructor Documentation

AlignHists::AlignHists ( int  nplanes,
int  nmdlperplane,
const char *  histname = 0 
)

Definition at line 13 of file AlignHists.cxx.

References fNumberOfTracks, fNumberOfTracksStrips, fResidHist, and fResidSqrHist.

00014     : fIteration(0)
00015       ,fHistName(histname)
00016 {
00017     cerr << "AlignHists::AlignHists("
00018          << nplanes << "," << nmdlperplane << ")\n";
00019 
00020     fNumberOfTracks[0] = new TH2D("NumberOfTracksU",
00021                                   "Number of tracks per scint module, U view",
00022                                   nplanes,0,nplanes,
00023                                   nmdlperplane,0,nmdlperplane);
00024     fNumberOfTracks[1] = new TH2D("NumberOfTracksV",
00025                                   "Number of tracks per scint module, V view",
00026                                   nplanes,0,nplanes,
00027                                   nmdlperplane,0,nmdlperplane);
00028     fNumberOfTracksStrips[0] = new TH2D("NumberOfTracksStripsU",
00029                                   "Number of tracks per strip, U view",
00030                                   nplanes,0,nplanes,
00031                                   192,0,192);
00032     fNumberOfTracksStrips[1] = new TH2D("NumberOfTracksStripsV",
00033                                   "Number of tracks per strip, V view",
00034                                   nplanes,0,nplanes,
00035                                   192,0,192);
00036 
00037     for (int view = 0; view < 2; ++view) {
00038         char view_char = 'U';
00039         if (view) view_char = 'V';
00040 
00041         for (int itt = 0; itt < 20; ++ itt) {
00042             char name[80];
00043             char title[80];
00044             sprintf(name,"ResidHist%c%02d",view_char,itt);
00045             sprintf(title,"Per Module Residuals %c view, iter %02d",
00046                     view_char,itt);
00047 
00048             fResidHist[view][itt] = new TH2D(name, title,
00049                                              nplanes,0,nplanes,
00050                                              nmdlperplane,0,nmdlperplane);
00051             fResidHist[view][itt]->Sumw2();
00052             sprintf(name,"ResidSqrHist%c%02d",view_char,itt);
00053             sprintf(title,"Per Module Residuals**2 %c view, iter %02d",
00054                     view_char,itt);
00055 
00056             fResidSqrHist[view][itt] = new TH2D(name, title,
00057                                                 nplanes,0,nplanes,
00058                                                 nmdlperplane,0,nmdlperplane);
00059         }
00060     }
00061 
00062     cerr << "AlignHists::AlignHists() done\n";
00063 }

AlignHists::AlignHists ( const char *  filename  ) 

Definition at line 65 of file AlignHists.cxx.

References fNumberOfTracks, fNumberOfTracksStrips, fResidHist, and fResidSqrHist.

00066     : fIteration(0)
00067       ,fHistName(filename)
00068 {
00069     cerr << "AlignHists::AlignHists("<<filename<<")\n";
00070 
00071     fNumberOfTracks[0] = new TH2D("NumberOfTracksU",
00072                                   "Number of tracks per scint module, U view",
00073                                   500,0,500,8,0,8);
00074     fNumberOfTracks[1] = new TH2D("NumberOfTracksV",
00075                                   "Number of tracks per scint module, V view",
00076                                   500,0,500, 8,0,8);
00077     fNumberOfTracksStrips[0] = new TH2D("NumberOfTracksStripsU",
00078                                   "Number of tracks per strip, U view",
00079                                   500,0,500, 192,0,192);
00080     fNumberOfTracksStrips[1] = new TH2D("NumberOfTracksStripsV",
00081                                   "Number of tracks per strip, V view",
00082                                   500,0,500, 192,0,192);
00083 
00084     for (int view = 0; view < 2; ++view) {
00085         char view_char = 'U';
00086         if (view) view_char = 'V';
00087 
00088         for (int itt = 0; itt < 20; ++ itt) {
00089             char name[80];
00090             char title[80];
00091             sprintf(name,"ResidHist%c%02d",view_char,itt);
00092             sprintf(title,"Per Module Residuals %c view, iter %02d",
00093                     view_char,itt);
00094 
00095             fResidHist[view][itt] = new TH2D(name, title,500,0,500,8,0,8);
00096             fResidHist[view][itt]->Sumw2();
00097             sprintf(name,"ResidSqrHist%c%02d",view_char,itt);
00098             sprintf(title,"Per Module Residuals**2 %c view, iter %02d",
00099                     view_char,itt);
00100 
00101             fResidSqrHist[view][itt] = new TH2D(name, title,500,0,500,8,0,8);
00102         }
00103     }
00104 
00105 
00106 }

AlignHists::~AlignHists (  )  [virtual]

Definition at line 173 of file AlignHists.cxx.

References fHistName, fNumberOfTracks, fNumberOfTracksStrips, fResidHist, and fResidSqrHist.

00174 {
00175     // dump hists to file?
00176     if (!fHistName) fHistName = "alignment-hists.root";
00177     TFile userFile(fHistName,"RECREATE");
00178     for (int view = 0; view < 2; ++view) {
00179         for (int itt = 0; itt < 20; ++ itt) {
00180 //            fResidHist[view][itt]->Divide(fNumberOfTracks[view]);
00181 //            fResidSqrHist[view][itt]->Divide(fNumberOfTracks[view]);
00182 
00183             fResidHist[view][itt]->Write();
00184             fResidSqrHist[view][itt]->Write();
00185         }
00186         fNumberOfTracks[view]->Write();
00187         fNumberOfTracksStrips[view]->Write();
00188     }
00189 }

AlignHists::AlignHists ( const AlignHists rhs  )  [private]

Member Function Documentation

void AlignHists::ApplyTrack ( PlaneView::PlaneView_t  the_view,
std::vector< int > &  strip,
std::vector< int > &  plane,
std::vector< int > &  mdl,
std::vector< double > &  resid 
)

Definition at line 191 of file AlignHists.cxx.

References count, fIteration, fNumberOfTracks, fNumberOfTracksStrips, fResidHist, fResidSqrHist, and PlaneView::kV.

Referenced by StraightTrackAlignment::ApplyTrack().

00195 {
00196     static int count=0;
00197     ++count;
00198 
00199 
00200     int view=0;
00201     if (the_view == PlaneView::kV) view = 1;
00202     cerr << "AlignHists::ApplyTrack " << resid.size() << " points,"
00203          << " iteration=" << fIteration << endl;
00204     for (unsigned int ind = 0; ind < resid.size(); ++ind) {
00205         cerr << ".";
00206         TH2D* hist;
00207 
00208         hist = fResidHist[view][fIteration];
00209         hist->Fill(plane[ind],mdl[ind],resid[ind]);
00210 
00211         hist = fResidSqrHist[view][fIteration];
00212         hist->Fill(plane[ind],mdl[ind],resid[ind]*resid[ind]);
00213 
00214         if (!fIteration) {
00215             fNumberOfTracks[view]->Fill(plane[ind],mdl[ind],1.0);
00216             fNumberOfTracksStrips[view]->Fill(plane[ind],strip[ind],1.0);
00217         }
00218     }
00219     cerr << endl;
00220 }

TH2D* AlignHists::GetNumberOfTracksHist ( int  view  )  [inline]

Definition at line 48 of file AlignHists.h.

References fNumberOfTracks.

00048 { return fNumberOfTracks[view]; }

TH2D* AlignHists::GetResidHist ( int  view,
int  iter 
) [inline]

Definition at line 46 of file AlignHists.h.

References fResidHist.

00046 { return fResidHist[view][iter]; }

TH2D* AlignHists::GetResidSqrHist ( int  view,
int  iter 
) [inline]

Definition at line 47 of file AlignHists.h.

References fResidSqrHist.

00047 { return fResidSqrHist[view][iter]; }

void AlignHists::IncrementIteration (  )  [inline]

Definition at line 38 of file AlignHists.h.

References fIteration.

Referenced by StraightTrackAlignment::ApplyAllOffsets().

00038 { ++fIteration; }

void AlignHists::LoadFromFile ( const char *  histfilename  ) 

Definition at line 108 of file AlignHists.cxx.

References fNumberOfTracks, fNumberOfTracksStrips, fResidHist, and fResidSqrHist.

00109 {
00110     TFile* leak = new TFile(histname);
00111     fNumberOfTracks[0] = (TH2D*)leak->Get("NumberOfTracksU");
00112     fNumberOfTracks[1] = (TH2D*)leak->Get("NumberOfTracksV");
00113 
00114     for (int view = 0; view < 2; ++view) {
00115         char view_char = 'U';
00116         if (view) view_char = 'V';
00117 
00118         for (int itt = 0; itt < 20; ++ itt) {
00119             char name[80];
00120 
00121             sprintf(name,"ResidHist%c%02d",view_char,itt);
00122             fResidHist[view][itt] = (TH2D*)leak->Get(name);
00123 
00124             sprintf(name,"ResidSqrHist%c%02d",view_char,itt);
00125             fResidSqrHist[view][itt] = (TH2D*)leak->Get(name);
00126         }
00127     }
00128     fNumberOfTracksStrips[0] = (TH2D*)leak->Get("NumberOfTracksStripsU");
00129     fNumberOfTracksStrips[1] = (TH2D*)leak->Get("NumberOfTracksStripsV");    
00130 }

AlignHists& AlignHists::operator= ( const AlignHists rhs  )  [private]
void AlignHists::ReadHists ( const char *  filename  ) 

Definition at line 145 of file AlignHists.cxx.

References add2d(), fNumberOfTracks, fNumberOfTracksStrips, fResidHist, and fResidSqrHist.

00146 {
00147     TFile file(filename);
00148 
00149     add2d(fNumberOfTracks[0],(TH2D*)file.Get("NumberOfTracksU"));
00150     add2d(fNumberOfTracks[1],(TH2D*)file.Get("NumberOfTracksV"));
00151 
00152     add2d(fNumberOfTracksStrips[0],(TH2D*)file.Get("NumberOfTracksStripsU"));
00153     add2d(fNumberOfTracksStrips[1],(TH2D*)file.Get("NumberOfTracksStripsV"));
00154 
00155     for (int view = 0; view < 2; ++view) {
00156         char view_char = 'U';
00157         if (view) view_char = 'V';
00158 
00159         for (int itt = 0; itt < 20; ++ itt) {
00160             char name[80];
00161 
00162             sprintf(name,"ResidHist%c%02d",view_char,itt);
00163             add2d(fResidHist[view][itt],(TH2D*)file.Get(name));
00164 
00165             sprintf(name,"ResidSqrHist%c%02d",view_char,itt);
00166             add2d(fResidSqrHist[view][itt],(TH2D*)file.Get(name));
00167         }
00168     }
00169     
00170 }


Member Data Documentation

const char* AlignHists::fHistName [private]

Definition at line 61 of file AlignHists.h.

Referenced by ~AlignHists().

int AlignHists::fIteration [private]

Definition at line 60 of file AlignHists.h.

Referenced by ApplyTrack(), and IncrementIteration().

TH2D* AlignHists::fNumberOfTracks[2] [private]

Definition at line 59 of file AlignHists.h.

Referenced by AlignHists(), ApplyTrack(), LoadFromFile(), ReadHists(), and ~AlignHists().

TH2D* AlignHists::fResidHist[2][20] [private]

Definition at line 56 of file AlignHists.h.

Referenced by AlignHists(), ApplyTrack(), GetResidHist(), LoadFromFile(), ReadHists(), and ~AlignHists().

TH2D* AlignHists::fResidSqrHist[2][20] [private]

The documentation for this class was generated from the following files:

Generated on 2 Nov 2017 for loon by  doxygen 1.6.1