AlignmentAlgorithm Class Reference

#include <AlignmentAlgorithm.h>

List of all members.

Public Member Functions

 AlignmentAlgorithm (TFile *rootfile, const VldContext vldc)
virtual ~AlignmentAlgorithm ()
void Fill (const AlignmentStrip &astrip)
void FillCandStrip (const AlignmentStrip &astrip)
void ResetSubset (const VldContext &vldc, const int ntracks)
void FitStripAttenuationHistograms ()
void RunAlgorithm ()

Private Member Functions

TProfile * GetMdlRotationalResidualHistogram (int plane, int module, double low, double high)
TProfile * GetPlaneRotationalResidualHistogram (int plane, double low, double high)
void AnalyzeStripData ()
void AnalyzeModuleResiduals ()
void FitPlaneRotRes ()

Private Attributes

TFile * fRootFile
TDirectory * fdNonTrackStripChargeDir
TDirectory * fdMdlResDir
TDirectory * fdMdlRotResDir
TDirectory * fdPlaneRotResDir
TDirectory * fdResidualDir
TDirectory * fdChargeDir
TDirectory * fdAttenDir
TDirectory * fdOccupancyDir
TDirectory * fdRotResDir
StatisticalFluctuations fFluctuations
map< PlexScintMdlId, TH1D * > fmModuleResidual
map< PlexStripEndId,
AlignmentStripHistograms
fmStripHistograms
map< PlexScintMdlId, TProfile * > fpMdlRotationalResidual
map< PlexPlaneId, TProfile * > fpPlaneRotationalResidual
map< PlexStripEndId, TH1D * > fhCandStripCharge
bool fAlignmentAlgorithmCompleted
const Int_t fNStripChargeBins
const Int_t fNMdlResBins
const Double_t fStripChargeLimit
const Double_t fMdlResLimit
const Double_t fMdlRotResBinWidth
const Double_t fMinResHistEntriesForFit
const Double_t fMinAttenHistEntriesForFit
const Double_t fMinRotResHistEntriesForFit
const Double_t fMinStripRotResHistEntriesForFit
const Double_t fPlaneRotResBinWidth
const Double_t fStripAttenPar0
const Double_t fStripAttenPar1

Detailed Description

Definition at line 40 of file AlignmentAlgorithm.h.


Constructor & Destructor Documentation

AlignmentAlgorithm::AlignmentAlgorithm ( TFile *  rootfile,
const VldContext  vldc 
)

Definition at line 50 of file AlignmentAlgorithm.cxx.

References cd(), fdAttenDir, fdChargeDir, fdMdlResDir, fdMdlRotResDir, fdNonTrackStripChargeDir, fdOccupancyDir, fdPlaneRotResDir, fdResidualDir, fdRotResDir, fpMdlRotationalResidual, fpPlaneRotationalResidual, fRootFile, GetMdlRotationalResidualHistogram(), PlexScintMdlId::GetModule(), PlexPlaneId::GetPlane(), GetPlaneRotationalResidualHistogram(), PlexPlaneId::GetPlaneView(), UgliGeomHandle::GetScintPlnHandleVector(), it, Msg::kFatal, Msg::kInfo, PlaneView::kU, MSG, and UgliGeomHandle::xyz2uvz().

00051    :fRootFile(rootfile),
00052     fFluctuations(vldc),
00053     fAlignmentAlgorithmCompleted(false),
00054     fNStripChargeBins(1000),
00055     fNMdlResBins(200),
00056     fStripChargeLimit(10000.0),
00057     fMdlResLimit(0.10),
00058     fMdlRotResBinWidth(0.4),
00059     fMinResHistEntriesForFit(100),
00060     fMinAttenHistEntriesForFit(10000),
00061     fMinRotResHistEntriesForFit(1000),
00062     fMinStripRotResHistEntriesForFit(100),
00063     fPlaneRotResBinWidth(0.30),
00064     fStripAttenPar0(6.0),
00065     fStripAttenPar1(-0.3)
00066 {
00067    
00068    MSG("Align", Msg::kInfo) << "Constructor AlignmentAlgorithm() " << endl;
00069    
00070    if(!fRootFile)
00071    {
00072       MSG("Align", Msg::kFatal) << "ROOT file pointer is zero. Abort()" <<endl;
00073       abort();
00074    }
00075 
00076    fRootFile -> cd();
00077 
00078    fdNonTrackStripChargeDir = new TDirectory("StripNonTrackChargeHistograms",
00079                                              "StripNonTrackChargeHistograms");
00080 
00081    fdMdlResDir      = new TDirectory("ModuleResHistograms",   "ModuleResHistograms");
00082    fdMdlRotResDir   = new TDirectory("ModuleRotResHistograms","ModuleRotResHistograms");
00083    fdPlaneRotResDir = new TDirectory("PlaneRotResHistograms", "PlaneRotResHistograms");
00084 
00085    fdResidualDir  = new TDirectory("StripResidualHistograms","StripResidualHistograms");
00086    fdRotResDir    = new TDirectory("StripRotationalResidual","StripRotationalResidual");
00087    fdChargeDir    = new TDirectory("StripChargeHistograms","StripChargeHistograms");
00088    fdAttenDir     = new TDirectory("StripAttenuationHistograms","StripAttenuationHistograms");
00089    fdOccupancyDir = new TDirectory("StripOccupancy","StripOccupancy");
00090 
00091    UgliGeomHandle ugh(vldc);
00092    vector<UgliScintPlnHandle> uph  = ugh.GetScintPlnHandleVector();
00093    for(vector<UgliScintPlnHandle>::iterator it = uph.begin(); it != uph.end(); ++it){
00094 
00095       double plowerlimit = 100.0, pupperlimit = -100.0;
00096 
00097       vector<UgliStripHandle> ushv = it -> GetStripHandleVector();
00098       for(vector<UgliStripHandle>::iterator sit = ushv.begin(); sit != ushv.end(); ++sit){
00099          PlexStripEndId plexid = sit -> GetSEId();
00100 
00101          Double_t halflen = sit -> GetHalfLength();
00102          TVector3 localWestEnd(+halflen, 0, 0);
00103          TVector3 localEastEnd(-halflen, 0, 0);
00104          TVector3 globalWestEndxyz = sit -> LocalToGlobal(localWestEnd);
00105          TVector3 globalEastEndxyz = sit -> LocalToGlobal(localEastEnd);
00106          TVector3 globalWestEnduvz = ugh.xyz2uvz(globalWestEndxyz);
00107          TVector3 globalEastEnduvz = ugh.xyz2uvz(globalEastEndxyz);
00108 
00109          if(plexid.GetPlaneView() == PlaneView::kU){
00110             if(plowerlimit > globalWestEnduvz.y())
00111                plowerlimit = globalWestEnduvz.y();
00112             if(pupperlimit < globalEastEnduvz.y())
00113                pupperlimit = globalEastEnduvz.y();
00114          } else {
00115             if(plowerlimit > globalEastEnduvz.x())
00116                plowerlimit = globalEastEnduvz.x();
00117             if(pupperlimit < globalWestEnduvz.x())
00118                pupperlimit = globalWestEnduvz.x();
00119          }
00120       }
00121       
00122       PlexPlaneId planeid = it -> GetPlexPlaneId();
00123       fpPlaneRotationalResidual[planeid] = 
00124          GetPlaneRotationalResidualHistogram(planeid.GetPlane(), plowerlimit, pupperlimit);
00125       
00126       vector<UgliScintMdlHandle> umhv = it -> GetScintMdlHandleVector();
00127       for(vector<UgliScintMdlHandle>::iterator mit = umhv.begin(); mit != umhv.end(); ++mit){    
00128          PlexScintMdlId plexmdlid = mit -> GetPlexScintMdlId();
00129          double mlowerlimit = 100.0, mupperlimit = -100.0;
00130       
00131          for(vector<UgliStripHandle>::iterator sit = ushv.begin(); sit != ushv.end(); ++sit){
00132             if(plexmdlid != (sit->GetScintMdlHandle()).GetPlexScintMdlId())
00133                continue;            
00134             
00135             Double_t halflen = sit -> GetHalfLength();
00136             Double_t lpos = sit -> GetLPosRelMdl();
00137             
00138             if(mlowerlimit > lpos - halflen)
00139                mlowerlimit = lpos - halflen;
00140             if(mupperlimit < lpos + halflen)
00141                mupperlimit = lpos + halflen;
00142          }
00143          
00144          const int plane  = plexmdlid.GetPlane();
00145          const int module = plexmdlid.GetModule();
00146          fpMdlRotationalResidual[plexmdlid] = 
00147             GetMdlRotationalResidualHistogram(plane, module, mlowerlimit, mupperlimit);
00148       }
00149    }
00150 }

