Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:44:23

0001 #include "TChain.h"
0002 #include "TClonesArray.h"
0003 
0004 void CocoaAna() {
0005 
0006   gSystem->CompileMacro("NtupleObjects.cc","k"); // This file is in CocoaAnalysis/src/
0007 
0008   TChain* chain = new TChain("CocoaTree");
0009   chain->AddFile("report.root",TChain::kBigNumber);
0010 
0011   double chi2meas;
0012   double chi2cal;
0013   int ndof;
0014   int nfitparam;
0015   int noptobj;
0016   int nsensor2d;
0017   int ndistancemeter;
0018   int ndistancemeter1dim;
0019   int ntiltmeter;
0020   int ncops;
0021 
0022   chain->SetBranchAddress("Chi2Measurements",   &chi2meas);
0023   chain->SetBranchAddress("Chi2CalibratedParameters",   &chi2cal);
0024   chain->SetBranchAddress("NDegreesOfFreedom",  &ndof);
0025   chain->SetBranchAddress("NFitParameters",     &nfitparam);
0026   chain->SetBranchAddress("NOptObjects",        &noptobj);
0027   chain->SetBranchAddress("NSensor2D",          &nsensor2d);
0028   chain->SetBranchAddress("NDistancemeter",     &ndistancemeter);
0029   chain->SetBranchAddress("NDistancemeter1Dim", &ndistancemeter1dim);
0030   chain->SetBranchAddress("NTiltmeter",         &ntiltmeter);
0031   chain->SetBranchAddress("NCops",              &ncops);
0032 
0033   TClonesArray* FitParamA              = new TClonesArray("FitParam");
0034   TClonesArray* OptObjectA             = new TClonesArray("OptObject");
0035   TClonesArray* Sensor2DMeasA          = new TClonesArray("Sensor2DMeas");
0036   TClonesArray* DistancemeterMeasA     = new TClonesArray("DistancemeterMeas");
0037   TClonesArray* Distancemeter1DimMeasA = new TClonesArray("Distancemeter1DimMeas");
0038   TClonesArray* TiltmeterMeasA         = new TClonesArray("TiltmeterMeas");
0039   TClonesArray* CopsMeasA              = new TClonesArray("CopsMeas");
0040 
0041   chain->SetBranchAddress("FitParameters",                  &FitParamA);
0042   chain->SetBranchAddress("OptObjects",                     &OptObjectA);
0043   chain->SetBranchAddress("Sensor2DMeasurements",           &Sensor2DMeasA);
0044   chain->SetBranchAddress("DistancemeterMeasurements",      &DistancemeterMeasA);
0045   chain->SetBranchAddress("Distancemeter1DimMeasurements",  &Distancemeter1DimMeasA);
0046   chain->SetBranchAddress("TiltmeterMeasurements",          &TiltmeterMeasA);
0047   chain->SetBranchAddress("CopsMeasurements",               &CopsMeasA);
0048 
0049   int nEvents = chain -> GetEntries();
0050   int counter = 0;
0051 
0052   for(int ev=0; ev<nEvents; ev++) {
0053 
0054     counter++;
0055 //     int lflag = chain->LoadTree(ev);
0056     chain -> GetEntry(ev);
0057     
0058 //     TBranch *bchi2meas = chain->GetBranch("Chi2Measurements");
0059 //     int nbytes = bchi2meas->GetEntry(lflag);
0060 
0061 //     TBranch *bchi2cal = chain->GetBranch("Chi2CalibratedParameters");
0062 //     int nbytes = bchi2cal->GetEntry(lflag);
0063 
0064 //     TBranch *bndof = chain->GetBranch("NDegreesOfFreedom");
0065 //     int nbytes = bndof->GetEntry(lflag);
0066 
0067 
0068 //     TBranch *bnfitparam = chain->GetBranch("NFitParameters");
0069 //     int nbytes = bnfitparam->GetEntry(lflag);
0070 
0071 //     TBranch *bfitparam = chain->GetBranch("FitParameters");
0072 //     nbytes = bfitparam->GetEntry(lflag); 
0073     
0074 //     TBranch *bnoptobj = chain->GetBranch("NOptObjects");
0075 //     int nbytes = bnoptobj->GetEntry(lflag);
0076 
0077 //     TBranch *boptobject = chain->GetBranch("OptObjects");
0078 //     nbytes = boptobject->GetEntry(lflag); 
0079     
0080 //     TBranch *bnsensor2d = chain->GetBranch("NSensor2D");
0081 //     nbytes = bnsensor2d->GetEntry(lflag);
0082 
0083 //     TBranch *bsensor2d = chain->GetBranch("Sensor2DMeasurements");
0084 //     nbytes = bsensor2d->GetEntry(lflag); 
0085     
0086 //     TBranch *bndistancemeter = chain->GetBranch("NDistancemeter");
0087 //     nbytes = bndistancemeter->GetEntry(lflag);
0088 
0089 //     TBranch *bdistancemeter = chain->GetBranch("DistancemeterMeasurements");
0090 //     nbytes = bdistancemeter->GetEntry(lflag);  
0091     
0092 //     TBranch *bndistancemeter1dim = chain->GetBranch("NDistancemeter1Dim");
0093 //     nbytes = bndistancemeter1dim->GetEntry(lflag);
0094 
0095 //     TBranch *bdistancemeter1dim = chain->GetBranch("Distancemeter1DimMeasurements");
0096 //     nbytes = bdistancemeter1dim->GetEntry(lflag); 
0097     
0098 //     TBranch *bntiltmeter = chain->GetBranch("NTiltmeter");
0099 //     nbytes = bntiltmeter->GetEntry(lflag);
0100 
0101 //     TBranch *btiltmeter = chain->GetBranch("TiltmeterMeasurements");
0102 //     nbytes = btiltmeter->GetEntry(lflag); 
0103     
0104 //     TBranch *bncops = chain->GetBranch("NCops");
0105 //     nbytes = bncops->GetEntry(lflag);
0106 
0107 //     TBranch *bcops = chain->GetBranch("CopsMeasurements");
0108 //     nbytes = bcops->GetEntry(lflag); 
0109 
0110     cout << chi2meas << " " << chi2cal << " " << ndof << endl;
0111     
0112     for (int np = 0; np<nfitparam; np++) {
0113 
0114       FitParam* fitparam = (FitParam*) FitParamA->At(np);
0115       cout << np << " " << fitparam->Name << " " << fitparam->Quality << " " << " " << fitparam->InitialValue << " " << fitparam->InitialSigma << " " << fitparam->FittedValue << " " << endl;
0116 
0117     }
0118 
0119     for (int no = 0; no<noptobj; no++) {
0120 
0121       OptObject* optobj = (OptObject*) OptObjectA->At(no);
0122       int pr = optobj->Parent; OptObject* optobjp = (OptObject*) OptObjectA->At(pr);
0123       cout << "     " << optobj->CentreGlobal[0] << " " << optobj->CentreGlobal[1] << " " << optobj->CentreGlobal[2] << "        " << optobj->CentreLocal[0] << " " << optobj->CentreLocal[1] << " " << optobj->CentreLocal[2] << endl;
0124       cout << "     " << optobj->AnglesGlobal[0] << " " << optobj->AnglesGlobal[1] << " " << optobj->AnglesGlobal[2] << "        " << optobj->AnglesLocal[0] << " " << optobj->AnglesLocal[1] << " " << optobj->AnglesLocal[2] << endl;
0125     
0126     }
0127 
0128     for (int ns = 0; ns<nsensor2d; ns++) {
0129 
0130       Sensor2DMeas* sensor2d = (Sensor2DMeas*) Sensor2DMeasA->At(ns);
0131       cout << ns << " " << sensor2d->Name << " " << sensor2d->Position[0] << " " << sensor2d->PosError[0] << " " << sensor2d->SimulatedPosition[0] << " " << sensor2d->SimulatedPosition[0]-sensor2d->Position[0] << endl;
0132 
0133     }
0134 
0135     for (int ns = 0; ns<ndistancemeter; ns++) {
0136 
0137       DistancemeterMeas* dist = (DistancemeterMeas*) DistancemeterMeasA->At(ns);
0138       cout << ns << " " << dist->Name << " " << dist->Distance << " " << dist->DisError << " " << dist->SimulatedDistance << endl;
0139 
0140     }
0141 
0142 
0143 
0144   }
0145 
0146 
0147 
0148 
0149 }