Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 void AddContributionFromOtherAPV(TH1D* Proj, unsigned int CurrentAPV, TH1F* APV_DetId, TH1F* APV_Id, TH2F* APV_Charge);
0002 
0003 void DebugMacro()
0004 {
0005    gROOT->Reset();
0006    gStyle->SetCanvasColor(0);
0007    gStyle->SetOptStat("neMRuoi");
0008    gStyle->SetOptFit(111);
0009    gStyle->SetPalette(1);
0010    bool save = true;
0011 
0012    TFile* file  = new TFile("file:../SiStripCalib.root");
0013 
0014    TH1F* APV_MPV    = file->FindObjectAny("APV_MPV");
0015    TH1F* APV_DetId  = file->FindObjectAny("APV_DetId");
0016    TH1F* APV_Id     = file->FindObjectAny("APV_Id");
0017    TH1F* APV_Eta    = file->FindObjectAny("APV_Eta");
0018    TH2F* APV_Charge = file->FindObjectAny("APV_Charge");
0019   if(!(APV_MPV && APV_DetId && APV_Id && APV_Eta && APV_Charge))printf("Loading of Histos failed\n");
0020 
0021    TCanvas* c1 = new TCanvas();
0022 
0023    unsigned int K=0;
0024    for(int i=0;i<APV_MPV->GetXaxis()->GetNbins();i++){
0025         int MPV = APV_MPV->GetBinContent(i);
0026         if(APV_Id->GetBinContent(i)!=0)continue;
0027     if(MPV>0 && MPV<170){
0028        printf("Low MPV (%3i) for APV_%i_%i\n",MPV, APV_DetId->GetBinContent(i), APV_Id->GetBinContent(i) );
0029 
0030            TH1D* Proj = APV_Charge->ProjectionY(" ",i,i,"e");
0031            Proj = (TH1D*)Proj->Clone();
0032            if(Proj==NULL)continue;
0033            AddContributionFromOtherAPV(Proj,i,APV_DetId,APV_Id,APV_Charge);
0034 
0035 
0036        if(Proj->GetEntries()<40)continue;
0037            printf("#Entries = %i\n", Proj->GetEntries());
0038 
0039            Proj = Proj->Rebin(4);
0040 
0041 
0042            TF1* MyLandau = new TF1("MyLandau","landau",0, 5400.0);
0043            MyLandau->SetParameter("MPV",300);
0044            Proj->Fit("MyLandau","QR WW 0");
0045            TF1 * fitfunction = (TF1*) Proj->GetListOfFunctions()->First();
0046 
0047 
0048        Proj->SetTitle();
0049 //     Proj->SetStats(kFALSE);
0050        Proj->GetXaxis()->SetTitle("Charged (ADC Normalized)");
0051        Proj->GetYaxis()->SetTitle("#Entries");
0052        Proj->GetYaxis()->SetTitleOffset(1.05);
0053            Proj->SetAxisRange(0,900 ,"X");
0054        Proj->SetLineColor(4);
0055        Proj->SetLineWidth(2);         
0056        Proj->Draw("HIST");
0057        fitfunction->Draw("same");
0058 
0059        char filepath[1024];sprintf(filepath,"DebugPictures/DetId%i_MPV%03i_Entries%05i.png",APV_DetId->GetBinContent(i), MPV, Proj->GetEntries());
0060        if(save)c1->SaveAs(filepath);
0061            delete Proj;
0062 
0063        K++;
0064        //if(K==1)return;
0065     }
0066    }
0067 
0068 }
0069 
0070 void AddContributionFromOtherAPV(TH1D* Proj, unsigned int CurrentAPV, TH1F* APV_DetId, TH1F* APV_Id, TH2F* APV_Charge){
0071    int DetId = APV_DetId->GetBinContent(CurrentAPV);
0072    int Id    = APV_Id->GetBinContent(CurrentAPV);
0073 
0074    for(int i=CurrentAPV;i<APV_DetId->GetXaxis()->GetNbins()&&i<CurrentAPV+6;i++){
0075       if(APV_DetId->GetBinContent(i)!=DetId)continue;
0076       if(APV_Id->GetBinContent(i)   ==Id   )continue;
0077 
0078        TH1D* Proj2 = APV_Charge->ProjectionY(" ",i,i,"e");
0079        Proj2 = (TH1D*)Proj2->Clone();
0080        if(Proj2==NULL)continue;
0081 
0082        printf("Add histos From %i_%i   --> +%iEntries\n",APV_DetId->GetBinContent(i),APV_Id->GetBinContent(i),Proj->GetEntries());
0083 
0084       
0085        Proj->Add(Proj2,1.0);
0086    }
0087 }
0088 
0089 
0090 
0091 
0092 
0093