AlignmentAlgorithm::~AlignmentAlgorithm (  )  [virtual]

Definition at line 1050 of file AlignmentAlgorithm.cxx.

References Msg::kInfo, and MSG.

01051 {
01052    MSG("Align", Msg::kInfo) << "Destructor ~AlignmentAlgorithm()..." << endl;
01053    MSG("Align", Msg::kInfo) << "Destructor ~AlignmentAlgorithm()...Done" << endl;
01054 }


Member Function Documentation

void AlignmentAlgorithm::AnalyzeModuleResiduals (  )  [private]

Definition at line 643 of file AlignmentAlgorithm.cxx.

References fFluctuations, SubsetStat::Fill(), Fill(), fMinRotResHistEntriesForFit, fmModuleResidual, fmStripHistograms, fpMdlRotationalResidual, fRootFile, PlexScintMdlId::GetEncoded(), SubsetStat::GetMean(), PlexScintMdlId::GetModule(), StatisticalFluctuations::GetModuleResidualSample(), StatisticalFluctuations::GetNSubsets(), PlexPlaneId::GetPlane(), SubsetStat::GetSigma(), SubsetStat::GetSize(), it, Msg::kError, Msg::kInfo, SubsetSummary::mean, MSG, Munits::second, SubsetSummary::sigma, SubsetSummary::size, size, and stat.

Referenced by RunAlgorithm().

