CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_0/src/Validation/Geometry/src/MaterialBudgetTree.cc

Go to the documentation of this file.
00001 #include "Validation/Geometry/interface/MaterialBudgetTree.h"
00002 #include "Validation/Geometry/interface/MaterialBudgetData.h"
00003 
00004 
00005 MaterialBudgetTree::MaterialBudgetTree(MaterialBudgetData* data, const std::string& filename ): MaterialBudgetFormat( data )
00006 {
00007   theFile = new TFile(filename.c_str(),"RECREATE");
00008   
00009   theFile->cd();
00010 
00011   book();
00012   
00013 }
00014 
00015 
00016 void MaterialBudgetTree::book() 
00017 {
00018   std::cout << "=== booking user TTree ===" << std::endl;
00019   // create the TTree
00020   theTree = new TTree("T1","GeometryTest Tree");
00021 
00022   // GENERAL block
00023   theTree->Branch("MB", &t_MB, "MB/F");
00024   theTree->Branch("IL", &t_IL, "IL/F");
00025   
00026   // rr
00027   // PARTICLE Block
00028   theTree->Branch( "Particle ID",     &t_ParticleID,     "Particle_ID/I"  );
00029   theTree->Branch( "Particle Pt",     &t_ParticlePt,     "Particle_Pt/F"  );
00030   theTree->Branch( "Particle Eta",    &t_ParticleEta,    "Particle_Eta/F" );
00031   theTree->Branch( "Particle Phi",    &t_ParticlePhi,    "Particle_Phi/F" );
00032   theTree->Branch( "Particle Energy", &t_ParticleEnergy, "Particle_E/F"   );
00033   theTree->Branch( "Particle Mass",   &t_ParticleMass,   "Particle_M/F"   );
00034   // rr
00035  
00036   if( theData->allStepsON() ) {
00037     theTree->Branch("Nsteps", &t_Nsteps, "Nsteps/I");
00038     theTree->Branch("DeltaMB", t_DeltaMB, "DeltaMB[Nsteps]/F");
00039     // rr
00040     theTree->Branch("DeltaMB_SUP", t_DeltaMB_SUP, "DeltaMB_SUP[Nsteps]/F");
00041     theTree->Branch("DeltaMB_SEN", t_DeltaMB_SEN, "DeltaMB_SEN[Nsteps]/F");
00042     theTree->Branch("DeltaMB_CAB", t_DeltaMB_CAB, "DeltaMB_CAB[Nsteps]/F");
00043     theTree->Branch("DeltaMB_COL", t_DeltaMB_COL, "DeltaMB_COL[Nsteps]/F");
00044     theTree->Branch("DeltaMB_ELE", t_DeltaMB_ELE, "DeltaMB_ELE[Nsteps]/F");
00045     theTree->Branch("DeltaMB_OTH", t_DeltaMB_OTH, "DeltaMB_OTH[Nsteps]/F");
00046     theTree->Branch("DeltaMB_AIR", t_DeltaMB_AIR, "DeltaMB_AIR[Nsteps]/F");
00047     theTree->Branch("DeltaIL", t_DeltaIL, "DeltaIL[Nsteps]/F");
00048     theTree->Branch("DeltaIL_SUP", t_DeltaIL_SUP, "DeltaIL_SUP[Nsteps]/F");
00049     theTree->Branch("DeltaIL_SEN", t_DeltaIL_SEN, "DeltaIL_SEN[Nsteps]/F");
00050     theTree->Branch("DeltaIL_CAB", t_DeltaIL_CAB, "DeltaIL_CAB[Nsteps]/F");
00051     theTree->Branch("DeltaIL_COL", t_DeltaIL_COL, "DeltaIL_COL[Nsteps]/F");
00052     theTree->Branch("DeltaIL_ELE", t_DeltaIL_ELE, "DeltaIL_ELE[Nsteps]/F");
00053     theTree->Branch("DeltaIL_OTH", t_DeltaIL_OTH, "DeltaIL_OTH[Nsteps]/F");
00054     theTree->Branch("DeltaIL_AIR", t_DeltaIL_AIR, "DeltaIL_AIR[Nsteps]/F");
00055     // rr
00056     theTree->Branch("Initial X", t_InitialX, "Initial_X[Nsteps]/D");
00057     theTree->Branch("Initial Y", t_InitialY, "Initial_Y[Nsteps]/D");
00058     theTree->Branch("Initial Z", t_InitialZ, "Initial_Z[Nsteps]/D");
00059     theTree->Branch("Final X",   t_FinalX,   "Final_X[Nsteps]/D");
00060     theTree->Branch("Final Y",   t_FinalY,   "Final_Y[Nsteps]/D");
00061     theTree->Branch("Final Z",   t_FinalZ,   "Final_Z[Nsteps]/D");
00062     // rr
00063     theTree->Branch("Volume ID",       t_VolumeID,     "VolumeID[Nsteps]/I");
00064     theTree->Branch("Volume Name",     t_VolumeName,   "VolumeName[Nsteps]/C");
00065     theTree->Branch("Volume Copy",     t_VolumeCopy,   "VolumeCopy[Nsteps]/I");
00066     theTree->Branch("Volume X",        t_VolumeX,      "VolumeX[Nsteps]/F");
00067     theTree->Branch("Volume Y",        t_VolumeY,      "VolumeY[Nsteps]/F");
00068     theTree->Branch("Volume Z",        t_VolumeZ,      "VolumeZ[Nsteps]/F");
00069     theTree->Branch("Volume X axis 1", t_VolumeXaxis1, "VolumeXaxis1[Nsteps]/F");
00070     theTree->Branch("Volume X axis 2", t_VolumeXaxis2, "VolumeXaxis2[Nsteps]/F");
00071     theTree->Branch("Volume X axis 3", t_VolumeXaxis3, "VolumeXaxis3[Nsteps]/F");
00072     theTree->Branch("Volume Y axis 1", t_VolumeYaxis1, "VolumeYaxis1[Nsteps]/F");
00073     theTree->Branch("Volume Y axis 2", t_VolumeYaxis2, "VolumeYaxis2[Nsteps]/F");
00074     theTree->Branch("Volume Y axis 3", t_VolumeYaxis3, "VolumeYaxis3[Nsteps]/F");
00075     theTree->Branch("Volume Z axis 1", t_VolumeZaxis1, "VolumeZaxis1[Nsteps]/F");
00076     theTree->Branch("Volume Z axis 2", t_VolumeZaxis2, "VolumeZaxis2[Nsteps]/F");
00077     theTree->Branch("Volume Z axis 3", t_VolumeZaxis3, "VolumeZaxis3[Nsteps]/F");
00078     
00079     theTree->Branch("Material ID",      t_MaterialID,      "MaterialID[Nsteps]/I");
00080     theTree->Branch("Material Name",    t_MaterialName,    "MaterialName[Nsteps]/C");
00081     theTree->Branch("Material X0",      t_MaterialX0,      "MaterialX0[Nsteps]/F");
00082     theTree->Branch("Material Lambda0", t_MaterialLambda0, "MaterialLambda0[Nsteps]/F");
00083     theTree->Branch("Material Density", t_MaterialDensity, "MaterialDensity[Nsteps]/F");
00084     
00085     theTree->Branch("Particle Step ID",               t_ParticleStepID,              "Step_ID[Nsteps]/I");
00086     theTree->Branch("Particle Step Initial Pt",       t_ParticleStepInitialPt,       "Step_Initial_Pt[Nsteps]/F");
00087     theTree->Branch("Particle Step Initial Eta",      t_ParticleStepInitialEta,      "Step_Initial_Eta[Nsteps]/F");
00088     theTree->Branch("Particle Step Initial Phi",      t_ParticleStepInitialPhi,      "Step_Initial_Phi[Nsteps]/F");
00089     theTree->Branch("Particle Step Initial Energy",   t_ParticleStepInitialEnergy,   "Step_Initial_E[Nsteps]/F");
00090     theTree->Branch("Particle Step Initial Px",       t_ParticleStepInitialPx,       "Step_Initial_Px[Nsteps]/F");
00091     theTree->Branch("Particle Step Initial Py",       t_ParticleStepInitialPy,       "Step_Initial_Py[Nsteps]/F");
00092     theTree->Branch("Particle Step Initial Pz",       t_ParticleStepInitialPz,       "Step_Initial_Pz[Nsteps]/F");
00093     theTree->Branch("Particle Step Initial Beta",     t_ParticleStepInitialBeta,     "Step_Initial_Beta[Nsteps]/F");
00094     theTree->Branch("Particle Step Initial Gamma",    t_ParticleStepInitialGamma,    "Step_Initial_Gamma[Nsteps]/F");
00095     theTree->Branch("Particle Step Initial Mass",     t_ParticleStepInitialMass,     "Step_Initial_Mass[Nsteps]/F");
00096     theTree->Branch("Particle Step Final Pt",         t_ParticleStepFinalPt,         "Step_Final_Pt[Nsteps]/F");
00097     theTree->Branch("Particle Step Final Eta",        t_ParticleStepFinalEta,        "Step_Final_Eta[Nsteps]/F");
00098     theTree->Branch("Particle Step Final Phi",        t_ParticleStepFinalPhi,        "Step_Final_Phi[Nsteps]/F");
00099     theTree->Branch("Particle Step Final Energy",     t_ParticleStepFinalEnergy,     "Step_Final_E[Nsteps]/F");
00100     theTree->Branch("Particle Step Final Px",         t_ParticleStepFinalPx,         "Step_Final_Px[Nsteps]/F");
00101     theTree->Branch("Particle Step Final Py",         t_ParticleStepFinalPy,         "Step_Final_Py[Nsteps]/F");
00102     theTree->Branch("Particle Step Final Pz",         t_ParticleStepFinalPz,         "Step_Final_Pz[Nsteps]/F");
00103     theTree->Branch("Particle Step Final Beta",       t_ParticleStepFinalBeta,       "Step_Final_Beta[Nsteps]/F");
00104     theTree->Branch("Particle Step Final Gamma",      t_ParticleStepFinalGamma,      "Step_Final_Gamma[Nsteps]/F");
00105     theTree->Branch("Particle Step Final Mass",       t_ParticleStepFinalMass,       "Step_Final_Mass[Nsteps]/F");
00106     theTree->Branch("Particle Step Pre Interaction",  t_ParticleStepPreInteraction,  "Step_PreInteraction[Nsteps]/I");
00107     theTree->Branch("Particle Step Post Interaction", t_ParticleStepPostInteraction, "Step_PostInteraction[Nsteps]/I");
00108     // rr
00109   }
00110   
00111   std::cout << "=== booking user TTree done ===" << std::endl;
00112   
00113 }
00114 
00115 
00116 void MaterialBudgetTree::fillStartTrack()
00117 {
00118   
00119 }
00120 
00121 
00122 void MaterialBudgetTree::fillPerStep()
00123 {
00124 }
00125 
00126 
00127 void MaterialBudgetTree::fillEndTrack()
00128 {
00129   t_MB  = theData->getTotalMB();
00130   t_IL  = theData->getTotalIL();
00131   //  t_Eta = theData->getEta();
00132   //  t_Phi = theData->getPhi();
00133 
00134   // rr
00135   t_ParticleID     = theData->getID();
00136   t_ParticlePt     = theData->getPt();
00137   t_ParticleEta    = theData->getEta();
00138   t_ParticlePhi    = theData->getPhi();
00139   t_ParticleEnergy = theData->getEnergy();
00140   t_ParticleMass   = theData->getMass();
00141   // rr
00142   
00143   // do this only if I really want to save all the steps
00144   if( theData->allStepsON() ) {
00145     t_Nsteps = theData->getNumberOfSteps();
00146     if( t_Nsteps > MAXSTEPS ) t_Nsteps = MAXSTEPS;
00147     std::cout << " Number of Steps into the tree " << t_Nsteps << std::endl;
00148     for(int ii=0;ii<t_Nsteps;ii++) {
00149       t_DeltaMB[ii] = theData->getStepDmb(ii);
00150       t_DeltaMB_SUP[ii] = theData->getSupportDmb(ii);
00151       t_DeltaMB_SEN[ii] = theData->getSensitiveDmb(ii);
00152       t_DeltaMB_CAB[ii] = theData->getCablesDmb(ii);
00153       t_DeltaMB_COL[ii] = theData->getCoolingDmb(ii);
00154       t_DeltaMB_ELE[ii] = theData->getElectronicsDmb(ii);
00155       t_DeltaMB_OTH[ii] = theData->getOtherDmb(ii);
00156       t_DeltaMB_AIR[ii] = theData->getAirDmb(ii);
00157       
00158       t_DeltaIL[ii] = theData->getStepDil(ii);
00159       t_DeltaIL_SUP[ii] = theData->getSupportDil(ii);
00160       t_DeltaIL_SEN[ii] = theData->getSensitiveDil(ii);
00161       t_DeltaIL_CAB[ii] = theData->getCablesDil(ii);
00162       t_DeltaIL_COL[ii] = theData->getCoolingDil(ii);
00163       t_DeltaIL_ELE[ii] = theData->getElectronicsDil(ii);
00164       t_DeltaIL_OTH[ii] = theData->getOtherDil(ii);
00165       t_DeltaIL_AIR[ii] = theData->getAirDil(ii);
00166 
00167       t_InitialX[ii] = theData->getStepInitialX(ii);
00168       t_InitialY[ii] = theData->getStepInitialY(ii);
00169       t_InitialZ[ii] = theData->getStepInitialZ(ii);
00170       t_FinalX[ii]   = theData->getStepFinalX(ii);
00171       t_FinalY[ii]   = theData->getStepFinalY(ii);
00172       t_FinalZ[ii]   = theData->getStepFinalZ(ii);
00173       
00174       t_VolumeID[ii]     = theData->getStepVolumeID(ii);
00175       t_VolumeName[ii]   = const_cast<char*> (theData->getStepVolumeName(ii).c_str());
00176       t_VolumeCopy[ii]   = theData->getStepVolumeCopy(ii);
00177       t_VolumeX[ii]      = theData->getStepVolumeX(ii);
00178       t_VolumeY[ii]      = theData->getStepVolumeY(ii);
00179       t_VolumeZ[ii]      = theData->getStepVolumeZ(ii);
00180       t_VolumeXaxis1[ii] = theData->getStepVolumeXaxis(ii).x();
00181       t_VolumeXaxis2[ii] = theData->getStepVolumeXaxis(ii).y();
00182       t_VolumeXaxis3[ii] = theData->getStepVolumeXaxis(ii).z();
00183       t_VolumeYaxis1[ii] = theData->getStepVolumeYaxis(ii).x();
00184       t_VolumeYaxis2[ii] = theData->getStepVolumeYaxis(ii).y();
00185       t_VolumeYaxis3[ii] = theData->getStepVolumeYaxis(ii).z();
00186       t_VolumeZaxis1[ii] = theData->getStepVolumeZaxis(ii).x();
00187       t_VolumeZaxis2[ii] = theData->getStepVolumeZaxis(ii).y();
00188       t_VolumeZaxis3[ii] = theData->getStepVolumeZaxis(ii).z();
00189       
00190       t_MaterialID[ii]        = theData->getStepMaterialID(ii);
00191       t_MaterialName[ii]      = const_cast<char*> (theData->getStepMaterialName(ii).c_str());
00192       t_MaterialX0[ii]        = theData->getStepMaterialX0(ii);
00193       t_MaterialLambda0[ii]   = theData->getStepMaterialLambda0(ii);
00194       t_MaterialDensity[ii]   = theData->getStepMaterialDensity(ii);
00195       
00196       t_ParticleStepID[ii]              = theData->getStepID(ii);
00197       t_ParticleStepInitialPt[ii]       = theData->getStepInitialPt(ii);
00198       t_ParticleStepInitialEta[ii]      = theData->getStepInitialEta(ii);
00199       t_ParticleStepInitialPhi[ii]      = theData->getStepInitialPhi(ii);
00200       t_ParticleStepInitialEnergy[ii]   = theData->getStepInitialEnergy(ii);
00201       t_ParticleStepInitialPx[ii]       = theData->getStepInitialPx(ii);
00202       t_ParticleStepInitialPy[ii]       = theData->getStepInitialPy(ii);
00203       t_ParticleStepInitialPz[ii]       = theData->getStepInitialPz(ii);
00204       t_ParticleStepInitialBeta[ii]     = theData->getStepInitialBeta(ii);
00205       t_ParticleStepInitialGamma[ii]    = theData->getStepInitialGamma(ii);
00206       t_ParticleStepInitialMass[ii]     = theData->getStepInitialMass(ii);
00207       t_ParticleStepFinalPt[ii]         = theData->getStepFinalPt(ii);
00208       t_ParticleStepFinalEta[ii]        = theData->getStepFinalEta(ii);
00209       t_ParticleStepFinalPhi[ii]        = theData->getStepFinalPhi(ii);
00210       t_ParticleStepFinalEnergy[ii]     = theData->getStepFinalEnergy(ii);
00211       t_ParticleStepFinalPx[ii]         = theData->getStepFinalPx(ii);
00212       t_ParticleStepFinalPy[ii]         = theData->getStepFinalPy(ii);
00213       t_ParticleStepFinalPz[ii]         = theData->getStepFinalPz(ii);
00214       t_ParticleStepFinalBeta[ii]       = theData->getStepFinalBeta(ii);
00215       t_ParticleStepFinalGamma[ii]      = theData->getStepFinalGamma(ii);
00216       t_ParticleStepFinalMass[ii]       = theData->getStepFinalMass(ii);
00217       t_ParticleStepPreInteraction[ii]  = theData->getStepPreProcess(ii);
00218       t_ParticleStepPostInteraction[ii] = theData->getStepPostProcess(ii);
00219       
00220       // rr
00221     }
00222   }
00223 
00224   theTree->Fill();
00225 
00226 }
00227 
00228 
00229 // here one can print the histograms or 
00230 // manipulate them before they are written to file
00231 void MaterialBudgetTree::hend() 
00232 {
00233   std::cout << " === save user TTree ===" << std::endl;
00234  
00235   theFile->cd();
00236   theTree->Write();
00237   
00238   theFile->Close();
00239 
00240 }
00241