Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

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, AlignmentStripHistogramsfmStripHistograms
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


Constructor & Destructor Documentation

AlignmentAlgorithm::AlignmentAlgorithm TFile *  rootfile,
const VldContext  vldc
 

Definition at line 49 of file AlignmentAlgorithm.cxx.

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

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

AlignmentAlgorithm::~AlignmentAlgorithm  )  [virtual]
 

Definition at line 1049 of file AlignmentAlgorithm.cxx.

References MSG.

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


Member Function Documentation

void AlignmentAlgorithm::AnalyzeModuleResiduals  )  [private]
 

Definition at line 642 of file AlignmentAlgorithm.cxx.

References fFluctuations, SubsetStat::Fill(), Fill(), fmModuleResidual, fmStripHistograms, fpMdlRotationalResidual, fRootFile, PlexScintMdlId::GetEncoded(), SubsetStat::GetMean(), PlexScintMdlId::GetModule(), StatisticalFluctuations::GetModuleResidualSample(), StatisticalFluctuations::GetNSubsets(), PlexPlaneId::GetPlane(), SubsetStat::GetSigma(), SubsetStat::GetSize(), SubsetSummary::mean, MSG, SubsetSummary::sigma, and SubsetSummary::size.

Referenced by RunAlgorithm().

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

void AlignmentAlgorithm::AnalyzeStripData  )  [private]
 

Definition at line 244 of file AlignmentAlgorithm.cxx.

References fFluctuations, fhCandStripCharge, SubsetStat::Fill(), Fill(), 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(), SubsetSummary::mean, MSG, SubsetSummary::sigma, and SubsetSummary::size.

Referenced by RunAlgorithm().

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

void AlignmentAlgorithm::Fill const AlignmentStrip astrip  ) 
 

Definition at line 152 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(), AlignmentStrip::ghitpos, AlignmentStrip::goodhit, AlignmentStrip::lhitpos, AlignmentStrip::lposrelmdl, AlignmentStrip::plexseid, and AlignmentStrip::residual.

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

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

void AlignmentAlgorithm::FillCandStrip const AlignmentStrip astrip  ) 
 

Definition at line 200 of file AlignmentAlgorithm.cxx.

References AlignmentStrip::charge, fdNonTrackStripChargeDir, fhCandStripCharge, Fill(), fNStripChargeBins, fStripChargeLimit, PlexPlaneId::GetPlane(), MSG, and AlignmentStrip::plexseid.

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

void AlignmentAlgorithm::FitPlaneRotRes  )  [private]
 

Definition at line 892 of file AlignmentAlgorithm.cxx.

References Fill(), fpPlaneRotationalResidual, fRootFile, PlexPlaneId::GetPlane(), and MSG.

Referenced by RunAlgorithm().

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

void AlignmentAlgorithm::FitStripAttenuationHistograms  ) 
 

Definition at line 949 of file AlignmentAlgorithm.cxx.

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

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

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

Definition at line 1015 of file AlignmentAlgorithm.cxx.

References fdMdlRotResDir, and fMdlRotResBinWidth.

Referenced by AlignmentAlgorithm().

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

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

Definition at line 1032 of file AlignmentAlgorithm.cxx.

References fdPlaneRotResDir, and fPlaneRotResBinWidth.

Referenced by AlignmentAlgorithm().

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

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

Definition at line 53 of file AlignmentAlgorithm.h.

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

void AlignmentAlgorithm::RunAlgorithm  ) 
 

Definition at line 224 of file AlignmentAlgorithm.cxx.

References AnalyzeModuleResiduals(), AnalyzeStripData(), fAlignmentAlgorithmCompleted, FitPlaneRotRes(), and MSG.

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


Member Data Documentation

bool AlignmentAlgorithm::fAlignmentAlgorithmCompleted [private]
 

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().

TDirectory* AlignmentAlgorithm::fdNonTrackStripChargeDir [private]
 

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().

StatisticalFluctuations AlignmentAlgorithm::fFluctuations [private]
 

Definition at line 82 of file AlignmentAlgorithm.h.

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

map<PlexStripEndId, TH1D *> AlignmentAlgorithm::fhCandStripCharge [private]
 

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().

const Double_t AlignmentAlgorithm::fMinAttenHistEntriesForFit [private]
 

Definition at line 107 of file AlignmentAlgorithm.h.

const Double_t AlignmentAlgorithm::fMinResHistEntriesForFit [private]
 

Definition at line 106 of file AlignmentAlgorithm.h.

const Double_t AlignmentAlgorithm::fMinRotResHistEntriesForFit [private]
 

Definition at line 108 of file AlignmentAlgorithm.h.

const Double_t AlignmentAlgorithm::fMinStripRotResHistEntriesForFit [private]
 

Definition at line 109 of file AlignmentAlgorithm.h.

map<PlexScintMdlId, TH1D *> AlignmentAlgorithm::fmModuleResidual [private]
 

Definition at line 85 of file AlignmentAlgorithm.h.

Referenced by AnalyzeModuleResiduals(), and Fill().

map<PlexStripEndId, AlignmentStripHistograms> AlignmentAlgorithm::fmStripHistograms [private]
 

Definition at line 88 of file AlignmentAlgorithm.h.

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

const Int_t AlignmentAlgorithm::fNMdlResBins [private]
 

Definition at line 102 of file AlignmentAlgorithm.h.

Referenced by Fill().

const Int_t AlignmentAlgorithm::fNStripChargeBins [private]
 

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().

map<PlexScintMdlId, TProfile *> AlignmentAlgorithm::fpMdlRotationalResidual [private]
 

Definition at line 91 of file AlignmentAlgorithm.h.

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

map<PlexPlaneId, TProfile *> AlignmentAlgorithm::fpPlaneRotationalResidual [private]
 

Definition at line 94 of file AlignmentAlgorithm.h.

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

TFile* AlignmentAlgorithm::fRootFile [private]
 

Definition at line 61 of file AlignmentAlgorithm.h.

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

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 Mon Feb 15 11:08:32 2010 for loon by  doxygen 1.3.9.1