00644 {
00645    MSG("Align", Msg::kInfo) << "AlignmentAlgorithm::AnalyzeModuleResiduals()..." <<endl;
00646    
00647    //-----------------------------------------------------------------------------------------
00648 
00649    TTree *MdlResTree = new TTree("MdlResSubset","Module residual subsets");
00650    MdlResTree -> SetDirectory(fRootFile);
00651    
00652    Double_t mean, sigma;
00653    Int_t plane, module;
00654    UInt_t plexmdlid, size, nsubset;
00655    MdlResTree -> Branch("mean",      &mean,      "mean/D");
00656    MdlResTree -> Branch("sigma",     &sigma,     "sigma/D");
00657    MdlResTree -> Branch("size",      &size,      "size/i");
00658    MdlResTree -> Branch("nsubset",   &nsubset,   "nsubset/i");
00659    MdlResTree -> Branch("plane",     &plane,     "plane/I");   
00660    MdlResTree -> Branch("module",    &module,    "module/I");   
00661    MdlResTree -> Branch("plexmdlid", &plexmdlid, "plexmdlid/i");
00662 
00663    map<PlexScintMdlId, SubsetStat> mdl_subset_mean;
00664    map<PlexScintMdlId, SubsetStat> mdl_subset_sigma;
00665    map<PlexScintMdlId, SubsetStat> mdl_subset_size;
00666 
00667    map<unsigned int, map<PlexScintMdlId, SubsetSummary> > res_fluc = fFluctuations.GetModuleResidualSample();
00668    
00669    for(map<unsigned int, map<PlexScintMdlId, SubsetSummary> >::iterator it = res_fluc.begin();
00670        it != res_fluc.end(); ++it)
00671    {
00672       nsubset = it -> first;
00673       map<PlexScintMdlId, SubsetSummary> mdlsample = it -> second;
00674       
00675       for(map<PlexScintMdlId, SubsetSummary>::iterator mit = mdlsample.begin();
00676           mit != mdlsample.end(); ++mit)
00677       {
00678          PlexScintMdlId plexid = mit -> first;
00679          SubsetSummary summary = mit -> second;
00680 
00681          plane     = plexid.GetPlane();
00682          module    = plexid.GetModule();
00683          plexmdlid = plexid.GetEncoded();
00684          mean      = summary.mean;
00685          sigma     = summary.sigma;
00686          size      = summary.size;
00687          MdlResTree -> Fill();
00688 
00689          map<PlexScintMdlId, SubsetStat>::iterator fmean = mdl_subset_mean.find(plexid);
00690          if(fmean == mdl_subset_mean.end())
00691          {
00692             SubsetStat stat;
00693             stat.Fill(mean);
00694             pair<PlexScintMdlId, SubsetStat> p(plexid, stat);
00695             mdl_subset_mean.insert(p);
00696          } else
00697             (fmean -> second).Fill(mean);
00698 
00699          map<PlexScintMdlId, SubsetStat>::iterator fsigma = mdl_subset_sigma.find(plexid);
00700          if(fsigma == mdl_subset_sigma.end())
00701          {
00702             SubsetStat stat;
00703             stat.Fill(sigma);
00704             pair<PlexScintMdlId, SubsetStat> p(plexid, stat);
00705             mdl_subset_sigma.insert(p);
00706          } else
00707             (fsigma -> second).Fill(sigma);
00708 
00709          map<PlexScintMdlId, SubsetStat>::iterator fsize = mdl_subset_size.find(plexid);
00710          if(fsize == mdl_subset_size.end())
00711          {
00712             SubsetStat stat;
00713             stat.Fill(size);
00714             pair<PlexScintMdlId, SubsetStat> p(plexid, stat);
00715             mdl_subset_size.insert(p);
00716          } else
00717             (fsize -> second).Fill(size);
00718       }            
00719    }
00720 
00721 
00722    //calculate mean and sigma of mean residual of strips in a module
00723    map<PlexScintMdlId, SubsetStat> strip_mean;
00724    for(map<PlexStripEndId, AlignmentStripHistograms>::iterator it = fmStripHistograms.begin();
00725        it != fmStripHistograms.end(); ++it)
00726    {
00727       PlexScintMdlId plexmdlid = (it->first).GetScintMdlId();
00728       TH1D *h = (it->second).GetResidualHistogram();
00729       
00730       map<PlexScintMdlId, SubsetStat>::iterator fmean = strip_mean.find(plexmdlid);
00731       if(fmean == strip_mean.end())
00732       {
00733          SubsetStat stat;
00734          stat.Fill(h -> GetMean());
00735          pair<PlexScintMdlId, SubsetStat> p(plexmdlid, stat);
00736          strip_mean.insert(p);
00737       } else
00738          (fmean -> second).Fill(h -> GetMean());
00739    }
00740 
00741    //-----------------------------------------------------------------------------------------
00742 
00743    TTree *MdlResSummaryTree = new TTree("MdlRes","Module residual data");
00744    MdlResSummaryTree -> SetDirectory(fRootFile);
00745 
00746    Double_t hmean, hrms, hentries;
00747 
00748    Double_t mean_of_means, sigma_of_means;
00749    Double_t mean_of_sigmas, sigma_of_sigmas;
00750    Double_t mean_of_sizes, sigma_of_sizes;
00751    Double_t mean_of_strip_mean, sigma_of_strip_mean;
00752    UInt_t number_of_subsets, nstrip;
00753 
00754    Int_t rot_res_fit_result, rot_res_fit_ndgf;
00755    Double_t rot_res_fit_par0,     rot_res_fit_par1;
00756    Double_t rot_res_fit_err_par0, rot_res_fit_err_par1;
00757    Double_t rot_res_fit_chi2;
00758 
00759    MdlResSummaryTree -> Branch("plane",     &plane,     "plane/I");   
00760    MdlResSummaryTree -> Branch("module",    &module,    "module/I"); 
00761    MdlResSummaryTree -> Branch("plexmdlid", &plexmdlid, "plexmdlid/i");
00762 
00763    MdlResSummaryTree -> Branch("hmean",    &hmean,    "hmean/D");
00764    MdlResSummaryTree -> Branch("hrms",     &hrms,     "hrms/D");
00765    MdlResSummaryTree -> Branch("hentries", &hentries, "hentries/D");
00766 
00767    MdlResSummaryTree -> Branch("mean_of_strip_mean",  &mean_of_strip_mean,  "mean_of_strip_mean/D");
00768    MdlResSummaryTree -> Branch("sigma_of_strip_mean", &sigma_of_strip_mean, "sigma_of_strip_mean/D");
00769    MdlResSummaryTree -> Branch("nstrip",              &nstrip,              "nstrip/i");
00770 
00771    MdlResSummaryTree -> Branch("mean_of_means",     &mean_of_means,     "mean_of_means/D");
00772    MdlResSummaryTree -> Branch("mean_of_sigmas",    &mean_of_sigmas,    "mean_of_sigmas/D");
00773    MdlResSummaryTree -> Branch("mean_of_sizes",     &mean_of_sizes,     "mean_of_sizes/D");
00774    MdlResSummaryTree -> Branch("sigma_of_means",    &sigma_of_means,    "sigma_of_means/D");
00775    MdlResSummaryTree -> Branch("sigma_of_sigmas",   &sigma_of_sigmas,   "sigma_of_sigmas/D");
00776    MdlResSummaryTree -> Branch("sigma_of_sizes",    &sigma_of_sizes,    "sigma_of_sizes/D");
00777    MdlResSummaryTree -> Branch("number_of_subsets", &number_of_subsets, "number_of_subsets/i");
00778     
00779    MdlResSummaryTree -> Branch("rot_res_fit_result",   &rot_res_fit_result,   "rot_res_fit_result/I");
00780    MdlResSummaryTree -> Branch("rot_res_fit_par0",     &rot_res_fit_par0,     "rot_res_fit_par0/D");
00781    MdlResSummaryTree -> Branch("rot_res_fit_par1",     &rot_res_fit_par1,     "rot_res_fit_par1/D");
00782    MdlResSummaryTree -> Branch("rot_res_fit_err_par0", &rot_res_fit_err_par0, "rot_res_fit_err_par0/D");
00783    MdlResSummaryTree -> Branch("rot_res_fit_err_par1", &rot_res_fit_err_par1, "rot_res_fit_err_par1/D");
00784    MdlResSummaryTree -> Branch("rot_res_fit_chi2",     &rot_res_fit_chi2,     "rot_res_fit_chi2/D");
00785    MdlResSummaryTree -> Branch("rot_res_fit_ndgf",     &rot_res_fit_ndgf,     "rot_res_fit_ndgf/I");
00786 
00787    for(map<PlexScintMdlId, TH1D *>::iterator mit = fmModuleResidual.begin();
00788        mit != fmModuleResidual.end(); ++mit)
00789    {
00790       PlexScintMdlId plexid = mit -> first;
00791       TH1D *h = mit -> second;
00792 
00793       plane     = plexid.GetPlane();
00794       module    = plexid.GetModule();
00795       plexmdlid = plexid.GetEncoded();
00796       hmean     = h -> GetMean(); 
00797       hrms      = h -> GetRMS(); 
00798       hentries  = h -> GetEntries();
00799 
00800       map<PlexScintMdlId, SubsetStat>::const_iterator sit = strip_mean.find(plexid);
00801       if(sit == strip_mean.end())
00802       {
00803          MSG("Align", Msg::kError) << "Required map PlexScintMdlId key is missing."<<endl; 
00804          continue;
00805       }
00806       SubsetStat strip_stat = sit -> second;      
00807       nstrip                = strip_stat.GetSize();
00808       mean_of_strip_mean    = strip_stat.GetMean();
00809       sigma_of_strip_mean   = strip_stat.GetSigma();
00810 
00811       map<PlexScintMdlId, SubsetStat>::iterator mean_it = mdl_subset_mean.find(plexid);
00812       if(mean_it == mdl_subset_mean.end())
00813       {
00814          if(fFluctuations.GetNSubsets() > 0)
00815             MSG("Align", Msg::kError) << "Failed to find map item." << endl;
00816          number_of_subsets = 0;
00817          mean_of_means     = -1.0;
00818          sigma_of_means    = -1.0;
00819       }
00820       else
00821       {
00822          SubsetStat mean_stat  = mean_it -> second;
00823          number_of_subsets = mean_stat.GetSize();
00824          mean_of_means     = mean_stat.GetMean();
00825          sigma_of_means    = mean_stat.GetSigma();
00826       }
00827 
00828       map<PlexScintMdlId, SubsetStat>::iterator sigma_it = mdl_subset_sigma.find(plexid);
00829       if(sigma_it == mdl_subset_sigma.end())
00830       {
00831          if(fFluctuations.GetNSubsets() > 0)
00832             MSG("Align", Msg::kError) << "Failed to find map item." << endl;
00833          mean_of_sigmas  = -1.0;
00834          sigma_of_sigmas = -1.0;
00835       }
00836       else
00837       {      
00838          SubsetStat sigma_stat = sigma_it -> second;
00839          mean_of_sigmas  = sigma_stat.GetMean();
00840          sigma_of_sigmas = sigma_stat.GetSigma();
00841       }
00842 
00843       map<PlexScintMdlId, SubsetStat>::iterator size_it = mdl_subset_size.find(plexid);
00844       if(size_it == mdl_subset_size.end())
00845       {
00846          if(fFluctuations.GetNSubsets() > 0)
00847             MSG("Align", Msg::kError) << "Failed to find map item." << endl;
00848          mean_of_sizes  = -1.0;
00849          sigma_of_sizes = -1.0;
00850       }
00851       else
00852       {
00853          SubsetStat size_stat = size_it -> second;
00854          mean_of_sizes  = size_stat.GetMean();
00855          sigma_of_sizes = size_stat.GetSigma();
00856       }
00857 
00858       rot_res_fit_result   = -1;
00859       rot_res_fit_par0     = -1.0;
00860       rot_res_fit_par1     = -1.0;
00861       rot_res_fit_err_par0 = -1.0;
00862       rot_res_fit_err_par1 = -1.0;
00863       rot_res_fit_chi2     = -1.0;
00864       rot_res_fit_ndgf     = -1;
00865 
00866       map<PlexScintMdlId, TProfile *>::iterator rot_it = fpMdlRotationalResidual.find(plexid);
00867       if(rot_it != fpMdlRotationalResidual.end() &&
00868          rot_it -> second -> GetEntries() > fMinRotResHistEntriesForFit)
00869       {
00870          char function[80];
00871          sprintf(function,"FitRotResInPlane%03dModule%02d", plane, module);
00872          TF1 *f =  new TF1(function, "pol1");
00873          
00874          //fit rotational residual TProfile
00875          rot_res_fit_result   = rot_it -> second -> Fit(function, "QI");
00876          rot_res_fit_par0     = f -> GetParameter(0);
00877          rot_res_fit_par1     = f -> GetParameter(1);
00878          rot_res_fit_err_par0 = f -> GetParError(0);
00879          rot_res_fit_err_par1 = f -> GetParError(1);
00880          rot_res_fit_chi2     = f -> GetChisquare();
00881          rot_res_fit_ndgf     = f -> GetNDF();
00882       }
00883       
00884       //finally... fill that tree...
00885       MdlResSummaryTree -> Fill();
00886    }
00887 
00888    MSG("Align", Msg::kInfo) << "AlignmentAlgorithm::AnalyzeModuleResiduals()... Done" <<endl;
00889 }

void AlignmentAlgorithm::AnalyzeStripData (  )  [private]

Definition at line 245 of file AlignmentAlgorithm.cxx.

References fFluctuations, fhCandStripCharge, SubsetStat::Fill(), Fill(), fMinResHistEntriesForFit, fMinStripRotResHistEntriesForFit, fmStripHistograms, fRootFile, AlignmentStripHistograms::GetChargeHistogram(), AlignmentStripHistograms::GetChargePathCorrHistogram(), VldTimeStamp::GetDate(), PlexStripEndId::GetEncoded(), SubsetStat::GetMean(), StatisticalFluctuations::GetNSubsets(), PlexPlaneId::GetPlane(), AlignmentStripHistograms::GetResidualHistogram(), AlignmentStripHistograms::GetRotationalHistogram(), VldTimeStamp::GetSec(), SubsetStat::GetSigma(), SubsetStat::GetSize(), PlexStripEndId::GetStrip(), StatisticalFluctuations::GetStripChargeSample(), StatisticalFluctuations::GetStripResidualSample(), StatisticalFluctuations::GetSubsetNRecords(), StatisticalFluctuations::GetSubsetValidity(), VldTimeStamp::GetTime(), VldContext::GetTimeStamp(), it, Msg::kDebug, Msg::kError, Msg::kInfo, Msg::kWarning, SubsetSummary::mean, MSG, Munits::second, SubsetSummary::sigma, SubsetSummary::size, size, and stat.

