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

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

AlignmentAlgorithm::~AlignmentAlgorithm  )  [virtual]
 

Definition at line 1048 of file AlignmentAlgorithm.cxx.

References MSG.

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


Member Function Documentation

void AlignmentAlgorithm::AnalyzeModuleResiduals  )  [private]
 

Definition at line 641 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().

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

void AlignmentAlgorithm::AnalyzeStripData  )  [private]
 

Definition at line 243 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().

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

void AlignmentAlgorithm::Fill const AlignmentStrip astrip  ) 
 

Definition at line 151 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().

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

void AlignmentAlgorithm::FillCandStrip const AlignmentStrip astrip  ) 
 

Definition at line 199 of file AlignmentAlgorithm.cxx.

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

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

void AlignmentAlgorithm::FitPlaneRotRes  )  [private]
 

Definition at line 891 of file AlignmentAlgorithm.cxx.

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

Referenced by RunAlgorithm().

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

void AlignmentAlgorithm::FitStripAttenuationHistograms  ) 
 

Definition at line 948 of file AlignmentAlgorithm.cxx.

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

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

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

Definition at line 1014 of file AlignmentAlgorithm.cxx.

References fdMdlRotResDir, and fMdlRotResBinWidth.

Referenced by AlignmentAlgorithm().

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

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

Definition at line 1031 of file AlignmentAlgorithm.cxx.

References fdPlaneRotResDir, and fPlaneRotResBinWidth.

Referenced by AlignmentAlgorithm().

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

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 223 of file AlignmentAlgorithm.cxx.

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

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


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 Fri Mar 28 15:53:51 2008 for loon by  doxygen 1.3.9.1