Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:34:41

0001 void TrackingTruthCompare()
0002 {
0003   
0004   gROOT ->Reset();
0005   char*  sfilename = "trackingtruthhisto.root";
0006   // char*  rfilename = "mergedtruthhisto.root";
0007   //char*  rfilename = "/localscratch/azzi/Validation/CMSSW_1_8_0_pre5/src/Validation/TrackingMCTruth/test/trackingtruthhisto.root";
0008   char*  rfilename = "../trackingtruthhisto.root";
0009   
0010   delete gROOT->GetListOfFiles()->FindObject(rfilename);
0011   delete gROOT->GetListOfFiles()->FindObject(sfilename); 
0012   
0013   TText* te = new TText();
0014  TFile * rfile = new TFile(rfilename);
0015  TDirectory * rdir=gDirectory; 
0016  TFile * sfile = new TFile(sfilename);
0017  TDirectory * sdir=gDirectory; 
0018 
0019  if(rfile->cd("DQMData/Run 1/TrackingMCTruthV"))rfile->cd("DQMData/Run 1/TrackingMCTruthV/Run summary/TrackingMCTruth/TrackingParticle");
0020  else if(rfile->cd("DQMData/TrackingMCTruthV"))rfile->cd("DQMData/TrackingMCTruthV/TrackingMCTruth/TrackingParticle");
0021  else if(rfile->cd("DQMData/Run 1/Tracking"))rfile->cd("DQMData/Run 1/Tracking/Run summary/TrackingMCTruth/TrackingParticle");
0022  else if(rfile->cd("DQMData/Tracking"))rfile->cd("DQMData/Tracking/TrackingMCTruth/TrackingParticle");
0023  rdir=gDirectory;
0024  
0025  if(sfile->cd("DQMData/Run 1/Tracking"))sfile->cd("DQMData/Run 1/Tracking/Run summary/TrackingMCTruth/TrackingParticle");
0026  else sfile->cd("DQMData/Tracking/TrackingMCTruth/TrackingParticle");
0027  sdir=gDirectory; 
0028 
0029   TLegend leg(0.3, 0.83, 0.55, 0.90);
0030   //Get list of Keys from the Reference file.
0031   TList* ref_list = rfile->GetListOfKeys() ;
0032   if (!ref_list) {
0033     std::cout<<"=========>> AutoComaprison:: There is no Keys available in the Reference file."<<std::endl;
0034     exit(1) ;
0035   }
0036   
0037   //Get list of Keys from the New file.
0038   TList* new_list = sfile->GetListOfKeys() ;
0039   if (!new_list) {
0040     std::cout<<"=========>> AutoComaprison:: There is no Keys available in New file."<<std::endl;
0041     exit(1) ;
0042   }
0043   
0044   
0045   //Iterate on the List of Keys of the  Reference file.
0046   TIter     refkey_iter( ref_list) ;
0047   TKey*     ref_key ;
0048   TObject*  ref_obj ;
0049   
0050   char rver[50];
0051   char cver[50];
0052   while ( ref_key = (TKey*) refkey_iter() ) {
0053     ref_obj = ref_key->ReadObj() ;
0054     if (strcmp(ref_obj->IsA()->GetName(),"TObjString")==0) {
0055       
0056       TObjString * rversion = dynamic_cast< TObjString*> (ref_obj);
0057       sprintf(rver, "%s", rversion->GetName());
0058       std::cout<<" Ref. version (OLD)=" << rver<<std::endl;
0059       break;
0060     }
0061   }
0062   
0063   //Iterate on the List of Keys of the  Reference file.
0064   TIter     newkey_iter( new_list) ;
0065   TKey*     new_key ;
0066   TObject*  new_obj ;
0067   while ( new_key = (TKey*) newkey_iter() ) {
0068     new_obj = new_key->ReadObj() ;
0069     if (strcmp(new_obj->IsA()->GetName(),"TObjString")==0) {
0070       
0071       TObjString * cversion = dynamic_cast< TObjString*> (new_obj);
0072       sprintf(cver, "%s", cversion->GetName());
0073       std::cout<<" Cur version (FIX)=" << cver<<std::endl;
0074       break;
0075       
0076     }
0077   }
0078   
0079   //gDirectory->ls();
0080   
0081   Char_t histo[200];
0082   
0083   gROOT->ProcessLine(".x HistoCompare.C");
0084   HistoCompare * myPV = new HistoCompare();
0085   
0086   
0087   if (1) {
0088     TCanvas * TrackingParticleGV = new TCanvas("TrackingParticleGV","TrackingParticleGV",1000,1000);
0089     TrackingParticleGV->Divide(3,2);
0090     
0091     TH1* meTPmass;
0092     TH1* meTPcharge;
0093     TH1* meTPid;
0094     TH1* meTPproc;
0095     TH1* meTPhits;
0096     TH1* meTPmhits;
0097     
0098     TH1* newmeTPmass;
0099     TH1* newmeTPcharge;
0100     TH1* newmeTPid;
0101     TH1* newmeTPproc;
0102     TH1* newmeTPhits;
0103     TH1* newmeTPmhits;
0104     
0105     sprintf(histo,"TPMass");
0106     rdir->GetObject( histo,meTPmass);
0107     sdir->GetObject(histo,newmeTPmass);
0108     meTPmass;
0109     newmeTPmass;
0110     TrackingParticleGV->cd(1);
0111     meTPmass->SetLineColor(2);
0112     newmeTPmass->SetLineColor(4);
0113     newmeTPmass->SetLineStyle(2);
0114     meTPmass->Draw();
0115     newmeTPmass->Draw("sames");
0116     myPV->PVCompute(meTPmass , newmeTPmass , te );
0117     leg.Clear();
0118     leg.AddEntry(meTPmass,rver , "l");
0119     leg.AddEntry(newmeTPmass,cver , "l");
0120     leg.Draw();
0121 
0122     sprintf(histo,"TPCharge");
0123     rdir->GetObject( histo,meTPcharge);
0124     sdir->GetObject(histo,newmeTPcharge);
0125     meTPcharge;
0126     newmeTPcharge;
0127     TrackingParticleGV->cd(2);
0128     meTPcharge->SetLineColor(2);
0129     newmeTPcharge->SetLineColor(4);
0130     newmeTPcharge->SetLineStyle(2);
0131     meTPcharge->Draw();
0132     newmeTPcharge->Draw("sames");
0133     myPV->PVCompute(meTPcharge , newmeTPcharge , te );
0134     leg.Clear();
0135     leg.AddEntry(meTPcharge,rver , "l");
0136     leg.AddEntry(newmeTPcharge,cver , "l");
0137     leg.Draw();
0138     
0139     sprintf(histo,"TPId");
0140     rdir->GetObject( histo,meTPid);
0141     sdir->GetObject(histo,newmeTPid);
0142     meTPid;
0143     newmeTPid;
0144     TrackingParticleGV->cd(3);
0145     meTPid->SetLineColor(2);
0146     newmeTPid->SetLineColor(4);
0147     newmeTPid->SetLineStyle(2);
0148     meTPid->Draw();
0149     newmeTPid->Draw("sames");
0150     myPV->PVCompute(meTPid , newmeTPid , te );
0151     leg.Clear();
0152     leg.AddEntry(meTPid,rver , "l");
0153     leg.AddEntry(newmeTPid,cver , "l");
0154     leg.Draw();
0155 
0156 
0157     sprintf(histo,"TPProc");
0158     rdir->GetObject( histo,meTPproc);
0159     sdir->GetObject(histo,newmeTPproc);
0160     meTPproc;
0161     newmeTPproc;
0162     TrackingParticleGV->cd(4);
0163     meTPproc->SetLineColor(2);
0164     newmeTPproc->SetLineColor(4);
0165     newmeTPproc->SetLineStyle(2);
0166     meTPproc->Draw();
0167     newmeTPproc->Draw("sames");
0168     myPV->PVCompute(meTPproc , newmeTPproc , te );
0169     leg.Clear();
0170     leg.AddEntry(meTPproc,rver , "l");
0171     leg.AddEntry(newmeTPproc,cver , "l");
0172     leg.Draw();
0173 
0174     sprintf(histo,"TPAllHits");
0175     rdir->GetObject( histo,meTPhits);
0176     sdir->GetObject(histo,newmeTPhits);
0177     meTPhits;
0178     newmeTPhits;
0179     TrackingParticleGV->cd(5);
0180     meTPhits->SetLineColor(2);
0181     newmeTPhits->SetLineColor(4);
0182     newmeTPhits->SetLineStyle(2);
0183     meTPhits->Draw();
0184     newmeTPhits->Draw("sames");
0185     myPV->PVCompute(meTPhits , newmeTPhits , te );
0186     leg.Clear();
0187     leg.AddEntry(meTPhits,rver , "l");
0188     leg.AddEntry(newmeTPhits,cver , "l");
0189     leg.Draw();
0190 
0191     sprintf(histo,"TPMatchedHits");
0192     rdir->GetObject( histo,meTPmhits);
0193     sdir->GetObject(histo,newmeTPmhits);
0194     meTPmhits;
0195     newmeTPmhits;
0196     TrackingParticleGV->cd(6);
0197     meTPmhits->SetLineColor(2);
0198     newmeTPmhits->SetLineColor(4);
0199     newmeTPmhits->SetLineStyle(2);
0200     meTPmhits->Draw();
0201     newmeTPmhits->Draw("sames");
0202     myPV->PVCompute(meTPmhits , newmeTPmhits , te );
0203     leg.Clear();
0204     leg.AddEntry(meTPmhits,rver , "l");
0205     leg.AddEntry(newmeTPmhits,cver , "l");
0206     leg.Draw();
0207     
0208     TrackingParticleGV->Print("TPPlot1.eps");
0209     TrackingParticleGV->Print("TPPlot1.gif");
0210  }
0211 
0212  if (1) {
0213   TCanvas * TrackingParticleTV = new TCanvas("TrackingParticleTV","TrackingParticleTV",1000,1000);
0214    TrackingParticleTV->Divide(4,2);
0215 
0216    TH1* meTPpt;
0217    TH1* meTPeta;
0218    TH1* meTPphi;
0219    TH1* meTPvtxx;
0220    TH1* meTPvtxy;
0221    TH1* meTPvtxz;
0222    TH1* meTPlip;
0223    TH1* meTPtip;
0224 
0225    TH1* newmeTPpt;
0226    TH1* newmeTPeta;
0227    TH1* newmeTPphi;
0228    TH1* newmeTPvtxx;
0229    TH1* newmeTPvtxy;
0230    TH1* newmeTPvtxz;
0231    TH1* newmeTPlip;
0232    TH1* newmeTPtip;
0233 
0234    sprintf(histo,"TPPt");
0235    rdir->GetObject(histo ,meTPpt);
0236    sdir->GetObject(histo ,newmeTPpt);
0237    meTPpt;
0238    newmeTPpt;
0239    TrackingParticleTV->cd(1);
0240    meTPpt->SetLineColor(2);
0241    newmeTPpt->SetLineColor(4);
0242    newmeTPpt->SetLineStyle(2);
0243    meTPpt->Draw();
0244    newmeTPpt->Draw("sames");
0245    myPV->PVCompute(meTPpt , newmeTPpt , te );
0246    leg.Clear();
0247    leg.AddEntry(meTPpt,rver , "l");
0248    leg.AddEntry(newmeTPpt,cver , "l");
0249    leg.Draw();
0250 
0251    sprintf(histo,"TPEta");
0252    rdir->GetObject(histo ,meTPeta);
0253    sdir->GetObject(histo ,newmeTPeta);
0254    meTPeta;
0255    newmeTPeta;
0256    TrackingParticleTV->cd(2);
0257    meTPeta->SetLineColor(2);
0258    newmeTPeta->SetLineColor(4);
0259    newmeTPeta->SetLineStyle(2);
0260    meTPeta->Draw();
0261    newmeTPeta->Draw("sames");
0262    myPV->PVCompute(meTPeta , newmeTPeta , te );
0263    leg.Clear();
0264    leg.AddEntry(meTPeta,rver , "l");
0265    leg.AddEntry(newmeTPeta,cver , "l");
0266    leg.Draw();
0267 
0268    sprintf(histo,"TPPhi");
0269    rdir->GetObject(histo ,meTPphi);
0270    sdir->GetObject(histo ,newmeTPphi);
0271    meTPphi;
0272    newmeTPphi;
0273    TrackingParticleTV->cd(3);
0274    meTPphi->SetLineColor(2);
0275    newmeTPphi->SetLineColor(4);
0276    newmeTPphi->SetLineStyle(2);
0277    meTPphi->Draw();
0278    newmeTPphi->Draw("sames");
0279    myPV->PVCompute(meTPphi , newmeTPphi , te );
0280    leg.Clear();
0281    leg.AddEntry(meTPphi,rver , "l");
0282    leg.AddEntry(newmeTPphi,cver , "l");
0283    leg.Draw();
0284    
0285    sprintf(histo,"TPVtxX");
0286    rdir->GetObject(histo ,meTPvtxx);
0287    sdir->GetObject(histo ,newmeTPvtxx);
0288    meTPvtxx;
0289    newmeTPvtxx;
0290    TrackingParticleTV->cd(4);
0291    meTPvtxx->SetLineColor(2);
0292    newmeTPvtxx->SetLineColor(4);
0293    newmeTPvtxx->SetLineStyle(2);
0294    meTPvtxx->Draw();
0295    newmeTPvtxx->Draw("sames");
0296    myPV->PVCompute(meTPvtxx , newmeTPvtxx , te );
0297    leg.Clear();
0298    leg.AddEntry(meTPvtxx,rver , "l");
0299    leg.AddEntry(newmeTPvtxx,cver , "l");
0300    leg.Draw();
0301 
0302    sprintf(histo,"TPVtxY");
0303    rdir->GetObject(histo ,meTPvtxy);
0304    sdir->GetObject(histo ,newmeTPvtxy);
0305    meTPvtxy;
0306    newmeTPvtxy;
0307    TrackingParticleTV->cd(5);
0308    meTPvtxy->SetLineColor(2);
0309    newmeTPvtxy->SetLineColor(4);
0310    newmeTPvtxy->SetLineStyle(2);
0311    meTPvtxy->Draw();
0312    newmeTPvtxy->Draw("sames");
0313    myPV->PVCompute(meTPvtxy , newmeTPvtxy , te );
0314    leg.Clear();
0315    leg.AddEntry(meTPvtxy,rver , "l");
0316    leg.AddEntry(newmeTPvtxy,cver , "l");
0317    leg.Draw();
0318 
0319    sprintf(histo,"TPVtxZ");
0320    rdir->GetObject(histo ,meTPvtxz);
0321    sdir->GetObject(histo ,newmeTPvtxz);
0322    meTPvtxz;
0323    newmeTPvtxz;
0324    TrackingParticleTV->cd(6);
0325    meTPvtxz->SetLineColor(2);
0326    newmeTPvtxz->SetLineColor(4);
0327    newmeTPvtxz->SetLineStyle(2);
0328    meTPvtxz->Draw();
0329    newmeTPvtxz->Draw("sames");
0330    myPV->PVCompute(meTPvtxz , newmeTPvtxz , te );
0331    leg.Clear();
0332    leg.AddEntry(meTPvtxz,rver , "l");
0333    leg.AddEntry(newmeTPvtxz,cver , "l");
0334    leg.Draw();
0335 
0336    sprintf(histo,"TPtip");
0337    rdir->GetObject(histo ,meTPtip);
0338    sdir->GetObject(histo ,newmeTPtip);
0339    meTPtip;
0340    newmeTPtip;
0341    TrackingParticleTV->cd(7);
0342    meTPtip->SetLineColor(2);
0343    newmeTPtip->SetLineColor(4);
0344    newmeTPtip->SetLineStyle(2);
0345    meTPtip->Draw();
0346    newmeTPtip->Draw("sames");
0347    myPV->PVCompute(meTPtip , newmeTPtip , te );
0348    leg.Clear();
0349    leg.AddEntry(meTPtip,rver , "l");
0350    leg.AddEntry(newmeTPtip,cver , "l");
0351    leg.Draw();
0352 
0353    sprintf(histo,"TPlip");
0354    rdir->GetObject(histo ,meTPlip);
0355    sdir->GetObject(histo ,newmeTPlip);
0356    meTPlip;
0357    newmeTPlip;
0358    TrackingParticleTV->cd(8);
0359    meTPlip->SetLineColor(2);
0360    newmeTPlip->SetLineColor(4);
0361    newmeTPlip->SetLineStyle(2);
0362    meTPlip->Draw();
0363    newmeTPlip->Draw("sames");
0364    myPV->PVCompute(meTPlip , newmeTPlip , te );
0365    leg.Clear();
0366    leg.AddEntry(meTPlip,rver , "l");
0367    leg.AddEntry(newmeTPlip,cver , "l");
0368    leg.Draw();
0369 
0370    TrackingParticleTV->Print("TPPlot2.eps");
0371    TrackingParticleTV->Print("TPPlot2.gif");
0372  }
0373 }
0374