Referenced by RunAlgorithm().

00246 {
00247 
00248    MSG("Align", Msg::kInfo) << "AlignmentAlgorithm::AnalyzeStripResidualHistograms()..." << endl;
00249    
00250    //-----------------------------------------------------------------------------------------
00251 
00252    MSG("Align", Msg::kInfo) << "Processing statistical subset data for strip residuals..." << endl;
00253 
00254    TTree *StripResTree = new TTree("StripResSubset","Strip residual subsets");
00255    StripResTree -> SetDirectory(fRootFile);
00256    
00257    Double_t mean, sigma;
00258    Int_t plane, strip, second, date, time, number_of_records;
00259    UInt_t plexseid, size, nsubset;
00260    StripResTree -> Branch("mean", &mean, "mean/D");
00261    StripResTree -> Branch("sigma", &sigma, "sigma/D");
00262    StripResTree -> Branch("size", &size, "size/i");
00263    StripResTree -> Branch("nsubset", &nsubset, "nsubset/i");
00264    StripResTree -> Branch("plane", &plane, "plane/I");   
00265    StripResTree -> Branch("strip", &strip, "strip/I");
00266    StripResTree -> Branch("second", &second, "second/I");
00267    StripResTree -> Branch("date", &date, "date/I");
00268    StripResTree -> Branch("time", &time, "time/I");
00269    StripResTree -> Branch("number_of_records", &number_of_records, "number_of_records/I");
00270    StripResTree -> Branch("plexseid", &plexseid, "plexseid/i");
00271    
00272    map<PlexStripEndId, SubsetStat> strip_subset_mean;
00273    map<PlexStripEndId, SubsetStat> strip_subset_sigma;
00274    map<PlexStripEndId, SubsetStat> strip_subset_size;
00275 
00276    map<unsigned int, map<PlexStripEndId, SubsetSummary> > res_fluc = fFluctuations.GetStripResidualSample();
00277    map<unsigned int, VldContext> vld_map = fFluctuations.GetSubsetValidity();
00278    map<unsigned int, int> record_map     = fFluctuations.GetSubsetNRecords();
00279 
00280    for(map<unsigned int, map<PlexStripEndId, SubsetSummary> >::const_iterator it = res_fluc.begin();
00281        it != res_fluc.end(); ++it)
00282    {
00283       nsubset = it -> first;
00284 
00285       map<unsigned int, VldContext>::const_iterator vit = vld_map.find(nsubset);
00286       if(vit == vld_map.end())
00287       {
00288          second = -1;
00289          date   = -1;
00290          time   = -1;
00291          MSG("Align", Msg::kError) << "Failed to find map subset number key for validity map." << endl;
00292       }
00293       else
00294       {
00295          const VldContext vldc  = vit -> second;
00296          const VldTimeStamp vts = vldc.GetTimeStamp();
00297          second = vts.GetSec();
00298          date   = vts.GetDate();
00299          time   = vts.GetTime();
00300       }
00301 
00302       map<unsigned int, int>::const_iterator rit = record_map.find(nsubset);
00303       if(rit == record_map.end())
00304       {
00305          number_of_records = -1;
00306          MSG("Align", Msg::kError) << "Failed to find map subset number key for validity map." << endl;
00307       }
00308       else
00309           number_of_records = rit -> second;
00310 
00311       map<PlexStripEndId, SubsetSummary> stripsample = it -> second;
00312       
00313       for(map<PlexStripEndId, SubsetSummary>::const_iterator sit = stripsample.begin();
00314           sit != stripsample.end(); ++sit)
00315       {
00316          PlexStripEndId plexid = sit -> first;
00317          SubsetSummary summary = sit -> second;
00318          plane    = plexid.GetPlane();
00319          strip    = plexid.GetStrip();
00320          plexseid = plexid.GetEncoded();
00321          mean     = summary.mean;
00322          sigma    = summary.sigma;
00323          size     = summary.size;
00324          StripResTree -> Fill();
00325 
00326          map<PlexStripEndId, SubsetStat>::iterator fmean = strip_subset_mean.find(plexid);
00327          if(fmean == strip_subset_mean.end())
00328          {
00329             SubsetStat stat;
00330             stat.Fill(mean);
00331             pair<PlexStripEndId, SubsetStat> p(plexid, stat);
00332             strip_subset_mean.insert(p);
00333          } else
00334             (fmean -> second).Fill(mean);
00335 
00336          map<PlexStripEndId, SubsetStat>::iterator fsigma = strip_subset_sigma.find(plexid);
00337          if(fsigma == strip_subset_sigma.end())
00338          {
00339             SubsetStat stat;
00340             stat.Fill(sigma);
00341             pair<PlexStripEndId, SubsetStat> p(plexid, stat);
00342             strip_subset_sigma.insert(p);
00343          } else
00344             (fsigma -> second).Fill(sigma);
00345 
00346          map<PlexStripEndId, SubsetStat>::iterator fsize = strip_subset_size.find(plexid);
00347          if(fsize == strip_subset_size.end())
00348          {
00349             SubsetStat stat;
00350             stat.Fill(size);
00351             pair<PlexStripEndId, SubsetStat> p(plexid, stat);
00352             strip_subset_size.insert(p);
00353          } else
00354             (fsize -> second).Fill(size);
00355       }      
00356    }
00357 
00358 
00359    //-----------------------------------------------------------------------------------------
00360 
00361    MSG("Align", Msg::kInfo) << "Creating a tree with strip residual and charge data..." << endl;
00362 
00363    Double_t residual_mean, residual_rms, residual_hentries;
00364 
00365    Double_t residual_fit_mean,  residual_fit_err_mean;
00366    Double_t residual_fit_sigma, residual_fit_err_sigma;
00367    Double_t residual_fit_par0,  residual_fit_err_par0;
00368    Double_t residual_fit_chi2;  
00369    Int_t residual_fit_ndgf, residual_fit_result;
00370 
00371    Int_t rot_res_fit_result;
00372    Double_t rot_res_fit_par0,     rot_res_fit_par1;
00373    Double_t rot_res_fit_err_par0, rot_res_fit_err_par1;
00374    Double_t rot_res_fit_chi2;
00375    Int_t rot_res_fit_ndgf;
00376    
00377    Double_t charge_mean,      charge_rms,      charge_hentries,      charge_overflow;
00378    Double_t pc_charge_mean,   pc_charge_rms,   pc_charge_hentries,   pc_charge_overflow;
00379    Double_t cand_charge_mean, cand_charge_rms, cand_charge_hentries, cand_charge_overflow;
00380    
00381    Double_t mean_of_res_means,  sigma_of_res_means;
00382    Double_t mean_of_res_sigmas, sigma_of_res_sigmas;
00383    Double_t mean_of_res_sizes,  sigma_of_res_sizes;
00384    UInt_t number_of_subsets;
00385 
00386    TTree *StripResultsTree = new TTree("StripResults","Strip data");   
00387    StripResultsTree -> SetDirectory(fRootFile);
00388 
00389    StripResultsTree -> Branch("plane", &plane, "plane/I");
00390    StripResultsTree -> Branch("strip", &strip, "strip/I");
00391    StripResultsTree -> Branch("plexseid", &plexseid, "plexseid/i");
00392 
00393    StripResultsTree -> Branch("residual_mean",     &residual_mean,     "residual_mean/D");
00394    StripResultsTree -> Branch("residual_rms",      &residual_rms,      "residual_rms/D");
00395    StripResultsTree -> Branch("residual_hentries", &residual_hentries, "residual_hentries/D");
00396 
00397    StripResultsTree -> Branch("residual_fit_mean",      &residual_fit_mean,      "residual_fit_mean/D");
00398    StripResultsTree -> Branch("residual_fit_sigma",     &residual_fit_sigma,     "residual_fit_sigma/D");
00399    StripResultsTree -> Branch("residual_fit_par0",      &residual_fit_par0,      "residual_fit_par0/D");
00400    StripResultsTree -> Branch("residual_fit_err_mean",  &residual_fit_err_mean,  "residual_fit_err_mean/D");
00401    StripResultsTree -> Branch("residual_fit_err_sigma", &residual_fit_err_sigma, "residual_fit_err_sigma/D");
00402    StripResultsTree -> Branch("residual_fit_err_par0",  &residual_fit_err_par0,  "residual_fit_err_par0/D");
00403    StripResultsTree -> Branch("residual_fit_chi2",      &residual_fit_chi2,      "residual_fit_chi2/D");
00404    StripResultsTree -> Branch("residual_fit_ndgf",      &residual_fit_ndgf,      "residual_fit_ndgf/I");
00405    StripResultsTree -> Branch("residual_fit_result",    &residual_fit_result,    "residual_fit_result/I");
00406 
00407    StripResultsTree -> Branch("rot_res_fit_result",   &rot_res_fit_result,   "rot_res_fit_result/I");
00408    StripResultsTree -> Branch("rot_res_fit_par0",     &rot_res_fit_par0,     "rot_res_fit_par0/D");
00409    StripResultsTree -> Branch("rot_res_fit_par1",     &rot_res_fit_par1,     "rot_res_fit_par1/D");
00410    StripResultsTree -> Branch("rot_res_fit_err_par0", &rot_res_fit_err_par0, "rot_res_fit_err_par0/D");
00411    StripResultsTree -> Branch("rot_res_fit_err_par1", &rot_res_fit_err_par1, "rot_res_fit_err_par1/D");
00412    StripResultsTree -> Branch("rot_res_fit_chi2",     &rot_res_fit_chi2,     "rot_res_fit_chi2/D");
00413    StripResultsTree -> Branch("rot_res_fit_ndgf",     &rot_res_fit_ndgf,     "rot_res_fit_ndgf/I");
00414 
00415    StripResultsTree -> Branch("charge_mean",     &charge_mean,    "charge_mean/D");
00416    StripResultsTree -> Branch("charge_rms",      &charge_rms,      "charge_rms/D");
00417    StripResultsTree -> Branch("charge_hentries", &charge_hentries, "charge_hentries/D");
00418    StripResultsTree -> Branch("charge_overflow", &charge_overflow, "charge_overflow/D");
00419 
00420    StripResultsTree -> Branch("pc_charge_mean",     &pc_charge_mean,     "pc_charge_mean/D");
00421    StripResultsTree -> Branch("pc_charge_rms",      &pc_charge_rms,      "pc_charge_rms/D");
00422    StripResultsTree -> Branch("pc_charge_hentries", &pc_charge_hentries,  "pc_charge_hentries/D");
00423    StripResultsTree -> Branch("pc_charge_overflow", &pc_charge_overflow, "pc_charge_overflow/D");
00424 
00425    StripResultsTree -> Branch("cand_charge_mean",     &cand_charge_mean,     "cand_charge_mean/D");
00426    StripResultsTree -> Branch("cand_charge_rms",      &cand_charge_rms,      "cand_charge_rms/D");
00427    StripResultsTree -> Branch("cand_charge_hentries", &cand_charge_hentries, "cand_charge_hentries/D");
00428    StripResultsTree -> Branch("cand_charge_overflow", &cand_charge_overflow, "cand_charge_overflow/D");
00429 
00430    StripResultsTree -> Branch("mean_of_res_means",   &mean_of_res_means,   "mean_of_res_means/D");
00431    StripResultsTree -> Branch("mean_of_res_sigmas",  &mean_of_res_sigmas,  "mean_of_res_sigmas/D");
00432    StripResultsTree -> Branch("mean_of_res_sizes",   &mean_of_res_sizes,   "mean_of_res_sizes/D");
00433    StripResultsTree -> Branch("sigma_of_res_means",  &sigma_of_res_means,  "sigma_of_res_means/D");
00434    StripResultsTree -> Branch("sigma_of_res_sigmas", &sigma_of_res_sigmas, "sigma_of_res_sigmas/D");
00435    StripResultsTree -> Branch("sigma_of_res_sizes",  &sigma_of_res_sizes,  "sigma_of_res_sizes/D");
00436    StripResultsTree -> Branch("number_of_subsets",   &number_of_subsets,   "number_of_subsets/i");
00437  
00438    for(map<PlexStripEndId, AlignmentStripHistograms>::iterator itr = fmStripHistograms.begin(); 
00439        itr != fmStripHistograms.end(); ++itr)
00440    {
00441       PlexStripEndId plexid = itr -> first;
00442       plane    = plexid.GetPlane();
00443       strip    = plexid.GetStrip();
00444       plexseid = plexid.GetEncoded();
00445 
00446       AlignmentStripHistograms &strip_hist = itr -> second;      
00447 
00448       //save histogram parameters
00449       TH1D *h_residual = strip_hist.GetResidualHistogram();
00450       residual_mean     = h_residual -> GetMean();
00451       residual_rms      = h_residual -> GetRMS();
00452       residual_hentries = h_residual -> GetEntries();
00453 
00454       if(residual_hentries > fMinResHistEntriesForFit)
00455       {
00456          //create gaussian fit function
00457          const int maxbin    = h_residual -> GetMaximumBin();
00458          const Double_t maxv = h_residual -> GetBinContent(maxbin);
00459          char function[100];
00460          sprintf(function, "functionp%03ds%03d", plane, strip);
00461 
00462          //fit strip residual histogram
00463          const double lower_limit =  residual_mean - 2*residual_rms;
00464          const double upper_limit =  residual_mean + 2*residual_rms;
00465          TF1 *f =  new TF1(function, "gaus",lower_limit, upper_limit);
00466          f -> SetParameters(maxv, residual_mean, residual_rms);
00467          residual_fit_result = h_residual -> Fit(function, "RQI");
00468          
00469          //save fit results
00470          residual_fit_mean      = f -> GetParameter(1);
00471          residual_fit_sigma     = f -> GetParameter(2);
00472          residual_fit_par0      = f -> GetParameter(0);
00473          residual_fit_err_mean  = f -> GetParError(1);
00474          residual_fit_err_sigma = f -> GetParError(2);
00475          residual_fit_err_par0  = f -> GetParError(0);
00476          residual_fit_chi2      = f -> GetChisquare();
00477          residual_fit_ndgf      = f -> GetNDF();
00478       }
00479       else
00480       {
00481          residual_fit_result    = -1;
00482          residual_fit_mean      = -1.0;
00483          residual_fit_sigma     = -1.0;
00484          residual_fit_par0      = -1.0;
00485          residual_fit_err_mean  = -1.0;
00486          residual_fit_err_sigma = -1.0;
00487          residual_fit_err_par0  = -1.0;
00488          residual_fit_chi2      = -1.0;
00489          residual_fit_ndgf      = -1;
00490       }
00491 
00492       TProfile *p_rot_res = strip_hist.GetRotationalHistogram();
00493       if(p_rot_res -> GetEntries() > fMinStripRotResHistEntriesForFit)
00494       {
00495          //create fit function
00496          char function[80];
00497          sprintf(function,"FitRotResInPlane%03dStrip%03d", plane, strip);
00498          TF1 *f =  new TF1(function, "pol1");
00499 
00500          //fit strip rotaional residual TProfile
00501          rot_res_fit_result   = p_rot_res -> Fit(function, "QI");
00502          rot_res_fit_par0     = f -> GetParameter(0);
00503          rot_res_fit_par1     = f -> GetParameter(1);
00504          rot_res_fit_err_par0 = f -> GetParError(0);
00505          rot_res_fit_err_par1 = f -> GetParError(1);
00506          rot_res_fit_chi2     = f -> GetChisquare();
00507          rot_res_fit_ndgf     = f -> GetNDF();
00508       }
00509       else
00510       {
00511          rot_res_fit_result   = -1;
00512          rot_res_fit_par0     = -1.0;
00513          rot_res_fit_par1     = -1.0;
00514          rot_res_fit_err_par0 = -1.0;
00515          rot_res_fit_err_par1 = -1.0;
00516          rot_res_fit_chi2     = -1.0;
00517          rot_res_fit_ndgf     = -1;
00518       }
00519 
00520       TH1D *h_charge  = strip_hist.GetChargeHistogram();      
00521       charge_mean     = h_charge -> GetMean();
00522       charge_rms      = h_charge -> GetRMS();
00523       charge_hentries = h_charge -> GetEntries();
00524       charge_overflow = h_charge -> GetBinContent(h_charge -> GetNbinsX()+1);
00525 
00526       TH1D *h_charge_pc  = strip_hist.GetChargePathCorrHistogram();
00527       pc_charge_mean     = h_charge_pc -> GetMean();
00528       pc_charge_rms      = h_charge_pc -> GetRMS();
00529       pc_charge_hentries = h_charge_pc -> GetEntries();
00530       pc_charge_overflow = h_charge_pc -> GetBinContent(h_charge_pc -> GetNbinsX() + 1);
00531 
00532       map<PlexStripEndId, TH1D *>::iterator fit = fhCandStripCharge.find(plexid);
00533       if(fit == fhCandStripCharge.end())
00534       {
00535          MSG("Align", Msg::kDebug) << "Failed to find map item." << endl;
00536          cand_charge_mean     = -1.0; 
00537          cand_charge_rms      = -1.0; 
00538          cand_charge_hentries = -1.0; 
00539          cand_charge_overflow = -1.0;
00540       }
00541       else 
00542       {
00543          TH1D *h_cand_charge = fit -> second;
00544          cand_charge_mean     = h_cand_charge -> GetMean();
00545          cand_charge_rms      = h_cand_charge -> GetRMS();
00546          cand_charge_hentries = h_cand_charge -> GetEntries();
00547          cand_charge_overflow = h_cand_charge -> GetBinContent(h_cand_charge -> GetNbinsX() + 1);
00548       }
00549 
00550       map<PlexStripEndId, SubsetStat>::iterator mean_it = strip_subset_mean.find(plexid);
00551       if(mean_it == strip_subset_mean.end())
00552       {
00553          if(fFluctuations.GetNSubsets() > 0)
00554             MSG("Align", Msg::kWarning) << "Failed to find map item." << endl;
00555          number_of_subsets  = 0;
00556          mean_of_res_means  = -1.0;
00557          sigma_of_res_means = -1.0;
00558       } 
00559       else
00560       {
00561          SubsetStat mean_stat = mean_it -> second;
00562          number_of_subsets    = mean_stat.GetSize();
00563          mean_of_res_means    = mean_stat.GetMean();
00564          sigma_of_res_means   = mean_stat.GetSigma();
00565       }
00566       
00567       map<PlexStripEndId, SubsetStat>::iterator sigma_it = strip_subset_sigma.find(plexid);
00568       if(sigma_it == strip_subset_sigma.end())
00569       {
00570          if(fFluctuations.GetNSubsets() > 0)
00571             MSG("Align", Msg::kWarning) << "Failed to find map item." << endl;
00572          mean_of_res_sigmas  = -1.0;
00573          sigma_of_res_sigmas = -1.0;
00574       }
00575       else
00576       {
00577          SubsetStat sigma_stat = sigma_it -> second;
00578          mean_of_res_sigmas    = sigma_stat.GetMean();
00579          sigma_of_res_sigmas   = sigma_stat.GetSigma();
00580       }
00581 
00582       map<PlexStripEndId, SubsetStat>::iterator size_it = strip_subset_size.find(plexid);
00583       if(size_it == strip_subset_size.end())
00584       {
00585          if(fFluctuations.GetNSubsets() > 0)
00586             MSG("Align", Msg::kWarning) << "Failed to find map item." << endl;
00587          mean_of_res_sizes  = -1.0;
00588          sigma_of_res_sizes = -1.0;
00589       }
00590       else
00591       {
00592          SubsetStat size_stat = size_it -> second;
00593          mean_of_res_sizes    = size_stat.GetMean();
00594          sigma_of_res_sizes   = size_stat.GetSigma();
00595       }
00596 
00597       //finally... fill that tree...
00598       StripResultsTree -> Fill();
00599    }
00600 
00601    //-----------------------------------------------------------------------------------------
00602 
00603    MSG("Align", Msg::kInfo) << "Processing statistical subset data for strip charges..." << endl;   
00604 
00605    TTree *StripChargeTree = new TTree("StripChargeSubset","Strip charge subsets");
00606    StripChargeTree -> SetDirectory(fRootFile);
00607    StripChargeTree -> Branch("mean", &mean, "mean/D");
00608    StripChargeTree -> Branch("sigma", &sigma, "sigma/D");
00609    StripChargeTree -> Branch("size", &size, "size/i");
00610    StripChargeTree -> Branch("nsubset", &nsubset, "nsubset/i");
00611    StripChargeTree -> Branch("plane", &plane, "plane/I");   
00612    StripChargeTree -> Branch("strip", &strip, "strip/I");   
00613    StripChargeTree -> Branch("plexseid", &plexseid, "plexseid/i");
00614 
00615    map<unsigned int, map<PlexStripEndId, SubsetSummary> > charge_fluc = fFluctuations.GetStripChargeSample();
00616    
00617    for(map<unsigned int, map<PlexStripEndId, SubsetSummary> >::const_iterator it = charge_fluc.begin();
00618        it != charge_fluc.end(); ++it)
00619    {
00620       nsubset = it -> first;
00621       map<PlexStripEndId, SubsetSummary> stripsample = it -> second;
00622       
00623       for(map<PlexStripEndId, SubsetSummary>::const_iterator sit = stripsample.begin();
00624           sit != stripsample.end(); ++sit)
00625       {
00626          PlexStripEndId plexid = sit -> first;
00627          SubsetSummary summary = sit -> second;
00628          plane    = plexid.GetPlane();
00629          strip    = plexid.GetStrip();
00630          plexseid = plexid.GetEncoded();
00631          mean     = summary.mean;
00632          sigma    = summary.sigma;
00633          size     = summary.size;
00634          StripChargeTree -> Fill();
00635       }
00636    }
00637 
00638    MSG("Align", Msg::kInfo) << "AlignmentAlgorithm::AnalyzeStripResidualHistograms()... Done" << endl;
00639 }

