#include //////////////////////////////////////////////////////////// /// INITIALIZATIONS & GLOBAL PARAMETERS //////////////////////////////////////////////////////////// CaloElectron_parameters * CaloElectron_parameters::_parameters = 0; /** * Set external parameters to default values */ void CaloElectron_parameters::SetDefault(){ cout << "CaloElectron --> SET DEFAULT PARAMETERS" << endl; isimu = 0; dolongfit = 1; dolatcorr = 1; calibmode = 0; debug = false; // dodrawlong = false; // dodrawq0q1 = false; // dodrawlat = false; TAUMAX = 5.; RMAX = 40.;//4.; //temporaneo??? RMAXsp = 40.; // cout << "Shower cuts:"< DUMP PARAMETERS" << endl; cout << endl; cout << "Shower cuts (for energy determination):"< "; for(int ip=0; ip<22; ip++)cout << maskpl[ip][0]; cout << endl; cout << " Y -> "; for(int ip=0; ip<22; ip++)cout << maskpl[ip][1]; cout << endl; cout << " ipmin = "< all planes included) * @notused Num.of planes exluded (icalo=1 excludes bottom planes, icalo=2 exclude top planes) * NB: plane 19x is always excluded * */ void CaloElectron_parameters::SetCalo(int icalo,int notused){ if(icalo==0){ maskpl[18][0]=true; ipmin=0; ipmax=22; } if(icalo==1){ maskpl[18][0]=true; ipmin=0; ipmax=22-notused; if(18-notused>=0)maskpl[18-notused][0]=true; } if(icalo==2){ maskpl[18][0]=true; ipmin=notused; ipmax=22; if(18+notused<22)maskpl[18+notused][0]=true; } // cout << "MASKED PLANES:"< "; // for(int ip=0; ip<22; ip++)cout << maskpl[ip][0]; // cout << endl; // cout << "Y -> "; // for(int ip=0; ip<22; ip++)cout << maskpl[ip][1]; // cout << endl; // cout << "ipmin = "<Delete(); if(h_qtot[1])h_qtot[1]->Delete(); if(h_qfit[0])h_qfit[0]->Delete(); if(h_qfit[1])h_qfit[1]->Delete(); h_qtot[0] = new TH2F("htot0","Matrix of energy releases (measured)",nbin,xbin,22,-0.5,21.5); h_qfit[0] = new TH2F("hfit0","Matrix of energy releases (fit)", nbin,xbin,22,-0.5,21.5); h_qtot[1] = new TH2F("htot1","Matrix of energy releases (measured)",nbin,xbin,22,-0.5,21.5); h_qfit[1] = new TH2F("hfit1","Matrix of energy releases (fit)", nbin,xbin,22,-0.5,21.5); } /** * Set external parameters to default values */ void CaloElectron_parameters::SetPar(){ // --------------- // lateral profile (hardcoded parameters ) // --------------- TString pathx,pathy,pathyd,pathyp; TString dir = gSystem->Getenv("PAM_CALIB"); if(isimu==0){ pathx=dir+"/cal-param/parxdati.txt"; pathyd=dir+"/cal-param/paryddati.txt"; pathyp=dir+"/cal-param/parypdati.txt"; }else{ pathx=dir+"/cal-param/parxsimu.txt"; pathyd=dir+"/cal-param/parydsimu.txt"; pathyp=dir+"/cal-param/parypsimu.txt"; } cout << "Load LATERAL PARAMETERS "<>file_tau[i]>>file_p[i][iv]>>file_rt[i][iv]>>file_rc[i][iv]; } if(iv==1){ ifstream filep(pathyp); for(int i=0;i<12;i++)filep>>file_tau[i]>>file_p[i][iv]>>file_rt[i][iv]>>file_rc[i][iv]; ifstream filed(pathyd); for(int i=0;i<12;i++)filed>>file_tau[i]>>file_p[i][iv+1]>>file_rt[i][iv+1]>>file_rc[i][iv+1]; } } }; /** * Set calibration tools. * Create histos for lateral profile parameterization */ void CaloElectron_parameters::Calibration_SetTools(int ntau, float* taubin){ if(!calibmode)return; cout << "CaloElectron --> Set calibration tools "< NTAUBINMAX ){ ntau = NTAUBINMAX; cout << "(NB: max allowed n.tau-bins = "< "<< htitle<<" "<Delete(); h_qtot_tau[i][j] = new TH2F(hid.Data(),htitle.Data(),CALIBNBIN,-1*CALIBRANGE,1*CALIBRANGE,5000,0.,10.); // hid.Form("hqtottauwav_%i_%i",i,j); htitle.Form("Lateral profile - view %i - tau-bin %i (weighted average)",j,i); cout < "<< htitle<<" "<Delete(); h_qtot_tau_wav[i][j] = new TH1F(hid.Data(),htitle.Data(),CALIBNBIN,-1*CALIBRANGE,1*CALIBRANGE); } } return; }; /** * Set calibration tools * Create histos for lateral profile parameterization */ void CaloElectron_parameters::Calibration_SetTools(){ if(!calibmode)return; int ntau = 12; float fromtau = 0.; float totau = 3.; float dtau = (totau-fromtau)/(float)ntau; vector taubin; float *pt_taubin = taubin.get_allocator().allocate(ntau+1); pt_taubin[0]=fromtau; for(int i=1; i<=ntau; i++)pt_taubin[i]=(pt_taubin[0]+i*dtau); Calibration_SetTools(ntau,pt_taubin); return; }; /** * Fit calibration histos */ void CaloElectron_parameters::Calibration_Fit(){ if(!calibmode)return; TF1* frad = new TF1("frad",fradpro,-5.,5.,4); // // int nt_tau = CaloElectron_parameters::Get()->par_ntau; int ntau = par_ntau; // for(int itau = 0; itauGetName()<ProfileX("hh"); // frad->SetParameter(0,1.5);//rt // frad->SetParameter(1,0.5);//p // frad->SetParameter(2,0.4);//rc // frad->SetParameter(3,.01);//nrom // hh->Fit(frad,"R","",-2,2); // hh->Fit(frad,"R","",-5,5); // hh->Delete(); // if( !h_qtot_tau_wav[itau][j] )continue; cout << " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "<GetName()<SetParameter(0,1.5);//rt frad->SetParameter(1,0.5);//p frad->SetParameter(2,0.4);//rc frad->SetParameter(3,.01);//nrom hh->Fit(frad,"R","",-2,2); hh->Fit(frad,"R","",-5,5); hh->Delete(); }; }; frad->Delete(); return; }; /** * Write calibration output to file */ void CaloElectron_parameters::Calibration_Save(TFile* file){ if(!calibmode)return; if( !file || (file&&file->IsZombie()) )return; file->cd(); // // int ntau = CaloElectron_parameters::Get()->par_ntau; int ntau = par_ntau; for(int itau=0; itauSetBinContent(ibin+1,summWF[itau][j][ibin]/summW[itau][j][ibin]); h_qtot_tau_wav[itau][j]->SetBinError(ibin+1,1./sqrt(summW[itau][j][ibin])); } if(h_qtot_tau[itau][j]) h_qtot_tau[itau][j]->Write(); if(h_qtot_tau_wav[itau][j]) h_qtot_tau_wav[itau][j]->Write(); } } return; }; /** * Load calibration output histos from existing file */ void CaloElectron_parameters::Calibration_Load(TFile* file){ if( !file || (file&&file->IsZombie()) )return; file->cd(); cout <<" File: "<GetName(); // TString hid; par_ntau=0; for(int i=0; i<100; i++){ for(int j=0; j<3; j++){ // hid.Form("hqtottau_%i_%i",i,j); TH2F* hh = (TH2F*)file->Get(hid.Data()); if(!hh)continue; cout<<"histo --> "<Get(hid.Data()); if(!hhh)continue; cout<<"histo --> "<TAUMAX; int ipmin = CaloElectron_parameters::Get()->ipmin; int ipmax = CaloElectron_parameters::Get()->ipmax; float qqqq=0; // if(onlyy && iv==0) return qqqq; float idmax,ipmaxl; //se faccio così idmax deve essere rispetto al piano da cui inizio davvero idmax = GetShowerMaximum(icorr); // ***BUG??*** ipmaxl = idmax*TAUMAX+iv; // ***BUG??*** // ipmaxl = idmax*TAUMAX; if( ipmaxl>(ipmax-ipmin) ) ipmaxl=ipmax-ipmin; //if(ipmaxl<22) cout<<"GetQView icorr "<ipmin; int ipmax = CaloElectron_parameters::Get()->ipmax; int maxlayer = 0; float maxq = qplane[0][1]; //0Y - first active layer float q; for(int il=1; il<22; il++){ q=0.; int nxy=0; float qx = qplane[il-1][0]; float qy = qplane[il][1]; bool ISHIT = true; bool maskpl_x = CaloElectron_parameters::Get()->maskpl[il-1][0]; bool maskpl_y = CaloElectron_parameters::Get()->maskpl[il][1]; if( tplane[il-1][0] <0 || tplane[il][1]<0 )ISHIT=false; if(ISHIT){ // if( !maskpl[il-1][0] )nxy++; // if( !maskpl[il][1] )nxy++; if( !maskpl_x )nxy++; if( !maskpl_y )nxy++; if(nxy>0)q=(qx+qy)/nxy; if(q>maxq){ maxq=q; maxlayer=il; } } } if( tplane[21][0] > 0 ){ q = qplane[21][0]; //21X - last active layer if(q>maxq){ maxq=q; maxlayer=22; } } maxlayer=maxlayer-ipmin; if(maxlayer<0) maxlayer=0; if(maxlayer>ipmax-ipmin) maxlayer=ipmax-ipmin; return (float)maxlayer; } /** * \brief Evaluate shower maximum (id of shower maximum plane) */ float CaloElectron::GetShowerMaximum(int icorr){ // ------------------------------------ // shower maximum before any correction // ------------------------------------ if(icorr==0) return GetShowerMaximum(qplane0); // --------------------------------------- // shower maximum after lateral correction // --------------------------------------- if(icorr==1) return GetShowerMaximum(qplane1); // --------------------------------------- // --------------------------------------- // shower maximum from longitudinal fit // --------------------------------------- if(icorr==2 || icorr==3){ if( err__l==0 ){ return par__l[2]*cos(atan(tg))/(WTICK/WX0); }else{ return GetShowerMaximum(qplane1); } } return 0.; } /** * \brief Evaluate shower maximum (in X0 unit, considering track inclination angle) */ float CaloElectron::GetShowerMaximumX0(int icorr){ float maxX0=0; if(icorr==0 || icorr==1) maxX0=(GetShowerMaximum(icorr)/cos(atan(tg)))*(WTICK/WX0); if(icorr==2 || icorr==3) maxX0=par__l[2]; return maxX0; } float CaloElectron::GetShowerMaximumViewX0(int view,int icorr){ float maxX0=0; if(icorr==0 || icorr==1) maxX0=(GetShowerMaximumView(view,icorr)/cos(atan(tg)))*(WTICK/WX0); if(icorr==2 || icorr==3) maxX0=par__l[2]; return maxX0; } float CaloElectron::GetShowerMaximumView(int view,float qplane[][2]){ int ipmin = CaloElectron_parameters::Get()->ipmin; int ipmax = CaloElectron_parameters::Get()->ipmax; int maxlayer = 0; float maxq = qplane[0][view]; for(int il=1; il<22; il++){ if(qplane[il][view]>maxq){ maxq = qplane[il][view]; maxlayer = il+1-view; } } maxlayer=maxlayer-ipmin; if(maxlayer<0) maxlayer=0; if(maxlayer>ipmax-ipmin) maxlayer=ipmax-ipmin; return (float)maxlayer; } float CaloElectron::GetShowerMaximumView(int view,int icorr){ // ------------------------------------ // shower maximum before any correction // ------------------------------------ if(icorr==0) return GetShowerMaximumView(view,qplane0); // --------------------------------------- // shower maximum after lateral correction // --------------------------------------- if(icorr==1) return GetShowerMaximumView(view,qplane1); // --------------------------------------- // --------------------------------------- // shower maximum from longitudinal fit // --------------------------------------- if(icorr==2 || icorr==3){ if(err__l==0){ return par__l[2]*cos(atan(tg))/(WTICK/WX0); }else{ return GetShowerMaximumView(view,qplane1); } } return 0.; } /** * \brief Set event */ bool CaloElectron::Set(CaloLevel1 *cl1,float trackcoordinate[][2]){ if(!cl1 || !trackcoordinate ){ cout <<" void CaloElectron::Set(CaloLevel1 *cl1, float tracoo[22][2]) -- ERROR -- input == NULL"<cl1 = cl1; //set CaloLevel1 event CaloStrip cstrip; // ------------------- // retrieve parameters // ------------------- bool debug = CaloElectron_parameters::Get()->debug; float RMAX = CaloElectron_parameters::Get()->RMAX; int dolatcorr = CaloElectron_parameters::Get()->dolatcorr; int dolongfit = CaloElectron_parameters::Get()->dolongfit; int ipmin = CaloElectron_parameters::Get()->ipmin; int ipmax = CaloElectron_parameters::Get()->ipmax; int calibmode = CaloElectron_parameters::Get()->calibmode; // gBenchmark->Start("conta"); // -------------------------- // reset energy-deposit plots // -------------------------- TH2F* h_qtot[2]; for(int iv=0; iv<2; iv++){ h_qtot[iv] = CaloElectron_parameters::Get()->h_qtot[iv]; if(!h_qtot[iv])return false; h_qtot[iv]->Reset(); } // cout <<"%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% "<< CaloElectron_parameters::Get() << endl; // cout <<"%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% "<< CaloElectron_parameters::Get()->cl1 << endl; // cout <<"%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% "<< cl1 << endl; if( cl1->istrip < 5 )return false; // float trkstrip[22][2]; // strip traversed by the track // for(int ip=0; ip<22; ip++){ for(int iv=0; iv<2; iv++){ // -------------------------------------- // determine strip traversed by the track // -------------------------------------- // Float_t coo(0),lad(0),stri(0); // Float_t xcorner,ycorner; // GetCornerCoord(ip,iv,xcorner,ycorner); // if(iv==0) coo = (trackcoordinate[ip][iv]-xcorner)*10.; // if(iv==1) coo = (trackcoordinate[ip][iv]-ycorner)*10.; // if(coo<80.25) lad=1; // if(coo>80.25 && coo<160.75) lad=2; // if(coo>160.75) lad=3; // stri=32*(lad-1)+(coo-(lad-1)*80.5-0.96)/2.44; // Int_t trkstripnew = (Int_t)stri; // if(stri-trkstripnew>0.5) trkstripnew=trkstripnew+1; // trkstrip[ip][iv]=trkstripnew; // if(coo<0. || coo> 241.)trkstrip[ip][iv]=-1.; // // non so perche` ma mi sembra che sia sbagliato... // ci riprovo a modo mio: // trkstrip[ip][iv]=-1.; float xy[2]; for(int is=0; is<96; is++){ cstrip.Set(iv,ip,is); xy[0] = cstrip.GetX(); xy[1] = cstrip.GetY(); if( trackcoordinate[ip][iv] >= xy[iv] - 0.5*PITCH && trackcoordinate[ip][iv] < xy[iv] + 0.5*PITCH && true){ trkstrip[ip][iv] = is; break; } }; } } // cout << " 1 ------------------ init"<Print("conta"); //<><><><><><><><><><><><><><><><><><><><><><><><> // LOOP OVER HIT STRIPS // - to set charge collected in each plane // - to fill energy-deposit plot (if required) //<><><><><><><><><><><><><><><><><><><><><><><><> int isimu = CaloElectron_parameters::Get()->isimu; if(isimu==0)cstrip = CaloStrip(cl1,false);//conferma da Emiliano if(isimu==1)cstrip = CaloStrip(cl1,true); float xy[2]; for(int ih=0;ihistrip;ih++){ int iv=-1; int ip=-1; int is=-1; cl1->DecodeEstrip(ih,iv,ip,is); cstrip.Set(iv,ip,is); // enestr[is][ip][iv] = cstrip.GetE(); xy[0] = cstrip.GetX(); xy[1] = cstrip.GetY(); if( TMath::Abs(trackcoordinate[ip][iv]-xy[iv]) < RMAX ) qplane0[ip][iv] += cstrip.GetE(); //<< QPLANE0 bool maskpl = CaloElectron_parameters::Get()->maskpl[ip][iv]; if( ip>=ipmin && ipFill( (float)(is+iv*96), (float)ip, cstrip.GetE()); // retrieve the coordinate of the bottom-left corner of the plane float corner[] = {0.,0.}; GetCornerCoord(ip,iv,corner[0],corner[1]); h_qtot[iv]->Fill( xy[iv]-corner[iv], (float)ip, cstrip.GetE()); } // cout <<(float)(is+iv*96)<<(float)ip<Print("conta"); // ------------------------------------------------ // set track intersection coordinate in each plane // and evaluate shower depth // ------------------------------------------------ float trkcoordz[22][2]; ///< track coordinates (PAMELA r.s.) for(int ip=0; ip<22; ip++){ for(int iv=0; iv<2; iv++){ cstrip.Set(iv,ip,0); trkcoordz[ip][iv] = cstrip.GetZ(); } } tgx = (trackcoordinate[0][0]-trackcoordinate[21][0])/(trkcoordz[0][0]-trkcoordz[21][0]); tgy = (trackcoordinate[0][1]-trackcoordinate[21][1])/(trkcoordz[0][1]-trkcoordz[21][1]); tg = sqrt(pow(trackcoordinate[0][1]-trackcoordinate[21][1],2)+pow(trackcoordinate[0][0]-trackcoordinate[21][0],2))/(trkcoordz[0][1]-trkcoordz[21][1]); bool TRACK_OUT = false; for(int ip=0; ip<22; ip++){ for(int iv=1; iv>=0; iv--){ if(iv==0){ trkcoordx[ip][0] = trackcoordinate[ip][0]; //track intersection coordinate trkcoordy[ip][0] = trackcoordinate[ip][1] + (trkcoordz[ip][0]-trkcoordz[ip][1])*tgy; //track intersection coordinate }else{ trkcoordx[ip][1] = trackcoordinate[ip][0] + (trkcoordz[ip][1]-trkcoordz[ip][0])*tgx; //track intersection coordinate trkcoordy[ip][1] = trackcoordinate[ip][1]; //track intersection coordinate } // --------------------------------------------- // if the track go out of the calorimeter, break // --------------------------------------------- if( trkstrip[ip][iv] == -1 ){ //TRACK_OUT = true; if(debug)cout << "ip="< TRACK OUT"; } if( !TRACK_OUT ){ // shower depth in units of radiation length (TO BE CHECKED) tplane[ip][iv] = GetNWLayers(ip,iv) * sqrt(tgx*tgx+tgy*tgy+1) * WTICK/WX0;//sqrt(tgx*tgx+tgy*tgy+1)=1/cos(atan(tg) qplane1[ip][iv] = qplane0[ip][iv]; // initialize qplane1 }else return false; } } // cout << " 3 ------------------ get track coordinates"<Print("conta"); if(GetQ(0)<1){ cout<<"Don't go on ..GetQ(0) "<21){ cout<<"Don't go on ..GetShowerMaximum(0) "<1)cout<<"WARNING! - lateral correction iterated "<Print("conta"); if(GetQ(1)<1){ cout<<"Don't go on ..GetQ(1) "<Print("conta"); if( ret==0 ){ corr = ApplyLateralCorrection( GetShowerMaximum(2) ); ret = ApplyLongitudinalFit(dolongfit); corr__l = GetLongitudinalCorrection(); chi2 = ProfileTest(); } if(debug){ cout << "LATERAL CORRECTION FACTOR (iterated) = "<Print("conta"); // if(ret==0 || ret==10){ // if(debug)cout << ">> Longitudinal correction from level "<600){ // cout<< "too big GetLongitudinalFcnout() "<> problems with Longitudinal correction!"<tbar[ip][iv]; // trkstrip[ip][iv]=ctrk->tibar[ip][iv]; } } return Set(cl1,trackcoordinate); }; /** * \brief Set event */ bool CaloElectron::Set(PamLevel2 *l2, int ntr){ CaloLevel1* cl1 = l2->GetCaloLevel1(); CaloTrkVar* ctrk = 0; if( ntr < l2->GetTrkLevel2()->GetNTracks() )ctrk = l2->GetTrack(ntr)->GetCaloTrack(); return Set(cl1,ctrk); }; /** * \brief Method to apply lateral correction * @param maxl shower maximum, in units of W-layers */ float CaloElectron::ApplyLateralCorrection( float maxl ){ bool debug = CaloElectron_parameters::Get()->debug; float TAUMAX = CaloElectron_parameters::Get()->TAUMAX; // float RMAX = CaloElectron_parameters::Get()->RMAX; int ipmin = CaloElectron_parameters::Get()->ipmin; int ipmax = CaloElectron_parameters::Get()->ipmax; if( debug ) cout << "CaloElectron::ApplyLateralCorrection(maxl="<=0; iv--){ double corr=1.; // evaluate the shower-depth of the plane float nlayer = (float)GetNWLayers(ip,iv); double tau = (double)(nlayer-ipmin)/(double)maxl; int ibintau = (int)(tau/0.25); if( ibintau>=12 ) ibintau=11; // retrieve the coordinate of the bottom-left corner of the plane float xcorner = 0; float ycorner = 0; GetCornerCoord(ip,iv,xcorner,ycorner); // evaluate track coordinate relative to the plane corner double xpl = (double)trkcoordx[ip][iv] - (double)xcorner; double ypl = (double)trkcoordy[ip][iv] - (double)ycorner; // trkcoordxpl[ip][iv] = xpl; // trkcoordypl[ip][iv] = ypl; //cout<<"ip "<TAUMAX bool maskpl = CaloElectron_parameters::Get()->maskpl[ip][iv]; // if( !maskpl[ip][iv] ){ if( !maskpl ){ if( tplane[ip][iv] > 0 && tauSetMarkerColor(2);gqx1->SetMarkerStyle(7);gqx1->Draw("AP"); // gqx->SetMarkerColor(1);gqx->SetMarkerStyle(7);gqx->Draw("Psame"); // a.cd(2); // gqy1->SetMarkerColor(2);gqy1->SetMarkerStyle(7);gqy1->Draw("AP"); // gqy->SetMarkerColor(1);gqy->SetMarkerStyle(7);gqy->Draw("Psame"); // a.Update(); // int salvalo; // cout<<"save dodrawq0q1 (1 yes, 0 no)??"; // cin>>salvalo; // if(salvalo>1) a.Print(Form("./gq0q1_%d.root",salvalo)); // else if(salvalo==1) a.Print("electronq0q1.root"); // }// end of if(dodrawq0q1) // //questo disegna la distribuzione laterale sul un certo piano e vista // //con la posizione dei gap e la funzione usata per correggere // if(dodrawq0q1){ // int iv,ip,iiv(0); // float iwmax,iw; // cout<<"which plane and view?"<>ip>>iv; // if(iv==0)iiv=0; // if(iv==1 && ip%2) iiv=1; // if(iv==1 && !ip%2) iiv=2; // iwmax=GetShowerMaximum(0); // iw=ip+(iv-1); // int ibintau=(int)((iw/iwmax)/0.25); // cout<<"plane "<=12) ibintau=11; // int nparam=5; // TF1 ff = TF1("fradpro",fradpro,-RMAXsp,RMAXsp,nparam); // Double_t param[5]; // param[0]=file_rt[ibintau][iiv]; // param[1]=file_p[ibintau][iiv]; // param[2]=file_rc[ibintau][iiv]; // param[3]=qplane0[ip][iv]; // //param[4]=trkcoordx[ip][iv]; // param[4]=0.; // cout<<"plane "< "<Fill(posgap1,100.); // hgap->Fill(posgap2,100.); // TH1F *h=new TH1F("h","h",34,-RMAXsp,RMAXsp); // float binsize=8./34.; // double e(0),d(0),etot(0); // for(int is=0;is<96;is++){ // e=enestr[is][ip][iv]; // if(e>0.){ // st.Set(iv,ip,is); // if (iv==0) d=st.GetX()-trkcoordx[ip][iv]; // if (iv==1) d=st.GetY()-trkcoordy[ip][iv]; // if(TMath::Abs(d)Fill(d,e/binsize); // } // } // } // TCanvas a;a.Divide(2,1);a.cd(1); // h->Draw();//ff.Draw("same"); // a.cd(2);ff.Draw(); h->Draw("same");hgap->SetFillColor(2);hgap->Draw("same"); // a.Update(); // cout<<"plane "<Integral(width) "<Integral("width")<<" h->Integral() "<Integral()<<" ff.Integral() "<>salvalo; // //potrei provare a calcolare il fattore di correzione su ogni piano da questo confronto e // //confrontarlo con quello che viene dal mio metodo // } // return corr; } //////////////////////////////////////////////////////////////////////// /** * 1-dimension function describing lateral distribution of the * shower as viewed by calorimeter * (projection of 3d function in one direction) * * xi[0] = x or y coordinate relative to shower axis * parmin[0] = rt * parmin[1] = p * parmin[2] = rc * parmin[3] = norm * parmin[4] = x0,y0 * */ //////////////////////////////////////////////////////////////////////// double fradpro(Double_t *xi, Double_t *parmin) { double fradpromin2,p,rt,rc,es,x,pig,norm,c; x = *xi; pig = acos(-1.); rt = parmin[0]; p = parmin[1]; rc = parmin[2]; norm = parmin[3]; c = parmin[4]; x = x-c; es = 1.5; fradpromin2 = p*pig*pow(rc,2)/pow((pow(x,2)+pow(rc,2)),es); fradpromin2 = fradpromin2+(1-p)*pig*pow(rt,2)/pow((pow(x,2)+pow(rt,2)),es); fradpromin2 = norm*fradpromin2/(2*pig); //cout<<"x,fradpromin2 "<< x<<" "<file_rt[ibintau][ivqui]; float file_p = CaloElectron_parameters::Get()->file_p[ibintau][ivqui]; float file_rc = CaloElectron_parameters::Get()->file_rc[ibintau][ivqui]; ff.SetParameter(0,file_rt); ff.SetParameter(1,file_p); ff.SetParameter(2,file_rc); double corr = GetLateralCorrection(xpl,ypl,&ff,iv); return corr; }; /** * \brief Evaluate lateral correction factor */ double CaloElectron::GetLateralCorrection(double xpl, double ypl, TF2* ff,int iv){ float RMAXsp = CaloElectron_parameters::Get()->RMAXsp; float RMAX = CaloElectron_parameters::Get()->RMAX; double x1,x2,x3,x4,x5,x6,ps[3]; x1 = DEAD; x2 = x1 + PITCH*32; x3 = x2 + DEAD + GLUE + DEAD; x4 = x3 + PITCH*32; x5 = x4 + DEAD + GLUE + DEAD; x6 = x5 + PITCH*32; ps[0] = x1; ps[1] = x3; ps[2] = x5; double integgap(0),integgaptmp(0),integnogap(0),correggif(0); double epsil=0.0001; for (Int_t ii=0;ii<3;ii++){ for (Int_t jj=0;jj<3;jj++){ double xmi = ps[ii] - xpl; double xma = xmi + PITCH*32; double ymi = ps[jj] - ypl; double yma = ymi + PITCH*32; int dointeg=1; if(iv==0){ if(xmi<-RMAXsp && xma>-RMAXsp) xmi=-RMAXsp; if(xma>RMAXsp && xmiRMAXsp || xma<-RMAXsp)dointeg=0; } if(iv==1 || iv==2){ if(ymi<-RMAXsp && yma>-RMAXsp) ymi=-RMAXsp; if(yma>RMAXsp && ymiRMAXsp || yma<-RMAXsp)dointeg=0; } if(dointeg==1){ integgaptmp=ff->Integral(xmi,xma,ymi,yma,epsil); integgap += integgaptmp; } } } double RPMAX=40.; double xmin(0),xmax(0),ymin(0),ymax(0); if(iv==0){ ymin=-RPMAX; ymax=RPMAX; xmin=-RMAX; xmax=RMAX; } if(iv==1 || iv==2){ xmin=-RPMAX; xmax=RPMAX; ymin=-RMAX; ymax=RMAX; } integnogap=ff->Integral(xmin,xmax,ymin,ymax,epsil); correggif=integgap/integnogap; return correggif; } // --------------------------------------------------------------------- // TMinuit does not allow fcn to be a member function, and the function // arguments are fixed, so the one of the only ways to bring the data // into fcn is to declare the data as global. // --------------------------------------------------------------------- // Int_t iuse; Double_t zfit[44],tfit[44],errorzfit[44],errortfit[44]; //Float_t corr,m,q,lp1m,lp2m,sig1,sig2;Float_t parglobali[4]; //______________________________________________________________________________ Double_t func(Double_t *tin,Double_t *par) { Double_t gaa,a,tm,et,value,t,t0; t = *tin; et = par[0]; a = par[1]; tm = par[2]; t0 = par[3]; gaa = TMath::Gamma(a); value = et*((a-1)/(tm*gaa))*pow(((a-1)*(t-t0)/tm),(a-1))*exp(-(a-1)*(t-t0)/tm); return value; } //______________________________________________________________________________ // fcn passes back f = chisq the function to be minimized. void fcn(Int_t &npar, Double_t *gin, Double_t &f, Double_t *par, Int_t iflag) { int iusequi=0; Double_t chisq = 0.; for (int i=0;i=par[3]){ iusequi++; Double_t fu=func(&tfit[i],par); Double_t delta = (zfit[i]-fu)/errorzfit[i]; chisq += delta*delta; } } //cout<<"iusequi,par,fcn "< temporarily commented (problems with TMinuit!!)"<debug; // float TAUMAX = CaloElectron_parameters::Get()->TAUMAX; // // float RMAX = CaloElectron_parameters::Get()->RMAX; // int ipmin = CaloElectron_parameters::Get()->ipmin; // int ipmax = CaloElectron_parameters::Get()->ipmax; // if( debug ) cout << "CaloElectron::ApplyLongitudinalFit("<SetPrintLevel(-1); // if( debug) minuit->SetPrintLevel(-1); // minuit->SetFCN(fcn); // // cout << "<><><><><><><><><><><><><"<=0; iv--){ // bool maskpl = CaloElectron_parameters::Get()->maskpl[ip][iv]; // if(!maskpl){ // if(longto==0) zfit[iuse] = qplane0[ip][iv]; // if(longto==1) zfit[iuse] = qplane1[ip][iv]; // tfit[iuse] = (double)tplane[ip][iv]-(double)tplane[ipmin][1]; // errortfit[iuse] = 0.01; // errorzfit[iuse] = sqrt( zfit[iuse] ); // if(zfit[iuse]<0.0001) errorzfit[iuse] = 1.; // // if(debug)cout<<"iuse,ip,iv,tplane,t,z "<mnparm(i, parname[i].c_str(),vstart[i],step[i],limmin[i],limmax[i],ierflg); // minuit->FixParameter(3);//fix starting point // arglist[0] = 500; // minuit->mnexcm("MIGRAD", arglist ,1,ierflg); // err__l = ierflg; // if(ierflg>0){ // if(debug){ // cout<<"ierflg "<GetParameter(i,vend[i],errvend[i]); // if(debug)cout< v-end "<mnfree(0); //restore all fixed parameters // for (int i=0; i<4; i++){ // vstart[i] = vend[i]; // minuit->mnparm(i, parname[i].c_str(),vstart[i],step[i],0.,0.,ierflg); // } // minuit->FixParameter(3);//fix starting point // arglist[0] = 500; // minuit->mnexcm("MIGRAD", arglist ,1,ierflg); // err__l = ierflg; // if(ierflg>0){ // if(debug){ // cout<<"ierflg "<GetParameter(i,vend[i],errvend[i]); // if(debug)cout< v-end "<SetLineWidth(1); // for(int i=0; i<4; i++){ // par__l[i] = vend[i]; // if(par__l[i]<0 || par__l[2]>22 || par__l[1]>50){ // cout<<" converge a valori assurdi... escluso"<maskpl[ip][iv]; // if(!maskpl){ // double tpla = (double)tplane[ip][iv]; // Double_t fu1=func(&tpla,vend); // qplanefit[ip][iv] = fu1; // } // } // } // Double_t graddummy[4]; // double outfcn; // minuit->Eval(4,graddummy,outfcn,vend,1); // if(iuse>3)chi2__l = (float)outfcn/(float)(iuse-3); // else chi2__l = 0.; // delete minuit; return err__l; } /* * \brief Evaluate longitudinal correction */ float CaloElectron::GetLongitudinalCorrection(){ bool debug = CaloElectron_parameters::Get()->debug; float TAUMAX = CaloElectron_parameters::Get()->TAUMAX; int ipmin = CaloElectron_parameters::Get()->ipmin; int ipmax = CaloElectron_parameters::Get()->ipmax; // -------------------------------------------- // evaluate longitudinal // -------------------------------------------- Double_t corr = 0.; Double_t t3,intecalo3,intecalo,tmaxcalo; if( err__l == 0 ){ t3 = par__l[3] + TAUMAX*par__l[2]; TF1 *ffunc = GetFunc_Longitudinal(); intecalo3 = ffunc->Integral(par__l[3],t3); // if(debug)cout<<"integro da "<t3 "<<" intecalo=intecalo3 "<Integral(par__l[3],tmaxcalo); // if(debug)cout<<"integro da "<SetMarkerSize(0.8); graph->SetMarkerStyle(20); return graph; } // TGraphErrors *CaloElectron::GetGraph_Longitudinal_Fit(){ double zfunc[44]; double errorzfunc[44]; TF1 *fu = new TF1("fu",func,0.,tfit[iuse-1],4); for(int i=0; i<4; i++)fu->SetParameter(i,par__l[i]); for(int i=0; iEval(tfit[i]);; errorzfunc[i] = 0.; if(zfunc[i]>0.)errorzfunc[i] = sqrt(zfunc[i]); } delete fu; TGraphErrors *graph = new TGraphErrors(iuse,tfit,zfunc,errortfit,errorzfunc); graph->SetMarkerSize(0.8); graph->SetMarkerColor(2); graph->SetMarkerStyle(20); return graph; } // TGraphErrors *CaloElectron::GetGraph_Longitudinal_Integral(){ double zfitint[44]; double errorzfitint[44]; zfitint[0] = zfit[0]; for(int i=1; iSetMarkerSize(0.8); graph->SetMarkerStyle(24); return graph; } // TGraphErrors *CaloElectron::GetGraph_Longitudinal_Integral_Fit(){ double zfunc[44]; double errorzfunc[44]; TF1 *fu = new TF1("fu",func,0.,tfit[iuse-1],4); for(int i=0; i<4; i++)fu->SetParameter(i,par__l[i]); zfunc[0] = fu->Eval(tfit[0]);; for(int i=1; iEval(tfit[i]);; errorzfunc[i] = 0.; if(zfunc[i]>0.)errorzfunc[i] = sqrt(zfunc[i]); } delete fu; TGraphErrors *graph = new TGraphErrors(iuse,tfit,zfunc,errortfit,errorzfunc); graph->SetMarkerSize(0.8); graph->SetMarkerStyle(24); graph->SetMarkerColor(2); graph->SetLineColor(2); return graph; } // TF1 *CaloElectron::GetFunc_Longitudinal(){ TF1 *fu = new TF1("longitudinalprofile",func,0.,tfit[iuse-1],4); for(int i=0; i<4; i++)fu->SetParameter(i,par__l[i]); fu->SetLineColor(2); // fu->Draw(); // if(err__l!=0)fu->SetLineStyle(12); return fu; } // TGraphErrors *CaloElectron::GetGraph_Lateral(int ipp, int ivv){ cout << "TGraphErrors *CaloElectron::GetGraph_Lateral("<cl1 << endl; CaloLevel1* cl1 = CaloElectron_parameters::Get()->cl1; if(!cl1)return NULL; float xx[96]; float qq[96]; float errxx[96]; float errqq[96]; CaloStrip cstrip; for(int is=0; is<96; is++){ cstrip.Set(ivv,ipp,is); float xy[2]; xy[0] = cstrip.GetX() - trkcoordx[ipp][ivv]; xy[1] = cstrip.GetY() - trkcoordy[ipp][ivv]; qq[is] = 0.; xx[is] = xy[ivv]; errqq[is] = 0.; errxx[is] = 0.5*PITCH; } // ----------------------------------- // set charge collected in each plane // ----------------------------------- int isimu = CaloElectron_parameters::Get()->isimu; if(isimu==0)cstrip = CaloStrip(cl1,false); if(isimu==1)cstrip = CaloStrip(cl1,true); for(int ih=0;ihistrip;ih++){ int iv=-1; int ip=-1; int is=-1; cl1->DecodeEstrip(ih,iv,ip,is); cstrip.Set(iv,ip,is); float xy[2]; xy[0] = cstrip.GetX() - trkcoordx[ip][iv]; xy[1] = cstrip.GetY() - trkcoordy[ip][iv]; if( ip==ipp && iv==ivv ){ qq[is] = cstrip.GetE(); xx[is] = xy[iv]; if(qq[is]>0)errqq[is] = sqrt( qq[is] ); } } TGraphErrors *graph = new TGraphErrors(96,xx,qq,errxx,errqq); graph->SetMarkerSize(0.8); graph->SetMarkerStyle(20); return graph; } // // TF1 *CaloElectron::GetFunc_Lateral(int ip, int iv, int icorr){ // int iiv(0); // if(iv==0)iiv=0; // if(iv==1 && ip%2) iiv=1; // if(iv==1 && !ip%2) iiv=2; // float iwmax,iw; // iwmax = GetShowerMaximum(icorr); // iw = ip+(iv-1); // int ibintau = (int)((iw/iwmax)/0.25); // if(ibintau>=12) ibintau=11; // float file_rt = CaloElectron_parameters::Get()->file_rt[ibintau][iiv]; // float file_p = CaloElectron_parameters::Get()->file_p[ibintau][iiv]; // float file_rc = CaloElectron_parameters::Get()->file_rc[ibintau][iiv]; // float RMAXsp = CaloElectron_parameters::Get()->RMAXsp; // int nparam=5; // TF1 *ff = new TF1("fradpro",fradpro,-RMAX,RMAX,nparam); // Double_t param[5]; // param[0] = file_rt; // param[1] = file_p; // param[2] = file_rc; // param[3] = qplanefit[ip][iv];//qplane0[ip][iv]; // param[4] = 0.; // for(int i=0;iSetParameter(i,param[i]); // // cout<<" "< "<SetMarkerSize(0.8); // graph->SetMarkerStyle(1); graph->SetLineColor(2); return graph; } /** * evaluate the expected average profile, by integrating the expected charge distribution * over each strip * */ void CaloElectron::GetProfile(int ip, int iv, float xx[], float qq[],float errxx[], float errqq[] ){ // bool debug = CaloElectron_parameters::Get()->debug; // float xx[96]; // float qq[96]; // float errxx[96]; // float errqq[96]; CaloLevel1* cl1 = CaloElectron_parameters::Get()->cl1; if(!cl1)cout << " ERROR -- CaloLevel1* cl1 == NULL"< tau-bin // float iwmax,iw; // iwmax = GetShowerMaximum(icorr); // // iw = ip+(iv-1); //!!!!!!!!!!!!! BUG!?!?! // iw = ip-(iv-1); // int ibintau = (int)((iw/iwmax)/0.25); // if(ibintau>=12) ibintau=11; // cout << " maximum (W)"<ipmin; float maxl = GetShowerMaximum(2); float nlayer = (float)GetNWLayers(ip,iv); double tau = (double)(nlayer-ipmin)/(double)maxl; int ibintau = (int)(tau/0.25); if(ibintau>=12) ibintau=11; // if(debug){ // cout << " maximum (W)"<file_rt[ibintau][iiv]; float file_p = CaloElectron_parameters::Get()->file_p[ibintau][iiv]; float file_rc = CaloElectron_parameters::Get()->file_rc[ibintau][iiv]; float RMAXsp = CaloElectron_parameters::Get()->RMAXsp; // if(debug){ // cout << " RT "<-RMAXsp) xmi = -RMAXsp; if(xma>RMAXsp && xmiRMAXsp || xma<-RMAXsp) dointeg = 0; } if(iv==1 || iv==2){ if(ymi<-RMAXsp && yma>-RMAXsp) ymi = -RMAXsp; if(yma>RMAXsp && ymiRMAXsp || yma<-RMAXsp) dointeg = 0; } if(dointeg==0) continue; // bool DOFAST = false; if(fabs(xx[is])>2.)DOFAST=true; double integral = 0.; if(DOFAST){ // // integrale veloce // double fmi,fma,k,c; fx.SetParameter(3,xmi); fmi = fx.Integral(ymi,yma); fx.SetParameter(3,xma); fma = fx.Integral(ymi,yma); k = 0.; if(fmi>0.&&fma>0.&&(xma-xmi)>0.)k=log(fma/fmi)/(xma-xmi); c = log(fmi)-k*xmi; if(fabs(k)>1.e-6)integral += (fma-fmi)/k; }else{ // // integrale lento ma piu` preciso // integral = ff.Integral(xmi,xma,ymi,yma,epsil); } integgap += integral; // cout << setw(2)<0 )errqq[is] = sqrt(qq[is]); } } /** * */ float CaloElectron::ProfileTest(){ int ipmin = CaloElectron_parameters::Get()->ipmin; int ipmax = CaloElectron_parameters::Get()->ipmax; float RMAX = CaloElectron_parameters::Get()->RMAX; // float TAUMAX = CaloElectron_parameters::Get()->TAUMAX; TH2F* h_qfit[2]; TH2F* h_qtot[2]; // // retrieve histrograms of shower lateral profile // for(int iv=0; iv<2; iv++){ h_qfit[iv] = CaloElectron_parameters::Get()->h_qfit[iv]; //average if(!h_qfit[iv])return 0.; h_qfit[iv]->Reset(); //-->reset h_qtot[iv] = CaloElectron_parameters::Get()->h_qtot[iv]; //data if(!h_qtot[iv])return 0.; } // float maxl = GetShowerMaximum(2); // double chi2tmp = 0.; int ndof = 0; // cout << "<><><><><><><><><><><><><><>"<=0; iv--){ // loop over views bool maskpl = CaloElectron_parameters::Get()->maskpl[ip][iv]; float corner[] = {0.,0.}; GetCornerCoord(ip,iv,corner[0],corner[1]); if( ip >= ipmin && ip < ipmax && !maskpl && true){ // float xx[96]; float qq[96]; float errxx[96]; float errqq[96]; // float trkcoord[2]; trkcoord[0] = trkcoordx[ip][iv]; trkcoord[1] = trkcoordy[ip][iv]; // GetProfile(ip,iv,xx,qq,errxx,errqq); //<<< average profile // float nlayer = (float)GetNWLayers(ip,iv); // double tau = (double)(nlayer-ipmin)/(double)maxl; for(int is=0; is<96; is++) { if( fabs(xx[is]) < RMAX && // tauFill( (float)(is+iv*96), (float)ip, qq[is]); h_qfit[iv]->Fill( xx[is]+trkcoord[iv]-corner[iv], (float)ip, qq[is]); float qqq = h_qtot[iv]->GetBinContent((is+iv*96+1),ip+1); // cout << setw(15)<< qqq<0) chi2tmp += pow((double)(qq[is]-qqq),2.)/sqrt((double)qq[is]); ndof++; } } // cout << "<><><><><><><><><><><><><><>"<ProjectionX("hfitpx",ip+1,ip+2); TH1D* htotpro = h_qtot[iv]->ProjectionX("htotpx",ip+1,ip+2); // cout <<"Mean "<< setw(10)<GetMean() << setw(10)<GetMean() << endl; // cout <<"RMS "<< setw(10)<GetRMS() << setw(10)<GetRMS() << endl; // cout <<"Skew "<< setw(10)<GetSkewness() << setw(10)<GetSkewness() << endl; // cout <<"Kurt "<< setw(10)<GetKurtosis() << setw(10)<GetKurtosis() << endl; if(GetShowerMaximumX0(2)>0.) TAU[ip][iv] = tplane[ip][iv]/GetShowerMaximumX0(2); if(htotpro->GetEntries()>4){ RMS[ip][iv] = htotpro->GetRMS(); SKEW[ip][iv] = htotpro->GetSkewness(); KURT[ip][iv] = htotpro->GetKurtosis(); } // cout << setw(3) << ip << setw(3) << iv ; // cout << setw(10) << TAU[ip][iv]; // cout << setw(10) << RMS[ip][iv]; // cout << setw(10) << SKEW[ip][iv]; // cout << setw(10) << KURT[ip][iv]; // cout << endl; // hfitpro->Delete(); htotpro->Delete(); // cout << "<><><><><><><><><><><><><><>"<<><><><><><><><><><><><><>"<KolmogorovTest(h_qtot,"ND"); // double kold = h_qfit->KolmogorovTest(h_qtot,"NDM"); // h_qfit->Sumw2(); // h_qtot->Sumw2(); // double kolp = h_qfit->KolmogorovTest(h_qtot,"D"); // double kold = h_qfit->KolmogorovTest(h_qtot,"DM"); // double chi2tmp = h_qfit->Chi2Test(h_qtot,"WWP"); // cout << "KKKKK "<3 )chi2 = (float)(chi2tmp/(double)(ndof-3)); else chi2 = 0.; return chi2; } /** * */ float CaloElectron::GetMaxResidual(){ float max = 0; for(int iv=0; iv<2; iv++){ for(int ip=0; ip<22; ip++){ if( // qplane1[ip][iv] > 0. && // fabs(qplane1[ip][iv]-qplanefit[ip][iv])/sqrt(qplane1[ip][iv]) > fabs(max) && fabs(qplane1[ip][iv]-qplanefit[ip][iv]) > fabs(max) && true){ max = qplane1[ip][iv]-qplanefit[ip][iv]; } } } return max; } int CaloElectron::GetNRun(){ bool POS = true; bool NEG = true; int nrun = 0; for(int ip=0; ip<22; ip++){ for(int iv=1; iv>=0; iv--){ if( qplane1[ip][iv] > qplanefit[ip][iv] && NEG ){ nrun++; POS = true; NEG = !POS; } if( qplane1[ip][iv] <= qplanefit[ip][iv] && POS ){ nrun++; NEG = true; POS = !NEG; } } } return nrun; } float CaloElectron::GetMaxRun(){ bool POS = true; bool NEG = true; int nrun = 0; float sum[44]; for(int ip=0; ip<44; ip++)sum[ip]=0.; // for(int ip=0; ip<22; ip++){ for(int iv=1; iv>=0; iv--){ if( qplane1[ip][iv] > qplanefit[ip][iv] && NEG ){ nrun++; POS = true; NEG = !POS; } if( qplane1[ip][iv] <= qplanefit[ip][iv] && POS ){ nrun++; NEG = true; POS = !NEG; } sum[nrun-1] += qplane1[ip][iv]-qplanefit[ip][iv]; } } // float max=0; for(int ip=0; ip<44; ip++) if( fabs(sum[ip]) > fabs(max) )max=sum[ip]; return max; } /** * \brief Method to retrieve the coordinates of the plane bottom-left corner * (l'angolo è dell'inizio del rivelatore compreso il dead) */ void CaloElectron::GetCornerCoord(int ip, int iv, float& xorig, float& yorig){ // coordinate meccaniche dei piani in cm CaloStrip st = CaloStrip(); int isimu = CaloElectron_parameters::Get()->isimu; if(isimu==0)st.UseStandardAlig(); if(isimu==1)st.UseMechanicalAlig(); yorig = -0.1*st.GetYalig()+0.1; xorig = -0.1*st.GetXalig(); if(ip%2!=1){ //ip 0,2,4,6,...,20 if(iv==0){ yorig = yorig; xorig = xorig+0.05; }else{ yorig = yorig-0.05; xorig = xorig+0.1; } }else{ //ip 1,3,5,..,21 if(iv==0){ yorig = yorig-0.2; xorig = xorig-0.05; }else{ yorig = yorig-0.15; xorig = xorig-0.1; } } } /** * \brief Print the event */ void CaloElectron::Print(){ int ipmin = CaloElectron_parameters::Get()->ipmin; int ipmax = CaloElectron_parameters::Get()->ipmax; // cout<<"Print idiev "< qx1 qy1 -------> qx(fit) qy(fit)"<ipmin){ qx0 = qplane0[il-1][0]; qy0 = qplane0[il][1]; qx1 = qplane1[il-1][0]; qy1 = qplane1[il][1]; qx2 = qplanefit[il-1][0]; qy2 = qplanefit[il][1]; } if(il==ipmin){ // qx0 = 0; qy0 = qplane0[ipmin][1]; // qx1 = 0; qy1 = qplane1[ipmin][1]; // qx2 = 0; qy2 = qplanefit[ipmin][1]; } if(il==ipmax){ qx0 = qplane0[ipmax-1][0]; // qy0 = 0.; qx1 = qplane1[ipmax-1][0]; // qy1 = 0.; qx2 = qplanefit[ipmax-1][0]; // qy2 = 0.; } cout << " "<TAUMAX; float RMAX = CaloElectron_parameters::Get()->RMAX; cout << "Total collectced charge (mip) "<0.)cout <<" ( "<< 100.*(qtot-GetQ(0))/qtot<<" % )"<FixParameter(2,1.3); f4->SetParameter(0,-0.8013231); f4->SetParameter(1,2.276176); f4->SetParameter(2,-0.8295547); f4->SetParameter(3,0.06835571); float lnmax=TMath::Log(par__l[2]); float lnmax1=TMath::Log(GetShowerMaximumX0(1)); if(lnmax>2.4 || GetIerflg()>0){ cout<<"max "<Eval(lnmax); //cout<<"icorr 3...lnmax "<=20 || ma<=4)return false; // int ima=(int)ma+ipmin; // float strima=0; // for(int iv=0;iv<=1;iv++){ // strima=GetStripW(ima,iv); // if(strima<11 || strima>86 || strima==33 || strima==32 || strima==65 || strima==64) return false; // } // if(level==1) return true; // if(outfcn>600) return false; // if(minuitierflg>0) return false; // float lma1=log(par__l[1]); // float lma2=log(par__l[2]); // float lma1expected=0.92*lma2; // if(lma2<1.3 || lma2>2.3) return false; // if(TMath::Abs(lma1-lma1expected)>0.5) return false; return true; } ////////////////////////////////////////////////////////////////////////// /** * Fill calibration histos */ void CaloElectron::Calibration_Fill(){ bool debug = CaloElectron_parameters::Get()->debug; float TAUMAX = CaloElectron_parameters::Get()->TAUMAX; float RMAX = CaloElectron_parameters::Get()->RMAX; int ntau = CaloElectron_parameters::Get()->par_ntau; float *taubin = CaloElectron_parameters::Get()->par_taubin; CaloLevel1* cl1 = CaloElectron_parameters::Get()->cl1; // if(!cl1)cout << "NB --> missing CaloLevel1, needed for calibration !!"<isimu; // ///////////////////////////////////// // some parameters to select good shower // ///////////////////////////////////// float stoll_g = 5;//maximum n.strips from gaps float stoll_b = 10;//maximum n.strips from borders float toll = stoll_b*PITCH;//3.;//(cm) distance of shower axis from border on the last silicon plane float qmin = 10;//(mip)minimum energy deposit per plane // // --------------- // lateral profile // --------------- CaloStrip cstrip; if(isimu==0)cstrip = CaloStrip(cl1,false); if(isimu==1)cstrip = CaloStrip(cl1,true); if(debug)cout << "====== n.strip "<istrip< xcorner_l + toll && trkcoordx[ip][iv] < xcorner_r - toll && trkcoordy[ip][iv] > ycorner_l + toll && trkcoordy[ip][iv] < ycorner_r - toll && true)CONTAINED = true; // // if(!CONTAINED)return; // discard event if shower is not contained // ----------------------------------------------- // first loop over planes to determine the tau-bin // and verify some general conditions: // - shower axis in each plane far from gaps // - minimal energy deposit // ----------------------------------------------- int ibintau[22][2]; // for(int ip=0; ip<22; ip++){ for(int iv=0; iv<2; iv++){ // ibintau[ip][iv]=-1; // ------------ // shower depth // ------------ float tau = tplane[ip][iv]/showermax; if(debug)cout <<" --> plane "<TAUMAX)continue; // discard plane if tau exceed TAUMAX // // --------------------------------------- // containment conditions (plane by plane) // --------------------------------------- // shower axis should be far from gaps // if(qplane0[ip][iv]= stoll_b && trkstrip[ip][iv] < 32 - stoll_g )|| ( trkstrip[ip][iv] >= 32 + stoll_g && trkstrip[ip][iv] < 64 - stoll_g )|| ( trkstrip[ip][iv] >= 64 + stoll_g && trkstrip[ip][iv] < 96 - stoll_b )|| false)CONTAINED = true; // if(!CONTAINED)continue; // discard plane if shower traverses gaps // for(int itau = 0; itautau)break; if(taubin[itau+1]>=tau){ ibintau[ip][iv]=itau; break; } } if(debug)cout << " --> tau-bin "<istrip;ih++){//loop over hit strips // int iv=-1; // int ip=-1; // int is=-1; // cl1->DecodeEstrip(ih,iv,ip,is); // // NBNB --> credo di dover riempire con TUTTE le strisce // for(int ip=0; ip<22; ip++){ for(int iv=0; iv<2; iv++){ int ivv=iv; //x (0) and yeven (1) if(ip%2)ivv=2; //yodd (2) // if(ibintau[ip][iv]==-1)continue; //outside tau range or plane discarded // for(int is=0; is<96; is++){ cl1->GetEstrip(iv,ip,is); cstrip.Set(iv,ip,is); // float xy[2]; xy[0] = cstrip.GetX() - trkcoordx[ip][iv]; xy[1] = cstrip.GetY() - trkcoordy[ip][iv]; // if( TMath::Abs(xy[iv]) >= RMAX )continue;// discard strip if exceed TAUMAX // // FRACTION OF CHARGE COLLECTED BY THE STRIP // float pitch = 1.;//PITCH; float F = cstrip.GetE(); F = F / qplane0[ip][iv]; // normalized to total charge F = F / pitch; // per unit length // // weigths // double calo_noise = 0.2; //MIP // if(F==0.)calo_noise = 0.7; //MIP (threshold) double DF2 = 0.; DF2 += pow(calo_noise/cstrip.GetE(),2.)*pow((double)F,2.); // DF2 += pow((double)F,2.)/(double)qplane0[ip][iv];//sbagliato double W = 1./DF2; // ----------- // fill histos // ----------- TH2F* h_qtot_tau = CaloElectron_parameters::Get()->h_qtot_tau[ibintau[ip][iv]][ivv]; if( !h_qtot_tau ) CaloElectron_parameters::Get()->Calibration_SetTools(); // if( !h_qtot_tau )return;; h_qtot_tau->Fill(xy[iv],F); // ------------------------- // evaluate weighted average // ------------------------- int ibin; for(ibin=-1; ibin= xy[iv] )break; } if(ibin==-1)continue;//strip out of range // // problema: quando il segnale e` 0. in realta` e` <0.7 // quindi si introduce un bias... che spero pero` sia piccolo // // CaloElectron_parameters::Get()->summW[ibintau[ip][iv]][ivv][ibin] += W; CaloElectron_parameters::Get()->summWF[ibintau[ip][iv]][ivv][ibin] += W*(double)F; } } } return; }; ClassImp(CaloElectron); ClassImp(CaloElectron_parameters);