CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/Calibration/EcalTBTools/src/TB06TreeH2.cc

Go to the documentation of this file.
00001 #include "Calibration/EcalTBTools/interface/TB06TreeH2.h"
00002 #include "TFile.h" 
00003 #include "TTree.h" 
00004 #include "Calibration/EcalTBTools/interface/TB06RecoH2.h"
00005 
00006 #include <iostream>
00007 
00008 
00009 TB06TreeH2::TB06TreeH2 (const std::string & fileName, 
00010                     const std::string & treeName):
00011   m_file (0), m_tree (0), m_data (0), m_dataSize (0)  
00012 {
00013   TDirectory *dir = gDirectory ;
00014   m_file = new TFile (fileName.c_str (),"RECREATE") ;
00015   m_file->cd () ;
00016   m_tree = new TTree (treeName.c_str(),"Analysis tree") ;
00017   m_tree->SetAutoSave (10000000) ;
00018   dir->cd () ;
00019 
00020   //  m_tree->cd () ;
00021   m_data = new TClonesArray (TB06RecoH2::Class (), 1) ;
00022   m_data->ExpandCreateFast (1) ;
00023 
00024   //  m_tree->Branch ("EGCO", &m_data, 64000, 2) ;
00025   m_tree->Branch ("TB06O", &m_data, 64000, 2) ;
00026   m_tree->Print () ;
00027  
00028 }
00029 
00030 
00031 // -------------------------------------------------------------------      
00032 
00033 TB06TreeH2::~TB06TreeH2 () 
00034 {
00035   std::cout << "[TB06TreeH2][dtor] saving TTree " << m_tree->GetName ()
00036             << " with " << m_tree->GetEntries () << " entries"
00037             << " on file: " << m_file->GetName () << std::endl ;
00038 
00039   m_file->Write () ;
00040   delete m_tree ;
00041   m_file->Close () ;
00042   delete m_file ;
00043   delete m_data ;
00044 }
00045 
00046 
00047 // -------------------------------------------------------------------   
00048 
00050   void TB06TreeH2::store (const int & tableIsMoving,
00051                       const int & run, const int & event,
00052                       const int & S6adc ,
00053                       const double & xhodo, const double & yhodo, 
00054                       const double & xslope, const double & yslope, 
00055                       const double & xquality, const double & yquality,
00056                       const int & icMax,
00057                       const int & ietaMax, const int & iphiMax,
00058                       const double & beamEnergy, 
00059                       const double ampl[49],
00060                       const int &wcAXo,const int &wcAYo,
00061                       const int &wcBXo,const int &wcBYo,
00062                       const int &wcCXo,const int &wcCYo,
00063                       const double & xwA, const double & ywA,
00064                       const double & xwB, const double & ywB,
00065                       const double & xwC, const double & ywC,
00066                       const float &S1adc, const float &S2adc,
00067                       const float &S3adc, const float &S4adc,
00068                       const float &VM1,const float &VM2,const float &VM3,
00069                       const float &VM4,const float &VM5,const float &VM6,
00070                       const float &VM7,const float &VM8,const float &VMF,
00071                       const float &VMB,
00072                       const float &CK1,const float &CK2, const float &CK3,
00073                       const float &BH1,const float &BH2,const float &BH3,
00074                       const float &BH4,
00075                       const float &TOF1S, const float &TOF2S, 
00076                       const float &TOF1J,const float &TOF2J
00077                       )
00078 {
00079 
00080   m_data->Clear () ;
00081   TB06RecoH2 * entry = static_cast<TB06RecoH2*> (m_data->AddrAt (0)) ;
00082 
00083   entry->reset () ;
00084   //  reset (entry->myCalibrationMap) ;
00085 
00086   entry->tableIsMoving = tableIsMoving ;
00087   entry->run = run ;
00088   entry->event = event ;
00089   entry->S6ADC = S6adc ;
00090 
00091   entry->MEXTLindex = icMax ;
00092   entry->MEXTLeta = ietaMax ;
00093   entry->MEXTLphi = iphiMax ;
00094   entry->MEXTLenergy = ampl[24] ;
00095   entry->beamEnergy = beamEnergy ;
00096 
00097   for (int eta = 0 ; eta<7 ; ++eta)
00098     for (int phi = 0 ; phi<7 ; ++phi)
00099       {
00100         // FIXME capire l'orientamento di phi!
00101         // FIXME capire se eta, phi iniziano da 1 o da 0
00102         entry->localMap[eta][phi] = ampl[eta*7+phi] ;
00103       }
00104 
00105  //[Edgar] S1 uncleaned, uncalibrated energy
00106   entry->S1uncalib_ = ampl[24];
00107   
00108   //[Edgar] S25 uncleaned, uncalibrated energy
00109   for (int eta = 1 ; eta<6 ; ++eta)
00110     for (int phi = 1 ; phi<6 ; ++phi)
00111       {
00112         entry->S25uncalib_ += entry->localMap[eta][phi] ;
00113       }
00114 
00115   //[Edgar] S49 uncleaned, uncalibrated energy
00116   for (int eta = 0 ; eta<7 ; ++eta)
00117     for (int phi = 0 ; phi<7 ; ++phi)
00118       {
00119         entry->S49uncalib_ += entry->localMap[eta][phi] ;
00120       }
00121 
00122   //[Edgar] S9 uncleaned, uncalibrated energy
00123   for (int eta = 2 ; eta<5 ; ++eta)
00124     for (int phi = 2 ; phi<5 ; ++phi)
00125       {
00126         entry->S9uncalib_ += entry->localMap[eta][phi] ;
00127       }
00128 
00129   entry->xHodo = xhodo ;
00130   entry->yHodo = yhodo ;
00131   entry->xSlopeHodo = xslope ;
00132   entry->ySlopeHodo = yslope ;
00133   entry->xQualityHodo = xquality ;
00134   entry->yQualityHodo = yquality ;
00135  entry->wcAXo_ = wcAXo;
00136   entry->wcAYo_ = wcAYo;
00137   entry->wcBXo_ = wcBXo;
00138   entry->wcBYo_ = wcBYo;
00139   entry->wcCXo_ = wcCXo;
00140   entry->wcCYo_ = wcCYo;
00141   entry->xwA_ = xwA;
00142   entry->ywA_ = ywA;
00143   entry->xwB_ = xwB;
00144   entry->ywB_ = ywB;
00145   entry->xwC_ = xwC;
00146   entry->ywC_ = ywC;
00147   entry->S1adc_ = S1adc;
00148   entry->S2adc_ = S2adc;
00149   entry->S3adc_ = S3adc;
00150   entry->S4adc_ = S4adc;
00151   entry->VM1_ = VM1;
00152   entry->VM2_ = VM2;
00153   entry->VM3_ = VM3;
00154   entry->VM4_ = VM4;
00155   entry->VM5_ = VM5;
00156   entry->VM6_ = VM6;
00157   entry->VM7_ = VM7;
00158   entry->VM8_ = VM8;
00159   entry->VMF_ = VMF;
00160   entry->VMB_ = VMB;
00161   entry->CK1_ = CK1;
00162   entry->CK2_ = CK2;
00163   entry->CK3_ = CK3;
00164   entry->BH1_ = BH1;
00165   entry->BH2_ = BH2;
00166   entry->BH3_ = BH3;
00167   entry->BH4_ = BH4;
00168   entry->TOF1S_ = TOF1S;
00169   entry->TOF2S_ = TOF2S;
00170   entry->TOF1J_ = TOF1J;
00171   entry->TOF2J_ = TOF2J;
00172 
00173   entry->convFactor = 0. ;
00174 
00175   /*
00176   // loop over the 5x5 see (1)
00177   for (int xtal=0 ; xtal<25 ; ++xtal) 
00178     {
00179       int ieta = xtal/5 + 3 ;
00180       int iphi = xtal%5 + 8 ;
00181       entry->myCalibrationMap[ieta][iphi] = ampl[xtal] ;
00182     } // loop over the 5x5
00183 
00184   entry->electron_Tr_Pmag_ = beamEnergy ;
00185   
00186         entry->centralCrystalEta_ = ietaMax ;
00187         entry->centralCrystalPhi_ = iphiMax ;
00188         entry->centralCrystalEnergy_ = ampl[12] ; 
00189 
00190   // this is a trick
00191   entry->electron_Tr_Peta_ = xhodo ;
00192   entry->electron_Tr_Pphi_ = yhodo ;
00193   */
00194   m_tree->Fill () ;
00195 }
00196 
00197 
00198 // -------------------------------------------------------------------
00199 
00200 
00201 void TB06TreeH2::reset (float crystal[11][21])
00202 {
00203   for (int eta =0 ; eta<11 ; ++eta)    
00204     {
00205       for (int phi =0 ; phi<21 ; ++phi) 
00206         {
00207           crystal[eta][phi] = -999. ;  
00208         }   
00209     }
00210 }
00211 
00212 
00213 // -------------------------------------------------------------------
00214 
00215 
00216 void TB06TreeH2::check ()
00217 {
00218   TB06RecoH2 * entry = static_cast<TB06RecoH2*> (m_data->AddrAt (0)) ;
00219 
00220   std::cout << "[TB06TreeH2][check]reading . . . \n" ;
00221   std::cout << "[TB06TreeH2][check] entry->run: " << entry->run << "\n" ;
00222   std::cout << "[TB06TreeH2][check] entry->event: " << entry->event << "\n" ;
00223   std::cout << "[TB06TreeH2][check] entry->tableIsMoving: " << entry->tableIsMoving << "\n" ;
00224   std::cout << "[TB06TreeH2][check] entry->MEXTLeta: " << entry->MEXTLeta << "\n" ;
00225   std::cout << "[TB06TreeH2][check] entry->MEXTLphi: " << entry->MEXTLphi << "\n" ;
00226   std::cout << "[TB06TreeH2][check] entry->MEXTLenergy: " << entry->MEXTLenergy << "\n" ;
00227 
00228   for (int eta = 0 ; eta<7 ; ++eta)
00229       for (int phi = 0 ; phi<7 ; ++phi)
00230         std::cout << "[TB06TreeH2][check]   entry->localMap[" << eta
00231                   << "][" << phi << "]: "
00232                   << entry->localMap[eta][phi] << "\n" ;
00233 
00234   std::cout << "[TB06TreeH2][check] entry->xHodo: " << entry->xHodo << "\n" ;
00235   std::cout << "[TB06TreeH2][check] entry->yHodo: " << entry->yHodo << "\n" ;
00236   std::cout << "[TB06TreeH2][check] entry->xSlopeHodo: " << entry->xSlopeHodo << "\n" ;
00237   std::cout << "[TB06TreeH2][check] entry->ySlopeHodo: " << entry->ySlopeHodo << "\n" ;
00238   std::cout << "[TB06TreeH2][check] entry->xQualityHodo: " << entry->xQualityHodo << "\n" ;
00239   std::cout << "[TB06TreeH2][check] entry->yQualityHodo: " << entry->yQualityHodo << "\n" ;
00240   std::cout << "[TB06TreeH2][check] entry->convFactor: " << entry->convFactor << "\n" ;
00241 
00242   /* to be implemented with the right variables
00243   std::cout << "[TB06TreeH2][check] ------------------------" << std::endl ;
00244   std::cout << "[TB06TreeH2][check] " << entry->variable_name << std::endl ;
00245   */
00246 }
00247 
00248 
00249 
00250 /* (1) to fill the 25 crystals vector
00251 
00252    for (UInt_t icry=0 ; icry<25 ; ++icry)
00253      {
00254        UInt_t row = icry / 5 ;
00255        Int_t column = icry % 5 ;
00256        try
00257            {
00258              EBDetId tempo (maxHitId.ieta()+column-2, 
00259                             maxHitId.iphi()+row-2, 
00260                             EBDetId::ETAPHIMODE) ;
00261 
00262              Xtals5x5.push_back (tempo) ;
00263              amplitude [icry] = hits->find (Xtals5x5[icry])->energy () ;
00264              
00265            }
00266        catch ( std::runtime_error &e )
00267            {
00268              std::cout << "Cannot construct 5x5 matrix around EBDetId " 
00269                      << maxHitId << std::endl ;
00270              return ;
00271            }
00272      } // loop over the 5x5 matrix
00273 
00274 
00275 */