void AlignmentAlgorithm::Fill ( const AlignmentStrip astrip  ) 

Definition at line 153 of file AlignmentAlgorithm.cxx.

References fdAttenDir, fdChargeDir, fdMdlResDir, fdOccupancyDir, fdResidualDir, fdRotResDir, fFluctuations, StatisticalFluctuations::Fill(), AlignmentStripHistograms::FillHistograms(), fMdlResLimit, fmModuleResidual, fmStripHistograms, fNMdlResBins, fpMdlRotationalResidual, fpPlaneRotationalResidual, PlexScintMdlId::GetModule(), PlexPlaneId::GetPlane(), PlexStripEndId::GetScintMdlId(), AlignmentStrip::ghitpos, AlignmentStrip::goodhit, AlignmentStrip::lhitpos, AlignmentStrip::lposrelmdl, AlignmentStrip::plexseid, and AlignmentStrip::residual.

Referenced by AnalyzeModuleResiduals(), AnalyzeStripData(), FillCandStrip(), FitPlaneRotRes(), and FitStripAttenuationHistograms().

00154 {
00155    PlexStripEndId plexid(astrip.plexseid);
00156    PlexScintMdlId plexmdlid = plexid.GetScintMdlId();
00157 
00158    map<PlexStripEndId, AlignmentStripHistograms>::iterator fit = fmStripHistograms.find(plexid);
00159    if(fit == fmStripHistograms.end())
00160    {     
00161       AlignmentStripHistograms strip(fdResidualDir,
00162                                      fdChargeDir,
00163                                      fdAttenDir,
00164                                      fdOccupancyDir,
00165                                      fdRotResDir, 
00166                                      astrip);
00167       
00168       strip.FillHistograms(astrip);
00169 
00170       pair<PlexStripEndId, AlignmentStripHistograms> p(plexid, strip);
00171       fmStripHistograms.insert(p);
00172    }
00173    else (fit->second).FillHistograms(astrip);
00174 
00175    fFluctuations.Fill(astrip);
00176    
00177    if(astrip.goodhit){
00178       fpMdlRotationalResidual[plexmdlid] -> Fill(astrip.lhitpos+astrip.lposrelmdl, astrip.residual);
00179       fpPlaneRotationalResidual[plexid]  -> Fill(astrip.ghitpos, astrip.residual);
00180    }
00181     
00182    map<PlexScintMdlId, TH1D *>::iterator mit = fmModuleResidual.find(plexmdlid);
00183    if(mit ==  fmModuleResidual.end())
00184    {
00185       const int plane  = plexmdlid.GetPlane();
00186       const int module = plexmdlid.GetModule();
00187       char name[80], title[80];
00188       sprintf(name,"ResidualInPlane%03dModule%02d", plane, module);
00189       sprintf(title,"Residual in hit module, plane %03d, module %03d", plane, module);
00190       TH1D *h = new TH1D(name, title, fNMdlResBins, -fMdlResLimit, fMdlResLimit);
00191       h -> SetDirectory(fdMdlResDir);
00192       h -> GetXaxis() -> SetTitle("residual (m)");
00193       h -> GetXaxis() -> CenterTitle();
00194       h -> Fill(astrip.residual);
00195       fmModuleResidual[plexmdlid] = h;
00196    } else 
00197       (mit->second) -> Fill(astrip.residual);
00198 }

void AlignmentAlgorithm::FillCandStrip ( const AlignmentStrip astrip  ) 

Definition at line 201 of file AlignmentAlgorithm.cxx.

References AlignmentStrip::charge, fdNonTrackStripChargeDir, fhCandStripCharge, Fill(), fNStripChargeBins, fStripChargeLimit, PlexPlaneId::GetPlane(), PlexStripEndId::GetStrip(), Msg::kVerbose, MSG, AlignmentStrip::plexseid, and Munits::second.

00202 {
00203    
00204    PlexStripEndId plexid(astrip.plexseid);
00205    map<PlexStripEndId, TH1D *>::iterator cit = fhCandStripCharge.find(plexid);
00206    if(cit == fhCandStripCharge.end())
00207    {
00208       char name[100], title[100];
00209       int plane = plexid.GetPlane(), strip = plexid.GetStrip();
00210       sprintf(name,"CandChargeInPlane%03dStrip%03d", plane, strip);
00211       sprintf(title,"Candidate charge plane %03d, strip %03d", plane, strip);
00212       MSG("Align", Msg::kVerbose) << "Creating histogram " << name << endl;
00213       TH1D *h = new TH1D(name, title, fNStripChargeBins, 0.0, fStripChargeLimit);
00214       h -> SetDirectory(fdNonTrackStripChargeDir);
00215       h -> GetXaxis() -> SetTitle("Raw ADC");
00216       h -> GetXaxis() -> CenterTitle();
00217       h -> Fill(astrip.charge);
00218       fhCandStripCharge[plexid] = h;
00219    } 
00220    else (cit -> second) -> Fill(astrip.charge);
00221 }

void AlignmentAlgorithm::FitPlaneRotRes (  )  [private]

Definition at line 893 of file AlignmentAlgorithm.cxx.

References Fill(), fMinRotResHistEntriesForFit, fpPlaneRotationalResidual, fRootFile, PlexPlaneId::GetPlane(), Msg::kInfo, Msg::kWarning, and MSG.

Referenced by RunAlgorithm().

00894 {   
00895    MSG("Align", Msg::kInfo) << "AlignmentAlgorithm::FitRotationalResiduals()..." << endl;
00896 
00897    if(fpPlaneRotationalResidual.empty())
00898    {
00899       MSG("Align", Msg::kWarning) << "fpPlaneRotationalResidual is empty. Bailing out."<< endl;
00900       return;
00901    }
00902    
00903    Double_t par0, par1, par0_err, par1_err, chi2, pentries;
00904    Int_t plane, fit_result, ndgf, nbin;
00905 
00906    TTree *ptree = new TTree("PlaneRotRes","Results of fitting plane rotations");
00907    ptree -> SetDirectory(fRootFile);
00908 
00909    ptree -> Branch("par0",       &par0,       "par0/D");
00910    ptree -> Branch("par1",       &par1,       "par1/D");
00911    ptree -> Branch("par0_err",   &par0_err,   "par0_err/D");
00912    ptree -> Branch("par1_err",   &par1_err,   "par1_err/D");
00913    ptree -> Branch("chi2",       &chi2,       "chi2/D");
00914    ptree -> Branch("ndgf",       &ndgf,       "ndgf/I");
00915    ptree -> Branch("nbin",       &nbin,       "nbin/I");
00916    ptree -> Branch("pentries",   &pentries,   "pentries/D");
00917    ptree -> Branch("plane",      &plane,      "plane/I");   
00918    ptree -> Branch("fit_result", &fit_result, "fit_result/I");   
00919 
00920    for(map<PlexPlaneId, TProfile *>::iterator pit = fpPlaneRotationalResidual.begin();
00921        pit != fpPlaneRotationalResidual.end(); ++pit){
00922       
00923       PlexPlaneId plexid = pit -> first;
00924       plane = plexid.GetPlane();
00925 
00926       TProfile *p = pit->second;
00927       
00928       if(p->GetEntries() < fMinRotResHistEntriesForFit) continue;
00929 
00930       char function[80];
00931       sprintf(function,"FitRotResInPlane%03d", plane);
00932       TF1 *f =  new TF1(function, "pol1");
00933       fit_result = p -> Fit(function, "QI");
00934       par0       = f -> GetParameter(0);
00935       par1       = f -> GetParameter(1);
00936       par0_err   = f -> GetParError(0);
00937       par1_err   = f -> GetParError(1);
00938       chi2       = f -> GetChisquare();
00939       ndgf       = f -> GetNDF();
00940       pentries   = p -> GetEntries();
00941 
00942       ptree -> Fill();
00943    }   
00944 
00945    MSG("Align", Msg::kInfo) << "AlignmentAlgorithm::FitRotationalResiduals()... Done" << endl;
00946 }

void AlignmentAlgorithm::FitStripAttenuationHistograms (  ) 

Definition at line 950 of file AlignmentAlgorithm.cxx.

References Fill(), fMinAttenHistEntriesForFit, fmStripHistograms, fRootFile, fStripAttenPar0, PlexStripEndId::GetEncoded(), PlexPlaneId::GetPlane(), PlexStripEndId::GetStrip(), Msg::kInfo, Msg::kWarning, and MSG.

00951 {   
00952    MSG("Align", Msg::kInfo) << "AlignmentAlgorithm::FitStripAttenuationHistograms()..."<<endl;
00953    
00954    if(fmStripHistograms.empty()){
00955       MSG("Align", Msg::kWarning) << "fmStripHistograms is empty. Bailing out."<< endl;
00956       return;
00957    }
00958       
00959    TTree *stree = new TTree("StripAttenuation","StripAttenuation");
00960    stree -> SetDirectory(fRootFile);
00961 
00962    Double_t par0, par1, par0_err, par1_err, chi2, pentries;
00963    UInt_t plexseid;
00964    Int_t plane, strip, fit_result, ndgf, nbin;
00965 
00966    stree -> Branch("plane",      &plane,      "plane/I");   
00967    stree -> Branch("strip",      &strip,      "strip/I"); 
00968    stree -> Branch("plexseid",   &plexseid,   "plexseid/i");
00969    stree -> Branch("par0",       &par0,       "par0/D");
00970    stree -> Branch("par1",       &par1,       "par1/D");
00971    stree -> Branch("par0_err",   &par0_err,   "par0_err/D");
00972    stree -> Branch("par1_err",   &par1_err,   "par1_err/D");
00973    stree -> Branch("chi2",       &chi2,       "chi2/D");
00974    stree -> Branch("ndgf",       &ndgf,       "ndgf/I");
00975    stree -> Branch("nbin",       &nbin,       "nbin/I");
00976    stree -> Branch("fit_result", &fit_result, "fit_result/I");
00977    stree -> Branch("pentries",   &pentries,   "pentries/D");
00978    
00979    for(map<PlexStripEndId, AlignmentStripHistograms>::iterator sit = fmStripHistograms.begin();
00980        sit != fmStripHistograms.end(); ++sit){
00981        
00982       TProfile *p = (sit->second).GetAttenHistogram();
00983       nbin        = p -> GetNbinsX();
00984       pentries    = p -> GetEntries();
00985 
00986       if(pentries < fMinAttenHistEntriesForFit) continue;
00987       
00988       PlexStripEndId plexid = sit->first;
00989       plane    = plexid.GetPlane();
00990       strip    = plexid.GetStrip();
00991       plexseid = plexid.GetEncoded();
00992 
00993       //create function
00994       char function[100];
00995       sprintf(function,"StripAttenuationPlane%03dStrip%03d", plane, strip);
00996       TF1 *f =  new TF1(function, "expo");
00997       f -> SetParameters(fStripAttenPar0, fStripAttenPar0);
00998 
00999       //fit TProfile and save results
01000       fit_result = p -> Fit(function, "QIB");
01001       par0       = f -> GetParameter(0);
01002       par1       = f -> GetParameter(1);
01003       par0_err   = f -> GetParError(0);
01004       par1_err   = f -> GetParError(1);
01005       chi2       = f -> GetChisquare();
01006       ndgf       = f -> GetNDF();
01007 
01008       stree -> Fill();
01009    }   
01010 
01011    MSG("Align", Msg::kInfo) << "AlignmentAlgorithm::FitStripAttenuationHistograms()... Done"<<endl;
01012 }

TProfile * AlignmentAlgorithm::GetMdlRotationalResidualHistogram ( int  plane,
int  module,
double  low,
double  high 
) [private]

Definition at line 1016 of file AlignmentAlgorithm.cxx.

References fdMdlRotResDir, and fMdlRotResBinWidth.

Referenced by AlignmentAlgorithm().

01017 {
01018    char name[100], title[100];
01019    sprintf(name,"RotResidualInPlane%03dModule%03d", plane, module);
01020    sprintf(title,"Profile rotational residuals plane %03d module %03d", plane, module);
01021    int nbin = int(fabs(high-low)/fMdlRotResBinWidth);
01022 
01023    TProfile *p = new TProfile(name, title, nbin, low, high);
01024    p -> SetDirectory(fdMdlRotResDir);
01025    p -> GetXaxis() -> SetTitle("position (m)");
01026    p -> GetXaxis() -> CenterTitle();
01027    p -> GetYaxis() -> SetTitle("residual (m)");
01028    p -> GetYaxis() -> CenterTitle();
01029    return p;
01030 }

TProfile * AlignmentAlgorithm::GetPlaneRotationalResidualHistogram ( int  plane,
double  low,
double  high 
) [private]

Definition at line 1033 of file AlignmentAlgorithm.cxx.

References fdPlaneRotResDir, and fPlaneRotResBinWidth.

Referenced by AlignmentAlgorithm().

01034 {
01035    char name[100], title[100];
01036    sprintf(name,"RotResidualInPlane%03d", plane);
01037    sprintf(title,"Profile rotational residuals plane %03d", plane);
01038    int nbin = int(2.0*fabs(high-low)/fPlaneRotResBinWidth);
01039 
01040    TProfile *p = new TProfile(name, title, nbin, low, high);
01041    p -> SetDirectory(fdPlaneRotResDir);
01042    p -> GetXaxis() -> SetTitle("position (m)");
01043    p -> GetXaxis() -> CenterTitle();
01044    p -> GetYaxis() -> SetTitle("residual (m)");
01045    p -> GetYaxis() -> CenterTitle();
01046    return p;
01047 }

void AlignmentAlgorithm::ResetSubset ( const VldContext vldc,
const int  ntracks 
) [inline]

Definition at line 53 of file AlignmentAlgorithm.h.

References fFluctuations, and StatisticalFluctuations::Reset().

00053 {fFluctuations.Reset(vldc, ntracks);};

void AlignmentAlgorithm::RunAlgorithm (  ) 

Definition at line 225 of file AlignmentAlgorithm.cxx.

References AnalyzeModuleResiduals(), AnalyzeStripData(), fAlignmentAlgorithmCompleted, FitPlaneRotRes(), Msg::kInfo, Msg::kWarning, and MSG.

00226 {
00227    MSG("Align", Msg::kInfo) << "AlignmentAlgorithm()::RunAlgorithm()..." << endl;
00228 
00229    if(fAlignmentAlgorithmCompleted)
00230    {
00231       MSG("Align", Msg::kWarning) << "AlignmentAlgorithm has already been done! Bailing out..." << endl;
00232       return;
00233    }
00234    else
00235       fAlignmentAlgorithmCompleted = true;
00236 
00237    AnalyzeStripData();
00238  
00239    AnalyzeModuleResiduals();
00240    
00241    FitPlaneRotRes();
00242 }


Member Data Documentation

Definition at line 99 of file AlignmentAlgorithm.h.

Referenced by RunAlgorithm().

TDirectory* AlignmentAlgorithm::fdAttenDir [private]

Definition at line 69 of file AlignmentAlgorithm.h.

Referenced by AlignmentAlgorithm(), and Fill().

TDirectory* AlignmentAlgorithm::fdChargeDir [private]

Definition at line 68 of file AlignmentAlgorithm.h.

Referenced by AlignmentAlgorithm(), and Fill().

TDirectory* AlignmentAlgorithm::fdMdlResDir [private]

Definition at line 63 of file AlignmentAlgorithm.h.

Referenced by AlignmentAlgorithm(), and Fill().

TDirectory* AlignmentAlgorithm::fdMdlRotResDir [private]

Definition at line 64 of file AlignmentAlgorithm.h.

Referenced by AlignmentAlgorithm(), and GetMdlRotationalResidualHistogram().

Definition at line 62 of file AlignmentAlgorithm.h.

Referenced by AlignmentAlgorithm(), and FillCandStrip().

TDirectory* AlignmentAlgorithm::fdOccupancyDir [private]

Definition at line 70 of file AlignmentAlgorithm.h.

Referenced by AlignmentAlgorithm(), and Fill().

TDirectory* AlignmentAlgorithm::fdPlaneRotResDir [private]

Definition at line 65 of file AlignmentAlgorithm.h.

Referenced by AlignmentAlgorithm(), and GetPlaneRotationalResidualHistogram().

TDirectory* AlignmentAlgorithm::fdResidualDir [private]

Definition at line 67 of file AlignmentAlgorithm.h.

Referenced by AlignmentAlgorithm(), and Fill().

TDirectory* AlignmentAlgorithm::fdRotResDir [private]

Definition at line 71 of file AlignmentAlgorithm.h.

Referenced by AlignmentAlgorithm(), and Fill().

Definition at line 82 of file AlignmentAlgorithm.h.

Referenced by AnalyzeModuleResiduals(), AnalyzeStripData(), Fill(), and ResetSubset().

Definition at line 97 of file AlignmentAlgorithm.h.

Referenced by AnalyzeStripData(), and FillCandStrip().

const Double_t AlignmentAlgorithm::fMdlResLimit [private]

Definition at line 104 of file AlignmentAlgorithm.h.

Referenced by Fill().

const Double_t AlignmentAlgorithm::fMdlRotResBinWidth [private]

Definition at line 105 of file AlignmentAlgorithm.h.

Referenced by GetMdlRotationalResidualHistogram().

Definition at line 107 of file AlignmentAlgorithm.h.

Referenced by FitStripAttenuationHistograms().

Definition at line 106 of file AlignmentAlgorithm.h.

Referenced by AnalyzeStripData().

Definition at line 108 of file AlignmentAlgorithm.h.

Referenced by AnalyzeModuleResiduals(), and FitPlaneRotRes().

Definition at line 109 of file AlignmentAlgorithm.h.

Referenced by AnalyzeStripData().

Definition at line 85 of file AlignmentAlgorithm.h.

Referenced by AnalyzeModuleResiduals(), and Fill().

const Int_t AlignmentAlgorithm::fNMdlResBins [private]

Definition at line 102 of file AlignmentAlgorithm.h.

Referenced by Fill().

Definition at line 101 of file AlignmentAlgorithm.h.

Referenced by FillCandStrip().

const Double_t AlignmentAlgorithm::fPlaneRotResBinWidth [private]

Definition at line 110 of file AlignmentAlgorithm.h.

Referenced by GetPlaneRotationalResidualHistogram().

Definition at line 91 of file AlignmentAlgorithm.h.

Referenced by AlignmentAlgorithm(), AnalyzeModuleResiduals(), and Fill().

Definition at line 94 of file AlignmentAlgorithm.h.

Referenced by AlignmentAlgorithm(), Fill(), and FitPlaneRotRes().

const Double_t AlignmentAlgorithm::fStripAttenPar0 [private]

Definition at line 113 of file AlignmentAlgorithm.h.

Referenced by FitStripAttenuationHistograms().

const Double_t AlignmentAlgorithm::fStripAttenPar1 [private]

Definition at line 114 of file AlignmentAlgorithm.h.

const Double_t AlignmentAlgorithm::fStripChargeLimit [private]

Definition at line 103 of file AlignmentAlgorithm.h.

Referenced by FillCandStrip().


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

Generated on 22 May 2017 for loon by  doxygen 1.6.1